Creating Simple Toolbar Button on Selection Screen.

Expected Result

*See source code at Appendix A.

First, declare a global table work area SSCRFIELDS; structure from ABAP Dictionary.

*See SSCRFIELDS structure at Appendix B.

Second, define the toolbar button as many as you need (the limitation is five buttons).


Next. Under the INITIALIZATION event, define the button text (FUNCTXT_0N) like “Button1”, …, “Button5” or you could use the Text Symbol [Text-001] instead; it’s better than hard coding.


Last. Under the ‘AT SELECTION-SCREEN‘ event, check their user commands (UCOMM)
using CASE…WHEN ‘FC01‘, ‘FC02‘, …. , ‘FC05‘ ENDCASE and specify routine for each button.

Appendix A
TABLES:
sscrfields. "Fields on selection screens

PARAMETERS:
p_bukrs TYPE t001-bukrs.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
SELECTION-SCREEN FUNCTION KEY 3.
SELECTION-SCREEN FUNCTION KEY 4.
SELECTION-SCREEN FUNCTION KEY 5.

INITIALIZATION.
sscrfields-functxt_01 = 'Button1'.
sscrfields-functxt_02 = 'Button2'.
sscrfields-functxt_03 = 'Button3'.
sscrfields-functxt_04 = 'Button4'.
sscrfields-functxt_05 = 'Button5'.

AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'FC01'. "Action 1
WHEN 'FC02'. "Action 2
WHEN 'FC03'. "Action 3
WHEN 'FC04'. "Action 4
WHEN 'FC05'. "Action 5
ENDCASE.


Appendix B


Leave a Reply

Your email address will not be published. Required fields are marked *