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: 

How to check the screen input on selection screen smartly?

Former Member
0 Kudos

Hi all,

I've a selection options plant:

select-option s_werks for marc-werks.

i want to display the error message if user inputs plant = 30xx or 30xx is within the range.

Currently, I use the codes below but i don't think it's smart enough, Is there a smarter way to do so?

AT SELECTION-SCREEN.

loop at s_werks.

if s_werks-sign = 'I'.

case s_werks-option = 'bt'.

...

endcase.

elseif s_werks-sign = 'E'.

case s_werks-option = 'bt'.

...

endcase.

endif.

endloop.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi Macy,

It is as simple as this...

if '30xx' in s_werks.

<give error msg>

endif.

This will check for the value 30xx as a single value or even if entered as a range.

Hope this helps.

Remember to reward points to the reply that best answered your question.

Reg,

PP.

4 REPLIES 4

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try this.

AT SELECTION-SCREEN.

loop at s_werks.

if ( ( s_werks-sign = 'I' or s_werks-sign = 'E' ).

and ( s_werks-option = 'bt' ) ).

...

endif.

endloop.

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Macy,

there might be faster ways than asking the database, but otherwise you will need a lot of coding to check all possible selections.

Try instead:


select werks into l_werks
       up to 1 rows
       from t001w
      where werks in s_werks
       and  werks between '3000' and '3099'.
if sy-subrc eq 0.
  message e398(00) with 'Please don't select 30xx!'.
endif.

So first where clause is from selection-screen, second you can define freely to match your 'forbidden zone' - maybe vlfkz = 'B' (distribution centers) or something else brings same result.

Regards,

Christian

Former Member
0 Kudos

hi Macy,

It is as simple as this...

if '30xx' in s_werks.

<give error msg>

endif.

This will check for the value 30xx as a single value or even if entered as a range.

Hope this helps.

Remember to reward points to the reply that best answered your question.

Reg,

PP.

Former Member
0 Kudos

Macy - you can use FM SELECT_OPTIONS_RESTRICT. It's well documented.

Rob