2009 Apr 14 7:26 AM
Dear Apapers,
My requirement is count based on matnr and werks. that is how many same matnr available in particular plant wise.
My input is,
Matnr werks
12 chen
12 chen
12 pblr
13 chen in this via
my target is,
matnr werks cnt
12 chen 2
12 pblr 1
13 chen 1 . plz help me?how to resolve this issues..
regards,
prabu
2009 Apr 14 7:29 AM
You can use control break statement inside your loop,
declare a 3rd variable as counter now
loop .
at end of
or
at last
increase the counter by 1
endloop
Hope it helps
Bhanu
Dear Apapers,
My requirement is count based on matnr and werks. that is how many same matnr available in particular plant wise.
My input is,
Matnr werks
12 chen
12 chen
12 pblr
13 chen in this via
my target is,
matnr werks cnt
12 chen 2
12 pblr 1
13 chen 1 . plz help me?how to resolve this issues..
regards,
prabu
2009 Apr 14 7:29 AM
You can use control break statement inside your loop,
declare a 3rd variable as counter now
loop .
at end of
or
at last
increase the counter by 1
endloop
Hope it helps
Bhanu
2009 Apr 14 7:29 AM
Sort your table .
Then loop at table and use AT END OF to count number of occurances.
Hope it helps you.
2009 Apr 14 7:29 AM
Try this!
Loop at the internal table.
Check if the material and plant combination is same for 1st and 2nd record.If yes increment the counter else reset it. Store the counter value in same internal table.
2009 Apr 14 7:31 AM
Hi,
Use:-
DATA : v_count TYPE i.
SORT itab BY matnr werks.
LOOP AT itab INTO wa.
CLEAR v_count.
AT NEW werks.
v_count = v_count + 1. "<--increment counter
ENDAT.
wa_count = v_count. "<--move value to work area
MODIFY itab FROM wa INDEX sy-tabix TRANSPORTING count. "<--modify internal table
CLEAR wa.
ENDLOOP.
Hope this helps you.
Regards,
Tarun
2009 Apr 14 7:34 AM
Hi,
create a new structure wa_new with matnr, werks, count(type i).
then
loop at itab into wa_itab.
wa_new-matnr = wa_itab-matnr.
wa_new-werks = wa_itab-werks.
wa_new-count = 1.
collect wa_new into itab_new.
endloop.
Thus, itab_new will contain the require output.
Regards.
2009 Apr 14 7:37 AM
Dear this you cae do as follow
make a duplicate copy of your internal table .
say :
it_mara and it_mara_dup .
loop at it_mara into wa_mara .
at new wa_mara-werks .
loop at it_mara_dup where werks = wa_mara-werks into wa_mara_dup .
count = count + 1 .
endlloop.
endat.
endloop.regards ankit
2009 Apr 14 7:39 AM
create an internal table itab1 and wa1 with fields matnr werks count.
DATA : count TYPE i.
SORT itab BY matnr werks.
LOOP AT itab INTO wa.
count = count + 1.
AT end werks. " triggered when matnr or werks is about to change
CLEAR count
wa1-matnr = wa-matnr.
wa1-werks = wa-werks.
wa1-count = count.
append wa1 into itab1. " add matnr werks and count in itab1
ENDAT.
ENDLOOP.the table itab1 that you get contains the number of times a matnr and werks repeats.
Regards,
Lalit Mohan Gupta.