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 select options

Karan_Chopra_
Active Participant
0 Likes
5,048

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

plz help me out

1 ACCEPTED SOLUTION
Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

its moving only high and low value into It_plant tableNOT all the values selected between them and looping only once

20 REPLIES 20
Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

plz help

Read only

0 Likes
2,886

Hi Karan,

Do you need to loop at select option and capture these values in any variable.

dat a: l_var type select option filed.

if not s_input[] is initial.

Loop at s_input .

l_var = s_input-low.

endloop.

endif.

  • reward if helps.

Read only

Former Member
0 Likes
2,886

hi,

try this,

SELECT-OPTIONS s_plant FOR marc-werks .

INITIALIZATION.

s_plant-low = '1000'.

s_plant-high = '2000'.

s_plant-sign = 'I'.

s_plant-option = 'BT'.

APPEND s_plant.

reward points if helpful,

seshu.

Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

i hav to suplpy all these values to a variable in a function module thru export

Message was edited by:

Karan Chopra

Read only

Former Member
0 Likes
2,886

First get all the records from database table for select option into a table and then loop through that internal table and assign to the variable you want..

or you can do like this..

LOOP AT so_keyfu.

ls_iobj-iobjnm = so_keyfu-low.

APPEND ls_iobj TO lt_iobj.

ENDLOOP.

Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

i am still not gettin guys ....sry

i am able to loop only once even if i enter 20 values e.g

1 to 20

Message was edited by:

Karan Chopra

Read only

Former Member
0 Likes
2,886

karan,

DATA : v_temp like marc-werks.

SELECT-OPTIONS s_plant FOR marc-werks .

LOOP At s_plant.

move s_plant-low to v_temp .

ENDLOOP.

Don't forget to reward if useful...

Read only

Former Member
0 Likes
2,886

karan,

karan,

DATA : c like marc-werks.

SELECT-OPTIONS s_plant FOR marc-werks .

LOOP At s_plant.

move s_plant-low to v_temp .

call Function 'Name'

export

xcxcx = v_temp.

ENDLOOP.

Note : xcxcx and v_temp should have same data type.

Don't forget to reward if useful...

Read only

Former Member
0 Likes
2,886

Hi Karan,

You can loop at select options and simultaneously move the values to variables

if it is of the type "I" "EQ". i.e. in the form of a range.

This you can do as follows:

report.

tables vbak.

data: begin of t_vbeln occurs 0,

vbeln type vbak-vbeln,

end of t_vbeln.

select-options : s_vbeln for vbak-vbeln.

loop at s_vbeln.

t_vbeln-vbeln = s_vbeln-low.

append t_vbeln.

endloop.

here s_vbeln-low can also be assigned to a variable.

As far as I think, if however, the select options, is of the type I BT ie a value range like 100 to 200, then you have to code a logic with a counter.

Regs,

Sameer

Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

no it is not looping thru select option

the loop occurs only once even if i enter it for 20 values

Read only

S0025444845
Active Participant
0 Likes
2,886

hi,

try with this code.

just copy paste n run.

tables: vbrk.

select-options: s_plant for vbrk-bukrs.

types: begin of ty_plant,

bukrs type vbrk-bukrs,

end of ty_plant.

data: it_plant type standard table of ty_plant,

wa_plant type ty_plant.

at selection-screen.

loop at s_plant.

move s_plant-low to wa_plant.

append wa_plant to it_plant.

clear wa_plant.

move s_plant-high to wa_plant.

append wa_plant to it_plant.

clear wa_plant.

endloop.

regards,

sudha.

reward points if useful.

Read only

Former Member
0 Likes
2,886

Hi Karan,

Forward to my previous answer..

If you want to loop at a select option in which the values are like 1 to 200..

There is NO DIRECT WAY of doing it.

You will have to loop and select s_vbeln-low in a variable. (see my prev post)

then s_vbeln-high in another.

And then put a logic to increment the values in a DO-ENDDO loop.

say it s_vbeln is 10 to 20.

do 10 times low (10) plus 1 (the difference) and move it to variables.

Regs,

Sameer

Read only

Karan_Chopra_
Active Participant
0 Likes
2,886

still confused plzzz help

Read only

0 Likes
2,886

hi,

try with this code.

just copy paste n run.

tables: vbrk.

select-options: s_plant for vbrk-bukrs.

types: begin of ty_plant,

bukrs type vbrk-bukrs,

end of ty_plant.

data: it_plant type standard table of ty_plant,

wa_plant type ty_plant.

at selection-screen.

loop at s_plant.

move s_plant-low to wa_plant.

append wa_plant to it_plant.

clear wa_plant.

move s_plant-high to wa_plant.

append wa_plant to it_plant.

clear wa_plant.

endloop.

regards,

sudha.

Read only

0 Likes
2,886

Hi Karan,

U r right .IT will loop only once if u loop at the select option.

What i guess u can do is select ur values not from the select option but from the table to which this select option corresponds.For ex.

###begin of code.

data:itab like mara occurs 0 with header line.

select-option:s_matnr for mara-matnr.

At selection screen.

select matnr

into corresponding fields of itab

from mara where matnr between s_matnr-low and S_matnr-high.

#end of code.

after this i guess u will get ur values in the matnr field of table itab-matnr.

Reward if useful.

Regards,

Abhi

Read only

Karan_Chopra_
Active Participant
0 Likes
2,887

its moving only high and low value into It_plant tableNOT all the values selected between them and looping only once

Read only

0 Likes
2,886

hi,

do like this,

at selection-screen.

select * from <dbtable> into table <itab> where keyfield in s_option.

loop at <itab> into <wa>.

move <wa> to <wa1>.

append <wa1> to <itab1>.

endloop.

here in <itab1> we can find avbl fields from 1 to 20.

reward points if useful,

regards,

seshu.

Read only

0 Likes
2,886

Hi,

then take the select option without intervals and do.

copy paste n run.

SELECT-OPTIONS: s_plant FOR vbrk-bukrs no intervals.

TYPES: BEGIN OF ty_plant,

bukrs TYPE vbrk-bukrs,

END OF ty_plant.

DATA: it_plant TYPE STANDARD TABLE OF ty_plant,

wa_plant TYPE ty_plant.

AT SELECTION-SCREEN.

LOOP AT s_plant.

MOVE s_plant-low TO wa_plant.

APPEND wa_plant TO it_plant.

CLEAR wa_plant.

ENDLOOP.

regards,

sudha

Read only

Former Member
0 Likes
2,886

HI karan,

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.

data: it_plant type table of ty_plant,

wa_plant type ty_plant.

at selection-screen.

loop at s_plant.

move s_plant-low to wa_plant-bukrslow.

move s_plant-low to wa_plant-bukrslow.

append wa_plant to it_plant.

clear wa_plant.

endloop.

regards,

Ruchika

reward if useful...............

Read only

0 Likes
2,886

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

data: it_plant type table of ty_plant,

wa_plant type ty_plant.

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.