Up to 80% faster SAP reporting through autonomous agentic AI
AI agents autonomously optimized high-impact SAP ABAP reports for one of India's largest cement manufacturers, eliminating database bottlenecks, reducing runtime by up to 80%, and restoring production stability without altering business logic or output.
Client's critical SAP reports were timing out or running for minutes, creating serious performance bottlenecks and business risk.
Our client operates one of India's most complex SAP landscapes, with hundreds of custom ABAP programs spanning sales and distribution, finance, procurement, and logistics. Several programs, including e-invoice and e-bill detail reporting, customer credit risk and sales reporting, and invoice exception reporting, had become serious operational bottlenecks.
Each program shared the same root cause: ABAP written for smaller data volumes and older database architectures. SELECT SINGLE statements fired inside tight loops over thousands of records. Repeated calls to BAPI_USER_GET_DETAIL fetched the same user master data on every iteration. Linear table scans ran where indexed binary search was possible. Temporary tables accumulated memory without being released.
With S/4HANA migration in progress and the 2027 ECC sunset approaching, these programs needed to be HANA-ready, and manual remediation across all three was estimated to take months of scarce ABAP developer time.
“The optimized programs delivered exactly the same results but in a fraction of the time. What would have been a high-risk manual exercise was completed safely without disrupting production workflows.”
Automated ABAP Optimization with Zero Functional Risk
Sookti AI deployed autonomous agents to perform end-to-end code optimization with the objective of improving runtime performance, database efficiency, and memory usage, without altering existing business logic or functional output.
The scope of work included identifying and remediating performance bottlenecks such as database access inside loops, inefficient internal table access patterns, redundant function module calls, and delayed memory cleanup.
Through deep static analysis, the agents detected performance anti-patterns across all three programs and systematically transformed each one without manual production intervention or introducing regression risk.
Each program progressed independently through analysis, structural refactoring, automated regression validation, and documentation generation. Functional parity was verified against the original source clone prior to delivery.
Across all programs, the agents:
Data-driven improvements measured on live DEV 300 production workloads. Results below represent a subset of optimized programs from a broader SAP performance initiative.
Validation Methodology
For accurate benchmarking, source clones of the original programs were executed under identical DEV 300 workload conditions. Runtime measurements were captured using SAP Runtime Analysis (SAT), and optimized versions were validated against their respective source clones to confirm 100% output parity.
All optimizations were strictly technical enhancements and no changes were made to business logic, calculations, or functional behavior. The deployment introduced zero regressions and required no manual ABAP intervention.
SAP Runtime Analysis (SAT) DEV 300

Program 1, 42s to 17.6s (58% faster)

Program 2, 21.6s to 4.3s (80% faster)

Program 3, 37.4s to 15.5s (59% faster)
As a result, the transformed programs now deliver improved scalability, faster runtime performance, and enhanced memory efficiency, making them suitable for high-volume datasets and stable background execution in production environments.
Economic Impact
Compared to traditional manual ABAP optimization (estimated 1 FTE per 2–3 objects per month), the AI-driven approach enabled large-scale optimization at a fraction of the time and cost. Estimated cost savings exceeded 80–90% compared to conventional remediation models.
What Changed: From SELECT SINGLE inside loops to FOR ALL ENTRIES with Binary Search
Agents identify every instance of repeated database access inside loops and refactor them to a single bulk fetch with sorted binary search, delivering O(log n) lookup performance regardless of dataset size. The same pattern was applied consistently across all programs with zero exceptions.
PROGRAM 1 — ZRSD_EBILL_EINV_DETAILS (ZSD1062)
20 optimizations. 42s → 17.6s. 58% faster.| LINES | OPTIMIZATION | REASON |
|---|---|---|
| 382–407 | VBFA SELECT SINGLE → FOR ALL ENTRIES | Eliminated N DB calls inside loop; replaced with single bulk fetch and in-memory lookup |
| 392–397 | SORT L_TAB_VBRK BY VGBEL + binary search | Ensured sorted table before binary search for correctness and performance |
| 400–407 | VBFA lookup via READ TABLE ... BINARY SEARCH | Replaced database access with fast in-memory lookup for better scalability |
| 419 | FREE it_tsyrws | Released VBFA preload table after last usage to reduce memory footprint |
| 429–437 | VBAK ERNAM preload via FOR ALL ENTRIES | Eliminated repeated SELECT SINGLE calls on VBAK inside processing logic |
| 433–435 | SORT it_xfv5uf + DELETE ADJACENT DUPLICATES | Prepared unique, sorted lookup table for efficient binary search |
| 675–682 | Binary search lookup for VBAK ERNAM | Replaced database access with in-memory lookup to improve runtime |
| 438–446 | EKKO ERNAM preload via FOR ALL ENTRIES | Avoided repeated DB access to EKKO by bulk-fetching purchasing document owners |
| 443–445 | SORT it_h6fe8f + DELETE ADJACENT DUPLICATES | Ensured unique and sorted entries for binary search usage |
| 702–710 | Binary search lookup for EKKO ERNAM | Improved performance by avoiding DB reads inside loop |
| 447–475 | USR21 + ADRP user master preload | Reduced dependency on repeated BAPI_USER_GET_DETAIL calls by caching user master data |
| 476–523 | Email resolution via ADR6 with priority handling | Deterministic, efficient email selection avoiding repeated database calls |
| 525 | FREE lt_all_emails | Released temporary email lookup table after usage to optimize memory. |
| 527 | SORT lt_user_contact BY bname | Ensured sorted user contact table for binary search during user lookup. |
| 669–671 | SORT IT_CODMAST_IDS + binary search | Optimized repeated lookups by ensuring correct binary search usage. |
| 788–801 | SORT IT_DOCTYPE + binary search | Improved pending-invoice processing performance by optimizing table access. |
| 860–865 | SORT IT_RMC_INV + binary search | Optimized e-way bill related lookups by replacing linear scans. |
| 953–955 | FREE IT_RMC_INV | Released RMC invoice table after last usage to reduce memory consumption. |
| 1502–1504 | FREE L_TAB_VKORG | Released authorization validation table after completion of auth checks. |
| 1528–1530 | FREE L_TAB_FINAL2 | Freed FAE driver table in GET_PENDING_INV after data extraction. |
PROGRAM 2 — zhrsd947 (ZSD206)
21 optimizations. 21.6s → 4.3s. 80% faster.| LINES | OPTIMIZATION | REASON |
|---|---|---|
| 389–393 | SORT it_rpmkr BY kunnr + binary search | Ensured sorted table before binary search for correctness and performance |
| 403–409 | SORT it_rpmkr BY kunnr rpmkr + binary search | Enabled efficient deterministic lookup during repeated reads inside loop |
| 729–735 | risk_class SELECT SINGLE → FOR ALL ENTRIES | Avoided repeated DB access by preloading risk class data in a single call |
| 733–735 | SORT it_efxjg + DELETE ADJACENT DUPLICATES | Ensured unique partner entries and prepared table for binary search |
| 738–757 | Unique partner + segment list build | Eliminated redundant partner-segment combinations; reduced repeated function calls |
| 759–767 | Pre-read partner and segment lists before function | Reduced function module overhead by passing unique values only |
| 774 | FREE lt_pairs, lt_partner, lt_segments | Released temporary helper tables after last usage to reduce memory footprint |
| 783–791 | risk_class binary search lookup | Replaced DB calls inside loop with reads from preloaded internal table |
| 812 | FREE it_efxjg | Freed preload table after last usage to release memory early |
| 996–1002 | altkn SELECT SINGLE → FOR ALL ENTRIES | Eliminated repeated DB calls for customer alternate key retrieval |
| 1000–1001 | SORT it_bknib8 + DELETE ADJACENT DUPLICATES | Ensured correct and efficient binary search lookup |
| 1011–1014 | Binary search lookup for altkn | Replaced database access with fast in-memory lookup |
| 1022 | FREE it_bknib8 | Released lookup table after final usage to reduce memory |
| 1031–1037 | KNA1 name1 + zzfinance_scheme → FOR ALL ENTRIES | Prevented repeated KNA1 reads by bulk-fetching customer master data |
| 1035–1036 | SORT it_w8extk + DELETE ADJACENT DUPLICATES | Prepared lookup table for efficient binary search |
| 1046–1050 | Binary search for customer name and finance scheme | Improved runtime by replacing DB reads with internal table lookup |
| 1058 | FREE it_w8extk | Freed customer master preload table after usage |
| 1139–1145 | oitol SELECT SINGLE → FOR ALL ENTRIES (T691F) | Eliminated repeated DB access to T691F during loop execution |
| 1142–1143 | SORT it_yvvk9o + DELETE ADJACENT DUPLICATES | Ensured correct binary search behaviour and removed duplicates |
| 1152–1155 | Binary search lookup for oitol | Replaced DB reads with in-memory access for better performance |
| 1164 | FREE it_yvvk9o | Released temporary lookup table after last usage |
PROGRAM 3 — ZSDR_EXC_INVOICE_CDS (ZSD149)
19 optimizations. 37.4s → 15.5s. 59% faster.| LINES | OPTIMIZATION | REASON |
|---|---|---|
| 390–392 | SORT i_bsis1 BY bukrs belnr gjahr | Ensured sorted internal table for correct and efficient binary search during lookup |
| 397–404 | READ TABLE i_bsis1 ... BINARY SEARCH | Replaced linear search with binary search for faster in-memory access inside loop |
| 412–415 | FREE l_tab_bseg | Released temporary BSEG working table after last usage to reduce memory footprint |
| 418–420 | FREE i_bsis1 | Explicitly freed BSIS lookup table after completion of processing |
| 577–579 | SORT it_faglflexa + SORT i_bsis | Prepared both tables for efficient binary search and deterministic access |
| 590–593 | Binary search on it_faglflexa | Replaced database access with fast internal table lookup for FAGLFLEXA data |
| 601–603 | FREE it_faglflexa | Released FAGLFLEXA preload table after final usage to optimise memory |
| 663–704 | Parallel cursor logic on i_bsis | Improved performance by iterating only over matching key ranges instead of full table scans |
| 714–735 | Bulk SELECT on BSEG via FOR ALL ENTRIES | Eliminated repeated DB calls by fetching BSEG data in a single bulk operation |
| 721–724 | SORT lt_bseg_sa56gg + DELETE ADJACENT DUPLICATES | Ensured unique key combinations and prepared table for efficient access |
| 733–735 | SORT lt_bseg_sa56gh + duplicate removal | Reduced redundant entries and ensured deterministic lookup behaviour |
| 738–740 | FREE lt_collected_keys | Released collected key table after DB fetch to reduce memory usage |
| 742–745 | SORT i_hkont + DELETE ADJACENT DUPLICATES | Prepared G/L account lookup table for optimised binary search |
| 749–767 | Parallel cursor on i_bsis with indexed looping | Processed only contiguous matching records, avoiding unnecessary full-table comparisons |
| 878–880 | Binary search on i_hkont | Improved lookup performance for G/L account resolution |
| 893–895 | FREE i_bsis, t_i_bsis, lt_bseg_sa56gg/gh | Released multiple temporary processing tables after last usage to minimise memory |
| 972–987 | Replaced SELECT SINGLE on BSEG with internal table lookup | Avoided repeated DB access by reading vendor data from preloaded BSEG table. |
| 990–1005 | Binary search on p_ltl_bseg | Improved vendor lookup performance by using sorted internal table access. |
“The optimized programs delivered exactly the same results but in a fraction of the time. What would have been a high-risk manual exercise was completed safely without disrupting production workflows.”
Engagement Details
Ready to Unlock Similar Performance Gains?
Run a controlled pilot on your most critical SAP workloads and validate measurable results before scaling enterprise-wide.
Book a call with us or write to: aditya@sookti.ai | tanushree@sookti.ai

