1

We are using SAP S4HANA SDK Springboot archetype to build the application in SCP Cloud Foundry.

The requirement is to fetch the OData services from the SAP S4HANA and expose them to the Fiori UI frontend in the form of OData.

From the Java web services, we are getting the responses in JSON format: Sample JSON response

Output what I need is in the below oData format.

oData Format

This is one of the services and the same should be made available to all the java rest services. Found out Apache Olingo for converting it into odata format. But wanted to know if there is any method class in SAP SDK which supports this.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Arun Kumar
  • 133
  • 8
  • Unfortunately, your question is very unspecific. What is "the application"? What exactly are you trying to achieve? where are you getting data from? what format do you expect?... – Dennis H Jul 17 '19 at 15:05
  • The application is build using s4 hana sdk archetype in SAP Cloud foundry. The requirement is to fetch the data by using odata services from the SAP S4 HANA on premise system to our Java springboot, deployed in SCP CF which we have achieved. Now, we are exposing a java services to our fiori UI. Currently, the java services response is in JSON format. We would like to understand if there is a way to make the responses to an oData format? This would help ease the fiori UI bindings. – Arun Kumar Jul 18 '19 at 04:58
  • Okay, understood. Can you give a concrete example of how a payload looks compared to how it should look like? Because I'm still confused by "OData format". The OData protocol supports both JSON and XML, and I don't know what Fiori/UI5 expects as format (I would've expected JSON tbh). So a concrete example would help to understand the problem. – Dennis H Jul 18 '19 at 07:12
  • Thanks for the reply, oData is a different protocol and it is a way to create RESTful web services. One sample oData format is below https://services.odata.org/V2/Northwind/Northwind.svc/$metadata. Fiori UI supports Odata and JSON but our requirement is to use oData format. – Arun Kumar Jul 18 '19 at 09:26
  • 1
    Can you please provide an example that is **specific to your application**? I.e. please update your question with **what your currently get** and **what you expect to get**. (I know what OData is, but "OData format" is not a specific enough term to find out how to help you) – Dennis H Jul 18 '19 at 10:28
  • This is the sample JSON responses coming from SAP cloud foundry services : [{ "customerName": "Carl", "saNo": "3001011" }, { "customerName": "RCO ", "saNo": "3001012" }, { "customerName": "Techniplas", "saNo": "3001013" } ] – Arun Kumar Jul 18 '19 at 12:28
  • 1
    @Arun Kumar, be so kind and enhance your question above with more details. Putting the details in the comments might not be obvious for everyone. Furthermore, pls tell us how the JSON you provided looks like in what you call OData format. Thanks – Emdee Jul 18 '19 at 12:49
  • @Emdee, Sorry...I have edited it – Arun Kumar Jul 19 '19 at 05:17
  • 1
    @Arun Kumar: Thanks for editing. I do see that your first screenshot shows data in JSON format, while the second screenshot shows XML. Thus, I guess what you mean as OData format is the same as XML. Is that a correct implication? – Emdee Jul 19 '19 at 05:21
  • Not exaclty...OData is based on REST and Atom Protocol.In OData , the URL purely takes care of everything. You just need to build the underlying Entity Models and implement runtime classes. OData is widely accepted and in SAPUI5 the consumption of an OData service is at ease just by invoking the URL, while the same consumption using a webservice requires lots of implementation effort.Since Odata is light weight and can be used for CRUD operations – Arun Kumar Jul 19 '19 at 07:16
  • @Arun Kumar: To me it looks that you compare different things here which cannot be compared, IMHO. The thing is the first screenshot shows also a server response from an OData service, just in JSON format. The second screenshot shows the same, just in XML serialization. However, Dennis H already pointed out how you can continue. – Emdee Jul 19 '19 at 07:21
  • always put code and sample in text format, not in pic – Suncatcher Apr 21 '20 at 10:50

1 Answers1

2

There are several possibilities to solve that problem:

  1. You can fake it, i.e. manually translate all the results into XML yourself just enough so that UI5 accepts it.
  2. You can expose an OData service from your backend using the SAP Cloud Platform SDK for Service Development (that is already modeled as a dependency of the SAP Cloud SDK). You can find information on how to do that here and also here.
  3. Have you considered calling the OData service from your frontend directly?
Dennis H
  • 589
  • 4
  • 10