1 PACKAGE BODY PO_Document_Control_GRP AS
2 /* $Header: POXGDCOB.pls 120.2 2005/06/29 19:23:08 shsiung noship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_fnd_debug CONSTANT 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 * Public Procedure: control_document
11 * Requires: API message list has been initialized if p_init_msg_list is false.
12 * Modifies: All columns related to the control action, and who columns. The API
13 * message list.
14 * Effects: Performs the control action p_action on the specified document.
15 * Currently, only the 'CANCEL' action is supported. If the control action was
16 * successful, the document will be updated at the specified entity level.
17 * Derives any ID if the ID is NULL, but the matching number is passed in. If
18 * both the ID and number are passed in, the ID is used. Executes at shipment
19 * level if the final doc_id, line_id, and line_loc_id are not NULL. Executes
20 * at line level if only the final doc_id and line_id are not NULL. Executes
21 * at header level if only the final doc_id is not NULL. The document will be
22 * printed if it is a PO, PA, or RELEASE, and the p_print_flag is 'Y'. All
23 * changes will be committed upon success if p_commit is FND_API.G_TRUE.
24 * Appends to API message list on error, and leaves the document unchanged.
25 * Returns:
26 * x_return_status - FND_API.G_RET_STS_SUCCESS if control action succeeds
27 * FND_API.G_RET_STS_ERROR if control action fails
28 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
29 */
30 PROCEDURE control_document
31 (p_api_version IN NUMBER,
32 p_init_msg_list IN VARCHAR2,
33 p_commit IN VARCHAR2,
34 x_return_status OUT NOCOPY VARCHAR2,
35 p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
36 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
37 p_doc_id IN NUMBER,
38 p_doc_num IN PO_HEADERS.segment1%TYPE,
39 p_release_id IN NUMBER,
40 p_release_num IN NUMBER,
41 p_doc_line_id IN NUMBER,
42 p_doc_line_num IN NUMBER,
43 p_doc_line_loc_id IN NUMBER,
44 p_doc_shipment_num IN NUMBER,
45 p_source IN VARCHAR2,
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 )
54 IS
55
56 l_api_name CONSTANT VARCHAR2(30) := 'control_document';
57 l_api_version CONSTANT NUMBER := 1.0;
58 l_doc_id NUMBER;
59 l_doc_line_id NUMBER;
60 l_doc_line_loc_id NUMBER;
61
62 BEGIN
63 -- Start standard API initialization
64 SAVEPOINT control_document_GRP;
65 IF FND_API.to_boolean(p_init_msg_list) THEN
66 FND_MSG_PUB.initialize;
67 END IF;
68 IF NOT FND_API.compatible_api_call(l_api_version, p_api_version,
69 l_api_name, g_pkg_name)
70 THEN
71 RAISE FND_API.g_exc_unexpected_error;
72 END IF;
73 x_return_status := FND_API.g_ret_sts_success;
74 -- End standard API initialization
75
76 IF (g_fnd_debug = 'Y') THEN
77 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
78 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
79 '.invoked', 'Source: ' || NVL(p_source,'null') ||
80 ', Action: ' || NVL(p_action,'null') ||
81 ', Type: ' || NVL(p_doc_type,'null') ||
82 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null'));
83 END IF;
84 END IF;
85
86 -- Validate the action parameter
87 IF (p_action NOT IN ('CANCEL')) THEN
88 FND_MESSAGE.set_name('PO','PO_CONTROL_INVALID_ACTION');
89 FND_MESSAGE.set_token('ACTION',p_action);
90 IF (g_fnd_debug = 'Y') THEN
91 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
92 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
93 '.invalid_action', FALSE);
94 END IF;
95 END IF;
96 FND_MSG_PUB.add;
97 RAISE FND_API.g_exc_error;
98 END IF;
99
100 val_doc_params(p_api_version => 1.0,
101 p_init_msg_list => FND_API.G_FALSE,
102 x_return_status => x_return_status,
103 p_doc_type => p_doc_type,
104 p_doc_subtype => p_doc_subtype,
105 p_doc_id => p_doc_id,
106 p_doc_num => p_doc_num,
107 p_doc_line_id => p_doc_line_id,
108 p_doc_line_num => p_doc_line_num,
109 p_release_id => p_release_id,
110 p_release_num => p_release_num,
111 p_doc_line_loc_id => p_doc_line_loc_id,
112 p_doc_shipment_num => p_doc_shipment_num,
113 x_doc_id => l_doc_id,
114 x_doc_line_id => l_doc_line_id,
115 x_doc_line_loc_id => l_doc_line_loc_id);
116 IF (x_return_status = FND_API.g_ret_sts_error) THEN
117 RAISE FND_API.g_exc_error;
118 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
119 RAISE FND_API.g_exc_unexpected_error;
120 END IF;
121
122 PO_Document_Control_PVT.control_document
123 (p_api_version => 1.0,
124 p_init_msg_list => FND_API.G_FALSE,
125 p_commit => FND_API.G_FALSE,
126 x_return_status => x_return_status,
127 p_doc_type => p_doc_type,
128 p_doc_subtype => p_doc_subtype,
129 p_doc_id => l_doc_id,
130 p_doc_line_id => l_doc_line_id,
131 p_doc_line_loc_id => l_doc_line_loc_id,
132 p_source => p_source,
133 p_action => p_action,
134 p_action_date => p_action_date,
135 p_cancel_reason => p_cancel_reason,
136 p_cancel_reqs_flag => p_cancel_reqs_flag,
137 p_print_flag => p_print_flag,
138 p_note_to_vendor => p_note_to_vendor,
139 p_use_gldate => p_use_gldate -- <ENCUMBRANCE FPJ>
140 );
141
142 IF (x_return_status = FND_API.g_ret_sts_error) THEN
143 RAISE FND_API.g_exc_error;
144 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
145 RAISE FND_API.g_exc_unexpected_error;
146 END IF;
147
148
149 -- Standard API check of p_commit
150 IF FND_API.to_boolean(p_commit) THEN
151 COMMIT WORK;
152 END IF;
153 EXCEPTION
154 WHEN FND_API.g_exc_error THEN
155 ROLLBACK TO control_document_GRP;
156 x_return_status := FND_API.g_ret_sts_error;
157 WHEN FND_API.g_exc_unexpected_error THEN
158 ROLLBACK TO control_document_GRP;
159 x_return_status := FND_API.g_ret_sts_unexp_error;
160 WHEN OTHERS THEN
161 ROLLBACK TO control_document_GRP;
162 x_return_status := FND_API.g_ret_sts_unexp_error;
163 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
164 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
165 IF (g_fnd_debug = 'Y') THEN
166 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
167 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
168 l_api_name || '.others_exception', 'Exception');
169 END IF;
170 END IF;
171 END IF;
172 END control_document;
173
174
175 /**
176 * Private Procedure: validate_control_action
177 * Requires: API message list has been initialized.
178 * Modifies: API message list.
179 * Effects: Validates that p_action is an allowable control action to be
180 * executed by the caller on the document entity level specified. Derives any
181 * ID if the ID is NULL, but the matching number is passed in. If both ID and
182 * number are passed in, the ID is used. Validates at shipment level if the
183 * final line_loc_id is not NULL. Else, validates at line level if the final
184 * line_id is not NULL. Else, validates at header level if the final doc_id is
185 * not NULL. Control actions supported for p_action are: 'CANCEL'.
186 * Requisitions are currently not supported. Appends to API message list on
187 * error.
188 * Returns:
189 * x_return_status - FND_API.G_RET_STS_SUCCESS if validation succeeds
190 * FND_API.G_RET_STS_ERROR if validation fails
191 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
192 */
193 PROCEDURE validate_control_action
194 (p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
195 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
196 p_doc_id IN NUMBER,
197 p_doc_num IN PO_HEADERS.segment1%TYPE,
198 p_release_id IN NUMBER,
199 p_release_num IN NUMBER,
200 p_doc_line_id IN NUMBER,
201 p_doc_line_num IN NUMBER,
202 p_doc_line_loc_id IN NUMBER,
203 p_doc_shipment_num IN NUMBER,
204 p_action IN VARCHAR2,
205 p_agent_id IN PO_HEADERS.agent_id%TYPE,
206 x_return_status OUT NOCOPY VARCHAR2)
207 IS
208
209 l_api_name CONSTANT VARCHAR2(30) := 'validate_control_action';
210 l_control_level NUMBER;
211 l_doc_id NUMBER;
212 l_doc_line_id NUMBER;
213 l_doc_line_loc_id NUMBER;
214
215 BEGIN
216 x_return_status := FND_API.g_ret_sts_success;
217
218 IF (g_fnd_debug = 'Y') THEN
219 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
220 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
221 '.invoked', 'Action: ' || NVL(p_action,'null') ||
222 ', Type: ' || NVL(p_doc_type,'null') ||
223 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null'));
224 END IF;
225 END IF;
226
227 -- Validate the action parameter
228 IF (p_action NOT IN ('CANCEL')) THEN
229 FND_MESSAGE.set_name('PO','PO_CONTROL_INVALID_ACTION');
230 FND_MESSAGE.set_token('ACTION',p_action);
231 IF (g_fnd_debug = 'Y') THEN
232 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
233 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
234 '.invalid_action', FALSE);
235 END IF;
236 END IF;
237 FND_MSG_PUB.add;
238 RAISE FND_API.g_exc_error;
239 END IF;
240
241 val_doc_params(p_api_version => 1.0,
242 p_init_msg_list => FND_API.G_FALSE,
243 x_return_status => x_return_status,
244 p_doc_type => p_doc_type,
245 p_doc_subtype => p_doc_subtype,
246 p_doc_id => p_doc_id,
247 p_doc_num => p_doc_num,
248 p_release_id => p_release_id,
249 p_release_num => p_release_num,
250 p_doc_line_id => p_doc_line_id,
251 p_doc_line_num => p_doc_line_num,
252 p_doc_line_loc_id => p_doc_line_loc_id,
253 p_doc_shipment_num => p_doc_shipment_num,
254 x_doc_id => l_doc_id,
255 x_doc_line_id => l_doc_line_id,
256 x_doc_line_loc_id => l_doc_line_loc_id);
257 IF (x_return_status = FND_API.g_ret_sts_error) THEN
258 RAISE FND_API.g_exc_error;
259 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
260 RAISE FND_API.g_exc_unexpected_error;
261 END IF;
262
263 -- Call private level validation. If the agent ID is not NULL, then user
264 -- authority and document access levels will be validated as well.
265 PO_Document_Control_PVT.val_control_action
266 (p_api_version => 1.0,
267 p_init_msg_list => FND_API.G_FALSE,
268 x_return_status => x_return_status,
269 p_doc_type => p_doc_type,
270 p_doc_subtype => p_doc_subtype,
271 p_doc_id => l_doc_id,
272 p_doc_line_id => l_doc_line_id,
273 p_doc_line_loc_id => l_doc_line_loc_id,
274 p_action => p_action,
275 p_agent_id => p_agent_id,
276 x_control_level => l_control_level);
277
278 IF (x_return_status = FND_API.g_ret_sts_error) THEN
279 RAISE FND_API.g_exc_error;
280 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
281 RAISE FND_API.g_exc_unexpected_error;
282 END IF;
283
284 EXCEPTION
285 WHEN FND_API.g_exc_error THEN
286 x_return_status := FND_API.g_ret_sts_error;
287 WHEN FND_API.g_exc_unexpected_error THEN
288 x_return_status := FND_API.g_ret_sts_unexp_error;
289 WHEN OTHERS THEN
290 x_return_status := FND_API.g_ret_sts_unexp_error;
291 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
292 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
293 IF (g_fnd_debug = 'Y') THEN
294 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
295 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
296 l_api_name || '.others_exception', 'Exception');
297 END IF;
298 END IF;
299 END IF;
300 END validate_control_action;
301
302
303 /**
304 * Public Procedure: val_control_action
305 * Requires: API message list has been initialized if p_init_msg_list is false.
306 * Modifies: API message list.
307 * Effects: Validates that p_action is an allowable control action to be
308 * executed by the caller on the document entity level specified. Derives any
309 * ID if the ID is NULL, but the matching number is passed in. If both ID and
310 * number are passed in, the ID is used. Validates at shipment level if the
311 * final line_loc_id is not NULL. Else, validates at line level if the final
312 * line_id is not NULL. Else, validates at header level if the final doc_id is
313 * not NULL. Control actions supported for p_action are: 'CANCEL'.
314 * Requisitions are currently not supported. Appends to API message list on
315 * error.
316 * Returns:
317 * x_return_status - FND_API.G_RET_STS_SUCCESS if validation succeeds
318 * FND_API.G_RET_STS_ERROR if validation fails
319 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
320 */
321 PROCEDURE val_control_action
322 (p_api_version IN NUMBER,
323 p_init_msg_list IN VARCHAR2,
324 x_return_status OUT NOCOPY VARCHAR2,
325 p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
326 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
327 p_doc_id IN NUMBER,
328 p_doc_num IN PO_HEADERS.segment1%TYPE,
329 p_release_id IN NUMBER,
330 p_release_num IN NUMBER,
331 p_doc_line_id IN NUMBER,
332 p_doc_line_num IN NUMBER,
333 p_doc_line_loc_id IN NUMBER,
334 p_doc_shipment_num IN NUMBER,
335 p_action IN VARCHAR2)
336 IS
337
338 l_api_name CONSTANT VARCHAR2(30) := 'val_control_action';
339 l_api_version CONSTANT NUMBER := 1.0;
340
341 -- Apps context should be initialized, so we can get the employee id directly
342 l_agent_id PO_HEADERS.agent_id%TYPE := FND_GLOBAL.employee_id;
343
344 BEGIN
345 -- Start standard API initialization
346 IF FND_API.to_boolean(p_init_msg_list) THEN
347 FND_MSG_PUB.initialize;
348 END IF;
349 IF NOT FND_API.compatible_api_call(l_api_version, p_api_version,
350 l_api_name, g_pkg_name)
351 THEN
352 RAISE FND_API.g_exc_unexpected_error;
353 END IF;
354 x_return_status := FND_API.g_ret_sts_success;
355 -- End standard API initialization
356
357 -- Ensure that we are not using a NULL agent ID.
358 IF (l_agent_id IS NULL) THEN
359 l_agent_id := -1;
360 END IF;
361
362 IF (g_fnd_debug = 'Y') THEN
363 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
364 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
365 '.invoked', 'Action: ' || NVL(p_action,'null') ||
366 ', Type: ' || NVL(p_doc_type,'null') ||
367 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null') ||
368 ', agent ID: ' || NVL(TO_CHAR(l_agent_id),'null'));
369 END IF;
370 END IF;
371
372 -- Call private procedure validation with agent ID. This ensures that the
373 -- user's authority and document access level are validated.
374 validate_control_action(p_doc_type => p_doc_type,
375 p_doc_subtype => p_doc_subtype,
376 p_doc_id => p_doc_id,
377 p_doc_num => p_doc_num,
378 p_release_id => p_release_id,
379 p_release_num => p_release_num,
380 p_doc_line_id => p_doc_line_id,
381 p_doc_line_num => p_doc_line_num,
382 p_doc_line_loc_id => p_doc_line_loc_id,
383 p_doc_shipment_num => p_doc_shipment_num,
384 p_action => p_action,
385 p_agent_id => l_agent_id,
386 x_return_status => x_return_status);
387 IF (x_return_status = FND_API.g_ret_sts_error) THEN
388 RAISE FND_API.g_exc_error;
389 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
390 RAISE FND_API.g_exc_unexpected_error;
391 END IF;
392
393 EXCEPTION
394 WHEN FND_API.g_exc_error THEN
395 x_return_status := FND_API.g_ret_sts_error;
396 WHEN FND_API.g_exc_unexpected_error THEN
397 x_return_status := FND_API.g_ret_sts_unexp_error;
398 WHEN OTHERS THEN
399 x_return_status := FND_API.g_ret_sts_unexp_error;
400 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
401 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
402 IF (g_fnd_debug = 'Y') THEN
403 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
404 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
405 l_api_name || '.others_exception', 'Exception');
406 END IF;
407 END IF;
408 END IF;
409 END val_control_action;
410
411
412 /**
413 * Public Procedure: check_control_action
414 * Requires: API message list has been initialized if p_init_msg_list is false.
415 * Modifies: API message list.
416 * Effects: Checks that p_action is an allowable control action to be executed
417 * on the document at the entity level specified, regardless of the API
418 * caller's authority or access level. Derives any ID if the ID is NULL, but
419 * the matching number is passed in. If both ID and number are passed in, the
420 * ID is used. Checks at shipment level if the final line_loc_id is not NULL.
421 * Else, checks at line level if the final line_id is not NULL. Else, checks
422 * at header level if the final doc_id is not NULL. Control actions supported
423 * for p_action are: 'CANCEL'. Requisitions are currently not supported.
424 * Appends to API message list on error.
425 * Returns:
426 * x_return_status - FND_API.G_RET_STS_SUCCESS if check succeeds
427 * FND_API.G_RET_STS_ERROR if check fails
428 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
429 */
430 PROCEDURE check_control_action
431 (p_api_version IN NUMBER,
432 p_init_msg_list IN VARCHAR2,
433 x_return_status OUT NOCOPY VARCHAR2,
434 p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
435 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
436 p_doc_id IN NUMBER,
437 p_doc_num IN PO_HEADERS.segment1%TYPE,
438 p_release_id IN NUMBER,
439 p_release_num IN NUMBER,
440 p_doc_line_id IN NUMBER,
441 p_doc_line_num IN NUMBER,
442 p_doc_line_loc_id IN NUMBER,
443 p_doc_shipment_num IN NUMBER,
444 p_action IN VARCHAR2)
445 IS
446
447 l_api_name CONSTANT VARCHAR2(30) := 'check_control_action';
448 l_api_version CONSTANT NUMBER := 1.0;
449
450 BEGIN
451 -- Start standard API initialization
452 IF FND_API.to_boolean(p_init_msg_list) THEN
453 FND_MSG_PUB.initialize;
454 END IF;
455 IF NOT FND_API.compatible_api_call(l_api_version, p_api_version,
456 l_api_name, g_pkg_name)
457 THEN
458 RAISE FND_API.g_exc_unexpected_error;
459 END IF;
460 x_return_status := FND_API.g_ret_sts_success;
461 -- End standard API initialization
462
463 IF (g_fnd_debug = 'Y') THEN
464 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
465 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
466 '.invoked', 'Action: ' || NVL(p_action,'null') ||
467 ', Type: ' || NVL(p_doc_type,'null') ||
468 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null'));
469 END IF;
470 END IF;
471
472 -- Call private procedure validation with a NULL agent ID. This will
473 -- ensure that no user authority or document access levels are checked.
474 validate_control_action(p_doc_type => p_doc_type,
475 p_doc_subtype => p_doc_subtype,
476 p_doc_id => p_doc_id,
477 p_doc_num => p_doc_num,
478 p_release_id => p_release_id,
479 p_release_num => p_release_num,
480 p_doc_line_id => p_doc_line_id,
481 p_doc_line_num => p_doc_line_num,
482 p_doc_line_loc_id => p_doc_line_loc_id,
483 p_doc_shipment_num => p_doc_shipment_num,
484 p_action => p_action,
485 p_agent_id => NULL,
486 x_return_status => x_return_status);
487 IF (x_return_status = FND_API.g_ret_sts_error) THEN
488 RAISE FND_API.g_exc_error;
489 ELSIF (x_return_status = FND_API.g_ret_sts_unexp_error) THEN
490 RAISE FND_API.g_exc_unexpected_error;
491 END IF;
492
493 EXCEPTION
494 WHEN FND_API.g_exc_error THEN
495 x_return_status := FND_API.g_ret_sts_error;
496 WHEN FND_API.g_exc_unexpected_error THEN
497 x_return_status := FND_API.g_ret_sts_unexp_error;
498 WHEN OTHERS THEN
499 x_return_status := FND_API.g_ret_sts_unexp_error;
500 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
501 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
502 IF (g_fnd_debug = 'Y') THEN
503 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
504 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
505 l_api_name || '.others_exception', 'Exception');
506 END IF;
507 END IF;
508 END IF;
509 END check_control_action;
510
511
512 /**
513 * Private Procedure: val_po_params
514 * Requires: API message list has been initialized. Document is PO or PA.
515 * Modifies: API message list
516 * Effects: Derives any ID if the ID is NULL and the matching number is passed
517 * in. If both the ID and number are passed in, the ID is used for validation.
518 * The final IDs must match the document specified. Appends to API message
519 * list on error.
520 * Returns:
521 * x_return_status - FND_API.G_RET_STS_SUCCESS if derived all IDs correctly
522 * FND_API.G_RET_STS_ERROR if error occurred
523 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
524 */
525 PROCEDURE val_po_params
526 (p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
527 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
528 p_doc_id IN NUMBER,
529 p_doc_num IN PO_HEADERS.segment1%TYPE,
530 p_doc_line_id IN NUMBER,
531 p_doc_line_num IN NUMBER,
532 p_doc_line_loc_id IN NUMBER,
533 p_doc_shipment_num IN NUMBER,
534 x_doc_id OUT NOCOPY NUMBER,
535 x_doc_line_id OUT NOCOPY NUMBER,
536 x_doc_line_loc_id OUT NOCOPY NUMBER,
537 x_return_status OUT NOCOPY VARCHAR2)
538 IS
539
540 l_api_name CONSTANT VARCHAR2(30) := 'val_po_params';
541 l_exists VARCHAR2(10);
542 l_control_level NUMBER;
543
544 BEGIN
545 x_return_status := FND_API.g_ret_sts_success;
546
547 IF (g_fnd_debug = 'Y') THEN
548 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
549 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
550 '.invoked', 'Type: ' || NVL(p_doc_type,'null') ||
551 ', Subtype: ' || NVL(p_doc_subtype,'null') ||
552 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null') ||
553 ', Num: ' || NVL(p_doc_num,'null'));
554 END IF;
555 END IF;
556
557 -- Must have a document ID or document num
558 IF (p_doc_id IS NULL) AND (p_doc_num IS NULL) THEN
559 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
560 IF (g_fnd_debug = 'Y') THEN
561 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
562 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name
563 || '.invalid_doc_ids', FALSE);
564 END IF;
565 END IF;
566 FND_MSG_PUB.add;
567 RAISE FND_API.g_exc_error;
568 END IF; --<if p_doc_id ...>
569
570 -- initialize outputs
571 x_doc_id := p_doc_id;
572 x_doc_line_id := p_doc_line_id;
573 x_doc_line_loc_id := p_doc_line_loc_id;
574
575 -- Find level of control action
576 IF (p_doc_line_loc_id IS NOT NULL) OR (p_doc_shipment_num IS NOT NULL)
577 THEN
578 l_control_level := PO_Document_Control_PVT.g_shipment_level;
579 ELSIF (p_doc_line_id IS NOT NULL) OR (p_doc_line_num IS NOT NULL) THEN
580 l_control_level := PO_Document_Control_PVT.g_line_level;
581 ELSE
582 l_control_level := PO_Document_Control_PVT.g_header_level;
583 END IF; --<if p_doc_line_loc_id ...>
584
585 -- Derive header
586 IF (p_doc_id IS NULL) THEN
587 SELECT poh.po_header_id
588 INTO x_doc_id
589 FROM po_headers poh
590 WHERE poh.segment1 = p_doc_num AND
591 poh.type_lookup_code = p_doc_subtype;
592 ELSE
593 SELECT poh.po_header_id
594 INTO x_doc_id
595 FROM po_headers poh
596 WHERE poh.po_header_id = p_doc_id;
597 END IF;
598
599 IF (g_fnd_debug = 'Y') THEN
600 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
601 FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix || l_api_name ||
602 '.validated_header', 'ID: ' || NVL(TO_CHAR(x_doc_id),'null'));
603 END IF;
604 END IF;
605
606 IF (l_control_level <> PO_Document_Control_PVT.g_header_level) THEN
607
608 IF (p_doc_line_id IS NULL) THEN
609 SELECT pol.po_line_id
610 INTO x_doc_line_id
611 FROM po_lines pol
612 WHERE pol.po_header_id = x_doc_id AND
613 pol.line_num = p_doc_line_num;
614 ELSE
615 SELECT 'Exists'
616 INTO l_exists
617 FROM po_lines pol
618 WHERE pol.po_line_id = x_doc_line_id AND
619 pol.po_header_id = x_doc_id;
620 END IF; --<if p_doc_line_id ...>
621
622 IF (g_fnd_debug = 'Y') THEN
623 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
624 FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix ||
625 l_api_name || '.validated_line', 'ID: ' ||
626 NVL(TO_CHAR(x_doc_line_id),'null'));
627 END IF;
628 END IF;
629
630 -- Derive shipment if at shipment level and doc is PO
631 IF (l_control_level = PO_Document_Control_PVT.g_shipment_level) THEN
632
633 IF (p_doc_type = 'PO') THEN
634
635 IF (p_doc_line_loc_id IS NULL) THEN
636 SELECT poll.line_location_id
637 INTO x_doc_line_loc_id
638 FROM po_line_locations poll
639 WHERE poll.shipment_num = p_doc_shipment_num AND
640 poll.po_line_id = x_doc_line_id AND
641 poll.po_header_id = x_doc_id;
642 ELSE
643 SELECT 'Exists'
644 INTO l_exists
645 FROM po_line_locations poll
646 WHERE poll.line_location_id = x_doc_line_loc_id AND
647 poll.po_line_id = x_doc_line_id AND
648 poll.po_header_id = x_doc_id;
649 END IF; --<if p_doc_line_loc_id ...>
650
651 IF (g_fnd_debug = 'Y') THEN
652 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
653 FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix ||
654 l_api_name || '.validated_shipment', 'ID: ' ||
655 NVL(TO_CHAR(x_doc_line_loc_id),'null'));
656 END IF;
657 END IF;
658
659 ELSE
660 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
661 IF (g_fnd_debug = 'Y') THEN
662 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
663 FND_LOG.message(FND_LOG.level_error, g_module_prefix ||
664 l_api_name || '.pa_has_ship_ids', FALSE);
665 END IF;
666 END IF;
667 FND_MSG_PUB.add;
668 RAISE FND_API.g_exc_error;
669 END IF; --<if p_doc_type PO>
670
671 END IF; --<if l_control_level = g_shipment_level>
672
673 END IF; --<if l_control_level <> g_header_level>
674
675 EXCEPTION
676 WHEN NO_DATA_FOUND OR TOO_MANY_ROWS THEN
677 x_return_status := FND_API.g_ret_sts_error;
678 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
679 IF (g_fnd_debug = 'Y') THEN
680 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
681 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
682 '.invalid_doc_ids', FALSE);
683 END IF;
684 END IF;
685 FND_MSG_PUB.add;
686 WHEN FND_API.g_exc_error THEN
687 x_return_status := FND_API.g_ret_sts_error;
688 WHEN OTHERS THEN
689 x_return_status := FND_API.g_ret_sts_unexp_error;
690 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
691 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
692 IF (g_fnd_debug = 'Y') THEN
693 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
694 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
695 l_api_name || '.others_exception', 'Exception');
696 END IF;
697 END IF;
698 END IF;
699 END val_po_params;
700
701
702 /**
703 * Private Procedure: val_rel_params
704 * Requires: API message list has been initialized. Document is a Release.
705 * Modifies: API message list
706 * Effects: Derives any ID if the ID is NULL and the matching number is passed
707 * in. If both the ID and number are passed in, the ID is used for validation.
708 * The final IDs must match the document specified. Appends to API message
709 * list on error.
710 * Returns:
711 * x_return_status - FND_API.G_RET_STS_SUCCESS if derived all IDs correctly
712 * FND_API.G_RET_STS_ERROR if error occurred
713 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
714 */
715 PROCEDURE val_rel_params
716 (p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
717 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
718 p_doc_id IN NUMBER,
719 p_doc_num IN PO_HEADERS.segment1%TYPE,
720 p_release_id IN NUMBER,
721 p_release_num IN NUMBER,
722 p_doc_line_loc_id IN NUMBER,
723 p_doc_shipment_num IN NUMBER,
724 x_doc_id OUT NOCOPY NUMBER,
725 x_doc_line_loc_id OUT NOCOPY NUMBER,
726 x_return_status OUT NOCOPY VARCHAR2)
727 IS
728
729 l_api_name CONSTANT VARCHAR2(30) := 'val_rel_params';
730 l_exists VARCHAR2(10);
731 l_control_level NUMBER;
732 l_release_po_header_id NUMBER;
733 l_release_po_subtype PO_DOCUMENT_TYPES.document_subtype%TYPE;
734
735 BEGIN
736 x_return_status := FND_API.g_ret_sts_success;
737
738 IF (g_fnd_debug = 'Y') THEN
739 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
740 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
741 '.invoked', 'Type: ' || NVL(p_doc_type,'null') ||
742 ', Subtype: ' || NVL(p_doc_subtype,'null') ||
743 ', ID: ' || NVL(TO_CHAR(p_release_id),'null') ||
744 ', Num: ' || NVL(TO_CHAR(p_release_num),'null'));
745 END IF;
746 END IF;
747
748 -- Must have a document ID or document num if release_id is null
749 IF (p_release_id IS NULL) AND (p_doc_id IS NULL) AND (p_doc_num IS NULL)
750 THEN
751 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
752 IF (g_fnd_debug = 'Y') THEN
753 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
754 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name
755 || '.invalid_doc_ids', FALSE);
756 END IF;
757 END IF;
758 FND_MSG_PUB.add;
759 RAISE FND_API.g_exc_error;
760 END IF; --<if p_doc_id ...>
761
762 -- initialize output
763 x_doc_id := p_release_id;
764 x_doc_line_loc_id := p_doc_line_loc_id;
765
766 -- Find level of control action
767 IF (p_doc_line_loc_id IS NOT NULL) OR (p_doc_shipment_num IS NOT NULL)
768 THEN
769 l_control_level := PO_Document_Control_PVT.g_rel_shipment_level;
770 ELSE
771 l_control_level := PO_Document_Control_PVT.g_rel_header_level;
772 END IF; --<if p_doc_line_loc_id ...>
773
774 -- Derive release header
775 IF (p_release_id IS NULL) THEN
776
777 IF (p_doc_id IS NULL) THEN
778 IF (p_doc_subtype = 'BLANKET') THEN
779 l_release_po_subtype := 'BLANKET';
780 ELSE
781 l_release_po_subtype := 'PLANNED';
782 END IF;
783
784 -- SQL What: Query to find po_header_id and po_release_id
785 -- SQL Why: Need to derive the missing unique po_release_id
786 -- SQL Join: po_header_id
787 SELECT poh.po_header_id, por.po_release_id
788 INTO l_release_po_header_id, x_doc_id
789 FROM po_headers poh,
790 po_releases por
791 WHERE poh.segment1 = p_doc_num AND
792 poh.type_lookup_code = l_release_po_subtype AND
793 por.po_header_id = poh.po_header_id AND
794 por.release_num = p_release_num;
795 ELSE
796 -- SQL What: Query to find po_header_id and po_release_id
797 -- SQL Why: Need to derive the missing unique po_release_id
798 -- SQL Join: po_header_id
799 SELECT poh.po_header_id, por.po_release_id
800 INTO l_release_po_header_id, x_doc_id
801 FROM po_headers poh,
802 po_releases por
803 WHERE poh.po_header_id = p_doc_id AND
804 por.po_header_id = poh.po_header_id AND
805 por.release_num = p_release_num;
806 END IF; --<if p_doc_id is null>
807
808 ELSE
809 SELECT por.po_header_id
810 INTO l_release_po_header_id
811 FROM po_releases por
812 WHERE por.po_release_id = x_doc_id;
813 END IF; --<if p_release_id is null>
814
815 IF (g_fnd_debug = 'Y') THEN
816 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
817 FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix || l_api_name ||
818 '.validated_rel_header', 'ID: ' ||
819 NVL(TO_CHAR(x_doc_id),'null'));
820 END IF;
821 END IF;
822
823 -- Derive release shipment if at shipment level
824 IF (l_control_level = PO_Document_Control_PVT.g_rel_shipment_level) THEN
825
826 IF (p_doc_line_loc_id IS NULL) THEN
827 -- SQL What: Query to find the line_location_id
828 -- SQL Why: Need to derive the missing unique line_location_id
829 -- SQL Join: po_line_id
830 SELECT poll.line_location_id
831 INTO x_doc_line_loc_id
832 FROM po_line_locations poll,
833 po_lines pol
834 WHERE poll.po_release_id = x_doc_id AND
835 poll.po_header_id = l_release_po_header_id AND
836 poll.po_line_id = pol.po_line_id AND
837 poll.shipment_num = p_doc_shipment_num AND
838 pol.po_header_id = l_release_po_header_id;
839 ELSE
840 SELECT 'Exists'
841 INTO l_exists
842 FROM po_line_locations poll
843 WHERE poll.line_location_id = x_doc_line_loc_id AND
844 poll.po_release_id = x_doc_id;
845 END IF; --<if p_doc_line_loc_id ...>
846
847 IF (g_fnd_debug = 'Y') THEN
848 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
849 FND_LOG.string(FND_LOG.LEVEL_STATEMENT, g_module_prefix ||
850 l_api_name || '.validated_rel_shipment', 'ID: ' ||
851 NVL(TO_CHAR(x_doc_line_loc_id),'null'));
852 END IF;
853 END IF;
854
855 END IF; --<if l_control_level = g_rel_shipment_level>
856
857 EXCEPTION
858 WHEN NO_DATA_FOUND OR TOO_MANY_ROWS THEN
859 x_return_status := FND_API.g_ret_sts_error;
860 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
861 IF (g_fnd_debug = 'Y') THEN
862 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
863 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
864 '.invalid_doc_ids', FALSE);
865 END IF;
866 END IF;
867 FND_MSG_PUB.add;
868 WHEN FND_API.g_exc_error THEN
869 x_return_status := FND_API.g_ret_sts_error;
870 WHEN OTHERS THEN
871 x_return_status := FND_API.g_ret_sts_unexp_error;
872 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
873 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
874 IF (g_fnd_debug = 'Y') THEN
875 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
876 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
877 l_api_name || '.others_exception', 'Exception');
878 END IF;
879 END IF;
880 END IF;
881 END val_rel_params;
882
883
884 /**
885 * Public Procedure: val_doc_params
886 * Requires: API message list has been initialized if p_init_msg_list is false.
887 * Modifies: API message list
888 * Effects: Validates that the input parameters are all valid and match the
889 * document specified. Derives any ID if the ID is NULL, but the matching
890 * number is passed in. If both the ID and number are passed in, the ID is
891 * used. Appends to API message list on error.
892 * Returns:
893 * x_return_status - FND_API.G_RET_STS_SUCCESS if validation succeeds
894 * FND_API.G_RET_STS_ERROR if validation fails
895 * FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
896 * x_doc_id - The valid document ID
897 * x_doc_line_id - The valid line ID, if at line level
898 * x_doc_line_loc_id - The valid line location ID, if at shipment level
899 */
900 PROCEDURE val_doc_params
901 (p_api_version IN NUMBER,
902 p_init_msg_list IN VARCHAR2,
903 x_return_status OUT NOCOPY VARCHAR2,
904 p_doc_type IN PO_DOCUMENT_TYPES.document_type_code%TYPE,
905 p_doc_subtype IN PO_DOCUMENT_TYPES.document_subtype%TYPE,
906 p_doc_id IN NUMBER,
907 p_doc_num IN PO_HEADERS.segment1%TYPE,
908 p_release_id IN NUMBER,
909 p_release_num IN NUMBER,
910 p_doc_line_id IN NUMBER,
911 p_doc_line_num IN NUMBER,
912 p_doc_line_loc_id IN NUMBER,
913 p_doc_shipment_num IN NUMBER,
914 x_doc_id OUT NOCOPY NUMBER,
915 x_doc_line_id OUT NOCOPY NUMBER,
916 x_doc_line_loc_id OUT NOCOPY NUMBER)
917 IS
918
919 l_api_name CONSTANT VARCHAR2(30) := 'val_doc_params';
920 l_api_version CONSTANT NUMBER := 1.0;
921 l_exists VARCHAR2(10);
922 l_control_level NUMBER;
923 l_release_po_header_id NUMBER;
924 l_release_po_subtype PO_DOCUMENT_TYPES.document_subtype%TYPE;
925
926 BEGIN
927 -- Start standard API initialization
928 IF FND_API.to_boolean(p_init_msg_list) THEN
929 FND_MSG_PUB.initialize;
930 END IF;
931 IF NOT FND_API.compatible_api_call(l_api_version, p_api_version,
932 l_api_name, g_pkg_name)
933 THEN
934 RAISE FND_API.g_exc_unexpected_error;
935 END IF;
936 x_return_status := FND_API.g_ret_sts_success;
937 -- End standard API initialization
938
939 IF (g_fnd_debug = 'Y') THEN
940 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
941 FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||
942 '.invoked', 'Type: ' || NVL(p_doc_type,'null') ||
943 ', Subtype: ' || NVL(p_doc_subtype,'null') ||
944 ', ID: ' || NVL(TO_CHAR(p_doc_id),'null'));
945 END IF;
946 END IF;
947
948 -- Must have correct, matching doc types and subtypes
949 IF ((p_doc_type IS NULL) OR (p_doc_subtype IS NULL)) OR
950 (p_doc_type NOT IN ('PO','PA','RELEASE')) OR
951 ((p_doc_type = 'PO') AND (p_doc_subtype NOT IN('STANDARD','PLANNED'))) OR
952 ((p_doc_type = 'PA') AND (p_doc_subtype NOT IN('BLANKET','CONTRACT'))) OR
953 ((p_doc_type = 'RELEASE') AND
954 (p_doc_subtype NOT IN ('BLANKET','SCHEDULED')))
955 THEN
956 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_TYPE_SUBTYPE');
957 FND_MESSAGE.set_token('TYPE',p_doc_type);
958 FND_MESSAGE.set_token('SUBTYPE',p_doc_subtype);
959 IF (g_fnd_debug = 'Y') THEN
960 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
961 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
962 '.invalid_doc_type', FALSE);
963 END IF;
964 END IF;
965 FND_MSG_PUB.add;
966 RAISE FND_API.g_exc_error;
967 END IF;
968
969 IF (p_doc_type IN ('PO','PA')) THEN
970
971 IF (p_release_id IS NOT NULL) OR (p_release_num IS NOT NULL) THEN
972 -- Should not pass in release info for POs and PAs
973 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
974 IF (g_fnd_debug = 'Y') THEN
975 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
976 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
977 '.po_pa_has_release_info', FALSE);
978 END IF;
979 END IF;
980 FND_MSG_PUB.add;
981 RAISE FND_API.g_exc_error;
982 END IF; --<if p_doc_line_id ...>
983
984 val_po_params(p_doc_type => p_doc_type,
985 p_doc_subtype => p_doc_subtype,
986 p_doc_id => p_doc_id,
987 p_doc_num => p_doc_num,
988 p_doc_line_id => p_doc_line_id,
989 p_doc_line_num => p_doc_line_num,
990 p_doc_line_loc_id => p_doc_line_loc_id,
991 p_doc_shipment_num => p_doc_shipment_num,
992 x_doc_id => x_doc_id,
993 x_doc_line_id => x_doc_line_id,
994 x_doc_line_loc_id => x_doc_line_loc_id,
995 x_return_status => x_return_status);
996
997 ELSE -- else is a release
998
999 IF (p_doc_line_id IS NOT NULL) OR (p_doc_line_num IS NOT NULL) THEN
1000 -- Releases don't have lines
1001 FND_MESSAGE.set_name('PO','PO_INVALID_DOC_IDS');
1002 IF (g_fnd_debug = 'Y') THEN
1003 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
1004 FND_LOG.message(FND_LOG.level_error, g_module_prefix || l_api_name ||
1005 '.release_has_line_ids', FALSE);
1006 END IF;
1007 END IF;
1008 FND_MSG_PUB.add;
1009 RAISE FND_API.g_exc_error;
1010 END IF; --<if p_doc_line_id ...>
1011
1012 val_rel_params(p_doc_type => p_doc_type,
1013 p_doc_subtype => p_doc_subtype,
1014 p_doc_id => p_doc_id,
1015 p_doc_num => p_doc_num,
1016 p_release_id => p_release_id,
1017 p_release_num => p_release_num,
1018 p_doc_line_loc_id => p_doc_line_loc_id,
1019 p_doc_shipment_num => p_doc_shipment_num,
1020 x_doc_id => x_doc_id,
1021 x_doc_line_loc_id => x_doc_line_loc_id,
1022 x_return_status => x_return_status);
1023
1024 x_doc_line_id := NULL;
1025
1026 END IF; --<if p_doc_type PO or PA>
1027
1028 EXCEPTION
1029 WHEN FND_API.g_exc_error THEN
1030 x_return_status := FND_API.g_ret_sts_error;
1031 WHEN FND_API.g_exc_unexpected_error THEN
1032 x_return_status := FND_API.g_ret_sts_unexp_error;
1033 WHEN OTHERS THEN
1034 x_return_status := FND_API.g_ret_sts_unexp_error;
1035 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
1036 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name);
1037 IF (g_fnd_debug = 'Y') THEN
1038 IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
1039 FND_LOG.string(FND_LOG.level_unexpected, g_module_prefix ||
1040 l_api_name || '.others_exception', 'Exception');
1041 END IF;
1042 END IF;
1043 END IF;
1044 END val_doc_params;
1045
1046
1047 END PO_Document_Control_GRP;