Alv grid key event

Hi,
is it possible to register key press event in alv grid ? I want to detect ctrl button was pressed than call same action.
help
thx
Message was edited by:
        mk kn

Hi,
did you find a solution? I have the same question.

Similar Messages

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • Issue with ALV Grid and events

    Hi,
    I am creating an ALV Grid with fields Matnr,Charg,Labst,Meins. The first three fields are editable and the last (MEINS) is read only.
    Now I am trying to fill the MEINS field programmaticly after entering the MATNR and confirm with enter/return.
    I think that I have to "overload" the enter event of the alv grid to fill the MEINS everytime when a MATNR was entered. But I don't know how I could implementing this. Could you give me a hint how I could solve this problem?
    (The behavior should look like in transaction MIGO)
    Thanks

    Hi Alex
    When you press enter an event is triggerd and function code is filled in sy-ucoom or you can say in ok_code. At that time PAI event occurs. In PAI of that screen you need to check ok_code and load new data in table which you passed to ALV and also refresh the ALV.
    data: ok_code like sy-ucomm.
    PAI----screen 100
    case ok_code.
    when 'ENTER'.
    select data
    and refresh ALV
    then again call
    funtion to display ALV
    Regards
    Aditya

  • Know alv grid on event click

    Hi,
    Is it possible to know the alv grid (TYPE REF TO cl_gui_alv_grid) on the event click? In fact, on a screen, I have 2 alv grids and I would like to store the alv grid name for a process at click moment.
    Thanks.
    Edited by: Xavier Couloumies on Sep 12, 2008 2:07 PM

    you might declare two differents methods for the two grids
    PUBLIC SECTION.
      METHODS:
        HANDLE_DOUBLE_CLICK
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN,
        HANDLE_DOUBLE_CLICK2
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN.
    something like that
    then , in the implementations do something like this
    METHOD HANDLE_DOUBLE_CLICK.
         PERFORM X USING GRID = '1'.
    ENDMETHOD.
    METHOD HANDLE_DOUBLE_CLICK2.
         PERFORM X USING GRID = '2'.
    ENDMETHOD.
    and do the respective validations on that form
    hope this help

  • ALV Grid Click Event Handler

    Haw can i handle the single-click mouse event in a ALV Grid class implementation...???
    The LEFT_CLICK_RUN and RIGHT_CLICK don't help's me....
    Someone can update me...???
    Thank's...

    hi,
    you can just set all the field as hotspot , and implement the event hotspot_click.
    check the code below:
    pay attention the words in red
    REPORT  ZDAVID_ALV1.
    CLASS ZCL_EVENT_RECEIVER DEFINITION DEFERRED." Declear a custom class
    tables zemployee.
    data: ls_fcat type lvc_s_fcat,
          li_fcat type lvc_t_fcat,
          ls_layo type lvc_s_layo,
          ls_color type lvc_s_scol,
          LO_EVENT TYPE REF TO ZCL_EVENT_RECEIVER.
    data: container type ref to cl_gui_custom_container,
          grid type ref to cl_gui_alv_grid.
    types: begin of ty_emp,
      emp_x type c,
      zemp_id type zemp_id,
      zemp_name type zemp_name,
      zemp_salary type zemp_salary,
      zemp_dpart type zemp_dpart,
      rowcolor(4) type c,
      cellcolor type lvc_t_scol,
      end of ty_emp.
    data: emp type table of ty_emp,
          wa_emp type ty_emp,
          wcellcolor type lvc_s_scol.
    call screen 9000.
    CLASS ZCL_EVENT_RECEIVER DEFINITION." class definition
      PUBLIC SECTION.
        methods:
          handle_single_click
             for event hotspot_click of cl_gui_alv_grid
               importing
                 e_row_id es_row_no e_column_id.
      PRIVATE SECTION.
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    *   LCL_EVENT_RECEIVER (DEFINITION)
    *  ===============================================================
    *   LOCAL CLASSES: IMPLEMENTATION
    *  ===============================================================
    *   CLASS LCL_EVENT_RECEIVER (IMPLEMENTATION)
    *   IN THIS EXAMPLE, ONLY EVENT DOUBLE_CLICK IS CAUGHT
    CLASS ZCL_EVENT_RECEIVER IMPLEMENTATION." implementation
    method handle_single_click.
         message e_column_id-fieldname type 'I'.
       endmethod.
    ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
    form sub_get_data.
      select * from zemployee into corresponding fields of wa_emp.
        wa_emp-emp_x = 'X'.
        if wa_emp-zemp_id = '171184'.
    "        wa_emp-rowcolor = 'C610'.
           wcellcolor-fname = 'ZEMP_ID'.
           wcellcolor-color-col = '7'.
           wcellcolor-color-int = '1'.
           append wcellcolor to wa_emp-cellcolor.
          ENDIF.
        append wa_emp to emp.
        CLEAR WA_EMP. clear wcellcolor.
        endselect.
      endform.
    form sub_create_obj.
      if container is initial.
        create object container
         exporting
           container_name = 'MYCONT'.
       endif.
       if grid is initial.
         create object grid
          exporting
            i_parent = container.
        endif.
      endform.
    form sub_call_alv.
        call method grid->set_table_for_first_display
        exporting
          is_layout                     = ls_layo
        changing
          it_outtab                     = emp
          it_fieldcatalog               = li_fcat
          "it_sort                       = i_sort2
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
        if sy-subrc <> 0.
          endif.
        create object lo_event.
        set handler lo_event->handle_single_click for grid." set handler
      endform.
    form sub_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'EMP_X'.
      ls_fcat-coltext = 'Check'.
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
      ls_fcat-hotspot = 'X'." hotspot
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_ID'.
      ls_fcat-coltext = 'ID'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_NAME'.
      ls_fcat-coltext = 'Name'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_SALARY'.
      ls_fcat-coltext = 'Salary'.
      ls_fcat-do_sum = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_DPART'.
      ls_fcat-coltext = 'Department'.
      ls_fcat-drdn_hndl = '1'.
      ls_fcat-edit = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      endform.
    form sub_layout.
      ls_layo-zebra = 'X'.
      ls_layo-INFO_FNAME = 'ROWCOLOR'.
      endform.
    module pbo output.
       perform sub_get_data.
       perform sub_fcat.
       perform sub_layout.
       perform sub_create_obj.
       perform sub_drop.
       perform sub_call_alv.
      endmodule.
    module pai input.
      data: ok_code type sy-ucomm.
      case ok_code.
        when 'SHOW'.
          MESSAGE 'D' TYPE 'I'.
        WHEN 'EXIT'.
          leave program.
        WHEN OTHERS.
          ENDCASE.
      clear ok_code.
      endmodule.
    form sub_drop.
      data: wa_drop type lvc_s_drop,
            drop type lvc_t_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Dev'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Testing'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Admin'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'NSS'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Finance'.
      append wa_drop to drop.
      clear wa_drop.
      call method grid->set_drop_down_table
        EXPORTING
          it_drop_down = drop.
      endform.
    *&      Module  set_gui  OUTPUT
    *       text
    MODULE set_gui OUTPUT.
      set pf-status 'PF_GUI'.
    ENDMODULE.                 " set_gui  OUTPUT

  • ALV Grid-- "DOUBLECLICK EVENT" doesnt work with "DATA_CHANGED_FINISHED" ??

    Hello at all,
    i have an ALV-Grid with 2 different Events.
    .....First Event: "Doubleclick"
    Second Event: "data_changed_finished"
    If i click to a column than it should be trigger the Doubleclick Event.
    And if i write some text in the column and "Press" Enter than it should be trigger the Event data_changed_finished.
    But the Problem is:
    If i click double to any column it will allways trigger the Event datachanged_finished_
    But if i replace the Event data_changed_finished with Event data_change, than it will be work.
    What can I do to resolve the Problem??
    Please give me some ideas, what i can do!!!
    With kind regards
    Ersin

    Hi,
    Try to do SET HANDLER first for Hanld_Double_Click Event then Handle Data Changed
    Thanks,
    Pramod

  • ALV grid Enter event

    Hi
    I have a grid view where I can insert a new line and enter values in 2 of its columns. I wish to update other columns based on the values that the user enters in the 2 columns.
    I have tried both of the following but neither gives me exactly what I want :-
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.     " and
         i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    I want the user to be able to TAB (or mouse) between the 2 columns. After entering a value and TABing away from the column then the other columns in the row should be updated. When the user is finished experimenting with values, he hits ENTER then the 2 columns should cease to be editable (I know how to enable/disable edit on cells).
    If I use mc_evt_modified then TABing between the 2 columns updates the other columns nicely. However I cannot distinguish between TAB and ENTER and so cannot switch of EDIT when the user hits ENTER.
    If I use mc_evt_enter then the other columns are not updated when I TAB away. This is of course correct, but not what I want. When the user hits ENTER then everything is updated and I could switch of Edit at this point.
    It looks like I need a different event to DATA_CHANGED and DATA_CHANGED_FINISH. This event should be invoked when the user hits ENTER even if nothing has changed in the Grid. I have tested DOUBLE_CLICK but it does not work.
    So what I really want is for the user to see the results of his changes imeadiately (using the TAB) and then to finish the insert by hitting ENTER. Remember that since the user TABed away to see the updated columns, a subsequent ENTER will not result in a DATA_CHANGED event since the Grid is unchanged.
    Perhaps I am designing a bad GUI. When does one normaly switch off EDIT on cells in a newly inserted line.
    Peter

    can't you add a button instead of enter to switch off EDIT ?

  • Displaying items in a single line in ALV grid using  ALV_TOP_OF_PAGE.

    Hello Guys,
    I am having a problem in displaying items in a single line in the ALV Grid using event ALV_TOP_OF_PAGE.
    My requirement is to group items on a single line i.e. in the example below, Vendor code and posting date are on the same line. The next line the prints Vendor Name and Document no.
    Vendor Code: 123123                               Posting Date : 01.01.2011
    Vendor Name: ABCD                                 Document No: 152246598.
    Here is my code in subroutine 'ALV_TOP_OF_PAGE', 
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Vendor Code'.
      APPEND wa_list_comments TO it_list_comments.
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Posting Date'.
      APPEND wa_list_comments TO it_list_comments.
    The above code prints in the following format i.e one below the other,
    Vendor Code: 123123                              
    Posting Date : 01.01.2011.
    I also tried using HTML_TOP_OF_PAGE, but it didn't work.
    Can anybody please help me out with this.
    Regards,
    Danish.

    Hi Danish,
    Your problem is with the alignment and you need some fix positions .
    The solution i feel is u can use as below :
    In CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    use 
    i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'.
    Now on calling routine call use cl_dd_document class :
    FORM html_top_of_page USING document TYPE REF TO cl_dd_document .
    data : doctable TYPE REF TO cl_dd_table_element,
              col1_t1 TYPE REF TO cl_dd_area,
              col2_t1 TYPE REF TO cl_dd_area,
              col1_t2 TYPE REF TO cl_dd_area,
              col2_t2 TYPE REF TO cl_dd_area.
    add quick table with five columns
        CALL METHOD lw_document->add_table
          EXPORTING
            no_of_columns               = 2
            border                      = '0'
         cell_background_transparent = ' '
            width                       = '100%'
          IMPORTING
            table                       = doctable.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t1.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t1.* Filling columns in row
    Call method doctable->new_row.
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t2.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t2.
    *Now adding the texts
    lw_text1 = 'your first text'
    CALL METHOD col1_t1->add_text
          EXPORTING
            text = lw_text.
    *Similarly add text for other columns
    *Adujust % in width to adjust the column as required
    Endform.
    Hope this will solve your problem .

  • ALV grid oo delete rows and update to table

    Hi all
      How can I delete one row and update to the db table?
    thanks

    Hi,
    Refer:-
    The ALV Grid has events data_changed and data_changed_finished. The former method is
    triggered just after the change at an editable field is perceived. Here you can make checks for
    the input. And the second event is triggered after the change is committed.
    You can select the way how the control perceives data changes by using the method
    register_edit_event. You have two choices:
    1. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.
    2. After the field is modified and the cursor is moved to another field: For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.
    To make events controlling data changes be triggered, you must select either way by
    calling this method. Otherwise, these events will not be triggered.
    To control field data changes, ALV Grid uses an instance of the class
    CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed.
    Using methods of this class, you can get and modify cell values and produce error messages.
    Hope this helps you.
    Regards,
    Tarun

  • ALV Grid - Add/Delete/Change Values

    Hi,
    I have an ALV Grid with editable fields. I know want to process the changed, deleted and added lines.
    Is it not possible to get the shown ALV table back?
    In the event DATA CHANGED I have only attributes and methods of CL_ALV_CHANGED_DATA_PROTOCOL. So I have a method to get deleted, changed and added rows. But this event is only thrown, when I press enter or something else, but not when I´m pressing the icon for "add" or "delete".
    End when the event is thrown, i´m only getting the changed data. In some case it´s not possible to react in the right way.
    For example:
    I have an internal table with 5 lines. I now build the alv grid with that table. When I´m now adding a line with the "add" Icon, the event is not thrown. But if I press enter, I can handle the event. In the event methods I now have one line in added data. But when I´m deleting and adding again, it sometimes "forget" some actions I have done. Isn´t there a better way to compare the changed data in ALV with my "real" internal table?
    Next example:
    If I´m adding a new line to the alv, I can compare the key of that line with the exisiting keys of my internal table. If the user has typed in a line with the same key, I can throw and error message.
    But when the user is changing a line it should be possible to update that line. But how to compare, if the line is a new addewd line or a changed line?
    I hope it´s not too complicated to understand!
    Reward points guaranteed!

    As we can now make our ALV Grid editable we may require controlling input data. The ALV Grid has events “data_changed” and “data_changed_finished”. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.
    You can select the way how the control perceives data changes by using the method “register_edit_event”. You have two choices:
    1. After return key is pressed: To select this way, to the parameter “i_event_id” pass “cl_gui_alv_grid=>mc_evt_enter”.
    2. After the field is modified and the cursor is moved to another field: For this, pass “cl_gui_alv_grid=>mc_evt_modifies” to the same parameter.
    To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.
    To control field data changes, ALV Grid uses an instance of the class “CL_ALV_CHANGED_DATA_PROTOCOL” and passes this via the event “data_changed”. Using methods of this class, you can get and modify cell values and produce error messages. Here are some of those methods:
    get_cell_value: Gets the cell value. You pass the address of the cell to the interface.
    modify_cell : Modifies the cell value addressed via parameters.
    add_protocol_entry : Add a log entry. You make use of standard message interface with message type, message id, etc…
    protocol_is_visible : Make the error table visible or not.
    refresh_protocol : Refreshing log entries.
    Table 16 – Methods to use for controlling data changes
    With the reference of the instance, you can reach information about modifications. These useful attribute tables are:
    MT_MOD_CELLS
    Contains addresses of modified cells with “row_id”s and “fieldname”s.
    MP_MOD_ROWS
    Contains modified rows. Its type is generic.
    MT_GOOD_CELLS
    Contains cells having proper values
    MT_DELETED_ROWS
    Contains rows deleted from the list
    MT_INSERTED_ROWS
    Contains rows inserted to the list
    Rgds
    Mohit

  • Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

    Hi guys,
    I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
    call method alv_grid->register_edit_event
                            exporting
                               i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
    Any advice or tips or sample code is greatly appreciated.
    Thanks,
    Shareen

    Hi Shareen,
    Handle the data_changed event in the grid.
    Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    Implementation:
      METHOD handle_data_changed.
        PERFORM validations USING er_data_changed.
      ENDMETHOD.
    FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
      DATA: ls_good TYPE lvc_s_modi.
      DATA  wa LIKE LINE OF lt_good_cells.
      CALL METHOD g_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      LOOP AT er_data_changed->mt_good_cells INTO ls_good.
        CASE ls_good-fieldname.
        WHEN 'FIELDNAME'. "Your fieldname
            CALL METHOD er_data_changed->get_cell_value "Get the changed value
              EXPORTING
                i_row_id    = ls_good-row_id
                i_fieldname = ls_good-fieldname
              IMPORTING
                e_value     = temp. "Your temp variable
            "Make your validations here.
        ENDCASE.
    Ps: Reward points if helpful.
    Regards,
    Wenceslaus.

  • Enter Key Event in Editable ALV Grid

    Hi all,
    I am trying to create and editable ALV grid using the REUSE ALV FM.
    On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
    Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
    Is it possible to capture the Enter keypress on the ALV grid?

    Hello Preet
    I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
    The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
    I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
    When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
    Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
    I assume that the logic will be similar using ALV function modules.
    Regards
       Uwe

  • How to capture the event in ALV grid display?

    Hi experts,
      How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
    regards,
    Arul Jothi.

    Hi Arul,
    Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
    Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
    If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • 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

  • Capturing the ALV Grid Event

    Hi Experts,
    I am working on ALV Grid , Data is Displayed in Grid well , But Can Any one please tell me how can i capture the event (back,exit and cancel) which is persent on standard toolbar on ALV Gried output .
    Rgds,
    Premraj

    Hello PremRaj ,
    Please find an dummy program to capture the events below:
    TYPE-POOLS slis.
    DATA: ITAB_EVENTS TYPE slis_t_event,
          WA_EVENTS TYPE SLIS_ALV_EVENT.
    DATA: IT_END TYPE SLIS_T_LISTHEADER,
          WA_END TYPE SLIS_LISTHEADER.
    ** This function module will get all the events present in alv into internal table itab_events*
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = ITAB_EVENTS
    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.
    ** With this read table statement itab_events is read for the desired event*+
    READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
      wa_eventS-form = 'END'.
      MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
      CLEAR wa_eventS.
    *Pass the ITAB_EVENTS created in this Function Module
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        IT_EVENTS                         = ITAB_EVENTS
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER           =
       ES_EXIT_CAUSED_BY_USER            =
       TABLES
         t_outtab                          = it_tab
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
    wa_eventS-form = 'END'.
    MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
    CLEAR wa_eventS.
    *in these statements ,the second line will automatically try to call subroutine with name end.
    FORM END.
    WA_END-TYP = 'S'.
    WA_END-KEY = TEXT-004.
    WA_END-INFO = SY-DATUM.
    APPEND WA_end TO IT_END.
    CLEAR WA_END.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = IT_END
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.
    Hope it helps you.
    Thanks Mansi
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 11:02 AM
    Edited by: MANSI  ASNANI on Jan 9, 2009 7:31 AM

Maybe you are looking for