Infolinks

Tuesday 24 July 2012

Submitting Concurrent Request Using FND_CONCURRENT.WAIT_FOR_REQUEST Sample Code

When submitting concurrent requests using PL/SQL, it is often desired to have the parent process wait until all the child processes have completed before completing itself. The following describes the function used to accomplish this.
Refer Metalink 1021956.6: The following describes how to submit concurrent requests using PL/SQL and have the parent request ‘wait’ until each of the child processes have completed before it completes.
Use the FND_CONCURRENT.WAIT_FOR_REQUEST function documented in the Oracle Applications Developer’s Guide, RELEASE 11i, Page 21-8 See the FND_CONCURRENT.WAIT_FOR_REQUEST function description.
Summary
        <strong>FUNCTION FND_CONCURRENT.WAIT_FOR_REQUEST</strong>

  (request_id IN number DEFAULT NULL,
          interval   IN number DEFAULT 60,
          max_wait   IN number DEFAULT 0,
          phase      OUT varchar2,
          STATUS     OUT varchar2,
          dev_phase  OUT varchar2,
          dev_status OUT varchar2,
          message    OUT varchar2) RETURN  BOOLEAN;
Description
Wait for the request completion, then return the request phase/status and
completion message to the caller. Also call sleep between database checks.
Arguments (input)
request_id
The request ID of the program to wait on.
interval
Time to wait between checks. This is the number of seconds to sleep.
The default is 60 seconds.
max_wait
The maximum time in seconds to wait for the requests completion.
Arguments (output)
phase
The user friendly request phase from FND_LOOKUPS.
status
The user friendly request status from FND_LOOKUPS.
dev_phase
The request phase as a constant string that can be used for program
logic comparisons.
dev_status
The request status as a constant string that can be used for program
logic comparisons.
message
The completion message supplied if the request has completed.
BEGIN
         l_request_id :=
            fnd_request.submit_request (‘XXCUS’,
                                        ‘XXCUSSPOOL’,    
                                        NULL,
                                        NULL,
                                        FALSE,
                                        p_filename_i,
                                        p_seq_i
                                       );
      END;       p_request_id_o := l_request_id;
      fnd_file.put_line (fnd_file.LOG,‘XXCUSSPOOL Submitted. Request_id=’p_request_id_o‘ Filename=’p_filename_i‘ Seq=’p_seq_i  );
      IF p_request_id_o = 0
      THEN
         ec_log_debug (p_filename_i,‘SUBMIT_FILE_CREATION’,4090, ‘XXCUSSPOOL submission failed for ‘p_filename_i‘Request_id=’p_request_id_o );
      ELSE
         l_return :=
            fnd_concurrent.wait_for_request (request_id      => p_request_id_o,
                                             INTERVAL        => 10,
                                             max_wait        => 300, – Null means wait forever, I normally provide 300 = 5 mins
                                             phase           => l_phase,
                                             STATUS          => l_status,
                                             dev_phase       => l_dev_phase,
                                             dev_status      => l_dev_status,
                                             MESSAGE         => l_message
                                            );
      END IF;

No comments:

Post a Comment