Skip to Content
author's profile photo Former Member
Former Member

IPC JAVA coding help for looping all the line items

Hi all,

Can someone help me on below code?

The requirement is as follows:

One of the multiple line items has condition type ZDDS. This value should contain the total value of other line items' value where the condition type is ZDDX.

ex.)

Line item 10, cond type = ZDDX, value $11.00.

Line item 20, cond type = ZDDX, value $5.00.

Line item 30, cond type = ZDDS, value $16.00 <-- this value is calculated in IPC Java code, adding line item 10 and 20.

Based on the other post, http://scn.sap.com/thread/3205565 I coded as follows:

public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,
IPricingConditionUserExit pricingCondition)
{
BigDecimal accumulatedNetValue = PricingTransactiondataConstants.ZERO;
IPricingItemUserExit[] prItems = pricingItem.getSubPricingItemsUserExitRecursive();

for (int i = 0; i < prItems.length; i++)
{
IPricingCondition condition =
((IPricingCondition)prItems[i].findPricingCondition
(pricingCondition.getStepNumber(),pricingCondition.getCounter()));

if(condition != null && condition.getConditionTypeName().equals("ZDDX"))
{
accumulatedNetValue = accumulatedNetValue.add(condition.getConditionBase().getValue());
}
else;
{
// accumulatedNetValue = PricingTransactiondataConstants.HUNDRED; //test value }
}
return accumulatedNetValue;
}

}

Can someone tell me why it is not working?

By the way, I tried one another thing. I simply copied the code from the previous post, added "return" statement, changed the condition type literal to the one existing in out system, and ran. I was not able to make it work.

Thanks for help.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2013 at 11:38 AM

    Hi Noriko,

    I dont think you need pricingItem.getSubPricingItemsUserExitRecursive() method to solve your issue.

    Try to use below item.getUserExitDocument().getUserExitItems() for getting all the line item documents. once you get line item document you can loop through the conditions with the method item.getUserExitConditions() .

    Hope it helps you.

    Thanks,

    Sarath.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sarath,

      Thank you for your input. Based on your advice, the code is now as follows and works.

      ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

      package sears.pricing.userexits;

      import java.math.BigDecimal;

      import com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit;

      import com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit;

      import com.sap.spe.pricing.transactiondata.userexit.ValueFormulaAdapter;

      import com.sap.spe.pricing.transactiondata.PricingTransactiondataConstants;

      /**

      * @author nchand3

      *

      * Sears Condition Price A905

      *

      * Sum of the Delivery Amount from each line where item category ZDOX, xworki.

      */

      public class A905 extends ValueFormulaAdapter {

      public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,

      IPricingConditionUserExit pricingCondition)

      {

      BigDecimal accumulatedNetValue = PricingTransactiondataConstants.ZERO;

      IPricingItemUserExit[] prItems = pricingItem.getUserExitDocument().getUserExitItems();

      for (int i = 0; i < prItems.length; i++)

      {

      IPricingConditionUserExit[] pricingConditions = prItems[i].getUserExitConditions();

      for (int j = 0; j < pricingConditions.length; j++) {

      if(pricingConditions[j].getConditionTypeName()==null){

      continue;

      }

      else if ( pricingConditions[j].getConditionTypeName().equalsIgnoreCase("ZDDX")) {

      accumulatedNetValue = accumulatedNetValue.add(pricingConditions[j].getConditionRate().getValue());

      break;

      }

      else{

      continue;

      }

      }

      }

      return accumulatedNetValue;

      }

      }

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.