Process Order API In Order Management

 

 
TIP:  Click help for a detailed explanation of this page.
Bookmark Go to End

Subject: Process Order API In Order Management
  Doc ID: 746787.1 Type: BULLETIN
  Modified Date : 02-JUN-2009 Status: PUBLISHED

In this Document
  Purpose
  Scope and Application
  Process Order API In Order Management
     Overview of Process Order API
     Structure of PL/SQL block to call process Order API
     Process Order Usage
      CREATE Operation
      UPDATE Operation
      DELETE Operation
      Other Action Requests
     Sample Scripts
  References


 

 

Applies to:

Oracle Order Management - Version: 11.5.9 to 12.0.5
Information in this document applies to any platform.

Purpose

This note is intended to help Customer and Support Engineers get acquainted with the basics of Process Order application Interface(API) and demostrate how Process Order API can be used to manipulate Sales Order business objects owned by Order Mangement module.

Scope and Application

This note is intended for any users who tries to import an order in Order Management using Process Order API. This scope of this note is to understand and perform test case for using Process Order API.

Examples provided here work in Internal Instance. The screenshots and testing of sample insert scripts in this page were done in an 11.5.10 CU2 instance. Customers may use these examples; do confirm results on your test instance before trying them on production instance.

The examples discussed here are the most frequently used actions in the Sales Order Transactions. However for the complete list of options, please refer to user guide “Oracle Order Management -- Open Interfaces, API, & Electronic Messaging Guide(Release 11i)”.

Process Order API In Order Management

Overview of Process Order API

       Process Order API is a PL/SQL packaged procedure which can be used to manipulate the sales order data by performing Insert, update or delete operation on the following sales Order business object entities. Analogous to other public API’s(API’s available to the users), Process Order API also validates the data before inserting them into the application tables.
       Though Process Order API has packaged procedures which will insert, update, delete data into the tables, they can not be run on their own. Either they need to be called from another package procedure or can be executed as PL/SQL block via the sql*plus.

Entity Related                                          Table Name
-----------------------------                       ------------------------
Order Header                                    OE_ORDER_HEADERS_ALL
Order Price Adjustments                  OE_PRICE_ADJUSTMENTS
Order Sales Credits                          OE_SALES_CREDITS
Order Line                                         OE_ORDER_LINES_ALL
Order Pricing Attributes                    OE_ORDER_PRICE_ATTRIBS
Order Adjustment Attributes             OE_PRICE_ADJ_ATTRIBS
Order Adjustment Associations        OE_PRICE_ADJ_ASSOCS
Line Sales Credits                             OE_SALES_CREDITS
Line Price Adjustments                     OE_PRICE_ADJUSTMENTS
Line Pricing Attributes                       OE_ORDER_PRICE_ATTRIBS
Line Adjustment Attributes                OE_PRICE_ADJ_ATTRIBS
Line Adjustment Associations           OE_PRICE_ADJ_ASSOCS
Lot Serial Numbers                            OE_LOT_SERIAL_NUMBERS

 

Structure of PL/SQL block to call process Order API

DECLARE
 Variable Declaration
BEGIN
Populate the various specific API parameters
--Call to Process Order API
OE_ORDER_PUB.Process_order(
Standard Parameters


Specific Parameters);
Exception Handling
END;

Detailed explanation to each of these section is discussed as follows
 

DECLARE
/* In Variable declaration section, declare and initialize the various variables used in the pl/sql block can be done here. These entities are used to define INPUT and OUTPUT parameters to Process Order API*/
 l_header_rec OE_ORDER_PUB.Header_Rec_Type;
 l_line_rec OE_ORDER_PUB.line_rec_type;
 l_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;
 l_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type;
 l_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type;
 l_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type;
 l_Header_price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type ;
 l_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type ;
 l_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type ;
 l_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type;
 l_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type;
 l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
 l_Request_Tbl OE_ORDER_PUB.Request_Tbl_Type;
 l_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type;
 l_Line_Adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type;
 l_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type;
 l_Line_price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type ;
 l_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type ;
 l_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type ;
 l_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type;
 l_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type;
 l_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type;
 l_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type;
 l_request_rec OE_ORDER_PUB.Request_Rec_Type ;
 -- Initialize the API Version to 1.0
 p_api_version_number NUMBER :=1.0;
 x_return_status VARCHAR2(1);
BEGIN
--This sets the buffer size so that messages are written to debug file.
 dbms_output.enable(1000000);
/*****************INITIALIZE ENVIRONMENT*************************
-- fnd_global.apps_initialize(user_id,responsibility_id ,application_id);
/* Pass in user_id, responsibility_id, and application_id here, as the system would need to information while setting the who columns for updating the data in the tables. Also required to set the organization/operating unit context for the system has to see the data in views.*/
 fnd_global.apps_initialize(4096,21623,660);-- vision env variables
/*This section sets the debug level to 5 so that all messages would be written to the debug file.*/
 oe_msg_pub.initialize;
 oe_debug_pub.initialize; 
 X_DEBUG_FILE := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
 oe_debug_pub.SetDebugLevel(5);
 dbms_output.put_line('START OF NEW DEBUG');
/* The header record is initialized to missing as there would be no header_id exists for the record.Once the header_id is generated by the API, the l_header_rec will take the value of the header_id */
 l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
-- Header Attributes
 l_header_rec.order_type_id := &Order Type ID;
 l_header_rec.sold_to_org_id := &Sold To Org ID;
 l_header_rec.ship_to_org_id := &Ship To Org ID;
 l_header_rec.ship_from_org_id := &Ship From Org ID;
 l_header_rec.orig_sys_document_ref := &Document Reference;
 l_header_rec.price_list_id := &Price List ID;
 -- The statement indicates to the process order API that a new header has to be created.
 l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
 -- Setting index as 1 to indicate that these belong to 1st line record
 l_line_tbl_index := 1;
 -- Initializing the line record to missing
 l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
 -- Line Attributes
 l_line_tbl(l_line_tbl_index).inventory_item_id := &Inventory Item ID;
 l_line_tbl(l_line_tbl_index).ordered_quantity := &Ordered Quantity;
 l_line_tbl(l_line_tbl_index).orig_sys_document_ref := &Doc Ref;
 l_line_tbl(l_line_tbl_index).orig_sys_line_ref := &Line Reference;
 l_line_tbl(l_line_tbl_index).calculate_price_flag := &Calculate Price Flag;
 l_line_tbl(l_line_tbl_index).line_type_id := &Line Type ID;
 -- Indicates that this is a create operation for the line record.
 l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_CREATE;
 -- Indicates that this is an update operation for the line record.
 l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_UPDATE;
 -- Indicates that this is a delete operation for the line record.
 l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_DELETE;
 /*The below action request indicates to the process order that the order has to be booked. */
 l_action_request_tbl(1).request_type := oe_globals.g_book_order;
 l_action_request_tbl(1).entity_code := oe_globals.g_entity_header;
 -- Call To Process Order API with the required IN and OUT parameters. 
 OE_ORDER_PUB.process_order( );
 -- Get the messages generated and print them
 FOR i IN 1 .. l_msg_count
 LOOP 
  Oe_Msg_Pub.get( p_msg_index => i
   , p_encoded => Fnd_Api.G_FALSE
   , p_data => l_msg_data
   , p_msg_index_out => l_msg_index_out);
  DBMS_OUTPUT.PUT_LINE('message is: ' || l_msg_data);
  DBMS_OUTPUT.PUT_LINE('message index is: ' || l_msg_index_out);
 END LOOP;
/* Check if the process order goes through then it prints the success message, otherwise it prints failed message.*/
 IF l_return_status = FND_API.G_RET_STS_SUCCESS
 THEN
  dbms_output.put_line('Process Order Success ');
 ELSE
  dbms_output.put_line('Failed');
 END IF;
END;

 

Process Order Usage

This section is intended to help the users of the process order API in identifying the required parameters for some common operations and to give an understanding of the business flow behind each of these operations.


 CREATE Operation

In order to create new entities in order management using process_order API, it is necessary that the operation OE_GLOBALS.G_OPR_CREATE is passed alone with the necessary entity records and entity tables.

Create an Order with one line:
The following code snippet shows the various attributes required to create an order with one header and line

--Create Header record
--Initialize header record to missing
l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
-- Header Attributes
-- Required attributes (e.g. Order Type and Customer)
l_header_rec.order_type_id := &Order Type ID;
l_header_rec.sold_to_org_id := &Sold To Org ID;
-- Other Attributes
l_header_rec.transactional_curr_code :=&Trans Currency Code;
l_header_rec.pricing_date := &Pricing Date;
l_header_rec.cust_po_number := &Customer PO#;
l_header_rec.price_list_id : = &Price List ID;
l_header_rec.ordered_date := &Ordered Date;
l_header_rec.shipping_method_code := &Shipping Method Code;
l_header_rec.sold_from_org_id := &Sold from Org ID;
l_header_rec.salesrep_id := &Sales Rep ID;
l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
-- Create first line record
l_line_tbl_index := 1;
-- Initialize line record to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
-- Line attributes
-- Required Attributes Inventory Item Id, Quantity and Operation
l_line_tbl(l_line_tbl_index).inventory_item_id := &Inventory Item ID;
l_line_tbl(l_line_tbl_index).ordered_quantity := &Ordered Quantity;
l_line_tbl(l_line_tbl_index).ship_from_org_id := &Ship From Org ID;
l_line_tbl(l_line_tbl_index).subinventory := &Subinventory Code;
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_CREATE;


Adding a new line to an existing order

l_line_tbl_index := 1;
--This is to add a line to an existing order
-- Initialize record to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
-- Line attributes
-- Required Line Attributes
l_line_tbl(l_line_tbl_index).header_id := &Order Header ID;
l_line_tbl(l_line_tbl_index).ordered_quantity := &Ordered Quantity;
l_line_tbl(l_line_tbl_index).inventory_item_id := &Inventory Item ID;
-- Other line attributes
l_line_tbl(l_line_tbl_index).ship_from_org_id := &Ship from org ID;
l_line_tbl(l_line_tbl_index).subinventory := &Subinventory Code;
--Operation set to Create
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_CREATE;

IMP Note: It is not possible to insert new lines (or, process any other entity) belonging to different orders in one process order call


 UPDATE Operation

In order to update the entities in order management using process_order API, it is necessary that the operation OE_GLOBALS.G_OPR_UPDATE is passed alone with the necessary entity records and entity tables.

Cancelling an existing Order:
In order to cancel an order set the cancelled_flag to ‘Y’
The following sections describe the code required to cancel an order.

--This section is used to cancel a order
-- Initialize record to missing
l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
l_header_rec.header_id := &Order Header ID;
l_header_rec.cancelled_flag := 'Y';
l_header_rec.change_reason := 'Not provided';
l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;

Cancelling an existing Order Line:
In order to cancel an order line, set the cancelled_flag to ‘Y’
The following sections describe the code required to cancel an order line.

--This section is used to cancel an order line
l_line_tbl_index := 1;
-- Initialize record to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(l_line_tbl_index).header_id := &Order Header ID;
l_line_tbl(l_line_tbl_index).line_id := &Order Line ID;
l_line_tbl(l_line_tbl_index).ordered_quantity := &Ordered quantity;
l_line_tbl(l_line_tbl_index).cancelled_flag := 'Y';
l_line_tbl(l_line_tbl_index).change_reason := 'Not provided';
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_UPDATE;

Updating the Line Quantity:

Updates or cancels a quantity on a sales Order Line

l_line_tbl_index :=1;
-- Changed attributes
-- Initialize the line to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(l_line_tbl_index).ordered_quantity := &Ordered Quantity;
-- Primary key of the entity i.e. the order line
l_line_tbl(l_line_tbl_index).line_id := &Order Line ID;
l_line_tbl(l_line_tbl_index).change_reason := &Change Reason;


Reserve an existing order line :
Reservation can be done by providing the reserved_quantity to some non zero value.

l_line_tbl_index := 1;
-- Initialize line record to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
-- Line attributes
l_line_tbl(l_line_tbl_index).header_id := &Order Header ID;
l_line_tbl(l_line_tbl_index).line_id := &Order Line ID;
l_line_tbl(l_line_tbl_index).reserved_quantity := &Reserved Quantity;
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_UPDATE;


Unreserve a reserved order line:
Unreservation can be done by reducing reserved quantity or make reserved quantity to zero.

l_line_tbl_index := 1;
-- Initialize record to missing
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
-- Line attributes
l_line_tbl(l_line_tbl_index).header_id := &Order Header ID;
l_line_tbl(l_line_tbl_index).line_id := &Order Line ID;
l_line_tbl(l_line_tbl_index).reserved_quantity := 0;
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_UPDATE;


Splitting an Order Line:
To split an order line using Process_Order API, It is required to pass the following parameters :

l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
l_header_rec.header_id := &Order Header ID; -- header_id of the order
l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE;
l_line_tbl(1).split_by := &User ID; -- user_id
l_line_tbl(1).split_action_code := 'SPLIT';
l_line_tbl(1).header_id := &Header ID of the Order; -- header_id of the order
l_line_tbl(1).line_id := &Line ID of the Order Line; -- line_id of the order line
l_line_tbl(1).ordered_quantity := &New Ordered Qty; -- new ordered quantity
l_line_tbl(1).change_reason := 'MISC'; -- change reason code
l_line_tbl(2) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(2).operation := OE_GLOBALS.G_OPR_CREATE;
l_line_tbl(2).split_by := &User ID; -- user_id
l_line_tbl(2).split_action_code := 'SPLIT';
l_line_tbl(2).split_from_line_id := &Line ID of the Original Line; -- line_id of original line
l_line_tbl(2).inventory_item_id := &Inventory Item ID; -- inventory item id
l_line_tbl(2).ordered_quantity := &Ordered Qty; -- ordered quantity

 

 DELETE Operation

In order to delete the entity record, its necessary to pass the operation like OE_GLOBALS.G_OPR_DELETE. The only attribute which needs to be passed is either the header id or the line id depending on the whether deletion is done for the order or the line. Deletes are cascaded down to the child entities. For example to delete a header record all the child entities i.e. lines, header sales credits, header adjustments are deleted.
Deleting the lines results in the deletion of line adjustments, line sales credits and line lot serial numbers as well.
Deletes would also result in the deletion of any holds and attachments associated with the deleted entity and its child entities. The workflow status information for this entity is also purged.

Delete Order:
--This is to delete an order

l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
l_header_rec.header_id := &Order Header ID;
-- Indicate to process order that the order is to be deleted
l_header_rec.operation := OE_GLOBALS.G_OPR_DELETE;



Delete Line:
-- This is to delete an order line

l_line_tbl_index := 1;
--This is to delete an existing order line.
l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(l_line_tbl_index).header_id :=&Order Header ID;
l_line_tbl(l_line_tbl_index).line_id := &Order Line ID;
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_DELETE;


 

 Other Action Requests

Book Order:
Following are the details of the requests used to book the order

request_type --> OE_GLOBALS.G_BOOK_ORDER
Entity_code --> This should be always set to OE_GLOBALS.G_ENTITY_HEADER as booking is an order level action.
Entity_id --> Header ID of the order to be booked.

If the order is also being created in the same call to process order, then the user does not need to
provide this value.

 

l_line_tbl_index := 1;
l_action_request_tbl(l_line_tbl_index).request_type := oe_globals.g_book_order;
l_action_request_tbl(l_line_tbl_index).entity_code := oe_globals.g_entity_header;
l_action_request_tbl(l_line_tbl_index).entity_id := ;

Apply Hold:
Following are the details of the requests used to apply hold to the sales Order Header or Line depending on the parameters passed to the Process_Order .

request_type --> OE_GLOBALS.G_APPLY_HOLD
Entity_code --> OE_GLOBALS.G_ENTITY_ORDER for order or OE_GLOBALS.G_ENTITY_LINE for line.
Entity_id --> ID of the order or line to be held
Param1 --> Hold ID to identify the type of hold that should be applied. (HOLD_ID from OE_HOLD_DEFINITIONS)
Param2 --> Hold entity code for the hold source to be created.
C: Customer hold source
S: Bill To or Ship To hold source
I: Item hold source
O: Order hold source
W: Warehouse Hold Source

Param3 --> Hold entity ID
C, B, or S: for Org ID
O: Header ID
I: Inventory Item ID

param4 --> Hold comment
date_param1 --> Hold Until Date
parm6-param20 --> Attribute1-15 of the descriptive flex field associated with the hold source record.

 

--This is to create a hold on an order header
l_request_rec.entity_id := &Order Header ID;
l_request_rec.entity_code := OE_GLOBALS.G_ENTITY_HEADER;
l_request_rec.request_type := OE_GLOBALS.G_APPLY_HOLD;
-- hold_id must be passed
l_request_rec.param1 := &Hold ID;
-- indicator that it is an order hold
l_request_rec.param2 := 'O' ;
-- Header ID of the order
l_request_rec.param3 := &Order Header ID;
l_action_request_tbl(l_line_tbl_index) := l_request_rec;

 
Release Hold:
Following are the details of the requests used to release hold from the sales Order Header or Line depending on the parameters passed to the Process_Order .

request_type --> OE_GLOBALS.G_RELEASE_HOLD
Entity_code --> OE_GLOBALS.G_ENTITY_HEADER for order or OE_GLOBALS.G_ENTITY_LINE for line.
Entity_id --> ID of the order or line to be released from hold
Param1 --> Hold ID to specify the type of hold that is to be removed.
Param2 --> Hold entity code on the hold source associated with the hold to be released
C: Customer hold source
S: Bill To or Ship To hold source
I: Item hold source
O: Order hold source
W: Warehouse Hold Source

param3 --> Hold entity ID:
C or S: for Org ID
O: Header ID
I: Inventory Item ID

param4 --> Release Reason Code
param5 --> Release Comment

 

-- This is to release a hold on the order
l_request_rec.entity_id := &Order Header ID;
l_request_rec.entity_code := OE_GLOBALS.G_ENTITY_HEADER;
l_request_rec.request_type := OE_GLOBALS.G_RELEASE_HOLD;
-- hold_id must be passed
l_request_rec.param1 := &Hold ID;
-- indicator that it is an order hold
l_request_rec.param2 := 'O' ;
-- Header ID of the order
l_request_rec.param3 := &Order Header ID;
l_request_rec.param4 :='OM_APPROVE';
l_action_request_tbl(l_line_tbl_index) := l_request_rec;

 

Sample Scripts

Note 746783.1-Script to Create an order with one line
Note 746796.1-Script to add a new line to an existing order
Note 746797.1-Script to cancel an existing Order
Note 746798.1-Script to cancel an existing Order line
Note 746802.1- Script to update an existing Order line
Note 746803.1-Script to reserve order line
Note 746804.1-Script to unreserve order line
Note 746808.1-Script to splitting An Order Line
Note 746809.1-Script to delete an Order
Note 746810.1-Script to delete a Line
Note 470741.1-Script to book Order
Note 746811.1-Script to apply Hold in a sales order
Note 746812.1-Script to release Hold in a sales order
Note 292743.1-Script to create an RMA
Note 746172.1- Script to import an Order with skipped Line number
Note 745369.1- Script to update Header details using OE_ORDER_PUB For R12
Note 836332.1 - Script To Update Order Header Using OE_ORDER_PUB. Update_Header

== Additional Information ==

The processing Constraint setup has a direct influence on the way the process order API works. For e.g. The processing constraint on reducing quantity on a booked order line, will results in an error if the Update operation is attempted via the Process Order API.

References

Note 743389.1 - Order Management Testcase Repository Library

Keywords

PROCESSING~CONSTRAINTS ; WAREHOUSES ; ORDER~LINES ; RESERVE~ORDERS ; OE_ORDER_HEADERS_ALL ; WAREHOUSES ; 

Help us improve our service. Please email us your comments for this document. .
     
 
My Oracle Support (the new MetaLink)   Bookmarks   Admin   Profile   Feedback   Sign Out   Help  
 
   Headlines Knowledge Service Request Collector Patches & Updates Community Certify
   Knowledge Browser    Advanced Search    Bug Search   
 
Quick Find
All SourcesKnowledge BaseKnowledge Base (Including Archived Articles)Bug DatabaseTechnical ForumsDocument ID (Knowledge Base, Forum, or Bug)Service Request NumberError CodePatch Number
Go
      Advanced   Saved Searches
 
 
           

你可能感兴趣的:(Oracle,EBS)