cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP in SCP, Custom Entity (CDS views)

Sapcoder
Explorer

I've followed the excellent blog from Andre Fischer (https://blogs.sap.com/2019/03/01/how-to-implement-a-custom-entity-in-the-abap-restful-programming-mo.../) and want to know if it is possible to have associations with a Custom Entity CDS view?

I want to have a root custom entity that is tied to another view in an association. Is this possible? I couldn't find where this was documented and all attempts to get it to work lead to a syntax error.

This needs to be an unmanaged query since I am calling BAPI's in S/4HANA.

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Sarah,

yes it is possible.

However the association has to be defined within the select list.

Unfortunately I have not been able to update my blog post with simple example yet.

But here is a code snippet that might be helpful.

define root custom entity SADL_SO_CUSTOM_ENTITY 
{
  key id : abap.char(20);
  seller_id : abap.char(20);
  buyer_id : abap.char(20);
  act_indicator : abap.char( 1 );
  type_code : abap.char( 5 );
  _type_code_texts : association [0..*] to Sadl_V_Rs_Type_Code_Text 
  on _type_code_texts.TypeCode = SADL_SO_CUSTOM_ENTITY.type_code;
}

The syntax is also described in the online help

https://help.sap.com/viewer/c0d02c4330c34b3abca88bdd57eaccfc/Cloud/en-US/e4fcfd77dcec48fbb361d7193f6... --> Unmanaged Query.

but without an example.

Hope this helps.

Best Regards,

Andre

											
Sapcoder
Explorer
0 Kudos

Fantastic!! This is exactly what I need. Thank you Andre!

amarnath_n2
Explorer
0 Kudos

Hi Andre,

Is it possible to get both entity (SADL_SO_CUSTOM_ENTITY ) and association entity details ( here sadl_v_rs_type_code_text ) using the association name ( _type_code_texts ) in a single call ? do we have to use $expand here

Thanks and Regards,

Amarnath.

srijayant
Explorer

Is it possible to go other way around,

Associate a custom entity to a DDL CDS view

Hello andre.fischer thanks for the example. If the association requires a parameter how is it possible to pass the value in this case in a custom entity?

roman_g1
Explorer

Is it possible make other way association.?
In abap cds i want add association to Custom Entity, and use fields from Custom Entity in CDS View

dirk_roeckmann
Participant
0 Kudos

Hello andre.fischer ,

it is great, that it is possible to have associations between custom entities, but this approach apparently fails when combining it with unmanaged behavior definitions which need composition trees, right?

The following blogs with identical problems

https://answers.sap.com/questions/13533252/custom-entity-association-and-their-behavior-defin.html

and

https://answers.sap.com/questions/13286489/abap-in-btp-custom-entity-association-composition.html

remain unanswered.

We have the same problem: Trying to combine associated custom entities with composition and parent associations. Is this possible at all and if yes could you please elaborate a little and tell us the release in which this works.

Thank you so much

JannisBer
Discoverer

Hi Andre,

thanks for providing the code snippet.

Unfortunately, we are now facing the problem of using the association.
We want to use the association to show a text instead of the value.

We tried several annotations such as:
@ObjectModel.text: { element: ['<association>.text'] }

@ObjectModel.text.association:

Especially the latter caused the app to crash.

Do you have any further suggestions we could try?

Best Regards,
Jannis

jheisler
Explorer
0 Kudos

jannisber did you find a solution for this? I have the same situation that i want to add a text for a field which is part of a custom entity. Both annotations you mentioned dont work for me as well.

Answers (0)