ALV GRID  - double click event - hot spot event

Dear developers
I am building a custom application using ALV GRID (OO method).
I have three ALV's on the screen.
User selects a cell on the first ALV from the list. say a specific product group.
The second ALV displays the product records depnding on selection of first ALV. (this works fine).
when the user selects a cell of a specific column on ALV grid 2 using double click event or hotspot I am always getting row ID as 1 , irrespective of the user clickin on row 2 or 3 on the specific cell.
To carry out further processing , I need to get the exact row the user is selecting which I expected to be available in LVC_S_ROID. My further process works always with ROW ID as 1.
I am using event hot spot in alv grid 1. In grid 2 I tried both hot spot and double click . But both returns the index value of row as 1 , irrespective of the cell being clicked is beyond row 1. in second grid.
Looking forward for help or suggestion on this,
Regards
Kumar

Hi
The handler is implemented as follows for all ALV GRIDs.
I give below only the relevant one grid 2 from my code.
Class definition
**03/17/2005 skulist hotspot
handle_skulist FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
Class implementation
**03/17/2005 sku list by currency hotspot on listprice
  METHOD handle_skulist .
    PERFORM handle_skulist USING e_row_id e_column_id es_row_no.
  ENDMETHOD.                    "HANDLE_HOTSPOT_CLICK
DATA gr_event_handler TYPE REF TO lcl_event_handler.
DATA gr_event_handler_4 TYPE REF TO lcl_event_handler.
The above are done in an include and are public in nature.
Also note that I have similar implementation for similar events for grid 1 bu the event handlers are registered in different names.
The code below is in the maib program , under a custom container for grid 2
CREATE OBJECT gr_event_handler_4.
    SET HANDLER gr_event_handler_4->handle_skulist FOR gr_alvgrid1.
*Based on the user action on grid 2 this form is getting executed. But as I said earlier the parameter I am getting for index is 1 always.
FORM handle_skulist USING i_row_id1 TYPE lvc_s_row
                                i_column_id1 TYPE lvc_s_col
                                is_row_no1 TYPE lvc_s_roid.

Similar Messages

  • I can no longer create an event on iCal by double clicking on a time or date, nor can I double click on an existing event! HELP!

    I can no longer create an event on iCal by double clicking on a time or date, nor can I double click on an existing event! HELP!
    The only way I have to create an event is by using the "+" button, which is very limiting!
    I am running the latest version of Mac OS X and all the updates.
    Anyone know how I could get a proper use of my iCal ?
    Thanks

    Hi,
    If you list the steps you have taken to fix this it will help.
    Have you tried using the File > New Event menu item?
    Have you logged the user account out/ restarted the computer?
    Have you tried un-syncing any accounts synced to Calendar?
    Is there some change made to the computer that may have triggered this?
    Best wishes
    John M

  • I just started using iCal and I cannot double-click to add an event. Did I accidentally change something?

    I just started using iCal and I cannot double-click to add an event. I could when I started a couple of hours ago. Did I change something? Can I change it back?

    Kristacattack,
    The tracing results in separate paths. The straight lines show where the open filled paths start and end.
    In the first sample, you may drag with the Direct Selection Tool over the top where the straight lines meet and Ctrl/Cmd+J to join the the paths; you may do the same elsewhere to create continuous/closed paths (hopefully, you will only drag over the two endpoints, otherwise you will have to find and delete superfluous Anchor Points).
    This may be better than just cheating with the Live Paint Tool because the artwork becomes more coherent.
    Edit: Hi Monika.

  • ALV TREE - Double click on an item

    Hi all,
    I need to handle the double click action on an Item of ad ALV_TREE defined cl_gui_alv_tree_simple
    What I did at now is:
    u2026
    DATA tree1  TYPE REF TO cl_gui_alv_tree_simple.
    u2026     
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->item_double_click FOR tree1.
      SET HANDLER event_receiver->node_double_click FOR tree1.
    u2026
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *Double-click control
        item_double_click FOR EVENT item_double_click OF cl_gui_alv_tree_simple
                          IMPORTING index_outtab
                                    fieldname
                                    grouplevel,
    *Double-click control
        node_double_click FOR EVENT node_double_click OF cl_gui_alv_tree_simple
                          IMPORTING index_outtab
                                    grouplevel.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD item_double_click.
        break <my_user_id>.
      ENDMETHOD.                    "handle_double_click
      METHOD node_double_click.
        break <my_user_id>.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    When I double click on item the program do nothing and I donu2019t understand the why.
    Note: I think I could try to define the events passed, using the method et_registered_events, but I donu2019t know how to obtain the id of method item_double_click defined in class cl_gui_alv_tree_simple.
    Any Idea?
    Thank you in advance.

    Register the events with the below code...
      data: lt_events type cntl_simple_events,
            l_event type cntl_simple_event.
      l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_CLICK.
      append l_event to lt_events.
      call method tree1->set_registered_events
        exporting
          events = lt_events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.

  • Hot spot event on alv tree

    hi.....
    whats the event for hotspot or single click on node event
    thanks.

    Hi,
    If you want to get it through grid you can go through the sample code...
    The sample program explains on how to achieve hotspot apply the same for alv tree...
    REPORT  Z_ALV_HOTSPOT.
    TABLES:EKKO.
    SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
        INTERNAL TABLE FOR EKKO
    DATA: TB_EKKO TYPE STANDARD TABLE OF EKKO,
        INTERNAL TABLE FOR EKPO
          TB_EKPO TYPE STANDARD TABLE OF EKPO,
          DA_TOP  TYPE REF TO CL_DD_DOCUMENT,
          DW_TOP  TYPE REF TO CL_DD_DOCUMENT.
    DATA:
        GRIDS
          EKKO_GRID TYPE REF TO CL_GUI_ALV_GRID,
          EKPO_GRID TYPE REF TO CL_GUI_ALV_GRID,
        CONTAINERS
          EKKO_CONTAINER        TYPE REF TO CL_GUI_CONTAINER,
          EKPO_CONTAINER        TYPE REF TO CL_GUI_CONTAINER,
          TOP_OF_PAGE_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
          DTOP_OF_PAGE_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
          DMAIN_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          MAIN_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
          DSPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
        LAYOUT
          X_LAYOUT TYPE LVC_S_LAYO,
        WORK AREA
          X_EKKO LIKE EKKO.
      DATA: FLAG TYPE C,
            flag_top type c.
          CLASS LCL_HANDLER DEFINITION
    CLASS LCL_HANDLER DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:HANDLER_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF
         CL_GUI_ALV_GRID IMPORTING E_ROW_ID.
        CLASS-METHODS:HANDLER_TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF
         CL_GUI_ALV_GRID .
    ENDCLASS.                    "LCL_HANDLER DEFINITION
          CLASS LCL_HANDLER IMPLEMENTATION
    CLASS LCL_HANDLER IMPLEMENTATION.
      METHOD HANDLER_HOTSPOT_CLICK.
    CLEAR X_EKKO.
    CLEAR TB_EKKO.
        READ TABLE TB_EKKO INDEX E_ROW_ID-INDEX INTO X_EKKO.
        IF SY-SUBRC = 0.
          PERFORM GET_ITEM_DETAILS USING X_EKKO-EBELN.
        ENDIF.
      ENDMETHOD.                    "HANDLER_HOTSPOT_CLICK
      METHOD HANDLER_TOP_OF_PAGE.
        CALL METHOD DA_TOP->ADD_TEXT
          EXPORTING
            TEXT = 'Top Of Page'.
        CALL METHOD DA_TOP->DISPLAY_DOCUMENT
          EXPORTING
            PARENT = TOP_OF_PAGE_CONTAINER.
    if flag_top = 'X'.
    CALL METHOD DW_TOP->ADD_TEXT
          EXPORTING
            TEXT = 'ITEM Top Of Page '.
        CALL METHOD DW_TOP->DISPLAY_DOCUMENT
          EXPORTING
            PARENT = DTOP_OF_PAGE_CONTAINER.
      flag_top = ' '.
    endif.
      ENDMETHOD.                    "HANDLER_TOP_OF_PAGE
    ENDCLASS.                    "LCL_HANDLER IMPLEMENTATION
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ABC'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  GET_DATA
    MODULE GET_DATA OUTPUT.
      SELECT * UP TO 5 ROWS INTO TABLE TB_EKKO FROM EKKO WHERE EBELN IN
      S_EBELN.
    ENDMODULE.                    " GET_DATA
                             START OF SELECTION.
    START-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  DISPLAY_DATA  OUTPUT
          text
    MODULE DISPLAY_DATA OUTPUT.
    CREATING CONTAINER OBJ*******
      CREATE OBJECT MAIN_CONTAINER
        EXPORTING
          CONTAINER_NAME               = 'CONT1'
        EXCEPTIONS
          CNTL_ERROR                  = 1
          CNTL_SYSTEM_ERROR           = 2
          CREATE_ERROR                = 3
          LIFETIME_ERROR              = 4
          LIFETIME_DYNPRO_DYNPRO_LINK = 5
          OTHERS                      = 6
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT SPLITTER
                        EXPORTING TOP     = 5
                                  PARENT  = MAIN_CONTAINER
                                  ROWS    = 2
                                  COLUMNS = 1.
      CALL METHOD SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = TOP_OF_PAGE_CONTAINER.
      CALL METHOD SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = EKKO_CONTAINER.
    CREATING GRID OBJ AND ASSAIGNING TO CONTAINER ****
      CREATE OBJECT EKKO_GRID
        EXPORTING
          I_PARENT          =  EKKO_CONTAINER
        EXCEPTIONS
          ERROR_CNTL_CREATE = 1
          ERROR_CNTL_INIT   = 2
          ERROR_CNTL_LINK   = 3
          ERROR_DP_CREATE   = 4
          OTHERS            = 5
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    LAYOUT SETTINGS ***
      X_LAYOUT-ZEBRA  = 'X'.
      X_LAYOUT-KEYHOT = 'X'.
    TO DISPLAY TB_EKKO CONTENTS  ********
      CALL METHOD EKKO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME              = 'EKKO'
          IS_LAYOUT                     = X_LAYOUT
        CHANGING
          IT_OUTTAB                     = TB_EKKO
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ***REGESTRING HANDLER FOR HOT SPOT CLICK EVENT
      SET HANDLER LCL_HANDLER=>HANDLER_HOTSPOT_CLICK FOR EKKO_GRID.
      SET HANDLER LCL_HANDLER=>HANDLER_TOP_OF_PAGE FOR EKKO_GRID.
    For Top Of Page
      CREATE OBJECT DA_TOP
        EXPORTING STYLE = 'ALV_GRID'.
      CALL METHOD DA_TOP->INITIALIZE_DOCUMENT.
      CALL METHOD EKKO_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DA_TOP.
    ENDMODULE.                 " DISPLAY_DATA  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'OTHERS'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  GET_ITEM_DETAILS
    FORM GET_ITEM_DETAILS  USING  P_EKKO_EBELN TYPE EKKO-EBELN.
      CLEAR TB_EKPO[].
      SELECT * UP TO 5 ROWS INTO TABLE TB_EKPO FROM EKPO WHERE EBELN =
      P_EKKO_EBELN.
      IF FLAG IS INITIAL.
        FLAG = 'X'.
    CREATING CONTAINER OBJ*******
        CREATE OBJECT DMAIN_CONTAINER
          EXPORTING
            CONTAINER_NAME               = 'CONT2'
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
            OTHERS                      = 6
        IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    CREATE OBJECT DSPLITTER
                        EXPORTING TOP     = 5
                                  PARENT  = DMAIN_CONTAINER
                                  ROWS    = 2
                                  COLUMNS = 1.
      CALL METHOD DSPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = DTOP_OF_PAGE_CONTAINER.
      CALL METHOD DSPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = EKPO_CONTAINER.
    CREATING GRID OBJ AND ASSAIGNING TO CONTAINER ****
        CREATE OBJECT EKPO_GRID
          EXPORTING
            I_PARENT          =  EKPO_CONTAINER
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5
        IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    LAYOUT SETTINGS ***
      X_LAYOUT-ZEBRA  = 'X'.
    TO DISPLAY TB_EKPO CONTENTS  ********
      CALL METHOD EKPO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME              = 'EKPO'
          IS_LAYOUT                     = X_LAYOUT
        CHANGING
          IT_OUTTAB                     = TB_EKPO
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    SET HANDLER LCL_HANDLER=>HANDLER_TOP_OF_PAGE FOR EKPO_GRID.
    For Top Of Page
      CREATE OBJECT DW_TOP
        EXPORTING STYLE = 'ALV_GRID'.
      CALL METHOD DW_TOP->INITIALIZE_DOCUMENT.
    flag_top = 'X'.
      CALL METHOD EKPO_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DW_TOP.
    ENDFORM.                    " GET_ITEM_DETAILS
    <b>Reward points for all helpful answers.</b>
    Regards,
    Azaz Ali.

  • ALV OOPS Double-click event

    Hi,
    I want to handle the double-click event in ALV grid (OOPs).
    The output should be shown in the same fashion as it is shown in SE16 when we double-click on any record in the result set.
    i.e. if you have selected the ALV grid display for the Data browser in SE16 and when you double click on any record, the complete record is shown in a window.
    I want this in my ALV as well..
    Can anyone please suggest how to achieve this?
    Regards
    s.a.k

    Hi siemens.a.k ,
    The solution for the issue would be to create a  custom screen and add a custom table controller in a container.
    In this table controller you map the respective fields required for your output
    Now once you are done with data population in the custom controller for ALV grid display using cl_gui_alv_grid_display class...
    create events in your custom class to handle the on click event.
    If you observe the standard functionality it could be clearly seen that sap has created another screen for the display of records in different view.
    You could also replicate the similar thing by creating another screen and populating the required fields into the second screen.
    As of now i am providing this information ...I would even try to simulate the scenario at my system.
    So once i am done i would update you the same...
    Thanks
    M.Naveen Kumar....

  • ALV Class Double click event

    Hi All,
    I have created an alv report using alv class. I have handled the double click event in that i am calling transaction using row currenlty selected. But after doing subtotalling the list and then i double click a line it is passing wrong data.
    Points are awarded,
    Regards,
    Bharat Mistry
    Message was edited by: Bharat Mistry

    Hi Bharat,
    Read the internal table contents in double click event with e_row-index , then you will get the data of that particular row.
    check below code :
    local class to handle semantic checks
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    DATA: g_event_receiver TYPE REF TO lcl_event_receiver.
    LOCAL CLASS Definition
    *§4.Define and implement event handler to handle event DATA_CHANGED.
    CLASS lcl_event_receiver DEFINITION.
      public section.
        METHODS:
          handle_double_click
                 FOR EVENT double_click OF cl_gui_alv_grid
                 IMPORTING e_row e_column.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_double_click.
      read table gt_outtab index e_row-index into
    Regards
    Appana
    *Reward Points for helpful answers
    Message was edited by: L Appana

  • ALV Grid Dropdown Click Event

    I have created an ALV grid with a dropdown as one of the columns. This all works fine, except that I want to be able to react to a change in the value of each line's dropdown.
    Currently I am reacting to the DATA_CHANGED event of the ALV grid, but that is too late. This event is only triggered if you change the value of the dropdown and then hit enter, or click on another cell or row.
    I want to be able to react to a change in the value immediately without having to lose focus of the dropdown.
    Is this possible?
    As an example, I have a table of records with one column as a dropdown called "Reason". A change in "reason" should change which fields in the row are editable. I'm sure I could just make sure to call the check_changed_data method before saving but I am hoping for a more user-friendly approach where as the new value is selected, the columns in the row can change to their required editable status.
    Of course points will be awarded.

    Hi David,
    Instead of using delayed call back event here i hav used data_changed event and this exacty suits ur requirement.....
    even here we have to register the edit events............
    PROGRAM bcalv_edit_06.
    * Purpose:
    * ~~~~~~~~
    * This example shows how to define a dropdown listbox for all cells
    * of one column in an editable ALV Grid Control.
    * To check program behavior
    * ~~~~~~~~~~~~~~~~~~~~~~~~~
    * Klick on the dropdown button of column 'WUNIT'. It shows
    * 'KG' and 'G' as suitable units for luggage weight.
    * (The standard F4-Help shows many other units that does not
    * make sense in this context).
    * Essential steps (search for '§')
    * ~~~~~~~~~~~~~~~
    * 1.Define a dropdown table and pass it to ALV.
    * 2.Set status of column WUNIT to editable and set a dropdown handle.
    CLASS lcl_event_responder DEFINITION.
      PUBLIC SECTION.
        METHODS refresh_changed_data  FOR EVENT data_changed
                                      OF cl_gui_alv_grid
                                      IMPORTING er_data_changed
                                                e_ucomm.
    ENDCLASS.                    "event_responder DEFINITION
    DATA: ok_code LIKE sy-ucomm,
          save_ok LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          handler   TYPE REF TO lcl_event_responder,
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo,
          g_max TYPE i VALUE 100.
    DATA: gt_outtab TYPE TABLE OF sbook.
    *       MAIN                                                          *
    END-OF-SELECTION.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF g_custom_container IS INITIAL.
        PERFORM create_and_init_alv CHANGING gt_outtab
                                             gt_fieldcat.
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    *&      Form  BUILD_FIELDCAT
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SBOOK'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
        IF    ls_fcat-fieldname EQ 'WUNIT'.
    *§2.Set status of column WUNIT to editable and set a dropdown handle.
          ls_fcat-edit = 'X'.
          ls_fcat-drdn_hndl = '1'.
          ls_fcat-outputlen = 7.
    * Field 'checktable' is set to avoid shortdumps that are caused
    * by inconsistend data in check tables. You may comment this out
    * when the test data of the flight model is consistent in your system.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          MODIFY pt_fieldcat FROM ls_fcat.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    *      <--P_GT_OUTTAB  text
    *      <--P_GT_FIELDCAT  text
    *      <--P_GS_LAYOUT  text
    FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
                                      pt_fieldcat TYPE lvc_t_fcat.
      DATA: lt_exclude TYPE ui_functions,
            lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
      CREATE OBJECT g_custom_container
             EXPORTING container_name = g_container.
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    * Build fieldcat and set column WUNIT
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM exclude_tb_functions CHANGING lt_exclude.
    * Define a drop down table.
      PERFORM set_drdn_table.
      SELECT * FROM sbook INTO TABLE pt_outtab UP TO g_max ROWS.
      IF sy-subrc NE 0.
    * generate own entries if database table is empty
        PERFORM generate_entries CHANGING pt_outtab.
      ENDIF.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab.
    * Set editable cells to ready for input initially
      CALL METHOD g_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
      g_grid->register_edit_event(
         EXPORTING
           i_event_id = cl_gui_alv_grid=>mc_evt_modified ). "Registering edit events
      CREATE OBJECT handler.
      SET HANDLER handler->refresh_changed_data FOR g_grid.
      CLEAR lt_f4.
      lt_f4-fieldname = 'WUNIT'.
      lt_f4-register = 'X'.
      APPEND lt_f4.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      <--P_LT_EXCLUDE  text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_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_append_row.
      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_move_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  set_drdn_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_drdn_table.
    *§1.Define a dropdown table and pass it to ALV.
    *   One listbox is referenced by a handle, e.g., '1'.
    *   For each entry that shall appear in this listbox
    *   you have to append a line to the dropdown table
    *   with handle '1'.
    *   This handle can be assigned to several columns
    *   of the output table using the field catalog.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    * First listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = 'KG'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = 'G'.
      APPEND ls_dropdown TO lt_dropdown.
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " set_drdn_table
    *&      Form  generate_entries
    *       text
    *      <--P_LT_SLFIGHT  text
    FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
    * This form is only needed if database table sbook is empty.
    * It generates some entries so that you may
    * still try out this example program.
      DATA: ls_sbook TYPE sbook,
            l_month(2) TYPE c,
            l_day(2) TYPE c,
            l_date(8) TYPE c,
         l_prebookid TYPE i.
      ls_sbook-carrid = 'LH'.
      ls_sbook-connid = '0400'.
      ls_sbook-forcurkey = 'DEM'.
      ls_sbook-loccurkey = 'USD'.
      ls_sbook-custtype = 'B'.
      DO 110 TIMES.
        l_prebookid = sy-index.
        ls_sbook-forcuram = sy-index * 10.
        ls_sbook-loccuram = ls_sbook-loccuram * 2.
        ls_sbook-customid = sy-index.
        ls_sbook-counter = 18.
        ls_sbook-agencynum = 11.
        l_month = sy-index / 10 + 1.
        DO 2 TIMES.
          l_day = 3 + l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date+4(2) = l_month.
          l_date+6(2) = l_day.
          ls_sbook-fldate = l_date.
          SUBTRACT 3 FROM l_day.
          ls_sbook-order_date+0(6) = l_date+0(6).
          ls_sbook-order_date+6(2) = l_day.
          ls_sbook-bookid = l_prebookid * 2 + sy-index.
          IF sy-index EQ 1.
            ls_sbook-smoker = 'X'.
          ELSE.
            ls_sbook-smoker = space.
          ENDIF.
          ls_sbook-luggweight = l_prebookid * 10.
          IF ls_sbook-luggweight GE 1000.
            ls_sbook-wunit = 'G'.
            ls_sbook-class = 'C'.
          ELSE.
            ls_sbook-wunit = 'KG'.
            ls_sbook-class = 'Y'.
          ENDIF.
          IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
            ls_sbook-invoice = 'X'.
          ENDIF.
          IF ls_sbook-bookid EQ 2.
            ls_sbook-cancelled = 'X'.
            ls_sbook-class = 'F'.
          ENDIF.
          APPEND ls_sbook TO pt_sbook.
        ENDDO.
      ENDDO.
    ENDFORM.                               " generate_entries
    *       CLASS event_responder IMPLEMENTATION
    CLASS lcl_event_responder IMPLEMENTATION.
      METHOD refresh_changed_data.
        BREAK-POINT.  
      ENDMETHOD.                    "click
    ENDCLASS.                    "event_responder IMPLEMENTATION

  • How to display data in alv through double click

    Hello Friends,
    I am new to this community,please tell me if I make any mistake while posting.
    Friends I had written this code. ALV is displayed at first time but when I am double clicking on the row then error is coming related to mismatch of actual and formal paramaters while calling function 'USER_COMMAND'. I am unable to locate where the error is. Please help me out.
    REPORT  ZALV12.
    TYPE-POOLS SLIS.
    DATA: it_vbak type standard table of VBAK,
          it_vbap type table of VBAP.
    DATA: wa_vbak like line of it_vbak,
          wa_vbap like line of it_vbap.
    DATA syrepid like sy-repid.
    DATA:fld_vbak type SLIS_T_FIELDCAT_ALV,
          fld_vbap type SLIS_T_FIELDCAT_ALV.
    DATA:fld_wa_vbak type SLIS_FIELDCAT_ALV,
         fld_wa_vbap type SLIS_FIELDCAT_ALV.
    DATA:vevent type SLIS_T_EVENT,
         waevent type SLIS_ALV_EVENT.
    DATA:LST_HEADR type SLIS_T_LISTHEADER.
    DATA title_alv type LVC_TITLE value 'LIST FOR VBAK'.
    INITIALIZATION.
    syrepid = sy-repid.
    perform get_event.
    perform populate_event.
    perform set_list_headr using LST_HEADR.
    perform field_cat.
    START-OF-SELECTION.
    .....                       "code for displaying data from table VBAK in ALV.
    form USER_COMMAND using R_UCOMM type SY-UCOMM.           "error is in this function.
        data r_selfield type SLIS_SELFIELD.
        case R_UCOMM.
         when '&IC1'.
           read table it_vbak into wa_vbak index r_selfield-TABINDEX.
            perform data_select.
            perform list_heading using LST_HEADR.
            perform event_get.
            perform build_event.
            perform alv_display.
        endcase.
    endform.
    form data_select.
       select * from VBAP into table it_vbap up to 20 rows.
    endform.
    form list_heading using i_lst type SLIS_T_LISTHEADER.
       data HLINE type SLIS_LISTHEADER.
       HLINE-TYP = 'H'.
       HLINE-INFO = 'FOR VBAP'.
       append HLINE to i_lst.
    endform.
    form alv_display.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           I_CALLBACK_PROGRAM                = syrepid
          I_STRUCTURE_NAME                  = 'VBAP'
           I_GRID_TITLE                      = 'SCREEN2_VBAP'
         TABLES
           T_OUTTAB                          = it_vbap
       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.
       form event_get.
         CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
             I_LIST_TYPE           = 0
         IMPORTING
             ET_EVENTS             = vevent
         EXCEPTIONS
           LIST_TYPE_WRONG       = 1
           OTHERS                = 2
         IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
      endform.
      form build_event.
        read table vevent into waevent with key name = 'TOP_OF_PAGE'.
        if sy-subrc = 0.
          waevent-form = 'F_TOP_OF_PAGE'.
          modify vevent from waevent transporting form
          where name = 'TOP_OF_PAGE'.
          endif.
      endform.
      form F_TOP_OF_PAGE.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY       = LST_HEADR
          I_LOGO                   =
          I_END_OF_LIST_GRID       =
          I_ALV_FORM               =
      endform.

    You missed one paramete in user_command form
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
    Regards,
    Raymond

  • Sorting ALV grid by clicking on header.

    Hey everyone.
    I've got a report displaying an ALV grid where I really don't want to have the toolbar for it showing, so i've taken that out. But I would like to be able to sort the data in the grid by clicking on a field in the header.
    I've seen this in some standard SAP programs, is it very easy to implement?
    Any help much appreciated,
    Cheers.

    Hi,
    Go through the following link.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    hope it helps.
    Regards
    Rajesh Kumar

  • Problem in handling double click in the second alv grid control

    Hi all,
    I have a screen. In the screen , I have 2 custom container and each custom container has 1 alv grid control.
    I need to handle double click event for both of alv grid controls in my screen.
    I defined 2 local event handler class for each alv grid and defined 2 handle_double_click event.
    In the first Alv grid double click works fine , everything is ok, world is peaceful.
    But in the second alvgrid, the row parameters (E_ROW, E_COLUMN, ES_ROW_NO) comes initial so i cannot handle it.
    All i need is to call a different transaction (displaying the equipment-IE03) when user double-click on a field in the second alv grid control. I tried to use hotspot_click event too but it does'nt give the row id either.
    I read some posts in the forms ([Double click event of alv grid control|Double click event of alv grid control]).
    I tried everything but nothing works.
    Please help. Your answers will be appreciated.

    Hello Eagle
    I am not sure where the problem lies in your case but sample report ZUS_SDN_THREE_ALV_GRIDS_01 shows that you can always find out the current cell after the double-click event (in any case you have the current cell already as IMPORTING parameters of the event):
    *& Report  ZUS_SDN_THREE_ALV_GRIDS_01
    *& Flow logic of screen '0100' (no screen elements, ok-code => GD_OKCODE):
    **    PROCESS BEFORE OUTPUT.
    **      MODULE STATUS_0100.
    **    PROCESS AFTER INPUT.
    **      MODULE USER_COMMAND_0100.
    *& Thread: problem in handling double click in the second alv grid control
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1172052"></a>
    REPORT  zus_sdn_three_alv_grids_01.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_splitter_2    TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      go_grid3         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_outtab        TYPE STANDARD TABLE OF vbak,
      gt_outtab_2      TYPE STANDARD TABLE OF vbap,
      gt_outtab_3      TYPE STANDARD TABLE OF vbep.
    **PARAMETERS:
    **  p_bukrs          TYPE bukrs  DEFAULT '1000'.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_row      TYPE lvc_s_row,
          ms_col      TYPE lvc_s_col.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_outtab      TYPE vbak,
          ls_outtab_2    TYPE vbap,
          ls_outtab_3    TYPE vbep.
        "   Initialize class data
        CLEAR: ms_row,
               ms_col.
        CASE sender.
          WHEN go_grid1.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_ITEMS'
    *          IMPORTING
    *            rc       =
          WHEN go_grid2.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_SCHEDULE_LINES'
    *          IMPORTING
    *            rc       =
          WHEN go_grid3.
    **        READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
    **        CHECK ( ls_vbap-matnr IS NOT INITIAL ).
    **        SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
    **        CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  vbak INTO TABLE gt_outtab UP TO 100 ROWS.
      PERFORM init_controls.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_outtab
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_2.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_outtab_2    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_3.
      CALL METHOD go_grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBEP'
        CHANGING
          it_outtab        = gt_outtab_3    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "ORDERS"
    *  SET TITLEBAR 'xxx'.
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Refresh display of detail ALV list
      CALL METHOD go_grid3->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        " Double-click on first or second ALV grid
        WHEN 'GET_ITEMS'  OR
             'GET_SCHEDULE_LINES'.
          PERFORM get_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 2
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_left.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
    * Create 2nd splitter container
      CREATE OBJECT go_splitter_2
        EXPORTING
          parent            = go_cell_left
          rows              = 2
          columns           = 1
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent = go_cell_top
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent = go_cell_bottom
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid3
        EXPORTING
          i_parent = go_cell_right
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  GET_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_details .
    * define local data
      DATA: ls_row      TYPE lvc_s_row,
            ls_col      TYPE lvc_s_col.
      data: ls_outtab   type vbak,
            ls_outtab_2 type vbap,
            ls_outtab_3 type vbep.
      BREAK-POINT.
      CASE gd_okcode.
        WHEN 'GET_ITEMS'.
          CALL METHOD go_grid1->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          read TABLE gt_outtab into ls_outtab index ls_row-index.
          refresh: gt_outtab_2,
                   gt_outtab_3.
          SELECT        * FROM  vbap into TABLE gt_outtab_2
                 WHERE  vbeln  = ls_outtab-vbeln.
        WHEN 'GET_SCHEDULE_LINES'.
          CALL METHOD go_grid2->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          READ TABLE gt_outtab_2 into ls_outtab_2 index ls_row-index.
          refresh: gt_outtab_3.
          SELECT        * FROM  vbep into TABLE gt_outtab_3
                 WHERE  vbeln  = ls_outtab_2-vbeln
                 AND    posnr  = ls_outtab_2-posnr.
        WHEN OTHERS.
          RETURN.
      ENDCASE.
      IF ( lcl_eventhandler=>ms_row = ls_row  AND
           lcl_eventhandler=>ms_col = ls_col ).
        MESSAGE 'Current cell identical'  TYPE 'I'.
      ELSE.
        MESSAGE 'Current cell NOT identical'  TYPE 'I'.
      ENDIF.
    ENDFORM.                    " GET_DETAILS
    Regards
      Uwe

  • Problem with ALV Grid (created via FM)

    Dear forumers,
    When double-clicking on any data row of an ALV grid, the following runtime error occurs:
    Runtime error: PERFORM_NOT_FOUND
    Exception: CX_SY_DYN_CALL_ILLEGAL_FORM
    Short Text
    =======
    Call (PERFORM) to a non-existent routine.
    What happened?
    ==========
    There exist various options:                                                     
    Error in the ABAP Application Program                                                                               
    The current ABAP program "SAPLSLVC_FULLSCREEN" had to be terminated
    because it has come across a statement that unfortunately cannot be executed.                   
    or                                                                               
    Error in the SAP kernel.                                                         
    The current ABAP "SAPLSLVC_FULLSCREEN" program had to be terminated because the  
    ABAP processor detected an internal system error.
    How can I resolve this error for an ALV grid? The ALV grid is created via the FM, 'REUSE_ALV_GRID_DISPLAY' and the field catalog is built via the FM, 'REUSE_ALV_FIELDCATALOG_MERGE'.
    Please help. Thanks so much.
    I also noticed in the Data Browser, SE16 - that if the table contents are displayed in an ALV Grid, double-clicking on any data row will not generate the same error. It also has an additional column on the leftmost to aid the data row selection. Any other ideas on this?
    Edited by: Deborah Tan on Jun 23, 2010 8:16 AM

    Hi Deborah,
    While calling 'REUSE_ALV_GRID_DISPLAY', You should have also passed the parameter I_CALLBACK_USER_COMMAND with any form name, or You have passed table IT_EVENTS with form name 'USER_COMMAND' with a form mentioned in it.
    If You do not require any user interaction on your ALV, comment the line where I_CALLBACK_USER_COMMAND is passed, or delete the line for 'USER_COMMAND' from the table that is passed in IT_EVENTS.
    Else, if You require user interaction, You need to code a form for user command in your program as FORM_USER_COMMAND USING  OK_CODE  SELFIELD.
    Remember the name of the form (for e.g. 'FORM_USER_COMMAND') should be the same that you pass in CALLBACKUSER_COMMAND or the one in 'USER_COMMAND' in table for IT_EVENTS.
    Regards,
    Birendra

  • Event for the List Box in ALV Grid Control

    Hello,
    I have the below urgent requirment.
    I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
    For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
    Early reply is hightly appreciated.
    Priya

    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         COMISN(10),
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(20),
        <b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
         END OF ITAB.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    <b>**Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER,</b>
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
      ENDMETHOD.                    "handle_double_click
    <b>**Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
        DATA: X_CHANGE TYPE LVC_S_MODI,
                X_FINAL TYPE ITAB,
                L_FLAG,
                LS_OUTTAB LIKE LINE OF ITAB.
        DATA: LS_EDIT TYPE LVC_S_STYL,
              LT_EDIT TYPE LVC_T_STYL.
        LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
          IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          else.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          ENDIF.
        ENDLOOP.
        CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
          EXCEPTIONS
            FINISHED = 1
            OTHERS   = 2.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED</b>
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
       <b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
    <b>  CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    <b>  SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_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_APPEND_ROW.
      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_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
      X_FIELDCAT-FIELDNAME = 'COMISN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-EDIT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'S/W Engineer'.
      LS_DRAL-INT_VALUE =  'S/W Engineer'.
      APPEND LS_DRAL TO LT_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'Manager'.
      LS_DRAL-INT_VALUE =  'Manager'.
      APPEND LS_DRAL TO LT_DRAL.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    Regards
    vijay

  • Reg: Top_Of_List Events in ALV GRID Display

    Hi ,
    How can i use the the the Top_of_list Event Alv grid Disply.
    I have passed Events table with event name and form name to GRID FM it_events.
    Form details:-
    T_LISTHEADER header deatils table with data. . 
    FORM TOP_OF_LIST.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY = T_LISTHEADER.
    ENDFORM.
    But still its not calling the form and also end_of list is working with same coding but top_of_list is not  working can u give solution for this.
    Regards,
    raj

    Hi Rajviji,
    Please change the coding to below :-
    *& Report  ZR2K9_ALV008
    REPORT  alv_top_of_list
    TABLES : t001.
    TYPE-POOLS: slis.
    DATA : w_repid LIKE sy-repid.
    TYPES : BEGIN OF ty_comp.
            INCLUDE STRUCTURE t001.
    TYPES : END OF ty_comp.
    DATA: T_EVENTS  TYPE slis_t_event.
    DATA: WA_EVENTS   TYPE slis_alv_event .
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE slis_fieldcat_alv.
    DATA : it_comp TYPE TABLE OF ty_comp.
    INITIALIZATION.
      w_repid = sy-repid.
    *Need to change here
    wa_events-name = 'TOP_OF_PAGE'.       "Instead of TOP_OF_LIST
    wa_events-form = 'TOP_OF_PAGE'.
    APPEND wa_events TO t_events.
    START-OF-SELECTION.
      SELECT * FROM t001 INTO TABLE it_comp up to 20 rows.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = w_repid
          i_internal_tabname     = 'IT_COMP'
          I_STRUCTURE_NAME       = 't001'
          i_inclname             = w_repid
        CHANGING
          ct_fieldcat            = it_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          it_fieldcat                 = it_fieldcat[]
          IT_EVENTS                    = T_EVENTS
        TABLES
          t_outtab                    = it_comp
        EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.
    FORM TOP_OF_PAGE.             "Form Name Changed
    DATA: T_LISTHEADER   TYPE SLIS_T_LISTHEADER.
    DATA: LS_LISTHEADER TYPE SLIS_LISTHEADER.
    CLEAR LS_LISTHEADER.
    LS_LISTHEADER-TYP  = 'S'.
    LS_LISTHEADER-KEY  = 'Po Heder Details :-'.
    APPEND LS_LISTHEADER  TO T_LISTHEADER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY = T_LISTHEADER.
    ENDFORM.
    Regards
    Sandipan

  • Strange navigation in ALV hot-spot.

    Hi All,
    I have a strange problem, which I hope to get som advice about.
    Anyway I have created an ALV-report with hot-spot.
    The hot-spot executes the line below and of course it "jumps" to VA03.
    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    The strange thing happens when I press 'F3' and returns to the ALV.
    The first time I do this, - it works fine, but when I 're-click' on the hot-spot Im again directed to transaction VA03.
    Now have to press 'F3' twice to get back to the ALV.
    Same thing happens when I 're-re-click' the hot-spot. But now I have to press 'F3' three times.
    Does anyone have an Idea how to solve this?
    I use the event to handle the hot-spot and I have attached the PBO snippet below to ease your understanding of my program.
    Please feel free to ask for more information
    Thanks in advance
    Lars Bernstorff Hansen
    CLASS cl_event_receiver DEFINITION.
      PUBLIC SECTION.
        DATA: t_utab_unsend TYPE zsd_tt_utab_unsend_mail
            , t_utab_send   TYPE zsd_tt_utab_send_mail.
        METHODS: handle_hotspot_click
          FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id.
    MODULE status_0100 OUTPUT.
      DATA: et_index_columns  TYPE lvc_t_col
          , i_structure_name  TYPE dd02l-tabname
          , is_layout         TYPE lvc_s_layo
          , it_fieldcatalog       TYPE lvc_t_fcat
          , i_gridtitle       TYPE lvc_title
          , linetype          TYPE string
          , itabref           TYPE REF TO data
          , ls_fcat           TYPE lvc_s_fcat.
      FIELD-SYMBOLS: <psaareatab>  TYPE STANDARD TABLE
                   , <psaareatab2> TYPE STANDARD TABLE.
      IF p_r1 = lcl_initialization=>c_x.
        linetype         = 'ZSD_UTAB_UNSEND_MAIL'.
        i_gridtitle      = 'Ukomplette ordrer - ej sendte'(200).
        i_structure_name = 'ZSD_UTAB_UNSEND_MAIL'.
      ELSE.
        linetype         = 'ZSD_UTAB_SEND_MAIL'.
        i_structure_name = 'ZSD_UTAB_SEND_MAIL'.
        i_gridtitle      = 'Komplette ordrer - sendte'(201).
      ENDIF.
      CREATE DATA itabref TYPE STANDARD TABLE OF (linetype).
      ASSIGN itabref->* TO <psaareatab>.
      IF p_r1 = gc_x.
        ASSIGN gt_utab_unsend TO <psaareatab>.
      ELSE.
        ASSIGN gt_utab_send TO <psaareatab>.
      ENDIF.
      SET TITLEBAR  'MAIN100'.
      SET PF-STATUS 'MAIN100'.
      IF go_custom_container IS INITIAL.
        CREATE OBJECT go_custom_container
          EXPORTING
            container_name = go_container.
        CREATE OBJECT go_grid
          EXPORTING
            i_appl_events = lcl_initialization=>c_x
            i_parent      = go_custom_container.
      ENDIF.
      lcl_initialization=>gxt_utab_unsend[] = gt_utab_unsend[].
      lcl_initialization=>gxt_utab_send[]   = gt_utab_send[].
      lcl_initialization=>bukrs             = p_bukrs.
      lcl_initialization=>r1                = p_r1.
      " Create handler.
      CREATE OBJECT event_receiver.
      " Register handler for events.
      SET HANDLER event_receiver->handle_hotspot_click FOR go_grid.
      CALL METHOD r_present_result->set_layout( CHANGING is_layout = is_layout ).
      " Create field catalog.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = i_structure_name
        CHANGING
          ct_fieldcat      = it_fieldcatalog.
      " Hotspot fields.
      CALL METHOD r_present_result->set_fieldcatalog
        EXPORTING
          i_r1            = p_r1
        CHANGING
          it_fieldcatalog = it_fieldcatalog.
      lcl_initialization=>it_fieldcatalog[] = it_fieldcatalog[].
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = i_structure_name
          is_layout        = is_layout
        CHANGING
          it_fieldcatalog  = it_fieldcatalog
          it_outtab        = <psaareatab>.
      CALL METHOD go_grid->set_gridtitle
        EXPORTING
          i_gridtitle = i_gridtitle.
    ENDMODULE.                 " STATUS_0100  OUTPUT

    Hi.,
    Please Share your solution here.. It will be useful for others who are facing this kind of problem..!!
    Thanks & Regards,
    Kiran

Maybe you are looking for

  • My iTunes keeps freezing during syncing and wont let me put any music on. What do I do?

    I have a PC and the newest iPod touch. I was receiving error message -54 while syncing recently so i checked on this site and found out that some of my files could be locked. Sure enough I went through all of my files, found and deleted all the locke

  • Can I take an itunes credit from one Apple ID and send it to another?

    I purchased a gift card for my son, but when checking for the email, it added the money to my account.  How can I send it to his account?

  • Can't copy files to iDisk from Finder

    Good Day, I am trying to copy a file from my desktop to my iDisk. I have shown my iDisk in the Finder Prefs. I have also done Go->iDisk->My iDisk. The iDisk folder shows in the finder with several folders inside it (none of which I created). I DO NOT

  • FTP receiver adapter - end of line ,marker

    Hi, i'm facing a really strange problem. I'm putting a file on  a FTP server from one of our customers. i'm using text conversion with CR* LF** as end of line marker. In D and Q where i'm putting the file on our own FTP server everything is ok. But i

  • List of Deleted sharepoint sites

    SharePoint Experts, How do I genererate a list of deleted sharepoint sites? I know there's a command Get-SPDeletedSite but I think that's for a specific site where you know what site and ID, etc. Thanks, Hubble