Thursday, 1 January 2015

Submitting Concurrent Program from Backend

Submitting a Concurrent Program (Work Flow BG Process for PO)

DECLARE
l_request_id NUMBER;
BEGIN
fnd_global.apps_initialize('4880',50781,201);
l_request_id := fnd_request.submit_request (application => 'FND'
                                           ,program     => 'FNDWFBG'
                                           ,argument1   => 'POAPPRV'
                                           ,ARGUMENT2   =>  NULL
                                           ,ARGUMENT3   =>  NULL
                                           ,argument4   =>  TRUE
                                           ,argument5   =>  TRUE );
COMMIT;  
dbms_output.put_line(l_request_id);
END; 



Submitting a Concurrent Program and Waits Until it Completes

PROCEDURE workflow_bg_process(p_request_id OUT NUMBER)
IS
v_interval        NUMBER := 5;  -- seconds
v_max_wait        NUMBER := 0;  -- seconds(0 = Will not time out)
v_phase_code      VARCHAR2(30);
v_status_code     VARCHAR2(30);
v_dev_phase       VARCHAR2(30);
v_dev_status      VARCHAR2(30);
v_message         VARCHAR2(240);
v_complete        BOOLEAN;
BEGIN

p_request_id := FND_REQUEST.SUBMIT_REQUEST(application => 'FND'
                                          ,program     => 'FNDWFBG'
                                          ,start_time  => SYSDATE
                                          ,sub_request => FALSE
                                          ,argument1   => 'POAPPRV'
                                          ,argument2   => NULL
                                          ,argument3   => NULL
                                          ,argument4   => 'Y'
                                          ,argument5   => 'Y'
                                          ,argument6   => NULL );

COMMIT;  

 v_complete := FND_CONCURRENT.WAIT_FOR_REQUEST(p_request_id,
                                               v_interval,
                                               v_max_wait,
                                               v_phase_code,
                                               v_status_code,
                                               v_dev_phase,
                                               v_dev_status,
                                               v_message);
                                                          
    IF  (v_dev_phase = 'COMPLETE' and v_dev_status != 'NORMAL')
    THEN
       LOG ('Error in Workflow BG Process ');
    ELSE
       LOG ('Successfully Completed Workflow BG Process ');
    END IF;


END workflow_bg_process;

No comments:

Post a Comment