Horst Keller The Official ABAP™ Reference Volume I Bonn (cid:2) Boston 337766vvooll11..iinndddd 33 1166..0066..22001111 1188::3344::0044 Contents at a Glance Volume I PART 1 ABAP Overview ...................................................................... 33 PART 2 ABAP Syntax ........................................................................... 39 PART 3 Program Structure ................................................................. 71 PART 4 Declarative Statements ........................................................ 145 PART 5 Generating Objects ............................................................... 273 PART 6 Executing Program Units ..................................................... 295 PART 7 Program Flow Control .......................................................... 371 PART 8 Assignments ........................................................................... 435 PART 9 Processing Internal Data ...................................................... 517 Volume II PART 10 User Dialogs ........................................................................... 829 PART 11 Processing External Data ..................................................... 1053 PART 12 Program Parameters .............................................................. 1259 PART 13 Program Processing ............................................................... 1293 PART 14 Data and Communication Interfaces ................................. 1329 PART 15 Enhancements ........................................................................ 1401 PART 16 Obsolete Statements ............................................................ 1419 www.sap-press.com 337766vvooll11..iinndddd 55 1166..0066..22001111 1188::3344::0044 Contents Preface ............................................................................................................. 19 1 Introduction ............................................................................. 23 1.1 Releases Used .............................................................................. 23 1.2 New Features in Releases 7.02 and 7.2 ........................................ 25 1.2.1 New Features in ABAP ................................................... 25 1.2.2 New Features in Tools ................................................... 28 1.3 Syntax Conventions in The Official ABAP Reference ..................... 30 PART 1 ABAP Overview 2 ABAP Programming Language ................................................. 35 2.1 SAP NetWeaver ........................................................................... 35 2.2 Scope and Usage Areas ................................................................ 36 2.3 Programming Models .................................................................. 37 2.4 Unicode ....................................................................................... 37 PART 2 ABAP Syntax 3 Statements ............................................................................... 41 3.1 ABAP Words ............................................................................... 42 3.2 Operands .................................................................................... 42 3.2.1 Names for Single Operands ............................................ 43 3.2.2 Specifying Single Operands ............................................ 49 3.2.3 Operand Position and Type ........................................... 50 3.2.4 Data Objects in Operand Positions ................................ 52 3.2.5 Functions and Expressions in Operand Positions ............ 55 3.3 Operators and Expressions ........................................................... 59 3.3.1 Operators ...................................................................... 59 3.3.2 Expressions .................................................................... 60 7 www.sap-press.com 337766vvooll11..iinndddd 77 1166..0066..22001111 1188::3344::0044 Contents 4 Names ....................................................................................... 61 4.1 Naming Conventions ................................................................... 61 4.2 Name Spaces ............................................................................... 62 5 Chained Statements ................................................................. 63 6 Comments ................................................................................ 65 7 Program Directives ................................................................... 67 7.1 Pragmas ....................................................................................... 67 7.1.1 Pragma Parameters ........................................................ 68 7.1.2 Positioning Pragmas ...................................................... 68 7.2 Pseudo Comments ....................................................................... 69 PART 3 Program Structure 8 Program Structure .................................................................... 73 9 Programs .................................................................................. 75 9.1 Standalone Programs ................................................................... 75 9.1.1 Program Types ............................................................... 75 9.1.2 Introductory Program Statement .................................... 76 9.2 Executable Programs ................................................................... 77 9.2.1 Additions for the Basic List of the Program .................... 78 9.2.2 Addition for the Message Class ...................................... 80 9.2.3 Addition for Subroutine Pools ........................................ 80 9.3 Module Pools and Subroutine Pools ............................................ 80 9.4 Function Groups .......................................................................... 82 9.5 Class Pools ................................................................................... 84 9.6 Interface Pools ............................................................................. 85 9.7 Type Groups ................................................................................ 86 10 Modularization ......................................................................... 89 10.1 Procedures .................................................................................. 89 10.1.1 Parameter Interface of Procedures ................................. 90 8 www.sap-press.com 337766vvooll11..iinndddd 88 1166..0066..22001111 1188::3344::0044 Contents 10.1.2 Method Implementation ............................................... 92 10.1.3 Function Modules ......................................................... 93 10.2 Dialog Modules ........................................................................... 99 10.3 Event Blocks ................................................................................ 100 10.3.1 Program Constructor ..................................................... 101 10.3.2 Reporting Events ........................................................... 102 10.3.3 Selection Screen Events and List Events ......................... 106 10.4 Source Code Modules .................................................................. 107 10.4.1 Include Programs ........................................................... 107 10.4.2 Macros .......................................................................... 109 11 Built-in Elements ..................................................................... 113 11.1 Built-in Data Types ...................................................................... 113 11.1.1 Built-in ABAP Types ....................................................... 113 11.1.2 Generic ABAP Types ...................................................... 118 11.1.3 Built-in Types in the ABAP Dictionary ............................ 120 11.2 Built-in Data Objects ................................................................... 131 11.2.1 ABAP System Fields ....................................................... 131 11.2.2 space, me, and screen .................................................... 138 11.3 Built-in Functions ........................................................................ 140 11.3.1 Syntax of Built-in Functions ........................................... 140 11.3.2 Overview of Built-in Functions ....................................... 141 PART 4 Declarative Statements 12 Types and Objects .................................................................... 147 12.1 Validity and Visibility ................................................................... 148 12.2 Absolute Type Names .................................................................. 149 12.3 Shared Objects ............................................................................ 152 13 Data Types and Data Objects .................................................. 153 13.1 Declaring Data Types ................................................................... 153 13.1.1 Defining Types with Predefined ABAP Types .................. 154 13.1.2 Defining Types by Referring to Existing Types ................ 155 13.1.3 Defining Reference Types .............................................. 156 13.1.4 Defining Structured Types .............................................. 158 9 www.sap-press.com 337766vvooll11..iinndddd 99 1166..0066..22001111 1188::3344::0044 Contents 13.1.5 Defining Table Types ..................................................... 164 13.1.6 Defining Ranges Table Types ......................................... 174 13.1.7 Defining LOB Handle Structures .................................... 175 13.2 Declaring Data Objects ................................................................ 179 13.2.1 Literals .......................................................................... 179 13.2.2 Declaring Variables ........................................................ 182 13.2.3 Declaring Constants ....................................................... 194 13.2.4 Declaring Static Data Objects in Procedures .................. 195 13.2.5 Declaring Table Work Areas ........................................... 196 13.2.6 Declaring Data Objects for HR Infotypes ........................ 200 14 Classes and Interfaces .............................................................. 203 14.1 Defining Classes ........................................................................... 203 14.1.1 Declaration .................................................................... 204 14.1.2 Specifying Class Properties ............................................. 205 14.1.3 Visibility Sections of Classes ........................................... 213 14.1.4 Class Components ......................................................... 217 14.1.5 Implementation Section ................................................. 218 14.1.6 Declaring Classes ........................................................... 220 14.1.7 Local Friends of Global Classes ....................................... 221 14.2 Defining Interfaces ...................................................................... 221 14.2.1 Definition ...................................................................... 222 14.2.2 Interface Components ................................................... 223 14.2.3 Declaring Interfaces ....................................................... 224 14.3 Declaring Components ................................................................ 224 14.3.1 Attributes and Data Types ............................................. 224 14.3.2 Methods ........................................................................ 226 14.3.3 Events ........................................................................... 249 14.3.4 Interface Components ................................................... 252 15 Field Symbols ........................................................................... 259 16 Typing ....................................................................................... 261 16.1 Syntax of Typing .......................................................................... 261 16.1.1 Generic Typing .............................................................. 262 16.1.2 Complete Typing ........................................................... 264 10 www.sap-press.com 337766vvooll11..iinndddd 1100 1166..0066..22001111 1188::3344::0044 Contents 16.2 Checking the Typing .................................................................... 265 16.2.1 General Rules ................................................................ 265 16.2.2 Return Values of Functional Methods ............................ 267 16.2.3 Literals as Actual Parameters ......................................... 268 16.2.4 Functions and Expressions as Actual Parameters ............ 270 PART 5 Generating Objects 17 Creating Objects ...................................................................... 275 17.1 Creating Data Objects .................................................................. 275 17.1.1 Defining the Data Type Implicitly .................................. 276 17.1.2 Defining the Data Type Through Built-in ABAP Types .... 277 17.1.3 Defining Data Through an Existing Type ........................ 278 17.1.4 Creating Data with Reference to a Type Object .............. 280 17.1.5 Creating Reference Variables ......................................... 281 17.1.6 Creating Internal Tables ................................................. 282 17.1.7 Creating Shared Objects ................................................ 284 17.1.8 Treatable Exceptions ...................................................... 287 17.2 Creating Instances of Classes ........................................................ 287 17.2.1 Specifying the Class Implicitly ........................................ 288 17.2.2 Specifying the Class Explicitly ......................................... 289 17.2.3 Creating Shared Objects ................................................ 290 17.2.4 Static Parameter Passing ................................................ 291 17.2.5 Dynamic Parameter Passing ........................................... 292 17.2.6 Treatable Exceptions ...................................................... 294 PART 6 Executing Program Units 18 Calling Programs ...................................................................... 297 18.1 Calling Executable Programs ........................................................ 297 18.1.1 Processing an Executable Program ................................. 297 18.1.2 Calling of an Executable Program ................................... 299 18.2 Calling Transactions ..................................................................... 315 18.2.1 Calling a Transaction with Returning to the Calling Program ............................................................. 315 18.2.2 Calling a Transaction without Returning to the Calling Program ............................................................. 321 11 www.sap-press.com 337766vvooll11..iinndddd 1111 1166..0066..22001111 1188::3344::0055 Contents 19 Calling Processing Blocks ........................................................ 323 19.1 Calling Procedures ....................................................................... 323 19.1.1 Internal and External Procedure Call .............................. 323 19.1.2 Calling Methods ............................................................ 327 19.1.3 Calling Function Modules .............................................. 341 19.1.4 Calling Subroutines ........................................................ 349 19.2 Calling Event Handlers ................................................................. 354 19.2.1 Triggering Events ........................................................... 354 19.2.2 Registering Event Handlers ............................................ 355 19.3 Calling Event Blocks ..................................................................... 359 20 Exiting Program Units .............................................................. 361 20.1 Leaving Programs ........................................................................ 361 20.2 Exiting Processing Blocks ............................................................. 362 20.2.1 Terminating Processing Blocks Normally ........................ 362 20.2.2 Exiting Processing Blocks Unconditionally ...................... 363 20.2.3 Exiting Processing Blocks Conditionally .......................... 366 20.3 Exiting Loops ............................................................................... 368 20.3.1 Exiting Loops Unconditionally ........................................ 368 20.3.2 Exiting Loop Passes Unconditionally .............................. 369 20.3.3 Exiting Loop Passes Conditionally .................................. 370 PART 7 Program Flow Control 21 Logical Conditions .................................................................... 373 21.1 Logical Expressions ...................................................................... 373 21.1.1 Comparisons .................................................................. 374 21.1.2 Predicates ...................................................................... 388 21.1.3 Evaluating Selection Tables ............................................ 393 21.1.4 Boolean Operators and Brackets .................................... 395 21.2 Logical Functions ......................................................................... 400 21.2.1 Boolean Functions ......................................................... 400 21.2.2 Predicate Functions ....................................................... 401 12 www.sap-press.com 337766vvooll11..iinndddd 1122 1166..0066..22001111 1188::3344::0055 Contents 22 Control Structures .................................................................... 405 22.1 Branches ...................................................................................... 405 22.1.1 Conditional Branches ..................................................... 406 22.1.2 Case Distinction ............................................................. 407 22.2 Loops .......................................................................................... 408 22.2.1 Unconditional Loops ..................................................... 408 22.2.2 Conditional Loops ......................................................... 409 22.2.3 Interrupting the Program ............................................... 410 22.3 Exception Handling ..................................................................... 411 22.3.1 Class-Based Exceptions .................................................. 411 22.3.2 Exceptions Before the Introduction of Class-Based Exceptions ..................................................................... 428 22.3.3 Exceptions in ABAP Statements ..................................... 432 22.3.4 Runtime Errors .............................................................. 433 PART 8 Assignments 23 Assignment Rules ..................................................................... 437 23.1 Compatibility of Data Types ......................................................... 438 23.1.1 Compatibility of Non-Generic Data Types ...................... 438 23.1.2 Compatibility of Generic Data Types .............................. 439 23.1.3 Reference Types ............................................................ 439 23.2 Conversion Rules for Elementary Data Objects ............................. 440 23.2.1 Source Field Type c ........................................................ 441 23.2.2 Source Field Type d ....................................................... 444 23.2.3 Source Field Type decfloat16 or decfloat34 ................... 446 23.2.4 Source Field Type f ........................................................ 448 23.2.5 Source Field Type i, b, or s ............................................. 449 23.2.6 Source Field Type n ....................................................... 452 23.2.7 Source Field Type p ....................................................... 453 23.2.8 Source Field Type string ................................................. 454 23.2.9 Source Field Type t ........................................................ 455 23.2.10 Source Field Type x ........................................................ 457 23.2.11 Source Field Type xstring ............................................... 458 23.2.12 Numeric Values in Character-Type Fields ....................... 459 13 www.sap-press.com 337766vvooll11..iinndddd 1133 1166..0066..22001111 1188::3344::0055 Contents 23.3 Conversion Rules for Structures ................................................... 461 23.3.1 Unicode Fragment View ................................................ 462 23.3.2 Conversion between Flat Structures ............................... 463 23.3.3 Conversion between Flat Structures and Single Fields .... 466 23.4 Conversion Rules for Internal Tables ............................................ 467 23.5 Assignment Rules for Reference Variables .................................... 467 23.5.1 Static and Dynamic Type ............................................... 468 23.5.2 Assignments between Data Reference Variables ............ 469 23.5.3 Assignments between Object Reference Variables ......... 470 23.6 System Class for Character Set Conversion and NumberFormat Conversion .................................................................................. 472 24 Assigning Values ...................................................................... 473 24.1 General Assignment ..................................................................... 474 24.2 Lossless Assignment ..................................................................... 476 24.2.1 Lossless Assignment of Elementary Data Objects ........... 477 24.2.2 Lossless Assignment of Structures .................................. 484 24.2.3 Lossless Assignment of Internal Tables ........................... 484 24.2.4 Lossless Assignment of Reference Variables ................... 485 24.2.5 Treatable Exceptions ...................................................... 485 24.3 Multiple Assignments .................................................................. 486 24.4 Assigning Structure Components ................................................. 486 24.5 Special Assignment of a Packed Number ...................................... 489 25 Setting References ................................................................... 491 25.1 Assigning Data Objects to Field Symbols ..................................... 491 25.1.1 Specifying the Memory Area .......................................... 492 25.1.2 Specifying the Data Type ............................................... 503 25.1.3 Specifying Area Limits .................................................... 506 25.1.4 Treatable Exceptions ...................................................... 509 25.2 Retrieving Data References .......................................................... 510 26 Initializations ........................................................................... 513 26.1 Initializing Data Objects ............................................................... 513 26.2 Releasing Memory ....................................................................... 514 26.3 Initializing Field Symbols ............................................................. 515 14 www.sap-press.com 337766vvooll11..iinndddd 1144 1166..0066..22001111 1188::3344::0055
Description: