Replacing SELECT on BSEG in S/4HANA: ACDOCA, I_JournalEntryItem and I_OperationalAcctgDocItem
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.
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. 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 |
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_JournalEntryItemis a wide cube view with many associations.SELECT *pulls far more than BSEG reads usually needed. - Don't loop and select. Replace
SELECT SINGLEin a loop with one set-based read. ForFOR ALL ENTRIES, keep the empty-table guard from FOR ALL ENTRIES with an empty table. - Expect authorization checks.
I_JournalEntryItemrequires 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:
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:
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 shows how. SAP's ADT MCP server lets an agent run the ATC itself, and the free abap-for-agents-lite rules cover ECC-to-S/4HANA patterns.
Sources
- SAP on GitHub: Cloudification Repository (abap-atc-cr-cv-s4hc), README and the files objectReleaseInfoLatest.json and objectReleaseInfo_PCELatest.json (entries BSEG, ACDOCA and the successor views)
- SAP S/4HANA (2025): Data Summarization in Financial Accounting, Summarization of the Universal Journal, Reconcile Journal Entries and General Ledger-Specific Reconciliation
- SAP S/4HANA Cloud Public Edition CDS views (2608): Journal Entry Item and G/L Account Line Item - Raw Data
- SAP S/4HANA Cloud Public Edition: Main CDS Views for Accounting and Setup of Ledgers and Depreciation Areas
- SAP Datasphere content: Operational Accounting Document Item
- ABAP platform: ATC Exemptions and ABAP Cloud: Requesting Exemptions for ATC Findings
- Published field listing of
I_JournalEntryItemkey fields (SourceLedger, CompanyCode, FiscalYear, AccountingDocument, LedgerGLLineItem, Ledger): MuleSoft manufacturing accelerator, SAP S/4HANA setup guide - Free lite rules (MIT): abap-for-agents-lite on GitHub
Get the rules
Start with the free rules: ABAP for Agents Lite (MIT) has the core rules from this guide, ready for Cursor, Claude Code, GitHub Copilot, Windsurf and AGENTS.md, in English and Portuguese.
Need more? 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. It is 19 € at launch (29 € after).
More guides
ABAP mistakes AI coding assistants make, and how to prevent them
The pillar guide. Nine repeat mistakes, why models make them, and the rule or code pattern that prevents each one.
FOR ALL ENTRIES with an empty table: the trap and the fix
Why an empty driver table reads the whole database table, the one-line guard, the silent duplicate-row trap, and the alternatives.
Cursor rules for SAP ABAP: a setup guide
Project rules in .cursor/rules for ABAP: rule types, glob patterns for abapGit and ADT files, an always-on core rule and a quick test.
Using Claude Code and AGENTS.md with SAP ABAP
One AGENTS.md for every agent, a CLAUDE.md that imports it, an on-demand review skill, and how to check that Claude Code loaded them.
GitHub Copilot custom instructions for ABAP
copilot-instructions.md for the core rules, applyTo-scoped instruction files for ABAP sources, a review prompt file, and where each one works.
SAP's ADT MCP server with Claude Code, GitHub Copilot and Codex
What SAP's ADT MCP server in ABAP development tools for VS Code is, how to connect Claude Code, Copilot and Codex, and a read-only-first setup.
Column totals in a Fiori Elements List Report with RAP and CDS
How to get a totals row in an OData V4 List Report from RAP: the two CDS annotations, currencies and units, the table type, and what to check when the sum doesn't show.
Extracting data from SAP S/4HANA Cloud with released CDS views
How SAP S/4HANA Cloud exposes data for extraction: C1-released CDS views with @Analytics.dataExtraction, the CDS_EXTRACTION route into Datasphere, key views and the A_ OData API limits.