Liquid UI - Documentation - 10.23 Get hostname of the PC using _hostname

10.23 Get hostname of the PC using _hostname


Prerequisites


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.

  1. Delete unnecessary screen elements on the SAP screen.
  2. Customize the screen if z_hostname is blank.
  3. Customize the screen if z_hostname is not blank.
  4. Add an isblank function.
  5. Add a function to assign the hostname and clear it.
  6. Display the hostname.
 
Note: You need to have an updated version of the Liquid UI WS and the Liquid UI Server to access this variable. Available from WS Version 1.2.339.0 and Liquid UI Server Version 3.5.583.0 onwards.
 

//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.

  1. 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]");
     

     
  2. 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});
    
     

     
  3. 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});
     

     
  4. 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"}});
    }
     
  5. 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"}});
    } 
     
  6. 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.
      
  7. 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

  1. Click the Get Hostname pushbutton to view the hostname of your PC on the SAP screen, as shown in the image below.
      

     
  2. Click the Clear Hostname pushbutton to remove the hostname displayed on the screen, as shown in the image below.
     

     


Next Steps

Sort table values based on column
Learn how to use the Insertion algorithm to sort items in a table.
5 min

This article is part of the Conditional scripts tutorial.


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