Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: box(), text(), pushbutton(), del(), set(), _hostname
Purpose
Learn how to use the _hostname variable to return the client’s PC name or computer name. You can also use this variable to conditionalize a process based on the client's PC name, which will display the Client’s PC name on the SAP screen or the Cornelius window as per your requirement. We will walk you through the following steps.
- Delete unnecessary screen elements on the SAP screen.
- Customize the screen if z_hostname is blank.
- Customize the screen if z_hostname is not blank.
- Add an isblank function.
- Add a function to assign the hostname and clear it.
- Display the hostname.
//Create this file inside your script folder for customizing the SAP Easy Access screen: SAPLSMTR_NAVIGATION.E0100.sjs
//Now, let's start adding the Liquid UI script to the above file and save it.
- Logon to SAP and delete the image container using the del command on the SAP Easy Access screen, as shown below.
// Deletes an image container on the easy access screen
del("X[IMAGE_CONTAINER]");
- Add a pushbutton with the label Get Hostname to call the function GetHostName.
// Creates a pushbutton with the label Get Hostname to call the process GetHostName. pushbutton("G[Hostname]+[3,10]", "Get Hostname","?",{"process":GetHostName});
- Add another pushbutton with the label Clear Hostname to call the function ClearHostName.
// Creates a pushbutton with the label Clear Hostname to call the process ClearHostName.
pushbutton("G[Hostname]+[3,10]", "Clear Hostname","?",{"process":GetHostName});
- Add a condition to check the hostname value is blank and customize the screen as per requirement.
if(isBlank(z_hostname)){ box([0,0],[10,100], "Hostname"); pushbutton("G[Hostname]+[3,10]","Get Hostname", "?",{"process":GetHostName, "using":{"h_param":"hostname"}}); }
- Add a condition to check the z_hostname value is not blank and customize the SAP screen as per the requirement.
if(!isBlank(z_hostname)){ box([0,0],[10,100], "Hostname"); text("G[Hostname]+[4,10]","HostName of this machine is: "+z_hostname); pushbutton("G[Hostname]+[3,10]", "Clear Hostname","?",{"process":GetHostName, "using":{"h_param":"clear"}}); }
- Add a function to check a variable value is blank.
function isBlank(jvar){ return(jvar == null || jvar == "" || jvar == void(0)); }
Note: You can place all the generic functions in elogon.sjs file to access whenever necessary. - Add a function to display the hostname and clear it as per your requirement.
function GetHostName(param){ var hostparam = param.h_param; if(hostparam == "hostname"){ set("V[z_hostname]",_hostname); println("\n@@@@@@\n System Variable: "+_hostname+"\n@@@@@@@\n"); println("\n@@@@@@@@@@@@@\n Liquid UI variable: "+z_hostname+"\n@@@@@@@@@\n"); } else{ set("V[z_hostname]",""); } }
SAP Process
- Click the Get Hostname pushbutton to view the hostname of your PC on the SAP screen, as shown in the image below.
- Click the Clear Hostname pushbutton to remove the hostname displayed on the screen, as shown in the image below.
Next Steps
Learn how to use the Insertion algorithm to sort items in a table.
This article is part of the Conditional scripts tutorial.