Liquid UI - Documentation - 4.01 WS Special Scripts

4.01 WS Special Scripts


WS special script files are distinct from the script files that are associated with the SAP dynpros. These files include the following types:

Logon Script

The Logon script is typically used to run specific tasks that need to be loaded or run at logon, helping users get the right SAP screens.

Session Script

The session script is similar to the logon script and runs each time a new session is started. This script can automate tasks that should occur each time a user opens a new SAP session.

Function Script

The function script defines reusable functions that can be accessed across all SAP transactions. You can place any function you want to access across all transactions in the functionsSystem.sjs script file. This special script file will help you with code optimization, improving the script’s quality.

Each of these script files is explained in detail in the following sections:

Logon Script (elogon.sjs)

The logon script file allows you to add functions or commands that need to be loaded during the logon process. Although this file is not mandatory for a WS implementation, it can be helpful when specific files need to be loaded or called at logon time. The logon script will be used across all SAP transactions and is not restricted to a single session. Below is an example of a logon script file:

elogon.sjs

load('wsoffice');
load('functionsSystem.sjs');
function getFilesToUpload(szPrompt)
{  
    if(szPrompt==void 0) szPrompt = 'Select File';
    var dialog = new ActiveXObject('MsComDlg.CommonDialog');  
    dialog.Filter='All Files(*.*)|*.*';  
    dialog.MaxFileSize=32767;  
    //dialog.AllowMultiSelect = true;
    dialog.DialogTitle=szPrompt;
    dialog.Flags=0x200|0x80000|0x800|0x4|0x200000  
    dialog.ShowOpen();  
    //var ret = dialog.FileTitle;
    var ret = dialog.FileName;
    dialog = void 0;
    return ret;
} 

In the above script, you can see a set of libraries for the WSOffice extension. Functions stored in an external script file are called using the load command and include a function that can access specific files for uploading. Although this particular logon script is from an Offline implementation, it can be used in any interface.

The logon script is typically named elogon.sjs, regardless of the target language, where e indicates English. If you name the logon script anything other than elogon.sjs, it will not be read.

Following are the commonly used commands in the logon script file.

load command

The load command is used to load external files or libraries for the WS engine to utilize.

Click here for details on the load command.

onscreen command

The onscreen command defines a specific screen where an operation will occur.

Click here for details on the onscreen command.

set command

The set command is used to add value to a given object in SAP.

Click here for details on the set command.

 

Note: You will receive license remainder emails from the LAMP at regular intervals to remind you about soon-to-expire licenses.

 

Session Script (esession.sjs)

The session script file (for English, it is named session.sjs) contains functions or commands that need to be loaded when a new SAP session is launched. While this file is not required for a WS implementation, it is considered good practice to use it if there are elements that need to be loaded or called upon session startup. Anything in the session script file will be applied universally to your scripts for that particular session.

Similar to the elogon.sjs file, there is no predefined set of commands or elements that must be included. The content of the script's depends on the specific needs of the implementation. Below is an example of the esession.sjs file:

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 the session script, a switch statement is created to assign the appropriate default script directory for each user when the session begins, ensuring it points to the correct directory for each specific user.

Functions Script(functionsSystem.sjs)

The functions script file is used to store any functions or commands you want to be accessible across all script files. This simplifies script management by centralizing functions in a single location. Having a single file with all your functions enhances portability. Since this script is separate from the transaction-specific scripts, it promotes code reusability, allowing functions to be used across various SAP transactions. Below is an example from a functionsSystem.sjs file.

 
/*
**	Open Excel file
*/
function open_excel(filename)
{
    if(g_ExcelApp == void 0)
	g_ExcelApp = new ActiveXObject('Excel.Application');
    g_ExcelBook = g_ExcelApp.Workbooks.Open(filename);
    g_ExcelApp.Visible = true;
    g_ExcelApp.ScreenUpdating = true;
}

/*
**	get first item level column number (needs to be populated in to a table)
*/
var firstItemColumn;
function get_first_item_column(activesheet){
	//find firstItemColumn
	var lastCol = 3;
	for (var nCol=2; nCol < lastCol; nCol++){
		if (activesheet.Cells(1,nCol).Value.indexOf(",") > -1){
			firstItemColumn = nCol;
			break;
		} else {
			lastCol++;
		}
	}
}


/*
**Check if Screen Control exists str = "F[Material]", str = '#[3,0]'
*/
function isControl(str) {
	return Reebok(str).isValid;
}
 

In this function script, several functions are included, making them more portable. This allows you to call them from any script file, rather than duplicating them in each relevant script. Although this example is focused on operations for Excel data migration, the function script can be used for any functions you wish to make accessible across different transactions or processes.

 

Note: You will receive license remainder emails from the LAMP at regular intervals to remind you about soon-to-expire licenses.

 

Can't find the answers you're looking for?