Sub topic 9
Custom code analysis and adaptation
This chapter assumes you know what custom ABAP code is, how a development, quality, and production landscape works, and what simplification items are (covered in an earlier chapter). It covers how to find which custom code breaks in S/4HANA and how to fix it.
Why custom code matters
Most ECC systems hold years of custom reports, enhancements, interfaces, and forms. Many were written before S/4HANA existed. S/4HANA changes the data model and removes some objects, so custom code that reads or writes the old structures can fail or return wrong results.
Custom code work matters most in a brownfield conversion, because the code travels with the system. In a greenfield project you start clean and only rebuild what you still need. In a selective transition, the amount of code you carry depends on the scope you choose.
What breaks
- Code that selects from tables that no longer exist or that now hold different content. Examples are the old aggregate and index tables in finance, and the customer and vendor master tables, which are replaced by the business partner model.
- Code that calls function modules or classes that were removed or replaced.
- Code that assumes field lengths that changed, such as the longer material number.
- Code that is slow on SAP HANA because it relies on patterns that suited older databases.
The analysis tools
SAP provides checks that compare your custom code against the S/4HANA simplification database.
- ABAP Test Cockpit (ATC) runs the S/4HANA readiness check variant against your code and lists findings by object.
- Custom Code Migration app (in the Fiori launchpad of a central check system) gathers findings and tracks the work.
- Usage data collection records which custom objects actually run in production. The tools for this are the ABAP call monitor (SCMON) and the usage and procedure logging (UPL).
Run the checks on a central ATC system, which can scan a remote ECC system's code. Keep that system on a current release so it has the latest check content.
" Typical pattern flagged by the S/4HANA readiness check:
" direct read of the removed customer master table
SELECT SINGLE name1 FROM kna1
INTO @DATA(lv_name)
WHERE kunnr = @lv_kunnr.KNA1 still exists, but customer data is now maintained through the business partner. The check flags this kind of access so you can decide whether a read is still valid.
Reduce first, then adapt
Usage data lets you shrink the problem before fixing it. A common sequence:
- Collect usage data for at least a full business cycle, ideally including year-end.
- Split custom objects into used and unused.
- Retire unused objects. Do not fix code nobody runs.
- Run ATC on what remains.
- Prioritize findings by business criticality and effort.
Adapting the code
Some fixes are automatic. SAP offers quick fixes in ABAP Development Tools for common findings. Others need manual redesign, such as moving logic that depended on removed tables to the new data sources.
Timing differs by path. In a brownfield conversion you adapt code in two phases. Fixes that work in both releases are made in ECC before the conversion. Fixes that only work in S/4HANA are made after the system is converted.
Common errors
- Skipping usage data, then spending effort on dead code.
- Collecting usage for too short a period and retiring code that runs once a year.
- Fixing syntax findings but not testing the result. A clean check does not prove the business result is correct.
- Ignoring performance, so code that passes the checks runs slowly on HANA.
Exercise
Why should you collect usage data before running the ATC readiness checks and fixing findings?
Show answer
Usage data shows which custom objects actually run in production. You can retire the unused ones and fix only the used ones, which reduces effort and avoids repairing dead code.