Wednesday, 7 June 2017

How To Run Concurrent Program From Back end (Psql) and notify to USER

You can Run Concurrent program from backend by using FND_REQUEST.SUBMIT_REQUEST API.
And By using FND_REQUEST.ADD_NOTIFICATION  API You can send notification mail to particular User.

Below given script is used for one of my client place where we want to run concurrent program from backend.

First you have to initialize apps by using API fnd_global.apps_initialize.

script output gives you concurrent program request id. which you can check from front end.

********************************************************
create or replace procedure XXFNDREQPROC   AS
v_request_id number;
v_request_id1 number;
v_request_id2 number;
v_request_id3 number;
v_request_id4 number;
v_request_id5 number;
v_notify_user  boolean;
l_user_id NUMBER:=0;
l_responsibility_id NUMBER:=55550;
l_resp_appl_id NUMBER:=222;
P_ORG_ID NUMBER;
begin
fnd_global.apps_initialize(l_user_id,l_responsibility_id,l_resp_appl_id);
mo_global.init ('S');
v_notify_user := FND_REQUEST.ADD_NOTIFICATION ('USER_NAME');
--v_test:=v_notify_user;
---dbms_output.PUT_LINE('result'||v_notify_user);
--MO_GLOBAL.SET_ORG_CONTEXT(P_ORG_ID,NULL,'AR');
--MO_GLOBAL.SET_POLICY_CONTEXT('S',P_ORG_ID);
v_request_id := fnd_request.submit_request
(application=>'APPLICATION SHORT NAME',
program=>'CONCURRENT PROG SHORT NAME',
description=>NULL,
start_time=>NULL,
sub_request=>FALSE,
argument1=>'PARAMETER1',
argument2=>'PARAMETER2',
argument3=>'PARAMETER3',
argument4=>'PARAMETER4');


commit;
if v_request_id > 0 then
   dbms_output.put_line('Successfully submitted'||V_REQUEST_ID );
 
else
  dbms_output.put_line('Not Submitted'||V_REQUEST_ID );
  end if;
EXCEPTION WHEN OTHERS THEN              
DBMS_OUTPUT.PUT_LINE(SQLCODE||' Error :'||SQLERRM);
END;


*******************************************************

How to checks the request states?


A PL/SQL procedure can check the status of a concurrent request by calling.

FND_CONCURENT.GET_REQUEST_STATUS
FND_CONCURRENT.WAIT_FOR_REQUEST

 FND_CONCURRENT.GET_REQUEST_STATUS :
-          This function returns the status of a concurrent request
-          If the request is already computed, it also returns the completion message.
-          This function returns both user friendly (translatable) phase and status values as well as developer phase and status vales that can drive program logic.

Syntax  Function FND_CONCURRENT.GET_REQUEST_STATUS
                   ( request_id in out number,
                   application in varchar2 default null,
                   program in varchar2 default null,
                   phase out varchar2,
                   status out varchar,
                   dev_phase out varchar2,
                   dev_status out varchar2,
                   message out varchar2) return BOOLEAN;

-          when application and program are specified, the request_id of the last request for the specified program should be returned to request_id.
-          Phase, and status values should be taken from

FND_LOOKUPS
dev_phase                                          dev_status
pending                                    normal, standby, scheduled, paused
running                                     normal, waiting, resuming, terminating.
Complete                                  normal, Error, warning, cancelled, terminated
Inactive                                     disabled, on-hold, No-manager, supended

FND_REQUEST.WAIT_FOR_REQUEST :
-          This function waits for request completion, then returns the request phase/status and completion message to the caller.
-          Goes to sleep between checks for request completion.

Syntax FND_CONCURRENT.WAIT_FOR_REQUEST
     ( request_id in number default null,
     interval in number default 60,
     max_wait in numbe default 0,
     phase out varchar2,
     status out varchar2,
dev_phase out varchar2,
dev_status out varchar2,
message out varchar2) return BOOLEN;

 FND_CONCURRENT.SET_COMPLETION_STATUS :
-          this function should be called from a concurrent program to set its completion states.
-          This function returns TRUE on success, other wise FALSE.
Syntax  function 
FND_CONCURRENT.SET_COMPLETION_STATUS
     ( status in varchar2,          message in varchar2) return BOOLEAN;
Normal status  warning message any message Error

No comments:

Post a Comment

AP Invoice Notes related Table details in Oracle Fusion

 What is the table that stores the AP Invoice notes? AP notes are stored in ZMM_NOTES table with SOURCE_OBJECT_CODE = 'AP_STANDARD_INVOI...