Skip to Content
0

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

Feb 20, 2017 at 12:08 PM

189

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Florian Pfeffer
Feb 20, 2017 at 12:31 PM
0

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

Show 8 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0

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.

0
Former Member
Florian Pfeffer

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

0

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

0
Former Member
Florian Pfeffer

Hi Florian ,

Thank you for your help .

Thanks,

Sumit

0

@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.

0

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).

0

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=008e171389d5d4e1e9b3a44918b882a7a&authkey=AajhFcCYZUQhihlIhqpjhd4&expiration=2017-09-07T14%3a07%3a45.000Z


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.

0