10-15-2019 6:25 PM
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.
10-15-2019 7:40 PM
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!
10-16-2019 5:56 AM
10-16-2019 6:44 AM
10-16-2019 6:49 AM
10-16-2019 7:38 AM
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.
10-16-2019 7:54 AM
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.
10-16-2019 9:13 AM
That would be nice if you could update your answer with corrected code 😉
10-16-2019 9:51 AM
Anusha anusha the code above is updated check now.
Sandra Rossi Its done!10-15-2019 9:06 PM
Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).