06-29-2007 12:22 PM
Hi Experts,
I have created a report and inserted into itab. The values are
Matkl Pend.Qty. Pend Value.
=========================
SPG 5 100.00
SPG 3 300.00
SRG 2 300.00
SRG 7 800.00
Now i want to group matkl and total of Pendqty & value into another table.
How to do that.
Pl. give some idea.
Yusuf
06-29-2007 12:30 PM
hi,
chk out the code below:
sort itab1 by matkl.
loop at itab1.
at new matkl.
read table itab1 index sy-tabix.
itab2-matkl = itab1-matkl.
endat.
at end of matkl.
sum.
itab2-pendqty = itab1-pendqty.
itab2-pendvalue = itab1-pendvalue.
append itab2.
clear itab2.
endat.
endloop.
regards,
Navneeth K.
06-29-2007 12:24 PM
HI,
DATA: itab type table of <your table> with key MATKL.
Now use.
COLLECT wa into ITAB.
COLLECT sums up all the numeric fields of the table if the KEY's of the records are same.
SO when push a WOrkarea into a table using PUSH if there exists a record with the key it just adds the value that is there in the workarea to the record.
Example:
DATA: BEGIN OF seats,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
seatsocc TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE HASHED TABLE OF seats
WITH UNIQUE KEY carrid connid.
SELECT carrid connid seatsocc
FROM sflight
INTO seats.
COLLECT seats INTO seats_tab.
ENDSELECT.
Regards,
Sesh
.
.
06-29-2007 12:30 PM
hi,
chk out the code below:
sort itab1 by matkl.
loop at itab1.
at new matkl.
read table itab1 index sy-tabix.
itab2-matkl = itab1-matkl.
endat.
at end of matkl.
sum.
itab2-pendqty = itab1-pendqty.
itab2-pendvalue = itab1-pendvalue.
append itab2.
clear itab2.
endat.
endloop.
regards,
Navneeth K.
06-29-2007 12:51 PM
06-29-2007 12:45 PM
HI.
We can use collect statement for this isuse.
DATA: BEGIN WA,
Matkl type <table-filed>
Pend.Qty type <table-filed>.
Pend Value type <table-filed>.
END OF WA.
DATA ttab LIKE WA
WITH UNIQUE KEY Matkl Pend.Qty.
SELECT matfl pend_qty pend_val
FROM dbt
INTO itab.
COLLECT dbt INTO itab.
ENDSELECT.
Reward all helpfull answers.
Regards.
Jay