Creating Toolbar Button with Icon on Selection Screen.

Expected Result

*See source code at Appendix A.

First, declare two global table work area, SSCRFIELDS and SMP_DYNTXT;
structures from ABAP Dictionary.

*See SSCRFIELDS and SMP_DYNTXT structures 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 following values: –
1) SMP_DYNTXT-TEXT: Function or menu text (Optional)
2) SMP_DYNTXT-ICON_ID: Icon ID
3) SMP_DYNTXT-ICON_TEXT: Icon Text
4) SMP_DYNTXT-QUICKINFO: Info. Text (Optional)
And then move SMP_DYNTXT to SSCRFIELDS-FUNCTXT_XX.


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

Appendix A
TABLES:
"Fields on selection screens
sscrfields,
"Menu Painter: Program interface for dynamic texts
smp_dyntxt.

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.
"Button1
smp_dyntxt-text = 'Calculation'.
smp_dyntxt-icon_id = icon_calculation.
smp_dyntxt-icon_text = 'Calculation'.
smp_dyntxt-quickinfo = 'Calculation Program'.
sscrfields-functxt_01 = smp_dyntxt.
CLEAR smp_dyntxt.

"Button2
smp_dyntxt-text = 'Statistics'.
smp_dyntxt-icon_id = icon_graphics.
smp_dyntxt-icon_text = 'Statistics'.
smp_dyntxt-quickinfo = 'Statistics Program'.
sscrfields-functxt_02 = smp_dyntxt.
CLEAR smp_dyntxt.

"Button3
smp_dyntxt-text = 'Printing'.
smp_dyntxt-icon_id = icon_print.
smp_dyntxt-icon_text = 'Printing'.
smp_dyntxt-quickinfo = 'Printing Program'.
sscrfields-functxt_03 = smp_dyntxt.
CLEAR smp_dyntxt.

"Button4
smp_dyntxt-text = 'Email'.
smp_dyntxt-icon_id = icon_mail.
smp_dyntxt-icon_text = 'Email'.
smp_dyntxt-quickinfo = 'Email Program'.
sscrfields-functxt_04 = smp_dyntxt.
CLEAR smp_dyntxt.

"Button5
smp_dyntxt-text = 'Log Report'.
smp_dyntxt-icon_id = icon_protocol.
smp_dyntxt-icon_text = 'Log Report'.
smp_dyntxt-quickinfo = 'Display Log Report'.
sscrfields-functxt_05 = smp_dyntxt.
CLEAR smp_dyntxt.

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 *