Вы находитесь на странице: 1из 9

http://jyotioraapps.blogspot.com/2009/08/use-of-oeorderpubprocessorder-to-create.

html
http://proracleapps.blogspot.com/2012/05/process-order-api-in-oracle-to-create.html
http://krishnareddyoracleapps.blogspot.com/2012/07/oracle-apps-order-management-omprocess.html
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;

The below script is used to create a an order with one line.


set serveroutput on
DECLARE
l_header_rec OE_ORDER_PUB.Header_Rec_Type;
l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
l_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;
l_header_adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type;
l_line_adj_tbl OE_ORDER_PUB.line_adj_tbl_Type;
l_header_scr_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type;
l_line_scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type;
l_request_rec OE_ORDER_PUB.Request_Rec_Type ;
l_return_status VARCHAR2(1000);
l_msg_count NUMBER;
l_msg_data VARCHAR2(1000);
p_api_version_number NUMBER :=1.0;
p_init_msg_list VARCHAR2(10) := FND_API.G_FALSE;
p_return_values VARCHAR2(10) := FND_API.G_FALSE;
p_action_commit VARCHAR2(10) := FND_API.G_FALSE;

x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(100);
p_header_rec OE_ORDER_PUB.Header_Rec_Type := OE_ORDER_PUB.G_MISS_HEADER_REC;
p_old_header_rec OE_ORDER_PUB.Header_Rec_Type := OE_ORDER_PUB.G_MISS_HEADER_REC;
p_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type := OE_ORDER_PUB.G_MISS_HEADER_VAL_REC;
p_old_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type := OE_ORDER_PUB.G_MISS_HEADER_VAL_REC;
p_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type := OE_ORDER_PUB.G_MISS_HEADER_ADJ_TBL;
p_old_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type := OE_ORDER_PUB.G_MISS_HEADER_ADJ_TBL;
p_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_VAL_TBL;
p_old_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_VAL_TBL;
p_Header_price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_PRICE_ATT_TBL;
p_old_Header_Price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_PRICE_ATT_TBL;
p_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_ATT_TBL;
p_old_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_ATT_TBL;
p_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL;
p_old_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL;
p_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_SCREDIT_TBL;
p_old_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_SCREDIT_TBL;
p_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_SCREDIT_VAL_TBL;
p_old_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_HEADER_SCREDIT_VAL_TBL;
p_line_tbl OE_ORDER_PUB.Line_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_TBL;
p_old_line_tbl OE_ORDER_PUB.Line_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_TBL;
p_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_VAL_TBL;
p_old_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_VAL_TBL;
p_Line_Adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_ADJ_TBL;
p_old_Line_Adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type := OE_ORDER_PUB.G_MISS_LINE_ADJ_TBL;
p_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_VAL_TBL;
p_old_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_VAL_TBL;
p_Line_price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_PRICE_ATT_TBL;
p_old_Line_Price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_PRICE_ATT_TBL;
p_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_ATT_TBL;
p_old_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_ATT_TBL;
p_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_TBL;
p_old_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_TBL;
p_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_SCREDIT_TBL;
p_old_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_SCREDIT_TBL;
p_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_SCREDIT_VAL_TBL;
p_old_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LINE_SCREDIT_VAL_TBL;
p_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type := OE_ORDER_PUB.G_MISS_LOT_SERIAL_TBL;
p_old_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type := OE_ORDER_PUB.G_MISS_LOT_SERIAL_TBL;

p_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LOT_SERIAL_VAL_TBL;
p_old_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type :=
OE_ORDER_PUB.G_MISS_LOT_SERIAL_VAL_TBL;
p_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type := OE_ORDER_PUB.G_MISS_REQUEST_TBL;
x_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type;
x_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type;
x_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type;
x_Header_price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type;
x_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type;
x_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type;
x_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type;
x_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type;
x_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type;
x_Line_Adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type;
x_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type;
x_Line_price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type;
x_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type;
x_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type;
x_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type;
x_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type;
x_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type;
x_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type;
x_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;
X_DEBUG_FILE VARCHAR2(100);
l_line_tbl_index NUMBER;
l_msg_index_out NUMBER(10);
BEGIN
dbms_output.enable(1000000);
fnd_global.apps_initialize(1318,21623,660); -- pass in user_id, responsibility_id, and
application_id
MO_GLOBAL.INIT('ONT'); -- Required for R12
MO_GLOBAL.SET_POLICY_CONTEXT('S', 204); -- Required for R12
oe_msg_pub.initialize;
oe_debug_pub.initialize;
X_DEBUG_FILE := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
oe_debug_pub.SetDebugLevel(5); -- Use 5 for the most debuging output, I warn you its a lot of
data
dbms_output.put_line('START OF NEW DEBUG');
--This is to CREATE an order header and an order line
--Create Header record
--Initialize header record to missing
l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
l_header_rec.TRANSACTIONAL_CURR_CODE := 'USD';
l_header_rec.pricing_date := SYSDATE;
l_header_rec.cust_po_number := 'Test123';
l_header_rec.sold_to_org_id := 1005;
l_header_rec.price_list_id := 1000;
l_header_rec.ordered_date := SYSDATE;
l_header_rec.shipping_method_code := 'DHL';
l_header_rec.sold_from_org_id := 204;
l_header_rec.salesrep_id := -3;
l_header_rec.order_type_id := 1437;
l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
l_line_tbl_index :=1;
-- FIRST LINE RECORD
-- 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).inventory_item_id := 149;
l_line_tbl(l_line_tbl_index).ordered_quantity := 1;
l_line_tbl(l_line_tbl_index).ship_from_org_id := 207;
l_line_tbl(l_line_tbl_index).subinventory := 'FGI';
l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_CREATE;
-- CALL TO PROCESS ORDER Check the return status and then commit.
OE_ORDER_PUB.process_order (
p_api_version_number => 1.0

,
,
,
,
,
,
,
,
,

p_init_msg_list => fnd_api.g_false


p_return_values => fnd_api.g_false
p_action_commit => fnd_api.g_false
x_return_status => l_return_status
x_msg_count => l_msg_count
x_msg_data => l_msg_data
p_header_rec => l_header_rec
p_line_tbl => l_line_tbl
p_action_request_tbl => l_action_request_tbl
-- OUT PARAMETERS
, x_header_rec => l_header_rec
, x_header_val_rec => x_header_val_rec
, x_Header_Adj_tbl => x_Header_Adj_tbl
, x_Header_Adj_val_tbl => x_Header_Adj_val_tbl
, x_Header_price_Att_tbl => x_Header_price_Att_tbl
, x_Header_Adj_Att_tbl => x_Header_Adj_Att_tbl
, x_Header_Adj_Assoc_tbl => x_Header_Adj_Assoc_tbl
, x_Header_Scredit_tbl => x_Header_Scredit_tbl
, x_Header_Scredit_val_tbl => x_Header_Scredit_val_tbl
, x_line_tbl => l_line_tbl
, x_line_val_tbl => x_line_val_tbl
, x_Line_Adj_tbl => x_Line_Adj_tbl
, x_Line_Adj_val_tbl => x_Line_Adj_val_tbl
, x_Line_price_Att_tbl => x_Line_price_Att_tbl
, x_Line_Adj_Att_tbl => x_Line_Adj_Att_tbl
, x_Line_Adj_Assoc_tbl => x_Line_Adj_Assoc_tbl
, x_Line_Scredit_tbl => x_Line_Scredit_tbl
, x_Line_Scredit_val_tbl => x_Line_Scredit_val_tbl
, x_Lot_Serial_tbl => x_Lot_Serial_tbl
, x_Lot_Serial_val_tbl => x_Lot_Serial_val_tbl
, x_action_request_tbl => l_action_request_tbl
);
dbms_output.put_line('OM Debug file: ' ||oe_debug_pub.G_DIR||'/'||oe_debug_pub.G_FILE);
-- Retrieve messages
FOR i IN 1 .. l_msg_count
LOOP
fnd_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 the return status
IF l_return_status = FND_API.G_RET_STS_SUCCESS
THEN
dbms_output.put_line('Process Order Sucess');
ELSE
dbms_output.put_line('Failed');
END IF;
END;
/
Commit;

a script to add a line to the existing order using Process Order API

set serveroutput on size 1000000


Declare
/* Initialize the proper Context */

l_org_id NUMBER := 204;


l_application_id NUMBER := 660;
/* PQD12MS1 */
-- l_responsibility_id NUMBER := 21623;
-- l_user_id NUMBER := 1318;
/* MZ4Md211 */
l_responsibility_id NUMBER := 21623;
l_user_id NUMBER := 1318;
/* Initialize the record to G_MISS to enable defaulting */
l_header_rec OE_ORDER_PUB.Header_Rec_Type :=
OE_ORDER_PUB.G_MISS_HEADER_REC;
l_old_header_rec OE_ORDER_PUB.Header_Rec_Type;
l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
l_old_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
l_action_request_tbl

OE_ORDER_PUB.Request_Tbl_Type;

x_header_rec OE_ORDER_PUB.Header_Rec_Type;
x_header_val_rec
OE_ORDER_PUB.Header_Val_Rec_Type;
x_Header_Adj_tbl
OE_ORDER_PUB.Header_Adj_Tbl_Type;
x_Header_Adj_val_tbl
OE_ORDER_PUB.Header_Adj_Val_Tbl_Type;
x_Header_price_Att_tbl
OE_ORDER_PUB.Header_Price_Att_Tbl_Type;
x_Header_Adj_Att_tbl
OE_ORDER_PUB.Header_Adj_Att_Tbl_Type;
x_Header_Adj_Assoc_tbl
OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type;
x_Header_Scredit_tbl
OE_ORDER_PUB.Header_Scredit_Tbl_Type;
x_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type;
x_line_tbl
OE_ORDER_PUB.Line_Tbl_Type;
x_line_val_tbl
OE_ORDER_PUB.Line_Val_Tbl_Type;
x_Line_Adj_tbl
OE_ORDER_PUB.Line_Adj_Tbl_Type;
x_Line_Adj_val_tbl
OE_ORDER_PUB.Line_Adj_Val_Tbl_Type;
x_Line_price_Att_tbl
OE_ORDER_PUB.Line_Price_Att_Tbl_Type;
x_Line_Adj_Att_tbl
OE_ORDER_PUB.Line_Adj_Att_Tbl_Type;
x_Line_Adj_Assoc_tbl
OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type;
x_Line_Scredit_tbl
OE_ORDER_PUB.Line_Scredit_Tbl_Type;
x_Line_Scredit_val_tbl
OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type;
x_Lot_Serial_tbl
OE_ORDER_PUB.Lot_Serial_Tbl_Type;
x_Lot_Serial_val_tbl
OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type;
x_action_request_tbl
OE_ORDER_PUB.Request_Tbl_Type;
l_return_status VARCHAR2(2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);

l_line_cnt number := 0;
l_top_model_line_index number;
l_link_to_line_index number;
l_msg_index_out number(10);
Begin
/* Turn on DBMS Output */
dbms_output.enable(1000000);
/* Set the appropriate context */
/* For 11i */
-- fnd_global.apps_initialize(l_user_id, l_responsibility_id, l_application_id);
-- fnd_client_info.set_org_context(to_char(l_org_id));
/* For R12 */
fnd_global.apps_initialize(l_user_id, l_responsibility_id, l_application_id, NULL);
mo_global.init('ONT');
mo_global.set_policy_context('S',204);
/* Turn on OM Debug */
oe_debug_pub.G_FILE := NULL;
oe_debug_pub.debug_on;
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(5);
dbms_output.put_line('Debug File : '|| OE_DEBUG_PUB.Set_Debug_Mode('FILE'));

/* Populate the required Header Fields */


--l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
--l_header_rec.sold_to_org_id := 1006;

/* Populate the Actions Table for Header */


-- l_action_request_tbl(1).request_type := OE_GLOBALS.G_BOOK_ORDER;
--l_action_request_tbl(1).entity_code := OE_GLOBALS.G_ENTITY_HEADER;

/* Populate the required Line Fields */


/* Standard Items */
l_line_cnt := l_line_cnt + 1;
l_line_tbl(l_line_cnt)
:= OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(l_line_cnt).operation := OE_GLOBALS.G_OPR_CREATE;
l_line_tbl(l_line_cnt).header_id := 187415;
l_line_tbl(l_line_cnt).item_type_code := 'STANDARD';
l_line_tbl(l_line_cnt).inventory_item_id := 149;

l_line_tbl(l_line_cnt).ordered_quantity := 2;
/* Call the Process Order API with Header Rec and Line Tbl */
OE_ORDER_PUB.Process_Order
(
p_api_version_number => 1,
p_org_id => l_org_id, -- For R12
p_init_msg_list
=> FND_API.G_TRUE,
p_return_values
=> FND_API.G_TRUE,
p_action_commit
=> FND_API.G_TRUE,
x_return_status
=> l_return_status,
x_msg_count
=> l_msg_count,
x_msg_data
=> l_msg_data,
p_action_request_tbl => l_action_request_tbl,
p_header_rec
=> l_header_rec,
p_old_header_rec
=> l_old_header_rec,
p_line_tbl => l_line_tbl,
p_old_line_tbl => l_old_line_tbl,
x_header_rec
=> x_header_rec,
x_header_val_rec
=> x_header_val_rec,
x_Header_Adj_tbl
=> x_Header_Adj_tbl,
x_Header_Adj_val_tbl => x_Header_Adj_val_tbl,
x_Header_price_Att_tbl => x_Header_Price_Att_Tbl,
x_Header_Adj_Att_tbl => x_Header_Adj_Att_Tbl,
x_Header_Adj_Assoc_tbl => x_Header_Adj_Assoc_Tbl,
x_Header_Scredit_tbl => x_Header_Scredit_Tbl,
x_Header_Scredit_val_tbl=> x_Header_Scredit_Val_Tbl,
x_line_tbl
=> x_Line_Tbl,
x_line_val_tbl
=> x_Line_Val_Tbl,
x_Line_Adj_tbl
=> x_Line_Adj_Tbl,
x_Line_Adj_val_tbl
=> x_Line_Adj_Val_Tbl,
x_Line_price_Att_tbl => x_Line_Price_Att_Tbl,
x_Line_Adj_Att_tbl
=> x_Line_Adj_Att_Tbl,
x_Line_Adj_Assoc_tbl => x_Line_Adj_Assoc_Tbl,
x_Line_Scredit_tbl
=> x_Line_Scredit_Tbl,
x_Line_Scredit_val_tbl => x_Line_Scredit_Val_Tbl,
x_Lot_Serial_tbl
=> x_Lot_Serial_Tbl,
x_Lot_Serial_val_tbl => x_Lot_Serial_Val_Tbl,
x_action_request_tbl => x_action_request_tbl
);
/*
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;
*/
/* Display the status and Order Number if successfully created */
if l_return_status = 'S' then
dbms_output.put_line('CONGRATULATIONS! New Order created successfully!');
dbms_output.put_line('New Order Number : ' || x_header_rec.order_number || ';
New Header Id : ' || x_header_rec.header_id);
dbms_output.put_line('Commit Issued ... !');
commit;
else
dbms_output.put_line('Hard Luck! Error(s) while creating Order.');
dbms_output.put_line(l_msg_count || ';' || l_msg_data);
end if;

/* Turn off OM Debug */


oe_debug_pub.debug_off;
End;
/

Вам также может понравиться