02-21-2018 11:09 AM
I have one internal table in it we have Account number, and for one account number we have multiple document numbers with different amounts respectively. In the current program only account number and sum of all document number's amount is getting displayed through COLLECT statement but now user wants document number and respective amount in the ALV as well. So I feel now COLLECT statement will not work. Total should be displayed in the new line, suppose 5 document numbers are there then total should be displayed at the 6th line. I tried one test program and fetched data from SFLIGHT table but my total is coming in at the top of the table.
02-21-2018 11:10 AM
collect-program.txt
Sample Program attached.
02-21-2018 1:08 PM
Could you please provide a code which compiles! (declaring lw_test twice leads to a syntax error)
02-21-2018 11:16 AM
Why not just look into SAP Help Documentation on COLLECT : link
02-21-2018 12:13 PM
If you are using ALV, don't use COLLECT, just fill the internal table at document level, sort by account number, declare amount as sum, define account level for subtotal. (If you add a sum record to the table, it will carry an initial document number so will be sorted by default before the records with a document number)
If you are using CL_SALV_TABLE (hopefully) use:
02-22-2018 1:30 PM
I do second Raymond's answer. Nonetheless, I recently came across this. Maybe it can be of use to you.