# Replacing SELECT on BSEG in S/4HANA: ACDOCA, I_JournalEntryItem and I_OperationalAcctgDocItem

> Replace SELECT on BSEG in S/4HANA: why ATC flags it, BSEG vs ACDOCA, I_JournalEntryItem or I_OperationalAcctgDocItem, leading ledger, and exemptions.

By ABAP for Agents · Updated 2026-11-09 · https://abapforagents.com/guides/replace-bseg-select-acdoca/

## TL;DR

- BSEG still exists in S/4HANA. It holds the entry view of accounting documents, and ACDOCA (the universal journal) holds the general ledger view, with one set of lines per ledger.
- SAP's Cloudification Repository, the content behind the ATC's released-API checks, marks BSEG and ACDOCA as not to be released. That's why direct SELECTs on them are flagged.
- SAP's named successor for BSEG is I_OperationalAcctgDocItem. For ACDOCA it lists I_JournalEntryItem, I_GLAccountLineItem and I_GLAccountLineItemRawData.
- I_JournalEntryItem returns a row per ledger. Without a ledger filter, totals multiply, so filter on your leading ledger (0L in SAP's standard setup).
- Rewrite when the code is staying. Request an ATC exemption only when it can't or shouldn't be fixed now, and give it a time limit.

Classic ECC code reads accounting line items with `SELECT … FROM bseg`. In S/4HANA that code usually still runs, but the ABAP Test Cockpit (ATC) flags it, and it doesn't fit ABAP Cloud or a clean core. AI assistants trained on ECC-era code keep suggesting it, the kind of direct table read covered in [the 10 mistakes AI makes in ABAP](https://abapforagents.com/guides/ai-abap-mistakes/).

This guide explains why the read is flagged, what BSEG and ACDOCA hold in S/4HANA, which released CDS view replaces which read, the ledger trap, performance points, and when an exemption beats a rewrite. It's based on SAP's Cloudification Repository on GitHub and SAP's documentation on the SAP Help Portal, linked under [Sources](#sources). **We haven't tested this against a real SAP system, and the code below is an illustration, not tested code.** Check view and field names in your release with ADT or the View Browser before you rely on them.

## Why the ATC flags SELECT on BSEG

SAP publishes the list of released and not-released objects in the **Cloudification Repository** on GitHub. Its README describes it as the content for the ATC checks "Usage of Released APIs (Cloudification Repository)" (cloud readiness) and "Usage of APIs" (clean core). Customers can run these checks on custom code "on all ECC and S/4HANA releases".

In both the SAP Cloud ERP file and the latest Private edition file, BSEG and ACDOCA appear like this:

| Table | State | Successor(s) named by SAP |
|---|---|---|
| `BSEG` | `notToBeReleased` | `I_OperationalAcctgDocItem` |
| `ACDOCA` | `notToBeReleased` | `I_JournalEntryItem`, `I_GLAccountLineItem`, `I_GLAccountLineItemRawData` |

All four successor views have the state `released`. So the finding isn't about BSEG being gone. A direct read on a table that SAP won't release is outside what the check allows, and SAP tells you which released view to use instead. Swapping BSEG for a direct `SELECT` on ACDOCA just moves the finding to another table.

## BSEG still exists: entry view vs general ledger view

SAP's S/4HANA documentation (2025) describes two views of the same postings:

- **Entry view:** table BSEG, together with the document header in BKPF.
- **Universal journal or general ledger view:** table ACDOCA.

Ledger-specific entries go to **BSEG_ADD**. SAP's reconciliation checks compare BSEG with ACDOCA, and BSEG_ADD with ACDOCA, in both directions, and "every journal entry must balance to zero in all relevant amounts on BSEG and BSEG_ADD". SAP's summarization docs add that ACDOCA "can, at maximum, be summarized to the level of table BSEG". The two tables are kept in step, but they aren't the same data:

- ACDOCA has lines per ledger.
- BSEG has the entry view.
- Summarization can make either one coarser than the other.

## Which view replaces which read

Start from what the old code actually wants:

| The old BSEG read is for… | Use | Why |
|---|---|---|
| Open items, clearing, payment or tax data for customers and suppliers | `I_OperationalAcctgDocItem` | SAP's named BSEG successor. SAP's Datasphere content describes it as "sourced from BSEG" with "clearing document details, payment data, and tax data" for receivables and payables |
| G/L amounts by account, profit center, cost center or segment | `I_JournalEntryItem` | SAP: "access to all details of a journal entry item (database table ACDOCA)", with company code, G/L account, profit center, segment and more |
| Raw G/L line items, for example for extraction | `I_GLAccountLineItemRawData` | Released, extraction-enabled with CDC delta on ACDOCA. See [CDS views for S/4HANA Cloud data extraction](https://abapforagents.com/guides/s4hana-cloud-cds-extraction/) |

**Fields that only the entry view has.** If the old code reads payment, dunning or tax details from BSEG, don't assume `I_JournalEntryItem` has them. Check the field list in ADT, and look in `I_OperationalAcctgDocItem` first. SAP's own matching apps make the same split: SAP documents an AR/AP matching data source "From BSEG and BKPF" next to data sources built on ACDOCA.

**Deprecated elements.** SAP's page for `I_JournalEntryItem` lists elements deprecated with S/4HANA Cloud Public Edition 2011, with successors, such as `Material → Product` and `SalesOrder → SalesDocument`. New code shouldn't use the deprecated names, even if an older example does.

**Balance carry-forward.** `I_JournalEntryItem` "does not expose technical balance carried forward items of period 000". `I_GLAccountLineItemRawData` includes balance carry-forward postings. Pick the one that matches what your report means by a balance.

## The ledger trap

ACDOCA holds a set of lines for each ledger, and `I_JournalEntryItem` exposes both `Ledger` and `SourceLedger`. `Ledger` is part of the key in published field listings of the view. A BSEG read gave you one line per document item. The same read on `I_JournalEntryItem` without a ledger filter gives you one line per item **per ledger**, so sums double or triple as soon as parallel ledgers exist.

In SAP's standard setup the **leading ledger is 0L**. SAP's ledger setup docs show 0L as the leading ledger for the local accounting principle, or for IFRS when you reverse the assignment. Filter on your leading ledger unless you mean to report a parallel one. Don't hard-code 0L blindly. Check which ledger is leading in your system.

## Performance

- **Filter on the key.** Pass company code, fiscal year and ledger, and the document number when you have it, as you did with BSEG's key. A finance cube with no filter reads a lot.
- **List the fields.** `I_JournalEntryItem` is a wide cube view with many associations. `SELECT *` pulls far more than BSEG reads usually needed.
- **Don't loop and select.** Replace `SELECT SINGLE` in a loop with one set-based read. For `FOR ALL ENTRIES`, keep the empty-table guard from [FOR ALL ENTRIES with an empty table](https://abapforagents.com/guides/for-all-entries-empty-table/).
- **Expect authorization checks.** `I_JournalEntryItem` requires authorizations for ledgers, company codes, financial account types and segments. A rewrite can return fewer rows for a user than the old BSEG read, which had no access control.

## An illustrative rewrite

**Illustration only.** We haven't run this on a system. Field names are taken from SAP's documentation and published listings of `I_JournalEntryItem`, so verify them in your release.

Before, the classic read on BSEG:

```abap
SELECT * FROM bseg
  WHERE bukrs = @company_code
    AND gjahr = @fiscal_year
    AND belnr = @document
  INTO TABLE @DATA(lines).
```

After, the released view, restricted to the leading ledger with an explicit field list:

```abap
CONSTANTS leading_ledger TYPE c LENGTH 2 VALUE '0L'. " check your leading ledger

SELECT FROM i_journalentryitem
  FIELDS companycode,
         fiscalyear,
         accountingdocument,
         ledgergllineitem,
         customer,
         amountincompanycodecurrency,
         companycodecurrency
  WHERE ledger             = @leading_ledger
    AND companycode        = @company_code
    AND fiscalyear         = @fiscal_year
    AND accountingdocument = @document
  INTO TABLE @DATA(journal_items).
```

The item number is `LedgerGLLineItem`, which isn't BSEG's `BUZEI`. Code that joins old and new results on the item number needs to be checked. If the old read was really about open items or payment data, write the same pattern against `I_OperationalAcctgDocItem` instead.

## Exemption or rewrite?

SAP's documentation says an ATC exemption "deactivates an ATC finding or set of findings for a set amount of time". A developer requests one when a finding "is a false positive or currently cannot be repaired or should not be repaired", and a quality manager approves it. The minimum scope is one check message in one include or object, and exemptions "are not user-specific". They hide the finding for everyone working on that code.

A workable rule:

- **Rewrite** code that you're keeping, moving to ABAP Cloud, or touching anyway.
- **Exempt, with a time limit,** code that you're retiring, code that needs entry-view fields that aren't in a released view in your release yet, and cases where a rewrite would need a functional decision first, such as which ledger a report should use. Write the reason and the successor view into the exemption request.

When an AI assistant writes the rewrite, put the successor table above and the ledger rule into its instructions, and keep ATC as the gate. [Claude Code and AGENTS.md for ABAP](https://abapforagents.com/guides/claude-code-agents-md-abap/) shows how. SAP's [ADT MCP server](https://abapforagents.com/guides/adt-mcp-server-vs-code-abap/) lets an agent run the ATC itself, and the free [abap-for-agents-lite](https://github.com/abapforagents/abap-for-agents-lite) rules cover ECC-to-S/4HANA patterns.

## Sources

- SAP on GitHub: [Cloudification Repository (abap-atc-cr-cv-s4hc)](https://github.com/SAP/abap-atc-cr-cv-s4hc), README and the files [objectReleaseInfoLatest.json](https://raw.githubusercontent.com/SAP/abap-atc-cr-cv-s4hc/main/src/objectReleaseInfoLatest.json) and [objectReleaseInfo_PCELatest.json](https://raw.githubusercontent.com/SAP/abap-atc-cr-cv-s4hc/main/src/objectReleaseInfo_PCELatest.json) (entries BSEG, ACDOCA and the successor views)
- SAP S/4HANA (2025): [Data Summarization in Financial Accounting](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/3cb1182b4a184bdd93f8d62e3f1f0741/ad525f4a809e4c15a7b25a5fcec2517e.html), [Summarization of the Universal Journal](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/8fbeed5f2046489696a50ac7fd76f9c6/b16e62717aef44979261da56e1ff612d.html), [Reconcile Journal Entries](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/651d8af3ea974ad1a4d74449122c620e/fbbc914ed0cb462e97d8fa4a53e1a3e9.html) and [General Ledger-Specific Reconciliation](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/caf31ad0fb24449a8c6e820a738d3bc8/3c1f7354b58a49b79f7f3c81a297075e.html)
- SAP S/4HANA Cloud Public Edition CDS views (2608): [Journal Entry Item](https://help.sap.com/docs/SAP_S4HANA_CLOUD/c0c54048d35849128be8e872df5bea6d/47dce95760521070e10000000a44147b.html) and [G/L Account Line Item - Raw Data](https://help.sap.com/docs/SAP_S4HANA_CLOUD/c0c54048d35849128be8e872df5bea6d/7fe239a3f2214e2cb36e90d453eee6d3.html)
- SAP S/4HANA Cloud Public Edition: [Main CDS Views for Accounting](https://help.sap.com/docs/SAP_S4HANA_CLOUD/90c07e91c7a64f328be3fd6b48955b13/bdff67aa4ec449928c87b03ac1a0ed88.html) and [Setup of Ledgers and Depreciation Areas](https://help.sap.com/docs/SAP_S4HANA_CLOUD/3e5fcf2c768746049b5627bd5a42f720/ca8143c09b35455c98c509b9800dedd5.html)
- SAP Datasphere content: [Operational Accounting Document Item](https://help.sap.com/docs/SAP_DATASPHERE/6eb1eff34e4c4b1f90adfbfba1334240/a88ae4e56bfc1014a79e69594ccc91ad.html)
- ABAP platform: [ATC Exemptions](https://help.sap.com/docs/ABAP_PLATFORM_NEW/ba879a6e2ea04d9bb94c7ccd7cdac446/3a759579e173410caa551e0d428bd7d6.html) and ABAP Cloud: [Requesting Exemptions for ATC Findings](https://help.sap.com/docs/ABAP_Cloud/bbcee501b99848bdadecd4e290db3ae4/4ec5865a6e391014adc9fffe4e204223.html)
- Published field listing of `I_JournalEntryItem` key fields (SourceLedger, CompanyCode, FiscalYear, AccountingDocument, LedgerGLLineItem, Ledger): [MuleSoft manufacturing accelerator, SAP S/4HANA setup guide](https://github.com/mulesoft/docs-accelerators/blob/latest/manufacturing/1.4/modules/ROOT/pages/sap-s4hana-setup-guide.adoc)
- Free lite rules (MIT): [abap-for-agents-lite on GitHub](https://github.com/abapforagents/abap-for-agents-lite)

## Get the rules

Start with the free rules: ABAP for Agents Lite (MIT), for Cursor, Claude Code, GitHub Copilot, Windsurf and AGENTS.md: https://github.com/abapforagents/abap-for-agents-lite (ZIP: https://github.com/abapforagents/abap-for-agents-lite/releases/latest/download/abap-for-agents-lite.zip).

The full Rules Pack (v1.1) has 300+ rules across 20 topics (adding performance, security, RAP, CDS, OData and Fiori, ABAP Cloud and clean core, LUW and locks, BAPIs, ABAP Unit and S/4HANA migration) plus 8 agent skills, with free updates: 19 € at launch (29 € after), https://abapforagents.com/#pricing
