Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Input validation based on radio button

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.

Tags:
Former Member replied

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!

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question