cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to use Batch operation of SAP HANA Service layer for multiple transaction in one request

Former Member
0 Kudos
9,336

How to use Batch operation of SAP HANA Service layer for multiple transaction in one request

Accepted Solutions (0)

Answers (4)

Answers (4)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi Rahul,

Service Layer supports executing multiple operations sent in a single HTTP request through the use of Batch Operations. Refer to the "Service_Layer_Documentation" which shows how you can use Batch Operations using Service Layer.

Below is an example to Create Multiple Business Partners in a Single HTTP Request Using Service Layer Batch Operations:

1. Batch Request Headers:

In the Header, you must set the key “Content-Type” with the value as multipart/mixed;boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77c. The boundary is arbitrary, pick whatever you want. Just make sure you use it as the same on the body of your request.

2. Batch Request Body:

The body of a batch request consists a series of individual requests and change sets, each represented as a distinct MIME part, and separated by the boundary defined in the Content-Type Header.

The HTTP request is provided in the attached "HTTP Request.txt" file.

http-request.txt

Hope it helps!

Kind regards,
ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

Dear Ankit,

I have tried This above solution but its getting Error Like Bad Format

Please find attached file for Body data.

--------------------------------------Error----------------------------------

--batchresponse_G0EL122V-s4WZ-H30t-Fyzb-WwhFQ4ckSEWJ

Content-Type: application/http

Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request

Content-Type: application/json;charset=utf-8

Content-Length: 129

{

"error" : {

"code" : -1,

"message" : {

"lang" : "en-us",

"value" : "BadFormat"

}

}

}

--batchresponse_G0EL122V-s4WZ-H30t-Fyzb-WwhFQ4ckSEWJ--

----------------------------------Header------------------------------------------

Content-Type - multipart/mixed;boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77c

----------------------------

Please suggest solution for same.

Thanks and Regard.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rahul,

Make sure that you have selected the Content-Type Header value correctly. Also we are using the POSTMAN app to check the request.

If you are using some other application, then please make sure the equivalent options are selected.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member

The http-request is missing a line break and should be probably like this:

--batch_36522ad7-fc75-4b56-8c71-56071383e77c
Content-Type: application/http 
Content-Transfer-Encoding:binary

POST /b1s/v1/BusinessPartners

{"CardCode":"TestBatch004", "CardName":"Test Batch 01", "CardType": "C"}

--batch_36522ad7-fc75-4b56-8c71-56071383e77c

Content-Type: multipart/mixed;boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd
--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd
Content-Type: application/http 
Content-Transfer-Encoding: binary 
Content-ID: 1 

POST /b1s/v1/BusinessPartners

{"CardCode":"TestBatch005", "CardName":"Test Batch 02", "CardType": "C"}

--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd--
--batch_36522ad7-fc75-4b56-8c71-56071383e77c--

This still results in a "Bank account is missing" error in my demo system, but at least the request's format seems to be okay.

Former Member
0 Kudos

And if you're new to using Postman, make sure that you enter value for content-type in the "value" field and not in "description". If there is no "value" field click on "..." to select it.

tenluis2
Member
0 Kudos

Hi, this is working in postman perfectly, but I need to do this with C#. Do you have any example in C#?

Robin-Feng
Participant
0 Kudos

Hi All,

One more question.

Is the batch operation like a DI transaction? (StartTransaction / EndTransaction)

BR

Robin

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rahul,

Please allow me some time to check it and come back to you.

Kind regards,

ANKIT CHAUHAN

SAP SME Support