OPEN SQL Statement To Access The CDS View
OPEN SQL Statement To Access The CDS View
OPEN SQL Statement To Access The CDS View
************************************************
* CDS View in ABAP ALV Report *
************************************************
DATA: lo_alv TYPE REF TO if_salv_gui_table_ida.
cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = 'ZV_DEMO_01' "Name of CDS View name
RECEIVING
ro_alv_gui_table_ida = lo_alv
).
* CATCH cx_salv_db_connection. "
* CATCH cx_salv_db_table_not_supported. "
* CATCH cx_salv_ida_contract_violation. "
* Display ALV
lo_alv->FULLSCREEN( )->display( )
5. Lets look at the code, we have used CDS view name created in our previous
tutorial to the ALV with IDA class CL_SALV_GUI_TABLE_IDA as a data source to the
ALV. Save and activate the ABAP program.
CDS View Association is nothing but, establishing the relationship between these 2 CDS
views on a common field/expression to get the order header and its line item information.
max cannot be 0.
An asterisk * for max means any number of rows.
min can be omitted (set to 0 if omitted).
min cannot be *.
When an association is used in a WHERE condition, 1 must be specified
for max.
on $projection.vbeln = _OrderItems.vbeln
{ ..... }
Association as join type
The association defined in an ABAP CDS view will be converted to join type at run-
time. By default the join type is LEFT OUTER JOIN.
The below CDS view will result in LEFT OUTER JOIN when executed.
o achieve INNER JOIN, you need to define the attribute in the path expression like
below.
@AbapCatalog.sqlViewName: 'ZV_ORD_HDR'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
on $projection.vbeln = _OrderItems.vbeln
key vbeln,
erdat,
vbtyp,
auart,
netwr,
waerk,
_OrderItems[inner].matnr
CL_SALV_GUI_TABLE_IDA
CREATE Static Method Public Create ALV with integrated data access (IDA)
CREATE_FOR_CDS_VIEW Static Method Public Create 'ALV with IDA' for Core Data
Services(CDS)
We can access the CDS view which has associations defined in ABAP program using
Open SQL statement using the path expressions like below
DATA(is_supported) = cl_abap_dbfeatures=>use_features(
requested_features = VALUE
#( ( cl_abap_dbfeatures=>views_with_parameters ) ) ).
IF is_supported IS NOT INITIAL.
SELECT *
FROM zcds_salesorder_hdr
INTO TABLE @DATA(lt_data).
ENDIF.
CDS Annotations
The following list summarizes all SAP annotations of the Data Definition Language (DDL) of ABAP
CDS. SAP CDS annotations are evaluated by SAP frameworks and can be either ABAP annotations
or framework-specific annotations.
AbapCatalog Annotations
AccessControl Annotations
ClientDependent Annotations
DataAging Annotations
EndUserText Annotations
Environment Annotations
MappingRole Annotations
Metadata Annotations
Semantics Annotations
Framework-Specific Annotations
CDS annotations that (as a rule) are evaluated during runtime by specific frameworks such
as SADL, BOPF, Analytics, or Enterprise Search:
Analytics Annotations
AnalyticsDetails Annotations
Consumption Annotations
DefaultAggregation Annotations
EnterpriseSearch Annotations
Hierarchy Annotations
ObjectModel Annotations
OData Annotations
Search Annotations
Semantics Annotations
UI Annotations
VDM Annotations