Skip to Content
0
Former Member
Aug 04, 2009 at 11:46 AM

unable to trigger my event

37 Views

dear experts,

I need to add some extra features to title bar of my alv report.i got some documents and iam trying on that.Here in my program its displaying the newly created icon but when i click on that icon its not displaying or teriigering my event -

class lcl_event_receiver definition deferred.

TYPE-POOLS: ICON.

data: con type ref to cl_gui_custom_container,

gr_alvgrid type ref to cl_gui_alv_grid.

DATA: ITAB_EXCLUDE TYPE UI_FUNCTIONS.

DATA: WA_EXCLUDE TYPE UI_FUNC.

data: it_toolbar TYPE stb_button.

data: begin of itab occurs 0.

include structure mara.

data: end of itab.

data: event_receiver TYPE REF TO LCL_EVENT_RECEIVER.

select * from mara into table itab.

call screen 1000.

----


  • CLASS lcl_event_receiver DEFINITION

----


*

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

class-methods: handle_toolbar for event toolbar of cl_gui_alv_grid importing e_object e_interactive,

handle_menu_buttons for event menu_button of cl_gui_alv_grid importing e_object e_ucomm,

handle_USER_COMMAND for event user_command of cl_gui_alv_grid importing e_ucomm.

ENDCLASS. "lcl_event_receiver DEFINITION

----


  • CLASS lcl_event_receiver IMPLEMENTATION

----


*

----


CLASS lcl_event_receiver implementation.

method handle_toolbar.

move 'DETAIL-TAIL' TO IT_TOOLBAR-FUNCTION.

MOVE ICON_DETAIL TO IT_TOOLBAR-ICON.

MOVE 2 TO IT_TOOLBAR-BUTN_TYPE.

APPEND IT_TOOLBAR TO E_OBJECT->MT_TOOLBAR.

ENDMETHOD. "handle_toolbar

METHOD HANDLE_MENU_BUTTONS.

IF E_UCOMM = 'DETAIL'.

CALL METHOD e_object->add_function

EXPORTING

fcode = 'DISPLAY'

text = 'DISPLAY'.

ENDIF.

ENDMETHOD. "HANDLE_MENU_BUTTONS

METHOD handle_user_command.

CASE e_ucomm.

WHEN 'DISPLAY'.

MESSAGE 'Menu Clicked' TYPE 'I'.

ENDCASE.

ENDMETHOD. "handle_user_command

ENDCLASS. "lcl_event_receiver IMPLEMENTATION

----


  • MODULE STATUS_1000 OUTPUT

----


*

----


MODULE STATUS_1000 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

CREATE OBJECT CON

EXPORTING

  • PARENT =

CONTAINER_NAME = 'CO_CON'

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CREATE OBJECT GR_ALVGRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = CON

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • I_FCAT_COMPLETE = SPACE

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

WA_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_MAXIMUM.

APPEND WA_EXCLUDE TO ITAB_EXCLUDE.

WA_EXCLUDE = CL_GUI_ALV_GRID=>MC_mb_SUM.

APPEND WA_EXCLUDE TO ITAB_EXCLUDE.

CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'MARA'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

IT_TOOLBAR_EXCLUDING = ITAB_EXCLUDE

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

IT_OUTTAB = ITAB[]

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CREATE OBJECT event_receiver.

SET HANDLER event_receiver->handle_user_command

event_receiver->handle_menu_buttons

event_receiver->handle_toolbar FOR ALL INSTANCES. "*Calling the interactive toolbar method of ALV

CALL METHOD GR_ALVGRID->set_toolbar_interactive.

ENDMODULE. " STATUS_1000 OUTPUT

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


MODULE USER_COMMAND_1000 INPUT.

ENDMODULE. " USER_COMMAND_1000 INPUT