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: 

Using OData custom query options (URL parameters) in Gateway

0 Kudos
6,394

Hi,

I created a CDS view with explicitly defined parameters and generated a Gateway OData service on top using SADL. Now I want to use OData custom query options to map them to the CDS parameters. I'm quite sure that this will not work automatically.


I'm already able to set the CDS parameters in the OData service DPC_EXT class manually, using the method if_sadl_gw_query_control~set_query_options.


METHOD if_sadl_gw_query_control~set_query_options.

     IF ( iv_entity_set = 'POIPARAMSet' ).

          IF sy-subrc = 0.

               io_query_options->set_entity_parameters(

                    it_parameters = VALUE #( (

                         entity_alias = 'POIPARAMSet' parameters = VALUE #( (

                              name = 'P_PurchaseOrderNetAmount' value = '10'

                         ) )

                    ) )

                )

          ENDIF.

     ENDIF.

ENDMETHOD.

However, I want to use custom query options (URL parameters) and want to map them to CDS parameters within the DPC_EXT class.

The URL looks like:

...ZBF_POIPARAM02MAN_SRV/POIPARAMSet?P_Material='STANDARD'

Unfortunately, these custom query options are obviously not parsed by Gateway. I can't find them anywhere in the data structures of MR_REQUEST_DETAILS or MO_CONTEXT. Fields like PARAMETERS, MT_PARAMETERS or URI_PARAMETERS are empty or containing other stuff. The custom query options only appear in the ~request_uri header parameter in a non-parsed way like

....?param1=1&param2=2&param3=3....  [figure01]

Of course I can parse the query string myself but I believe there must be an other way to access them. However, I also read in a SCN post from 2012, that SAP doesn't support this aspect of the OData standard. Is this still true?

>>

Kind regards, Tobias

1 ACCEPTED SOLUTION

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
828

Hi Tobias,

you are right. In SAP Gateway we currently (OData v2) don't support custom query options and hence do not parse them.

In your scenario the parameter that you want to use as a custom query option is not part of the result set and hence cannot be provided as a filter.

The solution would thus be to create a function import that will return your data and that would have a custom query parameter.

Best Regards,

Andre

ceterum censeo RAP esse utendam
4 REPLIES 4

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
829

Hi Tobias,

you are right. In SAP Gateway we currently (OData v2) don't support custom query options and hence do not parse them.

In your scenario the parameter that you want to use as a custom query option is not part of the result set and hence cannot be provided as a filter.

The solution would thus be to create a function import that will return your data and that would have a custom query parameter.

Best Regards,

Andre

ceterum censeo RAP esse utendam

0 Kudos
828

Hi André,


is it planned to support custom query options in future? I think this feature would be very useful for many scenarios


Best regards,

Oliver

0 Kudos
828

Hi André,

thanks for the answer. I finally used another approach to pass parameters via URL instead of using custom query options (URL parameters). The following notation worked for me..:

...SRV/TestEntity(P_Param='test')/Set

dirk_roeckmann
Participant
0 Kudos
828

Hi Tobias,

may I ask which release you worked on to manipulate the query options?

I am not able to do that on our 7.5 SP1 system, since the generated runtime artifacts don't contain the interface  'if_sadl_gw_query_control' with the 'set_query_options' method.

I generated the runtime artifacts in SEGW after referencing the CDS view via 'Data Model/Reference/Modeled Data Source Reference'.

Did you follow another path?

Thanks in advance for any input on that matter!