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 and a trial balance are, and the basic roles of company code and controlling area from the previous chapter. The optional SQL examples need only basic SELECT, GROUP BY, and HAVING.
The problem the Universal Journal solves
Before SAP S/4HANA, the same business event wrote its numbers to several tables. Financial Accounting stored line items in BSEG and headers in BKPF. Controlling stored cost line items in COEP. Profitability analysis, asset accounting, and the material ledger each kept their own copies. Reconciliation reports existed to prove that these copies agreed.
In S/4HANA, one table holds the line items for all of these areas. It is ACDOCA, the Universal Journal. A posting writes each line once, and that line carries both its accounting fields and its controlling fields.
What an ACDOCA line contains
Each row is one line item of a journal entry in one ledger. The fields below are the ones you will use most often.
| Field | Meaning |
|---|---|
| RLDNR | Ledger, for example 0L for the leading ledger |
| RBUKRS | Company code |
| GJAHR | Fiscal year |
| BELNR | Journal entry number |
| DOCLN | Line item within the entry in that ledger |
| RACCT | G/L account |
| POPER | Posting period |
| HSL | Amount in company code currency, signed |
| KSL | Amount in group currency, signed |
| RCNTR | Cost center |
| PRCTR | Profit center |
| RASSC | Trading partner, used for intercompany |
| DRCRK | Debit or credit indicator |
A few points about these fields:
- Amounts such as HSL are signed. Debits are positive and credits are negative, so a plain SUM gives a balance.
- Amounts in other currencies appear in parallel columns, such as the transaction currency and up to several additional currency types.
- Controlling objects like cost center, profit center, order, and WBS element sit on the same row as the G/L account. That is the "one table for accounting and controlling" idea.
How a posting flows into ACDOCA
A journal entry has a header and line items. The header is stored in BKPF. The lines are written to ACDOCA, with one row per line per ledger. If you post to a leading ledger and a non-leading ledger that differ for this entry, each ledger gets its own rows.
Because every source uses the same engine and table, a controlling allocation is a real journal entry. It carries a document number, a ledger, and a period, and it appears next to Financial Accounting postings.
Reading the table with SQL
The first query sums HSL by G/L account for one company code, one fiscal year, and the leading ledger, up to period 012. The values 1010 and 2025 are samples.
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).Three things to notice:
- The ledger filter is required. Without
rldnr, rows from every ledger are added together and the totals are wrong when you run parallel accounting. - The period filter turns a year-to-date balance into a balance as of a period. Period 000 holds carried-forward balances, so including it is correct for balance sheet accounts.
- In production code you would read released CDS views, not the table. Views are stable across releases and apply authorizations. Direct table access is fine for learning and for quick checks.
Checking that entries balance
Every journal entry must net to zero in company code currency. The second query looks for entries that do not. For a single-currency company code it should return no rows.
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).Group by ledger as well as entry number. An entry can exist in several ledgers, and each ledger's rows must balance on their own.
Edge cases and common errors
- Summing across ledgers. The most frequent mistake. Always filter on
rldnror group by it. - Ignoring the period 000 convention. Balance carryforward lines are stored in period 000. A query that starts at period 001 misses them and shows only the activity for the year.
- Expecting balanced entries per account. Balance is per entry, not per row. A single row is never balanced by itself.
- Multi-currency entries. Lines in a foreign currency balance in transaction currency, and in each local currency type. A rounding difference in one currency can still appear. The
HAVINGcheck above looks at company code currency only. - Reading line item order. DOCLN is a ledger-level line number. It can differ from the item number you see in the entry display.
- Technical lines. Some rows exist only for ledger-specific effects, such as valuation differences. They are real rows and count in the totals.
Why this matters for the rest of the close
Many later steps rely on this design. Trial balance and financial statements read ACDOCA. Allocations post in the same table, so a cost center and its G/L account always agree. Reconciliation between Financial Accounting and Controlling is no longer a separate job, because both are the same rows.
Exercise
A colleague runs the balance query for company code 1010 without a filter on RLDNR, and the totals are twice what the leading ledger shows. The company code has two ledgers that both hold the same entries. What is the cause, and how do you fix the query?
Show answer
The query adds the rows of both ledgers, so each entry counts twice. Add the condition rldnr = '0L' (or whichever ledger you want to report on) to the WHERE clause, or add rldnr to the SELECT list and GROUP BY so each ledger is shown separately.
Exercise
What does the second query in this chapter return for a consistent single-currency company code, and why group by ledger and entry number?
Show answer
It returns no rows. Each journal entry nets to zero in each ledger, and the same entry number can appear in several ledgers, so the check must group by ledger and entry number to test each ledger's rows on their own.