I was trying to make my code look more clean by storing some function code in a own function. However this did not work out. No error is logged in the console.
This is my code:
onPressScan: function() {
sap.ndc.BarcodeScanner.scan(
// calling the function at this point works
function(mResult) {
if (!mResult.cancelled) {
// call another function from the same controller
this.handleData(mResult.text);
}
},
function(Error) {
sap.m.MessageBox.error("Scanning failed due to following error: " + Error, {
title: "Error while scanning"
});
}
),
handleData: function(data) {
sap.m.MessageBox.success("Calling function worked: " + data, {
title: "Success"
});
}
For testing purpose I minimized the handleData function to a minimum. What I just tried was calling the function one layer above (not threw two function calls...). This works. However, I need to call the function where you can see it in the code. How can I achieve that?
Thank you.