How to Identify and Decommission Unused SAP Custom Code Before Migration
4 min read
TL;DR
Most SAP ECC systems carry thousands of custom objects nobody runs anymore. To decommission unused SAP custom code before migration, collect at least 13 months of production usage data, check the dependencies usage logs cannot see, get business owner sign-off, and deactivate before you delete. Every retired object is one less object to remediate, test, and secure.
Introduction
Every S/4HANA program I join starts with the same question: how much of this code do we still need? The answer is usually less than half. smartShift benchmarks put a typical ECC system at about 22,000 custom objects and 2.7 million lines of ABAP, with 40% to 60% of that code potentially unused. Teams that decommission unused SAP custom code before migration shrink their remediation scope, their test cycles, and their security exposure in one move. Teams that skip it pay to convert, test, and maintain code nobody has executed in years. This article shows how we separate the two in practice.
Why Should You Decommission Unused SAP Custom Code Before Migration?
What Unused Code Costs During Conversion
S/4HANA changes data models, tables, and interfaces, so custom code has to be checked and often adapted before it runs on the new system. That effort grows with object count, not with business value. An unused report that reads a table S/4HANA no longer has still appears as a finding in the ABAP Test Cockpit (ATC), SAP’s static code check tool, and still needs a fix, a transport, and a test case.
Unused code also hides risk. Old routines with missing authority checks or hard-coded values rarely get reviewed, which makes them easy to overlook and hard to defend in an audit. SAP’s own custom code adaptation FAQ points out that custom code left unadapted after a conversion should be removed, because it puts data consistency at risk.
Why Teams Still Carry It Forward
The blocker is rarely technical. Nobody wants to own a deletion, and nobody can promise that a quarter-end job or an audit report won’t be needed next spring. Without evidence, migrating everything looks like the safe choice. Recent ASUG and smartShift research found that 92% of organizations expect to carry custom code into S/4HANA, while only 17% describe their code as significantly optimized for clean core.
How Do You Identify Unused SAP Custom Code?
Collect Usage Data Across a Full Business Cycle
Start with production usage data, not a where-used list. SAP gives you several sources. The ABAP Call Monitor (SCMON) records which programs and procedures are called in production. Transaction SUSG aggregates that SCMON data over longer periods. Usage and Procedure Logging (UPL) does a similar job through SAP Solution Manager. The SAP Custom Code Migration app can then use those snapshots to scope out code that never runs.
Time matters more than the tool. Thirteen months of data covers year-end closing, annual tax runs, and seasonal peaks. A three-month sample will flag your annual depreciation report as unused, and someone will notice in January. Switch monitoring on as early as you can, because usage history cannot be filled in later.
Map the Dependencies Usage Data Misses
Usage logs show what ran. They don’t show what is still referenced. A function module that never executes may sit in an include that an active program loads, and dynamic calls, RFC entry points, and background job variants often slip past static checks. Map every candidate against its callers, data dictionary objects, and interfaces first. In a smartShift Code Analysis, we combine usage data with a dependency model of the full repository, so an object only qualifies for retirement when it is both unused and unreferenced by anything active.
Get Sign-Off From Business Owners
Usage data proves that code didn’t run. It doesn’t prove that nobody needs it. Regulatory reports, disaster recovery routines, and once-a-year interfaces can sit idle for months and still be mandatory. Send the candidate list to process owners grouped by module, with last-execution dates and a fixed deadline. Objects without an owner should default to retirement, not migration.
How Do You Retire Unused ABAP Code Safely?
Deactivate First, Delete Later
Safe SAP custom code decommissioning is reversible. Instead of deleting objects outright, flag them so they can’t execute, keep a full backup, and watch for requests. CONA Services used this approach during its S/4HANA move. smartShift identified about 1,000 custom objects that could be retired, and the team let the system run for six months before deleting anything. When a user still needed an object, IT removed the flag and the object was active again.
Automate at Repository Scale
Reviewing a few hundred objects by hand is manageable. Reviewing 20,000 is not. Automated code decommissioning applies the same rules to every object: usage, dependencies, documentation, and backup. smartShift also remediates code before it is retired, so anything restored later already works on S/4HANA. The same platform then transforms the code that stays, and Dual Maintenance keeps ECC changes in sync until go-live. Here is what that looks like in customer programs:
|
Customer |
Scope |
Result |
|---|---|---|
|
CONA Services |
45,084 custom objects and 5.8 million lines of code |
About 1,000 objects identified for decommissioning and all custom code transformed in 3 months |
|
Salling Group |
30,000+ custom objects and 1.8 million+ lines of code |
256,000+ coding issues resolved in 5 weeks, with only 12 custom code tickets raised in testing |
|
Procter & Gamble |
77,000 custom objects |
Transformed in 8 weeks with an error rate below 0.01% |
|
Beiersdorf |
33,000 custom objects and 5.6 million lines of code |
69,000 issues fixed in under 6 weeks |
Before you start, get clear answers to these questions:
- Is SCMON or UPL running in production today, and how many months of data do we have?
- Who signs off on retirement for each module, and by when?
- How will we catch dynamic calls and RFC-enabled function modules?
- What is the restore process if a retired object is needed after go-live?
- Do we retire code before remediation starts, and who confirms the final scope?
Conclusion
Unused code is the cheapest scope reduction available in an S/4HANA program. Finding it takes a full business cycle of usage data, a dependency check that catches what logs miss, and business sign-off for every object you plan to retire. Retiring it safely means deactivating first, keeping a backup, and deleting only after a waiting period. Done across the whole repository, this cuts remediation effort, test cases, and security exposure before conversion starts, and it gives clean core governance a smaller baseline to manage afterward.
Book a free Rapid Code Analysis to see how much of your custom code is ready to retire.
Pablo Iglesias is a Solutions Architect at smartShift with more than 12 years of experience in enterprise software. He combines deep technical expertise with a background in consultative sales, helping global customers modernize and optimize their SAP systems. His focus areas include cloud migration, SAP modernization, enterprise architecture, and value-based solution selling. Pablo works closely with customer stakeholders to design scalable, secure, and cost-efficient solutions, and he is known for turning complex technology into clear business value.