09-02-2008 4:42 PM
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.
09-02-2008 5:33 PM
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.
09-02-2008 4:47 PM
You can use the COLLECT statment to do this. Before using the COLLECT you must have to set the relationship between the Master and Sub GL accounts.
So, take one more field in the table: MASTER_GL.
Based on your rules modify the MASTER_GL field.
BUK GL AMT MASTER_GL
001 0010010010 1000 0010010010
001 0010010011 1000 0010010010
001 0010010012 1000 0010010010
001 0010010013 1000 0010010010
001 0010010020 1000 0010010020
001 0010010021 1000 0010010020
001 0010010022 1000 0010010020
002 0010010010 1000 0010010010
002 0010010011 1000 0010010010
002 0010010012 1000 0010010010
001 0010010030 1000 0010010030
001 0010010031 1000 0010010031
Now loop on this table and Use COLLECT to get the sum based on the company and MASTER_GL.
LOOP AT ITAB.
IT_SUM-BUKRS = ITAB-BUKRS.
IT_SUM-GL = ITAB-MASTER_GL.
IT_SUM-DMBTR = ITAB-DMBTR.
COLLECT IT_SUM.
CLEAR: IT_SUM, ITAB.
ENDLOOP.
Regards,
Naimesh Patel
09-02-2008 5:13 PM
In what basis we fill up the master_GL field .could you please eleborate , how you filled the master_GL values .
Thanks.
Puneet
09-02-2008 4:48 PM
take at new on account number and try to search if there is any flag in the database table to indicate a sub account.if yes, it makes ur job easy.
but still, at-new triggers for both bukrs and account number. so u can do ur additions.
but make sure u have no double entries for each sub account.if u have, this logic will not work as at-new will not trigger for that record.
or u can even use COLLECT statement in a loop.
Let me know if u need any more help.
Hope this helps.
Thanks.
Kiran
Edited by: kiran dasari on Sep 2, 2008 9:18 PM
09-02-2008 5:33 PM
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.
09-02-2008 5:46 PM
Hi Perez C,
Thanks for ur solution it's .Really appreciated to you . You have done excellent work and resuce my tension for resolving quick reply as well better solution provided.
Once again thanks Perez. Keep it up.
It worked in my program.
Thanks.
Puneet.