Monday 1 April 2013

Submitting Concurrent Program from Back-end

We first need to initialize oracle applications session using:

fnd_global.apps_initialize(user_id,responsibility_id,application_responsibility_id)
and then run fnd_request.submit_request

If you are directly running from the database using the TOAD, SQL NAVIGATOR or SQL*PLUS etc. Then you need to initialize the Apps. In this case use the above API to Initialize the APPS.

DECLARE
  l_request_id NUMBER(30);

BEGIN


 FND_GLOBAL.APPS_INITIALIZE (user_id => 1318, resp_id => 59966, resp_appl_id => 20064);
 
  l_request_id:= FND_REQUEST.SUBMIT_REQUEST
('XXMZ' --Application Short name,
 'VENDOR_FORM'-- Concurrent Program Short Name );
                         
  DBMS_OUTPUT.PUT_LINE(l_request_id);
  commit;
END;

**************************************************************
If you are using same code in some procedure and running directly from application then you don't need to initialize. Then you can comment the fnd_global.apps_initialize API.

DECLARE
l_success NUMBER;
BEGIN
BEGIN

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

l_success :=
fnd_request.submit_request
('XXAPP', -- Application Short name of the Concurrent Program.
'XXPRO_RPT', -- Program Short Name.
'Program For testing the backend Report', -- Description of 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 the above request Run, I have created the Report, which has one parameter.

IF l_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' );
END IF;

END;

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

Exp:
PROCEDURE URSTING_PRG (
errbuf OUT VARCHAR2,
retcode OUT NUMBER,
v_req_id OUT NUMBER,
v_dev_status OUT VARCHAR2,
v_dev_phase OUT VARCHAR2,
v_request_status OUT BOOLEAN,
p_request_id number
) IS
v_layout BOOLEAN;
--v_request_status BOOLEAN;
v_phase VARCHAR2 (2000);
v_wait_status VARCHAR2 (2000);
--v_dev_phase VARCHAR2 (2000);
--v_dev_status VARCHAR2 (2000);
v_message VARCHAR2 (2000);
BEGIN
FND_FILE.PUT_LINE(FND_FILE.LOG,'  Starting of Bursting Procedure BURSTING_PRG');
   v_req_id :=NULL;
FND_FILE.PUT_LINE(FND_FILE.LOG,'  Initializing Apps');
    FND_GLOBAL.Apps_Initialize(FND_GLOBAL.USER_ID, FND_GLOBAL.RESP_ID, FND_GLOBAL.RESP_APPL_ID);
                                v_layout := FND_REQUEST.ADD_LAYOUT('XDO'
                                                                   ,'BURST_STATUS_REPORT'
                                                                       ,'en'
                                                                       ,'US'
                                                                       ,'PDF');
                                v_req_id:=   FND_REQUEST.SUBMIT_REQUEST(
                                            'XDO',
                                            'XDOBURSTREP',
                                            '',
                                            '',
                                            FALSE,
                                            p_request_id,'N',
                                            chr(0),'','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','',
                                            '','','','','','','','','','');
commit;
FND_FILE.PUT_LINE(FND_FILE.LOG,'   Submitted the Bursting Program' || '-'||  v_req_id);
FND_FILE.PUT_LINE(FND_FILE.LOG,'   Waiting for the Bursting Program');
 v_request_status:=
                                        fnd_concurrent.wait_for_request
                                        (request_id => v_req_id,
                                        INTERVAL => 5,
                                        max_wait => 600,
                                        phase => v_phase,
                                        status => v_wait_status,
                                        dev_phase => v_dev_phase,
                                        dev_status => v_dev_status,
                                        MESSAGE => v_message);
commit;
FND_FILE.PUT_LINE(FND_FILE.LOG,'  Bursting Program Request Phase' || '-'||  v_dev_phase);
FND_FILE.PUT_LINE(FND_FILE.LOG,'  Bursting Program Request Dev status' || '-'||  v_dev_status);
                               EXCEPTION
                 WHEN OTHERS THEN
                                      v_req_id := null;
FND_FILE.PUT_LINE(FND_FILE.LOG,'  Ending of Bursting Procedure GEPS_BURSTING_PRG');
END BURSTING_PRG;

No comments:

Post a Comment