2022 Nov 29 12:27 PM
Hello Gurus,
Can you please explain the way or approach to implement report for below output. itab[] entries may increase.
Thank you.
2022 Nov 29 3:33 PM
Hello,
You can create a Dynamic table from your field catalog and fill it with field symbols.
Regards.
2022 Nov 29 7:26 PM
Sorry but you can't have an internal table with 2 same field names e.g. FIELD1 can appear only once.
2022 Nov 29 7:30 PM
Hello,
If I understood correctly, my procedure would be:
1. Find the maximum number of rows with the same DOCNUM.
2. Multiply this number by the number of FIELD columns.
3. Add 1 to the calculated number. This is the component count of the OUTPUT table.
- Formula: 1 + ( [Number of FIELD columns] x [Maximum number of rows with same DOCNUM] )
- In your example this number would be: 1 + ( 4 x 4 ) = 17
4. Create a dynamic structure with the first field being DOCNUM followed by the FIELD fields.
- First field: DOCNUM (1x)
- Subsequent fields: Repetitive of FIELD fields (in your example 4 x 4 = 16x). Add a counter to FIELD columns to make them unique.
5. Create a dynamic table from the dynamic structure.
6. Sort the ITAB table by DOCNUM.
7. Loop at the ITAB table group by DOCNUM.
8. Add an initial line to OUTPUT table and assign it to a field symbol. Let's say this is <dst>. (dst: destination)
9. For each new group, set the DOCNUM field in the <dst> structure.
10. For each row that have same DOCNUM group, move the FIELD fields to the corresponding fields in <dst>. While doing this, a COUNTER variable can be used. (When the COUNTER value reaches the total number of FIELD columns per DOCNUM, transfer was done).
11. Eventually, the OUTPUT table will have rows where some FIELD fields are full and some are empty based on the number of rows in each DOCNUM.