You are on page 1of 15

10

ISBN 1-59229-073-6

Techniques to simplify the development of essential lists

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

SAP Controls
Workshop

SAP PRESS Essentials

Harald Rser

SAP PRESS Essentials 10

073_cover.indd 1

05.12.2005 17:07:28

SAP Controls Workshop


Harald Rser

Contents
1
2

Introduction .............................................

SAP HTML Viewer .................................. 49

SAP TextEdit ............................................. 57


SAP Toolbar .............................................. 61

Classical Controls ...................................

2.1

Tabstrip Control ...................................

2.2

Table Control .......................................

Control Framework ( CFW ) ................. 11

SAP Tree and Tree Model ..................... 69

3.1

Architecture ......................................... 11

9.1

SAP Simple Tree ................................... 70

3.2

Automation Queue .............................. 12

9.2

SAP Column Tree ................................. 79

3.3

Event Handling .................................... 14

9.3

SAP List Tree ........................................ 87

3.4

Lifetime Management .......................... 15

9.4

SAP Tree Model ................................... 92

3.5

Class Hierarchy .................................... 15

3.6

Testing an Application .......................... 16

10 SAP ALV Grid ........................................... 99


10.1 ALV Grid with Predened Structure in

Custom Containers with Picture


Controls ..................................................... 17
4.1

the ABAP Dictionary ............................ 100


Some Notes on the

Basic Program ...................................... 17

Standard Functions ............................. 103

Summary ............................................. 20

10.2 ALV Grid with Display Variant .............. 103

4.2

Controls for Container and Picture ....... 21

10.3 ALV Grid with Selectable

4.3

Method Call ........................................ 24

Data Area Layout ................................. 104

Summary ............................................. 26

10.4 ALV Grid with Toolbar ......................... 107

4.4

Event Handling .................................... 26

10.5 ALV Grid with Field Catalog ................. 112

System Event ...................................... 31

10.6 ALV Grid with Double-Click Event

Summary ............................................. 32

and Hotspot ........................................ 116

Container Controls ................................. 35

11 Context Menu ......................................... 121

5.1

Custom Container Control ................... 35

5.2

Dialog Box Container Control .............. 37

5.3

Docking Container Control .................. 40

5.4

Splitter Container Control .................... 42

5.5

Easy Splitter Container Control ............ 45

11.1 Context Menu for the Picture


Control ................................................ 121
11.2 Context Menu for Tree Control and
Tree Model .......................................... 125
11.3 Context Menu for the ALV Grid
Control ................................................ 127

www.sap-press.com

Content

12 Drag&Drop ............................................... 131

Appendix ................................................... 161

12.1 The Drag&Drop Operation ................... 132

A.1 Sample Programs .................................... 161

12.2 Events of the Drag&Drop Operation .... 132

A.2 Test Data in the Front-End PC ................ 162

12.3 Creating a Sample Application .............. 133

A.3 Online Documentation ........................... 162

13 Desktop Ofce Integration ................. 143

Index ................................................................... 163

13.1 Integrating Ofce Applications .............. 144


13.2 Integrating MS Excel Functions ............. 155

Galileo Press 2006. All rights reserved.

Introduction

This workshop provides you with a step-by-step intro-

ple programs in this workshop. You should create this ba-

duction to programming GUI controls. It is intended for

sic program in your SAP system as a template. Then, we'll

ABAP developers who have a basic knowledge of dialog

use a very simple control to create our rst sample pro-

programming and ABAP Objects. However, if you are not

gram. We'll also highlight the various event-handling op-

yet familiar with object-oriented programming, youll

tions for you.

soon learn that it is relatively easy to use GUI controls to

Chapter 5 deals with the container concept. Because a

create dialog programs. Furthermore, since GUI controls

GUI control cannot be executed on its own, it must al-

are available exclusively as instances and interfaces, and

ways be wrapped by a container. SAP provides many dif-

the functions must therefore be called via methods, you

ferent types of containers, which we'll show you in a

will nd that this is a very practical exercise that should

sample program.

prove helpful to you in your work.

Chapters 6 through 8 describe various GUI controls

One of the most common areas of application in which

such as SAP HTML Viewer, SAP TextEdit, and SAP Tool-

controls are used is in the output of controllable lists. You

bar. For each of these controls, we'll create a sample pro-

probably know that you can create lists in a report using

gram to demonstrate the different functions.

the WRITE statement, and even create interactive lists us-

Chapter 9 deals with the various controls used to out-

ing the HIDE statement. Perhaps youre also familiar with

put hierarchical lists. If youre an experienced developer,

the step loop technique for outputting screen lists in a

youll already be familiar with this type of output from

dynpro. During the course of this workshop, you will

Object Navigator (Transaction SE80). For an easier navi-

learn about many other ways in which to output data in

gation, the list is often output in a tree structure contain-

hierarchical and non-hierarchical lists.

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

of this chapter, you should be able to implement these


tree structures in your own applications.

called with the corresponding ABAP statements. Unfor-

Chapter 10 revisits the description of screen list out-

tunately, the request is quite complex with regard to the

puts. After instancing the necessary objects, youll see

ow logic and the ABAP program, which is why the user

that you can output very powerful lists with just one

is supported by a wizard during the implementation pro-

method call. By default, these lists contain nearly every

cess. Nevertheless, this information on the underlying

detail you will need. If you previously used many com-

concepts should prove useful to you in your work.

plex function modules to obtain the same result, this part

Chapter 3 contains some basic information on the use

of your life has just become much easier.

of GUI controls. Since GUI controls are used to develop

In Chapter 11, you'll be introduced to the controls for

technically sophisticated client/server applications, it is

the context menu. This function is very useful for SAP us-

critical that you pay attention to certain aspects of these

ers because it provides context-sensitive support for the

controls, so you can enjoy the full range of their function-

operation of the system. Unfortunately, all too often, we

alities. Client/server applications make extensive use of

(as developers) simply forget to provide this useful aide in

the event control from ABAP Objects.

our applications. But you'll see that you can easily use

Chapter 4 shows you howstep by stepto create a


basic dialog program, which is used as a basis for all sam-

GUI controls to compensate for this faux pas and make a


lot of new friends in the user departments.
www.sap-press.com

Introduction

In Chapter 12, we'll describe the Drag&Drop concept


and use an example to demonstrate the possibilities that
are available once this functionality is implemented.
Finally, in Chapter 13, we'll demonstrate that the GUI
controls concept cannot only be used to integrate con-

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

The module pool lists only the include statements,

OLE2-enabled external application. The provided inter-

with the exception of the include statement for local

faces enable you to transfer data directly into ofce ap-

classes, since this statement is always implemented in

plications such as MS Word or Excel, or into your own


Visual Basic programs. In most cases, this data can also be

the TOP include.




can activate the modules between the individual

retransferred into the SAP system.

steps without causing any syntax errors. You should

The Appendix contains a list of all sample programs.

always execute these activation steps to facilitate

You can download these programs from www.sap-press.

troubleshooting.

com/go/essentials, which will save you editing time when


you reprogram the examples. In any case, you should try

The examples are structured in such a way that you

You will often create sample programs due to copies

to create the sample programs yourself. When preparing

of existing examples or copies of the basic dialog pro-

them, we tried to keep the necessary coding effort to a

gram. The creation of this basic program is described

minimum. The instancings to classes and the method calls

in Section 4.1. Section 4.4 describes the procedure of


copying dialog programs.

can be generated via the Pattern function. Needless to


say, the programs won't be free of errors initially, how-

When copying sample programs, you should note

ever, it is precisely this troubleshooting process that in-

that the _CL include statement for local classes will

creases the mastery of learning and your understanding

not be copied because it is not integrated in the

of the functionality involved. You should copy only the

module pool, but rather in the TOP include statement.

source code of the sample solution into your modules if


you get stuck and no longer know how to proceed. Fur-

If you use the copy process to generate sample pro-

thermore, you should try to identify the cause of the er-

grams, remember that you must create a transaction

ror again.

code for the newly-generated program and that you


should adapt the GUI title.

The online documentation contains a comprehensive


description of the GUI controls introduced in this book. If

For the examples, we'll use only text literals to im-

you want to indulge further into a certain subject, refer-

prove the readability of the programs. However, we

ring to the online documentation would be your best

dont recommend that a programmer engage in this

bet. Unfortunately, sometimes its difcult to nd the in-

behavior. Instead, we advise that text elements be


used.

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.

ow logic, or the call of the subroutine into the ABAP

Before we start, I'd like to provide you with some


additional information on the sample programs:

program respectively. Then, you can easily create the

To obtain a clear design, we'll use the following

module or subroutine to be added by simply double-

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

ming code that has been omitted for the purposes of

<Program name>_PAI

PAI module

clarity and readability.

Galileo Press 2006. All rights reserved.

We'll use the colon (:) as an indicator for program-

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-

Figure 8.1 SAP Toolbar Control

cation toolbar:


Button ( with icon and name )

First, we have to create an area called DYNPRO_CON-

Button ( with dropdown menu )

TAINER with row height 1 for the custom control in the

If you click on the button, the assigned function is

dynpro. We'll use the Screen Painter to do that. Then, we

triggered. If you click on the arrow next to the but-

have to complement the TOP include with the object ref-

ton, a menu is expanded.

erence variables for the container and the toolbar. Press-

Menu

ing the function key will trigger an event. Therefore, we'll

If you click on the button, a menu is displayed.

provide an internal table and a work area for the registra-

Splitter bar/separator

tion. For event handling, we'll create a local class with a

Button group ( similar to checkboxes )

handling method. For better readability, we'll encode the

Toggle buttons ( similar to radio buttons )

local class in a separate include statement. We also need


an object reference variable to instance this class. The in-

You can arrange the buttons in the application toolbar

dividual buttons of the application toolbar will be de-

horizontally or vertically. As soon as you click on a but-

scribed as elements of an internal table. For the row

ton, the control framework carries out the event control,

structure and the table type, SAP provides type deni-

and simultaneously, the assigned function code is trans-

tions in the type pool CNTB. Since we'll also output an

ferred to the control framework.

icon on the button, we'll use the type pool ICON that
contains the denitions for all SAP icons.

Note The SAP Toolbar Control assumes that the


Microsoft Common control is present. The latter is in-

This results in the following implementation for our


TOP include:

stalled by the Microsoft Internet Explorer.


*&--------------------------------------*
In our example, we'll create a horizontal application tool-

*& Include ZCFW_32_TOOLBAR_TOP

bar in the dynpro. To respond to the activation of the in-

*&--------------------------------------*

dividual buttons, we'll output a corresponding message.

PROGRAM

ZCFW_32_TOOLBAR.

First create a dialog program called ZCFW_32_TOOLBAR as described in Section 4.1. Assign an appropriate

*&--------------------------------------*

GUI title to the program and check whether the program

* Definition for the control framework

is executable.

*&--------------------------------------*

www.sap-press.com

61

SAP Toolbar

CLASS cl_gui_cfw DEFINITION LOAD.

* SHOWICON
*&--------------------------------------*

*&--------------------------------------*

TYPE-POOLS: icon.

* Object reference variables (user


* control)

We can create the include statement for dening and im-

*&--------------------------------------*

plementing the local class by double-clicking on the in-

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

CLASS cl_event_receiver DEFINITION.


*&--------------------------------------*

ENDCLASS.

* Define class for event handler and

*****************************************

* object reference

* CLASS

*&--------------------------------------*

* IMPLEMENTATION

INCLUDE ZCFW_32_TOOLBAR_CL.

*****************************************

cl_event_receiver

CLASS cl_event_receiver IMPLEMENTATION.


ENDCLASS.

DATA: obj_event_receiver
TYPE REF TO cl_event_receiver,

We'll use three additional PBO modules in our ow logic.

fcode

The PBO module CREATE_OBJECTS will be used to create

TYPE ui_func.

the container and toolbar objects. For registering the


*&--------------------------------------*

events at the front-end PC, creating the event handler,

* User action

and registering the events we'll provide the PBO module

*&--------------------------------------*

REGISTER_EVENTS. You should already be familiar with

DATA:

TYPE sy-ucomm,

these steps from the previous examples. The individual

save_okcode TYPE sy-ucomm.

buttons will now be created in the PBO module CRE-

okcode

ATE_TOOLBAR.
Create the following ow logic:

*&--------------------------------------*
* Table for toolbar buttons
*&--------------------------------------*

PROCESS BEFORE OUTPUT.


MODULE status_0100.

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

PROCESS AFTER INPUT.

* Overview of all icons with report

62

Galileo Press 2006. All rights reserved.

8 SAP Toolbar

MODULE user_command_0100.

the area in the dynpro. In the next step, we'll instance the

MODULE exit_command_0100.

toolbar control and connect it to the custom container.


You can use the DISPLAY_MODE parameter to specify

Then create the PBO modules by double-clicking on the

the orientation of the application toolbar. A horizontal

module names. In the PBO module CREATE_OBJECTS,

application toolbar must have a height of at least one

we'll query whether the custom container object already

row, and a vertical application toolbar should be at least

exists. If it doesn't exist, we'll create it and connect it to

four columns wide. Listing 8.1 shows the result.

*&---------------------------------------------------------*
*&

Module

create_objects

OUTPUT

*&---------------------------------------------------------*
*

Create instances

*&---------------------------------------------------------*
MODULE create_objects OUTPUT.
IF NOT obj_custom_container IS INITIAL.
EXIT.
ENDIF.
*&---------------------------------------------------------*
*

Create instance for custom container

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

Create instance for toolbar control

Note:

Listing 8.1 PBO Module CREATE_OBJECTS

www.sap-press.com

63

SAP Toolbar

Horizontal application 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

Listing 8.1 PBO Module CREATE_OBJECTS (cont.)

We recommend that you activate the development ob-

M_ID_FUNCTION_SELECTED is available for the EVEN-

jects periodically to facilitate troubleshooting in the event

TID parameter in the class CL_GUI_TOOLBAR. To handle

of an error.

the event, we'll use the on_function_selected

Now we'll create the PBO module REGISTER_EVENTS

method.

( see Listing 8.2 ). To register the event, the static attribute


*&---------------------------------------------------------*
*&

Module

register_events

OUTPUT

*&---------------------------------------------------------*
*

Event handling

*&---------------------------------------------------------*
MODULE register_events OUTPUT.
*&---------------------------------------------------------*
*

Register events as system events at CFW

*&---------------------------------------------------------*
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

Galileo Press 2006. All rights reserved.

8 SAP Toolbar

APPEND wa_event TO t_events.


CALL METHOD obj_toolbar->set_registered_events
EXPORTING
EVENTS

= t_events

EXCEPTIONS
CNTL_ERROR

= 1

others

= 2.

IF SY-SUBRC <> 0.
MESSAGE i398(00)
WITH 'Error' sy-subrc
'when registering the events'.
ENDIF.
*&---------------------------------------------------------*
*

Create event handler and register events

*&---------------------------------------------------------*
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

Listing 8.2 PBO Module REGISTER_EVENTS

At this point, we can also create the denition for the

* Handling method:

handling method. The CL_GUI_TOOLBAR class provides

*----------------------------------------

on_function_selected

the FUNCTION_SELECTED event. The function code of

METHOD on_function_selected.

the selected button or menu item is transferred in the

IF sender = obj_toolbar.

FCODE parameter. Therefore, we obtain the following


denition for the local class:

CASE fcode.
WHEN 'FCODE_CANCEL'.
MESSAGE i398(00)

CLASS cl_event_receiver DEFINITION.


PUBLIC SECTION.
METHODS on_function_selected
FOR EVENT function_selected
OF cl_gui_toolbar
IMPORTING fcode sender.
ENDCLASS.

WITH 'button CANCEL'


'was pressed !'.
WHEN 'FCODE_CREATE'.
MESSAGE i398(00)
WITH 'button CREATE'
'was pressed !'.
WHEN 'FCODE_CHANGE'.
MESSAGE i398(00)

As a response to the user action, we will merely output a


notication message, therefore, we'll create the following
denition for our handling method:

WITH 'button CHANGE'


'was pressed !'.
WHEN 'FCODE_DELETE'.
MESSAGE i398(00)

CLASS cl_event_receiver IMPLEMENTATION.


*---------------------------------------* Triggering event: function_selected

WITH 'button DELETE'


'was pressed !'.
WHEN 'FCODE_SEARCH'.

www.sap-press.com

65

SAP Toolbar

In the last PBO module of our ow logic, we must dene

MESSAGE i398(00)

the application toolbar. To do this, we must rst dene

WITH 'button SEARCH'

the individual buttons in an internal table. Then, this list

'was pressed !'.

of buttons must be added to the toolbar.

ENDCASE.
ENDIF

To ll this internal table with the buttons of the appli-

*--- Trigger PAI and transfer

cation

* function code (system event) ---*

method is provided with the following parameters:

toolbar,

the

fill_data_buttons_table

CALL METHOD
Parameter

Data type

Meaning

fcode

ui_func

Function code

icon

Name of an icon

disabled

Active/inactive status of button

butn_type

tb_btype

Toolbar button type

If you recall, when an event is handled as a system event

text

text40

Text on button

by the control framework, no PAI processing takes place.

quickinfo

iconquick

Tooltip for icon

checked

Button has/has not been selected

data_table

ttb_button

Internal table with buttons

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-

Table 8.1 Parameters for FILL_DATA_BUTTONS_TABLE Method

gered, by using the set_new_ok_code method in the


handling method, for the system event to transfer the

To ll the internal table with the individual buttons, we'll

function code to the PAI modules. In our example, we'll

create a subroutine as shown in Listing 8.3.

use the latter technique.


*&---------------------------------------------------------*
*&

Form

fill_buttons_data_table

*&---------------------------------------------------------*
*

Fill a table

for creating several buttons

*&---------------------------------------------------------*
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

"toolbar button type

p_text

TYPE text40

"text on buttons

p_tip

TYPE iconquick

"tooltip for icon

CHANGING p_ttb_button TYPE ttb_button. "toolbar buttons


* Define button and enter in table
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING

FCODE

= p_fcode

ICON

= p_icon

DISABLED

BUTN_TYPE

= p_type

Listing 8.3 Subroutine for Filling Internal Tables

66

Galileo Press 2006. All rights reserved.

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

Listing 8.3 Subroutine for Filling Internal Tables (cont.)

In the PBO module CREATE_TOOLBAR, we'll rst create

MODULE create_toolbar OUTPUT.

the individual buttons and provide them in the internal

IF NOT t_toolbar_button IS INITIAL.

table. You can obtain a clear and quick overview of the

EXIT.

existing icons and their names by starting the SHOW-

ENDIF.

ICON report. The following table contains possible but-

*&--------------------------------------*

ton types:

Create table with buttons

*&--------------------------------------*
Value

Meaning

cntb_btype_button

Button

cntb_btype_dropdown

Button with menu

cntb_btype_menu

Menu

cntb_btype_sep

Splitter bars/separators

cntb_btype_group

Button group

cntb_btype_check

Toggle button

PERFORM fill_buttons_data_table USING:


'FCODE_CANCEL'
ICON_CANCEL
'Cancel'

cntb_btype_button

'Cancel'

t_toolbar_button,
'FCODE_CREATE'
ICON_CREATE

Table 8.2 Possible Values for the BUTN_TYPE Parameter

'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

*&--------------------------------------*
*

Add list of buttons to

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

*&--------------------------------------*
*

Add list of buttons to

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

LEAVE TO SCREEN 100.


*--- PAI processing upon completion of

DP_ERROR

= 1

CNTB_ERROR_FCODE = 2
others

handling method ---*


WHEN 'FCODE_CANCEL'.

= 3.

MESSAGE i398(00)

IF SY-SUBRC <> 0.

WITH 'CANCEL PAI processing'

MESSAGE i398(00)

'for button'.

WITH 'Error' sy-subrc

WHEN 'FCODE_CREATE'.

'at method'

MESSAGE i398(00)

'ADD_BUTTON_GROUP'.

WITH 'CREATE PAI processing'

ENDIF.

'for button'.

ENDMODULE.

" create_toolbar

OUTPUT

WHEN 'FCODE_CHANGE'.
MESSAGE i398(00)

We'll use the free method again to release the instances.

WITH 'CHANGE PAI processing'

The object reference variables will be initialized with the

'for button'.

ABAP statement FREE. Therefore, we'll create a subrou-

WHEN 'FCODE_DELETE'.

tine that contains the necessary calls. Before the subrou-

MESSAGE i398(00)

tine ends, the automation queue should be synchronized

WITH 'DELETE PAI processing'

with the cl_gui_cfw=>flush method. Make sure that


the subroutine is always called before the application
exits.

'for button'.
WHEN 'FCODE_SEARCH'.
MESSAGE i398(00)

Furthermore, we'll query the SAP Toolbar function

WITH 'SEARCH PAI processing'

codes in the PAI module USER_COMMAND_0100. As a


prerequisite for this step, we have already implemented

'for button'.
ENDCASE.

the cl_gui_cfw=>set_new_ok_code method in the

ENDCASE.

handling method. And nally, to respond to the user ac-

ENDMODULE.

" USER_COMMAND_0100

INPUT

tion, we'll output a corresponding message again.


We have now completed our second sample application.
*&--------------------------------------*

We should be able to activate all modules without en-

*&

countering any problems. Start the transaction and click

Module

USER_COMMAND_0100

INPUT

*&--------------------------------------*

on one of the buttons in the SAP Toolbar. You should see

two sequential messages displayed. The rst message is

Query user action

*---------------------------------------*

output by the handling method for the system event; the

MODULE user_command_0100 INPUT.

second message is output by the PAI module. Where you

save_okcode = okcode.

want to program the functionality for the selected button

CLEAR okcode.

depends entirely on your own specic requirements.

68

Galileo Press 2006. All rights reserved.

Index

ActiveX Controls 11

Easy splitter container control 45

Object Navigator 17

Application event 15, 32

Event handling 14

OK field 5, 14

Automation Controller 11

EXIT_COMMAND_0100 20

Online documentation 8, 24, 37

Flow logic 5

Parent parameter 23

Flush 12

PBO processing 12

Basic program 17

FLUSH_ERROR 13

Performance optimization 12

Business Document Server 26

Flush call 12

Picture Control 17

Functional type 20

Process After Input 5

Automation Queue 12
Automation Trace 16

Process Before Output 5

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

HTML Viewer control 49

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

Custom container control 35

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

SAP HTML Viewer 49

Step loop technique 8

Dialog transaction 18

Docking container control 40

MIME documents 49

Subscreen dynpro 5

Modeless dialog box 37

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

System event 15, 31

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

Galileo Press 2006. All rights reserved.

You might also like