Oracle EBS OPM reshedule batch

	
--reschedule_batch
--created by jenrry 


DECLARE
   x_message_count         NUMBER;
   x_message_list          VARCHAR2 (2000);
   x_return_status         VARCHAR2 (2000);
   x_batch_header          gme_batch_header%ROWTYPE;
   p_batch_header_rec      gme_batch_header%ROWTYPE;
   p_use_workday_cal       VARCHAR2 (100)             := fnd_api.g_false;
   p_contiguity_override   VARCHAR2 (100)             := fnd_api.g_true;
   p_org_code              VARCHAR2 (3); 
   l_user_name             VARCHAR2 (80);
   l_user_id               NUMBER;

   CURSOR get_user_id (v_user_name IN VARCHAR2)
   IS
      SELECT user_id
        FROM fnd_user
       WHERE user_name = v_user_name;

   PROCEDURE display_messages (p_msg_count IN NUMBER)
   IS
      MESSAGE               VARCHAR2 (2000);
      dummy                 NUMBER;
      l_api_name   CONSTANT VARCHAR2 (30)   := 'DISPLAY_MESSAGES';
   BEGIN
      FOR i IN 1 .. p_msg_count
      LOOP
         fnd_msg_pub.get (p_msg_index          => i,
                          p_data               => MESSAGE,
                          p_encoded            => 'F',
                          p_msg_index_out      => dummy
                         );
         DBMS_OUTPUT.put_line ('Message ' || TO_CHAR (i) || ' ' || MESSAGE);
      END LOOP;
   EXCEPTION
      WHEN OTHERS
      THEN
         fnd_msg_pub.add_exc_msg ('wrapper for Reschedule_Batch', l_api_name);
   END display_messages;
BEGIN 
   DBMS_OUTPUT.ENABLE (20000); 
   l_user_name := 'PROCESS_OPS';

   OPEN get_user_id (l_user_name);

   FETCH get_user_id
    INTO l_user_id;

   IF get_user_id%NOTFOUND
   THEN
      DBMS_OUTPUT.put_line ('Invalid User ' || l_user_name);

      CLOSE get_user_id;

      RAISE NO_DATA_FOUND;
   END IF;

   CLOSE get_user_id;

   fnd_profile.initialize (l_user_id); 
   fnd_global.apps_initialize (user_id           => l_user_id,
                               resp_id           => NULL,
                               resp_appl_id      => NULL
                              ); 
   p_batch_header_rec.batch_id := 819043;
   p_batch_header_rec.batch_no := '138177';
   p_batch_header_rec.batch_type := 0;
   p_batch_header_rec.plan_start_date :=
                    TO_DATE ('09-FEB-2009 01:01:01', 'DD-MON-YYYY HH24:MI:SS');
   --p_batch_header_rec.actual_start_date := TO_DATE('');
   --p_batch_header_rec.due_date := TO_DATE('');
   --p_batch_header_rec.plan_cmplt_date := TO_DATE('10-FEB-2009 10:00:00','DD-MON-YYYY HH24:MI:SS');
   --p_batch_header_rec.actual_cmplt_date := TO_DATE('');
   p_batch_header_rec.batch_status := 1;
 
   gme_api_pub.reschedule_batch
                              (p_api_version              => 2,
                               p_validation_level         => 100,
                               p_init_msg_list            => fnd_api.g_true,
                               p_commit                   => fnd_api.g_true,
                               p_org_code                 => 'PR1',
                               p_use_workday_cal          => p_use_workday_cal,
                               p_contiguity_override      => p_contiguity_override,
                               x_message_count            => x_message_count,
                               x_message_list             => x_message_list,
                               x_return_status            => x_return_status,
                               p_batch_header_rec         => p_batch_header_rec,
                               x_batch_header_rec         => x_batch_header
                              ); 
   DBMS_OUTPUT.put_line ('x_message_count = ' || TO_CHAR (x_message_count));
   DBMS_OUTPUT.put_line (SUBSTR ('x_message_list = ' || x_message_list, 1,
                                 255)
                        );
   DBMS_OUTPUT.put_line (SUBSTR ('x_return_status = ' || x_return_status,
                                 1,
                                 255
                                )
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.batch_id = '
                         || TO_CHAR (x_batch_header.batch_id)
                        );
   DBMS_OUTPUT.put_line (SUBSTR (   'x_batch_header.batch_no = '
                                 || x_batch_header.batch_no,
                                 1,
                                 255
                                )
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.batch_type = '
                         || TO_CHAR (x_batch_header.batch_type)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.plan_start_date = '
                         || TO_CHAR (x_batch_header.plan_start_date)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.actual_start_date = '
                         || TO_CHAR (x_batch_header.actual_start_date)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.due_date = '
                         || TO_CHAR (x_batch_header.due_date)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.plan_cmplt_date = '
                         || TO_CHAR (x_batch_header.plan_cmplt_date)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.actual_cmplt_date = '
                         || TO_CHAR (x_batch_header.actual_cmplt_date)
                        );
   DBMS_OUTPUT.put_line (   'x_batch_header.batch_status = '
                         || TO_CHAR (x_batch_header.batch_status)
                        );

   IF x_message_count > 1
   THEN
      display_messages (x_message_count);
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Error ' || TO_CHAR (SQLCODE) || ': ' || SQLERRM);
      RAISE;
END;
/

  

posted on 2018-11-26 16:34  Jenrry  阅读(291)  评论(0编辑  收藏  举报