Skip to content

Blogs

How to disable keyboard for an RF Scanner in SAP Slipstream

Problem Statement: When using an RF scanner on a mobile device, the on-screen keyboard often pops up when a field is tapped. This disrupts the RF scanning experience, especially for SAP RF Android users, as they simply want to scan a barcode without the need to close the keyboard. The challenge is to find a way to disable the on-screen keyboard while still allowing RF scanner input.

Picture 1

Option Findings:

Finding 1:
We considered implementing a custom keyboard, like the ‘Null keyboard,’ from the app store. This would make the keyboard invisible, preventing it from popping up during RF scanning. However, this option was not feasible since the user might still need to type in values when no barcodes are available, limiting the flexibility of RF scanners in SAP environments.

Finding 2:
Setting a field to readOnly (enabled = false) prevents the on-screen keyboard from appearing. However, since RF scanners simulates a keyboard input, the scanned value wouldn’t paste into the read-only field. This limitation posed a problem for SAP RF Fiori users who rely on seamless RF scanning.

Finding 3:
We explored plug-ins like ‘Cordova Ionic-Keyboard’ for better control over keyboard behaviour. After developing a custom SAP RF Fiori Client, we could use a ‘keyboard.hide()’ command to close the on-screen keyboard instantly. However, the keyboard still appeared briefly, disrupting the RF scanning experience.

Finding 4:
Standard Android API functions offered potential solutions, but they were inaccessible due to our use of Slipstream and SAP Screen Personas. This limitation hindered our ability to fully control the RF scanner function keys and disable the on-screen keyboard effectively.

The Fix:
Finally, we discovered a setting within the RF scanner device’s configuration (e.g., DataWedge) that allowed scanned values to be sent directly to the front-end layer. By using a ‘keypress’ event listener, we captured each scanned character, storing it in a global array. This method allowed us to disable the on-screen keyboard and ensure smooth RF scanning without interruptions.

This lead us to try using a standard browser event listener called ‘keypress’, which as the name suggests, will run a function every time a key is pressed.

In our scenario, the scanned value is sent 1 character at a time instead of all at once. This means whatever function we attach the keypress event will run over and over again until it’s finished. This meant any variable we defined in the function was getting overwritten by the next character, so the final result was just the last character of the scanned value.

What we ended up doing was defining a global array, and inside the keypress function we simply pushed the sent character into that array. We chose to store the array globally as we wanted to access this array in a 2nd screen personas script which we would call asynchronously.

As we now had a way to capture the scanned value in the scripting engine, we could go back to the earlier finding and make the field readOnly which would prevent the keyboard appearing.

 


Script 1:

window.removeEventListener(‘keypress’, window.ourFunction , true);
window.arrayName = [];

window.ourFunction = function(e) {
if(document.activeElement.readOnly){
window.arrayName.push(e.key);

}

if (window.ArrayName.length === 20){
session.utils.executeScriptAsync(‘2nd script ID’);
}
};

window.addEventListener(‘keypress’, window.ourFunction , true);


Script 2:

var value = window.arrayName.join(”);

session.findById(“fieldID”).text = value;


The above Script 1 code is added to the onLoad event of the Slipstream transaction.

To summarise what it does:

  1. Removes any existing function added to the keypress event. This is because we attach it globally, so if we add it to 1 transaction and then navigate to another transaction, it will still exist.
  2. Define the global array that will hold the scanned characters
  3. Create the function which says, if the currently focused element is read only (so we know its the correct field we are scanning to), then push the pressed key to the global array
  4. As stated earlier, the function will run every time a character is sent, which may result in a performance lag if the value is large. To work around this we add an if condition which only runs if the global array length hits 20. In our case we say 20 because the example field is for SSCC in the warehouse and we know it is always going to be 20 characters long. In your case this field length may be different, so adjust to fit. The if condition calls the 2nd above script which will paste the value into the field
  5. Add the function fo the keypress event.

Script 2 is called from within script 1 and simple combines all the values in the global array into a single string and then pastes it into the desired field.

By focusing on the right configurations and using custom scripting, we successfully streamlined the RF scanning experience in SAP environments, particularly for those using SAP RF Android devices. The solution also allows for the simple disable key function and ensures the SAP RF scanner operates efficiently without unnecessary disruptions from the on-screen keyboard.

For more guides on SAP Screen Personas, read our guide on Create Purchase Requisitions in Slipstream

Dan Barton

Partner & Co-Founder of Bluestonex

Knowledge Bank

Dive into our collection of expert insights, industry guides, and thought leadership pieces. From practical tips to in-depth explorations, our blogs and guides are designed to help you stay ahead in the ever-evolving world of SAP solutions, data management and digital transformation.