码迷,mamicode.com
首页 > 其他好文 > 详细

采购订单关闭

时间:2014-08-30 23:08:00      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   数据   cti   sp   on   line   c   

DECLARE
  -- Local variables here
  i                 INTEGER;
  l_return_status   VARCHAR2(10);
  p_retcode         VARCHAR2(2000);
  p_errbuf          VARCHAR2(2000);
  v_x_return_status VARCHAR2(250);
  v_x_exception_msg VARCHAR2(250);
BEGIN
  -- Test statements here

  FOR rec IN (SELECT pha.org_id,
                     pha.segment1,
                     pha.po_header_id erp_header_id
                FROM po_headers_all pha
               WHERE 1 = 1
                 AND pha.org_id = 86
                 AND pha.segment1 LIKE 'CXY-%'
                 AND pha.created_by = 1150
                 AND pha.cancel_flag <> 'Y')
  LOOP
  
    apps.fnd_global.apps_initialize(user_id      => 1150, -- V_USER_ID,  
                                    resp_id      => 50758, --P_RESP_ID, 50757  50737  50758 
                                    resp_appl_id => 201);
    apps.mo_global.init('PO');
  
    --DBMS_OUTPUT.PUT_LINE(P_USER_ID || '*' || V_USER_ID || '*' ||P_RESP_ID);
    dbms_output.put_line('------' || rec.segment1 || '------');
    dbms_output.put_line(l_return_status);
    apps.po_document_control_pub.control_document(p_api_version      => 1.0, -- p_api_version
                                                  p_init_msg_list    => apps.fnd_api.g_true, -- p_init_msg_list
                                                  p_commit           => apps.fnd_api.g_true, -- p_commit
                                                  x_return_status    => l_return_status, -- x_return_status
                                                  p_doc_type         => 'PO', -- p_doc_type
                                                  p_doc_subtype      => 'STANDARD', -- p_doc_subtype
                                                  p_doc_id           => NULL, -- p_doc_id
                                                  p_doc_num          => rec.segment1, -- p_doc_num
                                                  p_release_id       => NULL, -- p_release_id
                                                  p_release_num      => NULL, -- p_release_num
                                                  p_doc_line_id      => NULL, -- p_doc_line_id
                                                  p_doc_line_num     => NULL, --REC.LINE_NUM, -- p_doc_line_num
                                                  p_doc_line_loc_id  => NULL, --rec.Line_Location_Id, -- p_doc_line_loc_id
                                                  p_doc_shipment_num => NULL, -- p_doc_shipment_num
                                                  p_action           => 'CANCEL', -- p_action
                                                  p_action_date      => SYSDATE, -- p_action_date
                                                  p_cancel_reason    => '期初数据导入错误', -- p_cancel_reason
                                                  p_cancel_reqs_flag => 'N', -- p_cancel_reqs_flag
                                                  p_print_flag       => NULL, -- p_print_flag
                                                  p_note_to_vendor   => NULL,
                                                  p_use_gldate       => NULL, -- <ENCUMBRANCE FPJ>
                                                  p_org_id           => rec.org_id); -- p_note_to_vendor
  
    -- Get any messages returned by the Cancel API
    COMMIT;
    FOR i IN 1 .. apps.fnd_msg_pub.count_msg
    LOOP
      dbms_output.put_line(apps.fnd_msg_pub.get(p_msg_index => i,
                                                p_encoded   => 'F'));
    
      p_errbuf := apps.fnd_msg_pub.get(p_msg_index => i,
                                       p_encoded   => 'F');
    END LOOP;
    COMMIT;
    IF l_return_status = 'S' THEN
      BEGIN
        apps.po_document_action_pvt.do_approve(p_document_id      => rec.erp_header_id, --PO_HEADER_ID
                                               p_document_type    => 'PO',
                                               p_document_subtype => 'STANDARD',
                                               p_note             => NULL,
                                               p_approval_path_id => NULL,
                                               x_return_status    => v_x_return_status,
                                               x_exception_msg    => v_x_exception_msg);
        dbms_output.put_line('V_X_RETURN_STATUS:' || v_x_return_status);
        dbms_output.put_line('V_X_EXCEPTION_MSG:' || v_x_exception_msg);
        IF v_x_return_status = 'S' THEN
          COMMIT;
        ELSE
          ROLLBACK;
        END IF;
      
      END;
    
      dbms_output.put_line('Y');
      dbms_output.put_line('取消成功');
      COMMIT;
    
    ELSE
    
      dbms_output.put_line('E');
      dbms_output.put_line('取消失败:' || p_errbuf);
    
    END IF;
    COMMIT;
    ----update po_header
  ----更新头行的审批状态
  
  END LOOP;

END;

采购订单关闭

标签:io   ar   for   数据   cti   sp   on   line   c   

原文地址:http://blog.csdn.net/cai_xingyun/article/details/38949069

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!