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

Multiple select options validation at selection screen

Former Member
0 Likes
2,159

Hi,

I have the requirement to create a selection screen with 3 select options. Two of them are cross-dependent. It is mandatory to fill one of them and it is not allowed to fill both. The third one is optional. I tried the validation at selection-screen on block... and I have a problem that search help buttons for select options react like execution buttons, when I press any of them I am getting one of errors instead of search help.

Any help on this issue would be appreciated.

Here is my code:

DATA:
      so_rbkp TYPE rbkp,
      so_mseg TYPE mseg.

SELECTION-SCREEN BEGIN OF BLOCK blok WITH FRAME.
  SELECT-OPTIONS:
        s_fakt   FOR so_rbkp-belnr,
        s_matdok FOR so_mseg-mblnr,
        s_god FOR so_mseg-gjahr.
SELECTION-SCREEN END OF BLOCK blok.

INITIALIZATION.
SET TITLEBAR '0100'.
START-OF-SELECTION.

  AT SELECTION-SCREEN on block blok.
      if s_fakt <> space and s_matdok <> space.
        MESSAGE 'Message1' TYPE 'E'.
      elseif s_fakt = space and s_matdok = space.
        MESSAGE 'Message2' TYPE 'E'.
      endif.
    ENDIF.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,024

Only perform the check when user wants to execute or submit the program, not when pressing F4 or even Enter, but in a selection-screen event, before START-OF-SELECTION which were program would terminate in error :

TABLES: SSCRFIELDS.
* ...
 AT SELECTION-SCREEN OB BLOCK b01.
    IF sscrfields-ucomm EQ 'ONLI' 
    OR sscrfields-ucomm EQ 'PRIN' 
    OR sscrfields-ucomm EQ 'SJOB'.
      IF s_fakt[] IS NOT INITIAL AND s_matdok IS NOT INITIAL.
        MESSAGE 'Message1' TYPE 'E'.
      ELSEIF s_fakt[] IS INITIAL and s_matdok[] IS INITIAL.
        MESSAGE 'Message2' TYPE 'E'.
      ENDIF.
    ENDIF.

(You could also always send the message, but using type 'E' for those function code and 'S' status for any other value.)

Regards,

Raymond

5 REPLIES 5
Read only

Former Member
0 Likes
1,024

Hi,

Try the below code. This will not get triggered until you wont execution button.

START-OF-SELECTION.

if s_fakt = space and s_matdok = space.

MESSAGE 'Message1' TYPE 'E'.

elseif s_fakt <> space and s_matdok <> space.

MESSAGE 'Message2' TYPE 'E'.

endif.

Shiva

Read only

0 Likes
1,024

I tried your code, but if it happens the situation which produces an error, I jump out of program and I should stay at selection screen to make necessary changes.

Read only

0 Likes
1,024

Raymond, your code solved my problem, but with START-OF-SELECTION command after AT SELECTION-SCREEN.

Tnx a lot.

Read only

Former Member
0 Likes
1,024

Hi,

You have placed your screen validation "AT SELECTION SCREEN on BLOCK" after "START-OF-SELECTION". And because of this whenver you press F8, your check is get executed and so you are getting the error.

Please place your screen validation before "START-OFSELECTION" as below and then try.

Hope this will be helpful

Regards,

S.Meganadhan

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,025

Only perform the check when user wants to execute or submit the program, not when pressing F4 or even Enter, but in a selection-screen event, before START-OF-SELECTION which were program would terminate in error :

TABLES: SSCRFIELDS.
* ...
 AT SELECTION-SCREEN OB BLOCK b01.
    IF sscrfields-ucomm EQ 'ONLI' 
    OR sscrfields-ucomm EQ 'PRIN' 
    OR sscrfields-ucomm EQ 'SJOB'.
      IF s_fakt[] IS NOT INITIAL AND s_matdok IS NOT INITIAL.
        MESSAGE 'Message1' TYPE 'E'.
      ELSEIF s_fakt[] IS INITIAL and s_matdok[] IS INITIAL.
        MESSAGE 'Message2' TYPE 'E'.
      ENDIF.
    ENDIF.

(You could also always send the message, but using type 'E' for those function code and 'S' status for any other value.)

Regards,

Raymond