cancel
Showing results for 
Search instead for 
Did you mean: 

Deep insert post in SMP with Sapui5(sap mobility)

arkabasu007
Discoverer
0 Kudos

I have build a native hybrid app with sapui5 along with cordova kapsel plugin. I have implemented deep insert while posting create operation.

I am using header + line item and then posting it.

It is working fine in online mode but in offline mode it is giving error from smp :

[-10213] Deep inserts to entity sets are not supported

I read deep insert is not supported in offline mode.

What is the alternative for it is there any other way for post(create) operation in offline mode other than deep insert.

What are the changes needed for it . I have been trying a lot. How can I post what are changes needed from sapui5 and odata/abap

Please somebody give some suggestion

grabz
Employee
Employee

Hi Arka,

There are certain limitation with deep inserts, which can be read here: Limitations with Deep Inserts

Other than that you can use Content-Id referencing in a batch. You can use the online library's method:

public void createEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)

Where you add the header "Content-ID"

This is the OData.org doc about it (search for: 2.2.1. Referencing Requests in a Change Set): Batch Processing (OData Version 2.0)

These are great SAP Blogs about the usage of it:
Introduction: OData $batch Processing with Content ID in SAP Gateway
Creating hierarchical data using Content-ID Referencing in a Change Set (Batch Request) in hybrid ap...

And last but not least there might be some server side changes needed in the app config file (search for content_id_header_location): Application Configuration File

Let me know if you have further questions. Regards,
Ákos

View Entire Topic
0 Kudos

Hi Arka,

there is a better work-around to the one suggested by sap. It works very well in my last project which contains lots of multi-level deepinsert entities. And in this solution, you can keep your deep model and no need to split it into flat entities. Here is the general idea:

For example, you have several DeepInsert Entity in your GW project. One called ProductSet.

You define an Entity DeepInsertInput that contains a name and body properties (string). In the UI, you encode (e.g. base64) the deepinsert json and post it to this entityset. The reason for encoding is to be enable to pack that json payload inside another json. The payload looks like this:

{
"name": "ProductSet", //name of your DeepInsert Header Entity
"body": "YLKJlXYjx" //encoded string of the JSON payload
}

In the create() method of the gateway, you decode the body and get the json string. And send it to the orignial Entity using it as json payload using HTTP Post request in ABAP. In this example, it will be:

HTTP: Post
URL: http:\\<url GW odata service>\ProductSet
body: decoded json of the deepinsert payload

That mean, you first use this DeepInsertInput Entity just for forwarding the deepinsert payload. Then, the GW send it to himself.

I hope I have explained it clearly.

May be next time I should write a blog about how to implement it in detail, and share some code.

former_member471063
Discoverer
0 Kudos
Haolin Zhi: you are saying creating a separate Entity Set with 2 properties name(containing the original entity set) and body(containing the base64 format of the original payload with header and line item).
0 Kudos

Hi Samrat, exactly. You can reuse that EntitySet for different DeepInsert Entities within your GW project.

former_member471063
Discoverer
0 Kudos

This will work for offline also as well as for online?

arkabasu007
Discoverer
0 Kudos

Ok i am trying this.