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: 
Read only

Cannot access nested CDS view using path expressions

Former Member
0 Likes
1,506

Hi,

I'm trying to leverage the functionality of path expressions in a following scenario:

We have a simple [0..*] association of an entity business transaction header with another entity business partner. The ABAP CDS View for a business transaction could look something like this:


@AbapCatalog.sqlViewName: 'BTRAN'

define view btran_ddl as

     select from crmd_orderadm_h as btrn_header

     association [1..*] to bt_bp as partners on $projection.guid = partners.header_guid

{

     key btrn_header.guid as guid,

     btrn_header.object_id as h_object_id,

     ... // further fields from crmd_orderadm_h

     partners // publishing association for use in other CDS views

}

The target data source BT_BP is another CDS view containing data on business partner. In the last line of SELECT list, the association PARTNERS is stated to be accessible by other CDS views which build on top of BTRAN.

Now let's say I want to create another view CONTRACT. A contract is a special case of a business transaction with a specific transaction type. In this view I'd like to access the association PARTNERS to display information on different business partners:


@AbapCatalog.sqlViewName: 'CONTRACT'

define view contract_ddl as

     select from btran

{

     key btran.guid as guid,

     ... // further fields

     partners.name as partner_name,               // accessing PARTNERS

     partners.function as partner_function        // accessing PARTNERS

}

where btran.object_type = 'BUS2000113'

The syntax check on this view returns the error message: Component PARTNERS does not exist or is not active

Am I missing something?

Thanks,

Marek

1 ACCEPTED SOLUTION
Read only

thomasgauweiler
Employee
Employee
0 Likes
784

Dear Marek,

your second view does a SELECT from BTRAN which is not a CDS view but only a technical vehicel (sqlViewName) which does not have associations.

You should always use the name used by "create view", in your case btran_ddl.

So better change the second view to

define view contract_ddl as 

select from btran_ddl ...

Also when doing a SELECT in ABAP the recommendation is to use the real view name and not the sqlViewName.

Best Regards,

Thomas

2 REPLIES 2
Read only

thomasgauweiler
Employee
Employee
0 Likes
785

Dear Marek,

your second view does a SELECT from BTRAN which is not a CDS view but only a technical vehicel (sqlViewName) which does not have associations.

You should always use the name used by "create view", in your case btran_ddl.

So better change the second view to

define view contract_ddl as 

select from btran_ddl ...

Also when doing a SELECT in ABAP the recommendation is to use the real view name and not the sqlViewName.

Best Regards,

Thomas

Read only

0 Likes
784

Hi Thomas,

thank you, I was really stuck on this . I was not aware of the difference between CDS name and the ABAP dictionary name.

Cheers,

Marek