This video discusses the use of the $batch query option in SAP Fiori applications. Here’s a summary of the key points:
- What is $batch?: The $batch query option allows multiple service calls to be combined into one, which can be useful when you want to retrieve or modify multiple sets of data in a single request. For example, if you want to retrieve data for two different sales orders, you can use $batch to do this in one call instead of making two separate calls.
- How to use $batch?: To use $batch, you need to use the POST method and pass a payload that includes the multiple service calls you want to make. The payload needs to follow a specific format, which includes defining the content type as “multipart/mixed” and specifying a boundary. Each individual service call is included within this boundary.
- Example of using $batch: The video provides an example of using $batch to retrieve data for two different employees from an OData service. The presenter demonstrates how to construct the payload for the $batch request, how to execute the request, and how to interpret the response.
- Creating a Fiori App using $batch: The video also shows how to create a basic SAP Fiori application that uses $batch to retrieve data. The presenter uses SAP Business Application Studio to create a worklist application that retrieves data for multiple employees using a single $batch request.
- Important points to remember: When using $batch, it’s important to remember to use the POST method, to format the payload correctly, and to include two line spaces after each query option in the payload. If these requirements are not met, the $batch request will not be successful.
- Debugging $batch requests: The presenter also demonstrates how to debug $batch requests by setting breakpoints in the backend system and examining the response to the $batch request. This can help you understand what’s happening when the $batch request is processed and troubleshoot any issues.