Extend QP Custom Applications
Extend QP Custom Applications
Extend QP Custom Applications
To Custom Applications
Abstract
This presentation will discuss techniques of extending standard Advanced Pricing
functionality to integrate with custom applications. An overview of the Advanced Pricing
module, using the PRICE_REQUEST API, mapping attributes to custom data sources,
and use of GET_CUSTOM_PRICE will be discussed.
Objective
Oracle Application’s Advanced Pricing (QP) module is a flexible, extendable module that
provides a common source for setting up rules to derive prices. This paper will define key
components of the Advanced Pricing module, present methods and identify components
to extend aspects of the module to custom data, and discuss the risks and rewards of
customization.
Concepts
• Discuss key components of Advanced Pricing
• Provide an overview of Advanced Pricing Architecture
Code
• Present Extendible Components of Advanced Pricing
o Attribute Linking
o Get_Custom_Price
o Request_Price (Pricing Engine)
• Identify other Open APIs
Customization Considerations
• Customization Risk and Reward
• Customization methods
• Customization Do’s and Don’ts
The following pricing entities are important to define before the discussion of extending
Advanced Pricing to custom applications.
Price Lists
The price list remains as the starting point for a pricing transaction. All orders must have
a price, and the price list is where this price originates. Basic information on a price list
includes the price list name, item, list price, currency, and effective dates. Additionally,
list prices can be established for an item category. List prices can be derived from a
defined value, static formula (calculated prior to requesting a list price) or dynamic
formula (calculated at the time of a price request).
Qualifiers
Qualifiers define the rules of eligibility determining a price. The attributes of a
transaction are evaluated to enable, or qualify, for a pricing entity (price lists and
modifiers). Price lists and modifiers can be qualified by a qualifier attribute. A qualifier
attribute is a data element that is derived from a component of the transaction being
priced. It may be as simple as the item or customer on a transaction, or, a value returned
by program logic.
Modifiers
Modifiers are the pricing discounts, benefits, surcharges, and terms adjustments that can
be applied to an order when a price is requested. The Modifier also defines:
• Currency in which pricing is calculated
• Method to calculate discount (percent, lump sum, new price, amount)
• Level (header / line) the modifier will apply
• Pricing phase (when the modifier is to be considered)
• Effective Dates
• Item or Item Category that is eligible
• Bucket (sub total) from which a discount is applied
• Eligibility of the Modifier (Qualifiers)
• Incompatibility
For price discounts or charges, the application method, value, and formula can be defined
to calculate the value.
Formulas
A series of steps and mathematical expression interpreted and executed by the pricing
engine to calculate list prices or modifier discounts. This is the Advanced Pricing
extension point for GET_CUSTOM_PRICE as discussed in detail later in this paper.
Extend Advanced Pricing
Request Types
Request types define the header and line PL/SQL structures that are used to pass
transaction information to the pricing engine. These structures are the entry point for
price request processing. A group of request types for a similar transaction source is
referred to as a Pricing Transaction Entity. Figure 1 displays how global structures are
defined for a request type.
Figure 1
Qualifier Attributes
Qualifier attributes are used for the purpose of qualifying for a modifier or price
list. Examples of seeded contexts (logical groupings) of qualifier contexts are
‘CUSTOMER’ and ‘ORDER’. Qualifier attributes for each qualifier context are
Extend Advanced Pricing
defined. The values, derived at the time of a price request, are held in the
attribute for the pricing engine to use when determining a price. Custom qualifier
contexts can be defined, and, custom attributes can be defined for seeded contexts
or custom contexts. If a custom qualifier attribute is needed, begin using
QUALIFIER_ATTRIBUTE31 or greater. Oracle reserves
QUALIFIER_ATTRIBUTE1 to QUALIFIER_ATTRIBUTE30 for seeded
context / attribute definitions.
Pricing Attributes
Pricing attributes are values that are captured the time a pricing transaction is
entered, or, an additional way to define eligibility for a modifier or price list. The
two distinguishing properties of a pricing attribute are that the values can be
referenced in a formula line step, and, the values can be captured on the order line
in the pricing context / attribute form item. Again, custom definition of pricing
attributes should use PRICING_ATTRIBUTE31 or greater.
Product Attributes
Product attributes capture information related to an item. It is comprised of a
single context: ITEM. Attributes defined for the ITEM contexts are derived from
item categories and segments. Product attributes are used on modifier and price
list lines to determine the type of item, item category, or hierarchy that is being
priced. New custom contexts may not be created for product attributes; however,
new attributes may be defined for an existing product context. Product attributes
use the same physical columns as pricing attributes. PRICING_ATTRIBUTE31
and greater are reserved for custom definition.
Figure 2
Figure 3
Figure 4
Each qualifier attribute now must define the source for the value at the time a transaction
is priced. When a request for price is executed, a VALUE for all CONTEXT /
ATTRIBUTE pairs is resolved. These values are used by the pricing engine for that
pricing transaction request. The CONTEXT / ATTRIBUTE / VALUE combinations are
stored in PL/SQL or temporary table structures as a source for the pricing engine to
determine a price. To define the source, the attribute must identify how the value is
derived.
Attribute Linking
Linking an attribute defines the source of a VALUE for the CONTEXT / ATTRIBUTE
combination. There are three methods to link an attribute to a source:
User Entered
The value that is captured in a pricing context attribute and is entered on the
transaction. For Order Management, this is the pricing context field under the
pricing tab. The value of this mapping is simply derived from the
PRICING_ATTRIBUTE on OE_ORDER_LINES_ALL.
Custom Sourced
PL/SQL logic for custom sourced attribute is stored and compiled in an Oracle
provided package procedure: QP_CUSTOM_SOURCE.
Get_Custom_Attribute_Values. In this API, the user defined PL/SQL logic
Extend Advanced Pricing
derives a value and explicitly assigns the CONTEXT, ATTRIBUTE, VALUE for
a request type (ONT, ASO) and pricing type (Header or Line).
Attribute Mapping
The attribute value is determined for the header level, line level, or both levels of
the priced transaction by a value derived from a profile option, PL/SQL API, or
PL/SQL Multi-Record. In the Attribute Mapping method, the assignment of the
CONTEXT, ATTRIBUTE, VALUE combination is made by the
BUILD_SOURCING API. The PL/SQL function contains logic to derive a value.
Figure 5
To link an attribute to a custom PL/SQL package, navigate to the Attribute and Linking
Form, select Attribute Mapping , the Request System that will access this mapping, and
the level at which the mapped value will be applied (LINE, HEADER, BOTH). Select
Extend Advanced Pricing
Figure 6
The Attribute Mapping button opens the following form where the actual PL/SQL API,
PL/SQL multi-record logic, or, Profile Option is linked to the Attribute. The global
structure defined by the request type can be referenced in PL/SQL syntax. In this case, a
customer may have more than one color, therefore a PL/SQL API Multi-Record structure
will be returned by the custom function.
Extend Advanced Pricing
Figure 7
After the attribute link has been saved, the concurrent program Build Attribute Mapping
Rules must be executed.
Before executing Build Attribute Mapping Rules, the PL/SQL package / function:
c_qp_source.get_customer_color must be developed and built in the database. The
following is the package / function signature:
END C_QP_SOURCE;
Extend Advanced Pricing
The package body will contain PL/SQL logic to obtain Customer Colors from a data
source that may / or may not be a core Oracle Applications table.
The Build Attribute Mapping Rules concurrent program reads all PL/SQL linked
attributes and drops and re-creates the QP_BUILD_SOURCING _PVT package. This
package simply builds calls to both seeded and custom sourcing rules. The concurrent
program accomplishes this in two steps. First it builds a
QP_BUILD_SOURCING_PVT_TMP package and attempts to create this in the
database. If any compilation errors occur, then the concurrent program exits with an
error and does not attempt to build QP_BUILD_SOURCING_PVT. Execute the
concurrent report: Attribute Mapping Rules Error Report for a list of compilation errors.
If QP_BUILD_SOURCING _PVT_TMP is successfully compiled, then the
QP_BUILD_SOURCING _PVT package is dropped and re-created using the new
mapping rules.
The code that results loops through each enabled qualifier, pricing, and product attribute
and executes that function. The following code snippet displays a portion of
QP_BUILD_SOURCING_PVT that is built by Build Attribute Mapping Rules. Both
seeded calls for CUSTOMER, QUALIFIER_ATTRIBUTE2, Customer Name (as
displayed in Figure 4), and the custom CUSTOMER, QUALIFIER_ATTRIBUTE35,
Customer Color are shown.
… Extend Advanced Pricing
-- Src_Type: API
BEGIN
v_attr_value :=
OE_ORDER_PUB.G_LINE.sold_to_org_id;
EXCEPTION
WHEN OTHERS THEN
v_attr_value := NULL;
END;
BEGIN
IF v_attr_value = FND_API.G_MISS_NUM THEN
v_attr_value := NULL;
END IF;
EXCEPTION
WHEN VALUE_ERROR THEN
IF v_attr_value = FND_API.G_MISS_CHAR THEN
v_attr_value := NULL;
END IF;
WHEN OTHERS THEN
v_attr_value := NULL;
END;
x_qual_ctxts_result_tbl(q_count).context_name := 'CUSTOMER';
x_qual_ctxts_result_tbl(q_count).attribute_name := 'QUALIFIER_ATTRIBUTE2';
x_qual_ctxts_result_tbl(q_count).attribute_value := v_attr_value;
q_count := q_count + 1;
Best Practices
• Use a common PL/SQL Package for all functions used for custom attribute
linking.
• Use engine debug in custom code to assist in troubleshooting mapping errors.
These statements will appear in a debug file when Help-> Diagnostics-> Debug is
turned on for a session.
• Execute QP Build Sourcing Rules during system down time, or quiet system
times. Objects need to be locked for this process to complete successfully.
Figure 8
To define a Formula, navigate to the Formula Setup screen. Define the formula name,
description, effective dates, and, Formula; the arithmetic statement referencing formula
lines as steps. To extend to custom PL/SQL code, enter the Formula Type as ‘Function’
with a component of GET_CUSTOM_PRICE. After the Formula is saved, obtain the
Price_Formula_ID from the Help -> Diagnostic -> Examine feature. The
Price_Formula_ID is passed to GET_CUSTOM_PRICE when the Pricing Engine
determines that a value from this formula is required to satisfy a pricing request.
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;
Modify the function body to include the PL/SQL logic. The logic should be accesses by:
There are two (2) methods to obtain the parameter values needed for a discount percent in
this example:
END LOOP;
l_sold_to_org_id := OE_ORDER_PUB.G_HDR.sold_to_ord_id;
The values from the order transaction can now be used to calculate the discount percent.
RETURN l_disc_percent;
END IF;
Figure 9
When the OAUG_Example modifier is qualified for this discount, the Formula
OAUG_Percent_Discount will execute using custom logic to derive the discount percent.
Best Practices
• Use a common PL/SQL package for all functions custom pricing functions.
• Modularize the PL/SQL code outside GET_CUSTOM_PRICE.
GET_CUSTOM_PRICE simply becomes a wrapper to the custom function. The
custom function can then be reference outside a request for price.
The following steps outline the components needed to make a call to QP_PREQ_PUB
.Price_Request:
1. Copy the transaction information to the PL/SQL global structure defined by the
Request Type. For the ONT (Order Management Orders) request type, these
structures are OE_ORDER_PUB.G_HDR and OE_ORDER_PUB.G_LINE. Both
structures contain most all columns associated with the
OE_ORDER_HEADERS_ALL and OE_ORDER_LINES_ALL order
management tables that store transaction information for an order.
2. For each transaction line, execute the
QP_ATTR_MAPPING_PUB.Build_Contexts API to resolve the product, pricing,
and qualifier CONTEXT / ATTRIBUTE VALUES.
3. Copy the values returned by Build_Contexts, and the transaction header and line
information, to the parameters of QP_PREQ_PUB.Price_Request. Also, define
the control record. Three values are required for the Control Record:
a. Pricing Event. This defines the pricing phases that the Pricing Engine to
consider when evaluating the request. Valid Pricing Events are:
i. PRICE – List Line Base Price (List Price)
ii. LINE – Includes the pricing phases of List Line Base Price, List
Line Adjustment, Line Charges, and, Line Charges Manual.
iii. BOOK – Includes the Book Event Phases only.
iv. ORDER – All Lines Adjustments, Header Level adjustments and
Header Level Charges
v. SHIP – Includes Phases related to the Shipping Events
vi. BATCH – All ORDER and LINE phases. This is used to capture
all pricing for an order transaction.
b. Calculate Flag – Determines the scope of work the pricing engine is being
asked to perform:
i. Search Only - Obtain a list price only. Do not calculate a selling
price.
ii. Calculate Only - Pass this if adjustment records need to be
interpreted by the Pricing Engine. New adjustments are not
retrieved. Typically, this is set when the Pricing Engine has been
called, and modifications to adjustments have been made.
iii. Search and Calculate - Used for the standard Pricing Engine call.
New adjustments are captured and applied to the list price to obtain
a new selling price.
c. Simulation Flag – The Pricing Engine keeps track of issued and redeemed
coupons. A value of ‘Y’es indicates that the call to pricing is a simulation
and that the pricing engine should not make permanent record changes for
issuing and redeeming coupons.
Extend Advanced Pricing
4. Call QP_PREQ_PUB.Price_Request.
If this call is made by a separate request type, logic must be developed to capture the
information returned by QP_PREQ_PUB.Price_Request. The requirements of the
interface will determine what needs to be captured and retained from the call.
Customizations
Customizations are a double edged sword. While providing your business users with
functionality that enables productivity, customer satisfaction, and competitive advantage,
introduced is a cost of development, maintenance, support and upgrade vulnerability.
Many times Oracle Application modules provide a way to meet the custom requirement;
however, the implementation of the requirement may not be straight forward and be
cumbersome. The cost to implement with “vanilla” Oracle may out weigh the cost to
develop a customization.
When to Customize
Evaluate the cost of doing business without the customization. Quantify and answer the
following questions:
• Does the customization reduce the time to execute a change to meet changing
market place requirements?
• Does the customization minimize data errors during maintenance periods?
• Does the customization provide a competitive advantage?
• Does the customization enable your business the bandwidth to develop and
explore new opportunities?
How to Customize
If Customizations are developed correctly, the vulnerability to patches and upgrades can
be minimized and avoided. Oracle Applications Developer Guide discusses two general
methods of customization:
Customization by Modification
This method of customization involves modifying existing Oracle Application
components to meet the custom requirement. This may mean changing a form,
PL/SQL logic, or, tables that are provided by Oracle Applications. These types of
modifications may be lost during the application of patches or upgrades, and, can
introduce data integrity issues for standard Oracle processes.
Extend Advanced Pricing
Customization by Extension
Customization by extension involves developing PL/SQL, forms, database tables
as stand alone entities that can be integrated with core Oracle Application
modules. Using development methods documented in the Oracle Applications
Developers Guide, this method can result custom modules that look and feel the
same as the core application modules. Oracle Applications Architecture provides
interface points such as Zoom Forms and Custom PLLs (form libraries) that allow
standard form modules to interface with custom forms, as well as, APIs that
support application logic to insure data integrity when maintaining data in
standard oracle data structures.
Custom Data
Data accessed by the Advanced Pricing module should be in the same Oracle instance
that Oracle Applications is running. If data sources exist outside the Oracle instance,
consider replication or import methods to make the data available within the Oracle
Application instance. Data referenced outside the Oracle Applications instance will
result in performance issues.
When modeling custom data sources that are accessed by extending the Advanced
Pricing module, be sure to design physical tables in a way that program logic can
efficiently resolve a value from a data element on the transaction being priced.
Information pertaining to a priced transaction typically is derived from a Customer or
Item related data element. In a custom tables, consider referencing
HZ_PARTIES.PARTY_ID, HZ_CUST_ACCOUNT.CUST_ACCOUNT_ID, and,
HZ_CUST_SITE_USES_ALL.SITE_USE_ID for quick retrieval of customer related
information, and, MTL_SYSTEM_ITEMS.INVENTORY_ITEM_ID and Item
Categories for item related information. Logic to resolve values from custom data
sources must be proficient to avoid performance issues.