Skip to content

Instantly share code, notes, and snippets.

@JouryJonkergouw
Last active November 6, 2022 11:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JouryJonkergouw/0bb34a8fca0a600d297cb7df2647a660 to your computer and use it in GitHub Desktop.
Save JouryJonkergouw/0bb34a8fca0a600d297cb7df2647a660 to your computer and use it in GitHub Desktop.
*- 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