abap objects - aws · pdf filebonn boston horst keller, sascha krüger abap® objects...

120
Bonn Boston Horst Keller, Sascha Krüger ABAP ® Objects ABAP Programming in SAP NetWeaver™

Upload: phungliem

Post on 12-Mar-2018

310 views

Category:

Documents


19 download

TRANSCRIPT

Page 1: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Bonn � Boston

Horst Keller, Sascha Krüger

ABAP® ObjectsABAP Programming in SAP NetWeaver™

Page 2: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents at a Glance

1 Introduction .................................................. 23

2 A Practical Introduction to ABAP ................. 53

3 Basic Principles of ABAP ............................... 141

4 Classes and Objects ...................................... 177

5 Basic ABAP Language Elements ................... 225

6 Advanced Concepts in ABAP Objects ........... 341

7 Classic ABAP—Events and Procedures ......... 449

8 Error Handling .............................................. 479

9 GUI Programming with ABAP ....................... 513

10 Working with Persistent Data ..................... 705

11 Dynamic Programming ................................. 795

12 External Interfaces ........................................ 841

13 Testing and Analysis Tools ........................... 939

Page 3: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

7

Contents

Foreword ...................................................................................... 19

1 Introduction ............................................................. 23

1.1 What Is ABAP? ........................................................... 231.1.1 The Evolution of ABAP ................................... 231.1.2 Scope of ABAP ............................................... 251.1.3 ABAP Development Environment ................... 261.1.4 ABAP Programming Model ............................ 261.1.5 ABAP and SAP NetWeaver ............................. 291.1.6 ABAP or Java? ................................................ 301.1.7 ABAP and Java! .............................................. 31

1.2 The Objective of This Book ......................................... 401.2.1 Target Audience ............................................. 401.2.2 Structure of this Book .................................... 411.2.3 Observing Programming Guidelines ................ 461.2.4 Syntax Conventions ........................................ 47

1.3 How Can I Use This Book on a Practical Level? ........... 481.3.1 Creating the Examples .................................... 481.3.2 Goal of the Examples ..................................... 491.3.3 Using the Examples ........................................ 491.3.4 Releases Described ......................................... 501.3.5 Database Tables Used .................................... 50

2 A Practical Introduction to ABAP ............................ 53

2.1 Functionality of the Sample Application ...................... 542.2 Getting Started with the ABAP Workbench ................. 54

2.2.1 Entry through SAP Easy Access ....................... 552.2.2 The Object Navigator ..................................... 57

2.3 Packages ..................................................................... 602.3.1 Package for Local Development Objects ......... 612.3.2 Packages for Transportable Develop-

ment Objects ................................................. 622.3.3 Creating a Package ......................................... 632.3.4 Calling the Transport Organizer ...................... 67

2.4 Database Tables .......................................................... 682.4.1 Creating a Customer Table ............................. 682.4.2 Creating a Data Element ................................ 72

Page 4: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

8

2.4.3 Creating a Domain ........................................ 752.4.4 Completing the Customer Table .................... 762.4.5 Creating a Search Help .................................. 782.4.6 Creating the Rental Car Table ........................ 782.4.7 Creating the Reservations Table ..................... 81

2.5 Creating an ABAP Program ........................................ 822.5.1 Creating an Auxiliary Program ....................... 822.5.2 ABAP Syntax ................................................. 842.5.3 General Program Structure ............................ 862.5.4 Two “Hello World” Programs ........................ 882.5.5 Copying Programs ......................................... 91

2.6 Implementing the Auxiliary Program .......................... 912.6.1 Source Code for the Auxiliary Program .......... 922.6.2 Chained Statements ...................................... 942.6.3 Data Declarations .......................................... 942.6.4 Assigning Values to Data Objects .................. 952.6.5 Database Accesses ......................................... 952.6.6 Exception Handling ....................................... 962.6.7 Testing the Auxiliary Program using

the ABAP Debugger ...................................... 962.6.8 Result of the Auxiliary Program in the

Data Browser ................................................ 982.7 User Dialog ................................................................ 99

2.7.1 Using a Function Group ................................. 1002.7.2 Top Include of the Function Group ................ 1012.7.3 Creating Function Modules ........................... 1052.7.4 Testing Function Modules ............................. 108

2.8 Application Logic ....................................................... 1102.8.1 Exception Classes .......................................... 1112.8.2 Creating a Class for Reservations ................... 1122.8.3 Creating a Class for Customer Objects ........... 1202.8.4 Application Program ...................................... 1262.8.5 Creating a Transaction Code .......................... 1292.8.6 Executing the Transaction .............................. 1312.8.7 Reporting ...................................................... 133

2.9 Summary ................................................................... 1352.10 Using the Keyword Documentation ........................... 136

3 Basic Principles of ABAP .......................................... 141

3.1 ABAP and SAP NetWeaver ......................................... 1413.1.1 SAP NetWeaver ............................................. 141

Page 5: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

9

3.1.2 The Application Server ................................... 1423.1.3 The Application Server ABAP ......................... 1433.1.4 The ABAP Runtime Environment .................... 1503.1.5 The Text Environment .................................... 151

3.2 ABAP Program Organization and Properties ................ 1523.2.1 ABAP Program Design .................................... 1523.2.2 ABAP Program Execution ............................... 1553.2.3 ABAP Program Calls ....................................... 1563.2.4 ABAP Program Types ..................................... 1593.2.5 Other Program Attributes ............................... 1623.2.6 Processing Blocks ........................................... 164

3.3 Source Code Organization .......................................... 1673.3.1 Include Programs ........................................... 1673.3.2 Macros ........................................................... 170

3.4 Software and Memory Organization of AS ABAP ......... 1713.4.1 AS ABAP as a System ..................................... 1713.4.2 Application Server .......................................... 1713.4.3 User Session ................................................... 1743.4.4 Main Session .................................................. 1743.4.5 Internal Session .............................................. 175

4 Classes and Objects ................................................. 177

4.1 Object Orientation ..................................................... 1774.2 Object-Oriented Programming in ABAP ...................... 1804.3 Classes ........................................................................ 182

4.3.1 Global and Local Classes ................................ 1824.3.2 Creating Classes ............................................. 183

4.4 Attributes and Methods .............................................. 1914.4.1 Instance Components and

Static Components ......................................... 1914.4.2 Attributes ...................................................... 1924.4.3 Methods ........................................................ 1944.4.4 Using Static Components ............................... 1974.4.5 Editor Mode of the Class Builder .................... 199

4.5 Data Types as Components of Classes ......................... 2004.6 Objects and Object References ................................... 202

4.6.1 Creating and Referencing Objects .................. 2024.6.2 The Self-Reference “me” ................................ 2054.6.3 Assigning References ...................................... 2054.6.4 Multiple Instantiation .................................... 207

Page 6: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

10

4.6.5 Object Creation in a Factory Method ............. 2094.6.6 Garbage Collection ........................................ 212

4.7 Constructors .............................................................. 2134.7.1 Instance Constructor ..................................... 2144.7.2 Static Constructor .......................................... 2164.7.3 Destructors ................................................... 219

4.8 Local Declarations of a Class Pool .............................. 2194.8.1 Local Types in Class Pools .............................. 2204.8.2 Local Classes in Class Pools ............................ 220

4.9 Using ABAP Objects on the AS ABAP ......................... 2214.10 Summary and Perspective .......................................... 224

5 Basic ABAP Language Elements ............................... 225

5.1 Data Types and Data Objects ..................................... 2255.1.1 Data Objects ................................................. 2255.1.2 Data Types .................................................... 2295.1.3 Elementary Data Types and Data Objects ...... 2365.1.4 Structured Data Types and Data Objects ....... 2445.1.5 Table Types and Internal Tables ..................... 2485.1.6 Reference Types and Reference Variables ...... 2495.1.7 Data Types in the ABAP Dictionary ................ 2505.1.8 Flat and Deep Data Types ............................. 2615.1.9 Generic Data Types ....................................... 2635.1.10 Further Details in Data Objects ..................... 265

5.2 Operations and Expressions ....................................... 2735.2.1 Assignments .................................................. 2735.2.2 Type Conversions .......................................... 2745.2.3 Special Assignments ...................................... 2825.2.4 Calculations ................................................... 2865.2.5 Logical Expressions ........................................ 292

5.3 Control Structures ...................................................... 2985.3.1 Conditional Branches ..................................... 2985.3.2 Loops ............................................................ 301

5.4 Processing Character and Byte Strings ........................ 3035.4.1 Operations with Character Strings ................. 3055.4.2 Find and Replace ........................................... 3065.4.3 Subfield Access .............................................. 3135.4.4 Functions for Character String Processing ...... 3155.4.5 Relational Operators for Character

String Processing ........................................... 316

Page 7: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

11

5.5 Internal Tables ............................................................ 3185.5.1 Attributes of Internal Tables ........................... 3195.5.2 Working with Internal Tables ......................... 326

6 Advanced Concepts in ABAP Objects ...................... 341

6.1 Method Interfaces and Method Calls .......................... 3456.1.1 Parameter Interfaces of Methods ................... 3456.1.2 Method Calls ................................................. 355

6.2 Inheritance ................................................................. 3596.2.1 Basic Principles .............................................. 3596.2.2 Creating Subclasses ........................................ 3626.2.3 Visibility Sections and Namespaces in

Inheritance ..................................................... 3646.2.4 Method Redefinition ...................................... 3666.2.5 Abstract Classes and Methods ........................ 3706.2.6 Final Classes and Methods ............................. 3726.2.7 Static Attributes in Inheritance ....................... 3736.2.8 Constructors in Inheritance ............................ 3746.2.9 Instantiation in Inheritance ............................ 380

6.3 Standalone Interfaces ................................................. 3816.3.1 Basic Principles .............................................. 3826.3.2 Creating Interfaces ......................................... 3846.3.3 Implementing Interfaces in Classes ................. 3866.3.4 Access to Interfaces of Objects ....................... 3896.3.5 Access to Static Interface Components ........... 3946.3.6 Composing Interfaces ..................................... 3946.3.7 Alias Names for Interface Components ........... 3976.3.8 Interfaces and Inheritance .............................. 400

6.4 Object References and Polymorphism ......................... 4026.4.1 Static and Dynamic Type ................................ 4026.4.2 Assignments Between Reference Variables ..... 4056.4.3 Polymorphism ................................................ 413

6.5 Events and Event Handling ......................................... 4226.5.1 Declaring Events ............................................ 4246.5.2 Triggering Events ........................................... 4266.5.3 Event Handlers ............................................... 4286.5.4 Registering Event Handlers ............................. 431

6.6 Shared Objects ........................................................... 4336.6.1 Basics—Areas and Co. .................................... 4356.6.2 Accessing Shared Objects ............................... 4366.6.3 Creating an Area ............................................ 437

Page 8: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

12

6.6.4 Locking ......................................................... 4406.6.5 Working with Shared Objects ........................ 4416.6.6 Managing Shared Objects .............................. 447

7 Classic ABAP—Events and Procedures .................... 449

7.1 Event-Oriented Program Execution ............................ 4517.1.1 Executable Programs ..................................... 4517.1.2 Dialog Transactions ....................................... 4577.1.3 Comparison Between Different Types

of Classic Program Execution ......................... 4597.2 Procedural Modularization ......................................... 460

7.2.1 Function Modules ......................................... 4617.2.2 Subroutines ................................................... 474

8 Error Handling .......................................................... 479

8.1 Robust Programs ........................................................ 4798.1.1 Defensive Programming ................................ 4798.1.2 Exception Situations ...................................... 480

8.2 Exception Handling .................................................... 4818.2.1 Class-Based Exception Handling .................... 4818.2.2 Classic Exception Handling ............................ 5008.2.3 Messages in Exception Handling .................... 5038.2.4 Combining Class-Based Exception

Handling and Earlier Concepts ....................... 5058.2.5 Runtime Errors .............................................. 508

8.3 Assertions .................................................................. 5088.3.1 Advantages of Assertions ............................... 5098.3.2 Using Assertions ............................................ 509

9 GUI Programming with ABAP .................................. 513

9.1 General Dynpros ........................................................ 5159.1.1 Screen ........................................................... 5159.1.2 Dynpro Flow Logic ........................................ 5179.1.3 Dynpros and ABAP programs ........................ 5189.1.4 Dynpro Sequences and Dynpro Calls ............. 5199.1.5 Creating Dynpros .......................................... 5249.1.6 Dynpro Fields ................................................ 5309.1.7 Function Codes and Functions ....................... 5349.1.8 Context Menus .............................................. 539

Page 9: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

13

9.1.9 Dialog Modules ............................................. 5419.1.10 Data Transport ............................................... 5439.1.11 Conditional Module Calls ............................... 5449.1.12 Input Check ................................................... 5459.1.13 Field Help ...................................................... 5489.1.14 Input Help ..................................................... 5499.1.15 Dynpros and Classes ....................................... 5559.1.16 Dynpro Controls ............................................. 5739.1.17 GUI Controls .................................................. 587

9.2 Selection Screens ........................................................ 6159.2.1 Creating Selection Screens ............................. 6179.2.2 Parameters ..................................................... 6189.2.3 Selection Criteria ............................................ 6229.2.4 Additional Elements on Selection Screens ...... 6279.2.5 Calling Selection Screens ................................ 6309.2.6 Selection Screen Processing ............................ 6319.2.7 Functions of Selection Screens ....................... 6349.2.8 Standard Selection Screens ............................. 6389.2.9 Selection Screens as Program Interfaces ......... 640

9.3 Classical Lists .............................................................. 6459.3.1 List Creation ................................................... 6459.3.2 Screen List ..................................................... 6469.3.3 Lists in Executable Programs .......................... 6479.3.4 Lists and Transactions .................................... 6489.3.5 Functions on Lists .......................................... 6519.3.6 Print Lists ....................................................... 6549.3.7 Lists in ABAP Objects ..................................... 658

9.4 Messages .................................................................... 6669.4.1 Creating Messages ......................................... 6669.4.2 Sending messages .......................................... 6679.4.3 Message Type ................................................ 6689.4.4 Use of Messages ............................................ 670

9.5 Web Dynpro ABAP ..................................................... 6719.5.1 First Steps with Web Dynpro ABAP ................ 6739.5.2 Query with Web Dynpro ABAP ...................... 6819.5.3 Summary ........................................................ 702

10 Working with Persistent Data ................................. 705

10.1 Database Accesses ...................................................... 70610.1.1 Definition of Database Tables in the

ABAP Dictionary ............................................ 707

Page 10: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

14

10.1.2 Open SQL ..................................................... 71010.1.3 Consistent Data Storage ................................ 74110.1.4 Special Sections Relating to

Database Accesses ......................................... 75110.2 Database Access with Object Services ........................ 757

10.2.1 Creating Persistent Classes ............................. 75710.2.2 Managing Persistent Objects ......................... 76010.2.3 GUID Object Identity .................................... 77010.2.4 Transaction Service ........................................ 771

10.3 File Interfaces ............................................................ 77510.3.1 Files of the Application Server ....................... 77610.3.2 Files of the Presentation Server ..................... 781

10.4 Data Clusters ............................................................. 78410.4.1 Storing Data Clusters ..................................... 78510.4.2 Reading Data Clusters ................................... 78610.4.3 Deleting Data Clusters ................................... 78710.4.4 Example for Data Clusters .............................. 787

10.5 Authorization Checks ................................................. 78910.5.1 Authorization Objects and Authorizations ..... 79010.5.2 Authorization Check ...................................... 791

11 Dynamic Programming ............................................. 795

11.1 Field Symbols and Data References ............................ 79611.1.1 Field Symbols ................................................ 79711.1.2 Data References ............................................ 809

11.2 Run Time Type Services (RTTS) ................................... 81911.2.1 Run Time Type Information (RTTI) ................. 82011.2.2 Run Time Type Creation (RTTC) ..................... 824

11.3 Dynamic Token Specifications .................................... 82911.3.1 Dynamic Specifications of Operands .............. 83011.3.2 Dynamic Specifications of Clauses ................. 83011.3.3 Special Dynamic Specifications of Clauses ...... 831

11.4 Dynamic Procedure Call ............................................. 83211.4.1 Dynamic Method Call .................................... 83211.4.2 Dynamic Function Module Call ..................... 835

11.5 Program Generation ................................................... 83611.5.1 Transient Program Generation ....................... 83711.5.2 Persistent Program Generation ...................... 840

Page 11: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

15

12 External Interfaces ................................................... 841

12.1 Synchronous and Asynchronous Communication ........ 84212.1.1 Synchronous Communication ......................... 84312.1.2 Asynchronous Communication ....................... 843

12.2 Remote Function Call (RFC) ........................................ 84512.2.1 RFC Variants .................................................. 84512.2.2 RFC Communication Scenarios ....................... 84912.2.3 RFC Programming on AS ABAP ...................... 85312.2.4 RFC Programming of an

External RFC Interface .................................... 86212.2.5 RFC Programming with JCo ............................ 869

12.3 Internet Communication Framework (ICF) .................. 87712.3.1 ICF in AS ABAP .............................................. 87812.3.2 ICF Server Programming ................................. 87912.3.3 ICF Client Programming ................................. 886

12.4 ABAP Web Services .................................................... 89012.4.1 What Is a Web Service? .................................. 89112.4.2 Web Services and Enterprise SOA .................. 89212.4.3 Standards for Web Services ............................ 89312.4.4 Web Services for AS ABAP ............................. 89412.4.5 Role of the Exchange Infrastructure ................ 89512.4.6 Web Service Framework ................................. 89712.4.7 Creating a Web Service .................................. 89812.4.8 Releasing a Web Service ................................. 90012.4.9 Testing a Web Service .................................... 90212.4.10 Publishing a Web Service ............................... 90412.4.11 Creating a Client for Web Services .................. 905

12.5 ABAP and XML ........................................................... 90812.5.1 What Is XML? ................................................ 90912.5.2 The iXML Library ........................................... 91312.5.3 Using XSLT ..................................................... 91812.5.4 Use of Simple Transformations ....................... 92612.5.5 Summary ........................................................ 937

13 Testing and Analysis Tools ....................................... 939

13.1 Static Testing Procedures ............................................ 94113.1.1 Syntax Check .................................................. 94113.1.2 Extended Program Check ............................... 94213.1.3 Code Inspector ............................................... 945

Page 12: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

16

13.2 Program Analysis with the ABAP Debugger ................ 95013.2.1 The New ABAP Debugger with

Two-Process Architecture .............................. 95113.2.2 User Interface of the ABAP Debugger ............ 95213.2.3 Using the Debugger ...................................... 955

13.3 Module Tests with ABAP Unit .................................... 96113.3.1 What Is a Module Test? ................................. 96213.3.2 Organization of ABAP Unit ............................ 96313.3.3 Sample Use of ABAP Unit .............................. 96413.3.4 Execution and Analysis of a Test Run ............. 96913.3.5 ABAP Unit in Code Inspector ........................ 970

13.4 ABAP Memory Inspector ............................................ 97113.4.1 Dynamic Memory Objects ............................. 97213.4.2 Creating Memory Snapshots .......................... 97513.4.3 Working with the Memory Inspector ............. 977

13.5 ABAP Runtime Analysis .............................................. 98013.5.1 Calling the Runtime Analysis ......................... 98113.5.2 Evaluating the Performance Data Files ........... 98213.5.3 Tips & Tricks .................................................. 984

13.6 Additional Testing Tools ............................................ 98413.6.1 Coverage Analyzer ......................................... 98413.6.2 Extended Computer-Aided Test Tool

(eCATT) ......................................................... 986

A Appendix ................................................................ 989

A.1 Overview of all ABAP Statements ............................. 989A.1.1 Statements Introducing a Program ............... 989A.1.2 Modularization Statements .......................... 989A.1.3 Declarative Statements ................................ 990A.1.4 Object Creation ........................................... 991A.1.5 Calling and Exiting Program Units ................ 991A.1.6 Program Flow Control ................................. 992A.1.7 Assignments ................................................ 993A.1.8 Processing Internal Data .............................. 993A.1.9 User Dialogs ................................................ 995A.1.10 Processing External Data ............................. 997A.1.11 Program Parameters .................................... 998A.1.12 Program Processing ..................................... 999A.1.13 ABAP Data and Communication

Interfaces .................................................... 1000A.1.14 Enhancements ............................................. 1000

Page 13: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

Contents

17

A.2 ABAP System Fields ................................................. 1001A.3 ABAP Program Types ............................................... 1006A.4 ABAP Naming Conventions ...................................... 1007A.5 Selectors .................................................................. 1008A.6 Auxiliary Class for Simple Text Outputs .................... 1009A.7 References on the Web ............................................ 1012A.8 Installing and Using the SAP NetWeaver

2004s ABAP Trial Version ........................................ 1012

Authors ..................................................................................... 1015

Index ......................................................................................... 1019

Page 14: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

19

Foreword

This book is the sequel to ABAP Objects: An Introduction to Program-ming SAP Applications from the SAP PRESS series. Instead of produc-ing a reworked second edition of the Introduction, we have writtena new book that is based, in part, on the manuscript for the previousbook.

The earlier book was the first ABAP book in the SAP PRESS seriesand was intended to serve both as an introduction to ABAP Objectsas well as a general overview of the ABAP language and SAP Basis.Since then, however, SAP PRESS has published dedicated introduc-tion and practice books, as well as a comprehensive ABAP referencebook, which is complemented by an ABAP quick reference guide toprovide a quick overview. This has allowed us to take a new direc-tion in the current book. This book is much less of a reference guidethan its predecessor. Instead, it is intended to function as the pro-gramming handbook in the series of ABAP books that have previ-ously appeared at SAP PRESS, grouped between introductory practi-cal books and ABAP reference guides.

In this book, we are therefore offering our readers a compendium ofmodern ABAP programming and of the key possibilities of the ABAPApplication Server in SAP NetWeaver. Modern ABAP programmingmeans programming with ABAP Objects. Contrary to the previousbook, ABAP Objects are no longer treated as an addition to classicalABAP, but rather as the underlying programming model. Consistentwith all books on object-oriented programming languages, the pres-entation of the ABAP language in Chapter 4 begins this time with“Classes and Objects.” From the start, we have integrated thedescription of the Class Builder into the description of classes andobjects. All remaining language elements and tools have been pre-sented in the same way that they are used in ABAP Objects to imple-ment classes. The classical concepts of ABAP are mentioned wherethey are still used. We no longer discuss obsolete concepts; and if wedo, we only touch on them very briefly.

Page 15: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

20

Foreword

Whereas in the previous book, we dealt mainly with elementaryABAP language topics, in this book we have also included—in addi-tion to the many new developments that the ABAP language has seenin the meantime—additional topics that are essential for the pro-gramming of the ABAP Application Server in SAP NetWeaver. Infact, we devote an entire chapter to the error handling reaching fromexception classes to assertions, offer an introduction to Web Dynprofor ABAP, provide a separate chapter on dynamic programmingincluding Run Time Type Creation, and a chapter on the externalcommunication and data interfaces from RFC over ICF to XML, andalso provide an overview of all possible tools to use for testing qual-ity assurance.

Because of the large number of new topics, the scope of this book hasnow passed the magical 1000-page milestone. Therefore, we will atleast try to keep the foreword brief, albeit without neglecting toextend our thanks to all of the people who have helped, directly orindirectly, to produce this book.

First we must mention our colleagues in the department “SAPNetWeaver Foundation ABAP.” While this organizational unit had adifferent name in all of the other books that have appeared to date, itis essentially still the “ABAP Language” group, which develops theABAP language and the ABAP tools, and which now also encom-passes the groups “ABAP Workbench” and “ABAP Connectivity.”This group’s work is the foundation of everything that is described inthis book, and we do not exaggerate when we say that the output ofthis group is the basis of any ABAP developments internationally. Inappreciation of all of this team’s members, we would here again liketo thank the Vice President Andreas Blumenthal, who has supportedthis book from the very beginning and provided the necessaryresources to make it become a reality.

We would specifically like to thank the following colleagues whohave made special contributions to producing this book: Kai Baum-garten (information and corrections on Shared Objects), ThomasBecker (information on qRFC), Joachim Bender and Michael Schmitt(proofreading of the section on Web Services), Dirk Feeken andManfred Lutz (publication of the AS ABAP Trial Version on DVD),Eva Pflug (help in setting up the AS ABAP trial version as a transla-tion system, to ensure that the examples also work when users log

Page 16: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

21

Foreword

on in English), Susanne Rothaug and Volker Wichers (support withtesting the ABAP Web Services on another J2EE Server), Klaus-DieterScherer (help and information on ALV print lists), Stefan Seemann(hooked the MaxDB that failed when we tried to install a parallelJ2EE Server backup to the AS ABAP trial version), Markus Tolksdorf(information and corrections on JCo), and Doris Vielsack (informa-tion and corrections on dynpros).

As a further new feature, this issue of the ABAP Objects book is alsobased on texts from authors who are responsible for one particularcontribution: Stefan Bresch (object services), Rupert Hieble (XML),Anne Lanfermann (Web Services), Frank Müller (RFC and ICF), andStefanie Rohland (Web Dynpro). We would like to thank theseauthors for their readiness to assist with this project, in addition totheir normal responsibilities. The authors’ bios are provided at theend of this book.

We would like to thank the publishers at Galileo Press for their col-laboration, which was, as always, excellent. Alexandra Müller andFlorian Zimniak did an outstanding job correcting and editing themanuscript, even going so far as to find formal errors in the code.For the production, we would like to thank Iris Warkus (GalileoPress) and Dirk Hemke (SatzPro), most especially for the fact thatright from the first typesetting for this book, we found nothing ofnote to grumble about. For the English edition, the authors want toexpress their gratitude to Nancy Etscovitz from Wellesley Informa-tion Services, who did a terrific job in editing the translation, and toSnezhina Gileva from SAP Labs Sofia for proof reading the final man-uscript.

Sascha Krüger would especially like to thank his wife Katja for somany things too numerous to mention, both big and small, such askeeping him free from any “distractions,” loads of understanding,constant encouragement and motivation, lots of free space, morethan a little coffee, and so much more. In this way, she ultimatelyplayed a large part in the production of his share of the manuscript.

Horst Keller would like to thank his wife Ute, as always, who againsupported the creation of this book with her considerable patienceand understanding. Despite the promises made after every previousbook—that next time things would be easier—this book, in particu-lar, again proved that such promises cannot always be kept, and con-

Page 17: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

22

Foreword

sequently much joint free time during the first half of 2006 had to besacrificed. The fact that Ute never once questioned this project, butjust looked forward with Horst to meeting the deadline, proved to beinvaluable.

Walldorf, February 2007Horst KellerSascha Krüger

Page 18: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

341

A physician, a civil engineer, and a computer scientist were arguing about what was the oldest profession in the world. The physician remarked, “Well, in the Bible, it says that God created Eve from a rib taken out of Adam. This clearly required surgery, and so I can rightly claim that mine is the oldest profession in the world.” The civil engineer interrupted and said, “But even earlier in the book of Genesis, it states that God created the order of the heavens and the earth from out of the chaos. This was the first and certainly the most spectacular application of civil engineering. Therefore, fair doctor, you are wrong; mine is the oldest profession in the world.” The computer scientist leaned back in her chair, smiled, and then said confidently, “Ah, but who do you think created the chaos?”—Grady Booch, Object-Oriented Analysis and Design with Applications

6 Advanced Concepts in ABAP Objects

The above quotation is from a book entitled Object-Oriented Analysisand Design with Applications by Grady Booch (Addison-Wesley1995), where it is used to introduce a chapter discussing “the inher-ent complexity of software.” One advantage of the object-orientedapproach is its ability to handle complexity. In Chapter 4, you wereintroduced to classes and objects as a basis for object orientation, andto attributes and methods as underlying components of these classesand objects. We can sum up what you have already learned as fol-lows:

Basic principles� Objects constitute the key concept in object-oriented program-ming. An object is a self-contained unit whose status is deter-mined by the values of its attributes, whose behavior is deter-mined by its methods, and whose identity is defined by its addressin the memory. An object is accessed by reference variables,

Page 19: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

342

Advanced Concepts in ABAP Objects6

which refer to this address. An object in a program that performsa certain task should reflect a real object of the task 1:1 as far aspossible. With objects, a clear distinction can be made betweenthe public interface and the private and protected components,which are not externally visible. One object can interact withanother by accessing its attributes directly in a method, callingmethods, or triggering an event (see Section 6.5.2).

� Classes consist of source code containing the definition of possibleobjects. An object is always an instance of a class, which isaddressed by at least one reference variable. All components andproperties of its objects are declared in a class. The basis for encap-sulation in ABAP Objects is always the class, rather than theobject.1 Classes are either global for all programs or local in a sin-gle program. They can be specialized by inheritance (see Section6.2), and can incorporate standalone interfaces as a public inter-face (see Section 6.3).

� Attributes describe the status of an object. Technically speaking,attributes (instance attributes) are the local variables of an object,which cannot normally be changed directly from the outside. Aclass may also contain static attributes, which are jointly used byall objects of the class. Static attributes may be variables or con-stants.

� Methods allow objects to perform operations. A method (instancemethod) always works in a specific object. In other words, it readsand changes the status of this object, and interacts with otherobjects by calling their methods or by triggering events. A methodhas a parameter interface (see Section 6.1.1), and can pass onexceptions (see Section 8.2). A class may also contain static meth-ods, which only access static attributes, and can only trigger staticevents.

You may have already realized how powerful these components ofABAP Objects can be when used to program application programs;however, there is more to ABAP Objects than just these basic ele-ments. In this chapter, you’ll become familiar with additional con-cepts that are essential for advanced object-oriented design.

1 The private components of an object of a class are visible to another object of thesame class.

Page 20: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

343

Advanced Concepts in ABAP Objects 6

Advanced concepts� Method Interfaces and Method CallsChapter 4 introduced methods in their fundamental role as theoperational components of classes. Section 6.1.1 examines theparameter interface of methods in more detail, and focuses in par-ticular on the various options with method calls.

� Specialization by InheritanceABAP Objects supports simple inheritance, whereby a class can bedeclared as the direct subclass of exactly one superclass. All classesof ABAP Objects are part of an inheritance hierarchy tree originat-ing in one common superclass. In addition to its own compo-nents, a subclass also contains the components of its superclass.The implementation of superclass methods can be overwritten insubclasses. The concept of inheritance is discussed in Section 6.2.

� Standalone InterfacesThe public visibility section of a class is its external interface.ABAP Objects allows you to create standalone interfaces, whichcan be used by classes as part of their interface, or even as theircomplete interface. Objects belonging to various classes that usethe same interface can be handled by outside users in the sameway. An standalone interface may also comprise several otherinterfaces. The interface concept is described in Section 6.3.

� Object Reference Variables and PolymorphismObjects in a program can only be accessed by object references inobject reference variables. The type of the object reference varia-bles determines exactly what a program can do with an object.There are both class reference variables and interface referencevariables. The latter enable exclusive access to the interface com-ponents of a class. The concepts of inheritance and independentinterfaces allow you to assign object references between referencevariables of different types according to certain rules. This opensup the possibilities of polymorphism, whereby the same referencevariable can be used to access objects belonging to differentclasses with different behavior. This is discussed in Section 6.4.

� Events and Event HandlingA method of an object is normally executed after a direct call. Inthis case, the calling object and the called object are closely cou-pled. Events are used to decouple the caller from the calledmethod. In ABAP Objects, events, like attributes and methods, arecomponent type of classes. An object can trigger an event in a

Page 21: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

344

Advanced Concepts in ABAP Objects6

method, and methods of other objects can handle this event. Thiscorresponds to an indirect method call because the calling methoddoes not need to know anything about the possible event han-dlers. The event concept is described in Section 6.5.

� Shared ObjectsObjects as instances of classes exist in the memory area of a pro-gram, and are deleted at the latest when the program is exited. Asa result, cross-program access to objects is not generally possible.However, ABAP Objects enables cross-program access with sharedobjects, which are objects in the shared memory of an applicationserver. The concept of shared objects is discussed in Section 6.6.

The basic concepts of ABAP Objects, which were introduced in Chap-ter 4 (i. e., classes with attributes and methods, objects, and objectreferences), are used in almost all object-oriented programming lan-guages. The advanced concepts introduced in this chapter comprise,on the one hand, a selection of tried and tested advanced techniquesadopted by ABAP Objects based on the standards of well-knownobject-oriented programming languages like Java or C++, and, on theother hand, specialized techniques that are unique to ABAP Objects.When this language was designed, special care was taken to ensurethat the focus on business applications was not lost.

ASAP principle Certain concepts of object-oriented programming, such as multipleinheritance, which is used in C++, for example, would have servedonly to increase the complexity of the language, without offering anyadditional benefits for SAP applications. In accordance with theASAP principle, of “As Simple As Possible,” ABAP Objects was madeas easy to understand as possible, and only well-established object-oriented concepts were used. Following the example of Java, theinterface concept was introduced in place of multiple inheritance.The correct application of inheritance and interfaces represents thecrowning achievement of object-oriented programming, and pro-vides a range of options for managing complexity.2

The range of options for defining a parameter interface for methodsis, in contrast, specific to ABAP. Similarly, the concept of fully inte-

2 However, we do not wish to conceal the fact that the incorrect use of concepts likeinheritance may cause major problems. Meticulous object-oriented modeling isessential, particularly when advanced concepts of object orientation are used tomanage complex applications.

Page 22: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

345

Method Interfaces and Method Calls 6.1

grating events into the language scope of ABAP Objects as independ-ent components of classes is not a feature of all object-oriented pro-gramming languages.

6.1 Method Interfaces and Method Calls

We have defined and called methods on many occasions in the pre-vious chapters. The next two sections discuss the finer points ofmethods in ABAP Objects.

6.1.1 Parameter Interfaces of Methods

The parameter interface of a method is defined by the additions tothe METHODS and CLASS-METHODS statements when the method isdeclared, or by the selection of Parameters in the Class Builder. Nofurther details of the parameter interface are required in the imple-mentation section between METHOD and ENDMETHOD. However, you candisplay the interface during implementation of global classes.

Formal parametersThe parameter interface of a method comprises formal parametersand exceptions. The declaration of exceptions is discussed in Section8.2. Formal parameters are keyword parameters, to which an actualparameter can or must be assigned when the method is called.Within a method, formal parameters can be used via their names inoperand positions. The possible usage kinds depend on the parame-ter properties. The following properties can be defined for a formalparameter:

� The parameter type

� Kind of parameter passing

� Parameter typing

� Supply type of the parameter

In principle, a parameter interface can contain any number of param-eters; however, a small number is recommended. An ideal parameterinterface contains only a small number of input parameters or noneat all, and a return value.

No overloadingAt this point, we should point out that methods in ABAP Objects can-not be overloaded. In other words, you cannot use the same method

Page 23: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

346

Advanced Concepts in ABAP Objects6

names with different parameter interfaces, even when you redefinemethods in subclasses.

Parameter Type

You can define the following parameters:

� Input ParametersInput parameters are specified after the IMPORTING addition to theMETHODS or CLASS-METHODS statement, or are declared by selectingImporting in the Type column on the Parameters tab page in theClass Builder. When a method is called, the value of the assignedactual parameter is assigned to the input parameter. Input param-eters for which pass by reference is defined cannot be overwrittenin the method. Input parameters for which pass by value isdefined are not passed to the actual parameter when the proce-dure is exited.

� Output ParametersOutput parameters are specified after the EXPORTING addition tothe METHODS or CLASS-METHODS statement, or are declared by select-ing Exporting in the Type column on the Parameters tab page inthe Class Builder. When a method is called, the value of theassigned actual parameter is not assigned to an output parameterfor which pass by value is defined. Output parameters can beoverwritten in the method. If the procedure is exited withouterrors using ENDMETHOD or RETURN, the output parameter is passedto the actual parameter.

� Input/Output ParametersInput/output parameters are specified after the CHANGING additionto the METHODS or CLASS-METHODS statement, or are declared byselecting Changing in the Type column on the Parameters tabpage in the Class Builder. When a method is called, the value ofthe assigned actual parameter is assigned to the input/outputparameter, and, if the method is exited without errors using END-METHOD or RETURN, the input/output parameter is passed to theactual parameter. Input/output parameters can be overwritten inthe method.

Functionalmethod

� Return ValueA method can have only one return value, for which pass by valuemust be declared. This return value can be declared after the

Page 24: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

347

Method Interfaces and Method Calls 6.1

RETURNING addition to the METHODS or CLASS-METHODS statement, orby selecting Returning in the Type column on the Parameters tabpage in the Class Builder. A return value is handled in the sameway that an output parameter is handled in the method; however,a method with a return value is a functional method, which, inaddition to the return value, can have only input parameters. Afunctional method can be used in operand positions. The returnvalue is then used in these positions.3

When you declare a parameter, you must always select the type thatmatches the behavior of that parameter exactly. A parameter that isreceived but not changed by the method is an input parameter. Aparameter that is output but is not received is an output parameter ora return value. A parameter that is received, changed, and output isan input/output parameter.

This may appear to be stating the obvious, but, as you will see,parameters do not have to behave in accordance with their type.

Kind of Parameter Passing

You can define the way a formal parameter is passed either as pass byreference or as pass by value for each individual parameter, with theexception of the return value, for which pass by value is set bydefault.

The syntax for pass by reference is shown below using the exampleof an input parameter ipara:

REFERENCEMETHODS meth IMPORTING ipara ...

Equally, you can also use:

METHODS meth IMPORTING REFERENCE(ipara) ...

The syntax for pass by value is shown below using the example ofthe return value return:

VALUEMETHODS meth RETURNING VALUE(return) ...

3 Functional methods (as opposed to function modules) are the natural extension ofintegrated functions (see Section 5.2.4) by self-defined functions in the same wayas self-defined data types extend the built-in ABAP types.

Page 25: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

348

Advanced Concepts in ABAP Objects6

In the Class Builder, you define the kind of parameter passing byselecting the Pass by value check box on the Parameters tab page orleaving this blank. Therefore, pass by reference is the standard trans-fer type, which is used unless a different type is specified, both in thesyntax and in the Class Builder. What is the difference between thesetransfer types?

� Pass by ReferenceWith pass by reference, a reference to the actual parameter ispassed to the method for each formal parameter for which anactual parameter is specified when you call the method, regardlessof the parameter type. The method thus uses the actual parameteritself, and changes to formal parameters have a direct effect on theactual parameter.

� Pass by ValueWith pass by value, a local data object is created as a copy of theactual parameter for each formal parameter when the method iscalled. In the case of input parameters and input/output parame-ters, the value of the actual parameter is assigned to this dataobject. The value of the formal parameter is only assigned to out-put parameters, input/output parameters, and return values if themethod is exited without errors using ENDMETHOD or RETURN.

Parameter typeand kind of passing

The kind of parameter passing is a technical property, which definesthe behavior of a formal parameter. Only with pass by value does theactual behavior always correspond to the behavior defined by theparameter type. The following points apply to pass by reference:

� Output parameters are not necessarily initial at the start of themethod (output parameters behave like input/output parameters).

� Changes to output parameters and input/output parameters areeffective, even if the method terminates with an exception.

� Input parameters that are passed by reference cannot be explicitlychanged in the method. Their values may change, however, if theyare linked to global actual parameters and if these parameters arechanged during the method is executed.

Therefore, a method should always be programmed in such a waythat the behavior of its parameters corresponds to the semanticsdefined by the parameter type:

Page 26: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

349

Method Interfaces and Method Calls 6.1

� Do not execute read access to an output parameter that is passedby reference because its initial value is not defined.

� If you add lines to an internal table or extend a string that isdefined as an output parameter that is passed by reference, youmust initialize the parameter before the first access.

� Give due consideration to the value you set for output parametersor input/output parameters that are passed by reference before anexception is triggered to ensure that a calling program can executeadequate exception handling.

Pass by reference and pass by value

A number of precautionary methods are thus required for pass byreference, which do not apply to pass by value. So why is pass by ref-erence even necessary? The answer is performance.

Performance as against robustness

In ABAP, pass by reference always performs better than pass byvalue, because no data object has to be created when a procedure iscalled, and no data transport takes place. For performance reasons,pass by reference is usually preferable to pass by value, unlessexplicit or implicit write access to an input parameter is required, oryou want to ensure that an output parameter or an input/outputparameter is only returned if the procedure is completed withoutany errors. If possible, these cases should be limited to the transfer ofparameters smaller than approximately 100 bytes.4

The example in Listing 6.1 is of a small and probably unexpected sit-uation, which may occur if pass by reference is used without dueconsideration.

Listing 6.1 Transfer Type of Formal Parameters

REPORT z_parameter_passing.

CLASS demo DEFINITION CREATE PRIVATE.PUBLIC SECTION.

CLASS-METHODS main.PRIVATE SECTION.

METHODS: meth1 IMPORTING value(idx) TYPE i,meth2 IMPORTING reference(idx) TYPE i.

4 With strings and internal tables, the disadvantage in terms of performance of passby value compared with pass by reference can even be compensated for by theintegrated Copy-on-Write semantics (the concept of sharing, see Section 5.1.7).This is the case for input parameters in particular, provided that they are notchanged.

Page 27: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

350

Advanced Concepts in ABAP Objects6

DATA msg TYPE string.ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.DATA oref TYPE REF TO demo.CREATE OBJECT oref.DO 2 TIMES.

oref->meth1( sy-index ).oref->meth2( sy-index ).

ENDDO.ENDMETHOD.METHOD meth1.DO 3 TIMES.

msg = idx.CONCATENATE `meth1: ` msg INTO msg.MESSAGE msg TYPE 'I'.

ENDDO.ENDMETHOD.METHOD meth2.DO 3 TIMES.

msg = idx.CONCATENATE `meth2: ` msg INTO msg.MESSAGE msg TYPE 'I'.

ENDDO.ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.demo=>main( ).

In the main method, two methods are called with an identical imple-mentation in a DO loop. The first method, meth1, outputs the contentof sy-index , which is passed by value, three times as expected, inother words, “1”, “1”, “1” during the first call, and “2”, “2”, “2” dur-ing the second call. The second method, meth2, outputs “1”, “2”, “3”during both calls. The DO loop in meth1 and meth2 sets the global sys-tem field sy-index and thus also the formal parameter idx (passed byreference) in meth2.

The method with pass by value is therefore more robust. However,this example also shows that global parameters like system fields—changes to which are not subject to the direct control of a method—should not be simply passed to methods in this way from the calling

Page 28: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

351

Method Interfaces and Method Calls 6.1

program. The expected result is also returned by meth2 if a local aux-iliary variable is implemented in main, to which sy-index is assignedand which is then passed to meth2.

Typing

You must type each formal parameter of a method. Typing simplymeans that you assign a type to a formal parameter. As with data dec-laration, the syntax used for this purpose is a TYPE or LIKE addition,which you must specify after each formal parameter, for example:

METHODS meth EXPORTING opara TYPE dtype ...

With local classes, any visible type can be specified here. In the ClassBuilder, fill the Typing (Type, Type Ref To or Like) and Referencetype columns accordingly on the Parameters tab page in order tospecify the type,. Since the type you specify must also be accessibleto all users of the method, you can only specify built-in ABAP types,global types from the ABAP Dictionary, or types from the public vis-ibility section of a global class for public methods. With protectedmethods, additional types from the protected visibility section of theclass can also be used, while types from the private visibility sectionand local types from the class pool can be used for private methodtypes only.

The main difference between typing and data declaration is that aformal parameter is assigned its actual data type only when it islinked to an actual parameter when a method is called. All technicalproperties of the actual parameter are then passed to the formalparameter.

Checking typingIn order for an actual parameter to be passed, its data type mustmatch the typing of the formal parameter. To be more precise, itstechnical type properties must be compatible with the data type usedfor the typing. The technical properties of an elementary type are thebuilt-in ABAP type (c, d, f, i, n, p, t, string, x, xstring), the length(for c, n, p, x), and the number of decimal places (for p). The technicalproperty of a structured type is its structure, based on substructuresand elementary components (the component names are irrelevant).The technical properties of an internal table are the table type(STANDARD, HASHED, SORTED), line type, and table key.

Page 29: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

352

Advanced Concepts in ABAP Objects6

Generic typing The typing of a formal parameter may be complete or generic. Forcomplete typing, use TYPE to refer to a complete data type, or LIKE torefer to a data object. For generic typing, you can use the built-ingeneric types (any, any table, c, clike, csequence, data, hashedtable, index table, n, numeric, object, simple, sorted table, stand-ard table, table, x, xsequence—see Section 5.1.9). Internal tabletypes are also generic if the table key is not fully defined.

Formal parameters that have complete typing can always beregarded as local data objects of this type, with all type propertiesknown inside the method. Generic types differ in terms of static anddynamic access. The type properties used for typing are only used forstatic access. With dynamic access,5 the type properties of theassigned actual parameter are used. These properties may differ fromthe typing in terms of the non-technical properties, such as compo-nent names.

Operand position In addition to checking the data type of an assigned actual parameter,the typing defines how the formal parameter can be used as an oper-and of statements in the method. With one exception, formal param-eters can be used in all operand positions that are not excluded by thetyping. For example, a generic formal parameter with the typing anycan be assigned to any formal parameter that has the same typing. Inthat case, an exception occurs at runtime if types for which no conver-sion rules exist (see Section 5.2.2) are assigned. Internal tables consti-tute the exception to this rule. In this case, table accesses are only per-mitted to formal parameters that have a corresponding typing.

The example provided in Listing 6.2 shows various typings and theireffects on how formal parameters are used in the methods.

Listing 6.2 Typing of Formal Parameters

REPORT z_parameter_typing.

CLASS demo DEFINITION.PUBLIC SECTION.METHODS: meth1 IMPORTING ipar TYPE any,

meth2 IMPORTING ipar TYPE any table,meth3 IMPORTING ipar TYPE index table.

ENDCLASS.

5 With dynamic access to a component during an operation on an internal table, forexample.

Page 30: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

353

Method Interfaces and Method Calls 6.1

CLASS demo IMPLEMENTATION.METHOD meth1.

DATA num TYPE string.num = ipar."READ TABLE ipar INDEX 1" TRANSPORTING NO FIELDS."READ TABLE ipar WITH KEY table_line = '...'" TRANSPORTING NO FIELDS.

ENDMETHOD.METHOD meth2.

DATA num TYPE string."num = ipar."READ TABLE ipar INDEX 1" TRANSPORTING NO FIELDS.READ TABLE ipar WITH KEY table_line = '...'

TRANSPORTING NO FIELDS.ENDMETHOD.METHOD meth3.

DATA num TYPE string."num = ipar.READ TABLE ipar WITH KEY table_line = '...'

TRANSPORTING NO FIELDS.READ TABLE ipar INDEX 1

TRANSPORTING NO FIELDS.ENDMETHOD.

ENDCLASS.

Three conceivable uses of the input parameter are specified in themethods, while the statements that result in syntax errors for therespective typing are commented out:

� The ipar input parameter of the meth1 method is typed as com-pletely generic. It can be assigned to the num local variables; how-ever, no read operations can be executed for internal tables. Whenthe method is called, any data objects can be passed to the formalparameter. But, if an internal table is passed, an exception occursduring the assignment to num.

� The ipar input parameter of the meth2 method is typed with aninternal table that is generic in terms of table type, line type, andtable key. It cannot be assigned to the num local variable. Only keyaccess can be executed for internal tables because only theseaccesses are permitted for all table types. When the method iscalled, any internal tables can be passed to the formal parameter.

Page 31: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

354

Advanced Concepts in ABAP Objects6

� The ipar input parameter of the meth3 method is typed with anindex table that is generic in terms of line type and table key. Itcannot be assigned to the num local variable. However, all accessescan be executed for internal tables because key and index accessesare possible for index tables. When the method is called, onlyindex tables (and no hash tables) can be passed to the formalparameter.

Formal parameters should be as appropriately typed as possible. Thetyping must comply with both the implementation requirements andthe expectations of the calling program. If you want or need to use ageneric type, you should always be as specific as possible. Usegeneric types like csequence, numeric, simple, and xsequence insteadof any. For example, csequence is usually an appropriate typing fortext processing. The typings standard table, sorted table, indextable, or hashed table are similarly preferable to any table.

Generic orcomplete

The more generic the typing you use, the more careful you must bewhen using the formal parameter in the implementation to avoidexceptions. Accordingly, you should avoid assigning formal parame-ters with a typing that is completely generic if you do not want tofirst check the type at runtime (see Section 11.2) or handle possibleexceptions (see Section 8.2).

Unless generic typing is required, you should always use completetyping. Only formal parameters with complete typing always behavein the same way and can be tested locally. You must be particularlycareful to ensure that you don’t use generic typing by mistake whenyou actually intend to use complete typing. This frequently occurswith internal tables with a generic key.

Supply Type

For every formal parameter that awaits a value—input parametersand input/output parameters—by standard, an actual parametermust be specified when the method is called. The assignment ofactual parameters to output parameters and return values is alwaysoptional.

For input parameters and input/output parameters, this rule can beavoided by declaring the parameter as optional. The syntax is shownbelow, using the example of an input/output parameter:

Page 32: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

355

Method Interfaces and Method Calls 6.1

OPTIONALMETHODS meth CHANGING cpara TYPE dtype OPTIONAL ...

or

DEFAULTMETHODS meth CHANGING cpara TYPE dtype DEFAULT dobj ...

No actual parameters have to be specified when the method is calledfor a formal parameter that is declared as optional. An optional for-mal parameter for which no actual parameter is specified is initial-ized in accordance with its type. With the addition DEFAULT, thevalue and type of an appropriately specified replacement parameterdobj are copied.

In the Class Builder, you can make a formal parameter optional byselecting the Optional column, or by entering a value in the Defaultvalue column.

We recommend that you make all formal parameters optional, withthe exception of those for which a different entry is actually requiredeach time the method is called. Otherwise, you force your callers tospecify unnecessary actual parameters, for which type-specific auxil-iary variables often have to be created.

Ensure that the predefined initialization of optional parameters issufficient or, if you must initialize such a parameter explicitly, forexample, in dependence of other parameters. With the special pred-icate

... IS SUPPLIED ...

you can even use a logical expression to react differently in themethod, depending on whether an actual parameter is assigned to anoptional parameter.

6.1.2 Method Calls

This section discusses the options for calling methods statically. Adynamic method call is also possible (see Section 11.4). When amethod is called, actual parameters must be passed to all non-optional formal parameters (in other words, all input parameters andinput/output parameters that are not defined as optional). Actualparameters can be connected to optional formal parameters. Theactual parameters must match the typing of the formal parameters.

Page 33: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

356

Advanced Concepts in ABAP Objects6

The following sections describe static method with increasing com-plexity of the method interface.

Static Method Calls

The simplest method has no interface parameters. Accordingly, themethod call is also simple. The statement is as follows:

No parameters meth( ).

With meth, you specify the method as it can be addressed as a com-ponent of a class or an object in the current location, that is, directlywith its name meth in a method of the same class, or with oref->methor class=>meth everywhere the method is visible.

If the method has one non-optional input parameter, the statement isas follows:

One inputparameter

meth( dobj ).

The dobj data object is passed to the input parameter as an actualparameter. If the method has several non-optional input parameters,the statement is as follows:

Several inputparameters

meth( i1 = dobj1 i2 = dobj2 ... ).

A data object is explicitly assigned to each input parameter. If actualparameters are to be assigned to any formal parameters, the syntax isas follows:

Any parameter meth( EXPORTING i1 = dobj1 i2 = dobj2 ...IMPORTING o1 = dobj1 o2 = dobj2 ...CHANGING c1 = dobj1 c2 = dobj2 ... ).

With EXPORTING, you supply the input parameters defined withIMPORTING. With IMPORTING, you receive values from output parame-ters defined with EXPORTING. With CHANGING, you assign the actualparameters to the input/output parameters defined with CHANGING.The equal sign is not an assignment operator in this case. Instead, itsfunction is to bind actual parameters to formal parameters. This syn-tax includes the previous short forms and can be used instead.

Finally, you can add a CALL METHOD to all of the previous syntaxforms, for example:

CALL METHOD CALL METHOD meth( i1 = dobj1 i2 = dobj2 ... ).

Page 34: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

357

Method Interfaces and Method Calls 6.1

However, this specification is merely unnecessary syntactical noiseand can be omitted (as of Release 6.10).6

Functional Method Call

You may notice that we haven’t mentioned the RETURNING parameterof a functional method7 in our discussion of method calls. This isbecause functional methods are intended to be used in operand posi-tions. Nevertheless, there is also a separate statement for calling afunctional method:

RETURNING parameter

meth( EXPORTING i1 = dobj1 i2 = dobj2 ...RECEIVING r = dobj ).

Here, RECEIVING receives the return value in dobj; however, thisstatement is seldom if ever used in practice. The functional equiva-lent for the above call is as follows:

dobj = meth( i1 = dobj1 i2 = dobj2 ... ).

The call of the functional method can be specified in an operandposition, which, in this case, is the source field of an assignment,without specifying RECEIVING. When the statement is executed, themethod is called and the return value is used as an operand. In theexample shown above, it is assigned to dobj. The actual parametersare assigned to input parameters using the three syntax formsdescribed above for no input parameters, one input parameter, orseveral input parameters.

... meth( ) ...

... meth( dobj ) ...

... meth( i1 = dobj1 i2 = dobj2 ... ) ...

Functional methods can be used in the same places as built-in func-tions (see Section 5.2.4). A functional method called with meth( a )hides an built-in function with the same name:

� As the source field of an assignment

� As an operand in an arithmetic expression

� As an operand in a logical expression

6 The CALL METHOD language element is only required for the dynamic method callsstill.

7 Remember that a function method can have any number of input parameters andonly one return value that is passed by value.

Page 35: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

358

Advanced Concepts in ABAP Objects6

� As an operand in the CASE statement

� As an operand in the WHEN statement

� As an operand in the WHERE condition for internal tables

If a functional method called in an operand position sends a class-based exception, this can be handled within a TRY control structure.8

As of the next release of SAP NetWeaver, you will be able to usefunctional methods as well as built-in functions and complete arith-metic expressions in almost all operand positions where it is usefulto do so. You will be able to use them, in particular, as actual param-eters for input parameters of methods, which will allow you to nestmethod calls.

In Listing 6.3, we have implemented two functional methods get_area and get_volume, to calculate the circular area and volume of acylinder in a class called cylinder.

Listing 6.3 Functional Methods

REPORT z_functional_method.

SELECTION-SCREEN BEGIN OF SCREEN 100.PARAMETERS: p_radius TYPE i,

p_height TYPE i.SELECTION-SCREEN END OF SCREEN 100.

CLASS demo DEFINITION.PUBLIC SECTION.CLASS-METHODS main.

ENDCLASS.

CLASS cylinder DEFINITION.PUBLIC SECTION.METHODS: constructor IMPORTING i_radius TYPE numeric

i_height TYPE numeric,get_area RETURNING value(r_area) TYPE f,get_volume RETURNING value(r_volume) TYPE f.

PRIVATE SECTION.CONSTANTS pi TYPE f VALUE '3.14159265'.DATA: radius TYPE f,

height TYPE f.ENDCLASS.

CLASS cylinder IMPLEMENTATION.METHOD constructor.

8 Classical exceptions cannot be handled in this case.

Page 36: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

359

Inheritance 6.2

me->radius = i_radius.me->height = i_height.

ENDMETHOD.METHOD get_area.

r_area = pi * me->radius ** 2.ENDMETHOD.METHOD get_volume.

r_volume = me->get_area( ) * me->height.ENDMETHOD.

ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.

DATA: oref TYPE REF TO cylinder,volume TYPE string.

CALL SELECTION-SCREEN 100 STARTING AT 10 10.IF sy-subrc = 0.CREATE OBJECT oref EXPORTING i_radius = p_radius

i_height = p_height.volume = oref->get_volume( ).CONCATENATE `Volume: ` volume INTO volume.MESSAGE volume TYPE 'I'.

ENDIF.ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.demo=>main( ).

The main method of the demo class uses a function call to get_volumeon the right side of an assignment, and assigns the result to the vol-ume string. The get_volume method calls get_area in an arithmeticexpression. The calculation type of this expression is f.

6.2 Inheritance

In object orientation, inheritance refers to the specialization ofclasses by deriving subclasses from superclasses.

6.2.1 Basic Principles

Classes provide a construction plan for objects. Suppose you createtwo classes called “Car” and “Truck”. You want to implement meth-ods for both classes, which control the objects or return information

Page 37: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

360

Advanced Concepts in ABAP Objects6

about their location and speed. Even at this stage, you can foreseethat some parts of the classes will have to be written twice. Theinheritance mechanism of an object-oriented programming languageprovides options that help you to reuse the same or similar parts of aclass, and to create a hierarchy of classes.

Superclasses andsubclasses

If we examine the two classes (i. e., “Car” and “Truck”) in moredetail, it becomes clear that both classes comprise types of vehicles.If you want to create a third class called “Dump truck” it will com-prise a specific type of truck. To create a hierarchy relationshipbetween these classes, classes can be derived from each other usinginheritance. In our example, “Car” and “Truck” are derived from the“Vehicle” class, while “Dump truck” are derived from the “Truck”class. Derived or more specific classes are referred to as subclasses,while more general classes are called superclasses.

Simple inheritance The concept of simple inheritance is implemented in ABAP Objects.According to this concept, each class can have several subclasses butonly one superclass.9 In simple inheritance, inheritance relationshipsare represented by an inheritance tree. Every class in an object-ori-ented programming language in which simple inheritance is imple-mented has a unique position as a node in an inheritance tree. Thisalso applies to all the classes we have dealt with up to now, althoughwe have not yet spoken of them in terms of inheritance. For eachclass, a unique path can be traced back through their superclasses inthe inheritance tree until you reach exactly one root node. This rootnode is the superclass of all classes in the inheritance tree.

Root class Figure 6.1 illustrates this relationship. The root node of the inherit-ance tree in ABAP Objects is the predefined, empty, and abstractclass object.

Derivation Inheritance simply means that a subclass inherits all components(attributes, methods, events, etc.) of its superclass and can use themlike its own components. In each subclass, new elements can beadded or methods can be redefined in order to specialize, withoutthis having any impact on the superclass. Elements can only beadded in subclasses. It would go against the inheritance concept toremove elements in a subclass.

9 Other programming languages, such as C++, allow a class to be derived from sev-eral classes. This mechanism, which is referred to as multiple inheritance, is notimplemented in ABAP Objects.

Page 38: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

361

Inheritance 6.2

Implicit subclassesIn accordance with this concept, the direct subclasses of the emptyobject root class do not inherit any components from its superclass.Instead, they can add new components. This situation applies to allour sample classes up to now. All classes in ABAP Objects that do notexplicitly inherit from another class are implicit direct subclasses ofobject.

Specialization/generalization

When subclasses of explicitly defined classes are created, theseinherit the components of their superclasses and can add new com-ponents. Classes become increasingly specialized the further awayyou move from the root in the inheritance tree. As you movetowards the root node, on the other hand, the classes become moregeneralized.

CompositionIf you look at a class that is located near the bottom of the inheritancetree, you will notice that the inherited components of the class orig-inate in all classes along the path between this class and the rootclass, which is the superclass of all classes. In other words, the defi-nition of a subclass is composed of the definitions of all of its super-classes right up to object. The relationship between a subclass andits superclasses should always be expressed as “is a”; for example, “acargo plane is a plane is a means of transportation is an object.” Ifthis is fulfilled, subclasses can always be handled the same way assuperclasses (see polymorphism in Section 6.4).

Figure 6.1 Inheritance Tree in ABAP Objects

CLASS c1 DEFINITION [INHERITING FROM object ].

CLASS c2 DEFINITION [INHERITING FROM object ].

CLASS c11 DEFINITION INHERITING FROM c1 .

CLASS c12 DEFINITION INHERITING FROM c1 .

object

Page 39: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

362

Advanced Concepts in ABAP Objects6

6.2.2 Creating Subclasses

A superclass has no knowledge of any subclasses it may have. Only asubclass is aware that it is the heir of another class. Therefore, aninheritance relationship can only be defined when a subclass isdeclared. The syntax for deriving a subclass (subclass) from a super-class (superclass) is as follows:

INHERITINGFROM

CLASS subclass DEFINITION INHERITING FROM superclass....

ENDCLASS.

It therefore involves a simple addition to the CLASS DEFINITION state-ment. Any non-final class that is visible at this point can be specifiedfor superclass. To create a subclass in the Class Builder, selectSuperclass on the Properties tab page. Then enter any non-final, glo-bal class as a superclass in the Inherits from field. The Undo inherit-ance and Change inheritance options allow you to change the inher-itance relationship (see Figure 6.2).

To display the components in a subclass that were inherited from thesuperclass, select the menu option Utilities � Settings, and select theDisplay Inherited Components Also option.

For each class that does not have an explicit INHERITING FROM addi-tion, the system implicitly adds the INHERITING FROM object addi-tion, which means that any class without an INHERITING addition isautomatically a direct subclass of the object root class.

Listing 6.4 shows the implementation of our example based on vehi-cles. In this implementation, two classes (car and truck) are derivedfrom the vehicle class.

Listing 6.4 Simple Example of Inheritance

REPORT z_inheritance.

CLASS demo DEFINITION.PUBLIC SECTION.

Figure 6.2 Inheritance in the Class Builder

Page 40: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

363

Inheritance 6.2

CLASS-METHODS main.ENDCLASS.

CLASS vehicle DEFINITION.PUBLIC SECTION.

METHODS: accelerate IMPORTING delta TYPE i,show_speed.

PROTECTED SECTION.DATA speed TYPE i.

ENDCLASS.

CLASS car DEFINITION INHERITING FROM vehicle.ENDCLASS.

CLASS truck DEFINITION INHERITING FROM vehicle.PUBLIC SECTION.

METHODS: load IMPORTING freight TYPE string,unload.

PROTECTED SECTION.DATA freight TYPE string.

ENDCLASS.

CLASS vehicle IMPLEMENTATION.METHOD accelerate.

me->speed = me->speed + delta.ENDMETHOD.METHOD show_speed.

DATA output TYPE string.output = me->speed.MESSAGE output TYPE 'I'.

ENDMETHOD.ENDCLASS.

CLASS truck IMPLEMENTATION.METHOD load.

me->freight = freight.ENDMETHOD.METHOD unload.

CLEAR me->freight.ENDMETHOD.

ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.

DATA: car_ref TYPE REF TO car,truck_ref TYPE REF TO truck.

CREATE OBJECT: car_ref,truck_ref.

car_ref->accelerate( 130 ).car_ref->show_speed( ).

Page 41: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

364

Advanced Concepts in ABAP Objects6

truck_ref->load( `Beer` ).truck_ref->accelerate( 110 ).truck_ref->show_speed( ).truck_ref->unload( ).

ENDMETHOD.ENDCLASS.

START-OF-SELECTION.demo=>main( ).

The vehicle class contains a protected attribute (speed) and two pub-lic methods (accelerate and show_speed). Note that we have explic-itly specified that vehicle inherits from object. Normally, we do notspecify the INHERITING addition for such classes. The car and truckclasses are both derived from vehicle. Therefore, they inherit theattribute and methods of the vehicle class. Since speed is declared inthe PROTECTED SECTION, it is also visible in the subclasses. The truckclass is specialized with an additional attribute for freight and addi-tional methods for loading and unloading (load and unload). In thisexample, the car class receives no additional components. Thismeans that its objects are the same as those of the vehicle class.Since no methods have been added, car does not require an imple-mentation part.

In the main method of the demo class, we use the reference variablescar_ref und truck_ref to generate one object each for the two sub-classes and call their methods. The accelerate and show_speed meth-ods can be used in both subclasses; however, the load and unloadmethods can be used only in truck.

6.2.3 Visibility Sections and Namespaces in Inheritance

There are three different visibility sections in a class, in which thecomponents of the class are declared (see Section 4.3.2). A subclassinherits all components of its superclasses without changing their vis-ibility. For that reason, only the public and protected components ofits superclasses are visible in a subclass. In contrast, the private com-ponents are contained in the subclass but are invisible.10 The visibilitysections of a subclass therefore contain the following components:

10 Note, however, that the methods inherited from the superclass use the privateattributes of the superclass, unless these inherited methods are redefined in thesubclass.

Page 42: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

365

Inheritance 6.2

� PUBLICThe public visibility section of a subclass contains all public com-ponents of all superclasses, plus its own additional public compo-nents. These components can be accessed externally using compo-nent selectors.

� PROTECTEDThe protected visibility section of a subclass contains all protectedcomponents of all superclasses, plus its own additional protectedcomponents. These components cannot be accessed externallyusing component selectors. From an external point of view, “pro-tected” is the same as “private.”

� PRIVATEThe private visibility section of a subclass contains only the sub-class’s own private components. These components can only beaccessed in the method implementations of the subclass.

NamespaceSince all visible components in a class must have unique names, allpublic and protected components of all classes along an inheritancepath in the inheritance tree belong to the same namespace and haveunique names. Private components, which are only visible within aclass and cannot be used in subclasses, must only have unique nameswithin their own class.

The implications of this are as follows: A superclass is not aware ofany subclasses it may have. If you create a non-final class in a classlibrary and release it for use, you can never know, as a developer,which subclasses your class will eventually have other than thoseyou define yourself. If you then subsequently add new componentsto the public or protected section of your class, and any of its sub-classes happen to have a component of its own with the same name,this becomes syntactically incorrect. Therefore, it is only secure toadd private components. In global classes, not only the externalinterface but also the interface with any possible subclasses mustremain stable.

Therefore, to limit the subclasses of a class to at least the same pack-age, non-final classes should preferably be organized in packages forwhich the Package Check as Server property is activated (see Section2.3.3).

Page 43: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

366

Advanced Concepts in ABAP Objects6

6.2.4 Method Redefinition

A subclass inherits all public and protected methods additionally toits own components.11 When a method is called in the subclass, it isexecuted in the same way it was implemented in the superclass, andeven uses the private components of the superclass. However, sincethe main purpose of inheritance is to specialize classes, the behaviorof the method of a superclass may be too general for the more spe-cific purpose of the subclass. In some cases, the implementation ofsuperclass must be enhanced in the subclass, while in otherinstances, the implementation must be completely changed. How-ever, the semantics of the method must remain stable for the exter-nal user, because all this user ever sees is the constant interface(including the documentation) and not the implementation itself.

New implemen-tation

Instance methods can be redefined in subclasses to specialize thebehavior of subclass objects. Static methods cannot be redefined.Redefining a method means creating a new implementation of themethod in a subclass without changing the interface.12 The method isstill declared in the superclass. Previous implementations of themethod in preceding superclasses remain unchanged. When amethod is redefined in a subclass, an additional implementation iscreated, which hides the previous implementation when the subclassand further subclasses are used.

Access Every reference that refers to an object of the subclass uses the rede-fined method. This is always the case, regardless of the type of thereference variables (for more details, see Section 6.4). This applies inparticular to the self reference me. Therefore, if a superclass method(meth1) contains the call of a method (meth2) belonging to the sameclass, which is redefined in a subclass, the call of the meth1 method inan instance of the superclass results in the execution of the originalmethod (meth2), while the call of the meth1 method in an instance ofthe subclass results in the execution of the redefined method (meth2).

11 The private methods are also inherited in principle, but are not visible in the sub-class.

12 Some other object-oriented programming languages permit the overloading offunctions or methods. This means that a separate, changed parameter interfacecan be defined for an overwritten or redefined method. ABAP Objects does notcurrently support this mechanism.

Page 44: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

367

Inheritance 6.2

Like the methods belonging to the subclass, a redefined methodaccesses the private attributes of the subclass.

REDEFINITIONThe syntax for redefining an instance method in a subclass is as fol-lows:

METHODS meth REDEFINITION.

This statement must be specified in the declaration part of the sub-class in the same visibility section as the actual declaration of themethod in the superclass. The definition of the interface is notrepeated.

In the Class Builder, you redefine an inherited method by displayingit on the Methods tab. To do so, you must use the Settings functionof the Class Builder to select the Display Inherited Components Alsoentry. Then, you must highlight the method and select the Redefinefunction (see Figure 6.3).

ImplementationA new implementation must be created for each redefined methodin the redefining subclass. In global classes, the Class Builder doesthis as part of the Redefine process, and you can navigate to theimplementation in the same way as with normal methods. In localclasses, you must enter the implementation yourself in the imple-mentation part as for normal methods.

Pseudo referenceIn the implementation of a redefined method, you can use thepseudo reference super-> to access the original method of the directsuperclass. This overrides the hiding of the redefined method. Youmust always use this pseudo reference if you want to first copy thefunctionality of the superclass and then enhance it.

We can now apply method redefinition to our example from Listing6.4. Listing 6.5 shows how this differs from Listing 6.4.

Figure 6.3 Redefinition of an Inherited Method

Page 45: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

368

Advanced Concepts in ABAP Objects6

Listing 6.5 Method Redefinition

REPORT z_method_redefinition.

...

CLASS car DEFINITION INHERITING FROM vehicle.PUBLIC SECTION.METHODS show_speed REDEFINITION.

ENDCLASS.

CLASS truck DEFINITION INHERITING FROM vehicle.PUBLIC SECTION.METHODS: accelerate REDEFINITION,

show_speed REDEFINITION,load IMPORTING freight TYPE string,unload.

PROTECTED SECTION.DATA freight TYPE string.

PRIVATE SECTION.CONSTANTS max_speed TYPE i VALUE '80'.

ENDCLASS.

...

CLASS car IMPLEMENTATION.METHOD show_speed.DATA output TYPE string.output = me->speed.CONCATENATE `Car, speed: ` output INTO output.MESSAGE output TYPE 'I'.

ENDMETHOD.ENDCLASS.

CLASS truck IMPLEMENTATION.METHOD accelerate.super->accelerate( delta ).IF me->speed > truck=>max_speed.

me->speed = truck=>max_speed.ENDIF.

ENDMETHOD.METHOD show_speed.DATA output TYPE string.output = me->speed.CONCATENATE `Truck with `

me->freight`, speed: `output

INTO output.

Page 46: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

369

Inheritance 6.2

MESSAGE output TYPE 'I'.ENDMETHOD....

ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.

DATA: car_ref TYPE REF TO car,truck_ref TYPE REF TO truck.

CREATE OBJECT: car_ref,truck_ref.

car_ref->accelerate( 130 ).car_ref->show_speed( ).truck_ref->load( `Beer` ).truck_ref->accelerate( 110 ).truck_ref->show_speed( ).truck_ref->unload( ).

ENDMETHOD.ENDCLASS.

START-OF-SELECTION.demo=>main( ).

We specialize the accelerate method in the truck class and theshow_speed method in both subclasses:

� In the truck class, we introduced a maximum speed max_speedthat cannot be exceeded in accelerate. In the new implementa-tion, the speed is therefore set by calling super->accelerate viathe previous implementation, and then checked and adapted, ifnecessary.

� The show_speed method is extended by specific outputs in bothsubclasses. The previous implementation is not used for this pur-pose.

All redefined methods keep their original semantics in spite of thenew implementation. You will notice that this requires some pro-gramming discipline because we can also implement the methods ina completely different way (for more information, see Section 6.4.3).A test tool that might help you check the stability of applications isABAP Unit (see Section 13.3).

Page 47: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

370

Advanced Concepts in ABAP Objects6

6.2.5 Abstract Classes and Methods

If you want to use a class just as a template for subclasses and don’tneed any objects of this class, you can define the class as an abstractclass. The syntax for defining an abstract class is:

ABSTRACT CLASS class DEFINITION ABSTRACT....

ENDCLASS.

To create an abstract class in the Class Builder, select Abstract in theInstantiation input field on the Properties tab (see Figure 6.4).

Objects cannot be created from an abstract class using CREATE OBJECT.Instead, abstract classes are used as a template for subclasses. Froman abstract class, actual subclasses can be derived from which objectscan then be created.

Single instance methods can be identified as abstract as well. Thesyntax is:

METHODS meth ABSTRACT.

In the Class Builder, you can identify a method as Abstract in itsDetail view (see Figure 6.5).

Implementation An abstract method cannot be implemented in its own class, but onlyin a concrete subclass. Therefore, abstract methods can only be cre-ated in abstract classes. Otherwise, it would be possible to create anobject with an addressable method but without its implementation.To implement an abstract method in a subclass, you use the methoddefinition mechanism discussed in Section 6.2.4. The only differenceto a real redefinition is that you cannot use the super-> pseudo ref-erence in the method.

Figure 6.4 Abstract Global Class

Page 48: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

371

Inheritance 6.2

In an abstract class, both concrete and abstract methods can bedeclared. Concrete methods are declared and implemented as usual.With the exception of instance constructers, concrete methods caneven call abstract methods, because names and interfaces are com-pletely known. The behavior of the abstract method, however, isdefined during the implementation in a subclass and can thereforevary in different subclasses.

In our example in Listing 6.5, the vehicle superclass is rather rudi-mentary and is not used for creating any objects. To prevent this alsosyntactically, the class can be defined as abstract, as shown in Listing6.6. Listing 6.6 only demonstrates the differences in comparisonwith Listing 6.5.

Listing 6.6 Abstract Class and Method

REPORT z_abstract_class.

...

CLASS vehicle DEFINITION ABSTRACT.PUBLIC SECTION.

METHODS: accelerate IMPORTING delta TYPE i,show_speed ABSTRACT.

PROTECTED SECTION.

Figure 6.5 Abstract Method

Page 49: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

372

Advanced Concepts in ABAP Objects6

DATA speed TYPE i.ENDCLASS.

...

CLASS vehicle IMPLEMENTATION.METHOD accelerate.me->speed = me->speed + delta.

ENDMETHOD.ENDCLASS.

...

The vehicle class only determines the common elements of the sub-classes. Because the two subclasses in Listing 6.5 redefine the show_speed method anyway, we declared it in Listing 6.6 as abstract aswell. It is therefore no longer implemented in the vehicle class.

Design The use of abstract classes and methods can be an important meansof object-oriented design. Abstract classes provide a common inter-face and a partially implemented functionality to their subclasses,but cannot perform any relevant operations on their attributes them-selves. In a payroll system, for example, you can imagine a class thatalready implements many tasks like bank transfers, but only includesthe actual payroll function in an abstract manner. It is then the taskof various subclasses to perform the correct payroll calculation fordifferent work contracts.

Interfaces Because ABAP Objects does not support multiple inheritance, theusage of abstraction via abstract classes is always restricted to thesubclasses of a specific node of the inheritance tree. Interfaces areanother means of solving similar tasks, irrespective of the position inthe inheritance hierarchy. They are discussed in Section 6.3.

6.2.6 Final Classes and Methods

Just as abstract classes and methods require a definition of subclassesin order to work with the classes, there can be adverse situationswhere you want to protect a whole class or a single method fromuncontrolled specialization. For this purpose, you can declare a classor an instance method as final. This can make sense particularly ifyou want to make changes to a class at a later stage without causingany subclasses to become syntactically or semantically incorrect (seethe namespace of components in inheritance in Section 6.2.3). If youfollow the defensive procedure for programming the AS ABAP using

Page 50: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

373

Inheritance 6.2

ABAP Objects, which was introduced in Section 4.9, the declarationof final classes is always recommended.

The syntax for defining a final class is:

FINALCLASS class DEFINITION FINAL....

ENDCLASS.

In the Class Builder, you create a final class by selecting the Finalcheckbox on the Properties tab (see Figure 6.4). You cannot deriveany more subclasses from a final class. A final class therefore termi-nates a path of the inheritance hierarchy. All instance methods of afinal class are automatically final.

In a non-final class, individual instance methods can be declared asfinal. The syntax is:

METHODS meth FINAL.

In the Class Builder, you can identify an instance method as Final inits Detail view (see Figure 6.5). A final method cannot be redefinedin subclasses. A final method cannot be abstract at the same time. Aclass can be final and abstract at the same time, but only its staticcomponents are usable in this case. Although you can declareinstance components in such a class, it is not recommended.

6.2.7 Static Attributes in Inheritance

To use a static component of a class, instances of the class are notrequired. If instances exist, they share the static components. Howdoes inheritance affect static components, and static attributes inparticular?

Inheritance treeLike all components, a static attribute exists exactly once within apath of the inheritance tree. A subclass can access the contents of thepublic and protected static attributes of all superclasses. Alterna-tively, a superclass shares its public and protected static attributeswith all subclasses. In inheritance, a static attribute is therefore notassigned to a single class, but to a path of the inheritance tree. It canbe accessed from outside via the class component selector (=>) usingall class names involved, or from inside in all affected classes wherea static attribute is visible. Changes to the value are visible in all rel-evant classes. Listing 6.7 shows a simple example.

Page 51: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

374

Advanced Concepts in ABAP Objects6

Listing 6.7 Static Attributes in Inheritance

REPORT z_static_attributes.

CLASS demo DEFINITION.PUBLIC SECTION.CLASS-METHODS main.

ENDCLASS.

CLASS c1 DEFINITION.PUBLIC SECTION.CLASS-DATA a1 TYPE string.

ENDCLASS.

CLASS c2 DEFINITION INHERITING FROM c1....

ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.c2=>a1 = 'ABAP Objects'.MESSAGE c1=>a1 TYPE 'I'.

ENDMETHOD.ENDCLASS.

START-OF-SELECTION.demo=>main( ).

Static constructor When addressing a static attribute belonging to a path of an inherit-ance tree, you always address the class in which the attribute isdeclared, irrespective of the class name used in the class componentselector. This is important for calling the static constructor (see Sec-tion 6.2.8). A static constructor is executed when a class is addressedfor the first time. If a static attribute is addressed via the class nameof a subclass but declared in a superclass, only the static constructorof the superclass is executed.

Static methods Static methods cannot be redefined in ABAP Objects, because staticcomponents should occur exactly once (i. e., not more or less) in apath so that they can be shared by all subclasses.

6.2.8 Constructors in Inheritance

Constructors are used for initializing the attributes of a class (see Sec-tion 4.7). While instance constructors can set the instance attributesof every single object during the instancing process, the static con-structors are responsible for the static attributes of the class beforethe class is first accessed. Because a subclass inherits all attributes of

Page 52: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

375

Inheritance 6.2

its superclasses in inheritance, this automatically begs the question“How can the constructors ensure that the inherited attributes areinitialized as well when the subclass is used?”

Instance Constructors

Every class has a predefined instance constructor named construc-tor. Instance constructors thus deviate from the rule that there areonly unique component names along a path of the inheritance tree.Consequently, the instance constructors of the individual classes ofan inheritance tree must be completely independent of one another.To avoid naming conflicts, the following rules apply:

� Instance constructors of superclasses cannot be redefined in sub-classes.

� Instance constructors cannot be explicitly called via the construc-tor( ) statement.

super->constructorAfter an object has been created with the CREATE OBJECT command,the instance constructor is automatically invoked. Because a subclasscontains all superclass attributes that are visible to it, the contents ofwhich can be set by instance constructors of these classes, theinstance constructor of a subclass must ensure that the instance con-structors of all superclasses are executed as well.13 For this purpose,the instance constructor of every subclass must contain a call

super->constructor( ... ).

of the instance constructor of the direct superclass, even if the con-structor is not explicitly declared. The only exceptions to this rule arethe direct subclasses of the root node, object. The super->construc-tor( ... ) statement is the only exception from the rule that con-structors cannot be explicitly called.

In superclasses in which the instance constructor is not explicitlydeclared and implemented, the implicitly existing implementation ofthe instance constructor is run. It automatically ensures that theinstance constructor of the next higher superclass is called.

Input parametersBefore an instance constructor is run, you must supply its non-optional input parameters. These are searched for as follows:

13 In particular, the private attributes of superclasses can only be initialized in thesuperclasses’ own constructors.

Page 53: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

376

Advanced Concepts in ABAP Objects6

� Provision in CREATE OBJECTStarting with the class of the created object, the first explicitlydefined instance constructor is searched for in the correspondingpath of the inheritance tree. This is the instance constructor of theclass itself, or the first explicitly defined instance constructor of asuperclass.

� Provision in super->constructor( ... )Starting with the direct superclass, the first explicitly definedinstance constructor is searched for in the corresponding path ofthe inheritance tree.

In CREATE OBJECT or in super->constructor( ... ), respectively, theinterface of the first explicitly defined instance constructor is pro-vided with values like a normal method:

� If there are no input parameters, no parameters are transferred.

� Optional input parameters can be provided with values.

� Non-optional input parameters must be provided with values.

If there is no explicitly defined instance constructor in the path of theinheritance tree up to the object root class, no parameters will betransferred.

Inheritance tree For both CREATE OBJECT and super->constructor( ... ), the firstexplicit instance constructor must therefore be regarded and, if oneexists, its interface must be provided with a value. When workingwith subclasses, you therefore need to know the entire path verywell because when creating a subclass object that resides at the lowerend of the inheritance tree, a situation can occur whereby parame-ters must be transferred to the constructor of a superclass positionedmuch closer to the root node.

The instance constructor of a subclass is split into two parts by thesuper->constructor( ... ) call required by the syntax. In the state-ments before the call, the constructor behaves like a static method.Before the call, it does not have access to the instance attributes of itsclass, that is, instance attributes cannot be addressed until after thecall.

3-phase model The execution of a subclass instance constructor can therefore bedivided into three phases that are presented in the comment lines ofListing 6.8.

Page 54: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

377

Inheritance 6.2

Listing 6.8 Three-Phase Model of an Instance Constructor

METHOD constructor." Phase 1: Access to static attributes only..." Phase 2: Execution of super class constructor(s)CALL METHOD super->constructor EXPORTING ..." Phase 3: Access to instance attributes only...

ENDMETHOD.

In the individual phases, the instance constructor can execute the fol-lowing tasks:

� Phase 1Here you can prepare the call of the superclass instance construc-tor, for example, you can determine the actual parameters for itsinterface.

� Phase 2In this phase, the instance constructor of the superclass is exe-cuted, which is again divided into three phases, if implemented.

� Phase 3The attributes of all superclasses are now correctly initialized.Using these values, the necessary initializations for the owninstance attributes can be performed.

Therefore, during the instantiation of a subclass, a nested call of theinstance constructors from the subclass to the superclasses takesplace, where the instance attributes of the highest superclass can beaddressed only as of the deepest nesting level. When returning to theconstructors of the subclasses underneath, their instance attributescan also be addressed successively.

Self-referenceThe methods of subclasses are not visible in constructors. If aninstance constructor calls an instance method of the same class viathe implicit self-reference me, the method is called in the way inwhich it is implemented in the class of the instance constructor, andnot the possibly redefined method of the subclass to be instantiated.This is an exception to the rule that whenever instance methods arecalled, the implementation is called in the class of the instance towhich the reference is pointing.

Listing 6.9 shows the behavior of instance constructors in inherit-ance using a simple example.

Page 55: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

378

Advanced Concepts in ABAP Objects6

Listing 6.9 Instance Constructors in Inheritance

REPORT z_constructor_inheritance.

CLASS demo DEFINITION.PUBLIC SECTION.CLASS-METHODS main.

ENDCLASS.

CLASS vessel DEFINITION.PUBLIC SECTION.METHODS constructor IMPORTING i_name TYPE string.

PROTECTED SECTION.DATA name TYPE string.

ENDCLASS.

CLASS ship DEFINITION INHERITING FROM vessel....

ENDCLASS.

CLASS motorship DEFINITION INHERITING FROM ship.PUBLIC SECTION.METHODS constructor IMPORTING i_name TYPE string

i_fuelamount TYPE i.PRIVATE SECTION.DATA fuelamount TYPE i.

ENDCLASS.

CLASS vessel IMPLEMENTATION.METHOD constructor.name = i_name.

ENDMETHOD.ENDCLASS.

CLASS motorship IMPLEMENTATION.METHOD constructor.super->constructor( i_name ).fuelamount = i_fuelamount.

ENDMETHOD.ENDCLASS.

CLASS demo IMPLEMENTATION.METHOD main.DATA: o_vessel TYPE REF TO vessel,

o_ship TYPE REF TO ship,o_motorship TYPE REF TO motorship.

CREATE OBJECT:o_vessel EXPORTING i_name = 'Vincent',o_ship EXPORTING i_name = 'Mia',o_motorship EXPORTING i_name = 'Jules'

i_fuelamount = 12000.

Page 56: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

379

Inheritance 6.2

ENDMETHOD.ENDCLASS.

START-OF-SELECTION.demo=>main( ).

This example shows three consecutive classes of the inheritance hier-archy. The vessel class has an instance constructor with an inputparameter. From vessel, we derive the ship class that does notexplicitly declare and implement the instance constructor. Fromship, we derive motorship. This class again has an explicit instanceconstructor with two input parameters. We create an object fromevery class and provide the parameter interface of the constructorswith actual parameters. The constructors are called as follows:

� The object created using o_vessel is initialized at CREATE OBJECT inthe explicit instance constructor of vessel, where an attribute isset using the passed actual parameter.

� The object created using o_ship is also initialized at CREATE OBJECTvia the instance constructor of vessel, because it is called by theimplicit instance constructor of ship. Its parameter interfaceneeds to be provided with actual parameters.

� The object created using o_motorship is initialized in the explicitinstance constructor of motorship. In this constructor, theinstance constructor of the direct superclass must be called viasuper->constructor. The implicit instance constructor of shipcalls the explicit instance constructor of vessel. Its parameterinterface needs to be provided with actual parameters.

You can best understand the behavior of the program if you run itline by line in the ABAP Debugger.

Static Constructors

Every class has a static constructor named class_constructor. Withregard to the namespace along an inheritance tree, the same rulesthat apply to the instance constructor also apply to the static con-structor.

CallWhen a subclass is addressed for the first time in a program, its staticconstructor is run. Before that, however, the preceding static con-structors of the entire inheritance tree must have been run. Because

Page 57: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

380

Advanced Concepts in ABAP Objects6

a static constructor should be called only once during the executionof a program, when a subclass is addressed for the first time, the nexthigher superclass is searched whose static constructor has not yetrun. Then this static constructor is executed first, followed by theconstructors of all subclasses up to and including the addressed sub-class. In contrast to instance constructors, a static constructor doesnot have to explicitly call the static constructor of its superclass.Instead, the runtime environment automatically ensures that thestatic constructors are called in the correct order. In a subclass, youcan always assume that the static attributes of the superclasses havebeen correctly initialized.

6.2.9 Instantiation in Inheritance

A subclass includes the object descriptions of all superclasses. Theinstantiation of a subclass therefore means the instantiation of allsuperclasses in a single object, where the initialization of the super-class attributes is ensured by calling the superclass constructors, asdescribed in Section 4.3.2.

The additions CREATE PUBLIC|PROTECTED|PRIVATE of the CLASS state-ment or the corresponding Class Builder settings, respectively, con-trol for each class who can create an instance of the class or call itsinstance constructor (see Section 4.3.2). In inheritance, this results inthree scenarios whose behavior is defined in ABAP Objects as fol-lows:

� Superclass with Public InstantiationThe instance constructor of the superclass is publicly visible. If theinstantiatiability of a subclass is not explicitly specified, it inheritsthe public instantiation of the superclass. The instantiatiability of asubclass can be explicitly specified in one of the three ways. A sub-class can control the visibility of its own instance constructor inde-pendently of the superclass.

� Superclass with Protected InstantiationThe instance constructor of the superclass is visible in subclasses.If the instantiatiability of a subclass is not explicitly specified itinherits the protected instantiation of the superclass. The instan-tiatiability of a subclass can be explicitly specified in one of thethree ways. A subclass can control the visibility of its own instanceconstructor independently of the superclass and can thus also

Page 58: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

381

Standalone Interfaces 6.3

publish the protected instance constructor of the superclass in thespecified section.

� Superclass with Private InstantiationThe instance constructor of the superclass is visible only in thesuperclass. There are two different scenarios here:

� The subclass is not a friend of the superclass.Because only the superclass itself can call its instance construc-tor, the subclass cannot be instantiated. Therefore, the sub-class has an implicit addition, CREATE NONE. The instantiatiabil-ity of the subclass cannot be explicitly specified because thiswould mean a publication of the superclass constructor in thespecified section.

� The subclass is a friend of the superclass.If the instantiatiability of the subclass has not been explicitlyspecified, it inherits the private instantiation of the superclass.The instantiatiability of a subclass can be explicitly specified inone of the three ways. As a friend, a subclass can publish theprivate constructor of the superclass in the specified section.

Private superclassIf a superclass with private instantiation has been defined in a path ofthe inheritance tree, no subclass can be instantiated by externalusers, and a subclass cannot even instantiate itself because it does nothave access to the instance constructor of the superclass! The obviousthing to do would be to make a class defined for private instantiationa final class in order to prevent subclasses from being derived.

Exceptions from this rule only exist if a privately instantiatablesuperclass offers its friendship to its subclasses. This is not often thecase, though, because a superclass usually does not know its sub-classes. However, a superclass can offer its friendship to an interfaceas well, which can then be implemented by its subclasses (see Sec-tion 6.3.3). As always, when offering friendship, you should proceedvery carefully in this case as well, for example, by restricting theusage of the friendly interface to the current package.

6.3 Standalone Interfaces

In ABAP Objects, interfaces of classes can be defined independentlyfrom a class as standalone interfaces.

Page 59: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

382

Advanced Concepts in ABAP Objects6

6.3.1 Basic Principles

Point of contact The only part of a class that is relevant to an external user is its publicinterface that is made up of the components of its public visibilitysection. All other components are irrelevant to the user. This aspectbecomes clear particularly when using abstract methods in abstractclasses (see Section 6.2.5). Basically, such classes are used to definenothing but interfaces that can only be used with objects of sub-classes.

No multipleinheritance

Because ABAP Objects does not support multiple inheritance, theusage of abstract classes for defining interfaces is restricted to theirsubclasses. However, it is also desirable to be able to define generallyvalid interfaces that can equally be used in several classes.

Decoupling Such generally valid interfaces can be provided via standalone inter-faces. Standalone interfaces are independently definable interfaceswithout implementation that can be integrated and implemented inclasses. Standalone interfaces are used to achieve a looser couplingbetween a class and a user, because they provide an additional accesslayer (protocol). Two scenarios are possible:

� A class entirely or partially provides its public interface to the uservia one or several standalone interfaces and thus decouples theuser from the actual class definition. Every standalone interfacedescribes an independent aspect of the class and only providesthis aspect and nothing else to a user. This can positively affect themaintainability of a class.

� A user has an exact idea of how an object should be used anddefines an standalone interface containing all wanted compo-nents. Every class that is to fulfill this task integrates this interfaceand provides the functionality.

BAdI A very nice application example of this decoupling is given by theenhancebility of delivered ABAP application programs in customersystems using Business Add-Ins (BAdIs). BAdIs are based on stan-dalone interfaces that are declared in the original system. The actualfunctionality of a BAdI is provided only in follow-up systems byimplementing the standalone interface in classes.14

14 The comprehensive topic of enhancing and modifying ABAP applications of ASABAP will not yet be discussed in this edition.

Page 60: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

383

Standalone Interfaces 6.3

Interface reference variables

Because standalone interfaces are just interfaces without implemen-tation, you cannot create any objects from them—similar to abstractclasses. Instead, they are integrated and implemented in classes. If aclass implements a standalone interface, it can be addressed via thisinterface. There are specific interface reference variables for this pur-pose. These can point to objects of all classes that contain the respec-tive standalone interface. Because any classes can integrate the sameinterface, their objects can be addressed via the same interface refer-ence variable.

Figure 6.6 illustrates the role of interfaces in a graphical way. In ourrepresentation of objects with a core that is separated from the exter-nal user by a shell, standalone interfaces can be imagined as emptyshells that can be used by classes instead of their own shells or asparts of their own shells.15 For example, if a class wants to provideservices like outputting its attributes in a list or serialization, it canimplement the corresponding standalone interfaces. Users who areonly interested in these different aspects of objects access these viainterface reference variables. In the following sections, we will dis-cuss the language elements shown in Figure 6.6 in detail.

Figure 6.6 Interfaces

15 Compared to Figure 6.1, you can clearly see that the integration of standaloneinterfaces in classes can also be regarded as a multiple inheritance of interfacesto classes. Because standalone interfaces don’t have their own method imple-mentations, there are no conceptual problems like those that occur in multipleinheritance of classes.

CLASS cl_... . INTERFACES: if_serializable ,

if_writeable ... ...

ENDINTERFACE.

INTERFACE if_serializable . METHODS serialize ...

... ENDINTERFACE.

INTERFACE if_writeable . METHODS write_list ...

... ENDINTERFACE.

DATA: iref1 TYPE REF TO if_serializable , iref2 TYPE REF TO if_writeable .

iref1

iref2

METHOD if_serializable ~ serialize . ...

METHOD if_writeable ~ write_list . ...

Page 61: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

384

Advanced Concepts in ABAP Objects6

6.3.2 Creating Interfaces

With regard to their declaration, interfaces in ABAP Objects play thesame role as classes. Just like classes, interfaces are object types thatreside in the namespace of all types. While a class describes allaspects of a class, an interface only describes a partial aspect. As men-tioned above, standalone interfaces can be regarded as specialabstract classes without implementation that can be used in multipleclasses.

Accordingly, the declaration of a standalone interface hardly variesfrom the declaration of a class. As with classes, we distinguish globaland local interfaces in the same way that we do global and localclasses. Therefore, the same rules apply regarding their usability.Global interfaces can be used in any program if the package assign-ment of the program permits it. Local interfaces can only be used inthe same program.

INTERFACE—ENDINTERFACE

The syntax for declaring a local interface is:

INTERFACE intf.DATA ...CLASS-DATA ...METHODS ...CLASS-METHODS ......

ENDINTERFACE.

Basically, the declaration of an interface corresponds to the declara-tion part of a class, where instead of CLASS—ENDCLASS, you simply useINTERFACE—ENDINTERFACE. Interfaces can contain exactly the samecomponents as classes. Unlike classes, however, interfaces don’tneed to be divided into different visibility sections because interfacecomponents are always integrated in the public visibility section ofclasses.

To create a global interface, use the Class Builder just as you wouldfor global classes. In the Object Navigator, select Create � ClassLibrary � Interface. In Transaction SE24, after selecting Create, selectthe Interface object type instead of Class.16

16 If you observe the naming convention IF_... bzw. ZIF_..., an interface is createdautomatically.

Page 62: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

385

Standalone Interfaces 6.3

Class BuilderFigure 6.7 shows the Class Builder for a global interface ZIF_DRIVE_OBJECT. You see the familiar user interface that you know fromworking with classes. When creating components, you need to spec-ify the same input as you do for classes, except for the assignment toa visibility section. In the shown example, we created the samemethods ACCELERATE and SHOW_SPEED as in ZCL_VEHICLE pre-sented in Figure 4.7 in Chapter 4. The shown interface can thereforeserve as an interface to objects that can be driven.

The Class Builder generates the corresponding ABAP statements in aprogram of the interface pool type, the source code of which can alsobe edited directly via Goto � Interface Section (see Figure 6.8). As inclass pools, the addition PUBLIC identifies the interface as a globalinterface that can be used in all programs. Apart from the declarationof the global interface, an interface pool cannot contain any localtype declarations except for the publication of type groups.17

AbstractionThe essential difference between interfaces and classes is that there isno implementation part for an interface. Therefore, it is not neces-sary to add DEFINITION to INTERFACE. The methods of an interface areall abstract. They are fully declared, including their parameter inter-face, but not implemented in the interface. Like the subclasses that

Figure 6.7 Global Interface

17 In interface pools, declarations like these would not be of any use. They are pos-sible in class pools, but can only be used in the private section of the global class.This section does not exist for interfaces.

Page 63: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

386

Advanced Concepts in ABAP Objects6

implement the abstract methods of their abstract superclasses, allclasses that want to use an interface must implement its methods.18

6.3.3 Implementing Interfaces in Classes

Every class can implement one or more interfaces. The essentialrequirement for implementing an interface is that the interface isknown to the implementing class. Therefore, it must be declared glo-bally in the class library or locally in the same program. Additionally,the usage of the interface must be permitted by the package assign-ment.

INTERFACES The syntax for implementing interfaces is:

CLASS class DEFINITION.PUBLIC SECTION.INTERFACES: intf1, intf2 ......

...ENDCLASS.

Interfaces are therefore integrated using the INTERFACES statement inthe public visibility section of a class. Only global interfaces can beintegrated in the public visibility section of a global class. You can dothis on the Interfaces tab of Class Builder.

Figure 6.8 Source Code of an Interface Pool

18 Strictly speaking, however, this similarity applies only to instance methods. Ininterfaces, you can also define static methods without implementation. This isnot possible in abstract classes because static methods cannot be redefined.

Page 64: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

387

Standalone Interfaces 6.3

In Figure 6.9, we copied the ZCL_VEHICLE class shown in Figure 4.7to a new class ZCL_VEHICLE_WITH_INTF, deleted its method, andspecified the interface ZIF_DRIVE_OBJECT shown in Figure 6.7. Inthe Abstract and Final columns, you can specify that all methods ofthe interface should be either abstract or final in the class. In theINTERFACES statement, this is expressed by the optional addition ALLMETHODS ABSTRACT|FINAL.

intf~compImplementing an interface extends the public interface of the classby the interface components. Every comp component of an imple-mented intf interface becomes a full component of the class and isidentified within the class via the name

... intf~comp ...

Interface components are inherited to subclasses like class-specificpublic components. A class can have its own component of the samename like an interface component, or various implemented inter-faces can contain components of the same name. All reside in onenamespace and are distinguished in the class by different intf~ pre-fixes. The tilde sign (~) is the interface component selector.

Figure 6.10 shows how the methods of the interface ZIF_DRIVE_OBJECT are presented in ZCL_VEHICLE_WITH_INTF. In the detailedview (see Figure 6.5), you can specify for every single method if it isto be abstract or final. The INTERFACES statement has the optionaladditions for this purpose, ABSTRACT METHODS and FINAL METHODS.

Figure 6.9 Integrating the Interface

Page 65: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

388

Advanced Concepts in ABAP Objects6

Otherwise, however, an interface method can no longer be changedin a class. The same applies to interface attributes. The only propertythat can be changed when integrating it in a class is the initial value(addition DATA VALUES to INTERFACES).

A class must implement all concrete (non-abstract) methods of allintegrated interfaces in its implementation part. In the Class Builder,this is achieved via the usual procedure, by selecting Code for everyinterface method. In the ZCL_VEHICLE_WITH_INTF class, we basi-cally used the method implementations of ZCL_VEHICLE (see Listing6.10).

Listing 6.10 Implementation of Interface Methods

CLASS zcl_vehicle_with_intf IMPLEMENTATION.METHOD zif_drive_object~accelerate.speed = speed + delta.

ENDMETHOD.METHOD zif_drive_object~show_speed.DATA output TYPE string.output = speed.CONCATENATE `Vehicle speed: ` output INTO output.MESSAGE output TYPE 'I'.

ENDMETHOD.ENDCLASS.

If a class does not declare its own components in its public visibilitysection, but only integrates standalone interfaces, the entire public

Figure 6.10 Interface Methods

Page 66: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

389

Standalone Interfaces 6.3

interface of the class is defined via standalone interfaces; and stan-dalone interfaces and its public interface are indeed the same for thisclass. This applies to our sample class ZCL_VEHICLE_WITH_INTF.The interface to the outside world that had so far been built of theclass’s own components is now completely outsourced to the ZIF_DRIVE_OBJECT interface.

Listing 6.11 summarizes what we have just described using theexample of a local interface. The public interface of the vehicle classfrom Listing 4.5 is outsourced to a local standalone interface; how-ever, the local vehicle class could just as easily implement the globalinterface ZIF_DRIVE_OBJECT instead of a local interface drive_object.

Listing 6.11 Declaration and Implementation of a Local Interface

REPORT z_vehicle_with_intf.

INTERFACE drive_object.METHODS: accelerate IMPORTING delta TYPE i,

show_speed.ENDINTERFACE.

CLASS vehicle DEFINITION.PUBLIC SECTION.

INTERFACES drive_object.PRIVATE SECTION.

DATA speed TYPE i.ENDCLASS.

CLASS vehicle IMPLEMENTATION.METHOD drive_object~accelerate.

speed = speed + delta.ENDMETHOD.METHOD drive_object~show_speed.

DATA output TYPE string.CONCATENATE `Vehicle speed: ` output INTO output.output = speed.MESSAGE output TYPE 'I'.

ENDMETHOD.ENDCLASS.

6.3.4 Access to Interfaces of Objects

Objects are always accessed via object reference variables. Untilnow, we worked with object reference variables that were declaredwith a reference to a class:

Page 67: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

390

Advanced Concepts in ABAP Objects6

Class referencevariable

DATA cref TYPE REF TO class.

By using these reference variables, you can address all those compo-nents of an object’s class class that are visible at the current posi-tion. This kind of object reference variable is therefore referred to asa class reference variable.

As you saw in the previous section, the interface components of aninterface implemented in a class are handled as full components. Youmight therefore be tempted to address the interface components ofan object as follows:

... cref->intf~comp ...

In point of fact, this works. You can try this with our ZCL_VEHICLE_WITH_INTF class; however, this kind of access is not recommended.The external user of a class should be able to access its componentswithout having to worry about the technical composition of theinterface. Standalone interfaces and the class-specific componentsboth define different sets of components. They should be useddirectly, but not in mixed forms as shown above. In short, the inter-face component selector should only be used within classes (andinterfaces, see Section 6.3.6).

To access the interface components of objects, ABAP Objectsincludes interface reference variables. These are object reference var-iables that are declared with a reference to an interface:

Interface referencevariables

DATA ref TYPE REF TO intf.

An interface reference variable can point to the objects of all classesimplementing the intf interface. Using such a reference variable, allcomponents of the interface of an object can be addressed directly via

... iref->comp ...

In contrast to cref->intf~comp, the interface reference variableiref->comp expresses that components of a class are accessed that arehierarchically on the same level but reside in a different part of theinterface. An interface reference variable enables you to addressthose components of an object that were added to the object’s classvia the implementation of the intf interface that was used to declarethe class. Other components—class-specific components or compo-nents of other interfaces—cannot be addressed via an interface refer-ence variable (not even dynamically, see Sections 11.1.1 and 11.4.1).

Page 68: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

391

Standalone Interfaces 6.3

Figure 6.11 shows how class and interface reference variables pointto the same object, where the interface reference variable onlyknows its own interface components, and the class reference varia-ble should only be used to address the non-interface components ofthe class.

Up CastThe code in Figure 6.11 already shows how interface reference vari-ables can point to objects. You can simply assign a class referencevariable pointing to an object to an interface reference variable. Usu-ally, this is an up cast (see Section 6.4.2 for more information).

This can be accomplished even more comfortably if you’re onlyinterested in the interface components of a class. For example, youare naturally only interested in the interface components of a class ifthe entire public interface of a class is defined via an standaloneinterface. In these situations, creating the objects of the class via aninterface reference variable will suffice:

CREATE OBJECTCREATE OBJECT iref TYPE class EXPORTING ...

Via the TYPE addition, you specify the class of the object to be createdand provide the instance constructor with EXPORTING, if necessary.However, you don’t need a class reference variable to create theobject. The only prerequisite is that the class class (or one of itssuperclasses) contain the intf interface.

User viewA user of object reference variables usually works with objects with-out having to deal with the details of their implementation. In con-

Figure 6.11 Interface Reference Variables

DATA: cref TYPE REF TO class , iref TYPE REF TO intf .

CREATE OBJECT cref .

iref = cref .

cref

iref

intf~comp

comp

Page 69: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

392

Advanced Concepts in ABAP Objects6

trast to the work with class reference variables, a user of an interfacereference variable normally doesn’t even need to know from whichclass the object it is working with originates.

The example shown in Listing 6.12 demonstrates the usage of inter-face reference variables. The methods main and output of the democlass exclusively work with such object reference variables that wereall created with a reference to our sample interface ZIF_DRIVE_OBJECT. For this purpose, an internal table type is declared in demothe line type of which is such a reference type. In addition to our glo-bal sample class CL_VEHICLE_WITH_INTF, we have also created alocal class electron that contains the standalone interface as well,but specifically implements the methods by storing the speed inunits of the speed of light (c=300.000).

From each of the two classes, an object is created and accelerated,and the object reference is appended to an internal table. Then thistable is transferred to the output method where the show_speedinterface method is executed line by line.

Listing 6.12 Standalone Interface Reference Variables

REPORT z_drive_many_objects.

CLASS demo DEFINITION.PUBLIC SECTION.CLASS-METHODS main.

PRIVATE SECTION.TYPES iref_tab_type TYPE TABLE OF

REF TO zif_drive_object.CLASS-METHODS output IMPORTING iref_tab

TYPE iref_tab_type.ENDCLASS.

CLASS electron DEFINITION.PUBLIC SECTION.INTERFACES zif_drive_object.

PRIVATE SECTION.CONSTANTS c TYPE i VALUE 300000.DATA speed_over_c TYPE p DECIMALS 3.

ENDCLASS.

CLASS electron IMPLEMENTATION.METHOD zif_drive_object~accelerate.me->speed_over_c = me->speed_over_c + delta / c.

ENDMETHOD.METHOD zif_drive_object~show_speed.

Page 70: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

393

Standalone Interfaces 6.3

DATA output TYPE string.output = me->speed_over_c.CONCATENATE `Electron speed/c: ` output INTO output.MESSAGE output TYPE 'I'.

ENDMETHOD.ENDCLASS.

CLASS demo IMPLEMENTATION.

METHOD main.DATA: iref_tab TYPE iref_tab_type,

iref LIKE LINE OF iref_tab.CREATE OBJECT iref TYPE zcl_vehicle_with_intf.iref->accelerate( 100 ).APPEND iref TO iref_tab.CREATE OBJECT iref TYPE electron.iref->accelerate( 250000 ).APPEND iref TO iref_tab.demo=>output( iref_tab ).

ENDMETHOD.

METHOD output.DATA iref LIKE LINE OF iref_tab.LOOP AT iref_tab INTO iref.iref->show_speed( ).

ENDLOOP.ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.demo=>main( ).

Although the example is similar to the one shown in Listing 4.8, ithas a completely new quality. As before, the internal table is a collec-tion of pointers to objects. Because these pointers are interface refer-ence objects, however, the classes and thus the behavior of theobjects managed by an internal table can vary.

You should pay special attention to the output method. This methodis an example of the user mentioned above who works with objectswithout knowing their classes. The output method receives a tablewith reference variables and knows that it can call a show_speedmethod there. The actual implementation is irrelevant to it. Thismatches the concept of polymorphism that is illustrated in Figure6.14 exactly and will be further discussed in the corresponding sec-tion. For the moment, it will suffice just to note that syntacticallyidentical method calls in a loop lead to different output.

Page 71: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

394

Advanced Concepts in ABAP Objects6

6.3.5 Access to Static Interface Components

Because interfaces can contain the same components as classes, staticcomponents are possible as well. You cannot access the static compo-nents of an interface using the name of the interface and the classcomponent selector. The only exceptions are constants declared viaCONSTANTS:

... intf=>const ...

The static components belong to the static components of everyimplementing class. This means that static attributes have differentvalues depending on the class and that static methods can be differ-ently implemented in every class. To access the static components ofinterfaces, independently of the instance, you would have to use thename of an implementing class and the interface component selec-tor:

... class=>intf~comp ...

Alias names However, this should be the exception for the reasons mentioned inSection 6.3.4. Instead, implementing classes should declare aliases(see Section 6.3.7) for the static components of interfaces and there-fore make them addressable via the class name like their own staticcomponents. Naturally, you can always use interface reference varia-bles for accessing static components after you created objects fromthe implementing classes.

6.3.6 Composing Interfaces

In Figure 6.9, it is apparent that the Class Builder provides the Inter-faces tab as well for an interface as it does for a class. Accordingly,the INTERFACES statement cannot only be used in classes but also inthe declaration of an interface:

INTERFACE intf1.INTERFACES: intf2, intf3, ......

ENDINTERFACE.

Componentinterface

This mechanism allows you to compose several interfaces into oneinterface. The composition of interfaces can be useful when mode-ling complex applications.

Page 72: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

395

Standalone Interfaces 6.3

The set of components of an interface intf1 that integrates addi-tional interfaces (i. e., intf2, intf3, ...) are composed of its own com-ponents and the components of the integrated interfaces. The com-ponents all reside on the same level. An interface containing at leastone other interface is called composite or nested interface. An inter-face integrated in another interface is called a component interface.A component interface can be composed itself. Let’s now look at thenesting of interfaces shown in Listing 6.13.

Listing 6.13 Composite Interfaces

INTERFACE intf1....

ENDINTERFACE.

INTERFACE intf2.INTERFACES: intf1 ......

ENDINTERFACE.

INTERFACE intf3.INTERFACES: intf1, intf2 ......

ENDINTERFACE.

The composite interface intf3 has a component intf2 that is com-posed itself. Although it seems like the nesting of several interfacescaused a component hierarchy, this is not the case. All componentinterfaces of a composite interface are on the same level. A nesting ofnames like intf3~intf2~intf1 is not possible.

In the example above, the component interface intf1 of the compos-ite interface intf2 becomes a component interface of intf3. A com-posite interface contains each component interface exactly once.Although intf1 is integrated in intf3 both directly as a componentinterface of intf3 and indirectly via intf2, it only occurs once. Inintf3, it can only be addressed under the name intf1, even if it wasnot integrated directly.

ImplementationIf a composite interface is implemented in a class, all interface com-ponents of the interface behave as if their interface had been imple-mented only once. The interface components of the individual com-ponent interfaces extend the public interface of the class by itsoriginal name. Because every interface is included exactly once in acomposite interface, naming conflicts cannot occur. The way an

Page 73: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

396

Advanced Concepts in ABAP Objects6

implemented interface is composed is irrelevant when it is imple-mented in a class. Next, let’s look at the example shown in Listing6.14:

Listing 6.14 Implementation of Composite Interfaces

INTERFACE intf1.METHODS meth.

ENDINTERFACE.

INTERFACE intf2.INTERFACES intf1.METHODS meth.

ENDINTERFACE.

INTERFACE intf3.INTERFACES intf1.METHODS meth.

ENDINTERFACE.

INTERFACE intf4.INTERFACES: intf2, intf3.

ENDINTERFACE.

CLASS class DEFINITION.PUBLIC SECTION.INTERFACES intf4.

ENDCLASS.

CLASS class IMPLEMENTATION.METHOD intf1~meth. ... ENDMETHOD.METHOD intf2~meth. ... ENDMETHOD.METHOD intf3~meth. ... ENDMETHOD.

ENDCLASS.

A method meth of the same name is declared in three individual inter-faces and thus implemented in three different ways using the inter-face component selector. The composition of the interfaces does notplay any role. The intf1~meth method is implemented only once,although it occurs in two interfaces, intf2 and intf3. The nameintf4 does not show up in the implementation part of the class at all.

If you list one or more of the other interfaces—intf1, intf2, orintf3—in addition to intf4 in the declaration part of the class men-tioned above, the components and the implementation part of theclass do not change at all, because the compiler always ensures for aclass as well as in composite interfaces that every component existsonly once.

Page 74: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

397

Standalone Interfaces 6.3

AccessIf the class of an object implements a composite interface, the objectis accessed in the same way as if the class implemented every inter-face individually. This means that interface components should beaccessed using interface reference variables of the type of the appro-priate component interface. This can always be achieved using thecorresponding assignments to interface reference variables (up casts,see Section 6.4.2). The interface component selector should not beused for this purpose; however, it can be used in a composite inter-face to make the components of component interfaces as accessibleas native components via aliasing.

6.3.7 Alias Names for Interface Components

The complete name of a component that is added via an interface toa class or another interface is intf~comp. For this name, you candefine an alias name at the level at which the interface is integratedusing the INTERFACES statement:

ALIASESALIASES name FOR intf~comp.

Alias names can be assigned when interfaces are implemented in thedeclaration part of a class or when interfaces are composed in the dec-laration of an interface. In the Class Builder, you can enter alias namesfor classes and for interfaces in the Aliases tab (see Figure 6.12).

Alias Names in Classes

In classes, alias names belong to the namespace of the components ofa class and must be assigned to a visibility section just like the other

Figure 6.12 Alias Names

Page 75: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

398

Advanced Concepts in ABAP Objects6

components. The visibility of an alias name from outside the classdepends on its visibility section and not on the visibility section ofthe assigned interface component.

In Listing 6.15, we modify the example of Listing 6.12 by using aliasnames. For this purpose, in the local class electron, we declare an aliasname accelerate for the zif_drive_object~accelerate interfacemethod as we did for ZCL_VEHICLE_WITH_INTF (see Figure 6.12).Listing 6.15 shows only the differences between it and Listing 6.12.

Listing 6.15 Alias Names in Classes

REPORT z_drive_via_aliases.

...

CLASS electron DEFINITION.PUBLIC SECTION.INTERFACES zif_drive_object.ALIASES accelerate FOR zif_drive_object~accelerate.

PRIVATE SECTION....

ENDCLASS.

CLASS electron IMPLEMENTATION.METHOD accelerate.me->speed_over_c = me->speed_over_c + delta / c.

ENDMETHOD....

ENDCLASS.

CLASS demo IMPLEMENTATION.

METHOD main.DATA: vehicle TYPE REF TO zcl_vehicle_with_intf,

electron TYPE REF TO electron,iref_tab TYPE iref_tab_type.

CREATE OBJECT vehicle.vehicle->accelerate( 100 ).APPEND vehicle TO iref_tab.CREATE OBJECT electron.electron->accelerate( 250000 ).APPEND electron TO iref_tab.demo=>output( iref_tab ).

ENDMETHOD.

...

ENDCLASS.

START-OF-SELECTION.demo=>main( ).

Page 76: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

399

Standalone Interfaces 6.3

The interface method can now be implemented in the class via itsalias name and called by a user like a direct method of the class. Here,we change the main method in which the classes for the object crea-tion must be known, anyway so that the objects are created via classreference variables. Because of the alias name, the class referencevariables can be used to call the interface method accelerate with-out using the interface component selector. Nothing is changed inthe output method, which does not need to know the classes.

Using alias names, a class can publish its interface components asclass-specific components, so to speak. In particular, alias names canbe used in classes to further on address class-specific componentsthat are outsourced to standalone interfaces in the course of a devel-opment cycle using their old name. Then, the users of the class don’tneed to be adapted to the new names.

In our sample class ZCL_VEHICLE_WITH_INTF, we converted themethods from ZCL_VEHICLE to interface methods. Just imagine if wehad made this change directly in ZCL_VEHICLE! All users would havebecome syntactically incorrect. By introducing alias names simultane-ously, however, the class would have remained addressable.

Alias Names in Composite Interfaces

Because names cannot be concatenated in composite interfaces, aliasnames provide the only means of addressing those components thatwould otherwise not be available in the composite interface. Let’slook at the example shown in Listing 6.16.

Listing 6.16 Alias Names in Interfaces

INTERFACE intf1.METHODS meth1.

ENDINTERFACE.

INTERFACE intf2.INTERFACES intf1.ALIASES meth1 FOR intf1~meth1.

ENDINTERFACE.

INTERFACE intf3.INTERFACES intf2.ALIASES meth1 FOR intf2~meth1.

ENDINTERFACE.

Page 77: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

400

Advanced Concepts in ABAP Objects6

The intf3 interface can use the alias name meth1 in intf2 to addressthe meth1 component of the intf1 interface in its own ALIASES state-ment. Without alias names in intf2, this would not be possiblebecause the name intf2~intf1~m1 is not permitted. Now the user ofintf3 can access the component meth1 in intf1 without having toknow anything about the composition of the interface:

DATA i_ref TYPE REF TO intf3....i_ref->meth1( ... ).

Without alias names in intf3, the access would look as follows:

i_ref->intf1~meth1( ... ).

The user would have to know that intf3 is composed of intf2,which is composed of intf1. For global interfaces, in particular, theuser should not have to look at the composition of an interface in theClass Builder before he can use a method of the interface. Of course,it is not necessary that the alias names always match the originalnames.

6.3.8 Interfaces and Inheritance

To conclude the description of interfaces, we will discuss the rela-tionship of standalone interfaces to inheritance and compare bothconcepts in a summary.

The concepts of standalone interfaces and inheritance are independ-ent of each other and totally compatible. Any number of interfacescan be implemented in the classes of an inheritance tree, but everyinterface can be implemented only once per inheritance tree path.Thus, every interface component has a unique name intf~compthroughout the inheritance tree and is contained in all subclasses ofthe class implementing the interface. After their implementation,interface methods are full components of a class and can be rede-fined in subclasses. Although interface methods cannot be identifiedas abstract or final in the interface declaration, every class can specifythese settings when implementing the interface.

Coupling The usage of inheritance always makes sense when different classeshave a generalization/specialization relationship. For example, if we

Page 78: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

401

Standalone Interfaces 6.3

regard two classes “cargo plane” and “passenger plane”, both classescontain components that can be declared in a common “plane”superclass. The big advantage of inheritance is that the subclassestake on and reuse all properties already programmed in the super-class. At the same time, this causes a very tight coupling betweensuperclasses and subclasses. A subclass strongly depends on itssuperclass, because it often largely consists of the superclass compo-nents. A subclass must know its superclass exactly. This became par-ticularly clear, for example, in the discussion of instance constructorsin inheritance (see Section 6.2.8). Every change to non-private com-ponents of a superclass changes all of its subclasses. Conversely, sub-classes can also affect the design of superclasses due to specificrequests. If you use inheritance for defining classes, you should ide-ally have access to all classes involved because only all of the classesin a path of the inheritance tree make a reasonable whole. On theother hand, it is dangerous to just link to some superclass by defininga subclass if the superclass does not belong to the same package, orwas explicitly shared as a superclass in the package interface.19

DecouplingThe implementation of interfaces is always recommended wheninterfaces or protocols are to be described without having to use aspecific type of implementation. An additional layer is introducedbetween user and class that decouples the user from an explicit classand therefore makes it much more independent. Interfaces allow theuser to handle the most different classes, which don’t need to berelated to each other. In object-oriented modeling, interfaces pro-vide an abstraction that is independent of classes. Irrespective of theactual implementation, the services required by a user can bedescribed. Additionally, interfaces also implement an aspect of mul-tiple inheritance, because several interfaces can be implemented in aclass. If a programming language permits a real multiple inheritance,this multiple inheritance is usually used in the sense of interfaces aswell. This means that only abstract classes with exclusively abstractmethods are suitable as different superclasses of a single subclass.Otherwise, the question would arise regarding which method imple-mentation is actually used in a subclass if it is already implemented

19 A complete package concept that allows you to predefine and check such speci-fications in the package interface will only be implemented in the next SAPNetWeaver release.

Page 79: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

402

Advanced Concepts in ABAP Objects6

in several superclasses.20 As with superclasses in inheritance, youshould note that for interfaces as well later changes to an interfacemight make all classes implementing the interface syntacticallyincorrect.

6.4 Object References and Polymorphism

Object references are the linchpin when dealing with objects. Theyare used for creating and addressing objects. As the contents ofobject reference variables, they can be assigned to other variables orpassed to procedures.

Object reference variables are divided into class reference variablesand interface reference variables. When using interface referencevariables, we already observed that the type of a reference variabledoes not have to match the type of the referenced object. In this sec-tion, we will have a closer look at this fact and at the resulting poly-morphic behavior of method calls.

6.4.1 Static and Dynamic Type

In this section, we define two important terms for reference varia-bles, that is, their static type and dynamic type.

Static type The static type of a reference variable oref is the type that is specifiedafter

... oref TYPE REF TO class|intf ...

in the declaration. As with all data objects, the static type is fixedduring the entire runtime of a program. For object reference varia-bles, the object types class for class reference variables and intf forinterface reference variables are possible as static types.21

20 This is the “diamond” problem of multiple inheritance. A method that isdeclared in a superclass is redefined in two subclasses, which, in turn, make upthe superclass of another subclass. Which implementation is used in this sub-class? For interfaces, this problem does not occur, because in the implementa-tion of composite interfaces every interface method exists only once.

21 Accordingly, data types are possible as static types for data reference variablesthat can point to data objects (see Section 11.1.2).

Page 80: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1019

Index

- (structure component selector) 245#EC (extended program check) 945$TMP package 61& (literal operator) 269(F1) help, dynpro 548(F4) help, dynpro 549* (Comment) 85:: (statement chain) 94< (relational operator) 293<= (relational operator) 293<> (relational operator) 293= (assignment operator) 273= (relational operator) 293=> (class component selector) 129, 198-> (object component selector) 129, 204,

250> (relational operator) 293->* (dereferencing operator) 250, 811>= (relational operator) 293?= (casting operator) 409, 817~ (column selector) 722, 728~ (interface component selector) 3874GL

fourth-generation language 24, 25

A

Amessage type 670

ABAPAdvanced Business Application

Programmning 23classic 449Generic Report Generation Processor 23programming models 450requirements 30

ABAP Debuggerclassical 951configuring 954new 951tool 950use 959user interface 952using 97

ABAP Dictionarydynpro field 531storage 69tool 69, 254

ABAP Editorconfiguring 84direct entry 57

ABAP glossaryABAP keyword documentation 138

ABAP keyword documentationopening 94using 136

ABAP memorydata cluster 785main mode 174

ABAP ObjectsABAP 24object orientation 180use 26, 221Using 110

ABAP processorAS ABAP 147

ABAP programactivating 88call 156copying 91creation 82design 152execute 155executing 89load 155, 175modularization 183testing 939type 159

ABAP runtime analysistool 980

ABAP Runtime environmentAS ABAP 150

ABAP runtime environmentAS ABAP 143virtual machine 88

ABAP scriptingBSP 671

ABAP syntaxcomments and statements 84

Page 81: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1020

Index

statement chain 94ABAP type

built-in 236generic 263

ABAP UnitCode Inspector 970organization 963tool 961use 964

ABAP wordABAP statement 85

ABAP WorkbenchAS ABAP 143development environment 54programming tools 56

ABAP/4R/3 24

absnumeric function 287

ABSTRACTCLASS 370METHODS 370

Abstractinterface 385

Abstractionobject orientation 179

Accessibilityproduct standard 658

acosfloating point function 287

ActionWeb Dynpro ABAP 692

Activationrepository object 74

Actual parameterevent 426function module 472transfer 355

ADDABAP statement 286

Additional data element documentationfield help 549

Agentclass 190, 210

Aggregate functionSELECT clause 715, 732

Alias nameclass 397interface 399

interface component 397ALIASES

ABAP statement 397ALL

WHERE clause 732ALL INSTANCES

SET HANDLER 431Alternative column name

SELECT clause 715Alternative table name

SELECT 728ALV

example 609print list 663SAP List Viewer 134, 593

ALV grid controlCFW 593

ALV listreporting 660

ANDBoolean operator 297WHERE clause 721

AND RETURNSUBMIT 157

Anonymous data objectcreation 812data type 813dynamic memory object 972usage 814

ANYWHERE clause 732

anygeneric type 264

ANY TABLEgeneric table type 324

any tablegeneric type 264

APPENDABAP statement 329

APPENDING TABLEINTO clause 716

Application componentpackage 64

Application controlCFW 591

Application eventGUI control 597

Application layerAS ABAP 147

Page 82: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1021

Index

Application serverAS ABAP 171usage type 142

Application Server ABAPSAP NetWeaver 143

Application Server JavaSAP NetWeaver 143

Application toolbarfunction 536SAP GUI 516, 534selection screen 636

Architectureservice-oriented 892

Archival parametersspool request 655

ArchiveLinkprint list 654

Areacreating 437properties 437

Area classShared Objects 435

AREA HANDLECREATE OBJECT 442

Area handleattaching 441Shared Objects 435

Area instance versionShared Objects 435

Area instancesShared Objects 435

Area root classshared objects 435

aRFCasynchronous RFC 846executing 855use 846

Arithmetic expressioncalculation expression 286

ASApplication Server 142

AS ABAPApplication Server ABAP 24, 143availability 37system 171trial version 37, 48

AS JavaApplication Server Java 143

AS WINDOWSELECTION-SCREEN 630

ASAPABAP objects 344

ASCENDINGSORT 335

asinfloating point function 287

ASSERTABAP statement 509

Assertionadvantages 509confirmation 508using 509

ASSIGNABAP statement 800dynamic 830

ASSIGN COMPONENTABAP statement 803

ASSIGN INCREMENTABAP statement 805

ASSIGNINGLOOP 331READ TABLE 330

Assignmentdata object 273down cast 409dynamically formatted 830elementary data object 275formatted 284internal table 281reference variable 282structure 279up cast 406

asXMLABAP Serialization XML 921

Asynchronous communicationtRFC 860

AT END OFABAP statement 332

AT EXIT COMMANDMODULE 546

AT NEWABAP statement 332

AT SELECTION-SCREENevent 453selection screen event 631

atanfloating point function 287

Page 83: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1022

Index

ATRAtransaction 981

Attributecreation 192declaring 116object orientation 178, 342XML 912

AUTHORITY_CHECK_TCODEauthorization check 792

AUTHORITY-CHECKABAP statement 792

Authorizationauthorization check 790checking 791

Authorization checkAS ABAP 789

Authorization groupauthorization check 792

Authorization objectauthorization check 790

Authorization profileauthorization check 791

Automation ControllerCFW 588

Automation queueCFW 595

AVGaggregate function 715

B

BACKABAP Statement 646

Background jobscheduling 451

Background processtRFC 860

Background processingexecutable program 451, 641scheduling 644

BACKGROUND TASKCALL FUNCTION 859

Background taskbackground request 641

BAdIinterface 382

Base listclassical list 647displaying 648

BEGIN OFTYPES/DATA 244

BEGIN OF BLOCKSELECTION-SCREEN 628

BEGIN OF LINESELECTION-SCREEN 628

BEGIN OF TABBED BLOCKSELECTION-SCREEN 628

BETWEENpredicate 296WHERE clause 722

bgRFCBackground RFC 862

Bit expressioncalculation expression 286

Blockselection screen 628

Boolean operatorlogical expression 297

Branchconditional 298control structure 298

BREAK-POINTABAP statement 957

BreakpointABAP Debugger 956Setting 96

Browser controlCFW 592example 608

BSPBusiness Server Pages 145, 515, 671

Built-in typeABAP Dictionary 253ABAP program 236

BundlingSAP LUW 744

Business keyobject identity 759

Business Server PageAS ABAP 145

Buttonscreen element 527Web Dynpro ABAP 691

BYSORT 335

BYPASSING BUFFEROpen SQL 753

Page 84: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1023

Index

Byte codeABAP program 88

Byte fielddata object 237, 241

Byte stringdata object 242processing 303

BYTE-CArelational operator 296

BYTE-CNrelational operator 296

BYTE-COrelational operator 296

BYTE-CSrelational operator 296

Byte-likedata type 237

BYTE-NArelational operator 296

BYTE-NSrelational operator 296

C

cABAP type 236, 239

CArelational operator 296, 316

Calculation expressionABAP syntax 286

Calculation typecalculation expression 288

CALL FUNCTIONABAP statement 472dynamic 835

Call hierarchyexception handling 487

CALL METHODABAP statement 356dynamic 832

CALL SCREENABAP statement 520, 522

CALL SELECTION-SCREENABAP statement 630

Call sequencemain session 174

CALL SUBSCREENdynpro statement 581

CALL TRANSACTIONABAP statement 521

CALL TRANSFORMATIONABAP program 929ABAP statement 920iXML Library 914

CALL TRANSACTIONABAP statement 158

Callback routineaRFC 855context menu 539

CASEABAP statement 299control structure 299

Case distinctioncontrol structure 299

CASTINGASSIGN 807

Castingfield symbol 806

Casting operatordown cast 409

CATCHABAP statement 484

CATCH blockTRY control structure 485

CATCH SYSTEM-EXCEPTIONSABAP statement 500

Catchable runtime erroruse 501

CATTtool 986

ceilnumeric function 287

CFWControl Framework 588

CHAINdynpro statement 544, 548

Change and Transport SystemCTS 62

CHANGINGActual parameter 356FORM 474METHOD 195METHODS 346PERFORM 475

Character stringfind/replace 306

Page 85: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1024

Index

operation 305processing 303

Character-likedata type 237

charlendescription function 287, 315

CHECKABAP statement 302

Check Indicatorauthorization check 791

Check tabledynpro 546foreign key 81input help 550

Check variantCode Inspector 946

CHECKBOXPARAMETERS 619

Checkboxscreen element 527selection screen 619

Checking typing 351Checkpoint

ABAP program 957Checkpoint group

assertion 510breakpoint 957

CL_ABAP_CLASSDESCRRTTI 823

CL_ABAP_MATCHERregular expression 312

CL_ABAP_MEMORY_AREAshared objects 441

CL_ABAP_REGEXregular expression 312

CL_ABAP_STRUCTDESCRRTTI 823

CL_ABAP_TYPEDESCRRTTI 820

CL_AUNIT_ASSERTABAP Unit 968

CL_CTMENUcontext menu 539

CL_GUI_ALV_GRIDCFW 593

CL_GUI_CFWCFW 589

CL_GUI_CONTROLCFW 589

CL_GUI_CUSTOM_CONTAINERCFW 590

CL_GUI_DIALOGBOX_CONTAINERCFW 590

CL_GUI_DOCKING_CONTAINERCFW 590

CL_GUI_FRONTEND_SERVICESsystem class 781

CL_GUI_HTML_VIEWERCFW 592

CL_GUI_OBJECTCFW 589

CL_GUI_PICTURECFW 591

CL_GUI_SIMPLE_TREECFW 592

CL_GUI_SPLITTER_CONTAINERCFW 590

CL_GUI_TEXTEDITCFW 592

CL_GUI_TOOLBARCFW 591

CL_HTTP_UTILITYICF 890

CL_SALV_EVENTS_TABLEALV 660

CL_SALV_FUNCTIONSALV 660

CL_SALV_HIERSEQ_TABLEALV 599

CL_SALV_PRINTALV 664

CL_SALV_TABLEALV 599

CL_SALV_TREEALV 599

CL_SHM_AREAshared objects 441

CLASSABAP statement 184

ClassABAP Objects 180abstract 370concrete 370creation 112, 183final 373global 182local 182object orientation 342

Page 86: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1025

Index

object type 182property 189testing 125

Class actorObject Services 757

Class actorscreate 759

Class Buildertool 184using 113

Class component selectorABAP syntax 198inheritance 373

Class constructorcreation 114

CLASS POOLABAP statement 159

Class poolABAP program 219program type 159

Class reference variableABAP Objects 390

class_constructorstatic constructor 217

CLASS-DATAABAP statement 192

CLASS-EVENTSABAP statement 424

Classic ABAPuse 460

Classical exceptionfunction module 469

Classical listcreating 645dynpro sequence 649encapsulation 658event 651executable program 647formatting 646processing 649transaction 648

CLASS-METHODSABAP statement 195

ClauseOpen SQL 712

Clausesspecified dynamically 830

CLEANUPABAP statement 484

CLEANUP blockleaving 490TRY control structure 485use 489

CLEARABAP statement 285

ClientAS ABAP 751SAP system 72

Client columndatabase table 751

Client fielddatabase table 72

Client handlingOpen SQL 751

Client IDSAP system 72

Client programweb service 906

Client proxyweb service 905

CLIENT SPECIFIEDOpen SQL 752

Client-server architectureAS ABAP 144

clikegeneric type 264

CLOSE CURSORABAP statement 736

CLOSE DATASETABAP statement 778

CNrelational operator 296, 316

COrelational operator 296, 316

Code Inspectorframework 950tool 945

COLLECTABAP statement 328

COMMENTSELECTION-SCREEN 628

Comment 85Comment line

ABAP program 85Commit

database 742COMMIT WORK

ABAP statement 746, 860

Page 87: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1026

Index

Persistence Service 770Communication

asynchronous 843synchronous 843

Communication scenariosRFC 849

COMMUNICATION_FAILURERFC 855

Communications technologyAS ABAP 841

Comparisonbyte-like 295character-like 295conversion 293logical expression 293numeric 294WHERE clause 722

Compatibility modeTransaction Service 774

Compatibledata object 273

Compilation unitABAP program 152

complete typingUsage 354

Complexdata type 231

Componentstructure 244

Component controllerweb dynpro component 682

Component interfaceinterface 395

Component specificationdynamic 830

COMPUTEABAP statement 288

Computing timeanalyze 980

CONCATENATEABAP statement 305

Concretesubclass 370

CONDENSEABAP statement 305

Consolidation systemCTS 62

Constantclass 194

data object 266CONSTANTS

ABAP statement 194, 266Constructor

class 214creation 114inheritance 375

constructorinstance constructor 214

Containerclass 190

Container controlCFW 590

Context bindingWeb Dynpro ABAP 688

Context mappingWeb Dynpro ABAP 686

Context menudefining 539SAP GUI 539

CONTINUEABAP statement 302

Control eventexample 610

Control FrameworkCFW 588

Control level changecontrol structure 332

Control level processing 332Control structure

processing block 298Controller

MVC 672, 681CONTROLS

ABAP statement 579, 583Conversion

assignment 274byte-like type 276date and time 277numeric type 276text-type type 275

Conversion errortype conversion 278

Conversion routineABAP Dictionary 285

Conversion rulecomparison 294elementary data type 275internal table 281

Page 88: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1027

Index

structure 280type conversion 275

CONVERT DATEABAP statement 292

CONVERT TEXTABAP statement 305

CONVERT TIME STAMPABAP statement 292

Convertibledata object 274

Cookieaccess 886

Copy-on-writedynamic data object 974internal table 282

CORRESPONDING FIELDSINTO clause 718

cosfloating point function 287

coshfloating point function 287

COUNTaggregate function 715

Couplinginheritance 400

Coverage Analyzercalling 985tool 984

CPrelational operator 296, 316

CREATE DATAABAP statement 271, 812

CREATE OBJECTABAP statement 203, 391

CREATE PRIVATECLASS 189

CREATE PROTECTEDCLASS 189

CREATE PUBLICCLASS 189

CREATE_PERSISTENTPersistence Service 765

Cross-transaction application bufferdata cluster 785

CSrelational operator 296, 316

csequencegeneric type 264

CTSSAP Change and Transport System 62

cursordata type 735

Cursor variabledatabase cursor 735

Custom containerCFW 590

Custom controlsscreen element 527

Customer systemnamespace 63

CX_DYNAMIC_CHECKexception category 492exception class 482

CX_NO_CHECKexception category 493exception class 482

CX_ROOTexception class 482

CX_STATIC_CHECKexception category 492exception class 482

CX_SY_NO_HANDLERexception class 490

D

dABAP type 236, 240

DATAABAP statement 192, 226

DataABAP program 225attribute 227character-like 229encapsulation 228local 226numerical 229program-global 227

datageneric type 264

Data Browsertool 98

DATA BUFFERdata cluster 785

Data clusterAS ABAP 784deleting 787

Page 89: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1028

Index

reading 786storing 785

Data declarationexecuting 94

Data elementactivating 74creation 72, 256database table 71

Data element documentationfield help 548

Data element maintenanceABAP Dictionary 73

Data elementsABAP Dictionary 255

Data encapsulationABAP Objects 27

Data objectABAP program 226anonymous 271, 812assigning 273context 226converting 274declaring 226dynamic 241elementary 236named 265names 226numeric 287operations 273predefined 271static 237

Data processingbusiness 29

Data referenceassign 817dynamic programming 796

Data reference variabledeclare 809declaring 250

Data rootSimple Transformation 930

Data storageconsistency 741persistent 705

Data transmissionAS ABAP 842

Data typeABAP Dictionary 233, 250bound 232

class 200class/interface 233data object 229defining 232domain 75elementary 236generic 237global 233, 251independent 232Local 116program-local 234type group 233type hierarchy 229use 234

DatabaseAS ABAP 148commit 743lock 748LUW 742rollback 744

Database cursoropening 734

Database interfaceAS ABAP 148, 706

Database logonAS ABAP 172

Database table 723ABAP Dictionary 707activating 77change contents 738change row 739create 68data cluster 785data type 252delete row 741insert or add row 740insert rows 738reading 712relational 706repository object 68structure 708technical settings 76

Database viewABAP Dictionary 709reading 727

Date fieldcalculating 290comparing 294data object 237, 240

Page 90: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1029

Index

validity 291DCL

Data Control Language 707DDL

Data Definition Language 707Debuggee

ABAP Debugger 951Debugger

ABAP Debugger 951Debugger Breakpoint

ABAP Debugger 956Debugger tools

ABAP Debugger 955Debugging session

ABAP Debugger 955ending 956starting 955

DECIMALSTYPES/DATA 243

DECLARATIONCLASS 185

Declaration partABAP program 87, 152class 184top include 168

Decouplinginterface 401object orientation 382

Deepdata type 261structure 262

Deep data objectmemory requirements 262, 973

DEFAULTMETHODS 355PARAMETERS 619

DEFERREDCLASS DEFINITION 211

DEFINEABAP statement 170

DELETE DATASETABAP statement 778

DELETE dbtabABAP statement 741

DELETE FROMdata cluster 787

DELETE itabABAP statement 334

DELETE_PERSISTENTPersistence Service 769

Delivery classdatabase table 70

DEQUEUElock function module 751

Dereferencingdata reference variable 811

Dereferencing operatorusing 250

DESCENDINGSORT 335

DESCRIBE FIELD 820DESCRIBE_BY_DATA

RTTI 823DESCRIBE_BY_NAME

RTTI 823Description function

function 287Deserialization

ST 927XML-ABAP 908XSLT 921

Design by contractassertion 511

DESTINATIONCALL FUNCTION 849, 854

DESTINATION IN GROUPCALL FUNCTION 856

DestructorABAP Objects 219

Details listclassical list 647creating 652

Developerauthorization 54

Developer keySAPNet 55

Development classpackage 62

Development environmentABAP 26

Development objectABAP Workbench 59

Development systemCTS 62

Dialog box containerCFW 590

Page 91: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1030

Index

Dialog interfaceAS ABAP 146

Dialog modulecreating 542data 227processing block 154, 165use 542

Dialog programmingclassical ABAP 457

Dialog statusGUI status 535

Dialog stepPAI/PBO 543

Dialog transactioncreating 520execution 457initial dynpro 520selection screen 631transaction code 157

Dialog transactionsuse 460

Dialog windowmodal 523

Dictionary typecreation 253

divarithmetic operator 286

DIVIDEABAP statement 286

DMLData Manipulation Language 707

DOABAP statement 301

Docking containerCFW 590example 604

Documentationdata element 256

DOMDocument Object Model 913, 914

DOM objectiXML library 918

DomainABAP Dictionary 256creation 256data element 74

Domain managementABAP Dictionary 76

Domainscreation 75

Double-clickclassical list 651

Down Castdata reference variable 817

Down castinheritance 410interface 411object reference variable 409

Downward compatibilityABAP 36, 449ABAP Objects 181

Dropdownlist box 553

DTDdocument type definitions 913, 914

Dynamic Accessclass components 801

Dynamic data objectdynamic memory object 972

Dynamic documentsCFW 599

Dynamic typeobject reference variable 403polymorphism 413reference variable 282

dynamic typedata reference variable 809

DynproABAP Objects 555ABAP program 518AS ABAP 146control 573creating 524dialog transaction 457dynamic program 515dynpro sequence 519example 557exiting 523field 530function group 556input check 545number 524process 458properties 525type 525usage 146

Page 92: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1031

Index

Dynpro data transportautomatic 543controlling 544

Dynpro fielddata transport 531data type 251, 531

Dynpro flow logicimplementing 529statements 530table control 578

Dynpro numberselection screen 617

Dynpro processingmessage 668

Dynpro screensdata transport 519

Dynpro sequencedialog transaction 524dynpro process 458nesting 523terminating 522

Dynproslayout 526

E

Emessage type 669

eCATTExtended Computer Aided Test Tool 986

Editor modeClass Builder 199

ElementXML 910

Elementarydata type 231

Elementary ABAP typeasXML 922JCO 875RFC API 866

Elementary data objectassigning 275comparing 294initial value 285

Elementary typedeclaring 242

ELSEABAP statement 298

ELSEIFABAP statement 298

Encapsulationclass 187classic ABAP 461object orientation 179procedure 188use 223

END OFTYPES/DATA 244

ENDING ATCALL SCREEN 523CALL SELECTION-SCREEN 630

END-OF-PAGEList event 646

END-OF-SELECTIONevent 453

Enhancement categorydatabase table 76

ENQUEUElock function module 749

Enterprise serviceclient proxy 905

Enterprise Services RepositoryExchange Infrastructure 893

Enterprise SOAXML 908

EQrelational operator 293

Errorexception situation 480

Error messagedynpro 559message type 669

error_messageclassical exception 670

Errorsavoiding 479

EventABAP Objects 27, 422ABAP runtime environment 452class 423declaring 424inheritance 428management 431Object orientation 343triggering 426Web Dynpro ABAP 691

Page 93: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1032

Index

Event blockdata 227function group 465processing block 154, 165

Event handlerdeclaring 428method 423

EVENTSABAP statement 424

Example libraryABAP keyword documentation 139

Exceptioncatch 484category 492declaring 114, 490function module 469handle 484handler 484non-class-based 500Parameter interface 345propagating 487raising 483RFC API 867untreatable 481

Exception categoryuse 493

Exception classadvantages 482attributes 494class-based exception 481creation 111, 493exception text 495local 494methods 494

Exception groupcatchable runtime error 501exception class 507

Exception handlerclass-based exception 485

Exception handlingABAP 481class-based 481class-based/classic 505classic 500cleanup tasks 489executing 96function module 472messages 503

Exception objectclass-based exception 481generating 483

Exception textcreation 496message 496, 505, 670OTR 496use 496

EXCEPTIONSCALL FUNCTION 502CALL METHOD 502METHODS 502

EXCEPTION-TABLECALL FUNCTION 835CALL METHOD 833

EXCLUDINGSET PF-STATUS 538

EXEC SQLABAP statement 754

Executable programABAP runtime enviroment 452call 156execute 451program type 160use 460

EXISTSWHERE clause 731

EXITABAP statement 302

Exit messagemessage type 670

expfloating point function 287

EXPORTABAP statement 785

EXPORTINGActual parameter 356EVENTS 424METHOD 195METHODS 346RAISE EVENT 426

Extension information systemObject Navigator 59

F

fABAP type 236, 238calculation type 289

Page 94: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1033

Index

Factory methodclass 209

falselogical expression 292

FavoritesSAP Easy Access 57

Favorites menuSAP Easy Access 56

FETCH NEXT CURSORABAP statement 736

FIELDDynpro statement 544, 547

Fielddatabase table 71

Field helpdefining 549dynpro 548selection screen 633Web Dynpro ABAP 690

Field labeldata element 74, 256

Field symboldynamic programming 796type 799usage 796

FIELD-SYMBOLSABAP statement 798

Fileapplication server 776closing 778deleting 778opening 776presentation server 781reading 777writing 777

File interfaceAS ABAP 775

File namelogical 775

Filter conditionQuery Service 760

FINALCLASS 373METHODS 373

FINDABAP statement 306

Fixed valuedomain 80input help 550

Fixed-Point Arithmeticprogram attribute 163

FixtureABAP Unit 968

Flatdata type 261structure 262

Flat structureassigning 280

Flight data modeldynpro 561SAP 50

Floating point functionfunction 287

Floating point numberdata object 236, 238

floornumeric function 287

Flow logicdynpro 517

FOR ALL ENTRIESSELECT 729

FOR EVENTMETHODS 428

Foreign keydatabase table 81

Foreign key dependencydatabase table 706

FORMABAP statement 474

Form fieldURL 886

Formal parameteroperand position 352optional 354parameter interface 345typing 351usage 348

FORMATABAP Statement 646

Forward navigationABAP Workbench 59, 73

fracnumeric function 287

Frameclassical list 646screen element 527

FrameworkABAP Objects 222

Page 95: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1034

Index

Friendclass 190

FRIENDSCLASS 190

Friendshipclass 190

FROM clauseSELECT 713

Full-text searchABAP keyword documentation 139

FUNCTIONABAP statement 470

Functionbuilt-in 287

Function Buildertool 105, 462, 467

Function codeclassical list 651evaluating 538exit command 546Menu Painter 535SAP GUI 534selection screen 634use 534

Function code assignmentMenu Painter 535

Function groupABAP program 462create 463creation 101global data 463introducing 101naming convention 465program type 160use 462

FUNCTION KEYSELECTION-SCREEN 636

Function key assignmentsGUI status 519

Function modulecreate 467creation 105dynamic 835implementing 105procedure 164, 462release 471source code 469test 471testing 108

Function poolprogram type 160

Functional methodcall 357define 347operand position 357

FUNCTION-POOLABAP statement 160, 466

G

Garbage CollectorABAP runtime environment 212

GErelational operator 293

Generalizationinheritance 361

GENERATE SUBROUTINE POOLABAP statement 837

Genericdata type 263

Generic data typeABAP type hierarchy 229

generic typingusage 354

GETevent 453

GET DATASETABAP statement 778

GET REFERENCEABAP statement 810

GET RUN TIMEABAP statement 726

GET TIME STAMPABAP statement 292

GET/SET methodspersistent class 758

GET_PERSISTENTPersistence Service 765

GET_PERSISTENT_BY_QUERYQuery Service 760

GET_PRINT_PARAMETERSprint parameters 655

Golden rulechecking 405data reference variable 809object reference variable 404

GROUP BY clauseSELECT 732

Page 96: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1035

Index

GTrelational operator 293

GUIGraphical User Interface 513

GUI ControlSAP GUI 587

GUI controldynpro 587event 595example 601lifetime 597methods 594processing 594wrapping 598

GUI statusABAP program 519checking 537classical list 651compare templates 537example 563functions 535selection screen 634setting 537

GUI titlecreating 538

GUI_DOWNLOADwriting a file 781

GUI_UPLOADreading a file 781

GUIDobject identity 770

H

HANDLEASSIGN 808CREATE DATA 813

HASHED TABLETYPES/DATA 248, 320

Hashed tablegeneric type 264table category 320use 322

HAVING clauseSELECT 732

Headerdeep data object 973

Hello worldABAP program 88

Hidingdata object 228

Host variableNative SQL 754

HTMLinterface 671

HTML GUISAP GUI 516

HTTP bodyaccess 882

HTTP clientICF 888

HTTP communicationsAS ABAP 877

HTTP headeraccess 882

HTTP requestsending 890

HTTP request handlercreating 880ICF 879implementing 882registering 880

HTTP serverICF 880

HTTP servicecreating 880testing 880

HTTP(S)protocol 877

I

Imessage type 669

iABAP type 236, 238calculation type 289

ICFAS ABAP 878Internet Communication Framework

877methods 884web service 897

ICF clientprogramming 886

ICF Serverprogramming 879

Page 97: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1036

Index

ICMAS ABAP 878Internet Communication Manager 149,

877ID

XSLT program 921IF

ABAP statement 298control structure 298

IF_HTTP_CLIENTICF 886

IF_HTTP_ENTITYICF 882

IF_HTTP_EXTENSIONICF 879

IF_HTTP_HEADER_FIELDSICF 882

IF_HTTP_HEADER_FIELDS_SAPICF 882

IF_HTTP_RESPONSEICF 882, 890

IF_OS_TRANSACTIONTransaction Service 771

IF_SERIALIZABLE_OBJECTinterface 412tag interface 925

IF_T100_MESSAGEmessage interface 496, 498, 667

IMPLEMENTATIONCLASS 185

Implementationmethod 195

Implementation partABAP program 87, 153class 184

IMPORTABAP statement 786

IMPORTINGActual parameter 356METHOD 195METHODS 346

IN BYTE MODEbyte string processing 304

IN CHARACTER MODEcharacter string processing 304

IN PROGRAMPERFORM 476

IN seltablogical expression 627

predicate 296WHERE clause 722

Inbound plugWeb Dynpro ABAP 696

INCLUDEABAP statement 167

Include programABAP program 167usage 168

INCLUDE STRUCTUREABAP statement 246

INCLUDE TYPEABAP statement 246

Indentationpretty printer 86

Independent interface reference variableABAP Objects 383, 390

INDEXINSERT 327READ TABLE 329

Index accessinternal table 321

Index searchABAP keyword documentation 138

INDEX TABLEgeneric table type 324

index tablegeneric type 264

INDX-likedatabase table 786

Informational messagemessage type 669

InheritanceABAP Objects 27, 359independent interface 400object orientation 179polymorphism 414

Inheritance treeABAP Objects 360

INHERITING FROMCLASS 362

Initial dynprodynpro sequence 520

INITIAL SIZETYPES/DATA 325

Initial valuedata object 285

INITIALIZATIONevent 452

Page 98: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1037

Index

Initializationobject 213

INNER JOINSELECT 729

INPUTMODULE 542

Input and output parameterfunction module 468

Input checkautomatic 545defining 547selection screen 633

Input dialogWeb Dynpro ABAP 689

Input formatdynpro 545

Input helpautomatic 550defining 552dynpro 549hierarchy 551selection screen 633Web Dynpro ABAP 689

Input parameterformal parameter 346function module 468instance constructor 215, 375

Input stream objectiXML library 918

Input verificationmessage 669

Input/output fieldscreen element 527

Input/output parameterFormal parameter 346

INSERT dbtabABAP statement 738

INSERT itabABAP statement 327

INSERT REPORTABAP statement 840

InspectionCode Inspector 948

InstanceABAP Objects 180data object 230

Instance attributecreation 121, 192

Instance component 191

Instance constructor3-phase model 376class 214exception 122implementing 118, 122inheritance 375interface 121

Instance methodcreation 194

InstantiationABAP Objects 27ABAP program 461inheritance 380

Integerdata object 236, 238

Integration brokerweb service 896

INTERFACEABAP statement 384

InterfaceABAP Objects 27, 381class 187, 382composing 394creating 384implementing 386, 395independent, usage 382inheritance 400, 404object orientation 343polymorphism 414user view 391using 397

Interface componentinterface 384static 394

Interface component selectorinterface 387

Interface methodimplementing 388

Interface parametercreation 114parameter interface 345parameter type 346transfer type 347

Interface poolprogram type 159

Interface reference variableABAP Objects 383

Interface viewweb dynpro window 677

Page 99: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1038

Index

Interface working areaABAP/dynpro 532

INTERFACE-POOLABAP statement 159

INTERFACESABAP statement 386, 394

Internal modestack 175

Internal sessionmemory limit 176

Internal tableABAP Dictionary 258access 326appending 329assigning 281, 336asXML 924attributes 319comparing 296, 336control level processing 332data object 95declaring 248deleting 334generic 324initial value 285inserting 327inserting aggregated rows 328JCo 875loop 331modifying 333reading 329RFC API 867runtime measurement 322short form 324sorting 335transferring 336using 318

InternetAS ABAP 149connection 878

Internet Communication FrameworkICF 877

Internet Communication ManagerAS ABAP 149ICM 877

INTOLOOP 331READ TABLE 330

INTO clauseSELECT 715

IPOprinciple 454

IS ASSIGNEDlogical expression 806predicate 297

IS BOUNDlogical expression 816predicate 297

IS INITIALpredicate 296

IS NULLWHERE clause 721

IS SUPPLIEDpredicate 297, 355

iXML Librarylibrary 913parsing 915

J

J2EEAS Java 143technology 30

J2EE ConnectorSAP JRA 852

JavaAS Java 143programming language 30

Java GUISAP GUI 516

JavaScript EngineAS ABAP 147

JCOJCo class 870

JCoconnection pool 871direct connection 870downloading 869passing parameters 875SAP Java Connector 869

JCO.addClientPoolJCo 872

JCO.AttributesJCo class 870

JCO.ClientJCo class 870

JCO.connectJCo 871

Page 100: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1039

Index

JCO.createClientJCo 871

JCO.disconnectJCo 871

JCO.FunctionJCo 874

JCO.getClientJCo 873

JCO.ParameterListJCo 875

JCO.PoolJCo class 872

JCO.PoolManagerJCo class 872

JCO.releaseClientJCo 873

JCO.RepositoryJCo 874

JCO.ServerJCo 876

JCO.StructureJCo 875

JCO.TableJCo 875

Jobbackground request 641

Job overviewbackground processing 643

JOB_CLOSEbackground processing 641

JOB_OPENbackground processing 641

JOINSELECT 727

JoinFROM clause 727linking 728

K

KernelAS ABAP 147

Key accessinternal table 321

Key attributepersistent class 759

KeywordABAP statement 85

Knowledge Warehouseusing 138

L

LDB_PROCESSfunction module 455

LErelational operator 293

LEAVE SCREENABAP statement 523

LEAVE TO LIST-PROCESSINGABAP statement 648

LEAVE TO SCREENABAP statement 523

LEAVE TO TRANSACTIONABAP statement 521

LEAVE TO TRANSACTIONABAP statement 158

LEFT OUTER JOINSELECT 729

LENGTHTYPES 232TYPES/DATA 242

LibraryJava 35

LIKETYPES/DATA 232WHERE clause 722

Lineclassical list 646selection screen 628

LINE OFFTYPES/DATA 328

linesdescription function 287

LINES OFAPPEND 329INSERT itab 328

Linked listexample 815

ListABAP Objects 658ALV list 659classical 645executable program 453

List bufferclassical list 646

Page 101: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1040

Index

List cursorsclassical list 646

List dynproclassical list 646

List eventevent block 167handling 652

List levelclassical list 647

List outputcreation 89

List processorcalling 648classical list 646

Literaldata object 268

Literal XML elementSimple Transformation 929

LOAD-OF-PROGRAMABAP statement 166event 452, 458

Local classclass pool 220creation 126definition 128function group 465implementation 128

LOCAL FRIENDSCLASS 220

Local objectrepository browser 61

Local typeclass pool 220

Localetext environment 151

lockshared objects 440

Lock conceptAS ABAP 748

Lock objectSAP lock 748

Lock tableSAP lock 748

Logassertion 510

logfloating point function 287

log10floating point function 287

Logical databaseprogram attribute 163selection screen 616

Logical Database Buildertool 454

Logical databasesuse 454

Logical expressionABAP syntax 292IF/ELSEIF 299WHERE 332WHERE clause 721

Logical portclient proxy 906

Long textmessage 666

LOOPABAP statement 331

Loopconditional 301control structure 301internal table 331unconditional 301

LOOP AT SCREENABAP statement 528

LOOP WITH CONTROLdynpro statement 578, 581

Loopsexecuting 129

LOWER CASEPARAMETERS 619

LTrelational operator 293

LUWdatabase 742Logical Unit of Work 742

M

Main programfunction group 106, 463

Main sessionuser session 174

Mappingobject-relational 757

Markup elementXML 910

Mathematical functionfunction 287

Page 102: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1041

Index

MAXaggregate function 715

medata object 271self-reference 125, 205

Memory analysisABAP Debugger 975

Memory areaAS ABAP 173

Memory Inspectorcalling 977tool 971

Memory leakcauses 971example 979object 213

Memory objectdynamic 972

Memory snapshotcomparing 978create 975opening 977ranked list 978

Menu barSAP GUI 516, 534

Menu Paintertool 535

MESSAGEABAP statement 667

Messagedialog processing 668exception handling 503SAP GUI 666sending 667use 670

Message classmessage 666

Message numbermessage 666

Message outputcreation 90

Message serverAS ABAP 172

Message typemessage 668

Messagescreating 666tool 666

MetadataXML 909

meth( )Method call 356

METHODABAP statement 195

Methodabstract 370call 355calling 129concrete 371creation 194declaring 113final 373functional 347implementing 117object orientation 178, 342parameter interface 345polymorphism 414procedure 164redefine 366source code 117subclass 366

Method calldynamic 832functional 357static 356

METHODSABAP statement 194

MIME RepositoryObject Navigator 606

MINaggregate function 715

modarithmetic operator 286

ModelMVC 672, 681

Modelingobject orientation 222

MODIFY dbtabABAP statement 740

MODIFY itabABAP statement 333

MODIFY SCREENABAP statement 528

Modularizationinternal 477procedural 460

Page 103: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1042

Index

MODULEABAP statement 542Dynpro statement 542

Module pooldialog programming 457program type 161

Module poolsuse 460

Module testABAP Unit 961analysis 969definition 962

Mousedouble-click 536

MOVEABAP statement 273

MOVE ?TOABAP statement 409, 817

MOVE-CORRESPONDINGABAP statement 283

MS WindowsSAP GUI 516

Multiple inheritanceABAP Objects 382object orientation 344

Multiple instantiationclass 207

Multiple selectionselection criterion 626

MULTIPLYABAP statement 286

MVCModel View Controller 145, 515, 672

mySAP Business Suiteproduct family 141

N

nABAP type 236, 239

NArelational operator 296, 316

NamespaceasXML 922class 191data object 228data type 234inheritance 365Simple Transformation 929

XML 912Naming conventions

class 185customer system 63

Native SQLAS ABAP 753

Native SQL interfaceAS ABAP 149

Navigation linkWeb Dynpro ABAP 697

NErelational operator 293

NEW-PAGE PRINT ONABAP statement 655

Next dynprocalling 521dynpro property 526dynpro sequence 519

NO INTERVALSSELECT-OPTIONS 624

NO-EXTENSIONSELECT-OPTIONS 624

Non-class-based exceptiondefine 502

NOTBoolean operator 297WHERE clause 721

NPrelational operator 296, 316

NSrelational operator 296, 316

Numericdata type 237

numericgeneric type 264

Numeric functionfunction 287

Numeric literaldata object 268

Numeric text fielddata object 236, 239

O

O/R mappingobject-relational mapping 757

OASISOrganization for the Advancement of

Structured Information Systems 893

Page 104: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1043

Index

ObjectABAP Objects 180asXML 925Creating 128dynamic memory object 972generic type 408object orientation 341real world 177root class 360software 178

Object component selectorABAP syntax 204using 250

Object IDObject Services 757

Object listRepository Browser 60

Object list typeRepository Browser 60

Object NavigatorABAP Workbench 57

Object orientationprogramming 177

Object referenceABAP Objects 402internal table 208memory address 202persistent 770

Object reference variabledeclaring 250golden rule 404user view 403

Object reference variablescreation 202

Object Servicesdatabase access 757

Object setCode Inspector 948

Object typeABAP type hierarchy 230

Object-oriented transaction modeTransaction Service 774

OBLIGATORYPARAMETERS 619

Obsolete language elementABAP 35

Offset/length specificationsubfield access 313

OK fielddynpro field 533use 538

ONJOIN 728

ON BLOCKAT SELECTION-SCREEN 632

ON CHAIN-INPUTMODULE 545

ON CHAIN-REQUESTMODULE 545

ON COMMITPERFORM 747

ON END OFAT SELECTION-SCREEN 632

ON EXIT-COMMANDAT SELECTION-SCREEN 632

ON HELP-REQUESTAT SELECTION-SCREEN 632

ON INPUTMODULE 544

ON para|selcritAT SELECTION-SCREEN 632

ON RADIOBUTTON GROUPAT SELECTION-SCREEN 632

ON REQUESTMODULE 544

ON ROLLBACKPERFORM 747

ON VALUE-REQUESTAT SELECTION-SCREEN 632

OO transactioncreation 130dynpro 560transaction code 158

OOAobject-oriented analysis 180

OODobject-oriented design 180

OPEN CURSORABAP statement 735

OPEN DATASETABAP statement 776

Open SQLABAP statements 710dynamic 830performance 711using 95

Page 105: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1044

Index

Open SQL interfaceAS ABAP 149

OperandABAP statement 85arithmetic expression 287logical expression 293specified dynamically 830

Operand positionABAP statement 226

OperatorABAP statement 85arithmetic expression 286

OPTIONALMETHODS 354

ORBoolean operator 297WHERE clause 721

ORDER BY clauseSELECT 734

OTROnline Text Repository 496

Outbound plugWeb Dynpro ABAP 696

OUTPUTAT SELECTION-SCREEN 631MODULE 542

Output fieldselection screen 628

Output parameterevent 425Formal parameter 346function module 468

OVERLAYABAP statement 305

P

pABAP type 236, 238calculation type 289

PackageABAP Workbench 60

Package Buildertool 66

Package checkpackage 67

Package interfacepackage 67verification 62

Package propertypackage 64

PACKAGE SIZEINTO clause 718

Package typepackage 64

Packed numberdata object 236, 238

PAIdynpro event 458Event 538PROCESS AFTER INPUT 517selection screen 631

PAI modulefunction group 465

Parallel processingaRFC 856

Parameterselection screen 618

Parameter interfaceevent 425exception 490executable program 640function module 467method 195, 196subroutine 474

Parameter transactiondialog transaction 457

Parameter transferperformance 349

PARAMETERSABAP statement 618

PARAMETER-TABLECALL FUNCTION 835CALL METHOD 833

Parenthesescalculation expression 286logical expressions 297

Pass by valueformal parameter 348

Patternsobject orientation 180

PBOdynpro event 458PROCESS BEFORE OUTPUT 517selection screen 631

PBO modulefunction group 465

Page 106: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1045

Index

PERFORMABAP statement 475

Performance data fileruntime analysis 982

Persistence layerAS ABAP 148

Persistence mappingtool 758

Persistence ServiceObject Services 757

persistent classcreate 757Object Services 757

Persistent objectchange 769SAP LUW 770

persistent objectcreate 765delete 769

Picture controlCFW 591encapsulation 601, 611example 605

PlugWeb Dynpro ABAP 695

POHPROCESS ON HELP REQUEST 517

PolymorphismABAP Objects 413benefits 417, 422example 417object orientation 179semantic rules 416usage 416

Popup levelcontainer control 594

POSITIONABAP statement 646

POSIX standardregular expression 308

POVPROCESS ON VALUE REQUEST 517

Predefined typedata element 74

Predicatelogical expression 296WHERE clause 722

Presentation layerAS ABAP 145

Presentation logicencapsulation 100

Presentation serverSAP GUI 516

Pretty printerABAP Editor 86

Primary indexdatabase table 723

PRIMARY KEYORDER BY clause 734

Primary keydatabase table 706

Print listALV 663classical list 654

Print list levelprint list 655

Print parametersbackground processing 641spool request 655

Privatevisibility area 186

privateInheritance 365

Private instantiationsuperclass 381

PRIVATE SECTIONvisibility area 187

Procedureclassical 461processing block 153, 164

Procedure calldynamic 832

ProcessABAP runtime environment 150runtime environment 451

PROCESS AFTER INPUTdynpro event 458, 517event block 530

PROCESS BEFORE OUTPUTdynpro event 458, 517event block 530

PROCESS ON HELP REQUESTdynpro event 517

PROCESS ON HELP-REQUESTdynpro event block 549

PROCESS ON VALUE REQUESTdynpro event 517dynpro event block 552

Page 107: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1046

Index

Processing blockABAP program 87dynpro flow logic 517implementation 153terminate 156

ProcessorABAP runtime environment 150

Production systemCTS 62

Productive partABAP program 966

PROGRAMABAP statement 160, 161

Program calldynamic 830

Program checkextended 942

Program constructorevent block 166

Program generationpersistent 840transient 837usage 836

Program groupinternal mode 476

Program introductionABAP program 86, 87

Program propertiesdefinition 83

Program typeABAP program 159recommendation 162

Programmingdefensive 223, 479robust 479

Programming guidelinesABAP 46

Programming languagesAS ABAP 147

Programming modelobject-oriented 26procedural 26

Protectedinheritance 365visibility area 186

Protected areaTRY block 484

Protected instantiationsuperclass 380

PROTECTED SECTIONvisibility area 187

Protocol 845Proxy

web service 896Proxy object

CFW 589Pseudo comment

extended program check 945Public

inheritance 365visibility area 186

Public instantiationsuperclass 380

PUBLIC SECTIONABAP statement 186

Publish-and-Subscribeevent 423

PUSHBUTTONSELECTION-SCREEN 628

Pushbuttonselection screen 628

Q

qRFCAPI 861executing 861queued RFC 847RFC API 868scenarios 848

qRFC managerqRFC 861

Quality managementCode Inspector 950

Query ManagerObject Services 760

Query ServiceObject Services 760

R

R/2system 23

R/3product family 141system 24, 141

Radio buttonscreen element 527

Page 108: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1047

Index

selection screen 619RADIOBUTTON GROUP

PARAMETERS 619RAISE EVENT

ABAP statement 426RAISE exc

ABAP statement 502RAISE EXCEPTION

ABAP statement 483RAISING

FORM 474MESSAGE 503METHOD 195METHODS 490

RANGEASSIGN 805

RANGE OFDATA 627

READ DATASETABAP statement 777

Read lockshared objects 440

READ REPORTABAP statement 838

READ TABLEABAP statement 329

READ-ONLYDATA 192, 243

RECEIVE RESULTSABAP statement 855

RECEIVINGActual parameter 357

REDEFINITIONMETHODS 367

REF TODATA 202TYPES/DATA 249, 402, 809

REFERENCEMETHODS 347

Referencedata type 231XML 926

REFERENCE INTOLOOP 331READ TABLE 330

Reference semanticsassignment 261data reference 796dynamic memory object 974

Reference transferformal parameter 348

Reference typeABAP Dictionary 257declaring 249

Reference variableassigning 205, 282, 405comparing 295declaring 249initial value 285using 117, 250

REGEXFIND 310REPLACE 311

Registering event handlers 431Registration

event 423Regular expression

class 312find/replace 308special character 309

Relational operatorlogical expression 293

Remote Function CallAS ABAP 149RFC 845

Remote-enabled function moduleRFC 853RFM 853

Rental car applicationexample 54

REPLACEABAP statement 306

REPORTABAP statement 160

Reportcreation 134

Report transactionexecutable program 631

Reportingclassic ABAP 451interactive 652process 454programming 133

Reporting eventevent block 166

Repositorydevelopment objects 59

Page 109: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1048

Index

Repository browserObject Navigator 59

Repository information systemObject Navigator 59

Repository objectABAP Workbench 59

Required fielddynpro 545selection screen 619

RETURNABAP statement 156, 303

Return valueformal parameter 346

RETURNINGMETHOD 195METHODS 347

RFC 849API 862asynchronous 846communication scenarios 849debugging 855object-oriented control 862programming 853queued 847Remote Function Call 845synchronous 845transactional 847

RFC APIC routines 862

RFC clientJCo 870non-SAP system 863

RFC destinationadministering 850HTTP connection 889non-SAP system 866specifying 850, 854

RFC interfaceAS ABAP 845external 850

RFC libraryRFC API 862

RFC SDKdownloading 863Software Development Kit 850

RFC serverJCO 876non-SAP system 865passing parameters 866

RfcAcceptRFC API 865

RfcCallRFC API 864

RfcCloseRFC API 864

RfcCreateTransIDRFC API 868

RfcDispatchRFC API 865

RfcGetDataRFC API 865

RfcGetNameRFC API 865

RfcIndirectCallExRFC API 868

RfcInstallFunctionRFC API 865

RfcInstallTransactionControlRFC API 868

RfcLibraryexternal RFC interface 862

RfcOpenRFC API 864

RfcReceiveRFC API 864

RfcSendDataRFC API 865

RFMJCo call 876

Roll areainternal session 175

Rollbackdatabase 742

ROLLBACK WORKABAP statement 746Persistence Service 770

Root classinheritance tree 360

Root objectshared objects 442

Row typeinternal table 248, 319

RTTCRun Time Type Creation 819

RTTIRun Time Type Information 819

RTTSASSIGN 808

Page 110: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1049

Index

CREATE DATA 813Run Time Type Creation (RTTC) 824Run Time Type Information (RTTI) 820Run Time Type Services (RTTS) 819Runtime analysis

call 981Runtime error

exception 483non-catchable 508

Runtime errorscatchable 500

S

Smessage type 669

S_MEMORY_INSPECTORtransaction 977

SAABtransaction 510, 957

SAP BasisR/3 141

SAP bufferingdatabase table 752

SAP Change and Transport Systempackage property 62

SAP Easy Accessstartup program 55

SAP gatewayJCo 876RFC server 865

SAP GUIAS ABAP 146SAP Graphical User Interface 516

SAP Help Portalusing 138

SAP JCoJava Connector 851

SAP JRAJava Resource Adapter 852

SAP List ViewerALV 593using 134

SAP lockSAP LUW 748

SAP LUWAS ABAP 744tRFC 859

SAP memoryuser session 174

SAP menuSAP Easy Access 55

SAP NetWeavertechnology platform 24, 30, 141

SAP NetWeaver 2004s sneak previewtutorial 53

SAP NetWeaver Exchange InfrastructureXML 908

SAP spool systemABAP Objects 663print list 654

sapitab.hRFC API 862

saprfc.hRFC API 862

SCItransaction 945

SCOVtransaction 985

Screencheck 530dynpro 515SAP GUI 516test 530

Screen elementdynpro field 530function code 534Layout Editor 527modifying 528properties 528SAP GUI 516selection screen 616

Screen listclassical list 646

Screen Painterelement list 528, 533Layout Editor 526source code editor 517tool 524

Scroll barSAP GUI 516

SE30transaction 981

SE38transaction 56

SE80transaction 58

Page 111: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1050

Index

Search helpABAP Dictionary 550creating 550creation 78using 108

Search help maintenanceABAP Dictionary 78

Secondary indexdatabase table 723

SELECTABAP statement 712assignment rules 720loop 717

SELECT clauseSELECT 713

SELECT loopnested 725using 118

Selection criterionselection screen 622

Selection screencalling 630creating 617creation 103Data Browser 98dynpro 615event 631GUI status 634processing 104, 631processor 631quitting 635use 617

Selection screen eventevent block 166

Selection screen processingsilent 641

Selection tableselection criterion 623WHERE clause 724

Selection textCreating 104Selection screen 619

SELECTION-SCREEN BEGIN OF SCREENABAP statement 617

SELECT-OPTIONSABAP statement 622

Self-referenceinstance constructor 377

senderevent parameter 425, 429

Separation of concernsclassical list 650, 658concept 514dynpro 557selection screen 617web service 885

SerializationABAP-XML 908ST 927XSLT 921

Serviceweb-based 878

Service Definition Wizardweb service 898

Service WizardICF 880

Servicesuse 30

Session breakpointABAP Debugger 956

SET DATASETABAP statement 778

SET EXTENDED CHECKABAP statement 945

SET HANDLERABAP statement 431

SET methodclass 187

SET PF-STATUSABAP statement 537

SET SCREENABAP statement 522

SET TITLEBARABAP statement 538

Shared memoryapplication server 173, 433

SHARED MEMORY ENABLEDCLASS 435

Shared Memory-enabledclass 435

Shared ObjectsAS ABAP 433Object orientation 344

Shared objectsaccess 436creating 442object reference 436

Page 112: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1051

Index

usage 440, 443Shared Objects Memory

management 435Shared Memory 434

Sharingdynamic data object 973internal table 282

SHIFTABAP statement 305

Short dumpruntime error 483, 508

Short referenceABAP keyword documentation 137

Short textmessage 666

SICFtransaction 880

signnumeric function 287

simplegeneric type 264

Simple inheritanceinheritance 360object orientation 343

Simple TransformationAS ABAP 928calling 929performance 928ST 927symmetrical/asymmetrical 935symmetry 927use 884

sinfloating point function 287

SINGLESELECT clause 713

Single stepABAP Debugger 98

Singletonpattern 192using 117

Singleton principle 217sinh

floating point function 287SKIP

ABAP statement 646SELECTION-SCREEN 628

SLINtransaction 942

SM59transaction 850

SOAPSimple Object Access Protocol 893

SOAP RuntimeWeb Service Framework 897

Software componentpackage 64

Software logisticsABAP 38AS ABAP 60CTS 67

SOMEWHERE clause 732

SORTABAP statement 335

SORTED TABLETYPES/DATA 248, 320

Sorted tabletable category 320use 322

sorted tablegeneric type 264

Source codeorganization 167

SPA/GPA parameterSAP memory 174

Spaceclosing 270

spacedata object 271

Specializationinheritance 360

SPLITABAP statement 305

Splitter containerCFW 590example 605

Spool requestbackground processing 643generating 655

SQLStructured Query Language 706

SQL Tracetool 713

sqrtfloating point function 287

sRFCexecuting 854

Page 113: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1052

Index

synchronous RFC 845ST

Simple Transformation 927ST processor

AS ABAP 147ST program

structure 931ST statement

Simple Transformation 929ST22

transaction 508Standard key

internal table 323Standard processing block

ABAP program 90Standard selection screen

creating 638executable program 452, 616printing 655

STANDARD TABLETYPES/DATA 248, 320

Standard tabletable category 320use 321

standard tablegeneric type 264

Standard toolbaricon 536SAP GUI 516, 534

STARTING ATCALL SCREEN 523CALL SELECTION-SCREEN 630

STARTING NEW TASKCALL FUNCTION 855

Starting valueselection screen 619

START-OF-SELECTIONevent 453standard event 455use 455

Statefulinternet communication 886

Statelessinternet communication 886

StatementABAP program 85obsolete 449

Statement blockcontrol structure 298

Statement chainABAP syntax 94

Static attributecreation 192inheritance 373shared objects 437

Static componentclass 191using 197

Static constructorclass 216implementing 117inheritance 379

Static methodcreation 195redefinition 374

Static typeinheritance tree 404interface reference variable 405object reference variable 402polymorphism 413reference variable 282

static typedata reference variable 809

Status barSAP GUI 516

Status messagemessage type 669

Steplooptechnique 578

Storage mediapersistent 705

stringABAP type 241

String literaldata object 269

strlendescription function 287, 315

StructureABAP Dictionary 257assigning 279asXML 923comparing 295data object 95declaring 244initial value 285JCo 875RFC API 866RTTC 824

Page 114: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1053

Index

Structure componentassigning 283integrating 246using 245

Structure component selectorABAP syntax 245

Subclasscomponent 361create 362implicit 361inheritance 360

Subfieldaccess 313

Subfield addressingfield symbol 800

SUBMITABAP statement 157, 451standard selection screen 639

SubquerySELECT 731

Subroutinefunction group 465procedure 164use 476

Subroutine calldynamic 836

Subroutine poolcreation 126program type 160, 476

Subroutinesprocedure 474

SUBSCREENSELECTION-SCREEN 628

Subscreendynpro 581screen element 527

Subscreen dynprostabstrip page 582

Subscreen-dynproselection screen 628

SUBSTRINGFIND/REPLACE 307

Substringfind/replace 307

Substructurestructure 244

SUBTRACTABAP statement 286

SubtransactionTransaction Service 773

SUMaggregate function 715

super->pseudo reference 367

super->constructorinheritance 375

Superclassinheritance 360private 381

SUPPRESS DIALOGABAP statement 649

systructure 272

sy-dbcntsystem field 713

sy-dynnrsystem field 521

Symbolic namefield symbol 797

Syntaxchecking 941

Syntax checkABAP program 88

Syntax cleansingABAP Objects 28, 181

Syntax conventionuse 47

Syntax diagramABAP keyword documentation 137

Syntax errorABAP program 88syntax check 942

Syntax warningsyntax check 942

SYSTstructure 272

System codepagetext environment 151

System data containereCATT 987

System eventGUI control 596

System fielddata object 271

System libraryABAP 25

Page 115: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1054

Index

SYSTEM_FAILURERFC 855

sy-subrcsystem field 272

sy-tabixsystem field 327, 332

sy-ucommsystem field 533

T

tABAP type 236, 240

T100database table 666

Tabdynpro 581

Tab stripsscreen element 527

TABLEINSERT 327

tablegeneric type 264

Table categoryinternal table 248, 320

Table controlcreating 574dynpro 574paging 580wizard 576

Table controlsscreen element 527

Table definitionABAP Dictionary 70

Table indexinternal table 321

TABLE KEYREAD TABLE 329

Table keydatabase table 71defining 323internal table 249, 321

Table maintenanceABAP Dictionary 70

TABLE OFTYPES/DATA 248

Table parameterfunction module 468subroutine 475

Table typeABAP Dictionary 258ABAP program 248generic 264

table_linepseudo component 323

TABLESABAP statement 532FORM 475

TABLEVIEWCONTROLS 579

TABSTRIPCONTROLS 583

Tabstrip controldynpro 581selection screen 628wizard 583

TagXML 910

Tag BrowserObject Navigator 929

tanfloating point function 287

tanhfloating point function 287

Target systemCTS 62

Tasktransport request 67

TCP/IPprotocol 845

Termination messagemessage type 670

Test classABAP Unit 963creation 967

Test configurationeCATT 987

Test data containereCATT 987

Test hierarchyABAP Unit 963

Test methodABAP Unit 963

Test methodscreation 967

Test partABAP program 966

Page 116: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1055

Index

Test propertyABAP Unit 967

Test runABAP Unit 969

Test scripteCATT 987

Test systemsCTS 62

Test taskABAP Unit 963

Testingtools 939

Testing procedurestatic 941

Text elementtranslating 268using 103

Text element maintenancetool 103, 267

Text environmentABAP runtime environment 151AS ABAP 26

Text fielddata object 236, 239screen element 527

Text field literaldata object 269

Text pooltext environment 151

Text stringdata object 241

Text symbolcreation 103data object 267text element 267using 103

Textedit controlCFW 592use 659

Time fieldcalculating 290comparing 294data object 237, 240validity 291

Time stampdate and time 292

TIMESDO 301

Tips & Tricksruntime analysis 984

Title barSAP GUI 516, 534

TO SAP-SPOOLSUBMIT 641, 655

TokenABAP statement 85specified dynamically 829

Tool areaObject Navigator 59

Toolbar controlCFW 591

TOP includefunction group 101

Top includefunction group 465include program 168

TOP-OF-PAGEList event 646

Transactionexecute 131, 158nesting 773program execution 130SAP LUW 747

Transaction codedevelopment object 157dialog transaction 457, 521rTFC 859SAP Easy Access 56transaction 130

Transaction managerTransaction Service 771

Transaction modeTransaction Service 774

Transaction ServiceObject Services 771use 771

TRANSFERABAP statement 777

Transformation Editortool 920, 928

transient attributepersistent class 769

TRANSLATEABAP statement 305

Transportrepository object 62

Page 117: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1056

Index

Transport layerCTS 63package 64

Transport OrganizerCTS 63, 67

Transport requestCTS 65

TRDIRsystem table 840

Tree controlCFW 592example 606

tRFCexecuting 859RFC API 868status 861transactional RFC 847use 847

TRFC_SET_QUEUE_NAMEqRFC 861

truelogical expression 292

truncnumeric function 287

TRYABAP statement 484control structure 484

TRY blockTRY control structure 484

tt:cond 936tt:include 932tt:loop 934tt:parameter 932tt:ref 932tt:root 931tt:switch 936tt:template 931tt:transform 931tt:type 932tt:value 933tt:variable 932TYPE

CREATE OBJECT 403DATA 229, 232METHODS 351TYPES 232

Type classRTTS 819

Type conversionassignment 274operand position 274

Type groupABAP Dictionary 259program type 161

Type hierarchyABAP 229

Type nameabsolute 823

Type objectcreate 825RTTC 825RTTS 819

Type of instantiationclass 188

Type specificationdynamic 830

TYPE TABLE OFTYPES/DATA 324

TYPE-POOLABAP statement 161, 260

TYPESABAP statement 200, 232

Typingcomplete 352define 351function module parameters 468generic 263, 352subroutine parameters 474

U

UDDIserver 905Universal Description, Discovery and

Integration 893UDDI registry

web service 905ULINE

ABAP statement 646SELECTION-SCREEN 628

UN/CEFACTUnited Nations Center for Trade

Facilitation and Electronic Business 894

UNASSIGNABAP statement 806

Page 118: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1057

Index

UnicodeSAP system 24

Unicode checks activeprogram attribute 163

Unicode fragment viewstructure 280

Unicode programABAP program 163

Unicode programsbyte and character string processing 304

Unicode systemAS ABAP 151

UNIQUE KEYTABLE 323

Up castdata reference variable 817inheritance 406interface 407interface reference variable 391object reference variable 406

UPDATE dbtabABAP statement 739

Update function moduleupdating 745

Update lockshared objects 440

UPDATE TASKCALL FUNCTION 745

Update work processAS ABAP 746

UpdatingSAP LUW 745

URIUniform Resource Identifier 913

URLaccess 882

Usage typeSAP NetWeaver 142

User breakpointABAP Debugger 957

User dialogcreation 99decoupling 100

User interfaceABAP 513AS ABAP 145

User menuSAP Easy Access 55

User sessionapplication server 174

USER-COMMANDSELECTION-SCREEN 635

USINGFORM 474PERFORM 475

UTCcoordinated universal time 292

V

VALUECONSTANTS 194, 266DATA 243METHODS 347

VALUE CHECKPARAMETERS 619

Value listdropdown list box 554

Value rangedomain 75, 80dynpro 545

Value semanticsassignment 261dynamic data object 973field symbol 796

Variabledata object 266

Variantruntime analysis 982

Variant transactiondialog transaction 457

VIA JOBSUBMIT 451, 641

VIA SELECTION-SCREENSUBMIT 630

Viewcreation 709database view 709MVC 672, 681Web Dynpro ABAP 675

View contextweb dynpro view 685

View DesignerWeb Dynpro ABAP 676

View layoutweb dynpro view 676, 687

Page 119: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1058

Index

View navigationWeb Dynpro ABAP 695

Visibility areaclass 186inheritance 364

W

Wmessage type 669

W3CWorld Wide Web Consortium 893

WAIT UNTILABAP statement 857

Warningmessage type 669

WatchpointABAP Debugger 957

Web DynproABAP 671AS ABAP 145Java 672wizard 683

Web Dynpro ABAPexample application 702use 671

Web Dynpro applicationexecuting 679Web Dynpro ABAP 679, 693

Web Dynpro componentWeb Dynpro ABAP 673, 682

Web Dynpro contextweb dynpro controller 683

Web Dynpro Explorertool 674

Web Dynpro viewnavigation 697

Web Dynpro windowWeb Dynpro ABAP 677

Web reportsexample 882

Web serviceABAP 891AS ABAP 894creating 898Enterprise SOA 892publishing 904releasing 900service provider 895

service requester 895standardization 893testing 902UDDI registry 895using 891

Web service clientcreating 905

Web Service FrameworkAS ABAP 894, 897J2EE server 902

Web service home pageWeb Service Framework 902

WHENABAP statement 299

WHEREDELETE itab 334LOOP 332MODIFY itab 333

WHERE clauseSELECT 721usage 723

WHILEABAP statement 301

Window EditorWeb Dynpro Explorer 677

WindowsSAP GUI 516

WITHSUBMIT 641

WITH KEYREAD TABLE 330

Wizarddynpro control 574web dynpro 683web service 898

Work processapplication server 172database logon 172database LUW 743

WRITEABAP statement 645executable program 647

Write lockshared objects 440

WRITE TOABAP statement 284

WSADMINtransaction 902

Page 120: ABAP Objects - AWS · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP Programming in SAP NetWeaver™

1059

Index

WSCONFIGtransaction 900

WSDLWeb Services Description Language 893

WSDL documentdisplaying 904URL 905

WS-IWeb Service Interoperability

Organization 894

X

Xmessage type 670

xABAP type 236, 241

XISAP NetWeaver Exchange Infrastructure

895XML 908

AS ABAP 908CALL TRANSFORMATION 920document 911Extensible Markup Language 909

XML documenttree representation 914

well-formed 914XML parser

iXML Library 913XML renderer

iXML Library 913xmlns

XML namespace 913xsequence

generic type 264XSLT

DOM 920Extensible Stylesheet Language

Transformations 918XSLT processor

AS ABAP 147, 919XSLT program

calling 920creating 920program generation 919repository object 919

xstringABAP type 242

Z

Z_ABAP_BOOKpackage 63