>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.
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.”
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:
Runtime & Execution Metrics (SAP SAT – Live Workloads)

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.
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.
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.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.
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.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.
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." 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.“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.”
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

