SD Pricing Part 7: Pricing Routines — Requirements, Alternative Calculation Types and Base Values
Extend pricing logic without modifications: requirement routines that decide whether a condition is determined, alternative calculation type routines that compute the value, alternative condition base value routines, standard examples (2, 10, 11, 16), and how to create and govern custom 9xx routines in VOFM.
Explanation
📌 KEY POINTS
✅ Requirement routine (Reqt column): condition is determined only if the routine returns sy-subrc = 0 (e.g. requirement 2 = item relevant for pricing).
✅ Alternative calculation type (AltCTy): computes the condition value with custom logic instead of rate × base (e.g. 11 profit margin).
✅ Alternative condition base value (AltCBV): changes the base the rate applies to (e.g. net value, weight).
✅ Custom routines are created in VOFM (900–999), activated and assigned in the pricing procedure — no modification of standard code.
⚠️ Pricing routines run for every item and every repricing — slow SELECTs here slow down every order.
━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE
Part 6 covered exclusion and groups. Now logic beyond configuration.
━━━━━━━━━━━━━━━━━━━━
▶ 1. REQUIREMENT ROUTINES
- Assigned per procedure line (Reqt).
- Examples: 2 = item relevant for pricing, 4 = cost, 10 = plant is set (tax), 23 = only in billing.
- Custom: condition only for export customers, only for certain item categories.
━━━━━━━━━━━━━━━━━━━━
▶ 2. ALTERNATIVE CALCULATION TYPE
- Replaces the standard calculation.
- Examples: 11 profit margin (net − cost), 16 tax calculation.
- Custom: freight as a percentage with minimum, price by formula.
━━━━━━━━━━━━━━━━━━━━
▶ 3. ALTERNATIVE CONDITION BASE VALUE
- Changes the base: e.g. net value instead of gross, or a weight- or volume-based base.
- Custom: base = net value excluding certain conditions.
━━━━━━━━━━━━━━━━━━━━
▶ 4. CREATING CUSTOM ROUTINES
- VOFM > Requirements > Pricing (or Formulas > Condition value / Condition base value).
- Copy closest standard, number 9xx, activate, assign, transport.
- Use KOMK (header), KOMP (item), XKOMV (conditions) — read-only except the output fields.
━━━━━━━━━━━━━━━━━━━━
▶ 5. GOVERNANCE AND PERFORMANCE
- Register routines with owner and purpose.
- No database updates, minimal SELECTs, use buffered tables.
- In S/4HANA prefer standard features (e.g. pricing function modules, BAdIs) where available.
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- Check whether configuration can express the rule.
- If not, copy the closest standard routine to 9xx.
- Implement minimal logic, activate, assign in V/08.
- Test with positive/negative cases and measure performance.
✅ CHECKPOINT: the custom condition appears only for items meeting your rule, and pricing time is unchanged.
Code example
* ===== STEP 1: pricing requirement 901 - only for export customers (VOFM > Requirements > Pricing) =====FORM kobed_901. sy-subrc = 4.* ===== STEP 2: item must be relevant for pricing (standard logic of requirement 2) ===== CHECK komp-prsfd CA 'BX'.* ===== STEP 3: customer group '02' = export (KOMK = pricing header communication) ===== IF komk-kdgrp = '02'. sy-subrc = 0. ENDIF.ENDFORM. FORM kobev_901. sy-subrc = 4. CHECK komp-prsfd CA 'BX'. IF komk-kdgrp = '02'. sy-subrc = 0. ENDIF.ENDFORM. * ===== STEP 4: activate in VOFM, assign in V/08 column "Reqt" = 901 for the export condition =====* ===== STEP 5: alternative calculation type example (standard 11) =====* condition value = net value - cost → used for statistical margin line in the procedureReal project scenario
A client added a custom alternative calculation type that read the customer's contract table with a non-buffered SELECT for every condition line. Orders with 400 items took minutes to price, and billing runs overran their batch window. The routine was rewritten to read the contract once per document into a buffer (static internal table keyed by document), and the logic was simplified. Pricing time returned to normal and the routine was added to a performance-reviewed register.
Common mistakes
- Modifying standard routines instead of creating 9xx.
- Expensive SELECTs in routines called per item and per condition.
- Forgetting the KOBEV form counterpart for requirements.
- Using routines where configuration (condition tables, exclusion) would do.
- Not activating or transporting routines.
Best practices
- Try configuration first; use routines for real logic only.
- Copy standard routines to 900–999 and keep them small.
- Buffer data reads; avoid database access per call.
- Register and review custom routines.
- Test performance with large orders and billing runs.
Interview angle
Questions: "What is a pricing requirement?", "Difference between alternative calculation type and alternative base value?", "How do you create a custom pricing routine?"
Strong answer: requirement routines decide if a condition applies (e.g. 2 item relevant for pricing), alternative calculation types compute the value (e.g. 11 margin), alternative base values change the base; custom 9xx routines in VOFM using KOMK/KOMP/XKOMV, activated and assigned in V/08, with performance and governance care.
Practice this lesson
Quick check
1. What does an alternative calculation type routine do on a pricing procedure line?
2. What does a requirement routine on a pricing procedure step do?
3. A condition should be determined only for export customers. What is the correct, upgrade-safe approach?
Interview questions
1. A condition record clearly exists, but pricing analysis says "requirement not fulfilled" for the condition. How do you proceed?
Answer it in your own words first, then compare.
2. Freight must be calculated as 3% of net value but at least 25 EUR per order. Configuration cannot express the minimum across the order. How do you implement it responsibly?
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.
More lessons in this topic
- SD Pricing Part 1: The Condition Technique — How SAP Prices a Sales Document
- SD Pricing Part 10: Enterprise Pricing Architecture — Governance, Extensibility and S/4HANA Migration
- SD Pricing Part 2: Condition Tables and Access Sequences — How SAP Finds a Price
- SD Pricing Part 3: Condition Types and the Pricing Procedure
- SD Pricing Part 4: Condition Records, Scales and Validity Management
- SD Pricing Part 5: Header Conditions, Statistical Conditions and Subtotals
- SD Pricing Part 6: Condition Exclusion, Group Conditions and Scales in Depth
- SD Pricing Part 8: Manual Pricing, Price Updates and Change Governance