[Home] [Help]
PACKAGE BODY: APPS.PO_SHIPMENTS_SV4
Source
1 PACKAGE BODY PO_SHIPMENTS_SV4 as
2 /* $Header: POXPOS4B.pls 120.10 2007/12/04 09:36:21 bisdas ship $*/
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'PO_SHIPMENTS_SV4';
5 /*===========================================================================
6
7 PROCEDURE NAME: delete_all_shipments
8
9 ===========================================================================*/
10 PROCEDURE delete_all_shipments
11 (X_delete_id IN NUMBER,
12 X_entity_level IN VARCHAR2,
13 X_type_lookup_code IN VARCHAR2) IS
14
15 X_progress VARCHAR2(3) := '';
16 x_line_location_id NUMBER := '';
17 x_po_line_id NUMBER := '';
18 x_quantity NUMBER := '';
19 x_original_quantity NUMBER := '';
20 x_shipment_type VARCHAR2(15) :=''; --1560839
21
22 --<R12 eTax Integration Start>
23 TYPE l_shipment_type IS TABLE OF PO_LINE_LOCATIONS_ALL.SHIPMENT_TYPE%TYPE;
24 l_shipment_type_tbl l_shipment_type;
25 l_transaction_line_rec_type ZX_API_PUB.transaction_line_rec_type;
26 l_return_status VARCHAR2(1);
27 l_msg_count NUMBER;
28 l_msg_data VARCHAR2(2000);
29 l_po_header_id_tbl PO_TBL_NUMBER;
30 l_po_release_id_tbl PO_TBL_NUMBER;
31 l_line_location_id_tbl PO_TBL_NUMBER;
32 l_line_location_org_id_tbl PO_TBL_NUMBER;
33 --<R12 eTax Integration End>
34
35 CURSOR C_LINE is
36 SELECT line_location_id
37 FROM po_line_locations_all /*Bug6632095: using base table instead of view */
38 WHERE po_line_id = X_delete_id;
39
40 CURSOR C_RELEASE is
41 SELECT line_location_id,
42 po_line_id,
43 quantity
44 FROM po_line_locations_all /*Bug6632095: using base table instead of view */
45 WHERE po_release_id = X_delete_id;
46
47 CURSOR C_HEADER is
48 SELECT line_location_id
49 FROM po_line_locations_all /*Bug6632095: using base table instead of view */
50 WHERE po_header_id = X_delete_id;
51
52 BEGIN
53
54 IF (X_entity_level = 'LINE') THEN
55
56 if (X_type_lookup_code NOT IN ('RFQ', 'QUOTATION')) THEN
57
58 -- delete attachements associated with shipment.
59 OPEN C_LINE;
60
61 LOOP
62
63 FETCH C_LINE INTO x_line_location_id;
64 EXIT WHEN C_LINE%notfound;
65
66 fnd_attached_documents2_pkg.delete_attachments('PO_SHIPMENTS',
67 x_line_location_id,
68 '', '', '', '', 'Y');
69 --<HTML Agreements R12 Start>
70 --Delete the Price differentials entity type for the given Shipment
71 PO_PRICE_DIFFERENTIALS_PKG.del_level_specific_price_diff(
72 p_doc_level => PO_CORE_S.g_doc_level_SHIPMENT
73 ,p_doc_level_id => x_line_location_id);
74 --<HTML Agreements R12 End>
75
76 END LOOP;
77
78 CLOSE C_LINE;
79
80 -- remove the req lnik
81 po_req_lines_sv.remove_req_from_po(X_delete_id,'LINE');
82
83 end if; /* X_type_lookup_code not in RFQ and QUOTATION */
84
85 X_progress := '010';
86
87 -- Delete the shipments
88 BEGIN
89 DELETE FROM PO_LINE_LOCATIONS
90 WHERE po_line_id = X_delete_id
91 AND shipment_type in ('PLANNED', 'STANDARD', 'PRICE BREAK',
92 'RFQ', 'QUOTATION')
93 --<R12 eTax Integration Start>
94 RETURNING
95 shipment_type,
96 po_header_id,
97 po_release_id,
98 line_location_id,
99 org_id
100 BULK COLLECT INTO
101 l_shipment_type_tbl,
102 l_po_header_id_tbl,
103 l_po_release_id_tbl,
104 l_line_location_id_tbl,
105 l_line_location_org_id_tbl
106 ;
107 --<R12 eTax Integration End>
108
109 EXCEPTION
110 WHEN NO_DATA_FOUND then null;
111 WHEN OTHERS then raise;
112
113 END;
114
115 -- bug 424099
116 -- skip Blanket PO
117
118 if (X_type_lookup_code NOT IN ('BLANKET','RFQ', 'QUOTATION')) THEN
119
120 -- delete the distributions associated with the line.
121 po_distributions_sv.delete_distributions(X_delete_id,
122 'LINE');
123
124 end if; /* X_type_lookup_code not in RFQ and QUOTATION */
125
126 ELSIF (X_entity_level = 'HEADER') THEN
127
128 if (X_type_lookup_code NOT IN ('RFQ', 'QUOTATION')) THEN
129
130 -- Delete the attachments associated with the shipments.
131 OPEN C_HEADER;
132
133 LOOP
134
135 FETCH C_HEADER INTO x_line_location_id;
136 EXIT WHEN C_HEADER%notfound;
137
138 fnd_attached_documents2_pkg.delete_attachments('PO_SHIPMENTS',
139 x_line_location_id,
140 '', '', '', '', 'Y');
141 --<HTML Agreements R12 Start>
142 --Delete the Price differentials entity type for the given Shipment
143 PO_PRICE_DIFFERENTIALS_PKG.del_level_specific_price_diff(
144 p_doc_level => PO_CORE_S.g_doc_level_SHIPMENT
145 ,p_doc_level_id => x_line_location_id);
146 --<HTML Agreements R12 End>
147 END LOOP;
148
149 CLOSE C_HEADER;
150
151 -- Remove the req link
152 po_req_lines_sv.remove_req_from_po(X_delete_id,'PURCHASE ORDER');
153
154 X_progress := '020';
155
156 end if; /* X_type_lookup_code not in RFQ and QUOTATION */
157
158 -- Delete the shipments.
159 BEGIN
160 DELETE FROM PO_LINE_LOCATIONS_ALL /*Bug6632095: using base table instead of view */
161 WHERE po_header_id = X_delete_id
162 AND shipment_type in ('PLANNED', 'STANDARD', 'PRICE BREAK',
163 'RFQ', 'QUOTATION')
164 --<R12 eTax Integration Start>
165 RETURNING
166 shipment_type,
167 po_header_id,
168 po_release_id,
169 line_location_id,
170 org_id
171 BULK COLLECT INTO
172 l_shipment_type_tbl,
173 l_po_header_id_tbl,
174 l_po_release_id_tbl,
175 l_line_location_id_tbl,
176 l_line_location_org_id_tbl
177 ;
178 --<R12 eTax Integration End>
179
180 EXCEPTION
181 WHEN NO_DATA_FOUND then null;
182 WHEN OTHERS then raise;
183 END;
184
185 -- bug 424099
186 -- Skip Blanket PO
187
188 if (X_type_lookup_code NOT IN ('BLANKET', 'RFQ', 'QUOTATION')) THEN
189
190 -- delete the distributions associated with the header
191 po_distributions_sv.delete_distributions(X_delete_id,
192 'HEADER');
193
194 end if; /* X_type_lookup_code not in RFQ and QUOTATION */
195
196 ELSIF (X_entity_level = 'RELEASE') THEN
197
198 -- Delete all the attachements associated with the shipments.
199 -- Update the quantity on the blanket line.
200 OPEN C_RELEASE;
201
202 LOOP
203
204 FETCH C_RELEASE INTO x_line_location_id,
205 x_po_line_id,
206 x_original_quantity;
207 EXIT WHEN C_RELEASE%notfound;
208
209 fnd_attached_documents2_pkg.delete_attachments('PO_SHIPMENTS',
210 x_line_location_id,
211 '', '', '', '', 'Y');
212
213 /* Bug 1560839 - Released quantity should be updated only when
214 the shipment_type is BLANKET */
215
216 SELECT shipment_type
217 INTO x_shipment_type
218 FROM po_line_locations
219 WHERE line_location_id = x_line_location_id;
220
221 IF (X_shipment_type = 'BLANKET' ) then
222
223 po_lines_sv.update_released_quantity('DELETE',
224 'BLANKET',
225 x_po_line_id,
226 x_original_quantity,
227 x_quantity);
228 END IF;
229
230 END LOOP;
231
232 CLOSE C_RELEASE;
233
234 -- Remove the req link
235 po_req_lines_sv.remove_req_from_po(X_delete_id,'RELEASE');
236
237 /*Bug no 776261
238 When a release is deleted, then the shipments,distributions should also
239 be deleted.
240 The deletion of distributions is based on the line_location_id
241 and prior to the fix we were deleting shipment first and then trying to
242 delete the distributions based on the line_location_id which did
243 not delete any records and thereby we ended up having orphan
244 distribution records.
245 Moved the po_distributions_sv_delete_distributions before deletion
246 of shipment lines
247 */
248
249 -- delete the distributions associated with the release
250 po_distributions_sv.delete_distributions(X_delete_id,
251 'RELEASE');
252
253 X_progress := '030';
254
255 -- Delete the shipments.
256 BEGIN
257 DELETE FROM PO_LINE_LOCATIONS
258 WHERE po_release_id = X_delete_id
259 AND shipment_type in ('SCHEDULED', 'BLANKET')
260 --<R12 eTax Integration Start>
261 RETURNING
262 shipment_type,
263 po_header_id,
264 po_release_id,
265 line_location_id,
266 org_id
267 BULK COLLECT INTO
268 l_shipment_type_tbl,
269 l_po_header_id_tbl,
270 l_po_release_id_tbl,
271 l_line_location_id_tbl,
272 l_line_location_org_id_tbl
273 ;
274 --<R12 eTax Integration End>
275
276
277 EXCEPTION
278 WHEN NO_DATA_FOUND then null;
279 WHEN OTHERS then raise;
280 END;
281
282
283 END IF;
284
285 --<eTax Integration R12 Start>
286 FOR i in 1..l_shipment_type_tbl.COUNT
287 LOOP
288 IF l_shipment_type_tbl(i) IN ('STANDARD','PLANNED','BLANKET','SCHEDULED')
289 THEN
290 l_transaction_line_rec_type.internal_organization_id := l_line_location_org_id_tbl(i);
291 l_transaction_line_rec_type.application_id := FND_GLOBAL.resp_appl_id;
292 l_transaction_line_rec_type.entity_code := PO_CONSTANTS_SV.PO_ENTITY_CODE ;
293 l_transaction_line_rec_type.event_class_code := PO_CONSTANTS_SV.PO_EVENT_CLASS_CODE;
294 l_transaction_line_rec_type.event_type_code := PO_CONSTANTS_SV.PO_ADJUSTED;
295 if l_po_release_id_tbl(i) is not null then
296 l_transaction_line_rec_type.trx_id := l_po_release_id_tbl(i);
297 else
298 l_transaction_line_rec_type.trx_id := l_po_header_id_tbl(i);
299 end if;
300 l_transaction_line_rec_type.trx_level_type :='SHIPMENT';
301 l_transaction_line_rec_type.trx_line_id := l_line_location_id_tbl(i);
302
303 ZX_API_PUB.del_tax_line_and_distributions(
304 p_api_version => 1.0,
305 p_init_msg_list => FND_API.G_TRUE,
306 p_commit => FND_API.G_FALSE,
307 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
308 x_return_status => l_return_status,
309 x_msg_count => l_msg_count,
310 x_msg_data => l_msg_data,
311 p_transaction_line_rec => l_transaction_line_rec_type
312 );
313
314 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
315 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
316 END IF;
317
318 END IF;
319 END LOOP;
320 --<eTax Integration R12 End>
321
322
323
324 EXCEPTION
325 WHEN NO_DATA_FOUND THEN
326 null;
327 WHEN OTHERS THEN
328 --dbms_output.put_line('In UPDATE exception');
329 po_message_s.sql_error('update_shipment_price', X_progress, sqlcode);
330 raise;
331 END delete_all_shipments;
332
333 /*===========================================================================
334
335 PROCEDURE NAME: delete_shipment
336
337 ===========================================================================*/
338 PROCEDURE delete_shipment
339 (X_line_location_id IN NUMBER,
340 X_row_id IN VARCHAR2,
341 X_doc_header_id IN NUMBER,
342 X_shipment_type IN VARCHAR2 ) IS
343
344 X_progress VARCHAR2(3) := '';
345
346 BEGIN
347
348 X_progress := '010';
349
350
351 /*
352 ** Call the cover routine to delete children if the
353 ** shipment type is NOT 'PRICE BREAK'.
354 */
355 IF (X_shipment_type IN ('PRICE BREAK', 'RFQ', 'QUOTATION')) then
356 null;
357 -- Have implemented it like this as this may be used by
358 -- RFQs and Quotes.. I am not sure. Can modify this if stmt.
359 -- appropriately later.
360 ELSE
361 po_shipments_sv4.delete_children(X_line_location_id, X_doc_header_id,
362 X_shipment_type);
363 END IF;
364 x_progress := '020';
365
366 --<HTML Agreements R12 Start>
367 --Delete the Price differentials entity type for the given Line
368 PO_PRICE_DIFFERENTIALS_PKG.del_level_specific_price_diff(
369 p_doc_level => PO_CORE_S.g_doc_level_SHIPMENT
370 ,p_doc_level_id => x_line_location_id);
371 --<HTML Agreements R12 End>
372
373 --dbms_output.put_line('after call to delete children');
374
375 /*
376 ** Call the Shipments table handler delete row
377 */
378 po_line_locations_pkg_s2.delete_row(X_row_id);
379 --dbms_output.put_line('after call to delete row');
380
381 EXCEPTION
382 WHEN OTHERS THEN
383 --dbms_output.put_line('In exception');
384 po_message_s.sql_error('delete_shipment', X_progress, sqlcode);
385 raise;
386 END delete_shipment;
387
388 /*===========================================================================
389
390 PROCEDURE NAME: delete_children
391
392 ===========================================================================*/
393 PROCEDURE delete_children
394 (X_line_location_id IN NUMBER,
395 X_doc_header_id IN NUMBER,
396 X_shipment_type IN VARCHAR2) IS
397
398 X_progress VARCHAR2(3) := '';
399 x_po_line_id NUMBER := '';
400 x_original_quantity NUMBER := '';
401 x_quantity NUMBER := '';
402
403
404 BEGIN
405
406 X_progress := '010';
407
408 --dbms_output.put_line('In call to delete children');
409
410 -- delete the distributions associated with the shipment
411 po_distributions_sv.delete_distributions(X_line_location_id,
412 'SHIPMENT');
413
414 -- Remove the req link
415 po_req_lines_sv.remove_req_from_po(X_line_location_id,'SHIPMENT');
416
417 -- Update the quantity on the blanket line
418 IF (X_shipment_type = 'BLANKET' ) then
419
420 SELECT quantity,
421 po_line_id
422 INTO x_original_quantity,
423 x_po_line_id
424 FROM po_line_locations
425 WHERE line_location_id = X_line_location_id;
426
427 po_lines_sv.update_released_quantity('DELETE',
428 'BLANKET',
429 x_po_line_id,
430 x_original_quantity,
431 x_quantity);
432
433 END IF;
434
435
436 -- Delete attachements.
437 fnd_attached_documents2_pkg.delete_attachments('PO_SHIPMENTS',
438 X_line_location_id,
439 '', '', '', '', 'Y');
440
441 EXCEPTION
442 WHEN OTHERS THEN
443 --dbms_output.put_line('In exception');
444 po_message_s.sql_error('delete_children', X_progress, sqlcode);
445 raise;
446 END delete_children;
447
448 /*===========================================================================
449
450 PROCEDURE NAME: update_shipment
451
452 ===========================================================================*/
453 PROCEDURE update_shipment
454 (X_Rowid VARCHAR2,
455 X_Line_Location_Id NUMBER,
456 X_Last_Update_Date DATE,
457 X_Last_Updated_By NUMBER,
458 X_Po_Header_Id NUMBER,
459 X_Po_Line_Id NUMBER,
460 X_Last_Update_Login NUMBER,
461 X_Quantity NUMBER,
462 X_Quantity_Received NUMBER,
463 X_Quantity_Accepted NUMBER,
464 X_Quantity_Rejected NUMBER,
465 X_Quantity_Billed NUMBER,
466 X_Quantity_Cancelled NUMBER,
467 X_Unit_Meas_Lookup_Code VARCHAR2,
468 X_Po_Release_Id NUMBER,
469 X_Ship_To_Location_Id NUMBER,
470 X_Ship_Via_Lookup_Code VARCHAR2,
471 X_Need_By_Date DATE,
472 X_Promised_Date DATE,
473 X_Last_Accept_Date DATE,
474 X_Price_Override NUMBER,
475 X_Encumbered_Flag VARCHAR2,
476 X_Encumbered_Date DATE,
477 X_Fob_Lookup_Code VARCHAR2,
478 X_Freight_Terms_Lookup_Code VARCHAR2,
479 X_Taxable_Flag VARCHAR2,
480 X_Tax_Code_Id NUMBER,
481 X_Tax_User_Override_Flag VARCHAR2,
482 X_Calculate_Tax_Flag VARCHAR2,
483 X_From_Header_Id NUMBER,
484 X_From_Line_Id NUMBER,
485 X_From_Line_Location_Id NUMBER,
486 X_Start_Date DATE,
487 X_End_Date DATE,
488 X_Lead_Time NUMBER,
489 X_Lead_Time_Unit VARCHAR2,
490 X_Price_Discount NUMBER,
491 X_Terms_Id NUMBER,
492 X_Approved_Flag IN OUT NOCOPY VARCHAR2,
493 X_Approved_Date DATE,
494 X_Closed_Flag VARCHAR2,
495 X_Cancel_Flag VARCHAR2,
496 X_Cancelled_By NUMBER,
497 X_Cancel_Date DATE,
498 X_Cancel_Reason VARCHAR2,
499 X_Firm_Status_Lookup_Code VARCHAR2,
500 X_Attribute_Category VARCHAR2,
501 X_Attribute1 VARCHAR2,
502 X_Attribute2 VARCHAR2,
503 X_Attribute3 VARCHAR2,
504 X_Attribute4 VARCHAR2,
505 X_Attribute5 VARCHAR2,
506 X_Attribute6 VARCHAR2,
507 X_Attribute7 VARCHAR2,
508 X_Attribute8 VARCHAR2,
509 X_Attribute9 VARCHAR2,
510 X_Attribute10 VARCHAR2,
511 X_Attribute11 VARCHAR2,
512 X_Attribute12 VARCHAR2,
513 X_Attribute13 VARCHAR2,
514 X_Attribute14 VARCHAR2,
515 X_Attribute15 VARCHAR2,
516 X_Inspection_Required_Flag VARCHAR2,
517 X_Receipt_Required_Flag VARCHAR2,
518 X_Qty_Rcv_Tolerance NUMBER,
519 X_Qty_Rcv_Exception_Code VARCHAR2,
520 X_Enforce_Ship_To_Location VARCHAR2,
521 X_Allow_Substitute_Receipts VARCHAR2,
522 X_Days_Early_Receipt_Allowed NUMBER,
523 X_Days_Late_Receipt_Allowed NUMBER,
524 X_Receipt_Days_Exception_Code VARCHAR2,
525 X_Invoice_Close_Tolerance NUMBER,
526 X_Receive_Close_Tolerance NUMBER,
527 X_Ship_To_Organization_Id NUMBER,
528 X_Shipment_Num NUMBER,
529 X_Source_Shipment_Id NUMBER,
530 X_Shipment_Type VARCHAR2,
531 X_Closed_Code VARCHAR2,
532 X_Ussgl_Transaction_Code VARCHAR2,
533 X_Government_Context VARCHAR2,
534 X_Receiving_Routing_Id NUMBER,
535 X_Accrue_On_Receipt_Flag VARCHAR2,
536 X_Closed_Reason VARCHAR2,
537 X_Closed_Date DATE,
538 X_Closed_By NUMBER,
539 X_need_to_approve IN OUT NOCOPY NUMBER,
540 X_increment_revision BOOLEAN,
541 X_new_rev_num NUMBER,
542 X_po_rel_Rowid VARCHAR2,
543 X_dist_window_open VARCHAR2,
544 X_Global_Attribute_Category VARCHAR2,
545 X_Global_Attribute1 VARCHAR2,
546 X_Global_Attribute2 VARCHAR2,
547 X_Global_Attribute3 VARCHAR2,
548 X_Global_Attribute4 VARCHAR2,
549 X_Global_Attribute5 VARCHAR2,
550 X_Global_Attribute6 VARCHAR2,
551 X_Global_Attribute7 VARCHAR2,
552 X_Global_Attribute8 VARCHAR2,
553 X_Global_Attribute9 VARCHAR2,
554 X_Global_Attribute10 VARCHAR2,
555 X_Global_Attribute11 VARCHAR2,
556 X_Global_Attribute12 VARCHAR2,
557 X_Global_Attribute13 VARCHAR2,
558 X_Global_Attribute14 VARCHAR2,
559 X_Global_Attribute15 VARCHAR2,
560 X_Global_Attribute16 VARCHAR2,
561 X_Global_Attribute17 VARCHAR2,
562 X_Global_Attribute18 VARCHAR2,
563 X_Global_Attribute19 VARCHAR2,
564 X_Global_Attribute20 VARCHAR2,
565 X_Country_of_Origin_Code VARCHAR2,
566 X_Invoice_Match_Option VARCHAR2, --bgu, Dec. 7, 98
567 --togeorge 10/03/2000
568 --added note to receiver
569 X_note_to_receiver VARCHAR2,
570 -- Mahesh Chandak(GML) Add 7 process related fields.
571 -- start of Bug# 1548597
572 X_Secondary_Unit_Of_Measure VARCHAR2,
573 X_Secondary_Quantity NUMBER,
574 X_Preferred_Grade VARCHAR2,
575 X_Secondary_Quantity_Received NUMBER,
576 X_Secondary_Quantity_Accepted NUMBER,
577 X_Secondary_Quantity_Rejected NUMBER,
578 X_Secondary_Quantity_Cancelled NUMBER,
579 -- end of Bug# 1548597
580 X_Consigned_Flag VARCHAR2, /* CONSIGNED FPI */
581 X_amount NUMBER, -- <SERVICES FPJ>
582 p_transaction_flow_header_id NUMBER, --< Shared Proc FPJ >
583 p_manual_price_change_flag VARCHAR2 default null --< Manual Price Override FPJ >
584 ) IS
585
586 X_progress VARCHAR2(3) := '';
587 X_num_of_distributions number := 0;
588 X_revised_date varchar2(20);
589
590 X_orig_quantity number :=0;
591
592 BEGIN
593
594 X_progress := '010';
595
596 -- Check if Shipment should be unapproved.
597 IF X_approved_flag = 'Y' THEN
598
599 -- Check if shipment needs to be unapproved.
600 /* <TIMEPHASED FPI> */
601 /*
602 Added parameters X_start_date and X_end_date in the call
603 to val_approval_status()
604 */
605 X_need_to_approve :=
606 po_shipments_sv10.val_approval_status(
607 X_Line_location_Id,
608 X_Shipment_Type,
609 X_Quantity,
610 X_amount, -- Bug 5409088
611 X_Ship_To_Location_Id,
612 X_Promised_Date,
613 X_Need_By_Date,
614 X_Shipment_Num,
615 X_Last_Accept_Date,
616 X_Taxable_Flag,
617 X_Ship_To_Organization_Id,
618 X_Price_Discount,
619 X_Price_Override,
620 X_Tax_Code_Id,
621 X_start_date, /* <TIMEPHASED FPI> */
622 X_end_date, /* <TIMEPHASED FPI> */
623 X_Days_Early_Receipt_Allowed); -- <INBOUND LOGISTICS FPJ>
624
625 IF (X_need_to_approve = 2) THEN
626
627 -- unapprove the shipment.
628 X_approved_flag := 'R';
629
630 END IF;
631
632 END IF;
633
634 /* Bug 482679 ecso 4/28/97
635 * Maintain the property that po_lines.quantity = quantity_released
636 * even we are not displaying it.
637 */
638 IF (X_shipment_type = 'BLANKET' ) THEN
639
640 SELECT quantity
641 INTO x_orig_quantity
642 FROM po_line_locations
643 WHERE line_location_id = X_line_location_id;
644
645 po_lines_sv.update_released_quantity('UPDATE',
646 'BLANKET',
647 x_po_line_id,
648 x_orig_quantity,
649 x_quantity);
650 END IF;
651
652 /*
653 ** Call the update row routine with all parameters.
654 */
655 po_line_locations_pkg_s2.update_row(
656 X_Rowid,
657 X_Line_Location_Id,
658 X_Last_Update_Date,
659 X_Last_Updated_By,
660 X_Po_Header_Id,
661 X_Po_Line_Id,
662 X_Last_Update_Login,
663 X_Quantity,
664 X_Quantity_Received,
665 X_Quantity_Accepted,
666 X_Quantity_Rejected,
667 X_Quantity_Billed,
668 X_Quantity_Cancelled,
669 X_Unit_Meas_Lookup_Code,
670 X_Po_Release_Id,
671 X_Ship_To_Location_Id,
672 X_Ship_Via_Lookup_Code,
673 X_Need_By_Date,
674 X_Promised_Date,
675 X_Last_Accept_Date,
676 X_Price_Override,
677 X_Encumbered_Flag,
678 X_Encumbered_Date,
679 X_Fob_Lookup_Code,
680 X_Freight_Terms_Lookup_Code,
681 X_Taxable_Flag,
682 X_Tax_Code_Id,
683 X_Tax_User_Override_Flag,
684 X_Calculate_Tax_Flag,
685 X_From_Header_Id,
686 X_From_Line_Id,
687 X_From_Line_Location_Id,
688 X_Start_Date,
689 X_End_Date,
690 X_Lead_Time,
691 X_Lead_Time_Unit,
692 X_Price_Discount,
693 X_Terms_Id,
694 X_Approved_Flag,
695 X_Approved_Date,
696 X_Closed_Flag,
697 X_Cancel_Flag,
698 X_Cancelled_By,
699 X_Cancel_Date,
700 X_Cancel_Reason,
701 X_Firm_Status_Lookup_Code,
702 X_Attribute_Category,
703 X_Attribute1,
704 X_Attribute2,
705 X_Attribute3,
706 X_Attribute4,
707 X_Attribute5,
708 X_Attribute6,
709 X_Attribute7,
710 X_Attribute8,
711 X_Attribute9,
712 X_Attribute10,
713 X_Attribute11,
714 X_Attribute12,
715 X_Attribute13,
716 X_Attribute14,
717 X_Attribute15,
718 X_Inspection_Required_Flag,
719 X_Receipt_Required_Flag,
720 X_Qty_Rcv_Tolerance,
721 X_Qty_Rcv_Exception_Code,
722 X_Enforce_Ship_To_Location,
723 X_Allow_Substitute_Receipts,
724 X_Days_Early_Receipt_Allowed,
725 X_Days_Late_Receipt_Allowed,
726 X_Receipt_Days_Exception_Code,
727 X_Invoice_Close_Tolerance,
728 X_Receive_Close_Tolerance,
729 X_Ship_To_Organization_Id,
730 X_Shipment_Num,
731 X_Source_Shipment_Id,
732 X_Shipment_Type,
733 X_Closed_Code,
734 NULL, --<R12 SLA>
735 X_Government_Context,
736 X_Receiving_Routing_Id,
737 X_Accrue_On_Receipt_Flag,
738 X_Closed_Reason,
739 X_Closed_Date,
740 X_Closed_By,
741 X_Global_Attribute_Category,
742 X_Global_Attribute1,
743 X_Global_Attribute2,
744 X_Global_Attribute3,
745 X_Global_Attribute4,
746 X_Global_Attribute5,
747 X_Global_Attribute6,
748 X_Global_Attribute7,
749 X_Global_Attribute8,
750 X_Global_Attribute9,
751 X_Global_Attribute10,
752 X_Global_Attribute11,
753 X_Global_Attribute12,
754 X_Global_Attribute13,
755 X_Global_Attribute14,
756 X_Global_Attribute15,
757 X_Global_Attribute16,
758 X_Global_Attribute17,
759 X_Global_Attribute18,
760 X_Global_Attribute19,
761 X_Global_Attribute20,
762 X_Country_of_Origin_Code,
763 X_Invoice_Match_Option, --bgu, Dec. 7, 98
764 --togeorge 10/03/2000
765 --added note to receiver
766 X_note_to_receiver,
767 --Start of Bug# 1548597.
768 X_Secondary_Unit_Of_Measure,
769 X_Secondary_Quantity,
770 X_Preferred_Grade,
771 X_Secondary_Quantity_Received,
772 X_Secondary_Quantity_Accepted,
773 X_Secondary_Quantity_Rejected,
774 X_Secondary_Quantity_Cancelled,
775 -- end of Bug# 1548597
776 X_Consigned_Flag, /* CONSIGNED FPI */
777 X_amount, -- <SERVICES FPJ>
778 p_transaction_flow_header_id, --< Shared Proc FPJ >
779 p_manual_price_change_flag --< Manual Price Override FPJ >
780 );
781
782 -- Value of 1, means header should be unapproved.
783 -- Value of 2, means header and shipment should be unapproved.
784 -- Value of 0, means nothing should be unapproved.
785 IF (X_need_to_approve > 0 ) THEN
786
787 -- Unapprove the PO or Release Header
788 IF X_shipment_type in ('BLANKET', 'SCHEDULED') then
789
790 X_progress := '030';
791
792 -- UPDATE po_releases
793 -- SET approved_flag = 'R',
794 -- authorization_status = 'REQUIRES REAPPROVAL'
795 -- WHERE rowid = X_po_rel_rowid;
796
797 ELSIF X_shipment_type in ('STANDARD', 'PLANNED', 'PRICE BREAK')
798 THEN
799
800 X_progress := '050';
801
802 -- UPDATE po_headers
803 -- SET approved_flag = 'R',
804 -- authorization_status = 'REQUIRES REAPPROVAL'
805 -- WHERE rowid = X_po_rel_rowid;
806
807
808 END IF; /* End of shipment_type */
809 END IF; /* End of approve > 0 */
810
811 /*
812 ** This distribution processing is not necessary for RFQs
813 ** and Quotations or Price Breaks
814 ** If the distributions window is open, we will not automatically
815 ** update the distributions quantity. The user must
816 ** manually update the quantity. There are to many issues
817 ** with this depending on window coordination.
818 ** Only update the distributions quantity if there is one
819 ** distriubtion and the distribution is not encumbered.
820 */
821 IF (X_Shipment_Type not in ('RFQ', 'QUOTATION', 'PRICE BREAK') AND
822 X_dist_window_open = 'FALSE') THEN
823
824 BEGIN
825
826 X_Progress := '080';
827
828 SELECT COUNT(po_distribution_id)
829 INTO X_num_of_distributions
830 FROM po_distributions pd
831 WHERE pd.line_location_id = X_line_location_id
832 AND NOT EXISTS (SELECT 'there are encumbered distributions'
833 FROM po_distributions pd2
834 WHERE pd2.line_location_id =
835 X_line_location_id
836 AND NVL(pd2.encumbered_flag, 'N') <> 'N') ;
837
838 EXCEPTION
839 when no_data_found then
840 X_num_of_distributions := 0;
841 when others then
842 po_message_s.sql_error('update_shipment', X_progress, sqlcode);
843 raise;
844 END;
845
846 IF X_num_of_distributions = 1 THEN
847
848 X_Progress := '090';
849
850 UPDATE po_distributions
851 SET quantity_ordered = X_quantity,
852 last_update_date = X_last_update_date,
853 last_updated_by = X_last_updated_by
854 WHERE line_location_id = X_line_location_id;
855
856 END IF;
857 END IF; /* X_Shipment_type is not in RFQ or QUOTATION */
858
859 /*Bug 782650
860 The following update is done for standard po and releases.
861 to have the accrue on receipt flag in distributions in sync. with
862 shipments accrue on receipt.
863 */
864
865 /* Bug: 2194604 Added the SCHEDULED also to make aor in sync with dist for release of
866 planned po
867 */
868
869 IF (X_Shipment_Type in ('STANDARD','BLANKET','SCHEDULED')) then
870 X_Progress := '091';
871 update po_distributions
872 set accrue_on_receipt_flag = X_accrue_on_receipt_flag
873 where line_location_id = X_line_location_id;
874 END IF;
875
876 EXCEPTION
877 WHEN OTHERS THEN
878 --dbms_output.put_line('In exception');
879 po_message_s.sql_error('update_shipment', X_progress, sqlcode);
880 raise;
881 END update_shipment;
882
883 -----------------------------------------------------------------------------
884 --Start of Comments
885 --Name: validate_delete_line_loc
886 --Pre-reqs:
887 -- None
888 --Modifies:
889 -- None
890 --Locks:
891 -- None
892 --Function:
893 -- Validates whether the Shipment whose ID has been passed can be deleted
894 -- or not
895 --Parameters:
896 --IN:
897 --p_line_loc_id
898 -- Line Location ID for the Po Shipment to be deleted
899 --p_po_line_id
900 -- Line ID for the Po line to which the entity being deleted belongs
901 --p_doc_type
902 -- Document type of the PO [PO/PA]
903 --p_style_disp_name
904 -- Display Name of the document style
905 --OUT:
906 --x_message_text
907 -- Will hold the error message in case the header cannot be deleted
908 --Notes:
909 -- Rules for checking whether deletion of shipment is valid or not
910 -- > Do not allow delete if shipment is approved or already approved once
911 -- > Do not allow delete if any distributions are reserved.
912 -- > Do not allow delete if only shipment
913 --End of Comments
914 -----------------------------------------------------------------------------
915 PROCEDURE validate_delete_line_loc(p_line_loc_id IN NUMBER
916 ,p_po_line_id IN NUMBER
917 ,p_doc_type IN VARCHAR2
918 ,p_style_disp_name IN VARCHAR2
919 ,x_message_text OUT NOCOPY VARCHAR2) IS
920 l_some_dists_reserved_flag VARCHAR2(1) := 'N';
921 l_approved_flag PO_LINE_LOCATIONS_ALL.approved_flag%TYPE := NULL;
922 l_shipment_type PO_LINE_LOCATIONS_ALL.shipment_type%TYPE := NULL;
923 l_dummy NUMBER := 0;
924 d_pos NUMBER := 0;
925 l_api_name CONSTANT VARCHAR2(30) := 'validate_delete_line_loc';
926 d_module CONSTANT VARCHAR2(70) := 'po.plsql.PO_SHIPMENTS_SV4.validate_delete_line_loc';
927 BEGIN
928 IF (PO_LOG.d_proc) THEN
929 PO_LOG.proc_begin(d_module); PO_LOG.proc_begin(d_module,'p_line_loc_id', p_line_loc_id); PO_LOG.proc_begin(d_module,'p_po_line_id', p_po_line_id); PO_LOG.proc_begin(d_module,'p_doc_type', p_doc_type);
930 PO_LOG.proc_begin(d_module,'p_style_disp_name', p_style_disp_name);
931 END IF;
932
933 SELECT shipment_type,
934 approved_flag
935 INTO l_shipment_type,
936 l_approved_flag
937 FROM po_line_locations_all
938 WHERE line_location_id = p_line_loc_id;
939
940 d_pos := 10;
941 IF (PO_LOG.d_stmt) THEN
942 PO_LOG.stmt(d_module,d_pos,'l_shipment_type',l_shipment_type); PO_LOG.stmt(d_module,d_pos,'l_approved_flag', l_approved_flag);
943 END IF;
944
945 -- Do not allow deletion for Approved PO/PA
946 IF (l_approved_flag IN ('Y', 'R'))
947 THEN
948 IF (l_shipment_type = 'PRICE BREAK')
949 THEN
950 x_message_text := PO_CORE_S.get_translated_text('PO_CANT_DELETE_PB_ON_APRVD_PO');
951 RAISE PO_CORE_S.G_EARLY_RETURN_EXC;
952 ELSE
953 x_message_text := PO_CORE_S.get_translated_text('PO_PO_USE_CANCEL_ON_APRVD_PO3'
954 ,'DOCUMENT_TYPE'
955 , p_style_disp_name);
956 RAISE PO_CORE_S.G_EARLY_RETURN_EXC;
957 END IF;
958 END IF;
959
960 d_pos := 20;
961 -- Disallow a delete if any distributions are reserved.
962 PO_CORE_S.are_any_dists_reserved(
963 p_doc_type => p_doc_type,
964 p_doc_level => PO_CORE_S.g_doc_level_SHIPMENT,
965 p_doc_level_id => p_line_loc_id,
966 x_some_dists_reserved_flag => l_some_dists_reserved_flag);
967
968 IF l_some_dists_reserved_flag = 'Y'
969 THEN
970 x_message_text := PO_CORE_S.get_translated_text('PO_PO_USE_CANCEL_ON_ENCUMB_PO');
971 RAISE PO_CORE_S.G_EARLY_RETURN_EXC;
972 END IF;
973 d_pos := 30;
974
975 --<Bug#4515762 Start>
976 -- If there is only one single viable shipment then we should not allow to
977 -- to delete the shipment
978 BEGIN
979 SELECT line_location_id
980 INTO l_dummy
981 FROM po_line_locations_all
982 WHERE po_line_id = p_po_line_id
983 AND nvl(closed_code, PO_DOCUMENT_ACTION_PVT.g_doc_action_OPEN) <> PO_DOCUMENT_ACTION_PVT.g_doc_closed_sts_FIN_CLOSED
984 AND nvl(cancel_flag, 'N') <> 'Y';
985
986 --If we reach here then we have only one valid shipment and shopuld not allow its deletion
987 x_message_text := PO_CORE_S.get_translated_text('PO_CANT_DELETE_ONLY_SCHEDULE');
988 RAISE PO_CORE_S.G_EARLY_RETURN_EXC;
989 --<Bug#4515762 End>
990 EXCEPTION
991 WHEN TOO_MANY_ROWS THEN
992 --If there are multiple viable shipments then we can allow the deletion of this shipment
993 NULL;
994 END ;
995
996 IF (PO_LOG.d_proc) THEN
997 PO_LOG.proc_end(d_module);
998 END IF;
999
1000 EXCEPTION
1001 WHEN PO_CORE_S.G_EARLY_RETURN_EXC THEN
1002 IF (PO_LOG.d_stmt) THEN
1003 PO_LOG.stmt(d_module,d_pos,'x_message_text',x_message_text);
1004 END IF;
1005 WHEN OTHERS THEN
1006 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name||':'||d_pos);
1007 IF PO_LOG.d_exc THEN
1008 PO_LOG.exc(d_module,d_pos,'Unhandled Exception in' || d_module);
1009 END IF;
1010 RAISE;
1011 END validate_delete_line_loc;
1012
1013 -----------------------------------------------------------------------------
1014 --Start of Comments
1015 --Name: process_delete_line_loc
1016 --Pre-reqs:
1017 -- Before calling this procedure one must call validate_delete_line_loc
1018 -- to ensure that deletion of the line location is a valid action
1019 --Modifies:
1020 -- PO_LINES_ALL
1021 -- PO_LINE_LOCATIONS_ALL
1022 --Locks:
1023 -- None
1024 --Function:
1025 -- Deletes the selected Line Location from the Database and
1026 -- calls the pricing APIs to calculate the new price if a Standard PO
1027 -- shipment with a source reference is deleted
1028 --Parameters:
1029 --IN:
1030 --p_line_loc_id
1031 -- Line Location ID for the Po Shipment to be deleted
1032 --p_line_loc_row_id
1033 -- Row ID for the Po Shipment record to be deleted
1034 --p_po_line_id
1035 -- Line ID for the Po line to be deleted
1036 --p_po_header_id
1037 -- Header ID of the PO to which the PO line being deleted belongs
1038 --p_doc_subtype
1039 -- Document Sub type of the PO [STANDARD/BLANKET]
1040 --OUT:
1041 --x_return_status
1042 -- Standard API specification parameter
1043 -- Can hold one of the following values:
1044 -- FND_API.G_RET_STS_SUCCESS (='S')
1045 -- FND_API.G_RET_STS_ERROR (='E')
1046 -- FND_API.G_RET_STS_UNEXP_ERROR (='U')
1047 --Notes:
1048 -- Before calling pricing, we need not make the check whether the line price has
1049 -- not been manually updated. As this API will be invoked when the changes are
1050 -- being done from backend.
1051 --End of Comments
1052 -----------------------------------------------------------------------------
1053
1054 PROCEDURE process_delete_line_loc(p_line_loc_id IN NUMBER
1055 ,p_line_loc_row_id IN ROWID
1056 ,p_po_header_id IN NUMBER
1057 ,p_po_line_id IN NUMBER
1058 ,p_doc_subtype IN VARCHAR2)
1059 IS
1060
1061 l_vendor_id PO_HEADERS_ALL.vendor_id%TYPE;
1062 l_vendor_site_id PO_HEADERS_ALL.vendor_site_id%TYPE;
1063 l_currency_code PO_HEADERS_ALL.currency_code%TYPE;
1064 l_org_id PO_HEADERS_ALL.org_id%TYPE;
1065 l_po_lines_rec PO_LINES_ALL%ROWTYPE;
1066 l_base_unit_price PO_LINES_ALL.base_unit_price%TYPE;
1067 l_from_line_location_id PO_LINES_ALL.from_line_location_id%TYPE := NULL;
1068 l_shipment_type PO_LINE_LOCATIONS_ALL.shipment_type%TYPE := NULL;
1069 l_ga_entity_type PO_PRICE_DIFFERENTIALS.entity_type%TYPE := NULL;
1070 l_ga_entity_id PO_PRICE_DIFFERENTIALS.entity_id%TYPE := NULL;
1071 l_is_source_info_changed BOOLEAN := FALSE;
1072 l_price NUMBER := NULL;
1073 l_min_shipment_num NUMBER := NULL;
1074 d_pos NUMBER := 0;
1075 l_api_name CONSTANT VARCHAR2(30) := 'process_delete_line_loc';
1076 d_module CONSTANT VARCHAR2(70) := 'po.plsql.PO_SHIPMENTS_SV4.process_delete_line_loc';
1077
1078 BEGIN
1079 IF (PO_LOG.d_proc) THEN
1080 PO_LOG.proc_begin(d_module); PO_LOG.proc_begin(d_module,'p_line_loc_id', p_line_loc_id); PO_LOG.proc_begin(d_module,'p_line_loc_row_id', p_line_loc_row_id); PO_LOG.proc_begin(d_module,'p_po_header_id', p_po_header_id);
1081 PO_LOG.proc_begin(d_module,'p_doc_subtype', p_doc_subtype);
1082 END IF;
1083
1084 d_pos := 10;
1085 --get the required data of shipment's header and line
1086 SELECT shipment_type
1087 INTO l_shipment_type
1088 FROM po_line_locations_all
1089 WHERE line_location_id = p_line_loc_id;
1090
1091 d_pos := 20;
1092 po_shipments_sv4.delete_shipment(p_line_loc_id,
1093 p_line_loc_row_id,
1094 p_po_header_id,
1095 l_shipment_type);
1096
1097 d_pos := 30;
1098 IF (PO_LOG.d_stmt) THEN
1099 PO_LOG.stmt(d_module,d_pos,'l_shipment_type',l_shipment_type);
1100 END IF;
1101
1102 SELECT *
1103 INTO l_po_lines_rec
1104 FROM po_lines_all
1105 WHERE po_line_id = p_po_line_id;
1106
1107 d_pos := 40;
1108 IF (PO_LOG.d_stmt) THEN
1109 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.price_break_lookup_code', l_po_lines_rec.price_break_lookup_code); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.base_unit_price', l_po_lines_rec.base_unit_price);
1110 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.category_id', l_po_lines_rec.category_id); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.contract_id', l_po_lines_rec.contract_id);
1111 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.creation_date', l_po_lines_rec.creation_date); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.from_header_id', l_po_lines_rec.from_header_id);
1112 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.from_line_id', l_po_lines_rec.from_line_id); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.item_id', l_po_lines_rec.item_id);
1113 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.item_revision', l_po_lines_rec.item_revision); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.line_type_id', l_po_lines_rec.line_type_id);
1114 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.po_header_id', l_po_lines_rec.po_header_id); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.po_line_id', l_po_lines_rec.po_line_id);
1115 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.quantity', l_po_lines_rec.quantity); PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.unit_meas_lookup_code', l_po_lines_rec.unit_meas_lookup_code);
1116 PO_LOG.stmt(d_module, d_pos, 'l_po_lines_rec.vendor_product_num', l_po_lines_rec.vendor_product_num);
1117 END IF;
1118
1119 SELECT poh.vendor_id,
1120 poh.vendor_site_id,
1121 poh.currency_code
1122 INTO l_vendor_id,
1123 l_vendor_site_id,
1124 l_currency_code
1125 FROM po_headers_all poh
1126 WHERE poh.po_header_id = l_po_lines_rec.po_header_id;
1127
1128 d_pos := 50;
1129 IF (PO_LOG.d_stmt) THEN
1130 PO_LOG.stmt(d_module,d_pos,'l_vendor_id',l_vendor_id); PO_LOG.stmt(d_module,d_pos,'l_vendor_site_id',l_vendor_site_id); PO_LOG.stmt(d_module,d_pos,'l_currency_code',l_currency_code);
1131 END IF;
1132
1133 --Deleting price break is a retroactive change. Call the
1134 -- API to update po_lines.retroactive_date. This needs to be
1135 --done for updated price breaks.
1136 d_pos := 60;
1137 IF (l_po_lines_rec.price_break_lookup_code = 'NON CUMULATIVE' AND
1138 l_shipment_type = 'PRICE BREAK')
1139 THEN
1140 po_lines_sv2.retroactive_change(l_po_lines_rec.po_line_id);
1141 END IF;
1142
1143 d_pos := 70;
1144 -- Call the wrapper function to calculate the price when a shipment
1145 -- of a Standard PO with a source reference is deleted
1146 IF (p_doc_subtype = 'STANDARD' AND
1147 (l_po_lines_rec.from_header_id IS NOT NULL OR
1148 l_po_lines_rec.contract_id IS NOT NULL))
1149 THEN
1150
1151 d_pos := 80;
1152 --Get the mininum shipment number from the database
1153 PO_SOURCING2_SV.get_min_shipment_num(l_po_lines_rec.po_line_id,
1154 l_min_shipment_num);
1155
1156 d_pos := 90;
1157 IF (PO_LOG.d_stmt) THEN
1158 PO_LOG.stmt(d_module,d_pos,'l_min_shipment_num', l_min_shipment_num);
1159 END IF;
1160 -- Call the API to obtain the new price based on the 1st shipment of the
1161 -- standard PO.
1162 l_org_id := PO_MOAC_UTILS_PVT.get_current_org_id;
1163 d_pos := 100;
1164 IF (PO_LOG.d_stmt) THEN
1165 PO_LOG.stmt(d_module,d_pos,'l_org_id', l_org_id);
1166 END IF;
1167
1168 PO_SOURCING2_SV.get_shipment_price(
1169 p_po_line_id => l_po_lines_rec.po_line_id,
1170 p_from_line_id => l_po_lines_rec.from_line_id,
1171 p_min_shipment_num => l_min_shipment_num,
1172 p_quantity => l_po_lines_rec.quantity,
1173 p_contract_id => l_po_lines_rec.contract_id,
1174 p_org_id => l_org_id,
1175 p_supplier_id => l_vendor_id,
1176 p_supplier_site_id => l_vendor_site_id,
1177 p_creation_date => l_po_lines_rec.creation_date,
1178 p_order_header_id => l_po_lines_rec.po_header_id,
1179 p_order_line_id => l_po_lines_rec.po_line_id,
1180 p_line_type_id => l_po_lines_rec.line_type_id,
1181 p_item_revision => l_po_lines_rec.item_revision,
1182 p_item_id => l_po_lines_rec.item_id,
1183 p_category_id => l_po_lines_rec.category_id,
1184 p_supplier_item_num => l_po_lines_rec.vendor_product_num,
1185 p_in_price => l_po_lines_rec.base_unit_price,
1186 p_uom => l_po_lines_rec.unit_meas_lookup_code,
1187 p_currency_code => l_currency_code,
1188 x_base_unit_price => l_base_unit_price,
1189 x_price => l_price,
1190 x_from_line_location_id => l_from_line_location_id);
1191
1192 d_pos := 100;
1193 IF (PO_LOG.d_stmt) THEN
1194 PO_LOG.stmt(d_module, 'l_base_unit_price', l_base_unit_price); PO_LOG.stmt(d_module, 'l_price', l_price); PO_LOG.stmt(d_module, 'l_from_line_location_id', l_from_line_location_id);
1195 END IF;
1196
1197 -- Check whether the above call to the Pricing API returned a
1198 -- price break that is different than what is currently
1199 -- in the database.
1200 l_is_source_info_changed := PO_AUTOSOURCE_SV.has_source_changed(
1201 l_po_lines_rec.po_line_id,
1202 l_po_lines_rec.from_header_id,
1203 l_po_lines_rec.from_line_id,
1204 l_from_line_location_id);
1205 d_pos := 110;
1206 --Reinitialise the price values to original values if pricing
1207 --call returns null
1208 l_price := nvl(l_price, l_po_lines_rec.unit_price);
1209 l_base_unit_price := nvl(l_price, l_po_lines_rec.base_unit_price);
1210 IF (PO_LOG.d_stmt) THEN
1211 PO_LOG.stmt(d_module, 'l_base_unit_price', l_base_unit_price); PO_LOG.stmt(d_module, 'l_price', l_price);
1212 PO_LOG.stmt(d_module, 'boolean coverted to char: l_is_source_info_changed', PO_CORE_S.boolean_to_flag(l_is_source_info_changed));
1213 END IF;
1214
1215 d_pos := 120;
1216 -- Update the line price and from_line_location_id in PO_LINES_ALL
1217 PO_SOURCING2_SV.update_line_price(
1218 p_po_line_id => l_po_lines_rec.po_line_id,
1219 p_price => l_price,
1220 p_base_unit_price => l_base_unit_price,
1221 p_from_line_location_id => l_from_line_location_id);
1222
1223 d_pos := 120;
1224 -- If the price break was changed from the above Pricing API call,
1225 -- then the Price Differentials need to be redefaulted/cleared.
1226 IF (l_is_source_info_changed)
1227 THEN
1228 IF (l_po_lines_rec.order_type_lookup_code = 'RATE' AND
1229 p_doc_subtype = 'STANDARD')
1230 THEN
1231
1232 IF (l_from_line_location_id IS NOT NULL)
1233 THEN
1234 l_ga_entity_type := 'PRICE BREAK';
1235 l_ga_entity_id := l_from_line_location_id;
1236 ELSIF (l_po_lines_rec.from_line_id IS NOT NULL)
1237 THEN
1238 l_ga_entity_type := 'BLANKET LINE';
1239 l_ga_entity_id := l_po_lines_rec.from_line_id;
1240 END IF;
1241 d_pos := 130;
1242 IF (PO_LOG.d_stmt) THEN
1243 PO_LOG.stmt(d_module, 'l_ga_entity_type', l_ga_entity_type); PO_LOG.stmt(d_module, 'l_ga_entity_id', l_ga_entity_id);
1244 END IF;
1245 PO_PRICE_DIFFERENTIALS_PVT.delete_price_differentials(
1246 p_entity_type => 'PO LINE',
1247 p_entity_id => l_po_lines_rec.po_line_id);
1248 d_pos := 140;
1249 -- Copy Price Differentials from GA to Standard PO
1250 PO_PRICE_DIFFERENTIALS_PVT.default_price_differentials(
1251 p_from_entity_type => l_ga_entity_type,
1252 p_from_entity_id => l_ga_entity_id,
1253 p_to_entity_type => 'PO LINE',
1254 p_to_entity_id => l_po_lines_rec.po_line_id);
1255 END IF; --l_po_lines_rec.order_type_lookup_code = 'RATE'
1256
1257 END IF; --l_is_source_info_changed
1258 d_pos := 140;
1259 -- For this line, update all its corresponding shipment records
1260 UPDATE po_line_locations_all
1261 SET price_override = l_price,
1262 last_update_date = SYSDATE,
1263 last_updated_by = fnd_global.user_id
1264 WHERE po_line_id = l_po_lines_rec.po_line_id;
1265 END IF; --l_type_lookup_code = 'STANDARD'
1266
1267 IF (PO_LOG.d_proc) THEN
1268 PO_LOG.proc_end(d_module);
1269 END IF;
1270
1271 EXCEPTION
1272 WHEN OTHERS THEN
1273 FND_MSG_PUB.add_exc_msg(g_pkg_name, l_api_name||':'||d_pos);
1274 IF PO_LOG.d_exc THEN
1275 PO_LOG.exc(d_module,d_pos,'Unhandled Exception in' || d_module);
1276 END IF;
1277 RAISE;
1278 END process_delete_line_loc;
1279
1280 END PO_SHIPMENTS_SV4;
1281