Inhaltsverzeichnis

Alle Kapitel aufklappen
Alle Kapitel zuklappen
Acknowledgments
19
Introduction
21
Structure of the Book
24
Chapter 1: Integrated Development Environment
25
Chapter 2: abapGit
25
Chapter 3: New Language Features in ABAP
25
Chapter 4: Exception Classes and Design by Contract
26
Chapter 5: ABAP Unit and Test-Driven Development
26
Chapter 6: Database Programming with SAP HANA
26
Chapter 7: Business Object Processing Framework
26
Chapter 8: Business Logic Using the ABAP RESTful Application Programming Model
27
Chapter 9: Service Layer
27
Chapter 10: ALV SALV Reporting Framework
27
Chapter 11: ABAP2XLSX and Beyond
27
Chapter 12: Web Dynpro ABAP and Floorplan Manager
27
Chapter 13: SAPUI5
28
Chapter 14: ABAP Channels
28
The Example Application
28
Baron Frankenstein's Business Model
29
SAP Developments Required to Support the Business Model
29
1 Integrated Development Environment
31
1.1 Installation
33
1.1.1 Installing Eclipse
33
1.1.2 Installing SAP-Specific Add-Ons
36
1.1.3 Connecting Eclipse to a Backend SAP System
37
1.1.4 Upgrading Eclipse
39
1.2 ABAP-Specific Features
39
1.2.1 Initial Tour and Basic Tasks
40
1.2.2 Working on Multiple Objects at the Same Time
44
1.2.3 Creating a Method from the Calling Code
45
1.2.4 Extracting a Method
49
1.2.5 Refactoring: Moving Methods and Attributes
54
1.2.6 Deleting Unused Variables
54
1.2.7 Creating Instance Attributes and Method Parameters
56
1.2.8 Quick Fixes for Classes
56
1.2.9 Extracting Conditional Logic
57
1.2.10 Seeing Message Details
59
1.2.11 Renaming Repository Objects
59
1.2.12 Magic Numbers
61
1.2.13 ABAP 7.5+ Features
61
1.3 Eclipse-Specific Features
65
1.3.1 Neon (2016)
66
1.3.2 Oxygen (2017)
67
1.3.3 Photon (2018)
68
1.3.4 Eclipse 2020-03
68
1.4 Testing and Troubleshooting
70
1.4.1 Unit Testing
70
1.4.2 Debugging
71
1.4.3 Dynamic Log Points
74
1.4.4 Runtime Analysis
76
1.5 Customization Options with User-Defined Plug-Ins
77
1.5.1 Favorites List
78
1.5.2 Continuous Integration
80
1.5.3 Code Insight
83
1.5.4 Custom Quick Fixes
83
1.5.5 Custom Quick Fixes for ABAP Test Cockpit
85
1.6 The Future of IDEs for ABAP Development
85
1.6.1 SAP Web IDE
85
1.6.2 SAP Business Application Studio
86
1.6.3 Visual Studio Code
89
1.7 Summary
96
2 abapGit
99
2.1 Theory
100
2.2 Installation
101
2.2.1 Installing the abapGit Repository in Your SAP System
101
2.2.2 Keeping Your abapGit Version Up to Date
107
2.2.3 Watching the abapGit Repository
109
2.3 Storing and Moving Objects
110
2.3.1 abapGit versus SAPlink
111
2.3.2 Using Online Repositories
111
2.3.3 Using Offline Repositories
117
2.4 Dependency Management
122
2.4.1 APACK: Theory
122
2.4.2 APACK: Installation
123
2.4.3 APACK: Example
124
2.5 Branching
125
2.5.1 Project Collaboration: Sharing Solutions
126
2.5.2 Production Support
133
2.5.3 Utopian Dream
141
2.6 abapGit for Customizing
141
2.7 Summary
142
3 New Language Features in ABAP
145
3.1 Declaring and Creating Variables
147
3.1.1 Omitting Data Type Declarations
147
3.1.2 Creating Objects Using NEW
148
3.1.3 Filling Structures and Internal Tables while Creating Them Using VALUE
148
3.1.4 Filling Internal Tables from Other Tables Using FOR
150
3.1.5 Creating Short-Lived Variables Using LET
151
3.1.6 Enumerations
152
3.1.7 New Mathematical Operators
155
3.2 String Processing
155
3.3 Calling Functions
156
3.3.1 Avoiding Type Mismatch Dumps when Calling Functions
156
3.3.2 Using Constructor Operators to Convert Strings
158
3.3.3 Functions Expecting TYPE REF TO DATA
159
3.4 Conditional Logic
160
3.4.1 Omitting ABAP_TRUE
161
3.4.2 Using XSDBOOL as a Workaround for BOOLC
162
3.4.3 The SWITCH Statement as a Replacement for CASE
164
3.4.4 The COND Statement as a Replacement for IF/ELSE
165
3.5 Internal Tables
167
3.5.1 Table Work Areas
167
3.5.2 Reading from a Table
169
3.5.3 CORRESPONDING for Normal Internal Tables
170
3.5.4 MOVE-CORRESPONDING for Internal Tables with Deep Structures
172
3.5.5 Dynamic MOVE-CORRESPONDING
175
3.5.6 New Functions for Common Internal Table Tasks
177
3.5.7 Internal Table Queries with REDUCE
179
3.5.8 Grouping Internal Tables
181
3.5.9 Extracting One Table from Another
185
3.5.10 Virtual Sorting of Internal Tables
187
3.6 Object-Oriented Programming
188
3.6.1 Upcasting/Downcasting with CAST
189
3.6.2 Finding the Subclass of an Object Instance
189
3.6.3 CHANGING and EXPORTING Parameters
191
3.6.4 Changes to Interfaces
192
3.7 Search Helps
193
3.7.1 Predictive Search Helps
193
3.7.2 Search Help in SE80
194
3.8 Assorted
195
3.8.1 Unicode
195
3.8.2 ABAP Language Versions
195
3.8.3 Deprecation Concept
196
3.8.4 Clean ABAP
197
3.9 Summary
198
4 Exception Classes and Design by Contract
199
4.1 Types of Exception Classes
201
4.1.1 Static Check: Local or Nearby Handling
201
4.1.2 Dynamic Check: Local or Nearby Handling
203
4.1.3 No Check: Remote Handling
204
4.1.4 Deciding Which Type of Exception Class to Use
206
4.2 Designing Exception Classes
207
4.2.1 Creating the Exception
207
4.2.2 Declaring the Exception
212
4.2.3 Raising the Exception
213
4.2.4 Cleaning Up after the Exception Is Raised
218
4.2.5 Error Handling with RETRY and RESUME
220
4.3 Design by Contract
224
4.3.1 Preconditions and Postconditions
226
4.3.2 Class Invariants
228
4.3.3 Handling Violations
230
4.4 Summary
232
5 ABAP Unit and Test-Driven Development
233
5.1 Eliminating Dependencies
235
5.1.1 Identifying Dependencies
236
5.1.2 Breaking Up Dependencies Using Test Seams
238
5.1.3 Breaking Up Dependencies Properly
240
5.2 Implementing Test Doubles
242
5.2.1 Test Injection for Test Seams
243
5.2.2 Creating Test Doubles
243
5.2.3 Injection: Good Method
246
5.2.4 Injection: Better Method
248
5.3 Writing and Implementing Unit Tests
251
5.3.1 Test-Driven Development
252
5.3.2 Defining Test Classes
254
5.3.3 Implementing Test Classes
260
5.4 Optimizing the Test Process
269
5.4.1 Eclipse Support for the Unit Test Process
269
5.4.2 ABAP Support for the Unit Test Process
271
5.4.3 Test Double Framework
274
5.4.4 ABAP Unit Authority Check
279
5.4.5 Unit Tests with Massive Amounts of Data
284
5.4.6 Combinatorial Test Design
287
5.5 Summary
289
6 Database Programming with SAP HANA
291
6.1 The Three Faces of Code Pushdown
292
6.2 ABAP SQL
293
6.2.1 New Commands in ABAP SQL
294
6.2.2 Creating while Reading
307
6.2.3 Buffering Improvements
308
6.2.4 INNER JOIN Improvements
310
6.2.5 UNION
311
6.2.6 Code Completion in SELECT Statements
312
6.2.7 Filling a Database Table with Summarized Data
313
6.2.8 Common Table Expressions
314
6.2.9 IS INITIAL in SELECT Statements
315
6.2.10 Stricter Syntax Check
316
6.2.11 The Death of FOR ALL ENTRIES
316
6.2.12 Unit Testing ABAP SQL Statements
320
6.3 CDS Views and CDS Entities
323
6.3.1 Creating a CDS Entity in Eclipse
325
6.3.2 Choosing an Entity Type
328
6.3.3 Coding Annotations in the CDS Entity
334
6.3.4 Adding Authority Checks to a CDS Entity
337
6.3.5 Reading a CDS Entity from an ABAP Program
339
6.3.6 Creating Special Types of CDS Entities
340
6.3.7 Using Special CDS Entity Features
342
6.3.8 Unit Testing CDS Entities
347
6.4 ABAP Managed Database Procedures
350
6.4.1 Defining an AMDP in Eclipse
350
6.4.2 Implementing AMDP in Eclipse
351
6.4.3 Calling AMDP from an ABAP Program
355
6.4.4 Calling AMDP from inside a CDS Entity
356
6.5 Locating and Pushing Down Code
359
6.5.1 Finding Custom Code that Needs to Be Pushed Down
359
6.5.2 Which Technique to Use to Push Code Down
360
6.5.3 Example
363
6.6 Summary
369
7 Business Object Processing Framework
371
7.1 Manually Defining a Business Object
373
7.1.1 Creating the Object
374
7.1.2 Creating the Header (Root) Node
375
7.1.3 Creating an Item Node
378
7.2 Automatically Defining a Business Object Based on a CDS View
379
7.3 Using BOPF to Write a Dynpro-Style Program
383
7.3.1 Creating a Model Class
384
7.3.2 Queries: Checking Object Existence
387
7.3.3 Locking Objects
399
7.3.4 Performing Authority Checks
400
7.3.5 Determinations: Deriving Values from Other Values
402
7.3.6 Validations: Checking Data Integrity
414
7.3.7 Actions: Responding to User Input
421
7.3.8 Saving to the Database
432
7.3.9 Tracking Changes in BOPF Objects
438
7.4 Unit Testing BOPF Objects with BUnit
446
7.5 Using a Custom Interface (Wrapper)
449
7.6 Summary
450
8 Business Logic Using the ABAP RESTful Application Programming Model
453
8.1 ABAP RESTful Application Programming Model versus BOPF
453
8.1.1 Business Definition Language
454
8.1.2 Business Objects as First-Class Citizens
455
8.2 Coding Business Object CDS Entities
455
8.2.1 Coding Data Definitions
456
8.2.2 Coding CDS Projections
460
8.2.3 Coding Metadata Extensions
463
8.3 Coding Behavior Definitions and Projections
469
8.4 Coding Behavior Implementations
474
8.4.1 Creating a Behavior Class
474
8.4.2 Creating or Changing Objects
480
8.4.3 Locking Objects
497
8.4.4 Performing Authority Checks
501
8.4.5 Determinations: Deriving Values from Other Values
504
8.4.6 Validations: Checking Data Integrity
507
8.4.7 Actions: Responding to User Input
510
8.4.8 Feature Control
513
8.4.9 Saving the Changed Business Objects
516
8.4.10 Tracking Changes in ABAP RESTful Application Programming Model Objects
518
8.5 Calling CRUD Operations from ABAP
519
8.6 Summary
520
9 Service Layer
521
9.1 What Is SAP Gateway?
521
9.2 Transaction SEGW Service Layer: Manual Creation
522
9.2.1 Configuration
522
9.2.2 Coding
536
9.3 Transaction SEGW Service Layer: Automatic Creation
549
9.3.1 Creating an SAP Gateway Service by Pulling from a CDS View
550
9.3.2 Creating an SAP Gateway Service by Pushing from a CDS View
552
9.4 ABAP RESTful Application Programming Model Service Layer: Manual Creation
554
9.4.1 Creating a Service Definition
555
9.4.2 Creating a Service Binding
556
9.4.3 Creating Automated Unit Tests for the OData Service
559
9.5 ABAP RESTful Application Programming Model Service Layer: Automatic Creation
561
9.5.1 Making Sure the RAP Generator Is Available in Your System
561
9.5.2 Creating a JSON Configuration File
562
9.5.3 Pressing a Big, Red Button
564
9.6 Summary
565
10 ALV SALV Reporting Framework
567
10.1 Getting Started
569
10.1.1 Defining an SALV-Specific (Concrete) Class
570
10.1.2 Coding a Program to Call a Report
571
10.2 Designing a Report Interface
574
10.2.1 Report Flow Step 1: Creating a Container (Generic/Optional)
576
10.2.2 Report Flow Step 2: Initializing a Report (Generic)
577
10.2.3 Report Flow Step 3: Making Application-Specific Changes (Specific)
584
10.2.4 Report Flow Step 4: Displaying the Report (Generic)
596
10.3 Adding Custom Command Icons with Programming
601
10.3.1 Creating a Method to Automatically Create a Container
603
10.3.2 Changing ZCL_BC_VIEW_SALV_TABLE to Fill the Container
604
10.3.3 Changing the INITIALIZE Method
605
10.3.4 Adding the Custom Commands to the Toolbar
606
10.3.5 Sending User Commands from the Calling Program
607
10.3.6 Adding Separators
607
10.4 Editing Data
609
10.4.1 Creating a Custom Class to Hold the Standard SALV Model Class
610
10.4.2 Changing the Initialization Method of ZCL_BC_VIEW_SALV_TABLE
610
10.4.3 Adding a Method to Retrieve the Underlying Grid Object
614
10.4.4 Changing the Calling Program
617
10.4.5 Coding User Command Handling
617
10.5 Handling Large Amounts of Data with CL_SALV_GUI_TABLE_IDA
621
10.5.1 Basic Example
621
10.5.2 Complex Example
624
10.6 Open-Source Fast ALV Grid Object
628
10.7 Making SAP GUI Look Like SAP Fiori
629
10.8 Summary
630
11 ABAP2XLSX and Beyond
631
11.1 The Basics
633
11.1.1 How XLSX Files Are Stored
633
11.1.2 Downloading ABAP2XLSX
635
11.1.3 Creating XLSX Files Using ABAP
635
11.2 Enhancing Custom Reports with ABAP2XLSX
639
11.2.1 Converting an ALV to an Excel Object
639
11.2.2 Changing Number and Text Formats
641
11.2.3 Establishing Printer Settings
644
11.2.4 Using Conditional Formatting
646
11.2.5 Creating Spreadsheets with Multiple Worksheets
655
11.2.6 Using Graphs and Pie Charts
656
11.2.7 Embedding Macros
660
11.2.8 Emailing the Result
665
11.2.9 Adding Hyperlinks to SAP Transactions
668
11.3 Tips and Tricks
673
11.3.1 Using the Enhancement Framework for Your Own Fixes
673
11.3.2 Creating a Reusable Custom Framework
676
11.4 Beyond Spreadsheets: Microsoft Word Documents
676
11.4.1 Installing the Tool
677
11.4.2 Creating a Template
678
11.4.3 Filling Out the Template Programmatically
681
11.5 Summary
688
12 Web Dynpro ABAP and Floorplan Manager
689
12.1 The Model-View-Controller Concept
690
12.1.1 Model
691
12.1.2 View
693
12.1.3 Controller
695
12.2 Building the WDA Application
696
12.2.1 Creating a Web Dynpro Component
697
12.2.2 Declaring Data Structures for the Controller
699
12.2.3 Establishing View Settings
701
12.2.4 Defining the Windows
710
12.2.5 Navigating between Views inside the Window
711
12.2.6 Enabling the Application to be Called
714
12.3 Coding the WDA Application
715
12.3.1 Linking the Controller to the Model
715
12.3.2 Selecting Monster Records
715
12.3.3 Navigating to the Single-Record View
721
12.4 Using Floorplan Manager to Create WDA Applications
724
12.4.1 Creating an WDA Application using FPM Manually
726
12.4.2 Creating a WDA Application Using FPM via BOPF Integration
738
12.5 Unit Testing WDA Applications
744
12.6 Making WDA Look Like SAP Fiori
747
12.6.1 Enabling SAP Fiori in WDA via Classic Configuration
747
12.6.2 Enabling SAP Fiori in WDA via New Customizing UI
748
12.7 Touch Enablement of WDA Applications
752
12.8 Summary
753
13 SAPUI5
755
13.1 Basics
757
13.1.1 What Is SAPUI5?
757
13.1.2 SAPUI5 versus SAP Fiori
758
13.2 Modern IDEs
759
13.2.1 VS Code
759
13.2.2 SAP Business Application Studio
761
13.3 Creating an SAPUI5 Application Manually
763
13.3.1 VS Code
764
13.3.2 SAP Business Application Studio
787
13.4 Creating an SAPUI5 Application Automatically
792
13.4.1 VS Code
793
13.4.2 SAP Business Application Studio
798
13.5 Extension Tools
804
13.5.1 Guided Development
805
13.5.2 Adding Elements with OpenUI5
809
13.6 Importing SAPUI5 Applications into SAP ERP
813
13.6.1 Storing the Application inside SAP
814
13.6.2 Testing the SAPUI5 Application from within SAP ERP
816
13.7 Unit Testing SAPUI5 Applications
818
13.7.1 ESLint
818
13.7.2 QUnit
819
13.7.3 OPA
820
13.7.4 Gherkin
821
13.7.5 UIVeri5 and the Test Recorder
822
13.8 Summary
824
14 ABAP Channels
827
14.1 General Concepts
828
14.1.1 ABAP Messaging Channels
829
14.1.2 ABAP Push Channels
830
14.1.3 ABAP Daemons
831
14.2 ABAP Messaging Channels: SAP GUI Example
833
14.2.1 Coding the Sending Application
835
14.2.2 Coding the Receiving Application
840
14.2.3 Watching the Applications Communicate
844
14.3 ABAP Push Channels: SAPUI5 Example
847
14.3.1 Coding the Receiving (Backend) Components
848
14.3.2 Coding the Sending (Frontend) Application
856
14.4 Internet of Things Relevance
857
14.5 Summary
859
Conclusion
861
The Author
863
Index
865