Author Topic: LiquidUI: GuiXT Column for SAP Table  (Read 3244 times)

chirag.amin@guixt.com

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 34
    • View Profile
LiquidUI: GuiXT Column for SAP Table
« on: January 27, 2016, 04:32:24 PM »
This is an example of creating a GuiXT column in an SAP Table.

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

// We want this to only run on VA03
if(_transaction == "VA03"){
        // On any navigation
   onUIEvents["/n*"] = {"process":va03ClearVar};
   
   column("Volume", {"table":"All items", "size":12, "name":"z_volume", "position":4, "readonly":true});
   
   if(z_run_function == undefined){
      z_run_function = true;
      enter("?", {"process":va03FetchVolume});
   }
}

// This function is responsible for retrieving the Volume of each item
function va03FetchVolume(){
   onscreen 'SAPMV45A.4001'
      // Table Scroll through each Item
      absrow = 1;
      relrow = 1;
      
      // Fetch the table attributes
      gettableattribute("T[All items]", {"firstvisiblerow":"FVisRow", "lastvisiblerow":"LVisRow", "lastrow":"LastRow"});
new_screen:;
      // Scroll to the absolute row
      enter("/ScrollToLine=&V[absrow]", {"table":"T[All items]"});
      
   onscreen 'SAPMV45A.4001'
      // Refetch table attributes, in case they might of changed
      gettableattribute("T[All items]", {"firstvisiblerow":"FVisRow", "lastvisiblerow":"LVisRow", "lastrow":"LastRow"});
      // Reset the relevant row
      relrow = 1; // reset the relative row with a new screen
new_row:;
      if(absrow>LVisRow){
         // end of the screen?
         goto new_screen;
      }
      if(absrow>LastRow){
         // end of the table?
         goto end_of_table;
      }
      
      // Set the cursor on the row
      setcursor("cell[All items,1,&V[relrow]]");
      
      // Go into Item Data
      enter("=ITEM");
   
   onscreen 'SAPMV45A.4003'
      // Navigate to the second tab
      enter("=T\\03");
   onscreen 'SAPMV45A.4003'
      // Set the Volume to our GuiXT Column
      set("V[temp]", "&F[Volume]");
      set("V[z_volume.&V[absrow]]",temp.trim());
      // Go back to Overview Screen
      enter("/3");
      
   onscreen 'SAPMV45A.4001'
      // Increment out counters
      absrow++;
      relrow++;
      goto new_row;
         
end_of_table:;
      // Scroll back to the top of the table
      enter("/ScrollToLine=1", {"table":"T[All items]"});
}

// This function is responsible for clearing all the variables
function va03ClearVar(){
   // set the column values to a blank string
   set("V[z_*]", "");
   // set the function flag to undefined
   z_run_function = void 0;
}

// This is a trim function for strings that will return the original string with
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

See attached documents.
« Last Edit: August 18, 2016, 11:43:17 AM by chirag.amin@guixt.com »