SAPFree generatorPDF, Excel, Word exportSAP ECC / S/4HANA

SAP MBEW Price Control ABAP SELECT Generator

This generator writes an ABAP report that reads the material valuation table MBEW and lists materials where the moving average price has drifted away from the standard price. Fill in your plant and range, copy the code and paste it into SE38.

Fill in

BWKEY equals the plant when valuation is at plant level.

18 characters for classic material numbers, check your length.

Generated code
Download:

ABAP report

REPORT ZMM_PRICE_DRIFT.

TYPES: BEGIN OF ty_price,
         matnr TYPE mbew-matnr,
         bwkey TYPE mbew-bwkey,
         vprsv TYPE mbew-vprsv,
         verpr TYPE mbew-verpr,
         stprs TYPE mbew-stprs,
         peinh TYPE mbew-peinh,
         lbkum TYPE mbew-lbkum,
         salk3 TYPE mbew-salk3,
       END OF ty_price.

DATA: lt_price TYPE STANDARD TABLE OF ty_price,
      ls_price TYPE ty_price,
      lv_map   TYPE p LENGTH 13 DECIMALS 4,
      lv_std   TYPE p LENGTH 13 DECIMALS 4,
      lv_drift TYPE p LENGTH 9 DECIMALS 2.

SELECT matnr bwkey vprsv verpr stprs peinh lbkum salk3
  FROM mbew
  INTO TABLE lt_price
  UP TO 500 ROWS
  WHERE bwkey = '1000'
    AND matnr BETWEEN '000000000000100000' AND '000000000000199999'
    AND lbkum > 0.

LOOP AT lt_price INTO ls_price.
  IF ls_price-peinh = 0.
    CONTINUE.
  ENDIF.
  lv_map = ls_price-verpr / ls_price-peinh.
  lv_std = ls_price-stprs / ls_price-peinh.
  IF lv_std = 0.
    CONTINUE.
  ENDIF.
  lv_drift = ( lv_map - lv_std ) / lv_std * 100.
  IF abs( lv_drift ) >= 10.
    WRITE: / ls_price-matnr, ls_price-vprsv, lv_std, lv_map, lv_drift.
  ENDIF.
ENDLOOP.

Quick check in SE16N

Table: MBEW
Filter BWKEY = 1000
Filter VPRSV = V to list moving average materials
Compare STPRS and VERPR per price unit PEINH

Verify field names and the material number length in SE11 for your release. In S/4HANA with Material Ledger active, actual costing prices live in Material Ledger tables, so MBEW alone may not show the full picture. Run in a non-production system first and use the standard authorization checks for your landscape.

Skip the ABAP for costing questions

An optional discussion on asking your SAP data costing questions in plain language, read-only.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter the report name, the plant that acts as your valuation area, a material range and the drift percentage you care about. The code block updates as you type. Copy it into a new executable program in SE38, check that the material number length matches your system, then run it. Export the generated text if you want to keep a record of what was used.

  • Set plant and material range
  • Choose a drift threshold, often 5 to 10 percent
  • Copy to SE38, activate and run in a test system first

What the fields mean

VPRSV is the price control: S for standard price and V for moving average price. STPRS is the standard price and VERPR is the moving average price, both stated per price unit PEINH. LBKUM is the total valuated stock quantity and SALK3 is the value of that stock. The report divides by PEINH so that prices are compared per base unit, which avoids false drift on materials priced per 100 or per 1000.

How to read the output

Each line shows a material, its price control and the two unit prices with the percent difference. A large positive drift on a V material suggests recent expensive receipts. A drift on an S material shows how far purchase or production cost has moved from the standard, which is a candidate for a standard cost revaluation. Use the list to prioritise investigation, not as a posting source.

Common mistakes

The most frequent errors are padding material numbers incorrectly in the BETWEEN range, ignoring price units, and reading MBEW for materials valued at company code level where BWKEY is the company code rather than the plant. Also remember that with Material Ledger active, periodic unit prices and actual costing results are in CKMLCR and related tables.

Frequently Asked Questions

What does VPRSV mean in MBEW?

VPRSV is the price control indicator. S means the material is valued at a standard price and V means moving average price. The indicator decides which price is used for stock valuation and how price differences are posted.

Why divide by PEINH?

Prices in MBEW are stored per price unit. If PEINH is 100, the stored price applies to 100 base units. Dividing by PEINH gives a comparable price per single base unit across materials.

Will this work in S/4HANA?

MBEW remains available as a table or view, and the SELECT usually works. If Material Ledger is active, which is default in S/4HANA, actual costing values come from Material Ledger structures. Check field availability and material number length in your system.

Can I use this in production?

It is a read-only SELECT, but follow your own change management and authorization rules. Test in a quality system and limit the row count so you do not scan a very large table without restrictions.

If your team spends time writing one-off ABAP reports for costing questions, Netray can add a governed read-only question layer on top of your SAP data.