DECLARE
vReturnStatus VARCHAR2(1);
vMsgData VARCHAR2(200);
vOrgId po_headers_all.org_id%TYPE := 00;
vPoHeaderId po_headers_all.po_header_id%TYPE := 11;
vDocSubtype po_headers_all.type_lookup_code%TYPE := 'STANDARD';
vDocType VARCHAR2(2) := 'PO';
vCancelReqsFlag VARCHAR2(1) := 'N';
vCancelReason VARCHAR2(200) := 'TEST';
vAction VARCHAR2(10) := 'CANCEL';
vActionDate DATE := SYSDATE;
BEGIN
fnd_global.apps_initialize(user_id => 00, resp_id => 00,resp_appl_id => 00);
mo_global.init('PO');
mo_global.set_policy_context('S',vOrgId);
dbms_output.put_line('Calling API For Cancelling Documents');
po_document_control_pub.control_document(p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_false,
x_return_status => vReturnStatus,
p_doc_type => vDocType,
p_doc_subtype => vDocSubtype,
p_doc_id => vPoHeaderId,
p_doc_num => NULL,
p_release_id => NULL,
p_release_num => NULL,
p_doc_line_id => NULL,
p_doc_line_num => NULL,
p_doc_line_loc_id => NULL,
p_doc_shipment_num => NULL,
p_action => vAction,
p_action_date => vActionDate,
p_cancel_reason => NULL,
p_cancel_reqs_flag => vCancelReqsFlag,
p_print_flag => NULL,
p_note_to_vendor => NULL,
p_use_gldate => NULL,
p_org_id => vOrgId);
DBMS_OUTPUT.PUT_LINE('The Return Status of the API : ' || vReturnStatus);
IF vReturnStatus = fnd_api.g_ret_sts_success THEN
COMMIT;
DBMS_OUTPUT.PUT_LINE('Cancellation of PO is Sucessfull : ' ||
vPoHeaderId);
ELSE
DBMS_OUTPUT.PUT_LINE('Cancellation of PO Failed ');
ROLLBACK;
FOR i IN 1 .. FND_MSG_PUB.COUNT_MSG
LOOP
vMsgData := FND_MSG_PUB.GET(p_msg_index => i, p_encoded => 'F');
DBMS_OUTPUT.PUT_LINE(i || ') ' || vMsgData);
END LOOP;
END IF;
END;
沒有留言:
張貼留言