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: 

URGENT : select options

Former Member
0 Kudos

Hye techies,

I have a requirement, where i have 3 select options. Atleast data one select option should be entered. So, i cannot use obligatory tag.

i am writing the code as follows.

select-options: s_a for ztab-a,

s_b for ztab-b,

s_c for ztab-c.

data: chk_input type i.

chk_input = 0.

if s_a is not initial.

chk_input = chk_input + 1.

endif.

if s_b is not initial.

chk_input = chk_input + 1.

endif.

if s_c is not initial.

chk_input = chk_input + 1.

endif.

case chk_input.

when 0:.

MESSAGE 'Select atleast one entry in block 2' TYPE 'I'.

when 1.

when others.

MESSAGE 'Too many inputs in block 2' TYPE 'E'.

endcase.

I have 2 problems here.

1. When i am clicking on the arrow next to select options, it is displaying the first message considering the entry as empty.

2. If i enter one entry in one of the select options and then click on arrow for multiple selection, second error message is coming.

Please help me, as my requirement is one entry should be dere in one select options and it can have multiple values. but one entry is mandatory.. If the entry is wrong, previously entered values should be cleared.

At selection-sceen output.

Thanks in advance

Imran.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

please go through the following logic.

perform validations in start-of-selection instead of at selection screen.

start-of-SELECTION.

if s_a is initial and s_b is INITIAL and s_c is INITIAL.

chk_input = 1.

stop.

endif.

end-of-SELECTION.

if chk_input = 1.

MESSAGE 'Select atleast one entry in block 1' TYPE 'I'.

endif.

This validates atleast one value is entered.

Reward points if helpful.

Thanks and regards.

9 REPLIES 9

Former Member
0 Kudos

Hi,

Use AT SELECTION-SCREEN event.

0 Kudos

hye gurus,

I have put the code in at selection screen on block b2.

now when i m clicking on the small arrow next to select options, which allows you to enter multiple values, it is triggering my error message, that atleast one entry is mandatory.

That is my problem, when i m entering the first value itself it is throwing an error that entry is mandatory.

Pls help.

thanks.

0 Kudos

Hi Imran,

Try this code:

select-options: s_a for mara-matnr,

s_b for mara-matnr,

s_c for mara-matnr.

data: chk_input type i.

chk_input = 0.

at selection-screen.

if not s_a[] is initial.

chk_input = chk_input + 1.

endif.

if not s_b[] is initial.

chk_input = chk_input + 1.

endif.

if not s_c[] is initial.

chk_input = chk_input + 1.

endif.

case chk_input.

when 0.

clear chk_input.

MESSAGE ' Select atleast one entry in block 2 ' TYPE 'I'.

when 1.

clear chk_input.

when others.

clear chk_input.

MESSAGE ' Too many inputs in block 2 ' TYPE 'E'.

endcase.

Hope this will solve your problem.

Regards,

Ravi K

0 Kudos

Imran,

just implement my solution and you won't have more problems

ec

0 Kudos

hye ravi,

When i do this and click on execute and click on arrow next to s_a select option, as chk_input is 0, first message is getting displayed, which is not the case.

Please help.

Thanks.

Former Member
0 Kudos

Hi İmran,

You firstly create a block and then put the select options within this block like this:

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-003.
SELECT-OPTIONS: 
s_lgort FOR ekpo-lgort  NO-EXTENSION NO INTERVALS,
s_vtweg FOR vbak-vtweg. 
SELECTION-SCREEN END OF BLOCK  block1.

Afterwards,

AT SELECTION-SCREEN ON BLOCK block1.

  IF s_lgort[] IS INITIAL AND
     NOT s_vtweg[] IS INITIAL.
    MESSAGE e101(c+) WITH
      'Please enter the value.... write here whatever you want'
  ELSEIF s_vtweg[] IS INITIAL AND
         NOT s_lgort[] IS INITIAL.
    MESSAGE e101(c+) WITH
        'Please enter the value.... write here whatever you want'

  ENDIF.

In the past I have used this and it works.

Hope helps.

Edited by: Deniz Toprak on Jun 17, 2008 10:12 AM

JozsefSzikszai
Active Contributor
0 Kudos

hi Imran,

pls. check the following code:

AT SELECTION-SCREEN.

IF s_a[] IS INITIAL
AND s_b[] IS INITIAL
AND s_c[] IS INITIAL.
==> All three select options are empty
ELSEIF ( s_a[] IS NOT INITIAL
AND s_b[] IS INITIAL
AND s_c[] IS INITIAL ) OR
( s_a[] IS INITIAL
AND s_b[] IS NOT INITIAL
AND s_c[] IS INITIAL ) OR
( s_a[] IS INITIAL
AND s_b[] IS INITIAL
AND s_c[] IS NOT INITIAL ).
==> Exactly one of the three select options is filled with value(s)
ELSE.
==> The rest... (At least two select options are filled)
ENDIF.

hope this helps

ec

Former Member
0 Kudos

Hi Imran,

Use At selection-screen event.

If you have multiple entries in your select options then use

s_a[], s_b[] and s_c[] for checking the if condition instead s_a which will check for work area.

Regards,

Ravi K

Former Member
0 Kudos

Hi,

please go through the following logic.

perform validations in start-of-selection instead of at selection screen.

start-of-SELECTION.

if s_a is initial and s_b is INITIAL and s_c is INITIAL.

chk_input = 1.

stop.

endif.

end-of-SELECTION.

if chk_input = 1.

MESSAGE 'Select atleast one entry in block 1' TYPE 'I'.

endif.

This validates atleast one value is entered.

Reward points if helpful.

Thanks and regards.