Saturday, April 12, 2014

How to Wait for Concurrent Request to Complete Previous Program.


Wait for concurrent request using fnd_concurrent.wait_for_request


 Now we are going to learn about how to wait for a concurrent program to complete previously submitted first. If you submitted the concurrent programs from backend and you want to run them in sequence one after the other then this can be achieved through fnd_concurrent.wait_for_request

 Call the fnd_concurrent.wait_for_request and pass the necessary parameters.
      l_complete      BOOLEAN;
      l_phase           VARCHAR2 (100);
      l_status           VARCHAR2 (100);
      l_dev_phase   VARCHAR2 (100);
      l_dev_status   VARCHAR2 (100);
      l_message      VARCHAR2 (100);


 The l_request_id is the return value of previously submitted program. If the first program submitted successfully then it should wait.

Arguments (input)
     request_id      -   Request ID to wait on
     interval         -   Number of seconds to wait.
     max_wait     - Max amount of time to wait (in seconds) for request's completion

 Arguments (output)  
     phase            - Request phase ( from meaning in fnd_lookups )
     status            - Request status( for display purposes          )
     dev_phase    - Request phase as a constant string so that it can be used for comparisons
     dev_status    - Request status as a constatnt string
     message       - Completion message if request has completed


IF l_request_id > 0
      THEN
         l_complete :=
            fnd_concurrent.wait_for_request (request_id      => l_request_id
                                                             ,interval            => 10
                                                             ,max_wait        => 60

                                                             ,phase              => l_phase
                                                             ,status              => l_status
                                                             ,dev_phase      => l_dev_phase
                                                             ,dev_status      => l_dev_status
                                                             ,message         => l_message
                                            );
         COMMIT;

         IF UPPER (lc_dev_phase) IN ('COMPLETE')
         THEN
            dbms_output.put_line('Concurrent request completed successfully');
         END IF;
      END IF;

No comments:

Post a Comment