The following lines contain the word 'select', 'insert', 'update' or 'delete':
* successful, the document will be updated at the specified entity level.
* Derives any ID if the ID is NULL, but the matching number is passed in. If
* both the ID and number are passed in, the ID is used. Executes at shipment
* level if the final doc_id, line_id, and line_loc_id are not NULL. Executes
* at line level if only the final doc_id and line_id are not NULL. Executes
* at header level if only the final doc_id is not NULL. The document will be
* printed if it is a PO, PA, or RELEASE, and the p_print_flag is 'Y'. All
* changes will be committed upon success if p_commit is FND_API.G_TRUE.
* Appends to API message list on error, and leaves the document unchanged.
* Returns:
* x_return_status - FND_API.G_RET_STS_SUCCESS if control action succeeds
* FND_API.G_RET_STS_ERROR if control action fails
* FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
*/
PROCEDURE control_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_num IN PO_HEADERS.segment1%TYPE,
p_release_id IN NUMBER,
p_release_num IN NUMBER,
p_doc_line_id IN NUMBER,
p_doc_line_num IN NUMBER,
p_doc_line_loc_id IN NUMBER,
p_doc_shipment_num IN NUMBER,
p_source IN VARCHAR2,
p_action IN VARCHAR2,
p_action_date IN DATE,
p_cancel_reason IN PO_LINES.cancel_reason%TYPE,
p_cancel_reqs_flag IN VARCHAR2,
p_print_flag IN VARCHAR2,
p_note_to_vendor IN PO_HEADERS.note_to_vendor%TYPE,
p_use_gldate IN VARCHAR2 --
)
IS
l_api_name CONSTANT VARCHAR2(30) := 'control_document';
SELECT poh.po_header_id
INTO x_doc_id
FROM po_headers poh
WHERE poh.segment1 = p_doc_num AND
poh.type_lookup_code = p_doc_subtype;
SELECT poh.po_header_id
INTO x_doc_id
FROM po_headers poh
WHERE poh.po_header_id = p_doc_id;
SELECT pol.po_line_id
INTO x_doc_line_id
FROM po_lines pol
WHERE pol.po_header_id = x_doc_id AND
pol.line_num = p_doc_line_num;
SELECT 'Exists'
INTO l_exists
FROM po_lines pol
WHERE pol.po_line_id = x_doc_line_id AND
pol.po_header_id = x_doc_id;
SELECT poll.line_location_id
INTO x_doc_line_loc_id
FROM po_line_locations poll
WHERE poll.shipment_num = p_doc_shipment_num AND
poll.po_line_id = x_doc_line_id AND
poll.po_header_id = x_doc_id;
SELECT 'Exists'
INTO l_exists
FROM po_line_locations poll
WHERE poll.line_location_id = x_doc_line_loc_id AND
poll.po_line_id = x_doc_line_id AND
poll.po_header_id = x_doc_id;
SELECT poh.po_header_id, por.po_release_id
INTO l_release_po_header_id, x_doc_id
FROM po_headers poh,
po_releases por
WHERE poh.segment1 = p_doc_num AND
poh.type_lookup_code = l_release_po_subtype AND
por.po_header_id = poh.po_header_id AND
por.release_num = p_release_num;
SELECT poh.po_header_id, por.po_release_id
INTO l_release_po_header_id, x_doc_id
FROM po_headers poh,
po_releases por
WHERE poh.po_header_id = p_doc_id AND
por.po_header_id = poh.po_header_id AND
por.release_num = p_release_num;
SELECT por.po_header_id
INTO l_release_po_header_id
FROM po_releases por
WHERE por.po_release_id = x_doc_id;
SELECT poll.line_location_id
INTO x_doc_line_loc_id
FROM po_line_locations poll,
po_lines pol
WHERE poll.po_release_id = x_doc_id AND
poll.po_header_id = l_release_po_header_id AND
poll.po_line_id = pol.po_line_id AND
poll.shipment_num = p_doc_shipment_num AND
pol.po_header_id = l_release_po_header_id;
SELECT 'Exists'
INTO l_exists
FROM po_line_locations poll
WHERE poll.line_location_id = x_doc_line_loc_id AND
poll.po_release_id = x_doc_id;