‎2007 Sep 20 10:31 PM
Hi,
1)i have internal table with material ,plant , stlal fields.
for same material and plant ...stlal has different values.
so i have select the material and plant which has minimum stlal value.
please tell how to select the value ..or pls give me sample code.
2) i have internal table with material number and plant.
There may be more than on material for same plant.
so i have to pass material numbers and plant to other program based on plant wise.
please give me sample code ... other program has selection screen which has material number as selection option and plant as parameter.
i have to use submit statement for this condition.
please help by giving sample code
thanks
satish
‎2007 Sep 21 2:43 AM
Ans1. Suppose ur internal table name is itab containing 3 fields matnr,werks,stlal.Now u want the mat and plant with min stlal value.heres the code
sort itab by stlal descending.
read table itab into ls_tab index 1.
Now ls_tab is a work area which will contain the material and plant values which has min stlal value.
Ans2.
Declare a range table lt_matnr for all the material no corresponding to the plant.
Now
Loop at itab into ls_tab where plant = lv_plant.
ls_matnr-sign = 'I'.
ls_matnr-option='EQ'.
ls_matnr-low = ls_tab-matnr.
Append ls_matnr to lt_matnr.
Clear ls_matnr,ls_tab.
Endloop.
so now lt_matnr will contain all the matnr corresponding to each plant.
thanks,
ashish.
‎2007 Sep 21 2:43 AM
Ans1. Suppose ur internal table name is itab containing 3 fields matnr,werks,stlal.Now u want the mat and plant with min stlal value.heres the code
sort itab by stlal descending.
read table itab into ls_tab index 1.
Now ls_tab is a work area which will contain the material and plant values which has min stlal value.
Ans2.
Declare a range table lt_matnr for all the material no corresponding to the plant.
Now
Loop at itab into ls_tab where plant = lv_plant.
ls_matnr-sign = 'I'.
ls_matnr-option='EQ'.
ls_matnr-low = ls_tab-matnr.
Append ls_matnr to lt_matnr.
Clear ls_matnr,ls_tab.
Endloop.
so now lt_matnr will contain all the matnr corresponding to each plant.
thanks,
ashish.
‎2007 Sep 21 2:52 AM
I have seen answer suggested by Ashish.
Question 2 is answered correctly.
For question 1
select matnr werks stlal into itab.
sort itab.
delete adjacent duplicates from itab comparing matnr werks.
This will delete duplicate entries from itab for each material and plat. As this is sorted ascending first record will contain min value for STLAL and this is your requirement.
In itab declaration, field sequence should be MATNR WERKS STLAL.
‎2007 Sep 21 3:28 AM
hi ashish d,
thanks for your answer...how to declare ranges can u pls given example...
thanks
satish
‎2007 Sep 21 3:36 AM
ranges: r_matnr for mara-matnr.
This is the way you declare ranges.
‎2007 Sep 21 4:01 AM
HI,
how to write full code..i m getting error..
ranges : ls_matnr for mara-matnr.
Loop at itab into ls_tab where plant = lv_plant.
ls_matnr-sign = 'I'.
ls_matnr-option='EQ'.
ls_matnr-low = ls_tab-matnr.
Append ls_matnr to lt_matnr.
Clear ls_matnr,ls_tab.
Endloop.
wt is ls_tab...wt is lv_plant..
can u pls explain..
please
thanks
satish
‎2007 Sep 21 4:05 AM
ranges : ls_matnr for mara-matnr.
Loop at itab into ls_tab where plant = lv_plant.
ls_matnr-sign = 'I'.
ls_matnr-option='EQ'.
ls_matnr-low = ls_tab-matnr.
Append ls_matnr.
Clear ls_matnr.
Endloop.
This will populate all material values to ranges LS_MATNR which you can pass to other program. It will act as a select option.
‎2007 Sep 21 4:31 AM
hi,
wr will we get the value of lv_plant ? in internal table of i have plant ,material number values..
please explain..i m fresher...i m doing one samll example ..please
‎2007 Sep 21 4:32 AM
‎2007 Sep 21 4:39 AM
You have internal table with plant and material. One Plant can have multiple Material entries.
So for the Plant entry of internal table, you are populating all materials into ranges.
‎2007 Sep 21 4:43 AM
ya that is correct. How i will get the value of lv_plant from internal table.
thanks
satish
‎2007 Sep 21 5:04 AM
Hi Dude,
as said above in all posts, once you sort the itab ascending based on the stlal value, the entry with the least stlal value is on top.
So use this.
data : wa_itab type itab. " To decalre a work area in case your itab has no header line.
then
sort itab asecnding by stlal.
read table itab into wa_itab index 1.
lv_palnt = wa_itab-plant.
if your itab has header line then code chabges as :
sort itab asecnding by stlal.
read table itab index 1.
lv_palnt = itab-plant.Reward if useful.