Sunteți pe pagina 1din 19

PL/SQL Script to Create a Concurrent Program

from backend
We need to use FND_PROGRAM.REGISTER api to create an concurrent program from backend
database, below is the sample script.

Creating the Concurrent Program from backend:

/******************************************************
*PURPOSE: To Create a Concurrent Program from backend *
*AUTHOR: Shailender Thallam *
*******************************************************/
--
DECLARE
--
l_program VARCHAR2 (200);
l_application VARCHAR2 (200);
l_enabled VARCHAR2 (200);
l_short_name VARCHAR2 (200);
l_description VARCHAR2 (200);
l_executable_short_name VARCHAR2 (200);
l_executable_application VARCHAR2 (200);
l_execution_options VARCHAR2 (200);
l_priority NUMBER;
l_save_output VARCHAR2 (200);
l_print VARCHAR2 (200);
l_cols NUMBER;
l_rows NUMBER;
l_style VARCHAR2 (200);
l_style_required VARCHAR2 (200);
l_printer VARCHAR2 (200);
l_request_type VARCHAR2 (200);
l_request_type_application VARCHAR2 (200);
l_use_in_srs VARCHAR2 (200);
l_allow_disabled_values VARCHAR2 (200);
l_run_alone VARCHAR2 (200);
l_output_type VARCHAR2 (200);
l_enable_trace VARCHAR2 (200);
l_restart VARCHAR2 (200);
l_nls_compliant VARCHAR2 (200);
l_icon_name VARCHAR2 (200);
l_language_code VARCHAR2 (200);
l_mls_function_short_name VARCHAR2 (200);
l_mls_function_application VARCHAR2 (200);
l_incrementor VARCHAR2 (200);
l_refresh_portlet VARCHAR2 (200);
l_check VARCHAR2 (2);
--
BEGIN
--
l_program := 'Concurrent program registered from backend
- OracleAppsDNA';
l_application := 'CUSTOM Custom';
l_enabled := 'Y';
l_short_name := 'XX_ORACLEAPPSDNA_CP';
l_description := 'OracleAppsDNA Test Program';
l_executable_short_name := 'XX_ORACLEAPPSDNA_EXE';
l_executable_application := 'CUSTOM Custom';
l_execution_options := NULL;
l_priority := NULL;
l_save_output := 'Y';
l_print := 'Y';
l_cols := NULL;
l_rows := NULL;
l_style := NULL;
l_style_required := 'N';
l_printer := NULL;
l_request_type := NULL;
l_request_type_application := NULL;
l_use_in_srs := 'Y';
l_allow_disabled_values := 'N';
l_run_alone := 'N';
l_output_type := 'TEXT';
l_enable_trace := 'N';
l_restart := 'Y';
l_nls_compliant := 'Y';
l_icon_name := NULL;
l_language_code := 'US';
l_mls_function_short_name := NULL;
l_mls_function_application := NULL;
l_incrementor := NULL;
l_refresh_portlet := NULL;
--
--Calling API to create concurrent program definition
--
apps.fnd_program.register
(program => l_program,
application => l_application,
enabled => l_enabled,
short_name => l_short_name,
description => l_description,
executable_short_name => l_executable_short_name,
executable_application => l_executable_application,
execution_options => l_execution_options,
priority => l_priority,
save_output => l_save_output,
print => l_print,
cols => l_cols,
ROWS => l_rows,
STYLE => l_style,
style_required => l_style_required,
printer => l_printer,
request_type => l_request_type,
request_type_application => l_request_type_application,
use_in_srs => l_use_in_srs,
allow_disabled_values => l_allow_disabled_values,
run_alone => l_run_alone,
output_type => l_output_type,
enable_trace => l_enable_trace,
restart => l_restart,
nls_compliant => l_nls_compliant,
icon_name => l_icon_name,
language_code => l_language_code,
mls_function_short_name => l_mls_function_short_name,
mls_function_application => l_mls_function_application,
incrementor => l_incrementor,
refresh_portlet => l_refresh_portlet
);
--
COMMIT;
--
BEGIN
--
--To check whether Concurrent Program is registered or not
--
SELECT 'Y'
INTO l_check
FROM fnd_concurrent_programs
WHERE concurrent_program_name = 'XX_ORACLEAPPSDNA_CP';
--
DBMS_OUTPUT.put_line ('Concurrent Program Registered Successfully');
--
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.put_line ('Concurrent Program Registration Failed');
END;
END;
View from front end application:

1. The various output types are PS, PDF, HTML, TEXT, PCL, XML.
2. The above script inserts data into FND_CONCURRENT_PROGRAMS and
FND_CONCURRENT_PROGRAMS_TL tables
PL/SQL Script to Create a Concurrent Program
Parameter from backend
We need to use FND_PROGRAM.PARAMETER api to create an concurrent program parameter
from backend database, below is the sample script.

Creating the Concurrent Program Parameter from backend:

/****************************************************************
*PURPOSE: To Create a Concurrent Program Parameter from backend *
*AUTHOR: Shailender Thallam *
*****************************************************************/
--
DECLARE
--
l_program_short_name VARCHAR2 (200);
l_application VARCHAR2 (200);
l_sequence NUMBER;
l_parameter VARCHAR2 (200);
l_description VARCHAR2 (200);
l_enabled VARCHAR2 (200);
l_value_set VARCHAR2 (200);
l_default_type VARCHAR2 (200);
l_default_value VARCHAR2 (200);
l_required VARCHAR2 (200);
l_enable_security VARCHAR2 (200);
l_range VARCHAR2 (200);
l_display VARCHAR2 (200);
l_display_size NUMBER;
l_description_size NUMBER;
l_concatenated_descr_size NUMBER;
l_prompt VARCHAR2 (200);
l_token VARCHAR2 (200);
l_cd_parameter VARCHAR2 (200);
l_check VARCHAR2 (2);
--
BEGIN
--
l_program_short_name := 'XX_ORACLEAPPSDNA_CP';
l_application := 'CUSTOM Custom';
l_sequence := 10;
l_parameter := 'Employee Name';
l_description := 'Employee Name';
l_enabled := 'Y';
l_value_set := '240 Characters';
l_default_type := NULL;
l_default_value := NULL;
l_required := 'N';
l_enable_security := 'N';
l_range := NULL;
l_display := 'Y';
l_display_size := 50;
l_description_size := 50;
l_concatenated_descr_size := 50;
l_prompt := 'Employee Name';
l_token := NULL;
l_cd_parameter := NULL;
--
--Calling API to create a Parameter for a concurrent program definition
--
apps.fnd_program.parameter
(program_short_name => l_program_short_name,
application => l_application,
SEQUENCE => l_sequence,
parameter => l_parameter,
description => l_description,
enabled => l_enabled,
value_set => l_value_set,
default_type => l_default_type,
DEFAULT_VALUE => l_default_value,
required => l_required,
enable_security => l_enable_security,
RANGE => l_range,
display => l_display,
display_size => l_display_size,
description_size => l_description_size,
concatenated_description_size => l_concatenated_descr_size,
prompt => l_prompt,
token => l_token,
cd_parameter => l_cd_parameter
);
--
COMMIT;
--
BEGIN
--
--To check whether a parameter is assigned to a Concurrent Program or
not
--
SELECT 'Y'
INTO l_check
FROM fnd_descr_flex_column_usages
WHERE descriptive_flexfield_name = '$SRS$.'
|| 'XX_ORACLEAPPSDNA_CP'
AND end_user_column_name = 'Employee Name';
--
dbms_output.put_line ('Concurrent Program Parameter registered
Successfully');
--
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line ('Concurrent Program Parameter Registration
Failed');
END;
--
END;

View from front end application:

1. The above script inserts data into FND_DESCR_FLEX_COL_USAGE_TL and


FND_DESCR_FLEX_COLUMN_USAGES tables
PL/SQL Script to Add a Concurrent Program to a
Request Group from backend
We can not only create a concurrent program from backend but also assign the concurrent program
to a Request Group by FND_PROGRAM.ADD_TO_GROUP api, below is the sample script.

Adding a Concurrent Program to Request Group from backend:

/*********************************************************
*PURPOSE: To Add a Concurrent Program to a Request Group *
* from backend *
*AUTHOR: Shailender Thallam *
**********************************************************/
--
DECLARE
l_program_short_name VARCHAR2 (200);
l_program_application VARCHAR2 (200);
l_request_group VARCHAR2 (200);
l_group_application VARCHAR2 (200);
l_check VARCHAR2 (2);
--
BEGIN
--
l_program_short_name := 'XX_ORACLEAPPSDNA_CP';
l_program_application := 'CUSTOM Custom';
l_request_group := 'System Administrator Reports';
l_group_application := 'Application Object Library';
--
--Calling API to assign concurrent program to a reqest group
--
apps.fnd_program.add_to_group (program_short_name =>
l_program_short_name,
program_application =>
l_program_application,
request_group => l_request_group,
group_application => l_group_application
);
--
COMMIT;
--
BEGIN
--
--To check whether a paramter is assigned to a Concurrent Program or
not
--
SELECT 'Y'
INTO l_check
FROM fnd_request_groups frg,
fnd_request_group_units frgu,
fnd_concurrent_programs fcp
WHERE frg.request_group_id = frgu.request_group_id
AND frg.application_id = frgu.application_id
AND frgu.request_unit_id = fcp.concurrent_program_id
AND frgu.unit_application_id = fcp.application_id
AND fcp.concurrent_program_name = 'XX_ORACLEAPPSDNA_CP';
--
dbms_output.put_line ('Adding Concurrent Program to Request Group
Succeeded');
--
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line ('Adding Concurrent Program to Request Group
Failed');
END;
END;

View from front end application:


PL/SQL Script to Create an Executable from
backend
We need to use FND_PROGRAM.EXECUTABLE api to create an executable from backend
database, below is the sample script.

Creating the Executable from backed:

/**************************************************

*PURPOSE: To Create an Executable from backend *

*AUTHOR: Shailender Thallam *

***************************************************/

--

DECLARE

--

l_executable VARCHAR2 (200);

l_application VARCHAR2 (200);

l_short_name VARCHAR2 (200);

l_description VARCHAR2 (200);

l_execution_method VARCHAR2 (200);

l_execution_file_name VARCHAR2 (200);

l_subroutine_name VARCHAR2 (200);

l_icon_name VARCHAR2 (200);

l_language_code VARCHAR2 (200);

l_execution_file_path VARCHAR2 (200);

l_check VARCHAR2 (2);

--

BEGIN
--

l_executable := 'XX_ORACLEAPPSDNA_EXE';

l_application := 'CUSTOM Custom'; -- Your target application name

l_short_name := 'XX_ORACLEAPPSDNA_EXE';

l_description := 'Test Script for creating Executable from Backend';

l_execution_method := 'PL/SQL Stored Procedure';

l_execution_file_name := 'XX_ORACLEAPPSDNA_PKG.MAIN';

l_subroutine_name := NULL;

l_icon_name := NULL;

l_language_code := 'US';

l_execution_file_path := NULL;

--

--Calling API to create executable

--

apps.fnd_program.executable (executable => l_executable,

application => l_application,

short_name => l_short_name,

description => l_description,

execution_method => l_execution_method,

execution_file_name =>

l_execution_file_name,

subroutine_name => l_subroutine_name,

icon_name => l_icon_name,

language_code => l_language_code,

execution_file_path => l_execution_file_path

);

COMMIT;
BEGIN

--

--To check whether executable is created or not

--

SELECT 'Y'

INTO l_check

FROM fnd_executables

WHERE executable_name = 'XX_ORACLEAPPSDNA_EXE';

--

DBMS_OUTPUT.put_line ('Executable Created Successfully');

--

EXCEPTION

WHEN NO_DATA_FOUND

THEN

DBMS_OUTPUT.put_line ('Executable Registration Failed');

END;

END;
View from front end application:

1. The above script inserts data into FND_EXECUTABLES and FND_EXECUTABLES_TL


tables
2. Execute the below query to find out different Execution Methods

SELECT MEANING "Execution_Method"

FROM fnd_lookup_values

WHERE lookup_type = 'CP_EXECUTION_METHOD_CODE'

AND enabled_flag = 'Y';

SQL Query to findout information about a


Concurrent Request
/
**************************************************************************
*PURPOSE: To find out information about a Concurrent Request
*
**************************************************************************
/
SELECT fcrs.request_id, fcrs.user_concurrent_program_name,
fcrs.actual_start_date, fcrs.actual_completion_date,
FLOOR(((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60)/3600)||':'||
FLOOR((((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60) -
FLOOR(((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60)/3600)*3600)/60)||':'||
round((((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60) -
FLOOR(((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60)/3600)*3600 -
(FLOOR((((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60) -
FLOOR(((fcrs.actual_completion_date-
fcrs.actual_start_date)*24*60*60)/3600)*3600)/60)*60) ))
"HOURS:MINUTES:SECONDS",
fcrs.argument_text, fcrs.requestor,
DECODE (fcrs.status_code,
'A', 'Waiting',
'B', 'Resuming',
'C', 'Normal',
'D', 'Cancelled',
'E', 'Errored',
'F', 'Scheduled',
'G', 'Warning',
'H', 'On Hold',
'I', 'Normal',
'M', 'No Manager',
'Q', 'Standby',
'R', 'Normal',
'S', 'Suspended',
'T', 'Terminating',
'U', 'Disabled',
'W', 'Paused',
'X', 'Terminated',
'Z', 'Waiting',
fcrs.status_code
) "Status",
decode(fcrs.phase_code,
'C','Completed',
'I','Inactive',
'R','Running',
'A','Active',
fcrs.phase_code) "Phase Code", fcrs.completion_text,
fcrs.responsibility_application_id, frt.responsibility_name,
fcrs.save_output_flag, fcrs.request_date ,
decode (fcrs.execution_method_code,
'B', 'Request Set Stage Function',
'Q', 'SQL*Plus',
'H', 'Host',
'L', 'SQL*Loader',
'A', 'Spawned',
'I', 'PL/SQL Stored Procedure',
'P', 'Oracle Reports',
'S', 'Immediate',
fcrs.execution_method_code
) execution_method , fcrs.concurrent_program_id,
fcrs.program_short_name, fcrs.printer,
fcrs.parent_request_id
FROM fnd_conc_req_summary_v fcrs,
fnd_responsibility_tl frt
WHERE 1 = 1
AND user_concurrent_program_name LIKE '%'
--and argument_text LIKE '%'
--and requestor not in ('SYSADMIN','INVADMIN')
--and request_id = 9686914
AND frt.language = 'US' AND fcrs.responsibility_id = frt.responsibility_id
--and fcrs.actual_start_date < sysdate
--and fcrs.phase_code = 'R'
--and fcrs.status_code = 'X'
--and fcrs.status_code not in ('P','D','Q','C')
--and trunc(fcrs.actual_start_date) =trunc(sysdate)
--and trunc(fcrs.actual_completion_date) = trunc(sysdate)
ORDER BY fcrs.actual_start_date DESC;

How to Submit concurrent Program


from PL/SQL - Oracle
We can use FND_REQUEST.SUBMIT_REQUEST to submit the concurrent program
from backend. The following code will submit the oracle seeded program Reserve
Orders.

Submitting Concurrent Program From PL SQL


Declare
v_user_id NUMBER;
v_app_id NUMBER;
v_resp_id NUMBER;
v_resp_name VARCHAR2 (100);
v_request_id NUMBER;
v_app_name VARCHAR2 (20);
v_req_phase VARCHAR2 (100);
v_req_status VARCHAR2 (100);
v_req_dev_phase VARCHAR2 (100);
v_req_dev_status VARCHAR2 (100);
v_req_message VARCHAR2 (100);
v_req_return_status BOOLEAN;
use_reservation_time_fence VARCHAR2 (10);
resertvaton_run_types VARCHAR2 (100);
item VARCHAR2 (100);
warehouse VARCHAR2 (100);
booked VARCHAR2 (100);
reservation_mode VARCHAR2 (500);

order_by VARCHAR2 (100);

BEGIN

/*First we need to initialize the apps, this will automatically done when we submit the program
from application directly*/

BEGIN
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE user_name = 'USER NAME';
EXCEPTION
WHEN OTHERS
THEN
v_user_id := NULL;
END;

BEGIN
SELECT fa.application_id, fr.responsibility_id,
fr.responsibility_name, fa.application_short_name
INTO v_app_id, v_resp_id,
v_resp_name, v_app_name
FROM fnd_responsibility_vl fr, fnd_application fa
WHERE responsibility_name LIKE 'Order Management Super User'
AND fr.application_id = fa.application_id;

EXCEPTION
WHEN OTHERS
THEN
v_app_id:=null;
v_resp_id:=null;
v_resp_name:=null;
v_app_name:=null;
END;

-- Initializing apps
fnd_global.apps_initialize (user_id => v_user_id,
resp_id => v_resp_id,
resp_appl_id => v_app_id
);

/*After Initializing we can straightaway submit the concurrent program */


-- Submitting Request

use_reservation_time_fence : = 'Y';
resertvaton_run_types : = 'RESERVE';
booked : = 'Y';
reservation_mode : = 'PARTIAL';
order_by : = 'ORDERED_DATE';
item : = Inventory_item_id;
warehouse : = Organization_id;

/*These are the parameters of the reserve orders program which will passed as arguments
through fnd_request.submit_request function*/

v_request_id :=
fnd_request.submit_request (v_app_name, /* Short name of the application
under which the program is registered in this it will be ONT since the Reserve Order program is
registered under order management*/
'OMRSVORD', -- Short name of the concurrent program needs to
submitted
NULL, -- concurrent program description OPTIONAL parameter
SYSDATE, /* Start time parameter which can be used to mention the
actual start of the concurrent program which once again OPTIONAL*/
FALSE, /* Sub request parameters if this program is need to be
submitted from another running request then TRUE needs to passed, but default is FALSE and an
OPTIONAL parameter*/
argument1 => use_reservation_time_fence,
argument2 => '',
argument3 => '',
argument4 => '',
argument5 => '',
argument6 => '',
argument7 => warehouse,
argument8 => item,
argument9 => '',
argument10 => '',
argument11 => '',
argument12 => '',
argument13 => '',
argument14 => '',
argument15 => '',
argument16 => '',
argument17 => '',
argument18 => '',
argument19 => booked,
argument20 => reservation_mode,
argument21 => '',
argument22 => '',
argument23 => '',
argument24 => '',
argument25 => resertvaton_run_types,
argument26 => '',
argument27 => '',
argument28 => order_by,
argument29 => '',
argument30 => '',
argument31 => ''
);

100 arguments are available through which additional parameters can be passed to the
concurrent program.

In case of Reserve Order concurrent program it is mandatory to pass 31 arguments to it


and the order of the parameters passing here must match the order defined in the
concurrent program.

Passing unequal number (or) unmatched additional parameters will complete the
concurrent program with ERROR Status.

COMMIT;

Only after the explicit commit the submitted requested will be available in the
fnd_concurrent_request table and in the Oracle apps.

DBMS_OUTPUT.put_line ('Concurrent Program Req ID' || v_request_id);

/* fnd_concurrent.wait_for_request function can be used to get the result of the


submitted concurrent program.
This is just like we are refreshing the concurrent program in Application until we get its
phase as completed */

-- Concurrent Program Status


IF v_request_id <> 0 AND v_request_id IS NOT NULL
THEN
LOOP
v_req_return_status :
fnd_concurrent.wait_for_request (v_request_id, -- request ID for which
results need to be known
60, --interval parameter time between checks
default is 60 Seconds
0, -- Max wait default is 0 , this is the
maximum amount of time a program should wait for it to get completed
v_req_phase,
v_req_status,
v_req_dev_phase,
v_req_dev_status,
v_req_message
);
/*Others are output parameters to get the phase and status of the submitted concurrent
program*/
EXIT WHEN UPPER (v_req_phase) = 'COMPLETED'
OR UPPER (v_req_status) IN
('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;

DBMS_OUTPUT.put_line ('Concurrent Program Status' || v_req_status);

EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Main Exception'
|| SQLERRM
|| DBMS_UTILITY.format_error_backtrace
);
End;

If you have any queries related to this, do comment below we are ready to rectify your
queries in ease..
Tags: Oracle apps,
FND_REQUEST.SUBMIT_REQUEST, fnd_concurrent.wait_for_request,plsql for
submitting concurrent program, fnd packages

S-ar putea să vă placă și