Online Tutorials & Training Materials | STechies.com
Register Login

Object-Oriented Programming with ABAP Objects

|| || 0 Download

Object-Oriented Programming with ABAP Objects
Stechies

Contents

Introduction ............................................................................................... 15
PART I: Basics  
1 Introduction to Object-Oriented Programming ........................ 23
1.1 The Need for a Better Abstraction ..................................................
1.2 Classes and Objects ........................................................................
1.3 Establishing Boundaries ..................................................................
1.4 Reuse .............................................................................................
1.4.1 Composition ......................................................................
1.4.2 Inheritance ........................................................................
1.4.3 Polymorphism ....................................................................
1.5 Object Management .......................................................................
1.6 UML Tutorial: Class Diagram Basics ................................................
1.6.1 Classes ...............................................................................
1.6.2 Attributes ..........................................................................
1.6.3 Operations .........................................................................
1.6.4 Associations .......................................................................
1.6.5 Notes .................................................................................
1.7 Summary ........................................................................................
23
24
27
29
29
30
31
33
33
34
36
37
38
39
39
2 Working with Objects ................................................................ 41
2.1 Syntax Overview .............................................................................
2.1.1 Defining Classes .................................................................
2.1.2 Declaring Components .......................................................
2.1.3 Implementing Methods ......................................................
2.2 Creating and Using Objects .............................................................
2.2.1 Object References ..............................................................
2.2.2 Creating Objects ................................................................
2.2.3 Object Reference Assignments ...........................................
2.2.4 Working with Instance Components ..................................
2.2.5 Working with Class Components ........................................
2.2.6 Creating Complex Expressions Using Functional
Methods ............................................................................
2.3 Building Your First Object-Oriented Program ..................................
2.4 Getting Started with the Class Builder .............................................
2.4.1 Class Pools .........................................................................
2.4.2 Accessing the Class Builder ................................................
2.4.3 Creating Classes .................................................................
2.4.4 Defining Class Components ................................................
2.4.5 Editing the Class Definition Section Directly .......................
2.5 Case Study: Working with Regular Expressions ...............................
2.6 UML Tutorial: Object Diagrams ......................................................
2.7 Summary ........................................................................................
41
42
42
51
52
52
53
53
54
57

61
64
71
71
71
72
74
82
82
84
86
PART II: Core Concepts  
3 Encapsulation and Implementation Hiding ............................... 89
3.1 Lessons Learned from the Procedural Approach ..............................
3.1.1 Decomposing Functional Decomposition ...........................
3.1.2 Case Study: A Procedural Code Library in ABAP .................
3.1.3 Moving Toward Objects .....................................................
3.2 Data Abstraction with Classes .........................................................
3.3 Defining Component Visibilities ......................................................
3.3.1 Visibility Sections ...............................................................
3.3.2 Friends ...............................................................................
3.4 Hiding the Implementation .............................................................
3.5 Designing by Contract ....................................................................
3.6 UML Tutorial: Sequence Diagrams ..................................................
3.7 Summary ........................................................................................
89
90
91
94
94
95
96
99
101
102
103
105
4 Object Initialization and Cleanup .............................................. 107
4.1 Creating Objects .............................................................................
4.2 Controlling Object Initialization with Constructors ..........................
4.3 Taking Control of the Instantiation Process .....................................
4.4 Garbage Collection .........................................................................
4.5 Tuning Performance .......................................................................
4.5.1 Design Considerations ........................................................
4.5.2 Lazy Initialization ...............................................................
4.5.3 Reusing Objects .................................................................
4.5.4 Using Class Attributes ........................................................
4.6 UML Tutorial: State Machine Diagrams ..........................................
4.7 Summary ........................................................................................

107
111
117
121
122
123
123
124
124
125
126

5 Inheritance ................................................................................. 127
5.1 Generalization and Specialization ...................................................
5.2 Inheriting Components ...................................................................
5.2.1 Designing the Inheritance Interface ....................................
5.2.2 Visibility of Instance Components in Subclasses .................
5.2.3 Visibility of Class Components in Subclasses .......................
5.2.4 Redefining Methods ...........................................................
5.2.5 Instance Constructors .........................................................
5.2.6 Class Constructors ..............................................................
5.3 The Abstract and Final Keywords ....................................................
5.3.1 Abstract Classes and Methods ............................................
5.3.2 Final Classes .......................................................................
5.3.3 Final Methods ....................................................................
5.4 Inheritance Versus Composition .....................................................
5.5 Using the Refactoring Assistant .......................................................
5.6 UML Tutorial: Advanced Class Diagrams Part I ................................
5.6.1 Generalization ....................................................................
5.6.2 Dependencies and Composition .........................................
5.6.3 Abstract Classes and Methods ............................................
5.7 Summary ........................................................................................
128
133
133
135
136
136
138
140
140
140
143
144
145
148
150
150
151
152
153
6 Polymorphism ............................................................................ 155
6.1 Object Reference Assignments Revisited .........................................
6.1.1 Static and Dynamic Types ..................................................
6.1.2 Casting ...............................................................................
6.2 Dynamic Method Call Binding ........................................................
6.3 Interfaces .......................................................................................
6.3.1 Interface Inheritance Versus Implementation Inheritance ...
6.3.2 Defining Interfaces .............................................................
6.3.3 Implementing Interfaces ....................................................
6.3.4 Working with Interfaces .....................................................
6.3.5 Nesting Interfaces ..............................................................
6.4 UML Tutorial: Advanced Class Diagrams Part II ..............................
6.4.1 Interfaces ...........................................................................
6.4.2 Providing and Required Relationships with Interfaces ........
6.4.3 Static Attributes and Methods ...........................................
6.5 Summary ........................................................................................

155
156
158
160
163
164
165
167
170
177
180
180
181
182
182

7 Component-Based Design Concepts ......................................... 183
7.1 Understanding the SAP Component Model ....................................
7.2 The Package Concept .....................................................................
7.2.1 What Is a Package? ............................................................
7.2.2 Creating and Organizing Packages Using the Package
Builder ...............................................................................
7.2.3 Embedding Packages .........................................................
7.2.4 Defining Package Interfaces ...............................................
7.2.5 Creating Use Accesses ........................................................
7.2.6 Performing Package Checks ................................................
7.2.7 Package Design Concepts ...................................................
7.3 UML Tutorial: Package Diagrams ....................................................
7.4 Summary ........................................................................................

183
185
186

188
191
192
194
195
196
197
199

8 Error Handling with Exceptions ................................................. 201
8.1 Lessons Learned from Prior Approaches ..........................................
8.2 The Class-Based Exception Handling Concept .................................
8.3 Dealing with Exceptions .................................................................
8.3.1 Handling Exceptions ..........................................................
8.3.2 Cleaning up the Mess .........................................................
8.4 Raising and Forwarding Exceptions .................................................
8.4.1 System-Driven Exceptions ..................................................
8.4.2 The RAISE EXCEPTION Statement ......................................
8.4.3 Propagating Exceptions ......................................................
8.5 Creating Exception Classes ..............................................................
8.5.1 Understanding Exception Class Types .................................
8.5.2 Local Exception Classes ......................................................
8.5.3 Global Exception Classes ....................................................
8.5.4 Defining Exception Texts ....................................................
8.5.5 Mapping Exception Texts to Message IDs ..........................
8.6 UML Tutorial: Activity Diagrams .....................................................
8.7 Summary ........................................................................................
201
203
205
205
209
210
211
211
215
219
220
221
221
223
227
229
231
9 Unit Testing with ABAP Unit ..................................................... 233
9.1 ABAP Unit Overview ......................................................................
9.1.1 The Need for Unit Testing Frameworks ..............................
9.1.2 Unit Testing Terminology ...................................................
9.1.3 Understanding How ABAP Unit Works ...............................
9.2 Creating Unit Test Classes ...............................................................
9.2.1 Test Attributes ...................................................................
9.2.2 Test Methods .....................................................................
9.2.3 Managing Fixtures .............................................................
9.2.4 Generating Test Classes for Global Classes ..........................
9.3 Case Study: Creating a Unit Test in ABAP Unit ................................
9.4 Executing Unit Tests .......................................................................
9.4.1 Integration with the ABAP Workbench ..............................
9.4.2 Integration with the Code Inspector ...................................
9.5 Evaluating Unit Test Results ............................................................
9.6 Moving Toward Test-Driven Development .....................................
9.7 UML Tutorial: Use Case Diagrams ...................................................
9.7.1 Use Case Terminology ........................................................
9.7.2 An Example Use Case .........................................................
9.7.3 The Use Case Diagram .......................................................
9.7.4 Use Cases for Requirements Verification ............................
9.7.5 Use Cases and Testing ........................................................
9.8 Summary ........................................................................................

234
234
235
236
237
238
239
239
240
241
244
245
245
246
247
248
249
249
251
252
252
253

PART III: Case Studies  
10 Working with the SAP List Viewer ...................................... 257
10.1 Overview of the SAP Control Framework ........................................
10.1.1 Control Framework Architecture ........................................
10.1.2 Survey of Available Controls ...............................................
10.2 Overview of the ALV Object Model ................................................
10.3 Getting Started with the Flight Query Report ..................................
10.3.1 Understanding the Report Requirements ............................
10.3.2 Report Design Using the MVC Design Pattern ....................
10.3.3 Developing the Flight Model Class .....................................
10.3.4 Developing the Report Controller Class ..............................
10.3.5 Implementing the Report View ..........................................
10.4 Event Handling with the ALV Object Model ...................................
10.4.1 Integrating Event Handler Methods into the Controller ......
10.4.2 Registering Event Handler Methods ...................................
10.4.3 Responding to Events ........................................................
10.4.4 Triggering Events on the Frontend .....................................
10.4.5 Timing of Event Handling ...................................................
10.5 UML Tutorial: Communication Diagrams ........................................
10.6 Summary ........................................................................................
257
258
259
260
261
261
261
262
264
267
271
271
272
273
274
275
275
277
11 ABAP Object Services ................................................................ 279
11.1 Object-Relational Mapping Concepts .............................................
11.2 Persistence Service Overview ..........................................................
11.2.1 Managed Objects ...............................................................
11.2.2 Mapping Concepts .............................................................
11.2.3 Understanding the Class Agent API ....................................
11.3 Building Persistent Classes ..............................................................
11.3.1 Creating a Persistent Class in the Class Builder ...................
11.3.2 Defining Persistent Attributes with the Mapping
Assistant ............................................................................
11.3.3 Working with Object References ........................................
11.4 Working with Persistent Objects .....................................................
11.4.1 Creating New Persistent Objects ........................................
11.4.2 Reading Persistent Objects Using the Query Service ...........
11.4.3 Updating Persistent Objects ...............................................
11.4.4 Deleting Persistent Objects ................................................
11.5 UML Tutorial: Advanced Sequence Diagrams ..................................
11.5.1 Creating and Deleting Objects ...........................................
11.5.2 Depicting Control Logic with Interaction Frames ................
11.6 Summary ........................................................................................
280
280
282
284
285
286
287

288
292
293
294
295
297
298
298
298
300
301
12 Working with XML .................................................................... 303
12.1 XML Overview ...............................................................................
12.1.1 Why Do We Need XML? ....................................................
12.1.2 Understanding XML Syntax ................................................
12.1.3 Defining XML Semantics ....................................................
12.2 XML Processing Concepts ...............................................................
12.2.1 Processing XML Using a Parser ...........................................
12.2.2 Modeling XML with the DOM ...........................................
12.2.3 Features of the iXML Library ..............................................
12.3 Case Study: Developing a Reading List ADT ....................................
12.4 Case Study: Building an XML Document .........................................
12.5 Case Study: Reading an XML Document .........................................
12.6 UML Tutorial: Advanced Activity Diagrams .....................................
12.7 Summary ........................................................................................

303
304
305
307
309
309
310
310
311
314
320
325
327

13 Where to Go From Here ............................................................. 329
APPENDIX  
A Debugging Objects ........................................................... 333
A.1 Debugging Objects Using the Classic ABAP Debugger ....................
A.1.1 Displaying and Editing Attributes .......................................
A.1.2 Tracing Through Methods ..................................................
A.1.3 Displaying Events and Event Handler Methods ...................
A.1.4 Viewing Reference Assignments for an Object ....................
A.1.5 Troubleshooting Class-Based Exceptions ............................
A.2 Debugging Objects Using the New ABAP Debugger .......................

333
333
336
336
337
338
340

B The Author .................................................................................. 343
Index ................................................................................................................ 345


 Download attached file.

You must be Logged in to download this file

Related Articles

0.0128 seconds.