You are on page 1of 8

CREATE OR REPLACE procedure APPS.

XXCG_SOS_ORDER_LINE_UPDATE_API(l_header_id IN n
umber,
l_line_id IN number
,
l_quantity in varch
ar2,
l_wearer_code in va
rchar2,
l_new_price in n
umber,
l_request_date in d
ate,
l_ceremony_date in
date,
l_unit_set
in v
archar2,
l_inventory_item_id
in number,
l_uom
in v
archar2,
-- l_orig_system_lin
e_reference in varchar2,
-- l_last_updated_by
in number,
l_sos_line_id
v
archar2,
l_price_changed_fla
g varchar2,
l_dis_price_adjustm
ent_id number,
-- l_tax_price_adjus
tment_id number,
l_sell_price_adjust
ment number,
l_lock_control
number,
l_results
OUT v
archar2) AS
-- l_field_name IN v
archar,
-- l_field_value IN
number) as
l_api_version_number
NUMBER := 1;
l_return_status
VARCHAR2(2000);
l_msg_count
NUMBER;
l_msg_data
VARCHAR2(2000);
l_msg_index
NUMBER;
l_data
VARCHAR2(2000);
app_user_id
NUMBER := 0;
v_user_id
number ;
v_resp_id
number;
v_resp_appl_id
number;
v_results
varchar2(50) ;
-- v_last_updated_by
number := l_last_updated_by;
v_sos_line_id
varchar2(50) := l_sos_line_id;
v_price_changed_flag
varchar2(10) := l_price_changed_
flag;
l_list_header_id
number;
l_list_line_id
number;
l_list_line_type_code
varchar2(100);

l_modifier_level_code
varchar2(100);
-/*****************INPUT VARIABLES FOR PROCESS_ORDER API*************************
************/
l_header_rec
l_line_tbl
l_action_request_tbl
l_line_adj_tbl

oe_order_pub.header_rec_type;
oe_order_pub.line_tbl_type;
oe_order_pub.Request_Tbl_Type;
OE_ORDER_PUB.line_adj_tbl_type;

/*****************OUT VARIABLES FOR PROCESS_ORDER API***************************


**********/
l_header_rec_out
l_header_val_rec_out
l_header_adj_tbl_out
l_header_adj_val_tbl_out

oe_order_pub.header_rec_type;
oe_order_pub.header_val_rec_type;
oe_order_pub.header_adj_tbl_type;
oe_order_pub.header_adj_val_tbl_t

l_header_price_att_tbl_out

oe_order_pub.header_price_att_tbl

l_header_adj_att_tbl_out

oe_order_pub.header_adj_att_tbl_t

l_header_adj_assoc_tbl_out

oe_order_pub.header_adj_assoc_tbl

l_header_scredit_tbl_out

oe_order_pub.header_scredit_tbl_t

l_header_scredit_val_tbl_out

oe_order_pub.header_scredit_val_t

ype;
_type;
ype;
_type;
ype;
bl_type;
l_line_tbl_out
l_line_val_tbl_out
l_line_adj_tbl_out
l_line_adj_val_tbl_out

oe_order_pub.line_tbl_type;
oe_order_pub.line_val_tbl_type;
oe_order_pub.line_adj_tbl_type;
oe_order_pub.line_adj_val_tbl_typ

l_line_price_att_tbl_out

oe_order_pub.line_price_att_tbl_t

l_line_adj_att_tbl_out

oe_order_pub.line_adj_att_tbl_typ

l_line_adj_assoc_tbl_out

oe_order_pub.line_adj_assoc_tbl_t

l_line_scredit_tbl_out

oe_order_pub.line_scredit_tbl_typ

l_line_scredit_val_tbl_out

oe_order_pub.line_scredit_val_tbl

l_lot_serial_tbl_out
l_lot_serial_val_tbl_out

oe_order_pub.lot_serial_tbl_type;
oe_order_pub.lot_serial_val_tbl_t

l_action_request_tbl_out

oe_order_pub.request_tbl_type;

e;
ype;
e;
ype;
e;
_type;
ype;
BEGIN
BEGIN
SELECT list_header_id,list_line_id,
list_line_type_code,modifier_level_code
INTO l_list_header_id,l_list_line_id,
l_list_line_type_code,l_modifier_level_code
FROM qp_lines_summary_v
WHERE name = 'Manual'
AND
NVL(end_date_active,SYSDATE+1) > SYSDATE
AND
ROWNUM <2;

EXCEPTION WHEN OTHERS THEN


l_list_header_id := 6035; -- use value in prod for prod instance
l_list_line_id := 6005;
l_list_line_type_code:= 'DIS';
l_modifier_level_code := 'LINE';
END;
/*****************INITIALIZE DEBUG INFO*********************************
****/
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(5);
Oe_Msg_Pub.initialize;
/*****************INITIALIZE ENVIRONMENT********************************
*****/
fnd_profile.get('USER_ID',v_user_id);
fnd_profile.get('RESP_ID',v_resp_id);
fnd_profile.get('RESP_APPL_ID',v_resp_appl_id);
IF v_user_id is null THEN
v_user_id := -1;
END IF;
IF v_resp_id is null THEN
v_resp_id := 21623;
END IF;
IF v_resp_appl_id is null THEN
v_resp_appl_id := 660;
END IF;
fnd_global.apps_initialize(v_user_id, v_resp_id, v_resp_appl_id); -- 1st
parameter is user_id, 2nd is responsibility_id, 3rd is responsibility_applicati
on_id
-dbms_output.put_line('User id :'||v_user_id||' Resp id :'||v_resp_id
||' Resp Appl id :'||v_resp_appl_id );
dbms_output.put_line(' NEW SELL PRICE IS: '||l_new_price);
dbms_output.put_line(' sos line id is: '||v_sos_line_id);
dbms_output.put_line('Ceremony date is: '||l_ceremony_date);
dbms_output.put_line('Price Adjustment value is '||l_sell_price_adjustm
ent);
dbms_output.put_line('Price Adjustment ID is '||l_dis_price_adjustment_
id);
dbms_output.put_line('Price Change flag is '||l_price_changed_flag);
--dbms_output.put_line('Last updated by: '||v_last_updated_by);
/*****************INITIALIZE HEADER RECORD******************************
*******/
l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
/*****************POPULATE HEADER INFO**********************************
***/
/*

if l_field_name = 'ordered_quantity' then


l_line_tbl(1).header_id
:= l_header_id;
l_line_tbl(1).line_id
:= l_line_id;
l_line_tbl(1).ordered_quantity := l_field_value;
l_line_tbl(1).operation
:= OE_GLOBALS.G_OPR_UPDATE;
end if;
*/

BEGIN
IF nvl(v_price_changed_flag,'N') = 'Y' THEN
dbms_output.put_line('processing price change');
l_line_tbl(1).header_id
:= l_header_id;
l_line_tbl(1).line_id
:= l_line_id;
l_line_tbl(1).ordered_quantity
:= l_quantity;
l_line_tbl(1).attribute15
:= l_wearer_code;
l_line_tbl(1).request_date
:= l_request_date;
l_line_tbl(1).promise_date
:= l_ceremony_date;
l_line_tbl(1).attribute1
:= l_unit_set;
l_line_tbl(1).inventory_item_id
:= l_inventory_item_id;
l_line_tbl(1).order_quantity_uom := l_uom;
l_line_tbl(1).pricing_quantity_uom := l_uom;
-- l_line_tbl(1).orig_sys_document_ref := l_orig_system_line_referenc
e;
l_line_tbl(1).unit_selling_price
:= l_new_price;
dbms_output.put_line('value for l line tbl unit sell price is: '||l_
line_tbl(1).unit_selling_price);
l_line_tbl(1).calculate_price_flag := 'N';
-- l_line_tbl(1).last_updated_by
:= v_last_updated_by;
l_line_tbl(1).ORIG_SYS_LINE_REF
:= v_sos_line_id;
l_line_tbl(1).operation
:= OE_GLOBALS.G_OPR_UPDATE;
/*****************

ADDING PRICE ADJUSTMENT STUFF -JULY26,2012

*/

IF l_dis_price_adjustment_id != '0' THEN


l_line_adj_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
dbms_output.put_line('trying to update DIS price adj');
-- l_sell_price := -1*lsell_price+NVL(v_list_price,0); -- Need to chnage
the sign of price supplied
l_line_adj_tbl(1).price_adjustment_id := l_dis_price_adjustment_id;
l_line_adj_tbl(1).change_reason_text := 'Manually applied adjustment
s';
l_line_adj_tbl(1).change_reason_code := 'MANUAL';
l_line_adj_tbl(1).updated_flag := 'Y';
l_line_adj_tbl(1).applied_flag := 'Y';
l_line_adj_tbl(1).automatic_flag := 'N';
l_Line_Adj_Tbl(1).arithmetic_operator:= 'AMT';
l_line_adj_tbl(1).operand := l_sell_price_adjustment; --jb l_sell_p
rice;
l_line_adj_tbl(1).operand_per_pqty := l_sell_price_adjustment; --jb
l_sell_price;
l_line_adj_tbl(1).adjusted_amount_per_pqty := l_sell_price_adjustmen
t * -1; -- jb l_sell_price;
l_line_adj_tbl(1).header_id := l_header_id ; --jb cline.header_id;
l_line_adj_tbl(1).list_header_id := l_list_header_id;
l_line_adj_tbl(1).list_line_id := l_list_line_id;
l_line_adj_tbl(1).line_index := 1;
l_line_adj_tbl(1).modifier_level_code := l_modifier_level_code;
l_line_adj_tbl(1).adjusted_amount := l_sell_price_adjustment * -1;
--jb l_sell_price;
l_line_adj_tbl(1).lock_control
:= l_lock_control + 1;
l_line_adj_tbl(1).list_line_type_code := l_list_line_type_code;
l_line_adj_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE ;
dbms_output.put_line('out of dis price adj code');

END IF;
/****************************************************************************/
/*****************CALLTO PROCESS ORDER API*************************************/
OE_Order_Pub.Process_Order(
p_api_version_number

=> l_api_version_numb

er,
p_line_tbl
x_header_rec
x_header_val_rec

=> l_line_tbl,
=> l_header_rec_out,
=> l_header_val_rec_o

x_header_adj_tbl

=> l_header_adj_tbl_o

x_header_adj_val_tbl

=> l_header_adj_val_t

x_header_price_att_tbl

=> l_header_price_att

x_header_adj_att_tbl

=> l_header_adj_att_t

x_header_adj_assoc_tbl

=> l_header_adj_assoc

x_header_scredit_tbl

=> l_header_scredit_t

x_header_scredit_val_tbl

=> l_header_scredit_v

x_line_tbl
x_line_val_tbl

=> l_line_tbl_out,
=> l_line_val_tbl_out

x_line_adj_tbl

=> l_line_adj_tbl_out

x_line_adj_val_tbl

=> l_line_adj_val_tbl

x_line_price_att_tbl

=> l_line_price_att_t

x_line_adj_att_tbl

=> l_line_adj_att_tbl

x_line_adj_assoc_tbl

=> l_line_adj_assoc_t

x_line_scredit_tbl

=> l_line_scredit_tbl

x_line_scredit_val_tbl

=> l_line_scredit_val

x_lot_serial_tbl

=> l_lot_serial_tbl_o

x_lot_serial_val_tbl

=> l_lot_serial_val_t

x_action_request_tbl

=> l_action_request_t

x_return_status
x_msg_count
x_msg_data

=> l_return_status,
=> l_msg_count,
=> l_msg_data);

ut,
ut,
bl_out,
_tbl_out,
bl_out,
_tbl_out,
bl_out,
al_tbl_out,
,
,
_out,
bl_out,
_out,
bl_out,
_out,
_tbl_out,
ut,
bl_out,
bl_out,

ELSE
dbms_output.put_line('processing NO price change');
l_line_tbl(1).header_id
:= l_header_id;
l_line_tbl(1).line_id
:= l_line_id;

l_line_tbl(1).ordered_quantity
:= l_quantity;
l_line_tbl(1).attribute15
:= l_wearer_code;
l_line_tbl(1).request_date
:= l_request_date;
l_line_tbl(1).promise_date
:= l_ceremony_date;
l_line_tbl(1).attribute1
:= l_unit_set;
l_line_tbl(1).inventory_item_id
:= l_inventory_item_id;
l_line_tbl(1).order_quantity_uom := l_uom;
l_line_tbl(1).pricing_quantity_uom := l_uom;
-- l_line_tbl(1).orig_sys_document_ref := l_orig_system_line_r
eference;
-- l_line_tbl(1).unit_selling_price
-- l_line_tbl(1).last_updated_by
l_line_tbl(1).ORIG_SYS_LINE_REF
:=
l_line_tbl(1).operation
:=
/*****************CALLTO PROCESS ORDER

:= l_new_price;
:= v_last_updated_by;
v_sos_line_id;
OE_GLOBALS.G_OPR_UPDATE;
API**********************

***************/
OE_Order_Pub.Process_Order(
p_api_version_number

=> l_api_version_numb

er,
p_line_tbl
x_header_rec
x_header_val_rec

=> l_line_tbl,
=> l_header_rec_out,
=> l_header_val_rec_o

x_header_adj_tbl

=> l_header_adj_tbl_o

x_header_adj_val_tbl

=> l_header_adj_val_t

x_header_price_att_tbl

=> l_header_price_att

x_header_adj_att_tbl

=> l_header_adj_att_t

x_header_adj_assoc_tbl

=> l_header_adj_assoc

x_header_scredit_tbl

=> l_header_scredit_t

x_header_scredit_val_tbl

=> l_header_scredit_v

x_line_tbl
x_line_val_tbl

=> l_line_tbl_out,
=> l_line_val_tbl_out

x_line_adj_tbl

=> l_line_adj_tbl_out

x_line_adj_val_tbl

=> l_line_adj_val_tbl

x_line_price_att_tbl

=> l_line_price_att_t

x_line_adj_att_tbl

=> l_line_adj_att_tbl

x_line_adj_assoc_tbl

=> l_line_adj_assoc_t

x_line_scredit_tbl

=> l_line_scredit_tbl

x_line_scredit_val_tbl

=> l_line_scredit_val

x_lot_serial_tbl

=> l_lot_serial_tbl_o

x_lot_serial_val_tbl

=> l_lot_serial_val_t

x_action_request_tbl

=> l_action_request_t

ut,
ut,
bl_out,
_tbl_out,
bl_out,
_tbl_out,
bl_out,
al_tbl_out,
,
,
_out,
bl_out,
_out,
bl_out,
_out,
_tbl_out,
ut,
bl_out,

bl_out,
x_return_status
x_msg_count
x_msg_data

=> l_return_status,
=> l_msg_count,
=> l_msg_data);

END IF;
EXCEPTION
when others then
dbms_output.put_line('Problem updating LINE ID: '||l_line_id);
END;
/*****************CHECK RETURN STATUS*************************************/
if l_return_status = FND_API.G_RET_STS_SUCCESS then
dbms_output.put_line('success');
l_results := 'S';
--commit;
else
dbms_output.put_line('failure');
l_results := 'F';
--rollback;
end if;
/*****************DISPLAY RETURN STATUS FLAGS***********************************
**/
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_head
er_rec_out.order_number));
-DBMS_OUTPUT.PUT_LINE('header.return_status IS: '
|| l_header_rec_ou
t.return_status);
-- DBMS_OUTPUT.PUT_LINE('header.booked_flag IS: '
|| l_header_rec_ou
t.booked_flag);
-- DBMS_OUTPUT.PUT_LINE('header.header_id IS: '
|| l_header_rec_o
ut.header_id);
-DBMS_OUTPUT.PUT_LINE('header.order_source_id IS: ' || l_header_rec_o
ut.order_source_id);
-DBMS_OUTPUT.PUT_LINE('header.flow_status_code IS: ' || l_header_rec_o
ut.flow_status_code);
/*****************DISPLAY ERROR MSGS*************************************/
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_data);
DBMS_OUTPUT.PUT_LINE('message index is: ' || l_msg_index);
END LOOP;

--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;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line ('Others exception : ' || SQLERRM);
END;
/

You might also like