以下代码为删除PO的API,还未做调试
DECLARE
p_po_header_id NUMBER;
l_api_name CONSTANT VARCHAR2(20) := 'delete_po';
l_po_header_id NUMBER;
l_type_lookup_code VARCHAR2(80);
l_ga_flag po_headers_all.global_agreement_flag%TYPE; -- <GA FPI>
l_deleted BOOLEAN;
--< CONTERMS FPJ START>
l_conterms_flag po_headers_all.conterms_exist_flag%TYPE;
-- l_k_doc_type should be %type based on contracts table but to circumvent
-- the dependency varchar length hardcoded. Consider again when refactoring
l_k_doc_type VARCHAR2(150);
l_return_status VARCHAR2(1);
l_msg_data VARCHAR2(2000);
l_msg_count NUMBER;
--< CONTERMS FPJ END>
BEGIN
--Program start
SELECT poh.po_header_id
,poh.type_lookup_code
,poh.global_agreement_flag
,nvl(poh.conterms_exist_flag
,'N')
INTO l_po_header_id
,l_type_lookup_code
,l_ga_flag
,l_conterms_flag
FROM po_headers_all poh
WHERE poh.po_header_id = p_po_header_id;
/* Call the procedure to delete the document */
l_deleted := po_headers_sv1.delete_po(l_po_header_id
,l_type_lookup_code);
-- <GA FPI START>: If document is a Global Agreement,
-- must also delete its Org Assignment entry from PO_GA_ORG_ASSIGNMENTS.
--
-- bug3239502
-- We should delete org assignments as long as ga_flag is 'Y'. This will then cover
-- both GA and GC.
IF (l_ga_flag = 'Y') THEN
po_ga_org_assign_pvt.delete_row(l_po_header_id);
END IF;
--
-- <GA FPI END>
--<CONTERMS FPJ START>
IF l_conterms_flag = 'Y' THEN
IF l_type_lookup_code = 'STANDARD' THEN
l_k_doc_type := 'PO' || '_' || l_type_lookup_code;
ELSIF l_type_lookup_code IN ('BLANKET'
,'CONTRACT') THEN
l_k_doc_type := 'PA_' || l_type_lookup_code;
END IF; -- type lookup code
-- call contracts to delete contract terms
okc_terms_util_grp.delete_doc(p_api_version => 1.0
,p_init_msg_list => 'F'
,p_commit => 'F'
,p_doc_id => l_po_header_id
,p_doc_type => l_k_doc_type
,p_validate_commit => 'F'
,x_return_status => l_return_status
,x_msg_data => l_msg_data
,x_msg_count => l_msg_count);
---Return Status Handling
IF (l_return_status <> 'S') THEN
-- Show error messages
raise_exception(x_return_status);
/*po_util_c.display_errors(p_stat => 'S',
p_return_status => l_return_status,
p_caller_proc => 'PO_HEADERS_PKG1.delete_row',
p_called_proc => 'OKC_TERMS_UTIL_GRP.delete_doc');*/
END IF; -- return status not success
END IF; -- conterms flag
--<CONTERMS FPJ END>
COMMIT;
--Program end
END;