cancel
Showing results for 
Search instead for 
Did you mean: 

Add the number of values from VA03 with SAP screen Personas 3.0

former_member604646
Discoverer
0 Kudos

Hello,

Situation:

Within a sales order (VA03) we have several items for different divisions in the Tabpage Item Overview.

For instance:

Item 1 - Division 10 - 1500 Pounds

Item 2 - Division 11 - 1000 Pounds

Item 3 - Division 10 - 1500 Pounds

Item 4 - Division 11 - 1000 Pounds

Each item has a certain number of pounds per division.


Question:

How do I add the number of pounds per division within Screen Personas 3.0?


Result:

Division 10 = 3000 Pounds

Division 11 = 2000 Pounds

Can someone help me with this problem?

Regards,

Tom

Accepted Solutions (0)

Answers (1)

Answers (1)

bwills
Contributor
0 Kudos

Hi Tom,

This can be done, but it is a bit complicated. You for sure need to understand JavaScript coding. You should be able to adapt the code I am providing here to do what you need. This code only gets the first 2 columns, hence 0010 and material number. You can adapt this code to look up any column you want or all the columns if you want to. Best to just put it in and debug it via the debugger script statement in the browser, that way you can see what's going on.

// onAfterRefresh
session.utils.log("onAfterRefresh");
var table = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\01/ssubSUBSCREEN_BODY:SAPMV45A:4402/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG");
var zContents = getTableContents(table);
debugger;
//Read Table Contents
function getTableContents(zStatusTable)
{
 session.utils.log('==================================== Read Table Contents Function ===============================');
 session.utils.log('zStatusTable.firstVisibleRow =>' + zStatusTable.firstVisibleRow);
 session.utils.log('zStatusTable.visibleRowCount =>' + zStatusTable.visibleRowCount);
 session.utils.log('zStatusTable.rowCount =>' + zStatusTable.rowCount);
 
 
 
 var zFoundYa = false;
 var zContents = [];
 var zcolumns = zStatusTable.columns;
 var zname;
 var oRow = [];
 var zTrackRow = 0;
 var zXcolumnname = zcolumns.elementAt(0).name;       //1st column
 var zStatusColumnName = zcolumns.elementAt(1).name;  //2nd column

debugger; 
 zStatusTable.firstVisibleRow = 0;
 var zStatusVisibleRows = zStatusTable.visibleRowCount - 1;  //Number of visable rows in the table at 0-based index (does not change).
 for(var zCurrentRow = 0; zCurrentRow < zStatusTable.rowCount; zCurrentRow++)
 {
  oRow = {};  //clear the oRow variable - reinitialize it
  
  //Start - scrolling only
  if(zCurrentRow > zStatusVisibleRows)
  { 
   if(zStatusVisibleRows + zStatusTable.visibleRowCount > zStatusTable.rowCount) //Make sure not to go past the last row in the table
   {
    zStatusTable.firstVisibleRow = zStatusTable.rowCount - zStatusTable.visibleRowCount;  
   }
   else
   {
    zStatusTable.firstVisibleRow = zStatusVisibleRows + 1;  //Pagedown in table
   }
   zStatusVisibleRows += zStatusTable.visibleRowCount;
  }
  //End - scrolling only
  
  //Populate columns 0 and 1 into oRow array
  for(var i=0; i <= 1; i++)  // only want columns 0 and 1
  {
   var zColumnName = zcolumns.elementAt(i).name;
   
   //if(zDebug > 1) session.utils.log('zCurrentRow = ' + zCurrentRow + ', zColumnName = ' + zColumnName + ' Value = ' + zStatusTable.getCellValue(zCurrentRow, zColumnName));
   
   if(zStatusTable.getCellValue(zCurrentRow, zColumnName) == '____')
   {
    session.utils.log('Last Row - Exit For Loop');
    //zFoundYa = true;
    zCurrentRow = zStatusTable.rowCount;  //End looping
    break;
   }
    
   oRow[i] = zStatusTable.getCellValue(zCurrentRow, zColumnName);
  }
  
  //Add Array to the Array
  zContents.push(oRow);
 }
 zStatusTable.firstVisibleRow = 0;
 return zContents;
}

Thanks,

Brian