‎2007 Jun 21 9:28 AM
i have to loop thru select option and assign all the values to a variable.
plz help me out
‎2007 Jun 21 9:33 AM
Hi,
Instead of loopin the select-option field and assign the values to another variable, just write a Select statment on that field then you will get all the values then assign those values to the variable
SELECT MATNR into table IT_MATNR where MATNR in S_MATNR .
Regards
Sudheer
‎2007 Jun 21 9:38 AM
ya i tried this but by this i get only those values which are present in that table
i want to manipute for all the entries(matnr) which i enter in select option not the one in table only
‎2007 Jun 21 9:42 AM
‎2007 Jun 21 9:52 AM
‎2007 Jun 21 9:55 AM
Hi,
Can you please give me your correct requirement?
Or you can do one thing.
select matnr from mara into table it_matnr where matnr in s_matnr.
loop at it_matnr.
write ur logic with it_matnr-matnr.
endloop.
with regards,
Vamsi
‎2007 Jun 21 9:59 AM
<b>select matnr from mara into table it_matnr where matnr in s_matnr.</b>
loop at it_matnr.
write ur logic with it_matnr-matnr.
endloop.
from the statement of ur (bolded) i can only manipute 4 values in MARA
e.g if i enter in select option from 1 to 20 and if 5 is <b>not</b> there in MARA then it will not occur in loop which i dont want ..i have to manipute that also and show that ..it is not present in MARA ....
‎2007 Jun 21 10:30 AM
Hi,
If you are only going to give 1 to 20(inclusion) or some values for ranges, the following code is fine.Otherwise, you need to include logic for other possiblities.
tables mara.
select-options s_matnr for mara-matnr.
data : begin of it_matnr occurs 0,
matnr type mara-matnr,
end of it_matnr.
loop at s_matnr.
it_matnr-matnr = s_matnr-low.
append it_matnr.
if s_matnr-sign = 'I' and s_matnr-option = 'BT'.
while it_matnr-matnr NE s_matnr-high.
it_matnr-matnr = it_matnr-matnr + 1.
unpack it_matnr-matnr to it_matnr-matnr.
append it_matnr.
endwhile.
endif.
endloop.
loop at it_matnr.
write : / it_matnr-matnr.
Endloop.
‎2007 Jun 21 10:10 AM
‎2007 Jun 21 10:27 AM
Hi Karan,
The select options have 3 important fields. One is direction (Inclusion/Exclusion), Comparison Operator (GT, LT, LE etc etc), Low and High.
The logic for assgning values to variables from Select options depends on the combinations used.
If the both Low and High is used or only if Low is used with LT GT LE etc operator, then the there will be atleast 2 values or more for assinging to variables. In that case your variable will have to be an internal table. In such cases you can make use of the logic as mentioned in the previous replies but modifying the where statement to include the select option variable.
If the operator is EQ and only low is used and only one entry is made then u can used only on variable to capture the value.
And also if you want to capture the value before at-selection screen for validation for value request then you may have to use DYNP_VALUES_READ to get the values into a variable.
Reward if useful...
Thanks...
Preetham
‎2007 Jun 21 10:42 AM
hi,
try like this.
tables: vbrk.
select-options: s_plant for vbrk-bukrs.
types: begin of ty_plant,
bukrslow type vbrk-bukrs,
bukrshigh type vbrk-bukrs,
end of ty_plant.
types: begin of ty_tab,
bukrs type vbrk-bukrs,
end of ty_tab.
data: it_plant type table of ty_plant,
wa_plant type ty_plant.
data: it_tab type table of ty_tab,
wa_tab type ty_tab.
at selection-screen.
loop at s_plant.
move s_plant-low to wa_plant-bukrslow.
move s_plant-high to wa_plant-bukrshigh.
append wa_plant to it_plant.
clear wa_plant.
endloop.
select bukrs from vbrk into table it_tab where bukrs in s_plant .
regards,
Ruchika
‎2007 Jun 21 10:54 AM
and after this you can check
if sy-subrc is not equal to zero.
message " no record found" type e.
regards,
ruchika
‎2007 Jun 21 10:46 AM
by ur logic i can have values if all are consecutive
wat if they are not ?????????