1 PACKAGE PO_DOCUMENT_ACTION_PVT AS
2 -- $Header: POXVDACS.pls 120.1 2005/10/11 07:10:51 pbamb noship $
3
4 /*
5 * Document Actions
6 * One note: it is best not to call a PO_DOCUMENT_ACTION_PVT method
7 * from within the code flow of another PO_DOCUMENT_ACTION_PVT method.
8 * These actions use a common switchboard, do_action(), as well as some
9 * common error handling (via pl/sql package varaible) which could
10 * conflict.
11 * Exception: find_forward_to_id, which calls verify_authority
12 * The find_forward_to_id does not use the switchboard; it is a
13 * complicated wrapper around many calls to verify_authority.
14 */
15
16 -- Global Constants
17
18
19 -- Previously doc manager actions
20 g_doc_action_APPROVE CONSTANT VARCHAR2(30)
21 := 'APPROVE';
22 g_doc_action_REJECT CONSTANT VARCHAR2(30)
23 := 'REJECT';
24 g_doc_action_FORWARD CONSTANT VARCHAR2(30)
25 := 'FORWARD';
26 g_doc_action_CHECK_APPROVE CONSTANT VARCHAR2(30)
27 := 'DOCUMENT_STATUS_CHECK_APPROVE';
28 g_doc_action_CHECK_REJECT CONSTANT VARCHAR2(30)
29 := 'DOCUMENT_STATUS_CHECK_APPROVE';
30 g_doc_action_CHECK_AUTHORITY CONSTANT VARCHAR2(30)
31 := 'VERIFY_AUTHORITY_CHECK';
32 g_doc_action_UPDATE_CLOSE_AUTO VARCHAR2(30)
33 := 'UPDATE_CLOSE_STATE';
34
35
36 -- Previously User exit actions
37 g_doc_action_RETURN CONSTANT VARCHAR2(30)
38 := 'RETURN';
39 g_doc_action_FREEZE CONSTANT VARCHAR2(30)
40 := 'FREEZE';
41 g_doc_action_UNFREEZE CONSTANT VARCHAR2(30)
42 := 'UNFREEZE';
43 g_doc_action_HOLD CONSTANT VARCHAR2(30)
44 := 'HOLD';
45 g_doc_action_RELEASE_HOLD CONSTANT VARCHAR2(30)
46 := 'RELEASE HOLD';
47 g_doc_action_OPEN CONSTANT VARCHAR2(30)
48 := 'OPEN';
49 g_doc_action_CLOSE CONSTANT VARCHAR2(30)
50 := 'CLOSE';
51 g_doc_action_CLOSE_RCV CONSTANT VARCHAR2(30)
52 := 'RECEIVE CLOSE';
53 g_doc_action_OPEN_RCV CONSTANT VARCHAR2(30)
54 := 'RECEIVE OPEN';
55 g_doc_action_CLOSE_INV CONSTANT VARCHAR2(30)
56 := 'INVOICE CLOSE';
57 g_doc_action_OPEN_INV CONSTANT VARCHAR2(30)
58 := 'INVOICE OPEN';
59 g_doc_action_FINALLY_CLOSE CONSTANT VARCHAR2(30)
60 := 'FINALLY CLOSE';
61
62
63 -- Not yet converted
64 g_doc_action_CANCEL CONSTANT VARCHAR2(30)
65 := 'CANCEL';
66
67
68 -- Possibly Deprecated actions - use PO_DOCUMENT_FUNDS_PVT instead?
69 g_doc_action_RESERVE CONSTANT VARCHAR2(30)
70 := 'RESERVE';
71 g_doc_action_UNRESERVE CONSTANT VARCHAR2(30)
72 := 'UNRESERVE';
73 g_doc_action_APPRV_RESERVE CONSTANT VARCHAR2(30)
74 := 'APPROVE AND RESERVE';
75 g_doc_action_CHECK_FUNDS CONSTANT VARCHAR2(30)
76 := 'CHECK FUNDS';
77
78 -- Intentionally Deprecated actions
79 g_doc_action_APPROVE_DOC CONSTANT VARCHAR2(30)
80 := 'APPROVE_DOCUMENT';
81 g_doc_action_FORWARD_DOC CONSTANT VARCHAR2(30)
82 := 'FORWARD_DOCUMENT';
83 g_doc_action_REJECT_DOC CONSTANT VARCHAR2(30)
84 := 'REJECT_DOCUMENT';
85
86
87
88 -- document authorization statuses
89 g_doc_status_APPROVED CONSTANT VARCHAR2(30)
90 := 'APPROVED';
91 g_doc_status_REJECTED CONSTANT VARCHAR2(30)
92 := 'REJECTED';
93 g_doc_status_PREAPPROVED CONSTANT VARCHAR2(30)
94 := 'PRE-APPROVED';
95 g_doc_status_INPROCESS CONSTANT VARCHAR2(30)
96 := 'IN PROCESS';
97 g_doc_status_INCOMPLETE CONSTANT VARCHAR2(30)
98 := 'INCOMPLETE';
99 g_doc_status_REAPPROVAL CONSTANT VARCHAR2(30)
100 := 'REQUIRES REAPPROVAL';
101 g_doc_status_RETURNED CONSTANT VARCHAR2(30)
102 := 'RETURNED';
103 g_doc_status_SENT CONSTANT VARCHAR2(30)
104 := 'SENT';
105
106 -- document closed statuses
107 g_doc_closed_sts_OPEN CONSTANT VARCHAR2(30)
108 := 'OPEN';
109 g_doc_closed_sts_CLOSED CONSTANT VARCHAR2(30)
110 := 'CLOSED';
111 g_doc_closed_sts_CLOSED_INV CONSTANT VARCHAR2(30)
112 := 'CLOSED FOR INVOICE';
113 g_doc_closed_sts_CLOSED_RCV CONSTANT VARCHAR2(30)
114 := 'CLOSED FOR RECEIVING';
115 g_doc_closed_sts_FIN_CLOSED CONSTANT VARCHAR2(30)
116 := 'FINALLY CLOSED';
117
118
119
120 -- Global Types
121
122 /* TYPE: DOC_ACTION_CALL_REC_TYPE
123 *
124 * Note: for a given action, only a few of the following
125 * container variables are actually used.
126 *
127 * Descriptions and examples:
128 *
129 * Used primarily as IN values:
130 *
131 * The following are used by most actions:
132 * action: one of g_doc_action_XXXX, e.g. g_doc_action_APPROVE
133 * lock_document: pass as true if you the document should be locked
134 * before handling the logic for the action
135 * document_type: 'PO', 'PA', 'REQUISITION', or 'RELEASE'
136 * document_subtype: 'STANDARD', 'BLANKET', 'CONTRACT', 'SCHEDULED', etc.
137 * document_id: po_header_id, requisition_header_id, or po_release_id
138 * note: usually used for action history purposes
139 *
140 * The following are primarily used by workflow actions (approve, reject, etc.)
141 * employee_id: ID of the employee taking the action
142 * new_document_status: one of g_doc_status_XXXX, e.g. g_doc_status_APPROVED
143 * needed by some actions so that they know what
144 * status to set the document to on completion
145 * approval_path_id: usually used for discovering next approver
146 * forward_to_id: ID of an employee to forward the document to
147 *
148 * The following are primarily used by closed status related actions:
149 * line_id/shipment_id: needed for some actions
150 * calling_mode: either 'PO', 'RCV', or 'AP'; needed for close actions. 'AP'
151 * code flow is slightly different for certain actions.
152 * called_from_conc: TRUE means we are being called from within a
153 * concurrent program. Used only in the close
154 * actions, to get the right login_id. Should be false
155 * for all other actions.
156 * action_date: Used in invoice open and finally close actions to
157 * determine gl_override_date for encumbrance calls.
158 * origin_doc_id : Needed for JFMIP for final close and invoice open actions.
159 * For those cases, this is the invoice id. Should be NULL
160 * if not coming from AP.
161 * use_gl_date : Needed only for encumbrance purposes, for final close
162 * and invoice open. 'Y' or 'N'
163 * offline_code: does not seem to be used; often passed in as NULL
164 *
165 *
166 * Used primarily as OUT values:
167 *
168 * return_code: used by certain actions to indicate functional success or
169 * error. Often, a null value means unconditional success.
170 * return_status: 'S' or 'U'. A 'U' indicates an unexpected technical
171 * error/exception occurred. Can also be 'E', but rarely used
172 * in that capacity, as the return_code variable is often used
173 * instead to denote functional errors.
174 * error_msg: concatenated string representing a stack of error messages
175 * often only relevant if return_status is 'U'
176 * functional_error: string representing a functional error. Ofen
177 * contains a translated error string from fnd. Should
178 * usually be used only when return_status is 'S'
179 * online_report_id: stores ID of online report with more error info.
180 * Used by certain actions only.
181 *
182 */
183 TYPE DOC_ACTION_CALL_REC_TYPE IS RECORD
184 (
185 action VARCHAR2(30),
186 lock_document BOOLEAN,
187 document_type VARCHAR2(25),
188 document_subtype VARCHAR2(25),
189 document_id NUMBER,
190 employee_id NUMBER,
191 new_document_status VARCHAR2(25),
192 approval_path_id NUMBER,
193 forward_to_id NUMBER,
194 note PO_ACTION_HISTORY.NOTE%TYPE,
195 return_code VARCHAR2(25),
196 return_status VARCHAR2(1), -- replaces return_value
197 error_msg VARCHAR2(2000),
198 functional_error VARCHAR2(2000),
199 line_id NUMBER,
200 shipment_id NUMBER,
201 calling_mode VARCHAR2(4),
202 called_from_conc BOOLEAN,
203 origin_doc_id NUMBER,
204 action_date DATE,
205 online_report_id NUMBER,
206 use_gl_date VARCHAR2(1),
207 offline_code VARCHAR2(1)
208 );
209
210
211 -- Methods
212
213 PROCEDURE do_action(
214 p_action_ctl_rec IN OUT NOCOPY PO_DOCUMENT_ACTION_PVT.doc_action_call_rec_type
215 );
216
217 PROCEDURE do_approve(
218 p_document_id IN VARCHAR2
219 , p_document_type IN VARCHAR2
220 , p_document_subtype IN VARCHAR2
221 , p_note IN VARCHAR2
222 , p_approval_path_id IN NUMBER
223 , x_return_status OUT NOCOPY VARCHAR2
224 , x_exception_msg OUT NOCOPY VARCHAR2
225 );
226
227 PROCEDURE do_reject(
228 p_document_id IN VARCHAR2
229 , p_document_type IN VARCHAR2
230 , p_document_subtype IN VARCHAR2
231 , p_note IN VARCHAR2
232 , p_approval_path_id IN NUMBER
233 , x_return_status OUT NOCOPY VARCHAR2
234 , x_return_code OUT NOCOPY VARCHAR2
235 , x_exception_msg OUT NOCOPY VARCHAR2
236 , x_online_report_id OUT NOCOPY NUMBER
237 );
238
239
240 PROCEDURE do_forward(
241 p_document_id IN VARCHAR2
242 , p_document_type IN VARCHAR2
243 , p_document_subtype IN VARCHAR2
244 , p_new_doc_status IN VARCHAR2
245 , p_note IN VARCHAR2
246 , p_approval_path_id IN NUMBER
247 , p_forward_to_id IN NUMBER
248 , x_return_status OUT NOCOPY VARCHAR2
249 , x_exception_msg OUT NOCOPY VARCHAR2
250 );
251
252 PROCEDURE do_return(
253 p_document_id IN VARCHAR2
254 , p_document_type IN VARCHAR2
255 , p_document_subtype IN VARCHAR2
256 , p_note IN VARCHAR2
257 , p_approval_path_id IN NUMBER
258 , x_return_status OUT NOCOPY VARCHAR2
259 , x_return_code OUT NOCOPY VARCHAR2
260 , x_exception_msg OUT NOCOPY VARCHAR2
261 , x_online_report_id OUT NOCOPY NUMBER
262 );
263
264 PROCEDURE do_freeze(
265 p_document_id IN VARCHAR2
266 , p_document_type IN VARCHAR2
267 , p_document_subtype IN VARCHAR2
268 , p_reason IN VARCHAR2
269 , x_return_status OUT NOCOPY VARCHAR2
270 , x_return_code OUT NOCOPY VARCHAR2
271 , x_exception_msg OUT NOCOPY VARCHAR2
272 );
273
274 PROCEDURE do_unfreeze(
275 p_document_id IN VARCHAR2
276 , p_document_type IN VARCHAR2
277 , p_document_subtype IN VARCHAR2
278 , p_reason IN VARCHAR2
279 , x_return_status OUT NOCOPY VARCHAR2
280 , x_return_code OUT NOCOPY VARCHAR2
281 , x_exception_msg OUT NOCOPY VARCHAR2
282 );
283
284 PROCEDURE do_hold(
285 p_document_id IN VARCHAR2
286 , p_document_type IN VARCHAR2
287 , p_document_subtype IN VARCHAR2
288 , p_reason IN VARCHAR2
289 , x_return_status OUT NOCOPY VARCHAR2
290 , x_return_code OUT NOCOPY VARCHAR2
291 , x_exception_msg OUT NOCOPY VARCHAR2
292 );
293
294 PROCEDURE do_release_hold(
295 p_document_id IN VARCHAR2
296 , p_document_type IN VARCHAR2
297 , p_document_subtype IN VARCHAR2
298 , p_reason IN VARCHAR2
299 , x_return_status OUT NOCOPY VARCHAR2
300 , x_return_code OUT NOCOPY VARCHAR2
301 , x_exception_msg OUT NOCOPY VARCHAR2
302 );
303
304 PROCEDURE verify_authority(
305 p_document_id IN VARCHAR2
306 , p_document_type IN VARCHAR2
307 , p_document_subtype IN VARCHAR2
308 , p_employee_id IN VARCHAR2
309 , x_return_status OUT NOCOPY VARCHAR2
310 , x_return_code OUT NOCOPY VARCHAR2
311 , x_exception_msg OUT NOCOPY VARCHAR2
312 , x_auth_failed_msg OUT NOCOPY VARCHAR2
313 );
314
315 PROCEDURE check_doc_status_approve(
316 p_document_id IN VARCHAR2
317 , p_document_type IN VARCHAR2
318 , p_document_subtype IN VARCHAR2
319 , x_return_status OUT NOCOPY VARCHAR2
320 , x_return_code OUT NOCOPY VARCHAR2
321 , x_exception_msg OUT NOCOPY VARCHAR2
322 );
323
324 PROCEDURE check_doc_status_reject(
325 p_document_id IN VARCHAR2
326 , p_document_type IN VARCHAR2
330 , x_exception_msg OUT NOCOPY VARCHAR2
327 , p_document_subtype IN VARCHAR2
328 , x_return_status OUT NOCOPY VARCHAR2
329 , x_return_code OUT NOCOPY VARCHAR2
331 );
332
333 PROCEDURE find_forward_to_id(
334 p_document_id IN NUMBER
335 , p_document_type IN VARCHAR2
336 , p_document_subtype IN VARCHAR2
337 , p_employee_id IN NUMBER
338 , p_approval_path_id IN NUMBER
339 , x_return_status OUT NOCOPY VARCHAR2
340 , x_forward_to_id OUT NOCOPY NUMBER
341 );
342
343 PROCEDURE auto_update_close_state(
344 p_document_id IN NUMBER
345 , p_document_type IN VARCHAR2
346 , p_document_subtype IN VARCHAR2
347 , p_line_id IN NUMBER DEFAULT NULL
348 , p_shipment_id IN NUMBER DEFAULT NULL
349 , p_calling_mode IN VARCHAR2 DEFAULT 'PO'
350 , p_called_from_conc IN BOOLEAN DEFAULT FALSE
351 , x_return_status OUT NOCOPY VARCHAR2
352 , x_exception_msg OUT NOCOPY VARCHAR2
353 , x_return_code OUT NOCOPY VARCHAR2
354 );
355
356 PROCEDURE do_manual_close(
357 p_action IN VARCHAR2
358 , p_document_id IN NUMBER
359 , p_document_type IN VARCHAR2
360 , p_document_subtype IN VARCHAR2
361 , p_line_id IN NUMBER
362 , p_shipment_id IN NUMBER
363 , p_reason IN VARCHAR2
364 , p_action_date IN DATE DEFAULT SYSDATE
365 , p_calling_mode IN VARCHAR2 DEFAULT 'PO'
366 , p_origin_doc_id IN NUMBER DEFAULT NULL
367 , p_called_from_conc IN BOOLEAN DEFAULT FALSE
368 , p_use_gl_date IN VARCHAR2 DEFAULT 'N'
369 , x_return_status OUT NOCOPY VARCHAR2
370 , x_exception_msg OUT NOCOPY VARCHAR2
371 , x_return_code OUT NOCOPY VARCHAR2
372 , x_online_report_id OUT NOCOPY NUMBER
373 );
374
375
376
377
378 -- PO_DOCUMENT_ACTION_XXXX Shared Error Message Trace Handlers
379 -- These should not be called outside of DOCUMENT_ACTION code.
380 PROCEDURE get_error_message(
381 x_error_message OUT NOCOPY VARCHAR2
382 );
383
384 PROCEDURE error_msg_append(
385 p_subprogram_name IN VARCHAR2
386 , p_position IN NUMBER
387 , p_message_text IN VARCHAR2
388 );
389
390 PROCEDURE error_msg_append(
391 p_subprogram_name IN VARCHAR2
392 , p_position IN NUMBER
393 , p_sqlcode IN NUMBER
394 , p_sqlerrm IN VARCHAR2
395 );
396
397 -- <R12 BEGIN INVCONV>
398 PROCEDURE update_secondary_qty_cancelled (
399 p_join_column IN VARCHAR2
400 , p_entity_id IN NUMBER
401 );
402 -- <R12 END INVCONV>
403
404 END PO_DOCUMENT_ACTION_PVT;