Şub
8
2018

Satınalma Siparişinin Kapalı Statüsüne Getirilmesi (API)

Merhaba,

Satınalma siparişini CLOSE yada FINALLY CLOSE statülerine getirmek için aşağıdaki script’i kullanabilirsiniz.

 
DECLARE
   x_action         CONSTANT VARCHAR2 (20) := 'FINALLY CLOSE'; -- Change this parameter as per requirement
   x_calling_mode   CONSTANT VARCHAR2 (2) := 'PO';
   x_conc_flag      CONSTANT VARCHAR2 (1) := 'N';
   x_return_code_h           VARCHAR2 (100);
   x_auto_close     CONSTANT VARCHAR2 (1) := 'N';
   x_origin_doc_id           NUMBER;
   x_returned                BOOLEAN;
 
   CURSOR c_po_details
   IS
      SELECT pha.po_header_id,
             pha.org_id,
             pha.segment1,
             pha.agent_id,
             pdt.document_subtype,
             pdt.document_type_code,
             pha.closed_code,
             pha.closed_date
        FROM apps.po_headers_all pha, apps.po_document_types_all pdt
       WHERE     pha.type_lookup_code = pdt.document_subtype
             AND pha.org_id = pdt.org_id
             AND pdt.document_type_code = 'PO'
             AND authorization_status = 'APPROVED'
             AND NVL(pha.closed_code,'OPEN') <> 'CLOSED'
             AND segment1 = 'XXXX'; -- Enter the PO Number if only one PO needs to be finally closed/Closed
BEGIN
   fnd_global.apps_initialize (user_id        => 0,
                               resp_id        => 0,
                               resp_appl_id   => 0);
 
   /*For more details on how to Initialize the session oracle Apps R-12 visit Initializing The Session Oracle Apps R-12
   */
   FOR po_head IN c_po_details
   LOOP
      mo_global.init (po_head.document_type_code);
      mo_global.set_policy_context ('S', po_head.org_id);
 
      DBMS_OUTPUT.PUT_LINE (
            'Calling PO_Actions.close_po for Closing/Finally Closing PO =>'
         || po_head.segment1);
 
      x_returned :=
         po_actions.close_po (p_docid           => po_head.po_header_id,
                              p_doctyp          => po_head.document_type_code,
                              p_docsubtyp       => po_head.document_subtype,
                              p_lineid          => NULL,
                              p_shipid          => NULL,
                              p_action          => x_action,
                              p_reason          => NULL,
                              p_calling_mode    => x_calling_mode,
                              p_conc_flag       => x_conc_flag,
                              p_return_code     => x_return_code_h,
                              p_auto_close      => x_auto_close,
                              p_action_date     => SYSDATE,
                              p_origin_doc_id   => NULL);
 
      IF x_returned = TRUE
      THEN
         DBMS_OUTPUT.PUT_LINE (
               'Purchase Order which just got Closed/Finally Closed is '
            || po_head.segment1);
 
         COMMIT;
      ELSE
         DBMS_OUTPUT.PUT_LINE (
            'API Failed to Close/Finally Close the Purchase Order');
      END IF;
   END LOOP;
END;

Kaan Sertaç Bozatlı

Blog yöneticisi ve aynı zamanda yazardır. 10 yılı aşkın bir süredir
profesyonel kariyerine Oracle ERP Developer olarak devam etmektedir.
Mail: kbozatli@gmail.com
LinkedIn: Profili Görüntüleyin
Kaan Sertaç Bozatlı

Latest posts by Kaan Sertaç Bozatlı (see all)



Yorum yapın

*