You cannot build a general-purpose "code scanner" inside SAP the way you would in a consumer barcode app, but you can absolutely build a working scanner program in SAP that reads barcodes or QR codes, decodes them, and writes the result into a SAP transaction or table. The realistic path is: use SAP's built-in scanning framework (SAPUI5 or Fiori Elements with the BarcodeScanner control, or the classic ITSmobile/WebDynpro HTMLBarcodeReader for GUI-based scanning), or call a device scanner through a native mobile app that posts into SAP via OData or a custom RFC. For most home and small-business users, the shortest working route is an SAP Fiori app using the sap.ndc.BarcodeScanner control or the newer sap.m.BarcodeScanner control, which calls the phone camera and returns the decoded string to your JavaScript controller. That string is then sent to an OData service or a custom function module that does the lookup or posting. If you only need to scan into a SAP GUI screen, a keyboard-wedge USB scanner does the job with no code at all — it types the barcode as keystrokes — and that is the method SAP itself documents for classic GUI transactions.

What You'll Need

  • Access to a SAP system with developer authorization (SAP GUI with SE38, SE80, SE11, SE37, and either SEGW or the ABAP RESTful Application Programming Model tooling).
  • An SAP Fiori development environment or SAP Business Application Studio if you are building the UI5 side.
  • A barcode or QR code to test with — printed or on screen.
  • A device with a camera (phone or tablet) for camera-based scanning, or a USB/Bluetooth keyboard-wedge scanner for GUI scanning.
  • An OData service or RFC-enabled function module to receive the scanned value.

Step-by-Step

  1. Decide which scanner type you need. Keyboard-wedge scanners (USB or Bluetooth) act as a keyboard: they type the barcode into whatever field has focus in SAP GUI. Camera-based scanning requires a Fiori/UI5 app because the camera is accessed through the browser or the SAP mobile app. Pick one before you start — mixing them mid-build causes confusion.
  2. For SAP GUI only: plug in the keyboard-wedge scanner, open the target transaction (for example MIGO for goods movements or MB51 for material document lists), click into the field that should receive the barcode (material number, document number, handling unit), and scan. The scanner types the value and usually sends an Enter keystroke. No ABAP code is needed for this path.
  3. For a camera-based Fiori app: create a new SAPUI5 project in SAP Business Application Studio (or your IDE of choice) using the SAP Fiori application template. Choose a freestyle SAPUI5 app if you want full control over the scanner control.
  4. Add the scanner control. In the view XML, add the sap.ndc.BarcodeScanner control (or sap.m.BarcodeScanner depending on your UI5 version — labels and control names can differ slightly by version). Bind a button press to a controller function that calls BarcodeScanner.open or the control's scan method.
  5. Handle the result in the controller. In the success callback, read oResult.text (the decoded string) and oResult.format (the symbology, e.g. EAN-13, QR, Code 128). Store the text in a JSON model so it appears on screen, and pass it to your OData call.
  6. Build the backend receiver. In the SAP system, create an OData service (SEGW) or a RESTful service with a function import / POST entity that accepts the scanned string. In ABAP, read the string, validate it against the expected format, then perform the lookup (for example SELECT SINGLE matnr FROM mara WHERE ean11 = @lv_scanned) or the posting (BAPI_GOODSMVT_CREATE for goods movements).
  7. Wire the app to the service. In the UI5 manifest, add the OData model pointing to your service URL. In the controller, call oModel.create or the function import with the scanned text as a parameter. Show a success or error message back to the user.
  8. Test with real codes. Scan a known barcode and confirm the decoded string matches what the backend expects. Test an unknown code too — the app should show a clear "not found" message rather than crash. Test on the actual device you will use, because camera permissions and browser behaviour differ between iPhone and Android.
  9. Deploy. Publish the app to the SAP Fiori launchpad or your BTP subaccount. Grant the required authorizations (the OData service and any BAPI need their own authorization objects).

Common Mistakes

  • Assuming a keyboard-wedge scanner needs code. It does not — it types into the focused field, so the field must be selected first.
  • Forgetting camera permissions. On iPhone and Android, the browser or SAP mobile app must be allowed camera access, or the scanner control returns nothing.
  • Not validating the scanned string on the backend. A barcode can contain characters that break your SQL or OData filter — always validate and escape.
  • Mixing symbologies. EAN-13, Code 128 and QR return different string lengths and formats; your backend must know which one it expects.
  • Testing only on desktop. Camera scanning behaves differently on mobile browsers, and the SAP mobile app has its own permission model.

Tips

  • Use the keyboard-wedge path for classic GUI transactions — it is the fastest, cheapest and most reliable option for MIGO, MB51, HU02 and similar screens.
  • Keep the decoded string in a JSON model so you can display it, re-use it, and log it for debugging.
  • Add a manual-entry fallback field next to the scan button — cameras fail in low light and on damaged labels.
  • Log the raw scanned text and the symbology in your backend so you can diagnose "not found" errors later.
  • If you are scanning into a web UI, confirm the browser supports the camera API you are using; older or locked-down browsers may block it.

Troubleshooting

If the scanner does nothing in SAP GUI, click into the target field first — keyboard-wedge scanners type into whatever has focus, and a lost focus means lost keystrokes. If the camera-based scanner returns nothing, check camera permissions in the device settings and confirm the browser or SAP mobile app is allowed to use the camera. If the scanned value arrives but the backend rejects it, log the raw string and compare it character by character with the expected format — leading zeros, check digits and symbology prefixes are the usual culprits. If the OData call fails, check the service is activated in SICF and that your user has the authorization objects for the service and the underlying BAPI. If the app works on desktop but not on mobile, test the camera permission flow on the actual device — iPhone and Android handle it differently, and the SAP mobile app has its own settings.

Frequently Asked Questions

Can I scan barcodes in SAP GUI without writing code?

Yes. A USB or Bluetooth keyboard-wedge scanner types the barcode into the focused field in any SAP GUI transaction. No ABAP or UI5 code is required.

Which SAP control handles camera scanning?

The sap.ndc.BarcodeScanner and sap.m.BarcodeScanner controls in SAPUI5 open the device camera and return the decoded text and symbology to your controller. Exact control names can differ by UI5 version.

Does the scanner work on iPhone and Android?

Yes, provided the browser or SAP mobile app has camera permission. The permission flow differs between iOS and Android, so test on the actual device.

Where does the scanned value go?

Into whatever field or variable you bind it to. In a Fiori app, the controller receives it and can post it to an OData service or RFC-enabled function module; in SAP GUI, it lands in the focused input field.

Can I scan QR codes as well as barcodes?

Yes. The UI5 scanner controls and most keyboard-wedge scanners support QR, EAN, Code 128 and other common symbologies. Confirm the symbology your backend expects, because the decoded string format differs.

Do I need a special license for scanning?

No separate scanner license is required. You need the standard SAP developer authorizations to build the app and the usual authorization objects for the OData service or BAPI it calls.