Monday, February 15, 2021

SAP CDS Views: Publishing an oData Service from a CDS View and Testing it (10 Simple Steps)

 In this post I am going to use the example from my previous post and publish it as an oData service in ten simple steps:

1. In the annotation part of the DDL, declare the publisher as 'true'



2. Make sure that the CDS View has at least one key field


3. Go to transaction SEGW and create a new project


4. Import the Structure of the CDS View to the new project


5. Map to the Data Source
6. Generate Mapping & Activate


7. Go to the Transaction /IWFND/MAINT_SERVICE 'Activate and Maintain Services' -> Add Service




Here select the System Alias and search for the Service with the name of the oData project

8. Load the Metadata and go to the Test Client





9. Coose an Entity Set you want to test.
In our example we have only one entity set.

10. Test your service













Wednesday, February 10, 2021

SAP CDS Views: Creating a CDS View with an Authorization Check

In this post I am going to demonstrate the creation of a CDS view with an authorization check. Implementing  authorization checks hand in hand with the CDS view is a great way to achieve even more code pushdown.

The example in this post is from the RE-FX module but it can be applied in every module.

I am going to redesign a common report in the real estate, for example the occupation and pull some contract and partner data.

The Data Definition Language (DDL) part looks like this:



In the annotation part it is very important to activate the authorization check.

The authorization check will be executed for the company code (BUKRS).

For this purpose we need to define an access control, the so called Data Control Language (DCL) part.


Usually, we want to integrate the standard SAP authorization checks as they are defined in PFCG.
For the company code we would refer to the dedicated authorization object F_BKPF_BUK.

The DCL grants access to the previously defined DDL zlo_demo. 

The user can see only the company codes for which they are authorized through the authorization object F_BKPF_BUK.