Académique Documents
Professionnel Documents
Culture Documents
ISBN 1-59229-073-6
and applications
Step-by-step guidance on how to use all container and
application controls
Benet immediately from extensively commented, reusable code
SAP Controls
Workshop
Harald Rser
073_cover.indd 1
05.12.2005 17:07:28
Contents
1
2
Introduction .............................................
2.1
2.2
3.1
Architecture ......................................... 11
9.1
3.2
9.2
3.3
9.3
3.4
9.4
3.5
3.6
Summary ............................................. 20
4.2
4.3
Summary ............................................. 26
4.4
Summary ............................................. 32
5.1
5.2
5.3
5.4
5.5
www.sap-press.com
Content
Introduction
sample program.
ing nodes that you can expand and collapse. At the end
Chapter 2 describes the classical controls. These controls are encapsulated to such an extent that they can be
that you can output very powerful lists with just one
the context menu. This function is very useful for SAP us-
our applications. But you'll see that you can easily use
Introduction
Include
Description
<Program name>_PBO
PBO module
<Program name>_UP
FORM routines
<Program name>_CL
Local classes
trols provided by SAP, but that the Desktop Ofce Integration (DOI) interface enables you to integrate any
troubleshooting.
ror again.
dividual topics. Therefore, the Appendix contains a detailed description of the directory paths for Releases 4.6
In most of the examples, we'll use the following procedure: First, well integrate the module call into the
and 4.7.
include statements:
clicking on the name. It is imperative that you perform this action in the correct include statement.
Include
Description
<Program name>_TOP
Data denitions
<Program name>_PAI
PAI module
SAP Toolbar
In our last example, we saw that the TextEdit control provides an application toolbar. The SAP Toolbar Control
( class CL_GUI_TOOLBAR ) enables you to integrate such
application toolbars into your own applications, but this
Toolbar Control must also be embedded into a container.
You can integrate the following objects in your appli-
cation toolbar:
Menu
Splitter bar/separator
icon on the button, we'll use the type pool ICON that
contains the denitions for all SAP icons.
*&--------------------------------------*
PROGRAM
ZCFW_32_TOOLBAR.
First create a dialog program called ZCFW_32_TOOLBAR as described in Section 4.1. Assign an appropriate
*&--------------------------------------*
is executable.
*&--------------------------------------*
www.sap-press.com
61
SAP Toolbar
* SHOWICON
*&--------------------------------------*
*&--------------------------------------*
TYPE-POOLS: icon.
*&--------------------------------------*
DATA:
clude name. In order to be able to activate the TOP include we'll implement the local class as follows:
obj_custom_container
TYPE REF TO cl_gui_custom_container,
*---------------------------------------*
obj_toolbar
TYPE REF TO cl_gui_toolbar.
INCLUDE ZCFW_32_TOOLBAR_CL
*---------------------------------------*
*&--------------------------------------*
* Event table
*****************************************
*&--------------------------------------*
* CLASS
DATA: t_events
TYPE cntl_simple_events,
* DEFINITION
TYPE cntl_simple_event.
*****************************************
wa_event
cl_event_receiver
ENDCLASS.
*****************************************
* object reference
* CLASS
*&--------------------------------------*
* IMPLEMENTATION
INCLUDE ZCFW_32_TOOLBAR_CL.
*****************************************
cl_event_receiver
DATA: obj_event_receiver
TYPE REF TO cl_event_receiver,
fcode
TYPE ui_func.
* User action
*&--------------------------------------*
DATA:
TYPE sy-ucomm,
okcode
ATE_TOOLBAR.
Create the following ow logic:
*&--------------------------------------*
* Table for toolbar buttons
*&--------------------------------------*
TYPE-POOLS: CNTB.
DATA:
s_toolbar_button
TYPE stb_button,
MODULE create_objects.
t_toolbar_button
TYPE ttb_button.
MODULE register_events.
MODULE create_toolbar.
*&--------------------------------------*
* Names of icons
62
8 SAP Toolbar
MODULE user_command_0100.
the area in the dynpro. In the next step, we'll instance the
MODULE exit_command_0100.
*&---------------------------------------------------------*
*&
Module
create_objects
OUTPUT
*&---------------------------------------------------------*
*
Create instances
*&---------------------------------------------------------*
MODULE create_objects OUTPUT.
IF NOT obj_custom_container IS INITIAL.
EXIT.
ENDIF.
*&---------------------------------------------------------*
*
*&---------------------------------------------------------*
CREATE OBJECT obj_custom_container
EXPORTING
*
PARENT
CONTAINER_NAME
= 'DYNPRO_CONTAINER'
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 i398(00)
WITH 'Error' sy-subrc
'when creating the custom container control'.
ENDIF.
*&---------------------------------------------------------*
*
Note:
www.sap-press.com
63
SAP Toolbar
>= 1 row
Vertical
>= 4 columns
application toolbar:
*&---------------------------------------------------------*
CREATE OBJECT obj_toolbar
EXPORTING
PARENT
= obj_custom_container
SHELLSTYLE
LIFETIME
DISPLAY_MODE
= cl_gui_toolbar=>m_mode_horizontal
DISPLAY_MODE
= cl_gui_toolbar=>m_mode_vertical
NAME
*
*
EXCEPTIONS
CNTL_INSTALL_ERROR = 1
CNTL_ERROR
= 2
CNTB_WRONG_VERSION = 3
others
= 4.
IF SY-SUBRC <> 0.
MESSAGE i398(00)
WITH 'Error' sy-subrc
'when creating the toolbar control'.
ENDIF.
ENDMODULE.
" create_objects
OUTPUT
of an error.
method.
Module
register_events
OUTPUT
*&---------------------------------------------------------*
*
Event handling
*&---------------------------------------------------------*
MODULE register_events OUTPUT.
*&---------------------------------------------------------*
*
*&---------------------------------------------------------*
CLEAR wa_event.
CLEAR t_events.
wa_event-eventid = CL_GUI_TOOLBAR=>M_ID_FUNCTION_SELECTED.
wa_event-appl_event = ' '.
Listing 8.2 PBO Module REGISTER_EVENTS
64
8 SAP Toolbar
= t_events
EXCEPTIONS
CNTL_ERROR
= 1
others
= 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00)
WITH 'Error' sy-subrc
'when registering the events'.
ENDIF.
*&---------------------------------------------------------*
*
*&---------------------------------------------------------*
IF obj_event_receiver IS INITIAL.
CREATE OBJECT obj_event_receiver.
SET HANDLER obj_event_receiver->on_function_selected
FOR obj_toolbar.
ENDIF.
ENDMODULE.
" register_events
OUTPUT
* Handling method:
*----------------------------------------
on_function_selected
METHOD on_function_selected.
IF sender = obj_toolbar.
CASE fcode.
WHEN 'FCODE_CANCEL'.
MESSAGE i398(00)
www.sap-press.com
65
SAP Toolbar
MESSAGE i398(00)
ENDCASE.
ENDIF
cation
toolbar,
the
fill_data_buttons_table
CALL METHOD
Parameter
Data type
Meaning
fcode
ui_func
Function code
icon
Name of an icon
disabled
butn_type
tb_btype
text
text40
Text on button
quickinfo
iconquick
checked
data_table
ttb_button
cl_gui_cfw=>set_new_ok_code
EXPORTING new_code = fcode.
ENDMETHOD.
ENDCLASS.
If, in addition to the transferred function code, the content of other dynpro elements is required for further processing, the event must either be handled as an application event, or the PAI processing must be explicitly trig-
Form
fill_buttons_data_table
*&---------------------------------------------------------*
*
Fill a table
*&---------------------------------------------------------*
FORM fill_buttons_data_table
USING p_fcode
TYPE ui_func
"function code
p_icon
TYPE c
"name of an icon
p_type
TYPE tb_btype
p_text
TYPE text40
"text on buttons
p_tip
TYPE iconquick
FCODE
= p_fcode
ICON
= p_icon
DISABLED
BUTN_TYPE
= p_type
66
8 SAP Toolbar
TEXT
= p_text
QUICKINFO
= p_tip
CHECKED
CHANGING
DATA_TABLE
= p_ttb_button
EXCEPTIONS
CNTB_BTYPE_ERROR = 1
others
= 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00)
WITH 'Error' sy-subrc
'at method fill_buttons_data_table.
ENDIF.
ENDFORM.
" fill_buttons_data_table
EXIT.
ENDIF.
*&--------------------------------------*
ton types:
*&--------------------------------------*
Value
Meaning
cntb_btype_button
Button
cntb_btype_dropdown
cntb_btype_menu
Menu
cntb_btype_sep
Splitter bars/separators
cntb_btype_group
Button group
cntb_btype_check
Toggle button
cntb_btype_button
'Cancel'
t_toolbar_button,
'FCODE_CREATE'
ICON_CREATE
'Create'
cntb_btype_button
'Create'
t_toolbar_button,
'FCODE_CHANGE'
Once we have built up the internal table with the buttons, we must add it to the toolbar. To do this, we'll use
the add_button_group method. This results in the following implementation:
ICON_CHANGE
'Change'
'Change'
t_toolbar_button,
'FCODE_DELETE'
ICON_DELETE
*&--------------------------------------*
*&
Module
create_toolbar
OUTPUT
*&--------------------------------------*
*
toolbar
cntb_btype_button
*&--------------------------------------*
'Delete'
cntb_btype_button
'Delete'
t_toolbar_button,
'FCODE_SEARCH'
ICON_SEARCH
'Search'
cntb_btype_button
'Search'
t_toolbar_button.
www.sap-press.com
67
SAP Toolbar
*&--------------------------------------*
*
toolbar
CASE sy-dynnr.
WHEN 0100.
CASE save_okcode.
*&--------------------------------------*
WHEN 'EXIT'.
CALL METHOD
PERFORM free_objects.
obj_toolbar->add_button_group
LEAVE PROGRAM.
EXPORTING
WHEN 'BACK'.
DATA_TABLE
= t_toolbar_button
EXCEPTIONS
DP_ERROR
= 1
CNTB_ERROR_FCODE = 2
others
= 3.
MESSAGE i398(00)
IF SY-SUBRC <> 0.
MESSAGE i398(00)
'for button'.
WHEN 'FCODE_CREATE'.
'at method'
MESSAGE i398(00)
'ADD_BUTTON_GROUP'.
ENDIF.
'for button'.
ENDMODULE.
" create_toolbar
OUTPUT
WHEN 'FCODE_CHANGE'.
MESSAGE i398(00)
'for button'.
WHEN 'FCODE_DELETE'.
MESSAGE i398(00)
'for button'.
WHEN 'FCODE_SEARCH'.
MESSAGE i398(00)
'for button'.
ENDCASE.
ENDCASE.
ENDMODULE.
" USER_COMMAND_0100
INPUT
*&
Module
USER_COMMAND_0100
INPUT
*&--------------------------------------*
*---------------------------------------*
save_okcode = okcode.
CLEAR okcode.
68
Index
ActiveX Controls 11
Object Navigator 17
Event handling 14
OK field 5, 14
Automation Controller 11
EXIT_COMMAND_0100 20
Flow logic 5
Parent parameter 23
Flush 12
PBO processing 12
Basic program 17
FLUSH_ERROR 13
Performance optimization 12
Flush call 12
Picture Control 17
Functional type 20
Automation Queue 12
Automation Trace 16
CALL SUBSCREEN 7
CFW 11
GUI status 18
CFW services 11
GUI title 18
Re-link 36
CL_GUI_CFW 13, 15
CL_GUI_CONTROL 15
Representative classes 12
Representative object 12, 15
CL_GUI_DIALOGBOX_CONTAINER 39
CL_GUI_HTML_VIEWER 49
Handling method 15
RFC calls 12
CL_GUI_OBJECT 15
HTML pages 49
RFC connection 12
CL_GUI_TEXTEDIT 57
Class Builder 25
Class hierarchy 15, 35
Result parameters 12
CNTL 28
CNTL_ERROR 13
Input checks 20
SAP TextEdit 57
Communication 12
Internet browser 49
SAP Toolbar 61
Container control 35
Control event 32
Screen Painter 5, 21
Control Framework 11
Copy 26
Java Beans 11
SENDER 30
SET_HANDLER 14
SET_NEW_OK_CODE 15
SET_REGISTERED_EVENTS 15
L
Lifetime Management 15
SHOWICON report 67
Splitter container control 42
Start dynpro 17
Statement pattern 23
Debugging 16
Dialog box container control 37
Dialog transaction 18
MIME documents 49
Subscreen dynpro 5
sy-ucomm 14
Subscreen area 5
www.sap-press.com
163
Index
Synchronization 12
TOP include 17
Synchronization time 12
Trace file 16
Wizard 8, 9
Type group 28
Wordwrap 59
Type pool 61
Wrapping 12
T
Table Control 7
TabStrip 5
UP include 18
Tabstrip control 5
URL address 51
Testing 16
USER_COMMAND_0100 20
TextEdit Control 57
164