05-28-2007 1:31 AM
friends,
i have aproblem,
the following can make you understand better.
name marks
-
john 20
john 30
john 40
martin 30
smith 20
martin 20
smith 10
this itab1 must be converted to itab2 given below
name marks
_______________________________
john 90(=203040)
martin 50(=30+20)
smith 30(=20+10)
what would be the best way of coding.
thank you.
05-28-2007 1:36 AM
Hi saritha,
loop at itab1.
itab2-name = itab1-name.
itab2-marks = itab1-marks.
collect itab2.
endloop.
Reward points if useful.
Regards,
Atish
05-28-2007 1:36 AM
Hi saritha,
loop at itab1.
itab2-name = itab1-name.
itab2-marks = itab1-marks.
collect itab2.
endloop.
Reward points if useful.
Regards,
Atish
05-28-2007 1:37 AM
05-28-2007 1:53 AM
but friends,
i have two questions:
1)after using collect statement,
will there be redundant entries like,
john
john
john
or only one john
2) if in place on name there is any numeric field like company code
will this collect statement add up the numeric company codes too. which should not happen.
thanks again.
05-28-2007 1:56 AM
Hi Saritha,
1 - There will be no JOHN multiple times. It will just add numeric values which has the same key (All character fields).
2 - Company code are always numeric, but if you see the data type attached it is BUKRS which is of type character 4. So no need to worry
Reward points if useful.
Regards,
Atish
05-28-2007 2:04 AM
when any key fields(genrally fields which are of C,N,D,T,X datatypes are by default assign to the key fields of itab) of itab is repeating then the non key fields (like I,P) is getting added. so as per your requirement check the key fields are belongs to that data type or not.
regards
shiba dutta