Submit the Concurrent Program from backend

on Thursday, February 26, 2009

The following is the Sample Code to Submit the Concurrent Programfrom the backend.

Note:- This is the Concurrent Program, not the RequestSet. To Submit the Request Set from the
backend, We have different API.


DECLARE
l_success NUMBER;
BEGIN
BEGIN

fnd_global.apps_initialize( user_id=> 2572694, resp_id => 50407, resp_appl_id => 20003);


-- If you are directlyrunning from the database using the TOAD, SQL-NAVIGATOR or SQL*PLUS etc. Then you need to Initialize the Apps.
-- In thiscase use the above API to Initialize the APPS. If you are using same code insome procedure and running directly fromapplication then you don't need to initalize.
-- Thenyou can comment the above API.


l_success:=
fnd_request.submit_request

('XXAPP',-- Application Short name of the Concurrent Program.
'XXPRO_RPT', --Program Short Name.
'
Program For testing the backendReport', -- Descriptionof the Program.

SYSDATE, --Submitted date. Always give the SYSDATE.

FALSE, --Always give the FLASE.

'1234' --Passing the Value to the First Parameter of the report.
);

COMMIT;


--Note:- In theabove request Run, I have created the Report, which has one parameter.

IFl_success = 0
THEN
-- fnd_file.put_line(fnd_file.LOG, 'Request submission For this store FAILED' );
DBMS_OUTPUT.PUT_LINE('Request submission For this store FAILED' );
ELSE
-- fnd_file.put_line(fnd_file.LOG, 'Request submission for this store SUCCESSFUL');
DBMS_OUTPUT.PUT_LINE('Request submission For this store SUCCESSFUL' );
ENDIF;


--Note:- If you arerunning directly from database, use DBMS API to display.
--If you are
running directly fromApplication, then Use the fnd_file API to write themessage in the log file.

END;



Write message in Log or Out file

on

PROCEDURE write(p_type IN VARCHAR2, p_message IN VARCHAR2)IS
/************************************************************************
Purpose : Procedure writes to the log file or output file based on type.
O=Output File, L=Log File
*************************************************************************/
BEGIN
IF p_type = 'L' THEN
fnd_file.put_line (fnd_file.log, p_message);
ELSIF p_type = 'O' THEN
fnd_file.put_line (fnd_file.output, p_message);
END IF;
END write;
The above write procedure can be used in other Procedure/Function in the package to write any information in the Log or Out files.
PROCEDURE main(errbuf OUT VARCHAR2, retcode OUT NUMBER, p_par1 IN NUMBER)
IS
v_errbuf VARCHAR2(1000) := NULL;
v_retcode NUMBER := 0;
v_file_name VARCHAR2(100);
BEGIN
v_retcode := 0;
v_file_name := fnd_profile.value('XYZ');
IF v_file_name IS NULL THEN
write('O','Profile XYZ is not defined or the value is not set');
retcode := 2;
RETURN;
END IF;
END;
Note:- In the above Procedure, I am using the write Procedure and returning 2 for the retcode (0 - Complete, 1- Warning and 2 will be for Error).
This is one time process and you will realise, how much helpful it will be when ever you have to right something in log or out file.