Adding buttons to ALV report

I am using CL_SALV_TABLE to generate a report. How do I add custom buttons on the application toolbar? Is this done in the menu or screen painter? I have not created any screens yet as I want it to remain a simple ALV report.

First create a PF status: We need to create a PF status with our own buttons as well as the ALV standard buttons. If we don't add the ALV buttons than it would not provide the standard functions of ALVs. On the other hand it is very tedious to add all the ALV buttons in our PF status manually. So here is the easy way: We will copy the PF-Status using of any standard SALV_DEMO report using the transaction SE41: Menu Painter. After Copying the PF-Status we can add our own buttons.
Call Method of SALV to display PF: Now we will call this newly created PF status in our ALV using the method SET_SCREEN_STATUS of the reference of the class CL_SALV_TABLE
In this section we will define the private methods which can be implemented to set the properties of the ALV and can be      called in the
PRIVATE SECTION.    METHODS:     
set_pf_status     CHANGING    co_alv TYPE REF TO cl_salv_table.
In this area we will call the methods which will set the  different properties to the ALV   
CALL METHOD set_pf_status      CHANGING        co_alv = o_alv.
In this area we will implement the methods which are defined in  the class definition
  METHOD set_pf_status.
  Calling method to set the PF-Status  
co_alv->set_screen_status(
    pfstatus      =  'SALV_STANDARD'    
   report        =  'SALV_DEMO_TABLE_SELECTIONS'    
   set_functions = co_alv->c_functions_all ).
  ENDMETHOD.                  "set_pf_status

Similar Messages

  • Add buttons in ALV Report output

    Dear Friends,
    I am developing one ALV report in PP moule for calculating Shelf Life. The output is coming properly in ALV.
      But my additional requirement is ADD coustomise buttons in ALV Reports.
    Please give me an idea how can I insert buttons in my alv report?
    Thanks & Regards
    Vasu

    Hi vasu,
    consider the code given below.
          FORM F4200_PF_STATUS_SET                                      *
    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
      REFRESH i_extab.
      PERFORM f4210_exclude_fcodes CHANGING i_extab.
    The PF status is an exact copy of the PF status 'STANDARD' of program
    SAPLSALV but with command 'CHNG' added to it.
      SET PF-STATUS 'ZSOM_STANDARD' EXCLUDING i_extab.
    ENDFORM.
    *&      Form  f4210_exclude_fcodes
    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
      DATA: ws_fcode TYPE slis_extab.
      CLEAR ws_fcode.
      ws_fcode = '&EB9'.            " Call up Report.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&ABC'.            " ABC Analysis.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&NFO'.            " Info Select.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&LFO'.            " Information.
      APPEND ws_fcode TO i_extab.
    ENDFORM.                    " f4210_exclude_fcodes
    *&      Form  f4300_user_command
    FORM f4300_user_command USING ucomm LIKE sy-ucomm
                                             selfield TYPE slis_selfield.
      CASE ucomm.
        WHEN '&IC1'.                              "Double Click line Item
          READ TABLE i_data INDEX selfield-tabindex.
          IF i_data-qmnum NE space.
            SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
            CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
            CLEAR ucomm.
          ENDIF.
        WHEN 'CHNG'.                          " Change Notification Icon
          READ TABLE i_data INDEX selfield-tabindex.
          IF i_data-qmnum NE space.
            SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
            CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
          CLEAR ucomm.
          ENDIF.
      ENDCASE.
      CLEAR ucomm.
    ENDFORM.                    " f4300_user_command
    EXPLANATION
    In this program, first we created a PF status (ZSOM_STANDARD), which was an exact copy of STANDARD of program SAPLSALV through transaction SE41 (Menu Painter). Then we added another button to it,with a new fcode called ‘CHNG’.  After this this we set this PF status instead of STANADRD.
    We initialize a third event USER_COMMAND and associate a form with it. In this form we can capture the function codes and write any functionality under it. If we write functionality for an existing fcode, then this gets precedence over the default functionality that might be associated with it.
    In this example, we capture a standard fcode ‘&IC1’ that is nothing but double clicking a line of the report.  We are capturing the notification number of that line and calling transaction IW52 with it. We are also doing the same when a user clicks on the new ‘Change Notification’ button.
    When the user clicks the “Back’ button in IW52, it comes back to the report.
    Please reward for the same.
    Message was edited by: Prakhar Saxena

  • Information button in ALV report

    Information button in ALV report is not working. any suggestion

    I have copied standard tool bar from standard program.During debugging, I have found that function code is defferent. Then I changed function code according to that.

  • Control User Specific button in ALV report

    Hi,
    Can anybody please suggest me how to control "USER SPECIFIC" button in ALV report layout using authorization object. I mean if you can tell me which authorization object is responsible to control the "USER SPECIFIC" button.

    additional info to what Lakshmi already said:-
    normally the restrictions for saving layouts/display variants are done at 2 levels:
    1) The developer of an ALV list first predetermines the authorization in the 'i_save' parameter within the code.
    I_SAVE = ' '     -
    layouts cannot be saved
    I_SAVE = 'A'   -
    user-specific and cross-user layouts can be saved
    I_SAVE = 'X'   --- cross-user layouts can be saved
    I_SAVE = 'U'  ---  user-specific layouts can be saved
    2) The second level comes to us restriciting the S_ALV_LAYO which gives access to users to save global layouts if I_SAVE for that particular transaction is A or X.
    for example, a report has I_SAVE= 'A', which means
    it will allow to save  User-specific  layouts without any restrictions.
    and if user has S_ALV_LAYO then he can save both User-Specific and Global Layouts(variants).
    it would be better to keep this object separate.

  • Button in ALV Report

    Hi All,
    I want to know how to create a button in alv report .
    Please respond to my query.
    Thanks and Regards,
    Aman

    hi aman,
    u can try this example:
    where i have a created a button:
    *& Report  Z_GURU_ALV_EVENT01                                          *
    report  z_guru_alv_event01                      .
    tables: mara, makt.
    type-pools slis.
    data: begin of imara occurs 0,
            matnr like mara-matnr,
            ernam like mara-ernam,
            ersda like mara-ersda,
          end of imara.
    data: begin of imakt occurs 0,
            matnr like mara-matnr,
            spras like makt-spras,
            maktx like makt-maktx,
          end of imakt.
    data: ffc type slis_t_fieldcat_alv,
          ievents type slis_t_event with header line,
          iievent type slis_t_event with header line.
    select-options: s_matnr for mara-matnr.
    initialization.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
       i_list_type           = 0
    importing
       et_events             = ievents[]
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    read table ievents with key name = slis_ev_top_of_page.
    ievents-form = 'TOPP'.
    modify ievents transporting form where name = slis_ev_top_of_page.
    clear ievents.
    read table ievents with key name = slis_ev_user_command.
    ievents-form = 'USR_COM'.
    modify ievents transporting form where name = slis_ev_user_command.
    clear ievents.
    read table ievents with key name = slis_ev_pf_status_set.
    ievents-form = 'PFSTAT'.
    modify ievents transporting form where name = slis_ev_pf_status_set.
    clear ievents.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
       i_list_type           = 0
    importing
       et_events             = iievent[]
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    read table iievent with key name = slis_ev_pf_status_set.
    iievent-form = 'PFSTAT'.
    modify iievent transporting form where name = slis_ev_pf_status_set.
    clear iievent.
    read table iievent with key name = slis_ev_user_command.
    iievent-form = 'USERCOM'.
    modify iievent transporting form where name = slis_ev_user_command.
    clear iievent.
    start-of-selection.
    select matnr ernam ersda from mara into table imara where matnr
    in s_matnr.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMARA'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ffc
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
       i_callback_top_of_page            = 'ALV_BACKGROUND'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       i_callback_html_end_of_list       = 'ALV_BACKGROUND'
      I_STRUCTURE_NAME                  =
       i_background_id                   = 'ALV_BACKGROUND'
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ffc
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = ievents[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imara
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    form topp.
    data: it_top type slis_t_listheader,"”having s , h ,a
           wa type slis_listheader.
          IT_SPEC TYPE SLIS_T_SPECIALCOL_ALV,
          WA1 TYPE SLIS_SPECIALCOL_ALV.
    wa-typ = 'H'.
    wa-info = 'RELIANCE GLOBAL SERVICES' .
    append wa to it_top.
    clear wa.
    wa-typ = 'S'.wa-key = 'NO:23'.
    wa-info = 'TRIPLICANE HIGH ROAD'.
    append wa to it_top.
    clear wa.
    wa-typ = 'S'.
    wa-info = 'TRIPLICANE'.
    append wa to it_top.
    clear wa.
    wa-typ = 'A'.
    wa-info = 'sample'.
    append wa to it_top.
    clear wa.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
         it_list_commentary       = it_top
        i_logo                   = 'ENJOYSAP_LOGO'
       I_END_OF_LIST_GRID       =
       I_ALV_FORM               =
    endform.
    form usr_com using r_ucomm type sy-ucomm r_selfield type slis_selfield.
    case r_ucomm.
    when 'CANC'.
    leave to screen 0.
    endcase.
    data: ff type slis_t_fieldcat_alv.
    data: v_vbeln(18) type n.
    v_vbeln = r_selfield-value.
    select matnr spras maktx
    from makt into table imakt
    up to 10 rows
    where matnr = v_vbeln.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMAKT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ff
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ff
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = iievent[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imakt
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. "USR_COM
    form pfstat using extab type slis_t_extab.
    set pf-status 'STD' excluding extab.
    endform. " pfstat
    form usercom using rucom type sy-ucomm rselfield type slis_selfield.
    case rucom.
    when 'CANC'.
    leave to screen 0.
    endcase.
    data: ffc type slis_t_fieldcat_alv,
          v_matnr(18) type n.
    v_matnr = rselfield-value.
    select matnr ernam ersda from mara into table imara
    where matnr = v_matnr.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMARA'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ffc
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ffc
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = iievent[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imara
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform.

  • How to give  push button in alv report  output

    hi,
    my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
    regards,
    siva kumar

    have a look at this thread, also has a sample report at the end from Uwe Schieferstein.
    [button on alv list|How to add and program a pushbutton on ALV grid line;
    seems not to work try this:
    How to add and program a pushbutton on ALV grid line
    Edited by: Micky Oestreich on May 15, 2008 10:20 PM

  • How can we place a push button in ALV  report

    hi
    could anybody inform me
    how can we place a push button in ALV  report
    thanx
    regards
    kals.

    Hi kals.
    please have a look at demoprogram
    SALV_DEMO_TABLE_FUNCTIONS
    BCALV_GRID_05
    Regards
    Bernd

  • How to create user defined button in alv report

    how to create user defined button in alv report
    thnks in advance.

    Hi,
    U can define it the the PF-STATUS ( Menu for ALV ).
    For that u have to define it in the EVENTCAT.
    form z_eventcat  using    p_i_eventcat type slis_t_event.
      data: i_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_i_eventcat
        exceptions
          list_type_wrong = 1
          others          = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      clear i_event.
      read table p_i_eventcat with key name = slis_ev_top_of_page into
      i_event.
      if sy-subrc = 0.
        move 'TOP_OF_PAGE' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
      read table p_i_eventcat with key name = slis_ev_pf_status_set into i_event.
      if sy-subrc = 0.
        move 'SET_PF_STATUS' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
      clear i_event.
      read table p_i_eventcat into i_event with key name = slis_ev_user_command .
      if sy-subrc = 0.
        move 'USER_COMMAND' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
    And in the DISPLAY
    call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
         i_callback_program                = v_progname
         i_callback_pf_status_set          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         i_grid_title                      = v_gridtitle
         i_save                            = 'A'
         is_layout                         = i_layout
         it_fieldcat                       = i_fieldcat[]
         it_sort                           = i_sortinfo
         it_events                         = i_eventcat
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        tables
          t_outtab                          = it_final
       exceptions
         program_error                     = 1
         others                            = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    *MENU SETTINGS.
    form set_pf_status using rt_extab type slis_t_extab.
      set pf-status 'ALV_MENU'.
    endform.                    "SET_PF_STATUS
    endform.                    " Z_EVENTCAT
    Now double click on ALV MENU nad u can create a button in the application bar.
    Regards,
    Pritha.

  • Radio button in alv report

    Hi experts,
    I am using radio buttons in alv report by using screen painter but error occurs in alv that screen doesn't exist in module.
    plz help me.

    Hi Ankita,
    check this program.
    *& Report ZALVGRID_WITH_RADIOBUTTONS
    *& This program shows how to realize radiobuttons in ALV grid lists
    *& using event HOTSPOT_CLICK.
    *& Screen 100:
    *& - Flow logic
    *& PROCESS BEFORE OUTPUT.
    *& MODULE PBO.
    *& PROCESS AFTER INPUT.
    *& MODULE PAI.
    *& - Screen elements: none
    *& - ok-code field -> gd_okcode
    *& GUI Status MAIN100:
    *& - F3 = 'BACK', Shift+F3 = 'EXIT', F12 = 'CANC'
    PROGRAM zalvgrid_with_radiobuttons.
    TYPE-POOLS: abap, icon. " INCLUDE . for releases < 6.20
    TYPES: BEGIN OF ty_s_sflight.
    INCLUDE TYPE sflight.
    TYPES: button1 TYPE iconname.
    TYPES: button2 TYPE iconname.
    TYPES: button3 TYPE iconname.
    TYPES: button4 TYPE iconname.
    TYPES: END OF ty_s_sflight.
    DATA:
    gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
    gs_layout TYPE lvc_s_layo,
    gt_fcat TYPE lvc_t_fcat.
    DATA:
    gd_okcode TYPE ui_func,
    go_docking TYPE REF TO cl_gui_docking_container,
    go_grid TYPE REF TO cl_gui_alv_grid.
    CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
    PUBLIC SECTION.
    CLASS-METHODS:
    handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING
    e_row_id
    e_column_id
    es_row_no
    sender.
    ENDCLASS. "lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
    METHOD handle_hotspot_click.
    define local data
    FIELD-SYMBOLS:
    IS ASSIGNED ).
    Set all radio buttons "unselected"
    IS ASSIGNED ).
    Set selected radio button "selected".
    = icon_wd_radio_button.
    ENDIF.
    Force PAI followed by refresh of table display in PBO
    CALL METHOD cl_gui_cfw=>set_new_ok_code
    EXPORTING
    new_code = 'REFRESH'
    IMPORTING
    RC =
    ENDMETHOD. "handle_hotspot_click
    ENDCLASS. "lcl_eventhandler IMPLEMENTATION
    MAIN *
    START-OF-SELECTION.
    PERFORM select_data.
    PERFORM init_controls.
    PERFORM build_fieldcatalog.
    PERFORM set_layout.
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
    i_structure_name = 'SFLIGHT'
    is_layout = gs_layout
    CHANGING
    it_fieldcatalog = gt_fcat
    it_outtab = gt_sflight.
    Link docking container to dynpro
    CALL METHOD go_docking->link
    EXPORTING
    repid = syst-repid
    dynnr = '0100'
    CONTAINER =
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    lifetime_dynpro_dynpro_link = 3
    OTHERS = 4.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL SCREEN 100.
    END-OF-SELECTION.
    MODULE PBO OUTPUT *
    MODULE pbo OUTPUT.
    SET PF-STATUS 'MAIN100'.
    SET TITLEBAR 'MAIN100'.
    ENDMODULE. "PBO OUTPUT
    MODULE PAI INPUT *
    MODULE pai INPUT.
    Leave report
    CASE gd_okcode.
    WHEN 'BACK' OR
    'EXIT' OR
    'CANC'.
    SET SCREEN 0. LEAVE SCREEN.
    Refresh table display
    WHEN 'REFRESH'.
    PERFORM refresh_display.
    WHEN OTHERS.
    do nothing
    ENDCASE.
    CLEAR gd_okcode.
    ENDMODULE. "PAI INPUT
    *& Form BUILD_FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM build_fieldcatalog .
    ALV List with Radio Buttons
    SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
    © 2007 SAP AG 7
    define local data
    DATA:
    ls_fcat TYPE lvc_s_fcat.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_BUFFER_ACTIVE =
    i_structure_name = 'ICON'
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_BYPASSING_BUFFER =
    I_INTERNAL_TABNAME =
    CHANGING
    ct_fieldcat = gt_fcat
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    DELETE gt_fcat WHERE ( fieldname <> 'NAME' ).
    NOTE: field ICON-NAME has data element ICONNAME.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_BUFFER_ACTIVE =
    i_structure_name = 'SFLIGHT'
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_BYPASSING_BUFFER =
    I_INTERNAL_TABNAME =
    CHANGING
    ct_fieldcat = gt_fcat
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE gt_fcat INTO ls_fcat
    WITH KEY fieldname = 'NAME'.
    IF ( syst-subrc = 0 ).
    DELETE gt_fcat INDEX syst-tabix.
    ENDIF.
    ls_fcat-fieldname = 'BUTTON4'.
    ls_fcat-coltext = ls_fcat-fieldname.
    ls_fcat-icon = 'X'.
    ls_fcat-hotspot = 'X'.
    INSERT ls_fcat INTO gt_fcat INDEX 5.
    ls_fcat-fieldname = 'BUTTON3'.
    ls_fcat-coltext = ls_fcat-fieldname.
    INSERT ls_fcat INTO gt_fcat INDEX 5.
    ls_fcat-fieldname = 'BUTTON2'.
    ls_fcat-coltext = ls_fcat-fieldname.
    INSERT ls_fcat INTO gt_fcat INDEX 5.
    ls_fcat-fieldname = 'BUTTON1'.
    ls_fcat-coltext = ls_fcat-fieldname.
    INSERT ls_fcat INTO gt_fcat INDEX 5.
    Renumbering of the columns
    LOOP AT gt_fcat INTO ls_fcat.
    ls_fcat-col_pos = syst-tabix.
    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
    ENDLOOP.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form SELECT_DATA
    text
    --> p1 text
    <-- p2 text
    FORM select_data .
    define local data
    DATA:
    ls_sflight TYPE ty_s_sflight.
    SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
    ls_sflight-button1 = icon_wd_radio_button. " selected radiobutton
    ls_sflight-button2 = icon_wd_radio_button_empty.
    ls_sflight-button3 = icon_wd_radio_button_empty.
    ls_sflight-button4 = icon_wd_radio_button_empty.
    Alternatively: create icons using function module 'ICON_CREATE'
    on SAP releases where these icons are not available.
    MODIFY gt_sflight FROM ls_sflight
    TRANSPORTING button1 button2 button3 button4
    WHERE ( carrid IS NOT INITIAL ).
    ENDFORM. " SELECT_DATA
    *& Form INIT_CONTROLS
    text
    --> p1 text
    <-- p2 text
    FORM init_controls .
    CHECK ( go_docking IS NOT BOUND ).
    ALV List with Radio Buttons
    SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
    © 2007 SAP AG 9
    Create docking container
    CREATE OBJECT go_docking
    EXPORTING
    parent = cl_gui_container=>screen0
    REPID =
    DYNNR =
    SIDE = DOCK_AT_LEFT
    EXTENSION = 50
    STYLE =
    LIFETIME = lifetime_default
    CAPTION =
    METRIC = 0
    ratio = 90
    NO_AUTODEF_PROGID_DYNNR =
    NAME =
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Size of container = full screen size
    CALL METHOD go_docking->set_extension
    EXPORTING
    extension = 99999
    EXCEPTIONS
    cntl_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Create ALV grid instance
    CREATE OBJECT go_grid
    EXPORTING
    I_SHELLSTYLE = 0
    I_LIFETIME =
    i_parent = go_docking
    I_APPL_EVENTS = space
    I_PARENTDBG =
    I_APPLOGPARENT =
    I_GRAPHICSPARENT =
    I_NAME =
    I_FCAT_COMPLETE = SPACE
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Set event handler for event HOTSPOT_CLICK
    SET HANDLER:
    lcl_eventhandler=>handle_hotspot_click FOR go_grid.
    ENDFORM. " INIT_CONTROLS
    *& Form REFRESH_DISPLAY
    Refresh table display after switching the radiobuttons
    --> p1 text
    <-- p2 text
    FORM refresh_display .
    define local data
    DATA:
    ls_stable TYPE lvc_s_stbl.
    ls_stable-row = abap_true.
    ls_stable-col = abap_true.
    CALL METHOD go_grid->refresh_table_display
    EXPORTING
    is_stable = ls_stable
    I_SOFT_REFRESH =
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " REFRESH_DISPLAY
    *& Form SET_LAYOUT
    Set layout for ALV list
    --> p1 text
    <-- p2 text
    FORM set_layout .
    CLEAR: gs_layout.
    gs_layout-cwidth_opt = abap_true. " optimize column width
    gs_layout-zebra = abap_true.
    ENDFORM. " SET_LAYOUT
    Regards,
    Prasanth
    Reward if helpful

  • How to create a radio button in ALV Reports

    Hi all,
    Best wishes to all..
    Kindly reply me to this question... that is "How to create a radio button in ALV Report"
    Thanks and Regards
    Anjali

    HI
    here is an example :
    PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
    Based on: BCALV_GRID_DEMO.
    TYPE-POOLS: icon.
    TYPES: BEGIN OF ty_s_sflight.
    INCLUDE TYPE sflight.
    TYPES: button1    TYPE lvc_emphsz.
    TYPES: button2    TYPE lvc_emphsz.
    TYPES: button3    TYPE lvc_emphsz.
    TYPES: button4    TYPE lvc_emphsz.
    TYPES: END OF ty_s_sflight.
    DATA:
      gt_sflight    TYPE STANDARD TABLE OF ty_s_sflight,
      gt_fcat       TYPE lvc_t_fcat.
    DATA: ok_code LIKE sy-ucomm,
         gt_sflight TYPE TABLE OF sflight,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          md_cnt    TYPE i.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    define local data
        FIELD-SYMBOLS:
          <ls_entry>    TYPE ty_s_sflight,
          <ld_fld>      TYPE ANY.
        READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
        CHECK ( <ls_entry> IS ASSIGNED ).
      Set all radio buttons "unselected"
        <ls_entry>-button1 =  icon_wd_radio_button_empty.
        <ls_entry>-button2 =  icon_wd_radio_button_empty.
        <ls_entry>-button3 =  icon_wd_radio_button_empty.
        <ls_entry>-button4 =  icon_wd_radio_button_empty.
        ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
                                                  TO <ld_fld>.
        IF ( <ld_fld> IS ASSIGNED ).
        Set selected radio button "selected".
          <ld_fld> = icon_wd_radio_button.
        ENDIF.
      Force PAI followed by refresh of table display in PBO
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'DUMMY'
         IMPORTING
           RC       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
          MAIN                                                          *
      PERFORM select_data.
      CALL SCREEN 100.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
        PERFORM build_fieldcatalog.
        CALL METHOD grid1->set_table_for_first_display
         EXPORTING
           i_structure_name = 'SFLIGHT'
          CHANGING
            it_fieldcatalog  = gt_fcat
            it_outtab        = gt_sflight.
      Set event handler for event TOOLBAR
        SET HANDLER:
          lcl_eventhandler=>handle_hotspot_click FOR grid1.
      else.
        CALL METHOD grid1->refresh_table_display
         EXPORTING
           IS_STABLE      =
           I_SOFT_REFRESH =
          EXCEPTIONS
            FINISHED       = 1
            others         = 2.
        IF sy-subrc <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    ENDMODULE.                    "PBO OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      to react on oi_custom_events:
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN OTHERS.
        do nothing
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "PAI INPUT
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
    CALL METHOD G_CUSTOM_CONTAINER->FREE.
    CALL METHOD CL_GUI_CFW=>FLUSH.
      LEAVE PROGRAM.
    ENDFORM.                    "EXIT_PROGRAM
    *&      Form  BUILD_FIELDCATALOG
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcatalog .
    define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat,
        ls_hype        TYPE lvc_s_hype.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          i_structure_name             = 'LVC_S_FCAT'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          i_structure_name             = 'SFLIGHT'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'EMPHASIZE'.
      IF ( syst-subrc = 0 ).
        DELETE gt_fcat INDEX syst-tabix.
      ENDIF.
      ls_fcat-fieldname = 'BUTTON4'.
      ls_fcat-icon    = 'X'.
      ls_fcat-hotspot = 'X'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON3'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON2'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON1'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      LOOP AT gt_fcat INTO ls_fcat.
        ls_fcat-col_pos = syst-tabix.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SELECT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM select_data .
    define local data
      DATA:
        ls_sflight    TYPE ty_s_sflight.
      SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
      ls_sflight-button1 = icon_wd_radio_button.
      ls_sflight-button2 = icon_wd_radio_button_empty.
      ls_sflight-button3 = icon_wd_radio_button_empty.
      ls_sflight-button4 = icon_wd_radio_button_empty.
      MODIFY gt_sflight FROM ls_sflight
          TRANSPORTING button1 button2 button3 button4
        WHERE ( carrid IS NOT INITIAL ).
    ENDFORM.                    " SELECT_DATA
    Regards,
    Prasanth
    Reward all helpful answers

  • Adding/Enabling Totals & Subtotals Button in ALV Report Output

    Hi Guys,
    I would like to know , how to add / enable Totals & Subtotals Button on the application tool bar in alv report output.
    Regards,
    Kishan

    ok so here i am sending my code....its also interactive...
    and in second list i am displaying quantity....
    *& Report  ZINT_ALV
    REPORT  zint_alv.
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           mseg.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
         END OF itab.
    DATA:BEGIN OF itab1 OCCURS 0,
          mblnr LIKE mseg-mblnr,
          menge LIKE mseg-menge,
          meins LIKE mseg-meins,
          werks LIKE mseg-werks,
         END OF itab1.
    DATA:fcat TYPE slis_t_fieldcat_alv,
         fcat1 TYPE slis_t_fieldcat_alv,
         eve TYPE slis_t_event,
         eve1 TYPE slis_t_event.
    DATA:t_mat LIKE mara-matnr,
         s_mat LIKE mara-matnr,
         g_repid LIKE sy-repid.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_fcat USING fcat.
      PERFORM build_eve.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  build_fcat
          text
         -->T_FCAT     text
    FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MARA'.
      wa_fcat-seltext_m = 'Material'.
    wa_fcat-input = ' '.
    wa_fcat-edit = 'X'.
      wa_fcat-input = 'X'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    "build_fcat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA:t_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type           = 0
       IMPORTING
         et_events             = eve
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  get_data
          text
    FORM get_data.
      SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt
      ON maramatnr = maktmatnr
      WHERE mara~matnr IN mat.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid         "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND'
         i_grid_title                      = 'Interactive ALV'
         it_fieldcat                       = fcat
         it_events                         = eve
        TABLES
          t_outtab                          = itab
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "dis_data
    *&      Form  user_command
          text
         -->U_COM      text
    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
      CLEAR fcat1.
      CASE u_com.
        WHEN '&IC1'.
          READ TABLE itab INDEX sel_field-tabindex.
          IF sel_field-fieldname = 'MATNR'.
            IF sy-subrc = 0.
              t_mat = itab-matnr.
              PERFORM build_cat1 USING fcat1.
              PERFORM build_eve1.
              PERFORM get_data1.
              PERFORM dis_data1.
            ENDIF.
          ENDIF.
         SET PARAMETER ID 'MAT' FIELD t_mat.
         CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  build_fcat1
          text
         -->T_FCAT1    text
    FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat1 TYPE slis_fieldcat_alv.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MBLNR'.
      wa_fcat1-seltext_m = 'Material Doc.'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MENGE'.
      wa_fcat1-seltext_m = 'Quantity'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MEINS'.
      wa_fcat1-seltext_m = 'UOM'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'WERKS'.
      wa_fcat1-seltext_m = 'Plant'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
    ENDFORM.                    "build_fcat1
    *&      Form  build_eve1
          text
    FORM build_eve1.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = eve1
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "build_eve1
    *&      Form  get_data1
          text
    FORM get_data1.
      SELECT mblnr menge meins werks FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab1
      WHERE matnr = t_mat.
    ENDFORM.                                                    "get_data1
    *&      Form  dis_data1
          text
    FORM dis_data1.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid              "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND1'
         it_fieldcat                       = fcat1
         it_events                         = eve1
        TABLES
          t_outtab                          = itab1
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "dis_data1

  • How to get GUI Status(Push Buttons) in ALV Report

    Hi Friends
    I have a requirement in a way that:
    Once selection-screen was processed,an ALV report has to come and above the ALV List,I need a custom GUI Status(4 Push Button) with Push Buttons Logic.
    Once I had clicks on thesse push button,I need to display one more ALV List and above this List,again I need a custom GUI Status(2 Push Buttons) with Push Buttons Logic.
    Can anyone throw some light how we can achieve this.
    Thanks for your cooperation!
    Regards,
    Madisetty

    data: rt_extab type slis_t_extab,
            g_ucomm like sy-ucomm ,
            g_selfield type slis_selfield.
    form alv_display .
      call function 'REUSE_ALV_LIST_DISPLAY'
         exporting
         i_callback_program             = g_repid
         i_callback_pf_status_set       = 'PF_STATUS'
         i_callback_user_command        = 'USER_COMM'
           it_fieldcat                    = it_fldcat
          tables
            t_outtab                       = it_final1
      perform pf_status using rt_extab.
      perform user_comm using g_ucomm g_selfield .
    endform.  
    form pf_status  using    p_rt_extab.
      set pf-status 'PF_STATUS' excluding p_rt_extab.
    endform.
    form user_comm  using    p_ucomm like sy-ucomm
                             p_selfield type slis_selfield.
      data: l_row type i.
      case  p_ucomm.
        when 'DISPLAY_PO'.
          loop at it_final1 into wa_final1.
            if wa_final1-sel eq 'X' .
              l_row = l_row + 1.
            endif.
            if l_row gt 1.
              message e004.
            endif.
            clear wa_final1.
          endloop.
          p_selfield-fieldname = 'SEL'.
          read table it_final1 into wa_final1 index p_selfield-tabindex .
          set parameter id 'BES' field wa_final1-ebeln.
          call transaction 'ME23N'.
      endcase.
    endform.
    *create user interface for gui status by double clicking on 'PF_STATUS'.
    *Check the above sample code .

  • How to add button in ALV report (Class method )?

    Hello experts,
    I have developed one ALV report using classes.
    I want to add one more  button on the report like already is there named DISPLQUA
    How ca i do that here?
    Following the code of CLASS definition & implimentation
    CLASS lcl_handle_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_on_user_command FOR EVENT added_function OF cl_salv_events
            IMPORTING e_salv_function.
    ENDCLASS.                    "lcl_handle_events DEFINITION
          CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD handle_on_user_command.
        CASE e_salv_function.
          WHEN 'DISPLQUA'.
            PERFORM show_quant_record.
         WHEN 'DISPQM03'.                                " Here i want to add button
           PERFORM display_quality_notification.
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.                    "handle_on_user_command
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

    HI Ronny.
    Code snippet for reference.
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION.
        METHODS :
    *--Toolbar control
          HANDLE_TOOLBAR FOR EVENT TOOLBAR
            OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
                                         E_INTERACTIVE,
    ENDCLASS
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *--handle toolbar
      METHOD HANDLE_TOOLBAR.
    * append a separator to normal toolbar
        CLEAR G_TOOLBAR.
        G_TOOLBAR-BUTN_TYPE = 3.
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
        CLEAR G_TOOLBAR.
        G_TOOLBAR-FUNCTION = 'SAVE'.
        G_TOOLBAR-ICON = ICON_SYSTEM_SAVE.
        G_TOOLBAR-BUTN_TYPE = 0.
        G_TOOLBAR-QUICKINFO = 'Save the Customer'(203).
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
      ENDMETHOD.                    "HANDLE_TOOLBAR
    Hope this helps.
    Gary.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 7, 2008 5:41 PM

  • Hide Change Layout Button in ALV report o/p for MB52 Tcode

    Hi,
    Is it possible to Hide Change Layout Button in ALV output for Report MB52 using authoriztaion.
    We have created a layout in which we are hiding some coloumns which the user should not see.
    But if the change layout button is active then the user can add those coloumns to output.
    Is this possible through authorizations. I want to avoid doing any chnages to the std sap program.
    Thanks & Regards,
    Fawaz

    Check the object S_ALV_LAYO

  • Push button in alv report

    Dear Experts,
             How to add pushbutton in alv report.....
    *& Report  ZTT_TEST_ALV
    REPORT  ZTT_TEST_ALV.
    *data declarations
    type-pools : SLIS.
    *  data : BEGIN OF wa_kna1,
    *                kunnr type kunnr,
    *                name1 type name1,
    *         end of wa_kna1,
    * it_kna1 like tABLE OF wa_kna1.
    data : begin of wa_mara,
      matnr type matnr,
      end of wa_mara,
      it_mara like table of wa_mara.
      data : it_fcat type slis_t_fieldcat_alv,
             wa_fcat like line of it_fcat.
    *selection screen
      SELECTION-SCREEN begin of block k with frame title text-001.
    *  select-OPTIONS : s_kunnr for wa_kna1-kunnr.
         select-OPTIONS : s_matnr for wa_mara-matnr.
      SELECTION-SCREEN end of block k.
    *select auery
    *SELECT kunnr name1 INTO table it_kna1 from kna1 where kunnr in s_kunnr.
    select matnr into table it_mara from mara where matnr in s_matnr.
    *for displaying fieldcatalog
      PERFORM fcat using '1' 'MATNR' 'material Number' 'C410' '20'.
    *  PERFORM fcat using '2' 'NAME1' 'Customer Name' 'C410' '36'.
    *for displaying output
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
    *   I_CALLBACK_PROGRAM                = ' '
       I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = 'Report for Customer Details'
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         =
       IT_FIELDCAT                       = it_fcat[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          = it_mara.
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    *  EXPORTING
    ****   I_INTERFACE_CHECK              = ' '
    ****   I_CALLBACK_PROGRAM             =
    ****   I_CALLBACK_PF_STATUS_SET       = ' '
    ****   I_CALLBACK_USER_COMMAND        = ' '
    ****   IS_LAYOUT                      =
    *   IT_FIELDCAT                    = it_fcat
    ****   IT_EXCLUDING                   =
    ****   IT_SPECIAL_GROUPS              =
    ****   IT_SORT                        =
    ****   IT_FILTER                      =
    ****   IS_SEL_HIDE                    =
    ****   I_SCREEN_START_COLUMN          = 0
    ****   I_SCREEN_START_LINE            = 0
    ****   I_SCREEN_END_COLUMN            = 0
    ****   I_SCREEN_END_LINE              = 0
    ****   I_DEFAULT                      = 'X'
    ****   I_SAVE                         = ' '
    ****   IS_VARIANT                     =
    ****   IT_EVENTS                      =
    ****   IT_EVENT_EXIT                  =
    ***    i_tabname_header               =
    ***    i_tabname_item                 =
    ****   I_STRUCTURE_NAME_HEADER        =
    ****   I_STRUCTURE_NAME_ITEM          =
    ***    is_keyinfo                     =
    ****   IS_PRINT                       =
    ****   IS_REPREP_ID                   =
    ****   I_BYPASSING_BUFFER             =
    ****   I_BUFFER_ACTIVE                =
    ****   IR_SALV_HIERSEQ_ADAPTER        =
    ****   IT_EXCEPT_QINFO                =
    ****   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    **** IMPORTING
    ****   E_EXIT_CAUSED_BY_CALLER        =
    ****   ES_EXIT_CAUSED_BY_USER         =
    *  tables
    **    t_outtab_header                = it_
    *    t_outtab_item                  = it_kna1.
    **** EXCEPTIONS
    ****   PROGRAM_ERROR                  = 1
    ****   OTHERS                         = 2
    ***IF sy-subrc <> 0.
    **** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    ****         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ***ENDIF.
    *&      Form  FCAT
    *       text
    *      -->P_0052   text
    *      -->P_0053   text
    *      -->P_0054   text
    form FCAT  using    fp_col_pos
                        fp_fieldname
                        fp_seltext_m
                        fp_emphasize
                        fp_outputlen..
    wa_fcat-col_pos = fp_col_pos.
    wa_fcat-fieldname = fp_fieldname.
    wa_fcat-seltext_m = fp_seltext_m.
    wa_fcat-emphasize = fp_emphasize.
    wa_fcat-outputlen = fp_outputlen.
    append wa_fcat to it_fcat.
    clear : wa_fcat.
    endform.                    " FCAT
    FORM SET_PF_STATUS                                         .
    SET PF-STATUS 'ZNEWSTATUS' .
    "Copy of 'STANDARD' pf_status from fgroup SALV
    endform.
    i need one push button in alv output display.
    Thanks and Regards,
    Thirukumaran. R

    HI THIRU TRY FOLLOWING CODES:
    *& Report  ZSAMPLE
    REPORT  ZSAMPLE.
    TABLES:MARA.
    TYPE-POOLS: SLIS.
    TYPES:BEGIN OF TY_ITAB,
          MATNR LIKE MARA-MATNR,
          ERSDA LIKE MARA-ERSDA,
          END OF TY_ITAB.
    DATA:ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV,
              WA_FCAT TYPE SLIS_FIELDCAT_ALV,
              LAYOUT TYPE SLIS_LAYOUT_ALV,
              WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:P_MATNR TYPE MARA-MATNR.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM FIELDCAT.
      LAYOUT-ZEBRA = 'X'.
      PERFORM OUTPUT.
    *&      Form  PF_STATUS
          text
         -->RT_EXTAB   text
    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'BUTT'.
    ENDFORM.                    "PF_STATUS
    *&      Form  PUSH_BUTT1
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM GET USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'GET'.
          IF SY-SUBRC EQ 0.
            CALL TRANSACTION 'SE11'.
          ELSE.
          ENDIF.
        WHEN 'EXIT' OR 'CANCEL' .
          LEAVE PROGRAM.
      ENDCASE.
    ENDFORM.                                                    "PUSH_BUTT1
    *&      Form  FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      WA_FCAT-SELTEXT_L = 'Select'.
      WA_FCAT-COL_POS = '1'.
      WA_FCAT-FIELDNAME = 'CHECK'.
      WA_FCAT-CHECKBOX = 'X'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '4'.
      WA_FCAT-INPUT(1) = 'X'.
    WA_FCAT-EDIT_MASK(1) = 'X'.
      WA_FCAT-EDIT(1) = 'X'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-SELTEXT_L = 'Material Number'.
      WA_FCAT-COL_POS = '2'.
      WA_FCAT-FIELDNAME = 'MATNR'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '18'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-SELTEXT_L = 'Date'.
      WA_FCAT-COL_POS = '3'.
      WA_FCAT-FIELDNAME = 'ERSDA'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '8'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
    ENDFORM.                    " FIELDCAT
    *&      Form  OUTPUT
          text
    -->  p1        text
    <--  p2        text
    FORM OUTPUT .
      SELECT MATNR ERSDA FROM MARA
        INTO TABLE ITAB
        WHERE MATNR EQ  P_MATNR.
      IF SY-SUBRC EQ 0.
        PERFORM GRID.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " OUTPUT
    *&      Form  GRID
          text
    -->  p1        text
    <--  p2        text
    FORM GRID .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_CALLBACK_PROGRAM              = SY-REPID
       I_CALLBACK_PF_STATUS_SET        = 'PF_STATUS'
       I_CALLBACK_USER_COMMAND         = 'GET'
       IS_LAYOUT                         = LAYOUT
         IT_FIELDCAT                     = FCAT
       I_DEFAULT                         = 'X'
        TABLES
          T_OUTTAB                          = ITAB.
    ENDFORM.                    " GRID
    REGARDS,
    SAKTHIVEL.VT

Maybe you are looking for

  • Dashcode is not working in Mountain Lion. I tried updating to Xcode 4.4 and it still did not work . . .

    Dashcode is not working in Mountain Lion. I tried updating to Xcode 4.4 and it still did not work . . . I use dashcode for most of my coding needs, so it is very important to me!

  • In master detail concept

    When user is going to add data into details section user need to get data from existing corresponding master data for example he add country code and state code in master he need to get added data from master to details for insert personal informatio

  • Bank Reconciliation report missing transtype=57

    Hi we are using SAP B1 version 8.81(8.81.313) PL 05 We have a cyrstal report for Bank Reconciliation which is missing all transactions with transtype=57 (Checks for Payment). 1. Is this a standard report for SAP B1 or has this been developed for us? 

  • JDeveloper 10.1.3.5 SOA extension not available

    Hi, anybody can help with locating the SOA extension for JDeveloper 10.1.3.5? It is not available on standard update center for jdev anymore. Thank you & kind regards, Ivan Edited by: Ivan Kristek on Aug 16, 2011 10:54 AM

  • Substract problem

    update  emp set sal = ((select max(sal) from emp) - (select min(sal) from emp))  where ename='SMITH' SQL> / update  emp set sal = ((select max(sal) from emp) - (select min(sal) from emp))  where ename='SMITH' ERROR at line 1: ORA-00907: missing right