The procedure uses Oe_Order_Pub.Process_Order to process sales order.
CREATE OR REPLACE
PROCEDURE xx_OM_PROC
( p_org_id IN NUMBER default 204,
p_ord_type_id IN NUMBER default 1437,
p_sold_to_org_id IN NUMBER default 1290,
p_ship_to_org_id IN NUMBER default 1425
)
is
k NUMBER;
P_USER_ID NUMBER;
P_RESP_ID NUMBER;
P_RESP_APPL_ID NUMBER;
l_org_id NUMBER;
p_price NUMBER;
--p_inv_s_id NUMBER;
p_line_type_id NUMBER;
p_order_number number;
l_responsibility_id NUMBER;
P_PRICE_U NUMBER;
x_return_status VARCHAR2(1);
x_msg_count NUMBER(20);
x_msg_data VARCHAR2(100);
l_return_status VARCHAR2 (1000);
l_msg_count NUMBER (20);
l_msg_data VARCHAR2 (1000);
l_msg_index_out NUMBER(10);
l_Header_Rec_Type oe_order_pub.Header_Rec_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_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_action_request_tbl oe_order_pub.Request_Tbl_Type ;
l_line_rec oe_order_pub.Line_Rec_Type;
--------------output----------------------
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;
begin
l_header_val_rec := oe_order_pub.G_MISS_HEADER_VAL_REC;
l_Header_Adj_tbl :=oe_order_pub.G_MISS_HEADER_ADJ_TBL;
l_Header_Adj_val_tbl :=oe_order_pub.G_MISS_HEADER_ADJ_VAL_TBL;
l_Header_price_Att_tbl :=oe_order_pub.G_MISS_HEADER_PRICE_ATT_TBL;
l_Header_Adj_Att_tbl :=oe_order_pub.G_MISS_HEADER_ADJ_ATT_TBL;
l_Header_Adj_Assoc_tbl :=oe_order_pub.G_MISS_HEADER_ADJ_ASSOC_TBL;
l_Header_Scredit_tbl :=oe_order_pub.G_MISS_HEADER_SCREDIT_TBL;
l_Header_Scredit_val_tbl :=oe_order_pub.G_MISS_HEADER_SCREDIT_VAL_TBL;
l_line_val_tbl :=oe_order_pub.G_MISS_LINE_VAL_TBL;
l_Line_Adj_tbl :=oe_order_pub.G_MISS_LINE_ADJ_TBL;
l_Line_Adj_val_tbl :=oe_order_pub.G_MISS_LINE_ADJ_VAL_TBL;
l_Line_price_Att_tbl :=oe_order_pub.G_MISS_LINE_PRICE_ATT_TBL;
l_Line_Adj_Att_tbl :=oe_order_pub.G_MISS_LINE_ADJ_ATT_TBL;
l_Line_Adj_Assoc_tbl :=oe_order_pub.G_MISS_LINE_ADJ_ASSOC_TBL;
l_Line_Scredit_tbl :=oe_order_pub.G_MISS_LINE_SCREDIT_TBL;
l_Line_Scredit_val_tbl :=oe_order_pub.G_MISS_LINE_SCREDIT_VAL_TBL;
l_Lot_Serial_tbl :=oe_order_pub.G_MISS_LOT_SERIAL_TBL;
l_Lot_Serial_val_tbl :=oe_order_pub.G_MISS_LOT_SERIAL_VAL_TBL;
l_action_request_tbl := oe_order_pub.G_MISS_REQUEST_TBL ;
l_return_status := null;
l_msg_count := 0;
l_msg_data := null;
l_msg_index_out := 0;
x_msg_count :=0;
x_msg_data :=null;
SELECT fnd_global.USER_ID,fnd_global.RESP_APPL_ID,fnd_global.RESP_ID
INTO P_USER_ID,P_RESP_APPL_ID,P_RESP_ID FROM dual;
P_USER_ID:=xx;
P_RESP_APPL_ID:=xx;
P_RESP_ID:= xx;
DBMS_OUTPUT.put_line( 'USER ID : '||P_USER_ID);
DBMS_OUTPUT.put_line( 'RESP APPL ID : '||P_RESP_APPL_ID);
DBMS_OUTPUT.put_line( 'RESP ID : '||P_RESP_ID);
l_responsibility_id:= P_RESP_ID;
DBMS_OUTPUT.put_line( 'AFTER FINDING RESPONSIBILITY ID ... ' || l_responsibility_id);
l_org_id:= p_org_id;
--apps.mo_global.set_org_context(7269,null,'ONT');
FND_GLOBAL.APPS_INITIALIZE(xx);
fnd_client_info.set_org_context(l_org_id);
SELECT DISTINCT
PRICE_LIST_ID,
--INVOICE_SOURCE_ID,
DEFAULT_OUTBOUND_LINE_TYPE_ID
INTO p_price,
--p_inv_s_id,
p_line_type_id
FROM apps.oe_transaction_types_all
WHERE TRANSACTION_TYPE_ID = 1437;
select FND_DOC_SEQ_624_S.nextval into p_order_number from dual ;
DBMS_OUTPUT.put_line( 'PRICE LIST ID : ' || p_price);
--DBMS_OUTPUT.put_line( 'INVOICE_SOURCE_ID : ' || p_inv_s_id);
DBMS_OUTPUT.put_line( 'LINE_TYPE_ID : ' || p_line_type_id);
DBMS_OUTPUT.put_line( 'p_order_number : ' || p_order_number);
l_line_tbl := OE_ORDER_PUB.G_MISS_LINE_TBL;
l_Header_Rec_Type := OE_ORDER_PUB.G_MISS_HEADER_REC;
l_Header_Rec_Type.order_type_id := P_ORD_TYPE_ID;
l_Header_Rec_Type.sold_to_org_id := p_sold_to_org_id;
l_Header_Rec_Type.ship_to_org_id := p_ship_to_org_id;
l_Header_Rec_Type.sold_from_org_id := 204;
l_Header_Rec_Type.ship_from_org_id := 207;
l_Header_Rec_Type.salesrep_id := -3;
l_Header_Rec_Type.Minisite_Id :=null;
l_Header_Rec_Type.booked_date :=sysdate;
l_Header_Rec_Type.booked_flag := 'N';
l_header_rec_type.open_flag:='Y';
l_header_rec_type.cancelled_flag:='N';
l_Header_Rec_Type.flow_status_code := 'ENTERED';
l_Header_Rec_Type.booked_date := null;
l_Header_Rec_Type.order_number := p_order_number;
l_Header_Rec_Type.payment_term_id := 4;
l_Header_Rec_Type.transactional_curr_code := 'USD';
l_Header_Rec_Type.price_list_id := P_PRICE;
l_Header_Rec_Type.order_source_id := 0;
l_Header_Rec_Type.org_id := l_org_id;
l_Header_Rec_Type.ordered_date :=SYSDATE;
l_Header_Rec_Type.pricing_date := SYSDATE;
l_Header_Rec_Type.order_category_code := 'MIXED';
l_Header_Rec_Type.operation := OE_GLOBALS.G_OPR_CREATE;
--l_header_val_rec.order_type:='Mixed';
l_header_rec_type.attribute15 := sysdate;
l_Header_Rec_type.created_by := fnd_global.user_id;
l_Header_Rec_type.creation_date:=sysdate;
l_Header_Rec_type.price_list_id :=1000;
l_Header_Rec_type.freight_terms_code := NULL;
l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_Tbl(1).Operation := OE_GLOBALS.G_OPR_CREATE;
l_line_tbl(1).inventory_item_id := 149;
l_line_tbl(1).ordered_item := 'AS54888';
l_line_tbl(1).ordered_item_id := 149;
l_line_tbl(1).sold_from_org_id := 204;
l_line_tbl(1).ship_from_org_id := 207;
l_line_tbl(1).ordered_quantity := 5;
l_line_tbl(1).order_quantity_uom := 'Ea';
l_line_tbl(1).orig_sys_document_ref := 'OE_ORDER_HEADERS_ALL95723';
l_line_tbl(1).orig_sys_line_ref := 'OE_ORDER_LINES_ALL196892';
l_line_tbl(1).payment_term_id := 4;
l_line_tbl(1).price_list_id := p_price;
l_line_tbl(1).UNIT_SELLING_PRICE := 1470;
l_line_tbl(1).UNIT_LIST_PRICE := 1470;
l_line_tbl(1).calculate_price_flag := 'Y';
l_line_tbl(1).line_type_id := P_LINE_TYPE_ID;
l_line_tbl(1).schedule_ship_date := SYSDATE;
l_line_tbl(1).request_date := SYSDATE;
l_line_tbl(1).booked_flag := 'N';
l_line_tbl(1).delivery_lead_time :=0;
l_line_tbl(1).schedule_arrival_date := sysdate;
l_line_tbl(1).schedule_status_code := 'SCHEDULED';
l_line_tbl(1).lock_control := 2;
l_line_tbl(1).re_source_flag := 'N';
l_line_tbl(1).visible_demand_flag := 'Y';
l_line_tbl(1).shipping_interfaced_flag := 'N';
l_line_tbl(1).dep_plan_required_flag := null;
l_line_tbl(1).flow_status_code := 'ENTERED';
l_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
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_Type,
p_old_header_rec => l_Header_Rec_Type,
p_header_val_rec => l_header_val_rec,
p_old_header_val_rec => l_header_val_rec,
p_Header_Adj_tbl => l_Header_Adj_tbl,
p_old_Header_Adj_tbl => l_Header_Adj_tbl,
p_Header_Adj_val_tbl => l_Header_Adj_val_tbl ,
p_old_Header_Adj_val_tbl => l_Header_Adj_val_tbl,
p_Header_price_Att_tbl => l_Header_price_Att_tbl ,
p_old_Header_Price_Att_tbl => l_Header_price_Att_tbl ,
p_Header_Adj_Att_tbl => l_Header_Adj_Att_tbl,
p_old_Header_Adj_Att_tbl => l_Header_Adj_Att_tbl ,
p_Header_Adj_Assoc_tbl => l_Header_Adj_Assoc_tbl ,
p_old_Header_Adj_Assoc_tbl => l_Header_Adj_Assoc_tbl ,
p_Header_Scredit_tbl => l_Header_Scredit_tbl ,
p_old_Header_Scredit_tbl => l_Header_Scredit_tbl ,
p_Header_Scredit_val_tbl => l_Header_Scredit_val_tbl ,
p_old_Header_Scredit_val_tbl => l_Header_Scredit_val_tbl ,
p_line_tbl => l_line_tbl,
p_old_line_tbl => l_line_tbl,
p_line_val_tbl => l_line_val_tbl,
p_old_line_val_tbl => l_line_val_tbl,
p_Line_Adj_tbl => l_Line_Adj_tbl ,
p_old_Line_Adj_tbl => l_Line_Adj_tbl,
p_Line_Adj_val_tbl => l_Line_Adj_val_tbl ,
p_old_Line_Adj_val_tbl => l_Line_Adj_val_tbl,
p_Line_price_Att_tbl => l_Line_price_Att_tbl,
p_old_Line_Price_Att_tbl => l_Line_price_Att_tbl ,
p_Line_Adj_Att_tbl => l_Line_Adj_Att_tbl ,
p_old_Line_Adj_Att_tbl => l_Line_Adj_Att_tbl ,
p_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl ,
p_old_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl,
p_Line_Scredit_tbl => l_Line_Scredit_tbl,
p_old_Line_Scredit_tbl => l_Line_Scredit_tbl,
p_Line_Scredit_val_tbl => l_Line_Scredit_val_tbl ,
p_old_Line_Scredit_val_tbl => l_Line_Scredit_val_tbl,
p_Lot_Serial_tbl => l_Lot_Serial_tbl ,
p_old_Lot_Serial_tbl => l_Lot_Serial_tbl,
p_Lot_Serial_val_tbl => l_Lot_Serial_val_tbl,
p_old_Lot_Serial_val_tbl => l_Lot_Serial_val_tbl,
p_action_request_tbl => l_action_request_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,
p_rtrim_data => 'N'
--p_validate_desc_flex => 'Y'
);
DBMS_OUTPUT.put_line( 'x_return_status : ' || L_return_status);
DBMS_OUTPUT.put_line( 'x_header_id : ' || x_header_rec.header_id);
DBMS_OUTPUT.put_line( 'x_msg_count : ' || L_msg_count);
DBMS_OUTPUT.put_line(OE_CODE_CONTROL.Code_Release_Level);
DBMS_OUTPUT.put_line(l_return_status);
IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
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( l_msg_data);
END LOOP;
END IF;
IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
IF l_msg_count > 0 THEN
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( l_msg_data);
END LOOP;
END IF;
DBMS_OUTPUT.put_line( 'PROCEDURE COMPLETED SUCCESFULLY ...');
COMMIT;
END IF;
DBMS_OUTPUT.put_line( 'AFTER COMMITING ORDER API ... ');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.put_line( 'EXCEPTION : NO DATA FOUND!');
RETURN;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.put_line( 'EXCEPTION : TOO MANY ROWS!');
RETURN;
WHEN OTHERS THEN
DBMS_OUTPUT.put_line( 'EXCEPTION : ERROR!'||SQLERRM||SQLCODE);
RETURN;
end xx_OM_PROC ;
/