Test and Troubleshoot Pricing Algorithms

Test your pricing algorithm set up. If it doesn't work, troubleshoot.

Test Your Setup

Here's how you test your pricing algorithm set up if you find a problem or prefer to test the set up before you publish.

  1. Open your pricing algorithm for editing.

  2. Click Test, then click Actions > Add Row.

  3. In the Test Input area, specify inputs to the test.

    In the Test Input area, specify inputs to the test

    Note

    • Examine the predefined set up. Some algorithms come predefined with tests already set up. For example, the Price Sales Transactions algorithm comes predefined with the PriceRequest variable already set up for testing.

      If necessary, modify the Variable Value so it reflects your changes.

    • If you created a new variable during set up, or need to test performance of a predefined one, then add it now.

    • Add variables that are of type Input, or type Input and Output.

      For example, add the Boolean variable GetAllUserDefinedAttributeFlags.

  4. In the Variable Value column, add one of.

    • Groovy expression.

    • Literal string.

    • XML formatted code.

    • Check mark for a Boolean data type.

  5. Click Run Test, then examine the output.

    examine the output

    Note

    • For future reference and tracking purposes, modify the Test Case Name and Description, as necessary.

    • If the test fails, click Show Exception Details to troubleshoot your set up.

    • Pricing saves your test case across upgrades for algorithms that are at version 2 or higher.

Study some examples that test algorithms. For details, see Overview of Pricing Use Cases.

Troubleshoot Your Setup

  1. Click Show Exception Details.

    Here's the dialog that displays.

    the dialog that displays.
  2. Examine the error message. It contains the exact Groovy code that causes the problem, such as Charge1. Its usually the second line in the details. For example:

    Alias 'Charge1' cannot be found on this Row
    
  3. Determine where the error happens. Its usually immediately below the text Algorithm Call Stack.

    The call stack includes the statement, step, and algorithm that contains the Groovy code that causes the problem. For example:

    createChargeComponent(Charge1, ChargeComponent, 'LIST_PRICE', 'QP_LIST_PRICE') at Step 'Get List Price'at Algorithm: 'Simple Pricing Process Custom-1'

    In this example, the code happens in the createChargeComponent statement on the Get List Price step of the Simple Pricing Process Custom-1 algorithm.

  4. Examine the variable values in the Algorithm Variable Stack section. This section includes variable values that exist immediately before the error happens.

    • Verify data type. For example, InventoryOrganizationId is a numeric value. It must contain numeric data, such as 204, not text data, such as Computer Service and Rentals.

    • Verify data value. For example, if you expect unitCode to equal Ea, but it contains Box, that's not good.

  5. Examine changes you made that might cause the error.

    • Examine your recent changes to the algorithm or algorithm step. Use details from the Algorithm Call Stack section to determine where to look first.

    • Examine changes you made to the service mapping. Changes can result in errors in the algorithm. For example, make sure you set up sources and attributes correctly.

    • Examine your code for typographical errors.

    • Make sure you declared all your variables.

    • Make sure you defined all attributes that the algorithm uses.

Here's the complete Test Exception details for this example.

JBO-29000: Unexpected exception caught: oracle.apps.scm.pricing.priceExecution.algorithms.publicQuery.exception.SetQueryException, msg=Failed to execute onEach Closure.

Alias 'Charge1' cannot be found on this Row

# Algorithm Call Stack -----------------------
createChargeComponent(Charge1, ChargeComponent, 'LIST_PRICE', 'QP_LIST_PRICE') at Step 'Get List Price'at Algorithm: 'Simple Pricing Process Custom-1'

# Algorithm Variable Stack---------------------------
Algorithm: 'Simple Pricing Process Custom-1' payload: VariableName:'PriceRequest' DateType:'commonj.sdo.DataObject' IOType:'InOut' value:'<?xml version="1.0" encoding="UTF-8"?>
<SimplePriceRequest:SimplePriceRequestType xmlns:SimplePriceRequest="http://xmlns.oracle.com/apps/scm/pricing/priceExecution/serviceMappings/publicMappings/SimplePriceRequestType" xmlns:ns0="http://xmlns.oracle.com/adf/svc/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SimplePriceRequest:SimplePriceRequestType">
<SimplePriceRequest:PricingServiceParameter>
<SimplePriceRequest:PricingContext>SALES</SimplePriceRequest:PricingContext>
</SimplePriceRequest:PricingServiceParameter>

<SimplePriceRequest:Header> 
  <SimplePriceRequest:CalculatePricingChargesFlag>true</SimplePriceRequest:CalculatePricingChargesFlag>
  <SimplePriceRequest:CalculateShippingChargesFlag>false</SimplePriceRequest:CalculateShippingChargesFlag> 
  <SimplePriceRequest:CalculateTaxFlag>false</SimplePriceRequest:CalculateTaxFlag>
  <SimplePriceRequest:CustomerId>1000</SimplePriceRequest:CustomerId>
  <SimplePriceRequest:HeaderId>1</SimplePriceRequest:HeaderId>
  <SimplePriceRequest:SellingBusinessUnitId>204</SimplePriceRequest:SellingBusinessUnitId>
  <SimplePriceRequest:SellingLegalEntityId>204</SimplePriceRequest:SellingLegalEntityId>
  <SimplePriceRequest:TransactionTypeCode>ORA_SALES_ORDER</SimplePriceRequest:TransactionTypeCode>
</SimplePriceRequest:Header> 

<SimplePriceRequest:Line>
  <SimplePriceRequest:HeaderId>1</SimplePriceRequest:HeaderId>
  <SimplePriceRequest:InventoryItemId>101</SimplePriceRequest:InventoryItemId>
  <SimplePriceRequest:InventoryOrganizationId>204</SimplePriceRequest:InventoryOrganizationId>
  <SimplePriceRequest:LineCategoryCode>ORDER</SimplePriceRequest:LineCategoryCode>
  <SimplePriceRequest:LineId>1</SimplePriceRequest:LineId>
  <SimplePriceRequest:LineQuantity unitCode="Ea" xmlns:tns="http://xmlns.oracle.com/adf/svc/errors/">2</SimplePriceRequest:LineQuantity>
<SimplePriceRequest:Line>