Click here to load reader

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

  • View
    239

  • Download
    6

Embed Size (px)

Text of ABAP Objects - · PDF fileBonn Boston Horst Keller, Sascha Krüger ABAP® Objects ABAP...

  • Bonn Boston

    Horst Keller, Sascha Krger

    ABAP ObjectsABAP 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 ABAPEvents 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

  • 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

  • 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

  • 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

  • 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 ..................