on 05-04-2016 5:14 PM
Hi Experts, I have a table grid and I would like to populate certain values in a row of a table grid .In my case I can have first 3 rows filled up so I have to populate the fields in 4rth row . I can have any number of rows filled .so how would I know what my next empty row would be ? Kindly suggest .
Hi,
you can test if a cell in a text column only contain underscores ("_"):
if
(row[columns.elementAt(0).name] && !row[columns.elementAt(0).name].replace(/_/g,
""
)) {
break
;
}
as suggested by Copying Table data into a variable - SAP Imagineering - SCN Wiki .
Cheers,
Clemens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Clemens , My requirement is to populate work order and operation (example 010 or 020)from IW32 to CAT2. In CAT2 there is a grid and there are columns for work order and operation. So basically i captured the work order and operation when i came to CAT2 . Now i see grid can have values starting from 3rd row and if this 3rd row is blank then i need to populate the two values in this 3rd row of gird since its blank. Now i can have a case where 7 th row is blank hence i have to populate there. I am able to capture the values from iw32 but when i came to CAT2 transaction.Here is where the difficulty is ( i have to populate those values in grid ) . Best regards, pradeep.
Hi,
you have to loop through your table until you find the first row with an empty cell value. I used the Total column for a test. The following script worked for me. Please note that I would recommend you use the table.modifyCell() method but it has a bug, so you have to build the cell id and use findById() instead.
var table = session.findById("wnd[0]/usr/subCATS002:SAPLCATS:2200/tblSAPLCATSTC_CATSD");
for (var i=table.firstVisibleRow; i<(table.firstVisibleRow+table.visibleRowCount); i++){
if(table.getCellValue(i, "CATSD-SUMDAYS")=='') {
session.findById("wnd[0]/usr/subCATS002:SAPLCATS:2200/tblSAPLCATSTC_CATSD/txtCATSD-DAY1[7,"+i+"]").text="4";
break;
}
}
Best Regards,
Clemens
Hi Clemens, I tried the logic you gave but works only for few cases .Let me brief you , I have 3 visible rows intially where 0,1 are just empty and i can not enter any values.(its kind of read only and these are blank). In the third row i can enter values (which means not just read only). Basically i can see only 3 rows at any point unless i scroll down . so intially 2 blank rows (read only and then 1 row where i can enter value). The logic you have given works until i have entries up to 5 .which means 0,1 just read only and then 2,3,4 has values . If i set first visible row as 0 then for loop iterates 3 times as visiblerow count plus visiblerow is ( 3+0 = 3) (first time 0, second iteration 1 and third iteration 2) once this is done then it exits. i tried using rowcount property instead of table.firstVisibleRow+table.visibleRowCount in for loop ,but it gives me message that rowindex 4 or say 5 is not visible . How can i tackle this problem where i have only 3 visible rows at any given time. Also i tried to use alternative for modify cell and in that case session.findid is having issue with the i value (as 2 instead of 4 ). This is how the gird is structured : As i scroll down little then i can see 1,2,3 rows instead of 0,1,2. when i scroll further then i can see 2,3,4 instead of 1,2,3 and then i can see 3,4,5 instead of 2,3,4 and so on and so on. I am trying to populate work order and operation from IW32 in CAT2 grid that i just mentioned . This grid have 3 visible rows initially and first 2 rows read only . Kindly suggest . Best regards, pradeep.
Hello Pradeep,
as I said GuiTableControl.modifyCell() has defect (for which we will release a fix as soon as possible), so you have to stick with session.findById() for now. The thing to remember with table control is that the IDs of its cell are static and reflect visible layout of the table. In other words if you only have three visible rows, then the row index portion of the IDs will always be 0,1,or 2, no matter what the firstVisibleRow property is. So you have to correct the cell id that you build by firstVisibleRow.
My suggestion is to change your script to do the following:
a) Find the first empty row as outlined above and fill it with the data from the other transaction
b) Increase property firstVisibleRow by one. The system should now append a new row at the end of the table.
c) Repeat the steps until all data is added.
Best Regards,
Clemens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.