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.
Showing results for 
Search instead for 
Did you mean: 

Hello Fellow SCNers,

I am writing this blog to demonstrate an example of how we can use Hybrid Odata in our Backend Developments for a POST(create) scenario.

This demonstration uses NetWeaver Gateway Foundation 7.4 SP 0008.

What is Hybrid OData?

Generally when we need to create/post multiple data records in a single backend table(like create multiple Sales Orders, multiple Purchase Orders, etc.) we use a 'Batch' and encapsulate multiple POST request payloads in it. When there are few records say around 1K then also due to huge data traffic the UI user can sense the latency in processing. Imagine what will be the case when its something like mass creation on materials, users, etc. in the system where data records can easily exceed by at least 10 times.

For such cases we can also explore the Hybrid OData development approach. It means sending the huge data (may be an entire file contents with thousands of records) to a single string property in an OData entity. This can be done by stringifying the data from file into JSON format and sending. Then a single POST on this entity can create all the records.


Scenario: Here I have a flat file which has user details which the end user can upload from user interface and at backend the users (records from that file) should be created. They should be visible in SU01 transaction. Also for every user we need to assign/revoke authorizations for multiple applications.

OData Service -

Create a service (here ZCDP_ASSESSMENT_MANAGE_USERS).

Create an entity(here UserUpload)

The entity has a single property of data type 'String'. This will hold the stringified JSON sent from user interface.This is shown below-

The corresponding data dictionary structure is (here ZCDP_ASSMNT_S_USER_DET) is

Now one needs to read this Stringified JSON data and convert its contents to Internal Table so that further processing can be undertaken.

This can be done by using Transformations (

Code as below -

In the Data Provider Extension Class, in the Create method of entity code as

The data should look like below in debug mode -

[I will give payload details below]

Till this step we have read the data sent from UI. Now as mentioned we need to convert this to the Internal table so that normal ABAP processing can be done.

The type ZCDP_ASSMNT_S_USER_LIST will be shown below.

Now we will see the parsed data in debug mode. Also, I have used a nested scenario that is every user record has multiple applications records whose access can be given/withdrawn from the user.

and nested table contents for a user

The actual table structures used above is ZCDP_ASSMNT_S_USER_LIST shown below

and nested table structure is

Post this all the contents in an internal table and normal ABAP processing can be done.

In case one needs to re-convert the internal table to stringified JSON and pass to UI, use below transformation code -

Declare the object of XML Writer class

Instantiate the object

Do the reverse transformation and parse the internal table into XString.

Then convert the XString to a string and pass back to UI.

*--------------------------------------------------------------------- That's It Folks -----------------------------------------------------------------*

The Payload used for testing is


"UsersDetails": "{\"USER_DET\":[{\"BNAME\": \"EMP9000\",\"MANAGER\": \"ABCD111\",\"KOSTL\": \"1100110011\",\"T_LEVEL\": \"EMP\",\"FIRSTNAME\": \"Employee\", \"LASTNAME\": \"9000\",\"FULLNAME\": \"Employee9000\",\"SMTP_ADDR\": \"EMP9000@DUMMY.COM\",\"LOCATION\": \"GURGAON\",\"DISABLED\": \"X\",\"PROCESSING_STATUS\": \"\",\"ERROR_TEXT\": \"\",\"APPLICATIONS\": [{\"BNAME\": \"EMP9000\",\"APP_ID\": \"MANAGE_CATEGORIES\",\"APP_MODE_INDICATOR\": \"X\",\"PROCESSING_STATUS\": \"\",\"ERROR_TEXT\": \"\"},{\"BNAME\": \"EMP9000\",\"APP_ID\": \"ASSIGN_EVALUATORS\",\"APP_MODE_INDICATOR\": \"X\",\"PROCESSING_STATUS\": \"E\",\"ERROR_TEXT\": \"Error ASSIGN_EVALUATORS\"}]},{\"BNAME\": \"EMP9901\",\"MANAGER\": \"ABCD111\",\"KOSTL\": \"1100110011\",\"T_LEVEL\": \"EXE\",\"FIRSTNAME\": \"Employee\", \"LASTNAME\": \"9901\",\"FULLNAME\": \"Employee9901\",\"SMTP_ADDR\": \"EMP9901@DUMMY.COM\",\"LOCATION\": \"GURGAON\",\"DISABLED\": \"X\",\"PROCESSING_STATUS\": \"\",\"ERROR_TEXT\": \"\",\"APPLICATIONS\": [{\"BNAME\": \"EMP9901\",\"APP_ID\": \"MANAGE_CATEGORIES\",\"APP_MODE_INDICATOR\": \"X\",\"PROCESSING_STATUS\": \"\",\"ERROR_TEXT\": \"\"},{\"BNAME\": \"EMP9901\",\"APP_ID\": \"ASSESSMENT_RESULTS\",\"APP_MODE_INDICATOR\": \"X\",\"PROCESSING_STATUS\": \"E\",\"ERROR_TEXT\": \"Error in user 2 ASSIGN_EVALUATORS\"}]}]}"


* Points to note - The double quotes is a special character in JSON and it needs to be escaped. This is done by backslash character(\).

Hope this infuses some new development ideas. Looking forward for valuable feedback.