Thursday, September 14, 2017

Submit a Concurrent Program/Request from PL/SQL

Oracle has provided the feasibility to submit a concurrent request from backend using "fnd_request.submit_request" API.

Before submitting the API we need to set the environment and this can be done using "fnd_global.apps_initialize"

Here is a sample code to submit a concurrent program from PL/SQL

Note:- This code is to submit a Concurrent Program, not the Request Set. To Submit the Request Set from the backend, We have a different API.

--
DECLARE
   l_responsibility_id     NUMBER;
   l_resp_application_id   NUMBER;
   l_security_group_id     NUMBER;
   l_user_id               NUMBER;
   l_request_id            NUMBER;
BEGIN
   --
   -- Get the apps environment variables --
   --
   SELECT user_id, responsibility_id, responsibility_application_id,
          security_group_id
     INTO l_user_id, l_responsibility_id, l_resp_application_id,
          l_security_group_id
     FROM fnd_user_resp_groups
    WHERE user_id = (SELECT user_id
                       FROM fnd_user
                      WHERE user_name = '&USER_NAME')
      AND responsibility_id =
             (SELECT responsibility_id
                FROM fnd_responsibility_vl
               WHERE responsibility_name = '&RESP_NAME');

   --
   --To set environment context.
   --
   apps.fnd_global.apps_initialize (l_user_id,
                                    l_responsibility_id,
                                    l_resp_application_id
                                   );
   --
   --Submitting Concurrent Request
   --
      l_request_id := 
fnd_request.submit_request(application => 'XXCUST', -- Application Short Name
            program     => 'XX_DEPT_DTLS', -- Program Short Name
            description => 'XX_DESCRIPTION', -- Any Description
            start_time  => SYSDATE, -- Start Time
            sub_request => FALSE, -- Subrequest Default False
            argument1   => 'ARG1' -- Parameters Starting
            );
   --
   COMMIT;

   --
   IF l_request_id = 0
   THEN
      DBMS_OUTPUT.put_line ('Concurrent request failed to submit');
   ELSE
      DBMS_OUTPUT.put_line ('Successfully Submitted the Concurrent Request: '||l_request_id);
   END IF;
   --
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Error While Submitting Concurrent Request '
                            || TO_CHAR (SQLCODE)'-'|| SQLERRM
                           );
END;
/

No comments:

Post a Comment

Price List Query for Item

 SELECT qph.list_header_id,        qph.name,        qph.description,        qphh.start_date_active,        qphh.currency_code,        q...