Author Topic: Fetching SAP Grid Data into Arrays using WS Function  (Read 2572 times)

Sai Siddhartha

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 47
    • View Profile
Fetching SAP Grid Data into Arrays using WS Function
« on: August 10, 2017, 05:36:58 AM »
Purpose:
Fetching data from the SAP grid into Array variables using WS function.

Using:
Data from grid is fetched into array variables with WS function by using “Select All” and “Details” buttons functionality of SAP.

Below example demonstrates the reading of notification grid data into array variables from IW28 transaction.
-> On screen "Selection of Notifications" enter appropriate filters and click on "Execute".
-> On screen "List of Notifications" add below code.

LiquidUI Code:

////////////////////////// SAPLSLVC_FULLSCREEN.E0500.sjs /////////////////////////////

//pushbutton to call function getnotifications function
pushbutton( [TOOLBAR], "Read to Arrays",{ "process":getnotifications});

function countnotifications(){
      z_count_notif=0;
      z_iw28_notif = []; // initializing array variables
      z_iw28_notifdesc = [];
      z_iw28_notifdate = [];
        // Display Notifications: List of Notifications
      onscreen 'SAPLSLVC_FULLSCREEN.0500'
         enter('/5');      //triggers "Selecl All" button to select all notifications in grid

      // Display Notifications: List of Notifications
      onscreen 'SAPLSLVC_FULLSCREEN.0500'
         enter('/37');  //triggers "Details" button which navigates to details of first notification

      // Display PM Notification: Maintenance request
      onscreen 'SAPLIQS0.7200'
              //logic to fetch notification numbers and respective details by looping
         FETCHNOTIF:             
            z_count_notif = z_count_notif+1;
            set("V[z_iw28_n]","&F[VIQMEL-QMNUM]");
            z_iw28_notif.push(z_iw28_n);
            set("V[z_iw28_ndate]","&F[VIQMEL-QMDAT]");
            z_iw28_notifdate.push(z_iw28_ndate);
            set("V[z_iw28_nd]","&F[VIQMEL-QMTXT]");
            z_iw28_notifdesc.push(z_iw28_nd);
            enter('/3');    // with ‘/3’ screen navigates to details of next notification till last notification in grid is reached

      onscreen 'SAPLIQS0.7200'
         goto FETCHNOTIF;
         enter();

      onscreen 'SAPLSLVC_FULLSCREEN.0500'
         message("number of notifications is:"+z_count_notif); // displays the number notifications on statusbar
         enter('?');
}

// display the data in the arrays on cornelius
for(idx=0;idx<z_count_notif;idx++){ 
println('--------------------------------z_iw28_notif_'+idx+'='+z_iw28_notif[idx]);
println('--------------------------------z_iw28_notif_'+idx+'='+z_iw28_notifdesc[idx]);
println('--------------------------------z_iw28_notif_'+idx+'='+z_iw28_notifdate[idx]);
}

-> Click on "Read to Arrays" button on toolbar.
-> After execution data stored in arrays can be viewed on cornelius window.

See attachment for sreenshots
« Last Edit: October 08, 2019, 12:40:25 PM by Rahul Gera »