Horst Keller The Official ABAP“ Reference Galileo Press Bonn • Preface This book is the latest edition of The Offical ABAP Reference. It provides a com plete description of SAP's proprietary programming language, ABAP. In compar ison to the last edition, which described ABAP for Release 6.40, this version dis cusses ABAP up to and including Release 7.2, and therefore contains many revisions and lots of additional information. But why was there a need for a new ABAP reference book? Even though the con tent is available not only in the online help for the system but also on the Inter net, the oft-quoted Goethe comes to mind: “For what one has in black and white, one can carry home in com fortReaders' comments in relation to earlier editions (for example, 7 can highlight sections of the book", 7 have everything I need at a glance" or "I can find everything I need") were also the motivation behind the book format used in this current edition. When it comes to a highly comprehensive language such as ABAP, there is very much a need for a reference book. Even though all of the content is available online, that doesn't necessarily mean that it will always be found. The ABAP hotline is receiving more and more requests and error messages that could be resolved by simply referring to the doc umentation. But why are developers unable to find this information themselves? My personal belief is that online content is only read occasionally, generally in an emergency, and the reader cannot browse the content as easily as he or she could in a book. Even though all of the required content is available in the online help, and generally at the click of a mouse, the likelihood that a person browsing con tent will remain at sections of interest to him or her is simply greater when refer encing a well-formatted book. Moreover, thanks to the compact nature of the book format, the reader is also better able to identify key interrelationships. The following is a real-life example of a popular hotline message: "The statement SORT itab is not working." Of course, the SORT statement works exactly as it is described in the documentation. Most of the time, developers also know that the SORT statement sorts according to the primary table key without having to explic itly specify the sort key. However, they may not know that the primary table key 19 Preface can be the standard key and that, in the case of standard tables, this key may not contain any key fields. As already mentioned, all of this information is available in the documentation. However, something seems to prevent readers from fol lowing the references to descriptions for keys in the SORT documentation. Fur thermore, too little attention seems to be paid to the fact that the online docu mentation is organized in a tree structure and, as a result, it may also be worthwhile for the reader to select neighboring nodes. This book hopes to contribute to avoiding such issues because printed informa tion is usually better documented than transient online information. Therefore, delve into this book, read everything there is to read about a statement (and not only the addition currently being used), and browse the ABAP glossary—some thing that you will probably never do online. Use this opportunity to learn all about ABAP rather than dipping into it occasionally via im . As the author responsible for the ABAP keyword documentation, it gives me great pleasure to create a well-formatted, high-quality book in conjunction with Galileo Press. As always, I wish to thank Mr. Florian Zimniak, my editor at Galileo Press, for his expert project management and editing skills. From almost 2,000 pages of HTML text, Dirk Hemke from SatzPro created a Word version of the manuscript, which Kai Ortmann reviewed and polished. Both men saved me a great deal of work. The additional formatting work performed by my student assistant, Ms. Lisa Monshausen, was a great help to me, and her initial proofing of the German text ensured that all of the Is were dotted and the Ts crossed. I also wish to thank Ms. Alexandra Muller for her excellent proof-reading skills and Ms. Iris Warkus for her, as always, competent production work. The last two tasks, in particular, were key ingredients for setting this version of the book apart from the online version. The latter is especially true for the English edition, for which I have checked the translation line-by-line, and which in this respect represents a real added value. Here, it was a pleasure working with Kelly Grace Harris from Galileo Press. Last but not least, I wish to thank all of the employees in the TD Core AS&VM area of SAP as well as any other ABAP developers who pointed out errors, omissions, and comprehension difficulties in the ABAP documentation, and therefore made a significant contribution to the quality of this book. Last, but by no means least, I wish to thank my wife Ute for her support in recent months. Even though it didn't take as long to create this manuscript (compared to 20 Preface previous editions), the work was much more intensive, and for the English edi tion it started all over again. Such a tour de force would not have been possible without the understanding of my dear wife. Horst Keller Knowledge Architect, SAP AG, TD Core AS&VM 21 1 Introduction The Official ABAP Reference provides a complete description of the language ele ments that have been released for use with the programming language ABAP, organized according to their thematic relationships. This description also includes obsolete language elements that are no longer recommended for use in new pro grams but are still part of existing programs. However, language elements that are only intended for internal use in system programs are not included. The Official ABAP Reference is therefore a reference book for everyday use when working with ABAP. For a comprehensive introduction to ABAP programming and the ABAP environment, please refer to ABAP Objects (SAP PRESS, 2006). Even though The Official ABAP Reference contains numerous references to the use of ABAP, please refer to ABAP Programming Guidelines (SAP PRESS, 2009), which provides a compact description of how to use ABAP today. In order to illustrate the syntax and semantics of ABAP statements, we have also displayed programs and sections of programs in this book. The syntax examples are not intended to be applied directly to a production system environment. Rather, the primary purpose of the source texts provided in the examples is to better explain and visualize the syntax and semantics behind ABAP statements, not to solve specific programming tasks. Therefore, a tailor-made solution should always be developed for production application programs. 1.1 Releases Used SAP NetWeaver Application Server, Release 7.0, is the basis for this latest edition of The Official ABAP Reference. This is the most commonly used release at present. Changes between Release 6.40 (the release described in the previous edition of The Official ABAP Reference) and Release 7.0 are not highlighted in this edition. One example of such a change is the description of regular expressions in charac ter string processing, which ABAP first supports as of Release 7.0. Up to and including AS ABAP, Release 7.0, SAP followed a strict linear release policy whereby an AS ABAP release, an earlier Web Application Server release or an earlier SAP Basis release always followed on from the preceding release. In 23 1 Introduction other words, Release 7.0 followed on from Releases 6.40, 6.20, 4.6, and so on, and each higher release always included all of the earlier releases. This policy has now changed. Since a Basis release upgrade always requires cus tomers to invest a great deal of time and money, SAP has promised its existing Release 7.0 customers that it will keep this release stable over a longer period of time. The adoption of functional new features supplied by SAP no longer requires the customer to upgrade to a higher release. Instead, these new features are pro vided in the form of Enhancement Packages (EhPs). An EhP can be imported into an existing release with minimal effort and without having to change the existing code. Enhancement Packages 1 and 2 (EhPl and EhP2 with the release IDs 7.01 and 7.02) are currently available for Release 7.0. Parallel to the EhPs, which normally do not contain any noteworthy enhance ments to the application server itself, the ABAP programming language and its environment will continue to be developed on an ongoing basis for genuine new releases, as was previously the case. In other words, Releases 7.1, 7.2, and so on, followed on from Release 7.0. However, the new features of these SAP NetWeaver releases benefited only a few users. Since many enhancements are extremely important, long-awaited new features (e.g., fundamentally improved handling of expressions, secondary keys for internal tables, new approaches to character string processing and, lest we forget, considerable improvements to tools such as Class Builder and ABAP Debugger), there was naturally an increased demand for these new features among all users who remained at Release 7.0. The good news is that, as a result of this demand, almost all of the new features of ABAP and associated tools, which were developed in the successive releases (Releases 7.1, 7.2), were backported to Release 7.02 or Release 7.0 EhP2. With the exception of the operational package concept and class-based exceptions for RFC (available in Release 7.2 only), Release 7.0 EhP2 and Release 7.2,, are largely the same concerning the ABAP language and its tools, and can therefore be pre sented together in this book.1 1 In AS ABAP 7.3, which is part of the recent standalone release of SAP NetWeaver 7.3, there have been no enhancements to ABAP. Therefore, the description provided for Release 7.2 still applies, and 7.2 and 7.3 can be regarded as synonyms in this book. Any ABAP enhancements since Release 7.2 are contained in another release that is currently only available for internal SAP develop ments. 24 1.2 New Features in Releases 7.02 and 7.2 The Official ABAP Reference therefore describes Release 7.0, including all new fea tures for Release 7.0 EhP2 and Release 7.2: ► Any new features in both Release 7.0 EhP2 and Release 7.2 are indicated in the •*^7.2 page margin with a corresponding icon and the text "Release 7.02/7.2." ► The few new features in Release 7.2 only are also indicated in the page margin 7.2 with a corresponding icon and the text "Release 7.2." Intermediate releases such as Release 7.1 and Release 7.11 (i.e., Release 7.1 EhPl) are not listed separately here. Instead, they are summarized under Release 7.2. For an exact history of the release-dependent changes between Release 7.0 and Release 7.2, please refer to the section entitled "Release-Dependent Changes" in the ABAP keyword documentation (search for the term "News"). 1.2 New Features in Releases 7.02 and 7.2 This section summarizes the most important new features in Releases 7.02 and *^^7.2 7.2 when compared with Release 7.0. Unless otherwise specified, the new fea tures apply to both releases. New features that apply only to Release 7.2 are indi cated accordingly. For a complete list, please refer to the section entitled "Release- Dependent Changes" in the ABAP keyword documentation. 1.2.1 New Features in ABAP The following new features are currently available and are described in this book: -^^7.2 ► On-demand loading This is an internal optimization whereby programs are only loaded when an element declared in the program is actually required. For example, a class of the type "class" is no longer loaded for a type reference TYPE REF TO class but rather for access to a component within the class or for access to the actual class itself. Consequently, the TYPE-POOLS statement and the LOAD addition for CLASS and INTERFACE are no longer required. ► Pragmas Pragmas can be used to suppress warnings from the syntax check that is per formed by ABAP Compiler and other check tools (see Section 7.1). These replace the conventional pseudo comments that were used previously. 25 1 | Introduction ► Enhanced expressions The usability of functions and expressions in operand positions has been enhanced considerably (see Section 3.2.5). For example, you can now use arithmetic expressions in logical expressions such as a + b > c - d. Furthermore, you can specify expressions and functions as actual parameters. Alternatively, chained method calls are now possible. Lastly, many new built-in functions have been implemented using several named parameters. ► Logical expressions New built-in functions are available for logical expressions. Here, Boolean functions assess logical expressions while predicate functions have truth values as a return value (see Section 21.2). Furthermore, there is a new EQUIV operator for equivalence operations (see Section 21.1.4). ► Class-based exceptions The RESUME statement has added a resume option during exception handling to class-based exceptions (see Section 22.3.1). Furthermore, a new RETRY state ment makes it possible to retry a TRY block. ► Support for decimal floating point numbers In the long term, the new built-in data types decfloatl6 and decfloat34 for decimal floating point numbers will replace type f for binary floating point numbers. They solve the problem of binary floating point numbers not being able to accurately display each decimal number. They also have a much larger range of values in comparison to packed numbers of the type p (see Section 11.1.1). Like any built-in data type, decimal floating point numbers are sup ported in every respect, have corresponding built-in data types in the ABAP Dictionary, and facilitate accurate calculations (see Section 27.1.1). 7.2 ► Package visibility As of Release 7.2, you can use the OPEN FOR PACKAGE addition to allow access to the protected components of a class within the class package. A new visibility section called PACKAGE SECTION contains components that are only visible in the package of the class (see Section 14.1.3). ► Exact assignments The new EXACT addition for the MOVE and MOVE-CORRESPONDING statements makes it possible to have lossless assignments, which cause an exception dur ing a loss of data or when values are invalid. 26 1.2 New Features in Releases 7.02 and 7.2 | ► Character string processing and byte string processing Considerable progress has been made in this area. New character string expres sions, which may contain a chaining operator and character string templates, can be used directly in operand positions (see Section 28.3). An extensive set of new character string functions, which can also be used in operand positions, extends and enhances the existing character string statements (see Section 28.4). ► Boxed components A boxed component is a new type of structured component for structures and classes. Such components are declared with the addition BOXED. Like strings and internal tables, they are based on implicit referencing, and they support initial value sharing, thus making it possible to avoid unnecessary memory consumption of initial components (see Section 13.1.4). ► Internal tables The option of using secondary table keys has been added to internal tables, thus permitting considerably more efficient key accesses to any internal table (see Section 29.1.3). Furthermore, the option of using a dynamic WHERE condi tion has been implemented for the following statements: LOOP AT itab, MODIFY i tab, and DELETE i tab. ► Shared objects Memory bottlenecks in the shared objects memory now trigger treatable exceptions of class CX_SHM_0UT_0F_MEM0RY. Previously, untreatable runtime errors occurred. ► Splitter controls for screens A splitter control enables you to arrange two subscreens above one another or next to one another whereby the user can move the boundary between the subscreen areas. ► Database accesses Streaming and locators allow a new sequential access or section-by-section access to strings in database tables, thus avoiding having to upload too much data to the application server (see Section 37.2.5). ► Remote Function Call The format basXML is supported as a new uniform RFC protocol that will replace older formats. As of Release 7.2, you can specify exception classes in the interfaces of remote-enabled function modules, and you can treat class- 27
Description: