cancel
Showing results for 
Search instead for 
Did you mean: 

Batch service passing multiple values as filters

former_member227510
Participant
0 Kudos

Hi,

Service call : /sap/opu/odata/sap/ZEMPS_SRV/$batch

My request is

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/xml

GET ztotal_EmpSet/?$filter= StartDate+eq+'24.08.2016 00:00:00'+and+EndDate+eq+'28.08.2016 23:00:00'+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'EMP1' HTTP/1.1

--batch--

The debugger is going into the get_entityset method, but

it_filter_select_option is empty.


How do I get these filter values?

Regards,

Gopa

Accepted Solutions (1)

Accepted Solutions (1)

former_member227510
Participant
0 Kudos

If this works,

My actual requirement is to pass multiple employee ids, and multiple units... in the same batch

Based on the combination, I have to filter and get the output in my backend and pass the final filtered values along with their details to the front end.

Regards,

Gopa

AshwinDutt
Active Contributor
0 Kudos

Hello Gopa,

The reason why filters are blank because i see there is an extra space between $filter Keyword and the parameters. See the highlighted in Red as below. So you need to remove the space and then it works.

However date value is also going wrong and it should go as below ( highlighted in yellow ).

Using OR operator you can send multiple values as below.

Regards,

Ashwin

former_member227510
Participant
0 Kudos

Hi Ashwin,

Thanks for the multiple values query.

However, I tried removing the space earlier itself, it was giving error.

' invalid token detected at position number 24 ' in the error log.


Without the date fields it's working fine now. I am getting the filter values. So I am seeing the datetime field passing.

After doing the complete change with datetime, it is giving the error.

Invalid parametertype used at function 'eq' (Position: 11) in the error log.

Below is the new query

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/xml

GET ztotal_EmpSet/?$filter=StartDate+eq+datetime'2016-08-24T00:00:00'+and+EndDate+eq+datetime'2016-08-28T23:00:00'+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'1' HTTP/1.1

--batch--

Regards,

Gopa

AshwinDutt
Active Contributor
0 Kudos

Sorry i am unable to get whats the exact issue now. For which Parameter & Value you are facing the issue ?

Can you please explain again ?

former_member227510
Participant
0 Kudos

I just checked the entity type.

StartDate and EndDate both are of type string i.e. edm.string not datetime..

I am getting all the five values in the filter if I pass the get like...

GET ztotal_EmpSet/?$filter=StartDate+eq+'24.08.2016T00:00:00'+and+EndDate+eq+'28.08.2016T23:00:00''+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'1'HTTP/1.1

However, I want to pass the Start date as 24.08.2016 00:00:00 with a space as a string using something like

GET ztotal_EmpSet/?$filter=StartDate+eq+'24.08.2016 00:00:00'+and+EndDate+eq+'28.08.2016 23:00:00''+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'1'HTTP/1.1


So the batch request is not taking the space here.


Can you tell me how can I pass the date as a string with space?


Gopa



AshwinDutt
Active Contributor
0 Kudos

I would recommend to use Edm.DateTime only for Date fields in the GW model.

Answers (2)

Answers (2)

former_member227510
Participant
0 Kudos

Hey Ashwin,

Can you give me an example as to how to call a batch request for POST in UI5 for the below:

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/xml

GET ztotal_EmpSet/?$filter=StartDate+eq+datetime'2016-08-24T00:00:00'+and+EndDate+eq+datetime'2016-08-28T23:00:00'+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'1'HTTP/1.1

--batch--

Any link would also be helpful.

Regards,

Gopa

former_member227510
Participant
0 Kudos

Thank you Ashwin.

I used Edm.DateTime instead of string and getting the required data in the filters.

The following thread also tells about the standard ways to do it.

Regards,

Gopa

former_member227510
Participant
0 Kudos

Hi,

Can we pass a batch request to get_expanded_entityset?

Regards,

Gopa

AshwinDutt
Active Contributor
0 Kudos

Yes can be done.