Liquid UI - WS Reference Library

Get system IP address


Prerequisites


Purpose

Retrieve the global IP Address using WSCurl.


User Interface

Log into SAP and on the SAP Easy Access Screen click on the ‘Get IP Address’ pushbutton which display the IP Address in the IP Address field.



Liquid UI Script

//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;
}

// User Interface
clearscreen();
pushbutton([TOOLBAR], 'Get IP Address', '?',{"process":getIPAddress});
inputfield([1,0], "IP Address", [1,16], {"size":15, "name":"z_ipaddress", "readonly":true});    



Was this information helpful? Send Feedback