09-23-2008 4:44 AM
Hi
Following is my final internal table values
A/c Ord.No m/c cost mfg cost std cost raw cost other total
121 12-test 100.00 0.00 0.00 50.00 50.00 200.00
121 12-test 50.00 50.00 -10 .00 50.00 50.00 190.00
121 34-test 100.00 0.00 0.00 50.00 50.00 150.00
121 34-test 25.00 0.00 0.00 25.00 25.00 75.00
I want to change my output to (I want to add the costs using Ord. No field)
A/c Ord.No m/c cost mfg cost std cost raw cost other total
121 12-test 150.00 50.00 -10 .00 100.00 100.00 390.00
121 34-test 125.00 0.00 0.00 75.00 75.00 225.00
Please help me.
09-23-2008 6:05 AM
Hi,
write collect keyword in ur editor and press F1 u'l find full documentation, but in ur case u shud use it as
loop at itab into wa.
collect wa into itab.
endloop.
it would be better if u sort ur internal table before use.
Thanku,
Regards,
Pavani
09-23-2008 4:47 AM
09-23-2008 4:48 AM
09-23-2008 4:48 AM
Hi,
You want to sum numeric fields.
Loop the internal table and use 'COLLECT' statement with your workarea.
Try this
Regards,
R.Nagarajan
09-23-2008 5:29 AM
09-23-2008 5:44 AM
Hi
I declared my internal table like following.
Anyone pls help me how to use collect statement
DATA : BEGIN OF IT_SUM OCCURS 0,
BUDAT LIKE BSIS-BUDAT,
PERIOD(6) TYPE C,
HKONT LIKE BSIS-HKONT,
AUFNR LIKE BSIS-AUFNR,
SGTXT LIKE BSIS-SGTXT,
BLART LIKE BSIS-BLART,
DMBTR(16) TYPE P DECIMALS 2,
MACHINE(16) TYPE P DECIMALS 2,
EXTERNAL(16) TYPE P DECIMALS 2,
STANDARD(16) TYPE P DECIMALS 2,
RAW(16) TYPE P DECIMALS 2,
WAERS LIKE BSIS-WAERS,
OTHERS(16) TYPE P DECIMALS 2,
TOTAL(16) TYPE P DECIMALS 2,
END OF IT_SUM.
09-23-2008 5:49 AM
Hi...,
You can check this sample code..,
DATA: BEGIN OF itab,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
seatsocc TYPE sflight-seatsocc,
END OF itab.
DATA tab LIKE standard table of itab WITH UNIQUE KEY carrid connid.
SELECT carrid connid seatsocc
FROM sflight
INTO itab.
COLLECT itab INTO tab.
ENDSELECT.
Thanks,
Naveen.I
09-23-2008 6:05 AM
Hi,
write collect keyword in ur editor and press F1 u'l find full documentation, but in ur case u shud use it as
loop at itab into wa.
collect wa into itab.
endloop.
it would be better if u sort ur internal table before use.
Thanku,
Regards,
Pavani
09-23-2008 7:43 AM
Hi
i tried collect statement. but it is not working. any one help me pls.
09-23-2008 7:49 AM
I think SAP Statements work the same in all systems.
So if it works perfectly in mine, it should work fine in yours.
pk
09-23-2008 8:10 AM
Hi
Use AT END OF statement as in below code.
LOOP at itab.
lwa_temp-acoount = itab-account.
lwa_temp-ord_no = itab-ord_no.
ADD itab-mc_cost TO lv_mc_cost. " Do the same for all fields
AT END OF ORD_NO.
lwa_temp-mc_cost = lv_mc_cost " Do the same for all fields
APPEND lwa_temp TO lt_temp.
ENDAT.
ENDLOOP.
" Now lt_temp will have final vaues
09-23-2008 7:58 AM
firstly move these records to another internal table as it_final1[] = it_final[]
then sort the internal table it_final1 by ord.no
and then use delete adjust duplicate records then u will get the required output
syntax:-delete adjust duplicate records from it_final1 comparing ord.no