Workik.

SAP S/4HANA Custom Code Migration: An ABAP Developer's Guide

Testing, Cutover and AI-Assisted Custom Code Remediation

Establish cutover regression testing workflows, manage transports, monitor ST22 short dumps, and leverage developer-reviewed AI code remediation.

Harbor Supply Co. is entering the final phases of its SAP S/4HANA system conversion. You have identified unused objects, analyzed Simplification Database findings, and remediated core data model changes across reports such as ZSD_ORDER_STATUS, ZMM_STOCK_MOVES, and ZSD_PRICE_EXPORT. Now you must validate every change through systematic regression testing, manage transport logistics during cutover, use artificial intelligence (AI) tools safely to accelerate remaining fixes, and monitor runtime behavior after go-live.

Previous lesson: Clean Core and ABAP Cloud for Migrated Systems


AI-Assisted Custom Code Remediation

Remediating hundreds of custom programs manually takes significant developer hours. Modern AI coding tools and SAP Joule for Developers provide an automated way to accelerate this workload while keeping control in developer hands.

The SAP S/4HANA custom code migration agent in SAP Joule for Developers works directly with the ABAP Test Cockpit (ATC). The agent scans assigned software packages, executes the S4HANA_READINESS check variant, and analyzes each finding. It then separates issues into deterministic changes and pattern-based proposals:

  1. Deterministic quick fixes: Standard changes with zero ambiguity, such as replacing references to VBUK with VBAK, are executed automatically.
  2. AI-generated proposals: For complex code adaptations, such as refactoring native Structured Query Language (SQL) statements or adapting legacy pricing logic, the agent calculates a confidence score.
  3. Automated imports: High-confidence changes apply directly to the code inside assigned transport requests.
  4. Human review queues: Lower-confidence proposals appear as structured comments directly in the source code. You must inspect, adapt, and uncomment these blocks manually.

General AI coding assistants such as Workik can also help: they read your custom ABAP and draft adapted code that a developer then reviews and tests.

Pro Tip: Never treat AI-generated code as production-ready without human review. AI models can occasionally produce hallucinated method parameters or syntax from older releases. Always run an ATC recheck and execute an ABAP Unit test after accepting an AI proposal.

Here is how an AI remediation assistant annotates an adapted pricing routine when human verification is required:

abap
Copy

Transport Management and Code Freeze Strategies

Converting an active production system requires careful transport coordination. Business operations continue in SAP ERP Central Component (SAP ECC) while developers fix code in the SAP S/4HANA migration sandbox and development environments. This overlap introduces the risk of overwriting remediated code or dropping emergency production fixes.

To manage this risk, implement a structured code freeze:

  1. Initial freeze: Establish a strict transport freeze on non-critical enhancements in the ECC development system before the final code extraction.
  2. Dual maintenance: If an emergency fix must go to ECC production during the migration project, log the transport request and duplicate the change manually into the SAP S/4HANA development system.
  3. Remediation transports: Package all S/4HANA custom code adaptations into dedicated transport requests categorized by functional area (for example, Sales and Distribution or Materials Management).
  4. Deletion transports: Group custom objects marked for decommissioning into separate transports. Import the deletion transports into the test environments well before cutover to confirm no active interfaces break.

Common Mistake: Combining functional code remediations and unused code deletions in the same transport request. If a deleted program is suddenly needed during user acceptance testing, you cannot easily roll back the deletion without undoing valid functional fixes.


Custom Code Regression Testing Strategy

Static checks through ATC prove that your ABAP code conforms to syntax rules and data dictionary changes. They do not prove that business logic produces correct calculations. A focused regression testing strategy confirms business continuity.

Focus your testing effort on three primary risk profiles:

1. Interface Validation

Custom export programs, such as Harbor Supply Co.'s ZSD_PRICE_EXPORT, communicate with third-party software. Verify that the output files, Application Link Enabling (ALE) Intermediate Documents (IDocs), and web service payloads retain exact field formats. If an external system expects an 18-character material number, sending a raw 40-character value from the new MATNR domain will break downstream systems.

2. High-Impact Transaction Scripts

Programs that execute goods movements or financial postings require step-by-step validation. Run ZMM_STOCK_MOVES against historical material documents and verify that compatibility views return accurate historical stock entries. Execute new postings and verify that table MATDOC registers the records without locking conflicts.

3. ABAP Unit Coverage

Write or update ABAP Unit test classes for isolated logic blocks before migration. Running unit tests before and after code changes provides instant proof that logic behavior remains consistent.

abap
Copy

Cutover Execution and Final Checks

During the cutover weekend, the Software Update Manager (SUM) executes the technical conversion of the database and data dictionary. Once SUM completes, technical cutover for custom code begins.

Follow this sequence during the cutover window:

  1. Import custom code remediation transports: Apply the transports containing adapted programs, functions, and dictionary structures.
  2. Confirm deletion transports: Check that the deletion transports for unused code were imported into production before the conversion run, as planned during the usage analysis phase.
  3. Run local ATC checks: Execute transaction ATC directly in the converted system using check variant S4HANA_READINESS. Verify that no priority 1 syntax errors or missing object references remain.
  4. Recompile critical programs: Execute transaction SGEN (SAP Load Generator) for custom packages (Z* and Y*) to generate ABAP program loads ahead of user logon. This step prevents initial response time spikes for end users.
  5. Check compatibility views: Run a remediated report such as ZMM_STOCK_MOVES and confirm that reads through the MKPF and MSEG compatibility views return the expected data.

Quick Challenge: Open transaction SE38 in your target test system and inspect a remediated program like ZSD_ORDER_STATUS. Run a local check using Ctrl + F2 to ensure no local inactive dependent includes were missed during transport release.


Post Go-Live Monitoring and Short Dump Analysis with ST22

Even thorough testing misses edge-case data combinations. In the initial weeks following cutover, active system monitoring must catch and resolve runtime failures before they disrupt operations.

Transaction ST22 (ABAP Dump Analysis) is your primary post go-live monitoring tool. Focus on these specific error categories:

1. SYNTAX_ERROR and LOAD_PROGRAM_NOT_FOUND

These errors indicate that an object was omitted from a cutover transport, or an inactive version was deployed. Filter ST22 by user and program name to isolate the missing dependency immediately.

2. OBJECTS_OBJREF_NOT_ASSIGNED

This dump means code used an object reference that was never assigned. After migration, check calls to changed or replaced BAdIs and classes first.

3. ITAB_DUPLICATE_KEY and ITAB_LINE_NOT_FOUND

ITAB_DUPLICATE_KEY occurs when code inserts a row into an internal table with a unique key and that key already exists. This can happen when new tables like ACDOCA or MATDOC return more detailed rows than the old tables did. ITAB_LINE_NOT_FOUND occurs when a table expression such as lt_orders[ ... ] finds no matching row.

abap
Copy

Set up an automated daily alert for short dumps matching the pattern Z* to address issues proactively each morning during hypercare.


Try It Yourself

Execute a mock post-conversion check on one of your remediated programs:

  1. Open your ABAP development environment (SAP GUI or ABAP Development Tools in Eclipse).
  2. Choose one remediated program, such as your version of ZSD_ORDER_STATUS or ZMM_STOCK_MOVES.
  3. In Eclipse, right-click the object and select Run As, ABAP Test Cockpit With, and enter the check variant S4HANA_READINESS.
  4. Verify that the ATC Problems view reports zero priority 1 or priority 2 findings.
  5. Launch transaction ST22 in your test environment. Filter the dump list for the last 7 days using your user name or test batch users to verify that your execution did not trigger silent runtime exceptions.

You have completed the full journey of custom code migration from SAP ECC to SAP S/4HANA. By scoping unused code with SCMON and SUSG, prioritizing findings with ATC, resolving data model transformations across MATNR, KONV, VBUK, and MATDOC, applying clean core principles, and executing disciplined testing, you are prepared to deliver an upgrade-stable, high-performance S/4HANA system.

You have completed the course

Was this lesson helpful?