Skip to Content
0

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

Mar 13, 2017 at 07:35 AM

543

avatar image

Hi,

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Mahesh kumar palavalli Mar 13, 2017 at 08:10 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Radek Chudziak Mar 13, 2017 at 09:22 AM
0

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)

Share
10 |10000 characters needed characters left characters exceeded