cancel
Showing results for 
Search instead for 
Did you mean: 

Can we insert multiple records using create Operation in OData ??

Former Member

Hi,

I'm trying to insert multiple records using create Operation (CREATE_ENTITY) in OData. Is it possible? Please explain with detailed steps

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor

Hi Venkatesh,

It is possible to insert multiple records in one go as mentioned in below ways:

1. If you use deep create funtionality, you can insert multiple child items at a time in single call(pass the data to odata service as an array).

2. Lets say you want to insert multiple header data at a same time, then simple loop on those items and call the odata create, update or delete operations(assuming you are using V2 odata model). Then a batch call will be sent to backend and in the backend if the changeset process is implemented, you can see all the insert records at a time and you can write your db logic there.

you can google or search in scn blogs for Deep create and Change set process and implement the same easily.

Best Regards,
Mahesh

Answers (1)

Answers (1)

Former Member

As Mahesh said just call oModel.create(); in a loop and if you are using v2 model it will take care of the batch operations automatically. You can also do that explicitly by setting deffered groups and then using oModel.submitBatches();. On the gateway side you have to redefine CHANGESET_BEGIN and CHANGESET_END methods and make sure there is no COMMIT WORK inside your CREATE entity method otherwise it will fail.

Use create deep entity if you want to create a header along with its items (e.g. Purchase order header + Purchase order items in one go)