[Home] [Help]
PACKAGE BODY: APPS.PO_LINES_SV3
Source
1 PACKAGE BODY PO_LINES_SV3 as
2 /* $Header: POXPOL3B.pls 120.12 2006/09/07 22:48:38 togeorge noship $ */
3
4 g_chktype_TRACKING_QTY_IND_S CONSTANT
5 MTL_SYSTEM_ITEMS_B.TRACKING_QUANTITY_IND%TYPE
6 := 'PS'; --<INVCONV R12>
7 /*============================= PO_LINES_SV3 ==============================*/
8
9 /*===========================================================================
10 PROCEDURE : Insert_line()
11
12 **===========================================================================*/
13
14 procedure insert_line(X_Rowid IN OUT NOCOPY VARCHAR2,
15 X_Po_Line_Id IN OUT NOCOPY NUMBER,
16 X_Last_Update_Date DATE,
17 X_Last_Updated_By NUMBER,
18 X_Po_Header_Id NUMBER,
19 X_Line_Type_Id NUMBER,
20 X_Line_Num NUMBER,
21 X_Last_Update_Login NUMBER,
22 X_Creation_Date DATE,
23 X_Created_By NUMBER,
24 X_Item_Id NUMBER,
25 X_Item_Revision VARCHAR2,
26 X_Category_Id NUMBER,
27 X_Item_Description VARCHAR2,
28 X_Unit_Meas_Lookup_Code VARCHAR2,
29 X_Quantity_Committed NUMBER,
30 X_Committed_Amount NUMBER,
31 X_Allow_Price_Override_Flag VARCHAR2,
32 X_Not_To_Exceed_Price NUMBER,
33 X_List_Price_Per_Unit NUMBER,
34 X_Unit_Price NUMBER,
35 X_Quantity NUMBER,
36 X_Un_Number_Id NUMBER,
37 X_Hazard_Class_Id NUMBER,
38 X_Note_To_Vendor VARCHAR2,
39 X_From_Header_Id NUMBER,
40 X_From_Line_Id NUMBER,
41 x_from_line_location_id NUMBER, -- <SERVICES FPJ>
42 X_Min_Order_Quantity NUMBER,
43 X_Max_Order_Quantity NUMBER,
44 X_Qty_Rcv_Tolerance NUMBER,
45 X_Over_Tolerance_Error_Flag VARCHAR2,
46 X_Market_Price NUMBER,
47 X_Unordered_Flag VARCHAR2,
48 X_Closed_Flag VARCHAR2,
49 X_User_Hold_Flag VARCHAR2,
50 X_Cancel_Flag VARCHAR2,
51 X_Cancelled_By NUMBER,
52 X_Cancel_Date DATE,
53 X_Cancel_Reason VARCHAR2,
54 X_Firm_Status_Lookup_Code VARCHAR2,
55 X_Firm_Date DATE,
56 X_Vendor_Product_Num VARCHAR2,
57 X_Contract_Num VARCHAR2,
58 X_Taxable_Flag VARCHAR2,
59 X_Tax_Code_Id NUMBER,
60 X_Type_1099 VARCHAR2,
61 X_Capital_Expense_Flag VARCHAR2,
62 X_Negotiated_By_Preparer_Flag VARCHAR2,
63 X_Attribute_Category VARCHAR2,
64 X_Attribute1 VARCHAR2,
65 X_Attribute2 VARCHAR2,
66 X_Attribute3 VARCHAR2,
67 X_Attribute4 VARCHAR2,
68 X_Attribute5 VARCHAR2,
69 X_Attribute6 VARCHAR2,
70 X_Attribute7 VARCHAR2,
71 X_Attribute8 VARCHAR2,
72 X_Attribute9 VARCHAR2,
73 X_Attribute10 VARCHAR2,
74 X_Reference_Num VARCHAR2,
75 X_Attribute11 VARCHAR2,
76 X_Attribute12 VARCHAR2,
77 X_Attribute13 VARCHAR2,
78 X_Attribute14 VARCHAR2,
79 X_Attribute15 VARCHAR2,
80 X_Min_Release_Amount NUMBER,
81 X_Price_Type_Lookup_Code VARCHAR2,
82 X_Closed_Code VARCHAR2,
83 X_Price_Break_Lookup_Code VARCHAR2,
84 X_Ussgl_Transaction_Code VARCHAR2,
85 X_Government_Context VARCHAR2,
86 X_Closed_Date DATE,
87 X_Closed_Reason VARCHAR2,
88 X_Closed_By NUMBER,
89 X_Transaction_Reason_Code VARCHAR2,
90 X_revise_header BOOLEAN,
91 X_revision_num NUMBER,
92 -- Bug 902976, zxzhang, 10/04/99
93 -- Change REVISED_DATE from VarChar(25) to Date.
94 -- X_revised_date VARCHAR2,
95 X_revised_date DATE,
96 X_approved_flag VARCHAR2,
97 X_header_row_id VARCHAR2,
98 X_type_lookup_code VARCHAR2,
99 X_ship_to_location_id NUMBER,
100 X_ship_org_id NUMBER,
101 X_need_by_date DATE,
102 X_promised_date DATE,
103 X_receipt_required_flag VARCHAR2,
104 X_invoice_close_tolerance NUMBER,
105 X_receive_close_tolerance NUMBER,
106 X_planned_item_flag VARCHAR2,
107 X_outside_operation_flag VARCHAR2,
108 X_destination_type_code VARCHAR2,
109 X_expense_accrual_code VARCHAR2,
110 X_dist_blk_status VARCHAR2,
111 X_accrue_on_receipt_flag IN OUT NOCOPY VARCHAR2,
112 X_ok_to_autocreate_ship VARCHAR2,
113 X_autocreated_ship IN OUT NOCOPY BOOLEAN,
114 X_line_location_id IN OUT NOCOPY NUMBER,
115 X_vendor_id NUMBER,
116 X_Global_Attribute_Category VARCHAR2,
117 X_Global_Attribute1 VARCHAR2,
118 X_Global_Attribute2 VARCHAR2,
119 X_Global_Attribute3 VARCHAR2,
120 X_Global_Attribute4 VARCHAR2,
121 X_Global_Attribute5 VARCHAR2,
122 X_Global_Attribute6 VARCHAR2,
123 X_Global_Attribute7 VARCHAR2,
124 X_Global_Attribute8 VARCHAR2,
125 X_Global_Attribute9 VARCHAR2,
126 X_Global_Attribute10 VARCHAR2,
127 X_Global_Attribute11 VARCHAR2,
128 X_Global_Attribute12 VARCHAR2,
129 X_Global_Attribute13 VARCHAR2,
130 X_Global_Attribute14 VARCHAR2,
131 X_Global_Attribute15 VARCHAR2,
132 X_Global_Attribute16 VARCHAR2,
133 X_Global_Attribute17 VARCHAR2,
134 X_Global_Attribute18 VARCHAR2,
135 X_Global_Attribute19 VARCHAR2,
136 X_Global_Attribute20 VARCHAR2,
137 X_Expiration_Date DATE,
138 -- Mahesh Chandak(GML-OPM).bug# 1548597.Add secondary_unit_of_measure,secondary_ quantity,preferred_grade for CR.base_uom and base_qty won't be used in future..
139 -- Preetam Bamb (GML-OPM) Added the following fields to replace PO_LINES flexfield
140 -- Bug# 1056597
141 X_Base_Uom VARCHAR2,
142 X_Base_Qty NUMBER,
143 X_Secondary_Uom VARCHAR2,
144 X_Secondary_Qty NUMBER,
145 X_Qc_Grade VARCHAR2,
146 --togeorge 10/03/2000
147 --added oke columns
148 X_oke_contract_header_id NUMBER default null,
149 X_oke_contract_version_id NUMBER default null,
150 --mchandak 1548597
151 X_Secondary_Unit_Of_Measure VARCHAR2 default null,
152 X_Secondary_Quantity NUMBER default null,
153 X_Preferred_Grade VARCHAR2 default null,
154 p_contract_id IN NUMBER DEFAULT NULL, -- <GC FPJ>
155 X_job_id IN NUMBER default null, -- <SERVICES FPJ>
156 X_contractor_first_name IN VARCHAR2 default null, -- <SERVICES FPJ>
157 X_contractor_last_name IN VARCHAR2 default null, -- <SERVICES FPJ>
158 X_assignment_start_date IN DATE default null, -- <SERVICES FPJ>
159 X_amount_db IN NUMBER default null, -- <SERVICES FPJ>
160 X_order_type_lookup_code IN VARCHAR2 default null, -- <SERVICES FPJ>
161 X_purchase_basis IN VARCHAR2 default null, -- <SERVICES FPJ>
162 X_matching_basis IN VARCHAR2 default null, -- <SERVICES FPJ>
163 -- <FPJ Advanced Price START>
164 X_Base_Unit_Price NUMBER DEFAULT NULL,
165 -- <FPJ Advanced Price END>
166 p_manual_price_change_flag IN VARCHAR2 default null, -- <Manual Price Override FPJ>
167 p_consigned_from_supplier_flag IN VARCHAR2 default null, --bug 3523348
168 p_org_id IN NUMBER default null -- <R12 MOAC>
169 ) is
170
171 X_Progress varchar2(3) := NULL;
172 X_item_valid varchar2(1) ;
173 X_valid_loc boolean := FALSE;
174 X_ship_row_id varchar2(18);
175 X_enforce_ship_to_location varchar2(25);
176 X_allow_substitute_receipts varchar2(1);
177 X_qty_rcv_exception_code varchar2(25);
178 X_qty_rcv_tol number;
179 X_days_early_receipt_allowed number;
180 X_days_late_receipt_allowed number;
181 X_receipt_days_exception_code varchar2(25);
182 X_receiving_routing_id number;
183 X_inspection_required_flag varchar2(1);
184 X_item_status VARCHAR2(1);
185 X_receipt_required_flag_tmp varchar2(1);
186
187
188 /*Bug 2632699 Added the variables */
189 temp_receipt_required_flag varchar2(1);
190 temp_inspection_required_flag varchar2(1);
191
192 /* Bug 919204
193 Added these two temp variables
194 X_receive_close_tolerance_tmp,X_invoice_close_tolerance_tmp
195 */
196
197 X_receive_close_tolerance_tmp number;
198 X_invoice_close_tolerance_tmp number;
199
200 /** bug# 1548597 **/
201 X_secondary_unit_of_measure_s MTL_UNITS_OF_MEASURE.UNIT_OF_MEASURE%TYPE := NULL;
202 X_secondary_quantity_shipment PO_LINE_LOCATIONS_ALL.SECONDARY_QUANTITY%TYPE := NULL;
203 X_preferred_grade_shipment MTL_GRADES.GRADE_CODE%TYPE := NULL;--<INVCONV R12> increased length to 150
204
205 --<INVCONV R12 START>
206 l_secondary_default_ind MTL_SYSTEM_ITEMS.SECONDARY_DEFAULT_IND%TYPE;
207 l_grade_control_flag MTL_SYSTEM_ITEMS.GRADE_CONTROL_FLAG%TYPE;
208 l_secondary_uom_code MTL_UNITS_OF_MEASURE.UOM_CODE%TYPE;
209 --<INVCONV R12 END>
210 l_outsourced_assembly po_line_locations_all.outsourced_assembly%type; --<SHIKYU R12>
211
212 l_ip_category_id PO_LINES_ALL.ip_category_id%TYPE; -- <Unified Catalog R12>
213
214 begin
215
216 -- verify that the line number is unique.
217 -- Otherwise, display a message to the user and
218 -- abort insert_row.
219
220 X_Progress := '010';
221 l_outsourced_assembly :=2; --<SHIKYU R12>
222 po_lines_pkg_scu.check_unique (X_rowid,
223 X_line_num,
224 X_po_header_id);
225
226 X_Progress := '015';
227
228 -- <Unified Catalog R12 Start>
229 -- Default the IP_CATEGORY_ID
230 PO_ATTRIBUTE_VALUES_PVT.get_ip_category_id
231 (
232 p_po_category_id => x_category_id
233 , x_ip_category_id => l_ip_category_id -- OUT
234 );
235 -- <Unified Catalog R12 End>
236
237 X_autocreated_ship := FALSE;
238
239 /* Insert the PO Line */
240
241 po_lines_pkg_si.insert_row(
242 X_Rowid ,
243 X_Po_Line_Id ,
244 X_Last_Update_Date ,
245 X_Last_Updated_By ,
246 X_Po_Header_Id ,
247 X_Line_Type_Id ,
248 X_Line_Num ,
249 X_Last_Update_Login ,
250 X_Creation_Date ,
251 X_Created_By ,
252 X_Item_Id ,
253 X_Item_Revision ,
254 X_Category_Id ,
255 X_Item_Description ,
256 X_Unit_Meas_Lookup_Code ,
257 X_Quantity_Committed ,
258 X_Committed_Amount ,
259 X_Allow_Price_Override_Flag ,
260 X_Not_To_Exceed_Price ,
261 X_List_Price_Per_Unit ,
262 -- <FPJ Advanced Price START>
263 -- Bug 3417479
264 X_Base_Unit_Price,
265 -- <FPJ Advanced Price END>
266 X_Unit_Price ,
267 X_Quantity ,
268 X_Un_Number_Id ,
269 X_Hazard_Class_Id ,
270 X_Note_To_Vendor ,
271 X_From_Header_Id ,
272 X_From_Line_Id ,
273 x_from_line_location_id , -- <SERVICES FPJ>
274 X_Min_Order_Quantity ,
275 X_Max_Order_Quantity ,
276 X_Qty_Rcv_Tolerance ,
277 X_Over_Tolerance_Error_Flag ,
278 X_Market_Price ,
279 X_Unordered_Flag ,
280 X_Closed_Flag ,
281 X_User_Hold_Flag ,
282 X_Cancel_Flag ,
283 X_Cancelled_By ,
284 X_Cancel_Date ,
285 X_Cancel_Reason ,
286 X_Firm_Status_Lookup_Code ,
287 X_Firm_Date ,
288 X_Vendor_Product_Num ,
289 X_Contract_Num ,
290 X_Taxable_Flag ,
291 X_Tax_Code_Id ,
292 X_Type_1099 ,
293 X_Capital_Expense_Flag ,
294 X_Negotiated_By_Preparer_Flag ,
295 X_Attribute_Category ,
296 X_Attribute1 ,
297 X_Attribute2 ,
298 X_Attribute3 ,
299 X_Attribute4 ,
300 X_Attribute5 ,
301 X_Attribute6 ,
302 X_Attribute7 ,
303 X_Attribute8 ,
304 X_Attribute9 ,
305 X_Attribute10 ,
306 X_Reference_Num ,
307 X_Attribute11 ,
308 X_Attribute12 ,
309 X_Attribute13 ,
310 X_Attribute14 ,
311 X_Attribute15 ,
312 X_Min_Release_Amount ,
313 X_Price_Type_Lookup_Code ,
314 X_Closed_Code ,
315 X_Price_Break_Lookup_Code ,
316 NULL , --<R12 SLA>
317 X_Government_Context ,
318 X_Closed_Date ,
319 X_Closed_Reason ,
320 X_Closed_By ,
321 X_Transaction_Reason_Code ,
322 X_Global_Attribute_Category ,
323 X_Global_Attribute1 ,
324 X_Global_Attribute2 ,
325 X_Global_Attribute3 ,
326 X_Global_Attribute4 ,
327 X_Global_Attribute5 ,
328 X_Global_Attribute6 ,
329 X_Global_Attribute7 ,
330 X_Global_Attribute8 ,
331 X_Global_Attribute9 ,
332 X_Global_Attribute10 ,
333 X_Global_Attribute11 ,
334 X_Global_Attribute12 ,
335 X_Global_Attribute13 ,
336 X_Global_Attribute14 ,
337 X_Global_Attribute15 ,
338 X_Global_Attribute16 ,
339 X_Global_Attribute17 ,
340 X_Global_Attribute18 ,
341 X_Global_Attribute19 ,
342 X_Global_Attribute20 ,
343 X_Expiration_Date ,
344 /** Mahesh Chandak(GML)bug# 1548597 base_uom and base_qty won't be used
345 in the future.we are keeping secondary_uom,secondary_qty and qc_grade for
346 supporting Common Purchasing. we will have 3 new fields secondary_unit_of_measu
347 re, secondary_quantity and preferred_grade columns in the table **/
348 -- Preetam Bamb (GML-OPM) Added the following fields to replace PO_LINES flexfield
349 -- Bug# 1056597
350 X_Base_Uom ,
351 X_Base_Qty ,
352 X_Secondary_Uom,
353 X_Secondary_Qty,
354 X_Qc_Grade,
355 --togeorge 10/03/2000
356 --added oke columns
357 X_oke_contract_header_id ,
358 X_oke_contract_version_id ,
359 -- start of 1548597
360 X_Secondary_unit_of_measure ,
361 X_Secondary_quantity ,
362 X_preferred_grade ,
363 -- end of 1548597
364 p_contract_id, -- <GC FPJ>
365 X_job_id, -- <SERVICES FPJ>
366 X_contractor_first_name, -- <SERVICES FPJ>
367 X_contractor_last_name, -- <SERVICES FPJ>
368 X_assignment_start_date, -- <SERVICES FPJ>
369 X_amount_db, -- <SERVICES FPJ>
370 X_order_type_lookup_code, -- <SERVICES FPJ>
371 X_purchase_basis, -- <SERVICES FPJ>
372 X_matching_basis, -- <SERVICES FPJ>
373 p_manual_price_change_flag, -- <Manual Price Override FPJ>
374 p_org_id, -- <R12 MOAC>
375 l_ip_category_id -- <Unified Catalog R12>
376 );
377
378 -- <Unified Catalog R12 Start>
379 -- Create default Attr and TLP rows for this PO Line
380 IF (x_type_lookup_code IN ('BLANKET', 'QUOTATION')) THEN
381 PO_ATTRIBUTE_VALUES_PVT.create_default_attributes
382 (
383 p_doc_type => x_type_lookup_code,
384 p_po_line_id => x_po_line_id,
385 p_req_template_name => NULL,
386 p_req_template_line_num => NULL,
387 p_ip_category_id => l_ip_category_id,
388 p_inventory_item_id => x_item_id,
389 p_org_id => p_org_id,
390 p_description => x_item_description
391 );
392 END IF;
393 -- <Unified Catalog R12 End>
394
395
396 if (x_type_lookup_code not in ('CONTRACT','BLANKET','RFQ', 'QUOTATION')) then
397
398 /* Check if a shipment can be autocreated */
399
400 IF X_ok_to_autocreate_ship = 'Y' THEN
401
402 if (X_ship_to_location_id is NULL) OR
403 (X_ship_org_id is NULL) then
404 /* Cannot Autocreate shipments AND distributions.
405 ** Should probably return.with an appropriate message DEBUG */
406
407 X_autocreated_ship := FALSE;
408
409 return;
410
411 elsif ( X_planned_item_flag = 'Y' ) then
412 if (X_need_by_date is NULL) AND
413 (X_promised_date is NULL) then
414 /* Cannot Autocreate shipments AND distributions.
415 ** Should probably return..with an appropriate msg. DEBUG */
416
417 X_autocreated_ship := FALSE;
418 return;
419
420 end if;
421
422 end if;
423
424 /* Attempt to autocreate shipment */
425
426 /* Validate the ship_to_location */
427 --<BUG 5506604> The following function call was happening only when x_item_id is null.
428 --removed the if clause around it to invoke irrespective of the item id.
429 /* Check_loc_valid_in_org */
430 X_valid_loc := po_locations_s.val_ship_to_site_in_org(
431 X_ship_to_location_id,
432 X_ship_org_id);
433
434 if X_item_id is not null then
435 /* The following procedure either validates
436 ** an item within an org, OR the item revision within
437 ** an org depending on the item_revision value */
438
439 po_items_sv.val_item_org(X_item_revision,
440 X_item_id,
441 X_ship_org_id,
442 X_outside_operation_flag,
443 X_item_valid);
444 end if;
445
446 /* Get the item status */
447
448 X_item_status := '';
449
450 po_items_sv2.get_item_status(X_item_id,
451 X_ship_org_id,
452 X_item_status);
453
454 --<BUG 5506604> Changed OR to AND below as
455 --auto creation should be taking place if both the condition are true
456 if ((nvl(X_item_valid,'Y') = 'Y') AND
457 (X_valid_loc)) then
458
459 /* rcv_core_s.get_receiving_controls;
460 ** DEBUG Need to add the call.
461 ** Currently the API does not duplicate the
462 ** functionality of the userexit.
463 ** Spoke to GKELLNER about it. 7/28 */
464 rcv_core_s.get_receiving_controls(null,
465 X_item_id,
466 X_vendor_id,
467 X_ship_org_id,
468 X_enforce_ship_to_location,
469 X_allow_substitute_receipts,
470 X_receiving_routing_id,
471 X_qty_rcv_tol,
472 X_qty_rcv_exception_code,
473 X_days_early_receipt_allowed,
474 X_days_late_receipt_allowed,
475 X_receipt_days_exception_code);
476
477
478 /* Bug 475621 ecso 4/23
479 * Get default value for invoice matching
480 */
481 po_shipments_sv8.get_matching_controls(
482 X_vendor_id,
483 X_line_type_id,
484 X_item_id,
485 X_receipt_required_flag_tmp,
486 X_inspection_required_flag);
487 IF X_receipt_required_flag_tmp IS NULL THEN
488 X_receipt_required_flag_tmp := 'N';
489 END IF;
490 IF X_inspection_required_flag IS NULL THEN
491 X_inspection_required_flag := 'N';
492 END IF;
493
494 /*Bug 2632699 Receipt required flag,Inspection required flag set for Item/destination Org
495 is retrived. If they are null then they are derived from masfer Org.
496 Also if Receipt required flag is N and Inspection required flag is Y then
497 Match option is showing as blank. Hence in the above case Inspection
498 required flag is set to N */
499
500 /* Bug 919204
501 Fix to use the invoice/receive close tolerance values
502 defined at the item/destination org level.
503 */
504 X_invoice_close_tolerance_tmp := X_invoice_close_tolerance;
505 X_receive_close_tolerance_tmp := X_receive_close_tolerance;
506 begin
507 SELECT nvl(msi.invoice_close_tolerance,X_invoice_close_tolerance_tmp),
508 nvl(msi.receive_close_tolerance,X_receive_close_tolerance_tmp),
509 msi.receipt_required_flag,
510 msi.inspection_required_flag,
511 --<INVCONV R12 START>
512 decode(msi.tracking_quantity_ind,
513 g_chktype_TRACKING_QTY_IND_S,msi.secondary_default_ind,NULL),
514 msi.grade_control_flag,
515 decode(msi.tracking_quantity_ind,
516 g_chktype_TRACKING_QTY_IND_S,msi.secondary_uom_code,NULL)
517 --<INVCONV R12 END>
518 INTO X_invoice_close_tolerance_tmp,
519 X_receive_close_tolerance_tmp,
520 temp_receipt_required_flag,
521 temp_inspection_required_flag,
522 l_secondary_default_ind, l_grade_control_flag, l_secondary_uom_code --<INVCONV R12>
523 FROM mtl_system_items msi
524 WHERE msi.inventory_item_id = X_item_id
525 AND msi.organization_id =X_ship_org_id;
526
527 exception
528 when no_data_found then null;
529 WHEN OTHERS THEN
530 po_message_s.sql_error('Fetch receive/invoice tolerances', x_progress, sqlcode);
531 raise;
532 end;
533 if temp_receipt_required_flag is not null then
534 X_receipt_required_flag_tmp := temp_receipt_required_flag;
535 end if;
536 if temp_inspection_required_flag is not null then
537 X_inspection_required_flag := temp_inspection_required_flag;
538 end if;
539
540 if X_receipt_required_flag_tmp = 'N' then
541 X_inspection_required_flag := 'N';
542 end if;
543
544 -- SERVICES FPJ start: Need to null out certain receiving and matching
545 -- controls for service lines.
546
547 IF X_order_type_lookup_code in ('RATE', 'FIXED PRICE') THEN
548
549 X_allow_substitute_receipts := null;
550 X_receiving_routing_id := 3;
551 X_enforce_ship_to_location := 'NONE';
552
553 X_inspection_required_flag := 'N';
554
555 IF X_purchase_basis = 'TEMP LABOR' THEN
556 X_days_early_receipt_allowed := null;
557 X_days_late_receipt_allowed := null;
558 X_receipt_days_exception_code := null;
559 END IF;
560
561 END IF;
562
563 -- SERVICES FPJ end
564
565 IF l_grade_control_flag = 'Y' THEN
566 X_preferred_grade_shipment := X_preferred_grade;
567 ELSE
568 X_preferred_grade_shipment := null;
569 END IF;
570
571 IF l_secondary_uom_code IS NOT NULL THEN -- item is dual uom control
572 SELECT unit_of_measure INTO x_secondary_unit_of_measure_s
573 FROM mtl_units_of_measure
574 WHERE uom_code = l_secondary_uom_code ;
575
576 /** secondary quantity is specified on the lines. Validate the line secondary quantity
577 with respect to ship to organization . Items in different organization can have different
578 from and to deviation so we need to validate before copying the line secondary quantity to shipment **/
579
580 IF X_secondary_quantity IS NOT NULL
581 and X_secondary_unit_of_measure = X_secondary_unit_of_measure_s THEN
582
583 IF ( INV_CONVERT.within_deviation(
584 p_organization_id => X_ship_org_id ,
585 p_inventory_item_id => x_item_id,
586 p_lot_number => null ,
587 p_precision => 5 ,
588 p_quantity => x_quantity,
589 p_unit_of_measure1 => X_Unit_Meas_Lookup_Code ,
590 p_quantity2 => x_secondary_quantity ,
591 p_unit_of_measure2 => X_secondary_unit_of_measure_s,
592 p_uom_code1 => null,
593 p_uom_code2 => null) = 1 ) THEN
594
595 X_secondary_quantity_shipment := X_secondary_quantity;
596 END IF;
597 END IF;
598
599 IF X_secondary_quantity_shipment IS NULL THEN -- derive secondary quantity
600 X_secondary_quantity_shipment := INV_CONVERT.inv_um_convert(
601 item_id => x_item_id ,
602 precision => 5,
603 from_quantity => x_quantity,
604 from_name => X_Unit_Meas_Lookup_Code ,
605 to_name => X_secondary_unit_of_measure_s,
606 from_unit => null,
607 to_unit => null ) ;
608 IF X_secondary_quantity_shipment <=0 then
609 X_autocreated_ship := FALSE;
610 return;
611 END IF;
612 END IF;
613 END IF; -- IF l_secondary_uom_code IS NOT NULL THEN
614
615
616 --<INVCONV R12 END>
617
618
619
620 /* AutoCreate the Shipment */
621
622 /* We are using the Qty_Rcv_Tol returned from get_receiving_controls()
623 in order to create the shipment automatically. We are not using
624 the value passed into this procedure insert_line() - Take a
625 note of that. SI 02/16 */
626
627 -- bug 451195
628 -- Added USSGL transaction code in autocreate shipment
629 --<SHIKYU R12 START>
630 IF X_item_id is NOT NULL and X_ship_org_id is not NULL THEN
631 l_outsourced_assembly := po_core_s.get_outsourced_assembly(X_item_id, X_ship_org_id);
632 END IF;
633 --<SHIKYU R12 END>
634 po_shipments_sv8.autocreate_ship(
635 X_line_location_id ,
636 X_last_update_date ,
637 X_last_updated_by ,
638 X_creation_date ,
639 X_created_by ,
640 X_last_update_login ,
641 X_po_header_id ,
642 X_po_line_id ,
643 X_type_lookup_code ,
644 X_quantity ,
645 X_ship_to_location_id ,
646 X_ship_org_id ,
647 X_need_by_date ,
648 X_promised_date ,
649 X_unit_price ,
650 X_tax_code_id ,
651 X_taxable_flag ,
652 X_enforce_ship_to_location ,
653 X_receiving_routing_id ,
654 X_inspection_required_flag ,
655 --X_receipt_required_flag ,
656 X_receipt_required_flag_tmp ,
657 X_qty_rcv_tol ,
658 X_qty_rcv_exception_code ,
659 X_days_early_receipt_allowed ,
660 X_days_late_receipt_allowed ,
661 X_allow_substitute_receipts ,
662 X_receipt_days_exception_code ,
663 X_invoice_close_tolerance_tmp ,
664 X_receive_close_tolerance_tmp ,
665 X_item_status ,
666 X_outside_operation_flag ,
667 X_destination_type_code ,
668 X_expense_accrual_code ,
669 X_item_id ,
670 NULL ,
671 X_accrue_on_receipt_flag ,
672 X_autocreated_ship ,
673 X_unit_meas_lookup_code, -- Added Parameter Bug 731564
674 X_order_type_lookup_code, -- <Complex Work R12>
675 X_matching_basis, -- <Complex Work R12>
676 -- start of bug# 1548597
677 X_secondary_unit_of_measure_s ,
678 X_secondary_quantity_shipment ,
679 X_preferred_grade_shipment,
680 p_consigned_from_supplier_flag, --bug 3523348
681 -- end of bug# 1548597
682 p_org_id, -- <R12 MOAC>
683 l_outsourced_assembly --<SHIKYU R12>
684 );
685
686 else
687
688 X_autocreated_ship := FALSE;
689
690 end if;
691
692 end if; /* IF ok_to_autocreate_ship flag is Y */
693
694 end if; /* not 'CONTRACT', 'BLANKET', 'RFQ' and 'QUOTATION' */
695
696 exception
697
698 when others then
699 po_message_s.sql_error('insert_line', x_progress, sqlcode);
700 raise;
701 end insert_line;
702
703 END PO_LINES_SV3;