cancel
Showing results for 
Search instead for 
Did you mean: 

Insert multiple records with batch - Gatewy Netweaver

Former Member
0 Kudos

Hi Experts,

I have done some posts for understood the functionality batch. But I can't understand how can I insert many records from sapui5 for sap gateway netweaver

I have the following scenario:

The users create items and this items need to be sent for sap gateway netweaver to generate the request with an existent bapi.

My doubt is how can I send many records in same request and how can I read this inside sap gateway in method created ?  Can you please share a tutorial or explain me how can I do this ?

Thanks very much for your help.

Best Regards
Cristina Rodrigues

Accepted Solutions (0)

Answers (3)

Answers (3)

arshad_ansary2
Active Participant
0 Kudos

Hi Cristina,

The batch operation in GW is used for sending multiple update or retrieve operations in one request .Update can be POST or a PUT .In your case it is POST operation for multiple Items.

In your above example Item 1,Item 2 and Item 3 belong to a Changeset (say changeset 1 ) inside a request.The concept of changeset is that  all the operations should be succesful or none should be succesful.For eg if Item 2 post fails it shud rollback item 1 post and shud not continue with Item 3 post. ..

Coming to how this request 1 is handled in the GW framework class, This request will first call the CHANGESET_BEGIN of the correspoding DPC_EXT class and then then it will call in a loop the CREATE_ENTITY method of the ITEM (in your case 3 times) and then finally it will call the CHANGESET_END method.

I think your backend API interface  can accept the items in mass and do the post for all the items. In that case , you redefine the CREATE_ENTITY of the ITEM entity to buffer the individual items to an internal table attribute MT_ITEM and finally in the CHANGE_SET_END method you call the backend AP with MT_ITEMS I to persist the change ..

BR

Arshad

former_member227918
Active Contributor
0 Kudos

Hi Cristina,

Please check below link, that may help you.

And, in gateway you will get records one by one, In case you need, set a breakpoint in back end for batch operations, just set a break point in method CHANGESET_BEGIN or CHANGESET_END.

Regards,

Akhilesh

Former Member
0 Kudos

Hi Akhilesh,

I saw this tutorial but anyone explain what I need to in method created and if I need make any change in methods CHANGESET_BEGIN and CHANGESET_END.

My question is , what is necessary to do in methods created , CHANGESET_BEGIN and CHANGESET_END for put the items I need in a table , but read one by one from http request ? For me is a little confused.

Because from what I understand is that the gateway can read many records but I don't know if this records need to be separated.

Thanks very much

Best Regards,
Cristina Rodrigues






former_member227918
Active Contributor
0 Kudos

Hi Cristina,

No need to write any code in methods CHANGESET_BEGIN and CHANGESET_END,  just need to redefine it. And yes its of http request only, which is separated by gateway only, No need to be separated manually.

Please check below link, might be helpful.

Regards,

Akhilesh

0 Kudos

Hi Cristina,

CHANGESET_BEGIN and CHANGESET_END are usually used for transaction handling.

You can set some flag in CHANGESET_BEGIN, for example mv_changeset = abap_true.

In CREATE_ENTITY you should avoid commits if mv_changeset is true.

And in CHANGESET_END you can do commit.

AshwinDutt
Active Contributor
0 Kudos

Hello Cristina,

What is the operation you are doing ? POST ?

Regards,

Ashwin

Former Member
0 Kudos

Hello Ashwin ,

Yes, I want to do the operation post.

Best Regards,

Cristina