CASE STUDY/GLOBAL PAPER MANUFACTURER

>60%+ faster SAP performance, no manual rework

Autonomous AI agents optimized runtime performance of critical SAP GST programs for a large paper manufacturer, achieving over 60% reduction in execution time, restoring business-critical reporting, and eliminating weeks of manual ABAP remediation, without altering business logic or report output.

Pattern
PERFORMANCE
60%-80%faster runtime on critical GST programs
MANUAL ABAP EFFORT
ZEROfully autonomous remediation
DELIVERY VELOCITY
1 hourvs 1 week per program, previously
FUNCTIONAL PARITY
100%from day 1, with zero discrepancies
THE CHALLENGE

Aging Custom ABAP Undermining SAP ECC Performance

As part of ongoing SAP modernization efforts, our client, a large paper manufacturer, identified performance limitations across several custom ABAP programs running on SAP ECC.

Over time, these programs had accumulated legacy coding patterns that were not optimized for HANA-based execution. As data volumes increased, program runtimes degraded, impacting the reliability and responsiveness of critical financial and reporting workloads.

Traditional remediation approaches required manual refactoring of each program, with estimates of one to two weeks of effort per object. This approach depended heavily on specialized ABAP expertise and introduced delivery risk, making large-scale optimization difficult to execute efficiently.

Refactoring these programs manually would have required weeks of effort per object. Sookti AI delivered optimised, clean-core compliant code in minutes with full regression validation and documentation we would never have produced by hand.

- IT Lead, Paper Manufacturer
THE APPROACH

End-to-End SAP Optimization Powered by Autonomous Agents

End-to-End Legacy ABAP Optimization Powered by Autonomous Agents Sookti AI deployed autonomous agents to analyze and optimize the client’s most resource-intensive custom SAP programs.

Without any human intervention, the agents transformed and optimised the client's codebase in minutes. The workflow included:

The agents:

1
Static code scan: The agent performs deep static analysis to identify anti-patterns, spotting SELECT * queries, SQL calls inside loops, direct access to high-volume tables such as BSEG, unnecessary nested loops, linear table scans where binary search was possible, and other performance killers.
2
Automated code transformation: Sookti's transformation engine rewrites the ABAP to use modern, efficient constructs. For the paper manufacturer, this included replacing direct BSEG table access with the custom CDS view zfi_gst_input_1, pushing data access to HANA's optimised layer, and consolidating loop-level database calls into single bulk SELECT operations with FOR ALL ENTRIES.
3
Regression testing harness: The agent automatically replays historical test data through the new code, guaranteeing 100% functional parity before and after transformation. Every unit test passed on the first run, confirming the converted programs behaved exactly like the originals, just faster.
4
Intelligent performance optimization: The agent introduces sorted indexes and binary search to eliminate loop-level database calls, replaces linear SELECT SINGLE patterns with bulk retrieval, and consolidates multiple selects into single queries, reducing database roundtrips from O(n) to a single bulk fetch.
5
Upgrade-proof output: Sookti AI's agents introduce SAP Standard CDS Views, Functions, and Classes into custom programs. The substitution of BSEG with zfi_gst_input_1 is a clean-core architecture pattern, decoupling custom logic from direct table dependency and ensuring readiness for any future SAP upgrade.
6
Self-documenting output: The agent produces clean, maintainable ABAP code annotated with the rationale for each change. It references relevant SAP Notes and labels where HANA clean-core principles are applied, making every transformed program a future-proof asset.
THE RESULTS

Runtime & Execution Metrics (SAP SAT – Live Workloads)

PROGRAM / REPORT
ZFI_GST_INPUT_REGISTER Net Runtime
BEFORE (LEGACY)
~19.1sec
AFTER (SOOKTI AI)
~7.1 sec
IMPROVEMENT
~63%reduction
PROGRAM / REPORT
Database Time
BEFORE (LEGACY)
~78.5%
AFTER (SOOKTI AI)
~56 %
IMPROVEMENT
DB dominancereduced
Runtime Analysis: ZFI_GST_INPUT_REGISTER. Before: 19.1 sec / After: 7.1 sec (Sookti AI). 63% improvement. Direct BSEG access (68% of legacy runtime) replaced by CDS view, reducing external DB time from 78.5% to 56.3% of total runtime.

Runtime Analysis: ZFI_GST_INPUT_REGISTER. Before: 19.1 sec / After: 7.1 sec (Sookti AI). 63% improvement. Direct BSEG access (68% of legacy runtime) replaced by CDS view, reducing external DB time from 78.5% to 56.3% of total runtime.

CUSTOM CODE REFACTORED
15000lines
STABILITY
ZEROregressions
OPERATIONAL RISK
100%eliminated
DOCUMENTATION
Automatic
WHAT CHANGED

Three distinct optimization patterns were applied by the autonomous agent across the paper manufacturer's codebase, each targeting a specific class of performance anti-pattern.

PATTERN 01

CDS View Substitution + Bulk Retrieval

Replacing SELECT SINGLE * FROM bseg inside a loop with a bulk SELECT from custom CDS view zfi_gst_input_1, followed by in-memory binary search. Database hits are reduced from O(n) individual BSEG calls to a single bulk fetch. BSEG is one of SAP's largest cluster tables, direct loop-level access is among the most expensive patterns possible in a HANA landscape. The CDS view also delivers clean-core compliance in a single transformation.

Before
BEFORE
LOOP AT it_gst ASSIGNING FIELD-SYMBOL(<fs>).
  SELECT SINGLE * FROM bseg
    INTO @DATA(wan_bseg)
    WHERE bukrs EQ @<fs>-rbukrs
      AND belnr EQ @<fs>-belnr
      AND gjahr EQ @<fs>-gjahr
      AND lifnr EQ @<fs>-lifnr
      AND koart EQ 'K'.
ENDLOOP.
After
AFTER (CDS view + binary search)
IF it_gst IS NOT INITIAL.
  SELECT bseg_bukrs, bseg_belnr AS belnr,
         bseg_gjahr AS gjahr, bseg_lifnr,
         bseg_koart AS koart, ...
    FROM zfi_gst_input_1  " ← CDS replaces BSEG
    INTO TABLE @DATA(lt_zfi_gst)
    FOR ALL ENTRIES IN @it_gst
    WHERE bseg_bukrs = @it_gst-rbukrs
      AND bseg_belnr = @it_gst-belnr
      AND bseg_koart = 'K'.

  SORT lt_zfi_gst BY bseg_bukrs bseg_belnr bseg_gjahr.
ENDIF.

LOOP AT it_gst ASSIGNING FIELD-SYMBOL(<fs>).
  READ TABLE lt_zfi_gst INTO DATA(wan_bseg)
    WITH KEY bseg_bukrs = <fs>-rbukrs ...
    BINARY SEARCH.  " O(log n)
ENDLOOP.

Clean-core insightThe agent didn't just optimize the query; it replaced direct BSEG table access with a purpose-built CDS view, delivering both performance and clean-core compliance in a single transformation.

PATTERN 02

Bulk Retrieval + Binary Search (O(n) DB hits → single bulk SELECT)

Replacing loop-based SELECT SINGLE calls with a single bulk SELECT using FOR ALL ENTRIES, followed by sorted in-memory reads. Applied across tax-code lookups in the GST report. Database hits cut from O(n) per iteration to a single fetch, with O(log n) in-memory binary search reads thereafter.

Before
BEFORE
LOOP AT it_gst INTO gs_gst
  WHERE mwskz NE ' '.
  lv_index = sy-tabix.
  SELECT SINGLE text1 FROM t007s
    INTO gs_gst-taxdesc
    WHERE mwskz EQ gs_gst-mwskz
      AND spras EQ sy-langu
      AND kalsm EQ 'ZKPTAX'.
ENDLOOP.
After
AFTER (FOR ALL ENTRIES + binary search)
IF it_gst IS NOT INITIAL.
  SELECT text1, mwskz FROM t007s
    INTO TABLE @DATA(lt_t007s)
    FOR ALL ENTRIES IN @it_gst
    WHERE mwskz = @it_gst-mwskz
      AND spras = @sy-langu
      AND kalsm = 'ZKPTAX'.

  SORT lt_t007s BY mwskz.
ENDIF.

LOOP AT it_gst INTO gs_gst
  WHERE mwskz NE ' '.
  READ TABLE lt_t007s
    WITH KEY mwskz = gs_gst-mwskz
    INTO DATA(ls_t007s)
    BINARY SEARCH.  " O(log n)

  IF sy-subrc = 0.
    gs_gst-taxdesc = ls_t007s-text1.
  ENDIF.
ENDLOOP.

PATTERN 03

Parallel Cursor Technique (O(n²) → O(n+m))

For nested dataset aggregation, agents implement parallel cursors to scan two sorted tables simultaneously, reducing complexity from O(n²) to nearly O(n+m), dramatically faster for large production workloads with multi-key matching conditions.

Before
BEFORE (O(n²) nested loops)
LOOP AT it_final1 ASSIGNING FIELD-SYMBOL(<gv>).
  CLEAR: <gv>-bundle, <gv>-fkimg.
  LOOP AT it1_final ASSIGNING FIELD-SYMBOL(<gv1>)
    WHERE delv_no      = <gv>-delv_no
      AND packing_type = <gv>-packing_type
      AND length       = <gv>-length
      AND width        = <gv>-width.
    <gv>-bundle = <gv>-bundle + <gv1>-bundle.
    <gv>-fkimg  = <gv>-fkimg  + <gv1>-fkimg.
  ENDLOOP.
ENDLOOP.
After
AFTER (parallel cursor O(n+m))
" Sort once — enable parallel cursor
SORT it1_final BY delv_no packing_type
                  length width.
DATA: lv_idx TYPE sy-tabix.

LOOP AT it_final1 ASSIGNING FIELD-SYMBOL(<gv>).
  CLEAR: <gv>-bundle, <gv>-fkimg.
  LOOP AT it1_final ASSIGNING FIELD-SYMBOL(<gv1>)
    FROM lv_idx.
    IF <gv1>-delv_no < <gv>-delv_no.
      CONTINUE.    " skip: not yet at match
    ELSEIF <gv1>-delv_no > <gv>-delv_no.
      EXIT.        " early exit: past match
    ELSE.
      lv_idx = sy-tabix. " advance cursor
      <gv>-bundle += <gv1>-bundle.
      <gv>-fkimg  += <gv1>-fkimg.
    ENDIF.
  ENDLOOP.
ENDLOOP.
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

Refactoring these programs manually would have required weeks of effort per object. Sookti AI delivered optimised, clean-core compliant code in minutes with full regression validation and documentation we would never have produced by hand.

- IT Lead, Paper Manufacturer
ENGAGEMENT DETAILS

Engagement Details

Industry
Manufacturing (Paper)
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