05-11-2009 8:17 PM
Hi gurus,
I have an ALV GRID and I have this requeriment:
"In Totals row, there must be the numbers of rows where the field FLAG is set to 'X''.
I'm calling the totals row with IT_SORT parameter in 'REUSE_ALV_GRID_DISPLAY' and setting the attribute DO_SUM in the fieldcat for the fields I need to sumarize; but I need to count how many rows have value 'X'.
How can I do this? Some ideas?
An Example of what I need:
Col.A | Col.B
1000 | X
2000 |
3000 | X
_____________________
6000 | 2 <- TOTALS ROW
A lot of thanks.
Edited by: Ole ES on May 11, 2009 9:18 PM
05-11-2009 8:26 PM
Hi ,
For this u can add one more field into ur internal table and loop through the table to update the field according to the field marked as 'X' and modify the table.
Now u can give this table to ALV dispaly with the total of the new field giving the total no of records having specific field marked as 'X'
Regards,
Anuj
Edited by: ANUJ SRIVASTAVA on May 12, 2009 1:05 AM
05-11-2009 8:29 PM
05-11-2009 8:53 PM
Create a Col3 as integer type and move a 1 to it for every occurance of X in Col2. You can then hide Col2.
05-12-2009 8:07 AM
I've already thought in that solution...but I need the totals under the colum with 'X'.
I've started thinking my requeriment is not possible; at least, not easily possible
05-14-2009 12:07 PM
I havent' found a solution yet...
¿Some more ideas?
Edited by: Ole ES on May 14, 2009 2:53 PM
05-14-2009 2:04 PM
Its simple but you dont need to use do_sum now.
Suppose your internal table is itab with column names as A and B.
itab
A B
3000 X
2000
1000 X
data final type i.
data count type i.
Loop at itab into wa.
final = wa-A + final.
if wa-B = 'X'.
count = count + 1.
endif.
endloop.
wa-A = final.
wa-B = count.
append wa to itab.
I think this will solve your problem and u dont need to do do_sum.
05-14-2009 2:33 PM
I think this is not a solution for my issue.
What I need is show a number in totals row; but in the normal rows, I need to show 'X'.
Colum A
X
X
X
X
___
4 <- Totals Row that appears with 'do_sum' at fieldcat.
05-14-2009 2:36 PM
the value of count is having the number of 'X' in your table. And u can store this count value in the same column and append this row at the end of your table. My code should work fine. Have u tried??
05-14-2009 2:42 PM
Your code works great; but I need 'do_sum' at all because I need to sumarize another fields too; and I want to preserve standard ALV funcion buttons.
If I compute in my programa the totals row; I lose the ALV control when pushing sorting buttons, for example.
Edited by: Ole ES on May 14, 2009 4:15 PM
11-17-2010 8:11 AM