Inhaltsverzeichnis

Alle Kapitel aufklappen
Alle Kapitel zuklappen
Preface
17
Structure of the Book
19
Acknowledgments
22
1 Modeling Your First CDS Views
23
1.1 Define the Data Model of the Application
24
1.2 Implement the Data Model of the Application
26
1.2.1 Create Database Tables
28
1.2.2 Create a CDS View
31
1.2.3 Edit a CDS View
37
1.2.4 Create a Hierarchy of CDS Views
40
1.3 Summary
52
2 Fundamentals of CDS Data Modeling
53
2.1 Overview of CDS Models
54
2.2 Overview of CDS View Syntax
58
2.3 Key Fields
61
2.4 Cast Operations
62
2.5 Typed Literals
64
2.6 Simple Types
66
2.7 Case Statements
68
2.8 Session Variables
69
2.9 Client Handling
71
2.10 Select Distinct Statements
72
2.11 Union Views
73
2.11.1 Union Definitions
73
2.11.2 Union and Union All Logic
78
2.12 Intersect and Except Statements
79
2.13 Joins
81
2.14 SQL Aggregation Functions
87
2.15 Projection Fields
89
2.16 Parameters
91
2.17 Reference Fields
96
2.18 Conversion Functions for Currencies and Quantity Units
99
2.19 Provider Contracts
102
2.20 Entity Buffer Definitions
104
2.21 Summary
106
3 Associations
107
3.1 Define Associations
108
3.2 Expose Associations
111
3.3 Model Compositional Relations
111
3.4 Model M:N Relations
114
3.5 Project Associations
117
3.6 Use Associations in CDS Views
118
3.6.1 Define Path Expressions
118
3.6.2 Implicit Joins
121
3.6.3 Cardinality Changes Resulting from Path Expressions
124
3.6.4 Restrictions for Defining Path Expressions
127
3.7 Use Associations in ABAP Code
129
3.8 Summary
129
4 Annotations
131
4.1 Annotation Definitions
132
4.1.1 Syntax Overview
132
4.1.2 Annotation Names
136
4.1.3 Annotation Types and Values
139
4.1.4 Enumeration Values
140
4.1.5 Annotation Default Values
141
4.1.6 Annotation Scopes
142
4.2 Effects of Annotations
143
4.3 Propagation Logic for Annotations
145
4.3.1 Propagation Logic within Simple Type Hierarchies
145
4.3.2 Propagation Logic of Element Annotations
147
4.3.3 Consistency Aspects
152
4.4 Metadata Extensions
155
4.5 Active Annotations
158
4.6 Summary
160
5 Access Controls
161
5.1 Fundamentals of Access Controls
162
5.2 Mode of Action of Access Controls
166
5.3 Implementation Patterns for Access Controls
171
5.3.1 Implement Access Controls with Path Expressions
171
5.3.2 Inherit Implementation of Access Controls
180
5.3.3 Implement Access Controls without Using Authorization Objects
189
5.3.4 Implement Access Controls for Analytical Queries
194
5.3.5 Implement Access Controls for Transactional Applications
196
5.3.6 Implement Access Controls on the Field Level
199
5.3.7 Change Access Controls of SAP-Delivered CDS Models
200
5.3.8 Block Standard Data Selections from CDS Models
203
5.3.9 Decouple Access Controls from User Input
205
5.3.10 Map CDS Fields onto Fields of Authorization Objects Using Indirection
207
5.4 Test Access Controls
207
5.5 Summary
210
6 Business Services
211
6.1 Projection Views
212
6.2 Service Definitions
216
6.3 Service Bindings
221
6.3.1 OData UI Services
222
6.3.2 OData Web API Services
227
6.3.3 InA UI Services
228
6.3.4 SQL Web API Services
230
6.4 Testing Business Services
230
6.4.1 Use OData Service URLs
231
6.4.2 Use UI Previews
231
6.5 Summary
233
7 Native SAP HANA Functions in CDS
235
7.1 Implementation of a CDS Table Function
236
7.2 Application Scenarios
244
7.3 Improve Performance and Avoid Errors
245
7.4 Summary
247
8 Modeling Application Data
249
8.1 Application Architecture in SAP S/4HANA
250
8.2 Field Labels
253
8.2.1 Determination of a Field Label
254
8.2.2 Length of a Field Label
255
8.3 Field Semantics
257
8.3.1 Quantities and Amounts
257
8.3.2 Aggregation Behavior
258
8.3.3 System Times
260
8.3.4 Text and Languages
261
8.3.5 Information for the Fiscal Year
262
8.4 Foreign Key Relations
262
8.5 Text Relations
267
8.6 Composition Relations
270
8.7 Time-Dependent Data
272
8.8 Summary
274
9 The Virtual Data Model of SAP S/4HANA
275
9.1 Why a Virtual Data Model?
276
9.2 SAP Object Types and Object Node Types
277
9.3 Categories of CDS Entities in the Virtual Data Model
280
9.3.1 Basic Interface Views
280
9.3.2 Composite Interface Views
281
9.3.3 Consumption Views
283
9.3.4 Other Types of VDMs
284
9.4 Naming in the Virtual Data Model
285
9.5 Basic Interface View for the Sales Order
288
9.5.1 View Annotations
288
9.5.2 Structure of the Sales Order View
292
9.5.3 Specialization
293
9.5.4 Element Annotations
294
9.6 Tips for Finding Virtual Data Model Views
295
9.6.1 SAP Business Accelerator Hub and View Browser App
295
9.6.2 Search in ABAP Development Tools
298
9.6.3 Search Views with Specific Annotations
300
9.6.4 ABAP Where-Used List
301
9.7 Summary
301
10 Modeling Analytical Applications
303
10.1 Analytics in SAP S/4HANA
303
10.2 Analytical Views
305
10.2.1 First Analytical Cube View
305
10.2.2 Test Environment for Analytical Views
307
10.2.3 Analytical Cube Views
311
10.2.4 Analytical Dimension Views
314
10.2.5 Analytical Model in the Test Environment
320
10.2.6 Consistency of the Analytical Model
322
10.3 Analytical Queries
325
10.3.1 Definition of an Analytical Query
325
10.3.2 Initial Layout of a Query
329
10.3.3 Filter, Select Options, Parameters
332
10.3.4 Calculation of Measures
338
10.3.5 Restricted Measures
342
10.3.6 Exception Aggregation
344
10.3.7 Currencies and Conversion
351
10.3.8 Analytical Query Selecting from Dimension Views
355
10.4 Analytical Infrastructure
356
10.5 Summary
359
11 Modeling Transactional Applications
361
11.1 Transactional Applications
362
11.2 Transactional Infrastructure in SAP S/4HANA
363
11.3 Transactional Object Models
366
11.3.1 Object Models
366
11.3.2 Access Controls
370
11.4 Behavior Definitions
372
11.4.1 Create Behavior Definition
372
11.4.2 Behavior Pool and Handler Implementation
381
11.4.3 Consumption via EML
385
11.4.4 Static Field Control
386
11.4.5 Numbering
387
11.4.6 Exclusive Locks
393
11.4.7 Authorization Checks
397
11.4.8 Authorization Contexts and Privileged Access
401
11.4.9 Associations
403
11.4.10 Actions
407
11.4.11 Functions
421
11.4.12 Data Determinations and Validations
427
11.4.13 Dynamic Feature Control
437
11.4.14 Mappings
442
11.4.15 Calculated Fields
444
11.4.16 Prechecks
445
11.4.17 HTTP ETags
447
11.4.18 Draft
449
11.4.19 Side Effects
458
11.4.20 Change Documents
461
11.4.21 Events
464
11.5 Transactional Projection Object Models
467
11.5.1 Projection Object Models
467
11.5.2 Access Control
471
11.5.3 Denormalized Fields
471
11.5.4 Localized Elements
472
11.5.5 Calculated Fields/Virtual Elements
473
11.6 Define Interface Behavior Definition
477
11.6.1 Create Interface Behavior Definition
477
11.6.2 Static Feature Control
479
11.6.3 Operations
480
11.6.4 Draft, ETag, and Side Effects
481
11.6.5 Events
482
11.6.6 Consumption via EML
483
11.6.7 Release for Consumption
483
11.7 Define Projection Behavior Definition
484
11.7.1 Create Projection Behavior Definition
484
11.7.2 Actions and Functions
485
11.7.3 Prechecks
487
11.7.4 Augmentation
488
11.7.5 Side Effects
491
11.7.6 Events
492
11.7.7 Consumption via EML
492
11.8 Runtime Orchestration
492
11.8.1 Interaction Phase Operation Flow
493
11.8.2 Save Phase Operation Flow
494
11.8.3 Runtime Component Overview
496
11.8.4 Consumption via OData
497
11.9 SAP Fiori and OData Consumption
498
11.9.1 OData Service for Web API Consumption
498
11.9.2 OData Service for UI Consumption
499
11.10 SAP Event Mesh and Local Event Handlers
510
11.10.1 Local Event Handler
510
11.10.2 SAP Event Mesh
512
11.11 Summary
513
12 Hierarchies in CDS
515
12.1 Hierarchy Categories and Basics
516
12.2 Annotation-Based Parent-Child Hierarchies
517
12.2.1 Example of a Parent-Child Hierarchy
519
12.2.2 Determination of a Hierarchy
522
12.2.3 Test a Hierarchy
524
12.3 CDS Hierarchies
526
12.3.1 Data for an Example of a Reporting Line Hierarchy
526
12.3.2 Define the CDS Hierarchy
529
12.3.3 Hierarchy Attributes
531
12.3.4 Visualization of a Hierarchy
533
12.3.5 Hierarchy with an Orphaned Node
536
12.3.6 Hierarchy with Multiple Parent Nodes
537
12.3.7 Hierarchy with Cycles
539
12.3.8 Further Options for Defining Hierarchies
540
12.3.9 CDS Hierarchies in ABAP SQL
541
12.3.10 OData Service for CDS Hierarchies
543
12.4 Summary
548
13 CDS-Based Search Functionality
549
13.1 Modeling Value Helps
550
13.1.1 Modeling Elementary Value Helps
550
13.1.2 Integrating Value Help CDS Views
553
13.1.3 Collective Value Helps
556
13.1.4 Exposing Value Helps in OData Services
558
13.1.5 Using Value Helps
559
13.2 Free-Text Search Functionality in OData Services
570
13.3 Enterprise Search Functionality
578
13.3.1 Define Enterprise Search Models
578
13.3.2 Adapt Enterprise Search Models from SAP
580
13.4 Summary
583
14 Lifecycle and Stability
585
14.1 Stability Contracts
586
14.2 Lifecycle of Development Objects
590
14.3 Deprecation of Development Objects
592
14.4 Use of CDS Models and Supported Capabilities
594
14.5 Summary
598
15 Extensions of CDS Views and Other Entities
599
15.1 Solution Variants and ABAP Language Versions
600
15.2 Stable CDS Extensions
602
15.2.1 Stable Extensions of CDS Views
603
15.2.2 Example: Stable Extension Points
604
15.2.3 Example: Extension with Custom Fields
609
15.2.4 CDS Extensions in Product Variants
613
15.3 Extensions of Transactional Models
615
15.3.1 Add Fields to an Entity
615
15.3.2 Add Application Logic
618
15.3.3 Extend Action and Function Parameters and Results
620
15.3.4 Extend Behavior
620
15.3.5 Add Composition Child Entity
622
15.4 Summary
628
16 Automated Testing
631
16.1 Test Logic of Data Selections
631
16.1.1 Fundamentals of the Test Double Framework
632
16.1.2 Test Sample Overview
633
16.1.3 Test Implementations of CDS Views
636
16.1.4 Test ABAP Logic with SQL Accesses to CDS Views
650
16.1.5 Test Code Generation Functions
653
16.2 Test Logic of Transactional Applications
658
16.2.1 Test Behavior Handler
658
16.2.2 Test Events and Event Payloads
661
16.2.3 Test Event Handler
667
16.2.4 Tests via EML Interface
669
16.3 Summary
670
17 Troubleshooting
671
17.1 Performance Aspects
671
17.1.1 Static View Complexity
672
17.1.2 Calculated Fields
675
17.1.3 CDS Models in ABAP Code
678
17.1.4 Performance Tests
678
17.1.5 Analysis Tools
679
17.2 Pitfalls
687
17.2.1 Null Values
688
17.2.2 Data Types
691
17.2.3 Decimal Shift Logic for Amounts
696
17.3 Troubleshoot Implementations of CDS Models
698
17.3.1 Syntax Checks
698
17.3.2 Consistency Checks of Frameworks
702
17.4 Troubleshoot Activation Issues
706
17.4.1 Online Activation
707
17.4.2 Mass Checks and Repairs
708
17.5 Examine ABAP RESTful Application Programming Model Applications
711
17.6 Summary
714
Appendices
715
A CDS Annotation Reference
717
B Migration to the ABAP RESTful Application Programming Model
729
C The Authors
737
Index
739