Professional Documents
Culture Documents
Get Custom Price API
Get Custom Price API
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 7
Then, you create a modifier that applies a lumpsum surcharge for a range of 1-999999999
using the surcharge formula.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 8
Setup steps
1. Create inventory items for each pricing scenario. In this example,
we have created L53-PRORATE, L53-SURCHARGE, and
L53-SVCCREDIT.
2. Assign these items to the org(s) desired.
Setup for the prorated item
3. Create a pricing formula for the proration. In this example, we have
created L53-Monthly Proration.
4. Enter NVL (1, 2) in the Formula field on the formula header.
5. Create one formula line with a Formula Type of Function.
GET CUSTOM PRICE is automatically populated into the Component
field and cannot be changed.
6. Enter 1 in the step field.
7. Create a second formula line with a Formula Type of Numeric
Constant, a Component of 0, and a Step of 2.
8. Save the record.
9. Navigate to Help>Diagnostics>Examine and enter the
password APPS.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 9
10. Search for the PRICING_FORMULA_ID attribute and note the formula
id.
11. Close the Pricing Formulas form and navigate to the Price Lists
window.
12. Add the L53-PRORATE item to a price list.
13.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 10
14. Enter a list price. In our example we used $2000.
3.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 11
Surcharge item setup
14. In the Dynamic Formula field, enter the name of the formula you
just created, L53-Monthly Proration in our example
15. Create a pricing formula for the surcharge item. In this example, we
have created 20% of Order.
16. Enter 2 * NVL(1, 3) in the Formula field on the formula header.
17. Create one formula line with a Formula Type of Function.
GET CUSTOM PRICE is automatically populated into the Component
field and cannot be changed.
18. Enter 1 in the step field.
19. Create a second formula line with a Formula Type of Numeric
Constant, a Component of .2, and a Step of 2.
20. Create a third formula line with a Formula Type of Numeric
Constant, a Component of 0, and a Step of 3.
21. Save the record.
22. Navigate to Help>Diagnostics>Examine and enter the
password APPS.
23. Search for the PRICING_FORMULA_ID attribute and note the formula
id.
Close the Pricing Formulas form and navigate to the Price Lists
window.
24. Add the L53-SURCHARGE item to a price list.
25. Enter a list price. In our example we used $0.
26. In the Dynamic Formula field, enter the name of the formula you
just created, 20% of Order in our example.
Service credit refund item setup
27. Create a pricing formula for the service credit. In this example, we
have created
JLS-Service Credit.
28. NVL ( 1, 2 ) in the Formula field on the formula header.
29. Create one formula line with a Formula Type of Function.
GET CUSTOM PRICE is automatically populated into the Component
field and cannot be changed.
30. Enter 1 in the step field.
31. Create a second formula line with a Formula Type of Numeric
Constant, a Component of 0, and a Step of 2.
Save the record.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 12
32. Navigate to Help>Diagnostics>Examine and enter the
password APPS.
33. Search for the PRICING_FORMULA_ID attribute and note the formula
id.
Close the Pricing Formulas form and navigate to the Price Lists
window.
34. Add the L53-SVCCREDIT item to a price list. Use Price Break
Header as the line type.
35. Click the Price Breaks button and enter price breaks according to
the following table:
From To Price
0 75 10
75 200 12
201 350 13
351 999999999 14
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 13
37. Close the Price Lists form.
38. Open the Define Modifiers form.
39. Create a new modifier of type Discount List. In our example, we
called it JLS-07.
40. Create a modifier line and set these values in the Modifiers
Summary tab.
Level Modifier Type Pricing Phase Break Type From To
Line+ Surcharge List Line Adjustment Point 1 9999999999
41. Enter these values in the Discounts/ Charges tab.
Formula Application Method
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 14
JLS-Service Credit Lumpsum
42. Save your work.
43. Modify the PL/ SQL package provided here by setting the formula and item constants.
44. Set the formula contants for C_surcharge_formula, C_prorate_formula,
C_service_credit_formula to the values you obtained when setting up the formulae
45. Set the item contants for C_surcharge_item_id, C_subscription_item_id.
Note that you can use either the item_id or item_description.
46. Create function QP_CUSTOM.Get_Custom_Price by compiling the PL/ SQL code that you
have modified Make sure that your extension code written in get_custom_price is tuned
for optimal performance. Otherwise, the Advanced Pricing engine performance will be
negatively impacted.
47. Set the value of the profile option QP: Get CustomPriceCustomized.at the site level. If you have
setup a formula to use the function but havent setup the profile then a runtime error will be
displayed.
48. After the code compiles successfully, test your setup by creating a sales order. Make sure you
add the surcharge item after you've added another item to have a sales order amount to
discount.
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM
Page 15
Oracle Advanced Pricing:
Get_Custom_Price
Code Example
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM Page 1
WARNI NG: Your Get _cust om_pr i ce r out i ne shoul d not i ssue any dat abase commi t .
I ssui ng a commi t wi l l cor r upt t he Tr ansact i on dat a as wel l as Pr i ci ng dat a.
CREATE CREATE OR REPLACE PACKAGE BODY QP_CUSTOM AS
FUNCTION Get_Custom_Price (p_price_formula_id IN NUMBER,
p_list_price IN NUMBER,
p_price_effective_date IN DATE,
p_req_line_attrs_tbl IN QP_FORMULA_PRICE_CALC_PVT.REQ_LINE_ATTRS_TBL)
RETURN NUMBER IS
l_number_of_days_left NUMBER; -- number of days left in month
l_number_of_days NUMBER; -- number of days in month
l_prorated_price NUMBER (9,2); -- final prorated price
l_todays_date NUMBER; -- today's date day
l_order_price NUMBER (9,2); -- total order selling price
l_header_id NUMBER; -- order header id
l_line_id NUMBER; -- order line id
l_line_quantity NUMBER; -- selling quantity
l_list_price NUMBER; -- line item list price
l_last_month_volume NUMBER; -- last month's sales volume for current customer
l_selling_price NUMBER; -- line price after discounts applied
l_line_list_price NUMBER; -- total line list price
l_refund_amount NUMBER; -- refund for service credit formula
l_surcharge NUMBER; -- surcharge for surcharge formula
-- formula constants identify which formula is being invoked
-- according to formula_id
C_surcharge_formula CONSTANT INTEGER := 6026; -- surcharge formula ID
C_prorate_formula CONSTANT INTEGER := 6069; -- proration formula ID
C_service_credit_formula CONSTANT INTEGER := 6177; -- service credit formula ID
-- The surcharge formula needs to know the inventory item id of the surcharge
-- item so it doesn't use that item's price in the total order amount
-- calculation. The service credit formula needs to know the item
-- or items to count when determining prior month subscription charges.
-- In this case, it's an item but it could be a group of items or a category
C_surcharge_item_id CONSTANT INTEGER := 4534; -- surcharge item ID
Oracle Advanced Pricing:
Get_Custom_Price
Code Example
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM Page 2
C_subscription_item_id CONSTANT VARCHAR2(200) := 'L53-SUBSCRIPTION'
BEGIN
-------------------------------------------------------------------
-- Service credit refund formula
-------------------------------------------------------------------
IF p_price_formula_id = C_service_credit_formula THEN
-- use the oe_order_pub API to get header and line information
l_line_id := oe_order_pub.G_LINE.line_id;
l_line_quantity := oe_order_pub.G_LINE.ordered_quantity;
l_list_price := oe_order_pub.G_LINE.unit_list_price;
l_selling_price := oe_order_pub.G_LINE.unit_selling_price; -- after modifier applied
-- the following statement determines the total amount of item L53-SUBSCRIPTION
-- ordered during the current month for the current customer. It only looks
-- at booked orders.
SELECT sum ( oola.ordered_quantity * oola.unit_selling_price )
INTO l_last_month_volume
FROM oe_order_lines_all oola,
oe_order_headers_all ooha
WHERE oola.sold_to_org_id = oe_order_pub.G_LINE.sold_to_org_id
AND
oola.ordered_item = C_subscription_item_id
AND
ooha.header_id = oola.header_id
AND
ooha.booked_flag = 'Y';
-- l_last_month_volume := 10000; -- for testing purposes
-- get the number of days in the current month for the refund formula
SELECT TO_NUMBER (TO_CHAR (LAST_DAY(SYSDATE), 'DD' ))
INTO l_number_of_days
FROM sys.dual;
Oracle Advanced Pricing:
Get_Custom_Price
Code Example
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM Page 3
-- because of the price-break component of this formula, we need to first get the list price
-- of the refund item. This is the price break header price. In other words, the price break
-- is set up on the price list, not in a modifier
l_line_list_price := l_line_quantity * l_list_price;
-- now we apply the formula to determine the total refund amount based on this month's volume
l_refund_amount := ( l_line_list_price / l_number_of_days ) * l_last_month_volume;
-- because this formula is approved through a surcharge modifier, we now need to subtract the
-- list price from the refund amount to get the surcharge. When this surcharge is added back
-- to the list price, the refund amount is correct.
l_surcharge := (l_refund_amount - l_line_list_price) * -1 ;
-- the following is to insert values into a table
-- for debugging purposes
--
-- insert into jls_Test
-- values ('QTY: ' || l_line_quantity || ' list: ' || l_list_price || ' selling: ' || l_selling_price
-- || ' days: ' || l_number_of_days || ' line: ' || l_line_list_price || ' refund: '
-- || l_refund_amount || ' surcharge: ' || l_surcharge || 'last month: ' || l_last_month_volume
-- || ' line id: ' || l_line_id );
-- commit;
RETURN l_surcharge;
END IF;
-------------------------------------------------------------------
-- Proration formula
-------------------------------------------------------------------
IF p_price_formula_id = C_prorate_formula THEN
-- get the last day of the month and the current day of the month
SELECT TO_NUMBER (TO_CHAR (LAST_DAY(SYSDATE), 'DD' )),
Oracle Advanced Pricing:
Get_Custom_Price
Code Example
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM Page 4
TO_NUMBER (TO_CHAR (SYSDATE, 'DD' ))
INTO l_number_of_days,
l_todays_date
FROM sys.dual;
l_number_of_days_left := l_number_of_days - l_todays_date;
-- apply the formula using the list price passed into this function
l_prorated_price := (p_list_price / l_number_of_days) * l_number_of_days_left;
RETURN l_prorated_price;
END IF;
IF p_price_formula_id = C_surcharge_formula THEN
l_line_id := oe_order_pub.G_LINE.line_id; -- get current line
SELECT oola.header_id -- get the header id for the order
INTO l_header_id
FROM oe_order_lines_all oola
WHERE oola.line_id = l_line_id;
-- sum the selling price of all lines except for the surcharge line
-- in the current order
SELECT SUM(oola.ordered_quantity * oola.unit_selling_price)
INTO l_order_price
FROM oe_order_lines_all oola
WHERE oola.header_id = l_header_id
AND oola.inventory_item_id != C_surcharge_item_id;
IF l_order_price IS NULL THEN
l_order_price := NULL;
END IF;
RETURN l_order_price;
END IF;
END GET_CUSTOM_PRICE;
Oracle Advanced Pricing:
Get_Custom_Price
Code Example
Oracle Corp 2001 All Rights Reserved Oracle Advanced Pricing: Extend Dont Customize 5/16/01 9:51 AM Page 5
END QP_CUSTOM;
Oracle 11i Advanced Pricing
Dont Customize. Extend!
May 2001
Author: Joshua Saffren
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.
Worldwide Inquiries:
Phone: +1.650.506.7000
Fax: +1.650.506.7200
Web: www.oracle.com
This document is provided for informational purposes
only and the information herein is subject to change
without notice. Please report any errors herein to
Oracle Corporation. Oracle Corporation does not
provide any warranties covering and specifically
disclaims any liability in connection with this document.
Oracle is a registered trademark, and Oracle Order Management is (are) a
trademark(s) or registered trademark(s) of Oracle corporation.
All other names may be trademarks of their respective owners.
Copyright Oracle Corporation 2001
All Rights Reserved