oracle ebs 采购订单关闭之PL/SQL实现方法

应客户需求,需要写个脚本,批量关闭Bonus Item类型的采购订单,在metalink上搜索到一些方法,但是都测试不通。原来需要将代码生成一个并发程序。下面是测试成功的代码。

1.首先创建一个存储过程,然后在存储过程中调用PO_ACTIONS.CLOSE_PO
2.注册一个存储过程类型的并发程序
3.在application中测试结果。


CREATE OR REPLACE PROCEDURE xx_po_close
  (
    err_buff OUT VARCHAR2,
    retcode OUT NUMBER,
    p_reason_desc VARCHAR2,
    p_po_from VARCHAR2,
    p_po_to VARCHAR2)
AS
  l_return_code VARCHAR2(2000);
  l_result      BOOLEAN;
  CURSOR PO_CLOSE_CUR
  IS
     SELECT poh.segment1,
      poll.po_header_id ,
      poll.po_line_id   ,
      poll.line_location_id
       FROM po_line_locations_all poll,
      po_headers_all poh              ,
      po_lines_all pol
      WHERE poll.po_header_id          = poh.po_header_id
    AND poll.po_line_id                =pol.po_line_id
    AND pol.po_header_id               = poh.po_header_id
    AND upper(poh.authorization_status)='APPROVED'
    AND UPPER(poll.closed_code )='CLOSED FOR RECEIVING'
    AND (pol.unit_price                 =0 or poh.quantity_billed - poh.quantity >=0)
    AND poh.segment1 between p_po_from and p_po_to;
    
BEGIN
  FOR PO_CLOSE_REC IN PO_CLOSE_CUR
  LOOP
    l_result := po_actions.close_po(
    p_docid => PO_CLOSE_REC.po_header_id,
    p_doctyp => 'PO', 
    p_docsubtyp => 'STANDARD', 
    p_lineid => PO_CLOSE_REC.po_line_id, 
    p_shipid => PO_CLOSE_REC.line_location_id, 
    p_action => 'CLOSE', 
    p_reason => p_reason_desc, 
    p_calling_mode => 'PO', 
    p_conc_flag => 'N', 
    p_return_code => l_return_code, 
    p_auto_close => 'N', 
    p_action_date => SYSDATE, 
    p_origin_doc_id => NULL);
    
    IF l_result THEN
      FND_FILE.PUT_LINE( FND_FILE.OUTPUT,PO_CLOSE_REC.segment1 || ' is Closed. ');
    ELSE
      FND_FILE.PUT_LINE( FND_FILE.OUTPUT,PO_CLOSE_REC.segment1 || ' is not Closed. ');
    END IF;
    
  END LOOP;
END;

posted @ 2013-12-17 14:44  我不卖豆腐  阅读(1699)  评论(0编辑  收藏  举报