Sub topic 4
A simpler data model: fewer tables, no stored aggregates
This chapter assumes you know the FI, CO, MM and SD modules, can read basic ABAP, and understand the split between a database and an application layer. It covers the idea behind the simplified data model. The next chapters cover the Universal Journal, Business Partner and material documents in detail.
The ECC pattern: redundancy for speed
ECC 6.0 ran on many databases, and most of them were slow at summing millions of rows. SAP's answer was to store results as well as transactions. Each posting wrote line items, and the system also updated aggregate tables. Two examples:
- In finance, line items sat in tables such as BSEG, and totals sat in GLT0 (general ledger totals) and in separate CO tables.
- In logistics, stock quantities sat in tables such as MARD, and movement history sat in MKPF and MSEG.
Reports read the small aggregate tables, which was fast. The cost was redundancy. The same fact lived in several places, and the copies could drift apart. Reconciling FI with CO, or stock totals with movements, was a regular job.
The S/4HANA pattern: store once, compute on demand
S/4HANA runs only on SAP HANA, an in-memory, column-oriented database. Column storage and compression make it fast to sum one column over a very large number of rows. SAP used this to remove many stored aggregates and index tables. The line items become the single source of truth, and totals are calculated when a query asks for them.
What this looks like in code
In S/4HANA, a general ledger balance can be summed directly from the Universal Journal table ACDOCA. No separate totals table is read.
SELECT SUM( hsl ) AS total_amount
FROM acdoca
WHERE rldnr = '0L'
AND rbukrs = '1000'
AND gjahr = '2024'
AND racct = '0000400000'
INTO @DATA(lv_total).The query filters on ledger (rldnr), company code (rbukrs), fiscal year (gjahr) and account (racct), then sums the amount in company code currency (hsl). Movement history works the same way. Material document items are read from MATDOC, which replaces MKPF and MSEG as the physical store.
SELECT mblnr, mjahr, zeile, matnr, werks, menge
FROM matdoc
WHERE matnr = @lv_matnr
AND werks = @lv_werks
INTO TABLE @DATA(lt_movements).Compatibility views
Removing tables would break every program that reads them. To limit that, SAP keeps the old table names as compatibility views, which are database views defined in the data dictionary. A view such as one standing in for a removed totals table presents the same fields and calculates them from the new source.
Two limits apply:
- Compatibility views are meant for reading. Code that writes to a removed table fails or has no effect.
- Reading through a view that aggregates on the fly can be slower than a query written against the new table.
Common errors
- Writing to removed tables. Custom code that inserts into or updates an old aggregate or index table must be rewritten to post through the standard APIs.
- Assuming a table still exists. A name that works in an ECC system may be absent or only a view after conversion. Check the object type in the data dictionary (transaction SE11).
- Keeping the old read pattern. Code that loops over line items to build its own totals is slower than one
SUMwithGROUP BYpushed down to the database. - Treating the change as only technical. Reports, extractors and interfaces that read the old tables are part of the conversion scope.
Exercise
A custom ECC report reads totals from an aggregate table and a second program inserts rows into that table. After conversion to S/4HANA, which program is more likely to break, and why?
Show answer
The program that inserts rows. Aggregate tables are removed or replaced by compatibility views, and these views are read-only. A reader may keep working through the view, but a writer cannot update data that is now calculated from line items.
Exercise
Why can S/4HANA drop stored aggregates that ECC needed?
Show answer
HANA is an in-memory, column-oriented database that can sum a column over many rows quickly. Totals can be calculated from line items on demand, so storing them separately adds redundancy without a speed benefit.