12 - Enable App to Select Product by Scanning Barcode
Show some of the native mobile capabilities of SAP Build Apps by allowing users to select a product by scanning a barcode, as part of the SAP Build CodeJam.
One of the best things about SAP Build Apps is that you can easily enable basic but powerful native mobile features โ such as access to contacts and photos, the camera, location services and more.
In this tutorial, you will let you scan a barcode in order to select a product, instead of having to select from the list on the home page.
Step 1Install preview app on your device
โ
To get and set up the SAP Build Apps Mobile Preview App, watch and follow along with this video from Daniel Wroblewski.
Step 2Add UI for barcode scanning
+
Go to the home page.
Select User Interface.
Back home
Right now, you have a title component.
UI title
Add a Row component just above the title.
When you drag in a row component, it will automatically contain 2 cells.
Add row
Move the existing title component into Cell #1.
Move title
In Cell #2, add a container, and in the container add a text and icon component.
The UI should look like this:
New UI
Select the row component (use the tree view), and in the Layout tab click the first 50%.
Alt text
Set the cell width to 5.
Cell width
Now click the other side, now 0%, and then enter for the cell width 3.
Cell width, again
This now sets the relative widths of the cells.
Row widths
Finally, set Align cell content to align bottoms.
Select the container in Cell #2, and in the Layout tab, in the Layout section, set the layout to Horizontal.
Container layout
Select the text component (in Cell #2) and set the following.
Under Properties, set Content to Click to scan product.
Text
In the Style tab, click the Primary Paragraph dropdown, and click Edit.
Edit style
Under Typography, set Text size to Small text.
In the Layout tab, in the Layout section, change Text align to right.
Select the icon component (the star in Cell #2), and set the following.
Under Properties, in the Icon property, click the word star.
Select star
Enter barcode in the search, and click the barcode symbol.
Icon
Under Style, click the Primary Icon dropdown, and click Edit.
Style edit
Under Typography, change the binding type for Font size to Static number, and change the font size to 60.
Your UI should now look like this:
Final UI
Step 3Add logic to scan barcode
+
Now lets create the logic for handling the tap of the barcode icon.
Select the icon component, open the logic canvas (at the bottom).
Open icon logic
Create the following logic, and connect the flow functions as shown.
Basic logic
The logic opens the barcode scanner, and if the user actually selects a barcode, then you test that value.
If the value is a product number and in our list of products โ held in our data variable โ then you navigate to the product details page.
If the value is not a product, you just alert the user.
IMPORTANT: You must connect the top output of he QR code flow function with the If condition flow function.
For the If condition flow function, set the Condition to the following formula:
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 4
1. Install preview app on your device2. Add UI for barcode scanning3. Add logic to scan barcode4. Test with preview app
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.