on 01-09-2006 8:57 AM
Hello,
I need to develop the following formula in IPC:
320 Condition 1: Value1
330 Condition 2: Value3
340 Condition 3: (Value 1 + Value 2)*100
I guess that I have to use the findPricingCondition method, but I don't know how to work with.
I tried:
IPricingCondition ConRes1 = findPricingCondition(320 ,0);
IPricingCondition ConRes2 = findPricingCondition(330 ,0);
BigDecimal Res1 = ConRes1.getConditionRate().getValue();
BigDecimal Res2 = ConRes2.getConditionRate().getValue();
BigDecimal Res = Res1 + Res2 ;
return Res.multiply(100);
This code is very bad coded as I think but I have no idea about Java programing.
Dear Javier,
I have received ur mail. Anyways that's not a problem as it was time consuming I have mentioned that. However, Please make this little change and see if its working. I Hope it should work. I will not be able to explain the logic behind it but I think it should work.
BigDecimal ResTot = new BigDecimal("0.00");
for step=320 to step=400 {
IPricingCondition cond = prItem.findPricingCondition(step,<b>1</b>);
if (cond != null) {
Res = cond.getConditionRate.getValue();
if (Res != null) {
ResTot = ResTot.add(Res);
}
}
}
prCondition.setConditionRateValue(ResTot);
return PricingConstants.HUNDRED (or whatever)
Regards,
Ajay S Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Javier,
Please try this code
BigDecimal ResTot = new BigDecimal("0.00");
for step=320 to step=400 {
<b>IPricingCondition cond = prItem.findPricingCondition(step,0);</b>
<b> if (cond != null) {</b>
Res = cond.getConditionRate.getValue();
if (Res != null) {
ResTot = ResTot.add(Res);
}
<b>}</b>
}
prCondition.setConditionRateValue(ResTot);
return PricingConstants.HUNDRED (or whatever)
This should work !!!
Regards,
Ajay S Gupta
Message was edited by: Ajay Gupta
Message was edited by: Ajay Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much Ajay,
I implemented this code and I noticed that prItem.findPricingCondition is always returning a null value and I dont know why.
I sent you my PricingUserExits.java and my configured pricing schema. If you could take some time with it I'd be very thankful.
Thanks in advance Ajay.
Dear Javier,
Use this code
BigDecimal ResTot = new BigDecimal("0.00");
for step=320 to step=400 {
Res = prItem.findPricingCondition(step,0).getConditionRate.getValue();
<b>if (Res != null) {</b>
ResTot = ResTot.add(Res);
<b>}</b>
}
prCondition.setConditionRateValue(ResTot);
return PricingConstants.HUNDRED (or whatever)
This should solve your problem.
Regards,
Ajay S Gupta
Message was edited by: Ajay Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much Ajay again, you're the best colleague in SDN for me.
I'm so sorry to tell you that your code doesn't work.... again. I don't know if I'm stupid or what, but this easy feature it's impossible for me (and I think that it isn't a complex one)
I tested this code:
case 661: //Participation Porcent
BigDecimal PorcenPart = new BigDecimal("0.00");
int step;
for (step=240;step<320;step++)
{
BigDecimal Res = prItem.findPricingCondition(step,0).getConditionRate().getValue();
if (Res!=null)
{
PorcenPart = PorcenPart.add(Res);
}
}
prCondition.setConditionRateValue(PorcenPart);
return PricingConstants.HUNDRED;
and the result remains to ZERO (with red light).
I think something goes wrong with findPricingCondition code line. The system seems to stop in this line but I'm not sure at all.
I tested too without loop as
BigDecimal Res = prItem.findPricingCondition(240,0).getConditionRate().getValue();
in order to prevent some wrong condition value in the schema (sure that condition 240 it's correctly calculated) but the system seems not to work.
Thank you everybody, especially to Ajay.
Dear Javier,
Can you please let me know what is the total amount received for various values of Val1...val110, If it returns ZERO in all cases, probably, I know what is the problem, Please let me know so that I can guide u further.
Regards,
Ajay S Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Javier,
What we have done is created another class with the getter and setter methods for each variable. Attach a IPC routine to each subtotal and through set methods set these values in this class. In the 340 condition, write a routine that will get the values from the getter - setter class and sum up the same.
Hope this helps
Regards,
Ajay S Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Ajay, but these subtotals have a IPC routine too, so it's impossible to attach others as you recommend me. Maybe using the setDynamicReturnValue / getDynamicReturnValue methods?? I dont know how to use these methods, could you help me?
I will try to explain it better:
ZCL1 IPCRoutine1
ZCL2 IPCRoutine2
ZCL3 IPCRoutine3
....
ZCL9 IPCRoutine9
ZTOT IPCRoutine10
I need to develop my routine 10 in order to add from ZCL1 to ZCL9 pricing conditions.
What I think is to use a loop similar to:
for step=320 to step=400
{
Res = prItem.findPricingCondition(step,0).getConditionRate.getValue();
ResTot = ResTot.add(Res);
}
prCondition.setConditionRateValue(ResTot);
return PricingConstants.HUNDRED (or whatever)
I dont know why the method findPricingCondition not works as doc says (or as I suppose it says ).
Thank you very much
Message was edited by: Javier Merino Vivar
Thanks for your response Dom,
It was my first solution (the easier too) but really I need a nine-tems addition (cond1cond2.....cond9) and I haven't enough subtotals to do it (I used them in other formulas).
So, I think it's more clearly to programm a custom JAVA routine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Have you considered copying the two conditions to subtotals (via configuring the pricing procedure) and then just adding the subtotals?
Cheers
Dom
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.