CDS-View als DDIC Objekt erstellen
@AbapCatalog.sqlViewName: 'ZCDS_MATNR_VIEW'
@AbapCatalog.compiler.CompareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'MATNR lesen'
@Metadata.allowExtensions: true
define view ZCDS_MATNR
with parameters p_min_date : dats,
p_max_date : dats
as select from mara as ma
inner join makt as kt on ma.matnr = kt.matnr
{
key ma.matnr as matnr,
ma.ernam as ersteller,
ma.vpsta as pflegestatus,
case ma.lvorm
when 'X' then 'gelöscht'
else 'aktiv'
end as loeschvormerkung,
kt.maktx as kurztext
} where ma.ernam like 'A%' and ma.ersda between :p_min_date and :p_max_date;
ABAP-Quellcode zum Auslesen des CDS-Views
DATA: it_matnr TYPE STANDARD TABLE OF zcds_matnr.
SELECT * FROM zcds_matnr( p_min_date = '20170101', p_max_date = '20171231' ) INTO TABLE @it_matnr.
LOOP AT it_matnr ASSIGNING FIELD-SYMBOL(<mat>).
WRITE: / <mat>-matnr, <mat>-ersteller, <mat>-pflegestatus, <mat>-loeschvormerkung, <mat>-kurztext.
ENDLOOP.