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