SAPFree generatorPDF, Excel, Word exportSAP S/4HANA

ABAP CDS View Skeleton Generator

Core Data Services views are the standard way to model data in S/4HANA, for reporting, for Fiori apps and for RAP business objects. This generator writes the DDL for a basic view with key, aliases, a currency amount and one association, in both classic and view entity syntax.

Fill in

Up to 16 characters, must differ from the CDS name.

Generated code
Download:

1. Classic CDS view (DDIC-based, ABAP 7.40 SP05 and later)

@AbapCatalog.sqlViewName: 'ZISALESORDER'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales order header'
define view ZI_SalesOrder
  as select from vbak
  association [0..*] to vbap as _Item
    on $projection.SalesOrder = _Item.vbeln
{
  key vbeln      as SalesOrder,
      erdat     as CreationDate,
      kunnr  as SoldToParty,

      @Semantics.currencyCode: true
      waerk as TransactionCurrency,

      @Semantics.amount.currencyCode: 'TransactionCurrency'
      netwr   as NetAmount,

      _Item
}

2. CDS view entity (S/4HANA 2020 / ABAP 7.55 and later, recommended for new views)

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales order header'
define view entity ZI_SalesOrder
  as select from vbak
  association [0..*] to vbap as _Item
    on $projection.SalesOrder = _Item.vbeln
{
  key vbeln      as SalesOrder,
      erdat     as CreationDate,
      kunnr  as SoldToParty,

      @Semantics.currencyCode: true
      waerk as TransactionCurrency,

      @Semantics.amount.currencyCode: 'TransactionCurrency'
      netwr   as NetAmount,

      _Item
}

3. Reading the view in ABAP

SELECT SalesOrder, CreationDate, SoldToParty, NetAmount, TransactionCurrency
  FROM ZI_SalesOrder
  WHERE SoldToParty = @lv_partner
  INTO TABLE @DATA(lt_result).

Check which syntax your release supports before activating: view entities arrived with ABAP 7.55 (on premise S/4HANA 2021 and cloud earlier), and classic DDIC-based views remain valid on older releases. Amounts need a currency reference, quantities need a unit reference with Semantics.quantity.unitOfMeasure. Add an access control (DCL) object when authorizationCheck is set to CHECK, otherwise users may see nothing or everything depending on release.

Plan your CDS data layer

Optional: talk to us about exposing governed CDS views to an on-prem AI assistant.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter the CDS name, the source table, a key field and a few more fields with their CamelCase aliases, then name the association target and the join field. The first block uses the classic syntax with an SQL view name, valid on ABAP 7.40 SP05 and up. The second block uses define view entity, which does not generate a separate DDIC view, and is recommended for new development where available. The third block shows how to read the view with Open SQL.

Annotations that matter

AccessControl.authorizationCheck decides whether a DCL access control is evaluated, and CHECK is the secure default. EndUserText.label gives the description shown in tools. Semantics.currencyCode and Semantics.amount.currencyCode link an amount to its currency so that UIs format values correctly, and quantities use the equivalent unit annotations. In the classic syntax, AbapCatalog.sqlViewName creates the DDIC view, with a name of up to 16 characters that must not clash with the CDS name.

Associations versus joins

An association declares a relationship without executing the join. The join happens only when a consumer navigates it, for example in a path expression such as _Item.material, or an OData client expands it. Exposing the association name in the select list makes it available to consumers. Use a join in the view when every consumer needs the data every time, and an association when the relation is optional. Cardinality in brackets helps the optimiser and documents the model.

Common mistakes

Frequent errors include missing currency references on amount fields, skipping the access control so authorization is bypassed or blocks all users, an SQL view name above 16 characters, ambiguous aliases, and building one huge view instead of layered basic, composite and consumption views. Also keep in mind that CDS field names are case-insensitive in the database but are used in CamelCase in UI and OData models.

Frequently Asked Questions

What is the difference between a CDS view and a CDS view entity?

A classic CDS view generates a DDIC SQL view in addition to the CDS entity, so it needs an SQL view name. A view entity is defined without that extra object, which simplifies transport and activation. View entities are the recommended choice where the release supports them.

Do I need a DCL access control?

If you set authorizationCheck to CHECK, you should create an access control object for the view, otherwise users may not see data or checks may be missing. Use NOT_REQUIRED only for views that do not expose sensitive data.

Why must amounts have a currency reference?

An amount without a currency cannot be formatted or converted correctly by consumers such as analytical and Fiori apps. The annotation links the amount column to the currency column, and the activation check will usually report an error if it is missing.

Can I use CDS on ECC?

Classic ABAP CDS views are available from NetWeaver 7.40 SP05, and the capabilities increase with later support packages. View entities and many annotations need newer ABAP releases. Check your system level before using a feature.

If your reports depend on stacks of custom CDS and ABAP, we can discuss how a read-only AI layer could use them as governed data sources.