[Home] [Help]
PACKAGE BODY: APPS.PO_PDOI_DISTRIBUTIONS_SV3
Source
1 PACKAGE BODY PO_PDOI_DISTRIBUTIONS_SV3 AS
2 /* $Header: POXPIDVB.pls 120.2 2005/08/15 18:59:49 vinokris noship $ */
3
4 /*================================================================
5
6 PROCEDURE NAME: validate_po_dist()
7
8 ==================================================================*/
9
10 /**
11 * Private Procedure: validate_po_dist
12 * Requires: none
13 * Modifies: PO_INTERFACE_ERRORS
14 * Effects: Validates the given PO distribution information. Writes
15 * any validation errors to the PO_INTERFACE_ERRORS table.
16 * Returns: none
17 */
18 PROCEDURE validate_po_dist(x_interface_header_id in NUMBER,
19 x_interface_line_id in NUMBER,
20 x_interface_distribution_id in NUMBER,
21 x_po_distribution_id IN NUMBER,
22 x_charge_account_id IN NUMBER,
23 x_destination_organization_id IN NUMBER,
24 x_sob_id IN NUMBER,
25 x_item_id IN NUMBER,
26 x_ship_to_organization_id IN NUMBER,
27 x_deliver_to_person_id IN NUMBER,
28 x_deliver_to_location_id IN NUMBER,
29 x_header_processable_flag in out NOCOPY varchar2,
30 x_quantity_ordered IN NUMBER,
31 x_distribution_num IN NUMBER,
32 x_quantity_delivered IN NUMBER,
33 x_quantity_billed IN NUMBER,
34 x_quantity_cancelled IN NUMBER,
35 x_destination_type_code IN VARCHAR2,
36 x_accrue_on_receipt_flag IN VARCHAR2,
37 p_transaction_flow_header_id IN NUMBER, --<Shared Proc FPJ>
38 x_destination_subinventory IN VARCHAR2,
39 x_wip_entity_id IN NUMBER,
40 x_wip_repetitive_schedule_id IN NUMBER,
41 x_prevent_encumbrance_flag IN VARCHAR2,
42 x_budget_account_id IN NUMBER,
43 x_accrual_account_id IN NUMBER,
44 x_variance_account_id IN NUMBER,
45 -- Bug 2137906 fixed. added ussgl_transaction_code.
46 x_ussgl_transaction_code IN VARCHAR2,
47 x_gl_date IN DATE,
48 x_chart_of_accounts_id IN NUMBER,
49 x_project_account_context IN VARCHAR2,
50 x_project_id IN NUMBER,
51 x_task_id IN NUMBER,
52 x_expenditure_type IN VARCHAR2,
53 x_expenditure_organization_id IN NUMBER,
54 p_order_type_lookup_code IN VARCHAR2, --<SERVICES FPJ>
55 p_amount IN NUMBER, --<SERVICES FPJ>
56 -- <PO_PJM_VALIDATION FPI START>
57 x_need_by_date IN DATE,
58 x_promised_date IN DATE,
59 x_expenditure_item_date IN DATE, --Bug 2892199
60 -- <PO_PJM_VALIDATION FPI END>
61 p_ship_to_ou_id IN NUMBER --< Bug 3265539 >
62 )
63 IS
64
65 X_progress varchar2(3) := NULL;
66 x_valid varchar2(1) := NULL;
67 x_item_status varchar2(2);
68 x_enc_flag varchar2(1);
69 x_temp_val BOOLEAN ;
70
71 BEGIN
72
73 x_progress := '010';
74 if x_po_distribution_id is null then
75 po_interface_errors_sv1.handle_interface_errors(
76 'PO_DOCS_OPEN_INTERFACE',
77 'FATAL',
78 null,
79 x_interface_header_id,
80 x_interface_line_id,
81 --need to create this message
82 'PO_PDOI_NO_DIST_ID',
83 'PO_DISTRIBUTIONS_INTERFACE',
84 'PO_DISTRIBUTION_ID' ,
85 null,null,null,null,null,null,
86 null,null,null,null,null,null,
87 x_header_processable_flag, x_interface_distribution_id);
88 end if;
89
90 x_progress := '020';
91
92 if x_charge_account_id is null then
93 po_interface_errors_sv1.handle_interface_errors(
94 'PO_DOCS_OPEN_INTERFACE',
95 'FATAL',
96 null,
97 x_interface_header_id,
98 x_interface_line_id,
99 --need to create this message
100 'PO_PDOI_NO_CHG_ACCT',
101 'PO_DISTRIBUTIONS_INTERFACE',
102 'CHARGE_ACCOUNT_ID' ,
103 null,null,null,null,null,null,
104 null,null,null,null,null,null,
105 x_header_processable_flag, x_interface_distribution_id);
106 end if;
107
108 x_progress := '030';
109
110 --<SERVICES FPJ START>
111 IF (p_order_type_lookup_code IN ('RATE', 'FIXED PRICE')) THEN
112 IF (NVL(p_amount, 0) <= 0) THEN
113 PO_INTERFACE_ERRORS_SV1.handle_interface_errors(
114 X_interface_type => 'PO_DOCS_OPEN_INTERFACE',
115 X_Error_type => 'FATAL',
116 X_Batch_id => NULL,
117 X_Interface_Header_Id => X_interface_header_id,
118 X_Interface_Line_id => X_interface_line_id,
119 X_Error_message_name => 'PO_PDOI_SVC_MUST_AMT',
120 X_Table_name => 'PO_DISTRIBUTIONS_INTERFACE',
121 X_Column_name => 'AMOUNT',
122 X_TokenName1 => NULL,
123 X_TokenName2 => NULL,
124 X_TokenName3 => NULL,
125 X_TokenName4 => NULL,
126 X_TokenName5 => NULL,
127 X_TokenName6 => NULL,
128 X_TokenValue1 => NULL,
129 X_TokenValue2 => NULL,
130 X_TokenValue3 => NULL,
131 X_TokenValue4 => NULL,
132 X_TokenValue5 => NULL,
133 X_TokenValue6 => NULL,
134 X_header_processable_flag => x_header_processable_flag);
135 END IF;
136
137 IF (NVL(x_quantity_ordered, 0) <> 0) THEN
138 PO_INTERFACE_ERRORS_SV1.handle_interface_errors(
139 X_interface_type => 'PO_DOCS_OPEN_INTERFACE',
140 X_Error_type => 'FATAL',
141 X_Batch_id => NULL,
142 X_Interface_Header_Id => X_interface_header_id,
143 X_Interface_Line_id => X_interface_line_id,
144 X_Error_message_name => 'PO_SVC_NO_QTY',
145 X_Table_name => 'PO_DISTRIBUTIONS_INTERFACE',
146 X_Column_name => 'QUANTITY_ORDERED',
147 X_TokenName1 => NULL,
148 X_TokenName2 => NULL,
149 X_TokenName3 => NULL,
150 X_TokenName4 => NULL,
151 X_TokenName5 => NULL,
152 X_TokenName6 => NULL,
153 X_TokenValue1 => NULL,
154 X_TokenValue2 => NULL,
155 X_TokenValue3 => NULL,
156 X_TokenValue4 => NULL,
157 X_TokenValue5 => NULL,
158 X_TokenValue6 => NULL,
159 X_header_processable_flag => x_header_processable_flag);
160 END IF; --IF (NVL(x_quantity_ordered, 0) <> 0)
161
162 ELSE --if p_order_type_lookup_code not in ('RATE', 'FIXED PRICE')
163 --<SERVICES FPJ END>
164 if (x_quantity_ordered <= 0) OR (x_quantity_ordered is null) then
165 po_interface_errors_sv1.handle_interface_errors(
166 'PO_DOCS_OPEN_INTERFACE',
167 'FATAL',
168 null,
169 x_interface_header_id,
170 x_interface_line_id,
171 --need to create this message
172 'PO_PDOI_INVALID_QTY',
173 'PO_DISTRIBUTIONS_INTERFACE',
174 'QUANTITY_ORDERED' ,
175 'QUANTITY_ORDERED',null,null,null,null,null,
176 x_QUANTITY_ORDERED,null,null,null,null,null,
177 x_header_processable_flag, x_interface_distribution_id);
178 end if;
179
180 --<SERVICES FPJ START>
181 IF (NVL(p_amount,0) <> 0) THEN
182 PO_INTERFACE_ERRORS_SV1.handle_interface_errors(
183 X_interface_type => 'PO_DOCS_OPEN_INTERFACE',
184 X_Error_type => 'FATAL',
185 X_Batch_id => NULL,
186 X_Interface_Header_Id => X_interface_header_id,
187 X_Interface_Line_id => X_interface_line_id,
188 X_Error_message_name => 'PO_SVC_NO_AMT',
189 X_Table_name => 'PO_DISTRIBUTIONS_INTERFACE',
190 X_Column_name => 'AMOUNT_ORDERED',
191 X_TokenName1 => NULL,
192 X_TokenName2 => NULL,
193 X_TokenName3 => NULL,
194 X_TokenName4 => NULL,
195 X_TokenName5 => NULL,
196 X_TokenName6 => NULL,
197 X_TokenValue1 => NULL,
198 X_TokenValue2 => NULL,
199 X_TokenValue3 => NULL,
200 X_TokenValue4 => NULL,
201 X_TokenValue5 => NULL,
202 X_TokenValue6 => NULL,
203 X_header_processable_flag => x_header_processable_flag);
204 END IF;
205 END IF; --IF (p_order_type_lookup_code IN ('RATE', 'FIXED PRICE')
206 --<SERVICES FPJ END>
207
208 x_progress := '040';
209
210 if (x_distribution_num is null) then
211 po_interface_errors_sv1.handle_interface_errors(
212 'PO_DOCS_OPEN_INTERFACE',
213 'FATAL',
214 null,
215 x_interface_header_id,
216 x_interface_line_id,
217 --need to create this message
218 'PO_PDOI_NO_DIST_NUM',
219 'PO_DISTRIBUTIONS_INTERFACE',
220 'DISTRIBUTION_NUM' ,
221 null,null,null,null,null,null,
222 null,null,null,null,null,null,
223 x_header_processable_flag, x_interface_distribution_id);
224 end if;
225
226 x_progress := '060';
227
228 -- Fixed Bug 2681256 draising
229 -- if (x_quantity_delivered <> 0) OR (x_quantity_delivered is not null) then
230
231 if nvl(x_quantity_delivered,0) <> 0 then
232 po_interface_errors_sv1.handle_interface_errors(
233 'PO_DOCS_OPEN_INTERFACE',
234 'FATAL',
235 null,
236 x_interface_header_id,
237 x_interface_line_id,
238 --need to create this message
239 'PO_PDOI_INVALID_QTY_DEL',
240 'PO_DISTRIBUTIONS_INTERFACE',
241 'QUANTITY_DELIVERED' ,
242 'QUANTITY_DELIVERED',null,null,null,null,null,
243 x_QUANTITY_DELIVERED,null,null,null,null,null,
244 x_header_processable_flag, x_interface_distribution_id);
245 end if;
246
247 x_progress := '070';
248
249 -- if (x_quantity_billed <> 0) OR (x_quantity_billed is not null) then
250 if nvl(x_quantity_billed,0) <> 0 then
251 po_interface_errors_sv1.handle_interface_errors(
252 'PO_DOCS_OPEN_INTERFACE',
253 'FATAL',
254 null,
255 x_interface_header_id,
256 x_interface_line_id,
257 --need to create this message
258 'PO_PDOI_INVALID_QTY_BILL',
259 'PO_DISTRIBUTIONS_INTERFACE',
260 'QUANTITY_BILLED' ,
261 'QUANTITY_BILLED',null,null,null,null,null,
262 x_QUANTITY_BILLED,null,null,null,null,null,
263 x_header_processable_flag, x_interface_distribution_id);
264 end if;
265
266 x_progress := '080';
267
268 -- if (x_quantity_cancelled <> 0) OR (x_quantity_cancelled is not null) then
269
270 if nvl(x_quantity_cancelled,0) <> 0 then
271 po_interface_errors_sv1.handle_interface_errors(
272 'PO_DOCS_OPEN_INTERFACE',
273 'FATAL',
274 null,
275 x_interface_header_id,
276 x_interface_line_id,
277 --need to create this message
278 'PO_PDOI_INVALID_QTY_CANCELLED',
279 'PO_DISTRIBUTIONS_INTERFACE',
280 'QUANTITY_CANCELLED' ,
281 'QUANTITY_CANCELLED',null,null,null,null,null,
282 x_QUANTITY_CANCELLED,null,null,null,null,null,
283 x_header_processable_flag, x_interface_distribution_id);
284 end if;
285
286 x_progress := '090';
287
288 --< Shared Proc FPJ Start>
289 -- The only validation needed for destination org is to ensure it is the same
290 -- as the Ship-to org, which has already been validated.
291 --
292 --< Bug 3022783 Start >
293 -- Destination org must be equal to ship-to org.
294 IF NVL(x_destination_organization_id, -11) <>
295 NVL(x_ship_to_organization_id, -99)
296 THEN
297 po_interface_errors_sv1.handle_interface_errors(
298 'PO_DOCS_OPEN_INTERFACE',
299 'FATAL',
300 null,
301 x_interface_header_id,
302 x_interface_line_id,
303 'PO_PDOI_INVALID_DEST_ORG',
304 'PO_DISTRIBUTIONS_INTERFACE',
305 'DESTINATION_ORGANIZATION_ID' ,
306 'DESTINATION_ORGANIZATION',null,null,null,null,null,
307 x_DESTINATION_ORGANIZATION_ID,null,null,null,null,null,
308 x_header_processable_flag, x_interface_distribution_id);
309 end if;
310 --< Bug 3022783 End >
311 --< Shared Proc FPJ End >
312
313 x_progress := '100';
314
315 if x_destination_type_code is not null then
316 po_items_sv2.get_item_status(x_item_id,
317 x_ship_to_organization_id,
318 x_item_status );
319 x_valid := validate_destination_type_code(x_destination_type_code, x_item_status,
320 x_accrue_on_receipt_flag, p_transaction_flow_header_id); --<Shared Proc FPJ>
321 if x_valid <> 'Y' then
322 po_interface_errors_sv1.handle_interface_errors(
323 'PO_DOCS_OPEN_INTERFACE',
324 'FATAL',
325 null,
326 x_interface_header_id,
327 x_interface_line_id,
328 --need to create this message
329 'PO_PDOI_INVALID_DEST_TYPE',
330 'PO_DISTRIBUTIONS_INTERFACE',
331 'DESTINATION_TYPE_CODE' ,
332 'DESTINATION_TYPE',null,null,null,null,null,
333 x_DESTINATION_TYPE_CODE,null,null,null,null,null,
334 x_header_processable_flag, x_interface_distribution_id);
335 end if;
336 end if;
337
338 x_progress := '110';
339
340 if x_deliver_to_location_id is not null then
341 x_valid := validate_deliver_to_loc_id(x_deliver_to_location_id, x_ship_to_organization_id);
342 if x_valid <> 'Y' then
343 po_interface_errors_sv1.handle_interface_errors(
344 'PO_DOCS_OPEN_INTERFACE',
345 'FATAL',
346 null,
347 x_interface_header_id,
348 x_interface_line_id,
349 --need to create this message
350 'PO_PDOI_INVALID_DEL_LOCATION',
351 'PO_DISTRIBUTIONS_INTERFACE',
352 'DELIVER_TO_LOCATION_ID' ,
353 'DELIVER_TO_LOCATION',null,null,null,null,null,
354 x_DELIVER_TO_LOCATION_ID,null,null,null,null,null,
355 x_header_processable_flag, x_interface_distribution_id);
356 end if;
357 end if;
358
359 x_progress := '115';
360
361 if x_deliver_to_person_id is not null then
362 x_valid := validate_deliver_to_person_id(x_deliver_to_person_id);
363 if x_valid <> 'Y' then
364 po_interface_errors_sv1.handle_interface_errors(
365 'PO_DOCS_OPEN_INTERFACE',
366 'FATAL',
367 null,
368 x_interface_header_id,
369 x_interface_line_id,
370 --need to create this message
371 'PO_PDOI_INVALID_DEL_PERSON',
372 'PO_DISTRIBUTIONS_INTERFACE',
373 'DELIVER_TO_PERSON_ID' ,
374 'DELIVER_TO_PERSON',null,null,null,null,null,
375 x_DELIVER_TO_PERSON_ID,null,null,null,null,null,
376 x_header_processable_flag, x_interface_distribution_id);
377 end if;
378 end if;
379
380 x_progress := '120';
381
382 IF (x_item_id is NULL) AND ( x_destination_type_code = 'INVENTORY' ) THEN
383 po_interface_errors_sv1.handle_interface_errors(
384 'PO_DOCS_OPEN_INTERFACE',
385 'FATAL',
386 null,
387 x_interface_header_id,
388 x_interface_line_id,
389 --need to create this message
390 'PO_PDOI_INVALID_DEST_TYPE',
391 'PO_DISTRIBUTIONS_INTERFACE',
392 'DESTINATION_TYPE_CODE' ,
393 'DESTINATION_TYPE',null,null,null,null,null,
394 x_DESTINATION_TYPE_CODE,null,null,null,null,null,
395 x_header_processable_flag, x_interface_distribution_id);
396 END IF;
397
398 x_progress := '130';
399
400 if (x_destination_TYPE_CODE = 'INVENTORY') and (x_destination_subinventory is not null) then
401 x_valid := validate_dest_subinventory(x_destination_subinventory, x_ship_to_organization_id, x_item_id);
402 if x_valid <> 'Y' then
403 po_interface_errors_sv1.handle_interface_errors(
404 'PO_DOCS_OPEN_INTERFACE',
405 'FATAL',
406 null,
407 x_interface_header_id,
408 x_interface_line_id,
409 --need to create this message
410 'PO_PDOI_INVALID_DEST_SUBINV',
411 'PO_DISTRIBUTIONS_INTERFACE',
412 'DESTINATION_SUBINVENTORY' ,
413 'DESTINATION_SUBINVENTORY',null,null,null,null,null,
414 x_DESTINATION_SUBINVENTORY,null,null,null,null,null,
415 x_header_processable_flag, x_interface_distribution_id);
416 end if;
417 END IF;
418
419 x_progress := '140';
420
421 if (x_destination_type_code in ('SHOP FLOOR','EXPENSE')) and (x_destination_subinventory is not null) then
422 po_interface_errors_sv1.handle_interface_errors(
423 'PO_DOCS_OPEN_INTERFACE',
424 'FATAL',
425 null,
426 x_interface_header_id,
427 x_interface_line_id,
428 --need to create this message
429 'PO_PDOI_INVALID_DEST_SUBINV',
430 'PO_DISTRIBUTIONS_INTERFACE',
431 'DESTINATION_SUBINVENTORY' ,
432 'DESTINATION_SUBINVENTORY',null,null,null,null,null,
433 x_DESTINATION_SUBINVENTORY,null,null,null,null,null,
434 x_header_processable_flag, x_interface_distribution_id);
435
436 end if;
437
438 x_progress := '150';
439
440 /* Bug 3083961 x_wip_repetitive_schedule_id can be null. So check only x_wip_entity_id. Fail the
441 Distribution if it is null and x_destination_type_code is SHOP FLOOR */
442
443 if (x_destination_type_code = 'SHOP FLOOR') then
444 if (x_wip_entity_id is not null) then
445 x_valid := validate_wip(x_wip_entity_id, x_destination_organization_id, x_wip_repetitive_schedule_id);
446 if x_valid <> 'Y' then
447 if x_wip_repetitive_schedule_id is not null then
448 po_interface_errors_sv1.handle_interface_errors(
449 'PO_DOCS_OPEN_INTERFACE',
450 'FATAL',
451 null,
452 x_interface_header_id,
453 x_interface_line_id,
454 --need to create this message
455 'PO_PDOI_INVALID_WIP_SCHED',
456 'PO_DISTRIBUTIONS_INTERFACE',
457 'WIP_REPETITIVE_SCHEDULE_ID' ,
458 'WIP_REPETITIVE_SCHEDULE_ID',null,null,null,null,null,
459 x_WIP_REPETITIVE_SCHEDULE_ID,null,null,null,null,null,
460 x_header_processable_flag, x_interface_distribution_id);
461 else
462 /* Bug 3083961 */
463 po_interface_errors_sv1.handle_interface_errors(
464 'PO_DOCS_OPEN_INTERFACE',
465 'FATAL',
466 null,
467 x_interface_header_id,
468 x_interface_line_id,
469 'PO_PDOI_INVALID_WIP_ENTITY',
470 'PO_DISTRIBUTIONS_INTERFACE',
471 'WIP_ENTITY_ID',
472 'WIP_ENTITY',null,null,null,null,null,
473 x_wip_entity_id,null,null,null,null,null,
474 x_header_processable_flag, x_interface_distribution_id);
475 end if;
476 end if; /* x_valid */
477 else -- x_wip_entity_id is null
478 /* Bug 3083961 */
479 po_interface_errors_sv1.handle_interface_errors(
480 'PO_DOCS_OPEN_INTERFACE',
481 'FATAL',
482 null,
483 X_interface_header_id,
484 X_interface_line_id,
485 'PO_PDOI_COLUMN_NOT_NULL',
486 'PO_DISTRIBUTIONS_INTERFACE',
487 'WIP_ENTITY_ID',
488 'COLUMN_NAME',
489 null,null,null,null,null,
490 'WIP_ENTITY_ID',
491 null,null, null,null,null,
492 X_header_processable_flag);
493 end if;
494 end if;
495
496 x_progress := '160';
497
498 IF x_destination_type_code = 'SHOP FLOOR' THEN
499
500 if x_Prevent_Encumbrance_Flag = 'N' then
501 po_interface_errors_sv1.handle_interface_errors(
502 'PO_DOCS_OPEN_INTERFACE',
503 'FATAL',
504 null,
505 x_interface_header_id,
506 x_interface_line_id,
507 --need to create this message
508 'PO_PDOI_INV_PREV_ENCUM_FLAG',
509 'PO_DISTRIBUTIONS_INTERFACE',
510 'PREVENT_ENCUMBRANCE_FLAG' ,
511 null,null,null,null,null,null,
512 null,null,null,null,null,null,
513 x_header_processable_flag, x_interface_distribution_id);
514 end if;
515 else --other dest
516 if x_Prevent_Encumbrance_Flag = 'Y' then
517 po_interface_errors_sv1.handle_interface_errors(
518 'PO_DOCS_OPEN_INTERFACE',
519 'FATAL',
520 null,
521 x_interface_header_id,
522 x_interface_line_id,
523 --need to create this message
524 'PO_PDOI_INV_PREV_ENCUM_FLAG',
525 'PO_DISTRIBUTIONS_INTERFACE',
526 'PREVENT_ENCUMBRANCE_FLAG' ,
527 null,null,null,null,null,null,
528 null,null,null,null,null,null,
529 x_header_processable_flag, x_interface_distribution_id);
530 end if;
531 END IF;
532
533 x_progress := '180';
534
535 if x_charge_account_id is not null then
536 x_valid := validate_account(x_charge_account_id, x_gl_date, x_chart_of_accounts_id);
537 if x_valid <> 'Y' then
538 po_interface_errors_sv1.handle_interface_errors(
539 'PO_DOCS_OPEN_INTERFACE',
540 'FATAL',
541 null,
542 x_interface_header_id,
543 x_interface_line_id,
544 --need to create this message
545 'PO_PDOI_INVALID_CHG_ACCOUNT',
546 'PO_DISTRIBUTIONS_INTERFACE',
547 'CHARGE_ACCOUNT_ID' ,
548 'CHARGE_ACCOUNT',null,null,null,null,null,
549 x_CHARGE_ACCOUNT_ID,null,null,null,null,null,
550 x_header_processable_flag, x_interface_distribution_id);
551 end if;
552 end if;
553
554 x_progress := '190';
555
556 if x_budget_account_id is not null then
557 x_valid := validate_account(x_budget_account_id, x_gl_date, x_chart_of_accounts_id);
558 if x_valid <> 'Y' then
559 po_interface_errors_sv1.handle_interface_errors(
560 'PO_DOCS_OPEN_INTERFACE',
561 'FATAL',
562 null,
563 x_interface_header_id,
564 x_interface_line_id,
565 --need to create this message
566 'PO_PDOI_INVALID_BUDGET_ACCT',
567 'PO_DISTRIBUTIONS_INTERFACE',
568 'BUDGET_ACCOUNT_ID' ,
569 'BUDGET_ACCOUNT',null,null,null,null,null,
570 x_BUDGET_ACCOUNT_ID,null,null,null,null,null,
571 x_header_processable_flag, x_interface_distribution_id);
572
573 end if;
574
575 else
576
577 /* Bug 2098833 */
578 /* If budget account is null and encumbrance is on, then it is an error */
579
580 select nvl(purch_encumbrance_flag,'N')
581 into x_enc_flag
582 from financials_system_parameters ;
583
584 if (x_enc_flag = 'Y') then
585
586 po_interface_errors_sv1.handle_interface_errors(
587 'PO_DOCS_OPEN_INTERFACE',
588 'FATAL',
589 null,
590 x_interface_header_id,
591 x_interface_line_id,
592 'PO_PDOI_INVALID_BUDGET_ACCT',
593 'PO_DISTRIBUTIONS_INTERFACE',
594 'BUDGET_ACCOUNT_ID' ,
595 'BUDGET_ACCOUNT',null,null,null,null,null,
596 NULL,null,null,null,null,null,
597 x_header_processable_flag, x_interface_distribution_id);
598 end if;
599
600 end if;
601
602 x_progress := '200';
603
604 if x_variance_account_id is not null then
605 x_valid := validate_account(x_variance_account_id, x_gl_date, x_chart_of_accounts_id);
606 if x_valid <> 'Y' then
607 po_interface_errors_sv1.handle_interface_errors(
608 'PO_DOCS_OPEN_INTERFACE',
609 'FATAL',
610 null,
611 x_interface_header_id,
612 x_interface_line_id,
613 --need to create this message
614 'PO_PDOI_INVALID_VAR_ACCT',
615 'PO_DISTRIBUTIONS_INTERFACE',
616 'VARIANCE_ACCOUNT_ID' ,
617 'VARIANCE_ACCOUNT',null,null,null,null,null,
618 x_VARIANCE_ACCOUNT_ID,null,null,null,null,null,
619 x_header_processable_flag, x_interface_distribution_id);
620 end if;
621 end if;
622
623 x_progress := '210';
624
625 if x_accrual_account_id is not null then
626 x_valid := validate_account(x_accrual_account_id, x_gl_date, x_chart_of_accounts_id);
627 if x_valid <> 'Y' then
628 po_interface_errors_sv1.handle_interface_errors(
629 'PO_DOCS_OPEN_INTERFACE',
630 'FATAL',
631 null,
632 x_interface_header_id,
633 x_interface_line_id,
634 --need to create this message
635 'PO_PDOI_INVALID_ACCRUAL_ACCT',
636 'PO_DISTRIBUTIONS_INTERFACE',
637 'ACCRUAL_ACCOUNT_ID' ,
638 'ACCRUAL_ACCOUNT',null,null,null,null,null,
639 x_accrual_account_id,null,null,null,null,null,
640 x_header_processable_flag, x_interface_distribution_id);
641 end if;
642 end if;
643
644 x_progress := '220';
645
646 if (x_project_account_context = 'N' or x_project_account_context is null)
647 and (x_project_id is not null) and (x_task_id is not null)
648 and (x_expenditure_type is not null)
649 and (x_expenditure_organization_id is not null) then
650 po_interface_errors_sv1.handle_interface_errors(
651 'PO_DOCS_OPEN_INTERFACE',
652 'FATAL',
653 null,
654 x_interface_header_id,
655 x_interface_line_id,
656 --need to create this message
657 'PO_PDOI_PROJ_ACCT_CONTEXT',
658 'PO_DISTRIBUTIONS_INTERFACE',
659 'PROJECT_ACCOUNT_CONTEXT' ,
660 null,null,null,null,null,null,
661 null,null,null,null,null,null,
662 x_header_processable_flag, x_interface_distribution_id);
663 end if;
664
665 x_progress := '230';
666
667 if (x_project_account_context = 'Y') then
668
669 -- <PO_PJM_VALIDATION FPI>
670 -- Make sure that there is no message on the stack.
671 fnd_message.clear;
672
673 x_valid := validate_project_info
674 (x_destination_type_code,
675 x_project_id,
676 x_task_id,
677 x_expenditure_type,
678 x_expenditure_organization_id,
679 -- <PO_PJM_VALIDATION FPI> added 3 parameters:
680 x_ship_to_organization_id,
681 x_need_by_date,
682 x_promised_date,
683 x_expenditure_item_date,
684 p_ship_to_ou_id, --< Bug 3265539 >
685 x_deliver_to_person_id); --<Bug 3793395>
686 -- Bug 2892199 Added expenditure_item_date
687 if x_valid <> 'Y' then
688 po_interface_errors_sv1.handle_interface_errors(
689 'PO_DOCS_OPEN_INTERFACE',
690 'FATAL',
691 null,
692 x_interface_header_id,
693 x_interface_line_id,
694 --need to create this message
695 'PO_PDOI_INVALID_PROJ_INFO',
696 'PO_DISTRIBUTIONS_INTERFACE',
697 'PROJECT_ID' ,
698 /*null,*/ 'PJM_ERROR_MSG', -- <PO_PJM_VALIDATION FPI>
699 null,null,null,null,null,
700 -- Pass in the PJM error message, if one exists
701 /*null,*/ NVL(fnd_message.get,''), -- <PO_PJM_VALIDATION FPI>
702 null,null,null,null,null,
703 x_header_processable_flag, x_interface_distribution_id);
704 end if;
705 end if;
706
707 -- Bug 3379488 Start: When there is a transaction flow between POU and ROU
708 -- and exists a project information on the distribution for expense
709 -- destination, prevent creation of the PO
710
711 x_progress := '235';
712 IF (x_destination_type_code = 'EXPENSE')
713 AND (p_transaction_flow_header_id IS NOT NULL)
714 AND (x_project_id IS NOT NULL) THEN
715 PO_INTERFACE_ERRORS_SV1.handle_interface_errors(
716 x_interface_type => 'PO_DOCS_OPEN_INTERFACE',
717 x_error_type => 'FATAL',
718 x_batch_id => null,
719 x_interface_header_id => x_interface_header_id,
720 x_interface_line_id => x_interface_line_id,
721 x_error_message_name => 'PO_CROSS_OU_PA_PROJECT_CHECK',
722 x_table_name => 'PO_DISTRIBUTIONS_INTERFACE',
723 x_column_name => 'PROJECT_ID',
724 x_tokenname1 => NULL,
725 x_tokenname2 => NULL,
726 x_tokenname3 => NULL,
727 x_tokenname4 => NULL,
728 x_tokenname5 => NULL,
729 x_tokenname6 => NULL,
730 x_tokenvalue1 => NULL,
731 x_tokenvalue2 => NULL,
732 x_tokenvalue3 => NULL,
733 x_tokenvalue4 => NULL,
734 x_tokenvalue5 => NULL,
735 x_tokenvalue6 => NULL,
736 x_header_processable_flag=> x_header_processable_flag,
737 x_interface_dist_id => x_interface_distribution_id);
738 END IF;
739
740 -- Bug 3379488 End
741
742 x_progress := '240';
743
744
745 EXCEPTION
746 WHEN others THEN
747 po_message_s.sql_error('validate_po_dist', X_progress, sqlcode);
748 raise;
749
750 END validate_po_dist;
751
752 /*================================================================
753
754 FUNCTION NAME: validate_destination_type_code()
755
756 ==================================================================*/
757
758 FUNCTION validate_destination_type_code(
759 x_destination_type_code IN varchar2,
760 x_item_status in varchar2,
761 x_accrue_on_receipt_flag IN varchar2,
762 p_transaction_flow_header_id IN NUMBER --<Shared Proc FPJ>
763 ) RETURN VARCHAR2 IS
764
765 x_valid_flag VARCHAR2(2);
766 x_expense_accrual_code po_system_parameters.expense_accrual_code%TYPE;
767 x_progress VARCHAR(4) := NULL;
768
769 BEGIN
770
771 x_progress := '001';
772
773 SELECT expense_accrual_code
774 INTO x_expense_accrual_code
775 FROM po_system_parameters;
776
777 -- Business Rules
778 -- item status
779 -- 'O' = outside processing item
780 -- - destination type must be SHOP FLOOR
781 -- 'E' = item stockable in the org
782 -- - destination type cannot be SHOP FLOOR
783 -- 'D' = item defined but not stockable in org
784 -- - destination type must be EXPENSE
785 -- null = item not defined in org
786 --
787 -- accrual on receipt
788 -- 'N' - destination type must be expense
789 -- 'Y' - if expense_accrual = PERIOD END
790 -- then destination type code cannot be EXPENSE
791 --
792
793 x_progress := '002';
794
795 select distinct 'Y' valid
796 into x_valid_flag
797 from po_lookup_codes
798 where lookup_type = 'DESTINATION TYPE'
799 and ( ( nvl( x_item_status,'D') = 'D'
800 and lookup_code = 'EXPENSE')
801 or ( nvl( x_item_status,'D') = 'E'
802 and lookup_code <> 'SHOP FLOOR')
803 or ( nvl( x_item_status,'D') = 'O'
804 and lookup_code = 'SHOP FLOOR') )
805 and ( ( nvl( x_accrue_on_receipt_flag,'Y') = 'N'
806 and lookup_code = 'EXPENSE')
807 OR p_transaction_flow_header_id is NOT NULL --<Shared Proc FPJ>
808 or (nvl( x_accrue_on_receipt_flag,'Y') = 'Y'
809 and (( x_expense_accrual_code = 'PERIOD END'
810 and lookup_code <> 'EXPENSE')
811 or x_expense_accrual_code <> 'PERIOD END')))
812 and lookup_code= x_destination_type_code;
813
814 return x_valid_flag;
815
816 EXCEPTION
817 WHEN NO_DATA_FOUND then
818 x_valid_flag := 'N';
819 return x_valid_flag;
820 WHEN OTHERS THEN
821 x_valid_flag := 'N';
822 return x_valid_flag;
823 po_message_s.sql_error('validate_destination_type_code',X_progress, sqlcode);
824 RAISE;
825
826 END validate_destination_type_code;
827
828 /*================================================================
829
830 FUNCTION NAME: validate_deliver_to_person_id()
831
832 ==================================================================*/
833
834 FUNCTION validate_deliver_to_person_id(
835 x_deliver_to_person_id IN NUMBER
836 ) RETURN VARCHAR2 IS
837 x_valid_flag VARCHAR2(2);
838 x_progress VARCHAR2(4) := NULL;
839
840 BEGIN
841 x_progress := '001';
842
843 -- validation
844 -- R12 CWK: removed where clause based on inactive_date
845 -- as it would taken care in the view itself.
846 SELECT distinct 'Y'
847 INTO x_valid_flag
848 FROM hr_employees_current_v
849 WHERE employee_id = x_deliver_to_person_id;
850
851 return x_valid_flag;
852
853 EXCEPTION
854 WHEN NO_DATA_FOUND then
855 x_valid_flag := 'N';
856 return x_valid_flag;
857 WHEN OTHERS THEN
858 x_valid_flag := 'N';
859 return x_valid_flag;
860 po_message_s.sql_error('validate_deliver_to_person_id',X_progress, sqlcode);
861 RAISE;
862
863 END validate_deliver_to_person_id;
864
865 /*================================================================
866
867 FUNCTION NAME: validate_deliver_to_loc_id()
868
869 ==================================================================*/
870
871 FUNCTION validate_deliver_to_loc_id(
872 x_deliver_to_location_id IN varchar2,
873 x_ship_to_organization_id IN NUMBER
874 ) RETURN VARCHAR2 IS
875
876 x_valid_flag VARCHAR2(2);
877 x_progress VARCHAR2(4) := NULL;
878
879 BEGIN
880
881 x_progress := '001';
882 --Bug# 1942696 togeorge 08/16/2001
883 --HR removes hz_locations from hr_locations; added exception
884 Begin
885 -- validation
886 SELECT distinct 'Y'
887 INTO x_valid_flag
888 FROM HR_LOCATIONS
889 WHERE nvl(inventory_organization_id,x_ship_to_organization_id) = x_ship_to_organization_id
890 AND nvl(inactive_date, trunc(sysdate + 1)) > trunc(sysdate)
891 AND location_id = x_deliver_to_location_id;
892
893 return x_valid_flag;
894 exception
895 WHEN NO_DATA_FOUND then
896 SELECT distinct 'Y'
897 INTO x_valid_flag
898 FROM HZ_LOCATIONS
899 WHERE nvl(address_expiration_date, trunc(sysdate + 1)) > trunc(sysdate)
900 AND location_id = x_deliver_to_location_id;
901
902 return x_valid_flag;
903 end;
904 --
905 EXCEPTION
906 WHEN NO_DATA_FOUND then
907 x_valid_flag := 'N';
908 return x_valid_flag;
909 WHEN OTHERS THEN
910 x_valid_flag := 'N';
911 return x_valid_flag;
912 po_message_s.sql_error('validate_deliver_to_loc_id',X_progress, sqlcode);
913 RAISE;
914
915 END validate_deliver_to_loc_id;
916
917 /*================================================================
918
919 FUNCTION NAME: validate_dest_subinventory()
920
921 ==================================================================*/
922
923 FUNCTION validate_dest_subinventory(
924 x_destination_subinventory IN varchar2,
925 x_ship_to_organization_id IN NUMBER,
926 x_item_id IN NUMBER
927 ) RETURN VARCHAR2 IS
928
929 x_valid_flag VARCHAR2(2);
930 x_progress VARCHAR2(4) := NULL;
931
932 BEGIN
933
934 x_progress := '001';
935
936 -- validation
937 select distinct 'Y'
938 into x_valid_flag
939 from mtl_secondary_inventories msub
940 where msub.organization_id = nvl(x_ship_to_organization_id, msub.organization_id)
941 and nvl(msub.disable_date, trunc(sysdate+1)) > trunc(sysdate)
942 and (x_item_id is null
943 or
944 (x_item_id is not null
945 and exists (select null
946 from mtl_system_items msi
947 where msi.organization_id = nvl(x_ship_to_organization_id, msi.organization_id)
948 and msi.inventory_item_id = x_item_id
949 and (msi.restrict_subinventories_code = 2
950 or (msi.restrict_subinventories_code = 1
951 and exists (select null
952 from mtl_item_sub_inventories mis
953 where mis.organization_id = nvl(x_ship_to_organization_id , mis.organization_id)
954 and mis.inventory_item_id = msi.inventory_item_id
955 and mis.secondary_inventory = msub.secondary_inventory_name))))))
956 and msub.secondary_inventory_name = x_destination_subinventory;
957
958 return x_valid_flag;
959
960 EXCEPTION
961 WHEN NO_DATA_FOUND then
962 x_valid_flag := 'N';
963 return x_valid_flag;
964 WHEN OTHERS THEN
965 x_valid_flag := 'N';
966 return x_valid_flag;
967 po_message_s.sql_error('validate_dest_subinventory',X_progress, sqlcode);
968 RAISE;
969
970 END validate_dest_subinventory;
971
972 /*================================================================
973
974 FUNCTION NAME: validate_org()
975
976 ==================================================================*/
977
978 FUNCTION validate_org(x_org_id in NUMBER, x_sob_id in NUMBER)
979 RETURN VARCHAR2 IS
980
981 x_valid VARCHAR2(2);
982 x_progress VARCHAR2(4) := NULL;
983
984 BEGIN
985
986 x_progress := '001';
987
988 SELECT distinct 'Y' INTO x_valid
989 FROM org_organization_definitions ood
990 WHERE x_org_id = ood.organization_id
991 AND ood.set_of_books_id = x_sob_id;
992
993 return x_valid;
994
995 EXCEPTION
996 WHEN NO_DATA_FOUND then
997 x_valid := 'N';
998 return x_valid;
999 WHEN OTHERS THEN
1000 x_valid := 'N';
1001 return x_valid;
1002 po_message_s.sql_error('validate_org',X_progress, sqlcode);
1003 RAISE;
1004
1005 END validate_org;
1006
1007 /*================================================================
1008
1009 FUNCTION NAME: validate_wip()
1010
1011 ==================================================================*/
1012
1013 FUNCTION validate_wip(x_wip_entity_id in NUMBER, x_destination_organization_id in NUMBER, x_wip_repetitive_schedule_id in NUMBER) RETURN VARCHAR2 IS
1014
1015 x_valid VARCHAR2(2);
1016 x_valid1 VARCHAR2(2);
1017 x_valid2 VARCHAR2(2);
1018 x_progress VARCHAR2(4) := NULL;
1019
1020 BEGIN
1021
1022 x_progress := '001';
1023
1024 /* If the destination_type_code = 'SHOP FLOOR', then if */
1025 /* WIP_REPETITIVE_SCHEDULE_ID is not null then the record must be a */
1026 /* repetitive_schedule. If WIP_REPETITIVE_SCHEDULE_ID is NULL, then it */
1027 /* must be a discrete job */
1028 -- Bug 3083961. If x_wip_repetitive_schedule_id is not null check in wip_repetitive_schedules.
1029 -- else check in wip_discrete_jobs
1030
1031 if x_wip_repetitive_schedule_id is not null then
1032 begin
1033 SELECT distinct 'Y' into x_valid
1034 FROM wip_repetitive_schedules wrs
1035 WHERE wrs.organization_id=x_destination_organization_id
1036 AND wrs.wip_entity_id = x_wip_entity_id
1037 AND wrs.repetitive_schedule_id =
1038 x_wip_repetitive_schedule_id
1039 AND wrs.status_type IN (3,4,6)
1040 AND x_wip_repetitive_schedule_id is not null;
1041 exception
1042 WHEN NO_DATA_FOUND then
1043 x_valid := 'N';
1044 return x_valid;
1045 end;
1046 else
1047 begin
1048 SELECT distinct 'Y' into x_valid
1049 FROM wip_discrete_jobs wdj
1050 WHERE wdj.organization_id=x_destination_organization_id
1051 AND wdj.wip_entity_id = x_wip_entity_id
1052 AND wdj.status_type IN (3,4,6)
1053 AND x_wip_repetitive_schedule_id is NULL;
1054 exception
1055 WHEN NO_DATA_FOUND then
1056 x_valid := 'N';
1057 return x_valid;
1058 end;
1059 end if;
1060
1061 return x_valid;
1062
1063 EXCEPTION
1064 WHEN NO_DATA_FOUND then
1065 x_valid := 'N';
1066 return x_valid;
1067 WHEN OTHERS THEN
1068 x_valid := 'N';
1069 return x_valid;
1070 po_message_s.sql_error('validate_wip',X_progress, sqlcode);
1071 RAISE;
1072
1073 END validate_wip;
1074
1075 /*================================================================
1076
1077 FUNCTION NAME: validate_account()
1078
1079 ==================================================================*/
1080
1081 FUNCTION validate_account(x_account_id in NUMBER, x_gl_date in date, x_chart_of_accounts_id in NUMBER) RETURN VARCHAR2 IS
1082
1083 x_valid VARCHAR2(2);
1084 x_progress VARCHAR2(4) := NULL;
1085
1086 BEGIN
1087
1088 x_progress := '001';
1089
1090 SELECT distinct 'Y' into x_valid
1091 FROM gl_code_combinations gcc
1092 WHERE gcc.code_combination_id = x_account_id
1093 AND gcc.enabled_flag = 'Y'
1094 AND trunc(nvl(x_gl_date,SYSDATE)) BETWEEN
1095 trunc(nvl(start_date_active,
1096 nvl(x_gl_date,SYSDATE) ))
1097 AND
1098 trunc(nvl (end_date_active,
1099 nvl(x_gl_date,SYSDATE) ))
1100 AND gcc.detail_posting_allowed_flag = 'Y'
1101 AND gcc.chart_of_accounts_id=
1102 x_chart_of_accounts_id
1103 AND gcc.summary_flag = 'N';
1104
1105 return x_valid;
1106
1107 EXCEPTION
1108 WHEN NO_DATA_FOUND then
1109 x_valid := 'N';
1110 return x_valid;
1111 WHEN OTHERS THEN
1112 x_valid := 'N';
1113 return x_valid;
1114 po_message_s.sql_error('validate_account',X_progress, sqlcode);
1115 RAISE;
1116
1117 END validate_account;
1118
1119 /*================================================================
1120
1121 FUNCTION NAME: validate_project_info()
1122
1123 ==================================================================*/
1124
1125 /**
1126 * Private Function: validate_project_info
1127 * Requires: none
1128 * Modifies: concurrent program log
1129 * Effects: Calls the PJM validation API with the given project, task,
1130 * etc. Writes validation warnings to the concurrent program log.
1131 * Returns:
1132 * 'N' if validation failed. This distribution becomes invalid.
1133 * 'Y' if the validation result is success or warning. Processing should
1134 * continue on this distribution.
1135 */
1136 FUNCTION validate_project_info
1137 (
1138 x_destination_type_code IN VARCHAR2,
1139 x_project_id IN NUMBER,
1140 x_task_id IN NUMBER,
1141 x_expenditure_type IN VARCHAR2,
1142 x_expenditure_organization_id IN NUMBER ,
1143 -- <PO_PJM_VALIDATION FPI START>
1144 x_ship_to_organization_id IN NUMBER,
1145 x_need_by_date IN DATE,
1146 x_promised_date IN DATE,
1147 x_expenditure_item_date IN DATE, -- Bug 2892199
1148 -- <PO_PJM_VALIDATION FPI END>
1149 p_ship_to_ou_id IN NUMBER, --< Bug 3265539 >
1150 p_deliver_to_person_id IN NUMBER --<Bug 3793395>
1151 ) RETURN VARCHAR2 IS
1152
1153 x_valid VARCHAR2(2);
1154 x_valid1 VARCHAR2(2);
1155 x_valid2 VARCHAR2(2);
1156 x_valid3 VARCHAR2(2);
1157 x_progress VARCHAR2(4) := NULL;
1158
1159 -- <PO_PJM_VALIDATION FPI START>
1160 l_val_proj_result VARCHAR(1);
1161 l_val_proj_error_code VARCHAR2(80);
1162 -- <PO_PJM_VALIDATION FPI END>
1163
1164 --<Bug 3793395 mbhargav START>
1165 x_msg_application varchar2(30);
1166 x_msg_type varchar2(1);
1167 x_msg_token1 varchar2(30);
1168 x_msg_token2 varchar2(30);
1169 x_msg_token3 varchar2(30);
1170 x_msg_count number;
1171 x_msg_data varchar2(30);
1172 x_billable_flag varchar2(1);
1173 --<Bug 3793395 mbhargav END>
1174
1175 BEGIN
1176
1177 x_progress := '001';
1178
1179 /* Bug: 1786105 For all the following three validation select, the table/views:
1180 mtl_projects_v
1181 pa_expenditure_types
1182 per_organization_units
1183 needs to be replaced with
1184 pa_projects_expend_v
1185 pa_expenditure_types_expend_v
1186 pa_organizations_expend_v
1187 or else the projects validation would fail.
1188 */
1189 /* Bug 2892199 Added expenditure item date validation */
1190 IF x_destination_type_code = 'EXPENSE' then
1191 SELECT 'Y' into x_valid1
1192 FROM pa_projects_expend_v pap,
1193 pa_tasks_expend_v pat
1194 WHERE pap.project_id = x_project_id
1195 AND pap.project_id = pat.project_id
1196 AND pat.task_id = x_task_id
1197 AND pat.chargeable_flag = 'Y'
1198 AND x_expenditure_item_date BETWEEN
1199 nvl(pap.start_date,x_expenditure_item_date)
1200 AND nvl(pap.completion_date,x_expenditure_item_date)
1201 AND x_expenditure_item_date BETWEEN
1202 nvl(pat.start_date,x_expenditure_item_date)
1203 AND nvl(pat.completion_date,x_expenditure_item_date) ;
1204
1205 SELECT 'Y' into x_valid2
1206 FROM pa_expenditure_types_expend_v pet
1207 WHERE pet.expenditure_type = x_expenditure_type
1208 AND pet.system_linkage_function = 'VI';
1209
1210 SELECT 'Y' into x_valid3
1211 FROM pa_organizations_expend_v pou
1212 WHERE pou.organization_id=x_expenditure_organization_id;
1213 if x_valid1 = 'Y' and x_valid2 = 'Y' and x_valid3 = 'Y' then
1214
1215 --<Bug 3793395 mbhargav START>
1216 --Call the PA API to validate project related information
1217 pa_transactions_pub.validate_transaction( X_project_id => x_project_id
1218 , X_task_id => x_task_id
1219 , X_ei_date => x_expenditure_item_date
1220 , X_expenditure_type => x_expenditure_type
1221 , X_non_labor_resource => ''
1222 , X_person_id => p_deliver_to_person_id
1223 , X_quantity => ''
1224 , X_denom_currency_code => ''
1225 , X_acct_currency_code => ''
1226 , X_denom_raw_cost => ''
1227 , X_acct_raw_cost => ''
1228 , X_acct_rate_type => ''
1229 , X_acct_rate_date => ''
1230 , X_acct_exchange_rate => ''
1231 , X_transfer_ei => ''
1232 , X_incurred_by_org_id => x_expenditure_organization_id
1233 , X_nl_resource_org_id => ''
1234 , X_transaction_source => ''
1235 , X_calling_module => 'POXPOEPO'
1236 , X_vendor_id => ''
1237 , X_entered_by_user_id => ''
1238 , X_attribute_category => ''
1239 , X_attribute1 => ''
1240 , X_attribute2 => ''
1241 , X_attribute3 => ''
1242 , X_attribute4 => ''
1243 , X_attribute5 => ''
1244 , X_attribute6 => ''
1245 , X_attribute7 => ''
1246 , X_attribute8 => ''
1247 , X_attribute9 => ''
1248 , X_attribute10 => ''
1249 , X_attribute11 => ''
1250 , X_attribute12 => ''
1251 , X_attribute13 => ''
1252 , X_attribute14 => ''
1253 , X_attribute15 => ''
1254 , X_msg_application => X_msg_application
1255 , X_msg_type => X_msg_type
1256 , X_msg_token1 => X_msg_token1
1257 , X_msg_token2 => X_msg_token2
1258 , X_msg_token3 => X_msg_token3
1259 , X_msg_count => X_msg_count
1260 , X_msg_data => X_msg_data
1261 , X_billable_flag => X_billable_flag);
1262
1263 IF x_msg_type = 'E' and x_msg_data is not NULL THEN
1264 --Project related info causes error. Stop processing
1265 FND_FILE.put_line(FND_FILE.LOG, x_msg_data);
1266 x_valid := 'N';
1267 ELSIF x_msg_type = 'W' and x_msg_data is not NULL THEN
1268 /* Write the warning to the concurrent program log and then */
1269 /* set x_valid to 'Y' to allow processing to continue.*/
1270 FND_FILE.put_line(FND_FILE.LOG, x_msg_data);
1271 x_valid := 'Y';
1272 ELSE
1273 x_valid := 'Y';
1274 END IF;
1275 --<Bug 3793395 mbhargav END>
1276
1277 else
1278 x_valid := 'N';
1279 end if;
1280 else
1281 -- <PO_PJM_VALIDATION FPI START>
1282 --< Bug 3265539 Start >
1283 -- Call PO wrapper procedure to validate the PJM project
1284 PO_PROJECT_DETAILS_SV.validate_proj_references_wpr
1285 (p_inventory_org_id => x_ship_to_organization_id,
1286 p_operating_unit => p_ship_to_ou_id,
1287 p_project_id => x_project_id,
1288 p_task_id => x_task_id,
1289 p_date1 => x_need_by_date,
1290 p_date2 => x_promised_date,
1291 p_calling_function => 'PDOI',
1292 x_error_code => l_val_proj_error_code,
1293 x_return_code => l_val_proj_result);
1294
1295 IF (l_val_proj_result = PO_PROJECT_DETAILS_SV.pjm_validate_failure) THEN
1296 x_valid1 := 'N';
1297 ELSIF (l_val_proj_result = PO_PROJECT_DETAILS_SV.pjm_validate_warning) THEN
1298 /* Write the warning to the concurrent program log and then */
1299 /* set x_valid to 'Y' to allow processing to continue.*/
1300 FND_FILE.put_line(FND_FILE.LOG, FND_MESSAGE.get);
1301 x_valid1 := 'Y';
1302 ELSE /* Success */
1303 x_valid1 := 'Y';
1304 END IF;
1305 --< Bug 3265539 End >
1306 -- <PO_PJM_VALIDATION FPI END>
1307 IF x_destination_type_code = 'INVENTORY' then
1308
1309 SELECT 'Y' into x_valid2
1310 FROM sys.dual
1311 WHERE x_expenditure_type IS NULL
1312 OR EXISTS( SELECT 'Valid Expenditure Type'
1313 FROM pa_expenditure_types pet
1314 WHERE pet.expenditure_type =
1315 x_expenditure_type
1316 AND pet.system_linkage_function = 'VI'
1317 );
1318
1319 /* Bug # 1609762
1320 When the Destination Type is INVENTORY then the expenditure Org can
1321 be NULL. */
1322
1323 SELECT 'Y' into x_valid3
1324 FROM sys.dual
1325 WHERE x_expenditure_organization_id IS NULL
1326 OR EXISTS( SELECT 'Valid Expenditure Org'
1327 FROM per_organization_units pou
1328 WHERE pou.organization_id=
1329 x_expenditure_organization_id
1330 );
1331
1332 if x_valid1 = 'Y' and x_valid2 = 'Y' and x_valid3 = 'Y' then
1333 x_valid := 'Y';
1334 else
1335 x_valid := 'N';
1336 end if;
1337 end if;
1338 end if;
1339
1340 return x_valid;
1341
1342 EXCEPTION
1343 WHEN NO_DATA_FOUND then
1344 x_valid := 'N';
1345 return x_valid;
1346 WHEN OTHERS THEN
1347 x_valid := 'N';
1348 return x_valid;
1349 po_message_s.sql_error('validate_project_info',X_progress, sqlcode);
1350 RAISE;
1351
1352 end validate_project_info;
1353
1354 END PO_PDOI_DISTRIBUTIONS_SV3;