Core data services for abap renzo colle all chapter instant download

Page 1


Core Data Services for ABAP Renzo Colle

Visit to download the full and correct content document: https://ebookmass.com/product/core-data-services-for-abap-renzo-colle/

More products digital (pdf, epub, mobi) instant download maybe you interests ...

Google Cloud Platform for Data Science: A Crash Course on Big Data, Machine Learning, and Data Analytics Services Dr. Shitalkumar R. Sukhdeve

https://ebookmass.com/product/google-cloud-platform-for-datascience-a-crash-course-on-big-data-machine-learning-and-dataanalytics-services-dr-shitalkumar-r-sukhdeve/

Ocean Science Data: Collection, Management, Networking and Services Giuseppe Manzella

https://ebookmass.com/product/ocean-science-data-collectionmanagement-networking-and-services-giuseppe-manzella/

Ocean Science Data: Collection, Management, Networking and Services Giuseppe Manzella

https://ebookmass.com/product/ocean-science-data-collectionmanagement-networking-and-services-giuseppe-manzella-2/

Relationship Between Microbes and the Environment for Sustainable Ecosystem Services, Volume 3: Microbial Tools for Sustainable Ecosystem Services Jastin Samuel

https://ebookmass.com/product/relationship-between-microbes-andthe-environment-for-sustainable-ecosystem-servicesvolume-3-microbial-tools-for-sustainable-ecosystem-services-

Relationship Between Microbes and the Environment for Sustainable Ecosystem Services, Volume 1: Microbial Products for Sustainable Ecosystem Services Jastin

Samuel

https://ebookmass.com/product/relationship-between-microbes-andthe-environment-for-sustainable-ecosystem-servicesvolume-1-microbial-products-for-sustainable-ecosystem-servicesjastin-samuel/

Relationship Between Microbes and the Environment for Sustainable Ecosystem Services, Volume 2: Microbial Mitigation of Waste for Sustainable Ecosystem Services

Jastin Samuel

https://ebookmass.com/product/relationship-between-microbes-andthe-environment-for-sustainable-ecosystem-servicesvolume-2-microbial-mitigation-of-waste-for-sustainable-ecosystemservices-jastin-samuel/

Core Curriculum for Forensic Nursing First Edition, (Ebook PDF)

https://ebookmass.com/product/core-curriculum-for-forensicnursing-first-edition-ebook-pdf/

Core Curriculum for Transplant Nurses 2nd Edition, (Ebook PDF)

https://ebookmass.com/product/core-curriculum-for-transplantnurses-2nd-edition-ebook-pdf/

Transforming China's Public Services: A Plan for 2030

Keyong Dong

https://ebookmass.com/product/transforming-chinas-publicservices-a-plan-for-2030-keyong-dong/

Core Data Services for ABAP®

3rd edition 2024, updated and revised

Imprint

This e-book is a publication many contributed to, specifically:

Editor   Megan Fuerst

Acquisitions Editor   Hareem Shafi

Copyeditor   Julie McNamee

Cover Design   Bastian Illerhaus

Photo Credit Unsplash: li-zhang-K-DwbsTXliY

Production E-Book   Kelly O’Callaghan

Typesetting E-Book   Satz-Pro (Germany)

We hope that you liked this e-book. Please share your feedback with us and read the Service Pages to find out how to contact us.

Library of Congress Cataloging-in-Publication Control Number:2023945756

ISBN 978-1-4932-2376-3 (print)

ISBN 978-1-4932-2377-0 (e-book)

ISBN 978-1-4932-2378-7 (print and e-book)

© 2024 by Rheinwerk Publishing Inc., Boston (MA) 3rd edition 2024, updated and revised

Notes on Usage

This e-book is protected by copyright. By purchasing this e-book, you have agreed to accept and adhere to the copyrights. You are entitled to use this e-book for personal purposes. You may print and copy it, too, but also only for personal use. Sharing an electronic or printed copy with others, however, is not permitted, neither as a whole nor in parts. Of course, making them available on the internet or in a company network is illegal as well.

For detailed and legally binding usage conditions, please refer to the section Legal Notes.

This e-book copy contains a digital watermark, a signature that indicates which person may use this copy:

Notes on the Screen Presentation

You are reading this e-book in a file format (EPUB or Mobi) that makes the book content adaptable to the display options of your reading device and to your personal needs. That’s a great thing; but unfortunately not every device displays the content in the same way and the rendering of features such as pictures and tables or hyphenation can lead to difficulties. This e-book was optimized for the presentation on as many common reading devices as possible.

If you want to zoom in on a figure (especially in iBooks on the iPad), tap the respective figure once. By tapping once again, you return to the previous screen. You can find more recommendations on the customization of the screen layout on the Service Pages.

Table of Contents

Notes on Usage

Table of Contents

Preface

1   Modeling Your First CDS

Views

1.1 Define the Data Model of the Application

1.2 Implement the Data Model of the Application

1.2.1   Create Database Tables

1.2.2   Create a CDS View

1.2.3   Edit a CDS View

1.2.4   Create a Hierarchy of CDS Views

1.3 Summary

2   Fundamentals of CDS Data

Modeling

2.1 Overview of CDS Models

2.2 Overview of CDS View Syntax

2.3 Key Fields

2.4 Cast Operations

2.5 Typed Literals

2.6 Simple Types

2.7 Case Statements

2.8 Session Variables

2.9 Client Handling

2.10 Select Distinct Statements

2.11 Union Views

2.11.1   Union Definitions

2.11.2   Union and Union All Logic

2.12 Intersect and Except Statements

2.13 Joins

2.14 SQL Aggregation Functions

2.15 Projection Fields

2.16 Parameters

2.17 Reference Fields

2.18 Conversion Functions for Currencies and Quantity Units

2.19 Provider Contracts

2.20 Entity Buffer Definitions

2.21 Summary

3   Associations

3.1 Define Associations

3.2 Expose Associations

3.3 Model Compositional Relations

3.4 Model M:N Relations

3.5 Project Associations

3.6 Use Associations in CDS Views

3.6.1   Define Path Expressions

3.6.2   Implicit Joins

3.6.3   Cardinality Changes Resulting from Path Expressions

3.6.4   Restrictions for Defining Path Expressions

3.7 Use Associations in ABAP Code

3.8 Summary

4   Annotations

4.1 Annotation Definitions

4.1.1   Syntax Overview

4.1.2   Annotation Names

4.1.3   Annotation Types and Values

4.1.4   Enumeration Values

4.1.5   Annotation Default Values

4.1.6   Annotation Scopes

4.2 Effects of Annotations

4.3 Propagation Logic for Annotations

4.3.1   Propagation Logic within Simple Type Hierarchies

4.3.2   Propagation Logic of Element Annotations

4.3.3   Consistency Aspects

4.4 Metadata Extensions

4.5 Active Annotations

4.6 Summary

5   Access Controls

5.1 Fundamentals of Access Controls

5.2 Mode of Action of Access Controls

5.3 Implementation Patterns for Access Controls

5.3.1   Implement Access Controls with Path Expressions

5.3.2   Inherit Implementation of Access Controls

5.3.3   Implement Access Controls without Using Authorization Objects

5.3.4   Implement Access Controls for Analytical Queries

5.3.5   Implement Access Controls for Transactional Applications

5.3.6   Implement Access Controls on the Field Level

5.3.7   Change Access Controls of SAP-Delivered CDS Models

5.3.8   Block Standard Data Selections from CDS Models

5.3.9   Decouple Access Controls from User Input

5.3.10   Map CDS Fields onto Fields of Authorization Objects Using Indirection

6.3.1   OData UI Services 6.3.2   OData Web API Services

6.3.3   InA UI Services

6.3.4   SQL Web API Services

6.4 Testing Business Services

6.4.1   Use OData Service URLs

6.4.2   Use UI Previews

6.5 Summary

7   Native SAP HANA Functions in CDS

7.1 Implementation of a CDS Table Function

7.2 Application Scenarios

7.3 Improve Performance and Avoid Errors

7.4 Summary

8   Modeling Application Data

8.1 Application Architecture in SAP S/4HANA

8.2 Field Labels

8.2.1   Determination of a Field Label

8.2.2   Length of a Field Label

8.3 Field Semantics

8.3.1   Quantities and Amounts

8.3.2   Aggregation Behavior

8.3.3   System Times

8.3.4   Text and Languages

8.3.5   Information for the Fiscal Year

8.4 Foreign Key Relations

8.5 Text Relations

8.6 Composition Relations

8.7 Time-Dependent Data

8.8 Summary

9   The Virtual Data Model of SAP S/4HANA

9.1 Why a Virtual Data Model?

9.2 SAP Object Types and Object Node Types

9.3 Categories of CDS Entities in the Virtual Data Model

9.3.1   Basic Interface Views

9.3.2   Composite Interface Views

9.3.3   Consumption Views

9.3.4   Other Types of VDMs

9.4 Naming in the Virtual Data Model

9.5 Basic Interface View for the Sales Order

9.5.1   View Annotations

9.5.2   Structure of the Sales Order View

9.5.3   Specialization

9.5.4   Element Annotations

9.6 Tips for Finding Virtual Data Model Views

9.6.1   SAP Business Accelerator Hub and View Browser App

9.6.2   Search in ABAP Development Tools

9.6.3   Search Views with Specific Annotations

9.6.4   ABAP Where-Used List

9.7 Summary

10   Modeling Analytical Applications

10.1 Analytics in SAP S/4HANA

10.2 Analytical Views

10.2.1   First Analytical Cube View

10.2.2   Test Environment for Analytical Views

10.2.3   Analytical Cube Views

10.2.4   Analytical Dimension Views

10.2.5   Analytical Model in the Test Environment

10.2.6   Consistency of the Analytical Model

10.3 Analytical Queries

10.3.1   Definition of an Analytical Query

10.3.2   Initial Layout of a Query

10.3.3   Filter, Select Options, Parameters

10.3.4   Calculation of Measures

10.3.5   Restricted Measures

10.3.6   Exception Aggregation

10.3.7   Currencies and Conversion

10.3.8   Analytical Query Selecting from Dimension Views

10.4 Analytical Infrastructure

10.5 Summary

11   Modeling Transactional Applications

11.1 Transactional Applications

11.2 Transactional Infrastructure in SAP S/4HANA

11.3 Transactional Object Models

11.3.1   Object Models

11.3.2   Access Controls

11.4 Behavior Definitions

11.4.1   Create Behavior Definition

11.4.2   Behavior Pool and Handler Implementation

11.4.3   Consumption via EML

11.4.4   Static Field Control

11.4.5   Numbering

11.4.6   Exclusive Locks

11.4.7   Authorization Checks

11.4.8   Authorization Contexts and Privileged Access

11.4.9   Associations

11.4.10   Actions

11.4.11   Functions

11.4.12   Data Determinations and Validations

11.4.13   Dynamic Feature Control

11.4.14   Mappings

11.4.15   Calculated Fields

11.4.16   Prechecks

11.4.17   HTTP ETags

11.4.18   Draft

11.4.19   Side Effects

11.4.20   Change Documents

11.4.21   Events

11.5 Transactional Projection Object Models

11.5.1   Projection Object Models

11.5.2   Access Control

11.5.3   Denormalized Fields

11.5.4   Localized Elements

11.5.5   Calculated Fields/Virtual Elements

11.6 Define Interface Behavior Definition

11.6.1   Create Interface Behavior Definition

11.6.2   Static Feature Control

11.6.3   Operations

11.6.4   Draft, ETag, and Side Effects

11.6.5   Events

11.6.6   Consumption via EML

11.6.7   Release for Consumption

11.7 Define Projection Behavior

Definition

11.7.1   Create Projection Behavior Definition

11.7.2   Actions and Functions

11.7.3   Prechecks

11.7.4   Augmentation

11.7.5   Side Effects

11.7.6   Events

11.7.7   Consumption via EML

11.8 Runtime Orchestration

11.8.1   Interaction Phase Operation Flow

11.8.2   Save Phase Operation Flow

11.8.3   Runtime Component Overview

11.8.4   Consumption via OData

11.9 SAP Fiori and OData Consumption

11.9.1   OData Service for Web API Consumption

11.9.2   OData Service for UI Consumption

11.10 SAP Event Mesh and Local Event Handlers

11.10.1   Local Event Handler

11.10.2   SAP Event Mesh

11.11 Summary

12   Hierarchies in CDS

12.1 Hierarchy Categories and Basics

12.2 Annotation-Based Parent-Child Hierarchies

12.2.1   Example of a Parent-Child Hierarchy

12.2.2   Determination of a Hierarchy

12.2.3   Test a Hierarchy

12.3 CDS Hierarchies

12.3.1   Data for an Example of a Reporting Line Hierarchy

12.3.2   Define the CDS Hierarchy

12.3.3   Hierarchy Attributes

12.3.4   Visualization of a Hierarchy

12.3.5   Hierarchy with an Orphaned Node

12.3.6   Hierarchy with Multiple Parent Nodes

12.3.7   Hierarchy with Cycles

12.3.8   Further Options for Defining Hierarchies

12.3.9   CDS Hierarchies in ABAP SQL

12.3.10   OData Service for CDS Hierarchies

12.4 Summary

13   CDS-Based Search

Functionality

13.1 Modeling Value Helps

13.1.1   Modeling Elementary Value Helps

13.1.2   Integrating Value Help CDS Views

13.1.3   Collective Value Helps

13.1.4   Exposing Value Helps in OData Services

13.1.5   Using Value Helps

13.2 Free-Text Search Functionality in OData Services

13.3 Enterprise Search Functionality

13.3.1   Define Enterprise Search Models

13.3.2   Adapt Enterprise Search Models from SAP 13.4 Summary

14   Lifecycle and Stability

14.1 Stability Contracts 14.2 Lifecycle of Development Objects

14.3 Deprecation of Development Objects

14.4 Use of CDS Models and Supported Capabilities

14.5 Summary

15   Extensions of CDS Views and Other Entities

15.1 Solution Variants and ABAP Language Versions

15.2 Stable CDS Extensions

15.2.1   Stable Extensions of CDS Views

15.2.2   Example: Stable Extension Points

15.2.3   Example: Extension with Custom Fields

15.2.4   CDS Extensions in Product Variants

15.3 Extensions of Transactional Models

15.3.1   Add Fields to an Entity

15.3.2   Add Application Logic

15.3.3   Extend Action and Function Parameters and Results

15.3.4   Extend Behavior

15.3.5   Add Composition Child Entity

15.4 Summary

16   Automated Testing

16.1 Test Logic of Data Selections

16.1.1   Fundamentals of the Test Double Framework

16.1.2   Test Sample Overview

16.1.3   Test Implementations of CDS Views

16.1.4   Test ABAP Logic with SQL Accesses to CDS Views

16.1.5   Test Code Generation Functions

16.2 Test Logic of Transactional Applications

16.2.1   Test Behavior Handler

16.2.2   Test Events and Event Payloads

16.2.3   Test Event Handler

16.2.4   Tests via EML Interface

16.3 Summary

17   Troubleshooting

17.1 Performance Aspects

17.1.1   Static View Complexity

17.1.2   Calculated Fields

17.1.3   CDS Models in ABAP Code

17.1.4   Performance Tests

17.1.5   Analysis Tools

17.2 Pitfalls

17.2.1   Null Values

17.2.2   Data Types

17.2.3   Decimal Shift Logic for Amounts

17.3 Troubleshoot Implementations of CDS Models

17.3.1   Syntax Checks

17.3.2   Consistency Checks of Frameworks

17.4 Troubleshoot Activation Issues

17.4.1   Online Activation

17.4.2   Mass Checks and Repairs

17.5 Examine ABAP RESTful Application Programming Model Applications

17.6 Summary

A   CDS Annotation Reference

B   Migration to the ABAP

RESTful Application Programming Model

C   The Authors

Index Service Pages

Legal Notes

Preface

ABAP's core data services (CDS) technology forms the basis of the ABAP platform’s modern programming model and is therefore an important part of SAP’s current technology strategy. Among other things, as an extension of SQL, this technology allows users to leverage the features of the SAP HANA database. ABAP CDS and its annotations can be used to enhance the model with information that can be optimally integrated into analytical applications and web interfaces for cloud applications or user interfaces (UIs) via OData as a model-based protocol. CDS also serves as a foundation for the new ABAP RESTful application programming model. Therefore, CDS and the programming model based on it form the basis of SAP Fiori applications, which embody the new standards for the modern user experience (UX) of SAP applications.

SAP S/4HANA, the next generation business suite, is also based on CDS in the form of the virtual data model (VDM).

In this book, we describe the use of CDS from the perspective of SAP S/4HANA and its overall architecture. Therefore, we not only describe the technical aspects of CDS but also the motivation behind the applied approaches. We use examples from application development and supplement them with recommendations for the successful implementation of your own projects, which go far beyond discussing purely functional aspects.

We cover the most important aspects and functions of ABAP CDS, which are used in concrete use cases in the SAP S/4HANA environment (up to date for release SAP S/4HANA 2023). For a technical description of all CDS functions, you can refer to the SAP standard documentation. This book also provides the relevant basis (in the respective version of the ABAP platform) for the applicable syntax and scope of functions supported.

The CDS-based programming model is relatively new and is therefore still subject to changes and significant further enhancements and features. Especially in the field of transactional applications and the ABAP RESTful application programming model, the development of the programming model is still evolving. Particularly in this area, we expect the implementation to become more efficient and the range of features and functions to be extended significantly in the future. You should always consider this evolution when implementing your own projects.

With this book, we aim to give you an overview of the CDSbased programming model and possible use cases. The knowledge we provide will enable you to define CDS models based on the basic rules and recommendations that the SAP standard development follows, to use them in a reasonable way in your applications, and to enhance the SAP S/4HANA standard applications. By the time you’ve finished the book, you should have developed comprehensive knowledge of the underlying concepts, learned how SAP uses these concepts in SAP S/4HANA, and gained a practical understanding of how these concepts can be applied when building your own applications.

The book is primarily aimed at ABAP developers who want to develop or enhance ABAP-based applications for use in OData application programming interfaces (APIs), in analytics or in SAP Fiori UIs. Basic knowledge of ABAP development and SQL is required. However, if you’re a newcomer to the ABAP and SQL world, the book will help you create your first applications and services with the help of CDS models. You can very quickly develop appealing analytical applications and interfaces, as well as purely reading applications, without writing ABAP code yourself.

Still, to enter the transactional world with the ABAP RESTful application programming model, using ABAP as a programming language for business logic is a prerequisite; in addition, a lot of model-driven infrastructure support is available. We’ll only deal with these topics on a very basic level in the context of this book. We also won’t go into detailed discussions regarding the SAP Fiori UI and will only use simple examples to show how you can easily create an OData service and an SAP Fiori UI based on your CDS models. However, you can also deepen your knowledge by studying the relevant literature or SAP documentation in parallel.

In the third edition of this book, the newest developments and features of the ABAP platform are reflected and included. With this, the structuring of the book was also reworked. The chapter on transactional applications (Chapter 11) has been enhanced significantly to cover the newest features of the ABAP RESTful application programming model (e.g., business events) and much more. We have provided a completely new chapter for the software lifecycle and stability of CDS and ABAP RESTful

application programming model artifacts; based on this, we’ve reworked the complete chapter on extensions of applications. The other chapters have all been updated accordingly, especially the chapter for test automation and troubleshooting, which has been enhanced to also cover transactional applications. Further, all CDS-based examples are now based on CDS view entities (CDS V2), the new generation of CDS views discussed and explained in the previous editions.

The descriptions and examples refer to the current state of the art (up to date for release SAP S/4HANA 2023, but also the related SAP S/4HANA Cloud, public edition). Most of the concepts and basics also work in general for ABAP cloudbased applications independent of SAP S/4HANA. We’ve created them to the best of our knowledge but can’t completely exclude errors. If in doubt, consult the official SAP documentation.

We use ABAP in Eclipse (ABAP Development Tools [ADT]) as our development environment. English is the default development language for development objects or comments in source code. All texts relevant for the end user can be translated, of course, and thus any application can also be localized.

Structure of the Book

This section provides a rough overview of the chapter structure and the content of the individual chapters. The first four chapters should be read sequentially as a foundation because all other concepts and chapters are

based on them. You can then jump back and forth between the individual chapters according to your needs and interests.

Chapter 1 shows you how to define your first simple CDS views quickly. In addition to the essential parts of a CDS view, we’ll also briefly introduce the most important development tools.

Chapter 2 provides the fundamentals and technical basics of CDS data models. For this purpose, we present the relevant CDS artifacts from the developer’s point of view, including their components, using modeling examples.

In Chapter 3, we explain the basics, definition, and usage of associations in CDS models via ABAP implementation and special association types, such as compositions.

In Chapter 4, we explain the basics of CDS annotations and their propagation logic using examples. CDS annotations enrich the data models with semantic information. This information is interpreted by CDS consumers and controls, and then influence, for example, the presentation on the UI or the aggregation behavior of an analytical application.

In Chapter 5, we deal with the authorizations for accessing the data exposed by the CDS models. Access controls using the CDS data control language (DCL) enable you to restrict the selection results of CDS views according to the user’s authorizations via classic ABAP authorization objects. We explain the basics of CDS access controls and demonstrate their concrete use.

In Chapter 6, you get an insight into the modeling and definition of business services based on a special view type,

projection views, service definitions, and service bindings focusing on OData protocol–based bindings. Business services allow you to expose your CDS models to external consumers.

In Chapter 7, we examine CDS table functions, which enable you to integrate native SAP HANA functions into the CDS view stack using SQLScript. We illustrate the modeling of CDS table functions and highlight their special features.

Chapter 8 provides an overview of the application architecture in SAP S/4HANA and the positioning of CDS within this architecture. Using examples, we show how important aspects of application data are modeled with CDS, such as field labels, field semantics, foreign key relationships, language-dependent texts, entity compositions, and time-dependent data.

In Chapter 9, we explain the virtual data model (VDM) of SAP S/4HANA, which is formed by selected CDS views that meet centrally defined quality and modeling aspects. The modeling rules used are presented schematically via examples. The explanations are intended to help you understand the CDS models delivered by SAP and enable you to use them purposefully in your own developments.

In Chapter 10, we focus on analytical applications. We briefly discuss the SAP S/4HANA architecture for embedded analytics and explain how CDS views can be used for this. The analytical model used is based on a consistent network of interlinked analytical CDS views and exposed via analytical queries. We use examples to show you the relationships between these CDS views and their special features and analytical calculations.

In Chapter 11, we then deal with transactional applications. In addition to modeling and executing read accesses, CDS also is the basic data model for enabling transactional processing. The integration of a transactional runtime based on the ABAP RESTful application programming model and the special aspects of transactional applications, such as locking, authorizations, feature control, business logic (e.g., actions, determinations, and validations), and business events are explained using appropriate examples. In addition, the draft concept is introduced and explained in detail.

In Chapter 12, we introduce two options for the flexible modeling in CDS of hierarchical structured data with concrete examples. The hierarchical models are interpreted directly by the underlying infrastructure (e.g., in analytical applications) or can be used as powerful functions for navigation or aggregation of these hierarchies in your ABAP implementations.

Chapter 13 shows you that CDS can also be used as a basis for modeling value helps and free-text searches. You’ll learn how the value helps and search functions can be integrated and used in certain use cases, for example, for OData exposure.

Chapter 14 addresses the question of lifecycle and stability of CDS and ABAP RESTful application programming model artifacts as well as if and how these can be changed within an upgrade or hot fix. Stability contracts provide security for developers and consumers of these artifacts. A defined lifecycle controls the release of these artifacts as well as their deprecation and replacing successors.

Chapter 15 provides an overview of the possibilities for modification-free enhancements by customers and partners. In SAP S/4HANA Cloud, public edition, special tailored apps support an experienced user with special authorizations— the key user—in performing necessary enhancements. These enhancements must be kept stable from a lifecycle perspective to ensure smooth software. This requires special preparations during application development and adherence to stability contracts. Further developer extensibility is explained by using CDS view extensions.

Chapter 16 introduces the creation of automated tests for your CDS models as well as the transactional runtime and its implementations. The test double framework presented here allows you to exchange the data sources of CDS views as well as certain parts of the behavior implementation and thus to decouple the test execution from the actual persistent data or productive application logic. We explain test automation with the test double frameworks using examples.

In Chapter 17, we recommend practical ways for troubleshooting to find and correct errors and problems in the context of CDS and the ABAP RESTful application programming model. We describe the tools relevant for troubleshooting and explain how to use them. In addition, we illustrate some pitfalls that you may come across when developing your CDS models.

An overview of the CDS annotations presented in this book is included in Appendix A as a quick reference. For an overview of all available CDS annotations, refer to the SAP documentation.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.