# Mass Material Price Change and Inventory Debit/Credit Posting

> A custom program that posts moving average or standard price corrections and debits/credits to inventory value from a file, for company and project stock. Before posting it shows old and new price, stock quantity and value difference for every material; after posting a control list with document numbers remains.

- Type: Program, Custom development, Mass upload
- Module: CO
- Estimated effort: M (6–9 working days)
- Last updated: 2026-11-18
- URL: https://nekuhub.com/en/programs/mass-material-price-change-and-inventory-debit-credit-posting/


## Why is the standard not enough?

MR21 price changes and MR22 inventory debits/credits are entered material by material; for a correction of hundreds of materials the lines are typed by hand and no control list showing the value impact is available before posting. For project stock (valuated WBS stock) the same work is repeated in separate lines. CKM3N shows the result per material but does not correct in bulk. The custom program checks the file, shows the impact in advance and posts in bulk.

### Closest standard alternatives

- MR21: Enters price changes material by material; no bulk preview or control list.
- MR22: Enters debits/credits to inventory value one by one.
- CKM3N: Shows the material price analysis; does not correct in bulk.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| MBEW | Material valuation: price control, price, stock and value | Read / write | - | ECC + S/4 |
| QBEW | Valuated project stock: price and value per WBS | Read / write | QBEW-MATNR = MBEW-MATNR AND QBEW-BWKEY = MBEW-BWKEY | ECC + S/4 |
| MARA | Material and base unit | Read | MARA-MATNR = MBEW-MATNR | ECC + S/4 |
| T001K | Valuation area to company code | Read | T001K-BWKEY = MBEW-BWKEY | ECC + S/4 |
| CKMLHD | Material ledger header (costing run unit) | Read | CKMLHD-KALNR = MBEW-KALNR | ECC + S/4 |
| CKMLCR | Material ledger period price and value | Read | CKMLCR-KALNR = CKMLHD-KALNR | ECC + S/4 |
| BKPF | Accounting documents created | Write | - | ECC + S/4 |

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Price correction file | Single value | - | Yes |
| P_BUDAT | Posting date (if empty in file) | Single value | - | No |
| P_DEVPR | Price deviation threshold to flag (%) | Single value | - | No |
| P_TEST | Test mode (preview only) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Plant | MBEW-BWKEY | Yes |
| Material | MBEW-MATNR | Yes |
| Valuation type | MBEW-BWTAR | No |
| WBS element (project stock) | QBEW-PSPNR | No |
| Operation | F = price change, B = debit, A = credit | Yes |
| New price | Required for operation F | No |
| Price unit | MBEW-PEINH | No |
| Debit/credit amount | Required for operation B or A | No |
| Reason | Written to the document header text | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: File row number |
| Plant | MBEW-BWKEY |
| Material | MBEW-MATNR |
| WBS | QBEW-PSPNR |
| Price control | MBEW-VPRSV |
| Stock | MBEW-LBKUM |
| Old price | Calculated: MBEW/QBEW-VERPR or STPRS (by VPRSV) |
| New price | Calculated: Price from the file or average after debit/credit |
| Old value | MBEW-SALK3 |
| Value difference | Calculated: New value − old value |
| Document no. | Calculated: Price change or accounting document number |
| Message | Calculated: Check, BAPI or batch input message |

## How does the program work?

1. The file contains plant (valuation area), material, valuation type, optional WBS element (project stock), operation (price change, debit, credit), new price and price unit or debit/credit amount, posting date and reason.
2. Checks: does valuation data exist in MBEW, or in QBEW for project stock; does the price control (VPRSV) fit the operation; is the posting period open; if the new price differs from the current price by more than the percentage set during setup, the row is flagged.
3. Preview: old price, new price, stock quantity (LBKUM), old value (SALK3), new value and the difference are calculated. If the material ledger is active, the period price is read from CKMLHD/CKMLCR.
4. Price changes are posted with BAPI_MATVAL_PRICE_CHANGE; for valuated project stock the WBS element is passed as the special stock key. Debits/credits are posted as batch input of the MR22 transaction; if stock is zero, the amount goes to the price difference account as in standard and this is shown on the row.
5. Price and stock value are updated in MBEW or QBEW and the accounting document is created in standard. For every row the material ledger or accounting document number is written to the list.
6. In test mode only the preview runs; faulty rows go to an error file.

## Authorization objects

- K_ML_VA: Authorization to change prices in the material ledger
- F_BKPF_BUK: Accounting posting authorization in the company code

## Frequently asked questions

### What happens with standard price materials?

For standard price materials a price change is only possible under the conditions allowed in the period, and the difference goes to the revaluation account. The program flags an operation that the price control does not allow as an error before posting.

### What is different on S/4HANA?

On S/4HANA the material ledger is always active; a price change creates a material ledger document and inventory value is written to ACDOCA. The program reads the period price from CKMLCR in the preview; the posting path stays the same.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=co-material-price-change-debit-credit-upload
