PO取消(包括头、行、发运行)

 --采购订单取消脚本,不知道怎么回事,初始化不起作用,暂时只有写在FORM或请求中了,详细的参数传递请看PKG中的说明
DECLARE
  X_RETURN_STATUS VARCHAR2(10);
  V_HEADER_ID     NUMBER;
  V_LINE_ID       NUMBER;
BEGIN
  IF :ITEM_QUERY.ITEM_NO IS NOT NULL
  THEN
    SELECT PO_HEADER_ID
          ,PO_LINE_ID
      INTO V_HEADER_ID
          ,V_LINE_ID
      FROM PO_LINE_LOCATIONS_ALL
     WHERE LINE_LOCATION_ID = TO_NUMBER(:ITEM_QUERY.ITEM_NO);
    PO_DOCUMENT_CONTROL_PUB.CONTROL_DOCUMENT(P_API_VERSION      => 1.0
                                            , --版本信息,目前为1.0
                                             P_INIT_MSG_LIST    => 'T'
                                            ,P_COMMIT           => 'T'
                                            ,X_RETURN_STATUS    => X_RETURN_STATUS
                                            , -- 返回接口运行结果,S为成功,E为错误,U为未知错误
                                             P_DOC_TYPE         => 'PO'
                                            ,P_DOC_SUBTYPE      => 'STANDARD'
                                            , -- 取消标准PO
                                             P_DOC_ID           => V_HEADER_ID
                                            ,P_DOC_NUM          => NULL
                                            , -- Po_header_id和单据编码任选一个参数即可
                                             P_RELEASE_ID       => NULL
                                            ,P_RELEASE_NUM      => NULL
                                            ,P_DOC_LINE_ID      => V_LINE_ID
                                            ,P_DOC_LINE_NUM     => NULL
                                            ,P_DOC_LINE_LOC_ID  => TO_NUMBER(:ITEM_QUERY.ITEM_NO)
                                            ,P_DOC_SHIPMENT_NUM => NULL
                                            ,P_ACTION           => 'CANCEL'
                                            , --固定值
                                             P_ACTION_DATE      => NULL
                                            ,P_CANCEL_REASON    => NULL
                                            , --Cancel原因
                                             P_CANCEL_REQS_FLAG => NULL
                                            ,P_PRINT_FLAG       => NULL
                                            ,P_NOTE_TO_VENDOR   => NULL
                                            ,P_USE_GLDATE       => 'N');
 
    COMMIT;
 
    FOR I IN 1 .. FND_MSG_PUB.COUNT_MSG
    LOOP
      FND_MESSAGE.DEBUG(FND_MSG_PUB.GET(P_MSG_INDEX => I
                                       ,P_ENCODED   => 'F'));
    END LOOP;
 
  END IF;
END;
--==============================================================================================================

--PO归档表

DELETE FROM PO_HEADERS_ARCHIVE_ALL WHERE PO_HEADER_ID = &PO_HEADER_ID;
DELETE FROM PO_LINES_ARCHIVE_ALL WHERE PO_HEADER_ID = &PO_HEADER_ID;
DELETE FROM PO_LINE_LOCATIONS_ARCHIVE_ALL
 WHERE PO_HEADER_ID = &PO_HEADER_ID;
--采购订单取消时若出现如下错误,是因为采购订单事实表和上面归档表信息不一致所致,此时需把归档表信息删除即可执行取消程序

“Please undo the changes to the document in the current revision before taking the cancel action.

Cause: You are trying to cancel a document that has been altered since its last archived revision.

Action: You must first undo the changes before you can cancel the document."

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值