Friday, July 12, 2013
Previously we worked on how to handle check boxes on table control. Now I would like to explain how to handle radio buttons on Table control display.

Steps

  • Define one internal table(IT_0001) in TOP include and structure should have one field RADBUT type C.
    *&---------------------------------------------------------------------*
    *& Include MZTEST_TABLE_CTRLTOP   Module Pool      SAPMZTEST_TABLE_CTRL
    *&
    *&---------------------------------------------------------------------*
    PROGRAM  SAPMZTEST_TABLE_CTRL.
    TYPES:
          BEGIN OF TY_0001,
            RADBUT TYPE C,
            PERNR  TYPE PA0001-PERNR,
            BUKRS  TYPE PA0001-BUKRS,
            ENAME  TYPE PA0001-ENAME,
          END OF TY_0001.
    DATA:
          IT_0001 TYPE STANDARD TABLE OF TY_0001,
          WA_0001 TYPE TY_0001.
    DATA  OK_CODE TYPE SY-UCOMM.
    
    CONTROLS TC_WITH_RAD TYPE TABLEVIEW USING SCREEN '1001'.

  • Create screen 1001 and place table control(Name TC_WITH_RADBUT) on screen layout. 



  • Map IT_0001 fields on table control by selecting radio button for RADBUT field as shown in screen shot.




  • Flow Logic 
    PROCESS BEFORE OUTPUT.
      MODULE GET_DATA.
      LOOP AT IT_0001 INTO WA_0001 WITH CONTROL TC_WITH_RAD.
    
      ENDLOOP.
    
    PROCESS AFTER INPUT.
      LOOP AT IT_0001.
        MODULE READ_TABLE_CONTROL.
      ENDLOOP.
      MODULE USER_COMMAND_1001.
    


  • *&-------------------------------------------------------------------*
    *&      Module  GET_DATA  OUTPUT
    *&-------------------------------------------------------------------*
    *       text
    *--------------------------------------------------------------------*
    MODULE GET_DATA OUTPUT.
      IF IT_0001 IS INITIAL.
        SELECT DISTINCT *
          FROM PA0001
          INTO CORRESPONDING FIELDS OF TABLE IT_0001
          UP TO 400 ROWS.
        SORT IT_0001 BY PERNR PERNR BUKRS ENAME.
        DELETE ADJACENT DUPLICATES FROM IT_0001 COMPARING ALL FIELDS.
    
      ENDIF.
    ENDMODULE.                 " GET_DATA  OUTPUT
    


    *&-------------------------------------------------------------------*
    *&      Module  READ_TABLE_CONTROL  INPUT
    *&-------------------------------------------------------------------*
    *       text
    *--------------------------------------------------------------------*
    MODULE READ_TABLE_CONTROL INPUT.
      MODIFY IT_0001 FROM WA_0001 INDEX TC_WITH_RAD-CURRENT_LINE.
    ENDMODULE.                 " READ_TABLE_CONTROL  INPUT
    


    *&-------------------------------------------------------------------*
    *&      Module  USER_COMMAND_1001  INPUT
    *&-------------------------------------------------------------------*
    *       text
    *--------------------------------------------------------------------*
    MODULE USER_COMMAND_1001 INPUT.
      CASE OK_CODE.
        WHEN 'DISPLAY'.
          LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 1001.
          LOOP AT IT_0001 INTO WA_0001 WHERE RADBUT = 'X'.
            WRITE:/ WA_0001-PERNR,
                    WA_0001-BUKRS,
                    WA_0001-ENAME.
          ENDLOOP.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_1001  INPUT
    
    • Create transaction code and execute.
    • Select the record and click on "Display selected record" button.

    2 comments:

    1. This article is a great example of opportunity cost….if the gov plans to train workers,
      spending must be cut from some other program, which could discourage economic growth.
      SAP APO Online Training

      ReplyDelete

    Your useful comments, suggestions are appreciated.Your comments are moderated.

    Followers

    Contact Form

    Name

    Email *

    Message *

    Web Dynpro ABAP Book

    An SAP Consultant

    Follow US


    Want to Contribute ?

    If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

    Click on Contribution for more details.