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