cancel
Showing results for 
Search instead for 
Did you mean: 

How to build OData Navigation from CDS Associations ?

Attila
Active Participant
0 Kudos

Dear Community Member,

I'm interested in a documentation, where building the navigation in SEGW between OData entities is based on CDS Entity associations using SADL is described.

We're on level 740 sp9.

I've defined tree very basic CDS views views to test the capabilities of the system, before starting implementation of a productive application.The main entity is Person, and are associated with dependent entities Phone and Address


@AbapCatalog.sqlViewName: 'ZCDS_PERSON'

@EndUserText.label: 'Persons'

define view Zperson as select from zbc_person as person

association [1..*] to Zaddress as address

on address.person_id = $projection.id

association [1..*] to Zphone as phone

on phone.person_id = $projection.id

{

    key person.id as id,

    person.name_first,

    person.name_last,

    person.name_nick

}


@AbapCatalog.sqlViewName: 'ZCDS_PHONE'

@EndUserText.label: 'Phone Number'

define view Zphone as select from zbc_phone as phone {

    key phone.person_id,

    key phone.type,

    phone.tel_number,

    phone.tel_extens,

    phone.fax_number,

    phone.fax_extens,

    phone.skype_id

}


@AbapCatalog.sqlViewName: 'ZCDS_ADDRESS'

@EndUserText.label: 'Address'

define view Zaddress as select from zbc_address as address {

    key address.person_id,

    key address.type,

    address.country,

    address.city1,

    address.street,

    address.house_num1,

    address.floor,

    address.roomnumber          

}

I created the OData entities and did the mapping successfully importing the CDS Views.

Unfortuanetly I cannot see the association defined in the CDS view to add as navigation in the OData Property - Business Entity mapping editor.

Assumed it should be listed in the right pane displaying my CDS entity ZPERSON.

Maybe the definition of the CDS views are not fine, or there is no support for this in SEGW transaction ?
There are demo examples in the system, where the business entities are implemented with classes implementing interfaces, which realize associations, and can be dragged and dropped as navigation from right pane to the middle pane.

I can define the association and navigation manually of course, but I want to let the system to do it. This is why I need help on this.

Thank you in advance

Accepted Solutions (1)

Accepted Solutions (1)

Marcel_Hermanns
Advisor
Advisor
0 Kudos

Hi Attila,

looks very good, just a little piece is missing, which also happend to me already several times:

Please add the declared definition to the projection list like the other attributes, so that is available outside of the CDS View. Then you will be able to see it in the SADL Mapping Editor in the SEGW.

  1. @AbapCatalog.sqlViewName: 'ZCDS_PERSON' 
  2. @EndUserText.label: 'Persons' 
  3. define view Zperson as select from zbc_person as person 
  4. association [1..*] to Zaddress as address 
  5. on address.person_id = $projection.id 
  6. association [1..*] to Zphone as phone 
  7. on phone.person_id = $projection.id 
  8.     key person.id as id, 
  9.     person.name_first, 
  10.     person.name_last, 
  11.     person.name_nick ,
  12.     address,
  13.     phone

Best regards,

Marcel

Attila
Active Participant
0 Kudos

Thank you very much Marcel for the practical solution! Working as expected.

Attila

0 Kudos

marcel.hermanns, attila.berencsi

Can you please show us a photo of your segw project?

  • Have you created an association of person to adress by hand?

This is my project and the error that I am facing right now:

  • Without an association / navigation created by me.

  • With an association/navigation created by me.

This is my CDS:

I am currently at SAP 7.4 SP12

Thanks in advance.

Attila
Active Participant
0 Kudos

Hello Pablo,

I cannot help you out in this unfortunately. I do not have access to that system anymore, sorry.

BR,Attila

Answers (0)