Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: box(), text(), call()
Purpose
You will learn how to call a function module (BAPI_USER_GET_DETAIL ) to display user details on the SAP Easy Access screen. We will walk you through the following steps:
- Delete unnecessary elements
- Add groupbox
- Add a function to trim the string
- Call a function to display the user details
- Add a for loop to create texts.
- Add a function to retrieve user parameters from the function module
//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
- Delete the image container on the SAP Easy Access screen.
del("X[IMAGE_CONTAINER]");
- Add a groupbox with a title as Defaults for the user where user name and class is displayed dynamically.
// Create a group box to hold the data with a title involving the user and the user's class 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.
// This allows a string to be trimmed of all blank spaces String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }
- Calls the getDetailFromFM function and executes it.
// Run the function getDetailFromFM();
- Add a for loop to create texts based on the number of parameters available for the user.
// Run a for loop to dynamically create the text for(i=0; i<param_id.length; i++) { text([1+i,0], param_id[i]+": "+param_val[i]); }
- Add a function to call a function module BAPI_USER_GET_DETAIL to retrieve required parameter values.
// This function makes the call to the Function Module and pulls the data to display 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 = []; // run a for loop to go through the table and store each value we want 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); } }
- Open SAP Easy Access screen. You will see the user details displayed as shown 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.