Professional Documents
Culture Documents
5HOHDVH
This guide provides delta information for several Releases. Select the
appropriate view.
You can also choose to view only the samples for each Release delta.
March 2000
English
™
ABAP Workbench Delta Guide (3.1-4.6)
&RS\ULJKW,QIRUPDWLRQ
SAP AG 2
ABAP Workbench Delta Guide (3.1-4.6)
$ERXWWKLV'HOWD*XLGH
3XUSRVH
This Delta Guide is designed for R/3 consultants and developers who are already
proficient in a functional area of SAP R/3 Release 3.x software. They can use it to
learn about the features available within SAP R/3 Releases 4.0, 4.5, and 4.6.
:KDW
V,QVLGH
• The ABAP Workbench Delta Guide CD covers the following Release deltas:
3.1 - 4.0 3.1 - 4.5 3.1 - 4.6 4.0 - 4.6
• These deltas have been divided into different views. There are also views of
the samples of each Release delta.
• The What’s New page provides a quick, general overview of all the new
developments and features in the ABAP Workbench for each delta.
• The topics present information about individual activities or concepts that you
need to master. The topics are organized into sub-units and content pages. In
each view, only the topics, units, and pages to have changed in the
corresponding Release are displayed. To help you further, the title of each
topic indicates the release in which it was introduced.
• Learning Objectives precede each topic and help you define a set of specific
goals and results against which you can measure your success in learning the
material.
• Samples are included for each topic, to show how the corresponding feature
can be used in practice. There are coding examples, exercises and other
material, which you can also access using separate sample views.
• Links to related R/3 system documentation (SAP Library) are a source of
specific information and a starting point for further reading. The ABAP
Workbench Delta Guide CD contains the BC component only.
• Print files (PDF) are provided for the main deltas (3.1 - 4.0, 3.1 - 4.5, 3.1 -
4.6).
+RZWR8VHWKLV'HOWD*XLGH
Select the appropriate Release/Samples view from the starting page. The title of
the selected view is visible in the navigation frame.
The SAP Knowledge Warehouse training browser interface features an
expandable navigation tree for switching between units, topics, and pages. With
the Next and Previous buttons you can move between items in sequence. The
Synchronize button is useful especially for the R/3 documentation links: When
you press it, the structure of the corresponding documentation folder is displayed,
allowing you to navigate to other related topics in the SAP Library. Additionally
links to SAP Library and SAPNet provide direct access to further information
sources.
6$3'HOWD*XLGHV3URGXFW6XSSRUW
Use SAPNet (http://sapnet.sap.com) to obtain the latest information about SAP
Delta Guides and other SAP Education self-guided learning products. A SAPNet
ID will be required.
• Remote Learning
• Study Guides
SAP AG 3
ABAP Workbench Delta Guide (3.1-4.6)
• Delta 4.6
• Self Study Options
• e-Learning
• Education Services
Visit our public Web site at www.sap.com/education if you do not have a SAPNet
ID.
Please send comments and questions to edsoft.us@sap.com.
SAP AG 4
ABAP Workbench Delta Guide (3.1-4.6)
3UHSDULQJIRU5HFHUWLILFDWLRQ
For continued project success, experienced consultants need to ensure that they
always have the most up-to-date information and tools. To provide all consultants
with the opportunity to keep their SAP skills and knowledge up-to-date, SAP offers
the opportunity to retrain and recertify their SAP skills and knowledge at
scheduled intervals. These intervals are defined by the changes in functionality
offered by the different software releases and editions.
This Delta Guide, together with hands-on experience, largely covers the new skills
and knowledge required for the application area functionality. Experience or
additional training may be necessary for other required skills and knowledge.
For more information about the recertification program, the detailed contents and
additional preparation sources, contact your local SAP office located in your
region or our Web www.sap.com/partner.
SAP AG 5
ABAP Workbench Delta Guide (3.1-4.6)
:KDW
V1HZLQ5HO
:RUNEHQFK7RROV
The tools of the new ABAP Workbench provide several new features and
functionalities that improve usability:
• New terminology
• Extended names
• Namespaces
• Active/Inactive sources
• Object Navigator
• ABAP Editor
• ABAP Debugger
• Runtime Analysis
(QKDQFHPHQWV
Originally, the software delivery chain consisted of two components, the customer
and SAP itself. Today, the situation has completely changed. In most cases SAP
does not deliver the software directly to the customer; instead, there are several
participants in the delivery chain.
SAP has changed its enhancement concept in order to provide more appropriate
support for this new situation.
• Business Add-Ins
0RGLILFDWLRQ$VVLVWDQW
In this unit you will learn more about the Modification Assistant, which is new in
Release 4.5. You will see how it guides you through SAP object modification. The
Modification Assistant is very useful at upgrade.
We will a look at the new "Modification Assistant" tool and discuss the effects that
the Modification Assistant has on the behavior of the system at upgrade.
• The Modification Assistant
• The Modification Browser
• Upgrade procedure
• Adjustments with Modification Assistent
• Adjustments without Modification Assistent
$%$3'LFWLRQDU\
• Views can be buffered
• Includes for database views
• Indexes on specific databases
• User-defined types
• Data elements with direct type entry
• Search Help (new concept for F4 help)
$%$3/DQJXDJH
• Type concept
• Internal tables
SAP AG 6
ABAP Workbench Delta Guide (3.1-4.6)
/RJLFDO'DWDEDVH
Up until now, a logical database could only be used with type 1 programs. The
name of the logical database had to be entered in the program attributes so that
programs had access to GET events. Another disadvantage was the fact that a
logical database could not be used with interactive reports or module pools. From
Release 4.5, you can use the new function module LDB_PROCESS to process
logical databases (0XOWLSOH&DOOV).
5HPRWH)XQFWLRQ&DOO
SAP has implemented the concept of WUXVWLQJWUXVWHG systems for Release 4.0.
The idea behind this concept is to allow certain "privileged" users of the RFC-
calling system to log on without a password if a trust relationship is defined
between two R/3 Systems.
'LDORJV
There are some new features in the context of programming dialogs:
• News on input/output elements
• Calling selection screens
• Tabstrip Controls
• Context Menus
SAP AG 7
ABAP Workbench Delta Guide (3.1-4.6)
&RQWURO(QDEOLQJ7HFKQRORJ\
This section describes the architecture and use of the CONTROL FRAMEWORK
(CFW), which provides the basis for the use of Control Enabling Technology
(CET) in the R/3 System.
Since the technology has been redesigned completely in Release 4.6A (switched
to object-oriented techniques), it does not make sense to cover the topic in delta
training. The materials shown here only reflect the state up to and including
Release 4.5.
For further details about the new design in Release 4.6a refer to standard course
BC412.
2IILFH,QWHJUDWLRQ
SAP has developed a new Basis programming technique in R/3 Release 4.0/4.5:
the LQWHJUDWLRQRIGHVNWRSDSSOLFDWLRQVXVLQJ$%$3REMHFWV. At the same
time, this technique represents the first standardized integration technique for
integrating any OLE-capable desktop applications with R/3 in a uniform manner.
In Release 4.6, SAP Desktop Office Integration and the Control Framework have
switched over to global classes. Within the Control Framework, global container
classes have also been introduced, in which objects such as an Office Integration
instance can be displayed.
6$36FULSW
In Release 4.0/4.5 of the R/3 System, SAPscript - SAP’s word processing system
- is much easier to use thanks to a new PC editor and a graphical form painter
which allow you to work simply and intuitively on the basis of WYSIWYG - „What
you see is what you get“.
'DWD7UDQVIHU
Release 4.x includes the following new data transfer tools and functions:
• Legacy System Migration Workbench (LSMW)
• Data Transfer Workbench (SXDA)
• Batch Input Recorder
The basic procedure for transferring data from a non-SAP system into the R/3
System has remained the same. The tools listed above provide support for any
data transfer program you use, whether the program is from SAP or elsewhere.
This makes data transfer more efficient and secure.
Since many new features have shown in the context of Data Transfer in Release
4.6A, it does not make sense to cover the topic in delta training. The materials
shown here only reflect the state up to and including Release 4.5
For further details about these new features in Release 4.6a/b refer to standard
course BC420.
SAP AG 8
ABAP Workbench Delta Guide (3.1-4.6)
:RUNEHQFK7RROV
New Terminology .......................................................................................................................... 15
Extended Names............................................................................................................................. 15
Namespaces.................................................................................................................................... 16
Active/Inactive Sources.................................................................................................................. 17
Object Navigator ............................................................................................................................ 18
ABAP Editor: Overview ................................................................................................................ 20
ABAP Debugger ............................................................................................................................ 22
Overview .................................................................................................................................... 22
ABAP Debugger: Improved Handling ....................................................................................... 23
ABAP Debugger: Breakpoint Overview .................................................................................... 24
Watchpoint Overview................................................................................................................. 25
Runtime Analysis ........................................................................................................................... 26
(QKDQFHPHQWV
Business Add-Ins............................................................................................................................ 29
Introduction ................................................................................................................................ 29
Creating a Business Add-In........................................................................................................ 31
Sample: Calling a Business Add-In............................................................................................ 36
Implementing a Business Add-In ............................................................................................... 38
0RGLILFDWLRQ$VVLVWDQW
Overview and Introduction............................................................................................................. 42
Change Levels ............................................................................................................................ 42
Enhancements to the Standard ................................................................................................... 43
The Modification Assistant ............................................................................................................ 43
Modifying Objects after Modification Assistant Installation ..................................................... 44
Modification of Program Code: The ABAP Editor.................................................................... 45
Modifications in the Screen Painter ........................................................................................... 48
Modifications in the Menu Painter ............................................................................................. 51
Modifying Text Elements........................................................................................................... 54
Modifying and Adding Function Modules ................................................................................. 55
Modifications in the ABAP Dictionary...................................................................................... 56
Modifying Documentation ......................................................................................................... 57
Disabling the Modification Assistant ......................................................................................... 57
Resetting to the Original............................................................................................................. 58
The Modification Browser ............................................................................................................. 58
Upgrade Procedure......................................................................................................................... 59
Adjusting ABAP Dictionary Objects ......................................................................................... 60
Adjusting R/3 Repository Objects (Release 4.5)........................................................................ 60
Adjustments with Modification Assistant ...................................................................................... 61
Adjusting Programs.................................................................................................................... 62
Adjustments in the Screen Painter.............................................................................................. 63
Adjustments in the Menu Painter ............................................................................................... 64
Adjusting Text Elements ............................................................................................................ 65
Adjusting Function Modules ...................................................................................................... 65
Adjusting Documentation........................................................................................................... 65
Adjustments without Modification Assistant ................................................................................. 66
$%$3'LFWLRQDU\
Overview........................................................................................................................................ 68
Buffering Database Views.............................................................................................................. 68
Includes for Database Views.......................................................................................................... 68
Indexes on Specific Databases ....................................................................................................... 68
Named Includes and Views as Includes ......................................................................................... 68
User-Defined Types ....................................................................................................................... 69
Data Elements with Direct Type Entry .......................................................................................... 69
Creating and Using Search Helps................................................................................................... 70
Migration of Matchcodes and Help Views................................................................................. 71
Creating a Search Help............................................................................................................... 72
SAP AG 9
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 10
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 11
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 12
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 13
ABAP Workbench Delta Guide (3.1-4.6)
:RUNEHQFK7RROV
After reviewing the following topics, you will be able to:
Explain the.new terminology
Use the new ABAP editor
Use the new features of ABAP debugger
Understand the concept of active/inactive sources
Describe the new features of Runtime Analysis
Work with the Object Navigator
SAP AG 14
ABAP Workbench Delta Guide (3.1-4.6)
1HZ7HUPLQRORJ\
In R/3 Release 4.6, several of the terms used to identify components of the ABAP
development environment have been streamlined to reflect our efforts toward object-oriented
R/3 development.
In addition to those changes listed below, new tools will be introduced in the ABAP
Workbench including: the Class Builder(Release 4.5), the BAPI Browser(Release 4.6), and
the Modification Assistant(Release 4.5).
7HUPLQRORJ\&KDQJHV
5HPRWH/HDUQLQJ
Terminology
5HOHDVH; 5HOHDVH 5HOHDVH
$%$3'HYHORSPHQW:RUNEHQFK $%$3:RUNEHQFK $%$3:RUNEHQFK
2EMHFW%URZVHU 5HSRVLWRU\%URZVHU 2EMHFW1DYLJDWRU
$%$3(GLWRU $%$3(GLWRU $%$3(GLWRU
$%$3'LFWLRQDU\ $%$3'LFWLRQDU\ 'LFWLRQDU\
$%$34XHU\ $%$34XHU\ 6$34XHU\
)XQFWLRQ/LEUDU\ )XQFWLRQ%XLOGHU )XQFWLRQ%XLOGHU
SAP AG
([WHQGHG1DPHV
To aid the creation of unique development object names, naming standards have been
altered to extend the name fields for most development objects. The most significant name
changes are listed below. Customer object names must still follow the convention that object
names must begin with a Y or a Z (with the normal exceptions). Function module and dialog
module names were not extended, therefore you should utilize namespace prefixes. The new
namespace concept is explained on the next page.
SAP AG 15
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
5HPRWH/HDUQLQJ
([WHQGHG1DPHV
&RPSRQHQW ([DPSOH
Program names 8 30 sapbc_retrieve_from_table_2
SAP AG
1DPHVSDFHV
Namespaces are identifiers assigned exclusively by SAP, which enable SAP customers, SAP
partners, and SAP to develop R/3 components and products on the basis of R/3 applications
without the risk of name conflicts occurring (when delivering to external R/3 Systems or
importing external products into internal systems). Objects in the ABAP Workbench are
assigned to a namespace by placing the reserved namespace prefix in front of the object
name. The namespace identifier begins and ends with a “/” (as a delimiter), is a maximum of
10 characters and is included as part of the new extended name lengths.
EXAMPLE: for the namespace: (;$03/(
You can create a program with the name: (;$03/(352*5$0
To enable developments in a namespace you must enter the internal namespace identifier
reserved at SAP and the development license key for the desired development system
through the SM30 maintenance of the V_TRNSPACE view.
6HH51RWHVDQG
SAP AG 16
ABAP Workbench Delta Guide (3.1-4.6)
1DPHVSDFHV
5HPRWH/HDUQLQJ
l $UHGHILQHGLQ60DQGDUHDVVRFLDWHGZLWKD
GHYHORSPHQWOLFHQVHNH\
l $UHXVHGWRXQLTXHO\LGHQWLI\GHYHORSPHQWREMHFWV
l 7KHLUQDPHVEHJLQDQGHQGZLWKD³´FKDUDFWHU
l 2QO\DOSKDQXPHULFFKDUDFWHUVDUHDOORZHG
l 1REODQNVDQGQRPRUHWKDQWZR³´VDUHDOORZHG
l 7KHVHFRQGFKDUDFWHULQWKHQDPHFDQQRWEHDQXPEHU
1DPHVSDFHVIURPWKHUDQJHWRDUH
UHVHUYHGE\6$3IRUJHQHUDWHGREMHFWV
l 7KHPD[LPXPOHQJWKRIWKHQDPHVSDFHLV
SAP AG
$FWLYH,QDFWLYH6RXUFHV
&RQFHSW
Concept
6XSSRUWLQWKH$%$3:RUNEHQFK7RROV
Support in the ABAP Workbench Tools
Activating Objects
Status Display
)XUWKHU(IIHFWV
Effect of Inactive Sources on Operations
Further Effects
SAP AG 17
ABAP Workbench Delta Guide (3.1-4.6)
2EMHFW1DYLJDWRU
The Object Navigator is the main point of entry into the ABAP Workbench. It is the successor
of the Repository Browser, and you can access it using transaction code 6(.
Object Navigator
8VHU6SHFLILF6HWWLQJV
User-Specific Settings
1DYLJDWLRQ
The screen of the object navigator is divided in two areas: the Browser (navigation area) and
the tool area.
6FUHHQ6WUXFWXUHLQWKH2EMHFW1DYLJDWRU
&ORVH%URZVHU 'LVSOD\REMHFWOLVW
an REMHFWOLVW as a REMHFW
KLHUDUFK\
5LJKW 5LJKW
6L]HRIGLVSOD\DUHDFDQEHFKDQJHG
SAP AG 1999
Navigation
Navigation Areas
SAP AG 18
ABAP Workbench Delta Guide (3.1-4.6)
1DYLJDWLRQ)XQFWLRQVLQWKH+LHUDUFK\$UHD
$SSOLFDWLRQKLHUDUFK\
'HYHORSPHQWFODVV
'HYHORSPHQWFODVV
3URJUDP
)XQFWLRQJURXS
&ODVV
%&
/RFDO2EMHFWV
3UHYLRXV2EMHFW/LVW
%&
1H[W2EMHFW/LVW
3URJUDPREMHFWW\SHV
'LFWLRQDU\REMHFWV
+LJKHU/HYHO2EMHFW/LVW
3URJUDPV
6$3%&:%'B*(77,1*B67$
)DYRULWHV
6$3%&:%7B*(77,1*B67$
$GG
)XQFWLRQJURXSV
(GLW
%&
3URJUDPV
&ODVVHV
+LVWRU\
&/B%&
5HIUHVK2EMHFW/LVW
SAP AG 1999
SAP AG 19
ABAP Workbench Delta Guide (3.1-4.6)
'LVSOD\LQJ3URJUDP2EMHFWVLQWKH2EMHFW:LQGRZ
6$3%&:%7B*(77,1*B67$57('
3URJUDPREMHFWW\SHV
'LFWLRQDU\VWUXFWXUHV
6%&B&$55,(5 (GLWRU
)LHOGV
3$B&$5 (GLWRU
:$B%&
(YHQWV
67$572)6(/(&7,21 (GLWRU
6FUHHQV
6FUHHQ3DLQWHU
1DYLJDWLRQ'RXEOHFOLFNLQJRQDQH[LVWLQJSURJUDPREMHFWVWDUWV
1DYLJDWLRQ
WKHFRUUHVSRQGLQJ:RUNEHQFKWRROLQWKHREMHFWZLQGRZ
DQGWDNHV\RXWRWKHULJKWSODFHZLWKLQWKHREMHFW
)RUZDUG1DYLJDWLRQ,IDQREMHFWGRHVQRW\HWH[LVW\RXFDQFUHDWHWKH
)RUZDUG1DYLJDWLRQ
REMHFWE\VLPSO\GRXEOHFOLFNLQJRQLW
SAP AG 1999
The System displays the structure of the program and the passage of the source code
simultaneously. Compare this to previous releases where you always had to switch between
detail and overview using the BACK (F3) button.
You can navigate in the Browser and object (or tool) screen areas separately. For
example, if you double-click a function module in the object screen area, the system displays
the source code for that module. However, the object list in the Browser area remains
unchanged. You can choose to display the object list for the current source text. If you
then navigate to another object list in the Browser area, the content of the object area remains
unchanged. In the object list, if you double-click an object that does not have its own object
list, the system displays the appropriate source text. The fact that the two screen areas are
independent allows you to search for variable names or names of subprograms in the object,
and simultaneously edit the program in the Editor.
Navigation Stack
Navigation Context
Worklist
$%$3(GLWRU2YHUYLHZ
SAP AG 20
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
The new ABAP Workbench contains two modes: the textedit control mode and the table
control mode. The 0RGH command no longer exists.
1DYLJDWLQJLQWKH6RXUFH&RGH
&KDQJLQJWKH(GLWRU0RGH
/RFDO(GLWLQJ
Local Editing
6DYLQJDQG$FWLYDWLQJ3URJUDPV
,PSURYLQJWKH/D\RXWXVLQJWKH3UHWW\3ULQWHU
8VLQJ$%$3+HOS
If you choose the information icon in the ABAP Workbench Editor, the system displays a
dialog box where you can choose example programs to accompany the online
documentation. In the next screen, you can execute this example program and display its
source code.
7H[WHGLW&RQWURO0RGH
ABAP Editor (Edit Control Mode)
7DEOH&RQWURO0RGH
Table Control-Mode
%UHDN3RLQWV
7DEOH&RQWURO0RGH
In the ABAP Editor, you can set breakpoints by positioning the cursor on a line of code and
pressing the breakpoint icon (stop sign) on the application toolbar. The VWRSLFRQLQWKH
VHOHFWHGOLQH will then indicate that the line of code has a breakpoint associated with it
SAP AG 21
ABAP Workbench Delta Guide (3.1-4.6)
outside the input line in the right margin. Click on the breakpoint icon to delete the breakpoint.
You can also manipulate breakpoints using the breakpoint table (8WLOLWLHV→%UHDNSRLQW→
6HW'LVSOD\'HOHWH
Editor settings for switching compression on/off; for upper or lower case display; and for
uppercase display of keywords have been added to the 6HWWLQJV menu. Here you can also
determine your editor mode (command mode, PC mode). The source code compression
clarifies the structure of large programs by collapsing syntactical blocks (SELECT loops,
WHILE loops, forms, and so on).
7H[WHGLW&RQWURO0RGH
In the ABAP Editor, you can set breakpoints by positioning the cursor on a line of code and
pressing the breakpoint icon (stop sign) on the application toolbar. The FRORUHGOLQH will then
indicate that the line of code has a breakpoint associated with it outside the input line in the
right margin. Click on the breakpoint icon to delete the breakpoint. You can also manipulate
breakpoints using the breakpoint table (8WLOLWLHV→%UHDNSRLQW→6HW'LVSOD\'HOHWH
$%$3'HEXJJHU
2YHUYLHZ
New functions have been added to the debugger in Release 4.0, and it has been made easier
to use. 6LQJOHVWHS, ([HFXWH, 5HWXUQ, and &RQWLQXH have been converted to pushbuttons with
icons on the application toolbar. A &UHDWHZDWFKSRLQW pushbutton has been added to the
application toolbar as a standard function on the FIELDS screen. Up to eight fields can
display field values and are scrollable from this screen. SY-SUBRC, SY-TABIX, and SY-
DBCNT are always displayed. A 'HOHWH pushbutton is provided and allows you to delete all
field names from the list. You can navigate to a line by entering the starting line number in the
IURPWR scroll field. A pushbutton for displaying the current statement is provided. Fixed point
arithmetic displays have also been improved. Nested internal table fields can now be
displayed in the TABLE screen.
SAP AG 22
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
5HPRWH/HDUQLQJ
SAP R/3
Debugging Goto Breakpoint Settings Development System Help
3Î 3Î 3 3 Î"
Î
Watchpoint
6RXUFHFRGHRI Test
VWDUWRIVHOHFWLRQ
strtab-c = ’b’.
str-c = ’c’. str-i = 3. Append str to strtab-x-tab.
str-c = ’d’. str-i = 4. Append: 4 to str-t3, 5 to str-t3.
Append str to strtab-x-tab.
'RXEOHFOLFN Append strtab to tab2.
Break-point.
Form f.
)LHOGQDPH )LHOGFRQWHQWV
str-c d
Strtab-x-tab Table[2x272]
str-t3 Table[6x4]
str ********************************************
6<68%5& 6<7$%,; 6<'%&17
SAP AG
$%$3'HEXJJHU,PSURYHG+DQGOLQJ
Screen navigation has been simplified by clearly labeling pushbuttons for the FIELDS,
TABLE, BREAKPOINTS, WATCHPOINTS, CALL STACK, OVERVIEW, and SETTINGS
screens.
SAP AG 23
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
5HPRWH/HDUQLQJ
l ,PSURYHGWRROEDUIRUTXLFNVFUHHQFKDQJH
Fields Table Breakpoints Watchpoints Calls Overview Settings
l 1HZLFRQV
n Increase program section size
n Display current statement
n Hex display and change functions
SAP AG
$%$3'HEXJJHU%UHDNSRLQW2YHUYLHZ
SAP AG 24
ABAP Workbench Delta Guide (3.1-4.6)
%UHDNSRLQW2YHUYLHZ
5HPRWH/HDUQLQJ
l 6FUROODEOHGLVSOD\IRUXSWREUHDNSRLQWV
%UHDNSRLQWV
SAP AG
:DWFKSRLQW2YHUYLHZ
Watchpoint processing in the debugger has been significantly improved. You can now define
multiple watchpoints, attach conditions to them, and link two or more watchpoints using a
relational operator.
SAP AG 25
ABAP Workbench Delta Guide (3.1-4.6)
1HZ'HEXJJLQJ6FUHHQ:DWFKSRLQWV
5HPRWH/HDUQLQJ
l 8SWRILYHZDWFKSRLQWVFDQEHGHILQHG
l &RQGLWLRQDOZDWFKSRLQWVFDQEHFUHDWHGZLWKRQHRI
WKHVHFRPSDULVRQRSHUDWRUV !! !
l :DWFKSRLQWVFDQEHFRPELQHGZLWK25RU$1'
l /RFDO
:DWFKSRLQWV
/RJLFDORSHUDWRUEHWZHHQZDWFKSRLQWV
DQG
RU DQG
JOREDO
1R
/ 3URJUDP )LHOGQDPH 2S )LHOG
&RPSDULVRQIOG9DOXH
1 x SAPBC411D_DEBUG
ZDWFK str-c
2 x SAPBC411D_DEBUG str-i = x 1
SRLQWV 3 x SAPBC411D_DEBUG i > sy-index
4 x SAPBC411D_DEBUG sy-tabix = 5
5 x SAPBC411D_DEBUG str-c <
&XUUHQWILHOGYDOXHRIODVWZDWFKSRLQWUHDFKHG
SAPBC411D_DEBUG i 4
SAP AG
5XQWLPH$QDO\VLV
0HDVXUHPHQW5HVWULFWLRQV
The new version of runtime analysis allows you refine the structure the restrictions on runtime
measurements – in particular, you can now use aggregations.
Aggregation
:HUHFRPPHQGWKHIROORZLQJSURFHGXUH
)LUVWVHWWKH$JJUHJDWLRQVHWWLQJWR³)XOO´WRLQYHVWLJDWHWKHVHFWLRQVRIWKHSURJUDP
WKDWDUHPRVWUXQWLPHLQWHQVLYH7KHQOLPLWWKH$JJUHJDWLRQWR³1RQH´DQGUHSHDWWKH
DQDO\VLV
Hierarchy views are only available when $JJUHJDWLRQ is set to “None”. You can create
YDULDQWV for measurement restrictions.
Measurement Restrictions
5HFRUGLQJ7LPHV
Recording Times
SAP AG 26
ABAP Workbench Delta Guide (3.1-4.6)
0HDVXULQJ([WHUQDO3URFHVVHV
Measuring External Processes
)XUWKHU5HDGLQJ
Runtime Analysis
SAP AG 27
ABAP Workbench Delta Guide (3.1-4.6)
(QKDQFHPHQWV
After reviewing the following topics, you will be able to:
Describe the new BADI enhancement concept
Explain how to create a Bussiness Add-In
Describe how to implement a Bussiness Add-In
SAP AG 28
ABAP Workbench Delta Guide (3.1-4.6)
%XVLQHVV$GG,QV
As of release 4.6 a new enhancement technique has been established in R/3: Business Add
Ins (BAdIs). The goal of this enhancement technique is to avoid the insufficient parts of the
older techniques, customer exits and SD user exits. This unit is divided into three sections. In
the first section we want to motivate the necessity of a new technique. The second section will
deal with creating Business Add Ins. Then, in the subsequent section we will learn how to
implement Business Add Ins. Finally, a short summary will conclude this unit.
,QWURGXFWLRQ
This section summarizes the insufficient aspects of the older enhancement techniques to
explain the need for Business Add Ins. One thing that has changed is the software delivery
chain.
6RIWZDUH'HOLYHU\&KDLQV<HVWHUGD\$QG7RGD\
l \HVWHUGD\
&XVWRPHU
6$3 &XVWRPHU
([LWV
l WRGD\
6$3
6$3 LQGXVWU\ 3DUWQHU &XVWRPHU
VROXWLRQ
%XVLQHVV
DGGLQ
1HZ$%$3/DQJXDJH
1HZ$%$3/DQJXDJH
$%$32EMHFWV
SAP AG 1999
Originally, the software delivery chain consisted of two components, the customer and SAP
itself. Today, the situation has completely changed. In most cases SAP does not deliver the
software directly to the customer; instead, there are several participants in the delivery chain.
A typical situation is depicted in the graphic: SAP delivers the Standard R/3 system to a SAP
Industry Solution, which is developing industry-specific components. Together, Standard R/3
and the industry-specific components are delivered to a company that produces a
complementary software product (CSP). Finally, the customer gets the complete software
bundle.
SAP AG 29
ABAP Workbench Delta Guide (3.1-4.6)
'LVDGYDQWDJHVRIWKH2OG(QKDQFHPHQW
7HFKQLTXHV
$GYDQWDJHVRI%XVLQHVV$GG,QV
The main advantage of this concept is the capacity for reuse. Once implemented, a business
add-in can be reimplemented using other links in the software chain. Further advantages are:
• Administrative layer to manage business add-ins
• Implementation using techniques of ABAP Objects
• All enhancement types available (this will be implemented in a future release).
%XVLQHVV$GG,QV$UFKLWHFWXUH
&XVWRPHU
HQKDQFH
PHQW
$GG,QDGDSWHU
&25(
5
$GG,QDGDSWHU
,QGXVWU\ &XVWRPHU
VROXWLRQ HQKDQFH
,QWHUIDFH
,6 PHQW
DQRWKHU
,QWHUIDFH
SAP AG 1999
SAP AG 30
ABAP Workbench Delta Guide (3.1-4.6)
Business add-ins, unlike customer exits, take into account the changes to the software
delivery process. The top part of the graphic illustrates the typical delivery process: It no
longer merely consists of provider and user. Instead, it can now contain a whole chain of
intermediate providers. Below this is a diagram explaining how business add-ins work.
Enhancements are made possible using SAP application programs. This requires at least
one interface and an adapter class that implements it. The interface is implemented by the
user.
The main advantage of this concept is the capacity for reuse. Once implemented, a business
add-in can be reimplemented by other links in the software chain (further to the right in the
graphic). Furthermore, an implementation can also offer its own business add-ins.
&UHDWLQJD%XVLQHVV$GG,Q
Business add-ins use the interface concept of ABAP Objects. There is a new transaction –
SE18 – to create business add-ins. You can find it in the ABAP Workbench following the path
8WLOLWLHV→%XVLQHVV$GG,QV→'HILQLWLRQ. Alternatively, you can start with the Object
Navigator. Here, choose :RUNEHQFK→2WKHU2EMHFW . In the popup window, select the
%XVLQHVV(QJLQHHULQJ tab. Here you find menu items for defining and implementing business
add-ins.
'HILQLQJ%XVLQHVV$GG,QV,QLWLDO6FUHHQ
%XVLQHVV$GG,QV'HILQLWLRQ0DLQWHQDQFH,QLWLDO6FUHHQ
%XVLQHVVDGGLQ
'HILQLWLRQQDPHBB GHILQLWLRQQDPH
'LVSOD\ &KDQJH &UHDWH
&UHDWH
SAP AG 1999
In the initial screen of Transaction SE18, enter the name of the business add-in definition and
choose &UHDWH. On the next screen, enter a short description for the business add-in
definition.
SAP AG 31
ABAP Workbench Delta Guide (3.1-4.6)
This next screen consists of a tabstrip. The first tab is the $WWULEXWHV tab. Here you can define
whether the Business Add-In can be single use or multiple use. Moreover, you can define a
filter dependence for the business add-in. You can also define a function code for your
business add-in. Using this, you can let the user display an additional menu entry in the
corresponding application. However, the most important component of a business add-in is
the ,QWHUIDFH. Using this, you can define the methods that will contain the additional source
code when a business add-in is implemented.
%XVLQHVV$GG,Q'HILQLWLRQ,QWHUIDFH0HWKRGV
$ )
,QWHUIDFHQDPH )B(;BE !
1DPHRIJHQHUDWHG%$G,FODVV /B(;BE !
&ODVV%XLOGHU&KDQJH,QWHUIDFH,)B(;BEDGL!
$ 0 (Y
3DUDPHWHUV ([FHSWLRQV
0HWKRG 7\SH 'HVFULSWLRQ
PHWKRG! %$G,PHWKRG
•6WDWLF
•,QVWDQFH
SAP AG 1999
Choose the ,QWHUIDFHTab to define these methods. Doubleclick the name of the interface. The
system displays the Class Builder where you can define the methods that should be provided
in that business add-in. To find out how to create the methods, see the Class Builder
documentation.
Class Builder
When you activate the interface, the system generates a class ("Adapter Class") which
processes the implementations of the business add-in.
Advantage of the adapter class:
♦ Multiple use of business add-ins
♦ Adapter class analyses which implementation is passed.
Overall, a business add-in consists of the components depicted in the following graphic:
SAP AG 32
ABAP Workbench Delta Guide (3.1-4.6)
%XVLQHVV$GG,QV&RPSRQHQWV
%XVLQHVV &/$66&/B(;BEDGL!'(),1,7,21
DGGLQ 38%/,&6(&7,21
38%/,&6(&7,21
,17(5)$&( ,17(5)$&(6,)B(;BEDGL!
$GG,QDGDSWHU
,)B(;BEDGL!
'$7$D
(1'&/$66
0(7+2'6P
0(7+2'6P
(;3257,1* &/$66FOBH[BEDGL!,03/(0(17$7,21
HBSDU
HBSDU 0(7+2'LIBH[BEDGLaP
,03257,1*
LBSDU (1'0(7+2'
0(7+2'6P 0(7+2'LIBH[BEDGL!aP
(1',17(5)$&( (1'0(7+2'
(1'&/$66
)XQFWLRQFRGH
QDPHVSDFH[[[
SAP AG 1999
A business add-in cannot have a function code as one of its components if you define a
filter dependency.
A business add-in cannot be filter-dependent if you define a function code as one of its
components.
A business add-in can have only one active implementation, if you define it filter specific
or if you define a function code as one of its components.
%XVLQHVV$GG,QV1DPLQJ&RQYHQWLRQV
SAP AG 33
ABAP Workbench Delta Guide (3.1-4.6)
%XVLQHVV$GG,Q'HILQLWLRQ1DPLQJ&RQYHQWLRQV
l %XVLQHVV$GG,Q'HILQLWLRQDQ\QDPHDOORZHG
n EDGL! 6$3QDPHUDQJH
n EDGL! 3DUWQHUQDPHVSDFH
n =EDGL! &XVWRPHUQDPHUDQJH
l ,QWHUIDFHDQ\QDPHDOORZHG
n ,)B(;BEDGL! 6$3QDPHUDQJH
n ,)B(;BEDGL! 3DUWQHUQDPHVSDFH
n =,)B(;BEDGL! &XVWRPHUQDPHUDQJH
l 0HWKRGVDQ\QDPHVDOORZHG
l *HQHUDWHG%XVLQHVV$GGLQ&ODVV$GDSWHU&ODVVQRWWREHFKDQJHG
n &/B,0BEDGL! 6$3QDPHUDQJH
n &/B(;BEDGL! 3DUWQHUQDPHVSDFH
n =&/B(;BEDGL! &XVWRPHUQDPHUDQJH
SAP AG 1999
The naming conventions depicted in the slide apply to business add-ins: Thus, for business
add-in definitions, you only have to take into account the corresponding name space or
customer name range.
The name of the interface is derived from the name of the business add-in using the following
rule:
• The name space prefix first
• IF_EX_ by default
• name of the business add-in without name space prefix
The name of the interface can be changed arbitrarily. You only have to take into account the
name-space rules. The methods are not Repository Objects. So their name is arbitrary, too.
The name of the generated class is fixed, and is composed as follows:
• The name space prefix
• CL_(;_
• The name of the business add-in without name space prefix.
SAP AG 34
ABAP Workbench Delta Guide (3.1-4.6)
%$G,,PSOHPHQWDWLRQ1DPLQJ&RQYHQWLRQV
l %XVLQHVVDGGLQLPSOHPHQWDWLRQDQ\QDPHDOORZHG
n LPSO! 6$3QDPHUDQJH
n LPSO! 3DUWQHUQDPHVSDFH
n =LPSO! &XVWRPHUQDPHUDQJH
l ,QWHUIDFHQDPHGHILQHGLQ%XVLQHVVDGGLQGHILQLWLRQ
l 0HWKRGVQDPHGHILQHGLQ%XVLQHVVDGGLQGHILQLWLRQ
l ,PSOHPHQWLQJFODVVDQ\QDPHDOORZHG
n &/B,0BLPSO! 6$3QDPHUDQJH
n &/B,0BLPSO! 3DUWQHUQDPHVSDFH
n =&/B,0BLPSO! &XVWRPHUQDPHUDQJH
SAP AG 1999
The name of the business add-in implementation can be chosen freely within the
corresponding name-space or name range, respectively. The same holds for the name of the
class that is created when you implement a business add in. the system makes the following
proposal for the class:
• The name space prefix
• CL_,0_
• The name of the implementation without name space prefix.
&UHDWLQJD)LOWHU'HSHQGHQW%XVLQHVV$GG,Q
You can create a filter dependent BAdI by marking the corresponding flag in the $WWULEXWHTab.
SAP AG 35
ABAP Workbench Delta Guide (3.1-4.6)
&UHDWLQJD)LOWHU'HSHQGHQW%$G,
$ E )
$ E
5 E
) S )LOWHUW\SH ' !
SAP AG 1999
The filter type has to be a data element defined in the ABAP Dictionary. Because a data
element refers to a domain which itself refers to a value table or fixed single values, the
values for the filter are predefined.
The methods defined in the BAdI-Interface have an additional fixed parameter: FLT_VAL,
which has the type of the data element. We will see in the implementation part how this filter
value is used to select a specific implementation.
6DPSOH&DOOLQJD%XVLQHVV$GG,Q
This section describes an ABAP Program that provides an enhancement as a business add-in
– by discussing the program flow, before providing the code itself.
SAP AG 36
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDPIRU3URYLGLQJ$%XVLQHVV$GG,Q)ORZ
$SSOLFDWLRQSURJUDP
6HUYLFH&ODVV
&/B(;,7+$1'/(5
3URFHVVLQJRIDFWLYH
,PSOHPHQWDWLRQV
$GDSWHU&ODVV
%XVLQHVV$GG,Q
&/B(;BEDGL!
,PSOHPHQWDWLRQ&ODVV
,PSOHPHQWDWLRQ&ODVV
&UHDWH
2EMHFWUHIHUHQFH
SAP AG 1999
The graphics shows the flow of an application program that provides a business add-in
enhancement. First, declare a reference variable that is a reference to the business add-in
interface. The following example shall provide you with the necessary code for calling a
business add-in method. Assume that we have created a business add-in with the name
<%$',7(67already. We let the name of the interface be <,)B(;B%$',7(67. Furthermore,
we have declared a method %$',B0(7+2' within the interface.
PROGRAM badi_provider.
'$7$UHIHUHQFBYDULDEOH7<3(5()72,)B(;B%$',7(67
Now, we have declared the reference variable. In a second step, we have to instantiate an
object of the Adapter class. This is done by calling the method *(7B,167$1&(of the
existing class &/B(;,7+$1'/(5. We advise calling this method as seldom as possible. So
it is a good choice to call it at the ABAP event LOAD-OF-PROGRAM. The code should look as
follows:
LOAD-OF-PROGRAM.
&$//0(7+2'FOBH[LWKDQGOHU !JHWBLQVWDQFH
&+$1*,1*
LQVWDQFH UHIHUHQFHBYDULDEOH
That is all the preparation we need. In the next step we can call the methods of the
enhancement. The provider determines where the enhancement is called:
&$//0(7+2'UHIHUHQFHBYDULDEOH!EDGLBPHWKRG
LQWHUIDFHRIWKHEDGLPHWKRG!
With this statement the method is called in the generated adapter class, as depicted in the
graphic above. The enhancements are called from within that method of the adapter class.
Thus, the adapter class looks for active implementations and executes them.
SAP AG 37
ABAP Workbench Delta Guide (3.1-4.6)
,PSOHPHQWLQJD%XVLQHVV$GG,Q
%XVLQHVV$GG,QV,PSOHPHQWDWLRQ0DLQW,QLWLDO6FUHHQ
1DPHRI
,PSHPHQWDWLRQQDPH LPSOPQW!
LPSOHPHQWDWLRQ
'LVSOD\ &KDQJH &UHDWH
&UHDWH
%XVLQHVV$GG,QV&KRRVH'HI
'HILQLWLRQQDPH EDGL!
SAP AG 1999
Enter a name for the implementation. It has to comply with name space conventions. For
example, to create an implementation in the customer name range, named =,03/(0(17
you would enter this name in the corresponding entry field and press the &UHDWHbutton. The
system asks you for the business add-in you want to implement. Enter the name of the
business add-in in the dialog box. The next screen displays some tabs. Here you can specify
more details for the implementation of the interface method.
SAP AG 38
ABAP Workbench Delta Guide (3.1-4.6)
,PSOHPHQWLQJ%XVLQHVV$GG,QV0HWKRGV
,QWHUIDFHQDPH ,)BLQWHUIDFH!
1DPHRILPSOHPHQWLQJFODVV &/B,0BLPSOPQW!
0HWKRG 'HVFULSWLRQ
PHWKRG! %XVLQHVVDGGLQPHWKRG
&ODVV%XLOGHU(GLW0HWKRG,)LQWHUIDFH!aP!
0(7+2'LIBLQWHUIDFH!aPHWKRG!
(1'0(7+2'
SAP AG 1999
When you double click the name of the interface method, the system navigates to the editor
where you can enter your source code. Technically, the system creates a new class, the
LPSOHPHQWLQJFODVV =&/B,0B,03/(0(17, which implements the interface that has been
defined in the business add-in definition. If you wish, you can change the name of the class.
Within this method you are free to do anything you can do within a class. For instance, you
could call other private methods within the class.
You can deactivate an active implementation. It will then be no longer carried out.
,PSOHPHQWLQJD)LOWHU'HSHQGHQW%XVLQHVV$GG
,Q
To implement a filter-dependent business add-in, you must specify the filter value for the
business add-in. Therefore, you must insert specific values for the filter in the $WWULEXWHVfield.
In the following graphic, the implementation is only performed when the implementation is
called with filter value "AA" or "LH".
SAP AG 39
ABAP Workbench Delta Guide (3.1-4.6)
)LOWHU'HSHQGHQW,PSOHPHQWDWLRQ
$WWULEXWHV ,QWHUIDFH
5HXVDEOH
SAP AG 1999
SAP AG 40
ABAP Workbench Delta Guide (3.1-4.6)
0RGLILFDWLRQ$VVLVWDQW
After reviewing the following topics, you will be able to:
Explain the concept of Modification Assistant
Use the Modification Browser
Understand the upgrade procedure
Explain how to do adjustments with Modification Assistant
Explain how to do adjustments without Modification Assistant
SAP AG 41
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZDQG,QWURGXFWLRQ
In this unit you will learn more about the Modification Assistant, which is new in Release 4.5.
You will see how it guides you through SAP object modification. The Modification Assistant is
very useful at upgrade. Before starting, you may want to have a look at the FKDQJHOHYHOV
that can be used in the R/3 System.
Modifying SAP objects in your customer’s system should only be undertaken as a final course
of action when trying to make changes to the SAP standard. There are several other
techniques available for adjusting the R/3 System to meet your personal requirements.
However, in many cases problems occur that cannot be solved using existing techniques. In
the past, there was no way of adding functionality or repairing known bugs unless you
modified the objects directly.
The following is an overview of the existing techniques for changing the SAP standard. We
will then have a look at the new "Modification Assistant" tool and discuss the effects that the
Modification Assistant has on the behavior of the system at upgrade.
&KDQJH/HYHOV
When making changes to the SAP standard, you must first determine which type of change
best suits your needs. The following graphic gives you an overview of the possibilities
available for adapting the system’s functionality to your needs:
There are several different techniques at your disposal. Before developing your programs,
make sure that you have checked of the all existing possibilities for adjusting the system to
your needs:
&KDQJH/HYHOVLQWKH56\VWHP
5HPRWH/HDUQLQJ
5%XVLQHVV
5%XVLQHVV
$SSOLFDWLRQV &XVWRPHU
6$36WDQGDUG 3URJUDPV
&XVWRPHU
&XVWRPL]LQJ 3HUVRQDOL]DWLRQ 0RGLILFDWLRQV (QKDQFHPHQWV
'HYHORSPHQW
%XVLQHVV $%$3
(QJLQHHU :RUNEHQFK
SAP AG
SAP AG 42
ABAP Workbench Delta Guide (3.1-4.6)
You can change the R/3 System standard in the following ways:
• Customizing
• Personalization, which includes
• Global field settings
• Company-specific settings
• User-specific settings
• For more information regarding these possibilities see the
Online documentation
• Enhancements to the standard
• Modifications
(QKDQFHPHQWVWRWKH6WDQGDUG
You can make enhancements to the standard using the SAP enhancement concept. There
are two techniques available to enhance your R/3 System:
• Customer Exits
• Business Transaction Events
The latter one is new in Release 4.0. Customer exits and Business Transaction Events
represent potential customer requirements that have not been developed in the standard.
Instead, the standard provides for further development of such exits at the customer site,
using logic specific to the customer. Enhancements can relate to programs, menus, and
screens.
For more information about the enhancement concept consult the
Online documentation
7KH0RGLILFDWLRQ$VVLVWDQW
The R/3 System is modified to meet the needs of individual working environments at several
different levels:
• Customizing
• Customer exits
• Customer developments and
• Modifications to the standard
Customizing, customer exits, and customer developments are all supported by corresponding
tools such as the IMG, transaction CMOD, or the development environment.
The Modification Assistant now offers you support in the fourth area listed above, modification
to the standard. The main goal of the Modification Assistant is to simplify the upgrade
process. For this, you branch to a special modification mode whenever you are modifying
objects from the standard in an ABAP Workbench tool. Originals are initially protected in this
mode and can only be changed with the help of additional pushbuttons that are put at your
disposal.
SAP AG 43
ABAP Workbench Delta Guide (3.1-4.6)
All changes that you make to the system are logged with the help of the Modification
Assistant. This provides you with a detailed overview of modifications that is easy to read and
that drastically reduces the amount of effort needed to upgrade your system.
The Modification Assistant supports your modifications in the following areas:
• ABAP Editor
• Screen Painter
• Menu Painter
• Text Elements
• Function Builder
• ABAP Dictionary
• Table and structure enhancements using append structures
• Data element attributes
• Documentation
If an object can be edited using the Modification Assistant, a dialog box appears the first time
that you attempt to edit that object informing you that editing functions are limited in
modification mode. This dialog box appears exactly once per user for each of the various
different kinds of transport objects.
:DUQLQJ'LDORJ%R[IRU0RGLILFDWLRQKHUH$%$3(GLWRU
You should not modify any object unless it is absolutely necessary for the optimization of
specific business processes. Before modifying the standard, it is essential that you have
exhausted all of the possibilities in the enhancement concept. You should keep in mind that
you are responsible for your modifications being correct!
0RGLI\LQJ2EMHFWVDIWHU0RGLILFDWLRQ$VVLVWDQW
,QVWDOODWLRQ
SAP AG 44
ABAP Workbench Delta Guide (3.1-4.6)
You may have modified an object prior to installing the Modification Assistant. In this case, the
following dialog box appears.
2EMHFW$OUHDG\0RGLILHGZLWKRXW0RGLILFDWLRQ$VVLVWDQW
5HPRWH/HDUQLQJ
:DUQLQJ&KDQJLQJDUHSDLUHGREMHFW
3URJUDP'$:B7(67ZDVUHSDLUHGEHIRUHWKH0RGLILFDWLRQ$VVLVWDQWZDV
HQDEOHG$OO0RGLILFDWLRQ$VVLVWDQWIXQFWLRQVRQO\DSSO\WRIXWXUH
PRGLILFDWLRQVQRWWRWKRVHDOUHDG\XQGHUWDNHQ7KLVPHDQV
R7KHPRGLILFDWLRQRYHUYLHZRQO\GLVSOD\VIXWXUHPRGLILFDWLRQV
R:KHQUHVHWWLQJWRWKHVWDQGDUGWKHV\VWHPZLOOUHVHWDOOREMHFWVWR
WKHLUFXUUHQWYHUVLRQVLQFHWKHDFWXDOVWDQGDUGFDQQRORQJHUEH
LGHQWLILHGE\WKH0RGLILFDWLRQ$VVLVWDQW7KLVGRHVQRWDSSO\LI
UHVHWWLQJWDNHVSODFHGXULQJDQXSJUDGH
R6XSSRUWIRUDGMXVWPHQWDIWHUDQXSJUDGHZLOORQO\EHDYDLODEOHIRU
IXWXUHPRGLILFDWLRQV0RGLILFDWLRQVWKDWDOUHDG\H[LVWPXVWEHUHPDGH
PDQXDOO\XVLQJYHUVLRQPDQDJHPHQW
SAP AG
This means the Modification Assistant will only support subsequent modifications. Previous
modifications are not supported. They have to be adjusted in the customary manner.
0RGLILFDWLRQRI3URJUDP&RGH7KH$%$3(GLWRU
You can make modifications to programs in the ABAP Editor using the Modification
Assistant’s ,QVHUW5HSODFH and 'HOHWH functions.
SAP AG 45
ABAP Workbench Delta Guide (3.1-4.6)
3XVKEXWWRQV$YDLODEOHLQ0RGLILFDWLRQ0RGH
5HPRWH/HDUQLQJ
,QVHUW ,QVHUW0RGLILFDWLRQ
5HSODFH 5HSODFH2ULJLQDO
'HOHWH 'HOHWH2ULJLQDO
0RGLILFDWLRQ2YHUYLHZ
8QGR0RGLILFDWLRQ
SAP AG
There are two change modes in the ABAP Editor: One you know from the past and a new
modification mode.
$%$3(GLWRU,QVHUWLQJ1HZ&RGH
5HPRWH/HDUQLQJ
$%$3(GLWRU0RGLI\3URJUDP6$3'(/7$B02'$66
3URJUDP(GLW*RWR8WLOLWLHV%ORFNEXIIHU6HWWLQJV6\VWHP+HOS
(1'2)6(/(&7,21
6(73)67$786
/,6767$7
3(5)250RXWSXW
&$6(
;
:+(1FKHFN
3(5)250UDGLRB
:+(1FKHFN
3(5)250UDGLRB
:+(1FKHFN
3(5)250UDGLRB
^,16(57,5.
:+(1P\BFKHFN
3(5)250P\BVXEURXWLQH
`,16(57
(1'&$6(
/LQH RI
SAP AG
SAP AG 46
ABAP Workbench Delta Guide (3.1-4.6)
Here you see the modification mode. You can choose from three different actions:
,QVHUW
The system automatically inserts comment lines before and after the lines you input. You can
only insert new code in those lines that are ready for input.
5HSODFH
You can replace one or more lines in the ABAP Editor. To replace more than one line, mark
the entire block. Then choose 5HSODFH from the application toolbar. Again the system inserts
two comment lines and adds a comment to the original code.
$%$3(GLWRU5HSODFLQJD%ORFNRI&RGH
5HPRWH/HDUQLQJ
$%$3(GLWRU0RGLI\3URJUDP6$3'(/7$B02'$66
3URJUDP(GLW*RWR8WLOLWLHV%ORFNEXIIHU6HWWLQJV6\VWHP+HOS
67$572)6(/(&7,21
VHOHFW63)/,GDWDVHWV
^5(3/$&(,5.
?6(/(&7&$55,'&211,'&,7<)520&,7<72'(37,0($557,0(
?,172&255(6321',1*),(/'62)7$%/(,7B63)/,
?)52063)/,
?:+(5(&$55,',162B&$55
6(/(&7FDUULGFRQQLGFLW\IURPFLW\WRGHSWLPHDUUWLPH
,172&255(6321',1*),(/'62)7$%/(LWBVSIOL
)520VSIOL
:+(5(FDUULG,1VRBFDUUDQG
FRQQLG,1VRBFRQQLG
`5(3/$&(
(YHQW(1'2)6(/(&7,21
(1'2)6(/(&7,21
6(73)67$786
/,6767$7
$FWLYH&KDQJHG /LQH RI
OLQHVFRPPHQWHGRXW
SAP AG
The replaced code is still visible, but commented out. The original code is copied and can be
overwritten or deleted. You can create new lines by pressing the ENTER key.
'HOHWH
Choose 'HOHWH from the application toolbar to delete lines of code. To delete more than one
line you have to mark the respective block first. The deleted code will be marked as a
comment.
0RGLILFDWLRQ2YHUYLHZ
SAP AG 47
ABAP Workbench Delta Guide (3.1-4.6)
0RGLILFDWLRQ2YHUYLHZ$Q([DPSOH
5HPRWH/HDUQLQJ
0RGLILFDWLRQVIRU3URJUDP6$3'(/7$B02'$66
6$3'(/7$B02'$66
5 (YHQWV
(1'2)6(/(&7,217(6786(5
67$572)6(/(&7,217(6786(5
SAP AG
The system records your modifications in a corresponding include. The granularity of this
recording corresponds to the processing blocks of your ABAP Program. All modifications from
the corresponding include are displayed on an overview screen.
For more information about the Modification Browser see also
Modification Browser
8QGRLQJ0RGLILFDWLRQV
In order to undo a modification you have made, place your cursor on a line in that modification
and choose 8QGRPRGLILFDWLRQ
Whenever you add a new modularization unit to an SAP program, you should assign the
unit to a customer include. You should also move all sections of code that are inserted in the
program to the subroutines of a customer include. This reduces upgrade time and is helpful
when trying to fix any conflicts that may arise.
0RGLILFDWLRQVLQWKH6FUHHQ3DLQWHU
You can make modifications to the following elements in the Screen Painter:
• Screen Attributes
• Flow Control
• Element List
6FUHHQ$WWULEXWHV
SAP AG 48
ABAP Workbench Delta Guide (3.1-4.6)
Screen attributes can be modified in any way that you like, including, for example, changing
the screen size maintenance value.
)ORZ/RJLF
In a screen’s flow logic, you can modify existing events or add new ones.
:DUQLQJ'LDORJ%R[<RX5HFHLYHZKHQ0RGLI\LQJD6FUHHQ
5HPRWH/HDUQLQJ
0RGLILFDWLRQ$VVLVWDQW
7UDQVSRUWREMHFWVFUHHQFDQEHHGLWHGXVLQJWKH0RGLILFDWLRQ
$VVLVWDQW
7KLVPHDQVWKDW5HSRVLWRU\REMHFWVWKDWDUHUHSDLUHGPXVWEHHGLWHGLQ
PRGLILFDWLRQPRGH2QO\DUHVWULFWHGQXPEHURIHGLWRUIXQFWLRQVDUH
DYDLODEOHLQWKLVPRGH6RXUFHSDUDJUDSKVWKLVFDQLQFOXGHVFUHHQ
ILHOGVDQGLQWHUIDFHPHQXVDUHSURWHFWHG
8VHWKHPRGLILFDWLRQLFRQWRFKDQJHWKHVHSDUDJUDSKV)RUIXUWKHU
LQIRUPDWLRQSOHDVHFRQVXOWWKHDSSURSULDWHGRFXPHQWDWLRQ
SAP AG
When you try to modify a screen you get a dialog box informing you that the transport object
screen can be edited using the Modification Assistant. You should use the modification icons
in the same way as in the ABAP Editor to make your modifications to the screen's flow logic.
SAP AG 49
ABAP Workbench Delta Guide (3.1-4.6)
6FUHHQ3DLQWHU0RGLI\LQJ)ORZ/RJLFRID6FUHHQ
5HPRWH/HDUQLQJ
6FUHHQ3DLQWHU
6FUHHQ3DLQWHU0RGLI\IORZORJLF6$
0RGLI\IORZORJLF6$3'$:B02'$
3'$:B02'$ 66
6FUHHQ(GLW*RWR8WLOLWLHV%ORFNEXIIHU6HWWLQJV6\VWHP+HOS
352&(66%()25(287387
02'8/(VWDWXVB
352&(66$)7(5,1387
^,16(57,5.
02'8/(P\BPRGXOH
`,16(57
02'8/(QDYLJDWLRQ
02'8/(86(5B&200$1'B
/LQH RI
SAP AG
Here the same icons are available as in the ABAP Editor. When you choose one of the
modification icons, a new line is created framed by a comment line indicating an insertion.
The comment line includes of the kind of modification (,QVHUW, 5HSODFH or 'HOHWH) and of the
name of the change request which the modification is assigned to. Finally, the number at the
right of the comment line serves for internal administration purposes. Additionally, when you
choose 5HSODFH or 'HOHWH the respective lines of code will be commented out.
6FUHHQ/D\RXW
In the Layout Editor, all sorts of screen element types can be added. You can change screen
element attributes and make modifications to screen layout.
There are, however, some restrictions. You are not allowed to:
• Delete an H[LVWLQJscreen element
• Modify the name of a screen element
• Change an element’s type (for example, from a checkbox to a radio button).
• Change an element’s graphical element (container) assignment (for example, from a step
loop to a table control).
The restrictions above do not apply for elements you have created yourself.
If you decide that your modifications cannot be made using the Modification Assistant,
you may switch the Modification Assistant off. Be aware that in this case, you no longer have
any modification support!
If you want to undo modifications you have made in the Screen Painter, no pushbutton is
available for this function at the time being. This is due to the fact that if screen elements have
been moved and new ones put in their place, two elements might collide if you try to undo
specific modifications. In the Layout Editor, modifications can only be manually reset. For
example, you can move a screen element back to its original position. Afterwards, it is no
longer classified as a modified element and the system once again treats it as an original
element.
SAP AG 50
ABAP Workbench Delta Guide (3.1-4.6)
There are, however, two different ways in which screen modifications can be undone. One
involves the Modification Browser - where you can reset the attributes of entire screens:
Online documentation
0RGLILFDWLRQVLQWKH*UDSKLFDO6FUHHQ3DLQWHU
When making changes to existing screens, no special functions are necessary when using
the graphical Screen Painter in the Modification Assistant. All changes are made using normal
Screen Painter functions.
Newly added objects are shaded in dark gray. Existing objects which have been changed or
moved are marked in light gray.
(OHPHQW/LVW
The functions for making changes to a screen available in the Screen Painter are also
available from the element list. If a element has been modified, it is marked with the
modification icon.
For more information about modifications in the Screen Painter consult the
Online documentation
0RGLILFDWLRQVLQWKH0HQX3DLQWHU
Menu enhancements can be made in the Modification Assistant, too. Menu entries,
pushbuttons, icons, and so on, can be both added and deleted. All changes made to the
standard are highlighted.
The following is an example of how to make modifications in the Menu Painter using the
Modification Assistant.
SAP AG 51
ABAP Workbench Delta Guide (3.1-4.6)
([DPSOHIRU0RGLILFDWLRQVLQWKH0HQX3DLQWHUXVLQJWKH0RGLILFDWLRQ$VVLVWDQW
5HPRWH/HDUQLQJ
0RGLI\6WDWXV/,6767$ 7LQ3URJUDP6$3'(/7$B02'$ 66
8VHULQWHUIDFH(GLW*RWR8WLOLWLHV)XQFWLRQDFWLYDWLRQ([WUDV6\VWHP+HOS
$ FWLYH!,QDFWLYH
0HQXEDU 0HQXIRU%DVLF/LVW
&RGH 7H[W
&+1* &KDQJH
'(/( 'HOHWH
35, 3ULQW
3& 6DYHWR3&ILOH
(; ([LW
SAP AG
Here we will add a new function (’New’) to the program’s menu bar. In addition, an existing
menu bar entry will be changed.
Consult 8WLOLWLHV → +HOSWH[WV→&RORUOHJHQGfor a more comprehensive explanation of how
colors are used in modification mode. Whenever you want to add a menu to a menu bar, the
new entry is highlighted in violet. However, if the new entry is an original menu, then it will not
be highlighted at all.
If you want to change a sub-object, for example a menu entry, select the corresponding
pushbutton &KDQJHVXEREMHFW. A dialog box appears:
SAP AG 52
ABAP Workbench Delta Guide (3.1-4.6)
&KDQJLQJ6XE2EMHFWV
5HPRWH/HDUQLQJ
)XQFWLRQDWWULEXWHV
)XQFWLRQFRGH &+1*
)XQFWLRQDOW\SH $SSOLFDWLRQIXQFWLRQ
0RGLILFDWLRQ 2ULJLQDO Change sub-object
6WDWLFIXQFWLRQWH[WV
)XQFWLRQWH[W &KDQJH
,FRQQDPH ,&21B&+$1*(
,FRQWH[W
,QIRWH[W &KDQJH'DWDVHW
)DVWSDWK $
0RGLILFDWLRQ 2ULJLQDO Change sub-object
&KDQJHWH[WW\SH
SAP AG
All changeable fields are ready for input after the corresponding pushbutton has been chosen
(&KDQJHVXEREMHFW).
By choosing the &KDQJHVXEREMHFW pushbutton in the frame, you can change the function
text, icon name, and icon text of your object.
Use &XW to remove entries from sub-objects. Whenever you remove an original entry from a
menu, it is highlighted in violet.
In addition to the &KDQJHVXEREMHFW function, several other functions are available to you in
modification mode in the Menu Painter.
SAP AG 53
ABAP Workbench Delta Guide (3.1-4.6)
0RGLILFDWLRQ2YHUYLHZ
5HPRWH/HDUQLQJ
0RGLILFDWLRQV,QWHUIDFH6$ 3'(/7$B02'$66
6$3'(/7$B02'$66
5 &XVWRPHUVXEREMHFWV
5 0HQXV
1HZ
5 )XQFWLRQV
'(/( 'HOHWH
&2'( 1XPEHU
&2'( 1XPEHU
5 0RGLILHGVXEREMHFWV
5 0HQXEDUV
5 0HQXIRU%DVLF/LVW
SAP AG
The modification overview provides you with a complete overview of your modifications to the
menu.
'LVSOD\2ULJLQDO
The 'LVSOD\RULJLQDO function allows you to display the original of the object that your cursor is
currently positioned on.
5HVHWWR2ULJLQDO
5HVHWWRRULJLQDO allows you to reset all objects that have been modified by a customer back to
their original form.
0RGLI\LQJ7H[W(OHPHQWV
SAP AG 54
ABAP Workbench Delta Guide (3.1-4.6)
&KDQJLQJ7H[W(OHPHQWVIRUD3URJUDP
5HPRWH/HDUQLQJ
SAP AG
You want to change the text elements for a program. To do so, simply position your cursor on
the line you want to modify and choose &KDQJHRULJLQDOWH[W The addition of new text
elements is also supported in the Modification Assistant.
In the same way you can also modify selection texts and list headers. When changing list
headers, be aware that you can modify the text line for line.
In addition to the &KDQJHRULJLQDOWH[W function, the functions 'LVSOD\RULJLQDO, 5HVHWWR
RULJLQDO, and 0RGLILFDWLRQRYHUYLHZ are available to you here.
0RGLI\LQJDQG$GGLQJ)XQFWLRQ0RGXOHV
From Release 4.5 on you can add new function modules to a function group and change
existing ones in the Modification Assistant. You can
• Add modules from the customer namespace to function groups in the standard
• Modify the process type of a function module
• Enhance the interface of function modules
Be aware that you must guarantee the compatibility of the interface.
- You can add new parameters. If you do not enter a 'HIDXOW for newly added parameters,
they automatically receive the attribute 2SWLRQDO
You can always change the reference fields and defaults of those parameters that
already exist.
• Modify the logic of a function module
Again, you can use the modification overview to display the modifications you have made
to a specific function module.
SAP AG 55
ABAP Workbench Delta Guide (3.1-4.6)
Online documentation
0RGLILFDWLRQVLQWKH$%$3'LFWLRQDU\
In the ABAP Dictionary there are basically two groups of objects you can modify using the
Modification Assistant
7DEOHVDQGVWUXFWXUHV
Simply use the append technique to add fields to transparent tables and structures. You can
get more information about using append structures in
SAP AG 56
ABAP Workbench Delta Guide (3.1-4.6)
All changes that you make are highlighted in color. The short text in the example above is
highlighted since it has already been changed.
Use the modification overview to display all modifications you have made to the current data
element.
Online documentation
0RGLI\LQJ'RFXPHQWDWLRQ
You can find a list of document classes that may modified using the Modification Assistant in
the online documentation:
Modifying Documentation
For example, if you want to modify the documentation for a data element, choose *RWRÅ
'RFXPHQWDWLRQÅ&KDQJH. The following dialog box is displayed:
Choose an appropriate name in the customer namespace for the new documentation object.
When you choose 2ULJLQDOWH[W the original documentation will be incorporated into your
documentation. You can modify or enhance existing documentation in this way. If you simply
want to use one of the headers stored for this document class in the standard, you can
choose the option7HPSODWHZLWKKHDGHUV.
After activating the data element, your modified documentation is displayed instead of the
original one.
You can reset modifications to their original form by deleting the document from the customer
namespace.
'LVDEOLQJWKH0RGLILFDWLRQ$VVLVWDQW
This should only be done if you need to make modifications that are not possible using
Modification Assistant!
SAP AG 57
ABAP Workbench Delta Guide (3.1-4.6)
By switching off Modification Assistant you have no longer support from Modification
Assistant! This may lead to substantial trouble at upgrade!
You can never switch the Modification Assistant on again once you have disabled it!
5HVHWWLQJWRWKH2ULJLQDO
If you want to undo the modifications you have made to certain Repository objects, you can
do this on the initial screen of the corresponding ABAP Workbench tool using the (GLW →
0RGLILFDWLRQV → 5HVHWWRRULJLQDO function. You may also undo modifications in the
Modification Browser (SE95) by selecting the Repository object and choosing 5HVHWWR
RULJLQDO. This will reset the entire Repository object to its version in the standard.
After you have reset a modification, there is no way in which this modification can be
retrieved.
In order to maintain consistency, modifications can only be reset for entire Repository objects.
To undo individual modifications (for example on a particular status), you have to navigate to
the modification directly using the appropriate tool. If you navigate to where the modification
was made, you can reset selected sub-objects (for example a menu bar) to their original
appearance and functionality.
7KH0RGLILFDWLRQ%URZVHU
The Modification Browser provides you with an overview of all modifications that have been
made to your system. You have access to the Modification Browser from the ABAP
Workbench choosing the function 2YHUYLHZ→ 0RGLILFDWLRQ%URZVHU6(. A selection
screen allows you to limit what the Modification Browser displays by choosing specific
development classes, objects modified with or without Modification Assistant, and objects to
be adjusted.
An overview of those changes to your system made ZLWK0RGLILFDWLRQ$VVLVWDQW resembles the
following illustration:
SAP AG 58
ABAP Workbench Delta Guide (3.1-4.6)
0RGLILFDWLRQ%URZVHU([DPSOH
5HPRWH/HDUQLQJ
0RGLILFDWLRQ%URZVHU
0RGLILFDWLRQV(GLW*RWR8WLOLWLHV(QYLURQPHQW6\VWHP+HOS
0RGLILFDWLRQV
5 :LWK0RGLILFDWLRQ$VVLVWDQW
5 3URJUDPV
5 6$3'(/7$B02'$66 3URJUDPIRU0RGLILFDWLRQV
5 6RXUFHV
4 (YHQWV
5 6FUHHQV
5 &XVWRPHUVXEREMHFWV
5 6FUHHQHOHPHQWV
SAP AG
Online Documentation
8SJUDGH3URFHGXUH
In the past, all objects which had been modified by a customer had to be modified manually
during upgrade using transactions SPDD and SPAU. These two transactions have been
altered dramatically. Modifications can either be automatically adopted at upgrade or the
system offers the user help adjusting his modifications to the newly upgraded configuration.
In general, objects that have been altered using the Modification Assistant can be
automatically accepted into the upgraded system if the modifications in the original version do
not directly overlap those made in the customer version. If collisions occur between these
SAP AG 59
ABAP Workbench Delta Guide (3.1-4.6)
versions at upgrade (such as naming collisions, or if a customer had modified an object that
has been deleted by SAP), support is offered to the user in the form of a semi-automatic
adjustment. In some cases manual adjustment using the tools of the ABAP Workbench may
even be necessary.
Objects modified according to the old system used prior to the advent of the Modification
Assistant must be manually maintained after an upgrade has been run. This also holds true
for modifications that have been made with the Modification Assistant switched off.
$GMXVWLQJ$%$3'LFWLRQDU\2EMHFWV
Transaction SPDD allows you to adjust modifications to ABAP Dictionary objects during an
upgrade. It is used for adjusting:
• Domains
• Data Elements
• Tables (structures, transparent tables, pooled and cluster tables including their technical
settings)
Changes to other ABAP Dictionary objects such as lock objects, matchcodes, and views
cannot result in the loss of data. They are not handled by transaction SPDD, but by
transaction SPAU when the upgrade has taken place.
For more information about Modification adjustments using transaction SPDD see
$GMXVWLQJ55HSRVLWRU\2EMHFWV5HOHDVH
Adjustments to R/3 Repository Objects are undertaken in transaction SPAU. Before running
transaction SPAU, you have to prepare your system. This is not new in Release 4.5 and is
described in:
Online Documentation
The most important features of the new transaction SPAU are:
'LVSOD\)XQFWLRQV
Transaction SPAU allows you to carry out adjustments to Repository objects. The initial
screen of this transaction displays a list of all objects that have been altered by either you or
by SAP in a tree structure
SAP AG 60
ABAP Workbench Delta Guide (3.1-4.6)
'LVSOD\)XQFWLRQVLQ7UDQVDFWLRQ63$8
5HPRWH/HDUQLQJ
0RGLILFDWLRQDGMXVWPHQW
0RGLILFDWLRQV(GLW*RWR8WLOLWLHV(QYLURQPHQW6\VWHP+HOS
5 :LWK0RGLILFDWLRQ$VVLVWDQW
4 'DWDHOHPHQWV
5 3URJUDPV
5 6$3'(/7$B02'$66
5 6FUHHQV
5 6$3'(/7$B02'$66 3URJUDP'$:B7(67
5 6RXUFHV
4 )XQFWLRQJURXSV
5 ,QFOXGHVXVHGUHSHDWHGO\
SAP AG
5HVHWWR2ULJLQDO
If you no longer want to maintain modifications that you have made to an object, then call WKH
5HVHWWRRULJLQDO function for that object. This function is particularly useful if you have
manually imported preliminary corrections from SAP. After preliminary corrections have been
delivered by SAP with the next upgrade, your initial preliminary correction phase should be
concluded.
To do so, use the 5HVHWWRRULJLQDO function to close the changes made to your objects during
preliminary correction and subsequently revert them to the SAP standard. Objects that have
been marked as closed are not displayed in transaction SPAU after future upgrades
After an object has been reset to the original, it is treated as an unmodified object during the
next upgrade and can be overwritten without its previous form being saved.
'LVSOD\LQJ/RJV
Use the 'LVSOD\ORJ function to display a log of upgrade problems and the actions necessary
to correct them. Pay special attention to the 2SHQXQUHVROYHGSUREOHPV category. If not all
objects in theZLWK0RGLILFDWLRQV$VVLVWDQW category can be successfully adjusted, then a
dialog box is displayed informing you that unresolved problems still exist.
0DUNLQJIRU7UDQVSRUW
This feature is already available in release 4.0. For further information refer to the
Online Documentation
$GMXVWPHQWVZLWK0RGLILFDWLRQ$VVLVWDQW
SAP AG 61
ABAP Workbench Delta Guide (3.1-4.6)
$GMXVWLQJ3URJUDPV
Whenever you alter a program using the Modification Assistant, most changes can be
adopted automatically because source comparison now takes place at the modularization unit
level (that is routine, module, or event level) and not at the transport object level.
Modifications to modularization units are automatically adopted at release upgrade if
• They have only been changed by the customer, but not in the original version
• They have been newly created by the customer
Automatic adoption of modifications at release upgrade is not possible if both the original
version of the modularization unit and the customer version have been changed (for example,
if either changes to interfaces that affect both function modules and subroutines, or changes
to the source code have been made). However, during this kind of adjustment, the
Modification Assistant does offer support in the form of the splitscreen editor.
Manual editing using the editor is necessary whenever the part of program that a customer
has changed no longer exists in the original. If this occurs, it is marked as an unresolved
problem and entered in the log.
The splitscreen editor is called in comparison mode. The positioning pushbutton 1H[W
GLIIHUHQFHallows you to scroll to the next source code difference between the two programs.
At this juncture, you must decide whether you want to insert your modifications into the
original or if the original should remain unchanged. To make changes to the original, proceed
as follows:
• Place your cursor on the appropriate passage in the modified version or select a portion
of the source code and then choose Copy.
• Place your cursor on the corresponding passage in your original or select the block of
code you want to replace and choose either Insert or Replace. This inserts the code you
just copied to the buffer into the original.
If further differences occur, you can use the 1H[WGLIIHUHQFH pushbutton to scroll to the next
modification that was not automatically adopted by the system.
After making all necessary modifications, save your changes. A dialog box appears, asking
you to confirm that you have adjusted all modifications. If you answer ‘yes’, all modifications
not yet adopted are lost and can never be displayed again after the splitscreen editor is
closed.
SAP AG 62
ABAP Workbench Delta Guide (3.1-4.6)
If your new original version contains code that you would like to replace with unmodified code
from the previous version, use %ORFNEXIIHU menu to copy it to the buffer and ,QVHUW5HSODFH to
insert it into the original.
Online Documentation
$GMXVWPHQWVLQWKH6FUHHQ3DLQWHU
SAP AG 63
ABAP Workbench Delta Guide (3.1-4.6)
• The maximum number of lines (200) is exceeded when repositioning overlapping fields
Online Documentation
$GMXVWPHQWVLQWKH0HQX3DLQWHU
Online Documentation
SAP AG 64
ABAP Workbench Delta Guide (3.1-4.6)
$GMXVWLQJ7H[W(OHPHQWV
Online Documentation
All other modifications have to be modified manually.
$GMXVWLQJ)XQFWLRQ0RGXOHV
Online Documentation
In all other cases, you have to adjust your modifications manually
$GMXVWLQJ'RFXPHQWDWLRQ
In this area modifications can be adopted whenever you so desire by simply choosing the
corresponding pushbutton. You can view both the original and the modifications before
adjustment.
SAP AG 65
ABAP Workbench Delta Guide (3.1-4.6)
$GMXVWPHQWVZLWKRXW0RGLILFDWLRQ$VVLVWDQW
Objects modified without the Modification Assitant can be adjusted using version
management.
When modifying objects where version management cannot be used, carefully document
any changes that you make. This customer documentation can be of great assistance the
next time the object needs to be adjusted.
For further information, see the
Online Documentation
SAP AG 66
ABAP Workbench Delta Guide (3.1-4.6)
$%$3'LFWLRQDU\
After reviewing the following topics, you will be able to:
Use append technique for Search Helps
Understand that views can be used as includes
Explain how the type can be directly assigned to data elements
Understand the concept of user-defined types
SAP AG 67
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
%XIIHULQJ'DWDEDVH9LHZV
From Release 4.0, you can buffer the data read from an ABAP program with a database view.
View data is buffered completely analogously to table data.
,QFOXGHVIRU'DWDEDVH9LHZV
From Release 4.0 an entire table can be included in a database view. In this case all the
fields of the included table will become fields of the view (whereby you can explicitly exclude
certain fields). If new fields are included in the table or existing fields are deleted, the view is
automatically adjusted to this change. A new or deleted field is thus included in the view or
deleted from the view in this case.
,QGH[HVRQ6SHFLILF'DWDEDVHV
The optimizer of the database system decides whether an index should be used for a certain
table access. This means that an index might only result in a gain in performance for certain
database systems. You can therefore define the database systems on which an index should
be created when you define the index in the ABAP Dictionary. You can also define an index in
the ABAP Dictionary that has no corresponding index in the database.
Indexes
1DPHG,QFOXGHVDQG9LHZVDV,QFOXGHV
SAP AG 68
ABAP Workbench Delta Guide (3.1-4.6)
In the past, only a structure or table could be used as a substructure in other structures or
tables. Now you can also include a view as a substructure in a table or structure.
A view is inserted as a substructure in the table or structure maintenance transaction (SE11)
analogously to including a structure or table.
Includes
It is now possible to assign a name to an included structure. This name can be used in ABAP
programs to address the included structure as a whole.
Named Includes
8VHU'HILQHG7\SHV
User-defined data types can be stored for all programs in the ABAP Dictionary. These user-
defined types provide the same functionality as the local types that can be defined in ABAP
programs with TYPES.
The central definition of types that are used more than once in the ABAP Dictionary permits
them to be changed centrally. The active ABAP Dictionary ensures that such changes are
made at all the relevant locations. ABAP programs, for example, are adjusted to the modified
type definitions when they are recreated. If a type is changed, all the objects (e.g. types or
tables) that use this type are determined at activation. The objects that are found are
automatically adjusted to the change.
There are three different type categories:
• 'DWDHOHPHQWV A data element defines elementary types and reference types.
• 6WUXFWXUHVA structure consists of components that also have a type, that is they refer to
a type.
• 7DEOHW\SHVA table type describes the structure and functional attributes of an internal
table.
All the types lie in a common namespace. For example, no structure or table type having the
same name can be created for a data element.
Types
'DWD(OHPHQWVZLWK'LUHFW7\SH(QWU\
In the past, a data element (elementary type) had to refer to a domain. Now you can also
define data elements that do not reference a domain. The data type, length and (depending
on the data type) number of decimal places can be directly assigned to data elements. As a
result, you can define elementary types directly and easily as in the ABAP programming
language.
There are two ways to define the type of a data element:
• 5HIHUHQFHWRDGRPDLQ The data element takes on the type and output attributes of the
domain, e.g. data type, number of places, output length. This is preferable if you want to
make sure that different data elements have the same data type.
SAP AG 69
ABAP Workbench Delta Guide (3.1-4.6)
• 'LUHFWHQWU\RIWKHGDWDW\SHOHQJWKDQGSRVVLEO\QXPEHURIGHFLPDOSODFHV The
additional setting options in the domain (e.g. conversion routines, settings for output
attributes such as output length, sign) are not available for direct type entry.
Data Elements
&UHDWLQJDQG8VLQJ6HDUFK+HOSV
Search helps are a new feature in Release 4.0. These easy-to-use input helps can be defined
in the ABAP Dictionary. There are three mechanisms available for attaching them to fields.
They can easily be used at several locations if you attach them to data elements and to check
tables. However, in this case, only the foreign key fields and no further screen fields can be
used in the search. If you directly attach a search help to a field of a structure or table,
however, all the fields of the structure or table can be used to generate the hit list.
Search Helps
56WDQGDUG)XQFWLRQ,QSXW+HOS
5HPRWH/HDUQLQJ
Airline LH
)
Flight number 0* ,QSXWKHOSKLWOLVW
...
$LUOLQH /+
1R 'HSDLUSRUW 'HVWDLUSRUW
/LVWRISRVVLEOHYDOXHV
IRUWKHIOLJKWQXPEHU
)XUWKHULQIRUPDWLRQ
RIDLUOLQH/+
SAP AG
Search helps permit the user to display a list of possible values for a screen field (see the
flight number on the slide). A value can be directly copied to an input field by list selection.
Fields with an input help can be recognized by the input help key to the right of the field. This
key appears as soon as the cursor is positioned on the corresponding screen field. The help
can be started either by clicking on this screen element or with the function key F4.
If the number of possible entries for a field is very large, you can limit the set of displayed
values by entering further restrictions.
SAP AG 70
ABAP Workbench Delta Guide (3.1-4.6)
Further meaningful information about the displayed values is included in the display of
possible entries (the hit list), especially if the field requires that a formal key be entered.
Since the input help is a standard function, it should look and behave the same throughout
the entire R/3 System. The ABAP Workbench therefore provides simple tools for assigning a
standardized input help to a screen field.
0LJUDWLRQRI0DWFKFRGHVDQG+HOS9LHZV
When you upgrade your system to Release 4.0, the system DXWRPDWLFDOO\JHQHUDWHVVHDUFK
KHOSV with the same names as the old input help objects. The original help objects remain in
your system, even though they will be redundant.
The input helps derived from the input checks stored in the flow logic are still supported for
reasons of compatibility, but should not be used any longer.
Input helps which you program yourself (POV) present problems when maintaining, reusing
and standardizing objects. You should therefore only use them if defining an input help with
the ABAP Dictionary does not provide satisfactory results.
0LJUDWLRQRI+HOS9LHZVDQG0DWFKFRGHV
MC ID DB View
belongs to generates 0B$%&'$
Help View $
Release 3.x MC Object
+B1$0(
$%&'
Primary tab. T MC ID DB View
generates 0B$%&'
Second. tab. 1 belongs to
...
Table
Release 4.x El. Search Help
7
Search help $%&'$ DB View
El. Search Help assignment Selection
0B$%&'$
+B1$0( method
Coll. Search Help
.
Selection Help-View $%&'
method
or +B1$0( Search help El. Search Help DB View
Primary tab T inclusions =$%&' 0B$%&'
SAP AG 1999
Search helps were introduced in Release 4.0. Previously, input helps were implemented by
creating matchcodes and help views. However these had a less-extensive range of functions.
When you upgrade to 4.0, search helps are created from these objects (the search helps will
have identical names to the original object from which they are created). The original objects
will initially remain in the system, but be meaningless.
Prior to Release 4.0, a help view was a complete description of an input help that was
automatically attached to its primary table (and only to it). An elementary search help is
SAP AG 71
ABAP Workbench Delta Guide (3.1-4.6)
created from each help view. The primary table of the help view can be entered as the
selection method for many cases, and the help view is used for the others. The search help
that is created is attached to the primary table of the help view.
An HOHPHQWDU\VHDUFKKHOS is created from a matchcode ID. The selection method assigned
is the generated database view (for a transparent ID) or the generated pooled table (for a
non-transparent ID) of the matchcode ID. In the first case, the generated view is handled as
an independent object in the ABAP Dictionary. In the second case, the pooled table is still
appended to its matchcode ID since the matchcode technique is used to update the data in
this table.
A FROOHFWLYHVHDUFKKHOS is created from a matchcode object. Since matchcodes are
attached to input fields on the screen, this search help is processed if the matchcode is
assigned to a screen field.
&UHDWLQJD6HDUFK+HOS
Search Helps
SAP AG 72
ABAP Workbench Delta Guide (3.1-4.6)
6HDUFK+HOS3DUDPHWHUV
5HPRWH/HDUQLQJ
,03257
6FUHHQ
6HDUFKKHOS
&$55,' LH
&211,' •&RQWH[WGDWD
•6HOHFWLRQPHWKRG
•'LDORJEHKDYLRXU
•2XWSXWGDWD
(;3257 WKHVHIRXUSDUDPHWHUV
KDYHWREHVSHFLILHG
SAP AG
0DLQWHQDQFH6FUHHQRI6HDUFK+HOS
SAP AG 73
ABAP Workbench Delta Guide (3.1-4.6)
6WHS7KH6HDUFK+HOS,QWHUIDFH
Search Helps
6HDUFK+HOS,QWHUIDFH,QSXW2XWSXW3DUDPHWHUV
5HPRWH/HDUQLQJ
,03257
6FUHHQ
6HDUFKKHOS
&$55,' LH
&211,'
•&RQWH[WGDWD
•2XWSXWGDWD
'HILQHWKHVHDUFKKHOS
(;3257 LPSRUWH[SRUWSDUDPHWHUV
SAP AG
The VHDUFKKHOSLQWHUIDFH defines the FRQWH[WGDWD that can be used in the input help and the
data that can be reurned to the input mask. The search help interface comprises interface
parameters, similarly to the interface of a function module.
When you define an interface parameter of a search help, you must also define whether it
should be used to copy data to the input help (iPSRUWSDUDPHWHU) or whether it should be used
to return data from the input help (e[SRUWSDUDPHWHU). A parameter can also have both
attributes at the same time.
The location from which the import parameters of a search help get their values and the
screen fields in which the contents of the export parameters are returned are defined in the
search help maintenance screen ( refer to the "Maintenance Screen" graphic). The parameter
types of a search help must be defined by assigning them data elements.
The field "/SRV" defines the order in which the values from the hitlist will appear. It should
contain a certain position value ( from 1 to n ) for each search help parameter.
SAP AG 74
ABAP Workbench Delta Guide (3.1-4.6)
6WHS6HDUFK+HOS'DWD6HOHFWLRQ0HWKRG
Search Helps
'DWD6HOHFWLRQ0HWKRG7DEOHRU9LHZ
5HPRWH/HDUQLQJ
,03257
6FUHHQ
&$55,' LH
6HDUFKKHOS
&211,'
•&RQWH[WGDWD
•6HOHFWLRQPHWKRG
•2XWSXWGDWD
+LWOLVW
Carrier /+
No City from City to
Frankfurt New York
SAP AG
The possible entries displayed for a field by the input help are determined at runtime by
VHOHFWLRQIURPWKHGDWDEDVH. When you define a search help, you must specify the database
object from which the data should be selected by specifying a table or a view as VHOHFWLRQ
PHWKRG
The fields of the selection method are assigned to the parameters of the search help if their
names are the same. If the user makes an entry in the dialog box for restricting values, this
value is used to define a WHERE condition for the corresponding field of the selection
method. Vice versa, the contents of the fields of the selection method having the same name
are assigned to the parameters of the search help appearing in the hit list.
If the selection method is a table with a text table, the non-key fields of this text table can also
be used in the search help. In this case the corresponding entries of the logon language are
automatically taken into consideration in the selection. These columns remain empty for
values that do not have text in the logon language.
If the selection method is client-specific, the client field cannot appear as a parameter of the
search help. The search help is always selected in the current client.
In a number of cases the attributes of the possible entries to be used in the input help for
restricting the selection or for displaying the hitlist are distributed on several tables. If more
than one table and its text table are involved here, you should use a YLHZas the selection
method of the search help.
Such a selection on several tables can be implemented with a database view, but you should
note that database views in the R/3 System are always defined with an inner join. However,
the set of possible entries is sometimes described by the entries in a primary table for which
SAP AG 75
ABAP Workbench Delta Guide (3.1-4.6)
additional optional information can be obtained from further secondary tables. This view on
the data can be implemented with a help view. The same outer join logic is used for help
views as for maintenance views.
A help view is defined in the same way as a maintenance view. The only use of a help view is
as the selection method for a search help. Since the R/3 System cannot pass the selection
directly to the database using a help view, it must generate its own access routines.
Selection using a table and text table corresponds to selection using a virtual help view. For
this reason an explicit help view should not be created in this case.
6WHS6HDUFK+HOS'LDORJ%HKDYLRU
Search Helps
'LDORJ%HKDYLRU±6HOHFWLRQ'LDORJ%R[
5HPRWH/HDUQLQJ
,03257
6FUHHQ
&$55,' LH
6HOHFWLRQGLDORJER[ 6HDUFKKHOS
&211,'
CArrier LH ... •&RQWH[WGDWD
Connection ... •6HOHFWLRQPHWKRG
City from •'LDORJEHKDYLRU
...
City to •2XWSXWGDWD
...
Restrict display to 500
+LWOLVW
(;3257 Carrier /+
No City from City to
Frankfurt New York
SAP AG
In an input help process, the set of possible entries is presented in the dialog box as a list for
displaying the hit list. The user selects the required value from this list by double clicking.
Since the possible entries are often formal keys, you must be able to display further
explanatory information about the possible entries in the list.
If the set of possible entries is very large, the user should be able to define additional
conditions for the attributes of the selected entry. Restricting the set of data in this way
increases the clarity of the list and reduces the system load. Additional conditions can be
SAP AG 76
ABAP Workbench Delta Guide (3.1-4.6)
entered in a further dialog box called the dialog box for restricting values (selection dialog box
in the above diagram).
Specifying the GLDORJW\SH of a search help defines whether the dialog box for restricting
values should be offered and if so under what conditions:
"D" = "Immediate value display" Å no dialog box appears; the hit list appears immediately
"A" = "Dialog depends on set of values" Å if there are more than 100 entries in the hit list, the
dialog box will appear.
"C" = "Complex dialog with value restriction" Å the dialog box appears. The number of hit list
entries is initialized with a certain value that can be changed later.
The attributes in the dialog box for displaying the hit list or in the dialog box for restricting
values must be defined as internal parameters of the search help. An internal parameter can
be used in only one of the two dialog boxes. It can also belong to the search help interface.
The internal parameter types are defined with data elements. These data elements define
how the parameters are displayed in the two dialog boxes.
6HDUFK+HOS$VVLJQPHQW
A search help can influence the behavior of a field when the input help is called. The search
help must be assigned to the field in order to do this. You have the following options for this
assignment:
• Attach the search help to a data element
• Attach the search help to a check table
• Attach the search help to a table field
• Attach the search help directly to a screen field
SAP AG 77
ABAP Workbench Delta Guide (3.1-4.6)
0HWKRGVWR$VVLJQD6HDUFK+HOSWRD)LHOG
6HDUFKKHOS
,QWHUQDO%HKDYLRU
,QWHUIDFH
&KHFNWDEOH
'DWDHOHPHQW
Client Key1 Key 2 Data part
6HDUFK
Client Field 1 Field 3 ...
ILHOG
7DEOH6WUXFWXUH
SAP AG 1999
More than one search help can thus be assigned to a field. Conflicts when calling the input
help are resolved with a hierarchy of search help attachments.
SAP AG 78
ABAP Workbench Delta Guide (3.1-4.6)
+LHUDUFK\RI,QSXW+HOS
exists
Search help from field does not exist
352&(6621
9$/8(5(48(67
Check table help
Search help for
dynpro field
Search help for Search help from
check table data element
Checks in the
flow logic
Check table with
FIELD … SELECT
text table Fixed values
FIELD … VALUES
Key values of
check table Time or
Calender help
SAP AG 1999
When you call the input help for a screen field, there is first a check if an input help is defined
for the field on the screen. There are three cases here. If there is a programmed help with
PROCESS ON VALUE-REQUEST , it is executed. If there is no programmed help, the system
tries to call the search help assigned to the field on the screen. If no search help is assigned
to the field on the screen, the help defined with FIELD SELECT or FIELD VALUES is
offered.
If no input help is defined for the field on the screen, the system tries to call the search help
attached to the table field. If there is no search help here, it tries to display the check table
help. There are two cases here. If a search help is attached to the check table, it is displayed.
Otherwise only the key values of the check table are displayed. If there is a text table or check
table, the text for the key value is added in the user’s logon language.
If there is no check table for the field, the system tries to call the search help from the data
element. If there is no search help for the data element either, existing domain fixed values
are displayed. The calendar help and time help are automatically provided for fields with data
type DATS and TIMS.
'DWD(OHPHQW6HDUFK+HOS
You can describe the input help process of a field with a search help. To do this, you need a
mechanism that assigns the description of an input help to a screen field.
SAP AG 79
ABAP Workbench Delta Guide (3.1-4.6)
The possible entries for a field are usually closely related to its semantics. You can therefore
attach a search help to a data element. This is done in the maintenance transaction for the
data element and causes the attached search help to be used for all the screen fields using
this data element.
When a search help is attached to a data element, you must define an EXPORT parameter of
the search help whose contents are returned to the search help from the input help. <RX
FDQQRWUHWXUQDQ\RWKHUYDOXHVZKHQ\RXDWWDFKDVHDUFKKHOSWRDGDWDHOHPHQW If the
selected parameter is also an IMPORT parameter, the contents of the search field are taken
into consideration in the input help if they contain a string. No other IMPORT parameters of
the search help can be defined (except with default values).
If no search help is attached to a data element, it can nevertheless define an input help. If the
domain to which the data element refers has fixed values, these will be offered for selection in
the input help.
If the domain has type DATS or TIMS, a calendar or clock is automatically displayed for the
input help.
&KHFN7DEOH+HOS
If an input check is defined for a screen field, a meaningful input help can be derived from this
check if it is possible to determine the set of all the values that would satisfy the input check.
Exactly this set must then be displayed in a suitable manner as the possible entries.
If a search help is not attached to the check table of a field, the check table help is processed
with a "virtual search help", that is, as an input help whose selection method is the check
table and whose parameters are WKHNH\ILHOGVRIWKHFKHFNWDEOH and possibly the first
character-type field of the text table.
A search help can also be implemented for this input help. The search help must be attached
to the check table when the check table is maintained. As when you define a foreign key, the
interface parameters of the search help must be assigned to the key fields of the check table.
The search help that is assigned to a table should display the data contained in this table.
Therefore the selection method should normally be this table or a view on this table.
,QWKHFKHFNWDEOHKHOSDOOWKHIRUHLJQNH\ILHOGVDQGQRWRQO\WKHVHDUFKILHOGDUHWDNHQ
LQWRFRQVLGHUDWLRQ The check table help therefore overrides any input help defined by the
data element.
SAP AG 80
ABAP Workbench Delta Guide (3.1-4.6)
7KHJUDSKLFVKRZVKRZWRGHILQHDVHDUFKKHOSIRUFKHFNWDEOH6&$55
)LHOG6HDUFK+HOS
If the input help of a field is defined by its data element, no further screen fields can be used
in the input help. Only the foreign key fields of the underlying foreign key can be taken into
consideration in the check table help. You can attach a search help to a field of a table or
structure to define an input help in which all the screen fields can be used. This attachment
overrides the check table help if it exists and the input help defined by the data element.
A search help is attached to a field of a table or structure in the maintenance transaction for
this table or structure. You must assign the interface parameters of the search help to any
fields of the table or structure. The search field must be assigned to an EXPORT parameter of
the search help at this time.
The other fields that are assigned to search help parameters by the attachment are sought in
the input mask and included in the process. Fields that are not found in the input mask are
sought in the flow logic, but values are only returned in fields of the input mask. A similar
mechanism is used for the check table help.
SAP AG 81
ABAP Workbench Delta Guide (3.1-4.6)
$VVLJQPHQWRID6HDUFK+HOSWRD)LHOGRID7DEOHRU6WUXFWXUH
0DSSLQJRI6HDUFK+HOS3DUDPHWHUV
When you have chosen a search help for the check table or for a table or structure field a
"mapping-screen" appears. The search help parameters on the left-hand side have to be
assigned to the table fields, which are shown on the right-hand side.
SAP AG 82
ABAP Workbench Delta Guide (3.1-4.6)
$VVLJQPHQWRI)LHOGVDQG6HDUFK+HOS3DUDPHWHUV
There is a value transport between the field contents on the screen and the interface of the
search help when the input help is called and when a line of the hit list is selected. The values
already entered on the screen can then be used to restrict the selection from the hit list. Only
those hits that are consistent with the values already entered are displayed.
This value transport is only possible if the parameters are linked with the corresponding table
or structure fields. For details see:
&ROOHFWLYH6HDUFK+HOSV
Like an elementary search help, a collective search help has an interface of IMPORT and
EXPORT parameters with which the search help exchanges data. Using this interface, the
collective search help can be attached to fields, tables and data elements exactly like an
elementary search help.
Only one search help can be attached to a field, table or data element, so a collective search
help is the only method for attaching multiple search paths to a field.
SAP AG 83
ABAP Workbench Delta Guide (3.1-4.6)
&ROOHFWLYH6HDUFK+HOS
&ROOHFWLYH6HDUFK+HOS
,QFOXGHG6HDUFK+HOSV
,QWHUQDO%HKDYLRU ,QWHUQDO%HKDYLRU
,QWHUIDFH ,QWHUIDFH
,QWHUIDFH
SAP AG 1999
When you define a collective search help, there are no components for describing the dialog
behavior and data selection; instead the included search helps are listed.You must assign the
parameters of the collective search help to the interface parameters of the included search
help for each inclusion.
A search help can also be included in several collective search helps and at the same time
itself be attached to fields, tables and data elements. A collective search help can also be
included in another collective search help.
The first time a user uses a collective search help, all the elementary search helps it contains
are offered for selection. Each time this collective search help is used thereafter, the last
elementary search help selected is processed since most users choose the same search path
each time. You can also switch to another elementary search help.
3HUIRUPDQFH&RQVLGHUDWLRQV
You sometimes have to search a large amount of data when making selections for an input
help. This means that you might have to wait a long time for the possible entries to be
displayed, which could result in a significant increase in the system load.
When you define a search help, you should therefore check whether you should take
measures to optimize the accessing behavior for the selection method. This is especially true
if the selection uses a view and thus accesses more than one physical table.
SAP AG 84
ABAP Workbench Delta Guide (3.1-4.6)
If the number of entries in the selection method is very large, you should restrict the hit list
with further conditions. This also increases the clarity of the hit list. The additional conditions
can directly result from the context or can be entered in the dialog box for restricting values.
The performance of the input help can frequently be significantly improved by creating an
index on the fields used to formulate the restrictions.
If a restriction is defined with the secondary table of a help view, the selection is automatically
performed as an inner join. In this case you should replace the help view with a database
view.
6HDUFK+HOS([LW
A search help is an object that describes an input help within the system-wide standard. In
some cases, the special semantics of a field require that some details deviate from this
standard. This can be implemented with a search help exit.
A search help exit is a function module having a standardized interface. (The function module
F4IF_SHLP_EXIT_EXAMPLE can be used as template.) If a search help has such a search
help exit, the search help exit is called prior to each single step of the process. The interface
passes the search help exit the administration data of the help processor where this data can
be manipulated.
1RQ6WDQGDUG6HDUFK+HOS([LW
5HPRWH/HDUQLQJ
Search
Search help exit
SAPBC_GLOBAL_F4_SFLIGHT
SAP AG
The administration data also includes the information about the next step to be executed. The
search help exit can now execute either preparatory actions for this step or the step itself (for
example a data selection which cannot be implemented with a SELECT on a table or view). In
the second case the search help exit also changes the information about the next step to be
executed. Some function modules that can be used as search help exits or that can be used
to manipulate the administration data in search help exits are already defined with the prefix
SAP AG 85
ABAP Workbench Delta Guide (3.1-4.6)
F4UT_. Search help exits should only be used for exceptions. Using search help exits
encourages non-standard solutions and make it more difficult to maintain the input help.
$SSHQGVIRU6HDUFK+HOSV
Append search helps permit you to enhance SAP search helps with additional search paths
without modifying them. In this way you can for example enhance an SAP collective search
help with further customer-specific search paths (elementary search helps) in the customer
system. The concept is analogous to append structures for tables.
$SSHQGIRU6HDUFK+HOS
DSSHQGV
6$3&ROOHFWLYH6HDUFK+HOS
,QFOXGHG6HDUFK+HOSV ,QFOXGHG6HDUFK+HOSV
&XVWRPHU$SSHQG
6HDUFK+HOS
SAP AG 1999
You can define an append search help for a collective search help of the SAP standard. An
append search help is a collective search help and inherits the interface from its appending
search help. In the customer system, the name of the append search help is selected from
the customer namespace. An append search help is assigned to exactly one collective search
help.
The customer can therefore enhance SAP collective search helps as follows:
1. Create a customer-specific elementary search help in the customer namespace.
2. Create an append search help and assign it to the SAP collective search help.
3. The elementary search helps belonging to the customer must be assigned in the append
search help.
SAP AG 86
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 87
ABAP Workbench Delta Guide (3.1-4.6)
$%$3/DQJXDJH
After reviewing the following topics, you will be able to:
Understand the news about the type concept
Explain the news about Internal Tables
Describe the SORT STABLE
SAP AG 88
ABAP Workbench Delta Guide (3.1-4.6)
7\SH&RQFHSW
'HILQLQJ&HQWUDO7\SHVLQWKH$%$3'LFWLRQDU\
*HQHUDO
Up until now the administration and maintenance of data types in the ABAP programming
language and in the ABAP Dictionary were not unified.
In Release 3.0 the type concept in the ABAP programming language was greatly enhanced,
allowing you to define elementary and structured data types independently. Structured data
types could be further subdivided into structures and internal tables. Structure components
and internal table line types could have any data type desired, which made the definition of
extremely complex data types possible. However, if you completely split a complex data type
into its component parts, you always end up with elementary ABAP data types.
ABAP data types and Dictionary data types previously only genuinely corresponded to one
another if they were structures with elementary components. The ABAP data type ’structure’
corresponded to the structure of database tables in the Dictionary and the structure of
independent structures. From ABAP programs you could refer to database tables and
Dictionary structures using the LIKE addition and also refer to individual components of ABAP
Dictionary types at the same time. However, complex ABAP data types like internal tables or
non-elementary structures had no direct equivalent in the Dictionary. From Release 3.0 type
groups based on include technology were put at the user’s disposal as a sort of temporary
solution. These type groups allowed the user to store ABAP data types centrally in the
Dictionary.
'HVFULSWLRQRI)XQFWLRQ
The following sections describe which Dictionary data types correspond to individual ABAP
data types and how they are addressed in ABAP
(OHPHQWDU\7\SHV
Elementary data types in ABAP correspond to the data elements that were up to now only
found in the ABAP Dictionary. From Release 4.5A data elements will also be called
elementary types in the Dictionary. For the time being, the two-tiered domain concept for
elementary types will retain its validity. The actual elementary Dictionary data type contains
the semantic attributes, while the technical attributes are defined in a domain. You can refer
to elementary types and previous Dictionary data elements directly in ABAP programs using
SAP AG 89
ABAP Workbench Delta Guide (3.1-4.6)
the addition TYPE. When you use TYPE all external Dictionary data types are converted into
their corresponding ABAP data types. Elementary types are the smallest indivisible units of
those structured types and table types listed below. Thus all Dictionary types contain
semantic attributes such as texts, value tables, and documentation.
6WUXFWXUHG7\SHV
Structures in ABAP correspond to the structures that up to now were only found in the ABAP
Dictionary. From Release 4.5A structures in the Dictionary will be called structured types.
Individual structured type components can take any Dictionary data type you want starting
from Release 4.5A. This makes complex structure construction possible. You can use the
addition TYPE to refer to structured types in ABAP programs. For reasons of compatibility you
will still be able to use the addition LIKE to refer to structured types.
7DEOH7\SHV
From Release 4.5A table types can be defined in the Dictionary. Table type specifications
correspond to internal tables in ABAP, that is they have an access type, a key, and a line
type. Line types can be of any Dictionary data type desired, which makes complex nested
table creation possible. You can use the addition TYPE to refer to table types in ABAP
programs.
'DWDEDVH7DEOHV
In addition to managing data types centrally, the most important task of the ABAP Dictionary
is still database table administration. The Dictionary describes from which elementary types
the structured type of a database table’s data record has been constructed. As in the past,
you will still be able to use the addition LIKE in ABAP to refer to the structure of database
tables and of individual data fields. From 4.5A you will also be able to use TYPE refer to the
structure and fields of database tables.
:KDW
V1H[W"
In the future, SAP plans to allow for the central definition of constants in the ABAP Dictionary,
a process which, at this time, can only be undertaken with the aid of type groups. Additionally,
a comprehensive bundling concept will make type group encapsulation generally available
throughout the system.
Further information about creating central types in the ABAP Dictionary :
Central Types
SAP AG 90
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUQDO7DEOHV
2YHUYLHZDQG,QWURGXFWLRQ
,QWHUQDO7DEOHV.H\7DEOHV
The following features of internal tables have been considerably improved in Release 4.0:
• Performance improvements, particularly for large tables. This has been achieved by
introducing KDVKHGWDEOHV, whose access time is largely constant, that is, independent of
the number of table entries.
• Introduction of VRUWHGWDEOHV. This has removed the need for complex program code,
whose tasks are now performed in the kernel.
• Support for generic programming by introducing JHQHULFWDEOHW\SHV.
The term default key has been extended to include a user-definable key. In addition to the
previous form of internal table (standard tables), SAP has introduced new table types for
sorted and hashed tables. The key of these tables is an integral part of the type definition. For
this reason, tables with these types are also generically known as key tables. For further
information, see
internal tables
1HZ7DEOH7\SHV67$1'$5'7$%/(6257('
7$%/(DQG+$6+('7$%/(
Internal tables in their old form are now known as standard tables. The old type TABLE has
now been replaced by 67$1'$5'7$%/(. The new types 6257('7$%/(and +$6+('
7$%/( have been introduced.
• 6RUWHGWDEOHV are always stored sorted by their table key in ascending order. The access
time is logarithmically related to the number of table entries.
• +DVKHGWDEOHV are managed internally using a hash procedure. The access time to a
single table entry is essentially constant, that is, the access time is independent of the
number of entries.
Thus, a complete table type is defined as follows:
• 7DEOHW\SH (STANDARD TABLE, SORTED TABLE, HASHED TABLE)
• /LQHW\SH
• .H\ (the field sequence is part of the type definition)
• 8QLTXHQHVVDWWULEXWH (UNIQUE, NON-UNIQUE)
SAP AG 91
ABAP Workbench Delta Guide (3.1-4.6)
*HQHULF7DEOH7\SHV,1'(;7$%/(DQG$1<
7$%/(
To allow generic programming, there is a hierarchy based on the basic internal table types
listed above. The generic type INDEX TABLE includes standard and sorted tables. The type
ANY TABLE can be used for any table.
Furthermore, you can define further generic types by omitting the line type, key, or
uniqueness attribute of a table. This enables you to define the types of parameters in generic
procedures.
7\SLQJ3URFHGXUH3DUDPHWHUV
Since the old internal table type corresponds to the new standard table, you can only pass
standard tables to a TABLES parameter. You can pass the new tables types to FORM and
FUNCTION parameters using the USING or CHANGING, and IMPORTING, EXPORTING, and
CHANGING additions.
1HZ7DEOH2SHUDWLRQV
Entries in key tables are located using their key. This means that it must also be possible to
add, modify, and delete table entries using the appropriate table key. The following new table
operations have therefore been introduced:
• INSERT ... INTO TABLE ...
• MODIFY TABLE ...
• READ TABLE ... [FROM ... |WITH TABLE KEY ...]
• DELETE TABLE ... [FROM ... |WITH TABLE KEY ...]
The new operations are valid for all table types and are, in this respect, generic (for details of
the semantics, refer to the corresponding keyword documentation). In each of the statements,
you can specify the key using a work area, either explicit or implicit (table with header line).
The key values are then taken from the work area. In the READ and DELETE statements, you
can also specify the key explicitly in the form:
... WITH TABLE KEY k1 = v1 ... kn = vn
Unlike the previous form of the READ statement - "WITH KEY k1 = v1 ... kn = vn" -
the new form must specify the key fully. This is tested within the syntax check.
The syntax of the new operations has been modeled as far as possible on the existing
statements for reading, inserting, modifying and deleting table entries. Note the following rules
of thumb:
• In the new operations, the word TABLE comes directly before the table name itself
• Use the addition WITH TABLE KEY to specify the key explicitly
SAP AG 92
ABAP Workbench Delta Guide (3.1-4.6)
,QWHJUDWLRQRIWKH1HZ7DEOH7\SHV
The new table types can be used both in the new table operations listed above and in existing
ABAP statements. Thus, you can also use the following statements with key tables:
• LOOP AT
• COLLECT
• EXPORT
• IF
• IMPORT
• MOVE
• SELECT
• SORT
/223$7LWDE!$66,*1,1*ILHOGV\PERO!
,QGH[7DEOHV
6WDQGDUG7DEOH
8VH
Whenever you want to access the internal table using mainly index operations (for example,
an internal table for a table control ). However, it is still possible to access the table using the
key.
2SHUDWLRQV6XSSRUWHG
• Key types
• ... WITH DEFAULT KEY: All non-numeric fields from the left of the structure
• ... WITH KEY <field1> <field2> <field3>: Fields <field1>, <field2>, <field3>
in the order in which you specify them
• Index operations: All
SAP AG 93
ABAP Workbench Delta Guide (3.1-4.6)
2SHUDWLRQV1RW6XSSRUWHG
1HZ6\QWD[IRU6WDQGDUG7DEOHV5HO
9DULDQW
Internal table without header line and a suitable table work area. Internal table has default key
TYPES: line_type 7<3( spfli,
itab_type TYPE STANDARD TABLE OF line_type
WITH DEFAULT KEY.
DATA: wa_itab TYPE line_type,
itab TYPE itab_type.
9DULDQW
Internal table with header line
TYPES: itab_type 7<3( STANDARD TABLE OF spfli
WITH DEFAULT KEY.
DATA: itab TYPE itab_type WITH HEADER LINE.
9DULDQW
The type of the internal table can be defined as a central type in the ABAP Dictionary.
,QLWLDO6L]H
If you want to use an initial size other than the default, you can use the following syntax:
5HOHDVH
TYPES: line_type LIKE spfli,
itab_type TYPE line_type 2&&856Q.
5HOHDVH
SAP AG 94
ABAP Workbench Delta Guide (3.1-4.6)
6KRUW)RUP
For the special case of a standard table with default key, there is a shortened syntax:
DATA: itab TYPE TABLE OF line_type.
This declares a standard table with line type line_type and default key.
You cannot use this construction to declare a type in a program using the TYPES statement,
since it is reserved for the definition of generic table types.
6RUWHG7DEOH
8VH
Whenever you need partial sequential key access to the internal table. However, it is still
possible to access the table using the index.
2SHUDWLRQ6XSSRUWHG
• .H\W\SHV
• ... WITH DEFAULT KEY: All non-numeric fields starting at the left-hand end of the
structure
• ... WITH KEY <field1> <field2> <field3>: The fields field1, field2, field3 in
the order in which you specify them
• WITH UNIQUE KEY ... : The key is unique. If you try to insert duplicate lines with the
same key, an error occurs.
• Key operations: All
• Index operations: All
2SHUDWLRQV1RW6XSSRUWHG
• Sorting. New lines are inserted into the internal table in the appropriate position according
to their key.
SAP AG 95
ABAP Workbench Delta Guide (3.1-4.6)
• INSERT ... INDEX n. Inserting using the index could otherwise lead to a sort order
violation.
+DVKHG7DEOH
8VH
Whenever you will only access the table using the full key of an entry. Index access is QRW
possible.
2SHUDWLRQV6XSSRUWHG
.H\W\SHV
• ...WITH UNIQUE KEY <field1> <field2> <field3>: The fields <field1>,
<field2>, <field3> form the key of the internal table in the order in which you specify them.
The key fields must identify a single line of the hashed table uniquely. If you try to insert
duplicate lines, an error occurs.
• Key operations: All (see the syntax table in this unit)
2SHUDWLRQV1RW6XSSRUWHG
6\QWD[
SAP AG 96
ABAP Workbench Delta Guide (3.1-4.6)
,QGH[2SHUDWLRQVIRU,QWHUQDO7DEOHV:LWKRXW
+HDGHU/LQH
,QGH[2SHUDWLRQVLWDEZLWKRXWKHDGHUOLQH
5HPRWH/HDUQLQJ
6LQJOHOLQHSURFHVVLQJ 0XOWLSOHOLQHSURFHVVLQJ
Q
5($'7$%/(LWDE! /223$7LWDE!
5HDG ,1'(;Q! >)520Q!@>72Q!@
,172ZD! ,172ZD!
>75$163257,1*@
(1'/223
$SSHQG $33(1'ZD!72LWDE! $33(1'/,1(62)LWDE!
>)520Q!@>72Q@
72LWDE!
[INDEX <n>] means, that this addition is only necessary if you want to use the statement
outside a LOOP AT itab INTO wa_itab. loop.
,QGH[2SHUDWLRQVIRU,QWHUQDO7DEOHV:LWK
+HDGHU/LQH
SAP AG 97
ABAP Workbench Delta Guide (3.1-4.6)
,QGH[2SHUDWLRQVLWDEZLWKKHDGHUOLQH
5HPRWH/HDUQLQJ
6LQJOHOLQHSURFHVVLQJ 0XOWLSOHOLQHSURFHVVLQJ
Q
5($'7$%/(LWDE! /223$7LWDE!
5HDG ,1'(;Q! >)520Q!@>72Q!@
>75$163257,1*@
(1'/223
.H\2SHUDWLRQVIRU,QWHUQDO7DEOHV:LWKRXW
+HDGHU/LQH
SAP AG 98
ABAP Workbench Delta Guide (3.1-4.6)
.H\2SHUDWLRQVLWDEZLWKRXWKHDGHUOLQH
5HPRWH/HDUQLQJ
6LQJOHOLQHRSHUDWLRQV 0XOWLSOHOLQHRSHUDWLRQV
LPSOLFLWIURPZD! H[SOLFLW
5($'7$%/(LWDE! 5($'7$%/(LWDE! /223$7LWDE!
,172LWDEBZD! ,172ZD! ,172ZD!
)520ZD! :,7+7$%/(.(< :+(5(FRQGLWLRQ!
5HDG >75$163257,1*@. N! Y!
(1'/223
,QVHUW ,16(57ZD!,172 ,16(57/,1(6
7$%/(LWDE! 2)LWDE!
,1727$%/(LWDE!
,QVHUW &2//(&7ZD!,172
FROOHFWHG LWDE!
02',)<LWDE!
02',)<7$%/(LWDE!
)520ZD!
&KDQJH )520ZD!
>75$163257,1*
>75$163257,1*
I!IQ!@
I!IQ!@
:+(5(FRQGLWLRQ!
'HOHWH '(/(7(7$%/(LWDE! '(/(7(7$%/(LWDE! '(/(7(LWDE!
)520ZD! :,7+7$%/(.(< :+(5(FRQGLWLRQ!
N! Y!
SAP AG
*) The system supports a special construction to determine the number of lines in the internal
table with a partially-specified key:
clear counter.
LOOP AT itab WHERE <condition> 75$163257,1*12),(/'6.
ADD 1 to counter.
ENDLOOP.
.H\2SHUDWLRQVIRU,QWHUQDO7DEOHV:LWK+HDGHU
/LQH
SAP AG 99
ABAP Workbench Delta Guide (3.1-4.6)
.H\RSHUDWLRQVLWDEZLWKKHDGHUOLQH
5HPRWH/HDUQLQJ
6LQJOHOLQHRSHUDWLRQV 0XOWLSOHOLQHRSHUDWLRQV
LPSOLFLWIURPZD! H[SOLFLW
5($'7$%/(LWDE! 5($'7$%/(LWDE! /223$7LWDE!
5HDG )520ZD_LWDE! :,7+7$%/(.(< :+(5(FRQGLWLRQ!
>75$163257,1*@. N! Y!
(1'/223
,QVHUW ,16(57ZD_LWDE! ,16(57/,1(6
,1727$%/(LWDE! 2)LWDE!
,1727$%/(LWDE!
,QVHUW &2//(&7LWDE!
FROOHFWHG
02',)<LWDE!
02',)<7$%/(LWDE!
75$163257,1*
&KDQJH >75$163257,1*
I!IQ!
I!IQ!@
:+(5(FRQGLWLRQ!
*) The system supports a special construction to determine the number of lines in the internal
table with a partially-specified key:
clear counter.
LOOP AT itab WHERE <condition> 75$163257,1*12),(/'6.
ADD 1 to counter.
ENDLOOP.
/223$7LWDE$66,*1,1*IV!
$FFHVV8VLQJ)LHOG6\PEROV
When you read table entries using READ or in a LOOP, you can assign them to a field symbol
using the addition
... ASSIGNING <FS>
The field symbol <FS> points directly to the assigned line in memory. Unlike work areas, in
which the contents of the line are only available indirectly, field symbols allow you to read and
change table entries directly.
Remember when you access internal tables using field symbols that you must not change the
contents of the key fields of sorted or hashed tables. If you try to assign a new value to a key
SAP AG 100
ABAP Workbench Delta Guide (3.1-4.6)
field using a field symbol, a runtime error occurs. Note that you cannot use the SUM
statement with field symbols, since the statement is always applied to work areas.
$GYDQWDJHVRI)LHOG6\PEROV
When you read from an internal table, there are no overheads for copying the table line to the
work area. When you change an internal table with the MODIFY statement, you must first fill
a work area with values, and then assign them to the internal table. If you work with field
symbols instead, you do not have this overhead. This can improve performance if you have
large or complex internal tables. It also makes it easier to process nested internal tables.
2YHUKHDGVRI5($'
Note that internal overheads arise when you access internal tables using field symbols. After
a READ statement with a field symbol, the system has to register the assignment. When you
delete a table line to which a field symbol is pointing, the system also has to unassign the field
symbol to prevent it from pointing to an undefined area.
When you read individual table lines, it is worth using field symbols with the READ statement
for tables with a line width of 1000 bytes or more. If you also change the line using the
MODIFY statement, using field symbols is worthwhile from a line width of 100 bytes onwards.
2YHUKHDGVRI/223
To minimize the overheads incurred by using field symbols in loop processing, the system
does not register the assignment of each current line to the field symbol. Instead, it registers a
general assignment between a line of the table and the field symbol. When the loop is
finished, the line processed in the last loop pass is assigned to the field symbol.
Consequently, it is worth using field symbols in a LOOP when the internal table has as few as
10 lines. However, it is not possible to reassign the field symbol to another field or unassign it
altogether within the loop. If you include the statements ASSIGN, UNASSIGN, or the
ASSIGNING addition for the same field symbol within the loop block, a runtime error occurs.
6DPSOH/223$7LWDE$66,*1,1*IV!
SAP AG 101
ABAP Workbench Delta Guide (3.1-4.6)
START-OF-SELECTION.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE ’<FS> is assigned!’.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
The example fills a sorted table ITAB with 4 lines. The second line is assigned to the field
symbol <FS> (which has the same type), and modified using it. The third line is assigned to
<FS> and then deleted. Consequently, the logical expression in the IF statement is untrue.
<FS> is used to display the table lines in the LOOP. Afterwards, it points to the third line of the
table.
625767$%/(
625767$%/(IRU,QWHUQDO7DEOHV
(IIHFW
Uses a stable sort, that is, the relative sequence of entries that have the same SORT key
remains unchanged.
*HQHUDO
• The number of sort fields is restricted to 250.
• The sort process is only stable if you use the STABLE addition. Otherwise, a predefined
sequence of fields used to sort a list is not usually retained.
• It does not make sense to use the SORT command for a SORTED TABLE. If the table type
is statically declared, the system returns a syntax error if you try to SORT the table. If the
table type is not statically declared (for example, because the table was passed to a FORM
SAP AG 102
ABAP Workbench Delta Guide (3.1-4.6)
routine as an INDEX TABLE in a parameter), and the system can interpret the SORT
statement as an empty operation, it ignores the statement. This is the case when the key
in the BY clause corresponds to the beginning of the table key. Otherwise, a runtime
error occurs.
• To delete all duplicate entries from a sorted internal table (for example, just after SORT),
you can use the DELETE ADJACENT DUPLICATES FROM itab statement.
• When using the addition AS TEXT, the sequence of entries after the sort does not
usually match the sequence resulting from a binary sort, i.e. if the addition AS TEXT is
not specified. The consequence of this is that after the SORT, you are not allowed to
access with the READ TABLE itab ... BINARY SEARCH statement.
If you still want to access data sorted appropriate to the locale with a binary search, you
can do this by including an additional component in the table where you can explicitly
store the data formatted using the CONVERT TEXT ... INTO SORTABLE CODE
statement. This is also recommended for performance reasons if you have to re-sort the
table several times according to locale-specific criteria.
• If there is not enough main memory space to sort the data, the system uses a sort
process which writes data to an external auxiliary file. You can define the directory where
this file is held with the SAP profile parameter DIR_SORTTMP. By default, the SAP data
directory (SAP profile parameter DIR_DATA) is used.
3HUIRUPDQFH
• The runtime required to sort an internal table increases with the number of entries and the
length of the sort key. Sorting an internal table with 100 entries with a 50 byte key
requires about 1300 msn (standardized microseconds). Using a 30-byte key, the runtime
is about 950 msn.
• If one of the specified sort criteria is itself an internal table, SORT may sometimes take
much longer.
• The runtime increases if you use a stable sort.
625767$%/(IRU([WUDFWV
(IIHFW
Uses a stable sort, that is, the relative order of entries that have the same SORT key is not
changed in the sort.
*HQHUDO
• The number of sort fields is restricted to 50.
• The sort process is only stable if you use the STABLE addition. Otherwise, a predefined
sequence of fields used to sort a list is not usually retained.
• Any field symbol after the BY that is not assigned is ignored. If a field symbol is assigned,
but does not point to the field group HEADER, a runtime error results.
• When you are working with logical databases, you can place fields that are undefined at
the GET event into an extract dataset using EXTRACT. When you sort the extract, these
fields are placed before the fields with defined contents. This occurs regardless of
whether the sort is ascending or descending.
• If you have to sort an extract dataset several times according to locale-specific rules (AS
TEXT), you are recommended to include an additional field in the sort key where you can
explicitly store the data formatted appropriate to the locale with the CONVERT TEXT ...
SAP AG 103
ABAP Workbench Delta Guide (3.1-4.6)
INTO SORTABLE CODE statement. If you perform a binary sort on this data, the original
data is also implicitly sorted according to the locale.
• If there is not enough main memory space to sort the data, the system uses a sort
process which writes data to an external auxiliary file. You can define the directory where
this file is held with the SAP profile parameter DIR_SORTTMP. By default, the SAP data
directory (SAP profile parameter DIR_DATA) is used.
3HUIRUPDQFH
• The runtime required to sort an extract dataset increases with the number of entries and
the length of the sort key.
• The runtime increases if you use a stable sort.
3URFHVVLQJ/DUJH'DWDVHWV(IILFLHQWO\
*HQHUDO,QIRUPDWLRQ
You can manage large datasets in ABAP either as internal tables or extract datasets. Internal
tables are dynamic sequential datasets whose rows all have the same structure and a key.
There are three types of internal tables:
Extracts are dynamic sequential datasets whose rows can be structured differently. Extracts
cannot be accessed with indexes or keys and are processed using loops.
In Release 4.5A the performance of several important operations has been greatly enhanced
using internal tables and extracts.
'HVFULSWLRQRI)XQFWLRQ
1HZ,QGH[0DQDJHPHQWLQ,QWHUQDO7DEOHV
Until now, the cost of manipulating indexes increased in linear relation to the number of
entries being inserted or deleted from standard and sorted tables. From Release 4.5A these
index manipulation costs will only increase in logarithmic relation to the number of entries,
mainly due to the fact that table indexes are now managed in tree form. This allows for more
efficient insertion and deletion in very large standard and sorted tables.
1HZ7DEOH7\SHV
SAP AG 104
ABAP Workbench Delta Guide (3.1-4.6)
If you want to read or change an internal table only by key, you can use the hashed table.
$FFHVVLQJ,QGLYLGXDO,QWHUQDO7DEOH(QWULHV:LWK
)LHOG6\PEROV
Until now, individual entries in internal tables could only be processed indirectly using
separate work areas. From Release 4.5A you can use field symbols to display internal table
entries. You can now both read internal table entries and write to them as well. This allows for
better performance when working with large and complex tables and makes processing
nested internal tables considerably easier.
To assign a table line to a field symbol, use the following statements:
LOOP AT itab ASSIGNING <fs>.
READ TABLE itab ASSIGNING <fs>.
1HZ6WRUDJH$UHDIRU([WUDFWV
Until now, extracts were stored in the paging area. In an effort to improve sorting and
sequential processing performance, extracts are now stored directly in the file system.
Extracts
1HZ([WHUQDO6RUW3URFHVVIRU,QWHUQDO7DEOHV
DQG([WUDFWV
The main memory cannot sort large datasets all at once. Until now large datasets were sorted
by the operating system’s corresponding platform-specific sort function. Now SAP’s own
platform-independent sort procedure is used. This reduces the costs of some sorting
operations considerably.
Extracts stored in the file system are always resorted physically. Internal tables are sorted
19
physically if they are longer than 2 lines or larger than 12MB. Physical sorting reduces the
costs of subsequent sequential processing.
For further information, see 625767$%/(IRULQWHUQDOWDEOHV and625767$%/(IRU
H[WUDFWV
)LHOG6\PEROV
SAP AG 105
ABAP Workbench Delta Guide (3.1-4.6)
2SHQ64/
,11(5-2,1DQG/()7287(5-2,1
You can now read entries from more than one logically-linked database table using a single
SELECT statement using the constructions INNER JOIN or LEFT OUTER JOIN in the FROM
clause. Until now, programmers have usually used nested SELECT loops to achieve this.
Replacing this method with joins will lead to considerable runtime improvements.
6XETXHULHV
You can now use subqueries in the WHERE condition of the SELECT, UPDATE, and DELETE
statements. This provides a more efficient solution for tasks that previously required more
than one SQL statement. For more information about subqueries, see the logical condition
section of the WHERE clause documentation.
+$9,1*&ODXVH
The new HAVING clause allows you to place conditions on a set of results produced by a
SELECT statement that uses aggregation and grouping.
SAP AG 106
ABAP Workbench Delta Guide (3.1-4.6)
,11(5-2,1DQG/()7287(5-2,1
6SHFLI\LQJ'DWDEDVH7DEOHV
The FROM clause determines the database tables from which the data specified in the
SELECT clause is read. You can specify either a single table or more than one table, linked
using inner or outer joins. The names of database tables may be specified statically or
dynamically, and you can use alias names. You can also use the FROM clause to bypass the
SAP buffer and restrict the number of lines to be read from the database.
Selection
Selection
Single
Single table
table
Several
Several tables
tables (Joins)
(Joins)
“Database table” can equally mean an ABAP Dictionary view. A view links two or more
database tables in the ABAP Dictionary, providing a static join that is available systemwide.
You can specify the name of a view wherever the name of a database table may occur in the
FROM clause.
The FROM clause has two parts - one for specifying database tables, and one for other
additions:
SELECT ... FROM <tables> <options> ...
In <tables>, you specify the names of database tables and define joins. <options> allows you
to specify further additions that control the database access.
SAP AG 107
ABAP Workbench Delta Guide (3.1-4.6)
6SHFLI\LQJ7ZRRU0RUH'DWDEDVH7DEOHVDVDQ
,QQHU-RLQ
In a relational database, you normally need to read data simultaneously from more than one
database table into an application program. You can read from more than one table in a
single SELECT statement, such that the data in the tables all has to meet the same
conditions, using the following join expression:
SELECT ...
...
FROM <tab> [INNER] JOIN <dbtab> [AS <alias>] ON <cond> <options>
...
where <dbtab> is a single database table and <tab> is either a table or another join
expression. The database tables can be specified statically or dynamically as described
above. You may also use aliases. You can enclose each join expression in parentheses. The
INNER addition is optional.
A join expression links each line of <tab> with the lines in <dbtab> that meet the condition
<cond>. This means that there is always one or more lines from the right-hand table that is
linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines
that meet the condition <cond>, the line from <tab> is QRW included in the selection.
6(/(&7
6(/(&7
)520'%7$%,11(5-2,1'%7$%21
)520'%7$%,11(5-2,1'%7$%21
,11(5-2,1'%7$%21
,11(5-2,1'%7$%21
,11(5-2,1'%7$%21
,11(5-2,1'%7$%21
'%7$%
'%7$%
'%7$%
'%7$%
'%7$%
'%7$% '%7$%
'%7$%
The syntax of the <cond> condition is like that of the WHERE clause, although individual
comparisons can only be linked using AND. Furthermore, each comparison must contain a
column from the right-hand table <dbtab>. It does not matter on which side of the comparison
it occurs. For the column names in the comparison, you can use the same names that occur
in the SELECT clause, to differentiate columns from different database tables that have the
same names.
The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON
clause, since both clauses are applied equally to the temporary table containing all of the
SAP AG 108
ABAP Workbench Delta Guide (3.1-4.6)
lines resulting from the join. However, each join must contain at least one comparison in the
condition <cond>.
6SHFLI\LQJ7ZRRU0RUH'DWDEDVH7DEOHVDVD
/HIW2XWHU-RLQ
In an inner join, a line from the left-hand database table or join is only included in the selection
if there is one or more lines in the right-hand database table that meet the ON condition
<cond>. The left outer join, on the other hand, reads lines from the left-hand database table or
join even if there is no corresponding line in the right-hand table.
SELECT ...
...
FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond> <options>
...
<tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The
OUTER addition is optional. The tables are linked in the same way as the inner join with the
one exception that all lines selected from <tab> are included in the final selection. If <dbtab>
does not contain any lines that meet the condition <cond>, the system includes a single line in
the selection whose columns from <dbtab> are filled with null values.
In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In
addition to the above restrictions:
• EQ or = is the only permitted relational operator.
• There must be at least one comparison between columns from <tab> and <dbtab>.
• The WHERE clause may not contain any comparisons with columns from <dbtab>. All
comparisons using columns from <dbtab> must appear in the condition <cond>.
6DPSOH,QQHU-RLQ
SAP AG 109
ABAP Workbench Delta Guide (3.1-4.6)
B~FLDATE = F~FLDATE )
WHERE P~CITYFROM = ’FRANKFURT’ AND
P~CITYTO = ’NEW YORK’ AND
F~SEATSMAX > F~SEATSOCC.
LOOP AT ITAB INTO WA.
AT NEW FLDATE.
WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.
ENDAT.
WRITE / WA-BOOKID.
ENDLOOP.
This example links the columns CARRID, CONNID, FLDATE, and BOOKID of the table SPFLI,
SFLIGHT, and SBOOK, and creates a list of booking numbers for all flights from Frankfurt to
New York that are not fully booked. An alias name is assigned to each table.
6DPSOH/HIW2XWHU-RLQ
/HIW2XWHU-RLQ
TYPES: BEGIN OF line_type,
carrid LIKE scarr-carrid,
carrname LIKE scarr-carrname,
connid LIKE spfli-connid,
END OF line_type,
itab_type TYPE SORTED TABLE OF line_type
WITH NON-UNIQUE KEY carrid.
DATA: wa TYPE line_type,
itab TYPE itab_type.
SELECT s~carrid s~carrname p~connid
FROM scarr AS s
LEFT OUTER JOIN spfli AS p
ON s~carrid = p~carrid
AND p~cityfrom = ’FRANKFURT’
INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-carrid, wa-carrname, wa-connid.
ENDLOOP.
The output might look like this:
SAP AG 110
ABAP Workbench Delta Guide (3.1-4.6)
The example links the columns CARRID, CARRNAME, and CONNID of the tables SCARR and
SPFLI using the condition in the left outer join that the airline must fly from Frankfurt. All
other airlines have a null value in the CONNID column in the selection.
If the left outer join is replaced with an inner join, the list looks like this:
Only lines that fulfill the ON condition are included in the selection.
6XETXHULHV
SAP AG 111
ABAP Workbench Delta Guide (3.1-4.6)
6FDODU6XETXHULHV
In a scalar subquery, the selection in the SELECT clause is restricted to one column or
aggregate expression. The expression <result> of the SELECT clause is:
... <line> [<agg>] <s>
You can only enter a single field in the SELECT clause.
6XETXHULHVLQ&RQGLWLRQV
A non-scalar subquery can only have a WHERE or HAVING clause in the [NOT] EXISTS
<subquery> condition.
This condition is true if the result set of the subquery contains at least one [no] line
6FDODU6XETXHULHVLQ&RQGLWLRQV
As well as in the above condition, you can also use scalar subqueries in further conditions.
&KHFNLQJD9DOXHRIWKH6XETXHU\
6FDODU6XETXHULHVLQ&RPSDULVRQV
The other conditions can all be comparisons whose operators are contained in the table for
comparisons with all types in the WHERE clause. There is a difference, depending on whether
the subquery selection contains one or more lines.
6LQJOH/LQH6XETXHU\
If the selection in the subquery only contains one line, use the following for the comparison:
SAP AG 112
ABAP Workbench Delta Guide (3.1-4.6)
0XOWLSOH/LQH6XETXHU\
If the selection from the subquery returns more than one line, you must write the comparison
as follows:
... <s> <operator> ALL|ANY|SOME <subquery> ...
If you use the ALL prefix, the condition is only true if the comparison is true for all lines in the
subquery. If you use the ANY or SOME prefix, the condition is only true if the comparison is
true for at least one line of the subquery. The equality operator (= or EQ) in conjunction with
ANY or SOME has the same effect as the IN operator for checking a value.
If the selection from the subquery contains several lines and you do not use the ALL, ANY, or
SOME expression, a runtime error occurs.
6DPSOH&RUUHODWHG1RQ6FDODU6XETXHU\
6DPSOH6FDODU6XETXHU\6LQJOH/LQH
SAP AG 113
ABAP Workbench Delta Guide (3.1-4.6)
6DPSOH6FDODU6XETXHU\0XOWLSOH/LQHV
AT LINE-SELECTION.
WINDOW STARTING AT 45 3 ENDING AT 85 13.
WRITE: ’Alternative Plane Types’,
’for’, WA-CARRID, WA-CONNID.
ULINE.
SELECT planetype seatsmax
FROM saplane AS plane
INTO (plane, seats)
WHERE seatsmax < wa-seatsmax AND
seatsmax >= ALL ( SELECT seatsocc
FROM sflight
WHERE carrid = wa-carrid AND
connid = wa-connid )
ORDER BY seatsmax.
WRITE: / plane, seats.
SAP AG 114
ABAP Workbench Delta Guide (3.1-4.6)
ENDSELECT.
The list output, after double-clicking a line, looks like this:
The detail list displays all aircraft types that have fewer seats than the currently-allocated
aircraft type, but enough to carry all of the passengers currently booked on the flight.
+$9,1*&ODXVH
6HOHFWLQJ*URXSVRI/LQHV
The HAVING clause uses conditions to restrict the number of groups selected.
SAP AG 115
ABAP Workbench Delta Guide (3.1-4.6)
Selection
Selection
Line
Line groups
groups
You can only use the HAVING clause in conjunction with the GROUP BY clause.
To select line groups, use:
SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
<agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
...
GROUP BY <s1> <s2> ....
HAVING <cond>.
The conditions <cond> that you can use in the HAVING clause are the same as those in the
SELECT clause, with the restrictions that you can only use columns from the SELECT clause,
and not all of the columns from the database tables in the FROM clause. If you use an invalid
column, a runtime error results.
On the other hand, you can enter aggregate expressions for DOO columns read from the
database table that do not appear in the GROUP BY clause. This means that you can use
aggregate expressions, even if they do not appear in the SELECT clause. You cannot use
aggregate expressions in the conditions in the WHERE clause.
As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents
of an internal table with line type C and length 72.
6DPSOH+$9,1*&ODXVH
SAP AG 116
ABAP Workbench Delta Guide (3.1-4.6)
This example selects groups of lines from database table SFLIGHT with the value ‘LH’ for
CARRID and identical values of CONNID. The groups are then restricted further by the
condition that the sum of the contents of the column SEATSOCC for a group must be greater
than 300.
In 5HOHDVH it will be possible to refer to a central type defined in the ABAP Dictionary
using the TYPE statement instead of the LIKE statement. Therefore you can replace the first
line by
DATA wa TYPE sflight.
6\VWHP([FHSWLRQV
2YHUYLHZ
In Release 4.0/4.5 of the R/3 System, you can catch several runtime errors in your ABAP
program.
1HFHVVDU\6WHSVLQ$%$3
In your program, include all statements that may trigger a runtime error in a code block that
begins with CATCH and ends with ENDCATCH.
SAP AG 117
ABAP Workbench Delta Guide (3.1-4.6)
&DWFKLQJ5XQWLPH(UURUV
5HPRWH/HDUQLQJ
5(3257VDSEFGBFDWFK
'$7$FKDU7<3(F9$/8(
$
SDFN7<3(S
SAP AG
In the processing block enclosed in the statements CATCH and ENDCATCH , you can catch
system exceptions (ABAP runtime errors). If the runtime error to be caught occurs in the
CATCH processing block, the system reacts as follows:
• Return value <rc> assigned to system exception <excpt> is imported into system field
SY-SUBRC.
• The program goes from the ABAP statement in which the error occurred directly to the
relevant ENDCATCH statement (irrespective of the number of control structure levels (IF,
DO, LOOP, SELECT, CATCH, ...) that need to be skipped).
• The content of the fields affected by an incorrect statement is not guaranteed after
ENDCATCH.
The return values <rc1> ... <rcn> must be numeric literals.
After ENDCATCH, you should read system field SY-SUBRC to determine if a runtime error
needed to be caught, and if yes, which one.
SAP AG 118
ABAP Workbench Delta Guide (3.1-4.6)
6\VWHP([FHSWLRQV
5HPRWH/HDUQLQJ
&$7&+6<67(0(;&(37,216
H[FSW! UF!
(1'&$7&+
EFGB]HURBGLYLGH
6LQJOH
FRQYWBWRBQXPEHU
UXQWLPHHUURU
DULWKPHWLFBHUURUV
(UURUFODVV FRQYHUVLRQBHUURUV
$OOFDWFKDEOHUXQWLPH
27+(56
HUURUV
SAP AG
Each runtime error has an error ID (for example, CONVT_NO_NUMBER: conversion error to a
target field of type I, F, or P). However, you cannot catch all runtime errors.
If you use an ABAP statement that might return a runtime error, see the online documentation
on this command for the IDs of all catchable runtime errros that might occur.
/LVWRI&DWFKDEOH5XQWLPH(UURUV
See the online documentation on the CATCH command for an alphabetical list of all catchable
runtime errors.
+RZWR6SHFLI\([FHSWLRQV
SAP AG 119
ABAP Workbench Delta Guide (3.1-4.6)
• 27+(56
If you specify OTHERS, all catchable runtime errors are caught.
If there is more than one expression of type <excpt> = <rc>, <rc> of the first
applicable expression is returned. This is of particular importance if you use a
combination of the above specifications or have specified different error classes that
all include the same runtime error.
%HKDYLRURI1HVWHG&$7&+(1'&$7&+6WUXFWXUHV
%HKDYLRURI1HVWHG&$7&+(1'&$7&+6WUXFWXUHV
5HPRWH/HDUQLQJ
&$7&+6<67(0(;&(37,216
FRPSXWHBLQWB]HURGLYLGH
DULWKPHWLFBHUURUV
&$7&+6<67(0(;&(37,216ILOHBDFFHVVBHUURUV
'27,0(6
&20387(L
(1''2 6HW
V\VXEUF
(1'&$7&+
(1'&$7&+
&RQWLQXH
SURFHVVLQJ
SAP AG
Any nesting depth is allowed. This means that CATCH... ENDCATCH can be called within
CATCH... ENDCATCH.
In the above example, the division by zero performed in the LQQHU CATCH ... ENDCATCH
block triggers exception ARITHMETIC_ERRORS which is handled only in the RXWHU CATCH
... ENDCATCH block. Initially, the runtime system searches the current block for the system
exception. If this search is not successful, the system searches the CATCH ... ENDCATCH
block at the next level.
In the above example, system exception arithmetic_errors occurs only in the outer
block. Therefore, the system continues processing after the relevant ENDCATCH of the outer
block.
SAP AG 120
ABAP Workbench Delta Guide (3.1-4.6)
You can set a ’Breakpoint at System exception’ in the debugger. If you do this, the
program stops as soon as a runtime error is caught. A warning triangle appears at the
relevant point.
CATCH ... ENDCATCH can be used wherever IF ... ENDIF can be used, for
example (this means, it may be used on an event-specific rather than a cross-event
basis).
Errors are only caught at the current call level. For example, PERFORM or CALL FUNCTION
statements within CATCH ... ENDCATCH are not tracked: The following example program
generates a runtime error despite CATCH ... ENDCATCH.
5HPRWH/HDUQLQJ
'$7$LQW7<3(L
&$7&+6<67(0(;&(37,216RWKHUV
3(5)250GLYLGH&+$1*,1*LQW
(1'&$7&+
,)V\VXEUF
(1',)
)250GLYLGH&+$1*,1*LQW7<3(L
LQW
(1')250
SAP AG
SAP AG 121
ABAP Workbench Delta Guide (3.1-4.6)
5HSRUWLQJ
After reviewing the following topics, you will be able to:
Describe the new features of QickViewer
Describe the new features of Query Painter
Create lists using the ALV Grid Control
SAP AG 122
ABAP Workbench Delta Guide (3.1-4.6)
4XLFN9LHZHU
*HQHUDO,QIRUPDWLRQ
The QuickViewer is a new tool developed for Release 4.6 that allows you to create DGKRF
reports, without the need for a special environment in the R/3 System. The lists you generate
are displayed using a standardized interface. You can use standard SAP functions, like ABC
analysis and EIS and export the lists to third-party software like Microsoft Word. The
QuickViewer is particularly suitable for beginners, since it requires no knowledge of the ABAP
language.
QuickViewer
4XLFN9LHZHU3ULQFLSOH
In principle, you name a data source for example a database table or a database view. You
can use the existing fields to structure the list. Two modes are available: basic mode and
layout mode. The generated list can be saved and then displayed again in the QuickViewer.
Selection criteria are also saved along with the list, and can be queried again at any time.
4XLFN9LHZHUSULQFLSOH
)LHOGVHTXHQFH
6RUWVHTXHQFH
6HOHFWLRQILHOGV
7DEOHMRLQ &RQWURO
)XQFWLRQDODUHD
/RJLFDOGDWDEDVH
SAP AG 1999
&UHDWLQJD4XLFN9LHZ6WHSE\6WHS
)LUVWVWHS6WDUWWKH4XLFN9LHZHU
1-1 Choose menu path: 6\VWHP→6HUYLFHV→4XLFN9LHZHUor start transaction SQVI.
1-2 Type '(02 and press the &UHDWH button
SAP AG 123
ABAP Workbench Delta Guide (3.1-4.6)
)LUVW6WHS
3OHDVHHQWHU\RXUQDPHDQG
VHOHFW&UHDWH
6$34XHU\ ([HFXWH
&KRRVHDWLWOHDQGUHPDUNV
1DPHDGDWDVRXUFH,WFDQEH 4XLFN9LHZVRIXVHU678'(17
DWDEOHDORJLFDOGDWDEDVHD
MRLQRUDIXQFWLRQDODUHDRIWKH
6$3TXHU\
&KRRVHOD\RXWPRGHWR
GHVLJDQWKH4XLFN9LHZJUDILFV
&KRRVHEDVLFPRGHWRH[SRUW
WKHVHOHFWHGILHOGVLQWKHUHSRUW
+HOSVXEMHFWV6HOHFWLRQILHOGV2XWSXWRSWLRQVLQ
OLVWGHU/LVWH:LGWKRIOLVW
SAP AG 1999
The initial screen displays branches to the relevant documentation (in the lower right screen
section). Each user creates their own user-specific QuickViews, which cannot be accessed by
other users (and therefore cannot be copied either). A QuickView is not assigned to a
development class and it is not linked to the Workbench Organizer, or in other words,
QuickViews are not transported to another R/3 system.
Creating QuickViews
6HFRQGVWHS&KRRVHGDWDVRXUFH
2-1 Choose WDEOH as the Data Source.
2-2 Choose 6)/,*+7 as the table name.
2-3 Choose %DVLVPRGH as the processing mode.
2-4 Press the (QWHU button
SAP AG 124
ABAP Workbench Delta Guide (3.1-4.6)
6HFRQGVWHS
4XLFN9LHZ '(02
7LWOH 7,7/(
&RPPHQWV &200(176
'DWDVRXUFH
7DEOH
'DWDIURPWDEOHGDWDEDVHYLHZ
7DEOHYLHZ 6)/,*+7
%DVLV /D\RXW
SAP AG 1999
When you specify a table as data source, you can structure the list with its fields.
When you specify a table join as the data source, you have to define the join before you
structure the list. You define the table join graphically (Drag and Drop). You have to specify
the links between the tables, and you can have the system propose a value. In the process,
the foreign key dependencies between the tables are evaluated. You determine the resulting
quantity by deciding on either Inner or Left Outer Join logic.
When you specify a logical database as data source, you can structure the list with fields of its
nodes.
When you specify a functional area of SAP query as data source, you have choose the most
flexible one. Functional areas are based for example upon logical databases. You can
structure the list with fields assigned to functional groups. So you can hide fields or you can
define help. The functional area must come from the standard query area. Functional areas
from the global query area may not be used when creating a QuickView.
7KLUGVWHS6WDUW%DVLVPRGH
The screen of the Basis mode is divided into four sections. The available fields are displayed
to the left in tree form. The tools for creating the QuickView are displayed in the upper right.
Further Information is displayed in the lower left portion of the window. Links to
documentation and any warnings that are output while formatting the list are displayed in the
lower right section of the window.
SAP AG 125
ABAP Workbench Delta Guide (3.1-4.6)
7KLUGVWHS
'DWD6RXUFH
4XLFN9LHZ
,QIRUPDWLRQ
+HOS7RSLFV
SAP AG 1999
Basis Mode
)RXUWKVWHS&KRRVHWKHOLVWDQGVHOHFWLRQILHOGV
4-1 Choose :/LVWIOGVHOHFW. in the tab strip
4-2 Now, select the fields you wanted to be displayed in the list in the right hand table
control (Available fields).
4-3 Press the single arrow button (Column left) to shift the selected fields to the right hand
table control (Fields in list).
4-4 Choose :6HOHFWLRQILHOGV. in the tab strip
4-5 Now, select the fields you wanted to be displayed on the selection screen in the right
hand table control (Possible selection fields).
4-6 Press the single arrow button (Column left) to shift the selected fields to the right hand
table control (Selection fields).
SAP AG 126
ABAP Workbench Delta Guide (3.1-4.6)
)RXUWKVWHS
4XLFN9LHZ '(02
7LWOH 7,7/(
&RPPHQWV &200(176
)LHOGVLQOLVW $YDLODEOHILHOGV
SAP AG 1999
)LIWKVWHS'LVSOD\WKHUHVXOWOLVW
5-1 Now press the ([HFXWH button and at first the selection screen appears.
5-2 Choose the selection criteria you want.
5-3 Press the ([HFXWH button.
5-6 The list is displayed.
2WKHU)XQFWLRQV
You can display the lists you have generated either in fullscreen format or as ALV lists. You
can, for example, sort the list, carry out an ABC analysis or export it to Microsoft Word or
Excel. You can save the list and then display it later by opening the QuickViewer initial screen
and using the *RWR menu. When you save the list, the system retains the interactive functions
and the selection criteria you have entered.
If you enter a functional area as the data source you can convert your QuickView to an SAP
Query. You can only use functional areas from the global work area, which means that
queries generated in this way must be assigned to a development class and can then be
transported.
Output Options
SAP AG 127
ABAP Workbench Delta Guide (3.1-4.6)
4XHU\3DLQWHU
*HQHUDO,QIRUPDWLRQ
The Query Painter is new for Release 4.6. It allows you to create SAP Query Lists and
QuickViews graphically, using Drag and Drop. In SAP Query you can decide whether you
want to create a list by editing a sequence of screens or by using the Query Painter. In the
QuickViewer you can use either the basis mode or the Query Painter.
6WUXFWXUHDQG8VH
7KH4XHU\3DLQWHU
63)/,
7LPHWDEOH 6XPPDWLRQILHOGV
$LUOLQH
6)/,*+7
)OLJKW
6%22. 6RUWILHOGV
%RRNLQJV
7RROER[
4XLFNYLHZHU/LVWGHVLJQ
7UDVK
8VHWKLVVFUHHQWRYLHZDQGGHVLJQ
WKHOLVWVWUXFWXUHEDVHGRQVDPSOH
GDWD
&OLFNRQSDUWRIWKHOLVWWRGLVSOD\WKH
FRUUHVSRQGLQJDWWULEXWHVRIWKHOLVW
+HOSVXEMHFWV6HOHFWLRQILHOGV2XWSXWRSWLRQVLQ
HOHPHQW
OLVW:LGWKRIOLVW
SAP AG 1999
The Query Painter screen is divided into four sections. The available fields are displayed to
the left in tree form. The list layout is displayed in the upper right. Information for the currently
active element is displayed in the lower left portion of the window. Links to documentation and
any warnings that are output while formatting the list are displayed in the lower right section of
the window. You can sort the list according to individual fields. You can define control level
processing for sorted fields, and output formats for lines or individual fields. You can produce
a total for each control level and count the fields in a control level.
Toolbars
SAP AG 128
ABAP Workbench Delta Guide (3.1-4.6)
/LVW
To edit /LVW properties, such as the headers and footers or width, select a field and choose
/LVWRSWLRQV in the alternate mouse button menu. You then edit the list in the bottom left
window. You must confirm any changes you make by choosing $SSO\.
/LVW/LQH
To edit /LVWOLQH properties, such as color or separators, select a field and choose /LVWOLQH
RSWLRQV in the alternate mouse button menu. You then edit the list line options in the bottom
left window. You must confirm any changes you make by choosing $SSO\.
)LHOG
To edit the properties of a )LHOG in the bottom left window, by selecting a field. You can also
edit other field properties by choosing them from the alternate mouse button menu.
&RQWURO/HYHO
You generate a control level list by sorting your existing list by fields. You select these fields in
the list and dragging them to the 6RUWILHOGV toolbar.
<RXFDQRQO\XVHWKH4XHU\3DLQWHUWRHGLWEDVLFOLVWVQRWVWDWLVWLFDORUUDQNHG
OLVWV
<RXFDQPDLQWDLQORFDOILHOGVLQDTXHU\RQWKH6HOHFWILHOGVFUHHQ
4XHU\3DLQWHU)$4V
4: How can an object be selected and what do the different cursors mean?
$: Select an object: position the cursor on an object and push the left mouse button. The
selected object appears within a (blue) frame.
The 4-arrow cursor: you can move the object.
The 2-arrow cursor: you can resize the object.
4: How can a list with multiple lines be created?
$: First, click on the list field in the correct order and build up the first list line. Then, in
the 7RROER[ select the ,QVHUWOLQH icon and move it on the list. A new line is created beneath
the cursor position. Then build up the next list line by clicking on the fields.
4: How can the order of two list fields be changed?
$: Select the field (select it in the list, not in the header) and move the field to its new
position by holding down the left mouse button.
4: How can an empty list line be deleted?
$: Choose the WUDVKFDQ and move it to the line. The line is deleted.
4: How can the list be sorted and how can the sort ordering be changed?
$: Select the sort field and drag it to the 6RUWILHOG box. If there is already any other field,
the new field will be inserted on the top. If this order should be changed, select the field LQ the
6RUWILHOGbox and move it to the right position.
4: How can fields be added to the selection screen?
$: The functional area defines the selection screen. To add further selection fields,
SAP AG 129
ABAP Workbench Delta Guide (3.1-4.6)
select in the left upper area of the Query Painter the selection fields. This creates SELECT-
OPTIONS for each selected field. The selection fields has not to be displayed on the list.
Attention: by using the screens of transaction SQ01 to select selection fields (last
screen), and starting the Query Painter after that, these information will not be transported
into the Query Painter. If the graphical tool is used, the list and selections fields have to be
defined there. On the other hand, the definitions in the Query Painter are transported to the
screens of transaction SQ01.
4: Why are the selected functional groups and list fields not transported from transaction
SQ01 screens to the Query Painter?
$: Transaction SQ01 can only transport from Query Painter to the screens. However,
local fields and short names are transported from screens to Query Painter.
4: How can global list properties be changed?
$: Select one list field. Push the right mouse button and you get a Context menu.
Choose /LVWRSWLRQV. After that, in the left lower area of the Query Painter input fields appear.
The width of the list also can be changed by using the ruler: just drag it. The current size of
the ruler is identical to the list width.
Attention: the changes have to be updated by using the $SSO\ function.
4: How can list line properties be changed?
$: Select the list field. Push the right mouse button and you get a Context menu.
Choose /LQHRSWLRQV. After that, in the left lower area of the Query Painter input fields appear.
Attention: the changes have to be updated by using the $SSO\IXQFWLRQ
4: How can field properties be changed?
$: Select the list field. After that, in the left lower area of the Query Painter input fields
appear.
Attention: the changes have to be updated by using the $SSO\IXQFWLRQ
4: How can sort field properties be changed?
$: Select the field in the 6RUWER[. After that, in the left lower area of the Query Painter
input fields appear.
Attention: the changes have to be updated by using the $SSO\IXQFWLRQ
4: How can field headers be changed?
$: Double click on the header field and this field is input enabled. Write the new text.
$/9*ULG&RQWURO
*HQHUDO,QIRUPDWLRQ
The ABAP List Viewer (ALV) Grid Control is a newly developed tool for Release 4.6 that
standardizes the display of lists on screens. It also provides generic functions for lists, which
you can then enhance to suit your needs.
The ALV Grid Control uses controls technology. Controls are software components that are
installed on the local PC. Controls are administered by the central Control Framework. The
ALV Grid Control is wrapped by the global ABAP objects class CL_GUI_ALV_GRID. This
class contains both control-specific and Control Framework methods.
SAP AG 130
ABAP Workbench Delta Guide (3.1-4.6)
$/9([DPSOH
3URSHUWLHV
)LQG
)LOWHU
6RUW
$$ 86' $ 7RWDOVVXEWRWDOV
0DLO
$$ 86'
([FHO:RUG
/+ '(0 $
)LOH
/+ '(0 $
SAP AG 1999
SAP AG 131
ABAP Workbench Delta Guide (3.1-4.6)
6WDQGDUG3XVKEXWWRQV
'LVSOD\OLVWURZGHWDLOVLQDGLDORJER[
6RUWLQDVFHQGLQJRUGHUE\FROXPQVVHOHFWHG
6RUWLQGHVFHQGLQJRUGHUE\FROXPQVVHOHFWHG
)LQGLWHPVLQWKHOLVW
6HWILOWHUGHWHUPLQHGDWDWREHGLVSOD\HGEDVHGRQDFRQGLWLRQURZVHOHFWLRQ
&DOFXODWHWRWDOVIRUVHOHFWHGFROXPQV
6XEWRWDOV
3ULQWSULQWSUHYLHZ
7UDQVIHUGDWD!VSUHDGVKHHWZRUGSURFHVVLQJORFDOILOHVHQG
'LVSOD\YDULDQWVFXVWRPL]HFROXPQVHOHFWLRQVHOHFWFKDQJHVDYHYDULDQWV
DQGVRRQ
SAP AG 1999
You can drag column edges to make the columns wider or narrower or use the 2SWLPL]H
ZLGWK function to fit the column width to the data it contains. You can change the order in
which columns appear by selecting a column and dragging it to a new position. When the
system downloads or prints a list, it does so for the whole list, not just the part displayed on
screen.
7HFKQLFDO9LHZ
The CL_GUI_ALV_GRID class encapsulates the technical details of communication with the
frontend control of the ALV Grid Control. The proxy object (or wrapper object) communicates
with three partners:
• The frontend grid control, responsible for displaying list data as a table
• The ABAP program, and thus the user
• The printer and spool system, responsible for outputting the list data as an ABAP print
list.
Communication between the ABAP program, proxy object, and the ALV Grid Control is
interactive at runtime. The spool system is used to output the associated ABAP print lists. The
ALV proxy object itself administers only the minimum of information on the data (using
pointers). This data (in the form of internal tables), along with the rules governing how it is
displayed (the field catalog and additional information), must be included in the program in the
form of (global) data objects.
SAP AG 132
ABAP Workbench Delta Guide (3.1-4.6)
7HFKQLFDO9LHZ
$/9*ULG&RQWURO 3ULQWHUVSRRO
)URQWHQG
$SSOLFDWLRQVHUYHU
$/9SUR[\REMHFW
$/9SUR[\REMHFW
$%$3SURJUDP
$GGLWLRQDO
/LVWGDWD )LHOGFDWDORJ
LQIR
SAP AG 1999
6DPSOH,PSOHPHQWLQJWKH$/9*ULG&RQWUROLQD
3URJUDP
6LPSOH([DPSOH
This example shows how data from the SFLIGHT table can be displayed using an ALV grid
control. An internal table (defined according to the SFLIGHT structure) must be filled with data
records by the program. When the method SET_TABLE_FOR_FIRST_DISPLAY is called, the
structure name SFLIGHT is copied automatically, so that the program obtains the description
of the table’s fields, which the ALV grid control needs to display the data.
&UHDWHDQ([HFXWDEOH3URJUDPZLWKD723,QFOXGH
For example: ZALVDEMO_1 (Type: H[HFXWDEOHSURJUDP
TOP-Include ZALVDEMO_1TOP
&UHDWHWKH&RQWDLQHU6FUHHQRIWKH$/9*ULG&RQWURO
Create a screen for this program (screen number 100; type: normal; next screen: screen
number 100 (that is, itself)). Ensure that a GUI status has been set for the PBO event.
Implement the OK-code processing for BACK, EXIT, and CANCEL for the PAI event.
In the Screen Painter layout, create a custom control and name it (for example,
MY_CONTROL_AREA).
SAP AG 133
ABAP Workbench Delta Guide (3.1-4.6)
,PSOHPHQWLQJWKH&RQWURO6FUHHQ
&UHDWHLQ6FUHHQ3DLQWHU
6FUHHQ
&UHDWHLQ0HQX3DLQWHU
6WDWXV
&UHDWHLQ6FUHHQ3DLQWHU
0<B&21752/B$5($
& OD\RXW
,QWKHIORZORJLFRIVFUHHQ
3%2'HILQHVWDWXV
3$,2.B&2'(SURFHVVLQJIRU%$&.(;,7DQG&$1&(/
SAP AG 1999
,QFOXGH'DWDLQWKH723,QFOXGH
Declare the reference variables for the custom container and ALV grid control using the 7<3(
5()72&ODVVQDPH! statement. The global classes you need to do this are
&/B*8,B&86720B&217$,1(5 and &/B*8,B$/9B*5,'. These global classes are
defined in the Class Builder.
*&-------------------------------------------------------------------
--*
*& INCLUDE ZALVDEMO_1TOP
*
*&
*
*&-------------------------------------------------------------------
--*
PROGRAM zalvdemo_1 .
TABLES sflight.
* OK code handling
DATA: ok_code LIKE sy-ucomm,
save_ok_code LIKE sy-ucomm.
SAP AG 134
ABAP Workbench Delta Guide (3.1-4.6)
*************************************************************
* CONTROLS *
*************************************************************
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
alv_grid TYPE REF TO cl_gui_alv_grid.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK connection WITH FRAME.
SELECT-OPTIONS: so_car FOR sflight-carrid.
SELECT-OPTIONS: so_con FOR sflight-connid.
SELECTION-SCREEN END OF BLOCK connection.
&UHDWHWKH2EMHFWV
Create a PBO module (for example, CREATE_OBJECTS). Implement the following
statements:
*HQHUDWLQJDQG/LQNLQJ2EMHFWV
02'8/(FUHDWHBREMHFWV287387
,)JBFXVWRPBFRQWDLQHU,6,1,7,$/
&5($7(2%-(&7
&5($7(2%-(&7
&5($7(2%-(&7JBFXVWRPBFRQWDLQHU
(;3257,1*FRQWDLQHUBQDPH
0<B&21752/B$5($
&5($7(2%-(&7
&5($7(2%-(&7
&5($7(2%-(&7DOYBJULG &
(;3257,1*LBSDUHQW JBFXVWRPBFRQWDLQHU
(1',)
(1'02'8/(&5($7(B2%-(&76287387
SAP AG 1999
Use ABAP statement &5($7(2%-(&7QDPH! to create the objects for the container and
the ALV control. Objects are instances of classes. When an object is created (&5($7(),
method CONSTRUCTOR of the corresponding class is executed. The parameters of method
CONSTRUCTOR determine which parameters have to be supplied with data when the object
SAP AG 135
ABAP Workbench Delta Guide (3.1-4.6)
is created. In the above example, object alv_grid is given the name of the container control
(g_custom_container) in exporting parameter i_parent, which links the two controls. For
information on which parameters method CONSTRUCTOR possesses and which of these
parameters are required, please refer to the Class Builder.
The object should be created once only during the program. This can be ensured by
enclosing it in an ,)REMHFWBQDPH!,6,1,7,$/(1',) clause.
7HFKQLFDO%DFNJURXQG
&UHDWLQJ/LVW'DWDDQG+ROGLQJ'DWD
$/9*ULG&RQWURO 3ULQWHUVSRRO
$/9SUR[\REMHFW
DSRLQWHUWRWKHGDWDREMHFW
$%$3SURJUDP
REMHFWLQWKHSURJUDPRUDFODVV
DWWULEXWH
,QWHUQDOWDEOH
LVDSSOLHGWRWKHSURJUDPGDWD
IXQFWLRQVRIWKH$/9*ULG&RQWURO
/LVWGDWD
SAP AG 1999
To display the data in the ALV grid control (or print the data using the control), you must pass
the data in an internal table to the proxy object. The proxy object does QRW have a copy of the
data, but maintains a UHIHUHQFH to the internal table passed. To improve performance, the
proxy object performs all interactive actions in the frontend control (sort, filter, and so on) on
the internal table in the calling program. For this reason, the internal table that contains the list
data must be declared as global in the program (or as a static variable in a class). Sort
processes in the ALV grid control change the state of the internal table in the calling program;
all other actions perform only read access to the data.
)LOOWKH,QWHUQDO7DEOHZLWK'DWD
The system stores the data that is to be displayed in the ALV grid control in an internal table.
*&-------------------------------------------------------------------
--*
*& Event START-OF-SELECTION
*&-------------------------------------------------------------------
--*
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE itab_sflight
WHERE carrid IN so_car
SAP AG 136
ABAP Workbench Delta Guide (3.1-4.6)
'LVSOD\WKH'DWDLQWKH$/9*ULG&RQWURO
Create a PBO module (for example, TRANSFER_DATA) and implement the following
statements:
'LVSOD\LQJWKH'DWDLQWKH&RQWURO
3URFHVV%HIRUH2XWSXW
02'8/(VWDWXVB
02'8/(FUHDWHBREMHFWV
02'8/(WUDQVIHUBGDWD
02'8/(WUDQVIHUBGDWD287387
&$//0(7+2'
&$//0(7+2'
&$//0(7+2'DOYBJULG!VHWBWDEOHBIRUBILUVWBGLVSOD\
(;3257,1*LBVWUXFWXUHBQDPH
6)/,*+7
&+$1*,1*LWBRXWWDE LWDEBVIOLJKW
(1'02'8/(75$16)(5B'$7$287387
6(7B7$%/(B)25B),567B',63/$<LVDPHWKRGRIFODVV
&/B*8,B$/9B*5,'
SAP AG 1999
After the export parameter, LBVWUXFWXUHBQDPH, supply the name of the dictionary structure
that contains the field description (SFLIGHT in the above example). After the changing
parameter, LWBRXWWDE, supply the name of the internal table that contains the data you want
to display.
)ORZ/RJLFIRU6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE create_objects.
MODULE transfer_data.
6DYHDQG([HFXWH
Save the program and run a syntax check. Provided the program is syntactically correct, you
can now execute it.
SAP AG 137
ABAP Workbench Delta Guide (3.1-4.6)
)LUVW6WHSV
)XUWKHU7HFKQLTXHV
6WUXFWXUHRIWKH$/9*ULG&RQWURO
7RROEDU
7RROEDU
()XQFWLRQVFDQEHKLGGHQ
(3XVKEXWWRQVDQGPHQX
/LVWKHDGHU RSWLRQVFDQEHDGGHG
()XQFWLRQVDUHWULJJHUHG
DVHYHQWV
/LVWKHDGHU
(2SWLRQDO
'DWDGLVSOD\DUHD (6LQJOHOLQH
JULG
'DWDDUHD
()XUWKHUVWUXFWXUHG
SAP AG 1999
7KH0HWKRG6(7B7$%/(B)25B),567B',63/$<
SAP AG 138
ABAP Workbench Delta Guide (3.1-4.6)
&$//0(7+2'DOYBJULG!VHWBWDEOHBIRUBILUVWBGLVSOD\
(;3257,1*
LBVWUXFWXUHBQDPH 1DPHRIVWUXFWXUHWDEOHRUYLHZ
LVBYDULDQW 'LVSOD\YDULDQWV
LBVDYH 6DYHGLVSOD\YDULDQW
LBGHIDXOW 6HOHFWLQLWLDOOD\RXW
LVBOD\RXW &KDQJHWKHWHFKQLFDOFRQILJXUDWLRQ
LVBSULQW 3DUDPHWHUVIRUSULQWLQJRQEDFNHQG
LWBVSHFLDOBJURXSV *URXSLQJV
LWBWRROEDUBH[FOXGLQJ +LGHVWDQGDUGIXQFWLRQV
&+$1*,1*
LWBRXWWDE 2XWSXWWDEOH
LWBILHOGFDWDORJ )LHOGFDWDORJ
LWBVRUW 6RUWFULWHULDIRUILUVWOLVWRXWSXW
LWBILOWHU )LOWHUFULWHULDIRUILUVWOLVWRXWSXW
SAP AG 1999
7KH)LHOG'HVFULSWLRQ7KH3DUDPHWHU
,7B),(/'&$7$/2*
A description of each column in the ALV grid control - for example, the field type and output
length - must be included.
This description is stored in an internal table, called the ILHOGFDWDORJ. The field catalog must
contain a line for each column in the control.
SAP AG 139
ABAP Workbench Delta Guide (3.1-4.6)
$/9*ULG&RQWUROSULQWOLVW
3U
RS
QW HU
QWH WLH
V
&R
,QWHUQDOWDEOHLWDEZLWKGDWD )LHOGFDWDORJFROXPQSURSHUWLHV
SAP AG 1999
There are three ways to pass the field description to the ALV grid control: automatically,
manually and semi automatically.
$XWRPDWLFDOO\
This is the most simple method. The name of a structure must be passed when the method is
called. The relevant information is then read from the dictionary.
SAP AG 140
ABAP Workbench Delta Guide (3.1-4.6)
$XWRPDWLFDOO\*HQHUDWHG)LHOG&DWDORJ
,QWHUQDOWDEOH LWBGDWDZLWK
OLVWGDWD
$%$3
$$ 86'
'LFWLRQDU\
$= ,7/
&$//0(7+2'P\BDOY!VHWBWDEOHBIRUBILUVWBGLVSOD\
(;3257,1*
LBVWUXFWXUHBQDPH
LBVWUXFWXUH
LBVWUXFWXUHBBQDPH
QDPH
6)/,*+7
&+$1*,1*
LWBRXWWDE
LWB
LWBRXWWDE LWBGDWD
RXWWDE LWB
LWBGDWD
SAP AG 1999
0DQXDOO\
You fill in the field catalog yourself in the program. It is then passed when the method is
called.
SAP AG 141
ABAP Workbench Delta Guide (3.1-4.6)
0DQXDOO\*HQHUDWHG)LHOG&DWDORJ
'$7$LWBIFDW7<3(OYFBWBIFDW
,QWHUQDOWDEOHLWBGDWDZLWK *HQHUDWHILHOGFDWDORJLWBIFDW
OLVWGDWD PDQXDOO\
ILHOGQDPH UHIBILHOG
D E F
D E F D
D E F
E
D E F
F
&$//0(7+2'P\BDOY!VHWBWDEOHBIRUBILUVWBGLVSOD\
(;3257,1*
LBVWUXFWXUHBQDPH
&+$1*,1*
LWBRXWWDE
LWB
LWBRXWWDE LWBGDWD
RXWWDE LWB
LWBGDWD
LWBILHOGFDWDORJ
LWB
LWBILHOGFDWDORJ LWBIFDW
ILHOGFDWDORJ LWB
LWBIFDW
SAP AG 1999
6HPL$XWRPDWLFDOO\
If you pass a dictionary structure or field catalog using the interface when the method
SET_TABLE_FOR_FIRST_DISPLAY is called, then this information is merged automatically.
The function module LVC_FIELDCATALOG_MERGE, which is called in the method, merges
the information.
You may want to generate the field catalog semi-automatically if, for example, you want to
add program-specific fields (see slide) or if you do not want to display all the fields in a
structure.
SAP AG 142
ABAP Workbench Delta Guide (3.1-4.6)
6HPL$XWRPDWLFDOO\*HQHUDWHG)LHOG&DWDORJ
,QWHUQDOWDEOH LWBGDWDZLWK
OLVWGDWD
)LHOGFDWDORJ
D E F VWUXF LWBIFDW
D E F
D E F
&$//0(7+2'P\BDOY!VHWBWDEOHBIRUBILUVWBGLVSOD\
(;3257,1*
LBVWUXFWXUHBQDPH
6758&785(!
&+$1*,1*
LWBRXWWDE
LWB
LWBRXWWDE LWBGDWD
RXWWDE LWB
LWBGDWD
LWBILHOGFDWDORJ
LWB
LWBILHOGFDWDORJ LWBIFDW
ILHOGFDWDORJ LWB
LWBIFDW
[WHQGILHOGFDWDORJ
)XQFWLRQPRGXOH LWBIFDW
/9&B),(/'&$7$/2*B0(5*(
SAP AG 1999
6DPSOH6HPL$XWRPDWLFDOO\*HQHUDWHG)LHOG
&DWDORJ
Semi-automatically generated structure: the ALV grid control includes the program-specific
field, "free seats", which is shown as a "traffic-light" icon. The functions BACK, CANCEL and
EXIT are displayed in the GUI status S100.
PROGRAM zalvd_merge_icon .
INCLUDE <icon>.
SAP AG 143
ABAP Workbench Delta Guide (3.1-4.6)
* OK code handling
DATA: ok_code LIKE sy-ucomm,
save_ok_code LIKE sy-ucomm.
* Field position
DATA: pos_free TYPE i VALUE 10,
pos_icon TYPE i VALUE 11.
* Fieldcatalog
DATA: gt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF gt_fieldcat.
* CONTROLS
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
alv_grid TYPE REF TO cl_gui_alv_grid.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK connection WITH FRAME.
SELECT-OPTIONS: so_car FOR wa_outtab-carrid.
SELECTION-SCREEN END OF BLOCK connection.
*&-------------------------------------------------------------------
--*
*& Event START-OF-SELECTION
*&-------------------------------------------------------------------
--*
START-OF-SELECTION.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF wa_outtab
SAP AG 144
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module EXIT INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE exit INPUT.
LEAVE PROGRAM.
ENDMODULE. " EXIT INPUT
*&-------------------------------------------------------------------
--*
*& Module USER_COMMAND_0100 INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
SAP AG 145
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module CREATE_OBJECTS OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE create_objects OUTPUT.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = ’MY_CONTROL_AREA’.
SAP AG 146
ABAP Workbench Delta Guide (3.1-4.6)
CLEAR wa_fieldcat.
* Name and types
wa_fieldcat-fieldname = ’FREE_SEATS’.
wa_fieldcat-ref_table = ’SFLIGHT’.
wa_fieldcat-ref_field = ’SEATSMAX’.
* Texts and position
wa_fieldcat-coltext = text-001.
wa_fieldcat-seltext = text-001.
wa_fieldcat-col_pos = pos_free.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
* Name and types
wa_fieldcat-fieldname = ’ICON_NAME’.
wa_fieldcat-icon = ’X’. " Displayed as Icon
* Texts and position
wa_fieldcat-coltext = text-001.
wa_fieldcat-seltext = text-001.
wa_fieldcat-col_pos = pos_icon.
APPEND wa_fieldcat TO gt_fieldcat.
SAP AG 147
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 148
ABAP Workbench Delta Guide (3.1-4.6)
6DYHWKH'LVSOD\9DULDQWV3DUDPHWHUV
,6B9$5,$17DQG,B6$9(
Users can adapt the ALV grid control on the screen to their own needs – for example by
moving, hiding or resizing columns. They also need to be able to save display variants, so
that they can display this adapted version of the list the next time they log on. To make this
possible, the IS_VARIANT structure and the I_SAVE parameter must be passed using the
interface when the method is called. The parameter I_SAVE can accept the following four
values:
,B6$9( 63$&(No variants can be saved.
,B6$9(
8
The user can only save user-specific variants.
,B6$9(
;
The user can only save general (shared) variants.
,B6$9(
$
The user can save both user-specific and general (shared) variants.
Display Variants
6DPSOH9LHZLQJ'LVSOD\9DULDQWV
PROGRAM zalvd_layout_save .
* OK code handling
DATA: ok_code LIKE sy-ucomm,
save_ok_code LIKE sy-ucomm.
SAP AG 149
ABAP Workbench Delta Guide (3.1-4.6)
* Field position
DATA: pos_free TYPE i VALUE 10,
pos_icon TYPE i VALUE 11.
* Fieldcatalog
DATA: gt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF gt_fieldcat.
* Save variants
data: gs_variant type disvariant,
x_save.
* CONTROLS
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
alv_grid TYPE REF TO cl_gui_alv_grid.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK connection WITH FRAME.
SELECT-OPTIONS: so_car FOR wa_outtab-carrid.
SELECTION-SCREEN END OF BLOCK connection.
INCLUDE <icon>.
*&-------------------------------------------------------------------
--*
*& Event START-OF-SELECTION
*&-------------------------------------------------------------------
--*
START-OF-SELECTION.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF wa_outtab
WHERE carrid IN so_car.
wa_outtab-free_seats = wa_outtab-seatsmax - wa_outtab-seatsocc.
IF wa_outtab-free_seats GT 0.
wa_outtab-icon_name = icon_green_light.
ELSE.
wa_outtab-icon_name = icon_red_light.
ENDIF.
SAP AG 150
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module EXIT INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE exit INPUT.
LEAVE PROGRAM.
ENDMODULE. " EXIT INPUT
*&-------------------------------------------------------------------
--*
*& Module USER_COMMAND_0100 INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE user_command_0100 INPUT.
MOVE ok_code TO save_ok_code.
CLEAR ok_code.
CASE save_ok_code.
WHEN ’BACK’.
CALL METHOD g_custom_container->free.
LEAVE TO SCREEN 0.
SAP AG 151
ABAP Workbench Delta Guide (3.1-4.6)
WHEN ’EXIT’.
CALL METHOD g_custom_container->free.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&-------------------------------------------------------------------
--*
*& Module CREATE_OBJECTS OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE create_objects OUTPUT.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = ’MY_CONTROL_AREA’.
SAP AG 152
ABAP Workbench Delta Guide (3.1-4.6)
it_fieldcatalog = gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’SEATSOCC’.
wa_fieldcat-ref_table = ’SFLIGHT’.
wa_fieldcat-emphasize = ’C510’.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’FREE_SEATS’.
wa_fieldcat-ref_table = ’SFLIGHT’.
.
wa_fieldcat-coltext = ’Free seats’(001).
wa_fieldcat-seltext = ’Free seats’(001).
wa_fieldcat-col_pos = pos_free.
wa_fieldcat-no_out = ’X’. " Not displayed
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’ICON_NAME’.
wa_fieldcat-icon = ’X’. " Displayed as Icon
wa_fieldcat-col_pos = pos_icon.
wa_fieldcat-coltext = ’Free seats’(001).
wa_fieldcat-seltext = ’Free seats’(001).
APPEND wa_fieldcat TO gt_fieldcat.
SAP AG 153
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module VARIANT OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE variant OUTPUT.
*********************************************************************
***
)ORZORJLFVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE create_objects.
MODULE field_catalog.
MODULE variant.
MODULE transfer_data.
SAP AG 154
ABAP Workbench Delta Guide (3.1-4.6)
5HVXOWLQJ$/9/LVW
0DQLSXODWLQJWKH/D\RXW7KH3DUDPHWHU
,6B/$<287
6DPSOH([WHQGLQJWKH=$/9'B/$<287B6$9(
3URJUDP
* Layout
DATA: gs_layout TYPE lvc_s_layo.
*&-------------------------------------------------------------------
--*
SAP AG 155
ABAP Workbench Delta Guide (3.1-4.6)
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fieldcat.
*&-------------------------------------------------------------------
--*
*& Module LAYOUT OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE layout OUTPUT.
*********************************************************************
***
)ORZORJLFVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
SAP AG 156
ABAP Workbench Delta Guide (3.1-4.6)
MODULE create_objects.
MODULE field_catalog.
MODULE layout.
MODULE variant.
MODULE transfer_data.
PROCESS AFTER INPUT.
MODULE exit AT EXIT-COMMAND.
MODULE user_command_0100.
5HVXOWLQJ$/9/LVW
(YHQW+DQGOLQJ
(YHQWV are defined in global class FOBJXLBDOYBJULG; you can use these events to implement
user interaction within the program. To respond to a double-click on a table line, you must
respond to event DOUBLE_CLICK.
SAP AG 157
ABAP Workbench Delta Guide (3.1-4.6)
You receive control in the program, allowing you to implement interactive reporting. The
events for FOBJXLBDOYBJULG are located in the Class Builder.
$/9*ULG&RQWURO(YHQWV
YHQWVGXULQJSULQWOLVWFUHDWLRQ
RXVHRSHUDWLRQV
GRXEOHBFOLFN 'RXEOHFOLFNRQDFHOO
KRWVSRWBFOLFN &OLFNRQDFHOOKRWVSRW
8VHU
8VHUGHILQHGIXQFWLRQV
EHIRUHBXVHUBFRPPDQG %HIRUHH[HFXWLRQRIDVWDQGDUGIXQFWLRQ
XVHUBFRPPDQG 8VHUGHILQHGIXQFWLRQFRGHLVWULJJHUHG
DIWHUBXVHUBFRPPDQG $IWHUH[HFXWLRQRIDVWDQGDUGIXQFWLRQ
WRROEDU 7RROEDULVFKDQJHG
PHQXBEXWWRQ $PHQXRSWLRQLVFKDQJHG
'UDJ
'UDJ 'URS
&RQWH[WPHQXV
SAP AG 1999
SAP AG 158
ABAP Workbench Delta Guide (3.1-4.6)
%()25(B86(5B&200$1'DQG$)7(5B86(5B&200$1'
FRQWURO SURJUDP
8VHUWULJJHUV
VWDQGDUG
IXQFWLRQ
EHIRUHB
EHIRUHBXVHUB
XVHUBFRPPDQG
,PSOHPHQWDWLRQ
,PSOHPHQWDWLRQRI
VWDQGDUGIXQFWLRQ DIWHUB
DIWHUBXVHUB
XVHUBFRPPDQG
,PSOHPHQWDWLRQ
SAP AG 1999
(YHQW+DQGOLQJ7KH'28%/(B&/,&.([DPSOH
SAP AG 159
ABAP Workbench Delta Guide (3.1-4.6)
'RXEOH&OLFN
&/$66OFOBLOV'(),1,7,21
38%/,&6(&7,21
'HILQLWLRQRIDORFDOFODVV
0(7+2'6RQBGEOFOLFN)25(9(17GRXEOHBFOLFN
2)FOBJXLBDOYBJULG,03257,1*HBURZ
(1'&/$66
&/$66FODVVOFOBLOV,03/(0(17$7,21
0(7+2'RQBGEOFOLFN
,PSOHPHQWLQJDORFDO
FODVVZLWKKDQGOHU >RZQIXQFWLRQDOLW\@
PHWKRG
(1'0(7+2'
(1'&/$66
'$7$DOYBGEOFOLFN7<3(5()72OFOBLOV
*HQHUDWLQJWKHREMHFW &5($7(2%-(&7DOYBGEOFOLFN
6(7+$1'/(5DOYBGEOFOLFN!RQBGEOFOLFN
5HJLVWUDWLRQRI
)25DOYBJULG
KDQGOHUPHWKRG
IRUHYHQWGRXEOHBFOLFN
SAP AG 1999
To define an implement a local class in the program, you use a handler method. In this
handler method, you program the functionality to trigger by a double-click in the output table.
To activate a handler method at runtime, a class or an object from that class registers itself
with an event using command 6(7+$1'/(5. The names of the IMPORTING parameters in
the handler method correspond to the names of the EXPORTING parameters of the related
event.
In the above example, the local class is LCL_ILS and the handler method is ON_DBLCLICK.
An object - ALV_DBLCLICK - is created and registers itself for event DOUBLE_CLICK.
You can query parameter e_row-index to determine which output line was requested by the
double-click. This parameter corresponds to the line number of the output table (internal table
with the data records to output). If you need information for the selected line, you have to
read it with 5($'7$%/(LWDE,1'(;HBURZLQGH[.
This subsequent read in the output table generally corresponds to the HIDE area in
conventional reporting. You first have to make sure that the user has double-clicked a line in
the output table (similar to the valid line selection with the HIDE technique).
6DPSOH'RXEOH&OLFN
SAP AG 160
ABAP Workbench Delta Guide (3.1-4.6)
* Local class
CLASS lcl_ils DEFINITION.
PUBLIC SECTION.
METHODS on_dblclick FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
* Double Click
DATA: alv_dblclick TYPE REF TO lcl_ils.
* OK code handling
DATA: ok_code LIKE sy-ucomm,
save_ok_code LIKE sy-ucomm.
* Field position
DATA: pos_free TYPE i VALUE 10,
pos_icon TYPE i VALUE 11.
* Fieldcatalog
DATA: gt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF gt_fieldcat.
SAP AG 161
ABAP Workbench Delta Guide (3.1-4.6)
* Layout
DATA: gs_layout TYPE lvc_s_layo.
* CONTROLS
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
alv_grid TYPE REF TO cl_gui_alv_grid.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK connection WITH FRAME.
SELECT-OPTIONS: so_car FOR wa_outtab-carrid.
SELECTION-SCREEN END OF BLOCK connection.
INCLUDE <icon>.
*&-------------------------------------------------------------------
--*
*& Event START-OF-SELECTION
*&-------------------------------------------------------------------
--*
START-OF-SELECTION.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF wa_outtab
WHERE carrid IN so_car
ORDER BY PRIMARY KEY.
wa_outtab-free_seats = wa_outtab-seatsmax - wa_outtab-seatsocc.
IF wa_outtab-free_seats GT 0.
wa_outtab-icon_name = icon_green_light.
ELSE.
wa_outtab-icon_name = icon_red_light.
ENDIF.
APPEND wa_outtab TO gt_outtab.
ENDSELECT.
*--------------------------------------------------------------------
-*
* CLASS lcl_ils IMPLEMENTATION
*--------------------------------------------------------------------
-*
* ........
*
SAP AG 162
ABAP Workbench Delta Guide (3.1-4.6)
*--------------------------------------------------------------------
-*
CLASS lcl_ils IMPLEMENTATION.
METHOD on_dblclick.
* valid line check
IF e_row-rowtype = space AND NOT e_row-index IS INITIAL.
READ TABLE gt_outtab INDEX e_row-index INTO wa_outtab.
CALL SCREEN 101.
ELSE.
MESSAGE i031(bc405).
ENDIF.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
*& Event TOP-OF-PAGE
*&-------------------------------------------------------------------
--*
TOP-OF-PAGE.
FORMAT COLOR COL_HEADING.
WRITE: ’Detail List’(004).
ULINE.
*&-------------------------------------------------------------------
--*
*& Module STATUS_0100 OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE status_0100 OUTPUT.
SET PF-STATUS ’S100’.
SET TITLEBAR ’T100’.
ENDMODULE. " STATUS_0100 OUTPUT
SAP AG 163
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module EXIT INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE exit INPUT.
LEAVE PROGRAM.
ENDMODULE. " EXIT INPUT
*&-------------------------------------------------------------------
--*
*& Module USER_COMMAND_0100 INPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE user_command_0100 INPUT.
MOVE ok_code TO save_ok_code.
CLEAR ok_code.
CASE save_ok_code.
WHEN ’BACK’.
CALL METHOD g_custom_container->free.
LEAVE TO SCREEN 0.
WHEN ’EXIT’.
CALL METHOD g_custom_container->free.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&-------------------------------------------------------------------
--*
*& Module CREATE_OBJECTS OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE create_objects OUTPUT.
SAP AG 164
ABAP Workbench Delta Guide (3.1-4.6)
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = ’MY_CONTROL_AREA’.
* Double click
CREATE OBJECT alv_dblclick.
SET HANDLER alv_dblclick->on_dblclick FOR alv_grid.
ENDIF.
SAP AG 165
ABAP Workbench Delta Guide (3.1-4.6)
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’SEATSOCC’.
wa_fieldcat-ref_table = ’SFLIGHT’.
wa_fieldcat-emphasize = ’C510’.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’FREE_SEATS’.
wa_fieldcat-ref_table = ’SFLIGHT’.
.
wa_fieldcat-coltext = ’Free seats’(001).
wa_fieldcat-seltext = ’Free seats’(001).
wa_fieldcat-col_pos = pos_free.
wa_fieldcat-no_out = ’X’. " Not displayed
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ’ICON_NAME’.
wa_fieldcat-icon = ’X’. " Displayed as Icon
wa_fieldcat-col_pos = pos_icon.
wa_fieldcat-coltext = ’Free seats’(001).
wa_fieldcat-seltext = ’Free seats’(001).
APPEND wa_fieldcat TO gt_fieldcat.
*&-------------------------------------------------------------------
--*
*& Module LAYOUT OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE layout OUTPUT.
SAP AG 166
ABAP Workbench Delta Guide (3.1-4.6)
*&-------------------------------------------------------------------
--*
*& Module LIST OUTPUT
*&-------------------------------------------------------------------
--*
* text
*--------------------------------------------------------------------
--*
MODULE list OUTPUT.
* Detail List after double click
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
FORMAT COLOR COL_NORMAL.
SELECT * FROM sbook INTO CORRESPONDING FIELDS OF wa_sbook
WHERE carrid = wa_outtab-carrid
AND connid = wa_outtab-connid
AND fldate = wa_outtab-fldate.
WRITE: / sy-vline, wa_sbook-carrid,
wa_sbook-connid,
wa_sbook-fldate,
wa_sbook-customid,
wa_sbook-bookid, 83 sy-vline.
ENDSELECT.
ULINE.
ENDMODULE. " LIST OUTPUT
*********************************************************************
***********
)ORZORJLFVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE create_objects.
MODULE field_catalog.
MODULE layout.
MODULE transfer_data.
SAP AG 167
ABAP Workbench Delta Guide (3.1-4.6)
*********************************************************************
***********
)ORZORJLFVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE list.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0101.
'HPR3URJUDPV'HOLYHUHG
The following demo programs are included in the development class SLIS:
'HPR3URJUDPVGHOLYHUHG
%&$/9B*5,'B %DVLFDQGGHWDLOVOLVWVZLWKRQHLQVWDQFH
%&$/9B*5,'B 'HWDLOOLVWLQPRGDOGLDORJER[
%&$/9B*5,'B 6HOIGHILQHGSXVKEXWWRQVLQWKHWRROEDU
%&$/9B*5,'B &RQWH[WPHQXV
%&$/9B*5,'B 6HOIGHILQHGPHQXVLQWKHWRROEDU
%&$/9B*5,'B 7RROEDUPHQXZLWKVWDQGDUGSXVKEXWWRQ
%&$/9B*5,'B &RQWURORSWLRQVIRUGLVSOD\YDULDQWV
%&$/9B*5,'B ,QLWLDOXVHRIGLVSOD\YDULDQWV
SAP AG 1999
SAP AG 168
ABAP Workbench Delta Guide (3.1-4.6)
$%$32EMHFWV
After reviewing the following topics, you will be able to:
Explain the new features about methods
Explain the news about interfaces
Describe the concept of inheritance
Use the Class Builder
SAP AG 169
ABAP Workbench Delta Guide (3.1-4.6)
,QWURGXFWLRQ
see also
see also
see also
:KDWDUH2EMHFWV"
This section provides an introduction to the term at the center of object-oriented program -
objects.
SAP AG 170
ABAP Workbench Delta Guide (3.1-4.6)
:KDWDUH2EMHFWV"
5HPRWH/HDUQLQJ
(QFDSVXODWLRQ $EVWUDFWLRQ
Function
0HWKRG
'DWD 0HWKRG
Function Function Function
0HWKRG
Function Function Function Function
SAP AG
Information systems have traditionally been defined through their functions. Functions
and data were always kept apart, and linked using input/output relationships.
At the center of object-oriented methods are objects. Objects represent abstract or concrete
aspects of the real world. Their nature and properties are described by their structure and
their attributes (data), and their behavior is described in a set of methods (functions).
Objects provide a single shell encompassing both their nature and their behavior. Using
objects, you can establish a one-to-one relationship between a real-life problem and its
software solution.
Typical objects in a business environment are ’customer’, ’order’, and ’invoice’. The R/3
System has implemented objects of this type since Release 3.1 in the Business Object
Repository (BOR). It is intended to integrate the object model of the BOR into ABAP Objects.
SAP AG 171
ABAP Workbench Delta Guide (3.1-4.6)
2EMHFWV
5HPRWH/HDUQLQJ
,QWHUIDFH
2EMHFW Public
DWWULEXWHV
attributes
Flight
$LUOLQH
Address )OLJKWQXPEHU
3XEOLF
3ULYDWH Customer
DFFHVV
DFFHVV Passenger Methods
list
%22.
Events
SAP AG
SAP AG 172
ABAP Workbench Delta Guide (3.1-4.6)
$GYDQWDJHVRI2EMHFW2ULHQWHG3URJUDPPLQJ
2YHUYLHZ
(QFDSVXODWLRQ
SAP AG 173
ABAP Workbench Delta Guide (3.1-4.6)
(QFDSVXODWLRQ
5HPRWH/HDUQLQJ
0HWKRGERRNDQGRQO\
PHWKRGERRNKDVDFFHVV
WRWKHGDWD
2EMHFW)OLJKW
Attribute:
3URJUDP Method:
SDVVHQJHU
5HDGWDEOH SDVVHQJHU book
No access
3URJUDP
DGGWR SDVVHQJHU
SAP AG
Encapsulation is one of the main principles of object orientation. It serves to ensure that
data can only be accessed by methods that have been specifically designed for the task, and
not by other programs.
In conventional programming, the user of a processing block such as a subroutine or function
module was responsible for choosing the correct data types to ensure that the caller and the
called processing block were compatible.
)URP)XQFWLRQ*URXSVWR2EMHFWV
We are now going to make the transition from structured program to object-oriented
programming. We will use one simple example, through which the benefits of object-oriented
programming should become apparent.
Before Release 4.0, the ABAP components that most closely resembled objects were function
modules and function groups. For example, suppose we have a function group for order
processing. The attributes of an order correspond to the global data of the function group, and
the individual function modules perform various functions (methods) on the data. In this ways,
the internal workings of the order are encapsulated in the function group, and the actual order
data is never processed directly, but always through function modules. The function modules
can ensure that the data always remains consistent.
When a function module is called, an instance of its function group is loaded into the memory
area of the internal session. If a single ABAP program calls function modules from more than
one function group, it will load more than one instance.
The principal difference between ‘real’ object-orientation and function modules is that a
program can work with instances of several function groups simultaneously, but not with
SAP AG 174
ABAP Workbench Delta Guide (3.1-4.6)
several instances of a single function group. For example, a program may need to work with
several independent counter variables, or process several orders at once. For this to work,
the function group containing the respective function modules would have to be specially
programmed to keep the various instances apart.
)XQFWLRQ*URXSVDQGWKHLU*OREDO'DWD
5HPRWH/HDUQLQJ
)XQFWLRQJURXS
)XQFWLRQJURXS
… …
$%$3SURJUDPZLWKGDWD
,QWHUQDOVHVVLRQRIDQ$%$3SURJUDP
([WHUQDOVHVVLRQ
SAP AG
SAP AG 175
ABAP Workbench Delta Guide (3.1-4.6)
,QVWDQFHVDQGWKHLU'DWD
5HPRWH/HDUQLQJ
QWKLQVWDQFHFODVV
QWKLQVWDQFHFODVVQ
VWLQVWDQFHFODVV
VWLQVWDQFHFODVVQ
,QWHUIDFH
6FKQLWW
6FKQLWW
VWHOOH 'DWD
... ...
,QWHUIDFH
… ... ,QWHUIDFH
…
... 'DWD
… …
$%$3SURJUDPZLWKGDWD
,QWHUQDOVHVVLRQRIDQ$%$3SURJUDP
External session
SAP AG
Let’s write an example that shows the differences between a program written in
conventional ABAP and one written using ABAP Objects.
Before we start, however, there is a new term to learn - ‘instance’. Instance just means the
same thing as ‘object’.
The term ‘object’ is used in the R/3 System in several different contexts. For example, we talk
about Repository objects, or program objects, or business objects. To differentiate between
objects in sense of object orientation and other things also called objects, we are going to
refer to objects in the object-oriented sense as instances from now on. This avoids us having
to use the word ‘object’ to mean lots of different things, and should therefore make things
clearer.
So, now back to our example:
The program creates two stacks of integer values. First it places 5 integers on the first stack,
and then removes them from the first stack and places them on the second stack. Finally, the
contents of the second stack are displayed .
First the stack program using conventional ABAP programming.
6DPSOH&RPSDULVRQ%HWZHHQ&RQYHQWLRQDODQG
223URJUDPPLQJ
SAP AG 176
ABAP Workbench Delta Guide (3.1-4.6)
&RQYHQWLRQDO3URJUDPPLQJ
*& Push/Pop of a stack with conventional programming
*& methods *
*& (compare program SAPBC411D_OO_STACK where the same
*& functionality is coded using OO-programming code.
*& Here you work with an internal table and pass it to the
*& function module, so the function module works on external
*& data, and the user of the function module is responsible
*& to use the proper data. Data are not encapsulated inside
*& the function module.
*&-----------------------------------------------------------*
REPORT sapbc411d_load_stack_convent.
*Define elemtype and STACK1
START-OF-SELECTION.
SAP AG 177
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 178
ABAP Workbench Delta Guide (3.1-4.6)
must use a changing parameter. This has nothing to do with the real world problem - the real
world problem is only about a stack of integers. That this stack is internally represented as a
changing parameter or an internal table or whatever is not relevant for a user.
Now you might say, let’s get rid of the changing parameter and do all that handling inside the
function group. This is possible, but then the developer of the function group has to
differentiate between different stacks internally. In our example we work only with two stacks.
Of course the more different stacks you work with the more complicated the handling
becomes within the function group. The developer has to manage the different stacks and
make sure that in each call of the function module the right internal table is used for the
function modules PUSH_STACK and POP_STACK.
By the way: The coding inside the function modules is not shown here. You'll find it in the
implementation part of the ABAP Objects program (see below).
Now here is the same function written in ABAP Objects. We are not going to explain each
statement here (that’s what the rest of this unit is about), but we will look at the major
differences and benefits.
223URJUDPPLQJ
REPORT sapbc411d_oo_stack .
*-------------------------------------------------------------
* OO DEMO Program: Simple Stack for integer values
*
* Stack integers. Show push and pop.
*-------------------------------------------------------------
*---------------------------
CLASS c_stack DEFINITION.
PUBLIC SECTION.
METHODS:
Push IMPORTING elem TYPE elemtype, "-- push value on the
"-- stack
pop EXPORTING elem TYPE elemtype "-- pop value from the
"-- stack
EXCEPTIONS stack_empty,
PRIVATE SECTION.
DATA: stab TYPE elemtype OCCURS 20. "-- stack table
ENDCLASS.
*-------------------------------------------------------------
CLASS c_stack IMPLEMENTATION.
METHOD push.
*& append an integer value to the stack
SAP AG 179
ABAP Workbench Delta Guide (3.1-4.6)
METHOD pop.
*& get the last entry and delete it from the stack.
*& if the stack is empty raise exception stack_empty.
*-------------------------------------------------------------
START-OF-SELECTION.
SAP AG 180
ABAP Workbench Delta Guide (3.1-4.6)
EXIT.
ENDIF.
WRITE: / ’pop: ’, i1.
CALL METHOD s2->push EXPORTING elem = i1.
ENDDO.
see also
&ODVVHVDQG2EMHFWV
SAP AG 181
ABAP Workbench Delta Guide (3.1-4.6)
Here you will learn the difference between classes and objects.
Both terms are very important, and classes are right at the center of any object-oriented
language. The two terms are sometimes used interchangeably, and often, when you read
about ‘objects’, it is really ‘classes’ that are meant.
&ODVVHVDQG2EMHFWV
5HPRWH/HDUQLQJ
,QVWDQWLDWLRQ
3ODQH
1DPH $$+ROO\ZRRG
$$+ROO\ZRRG
3LORWV
&DSDFLW\ NJ
NJ
3DVVHQJHU
1DPH %%%URDGZD\
%%%URDGZD\
3LORWV
&DSDFLW\ NJ
NJ
3DVVHQJHU
SAP AG
Here is a simple example for a class plane and the derived objects AA Hollywood and
BB Broadway. A class is an DEVWUDFWGHVFULSWLRQof a real-world object. A class is defined by
data, called attributes, and methods that work on this data. The process by which we derive
objects from a class is called LQVWDQWLDWLRQ An object is an LQVWDQFH of a class, and exists in
main memory.
You will design classes differently depending on your requirements. For example, to book
flights you need to know the name of the plane. For an information system, you might need to
know the number of pilots, the capacity, and the number of passengers that can be booked.
However, this data would be irrelevant, and instead you would need to know the span width,
the fuel capacity, engine type, and so on. As well as the data, you need methods to work with
it. For example a method ‘book’ or a method ‘refuel’. To keep things simple at this stage, the
methods are not shown in the example above. Establishing your requirements and designing
the class accordingly is part of object-oriented analysis and design. This is the most important
and most extensive part of your project. Typically you will have a set of classes that are linked
together in a hierarchical order. Once you have designed the classes, the coding is relatively
simple, because it can be derived directly from the class model. Class modeling and OO
analysis and design in general are not part of this unit.
In all examples classes are represented by yellow rectangles, and objects by blue rectangles
with rounded corners.
SAP AG 182
ABAP Workbench Delta Guide (3.1-4.6)
:KDWLV$%$32EMHFWV"
For further information about ABAP Objects, refer to the online documentation:see here.
&ODVVHV
We are now going to start looking at how to write programs using ABAP Objects and at the
syntax that you will need to use.
Classes must be defined and implemented. To do so, you use the following syntax:
CLASS <class> DEFINITION.
PUBLIC SECTION.
... 'HILQLWLRQRISXEOLFFRPSRQHQWV
PROTECTED SECTION.
... 'HILQLWLRQRISURWHFWHGFRPSRQHQWV
PRIVATE SECTION.
... 'HILQLWLRQRISULYDWHFRPSRQHQWV
ENDCLASS.
CLASS <class> IMPLEMENTATION.
... 0HWKRGLPSOHPHQWDWLRQ
ENDCLASS.
Objects of the same type are all defined by a single class definition. The declaration part of
the class describes its inner structure (attributes), and the methods that you can use to work
with the object. The source code of methods is defined in the implementation part of the
class.
A few general statements about classes:
• Classes contain components.
• Each component of a class is assigned to a visibility section.
• Classes implement methods.
SAP AG 183
ABAP Workbench Delta Guide (3.1-4.6)
A class is made up of components (attributes and methods), all of which are declared in the
declaration part of the class definition. Each component is declared in one of three visibility
sections; this defines the interface of the class. All components of a class are visible within
the class itself. The three visibility sections are:
PUBLIC - all public components can be addressed by all users and in all methods. They form
the external interface of the class. Only those components can be addressed outside the
CLASS ... ENDCLASS statement.
PROTECTED - Protected components of a class can be addressed in the methods of its
subclass, and in the class itself (not yet implemented. Will be available from Release 4.6,
together with inheritance).
PRIVATE - Private components of a class can only be addressed in the methods of that
class.
&ODVVHV
5HPRWH/HDUQLQJ
&/$66F'(),1,7,21
38%/,&6(&7,21 &ODVVF
'$7$D«
0(7+2'6P«
Public Private
3527(&7('6(&7,21 components components
'$7$D«
0(7+2'6P« D D,
P P
35,9$7(6(&7,21
'$7$D«
0(7+2'6P« Method
implementation
(1'&/$66
&/$66F,03/(0(17$7,21 Protected components
DP«
0(7+2'P«(1'0(7+2'
0(7+2'P«(1'0(7+2'
Subclasses of c1
0(7+2'P«(1'0(7+2'
All users
(1'&/$66
SAP AG
The left-hand side of the illustration shows the declaration and implementation parts of a
local class C1. (How to implement global classes will be shown later). The right-hand side
shows the components of the class in their different visibility sections, and the implementation
of the methods.
The public components form the point of contact between the class and its external users.
Protected components are a point of contact between the class and its subclasses. Private
components are fully encapsulated in the class and are not visible externally. The methods in
the implementation part have unrestricted access to all of the components in the class.
see also
SAP AG 184
ABAP Workbench Delta Guide (3.1-4.6)
'HFODULQJ$WWULEXWHV
This section shows you how to declare attributes. There are two kinds of attributes - ‘instance
attributes’ and ‘static attributes’.
,QVWDQFH$WWULEXWHV
You define instance attributes will be defined using the normal ABAP statement DATA.
Here is the general statement:
DATA <attr> TYPE <type>
[ VALUE <val> ]
[ READ-ONLY ]. “ 5HOHDVH
And here is a simple example:
REPORT sapbc411d_flight.
6WDWLF$WWULEXWHV
SAP AG 185
ABAP Workbench Delta Guide (3.1-4.6)
[ READ-ONLY]. “ 5HOHDVH
So, you use DATA to declare instance attributes, and CLASS-DATA to declare static attributes.
Here is a simple example.
REPORT sapbc411d_flight.
see also
SAP AG 186
ABAP Workbench Delta Guide (3.1-4.6)
,QVWDQFH'DWDDQG&ODVV'DWD
5HPRWH/HDUQLQJ
0DLQPHPRU\
,QVWDQFH'DWD
Class c_classname RQFHIRU
HDFKLQVWDQFHV
&ODVV'DWDV &ODVV'DWDV
&ODVV'DWDRQFHIRUDOOLQVWDQFHV
SAP AG
([HUFLVH'HILQLQJDQG,PSOHPHQWLQJ&ODVVHV
2EMHFW1DPH'HVFULSWLRQ
&ODVVHV
C_SHIP: Ship class,
C_TRUCK: Truck class
$WWULEXWHV
SHIP_SPEED, TRUCK_SPEED
Speed: Type I
$WWULEXWH
MAX_SPEED
Maximum speed : Type I.
SAP AG 187
ABAP Workbench Delta Guide (3.1-4.6)
$WWULEXWH
ID
Identity: Type I
6WDWLF$WWULEXWH
INST_ID: Instance-ID Type I
Hint: The solution to this exercise is not executable. You can only run the syntax check. You
will extend this solution in later exercises to produce a fully-working program written using
ABAP Objects.
6ROXWLRQ'HILQLQJDQG,PSOHPHQWLQJ&ODVVHV
**************************************************************
* Simple example for classes definition and implementation.
**************************************************************
ENDCLASS.
*-------------------------------------------------------------
SAP AG 188
ABAP Workbench Delta Guide (3.1-4.6)
**************************************************************
* Implementations
**************************************************************
*-------------------------------------------------------------
**************************************************************
* Program
**************************************************************
START-OF-SELECTION.
0HWKRGV
'HFODULQJ0HWKRGV
SAP AG 189
ABAP Workbench Delta Guide (3.1-4.6)
FRQQLG/,.(VIOLJKWFRQQLG
IOGDWH/,.(VIOLJKWIOGDWH
You will see that declaring methods is like declaring function modules, so it should be fairly
simple to rewrite a program to use methods instead of function modules.
You declare methods in the declaration part of a class or interface. The above example with
its additions declares an instance method. For further information, refer to the keyword
documentation in the ABAP Editor for the METHODS statement.
Before we go on, a remark to the design of the above method book. Defining the fields
carrid, connid, and fldate as parameters of the method is not actually good design.
Instead, in real life, you would pass a reference variable pointing to an object of a class
actual_flight with the attributes carrid, connid, and fldate. The method in the
example is just designed to be easy to understand.
You must specify the type of all interface parameters using the TYPE or LIKE addition.
When you declare a method, you only declare its parameters interface using the IMPORTING,
EXPORTING, CHANGING and RETURNING additions. These define the input, output,
input/output and return code parameters. You also define the attributes of the interface
parameters, for example, whether it is passed by reference or by value (VALUE), whether it
has a fixed type (TYPE), and whether an input parameter is optional (OPTIONAL, DEFAULT).
Unlike function modules, the default passing method for methods is by reference. To pass a
parameter by value, you must explicitly use VALUE. The return value (RETURNING parameter)
must always be passed as a value. This parameter is suitable for methods that return a single
value. If you use a returning parameter, you cannot use exporting or changing parameters.
Like function modules, methods allow you to define exception parameters (EXCEPTIONS),
allowing the user to react to errors that occur during the method.
So, apart from the RETURNING parameter, the interface of methods are like those in a
function module.
,PSOHPHQWLQJ0HWKRGV
Once a method has been defined it must be implemented in the implementation part of the
class. If it is not, a syntax error occurs. The general syntax is:
METHOD <meth>.
... Implementation ...
ENDMETHOD.
And here is a simple example:
REPORT sapbc411d_… .
TYPES: tpassenger(20).
DATA: begin of wa, ...
CLASS c_flight DEFINITION.
PUBLIC SECTION.
0(7+2'6ERRN,03257,1*SDVVHQJHU7<3(WSDVVHQJHU
FDUULG/,.(VIOLJKWFDUULG
FRQQLG/,.(VIOLJKWFRQQLG
IOGDWH/,.(VIOLJKWIOGDWH
SAP AG 190
ABAP Workbench Delta Guide (3.1-4.6)
PRIVATE SECTION.
DATA: passenger_list TYPE STANDARD TABLE OF wa.
ENDCLASS.
CLASS c_flight IMPLEMENTATION.
0(7+2'ERRN
029(FDUULG72ZDFDUULG
$33(1'ZD72SDVVHQJHUBOLVW
(1'0(7+2'
ENDCLASS.
Each method implementation must be enclosed in the METHOD <meth> … ENDMETHOD
statements in the same way that a function module definition is enclosed in the FUNCTION …
ENDFUNCTION statements or subroutines in FORM ... ENDFORM.
When you implement a method, you do not need to list its interface parameters again, since
you have already specified them in the method declaration. The interface parameters of
methods are treated like local variables within the method implementation. You can also
declare other local data using the DATA statement.
Like function modules, methods allow you to use the RAISE <exception> and MESSAGE
RAISING statements to trigger exceptions.
When you implement static methods, remember that they can only use the static attributes of
the class. Instance methods can use both: static attributes and instance attributes (see also
the online documentation for the CLASS statement).
&DOOLQJ0HWKRGV
Finally you must call the method. The general syntax is as follows:
CALL METHOD <method> EXPORTING <formal_e> = <actual_e>
IMPORTING <formal_i> = <actual_i>
CHANGING <formal_c> = <actual_c>
RECEIVING r = h
EXCEPTIONS <exc_i> = rc_i.
And here is our example from above with a method call inserted:
REPORT sapbc411d_flight.
CLASS c_flight DEFINITION.
PUBLIC SECTION.
METHODS: book IMPORTING ...
PRIVATE SECTION. ...
ENDCLASS.
CLASS c_flight IMPLEMENTATION.
METHOD book.
...
ENDMETHOD.
ENDCLASS.
SAP AG 191
ABAP Workbench Delta Guide (3.1-4.6)
&$//0(7+2'RIOLJKW!ERRN(;3257,1*SDVVHQJHU
3HWHU0LOOHU
FDUULG
/+
FRQQLG
IOGDWH
You call methods using the above statement. The exact way in which you address the
method <method> depends on where in the program the call occurs. Within the
implementation part of a class, you can call methods in the same class directly using the
name <method>.
CALL METHOD <method> … If you are calling the method from outside the class, the
visibility section of the method determines whether the call is possible. You can call visible
instance methods from outside the class using CALL METHOD <ref>-><method> where
<ref> is a reference variable whose value points to an instance of the class. You can call
visible static methods from outside the class using CALL METHOD <class>=><method>
where <class> is the name of the class.
When you call a method, you must specify all non-optional input parameters in the
EXPORTING and CHANGING additions of the CALL METHOD statement. You can (but do
not have to) receive the IMPORTING and RECEIVING parameters. It is also up to the caller
whether to handle any exceptions triggered in the method using the EXCEPTIONS addition.
However, you are recommended to do so.
CALL METHOD has a similar syntax to the CALL FUNCTION statement (apart from the new
RECEIVING addition). You pass and receive parameters in exactly the same way, namely:
<formal parameter> = <actual parameter> following the corresponding addition.
see also
)XQFWLRQDO0HWKRGV
Functional methods are methods that possess a RETURNING parameter. Each RETURNING
parameter returns exactly one value. Functional methods can possess an unlimited number of
IMPORTING parameters and EXCEPTIONS, but no EXPORTING or CHANGING
parameters. The benefit of functional methods is that they can be used directly in
expressions, such as arithmetical expressions or LOOP statements.
SAP AG 192
ABAP Workbench Delta Guide (3.1-4.6)
)XQFWLRQDO0HWKRGV([DPSOH
&/$66OFOBDLUSODQH'(),1,7,21
38%/,&6(&7,21
0(7+2'6HVWLPDWHGBIXHOBFRQVXPSWLRQ
,03257,1*LPBGLVWDQFH7<3(W\BGLVWDQFH
5(7851,1*9$/8(UHBIXHO7<3(W\BIXHO
&/$660(7+2'6JHWBFRXQW5(7851,1*9$/8(UHBFRXQW7<3(L
(1'&/$66
'$7$SODQH7<3(5()72OFOBDLUSODQH
SODQH7<3(5()72OFOBDLUSODQH
IXHOBFRQVXPSWLRQ7<3(W\BIXHO
FRXQWBSODQHV7<3(L
,QVWDQWLDWLRQRPLWWHG
&$//0(7+2'SODQH!JHWBFRXQW5(&(,9,1*UHBFRXQW FRXQWBSODQHV
FRXQWBSODQHV OFOBDLUSODQH !JHWBFRXQW
IXHOBFRQVXPSWLRQ SODQH!HVWLPDWHGBIXHOBFRQVXPSWLRQ
SODQH!HVWLPDWHGBIXHOBFRQVXPSWLRQLPBGLVWDQFH
SAP AG 1999
&UHDWLQJ2EMHFWV
So far we have defined and implemented classes with attributes and methods. You know that
classes do not occupy main memory, so we still have no objects we can work with in our
program. We therefore now need to look at how to create objects.
An object is an instance of a class. Each object has a unique identity and its own attributes.
All objects of a class exist within a single internal session (memory area of an ABAP
program). You can create any number of instances of a class.
5HIHUHQFHV5HIHUHQFH9DULDEOHV
Here you will see what a reference variable is and why you need it.
SAP AG 193
ABAP Workbench Delta Guide (3.1-4.6)
'HILQLQJ5HIHUHQFH9DULDEOHV
5HPRWH/HDUQLQJ
'$7$RIOLJKWB7<3(5()72FBIOLJKW
'$7$RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
0DLQPHPRU\
5HIHUHQFHVHPDQWLFV
5HIHUHQFHYDULDEOH
RIOLJKWB
B
5HIHUHQFHYDULDEOH
RIOLJKWB
B
SAP AG
ABAP programs access objects using object references. Object references are pointers to
objects, which, in ABAP, occur exclusively as the contents of reference variables (oflight_1
and oflight_2 above), which use reference semantics. This means that you never address the
values of attributes or methods or any other component of an instance directly, but always
using their reference variables. To enable you to do so ABAP contains a new data type TYPE
REF TO <class>. This is a true pointer like those you might be used to in other programming
languages. One of the advantages of the reference semantics is that the system does not
have to copy any object components when you assign one object/reference variable to
another. Instead, it merely copies the address of the new object.
Object references allow you to work with dynamic data structures such as detail lists, trees,
graphs, and so on without having to ‘hammer out’ their data structure to fit it into a table.
Object attributes can themselves contain reference variables.
So, the first step towards creating objects is to define a reference variable. However, so far,
the reference is not pointing to anything. So we need a second step to create an object and
make the reference variable point to it.
SAP AG 194
ABAP Workbench Delta Guide (3.1-4.6)
&UHDWLQJ2EMHFWV
5HPRWH/HDUQLQJ
'$7$RIOLJKWB7<3(5()72FBIOLJKW
'$7$RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
&5($7(
&5($7( 2%-(&7RIOLJKWB
2%-(&7RIOLJKWB
&5($7(
&5($7( 2%-(&7RIOLJKWB
2%-(&7RIOLJKWB
0DLQPHPRU\
5HIHUHQFHVHPDQWLFV
5HIHUHQFHYDULDEOH C_FLIGHT<1>
RIOLJKWB
RIOLJKWB
5HIHUHQFHYDULDEOH C_FLIGHT<2>
RIOLJKWB
RIOLJKWB
SAP AG
Once you have created a reference variable with reference to the class c_flight, you can
create an instance of the class (an object) using the statement CREATE OBJECT <cref>. The
reference variable <cref> now contains a reference to the object. The CREATE OBJECT
statement creates objects dynamically. The program requests main memory space from the
system to enable it to store the components of the new object.
You can create any number of objects belonging to the same class, each of which is fully
independent of the others. Each object has its own identity and its own attributes. Each
CREATE OBJECT statement creates a new object whose identity is defined by its unique
object reference.
In the above diagram, instances are displayed as rounded rectangles. The above notation for
instances (c_flight_1: instance 1 of class c_flight) corresponds to the contents of the
reference variables as displayed in the ABAP Debugger
see also
$VVLJQLQJ5HIHUHQFHV
SAP AG 195
ABAP Workbench Delta Guide (3.1-4.6)
$VVLJQLQJ5HIHUHQFHV
5HPRWH/HDUQLQJ
'$7$RIOLJKWB7<3(5()72FBIOLJKW
'$7$RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
RIOLJKWB
RIOLJKWB RIOLJKWB
RIOLJKWB
0DLQPHPRU\
5HIHUHQFHVHPDQWLFV
5HIHUHQFHYDULDEOH C_FLIGHT<1>
RIOLJKWB
RIOLJKWB
5HIHUHQFHYDULDEOH C_FLIGHT<2>
RIOLJKWB
RIOLJKWB
SAP AG
You can assign references to other reference variables using the MOVE statement. This
means that more than one reference variable can point to the same object. When you assign
reference variables, the types of the source and target variables must either be compatible or
convertible.
In the statement oflight_2 = oflight_1, both of the class references oflight_1 and oflight_2 must
have the same type, that is, they must both refer to the same class, or the class of oflight_1
must be the predefined empty class OBJECT or as you’ll see in the section of interfaces can
be an interface reference.
The class OBJECT has no components. Its significance to reference variables is the same as
that of data type ANY to normal variables. Reference variables with the type OBJECT can
serve as containers for passing references. However, you cannot use them to access
instances.
One further question arises from the above illustration. You will notice that there is no
reference pointing to the instance oflight_2. This means that it cannot be addressed under
any circumstances, and so is occupying memory space unnecessarily. What happens to it?
Are you, as the programmer, responsible for deleting it?
*DUEDJH&ROOHFWLRQ
SAP AG 196
ABAP Workbench Delta Guide (3.1-4.6)
*DUEDJH&ROOHFWLRQ
5HPRWH/HDUQLQJ
'$7$RIOLJKWB7<3(5()72FBIOLJKW
'$7$RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
RIOLJKWB7<3(5()72FBIOLJKW
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
&5($7(2%-(&7RIOLJKWB
RIOLJKWB
RIOLJKWB RIOLJKWB
RIOLJKWB
0DLQPHPRU\
5HIHUHQFHVHPDQWLFV
5HIHUHQFHYDULDEOH C_FLIGHT<1>
RIOLJKWB
RIOLJKWB
5HIHUHQFHYDULDEOH C_FLIGHT<2>
RIOLJKWB
RIOLJKWB *DUEDJHFROOHFWLRQ
SAP AG
When no more references point to an object, the runtime system automatically releases the
memory occupied by it. This is known as garbage collection.
Internally, garbage collection is implemented incrementally. That is, a counter is maintained
for each instance, which is increased by one for each reference variable pointing to it and
decreased each time a reference is moved away from it. When the counter reaches zero, the
system automatically deletes the instance.
Below is an example demonstrating everything we have covered so far.
6DPSOH&UHDWLQJ2EMHFWV
REPORT sapbc411d_flight.
TYPES: tpassenger(20).
SAP AG 197
ABAP Workbench Delta Guide (3.1-4.6)
MOVE ...
APPEND ...
ENDMETHOD.
ENDCLASS.
DATA: oflight TYPE REF TO c_flight.
START-OF-SELECTION.
CREATE OBJECT oflight.
0HWKRG&216758&725
0HWKRG&216758&7255HO
Before we go on to the next topic, let’s return briefly to methods, and introduce a special
method called CONSTRUCTOR.
You may already have wondered how you can create an instance with specific values for its
attributes. The CREATE OBJECT statement creates an instance with a set of initial values, but
in practice, you would probably want to create instances with real values, such as ‘Smith’ for a
name, and ‘01000’ for an ID number. To do this, you could of course define a method with a
name like INITIALIZE, which you could call directly after creating the object to assign the
values. However, programmers using your class would have to remember to do that every
time they created an instance. Another option would be to use the VALUE addition in the
DATA and CLASS-DATA statements, but then every instance you created would have the
same values which, in practice, is no more useful than all of the attributes having initial
values.
0HWKRG&216758&7255HO
The most efficient way to assign values to a new instance is to define and implement the
method CONSTRUCTOR. CONSTRUCTOR is called DXWRPDWLFDOO\in the CREATE OBJECT
statement, so you never have to remember to call it explicitly. This method allows you to set
the initial state of your new instance dynamically.
You always have to use the reserved name CONSTRUCTOR. Constructors can only have
IMPORTING parameters and EXCEPTIONS.
Here is the general syntax:
CLASS c DEFINITION.
PUBLIC SECTION.
METHODS CONSTRUCTOR
[ IMPORTING VALUE(arg1) TYPE type … ].
ENDCLASS.
And here is a concrete example:
PROGRAM SAPBC411D_… .
SAP AG 198
ABAP Workbench Delta Guide (3.1-4.6)
START-OF-SELECTION.
&5($7(2%-(&7RFXVWRPHUB(;3257,1*QDPH
6PLWK
LG
In Release 4.0, the constructor method is not called automatically. From Release 4.5A,
however, it is called automatically in the CREATE OBJECT statement. Consequently, any
constructor methods that you called explicitly in programs in Release 4.0 will be called twice
in Release 4.5A - once automatically, then your explicit call. Remember to delete the explicit
constructor calls from your 4.5A programs.
([HUFLVH'HILQLQJ,PSOHPHQWLQJ&DOOLQJ
0HWKRGVDQG&UHDWLQJ,QVWDQFHV
1. Extend the program you wrote in exercise 1 to include method definitions and
implementations.
2. Both classes should have the methods CONSTRUCTOR, SPEED_UP, STOP, and
WRITE. To keep things simple, none of the methods has an interface.
3. Define the instances OSHIP and OTRUCK, and two internal tables that can store the
instances of the classes you have defined. (DATA: itab1 TYPE REF TO c_truck.)
4. Using a DO loop for each class, create two instances of each of the classes C_TRUCK
and C_SHIP and add them to the appropriate internal table.
5. Use a LOOP statement to process the entries of each internal table. Within the loop, call
the methods SPEED_UP and WRITE for the corresponding instances. So both instances
will be accelerated and their attributes will be displayed.
2EMHFW1DPH'HVFULSWLRQ
0HWKRG
&216758&725for both classes: Increase the class attribute INST_ID by 1, assign the value
to the ID attribute. For class C_SHIP: set the MAX_SPEED attribute to 30. For class C_TRUCK:
set the MAX_SPEED attribute to 140.
0HWKRG
63(('B83for both classes: Check that SPEED is less than MAX_SPEED, and then increase
the speed by 10 for class C_SHIP and by 20 for class C_TRUCK.
SAP AG 199
ABAP Workbench Delta Guide (3.1-4.6)
0HWKRG
STOP for both classes: Set SPEED to 0.
0HWKRG
:5,7(for both classes: Display the following: ’TRUCK- ID = <value>SPEED = <value>’.
,QVWDQFH
26+,32758&.
,QWHUQDOWDEOH
6+,3B7$%758&.B7$%defined with: with TYPE REF TO class
Hint: Don’t forget to insert the START-OF-SELECTION statement at the appropriate point.
6ROXWLRQ'HILQLQJ,PSOHPHQWLQJ&DOOLQJ
0HWKRGVDQG&UHDWLQJ,QVWDQFHV
**************************************************************
* Simple example for classes definition/implementation with
* methods
**************************************************************
ENDCLASS.
*-------------------------------------------------------------
SAP AG 200
ABAP Workbench Delta Guide (3.1-4.6)
PUBLIC SECTION.
0(7+2'6FRQVWUXFWRU
0(7+2'6VSHHGBXS
0(7+2'6VWRS
0(7+2'6ZULWH
PRIVATE SECTION.
DATA: truck_speed TYPE i.
DATA: max_speed TYPE i VALUE 10.
DATA: id TYPE i.
CLASS-DATA: inst_id TYPE i.
ENDCLASS.
**************************************************************
* Implementations
**************************************************************
*-------------------------------------------------------------
SAP AG 201
ABAP Workbench Delta Guide (3.1-4.6)
0(7+2'FRQVWUXFWRU
,QVWBLG LQVWBLG
LG LQVWBLG
PD[BVSHHG
(1'0(7+2'
0(7+2'VSHHGBXS
7UXFNBVSHHG WUXFNBVSHHG
,)WUXFNBVSHHG!PD[BVSHHG
7UXFNBVSHHG PD[BVSHHG
(1',)
(1'0(7+2'
0(7+2'VWRS
7UXFNBVSHHG
(1'0(7+2'
0(7+2'ZULWH
:5,7(
7UXFN,'
LG
6SHHG
WUXFNBVSHHG
(1'0(7+2'
ENDCLASS.
**************************************************************
* Program
**************************************************************
67$572)6(/(&7,21
*Don’t forget it otherwise the DO statement (first statement) * is n
ot executable--
'$7$RVKLS7<3(5()72FBVKLS
'$7$RWUXFN7<3(5()72FBWUXFN
'$7$VKLSBWDE7<3(5()72FBVKLS2&&856
'$7$WUXFNBWDE7<3(5()72FBWUXFN2&&856
*-------------------------------------------------------------
SAP AG 202
ABAP Workbench Delta Guide (3.1-4.6)
'HEXJJHU
Before we go on, let’s take a look at how the Debugger handles instances.
The illustration below shows how instances are displayed in the Debugger. Here instance 1 of
class c_ship.
Once you have created the instance, you enter or double-click the name of the instance (here
instance oship) to place it in the variable list. Then double-click the field contents. The screen
appears as displayed below (4.5A system. In a 4.0 system, the functions are the same, but
the icons identifying the different types of attributes and instances are not displayed.)
SAP AG 203
ABAP Workbench Delta Guide (3.1-4.6)
'HEXJJLQJLQVWDQFHV
Objekt (Id) ABAP Debugger 5HPRWH
,QVWB,G ,
,B9HKLFOH
,B9HKLFOHa0D[BVSHHG ,
,B9HKLFOHa,G ,
,B9HKLFOHa,G ,
SAP AG
With the filter function you can determine which attributes and interfaces are shown (in the
diagram, all attributes). Icons show the type of each attribute. Similarly, by pressing the event
button, you can display the events the instance can trigger and the handler method that was
registered for the event when it is triggered by that instance.
5HOHDVH:
Events can only be displayed after the SET HANLDER statement has been processed.
It is not possible to display class events.
,QKHULWDQFH
,QWURGXFWLRQ
Classifying things is part of human nature. People naturally group things in hierarchies, with a
single unit (superclass) split into several subclasses. In the animal kingdom, for example,
people distinguish between mammals and insects. The mammals class can be further divided
into dogs, cats, elephants, and so on. At the next highest level, the superclass combines all
SAP AG 204
ABAP Workbench Delta Guide (3.1-4.6)
the characteristics that are common to the animals included in it. Characteristics that
differentiate the various animals in the same class are described in subclasses. For example,
all mammals bear their offspring, but only the elephant weighs 1-2 tonnes, is gray, and has a
trunk.
The concept of inheritance takes this human habit of classifying things and applies it to
programming. Inheritance is a relationship in which one class (the subclass) inherits all its
properties (attributes, methods,…) from another (the superclass). The subclass can also have
new components (attributres, methods…) added to it, or replace the methods it has inherited
with methods of its own.
,QKHULWDQFH([DPSOH
OFOBDLUSODQH
- name
- weight
...
+ get_fuel_level ( ) : ty_level
+ estimate_fuel_consumption ( ) : i
...
³LVD´UHODWLRQVKLS
OFOBSDVVHQJHUBDLUSODQH OFOBFDUJRBDLUSODQH
- seats - cargo
- emergency_exits ...
...
+ get_seats ( ) : i + get_cargo ( ) : ty_cargo
... ...
SAP AG 1999
The above example shows a superclass, OFOBDLUSODQH which describes all the properties
common to DOO aircraft – like having a name. Each of the two subclasses,
OFOBSDVVHQJHUBDLUSODQH and OFOBFDUJRBDLUSODQH lists the properties that are specific to a
passenger and freight airplane respectively. The properties of the superclass are not explicitly
listed in the subclasses, since each subclass inherits these properties automatically. The
inheritance relationship is often referred to as an "is a" relationship – for example, a
passenger airplane LVDQ airplane.
SAP AG 205
ABAP Workbench Delta Guide (3.1-4.6)
,QKHULWDQFHKLHUDUFK\
Generalization
OFOB
Specialization
1RPXOWLSOH
LQKHULWDQFH
OFOB
SAP AG 1999
In ABAP, you can make the inheritance levels as deep as you like – that is, a subclass can
itself be a superclass with other subclasses under it. There is no such thing as multiple
inheritance in ABAP –a subclass cannot inherit from two superclasses simultaneously.
Multiple inheritance can however be simulated using interfaces.
You should use inheritance to implement generalizations and specializations. Each
superclass is a generalization of its subclasses. Each subclass is a specialization of its
superclasses.
6\QWD[
SAP AG 206
ABAP Workbench Delta Guide (3.1-4.6)
,QKHULWDQFH6\QWD[
&/$66OFOBDLUSODQH'(),1,7,21
38%/,&6(&7,21
0(7+2'6JHWBIXHOBOHYHO5(7851,1*9$/8(UHBOHYHO7<3(W\BOHYHO
35,9$7(6(&7,21
'$7$QDPH7<3(VWULQJ
ZHLJKW7<3(,
(1'&/$66
&/$66OFOBFDUJRBDLUSODQH'(),1,7,21,1+(5,7,1*)520OFOBDLUSODQH
38%/,&6(&7,21
0(7+2'6JHWBFDUJR5(7851,1*9$/8(UHBFDUJR7<3(W\BFDUJR
35,9$7(6(&7,21
'$7$FDUJR7<3(W\BFDUJR
(1'&/$66
SAP AG 1999
,QIRUPDWLRQ+LGLQJ
Inheritance extends the concept of information hiding, since, besides public and private
components, there are also protected components. Public components are visible to all users,
all subclasses, and within the class itself, whereas private components are visible only to the
class itself. Protected components lie between these two types: they can be seen and used
by the class itself and by all its subclasses.
Subclasses cannot access the private components of their superclass. Thus, although the
subclass inherits the private attributes of its superclass, it cannot address them directly, but
only by using the public or protected methods of the superclass. Private components are used
in superclasses, if for example the (super-) class needs to carry out local enhancements to
get rid of an error. It can do this without recognizing or invalidating its subclasses, by using
private components.
SAP AG 207
ABAP Workbench Delta Guide (3.1-4.6)
,QKHULWDQFH,QIRUPDWLRQ+LGLQJ
&/$66OFOBDLUSODQH'(),1,7,21
l3XEOLFFRPSRQHQWV 38%/,&6(&7,21
n9LVLEOHWRDOO 0(7+2'6JHWBQDPH5(7851,1*
n'LUHFWDFFHVV 9$/8(UHBQDPH7<3(VWULQJ
l3URWHFWHGFRPSRQHQWV 3527(&7('6(&7,21
n2QO\YLVLEOHZLWKLQWKHLUFODVV '$7$WDQN7<3(5()72OFOBWDQN
DQGZLWKLQWKHVXEFODVV
l3ULYDWHFRPSRQHQWV
35,9$7(6(&7,21
'$7$QDPH7<3(VWULQJ
n2QO\YLVLEOHZLWKLQWKHFODVV
n1RDFFHVVIURPRXWVLGHWKH
(1'&/$66
FODVVQRWHYHQIURPWKH
VXEFODVV
SAP AG 1999
Protected components of a class, which are only visible to its subclass (and its subclasses),
must be declared in the 3527(&7(' section of the definition. These sections must be
included in the correct order – public, protected, private. Otherwise the system returns a
syntax error.
,QKHULWDQFHDQG&RQVWUXFWRUV
Within the constructor for a subclass, the constructor for the superclass directly above it PXVW
be called. This is obligatory because of the special task that the constructor must perform: to
ensure that an object has been initialized correctly. Only the class itself – not its subclasses –
can initialize its private components correctly. It is essential therefore that all the (instance)
constructors in the inheritance hierarchy are called in the correct order.
The constructor for the subclass generally contains parameters for DOO the attributes of the
subclass – that is including those that it has inherited from the superclass.
Static constructors, unlike instance constructors, are called automatically. That is, the runtime
system executes the static constructor for all the superclasses of a class, before the static
constructor for the class itself is run.
SAP AG 208
ABAP Workbench Delta Guide (3.1-4.6)
&/$66OFOBDLUSODQH'(),1,7,21 &/$66OFOBDLUSODQH,03/(0(17$7,21
38%/,&6(&7,21 0(7+2'&216758&725
0(7+2'6&216758&725,03257,1* QDPH LPBQDPH
LPBQDPH7<3(VWULQJ (1'0(7+2'
35,9$7(6(&7,21 (1'&/$66
'$7$QDPH7<3(VWULQJ
(1'&/$66
&/$66OFOBFDUJRBDLUSODQH'(),1,7,21,1+(5,7,1*)520OFOBDLUSODQH
38%/,&6(&7,21
0(7+2'6&216758&725,03257,1*LPBQDPH7<3(VWULQJ
LPBFDUJR7<3(W\BFDUJR
35,9$7(6(&7,21
'$7$FDUJR7<3(W\BFDUJR
(1'&/$66
&/$66OFOBFDUJRBDLUSODQH,03/(0(17$7,21
0(7+2'&216758&725
&$//0(7+2'683(5!&216758&725(;3257,1*LPBQDPH LPBQDPH
FDUJR LPBFDUJR
(1'0(7+2'
(1'&/$66
SAP AG 1999
In the above example a constructor has been defined for the subclass
OFOBFDUJRBDLUSODQH The system must assign values to two of its parameters – FDUJR
(which has been defined in the subclass) and QDPH (which has been defined as a private
attribute of the superclass). The superclass constructor must be called before the constructor
for OFOBFDUJRBDLUSODQH is called; otherwise a syntax error will occur. To do this, you must
use the standard reference SUPER, which is introduced specifically for this case, and which
always points to the superclass immediately above the class itself. Only then can values be
assigned to the attributes that have been defined in the subclass itself (in this case the
attribute FDUJR).
6DPSOH,QKHULWDQFH
3URJUDP'HVFULSWLRQ
Three classes have been created in the program:
Airplane OFOBDLUSODQH
(superclass)
Passenger airplane OFOBSDVVHQJHUBDLUSODQH (subclass of lcl_airplane)
Cargo plane OFOBFDUJRBDLUSODQH
(subclass of lcl_airplane)
A constructor is defined for each class. It assigns values to all the attributes of each class
along with a method for displaying class-specific attributes. Note that
GLVSOD\BQDPHBDQGBSODQHW\SHthe method defined in OFOBDLUSODQH is also available
in both subclasses.
SAP AG 209
ABAP Workbench Delta Guide (3.1-4.6)
In the main part of the program, a reference is defined for each subclass, and in each case an
object is generated. Each method is called for each object.
3URJUDP&RGH
REPORT SAPD46AW_INHERITANCE .
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane DEFINITION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
PROTECTED SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane IMPLEMENTATION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane IMPLEMENTATION.
METHOD constructor.
name = im_name.
planetype = im_planetype.
ENDMETHOD.
SAP AG 210
ABAP Workbench Delta Guide (3.1-4.6)
METHOD display_name_and_planetype.
WRITE: / ’Name of the airplane: ’(001), AT pos_1 name,
/ ’Plane type: ’(002), AT pos_1 planetype.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_passenger_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_passenger_airplane IMPLEMENTATION
*
*--------------------------------------------------------------------
-*
CLASS lcl_passenger_airplane IMPLEMENTATION.
METHOD constructor.
call method super->constructor exporting im_name = im_name
SAP AG 211
ABAP Workbench Delta Guide (3.1-4.6)
im_planetype =
im_planetype.
n_o_seats = im_n_o_seats.
ENDMETHOD.
METHOD display_n_o_seats.
WRITE: / ’Number of seats: ’(003), 25 n_o_seats, /.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_cargo_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_cargo_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_cargo_airplane IMPLEMENTATION
*
*--------------------------------------------------------------------
-*
CLASS lcl_cargo_airplane IMPLEMENTATION.
SAP AG 212
ABAP Workbench Delta Guide (3.1-4.6)
METHOD constructor.
CALL METHOD super->constructor EXPORTING im_name = im_name
im_planetype =
im_planetype.
cargo_max = im_cargo_max.
ENDMETHOD.
METHOD display_cargo_max.
WRITE: / ’Maximal cargo: ’(004), at pos_1 cargo_max, /.
ENDMETHOD.
ENDCLASS.
*--------------------------------------------------------------------
-*
* MAIN PROGRAM
*
*--------------------------------------------------------------------
-*
START-OF-SELECTION.
SAP AG 213
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP2XWSXW
5HGHILQLWLRQ
ABAP Objects allows you to add new components to a subclass, as well as to provide
inherited methods with new implementations. This is known as redefinition. It can only be
used on (public or protected) instance methods, not static methods or attributes. You can only
redefine a (new) implementation of an inherited method – that is, you add new code to an
existing method. You cannot change the parameters of the method.
To redefine an inherited method in a subclass, you must include this method again in the
subclass definition – ZLWKRXW including its parameters ( which are automatically inherited from
the subclass) – and append the addition REDEFINITION to the METHOD statement. You
must include this METHOD statement in the same section (public or protected) as in the
definition in the original method. You cannot redefine the private methods of a superclass,
since the subclass cannot see them.
SAP AG 214
ABAP Workbench Delta Guide (3.1-4.6)
5HGHILQLWLRQ([DPSOH
&/$66OFOBDLUSODQH'(),1,7,21
38%/,&6(&7,21
0(7+2'6HVWLPDWHBIXHOBFRQVXPSWLRQ
,03257,1*LPBGLVWDQFH7<3(W\BGLVWDQFH
5(7851,1*9$/8(UHBIXHO7<3(W\BIXHO
(1'&/$66
&/$66OFOBSDVVHQJHUBDLUSODQH'(),1,7,21,1+(5,7,1*)520OFOBDLUSODQH
38%/,&6(&7,21
0(7+2'6HVWLPDWHBIXHOBFRQVXPSWLRQ5('(),1,7,21
(1'&/$66
&/$66OFOBSDVVHQJHUBDLUSODQH,03/(0(17$7,21
0(7+2'HVWLPDWHBIXHOBFRQVXPSWLRQ
(1'0(7+2'
(1'&/$66
SAP AG 1999
SAP AG 215
ABAP Workbench Delta Guide (3.1-4.6)
5HGHILQLWLRQ([DPSOH
OFOBDLUSODQH
+ estimate_fuel_consumption ( ): fuel
OFOBSDVVHQJHUBDLUSODQH OFOBFDUJRBDLUSODQH
0(7+2'HVWLPDWHBIXHOBFRQVXPSWLRQ 0(7+2'HVWLPDWHBIXHOBFRQVXPSWLRQ
'$7$WRWDOBZHLJKW '$7$WRWDOBZHLJKW
WRWDOBZHLJKW VHDWV
WRWDOBZHLJKW FDUJRZHLJKW
DYHUDJHBZHLJKWZHLJKW
UHBIXHO WRWDOBZHLJKW
UHBIXHO WRWDOBZHLJKW
LPBGLVWDQFH
IDFWRU LPBGLVWDQFH
IDFWRU
(1'0(7+2' (1'0(7+2'
SAP AG 1999
The combination of inheritance and redefinition means that the same method can be
implemented differently in different (sub-)classes. In example 2, fuel consumption is
calculated differently for the two different types of airplane. It is important, however, that the
semantics are the same. (For example, the number of occupied seats in the airplane should
be calculated in a different method, not in HVWLPDWHBIXHOBFRQVXPSWLRQ).
The real benefits of redefinition become apparent only within the context of polymorphism
(see 3RO\PRUSKLVP.
6DPSOH5HGHILQLWLRQ
3URJUDP'HVFULSWLRQ
Three classes have been created in the program:
Airplane OFOBDLUSODQH
(superclass)
Passenger airplane OFOBSDVVHQJHUBDLUSODQH (subclass of lcl_airplane)
Cargo plane OFOBFDUJRBDLUSODQH
(subclass of lcl_airplane)
The method GLVSOD\BDWWULEXWHV is declared and implemented in the class
OFOBDLUSODQH. It is then redefined in the subclasses OFOBSDVVHQJHUBDLUSODQH and
OFOBFDUJRBDLUSODQH.This example program displays all the attributes of each class on a
different background color (specified using the input parameter LPBFRORU (which must have
a value from 0 to 7).In the main program, an object instance is generated and the method
called for each subclass (with a different background color in each case).
SAP AG 216
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP&RGH
REPORT yakd46aw_redefinition .
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane DEFINITION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
PROTECTED SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane IMPLEMENTATION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane IMPLEMENTATION.
METHOD constructor.
name = im_name.
planetype = im_planetype.
ENDMETHOD.
METHOD display_attributes.
SAP AG 217
ABAP Workbench Delta Guide (3.1-4.6)
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_passenger_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_passenger_airplane IMPLEMENTATION
*
*--------------------------------------------------------------------
-*
CLASS lcl_passenger_airplane IMPLEMENTATION.
METHOD constructor.
SAP AG 218
ABAP Workbench Delta Guide (3.1-4.6)
METHOD display_attributes.
CALL METHOD super-
>display_attributes EXPORTING im_color = im_color.
FORMAT COLOR = im_color.
WRITE: / ’Number of seats: ’(003),
AT pos_1 n_o_seats LEFT-JUSTIFIED, AT pos_2 space, /.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_cargo_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_cargo_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
SAP AG 219
ABAP Workbench Delta Guide (3.1-4.6)
METHOD constructor.
CALL METHOD super->constructor EXPORTING im_name = im_name
im_planetype = im_planety
pe.
cargo_max = im_cargo_max.
ENDMETHOD.
METHOD display_attributes.
CALL METHOD super-
>display_attributes EXPORTING im_color = im_color.
FORMAT COLOR = im_color.
WRITE: / ’Maximal cargo: ’(004), AT pos_1 cargo_max,
AT pos_2 space, /.
ENDMETHOD.
ENDCLASS.
*--------------------------------------------------------------------
-*
* MAIN PROGRAM
*
*--------------------------------------------------------------------
-*
START-OF-SELECTION.
SAP AG 220
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP2XWSXW
&DVW*HQHUDO
One of the basic principles of inheritance is that an instance of a subclass can be used
wherever an instance of the superclass occurs. This is possible because the subclass inherits
DOOthe components of the superclass – including its interface. Users can address the instance
of the subclass, just as they would an instance of the superclass. In practice, this means that,
at runtime, variables of the UHIHUHQFHWRVXSHUFODVVtype can also refer to instances of a
subclass.
This enables you to assign references between superclasses and subclasses. This is referred
to as FDVW. There are two types of cast:
1. An instance of a subclass is assigned to a superclass reference. This is known as
1DUURZLQJ&DVW.
2. An object is assigned to a subclass reference. A superclass reference points to this
object. This is known as :LGHQLQJ&DVW.
SAP AG 221
ABAP Workbench Delta Guide (3.1-4.6)
1DUURZLQJ&DVW
'$7$DLUSODQH7<3(5()72OFOBDLUSODQH
FDUJRBDLUSODQH7<3(5()72OFOBFDUJRBDLUSODQH
&5($7(2%-(&7FDUJRBDLUSODQH
airplane /+%HUOLQ
QDPH
ZHLJKW
NJ
DLUSODQH FDUJRBDLUSODQH
airplane /+%HUOLQ
QDPH
ZHLJKW
NJ
SAP AG 1999
In the above example, you define a reference to a class, OFOBDLUSODQH, and its subclass,
OFOBFDUJRBDLUSODQH. Then you generate a cargo plane, that is an object of the class
OFOBFDUJRBDLUSODQH. The gray box illustrates the situation in main memory, both before
and after the narrowing cast has taken place.
Before the narrowing cast, only the reference FDUJRBDLUSODQH points to the object that has
been generated. $OOthe public components of the object can be addressed using
FDUJRBDLUSODQH. At present, the reference DLUSODQH does not yet point to any object.
After the narrowing cast (DLUSODQH FDUJRBDLUSODQH) the components of the cargo
plane instance that were inherited from OFOBDLUSODQHcan be accessed using the reference
DLUSODQH (depending on their visibility). Accessing the cargo plane-specific part of the
instance (FDUJR in the example above) is no longer possible.
6WDWLFDQG'\QDPLF7\SHV
SAP AG 222
ABAP Workbench Delta Guide (3.1-4.6)
Each reference variable always has two types, a static type and a dynamic type:
The static type is specified using TYPE REF TO variable definition. It specifies which
attributes and methods can be address. It cannot be changed.
The dynamic type is the type of the instance currently being referred to – that is, it is
specified by assignment and can change while the program is running. It specifies which
code is to be executed when methods are redefined.
A dynamic type is compatible with a static type, provided it has all the components (attributes,
methods…) that are specified by the static type.
6WDWLFDQG'\QDPLF7\SHV([DPSOH
6WDWLFW\SHIRUDLUSODQH
'$7$DLUSODQH7<3(5()72OFOBDLUSODQH
FDUJRBDLUSODQH7<3(5()72OFOBFDUJRBDLUSODQH
&5($7(2%-(&7FDUJRBDLUSODQH
DLUSODQH FDUJRBDLUSODQH '\QDPLFW\SHIRUDLUSODQH
airplane /+%HUOLQ
QDPH
ZHLJKW
NJ
SAP AG 1999
In the above example, the static of the variable DLUSODQHis always 5()72OFOBDLUSODQH,
but after casting, the dynamic type becomes 5()72OFOBFDUJRBDLUSODQH.
:LGHQLQJ&DVW
SAP AG 223
ABAP Workbench Delta Guide (3.1-4.6)
Whether or not the widening cast is valid is usually determined only at runtime. To make this
visible, you must use the FDVWRSHUDWRU "" or the equivalent "029("72".
:LGHQLQJ&DVW9DOLG&DVH
'$7$DLUSODQH7<3(5()72OFOBDLUSODQH
FDUJRBDLUSODQH7<3(5()72OFOBFDUJRBDLUSODQH
FDUJRBDLUSODQH7<3(5()72OFOBFDUJRBDLUSODQH
&5($7(2%-(&7FDUJRBDLUSODQH
DLUSODQH FDUJRBDLUSODQH
airplane /+%HUOLQ
QDPH
ZHLJKW
NJ
cargo_airplane2
FDUJRBDLUSODQH" DLUSODQH
airplane /+%HUOLQ
QDPH
ZHLJKW
NJ
cargo_airplane2
SAP AG 1999
For the widening cast to be valid, the assigned object (the FDUJRDLUSODQH in the above
example) must be compatible with the object reference (FDUJRBDLUSODQH). This means that
the object possess the attributes and methods that the reference implies. In other words, the
dynamic type of the object must be compatible with the static type of the reference.
SAP AG 224
ABAP Workbench Delta Guide (3.1-4.6)
:LGHQLQJ&DVW,QYDOLG&DVH
'$7$DLUSODQH7<3(5()72OFOBDLUSODQH
FDUJRBDLUSODQH7<3(5()72OFOBFDUJRBDLUSODQH
&5($7(2%-(&7DLUSODQH
airplane QDPH
/+%HUOLQ
NJ ZHLJKW
cargo_airplane
/DXI]HLW
FDUJRBDLUSODQH" DLUSODQH IHKOHU
airplane QDPH
/+%HUOLQ
NJ ZHLJKW
cargo_airplane
SAP AG 1999
In this example, we tried to assign an object of the OFOBDLUSODQH class to the reference
FDUJRBDLUSODQH. This is not valid, since – because of the static type of FDUJRBDLUSODQH
– you may need to call the method JHWBFDUJR. This method, however, is defined only in the
OFOBFDUJRBDLUSODQH class, not in OFOBDLUSODQH and thus not in the object.
In this case, a runtime error is triggered when the program runs. If this error is not dealt with,
the program will terminate.
SAP AG 225
ABAP Workbench Delta Guide (3.1-4.6)
(UURUKDQGOLQJ
&$7&+6<67(0(;&(37,21029(B&$67B(5525
FDUJRBDLUSODQH" DLUSODQH
(1'&$7&+
,)6<68%5&(4
(1',)
SAP AG 1999
In general, it is not clear until runtime whether or not a widening cast is valid. For this reason,
you should always include code to handle a MOVE_CAST_ERROR error in case one occurs,
using a CATCH ... ENDCATCH statement – and reacting appropriately to the exception that is
triggered (IF SY_SUBRC ...). At runtime, the system will then ascertain whether or not the
present content of the sources variables corresponds to the type requirements of the target
variables – in this case, whether the dynamic type of the source reference, DLUSODQHis
compatible with the static type of the target reference, FDUJRBDLUSODQHIf this is the case,
then the object is assigned. Otherwise the system returns a MOVE_CAST_ERROR, (such
that the target variables retain their original values), which the program deals with. The
program, however, will not terminate.
3RO\PRUSKLVP
SAP AG 226
ABAP Workbench Delta Guide (3.1-4.6)
,QKHULWDQFH3RO\PRUSKLVP
OFOBDLUSRUW OFOBDLUSODQH
0,1 0..*
- plane_list :internal table
+ Calculate_required_fuel:re_fuel + estimate_fuel_consumption:re_fuel
'$7$SODQH7<3(5()72OFOBDLUSODQH
/223$7SODQHBOLVW,172SODQH
UHBIXHO UHBIXHO
SODQH!HVWLPDWHBIXHOBFRQVXPSWLRQ
(1'/223
OFOBSDVVHQJHU OFOBFDUJR
+ estimate_fuel_consu.. + estimate_fuel_consu..
SAP AG 1999
In the above example, there is a list, SODQHBOLVW, of airplanes of different types (passenger
and cargo). The system reads this list using /223 and (1'/223. In the &$//0(7+2'
SODQH!HVWLPDWHBIXHOBFRQVXPSWLRQ statement, the class of the instance to which
SODQH refers is used as a starting point for the system, searching for the implementation of
the method – in this case either OFOBSDVVHQJHUBDLUSODQHor OFOBFDUJRBDLUSODQH) –
not the static type SODQH, which is always a '5()72OFOBDLUSODQH‘.
SAP AG 227
ABAP Workbench Delta Guide (3.1-4.6)
3RO\PRUSKLVP([DPSOH
'$7$FDUJRBSODQH7<3(5()72OFOBFDUJRBDLUSODQH
SDVVHQJHUBSODQH7<3(5()72OFOBSDVVHQJHUBDLUSODQH
SODQHBOLVW7<3(7$%/(2)5()72OFOBDLUSODQH
&5($7(2%-(&7FDUJRBSODQH
$33(1'FDUJRBSODQH72SODQHBOLVW
&5($7(2%-(&7SDVVHQJHUBSODQH
$33(1'SDVVHQJHUBDLUSODQH72SODQHBOLVW
FDUJRBDLUSODQH
SODLQBOLVW
SDVVHQJHUBDLUSODQH
SAP AG 1999
SAP AG 228
ABAP Workbench Delta Guide (3.1-4.6)
3RO\PRUSKLVP([DPSOH
0(7+2'FDOFXODWHBUHTXLHUHGBIXHO
'$7$SODQH7<3(5()72OFOBDLUSODQH
/223$7SODQHBOLVW,172SODQH
UHBIXHO UHBIXHO
SODQH!HVWLPDWHBIXHOBFRQVXPSWLRQGLVWDQFH
(1'/223
(1'0(7+2'
0(7+2'HVWLPDWHBIXHOBFRQVXPSWLRQ
SODQH WRWDOBZHLJKW FDUJRBPD[ZHLJKW
UHBIXHO WRWDOBZHLJKW
SODLQBOLVW (1'0(7+2'
FDUJR
0(7+2'HVWLPDWHBIXHOBFRQVXPSWLRQ
WRWDOBZHLJKW
QBRBVHDWV
KXPDQBZHLJKWZHLJKW
SDVVHQJHU UHBIXHO WRWDOBZHLJKW
(1'0(7+2'
SAP AG 1999
In this example, the system reads the internal table, SODQHBOLVW, and calculates the fuel
consumption for each airplane in the list. To do this, it calls the method
HVWLPDWHBIXHOBFRQVXPSWLRQ from the (super-)class reference SODQH. The specific code
that is executed when HVWLPDWHBIXHOBFRQVXPSWLRQ is called depends on the dynamic
type of the reference variable, SODQH. In other words, it depends on which object SODQH is
referencing.
Using polymorphism, you can write very generic programs that do not need to be changed to
take account of user-specific enhancements. In the simple example above, this means that
you can add another subclass, VSDFHFUDIW, without having to change the rest of the code.
6DPSOH3RO\PRUSKLVP
3URJUDP'HVFULSWLRQ
Three classes have been created in the program:
Airplane OFOBDLUSODQH
(superclass)
Passenger airplane OFOBSDVVHQJHUBDLUSODQH (subclass of lcl_airplane)
Cargo plane OFOBFDUJRBDLUSODQH
(subclass of lcl_airplane)
The main part of the program creates an internal table, DLUSODQHBWDEOH. It consists of one
column, with references to the class OFOBDLUSODQH. It then defines a reference DLUSODQH
with the static type 5()72OFOBDLUSODQH, in order to generate the objects, fill them, and
to read from the internal table. The program defines an object from each class
SAP AG 229
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP&RGH
REPORT yakd46aw_polymorphism .
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane DEFINITION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
PROTECTED SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_airplane IMPLEMENTATION
*--------------------------------------------------------------------
-*
CLASS lcl_airplane IMPLEMENTATION.
METHOD constructor.
SAP AG 230
ABAP Workbench Delta Guide (3.1-4.6)
name = im_name.
planetype = im_planetype.
ENDMETHOD.
METHOD display_attributes.
FORMAT COLOR = im_color.
WRITE: / ’Name of the airplane: ’(001), AT pos_1 name,
AT pos_2 space,
/ ’Plane type: ’(002), AT pos_1 planetype,
AT pos_2 space.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_passenger_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
*--------------------------------------------------------------------
-*
* CLASS lcl_passenger_airplane IMPLEMENTATION
*
SAP AG 231
ABAP Workbench Delta Guide (3.1-4.6)
*--------------------------------------------------------------------
-*
CLASS lcl_passenger_airplane IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor EXPORTING im_name = im_name
im_planetype = im_planety
pe.
n_o_seats = im_n_o_seats.
ENDMETHOD.
METHOD display_attributes.
CALL METHOD super-
>display_attributes EXPORTING im_color = im_color.
FORMAT COLOR = im_color.
WRITE: / ’Number of seats: ’(003),
AT pos_1 n_o_seats LEFT-JUSTIFIED, AT pos_2 space, /.
ENDMETHOD.
ENDCLASS.
*&-------------------------------------------------------------------
--*
* CLASS lcl_cargo_airplane DEFINITION
*
*--------------------------------------------------------------------
--*
CLASS lcl_cargo_airplane DEFINITION INHERITING FROM lcl_airplane.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
SAP AG 232
ABAP Workbench Delta Guide (3.1-4.6)
*--------------------------------------------------------------------
-*
* CLASS lcl_cargo_airplane IMPLEMENTATION
*
*--------------------------------------------------------------------
-*
CLASS lcl_cargo_airplane IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor EXPORTING im_name = im_name
im_planetype = im_planety
pe.
cargo_max = im_cargo_max.
ENDMETHOD.
METHOD display_attributes.
CALL METHOD super-
>display_attributes EXPORTING im_color = im_color.
FORMAT COLOR = im_color.
WRITE: / ’Maximal cargo: ’(004), AT pos_1 cargo_max,
AT pos_2 space, /.
ENDMETHOD.
ENDCLASS.
*--------------------------------------------------------------------
-*
* MAIN PROGRAM
*
*--------------------------------------------------------------------
-*
START-OF-SELECTION.
SAP AG 233
ABAP Workbench Delta Guide (3.1-4.6)
im_n_o_seats = 580.
ENDLOOP.
3URJUDP2XWSXW
SAP AG 234
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUIDFHV
,QWURGXFWLRQ
Here you will learn what interfaces are and what benefits they offer. The declaration and
implementation is of course also covered here, and the section also contains an example.
Interfaces can be characterized with the following statements:
• Interfaces define the interaction between objects
• Interface references provide uniform access to different classes
• Polymorphism is independent of classes and inheritance
• Classes can implement more than one interface
This may seem confusing at first, but during the unit, everything should become clearer.
8VLQJ,QWHUIDFHV
5HPRWH/HDUQLQJ
%RRNLQJB
%RRNLQJB0JU
IBook
SAP AG
SAP AG 235
ABAP Workbench Delta Guide (3.1-4.6)
rental car, you need the car type. Consequently, the implementation will be different for each
of the above classes.
One solution to this problem is to define an interface. An interface is an independent
component that you define, but do not implement. It is an abstract definition of components
that are shared by different classes. They contain components exactly like classes, but
instead of having their own implementation part, their methods are implemented by the class
that implements the interface. The interface therefore extends the external point of contact of
a class to include all of the interface components as well as the class components.
The above example shows a booking manager application that you can use to book flights,
hotel rooms, and rental cars. An interface (Ibook) allows you to extend the classes flight,
hotel, and rental car and implement the booking procedure in each of the different classes by
addressing the same interface.
,QWHUIDFH0RGHO
Now let’s have a look what the interface model looks like.
,QWHUIDFH0RGHO
5HPRWH/HDUQLQJ
,17(5)$&(L
'$7$D
0(7+2'P &ODVVF
(1',17(5)$&(
Public Private
components components
&/$66F'(),1,7,21 D
D
38%/,&6(&7,21 P
'$7$D« LaD H
,17(5)$&(6L« LaP Method
3527(&7('6(&7,21 implementation
35,9$7(6(&7,21
Protected components
(1'&/$66 a3, m3, e3, …
&/$66F,03/(0(17$7,21
Subclasses of c1
0(7+2'LaP«(1'0(7+2'
All users
(1'&/$66
SAP AG
Here the local interface i1 is simply defined with, just as an example, the attribute a1 and the
method m1. A local class c1 defines the interface as part of the public section. You can regard
the interface statement inside the class as an include to the definition of the interface above.
Since the class c1 declares the interface it has to implement it.
The components of interfaces do not have to be explicitly assigned to a visibility section, since
the interface itself is assigned to a visibility section of the class that implements it, and all of
its components automatically assume the same visibility. Up to and including Release 4.0B,
an interface can be defined in any of the sections of a class, but from Release 4.5A onwards,
SAP AG 236
ABAP Workbench Delta Guide (3.1-4.6)
they must be defined in the public section. SAP therefore recommends that you define all
interfaces in the public section, even in Releases 4.0A and 4.0B.
From the right-hand side of the diagram, you will see that an interface extends the class-
specific contact point. These contact points are realized using interface reference variables.
'HILQLQJ,QWHUIDFHV
You are now going to learn how to define an interface. Here is the general syntax:
,17(5)$&(LQWHUIDFH!
... ('HILQLWLRQRILQWHUIDFHFRPSRQHQWV) ...
(1',17(5)$&(
,17(5)$&(LBUHVHUYDWLRQ
0(7+2'6ERRN,03257,1*SDVVHQJHU7<3(WSDVVHQJHU
FDQFHO,03257,1*SDVVHQJHU7<3(WSDVVHQJHU
(1',17(5)$&(
Like classes, you can define interfaces either globally in the R/3 Repository, or locally in an
ABAP program. The definition of a local interface <interface> is always enclosed in the
statements INTERFACE <interface> … ENDINTERFACE.
Interfaces allow you to implement abstract methods. In the above example, the methods
’book’ and ’cancel’ could appear in both the classes ’flight’ and ’hotel’. However, the actual
implementation is different in each class.
Interfaces allow you to define common components of different classes in one place.
The question now remains as to how interfaces are linked to objects. This is explained next.
,PSOHPHQWLQJ,QWHUIDFHV
Unlike classes, interfaces do not have an implementation part. Instead, they are implemented
by classes using this general syntax.
METHOD <interface~imethod>.
... (Method implementation) ...
ENDINTERFACE.
An example:
INTERFACE i_reservation.
METHODS: book IMPORTING passenger TYPE tpassenger,
cancel IMPORTING passenger TYPE tpassenger
ENDINTERFACE.
SAP AG 237
ABAP Workbench Delta Guide (3.1-4.6)
*HQHULF3URJUDPPLQJ8VLQJ,QWHUIDFH
5HIHUHQFHV
Consider the following coding where two classes, c_flight and c_hotel, both implement
the same interface i_reservation:
INTERFACE i_reservation.
METHODS: book ...
cancel...
ENDINTERFACE.
SAP AG 238
ABAP Workbench Delta Guide (3.1-4.6)
METHOD i_reservation~book.
...
ENDMETHOD.
METHOD i_reservation~cancel.
...
ENDMETHOD.
ENDCLASS.
SAP AG 239
ABAP Workbench Delta Guide (3.1-4.6)
of the methods of the instance oflight. These interface references provide uniform access to
different classes.
Note that you can’t use the create statement for interface references! Your interface reference
can only point to an object reference. (In the example above: You can’t use the statement
CREATE OBJECT iref.)
Classes can implement more than one interface.
You can access the interface component book using CALL METHOD iref->book. Similarly,
you can access an attribute defined in an interface using <iref_variable>-><attr>.
You can book both a flight and a hotel room by making the same call:
CALL METHOD ires->book EXPORTING ... The actual method that is called depends on
the target of the interface reference. You can thus program generically by ’redirecting’ the
reference variable. Now imagine that another class c_rental_car also implements the
interface. Then you simply can book a rental car by making the same call.
Of course you could also call the book method by CALL METHOD oflight1->
<book_method> EXPORTING... and the booking method for hotels by CALL METHOD
ohotel1-> <book_method> EXPORTING ... but then you must know what the methods
are called. For example, it would be possible to call the method book_method for a hotel
using the method name "booking", and the method for a rental car with "bk", but then you
would lose the generic aspect. If, on the other hand, you use interfaces, you only need to
know whether the class defines the interface. If it does, then you know that it must implement
the method ’book’, and you can call it without having to see if it is implemented and find out its
name. This is what makes interface references generic.
The only thing you have to bear in mind with these generic functions is that whatever object
you book, the parameters must be the same. You can get round this by defining parameters
as optional, so you don’t have to pass them to methods that don’t need them.
The interface methods book and cancel appear in different forms. Once where it is
implemented in the class c_flight, and once where it is implemented in the class
c_hotel. This is called SRO\PRUSKLVP. The call is the same in both cases, but the method
implementations are different.
Polymorphism is another term that you can find in almost any books or articles about object
orientation. In ABAP Objects polymorphism is implemented by interfaces. Polymorphism is
independent of classes and inheritance.
Now lets consider another scenario that is more likely to be found in the R/3 System. Assume
you have to write a generic program to archive different objects: FI documents, SD
documents, or customer/vendor master data, to name but a few.
Instead of learning how to archive these different objects and write the appropriate code, you
simply define an interface, let’s call it I_ARCHIVE, with an interface method archive and ask
the appropriate developers to implement that interface method, since they know exactly how
to archive these objects, and how this needs to be implemented if you want to archive it to
microfiche, tape, disk, or any other storage medium.
This makes your archive manager much simpler to use.
You define an internal table itab_ref with interface references to the instances to be archived.
Since you know that all instances implement the interface you know that they all implement a
method i_archive~archive that will be called inside a loop through the internal table.
Here is the code: (incomplete)
INTERFACE i_archive.
METHODS: archive IMPORTING id TYPE ...
ENDINTERFACE.
SAP AG 240
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 241
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUIDFH5HIHUHQFHVWR,QVWDQFHVWKDWDUHWREH$UFKLYHG
5HPRWH/HDUQLQJ
SAP AG
Each entry in the internal table points to an instance that is to be archived. Since each class
of the instances implements the interface i_archive, they must all have implemented an
interface method archive.
&RPSRXQG,QWHUIDFHV
ABAP Objects contains a composition model for interfaces, which you can use to define
interfaces as component interfaces. For example, if compound interfaces did not exist and
you wanted to add method 0 to interface $, you would need to implement this method in all
the classes that have implemented $, regardless of whether or not they need 0. In many
cases, this simply creates more work. To solve this problem, ABAP Objects lets you define
compound interfaces. In the above example, it means that you can define a new interface, %,
that includes the interface $ and the method 0 as components.
In a compound interface, the components of the component interface (attributes and
methods) retain the original names, that is:
<component-interface-name>~<componentname>. They do not have another prefix, such as
the name of the interface in which the component interface is defined. Since all the interfaces
are stored in the same namespace, interface names cannot be duplicated, so that component
names for compound interfaces are unique.
SAP AG 242
ABAP Workbench Delta Guide (3.1-4.6)
&RPSRXQG,QWHUIDFHV([DPSOH
,17(5)$&(OLIBGRF &/$66OFOBKWPOBGRF'(),1,7,21
0(7+2'6HGLW 38%/,&6(&7,21
(1',17(5)$&( ,17(5)$&(6OLIBPDUNXSBGRF
(1'&/$66
,17(5)$&(OLIBPDUNXSBGRF &/$66OFOBKWPOBGRF,03/(0(17$7,21
,17(5)$&(6OLIBGRF 0(7+2'OLIBGRFaHGLW
0(7+2'6LVBZHOOBIRUPHG (1'0(7+2'
(1',17(5)$&( 0(7+2'OLIBPDUNXSBGRFaLVBZHOOBIRUPHG
(1'0(7+2'
(1'&/$66
'$7$LBGRF7<3(5()72OLIBGRF
LBPDUNXSBGRF7<3(5()72OLIBPDUNXSBGRF
KWPOBGRF7<3(5()72OFOBKWPOBGRF
FUHDWHREMHFWKWPOBGRF
LBPDUNXSBGRF KWPOBGRF
LBGRF LBPDUNXSBGRF³1DUURZLQJ&DVW
&$//0(7+2'LBPDUNXSBGRF!OLIBGRFaHGLW
&$//0(7+2'LBGRF!HGLW
&$//0(7+2'KWPOBGRF!OLIBGRFaHGLW
LBPDUNXSBGRF" LBGRF³:LGHQLQJ&DVW
SAP AG 1999
In the above example, we have defined two interfaces, OLIBGRF and OLIBPDUNXSBGRF for
use in document classes The interface OLIBGRF is a component of OLIBPDUNXSBGRF. (see
top left).
The class OFOBKWPOBGRF implements the interface OLIBPDUNXSBGRF with all its methods.
This naturally includes the method HGLW of the interface OLIBGRF. The complete name of
HGLW in OLIBPDUNXSBGRF is OLIBGRFaHGLW (see top right).
At the bottom of the graphic, we have generated an object of the class OFOBKWPOBGRF.
There is no problem with assigning this object to an interface reference, since the relevant
class has implemented this interface. The second assignment, LBGRF LBPDUNXSBGRF, is
also possible, since LBGRF is a reference to OLIBGRF, which is included in the class
definition as part of the interface OLIBPDUNXSBGRF. This assignment is known as narrowing
cast, since the number of components available using the reference LBGRF is reduced (now,
only HGLW can be called from LBGRF).
When the method LBGRF is called using the interface reference LBPDUNXSBGRF, the name of
the interface (where HGLW is declared) must also be entered, since it is possible that the
interface OLIBPDUNXSBGRF also contains a method called HGLW. (The two lines that have
been commented out are also correct statements; they can be used as an alternative in the
above example).
The last assignment is a widening cast. The system can only ascertain at runtime whether or
not this assignment is valid or not, according to which object LBGRF is pointing to. For
example, the assignment would not be valid, if ,BGRF pointed to an object whose class only
implemented the interface OLIBGRF. For this reason, you must use the cast operator ""
(see also ,QKHULWDQFH&DVWV).
SAP AG 243
ABAP Workbench Delta Guide (3.1-4.6)
([HUFLVH'HILQLQJ,PSOHPHQWLQJDQG8VLQJ
,QWHUIDFHV
2EMHFW1DPH'HVFULSWLRQ
,QWHUIDFH
,B9(+,&/( Methods SPEED_UP, STOP, WRITE.Attributes: ID.
,QWHUIDFHPHWKRG
&216758&725 Supply values to the interface attributes ID and MAX_SPEED (see Exercise
2).
,QWHUIDFHPHWKRG
63(('B83 Change the name of the method and its attributes as required. Its function does
not change.
,QWHUIDFHPHWKRG
:5,7(Change the name of the method and attributes as required. Its function does not
change.
,QWHUQDOWDEOH
9(+B7$%Replaces the two previous internal tables.Line type: TYPE REF TO I_VEHICLE.
,QWHUIDFHUHIHUHQFHYDULDEOH
,9(+,&/(Type: TYPE REF TO I_VEHICLE.
'2ORRSV
APPENDinside both DO loops the instance reference variables to the interface reference table.
/223
/223 through WKHLQWHUIDFHUHIHUHQFHWDEOHDQGFDOOWKHPHWKRGV63(('B83:5,7(
6723:5,7(
SAP AG 244
ABAP Workbench Delta Guide (3.1-4.6)
6ROXWLRQ'HILQLQJ,PSOHPHQWLQJDQG8VLQJ
,QWHUIDFHV
**************************************************************
* Simple example of interfaces
**************************************************************
QHZSDUWVDUHPDUNHGEROG
,17(5)$&(LBYHKLFOH
'$7$LG7<3(L5($'21/<
0(7+2'6VSHHGBXS
ZULWH
VWRS
(1',17(5)$&(
*-------------------------------------------------------------
*-------------------------------------------------------------
SAP AG 245
ABAP Workbench Delta Guide (3.1-4.6)
**************************************************************
* Implementations
**************************************************************
CLASS c_ship IMPLEMENTATION.
METHOD constructor.
Inst_id = inst_id + 1.
LBYHKLFOHaLG LQVWBLG
Max_speed = 30.
ENDMETHOD.
0(7+2'LBYHKLFOHaVSHHGBXS
ship_speed = ship_speed + 10.
IF ship_speed > max_speed.
ship_speed = max_speed.
ENDIF.
ENDMETHOD.
0(7+2'LBYHKLFOHaVWRS
ship_speed = 0.
ENDMETHOD.
0(7+2'LBYHKLFOHaZULWH
:5,7(
6KLS,'
LBYHKLFOHaLG
6SHHG
VKLSBVSHHG
ENDMETHOD.
ENDCLASS.
*-------------------------------------------------------------
SAP AG 246
ABAP Workbench Delta Guide (3.1-4.6)
0(7+2'LBYHKLFOHaVWRS
truck_speed = 0.
ENDMETHOD.
0(7+2'LBYHKLFOHaZULWH
:5,7(
7UXFN,'
LBYHKLFOHaLG
6SHHG
WUXFNBVSHHG
ENDMETHOD.
ENDCLASS.
**************************************************************
* Program
**************************************************************
7<3(6UHIBW\SH7<3(5()72LBYHKLFOH
DATA oship TYPE REF TO c_ship.
DATA otruck TYPE REF TO c_truck.
'$7$LYHKLFOH7<3(5()72LBYHKLFOH
'$7$YHKBWDE7<3(7$%/(2)UHIBW\SH
START-OF-SELECTION.
*----------------------------------------
*--- create some instances (ID is set automatically).
DO 2 TIMES.
CREATE OBJECT oship.
$33(1'RVKLS72YHKBWDE
ENDDO.
DO 2 TIMES.
CREATE OBJECT otruck.
$33(1'RWUXFN72YHKBWDE
ENDDO.
SAP AG 247
ABAP Workbench Delta Guide (3.1-4.6)
6.,3
(1'/223
(YHQWV
Here you will learn what events are and how they are used. We will look at triggering,
handling, and registering events.
Firstly, let’s take a look at a simple example that explains the general concept and introduces
the syntax.
(YHQW&RQFHSW
(YHQWV7KH&RQFHSW
5HPRWH/HDUQLQJ
&RQWUROOHU
&RQWUROOHU
%XVLQHVVSODQH
%XVLQHVVSODQH
Mr Smith
/DQGHG
LH Munich
Mrs Jones
$SSODXVH
SAP AG
Instances can announce that their state has changed by triggering events. Events usually
contain export parameters, but never import parameters, since the instance only wants to
announce its change of state - it is not concerned about any further processing.
In the above example, the class business plane can trigger the event e_touch_down, which,
lets assume for our example, has been registered by other classes, and is then handled by
them. For example, if the event is raised the air traffic controller checks off the plane as
landed, the pilot can relax, and passenger Mrs. Jones applauds.
SAP AG 248
ABAP Workbench Delta Guide (3.1-4.6)
Unlike ’normal’ methods, where the caller controls the procedure and knows the method that
have to be called, an instance that triggers an event does not know who will handle it and it’s
not interested in knowing it. Instead, the classes that want to be called tell the trigger by
registering the event with it. So the trigger class is no longer responsible for ensuring that the
event is handled, but the handling classes must explicitly tell the system that they want to
handle a particular event.
This way you can build something that is called ORRVHFRXSOLQJ.
For example, an event may be triggered in the R/3 System for which an external application
had registered itself. The external application starts when the R/3 event occurs. This happens
because the external application had registered itself for the event, not because the R/3
System itself explicitly launched the new application.
(YHQW0RGHO
(YHQW0RGHO
5HPRWH/HDUQLQJ
7ULJJHU +DQGOHU
&/$66F'(),1,7,21 &/$66F'(),1,7,21
38%/,&6(&7,21
38%/,&6(&7,21
(9(176H(;3257,1*9$/8(S 0(7+2'6P)25(9(17H2)F
7<3(L ,03257,1*S
0(7+2'6P
35,9$7(6(&7,21 35,9$7(6(&7,21
'$7$D7<3(L '$7$D7<3(L
(1'&/$66 (1'&/$66
&/$66&,03/(0(17$7,21 &/$66&,03/(0(17$7,21
0(7+2'P 0(7+2'P
D D S
5$,6((9(17H(;3257,1*S D
(1'0(7+2' (1'0(7+2'
(1'&/$66 (1'&/$66
SAP AG
In order to trigger an event, a class must declare the event in its declaration part and trigger it
in its methods.
You declare events in a class or interface using the statement EVENTS <evt> EXPORTING
… VALUE (<ei>) TYPE type [OPTIONAL]. To declare a static event, use the
statement
CLASS-EVENTS <evt> ...
The EXPORTING parameters are always passed by value.
SAP AG 249
ABAP Workbench Delta Guide (3.1-4.6)
If a class contains an instance event, any method of the class can trigger it. Static events can
be triggered by any static method. To trigger an event in a method, use the statement RAISE
EVENT <evt> EXPORTING … <ei> = <fi>...
In the EXPORTING addition, you must specify the actual parameter <fi> for any formal
parameter <ei> that is not defined as optional.
Events are handled by special methods. To handle an event, a method must be declared as
an event handler method for it, and must have registered for the event at runtime.
That was a quick introduction to events and how they are used. Now let’s go back and look at
the process step by step.
'HILQLQJ(YHQWV
SAP AG 250
ABAP Workbench Delta Guide (3.1-4.6)
'HILQLQJDQ(YHQW+DQGOHU
Once you have defined your events and the methods that trigger them, you need to define the
methods that will actually handle the event. These are special methods called handler
methods (often also called handlers or event handlers).
METHODS name FOR EVENT e OF c|if
[ IMPORTING form_par … ]
Any class can contain event handler methods for events of other classes or interfaces. You
declare event handler methods for instance methods using the statement shown above,
where <e> is an event declared in class <c> or interface <if>.
Here is an example:
CLASS c_controller DEFINITION.
PUBLIC SECTION.
METHODS: mark_land_list FOR EVENT e_touch_down OF
c_business_plane
IMPORTING carrid
connid,
permit_start FOR EVENT e_touch_down OF
c_business_plane
IMPORTING carrid
connid,
ENDCLASS.
The interface of an event handler method may only contain formal parameters defined in the
declaration of the event <e>. The attributes of the parameters are also adopted from the
event. However, the event handler method does not have to accept all of the parameters
passed in the RAISE EVENT statement.
If a class declares an event handler method, it and its instances are, in principle, capable of
handling the event <e> that is triggered in an event.
In our example it looks as though we have two event handlers that handle the same event.
The methods mark_land_list to mark landed planes and permit_start to permit other
planes to take off. But this is not actually true: They are both events handlers that handle the
same W\SHof event. You will find out what this actually means in the next section.
5HJLVWHULQJDQG7ULJJHULQJ(YHQWV
So far we have defined and raised an event, and defined and implemented the event handler
methods. Finally, we need to register and trigger the event
To do this, you use the SET HANDLER statement. This statement is more difficult to
understand, since its syntax is fairly complex, so here’s an example straight away:
DATA: lh_munich TYPE REF TO c_business_plane, " Instance that
" triggers an event
no_handle_plane TYPE REF TO c_business_plane,
SAP AG 251
ABAP Workbench Delta Guide (3.1-4.6)
5HOHDVH:
SET HANDLER:handle_inst1->handle_method FOR ALL INSTANCES.
The FOR ALL INSTANCES clause is available from Release 4.5A. Other syntactical options
exist. For further information, refer to the ABAP keyword documentation for the SET
statement.
5HOHDVH:
The SET HANDLER statement does not specify the event for which you are registering. This is
SAP AG 252
ABAP Workbench Delta Guide (3.1-4.6)
defined in the event handler itself (METHODS <meth> FOR EVENT <evt> OF <class> in
the class definition), so specifying it again in the SET HANDLER statement would be
unnecessarily redundant.
Now we have registered our event, we just need to trigger it. This is simple - we just call the
method that raises the event. In our example, this is the following statement:
CALL METHOD lh_munich->landing.
(YHQW+DQGOHU7DEOH
In this section, we are going to look at when and how events are handled internally.
(YHQW+DQGOHU7DEOH
5HPRWH/HDUQLQJ
Handler: contr_mike
+DQGOHUWDEOH
5HIHUHQFHYDULDEOH HBWRXFKBGRZQ(YHQW mark_land
RNEXWWRQ 5HJLVWHUHGKDQGOLQJ _lst
REMHFWPHWKRG
FRQWUBPLNHPDUNBODQGBOLVW
Sender:lh_munich
K
SAP AG
Triggering and handling methods means that certain methods trigger events, while others are
registered as handlers and are executed when the event is raised.
Instances can trigger events while executing a method. The event can then be processed by
‘interested’ instances that have already registered themselves for the event. This registration
is entered in an internal handler table. In the above example, instance controller_mike
has registered the event e_touch_down, and will react to it using method
mark_landed_list.
The handler table is associated with an individual LQVWDQFH not with the FODVVthat
triggers the event. So when the runtime environment knows the instance that triggered the
event, it also knows which handler event to call.
SAP AG 253
ABAP Workbench Delta Guide (3.1-4.6)
Events allow very flexible programming. Unlike structured programming, where a program
explicitly calls an external processing block, a program that triggers an event does not have to
know what will react to it.
You declare events and event handler methods in classes. When an event occurs, the system
looks for registered instances and calls the corresponding source code of the event handler
method.
This is done instantly, and you can see in the Debugger how the appropriate event handler
method is called when an event is raised.
This leads us on conveniently to our next section - how instances are displayed in the
Debugger.
'HEXJJHU
,QVWB,G ,
,B9HKLFOH
,B9HKLFOHa0D[BVSHHG ,
,B9HKLFOHa,G ,
,B9HKLFOHa,G ,
SAP AG
With the filter function you can determine the attributes and interfaces that are displayed (here
all attributes). Icons show the type of attributes. The (YHQW button allows you to display the
SAP AG 254
ABAP Workbench Delta Guide (3.1-4.6)
events that the instance can trigger, along with the handler method registered for the event
triggered by the instance.
5HOHDVH:
Events can only be displayed in the Debugger after the SET HANLDER statement has been
processed.
It is not currently possible to display static events.
([HUFLVH'HILQLQJ5DLVLQJDQG5HJLVWHULQJ
(YHQWV
1. Define and implement an event BOILER_EXPLODES in the class C_SHIP that should be
raised when the method SPEED_UP increases the speed of a ship beyond the permitted
maximum.
2. Define and implement a class C_RESCUE_EVENT with the handler method
ALARM_CLOCK. Inside the method raise a message.
3. Create a handler instance ORESC.
4. Call four times the method SPEED_UP for instance OSHIP to raise the event.
2EMHFW1DPH'HVFULSWLRQ
(YHQWGHILQLWLRQ
%2,/(5B(;3/2'(6for class C_SHIP
(YHQWUDLVLQJ
in the method SPEED_UPof class C_SHIP raise the event, if SHIP_SPEED exceeds
MAX_SPEED
(YHQWKDQGOHUFODVVGHILQLWLRQ
Class &B5(6&8(B(9(17with public method $/$50B&/2&.
(YHQWKDQGOHUFODVVLPSOHPHQWDWLRQ
Method $/$50B&/2&.send information message ’STOP! Maximum speed exceeded’ and
set SHIP_SPEED to 0.
&UHDWHLQVWDQFH25(6&
create instance ORESC TYPE REF TO C_RESCUE_EVENT.
5HJLVWHULQJRIHYHQW
Inside the DO loop where instances of class C_SHIP are created, register each instance oship
for the event.
5DLVLQJWKHHYHQW
Inside the loop over the interface reference call four times the method SPEED_UP.
SAP AG 255
ABAP Workbench Delta Guide (3.1-4.6)
6ROXWLRQ'HILQLQJ5DLVLQJDQG5HJLVWHULQJ
(YHQWV
**************************************************************
*Simple example for events definition, raising and registering
**************************************************************
******* QHZSDUWVDUHPDUNHGEROG**************
INTERFACE i_vehicle.
DATA: id TYPE i READ-ONLY.
METHODS: speed_up,
write,
stop.
ENDINTERFACE.
*-------------------------------------------------------------
*-------------------------------------------------------------
SAP AG 256
ABAP Workbench Delta Guide (3.1-4.6)
ENDCLASS.
&/$66FBUHVFXHBHYHQW'(),1,7,21
38%/,&6(&7,21
0(7+2'6DODUPBFORFN
(1'&/$66
**************************************************************
* Implementations
**************************************************************
*-------------------------------------------------------------
SAP AG 257
ABAP Workbench Delta Guide (3.1-4.6)
max_speed = 130.
ENDMETHOD.
METHOD i_vehicle~speed_up.
CHECK truck_speed < max_speed.
truck_speed = truck_speed + 50.
ENDMETHOD.
METHOD i_vehicle~stop.
truck_speed = 0.
ENDMETHOD.
METHOD i_vehicle~write.
WRITE: / ’Truck: ID = ’, i_vehicle~id, ’ Speed = ’,
truck_speed.
ENDMETHOD.
ENDCLASS.
&/$66FBUHVFXHBHYHQW,03/(0(17$7,21
0(7+2'DODUPBFORFN
5$,6(0(66$*(,%&75$,1:,7+
67230D[LPXPVSHHGH[FHHGHGIRU,QVWDQFH
V\LQGH[
VKLSBVSHHG
(1'0(7+2'
(1'&/$66
**************************************************************
* Program
**************************************************************
START-OF-SELECTION.
DO 2 TIMES.
SAP AG 258
ABAP Workbench Delta Guide (3.1-4.6)
&ODVV%XLOGHU
For further information about the Class Builder, refer to the online documentation
&ODVV%XLOGHU)HDWXUHV
SAP AG 259
ABAP Workbench Delta Guide (3.1-4.6)
7KH&ODVV%XLOGHU
5HPRWH/HDUQLQJ
&ODVV%XLOGHU
0DLQWHQDQFHRI
0DLQWHQDQFHRI
%DVLF'DWD
%DVLF'DWD
&ODVV%URZVHU
&ODVV(GLWRU
&ODVV(GLWRU
,QLWLDO6FUHHQ
,QLWLDO6FUHHQ
$%$3(GLWRU
$%$3(GLWRU &ODVV/LEUDU\
7HVW(QYLURQPHQW
7HVW(QYLURQPHQW
Direct Branching
Data Flow
SAP AG
&ODVV%XLOGHU,QLWLDO6FUHHQ
This section introduces the Class Builder and describes how to create a new class or
interface.
SAP AG 260
ABAP Workbench Delta Guide (3.1-4.6)
&ODVV%XLOGHU,QLWLDO6FUHHQ
5HPRWH/HDUQLQJ
Class Browser
SAP AG
To start the Class Builder from the initial screen of the ABAP Workbench, choose
'HYHORSPHQW → &ODVV%XLOGHU. (The transaction code is SE24.)
On the initial screen, you can choose to create, change, display, or test a class.
When you create a new class or interface, a dialog box appears in which you have to enter
administrative details like the development class and change request. After this, the class
editor appears. This is where you create and edit the components of classes and interfaces.
If you do not designate your class as 2QO\PRGHOHG, the system automatically generates its
source code in a class pool.
From Release 4.5A, interfaces must be public, hence the default setting for the visibility
attribute.
([HUFLVH'HILQLQJ*OREDO&ODVVHVDQG
,QWHUIDFHV
You are now going to repeat the exercises you have already done, but this time using global
classes and interfaces.
1. Create the classes ZCL_SHIP, ZCL_TRUCK and the Interface ZI_VEHICLE.
2. Create a class ZCL_RESCUE_EVENT.
3. Enter the required data for description, development class and change request.
SAP AG 261
ABAP Workbench Delta Guide (3.1-4.6)
The components of the classes and interfaces will be defined and implemented in the
next exercise
6ROXWLRQ'HILQLQJ*OREDO&ODVVHVDQG
,QWHUIDFHV
'HILQLQJ&RPSRQHQWV
'HILQLQJ&RPSRQHQWV0HWKRGV([DPSOH
5HPRWH/HDUQLQJ
Local Class
Class =&/B6+,3
Status Implemented
3DUDPHWHUV ([FHSWLRQV 6RXUFH&RGH
SAP AG
You use the class editor to maintain the attributes, methods, events, and local types of a class
or interface.
You can also maintain local (auxiliary) classes that might be needed in a global class.
All components are in the same namespace. Therefore they all must have different names.
In the example above all methods of a class zcl_ship are displayed. You can define new
components by choosing the required component type on the screen.
SAP AG 262
ABAP Workbench Delta Guide (3.1-4.6)
For example, to define a method (see illustration above) you have to enter the name of the
method and a description. You can enter the type of the method (instance or static) together
with the visibility (public, protected or private) directly on this screen, or double-click the
method and enter the data in a separate dialog box. For methods you also have to define the
parameters. Similarly to function modules, methods can have importing, exporting, changing,
and returning parameters. You can also pass them by value or reference, assign them default
values, and define them as optional. In general you also have exceptions which must also be
defined with the appropriate function.
Finally the method must be implemented. To do this, choose ’source code’. The Class Builder
automatically opens the ABAP Editor. (Note: in Release 4.5A you must save the method
definition before you can edit the source code).
For further information about how to create and maintain attributes, events, and internal
types, refer to the online documentation .
([HUFLVH'HILQLQJ*OREDO&ODVVHVDQG
,QWHUIDFHV
1. For the classes ZCL_SHIP and ZCL_TRUCK, define the interface ZI_VEHICLE. The
interfaces consists of the instance attributes: VEH_SPEED, MAX_SPEED, ID and the
instance methods: STOP, WRITE, SPEED_UP.
2. Define and implement for the class ZCL_RESCUE_EVENT the public instance method
ALARM_CLOCK.
3. For the class ZCL_SHIP, define and implement the public interface ZI_VEHICLE, the
private class attribute: INST_COUNT and the public instance method CONSTRUCTOR and
public event BOILER_EXPLODES.Write the program Z_OO_ EVENT to use the global
classes and interface.
2EMHFW1DPH'HVFULSWLRQ
,QWHUIDFHLQVWDQFHDWWULEXWHV
9(+B63(('vehicle speed: Type i
0$;B63(('maximum speed: Type i
,'vehicle Id: Type i
,QWHUIDFHLQVWDQFHPHWKRGV
6723stop :5,7(display attributes
63(('B83 go faster
&ODVVHV=&/B6+,3=&/B758&.GHILQLWLRQ
Interface =,B9(+,&/( private static attribute: ,167B&2817instance counter: Type I public
instance method: &216758&725 public instance event: %2,/(5B(;3/2'(6
&ODVV=&/B6+,3=&/B758&.LPSO
Public interface methods: 6723:5,7(63(('B83 see exercises 2 and 3 In the method
SPEED_UP the event BOILER_EXPLODES should be raised if VEH_SPEED exceeds
MAX_SPEED. Public instance method: CONSTRUCTOR: see exercise 2.
&ODVV=&/B5(6&8(B(9(17GHILQLWLRQ
Public instance event handler method: $/$50B&/2&. see exercise 4
SAP AG 263
ABAP Workbench Delta Guide (3.1-4.6)
2EMHFW1DPH'HVFULSWLRQ
,QVWDQFH25(6&8(
define and create instance 25(6&8( TYPE REF TO ZCL_RESCUE_EVENT.
,QVWDQFH26+,3
define instance 26+,3 TYPE REF TO ZCL_SHIP.
,QWHUIDFHUHIHUHQFHYDULDEOH
,9(+,&/(Type: TYPE REF TO I_VEHICLE.
,QWHUQDOWDEOH
define internal table 9(+B7$%with: TYPE REF TO ZI_VEHICLE
'2/RRS
Inside a '2ORRS:
a) create the instance OSHIP and
b) append the reference variables to the interface reference table VEH_TAB and
c) register the instance ORESCUE for the event
5DLVLQJWKHHYHQW
Inside a second '2ORRSover the interface reference call four times the method SPEED_UP
and once the method WRITE
6ROXWLRQ'HILQLQJ*OREDO&ODVVHVDQG
,QWHUIDFHV
**************************************************************
* Simple example of events in global classes
**********************************************************
class zcl_ship_event definition load.
class zcl_rescue_event definition load.
**************************************************************
SAP AG 264
ABAP Workbench Delta Guide (3.1-4.6)
* Program
**************************************************************
start-of-selection.
data oship type ref to zcl_ship_event.
data orescue type ref to zcl_rescue_event.
data ivehicle type ref to zi_vehicle.
data veh_tab type ref to zi_vehicle occurs 0.
do 2 times.
create object oship.
append oship to veh_tab.
set handler: orescue->alarm_clock for oship.
enddo.
*---- speed up and write
loop at veh_tab into ivehicle.
call method ivehicle->speed_up.
call method ivehicle->speed_up.
call method ivehicle->speed_up.
call method ivehicle->speed_up.
call method ivehicle->write.
skip.
endloop.
&ODVV%XLOGHU7HVW0RGH
The test mode allows to test your classes and interfaces without having to write a program
from which to call them.
For further information, refer to the ’Testing’ section of the Class Builder documentation.
See here
6WDUWLQJWKH7HVW0RGH
SAP AG 265
ABAP Workbench Delta Guide (3.1-4.6)
6WDUWLQJWKH7HVW0RGH
Test Class ZCL_SHIP 5HPRWH/HDUQLQJ
Handler
7HVW2EMHFW!
8SSHUORZHUFDVHDFWLYH
=&/B6+,3 =&/B6+,3!
5 ,QWHUIDFHV
=,B9(+,&/(
$WWULEXWHV
0HWKRGV
SAP AG
You use the test environment to test all components of a class. A dynamic ABAP test
program will be generated, which simulates the execution of the components.
Note: You can only test the public components of classes.
Once you have started the test environment for a class, all of its components are displayed in
a tree structure (see illustration above).
First a test instance named TestObject is created. This executes the constructor method if
your class has one. If the constructor method requires input data, a dialog box will appear in
which you can enter it.
7HVWLQJ&RPSRQHQWV
7HVWLQJ&RPSRQHQWV$WWULEXWHVDQG0HWKRGV
([DPSOH
SAP AG 266
ABAP Workbench Delta Guide (3.1-4.6)
7HVWLQJ$WWULEXWHVDQG0HWKRGVLQWKH&ODVV%XLOGHU
Test Interface ZI_VEHICLE 5HPRWH/HDUQLQJ
Handler
7HVW2EMHFW!=,B9(+,&/(a
8SSHUORZHUFDVHDFWLYH
=,B9(+,&/( =&/B758&.!
5 $WWULEXWHV
9(+B63(('
0$;B63((' Enter new
,'
values
5 0HWKRGV
6723
:5,7(
63(('B83
Execute icon
SAP AG
If an attribute has an entry field next to it, you can change it simply by entering a new value. If
an attribute is a reference to another instance, the system transfers you to that instance. You
can then click on the attribute there to display or change it.
To test methods, choose ([HFXWH.. If the method has importing parameters, they are
displayed so you can change them. Once you have edited the parameters, the method is
executed. Methods without importing parameters are executed immediately. This simulates a
CALL METHOD statement for the instance. If your method triggers an exception, a dialog box
appears containing the exception and the error text.
You can also run the method in the Debugger by choosing 8WLOLWLHV → 'HEXJJLQJ.
7HVWLQJ(YHQWV
Suppose the class ZCL_SHIP defines an event BOILER_EXPLODES that should be raised in
the method SPEED_UP if the call of SPEED_UP speeds up the ship beyond its MAX_SPEED. To
do so you define and implement the event (see below).
SAP AG 267
ABAP Workbench Delta Guide (3.1-4.6)
'HILQLQJLQWKH&ODVV%XLOGHU
5HPRWH/HDUQLQJ
6WRS
6WRS
6WRS
3DUDPHWHUV ([FHSWLRQV 6RXUFH&RGH
SAP AG
When the event is triggered let’s assume that another class ZCL_RESCUE_EVENT defines
and implements a handler method ALARM_CLOCK that only raises a message (for the sake of
simplicity).
SAP AG 268
ABAP Workbench Delta Guide (3.1-4.6)
'HILQLQLQJ+DQGOHU0HWKRGVLQWKH&ODVV%XLOGHU
5HPRWH/HDUQLQJ
6WRS
6WRS
6WRS
SAP AG
The event handling in the test mode is executed with a standard handler method that is
executed when an event is triggered. The test mode simulates a relation of handler methods
and trigger method, through a generated SET HANDLER statement. For more information, see
the next illustration.
5HJLVWHULQJDQ(YHQW
SAP AG 269
ABAP Workbench Delta Guide (3.1-4.6)
7HVWLQJ(YHQWVLQWKH&ODVV%XLOGHU5HJLVWHULQJ
5HPRWH/HDUQLQJ
Handler
7HVW2EMHFW!
Position cursor on an event
8SSHUORZHUFDVHDFWLYH and press the Handler button
=&/B6+,3B(9(17 =&/B6+,3B(9(17!
5 ,QWHUIDFHV
=,B9(+,&/(
$WWULEXWHV
0HWKRGV
5 (YHQWV
%2,/(5B(;3/2'(6
SAP AG
To generate this statement you have to position the cursor on an event and choose the
’Handler’ function.
An new icon in front of the event shows that the handler is active.
5DLVLQJDQ(YHQW
To raise the event you have to execute the method that triggers the event in the way
described above (here the interface method SPEED_UP).
If the event is raised successfully the event is displayed like in the next illustration with all
export parameters and the sender instance (here instance 1 of class ZCL_SHIP_EVENT).
SAP AG 270
ABAP Workbench Delta Guide (3.1-4.6)
7HVWLQJ(YHQWVLQWKH&ODVV%XLOGHU(YHQWUDLVLQJ
5HPRWH/HDUQLQJ
%2,/(5B(;3/2'(6
5 ([SRUWSDUDPV
6(1'(5 =&/B6+,3B(9(17!
SAP AG
see also
6XPPDU\
In this unit you have learned about object-oriented programming with ABAP Objects. Object
orientation allows you to create programs that are easier to maintain and have a better
structure.
ABAP Objects supports all of the significant characteristics of object orientation, such as
encapsulation, interfaces and events.
6XPPDU\RI6\QWD[
At the end you’ll find a summary of the syntax we covered so far. For more details and
examples refer to the relevant ABAP keyword documentation.
D 'HILQLQJDQG,PSOHPHQWLQJ&ODVVHV
CLASS <class> DEFINITION.
PUBLIC SECTION.
... 'HILQLWLRQRISXEOLFFRPSRQHQWV
SAP AG 271
ABAP Workbench Delta Guide (3.1-4.6)
PROTECTED SECTION.
... 'HILQLWLRQRISURWHFWHGFRPSRQHQWV
PRIVATE SECTION.
... 'HILQLWLRQRISULYDWHFRPSRQHQWV
ENDCLASS.
CLASS <class> IMPLEMENTATION.
... 0HWKRGLPSOHPHQWDWLRQ
ENDCLASS.
E 'HFODULQJ,QVWDQFH$WWULEXWHV
DATA <attr> TYPE <type>
[ VALUE <val> ].
[ READ-ONLY ]. “ 5HOHDVH
F 'HFODULQJ6WDWLF$WWULEXWHV
CLASS-DATA <attr> TYPE <type>
[ VALUE <val> ].
[ READ-ONLY]. “ 5HOHDVH
G 'HFODULQJ0HWKRGV
METHODS <meth>
IMPORTING .. VALUE(<i>)| <i> TYPE type [OPTIONAL] ..
EXPORTING .. VALUE(<e>)| <e> TYPE type [OPTIONAL] ..
CHANGING .. VALUE(<c>)| <c> TYPE type [OPTIONAL] ..
RETURNING VALUE(<r>)
EXCEPTIONS .. <exc> ..
H ,PSOHPHQWLQJ0HWKRGV
METHOD <meth>.
... Implementation ...
ENDMETHOD.
I &DOOLQJ0HWKRGV
CALL METHOD <obj>-><method> EXPORTING <formal_e> = <actual_e>
IMPORTING <formal_i> = <actual_i>
CHANGING <formal_c> = <actual_c>
RECEIVING r = h
EXCEPTIONS <exc_i> = rc_i.
J 'HFODULQJD&RQVWUXFWRU0HWKRG
METHODS CONSTRUCTOR
[ IMPORTING VALUE(arg1) TYPE type … ].
K &DOOLQJD&216758&7250HWKRG5HOHDVH
CREATE OBJECT <instance>->constructor
[EXPORTING VALUE(arg1) = <value1> ...
L &UHDWLQJ2EMHFWV
DATA: <instance_variable> TYPE REF TO <class>.
SAP AG 272
ABAP Workbench Delta Guide (3.1-4.6)
Variants:
1. SET HANDLER <h1> ... <hn> FOR <ref>.
2. SET HANDLER <h1> ... <hn> FOR ALL INSTANCES.
3. SET HANDLER <h1> ... <hn>.
SAP AG 273
ABAP Workbench Delta Guide (3.1-4.6)
/RJLFDO'DWDEDVH
After reviewing the following topics, you will be able to:
Explain Logical Database requirements for recallibility
Use function module LDB_PROCESS to call Logical Databases
Adjust Logical Databases for recallibility
SAP AG 274
ABAP Workbench Delta Guide (3.1-4.6)
,QWURGXFWLRQDQG2YHUYLHZ
Up until now, a logical database could only be used with type 1 programs. The name of the
logical database had to be entered in the program attributes so that programs had access to
GET events. Another disadvantage was the fact that a logical database could not be used
with interactive reports or module pools. From Release 4.5, you can use the new function
module LDB_PROCESS to process logical databases (0XOWLSOH&DOOV).
see also
/RJLFDO'DWDEDVH5HTXLUHPHQWV
Logical databases can be called by function module LDB_PROCESS only once. However, if
you want to process the same logical database multiple times during program flow, then you
must DGMXVW\RXUGDWDEDVHSURJUDP to provide this functionality.
If a logical database is entered in your program attributes and re-called using function
module LDB_PROCESS, the system does not regard this as a multiple call. A multiple call
occurs for example when LDB_PROCESS is called during an interactive event and the user
executes a double-click more than once.
/'%VDQG3URJUDPV&ODVVLF6FHQDULR
5HPRWH/HDUQLQJ
352*5$06$3'%)6 5(3257
6WUXFWXUH '(),1,1*'$7$%$6()6
12'(6VSIOLVIOLJKWVERRN
63)/, )250387B63)/,
6(/(&7
)52063)/,
3URFHVVLQJRI63)/,UHFRUGV
38763)/, *(7VSIOL
(1'6(/(&7
(1')250
6)/,*+7 )250387B6)/,*+7
6(/(&7
)5206)/,*+7
3URFHVVLQJRI6)/,*+7UHFRUGV
3876)/,*+7 *(7VIOLJKW
(1'6(/(&7
(1')250
6%22. )250387B6%22.
6(/(&7
)5206%22.
3URFHVVLQJRI6%22.UHFRUGV
3876%22. *(7VERRN
(1'6(/(&7
(1')250
SAP AG
At the PUT event, your database program surrenders control to a GET event. Its ABAP
statements are processed sequentially and then, at the end of the event block, control is
SAP AG 275
ABAP Workbench Delta Guide (3.1-4.6)
returned to the logical database. Logical databases always call and process events in the
sequence prescribed by the structure.
see also
/'%VDQG3URJUDPV8VLQJ)XQFWLRQ0RGXOH/'%B352&(66
5HPRWH/HDUQLQJ
352*5$06$3'%)6 5(3257
6WUXFWXUH '(),1,1*'$7$%$6()6
)250&$//B%$&.B63)/,XVLQJ
63)/,
)250387B63)/, QDPHOLNHOGEQOGEQRGH
6(/(&7
)52063)/, ZRUNDUHDW\SHVSIOL
38763)/, PRGHW\SHF
(1'6(/(&7 VHOHFWHGW\SHF
(1')250
(1')250
)250387B6)/,*+7 )250&$//B%$&.B6)/,*+7
6)/,*+7 6(/(&7
)5206)/,*+7
XVLQJ
3876)/,*+7
(1'6(/(&7 (1')250
(1')250
)250387B6%22. )250&$//B%$&.B6%22.
6(/(&7
)5206%22. XVLQJ
6%22.
3876%22.
(1'6(/(&7 (1')250
(1')250
SAP AG
At the PUT event, your database program surrenders control to a callback routine. Its
ABAP statements are processed sequentially and then, at ENDFORM, control is returned to the
logical database. Logical databases always call and process events in the sequence
prescribed by the structure.
see also
:KDW6WHSV'R,+DYHWR7DNHLQ2UGHUWR%H
$EOHWR3URFHVV0\/RJLFDO'DWDEDVH8VLQJ
/'%B352&(66"
'DWD'HFODUDWLRQ
SAP AG 276
ABAP Workbench Delta Guide (3.1-4.6)
6SHFLI\LQJ:KLFK1RGHV$UHWR%H3URFHVVHG
You must create an internal table and a table work area based on the ABAP Dictionary
structure ldbcb. This table will be filled with the names of the nodes you want to process and
the name of the callback routine.
([DPSOH'HFODULQJDQG)LOOLQJWKH,QWHUQDO7DEOH
data: call_back_tab like standard table of ldbcb,
wa_call_back like ldbcb.
wa_call_back-ldbnode = ’SPFLI’.
wa_call_back-get = ’X’.
wa_call_back-get_late = ’ ’.
wa_call_back-cb_prog = sy-cprog.
wa_call_back-cb_form = ’CALL_BACK_SPFLI’.
append wa_call_back to call_back_tab.
What do the individual table fields used above mean?
LDBNODE: Name of the node to be processed
GET ‘X’: Process the node named above
(NOT the EVENT)
GET_LATE ‘X’: Process the node named above
(NOT the EVENT)
CB_PROG: Name of the program where the callback routine can be found
CB_FORM: Name of the callback routine you want to call
)LOOLQJWKH6HOHFWLRQ6FUHHQ
Whenever you call a logical database, you must ensure that the selection screen is provided
with valid parameters (values). An internal table and a table work area based on the ABAP
Dictionary structure rsparams must be created. This table is used to pass selection criteria
to your logical database.
([DPSOH'HFODULQJDQG)LOOLQJWKH,QWHUQDO7DEOH
data: sel_tab like standard table of rsparams,
wa_sel_tab like rsparams.
SAP AG 277
ABAP Workbench Delta Guide (3.1-4.6)
&DOOLQJWKH)XQFWLRQ0RGXOH
Function module LDB_PROCESS should be programmed in the ABAP Editor using the
sample statements available. This allows the entire interface to be generated in the
corresponding program automatically.
The name of the database you want to read from must be specified in the interface, as well as
the name of the internal table with the nodes that are to be processsed. If the selection table
remains empty, this means that all data for the specified nodes is read from the database.
&DOO%DFN5RXWLQHV
6DPSOH&DOOLQJ/'%YLD)XQFWLRQ0RGXOH
*&-----------------------------------------------------------*
*& Report ZCALL_LDB_SIMPLE
*& *
*&-----------------------------------------------------------*
*& *
*& *
*&-----------------------------------------------------------*
REPORT ZCALL_LDB_SIMPLE .
* Tables needed for function module LDB_PROCESS
DATA CALL_BACK_TAB LIKE STANDARD TABLE OF LDBCB.
DATA SEL_TAB LIKE STANDARD TABLE OF RSPARAMS.
* Work areas
SAP AG 278
ABAP Workbench Delta Guide (3.1-4.6)
END-OF-SELECTION.
* Check field for valid line selection
CLEAR WA_SCARR-CARRID.
AT LINE-SELECTION.
* Check valid line selection
CHECK NOT WA_SCARR-CARRID IS INITIAL.
* Creation of call back table
WA_CALL_BACK-LDBNODE = ’SPFLI’.
WA_CALL_BACK-GET = ’X’.
WA_CALL_BACK-GET_LATE = ’ ’.
WA_CALL_BACK-CB_PROG = SY-CPROG.
WA_CALL_BACK-CB_FORM = ’CALL_BACK_SPFLI’.
APPEND WA_CALL_BACK TO CALL_BACK_TAB.
CLEAR WA_CALL_BACK.
WA_CALL_BACK-LDBNODE = ’SFLIGHT’.
WA_CALL_BACK-GET = ’X’.
WA_CALL_BACK-CB_PROG = SY-CPROG.
WA_CALL_BACK-CB_FORM = ’CALL_BACK_SFLIGHT’.
APPEND WA_CALL_BACK TO CALL_BACK_TAB.
SAP AG 279
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 280
ABAP Workbench Delta Guide (3.1-4.6)
ENDFORM.
$GMXVWLQJWKH/RJLFDO'DWDEDVH
In order to allow a logical database to be processed multiple times using function module
LDB_PROCESS, you must insert an additional form routine in your database program.
*------------------------------------------------------------*
* FORM LDB_PROCESS_INIT *
*------------------------------------------------------------*
FORM LDB_PROCESS_INIT CHANGING LDB_SUBRC LIKE SY-SUBRC.
LDB_SUBRC = 0.
ENDFORM.
Whenever logical databases that do not contain this form routine are called multiple
times, the system responds with runtime error LDB_NOT_REENTRANT.
SAP AG 281
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH)XQFWLRQ&DOO
After reviewing the following topics, you will be able to:
Understand the concept of.trusting/trusted relationships between R/3 systems
SAP AG 282
ABAP Workbench Delta Guide (3.1-4.6)
7UXVWLQJ7UXVWHG5HODWLRQVKLSVEHWZHHQ5
6\VWHPV
,QWURGXFWLRQ
Prior to Release 4.0, R/3-to-R/3 RFC connections where the RFC destination was not used
interactively required you to store the UHPRWHFOLHQW, UHPRWHXVHU and UHPRWHSDVVZRUG for
UHPRWH5)&ORJLQ in the destination and automatically send it to the remote system when the
connection was established. Since this type of storing and transferring passwords represents
a certain risk, SAP has implemented the concept of WUXVWLQJWUXVWHG systems for Release
4.0. The idea behind this concept is to allow certain "privileged" users of the RFC-calling
system to log on without a password if a trust relationship is defined between two R/3
Systems. This eliminates the need for storing and transferring passwords in cases in which a
trust relation exists and a "privileged" user establishes an RFC connection to the remote
system by means of an RFC destination that does not require a password.
7KH7UXVWLQJ7UXVWHG&RQFHSW
2YHUYLHZ
5HPRWH/HDUQLQJ
7UXVWLQJ7UXVWHG6\VWHPV
56\VWHP$ 56\VWHP%
7UXVWHG6\VWHP 7UXVWLQJ6\VWHP
7UXVW'HVWLQDWLRQ 8VHU3URILOH
6PLWK
Remote System
Remote Client 5)&/RJRQ Authority
Remote User Smith ZRSDVVZRUG of Object
Logon Language S_RFCACL
$FWLYH8VHU
5\DQ 5)&
Function
ABAP Program Module
SAP AG
SAP AG 283
ABAP Workbench Delta Guide (3.1-4.6)
7HFKQLFDO'HWDLOV
'HILQLQJD7UXVW5HODWLRQVKLS
You define a trust relationship between two R/3 Systems in the system that is to become the
trusting system. To do this, call transaction 607 (or 60!5)&!7UXVWHGV\VWHPV). This
transaction defines a trusted system in the trusting system. You must specify a normal RFC
destination for the trusted system that is used to inform the trusted system of the trust
relationship and automatically create a trust destination to the trusting system there. When
transaction SMT1 is completed, the trust relationship is defined.
From the trusted system, you can use transaction SMT2 (or choose 60!5)&!7UXVWLQJ
V\VWHPV) to display all trusting systems for this system. The current client, the current user
and the current logon language are used to perform a trust logon to the trusting system based
on the trust destination that was generated automatically when the trust relationship was
defined. Whether the trust logon is successful, depends on whether or not the remote logon
user (= the current user) has an appropriate authorization for authorization object S_RFCACL
in the trusting system (see ’Using Authorization Object S_RFCACL’). The result of the test
trust logon is also displayed in the trusting systems list.
'HILQLQJD7UXVW'HVWLQDWLRQ
An RFC connection from the trusted system to the trusting system can be established either
by means of a normal password-protected destination or a trust destination without password.
It is true that a trust destination is automatically created in the trusted system when the trust
SAP AG 284
ABAP Workbench Delta Guide (3.1-4.6)
relationship is defined. However, this destination always uses the current user for the trust
logon. In order to use other remote logon users, you must create additional trust destinations
in 60. There, you must select the 7UXVWHGV\VWHP indicator in the 6HFXULW\RSWLRQV for
the destination. Also, you must specify the remote system (= trusting system), the remote
client, the remote logon user, and the remote logon language.
8VLQJ$XWKRUL]DWLRQ2EMHFW6B5)&$&/
2EMHFW6B5)&$&/
2EMHFW6B5)&$&/
)LHOGV $XWKRULW\H[DPSOH
5)&B6<6,' 5)&B6<6,' $$$
5)&B&/,(17 5)&B&/,(17
5)&B86(5 5)&B86(5 5<$1
5)&B(486(5 5)&B(486(5 12
5)&B7&2'( 5)&B7&2'(
5)&B,1)2 5)&B,1)2
$&797 $&797
SAP AG
SAP AG 285
ABAP Workbench Delta Guide (3.1-4.6)
For example, if user SMITH of the trusting system has the authorization illustrated in the
graphic above, user 5<$1 may use remote user SMITH as a logon user for a trust logon
without password from client of trusted system $$$ from within any transaction.
If field (486(5 were set to value <(6, not only RYAN but also user SMITH of the trusted
system would be allowed to perform the trust logon without password.
SAP AG 286
ABAP Workbench Delta Guide (3.1-4.6)
'LDORJV
After reviewing the following topics, you will be able to:
Describe the news on input/output elements
Use selection screens as subscreens
Implement Tabstrip Controls on selection screens
Describe name changes in ABAP Workbench tools
Create and use Context Menus
SAP AG 287
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ
1HZVRQ,QSXW2XWSXW(OHPHQWV
In Release 4.6 you can use a dropdown listbox as input help for I/O fields. It offers the user a
predefined set of entries to choose from for input. Moreover, it is possible to show not the
value but the corresponding describing text on screen. There are several ways to create the
value list. The easiest one is it to use the standard input help. Alternatively, use the Process
on Value request (POV) or the Process Before Output (PBO). For the implementation see
DropDown Listboxes for Input Fields [Seite 288].
Moreover, you can assign a function (function code, function type) to a dropdown listbox, a
checkbox or a radiobutton. Then the corresponding screen element triggers the Process After
Input (PAI), so that it is possible to react directly to the user’s input. For the implementation
and examples of use see PAI Event for Input/Output Screen Elements [Seite 290].
'URSGRZQ/LVWER[HVIRU,QSXW)LHOGV
'HVFULSWLRQ
As input help for an I/O field on a screen you can use a dropdown box. Then the user gets a
list of all possible entries in the corresponding fields. Users must select an entry from the list.
Moreover, you can not use any other input help at the same time. If you assign a function
(function code, function type) to a dropdown listbox, then it will trigger the PAI after loading
the function code into the field sy-ucomm and the command field of the underlying screen. So
you can react directly to the user’s input.
SAP AG 288
ABAP Workbench Delta Guide (3.1-4.6)
'URSGRZQ/LVWER[
,PSOHPHQWDWLRQ
In order to implement an I/O field with a dropdown box:
1. In the Screen Painter, define the I/O field.
2. Set the attribute 'URSGRZQ to /LVWER[.
3. Increase the attribute YLV/HQJWK to the appropriate text length.
4. Set the program attribute 9DOXHOLVW according to the method of finding the displayed
values.
5. Set the function code and function type if PAI processing is intended.
There are several methods for finding the displayed values:
8VLQJDVWDQGDUGLQSXWKHOS This is the easiest way of getting a list of values for your
dropdown listbox. You can use it if the domain in the data dictionary possesses fixed values
or a two-column check table. Then you set the program attribute 9DOXHOLVW to space.
8VLQJD329KHOSYou must find the values within a module belonging to the corresponding
field that has been called in the Process On Value request. Within this module, you call the
function module ‘F4IF_INT_TABLE_VALUE_REQUEST’. This function module passes the
values to the help processor that is responsible for displaying the dropdown list. Note that if
you want to sort the list, you need to specify this beforehand. You must also set the program
attribute 9DOXHOLVW to space.
There is a further method to call a function module within a module at PBO, but this method
does not work with all frontends. For more information see the online documentation .
SAP AG 289
ABAP Workbench Delta Guide (3.1-4.6)
'URSGRZQ/LVWER[LQWKH/D\RXW(GLWRURIWKH6FUHHQ3DLQWHU
6HWWLQJ/LVWER[
(QODUJH
9LV/HQJKW
)XQFWLRQFRGH
IRU3$,
'HILQLWLRQRIWKH
,2ILHOG
9DOXHOLVW
SAP AG 1999
8VH
Use dropdown listboxes only for input fields that do not have too many possible entries. Since
all possible entries will be displayed, scrollbars will appear if necessary. Sorting or reducing
the value set by the user is not supported so that it is difficult to control large datasets.
The main criterion must be that a dropdown listbox improves the usability of the program. So
it makes no sense to use a dropdown listbox for instance for currency fields, since the
corresponding keys are common knowledge to users.
There are some technical conditions that must be fulfilled for using dropdown listboxes.
• There must be a unique relationship between texts and keys.
• The value set consists of one column (key) or two columns (key and text).
• The value set does not depend on the value of input fields.
3$,(YHQWIRU,QSXW2XWSXW6FUHHQ(OHPHQWV
'HVFULSWLRQ
In order to react directly to the user’s input, you can assign functions to checkboxes, radio
button groups, or dropdown listboxes. Then the corresponding user action – that is, clicking
the checkbox, clicking the radio button or choosing an entry from the dropdown listbox – will
trigger the PAI and the corresponding function code will be copied into the system field sy-
ucomm as well as the command field of the current screen. If you do not use function type
SAP AG 290
ABAP Workbench Delta Guide (3.1-4.6)
space but rather ‘T’ or ‘E’, the system will start the transaction with a transaction code that is
equal to the function code or the PAI module ... AT EXIT COMMAND, as appropriate.
8VH
This section describes a typical scenario for using this technique.
The main aim of using PAI triggering is to have the program react immediately to the user’s
input.
Use PAI for checkboxes – for example, to ensure that fields are activated for input only if
specific boxes are checked. The following graphic shows a popup for defining complex sorting
criteria:
Here the user can choose the direction and sequence for sorting immediately after checking
the sort field. For implementation you have to assign a function of type space to each of the
checkboxes. Then you can call a module for the PBO event of the popup to activate the
appropriate fields for input.
Use PAI for input fields in order to activate hierarchically dependent fields at runtime.
SAP AG 291
ABAP Workbench Delta Guide (3.1-4.6)
%HIRUHXVLQJWKHFKHFNER[
Clicking on the checkbox triggers PAI. Further input fields may be activated by dynamic
screen modification. (LOOP AT SCREEN. ... ENDLOOP.)
SAP AG 292
ABAP Workbench Delta Guide (3.1-4.6)
5HVXOWLQJVFUHHQ
6HOHFWLRQ6FUHHQV
6\QWD[
'HILQLQJD6HOHFWLRQ6FUHHQ
The statements
selection-screen begin of screen <nnnn>
[title <textfield>]|[as window].
... .
selection-screen end of screen <nnnn>.
SAP AG 293
ABAP Workbench Delta Guide (3.1-4.6)
define a selection screen with the screen number <nnnn> (maximum four digits). Number
1000 is reserved for the standard selection screen of an executable program, and may
therefore not be used as a selection screen number.
The addition title <textfield> displays the contents of <textfield> as the titlebar
of the screen. <textfield> may either be defined statically, or set dynamically at runtime.
The addition as window allows you to display the selection screen as a modal dialog box
using the addition starting at ... in the call selection-screen statement.
&DOOLQJD6HOHFWLRQ6FUHHQ
The statement
call selection-screen <nnnn>
[starting at <c1> <r1> [ending at <c2> <r2>]].
like call screen, opens a new screen level. The event AT SELECTION-SCREEN OUTPUT
is processed, and the selection screen with the screen number <nnnn> is displayed. After the
user has chosen a function, any additional checks programmed in other AT SELECTION-
SCREEN ... events are processed. Program processing then resumes immediately after
the call selection-screen ... statement.
The return code value is set as follows:
sy-subrc = 0: The user chose ‘Execute’.
sy-subrc = 4: The user chose ‘Cancel’.
In this case, all selection tables and parameters
have the same values after CALL SELECTION-SCREEN
that they had before the selection screen was called.
If you use the starting at <c1> <r1> addition, the selection screen is displayed as a
modal dialog box as long as you defined it using the addition as window. The top left-hand
corner of the selection screen is positioned at column <c1> and line <r1> of the screen. You
can use the ending at <c2> <r2> addition to place the bottom right-hand corner of the
selection screen at column <c2> and row <r2>.
8VH
Like the standard selection screen, you define user-defined selection screens in the data
declarations at the beginning of your program. This means you should place the definition
either in your TOP include or, if you are not using one, immediately after your other data
declarations.
Between selection-screen begin of screen ... . and selection-screen
end of screen ... . you can use the same statements that you use to create the
standard selection screen. In particular, you can use select-options <seltab> for
<field>. to define a selection criterion, or parameters <par> type <type>. to create
a parameter.
SAP AG 294
ABAP Workbench Delta Guide (3.1-4.6)
The corresponding selection fields then appear on your selection screen, the relevant data
objects are defined in your program, and you can enter field labels for the input fields by
choosing *RWR → 7H[WHOHPHQWV → 6HOHFWLRQWH[WV.
For full details of the syntax and additions of the PARAMETERS and SELECT-OPTIONS
statements, refer to the following documentation:
Select-options
Parameters
Note that you should test the value of SY-SUBRC immediately after the call
selection-screen ... statement to find out how the user left the selection screen. If SY-
SUBRC is 0, the user chose ‘Execute’. If it is 4, the user chose ‘Cancel’.
The AT SELECTION-SCREEN events are processed for all selection screens. If you need
different AT SELECTION-SCREEN processing for different selection screens, you can use a
CASE statement for the system field SY-DYNNR to distinguish between the different screens.
SY-DYNNR always contains the number of the current screen.
The as window addition allows you to display the selection screen as a modal dialog box. In
this case, you should use the starting at <c1> <r1> addition when you call the
selection screen. The column <c1> and line <r1> set the top left-hand corner of the window.
You should always use call selection-screen to call a selection screen, and
QHYHU the call screen statement, since the latter statement omits the necessary
initialization steps for a selection screen, and will therefore try to send the screen in an
unusable state.
6HOHFWLRQ6FUHHQDV6XEVFUHHQ
'HVFULSWLRQ
Selection screens can be defined as subscreens. Thus you can include select-options or
parameters that have been defined in such subscreens in any other screen or a tabstip
control on a selection screen. Their processing is the same as for ordinary subscreens of
ordinary screens.
To use selection screens as subscreens you need the following technical prerequisites.
SAP AG 295
ABAP Workbench Delta Guide (3.1-4.6)
,PSOHPHQWDWLRQ
A selection screen can be defined as a subscreen as follows:
SELECTION-SCREEN BEGIN OF SCREEN <dynno> AS SUBSCREEN
[NESTING LEVEL <m>] [NO INTERVALS].
...
SELECTION-SCREEN END OF SCREEN <dynno>.
2SWLRQDODGGLWLRQV
[NESTING LEVEL <m>].
Every frame around a tabstrip control increases the NESTING LEVEL by one.
[NO INTERVALS].
When using SELECT-OPTIONS, no high fields will be displayed for the subscreen.
8VH
The main application for selection screens as subscreens is it to use them as pages for
tabstrip controls. To do this, see the paragraph Tabstrip Control on Selection Screen [Seite
314] of this chapter.
You can use reuse selection screens in your programs or in other programs. For more
Note that you have to transport data using function modules, if you use selection screens
as subscreens from other programs such as functional groups.
However, you also can display the selection screen on a normal screen or in a tabstrip control
that is embedded in a normal screen. All you need to do is to define the selection screen as a
subscreen with the relevant select options and input parameters. Then you can define a
subscreen area on the screen and embed the subscreen screen in it by calling the subscreen
screen in the PBO event and, if necessary, in the PAI event as well.
SAP AG 296
ABAP Workbench Delta Guide (3.1-4.6)
8VLQJD6HOHFWLRQ6FUHHQVDVD6XEVFUHHQ
6HOHFWLRQ6FUHHQDVD6XEVFUHHQRQWKH6FUHHQ
$668%6&5((1
6(/(&7,216&5((1%(*,12)6&5((1$668%6&5((1 ABAP
6(/(&7237,216VBFDUU)25VSIOLFDUULG
VBFRQQ)25VSIOLFRQQLG
6(/(&7,216&5((1(1'2)6&5((1
Screen
352&(66%()25(287387 Painter
VXEL
&$//68%6&5((1VXEL
,1&/8',1*6<&352*
352&(66$)7(5,1387
VXEL
&$//68%6&5((1VXEL
&RQQHFWLRQV
25 $LUOLQH
$LUOLQH /+
)OLJKW1R
SAP AG 1999
7DEVWULS&RQWURO
)HDWXUHV
3XUSRVH
Tabstrip control controls provide you with an easy, user-friendly way of displaying different
components of an application on a single screen. Their intuitive design allows users to
navigate easily between the components. Using this technique, the user can comprehend the
structure of an application more intuitively as with conventional techniques such as the *RWR
menu. This reduces the learning expense and facilitates the usage.
Tabstrip control controls are compatible with batch input processing.
SAP AG 297
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
6FUHHQ2EMHFW7DEVWULS&RQWURO
$QHDV\ZD\WRSUHVHQW
GDWDWKDWORJLFDOO\EHORQJV
WRJHWKHU
'HSDUW $UULYH ,QIR
SAP AG
Tabstrips
$UHDRI8VHDQG5HVWULFWLRQV
You can use tabstrip control controls wherever you have different components of an
application that form a logical unit. For example, you might have a set of header data which
remains constant, while underneath it, you want to display various other sets of data.
You PXVWQRW use tabstrip control controls if
You need to change the screen environment (menus, pushbuttons, header data, and so on)
while processing the application components. The screen surrounding the tabstrip control
must remain constant.
The components must be processed in a certain order. Tabstrip control controls are designed
to allow users to navigate freely between components.
The components are processed dynamically, that is, if user input on one tab page leads to
other tab pages suddenly appearing.
Using a tabstrip
3URJUDPPLQJ
SAP AG 298
ABAP Workbench Delta Guide (3.1-4.6)
7HFKQLFDO,QWURGXFWLRQ
7DEVWULS&RQWURO(OHPHQWV
&XUUHQWWDEWLWOH
SAP AG
A tab page consists of a tab title, a subscreen area, and a subscreen. From a technical point
of view, the system handles tab titles like pushbuttons.
The contents of tab pages are displayed using the subscreen technique. You assign a
subscreen area to each tab page, for which you can then call a subscreen.
SAP AG 299
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
7DE3DJH7HFKQLFDO9LHZ
3XVKEXWWRQ
3XVKEXWWRQ
7H[W
7H[W
7H[W
6XEVFUHHQ
&217(176 DUHD
DUHD
&RQWHQWV
6XEVFUHHQ
SAP AG
A tabstrip control allows two different ways to page between tab pages:
You can use "local scrolling" which is performed by the GUI itself. Your ABAP program does
not get control when you push a tab.
You can scroll with the help of your ABAP program. Pushing a tab means your ABAP
program gets the control and you have to page program controlled. In the following this type
of scrolling is named "scrolling via backend".
Local scrolling in a tabstrip control works as if you send a large screen consisting of several
subscreen areas with complete information to your front end. Then the tabstrip control in the
GUI controls which tab is displayed as current and hides the other subscreens.
SAP AG 300
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
/RFDO6FUROOLQJLQD7DEVWULS&RQWURO
6FUHHQ
7$% 7$% 7$%
6FUHHQ
7$% 7$% 7$% 3DJH &$//68%6&5((1
3DJH &$//68%6&5((1
3DJH
3DJH &$//68%6&5((1
6FUROOLQJXVLQJ
WKH*8,
SAP AG
If you choose scrolling via backend all tab titles use one subscreen area and the application
uses the function codes of the individual titles to determine which subscreen to display.
5HPRWH/HDUQLQJ
6FUROOLQJYLD%DFNHQG
3URJUDP
IFRGHV
)& )& )&
6FUHHQ
7$% 7$% 7$%
6XEVFUHHQ
6FUHHQ
DUHD
6XEVFUHHQ
DUHD
SAP AG
If you use local scrolling for all tab titles any action that raises PAI on your screen will process
all screens in your tabstrip control . If the structure of your user dialog prevents such a
sequence of processing you should use ’scrolling via backend’ (e.g. you have several
SAP AG 301
ABAP Workbench Delta Guide (3.1-4.6)
required input fields on several subscreens of your tabstrip control ; then you will have to
enter values in all required fields to process any user command). If you use ’scrolling via
backend’ only one subscreen is processed for any action that raises PAI on your screen.
It is also possible to mix both types of scrolling in a single tabstrip control, i.e. to use tab titles
that use scrolling via backend while other tab titles use local scrolling.
Related documentation:
+RZWR&UHDWH7DEVWULS&RQWUROV
The following section describes how to create a tabstrip control. We distinguish between the
following three cases:
• Tabstrip controls with ORFDOVFUROOLQJ
• Tabstrip controls with VFUROOLQJYLDEDFNHQG
• Tabstrip controls using ERWKWHFKQLTXHV
Prerequisites: You have created all subscreens that shall be handled in the tabstrip control .
7DEVWULS&RQWUROZLWK/RFDO6FUROOLQJ
SAP AG 302
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO/RFDO6FUROOLQJ
Tabstrip area
Tab titles
Subscreen areas
SAP AG
&UHDWLQJWKH7DEVWULS&RQWURO$UHD
To create a tabstrip control area, choose the pushbutton for ’Tabstrip control ’ from the object
list in the Screen Painter and place it on the screen.
First, position the top left-hand corner, then drag the object out to the required size.
Second, assign a name to the tabstrip control in the "name" attribute. You need this name to
identify your tabstrip control .
Third, in your ABAP program, declare a control with the same name and the type TABSTRIP
using the CONTROLS statement.
The type TABSTRIP is defined in the type pool CXTAB. The field ACTIVETAB contains the
function code of the tab title of the currently active tab page. The other fields are reserved for
internal use.
The default number of tab pages for a tabstrip control is two.
SAP AG 303
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO7DEVWULS$UHD
6FUHHQ3DLQWHU
Fullscreen Editor
7\SH TABSTRIP
TABSTRIP FRUUHVSRQGVWRWKH
Tab Strip Attributes CXTAB_TABSTRIP
CXTAB
VWUXFWXUHGW\SH ZLWK
DFWLYHWDE DFWLYHWDEWLWOH
$%$3
,1&/8'(0=[[[723
&21752/6P\BWDEBVWULS7<3(7$%675,3
SAP AG
As well as the general 1DPH, 6WDUWLQJSRVLWLRQ and VWDWLFVL]H attributes, tabstrip controls also
have special tabstrip control attributes (see graphic). The UHVL]LQJ attributes control whether
the size of a subscreen area can be changed vertically and horizontally. You should set these
attributes if you want the size of the subscreen area to change with the size of the whole
window. You can use the minimum size attribute to set a lower limit beyond which the
subscreen area cannot be resized.
5HPRWH/HDUQLQJ
7DEVWULS&RQWURO$WWULEXWHV
Attributes
*HQHUDO 7DEVWULS
l 1DPH l 5HVL]DEOH
l 6WDUWSRVLWLRQ YHUWLFDOO\
l 6L]H KRUL]RQWDOO\
VWDWLF l 0LQLPXPVL]H
YHUWLFDO
KRUL]RQWDO
SAP AG
SAP AG 304
ABAP Workbench Delta Guide (3.1-4.6)
Resizing Tabstrips
'HILQLQJDQG$GGLQJ7DE7LWOHV
Technically, tab titles are treated in the same way as pushbuttons. They have a name, a text,
a function code, and a function type. You enter these in the )LHOG QDPH, )LHOG tH[W, )FW&RGH
and )FW7\SH fields of the tab title attributes.
A tab title can have the function type ’ ’ (space) or ’P’. Use function type ’P’ for tabstrip
controls working with ORFDOVFUROOLQJ. You must assign a function code to the tab title to assign
function type ’P’, although the function codes are not used. Function type ’ ’ (space) is used
for tabstrip controls working with VFUROOLQJYLDEDFNHQG.
If you want your tabstrip control to have more than two pages, you must create further tab
titles. To do this, choose 3XVKEXWWRQ from the object list in the Screen Painter and place it in
the tab title area.
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO7DE7LWOH
6FUHHQ3DLQWHU
Fullscreen Editor
,QIR
Pushbutton Attributes
)LHOGQDPH EXW
)LHOGWH[W ,QIR
)FW&RGH )FW7\SH 3
)&
Field list
)FW7\S 0HDQLQJ
1DPH 7\S )NW&RGH )NW7\S
3 /RFDO*8,IXQFWLRQ
EXW )& 3 QRUPDO
EXW )& 3
EXW )& 3
RNBFRGH 2.
SAP AG
$VVLJQLQJ6XEVFUHHQ$UHDVWR(DFK7DE7LWOH
You must assign a subscreen area to each tab page. The subscreen area assigned to a tab
page is automatically entered as the 5HIHUHQFHILHOG (in the Dictionary attributes) for the tab
title of that page.
SAP AG 305
ABAP Workbench Delta Guide (3.1-4.6)
To assign a subscreen area to a tab page, choose the tab title in the fullscreen editor (for
Windows: click on it), choose the 6XEVFUHHQ icon, and place it on the tab page (position the
top left-hand corner, then drag the object out to the required size). Enter the name of your
subscreen in the field ILHOGQDPH.
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO6XEVFUHHQV
6FUHHQ3DLQWHU
Fullscreen Editor
6XEVFUHHQ
DUHD
Attributes: Subscreen Attributes: Pushbutton
)LHOGQDPH 68% )LHOGQDPH %87
5HIHUHQFHILHOG 68%
SAP AG
,PSOHPHQWLQJWKH6XEVFUHHQ&DOOVRID7DEVWULS
&RQWURO/RFDO6FUROOLQJ
If you have assigned a different subscreen area to each tab page in a tabstrip control, you
can scroll between the pages locally at the front end. To do this, you must send all of the
subscreens to the front end when you send the main screen itself. All of the tab titles in the
tabstrip control must also have function type ’P’.
To program a tabstrip control to scroll locally at the front end, you must:
• Assign a separate subscreen area to each tab page
• Call all of the subscreens from the flow logic
• Assign function code type ’P’ to all of the tab titles
The system hides any tab page whose subscreen contains no elements that can be
displayed.
If there are no tab pages containing elements that can be displayed, the system hides the
entire tabstrip control.
SAP AG 306
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
6FUROOLQJ/RFDOO\LQD7DEVWULS&RQWURO&RGLQJ
6FUHHQ
352&(66%()25(287387 3DLQWHU
6FUHHQ )FW7\SH3 &$//68%6&5((1VXEDUHD
0<B7$%B675,3 ,1&/8',1*6<&352*
&$//68%6&5((1VXEDUHD
,1&/8',1*6<&352*
)& )& )&
&$//68%6&5((1VXEDUHD
,1&/8',1*6<&352*
VXEDUHD
352&(66$)7(5,1387
VXEDUHD &$//68%6&5((1VXEDUHD
VXEDUHD &$//68%6&5((1VXEDUHD
&$//68%6&5((1VXEDUHD
$%$3
&21752/6P\BWDEBVWULS
7<3(7$%675,3
SAP AG
If the subscreens used by the tabstrip control do not have a special PAI logic (e.g. pure
display screens) you can omit the subscreen calls at PAI of your screen containing the
tabstrip control .
7DEVWULS&RQWUROZLWK6FUROOLQJDW%DFNHQG
SAP AG 307
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
6WHSVLQ&UHDWLQJD7DEVWULS&RQWURO
6FUROOLQJYLDEDFNHQG
Tabstrip area
Tab titles
Subscreen area
SAP AG
&UHDWLQJWKH7DEVWULS&RQWURO$UHD
To create a tabstrip control area, choose the pushbutton for ’Tabstrip control’ from the object
list in the Screen Painter and place it on the screen.
First, position the top left-hand corner, then drag the object out to the required size.
Second, assign a name to the tabstrip control in the "name" attribute. You need this name to
identify your tabstrip control .
Third, in your ABAP program, declare a control with the same name and the type TABSTRIP
using the CONTROLS statement.
The type TABSTRIP is defined in the type pool CXTAB. The field ACTIVETAB contains the
function code of the tab title of the currently active tab page. The other fields are reserved for
internal use.
The default number of tab pages for a tabstrip control is two.
SAP AG 308
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO7DEVWULS$UHD
6FUHHQ3DLQWHU
Fullscreen Editor
7\SH TABSTRIP
TABSTRIP FRUUHVSRQGVWRWKH
Tab Strip Attributes CXTAB_TABSTRIP
CXTAB
VWUXFWXUHGW\SH ZLWK
DFWLYHWDE DFWLYHWDEWLWOH
$%$3
,1&/8'(0=[[[723
&21752/6P\BWDEBVWULS7<3(7$%675,3
SAP AG
As well as the general 1DPH, 6WDUWLQJSRVLWLRQ and VWDWLFVL]H attributes, tabstrip controls also
have special tabstrip control attributes (see graphic). The UHVL]LQJ attributes control whether
the size of a subscreen area can be changed vertically and horizontally. You should set these
attributes if you want the size of the subscreen area to change with the size of the whole
window. You can use the minimum size attribute to set a lower limit beyond which the
subscreen area cannot be resized.
5HPRWH/HDUQLQJ
7DEVWULS&RQWURO$WWULEXWHV
Attributes
*HQHUDO 7DEVWULS
l 1DPH l 5HVL]DEOH
l 6WDUWSRVLWLRQ YHUWLFDOO\
l 6L]H KRUL]RQWDOO\
VWDWLF l 0LQLPXPVL]H
YHUWLFDO
KRUL]RQWDO
SAP AG
SAP AG 309
ABAP Workbench Delta Guide (3.1-4.6)
Tabstrip Attributes
Resizing Tabstrips
'HILQLQJDQG$GGLQJ7DE7LWOHV
Technically, tab titles are treated in the same way as pushbuttons. They have a name, a text,
a function code, and a function type. You enter these in the )LHOG QDPH, )LHOG tH[W, )FW&RGH
and )FW7\SH fields of the tab title attributes.
Assign a function code to each tab title and use function type ’ ’ (space).
Give a name to the command field (usually ok_code). You need the command field to
recognize the different function codes transferred by the GUI if you press a tab title.
If you want your tabstrip control to have more than two pages, you must create further tab
titles. To do this, choose 3XVKEXWWRQ from the object list in the Screen Painter and place it in
the tab title area.
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO7DE7LWOH
6FUHHQ3DLQWHU
Fullscreen Editor
,QIR
Pushbutton Attributes
)LHOGQDPH EXW
)LHOGWH[W ,QIR
)FW&RGH )FW7\SH
)&
Field list
)FW7\S 0HDQLQJ
1DPH 7\S )NW&RGH )NW7\S
3 /RFDO*8,IXQFWLRQ
EXW )& QRUPDO
EXW )&
EXW )&
RNBFRGH 2.
SAP AG
$VVLJQLQJ6XEVFUHHQ$UHDVWR(DFK7DE7LWOH
You must assign RQH subscreen area to all tab pages. The subscreen area assigned to a tab
page is automatically entered as the 5HIHUHQFHILHG (in the Dictionary attributes) for the tab
title of that page.
To assign the subscreen area to the tab pages, you can proceed in two ways:
SAP AG 310
ABAP Workbench Delta Guide (3.1-4.6)
*UDSKLFDOPHWKRG: select all tab titles of the tabstrip control in the fullscreen editor (for
Windows: click on the tab titles simultaneously pressing 6+,)7), choose the 6XEVFUHHQ icon,
and place it on the tab page (position the top left-hand corner, then drag the object out to the
required size). Give a name to the subscreen (ILHOGQDPH). The system will assign the name
of the subscreen to all selected tab pages via the field 5HIHUHQFHILHOG.
7H[WEDVHGPHWKRG: Select one tab title of your tabstrip control in the fullscreen editor and
assign the subscreen area to it as described in the previous point. Enter the name of your
subscreen area to each tab title of your tabstrip control using the 5HIHUHQFHILHOG field in the
element attributes of each tab title.
5HPRWH/HDUQLQJ
&UHDWLQJD7DEVWULS&RQWURO6XEVFUHHQ
6FUHHQ3DLQWHU
Fullscreen Editor
6XEVFUHHQ
DUHD
Attributes: Subscreen Attributes: Pushbutton
)LHOGQDPH 68% )LHOGQDPH %87%87
5HIHUHQFHILHOG 68%
SAP AG
,PSOHPHQWLQJWKH6XEVFUHHQ&DOOVRID7DEVWULS
&RQWURO6FUROOLQJDW%DFNHQG
If all of the tab pages share a single subscreen area, the program has to analyze the function
code of the chosen tab title to determine which screen will be displayed. The subscreen call
for the tabstrip control has to be implemented in the dialog process control at PBO using a
field containing the subscreen number screen_no:
* PBO.
CALL SUBSCREEN subarea INCLUDUNG sy-cprog screen_no.
To implement the scrolling:
Use the function code of the pressed tab title to assign the corresponding subscreen number
to the field screen_no.
SAP AG 311
ABAP Workbench Delta Guide (3.1-4.6)
Copy the function code of the selected tab title to the field ACTIVETAB of your tabstrip control
(created with the help of the CONTROLS command in you program). The GUI needs this
information to display the corresponding tab title as the active one.
You have to give initial values to the subscreen number and to the field ACTIVEFIELD
(corresponding value) for the first processing of the screen containing the tabstrip control .
5HPRWH/HDUQLQJ
6FUROOLQJDW%DFNHQG,PSOHPHQWDWLRQ,GHD
3DJH 3DJH
IBFRGH
0RGXOH 3$,PRGXOH
,QLWLDOYDOXHVIRU • 8VHIBFRGHWRGHWHUPLQHWKHVXEVFUHHQWREH
SURFHVVHGLQWKHVXEVFUHHQDUHD
• VXEVFUHHQ
QXPEHU • 6HWDSSURSULDWHWDEWLWOHDVFXUUHQWWDEWLWOH
• DFWLYHWDEWLWOH
SAP AG
You can use the field ACTIVETAB of your tabstrip control to determine whether you have
assigned initial value to your tabstrip control .
During this process, the system only checks the fields of the subscreen that is actually
displayed.
SAP AG 312
ABAP Workbench Delta Guide (3.1-4.6)
5HPRWH/HDUQLQJ
6FUROOLQJDW%DFNHQG,PSOHPHQWDWLRQ
)NW7\S
)NW7\S ABAP
6FUHHQ
MY_TAB_STRIP
&21752/6P\BWDEBVWULS7<3(7$%675,3
'$7$RNBFRGH/,.(V\XFRPP
VFUHHQBQU/,.(V\G\QQU
)& )& )&
02'8/(DFWLYHWDEBLQLW287387
,)P\BWDEBVWULSDFWLYHWDE,6,1,7,$/
VXEDUHD P\BWDEBVWULSDFWLYHWDE
)&
VFUHHQBQU
(1',)
(1'02'8/(
Screen 02'8/(XVHUBFRPPDQG,1387
352&(66%()25(287387 Painter ,IRNBFRGH&6
)&
02'8/(DFWLYHWDEBLQLW P\BWDEBVWULSDFWLYHWDE RNBFRGH
(1',)
&$//68%6&5((1VXEDUHD &$6(RNBFRGH
,1&/8',1*6<&352*VFUHHQBQU :+(1
)&
VFUHHQBQU
352&(66$)7(5,1387 :+(1
)&
&$//68%6&5((1VXEDUHD VFUHHQBQU
02'8/(XVHUBFRPPDQG (1'02'8/(
SAP AG
7DEVWULS&RQWUROZLWK0L[HG6FUROOLQJ
You can use a combination of the two scrolling methods. For example, if for editing individual
tab pages extensive database selections or extensive input checks are required, you can use
scrolling via backend for these tab pages, while offering local scrolling for simple display
tabstrip controls.
5HODWHG'RFXPHQWDWLRQ/LQNV
'\QDPLF0RGLILFDWLRQV
You can use dynamic text on tab titles exactly as you would realize it with a pushbutton.
SAP AG 313
ABAP Workbench Delta Guide (3.1-4.6)
Pushbuttons
You can hide a tab page at runtime by setting the corresponding tab title to inactive using the
system table SCREEN (SCREEN-ACTIVE = ’0’). You should do this before processing the
tabstrip control for the first time, to ensure that the screen environment remains constant.
More flexible tabstrip control implementation can be achieved using table entries. You can
customize the tabstrip control elements
• tab title texts
• subscreen numbers
• storing this information in table entries.
To do this you have to call a module at PBO. In this module you read the texts for the tab
titles as well as the screen numbers of the subscreens used in the tabstrip control from a
database table.
7DEVWULS&RQWUROVRQ6HOHFWLRQ6FUHHQV
'HVFULSWLRQ
You can now create tabstrip controls on selection screens. They allow you to create logical
groups of fields and make large selection screens more user-friendly. Very large selection
screens might otherwise appear, for example, if you use logical databases for data selection.
Tabstrip controls on selection screens are very useful for presenting the user various
independent views for filtering the data that will be selected from the database. They have to
be independent to let the user navigate freely to each tab.
Of course, standard screens offer the same functions as tabstrip controls . Note that if the
tabstrip control contains too many pages, it will not be possible for all of the tab titles to be
displayed at once. If this happens, the system displays a scrollbar with which you can scroll
through the remaining tabs. In the top right-hand corner of the tab is a pushbutton. If the user
clicks this, a list of all of the tab titles is displayed and the active tab title is marked with a tick.
The following requirements must be met if you are to use selection screens with tabstrip
controls in your R/3 System:
• GUI version 4.0 or higher
• Frontend: Motif, Windows 95, MacOs, NT 3.51 or higher.
SAP AG 314
ABAP Workbench Delta Guide (3.1-4.6)
6HOHFWLRQVFUHHQZLWKWDEVWULSFRQWURODQDORJRXVWRWKHVWDQGDUGVHOHFWLRQVFUHHQRI
WKHORJLFDOGDWDEDVH)6
,PSOHPHQWDWLRQ
For a selection screen with a tabstrip, you have to define:
• selection screens as subscreens for the individual tabs
• a subscreen area on the selection screen to accommodate the tabstrip control
• the individual tab titles
For defining selection screens as subscreens see the paragraph Selection Screen as
subscreen [Seite 295] of this chapter.
You define a subscreen area for a tabstrip control on a selection screen as follows:
SELECTION-SCREEN BEGIN OF TABBED BLOCK <blockname> FOR <n> LINES.
<definition of the tab titles>
SELECTION-SCREEN END OF BLOCK <blockname>.
The height of the subscreen area in lines is defined by <n>. Note that the system
automatically generates a CONTROLS statement (CONTROLS: tabstrip_<blockname>
TYPE TABSTRIP.) You must not write your own CONTROLS statement. If you try to do so, a
syntax error results.
Your next step is to define the individual tabs between the statements
SELECTION-SCREEN BEGIN OF TABBED BLOCK... and
SELECTION-SCREEN END OF TABBED BLOCK... as follows:
SELECTION-SCREEN TAB (length) <tabname> USER-COMMAND <ucomm>
[DEFAULT [PROGRAM <prog>] SCREEN <dynnr>].
The corresponding tabname is a character field which is also declared by the system. You
only have to assign the text. The best way to do this is to use a text symbol. Use the event
INITIALIZATION to move statically the text symbol to the tabname. Alternatively, use the
event AT SELECTION-SCREEN OUTPUT. Then it is possible to use label the tab titles
dynamically. The parameter length in brackets specifies the output length of the tab title.
Finally, the optional additions: [DEFAULT [PROGRAM <prog>] SCREEN <dynnr>]assign
a selection screen to a tab. If you use the DEFAULT addition, you must also use the SCREEN
SAP AG 315
ABAP Workbench Delta Guide (3.1-4.6)
addition. The PROGRAM addition then is optional, too. You only need it, if the screen comes
from another program.
You can delay specifying the link between the tab title and the selection screen until runtime.
You can also change an existing assignment at runtime. To do this, fill the automatically
generated structure <blockname>. This structure has the same name as the tabstrip block,
and describes the actual tab used. It contains the fields prog, dynnr and activetab. For
more information, see the online documentation.
The following code displays the above tabstrip control on the standard selection screen.
REPORT SAPBC410SUBD_SELECTION_SCREEN .
INITIALIZATION.
tabname1 = text-001. "TEXT-001 EN: Connection
SAP AG 316
ABAP Workbench Delta Guide (3.1-4.6)
For more information see the documentation on Tabstrip Controls on Selection Screens .
&UHDWLQJDQG8VLQJ&RQWH[W0HQXV
Context menus (which you access using the alternate mouse key or SHIFT-F10) are
shortcuts for functions that are frequently used.
They can be used to display context-sensitive menus. The context is defined by the position
(cursor for SHIFT-F10, mouse location for alternate mouse key) where the user called the
context menu. If needed, you can specify the context more precisely with the displayed
contents. This permits the user to select functions that are relevant for the current context
using the context menu.
(QFDSVXODWLRQ$UHDIRU&RQWH[W0HQXV
&RQWH[W0HQXV
6FUHHQ$UHDRI(QFDSVXODWLRQRID&RQWH[W0HQX
/LVW (GLW *RWR ([WUDV (QYLU 6\VWHP +HOS
Screen area
%R[ 6XEVFUHHQDUHD
Subscreen area
%R[LQWKHER[
SAP AG 1999
You define whether a context menu should be offered when you create a screen object (such
as screens, input fields, table controls, or boxes).
When the user selects a context menu on an object, an event mechanism (as understood by
ABAP objects) calls a certain subroutine in the application program. The subroutine is handed
over a menu reference. It uses this menu reference to build the display menu. You can use
either static menus (which are defined using the Menu Painter), or dynamic menus (built at
runtime).
SAP AG 317
ABAP Workbench Delta Guide (3.1-4.6)
After the user executes a menu function, the application program regains control and can
react to the user input.
Context menus have to be assigned to output fields. When you assign a context menu to a
box, table control or screen (normal or subscreen), all the subordinate output fields that do not
have a context menu themselves inherit it.
&UHDWLQJ6WDWLF&RQWH[W0HQXV
You create a context menu from within the object list of the Object Navigator. Position the
cursor on *8,VWDWXVand right-click. The Object Navigator automatically opens the Menu
Painter.
Alternatively, you can also create a context menu directly in the Menu Painter.
&UHDWLQJD&RQWH[W0HQX
A context menu is a special GUI status. Assign it a name, a descriptive text and status type
CRQWH[WPHQX.
In a context menu you can link any function codes and function texts. In particular, you can
take advantage of your screen pushbuttons. The functions already provided in the interface
can be used as possible entries help.
The link technique ensures consistent context menus in large applications.
You should observe the following rules when designing context menus:
• Do not use any functions that cannot be found elsewhere in the system (pushbuttons or
interface).
• Avoid using more than two hierarchy levels in context menus.
• Do not use more than 10 entries, but map all the available pushbuttons.
SAP AG 318
ABAP Workbench Delta Guide (3.1-4.6)
/LQNLQJD&RQWH[W0HQXWR6FUHHQ(OHPHQWV
You can assign a context menu to various output elements in the Screen Painter by
specifying a callback routine in the attributes of the screen element. Clicking the alternate
mouse key triggers this callback routine in your program. It is named ON_CTMENU_<name>.
It is possible to assign a callback routine to input/output fields, text fields and status icons
directly. Checkboxes, radio buttons, and pushbuttons do not have their own callback routines.
However, these fields can inherit context menus from boxes or screens. If you want to link a
callback routine to a screen, you have to input the <name> within the general screen
attributes.
If you assign a callback routine to a table control, it is triggered for all the fields of the table
control that do not have their own callback routine.
The following is an example of a callback routine:
FORM ON_CTMENU_<name>
USING p_menu TYPE REF TO cl_ctmenu.
************************************************
* definition of the context menu by assigning *
* a static defined context menu using a static *
* method of class cl_menu *
************************************************
ENDFORM.
In this subroutine, the context menu is built with a static method of the global class
cl_ctmenu to load a context menu that was predefined in the Menu Painter
Clicking on an output field at runtime, using the alternate mouse key, starts the corresponding
callback routine. Then the called method loads the predefined menu and displays it on the
screen for user input. If the user chooses a function in the context menu, the corresponding
function code is placed in the command field and the system triggers the PAI of the screen,
depending on function type.
The class cl_ctmenu provides a number of other methods in addition to the static method
load_gui_status. You can use them to adapt the context menu at runtime (e.g. using the
values in data fields). Some of these methods are:
add_function add a function to the menu
add_separator add a separator between entries
hide_functions hide functions of the menu
show_functions show hidden function
disable_functions deactivate functions
enable_functions activate functions
Note that these are not static methods of the class cl_ctmenu, that means you have to
call them using the syntax:
SAP AG 319
ABAP Workbench Delta Guide (3.1-4.6)
1DPH&KDQJHVLQ$%$3:RUNEHQFK7RROV
From 5HOHDVH the following names changed in the ABAP Workbench tools:
• Screen Painter: The ILHOGOLVW (Release 4.0) is called HOHPHQWOLVW in Release 4.5
• Screen Painter: The attribute ILHOGQDPH (Release 4.0) is called QDPH in Release 4.5.
• Screen Painter: The attribute ILHOGWH[W (Release 4.0) is called WH[W in Release 4.5.
SAP AG 320
ABAP Workbench Delta Guide (3.1-4.6)
&RQWURO(QDEOLQJ7HFKQRORJ\
After reviewing the following topics, you will be able to:
Identify the basics of Control Enabling Technology
Program with the Control Framework
Understand the example: HTML Control
SAP AG 321
ABAP Workbench Delta Guide (3.1-4.6)
,QWURGXFWLRQ
Controls are reusable standalone binary software elements. Programmers can include one or
more controls in an application and use the functions that they provide. One frequent use is to
provide reusable components for user interfaces. However, controls can also be used for
software components that are not visible.
6FRSHRI7KLV6HFWLRQ
This section describes the architecture and use of the CONTROL FRAMEWORK (CFW),
which provides the basis for the use of Control Enabling Technology (CET) in the R/3 System.
It applies to Release 4.5 of the R/3 System.
The section is structured as follows:
• The first part provides an overview of the basic ideas of the Control Framework
• The next part provides more detailed information. After each section of information, there
is a programming step to follow. If you follow all of the steps, you will end up with a
demonstration program containing a control.
• The final part contains the full code of the demonstration program.
7DUJHW*URXSDQG3UHUHTXLVLWHV
This documentation assumes that you are familiar with elementary screen programming
(dialog programming).
&RQWUROV%HQHILWVDQG3URSHUWLHV
Within ABAP and the runtime environment of the R/3 System, you can control desktop
components using the Automation Controller.
The application logic runs on the R/3 application server (automation client), and the desktop
components (automation server) run on the frontend.
Typical automation servers are WORD, EXCEL and other desktop applications.
The framework described here allows you to use custom controls.
Custom Controls are hosted within the client area of the SAPgui.
3UHUHTXLVLWHVDQG5HVWULFWLRQV
SAP AG 322
ABAP Workbench Delta Guide (3.1-4.6)
In Release 4.5 (both of the R/3 System and SAPgui), you can only use controls if your
frontend is running under Windows and the controls are in ActiveX form:
Windows 95, Windows 98, Windows NT 4.0 with Service Pack 3.
Controls do not work under Windows NT 3.51.
6$3JXLRQ:LQGRZV
5HPRWH/HDUQLQJ
:LQGRZV
%LW QDWLYH
:LQGRZV
:LQGRZV %LW
QDWLYH:LQGRZV%LW
%LW
5 5 5 5
l *8,UXQVDVQDWLYHFRGLQJRQ:LQGRZVELWSODWIRUPV
l 6XSSRUWIRUELW:LQGRZVZLOOVWRSDIWHU55HOHDVH
l &RQWUROHQDEOLQJZLWK$FWLYH;
SAP AG
%DVLFV
This part of the unit describes the basic principles of the Control Framework.
$UFKLWHFWXUH
SAP AG 323
ABAP Workbench Delta Guide (3.1-4.6)
&RQWUROV6LPSOLILHG9LHZ
5HPRWH/HDUQLQJ
$FWLYH; )URQWHQG
6$3*8,&OLHQW
&RQWUROV
&RQWURO)UDPHZRUN
5)&
%DFNHQG
&RQWURO)UDPHZRUN
$SSOLFDWLRQ
6HUYHU
function calls
$%$33URJUDP
SAP AG
$XWRPDWLRQ4XHXH
Performance is essential in a client / server environment. For this reason, the Control
Framework uses a sophisticated system of buffering method calls, allowing you to reuse
result variables within a queue. A series of calls to different instances is placed in a queue
and then transferred to the frontend at specific synchronization points. To define a
synchronization point, you can either define a method as not queued, or explicitly call the
function module CONTROL_FLUSH to dispatch the queued calls to the frontend.
The automation queue is transferred to the frontend and executed using RFC with destination
SAPgui. The execution is synchronous, which means that the Remote Function Call occurs at
exactly the point that you include a synchronization. Due to the architecture of the R/3
System, there is a time limit within which synchronous function calls must be executed,
otherwise the backend will terminate its communication with the frontend (example:
"Mousetip" = 200 ms)
([FHSWLRQ+DQGOLQJ
Exception handling (dealing with illegal calls or bad results), cannot occur until the
synchronization point has been reached. Any exception that occurs while the automation
queue is being processed is passed to the backend, where it becomes an exception of the
function module processing the synchronization. No further entries in the automation queue
are processed once an exception has occurred.
SAP AG 324
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDPPLQJIRU3HUIRUPDQFH
(YHQWV
Events are processed in the PAI event of the ABAP program. The Automation Controller
generates a special function code that identifies the event. This function code is interpreted
using ABAP function modules that can call pre-defined routines (CALLBACKS) for each
event.
If we look at this concept and think about performance, it is easy to see that not all events will
have to be passed to the R/3 System every time they occur (think of MOUSE_MOVE).
Consequently, events are only passed from the frontend to the backend if the application has
requested them.
&RQWUROV'HWDLOHG9LHZ
5HPRWH/HDUQLQJ
$SSOLFDWLRQVHUYHU
$%$3DSSOLFDWLRQ
5REMHFWKDQGOHV
&RQWUROIUDPHZRUN
$XWRPDWLRQFRQWUROOHU
$XWRPDWLRQFRQWUROOHU
2EMHFWPRGHO
$XWRPDWLRQEULGJH ERXQGDU\
$FWLYH;
&OLHQWREMHFWPRGHO
$FWLYH; &RQWUROPDQDJHU
FRQWURO
$FWLYH;
FRQWURO
&OLHQW $XWRPDWLRQVHUYHU
HJ([FHO:RUG
SAP AG
SAP AG 325
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDPPLQJZLWKWKH&RQWURO)UDPHZRUN
This section explains how to program using the Control Framework in Release 4.5. During the
section, we will also write a demonstration program. Each step of the demonstration program
corresponds to the technical programming information that immediately precedes it.
Our example will use the HTML Control. This is a control with medium complexity, having
enough functions to allow us to see all of the main features of controls programming, but it
does not require too much additional knowledge.
The demonstration program contains the following steps:
• Step 0: Explain the template (you will copy this template for your own program)
• Step 1: Basic steps for working with controls
• Step 1-1: Data structures and includes required by the Control Framework
• Step 1-2: Reserving a screen area for the control
• Step 1-3: Using the function modules necessary for the HTML control
As we go on, we will see which function calls are common to all controls (used to
configure the Control Framework) and which are control-specific.
• Step 1-4: Exiting the Control Framework
• Step 2: Accessing the attributes and method calls of a control
• Step 3: Event handling for controls
• Step 3-1: Registering events and CALLBACK routines
• Step 3-2: Defining CALLBACK routines
• Step 3-3: Dispatching CALLBACK routines
Note that the demonstration is merely an example to illustrate the basic principles of working
with the Control Framework. It is not intended to be an exhaustive programming guide for
controls in Release 4.5. The demonstration looks as though it includes a lot of technical detail.
However, in practice, many of the technical details required are encapsulated in the function
modules supplied by SAP for using controls.
Docu Reference
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
6DPSOH&(76WHS7HPSODWH3URJUDP
Our demonstration program will illustrate the steps needed to use the HTML control on an R/3
screen. We are going to:
• List some of the features of the HTML control
• Introduce a template program that already contains all of the required coding that is not
specific to the HTML control.
The template program is a normal program that processes an “empty” screen. Our aim is to
include an HTML control on that screen.
SAP AG 326
ABAP Workbench Delta Guide (3.1-4.6)
7KH+70/&RQWURO
The SAP HTML Viewer Control is one of the controls developed by SAP for use in its SAPgui
frontend version 4.5. SAP does not intend to write its own WWW browser. Instead, the SAP
HTML Viewer Control will provide platform-independent interface and data transport
mechanisms to third party WWW browsers. While the SAP HTML Viewer Control interface will
be the same for all platforms, the precise range of functions available will depend on the
underlying WWW browser. For Windows 95 & NT 4.0, Microsoft Internet Explorer 3.0 is used
as a third party WWW browser.
SAP HTML Viewer Control is designed to be used, along with other controls like buttons and
list boxes, on a screen in an R/3 transaction. With this control, ABAP developers will be able
to add HTML pages, graphics, or images to their programs that have either been stored in the
database or generated at runtime. The SAP HTML Viewer Control can also be used as a
generic container for Java applets and ActiveX controls or a viewer for any type of document
(MIME content types), as long as these features are supported by the underlying Web
browser.
The SAP HTML Viewer Control does not only display data provided by an R/3 transaction, but
can also trigger events on user input that you can process in the Process After Input (PAI)
modules of the transaction. An event is triggered whenever the user selects a URL or submits
an HTML form. The URL or the data from the form are then available for processing within the
ABAP program.
The SAP HTML Viewer Control also supports navigation through HTML pages and MIME
documents from data sources outside the current R/3 transaction, such as the desktop file
system or an HTTP server. This provides close integration between the SAPgui and your
Internet or Intranet environment.
Docu Reference
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
7KH7HPSODWH3URJUDP
The template program is an executable program (type 1) with a single screen (100) and a
standard selection screen. Screen 100 has a single output field that we will need later on. It is
used to display the URL of the page displayed in the HTML control. The screen has
pushbuttons for navigation (“Back”, “Cancel”, and “End program”). On the selection screen,
you can enter the URL of the page you want to display in the HTML control.
The ([DPSOH section contains a complete version of the same demonstration program that
we are going to write step-by-step in this unit.
3URJUDP&RGH
REPORT z_cet_html_1 MESSAGE-ID pc.
**************************************************************
* D A T A
**************************************************************
DATA: url(80) TYPE c."url of displayed html page
* screen specific
DATA: ok_code LIKE sy-ucomm, "user_command
save_ok LIKE ok_code. "copy of ok_code
**************************************************************
* C O N S T A N T S
**************************************************************
CONSTANTS:
SAP AG 327
ABAP Workbench Delta Guide (3.1-4.6)
* general
c_true TYPE c VALUE ’X’,
c_false TYPE c VALUE ’ ’.
**************************************************************
* S T A N D A R D S E L E C T I O N S C R E E N
**************************************************************
* url of start page used in browser
SELECTION-SCREEN COMMENT /1(65) text-s01.
* text-s01: ’Please enter the URL of the HTML page to be ’
* ’displayed here’
PARAMETERS:
pa_url LIKE url DEFAULT ’http://www.sap-ag.de’.
**************************************************************
* M A I N P A R T
**************************************************************
START-OF-SELECTION.
url = pa_url. " copy parameter to global variable
**************************************************************
* M O D U L E S S C R E E N 1 0 0
**************************************************************
* ------------------------------------------------------------
* Module STATUS_0100 OUTPUT
* ------------------------------------------------------------
* set user interface for screen 100
*-------------------------------------------------------------
MODULE status_0100 OUTPUT.
SET PF-STATUS ’SCREEN_0100’.
SET TITLEBAR ’SCREEN_0100’.
ENDMODULE. " STATUS_0100 OUTPUT
* ------------------------------------------------------------
* Module USER_COMMAND_0100 INPUT
* ------------------------------------------------------------
* react to all ’user interactions’ here
* possible ’user interactions’ are:
* 1. function codes of type ’ ’ raised from standard
SAP AG 328
ABAP Workbench Delta Guide (3.1-4.6)
* ------------------------------------------------------------
* Module EXIT_COMMANDS_0100
*-------------------------------------------------------------
* react to all function codes of type ’E’ here
*-------------------------------------------------------------
MODULE exit_commands_0100 INPUT.
CASE ok_code.
WHEN ’EXIT’. "leave the program
LEAVE PROGRAM.
WHEN ’CANCEL’. "cancel current screen
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " EXIT_COMMANDS INPUT
)ORZ/RJLFRI6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
*
PROCESS AFTER INPUT.
MODULE exit_commands_0100 AT EXIT-COMMAND.
MODULE user_command_0100.
SAP AG 329
ABAP Workbench Delta Guide (3.1-4.6)
6HOHFWLRQ6FUHHQRIWKH'HPRQVWUDWLRQ3URJUDP
SAP AG 330
ABAP Workbench Delta Guide (3.1-4.6)
6FUHHQRIWKH'HPRQVWUDWLRQ3URJUDP
:ULWLQJWKH'HPRQVWUDWLRQ3URJUDP
To recreate the sample program in your R/3 System:
• Copy the ABAP source code
• Double-click text element s01 and enter the text given in the comment in the source code
• Go to the selection screen texts. For PA_URL, enter ‘URL (Uniform Resource Locator)’
• Generate the program
• Double-click the screen number in the CALL SCREEN 100 statement. Copy the source
code
• In the layout editor of the Screen Painter, place the program field URL on the screen
• In the screen element list, enter the name 2.B&2'( for the field with type OK
• Go to the 6(7B67$786 module and double-click 3)67$786 (BACK, CANCEL, EXIT)
• Double-click the title bar name and enter a screen title
%DVLFV
The following section describe the steps necessary for controls programming in ABAP.
SAP AG 331
ABAP Workbench Delta Guide (3.1-4.6)
&RQVWDQWVDQG'DWD7\SHV
To program with controls you need a large number of data definitions for the Control
Framework and for handling the individual controls. Many of these type and data definitions
are encapsulated in a special include program, but you still have to declare some of the data
yourself in your program.
,1&/8'(3URJUDPV
The ABAP include <CTLDEF> contains several constants, type and data definitions. You
have to use it if you want to use controls in your program.
This include also contains macro definitions (ABAP Defines) for CALLBACK routines (see
Event Handling [Seite 345].)
&RQWURO+DQGOH
6DPSOH&(76WHS
Add the following statements to the declaration part of your program (new lines are in EROG
type):
REPORT z_cet_html_1 MESSAGE-ID pc.
,1&/8'(FWOGHI!QHHGHGIRU&(7
*************************************************************
* D A T A
**************************************************************
KWPOFRQWURO
DATA: html1_handle TYPE cntl_handle. "html_handle
SAP AG 332
ABAP Workbench Delta Guide (3.1-4.6)
&RQWUROVDQG6FUHHQV
This section describes how controls are embedded in SAP screens the things you have to
remember when working with different levels of the screen stack (ABAP VWDWHPHQW&$//
6&5((1VFUHHQBQPEHU!).
&XVWRP&RQWUROV
To place a control on a screen, use the function module CONTROL_LINK. This function
module has a parameter FRQWDLQHU, to which you pass the name of a control container that
you have placed on the screen using the Screen Painter. The control then appears on the
screen in the position defined for the control container in the Screen Painter.
From Release 4.5, the Screen Painter contains a new pushbutton in its element toolbar called
Custom Control. You use this to create a control container (reserved area for a control on a
screen).
/HYHO&RQFHSW
A control must always have a technical parent (window that hosts the control). The parent
cannot be changed during the lifetime of a control. For that reason, the ID of the parent must
be defined when you create the control.
The Control Framework can handle 10 different parents, one for each of the ten screen levels
that you can create using ABAP programs (see also the constants defined in <CTLDEF>):
DYNPRO_0: The “main” window
st
DYNPRO_1: 1 dialog box
...
th
DYNPRO_9: 9 dialog box
DYNPRO_DEFAULT: current screen level
You cannot reassign a control from one screen level to another. If you want to use a control at
different levels, you will need multiple instances.
The CONTROL_CREATE function module, which you use to create a control, has a
parameter SDUHQWLG. This represents the screen level in which the control is displayed. The
value ‘dynpro_0’ means screen level 0, which is a normal R/3 fullscreen. ‘dynpro_1’ is the first
dialog box level, ‘dynpro_2’ the second dialog box level, and so on up until ‘dynpro_9’. You
can also set the parameter to its initial value, or use the value ‘dynpro_default’. In this case,
the system automatically determines the screen level in which the control to be used.
However, this only works when you assign the screen level in the PBO event of the screen in
which the control is displayed. You cannot change the ‘parentid’ during the lifetime of the
control.
Since the ‘parentid’ can never be changed during the lifetime of a control, you can only reuse
the control in more than one screen if they all occur at the same screen level.
SAP AG 333
ABAP Workbench Delta Guide (3.1-4.6)
6DPSOH&(76WHS
Our first step is to reserve the Custom Control area on screen 100 in which our control will
appear later on. We do this using the Screen Painter. The layout editor contains a pushbutton
with a new icon and the name Custom Control. You reserve the control area in exactly the
same way that you would define a subscreen in the Screen Painter.
&UHDWLQJD&XVWRP&RQWURO
)XQFWLRQ0RGXOHVIRUWKH&RQWURO)UDPHZRUN
You use the following function modules to work with the Control Framework:
SAP AG 334
ABAP Workbench Delta Guide (3.1-4.6)
&):)XQFWLRQ0RGXOHV
5HPRWH/HDUQLQJ
&21752/B,1,7 ,QLWLDOL]HVWKHIUDPHZRUN7KLVPRGXOHKDVWR
EHFDOOHGEHIRUH\RXFDQFDOODQ\RWKHU
PRGXOHVOLVWHGKHUH
&21752/B&5($7( &UHDWHVDFRQWURORIWKHFODVV&/6,'7KH
FRQWUROFDQEHDFFHVVHGXVLQJWKHUHVXOWLQJ
KDQGOH+B&21752/H[SRUWLQJSDUDPHWHU
&21752/B'(6752< 'HVWUR\VDFRQWURODQGIUHHVDOOUHVRXUFHV
&21752/B)/86+ ([SOLFLW)/86+RIDXWRPDWLRQTXHXH
H[HFXWHVDOOSUHYLRXVFDOOV
&21752/B/,1. 'HILQHVZKHUHDQGZKHQDFRQWUROLVYLVLEOH
SAP AG
6DPSOH&(76WHS
6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
02'8/(KWPOBFRQWUROBSER
*
PROCESS AFTER INPUT.
MODULE exit_commands_0100 AT EXIT-COMMAND.
MODULE user_command_0100.
SAP AG 335
ABAP Workbench Delta Guide (3.1-4.6)
0RGXOHV
0RGXOH+70/B&21752/B3%2287387
GRDOOVWHSVQHHGHGIRUFRQWUROIUDPHZRUNKHUH
02'8/(KWPOBFRQWUROBSER287387
FDOOVXEURXWLQHVWRKDQGOHFRQWUROIUDPHZRUN
ILUVWEHVXUHWRFDOOWKHFRQWUROIUDPHZRUNRQO\WKHILUVW
WLPH\RXHQWHUWKHVFUHHQ
'$7$KWPOBILUVWBWLPH7<3(FYDOXHFBWUXHIODJ
JOREDOGDWD
,)KWPOBILUVWBWLPH FBWUXH
KWPOBILUVWBWLPH FBIDOVH
VWHSWHVWJXLW\SHZLQGRZVW\SH
3(5)250WHVWBJXLBW\SH
VWHSLQLWFRQWUROHQDEOLQJIUDPHZRUN
3(5)250LQLWLDOL]HBFRQWUROBIUDPHZRUN
VWHSFUHDWHFRQWUROKWPO
3(5)250FUHDWHBKWPOBFRQWURO
VWHSOLQNFRQWUROWRVFUHHQDUHD
3(5)250OLQNBFRQWUROBWRBVFUHHQBDUHD
3(5)250IOXVKBTXHXHGBFRQWUROBFRPPDQGV
(1',)
(1'02'8/(+70/B&21752/B3%2287387
)RUP5RXWLQHV
)RUP7(67B*8,B7<3(
WHVWZKHWKHUFRQWUROVFDQEHFDOOHGRUQRW
)250WHVWBJXLBW\SH
FKHFNIRUDSSURSULDWHIURQWHQG
'$7$ZLQBIODJ7<3(FIODJIRUJXLW\SH
&$//)81&7,21
*8,B+$6B$&7,9(;
,03257,1*
UHWXUQ ZLQBIODJ
,)ZLQBIODJ,6,1,7,$/ZURQJJXLW\SH
0(66$*(D:,7+
,QYDOLG)URQWHQG
SAP AG 336
ABAP Workbench Delta Guide (3.1-4.6)
(1',)
(1')2507(67B*8,B7<3(
)RUP,1,7,$/,=(B&21752/B)5$0(:25.
)250LQLWLDOL]HBFRQWUROBIUDPHZRUN
LQLWLDOL]HWKHFRQWUROIUDPHZRUN
&$//)81&7,21
&21752/B,1,7
(;&(37,216
FRQWUROBLQLWBHUURU
27+(56
,)V\VXEUF!
0(66$*(D
:,7+
(UURUGXULQJLQLWLDOL]DWLRQRIFRQWUROIUDPHZRUN
(1',)
(1')250,1,7,$/,=(B&21752/B)5$0(:25.
)RUP&5($7(B+70/B&21752/
)250FUHDWHBKWPOBFRQWURO
DVHWVKHOOVW\OH
XVHWKHFRQVWDQWVZVBYLVLEOHZVBFKLOGZVBERUGHU
ZKLFKDUHSUHGHILQHGLQWKHLQFOXGHFWOGHI!
LQIRUPDWLRQVRXUFHDERXWZLQGRZVYDULDEOHVZLQGRZVK
*8,
'$7$VKHOOVW\OH7<3(LZLQGRZVVKHOOVW\OH
,)VKHOOVW\OH,6,1,7,$/RQO\VHWILUVWWLPH
VKHOOVW\OH ZVBYLVLEOHZVBFKLOGZVBERUGHU
(1',)
EVHWSDUHQWLG
'$7$SDUHQWLG7<3(LVFUHHQZLWKFRQWURO
,)SDUHQWLG,6,1,7,$/RQO\VHWILUVWWLPH
SDUHQWLG G\QSURBGHIDXOWG\QSURBGHIDXOWIURPFWOGHI!
(1',)
FFUHDWHFRQWURO
SAP AG 337
ABAP Workbench Delta Guide (3.1-4.6)
&$//)81&7,21
&21752/B&5($7(
(;3257,1*
FOVLG
6$3+70/&RQWURO
VKHOOVW\OH VKHOOVW\OH
SDUHQWLG SDUHQWLG
RZQHUBUHSLG V\FSURJ
QRBIOXVK FBWUXH
&+$1*,1*
KBFRQWURO KWPOBKDQGOH
(;&(37,216
FUHDWHBHUURU
FRQWUROBLQVWDOOBHUURU
LQYDOLGBSDUHQWLG
LOOHJDOBOLIHWLPH
27+(56
,)V\VXEUF!
0(66$*(D:,7+
(UURUGXULQJLQLWLDOL]DWLRQRI+70/FRQWURO
(1',)
(1')250&5($7(B+70/B&21752/
)RUP/,1.B&21752/B72B6&5((1B$5($
DVVLJQWKHFDOOHGFRQWUROWRWKHDUHDUHVHUYHGRQVFUHHQ
)250OLQNBFRQWUROBWRBVFUHHQBDUHD
&$//)81&7,21
&21752/B/,1.
(;3257,1*
KBFRQWURO KWPOBKDQGOH
UHSLG V\FSURJ
G\QQU
FRQWDLQHU
&75/B$5($BB
(1')250/,1.B&21752/B72B6&5((1B$5($
)RUP)/86+B48(8('B&21752/B&200$1'6
SAP AG 338
ABAP Workbench Delta Guide (3.1-4.6)
IOXVKDOOTXHXHGFRPPDQGV
*-------------------------------------------------------------
)250IOXVKBTXHXHGBFRQWUROBFRPPDQGV
&$//)81&7,21
&21752/B)/86+
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
(1')250)/86+B48(8('B&21752/B&200$1'6
Do not run your program at this stage, since when you exit it, some of the control processes
will remain active on your PC. Although these produce no visible output, they can adversely
affect other ABAP programs running over your frontend.
6DPSOH&(76WHS
We will now include the steps to exit the Control Framework in an orderly fashion. To do this,
we call the function module &21752/B'(6752< from various points in our program.
Add all of the EROG statements to your demonstration program.
0RGXOHV
MODULE exit_commands_0100 INPUT.
CASE ok_code.
WHEN ’EXIT’. "leave the program
3(5)250GHVWUR\BKWPOBFRQWURO
LEAVE PROGRAM.
WHEN ’CANCEL’. "cancel current screen
3(5)250GHVWUR\BKWPOBFRQWURO
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " EXIT_COMMANDS INPUT
SAP AG 339
ABAP Workbench Delta Guide (3.1-4.6)
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
)RUP5RXWLQHV
************************************************************
* Form DESTROY_HTML_CONTROL
************************************************************
* destroy the html ...
*------------------------------------------------------------
)250GHVWUR\BKWPOBFRQWURO
&$//)81&7,21
&21752/B'(6752<
&+$1*,1*
KBFRQWURO KWPOBKDQGOH
(;&(37,216
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
(1')250'(6752<B+70/B&21752/
You can now test your program without causing any strange effects on your PC.
The demonstration program now displays the reserved area for the control on screen 100.
However, it does not yet display the control itself. To do this, we still have to include some
specific method calls for the HTML control.
SAP AG 340
ABAP Workbench Delta Guide (3.1-4.6)
&):&DOOV:LWKRXW&RQWURO6SHFLILF0HWKRG&DOOV
)XQFWLRQ0RGXOHVIRU&RQWURO+DQGOLQJ
You can use the following function modules to handle control attributes and method calls.
SAP AG 341
ABAP Workbench Delta Guide (3.1-4.6)
&RQWURO+DQGOLQJ)XQFWLRQ0RGXOHV
5HPRWH/HDUQLQJ
&21752/B6(7B:,1'2:B3523(57< 6HWDYLVXDODWWULEXWHRIWKH
FRQWUROVL]HSRVLWLRQ
YLVLEOHDOLJQPHQW
&21752/B*(7B:,1'2:B3523(57< *HWDYLVXDODWWULEXWHRIWKH
FRQWUROVL]HSRVLWLRQ
YLVLEOHDOLJQPHQW
&21752/B6(7B3523(57< 6HWDQDWWULEXWHRIWKH
FRQWUROFXVWRPDWWULEXWHV
&21752/B*(7B3523(57< *HWDQDWWULEXWHRIWKH
FRQWUROFXVWRPDWWULEXWHV
&21752/B&$//B0(7+2' &DOODPHWKRGRIWKHFRQWURO
FXVWRPPHWKRG
SAP AG
6DPSOH&(76WHS
We will now call two methods specific to the HTML control. You have to know which they are,
but the SAP documentation contains a list.
We will
• Initialize the HTML control and
• Make the control navigate to a start page.
Add the following calls to the program (new parts are marked EROG).
0RGXOHV
MODULE html_control_pbo OUTPUT.
* call subroutines to handle control framework
* first: be sure to call the control framework only the first
* time you enter the screen
DATA: html_first_time TYPE c value c_true. "flag
"= global data!
IF html_first_time = c_true.
html_first_time = c_false.
* step 1 test gui type (windows type)
PERFORM test_gui_type.
SAP AG 342
ABAP Workbench Delta Guide (3.1-4.6)
)RUP5RXWLQHV
**********************************************************
* Form INIT_HTML_CONTROL
**********************************************************
* initialize the html control
*----------------------------------------------------------
)250LQLWBKWPOBFRQWURO
&$//)81&7,21
&21752/B&$//B0(7+2'
(;3257,1*
KBFRQWURO KWPOBKDQGOH
PHWKRG
,QLW&RQWURO
SBFRXQW
QRBIOXVK FBWUXH
,03257,1*
5(7851
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
(1')250,1,7B+70/B&21752/
SAP AG 343
ABAP Workbench Delta Guide (3.1-4.6)
**************************************************************
* Form SHOW_INITIAL_THML_PAGE
**************************************************************
* show initial html page in the control
*-------------------------------------------------------------
)250VKRZBLQLWLDOBKWPOBSDJH
&$//)81&7,21
&21752/B&$//B0(7+2'
(;3257,1*
KBFRQWURO KWPOBKDQGOH
PHWKRG
6KRZ8UO
SBFRXQW
QRBIOXVK FBWUXH
S XUO
S
,03257,1*
5(7851
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
(1')2506+2:B,1,7,$/B+70/B3$*(
The result of the program will be:
SAP AG 344
ABAP Workbench Delta Guide (3.1-4.6)
'HPRQVWUDWLRQ3URJUDP+70/&RQWURO:LWKRXW(YHQWV
(YHQW+DQGOLQJ
5HJLVWHU(YHQWV
You have to register events if you want to handle them within your ABAP program (see the
overview section).
There are two different types of events:
• Custom events from the control
SAP AG 345
ABAP Workbench Delta Guide (3.1-4.6)
• “Shell” events from the container hosting the control (such as ‘activate’ or ‘focus’). Use
IS_SHELLEVENT =’x’ to specify this type.
Predefined shell events (include <CTLDEF>):
• SHELL_DOUBLE_CLICK
• SHELL_CLICK
• SHELL_CLOSE
• SHELL_MENU_CLICK
• SHELL_MOVE
• SHELL_SIZE
&RQWURO)UDPHZRUN)XQFWLRQ0RGXOHV8VHGIRU(YHQW+DQGOLQJ
5HPRWH/HDUQLQJ
&21752/B5(*,67(5B(9(17 (QDEOHVDQHYHQWIURPWKH
FXUUHQWFRQWURO
&21752/B815(*,67(5B(9(17 'LVDEOHVDQHYHQWIURP
WKHFXUUHQWFRQWURO
SAP AG
(YHQW+DQGOHUDQG&DOOEDFNV
Events coming from the frontend are represented as function codes (OK_CODE). The
function code contains the ShellId (part of the control handle H_CNTL) and the EVENT_ID.
In the PAI event, the function code has to be analyzed to find out what happened and call the
correct routines. However, you do not need to do this by hand.
The Control Framework provides a mechanism that allows you to define callbacks (special
FORM routines) that are executed automatically when an event occurs. This means that you
do not have to use IF and CASE to sort out what to call and when.
SAP AG 346
ABAP Workbench Delta Guide (3.1-4.6)
&):)XQFWLRQ0RGXOHVIRU5HJLVWHULQJ(YHQW+DQGOLQJ&DOOEDFNV
5HPRWH/HDUQLQJ
SAP AG
Note that registering an event handler is separate from registering an event itself. When you
register an event, you tell the Control Framework that you want a particular event to be
passed back from the GUI to your program (using a special function code). Registering a
callback routine tells the Control Framework which routine it needs to execute when the event
is raised.
The callback is called by the ‘CONTROL_DISPATCH’ function module in the PAI event. You
define a callback using the <CALLBACK_FORM>/<CALLBACK_PROG> combination.
Technically speaking, the call that occurs when the event is triggered is PERFORM
(<CALLBACK_FORM>) IN PROGRAM (<CALLBACK_PROG>).
The callback technique is merely a convenient way of eliminating series of IF and CASE
conditions to determine which routine should be called.
You can register more than one callback for a particular H_CONTROL / EVENT combination.
However, this is NOT RECOMMENDED.
If OVERWRITE is selected, the ILUVW callback is redefined. Use the function module
CONTROL_UNREGISTER_CB first to deregister the first callback, then re-register it with the
new values.
Note that deleting a callback GRHVQRW deregister the event. To deregister an event, use
CONTROL_UNREGISTER_EVENT.
6DPSOH&(76WHS
We will now use the events returned by the HTML control. We will register both types of
events, register CALLBACK routines for the events raised by the HTML control, and
implement the CALLBACK routines.
SAP AG 347
ABAP Workbench Delta Guide (3.1-4.6)
3ULQFLSOH
To work with the events raised by the HTML control, that is,
• NAVIGATE_COMPLETE
• EVENT_ON_NAVIGATE
we have to use a special HTML page. Create the following HTML file (using Windows
Notepad) and save it locally on your PC:
+70/)LOH8VLQJ(YHQWV
5HPRWH/HDUQLQJ
+70/!
%2'<!
+!/RFDO+!
$+5() 6$3(9(17&/,&.!&OLFN$!
%5!
$+5() 6$3(9(17&/,&.!&OLFN$!
%5!
$+5() 6$3(9(17&/,&.!&OLFN$!
+5!
$+5() KWWSZZZVDSFRP!6$3$!
%2'<!
+70/!
SAP AG
We will use the link to the SAP homepage to demonstrate the effect of the event 1$9,*$7(
&203/(7( and will raise events of type (9(17B21B1$9,*$7( using the other links on
the page.
To show the effect of the event 1$9,*$7(B&203/(7( we will use the method *HW8UO of the
HTML control. So after each navigation step (different URL) we will fetch the newURL and will
copy it into the field 85/ displayed on screen 100.
To show the effect of an event of type (9(17B21B1$9,*$7( we will fetch the name of the
event as it is defined in the HTML page (here: 6$3(9(17&/,&., 6$3(9(17&/,&. and
6$3(9(17&/,&..) and will display the name in a modal dialog box (screen 110). (The
name of the event raised will be transferred as a parameter of the event
(9(17B21B1$9,*$7(.).
Add all of the EROG statements to your program.
0RGXOHV
02'8/(KWPOBFRQWUROBSER287387
* call subroutines to handle control framework
* first: be sure to call the control framework only the first
* time you enter the screen
SAP AG 348
ABAP Workbench Delta Guide (3.1-4.6)
)RUP5RXWLQHV
)RUP5(*,67(5B(9(176B$1'B&%56
UHJLVWHUHYHQWVDQGFDOOEDFNURXWLQHVHYHQWKDQGOHUIRU
WKHKWPOFRQWURO
WKHUHDUHWZRW\SHVRIHYHQWFODVVHVIRUWKHKWPOFRQWURO
QDYLJDWHBFRPSOHWH
WKHHYHQWFODVVFRQVLVWVRIWKHVLQJOHHYHQW
QDYLJDWHBFRPSOHWH
,WLVUDLVHGE\WKHKWPOFRQWURO
HYHU\WLPHDSDJHLVORDGHGFRPSOHWHO\
WKHHYHQWQDYLJDWHBFRPSOHWHKDVWKHHYHQWLG
HYHQWBRQBQDYLJDWH
HYHQWVRIWKLVFODVVDUHGHILQHGLQKWPOSDJHV7KH\FDQ
EHUDLVHGE\XVHULQWHUDFWLRQVRQWKHKWPOSDJH
HYHQWVRIWKHFODVVHYHQWBRQBQDYLJDWHKDYHWKH
HYHQWLG
ZKDW\RXGRKHUHLVWRUHJLVWHUERWKHYHQWFODVVHVDQGWKH
QDPHVRIWKHFRUUHVSRQGLQJHYHQWKDQGOHUDVFDOOEDFN
URXWLQHV
)250UHJLVWHUBHYHQWVBDQGBFEUV
UHJLVWHUHYHQWV
DHYHQWFODVV
QDYLJDWHBFRPSOHWH
SAP AG 349
ABAP Workbench Delta Guide (3.1-4.6)
&$//)81&7,21
&21752/B5(*,67(5B(9(17
(;3257,1*
KBFRQWURO KWPOBKDQGOH
HYHQW
QRBIOXVK FBWUXH
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
EHYHQWFODVV
HYHQWBRQBQDYLJDWH
&$//)81&7,21
&21752/B5(*,67(5B(9(17
(;3257,1*
KBFRQWURO KWPOBKDQGOH
HYHQW
QRBIOXVK FBWUXH
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
UHJLVWHUFDOOEDFNURXWLQHV
DFDOOEDFNURXWLQHIRUHYHQWFODVV
QDYLJDWHBFRPSOHWH
&$//)81&7,21
&21752/B5(*,67(5B(97B&%
(;3257,1*
HYHQW
FDOOEDFNBSURJ V\FSURJ
FDOOEDFNBIRUP
1&B(9(17B+$1'/(5
,03257,1*
&$//%$&.B,'
SAP AG 350
ABAP Workbench Delta Guide (3.1-4.6)
&+$1*,1*
KBFRQWURO KWPOBKDQGOH
(;&(37,216
FEBQRWBIRXQG
LQYBFDOOEDFNBGHILQLWLRQ
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
EFDOOEDFNURXWLQHIRUHYHQWFODVV
HYHQWBRQBQDYLJDWH
&$//)81&7,21
&21752/B5(*,67(5B(97B&%
(;3257,1*
HYHQW
FDOOEDFNBSURJ V\FSURJ
FDOOEDFNBIRUP
(21B(9(17B+$1'/(5
,03257,1*
&$//%$&.B,'
&+$1*,1*
KBFRQWURO KWPOBKDQGOH
(;&(37,216
FEBQRWBIRXQG
LQYBFDOOEDFNBGHILQLWLRQ
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
(1')2505(*,67(5B(9(176B$1'B&%56
Substitute the path name of your HTML file as the default value for PA_URL in the program.
If you now execute the program the result will look like this:
SAP AG 351
ABAP Workbench Delta Guide (3.1-4.6)
'HPRQVWUDWLRQ3URJUDP+70/&RQWURO:LWK(YHQWV
The program is still incomplete, and will not react to the events yet. We have not yet
registered the CALLBACK routines. However, the navigation to the SAP homepage will work
already.
'HILQLQJ&DOOEDFNV
SAP AG 352
ABAP Workbench Delta Guide (3.1-4.6)
6DPSOH&(76WHS
&$//%$&.'HILQLWLRQV
We will now implement the corresponding CALLBACK routines that work as default event
handlers for the HTML control in our program.
To implement event handling in our demonstration program, we need to:
• Define the global data (9(17B1$0(
• It is used to display the name of the event of type (9(17B21B1$9,*$7( raised in the
HTML page.
• Copy the specified CALLBACK routines to the demonstration program
• Create screen 110 as a modal dialog box and copy the flow logic specified
• NOTE: Do not forget to create a pushbutton on screen 110. Otherwise you will not be
able to close the modal dialog box without terminating your session.
• Copy the PAI module to exit screen 110
*OREDO'DWD'HILQLWLRQV
We need to define the following field as a global field in our program (we will use it on a
screen later).
'$7$HYHQWBQDPH7<3(FHYHQWQDPHWULJJHUHGIURP
GLVSOD\HGKWPOSDJH
,PSOHPHQWDWLRQRI&DOOEDFNV
Add the following new statements (marked in EROG) to the demonstration program:
(9(171$9,*$7(&203/(7(
FDOOEDFNQFBHYHQWBKDQGOHU
FDOOEDFNURXWLQHIRUHYHQW
QDYLJDWHFRPSOHWH
JHWWKHXUORIWKHFXUUHQWGLVSOD\HGSDJHLQWKHFRQWURO
&$//)81&7,21
&21752/B&$//B0(7+2'
(;3257,1*
KBFRQWURO KWPOBKDQGOH
PHWKRG
*HW&XUUHQW85/
QRBIOXVK FBWUXH
SAP AG 353
ABAP Workbench Delta Guide (3.1-4.6)
,03257,1*
UHWXUQ XUO
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
&/($5XUO
(1',)
HQGFDOOEDFN
(9(17(9(17211$9,*$7(
FDOOEDFNHRQBHYHQWBKDQGOHU
KWPOVSHFLILFHYHQWFRGH
VWHSGHWHUPLQHWKHHYHQWQDPH
3(5)250JHWBHYHQWBQDPH
VWHS
GLVSDWFK
HYHQWV
KHUHFDOODGLDORJER[ZKLFKGLVSOD\VWKHQDPHRI
WKHILUHGHYHQW
&$6(HYHQWBQDPH
:+(1
&/,&.
&$//6&5((167$57,1*$7
:+(1
&/,&.
&$//6&5((167$57,1*$7
:+(1
&/,&.
&$//6&5((167$57,1*$7
(1'&$6(
HQGFDOOEDFN
)RUP5RXWLQHV
)RUP*(7B(9(17B1$0(
GHWHUPLQHWKHQDPHRIWKHHYHQWRIFODVV
HYHQWBRQBQDYLJDWH
SAP AG 354
ABAP Workbench Delta Guide (3.1-4.6)
ILUHGIURPWKHKWPOSDJH
)250JHWBHYHQWBQDPH
SUHIL[OHQJWK
6$3(9(17
RI
HYHQWRQQDYLJDWH
&2167$176FBHYHQWBSUHIL[BOHQ7<3(L9$/8(
),(/'6<0%2/6IV!
&/($5HYHQWBQDPH
&$//)81&7,21
&21752/B*(7B(9(17B3$5$0
(;3257,1*
KBFRQWURO KWPOBKDQGOH
SDUDPBLG
QRBIOXVK
;
&+$1*,1*
UHWXUQ HYHQWBQDPH
(;&(37,216
FQWOBV\VWHPBHUURU
FQWOBHUURU
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(/6(ILOWHUHYHQWQDPH
HYHQWBQDPHKDVWKHIXOOQDPHRIWKHILUHGHYHQW
6$3(9(17HYHQWBQDPH!
FXWRXWWKHQDPH
HYHQWBQDPH!
$66,*1SBHYHQWBQDPHFBHYHQWBSUHIL[BOHQ
72IV!
HYHQWBQDPH IV!
(1',)
(1')250
)ORZ/RJLFRI6FUHHQ
352&(66%()25(287387
02'8/(67$786B
352&(66$)7(5,1387
02'8/(XVHUBFRPPDQGB
SAP AG 355
ABAP Workbench Delta Guide (3.1-4.6)
0RGXOHV8VHGE\6FUHHQ
* close the modal dialog box
*-------------------------------------------------------------
02'8/(XVHUBFRPPDQGB,1387
/($9(726&5((1
(1'02'8/(86(5B&200$1'B,1387
/D\RXWRI6FUHHQ
To execute the event handling in the correct way, our program still needs one last step:
The automatic dispatching of the function codes returned by the GUI when the control raises
an event.
(YHQW'LVSDWFKLQJ
SAP AG 356
ABAP Workbench Delta Guide (3.1-4.6)
You must call this function module in all PAI modules of programs that use controls.
6DPSOH&(76WHS(YHQW'LVSDWFKLQJ
Add the following new statements (marked in EROG) to the demonstration program:
0RGXOHV
* react to all ’user interactions’ here
* possible ’user interactions’ are:
* 1. function codes of type ’ ’ raised from standard
* user interface or from bush buttons on the
* screen
HYHQWVILUHGIURPWKHFRQWURO
*------------------------------------------------------------
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN ’BACK’. "function code from user interface
PERFORM destroy_html_control. "destroy control
LEAVE TO SCREEN 0. "leave the program
WHEN OTHERS. "handle control events here
3(5)250GLVSDWFKBHYHQWVGLVSDWFKFRQWUROHYHQWV
3(5)250IOXVKBTXHXHGBFRQWUROBFRPPDQGV
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
)RUP5RXWLQHV
**************************************************************
* Form DISPATCH_EVENTS
**************************************************************
* give the technical function codes raised by the control
* framework on the desktop to the framework part on the
* application server level. The called function module
* addresses the previously assigned callback routines to the
* function codes
*-------------------------------------------------------------
)250GLVSDWFKBHYHQWV
SAP AG 357
ABAP Workbench Delta Guide (3.1-4.6)
&$//)81&7,21
&21752/B',63$7&+
(;3257,1*
IFRGH VDYHBRN
6<67(0
(;&(37,216
FEBQRWBIRXQG
27+(56
,)V\VXEUF!
0(66$*(,'6<06*,'7<3(6<06*7<180%(56<06*12
:,7+6<06*96<06*96<06*96<06*9
(1',)
(1')250',63$7&+B(9(176
Now your program will execute the defined CALLBACK routines correctly.
The result of a mouse click on one of the first three links will raise the corresponding event
that will be transferred by the GUI (Control Framework) to your program via a function code
that is dispatched by the function module CONTROL_DISPATCH. This function module will
execute the CALLBACK routine that calls screen 110. The result will look like this:
SAP AG 358
ABAP Workbench Delta Guide (3.1-4.6)
&RPSOHWH'HPRQVWUDWLRQ3URJUDP+70/&RQWURO:LWK(YHQWV
&RQWUROV)XUWKHU5HDGLQJ
Control Enabling
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
HTML Control
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
Tree Control
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
Image Control
7RYLHZWKHZKROHFKDSWHUFRQWH[WXVHWKHEXWWRQ6\QFKURQL]H
SAP AG 359
ABAP Workbench Delta Guide (3.1-4.6)
6DPSOH+70/&RQWURO
3XUSRVH
This program is a demonstration of the working principle of Control Enabling Technology
without using a control wrapper.
It uses the HTML control as an example to show how to use CET. The HTML control is a
control of medium complexity.
The program has two screens. Screen 100 is used as container for the HTML control that is
used inplace. Screen 110 is used as a dialog box to demonstrate the effect of events raised in
the HTML control. It displays the name of the custom event triggered by the control when you
click a special link on an HTML page.
6FUHHQV
6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE html_control_pbo.
*
PROCESS AFTER INPUT.
MODULE exit_commands_0100 AT EXIT-COMMAND.
MODULE user_command_0100.
6FUHHQ
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0110.
*
PROCESS AFTER INPUT.
MODULE user_command_0110.
8VHU,QWHUIDFH
*8,7LWOH
The program has the following GUI title:
SCREEN_0100 Display Screen Containing HTML Control
*8,6WDWXV
The program has the following GUI status:
SCREEN_0100 Status for screen 100
)XQFWLRQV
The GUI status contains three functions: %$&., &$1&(/ and (;,7. The %$&. function is a
normal function (type ‘ ’). The &$1&(/ and (;,7 functions are exit commands (type ‘E’).
SAP AG 360
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP
Program Z_CET_HTML1 is an executable program (type 1).
'HFODUDWLRQ3DUWRIWKH3URJUDP
REPORT z_cet_html_1 MESSAGE-ID pc.
INCLUDE <ctldef>. "needed for CET
**************************************************************
* T Y P E S
**************************************************************
* 1. used for control enabling variables
TYPES: t_clsid(80) TYPE c, "control class id
t_shellstyle TYPE i, "shell style
t_parentid TYPE i, "parent id
t_event_name(20) TYPE c, "event name
t_url(80) TYPE c. "url name
* 2. general
TYPES: t_flag TYPE c. "indicator
**************************************************************
* D A T A
**************************************************************
* 1. html-control
DATA: html1_handle TYPE cntl_handle, "html_handle
win32_flag TYPE t_flag, "flag for gui type
shellstyle TYPE t_shellstyle, "windows shellstyle
parentid TYPE t_parentid, "screen with control
html_first_time TYPE t_flag. "flag used in pbo of
"screen 100
DATA: url TYPE t_url,"url of displayed html page
event_name TYPE t_event_name. "event name (fired
"from displayed html page)
* 2. screen specific
DATA: ok_code LIKE sy-ucomm, "user_command
save_ok LIKE ok_code. "copy of ok_code
**************************************************************
C O N S T A N T S
**************************************************************
CONSTANTS:
* 1. control enabling, used shortcuts: NC = navigate complete
* EON = event on navigate
* - general
c_container_100_1 LIKE screen-name VALUE
SAP AG 361
ABAP Workbench Delta Guide (3.1-4.6)
’CTRL_AREA_0100_01’,
c_clsid TYPE t_clsid VALUE
’SAP.HTMLControl.1’,
* - event ids (->html control specific)
c_evid_eon TYPE i VALUE 1,
c_evid_nc TYPE i VALUE 2,
* - callback routines -> event handler
c_cbf_nc_name LIKE sy-repid VALUE
’NC_EVENT_HANDLER’,
c_cbf_eon_name LIKE sy-repid VALUE
’EON_EVENT_HANDLER’,
* - prefix length ’SAPEVENT:’ of ’event on navigate’
c_event_prefix_len TYPE i VALUE 9,
* 2. other
c_repid LIKE sy-repid VALUE ’Z_CET_HTML_1’,
c_dynnr LIKE sy-dynnr VALUE 100,
c_true TYPE t_flag VALUE ’X’,
c_false TYPE t_flag VALUE ’ ’.
6WDQGDUG6HOHFWLRQ6FUHHQ
* url of start page used in browser
SELECTION-SCREEN COMMENT /1(65) text-s01.
PARAMETERS:
pa_url LIKE url.
0DLQ3DUW
START-OF-SELECTION. "copy parameter to global variable
url = pa_url.
3%20RGXOHVRI6FUHHQ
02'8/(67$786B287387
* set user interface for screen 100
*-------------------------------------------------------------
MODULE status_0100 OUTPUT.
SET PF-STATUS ’SCREEN_0100’.
SET TITLEBAR ’SCREEN_0100’.
ENDMODULE. " STATUS_0100 OUTPUT
02'8/(+70/B&21752/B3%2
* do all steps needed for control framework and all steps
* specific to html control here
SAP AG 362
ABAP Workbench Delta Guide (3.1-4.6)
*-------------------------------------------------------------
MODULE html_control_pbo OUTPUT.
* call subroutines to handle control framework
* first: be sure to call the control framework only the first
* time you enter the screen
IF html_first_time = c_false.
html_first_time = c_true.
* step 1 test gui type (windows type)
PERFORM test_gui_type.
* step 2 init control enabling framework
PERFORM initialize_control_framework.
* step 3 create control (html)
PERFORM create_html_control.
* step 4 link control to screen area
PERFORM link_control_to_screen_area.
* step 5 control specific method calls, collect data, ...
PERFORM init_html_control.
PERFORM show_initial_html_page.
* step 6 flush
PERFORM flush_queued_control_commands.
* step 7 register events and callback routines
PERFORM register_events_and_cbrs.
* step 8 flush again
PERFORM flush_queued_control_commands.
ENDIF.
ENDMODULE. " HTML_CONTROL_PBO OUTPUT
3$,0RGXOHVRI6FUHHQ
02'8/(86(5B&200$1'B,1387
* react to all ’user interactions’ here
* possible ’user interactions’ are:
* 1. function codes of type ’ ’ raised from standard
* user interface or from pushbuttons on the
* screen
* 2. events fired from the control
*------------------------------------------------------------*
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN ’BACK’. "function code from user interface
SAP AG 363
ABAP Workbench Delta Guide (3.1-4.6)
02'8/((;,7B&200$1'6B,1387
* react to all function codes of type ’E’ here
*-------------------------------------------------------------
MODULE exit_commands_0100 INPUT.
CASE ok_code.
WHEN ’EXIT’. "leave the program
PERFORM destroy_html_control.
LEAVE PROGRAM.
WHEN ’CANCEL’. "cancel current screen
PERFORM destroy_html_control.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " EXIT_COMMANDS INPUT
3$,0RGXOHVRI6FUHHQ
02'8/(86(5B&200$1'B,1387
* close the modal dialog box
*-------------------------------------------------------------
MODULE user_command_0110 INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " USER_COMMAND_0110 INPUT
)RUP5RXWLQHV
)2507(67B*8,B7<3(
* test whether controls can be called or not
*---------------------------------------------------------
FORM test_gui_type.
* check for appropriate frontend
CALL FUNCTION ’GUI_HAS_ACTIVEX’
IMPORTING
return = win32_flag.
IF win32_flag IS INITIAL.
MESSAGE a011 WITH ’Invalid Frontend’(001).
ENDIF.
SAP AG 364
ABAP Workbench Delta Guide (3.1-4.6)
)250,1,7,$/,=(B&21752/B)5$0(:25.
FORM initialize_control_framework.
* initialize the control framework
CALL FUNCTION ’CONTROL_INIT’
EXCEPTIONS
control_init_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE a011
WITH ’Error during initialization of control framework’
(002).
ENDIF.
)250&5($7(B+70/B&21752/
FORM create_html_control.
* a) set shell style
* use the constants ws_visible, ws_child, ws_border
* which are predefined in the include <ctldef>
* information source about windows variables: windows.h
* (GUI)
IF shellstyle IS INITIAL. "only set first time
shellstyle = ws_visible + ws_child + ws_border.
ENDIF.
* b) set parent id
IF parentid IS INITIAL. "only set first time
parentid = dynpro_default. "dynpro_default from <ctldef>
ENDIF.
* c) create control
CALL FUNCTION ’CONTROL_CREATE’
EXPORTING
clsid = c_clsid
shellstyle = shellstyle
parentid = parentid
owner_repid = c_repid
no_flush = c_true
CHANGING
h_control = html1_handle
EXCEPTIONS
SAP AG 365
ABAP Workbench Delta Guide (3.1-4.6)
create_error = 1
control_install_error = 2
invalid_parentid = 3
illegal_lifetime = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE a011 WITH
’Error during initialization of HTML control’(003).
ENDIF.
)250/,1.B&21752/B72B6&5((1B$5($
* assign the called control to the area reserved on screen 100
*-------------------------------------------------------------
FORM link_control_to_screen_area.
)250)/86+B48(8('B&21752/B&200$1'6
* flush all queued commands
*-------------------------------------------------------------
FORM flush_queued_control_commands.
CALL FUNCTION ’CONTROL_FLUSH’
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SAP AG 366
ABAP Workbench Delta Guide (3.1-4.6)
)250'(6752<B+70/B&21752/
* destroy the html ...
*------------------------------------------------------------
FORM destroy_html_control.
CALL FUNCTION ’CONTROL_DESTROY’
CHANGING
h_control = html1_handle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DESTROY_HTML_CONTROL
)250,1,7B+70/B&21752/
* initialize the html control
*----------------------------------------------------------
FORM init_html_control.
CALL FUNCTION ’CONTROL_CALL_METHOD’
EXPORTING
h_control = html1_handle
method = ’InitControl’
p_count = 0
no_flush = c_true
* IMPORTING
* RETURN =
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
)2506+2:B,1,7,$/B+70/B3$*(
* show initial html page in the control
*-------------------------------------------------------------
SAP AG 367
ABAP Workbench Delta Guide (3.1-4.6)
FORM show_initial_html_page.
CALL FUNCTION ’CONTROL_CALL_METHOD’
EXPORTING
h_control = html1_handle
method = ’ShowUrl’
p_count = 2
no_flush = c_true
p1 = url
p2 = ’ ’
* IMPORTING
* RETURN = RET_CODE
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
)2505(*,67(5B(9(176B$1'B&%56
*&-----------------------------------------------------------*
* register events and callback routines (event handler) for
* the html control
* there are two types of event classes for the html control:
* - navigate_complete
* the event class consists of the single event
* ’navigate_complete’. It is raised by the html control
* every time a page is loaded completely
* - event_on_navigate
* events of this class are defined in html pages. They can
* be raised by user interactions on the html page
*
* what you do here is to register both event classes and the
* names of the corresponding event handler as callback
* routines
*------------------------------------------------------------*
FORM register_events_and_cbrs.
* 1. register events
* a) event class ’navigate_complete’
CALL FUNCTION ’CONTROL_REGISTER_EVENT’
EXPORTING
SAP AG 368
ABAP Workbench Delta Guide (3.1-4.6)
h_control = html1_handle
event = c_evid_nc
no_flush = c_true
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SAP AG 369
ABAP Workbench Delta Guide (3.1-4.6)
EXCEPTIONS
cb_not_found = 1
inv_callback_definition = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
)250',63$7&+B(9(176
* give the technical function codes raised by the control
* framework on the desktop to the framework part on the
* application server level. The called function module
* addresses the previously assigned callback routines to the
* function codes
*-------------------------------------------------------------
FORM dispatch_events.
CALL FUNCTION ’CONTROL_DISPATCH’
SAP AG 370
ABAP Workbench Delta Guide (3.1-4.6)
EXPORTING
fcode = save_ok
* SYSTEM = ’ ’
EXCEPTIONS
cb_not_found = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
)250*(7B(9(17B1$0(
* determine he name of the event of class ’event_on_navigate’
* fired from the html page
*-------------------------------------------------------------
FORM get_event_name.
FIELD-SYMBOLS: <fs>.
CLEAR event_name.
CALL FUNCTION ’CONTROL_GET_EVENT_PARAM’
EXPORTING
h_control = html1_handle
param_id = 2
* no_flush = ’X’
CHANGING
return = event_name
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE. "filter event name
* g_event_name has the full name of the fired event:
* ’SAPEVENT:<event_name>’
* cut out the name ’<event_name>’
SAP AG 371
ABAP Workbench Delta Guide (3.1-4.6)
*
ASSIGN event_name+c_event_prefix_len(*) TO <fs>.
event_name = <fs>.
ENDIF.
&$//%$&.5RXWLQHV
All callback routines are defined using the macro defined in the include <ctldef>
&$//%$&.1&B(9(17B+$1'/(5
***********************************************************
* E V E N T : N A V I G A T E C O M P L E T E
***********************************************************
callback nc_event_handler.
* callback routine for event ’navigate complete’
* get the url of the current displayed page in the control
CALL FUNCTION ’CONTROL_CALL_METHOD’
EXPORTING
h_control = html1_handle
method = ’GetCurrentURL’
no_flush = c_true
IMPORTING
return = url
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CLEAR url.
ENDIF.
endcallback.
&$//%$&.B(21B(9(17B+$1'/(5
**************************************************************
* E V E N T : E V E N T O N N A V I G A T E
**************************************************************
callback eon_event_handler.
SAP AG 372
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 373
ABAP Workbench Delta Guide (3.1-4.6)
2IILFH,QWHJUDWLRQ
After reviewing the following topics, you will be able to:
Understand the architecture and technical context
Explain the new concepts in Release 4.6
Identify the basic steps in Release 4.6
Identify central steps for managing documents in Release 4.6
Identify the new features about data transfer between R/3 and desktop applications
Explain the news about how to handle events
SAP AG 374
ABAP Workbench Delta Guide (3.1-4.6)
,QWURGXFWLRQDQG2YHUYLHZ
The full documentation for SAP Desktop Office Integration is available here .
5DQJHRI)XQFWLRQVDQG%HQHILWV
The R/3 4.0/4.5 integration technology through ABAP Objects (via ABAP OO interfaces)
enables the generic integration of any OLE2-compatible desktop applications, such as
Microsoft Office, Lotus SmartSuite or Visio with the SAP R/3 System. Communication and
data transfer are performed using object-oriented ABAP interfaces that utilize the component
concept of the 4.0 SAPgui, as well as the standard Microsoft OLE2 technology.
The wide-ranging scope of functions provided by this approach to desktop integration in SAP
R/3 can be divided into the following areas: DSSOLFDWLRQFRQWURO, LQWHJUDWLQJ5GDWDLQ
GRFXPHQWV, and FRPPXQLFDWLQJZLWKWKH56\VWHP.
&RQWUROOLQJD'HVNWRS$SSOLFDWLRQ
$SSOLFDWLRQ&RQWURO
Desktop applications can be started and exited from within the R/3 System, and documents
can be opened, saved, printed, and closed. In the process, document handling is performed
directly through the R/3 memory and OLE2, instead of the local file system used in previous
approaches. Downloading files to the PC, with all the problems posed by performance, write
privileges, and disk capacity, is no longer necessary – only somewhat more main memory is
required. Furthermore, SAP-specific menus and menu items can be easily integrated in the
corresponding applications using OLE2.
,Q3ODFH$FWLYDWLRQ
Documents can be activated in-place for display or editing in SAPgui screens. The desktop
application becomes a part of the R/3 screen. This represents a major simplification for the
end user, who no longer has to open an additional program in an extra window, and who only
sees the menus and menu entries that are relevant for the specific situation at hand.
SAP AG 375
ABAP Workbench Delta Guide (3.1-4.6)
,Q3ODFH$FWLYDWLRQRI06([FHOLQWKH6$3JXL
,QWHJUDWLQJ5'DWDLQ'RFXPHQWV
/LQNVWR5'DWD5HOHDVH
SAP objects such as fields, internal tables, bitmaps, and RTF texts, can be inserted in
documents through OLE links. Documents can then be treated as templates that contain links
to R/3 data. These links are replaced by data at runtime when the document is displayed,
controlled by the R/3 System, and can be updated at runtime. In addition to the direct
insertion of data in the document, this data can also be addressed from within a macro
programming language like Visual Basic for Applications (VBA), for example.
7DEOHB&ROOHFWLRQ5HOHDVH
The table collection allows you to pass data (especially the content of internal tables) from the
R/3 System to the desktop application. The desktop applications can then work with the data
and store it in work areas. They can also export it back to the R/3 System.
The data is incorporated in the desktop application using the SAP TableFactory OCX, which
is used for RFC programming under Visual Basic.
6SUHDGVKHHW,QWHUIDFH5HOHDVH
SAP AG 376
ABAP Workbench Delta Guide (3.1-4.6)
The spreadsheet interface allows you to use R/3 data in a spreadsheet and return changed
data to the R/3 System. You communicate with named ranges in the spreadsheet document
(a technique supported by all spreadsheets).
To exchange data, you use internal tables with predefined structures. Since the data
exchange is controlled from ABAP, you do not have to program your own macros.
The spreadsheet interface currently supports Microsoft Excel and Lotus 1-2-3.
0DLOPHUJH,QWHUIDFH5HOHDVH
You can use this interface to address mailmerge functions within the office application. It
allows you to transfer R/3 data to the frontend and merge it into a mailmerge template. To
transfer the data you use an internal table, each row of which represents the set of data to be
merged into a single document. Since everything is controlled from within ABAP, you do not
have to program your own macros.
The mailmerge interface currently supports Microsoft Word and Lotus WordPro.
)RUP,QWHUIDFH5HOHDVH
The form interface allows you to transfer R/3 data into user-defined fields in a document. You
can also retrieve data from the fields in the form and use them in your ABAP program. The
data exchange uses an internal table.
The entire process is controlled from within ABAP, so you do not have to program your own
macros.
The form interface currently supports Microsoft Word, Microsoft Excel, and Lotus WordPro.
&RPPXQLFDWLRQZLWKWKH56\VWHP8VLQJ
(YHQWV
The handling of this events in the ABAP program does not differ from the handling of other
ABAP OO events.
7HFKQRORJLFDO$UFKLWHFWXUH
6$35DQG2/(
SAP R/3 supports the full range of the OLE2 automation standard in Release 3.0 and later.
With the integration technology available in R/3 Release 4.0, SAP now also supports OLE2
documents and OLE2 controls for integrating desktop applications. In the process, OLE2
documents and OLE2 controls form the foundation for embedding or linking to R/3 data in
documents and in-place activation, as well as for communication between application and R/3
via events.
6$3JXL&RQWUROV
As part of the SAPgui 4.0 Client Component Framework, SAP has implemented various
controls that significantly improve the ease of use of the GUI. In addition to various other
controls, SAP also provides the SAP Document Container Control and den SAP Data
Provider as specific GUI controls particularly important for integrating PC applications.
SAP AG 377
ABAP Workbench Delta Guide (3.1-4.6)
6XPPDU\DQG2XWORRN
SAP AG 378
ABAP Workbench Delta Guide (3.1-4.6)
The integration of desktop applications in the SAP R/3 System using ABAP objects and the
component concept of the SAPgui has enormous potential. Desktop integration in the R/3
System alone represents a significant gain in productivity for end users. The applications that
are best suited to the task at hand can be used in many places in the R/3 System. normally
already know how to use the applications, which means that training costs can be reduced.
When the technical implementation of the desktop integration provides options for the
selection and migration of desktop applications that are as flexible as the described solution,
the required maintenance is also low. As a result, the total cost of ownership can be
significantly reduced.
In future releases of the R/3 System, the approaches described above will be used to
integrate even more desktop applications and components in suitable places in the standard
R/3 transactions, resulting in ever greater benefits for end users. At the same time, SAP will
continue to extend the features of the integration technology.
$UFKLWHFWXUHDQG7HFKQLFDO&RQWH[W
2YHUYLHZ5HOHDVH
From Release 4.0, there is a standardized solution for integrating any OLE2-capable desktop
application (such as Microsoft Office, Lotus SmartSuite or Visio) with the R/3 System.
Communication and data transfer is implemented by using object-oriented ABAP interfaces
that take advantage of the component concept of Version 4.6 of SAPgui and Microsoft’s
standard OLE2 technology. The presentation host must be running under Windows NT 4.0 or
Windows 95/ 98/ 2000.The document is processed directly by R/3 memory and OLE2 (files
are no longer downloaded to the PC).You can display and edit documents “in place” within
R/3 screens displayed using SAPgui 4.6.
In 5HOHDVH$ the ABAP Control Framework has been shifted to ABAP Objects
technology.
SAP AG 379
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZRIWHFKQLFDO&RPSRQHQWV
5HPRWH/HDUQLQJ
5 :LQGRZVRU:LQGRZV17
3&
$%$3 *8, $SSOLFDWLRQ
$%$32EMHFWV 'RFXPHQW
0HWKRGV 6 &RQWDLQHU
(YHQWV
&RQWURO
$
3
*
8
5GDWD
'RFXPHQWV
, 'DWD
/LQNGDWD 3URYLGHU
7DEOHV
CET (Control Enabling Technology
CF (Control Framework)
SAP AG
You can insert SAP objects (such as fields, internal tables, bitmaps, and RTF texts) into
documents in the relevant desktop application using OLE links. You can also address these
objects from within a macro language such as Visual Basic for Applications (VBA). In contrast
to the desktop integration solution in Release 3.x, the new solution provides parallel
processing in ABAP and the PC application, that is, programs on both sides can react to user
input.
Desktop applications can trigger events in R/3 to which you can react in the relevant ABAP
program. This makes two-way communication between R/3 and the desktop application
possible.
The SAP Document Container Control uses methods and attributes to communicate with the
desktop application using OLE2 interfaces and events.
The SAP Data Provider is a container and converter for data in various formats. It acts as a
buffer for the R/3 data that is either inserted into a document using an OLE link or addressed
by macros in the document. Documents and data are addressed using URLs.
SAP AG 380
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUDFWLRQVDQG&RPPXQLFDWLRQ
5HPRWH/HDUQLQJ
5
6$3JXL
6$3
(YHQWV 'RFXPHQW (YHQWV
&RQWDLQHU
$%$3FODVVHVDQG
&RQWURO LQWHUIDFHVIRU
0HWKRGV 0HWKRGV
Excel RIILFHLQWHJUDWLRQ
'DWD
3URYLGHU
'RFXPHQW 85/V
GDWD 5'%
5LQIR
:HE UHSRVLWRU\
/RFDO VHUYHU
3&ILOH
SAP AG
6HHDOVR
5XQWLPH&RPSRQHQWV
There is a range of ABAP interfaces containing specific methods that you can use to
implement Desktop Office Integration. At runtime, you create the interface-specific objects in
a predefined order.
The central instance administers the office integration. It contains methods that you use to
create other objects that you need.
The document management instance contains information about the URL address of a
document. Its methods allow you to execute various office functions. Events that the office
application can trigger are also registered under this instance.
The link server administers links to R/3 objects (such as fields and internal tables), and allows
you to transfer data from R/3 into the office document.
Tables_Collection (Release 4.5A), allows you to transfer data in both directions between the
R/3 System and office documents based on internal tables.
If an office application has an application-specific interface, you can generate an instance of
it. This instance contains application-specific methods that are not valid for all office
applications (wordprocessing and spreadsheet specific finctionality).
SAP AG 381
ABAP Workbench Delta Guide (3.1-4.6)
$UFKLWHFWXUHRIWKH5XQWLPH&RPSRQHQWV
5HPRWH/HDUQLQJ
&UHDWHV &UHDWHV
'RFXPHQW
$SSOLFDWLRQVSHFLILF
3UR[\
&HQWUDOREMHFW LQWHUIDFHV
IRUPDQDJLQJ
&UHDWHV
2IILFH :RUGSURFHVVRU$
/LQNVHUYHU
,QWHJUDWLRQ 6SUHDGVKHHW$
0DLO0HUJH$
&UHDWHV )RUP)LHOGV$
7DEOHB&ROOHFWLRQ
$
$%$32EMHFWV
'HVNWRS
6$3JXLFRQWUROV
6$3 6$3 2/(
'RFXPHQW 'DWD LQWHUIDFH 2IILFHDSSOLFDWLRQV
&RQWDLQHU 3URYLGHU
&RQWURO
SAP AG
See also
2YHUYLHZRI$%$32EMHFWV,QWHUIDFHV
You define the required objects with reference to the ABAP Objects interfaces listed below.
SAP AG 382
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZRI$%$3,QWHUIDFHV
5HPRWH/HDUQLQJ
LBRLBFRQWDLQHUBFRQWURO$
Display or edit in R/3 window
and in separate window
LBRLBGRFXPHQWBSUR[\$
Office functions: Open, Close, Save, Play, Print, …
and generic event handling
LBRLBPDLOPHUJH$
LBRLBIRUP$
Supplies mailmerge functions of
Data exchange between R/3 and
wordprocessor applications with
form fields of office applications
R/3 data
SAP AG
The interface LBRLBFRQWDLQHUBFRQWURO allows you to open a desktop application either in the
R/3 window ("in-place") or in a separate window. Use the static method
JHWBFRQWDLQHUBFRQWURO of class FBRLBFRQWDLQHUBFRQWUROBFUHDWRUto get an instance of this
interface. Use the methods of this instance to get access to all other interfaces
1HZ&RQFHSWVLQ5HOHDVH
In Release 4.6, SAP Desktop Office Integration and the Control Framework have switched
over to global classes. Within the Control Framework, global container classes have also
been introduced, in which objects such as an Office Integration instance can be displayed.
These changes have had the following effects on the programming model for Office
Integration.
*OREDO&ODVVHVDQG,QWHUIDFHV
The changeover to global classes and interfaces has meant that the names of the classes
used in Office Integration have changed slightly. You no longer have to use the include
programs previously required. It is still possible to work with the old names by including the
RIILFHLQWHJUDWLRQLQFOXGH include program, but changes in the way that container objects are
handled mean that programs from earlier releases that use Office Integration must be
changed in any case. This change applies to the method LQLWBFRQWURO of
LBRLBFRQWDLQHUBFRQWURO.
At the beginning of your program, you should declare the type group 62,. This allows you
access to all of the data types used in Office Integration.
SAP AG 383
ABAP Workbench Delta Guide (3.1-4.6)
2EMHFW2ULHQWHG&RQWURO)UDPHZRUNDQG&RQWDLQHU&RQFHSW
In Release 4.6, the Control Framework switched to global classes. This, and the way in which
screen containers are handled, has lead to some unavoidable incompatible changes in Office
Integration. These apply mainly to the use of container objects:
<RXFDQQRORQJHUSDVVWKHQDPHRIDFRQWDLQHUWRWKHLQLWBFRQWUROPHWKRGRI
LQWHUIDFHLBRLBFRQWDLQHUBFRQWURO,QVWHDG\RXPXVWILUVWLQVWDQWLDWHDFRQWDLQHUREMHFW
WKHQSDVVLWVUHIHUHQFHWRWKHQHZSDUDPHWHUSDUHQW7KHROGSDUDPHWHUJXLBFRQWDLQHU
LVQRZREVROHWH
Event if you use the old interface LBRLBROHBFRQWDLQHUBFRQWURO by including
RIILFHLQWHJUDWLRQLQFOXGH, you must fill the new SDUHQW parameter in the LQLWBFRQWURO method.
The screen areas used for displaying an office application in-place should be defined using
the 6FUHHQ3DLQWHU (&XVWRP&RQWURO object in the element toolbar). The old methods
VHWBZLQGRZBSURSHUWLHV, VHWBLQSODFHBERUGHUBVSDFH, and OLQNBFRQWURO of interface
LBRLBFRQWDLQHUBFRQWURO are now obsolete and should no longer be used.
6$3UHFRPPHQGVWKDW\RXXVHWKHJOREDOFODVVHVDQGLQWHUIDFHVZKHQ
SURJUDPPLQJ2IILFH,QWHJUDWLRQDSSOLFDWLRQVIURP5HOHDVHLQVWHDGRIWKHORFDO
FODVVHVDQGLQWHUIDFHVXVHGLQ5HOHDVHRIILFHLQWHJUDWLRQLQFOXGH<RXVKRXOG
RQO\XVHWKHLQWHUIDFHLBRLBFRQWDLQHUBFRQWURO7KHSUHYLRXVDOWHUQDWLYHIRUVWDUWLQJWKH
GHVNWRSDSSOLFDWLRQLQDVHSDUDWHZLQGRZXVLQJLBRLBGRFXPHQWBIDFWRU\LVQRORQJHU
VXSSRUWHG7RVSHFLI\ZKHWKHUWKHGHVNWRSDSSOLFDWLRQVKRXOGEHRSHQHGLQSODFHRULQ
DVHSDUDWHZLQGRZVHWWKHRSHQBLQSODFHSDUDPHWHULQWKHUHOHYDQWPHWKRGIRUFUHDWLQJ
RURSHQLQJDGRFXPHQWVHHMethods of the Interface i_oi_document_proxy
To allow it to use the new object-oriented Control Framework, Office Integration inherits from
the class FOBJXLBREMHFW. The method JHWBFRQWUROBREMHFW of LBRLBFRQWDLQHUBFRQWURO returns
a direct reference to an instance of the class cl_gui_object. You can use this reference to call
methods of the Control Framework directly.
&RQWDLQHUKDQGOLQJDQGLQLWLDOL]DWLRQ
&RQWDLQHUFRQFHSW
352*5$0VDSGUOBRLB
7<3(322/6VRL
&/$66FBRLBHUURU'(),1,7,21/2$'
'$7$RIILFH7<3(5()72LBRLBFRQWDLQHUBFRQWURO
'$7$HUURU7<3(5()72LBRLBHUURU
'$7$FRQWDLQHU7<3(5()72FOBJXLBFXVWRPBFRQWDLQHU
&$//0(7+2'FBRLBFRQWDLQHUBFRQWUROBFUHDWRU !JHWBROHBFRQWDLQHUBFRQWURO
,03257,1*
&21752/ RIILFH
(5525 HUURU
5(7&2'( UHWFRGH
&5($7(2%-(&7FRQWDLQHU
(;3257,1*
FRQWDLQHUBQDPH µ&RQWDLQHUµ
&$//0(7+2'RIILFH!LQLWBFRQWURO
(;3257,1*
3$5(17 FRQWDLQHU
,13/$&(B(1$%/(' µ;µ
12B)/86+ VSDFH
,03257,1*
5(7&2'( UHWFRGH
(5525 HUURU
SAP AG 1999
SAP AG 384
ABAP Workbench Delta Guide (3.1-4.6)
12B)/86+3DUDPHWHU
In line with the changes to the Control Framework, nearly all methods in SAP Desktop Office
Integration now have an importing parameter QRBIOXVK (default setting = space). This
parameter allows you more control over the performance of your controls in the network
environment. If you set QRBIOXVK
;
, the method call is not sent directly to the frontend.
Instead, it is placed in the automation queue on the application server. These calls are then
sent to the presentation server and executed in a bundle when the next method call is sent
with QRBIOXVK VSDFH or at the end of the PBO (whichever comes first).
7KLVEXQGOLQJRIPHWKRGFDOOVUHGXFHVWKHQXPEHURIURXQGULSVDQGWKHUHIRUHWKH
QHWZRUNORDG)RUIXUWKHULQIRUPDWLRQUHIHUWRSynchronizing the Automation Queue
(55252EMHFWV
From Release 4.6, Office Integration methods return both the return code and an error object
called error with the type LBRLBHUURU. To use this object, you must load the error class
definition using the statement &/$66FBRLBHUURUV'(),1,7,21/2$'. The actual parameter
that is to receive the error object must be defined with reference to LBRLBHUURU. The object has
a method JHWBPHVVDJH which returns the message text. You can also display the message
text using the methodUDLVHBPHVVDJH. Both methods are defined in LBRLBHUURU.
7KHUHWXUQFRGHDQGHUURUREMHFWGRQRWFRQWDLQWKHLUFRUUHFWYDOXHVXQWLODIWHUWKH
DXWRPDWLRQTXHXHKDVEHHQV\QFKURQL]HG,WLVWKHUHIRUHDJRRGLGHDWRFROOHFW\RXU
HUURUREMHFWVLQDQLQWHUQDOWDEOHDQGWRORRSWKURXJKWKHWDEOHORRNLQJIRUHUURUVDIWHU
WKHDXWRPDWLRQTXHXHKDVEHHQV\QFKURQL]HG
1HZ,QWHUIDFHV
The following new interfaces are available in Office Integration from Release 4.6:
• LBRLBVSUHDGVKHHW: Enables data exchange between R/3 applications and a spreadsheet
• LBRLBIRUP: Enables data exchange between R/3 applications and fields in forms in an
office document
• LBRLBPDLOBPHUJH: Allows you to control mailmerge functions from an ABAP program and
use R/3 data in the documents
• LBRLBZRUGBSURFHVVRUBGRFXPHQW: Allows you to control certain word processing
functions from your ABAP programs
You call the methods of these interfaces from your ABAP program, which means that there is
less need for macro programming than previously.
You get references to the new interfaces by calling the appropriate method of the interface
LBRLBGRFXPHQWBSUR[\. For each interface, there is also a method of LBRLBGRFXPHQWBSUR[\
that you can use to check beforehand whether the desktop application supports the interface:
,QWHUIDFH &KHFNVXSSRUWPHWKRGRI *HWUHIHUHQFHPHWKRGRI
LBRLBGRFXPHQWBSUR[\ LBRLBGRFXPHQWBSUR[\
spreadsheet has_spreadsheet_interface get_spreadsheet_interface
form has_form_interface get_form_interface
mailmerge has_mail_merge_interface get_mail_merge_interface
word processor has_wordprocessor_interface get_wordprocessor_interface
SAP AG 385
ABAP Workbench Delta Guide (3.1-4.6)
'RFXPHQW0DQDJHPHQW
Release 4.6 of the SAP System contains the new %XVLQHVV'RFXPHQW6HUYLFH%'6. This
is a document management service that has an ABAP API - the global class
&/B%'6B'2&80(17B6(7. The BDS allows you to administer documents in the R/3
database or on a separate content server. It allows you to
• Version documents
• Search for documents by attributes
• Access documents using an internal table or a URL
Office Integration can use the URLs generated by the BDS for getting or storing documents. It
can also collaborate with the BDS using internal tables.
You are strongly recommended to store desktop documents, images, and other data in the
BDS and not directly in the R/3 database. Documents from the BDS can be cached at the
frontend and therefore only have to be loaded over the network once.
12B)/86+3DUDPHWHU
1HWZRUN3HUIRUPDQFH/$1:$1
In conjunction with the changes to the Control Framework, the optional import parameter
QRBIOXVK has been added to nearly all Office Integration methods (default value = space).
This parameter allows you to control the performance of your controls in the network
environment. If you set QRBIOXVK
;
the method call is not sent to the frontend
immediately. Instead, it is placed in the automation queue on the application server.
There are certain points at which all of the queued methods in the automation queue are sent
to the frontend and executed:
• When a method call occurs with the parameter QRBIOXVK VSDFH
• At the end of the PBO
• When you explicitly call the static method FOBJXLBFIZ !IOXVK
7KLVPHFKDQLVPDOORZV\RXWREXQGOH\RXUPHWKRGFDOOVVRLQVWHDGRI
WUDQVIHUULQJVHYHUDOVLQJOHPHWKRGFDOOVWRWKHIURQWHQGWKHV\VWHPFDQVHQGDODUJHU
VHWLQRQHRSHUDWLRQ7KLVUHGXFHVWKHQXPEHURIURXQGWULSVDQGUHGXFHVWKHQHWZRUN
ORDG6LQFHSHUIRUPDQFHSUREOHPVFDQRIWHQRFFXUZKHQ\RXXVHIURQWHQGFRQWUROV
\RXVKRXOGXVHWKHQRBIOXVKSDUDPHWHUZKHUHYHUSRVVLEOH7KHGHIDXOWVHWWLQJRI
QRBIOXVKLVVSDFHLQZKLFKFDVHWKHPHWKRGFDOOLVIOXVKHGLPPHGLDWHO\7RSODFHWKH
PHWKRGFDOOLQWKHDXWRPDWLRQTXHXHLQVWHDG\RXPXVWVHWQRBIOXVK ;
Automation Queue
([HFXWLQJ0HWKRGVDQG5HFHLYLQJ3DUDPHWHUV
5HPHPEHUWKDWTXHXHGPHWKRGFDOOVDUHQRWVHQWWRWKHIURQWHQGXQWLOWKHIOXVK
RFFXUV&RQVHTXHQWO\WKHLPSRUWLQJSDUDPHWHUVLQWKHPHWKRGFDOODUHQRWILOOHGXQWLO
DIWHUWKHIOXVKDQGKHQFHGRQRWFRQWDLQWKHFRUUHFWYDOXHVXQWLOWKHQ<RXFDQQRWXVH
UHWXUQHGYDOXHVXQWLODIWHUWKHIOXVK,I\RXQHHGWKHYDOXHV\RXPXVWIOXVKWKHPHWKRG
FDOOLPPHGLDWHO\XVHQRBIOXVK VSDFH
This behavior also applies to the return code and error object returned by all Office Integration
methods.
SAP AG 386
ABAP Workbench Delta Guide (3.1-4.6)
'HEXJJLQJ
If you experience problems when programming using the no_flush parameter, you may find it
helpful to synchronize the automation queue after each individual method call. This will show
you which method call is causing the problem. To do this, start the Debugger, then choose
6HWWLQJV and select $XWRPDWLRQ&RQWUROOHU$OZD\VSURFHVVUHTXHVWVV\QFKURQRXVO\. The
methods are then processed individually instead of in a bundle, and their return values, return
codes, and error object are available immediately.
If the error no longer occurs when you run the program like this, it is very likely that one or
more flushes is missing, that is, no_flush = ’X’ has been set wrongly somewhere in the
program.
You can also create a trace for the automation queue. To do this, select $XWRPDWLRQin the
7UDFHgroup of the 6$3JXLVHWWLQJV. Now all automation queue calls and their parameters are
logged in a trace file. If an error occurs, it is logged in the trace file.
7KH(55252EMHFW
From Release 4.6, Office Integration methods return, in addition to the return code UHWFRGH,
an error object HUURU with the type LBRLBHUURU. In order to use this feature, you must declare
the class FBRLBGHILQLWLRQ at the start of your program using the statement
CLASS c_oi_definition DEFINITION LOAD.
You can find out the contents of the error object using the method JHWBPHVVDJH, or display
the message using the method UDLVHBPHVVDJH. Both methods are defined inLBRLBHUURU and
can be called for any error object.
If a method call is successful, the UHWFRGH parameter has the value 2.. If an error occurs, it
returns an error code instead. The class FBRLBHUURUV contains constants for all error codes
and the OK code.
The static method raise_message of class c_oi_errors displays a message in the status bar
containing the precise cause of the error. You call the method directly after a method call in
Office Integration:
CALL METHOD document->do_something
EXPORTING ...
&$//0(7+2'&B2,B(55256 !5$,6(B0(66$*(
(;3257,1*7<3( W\SH
In the method call, you specify the type that the message should have (A, E, W, I, S). This
determines how your program is processed further.
If an error occurs in the method, the system automatically selects an appropriate message
from the message class 62)),&(,17(*5$7,21 and displays it with the specified type. If no
error occurs, program processing continues as normal.
%RWKWKHUHWXUQFRGHDQGHUURUREMHFWDUHILOOHGZLWKWKHLUFRUUHFWYDOXHVDIWHUWKH
DXWRPDWLRQTXHXHKDVEHHQV\QFKURQL]HG&RQVHTXHQWO\ZKHQ\RXSURFHVVHUURU
REMHFWVLWLVDJRRGLGHDWRFROOHFWWKHPLQDQLQWHUQDOWDEOH$IWHUWKHDXWRPDWLRQ
TXHXHKDVEHHQV\QFKURQL]HG\RXFDQORRSWKURXJKWKHLQWHUQDOWDEOHWRFDWFKWKH
HUURUVDQGRXWSXWWKHPHVVDJHV
3URFHGXUH
1. At the start of your program, make the necessary data declarations:
TYPE-POOLS soi.
SAP AG 387
ABAP Workbench Delta Guide (3.1-4.6)
%DVLF6WHSV
At the beginning of your data declarations, include the type pool VRLand the class definition
&/$66FBRLBHUURUV'(),1,7,21/2$'These make the necessary error class, data, and
type definitions available in the program.
With Release 4.6a it is no longer neccessary to include the includes FWOGHI! and
RIILFHLQWHJUDWLRQLQFOXGH. All interfaces and classes of SAP Desktop Office Integration are now
globally accessible in your system.
SAP AG 388
ABAP Workbench Delta Guide (3.1-4.6)
7\SHVDQG(UURU&ODVV'HILQLWLRQV
5HPRWH/HDUQLQJ
0DLQSURJUDP
723LQFOXGH
352*5$0VDSGUOBRLB
7<3(322/6VRL
&/$66FBRLBHUURUV'(),1,7,21/2$'
SAP AG
see also
There is a central starting point of creating the central instance for Office Integration
administration: You can open the office application either in a separate window or within the
R/3 window. In either case, use the class method JHWBFRQWDLQHUBFRQWURO of the class
FBRLBFRQWDLQHUBFRQWUROBFUHDWRU. You must define the object with reference to the central
interface LBRLBFRQWDLQHUBFRQWURO.
The interface LBRLBFRQWDLQHUBFRQWURO has methods that you can call for the central instance
(which is called RIILFH in the example below ). They allow you to create the other instances
that you need for office integration.
You also have to define a FRQWDLQHUREMHFW with reference to the class
FOBJXLBFXVWRPBFRQWDLQHUand call its constructor to create the object. This container object
is a mandatory importing parameter of the method LQLWBFRQWURO of LBRLBFRQWDLQHUBFRQWURO.
If you want to open the application within the R/3 window you have to define a custom
container area within the dynpro using the screenpainter. The application will be opened
within this area.
see also
If you want to open the office application in a separate window you can also proceed the
way described above: You trigger the opening in a separate window by a respectice
parameter of the open_document methods of i_oi_document_proxy.
(The approach using the interface LBRLBGRFXPHQWBIDFWRU\ and the class method
JHWBGRFXPHQWBIDFWRU\ of class FBRLBIDFWRU\BFUHDWRU still works if you include
RIILFHLQWHJUDWLRQLQFOXGHBut with Release 4.6a this interface is no longer supported in the
context of global classes. It is preferable to avoid the use of the LBRLBGRFXPHQWBIDFWRU\ and to
use LBRLBFRQWDLQHUBFRQWURO instead in all cases.)
See also
SAP AG 389
ABAP Workbench Delta Guide (3.1-4.6)
&UHDWLQJWKH&HQWUDO2EMHFW2YHUYLHZ
5HPRWH/HDUQLQJ
2IILFHLQWHJUDWLRQ
LQWKH5ZLQGRZ
RULQDVHSDUDWHZLQGRZ
&ODVV
&B2,B&217$,1(5B&21752/B&5($725
&ODVVPHWKRG
*(7B&217$,1(5B&21752/
&HQWUDOREMHFW
IRU
2IILFH
,QWHJUDWLRQ
DGPLQLVWUDWLRQ
,B2,B&217$,1(5B&21752/
SAP AG
&UHDWLQJWKHFHQWUDO2EMHFWV6\QWD[
5 HP RW H/ HDU QL QJ
0DLQSURJUDP
352*5$0VDSGUOBRLB
7<3(322/6VRL
&/$66FBRLBHUURU'(),1,7,21/2$'
'$7$RIILFH7<3(5()72LBRLBFRQWDLQHUBFRQWURO
'$7$HUURU7<3(5()72LBRLBHUURU
'$7$FRQWDLQHU7<3(5()72FOBJXLBFXVWRPBFRQWDLQHU
&$//0(7+2'FBRLBFRQWDLQHUBFRQWUROBFUHDWRU !JHWBROHBF RQWDLQH UBFRQWU RO
,03257,1*
&21752/ RIILFH
(5525 HUURU
5(7&2'( UHWFRGH
&5($7(2%-(&7FRQWDLQHU
(;3257,1*
FRQWDLQHUBQDPH µ&RQWDLQHUµ
SAP AG
SAP AG 390
ABAP Workbench Delta Guide (3.1-4.6)
2IILFH$SSOLFDWLRQ5XQQLQJLQDQ5:LQGRZ
'HILQLWLRQ6WHSVLQWKH6FUHHQRQ:KLFK<RX
:DQWWR5XQWKH'HVNWRS$SSOLFDWLRQ
On the screen in which you want the desktop application to appear, define a custom control
container. From Release 4.5, there is a Screen Painter function that allows you to do this. In
the following example, the container is called OFFICE_APPL. Like any other screen object,
you can maintain special attributes for these containers in the Screen Painter (for example,
resizing attributes).
'HILQLQJD&RQWDLQHURQWKH6FUHHQ6FUHHQ3DLQWHU
SAP AG 391
ABAP Workbench Delta Guide (3.1-4.6)
6WDUWLQJD&RQWDLQHU&RQWUROLQWKH6$3JXL
Use in the ABAP program the method LQLWBFRQWURO to start a container control in the SAPgui.
,QRelease 4.6a incompatible changes were made to this method due to changes in the
Control Framework and the way in which containers are handled within the SAPgui. The
GUI_CONTAINER parameter is now obsolete and has been replaced by the new parameter
3$5(17. This takes a reference to a container object that you have already created with
reference to FOBJXLBFXVWRPBFRQWDLQHU
,QLWLDOL]DWLRQRID&RQWDLQHU&RQWUROLQWKH6$3JXL
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLBB
'$7$RIILFH7<3(5()72LBRLBROHBFRQWDLQHUBFRQWURO
'$7$FRQWDLQHU7<3(5()72FOBJXLBFXVWRPBFRQWDLQHU
...
&5($7(2%-(&7FRQWDLQHU
(;3257,1*
&217$,1(5B1$0( µ2IILFHB$SSOµ
&$//0(7+2'RIILFH!LQLWBFRQWURO
(;3257,1*
5B$33/,&$7,21B1$0(
'HPR
,13/$&(B(1$%/('
;
,13/$&(B6&52//B'2&80(176
;
3$5(17 &RQWDLQHU
,03257,1*
5(7&2'( 5(7&2'(
SAP AG
See also
'HVWUR\LQJWKH&RQWDLQHU&RQWURO
When you have finished with the document, delete the central instance on the desktop using
the method GHVWUR\BFRQWURO. You should also explicitly destroy all other instances that you
have created. To delete the relevant ABAP Object, use the FREE statement.
You should also call the FREE method of your container object and then delete the
container object using the FREE statement.
SAP AG 392
ABAP Workbench Delta Guide (3.1-4.6)
'HVWUXFWLRQRIWKH&RQWDLQHU&RQWURODQGWKH&RQWDLQHUREMHFWLQWKH6$3JXL
5HPRWH/HDUQLQJ
0DLQSURJUDP
352*5$0VDSGUOBRLBB
'$7$RIILFH7<3(5()72LBRLBROHBFRQWDLQHUBFRQWURO
'$7$FRQWDLQHU7<3(5()72FOBJXLBFXVWRPBFRQWDLQHU
'$7$HUURU7<3(5()72LBRLBHUURU
...
&$//0(7+2'RIILFH!GHVWUR\BFRQWURO
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
)5((RIILFH
&$//0(7+2'FRQWDLQHU!IUHH
)5((FRQWDLQHU
SAP AG
See also
6DPSOH2IILFH$SSO5XQQLQJLQDQ5:LQGRZ
%DVLF3URJU6WHSV
*HQHUDO'HVFULSWLRQRI3URJUDP
This program demonstrates the programming steps required to display an office application
"in-place" in an R/3 window.
The program is a module pool (type M) with a single screen. The user interface of the screen
contains three functions:
- Create document ( function code ,16(57 )
- Close document ( function code &/26( )
- Exit ( function code 6723IXQFWLRQW\SHH[LW )
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLBB
INCLUDE D45RL_OI_1_45TOP.
INCLUDE D45RL_OI_1_45O01.
INCLUDE D45RL_OI_1_45I01.
When you run the program, screen 100 is processed.
SAP AG 393
ABAP Workbench Delta Guide (3.1-4.6)
'DWD'HILQLWLRQV,QFOXGHSURJUDPGUOBRLBWRS
*& Include D45RL_OI_1_45TOP
DATA already_done.
DATA is_open.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Word.Document.8’.
DATA okcode(15).
3%2(YHQWRI6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the interface
SAP AG 394
ABAP Workbench Delta Guide (3.1-4.6)
3$,(YHQWRI6FUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE CREATE_BASIC_OBJECTS.
MODULE USER_COMMAND_0100.
3$,3URFHVVLQJRI6FUHHQ
,QWHUIDFHIXQFWLRQ,16(57FUHDWHVDQHZGRFXPHQW
Starts Microsoft Word "in-place" in the R/3 window.
SAP AG 395
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUIDFHIXQFWLRQ&/26(&ORVHVWKHGRFXPHQW
Closes Microsoft Word.
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGLVVWRSSHG
,QWHUIDFHIXQFWLRQ6723VWRSV$%$3SURJUDP
Å Processes the PAI module H[LW.
$%$30RGXOHV
,QFOXGHSURJUDPGUOBRLBBR
MODULE STATUS_0100 OUTPUT.
SAP AG 396
ABAP Workbench Delta Guide (3.1-4.6)
,QFOXGHSURJUDPGUOBRLBBL
MODULE EXIT INPUT.
CASE okcode.
WHEN ’STOP’.
IF NOT document IS INITIAL.
FREE document.
ENDIF.
IF NOT office IS INITIAL.
CALL METHOD office->destroy_control
IMPORTING
error = error
retcode = retcode.
FREE office.
ENDIF.
IF NOT container IS INITIAL.
CALL METHOD container->free.
FREE container.
ENDIF.
SET SCREEN 0.
ENDCASE.
ENDMODULE.
SAP AG 397
ABAP Workbench Delta Guide (3.1-4.6)
inplace_scroll_documents = ’X’
parent = container
no_flush = ’’
IMPORTING
retcode = retcode.
CALL METHOD office->get_document_proxy
EXPORTING
document_type = document_type
no_flush = ’’
IMPORTING
document_proxy = document
retcode = retcode
error = error.
already_done = ’X’.
ENDMODULE.
WHEN ’CLOSE’.
CHECK NOT is_open IS INITIAL.
CALL METHOD document->close_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
SAP AG 398
ABAP Workbench Delta Guide (3.1-4.6)
error = error
retcode = retcode.
is_open = ’ ’.
ENDCASE.
ENDMODULE
2IILFH$SSOLFDWLRQ5XQQLQJLQD6HSDUDWH
:LQGRZ
6WHSVLQ5HOHDVH
The programming in Release 4.5 is not very different to that in Release 4.0. However, in
Release 4.6A, the introduction of the object-oriented Control Framework and the consequent
changes to the way in which containers are handled mean that certain Office Integration
parameters (especially those related to the definition and extension of screen areas) are now
obsolete. Any obsolete methods are indicated as such in the online documentation.
See also
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
([DPSOH
CALL METHOD OFFICE->INIT_CONTROL
EXPORTING
R3_APPLICATION_NAME = ’Demo Document Container’(000)
INPLACE_MODE = 0
SHELL_STYLE = 0
RECEIVING “ Ä
RETCODE = RETCODE.
([DPSOH
CALL METHOD OFFICE->INIT_CONTROL
EXPORTING
R3_APPLICATION_NAME = 'Demo Document Container'(000)
INPLACE_MODE = 0
SHELL_STYLE = 0
IMPORTING “ Ä
RETCODE = RETCODE.
SAP AG 399
ABAP Workbench Delta Guide (3.1-4.6)
([DPSOH
CALL METHOD OFFICE->INIT_CONTROL
EXPORTING
R3_APPLICATION_NAME = ’Demo Document Container’(000)
parent = Container
no_flush = ’x’
IMPORTING “ ERROR error
RETCODE = RETCODE.
6DPSOH2IILFH$SS5XQQLQJLQD6HSDUDWH
:LQGRZ%DVLF6WHSV
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
*HQHUDO'HVFULSWLRQRI3URJUDP
The program demonstrates the programming steps required to start an office application in a
separate window.
The program is a module pool (type M) with a single screen. Its user interface contains the
following three functions:
- Create document ( function code ,16(57 )
- Close document ( function code &/26( )
- Exit ( function code 6723 )
3URJUDP6WUXFWXUHDQG)ORZ
0DLQ3URJUDPVDSGUOBRLB[
INCLUDE D45RL_OI_1XTOP.
INCLUDE D45RL_OI_1XO01.
INCLUDE D45RL_OI_1XI01.
When you run the program, screen 100 is processed.
'DWD'HILQLWLRQV,QFOXGHSURJUDPGUOBRLB[WRS
*& Include D45RL_OI_1TOP
PROGRAMSAPD45RL_OI_1XMESSAGE-ID BCTRAIN.
TYPE-POOLS: soi.
CLASS c_oi_errors DEFINITION LOAD.
*Instance-Definition for the central object of office-
*integration:
DATA: office TYPE REF TO i_oi_container_control.
SAP AG 400
ABAP Workbench Delta Guide (3.1-4.6)
DATA already_done.
DATA is_open.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Word.Document.8’.
DATA okcode(15).
3%2(YHQWRI6FUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100.“Set the user interface
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGQRW\HWVWDUWHG
3$,(YHQWRI6FUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
SAP AG 401
ABAP Workbench Delta Guide (3.1-4.6)
MODULE CREATE_BASIC_OBJECTS.
MODULE USER_COMMAND_0100.
3$,3URFHVVLQJRI6FUHHQ
,QWHUIDFHIXQFWLRQ,16(57&UHDWHVDQHZGRFXPHQW
Starts Microsoft Word in a separate window.
2IILFH$SSOLFDWLRQ06:RUGVWDUWHGLQDVHSDUDWH:LQGRZ
,QWHUIDFHIXQFWLRQ&/26(&ORVHVWKHGRFXPHQW
Closes the document.
,QWHUIDFHIXQFWLRQ67236WRSV$%$3SURJUDP
Processes the PAI module H[LW.
$%$30RGXOHV
,QFOXGHSURJUDPGUOBRLB[R
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
ENDMODULE.
,QFOXGHSURJUDPGUOBRLB[L
MODULE EXIT INPUT.
CASE OKCODE.
WHEN ’STOP’.
IF NOT document IS INITIAL.
SAP AG 402
ABAP Workbench Delta Guide (3.1-4.6)
FREE document.
ENDIF.
IF NOT office IS INITIAL.
CALL METHOD office->destroy_control
IMPORTING
error = error
retcode = retcode.
FREE office.
ENDIF.
IF NOT container IS INITIAL.
CALL METHOD container->free.
FREE container.
ENDIF.
SET SCREEN 0.
ENDCASE.
ENDMODULE.
SAP AG 403
ABAP Workbench Delta Guide (3.1-4.6)
document_type = document_type
no_flush = ’’
IMPORTING
document_proxy = document
retcode = retcode
error = error.
ALREADY_DONE = ’X’.
ENDMODULE.
WHEN ’CLOSE’.
CHECK NOT is_open IS INITIAL.
CALL METHOD document->close_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
is_open = ’ ’.
ENDCASE.
SAP AG 404
ABAP Workbench Delta Guide (3.1-4.6)
ENDMODULE.
&HQWUDO6WHSVIRU0DQDJLQJ'RFXPHQWV
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
To create an instance to manage a document, use the method JHWBGRFXPHQWBSUR[\. If you
want to handle several documents in parallel you need a separate instance for each
document.
,QVWDQFHIRU:RUNLQJZLWK'RFXPHQWV
5HPRWH/HDUQLQJ
,QVWDQFH
ZLWKW\SH
LBRLBFRQWDLQHUBFRQWURO
,QVWDQFH
ZLWKW\SH
LBRLBGRFXPHQWBSUR[\
&HQWUDOREMHFW
IRU
2IILFH 'RFXPHQW
,QWHJUDWLRQ
DGPLQLVWUDWLRQ 0HWKRG
*(7B'2&80(17B352;<
SAP AG
See also
To specify the office application that you want to start, use the parameter GRFXPHQWBW\SH
(example, :RUG'RFXPHQW). For a list of the document types registered on the frontend
machine, use the method JHWBUHJLVWHUHGBGRFBW\SHV. See the documentation for further
details.
See also
SAP AG 405
ABAP Workbench Delta Guide (3.1-4.6)
,QVWDQFHIRU:RUNLQJZLWK'RFXPHQWV
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$RIILFH7<3(5()72LBRLBFRQWDLQHUBFRQWURO
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
&$//0(7+2'RIILFH!JHWBGRFXPHQWBSUR[\
(;3257,1*
'2&80(17B7<3( GRFXPHQWBW\SH
,03257,1*
'2&80(17B352;< GRFXPHQW
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
Below is a list of most of the methods and all events defined for the interface
LBRLBGRFXPHQWBSUR[\. The following pages explain the most important methods in more
detail.
0HWKRGVDQG(YHQWVIRU'RFXPHQW,QVWDQFHV
5HPRWH/HDUQLQJ
LBRLBGRFXPHQWBSUR[\
(YHQWV
on_custom_event on_close_document
0HWKRGV
create_document open_document play_document
view_document close_document save_document_to_url
release_document save_as save_copy_as
print_document execute_macro get_document_handle
get_document_type has_standard_interface reopen_document
page_setup select_all clear_selection
cut_selection copy_selection paste_clipboard
paste_special
add_menu_bar add_menu_popup add_menu_item
delete_menu_item is_open has_changed
is_destroyed
has_wordprocessor_interface get_wordprocessor_interface
has_spreadsheet_interface get_spreadsheet_interface
has_form_interface get_form_interface
has_mail_merge_interface get_mail_merge_interface
SAP AG
SAP AG 406
ABAP Workbench Delta Guide (3.1-4.6)
See also
If the methods of the interface LBRLBGRFXPHQWBSUR[\are not sufficient to manipulate a
document you can use the methodJHWBGRFXPHQWBKDQGOHThe method
JHWBGRFXPHQWBKDQGOH returns the handle of the document that is currently active. This
enables you to address methods and attributes of the application-specific object model using
ABAP OLE Automation Controller statements.
See also
Use the method FUHDWHBGRFXPHQW to create a new document in the office application. If you
want to open the document in the R/3 window, set the RSHQBLQSODFH parameter ( You have to
define this at the method LQLWBFRQWUROtoo: parameter LQSODFHBPRGH. Note that only one
document may be open at a time when the desktop application is running within the R/3
window.
See also
You can use the parameter FUHDWHBYLHZBGDWD to specify whether you want to save
presentation data with the document. If you do save the presentation data, you can
subsequently view the document using the YLHZBGRFXPHQW method without having to open
the relevant office application.
See also
&UHDWLQJD1HZ'RFXPHQW
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
&$//0(7+2'GRFXPHQW!FUHDWHBGRFXPHQW
(;3257,1*
23(1B,13/$&(
&5($7(B9,(:B'$7$
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
Use the method RSHQBGRFXPHQW to open an existing document in the office application. If
you want to open the document in the R/3 window, set the parameter RSHQBLQSODFH. Note that
only one document may be open at a time when you run the office application in the R/3
window.
You can determine whether the document should be opened in display or change mode by
setting the parameters SURWHFWBGRFXPHQW and RSHQBUHDGRQO\.
SAP AG 407
ABAP Workbench Delta Guide (3.1-4.6)
The parameter SURWHFWBGRFXPHQW ¶[¶triggers the opening of the document in display mode.
If a document has been opened using only the setting RSHQBUHDGRQO\ µ[¶(and
SURWHFWBGRFXPHQW µµ it is still possible to change it and save it afterwards. However, the
system does not provide you with any information about whether the document has been
changed.
Specify the URL address of the document using the parameter GRFXPHQWBXUO. This is the
location from which the document is read.
See also
2SHQLQJDQ([LVWLQJ'RFXPHQW
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
GDWDGRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
LWHPBXUO
&$//0(7+2'GRFXPHQW!RSHQBGRFXPHQW
(;3257,1*
'2&80(17B85/ LWHPBXUO
23(1B,13/$&(
23(1B5($'21/<
3527(&7B'2&80(17
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
There are various locations in which you can store and manage documents:
,QWKH56\VWHP
Documents that you store in the R/3 database need to be loaded into an internal table in
ABAP when required. To make the document available to the frontend, you must generate a
URL for it using the function module '3B&5($7(B85/. This also transfers the document
from the application server to the memory of the frontend server.
5HOHDVH If, in Release 4.0, you want to transfer a changed document back from the
desktop application into the R/3 System (that is, the corresponding ABAP program), there is a
series of necessary programming steps:
a) Use the function module 6$3B2,B*(7B81,48(B85/to generate a unique URL.
b) Use the method VDYHBGRFXPHQWBWRBXUOto place the document in an RFC table at the
frontend.
c) Use the function module '3B*(7B675($0B)520B85/ to transfer the document into an
ABAP table).
SAP AG 408
ABAP Workbench Delta Guide (3.1-4.6)
See also
To transfer a document from the front end back to R/3 (an internal table in an ABAP program)
use the method VDYHBGRFXPHQWBWRBWDEOH
See also
5HOHDVH From Release 4.6, the SAP System contains the Business Document
Service (BDS). This is a document administration system with an ABAP programming
interface. You can check documents into the BDS from the frontend and retrieve them later
using a URL or by transferring them into an internal table. The documents are stored on a
separate content server. Using the BDS therefore reduces the load on the database. You can
use URLs returned by the BDS in the open_document and save_document_to_url methods
of SAP Desktop Office Integration. You can also load a document from the BDS into an
internal table and open it from there using the open_document_from_table method. Likewise,
if you save a document using the Office Integration method save_document_to_table , you
can pass the internal table directly back to the BDS.
2QD:HEVHUYHU
The URL must be made up of the prefix HTTP://, the host name, and the path.
2QDQ)73VHUYHU
The URL must be made up of the prefix FTP://, the host name, and the path.
/RFDOO\RQWKH5SUHVHQWDWLRQVHUYHU
The URL must begin with the string FILE://, followed by the relevant path.
85/V
5HPRWH/HDUQLQJ
85/JHQHUDWLRQIXQFWLRQPRGXOHV
5 '3B&5($7(B85/
'RFXPHQWLQLQWHUQDOWDEOH
$SSO 6$35
6HUYHU
'3B&5($7(B85/B)520B7$%/(
5GDWDLQLQWHUQDOWDEOH
'HVNWRS
:HEVHUYHU 5IURQWHQG
+773KRVWSDWK!
),/(SDWK!
)73VHUYHU
3& )73KRVWSDWK!
SAP AG
SAP AG 409
ABAP Workbench Delta Guide (3.1-4.6)
Use the method FORVHBGRFXPHQW to close a document in the office application. Note that the
document is retained internally to allow you to save it ( to release the document entirely, use
the method UHOHDVHBGRFXPHQW. The parameter KDVBFKDQJHG tells you whether the
document has been changed. Use the GRBVDYH parameter to specify whether you want to
hold the document in the memory or not.
Intermediate saving (i.e. calling VDYHBGRFXPHQWbefore calling FORVHBGRFXPHQW is
possible.
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
&$//0(7+2'GRFXPHQW!FORVHBGRFXPHQW
(;3257,1*
'2B6$ (
12B)/86+
,03257,1*
+$6B&+$1*(' KDVBFKDQJHG
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
SAP AG 410
ABAP Workbench Delta Guide (3.1-4.6)
6HHDOVR
5HOHDVLQJWKH0HPRU\2FFXSLHGE\D'RFXPHQW
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
&$//0(7+2'GRFXPHQW!UHOHDVHBGRFXPHQW
(;3257,1*
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
Use the method VDYHBGRFXPHQWBWRBXUO to save a document under the specified URL.
SAP AG 411
ABAP Workbench Delta Guide (3.1-4.6)
6DYLQJD'RFXPHQW
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
...
GRFBXUO
&$//0(7+2'GRFXPHQW!VDYHBGRFXPHQWBWRBXUO
(;3257,1*
85/ GRFBXUO
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
:RUNLQJZLWK'RFXPHQWV3URFHVV)ORZ
5HPRWH/HDUQLQJ
*HWBGRFXPHQWBSUR[\ &RQWDLQHUZLWKRXW
GRFXPHQW
$SSOLFDWLRQQRW
UXQQLQJ RSHQBGRFXPHQW
FUHDWHBGRFXPHQW
UHOHDVHBGRFXPHQW YLHZBGRFXPHQW
SOD\BGRFXPHQW
&RQWDLQHUZLWK &RQWDLQHUZLWK
GRFXPHQW GRFXPHQW
$SSOLFDWLRQ $SSOLFDWLRQ
FORVHG UXQQLQJ
FORVHBGRFXPHQW
See also
SAP AG 412
ABAP Workbench Delta Guide (3.1-4.6)
6DPSOH&HQWUDO6WHSV)RU0DQDJLQJ
'RFXPHQWV
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
*HQHUDO'HVFULSWLRQRI3URJUDP
This program demonstrates the essential ways of editing office documents and their logical
program context.
The program is a module pool (type M) with two screens - 100 and 101. Screen 101 is a
dialog box.
The user interface of screen 100 has six functions:
• Create document ( function code ,16(57 )
• Change document ( function code &+$1*( )
• Display document ( function code ',63/$< )
• Save document ( function code 6$9( )
• Close document ( function code &/26( )
• Exit ( function code 6723typeH[LWFRPPDQG )
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLB
INCLUDE D45RL_OI_2TOP.
INCLUDE D45RL_OI_2O01.
INCLUDE D45RL_OI_2I01.
INCLUDE D45RL_OI_2F01.
When you run the program, screen 100 is processed
'DWD'HILQLWLRQV,QFOXGHSURJUDPGUOBRLBWRS
*& Include D45RL_OI_2TOP
PROGRAM SAPD45RL_OI_2 MESSAGE-ID BCTRAIN.
TYPE-POOLS: soi.
CLASS c_oi_errors DEFINITION LOAD.
SAP AG 413
ABAP Workbench Delta Guide (3.1-4.6)
3%2(YHQWRIVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the user interface
MODULE set_values.
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGQRW\HWVWDUWHG
3$,(YHQWRIVFUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
SAP AG 414
ABAP Workbench Delta Guide (3.1-4.6)
3$,SURFHVVLQJRIVFUHHQ
,QWHUIDFHIXQFWLRQ,16(57&UHDWHVDQHZGRFXPHQW
Starts Microsoft Word in a separate window.
2IILFH$SSOLFDWLRQ06:RUGVWDUWHGLQDVHSDUDWH:LQGRZ
,QWHUIDFHIXQFWLRQ&+$1*(&KDQJHVDGRFXPHQW
A dialog box appears in which you can enter the file name.
SAP AG 415
ABAP Workbench Delta Guide (3.1-4.6)
Once you have entered a filename, the program starts Microsoft Word in a separate window
and loads the file that you specified.
,QWHUIDFHIXQFWLRQ',63/$<'LVSOD\VDGRFXPHQW
A dialog box appears in which you can enter the filename. The program then starts Microsoft
Word in a separate window and loads the file that you specified in read-only mode.
,QWHUIDFHIXQFWLRQ6$9(6DYHVDGRFXPHQW
A dialog box appears in which you can enter the path under which you want to save the
document.
SAP AG 416
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUIDFHIXQFWLRQ&/26(&ORVHVDGRFXPHQW
If the user changed the document, a 6DYH dialog box appears.
If you then want to save, the same dialog box appears for the path as illustrated earlier in this
section.
SAP AG 417
ABAP Workbench Delta Guide (3.1-4.6)
,QWHUIDFHIXQFWLRQ67236WRSVWKH$%$3SURJUDP
The PAI module H[LW is processed. If you changed the document, the 6DYH dialog illustrated
above is processed.
$%$3PRGXOHV
,QFOXGHSURJUDPGUOBRLBR
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
ENDMODULE.
,QFOXGHSURJUDPGUOBRLBL
MODULE USER_COMMAND_0100 INPUT.
CHECK NOT okcode IS INITIAL.
IF office IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = ’CONTAINER’.
SAP AG 418
ABAP Workbench Delta Guide (3.1-4.6)
IF document IS INITIAL.
CALL METHOD office->get_document_proxy
EXPORTING
document_type = document_type
no_flush = ’’
IMPORTING
document_proxy = document
error = error
retcode = retcode.
ENDIF.
CASE okcode.
WHEN ’INSERT’.
PERFORM open_check_and_save_dialog.
CALL METHOD document->create_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
is_open = ’X’.
WHEN ’CHANGE’.
PERFORM open_check_and_save_dialog.
CALL SCREEN 101 STARTING AT 5 5
ENDING AT 75 8.
IF okcode = ’YES’.
item_url = ’FILE://’.
CONCATENATE item_url path INTO item_url.
CALL METHOD document->open_document
SAP AG 419
ABAP Workbench Delta Guide (3.1-4.6)
EXPORTING
document_url = item_url
open_inplace = space
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
is_open = ’X’.
ENDIF.
WHEN ’DISPLAY’.
PERFORM open_check_and_save_dialog.
CALL SCREEN 101 STARTING AT 5 5
ENDING AT 75 8.
IF okcode = ’YES’.
CONCATENATE item_url path INTO item_url.
CALL METHOD document->open_document
EXPORTING
document_url = item_url
open_inplace = space
open_readonly = ’X’
protect_document = ’X’
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
is_open = ’X’.
ENDIF.
WHEN ’SAVE’.
title_flag = ’X’.
CALL SCREEN 101 STARTING AT 5 5
ENDING AT 75 8.
title_flag = space.
IF okcode = ’YES’.
CONCATENATE item_url path INTO item_url.
CALL METHOD document->save_document_to_url
EXPORTING
url = item_url
no_flush = ’’
SAP AG 420
ABAP Workbench Delta Guide (3.1-4.6)
IMPORTING
error = error
retcode = retcode.
ENDIF.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
WHEN ’CLOSE’.
PERFORM open_check_and_save_dialog.
ENDCASE.
ENDMODULE.
SAP AG 421
ABAP Workbench Delta Guide (3.1-4.6)
6XEURXWLQHV,1&/8'(GUOBRLBI
***INCLUDE D45RL_OI_2F01 .
FORM open_check_and_save_dialog.
CHECK NOT is_open IS INITIAL.
CALL METHOD document->close_document
EXPORTING
do_save = ’X’
no_flush = ’’
IMPORTING
has_changed = has_changed
error = error
retcode = retcode.
SAP AG 422
ABAP Workbench Delta Guide (3.1-4.6)
retcode = retcode.
ENDIF.
ENDIF.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
is_open = ’ ’.
ENDFORM.
'DWD7UDQVIHU%HWZHHQ5DQG'HVNWRS
$SSOLFDWLRQ
2YHUYLHZ
There are several techniques that you can use within SAP Desktop Office Integration to
exchange data between the R/3 System and a desktop application (quite apart from the
upload/download functions and the ABAP OLE interface).
See also
/LQNVHUYHU
The link server manages the objects of the R/3 System (internal tables, fields, documents,
graphics,...) that are integrated in the office application when the program is executed. The
link server also provides methods for managing and creating links to the office application. In
Release 4.0, it is only possible to transfer data from R/3 to the desktop side. In Release 4.5
you can also use the link server to transfer data from the desktop back to R/3.
7DEOHBFROOHFWLRQ
R/3 data in tabular form is made available using the SAP TableFactory OCX. This is part of
the SAP Automation Suite, and is used for RFC programming in Visual Basic. This function
allows you to reimport data into the R/3 System after you have edited it using the desktop
application.
6SUHDGVKHHW,QWHUIDFH
You can exchange data bidirectionally between an ABAP program and a named range in a
spreadsheet. Since the functions are available directly from ABAP, you do not have to
program your own macros.
SAP AG 423
ABAP Workbench Delta Guide (3.1-4.6)
0DLO0HUJH
This interface allows you to use data from R/3 in the mailmerge functions of a word processor
program. Again, no macro programming is necessary.
)RUP)LHOGV
This interface allows you to exchange data between R/3 and forms in an office application.
You can place R/3 data in the fields of a form, and return data from the form into your ABAP
program. Once more, there is no macro programming.
6$32IILFH,QWHJUDWLRQ,QWHUIDFH+LHDUFK\
LBRLBVFULSWBFROOHFWLRQ LBRLBVSUHDGVKHHW
…….. ……..
SAP AG 1999
$SSOLFDWLRQ6SHFLILF,QWHUIDFHV
As well as the Link Server and Table Collection, which are generic interfaces for exchanging
data between an ABAP program and a desktop application, there is also a range of more
specific interfaces, which provide functions for a particular application (such as a spreadsheet
or word processor) or an area of an application (such as forms or mailmerge).
The interface LBRLBGRFXPHQWBSUR[\ contains methods that return references to these
interfaces. Once you have such a reference, you can use it to control application-specific
functions from your ABAP program. You still use the document proxy instance for generic
functions such as opening, closing, and saving the document.
$SSOLFDWLRQ6SHFLILF,QWHUIDFHV$YDLODEOHLQ5HOHDVH$%
,QWHUIDFH 0HWKRGRILBRLBGRFXPHQWBSUR[\
XVHGWRJHWDUHIHUHQFH 'RFXPHQWDWLRQ
SAP AG 424
ABAP Workbench Delta Guide (3.1-4.6)
Open document
8VHDSSOLFDWLRQVSHFLILFLQVWDQFHIRUVSHFLILFWDVNV
8VHGRFXPHQWSUR[\LQVWDQFHIRUJHQHUDOWDVNV
SAP AG 1999
The instance of the application-specific interface always applies to the same document
as the instance of LBRLBGRFXPHQWBSUR[\that you used to create it.
7KH6SUHDGVKHHW,QWHUIDFH
The spreadsheet interface allows you to exchange data directly between your ABAP program
and a spreadsheet package such as Microsoft Excel or Lotus 1-2-3. You control the data
exchange from ABAP using the methods of the interface. Consequently, the need for macro
programming in the spreadsheet program is reduced.
To use the spreadsheet interface, you need a reference to it, which you get using the
JHWBVSUHDGVKHHWBLQWHUIDFHmethod of the central instance.
Before attempting to get the interface reference, you can check whether the application open
in the Office Integration instance supports it. To do this, you use the
KDVBVSUHDGVKHHWBLQWHUIDFH method of the central instance.
SAP AG 425
ABAP Workbench Delta Guide (3.1-4.6)
LVBDYDLODEOH
Reference with type
LBRLBVSUHDGVKHHW
Method Method
KDVBVSUHDGVKHHWBLQWHUIDFH JHWBVSUHDGVKHHWBLQWHUIDFH
Spreadsheet
interface
instance
SAP AG 1999
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
'$7$VSUHDGVKHHW7<3(5()72LBRLBVSUHDGVKHHW
&$//0(7+2'GRFXPHQW!KDVBVSUHDGVKHHWBLQWHUIDFH
(;3257,1*
QRBIOXVK
;
,03257,1*
LVBDYDLODEOH KDV
HUURU HUURUV
&$//0(7+2'GRFXPHQW!JHWBVSUHDGVKHHWBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
VKHHWBLQWHUIDFH VSUHDGVKHHW
HUURU HUURUV
SAP AG 1999
SAP AG 426
ABAP Workbench Delta Guide (3.1-4.6)
Once you have the spreadsheet interface reference, you can use the methods of the
interface. These allow you to control a large range of spreadsheet tasks from within an ABAP
program. The syntax of these method calls is always:
CALL METHOD spreadsheet-><method_name>
[EXPORTING] ...
[IMPORTING] ...
[CHANGING] ...
For further information, refer to the SAP Library documentation:
6DPSOH8VLQJWKH6SUHDGVKHHW,QWHUIDFH
*HQHUDO'HVFULSWLRQRI3URJUDP
To start this program, use transaction code GUOBRLB.It demonstrates how you can
exchange data between an ABAP program and an Excel worksheet (in both directions).
The program consists of a single screen (100), in which Excel is started in-place. There are
three functions:
)XQFWLRQ 7\SH 'HVFULSWLRQ
Show R/3 Data in Excel Pushbutton Transfers the contents of database table SFLIGHT into
the Excel worksheet on screen 100
Get Data Back Pushbutton Reads the contents of cell A1 in the worksheet and
places them in the screen field next to the pushbutton
Exit Icon Exits the program
3URJUDP6WUXFWXUHDQG)ORZ
The program consists of a main program and three include programs. The main program is
called VDSGUOBRLB.
In the PBO event of screen 100, the system creates the Office Integration instances and
creates an Excel workbook. (There is a flag in the program called DOUHDG\BGRQH, which is
used to ensure that this only happens once.)
The PAI event contains all of the other processing logic required to transfer data in both
directions between the ABAP program and the Excel sheet.
0DLQ3URJUDPVDSGUOBRLB
*& Module pool SAPD45RL_OI_7
INCLUDE D45RL_OI_7TOP.
INCLUDE D45RL_OI_7I01.
INCLUDE D45RL_OI_7O01.
When you run the program, the system processes screen 100.
'DWD'HILQLWLRQVGUOBRLBWRS
*& Include d45rl_oi_7top
SAP AG 427
ABAP Workbench Delta Guide (3.1-4.6)
TYPE-POOLS: soi.
* Gui-Container
DATA: container TYPE REF TO cl_gui_custom_container.
TABLES: sflight.
DATA already_done.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Excel.Sheet.8’.
DATA celldata(100) VALUE ’ <--
push button to get content of cell A1!’.
DATA okcode(15).
3%2(YHQWRI6FUHHQ
)ORZ/RJLF
PROCESS BEFORE OUTPUT.
SAP AG 428
ABAP Workbench Delta Guide (3.1-4.6)
MODULE STATUS_0100.
MODULE SET_VALUES.
0RGXOH67$786B
MODULE status_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
SAP AG 429
ABAP Workbench Delta Guide (3.1-4.6)
APPEND errors.
already_done = ’X’.
SAP AG 430
ABAP Workbench Delta Guide (3.1-4.6)
When you choose either of the pushbuttons (or the ([LW function), the PAI of screen 100 is
triggered.
3$,(YHQWRI6FUHHQ
When you choose ([LW, the function code STOP is triggered. This is processed in the EXIT
module, where it destroys the Office Integration instances and exits the program.
When you choose 6KRZ5'DWDLQ([FHO, the function code SHOW is triggered. This reads
the contents of SFLIGHT into an internal table (WHPSVIOLJKW), creates a range in Excel with the
appropriate dimensions (insert_ranges_dim method), then transfers the contents of
WHPSVIOLJKW into that range (insert_one_table method):
SAP AG 431
ABAP Workbench Delta Guide (3.1-4.6)
When you choose *HW'DWD%DFN, the function code GET is triggered. This creates a 1x1
range starting in row 1 column 1 (cell A1), then uses the get_ranges_data method to return
the contents of that range. The contents are placed in the ABAP program field FHOOGDWD and
are displayed on the screen:
)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE DATA_TRANSFER.
0RGXOH(;,7
MODULE exit INPUT.
CASE okcode.
WHEN ’STOP’.
IF NOT document IS INITIAL.
SAP AG 432
ABAP Workbench Delta Guide (3.1-4.6)
SET SCREEN 0.
ENDCASE.
0RGXOH'$7$B75$16)(5
MODULE data_transfer INPUT.
CHECK okcode NE ’STOP’.
CASE okcode.
WHEN ’GET’.
CALL METHOD spreadsheet->insert_range_dim
EXPORTING name = ’Cell’
top = 1
left = 1
rows = 1
columns = 1.
CLEAR ranges.
CLEAR contents.
SAP AG 433
ABAP Workbench Delta Guide (3.1-4.6)
rangeitem-name = ’Cell’.
APPEND rangeitem TO ranges.
CALL METHOD spreadsheet->get_ranges_data
IMPORTING contents = contents
CHANGING ranges = ranges.
WHEN ’SHOW’.
SELECT * FROM sflight INTO TABLE tempsflight.
7KH:RUG3URFHVVRU,QWHUIDFH
The Word Processor Interface allows you to use the application-specific functions of a word
processor application. To use it, you need a reference to it, which you get using the
JHWBZRUGSURFHVVRUBLQWHUIDFH method of the central instance.
Before attempting to get the interface reference, you can check whether the application open
in the Office Integration instance supports it. To do this, you use the
KDVBZRUGSURFHVVRUBLQWHUIDFHmethod of the central instance.
SAP AG 434
ABAP Workbench Delta Guide (3.1-4.6)
LVBDYDLODEOH
Reference with type
LBRLBZRUGBSURFHVVRUBGRFXPHQW
Method Method
KDVBZRUGSURFHVVRUBLQWHUIDFH JHWBZRUGSURFHVVRUBLQWHUIDFH
Word processor
interface
instance
SAP AG 1999
352*5$0
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
'$7$ZSLQVWDQFH7<3(5()72LBRLBZRUGBSURFHVVRUBGRFXPHQW
'$7$KDV7<3(L
&$//0(7+2'GRFXPHQW!KDVBZRUGSURFHVVRUBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
LVBDYDLODEOH KDV
HUURU HUURUV
,)KDV
&$//0(7+2'GRFXPHQW!JHWBZRUGSURFHVVRUBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
ZSBLQWHUIDFH ZSLQVWDQFH
HUURU HUURUV
(1',)
SAP AG 1999
This then allows you to call the methods of the Word Processor Interface using the form:
SAP AG 435
ABAP Workbench Delta Guide (3.1-4.6)
7KH0DLOPHUJH,QWHUIDFH
The mailmerge interface allows you to exchange data directly between your ABAP program
and the mailmerge functions within a word processing package. You control the data
exchange from ABAP using the methods of the interface, reducing the need for macro
programming in the word processor.
To use the mailmerge interface, you need a reference to it, which you get using the
JHWBPDLOBPHUJHBLQWHUIDFHmethod of the central instance.
Before attempting to get the interface reference, you can check whether the application open
in the Office Integration instance supports it. To do this, you use the
KDVBPDLOBPHUJHBLQWHUIDFH method of the central instance.
SAP AG 436
ABAP Workbench Delta Guide (3.1-4.6)
LVBDYDLODEOH
Reference with type
LBRLBPDLOBPHUJH
Method Method
KDVBPDLOBPHUJHBLQWHUIDFH JHWBPDLOBPHUJHBLQWHUIDFH
Mailmerge
interface
instance
SAP AG 1999
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
'$7$PDLOPHUJH7<3(5()72LBRLBPDLOBPHUJH
'$7$KDV7<3(L
&$//0(7+2'GRFXPHQW!KDVBPDLOBPHUJHBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
LVBDYDLODEOH KDV
HUURU HUURUV
,)KDV
&$//0(7+2'GRFXPHQW!JHWBPDLOBPHUJHBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
PPBLQWHUIDFH PDLOPHUJH
HUURU HUURUV
(1',)
SAP AG 1999
SAP AG 437
ABAP Workbench Delta Guide (3.1-4.6)
Once you have the mailmerge interface reference, you can use the methods of the interface.
These allow you to control the mailmerge tasks from within your ABAP program. The syntax
of these method calls is always:
CALL METHOD mailmerge-><method_name>
[EXPORTING] ...
[IMPORTING] ...
[CHANGING] ...
For further information, refer to the SAP Library documentation:
6DPSOH8VLQJWKH0DLOPHUJH,QWHUIDFH
In order to use the sample program, you must copy the file mailmerge.doc from the
templates directory of the installation CD to the directory C:\D46AW on your PC.
*HQHUDO'HVFULSWLRQRI3URJUDP
To start this program, use the transaction code GUOBRLB. It program demonstrates how you
can exchange data between an ABAP program and a mailmerge template in a word
processor package.
The program consists of a single screen (100) in which Word is started in-place. There are
three functions:
)XQFWLRQ 7\SH 'HVFULSWLRQ
Open document Pushbutton Opens a Word document containing a mailmerge
template
View Pushbutton Inserts values from a single line of the internal table
tempsflight into the corresponding fields of the Word
document.
Exit Icon Exits the program
3URJUDP6WUXFWXUHDQG)ORZ
The program consists of a main program and three include programs. The main program is
called VDSGUOBRLB. To run it, use transaction code GUOBRLB.
In the PBO event of screen 100, the system creates the Office Integration instances , but
does not open any documents. (There is a flag in the program called DOUHDG\BGRQH, which is
used to ensure that this only happens once.)
The PAI event contains all of the other processing logic required to open a document, start
the mailmerge interface instance, and transfer data from the ABAP program to the fields in
the Word document.
0DLQ3URJUDPVDSGUOBRLB
*& Module pool SAPD45RL_OI_9
INCLUDE D45RL_OI_9TOP.
INCLUDE D45RL_OI_9I01.
INCLUDE D45RL_OI_9O01.
SAP AG 438
ABAP Workbench Delta Guide (3.1-4.6)
When you run the program, the system processes screen 100.
'DWD'HILQLWLRQVGUOBRLBWRS
*& Include d45rl_oi_9top
*&
*
*&-------------------------------------------------------------------
--*
* Gui-Container
DATA: container TYPE REF TO cl_gui_custom_container.
SAP AG 439
ABAP Workbench Delta Guide (3.1-4.6)
3%2(YHQWRI6FUHHQ
)ORZ/RJLF
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE SET_VALUES.
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE DATA_TRANSFER.
0RGXOH67$786B
MODULE status_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
SAP AG 440
ABAP Workbench Delta Guide (3.1-4.6)
document_type = document_type
no_flush = ’’
IMPORTING
document_proxy = document
error = errors
retcode = retcode.
APPEND errors.
already_done = ’X’.
0RGXOH6(7B9$/8(6
MODULE set_values OUTPUT.
doc_url = ’FILE://’. "#EC NOTEXT
path = ’C:/users/my documents/internal/mailmerge.doc’."#EC NOTE
XT
SAP AG 441
ABAP Workbench Delta Guide (3.1-4.6)
When you choose either of the pushbuttons (or the ([LW function), the PAI of screen 100 is
triggered.
3$,(YHQWRI6FUHHQ
When you choose ([LW, the function code STOP is triggered. This is processed in the EXIT
module, where it destroys the Office Integration instances and exits the program.
When you choose Open Document, the function code OPEN is triggered. This is processed in
the DATA_TRANSFER module. It does the following:
1. Opens the Word document in-place
2. Checks whether Word can support the mailmerge interface (has_mail_merge_interface
method)
3. Starts an instance of the mailmerge interface (get_mail_merge_interface method)
4. Fills the internal table WHPSVIOLJKW with the contents of the database table VIOLJKW
5. Sets table WHPSVIOLJKW as the source table for the mailmerge data (set_data_source
method)
The screen then looks like this:
SAP AG 442
ABAP Workbench Delta Guide (3.1-4.6)
<RXFDQVHQGWKHGDWDRIPRUHWKDQRQHUHFRUGLQDVLQJOHPHWKRGFDOOLI\RXXVH
WKHmerge_range PHWKRG
The screen then looks like this:
SAP AG 443
ABAP Workbench Delta Guide (3.1-4.6)
)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE DATA_TRANSFER.
0RGXOH(;,7
MODULE exit INPUT.
CASE okcode.
WHEN ’STOP’.
IF NOT mailmerge IS INITIAL.
CALL METHOD mailmerge->shutdown
EXPORTING
no_flush = ’’
IMPORTING
retcode = retcode
error = error.
FREE mailmerge.
ENDIF.
IF NOT document IS INITIAL.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
SAP AG 444
ABAP Workbench Delta Guide (3.1-4.6)
IMPORTING
retcode = retcode
error = error.
FREE document.
ENDIF.
IF NOT office IS INITIAL.
CALL METHOD office->destroy_control
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
FREE office.
ENDIF.
IF NOT container IS INITIAL.
CALL METHOD container->free.
FREE container.
ENDIF.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " EXIT INPUT
0RGXOH'$7$B75$16)(5
MODULE data_transfer INPUT.
CHECK okcode NE ’STOP’.
CONCATENATE doc_url path INTO doc_url.
CASE okcode.
WHEN ’OPEN’.
IF is_open IS INITIAL.
CALL METHOD document->open_document
EXPORTING
document_url = doc_url
open_inplace = ’X’
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
CALL METHOD error->raise_message EXPORTING type = ’E’.
SAP AG 445
ABAP Workbench Delta Guide (3.1-4.6)
is_open = ’X’.
* check if our document proxy can serve a mailmerge interface:
DATA: has TYPE i.
CALL METHOD document->has_mail_merge_interface
EXPORTING no_flush = ’’
IMPORTING is_available = has
error = error.
CALL METHOD error->raise_message EXPORTING type = ’E’.
IF has = 1.
CALL METHOD document->get_mail_merge_interface
EXPORTING no_flush = ’ ’
IMPORTING
mm_interface = mailmerge
error = error.
CALL METHOD error->raise_message EXPORTING type = ’E’.
ENDIF.
WHEN ’MERGE’.
IF is_open = ’X’.
IF item > rows_number.
item = rows_number.
ENDIF.
CALL METHOD mailmerge->merge_one
EXPORTING
index = item.
SAP AG 446
ABAP Workbench Delta Guide (3.1-4.6)
ENDCASE.
7KH)RUP,QWHUIDFH
The form interface allows you to exchange data directly between your ABAP program and the
fields of a form within the desktop application. You control the data exchange from ABAP
using the methods of the interface, reducing the need for macro programming in the
application itself.
To use the form interface, you need a reference to it, which you get using the
JHWBIRUPBLQWHUIDFHmethod of the central instance.
Before attempting to get the interface reference, you can check whether the application open
in the Office Integration instance supports it. To do this, you use the KDVBIRUPBLQWHUIDFH
method of the central instance
LVBDYDLODEOH
Reference with type
LBRLBIRUP
Method Method
KDVBIRUPBLQWHUIDFH JHWBIRUPBLQWHUIDFH
Form
interface
instance
SAP AG 1999
SAP AG 447
ABAP Workbench Delta Guide (3.1-4.6)
352*5$0VDSGUOBRLB
'$7$GRFXPHQW7<3(5()72LBRLBGRFXPHQWBSUR[\
'$7$IRUPILHOG7<3(5()72LBRLBIRUP
'$7$KDV7<3(L
&$//0(7+2'GRFXPHQW!KDVBIRUPBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
LVBDYDLODEOH KDV
HUURU HUURUV
,)KDV
&$//0(7+2'GRFXPHQW!JHWBIRUPBLQWHUIDFH
(;3257,1*
QRBIOXVK
,03257,1*
IBLQWHUIDFH IRUPILHOG
HUURU HUURUV
(1',)
SAP AG 1999
Once you have the form interface reference, you can use the methods of the interface. These
allow you to control form fields from within your ABAP program. The syntax of these method
calls is always:
CALL METHOD formfield-><method_name>
[EXPORTING] ...
[IMPORTING] ...
[CHANGING] ...
For further information, refer to the SAP Library documentation:
6DPSOH8VLQJWKH)RUP,QWHUIDFH
In order to use the sample program, you must copy the file formfields.doc from the
templates directory of the installation CD to the directory C:\D46AW on your PC.
*HQHUDO'HVFULSWLRQRI3URJUDP
The program runs with transaction code GUOBRLB. It demonstrates how you can exchange
data (in both directions) between an ABAP program and a form in a Word document.
The program consists of a single screen, in which Word is started in-place. There are four
functions.
)XQFWLRQ 7\SH 'HVFULSWLRQ
Open document Pushbutton Starts Word in-place and opens the document
SAP AG 448
ABAP Workbench Delta Guide (3.1-4.6)
formfields.doc
Get data Pushbutton Retrieves the value from the form field in the document
and displays it in the field in the top right-hand corner of
the screen
Set data Pushbutton Places the value of the field in the top right-hand corner
of the screen in the form field in the document
Exit Icon Exits the program
3URJUDP6WUXFWXUHDQG)ORZ
The program consists of a main program and three include programs. The main program is
called VDSGUOBRLB.
In the PBO event of screen 100, the system creates the Office Integration instances . (There
is a flag in the program called DOUHDG\BGRQH, which is used to ensure that this only happens
once.)
The PAI event contains all of the other processing logic required to open the document
containing the form, exchange data between the ABAP program and the document, and to
end the program.
0DLQ3URJUDPVDSGUOBRLB
*& Module pool SAPD45RL_OI_10
INCLUDE d45rl_oi_10top.
INCLUDE d45rl_oi_10i01.
INCLUDE d45rl_oi_10o01.
When you run the program, the system processes screen 100.
'DWD'HILQLWLRQVGUOBRLBWRS
*& Include d45rl_oi_10top
SAP AG 449
ABAP Workbench Delta Guide (3.1-4.6)
* Gui-Container
DATA: container TYPE REF TO cl_gui_custom_container.
3%2(YHQWRI6FUHHQ
)ORZ/RJLF
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE SET_VALUES.
0RGXOH67$786B
MODULE status_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
SAP AG 450
ABAP Workbench Delta Guide (3.1-4.6)
register_on_custom_event = ’X’
inplace_enabled = ’X’
inplace_scroll_documents = ’X’
parent = container
no_flush = ’X’
IMPORTING
error = errors
retcode = retcode.
APPEND errors.
already_done = ’X’.
0RGXOH6(7B9$/8(6
MODULE set_values OUTPUT.
doc_url = ’FILE://’. "#EC NOTEXT
path = ’C:/users/my documents/internal/formfields.doc’."#EC NOT
EXT
SAP AG 451
ABAP Workbench Delta Guide (3.1-4.6)
When you choose any of the pushbuttons (or the ([LW function), the PAI of screen 100 is
triggered.
3$,(YHQWRI6FUHHQ
When you choose 2SHQGRFXPHQW, the function code 2SHQ is triggered. The program checks
whether the document type (in this case, Word.Document.8) can support the form interface,
and opens a Word document containing a form as shown below. The field in the form is
protected, which means that you cannot change it directly. However, the form interface
contains methods that allow an ABAP program to remove the protection and change the
value (methods of the form interface ).
SAP AG 452
ABAP Workbench Delta Guide (3.1-4.6)
If you enter a text in the input field in the top right-hand corner of the screen and choose 6HW
GDWD, the function code SET is triggered. The function performs the following tasks:
1. Unprotects the form field.
2. Fills a line of an internal table WDEOH with the name and type of the field in the form, and
the value to be placed in it (the value from the R/3 screen field).
3. Calls the method set_data to pass the data to the Word document.
4. Protects the form field again (protect method).
SAP AG 453
ABAP Workbench Delta Guide (3.1-4.6)
If you choose *HWGDWD, the function code GET is triggered. This is essentially the reverse of
SET: The program lifts the protection from the form field, retrieves the data from the form in
Word (get_data method), and places it in the R/3 Screen field. Finally, it reapplies the
protection to the form field.
When you choose ([LW, the function code STOP is triggered. This is processed in the EXIT
module, where it destroys the Office Integration instances and exits the program.
)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE DATA_TRANSFER.
0RGXOH(;,7
MODULE exit INPUT.
CASE okcode.
WHEN ’STOP’.
IF NOT formfield IS INITIAL.
FREE formfield.
ENDIF.
IF NOT document IS INITIAL.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
retcode = retcode
SAP AG 454
ABAP Workbench Delta Guide (3.1-4.6)
error = error.
FREE document.
ENDIF.
IF NOT office IS INITIAL.
CALL METHOD office->destroy_control
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
FREE office.
ENDIF.
IF NOT container IS INITIAL.
CALL METHOD container->free.
FREE container.
ENDIF.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " EXIT INPUT
0RGXOH'$7$B75$16)(5
MODULE data_transfer INPUT.
CHECK okcode NE ’STOP’.
CONCATENATE doc_url path INTO doc_url.
CASE okcode.
WHEN ’OPEN’.
IF is_open IS INITIAL.
CALL METHOD document->open_document
EXPORTING
document_url = doc_url
open_inplace = ’X’
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
CALL METHOD error->raise_message EXPORTING type = ’E’.
is_open = ’X’.
* check if our document proxy can serve a mailmerge interface:
SAP AG 455
ABAP Workbench Delta Guide (3.1-4.6)
IF has = 1.
CALL METHOD document->get_form_interface
EXPORTING no_flush = ’ ’
IMPORTING
f_interface = formfield
error = error.
CALL METHOD error->raise_message EXPORTING type = ’E’.
CALL METHOD formfield->protect EXPORTING protect = ’X’.
ENDIF.
ENDIF.
WHEN ’GET’.
IF is_open = ’X’.
CALL METHOD formfield->protect EXPORTING protect = ’ ’.
CALL METHOD formfield->get_data
EXPORTING all = ’X’
IMPORTING fields = table.
SAP AG 456
ABAP Workbench Delta Guide (3.1-4.6)
7DEOHB&ROOHFWLRQ
To create an instance for managing internal tables used to pass data between the R/3
System and the office application, use the JHWBWDEOHBFROOHFWLRQ method of the central
instance.
You must define the relevant instance with reference to the interface LBRLBWDEOHBFROOHFWLRQ.
,QVWDQFH
ZLWKW\SH
LBRLBFRQWDLQHUBFRQWURO
,QVWDQFH
ZLWKW\SH
LBRLBWDEOHBFROOHFWLRQ
&HQWUDOREMHFW
IRU
2IILFH 7DEOHB&ROOHFWLRQ
,QWHJUDWLRQ
DGPLQLVWUDWLRQ 0HWKRG
*(7B7$%/(B&2//(&7,21
SAP AG
See also
SAP AG 457
ABAP Workbench Delta Guide (3.1-4.6)
,QVWDQFHIRU7DEOHB&ROOHFWLRQ
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$RIILFH7<3(5()72 LBRLBFRQWDLQHUBFRQWURO
'$7$WDEOHBFROOHFWLRQ7<3(5()72LBRLBWDEOHBFROOHFWLRQ
&$//0(7+2'RIILFH!JHWBWDEOHBFROOHFWLRQ
(;3257,1*
12B)/86+
,03257,1*
7$%/(B&2//(&7,21 WDEOHBFROOHFWLRQ
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
The table_collection provides methods for administering internal tables and for transferring
them between application server and frontend.
7KH*HQHULF,QWHUIDFHIRU,QWHUQDO7DEOHV
5HPRWH/HDUQLQJ
LBRLBWDEOHBFROOHFWLRQ
0HWKRGV
add_table
add_table_by_url
get_table
get_table_by_url
remove_table
remove_all_tables
SAP AG
SAP AG 458
ABAP Workbench Delta Guide (3.1-4.6)
'LPWDEOHDVREMHFW
'LPURZDVREMHFW
VHWWDEOH 7KLV'RFXPHQW&RQWDLQHU7DEOHV&XVWRPHUV7DEOH
Container
IRUHDFKURZLQWDEOHURZV
SULQWURZYDOXH1DPH
QH[W
Tables
Name
Type
Table
Data
LinkServer
SAP AG
The add_table method allows you to add an internal table to the table collection. In the
table_name parameter, enter the name under which you want the table to be known in the
table collection. You pass the table data in the data_table parameter. The table_type
parameter specifies the direction in which the data is to be passed ( 1 = R/3 to frontend, 2 =
frontend to R/3).
The execute_macro method allows you to start a document macro. This reads the internal
table using the SAP Tables OCX made available by the container object.
5HDGLQJDQ,QWHUQDO7DEOH8VLQJD0DFUR
SAP AG 459
ABAP Workbench Delta Guide (3.1-4.6)
&$//0(7+2'WDEOHBFROOHFWLRQ!DGGBWDEOH
(;3257,1*
7$%/(B1$0(
,7$%;
,03257,1* 'LP5RZ$V2EMHFW
(5525 HUURU
6HW57DEOH 7KLV:RUNERRN&RQWDLQHU7DEOHV,7$%;7DEOH
57DEOH5RZV5HPRYH$OO
&+$1*,1* 6HW5RZ
)RUM
57DEOH5RZV$GG
7R57DEOH&ROXPQVFRXQW
1H[WM
&$//0(7+2'GRFXPHQW!H[HFXWHBPDFUR
1H[WL
(QG6XE
0DFUR
(;3257,1*
0$&52B675,1*
7$%/(%$&.725µ
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
&$//0(7+2'WDEOHBFROOHFWLRQ!JHWBWDEOH
(;3257,1*
7$%/(B1$0(
,7$%;µ
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
&+$1*,1*
'$7$B7$%/( LWDE[>@
SAP AG
You may not use the same internal table in your ABAP program to transfer data in both
directions.
SAP AG 460
ABAP Workbench Delta Guide (3.1-4.6)
*HQHUDO'HVFULSWLRQRI3URJUDP
This program demonstrates how you can transfer an internal table from an ABAP program to
an Excel worksheet and then return it to the ABAP program using the WDEOHBFROOHFWLRQ.
The program is a module pool (type M) with two screens - 100 and 101. Screen 101 display
the list. The interface of screen 100 contains four functions:
- Change document ( function code &+$1*( )
- Transfer an internal table to an Excel Worksheet using Table_collection ( function code
),//B(;&(/)
- Returning the data from the Excel worksheet to the ABAP program (function code
'$7$B%$&.)
- Exit ( function code 6723typeH[LWFRPPDQG )
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLB
*& Module pool SAPD45RL_OI_8
INCLUDE D45RL_OI_8TOP.
INCLUDE D45RL_OI_8I01.
INCLUDE D45RL_OI_8O01.
INCLUDE D45RL_OI_8F01.
When you run the program, screen 100 is processed.
'DWD'HILQLWLRQV,QFOXGHSURJUDPGUOBRLBWRS
*& Include d45rl_oi_8top
PROGRAM sapd45rl_oi_8 MESSAGE-ID bctrain.
TYPE-POOLS: soi.
CLASS c_oi_errors DEFINITION LOAD.
SAP AG 461
ABAP Workbench Delta Guide (3.1-4.6)
3%2(YHQWRIVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the user interface
MODULE set_values.
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGQRW\HWVWDUWHG
3$,(YHQWRIVFUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE CREATE_BASIC_OBJECTS.
MODULE USER_COMMAND_0100.
3$,SURFHVVLQJRIVFUHHQ
,QWHUIDFHIXQFWLRQ&+$1*(&KDQJHVDGRFXPHQW
• This function calls the ABAP module FUHDWHBEDVLFBREMHFWV This module creates a
table_collection instance.
• The ABAP module XVHUBFRPPDQGB is then executed. This starts Microsoft Excel
in a separate window and opens a document
SAP AG 462
ABAP Workbench Delta Guide (3.1-4.6)
06([FHOKDVEHHQVWDUWHGDQGDGRFXPHQWKDVEHHQRSHQHGXVLQJWKHLQWHUIDFH
IXQFWLRQ&KDQJHGRFXPHQW
You can find the Excel document in the directory ([B'RFVB2IILFHB,QWHJ ( filename
GHPR[OV
,QWHUIDFHIXQFWLRQ),//B(;&(/'DWDWUDQVIHUWR([FHOVKHHW
In the first step, the internal table is added to the table_collection. DGGBWDEOH method.
Then, a document macro is started, which transfers the table data into the Excel worksheet
(H[HFXWHBPDFUR method).
9LVXDO%DVLF0DFUR6XE56WDUWXS0DFURWKHPDFURLVVWRUHGLQWKH([FHOGRFXPHQW
PRGXOH6$30DFURV
Public Sub R3StartupMacro(i As Integer)
Dim R3Table As Object
Dim r As range
Dim cont As Object
count = i
Set cont = ThisWorkbook.Container
on_other_error:
SAP AG 463
ABAP Workbench Delta Guide (3.1-4.6)
End Sub
([FHOVKHHWDIWHUGDWDWUDQVIHU
,QWHUIDFHIXQFWLRQ'$7$B%$&.'DWDWUDQVIHUEDFNWR$%$3SURJUDP
You can now edit the data in Excel and subsequently return it to the ABAP program. To do
this, you need a second internal table in the ABAP program. This table (itabx), is added to the
table collection using the add_table method. Then, the data from the Excel worksheet is
transferred to the table collection using a macro and the ABAP method execute_macro. This
data is then uploaded into the ABAP program using the get_table method.
9LVXDO%DVLF0DFUR7DEOH%DFN7R5WKHPDFURLVVWRUHGLQWKH([FHOGRFXPHQW
PRGXOH6$30DFURV
Public Sub TableBackToR3()
Dim R3Table As Object
Dim row As Object
Dim r As range
R3Table.Rows.RemoveAll
For i = 1 To r.Rows.count
Set row = R3Table.Rows.Add
For j = 1 To r.Columns.count
row.Cell(j) = r.Cells(i, j).Value
Next j
Next i
End Sub
SAP AG 464
ABAP Workbench Delta Guide (3.1-4.6)
The table data received from Excel is then displayed on a list using screen 101.
/LVW2XWSXWIURP$%$33URJUDP
,QWHUIDFHIXQFWLRQ6723
$%$30RGXOHV
,QFOXGHSURJUDPGUOBRLBR
* INCLUDE D45RL_OI_8O01
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
ENDMODULE.
,QFOXGHSURJUDPGUOBRLBL
* INCLUDE D45RL_OI_8I01
MODULE USER_COMMAND_0100 INPUT.
IF already_filled IS INITIAL.
SAP AG 465
ABAP Workbench Delta Guide (3.1-4.6)
PERFORM fill_itab.
already_filled = ’X’.
ENDIF.
CASE okcode.
WHEN ’FILL_EXCEL’.
CALL METHOD table_collection->add_table
EXPORTING
table_name = ’itab’
* ddic_name = ’scarr’
table_type = 2 "table_type_output
no_flush = ’’
IMPORTING
retcode = retcode
error = error
CHANGING
data_table = itab[].
WHEN ’DATA_BACK’.
CALL METHOD table_collection->add_table
EXPORTING
table_name = ’itabx’
* ddic_name = ’scarr’
table_type = 1
no_flush = ’’
IMPORTING
retcode = retcode
error = error
CHANGING
data_table = itabx[].
SAP AG 466
ABAP Workbench Delta Guide (3.1-4.6)
WHEN ’CHANGE’.
file_url = ’FILE://’.
CONCATENATE file_url filename INTO file_url.
CALL METHOD document->open_document
EXPORTING
document_url = file_url
open_inplace = space
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
ENDCASE.
SAP AG 467
ABAP Workbench Delta Guide (3.1-4.6)
ENDMODULE.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE.
SAP AG 468
ABAP Workbench Delta Guide (3.1-4.6)
error = error
retcode = retcode.
SAP AG 469
ABAP Workbench Delta Guide (3.1-4.6)
ENDLOOP.
SET SCREEN 0.
ENDMODULE.
,QFOXGHSURJUDPGUOBRLBI
INCLUDE D45RL_OI_8f01
FORM fill_itab.
SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE itab.
DESCRIBE TABLE itab LINES count.
ENDFORM.
/LQN6HUYHU
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
The link server manages the objects from the R/3 System (fields, internal tables, documents,
screens) that you want to embed in the office application from an ABAP program.
,QVWDQFHIRUWKH/LQN6HUYHU
5HPRWH/HDUQLQJ
,QVWDQFH
ZLWKW\SH
LBRLBFRQWDLQHUBFRQWURO
,QVWDQFH
ZLWKW\SH
LBRLBOLQNBVHUYHU
&HQWUDOREMHFW
IRU
2IILFH /LQNVHUYHU
,QWHJUDWLRQ
DGPLQLVWUDWLRQ 0HWKRG
*(7B/,1.B6(59(5
SAP AG
See also
SAP AG 470
ABAP Workbench Delta Guide (3.1-4.6)
See also
Define an instance with reference to the interface LBRLBOLQNBVHUYHU.
Create the ABAP instance using the method JHWBOLQNBVHUYHU (method of the central
instance).
,QVWDQFHIRUWKH/LQN6HUYHU
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$RIILFH7<3(5()72LBRLBFRQWDLQHUBFRQWURO
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
&$//0(7+2'RIILFH!JHWBOLQNBVHUYHU
(;32357,1*
12B)/86+
,03257,1*
/,1.B6(59(5 OLQNVHUYHU
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
See also
The link server provides methods for creating and managing links.
SAP AG 471
ABAP Workbench Delta Guide (3.1-4.6)
7KH*HQHULF/LQN6HUYHU,QWHUIDFH
5HPRWH/HDUQLQJ
LBRLBOLQNBVHUYHU
0HWKRGV
start_link_server
stop_link_server
add_string_item
add_table_item
add_binary_item
remove_link_item
copy_link_item_to_clipboard
execute_copy_link_dialog
SAP AG
One of the ways in which you can insert R/3 data in a document is to use the OLQNVHUYHU.
When you design your document, insert the required links to the relevant R/3 objects at the
link server using the methods DGGBVWULQJBLWHP, DGGBWDEOHBLWHP, and DGGBELQDU\BLWHP.
You can then copy the appropriate links to the clipboard of the office application using the
method FRS\BOLQNBLWHPBWRBFOLSERDUG in your program (or interactively using the method
H[HFXWHBFRS\BOLQNBGLDORJ). From here, you can place the links in the appropriate places in
your document.
If the document contains links to R/3 objects, the corresponding data is inserted at runtime as
long as the items have been passed to the link server as described above.
You can refresh the contents of the link server by reinserting the relevant items at the server.
You can use document macros to access the contents of the link server and copy them into a
document (for example, to copy data from an ABAP table into a Word table or an Excel
range).
SAP AG 472
ABAP Workbench Delta Guide (3.1-4.6)
7KH/LQN6HUYHU,QWHUIDFH$UFKLWHFWXUHDQG+DQGOLQJ
5HPRWH/HDUQLQJ
FRS\BOLQNBLWHPBWRBFOLSERDUG SDVWHBFOLSERDUG
SDVWHBVSHFLDO
&OLSERDUG
'RFXPHQW
5 GHVLJQ /LQNV
DGGBVWULQJBLWHP
9DULDEOH
,QWWDEOH
DGGBWDEOHBLWHP
/LQNVHUYHU 'RFXPHQW
5GDWD
%LQREMHFW DGGBELQDU\BLWHP
5
0DFUR
H[HFXWHBPDFUR
SAP AG
SAP AG 473
ABAP Workbench Delta Guide (3.1-4.6)
&UHDWLQJDQG'HVWUR\LQJD/LQN6HUYHU,QVWDQFH
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
&$//0(7+2'OLQNVHUYHU!VWDUWBOLQNBVHUYHU
(;3257,1*
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
&$//0(7+2'OLQNVHUYHU!VWRSBOLQNBVHUYHU
(;3257,1*
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
'DWD7UDQVIHUIURP5WR'HVNWRS'RFXPHQW
8VLQJ/LQNV
Use the method DGGBVWULQJBLWHP to add a data field to the link server. The parameter
LWHPBQDPH defines the name by which the data field is known on the link server. The
parameter LWHPBYDOXH passes the value of the data field to the link server.
To delete a link server entry, use the method UHPRYHBOLQNBLWHP, using the LWHPBQDPH
parameter to specify the name by which the relevant data item is known on the link server.
SAP AG 474
ABAP Workbench Delta Guide (3.1-4.6)
'DWD5HIHUHQFHVRQWKH/LQN6HUYHU6WULQJV
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
&$//0(7+2'OLQNVHUYHU!DGGBVWULQJBLWHP
(;3257,1*
,7(0B1$0(
86(5
,7(0B9$/8( V\XQDPH
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
SAP AG 475
ABAP Workbench Delta Guide (3.1-4.6)
'DWD5HIHUHQFHVRQWKH/LQN6HUYHU,QWHUQDO7DEOHV
5HPRWH/HDUQLQJ
352*5$0VDSEFBRIILQWBG
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
&$//)81&7,21
'3B&5($7(B85/B)520B7$%/(
(;3257,1*
7$%1$0( 63$&(
7$%/(6
'$7$ LWDE
&+$1*,1*
85/ WDEOHBXUO
&$//0(7+2'OLQNVHUYHU!DGGBWDEOHBLWHP
(;3257,1*
,7(0B1$0(
$%$37$%/(
7$%/(B85/ WDEOHBXUO
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
SAP AG 476
ABAP Workbench Delta Guide (3.1-4.6)
'DWD5HIHUHQFHVRQWKH/LQN6HUYHU%LQDU\2EMHFWV
5HPRWH/HDUQLQJ
352*5$0VDSEFBRIILQWBG
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
/RDGELQDU\REMHFWIURP6$3GDWDEDVHLQWRDQLQWHUQDOWDEOH
&$//)81&7,21
'3B&5($7(B85/
(;3257,1*
7<3(
DSSOLFDWLRQ
68%7<3(
[UWI
6,=( GRFXPHQWBVL]H
7$%/(6
'$7$ GRFXPHQWBWDEOH
&+$1*,1*
85/ XUO
&$//0(7+2'OLQNVHUYHU!DGGBELQDU\BLWHP
(;3257,1*
,7(0B1$0(
SAP AG
You can also pass references to the clipboard interactively using the method
H[HFXWHBFRS\BOLQNBGLDORJ. This presents a dialog box with a list of all link server entries and
allows you to choose one.
SAP AG 477
ABAP Workbench Delta Guide (3.1-4.6)
3DVVLQJ5'DWDWRD'RFXPHQWYLDWKH&OLSERDUG
5HPRWH/HDUQLQJ
352*5$0VDSEFBRIILQWBG
'$7$OLQNVHUYHU7<3(5()72LBRLBOLQNBVHUYHU
...
&$//0(7+2'OLQNVHUYHU!FRS\BOLQNBLWHPBWRBFOLSERDUG
(;3257,1*
,7(0B1$0(
12B)/86+
,03257,1*
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
6DPSOH'DWD7UDQVIHUIURP5WR'HVNWRS
'RFXPHQW8VLQJ/LQNV
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
*HQHUDO'HVFULSWLRQRI3URJUDP
This program demonstrates how you can transfer data from an ABAP program into a desktop
document by using links.
The program is a module pool (type M) with a single screen (100). The interface of the screen
contains the following four functions:
- Create document ( function code ,16(57 )
- Pass a link to an ABAP program variable to the office clipboard using the link server (
function code /,1.B$'' )
- Refresh links in the office document from the ABAP program (function code 5()5(6+B/)
- Exit ( function code 6723typeH[LWFRPPDQG )
SAP AG 478
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLB
*& Module pool SAPD45RL_OI_3
INCLUDE D45RL_OI_3TOP.
INCLUDE D45RL_OI_3I01.
INCLUDE D45RL_OI_3O01.
When you run the program, screen 100 is processed.
'DWD'HILQLWLRQV,QFOXGHSURJUDPGUOBRLBWRS
*& Include d45rl_oi_3top
PROGRAM sapd45rl_oi_3 MESSAGE-ID bctrain.
TYPE-POOLS: soi.
CLASS c_oi_errors DEFINITION LOAD.
DATA already_done.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Word.Document.8’.
DATA inputfield(31).
DATA okcode(15).
3%2(YHQWRIVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the user interface
SAP AG 479
ABAP Workbench Delta Guide (3.1-4.6)
3$,(YHQWRIVFUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE CREATE_BASIC_OBJECTS.
MODULE USER_COMMAND_0100.
3$,SURFHVVLQJRIVFUHHQ
,QWHUIDFHIXQFWLRQ,16(57&UHDWHVDQHZGRFXPHQW
• This function calls the ABAP module FUHDWHBEDVLFBREMHFWV, which creates and starts a
link server instance.
• Then, the ABAP module XVHUBFRPPDQGB is executed. This starts Microsoft Word in
a separate window and creates a new document.
,QWHUIDFHIXQFWLRQ/,1.B$''$GGDOLQNWROLQNVHUYHU
• If you want to transfer data from an ABAP variable into a document, the document must
contain an appropriate link to that variable. You transfer the link from the ABAP program
to the document by declaring the relevant link item to the link server.
The link is then placed in the clipboard, from where you can place it in the document using the
"Paste special" function.
SAP AG 480
ABAP Workbench Delta Guide (3.1-4.6)
06:RUGKDVEHHQVWDUWHGDQGDQHZGRFXPHQWKDVEHHQFUHDWHGE\XVLQJWKH
IXQFWLRQ³&UHDWHGRFXPHQW´YDOXH³),5679$/8(´LVW\SHGWRWKHVFUHHQILHOG,1387
),(/'LQWHUIDFHIXQFWLRQ³/LQNÅ&OLSERDUG´LVH[HFXWHG
7KHOLQNLVSODFHGLQWKHGRFXPHQWXVLQJWKH06:RUGIXQFWLRQ³3DVWH6SHFLDO´7KH
JUDSKLFVKRZVWKHOLQNZLWKWKHRSWLRQ³)LHOGFRGH 21´
SAP AG 481
ABAP Workbench Delta Guide (3.1-4.6)
7KHOLQNLVSODFHGLQWKHGRFXPHQWXVLQJWKH06:RUGIXQFWLRQ³3DVWH6SHFLDO´7KH
JUDSKLFVKRZVWKHOLQNZLWKWKHRSWLRQ³)LHOGFRGH 2))´
,QWHUIDFHIXQFWLRQ5()5(6+B/5HIUHVKHVOLQNYDOXHLQWKHGRFXPHQW
• If the value of the corresponding ABAP variables has changed, you can retransport the
link items to the link server and update them in the document.
9DOXH³6(&21'9$/8(´LVHQWHUHGLQWKHVFUHHQILHOG,1387),(/'LQWHUIDFHIXQFWLRQ
³5HIUHVKOLQNV´LVH[HFXWHG
SAP AG 482
ABAP Workbench Delta Guide (3.1-4.6)
7KHYDOXHLQWKHGRFXPHQWKDVEHHQUHIUHVKHG
,QWHUIDFHIXQFWLRQ67236WRSVWKH$%$3SURJUDP
- The PAI module exit is processed. The link server instance on the front end is also
destroyed.
$%$3PRGXOHV
,QFOXGHSURJUDPGUOBRLBR
* INCLUDE D45RL_OI_3O01
MODULE status_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
ENDMODULE.
,QFOXGHSURJUDPGUOBRLBL
* INCLUDE D45RL_OI_3I01
MODULE CREATE_BASIC_OBJECTS INPUT.
CHECK okcode NE ’STOP’.
CHECK already_done IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = ’CONTAINER’.
SAP AG 483
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 484
ABAP Workbench Delta Guide (3.1-4.6)
document_proxy = document
error = error
retcode = retcode.
already_done = ’X’.
ENDMODULE.
WHEN ’LINK_ADD’.
CALL METHOD linkserver->add_string_item
EXPORTING
item_name = ’INPUTFIELD’
item_value = inputfield
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
WHEN ’REFRESH_L’.
CALL METHOD linkserver->add_string_item
EXPORTING
item_name = ’INPUTFIELD’
item_value = inputfield
SAP AG 485
ABAP Workbench Delta Guide (3.1-4.6)
no_flush = ’’
IMPORTING
retcode = retcode
error = error.
ENDCASE.
ENDMODULE.
SAP AG 486
ABAP Workbench Delta Guide (3.1-4.6)
/LQN6HUYHU&RQWDLQHU$XWRPDWLRQ6HUYHU
0RGHO
The SAP Document Container Control acts as an Automation Server object with properties
and methods. You can access these automation objects from automation clients such as
Visual Basic and VBA.
The container property points to the container in which the application is running (for example,
Excel running in the SAP Document Container Control, Excel running in Word, and so on).
One of the objects in the SAP Document Container Control is the link server object.
&RQWDLQHU$XWRPDWLRQ6HUYHU0RGHO/LQNVHUYHU
5HPRWH/HDUQLQJ
'LPWDEOHDVREMHFW
'LPURZDVREMHFW
VHWWDEOH
Container 7KLV'RFXPHQW&RQWDLQHU/LQNVHUYHU,WHP&XVWRPHUV7DEOH
IRUHDFKURZLQWDEOHURZV
SULQWURZYDOXH1DPH
LinkServer QH[W
Active
Name
Items
Name
Type
Tables Table Columns
Value
Data Rows
Ranges
SAP AG
To start a macro in a document, use the method execute_macro. The above example shows
how you can use a macro to read an internal table declared to the link server (method
add_table_item), using the SAP tables OCX.
You can read any link server object (internal table, variable, binary object…) using the link
server property.
SAP AG 487
ABAP Workbench Delta Guide (3.1-4.6)
/RDGLQJD7DEOH8VLQJD0DFUR
5HPRWH/HDUQLQJ
Sub R3UpdateTable()
Dim R3Table As Object 0DFUR
Dim ExcelRange as Excel.Range
Set R3Table = ThisWorkbook.Container.Linkserver.Item("ITAB").Table
Set ExcelRange = Sheet1.Range (Sheet1.Cells(1,1),
Sheet1.Cells ( R3Table.Rows.Count, R3Table.Rows.Count))
ExcelRange.Value = R3Table.Data
End Sub
([FHO
5DQJH
&$//0(7+2'OLQNVHUYHU!DGGBWDEOHBLWHP
&$//0(7+2'GRFXPHQW!H[HFXWHBPDFUR
(;3257,1*
0$&52B675,1*
583'$7(7$%/(µ $SSOVHUYHU /LQNVHUYHU
12B)/86+ ,QWWDEOH
,03257,1*
,QWWDEOH
(5525 HUURU
5(7&2'( UHWFRGH
SAP AG
(YHQW+DQGOLQJ
When a document is open, you can trigger events in the office application to which you can
react in the ABAP program. There are two kinds of events:
1. RQBFORVHBGRFXPHQW:
This event is automatically triggered whenever the document or the office application is
closed. It gives you the opportunity, for example, to save the document.
2. RQBFXVWRPBHYHQW:
This event is triggered by macros. You can start macros either through functions in the user
interface of the office application or from the ABAP program (using the method
H[HFXWHBPDFUR).
The SAPgui passes events to the ABAP program. The program must implement a special
class for event handling.
SAP AG 488
ABAP Workbench Delta Guide (3.1-4.6)
(YHQW+DQGOLQJ
5HPRWH/HDUQLQJ
5 3&
$%$3 *8, $SSOLFDWLRQ
'RFXPHQW
(YHQW &RQWDLQHU
KDQGOHU &RQWURO
FODVV
21B&/26(B'2&80(17
DXWRPDWLF
21B&86720B(9(17
PDFUR
SAP AG
See also
When you initialize the office integration using the LQLWBFRQWURO method, you must register any
events to which you want to react in your program, using the parameters
UHJLVWHUBRQBFORVHBHYHQW and UHJLVWHUBRQBFXVWRPBHYHQW.
SAP AG 489
ABAP Workbench Delta Guide (3.1-4.6)
5HJLVWHULQJ(YHQWV
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
'$7$RIILFH7<3(5()72LBRLBFRQWDLQHUBFRQWURO
...
&$//0(7+2'RIILFH!LQLWBFRQWURO
(;3257,1*
UHJLVWHUBRQBFORVHBHYHQW
;
UHJLVWHUBRQBFXVWRPBHYHQW
;
SAP AG
SAP AG 490
ABAP Workbench Delta Guide (3.1-4.6)
'HILQLQJ&ODVVHVIRU(YHQW+DQGOLQJ
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
&/$66FBHYHQWBKDQGOHU'(),1,7,21
38%/,&6(&7,21
&/$660(7+2'6FORVHBHYHQWBKDQGOHU
)25(9(17RQBFORVHBGRFXPHQW
2)LBRLBGRFXPHQWBSUR[\
,03257,1*GRFXPHQWBSUR[\KDVBFKDQJHG
(1'&/$66
&/$66FBHYHQWBKDQGOHU,03/(0(17$7,21
0(7+2'FORVHBHYHQWBKDQGOHU
,)KDVBFKDQJHG(4
3URFHVVLQJORJLF
H[DPSOH6DYH
(1',)
(1'0(7+2'
(1'&/$66
SAP AG
See also
Processing Logic for Events as Object Methods
See also
Use the SET HANDLER statement to assign the relevant method to the corresponding
document.
SAP AG 491
ABAP Workbench Delta Guide (3.1-4.6)
$VVLJQLQJ0HWKRGVWRD'RFXPHQW,QVWDQFH
5HPRWH/HDUQLQJ
352*5$0VDSGUOBRLB
&/$66FBHYHQWBKDQGOHU'(),1,7,21
38%/,&6(&7,21
&/$660(7+2'6FORVHBHYHQWBKDQGOHU
)25(9(17RQBFORVHBGRFXPHQW
2)LBRLBGRFXPHQWBSUR[\
(1'&/$66
...
&$//0(7+2'RIILFH!JHWBGRFXPHQWBSUR[\ &/26(B(9(17B+$1'/(5
(;3257,1* DVVLJQHGWRLQVWDQFH
'2&80(17B7<3( GRFXPHQWBW\SH GRFXPHQW
,03257,1* RIFODVV
'2&80(17B352;< GRFXPHQW
(5525 HUURU &B(9(17B+$1'/(5
5(7&2'( UHWFRGH
6(7+$1'/(5FBHYHQWBKDQGOHU !FORVHBHYHQWBKDQGOHU)25GRFXPHQW
SAP AG
You trigger a custom event in a document using a macro. You program this using the SAP
Container method 6HQG&XVWRP(YHQWagainst the standard FRQWDLQHUSURSHUW\.
&XVWRPB(YHQW8VLQJD9%$0DFUR
5HPRWH/HDUQLQJ
Sub ...
6WDQGDUGSURSHUW\ 6$3PHWKRG
...
ThisDocument.Container.SendCustomEvent (“PUSH")
End Sub
352*5$0VDSGUOBRLB
&/$66FBHYHQWBKDQGOHU'(),1,7,21
38%/,&6(&7,21
&/$660(7+2'6
FXVWRPBHYHQWBKDQGOHU
)25(9(17RQBFXVWRPBHYHQW
2)LBRLBGRFXPHQWBSUR[\
,03257,1*GRFXPHQWBSUR[\HYHQWBQDPH
SDUDPBFRXQWSDUDPSDUDPSDUDP
(1'&/$66
&/$66FBHYHQWBKDQGOHU,03/(0(17$7,21
0(7+2'FXVWRPBHYHQWBKDQGOHU
(1'0(7+2'
(1'&/$66
SAP AG
SAP AG 492
ABAP Workbench Delta Guide (3.1-4.6)
5HOHDVH5HOHDVH All of the screens that can be displayed while a document is active
must call the function module &21752/B',63$7&+ in their PROCESS AFTER INPUT
event and pass the contents of the RNBFRGH field to it.
5HOHDVH Due to internal chamges within the Control Framework the PAI handling of
events changed: All of the screens that can be displayed while a document is active must call
the class method',63$7&+ of the Control Framework class FOBJXLBFIZ in their PROCESS
AFTER INPUT event. This method takes no import parameters. You may call the method
always before evaluating the content of the ok_code field: If no event has been triggered the
method has no effect. You can find whether the event was successfully passed to a handler
by quering the return code parameter of the method cl_gui_cfw=>dispatch .
,QWHJUDWLQJ(YHQW+DQGOLQJLQWKH3$,
5HPRWH/HDUQLQJ
6$35 6$35
System Help System Help
3 3 3Ï 3
Î
Î
Î Ï
Ï 3ÎÎ 3Î 3Ï 3ÏÏ
100 200
3$,PRGXOH
*8,
......
'$7$UF7<3(,
'RFXPHQW
&$//0(7+2'FOBJXLBFIZ !GLVSDWFK
,03257,1* &RQWDLQHU
5(7851B&2'( UF &RQWURO
&$6(RNBFRGH
(YHQW
SAP AG
6DPSOH(YHQW+DQGOLQJRQBFORVHBGRFXPHQW
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
*HQHUDO'HVFULSWLRQRI3URJUDP
The program demonstrates how to process the interface event RQBFORVHBGRFXPHQW. If the
desktop application is closed while the program is running, the event is automatically sent to
the ABAP program, where you can react to it.
The program is a module pool (type M) with two screens - 100 and 101. Screen 101 is a
dialog box. The user interface of screen 100 contains two functions:
- Create document ( function code ,16(57 )
SAP AG 493
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLB
INCLUDE D45RL_OI_5TOP.
INCLUDE D45RL_OI_5O01.
INCLUDE D45RL_OI_5I01.
INCLUDE D45RL_OI_5F01.
When you run the program, screen 100 is processed.
'DWDDQG&ODVV'HILQLWLRQVLQFOXGHSURJUDPGUOBRLBWRS
*& Include d45rl_oi_5top
DATA answer.
DATA already_done.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Word.Document.8’.
DATA: item_url(256).
DATA okcode(15).
DATA: path(50).
SAP AG 494
ABAP Workbench Delta Guide (3.1-4.6)
METHOD CLOSE_EVENT_HANDLER.
IF HAS_CHANGED EQ 1.
PERFORM OPEN_CHECK_AND_SAVE_DIALOG.
ENDIF.
ENDMETHOD.
ENDCLASS.
3%2(YHQWRIVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the user interface
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGQRW\HWVWDUWHG
3$,(YHQWRIVFUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE CREATE_BASIC_OBJECTS
MODULE USER_COMMAND_0100.
3$,SURFHVVLQJRIVFUHHQ
,QWHUIDFHIXQFWLRQ,16(57&UHDWHVDQHZGRFXPHQW
- Starts Microsoft Word in a separate window .
$XWRPDWLF7ULJJHULQJRIWKH(YHQWRQBFORVHBGRFXPHQW:KHQWKH'RFXPHQWRU
'HVNWRS$SSOLFDWLRQLV&ORVHG
The event is converted into a function code (beginning with “%”) at the front end, and then
sent to the ABAP program (placed in the OK_CODE field). In the PAI event, you must call the
SAP AG 495
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 496
ABAP Workbench Delta Guide (3.1-4.6)
$%$30RGXOHV
,QFOXGHSURJUDPGUOBRLBR
* INCLUDE D45RL_OI_5O01
,QFOXGHSURJUDPGUOBRLBL
* INCLUDE D45RL_OI_5I01
SAP AG 497
ABAP Workbench Delta Guide (3.1-4.6)
inplace_enabled = ’’
parent = container
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
SAP AG 498
ABAP Workbench Delta Guide (3.1-4.6)
FORM SAVE_DIALOG.
CALL METHOD document->close_document
EXPORTING
do_save = ’X’
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
SAP AG 499
ABAP Workbench Delta Guide (3.1-4.6)
OTHERS = 2.
IF answer = ’1’.
CLEAR answer.
CALL SCREEN 101 STARTING AT 5 5
ENDING AT 75 8.
IF okcode = ’YES’.
CALL METHOD document->save_document_to_url
EXPORTING
url = path
no_flush = ’’
IMPORTING
retcode = retcode
error = error.
ENDIF.
ENDIF.
CALL METHOD document->release_document
EXPORTING
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
ENDFORM.
6DPSOH(YHQW+DQGOLQJRQBFXVWRPBHYHQW
Note that incompatible changes were made to the method interfaces between Releases
4.0 and 4.5. All returning parameters have been redefined as export parameters (that is, you
must replace RECEIVING with IMPORTING in your method calls).
*HQHUDO'HVFULSWLRQRI3URJUDP
This program demonstrates the use of the interface event RQBFXVWRPBHYHQW. A custom
event is triggered in a document using a macro, and this event is sent to the ABAP program.
You can then react to the event in the program.
The program is a module pool (type M) and has a single screen (100).
The interface of screen 100 contains the following two functions:
- Change document ( function code &+$1*( )
- Exit ( function code 6723typeH[LWFRPPDQG )
SAP AG 500
ABAP Workbench Delta Guide (3.1-4.6)
3URJUDP6WUXFWXUHDQG)ORZ
0DLQSURJUDPVDSGUOBRLB
INCLUDE D45RL_OI_6TOP.
INCLUDE D45RL_OI_6O01.
INCLUDE D45RL_OI_6I01.
When you run the program, screen 100 is processed.
'DWDDQG&ODVV'HILQLWLRQVLQFOXGHSURJUDPGUOBRLBWRS
*& Include d45rl_oi_6top
DATA already_done.
DATA retcode TYPE soi_ret_string.
DATA document_type(80) VALUE ’Word.Document.8’.
DATA: item_url(256).
DATA: filename(67).
DATA okcode(15).
SAP AG 501
ABAP Workbench Delta Guide (3.1-4.6)
3%2(YHQWRIVFUHHQ
PROCESS BEFORE OUTPUT.
MODULE status_0100. “Set the user interface
MODULE set_values.
6FUHHQRI53URJUDP2IILFH$SSOLFDWLRQ06:RUGQRW\HWVWDUWHG
3$,(YHQWRIVFUHHQ
3$,)ORZ/RJLF
PROCESS AFTER INPUT.
MODULE EXIT AT EXIT-COMMAND.
MODULE CREATE_BASIC_OBJECTS.
MODULE USER_COMMAND_0100.
SAP AG 502
ABAP Workbench Delta Guide (3.1-4.6)
3$,SURFHVVLQJRIVFUHHQ
,QWHUIDFHIXQFWLRQ&+$1*(2SHQVDGRFXPHQWLQFKDQJHPRGH
- Starts Microsoft Word in a separate window and opens the specified document for editing.
6HQGLQJDFXVWRPHYHQWIURPWKHGHVNWRSDSSOLFDWLRQ
$GRFXPHQWPDFURVHQGVWKHFXVWRPHYHQWRQBFXVWRPBHYHQWWRWKH$%$3SURJUDP
7KLVWULJJHUVWKHPHWKRGFXVWRPBHYHQWBKDQGOHULQWKHSURJUDP
You can find the Word document in the directory ([B'RFVB2IILFHB,QWHJ ( filename
GRFBFXVWBHYGRF
9LVXDO%DVLF0DFUR&RPPDQG%XWWRQB&OLFN
Private Sub CommandButton1_Click()
Application.ActiveDocument.Container.SendCustomEvent("PUSH")
End Sub
The macro &RPPDQG%XWWRQB&OLFN sends the event PUSHBUTTON to the corresponding
ABAP program. At the front end, the event is converted into a function code (beginning with
‘%’), which is then placed in the OK_CODE field of the program. In the PAI event of the
screen, you must call the class method &/B*8,B&): !',63$7&+. Then, the method
FXVWRPBHYHQWBKDQGOHU of local class FBHYHQWBKDQGOHU is executed.
$%$30RGXOHV
,QFOXGHSURJUDPGUOBRLBR
* INCLUDE D45RL_OI_6O01
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ’100’.
SET TITLEBAR ’100’.
ENDMODULE.
SAP AG 503
ABAP Workbench Delta Guide (3.1-4.6)
,QFOXGHSURJUDPGUOBRLBL
* INCLUDE D45RL_OI_6I01
MODULE USER_COMMAND_0100 INPUT.
CHECK okcode NE ’STOP’.
CALL METHOD cl_gui_cfw=>dispatch.
CASE okcode.
WHEN ’CHANGE’.
CONCATENATE item_url filename INTO item_url.
CALL METHOD document->open_document
EXPORTING
document_url = item_url
open_inplace = space
no_flush = ’’
IMPORTING
error = error
retcode = retcode.
ENDCASE.
ENDMODULE.
SAP AG 504
ABAP Workbench Delta Guide (3.1-4.6)
ENDIF.
SET SCREEN 0.
ENDCASE.
ENDMODULE.
SAP AG 505
ABAP Workbench Delta Guide (3.1-4.6)
SAP AG 506
ABAP Workbench Delta Guide (3.1-4.6)
6$36FULSW
After reviewing the following topics, you will be able to:
Understand the graphics management
SAP AG 507
ABAP Workbench Delta Guide (3.1-4.6)
,QWURGXFWLRQDQG2YHUYLHZ
In Release 4.0/4.5 of the R/3 System, SAPscript - SAP’s word processing system - is much
easier to use thanks to a new PC editor and a graphical form painter which allow you to work
simply and intuitively on the basis of WYSIWYG - „What you see is what you get“.
5DQJHRI)XQFWLRQVDQG7HFKQLFDO
5HTXLUHPHQWV
On your front-end, either Windows NT 4.0 or Windows95 and higher must be installed as 32-
bit operating system. At present, other platforms are not supported.
1HZ3&(GLWRU
In the new SAPscript editor, you can access all functions such as cut and paste either with
the mouse or through pushbuttons. Control commands like that used for bold type are no
longer necessary. This new editor automatically replaces the previous editor throughout R/3,
whether you are sending mails, or entering purchase orders or material texts. All in all, well
over 100 different locations in R/3 will benefit from this improvement.
Apart from its user-friendliness and excellent functionality, this new editor is distinguished by
its scalability. It is tailored so that each application only has access to the functions it really
needs. All purchase orders, for example, have a standard layout, so users do not have to be
familiar with all the style guidelines.
*UDSKLFDO)RUP3DLQWHU
In Release 4.0/4.5, the new form painter simplifies the design and modification of forms
considerably. A graphical user interface aids intuitive and fast handling, so you no longer
have to worry about abstract layout data such as the precise size of output areas - you simply
position the areas in a design window with the mouse and modify them there. Functions like
cut and paste and facilities such as alignment using grids both aid page design.
The new text editor also comes into play here. It allows you to enter form texts on the
appropriate scale and then get an immediate print preview screen of the results.
,QWHJUDWLRQLQWRWKH$%$3:RUNEHQFK
SAP AG 508
ABAP Workbench Delta Guide (3.1-4.6)
Forms are important at all levels of an enterprise. With its programming interface, SAPscript
thus provides a powerful tool to support data-driven generation of documents. For example,
you can hide or show selected areas of a form, or format database fields according to type
(with currencies or decimal places) just as they are defined in the ABAP Dictionary. These
techniques guarantee a uniform layout, but you can still adapt this to suit your own needs.
In Release 4.0/4.5, there is a handy input help facility for database fields used in forms. By
using the mouse, you can jump easily from a form to the relevant ABAP print program and
back. Where-used lists complete the integration into the ABAP Workbench and support
developers when designing a customized word processing system for their particular
application.
7KH3&(GLWRU
You use the new PC Editor to create and edit texts. These texts you can then print using
forms (for example, form letters) or use for creating documents in the R/3 system (for
example, orders and material texts).
:<6,:<*)XQFWLRQDOLW\
The processing of texts in the PC Editor is like the usual document handling in common text-
processing systems.
SAP AG 509
ABAP Workbench Delta Guide (3.1-4.6)
See also
SAP AG 510
ABAP Workbench Delta Guide (3.1-4.6)
6HWWLQJWKH3&(GLWRU
5HPRWH/HDUQLQJ
6WDQGDUG7H[W5HTXHVW
Settings
PC editor...
Line editor
3&HGLWRU
BL C
SU
SAP AG
From the 6WDQGDUG7H[W5HTXHVW screen you can choose which editor you want to work with.
Choose 6HWWLQJV→3&HGLWRU.
Choose *RWR→&KDQJHHGLWRU from within one editor to change to the other.
SAP AG 511
ABAP Workbench Delta Guide (3.1-4.6)
7KH3&(GLWRU
5HPRWH/HDUQLQJ
7H[W(GLW*RWR)RUPDW,QVHUW6\VWHP+HOS
+ 8 Character formats
Display formats
Reset character format
Paste Last character format
Copy Last paragraph format
Cut
Print preview
Display/Change
SAP AG
PC editor operations are called, in contrast to line editor operations, using pushbuttons and
menu functions. The paragraph and character format pushbuttons allow you to assign your
text paragraph and character formats according what is selected.
6HHDOVR
In Release 4.0 the pushbuttons 'LVSOD\&KDQJH and 3ULQWSUHYLHZ are not given on this
screen. You can find them using the 6WDQGDUG7H[W5HTXHVW screen.
SAP AG 512
ABAP Workbench Delta Guide (3.1-4.6)
(QWHULQJ7H[WLQWKH3&(GLWRU
5HPRWH/HDUQLQJ
BCL 1HZSDUDJUDSK
HU
BCL
1HZOLQH
HU
This is a normal text.
This is a normal text in a new
line of the same paragraph.o
Shift +
SAP AG
SAP AG 513
ABAP Workbench Delta Guide (3.1-4.6)
$VVLJQLQJ3DUDJUDSKDQG&KDUDFWHU)RUPDWV
5HPRWH/HDUQLQJ
BCL
HU
6HOHFWWH[W
ZLWKPRXVH
This is a normal text in left-justified
paragraph.o
$VVLJQQHZSDUDJUDSK
BCL
RUFKDUDFWHUIRUPDW
HU
SAP AG
&HQWUDO(GLWRU)XQFWLRQV
$VVLJQ3DUDJUDSK)RUPDW
$VVLJQ&KDUDFWHU)RUPDW
Various characters can be formatted differently (bold, italics, etc.) by selecting and choosing
the appropriate pushbuttons for the formats provided by the application.
In order to reset the new character format to what it previously was, mark the formatted
character string by positioning the mouse at the beginning and then using SHIFT and
positioning the mouse at the end. Choose (GLW→6HOHFWHGDUHD→/DVWFKDUDFWHUIRUPDW.
SAP AG 514
ABAP Workbench Delta Guide (3.1-4.6)
'LVSOD\3DUDJUDSKDQG&KDUDFWHU)RUPDW
You can display the current paragraph and character formats by choosing (GLW!'LVSOD\
IRUPDWV.
To show the paragraph marks Choose )RUPDW!3DUDJUDSKRQRII.
,QVHUWLQJ&RPPDQGV
7H[W(GLW*RWR)RUPDW,QVHUW6\VWHP+HOS
&UHDWH$GGLWLRQDO,QIRUPDWLRQ
Symbols
Delete command
Change command
Command
Insert command
Text element
Comment
SAP characters
SAP AG
Those commands and symbols inserted using the dialog box undergo a syntax check before
they are inserted into your text. You can also check syntax manually using 7H[W!&KHFN.
From Release 4.5 you can also check unknown symbols in form texts.
SAP AG 515
ABAP Workbench Delta Guide (3.1-4.6)
,QVHUW3URJUDP6\PEROV
As of 4.0/4.5 you can also insert program symbols which are defined as global data in the
print program.
Choose ,QVHUW→6\PEROV→3URJUDPV\PEROV. If no program is selected, choose $SSHQG
SULQWSURJUDP. The dialog window $SSHQGSULQWSURJUDPWRIRUP appears. Enter the desired
print program. Choose '',&ILHOGV or *OREDOGDWD. A list of the fields appears. Select the
desired field. Choose &RQWLQXH. The system inserts the program symbol.
Choose the 6\PEROGHILQLWLRQ pushbutton or *RWR→3ULQWSURJUDP→6\PEROGHILQLWLRQ to
branch to a specific data object’s definition screen in the print program.
3URJUDP6\PEROVDQG6\PERO'HILQLWLRQ
5HPRWH/HDUQLQJ
Program symbols
7H[W(GLW*RWR)RUPDW,QVHUW6\VWHP+HOS
63)/,
6)/,*+7
&57;
Program symbols
Symbol definition
3ULQWSURJUDPVIRUIRUP
Symbol definition
3ULQWUHSRUW 6KRUWGHVFULSWLRQ
5(3257ULSUDW
5,35$7 7$%/(6VSIOLVIOLJKW
'$7$VXPV/,.(
SAP AG
See also
3&(GLWRUGRHVQRWORDG Problems may arise when loading the editor and the previous
line editor is used instead of the PC Editor. This is because one or more paragraph and/or
character formats could not be converted. The old editor accepts incorrectly entered formats,
in the new PC Editor all formats used must be defined correctly.
In such cases you should ensure that all incorrect formats are removed and save the
document. You can then go to the PC Editor.
7KH*UDSKLFDO)RUP3DLQWHU
SAP AG 516
ABAP Workbench Delta Guide (3.1-4.6)
The new graphical Form Painter allows you to easily and intuitively design your forms. You
start the graphical Form Painter via the form maintenance transaction SE71 by choosing
6HWWLQJV→)RUP3DLQWHU. To maintain the layout of your form, choose then 3DJHOD\RXW.
:,1'2:
:LQGRZV
:LQGRZ 0$,1
'HVLJQ7H[W 2SWLRQV
SAP AG
7KH'HVLJQ:LQGRZ
When you choose /D\RXWwithin the Form Painter, the system displays a second window, the
Design window. Here, you can use the mouse to design the page layout (drag & drop, cut &
paste). From within the Administration screen, you can assign two different modes to the
design window. Choose 'HVLJQ7H[W to switch between Design mode and Text mode.
In design mode, you can
• Use the mouse to position the windows.
• Change the window size.
• Select a window for editing.
The design window has a grid surface to allow easy aligning of the windows.
To set the graduation of the grid in different measurement units, choose 8WLOLWLHV→2SWLRQV.
In addition, you can zoom the entire design window.
In text mode, the system displays the text elements of the individual windows. To see the
entire text, scroll in the window. However, the text is read-only. To edit it, branch to the editor
by choosing 7H[W on the administration screen.
SAP AG 517
ABAP Workbench Delta Guide (3.1-4.6)
See also
7KH$GPLQLVWUDWLRQ6FUHHQ
Pages and windows are edited in two structured areas. There are pushbuttons for the most
important menu paths.
7KH3DJH$UHD
/D\RXW3DJHV
5HPRWH/HDUQLQJ
&XUUHQWSDJH
&XUUHQWSDJH
2WKHUDWWULEXWHV
2WKHUDWWULEXWHV
Form: Page Layout IRUFXUUHQWSDJH
IRUFXUUHQWSDJH
3DJH
3DJH$GGUHVVSDJH
&UHDWH
&UHDWH 3DJHRYHUYLHZ
3DJHRYHUYLHZ
:LQGRZV
1H[WSDJH
1H[WSDJH
'HOHWH
'HOHWH
&RS\
&RS\ 5HQDPH
5HQDPH )LUVWSDJH
)LUVWSDJH
SAP AG
&KRRVHSDJH
You can switch between pages either in the List box, which contains all pages defined in the
form, or via )LUVWSDJH1H[WSDJH2YHUYLHZ.
&UHDWHSDJHV
To create individual pages, choose (GLW!3DJH!&UHDWH. The system automatically assigns
a default name and creates a main window. To rename the page, choose (GLW!3DJH!
5HQDPH.
&RS\SDJHV
To copy a page, you can also use the copy function (choose (GLW!3DJH!&RS\). The
system copies all windows including the respective text elements and assigns a default name.
SAP AG 518
ABAP Workbench Delta Guide (3.1-4.6)
'HOHWHSDJHV
To delete individual pages, choose (GLW!3DJH!'HOHWH.
3DJHVHTXHQFH
To display the current page sequence, choose 2YHUYLHZ. You can choose a page directly in
the list box.
3DJHDWWULEXWHV
To change the next page and the meaning of the page, choose 2WKHUDWWULEXWHV.
Here, you can determine the numbering and the page counter mode. You can set print
attributes such as resource name and print mode for the respective page.
7KH:LQGRZ$UHD
/D\RXW:LQGRZVDQG3DJH:LQGRZV
5HPRWH/HDUQLQJ
; 0DLQZLQGRZ
'HIDXOWSDU 3DJHZLQGRZDWWULEXWHV
3DJHZLQGRZDWWULEXWHV
/HIWPDUJLQ &0
8SSHUPDUJLQ &0
:LQGRZZLGWK &0
:LQGRZKHLJKW &0 (GLWLQJSXVKEXWWRQV
(GLWLQJSXVKEXWWRQV
'HVLJQ7H[W 2SWLRQV
SAP AG
&KRRVHZLQGRZV
You can display all windows in the current page in the list box and edit them via this box or by
clicking on the window in the Design window.
&UHDWHZLQGRZV
To create new windows, choose &UHDWH. By default, the system creates a variable window
(type VAR) and assigns a default name. To rename the window, choose (GLW!:LQGRZ!
5HQDPH. If you want to choose which type of window to create, you must use the function
from the menu bar instead of the pushbutton to create the window.
To create a main window, you must choose (GLW!:LQGRZV!&UHDWH!0DLQZLQGRZ.
SAP AG 519
ABAP Workbench Delta Guide (3.1-4.6)
:LQGRZV Options
:LQGRZ 0$,1 =RRP
118%
; 0DLQZLQGRZ
50% 200%
'HIDXOWSDU
:LQGRZZLGWK &0 0 10
:LQGRZKHLJKW &0
8QLWRIPHDVXU 00
$OLJQDXWRPDWLFDOO\WRJULG
'HVLJQ7H[W 2SWLRQV
SAP AG
The 2SWLRQV pushbutton allows you to zoom in on a specific section of your page.
In addition, you can choose to have your window aligned automatically to the grid.
SAP AG 520
ABAP Workbench Delta Guide (3.1-4.6)
You can also choose what size the individual units of your design window grid should be in a
unit of measure of your choice.
See also
When a form is created, an initial page with a main window is automatically created. A
main window must always have the same width on all pages (cf. variable window). If the width
of main window is changed it changes on all pages.
*UDSKLFV0DQDJHPHQW
To upload a Tag Image File Format (TIFF) graphic in a text, you can use the graphics
management. Choose /D\RXW within the Form Painter. To include the TIFF graphic, choose
(GLW→*UDSKLFV→&UHDWH. The dialog window ,QFOXGHJUDSKLF appears.
In this dialog window you name your text in which the TIFF file will be uploaded. Set raster
screen attributes for black/white or colored graphic. Choose ,PSRUW. The dialog window ,PSRUW
JUDSKLF appears.
SAP AG 521
ABAP Workbench Delta Guide (3.1-4.6)
Enter the path of your file name to import the TIFF file. Choose the resolution of your graphic.
If you don’t choose it, the system will take 300 DPI. Press ENTER. The system automatically
generates a text with Object GRAPHICS and ID BMON if you choosed black/white or ID
BCOL if you choosed color in raster screen attributes. The system shows all attributes on a
different screen. Choose %DFN to go on maintaining the form.
You can also choose the graphics management directly to upload TIFF graphics in a text.
Choose 7RROV→6$3VFULSW→$GPLQLVWUDWLRQ→*UDSKLFV.
6$3VFULSW5DZ'DWD,QWHUIDFH&RQFHSWDQG
8VDJH
&RQQHFWLQJH[WHUQDOWH[WPDQDJHPHQWV\VWHPV
Using the SAPscript Raw Data Interface (RDI), you can connect external text management
systems to master individual requests, for example, optimizing postage expense. The
interface contains all data of the R/3 forms, but no layout informations such as font or page
size. The external system alone is responsible for layout and administration of the document
data.
The RDI is of special importance for automatic addressing and postaging: The external
system sorts the data from the interface and forwards the document accordingly.
1RLQWHJUDWLRQLQWKH5V\VWHP
The Raw Data Interface is a certified interface and allows easy connection of external
systems. However, this extra functionality demands its price: You loose the tight integration
within the R/3 system. For example, there is no way to find out from within an R/3 application
wether the external system succesfully printed and sent the documents. In addition, each
adaption of standard forms causes extra expenses, since the system has to adapt an internal
as well as an external form. And the external tool is no integral part of the ABAP Workbench,
so that field information from the ABAP Dictionary (field type, output length, and so on) is not
available.
For detail information about RDI
See also
SAP AG 522
ABAP Workbench Delta Guide (3.1-4.6)
7UDQVSRUWLQJ6$3VFULSW2EMHFWV
From Release 4.0, texts administered by SAPscript (standard texts, for example) can be
transported using the Customizing Organizer.
If you want to transport document of this type, they must first be manually attached to a
transport request in the Cusomizing Organizer. Enter the following after double-clicking on the
task number:
R3TR TEXT <OBJECT>,<NAME>,<ID>,<L>
(OBJECT = text object, NAME = text name, ID = text ID, L = text language, use one
character only).
After attaching your document a transport request, all standard transport functions of the
Customizing Organizer are available.
Alternative, you can execute report RSTXTRAN and there select the texts you want to
transport. This program then creates a Customizing Organizer request.
([HUFLVH3&(GLWRUDQG*UDSKLFDO)RUP3DLQWHU
1. Choose the Forms transaction and make sure that the graphical Form Painter is set to be
used.
2. Copy the form S_CA930_DEMO_4 from client 000 into a new form named
Z_CA930_DEMO_4 by choosing 8WLOLWLHV!&RS\IURPFOLHQW.
3. Access the new form Z_CA930_DEMO_4.
4. Explore the new Forms transaction:
Visit the page layout
Look at different form pages using the icons
5. Check texts by pressing the pushbutton and double-clicking the windows with the
warnings. Correct the wrong paragraph format UL to paragraph format L by editing main
window text. After correcting you can change to PC Editor.
6. Add new fields in a new line and insert a prefix for each field:
Add the following customer fields in window SENDER; consider an enlargement of the
window:
Customer Type and Discount.
Find the fields in table SCUSTOM.
7. Print the form to the screen by using the print program RSTXEXP2. Fill in the correct form
in the selection screen and make sure that your changes in look nice.
6ROXWLRQ3&(GLWRUDQG*UDSKLFDO)RUP3DLQWHU
SAP AG 523
ABAP Workbench Delta Guide (3.1-4.6)
4. No hint.
5. Choose MAIN window in the page layout. Use in the Design Window the right mouse
button to choose (GLWZLQGRZWH[W.When editing the MAIN window, the system can’t load
the PC Editor, because of the wrong paragraph format UL, which does not exist in the
form. To change to PC Editor after correcting, choose *RWR!&KDQJHHGLWRU.
6. Choose window SENDER in the page layout of the Form Painter to edit window text.
Enter in new lines:
Customer Type: &SCUSTOM-CUSTTYPE&
Discount: &SCUSTOM-DISCOUNT&
The program symbols must be added as symbols by choosing the pushbutton ,QVHUW
FRPPDQG. Make sure that the prefixes are using the correct character format S (Key
word, small). Use tabs to place the added program symbols under the other symbols.
7. No hint.
SAP AG 524
ABAP Workbench Delta Guide (3.1-4.6)
'DWD7UDQVIHU
After reviewing the following topics, you will be able to:
Identify the new features of the Data Transfer Workbench
Use the Transaction Recorder in Release 4.5 (Batch Input Recorder)
SAP AG 525
ABAP Workbench Delta Guide (3.1-4.6)
2YHUYLHZ'DWD7UDQVIHU
Release 4.x includes the following new data transfer tools and functions:
• Legacy System Migration Workbench (LSMW)
• Data Transfer Workbench (SXDA)
• Batch Input Recorder
The basic procedure for transferring data from a non-SAP system into the R/3 System has
remained the same. The tools listed above provide support for any data transfer program you
use, whether the program is from SAP or elsewhere. This makes data transfer more efficient
and secure.
/HJDF\6\VWHP0LJUDWLRQ:RUNEHQFK
:KDWLVWKH/60:RUNEHQFK"
The LSM Workbench is an R/3-based tool providing support for single transfers of data or
periodic transfers of data from non-SAP systems (“legacy systems”) to R/3.
The tool converts the legacy system data to be transferred to R/3 into a format that can be
processed by a standard batch input or direct input program in the associated application.
In addition, the transaction recorder (batch input recorder) is linked to the LSM Workbench,
which can be used to generate a migration object from an entry or change a transaction
recording.
%DVLF3ULQFLSOHVRIWKH/60:RUNEHQFK
SAP AG 526
ABAP Workbench Delta Guide (3.1-4.6)
• Quality and consistency of the data created in R/3 are more important than the speed and
performance of data migration.
• Use existing knowledge and source code
• Be able to reuse the mapping and rules in other projects
2YHUYLHZ
$FFHOHUDWLQJ'DWD0LJUDWLRQ/60:RUNEHQFK
l +RZ/60:RUNEHQFKZRUNV
/HJDF\GDWD
RQ3&
5HDGGDWD 5HDGGDWD
6WUXFWXUH
/HJDF\GDWD
UHODWLRQV RQDSSOLFDWLRQ
VHUYHU
)LHOG
&RQYHUWGDWD
PDSSLQJ
%DWFK,QSXW
SURFHVVLQJ
&RQYHUVLRQ
UXOHV
&RQYHUWHG 'LUHFW,QSXW
GDWD SURFHVVLQJ
,'RFLQERXQG
SURFHVVLQJ
SAP AG 527
ABAP Workbench Delta Guide (3.1-4.6)
3UHGHILQHG&RQYHUVLRQ5XOHV
$FFHOHUDWLQJ'DWD0LJUDWLRQ/60:RUNEHQFK
l 0RVWFRPPRQFRQYHUVLRQUXOHVSUHGHILQHG
w ,QLWLDOYDOXH
Õ
Õ
' '(
w &RQVWDQW
Õ
$ $7
) )5
w $VVLJQ³029(´
w )L[HGYDOXH
w WUDQVODWLRQ
w 7UDQVODWLRQYLDLQWHUYDOV
w 8VHUGHILQHGURXWLQHV
Õ
Õ
w 3UHIL[
Õ
w 6XIIL[
w &RQFDWHQDWH
w ,QGLYLGXDO$%$3FRGLQJ
The most important transfer functions in the LSM Workbench can be accessed with the click
of a button. The 1:1 conversion is a powerful tool. One of the important features: various
values (from the legacy data) belonging to a field are automatically “collected” during the
conversion.
If users decide that the predefined conversion rules are insufficient for their needs, they can
add their own ABAP coding to every target field. This coding is used when the conversion
program is generated.
'DWD7UDQVIHU:RUNEHQFK
'HVFULSWLRQ
The Data Transfer Workbench (DTW) supports the automatic transfer of data from your
legacy system into the R/3 System. The Workbench provides you with access to the standard
programs as well as with the necessary tools for transferring data.
The DTW is a central access point for the objects named above and offers many standard
functions (such as displaying or changing a file)
The transfer program of the application does the actual transfer. The transfer program
determines which object-specific functions are supported by the DTW.
The transfer program also determines which transfer technologies are available to perform
the actual transfer (batch input, call transaction or direct input).
The data transfer object (DX object) you select specifies which type of data transfer is
executed.
'DWD7UDQVIHU2EMHFWV5HO
You can transfer the following objects using the Data Transfer Workbench in Release 4.5A:
SAP AG 528
ABAP Workbench Delta Guide (3.1-4.6)
([HUFLVH&UHDWLQJ&XVWRPHU0DVWHU'DWD
In the following sections, the Data Transfer Workbench (DTW) is described in terms of
transfer of customer master data.
SAP AG 529
ABAP Workbench Delta Guide (3.1-4.6)
The standard SAP transfer program RFBIDE00 is used to transfer customer master data. In
addition, the DX object "50" must be selected in the DTW.
For the following example and exercises, use the file DEBTOR_DT.TXT The file contains ten
customers in the standard record layout.
To transfer data, it is imperative that you are familiar with the transaction used to maintain the
data online.
If you are not familiar with Transaction FD01 for maintaining customer master records, first
create a customer. The following exercise will teach you how to do this. After you finish the
exercise, you will be familiar with the important fields in a customer master record.
&RQWH[WGDWD
Transaction: FD01
Company code: 0001
Account group: DEBI
Reconciliation account: 120000
VAT reg. number: Example:
(VAT registration number):
DE123456789 (for Germany)
GB123456789 (for England)
1. For remote data transfer of customers, analyze Transaction FD01 (Create Customer: Initial
Screen)
2. Start Transaction FD01
3. Fill in the required fields
3.1. On the first screen, enter the following values:
Customer → No entry!
Company code → 0001
Account group → debi
3.2. On the second screen, fill in all required fields with whatever sensible data you want to
use:
3.3.Name
Country → your own country
Language → your own language
3.3. On the third screen, enter the VAT registration number if required
3.4. Do not enter anything on the fourth screen
3.5. On the fifth screen, enter the value "120000" in the field 5HFRQDFFRXQW (reconciliation
account).
4. Save the customer
If you have problems creating a customer, this may be due to Customizing. If this occurs,
contact a member of the user department for the correct data needed to create a customer.
&DOOLQJWKH:RUNEHQFK
SAP AG 530
ABAP Workbench Delta Guide (3.1-4.6)
The Data Transfer Workbench provides you with the necessary data transfer functions. You
can call all of the functions from the initial Workbench screen:
SAP AG 531
ABAP Workbench Delta Guide (3.1-4.6)
,QLWLDO'7:6FUHHQ
&UHDWLQJDQ,QLWLDO'DWD7UDQVIHU)LOHIRU7HVW
3XUSRVHV
Before you can transfer data automatically into the R/3 System you first need to convert the
data from your legacy system into a format suitable for the R/3 System. This initial file
contains the relevant fields in the length and sequence specified by the structure. You can
use the data transfer file to see the fields of a transfer object in the R/3 System and the
structure in which the data should be delivered.
Choose 7UDQVIHUREMHFW → &UHDWHLQLWILOH to create an empty transfer file for test purposes.
This file is used to illustrate how the fields are filled.
If a transfer file already exists you may be able to just overwrite it.
&RS\LQJD6HTXHQWLDO)LOH
The transfer file must be on the application server. The DTW supports the transfer of files
between the presentation server and the application server. Enter the source of the file and
the target. Specify the physical path.
You can only copy files if the content of the file matches the selected DX object or the
SAP work area structure of the DX object.
SAP AG 532
ABAP Workbench Delta Guide (3.1-4.6)
&RS\ILOHV
Copy the file DEBTOR_DT.TXT from the current directory on the presentation server to
the transport directory on the application server.
'LVSOD\LQJWKH'DWD7UDQVIHU)LOH
SAP AG 533
ABAP Workbench Delta Guide (3.1-4.6)
6WUXFWXUHRIDQLQLWLDOILOHIRUFXVWRPHUV
)LHOGVRIWKHVWUXFWXUH%.1
To display the file DEBTOR_DT.TXT enter the physical path of the file (including the name
of the file and the name of the transport directory) on the initial screen.
Note: The file must exist on the application server, as described above.
SAP AG 534
ABAP Workbench Delta Guide (3.1-4.6)
6SHFLI\LQJWKHSK\VLFDOSDWKILOHQDPHRQWKHDSSOLFDWLRQVHUYHU
SAP AG 535
ABAP Workbench Delta Guide (3.1-4.6)
To check the data and the structure of the file, display the individual record layout structures
BGR00, BKN00, BKNA1 and BKNB1. You should see the correct (meaningful) data in each
field. In addition, fields that do not contain a value should contain “NO DATA”.
There is no value in the field KUNNR in the structure BKN00. This is correct in this case, as
an internal number is assigned when a customer is created.
6WUXFWXUH%.1ZLWKHPSW\ILHOG.8115
(GLWLQJWKH'DWD7UDQVIHU)LOH
Use the editor to change a data transfer file. The editor is particularly useful for editing
transfer data during the test, that is, before the data is actually transferred. To access the
editor, choose 7UDQVIHUREMHFW→&KDQJHILOH.
As well as being able to delete and duplicate structures, you can also edit the fields in the
structure, by entering field values, for example. You can often use 3RVVLEOHHQWULHV (F4) in the
editor.
For more information about the editor, see
Editing Blocks
SAP AG 536
ABAP Workbench Delta Guide (3.1-4.6)
([HUFLVH&KDQJHWKH$GGUHVVRIWKH6HFRQG
&XVWRPHU
Select the address of the second customer and change the following information in the initial
file:
1HZDGGUHVV
Street: 2021 Main Street
City: San Francisco
Save the file and return to the initial screen.
6WDUWLQJWKH'DWD7UDQVIHU
The data transfer can now commence using this sample file.
In our example, the DTW calls the actual transfer program for the customer transfer
(RFBIDE00). This program requires a file in the standard SAP record layout. This file is
imported and a batch input session is created using the data records the file contains. The
records then are processed using the batch input monitor.
Start the data transfer on the initial screen by choosing *RWR →6WDUW';SURJUDP. The
transfer file must be on the application server.
6WDUWLQJWKHGDWDWUDQVIHU
Starting the DX program starts the application program that executes the actual transfer
(program RFBIDE00). The system displays the selection screen of this transfer program. You
then create a batch input session. Enter the file path name.
There are two steps involved in creating a batch input session:
1. Test the file to make sure the transfer program can interpret the file structure. To do this
enter the name of the file and choose &KHFN)LOH RQO\. Execute the transfer program to start
the test.
SAP AG 537
ABAP Workbench Delta Guide (3.1-4.6)
7HVWLQJWKHILOH
During the test, the system displays a dialog box informing you of the test progress. The
system will also display some system messages you must confirm.
After the test is finished, the system should display the following dialog box:
'LDORJPHVVDJH
SAP AG 538
ABAP Workbench Delta Guide (3.1-4.6)
'LDORJPHVVDJH
After the session is successfully created, choose %DFN (F3) to return to the initial DTW
screen.
On the initial screen, choose *RWR →%DWFKLQSXWDGPLQ. to go to the batch input monitor to
process the session.
For more information about the batch input monitor, see Batch Input Monitor
$GGLWLRQDO'7:)XQFWLRQV
([SRUWLQJWKH'DWD'HILQLWLRQVLQWR2WKHU
3URJUDPPLQJ/DQJXDJHV
The data definitions in the transfer file as well as the individual structures can be exported into
other programming languages (C, COBOL, PL/1, or P_RPG). This export supports the
creation of a conversion program in the relevant programming language. You do not have to
manually define the data.
)XQFWLRQV
• Data can currently be exported into COBOL, PL/I, C and P_RPG. The program can be
executed in the background, if necessary.
• You can specify whether the generated source description should be saved to a file and
where this file should be stored. The file can be used for the data declaration in the
conversion program.
• You can change the selection options and save these as variants
$FWLYLWLHV
1. On the initial Workbench screen, choose *RWR → 6WUXFWXUHIRUSURJODQJ
2. Select which programming language the data definitions are to be exported into
SAP AG 539
ABAP Workbench Delta Guide (3.1-4.6)
'LVSOD\LQJWKH,QWHUIDFH6WUXFWXUH
To display the structure of the transfer file, choose *RWR → ,QWHUIDFHVWUXFWXUH on the initial
screen. The interface structure provides a technical description of the transfer file and shows
the structures that can be used and the sequence in which they should be used. This
information is required for the conversion of legacy data.
Initial structure
([DPSOHRIDVWUXFWXUHIRUWKH';REMHFW
To display the interface structure from outside the Data Transfer Workbench call program
RSXDAEXP. This allows you to display the structure without the field information, making it
easier to see the order of the structures.
SAP AG 540
ABAP Workbench Delta Guide (3.1-4.6)
,QWHJUDWLQJ8VHU'HILQHG3URJUDPVLQWKH
:RUNEHQFK
You can generate user-defined data transfer programs and integrate them in the Data
Transfer Workbench. This allows you to use the Workbench functions for user-defined
transfer programs.
The transfer program must have been generated using the batch input recorder in
Release 4.5. Transfer programs generated using a recorder in a Release earlier than 4.5A
cannot be integrated.
You create customer programs and integrate them in the Data Transfer Workbench as
follows:
1. Use the batch input recorder to record a transaction
2. Generate the user-defined data transfer program from the recording
3. Create a customer transfer object for this transfer program and integrate it in the Data
Transfer Workbench.
User-defined data transfer programs and customer transfer objects can be deleted. There is a
direct link to the ABAP Dictionary in case you need to maintain structures there.
3URFHGXUH
1. Record the transaction and generate the customer transfer program
2. Start the Data Transfer Workbench using Transaction SXDA
3. Choose *RWR → ,QW&XVWRPHUGDWDWUDQVIHUREMHFW
On the following screen, the system displays the functions available to create your own DX
object.
• Goto the batch input recorder
• Create a data transfer object
• Delete a data transfer object
• Goto the ABAP Dictionary
'7:'DWD7UDQVIHU:RUNEHQFKLQLWLDOVFUHHQ
SAP AG 541
ABAP Workbench Delta Guide (3.1-4.6)
If the data transfer program has not yet been generated, choose %DWFKLQSXWUHFRUGHU to go to
the recorder to create the program.
Once the data transfer program has been generated, you can create a DX object and
integrate it in the Workbench.
On the 7RROVIRU0DLQWDLQLQJ&XVWRPHU2EMHFWV screen, do the following:
1. Choose &UHDWHGDWDWUDQVIHUREMHFW.
On the following screen:
2. Enter a number for the data transfer object within the customer namespace (9000 -
9999).
3. Also enter a short text, the generated data transfer program and a structure name that is
not currently used in the ABAP Dictionary.
The structure is created in the ABAP Dictionary, where it can now be displayed.
4. The data transfer object is now included in the Data Transfer Workbench.
&UHDWH';REMHFW
5HVXOW
The user-defined data transfer program is integrated in the Data Transfer Workbench and can
be used.
,GHQWLI\LQJ5HOHYDQW)LHOGV
Each data transfer object has specific fields that must be filled by the data transfer. Relevant
fields are all required fields in the online transaction that must be filled before saving a
document. As all relevant fields must be filled with data at the time of the data transfer, you
must identify these fields.
From Release 4.5A, this step is supported by a function that automatically records the
relevant F1 help fields. Thus, fields in the transfer file can be automatically identified.
7KH7UDQVDFWLRQ5HFRUGHU%DWFK,QSXW
5HFRUGHU
Use the transaction recorder to record a series of transactions and their screens.
SAP AG 542
ABAP Workbench Delta Guide (3.1-4.6)
In Releases earlier than 4.5A, the recorder is called the batch input recorder.
As of Release 4.5A, the recorder is called the transaction recorder as many new functions
have been added.
5HFRUGLQJWUDQVDFWLRQVHVVLRQV
A batch input recording consists of a sequence of transactions including the screens
processed. A screen (program name, screen name) contains the modified fields (field name,
field value), the executed user command (BDC_OKCODE) and the cursor position
(BDC_CURSOR).
To start recording, go to the batch input initial screen and choose 5HFRUG or call Transaction
SHDB.
The system stores each recording under a name of up to 12 characters you specify. You must
specify this name before starting the recording. The following special characters are not
allowed: , () ' " = Ä Ö Ü ß.
The recording RQO\ records fields that are filled with new values. If certain fields already
contain values and you need to record these fields, you must change the values in those
fields.
5HFRUGLQJ)HDWXUHV5HO
8VHWKHUHFRUGLQJIXQFWLRQWRFUHDWH
• Data transfer programs that use batch input or CALL TRANSACTION
• Batch input sessions
• Test data
• Function modules.
The recording can be executed several times. The screens are called in exactly the same way
as during the recording.
Transaction Recorder
&UHDWLQJD5HFRUGLQJ
SAP AG 543
ABAP Workbench Delta Guide (3.1-4.6)
&UHDWLQJDUHFRUGLQJ
In the subsequent dialog box, enter the name of the transaction you want to record. Then
execute the transaction and enter the required values in the screen fields. The following uses
Transaction FD02 as an example. This transaction is used to change customer master data.
The address for a customer is changed in the example.
'LDORJER[(QWHULQJDWUDQVDFWLRQFRGH
To display the screens required to change the address, choose $GGUHVVon the initial screen.
SAP AG 544
ABAP Workbench Delta Guide (3.1-4.6)
,QLWLDOVFUHHQ
The data is changed on the following screen. The fields whose data you change are included
in the recording.
SAP AG 545
ABAP Workbench Delta Guide (3.1-4.6)
6FUHHQ&KDQJHFXVWRPHUDGGUHVV
After the transaction is finished, the system displays the processed screens (module pool,
screen number), the changed fields (field name, field value), the executed user commands
(BDC_OKCODE). and the cursor position (BDC_CURSOR) in a hierarchical list.
SAP AG 546
ABAP Workbench Delta Guide (3.1-4.6)
+LHUDUFKLFDOUHFRUGLQJOLVW
Choose 1H[WWUDQVDF if you want to record another transaction session using a different
transaction.
After recording all desired transactions, save the recording and exit the recording
8VLQJWKH5HFRUGLQJ
8VHWKHUHFRUGLQJWR
• Execute a session directly
• Create a batch input session
• Generate a batch input program
• Create test files
• Generate function modules
Before you can generate a data transfer program, you must record the transactions using the
data to be imported into the R/3 System. You use the transaction recorder to do this.
Using an existing recording, you can start a new recording or create a batch input session, a
data transfer program, test data, or a function module for data transfer:
SAP AG 547
ABAP Workbench Delta Guide (3.1-4.6)
5HFRUGLQJ2YHUYLHZ
([HFXWLQJWKH5HFRUGLQJ
*HQHUDWLQJ%DWFK,QSXW6HVVLRQV)URPWKH
5HFRUGLQJ
The data from the recording is transferred into batch input sessions you can process for test
purposes using the usual mechanisms.
1. The system displays an overview of all recordings.
2. Position the cursor on the relevant recording and then choose *HQHUDWHVHVVLRQ.
3. Enter a session name, a user with whose authorizations the session is to be processed,
and the processing date. You must also specify whether the session is to be deleted once
it has been processed.
4. Choose &RQWLQXH to exit the dialog box.
SAP AG 548
ABAP Workbench Delta Guide (3.1-4.6)
5HVXOW
You have generated a batch input session that uses the same data for the input fields that
you entered when you created the recording. You can now process this as usual.
&UHDWLQJD3URJUDPIURPWKH5HFRUGLQJ
SAP AG 549
ABAP Workbench Delta Guide (3.1-4.6)
6HOHFWLRQVFUHHQRIWKHGDWDWUDQVIHUSURJUDP
&UHDWLQJ7HVW)LOHV
To test the data transfer program you have created, create a data record in a sequential file.
This data record contains all the field contents from the recording relevant to the data transfer,
in the format required by the data transfer program. It is therefore useful if the format of your
conversion program data file is identical to the format of the test file.
1. Position the cursor on the relevant recording and choose &UHDWHWHVWGDWD
2. Enter a test file
3. Choose &RQWLQXH to exit the dialog box
You have now created a test file.
• If the test file you have specified already exists, the system appends the new data record.
• If you do not specify the path, the system archives the test file in the working directory of
the current application server.
*HQHUDWLQJ)XQFWLRQ0RGXOHV
3URFHGXUH
1. Position the cursor on the relevant recording and choose &UHDWHIXQFWLRQPRGXOH
2. On the subsequent dialog box, enter a function module name, a function group and a
short text for the function module
3. Choose &RQWLQXHto exit the dialog box
The system automatically creates the function module.
5HVXOW
SAP AG 550
ABAP Workbench Delta Guide (3.1-4.6)
You have now generated a function module you can use as an interface for your R/3 System.
The function module’s import interface contains a parameter for each input field of the
recorded transaction as well as information relevant for the data transfer.
For more information, see
create Function Module
using Function Module
6SHFLDO)HDWXUHV
SAP AG 551