Last active
November 6, 2022 11:16
-
-
Save JouryJonkergouw/0bb34a8fca0a600d297cb7df2647a660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*- Data declaration | |
DATA: l_t_results TYPE STANDARD TABLE OF _ty_s_sc_1, | |
lv_index TYPE i. | |
CONSTANTS: | |
lc_curtype_00 TYPE /bi0/oicurtype VALUE '00', | |
lc_curtype_10 TYPE /bi0/oicurtype VALUE '10', | |
lc_curtype_20 TYPE /bi0/oicurtype VALUE '20', | |
lc_curtype_30 TYPE /bi0/oicurtype VALUE '30'. | |
FIELD-SYMBOLS: <lfs_result> TYPE _ty_s_sc_1. | |
*- Clear the variables, just to be sure. | |
CLEAR: l_t_results, lv_index. | |
*- Start looping at the SOURCE_PACKAGE. | |
*- Because we are aggregating the different currency type records | |
*- into one single record we group the SOURCE_PACKAGE by the complete | |
*- key except the 0CURTYPE. Further we loop over it's members to | |
*- merge the multiple records into one. | |
LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields> | |
GROUP BY ( acocunt = <source_fields>-account ) | |
ASCENDING. | |
*- Create an additional line into the results table | |
APPEND INITIAL LINE TO l_t_results ASSIGNING <lfs_result>. | |
MOVE-CORRESPONDING <source_fields> TO <lfs_result>. | |
*- Make sure the record number is unique. | |
ADD 1 TO lv_index. | |
<lfs_result>-record = lv_index. | |
*- Start looping over the different currency types and | |
*- merge them into one single record. | |
LOOP AT GROUP <source_fields> ASSIGNING FIELD-SYMBOL(<lfs_member>). | |
IF <lfs_member>-curtype EQ lc_curtype_00. | |
<lfs_result>-amount_dc = <lfs_member>-amount. | |
ELSEIF <lfs_member>-curtype EQ lc_curtype_10. | |
<lfs_result>-amount_lc = <lfs_member>-amount. | |
ELSEIF <lfs_member>-curtype EQ lc_curtype_20. | |
<lfs_result>-amount_fc = <lfs_member>-amount. | |
ENDIF. | |
ENDLOOP. | |
ENDLOOP. | |
*- Replace the SOURCE_PACKAGE with the new internal table. | |
CLEAR SOURCE_PACKAGE. | |
SOURCE_PACKAGE = l_t_results. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment