cancel
Showing results for 
Search instead for 
Did you mean: 

Key is empty when passing to external association service

0 Kudos

Dear Expert,

I have problem with passing the key to external association service.

For example,

I have 2 service and create external association and navigation properties by following this guide

i have successfully linked services as picture below.

and no error in target service.

When I debug abap code in target system. The parameter it_key_tab should pass key (SalesOrganization , Distribution Channel , Division , ProductID , CustomerNo) from source service but it's always empty. Have I missed something?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Looking at your calling method, you're using a GET_ENTIYSET, as far as I remember, you can't use the keytab in that method, Keytab only works for GET_ENTITY methods, if you want to perform a filtering or pass a value for the service you have to use $filter property in your call.

Cheers.

0 Kudos

Thanks Emmanuel

The problem is solved. I changed association type from 1:1 to 1:N and It's working.

Answers (1)

Answers (1)

NabiZamani
Contributor
0 Kudos

It seems I'm having the same issue. Although the answer of @Emmanuel_Gonzalez might be helpful it is not a solution in all cases. I definitely have a 1:N relation, but it does not work.

I have an old GW Service with an Entity Order and a 1:N relation to the Entity OrderItems. When I call the service with /Orders('1234567890')/OrderItems then IT_FILTER_SELECT_OPTIONS is empty and IT_KEY_TAB has the one key of the dependent entity from the referential constraints. Also, if I create a new service + include the old service there I can still call the same /Orders('1234567890')/OrderItems from the new service which gives me exactly the same result as above (IT_KEY_TAB is filled). Of course in both cases the method ORDERITEMS_GET_ENTITYSET is called. This is exactly what I axpected.

However, when I create a new entity, let's say OrderTwo, and model a 1:N relation to the OrderItems from the included service (of course, I created also the correct referential constraints) + call /OrderTwoSet('1234567890')/OrderItems then IT_FILTER_SELECT_OPTIONS is filled while  IT_KEY_TAB is empty (why that???????):

Consider also the blog of  and there scroll down to the section "Limitations / Gotchas" (by the way - the first part of his blog is also great!).

Is there anyone who can explain this? I'm sure I have modeled the referential constraints correctly in the new service, or is that the limitation which mentioned?

Thanks,

Nabi

ps thi is what we have:

0 Kudos

Hello Nabi Zamani,

After several attempts I found that IT_KEY_TAB will always empty if assign model as 1:N to other service but It will be filled if assign model as 1:1. My solution may not correct but it work for me. I create model as 1:1 and I write a short abap code (In (ENTITY_NAME)_GET_ENTITY) for get key data from IT_KEY_TAB in dependent entity. Then, I create new entity and new association as 1:N (or 1:M) in dependent entity with passed key from IT_KEY_TAB.


Best Regards,


(Principal Entity)

(Dependent Entity)

NabiZamani
Contributor
0 Kudos

Thanks Kritchapon! I'm glad it works for you this way. However, I would prefer something more intuitive for the developer or the person who does the data modelling in SEGW. Although you solution works somehow for you, it's does not make the code more intuitive. I don't like and I don't understand why the ids are not passed for 1:N relations in case you use included entities from and included service. In my opinion it should work just the same way as having a normal 1:N (without included service)...

Best, Nabi

0 Kudos

Hi Nabi,


Have you ever try to call  io_tech_request_context->get_keys( ). or io_tech_request_context->get_source_keys( ) in your code?

Best Regards,

NabiZamani
Contributor
0 Kudos

Hi Kritchapon,

Yes, I did. However, io_tech_request_context->get_source_keys( ) has no entry 😞

By the way, the way I have solved this is by changing the service which I have included in the new service. There I have change the ORDERITEMS_GET_ENTITYSET to  something similar like this:


...

IF it_key_tab[] IS NOT INITIAL.

       READ TABLE it_key_tab ASSIGNING <lfs_key> WITH KEY name = 'Vbeln'.

       lv_order_key = <lfs_key>-value.

     ELSEIF it_filter_select_options IS NOT INITIAL.

       " get the key from the parent which is the Vbeln of the order by reading it_filter_select_options

" this is needed to allow 1:N relations if this entity is used in modelling of external services

       lv_order_key = ...

     ENDIF.

IF lv_order_key IS INITIAL.

    RETURN.

ENDIF.

...

I would like to avoid this kind of code because as a developer how can I know who includes my service with what kind of relation?

Anyway, that's how it is...

Best,

Nabi