How To Submit Concurrent Program From Backend In Oracle
How To Submit Concurrent Program From Backend In Oracle
create or replace PROCEDURE XXSD_REPORT_SUBMIT_PROC (
errbuf OUT NUMBER,
retcode OUT VARCHAR2,
P_DEPT_NO IN NUMBER) AS
l_request_id NUMBER;
v_phase VARCHAR2 (20);
v_dev_phase VARCHAR2 (20);
v_dev_status VARCHAR2 (20);
v_message VARCHAR2 (20);
v_wait_status VARCHAR2 (20);
l_return_status BOOLEAN;
e_submit_error EXCEPTION;
e_program_status EXCEPTION;
e_program_status1 EXCEPTION;
v_lay BOOLEAN;
l_user_id number := 15570; --fnd_global.user_id;
l_resp_id number := 20419; --fnd_global.resp_id;
l_resp_appl_id number := 0 ;-- fnd_global.resp_appl_id;
--select * from fnd_user where user_name = 'DEVELOPER'
--
--select * from fnd_responsibility_tl where RESPONSIBILITY_NAME = 'Application Developer'
--
--select * from fnd_application_tl where APPLICATION_NAME = 'Application Object Library'
BEGIN
BEGIN
fnd_global.APPS_INITIALIZE(l_user_id,l_resp_id, l_resp_appl_id);
END;
l_request_id := 0;
fnd_file.put_line (fnd_file.LOG, '************** Launching (XXSD_MULTI_TEMPLTE_REPORT) Program **************' );
IF P_DEPT_NO = 10 THEN
v_lay :=
fnd_request.add_layout ('XXSD',
'XXSD_Template_1',
'en',
'US',
'EXCEL');
ELSE
v_lay :=
fnd_request.add_layout ('XXSD',
'XXSD_Template_2',
'en',
'US',
'EXCEL');
END IF;
l_request_id :=
fnd_request.submit_request
(application => 'XXSD',
program => 'XXSD_MULTI_TEMPLTE_REPORT',
description => 'XXSD_MULTI_TEMPLTE_REPORT',
start_time => SYSDATE,
sub_request => FALSE,
argument1 => P_DEPT_NO
);
COMMIT;
IF l_request_id = 0 THEN
fnd_file.put_line (fnd_file.LOG, 'Request Not Submitted');
RAISE e_submit_error;
ELSIF l_request_id != 0
THEN
fnd_file.put_line (fnd_file.LOG, 'Request Submitted : ' || l_request_id );
LOOP
l_return_status :=
apps.fnd_concurrent.wait_for_request
(request_id => l_request_id,
INTERVAL => 2,
max_wait => 60,
-- out arguments
phase => v_phase,
status => v_wait_status,
dev_phase => v_dev_phase,
dev_status => v_dev_status,
MESSAGE => v_message
);
EXIT WHEN UPPER (v_phase) = 'COMPLETED' OR UPPER (v_wait_status) IN ('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
fnd_file.put_line (fnd_file.LOG,'(XXSD_MULTI_TEMPLTE_REPORT) Program|| '|| v_dev_phase||' With '||v_dev_status);
END IF;
EXCEPTION WHEN e_program_status THEN
RAISE e_program_status1;
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.LOG, 'Errored In exception'||SQLERRM);
END;
--===========================================
declare
V_CODE VARCHAR2(100);
V_ERROR VARCHAR2(100);
V_DEPT_NO NUMBER:= 10;
begin
XXSD_REPORT_SUBMIT_PROC(V_CODE, V_ERROR, V_DEPT_NO);
end;
--==========================================
create or replace PROCEDURE XXSD_REPORT_SUBMIT_PROC (
errbuf OUT NUMBER,
retcode OUT VARCHAR2,
P_DEPT_NO IN NUMBER) AS
l_request_id NUMBER;
v_phase VARCHAR2 (20);
v_dev_phase VARCHAR2 (20);
v_dev_status VARCHAR2 (20);
v_message VARCHAR2 (20);
v_wait_status VARCHAR2 (20);
l_return_status BOOLEAN;
e_submit_error EXCEPTION;
e_program_status EXCEPTION;
e_program_status1 EXCEPTION;
v_lay BOOLEAN;
l_user_id number := 15570; --fnd_global.user_id;
l_resp_id number := 20419; --fnd_global.resp_id;
l_resp_appl_id number := 0 ;-- fnd_global.resp_appl_id;
--select * from fnd_user where user_name = 'DEVELOPER'
--
--select * from fnd_responsibility_tl where RESPONSIBILITY_NAME = 'Application Developer'
--
--select * from fnd_application_tl where APPLICATION_NAME = 'Application Object Library'
BEGIN
BEGIN
fnd_global.APPS_INITIALIZE(l_user_id,l_resp_id, l_resp_appl_id);
END;
l_request_id := 0;
fnd_file.put_line (fnd_file.LOG, '************** Launching (XXSD_MULTI_TEMPLTE_REPORT) Program **************' );
IF P_DEPT_NO = 10 THEN
v_lay :=
fnd_request.add_layout ('XXSD',
'XXSD_Template_1',
'en',
'US',
'EXCEL');
ELSE
v_lay :=
fnd_request.add_layout ('XXSD',
'XXSD_Template_2',
'en',
'US',
'EXCEL');
END IF;
l_request_id :=
fnd_request.submit_request
(application => 'XXSD',
program => 'XXSD_MULTI_TEMPLTE_REPORT',
description => 'XXSD_MULTI_TEMPLTE_REPORT',
start_time => SYSDATE,
sub_request => FALSE,
argument1 => P_DEPT_NO
);
COMMIT;
IF l_request_id = 0 THEN
fnd_file.put_line (fnd_file.LOG, 'Request Not Submitted');
RAISE e_submit_error;
ELSIF l_request_id != 0
THEN
fnd_file.put_line (fnd_file.LOG, 'Request Submitted : ' || l_request_id );
LOOP
l_return_status :=
apps.fnd_concurrent.wait_for_request
(request_id => l_request_id,
INTERVAL => 2,
max_wait => 60,
-- out arguments
phase => v_phase,
status => v_wait_status,
dev_phase => v_dev_phase,
dev_status => v_dev_status,
MESSAGE => v_message
);
EXIT WHEN UPPER (v_phase) = 'COMPLETED' OR UPPER (v_wait_status) IN ('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
fnd_file.put_line (fnd_file.LOG,'(XXSD_MULTI_TEMPLTE_REPORT) Program|| '|| v_dev_phase||' With '||v_dev_status);
END IF;
EXCEPTION WHEN e_program_status THEN
RAISE e_program_status1;
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.LOG, 'Errored In exception'||SQLERRM);
END;
--===========================================
declare
V_CODE VARCHAR2(100);
V_ERROR VARCHAR2(100);
V_DEPT_NO NUMBER:= 10;
begin
XXSD_REPORT_SUBMIT_PROC(V_CODE, V_ERROR, V_DEPT_NO);
end;
--==========================================
Comments
Post a Comment