1 PACKAGE BODY PO_Document_Control_PUB AS
2 /* $Header: POXPDCOB.pls 120.2 2006/08/23 08:44:16 arudas noship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_fnd_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
6
7 g_module_prefix CONSTANT VARCHAR2(50) := 'po.plsql.' || g_pkg_name || '.';
8
9
10 /**
11 * Public Procedure: control_document
12 * Requires: API message list has been initialized if p_init_msg_list is false.
13 * Modifies: All columns related to the control action, and who columns. The API
14 * message list.
15 * Effects: Performs the control action p_action on the specified document.
16 * Currently, only the 'CANCEL' action is supported. If the control action was
17 * successful, the document will be updated at the specified entity level.
18 * Derives any ID if the ID is NULL, but the matching number is passed in. If
19 * both the ID and number are passed in, the ID is used. Executes at shipment
20 * level if the final doc_id, line_id, and line_loc_id are not NULL. Executes
21 * at line level if only the final doc_id and line_id are not NULL. Executes
22 * at header level if only the final doc_id is not NULL. The document will be
23 * printed if it is a PO, PA, or RELEASE, and the p_print_flag is 'Y'. All
24 * changes will be committed upon success if p_commit is FND_API.G_TRUE.
25 * Appends to API message list on error, and leaves the document unchanged.
26 * Returns:
27 * x_return_status - FND_API.G_RET_STS_SUCCESS if control action succeeds
28 * FND_API.G_RET_STS_ERROR if control action fails
29 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
30 */
31 PROCEDURE control_document
32 (p_api_version IN NUMBER,
33 p_init_msg_list IN VARCHAR2,
34 p_commit IN VARCHAR2,
35 x_return_status OUT NOCOPY VARCHAR2,
36 p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
37 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
38 p_doc_id IN NUMBER,
39 p_doc_num IN PO_HEADERS.segment1%TYPE,
40 p_release_id IN NUMBER,
41 p_release_num IN NUMBER,
42 p_doc_line_id IN NUMBER,
43 p_doc_line_num IN NUMBER,
44 p_doc_line_loc_id IN NUMBER,
45 p_doc_shipment_num IN NUMBER,
46 p_action IN VARCHAR2,
47 p_action_date IN DATE,
48 p_cancel_reason IN PO_LINES.cancel_reason%TYPE,
49 p_cancel_reqs_flag IN VARCHAR2,
50 p_print_flag IN VARCHAR2,
51 p_note_to_vendor IN PO_HEADERS.note_to_vendor%TYPE,
52 p_use_gldate IN VARCHAR2, -- <ENCUMBRANCE FPJ>
53 p_org_id IN NUMBER --<Bug#4581621>
54 )
55 IS
56
57 l_api_name CONSTANT VARCHAR2(30) := 'control_document';
58 l_api_version CONSTANT NUMBER := 1.0;
59 l_org_id PO_HEADERS_ALL.org_id%type := p_org_id;
60 BEGIN
61 -- Start standard API initialization
62 SAVEPOINT control_document_PUB;
63 IF FND_API.to_boolean(p_init_msg_list) THEN
64 FND_MSG_PUB.initialize;
65 END IF;
66 IF NOT FND_API.compatible_api_call(l_api_version, p_api_version,
67 l_api_name, g_pkg_name)
68 THEN
69 RAISE FND_API.g_exc_unexpected_error;
70 END IF;
71 x_return_status := FND_API.g_ret_sts_success;
72 -- End standard API initialization
73
74 IF (g_fnd_debug = 'Y') THEN
75 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
76 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
77 '.invoked', 'Action: ' || NVL(p_action,'null') ||
78 ', Type: ' || NVL(p_doc_type,'null') ||
79 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null'));
80 END IF;
81 END IF;
82
83 --<Bug#4581621 Start>
84 PO_MOAC_UTILS_PVT.validate_orgid_pub_api(x_org_id => l_org_id);
85 PO_MOAC_UTILS_PVT.set_policy_context('S',l_org_id);
86 --<Bug#4581621 End>
87
88 PO_Document_Control_GRP.control_document
89 (p_api_version => 1.0,
90 p_init_msg_list => FND_API.G_FALSE,
91 p_commit => FND_API.G_FALSE,
92 x_return_status => x_return_status,
93 p_doc_type => p_doc_type,
94 p_doc_subtype => p_doc_subtype,
95 p_doc_id => p_doc_id,
96 p_doc_num => p_doc_num,
97 p_release_id => p_release_id,
98 p_release_num => p_release_num,
99 p_doc_line_id => p_doc_line_id,
100 p_doc_line_num => p_doc_line_num,
101 p_doc_line_loc_id => p_doc_line_loc_id,
102 p_doc_shipment_num => p_doc_shipment_num,
103 p_source => NULL, -- p_source is currently unresolved
104 p_action => p_action,
105 p_action_date => p_action_date,
106 p_cancel_reason => p_cancel_reason,
107 p_cancel_reqs_flag => p_cancel_reqs_flag,
108 p_print_flag => p_print_flag,
109 p_note_to_vendor => p_note_to_vendor,
110 p_use_gldate => p_use_gldate -- <ENCUMBRANCE FPJ>
111 );
112
113 IF (x_return_status = FND_API.g_ret_sts_error) THEN
114 RAISE FND_API.g_exc_error;
115 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
116 RAISE FND_API.g_exc_unexpected_error;
117 END IF;
118
119
120 -- Standard API check of p_commit
121 IF FND_API.to_boolean(p_commit) THEN
122 COMMIT WORK;
123 END IF;
124 EXCEPTION
125 WHEN FND_API.g_exc_error THEN
126 ROLLBACK TO control_document_PUB;
127 x_return_status := FND_API.g_ret_sts_error;
128 WHEN FND_API.g_exc_unexpected_error THEN
129 ROLLBACK TO control_document_PUB;
130 x_return_status := FND_API.g_ret_sts_unexp_error;
131 WHEN OTHERS THEN
132 ROLLBACK TO control_document_PUB;
133 x_return_status := FND_API.g_ret_sts_unexp_error;
134 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
135 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
136 IF (g_fnd_debug = 'Y') THEN
137 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
138 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
139 l_api_name || '.others_exception', 'Exception');
140 END IF;
141 END IF;
142 END IF;
143 END control_document;
144
145
146
147 END PO_Document_Control_PUB;