Skip to Content
Technical Articles

How to consume an OData service using OData Services Consumption and Integration (OSCI)


  • 26.11.2014
    • added SAP Note 2038379 as a prerequisite
    • added link to constraints
  • 23.02.2015
    • added information that as of SP7 SEGW should be used
    • added information that for SAP Fiori like scenarios that consume SAP HANA XS OData services a SAP Web Dispatcher or SAP API Management should be used
  • 13.12.2019
    • added new recommendation to use SAP Web Dispatcher as a proxy instead of SAP Gateway

Recommendation: Use SAP Web Dispatcher

In the scenario described in this article SAP Gateway is used as an OData proxy for an external OData Service.

The main reason why customers asked for such a scenario was that they wanted to use the SAP Gateway Hub as the single point of entry for the consumption of OData services, so that a SAP Fiori App that is deployed on a SAP Fiori Frontend Server can consume OData Services from just one location.

The same result but with a much cleaner technical approach can be achieved by using the SAP Web Dispatcher as described in the following Wiki page (sectionConfiguring WDP for Fiori s4HANA Applications )

As you can see from the numerous questions and comments to this post you can see that this does not work well. In addition to the technical constraints (see below) also performance should be considered. So Web Dispatcher is your best friend.



Please be aware of the constraings listed in SAP Help.

OData Services Consumption and Integration – SAP NetWeaver Gateway Foundation (SAP_GWFND) – SAP Library


In this How-To Guide we want to describe how to consume the Odata sample service from that supports read write access.

Since SAP NetWeaver Gateway does not support V3 of OData we will use the V2 version of this service. The service document of the V2 version is accessible via this link

Though in this scenario the SAP Gateway Server acts like an OData proxy it is not the recommended way to use SAP Gateway to circumvent same origin policy issues that come up with scenarios where SAP Fiori like applications should consume data from OData service that are published via SAP Gateway and the SAP HANA XS engine. Instead the SAP Web Dispatcher or SAP API Management should be used.


  • This scenario has to be implemented on a Gateway Server where also the AddOn IW_BEP is deployed or on a Gateway Server running on SAP NetWeaver 7.40.
    The reason is that the Odata Lib that is part of the hub components is needed for consumption of the 3rd party OData service. This prerequisite is automatically fulfilled by a SAP Netweaver 7.40 SP2 and higher system since the software component SAP_GWFND contains the functionalities of IW_FND, GW_CORE and IW_BEP.
  • This scenario needs to run on SAP NetWeaver Gateway 2.0 SP6 or higher or SAP NetWeaver 7.40 SP2 or higher
  • You have to apply SAP Note 2038379

Let’s start with the configuration on SAP NetWeaver Gateway:

Step 1: Create an RFC destination

We first have to create a RFC destination of type G with the following technical settings:

Target Host:

In our example this RFC destination is called ODATAORG.

Please note that you might have to configure a proxy server.


Step 2: Create a System Alias

Now we have to create a System Alias that will be using the above created RFC destination. We call this System Alias OCI_NORTH and configure it such that the flags “Local GW” and “For Local App” are activated.


Step 3: Generate OData Service in SAP NetWeaver Gateway

Only on a SP6 system you have to run transaction /IWBEP/OCI_SRV_GEN.

On systems running on SP7 or later the integration into the SEGW has to be used instead.

Service Namespace = V2/(S(xuh52ptttgitgrkbtjzk1o31))/OData/

Service Name = OData.svc

and acitvate the check box “Configure Gateway Model and Service”.

Choose appropriate names for MPC, DPC, Model and Service and a package (here $TMP)


This registers the service in the backend (which is identical with the hub system).

Step 5: Activate Service using /IWFND/MAINT_SERVICE

We register the service in the hub and choose the Technical Service Name ZOSCI_RW_TEST_SRV and register it for the System Alias OCI_NORTH.


Step 6: Test the service

We can now test the service using the Gateway Client /IWFND/GW_CLIENT. You can simply press the push button GATEWAY CLIENT in the Activate and Maintain Service transcation.

We enter the following URI in the Gateway Client


and then press the push button “Use as request”.


Now change the URI to


and the HTTP method to


and change the values for

ID from “0” to “1000”

Name from “Bread” to “Toast”

and press Execute.


The HTTP status code 201 indicates that a new entry has been created in the collection “Products” and the created entry is shown in the HTTP response window.

You can now verify it also in a new browser window:


You must be Logged on to comment or reply to a post.
  • Hi Andre,

    This is a use case I hadn't considered for Gateway before now. In essence in this scenario you are using NWGW as a proxy for another OData service (external service in this case). Can you elaborate on the sort of scenarios where we might encounter this "in the wild" (e.g. are there already customers using NWGW in this way)?

    Thanks for sharing,

    • Hi Simon,

      This is what I can think off.

      I am an online video rental store with various audio/video titles in my store and has an ECC. I want to build a sales Mobile application which provides the current inventory as well as the rental rates to the renter.

      I would need a OData service providing these details from my ECC and in addition I would require generic details of the video title (like author, running length, related videos etc). In this case I can consume the Netflix OData service and enhance it to add rental rate and inventory details (from ECC) into that service and expose a single OData service for the mobile app developer to use. This would simple for the mobile app developer.

      Other option for the app developer would be to create an OData service only with inventory and rate details and the mobile app developer would have to combine/mash this service with the Netflix service at the client.

      Let me know what do you think of this use case



        • Hi Simon,

          one use case is to consume OData services that are being published by SAP Hana.

          Using composition with other OData services developed in the SAP backend you can create a new service that would allow for a fast data retrieval using SAP Hana and read / write access to SAP Business Suite at the same time.

          Best Regards,


  • Hi Andre,

    This is very useful information and Thanks for sharing it! I was always thinking how we can consume external oData services in NWGW and then combine it with other oData services to build UI mashup application.

    In my blog I am using public JSON APIs to build SAPUI5 application. Now I am thinking whether it is possible to consume these public APIs in NWGW and how we can leverage public API data along with business suite data.

    Again thanks for nice blog!



  • I always found it a bit odd that there wasn't any support for GW to read its own lingua franca, so it's great that it has now arrived.

    Thanks for the blog


  • Hi Andre,

    Excellent blog and it will be helpful for creating Gateway OData services from different backend systems like SAP and NON SAP..

    Could you please let me know, is it applicable(OSCI) for restful Web services ?


    Sreenivas Pachva

    • I would suggest that, in RFC configuration you need to enter

      Target Host: test.corp

      Service No: 8001

      Path Prefix:/services/abc

      At this point do a connection test and ensure that it is successful. If you get '404 resource not found' it is also fine.  

      Then in service builder wizard enter only service name which is 'test123.xsodata' and try it out..



  • Thanks Atanu for the response,

    In the RFC connection i gave the inputs as you mentioned now i am getting the below msg when i do a test connection.

    Status HTTP Response 303

    and was facing the same error in step 3 after entering the test123.xsodata  in Service Name:

    Error while fetching the source metadata.

    • Could you please check once in debug, what is the URL being called. You can check it in class /IWFND/CL_OCI_HTTP_PROCESSOR method /IWFND/IF_OCI_HTTP_WRAPPER~GET.

      Please check the URL once



  • Hi Atanu,

    Thanks a lot it is working fine..

    I have given the user and password details in RFC and then it is working as you mentioned and get the response as 404.

    Now i have created the service and trying to add it in transaction /IWFND/MAINT_SERVICE (Step 5) when i  double click on the service to add the service it is giving me short dump and when i checked the dump i found it is due to type mismatch at a function module which is called



    Issue field : SAP_NOTE_ID

    i guess we have missed some components to install. can you let us know what are the required components to be installed for this to work.

    Till now we have installed the following components

    patch 8 for IW_BEP and

    patch 4 for IW_HDB

    and we are on SAP EHP 2 for SAP NetWeaver 7.0

    • I do not think this is something specific to OSCI. If you register any other service you will encounter similar problem.

      I think there are notes to address this issue.

  • Hi Andre,

    Do you have updated version for SP07? I could not pass the wizard due to error when handling the model class.




    • Does your service name contain small letters and is your service case sensitive?

      There is a known issue with this wizard for these scenarios.

      Best Regards,


      • Andre,

        Thanks for your respond. I tried to use the same service in your document. I did found that the wizard is not case sensitive just as you mentioned. However, that's half the issue i encountered.

        The URL is being called is$metadata, which is working from web browser and in the method /IWFND/IF_OCI_HTTP_WRAPPER~GET of class /IWFND/CL_OCI_HTTP_PROCESSOR it returned Bad Request - Invalid URL (400)

        Then in debug mode I added 'http://' so the url is$metadata and that still has the same issue.

        I tried to include the

        I used S string as per your document and use V3 too eventhough you siad V3 is not supported, it's the same result.

        I used it has the same issue until i add the 'http://'. This completed step 3 as per your document. All green lights!

        Then during the service registration, I got the following message:

        Service 'ZTST_CALL_01_SVC' was created but its metadata could not be loaded.

        I'm guessing it relates to the 'http://' issue during step 3, but not sure where I should add the http:// since I can't do it in SM59.

        Do you have any idea on resolving this issue?



        • Hi Iwan,

          Please check system alias in transaction IWFND/MAINT_SERVICE.This error usually come when we add in correct system alias.



          • Hi Imran,

            Can you explain a little bit more? I setup the system alias the same way as per Andre mentioned in the article above.



      • Nevermind ­čÖé I added implicit enhancement in CONSTRUCTOR Method of class /IWFND/CL_OCI_HTTP_PROCESSOR. I added this code at the end of the method:

        concatenate 'http://' mv_target_host into mv_target_host.

        So at this point, the issue is only setting up via wizard for case sensitive OData service, since the wizard converted to upper case.



      • hi Andre,

        Great blog, thanks a lot for sharing!

        Will there be a note / fix for the class: /IWFND/CL_OCI_HTTP_PROCESSOR. Regarding the missing 'http://' in the 'mv_target_host' ? We ran into this issue when consuming an HANA xsodata service via SAP Gateway. It gives issues when loading metadata but also for reading of entities.

        We rather do not want to go the route of adding the 'implicit enhancement as Iwan Santoso describes a bit further in this thread.

        Our current gateway version is SP7.



      • Hi Andre,

          Thanks for the useful blog.

        I followed the steps described the blog and am receiving this error "Could not retrieve the model name and version" when trying to consume the above mentioned external REST service in gateway system(SAP NW 7.4).I am passing RFC destination, Service name in the SEGW tool wizard steps and started in debug mode. I found that in the below standard class RFC destination is getting retrieved as blank value.



        Parameter IV_RFC_DESTINATION is null.

        So exception is raised as below snipped will get executed.

        IF iv_rfc_destination IS INITIAL .

        *--  Raise Exception --*

             lv_message  = /iwfnd/cl_oci_common_util=>create_message_key( iv_msgid = /iwfnd/if_oci_common=>gc_message_id  iv_msgno = '001'   ) .

             RAISE EXCEPTION TYPE /iwfnd/cx_mgw_tech_exception


                 textid = lv_message.

           ENDIF .

        Message class : /IWFND/OCI_MSG

        Error: Enter an RFC Destination

        Gateway service builder didnt pick up the RFC destination passed via the wizard

        Could you give some insights on this error?

        Your help is appreciated.



  • Hi Atanu,


    Here in the URL, we are passing two inputs to the same parameter (marked in yellow) and it is giving the following error.

    Thanks in Advance. Kindly help us.


  • Thanks for the Guide.

    At first i want to say i ran into a problem with sm59 and /IWBEP/OCI_SRV_GEN. I had to das the Perfix for the link in sm59 and leave it out in /IWBEP/OCI_SRV_GEN. If i didn't do that, i'll get the error "problem while fetching meta data".

    Now i got a problem at step 6. The Get part is working, will get the entry "Bread". But when i try to post the new entry, ill run into a 500 error.

    But i cant find the error, may you experts have a look at this:

    <?xml version="1.0" encoding="utf-8" ?>

    - <error xmlns="">


    <message xml:lang="en">Create Entity failed: 3C68746D6C3E3C686561643E3C7469746C653E4F626A656374206D6F7665643C2F7469746C653E3C2F686561643E3C626F64793E0D0A3C68323E4F626A656374206D6F76656420746F203C6120687265663D222F56322F2853287571356171797061356C6864626A6E7877786363356D746729292F56322F4F446174612F4F446174612E7376632F50726F6475637473223E686572653C2F613E2E3C2F68323E0D0A3C2F626F64793E3C2F68746D6C3E0D0A.</message>

    - <innererror>



    - <Error_Resolution>

    <SAP_Transaction>Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more details</SAP_Transaction>

    <SAP_Note>See SAP Note 1797736 for error analysis (</SAP_Note>


    - <errordetails>

    - <errordetail>


    <message>Create Entity failed: 3C68746D6C3E3C686561643E3C7469746C653E4F626A656374206D6F7665643C2F7469746C653E3C2F686561643E3C626F64793E0D0A3C68323E4F626A656374206D6F76656420746F203C6120687265663D222F56322F2853287571356171797061356C6864626A6E7877786363356D746729292F56322F4F446174612F4F446174612E7376632F50726F6475637473223E686572653C2F613E2E3C2F68323E0D0A3C2F626F64793E3C2F68746D6C3E0D0A.</message>

    <propertyref />








  • Hello again,

    Now i come back with an other question.

    I want to use the data from the URI in a zprogram.

    How can i achieve that? How can i use the classes in ABAP.

    Let assume i want to write a report where i to print all of the items thati get from the odata stream.

    Please provide an example if you got one.

    Thansk in advance and best regards,


    • If the requirement is just to call the URL and get the response in the ABAP program then 

      you can directly use cl_http_client.

      OSCI is for OData consumption.

      • I have the same problem. If I use cl_http_client, I have to parse the XML-result myself.

        Isn't the point of generating the ABAP classes to have a nice API (including methods like "get_entity") without having to care about the underlying XML?


    • Hello All,


      I have exaclty the same requirement.  How can I then use the differents classes generated in a Zprogram ?


      Did you had any way for doing this ?

      thank You


    • You can generate proxy classes for the external┬áODATA service by using┬átransaction SECATT_ODATA.

      For each entity one class is generated. They can easily be used in order to consume the external ODATA service.



  • Hello,

    I tried to follow this tutorial, but I'm stucking unexpected. Step 4 seems not to register the service; I must add it manually, and trying it, I get the error message: "No Model assigned to Service '<Servicename>'; assign Model first".

    Did anyone of you encounter the same problem, and can provide me with a hint on that?

    Thanks in advance,


    • Get back to step 1 und use the path prefix V2 and at Step4 leave the V2 out in the Service Namespace. Then try again to create the classes.



      • Thx Nikolaus,

        I retried it, yet it doesn't solve the problem. Funnily, the generation protocols says, that the newly generated service is successfully assigned to the model instance.

        Best regards, Stephan

  • I've setup the read write service but in 3, it fails to load metadata. I looked at the URL and when I open the url in a browser, it is fine, but when I check the get method, it return 500 value. Is there anything extra I have to do for read write service?

    If I remove (S(xuh... string (read only service), it works fine all the way to testing via gateway client.



    • Hello,

      For the metadata problem you have to set the prefix in the SM59

      And in the /IWBEP/OCI_SRV_GEN set the Service Namespace as blank.

      It sould work ­čśë



  • Hi,

    I have configured xsOdata with Gateway. I am able to do create and get. When i try to do a batch request I get blank response with 202 success message. What could be the issue

  • /
  • @Andre Fischer

    Thanks for the great blog post.

    I want to ask here what if at design time the structure of requested resource from external web service is not known, so what would be approach to consume it.

    Also can you let me know the ABAP APIs to invoke external web service consumed in this case?

    Thanks for your help.


  • Hi,

    1. why are the Model and Data Provider class empty in the sense that they inherit everything and don't redefine anything? They are also not used when testing via client. Are they useless?

    2. Why is it not possible to use this service from within ABAP without going back to the XML document. Currently I only see disadvantages compared to SOAP.

    Thanks and regards,



  • /
  • Why aren't you using a web dispatcher and access the OData ressource directly?

    The OSCI integration has limited functionality and will not developed any further.

    Best Regards,


    • Hello Andre:

      I have studied your blog for some time looking for the best approach to consume an external ODATA service from a Fiori App but also make it available in the SAP Gateway, for ABAP internal consults.

      OSCI integration was my first approach, but you say here that could be better to use a Web Dispatcher and consume the ODATA directly?  Where can I find more info on this, do you know?

      If that is the case, just adding the destination to the SAP Cloud Cockpit wouldn't suffice?

      In my case I need to provide the ODATA to a Fiori App and also create a way for ABAP programs to access it? Can this be done with the Dispatcher or OSCI should be better? I would appreciate any advice, I'm an ABAP developer and UI5 enthusiast and this is the first time that I'm required to connect to 3rd party ODATA.



      • Hi Jose,

        neither OSCI nor  the Web Dispatcher approach are suitable for a programmatic approach to access a third party OData service.

        For this you would have to write code yourself.

        What might be helpful is the following tool:

        Though it is meant to help you to test OData services you can take the generated classes and use them in your own OData service.

        Best Regards,



        • Hi Andre,

          I am trying to develop Fiori application using Fiori template ( OV page and ALP) with HANA xsodata as datasource and take web dispatcher approach . Fiori template require higher UI5 runtime version more that 1.38. I have XS Classic that has UI5 Runtime version of 1.28  and to get to higher runtime I have no other way but to go on XS Advance, XSA migration and higher versions of hana DB and it make web-dispatcher approach more complicated.

          Will this OSCI approach help me to use my xs classic xsodata and deploy fiori template based fiori applications on gateway ?



          • Hi Tanveer,

            the Web Dispatcher Scenario should enable you to deploy the app on SAP Gateway (thereby leveraging an up to date SAP UI5 library) and call an OData Service published via an xs classic engine.

            The Web Dispatcher would then take care of redirecting the OData calls to the xs engine.

            Best Regards,



    • I can't really recommend using this integration scenario since it has lots of technical restrictions and I do not see why would want to use it to consume HANA XS OData services.

      I would rather use a web dispatcher instead.




  • Hi Team,

    We have requirement from our external team to expose the data from SAP ECC to PowerBI via ODATA service. Could you please provide me any document and the procedure to follow for this work.




  • Hi All,

    we are facing issue while registering External OData service via /IWBEP/OCI_SRV_GEN . we have

    created RFC Destination of type G and maintained host name and port name in the destination.

    we are getting Error while fetching Metadata Error while at the odata generation step.

    we have followed below Document for consuming the external odata service.

    Can someone please help us in removing this error .


  • Hi Andre,

    Can you please share some document which has steps to configure this scenario via SAP web Dispatcher?

    I went through the blog but couldn't find any document for the same.


    • It was a Wiki page I am referring to above, not a blog and this Wiki page is full of links describing how to configure SAP Web Dispatcher.

  • Hi Andre Fischer

    We have tried using the OSCI approach for C4C Odata services, but it fails on the /IWFND/MAINT_SERVICE step due to (apparently) naming issues.

    Would the SAP Web Dispatcher work in this case? (Proxying calls from an on-premise GW to C4C in the cloud?)

    Kind Regards,