CASE STUDY/GLOBAL TEXTILE MANUFACTURER

>80% faster SAP reporting through AI-led optimization, zero manual effort.

Autonomous agents optimized runtime performance of critical SAP reports for a large textile manufacturer, resolving timeouts, stabilizing execution, and eliminating operational risk, without altering business logic or report output.

Pattern
PERFORMANCE
50–90%faster runtime
Month-End Close
1dayvs 7 days previously
Delivery Velocity
1dayvs 1month traditionally
FUNCTIONAL PARITY
100%from day 1 with zero discrepancies
THE CHALLENGE

Business-critical reports were failing under production load.

Our client, a large textile manufacturer, was running SAP S/4HANA, having completed migration through another SI, but custom ABAP was not HANA-compliant and was causing performance failures. Over 15+ years of accumulated customization had been carried over into the S/4HANA landscape without HANA-compliant optimization.

The immediate crisis was operational. Business-critical reports, including the Purchase Register, the Order-Delivery-Bill Status, and the GST-Report, were timing out after 20+ minutes. The finance team was forced to run reports one day at a time, manually stitching results to keep operations moving.

Key pain points included:

Legacy code and poor performance: Thousands of lines of custom ABAP with outdated patterns (e.g. SELECT * inside nested loops) were not optimized for HANA, causing severe runtime bottlenecks. Complex nested loops without sorted reads or binary search meant some reports ran exponentially slower than they should.

High manual remediation effort: Traditional manual refactoring was estimated at 1–2 weeks per program. This approach relied on a few “hero” developers, creating a delivery risk if those key people were unavailable.

Quality and compliance concerns: Ensuring rewritten code followed SAP HANA clean core best practices was nearly impossible by hand. The legacy code lacked documentation and clarity, making it error-prone and hard to audit.

Traditional manual refactoring was estimated at 1–2 weeks per program. Across the full scope of programs, this amounted to approximately one month of sequential developer effort.

- Program Lead, Textile Manufacturer
THE APPROACH

Autonomous AI-Led Remediation of Legacy ABAP

Sookti AI deployed an autonomous AI agent to handle the code optimization end-to-end. Without any human intervention, the agent transformed and optimized the client’s codebase in minutes. The workflow included:

1
Static code scan: The agent performs deep static analysis to identify anti-patterns, spotting SELECT * queries, SQL calls inside loops, unnecessary nested loops, linear table scans where binary search was possible, missing parallel cursor techniques, legacy syntax incompatible with HANA optimization, and other performance killers. This scan pinpoints exactly where legacy code would violate HANA best practices or slow down execution.
2
Automated code transformation: Sookti’s transformation engine rewrites the ABAP to use modern, efficient constructs. It replaces inefficient logic with CDS views and set-based SQL, moving data processing to HANA where possible. The transformed code is also injected with clear, business-aligned comments for readability.
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 parallel cursor techniques to eliminate nested loop slowdowns, replaces linear searches with binary search, leverages hashed tables for quick lookups, and consolidates multiple selects into single queries, aligning with HANA’s in-memory strengths.
5
Upgrade-proof output: Sookti AI’s agents introduce SAP Standard CDS Views, Functions, and Classes into custom programs, making them ready for any future SAP upgrades without rework.
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 it a future-proof asset for the client’s IT team.

Throughout this automated workflow, the Sookti AI agent handled the entire conversion without a human in the loop. No manual coding or debugging was needed. Sookti AI essentially became an expert ABAP developer and tester that worked at machine speed. Transformation of each program completed in minutes. Automated regression testing confirmed 100% functional parity before delivery.

THE RESULTS

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

PROGRAM / REPORT
ZPURCHASE_REGISTER
BEFORE (LEGACY)
>20 min(Timeout)
AFTER (SOOKTI AI)
10 min(15 days data)
PROGRAM / REPORT
ZSDR_ORDER_DEL_BILL
BEFORE (LEGACY)
>20 min(Timeout)
AFTER (SOOKTI AI)
5 min(30 days data)
PROGRAM / REPORT
ZGSTR1 (GST Report)
BEFORE (LEGACY)
>20 min(Timeout)
AFTER (SOOKTI AI)
3.5 min(1 month data)
PROGRAM / REPORT
ZPP_CYCLE_TIME
BEFORE (LEGACY)
>20 min(Timeout)
AFTER (SOOKTI AI)
17–18 min

SAP Runtime Analysis (SAT) DEV 300

ZPP_CYCLE_TIME_REPORT. Before: 21.0 sec / After: 13.3 sec (Sookti AI). 37% improvement on live production workload.

ZPP_CYCLE_TIME_REPORT. Before: 21.0 sec / After: 13.3 sec (Sookti AI). 37% improvement on live production workload.

SAP SAT Analysis
ZGSTR1 Legacy version: memory dump, could not run. Sookti AI optimized version (ZGSTR1_SKT): stable execution, 55% reduction in memory consumption (7,377 kB → 3,233 kB), 55% reduction in runtime. Output matched 100% against the source version on QA data.

ZGSTR1 Legacy version: memory dump, could not run. Sookti AI optimized version (ZGSTR1_SKT): stable execution, 55% reduction in memory consumption (7,377 kB → 3,233 kB), 55% reduction in runtime. Output matched 100% against the source version on QA data.

ZPURCHASE_REGISTER. Before: 3.1 sec / After: 1.85 sec (Sookti AI). 41% improvement measured on live production workload.

ZPURCHASE_REGISTER. Before: 3.1 sec / After: 1.85 sec (Sookti AI). 41% improvement measured on live production workload.

ZPP_CYCLE_TIME_REPORT. Before: 22.1 sec / After: 5.8 sec (Sookti AI). 74% improvement, 81% reduction in external DB accesses, measured on live production workload.

ZPP_CYCLE_TIME_REPORT. Before: 22.1 sec / After: 5.8 sec (Sookti AI). 74% improvement, 81% reduction in external DB accesses, measured on live production workload.

All legacy reports exceeded acceptable execution limits and failed to complete. Results showed autonomous AI restored business-critical reporting performance without manual remediation or regression risk.

Lines of code refactored
11,000
STABILITY
ZEROregressions
Manual Effort
ZERO
DOCUMENTATION
Automatic
WHAT CHANGED

Pattern 1: Bulk Retrieval + Binary Search

Replacing loop-based database access with bulk retrieval and indexed in-memory processing. Database hits cut from O(n) per iteration to a single bulk SELECT followed by O(log n) binary search reads.

Before
SELECT in LOOP
LOOP AT t_final ASSIGNING <l_fs_final>.
  " Performance Anti-pattern: DB hit in loop
  SELECT SINGLE audat FROM vbak INTO (audat)
  WHERE vbeln = <l_fs_final>-sono.
ENDLOOP.
After
Bulk Select + Binary Search
IF t_final IS NOT INITIAL.
  " Bulk Retrieval using FOR ALL ENTRIES
  SELECT vbeln, audat FROM vbak
    INTO TABLE @DATA(lt_vbak)
    FOR ALL ENTRIES IN @t_final
    WHERE vbeln = @t_final-sono.

  SORT lt_vbak BY vbeln. " Prepare for Binary Search
ENDIF.

LOOP AT t_final ASSIGNING <l_fs_final>.
  " O(log n) Read instead of DB call
  READ TABLE lt_vbak INTO DATA(ls_vbak)
    WITH KEY vbeln = <l_fs_final>-sono
    BINARY SEARCH.
  IF sy-subrc = 0.
    audat = ls_vbak-audat.
  ENDIF.
ENDLOOP.

Pattern 2: 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.

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
Parallel Cursor O(n+m)
" Sort once for Parallel Cursor logic
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 to start of match
    ELSEIF <gv1>-delv_no > <gv>-delv_no.
      EXIT. " Early exit: no more matches
    ELSE.
      lv_idx = sy-tabix. " Update cursor
      <gv>-bundle += <gv1>-bundle.
      <gv>-fkimg += <gv1>-fkimg.
    ENDIF.
  ENDLOOP.
ENDLOOP.
TESTIMONIALS

Sookti AI compressed what would have taken our team a month of manual remediation into a single day of agent runtime, while simultaneously baking in HANA best-practices we wouldn't have implemented manually.

- Technical Lead, Textile Manufacturer
ENGAGEMENT DETAILS

Engagement Details

Industry
Manufacturing (Textile)
Landscape
S/4 HANA
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