Anlegen des CDS-Views in Eclipse (ab ABAP 7.4 SP8)
* Menü -> File -> New -> Other -> Core Data Services -> Data Definition
* 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 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
};
ABAP-Quellcode zum Auslesen des CDS-Views
* Variante 1 (SELECT)
DATA: it_matnr TYPE STANDARD TABLE OF zcds_matnr.
SELECT * FROM zcds_matnr INTO TABLE @it_matnr.
LOOP AT it_matnr ASSIGNING FIELD-SYMBOL(<mat>).
WRITE: / <mat>-matnr, <mat>-ersteller, <mat>-pflegestatus, <mat>-loeschvormerkung, <mat>-kurztext.
ENDLOOP.
* Variante 2 (SALV TABLE IDA)
TRY.
cl_salv_gui_table_ida=>create_for_cds_view( CONV #( 'ZCDS_MATNR' ) )->fullscreen( )->display( ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.
Links