Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Resource not found for segment Odata

naotoxxx
Participant
54,638

Hi guys! i'm facing an error with an odata that i created.

This is my structure

This is the code (just to test)

this is my uri request /sap/opu/odata/sap/ZCLMM_GW_CREARPROVEEDOR_ODATA_SRV/loggedUserSet(User='CL')

and this is the error i get:

more details:

it's like if the request iswrong or something like that, i modified the get entityset of another entity type called Pais and i got no error. Any suggestion ?

1 ACCEPTED SOLUTION

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
8,557

Hi Naoto,

I was able to reproduce your issue.

The root cause of the error message is that in your GET_ENTITY method there is no code that adds a value into the exporting parameter er_entity.

So you have to add Code like the following after line 24 within the IF .. ENDIF structure.

select single *  into corresponding fields of @er_entity  from <your table>  where <key_field> = @lv_usario.

In addition you should raise an error message if nothing is found.

But I have to admit that the error message of the framework is a little bit misleading here and I will raise an internal message for that issue to see if something like "no data provided" could be raised instead.

I would also recommend to use the method

io_tech_request_context->get_converted_keys

of the importing parameter IO_TECH_REQUEST_CONTEXT instead of the import parameter IT_KEY_TAB since all the IV* and IT* import parameters are depricated and are only part of the method signature because of compatibility reasons.

See my blog

https://blogs.sap.com/2016/05/31/odata-service-development-with-sap-gateway-code-based-service-devel...

for a sample implementation.

Regards,

Andre

ceterum censeo RAP esse utendam
4 REPLIES 4

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
8,558

Hi Naoto,

I was able to reproduce your issue.

The root cause of the error message is that in your GET_ENTITY method there is no code that adds a value into the exporting parameter er_entity.

So you have to add Code like the following after line 24 within the IF .. ENDIF structure.

select single *  into corresponding fields of @er_entity  from <your table>  where <key_field> = @lv_usario.

In addition you should raise an error message if nothing is found.

But I have to admit that the error message of the framework is a little bit misleading here and I will raise an internal message for that issue to see if something like "no data provided" could be raised instead.

I would also recommend to use the method

io_tech_request_context->get_converted_keys

of the importing parameter IO_TECH_REQUEST_CONTEXT instead of the import parameter IT_KEY_TAB since all the IV* and IT* import parameters are depricated and are only part of the method signature because of compatibility reasons.

See my blog

https://blogs.sap.com/2016/05/31/odata-service-development-with-sap-gateway-code-based-service-devel...

for a sample implementation.

Regards,

Andre

ceterum censeo RAP esse utendam

RaminS
Active Participant
8,557

Andre,

I'm following your recommendation, but io_tech_request_context is empty in my GET_ENTITY method. So I have to use the IT_KEY_TAB table, which does have the key values that I need.

My GET_ENTITY method is being called in an UPDATE operation of my entityset. Do you know why the framework needs to call the GET_ENTITY before an update? it's causing a lot of problems for us.

Thanks,

Ramin.

8,557

Hi Ramin.

I just stumbled upon this, because I had a similar issue.

The reason why GET_ENTITY (OData Read) is called, when you perform an OData update, is because SAPUI5 uses the MERGE operation when performing an Update. The MERGE operation implicitly performs an OData Read and merges this with the payload body of you OData request.

If you perform an OData Update, via the http operation PUT directly from an http client like PostMan or similar, the Read operation will not be performed.

Best regards, Søren Hansen

R4BB1T
Participant
0 Kudos
8,557

Keys can't be Initial.

IF sy-subrc EQ 0.
  lv_usuario = <parametrosIn>-name.
ELSE.
  lv_usuario = 'SomeValue'. " Keys Always have value
ENDIF.