Liquid UI - Documentation - 23.03 Calling a function module

23.03 Calling a function module


Prerequisites

 

Learn how to call a function module (BAPI_USER_GET_DETAIL) to display user details on the SAP Easy Access screen. To demonstrate the process, we’ll walk you through the following steps:

  1. Delete the image container on the SAP Easy Access screen
  2. Add a groupbox to display the user name and class dynamically
  3. Add a function to trim the string
  4. Call the function to display the user details
  5. Add a for loop to create texts.
  6. Add a function to retrieve user parameters from the function module
  7. Add a for loop that goes through the table and stores each value.

User Interface

//Create the file SAPLSMTR_NAVIGATION.E0100.sjs inside your scripts folder for customizing the SAP Easy Access screen
//Now, let's add the Liquid UI script to the above file and save it.

Customization

  1. Delete the image container on the SAP Easy Access screen using the del command.
     
    //Deletes the image container on the SAP screen
    del("X[IMAGE_CONTAINER]");
    
     
     
  2. Add a group box with a dynamically generated title that displays the user's name and class.
     
    //Creates a group box to hold user details
    box([0,0],[i+1,38],"Defaults for "+_user.trim()+" ("+z_class+")");
    
     
     
  3. Add a function to replace all the special characters in the string with blank spaces.
     
    //Function to trim all the blank spaces
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,"");
    }
    
     
  4. Call the getDetailFromFM function to display the user details.
     
    //Displays the user details
    getDetailFromFM();
    
     
  5. Add a for loop to create texts based on the number of parameters available for the user.
     
    //Runs a for loop that dynamically creates the text
    for(i=0; i<param_id.length; i++)
    {
        text([1+i,0], param_id[i]+": "+param_val[i]);
    }
    
     
  6. Add the getDetailFromFM function to call the BAPI_USER_GET_DETAIL function module to retrieve the required parameter values.
     
    //Function to call Module and retrieve the data
    function getDetailFromFM(){
        println("In this function.")
        call("BAPI_USER_GET_DETAIL", {"in.USERNAME":"&V[_user]", "out.LOGONDATA":"z_logondata", "table.PARAMETER":"z_parameters"});
        
        // extract the user's class type
        z_class = z_logondata.substring(17,29).trim();
    
            // create two arrays
        param_id = [];
        param_val = [];
    
     
  7. Add a for loop that goes through the table and store each value.
     
    //Runs a for loop to go through the table and store each value 
    	for(i = 0; i<z_parameters.length; i++){
    		tmp = z_parameters[i].substring(0,20).trim();
    		param_id.push(tmp);
    		tmp = z_parameters[i].substring(20,38).trim();
    		param_val.push(tmp);
    	}
    }
    
     

SAP Process

  1. Refresh the SAP screen and you will observe the user details are displayed in the group box, as depicted in the image below.
     
     


Next Steps

External Database Connection from SAPGUI
Learn how to connect to an external server to your SAP GUI

10 min.

This article is part of the Invoking functions tutorial.


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