CREATE OR REPLACE PACKAGE XXDEV_FND_CONCPRG_REGISTR
AS
--V_EXECUTABLE VARCHAR2(50):='XXC_ORDER_DETAILS';
--V_APPLICATION VARCHAR2(20):='Order Management';
--V_CPROGRAM VARCHAR2(50):='ORDER_DETAILS_XXC';
V_EXEC NUMBER(2);
V_CP NUMBER(2);
V_REQ_ID NUMBER(10);
PROCEDURE XXC_FND_CONCPRG_EXECUTABLE(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2);
PROCEDURE XXC_FND_CONCPRG_DEFINE(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2) ;
PROCEDURE XXC_FND_CONCPRG_PARAMETER(V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2);
PROCEDURE XXC_FND_CONCPRG_ADDTOGROUP(V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2);
PROCEDURE XXC_FND_CONCPRG_SUBMIT(V_CPROGRAM VARCHAR2);
PROCEDURE XXC_FND_CONCPRG_WAIT_REQUEST;
PROCEDURE XXC_FND_CONCPRG_MAIN(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2);
END;
/
------------------------------------------------------------------------------
CREATE OR REPLACE PACKAGE BODY XXDEV_FND_CONCPRG_REGISTR
AS
/*
Author : A. Devendra Naidu
Created_Date : 08-AUG-2012
Last_Update_by :
Last_Updated_Date :
Purpose : Used register Concurrent Progaram into apps (by creating
executable,define and submit the concurrenr program)
*/
PROCEDURE XXC_FND_CONCPRG_EXECUTABLE(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2)
IS
BEGIN
SELECT COUNT(*) INTO V_EXEC
FROM FND_EXECUTABLES
WHERE EXECUTABLE_NAME=V_EXECUTABLE;
IF V_EXEC=0 THEN
FND_GLOBAL.APPS_INITIALIZE( USER_ID =>1318,
RESP_ID =>21623,
RESP_APPL_ID =>660);
FND_PROGRAM.EXECUTABLE (
executable =>V_EXECUTABLE,
application =>V_APPLICATION,
short_name =>V_EXECUTABLE,
execution_method =>'Oracle Reports',
execution_file_name =>V_EXECUTABLE
);
COMMIT;
DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY CREATED EXECUTABLE NAME IS '||V_EXECUTABLE) ;
ELSE
DBMS_OUTPUT.PUT_LINE('THIS EXECUTABLE '||V_EXECUTABLE||'IS ALREADY CREATED');
END IF;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_EXECUTABLE;
PROCEDURE XXC_FND_CONCPRG_DEFINE(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2)
IS
BEGIN
SELECT COUNT(*)
INTO V_EXEC
FROM FND_EXECUTABLES
WHERE EXECUTABLE_NAME=V_EXECUTABLE;
IF V_EXEC=1 THEN
--DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY CREATED EXECUTABLE NAME IS '||V_EXECUTABLE) ;
SELECT COUNT(*) INTO V_CP
FROM FND_CONCURRENT_PROGRAMS
WHERE CONCURRENT_PROGRAM_NAME =V_CPROGRAM;
IF V_CP=0 THEN
FND_GLOBAL.APPS_INITIALIZE( USER_ID =>1318,
RESP_ID =>21623,
RESP_APPL_ID =>660);
FND_PROGRAM.REGISTER (
program =>V_CPROGRAM,
application =>V_APPLICATION,
enabled =>'Y',
short_name =>V_CPROGRAM,
executable_short_name =>V_EXECUTABLE,
executable_application =>V_APPLICATION,
style =>'A4',
output_type =>'TEXT',
use_in_srs => 'Y'
) ;
COMMIT;
DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY CREATED CONCURRENT PROGRAM '||V_CPROGRAM) ;
ELSE
DBMS_OUTPUT.PUT_LINE('CONCURRENT PROGRAM IS NOT CREATED'||SQLCODE||SQLERRM);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('THIS EXECUTABLE'||V_EXECUTABLE||' IS NOT CREATED ');
END IF;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_DEFINE;
PROCEDURE XXC_FND_CONCPRG_PARAMETER(V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2)
IS
BEGIN
SELECT COUNT(*) INTO V_CP
FROM FND_CONCURRENT_PROGRAMS
WHERE CONCURRENT_PROGRAM_NAME =V_CPROGRAM;
IF V_CP=1 THEN
BEGIN
--DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY CREATED CONCURRENT PROGRAM '||V_EXECUTABLE) ;
FND_GLOBAL.APPS_INITIALIZE( USER_ID =>1318,
RESP_ID =>21623,
RESP_APPL_ID =>660);
FND_PROGRAM.PARAMETER(
program_short_name =>V_CPROGRAM,
application =>V_APPLICATION,
sequence =>10,
parameter =>'P1',
-- enabled => 'Y',
value_set =>'DEV_P1',
display_size =>50,
description_size =>20,
concatenated_description_size =>20,
prompt =>'P_ORDER1',
token =>'P_ORDER1'
);
COMMIT;
DBMS_OUTPUT.PUT_LINE(' SUCCESSFULLY CREATED PARAMETER FOR CONCURRENT PROGRAM '||V_CPROGRAM);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END;
--PARAMETERS ARE STORED IN FND_DESCR_FLEX_COL_USAGE_VL
BEGIN
FND_PROGRAM.PARAMETER(
program_short_name =>V_CPROGRAM,
application =>V_APPLICATION,
sequence =>20,
parameter =>'P2',
-- enabled => 'Y',
value_set =>'DEV_P1',
display_size =>50,
description_size =>20,
concatenated_description_size =>20,
prompt =>'P_ORDER2',
token =>'P_ORDER2'
);
COMMIT;
DBMS_OUTPUT.PUT_LINE(' SUCCESSFULLY CREATED PARAMETER FOR CONCURRENT PROGRAM '||V_CPROGRAM) ;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END;
ELSE
DBMS_OUTPUT.PUT_LINE('CONCURRENT PROGRAM '||V_CPROGRAM||' IS NOT CREATED') ;
END IF;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_PARAMETER;
PROCEDURE XXC_FND_CONCPRG_ADDTOGROUP(V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2)
IS
BEGIN
SELECT COUNT(*) INTO V_CP
FROM FND_CONCURRENT_PROGRAMS
WHERE CONCURRENT_PROGRAM_NAME =V_CPROGRAM;
IF V_CP=1 THEN
BEGIN
FND_GLOBAL.APPS_INITIALIZE( USER_ID =>1318,
RESP_ID =>21623,
RESP_APPL_ID =>660);
FND_PROGRAM.ADD_TO_GROUP(
program_short_name =>V_CPROGRAM,
program_application =>V_APPLICATION,
request_group =>'OM Concurrent Programs',
group_application =>'Order Management'
);
COMMIT;
DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY ATTACHED CONCURRENT PROGRAM TO REQUEST GROUP') ;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END;
ELSE
DBMS_OUTPUT.PUT_LINE('CONCURRENT PROGRAM '||V_CPROGRAM||' IS NOT CREATED') ;
END IF;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_ADDTOGROUP;
PROCEDURE XXC_FND_CONCPRG_SUBMIT(V_CPROGRAM VARCHAR2)
IS
BEGIN
BEGIN
FND_GLOBAL.APPS_INITIALIZE( USER_ID =>1318,
RESP_ID =>21623,
RESP_APPL_ID =>660);
V_REQ_ID:=FND_REQUEST.SUBMIT_REQUEST(
application => 'ont',
program =>V_CPROGRAM,
ARGUMENT1 =>'10',
ARGUMENT2 =>'1000'
);
COMMIT;
DBMS_OUTPUT.PUT_LINE('SUCCESSFULLY SUBMITTED. REQUEST ID IS'||V_REQ_ID);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_SUBMIT;
PROCEDURE XXC_FND_CONCPRG_WAIT_REQUEST
IS
V_REQ_ID2 NUMBER(2);
V_Phase Varchar2(10);
V_Status Varchar2(10);
V_Phase1 Varchar2(10);
V_Status1 Varchar2(10);
V_Phase2 Varchar2(10);
V_Status2 Varchar2(10);
V_b BOOLEAN;
BEGIN
SELECT COUNT(*) INTO V_REQ_ID2
FROM FND_CONCURRENT_REQUESTS
WHERE REQUEST_ID=V_REQ_ID;
IF V_REQ_ID2=1 THEN
--DBMS_OUTPUT.PUT_LINE('SUCCEEFULLY SUBMITTED REQUEST ID IS '||V_REQ_ID) ;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(user_id =>1318,resp_id=>21623,resp_appl_id=>660);
V_B:=FND_CONCURRENT.wait_for_request(
request_id =>V_Req_Id,
interval => 60,
max_wait => 0,
phase => v_phase,
status => v_status,
dev_phase => v_phase1,
dev_status => v_status1,
message => v_Phase2
);
COMMIT;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END;
if v_phase='Completed'and v_status ='Normal' Then
DBMS_OUTPUT.PUT_LINE ( V_req_id ||' Sucessfully Completed With Status Normal');
ELSIF v_phase='Completed'and v_status ='Error' Then
DBMS_OUTPUT.PUT_LINE ( V_req_id ||' Sucessfully Completed With Status Error');
ELSIF v_phase='Completed'and v_status ='Warning' Then
DBMS_OUTPUT.PUT_LINE (V_req_id ||' Sucessfully Completed With Status Warning');
ELSE
DBMS_OUTPUT.PUT_LINE (V_req_id || V_Phase||' '||V_Status);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('ERROR FOR SUBMITION THE REQUEST. REQUEST ID IS '||V_REQ_ID) ;
END IF;
END XXC_FND_CONCPRG_WAIT_REQUEST;
PROCEDURE XXC_FND_CONCPRG_MAIN(V_EXECUTABLE VARCHAR2,V_APPLICATION VARCHAR2,V_CPROGRAM VARCHAR2)
IS
BEGIN
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_EXECUTABLE;
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_DEFINE;
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_PARAMETER;
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_ADDTOGROUP;
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_SUBMIT;
XXDEV_FND_CONCPRG_REGISTRATION.XXC_FND_CONCPRG_WAIT_REQUEST;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR OUT HERE'||SQLCODE||SQLERRM);
END XXC_FND_CONCPRG_MAIN;
END XXDEV_FND_CONCPRG_REGISTR;
/
EXEC XXDEV_FND_CONCPRG_REGISTR.XXC_FND_CONCPRG_MAIN('XXC_ORDER_DETAILS','Order Management','ORDER_DETAILS_XXC')