‎2007 Apr 27 12:22 PM
Hi all
I am very new to ABAP, i have a doubt on the following.
I have internal table like this
Material S Location Qty
C0001 TPIN 100
C0001 TAPS 200
C0001 CAFS 100
S1101 SCIN 25
S1101 SCOP 25
S1101 SCOP 125
I want to sum the qty by material wise and store in the variable.
The variable can be refered by another program.
Can anyone tell the solution for this.
Regards
Rajaram
‎2007 Apr 27 12:28 PM
HII
U CAN USE COLLECT STATEMENT FOR SUM
COLLECT INTERNAL TABLE NAME.
HOPE UR PROBLEM WILL GET SOLVED , IF SO REWARDS EXPECTED
GAURAV
‎2007 Apr 28 8:46 AM
hi gaurav
Thank you very much for your instant reply.
We can use COLLECT statement, but S Location is there na,
We can't put COLLECT ,
before doing COLLECT, non-numeric field should contain same data.
but our case, S Location has different data,
so how can we process now.
Regards
Rajaram
‎2007 Apr 27 12:52 PM
HI,
say your internal table name --ITAB and work area WA
lv_qty variable of type quantity
loop at ITAB into WA.
at end of matnr.
sum.
lv_qty = wa-qty.
Now you can export the material and quantity to another program..
endat.
endloop.
lv_aty contains the sum of quantity..
reward if useful
regards,
nazeer
‎2007 Apr 28 8:59 AM
hi nazeer
Thank your very much for your reply.
I don't think that by using this statement
at end of matnr.
sum.
we can sum the qty by material wise.
when we use this statement, our output would be
C001233 SLIN 25
SUM = 25
C001233 CLIN 130
SUM = 130
S3423 CCOP 100
SUM = 132
S3423 CCIN 232
Like this only, but our requirement is materiasl wise as follows
C001233 SLIN 25
C001233 CLIN 130
SUM = 155
S3423 CCOP 100
S3423 CCIN 232
SUM = 332
do you have idea of this. Anyway thank you very much for your response.
Regards
Rajaram
‎2007 Apr 27 12:53 PM
hello raja ram.
use this sample code, exe it and see, i think it will be useful
copy the same code and execute u will get an idea....
REPORT ZY_TEST1.
TYPES : BEGIN OF TY_ITAB,
PERNR TYPE PA0001-PERNR,
HRS(3) TYPE N,
WKS(3) TYPE N,
END OF TY_ITAB.
DATA : ITAB TYPE TABLE OF TY_ITAB WITH HEADER LINE.
DATA : ITAB2 TYPE TABLE OF TY_ITAB WITH HEADER LINE.
DATA : WF_HRS(3) TYPE N,
WF_WKS(3) TYPE N,
WA TYPE TY_ITAB .
ITAB-PERNR = '1'.
ITAB-HRS = '5'.
ITAB-WKS = '1'.
APPEND ITAB.
ITAB-PERNR = '1'.
ITAB-HRS = '6'.
ITAB-WKS = '2'.
APPEND ITAB.
ITAB-PERNR = '1'.
ITAB-HRS = '7'.
ITAB-WKS = '3'.
APPEND ITAB.
ITAB-PERNR = '2'.
ITAB-HRS = '5'.
ITAB-WKS = '4'.
APPEND ITAB.
ITAB-PERNR = '2'.
ITAB-HRS = '5'.
ITAB-WKS = '5'.
APPEND ITAB.
ITAB-PERNR = '3'.
ITAB-HRS = '5'.
ITAB-WKS = '1'.
APPEND ITAB.
ITAB-PERNR = '4'.
ITAB-HRS = '5'.
ITAB-WKS = '1'.
APPEND ITAB.
ITAB-PERNR = '4'.
ITAB-HRS = '7'.
ITAB-WKS = '8'.
APPEND ITAB.
LOOP AT ITAB.
WA = ITAB.
WF_HRS = WF_HRS + WA-HRS.
WF_WKS = WF_WKS + WA-WKS.
AT END OF PERNR.
CLEAR: ITAB2.
ITAB2-PERNR = WA-PERNR.
ITAB2-HRS = WF_HRS.
ITAB2-WKS = WF_WKS.
APPEND ITAB2.
CLEAR: WF_HRS, WF_WKS .
ENDAT.
ENDLOOP.
WRITE 😕 'BEFORE'.
LOOP AT ITAB.
WRITE 😕 ITAB-PERNR, 10 ITAB-HRS, 20 ITAB-WKS.
ENDLOOP.
SKIP 2.
WRITE 😕 'AFTER'.
loop at itab2.
WRITE 😕 ITAB2-PERNR, 10 ITAB2-HRS, 20 ITAB2-WKS.
ENDLOOP.
‎2007 Apr 28 10:35 AM
hi Bharani
It is really nice, and thank you very much.
It is very helpful to me, thank you.
Now my problem solved.
Thank you all for giving me great support on this forum.
Regards
Rajaram
‎2007 May 22 7:49 AM
hello raja ram,
giv ur gmail id yaar
mine is bharanidaran.sb1@gmail.com
With Regards,
S.Barani
‎2007 May 22 9:25 AM