Wednesday 7 March 2018

Concurrent Program WAIT until completion of another Concurrent Program

To make Concurrent Program WAIT until completion of another Concurrent Program:



CREATE OR REPLACE PROCEDURE apps.xxorc_test_backs (
   p_errbuff
               OUT   VARCHAR2,
   p_retcode
               OUT   VARCHAR2,
   f_arg1            NUMBER
                           ,
   s_arg1            VARCHAR2
                             ,
   s_arg2            VARCHAR2
                             ,
   s_arg3            VARCHAR2
                             ,
   s_arg4            VARCHAR2
                             ,
   s_arg5            VARCHAR2


)
AS
   req_id                NUMBER;


   RESULT                BOOLEAN;
   lv_request_id         NUMBER;


   lc_phase              VARCHAR2 (50);
   lc_status             VARCHAR2 (50);
   lc_dev_phase          VARCHAR2 (50);
   lc_dev_status         VARCHAR2 (50);
   lc_message            VARCHAR2 (50);
   l_req_return_status   BOOLEAN;
BEGIN
   fnd_global.apps_initialize (1013497, 50554, 200)

                                                   ;
   RESULT := fnd_request.set_mode (TRUE)

                                        ;
   req_id :=
      fnd_request.submit_request (application      => 'AR',
                                  program          => 'CPRXLS',
                                  start_time       => TO_CHAR (SYSDATE,
                                                               'DD-MON-YYYY'
                                                              ),
                                  sub_request      => FALSE,
                                  argument1        => f_arg1
                                 )

                                  ;
   COMMIT;

   IF lv_request_id = 0
   THEN
      DBMS_OUTPUT.put_line (   'Request Not Submitted due to "'
                            || fnd_message.get

                            || '".'
                           );
   ELSE
      DBMS_OUTPUT.put_line
         (   'The Program VIVEKPROGRAM_1 submitted successfully – Request id :'
          || req_id
         );
   END IF;

   IF req_id > 0
   THEN
      LOOP
         l_req_return_status :=
            fnd_concurrent.wait_for_request
               (request_id      => req_id,
                INTERVAL        => 5
                           --interval Number of seconds to wait between checks
                                    ,
                max_wait        => 60
                --Maximum number of seconds to wait for the request completion
                                     -- out arguments
            ,
                phase           => lc_phase,
                status          => lc_status,
                dev_phase       => lc_dev_phase,
                dev_status      => lc_dev_status,
                MESSAGE         => lc_message
               )

                ;
         EXIT WHEN UPPER (lc_phase) = 'COMPLETED'
               OR UPPER (lc_status) IN ('CANCELLED', 'ERROR', 'TERMINATED');
      END LOOP;

      --

      --
      IF UPPER (lc_phase) = 'COMPLETED' AND UPPER (lc_status) = 'ERROR'
      THEN
         DBMS_OUTPUT.put_line
               (   'The XX_PROGRAM_1 completed in error. Oracle request id: '
                || req_id
                || ' '
                || SQLERRM
               );
      ELSIF UPPER (lc_phase) = 'COMPLETED' AND UPPER (lc_status) = 'NORMAL'
      THEN
         DBMS_OUTPUT.put_line
                   (   'The XX_PROGRAM_1 request successful for request id: '
                    || req_id
                   );

         --
         BEGIN
            fnd_global.apps_initialize (1013497, 50554, 200)

                                                            ;
            RESULT := fnd_request.set_mode (TRUE)

                                                 ;
            lv_request_id :=
               fnd_request.submit_request
                                       (application      => 'AR',
                                        program          => 'XXTFS',
                                        -- description   => 'VIVEK_PROGRAM_2',
                                        start_time       => TO_CHAR
                                                                (SYSDATE,
                                                                 'DD-MON-YYYY'
                                                                ),
                                        sub_request      => FALSE,
                                        argument1        => s_arg1,
                                        argument2        => s_arg2,
                                        argument3        => s_arg3,
                                        argument4        => s_arg4,
                                        argument5        => s_arg5
                                       )

                                        ;
            
            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               DBMS_OUTPUT.put_line
                    (   'OTHERS exception while submitting VIVEK_PROGRAM_2: '
                     || SQLERRM
                    );

         END;
      ELSE
         DBMS_OUTPUT.put_line
                   (   'The XX_PROGRAM_1 request failed. Oracle request id: '
                    || req_id
                    || ' '
                    || SQLERRM
                   );
      END IF;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line
                    (   'OTHERS exception while submitting VIVEK_PROGRAM_1: '
                     || SQLERRM
                    );
      COMMIT;

END
   ;


Any Queries Mail Me vivekexpertize@gmail.com

No comments:

Post a Comment

Calling Different Language Layout Based On Conditions :

API For Calling Layout : 1.fnd_request.add_layout CREATE OR REPLACE procedure APPSLSPO_Calling_Templates1(ERRBUFF OUT VARCHAR,RETCODE O...