Inhaltsverzeichnis

Alle Kapitel aufklappen
Alle Kapitel zuklappen
Preface
17
Structure of the Book
19
Acknowledgments
22
1 Modeling Your First CDS View
23
1.1 Define the Data Model of the Application
24
1.2 Implement the Data Model of the Application
27
1.2.1 Create Database Tables
28
1.2.2 Create a CDS View
32
1.2.3 Edit a CDS View
37
1.2.4 Create a Hierarchy of CDS Views
41
1.3 Summary
51
2 Fundamentals of CDS Data Modeling
53
2.1 Overview of CDS Models
54
2.2 Overview of CDS View Syntax
57
2.3 Key Fields
59
2.4 Cast Operations
61
2.5 Typed Literals
63
2.6 Case Statements
64
2.7 Session Variables
66
2.8 Client Handling
67
2.9 Union Views
69
2.10 Joins
76
2.11 SQL Aggregation Functions
82
2.12 Projection Fields
85
2.13 Parameters
86
2.14 Reference Fields
91
2.15 Conversion Functions for Currencies and Quantity Units
94
2.16 Summary
97
3 Associations
99
3.1 Define Associations
100
3.2 Expose Associations
102
3.3 Model Compositional Relations
103
3.4 Model M:N Relations
105
3.5 Project Associations
109
3.6 Use Associations in CDS Views
109
3.6.1 Define Path Expressions
110
3.6.2 Joins Resulting from Path Expressions
112
3.6.3 Cardinality Changes Resulting from Path Expressions
115
3.6.4 Restrictions for Defining Path Expressions
118
3.7 Use Associations in ABAP Code
120
3.8 Summary
121
4 Annotations
123
4.1 Annotation Definitions
124
4.1.1 Syntax Overview
124
4.1.2 Annotation Names
128
4.1.3 Annotation Types and Values
131
4.1.4 Enumeration Values
131
4.1.5 Annotation Default Values
132
4.1.6 Annotation Scopes
133
4.2 Effects of Annotations
135
4.3 Propagation Logic of Element Annotations
137
4.3.1 Basic Principles
137
4.3.2 Consistency Aspects
142
4.4 CDS Metadata Extensions
144
4.5 Active Annotations
148
4.6 Summary
149
5 Access Controls
151
5.1 Fundamentals of Access Controls
152
5.2 Mode of Action of Access Controls
156
5.3 Implementation Patterns for Access Controls
161
5.3.1 Implement Access Controls with Path Expressions
161
5.3.2 Inherit Implementation of Access Controls
170
5.3.3 Implement Access Controls without Using Authorization Objects
178
5.3.4 Implement Access Controls for Analytical Queries
183
5.3.5 Implement Access Controls on the Field Level
185
5.3.6 Change Access Controls of SAP-Delivered CDS Models
186
5.3.7 Block Standard Data Selections from CDS Models
189
5.3.8 Decouple Access Controls from User Input
191
5.3.9 Map CDS Fields onto Fields of Authorization Objects Using Indirection
193
5.4 Test Access Controls
193
5.5 Summary
196
6 Business Services
197
6.1 Projection Views
198
6.2 Service Definitions
201
6.3 Service Bindings
206
6.3.1 UI Services
206
6.3.2 Web API Services
211
6.3.3 InA Services
212
6.4 Testing Business Services
213
6.5 Summary
215
7 Native SAP HANA Functions in CDS
217
7.1 Implementation of a CDS Table Function
218
7.2 Application Scenarios
226
7.3 Aspects for Consideration
227
7.4 Summary
228
8 Modeling Application Data
231
8.1 Application Architecture in SAP S/4HANA
232
8.2 Field Labels
235
8.2.1 Determination of a Field Label
236
8.2.2 Length of a Field Label
237
8.3 Field Semantics
239
8.3.1 Quantities and Amounts
239
8.3.2 Aggregation Behavior
240
8.3.3 System Times
242
8.3.4 Text and Languages
243
8.3.5 Information for the Fiscal Year
244
8.4 Foreign Key Relations
245
8.5 Text Relations
249
8.6 Composition Relations
252
8.7 Time-Dependent Data
255
8.8 Summary
256
9 The Virtual Data Model in SAP S/4HANA
257
9.1 Why a Virtual Data Model?
257
9.2 Lifecycle, Release, and Stability
259
9.2.1 Release Contracts and Visibility
260
9.2.2 Lifecycle
262
9.2.3 Deprecation
264
9.2.4 Supported Capabilities
266
9.3 Structure of the Virtual Data Model
270
9.3.1 Basic Interface Views
270
9.3.2 Composite Interface Views
273
9.3.3 Consumption Views
274
9.3.4 Other Types of VDMs
276
9.4 Naming in the Virtual Data Model
277
9.4.1 Field Names
277
9.4.2 Names of VDM Views
279
9.4.3 Names of Parameters and Associations
282
9.5 Basic Interface View for the Sales Order
282
9.5.1 View Annotations
283
9.5.2 Structure of the Sales Order View
286
9.5.3 Specialization
287
9.5.4 Element Annotations
288
9.6 Tips for Finding Virtual Data Model Views
289
9.6.1 Explore CDS Views in SAP API Business Hub
289
9.6.2 Search in the ABAP Development Tools
294
9.6.3 Search Views with Specific Annotations
296
9.6.4 ABAP Where-Used List
297
9.7 Summary
298
10 Modeling Analytical Applications
299
10.1 Analytics in SAP S/4HANA
299
10.2 Analytical Views
301
10.2.1 First Analytical Cube View
301
10.2.2 Test Environment for Analytical Views
302
10.2.3 Analytical Cube Views
306
10.2.4 Analytical Dimension Views
309
10.2.5 Analytical Model in the Test Environment
315
10.2.6 Consistency of the Analytical Model
318
10.3 Analytical Queries
321
10.3.1 Definition of an Analytical Query
321
10.3.2 Initial Layout of a Query
324
10.3.3 Filter, Select Options, Parameters
327
10.3.4 Calculation of Measures
332
10.3.5 Restricted Measures
336
10.3.6 Exception Aggregation
337
10.3.7 Currencies and Conversion
344
10.3.8 Analytical Query Selecting from Dimension Views
347
10.4 Analytical Infrastructure
348
10.5 Summary
351
11 Modeling Transactional Applications
353
11.1 Transactional Applications
354
11.2 Transactional Infrastructure in SAP S/4HANA
355
11.3 Transactional Object Models
358
11.3.1 Object Models
359
11.3.2 Access Controls
363
11.4 Behavior Definitions
364
11.4.1 Create Behavior Definition
364
11.4.2 Behavior Pool and Handler Implementation
373
11.4.3 Consumption via EML
377
11.4.4 Static Field Control
378
11.4.5 Numbering
380
11.4.6 Exclusive Locks
385
11.4.7 Authorization Checks
388
11.4.8 Actions
393
11.4.9 Functions
405
11.4.10 Data Determinations and Validations
412
11.4.11 Dynamic Feature Control
421
11.4.12 Mappings
427
11.4.13 Calculated Fields
428
11.4.14 Prechecks
429
11.4.15 HTTP ETags
431
11.4.16 Draft
433
11.5 Transactional Service Models
442
11.5.1 Service Models
442
11.5.2 Access Control
445
11.5.3 Localized Elements
446
11.5.4 Calculated Fields/Virtual Elements
446
11.6 Define Projection Behavior Definition
451
11.6.1 Projection Behavior Definition
451
11.6.2 Static Field Control
452
11.6.3 Operations and Features
453
11.6.4 Actions and Functions
456
11.6.5 Prechecks
458
11.6.6 Augmentation
458
11.6.7 Consumption via EML
461
11.7 Runtime Orchestration
461
11.7.1 Interaction Phase Operation Flow
462
11.7.2 Save Phase Operation Flow
463
11.7.3 Runtime Component Overview
464
11.7.4 Consumption via OData
466
11.8 SAP Fiori and OData Consumption
466
11.8.1 OData Service for Web API Consumption
466
11.8.2 OData Service for UI Consumption
468
11.9 Summary
479
12 Hierarchies in CDS
481
12.1 Hierarchy Categories and Basics
481
12.2 Annotation-Based Parent-Child Hierarchies
484
12.2.1 Example of a Parent-Child Hierarchy
486
12.2.2 Determination of a Hierarchy
488
12.2.3 Test a Hierarchy
490
12.3 CDS Hierarchies
492
12.3.1 Data for an Example of a Reporting Line Hierarchy
492
12.3.2 Define the CDS Hierarchy
496
12.3.3 Hierarchy Attributes
498
12.3.4 Visualization of a Hierarchy
500
12.3.5 Hierarchy with an Orphaned Node
503
12.3.6 Hierarchy with Multiple Parent Nodes
504
12.3.7 Hierarchy with Cycles
506
12.3.8 Further Options for Defining Hierarchies
507
12.3.9 CDS Hierarchies in ABAP SQL
508
12.4 Summary
510
13 CDS-Based Search Functionality
511
13.1 Modeling Value Helps
512
13.1.1 Modeling Value Help Views
512
13.1.2 Integrating Value Help Views
515
13.1.3 Exposing Value Helps
517
13.1.4 Using Value Helps
518
13.2 Free-Text Search Functionality in OData Services
529
13.3 Summary
537
14 Extensions of CDS Views and View Entities
539
14.1 Extension Options
540
14.1.1 Key User Extensions
540
14.1.2 Extensions Defined in ABAP Development Tools
541
14.2 CDS Entity Extensions
541
14.2.1 Extension of a CDS View Entity
542
14.2.2 Extension of a CDS View Stack
546
14.2.3 Indirect CDS View Extensions
547
14.2.4 Extend the Extension Include View
549
14.2.5 Extension Association
551
14.2.6 Stability of Indirect CDS View Extension
551
14.3 Usage of CDS Entity Extensions
552
14.3.1 Missing Extension Association
552
14.3.2 Missing Extension Include View
553
14.3.3 Missing Foreign Key Fields
554
14.3.4 Analytical Query Views
554
14.3.5 Extension with Standard Fields
555
14.3.6 Extensions of Released CDS Views
556
14.3.7 Extensions with Calculated Fields
558
14.4 Summary
558
15 Automated Testing
561
15.1 Fundamentals of the Test Double Framework
562
15.2 Test Sample Overview
563
15.3 Test Implementations of CDS Views
566
15.3.1 Create Test Design
566
15.3.2 Implement ABAP Unit Tests
568
15.3.3 Test CDS Access Controls
573
15.3.4 Test CDS Views with Conversion Functions for Currencies and Quantity Units
576
15.3.5 Test Data Sources with Null Values
579
15.4 Test ABAP Logic with SQL Accesses to CDS Views
580
15.5 Test Code Generation Functions
583
15.5.1 Create Test Classes
583
15.5.2 Adapt Test Classes
586
15.6 Summary
587
16 Troubleshooting
589
16.1 Performance Aspects
589
16.1.1 Static View Complexity
590
16.1.2 Calculated Fields
593
16.1.3 CDS Models in ABAP Code
595
16.1.4 Performance Tests
596
16.2 Pitfalls
596
16.2.1 Null Values
596
16.2.2 Data Types
600
16.2.3 Decimal Shift Logic for Amounts
604
16.3 Troubleshoot Implementations of CDS Models
606
16.3.1 Syntax Checks
607
16.3.2 Consistency Checks of Frameworks
611
16.4 Troubleshoot Activation Issues
613
16.4.1 Online Activation
614
16.4.2 Mass Checks and Repairs
616
16.5 Summary
618
Appendices
621
A CDS Annotation Reference
621
B The Authors
633
Index
635