‎2013 Jan 22 11:13 AM
Hi,
I am having a problem with input validation based on radio button if the user does not hit 'enter'.
The scene is : I have a parameter and 4 radio buttons on the selection screen and i want to validate user input (based on selection criteria) if 4th radio button is checked. If I enter the wrong value in parameter field and check 4th radio button and then execute it, it generates the output but it should not. But if the user inputs the value, checks the 4th radio button and then again on parameter field if the user presses enter , it shows the error message defined by me.
What to do to validate this input without hitting 'enter' based on check of 4th radio button .
Here is my code:
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS : p_vbeln LIKE vbrk-vbeln.
PARAMETERS: r1 RADIOBUTTON GROUP rad1," DEFAULT ’X’,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1,
r4 RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN : END OF BLOCK b2 .
AT SELECTION-SCREEN ON p_vbeln. "Invoice no.
IF r4 IS NOT INITIAL.
SELECT SINGLE * FROM vbrk WHERE ( fkart = 'F2' OR fkart = 'ZEX' ) AND vbeln = p_vbeln .
IF sy-subrc <> 0.
MESSAGE e000(zinv_print) WITH p_vbeln.
ENDIF.
ENDIF.
START-OF-SELECTION.
‎2013 Jan 22 4:51 PM
Hi Ekansh,
you should use the AT SELECTIO-SCREEN (as Faiz reccomend) and you coul add am USER-COMMAND on the radiobutton itself - as suggested by Playsuji, so you would obtain an error message as the user select the radiobutton r4.
the code would be more or less like this:
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS : p_vbeln LIKE vbrk-vbeln.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND dummy,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1,
r4 RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN : END OF BLOCK b2 .
AT SELECTION-SCREEN.
IF r4 IS NOT INITIAL.
SELECT SINGLE * FROM vbrk WHERE ( fkart = 'F2' OR fkart = 'ZEX' )
AND vbeln = p_vbeln .
IF sy-subrc <> 0.
MESSAGE e000(zinv_print) WITH p_vbeln.
ENDIF.
ENDIF.
Hope this may help you!
‎2013 Jan 22 12:39 PM
Hi Ekansh,
Please try using the below code
IF r4 EQ 'X'.
SELECT SINGLE * FROM vbrk WHERE ( fkart = 'F2' OR fkart = 'ZEX' ) AND vbeln = p_vbeln .
IF sy-subrc <> 0.
MESSAGE e000(zinv_print) WITH p_vbeln.
ENDIF.
ENDIF.
Also, make the field p_vbeln obligatory.
Also, you can use USER COMMAND with the radiobutton group. It will work for your requirement.
Hope this helps
‎2013 Jan 22 12:42 PM
You have put user-command for this....
this one will help you...
PARAMETERS: r1 RADIOBUTTON GROUP rad1," DEFAULT ’X’ USER-COMMAND dummy,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1,
r4 RADIOBUTTON GROUP rad1 .
‎2013 Jan 22 4:04 PM
Hi Ekansh,
U just need to make a small change to ur code and I think it will work...instead of AT SELECTION SCREEN ON.....use only AT SELECTION SCREEN.
PLS REWARD POINTS IF USEFUL......
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS : p_vbeln LIKE vbrk-vbeln.
PARAMETERS: r1 RADIOBUTTON GROUP rad1," DEFAULT ’X’,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1,
r4 RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN : END OF BLOCK b2 .
AT SELECTION-SCREEN
IF r4 IS NOT INITIAL.
SELECT SINGLE * FROM vbrk WHERE ( fkart = 'F2' OR fkart = 'ZEX' ) AND vbeln = p_vbeln .
IF sy-subrc <> 0.
MESSAGE e000(zinv_print) WITH p_vbeln.
ENDIF.
ENDIF.
START-OF-SELECTION.
‎2013 Jan 22 4:51 PM
Hi Ekansh,
you should use the AT SELECTIO-SCREEN (as Faiz reccomend) and you coul add am USER-COMMAND on the radiobutton itself - as suggested by Playsuji, so you would obtain an error message as the user select the radiobutton r4.
the code would be more or less like this:
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS : p_vbeln LIKE vbrk-vbeln.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND dummy,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1,
r4 RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN : END OF BLOCK b2 .
AT SELECTION-SCREEN.
IF r4 IS NOT INITIAL.
SELECT SINGLE * FROM vbrk WHERE ( fkart = 'F2' OR fkart = 'ZEX' )
AND vbeln = p_vbeln .
IF sy-subrc <> 0.
MESSAGE e000(zinv_print) WITH p_vbeln.
ENDIF.
ENDIF.
Hope this may help you!
‎2013 Jan 23 9:05 AM
‎2013 Jan 22 5:28 PM
Hi Ekansh,
try below code.
PARAMETERS:p_vbeln TYPE vbrk-vbeln OBLIGATORY.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',
r2 RADIOBUTTON GROUP rad1.
AT SELECTION-SCREEN.
IF r2 = 'X'.
DATA:wa_vbrk TYPE vbrk.
SELECT SINGLE * FROM vbrk
INTO wa_vbrk
WHERE vbeln = p_vbeln.
IF sy-subrc = 0.
MESSAGE 'Invlaid' TYPE 'E'.
ENDIF.
ENDIF.
Execute and check the following screen shots.
Regards,
Gurunath Kumar D
‎2013 Jan 23 8:53 AM
No your code does not solve this case. its working same as of mine. try to enter the no. by pressing space and choosing from pre-entered value. then press F8 , no error message is shown (i wrote a write statement to start output and this write statement got executed without error).
‎2013 Jan 23 8:47 AM
The problem got solved when i put radio buttons above the parameter field. user firstly checks the r4 radio button and then inputs data in parameter field and as soon as he executes it, it shows error message as the validation conditions are not met.
Can you people help me in showing 4 radio buttons in one single line. I am using begin of line but it just shows buttons but no text assigned to them.
‎2013 Jan 23 11:34 AM
Hi Ekansh,
check the below code.use your own texts in selection-screen comment postion ( lenth of text) and to select the next radio button use the selection-screen postion .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
*- r1
PARAMETERS: r1 RADIOBUTTON GROUP rad.
SELECTION-SCREEN COMMENT 5(10) text-002.
*-r2
SELECTION-SCREEN POSITION 15.
PARAMETERS: r2 RADIOBUTTON GROUP rad.
SELECTION-SCREEN COMMENT 18(10) text-003.
*- r3
SELECTION-SCREEN POSITION 35.
PARAMETERS: r3 RADIOBUTTON GROUP rad.
SELECTION-SCREEN COMMENT 38(10) text-004.
*-r4
SELECTION-SCREEN POSITION 50.
PARAMETERS:r4 RADIOBUTTON GROUP rad.
SELECTION-SCREEN COMMENT 52(10) text-005.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
hope it will surely helpful to you.
Regards,
Gurunath Kumar D
‎2013 Jan 23 7:12 PM