Skip to Content
0
Sep 26, 2018 at 06:28 PM

SAPUI5 Barcode Listener

569 Views

Hi I just developed a UI5 application (acceded through the Fiori LPD) that requires bar code scanning. For this I used a regular button:

<Button icon="sap-icon://bar-code" id="buttonScan" press="onPressScan" visible="{device>/system/phone}" />

And in the "press" action I used the code:

onPressScan: function (oEvent) {
	sap.ndc.BarcodeScanner.scan(
		function (mResult) {
			if (!mResult.cancelled && mResult.text.length > 0) {//action}
		},
		function (sError) {//error handling},
		function (mLive) {
			if (mLive.newValue && mLive.newValue.length > 0) {//action}
		}
	);
}

It works nice using the SAP Fiori Client, accessing the device's camera after tapping over the scan button.

The thing is: The customer is using iPods with a barcode sleeve (I don't know which brand) and they want to capture the scanned value and pass it to the application without tapping the button.

Is it possible to implement something like a listener to catch the barcode sleeve scanned value into my app?

Regards,

Gregory Mayorga