Author Topic: Assigning Values to SAP Table from liquid UI table  (Read 2172 times)

Sai Siddhartha

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 47
    • View Profile
Assigning Values to SAP Table from liquid UI table
« on: November 23, 2017, 07:17:35 AM »
Purpose:
Assign values entered into Liquid UI table into SAP table with Liquid UI function.

Below example demonstrates assigning of values form Liquid UI table created on easy access screen into "All Items" table of VA01 transaction.

Liquid UI Code:
////////////////////////////// SAPLSMTR_NAVIGATION.E0100.sjs ///////////////////////////////

del("X[IMAGE_CONTAINER]"); // deletes image
pushbutton( [TOOLBAR], "Assign to SAP Table","?",{  "process":z_AssigntoSAPTbale,"size":[2,23]}); // pushbutton to call function

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

//function to assign values to All Items table
function z_AssigntoSAPTbale(){
   k = 0; //declaring variables and arrays
   temp_items=[];
   temp_material=[];
   temp_quantity=[];
   
        // code to fetch data from Liquid table to arrays
   STARTLABEL:   
   z_temp1 = va01_AllItems.z_va01_item[k];   
   z_temp2 = va01_AllItems.z_va01_material[k]; 
   z_temp3 = va01_AllItems.z_va01_Orderquantity[k];
   
   if(isBlank(z_temp1) && isBlank(z_temp2) && isBlank(z_temp3)){
      goto ENDLOOP;
   }
   
   temp_items.push(z_temp1);
   temp_material.push(z_temp2);
   temp_quantity.push(z_temp3);
   k=k+1;
   goto STARTLABEL;
   
   ENDLOOP:
   enter('/nva01');

// Create Standard Order: Overview
onscreen 'SAPMV45A.0101'
   set('F[Order Type]', 'OR');
   enter();

// Create Standard Order: Overview
onscreen 'SAPMV45A.4001'
   set('F[Sold-to party]', '1460');
   enter();

// Logic to assign array values to All item table
onscreen 'SAPMV45A.4001'
   gettableattribute("T[All items]", {"lastvisiblerow":"LVisRow"}) // gets lastvisible row
   var z=1;
   for(j=0;j<LVisRow;j++){  // assign values to visible rows in table
      z_item_temp = temp_items[j];
      z_item_material = temp_material[j];
      z_item_quantity = temp_quantity[j];   
      set("cell[All items,Item,&V[z]]" , "&V[z_item_temp]");   
      set("cell[All items,Material,&V[z]]" , "&V[z_item_material]");
      set("cell[All items,Order Quantity,&V[z]]" , "&V[z_item_quantity]");
      z=z+1;
   }

   // on enter cursor moves to next row in table
   START:
   enter();

// logic assign values to rows after scrolling table using enter()
onscreen 'SAPMV45A.4001'   
   z_item_temp = temp_items[j];
   z_item_material = temp_material[j];
   z_item_quantity = temp_quantity[j];
   set("cell[All items,Item,&V[LVisRow]]" , "&V[z_item_temp]");
   set("cell[All items,Material,&V[LVisRow]]" , "&V[z_item_material]");
   set("cell[All items,Order Quantity,&V[LVisRow]]" ,  "&V[z_item_quantity]");
   j=j+1;

   if(j<=i){ // loops until all liquid ui table values are assigned to sap table
      goto START;
   }
   enter();
}

After executing you can see values from Liquid UI table assigned to "All Items" table of "VA01" transaction.

See Attachment for more information and screenshots.
« Last Edit: January 09, 2019, 12:50:52 PM by Rahul Gera »