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

How to loop on select options...?

Former Member
0 Likes
32,099

Hi all,

I've to loop on select options so tat i dnt want to take unwanteed fields into the ITAB. I want to check the select option one by one in a table and if its present then i want to retrive the data from another table.

is it possible to do so?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
12,644

loop at s_matmr.

if s_matnr-(low/High/sign/option) = <value>.

<process as per ur need>

endif.

endloop.

Hi all,

I've to loop on select options so tat i dnt want to take unwanteed fields into the ITAB. I want to check the select option one by one in a table and if its present then i want to retrive the data from another table.

is it possible to do so?

11 REPLIES 11
Read only

Former Member
0 Likes
12,644

the way we loop at internal table you can loop at select option

loop at s_matnr

if s-matnr = '99'

......

ENDLOOP.

Read only

Former Member
0 Likes
12,644

Hi,

Use

SELECT-OPTIONS: BEGDA FOR PA0000-BEGDA NO INTERVALS.

AWARD POINTS IF USEFUL

Read only

0 Likes
12,644

Hi,

As assumptions consider the following coding,

It will solve ur problem.

SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
DATA : BEGIN OF ITAB OCCURS 0,
             MATNR LIKE MARA-MATNR,
           END OF ITAB.

START-OF-SELECTION.

LOOP AT S_MATNR.
 IF S_MATNR-LOW = '22222'.
  MOVE : S-MATNR-LOW TO ITAB-MATNR.
   APPEND ITAB.CLEAR ITAB.
**DO UR CHECKING HERE ***
 ENDIF.
ENDLOOP.

Regards,

Balakumar.G.

Rewards Points If helpful.

Read only

Former Member
12,644

If you loop the select-option, there will be one loop for each row of the select option. So to get all the valid fields between a low value to high value in a select option you need to have a select statement in the check table.

Suppose for material no (Matnr) the check table in MARA and your select-option is s_matnr. then

1. Select all the valid values into gt_matnr table.


select matnr from mara into table gt_mannr
                                   where matnr in s_matnr.

2.Now you can loop gt_matnr instead



loop at gt_matnr.

************ put your logic

endloop.

Read only

Former Member
0 Likes
12,644

Hi,

if u create a select-options internally it will create an internal table with fields high,low,option and sign.u can use it like a normal one.

rgds,

bharat.

Read only

Former Member
0 Likes
12,645

loop at s_matmr.

if s_matnr-(low/High/sign/option) = <value>.

<process as per ur need>

endif.

endloop.

Read only

Former Member
0 Likes
12,644

Hi Sunny,

Say u want to check the existance of entered MATNR in MARC, and get the MATNR and WERKS relation from MARD.For this u code like this

TABLES mard.

select-options s_matnr FOR MARD-MATNR.

DATA IT_MARD TYPE TABLE OF MARD.

SELECT * INTO TABLE IT_MARD FROM MARD JOIN MARC ON MARCMATNR = MARCMATNR

WHERE MARC~matnr IN S_MATNR.

Thanks Arjun

Read only

Former Member
0 Likes
12,644

hi

It s cool job only.. If u create a Select-options, it l create a internal table like structure like

-option

-sign

-low

-high

Sign is to show Sign of a particular value..

Low-- Low value in ranges

high--high value in ranges

Read only

Former Member
0 Likes
12,644

select-options:s_option for *********.

at selection screen on s_option.

if not s_option is initial.

u can do ur part here or u can check s_option-low or s_option-high.

endif.

Read only

Former Member
0 Likes
12,644

hI,

Refer to the sample code below.

LOOP AT s_lgort.

IF NOT s_lgort-low IS INITIAL.

SELECT SINGLE lgort

FROM t001l

INTO l_lgort

WHERE lgort = s_lgort-low.

IF sy-subrc NE 0.

MESSAGE e000 WITH text-e01.

ENDIF.

ENDIF.

ENDLOOP.

Hope it helps.

Regards,

Ramya

Read only

Former Member
0 Likes
12,644

thanks for the solution , i used high and low options .