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

Former Member
0 Likes
3,574

hi,

is there a nice idea to loop at select options (table) and store all values (sorted) in one itab ?

example:

select options: matnr type matnr.

input:

range: 1 to 5

single: 8, 9 & 10

exclude: 3

Result:

1

2

3

4

8

9

10

Ideas ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,410

Hi,

YOu can do something like this.

Take another range eg R_RNAGE2

and put all crietria from the select options into this (including the excluded ones as well )

then you can fire a SELECT on the R_RANGE2.

If you want the excluded ranges seperately then you might want to have 2 differnt ranges.

r_rang2 for excluded select options and

r_range3 for included values of select options.

Is this your requirement????

I hope this helps,

Raj

15 REPLIES 15
Read only

JozsefSzikszai
Active Contributor
0 Likes
2,410

why don't you do a SELECT?

SELECT field

FROM ...

INTO TABLE ...

WHERE field IN select_option.

Read only

0 Likes
2,410

I need a include and exclude output.

select mara where matnr in ... shows only included values.

for that reason i need either the excluded values, too or the whole select options in one extra itab.

Read only

JozsefSzikszai
Active Contributor
0 Likes
2,410

OK, I see now, but this could be tough...

One starting point is to LOOP on the select option:

in your example you have a range first, now it is a decision, if you simply copy the values (from 1 to 5 in your example) or do a select (just in case the value 4 does not exist for example), this would result in a SELECT inside the LOOP, which is something we don't like

on the other hand, again in your example, the value 3 is excluded, while in the first line, in the interval 1 to 5 is included. Now it is easy because the include comes before the exclude, but it could be other way around. How would you check that?

At this point I realise however that the simpliest way would be to start like I suggested in my first reply:

1. Do a select with the select option, values into internal table.

2. LOOP at the select option, but only on the lines where exclusions are and append the excluded values into the internal table, by single values it is simple (now you can check is the value is included already and simply change its sign, otherwise you need a new line), by excluded ranges again you have to make decision, which way to follow....

Read only

monalisa_biswal
Contributor
0 Likes
2,410

hi Gordon,

Loop over your select-options and modify sign where it is 'E'.

loop at matnr where sign = 'E'.

matnr-sign = 'I'.

modify matnr index sy-tabix.

endloop.

Hope it helps!

Monalisa

Read only

Former Member
0 Likes
2,410

Hi

You can try this way...

&----


*& Report YTEST

*&

&----


*&

*&

&----


REPORT ytest.

TABLES: mara.

DATA: BEGIN OF itab OCCURS 0,

ans TYPE blanz,

END OF itab,

lf_val TYPE blanz.

SELECT-OPTIONS: s_int FOR mara-blanz.

START-OF-SELECTION.

LOOP AT s_int WHERE sign = 'I'.

CLEAR lf_val.

IF s_int-option = 'EQ'.

lf_val = s_int-low.

APPEND lf_val TO itab.

ELSEIF s_int-option = 'BT'.

lf_val = s_int-low.

APPEND lf_val TO itab.

WHILE lf_val < s_int-high.

lf_val = lf_val + 1.

APPEND lf_val TO itab.

IF lf_val EQ s_int-high.

EXIT.

ENDIF.

ENDWHILE.

ENDIF.

ENDLOOP.

SORT itab BY ans.

LOOP AT s_int WHERE sign = 'E'.

CLEAR lf_val.

IF s_int-option = 'EQ'.

lf_val = s_int-low.

DELETE itab WHERE ans = lf_val.

ELSEIF s_int-option = 'BT'.

lf_val = s_int-low.

DELETE itab WHERE ans = lf_val.

WHILE lf_val < s_int-high.

lf_val = lf_val + 1.

DELETE itab WHERE ans = lf_val.

IF lf_val EQ s_int-high.

EXIT.

ENDIF.

ENDWHILE.

ENDIF.

ENDLOOP.

SKIP 2.

WRITE:/ 'Result:'.

LOOP AT itab.

WRITE:/ itab-ans.

ENDLOOP.

Regards

Raj

Read only

Former Member
0 Likes
2,410

Hi,

I have a doubt:

do you find your result is wrong?

I think it should be like:

1

2

4

5

8

9

10

Right???

Regards,

Chris Gu

Read only

Former Member
0 Likes
2,411

Hi,

YOu can do something like this.

Take another range eg R_RNAGE2

and put all crietria from the select options into this (including the excluded ones as well )

then you can fire a SELECT on the R_RANGE2.

If you want the excluded ranges seperately then you might want to have 2 differnt ranges.

r_rang2 for excluded select options and

r_range3 for included values of select options.

Is this your requirement????

I hope this helps,

Raj

Read only

0 Likes
2,410

HI,

thanks for your reply. I think i can use another option.

Can you show me how to enable only "single values" allowed in Select Options ?

Range and excludes are not allowed.

Thx,

Gordon

Read only

0 Likes
2,410

>

> Can you show me how to enable only "single values" allowed in Select Options ?

> Range and excludes are not allowed.

when you define the select option:

SELECT OPTIONS : ... FOR ... NO INTERVALS.

Read only

0 Likes
2,410

NO-INTERVALS use this addition of the select options

Read only

0 Likes
2,410

Hi use the following addition in your select options.

no intervals no-extension

Read only

0 Likes
2,410

hi,

"no intervals" is working fine. The select option shows only one inputbox but it´s still possible to enter a rannge in the popupbox.

Any ideas to avoid ranges in that popup box ?

What about loop at screen and disable elements ?

Thx,

Gordon

Read only

0 Likes
2,410

Hi

U can use the fm SELECT_OPTIONS_RESTRICT in the event INITIALIZATION in order to hide the range

Max

Read only

0 Likes
2,410

hi..

what ever data like the range or the single date just enter into the select-option .

by clicking the icon side to it.

and just use the same select-option ( ex: s_ebeln)

in the where condition like

WHERE EBELN in S_EBELN.

it will work fill for all u r intervals and the single valuse entered in the selection screen.

tye it.. all the best..

UR's

GSANA

Read only

0 Likes
2,410

Hi

This is sample:

tables: mara.

select-options s_matnr for mara-matnr.

type-pools SSCR.

DATA: rest TYPE sscr_restrict,
      optl TYPE sscr_opt_list,
      sass TYPE sscr_ass.



initialization.

  optl-name = 'EQ'.
  optl-options-eq = 'X'.
  optl-options-BT = 'X'.
  APPEND optl TO resT-opt_list_tab.


  sass-kind = 'S'.
  Sass-name = 'S_MATNR'.
  Sass-sg_main = 'I'.
  Sass-sg_addy = ' '.
  Sass-op_main = 'EQ'.
  Sass-op_addy = 'EQ'.
  APPEND Sass TO rest-ass_tab.


  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      RESTRICTION = rest.

Max