# SAP Custom Code Inventory ABAP Query Generator (TADIR)

> Source: https://netray.co/tools/sap-custom-code-inventory-tadir-abap-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generates ABAP SELECT statements against TADIR that count and list custom objects by type and package for S/4HANA remediation planning.

## Category

sap

## Erp

SAP S/4HANA

## Audience

- SAP ABAP developer
- SAP program manager
- SAP Basis administrator

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Report name

**Key:** report_name

**Type:** text

**Default:** ZCUSTOM_CODE_INVENTORY

#### Object name pattern (SQL LIKE)

**Key:** name_pattern

**Type:** text

**Default:** Z%

**Help:** Use Z% or Y%, or your namespace such as /ACME/%

#### Package pattern (SQL LIKE)

**Key:** package_pattern

**Type:** text

**Default:** Z%

#### Max rows in detailed list

**Key:** max_rows

**Type:** number

**Default:** 10000

**Blocks:**

#### Count by object type

**Body:** REPORT {{report_name}}.

START-OF-SELECTION.
  SELECT object, COUNT(*) AS cnt
    FROM tadir
    WHERE pgmid = 'R3TR'
      AND obj_name LIKE '{{name_pattern}}'
      AND delflag = @abap_false
    GROUP BY object
    ORDER BY cnt DESCENDING
    INTO TABLE @DATA(lt_types).

  LOOP AT lt_types INTO DATA(ls_type).
    WRITE: / ls_type-object, ls_type-cnt.
  ENDLOOP.

#### Count by package

**Body:** * Add after the first block.
  SELECT devclass, COUNT(*) AS cnt
    FROM tadir
    WHERE pgmid = 'R3TR'
      AND obj_name LIKE '{{name_pattern}}'
      AND devclass LIKE '{{package_pattern}}'
      AND delflag = @abap_false
    GROUP BY devclass
    ORDER BY cnt DESCENDING
    INTO TABLE @DATA(lt_pack).

  LOOP AT lt_pack INTO DATA(ls_pack).
    WRITE: / ls_pack-devclass, ls_pack-cnt.
  ENDLOOP.

#### Detailed list of programs, classes and function groups

**Body:** * Core executable code objects, the usual remediation scope.
  SELECT object, obj_name, devclass, author, created_on
    FROM tadir
    WHERE pgmid = 'R3TR'
      AND object IN ('PROG', 'CLAS', 'FUGR')
      AND obj_name LIKE '{{name_pattern}}'
      AND delflag = @abap_false
    ORDER BY object, obj_name
    INTO TABLE @DATA(lt_obj)
    UP TO {{max_rows}} ROWS.

  LOOP AT lt_obj INTO DATA(ls_obj).
    WRITE: / ls_obj-object, ls_obj-obj_name, ls_obj-devclass, ls_obj-author.
  ENDLOOP.

**Notes:** TADIR lists repository objects, not whether they are used. Combine this inventory with SCMON and SUSG usage data and ATC results before estimating remediation. Needs ABAP 7.40 or later. Run in a non-production system with read access to TADIR.

## Content

**Intro:** Every S/4HANA custom code estimate starts with an honest inventory. This generator produces ABAP that counts and lists your Z and Y objects from TADIR, the central directory of repository objects.

**Sections:**

#### How to use the generated code

**Body:** Enter your naming pattern and package pattern, copy the code into SE38 and run it. The first block gives counts per object type such as PROG, CLAS, FUGR, TABL and DTEL. The second gives counts per package so you can see where the code lives and who owns it. The third lists programs, classes and function groups, which are the objects that usually need code remediation. Export the output to Excel for triage.

**Bullets:**

- Include namespace patterns, not only Z and Y
- Add owners per package after the first run
- Mark packages as retire, keep or rewrite

#### Turning the inventory into scope

**Body:** A raw count overstates the work because many objects are unused. Join the list with SCMON and SUSG usage data to drop code that never ran in the observed period, then run ATC with the S/4HANA readiness check variant on what remains. Remaining findings can be grouped by type, such as table access to changed structures, obsolete statements, and unsupported function modules. That grouped list is the basis for an effort estimate.

#### Common mistakes

**Body:** Do not count only programs. Dictionary objects, enhancements, BAdI implementations and Smart Forms or Adobe forms all create work. Do not trust author names as ownership, since many objects were created by people who left years ago. Do not assume that a package with few objects is low risk, because one interface program can carry the whole business process.

**Cta:** If you want help joining inventory, usage and ATC data into an effort model, Netray can work through it with your team.

**Faq:**

#### What is TADIR?

**Answer:** TADIR is the SAP table that stores the directory of repository objects, with fields such as program ID, object type, object name, package and author. It is the standard starting point for custom object inventories.

#### Does this show unused code?

**Answer:** No. TADIR lists objects that exist. To find unused code you need usage data from SCMON and SUSG collected in production over a representative period.

#### Why filter on delflag?

**Answer:** Objects marked for deletion remain in TADIR for a time. Filtering them avoids counting code that is already retired and prevents inflated estimates.

#### Can I run this in production?

**Answer:** It is read-only and light, but follow your own policy. Many teams run it on a recent production copy, which also gives representative object counts without touching live systems.

## Search terms

tadir custom code inventory, count z objects sap, tadir abap select, custom code s4hana inventory, sap z programs list tadir, custom object count by package, abap object inventory report, s4hana custom code remediation scope

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
