Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: wsCurl, pushbutton(), inputfield()
Purpose
To retrieve the global IP Address of the current system using wsCurl command in SAP. To demonstrate this, we’ll guide you through the following steps:
- Delete unnecessary elements on the SAP screen using the clearscreen command
- Add an input field to display the retrieved IP address.
- Add a toolbar pushbutton to execute the process that retrieves the current IP address on click.
- Add a function to retrieve the system IP address
User Interface
Create this file inside your script folder for customizing the SAP Easy Access screen SAPLSMTR_NAVIGATION.E0100
//Now, let's start adding the Liquid UI script to the above file and save it.
Customization
- Logon to SAP and delete the unnecessary screen elements on the SAP screen using the clearscreen command.
- Add an input field with the label IP Address to display the retrieved IP address, as shown below.
//Creates an input field with the label as IP Address to display the IP Address on click.
inputfield([1,0], "IP Address", [1,16], {"size":15, "name":"z_ipaddress", "readonly":true}); - Add a toolbar pushbutton with the label Get IP Address that calls the function getIPAddress to retrieve the current IP address on click, as shown in the following image.
//Creates a toolbar pushbutton with the label Get IP Address displays the location details on click.
pushbutton([TOOLBAR], 'Get IP Address', '?',{"process":getIPAddress}); - Now, add the following Liquid UI script to the above file and save it.
//SAPLSMTR_NAVIGATION.E0100
load('wscurl');
// Function to check if the string value is blank
function isBlank(jvar) {
if (jvar==void 0 || jvar=="" || jvar==null) {
return true;
} else {
return false;
}
}
// Function to retrieve IP address using WSCURL
function getIPAddress(){
var wsCurl = new Curl();
/* Build the URL to make a call*/
var completeURL = "http://www.howtofindmyipaddress.com/";
/* This is the URL for your translation request. Note this use is for
* calls made to Google Translate which returns us the JSON object in string*/
wsCurl.setopt(Curl.CURLOPT_URL, completeURL);
/* Final step is to call execute to dispatch email. You can check the return
* code to avoid errata string which can be found from "wsCurl.error"
* return value 0 means success*/
var response = wsCurl.exec();
var error = wsCurl.error;
ipaddrline = response.substring(1670,1700);
if(!isBlank(ipaddrline)){
if(error == 0){
posStart = ipaddrline.lastIndexOf(">") + 1;
posEnd = ipaddrline.lastIndexOf("\/") - 1;
ipaddress = ipaddrline.substring(posStart,posEnd);
if(isBlank(ipaddress)){
message('E: Could not find IP address, change URL');
} else{
set('V[z_ipaddress]','&V[ipaddress]');
}
}
} else{
message('E: Could not find IP address, change URL');
}
/* Close the http connection for the URL fetch*/
wsCurl.close();
/* Remove any reference for Garbage Collection*/
wsCurl= NULL;
}