on 09-10-2008 7:54 PM
Hello,
I have an internal table in the following format:
Prod Order Material Req Qty Used Qty
A1 M1 2 2
A1 M2 1 0
A2 M3 3 3
A3 M1 4 0
I need to find out the material usage i.e. the no. of production orders the material was used in along with the sum of the required qty and used qty.
In the example above, the results will be
Material Req Qty Used Qty PO count
M1 6 2 2
M2 1 0 1
M3 3 3 1
I tried the following code:
SORT mat_comp_list_tmp BY matnr.
LOOP AT mat_comp_list_tmp INTO wa_comp_list_tmp.
Store the work area.
wa_comp_list_final = wa_comp_list_tmp.
AT END OF matnr.
SUM.
Move the quantity.
wa_comp_list_final-req_qty = wa_comp_list_tmp-req_qty.
wa_comp_list_final-used_qty = wa_comp_list_tmp-used_qty.
wa_comp_list_final-cnt_aufnr = sy-dbcnt.
MODIFY mat_comp_list_tmp FROM wa_comp_list_final.
ENDAT.
ENDLOOP.
But this gives me a PO count per material per Prod. Order. This is not desired.
Is there any other way to acheive this. Any help will be greatly appreciated.
Thanks,
Rugmani
Hi .. I try this.
DATA: l_cont TYPE i,
itab TYPE mat_comp_list_tmp OCCURS 0 WITH HEADER LINE.
SORT mat_comp_list_tmp BY matnr.
LOOP AT mat_comp_list_tmp INTO wa_comp_list_tmp.
AT NET matnr.
CLEAR: l_cont, itab.
ENDAT.
ADD 1 TO l_cont.
ADD wa_comp_list_tmp-req_qty TO itab-req_qty.
ADD wa_comp_list_tmp-used_qty TO itab-used_qty.
AT END OF matnr.
itab_cnt_aufnr = l_cont.
APPEND itab.
ENDAT.
ENDLOOP.
PD: itab must have matnr as first field
Thanks and Regards.
David Carballido
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The AT END OF command is called each time any field up to and including the specified field changes. So it's called on every line with your current example. If you change the internal table to place material first it will work.
Production number first
Material Req Qty Used Qty PO count
M1 2 2 1
M2 1 0 1
M3 3 3 1
M1 4 0 1
Material number first
M1 6 2 2
M2 1 0 1
M3 3 3 1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
11 | |
11 | |
6 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.