The following lines contain the word 'select', 'insert', 'update' or 'delete':
* p_cbc_enabled is 'Y', then the CBC accounting date is updated to be
* p_action_date. If p_cancel_reqs_flag is 'Y', then backing requisitions will
* also be cancelled if allowable. Otherwise, they will be recreated.
* Encumbrance is recalculated for cancelled entities if enabled. If the
* cancel action is successful, the document's cancel and who columns will be
* updated at the specified entity level. Otherwise, the document will remain
* unchanged. All changes will be committed upon success if p_commit is
* FND_API.G_TRUE. Appends to API message list on error.
* Returns:
* x_return_status - FND_API.G_RET_STS_SUCCESS if cancel action succeeds
* FND_API.G_RET_STS_ERROR if cancel action fails
* FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
*/
PROCEDURE cancel_document
(p_api_version IN NUMBER,
p_init_msg_list IN VARCHAR2,
p_commit IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
p_doc_id IN NUMBER,
p_doc_line_id IN NUMBER,
p_doc_line_loc_id IN NUMBER,
p_cancel_agent_id IN PO_HEADERS.agent_id%TYPE,
p_action_date IN DATE,
p_cancel_reason IN PO_LINES.cancel_reason%TYPE,
p_cancel_reqs_flag IN VARCHAR2,
p_note_to_vendor IN PO_HEADERS.note_to_vendor%TYPE,
p_cbc_enabled IN VARCHAR2,
p_use_gldate IN VARCHAR2 --
)
IS
PRAGMA AUTONOMOUS_TRANSACTION;
ELSIF (l_return_code = 'UPDATE_CBC_FAILED') THEN
IF (g_fnd_debug = 'Y') THEN
IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix ||
l_api_name||'.error_msg4', NVL(l_error_msg,'null'));
PO_Document_Control_PVT.update_note_to_vendor
( p_api_version => 1.0,
p_init_msg_list => FND_API.G_FALSE,
p_commit => FND_API.G_FALSE,
x_return_status => x_return_status,
p_doc_type => p_doc_type,
p_doc_id => p_doc_id,
p_doc_line_id => p_doc_line_id,
p_note_to_vendor => p_note_to_vendor );
SELECT count(*)
INTO l_cto_order
FROM po_requisition_headers_all PRH,
po_requisition_lines_all PRL,
po_line_locations_all POLL
WHERE PRH.interface_source_code = 'CTO'
AND PRH.requisition_header_id = PRL.requisition_header_id
AND PRL.line_location_id = POLL.line_location_id
AND ((p_doc_type = 'PO') AND (POLL.po_header_id = p_doc_id)
OR
(p_doc_type = 'RELEASE') AND (POLL.po_release_id = p_doc_id));
SELECT DISTINCT(prd.requisition_line_id)
FROM po_req_distributions_all prd,
po_line_locations_all poll,
po_distributions_all pod
WHERE pod.line_location_id = p_doc_line_loc_id
AND pod.line_location_id = poll.line_location_id
AND pod.req_distribution_id = prd.distribution_id
AND NVL(poll.cancel_flag, 'N') = 'N'
AND NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
AND poll.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET', 'PREPAYMENT')
;
SELECT DISTINCT(prd.requisition_line_id)
FROM po_req_distributions_all prd,
po_line_locations_all poll,
po_distributions_all pod
WHERE pod.po_line_id = p_doc_line_id
AND pod.line_location_id = poll.line_location_id
AND pod.req_distribution_id = prd.distribution_id
AND NVL(poll.cancel_flag, 'N') = 'N'
AND NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
AND poll.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET', 'PREPAYMENT')
;
SELECT DISTINCT(prd.requisition_line_id)
FROM po_req_distributions_all prd,
po_line_locations_all poll,
po_distributions_all pod
WHERE pod.po_header_id = p_doc_id
AND pod.line_location_id = poll.line_location_id
AND pod.req_distribution_id = prd.distribution_id
AND NVL(poll.cancel_flag, 'N') = 'N'
AND NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
AND poll.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET', 'PREPAYMENT')
;
SELECT porl.requisition_line_id
FROM po_requisition_lines_all porl, --
po_line_locations poll
WHERE poll.po_release_id = p_doc_id AND
poll.line_location_id = porl.line_location_id AND
NVL(poll.cancel_flag, 'N') = 'N' AND
NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED' AND
poll.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET');
SELECT cancel_reqs_on_po_cancel_flag
INTO l_cancel_reqs_sys_val
FROM po_system_parameters;