ALV events

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

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

Similar Messages

  • ALV Event is malfunctioning

    Hello gurus,
    I created a workbench with an edittable ALV for its data. This ALV has several tabs, lets say 5 tabs with individual event handler declaration. Tabs 1, 2 & 3 shares the same event/class and method declaration. 4&5 shares also the same but different to 1,2, & 3.
    I have events handle data change and button click (for a column of buttons that pops up a screen when pressed), which are both standard toolbar. Then I also have event toolbar for my custom icon and event user command to handle these icons.
    I run my ALV, tabs 1,2 & 3 have their data first. Then I just copy these data going to tab4.
    On tab 4, whenever I click on the standard toolbar 'add row' (+ icon), it adds new row and triggers event handle data change.
    Now my problem is, whenever I click on any other icon that triggers alv event, instead of going to their respective event, it always go to the handle data change event. (i.e. when I click on my custom toolbar icon, instead of going to event user command, it triggers the handle data change. Same with when I click on any buttons under the button columns, it triggers handle data change.)
    Tab 1,2 & 3 works fine. But 4 & 5 are not. They have the same process and coded with the same logic. The only difference I see is that 4 & 5 has handle data change event while 1,2 & 3 have not.
    Please help me analysing what's really causing the issue and what solution to apply to handle this.
    Thanks,
    Sheera

    you need to set the subtotal option only to the dummy field. see the below code related.
      "no need of subtot option here..
      ls_sort-spos = 1.
      ls_sort-fieldname = 'EBELN'.
      ls_sort-tabname = 'ITAB'.
      ls_sort-up = 'X'.
      ls_sort-group = 'UL'.
      APPEND ls_sort TO it_sort.
      CLEAR ls_sort.
      ls_sort-spos = 2.
      ls_sort-fieldname = 'D'.
      ls_sort-tabname = 'ITAB'.
      ls_sort-up = 'X'.
      ls_sort-group = 'UL'.
      ls_sort-subtot = 'X'.           "Only specify here
      APPEND ls_sort TO it_sort.

  • ALV-Event data_changed after searchhelp with userdefined searchhelpexit

    Hi there ...
    I'm using an OO alv grid with an elementary searchhelp at defined fields.
    the search help uses an searchhelpexit, that simply filters data, to show the right stuff
    everything works fine!
    dependent on the returned value of the searchhelp, I need to trigger a recalculation of values.
    the alv-event "data_changed" looks interesting for that issue ... especially the flag "e_onf4_after" ...
    BUT: I don't know, when the flag is set :$
    the event is raised (with marked flags "e_onf4" and "e_onf4_before") before the Searchhelplist is displayed .... but I need to react AFTER the searchhelp is closed and the selected value is returned ...
    all I want to do is:
    trigger the recalculation after the user selected a value at the searchhelp
    can anybody help me in that case?!
    thanks a lot  & enjoy your weekend
    Markus

    Hi,
    You can call elementary search help like any popup screen
    with function F4IF_FIELD_VALUE_REQUEST.
    - Call f4 help manually in the event DATA_CHANGED
    - Process your recalculation
    - set values on cells..
    I hope it helps.

  • Need docu on alv events with examples

    hi experts,
    Need help on docu in <b>alv events</b> with exam</b>ples
    thanks in advance.

    Hi,
    Check this link..
    http://www.sap-basis-abap.com/abap/events-in-alv-and-their-fm.htm
    go through following links......
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
    Re: Performance Optimization for the following Code (URGENT & VERY IMPORTAN
    The main events in alv and their FM and why we use these:
    1. SLIS_PRINT_ALV.
    2. SLIS_T_LISTHEADER.
    3. SLIS_T_EVENT.
    4. SLIS_T_SORTINFO_ALV.
    5. SLIS_T_LAYOUT_ALV.
    6. SLIS_T_FIELDCAT_ALV.
    For more information check the following link:
    http://sap-img.com/abap/what-are-the-events-in-alv.htm
    Regards,
    Omkar.

  • Message handling in ALV events

    I have a screen with ALV Grid control. This grid has columns (attributes of more than one material). Now when I select more than one column and click on a button added on the ALV grid toolbar……it triggers a button click event and in the implementation I have  written a code to check whether the selected columns (ie attributes) are from same material or not….if not from same material it throws an error message (Message type E). Once the error message is displayed doing any operation exits from the program….as the Message type E exits from the program.
    The requirement is to remain on the same screen and not exit. Error will disappear only on selecting columns from the same material and press the button.
    Note : There are no input fields here. So the concept of Chain-EndChain doesn’t hold good.

    METHOD handle_user_command_mmv.
        DATA: lt_cols TYPE lvc_t_col,                       "Stores the selected columns
              wa_lt_cols LIKE LINE OF lt_cols,              "Work Area for the above
              skey TYPE char2,                              "To store the key of the selected material
              flag TYPE int1,                               "For getting the first entry in current field catalog
              errFlag TYPE int1,                            "Set if error occurs
              dupflag TYPE int1,                            "To check for invalid selection
              l_fld_name TYPE string,                       "String to hold dynamic column name
              it_curr_fcat TYPE lvc_t_fcat,                 "Current field catalog
              wa_curr_fcat LIKE LINE OF it_curr_fcat,       "Work Area for current field catalog
              it_new_fcat TYPE lvc_t_fcat,                  "New field catalog
              wa_new_fcat LIKE LINE OF it_new_fcat,         "Work Area for new field catalog
              it_sel_mat_fcat TYPE lvc_t_fcat,              "Selected materials field catalog
              wa_sel_mat_fcat LIKE LINE OF it_sel_mat_fcat, "Work Area for selected materials field catalog
              l_count_seq type int4.                         "Col position for the new table
        DATA: lt_fcat TYPE lvc_t_fcat.                  "New field catalog in which final data will be stored
    Structure to maintain the order of materials
        TYPES: BEGIN OF struct_mattab,
               matrkey TYPE char3,
               END OF struct_mattab.
        DATA: itab_mat_fcat TYPE TABLE OF struct_mattab,
              wa_mat_fcat LIKE LINE OF itab_mat_fcat,
              WA_G_MMV_F4_TAB LIKE LINE OF G_MMV_F4_TAB.
        CASE e_ucomm.
          WHEN 'MMV_CASCADE'.
    Get all selected columns in a temporary table
            CALL METHOD alv_grid_mmv->get_selected_columns
              IMPORTING
                et_index_columns = lt_cols[].
            flag = 1.
            dupflag = 1.
            l_count_seq = 1.
            errFlag = 0.
            CLEAR skey.
            LOOP AT lt_cols INTO wa_lt_cols.
              IF wa_lt_cols-fieldname <> 'LOCID' AND
                wa_lt_cols-fieldname <> 'TSYST' AND
                wa_lt_cols-fieldname <> 'MATNR' AND
                wa_lt_cols-fieldname <> 'CHARG' AND
                wa_lt_cols-fieldname <> 'DATUM' AND
                wa_lt_cols-fieldname <> 'DATE_MMV' AND
                wa_lt_cols-fieldname <> 'DOW' AND
                wa_lt_cols-fieldname <> 'INTNO' AND
                wa_lt_cols-fieldname <> 'MULTFLAG' AND
                wa_lt_cols-fieldname <> 'CELLIO_TAB' AND
                wa_lt_cols-fieldname <> 'CELLCOLOR_TAB' AND
                wa_lt_cols-fieldname <> 'LINECOLOR'.
    Get the key of the first column in the current field catalog other than the fixed columns
                IF flag = 1.
                  skey = wa_lt_cols-fieldname+7(2).
                  flag = flag + 1.
                ENDIF.
    Check if selected columns are from different materials or aggregate columns
                IF skey <> wa_lt_cols-fieldname+7(2).
                  dupflag = 2.
                ELSEIF wa_lt_cols-fieldname+7(2) = '00'.
                  dupflag = 3.
                ENDIF.
              ENDIF.
            ENDLOOP.
            <b>IF dupflag = 2.
              errFlag = 1.
              MESSAGE E067(OIJ_SP).
            ELSEIF dupflag = 3.
              errFlag = 1.
              MESSAGE E068(OIJ_SP).</b>       
             ELSE.
              CLEAR it_curr_fcat.
              CLEAR it_sel_mat_fcat.
              CLEAR it_new_fcat.
    Get the current field catalog
              CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
                IMPORTING
                  et_fieldcatalog = it_curr_fcat.
    If columns are not selected and the button is clicked
              IF SKEY EQ SPACE.
                IT_NEW_FCAT[] = IT_CURR_FCAT[].
              ELSE.
    Maintain the field catalog for the selected material in a temporary table
              LOOP AT it_curr_fcat INTO wa_curr_fcat.
                IF wa_curr_fcat-fieldname+7(2) = skey.
                  INSERT wa_curr_fcat INTO TABLE it_sel_mat_fcat.
                ENDIF.
    Inserting the aggregate and fixed columns into the new field catalog
               IF WA_CURR_FCAT-FIELDNAME EQ 'LOCID' OR
                WA_CURR_FCAT-FIELDNAME EQ 'TSYST' OR
                WA_CURR_FCAT-FIELDNAME EQ 'MATNR' OR
                WA_CURR_FCAT-FIELDNAME EQ 'CHARG' OR
                WA_CURR_FCAT-FIELDNAME EQ 'DATUM' OR
                WA_CURR_FCAT-FIELDNAME EQ 'DATE_MMV' OR
                WA_CURR_FCAT-FIELDNAME EQ 'DOW' OR
                WA_CURR_FCAT-FIELDNAME EQ 'INTNO' OR
                WA_CURR_FCAT-FIELDNAME EQ 'MULTFLAG' OR
                WA_CURR_FCAT-FIELDNAME EQ 'CELLIO_TAB' OR
                WA_CURR_FCAT-FIELDNAME EQ 'CELLCOLOR_TAB' OR
                WA_CURR_FCAT-FIELDNAME EQ 'LINECOLOR' OR
                WA_CURR_FCAT-FIELDNAME+7(2) EQ '00'.
                   WA_CURR_FCAT-COL_POS = l_count_seq.
                   APPEND WA_CURR_FCAT TO IT_NEW_FCAT.
                   l_count_seq = l_count_seq + 1.
               ENDIF.
              ENDLOOP.
    Sort the internal table to reflect ordering
              SORT IT_SEL_MAT_FCAT ASCENDING BY COL_POS.
              ENDIF.
            ENDIF.
    IF SKEY NE SPACE AND errFlag NE 1.
    Inserting the material columns into the new field catalog after cascading
         LOOP AT G_MMV_F4_TAB INTO WA_G_MMV_F4_TAB
                WHERE LOCID = G_LOCID.
              LOOP AT IT_SEL_MAT_FCAT INTO WA_SEL_MAT_FCAT.
                   CONCATENATE WA_SEL_MAT_FCAT-FIELDNAME(7) WA_G_MMV_F4_TAB-KEY INTO L_FLD_NAME.
                      LOOP AT IT_CURR_FCAT INTO WA_CURR_FCAT
                              WHERE FIELDNAME = L_FLD_NAME.
                         MOVE WA_SEL_MAT_FCAT-NO_OUT TO WA_CURR_FCAT-NO_OUT.
                         MOVE WA_SEL_MAT_FCAT-OUTPUTLEN TO WA_CURR_FCAT-OUTPUTLEN.
                         WA_CURR_FCAT-COL_POS = l_count_seq.
                         APPEND WA_CURR_FCAT TO IT_NEW_FCAT.
                         l_count_seq = l_count_seq + 1.
                     ENDLOOP.
              ENDLOOP.
            ENDLOOP.
    ENDIF.
    IF errFlag EQ 1.
    Get the current field catalog
              CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
                IMPORTING
                  et_fieldcatalog = it_curr_fcat.
      IT_NEW_FCAT[] = IT_CURR_FCAT[].
    ENDIF.
            CALL METHOD alv_grid_mmv->set_frontend_fieldcatalog
              EXPORTING
                it_fieldcatalog = it_new_fcat.
            CALL METHOD alv_grid_mmv->refresh_table_display.
    Saving the current fieldcatalog
            CLEAR g_itab_old_order.
            CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
              IMPORTING
                et_fieldcatalog = g_itab_old_order.
          WHEN 'MMV_COL_HDR_PREFIX'.
            CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
              IMPORTING
                et_fieldcatalog = lt_fcat.
            gv_mmv_col_hdr_setting = 1.
            PERFORM set_mmv_col_hdr_txt
              CHANGING lt_fcat
                       gv_mmv_col_hdr_setting.
            CALL METHOD alv_grid_mmv->set_frontend_fieldcatalog
              EXPORTING
                it_fieldcatalog = lt_fcat.
            CALL METHOD alv_grid_mmv->refresh_table_display.
          WHEN 'MMV_COL_HDR_SUFFIX'.
            CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
              IMPORTING
                et_fieldcatalog = lt_fcat.
            gv_mmv_col_hdr_setting = 2.
            PERFORM set_mmv_col_hdr_txt
              CHANGING lt_fcat
                       gv_mmv_col_hdr_setting.
            CALL METHOD alv_grid_mmv->set_frontend_fieldcatalog
              EXPORTING
                it_fieldcatalog = lt_fcat.
            CALL METHOD alv_grid_mmv->refresh_table_display.
          WHEN 'MMV_COL_HDR_1ST_PREFIX'.
            CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
              IMPORTING
                et_fieldcatalog = lt_fcat.
            gv_mmv_col_hdr_setting = 3.
            PERFORM set_mmv_col_hdr_txt
              CHANGING lt_fcat
                       gv_mmv_col_hdr_setting.
            CALL METHOD alv_grid_mmv->set_frontend_fieldcatalog
              EXPORTING
                it_fieldcatalog = lt_fcat.
            CALL METHOD alv_grid_mmv->refresh_table_display.
          WHEN 'MMV_COL_HDR_1ST_SUFFIX'.
            CALL METHOD alv_grid_mmv->get_frontend_fieldcatalog
              IMPORTING
                et_fieldcatalog = lt_fcat.
            gv_mmv_col_hdr_setting = 4.
            PERFORM set_mmv_col_hdr_txt
              CHANGING lt_fcat
                       gv_mmv_col_hdr_setting.
            CALL METHOD alv_grid_mmv->set_frontend_fieldcatalog
              EXPORTING
                it_fieldcatalog = lt_fcat.
            CALL METHOD alv_grid_mmv->refresh_table_display.
        ENDCASE.
      ENDMETHOD.                "handle_user_command_mmv

  • ALV Event for data input

    I have an internal table . One of the fields can take input in the ALV grid using ABAP objects.
    When the user enters a value in this field , I would like to capture the values in all the cells of all the fields that are adjaccent to this editable field.
    I think I will have to use data_changed event . The SLIS examples are a bit complex, If there is a simpler example to show how this can be done , it will be great.

    That's right, that is the event that you want to use.  See example programs which start with BCALV_EDIT*
    Regards,
    Rich Heilman

  • Alv event on keyboard arrow (up or down)

    Hello,
    i hope that someone can help me with my problem.
    i am looking for an event in alv that reacts on the keyboard arrows: cursor up or down.
    i know that i can use doubleclick or hotspot event, but my customer wants it by cursor up or down.
    i habe a subscreen under the alv-grid, where the details are shown.
    and when someone 'walks' through die alv-grid with cursor up or down, the details should be displayed - how can i do this ?
    Doubleclick ist second best...
    Thanks
    Helmut

    hi ,
    try using Event DELAYED_CHANGED_SEL_CALLBACK. The best  example of this event is WE02. When you select one record with a delay of 1 sec you get the details of idoc below. Try and see if meets ur req.
    Raj D

  • ALV event ON_CLICK - find out selected row?

    I have an ALV table and in one of the columns I display a linkToAction in each cell.
    When the link is clicked, i go to the ON_CLICK event handler and try to find out, which row is selected.
    For this, I can take the attribute "INDEX" of the parameter "R_PARAM", and read the context with the given index.
    METHOD alv_event_on_click .
       DATA lo_nd_my_node    TYPE REF TO if_wd_context_node.
       DATA lt_my_table          TYPE wd_this->elements_my_table.
       DATA ls_my_structure    TYPE wd_this->element_my_struture.
    *  click on prduct standard name link
       IF r_param->attribute = 'NAME_OF_THE_COLUMN'.
           lo_nd_my_node = wd_context->get_child_node( name = wd_this->wdctx_my_node ).
           lo_nd_my_node->get_static_attributes_table( IMPORTING table = lt_my_table ). "this is not sorted!!!!
           lo_nd_my_node->set_lead_selection_index( index = r_param->index ).
           READ TABLE lt_my_table INTO ls_my_structure INDEX r_param->index. "lt_my_table table might be sorted differently!!!!
           IF sy-subrc = 0.
             wd_this->do_something_with( ls_my_strcture ).
           ENDIF.
       ENDIF.
    ENDMETHOD.
    However, this does not work when I sort the ALV before!
    For a strange reason, the table that I get from the context is not sorted the same way as the data in the ALV.
    What can I do?

    Hi Daniel,
    I don't know if the external mapping messes things up.
    Perhaps you could try the following:
    lo_nd_my_node->get_static_attributes(
      EXPORTING
        index                = r_param->index
      IMPORTING
        static_attributes = ls_my_structure ).
    It could be that passing the data towards your internal table doesn't take over the sort.
    If you try debugging and check out the contents of the node, are they sorted correctly or not?
    Regards and good luck.
    Jos

  • Regarding ALV event

    Hi
    I have one double click event defination and one same event implementation. But two event handler one for top alv and one for bottom alv. Now from the event implementation I want to know which (top or bottom alv) alv is double clicked(top or bottom).

    CONSTANTS: formname_user_command TYPE slis_formname VALUE 'user_command'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
            i_callback_program = sy-repid
            i_callback_user_command = formname_user_command
    FORM formname_user_command USING ucomm LIKE sy-ucomm
                            selfield TYPE slis_selfield.
      CASE ucomm.
        WHEN '&IC1'.
          SELECT * FROM sflight
                       INTO CORRESPONDING FIELDS OF
                       TABLE it_sflight1
                       WHERE  CARRID = selfield-value.

  • ABAP Web Dynpro ALV: event for "tabel selection menu" needed

    Hi all,
    we need to react on the "table selection menue" control in our ALV grids. We found, that event "lead_select" is triggerd, if single lines are selected and if "delete selection" from the table selection menu is used.
    But if the "select all" item is used, the event is not triggered.
    Is there another event we can use? Does anybody know a sensible workaround for this problem?
    Thanks  and regards
    Joachim

    Hello Joachim,
    perhaps it's better to post your question in the WebDynpro ABAP forum:
    Web Dynpro ABAP
    Best regards
    Stephan

  • Abap WD ALV: Event for calculation row?

    Hi,
    i have one Abap WebDynpro ALV Component. It is possible to register an event (ON_CLICK) for Cells which are an Link_to_action for example.
    My Table:
    ID | Group | Var
    A1 | Test | 4
    A2 | Test | 5
    A3 | Dev | 4
    A4 | Dev | 6
    If i create the ON_CLICK event for the last row, which is then a link_to_action column, i can click on the numbers and the event is triggered
    Now i have a table which uses the ALV Calculation feature and the Intermediate Results for the grouping.
    My new output view is:
    ID | Group | Var
    ->---Test    9
      A1 | Test | 4
      A2 | Test | 5
    ->---Dev  10
      A3 | Dev | 4
      A4 | Dev | 6
    (It calculates the sum of the vars and groups it by the second column)
    Now I need an Event if someone clicks on the numbers in the Var Row of the intermediate results row (here: 9 and 10). How can i do this?
    If this is not possible, how can i register an event if someone expands or collapses a intermediate result row?
    Kind Regards,
    Thomas
    Edited by: Thomas Rodemer on Oct 9, 2008 3:30 PM
    Edited by: Thomas Rodemer on Oct 9, 2008 3:30 PM

    Hi,
    Is the DDLBK is filled with support function? if yes then look if you can enhance the method by post method exit etc..
    Thanks,
    Chandra

  • ALV events for data_change  executing multiple times

    Hello Experts,
    I am using the event "data_changed" of cl_gui_alv_grid and its getting triggred multiple times based on
    no. of rows in my ALV grid output.
    For ex: if i have 5 rows and if i input a field in any cell in a new row, in data_changed event is triggered 2 times.
    The  LOOP AT er_data_changed->mt_mod_cells INTO ls_modified is executing 6 times as in above example
    even though is having only 1 entry.
    Can some one pls help me with this?
    Also i see the  toolbar event is often getting excuted multiples no of times making the application slow.
    Please suggest.
    Thanks
    Dan

    Dan,
    Maybe you've placed or doing something wrong, take this report as a pattern "BCALV_EDIT_03".
    Best regards,
    Alexandre

  • OOP ALV event on standard toolbar

    Hi everyone,
    I'm using a method SET_TABLE_FOR_FIRST_DISPLAY to create an ALV grid.
    After making it editable I get these "Append", "Insert", "Delete" and "Duplicate Row" buttons in the toolbar by default.
    Is there a way to override the functionality of these buttons?
    My requirement is to make some cells (key fields) editable if a row has been duplicated or a new row has been inserted.
    Thanks in advance,
    Yasantha

    If you implement the toolbar event handler for the class, you can remove icons from the toolbar that you don't want. 
    *   Set up event handlers.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->toolbar for g_grid.
    METHODS:
          toolbar FOR EVENT toolbar OF cl_gui_alv_grid
                  IMPORTING e_object e_interactive.
    DATA: ls_toolbar type stb_button.
      LOOP AT p_e_object->mt_toolbar INTO ls_toolbar.
        IF ls_toolbar-function = '&REFRESH' OR
           ls_toolbar-function = '&LOCAL&CUT' OR
           ls_toolbar-function = '&LOCAL&COPY' OR
           ls_toolbar-function = '&LOCAL&PASTE' OR
           ls_toolbar-function = '&LOCAL&APPEND' OR
           ls_toolbar-function = '&LOCAL&INSERT_ROW' OR
           ls_toolbar-function = '&LOCAL&DELETE_ROW' OR
           ls_toolbar-function = '&LOCAL&COPY_ROW'.
           DELETE p_e_object->mt_toolbar.
        ENDIF.
      ENDLOOP.

  • ALV Events in Header

    In my OO ABAP ALV report i use containers.
    So in my Top of page or in the header, I display a URL using the method
    CALL METHOD p_dyndoc_id->add_link
    EXPORTING
    url = 'www.google.com'
    text = l_text.
    So when the user clicks on this URL, how to catch the ON_CLICK event.
    Can anyone pls help me with an example?
    Pls help
    Thanks
    Ram

    Hi Prabha,
    Good ... Check out the following documentation and examples
    Events in alv and their FM
    Please tell me what are the main events in alv and their FM and
    why we use these:
    1. SLIS_PRINT_ALV.
    2. SLIS_T_LISTHEADER.
    3. SLIS_T_EVENT.
    4. SLIS_T_SORTINFO_ALV.
    5. SLIS_T_LAYOUT_ALV.
    6. SLIS_T_FIELDCAT_ALV.
    and in classic reports what is the sequence of events:
    === Events are
    At selection-screen output.
    Initialization.
    At selection-screen on field
    At selection-screen on end of field
    At selection-screen on Radiobutton Group R1. (If you have any radio buttons)
    At selection-screen on block b1. (If you have any blocks)
    Start-of-selection.
    Get node. (if the data is retreived from a logical database)
    Get node late. (if the data is retreived from a logical database)
    Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)
    end-of-selection.
    and fuction modules are
    LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information.
    EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation.
    These events are captured by this FM.
    LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style.
    FIELDCAT - These are used to populate the List header. We can change them according to our req.
    These are some of the FM. I hope it is useful.
    Check out the following links
    http://www.sap-basis-abap.com/sapabap01.htm
    Sample programs on ALV Grid
    report zbnstest.
    TABLES AND DATA DECLARATION.
    *TABLES: mara,makt.",marc.
    data syrepid like sy-repid.
    data sydatum(10). " LIKE sy-datum.
    data sypagno(3) type n.
    WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
    GROUP (TYPE-POOLS--------->SLIS)
    type-pools : slis.
    INTERNAL TABLE DECLARATION.
    INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    mtart like mara-mtart,
    matkl like mara-matkl,
    end of t_mara.
    INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
    data : begin of t_marc occurs 0,
    matnr like mara-matnr,
    werks like marc-werks,
    minbe like marc-minbe.
    data: end of t_marc.
    INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
    data : begin of t_makt occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    spras like makt-spras,
    end of t_makt.
    INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
    data: begin of itab1 occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    maktx like makt-maktx,
    spras like makt-spras,
    werks like marc-werks,
    minbe like marc-minbe,
    end of itab1.
    THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
    AND THE LAYOUT FOR THE ALV.
    HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
    WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
    OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
    THIS IS DONE TO MAKE THE CODE SIMPLER.
    OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
    PROGRAMS.
    IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
    MORE TABLES AND CREATE A STRUCTURE
    IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
    LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    fieldlayout type slis_layout_alv.
    DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
    TOP-OF-PAGE ETC.
    data : eventstab type slis_t_event with header line.
    DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
    data : heading type slis_t_listheader with header line.
    data : heading1 type slis_t_listheader with header line.
    data : heading2 type slis_t_listheader with header line.
    data : heading3 type slis_t_listheader with header line.
    data : heading4 type slis_t_listheader with header line.
    data : heading5 type slis_t_listheader with header line.
    data : heading6 type slis_t_listheader with header line.
    data : heading7 type slis_t_listheader with header line.
    data : heading8 type slis_t_listheader with header line.
    STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
    data : colorstruct type slis_coltypes.
    INITIALIZATION. *
    initialization.
    syrepid = sy-repid.
    sypagno = sy-pagno.
    clear fieldcatalog.
    START-OF-SELECTION. *
    start-of-selection.
    SUBROUTINE TO POPULATE THE COLORSTRUCT
    perform fill_colorstruct using colorstruct.
    SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
    perform populate_fieldcatalog.
    SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
    INTERNAL TABLE.
    perform selectdata_and_sort.
    SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
    perform populate_layout using fieldlayout.
    SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    perform merge_fieldcatalog.
    SUBROUTINE TO POPULATE THE EVENTSTAB.
    perform fill_eventstab tables eventstab.
    SUBROUTINE TO POPULATE THE HEADING TABLES.
    perform fill_headingtable tables heading using 'HEADING'.
    perform fill_headingtable tables heading1 using 'HEADING1'.
    perform fill_headingtable tables heading2 using 'HEADING2'.
    perform fill_headingtable tables heading3 using 'HEADING3'.
    perform fill_headingtable tables heading4 using 'HEADING4'.
    perform fill_headingtable tables heading5 using 'HEADING5'.
    perform fill_headingtable tables heading6 using 'HEADING6'.
    perform fill_headingtable tables heading7 using 'HEADING7'.
    perform fill_headingtable tables heading8 using 'HEADING8'.
    SUBROUTINE TO DISPLAY THE LIST.
    perform display_alv_list.
    FORMS
    IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
    OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
    COLUMN JUSTIFICATION.
    form populate_fieldcatalog.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATNR' 'X' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MEINS' ' '.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MAKTX' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MTART' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATKL' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'SPRAS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'WERKS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MINBE' ' ' .
    endform. " POPULATE_FIELDCATALOG
    FORM FILL_FIELDS_OF_FIELDCATALOG *
    --> FIELDCATALOG *
    --> P_TABNAME *
    --> P_FIELDNAME *
    --> P_KEY *
    --> P_KEY *
    form fill_fields_of_fieldcatalog tables fieldcatalog
    structure fieldcatalog
    using p_tabname
    p_fieldname
    p_key.
    p_no_out.
    fieldcatalog-tabname = p_tabname.
    fieldcatalog-fieldname = p_fieldname.
    fieldcatalog-key = p_key.
    fieldcatalog-emphasize = '1234'.
    *fieldcatalog-no_out = p_no_out.
    append fieldcatalog.
    endform. " FILL_FIELDSOFFIELDCATALOG
    FORM POPULATE_LAYOUT *
    --> FIELDLAYOUT *
    form populate_layout using fieldlayout type slis_layout_alv.
    fieldlayout-f2code = '&ETA' .
    fieldlayout-zebra = 'X'.
    FOR THE WINDOW TITLE.
    fieldlayout-window_titlebar = 'ALV with Events'.
    fieldlayout-colwidth_optimize = 'X'.
    fieldlayout-no_vline = ' '.
    *fieldlayout-no_input = 'X'.
    fieldlayout-confirmation_prompt = ''.
    fieldlayout-key_hotspot = 'X'.
    This removes the column headings if the flag is set to 'X'
    fieldlayout-no_colhead = ' '.
    *fieldlayout-hotspot_fieldname = 'MAKTX'.
    fieldlayout-detail_popup = 'X'.
    fieldlayout-coltab_fieldname = 'X'.
    endform. " POPULATE_LAYOUT
    FORM SELECTDATA_AND_SORT *
    form selectdata_and_sort.
    select matnr meins mtart matkl from mara
    into corresponding fields of t_mara
    up to 500 rows .
    select matnr maktx spras from makt
    into corresponding fields of t_makt
    where matnr = t_mara-matnr and
    spras = sy-langu.
    select matnr werks minbe from marc
    into corresponding fields of t_marc
    where matnr = t_mara-matnr.
    append t_marc.
    endselect.
    append t_makt.
    endselect.
    append t_mara.
    endselect.
    perform populate_itab1.
    sort itab1 by matnr.
    endform. " SELECTDATA_AND_SORT
    FORM MERGE_FIELDCATALOG *
    form merge_fieldcatalog.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = syrepid
    i_internal_tabname = 'ITAB1'
    i_structure_name = 'COLORSTRUCT'
    I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = syrepid
    changing
    ct_fieldcat = fieldcatalog[]
    exceptions
    inconsistent_interface = 1
    program_error = 2
    others = 3.
    endform. " MERGE_FIELDCATALOG
    IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
    FOLLOWS:-
    i_callback_program --> CALLING PROGRAM NAME
    i_structure_name --> STRUCTURE NAME.
    is_layout --> LAYOUT NAME.
    it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
    form display_alv_list.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    i_callback_program = syrepid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = fieldlayout
    it_fieldcat = fieldcatalog[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
    TOOL BAR
    i_save = 'A'
    IS_VARIANT = ' '
    it_events = eventstab[]
    IT_EVENT_EXIT =
    IS_PRINT =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab1
    exceptions
    program_error = 1
    others = 2.
    endform. " DISPLAY_ALV_LIST
    *& Form POPULATE_ITAB1
    text
    --> p1 text
    <-- p2 text
    form populate_itab1.
    loop at t_mara.
    loop at t_makt where matnr = t_mara-matnr.
    loop at t_marc where matnr = t_mara-matnr.
    move-corresponding t_mara to itab1.
    move-corresponding t_makt to itab1.
    move-corresponding t_marc to itab1.
    append itab1.
    endloop.
    endloop.
    endloop.
    endform. " POPULATE_ITAB1
    *& Form FILL_EVENTSTAB
    text
    -->P_EVENTSTAB text *
    form fill_eventstab tables p_eventstab structure eventstab.
    WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
    INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
    AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
    EVENTS NAME.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_eventstab[]
    exceptions
    list_type_wrong = 1
    others = 2.
    BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
    THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
    WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
    FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
    IS DYNAMICALY CALLED.
    read table p_eventstab with key name = slis_ev_top_of_page.
    if sy-subrc = 0 .
    move 'TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_coverpage.
    if sy-subrc = 0 .
    move 'TOP_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_coverpage .
    if sy-subrc = 0 .
    move 'END_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_top_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_end_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_list_modify.
    if sy-subrc = 0 .
    move 'LIST_MODIFY' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_list.
    if sy-subrc = 0 .
    move 'TOP_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_page.
    if sy-subrc = 0 .
    move 'END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_list .
    if sy-subrc = 0 .
    move 'END_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    endform. " FILL_EVENTSTAB
    *& Form FILL_HEADINGTABLE
    text
    -->P_HEADING text *
    form fill_headingtable tables p_heading structure heading
    using tablename.
    case tablename.
    when 'HEADING'.
    p_heading-typ = 'H'.
    concatenate
    ' REPORT NAME:-' syrepid
    ' ABB Industry Pte Ltd' into p_heading-info.
    append p_heading.
    write sy-datum using edit mask '__/__/____' to sydatum.
    concatenate
    ' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
    into p_heading-info.
    append p_heading.
    when 'HEADING1'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING2'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING3'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
    append p_heading.
    when 'HEADING4'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-END-OF-PAGE'.
    append p_heading.
    WHEN 'HEADING5'.
    P_HEADING-TYP = 'H'.
    P_HEADING-INFO = 'LIST-MODIFY'.
    APPEND P_HEADING.
    when 'HEADING6'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-PAGE'.
    append p_heading.
    when 'HEADING7'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-LIST'.
    append p_heading.
    when 'HEADING8'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-LIST'.
    append p_heading.
    endcase.
    endform. " FILL_HEADINGTABLE
    FORM TOP_OF_PAGE *
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading[]
    exceptions
    others = 1.
    endform.
    *& Form FILL_COLORSTRUCT
    text
    -->P_COLORSTRUCT text *
    form fill_colorstruct using p_colorstruct type slis_coltypes .
    p_colorstruct-heacolfir-col = 6.
    p_colorstruct-heacolfir-int = 1.
    p_colorstruct-heacolfir-inv = 1.
    endform. " FILL_COLORSTRUCT
    FORM TOP_OF_COVERPAGE *
    form top_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading1[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_COVERPAGE *
    form end_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading2[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_TOP_OF_PAGE *
    form foreign_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading3[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_END_OF_PAGE *
    form foreign_end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading4[]
    exceptions
    others = 1.
    endform.
    FORM LIST_MODIFY *
    *FORM LIST_MODIFY.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEADING5[]
    EXCEPTIONS
    OTHERS = 1.
    *ENDFORM.
    FORM END_OF_PAGE *
    form end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading6[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_LIST *
    form end_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading7[]
    exceptions
    others = 1.
    endform.
    FORM TOP_OF_LIST *
    form top_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading8[]
    exceptions
    others = 1.
    endform.
    *--- End of Program
    Good Luck and thanks
    AK

  • ALV, event DATA_CHANGED, avoid insert of duplicate key

    Hello,
    I would like to implement edit functionality of an internal table with ALV based on class CL_GUI_ALV_GRID. Some fields of internal table are key fields and the combination of them should be unique. The user has a possibility to add a new record (all fields in new record are editable) or change values in an existing record (only non-key fields are editable). So far so good, it works.
    I'm doing a validation of entered data in the event DATA_CHANGED. In this event I'm checking if the new record is a duplicate combination of existing key fields. If yes, then all fields of the new record are reported as error with ADD_PROTOCOL_ENTRY method. This removes all entries related to this row from MT_GOOD_CELLS table and this is ok for me.
    My problem: after validation ALV inserts such empty row in my internal table and next time, when the user makes a correction, this record is an update and not a new record (there is no entry in MT_INSERTED_ROWS).
    Question: Is there a possibility to avoid ALV inserting a new record when all its cells are bad?
    Regards,
    Annie

    Hi,
    As far as i have understood your problem,you can try the following to avoid the insertion of an empty row:
    When you must be creating an empty row,just set a flag say flag_create = 'X'.
    Then when you are performing the validation then if there is an error then check for this flag that is :
    if flag_create = 'X'.
    then delete from the internal table based on sy-tabix.
    endif.
    This way the new row that got appended with wrong values will get deleted and the code will not consider this as an updated row.
    Kindly <<deleted> if useful.:)
    Follow the rules of engagement
    Edited by: Vijay Babu Dudla on Jan 9, 2012 7:07 AM

Maybe you are looking for