cancel
Showing results for 
Search instead for 
Did you mean: 

IPC formula

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Wow Ajay,

You're really the IPC expert. I tried your code modification and it really works. I have got no idea about this behaviour but I'm going to invest some time to discover it.

Thank you very much again, if yuo need something I will try to help you as you has made with me.

Kind Regards

Answers (6)

Answers (6)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Yes Ajay, it returns always ZERO

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi

Have you considered copying the two conditions to subtotals (via configuring the pricing procedure) and then just adding the subtotals?

Cheers

Dom