PROCEDURE pr_approve_invoice(errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_invoice_id IN NUMBER,
p_request_id OUT NUMBER) IS
CURSOR app_inv_cur IS
SELECT DISTINCT aia.invoice_num inv_number, aia.org_id
FROM ap_invoices_all aia
WHERE 1 = 1
AND aia.invoice_id = p_invoice_id
AND aia.wfapproval_status = 'REQUIRED';
--'VLAIDATED');
l_sub_request_id NUMBER := NULL;
l_resp_id NUMBER; --PAYABLES Manager
l_app_id NUMBER; --Account payables
v_request_completed BOOLEAN;
v_request_id NUMBER;
v_phase VARCHAR2(80) := NULL;
v_status VARCHAR2(80) := NULL;
v_dev_phase VARCHAR2(30) := NULL;
v_dev_status VARCHAR2(30) := NULL;
v_message VARCHAR2(240);
l_ou_name VARCHAR2(200);
l_org_id NUMBER := 101;
l_ou_count NUMBER;
BEGIN
FOR app_inv_rec IN app_inv_cur LOOP
BEGIN
SELECT DISTINCT fr.responsibility_id, frx.application_id
INTO l_resp_id, l_app_id
FROM apps.fnd_responsibility frx, apps.fnd_responsibility_tl fr
WHERE fr.responsibility_id = frx.responsibility_id
AND UPPER(fr.responsibility_name) = UPPER('Payables Manager');
-- fnd_client_info.set_org_context (85);
IF gn_user_id IS NOT NULL AND l_resp_id IS NOT NULL AND l_app_id IS NOT NULL THEN
pr_print_debug('Initializing AP responsibility and application',1);
--mo_global.init ('AP');
mo_global.set_policy_context ('S', 101);
apps.fnd_global.apps_initialize(gn_user_id, l_resp_id, l_app_id);
pr_print_debug('Submitting Invoice Approval Workflow.. ',1);
fnd_request.set_org_id('101');
l_sub_request_id :=
apps.fnd_request.submit_request('SQLAP',
'APXIAWRE',
'Invoice Approval Workflow',
NULL,
FALSE,
NULL,
app_inv_rec.inv_number,
NULL,
NULL);
COMMIT;
LOOP
v_request_completed := apps.fnd_concurrent.wait_for_request(l_sub_request_id -- Request ID
,
20
-- Time Interval
,
0
-- Total Time to wait
,
v_phase
-- Phase displyed on screen
,
v_status -- Status displayed on screen
,
v_dev_phase
-- Phase available for developer
,
v_dev_status -- Status available for developer
,
v_message
-- Execution Message
);
EXIT WHEN v_request_completed;
END LOOP;
END IF;
pr_print_debug('Invoice Approval Workflow completed with request id = ' ||
l_sub_request_id,1);
p_request_id := l_sub_request_id;
EXCEPTION
WHEN OTHERS THEN
pr_print_debug('Error in submiting Invoice Approval Workflow Program: ' ||
SQLERRM,1);
errbuf := 'Error in submiting Invoice Approval Workflow Program: '||SQLERRM;
retcode := 2;
END;
END LOOP;
END pr_approve_invoice;
retcode OUT VARCHAR2,
p_invoice_id IN NUMBER,
p_request_id OUT NUMBER) IS
CURSOR app_inv_cur IS
SELECT DISTINCT aia.invoice_num inv_number, aia.org_id
FROM ap_invoices_all aia
WHERE 1 = 1
AND aia.invoice_id = p_invoice_id
AND aia.wfapproval_status = 'REQUIRED';
--'VLAIDATED');
l_sub_request_id NUMBER := NULL;
l_resp_id NUMBER; --PAYABLES Manager
l_app_id NUMBER; --Account payables
v_request_completed BOOLEAN;
v_request_id NUMBER;
v_phase VARCHAR2(80) := NULL;
v_status VARCHAR2(80) := NULL;
v_dev_phase VARCHAR2(30) := NULL;
v_dev_status VARCHAR2(30) := NULL;
v_message VARCHAR2(240);
l_ou_name VARCHAR2(200);
l_org_id NUMBER := 101;
l_ou_count NUMBER;
BEGIN
FOR app_inv_rec IN app_inv_cur LOOP
BEGIN
SELECT DISTINCT fr.responsibility_id, frx.application_id
INTO l_resp_id, l_app_id
FROM apps.fnd_responsibility frx, apps.fnd_responsibility_tl fr
WHERE fr.responsibility_id = frx.responsibility_id
AND UPPER(fr.responsibility_name) = UPPER('Payables Manager');
-- fnd_client_info.set_org_context (85);
IF gn_user_id IS NOT NULL AND l_resp_id IS NOT NULL AND l_app_id IS NOT NULL THEN
pr_print_debug('Initializing AP responsibility and application',1);
--mo_global.init ('AP');
mo_global.set_policy_context ('S', 101);
apps.fnd_global.apps_initialize(gn_user_id, l_resp_id, l_app_id);
pr_print_debug('Submitting Invoice Approval Workflow.. ',1);
fnd_request.set_org_id('101');
l_sub_request_id :=
apps.fnd_request.submit_request('SQLAP',
'APXIAWRE',
'Invoice Approval Workflow',
NULL,
FALSE,
NULL,
app_inv_rec.inv_number,
NULL,
NULL);
COMMIT;
LOOP
v_request_completed := apps.fnd_concurrent.wait_for_request(l_sub_request_id -- Request ID
,
20
-- Time Interval
,
0
-- Total Time to wait
,
v_phase
-- Phase displyed on screen
,
v_status -- Status displayed on screen
,
v_dev_phase
-- Phase available for developer
,
v_dev_status -- Status available for developer
,
v_message
-- Execution Message
);
EXIT WHEN v_request_completed;
END LOOP;
END IF;
pr_print_debug('Invoice Approval Workflow completed with request id = ' ||
l_sub_request_id,1);
p_request_id := l_sub_request_id;
EXCEPTION
WHEN OTHERS THEN
pr_print_debug('Error in submiting Invoice Approval Workflow Program: ' ||
SQLERRM,1);
errbuf := 'Error in submiting Invoice Approval Workflow Program: '||SQLERRM;
retcode := 2;
END;
END LOOP;
END pr_approve_invoice;
No comments:
Post a Comment