Back to Blog
S/4HANA

Custom Code Remediation for S/4HANA

28 aprile 2026
15 min read

Custom code is both the strength and Achilles heel of SAP implementations. While it enables business-specific processes, it's also the #1 blocker for S/4HANA migration. This guide provides a systematic approach to identify, prioritize, and remediate custom code for successful S/4HANA transformation.

Reality Check:

  • • Average enterprise has 50,000-200,000 lines of custom ABAP code
  • • 30-40% requires modification for S/4HANA compatibility
  • • Manual remediation: 6-12 months of effort
  • • Automated tools reduce timeline to 2-4 months

Why Custom Code Breaks in S/4HANA

S/4HANA's simplified data model eliminates thousands of database tables, changes field lengths, and deprecates function modules. Your custom code likely relies on these structures.

Incompatible Code Patterns

  • • Direct table access to obsolete tables (BSEG, KONV)
  • • Use of deprecated function modules
  • • Hard-coded field lengths (now changed)
  • • Pool/cluster table reads (now standard tables)
  • • Custom enhancements in modified SAP code

S/4HANA Alternatives

  • • CDS views for data access
  • • Released BAPIs and APIs
  • • Dynamic field sizing
  • • Standard table access
  • • BAdI implementations (not modifications)

Phase 1: Discovery & Assessment

Step 1: Run SAP Readiness Check

SAP provides the Readiness Check tool (transaction SYCM or via SAP Support Portal).

// Transaction codes for analysis:
ATC
// ABAP Test Cockpit - Static code analysis
SYCM / SAT / SE80
// Custom code scan entry points
/SDF/CD_CDS
// CDS compatibility check

Step 2: Classify Custom Code

Classification Matrix:

MUST FIX
Critical Business Process + Syntax Error/Dump
Example: Order processing Z-program accessing BSEG directly
HIGH PRIORITY
Core Process + Performance Warning
Example: Reporting using deprecated FM, will work but slow
MEDIUM
Non-Critical Process + Compatibility Issue
Example: Rarely-used utility program with field length mismatch
LOW / DECOMMISSION
Unused Code or Obsolete Process
Example: Programs not executed in 2+ years, delete instead of fix

Phase 2: Remediation Strategies

Strategy 1: Replace with Standard SAP Functionality

Best case scenario: S/4HANA now offers standard functionality that replaces your custom code.

Example:

Custom credit management program → S/4HANA Advanced Credit Management (Fiori app)

Action: Decommission custom code, train users on new Fiori app. Zero remediation effort.

Strategy 2: Refactor to Use CDS Views

Replace direct table access with CDS consumption views.

Before (ECC):

SELECT * FROM bseg INTO TABLE lt_bseg
WHERE bukrs = p_bukrs
AND gjahr = p_gjahr.

After (S/4HANA):

SELECT * FROM i_journalentryitem INTO TABLE lt_items
WHERE companycode = p_bukrs
AND fiscalyear = p_gjahr.

Strategy 3: Update Field Lengths

S/4HANA extended key fields from 10 to 40 characters. Hardcoded lengths cause dumps.

❌ Problem Code:

DATA: lv_vbeln TYPE c LENGTH 10. " Fixed length!

✅ Fixed Code:

DATA: lv_vbeln TYPE vbeln_va. " Use data element!

Strategy 4: Replace Deprecated Function Modules

SAP provides the Simplification Database listing deprecated objects and replacements.

Common Replacements:

Deprecated: BAPI_CUSTOMER_GETLIST
Use: API_BUSINESS_PARTNER
Deprecated: SD_VBAP_READ_WITH_VBELN
Use: CDS View I_SALESORDERITEM
Deprecated: FI_DOCUMENT_READ
Use: I_JOURNALENTRY CDS

Phase 3: Testing Strategy

Multi-Layer Testing Approach

1. Unit Testing (ABAP Unit)

Test each remediated program in isolation with sample data

2. Integration Testing

Run end-to-end business processes in QA system

3. Performance Testing

Compare execution times vs. ECC baseline (CDS should be faster!)

4. User Acceptance Testing (UAT)

Business users validate outputs match expectations

Automated Tools for Remediation

SAP Native Tools

  • ATC: Built-in code inspector
  • Readiness Check 2.0: Comprehensive analysis
  • Custom Code Migration App: Fiori-based workbench

Third-Party Solutions

  • Automated refactoring tools (AI-assisted)
  • Impact analysis platforms
  • Code usage analytics (identify dead code)

Best Practices & Tips

  1. 1
    Start Early

    Begin remediation 12-18 months before planned go-live. Custom code is always the bottleneck.

  2. 2
    Prioritize Ruthlessly

    Fix only what's business-critical. Decommission 30-40% of unused code.

  3. 3
    Document Everything

    Maintain a remediation tracker: Program name, issue, fix applied, tester, status.

  4. 4
    Involve Business Early

    Some "fixes" change behavior. Get user buy-in before remediation.

  5. 5
    Monitor Post-Migration

    Even "fixed" code may perform differently in S/4HANA. Monitor with SUPTime for runtime issues.

Conclusion

Custom code remediation is the most labor-intensive part of S/4HANA migration, but it's also an opportunity to modernize and simplify your SAP landscape. With systematic analysis, smart prioritization, and the right tools, you can turn this challenge into a competitive advantage.

Need Help with S/4HANA Migration?

SUPTime helps monitor custom code performance during and after migration to catch issues early.

Talk to Our Experts