Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Report query

Hi Team,

we have a requirement like this Example shown as follows:

Bukrs Racct Balance

001 0010010010 1000

001 0010010011 1000

001 0010010012 1000

001 0010010013 1000

001 0010010020 1000

001 0010010021 1000

001 0010010022 1000

002 0010010010 1000

002 0010010011 1000

002 0010010012 1000

001 0010010030 1000

001 0010010031 1000

Output should comes as follows:

Bukrs Racct Balance

001 0010010010 4000

001 0010010020 3000

002 0010010010 3000

001 0010010030 2000

0010010010 is a main account balance and 0010010011/2/3 is a sub account balance .Total balance in result itab contain addition of main acount balance + sub acount balance which is shown as above mentioned Results.

So please clarify this how we proceed the code for calculating the summation of Main account balance and sub acount balance into another internal table.

i think this is enough information.

Thanks.

Puneet.

Tags:
Former Member
Former Member replied

Looking bit interesting .. I tried like this..

TYPES : BEGIN OF t_tab,
        bukrs(4),
        racct(10),
        balance(4) TYPE p,
        END OF t_tab.
DATA : it_tab TYPE STANDARD TABLE OF t_tab,
       wa_tab TYPE t_tab,
       it_final TYPE STANDARD TABLE OF t_tab,
       wa_final TYPE t_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010010'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010011'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010012'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010013'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010020'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010021'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010022'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '002'.
wa_tab-racct = '0010010010'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '002'.
wa_tab-racct = '0010010011'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '002'.
wa_tab-racct = '0010010012'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010030'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

wa_tab-bukrs = '001'.
wa_tab-racct = '0010010031'.
wa_tab-balance = '1000'.
APPEND wa_tab TO it_tab.

SORT it_tab BY bukrs racct.

LOOP AT it_tab INTO wa_tab.
  ON CHANGE OF wa_tab-racct+0(9).
    MOVE-CORRESPONDING wa_tab TO wa_final.
  ENDON.
  AT END OF racct+0(9).
    SUM.
    wa_final-balance = wa_tab-balance.
    APPEND wa_final TO it_final.
  ENDAT.

ENDLOOP.

LOOP AT it_final INTO wa_final.
  WRITE :/ wa_final-bukrs, wa_final-racct, wa_final-balance.
ENDLOOP.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question