Definition and decription of the available WS system variables.
Within the WS platform environment are a number of system variables that can be used for a variety of tasks. These are supported in all released versions of WS and are as follows:
The _ashost variable specifies the actual server name of the given SAP server. Operations can be performed based on a particular system name. This is particularly useful when users are connecting to multiple SAP ERP systems. In the following example we will print out the server:
println("Host>>" +_ashost);
The _client variable can be used to find data on any user in the system. In our example, if we wished to find the current user, and then output that information to the console window, we could write the following code:
println("Current user>>" + _client);
The _clientedition variable is used to gather information about the client side in order to create a single customized script for different platforms. In other words, the script can dynamically relocate a button based on the dimensions of the client platform - for example to based on portrait or horizontal position in the iPad. The variable is formatted in a four-digit number, followed by two integers as in the following example:
XGFS 4 7
This example would be interpreted as shown in the following example.
These parameters are further explained as follows:
The first letter in the _clientedition variable indicates the license type. The available options are as follows:
The second letter denotes the platform - iOS or Windows Mobile. The available options are as follows:
If the second letter is 'G', the third letter specifies the actual iOS hardware. The available options are:
If the second letter is 'M', then the third letter specifies the Windows Mobile hardware. The available options are:
The fourth digit specifies if the software is running on an emulator or on a physical device. The available options are shown below:
The X-parameter for the screen in pixels is placed three spaces after the last digit in the variable. It specifies the screen width in hundreds of pixels. So a screen width of 300 would be designated as '3'.
The Y-parameter for the screen in pixels is placed three spaces after the last digit in the variable. It specifies the screen height in hundreds of pixels. So a screen height of 1400 would be designated as '14'.
In the following example, we will write a script containing switch statements that will trigger particular specifications based on the detected client edition. This way a single script can adapt to any supported platform and the resulting screens will be drawn corrently for that platform.
del("G[Organizational Data]");
var flg = _clientedition;
println("\n***********flg************"+ flg);
for(var i=0;i<10;i++){
println("\n flg[" + i +"]: "+flg[i]);
}
switch (flg[0]){
case "X":
text([4,0], "Client License", {"size":20});
break;
case "E":
text([4,0], "Enterprise", {"size":20});
break;
default:
text([4,0], "X/E error ", {"size":20});
}
switch (flg[1]){
case "G":
text([5,0], "Gala", {"size":20});
break;
case "M":
text([5,0], "Mobile", {"size":20});
break;
default:
text([5,0], "G/M error", {"size":20});
}
switch(flg[2]){
case "S" :
text([6,0], "System", {"size":20});
break;
case "F" :
text([6,0], "iPhone", {"size":20});
break;
case "P" :
text([6,0], "iPad", {"size":20});
break;
case "O" :
text([6,0], "iPod", {"size":20});
break;
case "M" :
text([6,0], "iPad Mini", {"size":20});
break;
case "4" :
text([6,0], "CE4.0", {"size":20});
break;
case "5" :
text([6,0], "CE5.0", {"size":20});
break;
default:
text([6,0], "S/F/P/O/M error", {"size":20});
}
if(flg[2]=="4" || flg[2]=="5"){
text([7,0], flg[4]*10000+flg[5]*1000+flg[6]*100, {"size":20});
text([8,0], flg[7]*10000+flg[8]*1000+flg[9]*100, {"size":20});
}else{
switch(flg[3]){
case "S" :
text([7,0], "Simulator", {"size":20});
break;
case " " :
text([7,0], "Normal", {"size":20});
break;
default:
text([7,0], "S/N error", {"size":20});
}
text([8,0], flg[4]*10000+flg[5]*1000+flg[6]*100, {"size":20});
text([9,0], flg[7]*10000+flg[8]*1000+flg[9]*100, {"size":20});
}
The '_connectiondata' system variable is used to enable scripts to access URL queries and pass them as parameters to Web Server. This is particularly useful when passing a user name and a password to a Web browser. The syntax is as follows.
var obj = eval("(function(){return" + _connectiondata + ";})()");
The '_connectiondata' feature works by setting an object (var obj in our example), which has various properties. These properties correspond to the various parameters in a URL and are used to pass those parameter values to Web URLs. Some of the most ommonly used properties are as follows.
This corresponds to a user name in a Web URL, such as in the following example, where the value of 'obj.user' would be 'sampleuser'.
http://localhost:80/guixt4web/logon.gsp?user=sampleuser&pass=samplepass
This corresponds to a password in a Web URL, such as in the following example, where the value of 'obj.password' would be 'samplepass'.
http://localhost:80/guixt4web/logon.gsp?user=sampleuser&pass=samplepass
This specifies a particular order type for the Sales Order transactions. In our example, we are using the order type 'OR', for a Standard Order, as shown in the example URL below.
http://localhost/guixt4web/logon.gsp?user=dummy&pass=123&task=T1&tcode=va01 &ordType=OR&soldto=1460
This is a value that wil be input into the QPR2 transaction in SAP. In our example, the value is '100000205' as shown in the example URL below.
http://localhost/guixt4web/logon.gsp?user=dummy&pass=123&task=T2&tcode=qpr2 &sample=100000205
This is the customer code that will be input into the Sales Order transactions. In our example, the value is '1460' as shown in the example URL below.
http://localhost/guixt4web/logon.gsp?user=dummy&pass=123&task=T1&tcode=va01 &ordType=OR&soldto=1460
This specifies an action that can be executed by the script. in the following example, the action will be to perform a switch, where depending on the parameters passed, we can perfrom multiple actions.
switch(obj.task){
case 'T1':
if(obj.user && obj.pass){
set("F[User]",obj.user);
set("F[Password]",obj.pass);
}
enter({'process':goto_va01,"using":{"tcode":obj.tcode,
"ordType":obj.ordType,
"soldto":obj.soldto}});
break;
case 'T2':
if(obj.user && obj.pass){
set("F[User]",obj.user);
set("F[Password]",obj.pass);
}
enter({'process':goto_qpr2,"using":{"tcode":obj.tcode,
"sample":obj.sample}});
break;
The URLs for Case T1 and T2 from the above script would be as follows. The values for the ordType and soldTo are provided by the URL and are passed to the SAP transaction by the processes.
http://localhost/guixt4web/logon.gsp?user=dummy&pass=123&task=T1&tcode=va01 &ordType=OR&soldto=1460
http://localhost/guixt4web/logon.gsp?user=dummy&pass=123&task=T2&tcode=qpr2 &sample=100000205
This specifies a transaction code, and is one of the parameters that can be included in a URL. You can also specify the tcode manually in the process. An example URL with a tcode is shown below.
http://localhost/guixt4web/logon.gsp?task=T5&tcode=qpr2&sample=100000205
The full example script using '_connectiondata' is shown below.
println('Executing Web UI Scripts..........');
try{
println(_connectiondata);
var obj = eval("(function(){return" + _connectiondata + ";})()");
println('Priniting objec: '+obj);
var task;
println('-----------------------------------: ' + obj.task);
if(obj.task){
switch(obj.task){
case 'T1':
if(obj.user && obj.pass){
set("F[User]",obj.user);
set("F[Password]",obj.pass);
}
enter({'process':goto_va01,"using":{"tcode":obj.tcode,"ordType":obj.ordType,"soldto":obj.soldto}});
break;
case 'T2':
if(obj.user && obj.pass){
set("F[User]",obj.user);
set("F[Password]",obj.pass);
}
enter({'process':goto_qpr2,"using":{"tcode":obj.tcode,"sample":obj.sample}});
break;
case 'T3':
if(obj.user && obj.pass){
set("F[User]",obj.user);
set("F[Password]",obj.pass);
}
enter({'process':goto_va03,"using":{"tcode":obj.tcode,"order":obj.order}});
break;
case 'T4':
task = obj.task;
break;
case 'T5':
task = obj.task;
break;
case 'T6':
task = obj.task;
break;
}
}
}
catch(e){
println(e.description);
}
function goto_va01(param){
onscreen '*'
enter(param.tcode);
onscreen '*'
set('F[Order Type]',param.ordType);
enter();
onscreen '*'
set('F[Sold-to Party]',param.soldto);
enter();
}
//Sample : 100000205
function goto_qpr2(param){
onscreen '*'
enter(param.tcode);
onscreen '*'
set('F[Physical sample]',param.sample);
enter();
}
function goto_va03(param){
onscreen '*'
enter(param.tcode);
onscreen '*'
set('F[Order]',param.order);
enter();
}
An HTML page of sample URLs are shown in the following screenshot. Each URL contains some parameters that will be accessed by the script.

The _database variable can be used to perform operations based on the database or to simply find which database is being used. To find the database and to output that information to the console, we would write the following:
println("Database>>" +_database);
A DynPro is the actual SAP program name. Each SAP program is identified by a dynpro number. Examples of dynpro numbers are the following:
The dynpro is used with the language code and the program name to identify a given SAP screen. The _dynpro variable is used to find which dynpro is currently being accessed or to perform operations based on a particular dynpro number. In our example, we will simply find out which dynpro we are accessing and output that information to the console:
println("DynPro>>" +_dynpro);
The _language variable is used to return the current language code of a given implementation. If users are operating in different languages, this variable is useful for specifying the different language files or different operations for different users based on language. To find the current language and output that information to the console, we would write the following:
println("The language is>>" +_language);
The _listfirstvisiblerow system variable is used to specify the first row of a list screen that is visible to a user. In the following example, we will use this to obtain the first visible row for the 'Assigned Source of Supply to Requisitions' list screen contained in the ME56 transaction. The code in the RM06BL00.E0120.sjs script file would be as follows:
println("First visible row is>> " + _listfirstvisiblerow);
The _listlastvisiblerow system variable is used to specify the last row of a list screen that is visible to a user. In the following example, we will use this to obtain the last visible row for the 'Assigned Source of Supply to Requisitions' list screen contained in the ME56 transaction. The code in the RM06BL00.E0120.sjs script file would be as follows:
println("Last visible row is>> " + _listlastvisiblerow);
The _liststring system variable is used to obtain the cursor's current position on the list screen; not the full content of the row where cursor is. In the following example, we will use this to obtain the cursor's current position on the 'Assigned Source of Supply to Requisitions' list screen contained in the ME56 transaction. The code in the RM06BL00.E0120.sjs script file would be as follows:
println("Current cursor position is>> " + _liststring);
The _message variable is used to return various SAP system messages. Various levels of messages can be defined; the default is to return everything. Status messages can be output either to the SAP screen or to the console. To see current messages in the console window, use the following:
println("Messages>>" +_message);
The _page.exists property is used to identify individual tabs in a transaction. For example, the SAPMV45A.E4001 screen in the VA01 transaction has a number of tabs, as shown below:

With _page.exists, you can perform operations based on which tab of a given page is being edited, as shown in the following example:
if(_page.exists("Sales")) {
set("F[Sold-to party]", "1460");
}
You can also use the _page.exists command to verify if a given tab or page is actually present as shown in the above example.
Every dynpro has a program name associated with it, as shown in the following examples:
The _program variable returns the program name for the current screen. To return the current program number to the console, the following code can be used:
println("Program>>" +_program):
This variable retrieves the screen title where the user currently resides. An example is shown below:
println("Screen title is>>" + _title);
The _transaction variable is used to identify individual SAP transactions. It differs from the '_page' variable in that it refers to the transaction ID, such as 'VA01' as opposed to the actual page, which could be something quite different. Operations can be performed based on the transaction ID, as shown in the following example:
if(_transaction=="va01") {
set("F[Order Type]", "OR");
}
The _user variable specifies the current user. To find the user information and output it to Console, the following code can be used:
println("User>>" +_user);