Imagine you have a table with an account number (0ACCOUNT), currency type (0CURTYPE) and an amount (0AMOUNT). The account number and currency type are part of the key. For every account three different records are created, namely Currency Type 00 (Document Currency), 10 (Local Currency) and 20 (Group Currency). From reporting perspective you want to have the three separate records on one line.
The basic idea behind transposing is that you want to loop over an unique combination of characteristics and then loop over it’s members. As of SAP ABAP 7.4 you are able to do this very easily using the GROUP BY function. So let’s state you want to loop over the unique accounts within the internal table above? Then you should specify 0ACCOUNT as your GROUP BY clause.
The above ABAP statement will add two records (100001 and 100002) to a new internal table. Very nice, but it does not cover our full requirement. As an additional option we can loop over it’s members and transpose them into a single line. This results in the complete code below.
Don’t forget, that because this is default SAP, it is HANA optimized, which implies that the GROUP BY statement is pushed down to the HANA database!