Search for existing CDS views

Stijn MertensStijn Mertens
3 min read

This blog was first published at Expertum.net.

Introduction

Thanks to SAP HANA new powerful tools became available for developers to retrieve data from the database: ABAP CDS. With the advent of S4/HANA, even more CDS views are now available as standard SAP objects.

For developers, these CDS views are an important resource:

  • A lot of these standard CDS views are exposed via OData services and available for lookup via the SAP API Business Hub. This makes them a great resource for Front-end (UI5/Fiori) developers.
  • ABAP developers can re-use the existing CDS logic in a powerful and modular way. Finding the right CDS view can be dead easy or a challenge...

CDS View Types

In S/4HANA the VDM (virtual data model) forms the basis for data access and consists of CDS views. These views follow consistent modeling and naming rules, for example you'll recognize following prefixes during your search:

PrefixView Type
I_Basic interface view
I_Composite interface view
C_Consumption view
R_Basic restricted reuse views
R_Composite restricted reuse views
P_Private view
A_Remote API view
X_View extend
E_Extension include view
F_Derivation function
D_Abstract entity

SAP API Business Hub

You're first resource should be the SAP API Business Hub, which can be used to find CDS views:

Use the API Business Hub menu: Explore > CDS Views

The only thing you need is a good search term. For example when looking for (product) characteristics:

CDS View search results for Characteristic in the SAP API Business Hub

The result of the search will be a number of available CDS views. When clicking on a tile, more details are displayed:

The CDS view details for Characteristic Category

  • ID: The name of the development object. Notice that the prefix is I_, meaning that is an interface view.
  • Supported Capabilities: These are the uses SAP supports for this view.
  • Fields: The fields the CDS view returns.

Remark: all CDS views found on the SAP API Business Hub are all listed in the S/4HANA Cloud solutions only. At this point in time, it is not clear if the usage is also supported on S/4 HANA on-premise systems. But when searching for some samples on an on-premise S/4 system, they will exists depending on the installed product:

Found CDS view `I_Inspspeccharccategory` on an on-premise S/4 HANA system

Transaction SDDLAR

If you can't find what your looking for on the SAP API Business Hub, these is a final option: transaction SDDLAR. This transaction allows you to search in the DDL (Data Definition Language) of the CDS views:

Transaction SDDLAR, select the option Display DDL Source

After pressing Analyse, following input form is shown:

Search input SDDLAR on DLL-Source *PROD* and Regular Expression IBINVALUES

Warning: the search may take a while, depending on the performance of the system and your search terms. If all goes well, you'll end up with a list of DDL sources that have the given pattern in their definition.

The output contains:

  • The SAP object definition in the Dictionary, together with the complete CDS view DDL:

ABAP Dictionary object with a part of the DDL for the CDS view

  • And at the bottom of each DDL source, the ABAP Catalog View Name and in what other DDL sources this CDS view is used:

ABAP Catalog View Name and the Where-Used DDL sources

Summary

In search for the correct CDS view, always start on the SAP API Business Hub. These are publicly shared and supported by SAP. When building a future/upgrade prove solution, this should be your starting point.

If that is not enough, it can be useful to dive deeper in the system by searching for a CDS view with transaction SDDLAR. But be warned:

  • Don't get lost in the CDS view spaghetti.
  • There is no guarantee at future upgrades.
  • Sometimes the search will feel like looking for a needle in a haystack.
0
Subscribe to my newsletter

Read articles from Stijn Mertens directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Stijn Mertens
Stijn Mertens