SAP demos and examples are a great orientation for how SAP is doing things. But it is not as easy as one thinks to find meaningful SAP ABAP CDS view demos or examples in an ECC or S/4 HANA system.
These are 3 ways to find SAP ABAP CDS views implemented by SAP to orient towards them.
1. SAP ABAP CDS Views Demo Package in ECC and S/4 HANA System
There is a SAP ABAP CDS views demo package full of demo files. It is called SABAPDEMOS and you can find it either in the transaction SE80 or in Eclipse. It is available in every system with at least ABAP 7.40 SP05.
Depending on your ABAP version there might be more or less demo files in the SABAPDEMOS package because SAP continuously added new files to this package. Almost whenever the ABAP stack was updated and new features were released for ABAP CDS views then the package grew.
In Eclipse open the ABAP Development Object Dialog by pressing CTRL + SHIFT + A or through the menu: Navigate > Open ABAP Development Object. Once the dialog is open enter in the search field SAPABAPDEMOS. Now you should see the SABAPDEMOS package.
But be careful about the naming conventions of these files. Actually, they do not meet the naming conventions of SAP for CDS views like starting basic and composite views with an I_, and consumption view with a C_. Who knows why.
However, depending on your ABAP version you might find those files:
- ABAP CDS views with different types of joins, union, and associations
- ABAP CDS view with currency and unit conversion
- ABAP CDS views with parameters
- ABAP CDS views with SQL functions
- ABAP CDS views with different annotations
- ABAP CDS views with extensions
- ABAP CDS views with table functions
- ABAP CDS views with authorization checks
- Table functions
- Access Controls (Authorization checks)
2. Fiori Standard Application OData Services in S/4 HANA System
In an S/4 HANA system are pre-installed SAP Fiori standard applications and their OData services. CDS views generate those OData services. Therefore, these CDS views exist somewhere in the S/4 HANA system.
Here is how you find them:
- Go to the SAP Fiori Apps Library.
- Navigate in the left menu: All apps for SAP S/4HANA > All apps for SAP S/4HANA.
- Select one of the applications in the list on the left – for example, the application Cash Flow Analyzer.
- On the detail view of the application, select IMPLEMENTATION INFORMATIONS in the tab bar.
- Expand the Configuration item.
- Get the name of the OData service under OData Service(s). For example, the OData service of the application Change Process Analysis for Business Partner is called MDC_PROC_BP_ALP_SRV.
- Copy the name of the OData service without the _SRV at the end. For example, from MDC_PROC_BP_ALP_SRV copy just MDC_PROC_BP_ALP.
- Go to the transaction SEGW in your S/4 HANA system.
- Click on Open Project.
- Paste the OData service name without the _SRV of the Fiori standard application.
- Select the project and open it.
- Open the project in the SEGW navigator on the left.
- Open in the project the folders Data Model > Data Source References > CDS-Entity Exposures > Entity Types.
- Here you see the names of the ABAP CDS views associated with this OData service. For example, an entity of the OData service MDC_PROC_BP_ALP of the application Change Process Analysis for Business Partner is C_MDBusPartChangeProcessType.
- Copy an entity, and therefore ABAP CDS view name and go to Eclipse.
- Press CTRL + SHIFT + A or go to Navigate > Open ABAP Development Object… in the top menu of Eclipse.
- Paste the ABAP CDS view name into the input field of the Open ABAP Development Object dialog. For example, C_MDBusPartChangeProcessType.
- Open the CDS view.
3. Eclipse ABAP Development Object Type Search
In Eclipse it is possible to search for specific ABAP object types. Therefore, it is possible to search just for CDS Views.
- Open Eclipse.
- Press CTRL + SHIFT + A or navigate in the top menu to Navigate > Open ABAP Development Object…
- Enter in the Open ABAP Development Object input field any string and type:ddls. For example, I* type:ddls. Use type:dcls for access controls.
- Now you see all ABAP CDS views which names are starting with an I in the result list. The * is a wild card in the search.
- Go through the result list and open an ABAP CDS views which sounds interesting.
- Tip: SAP does not continuously stick to it, but the naming conventions for ABAP CDS views are that BASIC and COMPOSITE views start with an I_ and that CONSUMPTION views start with a C_. Therefore, a search for I_* type:ddls results in a search for basic and composite views and a search for C_* type:ddls results in a search for consumption views.