Application Development 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: 

Select - Options

Former Member
0 Kudos

Hi experts,

I have doubt in select-options. Please see the below code.

TABLES: ekko.

SELECT-OPTIONS: s_bukrs FOR ekko-bukrs.

DATA: flag TYPE i.

flag = 0.

AT SELECTION-SCREEN.

IF NOT s_bukrs IS INITIAL.

LOOP AT s_bukrs.

IF s_bukrs EQ '1000' OR s_bukrs EQ '0009'.

IF sy-subrc EQ 0.

flag = 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

During execution in the selection screen I am entering 1000,

0009, CRAB, TRN1 for s_bukrs.

But the If condition IF s_bukrs EQ '1000' OR s_bukrs EQ '0009'. is getting failed. Please let me know the correct syntax. i.e if s_bukrs is either 1000 or 0009 the variable flag should be set to 1. But its not happening.

Thanks & Regards,

Neethu.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

write as :

LOOP AT s_bukrs.

IF s_bukrs-low EQ '1000' OR s_bukrs-low EQ '0009'.IF sy-subrc EQ 0.

flag = 1.

ENDIF.

ENDIF.

ENDLOOP.

9 REPLIES 9

Former Member
0 Kudos

write as :

LOOP AT s_bukrs.

IF s_bukrs-low EQ '1000' OR s_bukrs-low EQ '0009'.IF sy-subrc EQ 0.

flag = 1.

ENDIF.

ENDIF.

ENDLOOP.

Former Member
0 Kudos

Hi,

you forgot to specify the field for the value in select-option header line:


LOOP AT s_bukrs.
  IF s_bukrs-low EQ '1000' OR s_bukrs-low EQ '0009'.
*     IF sy-subrc EQ 0.
    flag = 1.
*     ENDIF.
  ENDIF.
ENDLOOP.

By the way: A usual select option has got two value fields (LOW and HIGH). If you want to use the code above it could be better to restrict the select option e.g. with NO INTERVALS.

[Restricting Entry to Single Fields|http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba76d35c111d1829f0000e829fbfe/frameset.htm|]

Regards Rudi

Former Member
0 Kudos

hi

do this to ur code

TABLES: ekko.

SELECT-OPTIONS: s_bukrs FOR ekko-bukrs.

DATA: flag TYPE i.

flag = 0.

AT SELECTION-SCREEN.

IF NOT s_bukrs IS INITIAL.

LOOP AT s_bukrs.

IF s_bukrs-low EQ '1000' OR s_bukrs-high EQ '0009'.IF sy-subrc EQ 0.

flag = 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

cheers

snehi

Former Member
0 Kudos

Hi,

Try this -

at selection-screen on s_bukrs.

if '1000' in s_bukrs or '0009' in s_bukrs.

flag = 1.

endif.

Cheers.

...Reward if useful

Former Member
0 Kudos

Hi,

Try this -

at selection-screen on s_bukrs.

if '1000' in s_bukrs or '0009' in s_bukrs.

flag = 1.

endif.

Cheers.

...Reward if useful

Former Member
0 Kudos

Hi ,

Use the following code.

U need to use s_bukrs-low instead of s_bukrs

TABLES: ekko.

SELECT-OPTIONS: s_bukrs FOR ekko-bukrs.

DATA: flag TYPE i.

flag = 0.

AT SELECTION-SCREEN.

IF NOT s_bukrs IS INITIAL.

LOOP AT s_bukrs.

IF s_bukrs-low EQ '1000' OR s_bukrs-low EQ '0009'.

IF sy-subrc EQ 0.

flag = 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

Hi,

TABLES: ekko.

SELECT-OPTIONS: s_bukrs FOR ekko-bukrs.

DATA: flag TYPE i.

flag = 0.

AT SELECTION-SCREEN.

IF NOT s_bukrs IS INITIAL.

LOOP AT s_bukrs where s_bukrs-low = '1000'

or s_bukrs-low = '0009'.

flag = 1.

ENDLOOP.

ENDIF.

Hope it helps u.

regards.

Manjari.

Former Member
0 Kudos

Hi,

TABLES: ekko.

SELECT-OPTIONS: s_bukrs FOR ekko-bukrs.

DATA: flag TYPE i.

flag = 0.

AT SELECTION-SCREEN.

IF NOT s_bukrs IS INITIAL.

LOOP AT s_bukrs where s_bukrs-low = '1000'

or s_bukrs-low = '0009'.

flag = 1.

ENDLOOP.

ENDIF.

Hope it helps u.

regards.

Manjari.

Former Member
0 Kudos

Hi neethu

U r working with select options and many of our people has given replyes. But u need to consider the S_BUKRS-SIGN also while searching for the bukrs. There can be I -> INCLUDE E->EXCLUDE.

So instead of doing all these validations take an internal table with field bukrs and hit the table t001 and get the company codes which can be considered. Then loop through that table and check for your company code and set the flag.

This would be best solution.

Reward points if useful.

Venkat.