Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
78,334

Updates



    • 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


    • 27-08.2023
      • added recommendation NOT TO USE OSCI anymore


Recommendation: Use SAP Web Dispatcher or use OData Proxy Client


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.

Another approach is to use an OData Proxy Client as described here:
and to build a custom entity that consumes a remote OData Service if the data is to be published elsewhere.
 
The transaction OSCI is deprecated and has lots of restrictions and shall thus NOT BE USED.
 

Constraints


Please be aware of the constraings listed in SAP Help.

OData Services Consumption and Integration - SAP NetWeaver Gateway Foundation (SAP_GWFND) - SAP Libr...

Overview


In this How-To Guide we want to describe how to consume the Odata sample service from  http://services.odata.org/ 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

http://services.odata.org/V2/(S(xuh52ptttgitgrkbtjzk1o31))/OData/OData.svc/

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.

Prerequisites:



    • 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



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: services.odata.org

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

/sap/opu/odata/sap/ZOSCI_RW_TEST_SRV/Products(0)

and then press the push button "Use as request".



Now change the URI to

/sap/opu/odata/sap/ZOSCI_RW_TEST_SRV/Products

and the HTTP method to

POST

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:

http://services.odata.org/V2/(S(xuh52ptttgitgrkbtjzk1o31))/OData/OData.svc/Products(1000)



70 Comments
Former Member
0 Kudos

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,
Simon

kammaje_cis
SAP Mentor
SAP Mentor
0 Kudos

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

Thanks

Krishna

Former Member
0 Kudos

Hi Krishna,

That sounds cool, like a sort of OData Mashup :cool: .

Thanks for sharing.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

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,

Andre

CRVMANISH
Contributor
0 Kudos

Excellent blog. This will help developers and business to value position oData and SAP Gateway.

Thanks Andre to put this together.

Regards

Manish

ChandrashekharMahajan
Active Contributor
0 Kudos

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 http://scn.sap.com/community/developer-center/front-end/blog/2013/08/02/creating-sapui5-applications... 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!

Regards,

Chandra

SyambabuAllu
Contributor
0 Kudos

Hi Andre,

Excellent Blog.

Thanks,

Syam

JorgeWeiss
Participant
0 Kudos

Hi Andre,

very interesting!

Thanks,

Weiss

Robert_Eijpe
SAP Mentor
SAP Mentor
0 Kudos

Hi Andre,

very interesting blog :smile:

Do you know more hidden functions ?

Thanks,

Robert

Former Member
0 Kudos

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

Ron.

sreenivas_pachva
Participant
0 Kudos

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 ?

Thanks

Sreenivas Pachva

Former Member
0 Kudos

Excellent blog...

We have a requirement to create a gateway service to consume HANA ODATA service and our url look like below...

http://test.corp:8001/services/abc/test123.xsodata/VIEWParameters(VENDOR='000100')/Results?$format=j...

In Step 3: can you please let us know what details we should provide for service Namespace and service name.

we are getting the error in this step as shown.

Error while fetching the source metadata.

former_member184867
Active Contributor
0 Kudos

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..

Regards,

Atanu  

Former Member
0 Kudos

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.

former_member184867
Active Contributor
0 Kudos

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

Regards,

Atanu

Former Member
0 Kudos

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

FM: /IWBEP/FM_MGW_GET_OBJ_MODELS

Structure: /IWBEP/S_MESSAGE_CONTAINER_H

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

former_member184867
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Excellent Blog

Former Member
0 Kudos

nice blog :smile:

iwan_santoso4
Participant
0 Kudos

Hi Andre,

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

Thanks,

Iwan

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

iwan_santoso4
Participant
0 Kudos

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 services.odata.org/V2/OData/OData.svc/$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 http://services.odata.org/V2/OData/OData.svc/$metadata and that still has the same issue.

I tried to include the

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

I used service.odata.org/Northwind/Northwind.svc 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?

Thanks,

Iwan

iwan_santoso4
Participant
0 Kudos

Nevermind :smile: 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.

Regards,

Iwan

Former Member
0 Kudos

Hi Iwan,

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

Regards,

Imran.

iwan_santoso4
Participant
0 Kudos

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.

Regards,

Iwan

Former Member
0 Kudos

Hi Atanu,

/sap/opu/odata/sap/test/test_parameters(IP_VENDOR='*',In_PO_Type='*',In_Days=300,In_SCB_Doc_Type='ZRC1','ZRC2',In_PR_Doc_Type='*',In_Hub='*',In_Transit_Doc_Type='*')/Results?$top=1&$format=xml

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.

former_member184867
Active Contributor
0 Kudos

You can not pass two values for a key field, use filter instead

sagarjoshi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Has anyone figured out authentication aspects of such ODATA Consumption?

Is it possible to use named user and OAUTH for consuming the ODATA using OSCI?

former_member191815
Participant
0 Kudos

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.

Thanks!

Wim

Former Member
0 Kudos

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="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>SY/530</code>

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

- <innererror>

<transactionid>A8F29FE456F9F14193EE005056890FEC</transactionid>

<timestamp>20150119160019.6300000</timestamp>

- <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 (https://service.sap.com/sap/support/notes/1797736)</SAP_Note>

</Error_Resolution>

- <errordetails>

- <errordetail>

<code>/IWBEP/CX_OCI_TECH_EXCEPTION</code>

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

<propertyref />

<severity>error</severity>

</errordetail>

</errordetails>

</innererror>

</error>


Br,

Nikolaus



former_member184867
Active Contributor
0 Kudos

one possible reason of error may be the the framework could not parse the payload. Check the payload that you are using for post.

Former Member
0 Kudos

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,

Nikolaus

former_member184867
Active Contributor
0 Kudos

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.

roland_spindler
Participant
0 Kudos

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?

Roland

Former Member
0 Kudos

Hi Iwan,

Have you found a solution for the case sensitive problem? I'm in the same situation as u were.

Regards,


Dominik

45259
Participant
0 Kudos

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,

Stephan

Former Member
0 Kudos

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.

Br,

Nikolaus

45259
Participant
0 Kudos

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

kammaje_cis
SAP Mentor
SAP Mentor
0 Kudos

I just came out of this same error.

I had forgotten to maintain the HTTP RFC destination in the system alias with which I am registering the service.

former_member184739
Contributor
0 Kudos

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.

Class = >/IWFND/CL_OCI_REQ_PROCESSOR

Method=>GET_SRC_METADATA

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

       EXPORTING

         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.


Regards

Prabaharan

iwan_santoso4
Participant
0 Kudos

Hi Dominik, sorry for late reply. just have a chance to revisit this blog. I think OSS note 2038379 should fixed that issue .

iwan_santoso4
Participant
0 Kudos

W. Snoep, not sure if it still relevant. I'm at SP9 and the http:// issue still there.

iwan_santoso4
Participant
0 Kudos

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.

Regards,

Iwan

HadrienP
Active Participant
0 Kudos
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

Hadrien
Former Member
0 Kudos
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
Joseph_BERTHE
Active Contributor
0 Kudos
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 😉

 

Regards
buddhika_krishantha
Active Participant
0 Kudos
Hi,

I have netveawer gateway SP13. While I'm trying to create the service I'm getting following dump. Is anyone familiar with this dump.

 

amitkumar_singh2
Participant
0 Kudos
@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.

 
KarelVerbanck
Explorer
0 Kudos
Getting the same error here, did you manage to fix it?
dirk_riedel
Explorer
0 Kudos
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,

Thomas