Table of Contents

Open all
Close all
Preface
17
Audience
17
Your ABAP Learning Path
18
SAP Professional with Some Knowledge of ABAP
18
SAP Professional or Power User with No Knowledge of ABAP or Other Programming Languages
19
Professional Developer with No Knowledge of ABAP
20
Reader with No Knowledge of SAP, ABAP, or Any Programming Languages
21
Where to Go from Here?
21
1 Introduction to SAP’s ERP Systems
23
1.1 What Are SAP and ABAP?
23
1.2 Current State of SAP’s ERP Systems
24
1.3 “Old” versus “New” ABAP
26
1.4 Navigating SAP ERP Systems
28
1.4.1 Overview of SAP GUI
29
1.4.2 Overview of SAP Fiori
33
1.5 Summary
34
2 Creating Your First Program
35
2.1 “Hello, World!”
35
2.1.1 Creating a New Program with Eclipse
35
2.1.2 Creating a New Program in Transaction SE80
40
2.1.3 Writing a “Hello, World!” Program
45
2.1.4 Adding Features to Your First Program
46
2.2 Summary
49
3 ABAP 101
51
3.1 Variables and Constants in ABAP
51
3.1.1 The DATA Keyword
51
3.1.2 Numeric Data Types
53
3.1.3 Character-like Data Types
55
3.1.4 Boolean
57
3.1.5 Structures and Internal Tables
58
3.1.6 Inline Data Declarations
61
3.1.7 Constants
62
3.1.8 System Fields and Predefined Constants
63
3.2 Arithmetic and Basic Math Functions
65
3.2.1 Arithmetic Operations
65
3.2.2 Math Functions
68
3.2.3 CLEAR Command
70
3.3 Flow Control
72
3.3.1 IF Statements
72
3.3.2 CASE Statements
76
3.3.3 DO Loops
79
3.3.4 WHILE Loops
79
3.4 Selection Screen Programming
80
3.4.1 PARAMETER
81
3.4.2 SELECT-OPTIONS
85
3.4.3 Selection Texts
87
3.4.4 SELECTION-SCREEN
88
3.4.5 BLOCK
88
3.4.6 Other Selection Screen Elements
91
3.5 Event Blocks
92
3.5.1 INITIALIZATION
93
3.5.2 AT SELECTION-SCREEN
93
3.5.3 START-OF-SELECTION
95
3.6 Formatting Code
95
3.7 Comments
97
3.7.1 Common Commenting Mistakes
98
3.7.2 Using Comments while Programming
100
3.8 Debugging Basics
100
3.8.1 Program to Debug
101
3.8.2 Breakpoints in Eclipse
103
3.8.3 Breakpoints in the SAP GUI
108
3.8.4 Watchpoints in Eclipse
113
3.8.5 Watchpoints in SAP GUI
116
3.9 Tying It All Together
117
3.9.1 The Problem
118
3.9.2 The Solution
119
3.10 Summary
120
4 Data Dictionary Objects
121
4.1 What Is a Database?
121
4.2 What Is a Data Dictionary?
122
4.3 Database Design
123
4.3.1 Entity Relationship Diagrams
123
4.3.2 Database Normalization
124
4.3.3 Relationships in ERDs
126
4.4 Navigation to ABAP Dictionary Objects
127
4.5 Table, Data Element, and Domain
129
4.6 Training Data Model and Example Definition
132
4.6.1 SAP Flight and Booking Data Model
133
4.6.2 Training Example: Enhancing the SAP Model
134
4.7 Creating a New Domain
135
4.8 Creating a New Data Element
139
4.9 Creating and Editing Tables
144
4.9.1 Viewing the Flight Table Configuration
144
4.9.2 Creating an Append Structure
151
4.9.3 Creating a Custom Transparent Table
154
4.10 Documentation
161
4.11 Viewing Data in the Database Tables
162
4.11.1 Data Preview in Eclipse
162
4.11.2 Data Browser in SAP GUI
164
4.11.3 Setting Up the Flights Example Data
169
4.12 Table Maintenance Dialogs
170
4.12.1 Generating Maintenance Dialog for a Table
170
4.12.2 Table Maintenance Transaction SM30
172
4.13 Structures and Table Types
174
4.13.1 Creating Structures
174
4.13.2 Creating Table Types
176
4.14 Search Help
177
4.15 Views
181
4.16 Summary
184
5 Accessing the Database
185
5.1 SQL Console in Eclipse
186
5.2 Reading Data
187
5.2.1 SELECT Statements
188
5.2.2 INNER JOIN
192
5.2.3 LEFT OUTER JOIN
197
5.2.4 FOR ALL ENTRIES IN
199
5.2.5 With SELECT-OPTIONS
201
5.2.6 Aggregate Expressions in SELECT Statements
203
5.2.7 New Open SQL
205
5.2.8 ABAP CDS Views
207
5.3 Changing Data
210
5.3.1 INSERT
210
5.3.2 MODIFY/UPDATE
211
5.3.3 DELETE
213
5.4 Table Locks
214
5.4.1 Viewing Table Locks
216
5.4.2 Creating Table Lock Objects
218
5.4.3 Setting Table Locks
220
5.5 Performance Topics
224
5.6 Obsolete Database Access Keywords
226
5.6.1 SELECT…ENDSELECT
226
5.6.2 Short Form Open SQL
227
5.7 Summary
227
6 Storing Data in Working Memory
229
6.1 Using ABAP Dictionary Data Types
229
6.2 Creating Data Types with the TYPE Keyword
231
6.3 Field Symbols
233
6.4 Defining Internal Tables
234
6.4.1 Defining Standard Tables
234
6.4.2 Keys in Internal Tables
236
6.4.3 Defining Sorted Tables
238
6.4.4 Defining Hashed Tables
240
6.5 Reading Data from Internal Tables
241
6.5.1 READ TABLE
241
6.5.2 LOOP AT
247
6.6 Modifying Internal Tables
250
6.6.1 Inserting/Appending Rows
250
6.6.2 Changing Rows
253
6.6.3 Deleting Rows
255
6.7 Other Internal Table Operations
257
6.7.1 Copying Table Data
257
6.7.2 SORT
258
6.7.3 DELETE ADJACENT DUPLICATES FROM
260
6.8 Which Table Should Be Used?
261
6.9 Updating ABAP Dictionary Table Type
263
6.10 Obsolete Working Memory Syntax
265
6.10.1 WITH HEADER LINE
266
6.10.2 OCCURS
266
6.10.3 Square Brackets
267
6.10.4 Short Form Table Access
267
6.10.5 BINARY SEARCH
267
6.11 Summary
268
7 Making Programs Modular
269
7.1 Separation of Concerns
269
7.2 Subroutines
272
7.3 Introduction to Object-Oriented Programming
274
7.3.1 What Is an Object?
274
7.3.2 Modularizing with Object-Oriented Programming
276
7.4 Structuring Classes
277
7.4.1 Implementation versus Definition
278
7.4.2 Creating Objects
278
7.4.3 Public and Private Sections
280
7.4.4 Class Methods
282
7.4.5 Importing, Returning, Exporting, and Changing
286
7.4.6 Constructors
293
7.4.7 Recursion
295
7.4.8 Inheritance
297
7.4.9 Composition
302
7.5 Global Classes
308
7.5.1 How to Create Global Classes in Eclipse
309
7.5.2 How to Create Global Classes in Transaction SE80
310
7.5.3 Using the Form-Based View in Transaction SE80
312
7.6 Design Patterns
317
7.7 Function Modules
317
7.7.1 Creating Function Groups and Modules in Eclipse
318
7.7.2 Creating Function Groups in Transaction SE80
322
7.7.3 Calling Function Modules
326
7.8 Summary
327
8 Error Handling
329
8.1 SY-SUBRC
329
8.2 Message Classes
331
8.2.1 Displaying a Message Class
331
8.2.2 Creating a Message Class
333
8.2.3 Using the MESSAGE Keyword
336
8.3 Exception Classes
341
8.3.1 Unhandled Exceptions
342
8.3.2 TRY/CATCH Statements
348
8.3.3 Custom Exception Classes
350
8.4 Non-Class-Based Exceptions
355
8.5 Summary
358
9 Presenting Data Using the ABAP List Viewer
361
9.1 What Is ALV?
361
9.2 Report Example Using an SALV Table
366
9.3 Report Example Using SALV Tree
371
9.4 ALV with Integrated Data Access
380
9.5 Outdated ALV Frameworks
383
9.5.1 REUSE_ALV_GRID_DISPLAY Function Module
383
9.5.2 CL_GUI_ALV_GRID Class
385
9.6 Summary
386
10 Creating a Shopping Cart Example
387
10.1 The Design
388
10.1.1 The Database
389
10.1.2 The Global Class
390
10.1.3 The Access Programs
390
10.2 Database Solution
392
10.2.1 Data Elements
392
10.2.2 Transparent Tables
397
10.3 Accessing the Database Solution
405
10.4 Creating a Message Class for the Solution
415
10.5 Creating Classic Screens for the Solution
416
10.5.1 Product Maintenance Program
417
10.5.2 Shopping Cart Maintenance Program
423
10.6 Summary
429
11 Working with Strings and Texts
431
11.1 String Manipulation
431
11.1.1 String Templates
432
11.1.2 String Functions
435
11.2 Text Symbols
437
11.2.1 Creating Text Symbols
437
11.2.2 Translating Text Symbols
442
11.3 Translating Data in Tables
445
11.4 Translating Messages
451
11.5 Obsolete String and Text Commands
453
11.6 Updating the Shopping Cart Example
454
11.6.1 Updating the Database
454
11.6.2 Using the Text Table
460
11.7 Summary
463
12 Working with Dates, Times, Quantities, and Currencies
465
12.1 Dates
465
12.1.1 Date Type Basics
466
12.1.2 Factory Calendars
469
12.1.3 Datum Date Type
473
12.1.4 System Date Fields
475
12.1.5 Date-Limited Records
475
12.2 Times
477
12.2.1 Calculating Time
477
12.2.2 Timestamps
478
12.2.3 SY-UZEIT (System Time versus Local Time)
482
12.3 Quantities
482
12.3.1 Quantity Fields in Data Dictionary
484
12.3.2 Converting Quantities
485
12.4 Currencies
486
12.4.1 Currency Fields in Data Dictionary
487
12.4.2 Converting Currencies
488
12.5 Updating the Shopping Cart Example
490
12.5.1 Updating the Database
491
12.5.2 Updating the Global Class
497
12.5.3 Updating the ABAP Programs
500
12.6 Summary
504
13 User Interface Technologies
505
13.1 Working with Classic Dynpro Screens
505
13.1.1 Dynpro Screen Events
506
13.1.2 Creating a Dynpro Screen
508
13.2 Modern UI Technologies
528
13.2.1 Web Dynpro
529
13.2.2 SAP Screen Personas
531
13.2.3 SAP Gateway, SAPUI5, and SAP Fiori
532
13.3 Summary
534
14 Working with ABAP Professionally
535
14.1 ABAP System Architecture Basics
535
14.2 Transport Management
539
14.3 Authorization Concept
550
14.3.1 Authorization Object
550
14.3.2 Performing an Authorization Check in an ABAP Program
560
14.4 Working with Files
566
14.4.1 Files on the Presentation Server
567
14.4.2 Files on the Application Server
577
14.5 ABAP Development Guidelines
582
14.6 Maintaining Documentation
586
14.7 ABAP Unit Tests
593
14.8 Background Jobs
602
14.9 Tools of the Trade
611
14.10 Backward Compatibility and Dealing with Legacy Code
621
14.11 Summary
623
A Preparing Your Development Environment
627
A.1 ABAP Developer Edition Overview
627
A.2 ABAP Trial System Using SAP CAL
630
A.3 ABAP Trial System Using the Download Option
632
A.4 Getting Started with ABAP in Eclipse
633
A.4.1 Eclipse Workspaces
633
A.4.2 Eclipse Perspectives
634
A.4.3 ABAP Projects in Eclipse
636
A.5 ABAP-Based IDEs
639
A.5.1 Transaction SE80
639
A.5.2 Other ABAP IDE Transactions
643
B Interfaces, Forms, Enhancements
645
B.1 Interfaces
645
B.1.1 File Interfaces
645
B.1.2 Remote Function Call
646
B.1.3 IDoc and EDI
647
B.1.4 Web Services
648
B.2 Output Implementation in SAP ERP
649
B.2.1 Output Programs
650
B.2.2 Forms
650
B.3 Enhancements
654
C Differences Between ABAP Versions
661
C.1 Release 7.0
661
C.2 Release 7.02 (7.0 EHP 2)
662
C.3 Release 7.4
663
C.4 Release 7.4 SP 5
663
C.5 Release 7.4 SP 8
663
C.6 Release 7.50
664
C.7 Release 7.51
664
C.8 Release 7.52
664
C.9 Release 7.53
665
D Other Resources
667
D.1 SAP PRESS Books
667
D.2 SAP Community
668
D.3 openSAP
669
D.4 SAP Certifications
669
D.5 SAP TechEd Conferences
669
D.6 SAP Community Events
670
E The Authors
671
Index
673