← All posts

Industry

Dead Code in an SAP Environment: Why It Costs More Than You Think

Dead Code in an SAP Environment: Why It Costs More Than You Think

Unused custom objects inflate every estimate. A migration team scopes 40,000 custom objects, prices the work by the count, and only later learns that a large share of them never ran at all. Dead code in an SAP system is custom code that sits in the repository but never gets executed by a user, a job, or an interface. At 2iSolutions US, an SAP partner delivering since 2005, we see this pattern in almost every assessment, and teams who invest in SAP HANA Performance Optimization see it even more clearly.

The surprise is not that dead code exists. The surprise is its size, and how little of it anyone can name.

What Is Dead Code in an SAP System?

Dead code is custom ABAP, enhancements, interfaces, and dictionary objects that remain in the system but never run in production. It adds no business value. It still adds cost, because every estimate, test cycle, and upgrade plan counts it as live work.

Most of it arrives by accident. A developer builds a report for a one-time audit in 2011. A project team copies a standard program, changes three lines, and abandons the copy when requirements shift. A department retires a process but never tells the technical team.

Nobody deletes these objects because nobody is sure they are safe to delete. So they stay. Over fifteen or twenty years, the pile grows into something that dwarfs the active code base.

Why Nobody Sees It

Developers know the code they wrote last year. They rarely know the code a contractor wrote in 2008. Documentation, where it exists, describes what the object was meant to do, not whether anyone still uses it.

Ownership is the other problem. Business teams assume IT tracks custom objects. IT assumes the business would complain if something broke. Between those two assumptions, nobody checks.

Where Dead Code Hides

Dead code is not limited to reports. It spreads across every layer of the system, which is why a simple program search never finds it all. The usual hiding places look like this:

  • Custom reports and transactions built for a single project or audit
  • Enhancements and user exits attached to programs the business no longer runs
  • Interfaces to partner systems that closed or changed years ago
  • Dictionary tables and structures that no active program reads
  • Copied standard programs that drifted from the original and then went quiet

Each category needs a different check. A table may look unused in one view and still feed a nightly extract. That is why a careful assessment looks at several evidence sources at once instead of trusting a single report.

How Runtime Statistics Expose Unused Objects

Runtime statistics are usage records the SAP system collects as programs, transactions, and function modules run. They answer one plain question: did this object execute, and how often? Reading them turns a guess about usage into a fact.

This is the core of how a environment assessment works. Our agents read the custom repository, enhancements, interfaces, dictionary objects, and runtime statistics. They do not read business data. That boundary matters to security teams, because the analysis needs the shape of the system, not the contents of your ledgers.

What the Analysis Compares

The method sets two lists side by side. One lists everything custom that exists. Another lists everything that actually ran during the observation window.

Between them lies the dead code candidate list. A few checks then separate true dead code from rarely used code:

  1. Confirm the usage window covers period-end, year-end, and seasonal processes.
  2. Check whether an interface or batch job calls the object and logs elsewhere.
  3. Trace enhancement hooks to see whether the host program still runs.
  4. Flag objects referenced only by other dead objects.
  5. Review the remaining list with business owners before removal.

Step four deserves attention. Dead code often hides other dead code. So a function module that looks active because a report calls it is not active if the report itself never runs.

The Window Problem

A short observation window produces false positives. A quarter-end close program may run four times a year. If your statistics cover six weeks, that program looks dead when it is not.

For that reason, the assessment must cover a full business cycle at minimum. Longer is safer. Teams that skip this step delete something critical once, and then refuse to delete anything again.

Why Unused Objects Inflate Every Estimate

Unused custom objects inflate estimates because most migration and upgrade quotes price work per object. If the object count includes dead code, the quote includes work that adds no value. Every test script, code review, and remediation hour multiplies across objects nobody needs.

Consider a simple scenario. A manufacturer plans a move to SAP S/4HANA and counts 30,000 custom objects. The vendor prices a fixed amount per object for analysis, simplification, and testing. If a large share of those objects never ran, the company pays for remediation of code that could have been deleted for almost nothing. The wider SAP clean core discussion makes a similar point about how custom gaps drive project effort.

The cost does not stop at the quote. Testers write scripts for programs nobody uses. Project managers add weeks to the plan. Business users sit through workshops about reports they have never opened.

The Hidden Drag on Daily Operations

Dead code also taxes the system between projects. Every support ticket that touches a custom area starts with an investigation into what the object does. Engineers spend hours tracing a program, only to learn that nobody has run it in six years.

Upgrades slow down too. Each support pack and each notes review has to consider custom code that might break. A bigger code base means a bigger regression surface, and a bigger surface means longer test cycles.

Security and Audit Exposure

Unused code is still code. An old report may skip authority checks that the team later added everywhere else. A forgotten interface may still accept connections. Auditors do not care whether an object runs. They care whether it can.

Removing dead code shrinks the attack surface and the audit scope at the same time. That benefit rarely appears in a project business case, yet it often matters most to the security team.

What a Environment Assessment Delivers

A environment assessment gives you an evidence-based list of what exists, what runs, and what you can remove. It replaces opinion with usage data, so migration scope, budget, and risk can be set from facts rather than from the raw object count.

The output works best when it sorts objects into clear groups. Teams can then act on each group without arguing about every single program.

  • Active objects that must be carried forward and tested
  • Rarely used objects that need a business owner decision
  • Dead objects safe to delete before migration starts
  • Objects that duplicate standard functionality now available out of the box

The last group surprises many teams. SAP has added a lot of standard capability over the years. A custom report built in 2009 to fill a gap may now duplicate a standard app. Retiring it removes code and improves user experience at once.

Turning the List Into a Plan

A candidate list is not a deletion order. Good teams work through it in waves. They start with objects that have no references and no usage, then move to objects owned by retired processes, and leave the debated items for last.

Each wave needs a rollback path. Transports can be reversed, and backups give a safety net. With that net in place, business owners agree to deletions much faster, because the cost of a mistake is small and known.

Cleaning Up Before You Migrate

Cleaning up before a migration is cheaper than cleaning up during one. Dead code removed first never enters scope, so it never needs analysis, remediation, or testing. The sequence matters as much as the work itself.

According to the SAP product information for SAP S/4HANA at https://www.sap.com/products/erp/s4hana.html, the platform changes data models and standard functions that custom code often depends on. Custom code that touches those areas needs attention. Custom code nobody runs needs only a delete button.

Performance Is Part of the Case

Clutter affects speed as well as cost. Teams that plan SAP HANA Performance Optimization often find that unused tables, stale extracts, and abandoned jobs take memory and processing time from the work that matters. Removing them gives the database less to carry before anyone touches a single query.

Likewise, SAP HANA Performance Tuning works better on a clean base. Tuners can focus on the programs users actually wait for, instead of sorting through hundreds of objects that never run. Faster analysis and clearer priorities follow.

Who Should Own the Work

Cleanup needs both technical skill and business judgment. Developers can read code, but only process owners can say whether a quarterly report still matters. The best results come from a joint review, with usage data on the table.

Many companies lack the spare capacity to run this alongside daily support. Partners who offer SAP Consulting Services USA can supply the tooling and the experience, while internal teams supply the business context. After the cleanup, ongoing SAP Support Services keep the code base from filling up again.

Keeping Dead Code from Coming Back

Cleanup fails if nothing changes afterward. Within two years, new one-off reports and abandoned copies refill the repository. A few habits prevent that:

  1. Require an owner and a retirement review date for every new custom object.
  2. Run a usage check after each major release.
  3. Delete project-specific objects when the project closes.
  4. Add dead code metrics to the regular IT report.

These steps take little effort. They also give the finance team a number to watch, which keeps the topic on the agenda.

What Skilled SAP Professionals Gain From This Work

Code cleanup is a strong career lane for SAP developers and architects. Few consultants build a reputation for deleting code, yet the skill is in demand, because every S/4HANA program needs someone who can separate live code from dead weight.

If you work in ABAP, learn to read usage statistics and enhancement references. If you work in functional roles, practise running business owner reviews. Combining both skills makes you the person every migration team wants early in the project, before the scope is locked.

Hiring leaders should note the same point. A consultant who can shrink scope is worth more than one who can only remediate it. Ask candidates how they verify that an object is truly unused, and listen for mention of observation windows and indirect callers.

Frequently Asked Questions

Q. How much of a typical SAP custom code base is dead code?

A. The share varies by company and by system age. Older systems with many projects behind them usually carry the most unused code, and an assessment of your own usage statistics gives the only reliable number.

Q. Is it safe to delete unused custom objects?

A. It is safe when you use a full observation window, check indirect callers, and keep a rollback path through transports and backups. Business owner review of the final list removes the remaining risk.

Q. Does a dead code assessment read our business data?

A. No. At 2iSolutions US, the agents read the custom repository, enhancements, interfaces, dictionary objects, and runtime statistics only. They never read ledgers, orders, or employee records.

Q. How long should the observation window be?

A. Cover at least one full business cycle, including year-end. A shorter window flags period-end programs as unused when they are not.

Q. When should we remove dead code, before or during migration?

A. Remove it before. Objects deleted early never enter the migration scope, so they cost nothing in analysis, remediation, or testing.

Knowing What You Own Before You Decide What to Move

Dead code is larger than expected because nobody measures it. Years of projects, copies, and retired processes pile up, and the object count looks like workload when much of it is not. Usage data turns that count into a real scope.

The practical path is short. Measure what runs, confirm the findings with business owners, delete in waves, and set habits that keep the code base lean. Each step lowers cost and risk before the migration clock starts.

2iSolutions US has run this analysis across many SAP systems, and the first question we ask is always the same: what actually runs? Answering it early gives you a smaller scope, a firmer budget, and a clearer plan for the move ahead.

Email us at [email protected] to book an AI environment assessment.

Want this applied to your SAP estate?

Tell us where you are and we'll come back with a concrete next step.

Talk to our team