Monday, 22 January 2024

Script to Submit a Concurrent Request from backend in Oracle Apps

/*********************************************************

-- Script to Submit a Concurrent Request from backend.  

**********************************************************/


SET SERVEROUTPUT ON;


DECLARE

   ln_responsibility_id   NUMBER;

   ln_application_id      NUMBER;

   ln_user_id             NUMBER;

   ln_request_id          NUMBER;

BEGIN

   ---Get the application and responsibility info

   SELECT DISTINCT fr.responsibility_id, frx.application_id

     INTO ln_responsibility_id, ln_application_id

     FROM apps.fnd_responsibility frx, apps.fnd_responsibility_tl fr

    WHERE     fr.responsibility_id = frx.responsibility_id

          AND UPPER (fr.responsibility_name) LIKE

                 UPPER ('RESPONSIBILITY NAME');


   --Get the respective User Id

   SELECT user_id

     INTO ln_user_id

     FROM fnd_user

    WHERE user_name = 'USER_NAME';


   --To setup environment.

   apps.fnd_global.apps_initialize (ln_user_id,

                                    ln_responsibility_id,

                                    ln_application_id);


   --Submitting Concurrent Request

   ln_request_id :=

      fnd_request.submit_request (application   => 'APPLICATION_SHORT_NAME',

                                  program       => 'PROGRAM_SHORT_NAME',

                                  description   => 'Concurrent Program Name',

                                  start_time    => SYSDATE,

                                  sub_request   => FALSE,

                                  argument1     => 'PARAMETER_VALUE' ---if applicable we can add more attributes as per requirement

                                                                    );

   COMMIT;

   

   IF ln_request_id = 0

   THEN

      DBMS_OUTPUT.put_line ('Concurrent request failed to submit');

   ELSE

      DBMS_OUTPUT.put_line ('Successfully Submitted the Concurrent Request');

   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