Skip to main content

CDS authoring

Goal

Author a CDS view (DDL source) and a matching access control (DCL source) from the CLI, activate them, and recover from the most common activation errors.

Prerequisites

Steps

1. Create the DDL shell

adt ddl create ZI_CUSTOMER "Customer CDS view" ZMYPKG -t $TR

The object exists but holds an empty DEFINE VIEW ENTITY.

2. Write the source

cat > zi_customer.ddls.asddls <<'DDL'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Customer'
define view entity ZI_CUSTOMER
as select from zt_customer
{
key customer_id as CustomerId,
name as Name
}
DDL

adt ddl write ZI_CUSTOMER zi_customer.ddls.asddls -t $TR --activate

Expected output:

Wrote DDLS ZI_CUSTOMER (2.1 KB)
Activating ZI_CUSTOMER ... active

3. Add a DCL (access control)

adt dcl create ZI_CUSTOMER "Customer access" ZMYPKG -t $TR

cat > zi_customer.dcls.asdcls <<'DCL'
@EndUserText.label: 'Customer access'
@MappingRole: true
define role ZI_CUSTOMER {
grant select on ZI_CUSTOMER
where (CustomerId) = aspect pfcg_auth(Z_CUSTOMER, CUST_ID, ACTVT = '03');
}
DCL

adt dcl write ZI_CUSTOMER zi_customer.dcls.asdcls -t $TR --activate

4. Preview the data

adt datapreview osql 'SELECT * FROM zi_customer UP TO 10 ROWS'

5. Where-used

adt wb where-used ZI_CUSTOMER # every consumer (BDEFs, other views, ...)

Editing loop

adt ddl read ZI_CUSTOMER > zi_customer.ddls.asddls
$EDITOR zi_customer.ddls.asddls
adt ddl write ZI_CUSTOMER zi_customer.ddls.asddls -t $TR --activate

Troubleshooting

ErrorCauseFix
CDS entity name does not match sourceFirst token after define view entity differs from DDLS object nameKeep them in sync: object ZI_CUSTOMER → source define view entity ZI_CUSTOMER
Unknown column NAME in view ZI_CUSTOMERColumn missing in underlying table/viewAdd the field and activate ZT_CUSTOMER first (see DDIC modeling)
Syntax check failed: CDS_CHECK_063DCL role name must match DDL viewA DCL role that protects ZI_CUSTOMER must be named ZI_CUSTOMER
PFCG_AUTH aspect not known@MappingRole: true missing or authorisation object missingAdd annotation, create auth object in SU21 (not supported via CLI yet)
Long activation (> 30 s)Big projection / missing indexes on source tableConfirm it's a modelling issue, not CLI issue — there's no timeout knob here

See also