After_user_command or befor_user_command of a ALV

Hi,
I have a report with ALV where I have both after_user_command and befor_user_command handled.
The ALV is in edit mode.
This events are triggered in my report for all standard buttons of a ALV Toolbar except buttons : "Add new row",
"Append new row" and "Delete row".
Is there any way how to determine that user has changed, inserted or deleted a data ?
Thank you.
Marian Morzol

Hi Marian
The functions you've mentioned trigger the event <b>"data_changed"</b>. This event has a parameter referenced to class type <b>"CL_ALV_CHANGED_DATA_PROTOCOL"</b> which has attributes as internal tables containing changed, inserted and deleted rows/cells.
Within this event you can check user input and make the protocol class to handle error, warning and info messages.
After passing this event, <b>"data_change_finished"</b> event is triggerred in which it is guaranteed that the input has passed all data change controls.
For more information you can also refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Similar Messages

  • Functionality of Checkbox in ALV Grid Report

    Hi Experts,
    I created a ALV grid report with the checkbox as my first coloum and other fields as shown below. Initially, my ALV report displays as below. It is working fine till here.
    checkbox       customer     material      quantity       UOM         Sales Order    Delivery
                           C1                  M1           1                  KG
                           C1                   M2           2                  KG
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    I have created a push button on application toolbar for creating sales order and delivery using bapi's. When I click on my pushbutton, as of now it creates the SO and delivery for the first customer C1 and updates my Internal table with the sales order number and delivery number. If I need to create sales order for the second customer I need to run my ALV report again and so on for 3rd, 4th and 5th customers. It is also working fine till here.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
                           C1                  M1           1                  KG          SO1               DEL1
                           C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    Need help on this:
    When I select the check boxes as shown below and when I click the push button to create SO and Delivery then my program should create sales order and delivery for all the checked ones as shown below. What is the condition do I need to put here for selecting the checkbox.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
    X                      C1                  M1           1                  KG         SO1               DEL1
    X                     C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
    X                     C3                   M1          1                   KG        SO3             DEL3
    X                     C3                   M2          2                   KG        SO3             DEL3
    X                     C3                   M3           3                 KG          SO3            DEL3
                            C4                  M1           1                  KG
    X                     C5                   M5           1                  KG          SO5            DEL5
    I would really appreciate if somebody could help me / guide me on this. I will also post my code if someone needs to understand what I am doing exactly.
    Thanks.

    You need to use OO ABAP
    Use Class the class  1)  CL_GUI_ALV_GRID, 2) CL_GUI_CUSTOM_CONTAINER
    Create Sceen and container on same screen.
    Check following COde it used for printing purpose.
    Using AFTER_USER_COMMAND  Event you will find Check box selected entries.
    Capture those in another internal Table and use it for SO Creation
    DATA:  O_GRID TYPE REF TO CL_GUI_ALV_GRID,
           O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           T_FCAT TYPE LVC_T_FCAT,
           CONTAINER(15) TYPE C VALUE 'ET_CONTAINER'.
          CLASS EVENT_CLASS DEFINITION
    CLASS EVENT_CLASS DEFINITION.
      PUBLIC SECTION.
        METHODS: BEFORE_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
                 DOUBLE_CLICK_N  FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN,
                 TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT.
    ENDCLASS.                    "EVENT_CLASS DEFINITION
          CLASS EVENT_CLASS IMPLEMENTATION
    CLASS EVENT_CLASS IMPLEMENTATION.
      METHOD BEFORE_COMMAND.
        IF E_UCOMM = 'PRINT'.
          CLEAR : W_FLAG.
          T_FINAL2 = T_FINAL.
          SORT T_FINAL2 BY COL_CHK .
          DELETE   T_FINAL2 WHERE COL_CHK = ' '.
          IF NOT T_FINAL2 IS INITIAL.
            LOOP AT T_FINAL2 INTO WA_FINAL.
              IF W_FLAG IS INITIAL.
      Does some of modification/s in control parameters
                W_CONTROL_PARAM-NO_OPEN   = 'X'.
                W_CONTROL_PARAM-NO_CLOSE  = 'X'.
                W_CONTROL_PARAM-PREVIEW   = 'X'.
                W_CONTROL_PARAM-NO_DIALOG = SPACE.
                W_OUTPUT_OPTIONS-TDNEWID = 'X'.
                W_OUTPUT_OPTIONS-TDIMMED = SPACE.
      Opens the smartform print-job
                CALL FUNCTION 'SSF_OPEN'
                  EXPORTING
                    OUTPUT_OPTIONS     = W_OUTPUT_OPTIONS
                    CONTROL_PARAMETERS = W_CONTROL_PARAM
                  EXCEPTIONS
                    FORMATTING_ERROR   = 1
                    INTERNAL_ERROR     = 2
                    SEND_ERROR         = 3
                    USER_CANCELED      = 4
                    OTHERS             = 5.
                IF SY-SUBRC EQ 0.
                  W_FLAG = 'X'.
                ELSE.
                 LEAVE LIST-PROCESSING.
                ENDIF.
              ENDIF.
              IF W_FLAG = 'X'.
                CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
                  EXPORTING
                    FORMNAME           = 'ZFORM_BIW_PRINT'
                  IMPORTING
                    FM_NAME            = LF_FM_NAME
                  EXCEPTIONS
                    NO_FORM            = 1
                    NO_FUNCTION_MODULE = 2
                    OTHERS             = 3.
                IF SY-SUBRC <> 0.
                ENDIF.
                IF SY-SUBRC = 0.
                  CALL FUNCTION LF_FM_NAME
                    EXPORTING
                      CONTROL_PARAMETERS = W_CONTROL_PARAM
                     V_VBELN            = WA_FINAL-VBELN
                      WA_FINAL           = WA_FINAL.
                   TABLES
                     T_FINAL            = T_FINAL.
                ELSE.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                ENDIF.
              ENDIF.
            ENDLOOP.
           * Close the smartform print job
            IF W_FLAG EQ 'X'.
              CALL FUNCTION 'SSF_CLOSE'
                EXCEPTIONS
                  FORMATTING_ERROR = 1
                  INTERNAL_ERROR   = 2
                  SEND_ERROR       = 3
                  OTHERS           = 4.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "BEFORE_COMMAND

  • ALV-Grid:  Is it possible to catch "LOCAL Function Codes" in any Event ??

    Hi,
    is it possible that i can catch a "Local Function Code" in ALV Grid with an Event??
    For example if you click to an Grid Button on the toolbar than it must call an Event!
    ..........BUTTON: Local APPEND (existing in ALV Toolbar)
    Function Code: '&LOCAL&APPEND'
    My Idea is:
    --- IF i click to the Button "Local APPEND" in the ALV toolbar, than it must after this command give me an Message( "It was Successfull" ).
    But the "Local Function Codes" dont called the Event "User_command" OR "After_user_command" is there any other Event for this "Local Function Codes"???
    Have anyone an idea?
    Thanks in forward.
    Ersin

    Hi,
    See following thread.
    http://scn.sap.com/thread/715996
    Thanks
    Santosh

  • Handling Events in ALV Grid Display

    Hi,
         I need ur urgent help on how to trigger and handle the events associated with the class CL_GUI_ALV_GRID_DISPLAY .Events like
    •     ONF4
    •     ONF1
    •     DATA_CHANGED
    •     USER_COMMAND
    •     TOOLBAR
    •     HOTSPOT_CLICK
    Please help me in this matter and post some valid codes depicting these events.Ur help will be really appreciated throught points.
    Thnkx in advance.

    Hi,
    Please refer program "BCALV_TEST_GRID_EVENTS"
    Best regards,
    Prashant
    *& Report  BCALV_TEST_GRID_EVENTS                                      *
    report  bcalv_test_grid_events.
    types: g_ty_t_carrid  type standard table of alv_tab,
           g_ty_t_connid  type standard table of alv_chck,
           g_ty_t_curr    type standard table of alv_cur,
           g_ty_s_sflight type alv_t_t2,
           g_ty_s_carrid  type alv_tab,
           g_ty_s_connid  type alv_chck,
           g_ty_s_curr    type alv_cur.
    constants: con_sflight type lvc_fname value 'ALV_T_T2',
               con_scarr   type lvc_fname value 'ALV_TAB',
               con_spfli   type lvc_fname value 'ALV_CHCK'.
    * DATA                                                                 *
    class lcl_events_d0100 definition deferred.
    types: begin of g_ty_s_plane,
             carrid    type g_ty_s_sflight-carrid,
             connid    type g_ty_s_sflight-connid,
             planetype type g_ty_s_sflight-planetype,
             seatsmax  type g_ty_s_sflight-seatsmax,
           end   of g_ty_s_plane,
           g_ty_t_plane type sorted table of g_ty_s_plane
                             with unique key carrid connid,
           begin of g_ty_s_event,
             user_command                 type char1,
             before_user_command          type char1,
             after_user_command           type char1,
             double_click                 type char1,
             hotspot_click                type char1,
             button_click                 type char1,
             onf1                         type char1,
             onf4                         type char1,
             menu_button                  type char1,
             toolbar                      type char1,
             context_menu_request         type char1,
             ondrag                       type char1,
             ondrop                       type char1,
             ondropcomplete               type char1,
             ondropgetflavor              type char1,
             subtotal_text                type char1,
             data_changed                 type char1,
             data_changed_finished        type char1,
             after_refresh                type char1,
             delayed_callback             type char1,
             delayed_changed_sel_callback type char1,
             top_of_page                  type char1,
             end_of_list                  type char1,
             print_top_of_page            type char1,
             print_end_of_page            type char1,
             print_top_of_list            type char1,
             print_end_of_list            type char1,
           end   of g_ty_s_event,
           begin of g_ty_s_onf4,
             register        type char1,
             get_before      type char1,
             change_after    type char1,
             internal_format type char1,
           end   of g_ty_s_onf4,
           begin of g_ty_s_test,
             select_amount      type i,
             no_info_popup      type char1,
             info_popup_once    type char1,
             events_info_popup  type lvc_fname occurs 0,
             application_events type char1,
             event              type g_ty_s_event,
             onf4               type g_ty_s_onf4,
             button_fields      type lvc_fname occurs 0,
             hotspot_fields     type lvc_fname occurs 0,
             onf1_fields        type lvc_fname occurs 0,
             onf4_fields        type lvc_fname occurs 0,
             bypassing_buffer   type char1,
             buffer_active      type char1,
           end   of g_ty_s_test,
           begin of g_ty_s_outtab.
    include type g_ty_s_sflight.
    types:   box                  type char1,
             lights               type char1,
           end   of g_ty_s_outtab,
           g_ty_t_outtab type table of g_ty_s_outtab.
    constants: con_exit type sy-ucomm value 'EXIT',
               con_canc type sy-ucomm value 'CANC',
               con_back type sy-ucomm value 'BACK',
               con_true     type char1 value 'X'.
    data: g_okcode type sy-ucomm.
    data: gs_test type g_ty_s_test.
    data: gt_outtab type g_ty_t_outtab with header line,
          gr_container_d0100   type ref to cl_gui_custom_container,
          gr_grid_d0100        type ref to cl_gui_alv_grid,
          gr_events_d0100      type ref to lcl_events_d0100,
          gr_grid_dragdrop     type ref to cl_dragdrop.
    data: g_static_menu            type ref to cl_ctmenu,
          g_static_menu_default    type ref to cl_ctmenu.
    data: g_field type lvc_s_fcat-fieldname.
    *       CLASS lcl_dragdrop_obj_d0100 DEFINITION
    class lcl_dragdrop_obj_d0100 definition.
      public section.
        data: line  type g_ty_s_outtab,
              index type i.
    endclass.                    "lcl_dragdrop_obj_d0100 DEFINITION
    *       CLASS lcl_events_d0100 DEFINITION
    class lcl_events_d0100 definition.
      public section.
        methods:
        user_command         for event user_command
                             of cl_gui_alv_grid
                             importing e_ucomm sender,
        before_user_command  for event before_user_command
                             of cl_gui_alv_grid
                             importing e_ucomm,
        after_user_command   for event after_user_command
                             of cl_gui_alv_grid
                             importing e_ucomm
                                       e_not_processed
                                       e_saved,
        double_click         for event double_click
                             of cl_gui_alv_grid
                             importing e_row
                                       e_column
                                       es_row_no,
        hotspot_click        for event hotspot_click
                             of cl_gui_alv_grid
                             importing e_row_id
                                       e_column_id
                                       es_row_no,
        menu_button          for event menu_button
                             of cl_gui_alv_grid
                             importing e_object
                                       e_ucomm,
        toolbar              for event toolbar
                             of cl_gui_alv_grid
                             importing e_object
                                       e_interactive,
        context_menu_request for event context_menu_request
                             of cl_gui_alv_grid
                             importing e_object,
        top_of_page          for event top_of_page
                             of cl_gui_alv_grid
                             importing e_dyndoc_id,
        end_of_list          for event end_of_list
                             of cl_gui_alv_grid
                             importing e_dyndoc_id,
        print_top_of_page    for event print_top_of_page
                             of cl_gui_alv_grid,
        print_end_of_page    for event print_end_of_page
                             of cl_gui_alv_grid,
        print_top_of_list    for event print_top_of_list
                             of cl_gui_alv_grid,
        print_end_of_list    for event print_end_of_list
                             of cl_gui_alv_grid,
        after_refresh        for event after_refresh
                             of cl_gui_alv_grid,
        delayed_callback     for event delayed_callback
                             of cl_gui_alv_grid,
        delayed_changed_sel_callback
                             for event delayed_changed_sel_callback
                             of cl_gui_alv_grid,
        subtotal_text        for event subtotal_text
                             of cl_gui_alv_grid
                             importing es_subtottxt_info
                                       ep_subtot_line
                                       e_event_data,
        ondrag               for event ondrag
                             of cl_gui_alv_grid
                             importing e_row
                                       e_column
                                       es_row_no
                                       e_dragdropobj,
        ondrop               for event ondrop
                             of cl_gui_alv_grid
                             importing e_row
                                       e_column
                                       es_row_no
                                       e_dragdropobj,
        ondropcomplete       for event ondropcomplete
                             of cl_gui_alv_grid
                             importing e_row
                                       e_column
                                       es_row_no
                                       e_dragdropobj,
        ondropgetflavor      for event ondropgetflavor
                             of cl_gui_alv_grid
                             importing e_row
                                       e_column
                                       es_row_no
                                       e_dragdropobj
                                       e_flavors,
        data_changed         for event data_changed
                             of cl_gui_alv_grid
                             importing er_data_changed
                                       e_onf4
                                       e_onf4_before
                                       e_onf4_after,
        data_changed_finished
                             for event data_changed_finished
                             of cl_gui_alv_grid,
        button_click         for event button_click
                             of cl_gui_alv_grid
                             importing es_col_id
                                       es_row_no,
        onf1                 for event onf1
                             of cl_gui_alv_grid
                             importing e_fieldname
                                       es_row_no
                                       er_event_data,
        onf4                 for event onf4
                             of cl_gui_alv_grid
                             importing e_fieldname
                                       e_fieldvalue
                                       es_row_no
                                       er_event_data
                                       et_bad_cells
                                       e_display.
    endclass.                    "lcl_events_d0100 DEFINITION
    *       CLASS lcl_events_d0100 IMPLEMENTATION
    class lcl_events_d0100 implementation.
    *       METHOD user_command                                           *
      method user_command.
        perform d0100_event_ucomm using e_ucomm.
      endmethod.                    "user_command
    *       METHOD before_user_command                                    *
      method before_user_command.
        perform d0100_event_before_ucomm using e_ucomm.
      endmethod.                    "before_user_command
    *       METHOD after_user_command                                     *
      method after_user_command.
        perform d0100_event_after_ucomm using e_ucomm
                                              e_not_processed
                                              e_saved.
      endmethod.                    "after_user_command
    *       METHOD double_click                                           *
      method double_click.
        perform d0100_event_double_click using e_row
                                               e_column.
      endmethod.                    "double_click
    *       METHOD hotspot_click                                          *
      method hotspot_click.
    *    perform d0100_event_hotspot_click using e_row_id
    *                                            e_column_id.
        gr_grid_d0100->refresh_table_display( ).
      endmethod.                    "hotspot_click
    *       METHOD menu_button                                            *
      method menu_button.
        perform d0100_event_menu_button using e_object
                                              e_ucomm.
      endmethod.                    "menu_button
    *       METHOD toolbar                                                *
      method toolbar.
        perform d0100_event_toolbar using e_object
                                          e_interactive.
      endmethod.                    "toolbar
    *       METHOD context_menu_request                                   *
      method context_menu_request.
        perform d0100_event_context_menu_reqst using e_object.
      endmethod.                    "context_menu_request
    *       METHOD top_of_page                                            *
      method top_of_page.
        perform d0100_event_top_of_page using e_dyndoc_id.
      endmethod.                    "top_of_page
    *       METHOD end_of_list                                            *
      method end_of_list.
        perform d0100_event_end_of_list using e_dyndoc_id.
      endmethod.                    "end_of_list
    *       METHOD print_top_of_page                                      *
      method print_top_of_page.
        perform d0100_event_print_top_of_page.
      endmethod.                    "print_top_of_page
    *       METHOD print_end_of_page                                      *
      method print_end_of_page.
        perform d0100_event_print_end_of_page.
      endmethod.                    "print_end_of_page
    *       METHOD print_top_of_list                                      *
      method print_top_of_list.
        perform d0100_event_print_top_of_list.
      endmethod.                    "print_top_of_list
    *       METHOD print_end_of_list                                      *
      method print_end_of_list.
        perform d0100_event_print_end_of_list.
      endmethod.                    "print_end_of_list
    *       METHOD after_refresh                                          *
      method after_refresh.
        perform d0100_event_after_refresh.
      endmethod.                    "after_refresh
    *       METHOD delayed_callback                                       *
      method delayed_callback.
        perform d0100_event_delayed_callback.
      endmethod.                    "delayed_callback
    *       METHOD delayed_changed_sel_callback                           *
      method delayed_changed_sel_callback.
        perform d0100_event_changed_sel_callba.
      endmethod.                    "delayed_changed_sel_callback
    *       METHOD subtotal_text                                          *
      method subtotal_text.
        perform d0100_event_subtotal_text using es_subtottxt_info
                                                ep_subtot_line
                                                e_event_data.
      endmethod.                    "subtotal_text
    *       METHOD ondrag                                                 *
      method ondrag.
        perform d0100_event_ondrag using e_row
                                         e_column
                                         e_dragdropobj.
      endmethod.                    "ondrag
    *       METHOD ondrop                                                 *
      method ondrop.
        perform d0100_event_ondrop using e_row
                                         e_column
                                         e_dragdropobj.
      endmethod.                    "ondrop
    *       METHOD ondropcomplete                                         *
      method ondropcomplete.
        perform d0100_event_ondropcomplete using e_row
                                                 e_column
                                                 e_dragdropobj.
      endmethod.                    "ondropcomplete
    *       METHOD ondropgetflavor                                        *
      method ondropgetflavor.
        perform d0100_event_ondropgetflavor.
      endmethod.                    "ondropgetflavor
    *       METHOD data_changed                                           *
      method data_changed.
        perform d0100_event_data_changed using er_data_changed
                                               e_onf4
                                               e_onf4_before
                                               e_onf4_after.
      endmethod.                    "data_changed
    *       METHOD data_changed_finished                                  *
      method data_changed_finished.
        perform d0100_event_data_changed_finis.
      endmethod.                    "data_changed_finished
    *       METHOD button_click                                           *
      method button_click.
        perform d0100_event_button_click using es_col_id
                                               es_row_no.
      endmethod.                    "button_click
    *       METHOD onf1                                                   *
      method onf1.
        perform d0100_event_onf1 using e_fieldname
                                       es_row_no
                                       er_event_data.
      endmethod.                                                "onf1
    *       METHOD onf4                                                   *
      method onf4.
        perform d0100_event_onf4 using e_fieldname
                                       e_fieldvalue
                                       es_row_no
                                       er_event_data
                                       et_bad_cells
                                       e_display.
      endmethod.                                                "onf4
    endclass.                    "lcl_events_d0100 IMPLEMENTATION
    * SELECTION-SCREEN                                                     *
    selection-screen begin of block gen with frame.
      selection-screen begin of line.
      parameters:
        p_ext    radiobutton group db.
      selection-screen comment (29) for field p_ext.
      selection-screen comment (29) for field p_d_file.
      parameters:
        p_d_file   type char255.
      selection-screen end of line.
      selection-screen begin of line.
      parameters:
        p_db    radiobutton group db default 'X'.
      selection-screen comment (29) for field p_db.
      selection-screen comment (29) for field p_amount.
      parameters:
        p_amount type i default 30.
      selection-screen end of line.
    selection-screen end of block gen.
    selection-screen begin of block inf with frame.
    parameters:
    p_inf01 as checkbox default con_true,
    p_inf02 as checkbox.
    selection-screen end of block inf.
    selection-screen begin of block app with frame.
    parameters:
    p_appevt as checkbox.
    selection-screen end of block app.
    selection-screen begin of block evt with frame.
    parameters:
    p_evt01 as checkbox, "USER_COMMAND
    p_evt02 as checkbox, "BEFORE_USER_COMMAND
    p_evt03 as checkbox. "AFTER_USER_COMMAND
    selection-screen skip.
    parameters:
    p_evt04 as checkbox, "DOUBLE_CLICK
    p_evt05 as checkbox. "HOTSPOT_CLICK
    select-options:
    p_hotspt for g_field no intervals default 'CARRID'.
    parameters:
    p_evt06 as checkbox. "BUTTON_CLICK
    select-options:
    p_button for g_field no intervals default 'CARRID'.
    selection-screen skip.
    parameters:
    p_evt07 as checkbox.                                        "ONF1
    selection-screen begin of block of4 with frame.
    parameters:
    p_evt08 as checkbox.                                        "ONF4
    select-options:
    p_onf4 for g_field no intervals default 'CARRID'.
    selection-screen begin of line.
    selection-screen comment 5(30) text-c01 for field p_f401.
    parameters:
    p_f401 as checkbox default con_true. "REGISTER
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 5(30) text-c02 for field p_f402.
    parameters:
    p_f402 as checkbox. "GET_BEFORE
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 5(30) text-c03 for field p_f403.
    parameters:
    p_f403 as checkbox. "CHANGE_AFTER
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 5(30) text-c04 for field p_f404.
    parameters:
    p_f404 as checkbox. "INTERNAL_FORMAT
    selection-screen end of line.
    selection-screen end of block of4.
    selection-screen skip.
    parameters:
    p_evt09 as checkbox, "MENU_BUTTON
    p_evt10 as checkbox, "TOOLBAR
    p_evt11 as checkbox. "CONTEXT_MENU_REQUEST
    selection-screen skip.
    parameters:
    p_evt12 as checkbox, "ONDRAG
    p_evt13 as checkbox, "ONDROP
    p_evt14 as checkbox, "ONDROPCOMPLETE
    p_evt15 as checkbox. "ONDROPGETFLAVOR
    selection-screen skip.
    parameters:
    p_evt16 as checkbox. "SUBTOTAL_TEXT
    selection-screen skip.
    parameters:
    p_evt17 as checkbox, "DATA_CHANGED
    p_evt18 as checkbox, "DATA_CHANGED_FINISHED
    p_evt19 as checkbox. "AFTER_REFRESH
    selection-screen skip.
    parameters:
    p_evt20 as checkbox, "DELAYED_CALLBACK
    p_evt21 as checkbox. "DELAYED_CHANGED_SEL_CALLBACK
    selection-screen skip.
    parameters:
    p_evt22 as checkbox, "TOP_OF_PAGE
    p_evt23 as checkbox, "END_OF_LIST
    p_evt24 as checkbox, "PRINT_TOP_OF_PAGE
    p_evt25 as checkbox, "PRINT_END_OF_PAGE
    p_evt26 as checkbox, "PRINT_TOP_OF_LIST
    p_evt27 as checkbox. "PRINT_END_OF_LIST
    selection-screen end of block evt.
    * AT SELECTION-SCREEN ON VALUE-REQUEST                                 *
    at selection-screen on value-request for p_hotspt-low.
      perform d0100_f4_fcode changing p_hotspt-low.
    at selection-screen on value-request for p_button-low.
      perform d0100_f4_fcode changing p_button-low.
    at selection-screen on value-request for p_onf4-low.
      perform d0100_f4_fcode changing p_onf4-low.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_d_file.
      PERFORM f4_file.
    * START-OF-SELECTION                                                   *
    start-of-selection.
      gs_test-select_amount = p_amount.
      gs_test-no_info_popup   = p_inf01.
      gs_test-info_popup_once = p_inf02.
      gs_test-application_events = p_appevt.
      gs_test-event-user_command                 = p_evt01.
      gs_test-event-before_user_command          = p_evt02.
      gs_test-event-after_user_command           = p_evt03.
      gs_test-event-double_click                 = p_evt04.
      gs_test-event-hotspot_click                = p_evt05.
      gs_test-event-button_click                 = p_evt06.
      gs_test-event-onf1                         = p_evt07.
      gs_test-event-onf4                         = p_evt08.
      gs_test-event-menu_button                  = p_evt09.
      gs_test-event-toolbar                      = p_evt10.
      gs_test-event-context_menu_request         = p_evt11.
      gs_test-event-ondrag                       = p_evt12.
      gs_test-event-ondrop                       = p_evt13.
      gs_test-event-ondropcomplete               = p_evt14.
      gs_test-event-ondropgetflavor              = p_evt15.
      gs_test-event-subtotal_text                = p_evt16.
      gs_test-event-data_changed                 = p_evt17.
      gs_test-event-data_changed_finished        = p_evt18.
      gs_test-event-after_refresh                = p_evt19.
      gs_test-event-delayed_callback             = p_evt20.
      gs_test-event-delayed_changed_sel_callback = p_evt21.
      gs_test-event-top_of_page                  = p_evt22.
      gs_test-event-end_of_list                  = p_evt23.
      gs_test-event-print_top_of_page            = p_evt24.
      gs_test-event-print_end_of_page            = p_evt25.
      gs_test-event-print_top_of_list            = p_evt26.
      gs_test-event-print_end_of_list            = p_evt27.
      gs_test-onf4-register        = p_f401.
      gs_test-onf4-get_before      = p_f402.
      gs_test-onf4-change_after    = p_f403.
      gs_test-onf4-internal_format = p_f404.
      if p_evt05 ne space.
        loop at p_hotspt.
          if not p_hotspt-low is initial.
            append p_hotspt-low to gs_test-hotspot_fields.
          endif.
        endloop.
      endif.
      if p_evt06 ne space.
        loop at p_button.
          if not p_button-low is initial.
            append p_button-low to gs_test-button_fields.
          endif.
        endloop.
      endif.
      if p_evt08 ne space.
        loop at p_onf4.
          if not p_onf4-low is initial.
            append p_onf4-low to gs_test-onf4_fields.
          endif.
        endloop.
      endif.
      gs_test-bypassing_buffer = space.
      gs_test-buffer_active    = space.
    * END-OF-SELECTION                                                     *
    end-of-selection.
      call screen 100.
    *&      Module  d0100_set_status  OUTPUT
    *       text
    module d0100_set_status output.
      perform d0100_set_status.
    endmodule.                 " d0100_set_status  OUTPUT
    *&      Module  d0100_prepare_container  OUTPUT
    *       text
    module d0100_prepare_container output.
      perform d0100_prepare_container.
    endmodule.                 " d0100_prepare_container  OUTPUT
    *&      Module  d0100_exit  INPUT
    *       text
    module d0100_exit input.
      perform d0100_exit.
    endmodule.                 " d0100_exit  INPUT
    *&      Module  d0100_fcode  INPUT
    *       text
    module d0100_fcode input.
      perform d0100_fcode.
    endmodule.                 " d0100_fcode  INPUT
    *&      Form  d0100_set_status
    *       text
    form d0100_set_status .
      types: begin of l_ty_s_excl,
               func type syucomm,
             end   of l_ty_s_excl,
             l_ty_t_excl type standard table of l_ty_s_excl.
      data: lt_excl type l_ty_t_excl.
      set pf-status 'D0100' excluding lt_excl.
      set titlebar 'D0100'.
    endform.                    " d0100_set_status
    *&      Form  d0100_prepare_container
    *       text
    form d0100_prepare_container .
      data: lt_fcat             type lvc_t_fcat,
            ls_layo             type lvc_s_layo,
            ls_vari             type disvariant,
            ls_prnt             type lvc_s_prnt,
            l_consistency_check type char1.
      if gr_container_d0100 is initial.
        if cl_gui_alv_grid=>offline( ) is initial.
          create object gr_container_d0100
                        exporting container_name = 'D0100_CONTAINER'.
        endif.
        create object gr_grid_d0100
                      exporting i_parent      = gr_container_d0100
                                i_appl_events = gs_test-application_events.
        DATA: l_filename TYPE string,
              l_struct   TYPE string.
        CASE con_true.
          WHEN p_db.
            perform d0100_get_outtab.
          WHEN p_ext.
            l_struct = 'g_ty_t_outtab'.
            l_filename = p_d_file.
            CALL METHOD cl_salv_test_data=>select_data
              EXPORTING
                structname = l_struct
                SOURCE     = 2
                 filename   = l_filename
    *            AMOUNT     = 30
              CHANGING
                data       = gt_outtab[].
        ENDCASE.
        perform d0100_set_grid_vari     changing ls_vari.
        perform d0100_set_grid_layo     changing ls_layo.
        perform d0100_set_grid_fcat     changing lt_fcat.
        perform d0100_set_grid_onf4     changing lt_fcat.
        perform d0100_set_grid_buttons  changing lt_fcat.
        perform d0100_set_grid_hotspot  changing lt_fcat.
        perform d0100_set_grid_dragdrop changing ls_layo.
        perform d0100_set_grid_edit     changing ls_layo.
        perform d0100_set_grid_events.
        ls_prnt-grpchgedit = con_true.
        call method gr_grid_d0100->set_table_for_first_display
          exporting
            i_buffer_active     = gs_test-buffer_active
            i_bypassing_buffer  = gs_test-bypassing_buffer
            i_consistency_check = l_consistency_check
            is_variant          = ls_vari
            i_save              = 'A'
            i_default           = con_true
            is_layout           = ls_layo
            is_print            = ls_prnt
          changing
            it_outtab           = gt_outtab[]
            it_fieldcatalog     = lt_fcat.
      endif.
    endform.                    " d0100_prepare_container
    *&      Form  d0100_exit
    *       text
    form d0100_exit .
      data: l_okcode like sy-ucomm.
      l_okcode = g_okcode.
      clear g_okcode.
      case l_okcode.
        when con_exit or con_back or con_canc.
          call method gr_grid_d0100->free.
          call method gr_container_d0100->free.
          call method cl_gui_cfw=>flush.
          clear gr_container_d0100.
          clear gr_grid_d0100.
          clear gr_events_d0100.
          set screen 0.
          leave screen.
      endcase.
    endform.                    " d0100_exit
    *&      Form  d0100_fcode
    *       text
    form d0100_fcode .
      data: l_okcode like sy-ucomm.
      l_okcode = g_okcode.
      clear g_okcode.
      call method cl_gui_cfw=>dispatch.
      case l_okcode.
        when con_exit or con_back or con_canc.
          g_okcode = l_okcode.
          perform d0100_exit.
        when others.
      endcase.
    endform.                    " d0100_fcode
    *&      Form  d0100_set_grid_vari
    *       text
    form d0100_set_grid_vari changing cs_vari type disvariant.
      cs_vari-report      = sy-repid.
      cs_vari-handle      = space.
      cs_vari-log_group   = space.
      cs_vari-username    = space.
      cs_vari-variant     = space.
      cs_vari-text        = space.
      cs_vari-dependvars  = space.
    endform.                    " d0100_set_grid_vari
    *&      Form  d0100_set_grid_layo
    *       text
    form d0100_set_grid_layo  changing cs_layo type lvc_s_layo.
    *... ALV-Control: Allgemeine Anzeigeoptionen
      cs_layo-stylefname  = space.
      cs_layo-cwidth_opt  = con_true.
      cs_layo-zebra       = space.
      cs_layo-smalltitle  = space.
      cs_layo-graphics    = space.
      cs_layo-frontend    = space.
      cs_layo-template    = space.
    *... ALV-Control: Gridcustomizing
      cs_layo-no_colexpd  = space.
      cs_layo-no_hgridln  = space.
      cs_layo-no_vgridln  = space.
      cs_layo-no_rowmark  = space.
      cs_layo-no_headers  = space.
      cs_layo-no_merging  = space.
      cs_layo-grid_title  = space.
      cs_layo-no_toolbar  = space.
      cs_layo-sel_mode    = 'D'.
      cs_layo-box_fname   = space.
      cs_layo-sgl_clk_hd  = space.
    *... ALV-Control: Summenoptionen
      cs_layo-totals_bef  = space.
      cs_layo-no_totline  = space.
      cs_layo-numc_total  = space.
      cs_layo-no_utsplit  = space.
    *... ALV-Control: Exceptions
      cs_layo-excp_fname  = 'LIGHTS'.
      cs_layo-excp_rolln  = space.
      cs_layo-excp_conds  = space.
      cs_layo-excp_led    = space.
    *... ALV-Control: Steuerung Interaktion
      cs_layo-detailinit  = space.
      cs_layo-detailtitl  = space.
      cs_layo-keyhot      = space.
      cs_layo-no_keyfix   = space.
      cs_layo-no_author   = space.
      clear cs_layo-s_dragdrop.
    *... ALV-Control: Farben
      cs_layo-info_fname  = space.
      cs_layo-ctab_fname  = space.
    *... ALV-Control: Eingabefähigkeit
      cs_layo-edit        = space.
      cs_layo-edit_mode   = space.
      cs_layo-no_rowins   = space.
      cs_layo-no_rowmove  = space.
    *... ALV-Control: Web-Optionen
      cs_layo-weblook     = space.
      cs_layo-webstyle    = space.
      cs_layo-webrows     = space.
      cs_layo-webxwidth   = space.
      cs_layo-webxheight  = space.
    endform.                    " d0100_set_grid_layo
    *&      Form  d0100_set_grid_fcat
    *       text
    form d0100_set_grid_fcat changing ct_fcat type lvc_t_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_buffer_active        = gs_test-buffer_active
          i_structure_name       = con_sflight
          i_client_never_display = con_true
          i_bypassing_buffer     = gs_test-bypassing_buffer
        changing
          ct_fieldcat            = ct_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.
    endform.                    " d0100_set_grid_fcat
    *&      Form  d0100_set_grid_onf4
    *       text
    form d0100_set_grid_onf4 changing ct_fcat type lvc_t_fcat.
      field-symbols: <ls_fcat> type lvc_s_fcat.
      data: l_field type lvc_fname,
            lt_f4   type lvc_t_f4,
            ls_f4   type lvc_s_f4.
      if gs_test-event-onf4 eq con_true.
        loop at gs_test-onf4_fields into l_field.
          read table ct_fcat assigning <ls_fcat>
                     with key fieldname = l_field.
          if sy-subrc eq 0.
            <ls_fcat>-f4availabl = con_true.
          endif.
          ls_f4-fieldname  = l_field.
          ls_f4-register   = gs_test-onf4-register.
          ls_f4-getbefore  = gs_test-onf4-get_before.
          ls_f4-chngeafter = gs_test-onf4-change_after.
          ls_f4-internal   = gs_test-onf4-internal_format.
          insert ls_f4 into table lt_f4.
        endloop.
      endif.
      check not lt_f4 is initial.
      call method gr_grid_d0100->register_f4_for_fields
        exporting
          it_f4 = lt_f4.
    endform.                    " d0100_set_grid_onf4
    *&      Form  d0100_set_grid_buttons
    *       text
    form d0100_set_grid_buttons changing ct_fcat type lvc_t_fcat.
      field-symbols: <ls_fcat> type lvc_s_fcat.
      data: l_field type lvc_fname.
      loop at gs_test-button_fields into l_field.
    *... Spaltenebene
    *    In Feldkatalog wird Feld STYLE für Spalte auf
    *    cl_gui_alv_grid=>mc_style_button gesetzt
        read table ct_fcat assigning <ls_fcat>
                   with key fieldname = l_field.
        if sy-subrc eq 0.
          <ls_fcat>-style = cl_gui_alv_grid=>mc_style_button.
        endif.
      endloop.
    endform.                    " d0100_set_grid_buttons
    *&      Form  d0100_set_grid_hotspot
    *       text
    form d0100_set_grid_hotspot changing ct_fcat type lvc_t_fcat.
      field-symbols: <ls_fcat> type lvc_s_fcat.
      data: l_field type lvc_fname.
      loop at gs_test-hotspot_fields into l_field.
    *... Spaltenebene
    *    In Feldkatalog wird Feld STYLE für Spalte auf
    *    cl_gui_alv_grid=>mc_style_hotspot gesetzt
        read table ct_fcat assigning <ls_fcat>
                   with key fieldname = l_field.
        if sy-subrc eq 0.
          <ls_fcat>-style = cl_gui_alv_grid=>mc_style_hotspot.
        endif.
      endloop.
    endform.                    " d0100_set_grid_hotspot
    *&      Form  d0100_set_grid_edit
    *       text
    form d0100_set_grid_edit changing cs_layo type lvc_s_layo.
      if gs_test-event-data_changed eq con_true or
         gs_test-event-data_changed_finished eq con_true or
         gs_test-event-after_refresh eq con_true.
        cs_layo-edit = con_true.
        call method gr_grid_d0100->register_edit_event
          exporting
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
      endif.
    endform.                    " d0100_set_grid_edit
    *&      Form  d0100_set_grid_dragdrop
    *       text
    form d0100_set_grid_dragdrop changing cs_layo type lvc_s_layo.
      data: l_effect       type i,
            l_handle_grid  type i,
            ls_dragdrop    type lvc_s_dd01.
    *... setzen für Zeilen
      create object gr_grid_dragdrop.
      l_effect = cl_dragdrop=>move + cl_dragdrop=>copy.
      call method gr_grid_dragdrop->add
        exporting
          flavor     = 'Line'                                   "#EC NOTEXT
          dragsrc    = 'X'
          droptarget = 'X'
          effect     = l_effect.
      call method gr_grid_dragdrop->get_handle
        importing
          handle = l_handle_grid.
      ls_dragdrop-cntr_ddid = space.
      ls_dragdrop-grid_ddid = space.
      ls_dragdrop-col_ddid  = space.
      ls_dragdrop-row_ddid  = l_handle_grid.
      ls_dragdrop-fieldname = space.
      cs_layo-s_dragdrop = ls_dragdrop.
    endform.                    " d0100_set_grid_dragdrop
    *&      Form  d0100_set_grid_events
    *       text
    form d0100_set_grid_events .
      create object gr_events_d0100.
      if gs_test-event-user_command eq con_true.
        set handler gr_events_d0100->user_command
                    for gr_grid_d0100.
      endif.
      if gs_test-event-before_user_command eq con_true.
        set handler gr_events_d0100->before_user_command
                    for gr_grid_d0100.
      endif.
      if gs_test-event-after_user_command eq con_true.
        set handler gr_events_d0100->after_user_command
                    for gr_grid_d0100.
      endif.
      if gs_test-event-double_click eq con_true.
        set handler gr_events_d0100->double_click
                    for gr_grid_d0100.
      endif.
      if gs_test-event-hotspot_click eq con_true.
        set handler gr_events_d0100->hotspot_click
                    for gr_grid_d0100.
      endif.
      if gs_test-event-button_click eq con_true.
        set handler gr_events_d0100->button_click
                    for gr_grid_d0100.
      endif.
      if gs_test-event-onf1 eq con_true.
        set handler gr_events_d0100->onf1
                    for gr_grid_d0100.
      endif.
      if gs_test-event-onf4 eq con_true.
        set handler gr_events_d0100->onf4
                    for gr_grid_d0100.
      endif.
      if gs_test-event-menu_button eq con_true.
        set handler gr_events_d0100->menu_button
                    for gr_grid_d0100.
      endif.
      if gs_test-event-toolbar eq con_true.
        set handler gr_events_d0100->toolbar
                    for gr_grid_d0100.
      endif.
      if gs_test-event-context_menu_request eq con_true.
        set handler gr_events_d0100->context_menu_request
                    for gr_grid_d0100.
      endif.
      if gs_test-event-ondrag eq con_true.
        set handler gr_events_d0100->ondrag
                    for gr_grid_d0100.
      endif.
      if gs_test-event-ondrop eq con_true.
        set handler gr_events_d0100->ondrop
                    for gr_grid_d0100.
      endif.
      if gs_test-event-ondropcomplete eq con_true.
        set handler gr_events_d0100->ondropcomplete
                    for gr_grid_d0100.
      endif.
      if gs_test-event-ondropgetflavor eq con_true.
        set handler gr_events_d0100->ondropgetflavor
                    for gr_grid_d0100.
      endif.
      if gs_test-event-subtotal_text eq con_true.
        set handler gr_events_d0100->subtotal_text
                    for gr_grid_d0100.
      endif.
      if gs_test-event-data_changed eq con_true.
        set handler gr_events_d0100->data_changed
                    for gr_grid_d0100.
      endif.
      if gs_test-event-data_changed_finished eq con_true.
        set handler gr_events_d0100->data_changed_finished
                    for gr_grid_d0100.
      endif.
      if gs_test-event-after_refresh eq con_true.
        set handler gr_events_d0100->after_refresh
                    for gr_grid_d0100.
      endif.
      if gs_test-event-delayed_callback eq con_true.
        set handler gr_events_d0100->delayed_callback
                    for gr_grid_d0100.
        call method gr_grid_d0100->register_delayed_event
          exporting
            i_event_id = cl_gui_alv_grid=>mc_evt_delayed_move_curr_cell.
      endif.
      if gs_test-event-delayed_changed_sel_callback eq con_true.
        set handler gr_events_d0100->delayed_changed_sel_callback
                    for gr_grid_d0100.
        call method gr_grid_d0100->register_delayed_event
          exporting
            i_event_id = cl_gui_alv_grid=>mc_evt_delayed_change_select.
      endif.
      if gs_test-event-top_of_page eq con_true.
        set handler gr_events_d0100->top_of_page
                    for gr_grid_d0100.
      endif.
      if gs_test-event-end_of_list eq con_true.
        set handler gr_events_d0100->end_of_list
                    for gr_grid_d0100.
      endif.
      if gs_test-event-print_top_of_page eq con_true.
        set handler gr_events_d0100->print_top_of_page
                    for gr_grid_d0100.
      endif.
      if gs_test-event-print_end_of_page eq con_true.
        set handler gr_events_d0100->print_end_of_page
                    for gr_grid_d0100.
      endif.
      if gs_test-event-print_top_of_list eq con_true.
        set handler gr_events_d0100->print_top_of_list
                    for gr_grid_d0100.
      endif.
      if gs_test-event-print_end_of_list eq con_true.
        set handler gr_events_d0100->print_end_of_list
                    for gr_grid_d0100.
      endif.
    endform.                    " d0100_set_grid_events
    *&      Form  d0100_get_outtab
    *       text
    form d0100_get_outtab .
      field-symbols: <ls_outtab> type g_ty_s_outtab.
      data: l_excp_mod      type i,
            l_excp_div      type i,
            l_excp_amnt     type i value 4,
            l_excp          type i,
            lt_carrid       type g_ty_t_carrid,
            ls_carrid       type g_ty_s_carrid,
            l_carrid_amount type i,
            l_carrid_select type i,
            l_carrid_index1 type i,
            lt_connid       type g_ty_t_connid,
            ls_connid       type g_ty_s_connid,
            l_connid_amount type i,                             "#EC NEEDED
            l_connid_select type i,
            l_connid_index1 type i,
            l_connid_index2 type i,
            lt_plane        type g_ty_t_plane,
            ls_plane        type g_ty_s_plane.
      if gs_test-select_amount gt 0.
        select * from (con_sflight) into corresponding fields
                   of table gt_outtab up to gs_test-select_amount rows.
      endif.
      gs_test-select_amount = sy-dbcnt.
      perform d0100_get_carrid changing lt_carrid.
      perform d0100_get_connid changing lt_connid.
      perform d0100_get_plane  using lt_connid changing lt_plane.
      describe table lt_carrid lines l_carri

  • ALV grid, prevent return to line 1 column 1 after using filter button

    How can I prevent the ALV grid display from returning to line 1, column 1, after a user has modified the display using the filter or sort button ?  I know this is possible using the is_stable field when control is passed to my ALV code, but when the automatic on-screen buttons are used I can't find a way of controlling how the screen is displayed.

    Max,
    Thanks, the AFTER_USER_COMMAND event allows me access after the filter or sort button has bee npressed, but I am unable to prevent the grid from reverting to column1 line1.  By using the method GET_CURRENT_CELL I can find out the column, but it does not return me the row.   I have tried putting this column id into  SET_CURRENT_CELL_VIA_ID, as suggested by Naimesh above, and calling this from the AFTER_USER_COMMAND method, but it does not effect how the grid displays.    
    Any further advice would be very welcome.

  • Restrict ALV filter criteria like with MF SELECT_OPTIONS_RESTRICT

    Hi all,
    I would like to be able to manage my ALV OO filters.
    The aim is to force the user to use the pattern option (CP) when they want to filter on a specific field of the ALV.
    It would be great if there was a mean to get the same result as the MF SELECT_OPTIONS_RESTRICT for Select-option. ( = Only Pattern is available when the user tries to filter on this specific field)
    I'm able to user get_criteria/set_criteria to do so, but the result is not as OK as I want, because the filter are modified after the user action => the user wont understand what happened...
    Does anyone know about how to get the result I want?
    Thanks and regards,
    Christophe Drancourt

    Hi Christophe,
    for manage Filter after User Input you can use Event AFTER_USER_COMMAND:
    methods EVENT_AFTER_USER_COMMAND
         for event AFTER_USER_COMMAND of CL_GUI_ALV_GRID
         importing
           !E_UCOMM
           !SENDER .
    In method:
    METHOD EVENT_AFTER_USER_COMMAND.
    DATA ltb_filter TYPE LVC_T_FILT
       CASE e_ucomm.
         WHEN cl_gui_alv_grid=>mc_mb_filter.
               CALL METHOD sender->get_filter_criteria IMPORTING et_filter = ltb_filter.
    *Here Manage the Filter
               CALL METHOD sender->set_filter_criteria EXPORTING it_filter = ltb_filter.
               CALL METHOD sender->refresh_table_display.
           ENDCASE.
       ENDCASE.
    ENDMETHOD.
    Regards,
    Angelo.

  • What are main events in that are used in ALV reports

    hi gurus
    what are main events in that are used in ALV reports....
    regards
    baskar

    hi
    i think this will help u.
    Events in alv and their FM    The main events in alv and their FM and why we use these: 
    1. SLIS_PRINT_ALV. 
    2. SLIS_T_LISTHEADER. 
    3. SLIS_T_EVENT. 
    4. SLIS_T_SORTINFO_ALV. 
    5. SLIS_T_LAYOUT_ALV. 
    6. SLIS_T_FIELDCAT_ALV. 
    and in classic reports what is the sequence of events:   === Events are 
    At selection-screen output. 
    Initialization. 
    At selection-screen on field 
    At selection-screen on end of field 
    At selection-screen on Radiobutton Group R1. (If you have any radio buttons) 
    At selection-screen on block b1. (If you have any blocks) 
    Start-of-selection. 
    Get node. (if the data is retreived from a logical database) 
    Get node late. (if the data is retreived from a logical database) 
    Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement) 
    end-of-selection. 
    and fuction modules are 
    LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information.   EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation.   These events are captured by this FM.   LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style.   FIELDCAT - These are used to populate the List header. We can change them according to our req. 
    User-defined Text Output Event
        Application
          print_end_of_list
        Define output text to be printed at the end of the entire list
          print_top_of_list
        Define output text to be printed at the beginning of the entire list
          print_end_of_page
        Define output text to be printed at the end of each page
          print_top_of_page
        Define output text to be printed at the beginning of each page
          subtotal_text
        Define self-defined subtotals texts
    Mouse-controlled Actions in the Grid Control Event
        Application
          button_click
        Query a click on a pushbutton in the ALV Grid Control
          double_click
        Query a double-click on a cell of the ALV Grid control 
          hotspot_click
        Query a hotspot click on columns defined for this purpose in advance
          onDrag
        Collect information when elements of the ALV Grid Control are dragged 
          onDrop
        Process information when elements of the ALV Grid Control are dropped 
          onDropComplete
        Perform final actions after successful Drag&Drop 
          onDropGetFlavor
        Distinguish between options for Drag&Drop behavior
    Processing of Self-defined and Standard Functions Event
        Application
          before_user_command
        Query self-defined and standard function codes
          user_command
        Query self-defined function codes
          after_user_command
        Query self-defined and standard function codes
    Definition of Self-defined Functions Event
        Application
          toolbar
        Change, delete or add GUI elements in the toolbar
          menu_button
        Define menus for menu buttons in the toolbar
          context_menu_request
        Change context menu
          onf1
        Define self-defined F1 help
    All of these can be found under type group SLIS.
    Events
    SLIS_EV_ITEM_DATA_EXPAND        TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',
    SLIS_EV_REPREP_SEL_MODIFY       TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',
    SLIS_EV_USER_COMMAND              TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
    SLIS_EV_TOP_OF_PAGE                     TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
    SLIS_EV_DATA_CHANGED                TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',
    SLIS_EV_TOP_OF_COVERPAGE       TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',
    SLIS_EV_END_OF_COVERPAGE       TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',
    SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME
    VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME
    VALUE 'FOREIGN_END_OF_PAGE',
    SLIS_EV_PF_STATUS_SET                  TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
    SLIS_EV_LIST_MODIFY                      TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',
    SLIS_EV_TOP_OF_LIST                       TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
    SLIS_EV_END_OF_PAGE                    TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
    SLIS_EV_END_OF_LIST                      TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
    SLIS_EV_AFTER_LINE_OUTPUT       TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT     TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',
    SLIS_EV_SUBTOTAL_TEXT                TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.
    with regards
    sravani
    award points if found useful.

  • ALV events

    what are the different events in ABAP ALV.... I tried to use the regular top-of-page and end-of-page as in regular ABAP program..
    As I am new to ALV's it will be helpful if u can cite me with examples

    Rahul,
    There are quite a few events, which also depend upon whehter we dealing with editable grid or a display grid. These are the events you can find the SE24 - CL_GUI_ALV_GRID.
    ONF1
    ONF4
    DATA_CHANGED
    ONDROPGETFLAVOR
    ONDRAG
    ONDROP
    ONDROPCOMPLETE
    SUBTOTAL_TEXT
    BEFORE_USER_COMMAND
    USER_COMMAND
    AFTER_USER_COMMAND
    DOUBLE_CLICK
    DELAYED_CALLBACK
    DELAYED_CHANGED_SEL_CALLBACK
    PRINT_TOP_OF_PAGE
    PRINT_TOP_OF_LIST
    PRINT_END_OF_PAGE
    PRINT_END_OF_LIST
    TOP_OF_PAGE
    CONTEXT_MENU_REQUEST
    MENU_BUTTON
    TOOLBAR
    HOTSPOT_CLICK
    END_OF_LIST
    AFTER_REFRESH
    BUTTON_CLICK
    DATA_CHANGED_FINISHED
    Here are the sample programs for the events
    BCALV_GRID_EDIT_DELTA_EVENT
    BCALV_SIMPLE_EVENT_RECEIVER
    BCALV_TEST_FULLSCREEN_EVENTS
    BCALV_TEST_GRID_EVENTS
    BCALV_TEST_HIERSEQ_LIST_EVENTS
    BCALV_TEST_LIST_EVENTS
    BCALV_TOOLBAR_EVENT_RECEIVER
    BCALV_TREE_EVENT_RECEIVER
    The following are the examples for EDITABLE ALV's.
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_03
    BCALV_EDIT_04
    BCALV_EDIT_05
    BCALV_EDIT_06
    BCALV_EDIT_07
    BCALV_EDIT_08
    Regards,ff
    Ravi
    Note : Please mark the helpful answers

  • ALV: Refreshing Header Info

    Hello Guru's,
    i've got a Report which lists some Employes. The Data is displayed in an ALV. The Header of this ALV displays the Count of Employes displayed.
    My Problem: Is there any posibility to refresh the Employee Count in the Header when maybe a Filter on the ALV is set and the displayed Count of Employes changed?
    Regards

    Try implementing the AFTER_USER_COMMAND event of CL_GUI_ALV_GRID class.
    In its implementation checked if the filter was selected, determine the number of the rows filtered.
    There is method get_filtered_entries in class cl_gui_alv_grid which returns a table of all entries hidden by the filter. This will help you in determining the number of records hidden by the filter and so you can calculate the number of records shown as a result of filter.
    Hope this helps.
    Reward points if helpful.
    Thanks,
    Balaji
    Edited by: Balaji Ganapathiraman on Feb 20, 2008 12:57 PM

  • ALV Tree with editable checkbox

    Hi all,
    I have a ALV Tree with editable checkbox (for all the parent & leaf  nodes) , as one of the column.On clicking of a button in toolbar , i should get the nodes which are checked in checkbox.
    But the problem is i am not able to get the nodes which are checked through checkbox in the PAI of the screen,when the button is clicked.
    I tried using    
    CALL METHOD wf_tree->get_checked_items             
                           IMPORTING
                           et_checked_items = lint_selected_node.
    but the return table is not containing any entries , even if check boxes are checked in ALV tree.I tried the GET_CHECKED_ITEMS method in event handler method of AFTER_USER_COMMAND and also CHECKBOX_CHANGE , but no success.
    lfs_item_layout-fieldname = 'CHECK'.
      lfs_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
      lfs_item_layout-editable = 'X'.
      lfs_item_layout-CHOSEN = 'X'.
      APPEND lfs_item_layout TO lint_item_layout.
    CALL METHOD wf_tree->add_node
        EXPORTING
          i_relat_node_key = p_lfs_final_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = p_gfs_final
          is_node_layout   = lfs_node
          it_item_layout   = lint_item_layout
        IMPORTING
          e_new_node_key   = p_loc_qmnum_key.
    Friends ,if you can suggest something.
    Thanks
    Abhijeet

    hi ,
    i have written below code for registering the CHECKBOX_CHANGE event of CL_GUI_ALV_TREE.
    APPEND lfs_event TO lint_events.
        lfs_event-eventid = cl_gui_column_tree=>eventid_CHECKBOX_CHANGE.
      APPEND lfs_event TO lint_events.
      CALL METHOD wf_tree->set_registered_events
        EXPORTING
          events                    = lint_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc EQ 0.
    *    MESSAGE X208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
          SET HANDLER lo_event_receiver->handle_checkbox_change FOR wf_tree.
    *      SET HANDLER lo_event_receiver->handle_button_click FOR wf_tree.
        ENDIF.
    Also according to below code , i have put a break point in the event handler method of CHECKBOX_CHANGE event , so that control shall come here when check box is checked on ALV tree ...
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *      handle_checkbox_change FOR EVENT checkbox_change OF cl_gui_alv_tree,
    *              importing fcode.
    *      handle_button_click FOR EVENT AFTER_USER_COMMAND OF cl_gui_alv_tree
    *        IMPORTING ucomm,
          handle_CHECKBOX_CHANGE for event checkbox_change of cl_gui_alv_tree
            importing CHECKED
                      FIELDNAME
                      NODE_KEY.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *       CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_checkbox_change.
        data : lint_selected_node TYPE LVC_T_CHIT.
        BREAK abhijeetg.
    *   CHECKED
    *   FIELDNAME
    *   NODE_KEY
    *    case fcode.
    *      when 'SELALL'.
    *        perform select_all.
    *    CALL METHOD WF_TREE->GET_OUTTAB_LINE
    *      EXPORTING
    *        I_NODE_KEY     =
    **      IMPORTING
    **        e_outtab_line  =
    **        e_node_text    =
    **        et_item_layout =
    **        es_node_layout =
    **      EXCEPTIONS
    **        node_not_found = 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 method cl_gui_cfw=>dispatch.
        CALL METHOD wf_tree->get_checked_items
          IMPORTING
            et_checked_items = lint_selected_node.
        break abhijeetg.
      ENDMETHOD.         
    ENDCLASS.
    So according to you , I should get the control in the break point , but its not happening with this .. any thing missing ???
    Edited by: abhijeet_7013 on Jun 21, 2011 10:31 PM

  • *which event trigger by event wise in classical, interactive, alv reports*

    Hi Experts,
    can any body tell about
    event wise trigger in
    Q(1). classical reports.
            ( from initial)
    Q(2). Interactive reports.
         (from initial)
    Q(3). ALV List and Grid
         (from initial)
    points will be rewarded.
    Thanks,
    Balakrishna.

    Hi,
    Events in alv and their FM    The main events in alv and their FM and why we use these: 
    1. SLIS_PRINT_ALV. 
    2. SLIS_T_LISTHEADER. 
    3. SLIS_T_EVENT. 
    4. SLIS_T_SORTINFO_ALV. 
    5. SLIS_T_LAYOUT_ALV. 
    6. SLIS_T_FIELDCAT_ALV. 
    and in classic reports what is the sequence of events:   === Events are 
    At selection-screen output. 
    Initialization. 
    At selection-screen on field 
    At selection-screen on end of field 
    At selection-screen on Radiobutton Group R1. (If you have any radio buttons) 
    At selection-screen on block b1. (If you have any blocks) 
    Start-of-selection. 
    Get node. (if the data is retreived from a logical database) 
    Get node late. (if the data is retreived from a logical database) 
    Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement) 
    end-of-selection. 
    and fuction modules are 
    LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information.   EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation.   These events are captured by this FM.   LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style.   FIELDCAT - These are used to populate the List header. We can change them according to our req. 
    User-defined Text Output Event
        Application
          print_end_of_list
        Define output text to be printed at the end of the entire list
          print_top_of_list
        Define output text to be printed at the beginning of the entire list
          print_end_of_page
        Define output text to be printed at the end of each page
          print_top_of_page
        Define output text to be printed at the beginning of each page
          subtotal_text
        Define self-defined subtotals texts
    Mouse-controlled Actions in the Grid Control Event
        Application
          button_click
        Query a click on a pushbutton in the ALV Grid Control
          double_click
        Query a double-click on a cell of the ALV Grid control 
          hotspot_click
        Query a hotspot click on columns defined for this purpose in advance
          onDrag
        Collect information when elements of the ALV Grid Control are dragged 
          onDrop
        Process information when elements of the ALV Grid Control are dropped 
          onDropComplete
        Perform final actions after successful Drag&Drop 
          onDropGetFlavor
        Distinguish between options for Drag&Drop behavior
    Processing of Self-defined and Standard Functions Event
        Application
          before_user_command
        Query self-defined and standard function codes
          user_command
        Query self-defined function codes
          after_user_command
        Query self-defined and standard function codes
    Definition of Self-defined Functions Event
        Application
          toolbar
        Change, delete or add GUI elements in the toolbar
          menu_button
        Define menus for menu buttons in the toolbar
          context_menu_request
        Change context menu
          onf1
        Define self-defined F1 help
    All of these can be found under type group SLIS.
    Events
    SLIS_EV_ITEM_DATA_EXPAND        TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',
    SLIS_EV_REPREP_SEL_MODIFY       TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',
    SLIS_EV_USER_COMMAND              TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
    SLIS_EV_TOP_OF_PAGE                     TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
    SLIS_EV_DATA_CHANGED                TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',
    SLIS_EV_TOP_OF_COVERPAGE       TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',
    SLIS_EV_END_OF_COVERPAGE       TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',
    SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME
    VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME
    VALUE 'FOREIGN_END_OF_PAGE',
    SLIS_EV_PF_STATUS_SET                  TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
    SLIS_EV_LIST_MODIFY                      TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',
    SLIS_EV_TOP_OF_LIST                       TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
    SLIS_EV_END_OF_PAGE                    TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
    SLIS_EV_END_OF_LIST                      TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
    SLIS_EV_AFTER_LINE_OUTPUT       TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT     TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',
    SLIS_EV_SUBTOTAL_TEXT                TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.
    Reward pts if usefull.
    Regards,
    Dhan

  • How to Edit ALV

    Hi all,
    I have created an ALV Grid display using container.
    My question is : How to edit an AlV.
    Initially some of column are in Display Mode, That i had set as non editable.
    But i want that when i create new/insert new record using the Insert button of alv , the only new column should apper as editable (all columns) as it is new record. So i can insert it into batabase.
    Any one an help me with this .
    Thanks
    Amar

    Hi Amar,
    I have added one Sample program pls check it and Let me know
    INCLUDE .
    TABLES: lfa1, lfb1, ekko, ekpo.
    TYPE-POOLS: slis.
    DATA: ok_code LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CONTAINER',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    DATA: repname LIKE sy-repid.
    DATA: t_disvariant TYPE TABLE OF disvariant WITH HEADER LINE.
    DATA: t_fieldtab TYPE lvc_t_fcat.
    DATA: t_layout TYPE lvc_s_layo.
    DATA: gs_toolbar  TYPE stb_button.
    DATA: t_rows TYPE lvc_t_row WITH HEADER LINE.
          TABLA DE DATOS
    DATA: BEGIN OF ti_acred OCCURS 0,
               bukrs LIKE lfb1-bukrs,
               lifnr LIKE lfa1-lifnr,
               land1 LIKE lfa1-land1,
               name1 LIKE lfa1-name1,
               ort01 LIKE lfa1-ort01,
               pstlz LIKE lfa1-pstlz,
               regio LIKE lfa1-regio,
               sortl LIKE lfa1-sortl,
               stras LIKE lfa1-stras,
               adrnr LIKE lfa1-adrnr,
       END OF ti_acred.
    DATA i_salida LIKE ti_acred OCCURS 0.
    DATA: d_bukrs LIKE t001-bukrs.
    DATA  container.
    DATA save VALUE 'X'.
                  Pantalla de Selección                 -
    SELECTION-SCREEN BEGIN OF BLOCK bloq1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : lifnr FOR lfa1-lifnr,
                     bukrs FOR lfb1-bukrs.
    SELECTION-SCREEN END OF BLOCK bloq1.
    SELECTION-SCREEN BEGIN OF BLOCK bloq3 WITH FRAME TITLE text-003.
    PARAMETERS: p_alvasg TYPE slis_vari.  " Disposición ALV
    SELECTION-SCREEN END   OF BLOCK bloq3.
    LOCAL CLASSES: Definition
    *===============================================================
    class lcl_event_receiver: local class to
                            define and handle own functions.
    Definition:
    ~~~~~~~~~~~
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
        handle_menu_button
            FOR EVENT menu_button OF cl_gui_alv_grid
                IMPORTING e_object e_ucomm,
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.
    lcl_event_receiver (Definition)
    *===============================================================
    LOCAL CLASSES: Implementation
    *===============================================================
    class lcl_event_receiver (Implementation)
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
    § 2.At event TOOLBAR define a toolbar element of type 1 by using
        event paramenter E_OBJECT. Remember its function code.
    Part I: Define a menu button including a function code that
            is evaluated in 'handle_MENU_BUTTON
    append a menu with default button (Type 1)
    The function code of the default button is the same as
    the one for the menu.
    If the user klicks on the default button ALV raises
    directly event BEFORE_USER_COMMAND
    (then USER_COMMAND, AFTER_USER_COMMAND).
    If the user klicks on the menu button ALV raises event MENU_BUTTON.
        CLEAR gs_toolbar.
        MOVE 'MODIFY' TO gs_toolbar-function.
    --&gt; This function code is evaluated in 'handle_menu_button'
        MOVE icon_change TO gs_toolbar-icon.
        MOVE 'Modificar' TO gs_toolbar-quickinfo.
        MOVE 0 TO gs_toolbar-butn_type.
        MOVE space TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object-&gt;mt_toolbar.
      ENDMETHOD.
      METHOD handle_menu_button.
    § 3.At event MENU_BUTTON query your function code and define a
        menu in the same way as a context menu.
    Part II: Evaluate 'e_ucomm' to see which menu button of the toolbar
             has been clicked on.
             Define then the corresponding menu.
             The menu contains function codes that are evaluated
             in 'handle_user_command'.
    query e_ucomm to find out which menu button has been clicked on
        IF e_ucomm = 'MODIFY'.
          CALL METHOD e_object-&gt;add_function
                      EXPORTING fcode   = 'MODIFY'
                                text    = 'Modificar'. "modificar
    § 3a.) choose a default function and define the same function code
            as used for the menu.
         CALL METHOD e_object-&gt;add_function
                     EXPORTING fcode   = 'DECISION'
                               text    = 'Decisión de empleo'. "Decisión
                                                               "de empleo
        ENDIF.
      ENDMETHOD.
      METHOD handle_user_command.
    § 4.At event USER_COMMAND query the function code of each function
        defined in step 3.
    Part III : Evaluate user command to invoke the corresponding
                      function.
        DATA: lt_rows TYPE lvc_t_row.
    get selected row
        CALL METHOD grid1-&gt;get_selected_rows
                 IMPORTING et_index_rows = lt_rows.
        CALL METHOD cl_gui_cfw=&gt;flush.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
               EXPORTING
                    titel = repname
                    txt2  = sy-subrc
                    txt1  = 'Error in Flush'(500).
        ENDIF.
    go to other table
        CASE e_ucomm.
         WHEN 'DECISION'.
           REFRESH T_ROWS.
           PERFORM SELECCION_LINEAS_DECISION TABLES lt_rows.
          WHEN 'MODIFY'.
            REFRESH t_rows.
           PERFORM SELECCION_LINEAS_modify TABLES lt_rows.
           CALL SCREEN 200.
        ENDCASE.
      ENDMETHOD.                           "handle_user_command
    ENDCLASS.
    lcl_event_receiver (Implementation)
    *===================================================================
                   INITIALIZATION                      -
    INITIALIZATION.
      repname = sy-repid.
      PERFORM initialize_fieldcat.
      PERFORM initializa_layout.
       AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alv     -
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvasg.
      PERFORM alvl_value_request USING p_alvasg '  '.
                 START-OF-SELECTION                     -
    START-OF-SELECTION.
      PERFORM obtener_datos.
                 END-OF-SELECTION                        -
    END-OF-SELECTION.
      CALL SCREEN 9010.
                   Subrutinas                            -
         Form  obtener_datos
    FORM obtener_datos.
      REFRESH ti_acred.
      CLEAR ti_acred.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE ti_acred
               FROM lfa1
               WHERE lifnr IN lifnr.
      LOOP AT ti_acred.
        SELECT SINGLE bukrs INTO ti_acred-bukrs FROM lfb1
               WHERE lifnr = ti_acred-lifnr.
        MODIFY ti_acred.
      ENDLOOP.
      i_salida[] = ti_acred[].
    ENDFORM.
          MODULE PBO OUTPUT                                             *
    MODULE status_9010 OUTPUT.
      DATA it_toolbar_excluding TYPE ui_func.
      SET PF-STATUS 'EMPRESA'.
    CLEAR g_custom_container.
      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.
        CALL METHOD grid1-&gt;set_table_for_first_display
             EXPORTING i_structure_name = 'I_SALIDA'
                       is_variant       = t_disvariant
                       i_save           = save
                      I_DEFAULT        = ' '
                       is_layout        = t_layout
             CHANGING  it_outtab        = i_salida
                       it_fieldcatalog  = t_fieldtab.
        SET HANDLER lcl_event_receiver=&gt;handle_user_command
                    lcl_event_receiver=&gt;handle_menu_button
                    lcl_event_receiver=&gt;handle_toolbar FOR ALL INSTANCES.
        CALL METHOD grid1-&gt;set_toolbar_interactive.
      ELSE.
        CALL METHOD grid1-&gt;refresh_table_display.
      ENDIF.
    ENDMODULE.
         Module  EXIT  INPUT
    MODULE exit INPUT.
    REFRESH i_salida.
    CLEAR i_salida.
      SET SCREEN 0.
      LEAVE SCREEN.
    ENDMODULE.                 " EXIT  INPUT
         Form  initialize_fieldcat
    FORM initialize_fieldcat.
      DATA: l_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
      REFRESH t_fieldtab.
    Catálogo de Campos
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'BUKRS'.
      l_fieldcat-ref_table   = 'LFB1'.
      l_fieldcat-fieldname  = 'BUKRS'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'LIFNR'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'LIFNR'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'NAME1'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'NAME1'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'LAND1'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'LAND1'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'ORT01'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'ORT01'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'PSTLZ'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'PSTLZ'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'REGIO'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'REGIO'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'SORTL'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'SORTL'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'STRAS'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'STRAS'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'ADRNR'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'ADRNR'.
      APPEND l_fieldcat TO t_fieldtab.
    ENDFORM.                    " initialize_fieldcat
         Form  initializa_layout
    FORM initializa_layout.
      t_layout-zebra        = 'X'.
      t_layout-cwidth_opt   = 'X'.
    t_layout-no_toolbar   = 'X'.
    T_LAYOUT-EDIT         = 'X'.
      T_LAYOUT-DETAILINIT    = 'X'.
      T_LAYOUT-CWIDTH_OPT    = 'X'.
      T_LAYOUT-TOTALS_BEF    = 'X'.
      T_LAYOUT-NUMC_TOTAL    = 'X'.
    ENDFORM.                    " initializa_layout
         Module  USER_COMMAND_9010  INPUT
    MODULE user_command_9010 INPUT.
      CASE sy-ucomm.
        WHEN 'SAVE'.
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
             TITLEBAR                    = ' '
             DIAGNOSE_OBJECT             = ' '
              text_question               = 'Pulsaste SAVE'
             TEXT_BUTTON_1               = 'Ja'(001)
             ICON_BUTTON_1               = ' '
             TEXT_BUTTON_2               = 'Nein'(002)
             ICON_BUTTON_2               = ' '
             DEFAULT_BUTTON              = '1'
             DISPLAY_CANCEL_BUTTON       = 'X'
             USERDEFINED_F1_HELP         = ' '
             START_COLUMN                = 25
             START_ROW                   = 6
             POPUP_TYPE                  =
           IMPORTING
             ANSWER                      =
           TABLES
             PARAMETER                   =
           EXCEPTIONS
             TEXT_NOT_FOUND              = 1
             OTHERS                      = 2
          IF sy-subrc &lt;&gt; 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9010  INPUT
         Form  alvl_value_request
    FORM alvl_value_request USING    pi_alv
                                     value(p_0158).
      DATA: l_disvariant TYPE disvariant.
    Wertehilfe
      l_disvariant-report  = sy-cprog.
    l_disvariant-report(1) = 'A'.
      l_disvariant-variant = pi_alv.
      l_disvariant-log_group = p_0158.
      CALL FUNCTION 'LVC_VARIANT_SAVE_LOAD'
           EXPORTING
                i_save_load = 'F'
                i_tabname   = '1'
           CHANGING
                cs_variant  = l_disvariant
           EXCEPTIONS
                OTHERS      = 1.
      IF sy-subrc = 0.
        pi_alv = l_disvariant-variant.
      ELSE.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " ALVL_VALUE_REQUEST
    Kanagaraja L

  • ALV Grid using classes

    Hi gurus,
               can anyone send me sample code to develop a repot using classes with all possibilities i.e, using events and interactive, pop-up.
    Best answers wil be rewarded.
    Regards,
    alson

    REPORT zex35 MESSAGE-ID zsmg NO STANDARD PAGE HEADING.
    INCLUDE <icon>.
    CLASS myclass DEFINITION DEFERRED.
    TABLES: vbak,kna1.
    TYPE-POOLS: slis,sdydo.
    DATA: BEGIN OF jtab OCCURS 0,
          ch(1),
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          styletable TYPE lvc_t_styl,
          rowcolor(4),
          cellcolor TYPE lvc_t_scol,
          ptype_dd_hndl TYPE int4 ,
          END OF jtab.
    DATA : ejtab LIKE jtab OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF vjtab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          END OF vjtab.
    DATA: alv TYPE scrfname VALUE 'ALV',
          obj_c_container_alv TYPE REF TO cl_gui_custom_container,
          obj_grid TYPE REF TO cl_gui_alv_grid,
          obj_myclass TYPE REF TO myclass,
          i_fieldcat TYPE lvc_t_fcat,
          wa_fieldcat LIKE LINE OF i_fieldcat,
          ei_fieldcat TYPE lvc_t_fcat,
          ewa_fieldcat LIKE LINE OF i_fieldcat,
          gs_layout   TYPE lvc_s_layo.
    DATA:   l_rows TYPE lvc_t_row.
    DATA :  modi TYPE  lvc_s_modi ,
            rowid TYPE i,
            ind TYPE i,
            wjtab LIKE jtab,
            it_exclude TYPE ui_functions,
            it_sort TYPE lvc_t_sort,
            it_filt TYPE lvc_t_filt,
            gi_index_rows TYPE lvc_t_row,
            g_selected_row LIKE lvc_s_row.
    DATA: ls_edit TYPE lvc_s_styl,
          lt_edit TYPE lvc_t_styl.
    DATA: ls_outtab LIKE LINE OF jtab.
    CALL SCREEN 100.
          CLASS MYCLASS DEFINITION
    CLASS myclass DEFINITION.
      PUBLIC SECTION.
        METHODS:
        toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object
                 e_interactive,
        user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING
                 e_ucomm.
       after_user_command FOR EVENT BEFORE_user_command OF cl_gui_alv_grid
             IMPORTING
                e_ucomm,
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
    ENDCLASS.
          CLASS MYCLASS IMPLEMENTATION
    CLASS myclass IMPLEMENTATION.
      METHOD toolbar.
        DATA: ls_toolbar  TYPE stb_button.
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'BACK' TO ls_toolbar-function.
       MOVE icon_previous_object TO ls_toolbar-icon.
        MOVE 'BACK' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CLEA' TO ls_toolbar-function.
       MOVE icon_refresh TO ls_toolbar-icon.
        MOVE 'CLEAR' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'TEXT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'READ' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'INSERT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'INSERT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'FCAT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'FCAT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.
    METHOD after_user_command.
       CASE e_ucomm.
         WHEN '&LOCAL&INSERT_ROW'.
           PERFORM insert_data.
       ENDCASE.
    ENDMETHOD.
      METHOD user_command.
        CASE e_ucomm.
          WHEN 'BACK'.
            LEAVE PROGRAM.
          WHEN 'INSERT'.
            PERFORM insert_data.
          WHEN 'FCAT'.
            PERFORM fcat_change.
        ENDCASE.
      ENDMETHOD.
    METHOD handle_change_click.
       LOOP AT er_data_changed->mt_mod_cells INTO modi.
         rowid = modi-row_id.
         READ TABLE jtab INTO wjtab INDEX rowid.
      WJTAB-VBELN = MODI-VALUE.
         MODIFY jtab FROM wjtab INDEX rowid.
       ENDLOOP.
    ENDMETHOD.
    ENDCLASS.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'DISPLAY'.
          SELECT  vbeln erdat kunnr ernam netwr knumv bstnk ktext
              FROM vbak INTO CORRESPONDING FIELDS OF TABLE vjtab
              WHERE vbeln LT  '0000000500'.
          PERFORM display1.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  display1
    FORM display1.
      CREATE OBJECT obj_c_container_alv
        EXPORTING
          container_name              = alv.
      IF obj_grid IS INITIAL.
        CREATE OBJECT obj_grid
              EXPORTING
                i_parent          = obj_c_container_alv.
        CREATE OBJECT obj_myclass.
        SET HANDLER obj_myclass->toolbar FOR obj_grid.
        SET HANDLER obj_myclass->user_command FOR obj_grid.
       SET HANDLER obj_myclass->handle_change_click FOR obj_grid.
       gs_layout-sel_mode = 'C'.
       gs_layout-cwidth_opt = 'X'.
       gs_layout-smalltitle = 'X'.
        gs_layout-grid_title = 'ALV TITLE'.
       gs_layout-no_headers = 'X'.
        gs_layout-stylefname = 'STYLETABLE'.
       gs_layout-no_hgridln = 'X'.
       gs_layout-no_vgridln = 'X'.
       gs_layout-NO_ROWMARK = 'X'.
       gs_layout-no_toolbar = 'X'.
        gs_layout-info_fname = 'ROWCOLOR'.
        gs_layout-ctab_fname = 'CELLCOLOR'.
        LOOP AT vjtab.
          jtab-vbeln = vjtab-vbeln.
          jtab-erdat = vjtab-erdat.
          jtab-kunnr = vjtab-kunnr.
          jtab-ernam = vjtab-ernam.
          jtab-netwr = vjtab-netwr.
          jtab-knumv = vjtab-knumv.
          jtab-bstnk = vjtab-bstnk.
          jtab-ktext = vjtab-ktext.
          APPEND jtab.
          CLEAR jtab.
        ENDLOOP.
        PERFORM build_fieldcat.
        PERFORM exclude_toolbaricons CHANGING it_exclude.
        PERFORM sort_table CHANGING it_sort.
        PERFORM filter_table CHANGING it_filt.
        PERFORM rowcolor.
        PERFORM colcolor.
        PERFORM drilldown_values.
        CALL METHOD obj_grid->set_table_for_first_display
          EXPORTING
            i_structure_name              = 'JTAB'
            is_layout                     = gs_layout
            it_toolbar_excluding          = it_exclude
          CHANGING
            it_outtab                     = jtab[]
           it_sort                       = it_sort
            it_filter                     = it_filt
            it_fieldcatalog               = i_fieldcat.
      ELSE .
        CALL METHOD obj_grid->refresh_table_display.
      ENDIF.
    ENDFORM.                                                    " display1
    *&      Form  SAVE_DATA
    FORM save_data.
    ENDFORM.                    " SAVE_DATA
    *&      Form  INSERT_DATA
    FORM insert_data.
      DATA:l_lines TYPE i.
      REFRESH gi_index_rows.
      CLEAR   g_selected_row.
      DATA ls_listrow LIKE LINE OF jtab .
      CALL METHOD obj_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      READ TABLE gi_index_rows INTO g_selected_row INDEX 1.
      ind = g_selected_row-index + 1.
      INSERT INITIAL LINE INTO jtab INDEX ind.
      READ TABLE jtab INDEX ind.
      CLEAR ls_edit.
      ls_edit-fieldname = 'VBELN'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'ERDAT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KUNNR'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'ERNAM'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'NETWR'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KNUMV'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'BSTNK'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'KTEXT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR : ls_outtab.
      INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
      MODIFY jtab INDEX ind FROM ls_outtab  TRANSPORTING
                                      styletable .
      CALL METHOD obj_grid->refresh_table_display.
    GS_LAYOUT-STYLEFNAME = 'STYLETABLE'.
      REFRESH : lt_edit.
    ENDFORM.                    " INSERT_DATA
    *&      Form  FCAT_CHANGE
    FORM fcat_change.
    DATA ls_fcat TYPE lvc_s_fcat .
    DATA lt_fcat TYPE lvc_t_fcat .
    DATA ls_layout TYPE lvc_s_layo .
    CALL METHOD obj_grid->get_frontend_fieldcatalog
    IMPORTING
    et_fieldcatalog = lt_fcat[] .
    LOOP AT lt_fcat INTO ls_fcat .
       IF ls_fcat-fieldname = 'ERNAM' .
         ls_fcat-coltext = 'MYNAME'.
         ls_fcat-no_out = 'X'.
         MODIFY lt_fcat FROM ls_fcat .
       ENDIF .
    ENDLOOP .
    CALL METHOD obj_grid->set_frontend_fieldcatalog
    EXPORTING
    it_fieldcatalog = lt_fcat[] .
    CALL METHOD obj_grid->get_frontend_layout
    IMPORTING
    es_layout = ls_layout .
    ls_layout-grid_title = 'Changed ALV Grid Title' .
    ls_layout-zebra = 'X' .
    CALL METHOD obj_grid->set_frontend_layout
    EXPORTING
    is_layout = ls_layout .
    LOOP AT jtab.
       IF jtab-netwr > '400.00'.
         CLEAR ls_edit.
         ls_edit-fieldname = 'ERDAT'.
         ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
         INSERT ls_edit INTO TABLE lt_edit.
         CLEAR : ls_outtab.
         INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
         MODIFY jtab INDEX sy-tabix FROM ls_outtab  TRANSPORTING
                                         styletable .
       ENDIF.
    ENDLOOP.
      LOOP AT jtab.
        IF jtab-netwr LE '400.00'.
          ejtab-vbeln = jtab-vbeln.
          ejtab-erdat = jtab-erdat.
          ejtab-kunnr = jtab-kunnr.
          ejtab-ernam = jtab-ernam.
          ejtab-netwr = jtab-netwr.
          ejtab-knumv = jtab-knumv.
          ejtab-bstnk = jtab-bstnk.
          ejtab-ktext = jtab-ktext.
          APPEND ejtab.
          CLEAR ejtab.
        ENDIF.
      ENDLOOP.
      PERFORM ebuild_fieldcat.
      CALL METHOD obj_grid->set_table_for_first_display
           EXPORTING
             i_structure_name              = 'EJTAB'
             is_layout                     = gs_layout
             it_toolbar_excluding          = it_exclude
           CHANGING
             it_outtab                     = ejtab[]
           it_sort                       = it_sort
             it_filter                     = it_filt
             it_fieldcatalog               = ei_fieldcat.
    ENDFORM.                    " FCAT_CHANGE
    *&      Form  exclude_toolbaricons
    FORM exclude_toolbaricons CHANGING   pt_exclude TYPE ui_functions.
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_find .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_average .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row .
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                    " exclude_toolbaricons
    *&      Form  sort_table
    FORM sort_table CHANGING pt_sort TYPE lvc_t_sort.
      DATA ls_sort TYPE lvc_s_sort .
      ls_sort-spos = '1' .
      ls_sort-fieldname = 'VBELN' .
      ls_sort-up = 'X' .
      ls_sort-down = space .
      APPEND ls_sort TO pt_sort .
      ls_sort-spos = '2' .
      ls_sort-fieldname = 'KUNNR' .
      ls_sort-up = space .
      ls_sort-down = 'X' .
      APPEND ls_sort TO pt_sort .
    ENDFORM.                    " sort_table
    *&      Form  filter_table
    FORM filter_table CHANGING pt_filt TYPE lvc_t_filt.
      DATA ls_filt TYPE lvc_s_filt .
      ls_filt-fieldname = 'VBELN' .
      ls_filt-sign = 'E' .
      ls_filt-option = 'BT' .
      ls_filt-low = '0000000010' .
      ls_filt-high = '0000000100' .
      APPEND ls_filt TO pt_filt .
    ENDFORM.                    " filter_table
    *&      Form  ROWCOLOR
    FORM rowcolor.
      CLEAR wjtab.
      LOOP AT jtab INTO wjtab.
        IF wjtab-netwr LE '400.00'.
          wjtab-rowcolor    = 'C611'.
        ENDIF.
        MODIFY jtab FROM wjtab.
      ENDLOOP.
    ENDFORM.                    " ROWCOLOR
    *&      Form  colcolor
    FORM colcolor.
      DATA ls_cellcolor TYPE lvc_s_scol .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 8 .
      ls_cellcolor-fname = 'KUNNR' .
      ls_cellcolor-color-col = '0' .
      ls_cellcolor-color-int = '0' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 8 .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 13 .
      ls_cellcolor-fname = 'NETWR' .
      ls_cellcolor-color-col = '5' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 13 .
    ENDFORM.                    " colcolor
    *&      Form  DRILLDOWN_VALUES
    FORM drilldown_values.
      DATA lt_ddval TYPE lvc_t_drop .
      DATA ls_ddval TYPE lvc_s_drop .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JFK-12' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JSF-44' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'KMDA-53' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'SS3O/N' .
      APPEND ls_ddval TO lt_ddval .
      CALL METHOD obj_grid->set_drop_down_table
      EXPORTING
      it_drop_down = lt_ddval .
    ENDFORM.                    " DRILLDOWN_VALUES
    *&      Form  BUILD_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat.
      CLEAR i_fieldcat[].
    *CLEAR wa_fieldcat.
    *wa_fieldcat-col_pos = 1.
    *wa_fieldcat-fieldname = 'CH'.
    **wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '2'.
    **wa_fieldcat-coltext = 'CHECKBOX'.
    *wa_fieldcat-checkbox = 'X'.
    *wa_fieldcat-edit        = 'X'.
    *APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'VBELN'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'SALES ORDER'.
    *wa_fieldcat-CHECKBOX = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 4.
      wa_fieldcat-fieldname = 'KUNNR'.
      wa_fieldcat-tabname = 'JTAB'.
      wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 3.
      wa_fieldcat-fieldname = 'ERDAT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '8'.
      wa_fieldcat-coltext = 'DATE'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 5.
      wa_fieldcat-fieldname = 'ERNAM'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '12'.
      wa_fieldcat-coltext = 'NAME'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 6.
      wa_fieldcat-fieldname = 'NETWR'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '15'.
      wa_fieldcat-coltext = 'NET WEIGHT'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 7.
      wa_fieldcat-fieldname = 'KNUMV'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'DOC COND'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 8.
      wa_fieldcat-fieldname = 'BSTNK'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUST PO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 9.
      wa_fieldcat-fieldname = 'KTEXT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '40'.
      wa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      wa_fieldcat-edit        = 'X'.
      wa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  ebuild_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM ebuild_fieldcat.
      CLEAR ei_fieldcat[].
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 1.
      ewa_fieldcat-fieldname = 'CH'.
    *ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '2'.
    *ewa_fieldcat-coltext = 'CHECKBOX'.
      ewa_fieldcat-checkbox = 'X'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 2.
      ewa_fieldcat-fieldname = 'VBELN'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'SALES ORDER'.
    *ewa_fieldcat-CHECKBOX = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 4.
      ewa_fieldcat-fieldname = 'KUNNR'.
      ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 3.
      ewa_fieldcat-fieldname = 'ERDAT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '8'.
      ewa_fieldcat-coltext = 'DATE'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 5.
      ewa_fieldcat-fieldname = 'ERNAM'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '12'.
      ewa_fieldcat-coltext = 'NAME'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 6.
      ewa_fieldcat-fieldname = 'NETWR'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '15'.
      ewa_fieldcat-coltext = 'NET WEIGHT'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 7.
      ewa_fieldcat-fieldname = 'KNUMV'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'DOC COND'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 8.
      ewa_fieldcat-fieldname = 'BSTNK'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUST PO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 9.
      ewa_fieldcat-fieldname = 'KTEXT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '40'.
      ewa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      ewa_fieldcat-edit        = 'X'.
      ewa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND ewa_fieldcat TO ei_fieldcat.
    ENDFORM.                    " ebuild_fieldcat

  • Alv Grid and Refresh Button

    Hello ;
    My Program is type of report, not a moduler program.
    And I’m using  the alv grid ,  But there isn’t refresh button ,I couldn’t see it.
    How can I see refresh button?
    Thanks.

    Hai
    Check the following Code
    REPORT z_alv_grid_ctrl_refresh_2.
    ALV Grid Control *
    This report reads and displays data from table MARA, using *
    the Method set_table_for_first_display of CL_GUI_ALV_GRID *
    Button 'NEXT_PAGE' : displays the next N records *
    Button 'PREV_PAGE' : displays the previous N records *
    Button 'FIRST_PAGE' : displays the first page *
    Button 'LAST_PAGE' : displays the last page *
    When the buttons Sort up, sort down, Filter, Delete Filter are *
    pressed, N record are still displayed *
    Steps : *
    - Create the report Z_ALV_GRID_CTRL_REFRESH_2 *
    - Create the Dynpro 0100 (size 27x120) *
    - Add OKCODE (type OK) in the element list *
    - Modify the flow logic of dynpro 0100 : *
    * PROCESS BEFORE OUTPUT. *
    MODULE pbo_0100. *
    * PROCESS AFTER INPUT. *
    MODULE user_command_0100. *
    - Create a status named 'MAIN' *
    with the buttons : REFRESH BACK EXIT *
    and the buttons : FIRST_PAGE PREV_PAGE NEXT_PAGE LAST_PAGE *
    Author : Michel PIOUD *
    Email : [email protected] HomePage : http://www.geocities.com/mpioud *
    CONSTANTS:
    c_first_page TYPE syucomm VALUE 'FIRST_PAGE',
    c_next_page TYPE syucomm VALUE 'NEXT_PAGE',
    c_prev_page TYPE syucomm VALUE 'PREV_PAGE',
    c_last_page TYPE syucomm VALUE 'LAST_PAGE'.
    TYPES:
    BEGIN OF ty_s_mara,
    ernam LIKE mara-ernam,
    matnr LIKE mara-matnr,
    ersda LIKE mara-ersda,
    brgew LIKE mara-brgew,
    END OF ty_s_mara.
    CLASS lcl_event_alv DEFINITION DEFERRED.
    DATA:
    gt_mara TYPE STANDARD TABLE OF ty_s_mara,
    go_container TYPE REF TO cl_gui_docking_container,
    go_alv_grid TYPE REF TO cl_gui_alv_grid,
    go_events TYPE REF TO lcl_event_alv,
    gt_mara_ftr TYPE STANDARD TABLE OF ty_s_mara, " Data filtered
    gt_mara_all TYPE STANDARD TABLE OF ty_s_mara, " Data readfrom DB
    okcode TYPE syucomm,
    gv_okcode TYPE syucomm.
    CLASS lcl_event_alv DEFINITION
    CLASS lcl_event_alv DEFINITION.
    PUBLIC SECTION.
    METHODS:
    h_user_command FOR EVENT after_user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm
    sender.
    ENDCLASS. " LCL_EVENT_ALV DEFINITION
    Class (Implementation) lcl_event_alv
    CLASS lcl_event_alv IMPLEMENTATION.
    METHOD h_user_command.
    CASE e_ucomm.
    WHEN '&SORT_ASC' OR '&SORT_DSC'. " Sort
    PERFORM f_sort_big_table.
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    WHEN '&FILTER'. " Filter
    PERFORM f_filter_data.
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    WHEN '&DELETE_FILTER'. " Delete filter
    gt_mara_ftr[] = gt_mara_all[].
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    ENDCASE.
    ENDMETHOD. " user_command
    ENDCLASS. " LCL_EVENT_ALV
    SELECTION-SCREEN :
    BEGIN OF LINE,COMMENT 10(20) v_1 FOR FIELD p_max. "#EC NEEDED
    PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
    v_1 = 'Lines per page'.
    START-OF-SELECTION.
    SELECT matnr ernam ersda brgew
    INTO TABLE gt_mara_all
    FROM mara.
    gt_mara_ftr[] = gt_mara_all[].
    PERFORM f_read_data USING c_first_page.
    CALL SCREEN 100.
    Module pbo_0100 OUTPUT
    MODULE pbo_0100 OUTPUT.
    SET PF-STATUS 'MAIN'.
    PERFORM create_and_init_alv.
    ENDMODULE. " PBO_0100 OUTPUT
    Module user_command_0100 INPUT
    MODULE user_command_0100 INPUT.
    gv_okcode = okcode.
    CLEAR okcode.
    CASE gv_okcode.
    WHEN 'BACK'.
    SET SCREEN 0.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    WHEN c_first_page OR c_next_page OR c_last_page OR c_prev_page.
    PERFORM f_read_data USING gv_okcode. " Update gt_mara
    PERFORM f_refresh_table.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    Form f_read_data
    FORM f_read_data USING u_ucomm TYPE syucomm.
    STATICS :
    l_1 TYPE sytabix,
    l_2 TYPE sytabix.
    DATA l_max TYPE sytabix. " Internal table size
    DESCRIBE TABLE gt_mara_ftr LINES l_max.
    CASE u_ucomm.
    WHEN c_first_page. " 1st page
    l_1 = 1.
    WHEN c_prev_page. " Previous page
    SUBTRACT p_max FROM l_1.
    IF l_1 < 1.
    l_1 = 1.
    ENDIF.
    WHEN c_next_page. " Next page
    IF l_1 IS INITIAL.
    l_1 = 1.
    ELSE.
    ADD p_max TO l_1.
    ENDIF.
    IF l_1 > l_max.
    l_1 = l_max.
    ENDIF.
    WHEN c_last_page. " Last page
    l_1 = l_max - p_max + 1.
    IF l_1 < 1.
    l_1 = 1.
    ENDIF.
    ENDCASE.
    l_2 = l_1 + p_max - 1.
    IF l_2 > l_max.
    l_2 = l_max.
    ENDIF.
    REFRESH gt_mara.
    IF l_max > 0.
    APPEND LINES OF gt_mara_ftr FROM l_1
    TO l_2
    TO gt_mara.
    ENDIF.
    ENDFORM. " F_READ_DATA
    Form create_and_init_alv
    FORM create_and_init_alv.
    Macro definition
    DEFINE m_fieldcat.
    add 1 to ls_alv_cat-col_pos.
    ls_alv_cat-fieldname = &1.
    ls_alv_cat-ref_table = 'MARA'.
    append ls_alv_cat to lt_alv_cat.
    END-OF-DEFINITION.
    DATA:
    ls_variant TYPE disvariant,
    lt_alv_cat TYPE lvc_t_fcat,
    ls_alv_cat TYPE lvc_s_fcat,
    ls_alv_lay TYPE lvc_s_layo,
    l_offline TYPE char1.
    CHECK go_container IS INITIAL.
    CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING e_offline = l_offline.
    IF l_offline EQ 0.
    CREATE OBJECT go_container
    EXPORTING
    extension = 2000
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    IF sy-subrc NE 0.
    MESSAGE e208(00) WITH 'The control could not be created'.
    ENDIF.
    ENDIF.
    Create an instance of alv control
    CREATE OBJECT go_alv_grid
    EXPORTING i_parent = go_container.
    CREATE OBJECT go_events.
    SET HANDLER go_events->h_user_command FOR go_alv_grid.
    Build field catalog
    m_fieldcat 'ERNAM'.
    m_fieldcat 'MATNR'.
    m_fieldcat 'ERSDA'.
    m_fieldcat 'BRGEW'.
    Layout
    CLEAR ls_alv_lay.
    ls_alv_lay-zebra = 'X'.
    ls_alv_lay-cwidth_opt = 'X'.
    ls_variant-report = sy-cprog.
    Display
    CALL METHOD go_alv_grid->set_table_for_first_display
    EXPORTING
    is_variant = ls_variant
    is_layout = ls_alv_lay
    i_save = 'A'
    CHANGING
    it_outtab = gt_mara
    it_fieldcatalog = lt_alv_cat.
    ENDFORM. " CREATE_AND_INIT_ALV
    Form F_REFRESH_TABLE
    FORM f_refresh_table.
    DATA: ls_layout TYPE lvc_s_layo.
    CALL METHOD go_alv_grid->get_frontend_layout
    IMPORTING es_layout = ls_layout.
    ls_layout-cwidth_opt = 'X'.
    CALL METHOD go_alv_grid->set_frontend_layout
    EXPORTING is_layout = ls_layout.
    CALL METHOD go_alv_grid->refresh_table_display.
    ENDFORM. " F_REFRESH_TABLE
    Form F_SORT_BIG_TABLE
    FORM f_sort_big_table.
    DATA:
    lt_sort_kkblo TYPE kkblo_t_sortinfo,
    lt_sort TYPE lvc_t_sort.
    CALL METHOD go_alv_grid->get_sort_criteria
    IMPORTING et_sort = lt_sort.
    CHECK NOT lt_sort[] IS INITIAL.
    Format LVC --> KKBLO
    CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
    EXPORTING
    it_sort_lvc = lt_sort
    IMPORTING
    et_sort_kkblo = lt_sort_kkblo.
    The big tables must be sorted like the small one
    PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_ftr
    lt_sort_kkblo
    USING 'X'
    'X'.
    PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_all
    lt_sort_kkblo
    USING 'X'
    'X'.
    ENDFORM. " F_SORT_BIG_TABLE
    Form f_filter_data
    FORM f_filter_data.
    DATA:
    lt_filter_lvc TYPE lvc_t_filt,
    lt_filter_index TYPE lvc_t_fidx WITH HEADER LINE.
    CALL METHOD go_alv_grid->get_filter_criteria
    IMPORTING et_filter = lt_filter_lvc.
    Find data to filter
    CALL FUNCTION 'LVC_FILTER_APPLY'
    EXPORTING
    it_filter = lt_filter_lvc
    IMPORTING
    et_filter_index = lt_filter_index[]
    TABLES
    it_data = gt_mara_all.
    gt_mara_ftr[] = gt_mara_all[].
    SORT lt_filter_index DESCENDING.
    LOOP AT lt_filter_index.
    DELETE gt_mara_ftr INDEX lt_filter_index.
    ENDLOOP.
    ENDFORM. " F_FILTER_DATA
    END OF PROGRAM Z_ALV_GRID_CTRL_REFRESH_2 ********************
    Thanks & regards
    Sreenivasulu P

  • How can I trigger a USER_COMMAND for alv grid "toolbar" ???

    Hi,
    i have the standard ALV Grid "toolbar" and if i click to the Button "&LOCAL&COPY_ROW" than i want try to make a Refresh to my ALV Table in the Event "afteruser_command"_!!!!
    Here is the implementation of my Event *"afteruser_command":*_
    METHOD on_after_user_command.
    ........DATA: ls_stable TYPE lvc_s_stbl.
    .....CASE e_ucomm.
    .....WHEN '&LOCAL&COPY_ROW'.
    ........MESSAGE 'LOCAL_COPY_ROW' TYPE 'S' DISPLAY LIKE 'E'.
    ........ls_stable-row = 'X'.
    ........ls_stable-col = 'X'.
    ........CALL METHOD gr_grid_d0100->refresh_table_display
    ..............EXPORTING
    .......................is_stable      = ls_stable
    ..............EXCEPTIONS
    .......................finished       = 1
    .......................OTHERS         = 2.
    ......ENDCASE.
      ENDMETHOD.   
    But it doesnt work.
    Is there another function code for the Copy Button????
    Thanks
    Ersin

    Hello Ersin,
    the events "after_user_command", "before_user_command" and "user_command" will not be fired when selecting this command!
    In my opinion, there is no solution, to fire these events, using this alv-function!
    But there is a trick:
    1. Register on the event "toolbar" with an own method:
          toolbar_own          for event toolbar of cl_gui_alv_grid
                                       importing e_object
                                              e_interactive,
    In this method change the function code of "&LOCAL&COPY_ROW", but don´t change the row of the entry, because the button should appear on the same place in the toolbar:
        field-symbols: <ls_toolbar>  type stb_button.
        read table e_object->mt_toolbar with key function = '&LOCAL&COPY_ROW'
                                        assigning <ls_toolbar>.
        if sy-subrc = 0.
          <ls_toolbar>-function = 'COPYROW_OWN'.
        endif.
    2. Register on the event "user_command" ( I think, that´s clear ):
          user_cmd_own           for event user_command
                                              of cl_gui_alv_grid
                                              importing e_ucomm,
    ( don´t forget the set handler-commands for both events:
      set handler po_alv_own->user_cmd_own              for po_alv_own.
      set handler po_alv_own->toolbar_own               for po_alv_own.     )
    3. Now you can react in the method "user_command" on your own function code:
        case e_ucomm.
          when 'COPYROW_OWN'.
            perform copy_row using    me
                             changing gt_bis_cf_out.
    Sample code for copying the current line:
    FORM COPY_ROW  using    po_alv_own          type ref to gcl_alv_own
                   changing pt_table_alv      type gt_table_alv_t.
      data: l_index         type i,
            ls_table_alv   type gs_table_alvt_t.
      call method po_alv_own->get_current_cell
         importing
           e_row     = l_index.
    *      e_value   =
    *      e_col     =
    *      es_row_id =
    *      es_col_id =
    *      es_row_no =
      "read the current line:
      read table pt_table_alv index l_index
                               into ls_table_alv_out.
      "some changes for the new row:
      clear: ls_table_alv-style,
             ls_table_alv-tabix.
      "insert the new line:
      add 1 to l_index.
      insert ls_table_alv into pt_table_alv index l_index.
      po_alv_own->refresh( ).
    ENDFORM.                    " COPY_ROW
    In this manner the events "after_user_command", "before_user_command" are fired, too!
    For information: My problem was, that the ALV-function copied the style-information too, so in the new line, some fields are not editable. At least his field must be cleared!
    Best regard
    Thomas Scheuermann

Maybe you are looking for

  • How do I stop firefox from remenbering my last session every time I open up the browser?

    Something happen to my computer yesterday because lots of my program shut down but I was able to open up again and now I discovered today that every time I open firefox it remember my last session even though I didn't ask it to - my homepage is set t

  • How can i do a proper calculation of working hours?

    I have tried doing a calculation of my working hours using the ABS formula but it still gives me the wrong answer. 5:00 PM 1:00 AM 16h the formula is =ABS(A1-A2) the resulte shoulb be 8h but it shows 16h....

  • TS3899 I tried to send a message and the screen froze on my iPad 2.

    After my message froze, I restarted my iPad and Mail with no help. Each time I access Mail, the message I tried to send is showing and I can't get rid of it to see my messages. The recipient of the message said she got it, but I can't cancel it on my

  • Script language problem in Address syntax

    For this syntax in script ADDRESS PARAGRAPH ZD LINES 8 NAME     &BILL_NAME1&, &BILL_NAME2&, &BILL_NAME3&, &BILL_NAME4& STREET   &BILL_STRAS& POBOX    &BILL_PFACH& CODE &BILL_PSTL2& CITY &BILL_PFORT& POSTCODE &BILL_PSTLZ& REGION   &BILL_REGIO& CITY   

  • ITunes 7.3 & iPhone

    Current iTunes version is 7.2. At least that's the version currently showing under the iTunes Download. The iPhone Specs say it needs 7.3 or later. Is this correct? If so, I think Apple would be smart to make 7.3 available before 6/29. If the Spec is