Skip to Content
avatar image
Former Member

how to use radio button

how to use radio button

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 10, 2006 at 12:44 PM

    If it is a screen programing

    Check the below code:

    REPORT ypra_sample59.

    DATA: r1 TYPE c,

    r2 TYPE c,

    field1 TYPE char10,

    field2 TYPE char10.

    CALL SCREEN 100.

    &----


    *& Module status_0100 OUTPUT

    &----


    • text

    ----


    MODULE status_0100 OUTPUT.

    IF r1 IS INITIAL AND r2 IS INITIAL.

    r1 = 'X'.

    ENDIF.

    LOOP AT SCREEN.

    IF r1 EQ 'X'.

    IF screen-name = 'FIELD2' .

    screen-input = 0.

    ELSEIF screen-name = 'FIELD1'.

    screen-input = 1.

    ENDIF.

    MODIFY SCREEN.

    ENDIF.

    IF r2 EQ 'X'.

    IF screen-name = 'FIELD1' .

    screen-input = 0.

    ELSEIF screen-name = 'FIELD2'.

    screen-input = 1.

    ENDIF.

    MODIFY SCREEN.

    ENDIF.

    ENDLOOP.

    ENDMODULE. " status_0100 OUTPUT

    &----


    *& Module user_command_0100 INPUT

    &----


    • text

    ----


    MODULE user_command_0100 INPUT.

    ENDMODULE. " user_command_0100 INPUT

    Here in the screen r1 and r2 are radio buttons

    <b>If it is a report with selection screen:</b>

    ***********************************************************************

    • SELECTION SCREEN

    ***********************************************************************

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001

    NO INTERVALS.

    PARAMETERS: p_ym TYPE buper .

    SELECTION-SCREEN SKIP 1.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : p_r1 RADIOBUTTON GROUP rg1 USER-COMMAND vend DEFAULT 'X'.

    SELECTION-SCREEN COMMENT (43) text-002 FOR FIELD p_r1.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : p_r2 RADIOBUTTON GROUP rg1.

    SELECTION-SCREEN COMMENT (40) text-003 FOR FIELD p_r2.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : p_r3 RADIOBUTTON GROUP rg1.

    SELECTION-SCREEN COMMENT (40) text-004 FOR FIELD p_r3.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : p_r4 RADIOBUTTON GROUP rg1.

    SELECTION-SCREEN COMMENT (40) text-005 FOR FIELD p_r4.

    SELECTION-SCREEN END OF LINE.

    PARAMETERS: p_vendor TYPE lfa1-lifnr MODIF ID sup.

    SELECTION-SCREEN END OF BLOCK b1.

    Regards,

    Prakash.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2006 at 12:44 PM

    Hi venkata,

    parameters : r1 radiobutton group g1 user-command ABC,

    r2 radiobutton group g1.

    PARAMETERS: p1 TYPE d default sy-datum.

    select-options p2 for sy-datum.

    at selection-screen output.

    if r1 = 'X'.

    loop at screen.

    <b>if screen-field = 'P2-LOW'.

    screen-input = '0'.

    clear p2-LOW.

    endif.</b>

    modify screen.

    <b>if screen-field = 'P2-HIGH'.

    screen-input = '0'.

    clear p2-HIGH.

    endif.

    modify screen.</b>

    endloop.

    else.

    loop at screen.

    if <b>SCREEN_FIELD</b> = 'P1'.

    screen-input = '0'.

    clear p1.

    endif.

    modify screen.

    endloop.

    endif.

    check thiss....

    for select options you need specify low and high ..

    Reward points if it is helpful

    Regards

    Alfred

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2006 at 12:48 PM

    Hi Venkat

    go through the following document, and do the sample code

    Checkboxes and radio buttons without a function code behave like normal input/output fields.

    Clicking the object changes the contents of the field, but does not trigger the PAI event. (Clicking

    a pushbutton, on the other hand, always triggers the PAI event, even if it has an empty function

    code.)

    When a function code is assigned to a checkbox or radio button, clicking it not only changes

    the field contents, but also triggers the PAI event and places the function code in the OK CODE

    field. For further information, refer to Reading Function Codes [Page 555].

    While it is possible to assign an individual function code to each checkbox, you can only assign

    one function code to all of the radio buttons in a group. When you assign a function code to a

    radio button in the Screen Painter, the system automatically applies the same function code to all

    of the other radio buttons in the group.

    You can use checkboxes and radio buttons with function codes as follows:

    For processing parts of screens (context-sensitive processing). For example, only when a

    radio button or checkbox is selected is particular data read and placed in the corresponding

    input/output fields.

    You can fill fields with patterns depending on checkboxes or radio buttons. A typical example

    would be formatting settings for letters. The input fields can all be processed separately, but

    it is possible to fill all input fields simultaneously and consistently by choosing a pattern.

    You can control dynamic screen modifications [Page 611] directly using checkboxes or radio

    buttons. For example, you can make sure that an input/output field cannot accept input until

    the user selects a radio button.

    As when you create pushbuttons [Page 542], you should ensure when you assign function codes

    to checkboxes and radio buttons that they do not coincide with function codes from the GUI

    status.

    PROGRAM demo_dynpro_check_radio.

    DATA: radio1(1) TYPE c, radio2(1) TYPE c, radio3(1) TYPE c,

    field1(10) TYPE c, field2(10) TYPE c, field3(10) TYPE c,

    box TYPE c.

    DATA: ok_code TYPE sy-ucomm,

    save_ok TYPE sy-ucomm.

    CALL SCREEN 100.

    MODULE user_command_0100 INPUT.

    save_ok = ok_code.

    CLEAR ok_code.

    CASE save_ok.

    WHEN 'RADIO'.

    IF radio1 = 'X'.

    field1 = 'Selected!'.

    CLEAR: field2, field3.

    BC - ABAP Programming SAP AG

    Checkboxes and Radio Buttons with Function Codes

    546 April 2001

    ELSEIF radio2 = 'X'.

    field2 = 'Selected!'.

    CLEAR: field1, field3.

    ELSEIF radio3 = 'X'.

    field3 = 'Selected!'.

    CLEAR: field1, field2.

    ENDIF.

    WHEN 'CANCEL'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDMODULE.

    The next screen (statically defined) for screen 100 is itself. It has the following layout:

    Radio button 1

    Radio button 2

    Radio button 3

    Cancel

    The part of the element list relevant for the screen fields is as follows:

    Name Type DefLg Format Function code

    RADIO1 Radio 1 CHAR RADIO

    FIELD1 I/O 10 CHAR

    RADIO2 Radio 1 CHAR RADIO

    FIELD2 I/O 10 CHAR

    RADIO3 Radio 1 CHAR RADIO

    FIELD3 I/O 10 CHAR

    BOX Check 1 CHAR CANCEL

    OK_CODE OK 20 OK

    The input option for the screen fields FIELD1 to FIELD3 has been switched off in the

    Screen Painter.

    The screen flow logic is as follows:

    PROCESS BEFORE OUTPUT.

    PROCESS AFTER INPUT.

    MODULE user_command_0100.

    Each time you select one of the three radio buttons, the PAI event is triggered and

    the function code RADIO and the contents of the screen fields are passed to the

    SAP AG BC - ABAP Programming

    Checkboxes and Radio Buttons with Function Codes

    April 2001 547

    ABAP program. The dialog module USER_COMMAND_100 fills the fields FIELD1 to

    FIELD3 according to the radio button that was selected. These field contents appear

    the next time the screen is sent.

    The PAI event is also triggered if you select the checkbox. In this case, the function

    code CANCEL is passed to the ABAP program, and the dialog module

    USER_COMMAND_100 terminates the program immediately.

    Regards

    Antony Thomas

    Reward points if find useful!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2006 at 01:19 PM

    HI

    GOOD

    Radio buttons are graphic control elements with which you can choose exactly one element from a list of fields. If several fields are to be chosen at the same time, you then should use checkboxes.

    thanks

    mrutyun^

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2006 at 01:23 PM

    hi venkat,

    just go thru this link.

    http://help.sap.com/saphelp_47x200/helpdata/EN/20/845f0a2135be47966b002cce852582/frameset.htm

    this is help from SAP.

    excellent one.

    and also welcome to SDN..

    rgds

    anver

    if useful mark points

    Add comment
    10|10000 characters needed characters exceeded