[Home] [Help]
PACKAGE BODY: APPS.INV_RCV_DIR_RCPT_APIS
Source
1 PACKAGE BODY inv_rcv_dir_rcpt_apis AS
2 /* $Header: INVDIRDB.pls 120.8.12010000.2 2009/01/05 12:47:20 vssrivat ship $*/
3
4 --Variable to store interface_transaction_id for lot and serial splits
5 g_interface_transaction_id NUMBER;
6
7 PROCEDURE print_debug(p_err_msg VARCHAR2, p_level NUMBER DEFAULT 4) IS
8 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9 BEGIN
10 IF (l_debug = 1) THEN
11 inv_mobile_helper_functions.tracelog(p_err_msg => p_err_msg, p_module => 'INV_RCV_DIR_RCPT_APIS', p_level => p_level);
12 END IF;
13 END print_debug;
14
15 PROCEDURE populate_default_values(
16 p_rcv_transaction_rec IN OUT NOCOPY inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp
17 , p_rcv_rcpt_rec IN OUT NOCOPY inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp
18 , p_group_id IN NUMBER
19 , p_organization_id IN NUMBER
20 , p_item_id IN NUMBER
21 , p_revision IN VARCHAR2
22 , p_source_type IN VARCHAR2
23 , p_subinventory_code IN VARCHAR2
24 , p_locator_id IN NUMBER
25 , p_transaction_temp_id IN NUMBER
26 , p_lot_control_code IN NUMBER
27 , p_serial_control_code IN NUMBER
28 , p_project_id IN NUMBER DEFAULT NULL
29 , p_task_id IN NUMBER DEFAULT NULL
30 , p_express_transaction IN VARCHAR2 DEFAULT NULL--Bug 5550783
31 ) IS
32 l_interface_transaction_id NUMBER;
33 -- this is used to keep track of the id used to insert the row in rti
34
35 l_lot_serial_break_tbl inv_rcv_common_apis.trans_rec_tb_tp;
36 -- table that will store the record into which the lot/serial entered
37 -- have to be broken.
38
39 -- l_transaction_type VARCHAR2(20) := 'DELIVER';
40 -- I thought till 07/16/2000 that this should be deliver, but seems
41 -- that it should actually be receive.
42 l_transaction_type VARCHAR2(20) := 'RECEIVE';
43 l_valid_ship_to_location BOOLEAN;
44 l_valid_deliver_to_location BOOLEAN;
45 l_valid_deliver_to_person BOOLEAN;
46 l_valid_subinventory BOOLEAN;
47 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
48 BEGIN
49
50 --Bug 5550783 start
51 IF (l_debug = 1) THEN
52 print_debug('populate_default_values: p_express_transaction= ' ||p_express_transaction , 4);
53 END IF;
54 --Bug 5550783 end
55
56 IF (l_debug = 1) THEN
57 print_debug('Enter populate_default_values: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
58 END IF;
59
60 --validate deliver to info
61 IF (l_debug = 1) THEN
62 print_debug('populate_default_values 20: ', 4);
63 END IF;
64
65 rcv_transactions_sv.val_destination_info(
66 p_organization_id
67 , p_item_id
68 , NULL
69 , p_rcv_rcpt_rec.deliver_to_location_id
70 , p_rcv_rcpt_rec.deliver_to_person_id
71 , p_rcv_rcpt_rec.destination_subinventory
72 , l_valid_ship_to_location
73 , l_valid_deliver_to_location
74 , l_valid_deliver_to_person
75 , l_valid_subinventory
76 );
77
78 IF (l_debug = 1) THEN
79 print_debug('populate_default_values: 30 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
80 END IF;
81
82 -- since user fill in deliver to subinventory and locator, and they are validated through LOV
83 -- we dont need to validate or default them here as receiving does.
84
85 IF l_valid_deliver_to_person THEN
86 p_rcv_transaction_rec.deliver_to_person_id := p_rcv_rcpt_rec.deliver_to_person_id;
87 END IF;
88
89 IF l_valid_deliver_to_location THEN
90 p_rcv_transaction_rec.deliver_to_location_id := p_rcv_rcpt_rec.deliver_to_location_id;
91 END IF;
92
93 p_rcv_transaction_rec.destination_subinventory := p_subinventory_code;
94 p_rcv_transaction_rec.locator_id := p_locator_id;
95 -- revision should be passed into matching logic
96
97 p_rcv_transaction_rec.item_revision := p_revision;
98 p_rcv_rcpt_rec.item_revision := p_revision;
99
100 IF (l_debug = 1) THEN
101 print_debug(
102 'populate_default_values: 3 - before inv_rcv_std_rcpt_apis.insert_txn_interface '
103 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
104 , 4
105 );
106 END IF;
107
108 l_interface_transaction_id :=
109 inv_rcv_std_rcpt_apis.insert_txn_interface(
110 p_rcv_transaction_rec
111 , p_rcv_rcpt_rec
112 , p_group_id
113 , l_transaction_type
114 , p_organization_id
115 , p_rcv_transaction_rec.deliver_to_location_id
116 , p_source_type
117 , NULL
118 , p_project_id
119 , p_task_id
120 , p_express_transaction--Bug 5550783
121 );
122 --Store the interface_transaction_id in a global variable
123 g_interface_transaction_id := l_interface_transaction_id;
124
125 IF (l_debug = 1) THEN
126 print_debug(
127 'populate_default_values: 4 - after inv_rcv_std_rcpt_apis.insert_txn_interface ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
128 , 4
129 );
130 print_debug('populate_default_values: 4.1 - l_interface_transaction_id = ' || l_interface_transaction_id, 4);
131 END IF;
132
133 /* FP-J Lot/Serial Support Enhancement
134 * If INV J and PO J are installed then lot and serial splits are done based
135 * on the interface tables (MTLI/MSNI).
136 * If either of these are not installed, use the existing logic to break
137 * lots and serials based on temp records MTLI/MSNT
138 */
139 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) AND
140 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
141
142 l_lot_serial_break_tbl(1).transaction_id := l_interface_transaction_id;
143 l_lot_serial_break_tbl(1).primary_quantity := p_rcv_transaction_rec.primary_quantity;
144
145 IF (l_debug = 1) THEN
146 print_debug(
147 'populate_default_values: 5 - before inv_rcv_std_deliver_apis.insert_lot_serial '
148 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
149 , 4
150 );
151 END IF;
152
153 inv_rcv_std_deliver_apis.insert_lot_serial(
154 l_lot_serial_break_tbl
155 , p_transaction_temp_id
156 , p_lot_control_code
157 , p_serial_control_code
158 , l_interface_transaction_id);
159 ELSE
160 IF (l_debug = 1) THEN
161 print_debug('INV J and PO J are installed. Splitting of lots and serials through interface, not temp tables', 4);
162 END IF;
163 END IF;
164
165 IF (l_debug = 1) THEN
166 print_debug(
167 'About exit populate_default_values: 6 - after inv_rcv_std_deliver_apis.insert_lot_serial '
168 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
169 END IF;
170 END populate_default_values;
171
172 /** Bug #4147209 -
173 * New procedure added to populate the attribute_category
174 * and attributes 1-15 columns of the enter receipts record type
175 * with the values passed from the Mobile Receipt UI
176 */
177 PROCEDURE set_attribute_vals (
178 p_rcv_rcpt_rec IN OUT NOCOPY inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp
179 , p_attribute_category IN VARCHAR2 DEFAULT NULL
180 , p_attribute1 IN VARCHAR2 DEFAULT NULL
181 , p_attribute2 IN VARCHAR2 DEFAULT NULL
182 , p_attribute3 IN VARCHAR2 DEFAULT NULL
183 , p_attribute4 IN VARCHAR2 DEFAULT NULL
184 , p_attribute5 IN VARCHAR2 DEFAULT NULL
185 , p_attribute6 IN VARCHAR2 DEFAULT NULL
186 , p_attribute7 IN VARCHAR2 DEFAULT NULL
187 , p_attribute8 IN VARCHAR2 DEFAULT NULL
188 , p_attribute9 IN VARCHAR2 DEFAULT NULL
189 , p_attribute10 IN VARCHAR2 DEFAULT NULL
190 , p_attribute11 IN VARCHAR2 DEFAULT NULL
191 , p_attribute12 IN VARCHAR2 DEFAULT NULL
192 , p_attribute13 IN VARCHAR2 DEFAULT NULL
193 , p_attribute14 IN VARCHAR2 DEFAULT NULL
194 , p_attribute15 IN VARCHAR2 DEFAULT NULL) IS
195 BEGIN
196 p_rcv_rcpt_rec.attribute_category := p_attribute_category;
197 p_rcv_rcpt_rec.attribute1 := p_attribute1;
198 p_rcv_rcpt_rec.attribute2 := p_attribute2;
199 p_rcv_rcpt_rec.attribute3 := p_attribute3;
200 p_rcv_rcpt_rec.attribute4 := p_attribute4;
201 p_rcv_rcpt_rec.attribute5 := p_attribute5;
202 p_rcv_rcpt_rec.attribute6 := p_attribute6;
203 p_rcv_rcpt_rec.attribute7 := p_attribute7;
204 p_rcv_rcpt_rec.attribute8 := p_attribute8;
205 p_rcv_rcpt_rec.attribute9 := p_attribute9;
206 p_rcv_rcpt_rec.attribute10 := p_attribute10;
207 p_rcv_rcpt_rec.attribute11 := p_attribute11;
208 p_rcv_rcpt_rec.attribute12 := p_attribute12;
209 p_rcv_rcpt_rec.attribute13 := p_attribute13;
210 p_rcv_rcpt_rec.attribute14 := p_attribute14;
211 p_rcv_rcpt_rec.attribute15 := p_attribute15;
212 END set_attribute_vals;
213
214 PROCEDURE create_osp_drct_dlvr_rti_rec(
215 p_move_order_header_id IN OUT NOCOPY NUMBER
216 , p_organization_id IN NUMBER
217 , p_po_header_id IN NUMBER
218 , p_po_release_id IN NUMBER
219 , p_po_line_id IN NUMBER
220 , p_po_line_location_id IN NUMBER
221 , p_po_distribution_id IN NUMBER
222 , p_item_id IN NUMBER
223 , p_rcv_qty IN NUMBER
224 , p_rcv_uom IN VARCHAR2
225 , p_rcv_uom_code IN VARCHAR2
226 , p_source_type IN VARCHAR2
227 , p_transaction_temp_id IN NUMBER
228 , p_revision IN VARCHAR2
229 , x_status OUT NOCOPY VARCHAR2
230 , x_message OUT NOCOPY VARCHAR2
231 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
232 , p_attribute1 IN VARCHAR2 DEFAULT NULL
233 , p_attribute2 IN VARCHAR2 DEFAULT NULL
234 , p_attribute3 IN VARCHAR2 DEFAULT NULL
235 , p_attribute4 IN VARCHAR2 DEFAULT NULL
236 , p_attribute5 IN VARCHAR2 DEFAULT NULL
237 , p_attribute6 IN VARCHAR2 DEFAULT NULL
238 , p_attribute7 IN VARCHAR2 DEFAULT NULL
239 , p_attribute8 IN VARCHAR2 DEFAULT NULL
240 , p_attribute9 IN VARCHAR2 DEFAULT NULL
241 , p_attribute10 IN VARCHAR2 DEFAULT NULL
242 , p_attribute11 IN VARCHAR2 DEFAULT NULL
243 , p_attribute12 IN VARCHAR2 DEFAULT NULL
244 , p_attribute13 IN VARCHAR2 DEFAULT NULL
245 , p_attribute14 IN VARCHAR2 DEFAULT NULL
246 , p_attribute15 IN VARCHAR2 DEFAULT NULL
247 ) IS
248 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
249 l_rcv_transaction_rec inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
250 l_transaction_type VARCHAR2(20) := 'DELIVER';
251 l_total_primary_qty NUMBER := 0;
252 l_msg_count NUMBER;
253 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
254 l_group_id NUMBER;
255 l_rcv_rcpt_rec inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
256 l_err_message VARCHAR2(100);
257 l_temp_message VARCHAR2(100);
258 l_msg_prod VARCHAR2(5);
259 l_progress VARCHAR2(10);
260
261 CURSOR l_curs_rcpt_detail(v_po_distribution_id NUMBER) IS
262 SELECT 'N' line_chkbox
263 , 'VENDOR' source_type_code
264 , 'VENDOR' receipt_source_code
265 , 'PO' order_type_code
266 , '' order_type
267 , poll.po_header_id po_header_id
268 , poh.segment1 po_number
269 , poll.po_line_id po_line_id
270 , pol.line_num po_line_number
271 , poll.line_location_id po_line_location_id
272 , poll.shipment_num po_shipment_number
273 , poll.po_release_id po_release_id
274 , por.release_num po_release_number
275 , TO_NUMBER(NULL) req_header_id
276 , NULL req_number
277 , TO_NUMBER(NULL) req_line_id
278 , TO_NUMBER(NULL) req_line
279 , TO_NUMBER(NULL) req_distribution_id
280 --Passing as NULL for the columns for which values are not known. --Bug #3878174
281 , TO_NUMBER(NULL) rcv_shipment_header_id
282 , NULL rcv_shipment_number
283 , TO_NUMBER(NULL) rcv_shipment_line_id
284 , TO_NUMBER(NULL) rcv_line_number
285 , TO_NUMBER(NULL) from_organization_id
286 /*
287 , poh.po_header_id rcv_shipment_header_id
288 , poh.segment1 rcv_shipment_number
289 , pol.po_line_id rcv_shipment_line_id
290 , pol.line_num rcv_line_number
291 , poh.po_header_id from_organization_id
292 */
293 , poll.ship_to_organization_id to_organization_id
294 , poh.vendor_id vendor_id
295 , '' SOURCE
296 , poh.vendor_site_id vendor_site_id
297 , '' outside_operation_flag
298 , pol.item_id item_id
299 , NULL uom_code
300 -- , pol.unit_meas_lookup_code primary_uom
301 , msi.primary_unit_of_measure primary_uom /* Bug 5665041:Primary UOM should be taken from MSI*/
302 , mum.uom_class primary_uom_class
303 , NULL item_allowed_units_lookup_code
304 , NULL item_locator_control
305 , '' restrict_locators_code
306 , '' restrict_subinventories_code
307 , NULL shelf_life_code
308 , NULL shelf_life_days
309 , msi.serial_number_control_code serial_number_control_code
310 , msi.lot_control_code lot_control_code
311 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
312 , NULL item_rev_control_flag_from
313 , NULL item_number
314 , pol.item_revision item_revision
315 , pol.item_description item_description
316 , pol.category_id item_category_id
317 , '' hazard_class
318 , '' un_number
319 , pol.vendor_product_num vendor_item_number
320 , poll.ship_to_location_id ship_to_location_id
321 , '' ship_to_location
322 , NULL packing_slip
323 , poll.receiving_routing_id routing_id
324 , '' routing_name
325 , poll.need_by_date need_by_date
326 , NVL(poll.promised_date, poll.need_by_date) expected_receipt_date
327 , poll.quantity ordered_qty
328 , pol.unit_meas_lookup_code ordered_uom
329 , NULL ussgl_transaction_code
330 , poll.government_context government_context
331 , poll.inspection_required_flag inspection_required_flag
332 , poll.receipt_required_flag receipt_required_flag
333 , poll.enforce_ship_to_location_code enforce_ship_to_location_code
334 , NVL(poll.price_override, pol.unit_price) unit_price
335 , poh.currency_code currency_code
336 , poh.rate_type currency_conversion_type
337 , poh.rate_date currency_conversion_date
338 , poh.rate currency_conversion_rate
339 , poh.note_to_receiver note_to_receiver
340 , pod.destination_type_code destination_type_code
341 , pod.deliver_to_person_id deliver_to_person_id
342 , pod.deliver_to_location_id deliver_to_location_id
343 , pod.destination_subinventory destination_subinventory
344 , poll.attribute_category attribute_category
345 , poll.attribute1 attribute1
346 , poll.attribute2 attribute2
347 , poll.attribute3 attribute3
348 , poll.attribute4 attribute4
349 , poll.attribute5 attribute5
350 , poll.attribute6 attribute6
351 , poll.attribute7 attribute7
352 , poll.attribute8 attribute8
353 , poll.attribute9 attribute9
354 , poll.attribute10 attribute10
355 , poll.attribute11 attribute11
356 , poll.attribute12 attribute12
357 , poll.attribute13 attribute13
358 , poll.attribute14 attribute14
359 , poll.attribute15 attribute15
360 , poll.closed_code closed_code
361 , NULL asn_type
362 , NULL bill_of_lading
363 , TO_DATE(NULL) shipped_date
364 , NULL freight_carrier_code
365 , NULL waybill_airbill_num
366 , NULL freight_bill_num
367 , NULL vendor_lot_num
368 , NULL container_num
369 , NULL truck_num
370 , NULL bar_code_label
371 , '' rate_type_display
372 , poll.match_option match_option
373 , poll.country_of_origin_code country_of_origin_code
374 , TO_NUMBER(NULL) oe_order_header_id
375 , TO_NUMBER(NULL) oe_order_num
376 , TO_NUMBER(NULL) oe_order_line_id
377 , TO_NUMBER(NULL) oe_order_line_num
378 , TO_NUMBER(NULL) customer_id
379 , TO_NUMBER(NULL) customer_site_id
380 , NULL customer_item_num
381 , NULL pll_note_to_receiver
382 , pod.po_distribution_id
383 , pod.quantity_ordered - pod.quantity_delivered qty_ordered
384 , pod.wip_entity_id
385 , pod.wip_operation_seq_num
386 , pod.wip_resource_seq_num
387 , pod.wip_repetitive_schedule_id
388 , pod.wip_line_id
389 , pod.bom_resource_id
390 , '' destination_type
391 , '' LOCATION
392 , pod.rate currency_conversion_rate_pod
393 , pod.rate_date currency_conversion_date_pod
394 , pod.project_id project_id
395 , pod.task_id task_id
396 , pol.secondary_uom secondary_uom --OPM Convergence
397 , NULL secondary_uom_code --OPM Convergence
398 , pol.secondary_qty secondary_quantity --OPM Convergence
399 FROM po_headers poh
400 , po_line_locations poll
401 , po_lines pol
402 , po_releases por
403 , mtl_system_items msi
404 , mtl_units_of_measure mum
405 , po_distributions pod
406 WHERE pod.po_distribution_id = v_po_distribution_id
407 AND poh.po_header_id = poll.po_header_id
408 AND pol.po_line_id = poll.po_line_id
409 AND poll.po_release_id = por.po_release_id(+)
410 AND pod.line_location_id = poll.line_location_id
411 AND mum.unit_of_measure(+) = pol.unit_meas_lookup_code
412 AND NVL(msi.organization_id, poll.ship_to_organization_id) = poll.ship_to_organization_id
413 AND msi.inventory_item_id(+) = pol.item_id;
414
415 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
416 --table to store all RTId, quantity and original_rti_id for lot/serial splits
417 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
418 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
419 BEGIN
420 x_status := fnd_api.g_ret_sts_success;
421
422 IF (l_debug = 1) THEN
423 print_debug('Enter create_osp_drct_dlvr_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
424 END IF;
425
426 SAVEPOINT crt_po_rti_sp;
427 l_progress := '10';
428
429 -- query po_startup_value
430 BEGIN
431 inv_rcv_common_apis.init_startup_values(p_organization_id);
432 EXCEPTION
433 WHEN NO_DATA_FOUND THEN
434 fnd_message.set_name('INV', 'INV_RCV_PARAM');
435 fnd_msg_pub.ADD;
436 RAISE;
437 END;
438
439 l_progress := '20';
440
441 -- default l_group_id ? clear group id after done
442 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
443 SELECT rcv_interface_groups_s.NEXTVAL
444 INTO l_group_id
445 FROM DUAL;
446
447 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
448
449 IF (l_debug = 1) THEN
450 print_debug('create_osp_drct_dlvr_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
451 END IF;
452 ELSE
453 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
454
455 IF (l_debug = 1) THEN
456 print_debug('create_osp_drct_dlvr_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
457 END IF;
458 END IF;
459
460 l_progress := '30';
461 OPEN l_curs_rcpt_detail(p_po_distribution_id);
462 l_progress := '31';
463 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
464 l_rcv_rcpt_rec.item_id := p_item_id;
465 l_progress := '32';
466 CLOSE l_curs_rcpt_detail;
467 l_progress := '33';
468 -- bug 2743146
469 -- Make sure that the po_distribution passed does satisfy the tolerance
470 -- limits by calling the matching algorithm for that.
471 -- initialize input record for matching algorithm
472 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
473 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
474 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).unit_of_measure := p_rcv_uom;
475 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
476 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
477 p_organization_id;
478 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
479 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_header_id := p_po_header_id;
480 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_release_id := p_po_release_id;
481 -- line id, line location id and distribution id will be passed only from the putaway api.
482 -- line id however, can also be passed through the UI if the line number
483 -- field is enabled on the UI.
484 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_line_id :=
485 l_rcv_rcpt_rec.po_line_id;
486 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_line_location_id :=
487 l_rcv_rcpt_rec.po_line_location_id;
488 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_distribution_id :=
489 p_po_distribution_id;
490
491 IF p_item_id IS NOT NULL THEN
492 BEGIN
493 SELECT primary_unit_of_measure
494 INTO inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
495 FROM mtl_system_items
496 WHERE mtl_system_items.inventory_item_id = p_item_id
497 AND mtl_system_items.organization_id = p_organization_id;
498 EXCEPTION
499 WHEN NO_DATA_FOUND THEN
500 NULL;
501
502 IF (l_debug = 1) THEN
503 print_debug('create_osp_drct_dlvr_rti_rec: 3 - get primary_unit_of_measure exception', 4);
504 END IF;
505 END;
506 ELSE
507 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure := NULL;
508 END IF;
509
510 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).revision := p_revision;
511 --inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id;
512 --inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id := p_task_id;
513 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
514 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
515 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
516
517 IF (l_debug = 1) THEN
518 print_debug(
519 'create_osp_drct_dlvr_rti_rec: 4 - before inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
520 , 4
521 );
522 END IF;
523
524 l_progress := '40';
525 inv_rcv_txn_interface.matching_logic(
526 x_return_status => x_status
527 , x_msg_count => l_msg_count
528 , x_msg_data => x_message
529 , x_cascaded_table => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
530 , n => inv_rcv_std_rcpt_apis.g_receipt_detail_index
531 , temp_cascaded_table => l_rcpt_match_table_detail
532 , p_receipt_num => NULL
533 , p_shipment_header_id => NULL
534 , p_lpn_id => NULL
535 );
536
537 IF (l_debug = 1) THEN
538 print_debug(
539 'create_osp_drct_dlvr_rti_rec: 5 - after inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
540 , 4
541 );
542 END IF;
543
544 -- x_status is not successful if there is any execution error in matching.
545 IF x_status = fnd_api.g_ret_sts_error THEN
546 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
547 fnd_msg_pub.ADD;
548
549 IF (l_debug = 1) THEN
550 print_debug('create_osp_drct_dlvr_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
551 END IF;
552
553 RAISE fnd_api.g_exc_error;
554 END IF;
555
556 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
557 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
558 fnd_msg_pub.ADD;
559
560 IF (l_debug = 1) THEN
561 print_debug(
562 'Exiting create_osp_drct_dlvr_rti_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
563 , 1
564 );
565 END IF;
566 RAISE fnd_api.g_exc_unexpected_error;
567 END IF;
568
569 IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
570 l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
571 fnd_message.set_name('INV', l_err_message);
572 fnd_msg_pub.ADD;
573
574 IF (l_debug = 1) THEN
575 print_debug('create_osp_drct_dlvr_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
576 END IF;
577
578 RAISE fnd_api.g_exc_error;
579 END IF;
580
581 l_err_message := '@@@';
582
583 FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
584 inv_rcv_std_rcpt_apis.g_receipt_detail_index
585 + l_rcpt_match_table_detail.COUNT
586 - 1
587 ) LOOP
588 IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
589 x_status := 'W';
590 l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
591
592 IF l_temp_message IS NULL THEN
593 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
594 l_msg_prod := 'INV';
595 EXIT;
596 END IF;
597
598 IF l_err_message = '@@@' THEN
599 l_err_message := l_temp_message;
600 l_msg_prod := 'INV';
601 ELSIF l_temp_message <> l_err_message THEN
602 l_msg_prod := 'INV';
603 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
604 EXIT;
605 END IF;
606 END IF;
607 END LOOP;
608
609 IF l_err_message <> '@@@' THEN
610 fnd_message.set_name(l_msg_prod, l_err_message);
611 fnd_msg_pub.ADD;
612
613 IF (l_debug = 1) THEN
614 print_debug('create_osp_drct_dlvr_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
615 END IF;
616 END IF;
617
618 -- End bug fix 2743146
619
620
621 l_progress := '60';
622 l_rcv_transaction_rec.po_distribution_id := p_po_distribution_id;
623 l_rcv_transaction_rec.transaction_qty := p_rcv_qty;
624 l_rcv_transaction_rec.transaction_uom := p_rcv_uom;
625 l_rcv_transaction_rec.primary_quantity :=
626 rcv_transactions_interface_sv.convert_into_correct_qty(p_rcv_qty, p_rcv_uom, p_item_id, l_rcv_rcpt_rec.primary_uom);
627 l_rcv_transaction_rec.primary_uom := l_rcv_rcpt_rec.primary_uom;
628 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
629 l_progress := '64';
630 -- update following fields for po_distribution related values
631 l_rcv_transaction_rec.currency_conversion_date := l_rcv_rcpt_rec.currency_conversion_date_pod;
632 l_rcv_transaction_rec.currency_conversion_rate := l_rcv_rcpt_rec.currency_conversion_rate_pod;
633 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.qty_ordered;
634 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
635 -- wip related fields
636 l_rcv_transaction_rec.wip_entity_id := l_rcv_rcpt_rec.wip_entity_id;
637 l_rcv_transaction_rec.wip_operation_seq_num := l_rcv_rcpt_rec.wip_operation_seq_num;
638 l_rcv_transaction_rec.wip_resource_seq_num := l_rcv_rcpt_rec.wip_resource_seq_num;
639 l_rcv_transaction_rec.wip_repetitive_schedule_id := l_rcv_rcpt_rec.wip_repetitive_schedule_id;
640 l_rcv_transaction_rec.wip_line_id := l_rcv_rcpt_rec.wip_line_id;
641 l_rcv_transaction_rec.bom_resource_id := l_rcv_rcpt_rec.bom_resource_id;
642
643 --Bug #4147209 - Populate the record type with the DFF attribute category
644 --and segment values passed from the mobile UI
645 set_attribute_vals(
646 p_rcv_rcpt_rec => l_rcv_rcpt_rec
647 , p_attribute_category => p_attribute_category
648 , p_attribute1 => p_attribute1
649 , p_attribute2 => p_attribute2
650 , p_attribute3 => p_attribute3
651 , p_attribute4 => p_attribute4
652 , p_attribute5 => p_attribute5
653 , p_attribute6 => p_attribute6
654 , p_attribute7 => p_attribute7
655 , p_attribute8 => p_attribute8
656 , p_attribute9 => p_attribute9
657 , p_attribute10 => p_attribute10
658 , p_attribute11 => p_attribute11
659 , p_attribute12 => p_attribute12
660 , p_attribute13 => p_attribute13
661 , p_attribute14 => p_attribute14
662 , p_attribute15 => p_attribute15);
663
664 IF (l_debug = 1) THEN
665 print_debug('create_osp_drct_dlvr_rti_rec: 8 - before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
666 END IF;
667
668 populate_default_values(
669 p_rcv_transaction_rec => l_rcv_transaction_rec
670 , p_rcv_rcpt_rec => l_rcv_rcpt_rec
671 , p_group_id => l_group_id
672 , p_organization_id => p_organization_id
673 , p_item_id => p_item_id
674 , p_revision => p_revision
675 , p_source_type => p_source_type
676 , p_subinventory_code => NULL
677 , p_locator_id => NULL
678 , p_transaction_temp_id => p_transaction_temp_id
679 , p_lot_control_code => NULL
680 , p_serial_control_code => NULL
681 );
682
683
684 /* FP-J Lot/Serial Support Enhancement
685 * Populate the table to store the information of the RTIs created and
686 * split the lots and serials based on RTI quantity
687 */
688 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) OR
689 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po )) THEN
690
691 --BUG 3326408,3346758,3405320
692 --If there are any serials confirmed from the UI for an item that is
693 --lot controlled and serial control dynamic at SO issue,
694 --do not NULL out serial_transaction_temp_id. In other cases,
695 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
696 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
697 l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
698 IF (l_debug = 1) THEN
699 print_debug('create_osp_drct_dlvr_rti_rec 8.6:
700 serial_control_code IS '||l_rcv_rcpt_rec.serial_number_control_code || ' , need TO NULL OUT mtli', 4);
701 END IF;
702 BEGIN
703 UPDATE mtl_transaction_lots_interface
704 SET serial_transaction_temp_id = NULL
705 WHERE product_transaction_id = p_transaction_temp_id
706 AND product_code = 'RCV';
707 EXCEPTION
708 WHEN OTHERS THEN
709 IF (l_debug = 1) THEN
710 print_debug('create_osp_drct_dlvr_rti_rec 8.7: Error nulling serial temp id OF MTLI', 4);
711 END IF;
712 END ;
713 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
714
715 l_new_rti_info(1).orig_interface_trx_id := p_transaction_temp_id;
716 l_new_rti_info(1).new_interface_trx_id := g_interface_transaction_id;
717 l_new_rti_info(1).quantity := l_rcv_transaction_rec.transaction_qty;
718
719 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
720 p_api_version => 1.0
721 , p_init_msg_lst => FND_API.G_FALSE
722 , x_return_status => l_return_status
723 , x_msg_count => l_msg_count
724 , x_msg_data => x_message
725 , p_new_rti_info => l_new_rti_info);
726 IF ( NOT l_split_lot_serial_ok) THEN
727 IF (l_debug = 1) THEN
728 print_debug('create_osp_drct_dlvr_rti_rec 8.1: Failure in split_lot_serial', 4);
729 END IF;
730 RAISE FND_API.G_EXC_ERROR;
731 END IF;
732
733 IF (l_debug = 1) THEN
734 print_debug('create_osp_drct_dlvr_rti_rec 8.2: Call split_lot_serial is OK', 4);
735 END IF;
736 END IF;
737
738
739 IF (l_debug = 1) THEN
740 print_debug('create_osp_drct_dlvr_rti_rec: 9 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
741 END IF;
742
743 l_progress := '65';
744 inv_rcv_common_apis.do_check(
745 p_organization_id => p_organization_id
746 , p_inventory_item_id => p_item_id
747 , p_transaction_type_id => 18
748 , p_primary_quantity => l_total_primary_qty
749 , x_return_status => l_return_status
750 , x_msg_count => l_msg_count
751 , x_msg_data => x_message
752 );
753
754 IF l_return_status <> fnd_api.g_ret_sts_success THEN
755 x_status := l_return_status;
756 END IF;
757
758 l_progress := '70';
759 -- Clear the Lot Rec
760 inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
761
762 IF (l_debug = 1) THEN
763 print_debug('Exiting create_osp_drct_dlvr_rti_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
764 END IF;
765 EXCEPTION
766 WHEN fnd_api.g_exc_error THEN
767 ROLLBACK TO crt_po_rti_sp;
768 x_status := fnd_api.g_ret_sts_error;
769
770 IF l_curs_rcpt_detail%ISOPEN THEN
771 CLOSE l_curs_rcpt_detail;
772 END IF;
773
774 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
775
776 IF (l_debug = 1) THEN
777 print_debug('create_osp_drct_dlvr_rti_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
778 END IF;
779 WHEN fnd_api.g_exc_unexpected_error THEN
780 ROLLBACK TO crt_po_rti_sp;
781 x_status := fnd_api.g_ret_sts_unexp_error;
782
783 IF l_curs_rcpt_detail%ISOPEN THEN
784 CLOSE l_curs_rcpt_detail;
785 END IF;
786
787 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
788
789 IF (l_debug = 1) THEN
790 print_debug('create_osp_drct_dlvr_rti_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
791 END IF;
792 WHEN OTHERS THEN
793 ROLLBACK TO crt_po_rti_sp;
794 x_status := fnd_api.g_ret_sts_unexp_error;
795
796 IF l_curs_rcpt_detail%ISOPEN THEN
797 CLOSE l_curs_rcpt_detail;
798 END IF;
799
800 IF SQLCODE IS NOT NULL THEN
801 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_osp_drct_dlvr_rti_rec', l_progress, SQLCODE);
802 END IF;
803
804 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
805
806 IF (l_debug = 1) THEN
807 print_debug('create_osp_drct_dlvr_rti_rec: OTHER exception : ' || SQLCODE || ' '
808 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
809 , 4);
810 END IF;
811 END create_osp_drct_dlvr_rti_rec;
812
813 PROCEDURE create_po_drct_dlvr_rti_rec(
814 p_move_order_header_id IN OUT NOCOPY NUMBER
815 , p_organization_id IN NUMBER
816 , p_po_header_id IN NUMBER
817 , p_po_release_id IN NUMBER
818 , p_po_line_id IN NUMBER
819 , p_po_line_location_id IN NUMBER
820 , p_po_distribution_id IN NUMBER
821 , p_item_id IN NUMBER
822 , p_rcv_qty IN NUMBER
823 , p_rcv_uom IN VARCHAR2
824 , p_rcv_uom_code IN VARCHAR2
825 , p_source_type IN VARCHAR2
826 , p_subinventory VARCHAR2
827 , p_locator_id NUMBER
828 , p_transaction_temp_id IN NUMBER
829 , p_lot_control_code IN NUMBER
830 , p_serial_control_code IN NUMBER
831 , p_lpn_id IN NUMBER
832 , p_revision IN VARCHAR2
833 , x_status OUT NOCOPY VARCHAR2
834 , x_message OUT NOCOPY VARCHAR2
835 , p_inv_item_id IN NUMBER
836 , p_item_desc IN VARCHAR2
837 , p_location_id IN NUMBER
838 , p_is_expense IN VARCHAR2
839 , p_project_id IN NUMBER
840 , p_task_id IN NUMBER
841 , p_country_code IN VARCHAR2 DEFAULT NULL
842 , p_secondary_rcv_qty IN NUMBER DEFAULT NULL --OPM Convergence
843 , p_rcv_sec_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
844 , p_rcv_sec_uom_code IN VARCHAR2 DEFAULT NULL --OPM Convergence
845 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209
846 , p_attribute1 IN VARCHAR2 DEFAULT NULL
847 , p_attribute2 IN VARCHAR2 DEFAULT NULL
848 , p_attribute3 IN VARCHAR2 DEFAULT NULL
849 , p_attribute4 IN VARCHAR2 DEFAULT NULL
850 , p_attribute5 IN VARCHAR2 DEFAULT NULL
851 , p_attribute6 IN VARCHAR2 DEFAULT NULL
852 , p_attribute7 IN VARCHAR2 DEFAULT NULL
853 , p_attribute8 IN VARCHAR2 DEFAULT NULL
854 , p_attribute9 IN VARCHAR2 DEFAULT NULL
855 , p_attribute10 IN VARCHAR2 DEFAULT NULL
856 , p_attribute11 IN VARCHAR2 DEFAULT NULL
857 , p_attribute12 IN VARCHAR2 DEFAULT NULL
858 , p_attribute13 IN VARCHAR2 DEFAULT NULL
859 , p_attribute14 IN VARCHAR2 DEFAULT NULL
860 , p_attribute15 IN VARCHAR2 DEFAULT NULL
861 ) IS
862 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
863 l_rcv_transaction_rec inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
864 l_transaction_type VARCHAR2(20) := 'DELIVER';
865 l_total_primary_qty NUMBER := 0;
866 l_msg_count NUMBER;
867 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
868 l_group_id NUMBER;
869 l_rcv_rcpt_rec inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
870 --l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
871
872 l_err_message VARCHAR2(100);
873 l_temp_message VARCHAR2(100);
874 l_msg_prod VARCHAR2(5);
875 l_progress VARCHAR2(10);
876
877 CURSOR l_curs_rcpt_detail(v_po_distribution_id NUMBER) IS
878 SELECT 'N' line_chkbox
879 , 'VENDOR' source_type_code
880 , 'VENDOR' receipt_source_code
881 , 'PO' order_type_code
882 , '' order_type
883 , poll.po_header_id po_header_id
884 , poh.segment1 po_number
885 , poll.po_line_id po_line_id
886 , pol.line_num po_line_number
887 , poll.line_location_id po_line_location_id
888 , poll.shipment_num po_shipment_number
889 , poll.po_release_id po_release_id
890 , por.release_num po_release_number
891 , TO_NUMBER(NULL) req_header_id
892 , NULL req_number
893 , TO_NUMBER(NULL) req_line_id
894 , TO_NUMBER(NULL) req_line
895 , TO_NUMBER(NULL) req_distribution_id
896 --Passing as NULL for the columns for which values are not known. --Bug #3878174
897 , TO_NUMBER(NULL) rcv_shipment_header_id
898 , NULL rcv_shipment_number
899 , TO_NUMBER(NULL) rcv_shipment_line_id
900 , TO_NUMBER(NULL) rcv_line_number
901 , TO_NUMBER(NULL) from_organization_id
902 /*
903 , poh.po_header_id rcv_shipment_header_id
904 , poh.segment1 rcv_shipment_number
905 , pol.po_line_id rcv_shipment_line_id
906 , pol.line_num rcv_line_number
907 , poh.po_header_id from_organization_id
908 */
909 , poll.ship_to_organization_id to_organization_id
910 , poh.vendor_id vendor_id
911 , '' SOURCE
912 , poh.vendor_site_id vendor_site_id
913 , '' outside_operation_flag
914 , pol.item_id item_id
915 , -- Bug 2073164
916 NULL uom_code
917 -- , pol.unit_meas_lookup_code primary_uom
918 , msi.primary_unit_of_measure primary_uom /* Bug 5665041:Primary UOM should be taken from MSI*/
919 , mum.uom_class primary_uom_class
920 , NULL item_allowed_units_lookup_code
921 , NULL item_locator_control
922 , '' restrict_locators_code
923 , '' restrict_subinventories_code
924 , NULL shelf_life_code
925 , NULL shelf_life_days
926 , msi.serial_number_control_code serial_number_control_code
927 , msi.lot_control_code lot_control_code
928 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
929 , NULL item_rev_control_flag_from
930 , NULL item_number
931 , pol.item_revision item_revision
932 , pol.item_description item_description
933 , pol.category_id item_category_id
934 , '' hazard_class
935 , '' un_number
936 , pol.vendor_product_num vendor_item_number
937 , poll.ship_to_location_id ship_to_location_id
938 , '' ship_to_location
939 , NULL packing_slip
940 , poll.receiving_routing_id routing_id
941 , '' routing_name
942 , poll.need_by_date need_by_date
943 , NVL(poll.promised_date, poll.need_by_date) expected_receipt_date
944 , poll.quantity ordered_qty
945 , pol.unit_meas_lookup_code ordered_uom
946 , NULL ussgl_transaction_code
947 , poll.government_context government_context
948 , poll.inspection_required_flag inspection_required_flag
949 , poll.receipt_required_flag receipt_required_flag
950 , poll.enforce_ship_to_location_code enforce_ship_to_location_code
951 , NVL(poll.price_override, pol.unit_price) unit_price
952 , poh.currency_code currency_code
953 , poh.rate_type currency_conversion_type
954 , poh.rate_date currency_conversion_date
955 , poh.rate currency_conversion_rate
956 , poh.note_to_receiver note_to_receiver
957 , pod.destination_type_code destination_type_code
958 , pod.deliver_to_person_id deliver_to_person_id
959 , pod.deliver_to_location_id deliver_to_location_id
960 , pod.destination_subinventory destination_subinventory
961 , poll.attribute_category attribute_category
962 , poll.attribute1 attribute1
963 , poll.attribute2 attribute2
964 , poll.attribute3 attribute3
965 , poll.attribute4 attribute4
966 , poll.attribute5 attribute5
967 , poll.attribute6 attribute6
968 , poll.attribute7 attribute7
969 , poll.attribute8 attribute8
970 , poll.attribute9 attribute9
971 , poll.attribute10 attribute10
972 , poll.attribute11 attribute11
973 , poll.attribute12 attribute12
974 , poll.attribute13 attribute13
975 , poll.attribute14 attribute14
976 , poll.attribute15 attribute15
977 , poll.closed_code closed_code
978 , NULL asn_type
979 , NULL bill_of_lading
980 , TO_DATE(NULL) shipped_date
981 , NULL freight_carrier_code
982 , NULL waybill_airbill_num
983 , NULL freight_bill_num
984 , NULL vendor_lot_num
985 , NULL container_num
986 , NULL truck_num
987 , NULL bar_code_label
988 , '' rate_type_display
989 , poll.match_option match_option
990 , poll.country_of_origin_code country_of_origin_code
991 , TO_NUMBER(NULL) oe_order_header_id
992 , TO_NUMBER(NULL) oe_order_num
993 , TO_NUMBER(NULL) oe_order_line_id
994 , TO_NUMBER(NULL) oe_order_line_num
995 , TO_NUMBER(NULL) customer_id
996 , TO_NUMBER(NULL) customer_site_id
997 , NULL customer_item_num
998 , NULL pll_note_to_receiver
999 , --POLL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
1000 pod.po_distribution_id
1001 , pod.quantity_ordered - pod.quantity_delivered qty_ordered
1002 , pod.wip_entity_id
1003 , pod.wip_operation_seq_num
1004 , pod.wip_resource_seq_num
1005 , pod.wip_repetitive_schedule_id
1006 , pod.wip_line_id
1007 , pod.bom_resource_id
1008 , '' destination_type
1009 , '' LOCATION
1010 , pod.rate currency_conversion_rate_pod
1011 , pod.rate_date currency_conversion_date_pod
1012 , pod.project_id project_id
1013 , pod.task_id task_id
1014 , pol.secondary_uom secondary_uom --OPM Convergence
1015 , NULL secondary_uom_code --OPM Convergence
1016 , pol.secondary_qty secondary_quantity --OPM Convergence
1017 FROM po_headers poh
1018 , po_line_locations poll
1019 , po_lines pol
1020 , po_releases por
1021 , mtl_system_items msi
1022 , mtl_units_of_measure mum
1023 , po_distributions pod
1024 WHERE pod.po_distribution_id = v_po_distribution_id
1025 AND poh.po_header_id = poll.po_header_id
1026 AND pol.po_line_id = poll.po_line_id
1027 AND poll.po_release_id = por.po_release_id(+)
1028 AND pod.line_location_id = poll.line_location_id
1029 AND mum.unit_of_measure(+) = pol.unit_meas_lookup_code
1030 AND NVL(msi.organization_id, poll.ship_to_organization_id) = poll.ship_to_organization_id
1031 AND msi.inventory_item_id(+) = pol.item_id
1032 AND (p_project_id IS NULL
1033 OR(p_project_id = -9999
1034 AND pod.project_id IS NULL) -- bug 2669021
1035 OR pod.project_id = p_project_id)
1036 AND (p_task_id IS NULL
1037 OR pod.task_id = p_task_id);
1038
1039 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1040 --table to store all RTId, quantity and original_rti_id for lot/serial splits
1041 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
1042 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
1043 l_msni_count NUMBER := 0;
1044 BEGIN
1045 x_status := fnd_api.g_ret_sts_success;
1046
1047 IF (l_debug = 1) THEN
1048 print_debug('Enter create_po_drct_dlvr_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1049 END IF;
1050
1051 SAVEPOINT crt_po_rti_sp;
1052 l_progress := '10';
1053
1054 -- query po_startup_value
1055 BEGIN
1056 inv_rcv_common_apis.init_startup_values(p_organization_id);
1057 EXCEPTION
1058 WHEN NO_DATA_FOUND THEN
1059 fnd_message.set_name('INV', 'INV_RCV_PARAM');
1060 fnd_msg_pub.ADD;
1061 RAISE;
1062 END;
1063
1064 l_progress := '20';
1065
1066 -- default l_group_id ? clear group id after done
1067 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
1068 SELECT rcv_interface_groups_s.NEXTVAL
1069 INTO l_group_id
1070 FROM DUAL;
1071
1072 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
1073
1074 IF (l_debug = 1) THEN
1075 print_debug('create_po_drct_dlvr_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
1076 END IF;
1077 ELSE
1078 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1079
1080 IF (l_debug = 1) THEN
1081 print_debug('create_po_drct_dlvr_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
1082 END IF;
1083 END IF;
1084
1085 l_progress := '30';
1086 -- initialize input record for matching algorithm
1087 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
1088 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
1089 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).unit_of_measure := p_rcv_uom;
1090
1091 IF (l_debug = 1) THEN
1092 print_debug(
1093 'create_po_rcpt_intf_rec: 40-S - p_inv_item_id' || TO_CHAR(p_inv_item_id) || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1094 , 4
1095 );
1096 END IF;
1097
1098 IF p_inv_item_id IS NOT NULL THEN -- p_item_id has substitute item id
1099 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_inv_item_id;
1100 ELSE
1101 IF p_item_id IS NOT NULL THEN
1102 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
1103 ELSE
1104 IF (l_debug = 1) THEN
1105 print_debug('create_po_rcpt_intf_rec: Item id is null - One time item', 4);
1106 END IF;
1107
1108 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := NULL;
1109 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_desc := p_item_desc;
1110 END IF;
1111 END IF;
1112
1113 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
1114 p_organization_id;
1115 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
1116 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_header_id := p_po_header_id;
1117 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_release_id := p_po_release_id;
1118 -- line id, line location id and distribution id will be passed only from the putaway api.
1119 -- line id however, can also be passed through the UI if the line number
1120 -- field is enabled on the UI.
1121 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_line_id := p_po_line_id;
1122 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_line_location_id :=
1123 p_po_line_location_id;
1124 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_distribution_id :=
1125 p_po_distribution_id;
1126
1127 IF p_item_id IS NOT NULL THEN
1128 BEGIN
1129 SELECT primary_unit_of_measure
1130 INTO inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
1131 FROM mtl_system_items
1132 WHERE mtl_system_items.inventory_item_id = p_item_id
1133 AND mtl_system_items.organization_id = p_organization_id;
1134 EXCEPTION
1135 WHEN NO_DATA_FOUND THEN
1136 NULL;
1137
1138 IF (l_debug = 1) THEN
1139 print_debug('create_po_drct_dlvr_rti_rec: 3 - get primary_unit_of_measure exception', 4);
1140 END IF;
1141 END;
1142 ELSE
1143 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure := NULL;
1144 END IF;
1145
1146 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).revision := p_revision;
1147 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id;
1148 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id := p_task_id;
1149 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
1150 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
1151 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
1152
1153 IF (l_debug = 1) THEN
1154 print_debug(
1155 'create_po_drct_dlvr_rti_rec: 4 - before inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1156 , 4
1157 );
1158 END IF;
1159
1160 l_progress := '40';
1161 inv_rcv_txn_interface.matching_logic(
1162 x_return_status => x_status
1163 , x_msg_count => l_msg_count
1164 , x_msg_data => x_message
1165 , x_cascaded_table => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
1166 , n => inv_rcv_std_rcpt_apis.g_receipt_detail_index
1167 , temp_cascaded_table => l_rcpt_match_table_detail
1168 , p_receipt_num => NULL
1169 , p_shipment_header_id => NULL
1170 , p_lpn_id => NULL
1171 );
1172
1173 IF (l_debug = 1) THEN
1174 print_debug('create_po_drct_dlvr_rti_rec: 5 - after inv_rcv_txn_interface.matching_logic'
1175 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1176 , 4);
1177 END IF;
1178
1179 -- x_status is not successful if there is any execution error in matching.
1180 IF x_status = fnd_api.g_ret_sts_error THEN
1181 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1182 fnd_msg_pub.ADD;
1183
1184 IF (l_debug = 1) THEN
1185 print_debug('create_po_drct_dlvr_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1186 END IF;
1187
1188 RAISE fnd_api.g_exc_error;
1189 END IF;
1190
1191 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
1192 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1193 fnd_msg_pub.ADD;
1194
1195 IF (l_debug = 1) THEN
1196 print_debug('Exiting create_po_drct_dlvr_rti_rec 60.2: Unexpect error calling matching'
1197 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1198 , 1);
1199 END IF;
1200
1201 RAISE fnd_api.g_exc_unexpected_error;
1202 END IF;
1203
1204 IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
1205 l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
1206 fnd_message.set_name('INV', l_err_message);
1207 fnd_msg_pub.ADD;
1208
1209 IF (l_debug = 1) THEN
1210 print_debug('create_po_drct_dlvr_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1211 END IF;
1212
1213 RAISE fnd_api.g_exc_error;
1214 END IF;
1215
1216 l_err_message := '@@@';
1217
1218 FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
1219 inv_rcv_std_rcpt_apis.g_receipt_detail_index
1220 + l_rcpt_match_table_detail.COUNT
1221 - 1
1222 ) LOOP
1223 IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
1224 x_status := 'W';
1225 l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
1226
1227 IF l_temp_message IS NULL THEN
1228 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
1229 l_msg_prod := 'INV';
1230 EXIT;
1231 END IF;
1232
1233 IF l_err_message = '@@@' THEN
1234 l_err_message := l_temp_message;
1235 l_msg_prod := 'INV';
1236 ELSIF l_temp_message <> l_err_message THEN
1237 l_msg_prod := 'INV';
1238 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
1239 EXIT;
1240 END IF;
1241 END IF;
1242 END LOOP;
1243
1244 IF l_err_message <> '@@@' THEN
1245 fnd_message.set_name(l_msg_prod, l_err_message);
1246 fnd_msg_pub.ADD;
1247
1248 IF (l_debug = 1) THEN
1249 print_debug('create_po_drct_dlvr_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1250 END IF;
1251 END IF;
1252
1253 -- based on return from matching algorithm,
1254 -- determine which line in rcv_transaction block to be inserted into RTI
1255 IF (l_debug = 1) THEN
1256 print_debug('create_po_drct_dlvr_rti_rec: 6 - start loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1257 END IF;
1258
1259 l_progress := '60';
1260
1261 -- loop through results returned by matching algorithm
1262 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
1263 l_progress := '62';
1264 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).po_distribution_id);
1265 l_progress := '64';
1266 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
1267 -- Earlier item_id was filled with PO Line Item ID if the parameter p_inv_item_id
1268 -- is not null, so that matching logic finds shipments. Now, in order to actually
1269 -- insert RTI, replace item_id with a new value which is nothing but the substitute
1270 -- item.
1271 l_rcv_rcpt_rec.item_id := p_item_id;
1272 l_progress := '66';
1273 CLOSE l_curs_rcpt_detail;
1274 l_progress := '68';
1275
1276 IF (l_debug = 1) THEN
1277 print_debug('create_po_rcvtxn_intf_rec found a match 60', 4);
1278 print_debug('Matching returned values 60.1 - distribution_id:'
1279 || l_rcpt_match_table_detail(match_result_count).po_distribution_id
1280 , 4);
1281 print_debug('Matching returned values 60.1 - transaction_quantity:'
1282 || l_rcpt_match_table_detail(match_result_count).quantity
1283 , 4);
1284 print_debug('Matching returned values 60.1 - transaction_uom:'
1285 || l_rcpt_match_table_detail(match_result_count).unit_of_measure
1286 , 4);
1287 print_debug('Matching returned values 60.1 - primary_quantity:'
1288 || l_rcpt_match_table_detail(match_result_count).primary_quantity
1289 , 4);
1290 print_debug(
1291 'Matching returned values 60.1 - primary_uom:' || l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure
1292 , 4
1293 );
1294 END IF;
1295
1296 l_rcv_transaction_rec.po_distribution_id := l_rcpt_match_table_detail(match_result_count).po_distribution_id;
1297 -- update following fields from matching algorithm return value
1298 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
1299 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
1300 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
1301 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
1302 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
1303 /* OPM Convergence we dont base matching logic on secondary uom and secondary quantity.
1304 * Instead we calculate the secondary qty based on the ratio on which primary qty is split.
1305 */
1306 l_progress := '70';
1307 l_rcv_transaction_rec.secondary_uom := p_rcv_sec_uom;
1308 print_debug('create_po_drct_dlvr_rti_rec: sec_uom ' || p_rcv_sec_uom);
1309 l_rcv_transaction_rec.secondary_uom_code := p_rcv_sec_uom_code;
1310 print_debug('create_po_drct_dlvr_rti_rec: sec_uom_code ' || p_rcv_sec_uom_code);
1311 l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) * p_secondary_rcv_qty;
1312 print_debug('secondary quantity after matching logic qty is obtained is ' ||l_rcv_transaction_rec.secondary_quantity);
1313
1314 -- Nested LPN changes. Populate p_lpn_id as NULL for patchset J and above
1315 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po OR
1316 inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j OR
1317 inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
1318
1319 l_rcv_transaction_rec.lpn_id := p_lpn_id;
1320 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
1321 ELSE
1322 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
1323 END IF;
1324
1325 -- update following fields for po_distribution related values
1326 l_rcv_transaction_rec.currency_conversion_date := l_rcv_rcpt_rec.currency_conversion_date_pod;
1327 l_rcv_transaction_rec.currency_conversion_rate := l_rcv_rcpt_rec.currency_conversion_rate_pod;
1328 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.qty_ordered;
1329 --Bug 2073164
1330 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
1331
1332 -- wip related fields
1333 IF l_rcv_rcpt_rec.wip_entity_id > 0 THEN
1334 l_rcv_transaction_rec.wip_entity_id := l_rcv_rcpt_rec.wip_entity_id;
1335 l_rcv_transaction_rec.wip_operation_seq_num := l_rcv_rcpt_rec.wip_operation_seq_num;
1336 l_rcv_transaction_rec.wip_resource_seq_num := l_rcv_rcpt_rec.wip_resource_seq_num;
1337 l_rcv_transaction_rec.wip_repetitive_schedule_id := l_rcv_rcpt_rec.wip_repetitive_schedule_id;
1338 l_rcv_transaction_rec.wip_line_id := l_rcv_rcpt_rec.wip_line_id;
1339 l_rcv_transaction_rec.bom_resource_id := l_rcv_transaction_rec.bom_resource_id;
1340 -- there is getting actual values call for wip
1341 -- since they are not inserted in RTI, I am not calling it here
1342 -- the code is in
1343 -- rcv_transactions_sv.get_wip_info ()
1344 END IF;
1345
1346 IF p_country_code IS NOT NULL THEN
1347 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
1348 END IF;
1349
1350 IF (l_debug = 1) THEN
1351 print_debug('create_po_drct_dlvr_rti_rec: 8 - before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1352 END IF;
1353
1354 -- Deliver_to_location_id is mandatory for Expense Items case
1355 -- So if no deliver_to_location_id is present in the distributions of po for Expense Items
1356 -- we will default it to the value passed from the mobile UI.
1357
1358 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po OR
1359 inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j OR
1360 inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
1361 NULL;
1362 ELSE
1363 if l_rcv_rcpt_rec.destination_type_code = 'EXPENSE' then
1364 IF (l_debug = 1) THEN
1365 print_debug('create_po_drct_dlvr_rti_rec: p_location_id ='|| p_location_id, 4);
1366 print_debug('create_po_drct_dlvr_rti_rec: l_rcv_transaction_rec.deliver_to_location_id ='|| l_rcv_transaction_rec.deliver_to_location_id, 4);
1367 END IF;
1368 if l_rcv_transaction_rec.deliver_to_location_id is null and
1369 p_location_id is not null then
1370 l_rcv_transaction_rec.deliver_to_location_id := p_location_id;
1371 End if;
1372 End if;
1373 END IF;
1374
1375 --Bug #4147209 - Populate the record type with the DFF attribute category
1376 --and segment values passed from the mobile UI
1377 set_attribute_vals(
1378 p_rcv_rcpt_rec => l_rcv_rcpt_rec
1379 , p_attribute_category => p_attribute_category
1380 , p_attribute1 => p_attribute1
1381 , p_attribute2 => p_attribute2
1382 , p_attribute3 => p_attribute3
1383 , p_attribute4 => p_attribute4
1384 , p_attribute5 => p_attribute5
1385 , p_attribute6 => p_attribute6
1386 , p_attribute7 => p_attribute7
1387 , p_attribute8 => p_attribute8
1388 , p_attribute9 => p_attribute9
1389 , p_attribute10 => p_attribute10
1390 , p_attribute11 => p_attribute11
1391 , p_attribute12 => p_attribute12
1392 , p_attribute13 => p_attribute13
1393 , p_attribute14 => p_attribute14
1394 , p_attribute15 => p_attribute15);
1395
1396
1397 populate_default_values(
1398 p_rcv_transaction_rec => l_rcv_transaction_rec
1399 , p_rcv_rcpt_rec => l_rcv_rcpt_rec
1400 , p_group_id => l_group_id
1401 , p_organization_id => p_organization_id
1402 , p_item_id => p_item_id
1403 , p_revision => p_revision
1404 , p_source_type => p_source_type
1405 , p_subinventory_code => p_subinventory
1406 , p_locator_id => p_locator_id
1407 , p_transaction_temp_id => p_transaction_temp_id
1408 , p_lot_control_code => p_lot_control_code
1409 , p_serial_control_code => p_serial_control_code
1410 , p_project_id => p_project_id
1411 , p_task_id => p_task_id
1412 );
1413
1414
1415 /* FP-J Lot/Serial Support Enhancement
1416 * Populate the table to store the information of the RTIs created used for
1417 * splitting the lots and serials based on RTI quantity
1418 */
1419 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
1420 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
1421 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
1422 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
1423 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
1424 /*OPM Convergence. Populate the calculated secondary quantity */
1425 l_new_rti_info(match_result_count).sec_qty := l_rcv_transaction_rec.secondary_quantity;
1426
1427 IF (l_debug = 1) THEN
1428 print_debug('create_po_drct_dlvr_rti_rec: 8.5 - Populated the table for lot/serial split', 4);
1429 END IF;
1430 END IF; --END IF populate the table to store RTI info that was just created
1431
1432 IF (l_debug = 1) THEN
1433 print_debug('create_po_drct_dlvr_rti_rec: 9 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1434 END IF;
1435
1436 l_progress := '80';
1437 END LOOP;
1438
1439 /* FP-J Lot/Serial Support Enhancement
1440 * Call the split_lot API to split the lots and serials inserted from the UI
1441 * based on the quantity of each RTI record
1442 */
1443 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
1444 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
1445 --BUG 3326408,3346758,3405320
1446 --If there are any serials confirmed from the UI for an item that is
1447 --lot controlled and serial control dynamic at SO issue,
1448 --do not NULL out serial_transaction_temp_id. In other cases,
1449 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
1450 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
1451 l_rcv_rcpt_rec.serial_number_control_code IN(1,6)) THEN
1452 IF (l_debug = 1) THEN
1453 print_debug('create_po_drct_dlvr_rti_rec 9.6: serial_control_code IS 6, need TO NULL OUT mtli', 4);
1454 END IF;
1455 BEGIN
1456 UPDATE mtl_transaction_lots_interface
1457 SET serial_transaction_temp_id = NULL
1458 WHERE product_transaction_id = p_transaction_temp_id
1459 AND product_code = 'RCV';
1460 EXCEPTION
1461 WHEN OTHERS THEN
1462 IF (l_debug = 1) THEN
1463 print_debug('create_po_drct_dlvr_rti_rec 9.7: Error nulling serial temp id OF MTLI', 4);
1464 END IF;
1465 END ;
1466 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
1467
1468 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
1469 p_api_version => 1.0
1470 , p_init_msg_lst => FND_API.G_FALSE
1471 , x_return_status => l_return_status
1472 , x_msg_count => l_msg_count
1473 , x_msg_data => x_message
1474 , p_new_rti_info => l_new_rti_info);
1475 IF ( NOT l_split_lot_serial_ok) THEN
1476 IF (l_debug = 1) THEN
1477 print_debug('create_po_drct_dlvr_rti_rec 10.1: Failure in split_lot_serial', 4);
1478 END IF;
1479 RAISE FND_API.G_EXC_ERROR;
1480 END IF;
1481
1482 IF (l_debug = 1) THEN
1483 print_debug('create_po_drct_dlvr_rti_rec 10.2: Call split_lot_serial is OK', 4);
1484 END IF;
1485 END IF; --END IF check INV J and PO J installed
1486
1487 -- append index in input table where the line to be detailed needs to be inserted
1488 --inv_rcv_std_rcpt_apis.g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + inv_rcv_std_rcpt_apis.g_receipt_detail_index;
1489
1490 l_progress := '90';
1491 inv_rcv_common_apis.do_check(
1492 p_organization_id => p_organization_id
1493 , p_inventory_item_id => p_item_id
1494 , p_transaction_type_id => 18
1495 , p_primary_quantity => l_total_primary_qty
1496 , x_return_status => l_return_status
1497 , x_msg_count => l_msg_count
1498 , x_msg_data => x_message
1499 );
1500
1501 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1502 x_status := l_return_status;
1503 END IF;
1504
1505 l_progress := '100';
1506 -- Clear the Lot Rec
1507 inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
1508
1509 IF (l_debug = 1) THEN
1510 print_debug('Exiting create_po_drct_dlvr_rti_rec:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1511 END IF;
1512 EXCEPTION
1513 WHEN fnd_api.g_exc_error THEN
1514 ROLLBACK TO crt_po_rti_sp;
1515 x_status := fnd_api.g_ret_sts_error;
1516
1517 IF l_curs_rcpt_detail%ISOPEN THEN
1518 CLOSE l_curs_rcpt_detail;
1519 END IF;
1520
1521 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
1522
1523 IF (l_debug = 1) THEN
1524 print_debug('create_po_drct_dlvr_rti_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1525 END IF;
1526 WHEN fnd_api.g_exc_unexpected_error THEN
1527 ROLLBACK TO crt_po_rti_sp;
1528 x_status := fnd_api.g_ret_sts_unexp_error;
1529
1530 IF l_curs_rcpt_detail%ISOPEN THEN
1531 CLOSE l_curs_rcpt_detail;
1532 END IF;
1533
1534 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
1535
1536 IF (l_debug = 1) THEN
1537 print_debug('create_po_drct_dlvr_rti_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1538 END IF;
1539 WHEN OTHERS THEN
1540 ROLLBACK TO crt_po_rti_sp;
1541 x_status := fnd_api.g_ret_sts_unexp_error;
1542
1543 IF l_curs_rcpt_detail%ISOPEN THEN
1544 CLOSE l_curs_rcpt_detail;
1545 END IF;
1546
1547 IF SQLCODE IS NOT NULL THEN
1548 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_po_drct_dlvr_rti_rec', l_progress, SQLCODE);
1549 END IF;
1550
1551 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
1552
1553 IF (l_debug = 1) THEN
1554 print_debug('create_po_drct_dlvr_rti_rec: OTHER exception : ' || SQLCODE || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1555 , 4);
1556 END IF;
1557 END create_po_drct_dlvr_rti_rec;
1558
1559 PROCEDURE create_int_shp_dr_del_rti_rec(
1560 p_move_order_header_id IN OUT NOCOPY NUMBER
1561 , p_organization_id IN NUMBER
1562 , p_shipment_header_id IN NUMBER
1563 , p_shipment_line_id IN NUMBER
1564 , p_item_id IN NUMBER
1565 , p_rcv_qty IN NUMBER
1566 , p_rcv_uom IN VARCHAR2
1567 , p_rcv_uom_code IN VARCHAR2
1568 , p_source_type IN VARCHAR2
1569 , p_subinventory VARCHAR2
1570 , p_locator_id NUMBER
1571 , p_transaction_temp_id IN NUMBER
1572 , p_lot_control_code IN NUMBER
1573 , p_serial_control_code IN NUMBER
1574 , p_from_lpn_id IN NUMBER
1575 , p_lpn_id IN NUMBER
1576 , p_revision IN VARCHAR2
1577 , p_project_id IN NUMBER DEFAULT NULL
1578 , p_task_id IN NUMBER DEFAULT NULL
1579 , x_status OUT NOCOPY VARCHAR2
1580 , x_message OUT NOCOPY VARCHAR2
1581 , p_country_code IN VARCHAR2 DEFAULT NULL
1582 , p_secondary_rcv_qty IN NUMBER DEFAULT NULL --OPM Convergence
1583 , p_rcv_sec_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
1584 , p_rcv_sec_uom_code IN VARCHAR2 DEFAULT NULL --OPM Convergence
1585 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
1586 , p_attribute1 IN VARCHAR2 DEFAULT NULL
1587 , p_attribute2 IN VARCHAR2 DEFAULT NULL
1588 , p_attribute3 IN VARCHAR2 DEFAULT NULL
1589 , p_attribute4 IN VARCHAR2 DEFAULT NULL
1590 , p_attribute5 IN VARCHAR2 DEFAULT NULL
1591 , p_attribute6 IN VARCHAR2 DEFAULT NULL
1592 , p_attribute7 IN VARCHAR2 DEFAULT NULL
1593 , p_attribute8 IN VARCHAR2 DEFAULT NULL
1594 , p_attribute9 IN VARCHAR2 DEFAULT NULL
1595 , p_attribute10 IN VARCHAR2 DEFAULT NULL
1596 , p_attribute11 IN VARCHAR2 DEFAULT NULL
1597 , p_attribute12 IN VARCHAR2 DEFAULT NULL
1598 , p_attribute13 IN VARCHAR2 DEFAULT NULL
1599 , p_attribute14 IN VARCHAR2 DEFAULT NULL
1600 , p_attribute15 IN VARCHAR2 DEFAULT NULL
1601 ) IS
1602 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
1603 l_rcv_transaction_rec inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
1604 l_transaction_type VARCHAR2(20) := 'DELIVER';
1605 l_total_primary_qty NUMBER := 0;
1606 l_msg_count NUMBER;
1607 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
1608 l_group_id NUMBER;
1609 l_rcv_rcpt_rec inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
1610 l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
1611 l_err_message VARCHAR2(100);
1612 l_temp_message VARCHAR2(100);
1613 l_msg_prod VARCHAR2(5);
1614 l_progress VARCHAR2(10);
1615 l_receipt_num VARCHAR2(30);
1616
1617 CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER) IS
1618 SELECT 'N' line_chkbox
1619 , 'INTERNAL' source_type_code
1620 , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
1621 , rsl.source_document_code order_type_code
1622 , '' order_type
1623 --Passing as NULL for the columns for which value is not known. --Bug #3878174
1624 , TO_NUMBER(NULL) po_header_id
1625 , NULL po_number
1626 , TO_NUMBER(NULL) po_line_id
1627 , TO_NUMBER(NULL) po_line_number
1628 , TO_NUMBER(NULL) po_line_location_id
1629 , NULL po_shipment_number
1630 , TO_NUMBER(NULL) po_release_id
1631 , TO_NUMBER(NULL) po_release_number
1632 /*
1633 , rsh.shipment_header_id po_header_id
1634 , rsh.shipment_num po_number
1635 , rsl.shipment_line_id po_line_id
1636 , rsl.line_num po_line_number
1637 , rsl.shipment_line_id po_line_location_id
1638 , rsl.line_num po_shipment_number
1639 , rsh.shipment_header_id po_release_id
1640 , rsh.shipment_header_id po_release_number
1641 */
1642 , porh.requisition_header_id req_header_id
1643 , porh.segment1 req_number
1644 , porl.requisition_line_id req_line_id
1645 , porl.line_num req_line
1646 , rsl.req_distribution_id req_distribution_id
1647 , rsl.shipment_header_id rcv_shipment_header_id
1648 , rsh.shipment_num rcv_shipment_number
1649 , rsl.shipment_line_id rcv_shipment_line_id
1650 , rsl.line_num rcv_line_number
1651 , rsl.from_organization_id from_organization_id
1652 , rsl.to_organization_id to_organization_id
1653 , rsl.shipment_line_id vendor_id
1654 , '' SOURCE
1655 , TO_NUMBER(NULL) vendor_site_id
1656 , 'N' outside_operation_flag
1657 , rsl.item_id item_id
1658 , -- Bug 2073164
1659 NULL uom_code
1660 , rsl.unit_of_measure primary_uom
1661 , mum.uom_class primary_uom_class
1662 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
1663 , NVL(msi.location_control_code, 1) item_locator_control
1664 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
1665 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
1666 , NVL(msi.shelf_life_code, 1) shelf_life_code
1667 , NVL(msi.shelf_life_days, 0) shelf_life_days
1668 , msi.serial_number_control_code serial_number_control_code
1669 , msi.lot_control_code lot_control_code
1670 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
1671 , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
1672 , NULL item_number
1673 , rsl.item_revision item_revision
1674 , rsl.item_description item_description
1675 , rsl.category_id item_category_id
1676 , '' hazard_class
1677 , '' un_number
1678 , rsl.vendor_item_num vendor_item_number
1679 , rsh.ship_to_location_id ship_to_location_id
1680 , '' ship_to_location
1681 , rsh.packing_slip packing_slip
1682 , rsl.routing_header_id routing_id
1683 , '' routing_name
1684 , porl.need_by_date need_by_date
1685 , rsh.expected_receipt_date expected_receipt_date
1686 , rsl.quantity_shipped ordered_qty
1687 , rsl.primary_unit_of_measure ordered_uom
1688 , rsh.ussgl_transaction_code ussgl_transaction_code
1689 , rsh.government_context government_context
1690 , NULL inspection_required_flag
1691 , NULL receipt_required_flag
1692 , NULL enforce_ship_to_location_code
1693 , TO_NUMBER(NULL) unit_price
1694 , NULL currency_code
1695 , NULL currency_conversion_type
1696 , TO_DATE(NULL) currency_conversion_date
1697 , TO_NUMBER(NULL) currency_conversion_rate
1698 , NULL note_to_receiver
1699 , --PORL.NOTE_TO_RECEIVER NOTE_TO_RECEIVER,
1700 rsl.destination_type_code destination_type_code
1701 , rsl.deliver_to_person_id deliver_to_person_id
1702 , rsl.deliver_to_location_id deliver_to_location_id
1703 , rsl.to_subinventory destination_subinventory
1704 , rsl.attribute_category attribute_category
1705 , rsl.attribute1 attribute1
1706 , rsl.attribute2 attribute2
1707 , rsl.attribute3 attribute3
1708 , rsl.attribute4 attribute4
1709 , rsl.attribute5 attribute5
1710 , rsl.attribute6 attribute6
1711 , rsl.attribute7 attribute7
1712 , rsl.attribute8 attribute8
1713 , rsl.attribute9 attribute9
1714 , rsl.attribute10 attribute10
1715 , rsl.attribute11 attribute11
1716 , rsl.attribute12 attribute12
1717 , rsl.attribute13 attribute13
1718 , rsl.attribute14 attribute14
1719 , rsl.attribute15 attribute15
1720 , 'OPEN' closed_code
1721 , NULL asn_type
1722 , rsh.bill_of_lading bill_of_lading
1723 , rsh.shipped_date shipped_date
1724 , rsh.freight_carrier_code freight_carrier_code
1725 , rsh.waybill_airbill_num waybill_airbill_num
1726 , rsh.freight_bill_number freight_bill_num
1727 , rsl.vendor_lot_num vendor_lot_num
1728 , rsl.container_num container_num
1729 , rsl.truck_num truck_num
1730 , rsl.bar_code_label bar_code_label
1731 , NULL rate_type_display
1732 , 'P' match_option
1733 , NULL country_of_origin_code
1734 , TO_NUMBER(NULL) oe_order_header_id
1735 , TO_NUMBER(NULL) oe_order_num
1736 , TO_NUMBER(NULL) oe_order_line_id
1737 , TO_NUMBER(NULL) oe_order_line_num
1738 , TO_NUMBER(NULL) customer_id
1739 , TO_NUMBER(NULL) customer_site_id
1740 , NULL customer_item_num
1741 , NULL pll_note_to_receiver
1742 , --PORL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
1743 NULL po_distribution_id
1744 , NULL qty_ordered
1745 , NULL wip_entity_id
1746 , NULL wip_operation_seq_num
1747 , NULL wip_resource_seq_num
1748 , NULL wip_repetitive_schedule_id
1749 , NULL wip_line_id
1750 , NULL bom_resource_id
1751 , '' destination_type
1752 , '' LOCATION
1753 , NULL currency_conversion_rate_pod
1754 , NULL currency_conversion_date_pod
1755 , NULL project_id
1756 , NULL task_id
1757 , NULL secondary_uom --OPM Convergence
1758 , NULL secondary_uom_code --OPM Convergence
1759 , NULL secondary_quantity --OPM Convergence
1760 FROM rcv_shipment_headers rsh
1761 , rcv_shipment_lines rsl
1762 , po_requisition_headers porh
1763 , po_requisition_lines porl
1764 , mtl_system_items msi
1765 , mtl_system_items msi1
1766 , mtl_units_of_measure mum
1767 WHERE rsh.receipt_source_code <> 'VENDOR'
1768 AND rsl.requisition_line_id = porl.requisition_line_id(+)
1769 AND porl.requisition_header_id = porh.requisition_header_id(+)
1770 AND rsh.shipment_header_id = rsl.shipment_header_id
1771 AND mum.unit_of_measure(+) = rsl.unit_of_measure
1772 AND msi.organization_id(+) = rsl.to_organization_id
1773 AND msi.inventory_item_id(+) = rsl.item_id
1774 AND msi1.organization_id(+) = rsl.from_organization_id
1775 AND msi1.inventory_item_id(+) = rsl.item_id
1776 AND rsl.shipment_line_id = v_shipment_line_id
1777 AND (
1778 (
1779 rsl.source_document_code = 'REQ'
1780 AND EXISTS(
1781 SELECT '1'
1782 FROM po_req_distributions_all prd
1783 WHERE prd.requisition_line_id = porl.requisition_line_id
1784 AND
1785 (
1786 p_project_id IS NULL
1787 OR(p_project_id = -9999
1788 AND prd.project_id IS NULL)
1789 OR -- bug 2669021
1790 prd.project_id = p_project_id
1791 )
1792 AND (p_task_id IS NULL
1793 OR prd.task_id = p_task_id))
1794 )
1795 OR rsl.source_document_code <> 'REQ'
1796 );
1797
1798 -- 3441084 Requisition_line_id also needs to be joined in the above Query otherwise will do
1799 -- a full scan on po_req_distributions_all which is not good.
1800
1801
1802 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1803 --table to store all RTId, quantity and original_rti_id for lot/serial splits
1804 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
1805 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
1806 l_msni_count NUMBER := 0;
1807 BEGIN
1808 x_status := fnd_api.g_ret_sts_success;
1809
1810 IF (l_debug = 1) THEN
1811 print_debug('Enter create_int_shp_dr_del_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1812 END IF;
1813
1814 l_progress := '10';
1815 SAVEPOINT crt_intship_rti_sp;
1816
1817 -- query po_startup_value
1818 BEGIN
1819 /* Bug #2516729
1820 * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
1821 * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
1822 * in order that a new receipt # is not created everytime and the existing receipt # is used
1823 */
1824 BEGIN
1825 SELECT receipt_num
1826 INTO l_receipt_num
1827 FROM rcv_shipment_headers
1828 WHERE shipment_header_id = p_shipment_header_id
1829 AND ship_to_org_id = p_organization_id;
1830
1831 --Bug 4552825 - Assign the value only if it is not null
1832 IF l_receipt_num IS NOT NULL THEN
1833 inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
1834 END IF;
1835
1836 IF (l_debug = 1) THEN
1837 print_debug('create_int_shp_dr_del_rti_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
1838 END IF;
1839 EXCEPTION
1840 WHEN NO_DATA_FOUND THEN
1841 l_receipt_num := NULL;
1842 END;
1843
1844 inv_rcv_common_apis.init_startup_values(p_organization_id);
1845 EXCEPTION
1846 WHEN NO_DATA_FOUND THEN
1847 fnd_message.set_name('INV', 'INV_RCV_PARAM');
1848 fnd_msg_pub.ADD;
1849 RAISE;
1850 END;
1851
1852 l_progress := '20';
1853
1854 -- default l_group_id ? clear group id after done
1855 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
1856 SELECT rcv_interface_groups_s.NEXTVAL
1857 INTO l_group_id
1858 FROM DUAL;
1859
1860 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
1861
1862 IF (l_debug = 1) THEN
1863 print_debug('create_int_shp_dr_del_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
1864 END IF;
1865 ELSE
1866 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1867
1868 IF (l_debug = 1) THEN
1869 print_debug('create_int_shp_dr_del_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
1870 END IF;
1871 END IF;
1872
1873 l_progress := '30';
1874 -- initialize input record for matching algorithm
1875 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
1876 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
1877 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).unit_of_measure := p_rcv_uom;
1878 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
1879 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
1880 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
1881 p_organization_id;
1882 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).shipment_header_id :=
1883 p_shipment_header_id;
1884 -- line id will be passed only from the putaway api.
1885 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).shipment_line_id :=
1886 p_shipment_line_id;
1887 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id;
1888 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id := p_task_id;
1889
1890 BEGIN
1891 SELECT primary_unit_of_measure
1892 INTO inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
1893 FROM mtl_system_items
1894 WHERE mtl_system_items.inventory_item_id = p_item_id
1895 AND mtl_system_items.organization_id = p_organization_id;
1896 EXCEPTION
1897 WHEN NO_DATA_FOUND THEN
1898 IF (l_debug = 1) THEN
1899 print_debug('create_int_shp_dr_del_rti_rec: 3 - get primary_unit_of_measure exception', 4);
1900 END IF;
1901 END;
1902
1903 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
1904 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
1905 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
1906 l_progress := '40';
1907
1908 IF (l_debug = 1) THEN
1909 print_debug(
1910 'create_int_shp_dr_del_rti_rec: 4.0 - before inv_rcv_txn_interface.matching_logic'
1911 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1912 , 4
1913 );
1914 print_debug('create_int_shp_dr_del_rti_rec: 4.0 - p_from_lpn_id => '||p_from_lpn_id,4);
1915 END IF;
1916
1917 inv_rcv_txn_match.matching_logic(
1918 x_return_status => x_status
1919 , --?
1920 x_msg_count => l_msg_count
1921 , x_msg_data => x_message
1922 , x_cascaded_table => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
1923 , n => inv_rcv_std_rcpt_apis.g_receipt_detail_index
1924 , temp_cascaded_table => l_rcpt_match_table_detail
1925 , p_receipt_num => NULL
1926 , p_match_type => 'INTRANSIT SHIPMENT'
1927 , p_lpn_id => p_from_lpn_id --BUG 4613635 : pass
1928 --from_lpn_id to matching_logic so that
1929 --the rsl with the correct asn_lpn_id
1930 --can be matched
1931 );
1932
1933 IF (l_debug = 1) THEN
1934 print_debug(
1935 'create_int_shp_dr_del_rti_rec: 4 - after inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1936 , 4
1937 );
1938 print_debug('create_int_shp_dr_del_rti_rec: 4.1 - after matching l_return_status = ' || x_status, 4);
1939 print_debug('create_int_shp_dr_del_rti_rec: 4.2 - after matching l_msg_count = ' || l_msg_count, 4);
1940 print_debug('create_int_shp_dr_del_rti_rec: 4.3 - after matching l_msg_data = ' || x_message, 4);
1941 END IF;
1942
1943 -- x_status is not successful if there is any execution error in matching.
1944 IF x_status = fnd_api.g_ret_sts_error THEN
1945 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1946 fnd_msg_pub.ADD;
1947
1948 IF (l_debug = 1) THEN
1949 print_debug('create_int_shp_dr_del_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1950 END IF;
1951
1952 RAISE fnd_api.g_exc_error;
1953 END IF;
1954
1955 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
1956 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1957 fnd_msg_pub.ADD;
1958
1959 IF (l_debug = 1) THEN
1960 print_debug('create_int_shp_dr_del_rti_rec 60.2: Unexpect error calling matching'
1961 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1962 , 1);
1963 END IF;
1964
1965 RAISE fnd_api.g_exc_unexpected_error;
1966 END IF;
1967
1968 IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
1969 l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
1970 fnd_message.set_name('INV', l_err_message);
1971 fnd_msg_pub.ADD;
1972
1973 IF (l_debug = 1) THEN
1974 print_debug('create_int_shp_dr_del_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1975 END IF;
1976
1977 RAISE fnd_api.g_exc_error;
1978 END IF;
1979
1980 l_err_message := '@@@';
1981
1982 FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
1983 inv_rcv_std_rcpt_apis.g_receipt_detail_index
1984 + l_rcpt_match_table_detail.COUNT
1985 - 1
1986 ) LOOP
1987 IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
1988 x_status := 'W';
1989 l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
1990
1991 IF l_temp_message IS NULL THEN
1992 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
1993 l_msg_prod := 'INV';
1994 EXIT;
1995 END IF;
1996
1997 IF l_err_message = '@@@' THEN
1998 l_err_message := l_temp_message;
1999 l_msg_prod := 'INV';
2000 ELSIF l_temp_message <> l_err_message THEN
2001 l_msg_prod := 'INV';
2002 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2003 EXIT;
2004 END IF;
2005 END IF;
2006 END LOOP;
2007
2008 IF l_err_message <> '@@@' THEN
2009 fnd_message.set_name(l_msg_prod, l_err_message);
2010 fnd_msg_pub.ADD;
2011
2012 IF (l_debug = 1) THEN
2013 print_debug('create_int_shp_dr_del_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2014 END IF;
2015 END IF;
2016
2017 l_progress := '50';
2018
2019 IF (l_debug = 1) THEN
2020 print_debug('create_int_shp_dr_del_rti_rec: 90 - start loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2021 END IF;
2022
2023 l_rcv_transaction_rec.rcv_shipment_line_id := l_rcv_rcpt_rec.rcv_shipment_line_id;
2024 -- loop through results returned by matching algorithm
2025 l_progress := '60';
2026
2027 IF (l_debug = 1) THEN
2028 print_debug('create_int_shp_dr_del_rti_rec no recs matched by matching 95:' || l_rcpt_match_table_detail.COUNT, 4);
2029 END IF;
2030
2031 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
2032 l_progress := '62';
2033 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).shipment_line_id);
2034 l_progress := '64';
2035 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
2036 l_progress := '66';
2037 CLOSE l_curs_rcpt_detail;
2038 l_progress := '68';
2039
2040 IF (l_debug = 1) THEN
2041 print_debug('create_int_shp_dr_del_rti_rec found a match 100', 4);
2042 print_debug('Matching returned values 100.1 - shipment_line_id:'
2043 || l_rcpt_match_table_detail(match_result_count).shipment_line_id
2044 , 4);
2045 print_debug('Matching returned values 100.1 - transaction_quantity:'
2046 || l_rcpt_match_table_detail(match_result_count).quantity
2047 , 4);
2048 print_debug('Matching returned values 100.1 - transaction_uom:'
2049 || l_rcpt_match_table_detail(match_result_count).unit_of_measure
2050 , 4);
2051 print_debug('Matching returned values 100.1 - primary_quantity:'
2052 || l_rcpt_match_table_detail(match_result_count).primary_quantity
2053 , 4);
2054 print_debug(
2055 'Matching returned values 100.1 - primary_uom:' || l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure
2056 , 4
2057 );
2058 END IF;
2059
2060 l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
2061
2062 -- Get the transfer_cost_group_id from rcv_shipment_lines
2063 BEGIN
2064 SELECT cost_group_id
2065 INTO l_rcv_transaction_rec.transfer_cost_group_id
2066 FROM rcv_shipment_lines
2067 WHERE shipment_line_id = l_rcv_transaction_rec.rcv_shipment_line_id;
2068 EXCEPTION
2069 WHEN OTHERS THEN
2070 IF (l_debug = 1) THEN
2071 print_debug('exception in getting transfer cost group id', 4);
2072 END IF;
2073
2074 l_rcv_transaction_rec.transfer_cost_group_id := NULL;
2075 END;
2076
2077 -- update following fields from matching algorithm return value
2078 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
2079 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
2080 --Bug 2073164
2081 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
2082 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
2083 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
2084 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2085 l_progress := '70';
2086
2087 /* OPM Convergence we dont base matching logic on secondary uom and secondary quantity.
2088 * Instead we calculate the secondary qty based on the ratio on which primary qty is split.
2089 */
2090 l_progress := '70';
2091 l_rcv_transaction_rec.secondary_uom := p_rcv_sec_uom;
2092 print_debug('create_po_drct_dlvr_rti_rec: sec_uom ' || p_rcv_sec_uom);
2093 l_rcv_transaction_rec.secondary_uom_code := p_rcv_sec_uom_code;
2094 print_debug('create_po_drct_dlvr_rti_rec: sec_uom_code ' || p_rcv_sec_uom_code);
2095 l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) * p_secondary_rcv_qty;
2096 print_debug('secondary quantity after matching logic qty is obtained is ' ||l_rcv_transaction_rec.secondary_quantity);
2097
2098 -- Nested LPN changes If FromLPN is not null and Patchset Level of INV,WMS,PO
2099 -- are at J then pass From_lpn_id as lpn_id otherwise use old code.
2100 --IF p_from_lpn_id IS NOT NULL
2101 IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
2102 AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
2103 AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
2104 l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
2105 ELSE
2106 l_rcv_transaction_rec.lpn_id := p_lpn_id;
2107 END IF;
2108
2109 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2110
2111 IF p_country_code IS NOT NULL THEN
2112 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
2113 END IF;
2114
2115 --Bug #4147209 - Populate the record type with the DFF attribute category
2116 --and segment values passed from the mobile UI
2117 set_attribute_vals(
2118 p_rcv_rcpt_rec => l_rcv_rcpt_rec
2119 , p_attribute_category => p_attribute_category
2120 , p_attribute1 => p_attribute1
2121 , p_attribute2 => p_attribute2
2122 , p_attribute3 => p_attribute3
2123 , p_attribute4 => p_attribute4
2124 , p_attribute5 => p_attribute5
2125 , p_attribute6 => p_attribute6
2126 , p_attribute7 => p_attribute7
2127 , p_attribute8 => p_attribute8
2128 , p_attribute9 => p_attribute9
2129 , p_attribute10 => p_attribute10
2130 , p_attribute11 => p_attribute11
2131 , p_attribute12 => p_attribute12
2132 , p_attribute13 => p_attribute13
2133 , p_attribute14 => p_attribute14
2134 , p_attribute15 => p_attribute15);
2135
2136 IF (l_debug = 1) THEN
2137 print_debug('create_int_shp_dr_del_rti_rec: 110 - before populate_default_values'
2138 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2139 , 4);
2140 END IF;
2141
2142 populate_default_values(
2143 p_rcv_transaction_rec => l_rcv_transaction_rec
2144 , p_rcv_rcpt_rec => l_rcv_rcpt_rec
2145 , p_group_id => l_group_id
2146 , p_organization_id => p_organization_id
2147 , p_item_id => p_item_id
2148 , p_revision => p_revision
2149 , p_source_type => p_source_type
2150 , p_subinventory_code => p_subinventory
2151 , p_locator_id => p_locator_id
2152 , p_transaction_temp_id => p_transaction_temp_id
2153 , p_lot_control_code => p_lot_control_code
2154 , p_serial_control_code => p_serial_control_code
2155 , p_project_id => p_project_id
2156 , p_task_id => p_task_id
2157 );
2158
2159
2160 /* FP-J Lot/Serial Support Enhancement
2161 * Populate the table to store the information of the RTIs created used for
2162 * splitting the lots and serials based on RTI quantity
2163 */
2164 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2165 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2166 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
2167 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
2168 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
2169 IF (l_debug = 1) THEN
2170 print_debug('create_int_shp_dr_del_rti_rec: 115 - Populated the table for lot/serial split', 4);
2171 END IF;
2172 END IF; --END IF populate the table to store RTI info that was just created
2173
2174 IF (l_debug = 1) THEN
2175 print_debug('create_int_shp_dr_del_rti_rec: 120 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2176 , 4);
2177 END IF;
2178
2179 l_progress := '80';
2180
2181 IF (l_debug = 1) THEN
2182 print_debug('create_int_shp_dr_del_rti_rec: 125 - before update_rcv_serials_supply'
2183 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2184 , 4);
2185 END IF;
2186
2187 /* FP-J Lot/Serial Support Enhancement
2188 * No updates to rcv_serials_supply if INV J and PO J are installed
2189 */
2190 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
2191 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
2192 IF l_rcv_rcpt_rec.req_line_id IS NOT NULL
2193 AND p_serial_control_code NOT IN(1, 6) THEN
2194 -- update rss for req
2195 inv_rcv_std_deliver_apis.update_rcv_serials_supply(
2196 x_return_status => l_return_status
2197 , x_msg_count => l_msg_count
2198 , x_msg_data => x_message
2199 , p_shipment_line_id => l_rcv_transaction_rec.rcv_shipment_line_id
2200 );
2201 END IF;
2202
2203 IF (l_debug = 1) THEN
2204 print_debug('create_int_shp_dr_del_rti_rec: 127 - after update_rcv_serials_supply'
2205 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2206 , 4);
2207 END IF;
2208 END IF; --END IF PO J and INV J installed
2209 END LOOP;
2210
2211 /* FP-J Lot/Serial Support Enhancement
2212 * Call the split_lot API to split the lots and serials inserted from the UI
2213 * based on the quantity of each RTI record
2214 */
2215 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2216 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2217 --BUG 3326408,3346758,3405320
2218 --If there are any serials confirmed from the UI for an item that is
2219 --lot controlled and serial control dynamic at SO issue,
2220 --do not NULL out serial_transaction_temp_id. In other cases,
2221 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
2222 l_msni_count := 0;
2223 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
2224 l_rcv_rcpt_rec.serial_number_control_code IN(1,6)) THEN
2225 IF (l_debug = 1) THEN
2226 print_debug('create_int_shp_dr_del_rti_rec 128.2: serial_control_code IS 6, need TO NULL OUT mtli', 4);
2227 END IF;
2228 BEGIN
2229 IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2230 SELECT count(1)
2231 INTO l_msni_count
2232 FROM mtl_serial_numbers_interface
2233 WHERE product_transaction_id = p_transaction_temp_id
2234 AND product_code = 'RCV';
2235 END IF;
2236 IF (l_msni_count = 0) THEN
2237 UPDATE mtl_transaction_lots_interface
2238 SET serial_transaction_temp_id = NULL
2239 WHERE product_transaction_id = p_transaction_temp_id
2240 AND product_code = 'RCV';
2241 END IF;
2242 EXCEPTION
2243 WHEN OTHERS THEN
2244 IF (l_debug = 1) THEN
2245 print_debug('create_int_shp_dr_del_rti_rec 128.4: Error nulling serial temp id OF MTLI', 4);
2246 END IF;
2247 END ;
2248 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2249
2250 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2251 p_api_version => 1.0
2252 , p_init_msg_lst => FND_API.G_FALSE
2253 , x_return_status => l_return_status
2254 , x_msg_count => l_msg_count
2255 , x_msg_data => x_message
2256 , p_new_rti_info => l_new_rti_info);
2257 IF ( NOT l_split_lot_serial_ok) THEN
2258 IF (l_debug = 1) THEN
2259 print_debug('create_int_shp_dr_del_rti_rec 129.1: Failure in split_lot_serial', 4);
2260 END IF;
2261 RAISE FND_API.G_EXC_ERROR;
2262 END IF;
2263
2264 IF (l_debug = 1) THEN
2265 print_debug('create_int_shp_dr_del_rti_rec 128.2: Call split_lot_serial is OK', 4);
2266 END IF;
2267 END IF; --END IF check INV J and PO J installed
2268
2269 -- append index in input table where the line to be detailed needs to be inserted
2270 --inv_rcv_std_rcpt_apis.g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + inv_rcv_std_rcpt_apis.g_receipt_detail_index;
2271 l_progress := '90';
2272 inv_rcv_common_apis.do_check(
2273 p_organization_id => p_organization_id
2274 , p_inventory_item_id => p_item_id
2275 , p_transaction_type_id => 61
2276 , p_primary_quantity => l_total_primary_qty
2277 , x_return_status => l_return_status
2278 , x_msg_count => l_msg_count
2279 , x_msg_data => x_message
2280 );
2281
2282 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2283 x_status := l_return_status;
2284 END IF;
2285
2286 l_progress := '100';
2287 -- Clear the Lot Rec
2288 inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
2289
2290 IF (l_debug = 1) THEN
2291 print_debug('About exit create_int_shp_dr_del_rti_rec: 130 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2292 END IF;
2293 EXCEPTION
2294 WHEN fnd_api.g_exc_error THEN
2295 ROLLBACK TO crt_intship_rti_sp;
2296 x_status := fnd_api.g_ret_sts_error;
2297
2298 IF l_curs_rcpt_detail%ISOPEN THEN
2299 CLOSE l_curs_rcpt_detail;
2300 END IF;
2301
2302 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2303
2304 IF (l_debug = 1) THEN
2305 print_debug('create_int_shp_dr_del_rti_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2306 END IF;
2307 WHEN fnd_api.g_exc_unexpected_error THEN
2308 ROLLBACK TO crt_intship_rti_sp;
2309 x_status := fnd_api.g_ret_sts_unexp_error;
2310
2311 IF l_curs_rcpt_detail%ISOPEN THEN
2312 CLOSE l_curs_rcpt_detail;
2313 END IF;
2314
2315 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2316
2317 IF (l_debug = 1) THEN
2318 print_debug('create_int_shp_dr_del_rti_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2319 END IF;
2320 WHEN OTHERS THEN
2321 ROLLBACK TO crt_intship_rti_sp;
2322 x_status := fnd_api.g_ret_sts_unexp_error;
2323
2324 IF l_curs_rcpt_detail%ISOPEN THEN
2325 CLOSE l_curs_rcpt_detail;
2326 END IF;
2327
2328 IF SQLCODE IS NOT NULL THEN
2329 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_int_shp_dr_del_rti_rec', l_progress, SQLCODE);
2330 END IF;
2331
2332 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2333 END create_int_shp_dr_del_rti_rec;
2334
2335 PROCEDURE create_rma_drct_dlvr_rti_rec(
2336 p_move_order_header_id IN OUT NOCOPY NUMBER
2337 , p_organization_id IN NUMBER
2338 , p_oe_order_header_id IN NUMBER
2339 , p_oe_order_line_id IN NUMBER
2340 , p_item_id IN NUMBER
2341 , p_rcv_qty IN NUMBER
2342 , p_rcv_uom IN VARCHAR2
2343 , p_rcv_uom_code IN VARCHAR2
2344 , p_source_type IN VARCHAR2
2345 , p_subinventory VARCHAR2
2346 , p_locator_id NUMBER
2347 , p_transaction_temp_id IN NUMBER
2348 , p_lot_control_code IN NUMBER
2349 , p_serial_control_code IN NUMBER
2350 , p_lpn_id IN NUMBER
2351 , p_revision IN VARCHAR2
2352 , x_status OUT NOCOPY VARCHAR2
2353 , x_message OUT NOCOPY VARCHAR2
2354 , p_project_id IN NUMBER
2355 , p_task_id IN NUMBER
2356 , p_country_code IN VARCHAR2 DEFAULT NULL
2357 , p_secondary_rcv_qty IN NUMBER DEFAULT NULL --OPM Convergence
2358 , p_rcv_sec_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
2359 , p_rcv_sec_uom_code IN VARCHAR2 DEFAULT NULL --OPM Convergence
2360 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
2361 , p_attribute1 IN VARCHAR2 DEFAULT NULL
2362 , p_attribute2 IN VARCHAR2 DEFAULT NULL
2363 , p_attribute3 IN VARCHAR2 DEFAULT NULL
2364 , p_attribute4 IN VARCHAR2 DEFAULT NULL
2365 , p_attribute5 IN VARCHAR2 DEFAULT NULL
2366 , p_attribute6 IN VARCHAR2 DEFAULT NULL
2367 , p_attribute7 IN VARCHAR2 DEFAULT NULL
2368 , p_attribute8 IN VARCHAR2 DEFAULT NULL
2369 , p_attribute9 IN VARCHAR2 DEFAULT NULL
2370 , p_attribute10 IN VARCHAR2 DEFAULT NULL
2371 , p_attribute11 IN VARCHAR2 DEFAULT NULL
2372 , p_attribute12 IN VARCHAR2 DEFAULT NULL
2373 , p_attribute13 IN VARCHAR2 DEFAULT NULL
2374 , p_attribute14 IN VARCHAR2 DEFAULT NULL
2375 , p_attribute15 IN VARCHAR2 DEFAULT NULL
2376 ) IS
2377 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
2378 l_rcv_transaction_rec inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
2379 l_transaction_type VARCHAR2(20) := 'DELIVER';
2380 l_total_primary_qty NUMBER := 0;
2381 l_msg_count NUMBER;
2382 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
2383 l_group_id NUMBER;
2384 l_rcv_rcpt_rec inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
2385 l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
2386 l_err_message VARCHAR2(100);
2387 l_temp_message VARCHAR2(100);
2388 l_msg_prod VARCHAR2(5);
2389 l_progress VARCHAR2(10);
2390
2391 CURSOR l_curs_rcpt_detail(v_oe_order_line_id NUMBER) IS
2392 SELECT 'N' line_chkbox
2393 , 'CUSTOMER' source_type_code
2394 , 'CUSTOMER' receipt_source_code
2395 , '' order_type_code
2396 , '' order_type
2397 , TO_NUMBER(NULL) po_header_id
2398 , NULL po_number
2399 , TO_NUMBER(NULL) po_line_id
2400 , TO_NUMBER(NULL) po_line_number
2401 , TO_NUMBER(NULL) po_line_location_id
2402 , TO_NUMBER(NULL) po_shipment_number
2403 , TO_NUMBER(NULL) po_release_id
2404 , TO_NUMBER(NULL) po_release_number
2405 , TO_NUMBER(NULL) req_header_id
2406 , NULL req_number
2407 , TO_NUMBER(NULL) req_line_id
2408 , TO_NUMBER(NULL) req_line
2409 , TO_NUMBER(NULL) req_distribution_id
2410 , TO_NUMBER(NULL) rcv_shipment_header_id
2411 , NULL rcv_shipment_number
2412 , TO_NUMBER(NULL) rcv_shipment_line_id
2413 , TO_NUMBER(NULL) rcv_line_number
2414 , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) from_organization_id
2415 , NVL(oel.ship_from_org_id, oeh.ship_from_org_id) to_organization_id
2416 , TO_NUMBER(NULL) vendor_id
2417 , '' SOURCE
2418 , TO_NUMBER(NULL) vendor_site_id
2419 , NULL outside_operation_flag
2420 , oel.inventory_item_id item_id
2421 , -- Bug 2073164
2422 NULL uom_code
2423 , mum.unit_of_measure primary_uom
2424 , mum.uom_class primary_uom_class
2425 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
2426 , NVL(msi.location_control_code, 1) item_locator_control
2427 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
2428 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
2429 , NVL(msi.shelf_life_code, 1) shelf_life_code
2430 , NVL(msi.shelf_life_days, 0) shelf_life_days
2431 , msi.serial_number_control_code serial_number_control_code
2432 , msi.lot_control_code lot_control_code
2433 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
2434 , NULL item_rev_control_flag_from
2435 , msi.segment1 item_number
2436 , oel.item_revision item_revision
2437 , msi.description item_description
2438 , TO_NUMBER(NULL) item_category_id
2439 , NULL hazard_class
2440 , NULL un_number
2441 , NULL vendor_item_number
2442 , oel.ship_from_org_id ship_to_location_id
2443 , '' ship_to_location
2444 , NULL packing_slip
2445 , TO_NUMBER(NULL) routing_id
2446 , NULL routing_name
2447 , oel.request_date need_by_date
2448 , NVL(oel.promise_date, oel.request_date) expected_receipt_date
2449 , oel.ordered_quantity ordered_qty
2450 , '' ordered_uom
2451 , NULL ussgl_transaction_code
2452 , NULL government_context
2453 , DECODE(msi.return_inspection_requirement, 1, 'Y', 'N') inspection_required_flag--bug 4700067
2454 , 'Y' receipt_required_flag
2455 , 'N' enforce_ship_to_location_code
2456 , oel.unit_selling_price unit_price
2457 , oeh.transactional_curr_code currency_code
2458 , oeh.conversion_type_code currency_conversion_type
2459 , oeh.conversion_rate_date currency_conversion_date
2460 , oeh.conversion_rate currency_conversion_rate
2461 , NULL note_to_receiver
2462 , NULL destination_type_code
2463 , oel.deliver_to_contact_id deliver_to_person_id
2464 , oel.deliver_to_org_id deliver_to_location_id
2465 , NULL destination_subinventory
2466 , oel.CONTEXT attribute_category
2467 , oel.attribute1 attribute1
2468 , oel.attribute2 attribute2
2469 , oel.attribute3 attribute3
2470 , oel.attribute4 attribute4
2471 , oel.attribute5 attribute5
2472 , oel.attribute6 attribute6
2473 , oel.attribute7 attribute7
2474 , oel.attribute8 attribute8
2475 , oel.attribute9 attribute9
2476 , oel.attribute10 attribute10
2477 , oel.attribute11 attribute11
2478 , oel.attribute12 attribute12
2479 , oel.attribute13 attribute13
2480 , oel.attribute14 attribute14
2481 , oel.attribute15 attribute15
2482 , NULL closed_code
2483 , NULL asn_type
2484 , NULL bill_of_lading
2485 , TO_DATE(NULL) shipped_date
2486 , NULL freight_carrier_code
2487 , NULL waybill_airbill_num
2488 , NULL freight_bill_num
2489 , NULL vendor_lot_num
2490 , NULL container_num
2491 , NULL truck_num
2492 , NULL bar_code_label
2493 , NULL rate_type_display
2494 , NULL match_option
2495 , NULL country_of_origin_code
2496 , oel.header_id oe_order_header_id
2497 , oeh.order_number oe_order_num
2498 , oel.line_id oe_order_line_id
2499 , oel.line_number oe_order_line_num
2500 , oel.sold_to_org_id customer_id
2501 , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) customer_site_id
2502 , '' customer_item_num
2503 , '' pll_note_to_receiver
2504 , NULL po_distribution_id
2505 , NULL qty_ordered
2506 , NULL wip_entity_id
2507 , NULL wip_operation_seq_num
2508 , NULL wip_resource_seq_num
2509 , NULL wip_repetitive_schedule_id
2510 , NULL wip_line_id
2511 , NULL bom_resource_id
2512 , '' destination_type
2513 , '' LOCATION
2514 , NULL currency_conversion_rate_pod
2515 , NULL currency_conversion_date_pod
2516 , NULL project_id
2517 , NULL task_id
2518 , NULL secondary_uom --OPM Convergence
2519 , NULL secondary_uom_code --OPM Convergence
2520 , NULL secondary_quantity --OPM Convergence
2521 FROM oe_order_lines_all oel
2522 , oe_order_headers_all oeh
2523 , mtl_system_items msi
2524 , mtl_units_of_measure mum
2525 WHERE oel.line_category_code = 'RETURN'
2526 AND oel.header_id = oeh.header_id
2527 AND oel.inventory_item_id = msi.inventory_item_id
2528 AND oel.ship_from_org_id = msi.organization_id
2529 AND msi.primary_uom_code = mum.uom_code
2530 AND oel.booked_flag = 'Y'
2531 AND oel.ordered_quantity > NVL(oel.shipped_quantity, 0)
2532 AND msi.mtl_transactions_enabled_flag = 'Y'
2533 AND oel.line_id = v_oe_order_line_id
2534 AND (p_project_id IS NULL
2535 OR(p_project_id = -9999
2536 AND oel.project_id IS NULL)
2537 OR -- bug 2669021
2538 oel.project_id = p_project_id)
2539 AND (p_task_id IS NULL
2540 OR oel.task_id = p_task_id);
2541
2542 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2543 --table to store all RTId, quantity and original_rti_id for lot/serial splits
2544 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
2545 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
2546 BEGIN
2547 x_status := fnd_api.g_ret_sts_success;
2548
2549 IF (l_debug = 1) THEN
2550 print_debug('Enter create_rma_drct_dlvr_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2551 END IF;
2552
2553 l_progress := '10';
2554 SAVEPOINT crt_rma_rti_sp;
2555
2556 -- query po_startup_value
2557 BEGIN
2558 inv_rcv_common_apis.init_startup_values(p_organization_id);
2559 EXCEPTION
2560 WHEN NO_DATA_FOUND THEN
2561 fnd_message.set_name('INV', 'INV_RCV_PARAM');
2562 fnd_msg_pub.ADD;
2563 RAISE;
2564 END;
2565
2566 l_progress := '20';
2567
2568 -- default l_group_id ? clear group id after done
2569 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
2570 SELECT rcv_interface_groups_s.NEXTVAL
2571 INTO l_group_id
2572 FROM DUAL;
2573
2574 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
2575
2576 IF (l_debug = 1) THEN
2577 print_debug('create_rma_drct_dlvr_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
2578 END IF;
2579 ELSE
2580 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
2581
2582 IF (l_debug = 1) THEN
2583 print_debug('create_rma_drct_dlvr_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
2584 END IF;
2585 END IF;
2586
2587 -- initialize input record for matching algorithm
2588 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
2589 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
2590 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).unit_of_measure := p_rcv_uom;
2591 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
2592 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
2593 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
2594 p_organization_id;
2595 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).oe_order_header_id :=
2596 p_oe_order_header_id;
2597 -- line id will be passed only from the putaway api.
2598 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).oe_order_line_id :=
2599 p_oe_order_line_id;
2600 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id; --bug# 2794612
2601 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id := p_task_id; --bug# 2794612
2602
2603 BEGIN
2604 SELECT primary_unit_of_measure
2605 INTO inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
2606 FROM mtl_system_items
2607 WHERE mtl_system_items.inventory_item_id = p_item_id
2608 AND mtl_system_items.organization_id = p_organization_id;
2609 EXCEPTION
2610 WHEN NO_DATA_FOUND THEN
2611 IF (l_debug = 1) THEN
2612 print_debug('create_rma_drct_dlvr_rti_rec: 3 - get primary_unit_of_measure exception', 4);
2613 END IF;
2614 END;
2615
2616 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
2617 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
2618 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
2619 l_progress := '40';
2620
2621 IF (l_debug = 1) THEN
2622 print_debug(
2623 'create_rma_drct_dlvr_rti_rec: 4 - before inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2624 , 4
2625 );
2626 END IF;
2627
2628 inv_rcv_txn_match.matching_logic(
2629 x_return_status => x_status
2630 , --?
2631 x_msg_count => l_msg_count
2632 , x_msg_data => x_message
2633 , x_cascaded_table => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
2634 , n => inv_rcv_std_rcpt_apis.g_receipt_detail_index
2635 , temp_cascaded_table => l_rcpt_match_table_detail
2636 , p_receipt_num => NULL
2637 , p_match_type => 'RMA'
2638 , p_lpn_id => NULL
2639 );
2640
2641 IF (l_debug = 1) THEN
2642 print_debug(
2643 'create_rma_drct_dlvr_rti_rec: 4 - after inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2644 , 4
2645 );
2646 print_debug('create_rma_drct_dlvr_rti_rec: 4.1 - after matching l_return_status = ' || x_status, 4);
2647 print_debug('create_rma_drct_dlvr_rti_rec: 4.2 - after matching l_msg_count = ' || l_msg_count, 4);
2648 print_debug('create_rma_drct_dlvr_rti_rec: 4.3 - after matching l_msg_data = ' || x_message, 4);
2649 END IF;
2650
2651 -- x_status is not successful if there is any execution error in matching.
2652 IF x_status = fnd_api.g_ret_sts_error THEN
2653 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2654 fnd_msg_pub.ADD;
2655
2656 IF (l_debug = 1) THEN
2657 print_debug('create_rma_drct_dlvr_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2658 END IF;
2659
2660 RAISE fnd_api.g_exc_error;
2661 END IF;
2662
2663 IF x_status = fnd_api.g_ret_sts_unexp_error THEN
2664 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2665 fnd_msg_pub.ADD;
2666
2667 IF (l_debug = 1) THEN
2668 print_debug('create_rma_drct_dlvr_rti_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2669 , 1);
2670 END IF;
2671
2672 RAISE fnd_api.g_exc_unexpected_error;
2673 END IF;
2674
2675 IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
2676 l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
2677 fnd_message.set_name('INV', l_err_message);
2678 fnd_msg_pub.ADD;
2679
2680 IF (l_debug = 1) THEN
2681 print_debug('create_rma_drct_dlvr_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2682 END IF;
2683
2684 RAISE fnd_api.g_exc_error;
2685 END IF;
2686
2687 l_err_message := '@@@';
2688
2689 FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
2690 inv_rcv_std_rcpt_apis.g_receipt_detail_index
2691 + l_rcpt_match_table_detail.COUNT
2692 - 1
2693 ) LOOP
2694 IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
2695 x_status := 'W';
2696 l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
2697
2698 IF l_temp_message IS NULL THEN
2699 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2700 l_msg_prod := 'INV';
2701 EXIT;
2702 END IF;
2703
2704 IF l_err_message = '@@@' THEN
2705 l_err_message := l_temp_message;
2706 l_msg_prod := 'INV';
2707 ELSIF l_temp_message <> l_err_message THEN
2708 l_msg_prod := 'INV';
2709 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2710 EXIT;
2711 END IF;
2712 END IF;
2713 END LOOP;
2714
2715 IF l_err_message <> '@@@' THEN
2716 fnd_message.set_name(l_msg_prod, l_err_message);
2717 fnd_msg_pub.ADD;
2718
2719 IF (l_debug = 1) THEN
2720 print_debug('create_rma_drct_dlvr_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2721 END IF;
2722 END IF;
2723
2724 -- based on return from matching algorithm,
2725 -- determine which line in rcv_transaction block to be inserted into RTI
2726
2727 IF (l_debug = 1) THEN
2728 print_debug('create_rma_drct_dlvr_rti_rec: 6 - start loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2729 END IF;
2730
2731 -- loop through results returned by matching algorithm
2732 l_progress := '60';
2733
2734 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
2735 l_progress := '62';
2736 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).oe_order_line_id);
2737 l_progress := '64';
2738 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
2739 l_progress := '66';
2740 CLOSE l_curs_rcpt_detail;
2741 l_progress := '68';
2742
2743 IF (l_debug = 1) THEN
2744 print_debug('create_int_shp_dr_del_rti_rec found a match 60', 4);
2745 print_debug('Matching returned values 60.1 - oe_order_line_id:'
2746 || l_rcpt_match_table_detail(match_result_count).oe_order_line_id
2747 , 4);
2748 print_debug('Matching returned values 60.1 - transaction_quantity:'
2749 || l_rcpt_match_table_detail(match_result_count).quantity
2750 , 4);
2751 print_debug('Matching returned values 60.1 - transaction_uom:'
2752 || l_rcpt_match_table_detail(match_result_count).unit_of_measure
2753 , 4);
2754 print_debug('Matching returned values 60.1 - primary_quantity:'
2755 || l_rcpt_match_table_detail(match_result_count).primary_quantity
2756 , 4);
2757 print_debug(
2758 'Matching returned values 60.1 - primary_uom:' || l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure
2759 , 4
2760 );
2761 END IF;
2762
2763 l_rcv_transaction_rec.oe_order_line_id := l_rcpt_match_table_detail(match_result_count).oe_order_line_id;
2764 -- update following fields from matching algorithm return value
2765 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
2766 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
2767 --Bug 2073164
2768 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
2769 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
2770 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
2771 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2772 l_progress := '70';
2773
2774 -- Nested LPN changes. Populate p_lpn_id as NULL for patchset J and above
2775 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po OR
2776 inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j OR
2777 inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
2778
2779 l_rcv_transaction_rec.lpn_id := p_lpn_id;
2780 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2781 ELSE
2782 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2783 END IF;
2784
2785
2786 IF p_country_code IS NOT NULL THEN
2787 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
2788 END IF;
2789
2790 --Bug #4147209 - Populate the record type with the DFF attribute category
2791 --and segment values passed from the mobile UI
2792 set_attribute_vals(
2793 p_rcv_rcpt_rec => l_rcv_rcpt_rec
2794 , p_attribute_category => p_attribute_category
2795 , p_attribute1 => p_attribute1
2796 , p_attribute2 => p_attribute2
2797 , p_attribute3 => p_attribute3
2798 , p_attribute4 => p_attribute4
2799 , p_attribute5 => p_attribute5
2800 , p_attribute6 => p_attribute6
2801 , p_attribute7 => p_attribute7
2802 , p_attribute8 => p_attribute8
2803 , p_attribute9 => p_attribute9
2804 , p_attribute10 => p_attribute10
2805 , p_attribute11 => p_attribute11
2806 , p_attribute12 => p_attribute12
2807 , p_attribute13 => p_attribute13
2808 , p_attribute14 => p_attribute14
2809 , p_attribute15 => p_attribute15);
2810
2811 IF (l_debug = 1) THEN
2812 print_debug('create_rma_drct_dlvr_rti_rec: 8 - before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2813 , 4);
2814 END IF;
2815
2816 populate_default_values(
2817 p_rcv_transaction_rec => l_rcv_transaction_rec
2818 , p_rcv_rcpt_rec => l_rcv_rcpt_rec
2819 , p_group_id => l_group_id
2820 , p_organization_id => p_organization_id
2821 , p_item_id => p_item_id
2822 , p_revision => p_revision
2823 , p_source_type => p_source_type
2824 , p_subinventory_code => p_subinventory
2825 , p_locator_id => p_locator_id
2826 , p_transaction_temp_id => p_transaction_temp_id
2827 , p_lot_control_code => p_lot_control_code
2828 , p_serial_control_code => p_serial_control_code
2829 , p_project_id => p_project_id
2830 , p_task_id => p_task_id
2831 );
2832
2833
2834 /* FP-J Lot/Serial Support Enhancement
2835 * Populate the table to store the information of the RTIs created used for
2836 * splitting the lots and serials based on RTI quantity
2837 */
2838 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2839 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2840 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
2841 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
2842 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
2843 IF (l_debug = 1) THEN
2844 print_debug('create_rma_drct_dlvr_rti_rec: 115 - Populated the table for lot/serial split', 4);
2845 END IF;
2846 END IF; --END IF populate the table to store RTI info that was just created
2847
2848 IF (l_debug = 1) THEN
2849 print_debug('create_rma_drct_dlvr_rti_rec: 9 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2850 , 4);
2851 END IF;
2852
2853 l_progress := '80';
2854 END LOOP;
2855
2856 /* FP-J Lot/Serial Support Enhancement
2857 * Call the split_lot API to split the lots and serials inserted from the UI
2858 * based on the quantity of each RTI record
2859 */
2860 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2861 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2862
2863 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2864 p_api_version => 1.0
2865 , p_init_msg_lst => FND_API.G_FALSE
2866 , x_return_status => l_return_status
2867 , x_msg_count => l_msg_count
2868 , x_msg_data => x_message
2869 , p_new_rti_info => l_new_rti_info);
2870 IF ( NOT l_split_lot_serial_ok) THEN
2871 IF (l_debug = 1) THEN
2872 print_debug('create_rma_drct_dlvr_rti_rec 9.1: Failure in split_lot_serial', 4);
2873 END IF;
2874 RAISE FND_API.G_EXC_ERROR;
2875 END IF;
2876
2877 IF (l_debug = 1) THEN
2878 print_debug('create_rma_drct_dlvr_rti_rec 9.2: Call split_lot_serial is OK', 4);
2879 END IF;
2880 END IF; --END IF check INV J and PO J installed
2881
2882 -- append index in input table where the line to be detailed needs to be inserted
2883 --inv_rcv_std_rcpt_apis.g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + inv_rcv_std_rcpt_apis.g_receipt_detail_index;
2884
2885 l_progress := '90';
2886 inv_rcv_common_apis.do_check(
2887 p_organization_id => p_organization_id
2888 , p_inventory_item_id => p_item_id
2889 , p_transaction_type_id => 15
2890 , p_primary_quantity => l_total_primary_qty
2891 , x_return_status => l_return_status
2892 , x_msg_count => l_msg_count
2893 , x_msg_data => x_message
2894 );
2895
2896 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2897 x_status := l_return_status;
2898 END IF;
2899
2900 l_progress := '100';
2901 -- Clear the Lot Rec
2902 inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
2903
2904 IF (l_debug = 1) THEN
2905 print_debug('About exit create_rma_drct_dlvr_rti_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2906 END IF;
2907 EXCEPTION
2908 WHEN fnd_api.g_exc_error THEN
2909 ROLLBACK TO crt_rma_rti_sp;
2910 x_status := fnd_api.g_ret_sts_error;
2911
2912 IF l_curs_rcpt_detail%ISOPEN THEN
2913 CLOSE l_curs_rcpt_detail;
2914 END IF;
2915
2916 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2917
2918 IF (l_debug = 1) THEN
2919 print_debug('create_rma_drct_dlvr_rti_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2920 END IF;
2921 WHEN fnd_api.g_exc_unexpected_error THEN
2922 ROLLBACK TO crt_rma_rti_sp;
2923 x_status := fnd_api.g_ret_sts_unexp_error;
2924
2925 IF l_curs_rcpt_detail%ISOPEN THEN
2926 CLOSE l_curs_rcpt_detail;
2927 END IF;
2928
2929 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2930
2931 IF (l_debug = 1) THEN
2932 print_debug('create_rma_drct_dlvr_rti_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2933 END IF;
2934 WHEN OTHERS THEN
2935 ROLLBACK TO crt_rma_rti_sp;
2936 x_status := fnd_api.g_ret_sts_unexp_error;
2937
2938 IF l_curs_rcpt_detail%ISOPEN THEN
2939 CLOSE l_curs_rcpt_detail;
2940 END IF;
2941
2942 IF SQLCODE IS NOT NULL THEN
2943 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_rma_drct_dlvr_rti_rec', l_progress, SQLCODE);
2944 END IF;
2945
2946 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2947 END create_rma_drct_dlvr_rti_rec;
2948
2949 PROCEDURE create_asn_con_dd_intf_rec(
2950 p_move_order_header_id IN OUT NOCOPY NUMBER
2951 , p_organization_id IN NUMBER
2952 , p_shipment_header_id IN NUMBER
2953 , p_po_header_id IN NUMBER
2954 , p_item_id IN NUMBER
2955 , p_rcv_qty IN NUMBER
2956 , p_rcv_uom IN VARCHAR2
2957 , p_rcv_uom_code IN VARCHAR2
2958 , p_source_type IN VARCHAR2
2959 , p_subinventory VARCHAR2
2960 , p_locator_id NUMBER
2961 , p_from_lpn_id IN NUMBER
2962 , p_lpn_id IN NUMBER
2963 , p_lot_control_code IN NUMBER
2964 , p_serial_control_code IN NUMBER
2965 , p_revision IN VARCHAR2
2966 , p_transaction_temp_id IN NUMBER
2967 , x_status OUT NOCOPY VARCHAR2
2968 , x_message OUT NOCOPY VARCHAR2
2969 , p_project_id IN NUMBER
2970 , p_task_id IN NUMBER
2971 , p_country_code IN VARCHAR2 DEFAULT NULL
2972 , p_item_desc IN VARCHAR2 DEFAULT NULL
2973 , p_secondary_rcv_qty IN NUMBER DEFAULT NULL --OPM Convergence
2974 , p_rcv_sec_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
2975 , p_rcv_sec_uom_code IN VARCHAR2 DEFAULT NULL --OPM Convergence
2976 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
2977 , p_attribute1 IN VARCHAR2 DEFAULT NULL
2978 , p_attribute2 IN VARCHAR2 DEFAULT NULL
2979 , p_attribute3 IN VARCHAR2 DEFAULT NULL
2980 , p_attribute4 IN VARCHAR2 DEFAULT NULL
2981 , p_attribute5 IN VARCHAR2 DEFAULT NULL
2982 , p_attribute6 IN VARCHAR2 DEFAULT NULL
2983 , p_attribute7 IN VARCHAR2 DEFAULT NULL
2984 , p_attribute8 IN VARCHAR2 DEFAULT NULL
2985 , p_attribute9 IN VARCHAR2 DEFAULT NULL
2986 , p_attribute10 IN VARCHAR2 DEFAULT NULL
2987 , p_attribute11 IN VARCHAR2 DEFAULT NULL
2988 , p_attribute12 IN VARCHAR2 DEFAULT NULL
2989 , p_attribute13 IN VARCHAR2 DEFAULT NULL
2990 , p_attribute14 IN VARCHAR2 DEFAULT NULL
2991 , p_attribute15 IN VARCHAR2 DEFAULT NULL
2992 , p_express_transaction IN VARCHAR2 DEFAULT NULL--Bug 5550783
2993 ) IS
2994 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
2995 l_rcv_transaction_rec inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
2996 l_transaction_type VARCHAR2(20) := 'DELIVER';
2997 l_total_primary_qty NUMBER := 0;
2998 l_match_type VARCHAR2(20);
2999 l_msg_count NUMBER;
3000 l_msg_data VARCHAR2(400);
3001 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
3002 l_group_id NUMBER;
3003 l_rcv_rcpt_rec inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
3004 l_mmtt_rec mtl_material_transactions_temp%ROWTYPE;
3005 l_err_message VARCHAR2(100);
3006 l_temp_message VARCHAR2(100);
3007 l_msg_prod VARCHAR2(5);
3008 l_progress VARCHAR2(10);
3009 l_receipt_num VARCHAR2(30);
3010 l_lpn_id NUMBER := p_lpn_id;
3011
3012 CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER, v_po_distribution_id NUMBER) IS
3013 SELECT 'N' line_chkbox
3014 , p_source_type source_type_code
3015 , 'VENDOR' receipt_source_code
3016 , 'PO' order_type_code
3017 , '' order_type
3018 , poll.po_header_id po_header_id
3019 , poh.segment1 po_number
3020 , poll.po_line_id po_line_id
3021 , pol.line_num po_line_number
3022 , poll.line_location_id po_line_location_id
3023 , poll.shipment_num po_shipment_number
3024 , poll.po_release_id po_release_id
3025 , por.release_num po_release_number
3026 , TO_NUMBER(NULL) req_header_id
3027 , NULL req_number
3028 , TO_NUMBER(NULL) req_line_id
3029 , TO_NUMBER(NULL) req_line
3030 , TO_NUMBER(NULL) req_distribution_id
3031 , rsh.shipment_header_id rcv_shipment_header_id
3032 , rsh.shipment_num rcv_shipment_number
3033 , rsl.shipment_line_id rcv_shipment_line_id
3034 , rsl.line_num rcv_line_number
3035 , rsl.from_organization_id from_organization_id --Bug #3878174
3036 /*
3037 , NVL(rsl.from_organization_id, poh.po_header_id) from_organization_id
3038 */
3039 , rsl.to_organization_id to_organization_id
3040 , rsh.vendor_id vendor_id
3041 , '' SOURCE
3042 , poh.vendor_site_id vendor_site_id -- Bug 6403165
3043 , '' outside_operation_flag
3044 , rsl.item_id item_id
3045 , -- Bug 2073164
3046 NULL uom_code
3047 , rsl.unit_of_measure primary_uom
3048 , mum.uom_class primary_uom_class
3049 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
3050 , NVL(msi.location_control_code, 1) item_locator_control
3051 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
3052 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
3053 , NVL(msi.shelf_life_code, 1) shelf_life_code
3054 , NVL(msi.shelf_life_days, 0) shelf_life_days
3055 , msi.serial_number_control_code serial_number_control_code
3056 , msi.lot_control_code lot_control_code
3057 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
3058 , NULL item_rev_control_flag_from
3059 , NULL item_number
3060 , rsl.item_revision item_revision
3061 , rsl.item_description item_description
3062 , rsl.category_id item_category_id
3063 , '' hazard_class
3064 , '' un_number
3065 , rsl.vendor_item_num vendor_item_number
3066 , rsl.ship_to_location_id ship_to_location_id
3067 , '' ship_to_location
3068 , rsl.packing_slip packing_slip
3069 , rsl.routing_header_id routing_id
3070 , '' routing_name
3071 , poll.need_by_date need_by_date
3072 , rsh.expected_receipt_date expected_receipt_date
3073 , poll.quantity ordered_qty
3074 , pol.unit_meas_lookup_code ordered_uom
3075 , rsl.ussgl_transaction_code ussgl_transaction_code
3076 , rsl.government_context government_context
3077 , poll.inspection_required_flag inspection_required_flag
3078 , poll.receipt_required_flag receipt_required_flag
3079 , poll.enforce_ship_to_location_code enforce_ship_to_location_code
3080 , NVL(poll.price_override, pol.unit_price) unit_price
3081 , poh.currency_code currency_code
3082 , poh.rate_type currency_conversion_type
3083 , poh.rate_date currency_conversion_date
3084 , poh.rate currency_conversion_rate
3085 , poh.note_to_receiver note_to_receiver
3086 , pod.destination_type_code destination_type_code
3087 , pod.deliver_to_person_id deliver_to_person_id
3088 , pod.deliver_to_location_id deliver_to_location_id
3089 , pod.destination_subinventory destination_subinventory
3090 , rsl.attribute_category attribute_category
3091 , rsl.attribute1 attribute1
3092 , rsl.attribute2 attribute2
3093 , rsl.attribute3 attribute3
3094 , rsl.attribute4 attribute4
3095 , rsl.attribute5 attribute5
3096 , rsl.attribute6 attribute6
3097 , rsl.attribute7 attribute7
3098 , rsl.attribute8 attribute8
3099 , rsl.attribute9 attribute9
3100 , rsl.attribute10 attribute10
3101 , rsl.attribute11 attribute11
3102 , rsl.attribute12 attribute12
3103 , rsl.attribute13 attribute13
3104 , rsl.attribute14 attribute14
3105 , rsl.attribute15 attribute15
3106 , poll.closed_code closed_code
3107 , rsh.asn_type asn_type
3108 , rsh.bill_of_lading bill_of_lading
3109 , rsh.shipped_date shipped_date
3110 , rsh.freight_carrier_code freight_carrier_code
3111 , rsh.waybill_airbill_num waybill_airbill_num
3112 , rsh.freight_bill_number freight_bill_num
3113 , rsl.vendor_lot_num vendor_lot_num
3114 , rsl.container_num container_num
3115 , rsl.truck_num truck_num
3116 , rsl.bar_code_label bar_code_label
3117 , '' rate_type_display
3118 , poll.match_option match_option
3119 , rsl.country_of_origin_code country_of_origin_code
3120 , TO_NUMBER(NULL) oe_order_header_id
3121 , TO_NUMBER(NULL) oe_order_num
3122 , TO_NUMBER(NULL) oe_order_line_id
3123 , TO_NUMBER(NULL) oe_order_line_num
3124 , TO_NUMBER(NULL) customer_id
3125 , TO_NUMBER(NULL) customer_site_id
3126 , NULL customer_item_num
3127 , NULL pll_note_to_receiver
3128 , --POLL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
3129 pod.po_distribution_id po_distribution_id
3130 , pod.quantity_ordered - pod.quantity_delivered qty_ordered
3131 , pod.wip_entity_id wip_entity_id
3132 , pod.wip_operation_seq_num wip_operation_seq_num
3133 , pod.wip_resource_seq_num wip_resource_seq_num
3134 , pod.wip_repetitive_schedule_id wip_repetitive_schedule_id
3135 , pod.wip_line_id wip_line_id
3136 , pod.bom_resource_id bom_resource_id
3137 , '' destination_type
3138 , '' LOCATION
3139 , pod.rate currency_conversion_rate_pod
3140 , pod.rate_date currency_conversion_date_pod
3141 , pod.project_id project_id
3142 , pod.task_id task_id
3143 , NULL secondary_uom --OPM Convergence
3144 , NULL secondary_uom_code --OPM Convergence
3145 , NULL secondary_quantity --OPM Convergence
3146 FROM rcv_shipment_lines rsl
3147 , rcv_shipment_headers rsh
3148 , po_headers poh
3149 , po_line_locations poll
3150 , po_lines pol
3151 , po_releases por
3152 , mtl_system_items msi
3153 , mtl_units_of_measure mum
3154 , po_distributions pod
3155 WHERE pod.po_distribution_id = v_po_distribution_id
3156 AND pod.line_location_id = poll.line_location_id
3157 AND NVL(poll.approved_flag, 'N') = 'Y'
3158 AND NVL(poll.cancel_flag, 'N') = 'N'
3159 AND NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
3160 AND poll.shipment_type IN('STANDARD', 'BLANKET', 'SCHEDULED')
3161 AND poh.po_header_id = poll.po_header_id
3162 AND pol.po_line_id = poll.po_line_id
3163 AND poll.po_release_id = por.po_release_id(+)
3164 AND mum.unit_of_measure(+) = rsl.unit_of_measure
3165 AND NVL(msi.organization_id, rsl.to_organization_id) = rsl.to_organization_id
3166 AND msi.inventory_item_id(+) = rsl.item_id
3167 AND poll.line_location_id = rsl.po_line_location_id
3168 AND rsl.shipment_header_id = rsh.shipment_header_id
3169 AND rsh.asn_type IN('ASN', 'ASBN', 'LCM') -- For LCM Project
3170 AND rsl.shipment_line_status_code <> 'CANCELLED'
3171 AND rsl.shipment_line_id = v_shipment_line_id
3172 AND (p_project_id IS NULL
3173 OR(p_project_id = -9999
3174 AND pod.project_id IS NULL)
3175 OR -- bug 2669021
3176 pod.project_id = p_project_id)
3177 AND (p_task_id IS NULL
3178 OR pod.task_id = p_task_id)
3179 UNION
3180 SELECT 'N' line_chkbox
3181 , 'INTERNAL' source_type_code
3182 , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
3183 , rsl.source_document_code order_type_code
3184 , '' order_type
3185 , rsh.shipment_header_id po_header_id
3186 , rsh.shipment_num po_number
3187 , rsl.shipment_line_id po_line_id
3188 , rsl.line_num po_line_number
3189 , rsl.shipment_line_id po_line_location_id
3190 , rsl.line_num po_shipment_number
3191 , rsh.shipment_header_id po_release_id
3192 , rsh.shipment_header_id po_release_number
3193 , porh.requisition_header_id req_header_id
3194 , porh.segment1 req_number
3195 , porl.requisition_line_id req_line_id
3196 , porl.line_num req_line
3197 , rsl.req_distribution_id req_distribution_id
3198 , rsl.shipment_header_id rcv_shipment_header_id
3199 , rsh.shipment_num rcv_shipment_number
3200 , rsl.shipment_line_id rcv_shipment_line_id
3201 , rsl.line_num rcv_line_number
3202 , rsl.from_organization_id from_organization_id
3203 , rsl.to_organization_id to_organization_id
3204 , rsl.shipment_line_id vendor_id
3205 , '' SOURCE
3206 , TO_NUMBER(NULL) vendor_site_id
3207 , 'N' outside_operation_flag
3208 , rsl.item_id item_id
3209 , -- Bug 2073164
3210 NULL uom_code
3211 , rsl.unit_of_measure primary_uom
3212 , mum.uom_class primary_uom_class
3213 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
3214 , NVL(msi.location_control_code, 1) item_locator_control
3215 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
3216 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
3217 , NVL(msi.shelf_life_code, 1) shelf_life_code
3218 , NVL(msi.shelf_life_days, 0) shelf_life_days
3219 , msi.serial_number_control_code serial_number_control_code
3220 , msi.lot_control_code lot_control_code
3221 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
3222 , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
3223 , NULL item_number
3224 , rsl.item_revision item_revision
3225 , rsl.item_description item_description
3226 , rsl.category_id item_category_id
3227 , '' hazard_class
3228 , '' un_number
3229 , rsl.vendor_item_num vendor_item_number
3230 , rsh.ship_to_location_id ship_to_location_id
3231 , '' ship_to_location
3232 , rsh.packing_slip packing_slip
3233 , rsl.routing_header_id routing_id
3234 , '' routing_name
3235 , porl.need_by_date need_by_date
3236 , rsh.expected_receipt_date expected_receipt_date
3237 , rsl.quantity_shipped ordered_qty
3238 , rsl.primary_unit_of_measure ordered_uom
3239 , rsh.ussgl_transaction_code ussgl_transaction_code
3240 , rsh.government_context government_context
3241 , NULL inspection_required_flag
3242 , NULL receipt_required_flag
3243 , NULL enforce_ship_to_location_code
3244 , TO_NUMBER(NULL) unit_price
3245 , NULL currency_code
3246 , NULL currency_conversion_type
3247 , TO_DATE(NULL) currency_conversion_date
3248 , TO_NUMBER(NULL) currency_conversion_rate
3249 , NULL note_to_receiver
3250 , --PORL.NOTE_TO_RECEIVER NOTE_TO_RECEIVER,
3251 rsl.destination_type_code destination_type_code
3252 , rsl.deliver_to_person_id deliver_to_person_id
3253 , rsl.deliver_to_location_id deliver_to_location_id
3254 , rsl.to_subinventory destination_subinventory
3255 , rsl.attribute_category attribute_category
3256 , rsl.attribute1 attribute1
3257 , rsl.attribute2 attribute2
3258 , rsl.attribute3 attribute3
3259 , rsl.attribute4 attribute4
3260 , rsl.attribute5 attribute5
3261 , rsl.attribute6 attribute6
3262 , rsl.attribute7 attribute7
3263 , rsl.attribute8 attribute8
3264 , rsl.attribute9 attribute9
3265 , rsl.attribute10 attribute10
3266 , rsl.attribute11 attribute11
3267 , rsl.attribute12 attribute12
3268 , rsl.attribute13 attribute13
3269 , rsl.attribute14 attribute14
3270 , rsl.attribute15 attribute15
3271 , 'OPEN' closed_code
3272 , NULL asn_type
3273 , rsh.bill_of_lading bill_of_lading
3274 , rsh.shipped_date shipped_date
3275 , rsh.freight_carrier_code freight_carrier_code
3276 , rsh.waybill_airbill_num waybill_airbill_num
3277 , rsh.freight_bill_number freight_bill_num
3278 , rsl.vendor_lot_num vendor_lot_num
3279 , rsl.container_num container_num
3280 , rsl.truck_num truck_num
3281 , rsl.bar_code_label bar_code_label
3282 , NULL rate_type_display
3283 , 'P' match_option
3284 , NULL country_of_origin_code
3285 , TO_NUMBER(NULL) oe_order_header_id
3286 , TO_NUMBER(NULL) oe_order_num
3287 , TO_NUMBER(NULL) oe_order_line_id
3288 , TO_NUMBER(NULL) oe_order_line_num
3289 , TO_NUMBER(NULL) customer_id
3290 , TO_NUMBER(NULL) customer_site_id
3291 , NULL customer_item_num
3292 , NULL pll_note_to_receiver
3293 , --PORL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
3294 TO_NUMBER(NULL) po_distribution_id
3295 , TO_NUMBER(NULL) qty_ordered
3296 , TO_NUMBER(NULL) wip_entity_id
3297 , TO_NUMBER(NULL) wip_operation_seq_num
3298 , TO_NUMBER(NULL) wip_resource_seq_num
3299 , TO_NUMBER(NULL) wip_repetitive_schedule_id
3300 , TO_NUMBER(NULL) wip_line_id
3301 , TO_NUMBER(NULL) bom_resource_id
3302 , '' destination_type
3303 , '' LOCATION
3304 , TO_NUMBER(NULL) currency_conversion_rate_pod
3305 , TO_DATE(NULL) currency_conversion_date_pod
3306 , TO_NUMBER(NULL) project_id
3307 , TO_NUMBER(NULL) task_id
3308 , NULL secondary_uom --OPM Convergence
3309 , NULL secondary_uom_code --OPM Convergence
3310 , NULL secondary_quantity --OPM Convergence
3311 FROM rcv_shipment_headers rsh
3312 , rcv_shipment_lines rsl
3313 , po_requisition_headers porh
3314 , po_requisition_lines porl
3315 , mtl_system_items msi
3316 , mtl_system_items msi1
3317 , mtl_units_of_measure mum
3318 WHERE rsh.receipt_source_code <> 'VENDOR'
3319 AND rsl.requisition_line_id = porl.requisition_line_id(+)
3320 AND porl.requisition_header_id = porh.requisition_header_id(+)
3321 AND rsh.shipment_header_id = rsl.shipment_header_id
3322 AND mum.unit_of_measure(+) = rsl.unit_of_measure
3323 AND msi.organization_id(+) = rsl.to_organization_id
3324 AND msi.inventory_item_id(+) = rsl.item_id
3325 AND msi1.organization_id(+) = rsl.from_organization_id
3326 AND msi1.inventory_item_id(+) = rsl.item_id
3327 AND rsh.asn_type IS NULL
3328 AND rsl.shipment_line_id = v_shipment_line_id
3329 AND (
3330 (
3331 rsl.source_document_code = 'REQ'
3332 AND EXISTS(
3333 SELECT '1'
3334 FROM po_req_distributions_all prd
3335 WHERE prd.requisition_line_id = porl.requisition_line_id
3336 AND (
3337 p_project_id IS NULL
3338 OR(p_project_id = -9999
3339 AND prd.project_id IS NULL)
3340 OR -- bug 2669021
3341 prd.project_id = p_project_id
3342 )
3343 AND (p_task_id IS NULL
3344 OR prd.task_id = p_task_id))
3345 )
3346 OR rsl.source_document_code <> 'REQ'
3347 );
3348
3349 -- 3441084 Requisition_line_id also needs to be joined in the above Query otherwise will do
3350 -- a full scan on po_req_distributions_all which is not good.
3351
3352 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3353 --table to store all RTId, quantity and original_rti_id for lot/serial splits
3354 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
3355 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
3356 l_msni_count NUMBER := 0;
3357 BEGIN
3358 IF (l_debug = 1) THEN
3359 print_debug('create_asn_con_dd_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3360 print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
3361 print_debug('p_organization_id = ' || p_organization_id, 4);
3362 print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
3363 print_debug('p_po_header_id = ' || p_po_header_id, 4);
3364 print_debug('p_item_id = ' || p_item_id, 4);
3365 print_debug('p_rcv_qty = ' || p_rcv_qty, 4);
3366 print_debug('p_rcv_uom = ' || p_rcv_uom, 4);
3367 print_debug('p_rcv_uom_code = ' || p_rcv_uom_code, 4);
3368 print_debug('p_source_type = ' || p_source_type, 4);
3369 print_debug('p_subinventory = ' || p_subinventory, 4);
3370 print_debug('p_locator_id = ' || p_locator_id, 4);
3371 print_debug('p_transaction_temp_id = ' || p_transaction_temp_id, 4);
3372 print_debug('p_from_lpn_id = ' || p_from_lpn_id, 4);
3373 print_debug('p_lpn_id = ' || p_lpn_id, 4);
3374 print_debug('p_lot_control_code = ' || p_lot_control_code, 4);
3375 print_debug('p_revision = ' || p_revision, 4);
3376 print_debug('p_project_id = ' || p_project_id, 4);
3377 print_debug('p_task_id = ' || p_task_id, 4);
3378 END IF;
3379
3380 SAVEPOINT crt_asn_con_rti_sp;
3381 x_status := fnd_api.g_ret_sts_success;
3382 l_progress := '10';
3383
3384 -- query po_startup_value
3385 BEGIN
3386 /* Bug 2516729
3387 * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
3388 * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
3389 * in order that a new receipt # is not created everytime and the existing receipt # is used
3390 */
3391 BEGIN
3392 SELECT receipt_num
3393 INTO l_receipt_num
3394 FROM rcv_shipment_headers
3395 WHERE shipment_header_id = p_shipment_header_id
3396 AND ship_to_org_id = p_organization_id;
3397
3398 --Bug 4552825 - Assign the value only if it is not null
3399 IF l_receipt_num IS NOT NULL THEN
3400 inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
3401 END IF;
3402
3403 IF (l_debug = 1) THEN
3404 print_debug('create_asn_con_dd_intf_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
3405 END IF;
3406 EXCEPTION
3407 WHEN NO_DATA_FOUND THEN
3408 l_receipt_num := NULL;
3409 END;
3410
3411 inv_rcv_common_apis.init_startup_values(p_organization_id);
3412 EXCEPTION
3413 WHEN NO_DATA_FOUND THEN
3414 fnd_message.set_name('INV', 'INV_RCV_PARAM');
3415 fnd_msg_pub.ADD;
3416 RAISE fnd_api.g_exc_error;
3417 END;
3418
3419 -- default header level non-DB items in rcv_transaction block
3420 -- and default other values need to be insert into RTI
3421
3422 IF (l_debug = 1) THEN
3423 print_debug('create_asn_con_dd_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3424 END IF;
3425
3426 l_progress := '20';
3427
3428 -- default l_group_id ? clear group id after done
3429 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
3430 SELECT rcv_interface_groups_s.NEXTVAL
3431 INTO l_group_id
3432 FROM DUAL;
3433
3434 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
3435 ELSE
3436 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
3437 END IF;
3438
3439 l_progress := '30';
3440 -- call matching algorithm ?
3441
3442 -- initialize input record for matching algorithm
3443 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
3444 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
3445 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
3446 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).unit_of_measure := p_rcv_uom;
3447
3448 IF p_item_id IS NOT NULL THEN
3449 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
3450 ELSE
3451 IF (l_debug = 1) THEN
3452 print_debug('create_asn_con_dd_intf_rec: Item id is null - One time item', 4);
3453 END IF;
3454
3455 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := NULL;
3456 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_desc := p_item_desc;
3457 END IF;
3458
3459 --inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
3460 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id := p_organization_id;
3461 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).shipment_header_id := p_shipment_header_id;
3462 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).po_header_id := p_po_header_id;
3463 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
3464 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
3465 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
3466 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id; --BUG# 2794612
3467 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id := p_task_id; --BUG# 2794612
3468 l_progress := '60';
3469
3470 IF p_item_id IS NOT NULL THEN
3471 SELECT primary_unit_of_measure
3472 INTO inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
3473 FROM mtl_system_items
3474 WHERE mtl_system_items.inventory_item_id = p_item_id
3475 AND mtl_system_items.organization_id = p_organization_id;
3476
3477 l_progress := '70';
3478 ELSE
3479 inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure := NULL;
3480 l_progress := '71';
3481 END IF;
3482
3483 IF (l_debug = 1) THEN
3484 print_debug('create_asn_con_dd_intf_rec: 30 before matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3485 END IF;
3486
3487 IF p_source_type = 'ASN' THEN
3488 l_match_type := 'ASN';
3489 ELSIF p_source_type = 'LCM' THEN -- For LCM Project
3490 l_match_type := 'LCM'; -- For LCM Project
3491 ELSE
3492 l_match_type := 'INTRANSIT SHIPMENT';
3493
3494 -- Nested LPN changes
3495 -- Costgroup updates will be done by TM from patchset J
3496
3497 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
3498 OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
3499 OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
3500 BEGIN
3501 SELECT cost_group_id
3502 INTO l_rcv_transaction_rec.cost_group_id
3503 FROM wms_lpn_contents wlpnc
3504 WHERE organization_id = p_organization_id
3505 AND parent_lpn_id = p_lpn_id
3506 AND wlpnc.inventory_item_id = p_item_id
3507 AND EXISTS(SELECT 1
3508 FROM cst_cost_group_accounts
3509 WHERE organization_id = p_organization_id
3510 AND cost_group_id = wlpnc.cost_group_id);
3511 EXCEPTION
3512 WHEN OTHERS THEN
3513 l_rcv_transaction_rec.cost_group_id := NULL;
3514 END;
3515
3516 IF l_rcv_transaction_rec.cost_group_id IS NULL THEN
3517 UPDATE wms_lpn_contents wlpnc
3518 SET cost_group_id = NULL
3519 WHERE organization_id = p_organization_id
3520 AND parent_lpn_id = p_lpn_id
3521 AND wlpnc.inventory_item_id = p_item_id
3522 AND NOT EXISTS(SELECT 1
3523 FROM cst_cost_group_accounts
3524 WHERE organization_id = p_organization_id
3525 AND cost_group_id = wlpnc.cost_group_id);
3526 END IF;
3527 END IF;
3528 END IF;
3529
3530 -- bug 3213241
3531 IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
3532 AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
3533 AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
3534 l_lpn_id := p_from_lpn_id;
3535 ELSE
3536 l_lpn_id := p_lpn_id;
3537 END IF;
3538
3539 inv_rcv_txn_match.matching_logic(
3540 x_return_status => l_return_status
3541 , --?
3542 x_msg_count => l_msg_count
3543 , x_msg_data => l_msg_data
3544 , x_cascaded_table => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
3545 , n => inv_rcv_std_rcpt_apis.g_receipt_detail_index
3546 , temp_cascaded_table => l_rcpt_match_table_detail
3547 , p_receipt_num => NULL
3548 , p_match_type => l_match_type
3549 , p_lpn_id => l_lpn_id
3550 );
3551
3552 IF (l_debug = 1) THEN
3553 print_debug('create_asn_con_dd_intf_rec: 40 after matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3554 print_debug('create_asn_con_dd_intf_rec: 40.1 - after matching l_return_status = ' || l_return_status, 4);
3555 print_debug('create_asn_con_dd_intf_rec: 40.2 - after matching l_msg_count = ' || l_msg_count, 4);
3556 print_debug('create_asn_con_dd_intf_rec: 40.3 - after matching l_msg_data = ' || l_msg_data, 4);
3557 END IF;
3558
3559 IF l_return_status = fnd_api.g_ret_sts_error THEN
3560 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3561 fnd_msg_pub.ADD;
3562
3563 IF (l_debug = 1) THEN
3564 print_debug('create_asn_con_dd_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3565 END IF;
3566
3567 RAISE fnd_api.g_exc_error;
3568 END IF;
3569
3570 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3571 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3572 fnd_msg_pub.ADD;
3573
3574 IF (l_debug = 1) THEN
3575 print_debug('create_asn_con_dd_intf_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
3576 , 1);
3577 END IF;
3578
3579 RAISE fnd_api.g_exc_unexpected_error;
3580 END IF;
3581
3582 IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
3583 l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
3584 fnd_message.set_name('INV', l_err_message);
3585 fnd_msg_pub.ADD;
3586
3587 IF (l_debug = 1) THEN
3588 print_debug('create_asn_con_dd_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3589 END IF;
3590
3591 RAISE fnd_api.g_exc_error;
3592 END IF;
3593
3594 l_err_message := '@@@';
3595
3596 FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
3597 inv_rcv_std_rcpt_apis.g_receipt_detail_index
3598 + l_rcpt_match_table_detail.COUNT
3599 - 1
3600 ) LOOP
3601 IF (l_debug = 1) THEN
3602 print_debug('Error Status:'||
3603 l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index +1).error_status
3604 , 4);
3605 print_debug('Error Message:'||
3606 l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index +1).error_message
3607 , 4);
3608 END IF;
3609
3610 IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
3611 x_status := 'W';
3612 l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
3613
3614 IF l_temp_message IS NULL THEN
3615 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3616 l_msg_prod := 'INV';
3617 EXIT;
3618 END IF;
3619
3620 IF l_err_message = '@@@' THEN
3621 l_err_message := l_temp_message;
3622 l_msg_prod := 'INV';
3623 ELSIF l_temp_message <> l_err_message THEN
3624 l_msg_prod := 'INV';
3625 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3626 EXIT;
3627 END IF;
3628 END IF;
3629 END LOOP;
3630
3631 IF l_err_message <> '@@@' THEN
3632 fnd_message.set_name(l_msg_prod, l_err_message);
3633 fnd_msg_pub.ADD;
3634
3635 IF (l_debug = 1) THEN
3636 print_debug('create_asn_con_dd_intf_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3637 END IF;
3638 END IF;
3639
3640 -- load the matching algorithm result into input data structure
3641
3642
3643 -- based on return from matching algorithm,
3644 -- determine which line in rcv_transaction block to be inserted into RTI
3645 -- loop through results returned by matching algorithm
3646 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
3647 l_progress := '72';
3648
3649 IF (l_debug = 1) THEN
3650 print_debug('create_asn_con_dd_intf_rec 82: opening outer cursor for', 4);
3651 print_debug('shipment_line_id => ' || l_rcpt_match_table_detail(match_result_count).shipment_line_id, 4);
3652 print_debug('po_distribution_id => ' || l_rcpt_match_table_detail(match_result_count).po_distribution_id, 4);
3653 END IF;
3654
3655 OPEN l_curs_rcpt_detail(
3656 l_rcpt_match_table_detail(match_result_count).shipment_line_id
3657 , l_rcpt_match_table_detail(match_result_count).po_distribution_id
3658 );
3659 l_progress := '74';
3660 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
3661 l_progress := '76';
3662 CLOSE l_curs_rcpt_detail;
3663 l_progress := '78';
3664 l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
3665 l_rcv_transaction_rec.po_distribution_id := l_rcpt_match_table_detail(match_result_count).po_distribution_id;
3666
3667 IF (l_debug = 1) THEN
3668 print_debug(
3669 'create_asn_con_dd_intf_rec: 90.1 - the '
3670 || match_result_count
3671 || 'th record of matching results - rcv_shipment_line_id = '
3672 || l_rcpt_match_table_detail(match_result_count).shipment_line_id
3673 , 4
3674 );
3675 END IF;
3676
3677 -- update following fields from matching algorithm return value
3678 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
3679 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
3680 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
3681 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
3682
3683 -- Nested lpn changes.
3684 -- Pass From_lpn_id instead of p_lpn_id for creating confirm receipts.
3685 --IF p_from_lpn_id IS NOT NULL
3686 IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
3687 AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
3688 AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
3689 l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
3690 ELSE
3691 l_rcv_transaction_rec.lpn_id := p_lpn_id;
3692 END IF;
3693
3694 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
3695 -- update following fields for po_distribution related values
3696 l_rcv_transaction_rec.currency_conversion_date := l_rcv_rcpt_rec.currency_conversion_date_pod;
3697 l_rcv_transaction_rec.currency_conversion_rate := l_rcv_rcpt_rec.currency_conversion_rate_pod;
3698 -- following fileds can have distribution level values
3699 -- therefore they are set here instead of in the common insert code
3700 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.qty_ordered;
3701 --Bug 2073164
3702 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
3703 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3704 -- l_rcv_transaction_rec.lpn_id := p_lpn_id;
3705
3706 -- wip related fields
3707 IF l_rcv_rcpt_rec.wip_entity_id > 0 THEN
3708 l_rcv_transaction_rec.wip_entity_id := l_rcv_rcpt_rec.wip_entity_id;
3709 l_rcv_transaction_rec.wip_operation_seq_num := l_rcv_rcpt_rec.wip_operation_seq_num;
3710 l_rcv_transaction_rec.wip_resource_seq_num := l_rcv_rcpt_rec.wip_resource_seq_num;
3711 l_rcv_transaction_rec.wip_repetitive_schedule_id := l_rcv_rcpt_rec.wip_repetitive_schedule_id;
3712 l_rcv_transaction_rec.wip_line_id := l_rcv_rcpt_rec.wip_line_id;
3713 l_rcv_transaction_rec.bom_resource_id := l_rcv_transaction_rec.bom_resource_id;
3714 -- there is getting actual values call for wip
3715 -- since they are not inserted in RTI, I am not calling it here
3716 -- the code is in
3717 -- rcv_transactions_sv.get_wip_info ()
3718 END IF;
3719
3720 --Bug #4147209 - Populate the record type with the DFF attribute category
3721 --and segment values passed from the mobile UI
3722 set_attribute_vals(
3723 p_rcv_rcpt_rec => l_rcv_rcpt_rec
3724 , p_attribute_category => p_attribute_category
3725 , p_attribute1 => p_attribute1
3726 , p_attribute2 => p_attribute2
3727 , p_attribute3 => p_attribute3
3728 , p_attribute4 => p_attribute4
3729 , p_attribute5 => p_attribute5
3730 , p_attribute6 => p_attribute6
3731 , p_attribute7 => p_attribute7
3732 , p_attribute8 => p_attribute8
3733 , p_attribute9 => p_attribute9
3734 , p_attribute10 => p_attribute10
3735 , p_attribute11 => p_attribute11
3736 , p_attribute12 => p_attribute12
3737 , p_attribute13 => p_attribute13
3738 , p_attribute14 => p_attribute14
3739 , p_attribute15 => p_attribute15);
3740
3741 IF (l_debug = 1) THEN
3742 print_debug('create_asn_con_dd_intf_rec: 100 before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3743 END IF;
3744
3745 l_progress := '80';
3746 populate_default_values(
3747 p_rcv_transaction_rec => l_rcv_transaction_rec
3748 , p_rcv_rcpt_rec => l_rcv_rcpt_rec
3749 , p_group_id => l_group_id
3750 , p_organization_id => p_organization_id
3751 , p_item_id => p_item_id
3752 , p_revision => p_revision
3753 , p_source_type => p_source_type
3754 , p_subinventory_code => p_subinventory
3755 , p_locator_id => p_locator_id
3756 , p_transaction_temp_id => p_transaction_temp_id
3757 , p_lot_control_code => p_lot_control_code
3758 , p_serial_control_code => p_serial_control_code
3759 , p_project_id => p_project_id
3760 , p_task_id => p_task_id
3761 , p_express_transaction => p_express_transaction--Bug 5550783
3762 );
3763 /* FP-J Lot/Serial Support Enhancement
3764 * Populate the table to store the information of the RTIs created used for
3765 * splitting the lots and serials based on RTI quantity
3766 */
3767 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3768 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3769 l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
3770 l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
3771 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
3772 IF (l_debug = 1) THEN
3773 print_debug('create_asn_con_dd_intf_rec: 105 - Populated the table for lot/serial split', 4);
3774 END IF;
3775 END IF; --END IF populate the table to store RTI info that was just created
3776
3777 l_progress := '90';
3778
3779 IF (l_debug = 1) THEN
3780 print_debug('create_asn_con_dd_intf_rec: 110 after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3781 END IF;
3782 END LOOP;
3783
3784 /* FP-J Lot/Serial Support Enhancement
3785 * Call the split_lot API to split the lots and serials inserted from the UI
3786 * based on the quantity of each RTI record
3787 */
3788 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3789 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3790 l_msni_count := 0;
3791 --BUG 3326408,3346758,3405320
3792 --If there are any serials confirmed from the UI for an item that is
3793 --lot controlled and serial control dynamic at SO issue,
3794 --do not NULL out serial_transaction_temp_id. In other cases,
3795 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
3796 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
3797 l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
3798 IF (l_debug = 1) THEN
3799 print_debug('create_asn_con_dd_intf_rec 110.2: serial_control_code IS 6, need TO NULL OUT mtli', 4);
3800 END IF;
3801
3802 BEGIN
3803 IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3804 SELECT count(1)
3805 INTO l_msni_count
3806 FROM mtl_serial_numbers_interface
3807 WHERE product_transaction_id = p_transaction_temp_id
3808 AND product_code = 'RCV';
3809 END IF;
3810
3811 IF l_msni_count = 0 THEN
3812 UPDATE mtl_transaction_lots_interface
3813 SET serial_transaction_temp_id = NULL
3814 WHERE product_transaction_id = p_transaction_temp_id
3815 AND product_code = 'RCV';
3816 END IF;
3817 EXCEPTION
3818 WHEN OTHERS THEN
3819 IF (l_debug = 1) THEN
3820 print_debug('create_asn_con_dd_intf_rec 110.4: Error nulling serial temp id OF MTLI', 4);
3821 END IF;
3822 END ;
3823 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) 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_asn_con_dd_intf_rec 115.1: 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_asn_con_dd_intf_rec 115.2: Call split_lot_serial is OK', 4);
3841 END IF;
3842 END IF; --END IF check INV J and PO J installed
3843
3844 IF l_curs_rcpt_detail%ISOPEN THEN
3845 CLOSE l_curs_rcpt_detail;
3846 END IF;
3847
3848 -- append index in input table where the line to be detailed needs to be inserted
3849 --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
3850
3851 -- UPDATE lpn context
3852 l_progress := '100';
3853
3854 -- Nested LPN changes
3855 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
3856 OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
3857 OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
3858 UPDATE wms_license_plate_numbers
3859 SET lpn_context = 3
3860 WHERE lpn_id = p_lpn_id;
3861 END IF;
3862
3863 l_progress := '110';
3864 l_progress := '120';
3865 inv_rcv_common_apis.do_check(
3866 p_organization_id => p_organization_id
3867 , p_inventory_item_id => p_item_id
3868 , p_transaction_type_id => 18
3869 , p_primary_quantity => l_total_primary_qty
3870 , x_return_status => l_return_status
3871 , x_msg_count => l_msg_count
3872 , x_msg_data => x_message
3873 );
3874
3875 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3876 x_status := l_return_status;
3877 END IF;
3878
3879 l_progress := '130';
3880
3881 -- Calling The ASN Discrepnacy Details
3882 IF (l_debug = 1) THEN
3883 print_debug('Before Calling ASN Ddetails ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3884 END IF;
3885
3886 inv_cr_asn_details.create_asn_details(
3887 p_organization_id
3888 , l_group_id
3889 , l_rcv_rcpt_rec
3890 , l_rcv_transaction_rec
3891 , inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb
3892 , TO_NUMBER(NULL)
3893 , l_return_status
3894 , l_msg_data
3895 );
3896
3897 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3898 x_status := l_return_status;
3899 END IF;
3900
3901 l_progress := '140';
3902 -- Clear the Lot Rec
3903 inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
3904
3905 IF (l_debug = 1) THEN
3906 print_debug('About exit create_asn_con_dd_intf_rec: 140' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3907 END IF;
3908 EXCEPTION
3909 WHEN fnd_api.g_exc_error THEN
3910 ROLLBACK TO crt_asn_con_rti_sp;
3911 x_status := fnd_api.g_ret_sts_error;
3912
3913 IF l_curs_rcpt_detail%ISOPEN THEN
3914 CLOSE l_curs_rcpt_detail;
3915 END IF;
3916
3917 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3918
3919 IF (l_debug = 1) THEN
3920 print_debug('create_asn_con_dd_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3921 END IF;
3922 WHEN fnd_api.g_exc_unexpected_error THEN
3923 ROLLBACK TO crt_asn_con_rti_sp;
3924 x_status := fnd_api.g_ret_sts_unexp_error;
3925
3926 IF l_curs_rcpt_detail%ISOPEN THEN
3927 CLOSE l_curs_rcpt_detail;
3928 END IF;
3929
3930 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3931
3932 IF (l_debug = 1) THEN
3933 print_debug('create_asn_con_dd_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3934 END IF;
3935 WHEN OTHERS THEN
3936 ROLLBACK TO crt_asn_con_rti_sp;
3937 x_status := fnd_api.g_ret_sts_unexp_error;
3938
3939 IF l_curs_rcpt_detail%ISOPEN THEN
3940 CLOSE l_curs_rcpt_detail;
3941 END IF;
3942
3943 IF SQLCODE IS NOT NULL THEN
3944 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_con_dd_intf_rec', l_progress, SQLCODE);
3945 END IF;
3946
3947 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3948
3949 IF (l_debug = 1) THEN
3950 print_debug('create_asn_con_dd_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3951 END IF;
3952 END;
3953
3954 PROCEDURE create_asn_exp_dd_intf_rec(
3955 p_move_order_header_id IN OUT NOCOPY NUMBER
3956 , p_organization_id IN NUMBER
3957 , p_shipment_header_id IN NUMBER
3958 , p_po_header_id IN NUMBER
3959 , p_source_type IN VARCHAR2
3960 , p_subinventory VARCHAR2
3961 , p_locator_id NUMBER
3962 , p_lpn_id IN NUMBER
3963 , p_transaction_temp_id IN NUMBER
3964 , x_status OUT NOCOPY VARCHAR2
3965 , x_message OUT NOCOPY VARCHAR2
3966 , p_project_id IN NUMBER
3967 , p_task_id IN NUMBER
3968 , p_country_code IN VARCHAR2 DEFAULT NULL
3969 , p_secondary_rcv_qty IN NUMBER DEFAULT NULL --OPM Convergence
3970 , p_rcv_sec_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
3971 , p_rcv_sec_uom_code IN VARCHAR2 DEFAULT NULL --OPM Convergence
3972 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
3973 , p_attribute1 IN VARCHAR2 DEFAULT NULL
3974 , p_attribute2 IN VARCHAR2 DEFAULT NULL
3975 , p_attribute3 IN VARCHAR2 DEFAULT NULL
3976 , p_attribute4 IN VARCHAR2 DEFAULT NULL
3977 , p_attribute5 IN VARCHAR2 DEFAULT NULL
3978 , p_attribute6 IN VARCHAR2 DEFAULT NULL
3979 , p_attribute7 IN VARCHAR2 DEFAULT NULL
3980 , p_attribute8 IN VARCHAR2 DEFAULT NULL
3981 , p_attribute9 IN VARCHAR2 DEFAULT NULL
3982 , p_attribute10 IN VARCHAR2 DEFAULT NULL
3983 , p_attribute11 IN VARCHAR2 DEFAULT NULL
3984 , p_attribute12 IN VARCHAR2 DEFAULT NULL
3985 , p_attribute13 IN VARCHAR2 DEFAULT NULL
3986 , p_attribute14 IN VARCHAR2 DEFAULT NULL
3987 , p_attribute15 IN VARCHAR2 DEFAULT NULL
3988 ) IS
3989 -- Bug 2182881
3990 -- changed the cursor as for lot_numbers it was not joining with
3991 -- organization_id.
3992 CURSOR l_curs_asn_lpn_content IS
3993 SELECT lpnc.lpn_id
3994 , lpnc.inventory_item_id
3995 , lpnc.revision
3996 , lpnc.quantity
3997 , lpnc.uom_code
3998 , lpnc.lot_control_code
3999 , lpnc.serial_number_control_code
4000 , lpnc.primary_uom_code
4001 , p_po_header_id
4002 , lpnc.lot_number
4003 , mln.expiration_date
4004 , mln.status_id
4005 , lpnc.lpn_org_id
4006 FROM mtl_lot_numbers mln
4007 , (SELECT wlpn.lpn_id
4008 , wlpnc.inventory_item_id
4009 , msi.organization_id
4010 , msi.lot_control_code
4011 , msi.serial_number_control_code
4012 , msi.primary_uom_code
4013 , wlpnc.revision
4014 , wlpnc.quantity
4015 , wlpnc.uom_code
4016 , wlpnc.lot_number
4017 , wlpnc.source_line_id
4018 , wlpn.organization_id lpn_org_id
4019 FROM wms_lpn_contents wlpnc, wms_license_plate_numbers wlpn, mtl_system_items msi, rcv_shipment_headers rsh
4020 WHERE rsh.shipment_header_id = p_shipment_header_id
4021 AND (wlpn.source_header_id = rsh.shipment_header_id
4022 OR wlpn.source_name = rsh.shipment_num)
4023 AND wlpn.lpn_context IN(6, 7) -- only those pre-ASN receiving ones
4024 -- Nested LPN changes to explode the LPN
4025 --AND wlpnc.parent_lpn_id = Nvl(p_lpn_id, wlpn.lpn_id)
4026 -- In case user tries to to ASN reciept by giving only PO Number
4027 -- LPN id will be NULL, In this case we should not expand the LPN
4028 -- in which case start with lpn_id = p_lpn_id will fail.
4029 AND (wlpnc.parent_lpn_id = NVL(p_lpn_id, wlpn.lpn_id)
4030 OR wlpnc.parent_lpn_id IN(SELECT lpn_id
4031 FROM wms_license_plate_numbers
4032 START WITH lpn_id = p_lpn_id
4033 CONNECT BY parent_lpn_id = PRIOR lpn_id))
4034 AND wlpnc.inventory_item_id = msi.inventory_item_id
4035 AND msi.organization_id = p_organization_id
4036 AND wlpn.lpn_id = wlpnc.parent_lpn_id
4037 AND (
4038 wlpnc.source_line_id IN(SELECT pola.po_line_id
4039 FROM po_lines_all pola
4040 WHERE pola.po_header_id = NVL(p_po_header_id, pola.po_header_id))
4041 OR wlpnc.source_line_id IS NULL
4042 )) lpnc
4043 WHERE lpnc.inventory_item_id = mln.inventory_item_id(+)
4044 AND lpnc.lot_number = mln.lot_number(+)
4045 AND lpnc.organization_id = mln.organization_id(+);
4046
4047 CURSOR l_curs_serial_number(v_inventory_item_id NUMBER, v_revision VARCHAR2
4048 , v_lot_number VARCHAR2, v_lpn_id NUMBER) IS
4049 -- bug 2182881
4050 -- added nvl around the cursor
4051 SELECT serial_number
4052 , status_id
4053 FROM mtl_serial_numbers
4054 WHERE inventory_item_id = v_inventory_item_id
4055 AND (revision = v_revision
4056 OR(revision IS NULL
4057 AND v_revision IS NULL))
4058 AND (lot_number = v_lot_number
4059 OR(lot_number IS NULL
4060 AND v_lot_number IS NULL))
4061 AND lpn_id = v_lpn_id;
4062
4063 TYPE number_tab_tp IS TABLE OF NUMBER
4064 INDEX BY BINARY_INTEGER;
4065
4066 TYPE date_tab_tp IS TABLE OF DATE
4067 INDEX BY BINARY_INTEGER;
4068
4069 TYPE varchar_tab_tp IS TABLE OF VARCHAR2(30)
4070 INDEX BY BINARY_INTEGER;
4071
4072 l_msnt_transaction_temp_id number_tab_tp;
4073 l_msnt_last_update_date date_tab_tp;
4074 l_msnt_last_updated_by number_tab_tp;
4075 l_msnt_creation_date date_tab_tp;
4076 l_msnt_created_by number_tab_tp;
4077 l_msnt_fm_serial_number varchar_tab_tp;
4078 l_msnt_to_serial_number varchar_tab_tp;
4079 l_lpn_id NUMBER;
4080 l_inventory_item_id NUMBER;
4081 l_revision VARCHAR2(30);
4082 l_quantity NUMBER;
4083 l_uom_code VARCHAR2(3);
4084 l_lot_control_code NUMBER;
4085 l_serial_control_code NUMBER;
4086 l_unit_of_measure VARCHAR2(25);
4087 l_po_header_id NUMBER;
4088 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
4089 l_lot_number VARCHAR2(80);
4090 l_lot_expiration_date DATE;
4091 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4092 l_msg_count NUMBER;
4093 l_msg_data VARCHAR2(400);
4094 l_progress VARCHAR2(10);
4095 l_transaction_temp_id NUMBER;
4096 l_serial_txn_temp_id NUMBER;
4097 l_primary_uom_code VARCHAR2(3);
4098 l_primary_qty NUMBER;
4099 l_uom_conv_ratio NUMBER;
4100 l_serial_number VARCHAR2(30);
4101 l_msnt_rec mtl_serial_numbers_temp%ROWTYPE;
4102 l_serial_number_count NUMBER;
4103 l_label_status VARCHAR2(500);
4104 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4105
4106 l_transaction_interface_id NUMBER;
4107 l_product_transaction_id NUMBER;
4108 l_serial_transaction_temp_id NUMBER;
4109 l_lot_status_id NUMBER;
4110 l_serial_status_id NUMBER;
4111 l_lot_prm_quantity NUMBER; --lot quantity in primary uom
4112 l_from_org_id NUMBER;
4113 l_lpn_org NUMBER;
4114 l_lpn_controlled_flag NUMBER := 1;
4115 l_to_lpn_id NUMBER;
4116 BEGIN
4117 IF (l_debug = 1) THEN
4118 print_debug('create_asn_exp_dd_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4119 print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
4120 print_debug('p_organization_id = ' || p_organization_id, 4);
4121 print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
4122 print_debug('p_po_header_id = ' || p_po_header_id, 4);
4123 print_debug('p_subinventory = ' || p_subinventory, 4);
4124 print_debug('p_locator_id = ' || p_locator_id, 4);
4125 print_debug('p_transaction_temp_id = ' || p_transaction_temp_id, 4);
4126 print_debug('p_source_type = ' || p_source_type, 4);
4127 print_debug('p_lpn_id = ' || p_lpn_id, 4);
4128 print_debug('project id = ' || p_project_id);
4129 END IF;
4130
4131 x_status := fnd_api.g_ret_sts_success;
4132 l_progress := '10';
4133 OPEN l_curs_asn_lpn_content;
4134 l_progress := '20';
4135
4136
4137 -- Check if the ToSubinventory is LPN controlled.
4138 SELECT NVL(lpn_controlled_flag,1)
4139 INTO l_lpn_controlled_flag
4140 FROM mtl_secondary_inventories
4141 WHERE secondary_inventory_name = p_subinventory
4142 AND organization_id = p_organization_id;
4143
4144 IF (l_debug = 1) THEN
4145 print_debug('create_asn_exp_dd_intf_rec: 0 ' || l_lpn_controlled_flag, 9);
4146 END IF;
4147
4148
4149 LOOP
4150 FETCH l_curs_asn_lpn_content INTO l_lpn_id
4151 , l_inventory_item_id
4152 , l_revision
4153 , l_quantity
4154 , l_uom_code
4155 , l_lot_control_code
4156 , l_serial_control_code
4157 , l_primary_uom_code
4158 , l_po_header_id
4159 , l_lot_number
4160 , l_lot_expiration_date
4161 , l_lot_status_id
4162 , l_lpn_org;
4163 EXIT WHEN l_curs_asn_lpn_content%NOTFOUND;
4164 l_progress := '30';
4165
4166 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
4167 OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
4168 OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
4169 inv_rcv_std_rcpt_apis.update_lpn_org(
4170 p_organization_id => p_organization_id
4171 , p_lpn_id => l_lpn_id
4172 , x_return_status => l_return_status
4173 , x_msg_count => l_msg_count
4174 , x_msg_data => l_msg_data
4175 );
4176
4177 IF l_return_status <> fnd_api.g_ret_sts_success THEN
4178 RAISE fnd_api.g_exc_error;
4179 END IF;
4180 END IF;
4181
4182 l_progress := '35';
4183
4184 SELECT unit_of_measure
4185 INTO l_unit_of_measure
4186 FROM mtl_item_uoms_view
4187 WHERE uom_code = l_uom_code
4188 AND organization_id = p_organization_id
4189 AND inventory_item_id = l_inventory_item_id;
4190
4191 l_progress := '40';
4192
4193 /* FP-J Lot/Serial Support Enhancement
4194 * If either INV J or PO J are not installed, then retain the existing logic
4195 * to create temp records for lots and serials
4196 * If both INV J and PO J are installed, create interface records for the lots/serials
4197 */
4198 IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
4199 (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
4200 -- insert into mtlt
4201 IF l_lot_number IS NOT NULL THEN
4202 IF (l_debug = 1) THEN
4203 print_debug('create_asn_exp_dd_intf_rec: 25 before inv_rcv_common_apis.insert_lot'
4204 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4205 , 4);
4206 END IF;
4207
4208 inv_convert.inv_um_conversion(from_unit => l_uom_code, to_unit => l_primary_uom_code, item_id => l_inventory_item_id
4209 , uom_rate => l_uom_conv_ratio);
4210
4211 IF l_uom_conv_ratio = -99999 THEN -- uom conversion failure
4212 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
4213 fnd_msg_pub.ADD;
4214
4215 IF (l_debug = 1) THEN
4216 print_debug(
4217 'create_asn_exp_dd_intf_rec 25.1 - txn/primary uom ratio calculation failed'
4218 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4219 , 4
4220 );
4221 END IF;
4222
4223 RAISE fnd_api.g_exc_error;
4224 END IF;
4225
4226 IF (p_source_type = 'INTERNAL' AND l_lot_control_code = 2) THEN
4227 BEGIN
4228 SELECT expiration_date
4229 INTO l_lot_expiration_date
4230 FROM mtl_lot_numbers
4231 WHERE inventory_item_id = l_inventory_item_id
4232 AND organization_id = l_lpn_org
4233 AND lot_number = l_lot_number;
4234 EXCEPTION
4235 WHEN OTHERS THEN
4236 l_lot_expiration_date := NULL;
4237 END;
4238 END IF;
4239
4240 IF (l_debug = 1) THEN
4241 print_debug('l_lot_expiration_date = '||l_lot_expiration_date, 4);
4242 END IF;
4243
4244 l_primary_qty := l_quantity * l_uom_conv_ratio;
4245 inv_rcv_common_apis.insert_lot(
4246 p_transaction_temp_id => l_transaction_temp_id
4247 , p_created_by => fnd_global.user_id
4248 , p_transaction_qty => l_quantity
4249 , p_primary_qty => l_primary_qty
4250 , p_lot_number => l_lot_number
4251 , p_expiration_date => l_lot_expiration_date
4252 , p_status_id => NULL
4253 , x_serial_transaction_temp_id => l_serial_txn_temp_id
4254 , x_return_status => l_return_status
4255 , x_msg_data => l_msg_data
4256 );
4257
4258 IF l_return_status = fnd_api.g_ret_sts_error THEN
4259 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4260 fnd_msg_pub.ADD;
4261
4262 IF (l_debug = 1) THEN
4263 print_debug(
4264 'create_asn_exp_dd_intf_rec 25.1: inv_rcv_common_apis.insert_lot RAISE FND_API.G_EXC_ERROR;'
4265 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4266 END IF;
4267
4268 RAISE fnd_api.g_exc_error;
4269 END IF;
4270
4271 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4272 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4273 fnd_msg_pub.ADD;
4274
4275 IF (l_debug = 1) THEN
4276 print_debug(
4277 'create_asn_exp_dd_intf_rec 25.2: inv_rcv_common_apis.insert_lot RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
4278 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4279 END IF;
4280
4281 RAISE fnd_api.g_exc_unexpected_error;
4282 END IF; --END IF ret_status = unexp_error
4283 END IF; --END IF item is lot controlled
4284
4285 l_progress := '41';
4286
4287 -- insert into msnt
4288
4289 IF l_serial_control_code = 2
4290 OR l_serial_control_code = 5 THEN
4291 IF (l_debug = 1) THEN
4292 print_debug('create_asn_exp_dd_intf_rec 27.1 - insert serial temp' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4293 END IF;
4294
4295 OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4296 l_serial_number_count := 0;
4297
4298 IF l_serial_txn_temp_id IS NULL THEN -- Not lot controlled
4299 l_progress := '42';
4300
4301 SELECT mtl_material_transactions_s.NEXTVAL
4302 INTO l_serial_txn_temp_id
4303 FROM DUAL;
4304
4305 l_progress := '44';
4306 l_transaction_temp_id := l_serial_txn_temp_id;
4307 END IF;
4308
4309 LOOP
4310 l_progress := '45';
4311 FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4312 l_progress := '46';
4313 EXIT WHEN l_curs_serial_number%NOTFOUND;
4314 l_serial_number_count := l_serial_number_count + 1;
4315 l_msnt_transaction_temp_id(l_serial_number_count) := l_serial_txn_temp_id;
4316 l_msnt_last_update_date(l_serial_number_count) := SYSDATE;
4317 l_msnt_last_updated_by(l_serial_number_count) := fnd_global.user_id;
4318 l_msnt_creation_date(l_serial_number_count) := SYSDATE;
4319 l_msnt_created_by(l_serial_number_count) := fnd_global.user_id;
4320 l_msnt_fm_serial_number(l_serial_number_count) := l_serial_number;
4321 l_msnt_to_serial_number(l_serial_number_count) := l_serial_number;
4322 END LOOP;
4323
4324 IF (l_debug = 1) THEN
4325 print_debug('create_asn_exp_dd_intf_rec 27.2 - Number of serial temp records : ' || l_msnt_transaction_temp_id.COUNT, 4);
4326 END IF;
4327
4328 CLOSE l_curs_serial_number;
4329 l_progress := '47';
4330 FORALL i IN 1 .. l_msnt_transaction_temp_id.COUNT
4331 INSERT INTO mtl_serial_numbers_temp
4332 (
4333 transaction_temp_id
4334 , last_update_date
4335 , last_updated_by
4336 , creation_date
4337 , created_by
4338 , fm_serial_number
4339 , to_serial_number
4340 )
4341 VALUES (
4342 l_msnt_transaction_temp_id(i)
4343 , l_msnt_last_update_date(i)
4344 , l_msnt_last_updated_by(i)
4345 , l_msnt_creation_date(i)
4346 , l_msnt_created_by(i)
4347 , l_msnt_fm_serial_number(i)
4348 , l_msnt_to_serial_number(i)
4349 );
4350 l_progress := '48';
4351 FORALL i IN 1 .. l_msnt_transaction_temp_id.COUNT
4352 UPDATE mtl_serial_numbers
4353 SET group_mark_id = l_serial_txn_temp_id
4354 WHERE inventory_item_id = l_inventory_item_id
4355 AND serial_number = l_msnt_fm_serial_number(i);
4356 l_progress := '49';
4357 END IF; --END IF item is serial controlled
4358
4359 --INV J and PO J are installed. So create interface records MTLI and MSNI
4360 --instead of temp records
4361 ELSE
4362 --Reset the variables that store the IDs
4363 l_transaction_interface_id := NULL;
4364 l_serial_transaction_temp_id := NULL;
4365 l_product_transaction_id := NULL;
4366
4367 IF l_lot_control_code > 1 THEN
4368 IF l_lot_number IS NOT NULL THEN
4369 --Convert the lot quantity into Item's Primary UOM code
4370 IF l_uom_code <> l_primary_uom_code THEN
4371 l_lot_prm_quantity := inv_convert.inv_um_convert(
4372 item_id => l_inventory_item_id
4373 , precision => NULL
4374 , from_quantity => l_quantity
4375 , from_unit => l_uom_code
4376 , to_unit => l_primary_uom_code
4377 , from_name => NULL
4378 , to_name => NULL);
4379
4380 --Check for failure
4381 IF l_lot_prm_quantity = -99999 THEN
4382 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
4383 fnd_msg_pub.ADD;
4384 IF (l_debug = 1) THEN
4385 print_debug('create_asn_exp_rcpt_intf_rec: 20.2 - txn/primary uom conversion failed', 4);
4386 END IF;
4387 RAISE fnd_api.g_exc_error;
4388 END IF; --END IF check for failure
4389
4390 ELSE
4391 l_lot_prm_quantity := l_quantity;
4392 END IF;
4393
4394 IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
4395 l_from_org_id := l_lpn_org;
4396 ELSE
4397 l_from_org_id := p_organization_id;
4398 END IF;
4399
4400 --Create MTLI record for the lot and the lot quantity for this content
4401 --Set the flag for the API to populate the lot attributes
4402 inv_rcv_integration_apis.insert_mtli(
4403 p_api_version => 1.0
4404 , p_init_msg_lst => FND_API.G_FALSE
4405 , x_return_status => l_return_status
4406 , x_msg_count => l_msg_count
4407 , x_msg_data => l_msg_data
4408 , p_transaction_interface_id => l_transaction_interface_id
4409 , p_lot_number => l_lot_number
4410 , p_transaction_quantity => l_quantity
4411 , p_primary_quantity => l_lot_prm_quantity
4412 , p_organization_id => l_from_org_id
4413 , p_inventory_item_id => l_inventory_item_id
4414 , p_expiration_date => l_lot_expiration_date
4415 , p_status_id => l_lot_status_id
4416 , x_serial_transaction_temp_id => l_serial_transaction_temp_id
4417 , p_product_transaction_id => l_product_transaction_id
4418 , p_product_code => 'RCV'
4419 , p_att_exist => 'Y'
4420 , p_update_mln => 'N'
4421 );
4422
4423 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4424 IF (l_debug = 1) THEN
4425 print_debug('create_asn_exp_dd_intf_rec 28.1: Error in MTLI creation', 4);
4426 END IF;
4427 RAISE FND_API.G_EXC_ERROR;
4428 END IF;
4429
4430 IF (l_debug = 1) THEN
4431 print_debug('create_asn_exp_dd_intf_rec 28.2: txn i/f id: ' || l_transaction_interface_id
4432 || ' serial temp : ' || l_serial_transaction_temp_id || ' prod txn id: ' || l_product_transaction_id, 4);
4433 END IF;
4434 END IF; --END IF l_lot_number IS NOT NULL
4435
4436 --Create MSNI records for the serials within lots
4437 --Bug #3405320
4438 --Create MSNI records even if serial control code is dynamic at SO Issue in
4439 --receiving org if there are serials shipped
4440 IF ((l_serial_control_code IN (2, 5)) OR
4441 (l_serial_control_code = 6 AND p_source_type IN ('INTERNAL', 'INVENTORY'))) THEN
4442 -- bug 3196554
4443 OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4444 --Loop through the serials in the lot
4445 LOOP
4446 FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4447 EXIT WHEN l_curs_serial_number%NOTFOUND;
4448 IF (l_debug = 1) THEN
4449 print_debug('create_asn_exp_dd_intf_rec 28.2.1: Before MSNI creation', 4);
4450 END IF;
4451 --For each serial number in the lot create one MSNI record. The
4452 --serial attributes would be populated by the API
4453 inv_rcv_integration_apis.insert_msni(
4454 p_api_version => 1.0
4455 , p_init_msg_lst => FND_API.G_FALSE
4456 , x_return_status => l_return_status
4457 , x_msg_count => l_msg_count
4458 , x_msg_data => l_msg_data
4459 , p_transaction_interface_id => l_serial_transaction_temp_id
4460 , p_fm_serial_number => l_serial_number
4461 , p_to_serial_number => l_serial_number
4462 , p_organization_id => p_organization_id
4463 , p_inventory_item_id => l_inventory_item_id
4464 , p_status_id => l_serial_status_id
4465 , p_product_transaction_id => l_product_transaction_id
4466 , p_product_code => 'RCV'
4467 , p_att_exist => 'Y'
4468 , p_update_msn => 'N'
4469 );
4470
4471 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4472 IF (l_debug = 1) THEN
4473 print_debug('create_asn_exp_dd_intf_rec 28.3: Error in MSNI creation', 4);
4474 END IF;
4475 RAISE FND_API.G_EXC_ERROR;
4476 END IF;
4477 END LOOP; --END LOOP through serials for the lot
4478
4479 --Close the serial cursor
4480 IF l_curs_serial_number%ISOPEN THEN
4481 CLOSE l_curs_serial_number;
4482 END IF;
4483 END IF; --END IF item is lot and serial controlled
4484
4485 -- bug 3180322
4486 -- This code was inside the serial control and lot control
4487 -- However we should be setting this variable irrespective of
4488 -- whether it is lot and serial control or just lot controlled
4489 --Set the variable l_transaction_temp_id that should be passed to
4490 --create_asn_con_dd_intf_rec to product_transaction_id since lots
4491 --and serials would be split based on this value
4492 l_transaction_temp_id := l_product_transaction_id;
4493
4494 --If the item is serial controlled, loop through the serials within
4495 --the LPN and create one MSNI record for each serial number
4496 --The attributes for each serial number would be fetched by the API
4497 ELSIF (l_serial_control_code IN (2, 5) OR
4498 l_serial_control_code = 6 AND p_source_type IN ('INTERNAL', 'INVENTORY')) THEN
4499 -- bug 3196554
4500 OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4501 --Loop through the serials in the lot
4502 LOOP
4503 FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4504 EXIT WHEN l_curs_serial_number%NOTFOUND;
4505 --For each serial number in the lot create one MSNI record. The
4506 --serial attributes would be populated by the API
4507 IF (l_debug = 1) THEN
4508 print_debug('create_asn_exp_dd_intf_rec 28.3.1: Before MSNI creation', 4);
4509 END IF;
4510 inv_rcv_integration_apis.insert_msni(
4511 p_api_version => 1.0
4512 , p_init_msg_lst => FND_API.G_FALSE
4513 , x_return_status => l_return_status
4514 , x_msg_count => l_msg_count
4515 , x_msg_data => l_msg_data
4516 , p_transaction_interface_id => l_transaction_interface_id
4517 , p_fm_serial_number => l_serial_number
4518 , p_to_serial_number => l_serial_number
4519 , p_organization_id => p_organization_id
4520 , p_inventory_item_id => l_inventory_item_id
4521 , p_status_id => l_serial_status_id
4522 , p_product_transaction_id => l_product_transaction_id
4523 , p_product_code => 'RCV'
4524 , p_att_exist => 'Y'
4525 , p_update_msn => 'N'
4526 );
4527
4528 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4529 IF (l_debug = 1) THEN
4530 print_debug('create_asn_exp_dd_intf_rec 28.4: Error in MSNI creation', 4);
4531 END IF;
4532 RAISE FND_API.G_EXC_ERROR;
4533 END IF;
4534 IF (l_debug = 1) THEN
4535 print_debug('create_asn_exp_dd_intf_rec 28.5: txn i/f id: ' || l_transaction_interface_id || ' prod txn id: ' || l_product_transaction_id, 4);
4536 END IF;
4537 END LOOP; --END LOOP through serials for the LPN
4538
4539 --Set the variable l_transaction_temp_id that should be passed to
4540 --create_asn_con_dd_intf_rec to product_transaction_id since lots
4541 --and serials would be split based on this value
4542 l_transaction_temp_id := l_product_transaction_id;
4543
4544 --Close the serial cursor
4545 IF l_curs_serial_number%ISOPEN THEN
4546 CLOSE l_curs_serial_number;
4547 END IF;
4548 END IF; --END IF check lot and serial control codes
4549 END IF; --END IF check INV patchset J and PO patchset J are installed
4550
4551 IF (l_debug = 1) THEN
4552 print_debug('create_asn_exp_dd_intf_rec: 30 before create_asn_con_dd_intf_rec' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4553 END IF;
4554
4555 -- If subinventory is Non-LPN controlled then pass to_lpn
4556
4557 IF (l_lpn_controlled_flag = 2) THEN
4558 l_to_lpn_id := NULL ;
4559 ELSE
4560 l_to_lpn_id := l_lpn_id;
4561 END IF;
4562
4563 -- Nested LPN changes.
4564 -- Passed new parameter p_from_lpn_id also as l_lpn_id
4565 create_asn_con_dd_intf_rec(
4566 p_move_order_header_id => p_move_order_header_id
4567 , p_organization_id => p_organization_id
4568 , p_shipment_header_id => p_shipment_header_id
4569 , p_po_header_id => l_po_header_id
4570 , p_item_id => l_inventory_item_id
4571 , p_rcv_qty => l_quantity
4572 , p_rcv_uom => l_unit_of_measure
4573 , p_rcv_uom_code => l_uom_code
4574 , p_source_type => p_source_type
4575 , p_subinventory => p_subinventory
4576 , p_locator_id => p_locator_id
4577 , p_from_lpn_id => l_lpn_id
4578 , p_lpn_id => l_to_lpn_id
4579 , p_lot_control_code => l_lot_control_code
4580 , p_serial_control_code => l_serial_control_code
4581 , p_revision => l_revision
4582 , p_transaction_temp_id => NVL(l_transaction_temp_id, p_transaction_temp_id)
4583 , x_status => l_return_status
4584 , x_message => l_msg_data
4585 , p_project_id => p_project_id
4586 , p_task_id => p_task_id
4587 , p_attribute_category => p_attribute_category --Bug #4147209
4588 , p_attribute1 => p_attribute1
4589 , p_attribute2 => p_attribute2
4590 , p_attribute3 => p_attribute3
4591 , p_attribute4 => p_attribute4
4592 , p_attribute5 => p_attribute5
4593 , p_attribute6 => p_attribute6
4594 , p_attribute7 => p_attribute7
4595 , p_attribute8 => p_attribute8
4596 , p_attribute9 => p_attribute9
4597 , p_attribute10 => p_attribute10
4598 , p_attribute11 => p_attribute11
4599 , p_attribute12 => p_attribute12
4600 , p_attribute13 => p_attribute13
4601 , p_attribute14 => p_attribute14
4602 , p_attribute15 => p_attribute15
4603 , p_express_transaction => 'Y'--Bug 5550783
4604 );
4605
4606 IF l_return_status = fnd_api.g_ret_sts_error THEN
4607 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4608 fnd_msg_pub.ADD;
4609
4610 IF (l_debug = 1) THEN
4611 print_debug(
4612 'create_asn_exp_dd_intf_rec 40.1:create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_ERROR;'
4613 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4614 , 4
4615 );
4616 END IF;
4617
4618 RAISE fnd_api.g_exc_error;
4619 END IF;
4620
4621 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4622 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4623 fnd_msg_pub.ADD;
4624
4625 IF (l_debug = 1) THEN
4626 print_debug(
4627 'create_asn_exp_dd_intf_rec 40.2: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
4628 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4629 , 4
4630 );
4631 END IF;
4632
4633 RAISE fnd_api.g_exc_unexpected_error;
4634 END IF;
4635
4636 IF (l_debug = 1) THEN
4637 print_debug('create_asn_exp_dd_intf_rec: 50 after create_asn_con_dd_intf_rec' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4638 , 4);
4639 END IF;
4640 END LOOP;
4641
4642 --BUG 4567903: Need to set the status so that the UI will show the
4643 --correct messages
4644 x_status := l_return_status;
4645 IF (l_debug = 1) THEN
4646 print_debug('x_status:'||x_status,4);
4647 print_debug('x_message:'||x_message,4);
4648 END IF;
4649 --END BUG 4567903
4650
4651 -- Nested LPN changes, If INVJ,POJ,WMSJ Installed then
4652 -- insert WLPNI for FromLPN with parent as NULL.
4653
4654 IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
4655 AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
4656 AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
4657 IF (l_debug = 1) THEN
4658 print_debug(
4659 'create_asn_exp_dd_intf_rec: 50.1 - Before inserting into wlpni for p_lpn_id with parent NULL '
4660 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4661 END IF;
4662
4663 IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
4664 l_from_org_id := l_lpn_org;
4665 ELSE
4666 l_from_org_id := p_organization_id;
4667 END IF;
4668
4669 -- Nested LPN changes. Insert WLPNI
4670 inv_rcv_integration_apis.insert_wlpni(
4671 p_api_version => 1.0
4672 ,x_return_status => l_return_status
4673 ,x_msg_count => l_msg_count
4674 ,x_msg_data => l_msg_data
4675 ,p_organization_id => l_from_org_id -- BUG 4096028: should
4676 -- from org_id
4677 ,p_lpn_id => p_lpn_id
4678 ,p_license_plate_number => NULL
4679 ,p_lpn_group_id => inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4680 ,p_parent_lpn_id => NULL
4681 );
4682
4683 IF l_return_status = fnd_api.g_ret_sts_error THEN
4684 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4685 fnd_msg_pub.ADD;
4686
4687 IF (l_debug = 1) THEN
4688 print_debug('create_asn_exp_dd_intf_rec 50.2:create_asn_con_dd_intf_rec - RAISE FND_API.G_EXC_ERROR after insert_wlpni;'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4689 END IF;
4690
4691 RAISE fnd_api.g_exc_error;
4692 END IF;
4693
4694 IF (l_debug = 1) THEN
4695 print_debug(
4696 'create_asn_exp_dd_intf_rec: 50.1 - After inserting into wlpni for p_lpn_id with parent NULL '
4697 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4698 END IF;
4699 END IF;
4700
4701 l_progress := '60';
4702
4703 IF l_curs_asn_lpn_content%ISOPEN THEN
4704 CLOSE l_curs_asn_lpn_content;
4705 END IF;
4706
4707 l_progress := '70';
4708
4709 -- UPDATE lpn context
4710
4711
4712 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
4713 OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
4714 OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
4715
4716 UPDATE wms_license_plate_numbers
4717 SET lpn_context = 3
4718 WHERE source_header_id = p_shipment_header_id
4719 AND lpn_id = NVL(p_lpn_id, lpn_id);
4720
4721 l_progress := '80';
4722
4723 -- UPDATE the lpn history table with source name as ASNEXP since no packing happened.
4724 -- This is needed to help the cleanup later on
4725 -- Nothing else is updated to keep in synch with license_plate_number update
4726
4727 IF (l_debug = 1) THEN
4728 print_debug(' create_asn_exp_dd_intf_rec: Before Update lpn history ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4729 print_debug(
4730 ' create_asn_exp_dd_intf_rec: Group_id = '
4731 || inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4732 || ' '
4733 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4734 END IF;
4735
4736 UPDATE wms_lpn_histories
4737 SET source_name = 'ASNEXP'
4738 , source_header_id = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4739 WHERE lpn_context = 7
4740 AND parent_lpn_id IN(SELECT lpn_id
4741 FROM wms_license_plate_numbers
4742 WHERE source_header_id = p_shipment_header_id
4743 AND lpn_id = NVL(p_lpn_id, lpn_id));
4744 END IF;
4745
4746 IF (l_debug = 1) THEN
4747 print_debug('Exit create_asn_exp_dd_intf_rec: 90 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4748 END IF;
4749 EXCEPTION
4750 WHEN fnd_api.g_exc_error THEN
4751 x_status := fnd_api.g_ret_sts_error;
4752
4753 IF l_curs_asn_lpn_content%ISOPEN THEN
4754 CLOSE l_curs_asn_lpn_content;
4755 END IF;
4756
4757 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4758
4759 IF (l_debug = 1) THEN
4760 print_debug('create_asn_exp_dd_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4761 END IF;
4762 WHEN fnd_api.g_exc_unexpected_error THEN
4763 x_status := fnd_api.g_ret_sts_unexp_error;
4764
4765 IF l_curs_asn_lpn_content%ISOPEN THEN
4766 CLOSE l_curs_asn_lpn_content;
4767 END IF;
4768
4769 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4770
4771 IF (l_debug = 1) THEN
4772 print_debug('create_asn_exp_dd_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4773 END IF;
4774 WHEN OTHERS THEN
4775 x_status := fnd_api.g_ret_sts_unexp_error;
4776
4777 IF l_curs_asn_lpn_content%ISOPEN THEN
4778 CLOSE l_curs_asn_lpn_content;
4779 END IF;
4780
4781 IF SQLCODE IS NOT NULL THEN
4782 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_exp_dd_intf_rec', l_progress, SQLCODE);
4783 END IF;
4784
4785 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4786
4787 IF (l_debug = 1) THEN
4788 print_debug('create_asn_exp_dd_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4789 END IF;
4790 END create_asn_exp_dd_intf_rec;
4791
4792 PROCEDURE create_osp_direct_rti_rec(
4793 p_move_order_header_id IN OUT NOCOPY NUMBER
4794 , p_organization_id IN NUMBER
4795 , p_po_header_id IN NUMBER
4796 , p_po_release_id IN NUMBER
4797 , p_po_line_id IN NUMBER
4798 , p_item_id IN NUMBER
4799 , p_rcv_qty IN NUMBER
4800 , p_rcv_uom IN VARCHAR2
4801 , p_rcv_uom_code IN VARCHAR2
4802 , p_source_type IN VARCHAR2
4803 , p_transaction_temp_id IN NUMBER
4804 , p_revision IN VARCHAR2
4805 , p_po_distribution_id IN NUMBER
4806 , x_status OUT NOCOPY VARCHAR2
4807 , x_message OUT NOCOPY VARCHAR2
4808 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209
4809 , p_attribute1 IN VARCHAR2 DEFAULT NULL
4810 , p_attribute2 IN VARCHAR2 DEFAULT NULL
4811 , p_attribute3 IN VARCHAR2 DEFAULT NULL
4812 , p_attribute4 IN VARCHAR2 DEFAULT NULL
4813 , p_attribute5 IN VARCHAR2 DEFAULT NULL
4814 , p_attribute6 IN VARCHAR2 DEFAULT NULL
4815 , p_attribute7 IN VARCHAR2 DEFAULT NULL
4816 , p_attribute8 IN VARCHAR2 DEFAULT NULL
4817 , p_attribute9 IN VARCHAR2 DEFAULT NULL
4818 , p_attribute10 IN VARCHAR2 DEFAULT NULL
4819 , p_attribute11 IN VARCHAR2 DEFAULT NULL
4820 , p_attribute12 IN VARCHAR2 DEFAULT NULL
4821 , p_attribute13 IN VARCHAR2 DEFAULT NULL
4822 , p_attribute14 IN VARCHAR2 DEFAULT NULL
4823 , p_attribute15 IN VARCHAR2 DEFAULT NULL
4824 ) IS
4825 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4826 l_msg_count NUMBER;
4827 l_msg_data VARCHAR2(400);
4828 l_label_status VARCHAR2(500);
4829 l_progress VARCHAR2(10);
4830 l_txn_id_tbl inv_label.transaction_id_rec_type;
4831 l_counter NUMBER := 0;
4832
4833 CURSOR c_rti_txn_id IS
4834 /* Bug 2443163 */
4835 /* SELECT MIN(rti.interface_transaction_id) */
4836 /* Group BY LPN_ID is changed for Express Receipts */
4837 /* Also duplicate print of LPN labels is avoided */
4838 SELECT MAX(rti.interface_transaction_id)
4839 FROM rcv_transactions_interface rti
4840 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4841 GROUP BY DECODE(p_source_type, 'ASNEXP', rti.interface_transaction_id, 'SHIPMENTEXP', rti.interface_transaction_id, NULL);
4842 -- GROUP BY rti.lpn_id;
4843
4844 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4845 BEGIN
4846 x_status := fnd_api.g_ret_sts_success;
4847 l_progress := '10';
4848
4849 IF (l_debug = 1) THEN
4850 print_debug('create_osp_direct_rti_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4851 END IF;
4852
4853 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
4854 --BUG 3440184: For performance reason, use the follow query
4855 --instead of gl_sets_of_books
4856 SELECT TO_NUMBER(hoi.org_information1)
4857 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
4858 FROM hr_organization_information hoi
4859 WHERE hoi.organization_id = p_organization_id
4860 AND (hoi.org_information_context || '') = 'Accounting Information';
4861
4862 --SELECT ood.set_of_books_id
4863 --INTO inv_rcv_common_apis.g_po_startup_value.sob_id
4864 --FROM org_organization_definitions ood, gl_sets_of_books sob
4865 --WHERE organization_id = p_organization_id
4866 --AND sob.set_of_books_id = ood.set_of_books_id;
4867 END IF;
4868
4869 l_progress := '10';
4870 -- first check if the transaction date satisfies the validation.
4871 inv_rcv_common_apis.validate_trx_date(
4872 p_trx_date => SYSDATE
4873 , p_organization_id => p_organization_id
4874 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
4875 , x_return_status => x_status
4876 , x_error_code => x_message
4877 );
4878
4879 IF x_status <> fnd_api.g_ret_sts_success THEN
4880 RETURN;
4881 END IF;
4882
4883 IF p_po_header_id IS NULL
4884 AND p_item_id IS NULL THEN
4885 IF (l_debug = 1) THEN
4886 print_debug('create_osp_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
4887 END IF;
4888
4889 x_status := fnd_api.g_ret_sts_error;
4890 RETURN;
4891 END IF;
4892
4893 l_progress := '30';
4894 create_osp_drct_dlvr_rti_rec(
4895 p_move_order_header_id => p_move_order_header_id
4896 , p_organization_id => p_organization_id
4897 , p_po_header_id => p_po_header_id
4898 , p_po_release_id => p_po_release_id
4899 , p_po_line_id => p_po_line_id
4900 , p_po_line_location_id => NULL
4901 , p_po_distribution_id => p_po_distribution_id
4902 , p_item_id => p_item_id
4903 , p_rcv_qty => p_rcv_qty
4904 , p_rcv_uom => p_rcv_uom
4905 , p_rcv_uom_code => p_rcv_uom_code
4906 , p_source_type => p_source_type
4907 , p_transaction_temp_id => p_transaction_temp_id
4908 , p_revision => p_revision
4909 , x_status => l_return_status
4910 , x_message => x_message
4911 , p_attribute_category => p_attribute_category --Bug #4147209
4912 , p_attribute1 => p_attribute1
4913 , p_attribute2 => p_attribute2
4914 , p_attribute3 => p_attribute3
4915 , p_attribute4 => p_attribute4
4916 , p_attribute5 => p_attribute5
4917 , p_attribute6 => p_attribute6
4918 , p_attribute7 => p_attribute7
4919 , p_attribute8 => p_attribute8
4920 , p_attribute9 => p_attribute9
4921 , p_attribute10 => p_attribute10
4922 , p_attribute11 => p_attribute11
4923 , p_attribute12 => p_attribute12
4924 , p_attribute13 => p_attribute13
4925 , p_attribute14 => p_attribute14
4926 , p_attribute15 => p_attribute15
4927 );
4928
4929 IF l_return_status = fnd_api.g_ret_sts_error THEN
4930 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4931 fnd_msg_pub.ADD;
4932
4933 IF (l_debug = 1) THEN
4934 print_debug(
4935 'create_osp_direct_rti_rec 20.1: create_osp_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
4936 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4937 END IF;
4938
4939 RAISE fnd_api.g_exc_error;
4940 END IF;
4941
4942 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4943 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
4944 fnd_msg_pub.ADD;
4945
4946 IF (l_debug = 1) THEN
4947 print_debug(
4948 'create_osp_direct_rti_rec 20.2: create_osp_drct_dlvr_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
4949 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4950 END IF;
4951
4952 RAISE fnd_api.g_exc_unexpected_error;
4953 END IF;
4954
4955 l_progress := '40';
4956
4957 IF (l_debug = 1) THEN
4958 print_debug('create_osp_direct_rti_rec calling print_label: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4959 END IF;
4960
4961 x_status := l_return_status; -- l_return_status can be 'W', we want to carry that over
4962 -- calling label printing API
4963
4964 IF l_return_status <> fnd_api.g_ret_sts_error THEN
4965 l_progress := '40';
4966
4967 IF (l_debug = 1) THEN
4968 print_debug(
4969 'create_osp_direct_rti_rec: 8.1 before inv_label.print_label ' || inv_rcv_common_apis.g_rcv_global_var.interface_group_id, 4);
4970 END IF;
4971
4972 /* FP-J Lot/Serial Support Enhancement
4973 * If INV J and PO J are installed, do not call label printing API at this stage
4974 */
4975 IF ((inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po) OR
4976 (inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j)) THEN
4977
4978 IF (p_source_type <> 'VENDOR') THEN --Bug #4079952 ..For PO receipt, code in rcv_insert_update_header(INVSTDRB.pls) will be called.
4979 l_counter := 1;
4980 OPEN c_rti_txn_id;
4981
4982 LOOP
4983 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
4984 EXIT WHEN c_rti_txn_id%NOTFOUND;
4985
4986 IF (l_debug = 1) THEN
4987 print_debug('create_osp_direct_rti_rec calling printing for:' || l_txn_id_tbl(l_counter), 4);
4988 END IF;
4989
4990 l_counter := l_counter + 1;
4991 END LOOP;
4992
4993 CLOSE c_rti_txn_id;
4994 inv_label.print_label(
4995 x_return_status => l_return_status
4996 , x_msg_count => l_msg_count
4997 , x_msg_data => l_msg_data
4998 , x_label_status => l_label_status
4999 , p_api_version => 1.0
5000 , p_print_mode => 1
5001 , p_business_flow_code => 1
5002 , p_transaction_id => l_txn_id_tbl
5003 );
5004
5005 IF l_return_status <> fnd_api.g_ret_sts_success THEN
5006 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
5007 fnd_msg_pub.ADD;
5008 x_status := 'W';
5009
5010 IF (l_debug = 1) THEN
5011 print_debug('create_osp_direct_rti_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5012 END IF; --END IF l_debug = 1
5013 END IF; --END IF label ret_status <> S
5014 END IF ; --Bug #4079952
5015 ELSE
5016 IF (l_debug = 1) THEN
5017 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
5018 END IF;
5019 END IF; --END IF INV J and PO J installed
5020 END IF; --END IF ret_status = Success
5021
5022 IF (l_debug = 1) THEN
5023 print_debug('create_osp_direct_rti_rec exiting print_label: 7' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5024 END IF;
5025
5026 IF (l_debug = 1) THEN
5027 print_debug('About exit create_osp_direct_rti_rec: 8' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5028 print_debug('create_osp_direct_rti_rec: 8.1 - x_status = ' || x_status, 4);
5029 print_debug('create_osp_direct_rti_rec: 8.2 - x_message= ' || x_message, 4);
5030 END IF;
5031 EXCEPTION
5032 WHEN fnd_api.g_exc_error THEN
5033 x_status := fnd_api.g_ret_sts_error;
5034 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5035 WHEN fnd_api.g_exc_unexpected_error THEN
5036 x_status := fnd_api.g_ret_sts_unexp_error;
5037 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5038 WHEN OTHERS THEN
5039 x_status := fnd_api.g_ret_sts_unexp_error;
5040
5041 IF SQLCODE IS NOT NULL THEN
5042 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_osp_direct_rti_rec', l_progress, SQLCODE);
5043 END IF;
5044
5045 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5046 END create_osp_direct_rti_rec;
5047
5048 PROCEDURE create_direct_rti_rec(
5049 p_move_order_header_id IN OUT NOCOPY NUMBER
5050 , p_organization_id IN NUMBER
5051 , p_po_header_id IN NUMBER
5052 , p_po_release_id IN NUMBER
5053 , p_po_line_id IN NUMBER
5054 , p_shipment_header_id IN NUMBER
5055 , p_oe_order_header_id IN NUMBER
5056 , p_item_id IN NUMBER
5057 , p_rcv_qty IN NUMBER
5058 , p_rcv_uom IN VARCHAR2
5059 , p_rcv_uom_code IN VARCHAR2
5060 , p_source_type IN VARCHAR2
5061 , p_subinventory IN VARCHAR2
5062 , p_locator_id IN NUMBER
5063 , p_transaction_temp_id IN NUMBER
5064 , p_lot_control_code IN NUMBER
5065 , p_serial_control_code IN NUMBER
5066 , p_lpn_id IN NUMBER
5067 , p_revision IN VARCHAR2
5068 , x_status OUT NOCOPY VARCHAR2
5069 , x_message OUT NOCOPY VARCHAR2
5070 , p_inv_item_id IN NUMBER DEFAULT NULL
5071 , p_item_desc IN VARCHAR2 DEFAULT NULL
5072 , p_location_id IN NUMBER DEFAULT NULL
5073 , p_is_expense IN VARCHAR2 DEFAULT NULL
5074 , p_project_id IN NUMBER DEFAULT NULL
5075 , p_task_id IN NUMBER DEFAULT NULL
5076 , p_country_code IN VARCHAR2 DEFAULT NULL
5077 , p_from_lpn_id IN NUMBER -- Nested LPN changes
5078 , p_secondary_rcv_qty IN NUMBER --OPM Convergence
5079 , p_rcv_sec_uom IN VARCHAR2 --OPM Convergence
5080 , p_rcv_sec_uom_code IN VARCHAR2 --OPM Convergence
5081 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - DFF cols
5082 , p_attribute1 IN VARCHAR2 DEFAULT NULL
5083 , p_attribute2 IN VARCHAR2 DEFAULT NULL
5084 , p_attribute3 IN VARCHAR2 DEFAULT NULL
5085 , p_attribute4 IN VARCHAR2 DEFAULT NULL
5086 , p_attribute5 IN VARCHAR2 DEFAULT NULL
5087 , p_attribute6 IN VARCHAR2 DEFAULT NULL
5088 , p_attribute7 IN VARCHAR2 DEFAULT NULL
5089 , p_attribute8 IN VARCHAR2 DEFAULT NULL
5090 , p_attribute9 IN VARCHAR2 DEFAULT NULL
5091 , p_attribute10 IN VARCHAR2 DEFAULT NULL
5092 , p_attribute11 IN VARCHAR2 DEFAULT NULL
5093 , p_attribute12 IN VARCHAR2 DEFAULT NULL
5094 , p_attribute13 IN VARCHAR2 DEFAULT NULL
5095 , p_attribute14 IN VARCHAR2 DEFAULT NULL
5096 , p_attribute15 IN VARCHAR2 DEFAULT NULL
5097 ) IS
5098 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
5099 l_msg_count NUMBER;
5100 l_msg_data VARCHAR2(400);
5101 l_label_status VARCHAR2(500);
5102 l_progress VARCHAR2(10);
5103 l_txn_id_tbl inv_label.transaction_id_rec_type;
5104 l_counter NUMBER := 0;
5105 l_subinventory VARCHAR2(10);
5106 l_locator_id NUMBER;
5107
5108 -- For LCM
5109 l_tx_type VARCHAR2(40);
5110 -- END FOR LCM
5111
5112
5113 CURSOR c_rti_txn_id IS
5114 /* Bug 2443163 */
5115 /* SELECT MIN(rti.interface_transaction_id) */
5116 /* Group BY LPN_ID is changed for Express Receipts */
5117 /* Also duplicate print of LPN labels is avoided */
5118 SELECT MAX(rti.interface_transaction_id)
5119 FROM rcv_transactions_interface rti
5120 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
5121 GROUP BY DECODE(p_source_type, 'ASNEXP', rti.interface_transaction_id, 'SHIPMENTEXP', rti.interface_transaction_id, NULL);
5122
5123 -- GROUP BY rti.lpn_id;
5124 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5125 BEGIN
5126 x_status := fnd_api.g_ret_sts_success;
5127 l_progress := '10';
5128
5129 IF (l_debug = 1) THEN
5130 print_debug('create_direct_rti_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5131 END IF;
5132
5133 IF (l_debug = 1) THEN
5134 print_debug('txn temp id: ' || p_transaction_temp_id, 4);
5135 END IF;
5136
5137 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
5138
5139 --BUG 3440184: For performance reason, use the follow query
5140 --instead of gl_sets_of_books
5141
5142 SELECT TO_NUMBER(hoi.org_information1)
5143 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
5144 FROM hr_organization_information hoi
5145 WHERE hoi.organization_id = p_organization_id
5146 AND (hoi.org_information_context || '') = 'Accounting Information';
5147
5148 -- SELECT ood.set_of_books_id
5149 -- INTO inv_rcv_common_apis.g_po_startup_value.sob_id
5150 -- FROM org_organization_definitions ood, gl_sets_of_books sob
5151 -- WHERE organization_id = p_organization_id
5152 -- AND sob.set_of_books_id = ood.set_of_books_id;
5153
5154 END IF;
5155
5156 l_progress := '10';
5157 -- first check if the transaction date satisfies the validation.
5158 inv_rcv_common_apis.validate_trx_date(
5159 p_trx_date => SYSDATE
5160 , p_organization_id => p_organization_id
5161 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
5162 , x_return_status => x_status
5163 , x_error_code => x_message
5164 );
5165
5166 IF x_status <> fnd_api.g_ret_sts_success THEN
5167 RETURN;
5168 END IF;
5169
5170 IF p_shipment_header_id IS NULL THEN -- Added this check to fix bug no. 2159179
5171 IF p_po_header_id IS NULL
5172 AND p_item_id IS NULL THEN
5173 IF (l_debug = 1) THEN
5174 print_debug('create_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
5175 END IF;
5176
5177 x_status := fnd_api.g_ret_sts_error;
5178 RETURN;
5179 END IF;
5180 END IF;
5181
5182 l_progress := '30';
5183
5184 IF p_po_header_id IS NOT NULL
5185 AND p_source_type <> 'ASNEXP'
5186 AND p_source_type <> 'LCMEXP' -- For LCM Project
5187 AND p_source_type <> 'LCMCONFM' -- For LCM Project
5188 AND p_source_type <> 'ASNCONFM' -- bug fix 2129249
5189 THEN
5190 l_progress := '40';
5191
5192 IF (l_debug = 1) THEN
5193 print_debug('create_direct_rti_rec: 4 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5194 print_debug('create_direct_rti_rec: 4.1 p_po_header_id = ' || p_po_header_id, 4);
5195 END IF;
5196
5197 IF p_item_id IS NULL
5198 AND p_item_desc IS NULL THEN
5199 IF (l_debug = 1) THEN
5200 print_debug('create_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
5201 END IF;
5202
5203 x_status := fnd_api.g_ret_sts_error;
5204 RETURN;
5205 END IF;
5206
5207 l_subinventory := p_subinventory;
5208 l_locator_id := p_locator_id;
5209
5210 IF p_location_id IS NOT NULL THEN
5211 l_subinventory := '';
5212 l_locator_id := '';
5213 END IF;
5214
5215 create_po_drct_dlvr_rti_rec(
5216 p_move_order_header_id => p_move_order_header_id
5217 , p_organization_id => p_organization_id
5218 , p_po_header_id => p_po_header_id
5219 , p_po_release_id => p_po_release_id
5220 , p_po_line_id => p_po_line_id
5221 , p_po_line_location_id => NULL
5222 , p_po_distribution_id => NULL
5223 , p_item_id => p_item_id
5224 , p_rcv_qty => p_rcv_qty
5225 , p_rcv_uom => p_rcv_uom
5226 , p_rcv_uom_code => p_rcv_uom_code
5227 , p_source_type => p_source_type
5228 , p_subinventory => l_subinventory
5229 , p_locator_id => l_locator_id
5230 , p_transaction_temp_id => p_transaction_temp_id
5231 , p_lot_control_code => p_lot_control_code
5232 , p_serial_control_code => p_serial_control_code
5233 , p_lpn_id => p_lpn_id
5234 , p_revision => p_revision
5235 , x_status => l_return_status
5236 , x_message => x_message
5237 , p_inv_item_id => p_inv_item_id
5238 , p_item_desc => p_item_desc
5239 , p_location_id => p_location_id
5240 , p_is_expense => p_is_expense
5241 , p_project_id => p_project_id
5242 , p_task_id => p_task_id
5243 , p_country_code => p_country_code
5244 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5245 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5246 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5247 , p_attribute_category => p_attribute_category --Bug #4147209
5248 , p_attribute1 => p_attribute1
5249 , p_attribute2 => p_attribute2
5250 , p_attribute3 => p_attribute3
5251 , p_attribute4 => p_attribute4
5252 , p_attribute5 => p_attribute5
5253 , p_attribute6 => p_attribute6
5254 , p_attribute7 => p_attribute7
5255 , p_attribute8 => p_attribute8
5256 , p_attribute9 => p_attribute9
5257 , p_attribute10 => p_attribute10
5258 , p_attribute11 => p_attribute11
5259 , p_attribute12 => p_attribute12
5260 , p_attribute13 => p_attribute13
5261 , p_attribute14 => p_attribute14
5262 , p_attribute15 => p_attribute15
5263 );
5264
5265 IF l_return_status = fnd_api.g_ret_sts_error THEN
5266 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5267 fnd_msg_pub.ADD;
5268
5269 IF (l_debug = 1) THEN
5270 print_debug(
5271 'create_direct_rti_rec 20.1: create_po_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
5272 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5273 END IF;
5274
5275 RAISE fnd_api.g_exc_error;
5276 END IF;
5277
5278 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5279 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5280 fnd_msg_pub.ADD;
5281
5282 IF (l_debug = 1) THEN
5283 print_debug(
5284 'create_direct_rti_rec 20.2: create_po_drct_dlvr_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5285 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5286 END IF;
5287
5288 RAISE fnd_api.g_exc_unexpected_error;
5289 END IF;
5290 ELSIF p_shipment_header_id IS NOT NULL THEN
5291 l_progress := '50';
5292
5293 IF (l_debug = 1) THEN
5294 print_debug('create_direct_rti_rec: 22' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5295 print_debug('create_direct_rti_rec: 22.1 p_shipment_header_id = ' || p_shipment_header_id, 4);
5296 END IF;
5297
5298 IF p_source_type = 'ASNEXP'
5299 OR p_source_type = 'LCMEXP' -- For LCM Project
5300 OR p_source_type = 'SHIPMENTEXP'
5301 OR p_source_type = 'SHIPMENT'
5302 OR p_source_type = 'REQEXP' THEN
5303 IF p_source_type = 'ASNEXP' THEN
5304 IF (l_debug = 1) THEN
5305 print_debug(
5306 'create_direct_rti_rec: 23 - calling create_asn_exp_dd_intf_rec for ASNEXP'
5307 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5308 END IF;
5309
5310 -- For Bug 7440217 added code to handle LCM Doc also
5311 IF p_source_type = 'ASNEXP' THEN
5312 l_tx_type := 'ASN';
5313 ELSIF p_source_type = 'LCMEXP' THEN -- For LCM Project
5314 l_tx_type := 'LCM'; -- For LCM Project
5315 END IF;
5316 -- End for Bug 7440217
5317
5318 create_asn_exp_dd_intf_rec(
5319 p_move_order_header_id => p_move_order_header_id
5320 , p_organization_id => p_organization_id
5321 , p_shipment_header_id => p_shipment_header_id
5322 , p_po_header_id => p_po_header_id
5323 , p_source_type => l_tx_type
5324 , p_subinventory => p_subinventory
5325 , p_locator_id => p_locator_id
5326 , p_lpn_id => p_lpn_id
5327 , p_transaction_temp_id => p_transaction_temp_id
5328 , x_status => l_return_status
5329 , x_message => l_msg_data
5330 , p_project_id => p_project_id
5331 , p_task_id => p_task_id
5332 , p_country_code => p_country_code
5333 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5334 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5335 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5336 , p_attribute_category => p_attribute_category
5337 , p_attribute1 => p_attribute1
5338 , p_attribute2 => p_attribute2
5339 , p_attribute3 => p_attribute3
5340 , p_attribute4 => p_attribute4
5341 , p_attribute5 => p_attribute5
5342 , p_attribute6 => p_attribute6
5343 , p_attribute7 => p_attribute7
5344 , p_attribute8 => p_attribute8
5345 , p_attribute9 => p_attribute9
5346 , p_attribute10 => p_attribute10
5347 , p_attribute11 => p_attribute11
5348 , p_attribute12 => p_attribute12
5349 , p_attribute13 => p_attribute13
5350 , p_attribute14 => p_attribute14
5351 , p_attribute15 => p_attribute15
5352 );
5353
5354 IF l_return_status = fnd_api.g_ret_sts_error THEN
5355 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
5356 fnd_msg_pub.ADD;
5357
5358 IF (l_debug = 1) THEN
5359 print_debug(
5360 'create_direct_rti_rec 23.1: create_asn_exp_dd_intf_rec RAISE FND_API.G_EXC_ERROR;'
5361 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5362 END IF;
5363
5364 RAISE fnd_api.g_exc_error;
5365 END IF;
5366
5367 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5368 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
5369 fnd_msg_pub.ADD;
5370
5371 IF (l_debug = 1) THEN
5372 print_debug(
5373 'create_direct_rti_rec 23.2: create_asn_exp_dd_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5374 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5375 END IF;
5376
5377 RAISE fnd_api.g_exc_unexpected_error;
5378 END IF;
5379 ELSE
5380 l_progress := '50';
5381
5382 IF (l_debug = 1) THEN
5383 print_debug(
5384 'create_direct_rti_rec: 24 - calling create_asn_exp_dd_intf_rec for intransit shipment'
5385 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5386 END IF;
5387
5388 create_asn_exp_dd_intf_rec(
5389 p_move_order_header_id => p_move_order_header_id
5390 , p_organization_id => p_organization_id
5391 , p_shipment_header_id => p_shipment_header_id
5392 , p_po_header_id => p_po_header_id
5393 , p_source_type => 'INTERNAL'
5394 , p_subinventory => p_subinventory
5395 , p_locator_id => p_locator_id
5396 , p_lpn_id => p_lpn_id
5397 , p_transaction_temp_id => p_transaction_temp_id
5398 , x_status => l_return_status
5399 , x_message => l_msg_data
5400 , p_project_id => p_project_id
5401 , p_task_id => p_task_id
5402 , p_country_code => p_country_code
5403 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5404 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5405 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5406 , p_attribute_category => p_attribute_category
5407 , p_attribute1 => p_attribute1
5408 , p_attribute2 => p_attribute2
5409 , p_attribute3 => p_attribute3
5410 , p_attribute4 => p_attribute4
5411 , p_attribute5 => p_attribute5
5412 , p_attribute6 => p_attribute6
5413 , p_attribute7 => p_attribute7
5414 , p_attribute8 => p_attribute8
5415 , p_attribute9 => p_attribute9
5416 , p_attribute10 => p_attribute10
5417 , p_attribute11 => p_attribute11
5418 , p_attribute12 => p_attribute12
5419 , p_attribute13 => p_attribute13
5420 , p_attribute14 => p_attribute14
5421 , p_attribute15 => p_attribute15
5422 );
5423
5424 IF l_return_status = fnd_api.g_ret_sts_error THEN
5425 --BUG 3433072: The message below is not defined. Plus, it
5426 --create_asn_exp_dd_intf_rec fails, it will fails with a error
5427 --message.
5428 --fnd_message.set_name('INV', 'INV_RCV_CRT_INTSHIPEXP_RTI_FAIL'); -- MSGTBD
5429 --fnd_msg_pub.ADD;
5430
5431 IF (l_debug = 1) THEN
5432 print_debug(
5433 'create_direct_rti_rec 24.1: create_asn_exp_dd_intf_rec for IntShip RAISE FND_API.G_EXC_ERROR;'
5434 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5435 END IF;
5436
5437 RAISE fnd_api.g_exc_error;
5438 END IF;
5439
5440 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5441 --BUG 3433072: The message below is not defined
5442 --fnd_message.set_name('INV', 'INV_RCV_CREATE_INTSHIPEXP_RTI_FAIL');
5443 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL');
5444 fnd_msg_pub.ADD;
5445
5446 IF (l_debug = 1) THEN
5447 print_debug(
5448 'create_direct_rti_rec 24.2: create_asn_exp_dd_intf_rec for IntShip RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5449 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5450 END IF;
5451
5452 RAISE fnd_api.g_exc_unexpected_error;
5453 END IF;
5454 END IF;
5455 ELSIF p_source_type IN ('ASNCONFM', 'LCMCONFM') THEN -- For LCM Project
5456
5457 l_progress := '60';
5458
5459 -- For Bug 7440217 added code to handle LCM Doc also
5460 IF p_source_type = 'ASNCONFM' THEN
5461 l_tx_type := 'ASN';
5462 ELSIF p_source_type = 'LCMCONFM' THEN -- For LCM Project
5463 l_tx_type := 'LCM'; -- For LCM Project
5464 END IF;
5465 -- End for Bug 7440217
5466
5467 IF (l_debug = 1) THEN
5468 print_debug('create_direct_rti_rec: 25 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5469 END IF;
5470
5471 create_asn_con_dd_intf_rec(
5472 p_move_order_header_id => p_move_order_header_id
5473 , p_organization_id => p_organization_id
5474 , p_shipment_header_id => p_shipment_header_id
5475 , p_po_header_id => p_po_header_id
5476 , p_item_id => p_item_id
5477 , p_rcv_qty => p_rcv_qty
5478 , p_rcv_uom => p_rcv_uom
5479 , p_rcv_uom_code => p_rcv_uom_code
5480 , p_source_type => l_tx_type
5481 , p_subinventory => p_subinventory
5482 , p_locator_id => p_locator_id
5483 , p_from_lpn_id => p_from_lpn_id
5484 , -- Nested LPN changes
5485 p_lpn_id => p_lpn_id
5486 , p_lot_control_code => p_lot_control_code
5487 , p_serial_control_code => p_serial_control_code
5488 , p_revision => p_revision
5489 , p_transaction_temp_id => p_transaction_temp_id
5490 , x_status => l_return_status
5491 , x_message => l_msg_data
5492 , p_project_id => p_project_id
5493 , p_task_id => p_task_id
5494 , p_country_code => p_country_code
5495 , p_item_desc => p_item_desc
5496 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5497 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5498 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5499 , p_attribute_category => p_attribute_category
5500 , p_attribute1 => p_attribute1
5501 , p_attribute2 => p_attribute2
5502 , p_attribute3 => p_attribute3
5503 , p_attribute4 => p_attribute4
5504 , p_attribute5 => p_attribute5
5505 , p_attribute6 => p_attribute6
5506 , p_attribute7 => p_attribute7
5507 , p_attribute8 => p_attribute8
5508 , p_attribute9 => p_attribute9
5509 , p_attribute10 => p_attribute10
5510 , p_attribute11 => p_attribute11
5511 , p_attribute12 => p_attribute12
5512 , p_attribute13 => p_attribute13
5513 , p_attribute14 => p_attribute14
5514 , p_attribute15 => p_attribute15
5515 , p_express_transaction => NULL--Bug 5550783
5516 );
5517
5518 IF l_return_status = fnd_api.g_ret_sts_error THEN
5519 fnd_message.set_name('INV', 'INV_RCV_CRT_ASNCON_RTI_FAIL'); -- MSGTBD
5520 fnd_msg_pub.ADD;
5521
5522 IF (l_debug = 1) THEN
5523 print_debug(
5524 'create_direct_rti_rec 25.1: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_ERROR;'
5525 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5526 END IF;
5527
5528 RAISE fnd_api.g_exc_error;
5529 END IF;
5530
5531 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5532 fnd_message.set_name('INV', 'INV_RCV_CREATE_INTSHIPEXP_RTI_FAIL'); -- MSGTBD
5533 fnd_msg_pub.ADD;
5534
5535 IF (l_debug = 1) THEN
5536 print_debug(
5537 'create_direct_rti_rec 25.2: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5538 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5539 , 4
5540 );
5541 END IF;
5542
5543 RAISE fnd_api.g_exc_unexpected_error;
5544 END IF;
5545 ELSE
5546 create_int_shp_dr_del_rti_rec(
5547 p_move_order_header_id => p_move_order_header_id
5548 , p_organization_id => p_organization_id
5549 , p_shipment_header_id => p_shipment_header_id
5550 , p_shipment_line_id => NULL
5551 , p_item_id => p_item_id
5552 , p_rcv_qty => p_rcv_qty
5553 , p_rcv_uom => p_rcv_uom
5554 , p_rcv_uom_code => p_rcv_uom_code
5555 , p_source_type => p_source_type
5556 , p_subinventory => p_subinventory
5557 , p_locator_id => p_locator_id
5558 , p_transaction_temp_id => p_transaction_temp_id
5559 , p_lot_control_code => p_lot_control_code
5560 , p_serial_control_code => p_serial_control_code
5561 , p_from_lpn_id => p_from_lpn_id
5562 , -- Nested LPN Changes
5563 p_lpn_id => p_lpn_id
5564 , p_revision => p_revision
5565 , p_project_id => p_project_id
5566 , p_task_id => p_task_id
5567 , x_status => l_return_status
5568 , x_message => x_message
5569 , p_country_code => p_country_code
5570 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5571 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5572 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5573 , p_attribute_category => p_attribute_category
5574 , p_attribute1 => p_attribute1
5575 , p_attribute2 => p_attribute2
5576 , p_attribute3 => p_attribute3
5577 , p_attribute4 => p_attribute4
5578 , p_attribute5 => p_attribute5
5579 , p_attribute6 => p_attribute6
5580 , p_attribute7 => p_attribute7
5581 , p_attribute8 => p_attribute8
5582 , p_attribute9 => p_attribute9
5583 , p_attribute10 => p_attribute10
5584 , p_attribute11 => p_attribute11
5585 , p_attribute12 => p_attribute12
5586 , p_attribute13 => p_attribute13
5587 , p_attribute14 => p_attribute14
5588 , p_attribute15 => p_attribute15
5589 );
5590
5591 IF l_return_status = fnd_api.g_ret_sts_error THEN
5592 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5593 fnd_msg_pub.ADD;
5594
5595 IF (l_debug = 1) THEN
5596 print_debug(
5597 'create_direct_rti_rec 40.1: create_int_shp_dr_del_rti_rec RAISE FND_API.G_EXC_ERROR;'
5598 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5599 END IF;
5600
5601 RAISE fnd_api.g_exc_error;
5602 END IF;
5603
5604 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5605 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5606 fnd_msg_pub.ADD;
5607
5608 IF (l_debug = 1) THEN
5609 print_debug(
5610 'create_direct_rti_rec 40.2:create_int_shp_dr_del_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5611 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5612 END IF;
5613
5614 RAISE fnd_api.g_exc_unexpected_error;
5615 END IF;
5616 END IF;
5617 ELSIF p_oe_order_header_id IS NOT NULL THEN
5618 l_progress := '60';
5619
5620 IF (l_debug = 1) THEN
5621 print_debug('create_direct_rti_rec: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5622 print_debug('create_direct_rti_rec: 6.1 p_oe_order_header_id = ' || p_oe_order_header_id, 4);
5623 END IF;
5624
5625 create_rma_drct_dlvr_rti_rec(
5626 p_move_order_header_id => p_move_order_header_id
5627 , p_organization_id => p_organization_id
5628 , p_oe_order_header_id => p_oe_order_header_id
5629 , p_oe_order_line_id => NULL
5630 , p_item_id => p_item_id
5631 , p_rcv_qty => p_rcv_qty
5632 , p_rcv_uom => p_rcv_uom
5633 , p_rcv_uom_code => p_rcv_uom_code
5634 , p_source_type => p_source_type
5635 , p_subinventory => p_subinventory
5636 , p_locator_id => p_locator_id
5637 , p_transaction_temp_id => p_transaction_temp_id
5638 , p_lot_control_code => p_lot_control_code
5639 , p_serial_control_code => p_serial_control_code
5640 , p_lpn_id => p_lpn_id
5641 , p_revision => p_revision
5642 , x_status => l_return_status
5643 , x_message => x_message
5644 , p_project_id => p_project_id
5645 , p_task_id => p_task_id
5646 , p_country_code => p_country_code
5647 , p_secondary_rcv_qty => p_secondary_rcv_qty --OPM Convergence
5648 , p_rcv_sec_uom => p_rcv_sec_uom --OPM Convergence
5649 , p_rcv_sec_uom_code => p_rcv_sec_uom_code --OPM Convergence
5650 , p_attribute_category => p_attribute_category
5651 , p_attribute1 => p_attribute1
5652 , p_attribute2 => p_attribute2
5653 , p_attribute3 => p_attribute3
5654 , p_attribute4 => p_attribute4
5655 , p_attribute5 => p_attribute5
5656 , p_attribute6 => p_attribute6
5657 , p_attribute7 => p_attribute7
5658 , p_attribute8 => p_attribute8
5659 , p_attribute9 => p_attribute9
5660 , p_attribute10 => p_attribute10
5661 , p_attribute11 => p_attribute11
5662 , p_attribute12 => p_attribute12
5663 , p_attribute13 => p_attribute13
5664 , p_attribute14 => p_attribute14
5665 , p_attribute15 => p_attribute15
5666 );
5667
5668 IF l_return_status = fnd_api.g_ret_sts_error THEN
5669 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5670 fnd_msg_pub.ADD;
5671
5672 IF (l_debug = 1) THEN
5673 print_debug(
5674 'create_direct_rti_rec 50.1: create_rma_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
5675 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5676 END IF;
5677
5678 RAISE fnd_api.g_exc_error;
5679 END IF;
5680
5681 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5682 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5683 fnd_msg_pub.ADD;
5684
5685 IF (l_debug = 1) THEN
5686 print_debug(
5687 'create_direct_rti_rec 50.2: create_rma_drct_dlvr_rti_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5688 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5689 END IF;
5690
5691 RAISE fnd_api.g_exc_unexpected_error;
5692 END IF;
5693 END IF;
5694
5695 l_progress := '80';
5696
5697 IF (l_debug = 1) THEN
5698 print_debug('create_direct_rti_rec calling print_label: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5699 END IF;
5700
5701 x_status := l_return_status; -- l_return_status can be 'W', we want to carry that over
5702
5703 -- calling label printing API
5704
5705 IF l_return_status <> fnd_api.g_ret_sts_error THEN
5706 l_progress := '80';
5707
5708 IF (l_debug = 1) THEN
5709 print_debug('create_direct_rti_rec: 8.1 before inv_label.print_label ' || inv_rcv_common_apis.g_rcv_global_var.interface_group_id, 4);
5710 END IF;
5711
5712 /* FP-J Lot/Serial Support Enhancement
5713 * If INV J and PO J are installed, do not call label printing API at this stage
5714 */
5715 IF ((inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po) OR
5716 (inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j)) THEN
5717
5718 IF (p_source_type <> 'VENDOR') THEN --Bug #4079952.. For PO receipt code in rcv_insert_update_header(INVSTDRB.pls) will be called.
5719
5720 l_counter := 1;
5721 OPEN c_rti_txn_id;
5722
5723 LOOP
5724 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
5725 EXIT WHEN c_rti_txn_id%NOTFOUND;
5726
5727 IF (l_debug = 1) THEN
5728 print_debug('create_direct_rti_rec calling printing for:' || l_txn_id_tbl(l_counter), 4);
5729 END IF;
5730
5731 l_counter := l_counter + 1;
5732 END LOOP;
5733
5734 CLOSE c_rti_txn_id;
5735 inv_label.print_label(
5736 x_return_status => l_return_status
5737 , x_msg_count => l_msg_count
5738 , x_msg_data => l_msg_data
5739 , x_label_status => l_label_status
5740 , p_api_version => 1.0
5741 , p_print_mode => 1
5742 , p_business_flow_code => 1
5743 , p_transaction_id => l_txn_id_tbl
5744 );
5745
5746 IF l_return_status <> fnd_api.g_ret_sts_success THEN
5747 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
5748 fnd_msg_pub.ADD;
5749 x_status := 'W';
5750
5751 IF (l_debug = 1) THEN
5752 print_debug('create_direct_rti_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5753 END IF; --END IF l_debug = 1
5754 END IF; --END IF label ret status <> S
5755 END IF ; --Bug #4079952
5756 ELSE
5757 IF (l_debug = 1) THEN
5758 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
5759 END IF;
5760 END IF; --END IF INV J and PO J installed
5761 END IF; --END IF ret status = Successs
5762
5763 IF (l_debug = 1) THEN
5764 print_debug('create_direct_rti_rec exiting print_label: 7' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5765 END IF;
5766
5767 IF (l_debug = 1) THEN
5768 print_debug('About exit create_direct_rti_rec: 8' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5769 print_debug('create_direct_rti_rec: 8.1 - x_status = ' || x_status, 4);
5770 print_debug('create_direct_rti_rec: 8.2 - x_message= ' || x_message, 4);
5771 END IF;
5772 EXCEPTION
5773 WHEN fnd_api.g_exc_error THEN
5774 x_status := fnd_api.g_ret_sts_error;
5775 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5776 WHEN fnd_api.g_exc_unexpected_error THEN
5777 x_status := fnd_api.g_ret_sts_unexp_error;
5778 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5779 WHEN OTHERS THEN
5780 x_status := fnd_api.g_ret_sts_unexp_error;
5781
5782 IF SQLCODE IS NOT NULL THEN
5783 inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_direct_rti_rec', l_progress, SQLCODE);
5784 END IF;
5785
5786 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5787 END create_direct_rti_rec;
5788 /*
5789 PROCEDURE pack_lpn_txn
5790 IS
5791 l_proc_msg VARCHAR2(400);
5792 l_return_status NUMBER;
5793 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5794 BEGIN
5795 IF (l_debug = 1) THEN
5796 print_debug('Enter pack_lpn_txn: 1'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS') , 1);
5797 END IF;
5798
5799 l_return_status := inv_lpn_trx_pub.process_lpn_trx
5800 (p_trx_hdr_id => inv_rcv_common_apis.g_rcv_global_var.transaction_header_id,
5801 p_mode => 2, -- putaway mode
5802 p_commit => 'F',
5803 x_proc_msg => l_proc_msg);
5804
5805 IF (l_debug = 1) THEN
5806 print_debug('About exit pack_lpn_txn: 2'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS') , 1);
5807 END IF;
5808
5809
5810 END pack_lpn_txn;
5811 */
5812 END inv_rcv_dir_rcpt_apis;