Loading...
Loading...
ATC-driven S/4HANA custom code migration — runs ATC readiness checks, groups findings, and generates clean-core replacement code following modern ABAP patterns. Use when asked to "migrate this Z program", "fix ATC findings", "modernize this code for S/4HANA", "clean-core fixes", or "ABAP Cloud readiness for this object".
npx skill4agent add arc-mcp/arc-1 migrate-custom-code| Setting | Default | Rationale |
|---|---|---|
| Object type | Auto-detect via SAPSearch | Don't make user look up the type |
| ATC variant | System default | Omitting |
| Scope | | Most actionable output |
| Priority filter | All priorities (start with Priority 1 errors) | Don't miss anything, but fix most critical first |
ZCL_SALES_HANDLERZ_REPORT_POSTINGZSALES_PKGS4HANA_2023S4HANA_READINESSexplainfixfixATC gotchas (verified live on S/4HANA 2023):
- ATC skips
/ local objects. A check run against a$TMPobject resolves to an empty object set and returns zero findings — this is not "clean code", it's "not checked". Run ATC against objects in a transportable package. If the user points you at$TMPcode, say so and ask them to assign it to a transportable package first.$TMP- The check variant must exist on the system.
is the standard name on SAP BTP ABAP / S/4HANA Cloud, but on-premise systems often shipABAP_CLOUD_READINESS(e.g.S4HANA_READINESS_<release>) orS4HANA_READINESS_2023instead. If the named variant is absent ARC-1 rejects the call (SAP would silently runSAP_CLOUD_PLATFORM_DEFAULT) — list the real names withDEFAULT, or omitSAPDiagnose(action="atc_variants")to bind the system's configured default.variant
SAPDiagnose(action="atc", type="<type>", name="<object_name>", variant="<variant>")variantsystemCheckVariantcheckVariantDEFAULTSAPDiagnose(action="atc", type="<type>", name="<object_name>")S4HANA_READINESS_2023ABAP_CLOUD_READINESS$TMPSAPRead(type="DEVC", name="<package_name>")Migration Readiness Report for <object_name>
=============================================
Total findings: <N>
Priority 1 (Errors): <n>
Priority 2 (Warnings): <n>
Priority 3 (Info): <n>
| # | Priority | Check | Category | Count | Affected Objects |
|---|----------|-------|----------|-------|------------------|
| 1 | 1 | Use of obsolete statement MOVE | Syntax Change | 3 | Z_REPORT_POSTING |
| 2 | 1 | Call to released API CL_GUI_ALV_GRID | Deprecated API | 1 | Z_REPORT_POSTING |
| 3 | 2 | SELECT...ENDSELECT pattern | Performance | 5 | Z_REPORT_POSTING |
| ...SAPRead(type="<type>", name="<object_name>")search("<checkTitle> S/4HANA migration")
search("<deprecated_api> replacement ABAP")search("<simplification_item_id> simplification list")sap_notes_search(q="<checkTitle>")
sap_notes_search(q="<deprecated_api> replacement")SAPDiagnose(action="quickfix", type="<type>", name="<object_name>", source="<current_source>", line=<finding_line>, column=0)SAPDiagnose(action="apply_quickfix", type="<type>", name="<object_name>", source="<current_source>", line=<finding_line>, column=0, proposalUri="<proposal_uri>", proposalUserContent="<proposal_user_content>")apply_quickfixSAPWrite(action="update")Quickfix availability is system-dependent. SAP only offers quickfix proposals where the system has the corresponding check/cloudification content installed. On a bare ABAP trial or a system without the Clean-Core remediation content,returnsgetFixProposalsand ATC findings carry[]— that's expected, not a bug. In that case skip straight to LLM-generated fixes (the options below). Prefer SAP quickfixes only when they actually come back.hasQuickfix=false
Match the proposal to the finding — don't blindly apply.proposals[0]returns every proposal applicable at that source position, which often includes generic refactorings unrelated to the finding (verified live on S/4HANA 2023: a position returned "Rename", "Convert to attribute", "Convert to importing parameter", "Extract local variable", …). Pick the proposal whosequickfix/nameactually addresses the finding; ignore the rest.description
Refactoring-style proposals can't be auto-applied here. Proposals whosecontainsuri(rename / convert-to-X / extract / introduce) are interactive refactorings that ride the separate/providers/refactoring/multi-step flow —/sap/bc/adt/refactoringsreturns HTTP 500 for them (verified live). They are not finding fixes; skip them for automated apply and fall back to an LLM-generated fix. Only proposals from non-refactoring providers apply cleanly throughapply_quickfix.apply_quickfix
| Old Pattern | New Pattern | Notes |
|---|---|---|
| Class method call | Find replacement class in documentation |
| | Avoid row-by-row processing |
| | New ABAP syntax |
| | Use table expressions |
| Method call | Extract to class method |
| | Built-in function |
| | Functional call syntax |
| | NEW operator |
| | Built-in function |
| Classic DB view | CDS view entity | Redesign required |
| Fiori / RAP service | Major redesign |
SAPWrite(action="edit_method", type="CLAS", name="<class>", method="<method>", source="<fixed_source>", transport="<transport>")SAPWrite(action="update", type="<type>", name="<object_name>", source="<fixed_source>", transport="<transport>")SAPDiagnose(action="syntax", type="<type>", name="<object_name>")SAPActivate(type="<type>", name="<object_name>")SAPDiagnose(action="atc", type="<type>", name="<object_name>", variant="<variant>")Migration Fix Summary for <object_name>
========================================
Findings fixed: <n>
Findings remaining: <n>
Findings needing manual fix: <n>
Fixed:
- [FIXED] Use of obsolete statement MOVE (3 occurrences)
- [FIXED] SELECT...ENDSELECT replaced with SELECT INTO TABLE
Remaining:
- [MANUAL] CL_GUI_ALV_GRID replacement requires UI redesign
- [SKIPPED] User skipped FORM/PERFORM migration
Next steps:
- Address remaining manual findings
- Run full regression tests
- Consider running ATC on dependent objects| Error | Cause | Fix |
|---|---|---|
| ATC variant not found | Variant doesn't exist on this system (hard error — SAP would otherwise silently run | List the real names with |
| Object locked by another user | Object is being edited elsewhere | Inform user, suggest trying later or contacting the lock holder |
| Fix causes new syntax error | Generated replacement code is incorrect | Revert to original source, show the diff, suggest manual correction |
| No mcp-sap-docs available | Documentation MCP not configured | Explain findings using ATC finding text only, recommend user check SAP Help Portal |
| Package has too many objects | Large package with 100+ objects | Suggest breaking into smaller batches by sub-package or object type |
| ATC returns no findings | Object is already S/4HANA ready | Inform user — no findings is good news, suggest checking with a stricter variant |
| Transport required but not provided | Object is in a transportable package | Ask user for transport request number before applying fixes |