ToolBar Buttons Using CL_GUI_TOOLBAR


 

Class – CL_GUI_TOOLBAR provides methods to create toll bar buttons ( of different types) on the container.


DATA : lr_toolbar TYPE REF TO cl_gui_toolbar,
lr_cust_cont TYPE REF TO cl_gui_custom_container.

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

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


Domain fixed value defines Button Types.

Flow logic of the screen.


 Screen container.


 Execute the program and a button is created on the Container .


 

 

Leave a Reply