Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lakshmi.k

Pages: [1]
1
Purpose:
The below example demonstrates how to display native SAP function module details into a Liquid UI table on Easy Access Screen by making an RFC call.

Note:
For each output parameter in the function module, we need to specify individual structure object.
See Convert function module structure detail into type object to generate ready-to-use type object for selected structure.

Liquid UI Code:
------------------------------------------------------------------------------------------------------------------------------------
Script File Name : SAPLSMTR_NAVIGATION.E0100.sjs
------------------------------------------------------------------------------------------------------------------------------------

//User Interface
clearscreen();

pushbutton([0,1], "BAPI_USER_GET_DETAIL", "?", {"process":callBAPI_USER_GET_DETAIL, "size":[1,30]});

//LUI Table of Export Parameter
table([2,1], [25,42],{"name":"z_table_export", "title":"Data of Export Parameter", "rows":200});
column("Component", {"size":18, "table":"z_table_export", "name":"z_comp_export", "readonly":true});
column("Value", {"size":18, "maxlength":40, "table":"z_table_export", "name":"z_comp_value_export", "readonly":true});

//LUI Table of Table Parameter
table([2,50], [25,92],{"name":"z_table", "title":"Data of Table Parameter", "rows":200});
column("Component", {"size":18, "table":"z_table", "name":"z_comp_table", "readonly":true});
column("Value", {"size":18, "maxlength":40, "table":"z_table", "name":"z_comp_value_table", "readonly":true});


//Function
//Function to display data of export parameter and table parameter in the LUI table
function callBAPI_USER_GET_DETAIL() {
   
   var z_BAPILOGOND = {

      name:'BAPILOGOND',

      components:[

         { name:'GLTGV',      length:8,      decimalpl:0,      type:'D' },
         { name:'GLTGB',      length:8,      decimalpl:0,      type:'D' },
         { name:'USTYP',      length:1,      decimalpl:0,      type:'C' },
         { name:'CLASS',      length:12,      decimalpl:0,      type:'C' },
         { name:'ACCNT',      length:12,      decimalpl:0,      type:'C' },
         { name:'TZONE',      length:6,      decimalpl:0,      type:'C' },
         { name:'LTIME',      length:6,      decimalpl:0,      type:'T' },
         { name:'BCODE',      length:8,      decimalpl:0,      type:'undefined' },
         { name:'CODVN',      length:1,      decimalpl:0,      type:'C' },
         { name:'PASSCODE',      length:20,      decimalpl:0,      type:'undefined' },
         { name:'CODVC',      length:1,      decimalpl:0,      type:'C' },
         { name:'PWDSALTEDHASH',      length:255,      decimalpl:0,      type:'C' },
         { name:'CODVS',      length:1,      decimalpl:0,      type:'C' },
         { name:'SECURITY_POLICY',      length:40,      decimalpl:0,      type:'C' },
      ]

   };
   
   
   var z_BAPIPARAM = {

      name:'BAPIPARAM',

      components:[

         { name:'PARID',      length:20,      decimalpl:0,      type:'C' },
         { name:'PARVA',      length:18,      decimalpl:0,      type:'C' },
         { name:'PARTXT',      length:60,      decimalpl:0,      type:'C' },
      ]

   };
   
   rfcResult = call("BAPI_USER_GET_DETAIL", {"in.USERNAME":"&V[_user]",
                  "out.LOGONDATA(type:z_BAPILOGOND)":"z_export_logon",
                  "table.PARAMETER(width:3000,type:z_BAPIPARAM)":"z_table_param"});
   println("=====>>Exception: " + rfcResult.exception);

      

   
   var value_export = '';
   var a = 0;
   for (var idx in z_export_logon) {
      z_table_export.z_comp_export[a] = idx;
      set('V[value_export]',z_export_logon[idx]);
      z_table_export.z_comp_value_export[a] = value_export;
      a++;
   }
   

   
   var value_table = '';
   var c = 0;
    for (var j in z_table_param){
        for (var k in z_table_param[j]){
         z_table.z_comp_table[c] = k;
         set('V[value_table]',z_table_param[j][k]);
         z_table.z_comp_value_table[c] = value_table;
         c++;
        }
    }
}

2
Purpose:
Below example demonstrates structure to make function module calls, display message to the user if the call was successful and display an error message if the call was not successful.

Note:
To make the function module call, it is required to provide the rfc parameters in the configuration file i.e, guixt.sjs

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
----------------------------------------------------------------------------------------------------------------------
// User Interface
clearscreen();
inputfield([1,0],"Message",[1,10],{"name":"z_message","size":70,"readonly":true});
pushbutton([3,1],"Get Messsage","?",{"size":[2,20],"process":getMessage});

//Functions
//To remove blank spaces from variable values
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

//Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

//Function to check for blank string
function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}

//Function to call BAPI and display results
function getMessage(){
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      rfcresult = call('BAPI_USER_CHANGE',{'in.USERNAME':'&V[_user]','out.GENERATED_PASSWORD':'z_gen_pswd','table.RETURN':'z_return'});
      if(rfcresult.rfc_rc != 0) {         
         // Cannot Call RFC for any reason
         // RFC call was *NOT* successful.
         message('E: Error! RFC Call Failed to Return Data');
         enter("?");
         goto SCRIPT_END;
      } else {
         if(!isBlank(rfcresult.exception)) {
            // RFC Call succeeded, but the ABAP code in the function module generated an exception
            // Display message to user, that rfc exception occured (you can use rfcresult.exception)
            message('E: Error! '+rfcresult.exception);
            enter("?");
            goto SCRIPT_END;
         }
      }

      // RFC call was successful
      if(!isBlank(z_return)){
         set('V[z_message]', z_return.toString().substring(24,244));   
      }
      message('S: RFC call was successful');
      enter('?');
    SCRIPT_END:;   
}


3
Purpose:
Below example demonstrates to display users list on Easy Access Screen by calling BAPI_USER_GETLIST function module.

Note:
To make the function module call, it is required to provide the rfc parameters in the configuration file i.e., guixt.sjs

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
----------------------------------------------------------------------------------------------------------------------------------------------------
del("X[IMAGE_CONTAINER]");       //Deletes the image container on the Easy Access Screen

String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

getUsersList();         //Calls the getUserList function and executes it

//To create text based on the number of users in the list
for(i=0; i<user_id.length; i++){
   text([1+i,0], user_id);
}

//Function to get users list
function getUsersList() {
call('BAPI_USER_GETLIST',{'in.WITH_USERNAME':'&V[_user]','out.ROWS':'z_rows','table.USERLIST':'z_userslist'});
   user_id = [];
   for(i = 0; i<z_userslist.length; i++){
             temp = z_userslist.trim();
             user_id.push(temp);       
    }
}

4
Purpose:
To extract data from a SAP table and load it into a Liquid UI table. Additionally, the data in table will be cleared using pushbuttons.

The following example illustrates the above defined process established on the easy access screen.

Liquid UI Code:
------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
------------------------------------------------------------------------------------------------------------------------------------

//Delete Image Container
del("X[IMAGE_CONTAINER]");

//User Interface
inputfield( [0,1], "Order", [0,11],{ "name":"va02_Order", "size":21, "searchhelp":"VMVA"});

table([2,1],[8,68],{"name":"va02_AllItems","title":"All items", "rows":20, "rowselection":true,"columnselection":true});
column('Item',{"table":"va02_AllItems","size":4,"name":"va02_item","position":1});
column('Material',{"table":"va02_AllItems","size":15,"name":"va02_mat","position":2});
column('Order Quantity',{"table":"va02_AllItems","size":15,"name":"va02_qty","position":3});
column('description',{"table":"va02_AllItems","size":25,"name":"va02_desc","position":4});

pushbutton( [10,1], "Extract Data To LiquidUI Table","?",{ "process":extractDataToLiquidUiTable,"size":[1,27]});
pushbutton([10,30], "Clear Table Data", {"process":clearData}); //clearTableData



//Functions
//Function to retrieve data to Liquid UI table
function extractDataToLiquidUiTable(){ 
   // SAP Easy Access
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      enter("/nva02");
   
   // Change Sales Order: Initial Screen
   onscreen 'SAPMV45A.0102'
      set('F[Order]', '&V[va02_Order]');
      enter("=SUCH");
   
   
   // Change Sales Order: Initial Screen
   onscreen 'SAPMSDYP.0010'
      enter();
   
   // Change Sales Order: Initial Screen
   onscreen 'SAPMSDYP.0010'
      enter();
   
   onscreen 'SAPMV45A.4001'
      
      z_va02_item=[];
      z_va02_mat=[];
      z_va02_qty=[];
      z_va02_desc=[];
   
      
      gettableattribute('T[All items]', {'firstvisiblerow':'FVisRow', 'lastvisiblerow':'LVisRow', 'lastrow':'LastRow'});

      relrow=1;
      absrow=1;
      total=0;
      println("=====> First visible row is: "+FVisRow);
      println("=====> Last visible row is: "+LVisRow);
      println("=====> Last row of the table is: "+LastRow);

      if(FVisRow != 1){
         println("=====> Scroll to first row before start...");
         enter('/ScrollToLine=1', {table:'T[All items]'});
      } else {
         enter('?');
      }

   newscreen:;
   onscreen 'SAPMV45A.4001'
      relrow=1;
      gettableattribute('T[All items]', {'firstvisiblerow':'FVisRow', 'lastvisiblerow':'LVisRow'});
      println("=====> New first visible row is: "+FVisRow+", new last visible row is: "+LVisRow);

      newlabel:;
      
      if(absrow>LVisRow){
         println("=====> Scroll to next visible row before continue...");
         enter('/ScrollToLine=&V[absrow]', {table:'T[All items]'});
         goto newscreen;
      }

      if(absrow>LastRow){
         println("=====> Reach the end of table, end of scrolling");
         goto end;
      }
      set('V[z_curr_item]', '&cell[All items,Item,&V[relrow]]');
      z_va02_item.push(z_curr_item);
      set('V[z_curr_mat]', '&cell[All items,Material,&V[relrow]]');
      z_va02_mat.push(z_curr_mat);
      set('V[z_curr_quan]', '&cell[All items,Order Quantity,&V[relrow]]');
      z_va02_qty.push(z_curr_quan);
      set('V[z_curr_desc]', '&cell[All items,Description,&V[relrow]]');
      z_va02_desc.push(z_curr_desc);
      

      absrow++;
      relrow++;
      goto newlabel;
      
      end:;
      println("=====> Scroll to the first row of table at the end");
      enter('/ScrollToLine=1', {table:'T[All items]'});
   
      
      total = absrow;
      println("This is absolute row :"+absrow+":"+total);
      
      
   onscreen 'SAPMV45A.4001'
      for(var idx=1, i=0; idx<total-1;idx++, i++){

         va02_AllItems.va02_item=z_va02_item;
         va02_AllItems.va02_mat=z_va02_mat;
         va02_AllItems.va02_qty=z_va02_qty;
         va02_AllItems.va02_desc=z_va02_desc;

      }
      enter('/n');   
      
   
}


//clear table data
function clearData() {   
   var table_value = ' ';

   for(i=1;i<total-2;i++) { 
      table_value += ' ';
   }

   onscreen 'SAPLSMTR_NAVIGATION.0100'
      set('V[va02_*]','');
      set('V[z_*]','&V[table_value]');
      enter();
      
}

5
WS aka Web Scripts (Attended RPA for SAP) / Read LiquidUI Table
« on: February 29, 2024, 08:33:15 PM »
Purpose:
Read values in the LiquidUI table with toolbar pushbutton.

Below example demonstrates read LiquidUI table data and display them on the console window.

Liquid UI Code:
------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
------------------------------------------------------------------------------------------------------------------------------------
//Delete image container
del("X[IMAGE_CONTAINER]");

//User Interface
table([1,5],[10,45],{"name":"va01_AllItems","title":"All items", "rows":10, "rowselection":true,"columnselection":true});
column('Item',{"table":"va01_AllItems","size":4,"name":"z_va01_item","position":1});
column('Material',{"table":"va01_AllItems","size":15,"name":"z_va01_material","position":2});
column('Order Quantity',{"table":"va01_AllItems","size":15,"name":"z_va01_Orderquantity","position":3});

pushbutton([TOOLBAR],"Read LiquidUI Table","?",{"process":readLiquidUITableValues,"size":[2,23]});

//Functions
// Function prototype to trim blank characters from a string
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field
function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}


//function to read LiquidUI table 'All items'
function readLiquidUITableValues(){
   i = 0;
   //declaring variables and arrays
   temp_items=[];
   temp_material=[];
   temp_quantity=[];
   
   STARTLABEL:; 
   z_temp1 = va01_AllItems.z_va01_item[i ];   
   z_temp2 = va01_AllItems.z_va01_material[i ];   
   z_temp3 = va01_AllItems.z_va01_Orderquantity[i ];
   
   if(!isBlank(z_temp1) && !isBlank(z_temp2) && !isBlank(z_temp3)){   

      temp_items.push(z_temp1);
      temp_material.push(z_temp2);
      temp_quantity.push(z_temp3);
   
      i=i+1;
      goto STARTLABEL;
      
   }   
    
   println('-----------items-------'+temp_items);
   println('-----------material-------'+temp_material);
   println('-----------order quantity-------'+temp_quantity);
   

}

6
Purpose:
Add Inputfield values to SAP table using pushbutton.

Below example demonstrates adding inputfield values created on the VA02 screen to the "All items" table.

Liquid UI Code:
-------------------------------------------------------------------------------------
Script File Name: SAPMV45A.E0102.sjs
-------------------------------------------------------------------------------------

//User Interface
del("G[Search Criteria]");      //Deletes Search Criteria group box

comment([4,2], "Item   Material        Order Quantity  Plnt");

inputfield([5,2], {"name":"z_va02_item", "size":6,"nolabel":true});
inputfield([5,9], {"name":"z_va02_mat", "size":15,"nolabel":true});
inputfield([5,25], {"name":"z_va02_qty", "size":15,"nolabel":true});
inputfield([5,41], {"name":"z_va02_plnt", "size":4,"nolabel":true});

pushbutton([2,59],"Add Values To SAP Table", {"process":addValuesToSAPtable});


//Function to add values in the inputfield to SAP table
function addValuesToSAPtable(){

   onscreen "SAPMV45A.0102"
      enter();
   onscreen "SAPMSDYP.0010"
      enter();
   onscreen "SAPMV45A.4001"
      var absrow = 1;
      var relrow = 1;
      
   NEW_SCREEN:;   
   
      enter("/scrolltoline=&V[absrow]", {"table":"T[All items]"});
   onscreen "SAPMV45A.4001"
      relrow = 1;

      gettableattribute("T[All items]", {"firstvisiblerow":"FVisRow", "lastvisiblerow":"LVisRow", "lastrow":"LRow"});
   NEW_ROW:;
   
      if(absrow > LVisRow){
         goto NEW_SCREEN;
      }
      if(absrow > LRow){
         goto END_OF_TABLE_SCROLL;
      }
      
      relrow++;
      absrow++;
      
      goto NEW_ROW;
   END_OF_TABLE_SCROLL:;
   
      //Adding inputfields values to the All items table
      set("cell[All items,Item,&V[relrow]]","&V[z_va02_item]");
      set("cell[All items,Material,&V[relrow]]","&V[z_va02_mat]");
      set("cell[All items,Order Quantity,&V[relrow]]","&V[z_va02_qty]");
      set("cell[All items,Plnt,&V[relrow]]","&V[z_va02_plnt]");
      
      set('V[z_*]','');       //it clears the values in the inputfield
      enter('/11');
      
      onerror               //It navigates to VA02 screen if there is an error
      message(_message)
      enter('/nva02')
      
}





Pages: [1]