Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stephen_xue
Active Participant
You might be very familiar with consuming OData service by using REST receiver adapter. However SAP  has provided a native OData adapter to consume OData service as well.

In the content below, you will learn some knowledge on how to update information in backend by using OData adapter under the $batch mode.


There are some blogs post on using SAP PI OData adapter to make complex query to backend. Whereas in this blog post, I will describe how $batch has been used in OData adapter configuration under POST operation. here are the steps.

  1. Create a OData service as below from table SFLIGHT




 

remember to redefine these methods so that it can support $batch



In the above blogs, the author has described a way to get schema, resource path etc. by using Model Operation for query.

I will describe the detail steps on this.



 

Then create the ESR contents based on the xsd generated.

 

However, I found the Model Operation in NWDS has a defect dealing with an entity type having deep structure which prevents xsd from being generated.

I will write the way dealing with deep structure using $batch in another blog.

 

 

2. Configuration OData Receiver Channel



The entity set of the OData created in the backend by me is SflightSet



 



Note: this additional setting is to avoid an ‘utf-8’ string generated to the Accept in the request message, which cannot be accepted by SAP gateway service

 

3. Unit Test

Check entries in Table SFLIGHT

The values in field PRICE are 16 and 18.82 here



Make change to price field in the request message and send it.



 

Response message received by POSTMAN



Entries updated after the batch POST



 

4. Analysis

goto tx code /IWFND/TRACES, select the communication user, we can find that when OData Adapter makes one call to backend by using POST, the odata service has been called 4 times in the backend.



The GET operation is to retrieve CSRF Token.

Therefore, one of the benefit to use OData Adapter to create/change data is that you do not need to switch off csrf token as for REST adapter.

 

 

 

Hopefully you will find the blog is useful.

 

 

Reference


https://blogs.sap.com/2017/01/10/consuming-gateway-odata-service-with-odata-adapter/

https://blogs.sap.com/2017/03/13/diving-deeper-into-the-odata-adapter/

 
6 Comments
former_member771801
Discoverer
0 Kudos
Hi Stephen ,

 

I have the same requirement .I have gone thru the above description. I have some question on this.

1.How are you handling the CSRF token in the ODATA receiver adapter .

2. IF SAP PO want to connect the Odata service in the Backend via Apigee gateway then is there any possibility to add the static toke in the http header .

 

Thanks in advance !

 

Regards ,

Mahasweta Acharya
dylon_militani
Explorer
0 Kudos
 

Hi Stephen.

 

I am using the ContentTypeEncoding=none, as suggested, I'm still getting errors in the ODATA adapter and I am also trying the REST adapter, it's not working as well.

REST adapter is working when I am sending 1 item (not using the "Enable Batch Processing").

 

"this additional setting is to avoid an ‘utf-8’ string generated to the Accept in the request message"

Do you know what is the Encoding SAP Gateway is accepting ? And the header parameters expects to receive ?

 

Thanks in advance !

 

Best Regards!
stephen_xue
Active Participant
0 Kudos
Hi Mahsweta,

for item 1:

OData adapter will handle the csrf token automamtically. pleae check the record above. the adater will trigger a GET operation at first to get the csrf token.

for item 2:

i have only tested the odata adapter connecting with ABAP backend. if you were trying to connect a 3rd party system, please raise a ticket to SAP service. lol. I assume at least REST receiver adapter will fulfill the requirement.

 
stephen_xue
Active Participant
0 Kudos
not sure what error you encountered.

check if this one helpfully it works for you.

2575582 - OData/SuccessFactors adapters: java.net.URISyntaxException: Illegal character in query
former_member771801
Discoverer
0 Kudos
Hi Stephen ,

 

Thanks a lot for your response on the csrf token .

Could you please provide some feedback on the below 2 points.

 

  • Please provide some detail on how to perform the model operation , in the SAP PO Odata adapter (Note: considering there is no CPI available in our Landscape ).Please provide the link to perform the steps.


 

  • Is it mandatory to have the Eclipse installation with HCI plugins to perform the Operation modelling as per the blog (https://blogs.sap.com/2017/01/10/consuming-gateway-odata-service-with-odata-adapter/)


 

Thanks for your help in advance !

 

Regards ,

Mahasweta Acharya

 

 
stephen_xue
Active Participant
0 Kudos
Hi Mashsweta,

you do not have to have a CPI account. whereas you need to install an eclipse with the HCI plugins to generate the OData Adapter's query string.  hope it helps you. 🙂
Labels in this area