Table of Contents

Open all
Close all
Acknowledgments
21
Introduction
23
Structure of the Book
26
Chapter 1: ABAP in Eclipse
27
Chapter 2: abapGit
28
Chapter 3: New Language Features in ABAP
28
Chapter 4: Exception Classes and Design by Contract
28
Chapter 5: ABAP Unit and Test-Driven Development
28
Chapter 6: Debugger Scripting
29
Chapter 7: Database Programming for SAP HANA
29
Chapter 8: Business Object Processing Framework
29
Chapter 9: BRFplus
30
Chapter 10: ALV SALV Reporting Framework
30
Chapter 11: Web Dynpro ABAP and Floorplan Manager
30
Chapter 12: SAPUI5
30
Chapter 13: ABAP Channels
31
Chapter 14: The RESTful ABAP Programming Model
31
The Example Application
31
Baron Frankenstein’s Business Model
32
SAP Developments Required to Support the Business Model
32
1 ABAP in Eclipse
35
1.1 Installation
37
1.1.1 Installing Eclipse
38
1.1.2 Installing SAP-Specific Add-Ons
40
1.1.3 Connecting Eclipse to a Backend SAP System
42
1.2 ABAP-Specific Features
43
1.2.1 Working on Multiple Objects at the Same Time
48
1.2.2 Bookmarking
50
1.2.3 Creating a Method from the Calling Code
51
1.2.4 Extracting a Method
56
1.2.5 Refactoring: Moving Methods and Attributes
61
1.2.6 Deleting Unused Variables
62
1.2.7 Creating Instance Attributes and Method Parameters
63
1.2.8 Creating Class Constructors
63
1.2.9 ABAP 7.5+ Features
65
1.3 Eclipse-Specific Features
73
1.3.1 Neon (2016)
76
1.3.2 Oxygen (2017)
78
1.3.3 Photon (2018)
78
1.4 Testing and Troubleshooting
79
1.4.1 Unit Testing Code Coverage
79
1.4.2 Debugging
83
1.4.3 Runtime Analysis
86
1.4.4 Dynamic Log Points
87
1.5 Customization Options with User-Defined Plug-Ins
89
1.5.1 Favorites List
90
1.5.2 Automatic Pretty Print
92
1.5.3 System Coloring
94
1.6 Eclipse in the Cloud
95
1.7 Summary
96
2 abapGit
97
2.1 Theory
98
2.2 Installation
99
2.2.1 Installing the abapGit Repository in Your SAP System
99
2.2.2 Keeping Your abapGit Version Up to Date
105
2.2.3 Watching the abapGit Repository
107
2.3 Storing and Moving Objects
108
2.3.1 abapGit versus SAPlink
108
2.3.2 Using Online Repositories
109
2.3.3 Using Offline Repositories
115
2.4 Branching
120
2.4.1 Project Collaboration
121
2.4.2 Production Support
127
2.4.3 Utopian Dream
135
2.5 Summary
136
3 New Language Features in ABAP
137
3.1 Declaring and Creating Variables
138
3.1.1 Omitting Data Type Declarations
139
3.1.2 Creating Objects Using NEW
140
3.1.3 Filling Structures and Internal Tables While Creating Them Using VALUE
140
3.1.4 Filling Internal Tables from Other Tables Using FOR
142
3.1.5 Creating Short-Lived Variables Using LET
143
3.1.6 Enumerations
144
3.1.7 New Mathematical Operators
147
3.2 String Processing
148
3.3 Calling Functions
149
3.3.1 Avoiding Type Mismatch Dumps when Calling Functions
149
3.3.2 Using Constructor Operators to Convert Strings
151
3.3.3 Functions that Expect TYPE REF TO DATA
152
3.4 Conditional Logic
153
3.4.1 Omitting ABAP_TRUE
153
3.4.2 Using XSDBOOL as a Workaround for BOOLC
155
3.4.3 The SWITCH Statement as a Replacement for CASE
157
3.4.4 The COND Statement as a Replacement for IF/ELSE
158
3.5 Internal Tables
160
3.5.1 Table Work Areas
160
3.5.2 Reading from a Table
162
3.5.3 CORRESPONDING for Normal Internal Tables
164
3.5.4 MOVE-CORRESPONDING for Internal Tables with Deep Structures
165
3.5.5 Dynamic MOVE-CORRESPONDING
169
3.5.6 New Functions for Common Internal Table Tasks
171
3.5.7 Internal Table Queries with REDUCE
174
3.5.8 Grouping Internal Tables
175
3.5.9 Extracting One Table from Another
178
3.5.10 Virtual Sorting of Internal Tables
180
3.6 Object-Oriented Programming
182
3.6.1 Upcasting/Downcasting with CAST
182
3.6.2 Finding the Subclass of an Object Instance
183
3.6.3 CHANGING and EXPORTING Parameters
185
3.6.4 Changes to Interfaces
186
3.7 Search Helps
187
3.7.1 Predictive Search Helps
188
3.7.2 Search Help in SE80
189
3.8 Summary
189
4 Exception Classes and Design by Contract
191
4.1 Types of Exception Classes
193
4.1.1 Static Check (Local or Nearby Handling)
194
4.1.2 Dynamic Check (Local or Nearby Handling)
195
4.1.3 No Check (Remote Handling)
196
4.1.4 Deciding Which Type of Exception Class to Use
198
4.2 Designing Exception Classes
199
4.2.1 Creating the Exception
199
4.2.2 Declaring the Exception
201
4.2.3 Raising the Exception
202
4.2.4 Cleaning Up after the Exception Is Raised
207
4.2.5 Error Handling with RETRY and RESUME
210
4.3 Design by Contract
214
4.3.1 Preconditions and Postconditions
216
4.3.2 Class Invariants
218
4.3.3 Handling DBC Violations
221
4.4 Summary
222
5 ABAP Unit and Test-Driven Development
223
5.1 Eliminating Dependencies
225
5.1.1 Identifying Dependencies
226
5.1.2 Breaking Up Dependencies Using Test Seams
228
5.1.3 Breaking Up Dependencies Properly
231
5.2 Implementing Test Doubles
233
5.2.1 Test Injection for Test Seams
234
5.2.2 Creating Test Doubles
235
5.2.3 Injection: Good Method
237
5.2.4 Injection: Better Method
239
5.3 Writing and Implementing Unit Tests
243
5.3.1 Test-Driven Development
244
5.3.2 Defining Test Classes
245
5.3.3 Implementing Test Classes
252
5.4 Optimizing the Test Process
261
5.4.1 Eclipse Support for the Unit Test Process
262
5.4.2 ABAP Support for the Unit Test Process
264
5.4.3 Test Double Framework
267
5.4.4 Unit Tests with Massive Amounts of Data
272
5.4.5 Combinatorial Test Design
277
5.5 Summary
278
6 Debugger Scripting
281
6.1 Writing a Debugger Script Program
282
6.2 Coding the SCRIPT Method
287
6.3 Coding the INIT and END Methods
293
6.4 Real-World Examples
300
6.5 Summary
302
7 Database Programming with SAP HANA
305
7.1 The Three Faces of Code Pushdown
306
7.2 ABAP SQL
307
7.2.1 New Commands in ABAP SQL
308
7.2.2 Creating while Reading
314
7.2.3 Buffering Improvements
316
7.2.4 INNER JOIN Improvements
318
7.2.5 UNION
320
7.2.6 CROSS JOINS
320
7.2.7 Code Completion in SELECT Statements
322
7.2.8 Filling a Database Table with Summarized Data
322
7.2.9 Common Table Expressions
323
7.2.10 Stricter Syntax Check
324
7.2.11 Unit Testing ABAP SQL Statements
324
7.3 CDS Views
327
7.3.1 Creating a CDS View in Eclipse
329
7.3.2 Coding a CDS View in Eclipse
332
7.3.3 Classifying a CDS View
345
7.3.4 Adding Authority Checks to a CDS View
347
7.3.5 Reading a CDS View from an ABAP Program
348
7.3.6 Unit Testing CDS Views
351
7.4 ABAP Managed Database Procedures
354
7.4.1 Defining an AMDP in Eclipse
354
7.4.2 Implementing an ADMP in Eclipse
355
7.4.3 Calling an AMDP from an ABAP Program
360
7.4.4 Calling an AMDP from Inside a CDS View
360
7.5 Locating and Pushing Down Code
364
7.5.1 Finding Custom Code that Needs to Be Pushed Down
364
7.5.2 Which Technique to Use to Push Code Down
366
7.5.3 Example
369
7.6 Summary
375
8 Business Object Processing Framework
377
8.1 Manually Defining a Business Object
379
8.1.1 Creating the Object
380
8.1.2 Creating a Header Node
382
8.1.3 Creating an Item Node
384
8.2 Generating a Business Object from a CDS View
386
8.3 Using BOPF to Write a Dynpro-Style Program
389
8.3.1 Creating Model Classes
390
8.3.2 Creating or Changing Objects
394
8.3.3 Locking Objects
407
8.3.4 Performing Authority Checks
409
8.3.5 Setting Display Text Using Determinations
410
8.3.6 Disabling Specific Commands Using Validations
424
8.3.7 Checking Data Integrity Using Validations
426
8.3.8 Responding to User Input via Actions
433
8.3.9 Saving to the Database
445
8.3.10 Tracking Changes in BOPF Objects
452
8.4 Unit Testing BOPF Objects with BUnit
461
8.5 Custom Enhancements
464
8.5.1 Enhancing Standard SAP Objects
465
8.5.2 Using a Custom Interface (Wrapper)
466
8.6 Summary
468
9 BRFplus
469
9.1 The Historic Location of Rules
472
9.1.1 Rules in People’s Heads
472
9.1.2 Rules in Customizing Tables
474
9.1.3 Rules in ABAP
476
9.2 Creating Rules in BRFplus: Basic Example
477
9.2.1 Creating a BRFplus Application
477
9.2.2 Adding Rule Logic
486
9.2.3 BRFplus Rules in ABAP
498
9.3 Creating Rules in BRFplus: Complex Example
502
9.4 Simulations
509
9.5 Unit Testing
511
9.6 SAP Business Workflow Integration
512
9.7 Options for Enhancements
516
9.7.1 Procedure Expressions
517
9.7.2 Application Exits
517
9.7.3 Custom Frontends
518
9.7.4 Custom Extensions
518
9.7.5 Traces and Versions
519
9.8 Rules Frameworks
519
9.9 Summary
520
10 ALV SALV Reporting Framework
523
10.1 Getting Started
526
10.1.1 Defining an SALV-Specific (Concrete) Class
527
10.1.2 Coding a Program to Call a Report
528
10.2 Designing a Report Interface
531
10.2.1 Report Flow Step 1: Creating a Container (Generic/Optional)
534
10.2.2 Report Flow Step 2: Initializing a Report (Generic)
534
10.2.3 Report Flow Step 3: Making Application-Specific Changes (Specific)
542
10.2.4 Report Flow Step 4: Displaying the Report (Generic)
556
10.3 Adding Custom Command Icons with Programming
561
10.3.1 Creating a Method to Automatically Create a Container
563
10.3.2 Changing ZCL_BC_VIEW_SALV_TABLE to Fill the Container
564
10.3.3 Changing the INITIALIZE Method
565
10.3.4 Adding the Custom Commands to the Toolbar
566
10.3.5 Sending User Commands from the Calling Program
567
10.3.6 Adding Separators
568
10.4 Editing Data
569
10.4.1 Creating a Custom Class to Hold the Standard SALV Model Class
571
10.4.2 Changing the Initialization Method of ZCL_BC_VIEW_SALV_TABLE
571
10.4.3 Adding a Method to Retrieve the Underlying Grid Object
576
10.4.4 Changing the Calling Program
579
10.4.5 Coding User Command Handling
579
10.5 Handling Large Internal Tables with CL_SALV_GUI_TABLE_IDA
583
10.6 Open-Source Fast ALV Grid Object
586
10.7 Making SAP GUI Look Like SAP Fiori
587
10.8 Summary
588
11 Web Dynpro ABAP and Floorplan Manager
589
11.1 The Model-View-Controller Concept
590
11.1.1 Model
591
11.1.2 View
593
11.1.3 Controller
596
11.2 Building the WDA Application
597
11.2.1 Creating a Web Dynpro Component
599
11.2.2 Declaring Data Structures for the Controller
600
11.2.3 Establishing View Settings
604
11.2.4 Defining the Windows
612
11.2.5 Navigating between Views inside the Window
614
11.2.6 Enabling the Application to be Called
616
11.3 Coding the WDA Application
617
11.3.1 Linking the Controller to the Model
618
11.3.2 Selecting Monster Records
618
11.3.3 Navigating to the Single-Record View
624
11.4 Using Floorplan Manager to Create WDA Applications
628
11.4.1 Creating an Application Using Floorplan Manager
630
11.4.2 Integrating BOPF with Floorplan Manager
643
11.5 Unit Testing WDA Applications
651
11.6 Making WDA Look Like SAP Fiori
654
11.7 Summary
655
12 SAPUI5
657
12.1 Architecture
659
12.1.1 Frontend: What SAPUI5 Is
660
12.1.2 Backend: What SAP Gateway Is
661
12.2 Prerequisites
661
12.2.1 Requirements in SAP
662
12.2.2 Requirements on Your Local Machine
662
12.3 Backend Tasks: Creating the Model Manually Using SAP Gateway
663
12.3.1 Configuration
663
12.3.2 Coding
678
12.4 Backend Tasks: Automatically Generating the Model
691
12.4.1 Creating an SAP Gateway Service by Pulling from a CDS View
691
12.4.2 Creating an SAP Gateway Service by Pushing from a CDS View
694
12.5 Frontend Tasks: Creating the View and Controller Using SAPUI5
699
12.5.1 First Steps
699
12.5.2 View
704
12.5.3 Controller
718
12.5.4 Testing Your Application
724
12.6 Generating SAPUI5 Applications from SAP Web IDE Templates
726
12.7 Generating SAPUI5 Applications from SAP Build
733
12.8 Adding Elements with OpenUI5
743
12.9 Importing SAPUI5 Applications to SAP ERP
748
12.9.1 Storing the Application inside SAP
748
12.9.2 Testing the SAPUI5 Application from within SAP ERP
750
12.10 Unit Testing SAPUI5 Applications
753
12.10.1 ESLint
753
12.10.2 QUnit
754
12.10.3 OPA
755
12.10.4 Gherkin
756
12.11 SAPUI5 vs. SAP Fiori
757
12.12 Summary
759
13 ABAP Channels
761
13.1 General Concepts
762
13.1.1 ABAP Messaging Channels
763
13.1.2 ABAP Push Channels
764
13.1.3 ABAP Daemons
765
13.2 ABAP Messaging Channels: SAP GUI Example
767
13.2.1 Coding the Sending Application
770
13.2.2 Coding the Receiving Application
775
13.2.3 Watching the Applications Communicate
779
13.3 ABAP Push Channels: SAPUI5 Example
782
13.3.1 Coding the Receiving (Backend) Components
783
13.3.2 Coding the Sending (Frontend) Application
792
13.4 Internet of Things Relevance
793
13.5 Summary
794
14 The RESTful ABAP Programming Model
797
14.1 ABAP in the Cloud
798
14.2 Programming Model Changes
802
14.2.1 Changes to Database Layer
802
14.2.2 Changes to Business Logic Layer
803
14.2.3 Changes to User Interface Layer
805
14.3 Application Structure
806
14.4 Coding a Transactional Business Object Application
807
14.4.1 Coding Business Object CDS Views
807
14.4.2 Coding Behavior Definition
811
14.4.3 Coding Behavior Implementation
813
14.4.4 Saving the Changed Business Objects
837
14.5 Service Definitions and Bindings
839
14.5.1 Creating a Service Definition
839
14.5.2 Creating a Service Binding
840
14.5.3 Creating an SAPUI5 App to Consume the Application
842
14.6 Calling CRUD Operations from ABAP
846
14.7 Summary
847
Conclusion
849
The Author
851
Index
853