Oracle EBS Release 12 create Order API from Order Management Responsibility sample procedure.
PROCEDURE cust_create_order (inq_id NUMBER)
IS
l_api_version_number NUMBER := 1;
l_return_status VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
/*****************PARAMETERS****************************************/
l_debug_level NUMBER := 1;
-- OM DEBUG LEVEL (MAX 5)
l_org NUMBER := 101;
-- OPERATING UNIT
l_no_orders NUMBER := 1;
-- NO OF ORDERS
l_user NUMBER := 1110;
-- USER
l_resp NUMBER := 51330;
-- RESPONSIBLILTY
l_appl NUMBER := 660;
-- ORDER MANAGEMENT
/*************************INPUT VARIABLES FOR PROCESS_ORDER API****************************/
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_line_adj_tbl oe_order_pub.line_adj_tbl_type;
/****************************OUT VARIABLES FOR PROCESS_ORDER API**************************/
l_header_rec_out oe_order_pub.header_rec_type;
l_header_val_rec_out oe_order_pub.header_val_rec_type;
l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
l_line_tbl_out oe_order_pub.line_tbl_type;
l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
l_action_request_tbl_out oe_order_pub.request_tbl_type;
l_msg_index NUMBER;
l_data VARCHAR2 (2000);
l_loop_count NUMBER;
l_debug_file VARCHAR2 (200);
b_return_status VARCHAR2 (200);
b_msg_count NUMBER;
b_msg_data VARCHAR2 (2000);
l_etd_date DATE;
l_qty NUMBER;
l_line_no NUMBER;
l_line_tbl_index NUMBER;
order_typ NUMBER;
cust_id NUMBER;
poc_num NUMBER;
org_id NUMBER;
mfg_org_id NUMBER;
pay_term_id NUMBER;
from_size VARCHAR2 (20);
to_size VARCHAR2 (20);
header_id NUMBER;
order_num NUMBER;
Line_num NUMBER;
BEGIN
DBMS_APPLICATION_INFO.set_client_info (l_org);
mo_global.set_policy_context ('S', l_org);
mo_global.init ('ONT');
/**************************INITIALIZE DEBUG INFO**********************************/
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
oe_msg_pub.initialize;
END IF;
/****************************INITIALIZE ENVIRONMENT*******************************/
fnd_global.apps_initialize (l_user, l_resp, l_appl);
-- pass in user_id, responsibility_id, and application_id
/*****************INITIALIZE HEADER RECORD*************************/
l_header_rec := oe_order_pub.g_miss_header_rec;
/***********POPULATE REQUIRED ATTRIBUTES ************************/
SELECT cuoi.customer_id, cuoi.inquiry_number, cuoi.org_id,
cuoi.payment_term_id, cuoi.from_size, cuoi.to_size
INTO cust_id, poc_num, org_id,
pay_term_id, from_size, to_size
FROM cust_usg_ont_inquiry cuoi
WHERE cuoi.inquiry_id = inq_id;
SELECT ood.organization_id
INTO mfg_org_id
FROM org_organization_definitions ood
WHERE ood.operating_unit = org_id AND ood.organization_code <> 'IMO';
SELECT hcsu.order_type_id
INTO order_typ
FROM hz_parties hp,
hz_party_sites hps,
hz_locations hl,
hz_cust_accounts_all hca,
hz_cust_acct_sites_all hcsa,
hz_cust_site_uses_all hcsu
WHERE hp.party_id = hps.party_id
AND hps.location_id = hl.location_id
AND hp.party_id = hca.party_id
AND hcsa.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcsa.cust_acct_site_id
AND hca.cust_account_id = hcsa.cust_account_id
AND hca.cust_account_id = cust_id
and hcsa.ORG_ID = l_org
AND hcsu.site_use_code = 'BILL_TO';
l_header_rec.order_type_id := order_typ;
l_header_rec.sold_to_org_id := cust_id;
-- l_header_rec.ship_to_org_id := 1457;
l_header_rec.ship_from_org_id := mfg_org_id;
l_header_rec.orig_sys_document_ref := poc_num;
l_header_rec.payment_term_id := pay_term_id;
l_header_rec.global_attribute6 := inq_id;
l_header_rec.global_attribute7 := from_size;
l_header_rec.global_attribute8 := to_size;
l_header_rec.global_attribute9 := poc_num;
l_header_rec.ORDER_SOURCE_ID := 1001;
/**********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;
l_line_tbl_index := 0;
/**************************************CALLTO PROCESS ORDER API**********************************************/
oe_order_pub.process_order
(p_api_version_number => l_api_version_number,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
p_line_adj_tbl => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
,
x_header_rec => l_header_rec_out,
x_header_val_rec => l_header_val_rec_out,
x_header_adj_tbl => l_header_adj_tbl_out,
x_header_adj_val_tbl => l_header_adj_val_tbl_out,
x_header_price_att_tbl => l_header_price_att_tbl_out,
x_header_adj_att_tbl => l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out,
x_header_scredit_tbl => l_header_scredit_tbl_out,
x_header_scredit_val_tbl => l_header_scredit_val_tbl_out,
x_line_tbl => l_line_tbl_out,
x_line_val_tbl => l_line_val_tbl_out,
x_line_adj_tbl => l_line_adj_tbl_out,
x_line_adj_val_tbl => l_line_adj_val_tbl_out,
x_line_price_att_tbl => l_line_price_att_tbl_out,
x_line_adj_att_tbl => l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out,
x_line_scredit_tbl => l_line_scredit_tbl_out,
x_line_scredit_val_tbl => l_line_scredit_val_tbl_out,
x_lot_serial_tbl => l_lot_serial_tbl_out,
x_lot_serial_val_tbl => l_lot_serial_val_tbl_out,
x_action_request_tbl => l_action_request_tbl_out,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
header_id := l_header_rec_out.header_id;
order_num := l_header_rec_out.order_number;
line_num := 0;
l_header_rec.operation := oe_globals.g_opr_update;
l_header_rec.header_id := header_id;
FOR i IN (SELECT nvl(cope.quantity,cuoi.INQUIRY_QTY) qty, cuop.final_offer price,
cuoi.inquiry_number inqnum , nvl(cope.ETD, cuoi.EXPECT_SHIP_DATE ) etd
FROM cust_ont_poc_etd cope,
cust_usg_ont_inquiry cuoi,
cust_usg_ont_pcosting cuop
WHERE cope.inquiry_id = cuoi.inquiry_id
AND cuoi.inquiry_id = cuop.inquiry_id
AND cope.inquiry_id = inq_id)
LOOP
line_num := line_num+1;
l_line_tbl_index := l_line_tbl_index + 1;
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 := 11927;
l_line_tbl (l_line_tbl_index).ordered_quantity := i.qty;
l_line_tbl (l_line_tbl_index).SCHEDULE_SHIP_DATE := i.etd ;
l_line_tbl (l_line_tbl_index).orig_sys_document_ref := i.inqnum;
l_line_tbl (l_line_tbl_index).user_item_description := order_num||'/'||line_num||'.1';
--l_line_tbl (l_line_tbl_index).attribute3 := 20;
--l_line_tbl (l_line_tbl_index).attribute3 := 'Mohsin';
l_line_tbl (l_line_tbl_index).unit_list_price := i.price;
l_line_tbl (l_line_tbl_index).unit_selling_price := i.price;
/**********************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 (l_line_tbl_index).entity_code :=
oe_globals.g_entity_header;
END LOOP;
oe_order_pub.process_order
(p_api_version_number => l_api_version_number,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
p_line_adj_tbl => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
,
x_header_rec => l_header_rec_out,
x_header_val_rec => l_header_val_rec_out,
x_header_adj_tbl => l_header_adj_tbl_out,
x_header_adj_val_tbl => l_header_adj_val_tbl_out,
x_header_price_att_tbl => l_header_price_att_tbl_out,
x_header_adj_att_tbl => l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out,
x_header_scredit_tbl => l_header_scredit_tbl_out,
x_header_scredit_val_tbl => l_header_scredit_val_tbl_out,
x_line_tbl => l_line_tbl_out,
x_line_val_tbl => l_line_val_tbl_out,
x_line_adj_tbl => l_line_adj_tbl_out,
x_line_adj_val_tbl => l_line_adj_val_tbl_out,
x_line_price_att_tbl => l_line_price_att_tbl_out,
x_line_adj_att_tbl => l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out,
x_line_scredit_tbl => l_line_scredit_tbl_out,
x_line_scredit_val_tbl => l_line_scredit_val_tbl_out,
x_lot_serial_tbl => l_lot_serial_tbl_out,
x_lot_serial_val_tbl => l_lot_serial_val_tbl_out,
x_action_request_tbl => l_action_request_tbl_out,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
/**************************************CHECK RETURN STATUS**********************************************/
IF l_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line ('Order Processed Successfully');
resultout := l_header_rec_out.order_number;
COMMIT;
ELSIF l_return_status = fnd_api.g_ret_sts_error
OR l_return_status = fnd_api.g_ret_sts_unexp_error
THEN
DBMS_OUTPUT.put_line ('Failed to create Order');
resultout := 'Error ' || ':' || l_msg_data;
ROLLBACK;
END IF;
/************************DISPLAY RETURN STATUS FLAGS***************************/
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ( 'process ORDER ret status IS: '
|| l_return_status
);
DBMS_OUTPUT.put_line ('process ORDER msg data IS: ' || l_msg_data);
DBMS_OUTPUT.put_line ('process ORDER msg COUNT IS: ' || l_msg_count);
DBMS_OUTPUT.put_line ( 'header.order_number IS: '
|| TO_CHAR (l_header_rec_out.order_number)
);
/*DBMS_OUTPUT.put_line ( 'adjustment.return_status IS: '
|| l_line_adj_tbl_out (1).return_status
);*/
DBMS_OUTPUT.put_line ( 'header.header_id IS: '
|| l_header_rec_out.header_id
);
DBMS_OUTPUT.put_line ( 'line.unit_selling_price IS: '
|| l_line_tbl_out (l_line_tbl_index).unit_selling_price
);
END IF;
/********************************DISPLAY ERROR MSGS*******************************/
IF (l_debug_level > 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_data,
p_msg_index_out => l_msg_index
);
DBMS_OUTPUT.put_line ('message is: ' || l_header_rec_out.header_id);
DBMS_OUTPUT.put_line ( 'message index is: '
|| l_header_rec_out.order_number
);
END LOOP;
END IF;
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Debug = ' || oe_debug_pub.g_debug);
DBMS_OUTPUT.put_line ( 'Debug Level = '
|| TO_CHAR (oe_debug_pub.g_debug_level)
);
DBMS_OUTPUT.put_line ( 'Debug File = '
|| oe_debug_pub.g_dir
|| '/'
|| oe_debug_pub.g_file
);
DBMS_OUTPUT.put_line ('*******************************************');
oe_debug_pub.debug_off;
END IF;
END cust_create_order;
PROCEDURE cust_create_order (inq_id NUMBER)
IS
l_api_version_number NUMBER := 1;
l_return_status VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
/*****************PARAMETERS****************************************/
l_debug_level NUMBER := 1;
-- OM DEBUG LEVEL (MAX 5)
l_org NUMBER := 101;
-- OPERATING UNIT
l_no_orders NUMBER := 1;
-- NO OF ORDERS
l_user NUMBER := 1110;
-- USER
l_resp NUMBER := 51330;
-- RESPONSIBLILTY
l_appl NUMBER := 660;
-- ORDER MANAGEMENT
/*************************INPUT VARIABLES FOR PROCESS_ORDER API****************************/
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_line_adj_tbl oe_order_pub.line_adj_tbl_type;
/****************************OUT VARIABLES FOR PROCESS_ORDER API**************************/
l_header_rec_out oe_order_pub.header_rec_type;
l_header_val_rec_out oe_order_pub.header_val_rec_type;
l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
l_line_tbl_out oe_order_pub.line_tbl_type;
l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
l_action_request_tbl_out oe_order_pub.request_tbl_type;
l_msg_index NUMBER;
l_data VARCHAR2 (2000);
l_loop_count NUMBER;
l_debug_file VARCHAR2 (200);
b_return_status VARCHAR2 (200);
b_msg_count NUMBER;
b_msg_data VARCHAR2 (2000);
l_etd_date DATE;
l_qty NUMBER;
l_line_no NUMBER;
l_line_tbl_index NUMBER;
order_typ NUMBER;
cust_id NUMBER;
poc_num NUMBER;
org_id NUMBER;
mfg_org_id NUMBER;
pay_term_id NUMBER;
from_size VARCHAR2 (20);
to_size VARCHAR2 (20);
header_id NUMBER;
order_num NUMBER;
Line_num NUMBER;
BEGIN
DBMS_APPLICATION_INFO.set_client_info (l_org);
mo_global.set_policy_context ('S', l_org);
mo_global.init ('ONT');
/**************************INITIALIZE DEBUG INFO**********************************/
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
oe_msg_pub.initialize;
END IF;
/****************************INITIALIZE ENVIRONMENT*******************************/
fnd_global.apps_initialize (l_user, l_resp, l_appl);
-- pass in user_id, responsibility_id, and application_id
/*****************INITIALIZE HEADER RECORD*************************/
l_header_rec := oe_order_pub.g_miss_header_rec;
/***********POPULATE REQUIRED ATTRIBUTES ************************/
SELECT cuoi.customer_id, cuoi.inquiry_number, cuoi.org_id,
cuoi.payment_term_id, cuoi.from_size, cuoi.to_size
INTO cust_id, poc_num, org_id,
pay_term_id, from_size, to_size
FROM cust_usg_ont_inquiry cuoi
WHERE cuoi.inquiry_id = inq_id;
SELECT ood.organization_id
INTO mfg_org_id
FROM org_organization_definitions ood
WHERE ood.operating_unit = org_id AND ood.organization_code <> 'IMO';
SELECT hcsu.order_type_id
INTO order_typ
FROM hz_parties hp,
hz_party_sites hps,
hz_locations hl,
hz_cust_accounts_all hca,
hz_cust_acct_sites_all hcsa,
hz_cust_site_uses_all hcsu
WHERE hp.party_id = hps.party_id
AND hps.location_id = hl.location_id
AND hp.party_id = hca.party_id
AND hcsa.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcsa.cust_acct_site_id
AND hca.cust_account_id = hcsa.cust_account_id
AND hca.cust_account_id = cust_id
and hcsa.ORG_ID = l_org
AND hcsu.site_use_code = 'BILL_TO';
l_header_rec.order_type_id := order_typ;
l_header_rec.sold_to_org_id := cust_id;
-- l_header_rec.ship_to_org_id := 1457;
l_header_rec.ship_from_org_id := mfg_org_id;
l_header_rec.orig_sys_document_ref := poc_num;
l_header_rec.payment_term_id := pay_term_id;
l_header_rec.global_attribute6 := inq_id;
l_header_rec.global_attribute7 := from_size;
l_header_rec.global_attribute8 := to_size;
l_header_rec.global_attribute9 := poc_num;
l_header_rec.ORDER_SOURCE_ID := 1001;
/**********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;
l_line_tbl_index := 0;
/**************************************CALLTO PROCESS ORDER API**********************************************/
oe_order_pub.process_order
(p_api_version_number => l_api_version_number,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
p_line_adj_tbl => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
,
x_header_rec => l_header_rec_out,
x_header_val_rec => l_header_val_rec_out,
x_header_adj_tbl => l_header_adj_tbl_out,
x_header_adj_val_tbl => l_header_adj_val_tbl_out,
x_header_price_att_tbl => l_header_price_att_tbl_out,
x_header_adj_att_tbl => l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out,
x_header_scredit_tbl => l_header_scredit_tbl_out,
x_header_scredit_val_tbl => l_header_scredit_val_tbl_out,
x_line_tbl => l_line_tbl_out,
x_line_val_tbl => l_line_val_tbl_out,
x_line_adj_tbl => l_line_adj_tbl_out,
x_line_adj_val_tbl => l_line_adj_val_tbl_out,
x_line_price_att_tbl => l_line_price_att_tbl_out,
x_line_adj_att_tbl => l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out,
x_line_scredit_tbl => l_line_scredit_tbl_out,
x_line_scredit_val_tbl => l_line_scredit_val_tbl_out,
x_lot_serial_tbl => l_lot_serial_tbl_out,
x_lot_serial_val_tbl => l_lot_serial_val_tbl_out,
x_action_request_tbl => l_action_request_tbl_out,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
header_id := l_header_rec_out.header_id;
order_num := l_header_rec_out.order_number;
line_num := 0;
l_header_rec.operation := oe_globals.g_opr_update;
l_header_rec.header_id := header_id;
FOR i IN (SELECT nvl(cope.quantity,cuoi.INQUIRY_QTY) qty, cuop.final_offer price,
cuoi.inquiry_number inqnum , nvl(cope.ETD, cuoi.EXPECT_SHIP_DATE ) etd
FROM cust_ont_poc_etd cope,
cust_usg_ont_inquiry cuoi,
cust_usg_ont_pcosting cuop
WHERE cope.inquiry_id = cuoi.inquiry_id
AND cuoi.inquiry_id = cuop.inquiry_id
AND cope.inquiry_id = inq_id)
LOOP
line_num := line_num+1;
l_line_tbl_index := l_line_tbl_index + 1;
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 := 11927;
l_line_tbl (l_line_tbl_index).ordered_quantity := i.qty;
l_line_tbl (l_line_tbl_index).SCHEDULE_SHIP_DATE := i.etd ;
l_line_tbl (l_line_tbl_index).orig_sys_document_ref := i.inqnum;
l_line_tbl (l_line_tbl_index).user_item_description := order_num||'/'||line_num||'.1';
--l_line_tbl (l_line_tbl_index).attribute3 := 20;
--l_line_tbl (l_line_tbl_index).attribute3 := 'Mohsin';
l_line_tbl (l_line_tbl_index).unit_list_price := i.price;
l_line_tbl (l_line_tbl_index).unit_selling_price := i.price;
/**********************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 (l_line_tbl_index).entity_code :=
oe_globals.g_entity_header;
END LOOP;
oe_order_pub.process_order
(p_api_version_number => l_api_version_number,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
p_line_adj_tbl => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
,
x_header_rec => l_header_rec_out,
x_header_val_rec => l_header_val_rec_out,
x_header_adj_tbl => l_header_adj_tbl_out,
x_header_adj_val_tbl => l_header_adj_val_tbl_out,
x_header_price_att_tbl => l_header_price_att_tbl_out,
x_header_adj_att_tbl => l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out,
x_header_scredit_tbl => l_header_scredit_tbl_out,
x_header_scredit_val_tbl => l_header_scredit_val_tbl_out,
x_line_tbl => l_line_tbl_out,
x_line_val_tbl => l_line_val_tbl_out,
x_line_adj_tbl => l_line_adj_tbl_out,
x_line_adj_val_tbl => l_line_adj_val_tbl_out,
x_line_price_att_tbl => l_line_price_att_tbl_out,
x_line_adj_att_tbl => l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out,
x_line_scredit_tbl => l_line_scredit_tbl_out,
x_line_scredit_val_tbl => l_line_scredit_val_tbl_out,
x_lot_serial_tbl => l_lot_serial_tbl_out,
x_lot_serial_val_tbl => l_lot_serial_val_tbl_out,
x_action_request_tbl => l_action_request_tbl_out,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
/**************************************CHECK RETURN STATUS**********************************************/
IF l_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line ('Order Processed Successfully');
resultout := l_header_rec_out.order_number;
COMMIT;
ELSIF l_return_status = fnd_api.g_ret_sts_error
OR l_return_status = fnd_api.g_ret_sts_unexp_error
THEN
DBMS_OUTPUT.put_line ('Failed to create Order');
resultout := 'Error ' || ':' || l_msg_data;
ROLLBACK;
END IF;
/************************DISPLAY RETURN STATUS FLAGS***************************/
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ( 'process ORDER ret status IS: '
|| l_return_status
);
DBMS_OUTPUT.put_line ('process ORDER msg data IS: ' || l_msg_data);
DBMS_OUTPUT.put_line ('process ORDER msg COUNT IS: ' || l_msg_count);
DBMS_OUTPUT.put_line ( 'header.order_number IS: '
|| TO_CHAR (l_header_rec_out.order_number)
);
/*DBMS_OUTPUT.put_line ( 'adjustment.return_status IS: '
|| l_line_adj_tbl_out (1).return_status
);*/
DBMS_OUTPUT.put_line ( 'header.header_id IS: '
|| l_header_rec_out.header_id
);
DBMS_OUTPUT.put_line ( 'line.unit_selling_price IS: '
|| l_line_tbl_out (l_line_tbl_index).unit_selling_price
);
END IF;
/********************************DISPLAY ERROR MSGS*******************************/
IF (l_debug_level > 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_data,
p_msg_index_out => l_msg_index
);
DBMS_OUTPUT.put_line ('message is: ' || l_header_rec_out.header_id);
DBMS_OUTPUT.put_line ( 'message index is: '
|| l_header_rec_out.order_number
);
END LOOP;
END IF;
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Debug = ' || oe_debug_pub.g_debug);
DBMS_OUTPUT.put_line ( 'Debug Level = '
|| TO_CHAR (oe_debug_pub.g_debug_level)
);
DBMS_OUTPUT.put_line ( 'Debug File = '
|| oe_debug_pub.g_dir
|| '/'
|| oe_debug_pub.g_file
);
DBMS_OUTPUT.put_line ('*******************************************');
oe_debug_pub.debug_off;
END IF;
END cust_create_order;
No comments:
Post a Comment