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: 

Can I validate parameter fields before filling the mandatory field in Parameters(OBLIGATORY)

arumallaanusha
Explorer
0 Kudos

I have one parameter which is a mandatory field in the selection screen.

I have another two parameters for which I want to validate some scenarios.

Before filling the Mandatory field my validations on parameter fields aerror.png

re not working. After filling the Mandatory parameter then only my validations on other parameters are working .

Can anyone help me to solve my issue?

I tried this example

SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME.
PARAMETERS:p1 TYPE zd_studentno MATCHCODE OBJECT z1132_sh OBLIGATORY.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pselect RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND ucomm.
SELECTION-SCREEN COMMENT (30) TEXT-001.
PARAMETERS: p_month TYPE numc2 MODIF ID mnt,
p_year TYPE numc4 MODIF ID yer.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pdate RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN COMMENT (30) TEXT-002.
PARAMETERS: p_date1 TYPE sy-datum MODIF ID dt.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck1.

AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN.
IF pselect = 'X'.
IF screen-group1 = 'DT'.
screen-input = '0'.
p_date1 = ''.
p_year = sy-datum+0(4).
p_month = sy-datum+4(2).
MODIFY SCREEN.
ENDIF.
ELSEIF pdate = 'X'.
p_year = ''.
p_month = ''.
p_date1 = sy-datum.
IF screen-group1 = 'MNT'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'YER'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.

9 REPLIES 9

former_member1716
Active Contributor

Hello Anusha anusha,

Remove the OBLIGATORY keyword and write the Validation in AT SELECTION SCREEN.

Your code should be as below:


TABLES sscrfields.
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME.

PARAMETERS:p1 TYPE matnr MATCHCODE OBJECT qalsm.  --> This is for Example, similarly give valid MATCHCODE

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pselect RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND ucomm.
SELECTION-SCREEN COMMENT (30) TEXT-001.
PARAMETERS: p_month TYPE numc2 MODIF ID mnt,
            p_year  TYPE numc4 MODIF ID yer.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pdate RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN COMMENT (30) TEXT-002.
PARAMETERS: p_date1 TYPE sy-datum MODIF ID dt.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK blck1.

AT SELECTION-SCREEN OUTPUT .
  LOOP AT SCREEN.
    IF pselect = 'X'.
      IF screen-group1 = 'DT'.
        screen-input = '0'.
        p_date1 = ''.
        p_year = sy-datum+0(4).
        p_month = sy-datum+4(2).
        MODIFY SCREEN.
      ENDIF.

    ELSEIF pdate = 'X'.

      p_year = ''.
      p_month = ''.
      p_date1 = sy-datum.

      IF screen-group1 = 'MNT'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.

      IF screen-group1 = 'YER'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.

  ENDLOOP.

AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
    WHEN 'ONLI' OR 'CRET' OR 'JOBS'. " button "EXECUTE" or similar
      IF p1 IS INITIAL.
        MESSAGE 'Fill the value of p1' TYPE 'E'.
      ENDIF.
  ENDCASE.


Regards!

0 Kudos

It is not working same message is getting.

0 Kudos

Anusha anusha Can you paste your code here?

0 Kudos

Same code like what you post

I confirm + syntax error because type "zd_studentno" and search help "z1132_sh" don't exist (definition of P1).

Do the check only if the button "EXECUTE" is pressed:

PARAMETERS: p1 TYPE scarr-carrid. " <=== use something which exists anywhere
...
TABLES sscrfields.
AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
    WHEN 'ONLI' OR 'CRET' OR 'JOBS'. " button "EXECUTE" or similar
      IF p1 IS INITIAL.
        MESSAGE 'Fill the value of p1' TYPE 'E'.
      ENDIF.
  ENDCASE.

0 Kudos

Anusha anusha as suggested by Sandra Rossi make the necessary changes in the code and check on the match code object.

Also if you debug the code and follow the flow of the events and the code you will get a better understanding on the flow of the program.

0 Kudos

That would be nice if you could update your answer with corrected code 😉

0 Kudos

Anusha anusha the code above is updated check now.

Sandra Rossi Its done!

Sandra_Rossi
Active Contributor
0 Kudos

Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).