Friday, October 4, 2013

API to release the Hold on Order

DECLARE
   l_order_tbl                                       oe_holds_pvt.order_tbl_type;
   x_return_status                                   VARCHAR2 (30);
   x_msg_data                                        VARCHAR2 (256);
   x_msg_count                                       NUMBER;
   l_msg_index_out                                   NUMBER;
   l_error_message                                   VARCHAR2 (2000);
BEGIN
   fnd_global.apps_initialize (1318, 21623, 660);   -- pass in user_id, responsibility_id, and application_id
   oe_debug_pub.initialize;
   oe_debug_pub.setdebuglevel (5);
   oe_msg_pub.initialize;
   l_order_tbl (1).header_id                                := '<order header id>';
   oe_debug_pub.ADD ('Just before calling OE_Holds_PUB.Apply_Holds:');
   oe_holds_pub.release_holds (p_api_version                 => 1.0
                             , p_order_tbl                   => l_order_tbl
                             , p_hold_id                     => '<hold id>'
                             , p_release_reason_code         => '<Hold Release reason Code>'
                             , p_release_comment             => '<Hold release Addiotnal Commnent if any>'
                             , x_return_status               => x_return_status
                             , x_msg_count                   => x_msg_count
                             , x_msg_data                    => x_msg_data
                              );
   oe_debug_pub.ADD ('Just after calling OE_Holds_PUB.Apply_Holds:');

   IF x_return_status <> fnd_api.g_ret_sts_success
   THEN
      FOR i IN 1 .. x_msg_count
      LOOP
         apps.fnd_msg_pub.get (p_msg_index                   => i
                             , p_encoded                     => fnd_api.g_false
                             , p_data                        => x_msg_data
                             , p_msg_index_out               => l_msg_index_out
                              );

         IF l_error_message IS NULL
         THEN
            l_error_message                                          := SUBSTR (x_msg_data, 1, 250);
         ELSE
            l_error_message                                          :=
                                                                      l_error_message || ' /' || SUBSTR (x_msg_data, 1, 250);
         END IF;
      END LOOP;

      DBMS_OUTPUT.put_line ('*****************************************');
      DBMS_OUTPUT.put_line ('API Error : ' || l_error_message);
      DBMS_OUTPUT.put_line ('*****************************************');
      ROLLBACK;
   ELSE
      DBMS_OUTPUT.put_line ('*****************************************');
      DBMS_OUTPUT.put_line ('Hold Released Successfully ');
      DBMS_OUTPUT.put_line ('*****************************************');
      COMMIT;
   END IF;

   oe_debug_pub.debug_off;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Error is ' || SQLCODE || '---' || SQLERRM);
END;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.