Scan Bar Code Integration in SAP UI5

by | Mar 14, 2023 | UI5, UI5 Integrations

Home » SAP » UI5 » UI5 Integrations » Scan Bar Code Integration in SAP UI5


In SAP’s world, the UI5 and Fiori Apps are used extensively to perform a large number of operations. Among these operations, there is a common requirement of a warehouse to scan a barcode pasted over a material and get the material number from it. It is similar to the bar code scanning you might have seen at a shopping mall outlet. In this article, we will learn simple steps for Scan Bar Code Integration in SAP UI5

Pre requisite of Bar Code Scanning in SAP UI5 via Mobile

The bar code scanning works fine on a laptop, but to make it work on a mobile phone or a tablet, you need to deploy your UI5 application as a Fiori Application. The fiori application should be used via the Fiori Launchpad mobile application. You can download the same from here:

SAP Mobile Start: Fiori Launchpad for Android

SAP Mobile Start: Fiori Launchpad for iOS

Steps to create an SAP UI5 to scan a barcode

To create a scanning app, follow the steps below:

1. Create a UI5 project in any IDE

2. Create a view and add a button to start scanning, and an input box to get the scanned data. The code would be like mentioned below:

<mvc:View controllerName="Test.Test.controller.Main" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m" xmlns:core="sap.ui.core"
    <Shell id="shell">
        <App id="app">
                <Page id="page" title="Scan Bar Code Integration in SAP UI5">
                            <Button icon="sap-icon://bar-code" text="Scan" press="onScan"/>
                            <Label text="Material"/>
                            <Input id="materialNumber" value=""/>

Step 03: Add BarcodeScanner namespace and use it to scan the bar code, as shown below:

], function (Controller, MessageBox, MessageToast, JSONModel, BarcodeScanner) {
    "use strict";
    return Controller.extend("Test.Test.controller.Main", {
        onScan: function (oEvent) {
            var that = this;
                function (mResult) {
                    if (!mResult.cancelled) {
              "We got a bar code\n" +
                            "Result: " + mResult.text + "\n" +
                            "Format: " + mResult.format + "\n");
                function (Error) {
                    alert("Scanning failed: " + Error);

Note: If your scanning is not getting started, turn on the given extension in WebIDE:

Hybrid App Toolkit


Before Scanning

Scan Bar Code Integration in SAP UI5 Before Scanning

During Scanning

Scan Bar Code Integration in SAP UI5 During Scanning

After Scanning

Scan Bar Code Integration in SAP UI5 After Scanning

1 Comment

  1. Gaurav Varshney

    If we have multiple details in the QR or Barcode how we can scan the details and show all the details in different input field


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.