‎2006 Oct 30 1:53 PM
Hi Friends,
I have data in internal table,
ex:
matnr lgort dmbtr sum
10 xyz 100
10 xyz 500
20 pqr 200
20 pqr 400
30 abc 000
40 abc 200
I am doing the sum for the field dmbtr based on material number and storing the value under sum field.
matnr lgort dmbtr sum
10 xyz 100
10 xyz 500 600
20 pqr 200
20 pqr 400 600
30 abc 000 000
40 abc 200 200
Now I want only those records with the field sum,
Can any one tell me how to do this.
Thanx in advance,
Venu
‎2006 Oct 30 1:56 PM
Hi
Perhaps the easier way is to use another table for the sum:
DATA: ITAB_SUM LIKE STANDARD TABLE OF ITAB WITH HEADER LINE.
LOOP AT ITAB.
COLLECT ITAB TO ITAB_SUM.
DELETE ITAB.
ENDLOOP.
ITAB[] = ITAB_SUM[].
Max
‎2006 Oct 30 1:56 PM
Hi
Perhaps the easier way is to use another table for the sum:
DATA: ITAB_SUM LIKE STANDARD TABLE OF ITAB WITH HEADER LINE.
LOOP AT ITAB.
COLLECT ITAB TO ITAB_SUM.
DELETE ITAB.
ENDLOOP.
ITAB[] = ITAB_SUM[].
Max
‎2006 Oct 30 1:56 PM
Loop at itab where sum is not initial.
endloop.
OR
delete itab where sum is initial.
‎2006 Oct 30 1:59 PM
Hi Venu,
Create one more final internal table i_tab2 of type
I_tab1.(having all the details)
Loop at I_tab1 into wa_itab1.
Collect wa_itab1 into i_tab2.
I_tab2 will have all the sum values as per the matnr,Lgort.
Reward points if this helps.
Manish
‎2006 Oct 30 1:59 PM
Hi,
It seems that You need the summation by Material and Storage Location as per the given example by You.
let us say data is in itab internal table. You can write the below logic.
sort itab by matnr lgort.
loop at itab.
at end of lgort.
sum.
itab-sum = itab-dmbtr.
modify itab index sy-tabix transporting sum.
endat.
endloop.
delete itab where sum = 0.
by this logic you will get summation of records by Material and Storage location.
Thanks,
sksingh
‎2006 Oct 30 2:00 PM
Hi venu,
1. simple
2. a) Create one another internal table STAB
with only two fields, (keep field name same)
- matnr
- dmbtr
b) suppose your original internal table is itab
c) LOOP at ITAB
MOVE-CORRESPONDING ITAB TO STAB.
COLLECT STAB.
ENDLOOP.
3. This STAB will have ONLY SUMS.
regards,
amit m.
‎2006 Oct 30 2:02 PM
s d esay way is
DATA: ITAB_SUM LIKE STANDARD TABLE OF ITAB WITH HEADER LINE.
LOOP AT ITAB.
COLLECT ITAB TO ITAB_SUM.
ENDLOOP.
loop at ITAB_SUM.
print 3 fields.
endloop.
or...
for d existing code....
data: wa_itab type itab.
loop at itab.
wa_itab = itab.
at end of lgort.
print 4 ields in wa_itab.
endat.
endloop.
Ramesh.