You are on page 1of 31

Extending 11i Advanced Pricing for Your Business Part 1: Using Attributes Mapping

An Oracle Technical White Paper March 2001

Note: The information in this white paper is applicable to version 11.5.7 of Oracle Advanced Pricing or below. Customers with version 11.5.8 and above should refer to the Advanced Pricing Implementation Guide chapter on "Attribute Management."

Oracle Corporation 2001 All Rights Reserved

Extending Advanced Pricing Using Attributes Mapping

EXECUTIVE OVERVIEW

Oracle Advanced Pricing has a wide set of functionality provided in the out of the box solution. However, there are frequently new innovations and ideas generated in promoting/ pricing the product. Getting and keeping customers and sales requires great capacity for flexibility in pricing. Because of lack of flexibility, packaged pricing software frequently fails to meet the needs of eBusiness era companies. As a result, many companies find themselves making significant and therefore expensive customizations to packaged software pricing modules in order to meet their pricing business requirements, or go to great expense to integrate new software with older legacy pricing applications. This is precisely why Oracle Advanced Pricing provides a unique infrastructure that allows you to tap into your pricing related business data and harness it according to your pricing rules with a simple, non invasive extension that allows you to define your own elements of pricing data to Advanced Pricing. Advanced Pricing lets you avoid customizations by providing extension capabilities like Attribute Mapping and get_custom_price routine in the formula. This white paper explains Attributes Mapping . A separate white paper explains Get_custom_price. In this paper you will learn how you can use Attribute mapping to easily extend Pricing to tap into data from a wide variety of non-standard sources to drive your pricing. These data sources can be within Oracle Applications or from outside Oracle Applications. Some typical, but by no means limited examples of the uses of this capability include: Defining a qualifier if today is Tuesday then given 10% off. Define your own customer groupings that are in addition to the standard groupings that are provided in Oracle Applications. You can use these groups to control pricing such that if customer is in your special group A then 10% is given, or if customer is in your special group B then a 7% discount is given. Obtaining the cumulative value of sales over a long time period from a data warehouse, and using this as a qualifier for a discount, rebate accrual, or other pricing benefit.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 2

Define another element in the product hierarchy to give discounts based on the Brand of the product. For example, If you define segment6 of mtl_system_items to be product brand then you can create an element in the product hierarchy for Brand. The objective of this technical white paper is to provide you with information you need to utilize attribute mapping. An example of attribute mapping is provided as an appendix to this paper.
SOME TERMINOLOGY

Qualifiers :These are eligibility criteria. For example Customer class = VIP or If today is Tuesday: Product Hierarchy Element : A level in the product hierarchy at which pricing characteristics are defined. Examples of product hierarchy elements are item number, category, brand. Customer Hierarchy Element: A level in the customer hierarchy at which pricing characteristics are defined. Examples include customer groups not definable using the standard Oracle Customer Master or Trading Community Architecture definitions. Frequently, users define such groups in the flex fields of the Oracle customer master. Pricing Attributes : These are attributes which provide additional definition to the Product. For example Cleanliness is a Pricing attribute of an item Photocopier Service

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 3

OVERVIEW OF HOW ATTRIBUTES MAPPING WORKS AT RUN TIME

1.

Calling application calls QP_Attr_Mapping_PUB.Build_Contexts. This routine executes the static generated sourcing routines and returns the attributes to the calling application. Calling application then appends the User entered attributes and asked for Qualifiers to this request. Calling application then calls Pricing Engine with these sourced attribute values. Pricing Engine also appends a few internally sourced attributes to this request. Pricing engine processes the request and returns the results to the calling application.

2. 3. 4. 5.

OVERVIEW OF TASKS INVOLVED IN IMPLEMENTING THE EXTENSION

Example : Customers in the Western Region get 10% discount

Task1: Create a Qualifier Flexfield segment Customer Region Task2: Assign a value Set to show a List of valid values for the Customer region segment Task3: Use Attributes mapping to indicate where to fetch the customer region at the runtime. For example from transaction record row2.column1 or from PL/SQL API get_region. This may require wring a pl/sql API. Task4: Create a test modifier to use this attribute.

Task5: Run Build Sourcing Program

Figure 1 Overview of Tasks Involved in extension


DETAILED STEPS IN DEFINING YOUR OWN PRICING ELEMENT (QUALIFIERS, PRODUCT, PRICING ATTRIBUTE)

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 4

Defining Context

Context is considered as a group of related pricing elements. There is no real need to define multiple contexts other than convenience of grouping the related pricing elements. For example an organization can decide to create context for each of the line of business. Steps: 1. 2. 3. Open Setup-->Flexfields form Query Qualifier Context , to create a qualifier Attribute or Pricing Context to create a pricing attribute Add a new context in the Context Field Values or choose an existing context (for adding element to the product hierarchy use ITEM context) . Please note that following pre-defined contexts have a special meaning n Item - This context is used as Product Hierarchy context. You must use this context for defining any additional element in the product hierarchy n Volume - This context is used for defining the Price Break Criteria. Users can define a price break only for the attributes of the Volume Context ModList - This context is an internal context which is internally used for Price List, Asked for Promotions, Coupons etc
Defining Segment

Segments is a pricing element. For example Customer Region is a segment in the Context Customer. Brand may be a segment in the Item Context. Age may be a segment in the pricing attributes context called Photocopier Attributes. Steps: 1. 2. Click on the Segments button In the Segments Summary screen create a new segment . Enter the following fields:

Number : Decides the precedence. Lower Number has higher precedence. Please refer to Oracle Advanced Pricing User Guide for more information about Precedence and how it is used by the pricing engine.

Note : Advanced Pricing has been seeding certain qualifiers/ Pricing attributes. There is an issue where the precedence of the seeded attribute is same as customer created attribute. Going forward Advanced Pricing will use the precedence number in the series of 5s, 10s for the newly seeded attributes. Hence it is recommended that the customer use other available numbers for precedence.
Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 5

Name: Give a name which is unique. Please make sure that the Name is pre-fixed with your own custom prefix(other than QP) to prevent any accidental overwrite by future pricing seed data uploads. Window Prompt : Enter the display value for this segment Column : Choose a segment from the list. This value would be stored in the QP setup tables. This value also would be used in the Attribute Mapping. For example qualifier_attribute30/pricing_attribute30.

Note : Segments numbering less than 30 are reserved for future use by pricing. By default only 30 segments are enabled. More segments can be enabled using the screen -- flexfields->descriptive-->register

Attaching a value set to the segment

Value set provides the list of values for the pricing element. For example if my qualifier is customer region then the value set needs to provide valid list of values for the customer region. Attaching value set is a mandatory step for the pricing elements to be usable in pricing. As a general principle it is recommended that the value set should be from setup tables and not from transaction tables. (for example the valueset for Brand should be from the table where list of brands are stored and not from mtl_system_items_b.segment6 ). Please also note that as of now advanced pricing does not support dependent valuesets. Steps: 1. Choose an existing valueset or create a new one by clicking on the Value Set button. Please note that whatever defined in the Value Column is displayed in the value column of the qualifiers window. Meaning column is used in the LOV in the Qualifiers window while selecting a qualifier.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 6

2. 3. 4. 5.

Give a valueset name, description Choose the format type. If the value is number choose a number, for date choose standard date or for character choose char Make sure that there an assignment in the ID column. Follow the instructions from Flexfield guide to fill in the rest.

Warning: Please note that the qualifier and Pricing attributes datatype is derived from the valueset . Advanced Pricing does not support changing the datatype of a qualifier/pricing attributes once that qualifier/atttribute is used in setup. Not following this will result into pricing engine failure and potential data issues. Also please note that OM Family patchset D or QP patch 1508982 has introduced a faster algorithm which uses this datatype for evaluating the

Note: Consideration for Breaks on attributes other than Qty. If the volume breaks are defined based on attributes other than qty then it is assumed that the pricing attribute is and the break are in the matching UOM. For example if a volume break is defined on an attribute called Age in Years then it is assumed that the Age in Years is sourced as Age in years. Pricing Engine has no knowledge of the UOM of the pricing attribute hence no conversion can be performed

Completing the flexfield setup:

Commit the record and compile the flexfield and make sure that the concurrent program completes successfully
ATTRIBUTES MAPPING

After finishing the flex field setup you can start the setup activities of creating modifiers and attaching qualifiers or product hierarchy elements. However Pricing engine will not know where to find/ derive the values of these elements at the run time. Hence Attributes Mapping is a mandatory step before any pricing element is used by the Pricing engine. Pricing engine also provides a flexibility that a transaction area can define the attributes mapping specific for its use. For example Customer Region may be derived from a OE_ORDER_PUB.G_HDR.sold_to_org_id for Order Management. However this same element may have to be derived from

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 7

ASO_PRICING_INT.G_HEADER_REC.cust_account_id for Order Capture. Steps:

Note: Advanced Pricing uses OM Defaulting screens for Attributes mapping functionality. The Attributes mapping data is visible only if the form is invoked using the Advanced Pricing Manager Responsibility because the form takes application_id as a parameter.

While in Oracle Pricing manager responsibility , invoke setup-->Attribute Mapping

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 8

1. 2.

To enter a sourcing rule for a qualifier, query for entities Header Qualifier Attrs and Line Qualifier Attrs To enter a sourcing rule for a pricing attribute , query for entities Header Pricing Attrs and Line Pricing Attrs

Note: Use the Header entity , if the qualifier/pricing attribute is to be used for setting a modifier of level Order . Header level Qualifiers are sourced only for the Summary Record. Use the Line entity , if the qualifier/pricing attribute is to be used for setting a modifier of level Line or Line Group.
3. Define a validation template

Click on the button Defaulting Condition Templates

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 9

Enter a value for the condition name and description

Note Make the name reflect:


s

The source system that uses this condition: For example, ONT The pricing or qualifier context: For example, Item Context.

Navigate to Validation Rules Enter 1 in Group# In the Attribute field , choose Qualifier_context , if the entity is a qualifier or Pricing_context , for pricing attributes Validation operation is =

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 10

Enter the context name to which your segment belongs in the Value String Navigate to a new record in Validation Rules Enter 1 for Group# Choose SRC_SYSTEM_CODE for Attribute Validation Operation is = Enter the value of source system code in value strings . By default enter QP , if you are an OM customer, ASO , if you have I*Store implemented. Create Two condition names , one for source system code ASO and the other for QP , if you are an OM/I*Store customer.(*) Save the record

1.

Define Defaulting Rules

Navigate to the region Attributes in the main screen Go to Enter Query mode Query on Attribute for the qualifier/pricing attribute segment that you defined in the flex field. Say you use QUALIFIER_ATTRIBUTE31 to define a new qualifier in the flexfield Qualifier Context , query for QUALIFIER_ATTRIBUTE31 in this region. It is the value of the COLUMN in Define flexfield screen. Click on the button Defaulting Rules Navigate to Defaulting Conditions region. Enter a value for the precedence In the Defaulting Condition field choose the defaulting condition that you created in the previous step (Defaulting Condition Template) Navigate to the region Default Sourcing Rules Enter 1 in Sequence In the Source type you can choose from one of the following:

Profile Option PL/SQL API PL/SQL API Muti-Value

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 11

Constant System Variable

Source Type and Default Value Source/Value Select the defaulting source type and enter the source value. Source Type: Profile Option Profile option: Select the profile option from where you want to get the default value for this attribute. A LOV will provide a list of valid profile options. Ex. OE: Item Validation Organization Source Type: PL/SQL API Multi-Value

You can write a custom API (must be a function) that returns multiple values. The output of your function can only be a table of VARCHAR2s. Ex. To get the inventory categories for an item . The flexfield window above will popup. Please refer to the seeded sourcing for Item Categories or customer class as an example of multi-Value pl/sql API Package: Enter the PL/SQL package name. Function: Enter the function name.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 12

Source Type: Constant Constant: Enter a constant value that will always be mapped to this attribute for the given condition. Source Type: System Variable System Variable: Enter the system variable that will be mapped to the attribute for the given condition. Ex. SYSDATE Source Type: PL/SQL API

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 13

Attribute can be sourced directly from a global structure defined for the given source system. The following flexfield window will pop up. For OM all the record structures are defined in the package OE_ORDER_PUB. For example , if you want to use payment term id as the source value for the new segment that you have defined , enter G_LINE.payment_term_id in the function name. You have two record structures available. OE_ORDER_PUB.G_LINE contains all the possible values of a sales order line. OE_ORDER_PUB.G_HDR contains Fields from Order headers. Structure of the Line_rec_type and header_rec_type can be obtained from the Manufacturing Open Interface Manual. (For I*Store/OC the equivalent global structures are defined in the package ASO_PRICING_INT

Source Type: PL/SQL API You can write a custom API (must be a function that returns a single value) to get a default value if the value cannot be obtained using other source types. Ex. To get the customer class from the RA_CUSTOMERS table. The flexfield window above will popup. Package: Enter the PL/SQL package name. Function: Enter the function name.

Save the record and exit the form.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 14

6.

Setup a modifier and attach the newly created qualifier/pricing attribute For this qualifier to be sourced by OM , you need to regenerate the attribute mapping package by running the concurrent program Build Sourcing Rules

Check if the program has completed with a success This program needs to be run , whenever a qualifier is used for the first time to setup a modifier or a price list. For example , if you are using Customer Class as a qualifier for the first time in your install , you need to run this concurrent program.

Note: Please note that Pricing Build Sourcing Rules concurrent program is different from Order Managements Generate Defaulting Rules program.

6.

Enter an order in the sales order screen and check if the qualifier/pricing attribute is being sourced and has correct value by looking at the Pricing Debug screen or the Debug file generated .

Enter item, quantity in the sales order screen select Tools > Pricing Debug Navigate to Line Attributes Block Press Enter Query Enter QUALIFIER, PRODUCT, PRICING in the attribute type column, enter context and attribute (as QUALIFIER_ATTRIBUTE31 or PRICING_ATTRIBUTE31) and execute query. Examine the results. You should have the sourced value of the extended element.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 15

NOTE

1.

Current infrastructure does not allow users to change the value sets of the seeded pricing element (qualifiers, product, pricing) because subsequent pricing seed data uploaded overwrite the user changes. Hence it is recommended to define your own elements whenever the value set needs to be

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 16

changed. Also 2. 11.5.1 had a Seeded Qualifier with Context=Volume and attribute=QUALIFIER_ATTRIBUTE1 for Order Qty. This qualifier is erroneous and is no more supported. This is because Order qty can not be a simple sum of qty of all the order lines (regardless of the UOM). Please use Item_qty attribute of Pricing attribute where context = Volume

CONCLUSION

R11i Advanced Pricing has provided extremely powerful capabilities of extending the product using attributes mapping to satisfy various customer scenarios. This technical white paper has outlined the detailed steps needed to use this infrastructure. For additional information on Advanced Pricing, see the Oracle Advanced Pricing Users Guide.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 17

Appendix: An Example of Attributes Mapping

Introduction
This is an example of using Attributes Mapping for custom sourcing. The example also uses the pricing formula.

Background
Commonly in advanced pricing, there is a need to retrieve data from sources that were not set up as part of the standard installation. This document details the setup required to retrieve data using custom code into pricing for use with pricing formulae. Similar setup can be used for qualifiers however this is not documented here.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 18

Flexfield Setup
It is assumed for this section that the reader knows how to configure flexfields within Oracle Applications 11i. For custom sourcing, the flexfield against the table QP_ATTRIBUTE_DEFNS should be modified. This flexfield is actually defined twice in the system. Once as 'Qualifier Contexts' and once as 'Pricing Contexts'. For the examples in this document, we are only examining 'Pricing Contexts' Navigation Path & Responsibility:

Oracle Pricing Manager


Navigator Setup Flexfields

Please use the flexfield definitions given in Appendix A for this setup. After checking and setting up the flexfields, ensure that their definitions are frozen and that they are successfully re-compiled. It is critical that you do not overwrite existing preseeded pricing flexfield setup except where specifically needed.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 19

Set up Pricing Formulae


In order for this to work successfully, pricing formulae need to be created. These must then be attached to the relevant price list lines. Information regarding the set-up of these formulae is given in the following section.
Log into Oracle Applications under the 'Oracle Pricing Manager' responsibility. Navigate to the define pricing formulae form.

Navigator Pricing Formulas Formulas Setup


You will presented with a screen similar to the following:

Formula Header: In the tables on the following pages, the formula header tables relate to the header region of this form Formula Lines: In the tables on the following pages, the formula lines tables relate to the lines region of this form.

Enter the information exactly as given in the following tables on the following page and then save your data.

(Any fields not included in the following tables should be left as their default value or blank)
Please note, the pricing formulae are dependent on flexfield setups being completed for the pricing flexfields.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 20

Cost+25% Formula

Formula Header:

Name
Cost Plus 25 Percent

Description
Formula for retrieving cost for an item and increasing this by 25%. If cost is not found, list price is returned.

Formula
1 * NVL(2, 3)

Formula Lines: Formula Type Pricing Attribute Context


Numeric Constant Pricing Attribute List Price Pricing Attribute ITEM_COST

Pricing Attribute

Component

Step

1.25

1 2 3

Server Installation Write Custom Package


You need to write supporting code to pull data from whatever data source. As this point, you are only concerned with what data you wish to retrieve, not where it will go. Each piece of custom sourcing code you write should be grouped in a single pl/sql package for ease of maintenance. In our example, we will use a package called my_custom_sourcing. Custom sourcing is managed by writing small pl/sql stored functions. In this example, it must return a single value. This example will retrieve the cost of an item from cst_item_costs based on inventory_item_id. It is imperative that the performance of this function is tuned as this function will be called thousands of times a day. To improve performance, it is often wise to cache the most recent input and output values for the function. Copy the code given in appendix b and modify as required.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 21

Install Custom Package


to enable this pricing solution to work , you must install your custom PL/SQL package 'MY_CUSTOM_SOURCING' The new package includes custom sourcing for pricing data. Log into a SQL session on the 11I database as the apps user and execute the script in appendix b New package installed

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 22

Set Up Sourcing for Line Level pricing Attributes


For some of Oracle's pricing requirements, we need to pull additional information into pricing from areas such as flexfields, profile options and other database columns. As part of this setup, we need to define additional 'attribute mapping' to augment the pre-seeded setup supplied with the application. This extra setup tells the application where to pull values from specified sources into the pricing flexfield structures for use by the pricing engine. Multiple values can be pulled into the same flexfield attribute number by using different flexfield contexts.
Navigation Path: Pricing Manager: Navigator Setup Attribute Mapping You will now be presented with the following screen

Enter Query Mode by pressing F11. In the application field enter 'Oracle Pricing' , in the entity field enter 'Line Pricing Attrs' then press CTRL F11

You should see the following screen: (Defaulting Setup - Entity Attributes form.)

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 23

Select your Required pricing Attribute and click on 'Defaulting Rules' Note the required attributes are listed with their individual setup on the following pages.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 24

You will see a screen similar to the following: (Attribute Defaulting Rules) (This screen is the completed form for Pricing attribute20.

Defaulting Conditions Section

Default Sourcing Rules Section

Follow the setup given above for the following attributes:

Pricing Attribute20 (ONT Pricing Attributes Context) From the Defaulting Setup - Entity Attributes form, select the pricing attribute20 row. In the Defaulting Conditions Section: The row ONT Item Context should already be defaulted in. Do not modify this. Create another row with the following details:

Column Name Precedence Defaulting Condition

Value 2 ONT Pricing Attributes Context

After you have created this row, while it is still selected enter the following details on a new row in the Default Sourcing Rules Section:

Column Name

Value

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 25

Sequence Source Type

1 PL/SQL API

As you select PL/SQL API the following form will appear:

Enter the following information:

Column Name Package Name Function Name

Value MY_CUSTOM_SOURCIN G get_item_cost(oe_order_pub .g_line.inventory_item_id)

Save the record.

Build Sourcing Rules


Once sourcing setup is completed, you will need to run the concurrent program Build Sourcing Rules. This request is submitted from the standard concurrent requests screen under the pricing manager responsibility.
Navigation Path:

Pricing Manager: Navigator View Concurrent Requests Submit New Request Single Request Name: Build Sourcing Rules Parameters: None Hit Select, and ensure that the job completes successfully. Your sourcing setup is now complete.

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 26

Remember to attach your new formula as a dynamic formula to each price list line where a price is required.

Flexfield Definitions Required For This Setup


After each context is completed, it should be saved and the flexfield recompiled before continuing. This ensures that the implementation can be completed as quickly as possible. Many other flexfield contexts and segments are seeded. Following segment needs to be added in th Item Context for this example.

QP_ATTRIBUTE_DEFNS 'Pricing Contexts' - PRICING ATTRIBUTE


QP_ATTRIBUTE_DEFNS
DIS P# ATT # NAME / DESCRIPTION

CONTEXT: PRICING ATTRIBUTE


DISPLAY SIZE DISPLAY REQUIRE
D

VALUE SET

APUN

100

PRICING_ATTRIBUTE20

ITEM_COST

22

FND_NUMBER15

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice.

Page 27

My_custom_sourcing Sample Code -- Please note, the cursor cs_item_cost may need to be modified -- before use in your environment. CREATE OR REPLACE PACKAGE MY_CUSTOM_SOURCING AUTHID CURRENT_USER AS -- please see package body for version, history and notes. -- Package globals... G_Organization_id NUMBER := FND_PROFILE.VALUE('QP_ORGANIZATION_ID'); -- Cached in and out values for each sourcing routine. TYPE Item_Info_Rec_Type IS RECORD ( inventory_item_id VARCHAR2(240) , item_cost NUMBER ); G_Item_Info Item_Info_Rec_Type;

FUNCTION Get_Item_Cost (p_item_id IN NUMBER) RETURN VARCHAR2; PRAGMA RESTRICT_REFERENCES (Get_Item_Cost,WNDS); END MY_CUSTOM_SOURCING; / ------------------------------------------------CREATE OR REPLACE PACKAGE BODY MY_CUSTOM_SOURCING AS /* Package Body version 1.01 - 30th January 2001 */ -- This is the package body for Simon's example of -- Advanced pricing 11i's custom sourcing routines used for -- retrieving additional information from the

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice Page 1

apps tables into pricing -- data structures. -- Additions should only be created where a solution using -- standard functionality is not feasible. ------------------------------------------------------------ To marginally improve performance on successive pricing calls, -- we cache the most recent details from the sourcing functions -- so that the cursors are not run every time if the requests -- are the same. These cached values are stored in package-wide -- variables. ----------------------------------------------------------FUNCTION Get_Item_Cost (p_item_id IN NUMBER) RETURN VARCHAR2 IS -- Function to retrieve an item cost from cst_item_costs -- note, this returns null is a cost is not found -- so that the calling app can handle this. -- Note, Use your own cost type id from cst_cost_types. -- I've used 1 just for testing. CURSOR cs_item_cost(cp_item_id IN SELECT cic.item_cost FROM cst_item_costs cic WHERE cic.inventory_item_id AND cic.cost_type_id AND cic.organization_id G_organization_id; NUMBER) IS = cp_item_id = 1 =

v_cost cst_item_costs.item_cost%TYPE := NULL; BEGIN IF p_item_id = G_Item_Info.inventory_item_id THEN -- if the requested item is already cached then do nothing yet. NULL;

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice Page 2

ELSE -- if the requested agreement is NOT cached then retrieve -- the value from the flexfield. OPEN cs_item_cost(p_item_id); FETCH cs_item_cost INTO v_cost; CLOSE cs_item_cost; -- if we didn't get anything, default to NULL IF v_cost IS NULL THEN v_cost := NULL; END IF; -- store the data in global record. -- so that we don't have to keep reading from the tables. G_Item_Info.inventory_item_id := p_item_id; G_Item_Info.item_cost := v_cost; END IF; RETURN G_Item_Info.item_cost; EXCEPTION WHEN OTHERS THEN -- you may also wish to clear the cached item id if you hit an exception. -- In this example I don't. G_Item_Info.item_cost := NULL; RETURN G_Item_Info.item_cost; END Get_Item_Cost; END MY_CUSTOM_SOURCING; /

Oracle Corporation 2001. This Document is provided for informational purposes only and the information herein is subject to change without notice Page 3

IExtending 11i Advanced Pricing for Your Business Part 1: Using Attributes Mapping March 2001 Author: Nitin Hase Contributing Authors: Jayrama Holla, Tony Maxey, Jeff Lee, Simon Cromarty 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 2000 All Rights Reserved

You might also like