Liquid UI - Documentation - 10.14 Get server name using _ashost variable

10.14 Get server name using _ashost variable


Prerequisites


Purpose

You will learn how to use the system variable in retrieving the acutal server name of the SAP sever. This variable is very useful when you are working on multiple SAP ERP systems. We will walk you through the following steps. 

  1. Delete unnecessary screen elements
  2. Add a condition to check the server name
  3. Add a function to dynamically navigate through the other transaction

//Create this file inside your script folder for customizing SAP Easy Access screen: SAPLSMTR_NAVIGATION.E0100.sjs
//Now let's start adding the content to the above file

  1. Delete redundant/unneeded screen elements on the SAP Easy Access screen.
    del("X[IMAGE_CONTAINER]");
    
     

     
  2. Add a condition to check the server name and based on the server retrieved, you will be navigated to the assigned transaction.
     
    if(_ashost == "juneau"){
         set("V[z_tran]","/nVA01");
    } 
    else if(_ashost == "ZEUS"){
         set("V[z_tran]","/nMM01");
    }

     
  3. Add a function to navigate to the transaction dynamically.
     
    //on enter navigates to “VA01” if server is Juneau and to “MM01” if server is zues
    function z_navigate(){
         // SAP Easy Access
         onscreen 'SAPLSMTR_NAVIGATION.0100'
              enter("&V[z_tran]");
    }
    

     
  4. On performing enter operation, the z_navigate process should be called.
     
    //Executes z_navigate on performing enter 
    onUIEvents['enter']=z_navigate;

     
  5. You will see the SAP server name in the console window.
     
    //Displays server name on the console window
    println("Name of the server in use is "+_ashost);

     
  6. Open SAP Easy Access screen in Juneau(SAP server name) SAP server and click continue to navigate through the Create Sales Order screen.
     

     
  7. Open SAP Easy Access screen in Zeus(SAP server name) SAP server and click continue to navigate through the Create Material screen
     

     


Next Steps

Change your SAP GUI layout based on the client device
Learn how to change the layout of your SAP GUI based on the device used.

5 min

This article is part of the Conditional scripts tutorial.


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