--API to Close Sales Order Where SO Lines are already closed
DECLAREl_file_val VARCHAR2(300);
l_result VARCHAR2(30);
CURSOR header_cur IS
SELECT h.header_id
FROM wf_item_activity_statuses st,
oe_order_headers_all h,
wf_process_activities wpa
WHERE wpa.instance_id = st.process_activity
AND st.item_type = 'OEOH'
AND wpa.activity_name = 'CLOSE_WAIT_FOR_L'
AND wpa.process_name = 'CLOSE_HEADER_PROCESS'
AND st.activity_status = 'NOTIFIED'
AND st.item_key = To_char(h.header_id)
AND h.header_id = 3654189
AND h.open_flag = 'Y'
AND h.flow_status_code = 'BOOKED'
AND NOT EXISTS(SELECT 1
FROM oe_order_lines_all oel
WHERE oel.header_id = h.header_id
AND oel.open_flag = 'Y');
BEGIN
oe_debug_pub.Setdebuglevel(5);
oe_debug_pub.debug_on;
oe_debug_pub.initialize;
l_file_val := oe_debug_pub.Set_debug_mode('FILE');
dbms_output.Put_line('Debug File : ' ||l_file_val);
FOR header_rec IN header_cur LOOP
dbms_output.Put_line('Closing Header:' ||header_rec.header_id);
oe_debug_pub.ADD('Closing Header:'||header_rec.header_id);
oe_standard_wf.Oeoh_selector (p_itemtype => 'OEOH',
p_itemkey => To_char(header_rec.header_id), p_actid => 12345,
p_funcmode => 'SET_CTX', p_result => l_result);
wf_engine.Handleerror('OEOH', header_rec.header_id, 'CLOSE_HEADER_PROCESS:CLOSE_HEADER', 'RETRY', NULL);
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
oe_debug_pub.ADD(' Error is : '||SQLERRM);
dbms_output.Put_line('Error : '||SQLERRM);
NULL;
END;
/*
Metalink Docs:
All Order Lines Are Closed Yet Header Remains Open [ID 145010.1]
Sales Order Header Does Not Close After ALL Lines Have Closed [ID 133837.1]
*/
No comments:
Post a Comment