Condition Table in SAP SD and MM: Condition Record Query Generator (Axxx + KONP)
This generator writes ABAP for SAP ECC 6.0 that reads master condition records from a condition table such as A004, A005, A017 or A018, joins KONP for the rate and unit, and lists KONM quantity scales. Use it to answer which price, discount or info record condition is valid on a given date for a given key.
Fill in
V = sales, M = purchasing
A004 sales org / channel / material, A005 sales org / channel / customer / material, A017 and A018 purchasing info record.
ABAP report: condition table + KONP + KONM
REPORT z_condition_record_query.
* Reads condition records from a condition table (Axxx) joined to KONP.
* Find the condition table(s) for a condition type:
* SELECT kozgf FROM t685
* WHERE kvewe = 'A' AND kappl = 'V' AND kschl = 'PR00'.
* SELECT kolnr kotabnr FROM t682i
* WHERE kvewe = 'A' AND kappl = 'V' AND kozgf = <access sequence>.
* Table name = 'A' + KOTABNR, e.g. 004 -> A004.
* Document conditions (ECC): KONV WHERE knumv = VBAK-KNUMV or EKKO-KNUMV.
* In S/4HANA document conditions are in PRCD_ELEMENTS instead.
TYPES: BEGIN OF ty_cond,
knumh TYPE konp-knumh,
datab TYPE konh-datab,
datbi TYPE konh-datbi,
kopos TYPE konp-kopos,
kbetr TYPE konp-kbetr,
konwa TYPE konp-konwa,
kpein TYPE konp-kpein,
kmein TYPE konp-kmein,
loevm_ko TYPE konp-loevm_ko,
END OF ty_cond.
DATA: lt_cond TYPE STANDARD TABLE OF ty_cond,
ls_cond TYPE ty_cond,
lt_scale TYPE STANDARD TABLE OF konm,
ls_scale TYPE konm,
lv_tab TYPE tabname VALUE 'A004',
lv_fields TYPE string,
lv_from TYPE string,
lv_where TYPE string,
lv_pct TYPE p DECIMALS 3,
lx_sql TYPE REF TO cx_sy_dynamic_osql_error,
lv_msg TYPE string.
START-OF-SELECTION.
lv_fields = 'a~knumh a~datab a~datbi p~kopos p~kbetr p~konwa p~kpein p~kmein p~loevm_ko'.
CONCATENATE lv_tab 'AS a INNER JOIN konp AS p ON p~knumh = a~knumh'
INTO lv_from SEPARATED BY space.
* Key values must be in internal format (leading zeros for MATNR, KUNNR, LIFNR)
CONCATENATE 'a~kappl = ''V'' AND a~kschl = ''PR00'''
'AND a~datab <= ''20261022'' AND a~datbi >= ''20261022'''
'AND p~loevm_ko = '' '''
INTO lv_where SEPARATED BY space.
IF 'vkorg' <> '-'.
CONCATENATE lv_where 'AND a~vkorg = ''1000'''
INTO lv_where SEPARATED BY space.
ENDIF.
IF 'vtweg' <> '-'.
CONCATENATE lv_where 'AND a~vtweg = ''10'''
INTO lv_where SEPARATED BY space.
ENDIF.
IF 'matnr' <> '-'.
CONCATENATE lv_where 'AND a~matnr = ''000000000000100100'''
INTO lv_where SEPARATED BY space.
ENDIF.
TRY.
SELECT (lv_fields)
FROM (lv_from)
INTO CORRESPONDING FIELDS OF TABLE lt_cond
UP TO 200 ROWS
WHERE (lv_where).
CATCH cx_sy_dynamic_osql_error INTO lx_sql.
lv_msg = lx_sql->get_text( ).
WRITE: / 'Dynamic SQL error:', lv_msg.
RETURN.
ENDTRY.
LOOP AT lt_cond INTO ls_cond.
IF ls_cond-konwa = '%'.
* Percentages are stored in per mille: 100.00 in KBETR means 10 %
lv_pct = ls_cond-kbetr / 10.
WRITE: / ls_cond-knumh, ls_cond-datab, ls_cond-datbi, lv_pct, '%'.
ELSE.
WRITE: / ls_cond-knumh, ls_cond-datab, ls_cond-datbi,
ls_cond-kbetr CURRENCY ls_cond-konwa, ls_cond-konwa,
'per', ls_cond-kpein, ls_cond-kmein.
ENDIF.
* Quantity scales (KONM). Value scales are stored in KONW.
SELECT * FROM konm INTO TABLE lt_scale
WHERE knumh = ls_cond-knumh
AND kopos = ls_cond-kopos
ORDER BY klfn1.
LOOP AT lt_scale INTO ls_scale.
WRITE: /10 'Scale from qty', ls_scale-kstbm, 'rate', ls_scale-kbetr.
ENDLOOP.
ENDLOOP.
IF lt_cond IS INITIAL.
WRITE: / 'No valid records in', lv_tab, 'for', 'PR00', 'on', '20261022'.
ENDIF.
Check the key fields of your condition table in SE11 before running: customer-created tables (A501 and up) have their own keys. A017 keys are LIFNR, MATNR, EKORG, WERKS, ESOKZ; A018 omits WERKS. The select list uses only KAPPL, KSCHL, DATAB, DATBI and KNUMH, which every Axxx pricing table has. This reads ECC; in S/4HANA condition tables still exist but document conditions moved from KONV to PRCD_ELEMENTS.
Get your pricing tables mapped
Send us your pricing procedure and access sequences and we will list which A tables, keys and records drive each condition type in your ECC system.
Optional. The tool and every export work without this. No spam.
Where condition records live
Every condition record has a header and a variable key. The variable key sits in a generated condition table named A plus a three-digit number: A004 for sales org, distribution channel and material, A005 for sales org, distribution channel, customer and material, A017 and A018 for purchasing info record conditions with and without plant. Each row carries KAPPL, KSCHL, the key fields, DATBI, DATAB and KNUMH. KNUMH is the condition record number that links to KONH (header) and KONP (item with KBETR, KONWA, KPEIN, KMEIN, LOEVM_KO). Scales sit in KONM for quantity and KONW for value.
- T685: condition type to access sequence (KOZGF).
- T682I: access sequence to condition tables (KOTABNR), in access order KOLNR.
- KONV: conditions copied into sales and purchasing documents in ECC.
How to use it
Choose application V for sales or M for purchasing, enter the condition table and type, then up to three key fields with values. Use - for a key you do not want to restrict; the query then returns all records for the remaining keys. Values must be in internal format, so material 100100 is 000000000000100100 in a system with 18-character numbering. Enter the validity date as YYYYMMDD. The report uses a dynamic FROM and WHERE because the table name changes, wrapped in TRY so a wrong table or field name shows a readable error.
- Run it first with only KAPPL and KSCHL keys to see how many records exist.
- Deleted records (LOEVM_KO = X) are excluded.
Reading the result and common gotchas
For amount conditions KBETR is the rate per KPEIN KMEIN in currency KONWA, for example 245.50 USD per 1 EA. For percentage conditions KONWA is % and KBETR is stored in per mille, so 100.00 means 10 percent and -30.00 means a 3 percent discount: the code divides by 10. Overlapping validity periods are split by SAP when you maintain records, so normally one record is valid per key and date. If you see two, check whether they come from different condition tables in the access sequence; pricing searches the accesses in KOLNR order and stops at the first record found when the access is marked exclusive.
How to check in the system
Compare the output with VK13 for sales conditions or MEK3 for purchasing conditions, using the same condition type, key combination and date. In a sales order, the pricing analysis in the conditions tab shows which access and table found the record. For purchase orders, ME23N conditions and the info record (ME13) should show the same rate. SE16 on the A table with the KNUMH, then KONP with that KNUMH, reproduces the join by hand. If VK13 shows a record the report misses, check the key format and the validity date first.
Frequently Asked Questions
What is a condition table in SAP SD and MM?
A condition table defines the key combination for condition records, for example sales org plus distribution channel plus material. SAP generates a database table named A plus its number (A004, A005, A017) holding the key, the validity dates and KNUMH. The rate itself is not in the A table; it is in KONP under that KNUMH.
Which table stores PO conditions in SAP ECC?
Conditions in a purchase order document are stored in KONV, linked from EKKO-KNUMV. Master conditions such as info record prices live in A017 or A018 plus KONP. In S/4HANA document conditions moved to PRCD_ELEMENTS, while master condition tables and KONP remain.
How do I find the condition table for a condition type?
Read T685 for the condition type to get its access sequence (KOZGF), then T682I for that access sequence to get each KOTABNR in access order. The table name is A plus KOTABNR. In customizing, V/07 shows access sequences for sales and M/07 for purchasing.
How do I create a condition table in SAP SD?
Use V/03 in sales (M/03 in purchasing), choose fields from the field catalog, and generate the table. Customer tables use numbers 501 to 999. Then add the table to an access sequence (V/07) and maintain records with VK11. This generator only reads records; it does not create tables.
If your pricing team wants to ask ECC which condition is valid for a customer and material in plain English on your own servers, we can build that on top of queries like this one.
Related Tools
SAP SD Pricing Condition Types Reference (PR00, K004, MWST)
Look up standard SAP SD condition types and what each is normally used for in a pricing procedure.
SAPSAP SD Condition Record Load Worksheet
Prepare price and discount condition records row by row, check the per-unit value and export to Excel for LSMW, migration cockpit or manual VK11 entry.
Developer ToolsSAP ECC Table Structure and Message Text Query Generator (DD03L, DD04T, T100)
Choose a mode to generate a query that lists a table's fields with labels, finds transparent tables by description, or returns a message text from T100.
SAPSAP SD Tables Reference (VBAK, VBAP, LIKP, VBRK and More)
Lookup of the main SAP SD tables with their key fields and what changed in S/4HANA. Search, then export to Excel or PDF.
More Developer Tools tools
See all- SAP ECC Enhancement Transactions and Exit Tables Reference (SMOD, CMOD, SE18, MODSAP, SXC_EXIT)
- SAP ECC Data Dictionary and Repository Tables Reference (DD02L, DD03L, T100, E070, TSTC)
- SAP ECC ABAP Runtime Errors (ST22 Dumps) and Error Log Transactions Reference
- SAP ECC Background Job History ABAP Query Generator (TBTCO + TBTCP)
- SAP ECC Background Job Creation ABAP Generator (JOB_OPEN, SUBMIT, JOB_CLOSE)
- SAP ECC IDoc Segment Data Reader ABAP Generator (EDIDC, EDID4, EDIDS)
- SAP ECC Custom Inbound IDoc Function Module Skeleton Generator
- SAP ECC BAPI_SALESORDER_CHANGE ABAP Generator
- SAP ECC BAPI_PO_CHANGE ABAP Generator
Keep exploring
Free tools
- ABAP SELECT Statement GeneratorFill in table, fields and a WHERE condition and get modern ABAP Open SQL: SELECT INTO TABLE, SELECT SINGLE and a safe FOR ALL ENTRIES pattern.
- SAP ECC BAPI_PO_CHANGE ABAP GeneratorGenerate a working ABAP program that changes an SAP purchase order item with BAPI_PO_CHANGE, with POITEM/POITEMX, schedule line date conversion, test run and commit handling.
- SAP ECC BAPI_MATERIAL_SAVEDATA Material Creation ABAP GeneratorFill in material type, plant, sales and valuation data and get a complete ABAP report that creates the material with BAPI_MATERIAL_SAVEDATA and commits it.
ERP fixes and how-tos
- SAP Pricing Error: Condition Record Missing for PR00 in a Sales OrderMandatory condition PR00 missing in a sales order? Use pricing analysis, check pricing procedure determination and create the condition record in VK11.
- SAP MM Pricing Procedure Configuration (Calculation Schema, M/08)Configure the SAP MM pricing procedure (calculation schema): condition types, M/08, schema groups and determination, MEK1 condition records and account keys.
- Pricing Procedure in SAP MM, with a Worked PO ExampleHow the SAP MM purchasing pricing procedure works: condition types, calculation schema, schema determination, a worked PO and how freight is captured.
Runs with your ERP
- PROGATE 6.0 Interface with SAP ECC and S/4HANAPROGATE is an SAP-certified web service interface that sends master data and orders from SAP to third-party MES and returns confirmations. Setup and pitfalls.
- Loftware with SAP ECC and S/4HANA: label design and printing from SAP transactionsHow Loftware and the NiceLabel ABAP package drive labels from SAP ECC and S/4HANA, including SAP GLM Plus, data flows, setup steps and pitfalls to avoid.
- ShipERP with SAP ECC: native parcel shipping inside SAPShipERP is an SAP-native ABAP add-on for UPS, FedEx, DHL and USPS rate shopping, labels and tracking in SAP ECC and S/4HANA. Flows, setup and pitfalls.
Integrations
- How to connect Power BI to SAP ECC 6.0Connect Power BI to SAP ECC 6.0: SAP ERP connector, BW and warehouse options, on-prem data gateway, key manufacturing dashboards, and adding natural-language Q&A.
- How to add an AI chatbot to SAP ECC 6.0Add an AI chatbot to SAP ECC 6.0 for planners, buyers and customers: grounded in live data, role-aware, embeddable in portals, and able to run fully on-prem.