cancel
Showing results for 
Search instead for 
Did you mean: 

CDS View isssue (Publishing associations in a view is not supported in XS Classic)

former_member250641
Participant
0 Kudos

Hi ,

during creation of view I got bellow message Publishing associations in a view is not supported in XS Classic please see the dummy code .

namespace demo.first;

@Schema: 'DEMO'

context test {

@Catalog.tableType : #COLUMN

entity A {

a : Integer;

b : String(32);

};

@Catalog.tableType : #COLUMN

entity X

{ x : Integer;

y : Association to test.A{b} not null;

};

View XView as select from X

{

x as vx,

y as vy

};

};

When I try to activate the file showing me

(Publishing associations in a view is not supported in XS Classic)

Please help me to resolve this issue .

Thanks,

Sumit

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

As the message says, you try to publish the association (y) define in entity X via your view. This is not supported. You have to publish elements of the association in the view. For instance if you publish x and y, you have to define it:

  View XView as select from X {
    x as vx,
    y.a as vy_a,
    y.b as vy_b
  };

Regards,
Florian

former_member250641
Participant
0 Kudos

Hi Florian ,

Thanks for your reply ,

Its working but the issue is I have some many other entity that are associate to each other like an example.

namespace demo.first;

@Schema: 'DEMO'

context test {

@Catalog.tableType : #COLUMN

entity A {

a : Integer; // Its Id for the A table

b : String(32);

};

entity B {

a : Integer; // its like Id for the B table

d : String(32);

};

@Catalog.tableType : #COLUMN

entity X

{ x : Integer;

y : Association to test.A{a} not null;

z: Association to test.B{a} not null

};

View XView as select from X

{

x as vx,

y.a as vy_a

z.a as vz_a

};

};

Showing me that Identifier "a" has already been defined.

So I am giving you for like 3 entity but I have more than 30 that are related/associated to each other .

Please help me

Thanks,

Sumit

pfefferf
Active Contributor
0 Kudos

The only way to use it in a classic CDS view is to use alias names for all the fields with similar names you require.

former_member250641
Participant
0 Kudos

Hi Florian ,

Thanks for your reply .

But I have little confusion here how system will know which id we are referring example

In the previous entity class A and B contain "a" column with similar name so when we refer that column with

"y.a" so here which "a" is calling // entity A or entity B how system will know ??

View XView as select from X

{

x as vx,

y.a as vy_a

z.a as vz_a

};

Thanks,

Sumit

pfefferf
Active Contributor
0 Kudos

As your association y refers to entity A, it is the a column of entity A.

former_member250641
Participant
0 Kudos

Hi Florian ,

Thank you for your help .

Thanks,

Sumit

RobinReeb
Advisor
Advisor
0 Kudos

@florian:


had the same issue and solved it the same way, however when trying to grant SELECT,UPDATE,INSERT & DELETE on that view I had a horrible awakening.

Somehow, exposing the association the way you described in my view, it declared it as read-only.

error message upon saving the according .hdbrole: ...data manipulation operation not legal on this view: cannot grant delete on read-only view...

I can only use views instead of direct db tables, because I am bound to xsodata and need to do authorization related filtering on the data based on the logged-on user, but the xsodata exits only work with CREATE, UPDATE, DELETE.

See https://blogs.sap.com/2016/01/14/odata-read-exits-an-ingenious-solution/ for reference.


Any tips? Upgrading to XSA is no option right now.

pfefferf
Active Contributor
0 Kudos

Don't get your issue. Views are by default read-only.

I also do not understand why you can only use views because of xsodata usage. You can also use tables etc.

And you can use odata write exits also for views. Of course you cannot implement a write logic on the view, but on the underlying tables (or other tables).

RobinReeb
Advisor
Advisor
0 Kudos

Mhhm weird. Maybe we have a misunderstanding here.
Our reference architecture looks like this:
https://sap-my.sharepoint.com/personal/robin_reeb_sap_com/_layouts/15/guestaccess.aspx?docid=008e171...


We are using the CDS views in XSODATA not only for Read but for all CRUD operations. This does work just fine as long as the tables that are exposed as views don't consist out of any associations. Then I can use the view for all CRUD operations in my xsodata service.

However as said, as soon as I have to expose associations by exposing the association key part separately, the view is then declared as read-only not allowing me to grant INSERT,UPDATE & DELETE on it in my .hdbrole files.

Answers (0)