When implementing OData (2.0) services with SAP GW you should know that the Gateway APIs also include APIs which are obsolete and should not be used anymore (“deprecated”). These APIs are still available only because SAP wants to avoid syntax errors when customers upgrade. However, there are cases where such deprecated APIs lead to unexpected behavior.

If you use SAP GW APIs make sure to check the description for the corresponding method parameters you use. Do not use them if you can see the word “obsolete”. Instead, use the replacement APIs, i.e. the importing parameter IO_TECH_REQUEST_CONTEXT to access the request data in your service implementation.

1 46 7307253

This approach works if you check the class /IWBEP/CL_MGW_RT_SFLIGHT (see parameter descriptions of screenshot above). However, when you generate your classes via transaction code SEGW this might not be helpful (at least using NW ABAP 7.50 SP04). A better approach is to check the interface /IWBEP/IF_MGW_APPL_SRV_RUNTIME. There you can have a look the methods and the corresponding descriptions of the parameters (note “Obsolete” in the parameter description):

Here is an example of what could happen if you use the deprecated APIs (steps to reproduce on NW ABAP 7.50 SP04, this seems to be “fixed” in SP05 or SP06 due to backward compatibility I guess):

  1. In SE80 go to class /IWBEP/CL_MGW_RT_SFLIGHT
  2. Set a breakpoint in line 9 of /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET
  3. Go to Transaction /IWFND/GW_CLIENT
  4. Enter /sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection?$filter=substringof(‘HL’, carrid) and press execute
  5. When the debugger hits check the content of the Importing Table IT_FILTER_SELECT_OPTIONS:3 33 7010935
  6. You will see that carrid has the LOW value of *HK*, which is a length of 4 chars while carrid actually has a max. length of 3!
  7. Now check the instance attribute MO_FILTER of the importing parameter IO_TECH_REQUEST_CONTEXT (MT_FILTER_SELECT_OPTIONS ==> CARRID…):6 30 52794688 21 8476347
  8. Here you can suddenly see that we have two entries and not only one! Do you see the inconsistency? The two entries are correct (step 7), having one entry like in step 6 would be a bug in this scenario!

So what we learn from this example is to use IO_TECH_REQUEST_CONTEXT to get the data we want instead of using the deprecated APIs mentioned above. It seems SAP is not putting too much effort into keeping the deprecated APIs 100% correct across new releases of SAP GW – that’s why they are called “deprecated”. However, there are still many standard SAP applications around that are still using the deprecated APIs, and of course, many custom apps that do the same. Even the SAP GW SFLIGHT example from SAP is still using the deprecated APIs (just check line 6 of the first screenshot above, although that might not be the best example).

Here are a few examples of deprecated APIs and what you could use instead:

(Hint: just copy and paste the code above into the corresponding methods play around a little in the debugger. Make sure to compare the values you get with the corresponding deprecated method parameters.)

CREATE_ENTITY:

DATA : lv_entity_type_name TYPE /iwbep/mgw_tech_name, lv_entity_set_name TYPE /iwbep/mgw_tech_name, lv_src_entity_type_name TYPE /iwbep/mgw_tech_name, lv_src_entity_set_name TYPE /iwbep/mgw_tech_name, lt_source_keys TYPE /iwbep/t_mgw_tech_pairs, lt_navigation_path TYPE /iwbep/t_mgw_tech_navi. *IV_ENTITY_NAME lv_entity_type_name = io_tech_request_context->get_entity_type_name( ). *IV_ENTITY_SET_NAME lv_entity_set_name = io_tech_request_context->get_entity_set_name( ). *IV_SOURCE_NAME lv_src_entity_set_name = io_tech_request_context->get_source_entity_set_name( ). lv_src_entity_type_name = io_tech_request_context->get_source_entity_type_name( ). *IT_NAVIGATION_PATH lt_navigation_path = io_tech_request_context->get_navigation_path( ). *IT_KEY_TAB lt_source_keys = io_tech_request_context->get_source_keys( ).

GET_ENTITYSET:

DATA : lv_entity_type_name TYPE /iwbep/mgw_tech_name, lv_entity_set_name TYPE /iwbep/mgw_tech_name, lv_src_entity_type_name TYPE /iwbep/mgw_tech_name, lv_src_entity_set_name TYPE /iwbep/mgw_tech_name, lt_source_keys TYPE /iwbep/t_mgw_tech_pairs, lt_filter_select_options TYPE /iwbep/t_mgw_select_option, lt_orderby TYPE /iwbep/t_mgw_tech_order, lv_top TYPE i, lv_skip TYPE i, lt_navigation_path TYPE /iwbep/t_mgw_tech_navi, lv_filter_string TYPE string, lv_search_string TYPE string. *IV_ENTITY_NAME lv_entity_type_name = io_tech_request_context->get_entity_type_name( ). *IV_ENTITY_SET_NAME lv_entity_set_name = io_tech_request_context->get_entity_set_name( ). *IV_SOURCE_NAME lv_src_entity_set_name = io_tech_request_context->get_source_entity_set_name( ). lv_src_entity_type_name = io_tech_request_context->get_source_entity_type_name( ). *IT_FILTER_SELECT_OPTIONS lt_filter_select_options = io_tech_request_context->get_filter( )->get_filter_select_options( ). *IT_ORDER lt_orderby = io_tech_request_context->get_orderby( ). *IS_PAGING lv_top = io_tech_request_context->get_top( ). "why does this API return a string? lv_skip = io_tech_request_context->get_skip( ). *IT_NAVIGATION_PATH lt_navigation_path = io_tech_request_context->get_navigation_path( ). *IT_KEY_TAB lt_source_keys = io_tech_request_context->get_source_keys( ). *IV_FILTER_STRING lv_filter_string = io_tech_request_context->get_filter( )->get_filter_string( ). *IV_SEARCH_STRING lv_search_string = io_tech_request_context->get_search_string( ).

GET_ENTITY:

DATA : lv_entity_type_name TYPE /iwbep/mgw_tech_name, lv_entity_set_name TYPE /iwbep/mgw_tech_name, lv_src_entity_type_name TYPE /iwbep/mgw_tech_name, lv_src_entity_set_name TYPE /iwbep/mgw_tech_name, lt_keys TYPE /iwbep/t_mgw_tech_pairs, lt_source_keys TYPE /iwbep/t_mgw_tech_pairs, lt_navigation_path TYPE /iwbep/t_mgw_tech_navi. *IV_ENTITY_NAME lv_entity_type_name = io_tech_request_context->get_entity_type_name( ). *IV_ENTITY_SET_NAME lv_entity_set_name = io_tech_request_context->get_entity_set_name( ). *IV_SOURCE_NAME lv_src_entity_set_name = io_tech_request_context->get_source_entity_set_name( ). lv_src_entity_type_name = io_tech_request_context->get_source_entity_type_name( ). *IT_NAVIGATION_PATH lt_navigation_path = io_tech_request_context->get_navigation_path( ). *IT_KEY_TAB lt_keys = io_tech_request_context->get_keys( ). lt_source_keys = io_tech_request_context->get_source_keys( ). 

UPDATE_ENTITY:

DATA : lv_entity_type_name TYPE /iwbep/mgw_tech_name, lv_entity_set_name TYPE /iwbep/mgw_tech_name, lt_keys TYPE /iwbep/t_mgw_tech_pairs. *IV_ENTITY_NAME lv_entity_type_name = io_tech_request_context->get_entity_type_name( ). *IV_ENTITY_SET_NAME lv_entity_set_name = io_tech_request_context->get_entity_set_name( ). *IV_SOURCE_NAME * ==> no corresponding API in IO_TECH_REQUEST_CONTEXT (why not???) *IT_NAVIGATION_PATH * ==> no corresponding API in IO_TECH_REQUEST_CONTEXT (why not???) *IT_KEY_TAB lt_keys = io_tech_request_context->get_keys( ). "no source keys table available on IO_TECH_REQUEST_CONTEXT (why not???)

DELETE_ENTITY: 

DATA : lv_entity_type_name TYPE /iwbep/mgw_tech_name, lv_entity_set_name TYPE /iwbep/mgw_tech_name, lt_keys TYPE /iwbep/t_mgw_tech_pairs. *IV_ENTITY_NAME lv_entity_type_name = io_tech_request_context->get_entity_type_name( ). *IV_ENTITY_SET_NAME lv_entity_set_name = io_tech_request_context->get_entity_set_name( ). *IV_SOURCE_NAME * ==> no corresponding API in IO_TECH_REQUEST_CONTEXT (why not???) *IT_NAVIGATION_PATH * ==> no corresponding API in IO_TECH_REQUEST_CONTEXT (why not???) *IT_KEY_TAB lt_keys = io_tech_request_context->get_keys( ). "no source keys table available on IO_TECH_REQUEST_CONTEXT (why not???)

ATTENTION:

Make sure to test your code after you have changed your code to rely on io_tech_request_contexs! In some cases things have slightly changed, i.e. in IT_KEY_TAB the key is the Property Name of the entity while the keys in get_keys() and get_source_keys() are equal to the corresponding ABAP field names!!!! Such changes could break your logic in the code.

 

Unfortunately, I was not able to find some official announcement or documentation about the deprecated APIs. Even the public API docs do not list the deprecated APIs/parameters. Taking into account that the deprecation of APIs took place some years ago it’s very strange not to find any docs (I hope I’m not too stupid to google). I guess this is why we all keep seeing the deprecated APIs every day.

Cheers, Nabi

New NetWeaver Information at SAP.com

Very Helpfull

 

 

User Rating: Be the first one !