cancel
Showing results for 
Search instead for 
Did you mean: 

Association/Navigation without key properties

wouter_peeters
Participant
0 Kudos

Hi Experts,

I'm trying to make an association/navigation to another Entity, but this for a property without being marked as a key.

Example the EPM test service from http://scn.sap.com/docs/DOC-31221

The model: http://scn.sap.com/servlet/JiveServlet/showImage/102-44073-2-246387/Relationen.png

I already builded the SalesOrder association/navigation to the SalesOrderItem.

But I cannot seem to create the association/navigation from SalesOrderItem to the Product, in SEGW I always have to define the referential constraint with the key of the Entity. In SalesOrderItem, the productId property is not a key, and I can't imagine that I have to set it as a key.

Thanks in advance

Regards,

Wouter

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Wouter,

Are you familiar with key relationships in database terms? This is no different to that.

Only one side of this relationship needs to refer to an entity key and that is the Product side. On the other side, the key of this product is referenced by another entity, the SalesOrderItem; that side does not have to be a key value in the context of that entity (although it could be, that tends to be the case more when the target has a composite key).

There should be no problem in making this relationship.

Regards

Ron.

wouter_peeters
Participant
0 Kudos

Hello Ron,

I succeed in making the relationship between SalesOrder and SalesOrderItem, but making the navigation/association between SalesOrderItem and Product is not working, please provide information how to do so if you know.

I used the ES1 demo service data model (but in ES1 SAP system it's not implemented in SEGW )

https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV/?sap-ds-debug=true

I imported this into my Eclipse GPA, exported it and imported it in SEGW.

After implementing the read and query operations the navigation from SalesOrder to SalesOrderItem worked, but the Product did not.

I suspect that this navigation needs some extra coding. If not please provide details how to do the mapping.

Greets,

Wouter

Former Member
0 Kudos

Hi Wouter,

You need some extra coding in the Product 'get entity set' method. To determine if this is a direct collection reference or a navigation to a collection, you can check if the navigation path table parameter has an entry in it - if it does, you need to find which navigation (there could be more than one to pick from, as a caller-client) is being requested.

You can find the context for 'navigating from' in the key table parameter, i.e. that should contain the key of the sales order item.

e.g. (not necessarily correct for ES1 in terms of names)

   lt_nav_path = io_tech_request_context->get_navigation_path( ).

   read table lt_nav_path into ls_nav_path with key nav_prop = SalesOrderItems'.

   if sy-subrc = 0.

     lt_key = io_tech_request_context->get_source_keys( )..

     read table lt_key with key name = 'SoID' into ls_key.

     lv_orderid = ls_key-value.

" ditto for position key.....

   endif.


You can then use these two pieces of information to locate the product of the item.

Regards

Ron.

wouter_peeters
Participant
0 Kudos

Thanks Ron!

Abhijit
Explorer
0 Kudos

Hi Wouter,

I am facing simillar issue.. While modelling the association, it does not allow to create association between 'non key' or between 'key - non key' entities..

Were you able to solve this issue? Or just created navigation..

Regards,

Abhijit

wouter_peeters
Participant
0 Kudos

You create the navigation but without referential constraints.

When you implement the read_entity, you will see in the debugger that you have the keys available in the key table, and then it's your responsibility to code and retrieve the non-key relevant to those keys.

And then just fill up the entity structure ... the downside is that you have to code everything manual ...

So if you're designing everything with function module calls ( and mapping ), this is a small downside.

Regards,

Wouter

0 Kudos

Hello Ron,

I also have a simlar scenarion wherein I want to Navigate from Sales Order to Customer1 then to Customer

i.e 2 levels of navigation.

I assume that the above solution for implementation of Get_entity_set would work.

What would be the URI in this case?

Thanks in Advance,

Aarti

Former Member
0 Kudos

Hi,

I would like to know what is the type of data of lt_key ?

Thanks in advance,

Maxence Arnoult

Answers (1)

Answers (1)

wouter_peeters
Participant
0 Kudos

On a sidenote, i've also created the Entity Data Model in Eclipse with all associations and navigations (by importing SAP's ES1 test service for this), imported this in SAP SEGW, implemented the read and queries.

But when I try the product navigation, it goes into error with a "Internal error occurred, contact your system administrator." - /IWBEP/CX_MGW_TECH_EXCEPTION.