Sub topic 15
What changes in SAP S/4HANA
This chapter assumes you can read VBFA, EKBE and BKPF in SE16N and write a basic ABAP SELECT, as in the earlier chapters. It covers what stays the same in S/4HANA and what changes under the surface.
The concept stays, some storage moves
Document flow still works as a chain of reference links. Sales links are still in VBFA. Purchase order history is still in EKBE. Accounting documents still point back to their source through BKPF. Your tracing logic from the earlier chapters keeps working.
The changes are in the tables that hold the follow-on documents themselves.
| Area | Before S/4HANA | In S/4HANA |
|---|---|---|
| Material documents | Tables MKPF (header) and MSEG (items) | Table MATDOC. MKPF and MSEG remain as compatibility views. |
| Accounting line items | BSEG plus index tables such as BSIS and BSID | Table ACDOCA, the Universal Journal. BKPF remains as the header. |
| Document status | Status tables VBUK and VBUP | Status fields sit in the header and item tables, such as VBAK and VBAP. |
| Customers and vendors | Separate master records | Business Partner is the leading object. |
A compatibility view is a read-only view with the old table name. It lets old SELECT statements run, but it is built on top of the new table.
Where the links live now
A material document is still the link between a goods receipt and the purchase order. EKBE still records it. The material document itself now sits in MATDOC. Code that reads MKPF or MSEG still works through the views. New code should read MATDOC.
On the accounting side, BKPF still carries AWTYP and AWKEY. ACDOCA carries the reference fields as well, with the reference transaction in AWTYP and the reference document number in AWREF. You can therefore trace from a source document to the journal entries in one table, without a join to BKPF.
Querying the reference in ACDOCA
This query is the S/4HANA counterpart of the BKPF example. It finds the journal entries created for a billing document.
DATA lv_awref TYPE acdoca-awref VALUE '0090000123'.
SELECT DISTINCT rbukrs, gjahr, belnr
FROM acdoca
WHERE rldnr = '0L'
AND awtyp = 'VBRK'
AND awref = @lv_awref
INTO TABLE @DATA(lt_journal).The condition rldnr = '0L' restricts the result to the leading ledger. Without it, a company with several ledgers gets one set of entries per ledger.
Common errors
- Reading BSEG or BSIS for open items. In S/4HANA these are views or reduced tables. Results may differ from what you expect, and performance is worse than reading ACDOCA directly.
- Writing to MKPF or MSEG. These are compatibility views and are read-only. Posting goes through the standard BAPIs and transactions.
- Reading VBUK for the status of a flow. Use the status fields in VBAK, VBAP, LIKP and LIPS. VBUK and VBUP survive only as views.
- Assuming one ledger. Filter on the ledger, or you will count each journal entry once per ledger.
Exercise
A report finds the goods movements for a purchase order by joining EKBE to MSEG on the material document number and year. It still runs after the upgrade to S/4HANA. Why does it work, and what should you change in new code?
Show answer
MSEG still exists as a compatibility view over MATDOC, so the old join returns the same rows. In new code, join EKBE to MATDOC directly. This avoids the view layer and works with the current data model.
Exercise
Why does the ACDOCA query in this chapter filter on RLDNR = '0L'?
Show answer
ACDOCA stores each journal entry once per ledger. Filtering on the leading ledger '0L' returns one set of entries for the billing document instead of one set per ledger.