2006 Feb 27 4:44 AM
Hi experts,
I have itab like this/
GSBER AMT1 AMT2
8003 7,450.52 7,450.52
8003 8,166.40 8,166.40
8007 7,630.20 7,630.20
8007 6,510.80 6,510.80
Iam trying to collect like this.
loop at itab.
move-corresponding itab to itab2.
collect itab2.
endloop.
Why it is not summing AMT1 & AMT2?
thanks
kaki
2006 Feb 27 4:52 AM
plz see for the type of your fields. Only numeric components( i, p , f) are added in collect statement.
plz do some work with data type of ur variables...ur work ll be done..
regards.
Hi Kaki,
COLLECT will only work with number type fields(I,P,F).
Regards,
Abdul Hakim
2006 Feb 27 4:52 AM
plz see for the type of your fields. Only numeric components( i, p , f) are added in collect statement.
plz do some work with data type of ur variables...ur work ll be done..
regards.
2006 Feb 27 4:53 AM
Is your data type a Packed number?
Check this code... It works with data type p.
DATA: BEGIN OF itab OCCURS 0,
gsber(10),
amt TYPE p DECIMALS 2,
amt2 TYPE p DECIMALS 2,
END OF itab.
DATA itab1 LIKE TABLE OF itab WITH HEADER LINE.
itab-gsber = '1'.
itab-amt = '100.23'.
itab-amt2 = '100.23'.
APPEND itab.
APPEND itab.
APPEND itab.
itab-gsber = '2'.
itab-amt = '10.23'.
itab-amt2 = '100.23'.
APPEND itab.
APPEND itab.
APPEND itab.
LOOP At itab.
move-corresponding itab to itab1.
collect itab1.
ENDLOOP.
WRITE : 'f'.
2006 Feb 27 4:54 AM
Hi Kaki,
Check whether the field declaration of both AMT1 & AMT2 are declared with same data type i.e,( i,N ) ...
Regards,
Santosh P
2006 Feb 27 4:58 AM
hi Kaki,
REPORT ZTEST.
data: begin of itab occurs 0,
gsber type gsber,
amt1 type p decimals 2,
amt2 type p decimals 2,
end of itab.
data: itab2 like itab occurs 0 with header line.
itab-GSBER = '8003'.
itab-AMT1 = '8166.40'.
itab-AMT2 = '8166.40'.
append itab.
itab-GSBER = '8003'.
itab-AMT1 = '7450.52'.
itab-AMT2 = '7450.52' .
append itab.
itab-GSBER = '8007'.
itab-AMT1 = '7630.20'.
itab-AMT2 = '7630.20'.
append itab.
itab-GSBER = '8007'.
itab-AMT1 = '6510.80'.
itab-AMT2 = '6510.80'.
append itab.
clear itab.
sort itab by gsber.
loop at itab.
move-corresponding itab to itab2.
collect itab2.
endloop.
break-point.Regards
vijay
2006 Feb 27 5:06 AM
hi Kaki,
I hope it is a currency field..
i think the currency field will not be added when you use collect..
if you want to add when you append you can do like this..
data : itab1_wa like line of itab.
.....
loop at itab.
move itab to itab1_wa.
itab1_wa-amt1 = itab1-amt1 + itab1_wa-amt1.
itab1_wa-amt2 = itab1-amt2 + itab1_wa-amt2.
itab1 = itab1_wa.
append itab1.
endloop.regards
satesh
2006 Feb 27 6:18 AM
Hi Kaki,
COLLECT will only work with number type fields(I,P,F).
Regards,
Abdul Hakim
2006 Feb 27 6:33 AM
Hi kaki,
1. Make sure the FIELD-NAMES
AMT1, AMT2, GSBER
are same in ITAB2. (same like itab1)
2. Instead of trying with COLLECT,
just use APPEND to see
if ITAB2 really gets the data or not !
regards,
amit m.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |