Author Topic: Extracting of Data from SAP To Liquid UI Table  (Read 3854 times)

lakshmi.k

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 7
    • View Profile
Extracting of Data from SAP To Liquid UI Table
« on: March 01, 2024, 02:20:22 AM »
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();
      
}