Inhaltsverzeichnis

Alle Kapitel aufklappen
Alle Kapitel zuklappen
Foreword
19
Acknowledgments
21
Introduction
23
Structure of the Book
26
Chapter 1: ABAP in Eclipse
26
Chapter 2: New Language Features in ABAP 7.4 and 7.5
27
Chapter 3: ABAP Unit and Test-Driven Development
27
Chapter 4: Custom Code and ABAP Test Cockpit
27
Chapter 5: ABAP Programming Model for SAP HANA
28
Chapter 6: Exception Classes and Design by Contract
28
Chapter 7: Business Object Processing Framework
28
Chapter 8: BRFplus
28
Chapter 9: ALV SALV Reporting Framework
29
Chapter 10: ABAP2XLSX and Beyond
29
Chapter 11: Web Dynpro ABAP and Floorplan Manager
29
Chapter 12: SAPUI5
30
Chapter 13: ABAP Channels
30
The Example Application
30
1 ABAP in Eclipse
33
1.1 Installation
35
1.1.1 Installing Eclipse
36
1.1.2 Installing SAP-Specific Add-Ons
38
1.1.3 Connecting Eclipse to a Backend SAP System
40
1.2 Features
41
1.2.1 Working on Multiple Objects at the Same Time
45
1.2.2 Bookmarking
47
1.2.3 Creating a Method from the Calling Code
49
1.2.4 Extracting a Method
54
1.2.5 Deleting Unused Variables
58
1.2.6 Creating Instance Attributes and Method Parameters
59
1.2.7 Creating Class Constructors
60
1.2.8 Creating Structures
61
1.2.9 Creating Data Elements
63
1.2.10 Handling an Exception
63
1.2.11 Changing Package Assignment
65
1.2.12 Getting New IDE Features Automatically
65
1.3 Testing and Troubleshooting
69
1.3.1 Unit Testing Code Coverage
69
1.3.2 Debugging
72
1.3.3 Runtime Analysis
75
1.3.4 Dynamic Log Points
77
1.4 Customization Options with User-Defined Plug-Ins
79
1.4.1 UMAP
81
1.4.2 Obeo
87
1.5 Summary
87
2 New Language Features in ABAP 7.4 and 7.5
89
2.1 Database Access
90
2.1.1 New Commands in OpenSQL
90
2.1.2 Creating While Reading
95
2.1.3 Buffering Improvements
96
2.1.4 Inner Join Improvements
98
2.1.5 UNION
100
2.1.6 Code Completion in SELECT Statements
101
2.1.7 Filling a Database Table with Summarized Data
101
2.2 Declaring and Creating Variables
102
2.2.1 Omitting the Declaration of TYPE POOL Statements
103
2.2.2 Omitting Data Type Declarations
104
2.2.3 Creating Objects Using NEW
105
2.2.4 Filling Structures and Internal Tables While Creating Them Using VALUE
106
2.2.5 Filling Internal Tables from Other Tables Using FOR
107
2.2.6 Creating Short-Lived Variables Using LET
108
2.3 String Processing
109
2.3.1 New String Features in Release 7.02
109
2.3.2 New String Features in Release 7.4
110
2.4 Calling Functions
111
2.4.1 Method Chaining
111
2.4.2 Avoiding Type Mismatch Dumps When Calling Functions
112
2.4.3 Using Constructor Operators to Convert Strings
114
2.4.4 Functions That Expect TYPE REF TO DATA
115
2.5 Conditional Logic
116
2.5.1 Using Functional Methods in Logical Expressions
116
2.5.2 Omitting ABAP_TRUE
117
2.5.3 Using XSDBOOL as a Workaround for BOOLC
119
2.5.4 The SWITCH Statement as a Replacement for CASE
120
2.5.5 The COND Statement as a Replacement for IF/ELSE
122
2.6 Internal Tables
124
2.6.1 Using Secondary Keys to Access the Same Internal Table in Different Ways
124
2.6.2 Table Work Areas
127
2.6.3 Reading from a Table
128
2.6.4 CORRESPONDING for Normal Internal Tables
130
2.6.5 MOVE-CORRESPONDING for Internal Tables with Deep Structures
131
2.6.6 Dynamic MOVE-CORRESPONDING
135
2.6.7 New Functions for Common Internal Table Tasks
137
2.6.8 Internal Table Queries with REDUCE
139
2.6.9 Grouping Internal Tables
140
2.6.10 Extracting One Table from Another
143
2.7 Object-Oriented Programming
145
2.7.1 Upcasting/Downcasting with CAST
146
2.7.2 Finding the Subclass of an Object Instance
147
2.7.3 CHANGING and EXPORTING Parameters
148
2.7.4 Changes to Interfaces
149
2.8 Search Helps
151
2.8.1 Predictive Search Helps
151
2.8.2 Search Help in SE80
152
2.9 Unit Testing
153
2.9.1 Creating Test Doubles Relating to Interfaces
153
2.9.2 Coding Return Values from Test Doubles
154
2.9.3 Creating Test Doubles Related to Complex Objects
155
2.10 Summary
156
3 ABAP Unit and Test-Driven Development
159
3.1 Eliminating Dependencies
161
3.1.1 Identifying Dependencies
162
3.1.2 Breaking Up Dependencies Using Test Seams
164
3.1.3 Breaking Up Dependencies Properly
166
3.2 Implementing Mock Objects
168
3.2.1 Test Injection for Test Seams
168
3.2.2 Creating Mock Objects
169
3.2.3 Proper Injection
171
3.3 Writing and Implementing Unit Tests
173
3.3.1 Defining Test Classes
173
3.3.2 Implementing Test Classes
180
3.4 Automating the Test Process
189
3.4.1 Automating Dependency Injection
190
3.4.2 Automating Mock Object Creation: Test Double Framework
195
3.4.3 Combining Dependency Injection and the ABAP Test Double Framework
200
3.4.4 Unit Tests with Massive Amounts of Data
202
3.5 Summary
207
4 Custom Code and ABAP Test Cockpit
209
4.1 Automatic Run of Unit Tests
211
4.2 Mass Checks
213
4.2.1 Setting Up Mass Checks
214
4.2.2 Running Mass Checks
216
4.2.3 Reviewing Mass Checks
220
4.2.4 Dismissing False Errors
223
4.3 Recent Code Inspector Enhancements
227
4.3.1 Unsecure FOR ALL ENTRIES (12/5/2)
228
4.3.2 SELECT * Analysis (14/9/2)
230
4.3.3 Improving FOR ALL ENTRIES (14/9/2)
232
4.3.4 SELECT with DELETE (14/9/2)
233
4.3.5 Check on Statements Following a SELECT without ORDER BY (14/9/3)
234
4.3.6 SELECTs in Loops across Different Routines (14/9/3)
236
4.3.7 Syntax Check on Enhanced Programs (17/10/4)
237
4.3.8 SORT Statements inside Loops (18/11/5)
239
4.3.9 Copy Current Table Row for LOOP AT (18/11/5)
241
4.3.10 Nested Sequential Accesses to Internal Tables (7.5)
243
4.3.11 Test Suspect Conversions (7.5)
245
4.3.12 Technology-Specific Checks (7.02 to 7.5)
246
4.4 Custom Code Analyzer: Simplification Database
248
4.4.1 Preparation
248
4.4.2 Usage
249
4.4.3 Aftermath
251
4.5 Summary
252
5 ABAP Programming Model for SAP HANA
253
5.1 The Three Faces of Code Pushdown
254
5.2 OpenSQL
256
5.3 CDS Views
256
5.3.1 Creating a CDS View in Eclipse
258
5.3.2 Coding a CDS View in Eclipse
261
5.3.3 Adding Authority Checks to a CDS View
274
5.3.4 Reading a CDS View from an ABAP Program
276
5.4 ABAP Managed Database Procedures
279
5.4.1 Defining an AMDP in Eclipse
279
5.4.2 Implementing an ADMP in Eclipse
280
5.4.3 Calling an AMDP from an ABAP Program
285
5.4.4 Calling an AMDP from inside a CDS View
285
5.5 Locating and Pushing Down Code
288
5.5.1 Finding Custom Code that Needs to Be Pushed Down
289
5.5.2 Which Technique to Use to Push Code Down
291
5.5.3 Example
292
5.6 SAP HANA-Specific Changes for ABAP
298
5.6.1 Database Table Design
299
5.6.2 Avoiding Database-Specific Features
303
5.6.3 Changes to Database SELECT Coding
304
5.7 Summary
308
6 Exception Classes and Design by Contract
311
6.1 Types of Exception Classes
313
6.1.1 Static Check (Local or Nearby Handling)
314
6.1.2 Dynamic Check (Local or Nearby Handling)
316
6.1.3 No Check (Remote Handling)
316
6.1.4 Deciding Which Type of Exception Class to Use
318
6.2 Designing Exception Classes
319
6.2.1 Creating the Exception
320
6.2.2 Declaring the Exception
322
6.2.3 Raising the Exception
323
6.2.4 Cleaning Up after the Exception Is Raised
326
6.2.5 Error Handling with RETRY and RESUME
328
6.3 Design by Contract
332
6.3.1 Preconditions and Postconditions
334
6.3.2 Class Invariants
336
6.4 Summary
338
7 Business Object Processing Framework
341
7.1 Manually Defining a Business Object
342
7.1.1 Creating the Object
343
7.1.2 Creating a Header Node
345
7.1.3 Creating an Item Node
347
7.2 Generating a Business Object from a CDS View
349
7.3 Using BOPF to Write a DYNPRO-Style Program
352
7.3.1 Creating Model Classes
353
7.3.2 Creating or Changing Objects
357
7.3.3 Locking Objects
369
7.3.4 Performing Authority Checks
370
7.3.5 Setting Display Text Using Determinations
371
7.3.6 Disabling Certain Commands Using Validations
384
7.3.7 Checking Data Integrity Using Validations
386
7.3.8 Responding to User Input via Actions
392
7.3.9 Saving to the Database
404
7.3.10 Tracking Changes in BOPF Objects
411
7.4 Custom Enhancements
420
7.4.1 Enhancing Standard SAP Objects
420
7.4.2 Using a Custom Interface (Wrapper)
423
7.5 Summary
425
8 BRFplus
427
8.1 The Historic Location of Rules
430
8.1.1 Rules in People’s Heads
430
8.1.2 Rules in Customizing Tables
432
8.1.3 Rules in ABAP
434
8.2 Creating Rules in BRFplus: Basic Example
435
8.2.1 Creating a BRFplus Application
435
8.2.2 Adding Rule Logic
444
8.2.3 BRFplus Rules in ABAP
456
8.3 Creating Rules in BRFplus: Complicated Example
458
8.4 Simulations
465
8.5 SAP Business Workflow Integration
467
8.6 Options for Enhancements
472
8.6.1 Procedure Expressions
472
8.6.2 Application Exits
473
8.6.3 Custom Frontends
473
8.6.4 Custom Extensions
474
8.7 SAP HANA Rules Framework
474
8.8 Summary
475
9 ALV SALV Reporting Framework
477
9.1 Getting Started
480
9.1.1 Defining a SALV-Specific (Concrete) Class
481
9.1.2 Coding a Program to Call a Report
482
9.2 Designing a Report Interface
484
9.2.1 Report Flow Step 1: Creating a Container (Generic/Optional)
486
9.2.2 Report Flow Step 2: Initializing a Report (Generic)
487
9.2.3 Report Flow Step 3: Making Application-Specific Changes (Specific)
494
9.2.4 Report Flow Step 4: Displaying the Report (Generic)
507
9.3 Adding Custom Command Icons with Programming
512
9.3.1 Creating a Method to Automatically Create a Container
514
9.3.2 Changing ZCL_BC_VIEW_SALV_TABLE to Fill the Container
514
9.3.3 Changing the INITIALIZE Method
516
9.3.4 Adding the Custom Commands to the Toolbar
517
9.3.5 Sending User Commands from the Calling Program
518
9.4 Editing Data
519
9.4.1 Creating a Custom Class to Hold the Standard SALV Model Class
520
9.4.2 Changing the Initialization Method of ZCL_BC_VIEW_SALV_TABLE
521
9.4.3 Adding a Method to Retrieve the Underlying Grid Object
525
9.4.4 Changing the Calling Program
527
9.4.5 Coding User Command Handling
528
9.5 Handling Large Internal Tables with CL_SALV_GUI_TABLE_IDA
531
9.6 Open-Source Fast ALV Grid Object
534
9.7 Summary
535
10 ABAP2XLSX and Beyond
537
10.1 The Basics
539
10.1.1 How XLSX Files Are Stored
539
10.1.2 Downloading ABAP2XLSX
541
10.1.3 Creating XLSX Files Using ABAP
541
10.2 Enhancing Custom Reports with ABAP2XLSX
546
10.2.1 Converting an ALV Object to an Excel Object
546
10.2.2 Changing Number and Text Formats
548
10.2.3 Establishing Printer Settings
551
10.2.4 Using Conditional Formatting
554
10.2.5 Creating Spreadsheets with Multiple Worksheets
563
10.2.6 Using Graphs and Pie Charts
565
10.2.7 Embedding Macros
568
10.2.8 Emailing the Result
574
10.2.9 Adding Hyperlinks to SAP Transactions
577
10.3 Tips and Tricks
582
10.3.1 Using the Enhancement Framework for Your Own Fixes
583
10.3.2 Creating a Reusable Custom Framework
585
10.4 Beyond Spreadsheets: Microsoft Word Documents
586
10.4.1 Installing the Tool
587
10.4.2 Creating a Template
588
10.4.3 Filling the Template
589
10.5 Summary
596
11 Web Dynpro ABAP and Floorplan Manager
599
11.1 The Model-View-Controller Concept
600
11.1.1 Model
601
11.1.2 View
603
11.1.3 Controller
606
11.2 Building the WDA Application
607
11.2.1 Creating a Web Dynpro Component
609
11.2.2 Declaring Data Structures for the Controller
611
11.2.3 Establishing View Settings
613
11.2.4 Defining the Windows
623
11.2.5 Navigating between Views inside the Window
624
11.2.6 Enabling the Application to be Called
627
11.3 Coding the WDA Application
628
11.3.1 Linking the Controller to the Model
629
11.3.2 Selecting Monster Records
629
11.3.3 Navigating to the Single-Record View
635
11.4 Using Floorplan Manager to Create WDA Applications
639
11.4.1 Creating an Application Using Floorplan Manager
640
11.4.2 Integrating BOPF with Floorplan Manager
651
11.5 Summary
656
12 SAPUI5
659
12.1 Architecture
661
12.1.1 Frontend: What SAPUI5 Is
662
12.1.2 Backend: What SAP Gateway Is
663
12.2 Prerequisites
664
12.2.1 Requirements in SAP
664
12.2.2 Requirements on Your Local Machine
665
12.3 Backend Tasks: Creating the Model Manually Using SAP Gateway
665
12.3.1 Configuration
666
12.3.2 Coding
680
12.4 Backend Tasks: Automatically Generating the Model
691
12.4.1 BOPF/SAP Gateway Integration
691
12.4.2 CDS View/SAP Gateway Integration
694
12.5 Frontend Tasks: Creating the View and Controller Using SAPUI5
699
12.5.1 First Steps
699
12.5.2 View
702
12.5.3 Controller
715
12.5.4 Testing Your Application
721
12.6 Generating SAPUI5 Applications from SAP Web IDE Templates
723
12.7 Generating SAPUI5 Applications from the BUILD Tool
728
12.8 Adding Elements with OpenUI5
737
12.9 Importing SAPUI5 Applications to SAP ERP
741
12.9.1 Storing the Application in Releases Lower Than 7.31
742
12.9.2 Storing the Application in Releases 7.31 and Above
744
12.9.3 Testing the SAPUI5 Application from within SAP ERP
745
12.10 SAPUI5 vs. SAP Fiori
747
12.11 Summary
748
13 ABAP Channels
751
13.1 General Concept
752
13.1.1 ABAP Messaging Channels
753
13.1.2 ABAP Push Channels
754
13.2 ABAP Messaging Channels: SAP GUI Example
755
13.2.1 Coding the Sending Application
758
13.2.2 Coding the Receiving Application
764
13.2.3 Watching the Applications Communicate
768
13.3 ABAP Push Channels: SAPUI5 Example
771
13.3.1 Coding the Receiving (Backend) Components
772
13.3.2 Coding the Sending (Frontend) Application
780
13.4 Internet of Things Relevance
782
13.5 Summary
783
Appendices
785
A Conclusion
785
B The Author
789
Index
791