Efficient Data Retrieval using in SAP ISCI with Adapter
Efficient Data Retrieval using in SAP ISCI with Adapter
HTTP Adapter
Introduction:
What is Pagination?
Pagination is the process of dividing large data sets into smaller chunks (pages) to be
retrieved incrementally. This approach prevents excessive memory usage and reduces
the risk of timeouts or errors when processing large volumes of data.
Use Case:
In many cases, SAP CI provides a standard OData adapter that supports pagination.
However, there are scenarios where the source application, such as a database,
imposes restrictions and only allows HTTP calls from outside the network. Due to this
limitation, the standard OData adapter cannot be used directly. Instead, a customized
pagination approach is implemented in SAP CI to handle data retrieval efficiently. This
blog demonstrates how to achieve this using the HTTP adapter.
o Begin by making an initial HTTP call to retrieve the total count of records
from the database.
o Use the count query provided by the database team to fetch the total
count records information.
Example response: {
"TotalRecCount": 50000
}
Use a Groovy script to calculate the number of pages required to retrieve all
records based on the total count and records per page.
In this example, let’s assume the total count of records is 50,000 and the source
application can process 2,000 records per page. The script calculates the page
count by dividing the total count by the records per page and then rounding up to
ensure all records are retrieved.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.lang.*;
In this scenario:
The script ensures all records are retrieved by calculating and rounding up the page
count.
Configure the loop condition to continue until the Pagenumber is less than or
equal to the PagingLoopCount
Example configuration:
This ensures that the process continues to loop and retrieve data until all pages are
processed.
Local Integration process:
This local integration process works to retrieve the actual data from the database
in a looping mode. First, it will retrieve the page 1 data using the data query.
Once the data is retrieved, as per the given script, it will increment the
Pagenumber by +1 for every looping call.
import com.sap.gateway.ip.core.customdev.util.Message;
{(PageNumber:${header.Pagenumber},pageSize: ${header.RecordsPerPage}}
The Pagenumber and RecordsPerPage headers will be parsed into the actual data
query to pull the managed data from the database, ensuring compatibility with the
source application.
Conclusion:
Pagination is a powerful and essential technique to manage and process large data sets
efficiently in SAP CPI. This blog demonstrated how to implement customized pagination
using the HTTP adapter, addressing the limitations of standard OData pagination when
direct HTTP calls are required by the database. By leveraging Groovy scripts for
dynamic page calculations and loop management, you can:
With this approach, enterprises can streamline data retrieval processes, optimize
system performance, and scale their integration solutions.