07-25-2007 11:58 AM
Hi,
I have all my data in my fs_table which is nothing but field symbol , i need to sum up all the values which are of the same vbeln present in that internal table...
whats the way out?
LOOP AT <fs_table> ASSIGNING <fs_line>.
AT END OF <fs_line>-vbeln.
SUM.
ENDAT.
ENDLOOP.
Regards
Gunjan
07-25-2007 12:03 PM
hi thr,
chk out this sample code....
DATA: BEGIN OF wa,
col1 TYPE string,
col2 TYPE i,
END OF wa.
data : itab like wa occurs 0 with header line.
itab-col1 = 'A'.
itab-col2 = '10'.
APPEND itab .
itab-col1 = 'B'.
itab-col2 = '20'.
APPEND itab .
itab-col1 = 'A'.
itab-col2 = '10'.
APPEND itab.
itab-col1 = 'B'.
itab-col2 = '10'.
APPEND itab.
sort itab by col1.
loop at itab.
write:/ itab-col1, itab-col2.
at end of col1.
sum .
write:/ itab-col2.
endat.
endloop.
Regards,
Roshani
07-25-2007 12:04 PM
Hi,
LOOP AT itab into wa.
data : l_wa like wa.
l_wa = wa.
AT END OF l_wa-vbeln.
SUM.
ENDAT.
ENDLOOP.
Reward points if helpful.
Regards.
Srikanta Gope
07-25-2007 12:06 PM
Hi,
use this logic surely your problem will be solved.
CLEAR : WA_PMCO, W_TOTAL, W_PLND_TOTAL.
MATERIAL Planed COST IN Rs
SELECT SUM( WRT00 ) SUM( WRT01 ) SUM( WRT02 ) SUM( WRT03 )
SUM( WRT04 ) SUM( WRT05 ) SUM( WRT06 ) SUM( WRT07 )
SUM( WRT08 ) SUM( WRT09 ) SUM( WRT10 ) SUM( WRT11 )
SUM( WRT12 ) SUM( WRT13 ) SUM( WRT14 ) SUM( WRT15 )
SUM( WRT16 )
FROM PMCO
INTO (WA_PMCO-WRT00,WA_PMCO-WRT01,WA_PMCO-WRT02,WA_PMCO-WRT03,
WA_PMCO-WRT04,WA_PMCO-WRT05,WA_PMCO-WRT06,WA_PMCO-WRT07,
WA_PMCO-WRT08,WA_PMCO-WRT09,WA_PMCO-WRT10,WA_PMCO-WRT11,
WA_PMCO-WRT12,WA_PMCO-WRT13,WA_PMCO-WRT14,WA_PMCO-WRT15,
WA_PMCO-WRT16)
WHERE WRTTP = '01' AND
ACPOS = '905' AND
OBJNR = T_AUFK-OBJNR
AND VORGA EQ 'KPPZ'.
W_TOTAL = WA_PMCO-WRT00 + WA_PMCO-WRT01 + WA_PMCO-WRT02 +
WA_PMCO-WRT03 + WA_PMCO-WRT04 + WA_PMCO-WRT05 +
WA_PMCO-WRT06 + WA_PMCO-WRT07 + WA_PMCO-WRT08 +
WA_PMCO-WRT09 + WA_PMCO-WRT10 + WA_PMCO-WRT11 +
WA_PMCO-WRT12 + WA_PMCO-WRT13 + WA_PMCO-WRT14 +
WA_PMCO-WRT15 + WA_PMCO-WRT16.
W_PLND_TOTAL = W_PLND_TOTAL + W_TOTAL.
*code ended
regards
vijay