Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: del(), pushbutton(), column(), table()
Purpose
The article details how to check the existence of a username by calling the BAPI_USER_EXISTENCE_CHECK function, based on the SAP Easy Access screen. Here, we’ll perform the following actions:
- Delete the image container on the SAP Easy Access screen
- Add an input field to enter the user name
- Add a push button to execute the process
- Add functions to validate spaces, trimmed strings, and blank strings, call Bapi, and display results
User Interface
//Create the file SAPLSMTR_NAVIGATION.E0100.sjs inside your scripts folder for customizing the SAP Easy Access screen
//Now, add the Liquid UI script to the above file and save it.
Customization
- Delete the image container on the SAP Easy Access screen using del().
// Deletes the image container on the SAP screen del("X[IMAGE_CONTAINER]");
- Add an input field labeled User name to enter the user name.
//Creates an input field to enter the user name inputfield([1,0],["Username"],[1,10],{"name":"z_user_name","size":"15"});
- Add a push button labeled Check User Exist to execute the z_fmCallGetData process on click.
//Creates a push button to execute the process pushbutton([3,1],["Check User Exist"],"?",{"size":[2.20],"process":z_fmCallGetData});
- Add a function to remove blank spaces from variable values.
//Function to remove blank spaces String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }
- Add the getString function to return the trimmed string.
//Function to return trimmed string function getString(strInput) { return(typeof(strInput) == 'undefined' || strInput == 'undefined')? "" : strInput.toString().trim(); }
- Add the isBlank function to check for blank string.
//Function to check for blank string function isBlank(strInput) { var strVal = getString(strInput); var blank = strVal == ""; return blank; }
- Add the z_fmCallGetData function to call Bapi and display results.
//Function to call Bapi and display results function z_fmCallGetData() { rfcresult = call('BAPI_USER_EXISTENCE_CHECK',{'in.USERNAME':'&V[z_user_name]','out.RETURN':'z_return'}); if(rfcresult.rfc_rc != 0){ // Cannot Call RFC for any reason // RFC call was *NOT* successful. // Displays message to user that rfc cannot be called (you can use the content of rfcresult.rfc_key) message('E:Error! RFC call failed to return data'); enter("?"); goto SCRIPT_END; } else{ // RFC Call was successful if(!isBlank(z_return)){ set('V[z_user_exist]',z_return.substring(24,60)); } message('S:'+ z_user_exist); set('V[z_user_name]',''); enter("?"); SCRIPT_END:; } }
SAP Process
- Refresh the SAP interface and input the username. Then, click on the Check User Exist push button. Upon successful verification, a confirmation message stating that "User (divya) exists" will be displayed, as shown below.
- If the RFC call is unsuccessful due to any of the following conditions:
- An exception is encountered
- The specified username is not present
- The entered username is not valid