Skip to content

KorhanKara/abap-clean-core-successors / skill/clean-core-successors

clean-core-successors

Unverified

Answer which released CDS view field replaces a classic SAP table field (MARA-MATNR to I_PRODUCT-Product), what replaces another SAP object such as a function module, class or old CDS view, and rewrite simple SELECTs from a classic table to a released CDS view, from data read out of a real SAP system. Use whenever the user asks what to use instead of a table, table field, function module, BAPI, class or data element, which CDS view replaces a table, how to migrate a SELECT to a released API or clean core, or shares a SELECT on a classic table. Also use to load the user's own file downloaded from the ZCLEAN_CORE_SUCCESSORS report.

Clean core successors

The user wants to replace a classic SAP object with a released one: a table with a released CDS view, a function module, class or data element with its released successor. SAP publishes which object replaces which. This skill adds what SAP does not publish, which view field replaces which table field, and whether a successor really clears the ATC finding.

Answer from the data, never from memory. CDS field names look guessable and are not: MARA-MATKL is ProductGroup, not MaterialGroup.

Look it up

Run the scripts from this skill's folder. Use python3, or py -3 on Windows.

python3 scripts/lookup.py --table MARA --field MATNR   # which view field replaces this field
python3 scripts/lookup.py --table MARA                 # all views and their full mapping
python3 scripts/lookup.py --cds I_PRODUCT --field ProductGroup   # where a view field comes from
python3 scripts/lookup.py --rewrite "SELECT SINGLE matnr matkl FROM mara INTO @DATA(ls_mara) WHERE matnr = @lv_matnr."
python3 scripts/lookup.py --object BAPI_PROCORD_GET_DETAIL   # successor of any object, * as wildcard
python3 scripts/lookup.py --object I_STOCK* --type DDLS

Not-released views are skipped. Add --allow-unreleased only to explain why a view SAP names is not usable.

How to answer

  • Show the change, then ask before applying it. Always. For every fix, show the old code and the new code one after the other, with a short table of what each old field or object became and what was left out and why. Then ask the user whether to apply it. Do not write to the user's system, file or editor until they say yes, even when they asked you to "fix" or "convert" the code. If they say no, leave everything as it was.

  • Several views can cover one field. MARA-MATNR is Product in five views. Prefer the view that covers every field the user's SELECT reads, so the statement keeps one source. --rewrite sorts candidates by fewest unmappedFields. For a single field the data gives no ranking: list the views and ask which other fields the user reads, instead of picking one from memory.

  • computed: true in a --cds --field answer means the view field has no single column: readsColumns and expression say what it is built from.

  • Alias every renamed field as CdsField AS original_field. The rest of the program still uses the old names, and the alias keeps the change to one statement. --rewrite already does this; do the same in any rewrite you write by hand (joins, subqueries, FOR ALL ENTRIES).

  • Write the SELECT in this order: field list, FROM, WHERE, GROUP BY, ORDER BY, INTO, UP TO, one clause per line. --rewrite already does this, and maps table columns in WHERE and ORDER BY too.

  • Report unmapped fields, never drop them. A field missing from a view means that view is the wrong target or the rewrite needs a join. Dropping it gives code that compiles and returns wrong data.

  • usedInExpression is information, not a replacement. It lists view fields that use the column inside a CASE, a calculation or a function, with the definition. The value can differ from the column, so do not alias the view field to the column. Show the expression and let the user decide.

  • An empty mapping can be correct. A view SAP names as successor can read a different table or take a field through an association.

  • A mapping is not proof of the same rows. The view can filter or join. Present rewrites as drafts to compile and test, and name the release the data was read from (dataRelease in the output) when it matters.

  • Recommend only successors that clear the ATC finding. --object marks each row with clearsAtcFinding; only abapCloud: Released is true. A Key user only successor is released for key user apps but not for ABAP Cloud, so ATC still reports it as an internal API; Not released is not usable either. When asked about such an object, name SAP's successor but say plainly that using it would not clear the ATC finding, and do not put it into a rewrite. The report's screen hides these successors for the same reason.

  • A function module has no field mapping. For --object results, give the successor and its type; for a CDS successor of a table, continue with --table.

  • No row for an object means SAP's list names no successor. It does not mean the object is safe to use. Say what the data shows and do not invent a successor.

The data

references/core-data-services.json holds one entry per table and view pair: tableName, cdsName, released and a mapping list. Each row has cdsField and tableField. Rows with computed: true also carry expression and definedIn: the view field reads that column inside an expression. A row with an empty tableField could not be traced to a column of the table.

references/successors.json holds one row per object and successor: objectType, objectName, objectState, successorType, successorName and abapCloud. Function modules appear under their own name.

references/DATA_VERSION.json records where each file came from. Both bundled files are read from a standard S/4HANA 2025 system (S4CORE 109 SP1) with add-on and customer fields removed. Other releases can have other fields and other successors; the user's own file settles that.

Use the user's own system

When the user's release differs, or they want their own extension fields, they can load their own data:

  1. Install the ZCLEAN_CORE_SUCCESSORS report from this repository, with abapGit or by pasting standalone/zclean_core_successors.abap into a new report.
  2. Run it and press Download JSON in the toolbar. The report asks where to save the file; any folder works.
  3. Run python3 scripts/import_mapping.py <path to the file> from this skill's folder, the copy the assistant loads. The file carries its release; --release only overrides it.

The one file holds both the mapping and the successor list. The import replaces both bundled files and keeps the old ones with a .bak suffix. The new files can hold the user's own fields, so they stay on their machine.

Releases before S/4HANA 2022

The report needs S/4HANA 2022 or later: it reads SAP's successor list in the system, which is the same data ATC's "Usage of APIs" check reads, and SAP fills that list from 2022 on. On an older release the report stops, and this skill with its bundled S/4HANA 2025 data is the only source. When the user is on an older release, answer from the bundled data and say once that it comes from S/4HANA 2025: a view, field or successor it names may not exist in their release yet, so they should check it in their system (SE11, ADT) before using it.

Creating objects in an SAP system is the user's decision. Do not install or run the report for them without asking.

receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall