CASE STUDY/GLOBAL CEMENT MANUFACTURER

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.

Pattern
Faster Runtime
58-80%
MANUAL ABAP EFFORT
Zero
DELIVERY VELOCITY
1 Dayvs 1 month
FUNCTIONAL PARITY
100%
THE CHALLENGE

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.

- SAP Technical Lead, Global Cement Manufacturer
THE APPROACH

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:

Replaced every SELECT SINGLE inside a loop with FOR ALL ENTRIES bulk fetch
Introduced SORT + BINARY SEARCH on all preloaded internal tables for O(log n) access
Preloaded lookup data (user master via USR21/ADRP, customer KNA1, vendor BSEG, risk class) outside loops
Eliminated redundant BAPI_USER_GET_DETAIL calls by caching user and email data upfront
Built unique partner and segment lists before function module calls to eliminate duplicate overhead
Introduced parallel cursor logic to process grouped records without full table scans
Applied DELETE ADJACENT DUPLICATES after every sort to ensure correct binary search behaviour
Released all temporary internal tables with explicit FREE statements to reduce peak memory
Preserved every functional condition, business rule, and output structure exactly
All changes were self-documented, regression-tested automatically, and validated to ensure identical results to the legacy programs.
RESULTS (PERFORMANCE GAINS)

Data-driven improvements measured on live DEV 300 production workloads. Results below represent a subset of optimized programs from a broader SAP performance initiative.

PROGRAM / REPORT
ZRSD_EBILL_EINV_DETAILS (ZSD1062)
BEFORE (LEGACY)
42s
AFTER (SOOKTI AI)
17.6s
IMPROVEMENT
58%faster
PROGRAM / REPORT
zhrsd947 (ZSD206)
BEFORE (LEGACY)
21.6s
AFTER (SOOKTI AI)
4.3s
IMPROVEMENT
80%faster
PROGRAM / REPORT
ZSDR_EXC_INVOICE_CDS (ZSD149)
BEFORE (LEGACY)
37.4s
AFTER (SOOKTI AI)
15.5s
IMPROVEMENT
59%faster

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 1, 42s to 17.6s (58% faster)

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

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

Program 3, 37.4s to 15.5s (59% 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.

Lines of Custom Code Refactored Across Reports
110,000+
Business Logic Changes, No Regression Risk
Zero
Memory-Optimized for High Volume Runs
100%
Documentation, Traceable, and Audit-ready
Auto

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.

TECHNICAL APPENDIX: DETAILED OPTIMIZATION LOG

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 382–407
VBFA SELECT SINGLE → FOR ALL ENTRIES
Technical Reason:Eliminated N DB calls inside loop; replaced with single bulk fetch and in-memory lookup
LINES 392–397
SORT L_TAB_VBRK BY VGBEL + binary search
Technical Reason:Ensured sorted table before binary search for correctness and performance
LINES 400–407
VBFA lookup via READ TABLE ... BINARY SEARCH
Technical Reason:Replaced database access with fast in-memory lookup for better scalability
LINES 419
FREE it_tsyrws
Technical Reason:Released VBFA preload table after last usage to reduce memory footprint
LINES 429–437
VBAK ERNAM preload via FOR ALL ENTRIES
Technical Reason:Eliminated repeated SELECT SINGLE calls on VBAK inside processing logic
LINES 433–435
SORT it_xfv5uf + DELETE ADJACENT DUPLICATES
Technical Reason:Prepared unique, sorted lookup table for efficient binary search
LINES 675–682
Binary search lookup for VBAK ERNAM
Technical Reason:Replaced database access with in-memory lookup to improve runtime
LINES 438–446
EKKO ERNAM preload via FOR ALL ENTRIES
Technical Reason:Avoided repeated DB access to EKKO by bulk-fetching purchasing document owners
LINES 443–445
SORT it_h6fe8f + DELETE ADJACENT DUPLICATES
Technical Reason:Ensured unique and sorted entries for binary search usage
LINES 702–710
Binary search lookup for EKKO ERNAM
Technical Reason:Improved performance by avoiding DB reads inside loop
LINES 447–475
USR21 + ADRP user master preload
Technical Reason:Reduced dependency on repeated BAPI_USER_GET_DETAIL calls by caching user master data
LINES 476–523
Email resolution via ADR6 with priority handling
Technical Reason:Deterministic, efficient email selection avoiding repeated database calls
LINES 525
FREE lt_all_emails
Technical Reason:Released temporary email lookup table after usage to optimize memory.
LINES 527
SORT lt_user_contact BY bname
Technical Reason:Ensured sorted user contact table for binary search during user lookup.
LINES 669–671
SORT IT_CODMAST_IDS + binary search
Technical Reason:Optimized repeated lookups by ensuring correct binary search usage.
LINES 788–801
SORT IT_DOCTYPE + binary search
Technical Reason:Improved pending-invoice processing performance by optimizing table access.
LINES 860–865
SORT IT_RMC_INV + binary search
Technical Reason:Optimized e-way bill related lookups by replacing linear scans.
LINES 953–955
FREE IT_RMC_INV
Technical Reason:Released RMC invoice table after last usage to reduce memory consumption.
LINES 1502–1504
FREE L_TAB_VKORG
Technical Reason:Released authorization validation table after completion of auth checks.
LINES 1528–1530
FREE L_TAB_FINAL2
Technical Reason:Freed FAE driver table in GET_PENDING_INV after data extraction.

PROGRAM 2 — zhrsd947 (ZSD206)

21 optimizations. 21.6s → 4.3s. 80% faster.
LINES 389–393
SORT it_rpmkr BY kunnr + binary search
Technical Reason:Ensured sorted table before binary search for correctness and performance
LINES 403–409
SORT it_rpmkr BY kunnr rpmkr + binary search
Technical Reason:Enabled efficient deterministic lookup during repeated reads inside loop
LINES 729–735
risk_class SELECT SINGLE → FOR ALL ENTRIES
Technical Reason:Avoided repeated DB access by preloading risk class data in a single call
LINES 733–735
SORT it_efxjg + DELETE ADJACENT DUPLICATES
Technical Reason:Ensured unique partner entries and prepared table for binary search
LINES 738–757
Unique partner + segment list build
Technical Reason:Eliminated redundant partner-segment combinations; reduced repeated function calls
LINES 759–767
Pre-read partner and segment lists before function
Technical Reason:Reduced function module overhead by passing unique values only
LINES 774
FREE lt_pairs, lt_partner, lt_segments
Technical Reason:Released temporary helper tables after last usage to reduce memory footprint
LINES 783–791
risk_class binary search lookup
Technical Reason:Replaced DB calls inside loop with reads from preloaded internal table
LINES 812
FREE it_efxjg
Technical Reason:Freed preload table after last usage to release memory early
LINES 996–1002
altkn SELECT SINGLE → FOR ALL ENTRIES
Technical Reason:Eliminated repeated DB calls for customer alternate key retrieval
LINES 1000–1001
SORT it_bknib8 + DELETE ADJACENT DUPLICATES
Technical Reason:Ensured correct and efficient binary search lookup
LINES 1011–1014
Binary search lookup for altkn
Technical Reason:Replaced database access with fast in-memory lookup
LINES 1022
FREE it_bknib8
Technical Reason:Released lookup table after final usage to reduce memory
LINES 1031–1037
KNA1 name1 + zzfinance_scheme → FOR ALL ENTRIES
Technical Reason:Prevented repeated KNA1 reads by bulk-fetching customer master data
LINES 1035–1036
SORT it_w8extk + DELETE ADJACENT DUPLICATES
Technical Reason:Prepared lookup table for efficient binary search
LINES 1046–1050
Binary search for customer name and finance scheme
Technical Reason:Improved runtime by replacing DB reads with internal table lookup
LINES 1058
FREE it_w8extk
Technical Reason:Freed customer master preload table after usage
LINES 1139–1145
oitol SELECT SINGLE → FOR ALL ENTRIES (T691F)
Technical Reason:Eliminated repeated DB access to T691F during loop execution
LINES 1142–1143
SORT it_yvvk9o + DELETE ADJACENT DUPLICATES
Technical Reason:Ensured correct binary search behaviour and removed duplicates
LINES 1152–1155
Binary search lookup for oitol
Technical Reason:Replaced DB reads with in-memory access for better performance
LINES 1164
FREE it_yvvk9o
Technical Reason:Released temporary lookup table after last usage

PROGRAM 3 — ZSDR_EXC_INVOICE_CDS (ZSD149)

19 optimizations. 37.4s → 15.5s. 59% faster.
LINES 390–392
SORT i_bsis1 BY bukrs belnr gjahr
Technical Reason:Ensured sorted internal table for correct and efficient binary search during lookup
LINES 397–404
READ TABLE i_bsis1 ... BINARY SEARCH
Technical Reason:Replaced linear search with binary search for faster in-memory access inside loop
LINES 412–415
FREE l_tab_bseg
Technical Reason:Released temporary BSEG working table after last usage to reduce memory footprint
LINES 418–420
FREE i_bsis1
Technical Reason:Explicitly freed BSIS lookup table after completion of processing
LINES 577–579
SORT it_faglflexa + SORT i_bsis
Technical Reason:Prepared both tables for efficient binary search and deterministic access
LINES 590–593
Binary search on it_faglflexa
Technical Reason:Replaced database access with fast internal table lookup for FAGLFLEXA data
LINES 601–603
FREE it_faglflexa
Technical Reason:Released FAGLFLEXA preload table after final usage to optimise memory
LINES 663–704
Parallel cursor logic on i_bsis
Technical Reason:Improved performance by iterating only over matching key ranges instead of full table scans
LINES 714–735
Bulk SELECT on BSEG via FOR ALL ENTRIES
Technical Reason:Eliminated repeated DB calls by fetching BSEG data in a single bulk operation
LINES 721–724
SORT lt_bseg_sa56gg + DELETE ADJACENT DUPLICATES
Technical Reason:Ensured unique key combinations and prepared table for efficient access
LINES 733–735
SORT lt_bseg_sa56gh + duplicate removal
Technical Reason:Reduced redundant entries and ensured deterministic lookup behaviour
LINES 738–740
FREE lt_collected_keys
Technical Reason:Released collected key table after DB fetch to reduce memory usage
LINES 742–745
SORT i_hkont + DELETE ADJACENT DUPLICATES
Technical Reason:Prepared G/L account lookup table for optimised binary search
LINES 749–767
Parallel cursor on i_bsis with indexed looping
Technical Reason:Processed only contiguous matching records, avoiding unnecessary full-table comparisons
LINES 878–880
Binary search on i_hkont
Technical Reason:Improved lookup performance for G/L account resolution
LINES 893–895
FREE i_bsis, t_i_bsis, lt_bseg_sa56gg/gh
Technical Reason:Released multiple temporary processing tables after last usage to minimise memory
LINES 972–987
Replaced SELECT SINGLE on BSEG with internal table lookup
Technical Reason:Avoided repeated DB access by reading vendor data from preloaded BSEG table.
LINES 990–1005
Binary search on p_ltl_bseg
Technical Reason:Improved vendor lookup performance by using sorted internal table access.
SOOKTI AI'S VALUE
ASPECT
Code Transformation Time/ Time to Go-Live
BEFORE (MANUAL)
1 week per report (7 man-days per 5,000+ lines)
NOW WITH SOOKTI AI
Minutes per report, no manual intervention
ASPECT
Performance
BEFORE (MANUAL)
Bottlenecks from outdated patterns (SELECT * , loop-in-loop)
NOW WITH SOOKTI AI
50–90%faster execution with HANA-specific techniques
ASPECT
Code Optimization
BEFORE (MANUAL)
Manual identification and patching of inefficient code
NOW WITH SOOKTI AI
Automatic identification and correction; rewritten for HANA (CDS views, parallel cursors)
ASPECT
Quality Assurance
BEFORE (MANUAL)
Manual testing; high dependency on key developers
NOW WITH SOOKTI AI
100%functional parity validated with automated regression testing
ASPECT
Risk Management
BEFORE (MANUAL)
High dependency on key developers; risk of human error
NOW WITH SOOKTI AI
No “hero-developer” dependency; consistent, repeatable, auditable process with self-documenting output
ASPECT
SAP Clean-Core & Future/Upgrade-Proof
BEFORE (MANUAL)
Customizations break with SAP upgrades, manual checking to ensure HANA-compliant code
NOW WITH SOOKTI AI
Built-in clean-core compliance; SAP Standard CDS, Functions and Classes
ASPECT
Long-Term Maintainability
BEFORE (MANUAL)
Difficult to maintain; lack of documentation and poor readability
NOW WITH SOOKTI AI
Annotated ABAP with rationale per change; easy to maintain
TESTIMONIALS

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.

- SAP Technical Lead, Global Cement Manufacturer
ENGAGEMENT DETAILS

Engagement Details

Industry
Manufacturing (Cement)
Landscape
SAP ECC S/4HANA (Brownfield)
Scope
Custom Code Optimization
Environment
Live Enterprise Production Workloads

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

Background ASCII Illustration