You are on page 1of 4

Pricing validations using requirement routine

Att 4 ach me Added by Arun Kumar, last edited by Moshe Naveh on Aug 12, 2010 (view change) nts:

Applies to:
CRM 6.0/7.0

Summary
This wiki explains how to perform validations on pricing condition types using java routines with a simple example.

Author(s):
Company: Accenture

Created on: 09/08/2010 Author(s) Bio Arun Kumar is a senior CRM developer working with Accenture. Table of Contents

Applies to: Summary Author(s): Introduction Scenario Coding: Related Content

Introduction
There are scenarios where certain validations need to carried out when pricing is triggered. For example, when a reprice/complete re-price is triggered or when adding a manual condition type. In CRM since pricing is executed by the Sales Pricing Engine, the presentation layer is mostly used to implement any such validations. However, this doesn't prevent pricing from being executed in case of any failed validations. So the better approach for condition type validation is to use requirement routines thus preventing access to the condition. This wiki explains how to perform condition validations in IPC using a requirement routine with a simple example.

Scenario
The scenario is to restrict user from adding more than one manual entry for the same condition type. If user adds an existing condition type more than once, an error message should be displayed and the condition exclusion indicator must be set.

Create a manual condition type and add it to a pricing procedure.

Create a requirement routine

Requirement userexits are used during condition finding on pricing procedure step/counter level and on condition access step level.Assign a formula number for the userexit ZYIDP_CHECK and assign attribute PRC_INDICATOR from the item communication structure

Assign the requirement routine 601 to condition type YIDP in the pricing procedure.

Create an userexit using any Java IDE, the userexits class must be inherited from RequirementAdapter. Use library com.sap.spe.base.util.event.WarningStatusEvent to throw warning messages when validation fails.
private WarningStatusEvent event = new WarningStatusEvent(validateYIDP.class,"ZMSG",108,args,"Msg","Context");

Overwrite the method checkRequirement. If this method returns false, the current access in not made.
public boolean checkRequirement(IConditionFindingManagerUserExit item, IStep step, IAccess access)

Read the pricing indicator attribute passed to the userexit


String pricingIndicator = item.getAttributeValue("PRICING_INDICATOR");

Get item pricing condition types into an array and clear the status message initially.
IPricingItemUserExit pricingItem = (IPricingItemUserExit) item; IPricingConditionUserExit pricingCondition[] = pricingItem.getUserExitConditions() pricingItem.clearStatusMessage(event);

In the pricing conditions check the number of occurrences of condition type YIDP. If YIDP is added more than once then set the warning message and return the check result, 'false' to avoid the access.
pricingItem.setStatusMessage(event); return false;

Coding:
import import import import import import import

com.sap.spe.condmgnt.customizing.IAccess; com.sap.spe.condmgnt.customizing.IStep; com.sap.spe.condmgnt.finding.userexit.IConditionFindingManagerUserExit; com.sap.spe.condmgnt.finding.userexit.RequirementAdapter; com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit; com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit; com.sap.spe.base.util.event.WarningStatusEvent;

public class validateYIDP extends RequirementAdapter { String args[] = { }; boolean popup = false; private WarningStatusEvent event = new WarningStatusEvent(validateYIDP.class,"ZMSG",108,args,"Msg","Context"); public boolean checkRequirement(IConditionFindingManagerUserExit item, IStep step, IAccess access);

You might also like