SD Program Custom development Background program

Freight Cost Accrual and Carrier Invoice Difference Posting

Short answer: 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.

Estimated effort
L · 18–25 working days
System
ECC and S/4HANA
Tables
14
Scope
Global
Built by
NeKuDos Teknoloji
Last updated

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.

Who uses it? Logistics and shipping teams, vendor invoice and general ledger teams, cost accounting and sales controlling.

Closest standard alternatives

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

Tables used

The tables the program reads and updates. ECC and S/4HANA differences are marked separately.

TableRoleAccessSystem
VTTKShipment HeaderCompleted shipments and carrierReadECC + S/4
VTTPShipment ItemDeliveries in the shipment (for allocation)ReadECC + S/4
LIKPDelivery HeaderDelivery weight, volume and customerReadECC + S/4
VFKKShipment Costs: Header DataFreight cost document headerReadECC + S/4
VFKPShipment Costs: Item DataFreight cost items: carrier, amount, settlement purchase orderReadECC + S/4
PRCD_ELEMENTSPricing Elements (Document Conditions)Freight and surcharge condition lines (S/4HANA)ReadS/4HANA only
KONVConditions (Transaction Data)Freight and surcharge condition lines (ECC)ReadECC only
EKKOPurchasing Document HeaderPurchase order created by settlementReadECC + S/4
RBKPDocument Header: Incoming InvoiceCarrier invoice headerReadECC + S/4
RSEGDocument Item: Incoming InvoiceCarrier invoice items and purchase order referenceReadECC + S/4
LFA1Vendor Master (General Section)Carrier nameReadECC + S/4
BKPFAccounting Document HeaderDocument header of the accrual and difference posting (written)WriteECC + S/4
ACDOCAUniversal Journal Entry Line ItemsLine items of the accrual and difference posting (S/4HANA)WriteS/4HANA only
BSEGAccounting Document SegmentLine items of the accrual and difference posting (ECC)WriteECC only

S/4HANA notes

  • KONV → PRCD_ELEMENTS: In S/4HANA document conditions are stored in PRCD_ELEMENTS; custom code reading KONV must be adapted.

BAPIs and functions used

  • BAPI_ACC_DOCUMENT_POSTAccounting: Post Document. Posts the period-end freight accrual and the invoice difference
  • SD_SALESDOCUMENT_CHANGEChange Sales and Distribution Document. Writes a statistical freight condition to unbilled order items
  • BAPI_TRANSACTION_COMMITCommit a BAPI transaction. Commits the postings

Selection screen parameters

ParameterDescriptionTypeReference fieldRequiredExample
S_BUKRSCompany codeRange / multipleVFKP-BUKRSYes1000
S_TDLNRCarrierRange / multipleVFKP-TDLNRNo700120
S_TKNUMShipmentRange / multipleVTTK-TKNUMNo00012045
P_BUDATPosting dateSingle valueBKPF-BUDATYes30.11.2026
P_MODERun: report / accrual / difference postingRadio button—YesRapor
P_TOLAutomatic posting tolerance (amount)Single value—No250
P_TESTTest runCheckbox—NoX

Result list columns

#ColumnSource
1ShipmentVTTK-TKNUM
2CarrierVFKP-TDLNR
3Carrier nameLFA1-NAME1
4Freight cost documentVFKK-FKNUM
5CustomerLIKP-KUNAG
6Calculated freightVFKP-NETWR
7InvoiceRBKP-BELNR
8Invoiced amountRSEG-WRBTR
9DifferenceCalculated Invoiced amount − calculated freight
10CurrencyVFKP-WAERS
11StatusCalculated Accrued, matched, closed with difference or disputed
12Accounting documentBKPF-BELNR

Sample result list

ShipmentCarrierCarrier nameFreight cost documentCustomerCalculated freightInvoiceInvoiced amountDifferenceCurrencyStatusAccounting document
00012045700120Örnek Lojistik A.Ş.000000451220011818,500510560021118,5000TRYMatched
00012046700135Demo Nakliyat Ltd.00000045132003429,20051056002159,380180TRYClosed with difference100045230
00012050700142Anadolu Taşımacılık A.Ş.000000452020011812,400510560022014,1001,700TRYDisputed
00012058700120Örnek Lojistik A.Ş.000000453130004521,750TRYAccrued100045288
A view built with fictional sample data; not real system data.

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.

Performance notes

Restrict freight cost documents by company code, carrier and settlement date; read the condition lines for the document list in one go. In the allocation, total the delivery weights once per shipment. Package the postings per carrier, issue COMMIT WORK after each package and schedule the period-end run in the background.

Features

  • ALV list (sort, filter, subtotals)
  • Test mode (check without posting) Accrual and difference postings are first listed as a proposal.
  • Runs as a background job The period-end accrual and next-day reversal are scheduled as jobs.
  • Double-click drill-down to the document From a line the user drills down to the shipment, freight cost document, invoice and accounting document.
  • Line-by-line result and error log
  • Export to Excel

Authorization objects

  • V_VFKK_FKAAuthorization by freight cost document type
  • F_BKPF_BUKPosting authorization by company code
  • M_RECH_WRKInvoice 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.

Related reports

SD Report Custom ALV report

Sales Order Gross Margin Report by Item

A custom ALV report that compares the net value of every sales order item with the cost determined in pricing and shows the gross profit and margin …

VBAK · VBAP · KNA1 · KONV

Let us build this program for your system

Briefly describe your system and expectations. We will clarify the scope and come back with an effort and price quote.

Related report: Freight Cost Accrual and Carrier Invoice Difference Posting