Sub topic 4
The Universal Journal: one line-item table for accounting and controlling
This chapter assumes you know debits and credits, what a general ledger (G/L) account is, and how company codes and charts of accounts relate (covered in the earlier chapters). Basic SQL reading helps for the optional data checks.
The problem the Universal Journal solves
Before SAP S/4HANA, financial accounting (FI) and controlling (CO) stored line items in separate tables, such as BSEG for FI and COEP for CO. Totals lived in more tables, such as GLT0. Teams then spent time on reconciliation between FI and CO after every close.
In S/4HANA, the Universal Journal stores both views in one line-item table, ACDOCA. Each journal entry line carries the account and the controlling objects (cost center, profit center, order, and so on) together. FI and CO cannot drift apart, because they read the same line.
What an ACDOCA line contains
Each row is one line of a journal entry in one ledger. These fields matter most:
| Field | Meaning |
|---|---|
| RLDNR | Ledger, for example 0L for the leading ledger |
| RBUKRS | Company code |
| GJAHR, BELNR, DOCLN | Fiscal year, document number, line item |
| RACCT | G/L account |
| POPER | Posting period |
| HSL | Amount in company code currency, signed (debit positive, credit negative) |
| RCNTR, PRCTR | Cost center, profit center |
The key includes the ledger. A document posted to two ledgers has lines in each, so always filter by ledger when you total amounts.
Querying balances
Because amounts are signed, a balance is a plain sum. This query totals HSL per G/L account for the leading ledger.
SELECT racct,
SUM( hsl ) AS balance
FROM acdoca
WHERE rldnr = '0L'
AND rbukrs = '1010'
AND gjahr = '2025'
AND poper <= '012'
GROUP BY racct
ORDER BY racct
INTO TABLE @DATA(lt_balances).The values 1010, 2025, and 0L are samples. Production code should read released CDS views rather than the table directly.
Consistency check
Every journal entry must net to zero per ledger in a single-currency company code. This query finds the ones that do not.
SELECT rldnr, rbukrs, gjahr, belnr,
SUM( hsl ) AS doc_balance
FROM acdoca
WHERE rbukrs = '1010'
AND gjahr = '2025'
GROUP BY rldnr, rbukrs, gjahr, belnr
HAVING SUM( hsl ) <> 0
INTO TABLE @DATA(lt_unbalanced).An empty result is the expected outcome.
Common errors
- Summing without a ledger filter. This double counts every amount posted to more than one ledger.
- Reading all periods when you want a cut-off. Use POPER to limit the range.
- Mixing currencies. HSL is in company code currency only. Other currencies sit in separate amount fields.
- Treating ACDOCA as an interface. Custom code that reads it directly can break on upgrades. Use released CDS views.
Exercise
A document is posted to the leading ledger 0L and to a non-leading ledger. You sum HSL for the company code and year without a ledger filter. What goes wrong, and how do you fix the query?
Show answer
Each amount appears once per ledger, so totals are double counted. Add rldnr = '0L' (or the ledger you want) to the WHERE clause.