Liquid UI - Documentation - 5.2 Using SharedMemory Variables with bot

5.2 Using SharedMemory Variables with bot


This article will demonstrate how to automate the SAP logon and logoff processes using SharedMemory.

Place the variable in SharedMemory and check if the action is executed to determine whether to start the logoff procedure. It is also used to save a variable and create an infinite loop of this action in the SAP environment. The following steps explain the process.

  1. Create a new script file and name it ‘elogon.sjs’. This file will execute upon logon and will contain the user’s login credentials. Additionally, this file loads a file containing all the functions used in these examples. The file 'functions.sjs' has been created and placed in the script directory specified in the guixt.sjs file, as explained earlier in this document. Inside the elogon file, the WS 'set' command is used to send a specific username and password to SAP. Once these credentials are sent, the actions carried out by the elogon file are completed. The example code is as follows:
     
    load('C:\\guixt\\functions.sjs');
    set("F[User]",  "user"); 
    set("F[Password]", "12345"); 
    enter();
    
     
    Note: We defined the full path of the 'functions.sjs' file because we will be calling it from a different directory in a later example. You do not need to define the full path if you are calling the file from the same directory.
     
  2. Next the SAP Easy Access screen (SAPLSMTR_NAVIGATION.E0100.sjs) file will be read, as no processes are included in the elogon file. If the script file does not exist, create it. Then, call the function in this script.
     
    enter({process:run_infinite_LogonLoop}); 
     
  3. Save your changes and close the Easy Access script file.
     
  4. Create a new file named ‘function.sjs’ in the script directory and place all the functions that we use in the examples.  Open 'functions.sjs' and create a function to perform the required operations.
    • Delete all existing screen elements on the Easy Access screen
    • Execute a graceful exit
     

    The example code is as follows.

    function run_infinite_logonLoop() { 
     del('X[IMAGE_CONTAINER]');
     image([0,0],'GuiXT.jpg'); 
    
     if(SharedMemory('WS').read().autoexit)  
      enter('/i', {process:answeryes});
    
      function answeryes(){   
       onscreen 'SAPLSPO1.0100'
       enter('=YES');    
       SharedMemory('avatar').write({loop:true});  
     } 
    }
    
  5. The function deletes the image container on the SAP Easy Access screen and checks if the variable 'autoexit' exists in the 'WS' shared memory. If it does, it reads the state and acts accordingly. 
     
     
    Note: The 'autoexit' variable is defined in the avatar.js file and should not be edited by users. This variable controls graceful process exits. 'True' exits gracefully, while 'false' freeze the process. 'False' is useful for troubleshooting. The default is 'true'.
     
  6. If 'autoexit' is present in 'WS', the 'enter' command will execute, sending '/i' to SAP and running 'answeryes'. This function will click 'Yes' on the exit dialog box, then set 'loop' in shared memory 'avatar' to 'true', creating an infinite logon-logoff loop.
     
     
    Note: The variable 'loop' is defined in the avatar.js file. Similar to the 'autoexit' variable in the 'WS' shared memory, this should not be altered by users.
     
  7. Save the changes and close the script file.
     
  8. Open a command prompt and navigate to the bot directory. In our example, we placed this directory on the C drive.
     
  9. Enter the following command.
     
    GuiXT4webApp.exe -f avatar.js 
  10. The task will be executed, and you can monitor its progress in the Console since we are running the task manually. However, if the task is automated using the Task Scheduler, the Console will not be launched.

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