The session script file (for English this is named 'esession.sjs') is used to contain any functions or commands that need to be loaded when you launch a new session in SAP. Like the logon script file, this file is not required for a WS implementation, but it is good practice to use it if you have elements that need to be loaded or called when a new session starts. Anything contained in the session script file will be used universally in your scripts for that particular session.
Session scripts are named by prefixing a one-digit language code to the word 'session'. So for English, a session file would be named 'esession.sjs', while for Japanese, the file would be named 'jsession.sjs', a French session script would be 'fsession.sjs' and so forth.
Like the 'elogon.sjs' file, there is no specific set of elements that will always be included in this file - its contents are dependent on the needs of a particular implementation. An example esession.sjs file is shown below.
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, "");} //Creates a string prototype function
currentUser = _user.toLowerCase().trim();
println('########## current user: ' + currentUser);
switch(currentUser) {
case "maki":
{
currentDirectory = "d1=C:\\GuiXT\\WSScripts" //Real Demo
break;
}
case "demo1":
{
currentDirectory = "d1=C:\\GuiXT\\Demo3_Scripts" //Test1
break;
}
case "demo2":
{
currentDirectory = "d1=C:\\GuiXT\\Scripts" //Working folder
break;
}
case "jasupport1":
{
currentDirectory = "d1=C:\\GuiXT\\Demo_Scripts" //Training
break;
}
case "jasupport2":
{
currentDirectory = "d1=C:\\GuiXT\\Demo2_Scripts" //Excel demo
break;
}
default:
{
currentDirectory = "d1=C:\\GuiXT\\WSScripts"
break;
}
}
In this session script, we have created a switch statement so that for each of several different users, the default script directory will be set to the correct directory for that particular user when the session starts.