Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Two questions about CDS Views

0 Kudos
686

Hi Everyone,

I've two questions about CDS Views:

1.) How can I consume cds view, in particular cds views with associations in opensql?

At the abap documentation I found CDS explicit syntax only for passing parameters, but nothing for projection:


... *

  | {data_source1~*, data_source2~*, ...}

  | {col_spec1 [AS a1], col_spec2 [AS a2], ...}

  | (column_syntax) ...



2. Is there a comprehensive cds view syntax documentation availabe? I found this "By Example" Document CDS View Syntax Options - SAP HANA Developer Guide for SAP HANA Studio - SAP Library but I'm looking for something more like a railroad syntax. With the "By Example" style it's hard to see no subselects are supported...

Thanks and Regards,

Franz

4 REPLIES 4

0 Kudos
338

Ok. Got 2.) By Pressing F1 - sometimes it's really simpler as expected. But 1.) is still open.

0 Kudos
338

CDS views can be consumed like any other table view.

you need to write select query on the view.

Like,

select field1

from ZCDS_V

where field2 = 'ABC'.

0 Kudos
338

Thanks. But how can I access associations for a CDS View like:

from aaa association [1..1] to bbb on ....

Is it possible to have the association at the projection somehow?

Regards,

Franz

0 Kudos
338

Hi Franz,

In the Open SQL, the associations have to be prefixed with a backslash '\' in order to distinguish them from usual columns.

For example:

Association in the select-list:

SELECT    salesorderuuid,   

          \_PaymentTerms-SalesOrderPaymentTerms as terms

  FROM sepm_i_salesorder into table @data(tab1)     .

or in the from clause:

SELECT    SalesOrderItemUUID

  FROM sepm_i_salesorder\_item into table @data(tab2) .

Note: Filter expressions are not yet available in the Open SQL.

For obvious reason we could not use the dot as a seperator in the path expressions in the ABAP. Associations are always prefixed with a backslash, columns are prefixed in path expressions with the ABAP Open SQL with a dash '-', the standard component selector.

best regards Andreas