Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: box(), text(), call()
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:
- Delete the image container on the SAP Easy Access screen
- Add a groupbox to display the user name and class dynamically
- Add a function to trim the string
- Call the function to display the user details
- Add a for loop to create texts.
- Add a function to retrieve user parameters from the function module
- 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
- 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]");
- 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+")");
- 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,""); }
- Call the getDetailFromFM function to display the user details.
//Displays the user details getDetailFromFM();
- 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]); }
- 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 = [];
- 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
- 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
Learn how to connect to an external server to your SAP GUI
10 min.
This article is part of the Invoking functions tutorial.