DATA : lr_toolbar TYPE REF TO cl_gui_toolbar,
lr_cust_cont TYPE REF TO cl_gui_custom_container,
lt_event TYPE cntl_simple_events,
ls_event LIKE LINE OF lt_event.
*----------------------------------------------------------------------*
* CLASS LCL_HANDLE_TOOLBAR DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_handle_toolbar DEFINITION.
PUBLIC SECTION.
METHODS : handle_button FOR EVENT function_selected
OF cl_gui_toolbar IMPORTING fcode .
ENDCLASS. "LCL_HANDLE_TOOLBAR DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_handle_toolbar IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_handle_toolbar IMPLEMENTATION.
METHOD handle_button .
CASE fcode.
WHEN 'TSAVE'.
MESSAGE 'Save button clicked' TYPE 'I'.
ENDCASE.
ENDMETHOD. "handle_button
ENDCLASS. "lcl_handle_toolbar IMPLEMENTATION
START-OF-SELECTION.
DATA : lr_handle TYPE REF TO lcl_handle_toolbar.
CREATE OBJECT lr_handle.
CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*& Module CREATE_PFSTATUS OUTPUT
*&---------------------------------------------------------------------*
MODULE create_pfstatus OUTPUT.
SET PF-STATUS 'STATUS'.
ENDMODULE. " CREATE_PFSTATUS OUTPUT
*&---------------------------------------------------------------------*
*& Module CREATE_TOOLBAR OUTPUT
*&---------------------------------------------------------------------*
MODULE create_toolbar OUTPUT.
IF lr_cust_cont IS NOT BOUND.
CREATE OBJECT lr_cust_cont
EXPORTING
container_name = 'TOOLBAR'
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.
IF lr_toolbar IS NOT BOUND.
CREATE OBJECT lr_toolbar
EXPORTING
parent = lr_cust_cont
display_mode = cl_gui_toolbar=>m_mode_horizontal " Display mode
name = 'Demo Toolbar'
EXCEPTIONS
cntl_install_error = 1
cntl_error = 2
cntb_wrong_version = 3
OTHERS = 4.
ENDIF.
CALL METHOD lr_toolbar->add_button
EXPORTING
fcode = 'TSAVE' " Function Code of Button
icon = '@2L@' " Icon Name
* is_disabled = " Button Status
butn_type = 0 " Button Types Defined in CNTB
text = 'Save' " Text Shown to the Right of the Image
quickinfo = 'Click to update the database'
* is_checked = " Button Selected
EXCEPTIONS
cntl_error = 1
cntb_btype_error = 2
cntb_error_fcode = 3
OTHERS = 4.
ls_event-eventid = cl_gui_toolbar=>m_id_function_selected.
ls_event-appl_event = ''.
APPEND ls_event TO lt_event.
CALL METHOD lr_toolbar->set_registered_events
EXPORTING
events = lt_event.
SET HANDLER lr_handle->handle_button FOR lr_toolbar.
ENDMODULE. " CREATE_TOOLBAR OUTPUT
*&---------------------------------------------------------------------*
*& Module HANDLE_USERACTION INPUT
*&---------------------------------------------------------------------*
MODULE handle_useraction INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " HANDLE_USERACTION INPUT
---------------------------------------------------------------------------------------------------------------
lr_cust_cont TYPE REF TO cl_gui_custom_container,
lt_event TYPE cntl_simple_events,
ls_event LIKE LINE OF lt_event.
*----------------------------------------------------------------------*
* CLASS LCL_HANDLE_TOOLBAR DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_handle_toolbar DEFINITION.
PUBLIC SECTION.
METHODS : handle_button FOR EVENT function_selected
OF cl_gui_toolbar IMPORTING fcode .
ENDCLASS. "LCL_HANDLE_TOOLBAR DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_handle_toolbar IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_handle_toolbar IMPLEMENTATION.
METHOD handle_button .
CASE fcode.
WHEN 'TSAVE'.
MESSAGE 'Save button clicked' TYPE 'I'.
ENDCASE.
ENDMETHOD. "handle_button
ENDCLASS. "lcl_handle_toolbar IMPLEMENTATION
START-OF-SELECTION.
DATA : lr_handle TYPE REF TO lcl_handle_toolbar.
CREATE OBJECT lr_handle.
CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*& Module CREATE_PFSTATUS OUTPUT
*&---------------------------------------------------------------------*
MODULE create_pfstatus OUTPUT.
SET PF-STATUS 'STATUS'.
ENDMODULE. " CREATE_PFSTATUS OUTPUT
*&---------------------------------------------------------------------*
*& Module CREATE_TOOLBAR OUTPUT
*&---------------------------------------------------------------------*
MODULE create_toolbar OUTPUT.
IF lr_cust_cont IS NOT BOUND.
CREATE OBJECT lr_cust_cont
EXPORTING
container_name = 'TOOLBAR'
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.
IF lr_toolbar IS NOT BOUND.
CREATE OBJECT lr_toolbar
EXPORTING
parent = lr_cust_cont
display_mode = cl_gui_toolbar=>m_mode_horizontal " Display mode
name = 'Demo Toolbar'
EXCEPTIONS
cntl_install_error = 1
cntl_error = 2
cntb_wrong_version = 3
OTHERS = 4.
ENDIF.
CALL METHOD lr_toolbar->add_button
EXPORTING
fcode = 'TSAVE' " Function Code of Button
icon = '@2L@' " Icon Name
* is_disabled = " Button Status
butn_type = 0 " Button Types Defined in CNTB
text = 'Save' " Text Shown to the Right of the Image
quickinfo = 'Click to update the database'
* is_checked = " Button Selected
EXCEPTIONS
cntl_error = 1
cntb_btype_error = 2
cntb_error_fcode = 3
OTHERS = 4.
ls_event-eventid = cl_gui_toolbar=>m_id_function_selected.
ls_event-appl_event = ''.
APPEND ls_event TO lt_event.
CALL METHOD lr_toolbar->set_registered_events
EXPORTING
events = lt_event.
SET HANDLER lr_handle->handle_button FOR lr_toolbar.
ENDMODULE. " CREATE_TOOLBAR OUTPUT
*&---------------------------------------------------------------------*
*& Module HANDLE_USERACTION INPUT
*&---------------------------------------------------------------------*
MODULE handle_useraction INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " HANDLE_USERACTION INPUT
---------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment