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: 

SELECTION-SCREEN FIELD VALIDATION

Former Member
0 Kudos
518

Hi All!

I am trying to write this ABAP program in 4.7 Enterprise. I wish to selectively display (based on radio buttons) selection screen blocks and make them mandatory in runtime. I use code like this:

AT SELECTION-SCREEN ON SAL_ORG. (this is one of the fields that will be obligatory)

IF RD2 EQ 'X'.

IF SAL_ORG IS INITIAL.

MESSAGE 'THIS FIELD IS MANDATORY' TYPE 'I'.

ENDIF.

ENDIF.

Now, if I execute this as is, then I will get this message as soon as the block is displayed, not just after hitting the execution button. Can you please tell me how I should put a condition on this checking. I know it is triggered by SY-UCOMM = 'ONLI' but i am not sure where to put the condition.

Thanks in advance!

1 ACCEPTED SOLUTION

Former Member
0 Kudos
100
AT SELECTION-SCREEN.

  CHECK sscrfields-ucomm EQ 'ONLI'.

AT SELECTION-SCREEN ON SAL_ORG. (this is one of the fields that will be obligatory)
IF RD2 EQ 'X'.
IF SAL_ORG IS INITIAL.
MESSAGE 'THIS FIELD IS MANDATORY' TYPE 'I'.
ENDIF.
ENDIF.
4 REPLIES 4

Former Member
0 Kudos
100

Hi subhamoy,

1. for such things, it is better to follow this kind of logic.

(it will ensure that the report does not run when executed)

2.

START-OF-SELECTION.

IF FIELD IS INITIAL.

MESSAGE 'Please enter Field' type 'I'.

LEAVE LIST-PROCESSING.

ENDIF.

3. Important points.

a) Message should be of type I (and not E)

b) LEAVE LIST-PROCESSING. is important.

regards,

amit m.

Former Member
0 Kudos
101
AT SELECTION-SCREEN.

  CHECK sscrfields-ucomm EQ 'ONLI'.

AT SELECTION-SCREEN ON SAL_ORG. (this is one of the fields that will be obligatory)
IF RD2 EQ 'X'.
IF SAL_ORG IS INITIAL.
MESSAGE 'THIS FIELD IS MANDATORY' TYPE 'I'.
ENDIF.
ENDIF.

0 Kudos
100

hello J.C.!

this is what worked for me finally:

AT SELECTION-SCREEN.

CHECK sy-ucomm EQ 'ONLI'.

IF RD2 EQ 'X'.

IF SAL_ORG IS INITIAL.

MESSAGE 'THIS FIELD IS MANDATORY' TYPE 'I'.

ENDIF.

ENDIF.

SAP says sscrfields-ucomm is unrecognized. can you please tell me what it is actually? why did you prefer using it instead of SY-UCOMM? If possible, please direct me to some good reference on calling selection screen.

I have given your answer 10 points by the way. I am very new here, so i don't know what exactly it's role is, but i figured it is something significant.

0 Kudos
100

declare table SSCRFIELDS at top

TABLES : SSCRFIELDS.

this structure stores the selection screen fields

Message was edited by:

Chandrasekhar Jagarlamudi