2023 Oct 05 1:00 PM
I'm having alv report having DMBTR field , client asked me to add another column that should be cumulative of dmbtr filed... i tried this but no use ....can anyone help me on this?
SORT IT_FINAL BY LIFNR.
LOOP AT it_FINAL INTO WA_FINAL.
* AT NEW LIFNR.
IF WA_FINAL-LIFNR = 'VDSIVATC01'.
* gv_cumulative_sum = WA_FINAL-BASE + gv_cumulative_sum .
gv_cumulative_sum = gv_cumulative_sum + WA_FINAL-BASE .
WA_FINAL-CUM = gv_cumulative_sum.
MODIFY it_FINAL FROM WA_FINAL TRANSPORTING CUM WHERE LIFNR = 'VDSIVATC01'.
* ENDAT.
CLEAR :WA_FINAL.
ENDIF.
2023 Oct 05 4:08 PM
Try
SORT IT_FINAL BY name.
LOOP AT it_FINAL ASSIGNINBG <fs>.
AT NEW name.
CLEAR lv_cumulative_sum.
ENDAT.
<fs>-cum = lv_cumulative_sum = lv_cumulative_sum + <fs>-BASE.
ENDAT.
But if user change the sort order you sum will get wrong (disable sort options or handle relevant event to update those values)
2023 Oct 05 4:08 PM
Try
SORT IT_FINAL BY name.
LOOP AT it_FINAL ASSIGNINBG <fs>.
AT NEW name.
CLEAR lv_cumulative_sum.
ENDAT.
<fs>-cum = lv_cumulative_sum = lv_cumulative_sum + <fs>-BASE.
ENDAT.
But if user change the sort order you sum will get wrong (disable sort options or handle relevant event to update those values)
2023 Oct 05 6:47 PM
Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!
2023 Oct 05 6:51 PM
It seems that your requirement is to group by NAME and cumulate DMBTR for each NAME value.
You should explain what you currently get and what you expect instead of "it doesn't work". People can't have any idea of what is in your mind.
What is BASE ? I expected DMBTR...
Why are you doing WHERE name = ' ' ?