Playing SAP ITS sounds on Windows Mobile and CE Devices with Enterprise Browser
I had seen many support questions on playing SAP ITS mobile application transaction sounds on Enterprise Browser. Earlier, I had written blog on playing SAP ITS mobile sound on Android version of Enterprise Browser which can be found here.
From Enterprise Browser 2.0 onward, separate apk file is available only for SAP ITS customers; which has an inbuilt support for playing sap transaction sounds.
Unlike Android users, Enterprise Browser does not provide any SAP specific package for windows customers. For windows, it involves additional configuration to enable SAP ITS transaction sounds on Enterprise Browser.
This blog talks about enabling SAP ITS sounds on Enterprise Browser with Webkit engine on Windows Mobile and CE devices.
Why SAP Sounds are not played by default on Webkit Engine?
SAP ITS plays various sound to notify its users whether the server transaction was a failure or success. SAP ITS achieves this by presenting a
Enterprise Browser JavaScript Library
Enterprise Browser provides utility javascripts for playing a sound file that resides locally on the device. Similarly, it also provides a javascript API to transfer a file from remote location to device. We are going to use these APIs via dominjection to enable SAP ITS mobile sound support on Enterprise Browser with Webkit engine.
Enterprise Browser provides, fileTransfer scriptable object and generic scriptable object by default on the DOM window. Users should ensure that below Config.xml attribute is enabled for getting Enterprise Browser specific scriptable objects on the DOM Window.
Enterprise Browser DOMInjection Technique
Enterprise Browser allows users to inject a custom script file resides on the device to the SAP pages loaded on the Webkit engine. User just needs to develop his script and configure the same on the Enterprise Browser.
Script for playing the tag
Whenever a SAP page is loaded after any server transaction, we do a search for
Below script does the search for the tag
var bgs = document.getElementsByTagName('bgsound');
below script transfer the sound file from SAP server to device using Enterprise Browser Javascript API
for (var i=0; i
{
var attribute = bgs[i].getAttribute("src");
var newURL = window.location.protocol + "//" + window.location.host + attribute;
newURL = "url('"+newURL+"')";
fileTransfer.source = newURL;
fileTransfer.destination = "url('file://\\Program Files\\EnterpriseBrowser\\HTML\\sapsound.wav')";
fileTransfer.transferEvent = "url('JavaScript:handleResult(%json);')";
fileTransfer.overWrite = true;
fileTransfer.transfer();
}
Below script plays the transferred sound file when a transfer callback is fired from Enterprise Browser
function handleResult(params)
{
generic.PlayWave('\\Program Files\\EnterpriseBrowser\\HTML\\sapsound.wav', 0);
}
Below is the complete script that can be copied and saved into a file named customsound.js
(function ()
{
var bgs = document.getElementsByTagName('bgsound');
for (var i=0; i
{
var attribute = bgs[i].getAttribute("src");
var newURL = window.location.protocol + "//" + window.location.host + attribute;
newURL = "url('"+newURL+"')";
fileTransfer.source = newURL;
fileTransfer.destination = "url('file://\\Program Files\\EnterpriseBrowser\\HTML\\sapsound.wav')";
fileTransfer.transferEvent = "url('JavaScript:handleResult(%json);')";
fileTransfer.overWrite = true;
fileTransfer.transfer();
}
})();
function handleResult(params)
{
//alert('Download Result:' + params['transferResult']);
generic.PlayWave('\\Program Files\\EnterpriseBrowser\\HTML\\sapsound.wav', 0);
}
Configuring Enterprise Browser to DomInject
To inject any user created javascript file without modifying server application, user needs to include the javascript file names inside ‘tags’ file. To know more about dominjectiong ‘tags’ file grammar, please click here.
Below is the entry present inside ‘tags’ file in our case
Above 'tags' file content informs Enterprise Browser that a file named customsound.js needs to be injected on all navigated pages. It also provides the absolute path to customsound.js file on the device.
Let us name the ‘tags’ file as mytags.txt and place it under installed directory on the device. Once mytags.txt and customsound.js file are copied to installed directory, we need to inform Enterprise Browser about ‘tags’ file location on the device. This can be configured inside Config.xml as below
Play Sound Using New Configurations
Once the Config.xml is modified to configure the ‘tags’ file path, user can place the customsound.js file and mytags.txt file to the installed directory. Similarly, place the modified config.xml file to the Config folder. Once the files are copied, user can launch Enterprise Browser to validate the SAP ITS sound support.
Playing Custom Sound
Having this configuration enabled with Enterprise Browser, users can also play custom sound file without modifying server application.
User may have to change his script inside customsound.js file.
For example, user prefers to play different sound file for error scenarios. User can have a check for sound file name in his script as below
var bgs = document.getElementsByTagName('bgsound');
for (var i=0; i
{
if(attribute.indexOf("sapsounderr.wav") !== -1)
{
generic.PlayWave('\\Program Files\\EnterpriseBrowser\\HTML\\myError.wav', 0);
break;
}
}
Above example looks for the sound file name presented by the SAP server and based on the file-name, script takes a call to play preferred sound file present on the device.
Conclusion
DomInjection is a feature that enables user to inject custom scripts, CSS, meta tags on to DOM without modifying the SAP server application.
Users can inject custom script to invoke Enterprise Browser javascript APIs to do magics without modifying server applications. A working sample tested on MC32 CE7 device is attached with the blog.
Sabir Valappil Thattath
Replies