Anda di halaman 1dari 4

How to use Attribute Mapping in Oracle Advanced Pricing

Attribute management in Oracle Advanced pricing is a very powerful tool and can act as a perfect
gateway to resolve any complex requirement from the customer.
Let's take an fairly simple example:
Requirement:
Sales order line - List price needs to be calculated based on a custom formula below:
Price =Average cost+20% markup
So, if average cost if 100 then the price should be 120.
Solution:
Step 1 - Define a custom formula by referring to "GET_CUSTOM_FUNCTION"

Step 2 - Define a price list referring to this custom formula


Concept: GET_CUSTOM_FUNCTION
This is a seeded function provided by Oracle to apply custom logic. However, when this function is used
the only information which is passed automatically by Oracle is the "Formula ID" and set of ATTRIBUTEs
& their values. So, this is where one needs to setup attributes to pass relevant values to the custom
function, so that custom logic can derive the required output.
Step 3 - Identify input values required for GET_CUSTOM_FUNCTION to calculate the list price

INVENTORY_ITEM_ID - cost of which item?

ORGANIZATION_ID - cost under which organization?

SO_UOM - Sales order UOM. Maybe the cost needs to be converted into the unit of measure of
the quantity sold
Step 4 - Navigate to Oracle Pricing Manager->Setup->Attribute Management->Context and Attributes and
define a pricing context

Step 5 - Define pricing attributes

Code
INVENTORY_ITEM_I
D
ORG_ID

Name
Inventory Item
ID
Inv Org ID

Description
Inventory Item
ID
Inv Org ID

Precedence
1

SO_UOM

SO UOM

SO UOM

Column Mapped
PRICING_ATTRIBUTE
1
PRICING_ATTRIBUTE
2
PRICING_ATTRIBUTE
3

Step 6 - Enable this pricing context and navigate to Attribute Linking and Mapping, search for Pricing
Transaction Entity as "Order Fulfillment" and Select context type as "Pricing Context", select above
context from the list and click on "Link Attributes". Fill in below details for each of the attributes defined
above:
INVENTORY_ITEM_ID

Click on Attribute Mapping, select row with application as "Order Management" (ONT) and select source
application as "Advanced Pricing", user source type as "PL/SQL API" and user value as
"OE_ORDER_PUB.G_LINE.INVENTORY_ITEM_ID"

You can open TOAD or SQL Developer and view the definition of this package
"OE_ORDER_PUB.G_LINE" and find out the exact column definition.
You can also open any sales order, focus on the field and go so sales order line and navigate to Help>Diagnostics->Examine to find the column name to be used.
Step 7: Follow the same process and link remaining attributes
ORG_ID - OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID
SO_UOM - OE_ORDER_PUB.G_LINE.ORDERED_UOM
Step 8 - One of the limitations of advanced pricing is that, these attributes will not be passed into the
GET_CUSTOM_FUNCTION unless they are used by any of the advanced pricing objects like formulas
etc directly. So, create a dummy formula with a factor list and use all the three attributes with some
dummy values as conditions.

Step 9 - Now that all setup is done. Define the GET_CUSTOM_FUNCTION


I have embedded a sample code which will help you to understand how to retrieve these attribute values
dynamically:

Sample of how this function's body would start

CREATE OR REPLACE PACKAGE BODY QP_CUSTOM IS


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

Get the formula name dynamically, so that the custom code can be differentiated. Note that
Oracle provides only one function. Same function can actually be used by various other formulas in
various other price lists. Hence, get the formula name first based on formula id which comes by default:
SELECT NAME
INTO l_formula_name
FROM qp_price_formulas_vl
WHERE price_formula_id = p_price_formula_id
AND end_date_active IS NULL;

Now write your complete code within the condition based on the formula name
IF l_formula_name = 'List Price Formula' THEN
END IF;

Use below code to retrieve the attribute values dynamically. Note that, advanced pricing engine
passes all contexts and values in the same cursor (last parameter)
FOR j IN p_req_line_attrs_tbl.FIRST..p_req_line_attrs_tbl.LAST LOOP
IF p_req_line_attrs_tbl(j).CONTEXT = 'LIST_PRICE_CONTEXT' AND
p_req_line_attrs_tbl(j).ATTRIBUTE = 'PRICING_ATTRIBUTE1' THEN
l_inventory_item_id := l_req_line_attrs_tbl(j).VALUE;
ELSIF p_req_line_attrs_tbl(j).CONTEXT = 'LIST_PRICE_CONTEXT'' AND
p_req_line_attrs_tbl(j).ATTRIBUTE = 'PRICING_ATTRIBUTE2' THEN
l_org_id := l_req_line_attrs_tbl(j).VALUE;
ELSIF p_req_line_attrs_tbl(j).CONTEXT = 'LIST_PRICE_CONTEXT'' AND
p_req_line_attrs_tbl(j).ATTRIBUTE = 'PRICING_ATTRIBUTE3' THEN
l_so_uom := l_req_line_attrs_tbl(j).VALUE;
END IF;
END LOOP;
Step 10: Once input parameters are known code can be written to derive the average cost and to add the
markup % to return the list price.

Anda mungkin juga menyukai