DBA Data[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.15.12020000.2 2012/07/09 08:05:30 asugandh 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 := l_rcv_rcpt_rec.po_header_id; --Added for bug 9525003
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 	l_lot_number              VARCHAR2(80) := NULL ;--12596775
1618 
1619     CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER) IS
1620       SELECT 'N' line_chkbox
1621            , 'INTERNAL' source_type_code
1622            , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
1623            , rsl.source_document_code order_type_code
1624            , '' order_type
1625            --Passing as NULL for the columns for which value is not known.  --Bug #3878174
1626            , TO_NUMBER(NULL) po_header_id
1627            , NULL po_number
1628            , TO_NUMBER(NULL) po_line_id
1629            , TO_NUMBER(NULL) po_line_number
1630            , TO_NUMBER(NULL) po_line_location_id
1631            , NULL po_shipment_number
1632            , TO_NUMBER(NULL) po_release_id
1633            , TO_NUMBER(NULL) po_release_number
1634 /*
1635            , rsh.shipment_header_id po_header_id
1636            , rsh.shipment_num po_number
1637            , rsl.shipment_line_id po_line_id
1638            , rsl.line_num po_line_number
1639            , rsl.shipment_line_id po_line_location_id
1640            , rsl.line_num po_shipment_number
1641            , rsh.shipment_header_id po_release_id
1642            , rsh.shipment_header_id po_release_number
1643 */
1644            , porh.requisition_header_id req_header_id
1645            , porh.segment1 req_number
1646            , porl.requisition_line_id req_line_id
1647            , porl.line_num req_line
1648            , rsl.req_distribution_id req_distribution_id
1649            , rsl.shipment_header_id rcv_shipment_header_id
1650            , rsh.shipment_num rcv_shipment_number
1651            , rsl.shipment_line_id rcv_shipment_line_id
1652            , rsl.line_num rcv_line_number
1653            , rsl.from_organization_id from_organization_id
1654            , rsl.to_organization_id to_organization_id
1655            , rsl.shipment_line_id vendor_id
1656            , '' SOURCE
1657            , TO_NUMBER(NULL) vendor_site_id
1658            , 'N' outside_operation_flag
1659            , rsl.item_id item_id
1660            , -- Bug 2073164
1661              NULL uom_code
1662            , rsl.unit_of_measure primary_uom
1663            , mum.uom_class primary_uom_class
1664            , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
1665            , NVL(msi.location_control_code, 1) item_locator_control
1666            , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
1667            , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
1668            , NVL(msi.shelf_life_code, 1) shelf_life_code
1669            , NVL(msi.shelf_life_days, 0) shelf_life_days
1670            , msi.serial_number_control_code serial_number_control_code
1671            , msi.lot_control_code lot_control_code
1672            , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
1673            , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
1674            , NULL item_number
1675            , rsl.item_revision item_revision
1676            , rsl.item_description item_description
1677            , rsl.category_id item_category_id
1678            , '' hazard_class
1679            , '' un_number
1680            , rsl.vendor_item_num vendor_item_number
1681            , rsh.ship_to_location_id ship_to_location_id
1682            , '' ship_to_location
1683            , rsh.packing_slip packing_slip
1684            , rsl.routing_header_id routing_id
1685            , '' routing_name
1686            , porl.need_by_date need_by_date
1687            , rsh.expected_receipt_date expected_receipt_date
1688            , rsl.quantity_shipped ordered_qty
1689            , rsl.primary_unit_of_measure ordered_uom
1690            , rsh.ussgl_transaction_code ussgl_transaction_code
1691            , rsh.government_context government_context
1692            , NULL inspection_required_flag
1693            , NULL receipt_required_flag
1694            , NULL enforce_ship_to_location_code
1695            , TO_NUMBER(NULL) unit_price
1696            , NULL currency_code
1697            , NULL currency_conversion_type
1698            , TO_DATE(NULL) currency_conversion_date
1699            , TO_NUMBER(NULL) currency_conversion_rate
1700            , NULL note_to_receiver
1701            , --PORL.NOTE_TO_RECEIVER       NOTE_TO_RECEIVER,
1702              rsl.destination_type_code destination_type_code
1703            , rsl.deliver_to_person_id deliver_to_person_id
1704            , rsl.deliver_to_location_id deliver_to_location_id
1705            , rsl.to_subinventory destination_subinventory
1706            , rsl.attribute_category attribute_category
1707            , rsl.attribute1 attribute1
1708            , rsl.attribute2 attribute2
1709            , rsl.attribute3 attribute3
1710            , rsl.attribute4 attribute4
1711            , rsl.attribute5 attribute5
1712            , rsl.attribute6 attribute6
1713            , rsl.attribute7 attribute7
1714            , rsl.attribute8 attribute8
1715            , rsl.attribute9 attribute9
1716            , rsl.attribute10 attribute10
1717            , rsl.attribute11 attribute11
1718            , rsl.attribute12 attribute12
1719            , rsl.attribute13 attribute13
1720            , rsl.attribute14 attribute14
1721            , rsl.attribute15 attribute15
1722            , 'OPEN' closed_code
1723            , NULL asn_type
1724            , rsh.bill_of_lading bill_of_lading
1725            , rsh.shipped_date shipped_date
1726            , rsh.freight_carrier_code freight_carrier_code
1727            , rsh.waybill_airbill_num waybill_airbill_num
1728            , rsh.freight_bill_number freight_bill_num
1729            , rsl.vendor_lot_num vendor_lot_num
1730            , rsl.container_num container_num
1731            , rsl.truck_num truck_num
1732            , rsl.bar_code_label bar_code_label
1733            , NULL rate_type_display
1734            , 'P' match_option
1735            , NULL country_of_origin_code
1736            , TO_NUMBER(NULL) oe_order_header_id
1737            , TO_NUMBER(NULL) oe_order_num
1738            , TO_NUMBER(NULL) oe_order_line_id
1739            , TO_NUMBER(NULL) oe_order_line_num
1740            , TO_NUMBER(NULL) customer_id
1741            , TO_NUMBER(NULL) customer_site_id
1742            , NULL customer_item_num
1743            , NULL pll_note_to_receiver
1744            , --PORL.NOTE_TO_RECEIVER       PLL_NOTE_TO_RECEIVER,
1745              NULL po_distribution_id
1746            , NULL qty_ordered
1747            , NULL wip_entity_id
1748            , NULL wip_operation_seq_num
1749            , NULL wip_resource_seq_num
1750            , NULL wip_repetitive_schedule_id
1751            , NULL wip_line_id
1752            , NULL bom_resource_id
1753            , '' destination_type
1754            , '' LOCATION
1755            , NULL currency_conversion_rate_pod
1756            , NULL currency_conversion_date_pod
1757            , NULL project_id
1758            , NULL task_id
1759             , NULL secondary_uom --OPM Convergence
1760            , NULL secondary_uom_code --OPM Convergence
1761            , NULL secondary_quantity --OPM Convergence
1762       FROM   rcv_shipment_headers rsh
1763            , rcv_shipment_lines rsl
1764            , po_requisition_headers porh
1765            , po_requisition_lines porl
1766            , mtl_system_items msi
1767            , mtl_system_items msi1
1768            , mtl_units_of_measure mum
1769       WHERE  rsh.receipt_source_code <> 'VENDOR'
1770       AND    rsl.requisition_line_id = porl.requisition_line_id(+)
1771       AND    porl.requisition_header_id = porh.requisition_header_id(+)
1772       AND    rsh.shipment_header_id = rsl.shipment_header_id
1773       AND    mum.unit_of_measure(+) = rsl.unit_of_measure
1774       AND    msi.organization_id(+) = rsl.to_organization_id
1775       AND    msi.inventory_item_id(+) = rsl.item_id
1776       AND    msi1.organization_id(+) = rsl.from_organization_id
1777       AND    msi1.inventory_item_id(+) = rsl.item_id
1778       AND    rsl.shipment_line_id = v_shipment_line_id
1779       AND    (
1780               (
1781                rsl.source_document_code = 'REQ'
1782                AND EXISTS(
1783                     SELECT '1'
1784                     FROM   po_req_distributions_all prd
1785                     WHERE  prd.requisition_line_id = porl.requisition_line_id
1786                      AND
1787                            (
1788                             p_project_id IS NULL
1789                             OR(p_project_id = -9999
1790                                AND prd.project_id IS NULL)
1791                             OR -- bug 2669021
1792                                prd.project_id = p_project_id
1793                            )
1794                     AND    (p_task_id IS NULL
1795                             OR prd.task_id = p_task_id))
1796               )
1797               OR rsl.source_document_code <> 'REQ'
1798              );
1799 
1800 -- 3441084 Requisition_line_id also needs to be joined in the above Query otherwise will do
1801 -- a full scan on po_req_distributions_all which is not good.
1802 
1803 
1804     l_debug                   NUMBER  := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1805     --table to store all RTId, quantity and original_rti_id for lot/serial splits
1806     l_new_rti_info            inv_rcv_integration_apis.child_rec_tb_tp;
1807     l_split_lot_serial_ok     BOOLEAN;   --Return status of lot_serial_split API
1808     l_msni_count              NUMBER := 0;
1809 
1810     CURSOR l_curs_rcpt_lots_detail IS  -- 13972742
1811     SELECT lot_number, transaction_quantity
1812     FROM mtl_transaction_lots_interface
1813     WHERE product_transaction_id = p_transaction_temp_id ;
1814     end_loop NUMBER := 0;
1815     l_rcpt_lots l_curs_rcpt_lots_detail%ROWTYPE;
1816     l_transaction_quantity NUMBER;
1817 
1818   BEGIN
1819     x_status := fnd_api.g_ret_sts_success;
1820 
1821     IF (l_debug = 1) THEN
1822       print_debug('Enter create_int_shp_dr_del_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1823     END IF;
1824 
1825     l_progress := '10';
1826     SAVEPOINT crt_intship_rti_sp;
1827 
1828     -- query po_startup_value
1829     BEGIN
1830       /* Bug #2516729
1831        * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
1832        * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
1833        * in order that a new receipt # is not created everytime and the existing receipt # is used
1834        */
1835       BEGIN
1836         SELECT receipt_num
1837         INTO   l_receipt_num
1838         FROM   rcv_shipment_headers
1839         WHERE  shipment_header_id = p_shipment_header_id
1840         AND    ship_to_org_id = p_organization_id;
1841 
1842 	--Bug 4552825 - Assign the value only if it is not null
1843 	IF l_receipt_num IS NOT NULL THEN
1844 	   inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
1845 	END IF;
1846 
1847         IF (l_debug = 1) THEN
1848           print_debug('create_int_shp_dr_del_rti_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
1849         END IF;
1850       EXCEPTION
1851         WHEN NO_DATA_FOUND THEN
1852           l_receipt_num := NULL;
1853       END;
1854 
1855       inv_rcv_common_apis.init_startup_values(p_organization_id);
1856     EXCEPTION
1857       WHEN NO_DATA_FOUND THEN
1858         fnd_message.set_name('INV', 'INV_RCV_PARAM');
1859         fnd_msg_pub.ADD;
1860         RAISE;
1861     END;
1862 
1863     l_progress := '20';
1864 
1865     -- default l_group_id ? clear group id after done
1866     IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
1867       SELECT rcv_interface_groups_s.NEXTVAL
1868       INTO   l_group_id
1869       FROM   DUAL;
1870 
1871       inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
1872 
1873       IF (l_debug = 1) THEN
1874         print_debug('create_int_shp_dr_del_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
1875       END IF;
1876     ELSE
1877       l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1878 
1879       IF (l_debug = 1) THEN
1880         print_debug('create_int_shp_dr_del_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
1881       END IF;
1882     END IF;
1883     /*	comment for bug 13972742
1884     --12596775
1885     IF NVL(p_lot_control_code ,1) = 2 THEN
1886       BEGIN
1887 
1888 		 IF (l_debug = 1) THEN
1889  	         print_debug(' Fetching the Lot Number from MTLI ', 4);
1890  	     END IF;
1891 
1892         SELECT lot_number
1893           INTO l_lot_number
1894           FROM mtl_transaction_lots_interface
1895          WHERE product_transaction_id = p_transaction_temp_id ;
1896 
1897       EXCEPTION
1898        WHEN No_Data_Found THEN
1899          IF (l_debug = 1) THEN
1900            print_debug('create_int_shp_dr_del_rti_rec: No Lot records in MTLI for id :'||p_transaction_temp_id,4);
1901          END IF;
1902          l_lot_number :=NULL;
1903        WHEN too_many_rows THEN
1904          IF (l_debug = 1) THEN
1905            print_debug('create_int_shp_dr_del_rti_rec: More than one records in MTLI for id :'||p_transaction_temp_id,4);
1906          END IF;
1907          l_lot_number :=NULL; --For multiple lots dont input to matching logic
1908       END;
1909     END IF;
1910 
1911  	     IF (l_debug = 1) THEN
1912  	         print_debug('create_int_shp_dr_del_rti_rec: 2.2.1 lot_number: ' || l_lot_number, 4);
1913  	     END IF;
1914     --12596775
1915      */
1916     l_progress := '30';
1917 
1918      LOOP  --13972742
1919      l_lot_number := NULL;
1920      l_transaction_quantity:=p_rcv_qty;
1921      IF end_loop =1 THEN
1922        EXIT;
1923      ELSE
1924        IF NVL(p_lot_control_code ,1) = 1 THEN
1925           end_loop := 1;
1926        ELSE
1927           IF NOT l_curs_rcpt_lots_detail%ISOPEN   THEN
1928              OPEN  l_curs_rcpt_lots_detail;
1929           END IF;
1930           FETCH l_curs_rcpt_lots_detail INTO l_rcpt_lots;
1931           IF  l_curs_rcpt_lots_detail%NOTFOUND THEN
1932              IF end_loop =0 THEN
1933                 end_loop :=1;
1934              else
1935                 CLOSE l_curs_rcpt_lots_detail;
1936                 EXIT;
1937              END IF;
1938           ELSE
1939              l_lot_number := l_rcpt_lots.lot_number;
1940              l_transaction_quantity := l_rcpt_lots.transaction_quantity;
1941              end_loop :=2;
1942           END if;
1943        END IF;
1944      END IF;
1945      IF (l_debug = 1) THEN
1946  	   print_debug('create_int_shp_dr_del_rti_rec: 2.2.1 lot_number: ' || l_lot_number, 4);
1947            print_debug('create_int_shp_dr_del_rti_rec: 2.2.1 l_transaction_quantity: ' || l_transaction_quantity, 4);
1948      END IF;
1949 
1950     -- initialize input record for matching algorithm
1951     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
1952     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := l_transaction_quantity;--13972742
1953     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;
1954     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
1955     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
1956     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
1957                                                                                                                    p_organization_id;
1958     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).shipment_header_id :=
1959                                                                                                                 p_shipment_header_id;
1960     -- line id will be passed only from the putaway api.
1961     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).shipment_line_id :=
1962                                                                                                                   p_shipment_line_id;
1963     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).project_id := p_project_id;
1964     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).task_id    := p_task_id;
1965 	inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).lot_number := l_lot_number;  --12596775
1966 
1967     BEGIN
1968       SELECT primary_unit_of_measure
1969       INTO   inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
1970       FROM   mtl_system_items
1971       WHERE  mtl_system_items.inventory_item_id = p_item_id
1972       AND    mtl_system_items.organization_id = p_organization_id;
1973     EXCEPTION
1974       WHEN NO_DATA_FOUND THEN
1975         IF (l_debug = 1) THEN
1976           print_debug('create_int_shp_dr_del_rti_rec: 3 - get primary_unit_of_measure exception', 4);
1977         END IF;
1978     END;
1979 
1980     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
1981     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
1982     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
1983     l_progress := '40';
1984 
1985     IF (l_debug = 1) THEN
1986       print_debug(
1987         'create_int_shp_dr_del_rti_rec: 4.0 - before inv_rcv_txn_interface.matching_logic'
1988         || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1989       , 4
1990       );
1991       print_debug('create_int_shp_dr_del_rti_rec: 4.0 - p_from_lpn_id => '||p_from_lpn_id,4);
1992     END IF;
1993      l_rcpt_match_table_detail.DELETE; --13972742
1994     inv_rcv_txn_match.matching_logic(
1995       x_return_status         => x_status
1996     , --?
1997       x_msg_count             => l_msg_count
1998     , x_msg_data              => x_message
1999     , x_cascaded_table        => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
2000     , n                       => inv_rcv_std_rcpt_apis.g_receipt_detail_index
2001     , temp_cascaded_table     => l_rcpt_match_table_detail
2002     , p_receipt_num           => NULL
2003     , p_match_type            => 'INTRANSIT SHIPMENT'
2004     , p_lpn_id                => p_from_lpn_id --BUG 4613635 : pass
2005     						--from_lpn_id to matching_logic so that
2006 						--the rsl with the correct asn_lpn_id
2007 						--can be matched
2008     );
2009 
2010     IF (l_debug = 1) THEN
2011       print_debug(
2012         'create_int_shp_dr_del_rti_rec: 4  - after inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2013       , 4
2014       );
2015       print_debug('create_int_shp_dr_del_rti_rec: 4.1 - after matching  l_return_status = ' || x_status, 4);
2016       print_debug('create_int_shp_dr_del_rti_rec: 4.2 - after matching  l_msg_count = ' || l_msg_count, 4);
2017       print_debug('create_int_shp_dr_del_rti_rec: 4.3 - after matching  l_msg_data = ' || x_message, 4);
2018     END IF;
2019 
2020     -- x_status is not successful if there is any execution error in matching.
2021     IF x_status = fnd_api.g_ret_sts_error THEN
2022       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2023       fnd_msg_pub.ADD;
2024 
2025       IF (l_debug = 1) THEN
2026         print_debug('create_int_shp_dr_del_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2027       END IF;
2028 
2029       RAISE fnd_api.g_exc_error;
2030     END IF;
2031 
2032     IF x_status = fnd_api.g_ret_sts_unexp_error THEN
2033       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2034       fnd_msg_pub.ADD;
2035 
2036       IF (l_debug = 1) THEN
2037         print_debug('create_int_shp_dr_del_rti_rec 60.2: Unexpect error calling matching'
2038           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2039         , 1);
2040       END IF;
2041 
2042       RAISE fnd_api.g_exc_unexpected_error;
2043     END IF;
2044 
2045     IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
2046       l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
2047       fnd_message.set_name('INV', l_err_message);
2048       fnd_msg_pub.ADD;
2049 
2050       IF (l_debug = 1) THEN
2051         print_debug('create_int_shp_dr_del_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2052       END IF;
2053 
2054       RAISE fnd_api.g_exc_error;
2055     END IF;
2056 
2057     l_err_message := '@@@';
2058 
2059     FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
2060                                                                inv_rcv_std_rcpt_apis.g_receipt_detail_index
2061                                                              + l_rcpt_match_table_detail.COUNT
2062                                                              - 1
2063                                                             ) LOOP
2064       IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
2065         x_status := 'W';
2066         l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
2067 
2068         IF l_temp_message IS NULL THEN
2069           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2070           l_msg_prod := 'INV';
2071           EXIT;
2072         END IF;
2073 
2074         IF l_err_message = '@@@' THEN
2075           l_err_message := l_temp_message;
2076           l_msg_prod := 'INV';
2077         ELSIF l_temp_message <> l_err_message THEN
2078           l_msg_prod := 'INV';
2079           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2080           EXIT;
2081         END IF;
2082       END IF;
2083     END LOOP;
2084 
2085     IF l_err_message <> '@@@' THEN
2086       fnd_message.set_name(l_msg_prod, l_err_message);
2087       fnd_msg_pub.ADD;
2088 
2089       IF (l_debug = 1) THEN
2090         print_debug('create_int_shp_dr_del_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2091       END IF;
2092     END IF;
2093 
2094     l_progress := '50';
2095 
2096     IF (l_debug = 1) THEN
2097       print_debug('create_int_shp_dr_del_rti_rec: 90 - start loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2098     END IF;
2099 
2100     l_rcv_transaction_rec.rcv_shipment_line_id := l_rcv_rcpt_rec.rcv_shipment_line_id;
2101     -- loop through results returned by matching algorithm
2102     l_progress := '60';
2103 
2104     IF (l_debug = 1) THEN
2105       print_debug('create_int_shp_dr_del_rti_rec no recs matched by matching 95:' || l_rcpt_match_table_detail.COUNT, 4);
2106     END IF;
2107 
2108     FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
2109       l_progress := '62';
2110       OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).shipment_line_id);
2111       l_progress := '64';
2112       FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
2113       l_progress := '66';
2114       CLOSE l_curs_rcpt_detail;
2115       l_progress := '68';
2116 
2117       IF (l_debug = 1) THEN
2118         print_debug('create_int_shp_dr_del_rti_rec found a match 100', 4);
2119         print_debug('Matching returned values 100.1 - shipment_line_id:'
2120           || l_rcpt_match_table_detail(match_result_count).shipment_line_id
2121         , 4);
2122         print_debug('Matching returned values 100.1 - transaction_quantity:'
2123           || l_rcpt_match_table_detail(match_result_count).quantity
2124         , 4);
2125         print_debug('Matching returned values 100.1 - transaction_uom:'
2126           || l_rcpt_match_table_detail(match_result_count).unit_of_measure
2127         , 4);
2128         print_debug('Matching returned values 100.1 - primary_quantity:'
2129           || l_rcpt_match_table_detail(match_result_count).primary_quantity
2130         , 4);
2131         print_debug(
2132           'Matching returned values 100.1 - primary_uom:' || l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure
2133         , 4
2134         );
2135       END IF;
2136 
2137       l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
2138 
2139       -- Get the transfer_cost_group_id from rcv_shipment_lines
2140       BEGIN
2141         SELECT cost_group_id
2142         INTO   l_rcv_transaction_rec.transfer_cost_group_id
2143         FROM   rcv_shipment_lines
2144         WHERE  shipment_line_id = l_rcv_transaction_rec.rcv_shipment_line_id;
2145       EXCEPTION
2146         WHEN OTHERS THEN
2147           IF (l_debug = 1) THEN
2148             print_debug('exception in getting transfer cost group id', 4);
2149           END IF;
2150 
2151           l_rcv_transaction_rec.transfer_cost_group_id := NULL;
2152       END;
2153 
2154       -- update following fields from matching algorithm return value
2155       l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
2156       l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
2157       --Bug 2073164
2158       l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
2159       l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
2160       l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
2161       l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2162       l_progress := '70';
2163 
2164       /* OPM Convergence we dont base matching logic on secondary uom and secondary quantity.
2165        * Instead we calculate the secondary qty based on the ratio on which primary qty is split.
2166        */
2167       l_progress := '70';
2168       l_rcv_transaction_rec.secondary_uom := p_rcv_sec_uom;
2169       print_debug('create_po_drct_dlvr_rti_rec: sec_uom ' || p_rcv_sec_uom);
2170       l_rcv_transaction_rec.secondary_uom_code := p_rcv_sec_uom_code;
2171       print_debug('create_po_drct_dlvr_rti_rec: sec_uom_code ' || p_rcv_sec_uom_code);
2172       l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) * p_secondary_rcv_qty;
2173       print_debug('secondary quantity after matching logic qty is obtained is ' ||l_rcv_transaction_rec.secondary_quantity);
2174 
2175       -- Nested LPN changes If FromLPN is not null and Patchset Level of INV,WMS,PO
2176       -- are at J then pass From_lpn_id as lpn_id otherwise use old code.
2177       --IF p_from_lpn_id IS NOT NULL
2178       IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
2179          AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
2180          AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
2181         l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
2182       ELSE
2183         l_rcv_transaction_rec.lpn_id := p_lpn_id;
2184       END IF;
2185 
2186       l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2187 
2188       IF p_country_code IS NOT NULL THEN
2189         l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
2190       END IF;
2191 
2192       --Bug #4147209 - Populate the record type with the DFF attribute category
2193       --and segment values passed from the mobile UI
2194       set_attribute_vals(
2195           p_rcv_rcpt_rec        =>  l_rcv_rcpt_rec
2196         , p_attribute_category  => p_attribute_category
2197         , p_attribute1          => p_attribute1
2198         , p_attribute2          => p_attribute2
2199         , p_attribute3          => p_attribute3
2200         , p_attribute4          => p_attribute4
2201         , p_attribute5          => p_attribute5
2202         , p_attribute6          => p_attribute6
2203         , p_attribute7          => p_attribute7
2204         , p_attribute8          => p_attribute8
2205         , p_attribute9          => p_attribute9
2206         , p_attribute10         => p_attribute10
2207         , p_attribute11         => p_attribute11
2208         , p_attribute12         => p_attribute12
2209         , p_attribute13         => p_attribute13
2210         , p_attribute14         => p_attribute14
2211         , p_attribute15         => p_attribute15);
2212 
2213       IF (l_debug = 1) THEN
2214         print_debug('create_int_shp_dr_del_rti_rec: 110 - before populate_default_values'
2215           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2216         , 4);
2217       END IF;
2218 
2219       populate_default_values(
2220         p_rcv_transaction_rec     => l_rcv_transaction_rec
2221       , p_rcv_rcpt_rec            => l_rcv_rcpt_rec
2222       , p_group_id                => l_group_id
2223       , p_organization_id         => p_organization_id
2224       , p_item_id                 => p_item_id
2225       , p_revision                => p_revision
2226       , p_source_type             => p_source_type
2227       , p_subinventory_code       => p_subinventory
2228       , p_locator_id              => p_locator_id
2229       , p_transaction_temp_id     => p_transaction_temp_id
2230       , p_lot_control_code        => p_lot_control_code
2231       , p_serial_control_code     => p_serial_control_code
2232       , p_project_id              => p_project_id
2233       , p_task_id                 => p_task_id
2234       );
2235 
2236 
2237       /* FP-J Lot/Serial Support Enhancement
2238        * Populate the table to store the information of the RTIs created used for
2239        * splitting the lots and serials based on RTI quantity
2240        */
2241       IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2242           (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2243         l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
2244         l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
2245         l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
2246         IF (l_debug = 1) THEN
2247           print_debug('create_int_shp_dr_del_rti_rec: 115 - Populated the table for lot/serial split', 4);
2248         END IF;
2249       END IF;   --END IF populate the table to store RTI info that was just created
2250 
2251       IF (l_debug = 1) THEN
2252         print_debug('create_int_shp_dr_del_rti_rec: 120 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2253         , 4);
2254       END IF;
2255 
2256       l_progress := '80';
2257 
2258       IF (l_debug = 1) THEN
2259         print_debug('create_int_shp_dr_del_rti_rec: 125 - before update_rcv_serials_supply'
2260           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2261         , 4);
2262       END IF;
2263 
2264       /* FP-J Lot/Serial Support Enhancement
2265        * No updates to rcv_serials_supply if INV J and PO J are installed
2266        */
2267       IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
2268         (inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po)) THEN
2269         IF l_rcv_rcpt_rec.req_line_id IS NOT NULL
2270            AND p_serial_control_code NOT IN(1, 6) THEN
2271           -- update rss for req
2272           inv_rcv_std_deliver_apis.update_rcv_serials_supply(
2273             x_return_status        => l_return_status
2274           , x_msg_count            => l_msg_count
2275           , x_msg_data             => x_message
2276           , p_shipment_line_id     => l_rcv_transaction_rec.rcv_shipment_line_id
2277           );
2278         END IF;
2279 
2280         IF (l_debug = 1) THEN
2281           print_debug('create_int_shp_dr_del_rti_rec: 127 - after update_rcv_serials_supply'
2282             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2283           , 4);
2284         END IF;
2285       END IF;   --END IF PO J and INV J installed
2286        IF NVL(p_lot_control_code ,1) = 2 AND l_lot_number IS NOT NULL THEN   -- for 13972742
2287            l_new_rti_info(match_result_count).lot_number := l_rcpt_match_table_detail(match_result_count).lot_number;
2288            l_new_rti_info(match_result_count).quantity := l_rcpt_match_table_detail(match_result_count).quantity;
2289              IF (l_debug = 1) THEN
2290        		 print_debug('l_new_rti_info(match_result_count).lot_number='|| l_new_rti_info(match_result_count).lot_number, 4);
2291              END IF;
2292       END IF;
2293     END LOOP;
2294 
2295     /* FP-J Lot/Serial Support Enhancement
2296      * Call the split_lot API to split the lots and serials inserted from the UI
2297      * based on the quantity of each RTI record
2298      */
2299     IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2300         (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2301       --BUG 3326408,3346758,3405320
2302       --If there are any serials confirmed from the UI for an item that is
2303       --lot controlled and serial control dynamic at SO issue,
2304       --do not NULL out serial_transaction_temp_id. In other cases,
2305       --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
2306       l_msni_count := 0;
2307       IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
2308           l_rcv_rcpt_rec.serial_number_control_code IN(1,6)) THEN
2309 	      IF (l_debug = 1) THEN
2310 	        print_debug('create_int_shp_dr_del_rti_rec 128.2: serial_control_code IS 6, need TO NULL OUT mtli', 4);
2311 	      END IF;
2312 	      BEGIN
2313           IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2314             SELECT count(1)
2315             INTO   l_msni_count
2316             FROM   mtl_serial_numbers_interface
2317             WHERE  product_transaction_id = p_transaction_temp_id
2318             AND    product_code = 'RCV';
2319           END IF;
2320           IF (l_msni_count = 0) THEN
2321             UPDATE mtl_transaction_lots_interface
2322 	          SET  serial_transaction_temp_id = NULL
2323 	          WHERE product_transaction_id = p_transaction_temp_id
2324 	          AND   product_code = 'RCV';
2325           END IF;
2326 	      EXCEPTION
2327 	        WHEN OTHERS THEN
2328 		        IF (l_debug = 1) THEN
2329 		          print_debug('create_int_shp_dr_del_rti_rec 128.4: Error nulling serial temp id OF MTLI', 4);
2330 		      END IF;
2331 	      END ;
2332       END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2333 
2334       l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2335               p_api_version   => 1.0
2336             , p_init_msg_lst  => FND_API.G_FALSE
2337             , x_return_status =>  l_return_status
2338             , x_msg_count     =>  l_msg_count
2339             , x_msg_data      =>  x_message
2340             , p_new_rti_info  =>  l_new_rti_info);
2341       IF ( NOT l_split_lot_serial_ok) THEN
2342         IF (l_debug = 1) THEN
2343           print_debug('create_int_shp_dr_del_rti_rec 129.1: Failure in split_lot_serial', 4);
2344         END IF;
2345         RAISE FND_API.G_EXC_ERROR;
2346       END IF;
2347 
2348       IF (l_debug = 1) THEN
2349         print_debug('create_int_shp_dr_del_rti_rec 128.2: Call split_lot_serial is OK', 4);
2350       END IF;
2351     END IF;   --END IF check INV J and PO J installed
2352     END LOOP; --- 13972742
2353 
2354     -- append index in input table where the line to be detailed needs to be inserted
2355     --inv_rcv_std_rcpt_apis.g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + inv_rcv_std_rcpt_apis.g_receipt_detail_index;
2356     l_progress := '90';
2357     inv_rcv_common_apis.do_check(
2358       p_organization_id         => p_organization_id
2359     , p_inventory_item_id       => p_item_id
2360     , p_transaction_type_id     => 61
2361     , p_primary_quantity        => l_total_primary_qty
2362     , x_return_status           => l_return_status
2363     , x_msg_count               => l_msg_count
2364     , x_msg_data                => x_message
2365     );
2366 
2367     IF l_return_status <> fnd_api.g_ret_sts_success THEN
2368       x_status := l_return_status;
2369     END IF;
2370 
2371     l_progress := '100';
2372     -- Clear the Lot Rec
2373     inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
2374 
2375     IF (l_debug = 1) THEN
2376       print_debug('About exit create_int_shp_dr_del_rti_rec: 130 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2377     END IF;
2378   EXCEPTION
2379     WHEN fnd_api.g_exc_error THEN
2380       ROLLBACK TO crt_intship_rti_sp;
2381       x_status := fnd_api.g_ret_sts_error;
2382 
2383       IF l_curs_rcpt_detail%ISOPEN THEN
2384         CLOSE l_curs_rcpt_detail;
2385       END IF;
2386 
2387       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2388 
2389       IF (l_debug = 1) THEN
2390         print_debug('create_int_shp_dr_del_rti_rec:  FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2391       END IF;
2392     WHEN fnd_api.g_exc_unexpected_error THEN
2393       ROLLBACK TO crt_intship_rti_sp;
2394       x_status := fnd_api.g_ret_sts_unexp_error;
2395 
2396       IF l_curs_rcpt_detail%ISOPEN THEN
2397         CLOSE l_curs_rcpt_detail;
2398       END IF;
2399 
2400       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2401 
2402       IF (l_debug = 1) THEN
2403         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);
2404       END IF;
2405     WHEN OTHERS THEN
2406       ROLLBACK TO crt_intship_rti_sp;
2407       x_status := fnd_api.g_ret_sts_unexp_error;
2408 
2409       IF l_curs_rcpt_detail%ISOPEN THEN
2410         CLOSE l_curs_rcpt_detail;
2411       END IF;
2412 
2413       IF SQLCODE IS NOT NULL THEN
2414         inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_int_shp_dr_del_rti_rec', l_progress, SQLCODE);
2415       END IF;
2416 
2417       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
2418   END create_int_shp_dr_del_rti_rec;
2419 
2420   PROCEDURE create_rma_drct_dlvr_rti_rec(
2421     p_move_order_header_id  IN OUT NOCOPY  NUMBER
2422   , p_organization_id       IN             NUMBER
2423   , p_oe_order_header_id    IN             NUMBER
2424   , p_oe_order_line_id      IN             NUMBER
2425   , p_item_id               IN             NUMBER
2426   , p_rcv_qty               IN             NUMBER
2427   , p_rcv_uom               IN             VARCHAR2
2428   , p_rcv_uom_code          IN             VARCHAR2
2429   , p_source_type           IN             VARCHAR2
2430   , p_subinventory                         VARCHAR2
2431   , p_locator_id                           NUMBER
2432   , p_transaction_temp_id   IN             NUMBER
2433   , p_lot_control_code      IN             NUMBER
2434   , p_serial_control_code   IN             NUMBER
2435   , p_lpn_id                IN             NUMBER
2436   , p_revision              IN             VARCHAR2
2437   , x_status                OUT NOCOPY     VARCHAR2
2438   , x_message               OUT NOCOPY     VARCHAR2
2439   , p_project_id            IN             NUMBER
2440   , p_task_id               IN             NUMBER
2441   , p_country_code          IN             VARCHAR2 DEFAULT NULL
2442   , p_secondary_rcv_qty     IN             NUMBER DEFAULT NULL  --OPM Convergence
2443   , p_rcv_sec_uom           IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
2444   , p_rcv_sec_uom_code      IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
2445   , p_attribute_category    IN             VARCHAR2  DEFAULT NULL  --Bug #4147209 - DFF cols
2446   , p_attribute1            IN             VARCHAR2  DEFAULT NULL
2447   , p_attribute2            IN             VARCHAR2  DEFAULT NULL
2448   , p_attribute3            IN             VARCHAR2  DEFAULT NULL
2449   , p_attribute4            IN             VARCHAR2  DEFAULT NULL
2450   , p_attribute5            IN             VARCHAR2  DEFAULT NULL
2451   , p_attribute6            IN             VARCHAR2  DEFAULT NULL
2452   , p_attribute7            IN             VARCHAR2  DEFAULT NULL
2453   , p_attribute8            IN             VARCHAR2  DEFAULT NULL
2454   , p_attribute9            IN             VARCHAR2  DEFAULT NULL
2455   , p_attribute10           IN             VARCHAR2  DEFAULT NULL
2456   , p_attribute11           IN             VARCHAR2  DEFAULT NULL
2457   , p_attribute12           IN             VARCHAR2  DEFAULT NULL
2458   , p_attribute13           IN             VARCHAR2  DEFAULT NULL
2459   , p_attribute14           IN             VARCHAR2  DEFAULT NULL
2460   , p_attribute15           IN             VARCHAR2  DEFAULT NULL
2461   ) IS
2462     l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
2463     l_rcv_transaction_rec     inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
2464     l_transaction_type        VARCHAR2(20) := 'DELIVER';
2465     l_total_primary_qty       NUMBER       := 0;
2466     l_msg_count               NUMBER;
2467     l_return_status           VARCHAR2(1)  := fnd_api.g_ret_sts_success;
2468     l_group_id                NUMBER;
2469     l_rcv_rcpt_rec            inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
2470     l_mmtt_rec                mtl_material_transactions_temp%ROWTYPE;
2471     l_err_message             VARCHAR2(100);
2472     l_temp_message            VARCHAR2(100);
2473     l_msg_prod                VARCHAR2(5);
2474     l_progress                VARCHAR2(10);
2475 
2476     CURSOR l_curs_rcpt_detail(v_oe_order_line_id NUMBER) IS
2477       SELECT 'N' line_chkbox
2478            , 'CUSTOMER' source_type_code
2479            , 'CUSTOMER' receipt_source_code
2480            , '' order_type_code
2481            , '' order_type
2482            , TO_NUMBER(NULL) po_header_id
2483            , NULL po_number
2484            , TO_NUMBER(NULL) po_line_id
2485            , TO_NUMBER(NULL) po_line_number
2486            , TO_NUMBER(NULL) po_line_location_id
2487            , TO_NUMBER(NULL) po_shipment_number
2488            , TO_NUMBER(NULL) po_release_id
2489            , TO_NUMBER(NULL) po_release_number
2490            , TO_NUMBER(NULL) req_header_id
2491            , NULL req_number
2492            , TO_NUMBER(NULL) req_line_id
2493            , TO_NUMBER(NULL) req_line
2494            , TO_NUMBER(NULL) req_distribution_id
2495            , TO_NUMBER(NULL) rcv_shipment_header_id
2496            , NULL rcv_shipment_number
2497            , TO_NUMBER(NULL) rcv_shipment_line_id
2498            , TO_NUMBER(NULL) rcv_line_number
2499            , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) from_organization_id
2500            , NVL(oel.ship_from_org_id, oeh.ship_from_org_id) to_organization_id
2501            , TO_NUMBER(NULL) vendor_id
2502            , '' SOURCE
2503            , TO_NUMBER(NULL) vendor_site_id
2504            , NULL outside_operation_flag
2505            , oel.inventory_item_id item_id
2506            , -- Bug 2073164
2507              NULL uom_code
2508            , mum.unit_of_measure primary_uom
2509            , mum.uom_class primary_uom_class
2510            , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
2511            , NVL(msi.location_control_code, 1) item_locator_control
2512            , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
2513            , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
2514            , NVL(msi.shelf_life_code, 1) shelf_life_code
2515            , NVL(msi.shelf_life_days, 0) shelf_life_days
2516            , msi.serial_number_control_code serial_number_control_code
2517            , msi.lot_control_code lot_control_code
2518            , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
2519            , NULL item_rev_control_flag_from
2520            , msi.segment1 item_number
2521            , oel.item_revision item_revision
2522            , msi.description item_description
2523            , TO_NUMBER(NULL) item_category_id
2524            , NULL hazard_class
2525            , NULL un_number
2526            , NULL vendor_item_number
2527            , oel.ship_from_org_id ship_to_location_id
2528            , '' ship_to_location
2529            , NULL packing_slip
2530            , TO_NUMBER(NULL) routing_id
2531            , NULL routing_name
2532            , oel.request_date need_by_date
2533            , NVL(oel.promise_date, oel.request_date) expected_receipt_date
2534            , oel.ordered_quantity ordered_qty
2535            , '' ordered_uom
2536            , NULL ussgl_transaction_code
2537            , NULL government_context
2538            , DECODE(msi.return_inspection_requirement, 1, 'Y', 'N') inspection_required_flag--bug 4700067
2539            , 'Y' receipt_required_flag
2540            , 'N' enforce_ship_to_location_code
2541            , oel.unit_selling_price unit_price
2542            , oeh.transactional_curr_code currency_code
2543            , oeh.conversion_type_code currency_conversion_type
2544            , oeh.conversion_rate_date currency_conversion_date
2545            , oeh.conversion_rate currency_conversion_rate
2546            , NULL note_to_receiver
2547            , NULL destination_type_code
2548            , oel.deliver_to_contact_id deliver_to_person_id
2549            , oel.deliver_to_org_id deliver_to_location_id
2550            , NULL destination_subinventory
2551            , oel.CONTEXT attribute_category
2552            , oel.attribute1 attribute1
2553            , oel.attribute2 attribute2
2554            , oel.attribute3 attribute3
2555            , oel.attribute4 attribute4
2556            , oel.attribute5 attribute5
2557            , oel.attribute6 attribute6
2558            , oel.attribute7 attribute7
2559            , oel.attribute8 attribute8
2560            , oel.attribute9 attribute9
2561            , oel.attribute10 attribute10
2562            , oel.attribute11 attribute11
2563            , oel.attribute12 attribute12
2564            , oel.attribute13 attribute13
2565            , oel.attribute14 attribute14
2566            , oel.attribute15 attribute15
2567            , NULL closed_code
2568            , NULL asn_type
2569            , NULL bill_of_lading
2570            , TO_DATE(NULL) shipped_date
2571            , NULL freight_carrier_code
2572            , NULL waybill_airbill_num
2573            , NULL freight_bill_num
2574            , NULL vendor_lot_num
2575            , NULL container_num
2576            , NULL truck_num
2577            , NULL bar_code_label
2578            , NULL rate_type_display
2579            , NULL match_option
2580            , NULL country_of_origin_code
2581            , oel.header_id oe_order_header_id
2582            , oeh.order_number oe_order_num
2583            , oel.line_id oe_order_line_id
2584            , oel.line_number oe_order_line_num
2585            , oel.sold_to_org_id customer_id
2586            , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) customer_site_id
2587            , '' customer_item_num
2588            , '' pll_note_to_receiver
2589            , NULL po_distribution_id
2590            , NULL qty_ordered
2591            , NULL wip_entity_id
2592            , NULL wip_operation_seq_num
2593            , NULL wip_resource_seq_num
2594            , NULL wip_repetitive_schedule_id
2595            , NULL wip_line_id
2596            , NULL bom_resource_id
2597            , '' destination_type
2598            , '' LOCATION
2599            , NULL currency_conversion_rate_pod
2600            , NULL currency_conversion_date_pod
2601            , NULL project_id
2602            , NULL task_id
2603            , NULL secondary_uom --OPM Convergence
2604            , NULL secondary_uom_code --OPM Convergence
2605            , NULL secondary_quantity --OPM Convergence
2606       FROM   oe_order_lines_all oel
2607            , oe_order_headers_all oeh
2608            , mtl_system_items msi
2609            , mtl_units_of_measure mum
2610       WHERE  oel.line_category_code = 'RETURN'
2611       AND    oel.header_id = oeh.header_id
2612       AND    oel.inventory_item_id = msi.inventory_item_id
2613       AND    oel.ship_from_org_id = msi.organization_id
2614       AND    msi.primary_uom_code = mum.uom_code
2615       AND    oel.booked_flag = 'Y'
2616       AND    oel.ordered_quantity > NVL(oel.shipped_quantity, 0)
2617       AND    msi.mtl_transactions_enabled_flag = 'Y'
2618       AND    oel.line_id = v_oe_order_line_id
2619       AND    (p_project_id IS NULL
2620               OR(p_project_id = -9999
2621                  AND oel.project_id IS NULL)
2622               OR -- bug 2669021
2623                  oel.project_id = p_project_id)
2624       AND    (p_task_id IS NULL
2625               OR oel.task_id = p_task_id);
2626 
2627     l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2628     --table to store all RTId, quantity and original_rti_id for lot/serial splits
2629     l_new_rti_info         inv_rcv_integration_apis.child_rec_tb_tp;
2630     l_split_lot_serial_ok  BOOLEAN;   --Return status of lot_serial_split API
2631   BEGIN
2632     x_status := fnd_api.g_ret_sts_success;
2633 
2634     IF (l_debug = 1) THEN
2635       print_debug('Enter create_rma_drct_dlvr_rti_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2636     END IF;
2637 
2638     l_progress := '10';
2639     SAVEPOINT crt_rma_rti_sp;
2640 
2641     -- query po_startup_value
2642     BEGIN
2643       inv_rcv_common_apis.init_startup_values(p_organization_id);
2644     EXCEPTION
2645       WHEN NO_DATA_FOUND THEN
2646         fnd_message.set_name('INV', 'INV_RCV_PARAM');
2647         fnd_msg_pub.ADD;
2648         RAISE;
2649     END;
2650 
2651     l_progress := '20';
2652 
2653     -- default l_group_id ? clear group id after done
2654     IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
2655       SELECT rcv_interface_groups_s.NEXTVAL
2656       INTO   l_group_id
2657       FROM   DUAL;
2658 
2659       inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
2660 
2661       IF (l_debug = 1) THEN
2662         print_debug('create_rma_drct_dlvr_rti_rec: 2.1 - group_id created: ' || l_group_id, 4);
2663       END IF;
2664     ELSE
2665       l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
2666 
2667       IF (l_debug = 1) THEN
2668         print_debug('create_rma_drct_dlvr_rti_rec: 2.2 - group_id stored already: ' || l_group_id, 4);
2669       END IF;
2670     END IF;
2671 
2672     -- initialize input record for matching algorithm
2673     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
2674     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
2675     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;
2676     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
2677     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
2678     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).to_organization_id :=
2679                                                                                                                    p_organization_id;
2680     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).oe_order_header_id :=
2681                                                                                                                 p_oe_order_header_id;
2682     -- line id will be passed only from the putaway api.
2683     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).oe_order_line_id :=
2684                                                                                                                   p_oe_order_line_id;
2685     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
2686     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
2687 
2688     BEGIN
2689       SELECT primary_unit_of_measure
2690       INTO   inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
2691       FROM   mtl_system_items
2692       WHERE  mtl_system_items.inventory_item_id = p_item_id
2693       AND    mtl_system_items.organization_id = p_organization_id;
2694     EXCEPTION
2695       WHEN NO_DATA_FOUND THEN
2696         IF (l_debug = 1) THEN
2697           print_debug('create_rma_drct_dlvr_rti_rec: 3 - get primary_unit_of_measure exception', 4);
2698         END IF;
2699     END;
2700 
2701     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
2702     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
2703     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
2704     l_progress := '40';
2705 
2706     IF (l_debug = 1) THEN
2707       print_debug(
2708         'create_rma_drct_dlvr_rti_rec: 4 - before inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2709       , 4
2710       );
2711     END IF;
2712 
2713     inv_rcv_txn_match.matching_logic(
2714       x_return_status         => x_status
2715     , --?
2716       x_msg_count             => l_msg_count
2717     , x_msg_data              => x_message
2718     , x_cascaded_table        => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
2719     , n                       => inv_rcv_std_rcpt_apis.g_receipt_detail_index
2720     , temp_cascaded_table     => l_rcpt_match_table_detail
2721     , p_receipt_num           => NULL
2722     , p_match_type            => 'RMA'
2723     , p_lpn_id                => NULL
2724     );
2725 
2726     IF (l_debug = 1) THEN
2727       print_debug(
2728         'create_rma_drct_dlvr_rti_rec: 4  - after inv_rcv_txn_interface.matching_logic' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2729       , 4
2730       );
2731       print_debug('create_rma_drct_dlvr_rti_rec: 4.1 - after matching  l_return_status = ' || x_status, 4);
2732       print_debug('create_rma_drct_dlvr_rti_rec: 4.2 - after matching  l_msg_count = ' || l_msg_count, 4);
2733       print_debug('create_rma_drct_dlvr_rti_rec: 4.3 - after matching  l_msg_data = ' || x_message, 4);
2734     END IF;
2735 
2736     -- x_status is not successful if there is any execution error in matching.
2737     IF x_status = fnd_api.g_ret_sts_error THEN
2738       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2739       fnd_msg_pub.ADD;
2740 
2741       IF (l_debug = 1) THEN
2742         print_debug('create_rma_drct_dlvr_rti_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2743       END IF;
2744 
2745       RAISE fnd_api.g_exc_error;
2746     END IF;
2747 
2748     IF x_status = fnd_api.g_ret_sts_unexp_error THEN
2749       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2750       fnd_msg_pub.ADD;
2751 
2752       IF (l_debug = 1) THEN
2753         print_debug('create_rma_drct_dlvr_rti_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2754         , 1);
2755       END IF;
2756 
2757       RAISE fnd_api.g_exc_unexpected_error;
2758     END IF;
2759 
2760     IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
2761       l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
2762       fnd_message.set_name('INV', l_err_message);
2763       fnd_msg_pub.ADD;
2764 
2765       IF (l_debug = 1) THEN
2766         print_debug('create_rma_drct_dlvr_rti_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2767       END IF;
2768 
2769       RAISE fnd_api.g_exc_error;
2770     END IF;
2771 
2772     l_err_message := '@@@';
2773 
2774     FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
2775                                                                inv_rcv_std_rcpt_apis.g_receipt_detail_index
2776                                                              + l_rcpt_match_table_detail.COUNT
2777                                                              - 1
2778                                                             ) LOOP
2779       IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
2780         x_status := 'W';
2781         l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
2782 
2783         IF l_temp_message IS NULL THEN
2784           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2785           l_msg_prod := 'INV';
2786           EXIT;
2787         END IF;
2788 
2789         IF l_err_message = '@@@' THEN
2790           l_err_message := l_temp_message;
2791           l_msg_prod := 'INV';
2792         ELSIF l_temp_message <> l_err_message THEN
2793           l_msg_prod := 'INV';
2794           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2795           EXIT;
2796         END IF;
2797       END IF;
2798     END LOOP;
2799 
2800     IF l_err_message <> '@@@' THEN
2801       fnd_message.set_name(l_msg_prod, l_err_message);
2802       fnd_msg_pub.ADD;
2803 
2804       IF (l_debug = 1) THEN
2805         print_debug('create_rma_drct_dlvr_rti_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2806       END IF;
2807     END IF;
2808 
2809     -- based on return from matching algorithm,
2810     -- determine which line in rcv_transaction block to be inserted into RTI
2811 
2812     IF (l_debug = 1) THEN
2813       print_debug('create_rma_drct_dlvr_rti_rec: 6 - start loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2814     END IF;
2815 
2816     -- loop through results returned by matching algorithm
2817     l_progress := '60';
2818 
2819     FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
2820       l_progress := '62';
2821       OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).oe_order_line_id);
2822       l_progress := '64';
2823       FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
2824       l_progress := '66';
2825       CLOSE l_curs_rcpt_detail;
2826       l_progress := '68';
2827 
2828       IF (l_debug = 1) THEN
2829         print_debug('create_int_shp_dr_del_rti_rec found a match 60', 4);
2830         print_debug('Matching returned values 60.1 - oe_order_line_id:'
2831           || l_rcpt_match_table_detail(match_result_count).oe_order_line_id
2832         , 4);
2833         print_debug('Matching returned values 60.1 - transaction_quantity:'
2834           || l_rcpt_match_table_detail(match_result_count).quantity
2835         , 4);
2836         print_debug('Matching returned values 60.1 - transaction_uom:'
2837           || l_rcpt_match_table_detail(match_result_count).unit_of_measure
2838         , 4);
2839         print_debug('Matching returned values 60.1 - primary_quantity:'
2840           || l_rcpt_match_table_detail(match_result_count).primary_quantity
2841         , 4);
2842         print_debug(
2843           'Matching returned values 60.1 - primary_uom:' || l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure
2844         , 4
2845         );
2846       END IF;
2847 
2848       l_rcv_transaction_rec.oe_order_line_id := l_rcpt_match_table_detail(match_result_count).oe_order_line_id;
2849       -- update following fields from matching algorithm return value
2850       l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
2851       l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
2852       --Bug 2073164
2853       l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
2854       l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
2855       l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
2856       l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2857       l_progress := '70';
2858 
2859       IF (l_debug = 1) THEN
2860          print_debug('In create_rma_drct_dlvr_rti_rec 7.1: p_rcv_qty'|| p_rcv_qty, 1);
2861          print_debug('In create_rma_drct_dlvr_rti_rec 7.2: l_rcpt_match_table_detail(match_result_count).quantity'|| l_rcpt_match_table_detail(match_result_count).quantity, 1);
2862          print_debug('In create_rma_drct_dlvr_rti_rec 7.3: p_secondary_rcv_qty'|| p_secondary_rcv_qty, 1);
2863          print_debug('In create_rma_drct_dlvr_rti_rec 7.4: p_rcv_sec_uom'|| p_rcv_sec_uom, 1);
2864          print_debug('In create_rma_drct_dlvr_rti_rec 7.5: p_rcv_sec_uom_code'|| p_rcv_sec_uom_code, 1);
2865       END IF;
2866 
2867       -- Forward port Bug 7604079
2868       -- Assign secondary quantity and uoms.
2869       l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) *  p_secondary_rcv_qty;
2870       l_rcv_transaction_rec.secondary_uom := p_rcv_sec_uom;
2871       l_rcv_transaction_rec.secondary_uom_code := p_rcv_sec_uom_code;
2872 
2873       IF (l_debug = 1) THEN
2874          print_debug('In create_rma_drct_dlvr_rti_rec 7.6: l_rcv_transaction_rec.secondary_quantity'|| l_rcv_transaction_rec.secondary_quantity, 1);
2875       END IF;
2876 
2877       -- Nested LPN changes. Populate p_lpn_id as NULL for patchset J and above
2878       IF inv_rcv_common_apis.g_po_patch_level  < inv_rcv_common_apis.g_patchset_j_po OR
2879          inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j OR
2880          inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
2881 
2882          l_rcv_transaction_rec.lpn_id := p_lpn_id;
2883          l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2884       ELSE
2885         l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2886       END IF;
2887 
2888 
2889       IF p_country_code IS NOT NULL THEN
2890         l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
2891       END IF;
2892 
2893       --Bug #4147209 - Populate the record type with the DFF attribute category
2894       --and segment values passed from the mobile UI
2895       set_attribute_vals(
2896           p_rcv_rcpt_rec        =>  l_rcv_rcpt_rec
2897         , p_attribute_category  => p_attribute_category
2898         , p_attribute1          => p_attribute1
2899         , p_attribute2          => p_attribute2
2900         , p_attribute3          => p_attribute3
2901         , p_attribute4          => p_attribute4
2902         , p_attribute5          => p_attribute5
2903         , p_attribute6          => p_attribute6
2904         , p_attribute7          => p_attribute7
2905         , p_attribute8          => p_attribute8
2906         , p_attribute9          => p_attribute9
2907         , p_attribute10         => p_attribute10
2908         , p_attribute11         => p_attribute11
2909         , p_attribute12         => p_attribute12
2910         , p_attribute13         => p_attribute13
2911         , p_attribute14         => p_attribute14
2912         , p_attribute15         => p_attribute15);
2913 
2914       IF (l_debug = 1) THEN
2915         print_debug('create_rma_drct_dlvr_rti_rec: 8 - before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2916         , 4);
2917       END IF;
2918 
2919       populate_default_values(
2920         p_rcv_transaction_rec     => l_rcv_transaction_rec
2921       , p_rcv_rcpt_rec            => l_rcv_rcpt_rec
2922       , p_group_id                => l_group_id
2923       , p_organization_id         => p_organization_id
2924       , p_item_id                 => p_item_id
2925       , p_revision                => p_revision
2926       , p_source_type             => p_source_type
2927       , p_subinventory_code       => p_subinventory
2928       , p_locator_id              => p_locator_id
2929       , p_transaction_temp_id     => p_transaction_temp_id
2930       , p_lot_control_code        => p_lot_control_code
2931       , p_serial_control_code     => p_serial_control_code
2932       , p_project_id              => p_project_id
2933       , p_task_id                 => p_task_id
2934       );
2935 
2936 
2937       /* FP-J Lot/Serial Support Enhancement
2938        * Populate the table to store the information of the RTIs created used for
2939        * splitting the lots and serials based on RTI quantity
2940        */
2941       IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2942           (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2943         l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
2944         l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
2945         l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
2946         IF (l_debug = 1) THEN
2947           print_debug('create_rma_drct_dlvr_rti_rec: 115 - Populated the table for lot/serial split', 4);
2948         END IF;
2949       END IF;   --END IF populate the table to store RTI info that was just created
2950 
2951       IF (l_debug = 1) THEN
2952         print_debug('create_rma_drct_dlvr_rti_rec: 9 - after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2953         , 4);
2954       END IF;
2955 
2956       l_progress := '80';
2957     END LOOP;
2958 
2959     /* FP-J Lot/Serial Support Enhancement
2960      * Call the split_lot API to split the lots and serials inserted from the UI
2961      * based on the quantity of each RTI record
2962      */
2963     IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
2964         (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
2965 
2966        l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2967               p_api_version   => 1.0
2968             , p_init_msg_lst  => FND_API.G_FALSE
2969             , x_return_status =>  l_return_status
2970             , x_msg_count     =>  l_msg_count
2971             , x_msg_data      =>  x_message
2972             , p_new_rti_info  =>  l_new_rti_info);
2973       IF ( NOT l_split_lot_serial_ok) THEN
2974         IF (l_debug = 1) THEN
2975           print_debug('create_rma_drct_dlvr_rti_rec 9.1: Failure in split_lot_serial', 4);
2976         END IF;
2977         RAISE FND_API.G_EXC_ERROR;
2978       END IF;
2979 
2980       IF (l_debug = 1) THEN
2981         print_debug('create_rma_drct_dlvr_rti_rec 9.2: Call split_lot_serial is OK', 4);
2982       END IF;
2983     END IF;   --END IF check INV J and PO J installed
2984 
2985     -- append index in input table where the line to be detailed needs to be inserted
2986     --inv_rcv_std_rcpt_apis.g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + inv_rcv_std_rcpt_apis.g_receipt_detail_index;
2987 
2988     l_progress := '90';
2989     inv_rcv_common_apis.do_check(
2990       p_organization_id         => p_organization_id
2991     , p_inventory_item_id       => p_item_id
2992     , p_transaction_type_id     => 15
2993     , p_primary_quantity        => l_total_primary_qty
2994     , x_return_status           => l_return_status
2995     , x_msg_count               => l_msg_count
2996     , x_msg_data                => x_message
2997     );
2998 
2999     IF l_return_status <> fnd_api.g_ret_sts_success THEN
3000       x_status := l_return_status;
3001     END IF;
3002 
3003     l_progress := '100';
3004     -- Clear the Lot Rec
3005     inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
3006 
3007     IF (l_debug = 1) THEN
3008       print_debug('About exit create_rma_drct_dlvr_rti_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3009     END IF;
3010   EXCEPTION
3011     WHEN fnd_api.g_exc_error THEN
3012       ROLLBACK TO crt_rma_rti_sp;
3013       x_status := fnd_api.g_ret_sts_error;
3014 
3015       IF l_curs_rcpt_detail%ISOPEN THEN
3016         CLOSE l_curs_rcpt_detail;
3017       END IF;
3018 
3019       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3020 
3021       IF (l_debug = 1) THEN
3022         print_debug('create_rma_drct_dlvr_rti_rec:  FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3023       END IF;
3024     WHEN fnd_api.g_exc_unexpected_error THEN
3025       ROLLBACK TO crt_rma_rti_sp;
3026       x_status := fnd_api.g_ret_sts_unexp_error;
3027 
3028       IF l_curs_rcpt_detail%ISOPEN THEN
3029         CLOSE l_curs_rcpt_detail;
3030       END IF;
3031 
3032       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3033 
3034       IF (l_debug = 1) THEN
3035         print_debug('create_rma_drct_dlvr_rti_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3036       END IF;
3037     WHEN OTHERS THEN
3038       ROLLBACK TO crt_rma_rti_sp;
3039       x_status := fnd_api.g_ret_sts_unexp_error;
3040 
3041       IF l_curs_rcpt_detail%ISOPEN THEN
3042         CLOSE l_curs_rcpt_detail;
3043       END IF;
3044 
3045       IF SQLCODE IS NOT NULL THEN
3046         inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_rma_drct_dlvr_rti_rec', l_progress, SQLCODE);
3047       END IF;
3048 
3049       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
3050   END create_rma_drct_dlvr_rti_rec;
3051 
3052   PROCEDURE create_asn_con_dd_intf_rec(
3053     p_move_order_header_id  IN OUT NOCOPY  NUMBER
3054   , p_organization_id       IN             NUMBER
3055   , p_shipment_header_id    IN             NUMBER
3056   , p_po_header_id          IN             NUMBER
3057   , p_item_id               IN             NUMBER
3058   , p_rcv_qty               IN             NUMBER
3059   , p_rcv_uom               IN             VARCHAR2
3060   , p_rcv_uom_code          IN             VARCHAR2
3061   , p_source_type           IN             VARCHAR2
3062   , p_subinventory                         VARCHAR2
3063   , p_locator_id                           NUMBER
3064   , p_from_lpn_id           IN             NUMBER
3065   , p_lpn_id                IN             NUMBER
3066   , p_lot_control_code      IN             NUMBER
3067   , p_serial_control_code   IN             NUMBER
3068   , p_revision              IN             VARCHAR2
3069   , p_transaction_temp_id   IN             NUMBER
3070   , x_status                OUT NOCOPY     VARCHAR2
3071   , x_message               OUT NOCOPY     VARCHAR2
3072   , p_project_id            IN             NUMBER
3073   , p_task_id               IN             NUMBER
3074   , p_country_code          IN             VARCHAR2 DEFAULT NULL
3075   , p_item_desc             IN             VARCHAR2 DEFAULT NULL
3076   , p_secondary_rcv_qty     IN             NUMBER DEFAULT NULL  --OPM Convergence
3077   , p_rcv_sec_uom           IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
3078   , p_rcv_sec_uom_code      IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
3079   , p_attribute_category    IN             VARCHAR2  DEFAULT NULL  --Bug #4147209 - DFF cols
3080   , p_attribute1            IN             VARCHAR2  DEFAULT NULL
3081   , p_attribute2            IN             VARCHAR2  DEFAULT NULL
3082   , p_attribute3            IN             VARCHAR2  DEFAULT NULL
3083   , p_attribute4            IN             VARCHAR2  DEFAULT NULL
3084   , p_attribute5            IN             VARCHAR2  DEFAULT NULL
3085   , p_attribute6            IN             VARCHAR2  DEFAULT NULL
3086   , p_attribute7            IN             VARCHAR2  DEFAULT NULL
3087   , p_attribute8            IN             VARCHAR2  DEFAULT NULL
3088   , p_attribute9            IN             VARCHAR2  DEFAULT NULL
3089   , p_attribute10           IN             VARCHAR2  DEFAULT NULL
3090   , p_attribute11           IN             VARCHAR2  DEFAULT NULL
3091   , p_attribute12           IN             VARCHAR2  DEFAULT NULL
3092   , p_attribute13           IN             VARCHAR2  DEFAULT NULL
3093   , p_attribute14           IN             VARCHAR2  DEFAULT NULL
3094   , p_attribute15           IN             VARCHAR2  DEFAULT NULL
3095   , p_express_transaction   IN             VARCHAR2  DEFAULT NULL--Bug 5550783
3096   , p_location_id           IN             NUMBER    DEFAULT NULL  --Bug 13490287
3097   ) IS
3098     l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
3099     l_rcv_transaction_rec     inv_rcv_std_rcpt_apis.rcv_transaction_rec_tp; -- rcv_transaction block
3100     l_transaction_type        VARCHAR2(20) := 'DELIVER';
3101     l_total_primary_qty       NUMBER       := 0;
3102     l_match_type              VARCHAR2(20);
3103     l_msg_count               NUMBER;
3104     l_msg_data                VARCHAR2(400);
3105     l_return_status           VARCHAR2(1)  := fnd_api.g_ret_sts_success;
3106     l_group_id                NUMBER;
3107     l_rcv_rcpt_rec            inv_rcv_std_rcpt_apis.rcv_enter_receipts_rec_tp;
3108     l_mmtt_rec                mtl_material_transactions_temp%ROWTYPE;
3109     l_err_message             VARCHAR2(100);
3110     l_temp_message            VARCHAR2(100);
3111     l_msg_prod                VARCHAR2(5);
3112     l_progress                VARCHAR2(10);
3113     l_receipt_num             VARCHAR2(30);
3114     l_lpn_id                  NUMBER := p_lpn_id;
3115 
3116     CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER, v_po_distribution_id NUMBER) IS
3117       SELECT 'N' line_chkbox
3118            , p_source_type source_type_code
3119            , 'VENDOR' receipt_source_code
3120            , 'PO' order_type_code
3121            , '' order_type
3122            , poll.po_header_id po_header_id
3123            , poh.segment1 po_number
3124            , poll.po_line_id po_line_id
3125            , pol.line_num po_line_number
3126            , poll.line_location_id po_line_location_id
3127            , poll.shipment_num po_shipment_number
3128            , poll.po_release_id po_release_id
3129            , por.release_num po_release_number
3130            , TO_NUMBER(NULL) req_header_id
3131            , NULL req_number
3132            , TO_NUMBER(NULL) req_line_id
3133            , TO_NUMBER(NULL) req_line
3134            , TO_NUMBER(NULL) req_distribution_id
3135            , rsh.shipment_header_id rcv_shipment_header_id
3136            , rsh.shipment_num rcv_shipment_number
3137            , rsl.shipment_line_id rcv_shipment_line_id
3138            , rsl.line_num rcv_line_number
3139            , rsl.from_organization_id from_organization_id  --Bug #3878174
3140 /*
3141            , NVL(rsl.from_organization_id, poh.po_header_id) from_organization_id
3142 */
3143            , rsl.to_organization_id to_organization_id
3144            , rsh.vendor_id vendor_id
3145            , '' SOURCE
3146            , poh.vendor_site_id vendor_site_id -- Bug 6403165
3147            , '' outside_operation_flag
3148            , rsl.item_id item_id
3149            , -- Bug 2073164
3150              NULL uom_code
3151            , rsl.unit_of_measure primary_uom
3152            , mum.uom_class primary_uom_class
3153            , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
3154            , NVL(msi.location_control_code, 1) item_locator_control
3155            , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
3156            , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
3157            , NVL(msi.shelf_life_code, 1) shelf_life_code
3158            , NVL(msi.shelf_life_days, 0) shelf_life_days
3159            , msi.serial_number_control_code serial_number_control_code
3160            , msi.lot_control_code lot_control_code
3161            , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
3162            , NULL item_rev_control_flag_from
3163            , NULL item_number
3164            , rsl.item_revision item_revision
3165            , rsl.item_description item_description
3166            , rsl.category_id item_category_id
3167            , '' hazard_class
3168            , '' un_number
3169            , rsl.vendor_item_num vendor_item_number
3170            , rsl.ship_to_location_id ship_to_location_id
3171            , '' ship_to_location
3172            , rsl.packing_slip packing_slip
3173            , rsl.routing_header_id routing_id
3174            , '' routing_name
3175            , poll.need_by_date need_by_date
3176            , rsh.expected_receipt_date expected_receipt_date
3177            , poll.quantity ordered_qty
3178            , pol.unit_meas_lookup_code ordered_uom
3179            , rsl.ussgl_transaction_code ussgl_transaction_code
3180            , rsl.government_context government_context
3181            , poll.inspection_required_flag inspection_required_flag
3182            , poll.receipt_required_flag receipt_required_flag
3183            , poll.enforce_ship_to_location_code enforce_ship_to_location_code
3184            , NVL(poll.price_override, pol.unit_price) unit_price
3185            , poh.currency_code currency_code
3186            , poh.rate_type currency_conversion_type
3187            , poh.rate_date currency_conversion_date
3188            , poh.rate currency_conversion_rate
3189            , poh.note_to_receiver note_to_receiver
3190            , pod.destination_type_code destination_type_code
3191            , pod.deliver_to_person_id deliver_to_person_id
3192            , pod.deliver_to_location_id deliver_to_location_id
3193            , pod.destination_subinventory destination_subinventory
3194            , rsl.attribute_category attribute_category
3195            , rsl.attribute1 attribute1
3196            , rsl.attribute2 attribute2
3197            , rsl.attribute3 attribute3
3198            , rsl.attribute4 attribute4
3199            , rsl.attribute5 attribute5
3200            , rsl.attribute6 attribute6
3201            , rsl.attribute7 attribute7
3202            , rsl.attribute8 attribute8
3203            , rsl.attribute9 attribute9
3204            , rsl.attribute10 attribute10
3205            , rsl.attribute11 attribute11
3206            , rsl.attribute12 attribute12
3207            , rsl.attribute13 attribute13
3208            , rsl.attribute14 attribute14
3209            , rsl.attribute15 attribute15
3210            , poll.closed_code closed_code
3211            , rsh.asn_type asn_type
3212            , rsh.bill_of_lading bill_of_lading
3213            , rsh.shipped_date shipped_date
3214            , rsh.freight_carrier_code freight_carrier_code
3215            , rsh.waybill_airbill_num waybill_airbill_num
3216            , rsh.freight_bill_number freight_bill_num
3217            , rsl.vendor_lot_num vendor_lot_num
3218            , rsl.container_num container_num
3219            , rsl.truck_num truck_num
3220            , rsl.bar_code_label bar_code_label
3221            , '' rate_type_display
3222            , poll.match_option match_option
3223            , rsl.country_of_origin_code country_of_origin_code
3224            , TO_NUMBER(NULL) oe_order_header_id
3225            , TO_NUMBER(NULL) oe_order_num
3226            , TO_NUMBER(NULL) oe_order_line_id
3227            , TO_NUMBER(NULL) oe_order_line_num
3228            , TO_NUMBER(NULL) customer_id
3229            , TO_NUMBER(NULL) customer_site_id
3230            , NULL customer_item_num
3231            , NULL pll_note_to_receiver
3232            , --POLL.NOTE_TO_RECEIVER       PLL_NOTE_TO_RECEIVER,
3233              pod.po_distribution_id po_distribution_id
3234            , pod.quantity_ordered - pod.quantity_delivered qty_ordered
3235            , pod.wip_entity_id wip_entity_id
3236            , pod.wip_operation_seq_num wip_operation_seq_num
3237            , pod.wip_resource_seq_num wip_resource_seq_num
3238            , pod.wip_repetitive_schedule_id wip_repetitive_schedule_id
3239            , pod.wip_line_id wip_line_id
3240            , pod.bom_resource_id bom_resource_id
3241            , '' destination_type
3242            , '' LOCATION
3243            , pod.rate currency_conversion_rate_pod
3244            , pod.rate_date currency_conversion_date_pod
3245            , pod.project_id project_id
3246            , pod.task_id task_id
3247            , NULL secondary_uom --OPM Convergence
3248            , NULL secondary_uom_code --OPM Convergence
3249            , NULL secondary_quantity --OPM Convergence
3250       FROM   rcv_shipment_lines rsl
3251            , rcv_shipment_headers rsh
3252            , po_headers poh
3253            , po_line_locations poll
3254            , po_lines pol
3255            , po_releases por
3256            , mtl_system_items msi
3257            , mtl_units_of_measure mum
3258            , po_distributions pod
3259       WHERE  pod.po_distribution_id = v_po_distribution_id
3260       AND    pod.line_location_id = poll.line_location_id
3261       AND    NVL(poll.approved_flag, 'N') = 'Y'
3262       AND    NVL(poll.cancel_flag, 'N') = 'N'
3263       AND    NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
3264       AND    poll.shipment_type IN('STANDARD', 'BLANKET', 'SCHEDULED')
3265       AND    poh.po_header_id = poll.po_header_id
3266       AND    pol.po_line_id = poll.po_line_id
3267       AND    poll.po_release_id = por.po_release_id(+)
3268       AND    mum.unit_of_measure(+) = rsl.unit_of_measure
3269       AND    NVL(msi.organization_id, rsl.to_organization_id) = rsl.to_organization_id
3270       AND    msi.inventory_item_id(+) = rsl.item_id
3271       AND    poll.line_location_id = rsl.po_line_location_id
3272       AND    rsl.shipment_header_id = rsh.shipment_header_id
3273       AND    rsh.asn_type IN('ASN', 'ASBN', 'LCM')    -- For LCM Project
3274       AND    rsl.shipment_line_status_code <> 'CANCELLED'
3275       AND    rsl.shipment_line_id = v_shipment_line_id
3276       AND    (p_project_id IS NULL
3277               OR(p_project_id = -9999
3278                  AND pod.project_id IS NULL)
3279               OR -- bug 2669021
3280                  pod.project_id = p_project_id)
3281       AND    (p_task_id IS NULL
3282               OR pod.task_id = p_task_id)
3283       UNION
3284       SELECT 'N' line_chkbox
3285            , 'INTERNAL' source_type_code
3286            , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
3287            , rsl.source_document_code order_type_code
3288            , '' order_type
3289            , rsh.shipment_header_id po_header_id
3290            , rsh.shipment_num po_number
3291            , rsl.shipment_line_id po_line_id
3292            , rsl.line_num po_line_number
3293            , rsl.shipment_line_id po_line_location_id
3294            , rsl.line_num po_shipment_number
3295            , rsh.shipment_header_id po_release_id
3296            , rsh.shipment_header_id po_release_number
3297            , porh.requisition_header_id req_header_id
3298            , porh.segment1 req_number
3299            , porl.requisition_line_id req_line_id
3300            , porl.line_num req_line
3301            , rsl.req_distribution_id req_distribution_id
3302            , rsl.shipment_header_id rcv_shipment_header_id
3303            , rsh.shipment_num rcv_shipment_number
3304            , rsl.shipment_line_id rcv_shipment_line_id
3305            , rsl.line_num rcv_line_number
3306            , rsl.from_organization_id from_organization_id
3307            , rsl.to_organization_id to_organization_id
3308            , rsl.shipment_line_id vendor_id
3309            , '' SOURCE
3310            , TO_NUMBER(NULL) vendor_site_id
3311            , 'N' outside_operation_flag
3312            , rsl.item_id item_id
3313            , -- Bug 2073164
3314              NULL uom_code
3315            , rsl.unit_of_measure primary_uom
3316            , mum.uom_class primary_uom_class
3317            , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
3318            , NVL(msi.location_control_code, 1) item_locator_control
3319            , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
3320            , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
3321            , NVL(msi.shelf_life_code, 1) shelf_life_code
3322            , NVL(msi.shelf_life_days, 0) shelf_life_days
3323            , msi.serial_number_control_code serial_number_control_code
3324            , msi.lot_control_code lot_control_code
3325            , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
3326            , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
3327            , NULL item_number
3328            , rsl.item_revision item_revision
3329            , rsl.item_description item_description
3330            , rsl.category_id item_category_id
3331            , '' hazard_class
3332            , '' un_number
3333            , rsl.vendor_item_num vendor_item_number
3334            , rsh.ship_to_location_id ship_to_location_id
3335            , '' ship_to_location
3336            , rsh.packing_slip packing_slip
3337            , rsl.routing_header_id routing_id
3338            , '' routing_name
3339            , porl.need_by_date need_by_date
3340            , rsh.expected_receipt_date expected_receipt_date
3341            , rsl.quantity_shipped ordered_qty
3342            , rsl.primary_unit_of_measure ordered_uom
3343            , rsh.ussgl_transaction_code ussgl_transaction_code
3344            , rsh.government_context government_context
3345            , NULL inspection_required_flag
3346            , NULL receipt_required_flag
3347            , NULL enforce_ship_to_location_code
3348            , TO_NUMBER(NULL) unit_price
3349            , NULL currency_code
3350            , NULL currency_conversion_type
3351            , TO_DATE(NULL) currency_conversion_date
3352            , TO_NUMBER(NULL) currency_conversion_rate
3353            , NULL note_to_receiver
3354            , --PORL.NOTE_TO_RECEIVER       NOTE_TO_RECEIVER,
3355              rsl.destination_type_code destination_type_code
3356            , rsl.deliver_to_person_id deliver_to_person_id
3357            , rsl.deliver_to_location_id deliver_to_location_id
3358            , rsl.to_subinventory destination_subinventory
3359            , rsl.attribute_category attribute_category
3360            , rsl.attribute1 attribute1
3361            , rsl.attribute2 attribute2
3362            , rsl.attribute3 attribute3
3363            , rsl.attribute4 attribute4
3364            , rsl.attribute5 attribute5
3365            , rsl.attribute6 attribute6
3366            , rsl.attribute7 attribute7
3367            , rsl.attribute8 attribute8
3368            , rsl.attribute9 attribute9
3369            , rsl.attribute10 attribute10
3370            , rsl.attribute11 attribute11
3371            , rsl.attribute12 attribute12
3372            , rsl.attribute13 attribute13
3373            , rsl.attribute14 attribute14
3374            , rsl.attribute15 attribute15
3375            , 'OPEN' closed_code
3376            , NULL asn_type
3377            , rsh.bill_of_lading bill_of_lading
3378            , rsh.shipped_date shipped_date
3379            , rsh.freight_carrier_code freight_carrier_code
3380            , rsh.waybill_airbill_num waybill_airbill_num
3381            , rsh.freight_bill_number freight_bill_num
3382            , rsl.vendor_lot_num vendor_lot_num
3383            , rsl.container_num container_num
3384            , rsl.truck_num truck_num
3385            , rsl.bar_code_label bar_code_label
3386            , NULL rate_type_display
3387            , 'P' match_option
3388            , NULL country_of_origin_code
3389            , TO_NUMBER(NULL) oe_order_header_id
3390            , TO_NUMBER(NULL) oe_order_num
3391            , TO_NUMBER(NULL) oe_order_line_id
3392            , TO_NUMBER(NULL) oe_order_line_num
3393            , TO_NUMBER(NULL) customer_id
3394            , TO_NUMBER(NULL) customer_site_id
3395            , NULL customer_item_num
3396            , NULL pll_note_to_receiver
3397            , --PORL.NOTE_TO_RECEIVER       PLL_NOTE_TO_RECEIVER,
3398              TO_NUMBER(NULL) po_distribution_id
3399            , TO_NUMBER(NULL) qty_ordered
3400            , TO_NUMBER(NULL) wip_entity_id
3401            , TO_NUMBER(NULL) wip_operation_seq_num
3402            , TO_NUMBER(NULL) wip_resource_seq_num
3403            , TO_NUMBER(NULL) wip_repetitive_schedule_id
3404            , TO_NUMBER(NULL) wip_line_id
3405            , TO_NUMBER(NULL) bom_resource_id
3406            , '' destination_type
3407            , '' LOCATION
3408            , TO_NUMBER(NULL) currency_conversion_rate_pod
3409            , TO_DATE(NULL) currency_conversion_date_pod
3410            , TO_NUMBER(NULL) project_id
3411            , TO_NUMBER(NULL) task_id
3412          , NULL secondary_uom --OPM Convergence
3413            , NULL secondary_uom_code --OPM Convergence
3414            , NULL secondary_quantity --OPM Convergence
3415       FROM   rcv_shipment_headers rsh
3416            , rcv_shipment_lines rsl
3417            , po_requisition_headers porh
3418            , po_requisition_lines porl
3419            , mtl_system_items msi
3420            , mtl_system_items msi1
3421            , mtl_units_of_measure mum
3422       WHERE  rsh.receipt_source_code <> 'VENDOR'
3423       AND    rsl.requisition_line_id = porl.requisition_line_id(+)
3424       AND    porl.requisition_header_id = porh.requisition_header_id(+)
3425       AND    rsh.shipment_header_id = rsl.shipment_header_id
3426       AND    mum.unit_of_measure(+) = rsl.unit_of_measure
3427       AND    msi.organization_id(+) = rsl.to_organization_id
3428       AND    msi.inventory_item_id(+) = rsl.item_id
3429       AND    msi1.organization_id(+) = rsl.from_organization_id
3430       AND    msi1.inventory_item_id(+) = rsl.item_id
3431       AND    rsh.asn_type IS NULL
3432       AND    rsl.shipment_line_id = v_shipment_line_id
3433       AND    (
3434               (
3435                rsl.source_document_code = 'REQ'
3436                AND EXISTS(
3437                     SELECT '1'
3438                     FROM   po_req_distributions_all prd
3439                     WHERE  prd.requisition_line_id = porl.requisition_line_id
3440                       AND  (
3441                             p_project_id IS NULL
3442                             OR(p_project_id = -9999
3443                                AND prd.project_id IS NULL)
3444                             OR -- bug 2669021
3445                                prd.project_id = p_project_id
3446                            )
3447                     AND    (p_task_id IS NULL
3448                             OR prd.task_id = p_task_id))
3449               )
3450               OR rsl.source_document_code <> 'REQ'
3451              );
3452 
3453 -- 3441084 Requisition_line_id also needs to be joined in the above Query otherwise will do
3454 -- a full scan on po_req_distributions_all which is not good.
3455 
3456     l_debug  NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3457     --table to store all RTId, quantity and original_rti_id for lot/serial splits
3458     l_new_rti_info         inv_rcv_integration_apis.child_rec_tb_tp;
3459     l_split_lot_serial_ok  BOOLEAN;   --Return status of lot_serial_split API
3460     l_msni_count           NUMBER := 0;
3461   BEGIN
3462     IF (l_debug = 1) THEN
3463       print_debug('create_asn_con_dd_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3464       print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
3465       print_debug('p_organization_id = ' || p_organization_id, 4);
3466       print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
3467       print_debug('p_po_header_id = ' || p_po_header_id, 4);
3468       print_debug('p_item_id = ' || p_item_id, 4);
3469       print_debug('p_rcv_qty = ' || p_rcv_qty, 4);
3470       print_debug('p_rcv_uom = ' || p_rcv_uom, 4);
3471       print_debug('p_rcv_uom_code = ' || p_rcv_uom_code, 4);
3472       print_debug('p_source_type = ' || p_source_type, 4);
3473       print_debug('p_subinventory = ' || p_subinventory, 4);
3474       print_debug('p_locator_id = ' || p_locator_id, 4);
3475       print_debug('p_transaction_temp_id = ' || p_transaction_temp_id, 4);
3476       print_debug('p_from_lpn_id = ' || p_from_lpn_id, 4);
3477       print_debug('p_lpn_id = ' || p_lpn_id, 4);
3478       print_debug('p_lot_control_code = ' || p_lot_control_code, 4);
3479       print_debug('p_revision = ' || p_revision, 4);
3480       print_debug('p_project_id = ' || p_project_id, 4);
3481       print_debug('p_task_id = ' || p_task_id, 4);
3482     END IF;
3483 
3484     SAVEPOINT crt_asn_con_rti_sp;
3485     x_status := fnd_api.g_ret_sts_success;
3486     l_progress := '10';
3487 
3488     -- query po_startup_value
3489     BEGIN
3490       /* Bug 2516729
3491        * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
3492        * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
3493        * in order that a new receipt # is not created everytime and the existing receipt # is used
3494        */
3495       BEGIN
3496         SELECT receipt_num
3497         INTO   l_receipt_num
3498         FROM   rcv_shipment_headers
3499         WHERE  shipment_header_id = p_shipment_header_id
3500         AND    ship_to_org_id = p_organization_id;
3501 
3502 	--Bug 4552825 - Assign the value only if it is not null
3503 	IF l_receipt_num IS NOT NULL THEN
3504 	   inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
3505 	END IF;
3506 
3507         IF (l_debug = 1) THEN
3508           print_debug('create_asn_con_dd_intf_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
3509         END IF;
3510       EXCEPTION
3511         WHEN NO_DATA_FOUND THEN
3512           l_receipt_num := NULL;
3513       END;
3514 
3515       inv_rcv_common_apis.init_startup_values(p_organization_id);
3516     EXCEPTION
3517       WHEN NO_DATA_FOUND THEN
3518         fnd_message.set_name('INV', 'INV_RCV_PARAM');
3519         fnd_msg_pub.ADD;
3520         RAISE fnd_api.g_exc_error;
3521     END;
3522 
3523     -- default header level non-DB items in rcv_transaction block
3524     -- and default other values need to be insert into RTI
3525 
3526     IF (l_debug = 1) THEN
3527       print_debug('create_asn_con_dd_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3528     END IF;
3529 
3530     l_progress := '20';
3531 
3532     -- default l_group_id ? clear group id after done
3533     IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
3534       SELECT rcv_interface_groups_s.NEXTVAL
3535       INTO   l_group_id
3536       FROM   DUAL;
3537 
3538       inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
3539     ELSE
3540       l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
3541     END IF;
3542 
3543     l_progress := '30';
3544     -- call matching algorithm   ?
3545 
3546     -- initialize input record for matching algorithm
3547     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).GROUP_ID := l_group_id;
3548     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).transaction_type := 'DELIVER';
3549     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).quantity := p_rcv_qty;
3550     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;
3551 
3552     IF p_item_id IS NOT NULL THEN
3553       inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
3554     ELSE
3555       IF (l_debug = 1) THEN
3556         print_debug('create_asn_con_dd_intf_rec: Item id is null - One time item', 4);
3557       END IF;
3558 
3559       inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := NULL;
3560       inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_desc := p_item_desc;
3561     END IF;
3562 
3563     --inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).item_id := p_item_id;
3564     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;
3565     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;
3566     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;
3567     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
3568     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).tax_amount := 0; -- ?
3569     inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status := 'S'; -- ?
3570     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
3571     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
3572     l_progress := '60';
3573 
3574     IF p_item_id IS NOT NULL THEN
3575       SELECT primary_unit_of_measure
3576       INTO   inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure
3577       FROM   mtl_system_items
3578       WHERE  mtl_system_items.inventory_item_id = p_item_id
3579       AND    mtl_system_items.organization_id = p_organization_id;
3580 
3581       l_progress := '70';
3582     ELSE
3583       inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).primary_unit_of_measure := NULL;
3584       l_progress := '71';
3585     END IF;
3586 
3587     IF (l_debug = 1) THEN
3588       print_debug('create_asn_con_dd_intf_rec: 30 before matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3589     END IF;
3590 
3591     IF p_source_type = 'ASN' THEN
3592       l_match_type := 'ASN';
3593     ELSIF p_source_type = 'LCM' THEN       -- For LCM Project
3594       l_match_type := 'LCM';              -- For LCM Project
3595     ELSE
3596       l_match_type := 'INTRANSIT SHIPMENT';
3597 
3598       -- Nested LPN changes
3599       -- Costgroup updates will be done by TM from patchset J
3600 
3601       IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
3602          OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
3603          OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
3604         BEGIN
3605           SELECT cost_group_id
3606           INTO   l_rcv_transaction_rec.cost_group_id
3607           FROM   wms_lpn_contents wlpnc
3608           WHERE  organization_id = p_organization_id
3609           AND    parent_lpn_id = p_lpn_id
3610           AND    wlpnc.inventory_item_id = p_item_id
3611           AND    EXISTS(SELECT 1
3612                         FROM   cst_cost_group_accounts
3613                         WHERE  organization_id = p_organization_id
3614                         AND    cost_group_id = wlpnc.cost_group_id);
3615         EXCEPTION
3616           WHEN OTHERS THEN
3617             l_rcv_transaction_rec.cost_group_id := NULL;
3618         END;
3619 
3620         IF l_rcv_transaction_rec.cost_group_id IS NULL THEN
3621           UPDATE wms_lpn_contents wlpnc
3622           SET cost_group_id = NULL
3623           WHERE  organization_id = p_organization_id
3624           AND    parent_lpn_id = p_lpn_id
3625           AND    wlpnc.inventory_item_id = p_item_id
3626           AND    NOT EXISTS(SELECT 1
3627                             FROM   cst_cost_group_accounts
3628                             WHERE  organization_id = p_organization_id
3629                             AND    cost_group_id = wlpnc.cost_group_id);
3630         END IF;
3631       END IF;
3632     END IF;
3633 
3634     -- bug 3213241
3635     IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
3636       AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
3637       AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
3638        l_lpn_id := p_from_lpn_id;
3639      ELSE
3640        l_lpn_id := p_lpn_id;
3641     END IF;
3642 
3643     inv_rcv_txn_match.matching_logic(
3644       x_return_status         => l_return_status
3645     , --?
3646       x_msg_count             => l_msg_count
3647     , x_msg_data              => l_msg_data
3648     , x_cascaded_table        => inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross
3649     , n                       => inv_rcv_std_rcpt_apis.g_receipt_detail_index
3650     , temp_cascaded_table     => l_rcpt_match_table_detail
3651     , p_receipt_num           => NULL
3652     , p_match_type            => l_match_type
3653     , p_lpn_id                => l_lpn_id
3654     );
3655 
3656     IF (l_debug = 1) THEN
3657       print_debug('create_asn_con_dd_intf_rec: 40 after matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3658       print_debug('create_asn_con_dd_intf_rec: 40.1 - after matching  l_return_status = ' || l_return_status, 4);
3659       print_debug('create_asn_con_dd_intf_rec: 40.2 - after matching  l_msg_count = ' || l_msg_count, 4);
3660       print_debug('create_asn_con_dd_intf_rec: 40.3 - after matching  l_msg_data = ' || l_msg_data, 4);
3661     END IF;
3662 
3663     IF l_return_status = fnd_api.g_ret_sts_error THEN
3664       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3665       fnd_msg_pub.ADD;
3666 
3667       IF (l_debug = 1) THEN
3668         print_debug('create_asn_con_dd_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3669       END IF;
3670 
3671       RAISE fnd_api.g_exc_error;
3672     END IF;
3673 
3674     IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3675       fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3676       fnd_msg_pub.ADD;
3677 
3678       IF (l_debug = 1) THEN
3679         print_debug('create_asn_con_dd_intf_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
3680         , 1);
3681       END IF;
3682 
3683       RAISE fnd_api.g_exc_unexpected_error;
3684     END IF;
3685 
3686     IF inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_status = 'E' THEN
3687       l_err_message := inv_rcv_std_rcpt_apis.g_rcpt_match_table_gross(inv_rcv_std_rcpt_apis.g_receipt_detail_index).error_message;
3688       fnd_message.set_name('INV', l_err_message);
3689       fnd_msg_pub.ADD;
3690 
3691       IF (l_debug = 1) THEN
3692         print_debug('create_asn_con_dd_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3693       END IF;
3694 
3695       RAISE fnd_api.g_exc_error;
3696     END IF;
3697 
3698     l_err_message := '@@@';
3699 
3700     FOR i IN inv_rcv_std_rcpt_apis.g_receipt_detail_index ..(
3701                                                                inv_rcv_std_rcpt_apis.g_receipt_detail_index
3702                                                              + l_rcpt_match_table_detail.COUNT
3703                                                              - 1
3704                                                             ) LOOP
3705       IF (l_debug = 1) THEN
3706 	 print_debug('Error Status:'||
3707 		     l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index +1).error_status
3708 		     , 4);
3709 	 print_debug('Error Message:'||
3710 		     l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index +1).error_message
3711 		     , 4);
3712       END IF;
3713 
3714       IF l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_status = 'W' THEN
3715         x_status := 'W';
3716         l_temp_message := l_rcpt_match_table_detail(i - inv_rcv_std_rcpt_apis.g_receipt_detail_index + 1).error_message;
3717 
3718         IF l_temp_message IS NULL THEN
3719           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3720           l_msg_prod := 'INV';
3721           EXIT;
3722         END IF;
3723 
3724         IF l_err_message = '@@@' THEN
3725           l_err_message := l_temp_message;
3726           l_msg_prod := 'INV';
3727         ELSIF l_temp_message <> l_err_message THEN
3728           l_msg_prod := 'INV';
3729           l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3730           EXIT;
3731         END IF;
3732       END IF;
3733     END LOOP;
3734 
3735     IF l_err_message <> '@@@' THEN
3736       fnd_message.set_name(l_msg_prod, l_err_message);
3737       fnd_msg_pub.ADD;
3738 
3739       IF (l_debug = 1) THEN
3740         print_debug('create_asn_con_dd_intf_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3741       END IF;
3742     END IF;
3743 
3744     -- load the matching algorithm result into input data structure
3745 
3746 
3747     -- based on return from matching algorithm,
3748     -- determine which line in rcv_transaction block to be inserted into RTI
3749     -- loop through results returned by matching algorithm
3750     FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
3751       l_progress := '72';
3752 
3753       IF (l_debug = 1) THEN
3754         print_debug('create_asn_con_dd_intf_rec 82: opening outer cursor for', 4);
3755         print_debug('shipment_line_id => ' || l_rcpt_match_table_detail(match_result_count).shipment_line_id, 4);
3756         print_debug('po_distribution_id => ' || l_rcpt_match_table_detail(match_result_count).po_distribution_id, 4);
3757       END IF;
3758 
3759       OPEN l_curs_rcpt_detail(
3760             l_rcpt_match_table_detail(match_result_count).shipment_line_id
3761           , l_rcpt_match_table_detail(match_result_count).po_distribution_id
3762                              );
3763       l_progress := '74';
3764       FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
3765       l_progress := '76';
3766       CLOSE l_curs_rcpt_detail;
3767       l_progress := '78';
3768       l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
3769       l_rcv_transaction_rec.po_distribution_id := l_rcpt_match_table_detail(match_result_count).po_distribution_id;
3770 
3771       IF (l_debug = 1) THEN
3772         print_debug(
3773              'create_asn_con_dd_intf_rec: 90.1 - the '
3774           || match_result_count
3775           || 'th record of matching results - rcv_shipment_line_id = '
3776           || l_rcpt_match_table_detail(match_result_count).shipment_line_id
3777         , 4
3778         );
3779       END IF;
3780 
3781       -- update following fields from matching algorithm return value
3782       l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
3783       l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
3784       l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
3785       l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
3786 
3787     --  Bug 13445129
3788       -- Assign secondary quantity and uoms.
3789       l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) *  p_secondary_rcv_qty;
3790       l_rcv_transaction_rec.secondary_uom := p_rcv_sec_uom;
3791       l_rcv_transaction_rec.secondary_uom_code := p_rcv_sec_uom_code;
3792 
3793       IF (l_debug = 1) THEN
3794          print_debug('In create_asn_con_dd_intf_rec 90.1.1: l_rcv_transaction_rec.secondary_quantity'|| l_rcv_transaction_rec.secondary_quantity, 1);
3795       END IF;
3796       --  end Bug 13445129
3797 
3798       -- Nested lpn changes.
3799       -- Pass From_lpn_id instead of p_lpn_id for creating confirm receipts.
3800       --IF p_from_lpn_id IS NOT NULL
3801       IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
3802          AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
3803          AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
3804         l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
3805       ELSE
3806         l_rcv_transaction_rec.lpn_id := p_lpn_id;
3807       END IF;
3808 
3809       l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
3810       -- update following fields for po_distribution related values
3811       l_rcv_transaction_rec.currency_conversion_date := l_rcv_rcpt_rec.currency_conversion_date_pod;
3812       l_rcv_transaction_rec.currency_conversion_rate := l_rcv_rcpt_rec.currency_conversion_rate_pod;
3813       -- following fileds can have distribution level values
3814       -- therefore they are set here instead of in the common insert code
3815       l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.qty_ordered;
3816       --Bug 2073164
3817       l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
3818       l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3819       -- l_rcv_transaction_rec.lpn_id := p_lpn_id;
3820 
3821       -- wip related fields
3822       IF l_rcv_rcpt_rec.wip_entity_id > 0 THEN
3823         l_rcv_transaction_rec.wip_entity_id := l_rcv_rcpt_rec.wip_entity_id;
3824         l_rcv_transaction_rec.wip_operation_seq_num := l_rcv_rcpt_rec.wip_operation_seq_num;
3825         l_rcv_transaction_rec.wip_resource_seq_num := l_rcv_rcpt_rec.wip_resource_seq_num;
3826         l_rcv_transaction_rec.wip_repetitive_schedule_id := l_rcv_rcpt_rec.wip_repetitive_schedule_id;
3827         l_rcv_transaction_rec.wip_line_id := l_rcv_rcpt_rec.wip_line_id;
3828         l_rcv_transaction_rec.bom_resource_id := l_rcv_transaction_rec.bom_resource_id;
3829       -- there is getting actual values call for wip
3830       -- since they are not inserted in RTI, I am not calling it here
3831       -- the code is in
3832       -- rcv_transactions_sv.get_wip_info ()
3833       END IF;
3834 
3835       /***Bug 13490287  */
3836       -- Deliver_to_location_id is mandatory for Expense Items case
3837       -- So if no deliver_to_location_id is present in the distributions of po for Expense Items
3838       -- we will default it to the value passed from the mobile UI.
3839 
3840       IF inv_rcv_common_apis.g_po_patch_level  < inv_rcv_common_apis.g_patchset_j_po OR
3841          inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j OR
3842          inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
3843           NULL;
3844       ELSE
3845           if l_rcv_rcpt_rec.destination_type_code = 'EXPENSE' then
3846                     IF (l_debug = 1) THEN
3847                             print_debug('create_asn_con_dd_intf_rec: p_location_id ='|| p_location_id, 4);
3848                             print_debug('create_asn_con_dd_intf_rec: l_rcv_transaction_rec.deliver_to_location_id ='|| l_rcv_transaction_rec.deliver_to_location_id, 4);
3849                     END IF;
3850 
3851                   if l_rcv_transaction_rec.deliver_to_location_id is null and
3852                       p_location_id is not null THEN
3853                      l_rcv_transaction_rec.deliver_to_location_id := p_location_id;
3854                   End if;
3855           End if;
3856       END IF;
3857 
3858       /***End Bug 13490287 */
3859 
3860       --Bug #4147209 - Populate the record type with the DFF attribute category
3861       --and segment values passed from the mobile UI
3862       set_attribute_vals(
3863           p_rcv_rcpt_rec        =>  l_rcv_rcpt_rec
3864         , p_attribute_category  => p_attribute_category
3865         , p_attribute1          => p_attribute1
3866         , p_attribute2          => p_attribute2
3867         , p_attribute3          => p_attribute3
3868         , p_attribute4          => p_attribute4
3869         , p_attribute5          => p_attribute5
3870         , p_attribute6          => p_attribute6
3871         , p_attribute7          => p_attribute7
3872         , p_attribute8          => p_attribute8
3873         , p_attribute9          => p_attribute9
3874         , p_attribute10         => p_attribute10
3875         , p_attribute11         => p_attribute11
3876         , p_attribute12         => p_attribute12
3877         , p_attribute13         => p_attribute13
3878         , p_attribute14         => p_attribute14
3879         , p_attribute15         => p_attribute15);
3880 
3881       IF (l_debug = 1) THEN
3882         print_debug('create_asn_con_dd_intf_rec: 100 before populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3883       END IF;
3884 
3885       l_progress := '80';
3886       populate_default_values(
3887         p_rcv_transaction_rec     => l_rcv_transaction_rec
3888       , p_rcv_rcpt_rec            => l_rcv_rcpt_rec
3889       , p_group_id                => l_group_id
3890       , p_organization_id         => p_organization_id
3891       , p_item_id                 => p_item_id
3892       , p_revision                => p_revision
3893       , p_source_type             => p_source_type
3894       , p_subinventory_code       => p_subinventory
3895       , p_locator_id              => p_locator_id
3896       , p_transaction_temp_id     => p_transaction_temp_id
3897       , p_lot_control_code        => p_lot_control_code
3898       , p_serial_control_code     => p_serial_control_code
3899       , p_project_id              => p_project_id
3900       , p_task_id                 => p_task_id
3901       , p_express_transaction     => p_express_transaction--Bug 5550783
3902       );
3903       /* FP-J Lot/Serial Support Enhancement
3904        * Populate the table to store the information of the RTIs created used for
3905        * splitting the lots and serials based on RTI quantity
3906        */
3907       IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3908           (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3909         l_new_rti_info(match_result_count).orig_interface_trx_id := p_transaction_temp_id;
3910         l_new_rti_info(match_result_count).new_interface_trx_id := g_interface_transaction_id;
3911         l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
3912         IF (l_debug = 1) THEN
3913           print_debug('create_asn_con_dd_intf_rec: 105 - Populated the table for lot/serial split', 4);
3914         END IF;
3915       END IF;   --END IF populate the table to store RTI info that was just created
3916 
3917       l_progress := '90';
3918 
3919       IF (l_debug = 1) THEN
3920         print_debug('create_asn_con_dd_intf_rec: 110 after populate_default_values' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3921       END IF;
3922     END LOOP;
3923 
3924     /* FP-J Lot/Serial Support Enhancement
3925      * Call the split_lot API to split the lots and serials inserted from the UI
3926      * based on the quantity of each RTI record
3927      */
3928     IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
3929         (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
3930       l_msni_count := 0;
3931 	    --BUG 3326408,3346758,3405320
3932       --If there are any serials confirmed from the UI for an item that is
3933       --lot controlled and serial control dynamic at SO issue,
3934       --do not NULL out serial_transaction_temp_id. In other cases,
3935       --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
3936       IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
3937           l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
3938 	      IF (l_debug = 1) THEN
3939 	        print_debug('create_asn_con_dd_intf_rec 110.2: serial_control_code IS 6, need TO NULL OUT mtli', 4);
3940 	      END IF;
3941 
3942 	      BEGIN
3943           IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3944             SELECT count(1)
3945             INTO   l_msni_count
3946             FROM   mtl_serial_numbers_interface
3947             WHERE  product_transaction_id = p_transaction_temp_id
3948             AND    product_code = 'RCV';
3949           END IF;
3950 
3951           IF l_msni_count = 0 THEN
3952             UPDATE mtl_transaction_lots_interface
3953 	          SET  serial_transaction_temp_id = NULL
3954 	          WHERE product_transaction_id = p_transaction_temp_id
3955 	          AND   product_code = 'RCV';
3956           END IF;
3957 	      EXCEPTION
3958 	        WHEN OTHERS THEN
3959 		        IF (l_debug = 1) THEN
3960 		          print_debug('create_asn_con_dd_intf_rec 110.4: Error nulling serial temp id OF MTLI', 4);
3961 		        END IF;
3962 	      END ;
3963       END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3964 
3965       l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
3966               p_api_version   => 1.0
3967             , p_init_msg_lst  => FND_API.G_FALSE
3968             , x_return_status =>  l_return_status
3969             , x_msg_count     =>  l_msg_count
3970             , x_msg_data      =>  x_message
3971             , p_new_rti_info  =>  l_new_rti_info);
3972       IF ( NOT l_split_lot_serial_ok) THEN
3973         IF (l_debug = 1) THEN
3974           print_debug('create_asn_con_dd_intf_rec 115.1: Failure in split_lot_serial', 4);
3975         END IF;
3976         RAISE FND_API.G_EXC_ERROR;
3977       END IF;
3978 
3979       IF (l_debug = 1) THEN
3980         print_debug('create_asn_con_dd_intf_rec 115.2: Call split_lot_serial is OK', 4);
3981       END IF;
3982     END IF;   --END IF check INV J and PO J installed
3983 
3984     IF l_curs_rcpt_detail%ISOPEN THEN
3985       CLOSE l_curs_rcpt_detail;
3986     END IF;
3987 
3988     -- append index in input table where the line to be detailed needs to be inserted
3989     --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
3990 
3991     -- UPDATE lpn context
3992     l_progress := '100';
3993 
3994     -- Nested LPN changes
3995     IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
3996        OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
3997        OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
3998       UPDATE wms_license_plate_numbers
3999       SET lpn_context = 3
4000       WHERE  lpn_id = p_lpn_id;
4001     END IF;
4002 
4003     l_progress := '110';
4004     l_progress := '120';
4005     inv_rcv_common_apis.do_check(
4006       p_organization_id         => p_organization_id
4007     , p_inventory_item_id       => p_item_id
4008     , p_transaction_type_id     => 18
4009     , p_primary_quantity        => l_total_primary_qty
4010     , x_return_status           => l_return_status
4011     , x_msg_count               => l_msg_count
4012     , x_msg_data                => x_message
4013     );
4014 
4015     IF l_return_status <> fnd_api.g_ret_sts_success THEN
4016       x_status := l_return_status;
4017     END IF;
4018 
4019     l_progress := '130';
4020 
4021     -- Calling The ASN Discrepnacy  Details
4022     IF (l_debug = 1) THEN
4023       print_debug('Before Calling ASN Ddetails ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4024     END IF;
4025 
4026     inv_cr_asn_details.create_asn_details(
4027       p_organization_id
4028     , l_group_id
4029     , l_rcv_rcpt_rec
4030     , l_rcv_transaction_rec
4031     , inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb
4032     , TO_NUMBER(NULL)
4033     , l_return_status
4034     , l_msg_data
4035     );
4036 
4037     IF l_return_status <> fnd_api.g_ret_sts_success THEN
4038       x_status := l_return_status;
4039     END IF;
4040 
4041     l_progress := '140';
4042     -- Clear the Lot Rec
4043     inv_rcv_std_rcpt_apis.g_rcpt_lot_qty_rec_tb.DELETE;
4044 
4045     IF (l_debug = 1) THEN
4046       print_debug('About exit create_asn_con_dd_intf_rec: 140' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4047     END IF;
4048   EXCEPTION
4049     WHEN fnd_api.g_exc_error THEN
4050       ROLLBACK TO crt_asn_con_rti_sp;
4051       x_status := fnd_api.g_ret_sts_error;
4052 
4053       IF l_curs_rcpt_detail%ISOPEN THEN
4054         CLOSE l_curs_rcpt_detail;
4055       END IF;
4056 
4057       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4058 
4059       IF (l_debug = 1) THEN
4060         print_debug('create_asn_con_dd_intf_rec:  FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4061       END IF;
4062     WHEN fnd_api.g_exc_unexpected_error THEN
4063       ROLLBACK TO crt_asn_con_rti_sp;
4064       x_status := fnd_api.g_ret_sts_unexp_error;
4065 
4066       IF l_curs_rcpt_detail%ISOPEN THEN
4067         CLOSE l_curs_rcpt_detail;
4068       END IF;
4069 
4070       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4071 
4072       IF (l_debug = 1) THEN
4073         print_debug('create_asn_con_dd_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4074       END IF;
4075     WHEN OTHERS THEN
4076       ROLLBACK TO crt_asn_con_rti_sp;
4077       x_status := fnd_api.g_ret_sts_unexp_error;
4078 
4079       IF l_curs_rcpt_detail%ISOPEN THEN
4080         CLOSE l_curs_rcpt_detail;
4081       END IF;
4082 
4083       IF SQLCODE IS NOT NULL THEN
4084         inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_con_dd_intf_rec', l_progress, SQLCODE);
4085       END IF;
4086 
4087       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4088 
4089       IF (l_debug = 1) THEN
4090         print_debug('create_asn_con_dd_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4091       END IF;
4092   END;
4093 
4094   PROCEDURE create_asn_exp_dd_intf_rec(
4095     p_move_order_header_id  IN OUT NOCOPY  NUMBER
4096   , p_organization_id       IN             NUMBER
4097   , p_shipment_header_id    IN             NUMBER
4098   , p_po_header_id          IN             NUMBER
4099   , p_source_type           IN             VARCHAR2
4100   , p_subinventory                         VARCHAR2
4101   , p_locator_id                           NUMBER
4102   , p_lpn_id                IN             NUMBER
4103   , p_transaction_temp_id   IN             NUMBER
4104   , x_status                OUT NOCOPY     VARCHAR2
4105   , x_message               OUT NOCOPY     VARCHAR2
4106   , p_project_id            IN             NUMBER
4107   , p_task_id               IN             NUMBER
4108   , p_country_code          IN             VARCHAR2 DEFAULT NULL
4109   , p_secondary_rcv_qty     IN             NUMBER DEFAULT NULL  --OPM Convergence
4110   , p_rcv_sec_uom           IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
4111   , p_rcv_sec_uom_code      IN             VARCHAR2 DEFAULT NULL  --OPM Convergence
4112   , p_attribute_category    IN             VARCHAR2  DEFAULT NULL  --Bug #4147209 - DFF cols
4113   , p_attribute1            IN             VARCHAR2  DEFAULT NULL
4114   , p_attribute2            IN             VARCHAR2  DEFAULT NULL
4115   , p_attribute3            IN             VARCHAR2  DEFAULT NULL
4116   , p_attribute4            IN             VARCHAR2  DEFAULT NULL
4117   , p_attribute5            IN             VARCHAR2  DEFAULT NULL
4118   , p_attribute6            IN             VARCHAR2  DEFAULT NULL
4119   , p_attribute7            IN             VARCHAR2  DEFAULT NULL
4120   , p_attribute8            IN             VARCHAR2  DEFAULT NULL
4121   , p_attribute9            IN             VARCHAR2  DEFAULT NULL
4122   , p_attribute10           IN             VARCHAR2  DEFAULT NULL
4123   , p_attribute11           IN             VARCHAR2  DEFAULT NULL
4124   , p_attribute12           IN             VARCHAR2  DEFAULT NULL
4125   , p_attribute13           IN             VARCHAR2  DEFAULT NULL
4126   , p_attribute14           IN             VARCHAR2  DEFAULT NULL
4127   , p_attribute15           IN             VARCHAR2  DEFAULT NULL
4128   ) IS
4129     -- Bug 2182881
4130     -- changed the cursor as for lot_numbers it was not joining with
4131     -- organization_id.
4132     CURSOR l_curs_asn_lpn_content IS
4133       SELECT lpnc.lpn_id
4134            , lpnc.inventory_item_id
4135            , lpnc.revision
4136            , lpnc.quantity
4137            , lpnc.uom_code
4138            , lpnc.lot_control_code
4139            , lpnc.serial_number_control_code
4140            , lpnc.primary_uom_code
4141            , p_po_header_id
4142            , lpnc.lot_number
4143            , mln.expiration_date
4144            , mln.status_id
4145            , lpnc.lpn_org_id
4146 	   , lpnc.secondary_quantity   --Bug 7656734
4147       FROM   mtl_lot_numbers mln
4148            , (SELECT wlpn.lpn_id
4149                    , wlpnc.inventory_item_id
4150                    , msi.organization_id
4151                    , msi.lot_control_code
4152                    , msi.serial_number_control_code
4153                    , msi.primary_uom_code
4154                    , wlpnc.revision
4155                    , wlpnc.quantity
4156                    , wlpnc.uom_code
4157                    , wlpnc.lot_number
4158                    , wlpnc.source_line_id
4159                    , wlpn.organization_id lpn_org_id
4160 		   , wlpnc.secondary_quantity   --Bug 7656734
4161               FROM   wms_lpn_contents wlpnc, wms_license_plate_numbers wlpn, mtl_system_items msi, rcv_shipment_headers rsh
4162               WHERE  rsh.shipment_header_id = p_shipment_header_id
4163               AND    (wlpn.source_header_id = rsh.shipment_header_id
4164                       OR wlpn.source_name = rsh.shipment_num)
4165               AND    wlpn.lpn_context IN(6, 7)                                  -- only those pre-ASN receiving ones
4166                                                -- Nested LPN changes to explode the LPN
4167                                                --AND wlpnc.parent_lpn_id = Nvl(p_lpn_id, wlpn.lpn_id)
4168                                                -- In case user tries to to ASN reciept by giving only PO Number
4169                                                -- LPN id will be NULL, In this case we should not expand the LPN
4170                                                -- in which case start with lpn_id = p_lpn_id will fail.
4171               AND    (wlpnc.parent_lpn_id = NVL(p_lpn_id, wlpn.lpn_id)
4172                       OR wlpnc.parent_lpn_id IN(SELECT     lpn_id
4173                                                 FROM       wms_license_plate_numbers
4174                                                 START WITH lpn_id = p_lpn_id
4175                                                 CONNECT BY parent_lpn_id = PRIOR lpn_id))
4176               AND    wlpnc.inventory_item_id = msi.inventory_item_id
4177               AND    msi.organization_id = p_organization_id
4178               AND    wlpn.lpn_id = wlpnc.parent_lpn_id
4179               AND    (
4180                       wlpnc.source_line_id IN(SELECT pola.po_line_id
4181                                               FROM   po_lines_all pola
4182                                               WHERE  pola.po_header_id = NVL(p_po_header_id, pola.po_header_id))
4183                       OR wlpnc.source_line_id IS NULL
4184                      )) lpnc
4185       WHERE  lpnc.inventory_item_id = mln.inventory_item_id(+)
4186       AND    lpnc.lot_number = mln.lot_number(+)
4187       AND    lpnc.organization_id = mln.organization_id(+);
4188 
4189     CURSOR l_curs_serial_number(v_inventory_item_id NUMBER, v_revision VARCHAR2
4190               , v_lot_number VARCHAR2, v_lpn_id NUMBER) IS
4191       -- bug 2182881
4192       -- added nvl around the cursor
4193       SELECT serial_number
4194             , status_id
4195       FROM   mtl_serial_numbers
4196       WHERE  inventory_item_id = v_inventory_item_id
4197       AND    (revision = v_revision
4198               OR(revision IS NULL
4199                  AND v_revision IS NULL))
4200       AND    (lot_number = v_lot_number
4201               OR(lot_number IS NULL
4202                  AND v_lot_number IS NULL))
4203       AND    lpn_id = v_lpn_id;
4204 
4205     TYPE number_tab_tp IS TABLE OF NUMBER
4206       INDEX BY BINARY_INTEGER;
4207 
4208     TYPE date_tab_tp IS TABLE OF DATE
4209       INDEX BY BINARY_INTEGER;
4210 
4211     TYPE varchar_tab_tp IS TABLE OF VARCHAR2(30)
4212       INDEX BY BINARY_INTEGER;
4213 
4214     l_msnt_transaction_temp_id number_tab_tp;
4215     l_msnt_last_update_date    date_tab_tp;
4216     l_msnt_last_updated_by     number_tab_tp;
4217     l_msnt_creation_date       date_tab_tp;
4218     l_msnt_created_by          number_tab_tp;
4219     l_msnt_fm_serial_number    varchar_tab_tp;
4220     l_msnt_to_serial_number    varchar_tab_tp;
4221     l_lpn_id                   NUMBER;
4222     l_inventory_item_id        NUMBER;
4223     l_revision                 VARCHAR2(30);
4224     l_quantity                 NUMBER;
4225     l_uom_code                 VARCHAR2(3);
4226     l_lot_control_code         NUMBER;
4227     l_serial_control_code      NUMBER;
4228     l_unit_of_measure          VARCHAR2(25);
4229     l_po_header_id             NUMBER;
4230 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
4231     l_lot_number               VARCHAR2(80);
4232     l_lot_expiration_date      DATE;
4233     l_return_status            VARCHAR2(1) := fnd_api.g_ret_sts_success;
4234     l_msg_count                NUMBER;
4235     l_msg_data                 VARCHAR2(400);
4236     l_progress                 VARCHAR2(10);
4237     l_transaction_temp_id      NUMBER;
4238     l_serial_txn_temp_id       NUMBER;
4239     l_primary_uom_code         VARCHAR2(3);
4240     l_primary_qty              NUMBER;
4241     l_uom_conv_ratio           NUMBER;
4242     l_serial_number            VARCHAR2(30);
4243     l_msnt_rec                 mtl_serial_numbers_temp%ROWTYPE;
4244     l_serial_number_count      NUMBER;
4245     l_label_status             VARCHAR2(500);
4246     l_debug                    NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4247 
4248     l_transaction_interface_id    NUMBER;
4249     l_product_transaction_id      NUMBER;
4250     l_serial_transaction_temp_id  NUMBER;
4251     l_lot_status_id               NUMBER;
4252     l_serial_status_id            NUMBER;
4253     l_lot_prm_quantity            NUMBER; --lot quantity in primary uom
4254     l_from_org_id                 NUMBER;
4255     l_lpn_org                     NUMBER;
4256     l_lpn_controlled_flag         NUMBER := 1;
4257     l_to_lpn_id                   NUMBER;
4258     l_secondary_quantity          NUMBER;  --Bug 7656734
4259   BEGIN
4260     IF (l_debug = 1) THEN
4261       print_debug('create_asn_exp_dd_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4262       print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
4263       print_debug('p_organization_id = ' || p_organization_id, 4);
4264       print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
4265       print_debug('p_po_header_id = ' || p_po_header_id, 4);
4266       print_debug('p_subinventory = ' || p_subinventory, 4);
4267       print_debug('p_locator_id = ' || p_locator_id, 4);
4268       print_debug('p_transaction_temp_id = ' || p_transaction_temp_id, 4);
4269       print_debug('p_source_type = ' || p_source_type, 4);
4270       print_debug('p_lpn_id = ' || p_lpn_id, 4);
4271       print_debug('project id = ' || p_project_id);
4272     END IF;
4273 
4274     x_status := fnd_api.g_ret_sts_success;
4275     l_progress := '10';
4276     OPEN l_curs_asn_lpn_content;
4277     l_progress := '20';
4278 
4279 
4280     -- Check if the ToSubinventory is LPN controlled.
4281     SELECT NVL(lpn_controlled_flag,1)
4282       INTO l_lpn_controlled_flag
4283       FROM mtl_secondary_inventories
4284      WHERE secondary_inventory_name =  p_subinventory
4285        AND organization_id = p_organization_id;
4286 
4287     IF (l_debug = 1) THEN
4288        print_debug('create_asn_exp_dd_intf_rec: 0 ' || l_lpn_controlled_flag, 9);
4289     END IF;
4290 
4291 
4292     LOOP
4293       FETCH l_curs_asn_lpn_content INTO l_lpn_id
4294      , l_inventory_item_id
4295      , l_revision
4296      , l_quantity
4297      , l_uom_code
4298      , l_lot_control_code
4299      , l_serial_control_code
4300      , l_primary_uom_code
4301      , l_po_header_id
4302      , l_lot_number
4303      , l_lot_expiration_date
4304      , l_lot_status_id
4305      , l_lpn_org
4306      , l_secondary_quantity;   --Bug 7656734
4307       EXIT WHEN l_curs_asn_lpn_content%NOTFOUND;
4308       l_progress := '30';
4309 
4310       IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
4311          OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
4312          OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
4313         inv_rcv_std_rcpt_apis.update_lpn_org(
4314           p_organization_id     => p_organization_id
4315         , p_lpn_id              => l_lpn_id
4316         , x_return_status       => l_return_status
4317         , x_msg_count           => l_msg_count
4318         , x_msg_data            => l_msg_data
4319         );
4320 
4321         IF l_return_status <> fnd_api.g_ret_sts_success THEN
4322           RAISE fnd_api.g_exc_error;
4323         END IF;
4324       END IF;
4325 
4326       l_progress := '35';
4327 
4328       SELECT unit_of_measure
4329       INTO   l_unit_of_measure
4330       FROM   mtl_item_uoms_view
4331       WHERE  uom_code = l_uom_code
4332       AND    organization_id = p_organization_id
4333       AND    inventory_item_id = l_inventory_item_id;
4334 
4335       l_progress := '40';
4336 
4337       /* FP-J Lot/Serial Support Enhancement
4338        * If either INV J or PO J are not installed, then retain the existing logic
4339        * to create temp records for lots and serials
4340        * If both INV J and PO J are installed, create interface records for the lots/serials
4341        */
4342       IF ((inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j) OR
4343           (inv_rcv_common_apis.g_po_patch_level  < inv_rcv_common_apis.g_patchset_j_po)) THEN
4344         -- insert into mtlt
4345         IF l_lot_number IS NOT NULL THEN
4346           IF (l_debug = 1) THEN
4347             print_debug('create_asn_exp_dd_intf_rec: 25 before inv_rcv_common_apis.insert_lot'
4348               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4349             , 4);
4350           END IF;
4351 
4352           inv_convert.inv_um_conversion(from_unit => l_uom_code, to_unit => l_primary_uom_code, item_id => l_inventory_item_id
4353           , uom_rate      => l_uom_conv_ratio);
4354 
4355           IF l_uom_conv_ratio = -99999 THEN -- uom conversion failure
4356             fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
4357             fnd_msg_pub.ADD;
4358 
4359             IF (l_debug = 1) THEN
4360               print_debug(
4361                 'create_asn_exp_dd_intf_rec 25.1 - txn/primary uom ratio calculation failed'
4362                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4363               , 4
4364               );
4365             END IF;
4366 
4367             RAISE fnd_api.g_exc_error;
4368           END IF;
4369 
4370 	  IF (p_source_type = 'INTERNAL' AND l_lot_control_code = 2) THEN
4371           BEGIN
4372                 SELECT expiration_date
4373                 INTO l_lot_expiration_date
4374                 FROM mtl_lot_numbers
4375                 WHERE inventory_item_id = l_inventory_item_id
4376                 AND organization_id = l_lpn_org
4377                 AND lot_number = l_lot_number;
4378           EXCEPTION
4379                 WHEN OTHERS THEN
4380                 l_lot_expiration_date := NULL;
4381           END;
4382          END IF;
4383 
4384 	 IF (l_debug = 1) THEN
4385          	print_debug('l_lot_expiration_date = '||l_lot_expiration_date, 4);
4386 	 END IF;
4387 
4388           l_primary_qty := l_quantity * l_uom_conv_ratio;
4389           inv_rcv_common_apis.insert_lot(
4390             p_transaction_temp_id            => l_transaction_temp_id
4391           , p_created_by                     => fnd_global.user_id
4392           , p_transaction_qty                => l_quantity
4393           , p_primary_qty                    => l_primary_qty
4394           , p_lot_number                     => l_lot_number
4395           , p_expiration_date                => l_lot_expiration_date
4396           , p_status_id                      => NULL
4397           , x_serial_transaction_temp_id     => l_serial_txn_temp_id
4398           , x_return_status                  => l_return_status
4399           , x_msg_data                       => l_msg_data
4400           );
4401 
4402           IF l_return_status = fnd_api.g_ret_sts_error THEN
4403             fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4404             fnd_msg_pub.ADD;
4405 
4406             IF (l_debug = 1) THEN
4407               print_debug(
4408                    'create_asn_exp_dd_intf_rec 25.1: inv_rcv_common_apis.insert_lot RAISE FND_API.G_EXC_ERROR;'
4409                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4410             END IF;
4411 
4412             RAISE fnd_api.g_exc_error;
4413           END IF;
4414 
4415           IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4416             fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4417             fnd_msg_pub.ADD;
4418 
4419             IF (l_debug = 1) THEN
4420               print_debug(
4421                    'create_asn_exp_dd_intf_rec 25.2: inv_rcv_common_apis.insert_lot RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
4422                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4423             END IF;
4424 
4425             RAISE fnd_api.g_exc_unexpected_error;
4426           END IF;   --END IF ret_status = unexp_error
4427         END IF;   --END IF item is lot controlled
4428 
4429         l_progress := '41';
4430 
4431         -- insert into msnt
4432 
4433         IF l_serial_control_code = 2
4434            OR l_serial_control_code = 5 THEN
4435           IF (l_debug = 1) THEN
4436             print_debug('create_asn_exp_dd_intf_rec 27.1 - insert serial temp' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4437           END IF;
4438 
4439           OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4440           l_serial_number_count := 0;
4441 
4442           IF l_serial_txn_temp_id IS NULL THEN -- Not lot controlled
4443             l_progress := '42';
4444 
4445             SELECT mtl_material_transactions_s.NEXTVAL
4446             INTO   l_serial_txn_temp_id
4447             FROM   DUAL;
4448 
4449             l_progress := '44';
4450             l_transaction_temp_id := l_serial_txn_temp_id;
4451           END IF;
4452 
4453           LOOP
4454             l_progress := '45';
4455             FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4456             l_progress := '46';
4457             EXIT WHEN l_curs_serial_number%NOTFOUND;
4458             l_serial_number_count := l_serial_number_count + 1;
4459             l_msnt_transaction_temp_id(l_serial_number_count) := l_serial_txn_temp_id;
4460             l_msnt_last_update_date(l_serial_number_count) := SYSDATE;
4461             l_msnt_last_updated_by(l_serial_number_count) := fnd_global.user_id;
4462             l_msnt_creation_date(l_serial_number_count) := SYSDATE;
4463             l_msnt_created_by(l_serial_number_count) := fnd_global.user_id;
4464             l_msnt_fm_serial_number(l_serial_number_count) := l_serial_number;
4465             l_msnt_to_serial_number(l_serial_number_count) := l_serial_number;
4466           END LOOP;
4467 
4468           IF (l_debug = 1) THEN
4469             print_debug('create_asn_exp_dd_intf_rec 27.2 - Number of serial temp records : ' || l_msnt_transaction_temp_id.COUNT, 4);
4470           END IF;
4471 
4472           CLOSE l_curs_serial_number;
4473           l_progress := '47';
4474           FORALL i IN 1 .. l_msnt_transaction_temp_id.COUNT
4475             INSERT INTO mtl_serial_numbers_temp
4476                         (
4477                          transaction_temp_id
4478                        , last_update_date
4479                        , last_updated_by
4480                        , creation_date
4481                        , created_by
4482                        , fm_serial_number
4483                        , to_serial_number
4484                         )
4485             VALUES      (
4486                          l_msnt_transaction_temp_id(i)
4487                        , l_msnt_last_update_date(i)
4488                        , l_msnt_last_updated_by(i)
4489                        , l_msnt_creation_date(i)
4490                        , l_msnt_created_by(i)
4491                        , l_msnt_fm_serial_number(i)
4492                        , l_msnt_to_serial_number(i)
4493                         );
4494           l_progress := '48';
4495           FORALL i IN 1 .. l_msnt_transaction_temp_id.COUNT
4496             UPDATE mtl_serial_numbers
4497             SET group_mark_id = l_serial_txn_temp_id
4498             WHERE  inventory_item_id = l_inventory_item_id
4499             AND    serial_number = l_msnt_fm_serial_number(i);
4500           l_progress := '49';
4501         END IF;   --END IF item is serial controlled
4502 
4503       --INV J and PO J are installed. So create interface records MTLI and MSNI
4504       --instead of temp records
4505       ELSE
4506         --Reset the variables that store the IDs
4507         l_transaction_interface_id := NULL;
4508         l_serial_transaction_temp_id := NULL;
4509         l_product_transaction_id := NULL;
4510 
4511         IF l_lot_control_code > 1 THEN
4512           IF l_lot_number IS NOT NULL THEN
4513             --Convert the lot quantity into Item's Primary UOM code
4514             IF l_uom_code <> l_primary_uom_code THEN
4515               l_lot_prm_quantity := inv_convert.inv_um_convert(
4516                     item_id       =>  l_inventory_item_id
4517                   , precision     =>  NULL
4518                   , from_quantity =>  l_quantity
4519                   , from_unit     =>  l_uom_code
4520                   , to_unit       =>  l_primary_uom_code
4521                   , from_name     =>  NULL
4522                   , to_name       =>  NULL);
4523 
4524               --Check for failure
4525               IF l_lot_prm_quantity = -99999 THEN
4526                 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
4527                 fnd_msg_pub.ADD;
4528                 IF (l_debug = 1) THEN
4529                   print_debug('create_asn_exp_rcpt_intf_rec: 20.2 - txn/primary uom conversion failed', 4);
4530                 END IF;
4531                 RAISE fnd_api.g_exc_error;
4532               END IF;   --END IF check for failure
4533 
4534             ELSE
4535               l_lot_prm_quantity := l_quantity;
4536             END IF;
4537 
4538              IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
4539               l_from_org_id := l_lpn_org;
4540             ELSE
4541               l_from_org_id := p_organization_id;
4542             END IF;
4543 
4544             --Create MTLI record for the lot and the lot quantity for this content
4545             --Set the flag for the API to populate the lot attributes
4546             inv_rcv_integration_apis.insert_mtli(
4547                 p_api_version                 =>  1.0
4548               , p_init_msg_lst                =>  FND_API.G_FALSE
4549               , x_return_status               =>  l_return_status
4550               , x_msg_count                   =>  l_msg_count
4551               , x_msg_data                    =>  l_msg_data
4552               , p_transaction_interface_id    =>  l_transaction_interface_id
4553               , p_lot_number                  =>  l_lot_number
4554               , p_transaction_quantity        =>  l_quantity
4555               , p_primary_quantity            =>  l_lot_prm_quantity
4556 	      , p_secondary_quantity          =>  l_secondary_quantity   --Bug 7656734
4557               , p_organization_id             =>  l_from_org_id
4558               , p_inventory_item_id           =>  l_inventory_item_id
4559               , p_expiration_date             =>  l_lot_expiration_date
4560               , p_status_id                   =>  l_lot_status_id
4561               , x_serial_transaction_temp_id  =>  l_serial_transaction_temp_id
4562               , p_product_transaction_id      =>  l_product_transaction_id
4563               , p_product_code                =>  'RCV'
4564               , p_att_exist                   =>  'Y'
4565               , p_update_mln                  =>  'N'
4566             );
4567 
4568             IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4569               IF (l_debug = 1) THEN
4570                 print_debug('create_asn_exp_dd_intf_rec 28.1: Error in MTLI creation', 4);
4571               END IF;
4572               RAISE FND_API.G_EXC_ERROR;
4573             END IF;
4574 
4575             IF (l_debug = 1) THEN
4576               print_debug('create_asn_exp_dd_intf_rec 28.2: txn i/f id: ' || l_transaction_interface_id
4577                             || ' serial temp : ' || l_serial_transaction_temp_id || ' prod txn id: ' || l_product_transaction_id, 4);
4578             END IF;
4579           END IF;   --END IF l_lot_number IS NOT NULL
4580 
4581           --Create MSNI records for the serials within lots
4582           --Bug #3405320
4583           --Create MSNI records even if serial control code is dynamic at SO Issue in
4584           --receiving org if there are serials shipped
4585           IF ((l_serial_control_code IN (2, 5)) OR
4586               (l_serial_control_code = 6 AND p_source_type IN ('INTERNAL', 'INVENTORY'))) THEN
4587 	          -- bug 3196554
4588 	          OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4589             --Loop through the serials in the lot
4590             LOOP
4591               FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4592               EXIT WHEN l_curs_serial_number%NOTFOUND;
4593 	            IF (l_debug = 1) THEN
4594 		            print_debug('create_asn_exp_dd_intf_rec 28.2.1: Before MSNI creation', 4);
4595 	            END IF;
4596               --For each serial number in the lot create one MSNI record. The
4597               --serial attributes would be populated by the API
4598               inv_rcv_integration_apis.insert_msni(
4599                   p_api_version                 =>  1.0
4600                 , p_init_msg_lst                =>  FND_API.G_FALSE
4601                 , x_return_status               =>  l_return_status
4602                 , x_msg_count                   =>  l_msg_count
4603                 , x_msg_data                    =>  l_msg_data
4604                 , p_transaction_interface_id    =>  l_serial_transaction_temp_id
4605                 , p_fm_serial_number            =>  l_serial_number
4606                 , p_to_serial_number            =>  l_serial_number
4607                 , p_organization_id             =>  p_organization_id
4608                 , p_inventory_item_id           =>  l_inventory_item_id
4609                 , p_status_id                   =>  l_serial_status_id
4610                 , p_product_transaction_id      =>  l_product_transaction_id
4611                 , p_product_code                =>  'RCV'
4612                 , p_att_exist                   =>  'Y'
4613                 , p_update_msn                  =>  'N'
4614               );
4615 
4616               IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4617                 IF (l_debug = 1) THEN
4618                   print_debug('create_asn_exp_dd_intf_rec 28.3: Error in MSNI creation', 4);
4619                 END IF;
4620                 RAISE FND_API.G_EXC_ERROR;
4621               END IF;
4622             END LOOP;   --END LOOP through serials for the lot
4623 
4624             --Close the serial cursor
4625             IF l_curs_serial_number%ISOPEN THEN
4626               CLOSE l_curs_serial_number;
4627             END IF;
4628           END IF;   --END IF item is lot and serial controlled
4629 
4630       	  -- bug 3180322
4631       	  -- This code was inside the serial control and lot control
4632       	  -- However we should be setting this variable irrespective of
4633       	  -- whether it is lot and serial control or just lot controlled
4634       	  --Set the variable l_transaction_temp_id that should be passed to
4635       	  --create_asn_con_dd_intf_rec to product_transaction_id since lots
4636       	  --and serials would be split based on this value
4637       	  l_transaction_temp_id := l_product_transaction_id;
4638 
4639         --If the item is serial controlled, loop through the serials within
4640         --the LPN and create one MSNI record for each serial number
4641         --The attributes for each serial number would be fetched by the API
4642         ELSIF (l_serial_control_code IN (2, 5) OR
4643                l_serial_control_code = 6 AND p_source_type IN ('INTERNAL', 'INVENTORY')) THEN
4644 	        -- bug 3196554
4645 	        OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
4646           --Loop through the serials in the lot
4647           LOOP
4648             FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
4649             EXIT WHEN l_curs_serial_number%NOTFOUND;
4650             --For each serial number in the lot create one MSNI record. The
4651             --serial attributes would be populated by the API
4652  	          IF (l_debug = 1) THEN
4653 	            print_debug('create_asn_exp_dd_intf_rec 28.3.1: Before MSNI creation', 4);
4654 	          END IF;
4655             inv_rcv_integration_apis.insert_msni(
4656                 p_api_version                 =>  1.0
4657               , p_init_msg_lst                =>  FND_API.G_FALSE
4658               , x_return_status               =>  l_return_status
4659               , x_msg_count                   =>  l_msg_count
4660               , x_msg_data                    =>  l_msg_data
4661               , p_transaction_interface_id    =>  l_transaction_interface_id
4662               , p_fm_serial_number            =>  l_serial_number
4663               , p_to_serial_number            =>  l_serial_number
4664               , p_organization_id             =>  p_organization_id
4665               , p_inventory_item_id           =>  l_inventory_item_id
4666               , p_status_id                   =>  l_serial_status_id
4667               , p_product_transaction_id      =>  l_product_transaction_id
4668               , p_product_code                =>  'RCV'
4669               , p_att_exist                   =>  'Y'
4670               , p_update_msn                  =>  'N'
4671             );
4672 
4673             IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4674               IF (l_debug = 1) THEN
4675                 print_debug('create_asn_exp_dd_intf_rec 28.4: Error in MSNI creation', 4);
4676               END IF;
4677               RAISE FND_API.G_EXC_ERROR;
4678             END IF;
4679             IF (l_debug = 1) THEN
4680               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);
4681             END IF;
4682           END LOOP;   --END LOOP through serials for the LPN
4683 
4684           --Set the variable l_transaction_temp_id that should be passed to
4685           --create_asn_con_dd_intf_rec to product_transaction_id since lots
4686           --and serials would be split based on this value
4687           l_transaction_temp_id := l_product_transaction_id;
4688 
4689           --Close the serial cursor
4690           IF l_curs_serial_number%ISOPEN THEN
4691             CLOSE l_curs_serial_number;
4692           END IF;
4693         END IF;    --END IF check lot and serial control codes
4694       END IF;   --END IF check INV patchset J and PO patchset J are installed
4695 
4696       IF (l_debug = 1) THEN
4697         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);
4698       END IF;
4699 
4700       -- If subinventory is Non-LPN controlled then pass to_lpn
4701 
4702       IF (l_lpn_controlled_flag = 2) THEN
4703         l_to_lpn_id  := NULL ;
4704       ELSE
4705         l_to_lpn_id := l_lpn_id;
4706       END IF;
4707 
4708       -- Nested LPN changes.
4709       -- Passed new parameter p_from_lpn_id also as l_lpn_id
4710       create_asn_con_dd_intf_rec(
4711         p_move_order_header_id     => p_move_order_header_id
4712       , p_organization_id          => p_organization_id
4713       , p_shipment_header_id       => p_shipment_header_id
4714       , p_po_header_id             => l_po_header_id
4715       , p_item_id                  => l_inventory_item_id
4716       , p_rcv_qty                  => l_quantity
4717       , p_rcv_uom                  => l_unit_of_measure
4718       , p_rcv_uom_code             => l_uom_code
4719       , p_source_type              => p_source_type
4720       , p_subinventory             => p_subinventory
4721       , p_locator_id               => p_locator_id
4722       , p_from_lpn_id              => l_lpn_id
4723       , p_lpn_id                   => l_to_lpn_id
4724       , p_lot_control_code         => l_lot_control_code
4725       , p_serial_control_code      => l_serial_control_code
4726       , p_revision                 => l_revision
4727       , p_transaction_temp_id      => NVL(l_transaction_temp_id, p_transaction_temp_id)
4728       , x_status                   => l_return_status
4729       , x_message                  => l_msg_data
4730       , p_project_id               => p_project_id
4731       , p_task_id                  => p_task_id
4732       , p_attribute_category       => p_attribute_category  --Bug #4147209
4733       , p_attribute1               => p_attribute1
4734       , p_attribute2               => p_attribute2
4735       , p_attribute3               => p_attribute3
4736       , p_attribute4               => p_attribute4
4737       , p_attribute5               => p_attribute5
4738       , p_attribute6               => p_attribute6
4739       , p_attribute7               => p_attribute7
4740       , p_attribute8               => p_attribute8
4741       , p_attribute9               => p_attribute9
4742       , p_attribute10              => p_attribute10
4743       , p_attribute11              => p_attribute11
4744       , p_attribute12              => p_attribute12
4745       , p_attribute13              => p_attribute13
4746       , p_attribute14              => p_attribute14
4747       , p_attribute15              => p_attribute15
4748       , p_express_transaction       => 'Y'--Bug 5550783
4749       );
4750 
4751       IF l_return_status = fnd_api.g_ret_sts_error THEN
4752         fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4753         fnd_msg_pub.ADD;
4754 
4755         IF (l_debug = 1) THEN
4756           print_debug(
4757                'create_asn_exp_dd_intf_rec 40.1:create_asn_con_dd_intf_rec  RAISE FND_API.G_EXC_ERROR;'
4758             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4759           , 4
4760           );
4761         END IF;
4762 
4763         RAISE fnd_api.g_exc_error;
4764       END IF;
4765 
4766       IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4767         fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4768         fnd_msg_pub.ADD;
4769 
4770         IF (l_debug = 1) THEN
4771           print_debug(
4772                'create_asn_exp_dd_intf_rec 40.2: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
4773             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4774           , 4
4775           );
4776         END IF;
4777 
4778         RAISE fnd_api.g_exc_unexpected_error;
4779       END IF;
4780 
4781       IF (l_debug = 1) THEN
4782         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')
4783         , 4);
4784       END IF;
4785     END LOOP;
4786 
4787     --BUG 4567903: Need to set the status so that the UI will show the
4788     --correct messages
4789     x_status := l_return_status;
4790     IF (l_debug = 1) THEN
4791        print_debug('x_status:'||x_status,4);
4792        print_debug('x_message:'||x_message,4);
4793     END IF;
4794     --END BUG 4567903
4795 
4796     -- Nested LPN changes, If INVJ,POJ,WMSJ Installed then
4797     -- insert WLPNI for FromLPN with parent as NULL.
4798 
4799     IF inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po
4800        AND inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j
4801        AND inv_rcv_common_apis.g_wms_patch_level >= inv_rcv_common_apis.g_patchset_j THEN
4802       IF (l_debug = 1) THEN
4803         print_debug(
4804              'create_asn_exp_dd_intf_rec: 50.1 - Before inserting into wlpni for p_lpn_id with parent NULL '
4805           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4806       END IF;
4807 
4808       IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
4809 	 l_from_org_id := l_lpn_org;
4810        ELSE
4811 	 l_from_org_id := p_organization_id;
4812       END IF;
4813 
4814       -- Nested LPN changes. Insert WLPNI
4815       inv_rcv_integration_apis.insert_wlpni(
4816           p_api_version           => 1.0
4817          ,x_return_status         => l_return_status
4818          ,x_msg_count             => l_msg_count
4819          ,x_msg_data              => l_msg_data
4820          ,p_organization_id       => l_from_org_id -- BUG 4096028: should
4821 					           -- from org_id
4822          ,p_lpn_id                => p_lpn_id
4823          ,p_license_plate_number  => NULL
4824          ,p_lpn_group_id          => inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4825          ,p_parent_lpn_id         => NULL
4826          );
4827 
4828       IF l_return_status = fnd_api.g_ret_sts_error THEN
4829         fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
4830         fnd_msg_pub.ADD;
4831 
4832         IF (l_debug = 1) THEN
4833           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);
4834         END IF;
4835 
4836         RAISE fnd_api.g_exc_error;
4837       END IF;
4838 
4839       IF (l_debug = 1) THEN
4840         print_debug(
4841              'create_asn_exp_dd_intf_rec: 50.1 - After inserting into wlpni for p_lpn_id with parent NULL '
4842           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4843       END IF;
4844     END IF;
4845 
4846     l_progress := '60';
4847 
4848     IF l_curs_asn_lpn_content%ISOPEN THEN
4849       CLOSE l_curs_asn_lpn_content;
4850     END IF;
4851 
4852     l_progress := '70';
4853 
4854     -- UPDATE lpn context
4855 
4856 
4857     IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
4858        OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
4859        OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
4860 
4861       UPDATE wms_license_plate_numbers
4862       SET lpn_context = 3
4863       WHERE  source_header_id = p_shipment_header_id
4864       AND    lpn_id = NVL(p_lpn_id, lpn_id);
4865 
4866       l_progress := '80';
4867 
4868       -- UPDATE the lpn history table with source name as ASNEXP since no packing happened.
4869       -- This is needed to help the cleanup later on
4870       -- Nothing else is updated to keep in synch with license_plate_number update
4871 
4872       IF (l_debug = 1) THEN
4873         print_debug(' create_asn_exp_dd_intf_rec: Before Update lpn history  ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4874         print_debug(
4875              ' create_asn_exp_dd_intf_rec: Group_id = '
4876           || inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4877           || ' '
4878           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4879       END IF;
4880 
4881       UPDATE wms_lpn_histories
4882       SET source_name = 'ASNEXP'
4883         , source_header_id = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4884       WHERE  lpn_context = 7
4885       AND    parent_lpn_id IN(SELECT lpn_id
4886                               FROM   wms_license_plate_numbers
4887                               WHERE  source_header_id = p_shipment_header_id
4888                               AND    lpn_id = NVL(p_lpn_id, lpn_id));
4889     END IF;
4890 
4891     IF (l_debug = 1) THEN
4892       print_debug('Exit create_asn_exp_dd_intf_rec: 90 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4893     END IF;
4894   EXCEPTION
4895     WHEN fnd_api.g_exc_error THEN
4896       x_status := fnd_api.g_ret_sts_error;
4897 
4898       IF l_curs_asn_lpn_content%ISOPEN THEN
4899         CLOSE l_curs_asn_lpn_content;
4900       END IF;
4901 
4902       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4903 
4904       IF (l_debug = 1) THEN
4905         print_debug('create_asn_exp_dd_intf_rec:  FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4906       END IF;
4907     WHEN fnd_api.g_exc_unexpected_error THEN
4908       x_status := fnd_api.g_ret_sts_unexp_error;
4909 
4910       IF l_curs_asn_lpn_content%ISOPEN THEN
4911         CLOSE l_curs_asn_lpn_content;
4912       END IF;
4913 
4914       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4915 
4916       IF (l_debug = 1) THEN
4917         print_debug('create_asn_exp_dd_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4918       END IF;
4919     WHEN OTHERS THEN
4920       x_status := fnd_api.g_ret_sts_unexp_error;
4921 
4922       IF l_curs_asn_lpn_content%ISOPEN THEN
4923         CLOSE l_curs_asn_lpn_content;
4924       END IF;
4925 
4926       IF SQLCODE IS NOT NULL THEN
4927         inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_exp_dd_intf_rec', l_progress, SQLCODE);
4928       END IF;
4929 
4930       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
4931 
4932       IF (l_debug = 1) THEN
4933         print_debug('create_asn_exp_dd_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4934       END IF;
4935   END create_asn_exp_dd_intf_rec;
4936 
4937   PROCEDURE create_osp_direct_rti_rec(
4938     p_move_order_header_id  IN OUT NOCOPY  NUMBER
4939   , p_organization_id       IN             NUMBER
4940   , p_po_header_id          IN             NUMBER
4941   , p_po_release_id         IN             NUMBER
4942   , p_po_line_id            IN             NUMBER
4943   , p_item_id               IN             NUMBER
4944   , p_rcv_qty               IN             NUMBER
4945   , p_rcv_uom               IN             VARCHAR2
4946   , p_rcv_uom_code          IN             VARCHAR2
4947   , p_source_type           IN             VARCHAR2
4948   , p_transaction_temp_id   IN             NUMBER
4949   , p_revision              IN             VARCHAR2
4950   , p_po_distribution_id    IN             NUMBER
4951   , x_status                OUT NOCOPY     VARCHAR2
4952   , x_message               OUT NOCOPY     VARCHAR2
4953   , p_attribute_category    IN             VARCHAR2  DEFAULT NULL  --Bug #4147209
4954   , p_attribute1            IN             VARCHAR2  DEFAULT NULL
4955   , p_attribute2            IN             VARCHAR2  DEFAULT NULL
4956   , p_attribute3            IN             VARCHAR2  DEFAULT NULL
4957   , p_attribute4            IN             VARCHAR2  DEFAULT NULL
4958   , p_attribute5            IN             VARCHAR2  DEFAULT NULL
4959   , p_attribute6            IN             VARCHAR2  DEFAULT NULL
4960   , p_attribute7            IN             VARCHAR2  DEFAULT NULL
4961   , p_attribute8            IN             VARCHAR2  DEFAULT NULL
4962   , p_attribute9            IN             VARCHAR2  DEFAULT NULL
4963   , p_attribute10           IN             VARCHAR2  DEFAULT NULL
4964   , p_attribute11           IN             VARCHAR2  DEFAULT NULL
4965   , p_attribute12           IN             VARCHAR2  DEFAULT NULL
4966   , p_attribute13           IN             VARCHAR2  DEFAULT NULL
4967   , p_attribute14           IN             VARCHAR2  DEFAULT NULL
4968   , p_attribute15           IN             VARCHAR2  DEFAULT NULL
4969   ) IS
4970     l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
4971     l_msg_count     NUMBER;
4972     l_msg_data      VARCHAR2(400);
4973     l_label_status  VARCHAR2(500);
4974     l_progress      VARCHAR2(10);
4975     l_txn_id_tbl    inv_label.transaction_id_rec_type;
4976     l_counter       NUMBER := 0;
4977 
4978     CURSOR c_rti_txn_id IS
4979       /* Bug 2443163 */
4980       /* SELECT MIN(rti.interface_transaction_id) */
4981       /* Group BY LPN_ID is changed for Express Receipts */
4982       /* Also  duplicate print of LPN labels is avoided */
4983       SELECT   MAX(rti.interface_transaction_id)
4984       FROM     rcv_transactions_interface rti
4985       WHERE    rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
4986       GROUP BY DECODE(p_source_type, 'ASNEXP', rti.interface_transaction_id, 'SHIPMENTEXP', rti.interface_transaction_id, NULL);
4987     -- GROUP BY rti.lpn_id;
4988 
4989     l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4990   BEGIN
4991     x_status := fnd_api.g_ret_sts_success;
4992     l_progress := '10';
4993 
4994     IF (l_debug = 1) THEN
4995       print_debug('create_osp_direct_rti_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4996     END IF;
4997 
4998     IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
4999        --BUG 3440184: For performance reason, use the follow query
5000        --instead of gl_sets_of_books
5001        SELECT TO_NUMBER(hoi.org_information1)
5002 	 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
5003 	 FROM hr_organization_information hoi
5004 	 WHERE hoi.organization_id = p_organization_id
5005 	 AND (hoi.org_information_context || '') = 'Accounting Information';
5006 
5007       --SELECT ood.set_of_books_id
5008       --INTO   inv_rcv_common_apis.g_po_startup_value.sob_id
5009       --FROM   org_organization_definitions ood, gl_sets_of_books sob
5010       --WHERE  organization_id = p_organization_id
5011       --AND    sob.set_of_books_id = ood.set_of_books_id;
5012     END IF;
5013 
5014     l_progress := '10';
5015     -- first check if the transaction date satisfies the validation.
5016     inv_rcv_common_apis.validate_trx_date(
5017       p_trx_date            => SYSDATE
5018     , p_organization_id     => p_organization_id
5019     , p_sob_id              => inv_rcv_common_apis.g_po_startup_value.sob_id
5020     , x_return_status       => x_status
5021     , x_error_code          => x_message
5022     );
5023 
5024     IF x_status <> fnd_api.g_ret_sts_success THEN
5025       RETURN;
5026     END IF;
5027 
5028     IF p_po_header_id IS NULL
5029        AND p_item_id IS NULL THEN
5030       IF (l_debug = 1) THEN
5031         print_debug('create_osp_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
5032       END IF;
5033 
5034       x_status := fnd_api.g_ret_sts_error;
5035       RETURN;
5036     END IF;
5037 
5038     l_progress := '30';
5039     create_osp_drct_dlvr_rti_rec(
5040       p_move_order_header_id     => p_move_order_header_id
5041     , p_organization_id          => p_organization_id
5042     , p_po_header_id             => p_po_header_id
5043     , p_po_release_id            => p_po_release_id
5044     , p_po_line_id               => p_po_line_id
5045     , p_po_line_location_id      => NULL
5046     , p_po_distribution_id       => p_po_distribution_id
5047     , p_item_id                  => p_item_id
5048     , p_rcv_qty                  => p_rcv_qty
5049     , p_rcv_uom                  => p_rcv_uom
5050     , p_rcv_uom_code             => p_rcv_uom_code
5051     , p_source_type              => p_source_type
5052     , p_transaction_temp_id      => p_transaction_temp_id
5053     , p_revision                 => p_revision
5054     , x_status                   => l_return_status
5055     , x_message                  => x_message
5056     , p_attribute_category       => p_attribute_category  --Bug #4147209
5057     , p_attribute1               => p_attribute1
5058     , p_attribute2               => p_attribute2
5059     , p_attribute3               => p_attribute3
5060     , p_attribute4               => p_attribute4
5061     , p_attribute5               => p_attribute5
5062     , p_attribute6               => p_attribute6
5063     , p_attribute7               => p_attribute7
5064     , p_attribute8               => p_attribute8
5065     , p_attribute9               => p_attribute9
5066     , p_attribute10              => p_attribute10
5067     , p_attribute11              => p_attribute11
5068     , p_attribute12              => p_attribute12
5069     , p_attribute13              => p_attribute13
5070     , p_attribute14              => p_attribute14
5071     , p_attribute15              => p_attribute15
5072     );
5073 
5074     IF l_return_status = fnd_api.g_ret_sts_error THEN
5075       fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5076       fnd_msg_pub.ADD;
5077 
5078       IF (l_debug = 1) THEN
5079         print_debug(
5080              'create_osp_direct_rti_rec 20.1: create_osp_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
5081           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5082       END IF;
5083 
5084       RAISE fnd_api.g_exc_error;
5085     END IF;
5086 
5087     IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5088       fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5089       fnd_msg_pub.ADD;
5090 
5091       IF (l_debug = 1) THEN
5092         print_debug(
5093              'create_osp_direct_rti_rec 20.2: create_osp_drct_dlvr_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5094           || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5095       END IF;
5096 
5097       RAISE fnd_api.g_exc_unexpected_error;
5098     END IF;
5099 
5100     l_progress := '40';
5101 
5102     IF (l_debug = 1) THEN
5103       print_debug('create_osp_direct_rti_rec calling print_label: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5104     END IF;
5105 
5106     x_status := l_return_status; -- l_return_status can be 'W', we want to carry that over
5107                                  -- calling label printing API
5108 
5109     IF l_return_status <> fnd_api.g_ret_sts_error THEN
5110       l_progress := '40';
5111 
5112       IF (l_debug = 1) THEN
5113         print_debug(
5114           'create_osp_direct_rti_rec: 8.1 before  inv_label.print_label ' || inv_rcv_common_apis.g_rcv_global_var.interface_group_id, 4);
5115       END IF;
5116 
5117       /* FP-J Lot/Serial Support Enhancement
5118        * If INV J and PO J are installed, do not call label printing API at this stage
5119        */
5120       IF ((inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po) OR
5121           (inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j)) THEN
5122 
5123        IF (p_source_type <> 'VENDOR') THEN --Bug #4079952 ..For PO receipt, code in rcv_insert_update_header(INVSTDRB.pls) will be called.
5124         l_counter := 1;
5125         OPEN c_rti_txn_id;
5126 
5127         LOOP
5128           FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
5129           EXIT WHEN c_rti_txn_id%NOTFOUND;
5130 
5131           IF (l_debug = 1) THEN
5132             print_debug('create_osp_direct_rti_rec calling printing for:' || l_txn_id_tbl(l_counter), 4);
5133           END IF;
5134 
5135           l_counter := l_counter + 1;
5136         END LOOP;
5137 
5138         CLOSE c_rti_txn_id;
5139         inv_label.print_label(
5140           x_return_status          => l_return_status
5141         , x_msg_count              => l_msg_count
5142         , x_msg_data               => l_msg_data
5143         , x_label_status           => l_label_status
5144         , p_api_version            => 1.0
5145         , p_print_mode             => 1
5146         , p_business_flow_code     => 1
5147         , p_transaction_id         => l_txn_id_tbl
5148         );
5149 
5150         IF l_return_status <> fnd_api.g_ret_sts_success THEN
5151           fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
5152           fnd_msg_pub.ADD;
5153           x_status := 'W';
5154 
5155           IF (l_debug = 1) THEN
5156             print_debug('create_osp_direct_rti_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5157           END IF;   --END IF l_debug = 1
5158         END IF;   --END IF label ret_status <> S
5159        END IF ; --Bug #4079952
5160       ELSE
5161         IF (l_debug = 1) THEN
5162           print_debug('INV J and PO J are installed. NO label printing from UI', 4);
5163         END IF;
5164       END IF;   --END IF INV J and PO J installed
5165     END IF;   --END IF ret_status = Success
5166 
5167     IF (l_debug = 1) THEN
5168       print_debug('create_osp_direct_rti_rec exiting print_label: 7' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5169     END IF;
5170 
5171     IF (l_debug = 1) THEN
5172       print_debug('About exit create_osp_direct_rti_rec: 8' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5173       print_debug('create_osp_direct_rti_rec: 8.1   - x_status = ' || x_status, 4);
5174       print_debug('create_osp_direct_rti_rec: 8.2   -  x_message= ' || x_message, 4);
5175     END IF;
5176   EXCEPTION
5177     WHEN fnd_api.g_exc_error THEN
5178       x_status := fnd_api.g_ret_sts_error;
5179       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5180     WHEN fnd_api.g_exc_unexpected_error THEN
5181       x_status := fnd_api.g_ret_sts_unexp_error;
5182       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5183     WHEN OTHERS THEN
5184       x_status := fnd_api.g_ret_sts_unexp_error;
5185 
5186       IF SQLCODE IS NOT NULL THEN
5187         inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_osp_direct_rti_rec', l_progress, SQLCODE);
5188       END IF;
5189 
5190       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5191   END create_osp_direct_rti_rec;
5192 
5193   PROCEDURE create_direct_rti_rec(
5194     p_move_order_header_id  IN OUT NOCOPY  NUMBER
5195   , p_organization_id       IN             NUMBER
5196   , p_po_header_id          IN             NUMBER
5197   , p_po_release_id         IN             NUMBER
5198   , p_po_line_id            IN             NUMBER
5199   , p_shipment_header_id    IN             NUMBER
5200   , p_oe_order_header_id    IN             NUMBER
5201   , p_item_id               IN             NUMBER
5202   , p_rcv_qty               IN             NUMBER
5203   , p_rcv_uom               IN             VARCHAR2
5204   , p_rcv_uom_code          IN             VARCHAR2
5205   , p_source_type           IN             VARCHAR2
5206   , p_subinventory          IN             VARCHAR2
5207   , p_locator_id            IN             NUMBER
5208   , p_transaction_temp_id   IN             NUMBER
5209   , p_lot_control_code      IN             NUMBER
5210   , p_serial_control_code   IN             NUMBER
5211   , p_lpn_id                IN             NUMBER
5212   , p_revision              IN             VARCHAR2
5213   , x_status                OUT NOCOPY     VARCHAR2
5214   , x_message               OUT NOCOPY     VARCHAR2
5215   , p_inv_item_id           IN             NUMBER DEFAULT NULL
5216   , p_item_desc             IN             VARCHAR2 DEFAULT NULL
5217   , p_location_id           IN             NUMBER DEFAULT NULL
5218   , p_is_expense            IN             VARCHAR2 DEFAULT NULL
5219   , p_project_id            IN             NUMBER DEFAULT NULL
5220   , p_task_id               IN             NUMBER DEFAULT NULL
5221   , p_country_code          IN             VARCHAR2 DEFAULT NULL
5222   , p_from_lpn_id           IN             NUMBER -- Nested LPN changes
5223   , p_secondary_rcv_qty     IN             NUMBER --OPM Convergence
5224   , p_rcv_sec_uom           IN             VARCHAR2 --OPM Convergence
5225   , p_rcv_sec_uom_code      IN             VARCHAR2 --OPM Convergence
5226   , p_attribute_category    IN             VARCHAR2  DEFAULT NULL  --Bug #4147209 - DFF cols
5227   , p_attribute1            IN             VARCHAR2  DEFAULT NULL
5228   , p_attribute2            IN             VARCHAR2  DEFAULT NULL
5229   , p_attribute3            IN             VARCHAR2  DEFAULT NULL
5230   , p_attribute4            IN             VARCHAR2  DEFAULT NULL
5231   , p_attribute5            IN             VARCHAR2  DEFAULT NULL
5232   , p_attribute6            IN             VARCHAR2  DEFAULT NULL
5233   , p_attribute7            IN             VARCHAR2  DEFAULT NULL
5234   , p_attribute8            IN             VARCHAR2  DEFAULT NULL
5235   , p_attribute9            IN             VARCHAR2  DEFAULT NULL
5236   , p_attribute10           IN             VARCHAR2  DEFAULT NULL
5237   , p_attribute11           IN             VARCHAR2  DEFAULT NULL
5238   , p_attribute12           IN             VARCHAR2  DEFAULT NULL
5239   , p_attribute13           IN             VARCHAR2  DEFAULT NULL
5240   , p_attribute14           IN             VARCHAR2  DEFAULT NULL
5241   , p_attribute15           IN             VARCHAR2  DEFAULT NULL
5242   ) IS
5243     l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
5244     l_msg_count     NUMBER;
5245     l_msg_data      VARCHAR2(400);
5246     l_label_status  VARCHAR2(500);
5247     l_progress      VARCHAR2(10);
5248     l_txn_id_tbl    inv_label.transaction_id_rec_type;
5249     l_counter       NUMBER      := 0;
5250     l_subinventory  VARCHAR2(10);
5251     l_locator_id    NUMBER;
5252 
5253 -- For LCM
5254     l_tx_type       VARCHAR2(40);
5255 -- END FOR LCM
5256 
5257 
5258     CURSOR c_rti_txn_id IS
5259       /* Bug 2443163 */
5260       /* SELECT MIN(rti.interface_transaction_id) */
5261       /* Group BY LPN_ID is changed for Express Receipts */
5262       /* Also  duplicate print of LPN labels is avoided */
5263       SELECT   MAX(rti.interface_transaction_id)
5264       FROM     rcv_transactions_interface rti
5265       WHERE    rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
5266       GROUP BY DECODE(p_source_type, 'ASNEXP', rti.interface_transaction_id, 'SHIPMENTEXP', rti.interface_transaction_id, NULL);
5267 
5268     -- GROUP BY rti.lpn_id;
5269     l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5270   BEGIN
5271     x_status := fnd_api.g_ret_sts_success;
5272     l_progress := '10';
5273 
5274     IF (l_debug = 1) THEN
5275       print_debug('create_direct_rti_rec: 10' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5276     END IF;
5277 
5278     IF (l_debug = 1) THEN
5279       print_debug('txn temp id: ' || p_transaction_temp_id, 4);
5280     END IF;
5281 
5282     IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
5283 
5284       --BUG 3440184: For performance reason, use the follow query
5285       --instead of gl_sets_of_books
5286 
5287       SELECT TO_NUMBER(hoi.org_information1)
5288       INTO   inv_rcv_common_apis.g_po_startup_value.sob_id
5289       FROM hr_organization_information hoi
5290       WHERE hoi.organization_id = p_organization_id
5291         AND (hoi.org_information_context || '') = 'Accounting Information';
5292 
5293       -- SELECT ood.set_of_books_id
5294       -- INTO   inv_rcv_common_apis.g_po_startup_value.sob_id
5295       -- FROM   org_organization_definitions ood, gl_sets_of_books sob
5296       -- WHERE  organization_id = p_organization_id
5297       -- AND    sob.set_of_books_id = ood.set_of_books_id;
5298 
5299     END IF;
5300 
5301     l_progress := '10';
5302     -- first check if the transaction date satisfies the validation.
5303     inv_rcv_common_apis.validate_trx_date(
5304       p_trx_date            => SYSDATE
5305     , p_organization_id     => p_organization_id
5306     , p_sob_id              => inv_rcv_common_apis.g_po_startup_value.sob_id
5307     , x_return_status       => x_status
5308     , x_error_code          => x_message
5309     );
5310 
5311     IF x_status <> fnd_api.g_ret_sts_success THEN
5312       RETURN;
5313     END IF;
5314 
5315     IF p_shipment_header_id IS NULL THEN -- Added this check to fix bug no. 2159179
5316       IF p_po_header_id IS NULL
5317          AND p_item_id IS NULL THEN
5318         IF (l_debug = 1) THEN
5319           print_debug('create_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
5320         END IF;
5321 
5322         x_status := fnd_api.g_ret_sts_error;
5323         RETURN;
5324       END IF;
5325     END IF;
5326 
5327     l_progress := '30';
5328 
5329     IF p_po_header_id IS NOT NULL
5330        AND p_source_type <> 'ASNEXP'
5331        AND p_source_type <> 'LCMEXP'   -- For LCM Project
5332        AND p_source_type <> 'LCMCONFM' -- For LCM Project
5333        AND p_source_type <> 'ASNCONFM' -- bug fix 2129249
5334                                        THEN
5335       l_progress := '40';
5336 
5337       IF (l_debug = 1) THEN
5338         print_debug('create_direct_rti_rec: 4 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5339         print_debug('create_direct_rti_rec: 4.1  p_po_header_id = ' || p_po_header_id, 4);
5340       END IF;
5341 
5342       IF p_item_id IS NULL
5343          AND p_item_desc IS NULL THEN
5344         IF (l_debug = 1) THEN
5345           print_debug('create_direct_rti_rec: 2 item id and po number cannot be NULL', 4);
5346         END IF;
5347 
5348         x_status := fnd_api.g_ret_sts_error;
5349         RETURN;
5350       END IF;
5351 
5352       l_subinventory := p_subinventory;
5353       l_locator_id := p_locator_id;
5354 
5355       IF p_location_id IS NOT NULL THEN
5356         l_subinventory := '';
5357         l_locator_id := '';
5358       END IF;
5359 
5360       create_po_drct_dlvr_rti_rec(
5361         p_move_order_header_id     => p_move_order_header_id
5362       , p_organization_id          => p_organization_id
5363       , p_po_header_id             => p_po_header_id
5364       , p_po_release_id            => p_po_release_id
5365       , p_po_line_id               => p_po_line_id
5366       , p_po_line_location_id      => NULL
5367       , p_po_distribution_id       => NULL
5368       , p_item_id                  => p_item_id
5369       , p_rcv_qty                  => p_rcv_qty
5370       , p_rcv_uom                  => p_rcv_uom
5371       , p_rcv_uom_code             => p_rcv_uom_code
5372       , p_source_type              => p_source_type
5373       , p_subinventory             => l_subinventory
5374       , p_locator_id               => l_locator_id
5375       , p_transaction_temp_id      => p_transaction_temp_id
5376       , p_lot_control_code         => p_lot_control_code
5377       , p_serial_control_code      => p_serial_control_code
5378       , p_lpn_id                   => p_lpn_id
5379       , p_revision                 => p_revision
5380       , x_status                   => l_return_status
5381       , x_message                  => x_message
5382       , p_inv_item_id              => p_inv_item_id
5383       , p_item_desc                => p_item_desc
5384       , p_location_id              => p_location_id
5385       , p_is_expense               => p_is_expense
5386       , p_project_id               => p_project_id
5387       , p_task_id                  => p_task_id
5388       , p_country_code             => p_country_code
5389       , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5390       , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5391       , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5392       , p_attribute_category       => p_attribute_category  --Bug #4147209
5393       , p_attribute1               => p_attribute1
5394       , p_attribute2               => p_attribute2
5395       , p_attribute3               => p_attribute3
5396       , p_attribute4               => p_attribute4
5397       , p_attribute5               => p_attribute5
5398       , p_attribute6               => p_attribute6
5399       , p_attribute7               => p_attribute7
5400       , p_attribute8               => p_attribute8
5401       , p_attribute9               => p_attribute9
5402       , p_attribute10              => p_attribute10
5403       , p_attribute11              => p_attribute11
5404       , p_attribute12              => p_attribute12
5405       , p_attribute13              => p_attribute13
5406       , p_attribute14              => p_attribute14
5407       , p_attribute15              => p_attribute15
5408       );
5409 
5410       IF l_return_status = fnd_api.g_ret_sts_error THEN
5411         fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5412         fnd_msg_pub.ADD;
5413 
5414         IF (l_debug = 1) THEN
5415           print_debug(
5416                'create_direct_rti_rec 20.1: create_po_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
5417             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5418         END IF;
5419 
5420         RAISE fnd_api.g_exc_error;
5421       END IF;
5422 
5423       IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5424         fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5425         fnd_msg_pub.ADD;
5426 
5427         IF (l_debug = 1) THEN
5428           print_debug(
5429                'create_direct_rti_rec 20.2: create_po_drct_dlvr_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5430             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5431         END IF;
5432 
5433         RAISE fnd_api.g_exc_unexpected_error;
5434       END IF;
5435     ELSIF p_shipment_header_id IS NOT NULL THEN
5436       l_progress := '50';
5437 
5438       IF (l_debug = 1) THEN
5439         print_debug('create_direct_rti_rec: 22' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5440         print_debug('create_direct_rti_rec: 22.1  p_shipment_header_id = ' || p_shipment_header_id, 4);
5441       END IF;
5442 
5443       IF p_source_type = 'ASNEXP'
5444          OR p_source_type = 'LCMEXP'  -- For LCM Project
5445          OR p_source_type = 'SHIPMENTEXP'
5446          OR p_source_type = 'SHIPMENT'
5447          OR p_source_type = 'REQEXP' THEN
5448         IF p_source_type = 'ASNEXP' THEN
5449           IF (l_debug = 1) THEN
5450             print_debug(
5451               'create_direct_rti_rec: 23 - calling  create_asn_exp_dd_intf_rec for ASNEXP'
5452               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5453           END IF;
5454 
5455 -- For Bug 7440217 added code to handle LCM Doc also
5456       IF p_source_type = 'ASNEXP' THEN
5457            l_tx_type := 'ASN';
5458       ELSIF p_source_type = 'LCMEXP' THEN   -- For LCM Project
5459            l_tx_type := 'LCM';   -- For LCM Project
5460       END IF;
5461 -- End for Bug 7440217
5462 
5463           create_asn_exp_dd_intf_rec(
5464             p_move_order_header_id     => p_move_order_header_id
5465           , p_organization_id          => p_organization_id
5466           , p_shipment_header_id       => p_shipment_header_id
5467           , p_po_header_id             => p_po_header_id
5468           , p_source_type              => l_tx_type
5469           , p_subinventory             => p_subinventory
5470           , p_locator_id               => p_locator_id
5471           , p_lpn_id                   => p_lpn_id
5472           , p_transaction_temp_id      => p_transaction_temp_id
5473           , x_status                   => l_return_status
5474           , x_message                  => l_msg_data
5475           , p_project_id               => p_project_id
5476           , p_task_id                  => p_task_id
5477           , p_country_code             => p_country_code
5478           , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5479           , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5480           , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5481           , p_attribute_category       => p_attribute_category
5482           , p_attribute1               => p_attribute1
5483           , p_attribute2               => p_attribute2
5484           , p_attribute3               => p_attribute3
5485           , p_attribute4               => p_attribute4
5486           , p_attribute5               => p_attribute5
5487           , p_attribute6               => p_attribute6
5488           , p_attribute7               => p_attribute7
5489           , p_attribute8               => p_attribute8
5490           , p_attribute9               => p_attribute9
5491           , p_attribute10              => p_attribute10
5492           , p_attribute11              => p_attribute11
5493           , p_attribute12              => p_attribute12
5494           , p_attribute13              => p_attribute13
5495           , p_attribute14              => p_attribute14
5496           , p_attribute15              => p_attribute15
5497           );
5498 
5499           IF l_return_status = fnd_api.g_ret_sts_error THEN
5500             fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
5501             fnd_msg_pub.ADD;
5502 
5503             IF (l_debug = 1) THEN
5504               print_debug(
5505                    'create_direct_rti_rec 23.1: create_asn_exp_dd_intf_rec  RAISE FND_API.G_EXC_ERROR;'
5506                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5507             END IF;
5508 
5509             RAISE fnd_api.g_exc_error;
5510           END IF;
5511 
5512           IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5513             fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
5514             fnd_msg_pub.ADD;
5515 
5516             IF (l_debug = 1) THEN
5517               print_debug(
5518                    'create_direct_rti_rec 23.2: create_asn_exp_dd_intf_rec  FND_API.G_EXC_UNEXPECTED_ERROR;'
5519                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5520             END IF;
5521 
5522             RAISE fnd_api.g_exc_unexpected_error;
5523           END IF;
5524         ELSE
5525           l_progress := '50';
5526 
5527           IF (l_debug = 1) THEN
5528             print_debug(
5529                  'create_direct_rti_rec: 24 - calling  create_asn_exp_dd_intf_rec for intransit shipment'
5530               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5531           END IF;
5532 
5533           create_asn_exp_dd_intf_rec(
5534             p_move_order_header_id     => p_move_order_header_id
5535           , p_organization_id          => p_organization_id
5536           , p_shipment_header_id       => p_shipment_header_id
5537           , p_po_header_id             => p_po_header_id
5538           , p_source_type              => 'INTERNAL'
5539           , p_subinventory             => p_subinventory
5540           , p_locator_id               => p_locator_id
5541           , p_lpn_id                   => p_lpn_id
5542           , p_transaction_temp_id      => p_transaction_temp_id
5543           , x_status                   => l_return_status
5544           , x_message                  => l_msg_data
5545           , p_project_id               => p_project_id
5546           , p_task_id                  => p_task_id
5547           , p_country_code             => p_country_code
5548           , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5549           , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5550           , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5551           , p_attribute_category       => p_attribute_category
5552           , p_attribute1               => p_attribute1
5553           , p_attribute2               => p_attribute2
5554           , p_attribute3               => p_attribute3
5555           , p_attribute4               => p_attribute4
5556           , p_attribute5               => p_attribute5
5557           , p_attribute6               => p_attribute6
5558           , p_attribute7               => p_attribute7
5559           , p_attribute8               => p_attribute8
5560           , p_attribute9               => p_attribute9
5561           , p_attribute10              => p_attribute10
5562           , p_attribute11              => p_attribute11
5563           , p_attribute12              => p_attribute12
5564           , p_attribute13              => p_attribute13
5565           , p_attribute14              => p_attribute14
5566           , p_attribute15              => p_attribute15
5567           );
5568 
5569           IF l_return_status = fnd_api.g_ret_sts_error THEN
5570 	     --BUG 3433072: The message below is not defined.  Plus, it
5571 	     --create_asn_exp_dd_intf_rec fails, it will fails with a error
5572 	     --message.
5573 	     --fnd_message.set_name('INV', 'INV_RCV_CRT_INTSHIPEXP_RTI_FAIL'); -- MSGTBD
5574 	     --fnd_msg_pub.ADD;
5575 
5576             IF (l_debug = 1) THEN
5577               print_debug(
5578                    'create_direct_rti_rec 24.1: create_asn_exp_dd_intf_rec for IntShip RAISE FND_API.G_EXC_ERROR;'
5579                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5580             END IF;
5581 
5582             RAISE fnd_api.g_exc_error;
5583           END IF;
5584 
5585           IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5586 	     --BUG 3433072: The message below is not defined
5587 	     --fnd_message.set_name('INV', 'INV_RCV_CREATE_INTSHIPEXP_RTI_FAIL');
5588 	     fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL');
5589 	     fnd_msg_pub.ADD;
5590 
5591             IF (l_debug = 1) THEN
5592               print_debug(
5593                    'create_direct_rti_rec 24.2: create_asn_exp_dd_intf_rec for IntShip RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5594                 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5595             END IF;
5596 
5597             RAISE fnd_api.g_exc_unexpected_error;
5598           END IF;
5599         END IF;
5600       ELSIF p_source_type IN ('ASNCONFM', 'LCMCONFM') THEN   -- For LCM Project
5601 
5602         l_progress := '60';
5603 
5604 -- For Bug 7440217 added code to handle LCM Doc also
5605       IF p_source_type = 'ASNCONFM' THEN
5606            l_tx_type := 'ASN';
5607       ELSIF p_source_type = 'LCMCONFM' THEN     -- For LCM Project
5608            l_tx_type := 'LCM';       -- For LCM Project
5609       END IF;
5610 -- End for Bug 7440217
5611 
5612         IF (l_debug = 1) THEN
5613           print_debug('create_direct_rti_rec: 25  ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5614         END IF;
5615 
5616         create_asn_con_dd_intf_rec(
5617           p_move_order_header_id     => p_move_order_header_id
5618         , p_organization_id          => p_organization_id
5619         , p_shipment_header_id       => p_shipment_header_id
5620         , p_po_header_id             => p_po_header_id
5621         , p_item_id                  => p_item_id
5622         , p_rcv_qty                  => p_rcv_qty
5623         , p_rcv_uom                  => p_rcv_uom
5624         , p_rcv_uom_code             => p_rcv_uom_code
5625         , p_source_type              => l_tx_type
5626         , p_subinventory             => p_subinventory
5627         , p_locator_id               => p_locator_id
5628         , p_from_lpn_id              => p_from_lpn_id
5629         , -- Nested LPN changes
5630           p_lpn_id                   => p_lpn_id
5631         , p_lot_control_code         => p_lot_control_code
5632         , p_serial_control_code      => p_serial_control_code
5633         , p_revision                 => p_revision
5634         , p_transaction_temp_id      => p_transaction_temp_id
5635         , x_status                   => l_return_status
5636         , x_message                  => l_msg_data
5637         , p_project_id               => p_project_id
5638         , p_task_id                  => p_task_id
5639         , p_country_code             => p_country_code
5640         , p_item_desc                => p_item_desc
5641         , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5642         , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5643         , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5644         , p_attribute_category       => p_attribute_category
5645         , p_attribute1               => p_attribute1
5646         , p_attribute2               => p_attribute2
5647         , p_attribute3               => p_attribute3
5648         , p_attribute4               => p_attribute4
5649         , p_attribute5               => p_attribute5
5650         , p_attribute6               => p_attribute6
5651         , p_attribute7               => p_attribute7
5652         , p_attribute8               => p_attribute8
5653         , p_attribute9               => p_attribute9
5654         , p_attribute10              => p_attribute10
5655         , p_attribute11              => p_attribute11
5656         , p_attribute12              => p_attribute12
5657         , p_attribute13              => p_attribute13
5658         , p_attribute14              => p_attribute14
5659         , p_attribute15              => p_attribute15
5660         , p_express_transaction      => NULL--Bug 5550783
5661         , p_location_id              => p_location_id --Bug 13490287
5662         );
5663 
5664         IF l_return_status = fnd_api.g_ret_sts_error THEN
5665           fnd_message.set_name('INV', 'INV_RCV_CRT_ASNCON_RTI_FAIL'); -- MSGTBD
5666           fnd_msg_pub.ADD;
5667 
5668           IF (l_debug = 1) THEN
5669             print_debug(
5670                  'create_direct_rti_rec 25.1: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_ERROR;'
5671               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5672           END IF;
5673 
5674           RAISE fnd_api.g_exc_error;
5675         END IF;
5676 
5677         IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5678           fnd_message.set_name('INV', 'INV_RCV_CREATE_INTSHIPEXP_RTI_FAIL'); -- MSGTBD
5679           fnd_msg_pub.ADD;
5680 
5681           IF (l_debug = 1) THEN
5682             print_debug(
5683                  'create_direct_rti_rec 25.2: create_asn_con_dd_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5684               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5685             , 4
5686             );
5687           END IF;
5688 
5689           RAISE fnd_api.g_exc_unexpected_error;
5690         END IF;
5691       ELSE
5692         create_int_shp_dr_del_rti_rec(
5693           p_move_order_header_id     => p_move_order_header_id
5694         , p_organization_id          => p_organization_id
5695         , p_shipment_header_id       => p_shipment_header_id
5696         , p_shipment_line_id         => NULL
5697         , p_item_id                  => p_item_id
5698         , p_rcv_qty                  => p_rcv_qty
5699         , p_rcv_uom                  => p_rcv_uom
5700         , p_rcv_uom_code             => p_rcv_uom_code
5701         , p_source_type              => p_source_type
5702         , p_subinventory             => p_subinventory
5703         , p_locator_id               => p_locator_id
5704         , p_transaction_temp_id      => p_transaction_temp_id
5705         , p_lot_control_code         => p_lot_control_code
5706         , p_serial_control_code      => p_serial_control_code
5707         , p_from_lpn_id              => p_from_lpn_id
5708         , -- Nested LPN Changes
5709           p_lpn_id                   => p_lpn_id
5710         , p_revision                 => p_revision
5711         , p_project_id               => p_project_id
5712         , p_task_id                  => p_task_id
5713         , x_status                   => l_return_status
5714         , x_message                  => x_message
5715         , p_country_code             => p_country_code
5716         , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5717         , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5718         , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5719         , p_attribute_category       => p_attribute_category
5720         , p_attribute1               => p_attribute1
5721         , p_attribute2               => p_attribute2
5722         , p_attribute3               => p_attribute3
5723         , p_attribute4               => p_attribute4
5724         , p_attribute5               => p_attribute5
5725         , p_attribute6               => p_attribute6
5726         , p_attribute7               => p_attribute7
5727         , p_attribute8               => p_attribute8
5728         , p_attribute9               => p_attribute9
5729         , p_attribute10              => p_attribute10
5730         , p_attribute11              => p_attribute11
5731         , p_attribute12              => p_attribute12
5732         , p_attribute13              => p_attribute13
5733         , p_attribute14              => p_attribute14
5734         , p_attribute15              => p_attribute15
5735         );
5736 
5737         IF l_return_status = fnd_api.g_ret_sts_error THEN
5738           fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5739           fnd_msg_pub.ADD;
5740 
5741           IF (l_debug = 1) THEN
5742             print_debug(
5743                  'create_direct_rti_rec 40.1: create_int_shp_dr_del_rti_rec RAISE FND_API.G_EXC_ERROR;'
5744               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5745           END IF;
5746 
5747           RAISE fnd_api.g_exc_error;
5748         END IF;
5749 
5750         IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5751           fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
5752           fnd_msg_pub.ADD;
5753 
5754           IF (l_debug = 1) THEN
5755             print_debug(
5756                  'create_direct_rti_rec 40.2:create_int_shp_dr_del_rti_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5757               || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5758           END IF;
5759 
5760           RAISE fnd_api.g_exc_unexpected_error;
5761         END IF;
5762       END IF;
5763     ELSIF p_oe_order_header_id IS NOT NULL THEN
5764       l_progress := '60';
5765 
5766       IF (l_debug = 1) THEN
5767         print_debug('create_direct_rti_rec: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5768         print_debug('create_direct_rti_rec: 6.1  p_oe_order_header_id = ' || p_oe_order_header_id, 4);
5769       END IF;
5770 
5771       create_rma_drct_dlvr_rti_rec(
5772         p_move_order_header_id     => p_move_order_header_id
5773       , p_organization_id          => p_organization_id
5774       , p_oe_order_header_id       => p_oe_order_header_id
5775       , p_oe_order_line_id         => NULL
5776       , p_item_id                  => p_item_id
5777       , p_rcv_qty                  => p_rcv_qty
5778       , p_rcv_uom                  => p_rcv_uom
5779       , p_rcv_uom_code             => p_rcv_uom_code
5780       , p_source_type              => p_source_type
5781       , p_subinventory             => p_subinventory
5782       , p_locator_id               => p_locator_id
5783       , p_transaction_temp_id      => p_transaction_temp_id
5784       , p_lot_control_code         => p_lot_control_code
5785       , p_serial_control_code      => p_serial_control_code
5786       , p_lpn_id                   => p_lpn_id
5787       , p_revision                 => p_revision
5788       , x_status                   => l_return_status
5789       , x_message                  => x_message
5790       , p_project_id               => p_project_id
5791       , p_task_id                  => p_task_id
5792       , p_country_code             => p_country_code
5793       , p_secondary_rcv_qty        => p_secondary_rcv_qty  --OPM Convergence
5794       , p_rcv_sec_uom              => p_rcv_sec_uom --OPM Convergence
5795       , p_rcv_sec_uom_code         => p_rcv_sec_uom_code --OPM Convergence
5796       , p_attribute_category       => p_attribute_category
5797       , p_attribute1               => p_attribute1
5798       , p_attribute2               => p_attribute2
5799       , p_attribute3               => p_attribute3
5800       , p_attribute4               => p_attribute4
5801       , p_attribute5               => p_attribute5
5802       , p_attribute6               => p_attribute6
5803       , p_attribute7               => p_attribute7
5804       , p_attribute8               => p_attribute8
5805       , p_attribute9               => p_attribute9
5806       , p_attribute10              => p_attribute10
5807       , p_attribute11              => p_attribute11
5808       , p_attribute12              => p_attribute12
5809       , p_attribute13              => p_attribute13
5810       , p_attribute14              => p_attribute14
5811       , p_attribute15              => p_attribute15
5812       );
5813 
5814       IF l_return_status = fnd_api.g_ret_sts_error THEN
5815         fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5816         fnd_msg_pub.ADD;
5817 
5818         IF (l_debug = 1) THEN
5819           print_debug(
5820                'create_direct_rti_rec 50.1: create_rma_drct_dlvr_rti_rec RAISE FND_API.G_EXC_ERROR;'
5821             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5822         END IF;
5823 
5824         RAISE fnd_api.g_exc_error;
5825       END IF;
5826 
5827       IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5828         fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
5829         fnd_msg_pub.ADD;
5830 
5831         IF (l_debug = 1) THEN
5832           print_debug(
5833                'create_direct_rti_rec 50.2: create_rma_drct_dlvr_rti_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5834             || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5835         END IF;
5836 
5837         RAISE fnd_api.g_exc_unexpected_error;
5838       END IF;
5839     END IF;
5840 
5841     l_progress := '80';
5842 
5843     IF (l_debug = 1) THEN
5844       print_debug('create_direct_rti_rec calling print_label: 6' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5845     END IF;
5846 
5847     x_status := l_return_status; -- l_return_status can be 'W', we want to carry that over
5848 
5849                                  -- calling label printing API
5850 
5851     IF l_return_status <> fnd_api.g_ret_sts_error THEN
5852       l_progress := '80';
5853 
5854       IF (l_debug = 1) THEN
5855         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);
5856       END IF;
5857 
5858       /* FP-J Lot/Serial Support Enhancement
5859        * If INV J and PO J are installed, do not call label printing API at this stage
5860        */
5861       IF ((inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po) OR
5862           (inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j)) THEN
5863 
5864        IF (p_source_type <> 'VENDOR') THEN  --Bug #4079952.. For PO receipt code in rcv_insert_update_header(INVSTDRB.pls) will be called.
5865 
5866         l_counter := 1;
5867         OPEN c_rti_txn_id;
5868 
5869         LOOP
5870           FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
5871           EXIT WHEN c_rti_txn_id%NOTFOUND;
5872 
5873           IF (l_debug = 1) THEN
5874             print_debug('create_direct_rti_rec calling printing for:' || l_txn_id_tbl(l_counter), 4);
5875           END IF;
5876 
5877           l_counter := l_counter + 1;
5878         END LOOP;
5879 
5880         CLOSE c_rti_txn_id;
5881         inv_label.print_label(
5882           x_return_status          => l_return_status
5883         , x_msg_count              => l_msg_count
5884         , x_msg_data               => l_msg_data
5885         , x_label_status           => l_label_status
5886         , p_api_version            => 1.0
5887         , p_print_mode             => 1
5888         , p_business_flow_code     => 1
5889         , p_transaction_id         => l_txn_id_tbl
5890         );
5891 
5892         IF l_return_status <> fnd_api.g_ret_sts_success THEN
5893           fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
5894           fnd_msg_pub.ADD;
5895           x_status := 'W';
5896 
5897           IF (l_debug = 1) THEN
5898             print_debug('create_direct_rti_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5899           END IF;   --END IF l_debug = 1
5900         END IF;   --END IF label ret status <> S
5901        END IF ; --Bug #4079952
5902       ELSE
5903         IF (l_debug = 1) THEN
5904           print_debug('INV J and PO J are installed. NO label printing from UI', 4);
5905         END IF;
5906       END IF;   --END IF INV J and PO J installed
5907     END IF;   --END IF ret status = Successs
5908 
5909     IF (l_debug = 1) THEN
5910       print_debug('create_direct_rti_rec exiting print_label: 7' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5911     END IF;
5912 
5913     IF (l_debug = 1) THEN
5914       print_debug('About exit create_direct_rti_rec: 8' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5915       print_debug('create_direct_rti_rec: 8.1   - x_status = ' || x_status, 4);
5916       print_debug('create_direct_rti_rec: 8.2   -  x_message= ' || x_message, 4);
5917     END IF;
5918   EXCEPTION
5919     WHEN fnd_api.g_exc_error THEN
5920       x_status := fnd_api.g_ret_sts_error;
5921       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5922     WHEN fnd_api.g_exc_unexpected_error THEN
5923       x_status := fnd_api.g_ret_sts_unexp_error;
5924       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5925     WHEN OTHERS THEN
5926       x_status := fnd_api.g_ret_sts_unexp_error;
5927 
5928       IF SQLCODE IS NOT NULL THEN
5929         inv_mobile_helper_functions.sql_error('inv_rcv_dir_rcpt_apis.create_direct_rti_rec', l_progress, SQLCODE);
5930       END IF;
5931 
5932       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5933   END create_direct_rti_rec;
5934 /*
5935 PROCEDURE pack_lpn_txn
5936   IS
5937      l_proc_msg VARCHAR2(400);
5938      l_return_status NUMBER;
5939     l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5940 BEGIN
5941    IF (l_debug = 1) THEN
5942       print_debug('Enter pack_lpn_txn: 1'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS')  , 1);
5943    END IF;
5944 
5945    l_return_status := inv_lpn_trx_pub.process_lpn_trx
5946      (p_trx_hdr_id => inv_rcv_common_apis.g_rcv_global_var.transaction_header_id,
5947       p_mode => 2,  -- putaway mode
5948       p_commit => 'F',
5949       x_proc_msg => l_proc_msg);
5950 
5951    IF (l_debug = 1) THEN
5952       print_debug('About exit pack_lpn_txn: 2'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS')  , 1);
5953    END IF;
5954 
5955 
5956 END pack_lpn_txn;
5957 */
5958 END inv_rcv_dir_rcpt_apis;