Skip to Content
author's profile photo Former Member
Former Member

Trigger ALV Events

Hi

Please do let me know if there i a method where we can trigger various events in ALV without creating an internal table of type SLIS_T_EVENT and using the func module "REUSE_ALV_EVENTS_GET".

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 05:53 AM

    REPORT ZALV1.

    ******************TABLE DECLARATION***********************************

    TABLES : VBAP. " tables declaration

    *****************TYPE POOLS*******************************************

    TYPE-POOLS : SLIS. " slis type pool

    *****************INTERNAL TABLE DECLARATION***************************

    DATA : BEGIN OF IT_VBAP OCCURS 0,

    " internal table for sales document item

    VBELN LIKE VBAP-VBELN, " sales document

    POSNR LIKE VBAP-POSNR, " document item

    ERNAM LIKE VBAP-ERNAM,

    " name of the person who created the object

    ERDAT LIKE VBAP-ERDAT, " date on which the record was created

    MATNR LIKE VBAP-MATNR. " material number

    DATA : END OF IT_VBAP.

    DATA : BEGIN OF IT_MARA OCCURS 0, " general material data

    MATNR LIKE MARA-MATNR, " material number

    ERNAM LIKE MARA-ERNAM,

    " name of the person who created the object

    MATKL LIKE MARA-MATKL, " material group

    MEINS LIKE MARA-MEINS, " base unit of measure

    PSTAT LIKE MARA-PSTAT. " maintainence status

    DATA : END OF IT_MARA.

    ******************VARIABLE

    DECLARATION**********************************

    DATA : REPID LIKE SY-REPID. " program name

    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    " field catalog table for vbap

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA : IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    " field catalog table for mara

    WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.

    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

    DATA: GT_XEVENTS TYPE SLIS_T_EVENT.

    DATA: GT_YEVENTS TYPE SLIS_T_EVENT. " events table

    DATA : XS_EVENT TYPE SLIS_ALV_EVENT. " events type

    DATA : GT_PRINT TYPE SLIS_PRINT_ALV. " print table

    *******************MULTIPLE SELECT INPUT

    PARAMETERS**********************

    SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.

    " multiple selection for sales document

    ******************INITIALIZATION**************************************

    ***

    INITIALIZATION.

    REPID = SY-REPID.

    *******************START OF

    SELECTION************************************

    START-OF-SELECTION.

    PERFORM POP_VBAP.

    " populating the table with document item data

    PERFORM POP_MARA.

    " populating the table with general material data

    PERFORM FIELD_CAT.

    " mapping the fields for the field catalog

    PERFORM EVENTS. " using the events

    PERFORM BLOCK_LIST.

    " displaying the data in blocked list

    &----


    *& Form field_cat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FIELD_CAT .

    WA_FIELDCAT-FIELDNAME = 'VBELN'.

    WA_FIELDCAT-TABNAME = 'IT_VBAP'.

    WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.

    WA_FIELDCAT-COL_POS = 1.

    WA_FIELDCAT-OUTPUTLEN = 10.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'POSNR'.

    WA_FIELDCAT-TABNAME = 'IT_VBAP'.

    WA_FIELDCAT-SELTEXT_L = 'DOC ITEM'.

    WA_FIELDCAT-COL_POS = 2.

    WA_FIELDCAT-OUTPUTLEN = 6.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'ERNAM'.

    WA_FIELDCAT-TABNAME = 'IT_VBAP'.

    WA_FIELDCAT-SELTEXT_L = 'NAME'.

    WA_FIELDCAT-COL_POS = 3.

    WA_FIELDCAT-OUTPUTLEN = 12.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'ERDAT'.

    WA_FIELDCAT-TABNAME = 'IT_VBAP'.

    WA_FIELDCAT-SELTEXT_L = 'DATE'.

    WA_FIELDCAT-COL_POS = 4.

    WA_FIELDCAT-OUTPUTLEN = 8.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-TABNAME = 'IT_VBAP'.

    WA_FIELDCAT-SELTEXT_L = 'MAT NO'.

    WA_FIELDCAT-COL_POS = 5.

    WA_FIELDCAT-OUTPUTLEN = 18.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT1-FIELDNAME = 'MATNR'.

    WA_FIELDCAT1-TABNAME = 'IT_MARA'.

    WA_FIELDCAT1-SELTEXT_L = 'MAT NO'.

    WA_FIELDCAT1-COL_POS = 1.

    WA_FIELDCAT1-OUTPUTLEN = 18.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'ERNAM'.

    WA_FIELDCAT1-TABNAME = 'IT_MARA'.

    WA_FIELDCAT1-SELTEXT_L = 'NAME'.

    WA_FIELDCAT1-COL_POS = 2.

    WA_FIELDCAT1-OUTPUTLEN = 12.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'MATKL'.

    WA_FIELDCAT1-TABNAME = 'IT_MARA'.

    WA_FIELDCAT1-SELTEXT_L = 'MAT DESC'.

    WA_FIELDCAT1-COL_POS = 3.

    WA_FIELDCAT1-OUTPUTLEN = 9.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'MEINS'.

    WA_FIELDCAT1-TABNAME = 'IT_MARA'.

    WA_FIELDCAT1-SELTEXT_L = 'UNITS'.

    WA_FIELDCAT1-COL_POS = 4.

    WA_FIELDCAT1-OUTPUTLEN = 3.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'PSTAT'.

    WA_FIELDCAT1-TABNAME = 'IT_MARA'.

    WA_FIELDCAT1-SELTEXT_L = 'STATUS'.

    WA_FIELDCAT1-COL_POS = 5.

    WA_FIELDCAT1-OUTPUTLEN = 15.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    ENDFORM. " field_cat

    &----


    *& Form events

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM EVENTS .

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.

    XS_EVENT-FORM = 'XEND_OF_PAGE'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    XS_EVENT-FORM = 'XTOP_OF_PAGE'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.

    XS_EVENT-FORM = 'XTOP_OF_LIST'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_LIST.

    XS_EVENT-FORM = 'XEND_OF_LIST'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.

    XS_EVENT-FORM = 'YEND_OF_PAGE'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    XS_EVENT-FORM = 'YTOP_OF_PAGE'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.

    XS_EVENT-FORM = 'YTOP_OF_LIST'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_LIST.

    XS_EVENT-FORM = 'YEND_OF_LIST'.

    APPEND XS_EVENT TO GT_YEVENTS.

    ENDFORM. " events

    &----


    *& Form XTOP_OF_PAGE

    &----


    • text

    ----


    FORM XTOP_OF_PAGE.

    • BREAK-POINT.

    WRITE: / 'X_TOP_OF_PAGE'.

    ENDFORM. "XTOP_OF_PAGE

    ----


    • FORM XTOP_OF_LIST *

    ----


    • ........ *

    ----


    FORM XTOP_OF_LIST.

    • BREAK-POINT.

    WRITE: / 'X_TOP_OF_LIST'.

    ENDFORM. "XTOP_OF_LIST

    ----


    • FORM XEND_OF_PAGE *

    ----


    • ........ *

    ----


    FORM XEND_OF_PAGE.

    • BREAK-POINT.

    WRITE: / 'X_END_OF_PAGE'.

    ENDFORM. "XEND_OF_PAGE

    ----


    • FORM XEND_OF_LIST *

    ----


    • ........ *

    ----


    FORM XEND_OF_LIST.

    • BREAK-POINT.

    WRITE: / 'X_END_OF_LIST'.

    ENDFORM. "XEND_OF_LIST

    *

    FORM YTOP_OF_PAGE.

    • BREAK-POINT.

    WRITE: / 'Y_TOP_OF_PAGE'.

    ENDFORM. "YTOP_OF_PAGE

    ----


    • FORM YTOP_OF_LIST *

    ----


    • ........ *

    ----


    FORM YTOP_OF_LIST.

    • BREAK-POINT.

    WRITE: / 'Y_TOP_OF_LIST'.

    ENDFORM. "YTOP_OF_LIST

    ----


    • FORM YEND_OF_PAGE *

    ----


    • ........ *

    ----


    FORM YEND_OF_PAGE.

    • BREAK-POINT.

    WRITE: / 'Y_END_OF_PAGE'.

    ENDFORM. "YEND_OF_PAGE

    ----


    • FORM YEND_OF_LIST *

    ----


    • ........ *

    ----


    FORM YEND_OF_LIST.

    • BREAK-POINT.

    WRITE: / 'Y_END_OF_LIST'.

    ENDFORM. "YEND_OF_LIST

    *

    &----


    *& Form POP_VBAP

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM POP_VBAP .

    SELECT VBELN

    POSNR

    ERNAM

    ERDAT

    MATNR

    FROM VBAP

    INTO CORRESPONDING FIELDS OF TABLE IT_VBAP

    WHERE VBELN IN S_VBELN.

    ENDFORM. " POP_VBAP

    &----


    *& Form POP_MARA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM POP_MARA .

    LOOP AT IT_VBAP.

    SELECT SINGLE MATNR

    ERNAM

    MATKL

    MEINS

    PSTAT

    FROM MARA

    INTO CORRESPONDING FIELDS OF IT_MARA

    WHERE MATNR = IT_VBAP-MATNR.

    APPEND IT_MARA.

    ENDLOOP.

    ENDFORM. " POP_MARA

    &----


    *& Form BLOCK_LIST

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BLOCK_LIST .

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    I_CALLBACK_PROGRAM = REPID

    I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'user_command'.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT

    I_TABNAME = 'IT_VBAP'

    IT_EVENTS = GT_XEVENTS

    • IT_SORT =

    • I_TEXT = ' '

    TABLES

    T_OUTTAB = IT_VBAP

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • MAXIMUM_OF_APPENDS_REACHED = 2

    • OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT1

    I_TABNAME = 'IT_MARA'

    IT_EVENTS = GT_YEVENTS

    • IT_SORT =

    • I_TEXT = ' '

    TABLES

    T_OUTTAB = IT_MARA

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • MAXIMUM_OF_APPENDS_REACHED = 2

    • OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    IS_PRINT = GT_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 =

    • 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.

    ENDFORM. " BLOCK_LIST

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2007 at 05:56 AM

    Hi,

    Refer this code

    &----


    *& Form sub_create_events *

    &----


    • This form will display the ALV Events *

    ----


    FORM sub_create_events .

    *--Local Work Area

    DATA: lwa_event TYPE slis_alv_event. "Work area for Events

    *--Call Function to display the events for the ALV

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 1

    IMPORTING

    et_events = i_events.

    *--Sort by Name

    SORT i_events BY name.

    *--Clear

    CLEAR lwa_event.

    READ TABLE i_events INTO lwa_event WITH KEY name = slis_ev_top_of_page

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE c_top_of_page TO lwa_event-form.

    MODIFY i_events FROM lwa_event TRANSPORTING form WHERE

    name = slis_ev_top_of_page.

    ENDIF.

    CLEAR : lwa_event.

    ENDFORM. "sub_create_events

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 06:04 AM

    Hi

    Create an ALV with events without using the below

    1.Not creating an internal table of type SLIS_T_EVENT.

    2. Not using the func module REUSE_ALV_EVENTS_GET"

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.