# Freight Cost Accrual and Carrier Invoice Difference Posting

> A custom program that allocates the freight cost calculated per shipment to deliveries and customers, posts a period-end accrual for freight not yet invoiced, matches carrier invoices with the accrual and posts differences within tolerance automatically with the shipment reference. The reconciliation status per carrier and the shipping cost per customer are shown on the same screen.

- Type: Program, Custom development, Background program
- Module: SD
- Estimated effort: L (18–25 working days)
- Last updated: 2026-11-18
- URL: https://nekuhub.com/en/programs/freight-cost-accrual-and-carrier-invoice-difference/


## Why is the standard not enough?

The standard freight cost document (VI01/VI02) calculates freight from tariffs and, at settlement, creates a purchase order and service entry; the carrier invoice is entered in MIRO against that order. There is, however, no screen that lists the difference between accrual and invoice per shipment, posts it automatically within a tolerance and tracks the reconciliation status with the carrier. The allocation of freight per customer and delivery is not reported either; when the settlement runs in spreadsheets, overpayments and the real cost per shipment stay hidden.

### Closest standard alternatives

- VI01: Creates the freight cost document and calculates it from tariffs; does not track the accrual-invoice difference per shipment.
- VI02: Changes the freight cost document and triggers settlement (purchase order, service entry).
- MIRO: Enters the carrier invoice against the order; does not report the difference with the shipment reference or post it separately by tolerance.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| VTTK | Completed shipments and carrier | Read | - | ECC + S/4 |
| VTTP | Deliveries in the shipment (for allocation) | Read | VTTP-TKNUM = VTTK-TKNUM | ECC + S/4 |
| LIKP | Delivery weight, volume and customer | Read | LIKP-VBELN = VTTP-VBELN | ECC + S/4 |
| VFKK | Freight cost document header | Read | - | ECC + S/4 |
| VFKP | Freight cost items: carrier, amount, settlement purchase order | Read | VFKP-FKNUM = VFKK-FKNUM | ECC + S/4 |
| PRCD_ELEMENTS | Freight and surcharge condition lines (S/4HANA) | Read | PRCD_ELEMENTS-KNUMV = VFKP-KNUMV | S/4HANA only |
| KONV | Freight and surcharge condition lines (ECC) | Read | KONV-KNUMV = VFKP-KNUMV | ECC only |
| EKKO | Purchase order created by settlement | Read | EKKO-EBELN = VFKP-EBELN | ECC + S/4 |
| RBKP | Carrier invoice header | Read | - | ECC + S/4 |
| RSEG | Carrier invoice items and purchase order reference | Read | RSEG-EBELN = VFKP-EBELN | ECC + S/4 |
| LFA1 | Carrier name | Read | LFA1-LIFNR = VFKP-TDLNR | ECC + S/4 |
| BKPF | Document header of the accrual and difference posting (written) | Write | - | ECC + S/4 |
| ACDOCA | Line items of the accrual and difference posting (S/4HANA) | Write | ACDOCA-BELNR = BKPF-BELNR | S/4HANA only |
| BSEG | Line items of the accrual and difference posting (ECC) | Write | BSEG-BELNR = BKPF-BELNR | ECC only |

## BAPIs and functions used

- BAPI_ACC_DOCUMENT_POST: Posts the period-end freight accrual and the invoice difference
- SD_SALESDOCUMENT_CHANGE: Writes a statistical freight condition to unbilled order items
- BAPI_TRANSACTION_COMMIT: Commits the postings

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| S_BUKRS | Company code | Range / multiple | VFKP-BUKRS | Yes |
| S_TDLNR | Carrier | Range / multiple | VFKP-TDLNR | No |
| S_TKNUM | Shipment | Range / multiple | VTTK-TKNUM | No |
| P_BUDAT | Posting date | Single value | BKPF-BUDAT | Yes |
| P_MODE | Run: report / accrual / difference posting | Radio button | - | Yes |
| P_TOL | Automatic posting tolerance (amount) | Single value | - | No |
| P_TEST | Test run | Checkbox | - | No |

## Result list columns

| Column | Source |
|---|---|
| Shipment | VTTK-TKNUM |
| Carrier | VFKP-TDLNR |
| Carrier name | LFA1-NAME1 |
| Freight cost document | VFKK-FKNUM |
| Customer | LIKP-KUNAG |
| Calculated freight | VFKP-NETWR |
| Invoice | RBKP-BELNR |
| Invoiced amount | RSEG-WRBTR |
| Difference | Calculated: Invoiced amount − calculated freight |
| Currency | VFKP-WAERS |
| Status | Calculated: Accrued, matched, closed with difference or disputed |
| Accounting document | BKPF-BELNR |

## How does the program work?

1. Shipments completed in the selected period (VTTK) and their freight cost documents (VFKK/VFKP) are read. The freight amount, surcharges (waiting time, extra stops, tolls) and tax condition lines come from PRCD_ELEMENTS in S/4HANA and from KONV in ECC (VFKP-KNUMV).
2. Allocation: the freight of each shipment is distributed to its deliveries (VTTP → LIKP) by gross weight, volume or equal share and reported per customer, sales order and product group. Optionally a statistical freight condition is written to sales order items not yet billed with SD_SALESDOCUMENT_CHANGE, so freight flows into the invoice and into profitability analysis.
3. Period-end accrual: for shipments that have a freight cost document but no carrier invoice yet, an accrual is posted with BAPI_ACC_DOCUMENT_POST to the freight expense and accrual accounts with the shipment number as reference, and its reversal is scheduled for the first day of the next period. If standard settlement (purchase order + service entry) is used, the GR/IR account already acts as the accrual, so this step is switched off and only the report runs.
4. Matching: carrier invoices (RBKP/RSEG) are linked to the shipment through the purchase order created by settlement (VFKP-EBELN, EKKO/EKPO) or through a reference field set during installation. The difference between invoice and accrual is calculated per shipment and carrier.
5. Difference posting: differences within tolerance are posted with BAPI_ACC_DOCUMENT_POST to the freight expense account with the shipment reference (a test run only lists the proposal). Differences outside the tolerance go to a dispute list, and the reconciliation status with the carrier (open, matched, closed with difference, disputed) is tracked.
6. Postings go to ACDOCA in S/4HANA and BKPF/BSEG in ECC; the document number is stored on the shipment line and the user drills down from the line to the document.

## Authorization objects

- V_VFKK_FKA: Authorization by freight cost document type
- F_BKPF_BUK: Posting authorization by company code
- M_RECH_WRK: Invoice display authorization by plant

## Frequently asked questions

### We use standard freight settlement; is the accrual step needed?

If settlement creates a purchase order and service entry, the GR/IR account already acts as the accrual; the program then skips the accrual step and only performs allocation, invoice matching and difference tracking. If settlement is not used, the program posts the period-end accrual.

### How is freight allocated to customers?

The freight of a shipment is allocated to its deliveries by gross weight, volume or equal share; the rule is chosen per shipment type during installation. The allocated amount is reported per customer, sales order and product group and can optionally be written to the order item as a statistical condition.

### What happens to differences outside the tolerance?

They are not posted automatically; they go to the dispute list. After agreeing with the carrier, the logistics team can approve and post the difference or ask the carrier for a corrected invoice; each step is kept in the status history.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=sd-freight-cost-accrual-settlement
