on 01-31-2018 12:23 AM
I am really excited about the SlipStream engine in SP 06 and understand native device features of mobile devices can be utilized. I am trying to figure out how to use the native device camera to scan a barcode. Would really appreciate if someone could give some insights on how this can be achieved using Screen Personas 3.0 SP 06...
Thank you.
For this to work you need to run your slipstream flavours in the Fiori Client app rather than the device browser. This gives you access to the camera and other local devices. Once you are running in the Fiori Client, accessing the camera is fairly straightforward. The code looks like this:
function scanSuccess(result) {
var matnr = result.text;
session.utils.log("Scan succeeeded: " + matnr);
// Small hack to force a screen refresh after a field update
// in this asynchronous callback function
session.utils.put("message", matnr);
session.utils.executeScript("wnd[0]/scrptPersonas_005056840F9E1ED7BDAC77341716A0F9");
}
function scanError(error) {
session.utils.alert("Scan failed");
}
if(typeof cordova != "undefined") {
cordova.plugins.barcodeScanner.scan(scanSuccess, scanError);
} else {
session.findById("wnd[0]/usr/txtPersonas_151368242701275").text = "No scanner found";
}
Some things to note:
var matnr = session.utils.get("message");
session.findById("wnd[0]/usr/txtPersonas_151368242701275").text = matnr;
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using "executeScript" to update the field values, rather than a simple assignment, is meant to work around this problem. As I said above, "executeScript" should force a screen refresh. There's more detail now in this wiki page: https://wiki.scn.sap.com/wiki/display/Img/Scripting%3A+Building+flavors+with+Barcode+scanning+functi...
Steve.
I did that:
function scanSuccessCallback(result) {
if (!result.cancelled) {
var barcode = result.text;
session.utils.log("scanned value: " + barcode);
session.utils.put("scanvalue", barcode);
session.utils.executeScript("wnd[0]/scrptPersonas_080027E59F2C1ED8859A87D40EF060EE");
} else {
session.utils.alert("Cancelled!");
}
}
function scanErrorCallback(error) {
session.utils.alert("Scann Failed");
}
var cordova = window.parent.cordova;
if (cordova) {
cordova.plugins.barcodeScanner.scan(scanSuccessCallback, scanErrorCallback);
} else {
session.utils.alert("API not working!");
}
<br>
Where is my mistake?
Hi,
I am running the SAP Screen Personas 3.0 SP07 flavor as a tile in FIORI launchpad using slipstream engine on SAP FIORI client app on iOS device.
Everything works well except for scanning the bar code, I used the code as mentioned in your post, however I end up in "No scanner found", i am not sure why is it not finding the cordova plugins, I have downloaded the recent FIORI client app from the app store.
Any advice, is the sample code you have put in does it work or need any tweaks ?
With Kind Regards
Guru
Hi,
I tried Steve's script, but got "No scanner found". I will appreciate anyone to share the solution. @Guru, did you get any solution to share? Deborah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.