Author Topic: Arrays using Key Value Pairs  (Read 4098 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 95
    • View Profile
Arrays using Key Value Pairs
« on: July 26, 2016, 01:49:32 PM »
Purpose:
Insert and retrieve values from an array using Key/Value pairs.

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs

// Retrieve Material Descriptions
function showMatlDescs(){
   for(i=0;i<matDataArr.length;i++){
      matl_table.z_matl_desc[ i] = matDataArr[ i].value;
   }
   return;
}

// User Interface
clearscreen();
// Liquid UI table and columns
table([1,1],[20,50], {"name":"matl_table", "title":"Material Info", "rows":20});
column('Material', {"table":"T[Material Info]", "name":"z_matl", "readonly":true, "position":1, "size":15});
column('Description', {"table":"T[Material Info]", "name":"z_matl_desc", "position":2, "size":30});
pushbutton([21,1], "@01@Retrieve Material Descriptions", {"process":showMatlDescs});

// Sample Materials and Descriptions
var matDataArr = [];
for(i=1;i<=20;i++){
   matDataArr.push({key:'Material '+i+'',value:'Description '+i+''});
}

// Populating table with Material numbers
for(i=0;i<matDataArr.length;i++){
   matl_table.z_matl[ i] = matDataArr[ i].key;
}


See attachments for code samples!
« Last Edit: August 03, 2016, 03:52:47 PM by Benjamin Dasari »