Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

loop thru every select options

Karan_Chopra_
Active Participant
0 Likes
1,490

i have to loop thru select option and assign all the values to a variable.

plz help me out

12 REPLIES 12
Read only

Former Member
0 Likes
1,308

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

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

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

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

plzz help

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

nebody thrrr??????????/

Read only

former_member219399
Active Participant
0 Likes
1,308

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

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

<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 ....

Read only

0 Likes
1,308

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.

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

help plz

Read only

0 Likes
1,308

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

Read only

Former Member
0 Likes
1,308

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

Read only

0 Likes
1,308

and after this you can check

if sy-subrc is not equal to zero.

message " no record found" type e.

regards,

ruchika

Read only

Karan_Chopra_
Active Participant
0 Likes
1,308

by ur logic i can have values if all are consecutive

wat if they are not ?????????