[Home] [Help]
PACKAGE BODY: APPS.INV_RCV_STD_DELIVER_APIS
Source
1 PACKAGE BODY inv_rcv_std_deliver_apis AS
2 /* $Header: INVSTDDB.pls 120.29.12020000.3 2012/10/22 18:13:55 sfulzele ship $*/
3
4 --Variable to store interface_transaction_id for lot and serial splits
5 g_interface_transaction_id NUMBER;
6
7 g_pkg_name VARCHAR2(30) := 'INV_RCV_STD_DELIVER_APIS';
8
9 PROCEDURE print_debug(p_err_msg VARCHAR2, p_level NUMBER) IS
10 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
11 BEGIN
12 IF (l_debug = 1) THEN
13 inv_mobile_helper_functions.tracelog(p_err_msg => p_err_msg
14 , p_module => g_pkg_name||'($Revision: 120.29.12020000.3 $)'
15 , p_level => p_level);
16 END IF;
17 -- dbms_output.put_line(p_err_msg);
18 END print_debug;
19
20 -- rcv_transaction block
21 FUNCTION insert_interface_code(
22 l_rcv_transaction_rec IN OUT NOCOPY rcvtxn_transaction_rec_tp
23 , p_organization_id IN NUMBER)
24 RETURN NUMBER IS
25 l_receipt_source_code VARCHAR2(30) := l_rcv_transaction_rec.receipt_source_code;
26 l_interface_transaction_id NUMBER;
27 l_group_id NUMBER := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
28 l_user_id NUMBER := inv_rcv_common_apis.g_po_startup_value.user_id;
29 l_logon_id NUMBER := inv_rcv_common_apis.g_po_startup_value.logon_id;
30 l_source_document_code VARCHAR2(30) := l_rcv_transaction_rec.source_document_code;
31 l_dest_type_code VARCHAR2(30) := l_rcv_transaction_rec.destination_type_code;
32 l_quantity NUMBER := l_rcv_transaction_rec.transaction_quantity;
33 l_uom VARCHAR2(30) := l_rcv_transaction_rec.transaction_uom;
34 l_shipment_hdr_id NUMBER := l_rcv_transaction_rec.shipment_header_id;
35 l_shipment_line_id NUMBER := l_rcv_transaction_rec.shipment_line_id;
36 l_substitute_code VARCHAR2(30) := l_rcv_transaction_rec.substitute_unordered_code;
37 l_employee_id NUMBER := inv_rcv_common_apis.g_po_startup_value.employee_id;
38 l_parent_transaction_id NUMBER := l_rcv_transaction_rec.rcv_transaction_id;
39 l_inspection_code VARCHAR2(30) := l_rcv_transaction_rec.inspection_status_code;
40 l_quality_code VARCHAR2(30) := l_rcv_transaction_rec.inspection_quality_code;
41 l_po_hdr_id NUMBER := l_rcv_transaction_rec.po_header_id;
42 l_po_release_id NUMBER := l_rcv_transaction_rec.po_release_id;
43 l_po_line_id NUMBER := l_rcv_transaction_rec.po_line_id;
44 l_po_line_location_id NUMBER := l_rcv_transaction_rec.po_line_location_id;
45 l_po_dist_id NUMBER := l_rcv_transaction_rec.po_distribution_id;
46 l_po_rev_num NUMBER := l_rcv_transaction_rec.po_revision_num;
47 l_po_unit_price NUMBER := l_rcv_transaction_rec.po_unit_price;
48 l_currency_code VARCHAR2(30) := l_rcv_transaction_rec.currency_code;
49 l_currency_conv_rate NUMBER := l_rcv_transaction_rec.currency_conversion_rate;
50 l_currency_conv_date DATE := l_rcv_transaction_rec.currency_conversion_date;
51 l_currency_conv_type VARCHAR2(80) := l_rcv_transaction_rec.currency_conversion_type;
52 l_req_line_id NUMBER := l_rcv_transaction_rec.req_line_id;
53 l_req_dist_id NUMBER := l_rcv_transaction_rec.req_distribution_id;
54 l_routing_id NUMBER := l_rcv_transaction_rec.routing_id;
55 l_packing_slip VARCHAR2(80) := l_rcv_transaction_rec.packing_slip;
56 l_routing_step_id NUMBER := l_rcv_transaction_rec.routing_step_id;
57 l_comments VARCHAR2(240) := l_rcv_transaction_rec.comments;
58 l_vendor_item_num VARCHAR2(30) := l_rcv_transaction_rec.vendor_item_number;
59 l_attribute_category VARCHAR2(30) := l_rcv_transaction_rec.attribute_category;
60 l_attribute1 VARCHAR2(150) := l_rcv_transaction_rec.attribute1;
61 l_attribute2 VARCHAR2(150) := l_rcv_transaction_rec.attribute2;
62 l_attribute3 VARCHAR2(150) := l_rcv_transaction_rec.attribute3;
63 l_attribute4 VARCHAR2(150) := l_rcv_transaction_rec.attribute4;
64 l_attribute5 VARCHAR2(150) := l_rcv_transaction_rec.attribute5;
65 l_attribute6 VARCHAR2(150) := l_rcv_transaction_rec.attribute6;
66 l_attribute7 VARCHAR2(150) := l_rcv_transaction_rec.attribute7;
67 l_attribute8 VARCHAR2(150) := l_rcv_transaction_rec.attribute8;
68 l_attribute9 VARCHAR2(150) := l_rcv_transaction_rec.attribute9;
69 l_attribute10 VARCHAR2(150) := l_rcv_transaction_rec.attribute10;
70 l_attribute11 VARCHAR2(150) := l_rcv_transaction_rec.attribute11;
71 l_attribute12 VARCHAR2(150) := l_rcv_transaction_rec.attribute12;
72 l_attribute13 VARCHAR2(150) := l_rcv_transaction_rec.attribute13;
73 l_attribute14 VARCHAR2(150) := l_rcv_transaction_rec.attribute14;
74 l_attribute15 VARCHAR2(150) := l_rcv_transaction_rec.attribute15;
75 l_transaction_type VARCHAR2(30) := l_rcv_transaction_rec.transaction_type;
76 l_location_id NUMBER := l_rcv_transaction_rec.location_id;
77 l_processor_value VARCHAR2(10) := inv_rcv_common_apis.g_po_startup_value.transaction_mode;
78 l_category_id NUMBER := l_rcv_transaction_rec.category_id;
79 l_vendor_lot VARCHAR2(30) := l_rcv_transaction_rec.vendor_lot_num;
80 l_reason_id NUMBER := l_rcv_transaction_rec.reason_id;
81 l_primary_qty NUMBER := l_rcv_transaction_rec.primary_quantity;
82 l_primary_uom VARCHAR2(25) := l_rcv_transaction_rec.primary_uom;
83 l_secondary_quantity NUMBER := l_rcv_transaction_rec.sec_transaction_quantity; -- Bug 13344122
84 l_secondary_uom_code VARCHAR2(3) := l_rcv_transaction_rec.secondary_uom_code; -- Bug 13344122
85 l_item_id NUMBER := l_rcv_transaction_rec.item_id;
86 l_item_revision VARCHAR2(3) := l_rcv_transaction_rec.item_revision;
87 l_org_id NUMBER := p_organization_id;
88 l_deliver_to_location_id NUMBER := l_rcv_transaction_rec.deliver_to_location_id;
89 l_dest_context VARCHAR2(30) := l_rcv_transaction_rec.destination_context_nb;
90 l_vendor_id NUMBER := l_rcv_transaction_rec.vendor_id;
91 l_deliver_to_person_id NUMBER := l_rcv_transaction_rec.deliver_to_person_id;
92 l_subinventory VARCHAR2(30) := l_rcv_transaction_rec.subinventory_dsp;
93 l_locator_id NUMBER := l_rcv_transaction_rec.locator_id;
94 -- Bug 820859
95 l_wip_entity_id NUMBER := l_rcv_transaction_rec.wip_entity_id;
96 l_wip_line_id NUMBER := l_rcv_transaction_rec.wip_line_id;
97 l_wip_repetitive_schd_id NUMBER := l_rcv_transaction_rec.wip_repetitive_schedule_id;
98 l_bom_resource_id NUMBER := l_rcv_transaction_rec.bom_resource_id_nb;
99 -- Bug 820859
100 l_wip_resource_seq_num NUMBER := l_rcv_transaction_rec.wip_resource_seq_num;
101 l_wip_operation_seq_num NUMBER := l_rcv_transaction_rec.wip_operation_seq_num;
102 l_mtl_lot NUMBER := l_rcv_transaction_rec.lot_control_code;
103 l_mtl_serial NUMBER := l_rcv_transaction_rec.serial_number_control_code;
104 l_transaction_date DATE := l_rcv_transaction_rec.transaction_date_nb;
105 l_movement_id NUMBER;
106 l_qa_collection_id NUMBER := l_rcv_transaction_rec.qa_collection_id;
107 l_ussgl_transaction_code VARCHAR2(30) := l_rcv_transaction_rec.ussgl_transaction_code;
108 l_government_context VARCHAR2(30) := l_rcv_transaction_rec.government_context;
109 l_vendor_site_id NUMBER := l_rcv_transaction_rec.vendor_site_id;
110 l_oe_order_header_id NUMBER := l_rcv_transaction_rec.oe_order_header_id;
111 l_oe_order_line_id NUMBER := l_rcv_transaction_rec.oe_order_line_id;
112 l_customer_id NUMBER := l_rcv_transaction_rec.customer_id;
113 l_customer_site_id NUMBER := l_rcv_transaction_rec.customer_site_id;
114 l_put_away_rule_id NUMBER := l_rcv_transaction_rec.put_away_rule_id;
115 l_put_away_strategy_id NUMBER := l_rcv_transaction_rec.put_away_strategy_id;
116 l_lpn_id NUMBER := l_rcv_transaction_rec.lpn_id;
117 l_transfer_lpn_id NUMBER := l_rcv_transaction_rec.transfer_lpn_id;
118 l_cost_group_id NUMBER := l_rcv_transaction_rec.cost_group_id;
119 l_mmtt_temp_id NUMBER := l_rcv_transaction_rec.mmtt_temp_id;
120 l_transfer_cost_group_id NUMBER := l_rcv_transaction_rec.transfer_cost_group_id;
121 l_project_id NUMBER := NULL;
122 l_task_id NUMBER := NULL;
123
124 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
125 l_validation_flag VARCHAR2(1);
126 l_lpn_group_id NUMBER;
127
128 l_operating_unit_id MO_GLOB_ORG_ACCESS_TMP.ORGANIZATION_ID%TYPE; --<R12 MOAC>
129 --Bug #4348794
130 l_uom_code mtl_units_of_measure.uom_code%TYPE;
131
132
133 -- For Bug 7440217
134 v_lcm_enabled_org varchar2(1);
135 v_pre_receive varchar2(1);
136 v_lcm_ship_line_id NUMBER;
137 v_unit_landed_cost NUMBER;
138 -- End for Bug 7440217
139
140 BEGIN
141 IF (l_debug = 1) THEN
142 print_debug('entering insert_interface_code 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
143 print_debug('l_po_dist_id :'||l_po_dist_id,1);
144 END IF;
145 print_debug('transaction type is'||l_transaction_type, 1);
146 --Bug 3989684 start
147 --Bug #4058417 - Adding an exception handler block
148 --Check if l_reason_id is populated, if not get it from MMTT
149 IF (l_reason_id) IS NULL THEN
150 IF (l_debug = 1) THEN
151 print_debug('l_reason_id is null, check reason_id on MMTT',1);
152 END IF;
153 BEGIN
154 SELECT reason_id
155 INTO l_reason_id
156 FROM mtl_material_transactions_temp
157 WHERE transaction_temp_id = l_mmtt_temp_id;
158 EXCEPTION
159 WHEN OTHERS THEN
160 IF (l_debug = 1) THEN
161 print_debug('Exception occurred while querying MMTT', 1);
162 END IF;
163 END;
164
165 IF (l_debug = 1) THEN
166 print_debug('l_reason_id '||l_reason_id||' Updated to RTI,Transaction Interface Id'||l_interface_transaction_id,1);
167 END IF;
168 END IF;
169 --Bug 3989684 end
170
171 -- Chk if RCV_TRANSACTION.INTERFACE_transaction_id item is populated
172 -- If not, populate the item with get_interface_id function
173 --if l_rcv_transaction_rec.INTERFACE_transaction_id is null THEN
174 SELECT rcv_transactions_interface_s.NEXTVAL
175 INTO l_interface_transaction_id
176 FROM SYS.DUAL;
177
178 l_rcv_transaction_rec.interface_transaction_id := l_interface_transaction_id;
179
180 --else
181 --l_interface_transaction_id := l_rcv_transaction_rec.INTERFACE_transaction_id;
182 --end if;
183
184 --dbms_output.put_line('Inserted with intf. txn id:'||l_interface_transaction_id);
185
186 --Since we call the Transfer API for a receiving subinventory with WMS
187 --patchset J, do not need this validation
188 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
189 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
190 IF (l_debug = 1) THEN
191 print_debug('WMS patch level is < J. Setting txntype to TRANSFER for RECEIVING dest', 4);
192 END IF;
193 IF l_rcv_transaction_rec.destination_type_code = 'RECEIVING' THEN
194 l_transaction_type := 'TRANSFER';
195 l_dest_context := 'RECEIVING';
196 l_deliver_to_person_id := NULL;
197 l_deliver_to_location_id := NULL;
198 l_wip_entity_id := NULL;
199 l_subinventory := NULL;
200 l_locator_id := NULL;
201 l_wip_line_id := NULL;
202 l_wip_repetitive_schd_id := NULL;
203 l_wip_operation_seq_num := NULL;
204 l_bom_resource_id := NULL;
205 l_wip_resource_seq_num := NULL;
206 ELSE
207 l_transaction_type := 'DELIVER';
208 END IF;
209 ELSE
210 IF (l_debug = 1) THEN
211 print_debug('WMS patch level is >= J. Setting txntype to DELIVER since dest is INVENTORY', 4);
212 END IF;
213 l_transaction_type := 'DELIVER';
214 END IF;
215
216 SELECT rt.movement_id,
217 rt.project_id,
218 rt.task_id
219 INTO l_movement_id,
220 l_project_id,
221 l_task_id
222 FROM rcv_transactions rt
223 WHERE rt.transaction_id = l_parent_transaction_id;
224
225 /* FP-J Lot/Serial Support Enhancement
226 * Populate the LPN_GROUP_ID and validation_flag columns if INV and PO
227 * patch levels are J or higher else set them to NULL
228 * Insert these two additional columns in RTI
229 */
230 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
231 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
232 l_validation_flag := 'Y';
233 l_lpn_group_id := l_group_id;
234 -- bug 3452845
235 l_transaction_date := Sysdate;
236 ELSE
237 l_validation_flag := NULL;
238 l_lpn_group_id := NULL;
239 l_transaction_date := Trunc(Sysdate);
240 END IF;
241
242 --<R12 MOAC>
243 l_operating_unit_id := inv_rcv_common_apis.get_operating_unit_id( l_receipt_source_code,
244 l_po_hdr_id,
245 l_req_line_id,
246 l_oe_order_header_id );
247
248 IF (l_debug = 1) THEN
249 print_debug('insert_inspect_rec_rti: validation_flag : ' || l_validation_flag || ', lpn_group_id: ' || l_lpn_group_id, 4);
250 END IF;
251
252 --Bug #4348794 - Populate RTI with uom code
253 BEGIN
254 SELECT muom.uom_code
255 INTO l_uom_code
256 FROM mtl_units_of_measure muom
257 WHERE muom.unit_of_measure = l_uom;
258 IF (l_debug = 1) THEN
259 print_debug('Unit of measure: ' || l_uom || ', UOM Code: ' || l_uom_code, 1);
260 END IF;
261 EXCEPTION
262 WHEN OTHERS THEN
263 IF (l_debug = 1) THEN
264 print_debug('Error occurred while fetching UOM code', 1);
265 END IF;
266 END;
267
268 --bug 6412992
269 IF( inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j AND l_wip_entity_id is NULL) then
270 BEGIN
271 select backorder_delivery_detail_id into l_wip_entity_id
272 from mtl_txn_request_lines mtrl , mtl_material_transactions_temp mmtt
273 where mmtt.transaction_temp_id = l_mmtt_temp_id
274 and mtrl.line_id = mmtt.move_order_line_id
275 and mtrl.CROSSDOCK_TYPE = 2;
276 EXCEPTION
277 WHEN NO_DATA_FOUND THEN
278 l_wip_entity_id := null;
279 END;
280 END IF;
281 --end of fix of bug 6412992
282
283
284
285
286 INSERT INTO rcv_transactions_interface
287 (
288 receipt_source_code
289 , interface_transaction_id
290 , GROUP_ID
291 , last_update_date
292 , last_updated_by
293 , created_by
294 , creation_date
295 , last_update_login
296 , interface_source_code
297 , source_document_code
298 , destination_type_code
299 , transaction_date
300 , quantity
301 , unit_of_measure
302 , shipment_header_id
303 , shipment_line_id
304 , substitute_unordered_code
305 , employee_id
306 , parent_transaction_id
307 , inspection_status_code
308 , inspection_quality_code
309 , po_header_id
310 , po_release_id
311 , po_line_id
312 , po_line_location_id
313 , po_distribution_id
314 , po_revision_num
315 , po_unit_price
316 , currency_code
317 , currency_conversion_rate
318 , requisition_line_id
319 , req_distribution_id
320 , routing_header_id
321 , routing_step_id
322 , packing_slip
323 , vendor_item_num
324 , comments
325 , attribute_category
326 , attribute1
327 , attribute2
328 , attribute3
329 , attribute4
330 , attribute5
331 , attribute6
332 , attribute7
333 , attribute8
334 , attribute9
335 , attribute10
336 , attribute11
337 , attribute12
338 , attribute13
339 , attribute14
340 , attribute15
341 , transaction_type
342 , location_id
343 , processing_status_code
344 , processing_mode_code
345 , transaction_status_code
346 , category_id
347 , vendor_lot_num
348 , reason_id
349 , primary_quantity
350 , primary_unit_of_measure
351 , item_id
352 , item_revision
353 , to_organization_id
354 , deliver_to_location_id
355 , destination_context
356 , vendor_id
357 , deliver_to_person_id
358 , subinventory
359 , locator_id
360 , wip_entity_id
361 , wip_line_id
362 , wip_repetitive_schedule_id
363 , wip_operation_seq_num
364 , wip_resource_seq_num
365 , bom_resource_id
366 , use_mtl_lot
367 , use_mtl_serial
368 , movement_id
369 , currency_conversion_date
370 , currency_conversion_type
371 , qa_collection_id
372 , ussgl_transaction_code
373 , government_context
374 , vendor_site_id
375 , oe_order_header_id
376 , oe_order_line_id
377 , customer_id
378 , customer_site_id
379 , put_away_rule_id
380 , put_away_strategy_id
381 , lpn_id
382 , transfer_lpn_id
383 , cost_group_id
384 , mmtt_temp_id
385 , mobile_txn
386 , transfer_cost_group_id
387 , secondary_quantity -- Bug 13344122
388 , secondary_uom_code -- Bug 13344122
389 , validation_flag
390 , lpn_group_id
391 , project_id
392 , task_id
393 , org_id --<R12 MOAC>
394 , uom_code
395 )
396 VALUES (
397 l_receipt_source_code
398 , l_interface_transaction_id
399 , l_group_id
400 , SYSDATE
401 , l_user_id
402 , l_user_id
403 , SYSDATE
404 , l_logon_id
405 , 'RCV'
406 , l_source_document_code
407 , l_dest_type_code
408 , l_transaction_date
409 , l_quantity
410 , l_uom
411 , l_shipment_hdr_id
412 , l_shipment_line_id
413 , l_substitute_code
414 , l_employee_id
415 , l_parent_transaction_id
416 , l_inspection_code
417 , l_quality_code
418 , l_po_hdr_id
419 , l_po_release_id
420 , l_po_line_id
421 , l_po_line_location_id
422 , l_po_dist_id
423 , l_po_rev_num
424 , l_po_unit_price
425 , l_currency_code
426 , l_currency_conv_rate
427 , l_req_line_id
428 , l_req_dist_id
429 , l_routing_id
430 , l_routing_step_id
431 , l_packing_slip
432 , l_vendor_item_num
433 , l_comments
434 , l_attribute_category
435 , l_attribute1
436 , l_attribute2
437 , l_attribute3
438 , l_attribute4
439 , l_attribute5
440 , l_attribute6
441 , l_attribute7
442 , l_attribute8
443 , l_attribute9
444 , l_attribute10
445 , l_attribute11
446 , l_attribute12
447 , l_attribute13
448 , l_attribute14
449 , l_attribute15
450 , l_transaction_type
451 , l_location_id
452 , 'PENDING'
453 , l_processor_value
454 , 'PENDING'
455 , l_category_id
456 , l_vendor_lot
457 , l_reason_id
458 , l_primary_qty
459 , l_primary_uom
460 , l_item_id
461 , l_item_revision
462 , l_org_id
463 , l_deliver_to_location_id
464 , l_dest_context
465 , l_vendor_id
466 , l_deliver_to_person_id
467 , l_subinventory
468 , l_locator_id
469 , l_wip_entity_id
470 , l_wip_line_id
471 , l_wip_repetitive_schd_id
472 , l_wip_operation_seq_num
473 , l_wip_resource_seq_num
474 , l_bom_resource_id
475 , l_mtl_lot
476 , l_mtl_serial
477 , l_movement_id
478 , TRUNC(l_currency_conv_date)
479 , l_currency_conv_type
480 , l_qa_collection_id
481 , l_ussgl_transaction_code
482 , l_government_context
483 , l_vendor_site_id
484 , l_oe_order_header_id
485 , l_oe_order_line_id
486 , l_customer_id
487 , l_customer_site_id
488 , l_put_away_rule_id
489 , l_put_away_strategy_id
490 , l_lpn_id
491 , l_transfer_lpn_id
492 , l_cost_group_id
493 , l_mmtt_temp_id
494 , 'Y'
495 , -- MOBILE_TXN
496 l_transfer_cost_group_id
497 , l_secondary_quantity -- Bug 13344122
498 , l_secondary_uom_code -- Bug 13344122
499 , l_validation_flag
500 , l_lpn_group_id
501 , l_project_id
502 , l_task_id
503 , l_operating_unit_id --<R12 MOAC>
504 , l_uom_code
505 );
506
507
508
509
510
511 -- For Bug 7440217 added the following code to update RTI with the status as PENDING so that it gets picked up for processing
512 SELECT mp.lcm_enabled_flag
513 INTO v_lcm_enabled_org
514 FROM mtl_parameters mp
515 WHERE mp.organization_id = l_org_id;
516
517 SELECT rp.pre_receive
518 INTO v_pre_receive
519 FROM rcv_parameters rp
520 WHERE rp.organization_id = l_org_id;
521
522 IF nvl(v_lcm_enabled_org, 'N') = 'Y' THEN
523
524 SELECT LCM_SHIPMENT_LINE_ID, UNIT_LANDED_COST
525 INTO v_lcm_ship_line_id, v_unit_landed_cost
526 FROM rcv_shipment_lines
527 WHERE shipment_line_id = l_shipment_line_id;
528
529 UPDATE rcv_transactions_interface
530 SET lcm_shipment_line_id = v_lcm_ship_line_id,
531 unit_landed_cost = v_unit_landed_cost
532 WHERE interface_transaction_id = l_interface_transaction_id
533 AND to_organization_id = l_org_id;
534
535 END IF;
536 -- End for Bug 7440217
537
538
539
540
541 RETURN l_interface_transaction_id;
542
543 IF (l_debug = 1) THEN
544 print_debug('exiting insert_interface_code 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
545 END IF;
546 END insert_interface_code;
547
548 PROCEDURE insert_lot_serial(
549 p_lot_serial_break_tbl IN inv_rcv_common_apis.trans_rec_tb_tp
550 , p_transaction_temp_id IN NUMBER
551 , p_lot_control_code IN NUMBER
552 , p_serial_control_code IN NUMBER
553 , p_interface_transaction_id IN NUMBER
554 ) IS
555 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
556 BEGIN
557 IF (l_debug = 1) THEN
558 print_debug('entering insert_lot_serial 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
559 END IF;
560
561 inv_rcv_common_apis.BREAK(
562 p_transaction_temp_id
563 , p_lot_serial_break_tbl
564 , p_lot_control_code
565 , p_serial_control_code);
566
567 IF p_lot_control_code = 2 THEN
568 -- it is lot controlled so lots must be inserted into lots temp table
569 INSERT INTO rcv_lots_interface
570 (
571 interface_transaction_id
572 , last_update_date
573 , last_updated_by
574 , creation_date
575 , created_by
576 , last_update_login
577 , request_id
578 , program_application_id
579 , program_id
580 , program_update_date
581 , lot_num
582 , quantity
583 , transaction_date
584 , expiration_date
585 , primary_quantity
586 , item_id
587 , shipment_line_id
588 )
589 SELECT rti.interface_transaction_id
590 , rti.last_update_date
591 , rti.last_updated_by
592 , rti.creation_date
593 , rti.created_by
594 , rti.last_update_login
595 , rti.request_id
596 , rti.program_application_id
597 , rti.program_id
598 , rti.program_update_date
599 , mtlt.lot_number
600 , mtlt.transaction_quantity
601 , rti.transaction_date
602 , mtlt.lot_expiration_date
603 , mtlt.primary_quantity
604 , rti.item_id
605 , rti.shipment_line_id
606 FROM rcv_transactions_interface rti, mtl_transaction_lots_temp mtlt
607 WHERE rti.interface_transaction_id = p_interface_transaction_id
608 AND mtlt.transaction_temp_id = rti.interface_transaction_id;
609
610 -- Bug 2458540
611 -- IF p_serial_control_code NOT IN (1,6) THEN
612 IF p_serial_control_code NOT IN(1) THEN
613 -- serial numbers were also inserted in serials temp table
614 INSERT INTO rcv_serials_interface
615 (
616 interface_transaction_id
617 , last_update_date
618 , last_updated_by
619 , creation_date
620 , created_by
621 , last_update_login
622 , request_id
623 , program_application_id
624 , program_id
625 , program_update_date
626 , transaction_date
627 , fm_serial_num
628 , to_serial_num
629 , serial_prefix
630 , lot_num
631 , vendor_serial_num
632 , vendor_lot_num
633 , item_id
634 , organization_id
635 )
636 SELECT rti.interface_transaction_id
637 , rti.last_update_date
638 , rti.last_updated_by
639 , rti.creation_date
640 , rti.created_by
641 , rti.last_update_login
642 , rti.request_id
643 , rti.program_application_id
644 , rti.program_id
645 , rti.program_update_date
646 , rti.transaction_date
647 , mtst.fm_serial_number
648 , mtst.to_serial_number
649 , mtst.serial_prefix
650 , mtlt.lot_number
651 , NULL
652 , rti.vendor_lot_num
653 , rti.item_id
654 , rti.to_organization_id
655 FROM rcv_transactions_interface rti, mtl_transaction_lots_temp mtlt, mtl_serial_numbers_temp mtst
656 WHERE rti.interface_transaction_id = p_interface_transaction_id
657 AND mtlt.transaction_temp_id = rti.interface_transaction_id
658 AND mtlt.serial_transaction_temp_id = mtst.transaction_temp_id;
659 END IF;
660 ELSE
661 -- it is just serial controlled item
662 --
663 -- Toshiba Fix
664 --
665 -- IF p_serial_control_code NOT IN (1,6) THEN
666 IF p_serial_control_code NOT IN(1) THEN
667 -- serial numbers were also inserted in serials temp table
668 INSERT INTO rcv_serials_interface
669 (
670 interface_transaction_id
671 , last_update_date
672 , last_updated_by
673 , creation_date
674 , created_by
675 , last_update_login
676 , request_id
677 , program_application_id
678 , program_id
679 , program_update_date
680 , transaction_date
681 , fm_serial_num
682 , to_serial_num
683 , serial_prefix
684 , lot_num
685 , vendor_serial_num
686 , vendor_lot_num
687 , item_id
688 , organization_id
689 )
690 SELECT rti.interface_transaction_id
691 , rti.last_update_date
692 , rti.last_updated_by
693 , rti.creation_date
694 , rti.created_by
695 , rti.last_update_login
696 , rti.request_id
697 , rti.program_application_id
698 , rti.program_id
699 , rti.program_update_date
700 , rti.transaction_date
701 , mtst.fm_serial_number
702 , mtst.to_serial_number
703 , mtst.serial_prefix
704 , NULL
705 , NULL
706 , rti.vendor_lot_num
707 , rti.item_id
708 , rti.to_organization_id
709 FROM rcv_transactions_interface rti, mtl_serial_numbers_temp mtst
710 WHERE rti.interface_transaction_id = p_interface_transaction_id
711 AND mtst.transaction_temp_id = rti.interface_transaction_id;
712 END IF;
713 END IF;
714
715 IF (l_debug = 1) THEN
716 print_debug('exiting insert_lot_serial 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
717 END IF;
718 END insert_lot_serial;
719
720 PROCEDURE populate_default_values(
721 p_rcv_transaction_rec IN OUT NOCOPY rcvtxn_transaction_rec_tp
722 , p_rcv_rcvtxn_rec IN OUT NOCOPY rcvtxn_enter_rec_cursor_rec
723 , p_organization_id IN NUMBER
724 , p_item_id IN NUMBER
725 , p_revision IN VARCHAR2
726 , p_subinventory_code IN VARCHAR2
727 , p_locator_id IN NUMBER
728 , p_transaction_temp_id IN NUMBER
729 , p_lot_control_code IN NUMBER
730 , p_serial_control_code IN NUMBER
731 , p_original_txn_temp_id IN NUMBER
732 , p_lpn_id IN NUMBER DEFAULT NULL
733 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
734 ) IS
735 l_final_location_id NUMBER;
736 l_destination_context VARCHAR2(30);
737 l_final_deliver_to_person_id NUMBER;
738 l_final_deliver_to_location_id NUMBER;
739 l_person VARCHAR2(240);
740 l_location VARCHAR2(60); -- 4615262
741 l_hazard_class VARCHAR2(40);
742 l_un_number VARCHAR2(30);
743 l_sub_locator_control VARCHAR2(30);
744 l_count NUMBER;
745 l_locator_id NUMBER;
746 l_locator_control NUMBER;
747 l_req_line_id NUMBER;
748 l_oe_order_line_id NUMBER;
749 l_project_id NUMBER;
750 temp_sub VARCHAR2(30);
751 l_task_id NUMBER;
752 l_primary_quantity NUMBER;
753 l_today_date DATE := SYSDATE;
754 l_currency_conversion_rate NUMBER;
755 l_currency_conversion_date DATE;
756 l_linelocationid NUMBER;
757 l_rcvtrxid NUMBER;
758 l_matchflag VARCHAR2(1);
759 l_rate NUMBER;
760 l_ratedate DATE;
761 l_ratedisplay NUMBER;
762 l_interface_transaction_id NUMBER;
763 -- This keeps track of the number with which the record was inserted.
764
765 l_lot_serial_break_tbl inv_rcv_common_apis.trans_rec_tb_tp;
766 -- table that will store the record into which the lot/serial entered
767 -- have to be broken.
768
769 l_po_distribution_id NUMBER;
770 l_valid_ship_to_location BOOLEAN;
771 l_valid_deliver_to_location BOOLEAN;
772 l_valid_deliver_to_person BOOLEAN;
773 l_valid_subinventory BOOLEAN;
774 l_rcv_transaction_id NUMBER;
775 l_group_id NUMBER;
776 l_final_destination_type_code VARCHAR2(80);
777 l_final_destination_type_dsp VARCHAR2(80);
778 l_destination_type_dsp_hold VARCHAR2(80);
779 l_final_subinventory VARCHAR2(80);
780 l_wip_entity_id NUMBER;
781 l_wip_line_id NUMBER;
782 l_wip_repetitive_schedule_id NUMBER;
783 l_outside_processing VARCHAR2(1);
784 l_job_sch_dsp VARCHAR2(80);
785 l_op_seq_num_dsp VARCHAR2(80);
786 l_department_code VARCHAR2(80);
787 l_prod_line_dsp VARCHAR2(80);
788 l_bom_resource_id NUMBER;
789 l_available_quantity NUMBER;
790 l_tolerable_quantity NUMBER;
791 l_uom VARCHAR2(80);
792 l_distribution_count NUMBER;
793 l_receiving_value VARCHAR2(80);
794 l_po_operation_seq_num NUMBER;
795 l_po_resource_seq_num NUMBER;
796 l_content_lpn_id NUMBER;
797 l_lpn_controlled_flag NUMBER;
798 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
799 l_subinventory_type NUMBER;
800 l_tmp_destination_code VARCHAR2(80);
801 l_asn_line_flag VARCHAR2(3);
802 l_is_expense VARCHAR2(1);
803 l_po_routing_id NUMBER;
804 BEGIN
805 IF (l_debug = 1) THEN
806 print_debug('entering populate_default_values 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
807 END IF;
808
809 rcv_transaction_sv.post_query(
810 p_rcv_rcvtxn_rec.rcv_transaction_id
811 , p_rcv_rcvtxn_rec.receipt_source_code
812 , p_rcv_rcvtxn_rec.to_organization_id
813 , p_rcv_rcvtxn_rec.hazard_class_id
814 , p_rcv_rcvtxn_rec.un_number_id
815 , p_rcv_rcvtxn_rec.shipment_header_id
816 , p_rcv_rcvtxn_rec.shipment_line_id
817 , p_rcv_rcvtxn_rec.po_line_location_id
818 , p_rcv_rcvtxn_rec.po_line_id
819 , p_rcv_rcvtxn_rec.po_header_id
820 , p_rcv_rcvtxn_rec.po_release_id
821 , p_rcv_rcvtxn_rec.vendor_id
822 , p_rcv_rcvtxn_rec.item_id
823 , p_rcv_rcvtxn_rec.item_revision
824 , p_rcv_rcvtxn_rec.transaction_date
825 , p_rcv_rcvtxn_rec.creation_date
826 , p_rcv_rcvtxn_rec.location_id
827 , p_rcv_rcvtxn_rec.subinventory
828 , p_rcv_rcvtxn_rec.destination_type_code_hold
829 , l_destination_type_dsp_hold
830 , p_rcv_rcvtxn_rec.primary_uom
831 , p_rcv_rcvtxn_rec.routing_id
832 , l_po_distribution_id
833 , l_final_destination_type_code
834 , l_final_destination_type_dsp
835 , l_final_location_id
836 , l_final_subinventory
837 , l_destination_context
838 , l_wip_entity_id
839 , l_wip_line_id
840 , l_wip_repetitive_schedule_id
841 , l_outside_processing
842 , l_job_sch_dsp
843 , l_op_seq_num_dsp
844 , l_department_code
845 , l_prod_line_dsp
846 , l_bom_resource_id
847 , l_final_deliver_to_person_id
848 , l_final_deliver_to_location_id
849 , l_person
850 , l_location
851 , l_hazard_class
852 , l_un_number
853 , l_sub_locator_control
854 , l_count
855 , l_locator_id
856 , l_available_quantity
857 , l_primary_quantity
858 , l_tolerable_quantity
859 , l_uom
860 , l_distribution_count
861 , l_receiving_value
862 , l_po_operation_seq_num
863 , l_po_resource_seq_num
864 , l_currency_conversion_rate
865 , l_currency_conversion_date
866 , p_rcv_rcvtxn_rec.oe_order_line_id
867 );
868
869 --validate deliver to info
870 IF (l_debug = 1) THEN
871 print_debug('populate_default_values 20: ', 4);
872 END IF;
873
874 rcv_transactions_sv.val_destination_info(
875 p_organization_id
876 , p_item_id
877 , NULL
878 , p_rcv_rcvtxn_rec.final_deliver_to_location_id
879 , p_rcv_rcvtxn_rec.final_deliver_to_person_id
880 , p_subinventory_code
881 , l_valid_ship_to_location
882 , l_valid_deliver_to_location
883 , l_valid_deliver_to_person
884 , l_valid_subinventory
885 );
886 -- query RCV_ENTER_RECEIPTS_V to populate DB items in rcv_transaction block
887 p_rcv_transaction_rec.to_organization_id := p_rcv_rcvtxn_rec.to_organization_id;
888 p_rcv_transaction_rec.source_document_code := p_rcv_rcvtxn_rec.source_document_code;
889 p_rcv_transaction_rec.receipt_source_code := p_rcv_rcvtxn_rec.receipt_source_code;
890
891 IF p_rcv_rcvtxn_rec.receipt_source_code = 'CUSTOMER' THEN
892 SELECT displayed_field
893 , lookup_code
894 INTO l_final_destination_type_dsp
895 , l_final_destination_type_code
896 FROM po_lookup_codes
897 WHERE lookup_code = 'INVENTORY'
898 AND lookup_type = 'RCV DESTINATION TYPE';
899 END IF;
900
901 IF (l_debug = 1) THEN
902 print_debug('populate_default_values 30: ', 4);
903 END IF;
904
905 -- Get the lpn_id, transfer_lpn_id, content_lpn_id, cost_group_id,
906 -- PUT_AWAY_RULE_ID, PUT_AWAY_STRATEGY_ID
907 BEGIN
908 SELECT lpn_id
909 , transfer_lpn_id
910 , content_lpn_id
911 , cost_group_id
912 , put_away_rule_id
913 , put_away_strategy_id
914 INTO p_rcv_transaction_rec.lpn_id
915 , p_rcv_transaction_rec.transfer_lpn_id
916 , l_content_lpn_id
917 , p_rcv_transaction_rec.cost_group_id
918 , p_rcv_transaction_rec.put_away_rule_id
919 , p_rcv_transaction_rec.put_away_strategy_id
920 FROM mtl_material_transactions_temp
921 WHERE transaction_temp_id = p_original_txn_temp_id;
922 EXCEPTION
923 WHEN OTHERS THEN
924 IF (l_debug = 1) THEN
925 print_debug('exception in getting info. from orig mmtt', 4);
926 END IF;
927
928 NULL;
929 END;
930
931 -- Get the transfer_cost_group_id from rcv_shipment_lines
932 BEGIN
933 SELECT cost_group_id
934 INTO p_rcv_transaction_rec.transfer_cost_group_id
935 FROM rcv_shipment_lines
936 WHERE shipment_line_id = p_rcv_rcvtxn_rec.shipment_line_id;
937 EXCEPTION
938 WHEN OTHERS THEN
939 IF (l_debug = 1) THEN
940 print_debug('exception in getting transfer cost group id', 4);
941 END IF;
942
943 p_rcv_transaction_rec.transfer_cost_group_id := NULL;
944 END;
945
946
947 /* FP-J Nested LPN Support Enhancement
948 * If WMS and PO patch levels are J or higher, set the value of lpn_id and
949 * transfer_lpn_id in RTI from the input parameters and we should not
950 * refer to the MMTT columns since they would not be updating them
951 */
952 IF ((inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j) OR
953 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
954 IF l_content_lpn_id IS NOT NULL THEN
955 p_rcv_transaction_rec.lpn_id := l_content_lpn_id;
956
957 BEGIN
958 SELECT NVL(lpn_controlled_flag, 1)
959 INTO l_lpn_controlled_flag
960 FROM mtl_secondary_inventories
961 WHERE secondary_inventory_name = p_subinventory_code
962 AND organization_id = p_organization_id;
963
964 IF l_lpn_controlled_flag = 1 THEN
965 p_rcv_transaction_rec.transfer_lpn_id := l_content_lpn_id;
966 ELSE
967 p_rcv_transaction_rec.transfer_lpn_id := NULL;
968 END IF;
969 EXCEPTION
970 WHEN OTHERS THEN
971 p_rcv_transaction_rec.transfer_lpn_id := NULL;
972 END;
973 END IF;
974 ELSE
975 IF (l_debug = 1) THEN
976 print_debug('populate_default_values 35.5 : WMS and PO patch levels are J or higher. LPN columns should be set from passed values rather than MMTT', 4);
977 END IF;
978 p_rcv_transaction_rec.lpn_id := p_lpn_id;
979 p_rcv_transaction_rec.transfer_lpn_id := p_transfer_lpn_id;
980 END IF; --END IF check WMS and PO patch levels
981
982 p_rcv_transaction_rec.mmtt_temp_id := p_original_txn_temp_id;
983
984 IF (l_debug = 1) THEN
985 print_debug('Info got from original mmtt', 4);
986 print_debug('LPN_ID:' || p_rcv_transaction_rec.lpn_id, 4);
987 print_debug('TRANSFER_LPN_ID:' || p_rcv_transaction_rec.transfer_lpn_id, 4);
988 print_debug('CONTENT_LPN_ID:' || l_content_lpn_id, 4);
989 print_debug('COST_GROUP_ID:' || p_rcv_transaction_rec.cost_group_id, 4);
990 print_debug('TRANSFER_COST_GROUP_ID:' || p_rcv_transaction_rec.transfer_cost_group_id, 4);
991 print_debug('PUT_AWAY_RULE_ID:' || p_rcv_transaction_rec.put_away_rule_id, 4);
992 print_debug('PUT_AWAY_STRATEGY_ID:' || p_rcv_transaction_rec.put_away_strategy_id, 4);
993 END IF;
994
995 IF (l_debug = 1) THEN
996 print_debug('populate_default_values 40: ', 4);
997 END IF;
998
999 p_rcv_transaction_rec.rcv_transaction_id := p_rcv_rcvtxn_rec.rcv_transaction_id;
1000 p_rcv_transaction_rec.transaction_date := p_rcv_rcvtxn_rec.transaction_date;
1001 p_rcv_transaction_rec.transaction_type := p_rcv_rcvtxn_rec.transaction_type;
1002 p_rcv_transaction_rec.po_header_id := p_rcv_rcvtxn_rec.po_header_id;
1003 p_rcv_transaction_rec.po_revision_num := p_rcv_rcvtxn_rec.po_revision_num;
1004 p_rcv_transaction_rec.po_release_id := p_rcv_rcvtxn_rec.po_release_id;
1005 p_rcv_transaction_rec.vendor_id := p_rcv_rcvtxn_rec.vendor_id;
1006 p_rcv_transaction_rec.vendor_site_id := p_rcv_rcvtxn_rec.vendor_site_id;
1007 p_rcv_transaction_rec.po_line_id := p_rcv_rcvtxn_rec.po_line_id;
1008 p_rcv_transaction_rec.po_unit_price := p_rcv_rcvtxn_rec.po_unit_price;
1009 p_rcv_transaction_rec.category_id := p_rcv_rcvtxn_rec.category_id;
1010 p_rcv_transaction_rec.item_id := p_rcv_rcvtxn_rec.item_id;
1011 p_rcv_transaction_rec.primary_uom := p_rcv_rcvtxn_rec.primary_uom;
1012 p_rcv_transaction_rec.serial_number_control_code := p_rcv_rcvtxn_rec.serial_number_control_code;
1013 p_rcv_transaction_rec.lot_control_code := p_rcv_rcvtxn_rec.lot_control_code;
1014 p_rcv_transaction_rec.item_revision := p_rcv_rcvtxn_rec.item_revision;
1015 p_rcv_transaction_rec.po_line_location_id := p_rcv_rcvtxn_rec.po_line_location_id;
1016 p_rcv_transaction_rec.employee_id := p_rcv_rcvtxn_rec.employee_id;
1017 p_rcv_transaction_rec.comments := p_rcv_rcvtxn_rec.comments;
1018 p_rcv_transaction_rec.req_header_id := p_rcv_rcvtxn_rec.req_header_id;
1019 p_rcv_transaction_rec.req_line_id := p_rcv_rcvtxn_rec.req_line_id;
1020 p_rcv_transaction_rec.shipment_header_id := p_rcv_rcvtxn_rec.shipment_header_id;
1021 p_rcv_transaction_rec.shipment_line_id := p_rcv_rcvtxn_rec.shipment_line_id;
1022 p_rcv_transaction_rec.packing_slip := p_rcv_rcvtxn_rec.packing_slip;
1023 p_rcv_transaction_rec.government_context := p_rcv_rcvtxn_rec.government_context;
1024 p_rcv_transaction_rec.ussgl_transaction_code := p_rcv_rcvtxn_rec.ussgl_transaction_code;
1025 p_rcv_transaction_rec.inspection_status_code := p_rcv_rcvtxn_rec.inspection_status_code;
1026 p_rcv_transaction_rec.inspection_quality_code := p_rcv_rcvtxn_rec.inspection_quality_code;
1027 p_rcv_transaction_rec.vendor_lot_num := p_rcv_rcvtxn_rec.vendor_lot_num;
1028 p_rcv_transaction_rec.vendor_item_number := p_rcv_rcvtxn_rec.vendor_item_number;
1029 p_rcv_transaction_rec.substitute_unordered_code := p_rcv_rcvtxn_rec.substitute_unordered_code;
1030 p_rcv_transaction_rec.routing_id := p_rcv_rcvtxn_rec.routing_id;
1031 p_rcv_transaction_rec.routing_step_id := p_rcv_rcvtxn_rec.routing_step_id;
1032 p_rcv_transaction_rec.reason_id := p_rcv_rcvtxn_rec.reason_id;
1033 p_rcv_transaction_rec.currency_code := p_rcv_rcvtxn_rec.currency_code;
1034 p_rcv_transaction_rec.currency_conversion_rate := p_rcv_rcvtxn_rec.currency_conversion_rate;
1035 p_rcv_transaction_rec.currency_conversion_date := p_rcv_rcvtxn_rec.currency_conversion_date;
1036 p_rcv_transaction_rec.currency_conversion_type := p_rcv_rcvtxn_rec.currency_conversion_type;
1037 p_rcv_transaction_rec.req_distribution_id := p_rcv_rcvtxn_rec.req_distribution_id;
1038 p_rcv_transaction_rec.destination_type_code_hold := p_rcv_rcvtxn_rec.destination_type_code_hold;
1039
1040 IF (l_valid_deliver_to_person) THEN
1041 p_rcv_transaction_rec.deliver_to_person_id := p_rcv_rcvtxn_rec.final_deliver_to_person_id;
1042 ELSE
1043 p_rcv_transaction_rec.deliver_to_person_id := '';
1044 END IF;
1045
1046 IF (l_valid_deliver_to_location) THEN
1047 p_rcv_transaction_rec.deliver_to_location_id := p_rcv_rcvtxn_rec.final_deliver_to_location_id;
1048 ELSE
1049 p_rcv_transaction_rec.deliver_to_location_id := '';
1050 END IF;
1051
1052 p_rcv_transaction_rec.subinventory := p_rcv_rcvtxn_rec.subinventory;
1053 p_rcv_transaction_rec.un_number_id := p_rcv_rcvtxn_rec.un_number_id;
1054 p_rcv_transaction_rec.hazard_class_id := p_rcv_rcvtxn_rec.hazard_class_id;
1055 p_rcv_transaction_rec.creation_date := p_rcv_rcvtxn_rec.creation_date;
1056 p_rcv_transaction_rec.attribute_category := p_rcv_rcvtxn_rec.attribute_category;
1057 p_rcv_transaction_rec.attribute1 := p_rcv_rcvtxn_rec.attribute1;
1058 p_rcv_transaction_rec.attribute2 := p_rcv_rcvtxn_rec.attribute2;
1059 p_rcv_transaction_rec.attribute3 := p_rcv_rcvtxn_rec.attribute3;
1060 p_rcv_transaction_rec.attribute4 := p_rcv_rcvtxn_rec.attribute4;
1061 p_rcv_transaction_rec.attribute5 := p_rcv_rcvtxn_rec.attribute5;
1062 p_rcv_transaction_rec.attribute6 := p_rcv_rcvtxn_rec.attribute6;
1063 p_rcv_transaction_rec.attribute7 := p_rcv_rcvtxn_rec.attribute7;
1064 p_rcv_transaction_rec.attribute8 := p_rcv_rcvtxn_rec.attribute8;
1065 p_rcv_transaction_rec.attribute9 := p_rcv_rcvtxn_rec.attribute9;
1066 p_rcv_transaction_rec.attribute10 := p_rcv_rcvtxn_rec.attribute10;
1067 p_rcv_transaction_rec.attribute11 := p_rcv_rcvtxn_rec.attribute11;
1068 p_rcv_transaction_rec.attribute12 := p_rcv_rcvtxn_rec.attribute12;
1069 p_rcv_transaction_rec.attribute13 := p_rcv_rcvtxn_rec.attribute13;
1070 p_rcv_transaction_rec.attribute14 := p_rcv_rcvtxn_rec.attribute14;
1071 p_rcv_transaction_rec.attribute15 := p_rcv_rcvtxn_rec.attribute15;
1072 p_rcv_transaction_rec.qa_collection_id := p_rcv_rcvtxn_rec.qa_collection_id;
1073 p_rcv_transaction_rec.oe_order_header_id := p_rcv_rcvtxn_rec.oe_order_header_id;
1074 p_rcv_transaction_rec.oe_order_line_id := p_rcv_rcvtxn_rec.oe_order_line_id;
1075 p_rcv_transaction_rec.customer_id := p_rcv_rcvtxn_rec.customer_id;
1076 p_rcv_transaction_rec.customer_site_id := p_rcv_rcvtxn_rec.customer_site_id;
1077 p_rcv_transaction_rec.destination_type_code_pqry := p_rcv_rcvtxn_rec.final_destination_type_code;
1078 -- p_rcv_transaction_rec.destination_type_code := p_rcv_rcvtxn_rec.final_destination_type_code;
1079 p_rcv_transaction_rec.destination_type_code := l_final_destination_type_code;
1080 p_rcv_transaction_rec.location_id := l_final_location_id;
1081 p_rcv_transaction_rec.subinventory_hold := p_rcv_rcvtxn_rec.final_subinventory;
1082 p_rcv_transaction_rec.subinventory_dsp := p_rcv_rcvtxn_rec.final_subinventory;
1083 p_rcv_transaction_rec.destination_context_nb := l_destination_context;
1084 p_rcv_transaction_rec.wip_entity_id := p_rcv_rcvtxn_rec.wip_entity_id;
1085 p_rcv_transaction_rec.wip_line_id := p_rcv_rcvtxn_rec.wip_line_id;
1086 p_rcv_transaction_rec.wip_repetitive_schedule_id := p_rcv_rcvtxn_rec.wip_repetitive_schedule_id;
1087 p_rcv_transaction_rec.wip_resource_seq_num := p_rcv_rcvtxn_rec.po_resource_seq_num;
1088 p_rcv_transaction_rec.wip_operation_seq_num := p_rcv_rcvtxn_rec.po_operation_seq_num;
1089 p_rcv_transaction_rec.bom_resource_id_nb := p_rcv_rcvtxn_rec.bom_resource_id;
1090 p_rcv_transaction_rec.deliver_to_location_id := p_rcv_rcvtxn_rec.final_deliver_to_location_id;
1091 p_rcv_transaction_rec.deliver_to_person_id := l_final_deliver_to_person_id;
1092 p_rcv_transaction_rec.locator_id := l_locator_id;
1093
1094
1095 -- added for ASN delivery bug fix
1096 IF p_rcv_transaction_rec.po_distribution_id IS NULL THEN
1097 p_rcv_transaction_rec.po_distribution_id := l_po_distribution_id;
1098 END IF;
1099
1100 IF NVL(p_rcv_transaction_rec.routing_id, 1) = 2
1101 AND p_rcv_transaction_rec.inspection_status_code = 'NOT INSPECTED' THEN
1102 p_rcv_transaction_rec.destination_type_code := 'RECEIVING';
1103 p_rcv_transaction_rec.destination_context_nb := 'RECEIVING';
1104 p_rcv_transaction_rec.destination_type_code_pqry := p_rcv_rcvtxn_rec.final_destination_type_code;
1105 END IF;
1106
1107 IF (l_debug = 1) THEN
1108 print_debug('populate_default_values 50: ', 4);
1109 END IF;
1110
1111 IF (p_rcv_transaction_rec.req_line_id IS NOT NULL) THEN
1112 po_subinventories_s.get_default_subinventory(p_organization_id, p_item_id, l_final_subinventory);
1113 p_rcv_transaction_rec.subinventory_dsp := l_final_subinventory;
1114 p_rcv_transaction_rec.subinventory_hold := l_final_subinventory;
1115 END IF;
1116
1117 -- Go get the locator control value if the locator control has
1118 -- not already been selected or if the subinventory has been
1119 -- modified
1120
1121 IF (l_debug = 1) THEN
1122 print_debug('populate_default_values 60: ', 4);
1123 END IF;
1124
1125 IF (
1126 p_rcv_transaction_rec.destination_type_code_pqry = 'INVENTORY'
1127 AND p_rcv_transaction_rec.subinventory_locator_control IS NULL
1128 AND p_rcv_transaction_rec.subinventory_dsp IS NOT NULL
1129 ) THEN
1130 po_subinventories_s.get_locator_control(
1131 p_rcv_transaction_rec.to_organization_id
1132 , p_rcv_transaction_rec.subinventory_dsp
1133 , p_rcv_transaction_rec.item_id
1134 , l_locator_control
1135 );
1136 p_rcv_transaction_rec.subinventory_locator_control := l_locator_control;
1137 ELSE
1138 l_locator_control := p_rcv_transaction_rec.subinventory_locator_control;
1139 END IF;
1140
1141 IF (l_debug = 1) THEN
1142 print_debug('populate_default_values 70: ', 4);
1143 END IF;
1144
1145 IF (p_rcv_transaction_rec.destination_type_code_hold = 'INVENTORY'
1146 AND p_rcv_transaction_rec.subinventory_dsp IS NOT NULL) THEN
1147 -- get default locator
1148 --
1149 -- Anytime a subinventory is selected then the locator field
1150 -- should be prepopulated with the default locator_id from
1151 -- mtl_item_loc_defaults for the item, org and subinventory
1152 -- and where the default_type = 2
1153 po_subinventories_s.get_default_locator(
1154 p_rcv_transaction_rec.to_organization_id
1155 , p_rcv_transaction_rec.item_id
1156 , p_rcv_transaction_rec.subinventory_dsp
1157 , l_locator_id
1158 );
1159 -- Bug 616392
1160 l_req_line_id := p_rcv_transaction_rec.req_line_id;
1161 l_oe_order_line_id := p_rcv_transaction_rec.oe_order_line_id;
1162
1163 IF (l_debug = 1) THEN
1164 print_debug('populate_default_values 80: ', 4);
1165 END IF;
1166
1167 IF p_rcv_transaction_rec.receipt_source_code <> 'CUSTOMER' THEN
1168 IF (l_req_line_id IS NOT NULL
1169 AND l_locator_id IS NOT NULL) THEN
1170 SELECT project_id
1171 , task_id
1172 INTO l_project_id
1173 , l_task_id
1174 FROM po_req_distributions
1175 WHERE requisition_line_id = l_req_line_id;
1176 END IF;
1177 ELSE
1178 -- Locator field defaulting for rmas
1179 IF (l_oe_order_line_id IS NOT NULL
1180 AND l_locator_id IS NOT NULL) THEN
1181 SELECT project_id
1182 , task_id
1183 INTO l_project_id
1184 , l_task_id
1185 FROM oe_order_lines_all
1186 WHERE line_id = l_oe_order_line_id;
1187 END IF;
1188 END IF;
1189
1190 IF (l_debug = 1) THEN
1191 print_debug('populate_default_values 90: ', 4);
1192 END IF;
1193
1194 IF (l_project_id IS NOT NULL) THEN
1195 pjm_project_locator.get_defaultprojectlocator(
1196 p_rcv_transaction_rec.to_organization_id
1197 , l_locator_id
1198 , l_project_id
1199 , l_task_id
1200 , l_locator_id);
1201 END IF;
1202
1203 p_rcv_transaction_rec.locator_id := l_locator_id;
1204 END IF;
1205
1206 -- Depending on the Destination Type value, dependent fields will
1207 -- be enabled or disabled
1208 -- To ensure this, INIT code of the dependent fields will be executed
1209 IF (l_debug = 1) THEN
1210 print_debug('populate_default_values 100: ', 4);
1211 END IF;
1212
1213 -- Part of the code in RCV_LINE_LOC_PERS_CONTROL.LOCATION_DSP('INIT');
1214 IF (
1215 (p_rcv_transaction_rec.destination_type_code <> 'MULTIPLE')
1216 AND(p_rcv_transaction_rec.destination_type_code_hold <> 'MULTIPLE')
1217 ) THEN
1218 p_rcv_transaction_rec.location_id := p_rcv_transaction_rec.deliver_to_location_id;
1219 END IF;
1220
1221 -- Part of the code in RCV_SUBINVENTORY_CONTROL.SUBINVENTORY_DSP('INIT');
1222 temp_sub := p_rcv_transaction_rec.subinventory_dsp;
1223
1224 IF (p_rcv_transaction_rec.destination_type_code = 'INVENTORY') THEN
1225 -- INIT is used when you query up a new row or switch the destination
1226 -- destination type from receiving to inventory
1227 IF (temp_sub IS NULL) THEN
1228 p_rcv_transaction_rec.subinventory_dsp := p_rcv_transaction_rec.subinventory_hold;
1229 ELSE
1230 p_rcv_transaction_rec.subinventory_dsp := temp_sub;
1231 END IF;
1232 END IF;
1233
1234 IF (l_debug = 1) THEN
1235 print_debug('populate_default_values 110: ', 4);
1236 END IF;
1237
1238 -- Part of the code in RCV_LOCATOR_CONTROL.SET_LOCATOR_ATTRIBUTES('INIT');
1239 IF (
1240 NVL(inv_rcv_common_apis.g_rcv_global_var.express_mode, 'NO') = 'NO'
1241 AND p_rcv_transaction_rec.subinventory_dsp IS NOT NULL
1242 AND p_rcv_transaction_rec.destination_type_code = 'INVENTORY'
1243 AND p_rcv_transaction_rec.subinventory_locator_control IN(2, 3)
1244 ) THEN
1245 NULL;
1246 ELSE
1247 p_rcv_transaction_rec.locator_id := NULL;
1248 END IF;
1249
1250 -- l_primary_quantity has the available primary quantity for this row
1251 --p_rcv_transaction_rec.primary_quantity := l_primary_quantity;
1252 p_rcv_transaction_rec.transaction_date_nb := l_today_date;
1253 p_rcv_transaction_rec.inspection_detail := 'N';
1254
1255 -- If subinventory is null, then null out default locator details
1256 IF p_rcv_transaction_rec.subinventory_dsp IS NULL THEN
1257 p_rcv_transaction_rec.locator_id := NULL;
1258 END IF;
1259
1260 IF (p_rcv_transaction_rec.destination_type_code = 'MULTIPLE') THEN
1261 -- Chk if location_id item is null. If not null then copy null into the item
1262 IF p_rcv_transaction_rec.location_id IS NOT NULL THEN
1263 p_rcv_transaction_rec.location_id := NULL;
1264 END IF;
1265
1266 -- Bug No 1823328 Changes, setting the destination type code otherwise fails in rcvtpo..
1267 IF p_rcv_transaction_rec.po_distribution_id IS NOT NULL THEN
1268 p_rcv_transaction_rec.destination_type_code := p_rcv_rcvtxn_rec.final_destination_type_code;
1269
1270 IF (l_debug = 1) THEN
1271 print_debug('populate_default_values A : ' || p_rcv_transaction_rec.destination_type_code, 1);
1272 END IF;
1273 END IF;
1274 --
1275 --Begin changes bug 3157829
1276
1277
1278 SELECT nvl(rsh.asn_type, 'NNN')
1279 INTO l_asn_line_flag
1280 FROM rcv_shipment_headers rsh,
1281 rcv_shipment_lines rsl
1282 WHERE rsh.shipment_header_id = rsl.shipment_header_id
1283 AND rsl.shipment_line_id = p_rcv_rcvtxn_rec.shipment_line_id;
1284
1285 IF (l_debug = 1) THEN
1286 print_debug('populate_default_values : l_asn_line_flag = '||l_asn_line_flag, 4);
1287 print_debug('populate_defauly_values : p_rcv_transaction_rec.DESTINATION_TYPE_CODE ='||p_rcv_transaction_rec.DESTINATION_TYPE_CODE, 4);
1288 END IF;
1289
1290 IF (l_asn_line_flag = 'ASN') THEN
1291
1292 --Check if the destination is expense
1293 inv_rcv_common_apis.get_po_routing_id(
1294 x_po_routing_id => l_po_routing_id,
1295 x_is_expense => l_is_expense,
1296 p_po_header_id => p_rcv_rcvtxn_rec.po_header_id,
1297 p_po_release_id => p_rcv_rcvtxn_rec.po_release_id,
1298 p_po_line_id => p_rcv_rcvtxn_rec.po_line_id,
1299 p_item_id => p_rcv_rcvtxn_rec.item_id,
1300 p_item_desc => NULL);
1301
1302 IF (l_debug = 1) THEN
1303 print_debug('populate_default_values : l_is_expense ='||l_is_expense, 4);
1304 END IF;
1305
1306 IF (l_is_expense = 'Y') THEN
1307
1308 SELECT lookup_code
1309 INTO l_tmp_destination_code
1310 FROM po_lookup_codes
1311 WHERE lookup_code = 'EXPENSE'
1312 AND lookup_type = 'RCV DESTINATION TYPE';
1313
1314 ELSE
1315
1316 SELECT lookup_code
1317 INTO l_tmp_destination_code
1318 FROM po_lookup_codes
1319 WHERE lookup_code = 'INVENTORY'
1320 AND lookup_type = 'RCV DESTINATION TYPE';
1321
1322 END IF;
1323
1324 IF (l_debug = 1) THEN
1325 print_debug('populate_default_values : l_tmp_destination_code = '||l_tmp_destination_code,4);
1326 END IF;
1327
1328 p_rcv_transaction_rec.DESTINATION_TYPE_CODE := l_tmp_destination_code;
1329 END IF;
1330
1331 --End changes 3157829
1332
1333
1334 ELSE
1335 p_rcv_transaction_rec.currency_conversion_rate := l_currency_conversion_rate;
1336 p_rcv_transaction_rec.currency_conversion_date := l_currency_conversion_date;
1337 END IF;
1338
1339 IF (l_debug = 1) THEN
1340 print_debug('populate_default_values 120: ', 4);
1341 END IF;
1342
1343 IF p_rcv_transaction_rec.receipt_source_code = 'VENDOR' THEN
1344 l_linelocationid := p_rcv_transaction_rec.po_line_location_id;
1345
1346 SELECT NVL(match_option, 'P')
1347 INTO l_matchflag
1348 FROM po_line_locations_all
1349 WHERE line_location_id = l_linelocationid;
1350
1351 l_matchflag := SUBSTR(l_matchflag, 1, 1);
1352 l_rcvtrxid := p_rcv_transaction_rec.rcv_transaction_id;
1353
1354 IF l_matchflag = 'R' THEN
1355 -- need to pick up rate from rcv_transactions
1356 SELECT currency_conversion_date
1357 , currency_conversion_rate
1358 INTO l_ratedate
1359 , l_rate
1360 FROM rcv_transactions
1361 WHERE transaction_id = l_rcvtrxid;
1362
1363 p_rcv_transaction_rec.currency_conversion_rate := l_rate;
1364 p_rcv_transaction_rec.currency_conversion_date := l_ratedate;
1365 END IF;
1366
1367 l_rate := p_rcv_transaction_rec.currency_conversion_rate;
1368
1369 IF (inv_rcv_common_apis.g_po_startup_value.display_inverse_rate = 'Y') THEN
1370 l_ratedisplay := 1 / l_rate;
1371 ELSE
1372 l_ratedisplay := l_rate;
1373 END IF;
1374 END IF;
1375
1376 -- This part of the code is from the on-update trigger of
1377 -- rcv_transaction block in rcvtxert form.
1378
1379 -- Chk transaction getting saved are not under EXPRESS mode and
1380 -- that you havent entered inspection data for this line. When
1381 -- you enter inspection data the line is auto selected but you want
1382 -- to skip this line in that case.
1383 IF (l_debug = 1) THEN
1384 print_debug('populate_default_values 130: ', 4);
1385 END IF;
1386
1387 IF (NVL(inv_rcv_common_apis.g_rcv_global_var.express_mode, 'NO') <> 'YES'
1388 AND p_rcv_transaction_rec.inspection_detail <> 'Y') THEN
1389 --dbms_output.put_line('before insert');
1390
1391 -- Before this must populate the passed in parameters in the
1392 -- current row which include, revision, sub, locator_id
1393 p_rcv_transaction_rec.item_revision := p_revision;
1394 p_rcv_transaction_rec.subinventory_dsp := p_subinventory_code;
1395 p_rcv_transaction_rec.locator_id := p_locator_id;
1396
1397 IF (l_debug = 1) THEN
1398 print_debug('populate_default_values 140: ', 4);
1399 END IF;
1400
1401 /* Bug 8518384 : Because of below code, destination_type_code was getting
1402 overridden to INVENTORY for EXPENSE case also, because of which
1403 Standard delivery against Internal Req (with destination as EXPENSE)
1404 was populating destination_type_code as 'INVENTORY' instead of 'EXPENSE'.
1405 Not sure why this code has been added.
1406 To fix bug 8518384 , we are firing this code only when
1407 p_rcv_transaction_rec.destination_type_code is null */
1408
1409 --IF WMS and PO patch levels are J or higher, from teh putaway UI, we will create
1410 --a TRANSFER transaction if the subinventory type is RECEIVING. If the Deliver API is
1411 --called, then the destination sub should be a storage subinventory. So we should set
1412 --the destination type code to Inventory
1413 IF p_rcv_transaction_rec.destination_type_code IS NULL THEN
1414 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
1415 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
1416 p_rcv_transaction_rec.destination_type_code := 'INVENTORY';
1417 END IF;
1418 END IF;
1419
1420 -- bug 3198278
1421 -- If the destination_type_code is set to receiving for what ever
1422 -- reasons, then we need to validate the subinventory_type.
1423 -- If the subinventory_type is storage then we need to throw an
1424 -- exception since one cannot do a transfer in a storage sub.
1425 -- If the destination_type_code is receiving then the
1426 -- transaction_type is defaulted to be transfer in insert_interface_code
1427 IF p_rcv_transaction_rec.destination_type_code = 'RECEIVING'
1428 AND ((inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j)
1429 AND (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
1430 l_subinventory_type := wms_putaway_utils.get_subinventory_type
1431 (p_subinventory_code => p_subinventory_code
1432 , p_organization_id => p_organization_id);
1433 IF Nvl(l_subinventory_type,1) = 1 THEN
1434 IF (l_debug = 1) THEN
1435 print_debug('populate_default_values 141 - trying to do transfer IN storage sub_type : ', 4);
1436 END IF;
1437 fnd_message.set_name('INV', 'INV_INVALID_SUB_TXN_COMBO');
1438 fnd_msg_pub.ADD;
1439 RAISE fnd_api.g_exc_error;
1440 END IF;
1441 END IF;
1442
1443 -- Call procedure INSERT_INTERFACE_CODE to populate RCV_TRANSACTION_INTERFACE
1444 -- table with updated transactions
1445 l_interface_transaction_id := insert_interface_code(
1446 p_rcv_transaction_rec
1447 , p_organization_id);
1448
1449 --Store the interface_transaction_id in a global variable which would later
1450 --be used for splitting lots and serials
1451 g_interface_transaction_id := l_interface_transaction_id;
1452
1453 -- Create the necessary rcv_lots_interface and rcv_serials_interface
1454 -- rows based on the rows created in the mtl_transactions_lots_temp
1455 -- and the mtl_serial_numbers_temp table.
1456 -- There is an issue here between v10 and 10sc.
1457 -- In 10 we inserted rows into the rcv_lots_interface
1458 -- and rcv_serials_interface tables through the
1459 -- lot and serial forms. In 10sc we are using the Inventory lot and
1460 -- serial forms which insert into the mtl_transaction_lots_temp and
1461 -- the mtl_serial_numbers_temp table. The issue here is that if the
1462 -- transaction_interface row was created by a 10 client then we want
1463 -- to continue to insert into the mtl_ tables. If this trx was
1464 -- generated through a 10sc client then we need to insert into the
1465 -- 10sc tables. We are adding a flag use_mtl_lot_serial that is null
1466 -- allowable to tell us whether to use the rcv_ tables or the mtl_
1467 -- tables)
1468
1469 /* FP-J Lot/Serial Support Enhancement
1470 * If INV J and PO J are installed then lot and serial splits are done based
1471 * on the interface tables (MTLI/MSNI).
1472 * If either of these are not installed, use the existing logic to break
1473 * lots and serials based on temp records MTLI/MSNT
1474 */
1475 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
1476 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
1477
1478 l_lot_serial_break_tbl(1).transaction_id := l_interface_transaction_id;
1479 l_lot_serial_break_tbl(1).primary_quantity := p_rcv_transaction_rec.primary_quantity;
1480
1481 IF (l_debug = 1) THEN
1482 print_debug('populate_default_values 150: ', 4);
1483 END IF;
1484 insert_lot_serial(
1485 l_lot_serial_break_tbl
1486 , p_transaction_temp_id
1487 , p_lot_control_code
1488 , p_serial_control_code
1489 , l_interface_transaction_id);
1490 ELSE
1491 IF (l_debug = 1) THEN
1492 print_debug('populate_default_values 150: INV and PO patch levels are J or higher. No splits to temp records', 4);
1493 END IF;
1494 END IF; --END IF check INV and PO patch levels
1495
1496 IF (l_debug = 1) THEN
1497 print_debug('populate_default_values 160: ', 4);
1498 END IF;
1499 ELSIF(p_rcv_transaction_rec.inspection_detail = 'Y') THEN
1500 -- When we insert inspection transactions, we insert them with
1501 -- transaction_status_code = 'INSPECTION' and processing_status_code = 'INSPECTION'
1502 -- so they are not picked up as pending quantity to be processed. Since
1503 -- we insert the rows (like a post but not actually a post when you click
1504 -- on the OK button from the inspection buttton. If you were to immediately
1505 -- do another find and not save changes, (since this does not actually execute a
1506 -- database rollback) you would see this quantity as pending to be transacted if
1507 -- we inserted the rows as transaction_status_code = 'PENDING'
1508
1509 l_rcv_transaction_id := p_rcv_transaction_rec.rcv_transaction_id;
1510 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1511
1512 UPDATE rcv_transactions_interface
1513 SET transaction_status_code = 'PENDING'
1514 , processing_status_code = 'PENDING'
1515 WHERE parent_transaction_id = l_rcv_transaction_id
1516 AND GROUP_ID = l_group_id
1517 AND transaction_status_code = 'INSPECTION'
1518 AND processing_status_code = 'INSPECTION'
1519 AND transaction_type IN('ACCEPT', 'REJECT');
1520 END IF; -- transaction not related to EXPRESS mode
1521
1522 IF (l_debug = 1) THEN
1523 print_debug('exiting populate_default_values 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1524 END IF;
1525 END;
1526
1527 PROCEDURE create_osp_po_rcvtxn_intf_rec(
1528 p_organization_id IN NUMBER
1529 , p_po_header_id IN NUMBER
1530 , p_po_release_id IN NUMBER
1531 , p_po_line_id IN NUMBER
1532 , p_po_line_location_id IN NUMBER
1533 , p_po_distribution_id IN NUMBER
1534 , p_item_id IN NUMBER
1535 , p_vendor_id IN NUMBER
1536 , p_revision IN VARCHAR2
1537 , p_rcvtxn_qty IN NUMBER
1538 , p_rcvtxn_uom IN VARCHAR2
1539 , p_transaction_temp_id IN NUMBER
1540 , p_original_txn_temp_id IN NUMBER DEFAULT NULL
1541 , x_status OUT NOCOPY VARCHAR2
1542 , x_message OUT NOCOPY VARCHAR2
1543 , p_inspection_status_code IN VARCHAR2 DEFAULT NULL
1544 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
1545 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
1546 ) IS
1547 l_rcv_transaction_rec rcvtxn_transaction_rec_tp;
1548 l_rcv_rcvtxn_rec rcvtxn_enter_rec_cursor_rec;
1549 -- local record in which the values returned from the cursor are fetched.
1550
1551 l_rcvtxn_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type;
1552 -- local variable to store the output of the matching algorithm
1553
1554 l_msg_count NUMBER;
1555 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
1556 l_group_id NUMBER;
1557 l_transaction_type VARCHAR2(20) := 'STD_DELIVER';
1558 l_total_primary_qty NUMBER := 0;
1559 l_err_message VARCHAR2(100);
1560 l_temp_message VARCHAR2(100);
1561 l_msg_prod VARCHAR2(5);
1562 l_progress VARCHAR2(10);
1563
1564 CURSOR l_curs_rcvtxn_detail(v_po_distribution_id NUMBER
1565 , v_rcv_txn_id NUMBER) IS
1566 SELECT rsup.from_organization_id from_organization_id
1567 , rsup.to_organization_id to_organization_id
1568 , rt.source_document_code source_document_code
1569 , rsh.receipt_source_code receipt_source_code
1570 , rsup.rcv_transaction_id rcv_transaction_id
1571 , rt.transaction_date transaction_date
1572 , rt.transaction_type transaction_type
1573 , rt.primary_unit_of_measure primary_uom
1574 , rt.primary_quantity primary_quantity
1575 , rsup.po_header_id po_header_id
1576 , rt.po_revision_num po_revision_num
1577 , rsup.po_release_id po_release_id
1578 , rsh.vendor_id vendor_id
1579 , rt.vendor_site_id vendor_site_id
1580 , rsup.po_line_id po_line_id
1581 , rt.po_unit_price po_unit_price
1582 , rsl.category_id category_id
1583 , rsup.item_id item_id
1584 , msi.serial_number_control_code serial_number_control_code
1585 , msi.lot_control_code lot_control_code
1586 , rsup.item_revision item_revision
1587 , rsup.po_line_location_id po_line_location_id
1588 , rt.po_distribution_id po_distribution_id
1589 , rt.employee_id employee_id
1590 , rsl.comments comments
1591 , rsup.req_header_id req_header_id
1592 , rsup.req_line_id req_line_id
1593 , rsup.shipment_header_id shipment_header_id
1594 , rsup.shipment_line_id shipment_line_id
1595 , rsh.packing_slip packing_slip
1596 , rsl.government_context government_context
1597 , rsl.ussgl_transaction_code ussgl_transaction_code
1598 , rt.inspection_status_code inspection_status_code
1599 , rt.inspection_quality_code inspection_quality_code
1600 , rt.vendor_lot_num vendor_lot_num
1601 , pol.vendor_product_num vendor_item_number
1602 , rt.substitute_unordered_code substitute_unordered_code
1603 , rt.routing_header_id routing_id
1604 , rt.routing_step_id routing_step_id
1605 , rt.reason_id reason_id
1606 , rt.currency_code currency_code
1607 , pod.rate currency_conversion_rate
1608 , pod.rate_date currency_conversion_date
1609 , rt.currency_conversion_type currency_conversion_type
1610 , rsl.req_distribution_id req_distribution_id
1611 , rsup.destination_type_code destination_type_code_hold
1612 , pod.destination_type_code final_destination_type_code
1613 , rt.location_id location_id
1614 , pod.deliver_to_person_id final_deliver_to_person_id
1615 , pod.deliver_to_location_id final_deliver_to_location_id
1616 , rsl.to_subinventory subinventory
1617 , NVL(pol.un_number_id, msi.un_number_id) un_number_id
1618 , NVL(pol.hazard_class_id, msi.hazard_class_id) hazard_class_id
1619 , rsup.creation_date creation_date
1620 , rt.attribute_category attribute_category
1621 , rt.attribute1 attribute1
1622 , rt.attribute2 attribute2
1623 , rt.attribute3 attribute3
1624 , rt.attribute4 attribute4
1625 , rt.attribute5 attribute5
1626 , rt.attribute6 attribute6
1627 , rt.attribute7 attribute7
1628 , rt.attribute8 attribute8
1629 , rt.attribute9 attribute9
1630 , rt.attribute10 attribute10
1631 , rt.attribute11 attribute11
1632 , rt.attribute12 attribute12
1633 , rt.attribute13 attribute13
1634 , rt.attribute14 attribute14
1635 , rt.attribute15 attribute15
1636 , rt.qa_collection_id qa_collection_id
1637 , rsup.oe_order_header_id oe_order_header_id
1638 , rt.oe_order_line_id oe_order_line_id
1639 , rsh.customer_id customer_id
1640 , rsh.customer_site_id customer_site_id
1641 , pod.wip_entity_id wip_entity_id
1642 , pod.wip_operation_seq_num po_operation_seq_num
1643 , pod.wip_resource_seq_num po_resource_seq_num
1644 , pod.wip_repetitive_schedule_id wip_repetitive_schedule_id
1645 , pod.wip_line_id wip_line_id
1646 , pod.bom_resource_id bom_resource_id
1647 , pod.destination_subinventory final_subinventory
1648 , rt.SECONDARY_QUANTITY --OPM Convergence
1649 , rt.SECONDARY_UNIT_OF_MEASURE --OPM Convergence
1650 --The following columns are needed for matching in cases where no LPN is involved
1651 , rsup.to_subinventory from_subinventory_code
1652 , rsup.to_locator_id from_locator_id
1653 FROM rcv_transactions rt
1654 , rcv_supply rsup
1655 , rcv_shipment_headers rsh
1656 , rcv_shipment_lines rsl
1657 , mtl_system_items msi
1658 , po_lines pol
1659 , po_distributions pod
1660 WHERE rsup.rcv_transaction_id = v_rcv_txn_id
1661 AND rsup.to_organization_id = p_organization_id
1662 AND pod.line_location_id = rsup.po_line_location_id
1663 AND pod.po_distribution_id = v_po_distribution_id
1664 AND rsl.shipment_line_id = rsup.shipment_line_id
1665 AND rt.transaction_id = rsup.rcv_transaction_id
1666 AND rsh.shipment_header_id = rsup.shipment_header_id
1667 AND pol.po_line_id = rsup.po_line_id
1668 AND msi.organization_id = rsup.to_organization_id
1669 AND msi.inventory_item_id = rsup.item_id
1670 ORDER BY rt.transaction_date DESC;
1671
1672 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1673 BEGIN
1674 x_status := fnd_api.g_ret_sts_success;
1675
1676 IF (l_debug = 1) THEN
1677 print_debug('Entering create_osp_po_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1678 END IF;
1679
1680 l_progress := '10';
1681
1682 BEGIN
1683 inv_rcv_common_apis.init_startup_values(p_organization_id);
1684 EXCEPTION
1685 WHEN NO_DATA_FOUND THEN
1686 fnd_message.set_name('INV', 'INV_RCV_PARAM');
1687 fnd_msg_pub.ADD;
1688 RAISE;
1689 END;
1690
1691 l_progress := '20';
1692
1693 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
1694 SELECT rcv_interface_groups_s.NEXTVAL
1695 INTO l_group_id
1696 FROM DUAL;
1697
1698 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
1699 ELSE
1700 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1701 END IF;
1702
1703 l_progress := '30';
1704 -- call matching algorithm
1705 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).GROUP_ID := l_group_id;
1706 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).transaction_type := l_transaction_type;
1707 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).quantity := p_rcvtxn_qty;
1708 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).unit_of_measure := p_rcvtxn_uom;
1709 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id := p_item_id;
1710 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).revision := p_revision; -- 2252193
1711 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).to_organization_id := p_organization_id;
1712 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_header_id := p_po_header_id;
1713 -- line id and line location id will be passed only from the putaway api.
1714 -- line id however, can also be passed from the UI.
1715 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_line_id := p_po_line_id;
1716 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_release_id := p_po_release_id;
1717 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_line_location_id := p_po_line_location_id;
1718 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_distribution_id := p_po_distribution_id;
1719 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).expected_receipt_date := SYSDATE;
1720 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).tax_amount := 0;
1721 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status := 'S';
1722 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).inspection_status_code := p_inspection_status_code;
1723
1724 BEGIN
1725 SELECT primary_unit_of_measure
1726 INTO g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure
1727 FROM mtl_system_items
1728 WHERE mtl_system_items.inventory_item_id = p_item_id
1729 AND mtl_system_items.organization_id = p_organization_id;
1730 EXCEPTION
1731 WHEN NO_DATA_FOUND THEN
1732 NULL;
1733 END;
1734
1735 l_progress := '40';
1736 inv_rcv_txn_interface.matching_logic(
1737 x_return_status => x_status
1738 , x_msg_count => l_msg_count
1739 , x_msg_data => x_message
1740 , x_cascaded_table => g_rcvtxn_match_table_gross
1741 , n => g_rcvtxn_detail_index
1742 , temp_cascaded_table => l_rcvtxn_match_table_detail
1743 , p_receipt_num => NULL
1744 , p_shipment_header_id => NULL
1745 , p_lpn_id => NULL
1746 );
1747
1748 -- x_status is not successful if there is any execution error in matching.
1749 IF x_status <> fnd_api.g_ret_sts_success THEN
1750 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1751 fnd_msg_pub.ADD;
1752
1753 IF (l_debug = 1) THEN
1754 print_debug('Exiting create_osp_po_rcvtxn_intf_rec 20:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1755 END IF;
1756
1757 RETURN;
1758 END IF;
1759
1760 IF g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status = 'E' THEN
1761 x_status := fnd_api.g_ret_sts_error;
1762 l_err_message := g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_message;
1763 fnd_message.set_name('INV', l_err_message);
1764 fnd_msg_pub.ADD;
1765
1766 IF (l_debug = 1) THEN
1767 print_debug('exiting create_osp_po_rcvtxn_intf_rec 30:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1768 END IF;
1769
1770 RETURN;
1771 END IF;
1772
1773 l_err_message := '@@@';
1774
1775 FOR i IN g_rcvtxn_detail_index ..(g_rcvtxn_detail_index + l_rcvtxn_match_table_detail.COUNT - 1) LOOP
1776 IF l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_status = 'W' THEN
1777 x_status := 'W';
1778 l_temp_message := l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_message;
1779
1780 IF l_temp_message IS NULL THEN
1781 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
1782 l_msg_prod := 'INV';
1783 EXIT;
1784 END IF;
1785
1786 IF l_err_message = '@@@' THEN
1787 l_err_message := l_temp_message;
1788 l_msg_prod := 'INV';
1789 ELSIF l_temp_message <> l_err_message THEN
1790 l_msg_prod := 'INV';
1791 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
1792 EXIT;
1793 END IF;
1794 END IF;
1795 END LOOP;
1796
1797 IF l_err_message <> '@@@' THEN
1798 fnd_message.set_name(l_msg_prod, l_err_message);
1799 fnd_msg_pub.ADD;
1800
1801 IF (l_debug = 1) THEN
1802 print_debug('adding tolerance message create_osp_po_rcvtxn_intf_rec 40:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1803 END IF;
1804 END IF;
1805
1806 l_progress := '50';
1807 -- based on return from matching algorithm,
1808 -- determine which line in rcv_transaction block to be inserted into RTI
1809
1810 l_progress := '60';
1811
1812 IF (l_debug = 1) THEN
1813 print_debug('create_osp_po_rcvtxn_intf_rec no recs matched by matching 50:' || l_rcvtxn_match_table_detail.COUNT, 4);
1814 END IF;
1815
1816 -- loop through results returned by matching algorithm
1817 FOR match_result_count IN 1 .. l_rcvtxn_match_table_detail.COUNT LOOP
1818 IF (l_debug = 1) THEN
1819 print_debug('create_osp_po_rcvtxn_intf_rec found a match 60', 4);
1820 print_debug('Matching returned values 60.1 - distribution_id:' || l_rcvtxn_match_table_detail(match_result_count).po_distribution_id, 4);
1821 print_debug('Matching returned values 60.1 - rcv_transaction_id:' || l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id, 4);
1822 print_debug('Matching returned values 60.1 - transaction_quantity:' || l_rcvtxn_match_table_detail(match_result_count).quantity, 4);
1823 print_debug('Matching returned values 60.1 - transaction_uom:' || l_rcvtxn_match_table_detail(match_result_count).unit_of_measure, 4);
1824 print_debug('Matching returned values 60.1 - primary_quantity:' || l_rcvtxn_match_table_detail(match_result_count).primary_quantity, 4);
1825 print_debug('Matching returned values 60.1 - primary_uom:' || l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure, 4);
1826 END IF;
1827
1828 OPEN l_curs_rcvtxn_detail(
1829 l_rcvtxn_match_table_detail(match_result_count).po_distribution_id
1830 , l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id);
1831 FETCH l_curs_rcvtxn_detail INTO l_rcv_rcvtxn_rec;
1832 CLOSE l_curs_rcvtxn_detail;
1833 l_rcv_transaction_rec.po_distribution_id := l_rcvtxn_match_table_detail(match_result_count).po_distribution_id;
1834 l_rcv_transaction_rec.transaction_quantity := l_rcvtxn_match_table_detail(match_result_count).quantity;
1835 l_rcv_transaction_rec.transaction_uom := l_rcvtxn_match_table_detail(match_result_count).unit_of_measure;
1836 l_rcv_transaction_rec.primary_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
1837 l_rcv_transaction_rec.primary_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
1838 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
1839 l_progress := '70';
1840 populate_default_values(
1841 p_rcv_transaction_rec => l_rcv_transaction_rec
1842 , p_rcv_rcvtxn_rec => l_rcv_rcvtxn_rec
1843 , p_organization_id => p_organization_id
1844 , p_item_id => p_item_id
1845 , p_revision => p_revision
1846 , p_subinventory_code => NULL
1847 , p_locator_id => NULL
1848 , p_transaction_temp_id => p_transaction_temp_id
1849 , p_lot_control_code => NULL
1850 , p_serial_control_code => NULL
1851 , p_original_txn_temp_id => p_original_txn_temp_id
1852 );
1853 l_progress := '80';
1854 END LOOP;
1855
1856 IF l_curs_rcvtxn_detail%ISOPEN THEN
1857 CLOSE l_curs_rcvtxn_detail;
1858 END IF;
1859
1860 l_progress := '90';
1861 inv_rcv_common_apis.do_check(
1862 p_organization_id => p_organization_id
1863 , p_inventory_item_id => p_item_id
1864 , p_transaction_type_id => 18
1865 , p_primary_quantity => l_total_primary_qty
1866 , x_return_status => l_return_status
1867 , x_msg_count => l_msg_count
1868 , x_msg_data => x_message
1869 );
1870
1871 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1872 x_status := l_return_status;
1873 END IF;
1874
1875 l_progress := '100';
1876
1877 IF (l_debug = 1) THEN
1878 print_debug('Exiting create_osp_po_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1879 END IF;
1880 EXCEPTION
1881 WHEN OTHERS THEN
1882 x_status := fnd_api.g_ret_sts_unexp_error;
1883
1884 IF l_curs_rcvtxn_detail%ISOPEN THEN
1885 CLOSE l_curs_rcvtxn_detail;
1886 END IF;
1887
1888 IF SQLCODE IS NOT NULL THEN
1889 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_osp_po_rcvtxn_intf_rec', l_progress, SQLCODE);
1890 END IF;
1891
1892 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
1893 END create_osp_po_rcvtxn_intf_rec;
1894
1895 PROCEDURE create_po_rcvtxn_intf_rec(
1896 p_organization_id IN NUMBER
1897 , p_po_header_id IN NUMBER
1898 , p_po_release_id IN NUMBER
1899 , p_po_line_id IN NUMBER
1900 , p_po_line_location_id IN NUMBER
1901 , p_receipt_num IN VARCHAR2
1902 , p_item_id IN NUMBER
1903 , p_vendor_id IN NUMBER
1904 , p_revision IN VARCHAR2
1905 , p_subinventory_code IN VARCHAR2
1906 , p_locator_id IN NUMBER
1907 , p_rcvtxn_qty IN NUMBER
1908 , p_rcvtxn_uom IN VARCHAR2
1909 , p_transaction_temp_id IN NUMBER
1910 , p_lot_control_code IN NUMBER
1911 , p_serial_control_code IN NUMBER
1912 , p_original_txn_temp_id IN NUMBER DEFAULT NULL
1913 , x_status OUT NOCOPY VARCHAR2
1914 , x_message OUT NOCOPY VARCHAR2
1915 , p_inspection_status_code IN VARCHAR2 DEFAULT NULL
1916 , p_lpn_id IN NUMBER DEFAULT NULL
1917 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
1918 , p_lot_number IN VARCHAR2 DEFAULT NULL
1919 , p_parent_txn_id IN NUMBER DEFAULT NULL
1920 , p_deliver_to_location_id IN NUMBER DEFAULT NULL
1921 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
1922 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
1923 , p_rcvtxn_uom_code IN VARCHAR2 DEFAULT NULL
1924 ) IS
1925 l_rcv_transaction_rec rcvtxn_transaction_rec_tp;
1926 l_rcv_rcvtxn_rec rcvtxn_enter_rec_cursor_rec;
1927 -- local record in which the values returned from the cursor are fetched.
1928
1929 l_rcvtxn_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type;
1930 -- local variable to store the output of the matching algorithm
1931
1932 l_msg_count NUMBER;
1933 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
1934 l_group_id NUMBER;
1935 l_transaction_type VARCHAR2(20) := 'STD_DELIVER';
1936 l_total_primary_qty NUMBER := 0;
1937 l_err_message VARCHAR2(100);
1938 l_temp_message VARCHAR2(100);
1939 l_msg_prod VARCHAR2(5);
1940 l_progress VARCHAR2(10);
1941 l_orig_mol_id NUMBER := NULL;
1942 l_new_txn_temp_id NUMBER;
1943 l_mo_splt_tb inv_rcv_integration_apis.mo_in_tb_tp;
1944
1945 CURSOR l_curs_rcvtxn_detail(v_po_distribution_id NUMBER
1946 , v_rcv_txn_id NUMBER) IS
1947 SELECT rsup.from_organization_id from_organization_id
1948 , rsup.to_organization_id to_organization_id
1949 , rt.source_document_code source_document_code
1950 , rsh.receipt_source_code receipt_source_code
1951 , rsup.rcv_transaction_id rcv_transaction_id
1952 , rt.transaction_date transaction_date
1953 , rt.transaction_type transaction_type
1954 , rt.primary_unit_of_measure primary_uom
1955 , rt.primary_quantity primary_quantity
1956 , rsup.po_header_id po_header_id
1957 , rt.po_revision_num po_revision_num
1958 , rsup.po_release_id po_release_id
1959 , rsh.vendor_id vendor_id
1960 , rt.vendor_site_id vendor_site_id
1961 , rsup.po_line_id po_line_id
1962 , rt.po_unit_price po_unit_price
1963 , rsl.category_id category_id
1964 , rsup.item_id item_id
1965 , msi.serial_number_control_code serial_number_control_code
1966 , msi.lot_control_code lot_control_code
1967 , rsup.item_revision item_revision
1968 , rsup.po_line_location_id po_line_location_id
1969 , rt.po_distribution_id po_distribution_id
1970 , rt.employee_id employee_id
1971 , rsl.comments comments
1972 , rsup.req_header_id req_header_id
1973 , rsup.req_line_id req_line_id
1974 , rsup.shipment_header_id shipment_header_id
1975 , rsup.shipment_line_id shipment_line_id
1976 , rsh.packing_slip packing_slip
1977 , rsl.government_context government_context
1978 , rsl.ussgl_transaction_code ussgl_transaction_code
1979 , rt.inspection_status_code inspection_status_code
1980 , rt.inspection_quality_code inspection_quality_code
1981 , rt.vendor_lot_num vendor_lot_num
1982 , pol.vendor_product_num vendor_item_number
1983 , rt.substitute_unordered_code substitute_unordered_code
1984 , rt.routing_header_id routing_id
1985 , rt.routing_step_id routing_step_id
1986 , rt.reason_id reason_id
1987 , rt.currency_code currency_code
1988 , pod.rate currency_conversion_rate
1989 , pod.rate_date currency_conversion_date
1990 , rt.currency_conversion_type currency_conversion_type
1991 , rsl.req_distribution_id req_distribution_id
1992 , rsup.destination_type_code destination_type_code_hold
1993 , pod.destination_type_code final_destination_type_code
1994 , rt.location_id location_id
1995 , pod.deliver_to_person_id final_deliver_to_person_id
1996 , pod.deliver_to_location_id final_deliver_to_location_id
1997 , rsl.to_subinventory subinventory
1998 , NVL(pol.un_number_id, msi.un_number_id) un_number_id
1999 , NVL(pol.hazard_class_id, msi.hazard_class_id) hazard_class_id
2000 , rsup.creation_date creation_date
2001 , rt.attribute_category attribute_category
2002 , rt.attribute1 attribute1
2003 , rt.attribute2 attribute2
2004 , rt.attribute3 attribute3
2005 , rt.attribute4 attribute4
2006 , rt.attribute5 attribute5
2007 , rt.attribute6 attribute6
2008 , rt.attribute7 attribute7
2009 , rt.attribute8 attribute8
2010 , rt.attribute9 attribute9
2011 , rt.attribute10 attribute10
2012 , rt.attribute11 attribute11
2013 , rt.attribute12 attribute12
2014 , rt.attribute13 attribute13
2015 , rt.attribute14 attribute14
2016 , rt.attribute15 attribute15
2017 , rt.qa_collection_id qa_collection_id
2018 , rsup.oe_order_header_id oe_order_header_id
2019 , rt.oe_order_line_id oe_order_line_id
2020 , rsh.customer_id customer_id
2021 , rsh.customer_site_id customer_site_id
2022 , pod.wip_entity_id wip_entity_id
2023 , pod.wip_operation_seq_num po_operation_seq_num
2024 , pod.wip_resource_seq_num po_resource_seq_num
2025 , pod.wip_repetitive_schedule_id wip_repetitive_schedule_id
2026 , pod.wip_line_id wip_line_id
2027 , pod.bom_resource_id bom_resource_id
2028 , pod.destination_subinventory final_subinventory
2029 , rt.SECONDARY_QUANTITY --OPM Convergence
2030 , rt.SECONDARY_UNIT_OF_MEASURE --OPM Convergence
2031 --The following columns are needed for matching in cases where no LPN is involved
2032 , rsup.to_subinventory from_subinventory_code
2033 , rsup.to_locator_id from_locator_id
2034 FROM rcv_transactions rt
2035 , rcv_supply rsup
2036 , rcv_shipment_headers rsh
2037 , rcv_shipment_lines rsl
2038 , mtl_system_items msi
2039 , po_lines pol
2040 , po_distributions pod
2041 WHERE rsup.rcv_transaction_id = v_rcv_txn_id
2042 AND rsup.to_organization_id = p_organization_id
2043 AND pod.line_location_id = rsup.po_line_location_id
2044 AND pod.po_distribution_id = v_po_distribution_id
2045 AND rsl.shipment_line_id = rsup.shipment_line_id
2046 AND rt.transaction_id = rsup.rcv_transaction_id
2047 AND rsh.shipment_header_id = rsup.shipment_header_id
2048 AND pol.po_line_id = rsup.po_line_id
2049 AND msi.organization_id = rsup.to_organization_id
2050 AND msi.inventory_item_id = rsup.item_id
2051 ORDER BY rt.transaction_date DESC;
2052
2053 --BUG 4500676: To be used for expense items
2054 CURSOR l_curs_rcvtxn_detail_exp (v_po_distribution_id NUMBER , v_rcv_txn_id NUMBER) IS
2055 SELECT rsup.from_organization_id from_organization_id
2056 , rsup.to_organization_id to_organization_id
2057 , rt.source_document_code source_document_code
2058 , rsh.receipt_source_code receipt_source_code
2059 , rsup.rcv_transaction_id rcv_transaction_id
2060 , rt.transaction_date transaction_date
2061 , rt.transaction_type transaction_type
2062 , rt.primary_unit_of_measure primary_uom
2063 , rt.primary_quantity primary_quantity
2064 , rsup.po_header_id po_header_id
2065 , rt.po_revision_num po_revision_num
2066 , rsup.po_release_id po_release_id
2067 , rsh.vendor_id vendor_id
2068 , rt.vendor_site_id vendor_site_id
2069 , rsup.po_line_id po_line_id
2070 , rt.po_unit_price po_unit_price
2071 , rsl.category_id category_id
2072 , rsup.item_id item_id
2073 , null
2074 , null
2075 , rsup.item_revision item_revision
2076 , rsup.po_line_location_id po_line_location_id
2077 , rt.po_distribution_id po_distribution_id
2078 , rt.employee_id employee_id
2079 , rsl.comments comments
2080 , rsup.req_header_id req_header_id
2081 , rsup.req_line_id req_line_id
2082 , rsup.shipment_header_id shipment_header_id
2083 , rsup.shipment_line_id shipment_line_id
2084 , rsh.packing_slip packing_slip
2085 , rsl.government_context government_context
2086 , rsl.ussgl_transaction_code ussgl_transaction_code
2087 , rt.inspection_status_code inspection_status_code
2088 , rt.inspection_quality_code inspection_quality_code
2089 , rt.vendor_lot_num vendor_lot_num
2090 , pol.vendor_product_num vendor_item_number
2091 , rt.substitute_unordered_code substitute_unordered_code
2092 , rt.routing_header_id routing_id
2093 , rt.routing_step_id routing_step_id
2094 , rt.reason_id reason_id
2095 , rt.currency_code currency_code
2096 , pod.rate currency_conversion_rate
2097 , pod.rate_date currency_conversion_date
2098 , rt.currency_conversion_type currency_conversion_type
2099 , rsl.req_distribution_id req_distribution_id
2100 , rsup.destination_type_code destination_type_code_hold
2101 , pod.destination_type_code final_destination_type_code
2102 , rt.location_id location_id
2103 , pod.deliver_to_person_id final_deliver_to_person_id
2104 , pod.deliver_to_location_id final_deliver_to_location_id
2105 , rsl.to_subinventory subinventory
2106 , un_number_id un_number_id
2107 , hazard_class_id hazard_class_id
2108 , rsup.creation_date creation_date
2109 , rt.attribute_category attribute_category
2110 , rt.attribute1 attribute1
2111 , rt.attribute2 attribute2
2112 , rt.attribute3 attribute3
2113 , rt.attribute4 attribute4
2114 , rt.attribute5 attribute5
2115 , rt.attribute6 attribute6
2116 , rt.attribute7 attribute7
2117 , rt.attribute8 attribute8
2118 , rt.attribute9 attribute9
2119 , rt.attribute10 attribute10
2120 , rt.attribute11 attribute11
2121 , rt.attribute12 attribute12
2122 , rt.attribute13 attribute13
2123 , rt.attribute14 attribute14
2124 , rt.attribute15 attribute15
2125 , rt.qa_collection_id qa_collection_id
2126 , rsup.oe_order_header_id oe_order_header_id
2127 , rt.oe_order_line_id oe_order_line_id
2128 , rsh.customer_id customer_id
2129 , rsh.customer_site_id customer_site_id
2130 , pod.wip_entity_id wip_entity_id
2131 , pod.wip_operation_seq_num po_operation_seq_num
2132 , pod.wip_resource_seq_num po_resource_seq_num
2133 , pod.wip_repetitive_schedule_id wip_repetitive_schedule_id
2134 , pod.wip_line_id wip_line_id
2135 , pod.bom_resource_id bom_resource_id
2136 , pod.destination_subinventory final_subinventory
2137 , rt.SECONDARY_QUANTITY --OPM Convergence
2138 , rt.SECONDARY_UNIT_OF_MEASURE --OPM Convergence
2139 --The following columns are needed for matching in cases where no LPN is involved
2140 , rsup.to_subinventory from_subinventory_code
2141 , rsup.to_locator_id from_locator_id
2142 FROM rcv_transactions rt
2143 , rcv_supply rsup
2144 , rcv_shipment_headers rsh
2145 , rcv_shipment_lines rsl
2146 , po_lines pol
2147 , po_distributions pod
2148 WHERE rsup.rcv_transaction_id = v_rcv_txn_id
2149 AND rsup.to_organization_id = p_organization_id
2150 AND pod.line_location_id = rsup.po_line_location_id
2151 AND pod.po_distribution_id = v_po_distribution_id
2152 AND rsl.shipment_line_id = rsup.shipment_line_id
2153 AND rt.transaction_id = rsup.rcv_transaction_id
2154 AND rsh.shipment_header_id = rsup.shipment_header_id
2155 AND pol.po_line_id = rsup.po_line_id
2156 ORDER BY rt.transaction_date DESC;
2157 --END BUG 4500676
2158
2159
2160
2161 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2162 --table to store all RTId, quantity and original_rti_id for lot/serial splits
2163 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
2164 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
2165 l_prim_uom_code VARCHAR2(3);
2166 l_rcvtxn_uom_code VARCHAR2(3);
2167 BEGIN
2168 x_status := fnd_api.g_ret_sts_success;
2169
2170 IF (l_debug = 1) THEN
2171 print_debug('Entering create_po_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2172 print_debug(' p_item_id => '||p_item_id,4);
2173 END IF;
2174
2175 l_progress := '10';
2176
2177 --dbms_output.put_line('In create po');
2178 BEGIN
2179 inv_rcv_common_apis.init_startup_values(p_organization_id);
2180 EXCEPTION
2181 WHEN NO_DATA_FOUND THEN
2182 fnd_message.set_name('INV', 'INV_RCV_PARAM');
2183 fnd_msg_pub.ADD;
2184 RAISE;
2185 END;
2186
2187 l_progress := '20';
2188
2189 -- default l_group_id ?? clear group id after done
2190 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
2191 SELECT rcv_interface_groups_s.NEXTVAL
2192 INTO l_group_id
2193 FROM DUAL;
2194
2195 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
2196 ELSE
2197 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
2198 END IF;
2199
2200 l_progress := '30';
2201 -- call matching algorithm
2202 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).GROUP_ID := l_group_id;
2203 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).transaction_type := l_transaction_type;
2204 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).quantity := p_rcvtxn_qty;
2205 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).unit_of_measure := p_rcvtxn_uom;
2206 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id := p_item_id;
2207 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).revision := p_revision; -- 2252193
2208 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).to_organization_id := p_organization_id;
2209 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_header_id := p_po_header_id;
2210 -- line id and line location id will be passed only from the putaway api.
2211 -- line id however, can also be passed from the UI.
2212 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_line_id := p_po_line_id;
2213 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_release_id := p_po_release_id;
2214 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_line_location_id := p_po_line_location_id;
2215 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).p_lpn_id := p_lpn_id;
2216 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).expected_receipt_date := SYSDATE; --?
2217 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).tax_amount := 0; -- ?
2218 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status := 'S'; -- ?
2219 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).inspection_status_code := p_inspection_status_code;
2220
2221 /* FP-J Lot/Serial Support Enhancement
2222 * If INV and PO J are installed, then the lots for the parent transaction will
2223 * be stored in rcv_lots_supply. We must match the lot number passed with that
2224 * of the parent transaction and also the parent_txn_id
2225 */
2226 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2227 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2228 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := p_lot_number;
2229 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := p_parent_txn_id;
2230 ELSE
2231 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := NULL;
2232 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := NULL;
2233 END IF;
2234
2235 BEGIN
2236 SELECT primary_unit_of_measure
2237 INTO g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure
2238 FROM mtl_system_items
2239 WHERE mtl_system_items.inventory_item_id = p_item_id
2240 AND mtl_system_items.organization_id = p_organization_id;
2241 EXCEPTION
2242 WHEN NO_DATA_FOUND THEN
2243 --Bug5574012:In case of one time items,the UOM will be fetched from the
2244 --PO data.Setting the g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure
2245 --to null.
2246 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure := NULL;
2247 --NULL;
2248 END;
2249
2250 --BUG 4364407
2251 IF g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id IS NULL AND
2252 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_desc IS NULL THEN
2253 BEGIN
2254 SELECT item_description
2255 INTO g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_desc
2256 FROM po_lines_all pla
2257 WHERE pla.po_header_id =g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_header_id
2258 AND pla.po_line_id =g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).po_line_id;
2259 EXCEPTION
2260 WHEN NO_DATA_FOUND THEN
2261 NULL;
2262 END;
2263
2264 IF (l_debug = 1) THEN
2265 print_debug('g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_desc' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_desc, 1);
2266 END IF;
2267 END IF;
2268 --END BUG 4500676
2269
2270 l_progress := '40';
2271 inv_rcv_txn_interface.matching_logic(
2272 x_return_status => x_status
2273 , x_msg_count => l_msg_count
2274 , x_msg_data => x_message
2275 , x_cascaded_table => g_rcvtxn_match_table_gross
2276 , n => g_rcvtxn_detail_index
2277 , temp_cascaded_table => l_rcvtxn_match_table_detail
2278 , p_receipt_num => p_receipt_num
2279 , p_shipment_header_id => NULL
2280 , p_lpn_id => NULL
2281 );
2282
2283 -- x_status is not successful if there is any execution error in matching.
2284 IF x_status <> fnd_api.g_ret_sts_success THEN
2285 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2286 fnd_msg_pub.ADD;
2287
2288 IF (l_debug = 1) THEN
2289 print_debug('Exiting create_po_rcvtxn_intf_rec 20:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2290 END IF;
2291
2292 RETURN;
2293 END IF;
2294
2295 IF g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status = 'E' THEN
2296 x_status := fnd_api.g_ret_sts_error;
2297 l_err_message := g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_message;
2298 fnd_message.set_name('INV', l_err_message);
2299 fnd_msg_pub.ADD;
2300
2301 IF (l_debug = 1) THEN
2302 print_debug('exiting create_po_rcvtxn_intf_rec 30:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2303 END IF;
2304
2305 RETURN;
2306 END IF;
2307
2308 l_err_message := '@@@';
2309
2310 FOR i IN g_rcvtxn_detail_index ..(g_rcvtxn_detail_index + l_rcvtxn_match_table_detail.COUNT - 1) LOOP
2311 IF l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_status = 'W' THEN
2312 x_status := 'W';
2313 l_temp_message := l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_message;
2314
2315 IF l_temp_message IS NULL THEN
2316 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2317 l_msg_prod := 'INV';
2318 EXIT;
2319 END IF;
2320
2321 IF l_err_message = '@@@' THEN
2322 l_err_message := l_temp_message;
2323 l_msg_prod := 'INV';
2324 ELSIF l_temp_message <> l_err_message THEN
2325 l_msg_prod := 'INV';
2326 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2327 EXIT;
2328 END IF;
2329 END IF;
2330 END LOOP;
2331
2332 IF l_err_message <> '@@@' THEN
2333 fnd_message.set_name(l_msg_prod, l_err_message);
2334 fnd_msg_pub.ADD;
2335
2336 IF (l_debug = 1) THEN
2337 print_debug('adding tolerance message create_po_rcvtxn_intf_rec 40:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2338 END IF;
2339 END IF;
2340
2341 l_progress := '50';
2342 -- based on return from matching algorithm,
2343 -- determine which line in rcv_transaction block to be inserted into RTI
2344
2345 l_progress := '60';
2346
2347 IF (l_debug = 1) THEN
2348 print_debug('create_po_rcvtxn_intf_rec no recs matched by matching 50:' || l_rcvtxn_match_table_detail.COUNT, 4);
2349 END IF;
2350
2351 -- loop through results returned by matching algorithm
2352 FOR match_result_count IN 1 .. l_rcvtxn_match_table_detail.COUNT LOOP
2353 IF (l_debug = 1) THEN
2354 print_debug('create_po_rcvtxn_intf_rec found a match 60', 4);
2355 print_debug(
2356 'Matching returned values 60.1 - distribution_id:' || l_rcvtxn_match_table_detail(match_result_count).po_distribution_id, 4);
2357 print_debug('Matching returned values 60.1 - rcv_transaction_id:' || l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id, 4);
2358 print_debug('Matching returned values 60.1 - transaction_quantity:' || l_rcvtxn_match_table_detail(match_result_count).quantity, 4);
2359 print_debug('Matching returned values 60.1 - transaction_uom:' || l_rcvtxn_match_table_detail(match_result_count).unit_of_measure, 4);
2360 print_debug('Matching returned values 60.1 - primary_quantity:' || l_rcvtxn_match_table_detail(match_result_count).primary_quantity, 4);
2361 print_debug('Matching returned values 60.1 - primary_uom:' || l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure, 4);
2362 END IF;
2363
2364 --BUG 4500676: Use the cursor for expense PO if normal cursor does not
2365 --get the values.
2366 IF (p_item_id IS NOT NULL) THEN
2367 OPEN l_curs_rcvtxn_detail(
2368 l_rcvtxn_match_table_detail(match_result_count).po_distribution_id
2369 , l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id
2370 );
2371 FETCH l_curs_rcvtxn_detail INTO l_rcv_rcvtxn_rec;
2372 CLOSE l_curs_rcvtxn_detail;
2373 ELSE
2374 OPEN l_curs_rcvtxn_detail_exp(
2375 l_rcvtxn_match_table_detail(match_result_count).po_distribution_id
2376 , l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id
2377 );
2378 FETCH l_curs_rcvtxn_detail_exp INTO l_rcv_rcvtxn_rec;
2379 CLOSE l_curs_rcvtxn_detail_exp;
2380 END IF;
2381 --END BUG 4500676
2382
2383 -- update following fields from matching algorithm return value
2384 -- Bug No 1823328 Changes.
2385 l_rcv_transaction_rec.po_distribution_id := l_rcvtxn_match_table_detail(match_result_count).po_distribution_id;
2386
2387 --R12: create RTI with uom entered by user
2388 IF (p_item_id IS NOT NULL) THEN
2389 l_prim_uom_code := inv_rcv_cache.get_primary_uom_code(p_organization_id,p_item_id);
2390
2391 IF (p_rcvtxn_uom_code IS NULL) THEN
2392 SELECT uom_code
2393 INTO l_rcvtxn_uom_code
2394 FROM mtl_item_uoms_view
2395 WHERE organization_id = p_organization_id
2396 AND inventory_item_id = p_item_id
2397 AND unit_of_measure = p_rcvtxn_uom
2398 AND ROWNUM < 2;
2399 ELSE
2400 l_rcvtxn_uom_code := p_rcvtxn_uom_code;
2401 END IF;
2402
2403 IF (l_rcvtxn_uom_code <> l_prim_uom_code) THEN
2404 l_rcv_transaction_rec.transaction_quantity := inv_rcv_cache.Convert_qty
2405 (p_inventory_item_id => p_item_id
2406 ,p_from_qty => l_rcvtxn_match_table_detail(match_result_count).primary_quantity
2407 ,p_from_uom_code => l_prim_uom_code
2408 ,p_to_uom_code => l_rcvtxn_uom_code);
2409 l_rcv_transaction_rec.transaction_uom := p_rcvtxn_uom;
2410 ELSE
2411 l_rcv_transaction_rec.transaction_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
2412 l_rcv_transaction_rec.transaction_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
2413 END IF;
2414 ELSE
2415 IF (p_rcvtxn_uom_code IS NULL) THEN
2416 BEGIN
2417 SELECT uom_code
2418 INTO l_rcvtxn_uom_code
2419 FROM mtl_units_of_measure
2420 WHERE unit_of_measure = p_rcvtxn_uom
2421 AND ROWNUM < 2;
2422 EXCEPTION
2423 WHEN OTHERS THEN
2424 IF (l_debug = 1) THEN
2425 print_debug('Error retrieving UOM_CODE. SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM,4);
2426 END IF;
2427 END;
2428 ELSE
2429 l_rcvtxn_uom_code := p_rcvtxn_uom_code;
2430 END IF;
2431
2432 BEGIN
2433 SELECT uom_code
2434 INTO l_prim_uom_code
2435 FROM mtl_units_of_measure
2436 WHERE unit_of_measure = l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure
2437 AND ROWNUM < 2;
2438 EXCEPTION
2439 WHEN OTHERS THEN
2440 IF (l_debug = 1) THEN
2441 print_debug('Error retrieving PRIM UOM_CODE. SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM,4);
2442 END IF;
2443 END;
2444
2445 IF (l_debug = 1) THEN
2446 print_debug('l_rcvtxn_uom_code:'||l_rcvtxn_uom_code,4);
2447 print_debug('l_prim_uom_code:'||l_prim_uom_code,4);
2448 END IF;
2449
2450 IF (l_rcvtxn_uom_code <> l_prim_uom_code) THEN
2451 l_rcv_transaction_rec.transaction_quantity := inv_rcv_cache.Convert_qty
2452 (p_inventory_item_id => NULL
2453 ,p_from_qty => l_rcvtxn_match_table_detail(match_result_count).primary_quantity
2454 ,p_from_uom_code => l_prim_uom_code
2455 ,p_to_uom_code => l_rcvtxn_uom_code);
2456 l_rcv_transaction_rec.transaction_uom := p_rcvtxn_uom;
2457 ELSE
2458 l_rcv_transaction_rec.transaction_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
2459 l_rcv_transaction_rec.transaction_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
2460 END IF;
2461 END IF;
2462
2463 IF (l_debug = 1) THEN
2464 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_quantity :' ||l_rcv_transaction_rec.transaction_quantity , 4);
2465 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_uom :' ||l_rcv_transaction_rec.transaction_uom, 4);
2466 END IF;
2467 --R12 END
2468
2469 l_rcv_transaction_rec.primary_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
2470 l_rcv_transaction_rec.primary_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
2471
2472 /*OPM Convergence..calculate the secondary qty from the corresponding values obtained from matching logic's primary qty*/
2473 l_rcv_transaction_rec.sec_transaction_quantity := (l_rcvtxn_match_table_detail(match_result_count).quantity/p_rcvtxn_qty) * p_sec_rcvtxn_qty;
2474 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.secondary_quantity:' || l_rcv_transaction_rec.sec_transaction_quantity, 4);
2475
2476 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2477 IF (p_deliver_to_location_id IS NOT NULL) THEN
2478 l_rcv_rcvtxn_rec.final_deliver_to_location_id := p_deliver_to_location_id;
2479 END IF;
2480 l_progress := '70';
2481
2482 -- Only call split MO for patchset J or higher
2483 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2484 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2485 -- Added addition check for p_original_txn_temp_id: if it is null,
2486 -- then simply insert RTI with the MMTT column as null
2487 IF p_original_txn_temp_id IS NULL OR l_rcvtxn_match_table_detail.COUNT = 1 THEN
2488 l_new_txn_temp_id := p_original_txn_temp_id;
2489 ELSE --More than 1 result returned from matching logic
2490 -- Call split mo
2491 IF (l_debug = 1) THEN
2492 print_debug('create_po_rcvtxn_intf_rec calling split_mo',4);
2493 END IF;
2494
2495 IF (l_orig_mol_id IS NULL) THEN
2496 BEGIN
2497 SELECT move_order_line_id
2498 INTO l_orig_mol_id
2499 FROM mtl_material_transactions_temp
2500 WHERE transaction_temp_id = p_original_txn_temp_id;
2501 EXCEPTION
2502 WHEN OTHERS THEN
2503 IF (l_debug = 1) THEN
2504 print_debug('create_po_rcvtxn_intf_rec: Error retrieving MOL id',4);
2505 END IF;
2506 RAISE fnd_api.g_exc_error;
2507 END;
2508 END IF; --IF (l_orig_mol_id IS NULL) THEN
2509
2510
2511 l_mo_splt_tb(1).prim_qty := l_rcv_transaction_rec.primary_quantity;
2512 l_mo_splt_tb(1).line_id := NULL;
2513
2514 IF (l_debug = 1) THEN
2515 print_debug('create_po_rcvtxn_intf_rec: Calling split_mo',4);
2516 print_debug(' (p_orig_mol_id ====> ' || l_orig_mol_id,4);
2517 print_debug(' (p_mo_splt_tb.prim_qty ==> ' || l_mo_splt_tb(1).prim_qty,4);
2518 print_debug(' (p_operation_type => ' || 'DELIVER',4);
2519 print_debug(' (p_txn_header_id => ' || p_original_txn_temp_id,4);
2520 END IF;
2521
2522 inv_rcv_integration_apis.split_mo
2523 (p_orig_mol_id => l_orig_mol_id,
2524 p_mo_splt_tb => l_mo_splt_tb,
2525 p_operation_type => 'DELIVER',
2526 p_txn_header_id => p_original_txn_temp_id,
2527 x_return_status => l_return_status,
2528 x_msg_count => l_msg_count,
2529 x_msg_data => x_message);
2530
2531 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2532 RAISE fnd_api.g_exc_error;
2533 END IF;
2534 l_progress := '75';
2535
2536 BEGIN
2537 SELECT transaction_temp_id
2538 INTO l_new_txn_temp_id
2539 FROM mtl_material_transactions_temp
2540 WHERE move_order_line_id = l_mo_splt_tb(1).line_id;
2541 EXCEPTION
2542 WHEN OTHERS THEN
2543 IF (l_debug = 1) THEN
2544 print_debug('create_po_rcvtxn_intf_rec: Error retrieving new mmtt id',4);
2545 END IF;
2546 END;
2547 END IF; --l_rcvtxn_match_table_detail.COUNT = 1
2548
2549 IF (l_debug = 1) THEN
2550 print_debug('create_po_rcvtxn_intf_rec RTI to be inserted with mmtt id: ' ||
2551 l_new_txn_temp_id || ' p_transaction_temp_id = ' ||
2552 p_transaction_temp_id,4);
2553 END IF;
2554 ELSE -- If lower than J
2555 l_new_txn_temp_id := p_original_txn_temp_id;
2556 END IF;
2557
2558 --dbms_output.put_line('Got a match');
2559 populate_default_values(
2560 p_rcv_transaction_rec => l_rcv_transaction_rec
2561 , p_rcv_rcvtxn_rec => l_rcv_rcvtxn_rec
2562 , p_organization_id => p_organization_id
2563 , p_item_id => p_item_id
2564 , p_revision => p_revision
2565 , p_subinventory_code => p_subinventory_code
2566 , p_locator_id => p_locator_id
2567 , p_transaction_temp_id => p_transaction_temp_id
2568 , p_lot_control_code => p_lot_control_code
2569 , p_serial_control_code => p_serial_control_code
2570 , p_original_txn_temp_id => l_new_txn_temp_id
2571 , p_lpn_id => p_lpn_id
2572 , p_transfer_lpn_id => p_transfer_lpn_id
2573 );
2574 l_progress := '80';
2575
2576 /* FP-J Lot/Serial Support Enhancement
2577 * Populate the table to store the information of the RTIs created used for
2578 * splitting the lots and serials based on RTI quantity
2579 */
2580 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2581 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2582 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
2583 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
2584 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_quantity;
2585 l_new_rti_info(match_result_count).sec_qty := l_rcv_transaction_rec.sec_transaction_quantity;--OPM Convergence
2586 l_new_rti_info(match_result_count).sec_uom_code := l_rcv_transaction_rec.secondary_uom; --OPM Convergence
2587 IF (l_debug = 1) THEN
2588 print_debug('create_po_rcvtxn_intf_rec: 65 - Populated the table for lot/serial split', 4);
2589 END IF;
2590 END IF; --END IF populate the table to store RTI info that was just created
2591 END LOOP;
2592
2593 --g_rcvtxn_detail_index := l_rcvtxn_match_table_detail.COUNT + g_rcvtxn_detail_index;
2594
2595 IF l_curs_rcvtxn_detail%ISOPEN THEN
2596 CLOSE l_curs_rcvtxn_detail;
2597 END IF;
2598
2599 /* FP-J Lot/Serial Support Enhancement
2600 * Call the split_lot API to split the lots and serials inserted from the UI
2601 * based on the quantity of each RTI record
2602 */
2603 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2604 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2605
2606 IF (p_lot_control_code > 1 OR p_serial_control_code > 1) THEN
2607 --BUG 3326408
2608 IF (p_lot_control_code > 1 AND p_serial_control_code = 6) THEN
2609 IF (l_debug = 1) THEN
2610 print_debug('create_po_rcvtxn_intf_rec 65.3: serial_control_code IS 6, need TO NULL OUT mtli', 4);
2611 END IF;
2612 BEGIN
2613 UPDATE mtl_transaction_lots_interface
2614 SET serial_transaction_temp_id = NULL
2615 WHERE product_transaction_id = p_transaction_temp_id
2616 AND product_code = 'RCV';
2617 EXCEPTION
2618 WHEN OTHERS THEN
2619 IF (l_debug = 1) THEN
2620 print_debug('create_po_rcvtxn_intf_rec 65.7: Error nulling serial temp id OF MTLI', 4);
2621 END IF;
2622 END ;
2623 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2624
2625 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2626 p_api_version => 1.0
2627 , p_init_msg_lst => FND_API.G_FALSE
2628 , x_return_status => l_return_status
2629 , x_msg_count => l_msg_count
2630 , x_msg_data => x_message
2631 , p_new_rti_info => l_new_rti_info);
2632 IF ( NOT l_split_lot_serial_ok) THEN
2633 IF (l_debug = 1) THEN
2634 print_debug('create_po_rcvtxn_intf_rec 67: Failure in split_lot_serial', 4);
2635 END IF;
2636 RAISE FND_API.G_EXC_ERROR;
2637 END IF;
2638
2639 IF (l_debug = 1) THEN
2640 print_debug('create_po_rcvtxn_intf_rec 68: Call split_lot_serial is OK', 4);
2641 END IF;
2642 END IF; --END IF check lot and serial controls
2643 END IF; --END IF check INV J and PO J installed
2644
2645 l_progress := '90';
2646 inv_rcv_common_apis.do_check(
2647 p_organization_id => p_organization_id
2648 , p_inventory_item_id => p_item_id
2649 , p_transaction_type_id => 18
2650 , p_primary_quantity => l_total_primary_qty
2651 , x_return_status => l_return_status
2652 , x_msg_count => l_msg_count
2653 , x_msg_data => x_message
2654 );
2655
2656 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2657 x_status := l_return_status;
2658 END IF;
2659
2660 l_progress := '100';
2661
2662 IF (l_debug = 1) THEN
2663 print_debug('Exiting create_po_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2664 END IF;
2665 EXCEPTION
2666 WHEN OTHERS THEN
2667 x_status := fnd_api.g_ret_sts_unexp_error;
2668
2669 IF l_curs_rcvtxn_detail%ISOPEN THEN
2670 CLOSE l_curs_rcvtxn_detail;
2671 END IF;
2672
2673 IF SQLCODE IS NOT NULL THEN
2674 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_po_rcvtxn_intf_rec', l_progress, SQLCODE);
2675 END IF;
2676
2677 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2678 END create_po_rcvtxn_intf_rec;
2679
2680 PROCEDURE create_int_shp_rcvtxn_intf_rec(
2681 p_organization_id IN NUMBER
2682 , p_shipment_header_id IN NUMBER
2683 , p_shipment_line_id IN NUMBER
2684 , p_receipt_num IN VARCHAR2
2685 , p_item_id IN NUMBER
2686 , p_source_id IN NUMBER
2687 , p_revision IN VARCHAR2
2688 , p_subinventory_code IN VARCHAR2
2689 , p_locator_id IN NUMBER
2690 , p_rcvtxn_qty IN NUMBER
2691 , p_rcvtxn_uom IN VARCHAR2
2692 , p_transaction_temp_id IN NUMBER
2693 , p_lot_control_code IN NUMBER
2694 , p_serial_control_code IN NUMBER
2695 , p_original_txn_temp_id IN NUMBER DEFAULT NULL
2696 , x_status OUT NOCOPY VARCHAR2
2697 , x_message OUT NOCOPY VARCHAR2
2698 , p_inspection_status_code IN VARCHAR2 DEFAULT NULL
2699 , p_lpn_id IN NUMBER DEFAULT NULL
2700 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
2701 , p_lot_number IN VARCHAR2 DEFAULT NULL
2702 , p_parent_txn_id IN NUMBER DEFAULT NULL
2703 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
2704 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
2705 , p_rcvtxn_uom_code IN VARCHAR2 DEFAULT NULL
2706 ) IS
2707 l_rcv_transaction_rec rcvtxn_transaction_rec_tp;
2708 l_rcv_rcvtxn_rec rcvtxn_enter_rec_cursor_rec;
2709 -- local record in which the values returned from the cursor are fetched.
2710
2711 l_rcvtxn_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type;
2712 -- local variable to store the output of the matching algorithm
2713
2714 l_msg_count NUMBER;
2715 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
2716 l_group_id NUMBER;
2717 l_transaction_type VARCHAR2(20) := 'STD_DELIVER';
2718 l_total_primary_qty NUMBER := 0;
2719 l_asn_type VARCHAR2(25);
2720 l_source_type VARCHAR2(80);
2721 l_source_code VARCHAR2(30);
2722 l_err_message VARCHAR2(100);
2723 l_temp_message VARCHAR2(100);
2724 l_msg_prod VARCHAR2(5);
2725 l_progress VARCHAR2(10);
2726 l_orig_mol_id NUMBER := NULL;
2727 l_new_txn_temp_id NUMBER;
2728 l_mo_splt_tb inv_rcv_integration_apis.mo_in_tb_tp;
2729
2730 CURSOR l_curs_rcvtxn_detail(v_shipment_line_id NUMBER
2731 , v_rcv_txn_id NUMBER) IS
2732 SELECT rsup.from_organization_id from_organization_id
2733 , rsup.to_organization_id to_organization_id
2734 , rt.source_document_code source_document_code
2735 , rsh.receipt_source_code receipt_source_code
2736 , rsup.rcv_transaction_id rcv_transaction_id
2737 , rt.transaction_date transaction_date
2738 , rt.transaction_type transaction_type
2739 , rt.primary_unit_of_measure primary_uom
2740 , rt.primary_quantity primary_quantity
2741 , rsup.po_header_id po_header_id
2742 , rt.po_revision_num po_revision_num
2743 , rsup.po_release_id po_release_id
2744 , rsh.vendor_id vendor_id
2745 , rt.vendor_site_id vendor_site_id
2746 , rsup.po_line_id po_line_id
2747 , rt.po_unit_price po_unit_price
2748 , rsl.category_id category_id
2749 , rsup.item_id item_id
2750 , msi.serial_number_control_code serial_number_control_code
2751 , msi.lot_control_code lot_control_code
2752 , rsup.item_revision item_revision
2753 , rsup.po_line_location_id po_line_location_id
2754 , rt.po_distribution_id po_distribution_id
2755 , rt.employee_id employee_id
2756 , rsl.comments comments
2757 , rsup.req_header_id req_header_id
2758 , rsup.req_line_id req_line_id
2759 , rsup.shipment_header_id shipment_header_id
2760 , rsup.shipment_line_id shipment_line_id
2761 , rsh.packing_slip packing_slip
2762 , rsl.government_context government_context
2763 , rsl.ussgl_transaction_code ussgl_transaction_code
2764 , rt.inspection_status_code inspection_status_code
2765 , rt.inspection_quality_code inspection_quality_code
2766 , rt.vendor_lot_num vendor_lot_num
2767 , '' vendor_item_number
2768 , rt.substitute_unordered_code substitute_unordered_code
2769 , rt.routing_header_id routing_id
2770 , rt.routing_step_id routing_step_id
2771 , rt.reason_id reason_id
2772 , rt.currency_code currency_code
2773 , rt.currency_conversion_rate currency_conversion_rate
2774 , rt.currency_conversion_date currency_conversion_date
2775 , rt.currency_conversion_type currency_conversion_type
2776 , rsl.req_distribution_id req_distribution_id
2777 , rsup.destination_type_code destination_type_code_hold
2778 , rsup.destination_type_code final_destination_type_code
2779 , rt.location_id location_id
2780 , rsl.deliver_to_person_id final_deliver_to_person_id
2781 , rsl.deliver_to_location_id final_deliver_to_location_id
2782 , rsl.to_subinventory subinventory
2783 , msi.un_number_id un_number_id
2784 , msi.hazard_class_id hazard_class_id
2785 , rsup.creation_date creation_date
2786 , rt.attribute_category attribute_category
2787 , rt.attribute1 attribute1
2788 , rt.attribute2 attribute2
2789 , rt.attribute3 attribute3
2790 , rt.attribute4 attribute4
2791 , rt.attribute5 attribute5
2792 , rt.attribute6 attribute6
2793 , rt.attribute7 attribute7
2794 , rt.attribute8 attribute8
2795 , rt.attribute9 attribute9
2796 , rt.attribute10 attribute10
2797 , rt.attribute11 attribute11
2798 , rt.attribute12 attribute12
2799 , rt.attribute13 attribute13
2800 , rt.attribute14 attribute14
2801 , rt.attribute15 attribute15
2802 , rt.qa_collection_id qa_collection_id
2803 , rsup.oe_order_header_id oe_order_header_id
2804 , rt.oe_order_line_id oe_order_line_id
2805 , rsh.customer_id customer_id
2806 , rsh.customer_site_id customer_site_id
2807 , NULL wip_entity_id
2808 , NULL po_operation_seq_num
2809 , NULL po_resource_seq_num
2810 , NULL wip_repetitive_schedule_id
2811 , NULL wip_line_id
2812 , NULL bom_resource_id
2813 , NULL final_subinventory
2814 , rt.SECONDARY_QUANTITY --OPM Convergence
2815 , rt.SECONDARY_UNIT_OF_MEASURE --OPM Convergence
2816 --The following columns are needed for matching in cases where no LPN is involved
2817 , rsup.to_subinventory from_subinventory_code
2818 , rsup.to_locator_id from_locator_id
2819 FROM rcv_transactions rt
2820 , rcv_supply rsup
2821 , rcv_shipment_headers rsh
2822 , rcv_shipment_lines rsl
2823 , mtl_system_items msi
2824 WHERE rsup.rcv_transaction_id = v_rcv_txn_id
2825 AND rsup.shipment_line_id = v_shipment_line_id
2826 AND rsup.to_organization_id = p_organization_id
2827 AND rsl.shipment_line_id = rsup.shipment_line_id
2828 AND rt.transaction_id = rsup.rcv_transaction_id
2829 AND rsh.shipment_header_id = rsup.shipment_header_id
2830 AND msi.organization_id = rsup.to_organization_id
2831 AND msi.inventory_item_id = rsup.item_id
2832 ORDER BY rt.transaction_date DESC;
2833
2834 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2835 --table to store all RTId, quantity and original_rti_id for lot/serial splits
2836 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
2837 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
2838 l_msni_count NUMBER := 0;
2839 l_prim_uom_code VARCHAR2(3);
2840 l_rcvtxn_uom_code VARCHAR2(3);
2841 l_lot_number mtl_transaction_lots_interface.lot_number%TYPE; --Bug 13400589
2842 BEGIN
2843 x_status := fnd_api.g_ret_sts_success;
2844
2845 IF (l_debug = 1) THEN
2846 print_debug('Entering create_int_shp_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2847 END IF;
2848
2849 l_progress := '10';
2850
2851 BEGIN
2852 /*Begin Bug Fix 4158984
2853 Setting value of INV_RCV_COMMON_APIS.g_rcv_global_var.receipt_num to a
2854 dummy value of -9999 as if this value is null, we are generating recepit
2855 numbers during delivery transaction which is not required.
2856 We are setting value back to null after call to inv_rcv_common_apis.init_startup_values.
2857 */
2858 INV_RCV_COMMON_APIS.g_rcv_global_var.receipt_num := -9999;
2859 inv_rcv_common_apis.init_startup_values(p_organization_id);
2860 INV_RCV_COMMON_APIS.g_rcv_global_var.receipt_num := NULL;
2861 /*End bug 4158984*/
2862 EXCEPTION
2863 WHEN NO_DATA_FOUND THEN
2864 fnd_message.set_name('INV', 'INV_RCV_PARAM');
2865 fnd_msg_pub.ADD;
2866 RAISE;
2867 END;
2868
2869 l_progress := '20';
2870
2871 -- default l_group_id ?? clear group id after done
2872 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
2873 SELECT rcv_interface_groups_s.NEXTVAL
2874 INTO l_group_id
2875 FROM DUAL;
2876
2877 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
2878 ELSE
2879 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
2880 END IF;
2881
2882 -- default some header level variables based on the header id passed
2883 SELECT asn_type
2884 INTO l_asn_type
2885 FROM rcv_shipment_headers
2886 WHERE shipment_header_id = p_shipment_header_id;
2887
2888 -- If l_asn_type is NULL then this shipment is not from ASN
2889 IF l_asn_type IS NOT NULL THEN
2890 IF NVL(l_asn_type, 'STD') = 'STD' THEN
2891 l_source_type := 'INTERNAL';
2892 ELSE
2893 l_source_type := 'VENDOR';
2894 END IF;
2895 ELSE
2896 -- Not an ASN shipment.
2897 SELECT receipt_source_code
2898 INTO l_source_code
2899 FROM rcv_shipment_headers
2900 WHERE shipment_header_id = p_shipment_header_id;
2901
2902 IF l_source_code = 'VENDOR' THEN
2903 l_source_type := 'VENDOR';
2904 ELSE -- source code of 'INVENTORY' or 'INTERNAL ORDER'
2905 l_source_type := 'INTERNAL';
2906 END IF;
2907 END IF;
2908
2909 --Bug 13400589
2910 IF(p_lot_number IS NULL) THEN
2911 BEGIN
2912 SELECT lot_number INTO l_lot_number
2913 FROM mtl_transaction_lots_interface
2914 WHERE product_transaction_id = p_transaction_temp_id ;
2915 EXCEPTION
2916 WHEN No_Data_Found THEN
2917 IF (l_debug = 1) THEN
2918 print_debug('create_int_shp_rcvtxn_intf_rec: No Lot records in MTLI for id :'||p_transaction_temp_id,4);
2919 END IF;
2920 l_lot_number :=NULL;
2921 WHEN too_many_rows THEN
2922 IF (l_debug = 1) THEN
2923 print_debug('create_int_shp_rcvtxn_intf_rec: More than one records in MTLI for id :'||p_transaction_temp_id,4);
2924 END IF;
2925 l_lot_number :=NULL; --For multiple lots dont input to matching logic
2926 END;
2927 ELSE
2928 l_lot_number:=p_lot_number;
2929 END IF;
2930
2931 IF (l_debug = 1) THEN
2932 print_debug('create_int_shp_rcvtxn_intf_rec: 30.2 l_lot_number: ' || l_lot_number, 4);
2933 END IF;
2934
2935 l_progress := '30';
2936 -- call matching algorithm
2937 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).GROUP_ID := l_group_id;
2938 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).transaction_type := l_transaction_type;
2939 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).quantity := p_rcvtxn_qty;
2940 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).unit_of_measure := p_rcvtxn_uom;
2941 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id := p_item_id;
2942 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).revision := p_revision; -- 2252193
2943 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).shipment_header_id := p_shipment_header_id;
2944 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).shipment_line_id := p_shipment_line_id;
2945 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).to_organization_id := p_organization_id;
2946 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).from_organization_id := p_source_id;
2947 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).p_lpn_id := p_lpn_id;
2948 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).expected_receipt_date := SYSDATE; --?
2949 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).tax_amount := 0; -- ?
2950 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status := 'S'; -- ?
2951 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).inspection_status_code := p_inspection_status_code;
2952
2953 /* FP-J Lot/Serial Support Enhancement
2954 * If INV and PO J are installed, then the lots for the parent transaction will
2955 * be stored in rcv_lots_supply. We must match the lot number passed with that
2956 * of the parent transaction and also the parent_txn_id
2957 */
2958 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2959 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2960 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := l_lot_number;
2961 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := p_parent_txn_id;
2962 ELSE
2963 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := NULL;
2964 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := NULL;
2965 END IF;
2966
2967 BEGIN
2968 SELECT primary_unit_of_measure
2969 INTO g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure
2970 FROM mtl_system_items
2971 WHERE mtl_system_items.inventory_item_id = p_item_id
2972 AND mtl_system_items.organization_id = p_organization_id;
2973 EXCEPTION
2974 WHEN NO_DATA_FOUND THEN
2975 NULL;
2976 END;
2977
2978 l_progress := '40';
2979 if (l_asn_type = 'ASN') then
2980 inv_rcv_txn_match.matching_logic(
2981 x_return_status => x_status --?
2982 , x_msg_count => l_msg_count
2983 , x_msg_data => x_message
2984 , x_cascaded_table => g_rcvtxn_match_table_gross
2985 , n => g_rcvtxn_detail_index
2986 , temp_cascaded_table => l_rcvtxn_match_table_detail
2987 , p_receipt_num => p_receipt_num
2988 , p_match_type => 'ASN'
2989 , p_lpn_id => NULL
2990 );
2991 else
2992 inv_rcv_txn_match.matching_logic(
2993 x_return_status => x_status --?
2994 , x_msg_count => l_msg_count
2995 , x_msg_data => x_message
2996 , x_cascaded_table => g_rcvtxn_match_table_gross
2997 , n => g_rcvtxn_detail_index
2998 , temp_cascaded_table => l_rcvtxn_match_table_detail
2999 , p_receipt_num => p_receipt_num
3000 , p_match_type => 'INTRANSIT SHIPMENT'
3001 , p_lpn_id => NULL
3002 );
3003
3004
3005 -- x_status is not successful if there is any execution error in matching.
3006 IF x_status <> fnd_api.g_ret_sts_success THEN
3007 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3008 fnd_msg_pub.ADD;
3009
3010 IF (l_debug = 1) THEN
3011 print_debug('Exiting create_int_shp_rcvtxn_intf_rec 20:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3012 END IF;
3013
3014 RETURN;
3015 END IF;
3016
3017 END IF;
3018
3019 IF g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status = 'E' THEN
3020 x_status := fnd_api.g_ret_sts_error;
3021 l_err_message := g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_message;
3022 fnd_message.set_name('INV', l_err_message);
3023 fnd_msg_pub.ADD;
3024
3025 IF (l_debug = 1) THEN
3026 print_debug('exiting create_int_shp_rcvtxn_intf_rec 30:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3027 END IF;
3028
3029 RETURN;
3030 END IF;
3031
3032 l_err_message := '@@@';
3033
3034 FOR i IN g_rcvtxn_detail_index ..(g_rcvtxn_detail_index + l_rcvtxn_match_table_detail.COUNT - 1) LOOP
3035 IF l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_status = 'W' THEN
3036 x_status := 'W';
3037 l_temp_message := l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_message;
3038
3039 IF l_temp_message IS NULL THEN
3040 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3041 l_msg_prod := 'INV';
3042 EXIT;
3043 END IF;
3044
3045 IF l_err_message = '@@@' THEN
3046 l_err_message := l_temp_message;
3047 l_msg_prod := 'INV';
3048 ELSIF l_temp_message <> l_err_message THEN
3049 l_msg_prod := 'INV';
3050 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3051 EXIT;
3052 END IF;
3053 END IF;
3054 END LOOP;
3055
3056 IF l_err_message <> '@@@' THEN
3057 fnd_message.set_name(l_msg_prod, l_err_message);
3058 fnd_msg_pub.ADD;
3059
3060 IF (l_debug = 1) THEN
3061 print_debug('adding tolerance message create_int_shp_rcvtxn_intf_rec 40:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3062 END IF;
3063 END IF;
3064
3065 l_progress := '50';
3066 -- based on return from matching algorithm,
3067 -- determine which line in rcv_transaction block to be inserted into RTI
3068
3069 l_progress := '60';
3070
3071 IF (l_debug = 1) THEN
3072 print_debug('create_int_shp_rcvtxn_intf_rec no recs matched by matching 50:' || l_rcvtxn_match_table_detail.COUNT, 4);
3073 END IF;
3074
3075 -- loop through results returned by matching algorithm
3076 FOR match_result_count IN 1 .. l_rcvtxn_match_table_detail.COUNT LOOP
3077 IF (l_debug = 1) THEN
3078 print_debug('create_int_shp_rcvtxn_intf_rec found a match 60', 4);
3079 print_debug('Matching returned values 60.1 - shipment_line_id:' || l_rcvtxn_match_table_detail(match_result_count).shipment_line_id, 4);
3080 print_debug('Matching returned values 60.1 - rcv_transaction_id:' || l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id, 4);
3081 print_debug('Matching returned values 60.1 - transaction_quantity:' || l_rcvtxn_match_table_detail(match_result_count).quantity, 4);
3082 print_debug('Matching returned values 60.1 - transaction_uom:' || l_rcvtxn_match_table_detail(match_result_count).unit_of_measure, 4);
3083 print_debug('Matching returned values 60.1 - primary_quantity:' || l_rcvtxn_match_table_detail(match_result_count).primary_quantity, 4);
3084 print_debug('Matching returned values 60.1 - primary_uom:' || l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure, 4);
3085 print_debug('Matching returned values 60.1 - po_distribution_id : '||l_rcvtxn_match_table_detail(match_result_count).po_distribution_id,4);
3086 END IF;
3087
3088 OPEN l_curs_rcvtxn_detail(
3089 l_rcvtxn_match_table_detail(match_result_count).shipment_line_id
3090 , l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id);
3091 FETCH l_curs_rcvtxn_detail INTO l_rcv_rcvtxn_rec;
3092 CLOSE l_curs_rcvtxn_detail;
3093 -- update following fields from matching algorithm return value
3094 -- Bug No 1823328 Changes
3095 l_rcv_transaction_rec.shipment_line_id := l_rcvtxn_match_table_detail(match_result_count).shipment_line_id;
3096 --
3097
3098 --R12: create RTI with uom entered by user
3099 l_prim_uom_code := inv_rcv_cache.get_primary_uom_code(p_organization_id,p_item_id);
3100
3101 IF (p_rcvtxn_uom_code IS NULL) THEN
3102 SELECT uom_code
3103 INTO l_rcvtxn_uom_code
3104 FROM mtl_item_uoms_view
3105 WHERE organization_id = p_organization_id
3106 AND inventory_item_id = p_item_id
3107 AND unit_of_measure = p_rcvtxn_uom
3108 AND ROWNUM < 2;
3109 ELSE
3110 l_rcvtxn_uom_code := p_rcvtxn_uom_code;
3111 END IF;
3112
3113 IF (l_rcvtxn_uom_code <> l_prim_uom_code) THEN
3114 l_rcv_transaction_rec.transaction_quantity := inv_rcv_cache.Convert_qty
3115 (p_inventory_item_id => p_item_id
3116 ,p_from_qty => l_rcvtxn_match_table_detail(match_result_count).primary_quantity
3117 ,p_from_uom_code => l_prim_uom_code
3118 ,p_to_uom_code => l_rcvtxn_uom_code);
3119 l_rcv_transaction_rec.transaction_uom := p_rcvtxn_uom;
3120 ELSE
3121 l_rcv_transaction_rec.transaction_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
3122 l_rcv_transaction_rec.transaction_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
3123 END IF;
3124
3125 IF (l_debug = 1) THEN
3126 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_quantity :' ||l_rcv_transaction_rec.transaction_quantity , 4);
3127 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_uom :' ||l_rcv_transaction_rec.transaction_uom, 4);
3128 END IF;
3129 --R12 END
3130
3131 l_rcv_transaction_rec.primary_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
3132 l_rcv_transaction_rec.primary_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
3133 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3134
3135 -- Start Bug 13344122 change
3136 -- Passing the secondary quantity values entered by the user only when the matching logic returns one row
3137 -- i.e. one RTI record is created
3138 IF (l_rcvtxn_match_table_detail.COUNT = 1) THEN
3139
3140 -- Start of Bug 13961952 changes
3141 -- p_secondary_uom can have the unit of measure or uom_code as its value
3142 BEGIN
3143 SELECT unit_of_measure,
3144 uom_code
3145 INTO l_rcv_transaction_rec.secondary_uom,
3146 l_rcv_transaction_rec.secondary_uom_code
3147 FROM MTL_UNITS_OF_MEASURE_VL
3148 WHERE unit_of_measure = p_secondary_uom
3149 OR uom_code = p_secondary_uom;
3150
3151 l_rcv_transaction_rec.sec_transaction_quantity := p_sec_rcvtxn_qty;
3152
3153 EXCEPTION
3154 WHEN NO_DATA_FOUND THEN
3155 print_debug('Unit of measure does not exist', 4);
3156 END;
3157 -- End of Bug 13961952 changes
3158
3159 IF (l_debug = 1) THEN
3160 print_debug('60.1 - p_sec_rcvtxn_qty : ' || p_sec_rcvtxn_qty, 4);
3161 print_debug('60.1 - p_secondary_uom : ' || p_secondary_uom, 4);
3162 print_debug('60.1 - secondary_uom : ' || l_rcv_transaction_rec.secondary_uom, 4); -- Bug 13961952
3163 print_debug('60.1 - secondary_uom_code : ' || l_rcv_transaction_rec.secondary_uom_code, 4); -- Bug 13961952
3164 END IF;
3165
3166 END IF;
3167 -- End Bug 13344122 change
3168
3169 l_progress := '70';
3170
3171 if (l_asn_type = 'ASN') then
3172 l_rcv_transaction_rec.po_distribution_id := l_rcvtxn_match_table_detail(match_result_count).po_distribution_id;
3173 end if;
3174
3175
3176
3177 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3178 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3179 -- Added addition check for p_original_txn_temp_id: if it is null,
3180 -- then simply insert RTI with the MMTT column as null
3181 IF p_original_txn_temp_id IS NULL OR l_rcvtxn_match_table_detail.COUNT = 1 THEN
3182 l_new_txn_temp_id := p_original_txn_temp_id;
3183 ELSE --More than 1 result returned from matching logic
3184 -- Call split mo
3185 IF (l_debug = 1) THEN
3186 print_debug('create_int_shp_rcvtxn_intf_rec calling split_mo',4);
3187 END IF;
3188
3189 IF (l_orig_mol_id IS NULL) THEN
3190 BEGIN
3191 SELECT move_order_line_id
3192 INTO l_orig_mol_id
3193 FROM mtl_material_transactions_temp
3194 WHERE transaction_temp_id = p_original_txn_temp_id;
3195 EXCEPTION
3196 WHEN OTHERS THEN
3197 IF (l_debug = 1) THEN
3198 print_debug('create_int_shp_rcvtxn_intf_rec: Error retrieving MOL id',4);
3199 END IF;
3200 RAISE fnd_api.g_exc_error;
3201 END;
3202 END IF; --IF (l_orig_mol_id IS NULL) THEN
3203
3204 l_mo_splt_tb(1).prim_qty := l_rcv_transaction_rec.primary_quantity;
3205 l_mo_splt_tb(1).line_id := NULL;
3206
3207 IF (l_debug = 1) THEN
3208 print_debug('create_int_shp_rcvtxn_intf_rec: Calling split_mo',4);
3209 print_debug(' (p_orig_mol_id ====> ' || l_orig_mol_id,4);
3210 print_debug(' (p_mo_splt_tb.prim_qty ==> ' || l_mo_splt_tb(1).prim_qty,4);
3211 print_debug(' (p_operation_type => ' || 'DELIVER',4);
3212 print_debug(' (p_txn_header_id => ' || p_original_txn_temp_id,4);
3213 END IF;
3214
3215 inv_rcv_integration_apis.split_mo
3216 (p_orig_mol_id => l_orig_mol_id,
3217 p_mo_splt_tb => l_mo_splt_tb,
3218 p_operation_type => 'DELIVER',
3219 p_txn_header_id => p_original_txn_temp_id,
3220 x_return_status => l_return_status,
3221 x_msg_count => l_msg_count,
3222 x_msg_data => x_message);
3223
3224 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
3225 RAISE fnd_api.g_exc_error;
3226 END IF;
3227 l_progress := '75';
3228
3229 BEGIN
3230 SELECT transaction_temp_id
3231 INTO l_new_txn_temp_id
3232 FROM mtl_material_transactions_temp
3233 WHERE move_order_line_id = l_mo_splt_tb(1).line_id;
3234 EXCEPTION
3235 WHEN OTHERS THEN
3236 IF (l_debug = 1) THEN
3237 print_debug('create_int_shp_rcvtxn_intf_rec: Error retrieving new mmtt id',4);
3238 END IF;
3239 END;
3240 END IF; --l_rcvtxn_match_table_detail.COUNT = 1
3241
3242 IF (l_debug = 1) THEN
3243 print_debug('create_int_shp_rcvtxn_intf_rec RTI to be inserted with mmtt id: ' ||
3244 l_new_txn_temp_id || ' p_transaction_temp_id = ' ||
3245 p_transaction_temp_id,4);
3246 END IF;
3247 ELSE -- If lower than J
3248 l_new_txn_temp_id := p_original_txn_temp_id;
3249 END IF; -- End If (Patchset J)
3250
3251 --dbms_output.put_line('Got a match');
3252 populate_default_values(
3253 p_rcv_transaction_rec => l_rcv_transaction_rec
3254 , p_rcv_rcvtxn_rec => l_rcv_rcvtxn_rec
3255 , p_organization_id => p_organization_id
3256 , p_item_id => p_item_id
3257 , p_revision => p_revision
3258 , p_subinventory_code => p_subinventory_code
3259 , p_locator_id => p_locator_id
3260 , p_transaction_temp_id => p_transaction_temp_id
3261 , p_lot_control_code => p_lot_control_code
3262 , p_serial_control_code => p_serial_control_code
3263 , p_original_txn_temp_id => l_new_txn_temp_id
3264 , p_lpn_id => p_lpn_id
3265 , p_transfer_lpn_id => p_transfer_lpn_id
3266 );
3267 l_progress := '80';
3268
3269 IF (l_debug = 1) THEN
3270 print_debug('create_int_shp_rcvtxn_intf_rec 125 - before update_rcv_serials_supply' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3271 END IF;
3272
3273 /* FP-J Lot/Serial Support Enhancement
3274 * Populate the table to store the information of the RTIs created used for
3275 * splitting the lots and serials based on RTI quantity
3276 */
3277 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3278 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3279 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
3280 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
3281 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_quantity;
3282 IF (l_debug = 1) THEN
3283 print_debug('create_int_shp_rcvtxn_intf_rec 126.5 - Populated the table for lot/serial split', 4);
3284 END IF;
3285 END IF; --END IF populate the table to store RTI info that was just created
3286
3287 /* FP-J Lot/Serial Support Enhancement
3288 * No updates to rcv_serials_supply if INV J and PO J are installed
3289 */
3290 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
3291 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
3292 IF l_rcv_rcvtxn_rec.req_line_id IS NOT NULL
3293 AND p_serial_control_code NOT IN(1, 6) THEN
3294 -- update rss for req
3295 update_rcv_serials_supply(
3296 x_return_status => l_return_status
3297 , x_msg_count => l_msg_count
3298 , x_msg_data => x_message
3299 , p_shipment_line_id => l_rcv_rcvtxn_rec.shipment_line_id
3300 );
3301 END IF;
3302
3303 IF (l_debug = 1) THEN
3304 print_debug('create_int_shp_rcvtxn_intf_rec: 127 - before update_rcv_serials_supply' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3305 END IF;
3306 ELSE
3307 IF (l_debug = 1) THEN
3308 print_debug('create_int_shp_rcvtxn_intf_rec: 127.6 - INV and PO patch levels are J or higher. No update to rcv_supply', 4);
3309 END IF;
3310 END IF; --END IF check INV and PO patch levels
3311 END LOOP;
3312
3313 --g_rcvtxn_detail_index := l_rcvtxn_match_table_detail.COUNT + g_rcvtxn_detail_index;
3314
3315 IF l_curs_rcvtxn_detail%ISOPEN THEN
3316 CLOSE l_curs_rcvtxn_detail;
3317 END IF;
3318
3319 /* FP-J Lot/Serial Support Enhancement
3320 * Call the split_lot API to split the lots and serials inserted from the UI
3321 * based on the quantity of each RTI record
3322 */
3323 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3324 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3325 l_msni_count := 0;
3326 IF (p_lot_control_code > 1 OR p_serial_control_code > 1) THEN
3327 --BUG 3326408, 3405320
3328 --If there are any serials confirmed from the UI for an item that is
3329 --lot controlled and serial control dynamic at SO issue,
3330 --do not NULL out serial_transaction_temp_id. In other cases,
3331 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
3332 IF (p_lot_control_code > 1 AND p_serial_control_code = 6) THEN
3333 BEGIN
3334 SELECT count(1)
3335 INTO l_msni_count
3336 FROM mtl_serial_numbers_interface
3337 WHERE product_transaction_id = p_transaction_temp_id
3338 AND product_code = 'RCV';
3339
3340 IF (l_debug = 1) THEN
3341 print_debug('create_int_shp_rcvtxn_intf_rec 127.7: serial_control_code IS 6, need TO NULL OUT mtli', 4);
3342 END IF;
3343 IF l_msni_count <= 0 THEN
3344 UPDATE mtl_transaction_lots_interface
3345 SET serial_transaction_temp_id = NULL
3346 WHERE product_transaction_id = p_transaction_temp_id
3347 AND product_code = 'RCV';
3348 END IF;
3349 EXCEPTION
3350 WHEN OTHERS THEN
3351 IF (l_debug = 1) THEN
3352 print_debug('create_int_shp_rcvtxn_intf_rec 127.8: Error nulling serial temp id OF MTLI', 4);
3353 END IF;
3354 END ;
3355 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3356
3357 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
3358 p_api_version => 1.0
3359 , p_init_msg_lst => FND_API.G_FALSE
3360 , x_return_status => l_return_status
3361 , x_msg_count => l_msg_count
3362 , x_msg_data => x_message
3363 , p_new_rti_info => l_new_rti_info);
3364 IF ( NOT l_split_lot_serial_ok) THEN
3365 IF (l_debug = 1) THEN
3366 print_debug('create_int_shp_rcvtxn_intf_rec 128: Failure in split_lot_serial', 4);
3367 END IF;
3368 RAISE FND_API.G_EXC_ERROR;
3369 END IF;
3370
3371 IF (l_debug = 1) THEN
3372 print_debug('create_int_shp_rcvtxn_intf_rec 129: Call split_lot_serial is OK', 4);
3373 END IF;
3374 END IF; --END IF check lot and serial control controls
3375 END IF; --END IF check INV J and PO J installed
3376
3377 inv_rcv_common_apis.do_check(
3378 p_organization_id => p_organization_id
3379 , p_inventory_item_id => p_item_id
3380 , p_transaction_type_id => 61
3381 , p_primary_quantity => l_total_primary_qty
3382 , x_return_status => l_return_status
3383 , x_msg_count => l_msg_count
3384 , x_msg_data => x_message
3385 );
3386
3387 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3388 x_status := l_return_status;
3389 END IF;
3390
3391 l_progress := '100';
3392
3393 IF (l_debug = 1) THEN
3394 print_debug('Exiting create_int_shp_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3395 END IF;
3396 EXCEPTION
3397 WHEN OTHERS THEN
3398 x_status := fnd_api.g_ret_sts_unexp_error;
3399
3400 IF l_curs_rcvtxn_detail%ISOPEN THEN
3401 CLOSE l_curs_rcvtxn_detail;
3402 END IF;
3403
3404 IF SQLCODE IS NOT NULL THEN
3405 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_int_shp_rcvtxn_intf_rec', l_progress, SQLCODE);
3406 END IF;
3407
3408 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3409 END create_int_shp_rcvtxn_intf_rec;
3410
3411 PROCEDURE create_rma_rcvtxn_intf_rec(
3412 p_organization_id IN NUMBER
3413 , p_oe_order_header_id IN NUMBER
3414 , p_oe_order_line_id IN NUMBER
3415 , p_receipt_num IN VARCHAR2
3416 , p_item_id IN NUMBER
3417 , p_customer_id IN NUMBER
3418 , p_revision IN VARCHAR2
3419 , p_subinventory_code IN VARCHAR2
3420 , p_locator_id IN NUMBER
3421 , p_rcvtxn_qty IN NUMBER
3422 , p_rcvtxn_uom IN VARCHAR2
3423 , p_transaction_temp_id IN NUMBER
3424 , p_lot_control_code IN NUMBER
3425 , p_serial_control_code IN NUMBER
3426 , p_original_txn_temp_id IN NUMBER DEFAULT NULL
3427 , x_status OUT NOCOPY VARCHAR2
3428 , x_message OUT NOCOPY VARCHAR2
3429 , p_inspection_status_code IN VARCHAR2 DEFAULT NULL
3430 , p_lpn_id IN NUMBER DEFAULT NULL
3431 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
3432 , p_lot_number IN VARCHAR2 DEFAULT NULL
3433 , p_parent_txn_id IN NUMBER DEFAULT NULL
3434 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
3435 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
3436 , p_rcvtxn_uom_code IN VARCHAR2 DEFAULT NULL
3437 ) IS
3438 l_rcv_transaction_rec rcvtxn_transaction_rec_tp;
3439 l_rcv_rcvtxn_rec rcvtxn_enter_rec_cursor_rec;
3440 -- local record in which the values returned from the cursor are fetched.
3441
3442 l_rcvtxn_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type;
3443 -- local variable to store the output of the matching algorithm
3444
3445 l_msg_count NUMBER;
3446 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
3447 l_group_id NUMBER;
3448 l_transaction_type VARCHAR2(20) := 'STD_DELIVER';
3449 l_total_primary_qty NUMBER := 0;
3450 l_asn_type VARCHAR2(25);
3451 l_source_type VARCHAR2(80);
3452 l_source_code VARCHAR2(30);
3453 l_err_message VARCHAR2(100);
3454 l_temp_message VARCHAR2(100);
3455 l_msg_prod VARCHAR2(5);
3456 l_progress VARCHAR2(10);
3457 l_orig_mol_id NUMBER := NULL;
3458 l_new_txn_temp_id NUMBER;
3459 l_mo_splt_tb inv_rcv_integration_apis.mo_in_tb_tp;
3460
3461 CURSOR l_curs_rcvtxn_detail(v_order_line_id NUMBER
3462 , v_rcv_txn_id NUMBER) IS
3463 SELECT rsup.from_organization_id from_organization_id
3464 , rsup.to_organization_id to_organization_id
3465 , rt.source_document_code source_document_code
3466 , rsh.receipt_source_code receipt_source_code
3467 , rsup.rcv_transaction_id rcv_transaction_id
3468 , rt.transaction_date transaction_date
3469 , rt.transaction_type transaction_type
3470 , rt.primary_unit_of_measure primary_uom
3471 , rt.primary_quantity primary_quantity
3472 , rsup.po_header_id po_header_id
3473 , rt.po_revision_num po_revision_num
3474 , rsup.po_release_id po_release_id
3475 , rsh.vendor_id vendor_id
3476 , rt.vendor_site_id vendor_site_id
3477 , rsup.po_line_id po_line_id
3478 , rt.po_unit_price po_unit_price
3479 , rsl.category_id category_id
3480 , rsup.item_id item_id
3481 , msi.serial_number_control_code serial_number_control_code
3482 , msi.lot_control_code lot_control_code
3483 , rsup.item_revision item_revision
3484 , rsup.po_line_location_id po_line_location_id
3485 , rt.po_distribution_id po_distribution_id
3486 , rt.employee_id employee_id
3487 , rsl.comments comments
3488 , rsup.req_header_id req_header_id
3489 , rsup.req_line_id req_line_id
3490 , rsup.shipment_header_id shipment_header_id
3491 , rsup.shipment_line_id shipment_line_id
3492 , rsh.packing_slip packing_slip
3493 , rsl.government_context government_context
3494 , rsl.ussgl_transaction_code ussgl_transaction_code
3495 , rt.inspection_status_code inspection_status_code
3496 , rt.inspection_quality_code inspection_quality_code
3497 , rt.vendor_lot_num vendor_lot_num
3498 , '' vendor_item_number
3499 , rt.substitute_unordered_code substitute_unordered_code
3500 , rt.routing_header_id routing_id
3501 , rt.routing_step_id routing_step_id
3502 , rt.reason_id reason_id
3503 , rt.currency_code currency_code
3504 , rt.currency_conversion_rate currency_conversion_rate
3505 , rt.currency_conversion_date currency_conversion_date
3506 , rt.currency_conversion_type currency_conversion_type
3507 , rsl.req_distribution_id req_distribution_id
3508 , rsup.destination_type_code destination_type_code_hold
3509 , rsup.destination_type_code final_destination_type_code
3510 , rt.location_id location_id
3511 , rsl.deliver_to_person_id final_deliver_to_person_id
3512 , rsl.deliver_to_location_id final_deliver_to_location_id
3513 , rsl.to_subinventory subinventory
3514 , msi.un_number_id un_number_id
3515 , msi.hazard_class_id hazard_class_id
3516 , rsup.creation_date creation_date
3517 , rt.attribute_category attribute_category
3518 , rt.attribute1 attribute1
3519 , rt.attribute2 attribute2
3520 , rt.attribute3 attribute3
3521 , rt.attribute4 attribute4
3522 , rt.attribute5 attribute5
3523 , rt.attribute6 attribute6
3524 , rt.attribute7 attribute7
3525 , rt.attribute8 attribute8
3526 , rt.attribute9 attribute9
3527 , rt.attribute10 attribute10
3528 , rt.attribute11 attribute11
3529 , rt.attribute12 attribute12
3530 , rt.attribute13 attribute13
3531 , rt.attribute14 attribute14
3532 , rt.attribute15 attribute15
3533 , rt.qa_collection_id qa_collection_id
3534 , rsup.oe_order_header_id oe_order_header_id
3535 , rt.oe_order_line_id oe_order_line_id
3536 , rsh.customer_id customer_id
3537 , rsh.customer_site_id customer_site_id
3538 , NULL wip_entity_id
3539 , NULL po_operation_seq_num
3540 , NULL po_resource_seq_num
3541 , NULL wip_repetitive_schedule_id
3542 , NULL wip_line_id
3543 , NULL bom_resource_id
3544 , NULL final_subinventory
3545 , rt.SECONDARY_QUANTITY --OPM Convergence
3546 , rt.SECONDARY_UNIT_OF_MEASURE --OPM Convergence
3547 --The following columns are needed for matching in cases where no LPN is involved
3548 , rsup.to_subinventory from_subinventory_code
3549 , rsup.to_locator_id from_locator_id
3550 FROM rcv_transactions rt
3551 , rcv_supply rsup
3552 , rcv_shipment_headers rsh
3553 , rcv_shipment_lines rsl
3554 , mtl_system_items msi
3555 WHERE rsup.rcv_transaction_id = v_rcv_txn_id
3556 AND rsup.oe_order_line_id = v_order_line_id
3557 AND rsup.to_organization_id = p_organization_id
3558 AND rsl.shipment_line_id = rsup.shipment_line_id
3559 AND rt.transaction_id = rsup.rcv_transaction_id
3560 AND rsh.shipment_header_id = rsup.shipment_header_id
3561 AND msi.organization_id = rsup.to_organization_id
3562 AND msi.inventory_item_id = rsup.item_id
3563 ORDER BY rt.transaction_date DESC;
3564
3565 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3566 --table to store all RTId, quantity and original_rti_id for lot/serial splits
3567 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
3568 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
3569 l_prim_uom_code VARCHAR2(3);
3570 l_rcvtxn_uom_code VARCHAR2(3);
3571 BEGIN
3572 x_status := fnd_api.g_ret_sts_success;
3573
3574 IF (l_debug = 1) THEN
3575 print_debug('Entering create_rma_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3576 END IF;
3577
3578 l_progress := '10';
3579
3580 BEGIN
3581 inv_rcv_common_apis.init_startup_values(p_organization_id);
3582 EXCEPTION
3583 WHEN NO_DATA_FOUND THEN
3584 fnd_message.set_name('INV', 'INV_RCV_PARAM');
3585 fnd_msg_pub.ADD;
3586 RAISE;
3587 END;
3588
3589 l_progress := '20';
3590
3591 -- default l_group_id ?? clear group id after done
3592 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
3593 SELECT rcv_interface_groups_s.NEXTVAL
3594 INTO l_group_id
3595 FROM DUAL;
3596
3597 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
3598 ELSE
3599 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
3600 END IF;
3601
3602 l_progress := '30';
3603 -- call matching algorithm
3604 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).GROUP_ID := l_group_id;
3605 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).transaction_type := l_transaction_type;
3606 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).quantity := p_rcvtxn_qty;
3607 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).unit_of_measure := p_rcvtxn_uom;
3608 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id := p_item_id;
3609 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).revision := p_revision; -- 2252193
3610 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).oe_order_header_id := p_oe_order_header_id;
3611 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).oe_order_line_id := p_oe_order_line_id;
3612 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).to_organization_id := p_organization_id;
3613 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).customer_id := p_customer_id;
3614 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).p_lpn_id := p_lpn_id;
3615 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).expected_receipt_date := SYSDATE; --?
3616 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).tax_amount := 0; -- ?
3617 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status := 'S'; -- ?
3618 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).inspection_status_code := p_inspection_status_code;
3619
3620 /* FP-J Lot/Serial Support Enhancement
3621 * If INV and PO J are installed, then the lots for the parent transaction will
3622 * be stored in rcv_lots_supply. We must match the lot number passed with that
3623 * of the parent transaction and also the parent_txn_id
3624 */
3625 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3626 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3627 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := p_lot_number;
3628 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := p_parent_txn_id;
3629 ELSE
3630 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).lot_number := NULL;
3631 g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).parent_transaction_id := NULL;
3632 END IF;
3633
3634 BEGIN
3635 SELECT primary_unit_of_measure
3636 INTO g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).primary_unit_of_measure
3637 FROM mtl_system_items
3638 WHERE mtl_system_items.inventory_item_id = p_item_id
3639 AND mtl_system_items.organization_id = p_organization_id;
3640 EXCEPTION
3641 WHEN NO_DATA_FOUND THEN
3642 NULL;
3643 END;
3644
3645 l_progress := '40';
3646
3647 IF (l_debug = 1) THEN
3648 print_debug('Parameters to matching logic 40', 4);
3649 print_debug('40.1 quantity ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).quantity, 4);
3650 print_debug('40.2 item_id ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).item_id, 4);
3651 print_debug('40.3 oe_order_header_id ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).oe_order_header_id, 4);
3652 print_debug('40.4 oe_order_line_id ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).oe_order_line_id, 4);
3653 print_debug('40.5 to_organization_id ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).to_organization_id, 4);
3654 print_debug('40.6 customer_id ' || g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).customer_id, 4);
3655 print_debug('40.6 n ' || g_rcvtxn_detail_index, 4);
3656 END IF;
3657
3658 inv_rcv_txn_match.matching_logic(
3659 x_return_status => x_status
3660 , --?
3661 x_msg_count => l_msg_count
3662 , x_msg_data => x_message
3663 , x_cascaded_table => g_rcvtxn_match_table_gross
3664 , n => g_rcvtxn_detail_index
3665 , temp_cascaded_table => l_rcvtxn_match_table_detail
3666 , p_receipt_num => p_receipt_num
3667 , p_match_type => 'RMA'
3668 , p_lpn_id => NULL
3669 );
3670
3671 -- x_status is not successful if there is any execution error in matching.
3672 IF x_status <> fnd_api.g_ret_sts_success THEN
3673 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3674 fnd_msg_pub.ADD;
3675
3676 IF (l_debug = 1) THEN
3677 print_debug('Exiting create_rma_rcvtxn_intf_rec 20:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3678 END IF;
3679
3680 RETURN;
3681 END IF;
3682
3683 IF g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_status = 'E' THEN
3684 x_status := fnd_api.g_ret_sts_error;
3685 l_err_message := g_rcvtxn_match_table_gross(g_rcvtxn_detail_index).error_message;
3686 fnd_message.set_name('INV', l_err_message);
3687 fnd_msg_pub.ADD;
3688
3689 IF (l_debug = 1) THEN
3690 print_debug('exiting create_rma_rcvtxn_intf_rec 30:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3691 END IF;
3692
3693 RETURN;
3694 END IF;
3695
3696 l_err_message := '@@@';
3697
3698 FOR i IN g_rcvtxn_detail_index ..(g_rcvtxn_detail_index + l_rcvtxn_match_table_detail.COUNT - 1) LOOP
3699 IF l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_status = 'W' THEN
3700 x_status := 'W';
3701 l_temp_message := l_rcvtxn_match_table_detail(i - g_rcvtxn_detail_index + 1).error_message;
3702
3703 IF l_temp_message IS NULL THEN
3704 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3705 l_msg_prod := 'INV';
3706 EXIT;
3707 END IF;
3708
3709 IF l_err_message = '@@@' THEN
3710 l_err_message := l_temp_message;
3711 l_msg_prod := 'INV';
3712 ELSIF l_temp_message <> l_err_message THEN
3713 l_msg_prod := 'INV';
3714 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3715 EXIT;
3716 END IF;
3717 END IF;
3718 END LOOP;
3719
3720 IF l_err_message <> '@@@' THEN
3721 fnd_message.set_name(l_msg_prod, l_err_message);
3722 fnd_msg_pub.ADD;
3723
3724 IF (l_debug = 1) THEN
3725 print_debug('adding tolerance message create_rma_rcvtxn_intf_rec 40:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3726 END IF;
3727 END IF;
3728
3729 l_progress := '50';
3730 -- based on return from matching algorithm,
3731 -- determine which line in rcv_transaction block to be inserted into RTI
3732
3733 l_progress := '60';
3734
3735 IF (l_debug = 1) THEN
3736 print_debug('create_rma_rcvtxn_intf_rec no recs matched by matching 50:' || l_rcvtxn_match_table_detail.COUNT, 4);
3737 END IF;
3738
3739 -- loop through results returned by matching algorithm
3740 FOR match_result_count IN 1 .. l_rcvtxn_match_table_detail.COUNT LOOP
3741 IF (l_debug = 1) THEN
3742 print_debug('create_rma_rcvtxn_intf_rec found a match 60', 4);
3743 print_debug('Matching returned values 60.1 - oe_order_line_id:' || l_rcvtxn_match_table_detail(match_result_count).oe_order_line_id, 4);
3744 print_debug('Matching returned values 60.1 - rcv_transaction_id:' || l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id, 4);
3745 print_debug('Matching returned values 60.1 - transaction_quantity:' || l_rcvtxn_match_table_detail(match_result_count).quantity, 4);
3746 print_debug('Matching returned values 60.1 - transaction_uom:' || l_rcvtxn_match_table_detail(match_result_count).unit_of_measure, 4);
3747 print_debug('Matching returned values 60.1 - primary_quantity:' || l_rcvtxn_match_table_detail(match_result_count).primary_quantity, 4);
3748 print_debug('Matching returned values 60.1 - primary_uom:' || l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure, 4);
3749 END IF;
3750
3751 OPEN l_curs_rcvtxn_detail(
3752 l_rcvtxn_match_table_detail(match_result_count).oe_order_line_id
3753 , l_rcvtxn_match_table_detail(match_result_count).parent_transaction_id);
3754 FETCH l_curs_rcvtxn_detail INTO l_rcv_rcvtxn_rec;
3755 CLOSE l_curs_rcvtxn_detail;
3756 -- update following fields from matching algorithm return value
3757 -- Bug No 1823328 Changes
3758 l_rcv_transaction_rec.oe_order_line_id := l_rcvtxn_match_table_detail(match_result_count).oe_order_line_id;
3759 --
3760
3761 --R12: create RTI with uom entered by user
3762 l_prim_uom_code := inv_rcv_cache.get_primary_uom_code(p_organization_id,p_item_id);
3763
3764 IF (p_rcvtxn_uom_code IS NULL) THEN
3765 SELECT uom_code
3766 INTO l_rcvtxn_uom_code
3767 FROM mtl_item_uoms_view
3768 WHERE organization_id = p_organization_id
3769 AND inventory_item_id = p_item_id
3770 AND unit_of_measure = p_rcvtxn_uom
3771 AND ROWNUM < 2;
3772 ELSE
3773 l_rcvtxn_uom_code := p_rcvtxn_uom_code;
3774 END IF;
3775
3776 IF (l_rcvtxn_uom_code <> l_prim_uom_code) THEN
3777 l_rcv_transaction_rec.transaction_quantity := inv_rcv_cache.Convert_qty
3778 (p_inventory_item_id => p_item_id
3779 ,p_from_qty => l_rcvtxn_match_table_detail(match_result_count).primary_quantity
3780 ,p_from_uom_code => l_prim_uom_code
3781 ,p_to_uom_code => l_rcvtxn_uom_code);
3782 l_rcv_transaction_rec.transaction_uom := p_rcvtxn_uom;
3783 ELSE
3784 l_rcv_transaction_rec.transaction_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
3785 l_rcv_transaction_rec.transaction_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
3786 END IF;
3787
3788 IF (l_debug = 1) THEN
3789 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_quantity :' ||l_rcv_transaction_rec.transaction_quantity , 4);
3790 print_debug('Matching returned values 60.1 - l_rcv_transaction_rec.transaction_uom :' ||l_rcv_transaction_rec.transaction_uom, 4);
3791 END IF;
3792 --R12 END
3793
3794 l_rcv_transaction_rec.primary_quantity := l_rcvtxn_match_table_detail(match_result_count).primary_quantity;
3795 l_rcv_transaction_rec.primary_uom := l_rcvtxn_match_table_detail(match_result_count).primary_unit_of_measure;
3796 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3797
3798 -- Start Bug 10161177 change
3799 -- Passing the secondary quantity values entered by the user only when the
3800 -- matching logic returns 1 row i.e. one RTI record is created
3801
3802 IF (l_rcvtxn_match_table_detail.COUNT = 1) THEN
3803
3804 IF (l_debug = 1) THEN
3805 print_debug('60.1 - p_sec_rcvtxn_qty : ' || p_sec_rcvtxn_qty, 4);
3806 print_debug('60.1 - p_secondary_uom : ' || p_secondary_uom, 4);
3807 END IF;
3808
3809 l_rcv_transaction_rec.sec_transaction_quantity := p_sec_rcvtxn_qty;
3810 l_rcv_transaction_rec.secondary_uom_code := p_secondary_uom;
3811
3812 END IF;
3813 -- End Bug 10161177 change
3814
3815 l_progress := '70';
3816
3817 -- Only call split mo if J or higher
3818 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3819 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3820 -- Added addition check for p_original_txn_temp_id: if it is null,
3821 -- then simply insert RTI with the MMTT column as null
3822 IF p_original_txn_temp_id IS NULL OR l_rcvtxn_match_table_detail.COUNT = 1 THEN
3823 l_new_txn_temp_id := p_original_txn_temp_id;
3824 ELSE --More than 1 result returned from matching logic
3825 -- Call split mo
3826 IF (l_debug = 1) THEN
3827 print_debug('create_rma_rcvtxn_intf_rec calling split_mo',4);
3828 END IF;
3829
3830 IF (l_orig_mol_id IS NULL) THEN
3831 BEGIN
3832 SELECT move_order_line_id
3833 INTO l_orig_mol_id
3834 FROM mtl_material_transactions_temp
3835 WHERE transaction_temp_id = p_original_txn_temp_id;
3836 EXCEPTION
3837 WHEN OTHERS THEN
3838 IF (l_debug = 1) THEN
3839 print_debug('create_rma_rcvtxn_intf_rec: Error retrieving MOL id',4);
3840 END IF;
3841 RAISE fnd_api.g_exc_error;
3842 END;
3843 END IF; --IF (l_orig_mol_id IS NULL) THEN
3844
3845 l_mo_splt_tb(1).prim_qty := l_rcv_transaction_rec.primary_quantity;
3846 l_mo_splt_tb(1).line_id := NULL;
3847
3848 IF (l_debug = 1) THEN
3849 print_debug('create_rma_rcvtxn_intf_rec: Calling split_mo',4);
3850 print_debug(' (p_orig_mol_id ====> ' || l_orig_mol_id,4);
3851 print_debug(' (p_mo_splt_tb.prim_qty ==> ' || l_mo_splt_tb(1).prim_qty,4);
3852 print_debug(' (p_operation_type => ' || 'DELIVER',4);
3853 print_debug(' (p_txn_header_id => ' || p_original_txn_temp_id,4);
3854 END IF;
3855
3856 inv_rcv_integration_apis.split_mo
3857 (p_orig_mol_id => l_orig_mol_id,
3858 p_mo_splt_tb => l_mo_splt_tb,
3859 p_operation_type => 'DELIVER',
3860 p_txn_header_id => p_original_txn_temp_id,
3861 x_return_status => l_return_status,
3862 x_msg_count => l_msg_count,
3863 x_msg_data => x_message);
3864
3865 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
3866 RAISE fnd_api.g_exc_error;
3867 END IF;
3868 l_progress := '75';
3869
3870 BEGIN
3871 SELECT transaction_temp_id
3872 INTO l_new_txn_temp_id
3873 FROM mtl_material_transactions_temp
3874 WHERE move_order_line_id = l_mo_splt_tb(1).line_id;
3875 EXCEPTION
3876 WHEN OTHERS THEN
3877 IF (l_debug = 1) THEN
3878 print_debug('create_rma_rcvtxn_intf_rec: Error retrieving new mmtt id',4);
3879 END IF;
3880 END;
3881 END IF; --l_rcvtxn_match_table_detail.COUNT = 1
3882 ELSE -- If lower than J
3883 l_new_txn_temp_id := p_original_txn_temp_id;
3884 END IF; -- IF Patchset J
3885
3886 IF (l_debug = 1) THEN
3887 print_debug('create_rma_rcvtxn_intf_rec RTI to be inserted with mmtt id: ' ||
3888 l_new_txn_temp_id || ' p_transaction_temp_id = ' ||
3889 p_transaction_temp_id,4);
3890 END IF;
3891
3892 --dbms_output.put_line('Got a match');
3893 populate_default_values(
3894 p_rcv_transaction_rec => l_rcv_transaction_rec
3895 , p_rcv_rcvtxn_rec => l_rcv_rcvtxn_rec
3896 , p_organization_id => p_organization_id
3897 , p_item_id => p_item_id
3898 , p_revision => p_revision
3899 , p_subinventory_code => p_subinventory_code
3900 , p_locator_id => p_locator_id
3901 , p_transaction_temp_id => p_transaction_temp_id
3902 , p_lot_control_code => p_lot_control_code
3903 , p_serial_control_code => p_serial_control_code
3904 , p_original_txn_temp_id => l_new_txn_temp_id
3905 , p_lpn_id => p_lpn_id
3906 , p_transfer_lpn_id => p_transfer_lpn_id
3907 );
3908
3909 l_progress := '80';
3910
3911 /* FP-J Lot/Serial Support Enhancement
3912 * Populate the table to store the information of the RTIs created used for
3913 * splitting the lots and serials based on RTI quantity
3914 */
3915 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3916 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3917 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
3918 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
3919 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_quantity;
3920 IF (l_debug = 1) THEN
3921 print_debug('create_rma_rcvtxn_intf_rec 64 - Populated the table for lot/serial split', 4);
3922 END IF;
3923 END IF; --END IF populate the table to store RTI info that was just created
3924 END LOOP;
3925
3926 --g_rcvtxn_detail_index := l_rcvtxn_match_table_detail.COUNT + g_rcvtxn_detail_index;
3927 IF l_curs_rcvtxn_detail%ISOPEN THEN
3928 CLOSE l_curs_rcvtxn_detail;
3929 END IF;
3930
3931 /* FP-J Lot/Serial Support Enhancement
3932 * Call the split_lot API to split the lots and serials inserted from the UI
3933 * based on the quantity of each RTI record
3934 */
3935 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3936 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3937 IF (p_lot_control_code > 1 OR p_serial_control_code > 1) THEN
3938
3939 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
3940 p_api_version => 1.0
3941 , p_init_msg_lst => FND_API.G_FALSE
3942 , x_return_status => l_return_status
3943 , x_msg_count => l_msg_count
3944 , x_msg_data => x_message
3945 , p_new_rti_info => l_new_rti_info);
3946 IF ( NOT l_split_lot_serial_ok) THEN
3947 IF (l_debug = 1) THEN
3948 print_debug('create_rma_rcvtxn_intf_rec 65: Failure in split_lot_serial', 4);
3949 END IF;
3950 RAISE FND_API.G_EXC_ERROR;
3951 END IF;
3952
3953 IF (l_debug = 1) THEN
3954 print_debug('create_rma_rcvtxn_intf_rec 66: Call split_lot_serial is OK', 4);
3955 END IF;
3956 END IF; --END IF check lot and serial controls
3957 END IF; --END IF check INV J and PO J installed
3958
3959 l_progress := '90';
3960 inv_rcv_common_apis.do_check(
3961 p_organization_id => p_organization_id
3962 , p_inventory_item_id => p_item_id
3963 , p_transaction_type_id => 15
3964 , p_primary_quantity => l_total_primary_qty
3965 , x_return_status => l_return_status
3966 , x_msg_count => l_msg_count
3967 , x_msg_data => x_message
3968 );
3969
3970 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3971 x_status := l_return_status;
3972 END IF;
3973
3974 l_progress := '100';
3975
3976 IF (l_debug = 1) THEN
3977 print_debug('Exiting create_rma_rcvtxn_intf_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3978 END IF;
3979 EXCEPTION
3980 WHEN OTHERS THEN
3981 x_status := fnd_api.g_ret_sts_unexp_error;
3982
3983 IF l_curs_rcvtxn_detail%ISOPEN THEN
3984 CLOSE l_curs_rcvtxn_detail;
3985 END IF;
3986
3987 IF SQLCODE IS NOT NULL THEN
3988 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_rma_rcvtxn_intf_rec', l_progress, SQLCODE);
3989 END IF;
3990
3991 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3992 END create_rma_rcvtxn_intf_rec;
3993
3994 PROCEDURE create_rpt_num_rcvtxn_intf_rec(
3995 p_organization_id IN NUMBER
3996 , p_receipt_num IN VARCHAR2
3997 , p_shipment_header_id IN NUMBER
3998 , p_item_id IN NUMBER
3999 , p_source_id IN NUMBER
4000 , p_revision IN VARCHAR2
4001 , p_subinventory_code IN VARCHAR2
4002 , p_locator_id IN NUMBER
4003 , p_rcvtxn_qty IN NUMBER
4004 , p_rcvtxn_uom IN VARCHAR2
4005 , p_transaction_temp_id IN NUMBER
4006 , p_lot_control_code IN NUMBER
4007 , p_serial_control_code IN NUMBER
4008 , x_status OUT NOCOPY VARCHAR2
4009 , x_message OUT NOCOPY VARCHAR2
4010 , p_deliver_to_location_id IN NUMBER DEFAULT NULL
4011 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
4012 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
4013 , p_inspection_status_code IN VARCHAR2 DEFAULT NULL --BUG 4309432
4014 ) IS
4015 l_po_header_id NUMBER;
4016 l_oe_order_header_id NUMBER;
4017 l_progress VARCHAR2(10);
4018 l_msg_count NUMBER;
4019
4020 --BUG 3444177: query against the base tables instead
4021 -- of using the view.
4022 CURSOR l_curs_rcvtxn_detail IS
4023 SELECT rsup.po_header_id po_header_id
4024 ,rsup.oe_order_header_id oe_order_header_id
4025 FROM rcv_shipment_headers rsh
4026 ,rcv_supply rsup
4027 WHERE rsh.receipt_num = p_receipt_num
4028 AND rsh.shipment_header_id = rsup.shipment_header_id
4029 AND rsup.to_organization_id = p_organization_id
4030 AND rsup.item_id = p_item_id
4031 AND Nvl(rsup.ITEM_REVISION, '@@##') = Nvl(p_revision, '@@##'); /* Bug 13598673 to pick right po_header_id*/
4032
4033
4034 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4035 BEGIN
4036 x_status := fnd_api.g_ret_sts_success;
4037 l_progress := '10';
4038
4039 IF (l_debug = 1) THEN
4040 print_debug('create_rpt_num_rcvtxn_intf_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4041 END IF;
4042
4043 OPEN l_curs_rcvtxn_detail;
4044 FETCH l_curs_rcvtxn_detail INTO l_po_header_id, l_oe_order_header_id;
4045 CLOSE l_curs_rcvtxn_detail;
4046 l_progress := '20';
4047
4048 IF l_po_header_id IS NOT NULL THEN
4049 l_progress := '30';
4050
4051 IF (l_debug = 1) THEN
4052 print_debug('create_rpt_num_rcvtxn_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4053 END IF;
4054
4055 create_po_rcvtxn_intf_rec(
4056 p_organization_id => p_organization_id
4057 , p_po_header_id => l_po_header_id
4058 , p_po_release_id => NULL
4059 , p_po_line_id => NULL
4060 , p_po_line_location_id => NULL
4061 , p_receipt_num => p_receipt_num
4062 , p_item_id => p_item_id
4063 , p_vendor_id => p_source_id
4064 , p_revision => p_revision
4065 , p_subinventory_code => p_subinventory_code
4066 , p_locator_id => p_locator_id
4067 , p_rcvtxn_qty => p_rcvtxn_qty
4068 , p_rcvtxn_uom => p_rcvtxn_uom
4069 , p_transaction_temp_id => p_transaction_temp_id
4070 , p_lot_control_code => p_lot_control_code
4071 , p_serial_control_code => p_serial_control_code
4072 , x_status => x_status
4073 , x_message => x_message
4074 , p_inspection_status_code => p_inspection_status_code --BUG 4309432
4075 , p_lpn_id => NULL
4076 , p_transfer_lpn_id => NULL
4077 , p_lot_number => NULL
4078 , p_deliver_to_location_id => p_deliver_to_location_id
4079 );
4080
4081 IF x_status = fnd_api.g_ret_sts_error THEN
4082 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4083 fnd_msg_pub.ADD;
4084
4085 IF (l_debug = 1) THEN
4086 print_debug('create_rpt_num_rcvtxn_intf_rec 20.1: RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4087 END IF;
4088
4089 RAISE fnd_api.g_exc_error;
4090 END IF;
4091
4092 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4093 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4094 fnd_msg_pub.ADD;
4095
4096 IF (l_debug = 1) THEN
4097 print_debug('create_rpt_num_rcvtxn_intf_rec 20.2: FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4098 END IF;
4099
4100 RAISE fnd_api.g_exc_unexpected_error;
4101 END IF;
4102 ELSIF l_oe_order_header_id IS NOT NULL THEN
4103 l_progress := '40';
4104
4105 IF (l_debug = 1) THEN
4106 print_debug('create_rpt_num_rcvtxn_intf_rec: 30 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4107 END IF;
4108
4109 create_rma_rcvtxn_intf_rec(
4110 p_organization_id => p_organization_id
4111 , p_oe_order_header_id => l_oe_order_header_id
4112 , p_oe_order_line_id => NULL
4113 , p_receipt_num => p_receipt_num
4114 , p_item_id => p_item_id
4115 , p_customer_id => p_source_id
4116 , p_revision => p_revision
4117 , p_subinventory_code => p_subinventory_code
4118 , p_locator_id => p_locator_id
4119 , p_rcvtxn_qty => p_rcvtxn_qty
4120 , p_rcvtxn_uom => p_rcvtxn_uom
4121 , p_transaction_temp_id => p_transaction_temp_id
4122 , p_lot_control_code => p_lot_control_code
4123 , p_serial_control_code => p_serial_control_code
4124 , x_status => x_status
4125 , x_message => x_message
4126 , p_inspection_status_code => NULL
4127 , p_lpn_id => NULL
4128 , p_transfer_lpn_id => NULL
4129 , p_lot_number => NULL
4130 );
4131
4132 IF x_status = fnd_api.g_ret_sts_error THEN
4133 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
4134 fnd_msg_pub.ADD;
4135
4136 IF (l_debug = 1) THEN
4137 print_debug('create_rpt_num_rcvtxn_intf_rec 30.1: RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4138 END IF;
4139
4140 RAISE fnd_api.g_exc_error;
4141 END IF;
4142
4143 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4144 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
4145 fnd_msg_pub.ADD;
4146
4147 IF (l_debug = 1) THEN
4148 print_debug('create_rpt_num_rcvtxn_intf_rec 30.2: FND_API.G_EXC_UNEXPECTED_ERROR;'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4149 END IF;
4150
4151 RAISE fnd_api.g_exc_unexpected_error;
4152 END IF;
4153 ELSE
4154 l_progress := '50';
4155
4156 IF (l_debug = 1) THEN
4157 print_debug('create_rpt_num_rcvtxn_intf_rec: 40 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4158 END IF;
4159
4160 create_int_shp_rcvtxn_intf_rec(
4161 p_organization_id => p_organization_id
4162 , p_shipment_header_id => p_shipment_header_id
4163 , p_shipment_line_id => NULL
4164 , p_receipt_num => p_receipt_num
4165 , p_item_id => p_item_id
4166 , p_source_id => p_source_id
4167 , p_revision => p_revision
4168 , p_subinventory_code => p_subinventory_code
4169 , p_locator_id => p_locator_id
4170 , p_rcvtxn_qty => p_rcvtxn_qty
4171 , p_rcvtxn_uom => p_rcvtxn_uom
4172 , p_transaction_temp_id => p_transaction_temp_id
4173 , p_lot_control_code => p_lot_control_code
4174 , p_serial_control_code => p_serial_control_code
4175 , x_status => x_status
4176 , x_message => x_message
4177 , p_inspection_status_code => NULL
4178 , p_lpn_id => NULL
4179 , p_transfer_lpn_id => NULL
4180 , p_lot_number => NULL
4181 );
4182
4183 IF x_status = fnd_api.g_ret_sts_error THEN
4184 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
4185 fnd_msg_pub.ADD;
4186
4187 IF (l_debug = 1) THEN
4188 print_debug('create_rpt_num_rcvtxn_intf_rec 40.1: RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4189 END IF;
4190
4191 RAISE fnd_api.g_exc_error;
4192 END IF;
4193
4194 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4195 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
4196 fnd_msg_pub.ADD;
4197
4198 IF (l_debug = 1) THEN
4199 print_debug('create_rpt_num_rcvtxn_intf_rec 40.2: FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4200 END IF;
4201
4202 RAISE fnd_api.g_exc_unexpected_error;
4203 END IF;
4204 END IF;
4205
4206 l_progress := '60';
4207
4208 IF (l_debug = 1) THEN
4209 print_debug('create_rpt_num_rcvtxn_intf_rec exitting: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4210 END IF;
4211 EXCEPTION
4212 WHEN fnd_api.g_exc_error THEN
4213 x_status := fnd_api.g_ret_sts_error;
4214
4215 IF l_curs_rcvtxn_detail%ISOPEN THEN
4216 CLOSE l_curs_rcvtxn_detail;
4217 END IF;
4218
4219 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4220 WHEN fnd_api.g_exc_unexpected_error THEN
4221 x_status := fnd_api.g_ret_sts_unexp_error;
4222
4223 IF l_curs_rcvtxn_detail%ISOPEN THEN
4224 CLOSE l_curs_rcvtxn_detail;
4225 END IF;
4226
4227 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4228 WHEN OTHERS THEN
4229 x_status := fnd_api.g_ret_sts_unexp_error;
4230
4231 IF l_curs_rcvtxn_detail%ISOPEN THEN
4232 CLOSE l_curs_rcvtxn_detail;
4233 END IF;
4234
4235 IF SQLCODE IS NOT NULL THEN
4236 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_rpt_num_rcvtxn_intf_rec', l_progress, SQLCODE);
4237 END IF;
4238
4239 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4240 END;
4241
4242 PROCEDURE create_osp_std_rcvtxn_intf_rec(
4243 p_organization_id IN NUMBER
4244 , p_po_header_id IN NUMBER
4245 , p_po_release_id IN NUMBER
4246 , p_po_line_id IN NUMBER
4247 , p_po_distribution_id IN NUMBER
4248 , p_item_id IN NUMBER
4249 , p_vendor_id IN NUMBER
4250 , p_revision IN VARCHAR2
4251 , p_rcvtxn_qty IN NUMBER
4252 , p_rcvtxn_uom IN VARCHAR2
4253 , p_transaction_temp_id IN NUMBER
4254 , x_status OUT NOCOPY VARCHAR2
4255 , x_message OUT NOCOPY VARCHAR2
4256 , p_secondary_qty IN NUMBER DEFAULT NULL --OPM Convergence
4257 ) IS
4258 l_progress VARCHAR2(10);
4259 l_msg_count NUMBER;
4260 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4261 l_msg_data VARCHAR2(400);
4262 l_label_status VARCHAR2(500);
4263 l_txn_id_tbl inv_label.transaction_id_rec_type;
4264 l_counter NUMBER := 0;
4265
4266 CURSOR c_rti_txn_id IS
4267 /* Bug 2443163 */
4268 /* SELECT MIN(rti.interface_transaction_id) */
4269 SELECT MAX(rti.interface_transaction_id)
4270 FROM rcv_transactions_interface rti
4271 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4272 GROUP BY rti.lpn_id;
4273
4274 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4275 BEGIN
4276 x_status := fnd_api.g_ret_sts_success;
4277 l_progress := '10';
4278
4279 IF (l_debug = 1) THEN
4280 print_debug('create_osp_std_rcvtxn_intf_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4281 END IF;
4282
4283 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
4284 --BUG 3444177: User HOR for performance reasons
4285 SELECT TO_NUMBER(hoi.org_information1)
4286 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
4287 FROM hr_organization_information hoi
4288 WHERE hoi.organization_id = p_organization_id
4289 AND (hoi.org_information_context || '') = 'Accounting Information' ;
4290 END IF;
4291
4292 l_progress := '20';
4293 -- first check if the transaction date satisfies the validation.
4294 inv_rcv_common_apis.validate_trx_date(
4295 p_trx_date => SYSDATE
4296 , p_organization_id => p_organization_id
4297 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
4298 , x_return_status => x_status
4299 , x_error_code => x_message
4300 );
4301
4302 IF x_status <> fnd_api.g_ret_sts_success THEN
4303 RETURN;
4304 END IF;
4305
4306 l_progress := '30';
4307
4308 IF p_po_header_id IS NOT NULL THEN
4309 l_progress := '40';
4310
4311 IF (l_debug = 1) THEN
4312 print_debug('create_osp_std_rcvtxn_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4313 END IF;
4314
4315 create_osp_po_rcvtxn_intf_rec(
4316 p_organization_id => p_organization_id
4317 , p_po_header_id => p_po_header_id
4318 , p_po_release_id => p_po_release_id
4319 , p_po_line_id => p_po_line_id
4320 , p_po_line_location_id => NULL
4321 , p_po_distribution_id => p_po_distribution_id
4322 , p_item_id => p_item_id
4323 , p_vendor_id => p_vendor_id
4324 , p_revision => p_revision
4325 , p_rcvtxn_qty => p_rcvtxn_qty
4326 , p_rcvtxn_uom => p_rcvtxn_uom
4327 , p_transaction_temp_id => p_transaction_temp_id
4328 , x_status => x_status
4329 , x_message => x_message
4330 , p_inspection_status_code => NULL
4331 );
4332
4333 IF x_status = fnd_api.g_ret_sts_error THEN
4334 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4335 fnd_msg_pub.ADD;
4336
4337 IF (l_debug = 1) THEN
4338 print_debug('create_osp_std_rcvtxn_intf_rec 20.1: create_osp_po_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4339 END IF;
4340
4341 RAISE fnd_api.g_exc_error;
4342 END IF;
4343
4344 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4345 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4346 fnd_msg_pub.ADD;
4347
4348 IF (l_debug = 1) THEN
4349 print_debug('create_osp_std_rcvtxn_intf_rec 20.2: create_osp_po_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4350 END IF;
4351
4352 RAISE fnd_api.g_exc_unexpected_error;
4353 END IF;
4354 END IF;
4355
4356 l_progress := '80';
4357
4358 IF (l_debug = 1) THEN
4359 print_debug('create_osp_std_rcvtxn_intf_rec exitting: 60' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4360 END IF;
4361
4362 -- calling label printing API
4363 IF x_status <> fnd_api.g_ret_sts_error THEN
4364 IF (l_debug = 1) THEN
4365 print_debug('create_osp_std_rcpt_intf_rec: 8.1 before inv_label.print_label ', 4);
4366 END IF;
4367
4368 /* FP-J Lot/Serial Support Enhancement
4369 * If INV J and PO J are installed, do not call label printing API at this stage
4370 */
4371 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
4372 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
4373 l_counter := 1;
4374 OPEN c_rti_txn_id;
4375
4376 LOOP
4377 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
4378 EXIT WHEN c_rti_txn_id%NOTFOUND;
4379 l_counter := l_counter + 1;
4380 END LOOP;
4381
4382 CLOSE c_rti_txn_id;
4383 inv_label.print_label(
4384 x_return_status => l_return_status
4385 , x_msg_count => l_msg_count
4386 , x_msg_data => l_msg_data
4387 , x_label_status => l_label_status
4388 , p_api_version => 1.0
4389 , p_print_mode => 1
4390 , p_business_flow_code => 3
4391 , p_transaction_id => l_txn_id_tbl
4392 );
4393
4394 IF l_return_status <> fnd_api.g_ret_sts_success THEN
4395 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
4396 fnd_msg_pub.ADD;
4397 x_status := 'W';
4398
4399 IF (l_debug = 1) THEN
4400 print_debug('create_osp_std_rcpt_intf_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4401 , 4);
4402 END IF;
4403 END IF;
4404 ELSE
4405 IF (l_debug = 1) THEN
4406 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
4407 END IF;
4408 END IF; --END IF check INV and PO patch levels
4409 END IF; --END IF check ret status
4410 EXCEPTION
4411 WHEN fnd_api.g_exc_error THEN
4412 x_status := fnd_api.g_ret_sts_error;
4413 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4414 WHEN fnd_api.g_exc_unexpected_error THEN
4415 x_status := fnd_api.g_ret_sts_unexp_error;
4416 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4417 WHEN OTHERS THEN
4418 x_status := fnd_api.g_ret_sts_unexp_error;
4419
4420 IF SQLCODE IS NOT NULL THEN
4421 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_osp_std_rcvtxn_intf_rec', l_progress, SQLCODE);
4422 END IF;
4423
4424 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4425 END create_osp_std_rcvtxn_intf_rec;
4426
4427 PROCEDURE create_std_rcvtxn_intf_rec(
4428 p_organization_id IN NUMBER
4429 , p_po_header_id IN NUMBER
4430 , p_po_release_id IN NUMBER
4431 , p_po_line_id IN NUMBER
4432 , p_shipment_header_id IN NUMBER
4433 , p_oe_order_header_id IN NUMBER
4434 , p_receipt_num IN VARCHAR2
4435 , p_item_id IN NUMBER
4436 , p_vendor_id IN NUMBER
4437 , p_revision IN VARCHAR2
4438 , p_subinventory_code IN VARCHAR2
4439 , p_locator_id IN NUMBER
4440 , p_rcvtxn_qty IN NUMBER
4441 , p_rcvtxn_uom IN VARCHAR2
4442 , p_transaction_temp_id IN NUMBER
4443 , p_lot_control_code IN NUMBER
4444 , p_serial_control_code IN NUMBER
4445 , x_status OUT NOCOPY VARCHAR2
4446 , x_message OUT NOCOPY VARCHAR2
4447 , p_deliver_to_location_id IN NUMBER DEFAULT NULL
4448 , p_sec_rcvtxn_qty IN NUMBER DEFAULT NULL --OPM Convergence
4449 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPMConvergence
4450 , p_rcv_act_rjt_qty_type IN NUMBER DEFAULT NULL --BUG 4309432
4451 ) IS
4452 l_progress VARCHAR2(10);
4453 l_msg_count NUMBER;
4454 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4455 l_msg_data VARCHAR2(400);
4456 l_label_status VARCHAR2(500);
4457 l_txn_id_tbl inv_label.transaction_id_rec_type;
4458 l_counter NUMBER := 0;
4459 l_inspection_status_code VARCHAR2(30); --Bug 4309432
4460
4461 CURSOR c_rti_txn_id IS
4462 /* Bug 2443163 */
4463 /* SELECT MIN(rti.interface_transaction_id) */
4464 SELECT MAX(rti.interface_transaction_id)
4465 FROM rcv_transactions_interface rti
4466 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4467 GROUP BY rti.lpn_id;
4468
4469 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4470 BEGIN
4471 x_status := fnd_api.g_ret_sts_success;
4472 l_progress := '10';
4473
4474 IF (l_debug = 1) THEN
4475 print_debug('create_std_rcvtxn_intf_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4476 print_debug(' p_rcv_act_rjt_qty_type => '||p_rcv_act_rjt_qty_type,1);
4477 END IF;
4478
4479 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
4480 --BUG 3444177: User HOR for performance reasons
4481 SELECT TO_NUMBER(hoi.org_information1)
4482 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
4483 FROM hr_organization_information hoi
4484 WHERE hoi.organization_id = p_organization_id
4485 AND (hoi.org_information_context || '') = 'Accounting Information' ;
4486 END IF;
4487
4488 l_progress := '20';
4489 -- first check if the transaction date satisfies the validation.
4490 inv_rcv_common_apis.validate_trx_date(
4491 p_trx_date => SYSDATE
4492 , p_organization_id => p_organization_id
4493 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
4494 , x_return_status => x_status
4495 , x_error_code => x_message
4496 );
4497
4498 IF x_status <> fnd_api.g_ret_sts_success THEN
4499 RETURN;
4500 END IF;
4501
4502 l_progress := '30';
4503
4504 --Bug 4309432, p_rcv_act_rjt_qty_type will be passed from the MSCA deliver page if
4505 --the routing is Inspection. Based on this value setting the l_inspection_status_code
4506 --which will be finally passed to matching_logic api to respective accepted qty or rejected qty.
4507 IF p_rcv_act_rjt_qty_type = 1 THEN
4508 l_inspection_status_code := 'ACCEPTED';
4509 ELSIF p_rcv_act_rjt_qty_type = 2 THEN
4510 l_inspection_status_code := NULL;
4511 ELSIF p_rcv_act_rjt_qty_type = 3 THEN
4512 l_inspection_status_code := 'REJECTED';
4513 ELSE
4514 l_inspection_status_code := NULL;
4515 END IF;
4516
4517 IF (l_debug = 1) THEN
4518 print_debug('l_inspection_status_code: ' || l_inspection_status_code, 1);
4519 END IF;
4520
4521 --Bug 11887570 The interface records should be created based on po header id only when the receipt num is null.
4522 --Otherwise the receipt num,item combination should find all the valid POs attached to the receipt to Match.
4523 IF p_po_header_id IS NOT NULL AND p_receipt_num IS NULL THEN
4524 l_progress := '40';
4525
4526 IF (l_debug = 1) THEN
4527 print_debug('create_std_rcvtxn_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4528 END IF;
4529
4530 create_po_rcvtxn_intf_rec(
4531 p_organization_id => p_organization_id
4532 , p_po_header_id => p_po_header_id
4533 , p_po_release_id => p_po_release_id
4534 , p_po_line_id => p_po_line_id
4535 , p_po_line_location_id => NULL
4536 , p_receipt_num => p_receipt_num -- bug 7243023
4537 , p_item_id => p_item_id
4538 , p_vendor_id => p_vendor_id
4539 , p_revision => p_revision
4540 , p_subinventory_code => p_subinventory_code
4541 , p_locator_id => p_locator_id
4542 , p_rcvtxn_qty => p_rcvtxn_qty
4543 , p_rcvtxn_uom => p_rcvtxn_uom
4544 , p_transaction_temp_id => p_transaction_temp_id
4545 , p_lot_control_code => p_lot_control_code
4546 , p_serial_control_code => p_serial_control_code
4547 , x_status => x_status
4548 , x_message => x_message
4549 , p_inspection_status_code => l_inspection_status_code --BUG 4309432
4550 , p_lpn_id => NULL
4551 , p_transfer_lpn_id => NULL
4552 , p_lot_number => NULL
4553 , p_deliver_to_location_id => p_deliver_to_location_id
4554 , p_sec_rcvtxn_qty => p_sec_rcvtxn_qty --OPM Convergence
4555 , p_secondary_uom => p_secondary_uom --OPM Convergence
4556 );
4557
4558 IF x_status = fnd_api.g_ret_sts_error THEN
4559 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4560 fnd_msg_pub.ADD;
4561
4562 IF (l_debug = 1) THEN
4563 print_debug('create_std_rcvtxn_intf_rec 20.1: create_po_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4564 END IF;
4565
4566 RAISE fnd_api.g_exc_error;
4567 END IF;
4568
4569 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4570 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4571 fnd_msg_pub.ADD;
4572
4573 IF (l_debug = 1) THEN
4574 print_debug('create_std_rcvtxn_intf_rec 20.2: create_po_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4575 END IF;
4576
4577 RAISE fnd_api.g_exc_unexpected_error;
4578 END IF;
4579 ELSIF p_receipt_num IS NOT NULL THEN
4580 l_progress := '50';
4581
4582 IF (l_debug = 1) THEN
4583 print_debug('create_std_rcvtxn_intf_rec: 30 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4584 END IF;
4585
4586 create_rpt_num_rcvtxn_intf_rec(
4587 p_organization_id => p_organization_id
4588 , p_receipt_num => p_receipt_num
4589 , p_shipment_header_id => p_shipment_header_id
4590 , p_item_id => p_item_id
4591 , p_source_id => p_vendor_id
4592 , p_revision => p_revision
4593 , p_subinventory_code => p_subinventory_code
4594 , p_locator_id => p_locator_id
4595 , p_rcvtxn_qty => p_rcvtxn_qty
4596 , p_rcvtxn_uom => p_rcvtxn_uom
4597 , p_transaction_temp_id => p_transaction_temp_id
4598 , p_lot_control_code => p_lot_control_code
4599 , p_serial_control_code => p_serial_control_code
4600 , x_status => x_status
4601 , x_message => x_message
4602 , p_deliver_to_location_id => p_deliver_to_location_id
4603 , p_sec_rcvtxn_qty => p_sec_rcvtxn_qty --OPM Convergence
4604 , p_secondary_uom => p_secondary_uom --OPM Convergence
4605 , p_inspection_status_code => l_inspection_status_code --Bug 4309432
4606 );
4607
4608 IF x_status = fnd_api.g_ret_sts_error THEN
4609 IF (l_debug = 1) THEN
4610 print_debug('create_std_rcvtxn_intf_rec 30.1: create_rpt_num_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4611 END IF;
4612
4613 RAISE fnd_api.g_exc_error;
4614 END IF;
4615
4616 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4617 IF (l_debug = 1) THEN
4618 print_debug('create_std_rcvtxn_intf_rec 30.2: create_rpt_num_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4619 END IF;
4620
4621 RAISE fnd_api.g_exc_unexpected_error;
4622 END IF;
4623 ELSIF p_shipment_header_id IS NOT NULL THEN
4624 l_progress := '60';
4625
4626 IF (l_debug = 1) THEN
4627 print_debug('create_std_rcvtxn_intf_rec: 40 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4628 END IF;
4629
4630 create_int_shp_rcvtxn_intf_rec(
4631 p_organization_id => p_organization_id
4632 , p_shipment_header_id => p_shipment_header_id
4633 , p_shipment_line_id => NULL
4634 , p_receipt_num => NULL
4635 , p_item_id => p_item_id
4636 , p_source_id => p_vendor_id
4637 , p_revision => p_revision
4638 , p_subinventory_code => p_subinventory_code
4639 , p_locator_id => p_locator_id
4640 , p_rcvtxn_qty => p_rcvtxn_qty
4641 , p_rcvtxn_uom => p_rcvtxn_uom
4642 , p_transaction_temp_id => p_transaction_temp_id
4643 , p_lot_control_code => p_lot_control_code
4644 , p_serial_control_code => p_serial_control_code
4645 , x_status => x_status
4646 , x_message => x_message
4647 , p_inspection_status_code => NULL
4648 , p_lpn_id => NULL
4649 , p_transfer_lpn_id => NULL
4650 , p_lot_number => NULL
4651 , p_sec_rcvtxn_qty => p_sec_rcvtxn_qty --OPM Convergence
4652 , p_secondary_uom => p_secondary_uom --OPM Convergence
4653 );
4654
4655 IF x_status = fnd_api.g_ret_sts_error THEN
4656 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
4657 fnd_msg_pub.ADD;
4658
4659 IF (l_debug = 1) THEN
4660 print_debug('create_std_rcvtxn_intf_rec 40.1: create_int_shp_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4661 END IF;
4662
4663 RAISE fnd_api.g_exc_error;
4664 END IF;
4665
4666 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4667 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
4668 fnd_msg_pub.ADD;
4669
4670 IF (l_debug = 1) THEN
4671 print_debug('create_std_rcvtxn_intf_rec 40.2: create_int_shp_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4672 END IF;
4673
4674 RAISE fnd_api.g_exc_unexpected_error;
4675 END IF;
4676 ELSIF p_oe_order_header_id IS NOT NULL THEN
4677 l_progress := '70';
4678
4679 IF (l_debug = 1) THEN
4680 print_debug('create_std_rcvtxn_intf_rec: 50 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4681 END IF;
4682
4683 create_rma_rcvtxn_intf_rec(
4684 p_organization_id => p_organization_id
4685 , p_oe_order_header_id => p_oe_order_header_id
4686 , p_oe_order_line_id => NULL
4687 , p_receipt_num => NULL
4688 , p_item_id => p_item_id
4689 , p_customer_id => p_vendor_id
4690 , p_revision => p_revision
4691 , p_subinventory_code => p_subinventory_code
4692 , p_locator_id => p_locator_id
4693 , p_rcvtxn_qty => p_rcvtxn_qty
4694 , p_rcvtxn_uom => p_rcvtxn_uom
4695 , p_transaction_temp_id => p_transaction_temp_id
4696 , p_lot_control_code => p_lot_control_code
4697 , p_serial_control_code => p_serial_control_code
4698 , x_status => x_status
4699 , x_message => x_message
4700 , p_inspection_status_code => NULL
4701 , p_lpn_id => NULL
4702 , p_transfer_lpn_id => NULL
4703 , p_lot_number => NULL
4704 , p_sec_rcvtxn_qty => p_sec_rcvtxn_qty --OPM Convergence
4705 , p_secondary_uom => p_secondary_uom --OPM Convergence
4706 );
4707
4708 IF x_status = fnd_api.g_ret_sts_error THEN
4709 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
4710 fnd_msg_pub.ADD;
4711
4712 IF (l_debug = 1) THEN
4713 print_debug('create_std_rcvtxn_intf_rec 50.1: create_rma_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4714 END IF;
4715
4716 RAISE fnd_api.g_exc_error;
4717 END IF;
4718
4719 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
4720 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
4721 fnd_msg_pub.ADD;
4722
4723 IF (l_debug = 1) THEN
4724 print_debug('create_std_rcvtxn_intf_rec 50.2: create_rma_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4725 END IF;
4726
4727 RAISE fnd_api.g_exc_unexpected_error;
4728 END IF;
4729 END IF;
4730
4731 l_progress := '80';
4732
4733 IF (l_debug = 1) THEN
4734 print_debug('create_std_rcvtxn_intf_rec exitting: 60' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4735 END IF;
4736
4737 -- calling label printing API
4738 IF x_status <> fnd_api.g_ret_sts_error THEN
4739 IF (l_debug = 1) THEN
4740 print_debug('create_std_rcpt_intf_rec: 8.1 before inv_label.print_label ', 4);
4741 END IF;
4742
4743 /* FP-J Lot/Serial Support Enhancement
4744 * If INV J and PO J are installed, do not call label printing API at this stage
4745 */
4746 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
4747 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
4748 l_counter := 1;
4749 OPEN c_rti_txn_id;
4750
4751 LOOP
4752 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
4753 EXIT WHEN c_rti_txn_id%NOTFOUND;
4754 l_counter := l_counter + 1;
4755 END LOOP;
4756
4757 CLOSE c_rti_txn_id;
4758 inv_label.print_label(
4759 x_return_status => l_return_status
4760 , x_msg_count => l_msg_count
4761 , x_msg_data => l_msg_data
4762 , x_label_status => l_label_status
4763 , p_api_version => 1.0
4764 , p_print_mode => 1
4765 , p_business_flow_code => 3
4766 , p_transaction_id => l_txn_id_tbl
4767 );
4768
4769 IF l_return_status <> fnd_api.g_ret_sts_success THEN
4770 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
4771 fnd_msg_pub.ADD;
4772 x_status := 'W';
4773
4774 IF (l_debug = 1) THEN
4775 print_debug('create_std_rcpt_intf_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4776 END IF;
4777 END IF;
4778 ELSE
4779 IF (l_debug = 1) THEN
4780 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
4781 END IF;
4782 END IF; --END IF check INV and PO patch levels
4783 END IF; --END IF check ret status
4784 EXCEPTION
4785 WHEN fnd_api.g_exc_error THEN
4786 x_status := fnd_api.g_ret_sts_error;
4787 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4788 WHEN fnd_api.g_exc_unexpected_error THEN
4789 x_status := fnd_api.g_ret_sts_unexp_error;
4790 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4791 WHEN OTHERS THEN
4792 x_status := fnd_api.g_ret_sts_unexp_error;
4793
4794 IF SQLCODE IS NOT NULL THEN
4795 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_std_rcvtxn_intf_rec', l_progress, SQLCODE);
4796 END IF;
4797
4798 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4799 END create_std_rcvtxn_intf_rec;
4800
4801 /* FP-J Lot/Serial Support Enhancement
4802 * Added two new parameters p_transfer_lpn_id and p_lot_number
4803 */
4804 PROCEDURE create_putaway_rcvtxn_intf_rec(
4805 p_organization_id IN NUMBER
4806 , p_reference_id IN NUMBER
4807 , p_reference IN VARCHAR2
4808 , p_reference_type_code IN NUMBER
4809 , p_item_id IN NUMBER
4810 , p_revision IN VARCHAR2
4811 , p_subinventory_code IN VARCHAR2
4812 , p_locator_id IN NUMBER
4813 , p_rcvtxn_qty IN NUMBER
4814 , p_rcvtxn_uom_code IN VARCHAR2
4815 , p_transaction_temp_id IN NUMBER
4816 , p_lot_control_code IN NUMBER
4817 , p_serial_control_code IN NUMBER
4818 , p_original_txn_temp_id IN NUMBER
4819 , x_return_status OUT NOCOPY VARCHAR2
4820 , x_msg_count OUT NOCOPY VARCHAR2
4821 , x_msg_data OUT NOCOPY VARCHAR2
4822 , p_inspection_status_code IN NUMBER
4823 , p_lpn_id IN NUMBER
4824 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
4825 , p_lot_number IN VARCHAR2 DEFAULT NULL
4826 , p_parent_txn_id IN NUMBER DEFAULT NULL
4827 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
4828 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
4829 ) IS
4830 l_po_header_id NUMBER;
4831 l_po_release_id NUMBER;
4832 l_po_line_id NUMBER;
4833 l_po_line_location_id NUMBER;
4834 l_shipment_header_id NUMBER;
4835 l_oe_order_header_id NUMBER;
4836 l_rcvtxn_uom VARCHAR2(25);
4837 l_progress VARCHAR2(10);
4838 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4839 l_msg_count NUMBER;
4840 l_msg_data VARCHAR2(400);
4841 l_label_status VARCHAR2(500);
4842 l_txn_id_tbl inv_label.transaction_id_rec_type;
4843 l_counter NUMBER := 0;
4844 l_inspection_status VARCHAR2(25);
4845
4846 CURSOR c_rti_txn_id IS
4847 SELECT DISTINCT rti.interface_transaction_id
4848 FROM rcv_transactions_interface rti
4849 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
4850
4851 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4852 BEGIN
4853 x_return_status := fnd_api.g_ret_sts_success;
4854 l_progress := '10';
4855
4856 IF (l_debug = 1) THEN
4857 print_debug('create_putaway_rcvtxn_intf_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4858 print_debug(' p_organization_id =>'||p_organization_id,1);
4859 print_debug(' p_reference_id =>'||p_reference_id,1);
4860 print_debug(' p_reference =>'||p_reference,1);
4861 print_debug(' p_reference_type_code =>'||p_reference_type_code,1);
4862 print_debug(' p_item_id =>'||p_item_id,1);
4863 print_debug(' p_revision =>'||p_revision,1);
4864 print_debug(' p_subinventory_code =>'||p_subinventory_code,1);
4865 print_debug(' p_locator_id =>'||p_locator_id,1);
4866 print_debug(' p_rcvtxn_qty =>'||p_rcvtxn_qty,1);
4867 print_debug(' p_rcvtxn_uom_code =>'||p_rcvtxn_uom_code,1);
4868 print_debug(' p_transaction_temp_id =>'||p_transaction_temp_id,1);
4869 print_debug(' p_lot_control_code =>'||p_lot_control_code,1);
4870 print_debug(' p_serial_control_code =>'||p_serial_control_code,1);
4871 print_debug(' p_original_txn_temp_id =>'||p_original_txn_temp_id,1);
4872 print_debug(' p_inspection_status_code =>'||p_inspection_status_code,1);
4873 print_debug(' p_lpn_id =>'||p_lpn_id,1);
4874 print_debug(' p_transfer_lpn_id =>'||p_transfer_lpn_id,1);
4875 print_debug(' p_lot_number =>'||p_lot_number,1);
4876 print_debug(' p_parent_txn_id =>'||p_parent_txn_id,1);
4877 print_debug(' p_secondary_quantity =>'||p_secondary_quantity,1);
4878 print_debug(' p_secondary_uom =>'||p_secondary_uom,1);
4879 END IF;
4880
4881 --First check if the transaction date satisfies the validation.
4882 --If the transaction date is invalid then error out the transaction
4883 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
4884 --BUG 3444177: User HOR for performance reasons
4885 BEGIN
4886 SELECT TO_NUMBER(hoi.org_information1)
4887 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
4888 FROM hr_organization_information hoi
4889 WHERE hoi.organization_id = p_organization_id
4890 AND (hoi.org_information_context || '') = 'Accounting Information' ;
4891 EXCEPTION
4892 WHEN OTHERS THEN
4893 IF (l_debug = 1) THEN
4894 print_debug('create_std_rcvtxn_intf_rec 10.1: Error retrieving hr info',1);
4895 print_debug('SQLCODE:'||SQLCODE||' SQLERRM:'||Sqlerrm,1);
4896 END IF;
4897 RAISE fnd_api.g_exc_error;
4898 END ;
4899 END IF;
4900
4901 l_progress := '15';
4902
4903 inv_rcv_common_apis.validate_trx_date(
4904 p_trx_date => SYSDATE
4905 , p_organization_id => p_organization_id
4906 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
4907 , x_return_status => x_return_status
4908 , x_error_code => x_msg_data
4909 );
4910
4911 IF x_return_status <> fnd_api.g_ret_sts_success THEN
4912 IF (l_debug = 1) THEN
4913 print_debug('create_std_rcvtxn_intf_rec 10.2: validate_trx_date returned failure. x_error_code:'||x_msg_data,1);
4914 END IF;
4915 RETURN;
4916 END IF;
4917
4918
4919 --dbms_output.put_line('In create putaway move order');
4920 SELECT unit_of_measure
4921 INTO l_rcvtxn_uom
4922 FROM mtl_item_uoms_view
4923 WHERE organization_id = p_organization_id
4924 AND inventory_item_id = p_item_id
4925 AND uom_code = p_rcvtxn_uom_code
4926 AND ROWNUM < 2;
4927
4928 IF p_inspection_status_code = 2 THEN
4929 l_inspection_status := 'ACCEPTED';
4930 ELSIF p_inspection_status_code = 3 THEN
4931 l_inspection_status := 'REJECTED';
4932 ELSE
4933 l_inspection_status := NULL;
4934 END IF;
4935
4936 l_progress := '20';
4937
4938 IF p_reference = 'PO_LINE_LOCATION_ID' THEN
4939 BEGIN
4940 SELECT po_header_id
4941 , po_line_id
4942 , po_release_id
4943 INTO l_po_header_id
4944 , l_po_line_id
4945 , l_po_release_id
4946 FROM po_line_locations
4947 WHERE line_location_id = p_reference_id;
4948 EXCEPTION
4949 WHEN OTHERS THEN
4950 IF (l_debug = 1) THEN
4951 print_debug('create_std_rcvtxn_intf_rec 20: Error retrieving po info.',1);
4952 print_debug('SQLCODE:'||SQLCODE||' SQLERRM:'||Sqlerrm,1);
4953 END IF;
4954 RAISE fnd_api.g_exc_error;
4955 END;
4956
4957 l_progress := '30';
4958 create_po_rcvtxn_intf_rec(
4959 p_organization_id => p_organization_id
4960 , p_po_header_id => l_po_header_id
4961 , p_po_release_id => l_po_release_id
4962 , p_po_line_id => l_po_line_id
4963 , p_po_line_location_id => p_reference_id
4964 , p_receipt_num => NULL
4965 , p_item_id => p_item_id
4966 , p_vendor_id => NULL
4967 , p_revision => p_revision
4968 , p_subinventory_code => p_subinventory_code
4969 , p_locator_id => p_locator_id
4970 , p_rcvtxn_qty => p_rcvtxn_qty
4971 , p_rcvtxn_uom => l_rcvtxn_uom
4972 , p_rcvtxn_uom_code => p_rcvtxn_uom_code
4973 , p_transaction_temp_id => p_transaction_temp_id
4974 , p_lot_control_code => p_lot_control_code
4975 , p_serial_control_code => p_serial_control_code
4976 , p_original_txn_temp_id => p_original_txn_temp_id
4977 , x_status => x_return_status
4978 , x_message => x_msg_data
4979 , p_inspection_status_code => l_inspection_status
4980 , p_lpn_id => p_lpn_id
4981 , p_transfer_lpn_id => p_transfer_lpn_id
4982 , p_lot_number => p_lot_number
4983 , p_parent_txn_id => p_parent_txn_id
4984 );
4985
4986 IF x_return_status = fnd_api.g_ret_sts_error THEN
4987 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4988 fnd_msg_pub.ADD;
4989
4990 IF (l_debug = 1) THEN
4991 print_debug('create_std_rcvtxn_intf_rec 20.1: create_po_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4992 END IF;
4993
4994 RAISE fnd_api.g_exc_error;
4995 END IF;
4996
4997 IF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
4998 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4999 fnd_msg_pub.ADD;
5000
5001 IF (l_debug = 1) THEN
5002 print_debug('create_std_rcvtxn_intf_rec 20.2: create_po_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5003 END IF;
5004
5005 RAISE fnd_api.g_exc_unexpected_error;
5006 END IF;
5007 ELSIF p_reference = 'SHIPMENT_LINE_ID' THEN
5008 l_progress := '40';
5009
5010 SELECT shipment_header_id
5011 INTO l_shipment_header_id
5012 FROM rcv_shipment_lines
5013 WHERE shipment_line_id = p_reference_id;
5014
5015 l_progress := '50';
5016 create_int_shp_rcvtxn_intf_rec(
5017 p_organization_id => p_organization_id
5018 , p_shipment_header_id => l_shipment_header_id
5019 , p_shipment_line_id => p_reference_id
5020 , p_receipt_num => NULL
5021 , p_item_id => p_item_id
5022 , p_source_id => NULL
5023 , p_revision => p_revision
5024 , p_subinventory_code => p_subinventory_code
5025 , p_locator_id => p_locator_id
5026 , p_rcvtxn_qty => p_rcvtxn_qty
5027 , p_rcvtxn_uom => l_rcvtxn_uom
5028 , p_rcvtxn_uom_code => p_rcvtxn_uom_code
5029 , p_transaction_temp_id => p_transaction_temp_id
5030 , p_lot_control_code => p_lot_control_code
5031 , p_serial_control_code => p_serial_control_code
5032 , p_original_txn_temp_id => p_original_txn_temp_id
5033 , x_status => x_return_status
5034 , x_message => x_msg_data
5035 , p_inspection_status_code => l_inspection_status
5036 , p_lpn_id => p_lpn_id
5037 , p_transfer_lpn_id => p_transfer_lpn_id
5038 , p_lot_number => p_lot_number
5039 , p_parent_txn_id => p_parent_txn_id
5040 , p_sec_rcvtxn_qty => p_secondary_quantity -- Bug 13344122
5041 , p_secondary_uom => p_secondary_uom -- Bug 13344122
5042 );
5043
5044 IF x_return_status = fnd_api.g_ret_sts_error THEN
5045 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5046 fnd_msg_pub.ADD;
5047
5048 IF (l_debug = 1) THEN
5049 print_debug('create_std_rcvtxn_intf_rec 30.1: create_int_shp_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5050 END IF;
5051
5052 RAISE fnd_api.g_exc_error;
5053 END IF;
5054
5055 IF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
5056 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5057 fnd_msg_pub.ADD;
5058
5059 IF (l_debug = 1) THEN
5060 print_debug('create_std_rcvtxn_intf_rec 30.2: create_int_shp_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5061 END IF;
5062
5063 RAISE fnd_api.g_exc_unexpected_error;
5064 END IF;
5065 ELSIF p_reference = 'ORDER_LINE_ID' THEN
5066 l_progress := '60';
5067
5068 SELECT header_id
5069 INTO l_oe_order_header_id
5070 FROM oe_order_lines_all
5071 WHERE line_id = p_reference_id;
5072
5073 l_progress := '70';
5074 create_rma_rcvtxn_intf_rec(
5075 p_organization_id => p_organization_id
5076 , p_oe_order_header_id => l_oe_order_header_id
5077 , p_oe_order_line_id => p_reference_id
5078 , p_receipt_num => NULL
5079 , p_item_id => p_item_id
5080 , p_customer_id => NULL
5081 , p_revision => p_revision
5082 , p_subinventory_code => p_subinventory_code
5083 , p_locator_id => p_locator_id
5084 , p_rcvtxn_qty => p_rcvtxn_qty
5085 , p_rcvtxn_uom => l_rcvtxn_uom
5086 , p_rcvtxn_uom_code => p_rcvtxn_uom_code
5087 , p_transaction_temp_id => p_transaction_temp_id
5088 , p_lot_control_code => p_lot_control_code
5089 , p_serial_control_code => p_serial_control_code
5090 , p_original_txn_temp_id => p_original_txn_temp_id
5091 , x_status => x_return_status
5092 , x_message => x_msg_data
5093 , p_inspection_status_code => l_inspection_status
5094 , p_lpn_id => p_lpn_id
5095 , p_transfer_lpn_id => p_transfer_lpn_id
5096 , p_lot_number => p_lot_number
5097 , p_parent_txn_id => p_parent_txn_id
5098 , p_sec_rcvtxn_qty => p_secondary_quantity -- Bug 10161177
5099 , p_secondary_uom => p_secondary_uom -- Bug 10161177
5100 );
5101
5102 IF x_return_status = fnd_api.g_ret_sts_error THEN
5103 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5104 fnd_msg_pub.ADD;
5105
5106 IF (l_debug = 1) THEN
5107 print_debug('create_std_rcvtxn_intf_rec 40.1: create_rma_rcvtxn_intf_rec RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5108 END IF;
5109
5110 RAISE fnd_api.g_exc_error;
5111 END IF;
5112
5113 IF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
5114 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5115 fnd_msg_pub.ADD;
5116
5117 IF (l_debug = 1) THEN
5118 print_debug('create_std_rcvtxn_intf_rec 40.2: create_rma_rcvtxn_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5119 END IF;
5120
5121 RAISE fnd_api.g_exc_unexpected_error;
5122 END IF;
5123 END IF;
5124
5125 l_progress := '80';
5126
5127 IF (l_debug = 1) THEN
5128 print_debug('create_rma_rcvtxn_intf_rec exitting: 90' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5129 END IF;
5130
5131 IF x_return_status <> fnd_api.g_ret_sts_error THEN
5132 IF (l_debug = 1) THEN
5133 print_debug('create_std_rcpt_intf_rec: 8.1 before inv_label.print_label ', 4);
5134 END IF;
5135
5136 /* FP-J Lot/Serial Support Enhancement
5137 * If INV J and PO J are installed, do not call label printing API at this stage
5138 */
5139 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
5140 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
5141 OPEN c_rti_txn_id;
5142
5143 LOOP
5144 l_counter := 1;
5145 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
5146 EXIT WHEN c_rti_txn_id%NOTFOUND;
5147 l_counter := l_counter + 1;
5148 END LOOP;
5149
5150 CLOSE c_rti_txn_id;
5151 /* Start of Change.
5152 Earlier this call to label printing was commented out but was called for p_business_flow_code = 1
5153 Changed the p_business_flow_code = 4 (PutAway Drop) and uncommented this call to label printing for Bug 2151280.
5154 */
5155 inv_label.print_label(
5156 x_return_status => l_return_status
5157 , x_msg_count => l_msg_count
5158 , x_msg_data => l_msg_data
5159 , x_label_status => l_label_status
5160 , p_api_version => 1.0
5161 , p_print_mode => 1
5162 , p_business_flow_code => 4
5163 , p_transaction_id => l_txn_id_tbl
5164 );
5165
5166 /* End of Change */
5167 IF l_return_status <> fnd_api.g_ret_sts_success THEN
5168 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
5169 fnd_msg_pub.ADD;
5170 x_return_status := 'W';
5171 IF (l_debug = 1) THEN
5172 print_debug('create_std_rcpt_intf_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5173 END IF;
5174 END IF;
5175 ELSE
5176 IF (l_debug = 1) THEN
5177 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
5178 END IF;
5179 END IF; --END IF check INV and PO patch levels
5180 END IF; --END IF check ret status
5181 EXCEPTION
5182 WHEN fnd_api.g_exc_error THEN
5183 x_return_status := fnd_api.g_ret_sts_error;
5184 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
5185 IF (l_debug = 1) THEN
5186 print_debug('create_std_rcpt_intf_rec: g_exc_error thrown at progress '||l_progress,4);
5187 END IF;
5188 WHEN fnd_api.g_exc_unexpected_error THEN
5189 x_return_status := fnd_api.g_ret_sts_unexp_error;
5190 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
5191 IF (l_debug = 1) THEN
5192 print_debug('create_std_rcpt_intf_rec: g_exc_unexpected_error thrown at progress '||l_progress,4);
5193 END IF;
5194 WHEN OTHERS THEN
5195 x_return_status := fnd_api.g_ret_sts_unexp_error;
5196 IF (l_debug = 1) THEN
5197 print_debug('create_std_rcpt_intf_rec: others exception thrown at progress '||l_progress,4);
5198 END IF;
5199
5200 IF SQLCODE IS NOT NULL THEN
5201 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_std_rcvtxn_intf_rec', l_progress, SQLCODE);
5202 END IF;
5203
5204 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
5205 END create_putaway_rcvtxn_intf_rec;
5206
5207 PROCEDURE rcvtxn_clear_global IS
5208 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5209 BEGIN
5210 g_rcvtxn_detail_index := 1;
5211 inv_rcv_common_apis.g_po_startup_value := NULL;
5212 inv_rcv_common_apis.g_rcv_global_var := NULL;
5213 g_rcvtxn_match_table_gross.DELETE;
5214 END rcvtxn_clear_global;
5215
5216 PROCEDURE update_rcv_serials_supply(
5217 x_return_status OUT NOCOPY VARCHAR2
5218 , x_msg_count OUT NOCOPY NUMBER
5219 , x_msg_data OUT NOCOPY VARCHAR2
5220 , p_shipment_line_id IN NUMBER
5221 ) IS
5222 l_progress VARCHAR2(10);
5223 l_serial_number VARCHAR2(30);
5224 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5225 BEGIN
5226 x_return_status := fnd_api.g_ret_sts_success;
5227
5228 IF (l_debug = 1) THEN
5229 print_debug('Enter update_rcv_serials_supply 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5230 END IF;
5231
5232 IF (l_debug = 1) THEN
5233 print_debug('p_shipment_line_id => ' || p_shipment_line_id || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5234 print_debug('p_serial_number => ' || l_serial_number || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5235 END IF;
5236
5237 l_progress := '10';
5238 SAVEPOINT sp_update_rss;
5239
5240 SELECT rsi.fm_serial_num
5241 INTO l_serial_number
5242 FROM rcv_serials_interface rsi, rcv_transactions_interface rti
5243 WHERE rti.shipment_line_id = p_shipment_line_id
5244 AND rti.interface_transaction_id = rsi.interface_transaction_id;
5245
5246 IF (l_debug = 1) THEN
5247 print_debug('p_serial_number => ' || l_serial_number || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5248 END IF;
5249
5250 l_progress := '15';
5251
5252 UPDATE rcv_serials_supply
5253 SET shipment_line_id = (SELECT shipment_line_id
5254 FROM rcv_serials_supply
5255 WHERE serial_num = l_serial_number)
5256 WHERE shipment_line_id = p_shipment_line_id;
5257
5258 l_progress := '20';
5259
5260 UPDATE rcv_serials_supply
5261 SET shipment_line_id = p_shipment_line_id
5262 WHERE serial_num = l_serial_number;
5263
5264 l_progress := '30';
5265
5266 IF (l_debug = 1) THEN
5267 print_debug('Complete update_rcv_serials_supply 40' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5268 END IF;
5269 EXCEPTION
5270 WHEN OTHERS THEN
5271 x_return_status := fnd_api.g_ret_sts_unexp_error;
5272
5273 IF SQLCODE IS NOT NULL THEN
5274 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.update_rcv_serials_supply', l_progress, SQLCODE);
5275 END IF;
5276
5277 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
5278
5279 IF (l_debug = 1) THEN
5280 print_debug('Exception in update_rcv_serials_supply 50' || SQLCODE || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5281 END IF;
5282 END update_rcv_serials_supply;
5283
5284 FUNCTION insert_mtli_helper(
5285 p_txn_if_id IN OUT NOCOPY NUMBER
5286 , p_lot_number IN VARCHAR2
5287 , p_txn_qty IN NUMBER
5288 , p_prm_qty IN NUMBER
5289 , p_item_id IN NUMBER
5290 , p_org_id IN NUMBER
5291 , p_serial_temp_id IN NUMBER
5292 , p_product_txn_id IN NUMBER
5293 , p_secondary_quantity IN NUMBER --OPM Convergence
5294 , p_secondary_uom IN NUMBER --OPM Convergence
5295 ) RETURN BOOLEAN IS
5296 --Local variables
5297 l_lot_status_id NUMBER;
5298 l_txn_if_id NUMBER := p_txn_if_id;
5299 l_product_txn_id NUMBER := p_product_txn_id;
5300 l_expiration_date DATE;
5301 l_prod_code VARCHAR2(5) := inv_rcv_integration_apis.G_PROD_CODE;
5302 l_return_status VARCHAR2(1);
5303 l_msg_count NUMBER;
5304 l_msg_data VARCHAR2(10000);
5305 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5306 BEGIN
5307 --Get the required columns from MLN first
5308 SELECT expiration_date
5309 , status_id
5310 INTO l_expiration_date
5311 , l_lot_status_id
5312 FROM mtl_lot_numbers
5313 WHERE lot_number = p_lot_number
5314 AND inventory_item_id = p_item_id
5315 AND organization_id = p_org_id;
5316
5317 IF (l_txn_if_id IS NULL) THEN
5318 BEGIN
5319 SELECT mtl_material_transactions_s.NEXTVAL
5320 INTO l_txn_if_id
5321 FROM sys.dual;
5322 EXCEPTION
5323 WHEN OTHERS THEN
5324 IF (l_debug = 1) THEN
5325 print_debug('insert_mtli_helper: Error retrieving from seq.',1);
5326 print_debug('insert_mtli_helper: SQLCODE: '||SQLCODE||' SQLERRM:'||Sqlerrm,1);
5327 END IF;
5328 END;
5329 END IF;
5330
5331 IF (l_debug = 1) THEN
5332 print_debug('insert_mtli_helper: l_txn_if_id: '||l_txn_if_id,1);
5333 END IF;
5334
5335 --Call the insert_mtli API
5336 inv_rcv_integration_pvt.insert_mtli
5337 (p_product_transaction_id => l_product_txn_id
5338 ,p_product_code => l_prod_code
5339 ,p_interface_id => l_txn_if_id
5340 ,p_org_id => p_org_id
5341 ,p_item_id => p_item_id
5342 ,p_lot_number => p_lot_number
5343 ,p_transaction_quantity => p_txn_qty
5344 ,p_primary_quantity => p_prm_qty
5345 ,p_serial_interface_id => p_serial_temp_id
5346 ,x_return_status => l_return_status
5347 ,x_msg_count => l_msg_count
5348 ,x_msg_data => l_msg_data
5349 ,p_sec_qty => p_secondary_quantity
5350 );
5351
5352 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5353 fnd_msg_pub.count_and_get(p_count => l_msg_count, p_data => l_msg_data);
5354 IF (l_debug = 1) THEN
5355 print_debug('insert_mtli_helper: Error occurred while creating interface lots: ' || l_msg_data,1);
5356 END IF;
5357 RETURN FALSE;
5358 END IF;
5359
5360 p_txn_if_id := l_txn_if_id;
5361
5362 RETURN TRUE;
5363
5364 EXCEPTION
5365 WHEN OTHERS THEN
5366 IF (l_debug = 1) THEN
5367 print_debug('Exception occurred in insert_mtli_helper: ',1);
5368 END IF;
5369 RETURN FALSE;
5370 END insert_mtli_helper;
5371
5372 FUNCTION insert_msni_helper(
5373 p_txn_if_id IN OUT NOCOPY NUMBER
5374 , p_serial_number IN VARCHAR2
5375 , p_item_id IN NUMBER
5376 , p_org_id IN NUMBER
5377 , p_product_txn_id IN OUT NOCOPY NUMBER
5378 ) RETURN BOOLEAN IS
5379 --Local variables
5380 l_serial_status_id NUMBER;
5381 l_txn_if_id NUMBER := p_txn_if_id;
5382 l_product_txn_id NUMBER := p_product_txn_id;
5383 l_prod_code VARCHAR2(5) := inv_rcv_integration_apis.G_PROD_CODE;
5384 l_yes VARCHAR2(1) := inv_rcv_integration_apis.G_YES;
5385 l_no VARCHAR2(1) := inv_rcv_integration_apis.G_NO;
5386 l_false VARCHAR2(1) := inv_rcv_integration_apis.G_FALSE;
5387 l_return_status VARCHAR2(1);
5388 l_msg_count NUMBER;
5389 l_msg_data VARCHAR2(10000);
5390 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5391 BEGIN
5392
5393 --Get the serial status
5394 SELECT status_id
5395 INTO l_serial_status_id
5396 FROM mtl_serial_numbers
5397 WHERE serial_number = p_serial_number
5398 AND inventory_item_id = p_item_id;
5399
5400 --Call the insert_msni API
5401 inv_rcv_integration_apis.insert_msni(
5402 p_api_version => 1.0
5403 , p_init_msg_lst => l_false
5404 , x_return_status => l_return_status
5405 , x_msg_count => l_msg_count
5406 , x_msg_data => l_msg_data
5407 , p_transaction_interface_id => l_txn_if_id
5408 , p_fm_serial_number => p_serial_number
5409 , p_to_serial_number => p_serial_number
5410 , p_organization_id => p_org_id
5411 , p_inventory_item_id => p_item_id
5412 , p_status_id => l_serial_status_id
5413 , p_product_transaction_id => l_product_txn_id
5414 , p_product_code => l_prod_code
5415 , p_att_exist => l_yes
5416 , p_update_msn => l_no);
5417
5418 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5419 fnd_msg_pub.count_and_get(p_count => l_msg_count, p_data => l_msg_data);
5420 IF (l_debug = 1) THEN
5421 print_debug('insert_msni_helper: Error occurred while creating interface serials: ' || l_msg_data,1);
5422 END IF;
5423 RETURN FALSE;
5424 END IF;
5425
5426 IF (l_debug = 1) THEN
5427 print_debug('insert_msni_helper: msni '||p_txn_if_id||' inserted for serial '||p_serial_number,1);
5428 END IF;
5429
5430 RETURN TRUE;
5431
5432 EXCEPTION
5433 WHEN OTHERS THEN
5434 IF (l_debug = 1) THEN
5435 print_debug('Exception occurred in insert_msni_helper: ',1);
5436 END IF;
5437 RETURN FALSE;
5438 END insert_msni_helper;
5439
5440 PROCEDURE Match_putaway_rcvtxn_intf_rec(
5441 p_organization_id IN NUMBER
5442 , p_reference_id IN NUMBER
5443 , p_reference IN VARCHAR2
5444 , p_reference_type_code IN NUMBER
5445 , p_item_id IN NUMBER
5446 , p_revision IN VARCHAR2
5447 , p_subinventory_code IN VARCHAR2
5448 , p_locator_id IN NUMBER
5449 , p_rcvtxn_qty IN NUMBER
5450 , p_rcvtxn_uom_code IN VARCHAR2
5451 , p_transaction_temp_id IN NUMBER
5452 , p_lot_control_code IN NUMBER
5453 , p_serial_control_code IN NUMBER
5454 , p_original_txn_temp_id IN NUMBER
5455 , x_return_status OUT NOCOPY VARCHAR2
5456 , x_msg_count OUT NOCOPY VARCHAR2
5457 , x_msg_data OUT NOCOPY VARCHAR2
5458 , p_inspection_status_code IN NUMBER
5459 , p_lpn_id IN NUMBER
5460 , p_transfer_lpn_id IN NUMBER DEFAULT NULL
5461 , p_lot_number IN VARCHAR2 DEFAULT NULL
5462 , p_parent_txn_id IN NUMBER DEFAULT NULL
5463 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
5464 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
5465 , p_inspection_status IN NUMBER DEFAULT NULL
5466 , p_primary_uom_code IN VARCHAR2
5467 ) IS
5468
5469 CURSOR c_serial_cur IS
5470 SELECT distinct
5471 rsl.source_document_code source_document_code
5472 ,rsl.po_line_location_id po_line_location_id
5473 ,rsl.po_distribution_id po_distribution_id
5474 ,rsl.shipment_line_id shipment_line_id
5475 ,rsl.oe_order_line_id oe_order_line_id
5476 ,rsh.receipt_source_code receipt_source_code
5477 ,rss.serial_num serial_num
5478 ,rt.uom_code uom_code
5479 ,rss.transaction_id rcv_transaction_id
5480 ,rss.lot_num lot_num
5481 ,rs.secondary_quantity secondary_quantity
5482 ,msni.transaction_interface_id transaction_interface_id
5483 ,rsl.asn_line_flag asn_line_flag
5484 FROM rcv_supply rs,
5485 rcv_transactions rt,
5486 rcv_serials_supply rss,
5487 rcv_shipment_lines rsl,
5488 rcv_shipment_headers rsh,
5489 mtl_serial_numbers_interface msni
5490 WHERE rs.item_id = p_item_id
5491 --Bug 5250046: Removed the nvl and Modified the condition on item_revision.
5492 AND (p_revision is null or rs.item_revision = p_revision)
5493 AND rs.to_organization_id = p_organization_id
5494 AND nvl(rs.lpn_id,-1) = nvl(p_lpn_id,-1)
5495 AND rs.rcv_transaction_id = rt.transaction_id
5496 AND msni.product_code = 'RCV'
5497 AND msni.product_transaction_id = p_transaction_temp_id
5498 AND rss.serial_num between msni.fm_serial_number and msni.to_serial_number
5499 AND nvl(rss.lot_num,'@$#_') = nvl(p_lot_number, '@$#_')
5500 AND rss.supply_type_code = 'RECEIVING'
5501 AND rs.shipment_line_id = rsl.shipment_line_id
5502 AND rs.rcv_transaction_id = rss.transaction_id
5503 AND rsh.shipment_header_id = rsl.shipment_header_id
5504 AND decode(rt.routing_header_id, 2,
5505 decode(rt.inspection_status_code,'NOT INSPECTED',1, 'ACCEPTED',2,'REJECTED', 3)
5506 ,-1) = nvl(p_inspection_status, -1)
5507 ORDER BY rcv_transaction_id
5508 ;
5509
5510 CURSOR c_rtv_cur(v_from_sub VARCHAR2, v_from_locator_id NUMBER) IS
5511 SELECT
5512 rsl.source_document_code source_document_code
5513 ,rsl.po_line_location_id po_line_location_id
5514 ,rsl.po_distribution_id po_distribution_id
5515 ,rsl.shipment_line_id shipment_line_id
5516 ,rsl.oe_order_line_id oe_order_line_id
5517 ,rs.supply_source_id supply_source_id
5518 ,rs.rcv_transaction_id rcv_transaction_id
5519 ,rsh.receipt_source_code receipt_source_code
5520 ,rt.uom_code uom_code
5521 ,rs.secondary_quantity secondary_quantity
5522 ,Nvl(rls.primary_quantity,0) lot_prim_qty
5523 ,Nvl(rls.quantity,0) lot_qty
5524 ,decode(rt.uom_code, p_rcvtxn_uom_code, 1, 2) ORDERING1
5525 ,decode(rt.uom_code, p_rcvtxn_uom_code, (p_rcvtxn_qty - rs.quantity), 0) ORDERING2
5526 ,rsl.asn_line_flag asn_line_flag
5527 FROM rcv_supply rs,
5528 rcv_transactions rt,
5529 rcv_shipment_lines rsl,
5530 rcv_lots_supply rls,
5531 rcv_shipment_headers rsh
5532 WHERE rs.item_id = p_item_id
5533 --Bug 5250046: Removed the nvl and Modified the condition on item_revision.
5534 AND (p_revision is null or rs.item_revision = p_revision)
5535 AND rs.to_organization_id = p_organization_id
5536 AND nvl(rs.lpn_id,-1) = nvl(p_lpn_id,-1)
5537 AND nvl(rt.subinventory,'@$#_') = nvl(v_from_sub,'@$#_')
5538 AND nvl(rt.locator_id,-1) = nvl(v_from_locator_id, -1)
5539
5540 --4502518 Issue 26: redundant check. Also, it will fail
5541 -- when putting lines that have been corrected
5542 -- AND nvl(rt.transfer_lpn_id,-1) = nvl(p_lpn_id,-1)
5543
5544 AND rs.rcv_transaction_id = rt.transaction_id
5545 AND rt.shipment_line_id = rsl.shipment_line_id
5546 AND rs.supply_type_code = 'RECEIVING'
5547 AND rls.transaction_id (+) = rs.supply_source_id
5548 AND nvl(rls.lot_num, '@$#_') = nvl(p_lot_number, '@$#_')
5549 AND rsh.shipment_header_id = rsl.shipment_header_id
5550 AND decode(rt.routing_header_id, 2,
5551 decode(rt.inspection_status_code,'NOT INSPECTED',1, 'ACCEPTED',2,'REJECTED', 3)
5552 ,-1) = nvl(p_inspection_status, -1)
5553 AND --14133874
5554 ((rsl.shipment_line_id = p_reference_id AND p_reference='SHIPMENT_LINE_ID')
5555 OR
5556 (rsl.po_line_location_id = p_reference_id AND p_reference='PO_LINE_LOCATION_ID')
5557 OR
5558 (rsl.oe_order_line_id = p_reference_id AND p_reference='ORDER_LINE_ID')
5559 OR
5560 (rsl.po_distribution_id = p_reference_id AND p_reference='PO_DISTRIBUTION_ID') --bug 14734002
5561 )
5562 --Bug 5331779 - Begin change
5563 --Adding the following to make sure that we do not pickup RS with serial numbers
5564 AND NOT exists
5565 (SELECT '1' FROM rcv_serials_supply rss
5566 WHERE rss.transaction_id = rs.supply_source_id
5567 AND rss.supply_type_code = 'RECEIVING')
5568 --Bug 5331779-End change
5569 ORDER BY ORDERING1, ORDERING2
5570 ;
5571
5572 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5573 l_remaining_qty NUMBER;
5574 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
5575 l_from_sub VARCHAR2(30);
5576 l_from_locator_id NUMBER;
5577 l_split_lot_serial_ok BOOLEAN;
5578 l_parent_txn_id NUMBER;
5579 l_remaining_prim_qty NUMBER;
5580 l_qty_to_insert NUMBER;
5581 l_avail_qty NUMBER;
5582 l_tolerable_qty NUMBER;
5583 l_avail_prim_qty NUMBER;
5584 l_secondary_quantity NUMBER;
5585 l_original_lot_sec_qty NUMBER;
5586 l_lot_sec_qty_to_insert NUMBER;
5587 l_new_intf_id NUMBER;
5588 l_primary_uom_code VARCHAR2(3);
5589 l_uom_code VARCHAR2(3);
5590 L_RTI_REC_FOUND Boolean ;
5591 l_result Boolean;
5592 l_reference VARCHAR2(240);
5593 l_reference_type_code NUMBER;
5594 l_reference_id NUMBER;
5595 l_return_status VARCHAR2(1):= fnd_api.g_ret_sts_success;
5596 l_msg_count NUMBER;
5597 l_msg_data VARCHAR2(4000);
5598 l_matched_index NUMBER;
5599 l_ser_txn_temp_id NUMBER;
5600 l_progress VARCHAR2(10);
5601 l_original_sec_qty NUMBER;
5602 l_lot_temp_id NUMBER;
5603 l_temp_id NUMBER;
5604 l_receipt_uom VARCHAR2(30);
5605 l_receipt_qty NUMBER;
5606 l_mmtt_id_to_insert NUMBER;
5607 l_processed_lot_prim_qty NUMBER;
5608 l_processed_lot_qty NUMBER;
5609
5610 TYPE rti_info IS RECORD
5611 (rti_id NUMBER,
5612 rcv_transaction_id NUMBER,
5613 lot_number VARCHAR2(80),
5614 source_document_code VARCHAR2(25),
5615 po_line_location_id NUMBER,
5616 po_distribution_id NUMBER,
5617 shipment_line_id NUMBER,
5618 oe_order_line_id NUMBER,
5619 receipt_source_code VARCHAR2(25),
5620 serial_intf_id NUMBER,
5621 uom_code VARCHAR2(3),
5622 reference VARCHAR2(240),
5623 REFERENCE_TYPE_CODE NUMBER,
5624 REFERENCE_ID NUMBER,
5625 quantity NUMBER);
5626
5627 l_txn_id NUMBER;
5628 l_lot_num VARCHAR2(80);
5629
5630 TYPE lot_tb_tp IS TABLE OF rti_info INDEX BY VARCHAR2(80);
5631 TYPE rti_tb_tp IS TABLE OF lot_tb_tp INDEX BY BINARY_INTEGER;
5632
5633 l_rti_tb rti_tb_tp;
5634
5635 k NUMBER;
5636 l VARCHAR2(80);
5637
5638 BEGIN
5639
5640 SAVEPOINT create_rti_ss;
5641
5642 x_return_status := fnd_api.g_ret_sts_success;
5643
5644 IF (l_debug = 1) THEN
5645 print_debug('Enter Match_putaway_rcvtxn_intf_rec ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5646 END IF;
5647
5648 IF (l_debug = 1) THEN
5649 print_debug('Match_putaway_rcvtxn_intf_rec : ITEM_ID = '|| p_item_id , 1);
5650 print_debug('Match_putaway_rcvtxn_intf_rec : ORGANIZATION_ID = '|| p_organization_id , 1);
5651 print_debug('Match_putaway_rcvtxn_intf_rec : QTY = '|| p_rcvtxn_qty , 1);
5652 print_debug('Match_putaway_rcvtxn_intf_rec : UOM_CODE = '|| p_rcvtxn_qty , 1);
5653 print_debug('Match_putaway_rcvtxn_intf_rec : SUBINVENTORY_CODE = '||p_subinventory_code , 1);
5654 print_debug('Match_putaway_rcvtxn_intf_rec : LOCATOR_ID = '|| p_locator_id , 1);
5655
5656 print_debug('Match_putaway_rcvtxn_intf_rec : p_reference_id = '|| p_reference_id , 1);
5657 print_debug('Match_putaway_rcvtxn_intf_rec : p_reference = '|| p_reference , 1);
5658 print_debug('Match_putaway_rcvtxn_intf_rec : p_reference_type_code = '|| p_reference_type_code , 1);
5659 print_debug('Match_putaway_rcvtxn_intf_rec : p_transaction_temp_id = '|| p_transaction_temp_id , 1);
5660 print_debug('Match_putaway_rcvtxn_intf_rec : p_original_txn_temp_id = '||p_original_txn_temp_id,1);
5661
5662 END IF;
5663
5664 l_primary_uom_code := p_primary_uom_code;
5665
5666 BEGIN
5667 select subinventory_code
5668 , locator_id
5669 into l_from_sub
5670 ,l_from_locator_id
5671 from wms_license_plate_numbers wlpn
5672 where wlpn.lpn_id = p_lpn_id;
5673
5674 EXCEPTION
5675 WHEN NO_DATA_FOUND THEN
5676 NULL;
5677 END;
5678
5679 IF (l_debug = 1) THEN
5680 print_debug('Match_putaway_rcvtxn_intf_rec : PRIMARY_UOM_CODE = '|| l_primary_uom_code , 1);
5681 END IF;
5682
5683 l_remaining_qty := p_rcvtxn_qty;
5684
5685 l_remaining_prim_qty := inv_convert.inv_um_convert(
5686 item_id => p_item_id,
5687 precision => 5,
5688 from_quantity => p_rcvtxn_qty,
5689 from_unit => p_rcvtxn_uom_code,
5690 to_unit => l_primary_uom_code,
5691 from_name => null,
5692 to_name => null);
5693
5694 IF (l_debug = 1) THEN
5695 print_debug('Match_putaway_rcvtxn_intf_rec 10 : REMAINING QTY = '|| l_remaining_qty , 1);
5696 print_debug('Match_putaway_rcvtxn_intf_rec 10 : REMAINING PRIM QTY = '|| l_remaining_prim_qty , 1);
5697 END IF;
5698
5699 IF (p_serial_control_code = 1 OR p_serial_control_code = 6 ) then
5700 -- CASE WHERE ITEM IS NOT SERIAL CONTROLLED
5701 -- OR CASE WHEN SERIAL CONTROLLED CODE IS AT SO ISSUE Bug: 5253223
5702 For l_rtv_rec in c_rtv_cur(l_from_sub, l_from_locator_id)
5703 Loop
5704 IF (l_debug = 1) THEN
5705 print_debug('Match_putaway_rcvtxn_intf_rec 10 : REMAINING PRIM QTY = '|| l_remaining_prim_qty , 1);
5706 END IF;
5707
5708 IF l_remaining_prim_qty <= 0 THEN
5709 EXIT;
5710 END If;
5711
5712 IF (l_debug = 1) THEN
5713 print_debug('INSIDE MATCHING LOOP TO FIND THE PARENT TXN ' , 1);
5714 print_debug('SOURCE_DOCUMNET_CODE = '|| l_rtv_rec.source_document_code , 1);
5715 print_debug('po_line_location_id = ' || l_rtv_rec.po_line_location_id, 1);
5716 print_debug('shipment_line_id = ' || l_rtv_rec.shipment_line_id , 1);
5717 print_debug('oe_order_line_id ' || l_rtv_rec.oe_order_line_id , 1);
5718 print_debug('supply_source_id ' || l_rtv_rec.supply_source_id, 1);
5719 print_debug('receipt_source_code ' || l_rtv_rec.receipt_source_code, 1);
5720 print_debug('transaction id ' || l_rtv_rec.rcv_transaction_id, 1);
5721 END IF;
5722
5723 IF (l_debug = 1) THEN
5724 print_debug('BEFORE GETTING AVAIL QTY ' , 1);
5725 END IF;
5726
5727 IF (p_lot_control_code = 2) THEN
5728 IF (l_debug = 1) THEN
5729 print_debug('Querying MTLI to determine available QTY ' , 1);
5730 END IF;
5731
5732 BEGIN
5733 SELECT SUM(primary_quantity)
5734 , SUM(transaction_quantity)
5735 INTO l_processed_lot_prim_qty
5736 , l_processed_lot_qty
5737 FROM mtl_transaction_lots_interface
5738 WHERE product_code = 'RCV'
5739 AND product_transaction_id
5740 IN (SELECT interface_transaction_id
5741 FROM rcv_transactions_interface
5742 WHERE parent_transaction_id = l_rtv_rec.rcv_transaction_id
5743 )
5744 AND lot_number = p_lot_number;
5745 EXCEPTION
5746 WHEN OTHERS THEN
5747 l_processed_lot_prim_qty := 0;
5748 l_processed_lot_qty := 0;
5749 END;
5750
5751 IF (l_debug = 1) THEN
5752 print_debug('processed lot prim qty: '||l_processed_lot_prim_qty , 1);
5753 print_debug('processed lot qty: '|| l_processed_lot_qty, 1);
5754 END IF;
5755
5756 l_avail_prim_qty := l_rtv_rec.lot_prim_qty - Nvl(l_processed_lot_prim_qty,0);
5757 l_avail_qty := l_rtv_rec.lot_qty - Nvl(l_processed_lot_qty,0);
5758
5759 IF (l_debug = 1) THEN
5760 print_debug('available lot qty: '||l_avail_prim_qty , 1);
5761 END IF;
5762 ELSE
5763 rcv_quantities_s.get_available_quantity
5764 ('DELIVER'
5765 , l_rtv_rec.rcv_transaction_id
5766 , l_rtv_rec.receipt_source_code
5767 , NULL
5768 , l_rtv_rec.rcv_transaction_id
5769 , NULL
5770 , l_avail_qty
5771 , l_tolerable_qty
5772 , l_receipt_uom);
5773
5774 IF (l_debug = 1) THEN
5775 print_debug('AFTER GETTING AVAIL QTY. AVAIL QTY: '||l_avail_qty , 1);
5776 END IF;
5777
5778 print_debug('p_item_id'||p_item_id , 1);
5779 print_debug('l_avail_qty'||l_avail_qty , 1);
5780 print_debug('l_rtv_rec.uom_code'||l_rtv_rec.uom_code , 1);
5781 print_debug('l_primary_uom_code'||l_primary_uom_code , 1);
5782
5783
5784 print_debug('l_rtv_rec.rcv_transaction_id ' || l_rtv_rec.rcv_transaction_id, 1);
5785 print_debug('p_organization_id ' || p_organization_id, 1);
5786
5787
5788 /*7429358*/
5789 BEGIN
5790
5791 SELECT UOM_CODE INTO l_rtv_rec.uom_code FROM
5792 mtl_item_uoms_view WHERE organization_id=p_organization_id
5793 AND inventory_item_id = p_item_id
5794 AND unit_of_measure =
5795 ( SELECT unit_of_measure FROM RCV_TRANSACTIONS
5796 WHERE TRANSACTION_ID = l_rtv_rec.rcv_transaction_id);
5797
5798 EXCEPTION
5799 WHEN OTHERS THEN
5800 IF (l_debug = 1) THEN
5801 print_debug(': Error retrieving uom_code', 1);
5802 END IF;
5803
5804 END;
5805 /*End of 7429358*/
5806 print_debug('l_rtv_rec.uom_code ' || l_rtv_rec.uom_code, 1);
5807
5808
5809 l_avail_prim_qty := inv_convert.inv_um_convert
5810 ( item_id => p_item_id,
5811 precision => 5,
5812 from_quantity => l_avail_qty,
5813 from_unit => l_rtv_rec.uom_code,
5814 to_unit => l_primary_uom_code,
5815 from_name => null,
5816 to_name => null);
5817
5818 print_debug('p_item_id'||p_item_id , 1);
5819 print_debug('l_avail_qty'||l_avail_qty , 1);
5820 print_debug('l_rtv_rec.uom_code '||l_rtv_rec.uom_code , 1);
5821 print_debug('l_primary_uom_code '||l_primary_uom_code , 1);
5822
5823
5824
5825 IF (l_debug = 1) THEN
5826 print_debug('AVAIL QTY = ' || l_avail_qty , 1);
5827 print_debug('AVAIL_PRIM QTY = ' || l_avail_prim_qty , 1);
5828 print_debug('REMAINIG QTY = ' || l_remaining_qty , 1);
5829 print_debug('REMAINING_PRIM QTY = '|| l_remaining_prim_qty , 1);
5830 END IF;
5831 END IF;
5832
5833 IF l_avail_prim_qty <= 0 THEN
5834 IF (l_debug = 1) THEN
5835 print_debug('SKIPPING THIS LINE',1);
5836 END IF;
5837 GOTO nextrtrecord;
5838 END IF;
5839
5840 SELECT rcv_transactions_interface_s.NEXTVAL
5841 INTO l_new_intf_id
5842 FROM dual;
5843
5844 IF (l_avail_prim_qty < l_remaining_prim_qty ) THEN
5845 IF (p_rcvtxn_uom_code <> l_rtv_rec.uom_code) THEN
5846 l_qty_to_insert := inv_convert.inv_um_convert( item_id => p_item_id,
5847 precision => 5,
5848 from_quantity => l_avail_qty,
5849 from_unit => l_rtv_rec.uom_code,
5850 to_unit => p_rcvtxn_uom_code,
5851 from_name => null,
5852 to_name => null );
5853
5854
5855 -- Qty to Insert IS
5856 IF (l_debug = 1) THEN
5857 print_debug('QTY TO INSERT1: = '||L_QTY_TO_INSERT , 1);
5858 END IF;
5859 ELSE
5860 --
5861 -- WHICH MEANS THE DELIVER TRANSACTION UOM CODE
5862 -- IS SAME AS THAN THE RECEIPT TRANSACTION UOM CODE
5863 --
5864 l_qty_to_insert := l_avail_qty;
5865
5866 IF (l_debug = 1) THEN
5867 print_debug('QTY TO INSERT2: = '||L_QTY_TO_INSERT , 1);
5868 END IF;
5869
5870 END IF; -- IF (p_rcvtxn_uom_code <> l_rtv_rec.uom_code
5871
5872 l_remaining_prim_qty := l_remaining_prim_qty - l_avail_prim_qty;
5873 l_remaining_qty := l_remaining_qty - l_avail_qty;
5874
5875 IF (p_original_txn_temp_id IS NOT NULL) THEN
5876 IF (l_debug = 1) THEN
5877 print_debug('Calling split_mmtt', 1);
5878 END IF;
5879
5880 inv_rcv_integration_apis.split_mmtt
5881 (p_orig_mmtt_id => p_original_txn_temp_id
5882 ,p_prim_qty_to_splt => l_avail_prim_qty
5883 ,p_prim_uom_code => l_primary_uom_code
5884 ,x_new_mmtt_id => l_mmtt_id_to_insert
5885 ,x_return_status => l_return_status
5886 ,x_msg_count => l_msg_count
5887 ,x_msg_data => l_msg_data
5888 );
5889
5890 IF (l_debug = 1) THEN
5891 print_debug('Returned from split_mmtt',1);
5892 print_debug('x_return_status: '||l_return_status,1);
5893 END IF;
5894
5895 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
5896 IF (l_debug = 1) THEN
5897 print_debug('x_msg_data: '||l_msg_data,1);
5898 print_debug('x_msg_count: '||l_msg_count,1);
5899 print_debug('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM,1);
5900 print_debug('Raising Exception!!!',1);
5901 END IF;
5902 l_progress := '@@@';
5903 RAISE fnd_api.g_exc_unexpected_error;
5904 END IF;
5905 END IF;
5906
5907 IF (p_lot_control_code = 2) THEN
5908
5909
5910 l_new_rti_info(1).orig_interface_trx_id := p_transaction_temp_id;
5911 l_new_rti_info(1).new_interface_trx_id := l_new_intf_id;
5912 l_new_rti_info(1).quantity := L_qty_to_insert;
5913
5914 l_new_rti_info(1).to_organization_id := p_organization_id;
5915 l_new_rti_info(1).item_id := p_item_id;
5916 l_new_rti_info(1).uom_code := p_rcvtxn_uom_code;
5917
5918 IF (l_remaining_qty > 0) THEN
5919 l_new_rti_info(2).orig_interface_trx_id := p_transaction_temp_id;
5920 l_new_rti_info(2).new_interface_trx_id := p_transaction_temp_id;
5921 l_new_rti_info(2).quantity := l_remaining_qty;
5922
5923 l_new_rti_info(2).to_organization_id := p_organization_id;
5924 l_new_rti_info(2).item_id := p_item_id;
5925 l_new_rti_info(2).uom_code := p_rcvtxn_uom_code;
5926 END IF;
5927
5928 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial
5929 (p_api_version => 1.0
5930 , p_init_msg_lst => FND_API.G_FALSE
5931 , x_return_status => l_return_status
5932 , x_msg_count => l_msg_count
5933 , x_msg_data => l_msg_data
5934 , p_new_rti_info => l_new_rti_info);
5935
5936 IF ( NOT l_split_lot_serial_ok) THEN
5937 IF (l_debug = 1) THEN
5938 print_debug(' MATCH_PUTAWAY_RCVTXN_INTF_REC: Failure in split_lot_serial ', 4);
5939 END IF;
5940 RAISE FND_API.G_EXC_ERROR;
5941 END IF;
5942 END IF;
5943 ELSE
5944 /*10328780 - This is a redundant conversion
5945 l_qty_to_insert := inv_convert.inv_um_convert(
5946 item_id => p_item_id,
5947 precision => 5,
5948 from_quantity => l_remaining_prim_qty,
5949 from_unit => l_primary_uom_code,
5950 to_unit => p_rcvtxn_uom_code,
5951 from_name => null,
5952 to_name => null ); */
5953 l_qty_to_insert := l_remaining_qty; --10328780
5954
5955 IF (l_debug = 1) THEN
5956 print_debug('QTY TO INSERT3: = ' || L_QTY_TO_INSERT , 1);
5957 END IF;
5958
5959 IF (p_lot_control_code = 2) THEN
5960 UPDATE mtl_transaction_lots_interface
5961 SET product_transaction_id = l_new_intf_id
5962 WHERE product_transaction_id = p_transaction_temp_id
5963 AND product_code = 'RCV';
5964 END IF;
5965
5966 l_remaining_prim_qty := 0;
5967 l_remaining_qty := 0;
5968 l_mmtt_id_to_insert := p_original_txn_temp_id;
5969
5970 END IF;
5971
5972 IF l_rtv_rec.source_document_code = 'PO' THEN
5973 IF l_rtv_rec.asn_line_flag = 'Y' then
5974 L_reference := 'SHIPMENT_LINE_ID';
5975 L_reference_type_code := 4;
5976 L_reference_id := l_rtv_rec.shipment_line_id ;
5977 ELSE
5978 L_reference := 'PO_LINE_LOCATION_ID';
5979 L_reference_type_code := 4;
5980 L_reference_id := l_rtv_rec.po_line_location_id ;
5981 END IF;
5982 ELSIF l_rtv_rec.source_document_code IN ('INVENTORY', 'REQ') THEN
5983 L_reference := 'SHIPMENT_LINE_ID';
5984 L_reference_type_code := 8;
5985 L_reference_id := l_rtv_rec.shipment_line_id;
5986 ELSIF l_rtv_rec.source_document_code = 'RMA' THEN
5987 L_reference := 'ORDER_LINE_ID';
5988 L_reference_type_code := 7;
5989 L_reference_id := l_rtv_rec.oe_order_line_id;
5990 ELSE
5991 -- FAIL HERE AS THERE MAY NOT BE ANY OTHER SOURCE DOCUMENT CODE
5992 IF (l_debug = 1) THEN
5993 print_debug('REFERENCE INFO CAN NOT BE RETRIEVVED FROM RT' , 1);
5994 END IF;
5995 fnd_message.set_name('INV', 'INV_FAILED');
5996 fnd_msg_pub.ADD;
5997 RAISE fnd_api.g_exc_error;
5998 END IF;
5999
6000 IF (l_debug = 1) THEN
6001 print_debug('REFERENCE = '||L_REFERENCE , 1);
6002 print_debug('REFERENCE_TYPE_CODE = '||L_REFERENCE_TYPE_CODE , 1);
6003 print_debug('REFERENCE_ID = '||L_REFERENCE_ID , 1);
6004 END IF;
6005
6006 -- If the secondary_uom_code is not null then calculate the secondary
6007 -- Qty based on percentage of transaction quantity
6008
6009 if p_secondary_uom is not null Then
6010 IF (l_debug = 1) THEN
6011 print_debug('CALCULATING SEC QTY' , 1);
6012 END IF;
6013 l_secondary_quantity := p_secondary_quantity * (l_qty_to_insert/p_rcvtxn_qty);
6014 Else
6015 l_secondary_quantity := null;
6016 End if;
6017
6018 IF (l_debug = 1) THEN
6019 print_debug('INTF ID = '||l_new_intf_id , 1);
6020 END IF;
6021
6022 IF (l_debug = 1) THEN
6023 print_debug('SECONDARY UOM CODE = '|| p_secondary_uom , 1);
6024 print_debug('SECONDARY QTY = '|| l_secondary_quantity, 1);
6025 END IF;
6026
6027 inv_rcv_std_deliver_apis.create_putaway_rcvtxn_intf_rec(
6028 p_organization_id => p_organization_id
6029 , p_reference_id => l_reference_id
6030 , p_reference => l_reference
6031 , p_reference_type_code => l_reference_type_code
6032 , p_item_id => p_item_id
6033 , p_revision => p_revision
6034 , p_subinventory_code => p_subinventory_code
6035 , p_locator_id => p_locator_id
6036 , p_rcvtxn_qty => L_qty_to_insert
6037 , p_rcvtxn_uom_code => p_rcvtxn_uom_code
6038 , p_transaction_temp_id => l_new_intf_id
6039 , p_lot_control_code => p_lot_control_code
6040 , p_serial_control_code => p_serial_control_code
6041 , p_original_txn_temp_id => l_mmtt_id_to_insert
6042 , x_return_status => l_return_status
6043 , x_msg_count => l_msg_count
6044 , x_msg_data => l_msg_data
6045 , p_inspection_status_code => p_inspection_status_code
6046 , p_lpn_id => p_lpn_id
6047 , p_transfer_lpn_id => p_transfer_lpn_id
6048 , p_lot_number => p_lot_number
6049 , p_parent_txn_id => l_rtv_rec.rcv_transaction_id
6050 , p_secondary_quantity => l_secondary_quantity --OPM Integration
6051 , p_secondary_uom => p_secondary_uom --OPM Integration
6052 );
6053
6054 IF (l_debug = 1) THEN
6055 print_debug('AFTER CALLING THE DELIVERY API: p_rcvtxn_qty = '|| p_rcvtxn_qty, 1);
6056 print_debug('AFTER CALLING THE DELIVERY API: p_rcvtxn_uom_code = '|| p_rcvtxn_uom_code, 1);
6057 print_debug('AFTER CALLING THE DELIVERY API: STATUS = '|| l_return_status, 1);
6058 END IF;
6059
6060 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6061 fnd_message.set_name('WMS', 'WMS_TD_DEL_ERROR');
6062 fnd_msg_pub.ADD;
6063 RAISE fnd_api.g_exc_unexpected_error;
6064 ELSIF l_return_status = fnd_api.g_ret_sts_error THEN
6065 fnd_message.set_name('WMS', 'WMS_TD_DEL_ERROR');
6066 fnd_msg_pub.ADD;
6067 RAISE fnd_api.g_exc_error;
6068 END IF;
6069
6070 <<nextrtrecord>>
6071 NULL;
6072 End Loop; -- End of Recipt' txns Loop
6073
6074 IF (l_debug = 1) THEN
6075 print_debug('l_remaining_prim_qty final is ... '|| l_remaining_prim_qty, 1);
6076 END IF;
6077
6078 --Bug 5331779-Begin change
6079 --If l_remaining_prim_qty > 0 then only
6080 --fail if the serial control code is 1 because for serial control
6081 --code of 6, there may be lines with serial number which are yet to
6082 --be processed.
6083 IF p_serial_control_code = 1 AND l_remaining_prim_qty > 0.000005 THEN
6084 -- Bug 5331779 -End change
6085 -- IF l_remaining_prim_qty > 0 THEN
6086 IF (l_debug = 1) THEN
6087 print_debug('COUND NOT MATCH RECEIPT TRANSACTION FOR THE QTY TO BE DELIVERED: FAILURE ', 1);
6088 END IF;
6089
6090 -- Unable to match RS with quantity.
6091 fnd_message.set_name('WMS', 'WMS_TD_DEL_ERROR');
6092 fnd_msg_pub.ADD;
6093 RAISE FND_API.g_exc_error;
6094
6095 END IF;
6096
6097 --Bug 5331779-Begin Change
6098 --Instead of an else block we need to have
6099 --another if block because for items with serial control code 6, we
6100 --want both blocks to be executed.
6101 END IF;
6102 --ELSE -- ITEM IS SERIAL CONTROLLED.
6103
6104 IF ((p_serial_control_code NOT IN (1,6))
6105 OR (p_serial_control_code = 6 AND l_remaining_prim_qty > 0)) THEN
6106 --Bug 5331779- End change
6107
6108 IF (l_debug = 1) THEN
6109 print_debug('THIS IS A SERIAL-CONTROLLED ITEM',1);
6110 print_debug('Fetching from C_SERIAL_CUR',1);
6111 END IF;
6112
6113 L_RTI_REC_FOUND := FALSE;
6114
6115 FOR l_serial_rec in C_SERIAL_CUR
6116 LOOP
6117
6118 IF (l_debug = 1) THEN
6119 print_debug('INSIDE SERIAL CURSOR LOOP ', 1);
6120 END IF;
6121
6122 IF (l_debug = 1) THEN
6123 print_debug('COUNT OF RTI ROWS '|| l_rti_tb.COUNT, 1);
6124 END IF;
6125
6126 l_txn_id := l_serial_rec.rcv_transaction_id;
6127 l_lot_num := nvl(l_serial_rec.lot_num, '@$#_');
6128
6129
6130 IF (l_rti_tb.exists(l_txn_id) AND
6131 l_rti_tb(l_txn_id).exists(l_lot_num)) THEN
6132
6133 l_rti_tb(l_txn_id)(l_lot_num).quantity
6134 := l_rti_tb(l_txn_id)(l_lot_num).quantity + 1;
6135
6136 ELSE
6137 SELECT rcv_transactions_interface_s.NEXTVAL
6138 INTO l_new_intf_id
6139 FROM dual;
6140
6141 l_rti_tb(l_txn_id)(l_lot_num).rti_id := l_new_intf_id;
6142
6143 IF (p_lot_number IS NOT NULL) THEN
6144
6145 -- Generate the Serial Txn Temp Id
6146
6147 select mtl_material_transactions_s.nextval
6148 into l_ser_txn_temp_id from dual;
6149
6150 l_rti_tb(l_txn_id)(l_lot_num).lot_number := l_serial_rec.lot_num;
6151 l_rti_tb(l_txn_id)(l_lot_num).serial_intf_id := l_ser_txn_temp_id;
6152 ELSE
6153 l_rti_tb(l_txn_id)(l_lot_num).serial_intf_id := null;
6154 END IF;
6155
6156 l_rti_tb(l_txn_id)(l_lot_num).rcv_transaction_id := l_serial_rec.rcv_transaction_id;
6157 l_rti_tb(l_txn_id)(l_lot_num).po_line_location_id := l_serial_rec.po_line_location_id;
6158 l_rti_tb(l_txn_id)(l_lot_num).po_distribution_id := l_serial_rec.po_distribution_id;
6159 l_rti_tb(l_txn_id)(l_lot_num).uom_code := l_serial_rec.uom_code;
6160 l_rti_tb(l_txn_id)(l_lot_num).source_document_code := l_serial_rec.source_document_code;
6161 l_rti_tb(l_txn_id)(l_lot_num).quantity := 1;
6162 l_rti_tb(l_txn_id)(l_lot_num).receipt_source_code := l_serial_rec.receipt_source_code;
6163 l_rti_tb(l_txn_id)(l_lot_num).uom_code := l_serial_rec.uom_code;
6164 --l_rti_tb(l_txn_id)(l_lot_num).secondary_quantity := l_serial_rec.secondary_quantity;
6165 --l_rti_tb(l_txn_id)(l_lot_num).secondary_uom_code := l_serial_rec.secondary_uom_code;
6166
6167 IF l_rti_tb(l_txn_id)(l_lot_num).source_document_code = 'PO' THEN
6168 IF l_serial_rec.asn_line_flag = 'Y' then
6169 l_rti_tb(l_txn_id)(l_lot_num).reference := 'SHIPMENT_LINE_ID';
6170 l_rti_tb(l_txn_id)(l_lot_num).reference_type_code := 4;
6171 l_rti_tb(l_txn_id)(l_lot_num).reference_id := l_serial_rec.shipment_line_id ;
6172 ELSE
6173 l_rti_tb(l_txn_id)(l_lot_num).reference := 'PO_LINE_LOCATION_ID';
6174 l_rti_tb(l_txn_id)(l_lot_num).reference_type_code := 4;
6175 l_rti_tb(l_txn_id)(l_lot_num).reference_id := l_serial_rec.po_line_location_id;
6176 END IF;
6177 ELSIF l_rti_tb(l_txn_id)(l_lot_num).source_document_code IN ('INVENTORY', 'REQ') THEN
6178 l_rti_tb(l_txn_id)(l_lot_num).reference := 'SHIPMENT_LINE_ID';
6179 l_rti_tb(l_txn_id)(l_lot_num).reference_type_code := 8;
6180 l_rti_tb(l_txn_id)(l_lot_num).reference_id := l_serial_rec.shipment_line_id;
6181 ELSIF l_rti_tb(l_txn_id)(l_lot_num).source_document_code = 'RMA' THEN
6182 l_rti_tb(l_txn_id)(l_lot_num).reference := 'ORDER_LINE_ID';
6183 l_rti_tb(l_txn_id)(l_lot_num).reference_type_code := 7;
6184 l_rti_tb(l_txn_id)(l_lot_num).reference_id := l_serial_rec.oe_order_line_id;
6185 ELSE
6186 -- FAIL HERE AS THERE MAY NOT BE ANY OTHER SOURCE DOCUMENT CODE
6187 IF (l_debug = 1) THEN
6188 print_debug('REF INFO CAN NOT BE RETRIEVVED FROM RT' , 1);
6189 END IF;
6190 fnd_message.set_name('INV', 'INV_FAILED');
6191 fnd_msg_pub.ADD;
6192 RAISE fnd_api.g_exc_error;
6193 END IF;
6194
6195 IF (l_debug = 1) THEN
6196 print_debug('REFERENCE = ' ||l_rti_tb(l_txn_id)(l_lot_num).reference , 1);
6197 print_debug('REFERENCE_TYPE_CODE = '||l_rti_tb(l_txn_id)(l_lot_num).reference_type_code , 1);
6198 print_debug('REFERENCE_ID = ' ||l_rti_tb(l_txn_id)(l_lot_num).reference_id , 1);
6199 END IF;
6200
6201 END IF;
6202
6203 -- INSERT MSNI HERE
6204 l_result := insert_msni_helper(
6205 p_txn_if_id => l_rti_tb(l_txn_id)(l_lot_num).serial_intf_id
6206 , p_serial_number => l_serial_rec.serial_num
6207 , p_org_id => p_organization_id
6208 , p_item_id => p_item_id
6209 , p_product_txn_id => l_rti_tb(l_txn_id)(l_lot_num).rti_id
6210 );
6211
6212 IF NOT l_result THEN
6213 IF (l_debug = 1) THEN
6214 print_debug('Failure while Inserting MSNI records - lot and serial controlled item',1);
6215 END IF;
6216 RAISE fnd_api.g_exc_unexpected_error;
6217 END IF; -- END IF check l_result
6218
6219 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6220 fnd_msg_pub.count_and_get(p_count => l_msg_count, p_data => l_msg_data);
6221 IF (l_debug = 1) THEN
6222 print_debug('insert_msni_helper: Error occurred while creating interface serials: ' || l_msg_data,1);
6223 END IF;
6224 RAISE fnd_api.g_exc_error;
6225 END IF;
6226
6227 END LOOP; -- End of serial cursor Loop here
6228
6229 --
6230 -- INSERT LOT ROWS HERE IF IT IS BOTH LOT AND SERIAL CONTROLLED
6231
6232 l_remaining_prim_qty := inv_convert.inv_um_convert
6233 (item_id => p_item_id,
6234 precision => 5,
6235 from_quantity => p_rcvtxn_qty,
6236 from_unit => p_rcvtxn_uom_code,
6237 to_unit => l_primary_uom_code,
6238 from_name => null,
6239 to_name => null);
6240 k := l_rti_tb.first;
6241
6242 LOOP
6243 EXIT WHEN k IS NULL;
6244
6245 l := l_rti_tb(k).first;
6246
6247 LOOP
6248 EXIT WHEN l IS NULL;
6249
6250 IF (l_debug = 1) THEN
6251 print_debug('k: ' || k || ' l: '||l,1);
6252 print_debug('l_rti_tb(k)(l).quantity: '||l_rti_tb(k)(l).quantity,1);
6253 print_debug('l_rti_tb(k)(l).rcv_transaction_id: '||l_rti_tb(k)(l).rcv_transaction_id,1);
6254 print_debug('l_rti_tb(k)(l).receipt_source_code: '||l_rti_tb(k)(l).receipt_source_code,1);
6255 END IF;
6256
6257 --
6258 -- Get the seconadry qty from the Original MTLI
6259 --
6260 IF p_rcvtxn_uom_code = l_primary_uom_code Then
6261 l_qty_to_insert := l_rti_tb(k)(l).quantity;
6262 ELSE
6263 l_qty_to_insert := inv_convert.inv_um_convert
6264 ( item_id => p_item_id,
6265 precision => 5,
6266 from_quantity => l_rti_tb(k)(l).quantity,
6267 from_unit => l_primary_uom_code,
6268 to_unit => p_rcvtxn_uom_code,
6269 from_name => null,
6270 to_name => null );
6271 END IF;
6272
6273 l_uom_code := p_rcvtxn_uom_code;
6274
6275 IF (l_debug = 1) THEN
6276 print_debug(' qty to insert = ' || l_qty_to_insert, 1);
6277 END IF;
6278
6279 rcv_quantities_s.get_available_quantity(
6280 'DELIVER'
6281 ,l_rti_tb(k)(l).rcv_transaction_id
6282 ,l_rti_tb(k)(l).receipt_source_code
6283 , NULL
6284 ,l_rti_tb(k)(l).rcv_transaction_id
6285 , NULL
6286 , l_avail_qty
6287 , l_tolerable_qty
6288 , l_receipt_uom);
6289 IF (l_debug =1 ) THEN
6290 print_debug(' l_avail_qty: ' ||l_avail_qty, 1);
6291 print_debug(' l_receipt_uom: '||l_receipt_uom, 1);
6292
6293 END IF;
6294
6295 if l_rti_tb(k)(l).uom_code <> l_uom_code then
6296
6297 l_receipt_qty := inv_convert.inv_um_convert( item_id => p_item_id,
6298 precision => 5,
6299 from_quantity => l_avail_qty,
6300 from_unit => l_rti_tb(k)(l).uom_code,
6301 to_unit => l_uom_code,
6302 from_name => null,
6303 to_name => null );
6304
6305 l_avail_qty := l_receipt_qty;
6306 END if;
6307
6308 IF l_avail_qty < l_qty_to_insert THEN
6309 -- FAIL THE TXN NOT ENOUGH QTY AVAIABLE TO TRANSACT
6310 IF (l_debug = 1) THEN
6311 print_debug('l_avail_qty: ' || l_avail_qty, 1);
6312 print_debug('Avaiable Qty is less than Txn Qty ' , 1);
6313 END IF;
6314 fnd_message.set_name('WMS', 'WMS_TASK_ERROR');
6315 fnd_msg_pub.ADD;
6316 RAISE fnd_api.g_exc_error;
6317 END IF;
6318
6319 IF (l_rti_tb(k)(l).quantity < l_remaining_prim_qty) THEN
6320 IF (p_original_txn_temp_id IS NOT NULL) THEN
6321 IF (l_debug = 1) THEN
6322 print_debug('Calling split_mmtt', 1);
6323 END IF;
6324
6325 inv_rcv_integration_apis.split_mmtt
6326 (p_orig_mmtt_id => p_original_txn_temp_id
6327 ,p_prim_qty_to_splt => l_rti_tb(k)(l).quantity
6328 ,p_prim_uom_code => l_primary_uom_code
6329 ,x_new_mmtt_id => l_mmtt_id_to_insert
6330 ,x_return_status => l_return_status
6331 ,x_msg_count => l_msg_count
6332 ,x_msg_data => l_msg_data
6333 );
6334
6335 IF (l_debug = 1) THEN
6336 print_debug('Returned from split_mmtt',1);
6337 print_debug('x_return_status: '||l_return_status,1);
6338 END IF;
6339
6340 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
6341 IF (l_debug = 1) THEN
6342 print_debug('x_msg_data: '||l_msg_data,1);
6343 print_debug('x_msg_count: '||l_msg_count,1);
6344 print_debug('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM,1);
6345 print_debug('Raising Exception!!!',1);
6346 END IF;
6347 l_progress := '@@@';
6348 RAISE fnd_api.g_exc_unexpected_error;
6349 END IF;
6350 END IF;
6351
6352 l_remaining_prim_qty := l_remaining_prim_qty-l_rti_tb(k)(l).quantity;
6353 ELSE
6354 l_mmtt_id_to_insert := p_original_txn_temp_id;
6355 l_remaining_prim_qty := 0;
6356 END IF;
6357
6358 IF p_lot_number IS NOT NULL THEN
6359 -- CASE FOR BOTH LOT AND SERIAL CONTROLLED ITEM
6360 BEGIN
6361 select secondary_transaction_quantity
6362 into l_original_lot_sec_qty
6363 from mtl_transaction_lots_interface mtli
6364 where mtli.lot_number = p_lot_number
6365 and mtli.product_code = 'RCV'
6366 and mtli.product_transaction_id = p_transaction_temp_id ;
6367 EXCEPTION
6368 WHEN NO_DATA_FOUND THEN NULL;
6369 END;
6370
6371 IF l_original_sec_qty is not null THEN
6372 l_lot_sec_qty_to_insert := l_original_lot_sec_qty * (l_qty_to_insert / p_rcvtxn_qty);
6373 END IF;
6374
6375 IF (l_debug = 1) THEN
6376 print_debug('Lot Secondary qty to insert = ' || l_lot_sec_qty_to_insert, 1);
6377 END IF;
6378
6379 IF (l_debug = 1) THEN
6380 print_debug('BEFORE CALLING THE insert_mtli_helper API ', 1);
6381 print_debug(' p_txn_if_id => '|| l_lot_temp_id,1);
6382 print_debug(' p_lot_number => '|| l_rti_tb(k)(l).lot_number,1);
6383 print_debug(' p_txn_qty => '|| l_qty_to_insert,1);
6384 print_debug(' p_prm_qty => '|| l_rti_tb(k)(l).quantity,1);
6385 print_debug(' p_item_id => '|| p_item_id,1);
6386 print_debug(' p_org_id => '|| p_organization_id,1);
6387 print_debug(' p_serial_temp_id=> '|| l_rti_tb(k)(l).serial_intf_id,1);
6388 print_debug(' p_product_txn_id=> '|| l_rti_tb(k)(l).rti_id,1);
6389 print_debug(' p_secondary_quantit=> '|| l_lot_sec_qty_to_insert,1);
6390 print_debug(' p_secondary_uom =>'|| p_secondary_uom,1);
6391 END IF;
6392
6393 l_result := insert_mtli_helper
6394 (p_txn_if_id => l_lot_temp_id
6395 , p_lot_number => l_rti_tb(k)(l).lot_number
6396 , p_txn_qty => l_qty_to_insert
6397 , p_prm_qty => l_rti_tb(k)(l).quantity
6398 , p_item_id => p_item_id
6399 , p_org_id => p_organization_id
6400 , p_serial_temp_id => l_rti_tb(k)(l).serial_intf_id
6401 , p_product_txn_id => l_rti_tb(k)(l).rti_id
6402 , p_secondary_quantity => l_lot_sec_qty_to_insert --OPM Convergence
6403 , p_secondary_uom => p_secondary_uom); --OPM Convergence
6404
6405 IF NOT l_result THEN
6406 IF (l_debug = 1) THEN
6407 print_debug('Failure while Inserting MTLI records - lot and serial controlled item',1);
6408 END IF;
6409 RAISE fnd_api.g_exc_unexpected_error;
6410 END IF; --END IF check l_result
6411 END IF; --IF P_LOT_NUMBER IS NOT NULL THEN
6412
6413 -- CALL TO RTI HERE
6414
6415 l_reference := l_rti_tb(k)(l).reference;
6416 l_reference_id := l_rti_tb(k)(l).reference_id;
6417 l_reference_type_code := l_rti_tb(k)(l).reference_type_code;
6418 l_new_intf_id := l_rti_tb(k)(l).rti_id;
6419 l_parent_txn_id := l_rti_tb(k)(l).rcv_transaction_id;
6420
6421 IF (l_debug = 1) THEN
6422 print_debug('REFERENCE = '||L_REFERENCE , 1);
6423 print_debug('REFERENCE_TYPE_CODE = '||L_REFERENCE_TYPE_CODE , 1);
6424 print_debug('REFERENCE_ID = '||L_REFERENCE_ID , 1);
6425 END IF;
6426
6427 IF p_secondary_uom is not null THEN
6428 l_secondary_quantity := p_secondary_quantity * (l_qty_to_insert/p_rcvtxn_qty);
6429 END IF;
6430
6431 IF (l_debug = 1) THEN
6432 print_debug('BEFORE CALLING THE DELIVER API ', 1);
6433 END IF;
6434
6435 inv_rcv_std_deliver_apis.create_putaway_rcvtxn_intf_rec(
6436 p_organization_id => p_organization_id
6437 , p_reference_id => l_reference_id
6438 , p_reference => l_reference
6439 , p_reference_type_code => l_reference_type_code
6440 , p_item_id => p_item_id
6441 , p_revision => p_revision
6442 , p_subinventory_code => p_subinventory_code
6443 , p_locator_id => p_locator_id
6444 , p_rcvtxn_qty => L_qty_to_insert
6445 , p_rcvtxn_uom_code => p_rcvtxn_uom_code
6446 , p_transaction_temp_id => l_new_intf_id
6447 , p_lot_control_code => p_lot_control_code
6448 , p_serial_control_code => p_serial_control_code
6449 , p_original_txn_temp_id => l_mmtt_id_to_insert
6450 , x_return_status => l_return_status
6451 , x_msg_count => l_msg_count
6452 , x_msg_data => l_msg_data
6453 , p_inspection_status_code => p_inspection_status_code
6454 , p_lpn_id => p_lpn_id
6455 , p_transfer_lpn_id => p_transfer_lpn_id
6456 , p_lot_number => p_lot_number
6457 , p_parent_txn_id => l_parent_txn_id
6458 , p_secondary_quantity => l_secondary_quantity --OPM Integration
6459 , p_secondary_uom => p_secondary_uom --OPM Integration
6460 );
6461
6462 IF (l_debug = 1) THEN
6463 print_debug('AFTER CALLING THE DELIVER API: STATUS = '||l_return_status, 1);
6464 END IF;
6465
6466 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6467 fnd_message.set_name('WMS', 'WMS_TASK_ERROR');
6468 fnd_msg_pub.ADD;
6469 RAISE fnd_api.g_exc_unexpected_error;
6470 ELSIF l_return_status = fnd_api.g_ret_sts_error THEN
6471 fnd_message.set_name('WMS', 'WMS_TASK_ERROR');
6472 fnd_msg_pub.ADD;
6473 RAISE fnd_api.g_exc_error;
6474 END IF;
6475
6476 l := l_rti_tb(k).next(l);
6477 END LOOP;
6478
6479 k := l_rti_tb.next(k);
6480 END LOOP;
6481
6482 END IF; -- End of serial Controlled
6483
6484 IF (l_debug = 1) THEN
6485 print_debug('MATCH PUTAWAY RETURNING WITH SUCCESS RETUN STATUS = ' ||x_return_status, 1);
6486 END IF;
6487
6488 EXCEPTION
6489 WHEN fnd_api.g_exc_error THEN
6490 rollback to create_rti_ss;
6491 x_return_status := fnd_api.g_ret_sts_error;
6492 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6493 IF (l_debug = 1) THEN
6494 print_debug('MATCH PUTAWAY: EXCEPTION OCCURRED AT PROGRESS ' || l_progress, 1);
6495 END IF;
6496
6497 WHEN fnd_api.g_exc_unexpected_error THEN
6498 rollback to create_rti_ss;
6499 x_return_status := fnd_api.g_ret_sts_unexp_error;
6500 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6501 IF (l_debug = 1) THEN
6502 print_debug('MATCH PUTAWAY: EXCEPTION OCCURRED AT PROGRESS ' || l_progress, 1);
6503 END IF;
6504
6505 WHEN OTHERS THEN
6506 rollback to create_rti_ss;
6507 x_return_status := fnd_api.g_ret_sts_unexp_error;
6508
6509 IF SQLCODE IS NOT NULL THEN
6510 inv_mobile_helper_functions.sql_error('INV_rcv_std_deliver_apis.create_std_rcvtxn_intf_rec', l_progress, SQLCODE);
6511 END IF;
6512
6513 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6514 END Match_putaway_rcvtxn_intf_rec ;
6515
6516 END inv_rcv_std_deliver_apis;