6 Replies Latest reply: Jan 23, 2008 6:52 AM by Guest RSS

events in ALV

sanjana saran
Currently Being Moderated

hi the following events

 

TOP_OF_PAGE

END_OF_PAGE

PRINT_TOP_OF_LIST

PRINT_END_OF_LIST

 

 

 

what is the significance of each of these events, when do they get triggered in an alv OO grid display.

thank you

  • Re: events in ALV
    Lokesh Aggarwal
    Currently Being Moderated

    Hi Sanjana,

     

    Please refer to program BCALV_TEST_GRID_EVENTS for info on the events in the grid, how they execute and when they are triggered.

     

     

    Lokesh

  • Re: events in ALV
    Currently Being Moderated

    follwing is list of events :

    Only events with a form routine name are processed.

     

    The I_EVENTS table returns with the following possible constants:

     

    1.     Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.     

    Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.

    2.     Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.

    RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to       be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.

    RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that    entries are not repeated in the item table.

        RS_SELFIELD is initial in this case.         

    3.     Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.

    Is called at the beginning of the function module to make special settings. It is not usually used.          

    4.     Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

    As this is a frequently-used Callback event, the form routine can also be passed        directly in the interface by passing the user command in the IMPORTING parameter           I_CALLBACK_USER_COMMAND.

    5.     Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

       Equivalent to the list processing TOP-OF-PAGE event.           

    6.     Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.       

    The selection information and list status are output together (if they exist) on a separate page by default

    7.     Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.       

    Analogously to TOP_OF_COVERPAGE the user can add other information

    to the information output by ALV (selection information, list status) at this event.

    8.     Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.

    The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).

    In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

     

    9.     Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.  

    The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).

    In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.                             

    10.     Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.

    If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).

    The STANDARD status of the function group SALV should be used as a          template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.

    11.     Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.     

    LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME

                                             R_INDEX LIKE SY-TABIX

                                             R_INDEX_ITEM LIKE SY-TABIX

                                             R_INDEX_SUM LIKE SY-TABIX.

    12.     Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.  

    Information output at the start of the list     

    13.     Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.

    Information output at the end of a page. This is only called for printing.

    14.     Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.     

    Information output at the end of the list

    15.     Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.

    Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

    16.     Slis_ev_before_line_output TYPE slis_formname VALUE   'BEFORE_LINE_OUTPUT'.       

    Output information before each output line. Should only be used in justified cases because it costs a lot of performance.         

    17.     Slis_ev_subtotal_text TYPE slis_formname VALUE  'SUBTOTAL_TEXT'.                        

     

    This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.

     

     

     

    reward if useful

     

    regards

    vivek

  • Re: events in ALV
    Rajasekhar Reddy P
    Currently Being Moderated

    hi,

     

    Event: Application

    print_end_of_list:Define output text to be printed at thend of the entire list

    print_top_of_list:Define output text to be printed at the beginning of the entire list

    print_end_of_page:Define output text to be printed at the end of each page

    print_top_of_page:Define output text to be printed at the beginning of each page

    subtotal_text:Define self-defined subtotals texts

     

     

     

    rewrd if its useful

  • Re: events in ALV
    DEEPANKER MAHAJAN
    Currently Being Moderated

    Hi

     

    Hope it will help you.

     

    reward if help.

     

     

     

    A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.

    The function module contains following import and export parameters.

     

    IMPORTING PARAMETERS: I_LIST_TYPE

    This parameter has possible values from 0-4.

    The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .

     

    EXPORTING PARAMETERS: I_EVENTS table.

     

    This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.

    The table structure contains the fields:

    I_EVENTS-NAME: Name of the Callback event.

    I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.

     

    Only events with a form routine name are processed.

     

    The I_EVENTS table returns with the following possible constants:

     

    1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.

    Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.

    2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.

    RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.

    RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.

    RS_SELFIELD is initial in this case.

    3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.

    Is called at the beginning of the function module to make special settings. It is not usually used.

    4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

    As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.

    5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

    Equivalent to the list processing TOP-OF-PAGE event.

    6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.

    The selection information and list status are output together (if they exist) on a separate page by default

    7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.

    Analogously to TOP_OF_COVERPAGE the user can add other information

    to the information output by ALV (selection information, list status) at this event.

    8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.

    The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).

    In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

     

    9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.

    The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).

    In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.

    10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.

    If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).

    The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.

    11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.

    LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME

    R_INDEX LIKE SY-TABIX

    R_INDEX_ITEM LIKE SY-TABIX

    R_INDEX_SUM LIKE SY-TABIX.

    12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.

    Information output at the start of the list

    13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.

    Information output at the end of a page. This is only called for printing.

    14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.

    Information output at the end of the list

    15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.

    Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

    16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.

    Output information before each output line. Should only be used in justified cases because it costs a lot of performance.

    17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

     

    This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.

     

    Sample code :

     

     

    FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

    FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

     

    DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.

     

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

           EXPORTING

               I_LIST_TYPE = 0

           IMPORTING

                ET_EVENTS   = I_EVENTS.

     

      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

                               INTO L_I_EVENT.

      IF SY-SUBRC = 0.

        MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.

        APPEND L_I_EVENT TO I_EVENTS.

      ENDIF.

     

      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

                               INTO L_I_EVENT.

      IF SY-SUBRC = 0.

        MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.

        APPEND L_I_EVENT TO I_EVENTS.

      ENDIF.

      CLEAR L_I_EVENT.

      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND

                               INTO L_I_EVENT.

      IF SY-SUBRC = 0.

        MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.

        APPEND L_I_EVENT TO I_EVENTS.

      ENDIF.

     

     

    Events in alv and their FM The main events in alv and their FM and why we use these:

     

    1. SLIS_PRINT_ALV.

    2. SLIS_T_LISTHEADER.

    3. SLIS_T_EVENT.

    4. SLIS_T_SORTINFO_ALV.

    5. SLIS_T_LAYOUT_ALV.

    6. SLIS_T_FIELDCAT_ALV.

     

    and in classic reports what is the sequence of events: === Events are

    At selection-screen output.

    Initialization.

    At selection-screen on field

    At selection-screen on end of field

    At selection-screen on Radiobutton Group R1. (If you have any radio buttons)

    At selection-screen on block b1. (If you have any blocks)

    Start-of-selection.

    Get node. (if the data is retreived from a logical database)

    Get node late. (if the data is retreived from a logical database)

    Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)

    end-of-selection.

    and fuction modules are

     

    LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information. EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation. These events are captured by this FM. LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style. FIELDCAT - These are used to populate the List header. We can change them according to our req.

     

    User-defined Text Output Event

    Application

    print_end_of_list

    Define output text to be printed at the end of the entire list

    print_top_of_list

    Define output text to be printed at the beginning of the entire list

    print_end_of_page

    Define output text to be printed at the end of each page

    print_top_of_page

    Define output text to be printed at the beginning of each page

    subtotal_text

    Define self-defined subtotals texts

     

    Mouse-controlled Actions in the Grid Control Event

    Application

    button_click

    Query a click on a pushbutton in the ALV Grid Control

    double_click

    Query a double-click on a cell of the ALV Grid control

    hotspot_click

    Query a hotspot click on columns defined for this purpose in advance

    onDrag

    Collect information when elements of the ALV Grid Control are dragged

    onDrop

    Process information when elements of the ALV Grid Control are dropped

    onDropComplete

    Perform final actions after successful Drag&Drop

    onDropGetFlavor

    Distinguish between options for Drag&Drop behavior

     

    Processing of Self-defined and Standard Functions Event

    Application

    before_user_command

    Query self-defined and standard function codes

    user_command

    Query self-defined function codes

    after_user_command

    Query self-defined and standard function codes

     

    Definition of Self-defined Functions Event

    Application

    toolbar

    Change, delete or add GUI elements in the toolbar

    menu_button

    Define menus for menu buttons in the toolbar

    context_menu_request

    Change context menu

    onf1

    Define self-defined F1 help

     

    All of these can be found under type group SLIS.

     

    • Events

    SLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',

    SLIS_EV_REPREP_SEL_MODIFY TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',

    SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',

    SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

    SLIS_EV_DATA_CHANGED TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',

    SLIS_EV_TOP_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',

    SLIS_EV_END_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',

    SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME

    VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME

    VALUE 'FOREIGN_END_OF_PAGE',

    SLIS_EV_PF_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',

    SLIS_EV_LIST_MODIFY TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',

    SLIS_EV_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',

    SLIS_EV_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',

    SLIS_EV_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',

    SLIS_EV_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',

    SLIS_EV_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.

     

    For more information check the following link:

    http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/ALV_tutorial.html

    http://www.sap-img.com/abap-function.htm

Actions