cancel
Showing results for 
Search instead for 
Did you mean: 

$Batch read using Function Imports - Odata

Former Member
0 Kudos

Dear Experts,

I can able to perform multi read using $Batch.

For Ex :  SurveyEmpSet - Entity Set Name

GET SurveyEmpSet(EmpId='12345',EmpName='Test Emp1') HTTP/1.1


GET SurveyEmpSet(EmpId='45678',EmpName='Test Emp2') HTTP/1.1

But now I need the same for the function import to get output. What's the change I need to do in the above.

For Ex:  ContList is the Function Import Name.

/sap/opu/odata/sap/ZTEST_SRV/ContList?Lang='E'

/sap/opu/odata/sap/ZTEST_SRV/ContList?Lang='A'

Regards,

Srinivasan K

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Srini,

Refer the below to know how Function Import can be implemented.

Firing the service with BATCH payload is same as you did for READ. Only change is you need to use the Function Import URL in the payload instead of READ URL which you have already mentioned.

Regards,

Ashwin

Former Member
0 Kudos

Hi Ashwin,

I tried the same way. But its not hitting the execute action method.

I tried the below.

URL : /sap/opu/odata/sap/<Service Name>/$batch

Content-Type : multipart/mixed; boundary=batch

Http Method : Post

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

GET <Function Import Name>?Lang='E' HTTP/1.1

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

GET <Function Import Name>?Lang='E' HTTP/1.1

--batch--

Please correct the above. So that I will try again.

Regards,

Srinivasan K

AshwinDutt
Active Contributor
0 Kudos

Hello Srini,

It should trigger.

You will get 2 separate calls.

Check the format of the payload.

Below is just a sample for your reference ->

Model ->

Implement Execute Action Method in DPC_EXT class.

URL ->

/sap/opu/odata/sap/<Service_Name>/$batch

Header ->

Method : POST

Content-Type : multipart/mixed; boundary=batch

Payload ->

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

GET Test?A='XYZ' HTTP/1.1

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

GET Test?A='ABC' HTTP/1.1

--batch--

Run-time ->

Regards,

Ashwin

former_member204370
Participant
0 Kudos

Hi Aswin

I am trying to trigger a batch request for Function Import.

Though we specify "POST" method, the values should be appended to URL as you have created in the payload above.

The function import implementation works fine when called using callFunction of ODataModel.

But this seems to be difficult to trigger using batch. Did you try batch for function import?


Below is my SAPUI5 code.

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

var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/SAP/ZEMPLOYEES1_SRV/"); //CreateUser

  var data2 = {

  Userid: "134",

  FirstName: "Kumaraswamy",

  LastName: "Gowda",

  Country: "IN"

  };

  var batchChanges = [];

batchChanges.push( oModel.createBatchOperation("CreateUser", "POST", {urlParameters: data2 } ) );

//batchChanges.push( oModel.createBatchOperation("CreateUser", "POST", {method: "GET", urlParameters: data2 } ) ); //DID NOT WORK

//batchChanges.push( oModel.createBatchOperation("CreateUser", "GET", {urlParameters: data2 } ) ); //DID NOT WORK


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


OData Model:



Whatever the combination i try to add function import from batch, it does not create required payload format. I think, there should be a specific way to embed callFunction into batch. Otherwise, this does not seem to happen as the method should be mentioned as POST but the form values should be URL appended.


Let me know the work around in this case.


Thanks.

Answers (0)