Liquid UI - WS Reference Library

Function Module Call


Prerequisites


Runs On

  SAP GUI Android iOS WM Web
Direct Connect          
Liquid UI Server Connect        

Purpose

This is an example of calling a Function Module using WS. In this example, we will use the Function Module BAPI_USER_GET_DETAIL display information on a screen.

User Interface

Log into SAP and the FM call will run automatically. It will display information about the user’s defaults and what type of user authorization it is (e.g. “Super”).


The data we are pulling from in BAPI_USER_GET_DETAIL comes from the LOGONDATA output and the PARAMETERS table.


NOTE: When using the call command, be sure to have the correct RFC parameters in your guixt.sjs configuration file.


Liquid UI Script

//SAPLSMTR_NAVIGATION.E0100.sjs

// Author: Synactive, Inc. [1065 E. Hillsdale Blvd, Foster City, CA, 94404, USA]
// Email: support@guixt.com; sales@guixt.com;
// Contact: 650.341.3310
// Version: 1.0.0.0

// This allows a string to be trimmed of all blank spaces
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
// Clear the screen of all elements
del("X[IMAGE_CONTAINER]");

// Run the function
getDetailFromFM();

// 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]);
}
// Create a group box to hold the data witha  title involving the user and the user's class
box([0,0],[i+1,38],"Defaults for "+_user.trim()+" ("+z_class+")");

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