--采购订单取消脚本,不知道怎么回事,初始化不起作用,暂时只有写在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."