on 11-30-2007 9:44 AM
Hi SAP Gurus
Your help required
How Values/Rates can be passed to header conditions in IPC user exits, which method or how we can achieve this to pass a calculated value to a header condition.
Thanks
Javed
Hello Javed!
Can you explain a little bit more because it looks like to be very simple when you're using the SAPCND/UEASS. Have you use the Pricing Userexit Manual(PDF)? Follow an example on how to use in Java. Please let me know if you need any help.
package com.company.xxxxxx.xxxx.xxxx;
import java.math.BigDecimal;
import com.sap.spe.base.logging.UserexitLogger;
import com.sap.spe.conversion.ICurrencyValue;
import com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit;
import com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit;
import com.sap.spe.pricing.transactiondata.userexit.ValueFormulaAdapter;
/**
* @author Alexandre Menezes
*/
public class ZCheckManualConditionZCPA extends ValueFormulaAdapter
{
private static UserexitLogger userexitlogger = new UserexitLogger(
ZCheckManualConditionZCPA.class);
public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,
IPricingConditionUserExit pricingCondition)
{
// userexitlogger.writeLogError("INICIO FORMULA ZCP9");
BigDecimal result = null;
BigDecimal kbetrZCPB = null;
BigDecimal kbetrZCP3 = null;
BigDecimal kbetrZPLANO = null;
IPricingConditionUserExit all_pricingCond[] = pricingItem
.getUserExitConditions();
if (all_pricingCond == null)
return super.overwriteConditionValue(pricingItem, pricingCondition);
for (int i = 0; i < all_pricingCond.length; i++)
{
IPricingConditionUserExit pcue_exit = all_pricingCond<i>;
if (pcue_exit != null)
{
String str_cndname = pcue_exit.getConditionTypeName();
ICurrencyValue curr_val;
if (str_cndname != null)
{
if (str_cndname.equalsIgnoreCase("ZCPB"))
{
curr_val = pcue_exit.getConditionValue();
if (curr_val != null)
kbetrZCPB = curr_val.getValue();
}
if (str_cndname.equalsIgnoreCase("ZCP3"))
{
curr_val = pcue_exit.getConditionRate();
if (curr_val != null)
kbetrZCP3 = curr_val.getValue();
}
}
}
}
String str_zplano = pricingItem.getAttributeValue("ZPLANO");
if (str_zplano != null)
kbetrZPLANO = new BigDecimal(str_zplano);
/* userexitlogger.writeLogError(" str_zplano:" + str_zplano); */
if (kbetrZCPB != null && kbetrZPLANO != null)
{
BigDecimal div_zplano = null;
if (kbetrZPLANO.compareTo(new BigDecimal("0")) > 0)
{
div_zplano = kbetrZCPB.divide(kbetrZPLANO, 2,
BigDecimal.ROUND_DOWN);
if (div_zplano != null)
{
/*
* userexitlogger.writeLogError(" div_zplano:" + div_zplano +
* "kbetrZCP3:" + kbetrZCP3);
*/
if (kbetrZCP3 != null
&& kbetrZCP3.compareTo(new BigDecimal("0")) > 0)
{
ICurrencyValue val = pricingCondition
.getConditionRate();
int cmp_res = kbetrZCP3.compareTo(div_zplano);
switch (cmp_res)
{
case -1 :
result = new BigDecimal("-10.00");
break;
case 0 :
result = new BigDecimal("100.00");
break;
case 1 :
result = new BigDecimal("10.00");
break;
}
}
} else
{
/* userexitlogger.writeLogError("div_zplano:" + div_zplano); */
}
} else
{
/*
* userexitlogger.writeLogError("kbetrZPLANO.doubleValue():" +
* kbetrZPLANO.doubleValue());
*/
}
} else
{
/* userexitlogger.writeLogError("kbetrZCPB:" + kbetrZCPB); */
}
if (result != null)
{
pricingCondition.setConditionRateValue(result);
return result;
} else
{
return super.overwriteConditionValue(pricingItem, pricingCondition);
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.