You are on page 1of 5

2/4/2020 Avoid using deprecated SAP Gateway APIs in your OData service implementation -

Avoid using deprecated SAP Gateway APIs in your OData service


implementation
 SAP Gateway

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.

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):


www.learntips.net/avoid-using-deprecated-sap-gateway-apis-in-your-odata-service-implementation/ 1/5
2/4/2020 Avoid using deprecated SAP Gateway APIs in your OData service implementation -

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:

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…):


www.learntips.net/avoid-using-deprecated-sap-gateway-apis-in-your-odata-service-implementation/ 2/5
2/4/2020 Avoid using deprecated SAP Gateway APIs in your OData service implementation -

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

www.learntips.net/avoid-using-deprecated-sap-gateway-apis-in-your-odata-service-implementation/ 3/5
2/4/2020 Avoid using deprecated SAP Gateway APIs in your OData service implementation -

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_tec

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_tec

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_tec

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_E

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_E

ATTENTION:

www.learntips.net/avoid-using-deprecated-sap-gateway-apis-in-your-odata-service-implementation/ 4/5
2/4/2020 Avoid using deprecated SAP Gateway APIs in your OData service implementation -

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

Would you like to access Full Article?

If you are already a member in this website, Please Click here to login If you are not yet a member, Please

Click here to Sign up  


if you have any questions don't hesitate to contact us from the Button bellow

 Contact US

New NetWeaver Information at SAP.com


Very Helpfull

User Rating: Be the first one !


www.learntips.net/avoid-using-deprecated-sap-gateway-apis-in-your-odata-service-implementation/ 5/5

You might also like