I see you’re using nested $expand which is causing the timeout. Let me break down the complete solution addressing all the optimization areas:
1. Implement Server-Driven Pagination
Modify your OData service to support pagination with $top and $skiptoken. Set a reasonable page size:
GET /sapi/opu/odata/sap/ZCONS_ELIMINATION_SRV/EliminationSet
?$filter=FiscalPeriod eq '03' and FiscalYear eq '2025' and CompanyCode in ('1000','1010','1020')
&$top=500
&$skiptoken='AQAAAxxxxxxx'
This returns a manageable dataset with a continuation token for the next page.
2. Use Batch API for Parallel Processing
Replace your single expanded query with a batch request that groups operations by legal entity clusters:
--batch_boundary
Content-Type: application/http
GET EliminationSet?$filter=CompanyCode in ('1000','1010','1020') HTTP/1.1
--batch_boundary
Content-Type: application/http
GET EliminationSet?$filter=CompanyCode in ('1030','1040','1050') HTTP/1.1
--batch_boundary--
Process 10-15 entities per batch request to keep payload size under 10MB.
3. Configure BTP Timeout Settings
In BTP Cockpit:
- Navigate to Connectivity → Destinations → Your consolidation service
- Set Timeout: 600000 (10 minutes for batch processing)
- Add Additional Property: sap-client with your client number
- Enable “Use default JDK truststore” if using HTTPS
For the backend OData service itself, adjust the ICM timeout parameter in transaction SMICM or via profile parameter icm/server_port_ timeout setting.
4. Optimize Filter Strategy
Add selective filters to reduce dataset before expansion:
$filter=FiscalPeriod eq '03'
and FiscalYear eq '2025'
and CompanyCode in ('1000','1010')
and ConsolidationLedger eq 'L1'
and EliminationStatus eq 'POSTED'
&$select=EliminationID,CompanyCode,Amount,Currency
Remove the double $expand entirely. Instead:
- First call: Fetch EliminationSet with basic fields
- Second call: Use $batch to retrieve ToIntercompanyDetails for all EliminationIDs
- Third call: Fetch ToJournalEntries separately
This approach reduced our month-end consolidation API processing from timing out to completing in 4-6 minutes across 50+ entities. The key is breaking the monolithic query into paginated, filtered, batched operations that stay within timeout thresholds while maintaining data consistency.
Implement these four strategies together - pagination handles large datasets, batch API enables parallel processing, BTP timeout config provides buffer room, and filter optimization reduces unnecessary data transfer. Monitor the BTP application logs to track actual response times per batch and adjust page sizes accordingly.
This draft is based on general SAP S/4HANA knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.