PROCEDURE CREATE_SALES_ORD_DELIVERY_INT(errorbuff OUT VARCHAR2,
retcode OUT NUMBER,
p_record_id NUMBER DEFAULT NULL) IS
l_return_status VARCHAR2(10);
v_error_msg VARCHAR2(4000);
l_msg_summary VARCHAR2(250);
l_msg_details VARCHAR2(2000);
l_msg_count NUMBER;
l_line_rows wsh_util_core.id_tab_type;
l_del_rows wsh_util_core.id_tab_type;
l_commit VARCHAR2(10) := fnd_api.g_false;
l_cur_count NUMBER := 0;
--
CURSOR delivery_det(p_record_id NUMBER) IS
SELECT deliverydetailid delivery_detail_id
FROM XXIT_CREATE_DELIVERIES_V
WHERE record_id = nvl(p_record_id, record_id)
AND status = 'NEW';
BEGIN
--
-- Initialize return status
l_return_status := wsh_util_core.g_ret_sts_success;
-- Call this procedure to initialize applications parameters
fnd_global.apps_initialize(user_id => fnd_profile.VALUE('USER_ID'),
resp_id => fnd_profile.VALUE('RESP_ID'),
resp_appl_id => fnd_profile.VALUE('RESP_APPL_ID'));
FOR i IN delivery_det(p_record_id) LOOP
l_cur_count := l_cur_count + 1;
l_line_rows(l_cur_count) := i.delivery_detail_id;
--
UPDATE xxit_integration_in
SET status = 'NEW'
WHERE record_id = p_record_id;
--
END LOOP;
wsh_delivery_details_pub.autocreate_deliveries(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => l_commit,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => v_error_msg,
p_line_rows => l_line_rows,
x_del_rows => l_del_rows);
dbms_output.put_line('l_return_status:' || l_return_status);
IF (l_return_status <> wsh_util_core.g_ret_sts_success)
THEN
wsh_util_core.get_messages('Y', l_msg_summary, l_msg_details, l_msg_count);
dbms_output.put_line('l_msg_count:' || l_msg_count);
IF l_msg_count > 1
THEN
v_error_msg := l_msg_summary || l_msg_details;
ELSE
v_error_msg := l_msg_summary || l_msg_details;
END IF;
--
UPDATE xxit_integration_in
SET status = 'ERROR'
WHERE record_id = p_record_id;
COMMIT;
fnd_file.put_line(fnd_file.log,
'Error: Auto create delivery' || ':' || v_error_msg);
ELSE
UPDATE xxit_integration_in
SET status = 'PROCESSED'
WHERE record_id = p_record_id;
COMMIT;
fnd_file.put_line(fnd_file.log,
'Success: Auto create delivery for record_id :' || p_record_id);
END IF;
--Create Delivery
COMMIT;
EXCEPTION
WHEN OTHERS THEN
errorbuff := ('Error: ' || SQLERRM);
retcode := 1;
ROLLBACK;
fnd_file.put_line(fnd_file.log, 'Error: ' || SQLERRM);
--
END CREATE_SALES_ORD_DELIVERY_INT;
/
CREATE TABLE XXIT_CREATE_DELIVERIES_V
(
record_id NUMBER,
status VARCHAR2(150),
source_system VARCHAR2(150),
source_system_id NUMBER,
process_method VARCHAR2(150),
process_method_id NUMBER,
priority VARCHAR2(150),
soa_composite_id NUMBER,
context VARCHAR2(150),
attribute1 VARCHAR2(150),
attribute2 VARCHAR2(150),
attribute3 VARCHAR2(150),
attribute4 VARCHAR2(150),
attribute5 VARCHAR2(150),
attribute6 VARCHAR2(150),
attribute7 VARCHAR2(150),
attribute8 VARCHAR2(150),
attribute9 VARCHAR2(150),
attribute10 VARCHAR2(150),
attribute11 VARCHAR2(150),
attribute12 VARCHAR2(150),
attribute13 VARCHAR2(150),
attribute14 VARCHAR2(150),
attribute15 VARCHAR2(150),
creation_date DATE,
created_by NUMBER,
last_update_date DATE,
last_updated_by NUMBER,
SN VARCHAR2(150),
groupingId NUMBER,
CustomerName VARCHAR2(150),
DeliveryDetailId NUMBER
)
retcode OUT NUMBER,
p_record_id NUMBER DEFAULT NULL) IS
l_return_status VARCHAR2(10);
v_error_msg VARCHAR2(4000);
l_msg_summary VARCHAR2(250);
l_msg_details VARCHAR2(2000);
l_msg_count NUMBER;
l_line_rows wsh_util_core.id_tab_type;
l_del_rows wsh_util_core.id_tab_type;
l_commit VARCHAR2(10) := fnd_api.g_false;
l_cur_count NUMBER := 0;
--
CURSOR delivery_det(p_record_id NUMBER) IS
SELECT deliverydetailid delivery_detail_id
FROM XXIT_CREATE_DELIVERIES_V
WHERE record_id = nvl(p_record_id, record_id)
AND status = 'NEW';
BEGIN
--
-- Initialize return status
l_return_status := wsh_util_core.g_ret_sts_success;
-- Call this procedure to initialize applications parameters
fnd_global.apps_initialize(user_id => fnd_profile.VALUE('USER_ID'),
resp_id => fnd_profile.VALUE('RESP_ID'),
resp_appl_id => fnd_profile.VALUE('RESP_APPL_ID'));
FOR i IN delivery_det(p_record_id) LOOP
l_cur_count := l_cur_count + 1;
l_line_rows(l_cur_count) := i.delivery_detail_id;
--
UPDATE xxit_integration_in
SET status = 'NEW'
WHERE record_id = p_record_id;
--
END LOOP;
wsh_delivery_details_pub.autocreate_deliveries(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => l_commit,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => v_error_msg,
p_line_rows => l_line_rows,
x_del_rows => l_del_rows);
dbms_output.put_line('l_return_status:' || l_return_status);
IF (l_return_status <> wsh_util_core.g_ret_sts_success)
THEN
wsh_util_core.get_messages('Y', l_msg_summary, l_msg_details, l_msg_count);
dbms_output.put_line('l_msg_count:' || l_msg_count);
IF l_msg_count > 1
THEN
v_error_msg := l_msg_summary || l_msg_details;
ELSE
v_error_msg := l_msg_summary || l_msg_details;
END IF;
--
UPDATE xxit_integration_in
SET status = 'ERROR'
WHERE record_id = p_record_id;
COMMIT;
fnd_file.put_line(fnd_file.log,
'Error: Auto create delivery' || ':' || v_error_msg);
ELSE
UPDATE xxit_integration_in
SET status = 'PROCESSED'
WHERE record_id = p_record_id;
COMMIT;
fnd_file.put_line(fnd_file.log,
'Success: Auto create delivery for record_id :' || p_record_id);
END IF;
--Create Delivery
COMMIT;
EXCEPTION
WHEN OTHERS THEN
errorbuff := ('Error: ' || SQLERRM);
retcode := 1;
ROLLBACK;
fnd_file.put_line(fnd_file.log, 'Error: ' || SQLERRM);
--
END CREATE_SALES_ORD_DELIVERY_INT;
/
CREATE TABLE XXIT_CREATE_DELIVERIES_V
(
record_id NUMBER,
status VARCHAR2(150),
source_system VARCHAR2(150),
source_system_id NUMBER,
process_method VARCHAR2(150),
process_method_id NUMBER,
priority VARCHAR2(150),
soa_composite_id NUMBER,
context VARCHAR2(150),
attribute1 VARCHAR2(150),
attribute2 VARCHAR2(150),
attribute3 VARCHAR2(150),
attribute4 VARCHAR2(150),
attribute5 VARCHAR2(150),
attribute6 VARCHAR2(150),
attribute7 VARCHAR2(150),
attribute8 VARCHAR2(150),
attribute9 VARCHAR2(150),
attribute10 VARCHAR2(150),
attribute11 VARCHAR2(150),
attribute12 VARCHAR2(150),
attribute13 VARCHAR2(150),
attribute14 VARCHAR2(150),
attribute15 VARCHAR2(150),
creation_date DATE,
created_by NUMBER,
last_update_date DATE,
last_updated_by NUMBER,
SN VARCHAR2(150),
groupingId NUMBER,
CustomerName VARCHAR2(150),
DeliveryDetailId NUMBER
)
No comments:
Post a Comment