Dear Experts,
I want to use the statistical value the instead of the Net Value. Also I looked point 9b in the note 844141 from ECC. We understood that we needed to use the statistical value (XWORKM, for example) instead of the Net Value.
We created a copy of value formula 036 in the customer namespace (936). The replace the line ICurrencyValue netValue = pricingItem.getNetValue() with
ICurrencyValue netValue = pricingItem.getSubtotal(PricingCustomizingConstants.ConditionSubtotal.SUBTOTAL_M) in the copied formula 936.
Unfortunately the formula 936 did not work.
Please help me,
Alex.
package masterdata.pricing.userexits;
import java.math.BigDecimal;
import com.sap.spe.conversion.ICurrencyUnit;
import com.sap.spe.conversion.ICurrencyValue;
import com.sap.spe.pricing.customizing.PricingCustomizingConstants;
import com.sap.spe.pricing.transactiondata.PricingTransactiondataConstants;
import com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit;
import com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit;
import com.sap.spe.pricing.transactiondata.userexit.ValueFormulaAdapter;
public class ZCummulationCondition2 extends ValueFormulaAdapter {
public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,
IPricingConditionUserExit pricingCondition) {
if (pricingCondition.getStructureConditionFlag() != PricingCustomizingConstants.StructureIndicator.CONDITION_FOR_CUMULATION) {
return null;
}
// ICurrencyValue netValue = pricingItem.getNetValue();
ICurrencyValue netValue = pricingItem.getSubtotal(PricingCustomizingConstants.ConditionSubtotal.SUBTOTAL_M);
pricingCondition.setConditionBase(netValue.getValue(), netValue.getUnit());
BigDecimal accumulatedNetValue = PricingTransactiondataConstants.ZERO;
if (!pricingItem.isStatistical()) {
accumulatedNetValue = pricingCondition.getConditionBase().getValue();
}
IPricingItemUserExit[] prItems = pricingItem.getSubPricingItemsUserExitRecursive();
for (int i = 0; i < prItems.length; i++) {
if (!prItems[i].isStatistical()) {
IPricingConditionUserExit[] conditionsForCumulation = prItems[i].getConditionsForCumulation();
for (int j = 0; j < conditionsForCumulation.length; j++) {
if ((pricingCondition.getStepNumber() == conditionsForCumulation[j].getStepNumber())
&& (pricingCondition.getCounter() == conditionsForCumulation[j].getCounter())) {
accumulatedNetValue =
accumulatedNetValue.add(conditionsForCumulation[j].getConditionBase().getValue());
break;
}
}
}
}
pricingCondition.setConditionRate(accumulatedNetValue, (ICurrencyUnit) netValue.getUnit());
pricingCondition.setStatistical(true);
pricingItem.setSubtotal(PricingCustomizingConstants.ConditionSubtotal.SUBTOTAL_M, PricingTransactiondataConstants.ZERO);
return accumulatedNetValue;
}
}