[Home] [Help]
PACKAGE BODY: APPS.INV_RCV_STD_RCPT_APIS
Source
1 PACKAGE BODY inv_rcv_std_rcpt_apis AS
2 /* $Header: INVSTDRB.pls 120.53.12020000.15 2013/04/26 23:29:46 sahmahes ship $*/
3
4 -- Global constant holding the package name
5 g_pkg_name CONSTANT VARCHAR2(30) := 'INV_RCV_STD_RCPT_APIS';
6
7 --g_rcpt_lot_qty_rec_tb rcpt_lot_qty_rec_tb_tp;
8 --g_prev_lot_number VARCHAR2(30) := NULL;
9
10 PROCEDURE print_debug(p_err_msg VARCHAR2, p_level NUMBER DEFAULT 4) IS
11 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
12 BEGIN
13 IF (l_debug = 1) THEN
14 inv_mobile_helper_functions.tracelog(
15 p_err_msg => p_err_msg
16 , p_module => 'INV_RCV_STD_RCPT_APIS'
17 , p_level => p_level);
18 END IF;
19 -- dbms_output.put_line(p_err_msg);
20 END print_debug;
21
22 PROCEDURE get_project_task(
23 p_po_line_location_id IN NUMBER
24 , p_oe_order_line_id IN NUMBER
25 , x_project_id OUT NOCOPY NUMBER
26 , x_task_id OUT NOCOPY NUMBER
27 ) IS
28 l_project_id NUMBER := '';
29 l_task_id NUMBER := '';
30 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
31 BEGIN
32 IF (l_debug = 1) THEN
33 print_debug('get_project_task: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
34 END IF;
35
36 IF p_po_line_location_id IS NOT NULL THEN
37 --BUG 3444210: Modify the query below for performance reason
38 SELECT
39 pod.project_id project_id
40 ,NVL(pod.task_id, '') task_id
41 INTO l_project_id
42 , l_task_id
43 FROM po_distributions_all pod
44 WHERE pod.line_location_id = p_po_line_location_id
45 AND ROWNUM = 1
46 AND pod.project_id IS NOT NULL
47 ORDER BY nvl(pod.task_id,-1) DESC;
48 ELSIF p_oe_order_line_id IS NOT NULL THEN
49 SELECT project_id
50 , task_id
51 INTO l_project_id
52 , l_task_id
53 FROM oe_order_lines_all
54 WHERE line_id = p_oe_order_line_id;
55 END IF;
56
57 x_project_id := l_project_id;
58 x_task_id := l_task_id;
59
60 IF (l_debug = 1) THEN
61 print_debug('project_id:' || x_project_id, 4);
62 print_debug('task_id:' || x_task_id, 4);
63 END IF;
64 EXCEPTION
65 WHEN NO_DATA_FOUND THEN
66 x_project_id := '';
67 x_task_id := '';
68 END get_project_task;
69
70 FUNCTION insert_txn_interface(
71 p_rcv_transaction_rec IN OUT NOCOPY rcv_transaction_rec_tp
72 , p_rcv_rcpt_rec IN OUT NOCOPY rcv_enter_receipts_rec_tp
73 , p_group_id IN NUMBER
74 , p_transaction_type IN VARCHAR2
75 , p_organization_id IN NUMBER
76 , p_location_id IN NUMBER
77 , p_source_type IN VARCHAR2
78 , p_qa_routing_id IN NUMBER DEFAULT -1
79 , p_project_id IN NUMBER DEFAULT NULL
80 , p_task_id IN NUMBER DEFAULT NULL
81 , p_express_transaction IN VARCHAR2 DEFAULT NULL
82
83 )
84 RETURN NUMBER IS
85 l_rcv_transaction_rec rcv_transaction_rec_tp; -- rcv_transaction block
86 l_rti_rowid VARCHAR2(40);
87 l_interface_transaction_id NUMBER;
88 l_sysdate DATE := SYSDATE;
89 l_txn_date DATE := Sysdate;
90 l_auto_transact_code VARCHAR2(30);
91 l_shipment_line_id NUMBER;
92 l_primary_uom VARCHAR2(25);
93 l_source_type_code VARCHAR2(30);
94 l_vendor_id NUMBER;
95 l_vendor_site_id NUMBER;
96 l_from_org_id NUMBER;
97 l_to_org_id NUMBER;
98 l_source_doc_code VARCHAR2(30);
99 l_po_header_id NUMBER;
100 l_po_release_id NUMBER;
101 l_po_line_id NUMBER;
102 l_po_line_location_id NUMBER;
103 l_po_distribution_id NUMBER;
104 l_req_line_id NUMBER;
105 l_sub_unordered_code VARCHAR2(30);
106 l_deliver_to_person_id NUMBER;
107 l_location_id NUMBER;
108 l_deliver_to_location_id NUMBER;
109 l_subinventory VARCHAR2(10);
110 l_locator_id NUMBER;
111 l_wip_entity_id NUMBER;
112 l_wip_line_id NUMBER;
113 l_department_code VARCHAR2(30);
114 l_wip_rep_sched_id NUMBER;
115 l_wip_oper_seq_num NUMBER;
116 l_wip_res_seq_num NUMBER;
117 l_bom_resource_id NUMBER;
118 l_oe_order_header_id NUMBER;
119 l_oe_order_line_id NUMBER;
120 l_customer_item_num NUMBER;
121 l_customer_id NUMBER;
122 l_customer_site_id NUMBER;
123 l_rate NUMBER;
124 l_shipment_header_id NUMBER;
125 --variables for defaulting rcv_transaction non-db items
126
127 x_available_qty NUMBER;
128 x_ordered_qty NUMBER;
129 x_primary_qty NUMBER;
130 x_tolerable_qty NUMBER;
131 x_uom VARCHAR2(25);
132 x_primary_uom VARCHAR2(25);
133 x_valid_ship_to_location BOOLEAN;
134 x_num_of_distributions NUMBER;
135 x_po_distribution_id NUMBER;
136 x_destination_type_code VARCHAR2(30);
137 x_destination_type_dsp VARCHAR2(80);
138 x_deliver_to_location_id NUMBER;
139 x_deliver_to_location VARCHAR2(80);
140 x_deliver_to_person_id NUMBER;
141 x_deliver_to_person VARCHAR2(240);
142 x_deliver_to_sub VARCHAR2(10);
143 x_deliver_to_locator_id NUMBER;
144 x_wip_entity_id NUMBER;
145 x_wip_repetitive_schedule_id NUMBER;
146 x_wip_line_id NUMBER;
147 x_wip_operation_seq_num NUMBER;
148 x_wip_resource_seq_num NUMBER;
149 x_bom_resource_id NUMBER;
150 x_to_organization_id NUMBER;
151 x_job VARCHAR2(80);
152 x_line_num VARCHAR2(10);
153 x_sequence NUMBER;
154 x_department VARCHAR2(40);
155 x_enforce_ship_to_loc VARCHAR2(30);
156 x_allow_substitutes VARCHAR2(3);
157 x_routing_id NUMBER;
158 x_qty_rcv_tolerance NUMBER;
159 x_qty_rcv_exception VARCHAR2(30);
160 x_days_early_receipt NUMBER;
161 x_days_late_receipt NUMBER;
162 x_rcv_days_exception VARCHAR2(30);
163 x_item_revision VARCHAR2(3);
164 x_locator_control NUMBER;
165 x_inv_destinations BOOLEAN;
166 x_rate NUMBER;
167 x_rate_date DATE;
168 x_project_id NUMBER;
169 x_task_id NUMBER;
170 x_req_line_id NUMBER;
171 x_pos NUMBER;
172 x_oe_order_line_id NUMBER;
173 x_item_id NUMBER;
174 x_org_id NUMBER;
175 x_category_id NUMBER;
176 x_category_set_id NUMBER;
177 x_routing_name VARCHAR2(240);
178 l_project_id NUMBER := p_project_id;
179 l_task_id NUMBER := p_task_id;
180 l_validation_flag VARCHAR2(1);
181 l_lpn_group_id NUMBER;
182 l_header_interface_id NUMBER;
183 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
184 --OPM Convergence
185 l_secondary_unit_of_measure VARCHAR2(25);
186 l_secondary_uom_code VARCHAR2(3);
187 l_secondary_quantity NUMBER;
188 l_express_transaction VARCHAR2(1) := NVL(p_express_transaction, 'N');
189
190 t_sec_uom_code VARCHAR2(3);
191 t_sec_uom VARCHAR2(25); t_sec_qty NUMBER;
192
193 l_operating_unit_id MO_GLOB_ORG_ACCESS_TMP.ORGANIZATION_ID%TYPE; --<R12 MOAC>
194
195 l_po_item_id MTL_SYSTEM_ITEMS.INVENTORY_ITEM_ID%TYPE; --bug 4697949
196 l_substitute_item_id MTL_SYSTEM_ITEMS.INVENTORY_ITEM_ID%TYPE; --bug 4697949
197
198 -- For Bug 7440217
199 v_lcm_enabled_org varchar2(1) := 'N';
200 v_pre_receive varchar2(1) := 'N';
201 v_lcm_flag varchar2(1) := 'N';
202 v_lcm_ship_line_id NUMBER;
203 v_unit_landed_cost NUMBER;
204 -- End for Bug 7440217
205 l_client_code VARCHAR2(40); /* Bug 9158529: LSP Changes */
206 v_item_revision VARCHAR2(3); -- bug 13598673
207
208 BEGIN
209 IF (l_debug = 1) THEN
210 print_debug('Enter insert_txn_interface: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
211 print_debug('insert_txn_interface: p_express_transaction ' || p_express_transaction, 1);
212 print_debug('insert_txn_interface: l_express_transaction ' || l_express_transaction, 1);
213 END IF;
214
215 IF (l_debug = 1) THEN
216 print_debug('insert_txn_interface 2 value of coutry of origin is ' || p_rcv_rcpt_rec.country_of_origin_code, 4);
217 END IF;
218
219 IF (l_debug = 1) THEN
220 print_debug('insert_txn_interface: revision1 - ' || p_rcv_transaction_rec.item_revision, 4); -- revision needs to be taken care of by matching
221 END IF;
222
223 print_debug('Rcpt source code ' || p_rcv_rcpt_rec.receipt_source_code);
224 -- print_debug('Rcv Sub ' || p_rcv_transaction_rec.destination_subinventory);
225 -- print_debug('Rcv Loc ' || p_rcv_transaction_rec.locator_id);
226 l_rcv_transaction_rec := p_rcv_transaction_rec;
227 -- populate DB items in rcv_transaction block
228 l_rcv_transaction_rec.line_chkbox := p_rcv_rcpt_rec.line_chkbox;
229 l_rcv_transaction_rec.source_type_code := p_rcv_rcpt_rec.source_type_code;
230 l_rcv_transaction_rec.receipt_source_code := p_rcv_rcpt_rec.receipt_source_code;
231 l_rcv_transaction_rec.order_type_code := p_rcv_rcpt_rec.order_type_code;
232 l_rcv_transaction_rec.order_type := p_rcv_rcpt_rec.order_type;
233 l_rcv_transaction_rec.po_header_id := p_rcv_rcpt_rec.po_header_id;
234 l_rcv_transaction_rec.po_number := p_rcv_rcpt_rec.po_number;
235 l_rcv_transaction_rec.po_line_id := p_rcv_rcpt_rec.po_line_id;
236 l_rcv_transaction_rec.po_line_location_id := p_rcv_rcpt_rec.po_line_location_id;
237 l_rcv_transaction_rec.po_line_number := p_rcv_rcpt_rec.po_line_number;
238 l_rcv_transaction_rec.po_shipment_number := p_rcv_rcpt_rec.po_shipment_number;
239 l_rcv_transaction_rec.po_release_id := p_rcv_rcpt_rec.po_release_id;
240 l_rcv_transaction_rec.po_release_number := p_rcv_rcpt_rec.po_release_number;
241 l_rcv_transaction_rec.req_header_id := p_rcv_rcpt_rec.req_header_id;
242 l_rcv_transaction_rec.req_number := p_rcv_rcpt_rec.req_number;
243 l_rcv_transaction_rec.req_line_id := p_rcv_rcpt_rec.req_line_id;
244 l_rcv_transaction_rec.req_line := p_rcv_rcpt_rec.req_line;
245 l_rcv_transaction_rec.req_distribution_id := p_rcv_rcpt_rec.req_distribution_id;
246 l_rcv_transaction_rec.rcv_shipment_header_id := p_rcv_rcpt_rec.rcv_shipment_header_id;
247 l_rcv_transaction_rec.rcv_shipment_number := p_rcv_rcpt_rec.rcv_shipment_number;
248 l_rcv_transaction_rec.rcv_shipment_line_id := p_rcv_rcpt_rec.rcv_shipment_line_id;
249 l_rcv_transaction_rec.rcv_line_number := p_rcv_rcpt_rec.rcv_line_number;
250 l_rcv_transaction_rec.from_organization_id := p_rcv_rcpt_rec.from_organization_id;
251 l_rcv_transaction_rec.to_organization_id := p_rcv_rcpt_rec.to_organization_id;
252 l_rcv_transaction_rec.vendor_id := p_rcv_rcpt_rec.vendor_id;
253 -- l_rcv_transaction_rec.source := p_rcv_rcpt_rec.source;
254 l_rcv_transaction_rec.vendor_site_id := p_rcv_rcpt_rec.vendor_site_id;
255 -- l_rcv_transaction_rec.outside_operation_flag := p_rcv_rcpt_rec.outside_operation_flag;
256 l_rcv_transaction_rec.item_id := p_rcv_rcpt_rec.item_id;
257 --OPM Convergence
258 /* l_rcv_transaction_rec.secondary_uom := p_rcv_rcpt_rec.secondary_uom;
259 l_rcv_transaction_rec.secondary_uom_code := p_rcv_rcpt_rec.secondary_uom_code;
260 l_rcv_transaction_rec .secondary_quantity := p_rcv_rcpt_rec.secondary_quantity; */
261 -- end of changes for OPM Convergence changes
262
263
264 IF (l_debug = 1) THEN
265 print_debug('l_rcv_transaction_rec.item_id - ' || l_rcv_transaction_rec.item_id, 4);
266 print_debug('l_rcv_transaction_rec.secondary_uom - ' || l_rcv_transaction_rec.secondary_uom, 4);
267 print_debug('l_rcv_transaction_rec .secondary_quantity - ' || l_rcv_transaction_rec .secondary_quantity, 4);
268 END IF;
269
270 -- Bug 2073164
271 l_rcv_transaction_rec.uom_code := p_rcv_rcpt_rec.uom_code;
272 l_rcv_transaction_rec.primary_uom_class := p_rcv_rcpt_rec.primary_uom_class;
273 l_rcv_transaction_rec.serial_number_control_code := p_rcv_rcpt_rec.serial_number_control_code;
274 l_rcv_transaction_rec.lot_control_code := p_rcv_rcpt_rec.lot_control_code;
275 l_rcv_transaction_rec.item_rev_control_flag_to := p_rcv_rcpt_rec.item_rev_control_flag_to;
276 l_rcv_transaction_rec.item_rev_control_flag_from := p_rcv_rcpt_rec.item_rev_control_flag_from;
277 l_rcv_transaction_rec.item_number := p_rcv_rcpt_rec.item_number;
278 l_rcv_transaction_rec.item_description := p_rcv_rcpt_rec.item_description;
279 l_rcv_transaction_rec.item_category_id := p_rcv_rcpt_rec.item_category_id;
280 l_rcv_transaction_rec.vendor_item_number := p_rcv_rcpt_rec.vendor_item_number;
281 l_rcv_transaction_rec.ship_to_location_id := p_rcv_rcpt_rec.ship_to_location_id;
282 l_rcv_transaction_rec.packing_slip := p_rcv_rcpt_rec.packing_slip;
283 l_rcv_transaction_rec.routing_id := p_rcv_rcpt_rec.routing_id;
284 l_rcv_transaction_rec.need_by_date := p_rcv_rcpt_rec.need_by_date;
285 l_rcv_transaction_rec.expected_receipt_date := p_rcv_rcpt_rec.expected_receipt_date;
286 l_rcv_transaction_rec.ordered_uom := p_rcv_rcpt_rec.ordered_uom;
287 l_rcv_transaction_rec.ussgl_transaction_code := p_rcv_rcpt_rec.ussgl_transaction_code;
288 l_rcv_transaction_rec.government_context := p_rcv_rcpt_rec.government_context;
289 l_rcv_transaction_rec.inspection_required_flag := p_rcv_rcpt_rec.inspection_required_flag;
290 l_rcv_transaction_rec.receipt_required_flag := p_rcv_rcpt_rec.receipt_required_flag;
291 l_rcv_transaction_rec.enforce_ship_to_location_code := p_rcv_rcpt_rec.enforce_ship_to_location_code;
292 l_rcv_transaction_rec.unit_price := p_rcv_rcpt_rec.unit_price;
293 l_rcv_transaction_rec.currency_code := p_rcv_rcpt_rec.currency_code;
294 l_rcv_transaction_rec.currency_conversion_type := p_rcv_rcpt_rec.currency_conversion_type;
295 l_rcv_transaction_rec.note_to_receiver := p_rcv_rcpt_rec.note_to_receiver;
296 l_rcv_transaction_rec.destination_type_code := p_rcv_rcpt_rec.destination_type_code;
297 l_rcv_transaction_rec.deliver_to_location_id := p_rcv_rcpt_rec.deliver_to_location_id;
298 l_rcv_transaction_rec.attribute_category := p_rcv_rcpt_rec.attribute_category;
299 l_rcv_transaction_rec.attribute1 := p_rcv_rcpt_rec.attribute1;
300 l_rcv_transaction_rec.attribute2 := p_rcv_rcpt_rec.attribute2;
301 l_rcv_transaction_rec.attribute3 := p_rcv_rcpt_rec.attribute3;
302 l_rcv_transaction_rec.attribute4 := p_rcv_rcpt_rec.attribute4;
303 l_rcv_transaction_rec.attribute5 := p_rcv_rcpt_rec.attribute5;
304 l_rcv_transaction_rec.attribute6 := p_rcv_rcpt_rec.attribute6;
305 l_rcv_transaction_rec.attribute7 := p_rcv_rcpt_rec.attribute7;
306 l_rcv_transaction_rec.attribute8 := p_rcv_rcpt_rec.attribute8;
307 l_rcv_transaction_rec.attribute9 := p_rcv_rcpt_rec.attribute9;
308 l_rcv_transaction_rec.attribute10 := p_rcv_rcpt_rec.attribute10;
309 l_rcv_transaction_rec.attribute11 := p_rcv_rcpt_rec.attribute11;
310 l_rcv_transaction_rec.attribute12 := p_rcv_rcpt_rec.attribute12;
311 l_rcv_transaction_rec.attribute13 := p_rcv_rcpt_rec.attribute13;
312 l_rcv_transaction_rec.attribute14 := p_rcv_rcpt_rec.attribute14;
313 l_rcv_transaction_rec.attribute15 := p_rcv_rcpt_rec.attribute15;
314 l_rcv_transaction_rec.closed_code := p_rcv_rcpt_rec.closed_code;
315 l_rcv_transaction_rec.asn_type := p_rcv_rcpt_rec.asn_type;
316 l_rcv_transaction_rec.bill_of_lading := p_rcv_rcpt_rec.bill_of_lading;
317 l_rcv_transaction_rec.shipped_date := p_rcv_rcpt_rec.shipped_date;
318 l_rcv_transaction_rec.freight_carrier_code := p_rcv_rcpt_rec.freight_carrier_code;
319 l_rcv_transaction_rec.waybill_airbill_num := p_rcv_rcpt_rec.waybill_airbill_num;
320 l_rcv_transaction_rec.freight_bill_num := p_rcv_rcpt_rec.freight_bill_num;
321 l_rcv_transaction_rec.vendor_lot_num := p_rcv_rcpt_rec.vendor_lot_num;
322 l_rcv_transaction_rec.container_num := p_rcv_rcpt_rec.container_num;
323 l_rcv_transaction_rec.truck_num := p_rcv_rcpt_rec.truck_num;
324 l_rcv_transaction_rec.bar_code_label := p_rcv_rcpt_rec.bar_code_label;
325 l_rcv_transaction_rec.match_option := p_rcv_rcpt_rec.match_option;
326 l_rcv_transaction_rec.country_of_origin_code := p_rcv_rcpt_rec.country_of_origin_code;
327 l_rcv_transaction_rec.oe_order_header_id := p_rcv_rcpt_rec.oe_order_header_id;
328 l_rcv_transaction_rec.oe_order_num := p_rcv_rcpt_rec.oe_order_num;
329 l_rcv_transaction_rec.oe_order_line_id := p_rcv_rcpt_rec.oe_order_line_id;
330 l_rcv_transaction_rec.oe_order_line_num := p_rcv_rcpt_rec.oe_order_line_num;
331 l_rcv_transaction_rec.customer_id := p_rcv_rcpt_rec.customer_id;
332 l_rcv_transaction_rec.customer_site_id := p_rcv_rcpt_rec.customer_site_id;
333
334 -- l_rcv_transaction_rec.customer_item_num := p_rcv_rcpt_rec.customer_item_num;
335 -- defaulting other non-db items
336 -- generate l_interface_transaction_id
337 -- QA Skip lot change
338 -- interface txn id is generated in create_po at times as we need to
339 -- pass that to quality. So using that if it is generated.
340 IF l_rcv_transaction_rec.interface_transaction_id IS NOT NULL THEN
341 l_interface_transaction_id := l_rcv_transaction_rec.interface_transaction_id;
342 ELSE
343 SELECT rcv_transactions_interface_s.NEXTVAL
344 INTO l_interface_transaction_id
345 FROM DUAL;
346 END IF;
347
348 IF (l_debug = 1) THEN
349 print_debug('RTI interface id:' || l_interface_transaction_id, 4);
350 print_debug('insert_txn_interface: 2 before RCV_RECEIPTS_QUERY_SV.POST_QUERY ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
351 , 4);
352 END IF;
353
354 -- call defaulting api
355 rcv_receipts_query_sv.post_query(
356 l_rcv_transaction_rec.po_line_location_id
357 , l_rcv_transaction_rec.rcv_shipment_line_id
358 , l_rcv_transaction_rec.receipt_source_code
359 , l_rcv_transaction_rec.to_organization_id
360 , l_rcv_transaction_rec.item_id
361 , l_rcv_transaction_rec.primary_uom_class
362 , l_rcv_transaction_rec.ship_to_location_id
363 , l_rcv_transaction_rec.vendor_id
364 , l_rcv_transaction_rec.customer_id
365 , l_rcv_transaction_rec.item_rev_control_flag_to
366 , x_available_qty
367 , x_primary_qty
368 , x_tolerable_qty
369 , x_uom
370 , x_primary_uom
371 , x_valid_ship_to_location
372 , x_num_of_distributions
373 , x_po_distribution_id
374 , x_destination_type_code
375 , x_destination_type_dsp
376 , x_deliver_to_location_id
377 , x_deliver_to_location
378 , x_deliver_to_person_id
379 , x_deliver_to_person
380 , x_deliver_to_sub
381 , x_deliver_to_locator_id
382 , x_wip_entity_id
383 , x_wip_repetitive_schedule_id
384 , x_wip_line_id
385 , x_wip_operation_seq_num
386 , x_wip_resource_seq_num
387 , x_bom_resource_id
388 , x_to_organization_id
389 , x_job
390 , x_line_num
391 , x_sequence
392 , x_department
393 , x_enforce_ship_to_loc
394 , x_allow_substitutes
395 , x_routing_id
396 , x_qty_rcv_tolerance
397 , x_qty_rcv_exception
398 , x_days_early_receipt
399 , x_days_late_receipt
400 , x_rcv_days_exception
401 , x_item_revision
402 , x_locator_control
403 , x_inv_destinations
404 , x_rate
405 , x_rate_date
406 , l_rcv_transaction_rec.asn_type
407 , l_rcv_transaction_rec.oe_order_header_id
408 , l_rcv_transaction_rec.oe_order_line_id
409 , l_rcv_transaction_rec.from_organization_id
410 );
411
412 IF (l_debug = 1) THEN
413 print_debug('insert_txn_interface: 3 after RCV_RECEIPTS_QUERY_SV.POST_QUERY ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
414 END IF;
415
416 l_rcv_transaction_rec.destination_type_code_hold := x_destination_type_code;
417
418 IF l_rcv_transaction_rec.source_type_code = 'CUSTOMER' THEN
419 -- get the item category based on item_id, category_set_id and org_id
420
421 IF l_rcv_transaction_rec.item_category_id IS NULL THEN
422 BEGIN
423 SELECT MAX(category_id)
424 INTO l_rcv_transaction_rec.item_category_id
425 FROM mtl_item_categories
426 WHERE inventory_item_id = l_rcv_transaction_rec.item_id
427 AND organization_id = p_organization_id
428 AND category_set_id = inv_rcv_common_apis.g_po_startup_value.category_set_id;
429 EXCEPTION
430 WHEN OTHERS THEN
431 IF (l_debug = 1) THEN
432 print_debug('insert_txn_interface: Exception in getting the item categories', 4);
433 END IF;
434 END;
435 END IF;
436
437 IF NVL(l_rcv_transaction_rec.inspection_required_flag, 'N') = 'Y' THEN
438 x_routing_id := 2;
439 -- Bug 3124881 Get the default routing parameter from rcv_parameters
440 ELSIF ( l_rcv_transaction_rec.receipt_source_code = 'CUSTOMER' ) then
441 Begin
442
443 /* Bug 9158529: LSP Changes */
444
445 IF (NVL(FND_PROFILE.VALUE('WMS_DEPLOYMENT_MODE'), 1) = 3) THEN
446
447 l_client_code := wms_deploy.get_client_code(l_rcv_transaction_rec.item_id);
448
449
450 If (l_client_code IS NOT NULL) THEN
451
452 select RMA_RECEIPT_ROUTING_ID
453 into x_routing_id
454 from mtl_client_parameters
455 WHERE client_code = l_client_code;
456
457
458 ELSE
459
460 select rma_receipt_routing_id
461 into x_routing_id
462 from rcv_parameters
463 where organization_id = p_organization_id;
464
465
466 End If;
467
468 Else
469
470 select rma_receipt_routing_id
471 into x_routing_id
472 from rcv_parameters
473 where organization_id = p_organization_id;
474
475 END IF;
476
477 /* End Bug 9158529 */
478
479 IF (l_debug = 1) THEN
480 print_debug('insert_txn_interface: from rcv parameters: x_routing_id = '|| x_routing_id, 4);
481 END IF;
482
483 Exception
484 WHEN OTHERS THEN
485 IF (l_debug = 1) THEN
486 print_debug('insert_txn_interface: Exception in getting the routing id from rcv parameters', 4);
487 print_debug('insert_txn_interface: routing id is set to what fetched from post_query : x_routing_id ='|| x_routing_id, 4);
488 END IF;
489 End;
490 END IF;
491
492 /*
493 select routing_name
494 into l_rcv_transaction_rec.routing_name
495 from rcv_routing_headers
496 where routing_header_id = x_routing_id;
497 */
498 x_available_qty := l_rcv_transaction_rec.ordered_qty;
499 -- x_uom := l_rcv_transaction_rec.ordered_uom;
500
501 END IF;
502
503 -- using a nvl around p_qa_routing_id as calling apis pass null sometimes
504
505 IF (Nvl(p_qa_routing_id,-1) = -1) THEN
506 --BUG 3346758: For Int Ship, if the intrasit shipment is set
507 --created with a routing id, then the user go and change it in the
508 --shipping network form. Post_query above would return a different
509 --id then the one passed in UI. So, the check below is used to
510 --bypass this scenario.
511 IF (l_rcv_transaction_rec.routing_id IS NULL) THEN
512 l_rcv_transaction_rec.routing_id := x_routing_id;
513 END IF;
514 ELSE
515 l_rcv_transaction_rec.routing_id := p_qa_routing_id;
516 END IF;
517
518 IF inv_rcv_common_apis.g_po_startup_value.blind_receiving_flag = 'Y' THEN
519 x_available_qty := 0;
520 l_rcv_transaction_rec.ordered_qty := 0;
521 END IF;
522
523 IF (NOT x_valid_ship_to_location) THEN
524 l_rcv_transaction_rec.ship_to_location_id := '';
525 -- l_rcv_transaction_rec.ship_to_location := '';
526 END IF;
527
528 IF (NVL(l_rcv_transaction_rec.receipt_source_code, 'VENDOR') = 'CUSTOMER') THEN
529 -- Final destination for an RMA receiving trx. is always inventory.
530 SELECT displayed_field
531 , lookup_code
532 INTO x_destination_type_dsp
533 , x_destination_type_code
534 FROM po_lookup_codes
535 WHERE lookup_code = 'INVENTORY'
536 AND lookup_type = 'RCV DESTINATION TYPE';
537 END IF;
538
539 l_rcv_transaction_rec.destination_type_code_hold := x_destination_type_code;
540
541 --Bug #3792668
542 --Checking the conversion rate has been defined for a currency
543 --which is other than functional one for the transaction date.
544 --Taken out this portion of code from the check --> IF l_rcv_transaction_rec.routing_id IN('1', '2') THEN
545 --Changes Start
546
547 IF l_rcv_transaction_rec.routing_id IN('1', '2') THEN
548 IF x_num_of_distributions <= 1 THEN
549 l_rcv_transaction_rec.currency_conversion_rate := x_rate;
550 l_rcv_transaction_rec.currency_conversion_date := x_rate_date;
551 END IF;
552 END IF;
553
554 -- currency coversion info post query
555 -- copied from rcv_currency_c1.PostQuery (RCVRCCUR.pld)
556
557 IF l_rcv_transaction_rec.match_option <> 'P' THEN
558 l_rcv_transaction_rec.currency_conversion_date := l_sysdate;
559
560 IF (l_rcv_transaction_rec.currency_code <> inv_rcv_common_apis.g_po_startup_value.currency_code) THEN
561 l_rate := l_rcv_transaction_rec.currency_conversion_rate;
562
563 IF (l_rcv_transaction_rec.currency_conversion_type <> 'User') THEN
564 BEGIN
565 l_rate :=
566 gl_currency_api.get_rate(
567 inv_rcv_common_apis.g_po_startup_value.sob_id
568 , l_rcv_transaction_rec.currency_code
569 , l_rcv_transaction_rec.currency_conversion_date
570 , l_rcv_transaction_rec.currency_conversion_type
571 );
572
573 EXCEPTION
574 WHEN gl_currency_api.no_rate THEN
575 l_rate := NULL;
576 WHEN gl_currency_api.invalid_currency THEN
577 l_rate := NULL;
578 WHEN OTHERS THEN
579 IF (l_debug = 1) THEN
580 print_debug('insert_txn_interface: ERROR in getting the Conversion Rate' , 4);
581 END IF;
582
583 RAISE fnd_api.g_exc_unexpected_error;
584 END;
585
586 IF (l_debug = 1) THEN
587 print_debug('insert_txn_interface : l_rate : ' || l_rate, 4);
588 END IF;
589
590 -- Give error message to user that no rate has been found
591 IF l_rate IS NULL THEN
592 fnd_message.set_name('PO', 'PO_CPO_NO_RATE_FOR_DATE');
593 fnd_msg_pub.add;
594 IF (l_debug = 1) THEN
595 print_debug('insert_txn_interface: No Conversion rate has been defined for the currency : ' || l_rcv_transaction_rec.currency_code || ' for the txn date : ' || l_rcv_transaction_rec.currency_conversion_date , 4);
596 END IF;
597 RAISE FND_API.G_EXC_ERROR;
598 END IF;
599
600 END IF;
601
602 l_rcv_transaction_rec.currency_conversion_rate := l_rate;
603 END IF;
604 END IF;
605 --End of fix for the Bug #3792668
606
607
608 IF l_rcv_transaction_rec.routing_id IN('1', '2') THEN
609 l_rcv_transaction_rec.destination_type_code := 'RECEIVING';
610 -- following fields will be set at po_distribution level if
611 -- it has a direct routing
612 l_rcv_transaction_rec.po_distribution_id := x_po_distribution_id;
613 l_rcv_transaction_rec.deliver_to_location_id := x_deliver_to_location_id;
614 -- l_rcv_transaction_rec.locator_id := x_deliver_to_locator_id;
615 l_rcv_transaction_rec.deliver_to_person_id := x_deliver_to_person_id;
616 -- l_rcv_transaction_rec.locator_id := x_deliver_to_locator_id; --RCVCLOCSSUPPORT
617
618 -- IF x_deliver_to_sub IS NOT NULL THEN
619 -- l_rcv_transaction_rec.destination_subinventory := x_deliver_to_sub;
620 -- END IF; RCVLOCSSUPPORT --RCVLOCSSUPPORT
621
622 IF (x_wip_entity_id > 0) THEN
623 l_rcv_transaction_rec.wip_entity_id := x_wip_entity_id;
624 l_rcv_transaction_rec.wip_line_id := x_wip_line_id;
625 l_rcv_transaction_rec.wip_repetitive_schedule_id := x_wip_repetitive_schedule_id;
626 l_rcv_transaction_rec.wip_operation_seq_num := x_wip_operation_seq_num;
627 l_rcv_transaction_rec.wip_resource_seq_num := x_wip_resource_seq_num;
628 l_rcv_transaction_rec.bom_resource_id := x_bom_resource_id;
629 END IF;
630
631 IF (l_debug = 1) THEN
632 print_debug('insert_txn_interface: revision2 - ' || x_item_revision, 4);
633 END IF;
634
635 -- revision needs to be taken care of by matching
636
637 IF x_item_revision IS NOT NULL THEN
638 l_rcv_transaction_rec.item_revision := x_item_revision;
639 END IF;
640
641 IF (
642 x_req_line_id IS NOT NULL
643 AND x_deliver_to_locator_id IS NOT NULL
644 AND NVL(l_rcv_transaction_rec.receipt_source_code, 'VENDOR') <> 'VENDOR'
645 ) THEN
646 SELECT project_id
647 , task_id
648 INTO x_project_id
649 , x_task_id
650 FROM po_req_distributions
651 WHERE requisition_line_id = x_req_line_id;
652 END IF;
653
654 IF (
655 l_rcv_transaction_rec.receipt_source_code = 'CUSTOMER'
656 AND x_oe_order_line_id IS NOT NULL
657 AND x_deliver_to_locator_id IS NOT NULL
658 ) THEN
659 SELECT project_id
660 , task_id
661 INTO x_project_id
662 , x_task_id
663 FROM oe_order_lines_all
664 WHERE line_id = x_oe_order_line_id;
665 END IF;
666
667 IF x_project_id IS NOT NULL THEN
668 pjm_project_locator.get_defaultprojectlocator(
669 p_organization_id
670 , x_deliver_to_locator_id
671 , x_project_id
672 , x_task_id
673 , x_deliver_to_locator_id);
674 END IF;
675
676 -- l_rcv_transaction_rec.locator_id := x_deliver_to_locator_id;
677 ELSE
678 IF (NVL(l_rcv_transaction_rec.receipt_source_code, 'VENDOR') = 'CUSTOMER') THEN
679 SELECT lookup_code
680 INTO l_rcv_transaction_rec.destination_type_code
681 FROM po_lookup_codes
682 WHERE lookup_code = 'INVENTORY'
683 AND lookup_type = 'RCV DESTINATION TYPE';
684 END IF;
685 END IF;
686
687 IF l_rcv_transaction_rec.destination_type_code = 'RECEIVING'
688 AND p_location_id IS NOT NULL THEN
689 l_rcv_transaction_rec.ship_to_location_id := p_location_id;
690 ELSE
691 l_rcv_transaction_rec.deliver_to_location_id := p_location_id;
692 END IF;
693 -- end defaulting
694
695 -- prepare other values before inserting into RTI
696 -- this part of code is replicating RCV_RECEIPTS_TH.insert_transaction (RCVRCERL.pld)
697 l_primary_uom := l_rcv_transaction_rec.primary_uom;
698 l_source_type_code := l_rcv_transaction_rec.receipt_source_code;
699 l_source_doc_code := l_rcv_transaction_rec.order_type_code;
700 l_to_org_id := l_rcv_transaction_rec.to_organization_id;
701 l_sub_unordered_code := l_rcv_transaction_rec.substitute_receipt;
702 --OPM Convergence
703 l_secondary_unit_of_measure := l_rcv_transaction_rec.secondary_uom;
704 l_secondary_uom_code := l_rcv_transaction_rec.secondary_uom_code;
705 l_secondary_quantity := l_rcv_transaction_rec .secondary_quantity;
706 --end of changes for OPM Convergence
707
708 print_debug('l_secondary_quantity ' || l_secondary_quantity,4);
709 print_debug('l_secondary_uom_code ' || l_secondary_uom_code,4);
710 print_debug('l_secondary_unit_of_measure ' || l_secondary_unit_of_measure,4);
711
712
713 -- For Bug 7440217 added LCM Doc type along with ASN
714 IF l_rcv_transaction_rec.source_type_code IN('VENDOR', 'ASN', 'LCM') THEN
715 -- End for Bug 7440217
716 l_vendor_id := l_rcv_transaction_rec.vendor_id;
717 l_vendor_site_id := l_rcv_transaction_rec.vendor_site_id;
718 l_po_header_id := l_rcv_transaction_rec.po_header_id;
719 l_po_release_id := l_rcv_transaction_rec.po_release_id;
720 l_po_line_id := l_rcv_transaction_rec.po_line_id;
721 l_po_line_location_id := l_rcv_transaction_rec.po_line_location_id;
722 ELSIF l_rcv_transaction_rec.source_type_code = 'CUSTOMER' THEN
723 l_customer_id := l_rcv_transaction_rec.customer_id;
724 l_customer_site_id := l_rcv_transaction_rec.customer_site_id;
725 l_oe_order_header_id := l_rcv_transaction_rec.oe_order_header_id;
726 l_oe_order_line_id := l_rcv_transaction_rec.oe_order_line_id;
727 ELSIF l_rcv_transaction_rec.source_type_code = 'INTERNAL' THEN
728 l_req_line_id := l_rcv_transaction_rec.req_line_id;
729 l_from_org_id := l_rcv_transaction_rec.from_organization_id;
730 l_shipment_line_id := l_rcv_transaction_rec.rcv_shipment_line_id;
731 END IF;
732
733 -- For Bug 7440217 added LCM Doc type along with ASN
734 IF l_rcv_transaction_rec.source_type_code IN ('ASN', 'LCM') THEN
735 -- End for Bug 7440217
736 l_shipment_line_id := l_rcv_transaction_rec.rcv_shipment_line_id;
737 END IF;
738
739 IF l_rcv_transaction_rec.destination_type_code = 'RECEIVING' THEN
740 l_auto_transact_code := 'RECEIVE';
741 l_location_id := l_rcv_transaction_rec.ship_to_location_id;
742 l_subinventory := l_rcv_transaction_rec.destination_subinventory; --RCVLOCSSUPPORT
743 l_locator_id := l_rcv_transaction_rec.locator_id;
744 ELSE
745 l_auto_transact_code := 'DELIVER';
746 l_po_distribution_id := l_rcv_transaction_rec.po_distribution_id;
747 l_deliver_to_person_id := l_rcv_transaction_rec.deliver_to_person_id;
748 l_deliver_to_location_id := l_rcv_transaction_rec.deliver_to_location_id;
749 l_subinventory := l_rcv_transaction_rec.destination_subinventory;
750 l_locator_id := l_rcv_transaction_rec.locator_id;
751 l_location_id := l_rcv_transaction_rec.deliver_to_location_id;
752
753 -- For Bug 7440217 added LCM Doc type along with ASN
754 IF l_rcv_transaction_rec.source_type_code IN('VENDOR', 'ASN', 'LCM') THEN
755 -- End for Bug 7440217
756 l_wip_entity_id := l_rcv_transaction_rec.wip_entity_id;
757 l_wip_line_id := l_rcv_transaction_rec.wip_line_id;
758 l_department_code := l_rcv_transaction_rec.department_code;
759 l_wip_rep_sched_id := l_rcv_transaction_rec.wip_repetitive_schedule_id;
760 l_wip_oper_seq_num := l_rcv_transaction_rec.wip_operation_seq_num;
761 l_wip_res_seq_num := l_rcv_transaction_rec.wip_resource_seq_num;
762 l_bom_resource_id := l_rcv_transaction_rec.bom_resource_id;
763 END IF;
764 END IF;
765
766 l_sub_unordered_code := l_rcv_transaction_rec.substitute_receipt;
767
768 IF l_rcv_transaction_rec.receipt_source_code = 'CUSTOMER' THEN
769 l_source_doc_code := 'RMA';
770 END IF;
771
772 -- insert this record into RTI
773 -- Insert the row into the interface table using
774 -- the table handler call for the
775 -- rcv_transactions_interface table
776
777 -- For inter-org shipment and ASN receipt, shipment header id is set already
778 -- For Normal PO, we generate a shipment header id at this point,
779 -- then use the same when actually inserting record into RSH.
780 -- If it is to receive a PO that belongs to an ASN,
781 -- we need to create a new shipment header for it
782
783 -- If patchset J since the g_shipment_header_id is cleared from
784 -- rcv_clear_global in INVRCVCB.pls and not g_header_intf_id
785 -- we look at g_shipment_header_id to figure out if we need
786 -- to generate a new value for header_intf_id to insert in RTI.
787 IF g_shipment_header_id IS NULL THEN
788 SELECT rcv_headers_interface_s.NEXTVAL
789 INTO g_header_intf_id
790 FROM dual;
791 END IF;
792
793 IF l_rcv_transaction_rec.source_type_code = 'INTERNAL'
794 -- For Bug 7440217
795 OR(l_rcv_transaction_rec.source_type_code IN ('ASN', 'LCM')
796 -- End for Bug 7440217
797 AND p_source_type <> 'VENDOR') THEN
798 g_shipment_header_id := l_rcv_transaction_rec.rcv_shipment_header_id;
799 END IF;
800
801 IF g_shipment_header_id IS NULL THEN
802 SELECT rcv_shipment_headers_s.NEXTVAL
803 INTO g_shipment_header_id
804 FROM DUAL;
805 END IF;
806
807 IF (l_debug = 1) THEN
808 print_debug('insert_txn_interface: 4 before rcv_trx_interface_insert_pkg.insert_row '
809 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
810 , 4);
811 END IF;
812
813 IF (l_debug = 1) THEN
814 print_debug('insert_txn_interface: revision3 - ' || l_rcv_transaction_rec.item_revision, 4);
815 END IF;
816
817 IF (l_debug = 1) THEN
818 print_debug('insert_txn_interface: rcv sub loc - ' || l_subinventory ||' , '|| l_locator_id, 4);
819 END IF;
820
821 IF (l_debug = 1) THEN
822 print_debug('insert_txn_interface before insert row value of coutry of origin is '
823 || l_rcv_transaction_rec.country_of_origin_code
824 , 4);
825 END IF;
826
827 /* If INV and PO J are installed, :
828 * -> shipment_header_id should be inserted as null but header_interface_id
829 * should be inserted. Header_interface_id will be non null only if INV
830 * and PO J are installed (or higher).
831 * -> Populate values for three new columns lpn_group_id, validation_flag
832 * and header_interface_id_id
833 * -> Populate project_id and task_id in RTI from inputs
834 */
835 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
836 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
837 IF ((l_rcv_transaction_rec.source_type_code = 'INTERNAL') OR
838 -- For Bug 7440217
839 (l_rcv_transaction_rec.source_type_code IN ('ASN', 'LCM') AND p_source_type <> 'VENDOR')) THEN
840 -- End for Bug 7440217
841 IF (l_debug = 1) THEN
842 print_debug('Setting the shipment_header_id as this may be a INTSHIP/ASN Receive TXN', 4);
843 END IF;
844 l_shipment_header_id := g_shipment_header_id;
845 ELSE
846 IF (l_debug = 1) THEN
847 print_debug('Nulling the shipment_header_id to insert for J code', 4);
848 END IF;
849 l_shipment_header_id := NULL;
850 END IF;
851
852 --Set the values of the new columns to be populated in RTI
853 l_lpn_group_id := p_group_id;
854 l_validation_flag := 'Y';
855 l_header_interface_id := g_header_intf_id;
856
857 IF p_project_id = -9999 THEN
858 l_project_id := NULL;
859 END IF;
860
861 IF p_task_id = -9999 THEN
862 l_task_id := NULL;
863 END IF;
864
865 --If INV or PO patch levels are lower than J
866 ELSE
867 l_shipment_header_id := g_shipment_header_id;
868 l_header_interface_id := NULL;
869 l_lpn_group_id := NULL;
870 l_validation_flag := NULL;
871 l_project_id := NULL;
872 l_task_id := NULL;
873 END IF;
874
875 -- bug 3452845
876 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
877 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
878 l_txn_date := Sysdate;
879 ELSE
880 l_txn_date := Trunc(Sysdate);
881 END IF;
882
883 --BUG 4730474: populate the document number column when receiving
884 --against INTSHP/INTREQ so that the receiving preprocessor can
885 --match to the right line
886 IF (p_rcv_rcpt_rec.receipt_source_code = 'INVENTORY') then --bug 5483231
887 l_rcv_transaction_rec.rcv_line_number := p_rcv_rcpt_rec.rcv_line_number;
888 ELSE
889 l_rcv_transaction_rec.rcv_line_number := NULL;
890 END IF;
891
892 print_debug('b4 inserting l_secondary_quantity ' || l_secondary_quantity,4);
893 print_debug('b4 insertingl_secondary_uom_code ' || l_secondary_uom_code,4);
894 print_debug('b4 insertingl_secondary_unit_of_measure ' || l_secondary_unit_of_measure,4);
895
896 --<R12 MOAC>
897 l_operating_unit_id := inv_rcv_common_apis.get_operating_unit_id(
898 l_rcv_transaction_rec.receipt_source_code,
899 l_rcv_transaction_rec.po_header_id,
900 l_rcv_transaction_rec.req_line_id,
901 l_rcv_transaction_rec.oe_order_header_id );
902
903 --Using the direct insert statement here rather than table handler
904
905 /*bug 4697949.Populating the rti.item with item_id from po_line
906 and populating substitute_item_id with item_id so that the transaction
907 passes the validation.also nulling out description so that it can bedefaulted
908 correctly later on*/
909
910 /** Bug: 5598511
911 * Added the following conditions rcv_shipment_header_id not null and
912 * item_id not null.
913 */
914 IF l_po_line_id IS NOT null
915 and l_rcv_transaction_rec.rcv_shipment_header_id IS NULL
916 and l_rcv_transaction_rec.item_id IS NOT NULL THEN
917 SELECT item_id
918 INTO l_po_item_id
919 FROM po_lines_all pol
920 WHERE pol.po_line_id = l_po_line_id;
921
922 IF (l_po_item_id <> l_rcv_transaction_rec.item_id) THEN
923 l_substitute_item_id := l_rcv_transaction_rec.item_id;
924 l_rcv_transaction_rec.item_id := l_po_item_id;
925 l_rcv_transaction_rec.item_description := null;
926 END IF;
927 END IF;
928 print_debug('l_express_transaction: ' || l_express_transaction,4);
929 -- bug 4697949 end
930 INSERT INTO rcv_transactions_interface
931 (
932 interface_transaction_id
933 , GROUP_ID
934 , last_update_date
935 , last_updated_by
936 , creation_date
937 , created_by
938 , last_update_login
939 , transaction_type
940 , transaction_date
941 , processing_status_code
942 , processing_mode_code
943 , processing_request_id
944 , transaction_status_code
945 , category_id
946 , quantity
947 , unit_of_measure
948 , interface_source_code
949 , interface_source_line_id
950 , inv_transaction_id
951 , item_id
952 , item_description
953 , item_revision
954 , uom_code
955 , employee_id
956 , auto_transact_code
957 , shipment_header_id
958 , shipment_line_id
959 , ship_to_location_id
960 , primary_quantity
961 , primary_unit_of_measure
962 , receipt_source_code
963 , vendor_id
964 , vendor_site_id
965 , from_organization_id
966 , to_organization_id
967 , routing_header_id
968 , routing_step_id
969 , source_document_code
970 , parent_transaction_id
971 , po_header_id
972 , po_revision_num
973 , po_release_id
974 , po_line_id
975 , po_line_location_id
976 , po_unit_price
977 , currency_code
978 , currency_conversion_type
979 , currency_conversion_rate
980 , currency_conversion_date
981 , po_distribution_id
982 , requisition_line_id
983 , req_distribution_id
984 , charge_account_id
985 , substitute_unordered_code
986 , receipt_exception_flag
987 , accrual_status_code
988 , inspection_status_code
989 , inspection_quality_code
990 , destination_type_code
991 , deliver_to_person_id
992 , location_id
993 , deliver_to_location_id
994 , subinventory
995 , locator_id
996 , wip_entity_id
997 , wip_line_id
998 , department_code
999 , wip_repetitive_schedule_id
1000 , wip_operation_seq_num
1001 , wip_resource_seq_num
1002 , bom_resource_id
1003 , shipment_num
1004 , freight_carrier_code
1005 , bill_of_lading
1006 , packing_slip
1007 , shipped_date
1008 , expected_receipt_date
1009 , actual_cost
1010 , transfer_cost
1011 , transportation_cost
1012 , transportation_account_id
1013 , num_of_containers
1014 , waybill_airbill_num
1015 , vendor_item_num
1016 , vendor_lot_num
1017 , rma_reference
1018 , comments
1019 , attribute_category
1020 , attribute1
1021 , attribute2
1022 , attribute3
1023 , attribute4
1024 , attribute5
1025 , attribute6
1026 , attribute7
1027 , attribute8
1028 , attribute9
1029 , attribute10
1030 , attribute11
1031 , attribute12
1032 , attribute13
1033 , attribute14
1034 , attribute15
1035 , ship_head_attribute_category
1036 , ship_head_attribute1
1037 , ship_head_attribute2
1038 , ship_head_attribute3
1039 , ship_head_attribute4
1040 , ship_head_attribute5
1041 , ship_head_attribute6
1042 , ship_head_attribute7
1043 , ship_head_attribute8
1044 , ship_head_attribute9
1045 , ship_head_attribute10
1046 , ship_head_attribute11
1047 , ship_head_attribute12
1048 , ship_head_attribute13
1049 , ship_head_attribute14
1050 , ship_head_attribute15
1051 , ship_line_attribute_category
1052 , ship_line_attribute1
1053 , ship_line_attribute2
1054 , ship_line_attribute3
1055 , ship_line_attribute4
1056 , ship_line_attribute5
1057 , ship_line_attribute6
1058 , ship_line_attribute7
1059 , ship_line_attribute8
1060 , ship_line_attribute9
1061 , ship_line_attribute10
1062 , ship_line_attribute11
1063 , ship_line_attribute12
1064 , ship_line_attribute13
1065 , ship_line_attribute14
1066 , ship_line_attribute15
1067 , ussgl_transaction_code
1068 , government_context
1069 , reason_id
1070 , destination_context
1071 , source_doc_quantity
1072 , source_doc_unit_of_measure
1073 , use_mtl_lot
1074 , use_mtl_serial
1075 , qa_collection_id
1076 , country_of_origin_code
1077 , oe_order_header_id
1078 , oe_order_line_id
1079 , customer_item_num
1080 , customer_id
1081 , customer_site_id
1082 , put_away_rule_id
1083 , put_away_strategy_id
1084 , lpn_id
1085 , transfer_lpn_id
1086 , cost_group_id
1087 , mmtt_temp_id
1088 , mobile_txn
1089 , transfer_cost_group_id
1090 , lpn_group_id
1091 , validation_flag
1092 , header_interface_id
1093 , project_id
1094 , task_id
1095 , secondary_unit_of_measure --OPM Convergence
1096 , secondary_quantity --OPM Convergence
1097 , secondary_uom_code --OPM Convergence
1098 , org_id --<R12 MOAC>
1099 , document_line_num --BUG 4730474
1100 , substitute_item_id --bug 4697949
1101 , express_transaction --bug 5550783
1102 )
1103 VALUES (
1104 l_interface_transaction_id
1105 , p_group_id
1106 , l_sysdate
1107 , inv_rcv_common_apis.g_po_startup_value.user_id /* Last Updated By */
1108 , l_sysdate /* Created Date */
1109 , inv_rcv_common_apis.g_po_startup_value.user_id /* Created By */
1110 , inv_rcv_common_apis.g_po_startup_value.user_id /* last Update Login */
1111 , p_transaction_type /* transaction type */
1112 , l_txn_date /* transaction date */
1113 , 'PENDING' /* Processing status code */
1114 , inv_rcv_common_apis.g_po_startup_value.transaction_mode
1115 , NULL
1116 , 'PENDING' /* Transaction status code */
1117 , l_rcv_transaction_rec.item_category_id
1118 , l_rcv_transaction_rec.transaction_qty
1119 , l_rcv_transaction_rec.transaction_uom
1120 , 'RCV' /* interface source code */
1121 , NULL /* interface source line id */
1122 , NULL /* inv_transaction id */
1123 , l_rcv_transaction_rec.item_id
1124 , l_rcv_transaction_rec.item_description
1125 , l_rcv_transaction_rec.item_revision
1126 , l_rcv_transaction_rec.uom_code
1127 , inv_rcv_common_apis.g_po_startup_value.employee_id -- Fix for bug 2073164
1128 , l_auto_transact_code /* Auto transact code */
1129 , l_shipment_header_id /* shipment header id */
1130 , l_shipment_line_id /* shipment line id */
1131 , l_rcv_transaction_rec.ship_to_location_id
1132 , l_rcv_transaction_rec.primary_quantity /* primary quantity */
1133 , l_primary_uom /* primary uom */
1134 , l_source_type_code /* receipt source code */
1135 , l_vendor_id
1136 , l_vendor_site_id
1137 , l_from_org_id /* from org id */
1138 , l_to_org_id /* to org id */
1139 , l_rcv_transaction_rec.routing_id
1140 , 1 /* routing step id */
1141 , l_source_doc_code /* source document code */
1142 , NULL /* Parent trx id */
1143 , l_po_header_id
1144 , NULL /* PO Revision number */
1145 , l_po_release_id
1146 , l_po_line_id
1147 , l_po_line_location_id
1148 , l_rcv_transaction_rec.unit_price
1149 , l_rcv_transaction_rec.currency_code /* Currency_Code */
1150 , l_rcv_transaction_rec.currency_conversion_type
1151 , l_rcv_transaction_rec.currency_conversion_rate
1152 , TRUNC(l_rcv_transaction_rec.currency_conversion_date)
1153 , l_po_distribution_id
1154 , l_req_line_id
1155 , l_rcv_transaction_rec.req_distribution_id
1156 , NULL /* Charge_Account_Id */
1157 , l_sub_unordered_code /* Substitute_Unordered_Code */
1158 , l_rcv_transaction_rec.receipt_exception /* Receipt_Exception_Flag forms check box?*/
1159 , NULL /* Accrual_Status_Code */
1160 , 'NOT INSPECTED' /* Inspection_Status_Code */
1161 , NULL /* Inspection_Quality_Code */
1162 , l_rcv_transaction_rec.destination_type_code /* Destination_Type_Code */
1163 , l_deliver_to_person_id /* Deliver_To_Person_Id */
1164 , l_location_id /* Location_Id */
1165 , l_deliver_to_location_id /* Deliver_To_Location_Id */
1166 , l_subinventory /* Subinventory */
1167 , l_locator_id /* Locator_Id */
1168 , l_wip_entity_id /* Wip_Entity_Id */
1169 , l_wip_line_id /* Wip_Line_Id */
1170 , l_department_code /* Department_Code */
1171 , l_wip_rep_sched_id /* Wip_Repetitive_Schedule_Id */
1172 , l_wip_oper_seq_num /* Wip_Operation_Seq_Num */
1173 , l_wip_res_seq_num /* Wip_Resource_Seq_Num */
1174 , l_bom_resource_id /* Bom_Resource_Id */
1175 , l_rcv_transaction_rec.rcv_shipment_number
1176 , NULL
1177 , NULL /* Bill_Of_Lading */
1178 , NULL /* Packing_Slip */
1179 , TRUNC(l_rcv_transaction_rec.shipped_date)
1180 , TRUNC(l_rcv_transaction_rec.expected_receipt_date) /* Expected_Receipt_Date */
1181 , NULL /* Actual_Cost */
1182 , NULL /* Transfer_Cost */
1183 , NULL /* Transportation_Cost */
1184 , NULL /* Transportation_Account_Id */
1185 , NULL /* Num_Of_Containers */
1186 , NULL /* Waybill_Airbill_Num */
1187 , l_rcv_transaction_rec.vendor_item_number /* Vendor_Item_Num */
1188 , l_rcv_transaction_rec.vendor_lot_num /* Vendor_Lot_Num */
1189 , NULL /* Rma_Reference */
1190 , l_rcv_transaction_rec.comments /* Comments ? from form*/
1191 , l_rcv_transaction_rec.attribute_category /* Attribute_Category */
1192 , l_rcv_transaction_rec.attribute1 /* Attribute1 */
1193 , l_rcv_transaction_rec.attribute2 /* Attribute2 */
1194 , l_rcv_transaction_rec.attribute3 /* Attribute3 */
1195 , l_rcv_transaction_rec.attribute4 /* Attribute4 */
1196 , l_rcv_transaction_rec.attribute5 /* Attribute5 */
1197 , l_rcv_transaction_rec.attribute6 /* Attribute6 */
1198 , l_rcv_transaction_rec.attribute7 /* Attribute7 */
1199 , l_rcv_transaction_rec.attribute8 /* Attribute8 */
1200 , l_rcv_transaction_rec.attribute9 /* Attribute9 */
1201 , l_rcv_transaction_rec.attribute10 /* Attribute10 */
1202 , l_rcv_transaction_rec.attribute11 /* Attribute11 */
1203 , l_rcv_transaction_rec.attribute12 /* Attribute12 */
1204 , l_rcv_transaction_rec.attribute13 /* Attribute13 */
1205 , l_rcv_transaction_rec.attribute14 /* Attribute14 */
1206 , l_rcv_transaction_rec.attribute15 /* Attribute15 */
1207 , NULL /* Ship_Head_Attribute_Category */
1208 , NULL /* Ship_Head_Attribute1 */
1209 , NULL /* Ship_Head_Attribute2 */
1210 , NULL /* Ship_Head_Attribute3 */
1211 , NULL /* Ship_Head_Attribute4 */
1212 , NULL /* Ship_Head_Attribute5 */
1213 , NULL /* Ship_Head_Attribute6 */
1214 , NULL /* Ship_Head_Attribute7 */
1215 , NULL /* Ship_Head_Attribute8 */
1216 , NULL /* Ship_Head_Attribute9 */
1217 , NULL /* Ship_Head_Attribute10 */
1218 , NULL /* Ship_Head_Attribute11 */
1219 , NULL /* Ship_Head_Attribute12 */
1220 , NULL /* Ship_Head_Attribute13 */
1221 , NULL /* Ship_Head_Attribute14 */
1222 , NULL /* Ship_Head_Attribute15 */
1223 , NULL /* Ship_Line_Attribute_Category */
1224 , NULL /* Ship_Line_Attribute1 */
1225 , NULL /* Ship_Line_Attribute2 */
1226 , NULL /* Ship_Line_Attribute3 */
1227 , NULL /* Ship_Line_Attribute4 */
1228 , NULL /* Ship_Line_Attribute5 */
1229 , NULL /* Ship_Line_Attribute6 */
1230 , NULL /* Ship_Line_Attribute7 */
1231 , NULL /* Ship_Line_Attribute8 */
1232 , NULL /* Ship_Line_Attribute9 */
1233 , NULL /* Ship_Line_Attribute10 */
1234 , NULL /* Ship_Line_Attribute11 */
1235 , NULL /* Ship_Line_Attribute12 */
1236 , NULL /* Ship_Line_Attribute13 */
1237 , NULL /* Ship_Line_Attribute14 */
1238 , NULL /* Ship_Line_Attribute15 */
1239 , l_rcv_transaction_rec.ussgl_transaction_code /* Ussgl_Transaction_Code */
1240 , l_rcv_transaction_rec.government_context /* Government_Context */
1241 , l_rcv_transaction_rec.reason_id /* ? */
1242 , l_rcv_transaction_rec.destination_type_code /* Destination_Context */
1243 , l_rcv_transaction_rec.transaction_qty
1244 , l_rcv_transaction_rec.transaction_uom
1245 , l_rcv_transaction_rec.lot_control_code
1246 , l_rcv_transaction_rec.serial_number_control_code
1247 , NULL
1248 , l_rcv_transaction_rec.country_of_origin_code
1249 , l_oe_order_header_id
1250 , l_oe_order_line_id
1251 , l_customer_item_num
1252 , l_customer_id
1253 , l_customer_site_id
1254 , NULL /* PUT_AWAY_RULE_ID */
1255 , NULL /* PUT_AWAY_STRATEGY_ID */
1256 , l_rcv_transaction_rec.lpn_id /* LPN_ID */
1257 , l_rcv_transaction_rec.transfer_lpn_id /* Transfer LPN ID */
1258 , l_rcv_transaction_rec.cost_group_id /* cost_group_id */
1259 , NULL /* mmtt_temp_id */
1260 , 'Y' /* mobile_txn */
1261 , l_rcv_transaction_rec.transfer_cost_group_id /* xfer_cost_group_id*/
1262 , l_lpn_group_id
1263 , l_validation_flag
1264 , l_header_interface_id
1265 , l_project_id
1266 , l_task_id
1267 , l_secondary_unit_of_measure
1268 , l_secondary_quantity
1269 , l_secondary_uom_code
1270 , l_operating_unit_id --<R12 MOAC>
1271 , l_rcv_transaction_rec.rcv_line_number--BUG 4730474
1272 , l_substitute_item_id --bug 4697949
1273 , l_express_transaction --bug 5550783
1274 );
1275
1276 -- For Bug 7440217 added the following code to update RTI with the status as PENDING so that it gets picked up for processing
1277
1278 IF l_po_line_location_id IS NOT NULL THEN
1279 SELECT LCM_FLAG
1280 INTO v_lcm_flag
1281 FROM PO_LINE_LOCATIONS_ALL
1282 WHERE LINE_LOCATION_ID = l_po_line_location_id;
1283 END IF;
1284
1285 IF nvl(v_lcm_flag, 'N') = 'Y' THEN
1286 SELECT mp.lcm_enabled_flag
1287 INTO v_lcm_enabled_org
1288 FROM mtl_parameters mp
1289 WHERE mp.organization_id = l_to_org_id;
1290
1291 SELECT rp.pre_receive
1292 INTO v_pre_receive
1293 FROM rcv_parameters rp
1294 WHERE rp.organization_id = l_to_org_id;
1295
1296 /* SELECT LCM_FLAG
1297 INTO v_lcm_flag
1298 FROM PO_LINE_LOCATIONS_ALL
1299 WHERE LINE_LOCATION_ID = l_po_line_location_id;
1300 */
1301
1302 IF nvl(v_lcm_enabled_org, 'N') = 'Y' THEN
1303 IF nvl(v_pre_receive, 'N') = 'Y' THEN
1304
1305 SELECT LCM_SHIPMENT_LINE_ID, UNIT_LANDED_COST
1306 INTO v_lcm_ship_line_id, v_unit_landed_cost
1307 FROM rcv_shipment_lines
1308 WHERE shipment_line_id = l_shipment_line_id;
1309
1310 UPDATE rcv_transactions_interface
1311 SET lcm_shipment_line_id = v_lcm_ship_line_id,
1312 unit_landed_cost = v_unit_landed_cost
1313 WHERE interface_transaction_id = l_interface_transaction_id
1314 AND to_organization_id = l_to_org_id;
1315
1316 ELSE
1317 UPDATE rcv_transactions_interface
1318 SET processing_status_code = 'LC_PENDING',
1319 PROCESSING_MODE_CODE = 'BATCH'
1320 WHERE interface_transaction_id = l_interface_transaction_id
1321 AND to_organization_id = l_to_org_id;
1322
1323 END IF;
1324 END IF;
1325 END IF;
1326 -- End for Bug 7440217
1327
1328 -- bug 13598673 added the following update stmnt
1329 v_item_revision := l_rcv_transaction_rec.item_revision;
1330 IF v_item_revision IS NOT NULL AND l_rcv_transaction_rec.source_type_code='ASN' THEN
1331 update rcv_shipment_lines set ITEM_REVISION = v_item_revision where shipment_line_id = l_shipment_line_id;
1332 END IF;
1333 -- End of bug 13598673
1334
1335
1336 BEGIN
1337 SELECT secondary_uom_code, secondary_unit_of_measure,
1338 secondary_quantity
1339 INTO t_sec_uom_code, t_sec_uom, t_sec_qty
1340 FROM rcv_transactions_interface
1341 WHERE interface_transaction_id = l_interface_transaction_id;
1342 print_debug('t_sec_uom_code ' || t_sec_uom_code, 1);
1343 print_debug('t_sec_uom ' || t_sec_uom, 1);
1344 print_debug('t_sec_qty ' || t_sec_qty, 1);
1345 EXCEPTION
1346 WHEN OTHERS THEN
1347 print_debug('other error ' || SQLERRM,1);
1348 END;
1349 IF (l_debug = 1) THEN
1350 print_debug('About exit insert_txn_interface: 5 after rcv_trx_interface_insert_pkg.insert_row '
1351 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1352 END IF;
1353
1354 RETURN l_interface_transaction_id;
1355 END insert_txn_interface;
1356
1357 /****************************************************
1358 * This procedure populates the data structure that
1359 * stores received lot quantity.
1360 * It retrieves this info from wms_LPN_contents table
1361 ****************************************************/
1362 PROCEDURE populate_lot_rec(
1363 p_lot_number IN VARCHAR2
1364 , p_primary_qty IN NUMBER
1365 , p_txn_uom_code IN VARCHAR2
1366 , p_org_id NUMBER
1367 , p_item_id IN NUMBER
1368 , p_secondary_quantity IN NUMBER
1369 ) IS
1370 l_primary_uom VARCHAR2(3);
1371 l_txn_qty NUMBER;
1372 l_counter NUMBER;
1373 l_create_new NUMBER := 1;
1374 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1375 --OPM Convergence
1376 l_sec_txn_qty NUMBER;
1377 BEGIN
1378 IF (l_debug = 1) THEN
1379 print_debug('Enter populate_lot_rec: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1380 END IF;
1381
1382 SELECT primary_uom_code
1383 INTO l_primary_uom
1384 FROM mtl_system_items_kfv
1385 WHERE inventory_item_id = p_item_id
1386 AND organization_id = p_org_id;
1387
1388 IF (l_debug = 1) THEN
1389 print_debug('populate_lot_rec: 2 p_primary_qty = ' || p_primary_qty || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1390 print_debug('p_item_id = ' || p_item_id || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1391 print_debug('l_primary_uom = ' || l_primary_uom || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1392 print_debug('p_txn_uom_code = ' || p_txn_uom_code || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1393 END IF;
1394
1395 -- it is txn qty in primary uom passed from PackUnpack
1396 -- need to convert it to txn uom qty here
1397 IF (l_primary_uom <> p_txn_uom_code) THEN
1398 l_txn_qty := inv_rcv_cache.convert_qty
1399 (p_inventory_item_id => p_item_id
1400 ,p_from_qty => p_primary_qty
1401 ,p_from_uom_code => l_primary_uom
1402 ,p_to_uom_code => p_txn_uom_code);
1403 ELSE
1404 l_txn_qty := p_primary_qty;
1405 END IF;
1406
1407 -- bug 11887302,12539886 start
1408 IF (l_txn_qty - Trunc(l_txn_qty,0)<0.00005) THEN
1409 print_debug('Decimal dust case. l_txn_qty = ' || l_txn_qty || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1410 l_txn_qty := Trunc(l_txn_qty,0);
1411 END IF;
1412 -- bug 11887302,12539886 end
1413
1414 --OPM Convergence
1415 l_sec_txn_qty := p_secondary_quantity;
1416
1417 FOR i IN 1 .. g_rcpt_lot_qty_rec_tb.COUNT LOOP
1418 IF g_rcpt_lot_qty_rec_tb(i).lot_number = p_lot_number THEN
1419 g_rcpt_lot_qty_rec_tb(i).txn_quantity := g_rcpt_lot_qty_rec_tb(i).txn_quantity + l_txn_qty;
1420 --OPM Convergence
1421 g_rcpt_lot_qty_rec_tb(i).sec_txn_quantity := g_rcpt_lot_qty_rec_tb(i).sec_txn_quantity + l_sec_txn_qty;
1422 l_create_new := 0;
1423 EXIT;
1424 END IF;
1425 END LOOP;
1426
1427 IF l_create_new = 1 THEN
1428 l_counter := g_rcpt_lot_qty_rec_tb.COUNT + 1;
1429 g_rcpt_lot_qty_rec_tb(l_counter).txn_quantity := l_txn_qty;
1430 --OPM Convergence
1431 g_rcpt_lot_qty_rec_tb(l_counter).sec_txn_quantity := l_sec_txn_qty;
1432 g_rcpt_lot_qty_rec_tb(l_counter).lot_number := p_lot_number;
1433 END IF;
1434
1435 IF (l_debug = 1) THEN
1436 print_debug('populate_lot_rec: 3 l_txn_qty = ' || l_txn_qty || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1437 print_debug('p_lot_number = ' || p_lot_number || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1438 END IF;
1439 END populate_lot_rec;
1440
1441 /****************************************************
1442 * This procedure splits the input transaction qty
1443 * based on received lot qty
1444 * It retrieves this info from global variable g_rcpt_lot_qty_rec_tb
1445 ****************************************************/
1446 PROCEDURE split_qty_for_lot(p_txn_qty IN NUMBER, p_splitted_qty_rec_tb OUT NOCOPY rcpt_lot_qty_rec_tb_tp) IS
1447 l_new_txn_quantity NUMBER; -- the quanity user wants to split
1448 l_new_counter NUMBER := 0;
1449 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1450 BEGIN
1451 IF (l_debug = 1) THEN
1452 print_debug('Enter split_qty_for_lot: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1453 END IF;
1454
1455 l_new_txn_quantity := p_txn_qty;
1456
1457 IF (l_debug = 1) THEN
1458 print_debug('split_qty_for_lot: 1.1 txn qty :' || l_new_txn_quantity, 4);
1459 END IF;
1460
1461 FOR i IN 1 .. g_rcpt_lot_qty_rec_tb.COUNT LOOP -- Loop through all the transaction lines need to be splitted
1462 IF (l_debug = 1) THEN
1463 print_debug('split_qty_for_lot: 1.2 lot_number - ' || g_rcpt_lot_qty_rec_tb(i).lot_number, 4);
1464 print_debug('split_qty_for_lot: 1.3 lot_txn_qty - ' || g_rcpt_lot_qty_rec_tb(i).txn_quantity, 4);
1465 END IF;
1466
1467 IF l_new_txn_quantity > g_rcpt_lot_qty_rec_tb(i).txn_quantity
1468 AND g_rcpt_lot_qty_rec_tb(i).txn_quantity > 0 THEN
1469 -- reduce input qty
1470 l_new_txn_quantity := l_new_txn_quantity - g_rcpt_lot_qty_rec_tb(i).txn_quantity;
1471 -- create a record in output table
1472 l_new_counter := l_new_counter + 1;
1473 p_splitted_qty_rec_tb(l_new_counter).txn_quantity := g_rcpt_lot_qty_rec_tb(i).txn_quantity;
1474 p_splitted_qty_rec_tb(l_new_counter).lot_number := g_rcpt_lot_qty_rec_tb(i).lot_number;
1475 -- set lot record table quantity
1476 g_rcpt_lot_qty_rec_tb(i).txn_quantity := 0;
1477 ELSIF l_new_txn_quantity < g_rcpt_lot_qty_rec_tb(i).txn_quantity THEN
1478 -- create a record in output table
1479 l_new_counter := l_new_counter + 1;
1480 p_splitted_qty_rec_tb(l_new_counter).txn_quantity := l_new_txn_quantity;
1481 p_splitted_qty_rec_tb(l_new_counter).lot_number := g_rcpt_lot_qty_rec_tb(i).lot_number;
1482 -- set lot record table quantity
1483 g_rcpt_lot_qty_rec_tb(i).txn_quantity := g_rcpt_lot_qty_rec_tb(i).txn_quantity - l_new_txn_quantity;
1484 -- exit loop
1485 EXIT;
1486 ELSIF l_new_txn_quantity = g_rcpt_lot_qty_rec_tb(i).txn_quantity THEN
1487 -- create a record in output table
1488 l_new_counter := l_new_counter + 1;
1489 p_splitted_qty_rec_tb(l_new_counter).txn_quantity := l_new_txn_quantity;
1490 p_splitted_qty_rec_tb(l_new_counter).lot_number := g_rcpt_lot_qty_rec_tb(i).lot_number;
1491 -- set lot record table quantity
1492 g_rcpt_lot_qty_rec_tb(i).txn_quantity := g_rcpt_lot_qty_rec_tb(i).txn_quantity - l_new_txn_quantity;
1493 END IF;
1494 END LOOP;
1495
1496 IF (l_debug = 1) THEN
1497 print_debug('About Exit split_qty_for_lot: 2 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1498 END IF;
1499 END split_qty_for_lot;
1500
1501 /** Bug #4147209 -
1502 * New procedure added to populate the attribute_category
1503 * and attributes 1-15 columns of the enter receipts record type
1504 * with the values passed from the Mobile Receipt UI
1505 */
1506 PROCEDURE set_attribute_vals (
1507 p_rcv_rcpt_rec IN OUT NOCOPY rcv_enter_receipts_rec_tp
1508 , p_attribute_category IN VARCHAR2 DEFAULT NULL
1509 , p_attribute1 IN VARCHAR2 DEFAULT NULL
1510 , p_attribute2 IN VARCHAR2 DEFAULT NULL
1511 , p_attribute3 IN VARCHAR2 DEFAULT NULL
1512 , p_attribute4 IN VARCHAR2 DEFAULT NULL
1513 , p_attribute5 IN VARCHAR2 DEFAULT NULL
1514 , p_attribute6 IN VARCHAR2 DEFAULT NULL
1515 , p_attribute7 IN VARCHAR2 DEFAULT NULL
1516 , p_attribute8 IN VARCHAR2 DEFAULT NULL
1517 , p_attribute9 IN VARCHAR2 DEFAULT NULL
1518 , p_attribute10 IN VARCHAR2 DEFAULT NULL
1519 , p_attribute11 IN VARCHAR2 DEFAULT NULL
1520 , p_attribute12 IN VARCHAR2 DEFAULT NULL
1521 , p_attribute13 IN VARCHAR2 DEFAULT NULL
1522 , p_attribute14 IN VARCHAR2 DEFAULT NULL
1523 , p_attribute15 IN VARCHAR2 DEFAULT NULL) IS
1524 BEGIN
1525 p_rcv_rcpt_rec.attribute_category := p_attribute_category;
1526 p_rcv_rcpt_rec.attribute1 := p_attribute1;
1527 p_rcv_rcpt_rec.attribute2 := p_attribute2;
1528 p_rcv_rcpt_rec.attribute3 := p_attribute3;
1529 p_rcv_rcpt_rec.attribute4 := p_attribute4;
1530 p_rcv_rcpt_rec.attribute5 := p_attribute5;
1531 p_rcv_rcpt_rec.attribute6 := p_attribute6;
1532 p_rcv_rcpt_rec.attribute7 := p_attribute7;
1533 p_rcv_rcpt_rec.attribute8 := p_attribute8;
1534 p_rcv_rcpt_rec.attribute9 := p_attribute9;
1535 p_rcv_rcpt_rec.attribute10 := p_attribute10;
1536 p_rcv_rcpt_rec.attribute11 := p_attribute11;
1537 p_rcv_rcpt_rec.attribute12 := p_attribute12;
1538 p_rcv_rcpt_rec.attribute13 := p_attribute13;
1539 p_rcv_rcpt_rec.attribute14 := p_attribute14;
1540 p_rcv_rcpt_rec.attribute15 := p_attribute15;
1541 END set_attribute_vals;
1542
1543
1544 PROCEDURE create_po_rcpt_intf_rec(
1545 p_move_order_header_id IN OUT NOCOPY NUMBER
1546 , p_organization_id IN NUMBER
1547 , p_po_header_id IN NUMBER
1548 , p_po_release_number_id IN NUMBER
1549 , p_po_line_id IN NUMBER
1550 , p_item_id IN NUMBER
1551 , p_location_id IN NUMBER
1552 , p_rcv_qty IN NUMBER
1553 , p_rcv_uom IN VARCHAR2
1554 , p_rcv_uom_code IN VARCHAR2
1555 , p_source_type IN VARCHAR2
1556 , p_lpn_id IN NUMBER
1557 , p_lot_control_code IN NUMBER
1558 , p_revision IN VARCHAR2
1559 , p_inspect IN NUMBER
1560 , x_status OUT NOCOPY VARCHAR2
1561 , x_message OUT NOCOPY VARCHAR2
1562 , p_inv_item_id IN NUMBER DEFAULT NULL
1563 , p_item_desc IN VARCHAR2 DEFAULT NULL
1564 , p_project_id IN NUMBER DEFAULT NULL
1565 , p_task_id IN NUMBER DEFAULT NULL
1566 , p_country_code IN VARCHAR2 DEFAULT NULL
1567 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL -- RCVLOCATORSSUPPORT
1568 , p_rcv_locator_id IN NUMBER DEFAULT NULL
1569 , p_original_rti_id IN NUMBER DEFAULT NULL --Lot/Serial Support
1570 --OPM convergence
1571 , p_secondary_uom IN VARCHAR2 DEFAULT NULL
1572 , p_secondary_uom_code IN VARCHAR2 DEFAULT NULL
1573 , p_secondary_quantity IN NUMBER DEFAULT NULL
1574 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF columns
1575 , p_attribute1 IN VARCHAR2 DEFAULT NULL
1576 , p_attribute2 IN VARCHAR2 DEFAULT NULL
1577 , p_attribute3 IN VARCHAR2 DEFAULT NULL
1578 , p_attribute4 IN VARCHAR2 DEFAULT NULL
1579 , p_attribute5 IN VARCHAR2 DEFAULT NULL
1580 , p_attribute6 IN VARCHAR2 DEFAULT NULL
1581 , p_attribute7 IN VARCHAR2 DEFAULT NULL
1582 , p_attribute8 IN VARCHAR2 DEFAULT NULL
1583 , p_attribute9 IN VARCHAR2 DEFAULT NULL
1584 , p_attribute10 IN VARCHAR2 DEFAULT NULL
1585 , p_attribute11 IN VARCHAR2 DEFAULT NULL
1586 , p_attribute12 IN VARCHAR2 DEFAULT NULL
1587 , p_attribute13 IN VARCHAR2 DEFAULT NULL
1588 , p_attribute14 IN VARCHAR2 DEFAULT NULL
1589 , p_attribute15 IN VARCHAR2 DEFAULT NULL
1590 ) IS
1591 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
1592 l_rcv_transaction_rec rcv_transaction_rec_tp; -- rcv_transaction block
1593 l_interface_transaction_id NUMBER := NULL;
1594 -- this is used to keep track of the id used to insert the row in rti
1595
1596 l_transaction_type VARCHAR2(20) := 'RECEIVE';
1597 l_total_primary_qty NUMBER := 0;
1598 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
1599 l_msg_count NUMBER;
1600 l_msg_data VARCHAR2(4000);
1601 l_progress VARCHAR2(10);
1602 l_err_message VARCHAR2(100);
1603 l_temp_message VARCHAR2(100);
1604 l_msg_prod VARCHAR2(5);
1605 l_group_id NUMBER;
1606 l_inspect NUMBER;
1607 l_qa_availability VARCHAR2(30) := fnd_api.g_false;
1608 l_qa_routing_id NUMBER := -1;
1609 l_evaluation_result VARCHAR2(20);
1610 -- bug 2797704
1611 -- changed the defaulting from null to the passed values
1612 l_project_id NUMBER := p_project_id;
1613 l_task_id NUMBER := p_task_id;
1614 --Bug 4699085
1615 l_item_revision VARCHAR2(10);
1616
1617 CURSOR l_curs_rcpt_detail(v_po_line_location_id NUMBER) IS
1618 SELECT 'N' line_chkbox
1619 , 'VENDOR' source_type_code
1620 , 'VENDOR' receipt_source_code
1621 , 'PO' order_type_code
1622 , '' order_type
1623 , poll.po_header_id po_header_id
1624 , poh.segment1 po_number
1625 , poll.po_line_id po_line_id
1626 , pol.line_num po_line_number
1627 , poll.line_location_id po_line_location_id
1628 , poll.shipment_num po_shipment_number
1629 , poll.po_release_id po_release_id
1630 , por.release_num po_release_number
1631 , TO_NUMBER(NULL) req_header_id
1632 , NULL req_number
1633 , TO_NUMBER(NULL) req_line_id
1634 , TO_NUMBER(NULL) req_line
1635 , TO_NUMBER(NULL) req_distribution_id
1636 --Passing the values as NULL --Bug #3878174
1637 , TO_NUMBER(NULL) rcv_shipment_header_id
1638 , NULL rcv_shipment_number
1639 , TO_NUMBER(NULL) rcv_shipment_line_id
1640 , TO_NUMBER(NULL) rcv_line_number
1641 , TO_NUMBER(NULL) from_organization_id
1642 /*
1643 , poh.po_header_id rcv_shipment_header_id
1644 , poh.segment1 rcv_shipment_number
1645 , pol.po_line_id rcv_shipment_line_id
1646 , pol.line_num rcv_line_number
1647 , poh.po_header_id from_organization_id
1648 */
1649 , poll.ship_to_organization_id to_organization_id
1650 , poh.vendor_id vendor_id
1651 , '' SOURCE
1652 , poh.vendor_site_id vendor_site_id
1653 , '' outside_operation_flag
1654 , pol.item_id item_id
1655 , -- Bug 2073164
1656 NULL uom_code
1657 -- , pol.unit_meas_lookup_code primary_uom
1658 , msi.primary_unit_of_measure primary_uom /* Bug 5665041:Primary UOM should be taken from MSI*/
1659 , mum.uom_class primary_uom_class
1660 , NULL item_allowed_units_lookup_code
1661 , NULL item_locator_control
1662 , '' restrict_locators_code
1663 , '' restrict_subinventories_code
1664 , NULL shelf_life_code
1665 , NULL shelf_life_days
1666 , msi.serial_number_control_code serial_number_control_code
1667 , msi.lot_control_code lot_control_code
1668 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
1669 , NULL item_rev_control_flag_from
1670 , NULL item_number
1671 , pol.item_revision item_revision
1672 , pol.item_description item_description
1673 , pol.category_id item_category_id
1674 , '' hazard_class
1675 , '' un_number
1676 , pol.vendor_product_num vendor_item_number
1677 , poll.ship_to_location_id ship_to_location_id
1678 , '' ship_to_location
1679 , NULL packing_slip
1680 , poll.receiving_routing_id routing_id
1681 , '' routing_name
1682 , poll.need_by_date need_by_date
1683 , NVL(poll.promised_date, poll.need_by_date) expected_receipt_date
1684 , poll.quantity ordered_qty
1685 , pol.unit_meas_lookup_code ordered_uom
1686 , NULL ussgl_transaction_code
1687 , poll.government_context government_context
1688 , poll.inspection_required_flag inspection_required_flag
1689 , poll.receipt_required_flag receipt_required_flag
1690 , poll.enforce_ship_to_location_code enforce_ship_to_location_code
1691 , NVL(poll.price_override, pol.unit_price) unit_price
1692 , poh.currency_code currency_code
1693 , poh.rate_type currency_conversion_type
1694 , poh.rate_date currency_conversion_date
1695 , poh.rate currency_conversion_rate
1696 , poh.note_to_receiver note_to_receiver
1697 , NULL destination_type_code
1698 , TO_NUMBER(NULL) deliver_to_person_id
1699 , TO_NUMBER(NULL) deliver_to_location_id
1700 , NULL destination_subinventory
1701 , poll.attribute_category attribute_category
1702 , poll.attribute1 attribute1
1703 , poll.attribute2 attribute2
1704 , poll.attribute3 attribute3
1705 , poll.attribute4 attribute4
1706 , poll.attribute5 attribute5
1707 , poll.attribute6 attribute6
1708 , poll.attribute7 attribute7
1709 , poll.attribute8 attribute8
1710 , poll.attribute9 attribute9
1711 , poll.attribute10 attribute10
1712 , poll.attribute11 attribute11
1713 , poll.attribute12 attribute12
1714 , poll.attribute13 attribute13
1715 , poll.attribute14 attribute14
1716 , poll.attribute15 attribute15
1717 , poll.closed_code closed_code
1718 , NULL asn_type
1719 , NULL bill_of_lading
1720 , TO_DATE(NULL) shipped_date
1721 , NULL freight_carrier_code
1722 , NULL waybill_airbill_num
1723 , NULL freight_bill_num
1724 , NULL vendor_lot_num
1725 , NULL container_num
1726 , NULL truck_num
1727 , NULL bar_code_label
1728 , '' rate_type_display
1729 , poll.match_option match_option
1730 , poll.country_of_origin_code country_of_origin_code
1731 , TO_NUMBER(NULL) oe_order_header_id
1732 , TO_NUMBER(NULL) oe_order_num
1733 , TO_NUMBER(NULL) oe_order_line_id
1734 , TO_NUMBER(NULL) oe_order_line_num
1735 , TO_NUMBER(NULL) customer_id
1736 , TO_NUMBER(NULL) customer_site_id
1737 , NULL customer_item_num
1738 , NULL pll_note_to_receiver
1739 , --POLL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
1740 NULL po_distribution_id
1741 , NULL qty_ordered
1742 , NULL wip_entity_id
1743 , NULL wip_operation_seq_num
1744 , NULL wip_resource_seq_num
1745 , NULL wip_repetitive_schedule_id
1746 , NULL wip_line_id
1747 , NULL bom_resource_id
1748 , '' destination_type
1749 , '' LOCATION
1750 , NULL currency_conversion_rate_pod
1751 , NULL currency_conversion_date_pod
1752 , NULL project_id
1753 , NULL task_id
1754 , pol.secondary_uom secondary_uom --OPM Convergence
1755 , NULL secondary_uom_code --OPM Convergence
1756 , pol.secondary_qty secondary_quantity --OPM Convergence* commented out temp
1757 FROM po_headers poh
1758 , po_line_locations poll
1759 , po_lines pol
1760 , po_releases por
1761 , mtl_system_items msi
1762 , mtl_units_of_measure mum
1763 WHERE poll.line_location_id = v_po_line_location_id
1764 AND poh.po_header_id = poll.po_header_id
1765 AND pol.po_line_id = poll.po_line_id
1766 AND poll.po_release_id = por.po_release_id(+)
1767 AND mum.unit_of_measure(+) = pol.unit_meas_lookup_code
1768 AND NVL(msi.organization_id, poll.ship_to_organization_id) = poll.ship_to_organization_id
1769 AND msi.inventory_item_id(+) = pol.item_id
1770 AND poll.line_location_id IN(
1771 SELECT pod.line_location_id
1772 FROM po_distributions_all pod
1773 WHERE (
1774 p_project_id IS NULL
1775 OR(p_project_id = -9999
1776 AND pod.project_id IS NULL) --bug#2669021
1777 OR pod.project_id = p_project_id
1778 )
1779 AND(p_task_id IS NULL
1780 OR pod.task_id = p_task_id)
1781 AND pod.po_header_id = poll.po_header_id
1782 AND pod.po_line_id = poll.po_line_id
1783 AND pod.line_location_id = poll.line_location_id);
1784
1785 l_rcv_rcpt_rec rcv_enter_receipts_rec_tp;
1786 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1787
1788 --table to store all RTId, quantity and original_rti_id for lot/serial splits
1789 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
1790 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
1791 l_msni_count NUMBER := 0;
1792 l_line_id NUMBER;
1793 BEGIN
1794 IF (l_debug = 1) THEN
1795 print_debug('Enter create_po_rcpt_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1796 print_debug(p_secondary_uom,1);
1797 print_debug(p_secondary_uom_code,1);
1798 print_debug(p_secondary_quantity,1);
1799 END IF;
1800
1801 l_progress := '10';
1802 SAVEPOINT crt_po_rti_sp;
1803 x_status := fnd_api.g_ret_sts_success;
1804 l_split_lot_serial_ok := TRUE;
1805
1806 -- query po_startup_value
1807 l_progress := '20';
1808
1809 BEGIN
1810 inv_rcv_common_apis.init_startup_values(p_organization_id);
1811 EXCEPTION
1812 WHEN NO_DATA_FOUND THEN
1813 fnd_message.set_name('INV', 'INV_RCV_PARAM');
1814 fnd_msg_pub.ADD;
1815 RAISE fnd_api.g_exc_error;
1816 END;
1817
1818 l_progress := '30';
1819
1820 -- default header level non-DB items in rcv_transaction block
1821 -- and default other values need to be insert into RTI
1822 -- default l_group_id ? clear group id after done
1823 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
1824 l_progress := '40';
1825
1826 SELECT rcv_interface_groups_s.NEXTVAL
1827 INTO l_group_id
1828 FROM DUAL;
1829
1830 l_progress := '50';
1831
1832 IF (l_debug = 1) THEN
1833 print_debug(
1834 'Enter create_po_rcpt_intf_rec: 20 - Create l_group_id - l_group_id = '
1835 || l_group_id
1836 || ' '
1837 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1838 , 4
1839 );
1840 END IF;
1841
1842 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
1843 ELSE
1844 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
1845
1846 IF (l_debug = 1) THEN
1847 print_debug(
1848 'Enter create_po_rcpt_intf_rec: 30 - l_group_id exists - l_group_id = '
1849 || l_group_id
1850 || ' '
1851 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1852 , 4
1853 );
1854 END IF;
1855 END IF;
1856
1857 -- initialize input record for matching algorithm
1858 g_rcpt_match_table_gross(g_receipt_detail_index).GROUP_ID := l_group_id;
1859 g_rcpt_match_table_gross(g_receipt_detail_index).transaction_type := 'RECEIVE';
1860 g_rcpt_match_table_gross(g_receipt_detail_index).quantity := p_rcv_qty;
1861 g_rcpt_match_table_gross(g_receipt_detail_index).unit_of_measure := p_rcv_uom;
1862 --OPM Convergence
1863 /* g_rcpt_match_table_gross(g_receipt_detail_index).secondary_quantity := p_secondary_quantity;
1864 g_rcpt_match_table_gross(g_receipt_detail_index).secondary_uom := p_secondary_uom;*/
1865
1866 IF (l_debug = 1) THEN
1867 print_debug(
1868 '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')
1869 , 4
1870 );
1871 END IF;
1872
1873 IF p_inv_item_id IS NOT NULL THEN -- p_item_id has substitute item id
1874 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := p_inv_item_id;
1875 ELSE
1876 IF p_item_id IS NOT NULL THEN
1877 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := p_item_id;
1878 ELSE
1879 IF (l_debug = 1) THEN
1880 print_debug('create_po_rcpt_intf_rec: Item id is null - One time item', 4);
1881 END IF;
1882
1883 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := NULL;
1884 g_rcpt_match_table_gross(g_receipt_detail_index).item_desc := p_item_desc;
1885 END IF;
1886 END IF;
1887
1888 g_rcpt_match_table_gross(g_receipt_detail_index).revision := p_revision;
1889 g_rcpt_match_table_gross(g_receipt_detail_index).po_header_id := p_po_header_id;
1890 g_rcpt_match_table_gross(g_receipt_detail_index).po_release_id := p_po_release_number_id;
1891 g_rcpt_match_table_gross(g_receipt_detail_index).po_line_id := p_po_line_id;
1892 g_rcpt_match_table_gross(g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
1893 g_rcpt_match_table_gross(g_receipt_detail_index).ship_to_location_id := p_location_id; -- for tolerance checks in matching.
1894 g_rcpt_match_table_gross(g_receipt_detail_index).tax_amount := 0; -- ?
1895 g_rcpt_match_table_gross(g_receipt_detail_index).error_status := 'S'; -- ?
1896 g_rcpt_match_table_gross(g_receipt_detail_index).to_organization_id := p_organization_id;
1897 -- bug 2797704
1898 g_rcpt_match_table_gross(g_receipt_detail_index).project_id := p_project_id;
1899 g_rcpt_match_table_gross(g_receipt_detail_index).task_id := p_task_id;
1900 l_progress := '60';
1901
1902 IF p_item_id IS NOT NULL THEN
1903 BEGIN
1904 SELECT primary_unit_of_measure
1905 INTO g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure
1906 FROM mtl_system_items
1907 WHERE mtl_system_items.inventory_item_id = p_item_id
1908 AND mtl_system_items.organization_id = p_organization_id;
1909 EXCEPTION
1910 WHEN OTHERS THEN
1911 IF (l_debug = 1) THEN
1912 print_debug('Primary_uom is null should not be null', 4);
1913 END IF;
1914
1915 l_progress := '65';
1916 RAISE fnd_api.g_exc_error;
1917 END;
1918 ELSE
1919 g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure := NULL;
1920 --OPM Convergence..should this be unit_of_measure????
1921 -- g_rcpt_match_table_gross(g_receipt_detail_index).secondary_uom := NULL;
1922 END IF;
1923
1924 l_progress := '70';
1925
1926 IF (l_debug = 1) THEN
1927 print_debug('create_po_rcpt_intf_rec: 35 - p_inspect = '||p_inspect, 4);
1928 END IF;
1929
1930 -- BUG 3325627: Pass inspection status to matching logic
1931 IF p_inspect IS NOT NULL AND p_inspect = 1 THEN
1932 g_rcpt_match_table_gross(g_receipt_detail_index).inspection_status_code := 'Y';
1933 ELSE
1934 g_rcpt_match_table_gross(g_receipt_detail_index).inspection_status_code := 'N';
1935 END IF;
1936
1937 IF (l_debug = 1) THEN
1938 print_debug('create_po_rcpt_intf_rec: 40 - before matching ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1939 END IF;
1940
1941 inv_rcv_txn_interface.matching_logic(
1942 x_return_status => l_return_status
1943 , --?
1944 x_msg_count => l_msg_count
1945 , x_msg_data => l_msg_data
1946 , x_cascaded_table => g_rcpt_match_table_gross
1947 , n => g_receipt_detail_index
1948 , temp_cascaded_table => l_rcpt_match_table_detail
1949 , p_receipt_num => NULL
1950 , p_shipment_header_id => NULL
1951 , p_lpn_id => NULL
1952 );
1953
1954 IF (l_debug = 1) THEN
1955 print_debug('create_po_rcpt_intf_rec: 50 - after matching ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
1956 print_debug('create_po_rcpt_intf_rec: 50.1 - after matching l_return_status = ' || l_return_status, 4);
1957 print_debug('create_po_rcpt_intf_rec: 50.2 - after matching l_msg_count = ' || l_msg_count, 4);
1958 print_debug('create_po_rcpt_intf_rec: 50.3 - after matching l_msg_data = ' || l_msg_data, 4);
1959 END IF;
1960
1961 -- x_status is not successful if there is any execution error in matching.
1962 IF l_return_status = fnd_api.g_ret_sts_error THEN
1963 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1964 fnd_msg_pub.ADD;
1965
1966 IF (l_debug = 1) THEN
1967 print_debug('create_po_rcpt_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1968 END IF;
1969
1970 RAISE fnd_api.g_exc_error;
1971 END IF;
1972
1973 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
1974 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
1975 fnd_msg_pub.ADD;
1976
1977 IF (l_debug = 1) THEN
1978 print_debug('Exiting create_po_rcpt_intf_rec 60.2: Unexpect error calling matching'
1979 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
1980 , 1);
1981 END IF;
1982
1983 RAISE fnd_api.g_exc_unexpected_error;
1984 END IF;
1985
1986 IF g_rcpt_match_table_gross(g_receipt_detail_index).error_status = 'E' THEN
1987 l_err_message := g_rcpt_match_table_gross(g_receipt_detail_index).error_message;
1988 fnd_message.set_name('INV', l_err_message);
1989 fnd_msg_pub.ADD;
1990
1991 IF (l_debug = 1) THEN
1992 print_debug('create_po_rcpt_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
1993 END IF;
1994
1995 RAISE fnd_api.g_exc_error;
1996 END IF;
1997
1998 l_err_message := '@@@';
1999
2000 FOR i IN g_receipt_detail_index ..(g_receipt_detail_index + l_rcpt_match_table_detail.COUNT - 1) LOOP
2001 IF l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_status = 'W' THEN
2002 x_status := 'W';
2003 l_temp_message := l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_message;
2004
2005 IF l_temp_message IS NULL THEN
2006 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2007 l_msg_prod := 'INV';
2008 EXIT;
2009 END IF;
2010
2011 IF l_err_message = '@@@' THEN
2012 l_err_message := l_temp_message;
2013 IF l_err_message = 'RCV_ASN_EXISTS_FOR_POLINE' THEN --13850907
2014 l_msg_prod := 'PO';
2015 ELSE
2016 l_msg_prod := 'INV';
2017 END IF; --13850907
2018 ELSIF l_temp_message <> l_err_message THEN
2019 l_msg_prod := 'INV';
2020 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
2021 EXIT;
2022 END IF;
2023 END IF;
2024 END LOOP;
2025
2026 IF l_err_message <> '@@@' THEN
2027 fnd_message.set_name(l_msg_prod, l_err_message);
2028 fnd_msg_pub.ADD;
2029
2030 IF (l_debug = 1) THEN
2031 print_debug(
2032 'create_po_rcpt_intf_rec 80: adding tolerance message - l_msg_prod = '
2033 || l_msg_prod
2034 || ' l_err_message = '
2035 || l_err_message
2036 || ' '
2037 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2038 , 1
2039 );
2040 END IF;
2041 END IF;
2042
2043 -- load the matching algorithm result into input data structure
2044
2045 -- based on return from matching algorithm,
2046 -- determine which line in rcv_transaction block to be inserted into RTI
2047
2048
2049 IF (l_debug = 1) THEN
2050 print_debug('create_po_rcpt_intf_rec: 90 - before macthing result loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2051 END IF;
2052
2053 -- loop through results returned by matching algorithm
2054 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
2055 l_progress := 72;
2056
2057 IF (l_debug = 1) THEN
2058 print_debug(
2059 'create_po_rcpt_intf_rec: 90.1 - after matching po_line_location_id = '
2060 || l_rcpt_match_table_detail(match_result_count).po_line_location_id
2061 , 4
2062 );
2063 print_debug(
2064 'create_po_rcpt_intf_rec: 90.2 - after matching txn_quantity = '
2065 || l_rcpt_match_table_detail(match_result_count).quantity
2066 , 4
2067 );
2068
2069 END IF;
2070
2071 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).po_line_location_id);
2072 l_progress := 74;
2073 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
2074 -- Earlier item_id was filled with PO Line Item ID if the parameter p_inv_item_id
2075 -- is not null, so that matching logic finds shipments. Now, in order to actually
2076 -- insert RTI, replace item_id with a new value which is nothing but the substitute
2077 -- item.
2078 l_rcv_rcpt_rec.item_id := p_item_id;
2079 l_progress := 76;
2080 CLOSE l_curs_rcpt_detail;
2081 l_progress := 78;
2082 --Bug 6978466 Substitute Value should be there when we are doing substitute receipts through mobile.
2083 IF p_inv_item_id IS NOT NULL THEN
2084 l_rcv_transaction_rec.substitute_receipt:='SUBSTITUTE';
2085 END IF;
2086 --End of 6978466
2087
2088 l_rcv_transaction_rec.po_line_location_id := l_rcpt_match_table_detail(match_result_count).po_line_location_id;
2089 -- update following fields from matching algorithm return value
2090 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
2091 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
2092 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
2093 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
2094 --OPM Convergence
2095 --l_rcv_transaction_rec.secondary_quantity := l_rcpt_match_table_detail(match_result_count).secondary_quantity;
2096 l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) * p_secondary_quantity;
2097 l_rcv_transaction_rec.secondary_uom := p_secondary_uom; --OPM Convergence
2098 l_rcv_transaction_rec.secondary_uom_code := p_secondary_uom_code; --OPM Convergence
2099 print_debug(l_rcv_transaction_rec.secondary_quantity,1);
2100 print_debug( l_rcv_transaction_rec.secondary_uom,1);
2101 print_debug(l_rcv_transaction_rec.secondary_uom_code,1);
2102
2103 l_rcv_transaction_rec.destination_subinventory := p_rcv_subinventory_code;
2104 l_rcv_transaction_rec.locator_id := p_rcv_locator_id;
2105
2106
2107 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
2108
2109 l_rcv_transaction_rec.item_revision := p_revision;
2110 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
2111 -- following fileds can have distribution level values
2112 -- therefore they are set here instead of in the common insert code
2113 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.ordered_qty;
2114 --Bug 2073164
2115 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
2116 l_rcv_rcpt_rec.secondary_uom_code := p_secondary_uom_code;--OPM Convergence
2117 print_debug('l_rcv_rcpt_rec.secondary_uom_code ' || l_rcv_rcpt_rec.secondary_uom_code,4);
2118 print_debug('l_rcv_rcpt_rec.secondary_uom ' || l_rcv_rcpt_rec.secondary_uom,4);
2119
2120 IF (l_debug = 1) THEN
2121 print_debug('create_po_rcpt_intf_rec: 100 - within cursor loop - before insert RTI '
2122 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2123 , 4);
2124 END IF;
2125
2126 --Begin bug 4699085
2127 --If the item is not revision controlled ie l_rcv_rcpt_rec.item_rev_control_flag_to = 'N'
2128 --and l_rcv_transaction_rec.item_revision is null, ie p_revision is passed NULL to this
2129 --API, then check if there is a item revision stamped on the po lines table and use that
2130 --revision to pass to QA skip lot API and to the interface record created in RTI to
2131 --process the PO receipt.
2132 IF (l_debug = 1) THEN
2133 print_debug('create_po_rcpt_intf_rec: 100.1 l_rcv_rcpt_rec.item_rev_control_flag_to='||l_rcv_rcpt_rec.item_rev_control_flag_to, 4);
2134 print_debug('create_po_rcpt_intf_rec: 100.2 l_rcv_transaction_rec.item_revision='||l_rcv_transaction_rec.item_revision, 4);
2135 END IF;
2136
2137 IF ((l_rcv_rcpt_rec.item_rev_control_flag_to = 'N') AND
2138 (l_rcv_transaction_rec.item_revision IS NULL)) THEN
2139
2140 BEGIN
2141 SELECT nvl(item_revision, '@@@@')
2142 INTO l_item_revision
2143 FROM po_lines_all
2144 WHERE po_line_id = l_rcv_rcpt_rec.po_line_id;
2145
2146 IF (l_debug = 1) THEN
2147 print_debug('create_po_rcpt_intf_rec: 100.5 l_item_revision='||l_item_revision, 4);
2148 END IF;
2149 EXCEPTION
2150 WHEN NO_DATA_FOUND THEN
2151 l_item_revision := '@@@@';
2152 WHEN OTHERS THEN
2153 l_item_revision := '@@@@';
2154 END;
2155
2156 IF (l_debug = 1) THEN
2157 print_debug('create_po_rcpt_intf_rec: 100.6 l_item_revision='||l_item_revision, 4);
2158 END IF;
2159
2160 IF (l_item_revision <> '@@@@') THEN
2161 l_rcv_transaction_rec.item_revision := l_item_revision;
2162 END IF;
2163
2164 IF (l_debug = 1) THEN
2165 print_debug('create_po_rcpt_intf_rec: 100.7 l_rcv_transaction_rec.item_revision='||l_rcv_transaction_rec.item_revision, 4);
2166 END IF;
2167 END IF;
2168 --End bug 4699085
2169
2170 l_progress := '80';
2171
2172 -- check if the routing_id = 2 (Inspection required) then call
2173 -- QA_SKIPLOT_RCV_GRP.CHECK_AVAILABILITY
2174 -- to check if Quaility Skip Lot function is available for current org.
2175 -- returns fnd_api.g_true/false
2176 IF l_rcv_rcpt_rec.routing_id = 2 THEN
2177 BEGIN
2178 l_progress := '81';
2179 qa_skiplot_rcv_grp.check_availability(
2180 p_api_version => 1.0
2181 , p_init_msg_list => fnd_api.g_false
2182 , p_commit => fnd_api.g_false
2183 , p_validation_level => fnd_api.g_valid_level_full
2184 , p_organization_id => p_organization_id
2185 , x_qa_availability => l_qa_availability
2186 , x_return_status => l_return_status
2187 , x_msg_count => l_msg_count
2188 , x_msg_data => l_msg_data
2189 );
2190 l_progress := '82';
2191 EXCEPTION
2192 WHEN OTHERS THEN
2193 IF (l_debug = 1) THEN
2194 print_debug(
2195 'create_po_rcpt_intf_rec: 102 - Exception in calling QA_SKIPLOT_RCV_GRP.CHECK_AVAILABILITY'
2196 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2197 , 4
2198 );
2199 END IF;
2200
2201 RAISE fnd_api.g_exc_error;
2202 END;
2203
2204 IF NVL(l_return_status, fnd_api.g_ret_sts_success) = fnd_api.g_ret_sts_success THEN
2205 -- If the Quaility Skip Lot function is available, then gets the interface transaction id and
2206 -- calls QA_SKIPLOT_RCV_GRP.EVALUATE_LOT
2207 -- returns 'Standard' or 'Inspect' to x_evaluation_result.
2208 IF NVL(l_qa_availability, fnd_api.g_false) = fnd_api.g_true THEN
2209 l_qa_routing_id := 2;
2210
2211 BEGIN
2212 SELECT rcv_transactions_interface_s.NEXTVAL
2213 INTO l_rcv_transaction_rec.interface_transaction_id
2214 FROM DUAL;
2215
2216 l_progress := '83';
2217 /*
2218 We get the project /task from create_std..rec itself and it in turns
2219 gets it from java code (rcptflistener)
2220 get_project_task(p_po_line_location_id => l_rcv_transaction_rec.po_line_location_id,
2221 p_oe_order_line_id => NULL,
2222 x_project_id => l_project_id,
2223 x_task_id => l_task_id);
2224 */
2225 l_project_id := p_project_id;
2226 l_task_id := p_task_id;
2227
2228 IF l_project_id = '' THEN
2229 l_project_id := NULL;
2230 END IF;
2231
2232 IF l_task_id = '' THEN
2233 l_task_id := NULL;
2234 END IF;
2235
2236 --Begin bug 4699085
2237 --Added following debug messages
2238 IF (l_debug = 1) THEN
2239 print_debug('create_po_rcpt_intf_rec 84 calling qa_skiplot_rcv_grp.evaluate_lot', 4);
2240 print_debug('create_po_rcpt_intf_rec 84 with l_rcv_rcpt_rec.item_revision='||l_rcv_rcpt_rec.item_revision, 4);
2241 END IF;
2242 --End bug 4699085
2243
2244 l_progress := '84';
2245 qa_skiplot_rcv_grp.evaluate_lot(
2246 p_api_version => 1.0
2247 , p_init_msg_list => fnd_api.g_false
2248 , p_commit => fnd_api.g_false
2249 , p_validation_level => fnd_api.g_valid_level_full
2250 , p_interface_txn_id => l_rcv_transaction_rec.interface_transaction_id
2251 , p_organization_id => p_organization_id
2252 , p_vendor_id => l_rcv_rcpt_rec.vendor_id
2253 , p_vendor_site_id => l_rcv_rcpt_rec.vendor_site_id
2254 , p_item_id => l_rcv_rcpt_rec.item_id
2255 , p_item_revision => l_rcv_rcpt_rec.item_revision
2256 , p_item_category_id => l_rcv_rcpt_rec.item_category_id
2257 , p_project_id => l_project_id
2258 , p_task_id => l_task_id
2259 , p_manufacturer_id => NULL
2260 , p_source_inspected => NULL
2261 , p_receipt_qty => l_rcv_transaction_rec.transaction_qty
2262 , p_receipt_date => SYSDATE
2263 , p_primary_uom => l_rcv_transaction_rec.primary_uom
2264 , p_transaction_uom => l_rcv_transaction_rec.transaction_uom
2265 , p_po_header_id => l_rcv_rcpt_rec.po_header_id
2266 , p_po_line_id => l_rcv_rcpt_rec.po_line_id
2267 , p_po_line_location_id => l_rcv_transaction_rec.po_line_location_id
2268 , p_po_distribution_id => l_rcv_rcpt_rec.po_distribution_id
2269 , p_lpn_id => p_lpn_id
2270 , p_wms_flag => 'Y'
2271 , x_evaluation_result => l_evaluation_result
2272 , x_return_status => l_return_status
2273 , x_msg_count => l_msg_count
2274 , x_msg_data => l_msg_data
2275 );
2276
2277 IF l_return_status = fnd_api.g_ret_sts_error THEN
2278 IF (l_debug = 1) THEN
2279 print_debug('create_po_rcpt_intf_rec 84.1: QA CALL RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2280 END IF;
2281
2282 RAISE fnd_api.g_exc_error;
2283 END IF;
2284
2285 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
2286 IF (l_debug = 1) THEN
2287 print_debug('create_po_rcpt_intf_rec 135.2: QA CALL RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2288 END IF;
2289 RAISE fnd_api.g_exc_unexpected_error;
2290 END IF;
2291
2292 -- If QA_SKIPLOT_RCV_GRP returns 'Standard', sets the routing id to 1.
2293 -- If QA_SKIPLOT_RCV_GRP returns 'Inspect', leaves the routing id as 2.
2294 IF l_evaluation_result = 'STANDARD' THEN
2295 l_rcv_rcpt_rec.routing_id := 1;
2296 l_qa_routing_id := 1;
2297 END IF;
2298 EXCEPTION
2299 WHEN OTHERS THEN
2300 IF (l_debug = 1) THEN
2301 print_debug('create_po_rcpt_intf_rec: 104 - Exception in calling QA_SKIPLOT_RCV_GRP.EVALUATE_LOT'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2302 END IF;
2303 RAISE fnd_api.g_exc_error;
2304 END;
2305 END IF;
2306 END IF;
2307 END IF;
2308
2309 l_return_status := fnd_api.g_ret_sts_success;
2310 l_progress := '85';
2311
2312 IF p_country_code IS NOT NULL THEN
2313 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
2314 END IF;
2315
2316 --Bug #4147209 - Populate the record type with the DFF attribute category
2317 --and segment values passed from the mobile UI
2318 set_attribute_vals(
2319 p_rcv_rcpt_rec => l_rcv_rcpt_rec
2320 , p_attribute_category => p_attribute_category
2321 , p_attribute1 => p_attribute1
2322 , p_attribute2 => p_attribute2
2323 , p_attribute3 => p_attribute3
2324 , p_attribute4 => p_attribute4
2325 , p_attribute5 => p_attribute5
2326 , p_attribute6 => p_attribute6
2327 , p_attribute7 => p_attribute7
2328 , p_attribute8 => p_attribute8
2329 , p_attribute9 => p_attribute9
2330 , p_attribute10 => p_attribute10
2331 , p_attribute11 => p_attribute11
2332 , p_attribute12 => p_attribute12
2333 , p_attribute13 => p_attribute13
2334 , p_attribute14 => p_attribute14
2335 , p_attribute15 => p_attribute15);
2336
2337 l_interface_transaction_id :=
2338 insert_txn_interface(
2339 l_rcv_transaction_rec
2340 , l_rcv_rcpt_rec
2341 , l_group_id
2342 , l_transaction_type
2343 , p_organization_id
2344 , p_location_id
2345 , p_source_type
2346 , l_qa_routing_id
2347 , p_project_id
2348 , p_task_id
2349 );
2350 l_progress := '90';
2351
2352 IF (l_debug = 1) THEN
2353 print_debug('create_po_rcpt_intf_rec: 110 - within cursor loop - after insert RTI '|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2354 END IF;
2355
2356 IF (l_debug = 1) THEN
2357 print_debug('create_po_rcpt_intf_rec 130.5: INV J and PO J are installed. No Move Order creation from UI', 4);
2358 END IF;
2359 /* Populate the table to store the information of the RTIs created*/
2360 l_new_rti_info(match_result_count).orig_interface_trx_id := p_original_rti_id;
2361 l_new_rti_info(match_result_count).new_interface_trx_id := l_interface_transaction_id;
2362 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
2363 END LOOP; -- loop through results returned by matching algorithm
2364
2365 --BUG 3326408,3346758,3405320
2366 --If there are any serials confirmed from the UI for an item that is
2367 --lot controlled and serial control dynamic at SO issue,
2368 --do not NULL out serial_transaction_temp_id. In other cases,
2369 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
2370 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
2371 l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
2372 IF (l_debug = 1) THEN
2373 print_debug('create_po_rcpt_intf_rec 130.6: serial_control_code IS 6, need TO NULL OUT mtli', 4);
2374 END IF;
2375 BEGIN
2376 UPDATE mtl_transaction_lots_interface
2377 SET serial_transaction_temp_id = NULL
2378 WHERE product_transaction_id = p_original_rti_id
2379 AND product_code = 'RCV';
2380 EXCEPTION
2381 WHEN OTHERS THEN
2382 IF (l_debug = 1) THEN
2383 print_debug('create_po_rcpt_intf_rec 130.7: Error nulling serial temp id OF MTLI', 4);
2384 END IF;
2385 END ;
2386 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
2387
2388 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
2389 p_api_version => 1.0
2390 , p_init_msg_lst => FND_API.G_FALSE
2391 , x_return_status => l_return_status
2392 , x_msg_count => l_msg_count
2393 , x_msg_data => x_message
2394 , p_new_rti_info => l_new_rti_info);
2395 IF ( NOT l_split_lot_serial_ok) THEN
2396 IF (l_debug = 1) THEN
2397 print_debug('create_po_rcpt_intf_rec 132: Failure in split_lot_serial', 4);
2398 END IF;
2399 RAISE FND_API.G_EXC_ERROR;
2400 END IF;
2401
2402 IF (l_debug = 1) THEN
2403 print_debug('create_po_rcpt_intf_rec 133: Call split_lot_serial is OK', 4);
2404 END IF;
2405
2406 IF l_curs_rcpt_detail%ISOPEN THEN
2407 CLOSE l_curs_rcpt_detail;
2408 END IF;
2409
2410 -- append index in input table where the line to be detailed needs to be inserted
2411 --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
2412
2413 -- clear the lot/qty data structure
2414 g_rcpt_lot_qty_rec_tb.DELETE;
2415 l_progress := '90';
2416
2417 IF p_item_id IS NOT NULL THEN
2418 inv_rcv_common_apis.do_check(
2419 p_organization_id => p_organization_id
2420 , p_inventory_item_id => p_item_id
2421 , p_transaction_type_id => 18
2422 , p_primary_quantity => l_total_primary_qty
2423 , x_return_status => l_return_status
2424 , x_msg_count => l_msg_count
2425 , x_msg_data => x_message
2426 );
2427 END IF;
2428
2429 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2430 x_status := l_return_status;
2431 END IF;
2432
2433 l_progress := '100';
2434
2435 IF (l_debug = 1) THEN
2436 print_debug('About exiting create_po_rcpt_intf_rec: 140 - after cursor loop ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2437 END IF;
2438 EXCEPTION
2439 WHEN fnd_api.g_exc_error THEN
2440 ROLLBACK TO crt_po_rti_sp;
2441 x_status := fnd_api.g_ret_sts_error;
2442
2443 IF l_curs_rcpt_detail%ISOPEN THEN
2444 CLOSE l_curs_rcpt_detail;
2445 END IF;
2446
2447 fnd_msg_pub.count_and_get(
2448 p_encoded => fnd_api.g_false
2449 , p_count => l_msg_count
2450 , p_data => x_message);
2451
2452 IF (l_debug = 1) THEN
2453 print_debug('create_po_rcpt_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2454 END IF;
2455 WHEN fnd_api.g_exc_unexpected_error THEN
2456 ROLLBACK TO crt_po_rti_sp;
2457 x_status := fnd_api.g_ret_sts_unexp_error;
2458
2459 IF l_curs_rcpt_detail%ISOPEN THEN
2460 CLOSE l_curs_rcpt_detail;
2461 END IF;
2462
2463 fnd_msg_pub.count_and_get(
2464 p_encoded => fnd_api.g_false
2465 , p_count => l_msg_count
2466 , p_data => x_message);
2467
2468 IF (l_debug = 1) THEN
2469 print_debug('create_po_rcpt_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2470 END IF;
2471 WHEN OTHERS THEN
2472 ROLLBACK TO crt_po_rti_sp;
2473 x_status := fnd_api.g_ret_sts_unexp_error;
2474
2475 IF l_curs_rcpt_detail%ISOPEN THEN
2476 CLOSE l_curs_rcpt_detail;
2477 END IF;
2478
2479 IF SQLCODE IS NOT NULL THEN
2480 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_po_rcpt_intf_rec', l_progress, SQLCODE);
2481 END IF;
2482
2483 fnd_msg_pub.count_and_get(
2484 p_encoded => fnd_api.g_false
2485 , p_count => l_msg_count
2486 , p_data => x_message);
2487
2488 IF (l_debug = 1) THEN
2489 print_debug('create_po_rcpt_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2490 END IF;
2491 END create_po_rcpt_intf_rec;
2492
2493 -- Added one more parameter p_from_lpn_id
2494 PROCEDURE create_intship_rcpt_intf_rec(
2495 p_move_order_header_id IN OUT NOCOPY NUMBER
2496 , p_organization_id IN NUMBER
2497 , p_shipment_header_id IN NUMBER
2498 , p_req_header_id IN NUMBER
2499 , p_item_id IN NUMBER
2500 , p_location_id IN NUMBER
2501 , p_rcv_qty IN NUMBER
2502 , p_rcv_uom IN VARCHAR2
2503 , p_rcv_uom_code IN VARCHAR2
2504 , p_source_type IN VARCHAR2
2505 , p_from_lpn_id IN NUMBER
2506 , p_lpn_id IN NUMBER
2507 , p_lot_control_code IN NUMBER
2508 , p_revision IN VARCHAR2
2509 , p_inspect IN NUMBER
2510 , x_status OUT NOCOPY VARCHAR2
2511 , x_message OUT NOCOPY VARCHAR2
2512 , p_project_id IN NUMBER DEFAULT NULL
2513 , p_task_id IN NUMBER DEFAULT NULL
2514 , p_country_code IN VARCHAR2 DEFAULT NULL
2515 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL -- RCVLOCATORSSUPPORT
2516 , p_rcv_locator_id IN NUMBER DEFAULT NULL
2517 , p_original_rti_id IN NUMBER DEFAULT NULL --Lot/Serial Support
2518 , p_secondary_uom IN VARCHAR2 DEFAULT NULL-- OPM Convergence
2519 , p_secondary_uom_code IN VARCHAR2 DEFAULT NULL-- OPM Convergence
2520 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
2521 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
2522 , p_attribute1 IN VARCHAR2 DEFAULT NULL
2523 , p_attribute2 IN VARCHAR2 DEFAULT NULL
2524 , p_attribute3 IN VARCHAR2 DEFAULT NULL
2525 , p_attribute4 IN VARCHAR2 DEFAULT NULL
2526 , p_attribute5 IN VARCHAR2 DEFAULT NULL
2527 , p_attribute6 IN VARCHAR2 DEFAULT NULL
2528 , p_attribute7 IN VARCHAR2 DEFAULT NULL
2529 , p_attribute8 IN VARCHAR2 DEFAULT NULL
2530 , p_attribute9 IN VARCHAR2 DEFAULT NULL
2531 , p_attribute10 IN VARCHAR2 DEFAULT NULL
2532 , p_attribute11 IN VARCHAR2 DEFAULT NULL
2533 , p_attribute12 IN VARCHAR2 DEFAULT NULL
2534 , p_attribute13 IN VARCHAR2 DEFAULT NULL
2535 , p_attribute14 IN VARCHAR2 DEFAULT NULL
2536 , p_attribute15 IN VARCHAR2 DEFAULT NULL
2537 ) IS
2538 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
2539 l_rcv_transaction_rec rcv_transaction_rec_tp; -- rcv_transaction block
2540 l_interface_transaction_id NUMBER := NULL;
2541 -- this is used to keep track of the id used to insert the row in rti
2542
2543 l_transaction_type VARCHAR2(20) := 'RECEIVE';
2544 l_total_primary_qty NUMBER := 0;
2545 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
2546 l_msg_count NUMBER;
2547 l_msg_data VARCHAR2(4000);
2548 l_progress VARCHAR2(10);
2549 l_err_message VARCHAR2(100);
2550 l_temp_message VARCHAR2(100);
2551 l_msg_prod VARCHAR2(5);
2552 l_group_id NUMBER;
2553 l_rcv_rcpt_rec rcv_enter_receipts_rec_tp;
2554 l_inspect NUMBER;
2555 l_receipt_num VARCHAR2(30);
2556 l_serial_number VARCHAR2(80); --9651496,9764650
2557 l_lot_number VARCHAR2(80) ; --9229228
2558 l_serial_control_code1 NUMBER;--bug13558642
2559
2560 CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER) IS
2561 SELECT 'N' line_chkbox
2562 , 'INTERNAL' source_type_code
2563 , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
2564 , rsl.source_document_code order_type_code
2565 , '' order_type
2566 --Passing as NULL for the columns for which value is not known. --Bug #3878174
2567 , TO_NUMBER(NULL) po_header_id
2568 , NULL po_number
2569 , TO_NUMBER(NULL) po_line_id
2570 , TO_NUMBER(NULL) po_line_number
2571 , TO_NUMBER(NULL) po_line_location_id
2572 , NULL po_shipment_number
2573 , TO_NUMBER(NULL) po_release_id
2574 , TO_NUMBER(NULL) po_release_number
2575 /*
2576 , rsh.shipment_header_id po_header_id
2577 , rsh.shipment_num po_number
2578 , rsl.shipment_line_id po_line_id
2579 , rsl.line_num po_line_number
2580 , rsl.shipment_line_id po_line_location_id
2581 , rsl.line_num po_shipment_number
2582 , rsh.shipment_header_id po_release_id
2583 , rsh.shipment_header_id po_release_number
2584 */
2585 , porh.requisition_header_id req_header_id
2586 , porh.segment1 req_number
2587 , porl.requisition_line_id req_line_id
2588 , porl.line_num req_line
2589 , rsl.req_distribution_id req_distribution_id
2590 , rsl.shipment_header_id rcv_shipment_header_id
2591 , rsh.shipment_num rcv_shipment_number
2592 , rsl.shipment_line_id rcv_shipment_line_id
2593 , rsl.line_num rcv_line_number
2594 , rsl.from_organization_id from_organization_id
2595 , rsl.to_organization_id to_organization_id
2596 , rsl.shipment_line_id vendor_id
2597 , '' SOURCE
2598 , TO_NUMBER(NULL) vendor_site_id
2599 , 'N' outside_operation_flag
2600 , rsl.item_id item_id
2601 , -- Bug 2073164
2602 NULL uom_code
2603 , rsl.unit_of_measure primary_uom
2604 , mum.uom_class primary_uom_class
2605 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
2606 , NVL(msi.location_control_code, 1) item_locator_control
2607 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
2608 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
2609 , NVL(msi.shelf_life_code, 1) shelf_life_code
2610 , NVL(msi.shelf_life_days, 0) shelf_life_days
2611 , msi.serial_number_control_code serial_number_control_code
2612 , msi.lot_control_code lot_control_code
2613 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
2614 , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
2615 , NULL item_number
2616 , rsl.item_revision item_revision
2617 , rsl.item_description item_description
2618 , rsl.category_id item_category_id
2619 , '' hazard_class
2620 , '' un_number
2621 , rsl.vendor_item_num vendor_item_number
2622 , rsh.ship_to_location_id ship_to_location_id
2623 , '' ship_to_location
2624 , rsh.packing_slip packing_slip
2625 , rsl.routing_header_id routing_id
2626 , '' routing_name
2627 , porl.need_by_date need_by_date
2628 , rsh.expected_receipt_date expected_receipt_date
2629 , rsl.quantity_shipped ordered_qty
2630 , rsl.primary_unit_of_measure ordered_uom
2631 , rsh.ussgl_transaction_code ussgl_transaction_code
2632 , rsh.government_context government_context
2633 , NULL inspection_required_flag
2634 , NULL receipt_required_flag
2635 , NULL enforce_ship_to_location_code
2636 , TO_NUMBER(NULL) unit_price
2637 , NULL currency_code
2638 , NULL currency_conversion_type
2639 , TO_DATE(NULL) currency_conversion_date
2640 , TO_NUMBER(NULL) currency_conversion_rate
2641 , NULL note_to_receiver
2642 , --PORL.NOTE_TO_RECEIVER NOTE_TO_RECEIVER,
2643 rsl.destination_type_code destination_type_code
2644 , rsl.deliver_to_person_id deliver_to_person_id
2645 , rsl.deliver_to_location_id deliver_to_location_id
2646 , rsl.to_subinventory destination_subinventory
2647 , rsl.attribute_category attribute_category
2648 , rsl.attribute1 attribute1
2649 , rsl.attribute2 attribute2
2650 , rsl.attribute3 attribute3
2651 , rsl.attribute4 attribute4
2652 , rsl.attribute5 attribute5
2653 , rsl.attribute6 attribute6
2654 , rsl.attribute7 attribute7
2655 , rsl.attribute8 attribute8
2656 , rsl.attribute9 attribute9
2657 , rsl.attribute10 attribute10
2658 , rsl.attribute11 attribute11
2659 , rsl.attribute12 attribute12
2660 , rsl.attribute13 attribute13
2661 , rsl.attribute14 attribute14
2662 , rsl.attribute15 attribute15
2663 , 'OPEN' closed_code
2664 , NULL asn_type
2665 , rsh.bill_of_lading bill_of_lading
2666 , rsh.shipped_date shipped_date
2667 , rsh.freight_carrier_code freight_carrier_code
2668 , rsh.waybill_airbill_num waybill_airbill_num
2669 , rsh.freight_bill_number freight_bill_num
2670 , rsl.vendor_lot_num vendor_lot_num
2671 , rsl.container_num container_num
2672 , rsl.truck_num truck_num
2673 , rsl.bar_code_label bar_code_label
2674 , NULL rate_type_display
2675 , 'P' match_option
2676 , NULL country_of_origin_code
2677 , TO_NUMBER(NULL) oe_order_header_id
2678 , TO_NUMBER(NULL) oe_order_num
2679 , TO_NUMBER(NULL) oe_order_line_id
2680 , TO_NUMBER(NULL) oe_order_line_num
2681 , TO_NUMBER(NULL) customer_id
2682 , TO_NUMBER(NULL) customer_site_id
2683 , NULL customer_item_num
2684 , NULL pll_note_to_receiver
2685 , --PORL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
2686 NULL po_distribution_id
2687 , NULL qty_ordered
2688 , NULL wip_entity_id
2689 , NULL wip_operation_seq_num
2690 , NULL wip_resource_seq_num
2691 , NULL wip_repetitive_schedule_id
2692 , NULL wip_line_id
2693 , NULL bom_resource_id
2694 , '' destination_type
2695 , '' LOCATION
2696 , NULL currency_conversion_rate_pod
2697 , NULL currency_conversion_date_pod
2698 , NULL project_id
2699 , NULL task_id
2700 , NULL secondary_uom --OPM Convergence
2701 , NULL secondary_uom_code --OPM Convergence
2702 , NULL secondary_quantity --OPM Convergence temp
2703 FROM rcv_shipment_headers rsh
2704 , rcv_shipment_lines rsl
2705 , po_requisition_headers porh
2706 , po_requisition_lines porl
2707 , mtl_system_items msi
2708 , mtl_system_items msi1
2709 , mtl_units_of_measure mum
2710 WHERE rsh.receipt_source_code <> 'VENDOR'
2711 AND rsl.requisition_line_id = porl.requisition_line_id(+)
2712 AND porl.requisition_header_id = porh.requisition_header_id(+)
2713 AND rsh.shipment_header_id = rsl.shipment_header_id
2714 AND mum.unit_of_measure(+) = rsl.unit_of_measure
2715 AND msi.organization_id(+) = rsl.to_organization_id
2716 AND msi.inventory_item_id(+) = rsl.item_id
2717 AND msi1.organization_id(+) = rsl.from_organization_id
2718 AND msi1.inventory_item_id(+) = rsl.item_id
2719 AND rsl.shipment_line_id = v_shipment_line_id
2720 AND(
2721 (
2722 rsl.source_document_code = 'REQ'
2723 AND EXISTS(
2724 SELECT '1'
2725 FROM po_req_distributions_all prd
2726 WHERE prd.requisition_line_id = rsl.requisition_line_id
2727 AND Nvl(rsl.req_distribution_id,Nvl(prd.distribution_id,-999)) = Nvl(prd.distribution_id,-999)--BUG 4946182
2728 AND(
2729 p_project_id IS NULL
2730 OR(p_project_id = -9999
2731 AND prd.project_id IS NULL) --bug#2669021
2732 OR NVL(prd.project_id, -99) = p_project_id
2733 ))
2734 )
2735 OR rsl.source_document_code <> 'REQ'
2736 );
2737
2738 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2739 --table to store all RTId, quantity and original_rti_id for lot/serial splits
2740 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
2741 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
2742 l_msni_count NUMBER := 0;
2743 l_line_id NUMBER;
2744 l2_lot_code NUMBER := 0; --part2 bug number 12814511
2745
2746 BEGIN
2747 IF (l_debug = 1) THEN
2748 print_debug('create_intship_rcpt_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2749 END IF;
2750
2751 SAVEPOINT crt_intship_rti_sp;
2752 x_status := fnd_api.g_ret_sts_success;
2753 l_progress := '10';
2754
2755 -- query po_startup_value
2756 BEGIN
2757 /* Bug #2516729
2758 * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
2759 * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
2760 * in order that a new receipt # is not created everytime and the existing receipt # is used
2761 */
2762 BEGIN
2763 SELECT receipt_num
2764 INTO l_receipt_num
2765 FROM rcv_shipment_headers
2766 WHERE shipment_header_id = p_shipment_header_id
2767 AND ship_to_org_id = p_organization_id;
2768
2769 --Bug 4252372
2770 --We should set inv_rcv_common_apis.g_rcv_global_var.receipt_num to
2771 --l_receipt_num only if l_receipt_num is not null. It it is null and
2772 --we set the value then we will end up generating extra receipt numbers.
2773 IF (l_receipt_num IS NOT NULL) THEN
2774 inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
2775 END IF;
2776
2777 IF (l_debug = 1) THEN
2778 print_debug('create_intship_rcpt_intf_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
2779 END IF;
2780 EXCEPTION
2781 WHEN NO_DATA_FOUND THEN
2782 l_receipt_num := NULL;
2783 END;
2784
2785 inv_rcv_common_apis.init_startup_values(p_organization_id);
2786 EXCEPTION
2787 WHEN NO_DATA_FOUND THEN
2788 fnd_message.set_name('INV', 'INV_RCV_PARAM');
2789 fnd_msg_pub.ADD;
2790 RAISE fnd_api.g_exc_error;
2791 END;
2792
2793 -- default header level non-DB items in rcv_transaction block
2794 -- and default other values need to be insert into RTI
2795
2796 IF (l_debug = 1) THEN
2797 print_debug('create_intship_rcpt_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2798 END IF;
2799
2800 l_progress := '20';
2801
2802 -- default l_group_id ? clear group id after done
2803 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
2804 SELECT rcv_interface_groups_s.NEXTVAL
2805 INTO l_group_id
2806 FROM DUAL;
2807
2808 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
2809 ELSE
2810 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
2811 END IF;
2812
2813 l_progress := '30';
2814 /* We'll get shipment_header_id for req at front end
2815 IF p_shipment_header_id IS NULL THEN
2816 SELECT DISTINCT rsl.shipment_header_id
2817 INTO l_shipment_header_id
2818 FROM rcv_shipment_lines rsl,
2819 po_requisition_lines prl
2820 WHERE
2821 prl.requisition_header_id = p_req_header_id
2822 AND prl.requisition_line_id = rsl.requisition_line_id;
2823 ELSE
2824 l_shipment_header_id := p_shipment_header_id;
2825 END IF;
2826
2827 */
2828 --9651496,9764650-starts
2829 BEGIN
2830 SELECT fm_serial_number INTO l_serial_number
2831 FROM mtl_serial_numbers_interface
2832 WHERE product_transaction_id = p_original_rti_id ;
2833 EXCEPTION
2834 WHEN No_Data_Found THEN
2835 IF (l_debug = 1) THEN
2836 print_debug('create_intship_rcpt_intf_rec: No Serial records in MSNI for id :'||p_original_rti_id,4);
2837 END IF;
2838 l_serial_number :=NULL;
2839 WHEN too_many_rows THEN
2840 IF (l_debug = 1) THEN
2841 print_debug('create_intship_rcpt_intf_rec: More than one records in MSNI for id :'||p_original_rti_id,4);
2842 END IF;
2843 l_serial_number :=NULL; --For multiple lots dont input to matching logic
2844 END;
2845 IF (l_debug = 1) THEN
2846 print_debug('create_intship_rcpt_intf_rec: 30.2 serial_number: ' || l_serial_number, 4);
2847 END IF;
2848 --9651496,9764650-ends
2849
2850
2851 --9229228-starts
2852 BEGIN
2853 SELECT lot_number INTO l_lot_number
2854 FROM mtl_transaction_lots_interface
2855 WHERE product_transaction_id = p_original_rti_id ;
2856 EXCEPTION
2857 WHEN No_Data_Found THEN
2858 IF (l_debug = 1) THEN
2859 print_debug('create_intship_rcpt_intf_rec: No Lot records in MTLI for id :'||p_original_rti_id,4);
2860 END IF;
2861 l_lot_number :=NULL;
2862 WHEN too_many_rows THEN
2863 IF (l_debug = 1) THEN
2864 print_debug('create_intship_rcpt_intf_rec: More than one records in MTLI for id :'||p_original_rti_id,4);
2865 END IF;
2866 l_lot_number :=NULL; --For multiple lots dont input to matching logic
2867 END;
2868 IF (l_debug = 1) THEN
2869 print_debug('create_intship_rcpt_intf_rec: 30.2 lot_number: ' || l_lot_number, 4);
2870 END IF;
2871 --9229228-ends
2872 IF (l_debug = 1) THEN
2873 print_debug('create_intship_rcpt_intf_rec: 30.21 p_req_header_id: ' || p_req_header_id , 4);
2874 END IF;
2875
2876 --start part 2 bug 12814511
2877 BEGIN
2878 SELECT lot_control_code,serial_number_control_code
2879 INTO l2_lot_code,l_serial_control_code1
2880 FROM mtl_system_items_b
2881 WHERE inventory_item_id = p_item_id
2882 AND ORGANIZATION_id = (SELECT ORGANIZATION_id FROM
2883 rcv_shipment_headers WHERE SHIPMENT_HEADER_ID =p_shipment_header_id);--bug13558642
2884
2885 IF (l_debug = 1) THEN
2886 print_debug(' p_shipment_header_id: '||p_shipment_header_id, 4);
2887 print_debug(' l_serial_control_code1: '||l_serial_control_code1, 4);--bug13558642
2888 print_debug(' l2_lot_code: '|| l2_lot_code , 4);
2889 END IF;
2890
2891 EXCEPTION
2892 WHEN OTHERS THEN
2893 IF (l_debug = 1) THEN
2894 print_debug('lot_control_code: When Others Exception' , 4);
2895 END IF;
2896 l2_lot_code := 0;
2897 END;
2898
2899
2900 IF(l2_lot_code = 1) THEN
2901 -- condition added to pass lot_number as null if item is plain for the bug number 12814511,
2902 l_lot_number := NULL;
2903
2904 END IF;
2905 -- end part2 bug 12814511
2906
2907
2908 l_progress := '40';
2909 -- call matching algorithm ?
2910
2911 -- initialize input record for matching algorithm
2912 g_rcpt_match_table_gross(g_receipt_detail_index).GROUP_ID := l_group_id;
2913 g_rcpt_match_table_gross(g_receipt_detail_index).transaction_type := 'RECEIVE';
2914 g_rcpt_match_table_gross(g_receipt_detail_index).quantity := p_rcv_qty;
2915 g_rcpt_match_table_gross(g_receipt_detail_index).unit_of_measure := p_rcv_uom;
2916 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := p_item_id;
2917 --Need to use revision also in matching if entered by user.bug 3368197
2918 g_rcpt_match_table_gross(g_receipt_detail_index).revision := p_revision;
2919 g_rcpt_match_table_gross(g_receipt_detail_index).shipment_header_id := p_shipment_header_id;
2920 g_rcpt_match_table_gross(g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
2921 g_rcpt_match_table_gross(g_receipt_detail_index).ship_to_location_id := p_location_id; -- for tolerance checks in matching.
2922 g_rcpt_match_table_gross(g_receipt_detail_index).tax_amount := 0; -- ?
2923 g_rcpt_match_table_gross(g_receipt_detail_index).error_status := 'S'; -- ?
2924 g_rcpt_match_table_gross(g_receipt_detail_index).to_organization_id := p_organization_id;
2925 g_rcpt_match_table_gross(g_receipt_detail_index).project_id := p_project_id;
2926 g_rcpt_match_table_gross(g_receipt_detail_index).task_id := p_task_id;
2927 g_rcpt_match_table_gross(g_receipt_detail_index).lot_number := l_lot_number;
2928 IF (l_serial_control_code1 NOT IN (1)) THEN --bug13558642
2929 g_rcpt_match_table_gross(g_receipt_detail_index).serial_number := l_serial_number; --9651496,9764650
2930 END IF;
2931 g_rcpt_match_table_gross(g_receipt_detail_index).req_header_id := p_req_header_id; --12546176
2932
2933 l_progress := '60';
2934
2935 SELECT primary_unit_of_measure
2936 INTO g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure
2937 FROM mtl_system_items
2938 WHERE mtl_system_items.inventory_item_id = p_item_id
2939 AND mtl_system_items.organization_id = p_organization_id;
2940
2941 l_progress := '70';
2942
2943 IF (l_debug = 1) THEN
2944 print_debug('create_intship_rcpt_intf_rec: 30 before matching ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2945 END IF;
2946
2947 inv_rcv_txn_match.matching_logic(
2948 x_return_status => l_return_status
2949 , --?
2950 x_msg_count => l_msg_count
2951 , x_msg_data => l_msg_data
2952 , x_cascaded_table => g_rcpt_match_table_gross
2953 , n => g_receipt_detail_index
2954 , temp_cascaded_table => l_rcpt_match_table_detail
2955 , p_receipt_num => NULL
2956 , p_match_type => 'INTRANSIT SHIPMENT'
2957 , p_lpn_id => p_from_lpn_id
2958 );
2959
2960 IF (l_debug = 1) THEN
2961 print_debug('create_intship_rcpt_intf_rec: 40 after matching ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
2962 print_debug('create_intship_rcpt_intf_rec: 40.1 - after matching l_return_status = ' || l_return_status, 4);
2963 print_debug('create_intship_rcpt_intf_rec: 40.2 - after matching l_msg_count = ' || l_msg_count, 4);
2964 print_debug('create_intship_rcpt_intf_rec: 40.3 - after matching l_msg_data = ' || l_msg_data, 4);
2965 END IF;
2966
2967 -- x_status is not successful if there is any execution error in matching.
2968 IF l_return_status = fnd_api.g_ret_sts_error THEN
2969 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2970 fnd_msg_pub.ADD;
2971
2972 IF (l_debug = 1) THEN
2973 print_debug('create_intship_rcpt_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2974 END IF;
2975
2976 RAISE fnd_api.g_exc_error;
2977 END IF;
2978
2979 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
2980 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
2981 fnd_msg_pub.ADD;
2982
2983 IF (l_debug = 1) THEN
2984 print_debug('create_intship_rcpt_intf_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
2985 , 1);
2986 END IF;
2987
2988 RAISE fnd_api.g_exc_unexpected_error;
2989 END IF;
2990
2991 IF g_rcpt_match_table_gross(g_receipt_detail_index).error_status = 'E' THEN
2992 l_err_message := g_rcpt_match_table_gross(g_receipt_detail_index).error_message;
2993 fnd_message.set_name('INV', l_err_message);
2994 fnd_msg_pub.ADD;
2995
2996 IF (l_debug = 1) THEN
2997 print_debug('create_intship_rcpt_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
2998 END IF;
2999
3000 RAISE fnd_api.g_exc_error;
3001 END IF;
3002
3003 l_err_message := '@@@';
3004
3005 FOR i IN g_receipt_detail_index ..(g_receipt_detail_index + l_rcpt_match_table_detail.COUNT - 1) LOOP
3006 IF l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_status = 'W' THEN
3007 x_status := 'W';
3008 l_temp_message := l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_message;
3009
3010 IF l_temp_message IS NULL THEN
3011 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3012 l_msg_prod := 'INV';
3013 EXIT;
3014 END IF;
3015
3016 IF l_err_message = '@@@' THEN
3017 l_err_message := l_temp_message;
3018 l_msg_prod := 'INV';
3019 ELSIF l_temp_message <> l_err_message THEN
3020 l_msg_prod := 'INV';
3021 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3022 EXIT;
3023 END IF;
3024 END IF;
3025 END LOOP;
3026
3027 IF l_err_message <> '@@@' THEN
3028 fnd_message.set_name(l_msg_prod, l_err_message);
3029 fnd_msg_pub.ADD;
3030
3031 IF (l_debug = 1) THEN
3032 print_debug('create_intship_rcpt_intf_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3033 END IF;
3034 END IF;
3035
3036 -- load the matching algorithm result into input data structure
3037
3038
3039
3040 -- based on return from matching algorithm,
3041 -- determine which line in rcv_transaction block to be inserted into RTI
3042
3043
3044
3045 --loop through results returned by matching algorithm
3046 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
3047 l_progress := '72';
3048 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).shipment_line_id);
3049 l_progress := '74';
3050 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
3051 l_progress := '76';
3052 CLOSE l_curs_rcpt_detail;
3053 l_progress := '78';
3054 l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
3055 -- update following fields from matching algorithm return value
3056 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
3057 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
3058 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
3059 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
3060 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3061
3062 --Bug# 16474295 pass the seondary qty only when there is single line match,
3063 --For distributing into multiple RSLs case , don't pass any value ,
3064 --in RTP code has such logic if this is fully receive,secondary qty = rsl.shipped_SecQty
3065 --if this is patial receive , secondary qty = convert(primary_qty)
3066 IF l_rcpt_match_table_detail.Count = 1 THEN
3067 l_rcv_transaction_rec.secondary_quantity := p_secondary_quantity;
3068 l_rcv_transaction_rec.secondary_uom := p_secondary_uom; --OPM Convergence
3069 l_rcv_transaction_rec.secondary_uom_code := p_secondary_uom_code; --OPM Convergence
3070
3071 IF (l_debug = 1) THEN
3072 print_debug('in create_intship_rcpt_intf_rec: secondary_quantity ' || l_rcv_transaction_rec.secondary_quantity,1);
3073 print_debug('in create_intship_rcpt_intf_rec: secondary_uom ' || l_rcv_transaction_rec.secondary_uom,1);
3074 print_debug('in create_intship_rcpt_intf_rec: secondary_uom_code ' || l_rcv_transaction_rec.secondary_uom_code,1);
3075 END IF;
3076
3077 END IF;
3078
3079 -- End Bug# 16474295
3080
3081 l_rcv_transaction_rec.destination_subinventory := p_rcv_subinventory_code;
3082 l_rcv_transaction_rec.locator_id := p_rcv_locator_id;
3083
3084 l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
3085 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
3086
3087
3088 -- following fileds can have distribution level values
3089 -- therefore they are set here instead of in the common insert code
3090 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.ordered_qty;
3091 --Bug 2073164
3092 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
3093
3094 --bug 3368197. Need to pass revision to insert_txn_interface
3095 l_rcv_transaction_rec.item_revision := p_revision;
3096
3097 IF (l_debug = 1) THEN
3098 print_debug('create_intship_rcpt_intf_rec: 90 before insert_txn_interface ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3099 END IF;
3100
3101 l_progress := '80';
3102
3103 IF p_country_code IS NOT NULL THEN
3104 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
3105 END IF;
3106
3107 --Bug #4147209 - Populate the record type with the DFF attribute category
3108 --and segment values passed from the mobile UI
3109 set_attribute_vals(
3110 p_rcv_rcpt_rec => l_rcv_rcpt_rec
3111 , p_attribute_category => p_attribute_category
3112 , p_attribute1 => p_attribute1
3113 , p_attribute2 => p_attribute2
3114 , p_attribute3 => p_attribute3
3115 , p_attribute4 => p_attribute4
3116 , p_attribute5 => p_attribute5
3117 , p_attribute6 => p_attribute6
3118 , p_attribute7 => p_attribute7
3119 , p_attribute8 => p_attribute8
3120 , p_attribute9 => p_attribute9
3121 , p_attribute10 => p_attribute10
3122 , p_attribute11 => p_attribute11
3123 , p_attribute12 => p_attribute12
3124 , p_attribute13 => p_attribute13
3125 , p_attribute14 => p_attribute14
3126 , p_attribute15 => p_attribute15);
3127
3128 l_interface_transaction_id := insert_txn_interface(
3129 l_rcv_transaction_rec
3130 , l_rcv_rcpt_rec
3131 , l_group_id
3132 , l_transaction_type
3133 , p_organization_id
3134 , p_location_id
3135 , p_source_type
3136 , NULL --p_qa_routing_id
3137 , p_project_id
3138 , p_task_id);
3139 l_progress := '90';
3140
3141 IF (l_debug = 1) THEN
3142 print_debug('create_intship_rcpt_intf_rec: 100 after insert_txn_interface ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3143 END IF;
3144
3145 IF (l_debug = 1) THEN
3146 print_debug('create_intship_rcpt_intf_rec 135.5: INV J and PO J are installed. No Move Order creation from UI', 4);
3147 END IF;
3148 /* Populate the table to store the information of the RTIs created*/
3149 l_new_rti_info(match_result_count).orig_interface_trx_id := p_original_rti_id;
3150 l_new_rti_info(match_result_count).new_interface_trx_id := l_interface_transaction_id;
3151 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
3152 END LOOP; --END LOOP through results returned by matching algorithm
3153
3154 l_progress := '100';
3155
3156 --BUG 3326408,3346758,3405320
3157 --If there are any serials confirmed from the UI for an item that is
3158 --lot controlled and serial control dynamic at SO issue,
3159 --do not NULL out serial_transaction_temp_id. In other cases,
3160 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
3161 l_msni_count := 0;
3162 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
3163 l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
3164 IF (l_debug = 1) THEN
3165 print_debug('create_intship_rcpt_intf_rec 135.6: serial_control_code IS 6, need TO NULL OUT mtli', 4);
3166 END IF;
3167
3168 BEGIN
3169 IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3170 SELECT count(1)
3171 INTO l_msni_count
3172 FROM mtl_serial_numbers_interface
3173 WHERE product_transaction_id = p_original_rti_id
3174 AND product_code = 'RCV';
3175 END IF;
3176
3177 IF l_msni_count = 0 THEN
3178 UPDATE mtl_transaction_lots_interface
3179 SET serial_transaction_temp_id = NULL
3180 WHERE product_transaction_id = p_original_rti_id
3181 AND product_code = 'RCV';
3182 END IF;
3183
3184 EXCEPTION
3185 WHEN OTHERS THEN
3186 IF (l_debug = 1) THEN
3187 print_debug('create_intship_rcpt_intf_rec 135.7: Error nulling serial temp id OF MTLI', 4);
3188 END IF;
3189 END ;
3190 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
3191
3192 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
3193 p_api_version => 1.0
3194 , p_init_msg_lst => FND_API.G_FALSE
3195 , x_return_status => l_return_status
3196 , x_msg_count => l_msg_count
3197 , x_msg_data => x_message
3198 , p_new_rti_info => l_new_rti_info);
3199 IF ( NOT l_split_lot_serial_ok) THEN
3200 IF (l_debug = 1) THEN
3201 print_debug('create_intship_rcpt_intf_rec 100.1: Failure in split_lot_serial', 4);
3202 END IF;
3203 RAISE FND_API.G_EXC_ERROR;
3204 END IF;
3205
3206 IF (l_debug = 1) THEN
3207 print_debug('create_intship_rcpt_intf_rec 100.2: Call split_lot_serial is OK', 4);
3208 END IF;
3209
3210 l_progress := '110';
3211
3212 IF l_curs_rcpt_detail%ISOPEN THEN
3213 CLOSE l_curs_rcpt_detail;
3214 END IF;
3215
3216 -- append index in input table where the line to be detailed needs to be inserted
3217 --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
3218
3219 -- clear the lot/qty data structure
3220 g_rcpt_lot_qty_rec_tb.DELETE;
3221 l_progress := '120';
3222 inv_rcv_common_apis.do_check(
3223 p_organization_id => p_organization_id
3224 , p_inventory_item_id => p_item_id
3225 , p_transaction_type_id => 61
3226 , p_primary_quantity => l_total_primary_qty
3227 , x_return_status => l_return_status
3228 , x_msg_count => l_msg_count
3229 , x_msg_data => x_message
3230 );
3231
3232 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3233 x_status := l_return_status;
3234 END IF;
3235
3236 l_progress := '130';
3237
3238 IF (l_debug = 1) THEN
3239 print_debug('About exiting create_intship_rcpt_intf_rec: 140 - after cursor loop '
3240 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
3241 , 1);
3242 END IF;
3243 EXCEPTION
3244 WHEN fnd_api.g_exc_error THEN
3245 ROLLBACK TO crt_intship_rti_sp;
3246 x_status := fnd_api.g_ret_sts_error;
3247
3248 IF l_curs_rcpt_detail%ISOPEN THEN
3249 CLOSE l_curs_rcpt_detail;
3250 END IF;
3251
3252 fnd_msg_pub.count_and_get(
3253 p_encoded => fnd_api.g_false
3254 , p_count => l_msg_count
3255 , p_data => x_message);
3256
3257 IF (l_debug = 1) THEN
3258 print_debug('create_intship_rcpt_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3259 END IF;
3260 WHEN fnd_api.g_exc_unexpected_error THEN
3261 ROLLBACK TO crt_intship_rti_sp;
3262 x_status := fnd_api.g_ret_sts_unexp_error;
3263
3264 IF l_curs_rcpt_detail%ISOPEN THEN
3265 CLOSE l_curs_rcpt_detail;
3266 END IF;
3267
3268 fnd_msg_pub.count_and_get(
3269 p_encoded => fnd_api.g_false
3270 , p_count => l_msg_count
3271 , p_data => x_message);
3272
3273 IF (l_debug = 1) THEN
3274 print_debug('create_intship_rcpt_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3275 END IF;
3276 WHEN OTHERS THEN
3277 ROLLBACK TO crt_intship_rti_sp;
3278 x_status := fnd_api.g_ret_sts_unexp_error;
3279
3280 IF l_curs_rcpt_detail%ISOPEN THEN
3281 CLOSE l_curs_rcpt_detail;
3282 END IF;
3283
3284 IF SQLCODE IS NOT NULL THEN
3285 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_intship_rcpt_intf_rec', l_progress, SQLCODE);
3286 END IF;
3287
3288 fnd_msg_pub.count_and_get(
3289 p_encoded => fnd_api.g_false
3290 , p_count => l_msg_count
3291 , p_data => x_message);
3292
3293 IF (l_debug = 1) THEN
3294 print_debug('create_intship_rcpt_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3295 END IF;
3296 END create_intship_rcpt_intf_rec;
3297
3298 PROCEDURE create_rma_rcpt_intf_rec(
3299 p_move_order_header_id IN OUT NOCOPY NUMBER
3300 , p_organization_id IN NUMBER
3301 , p_oe_order_header_id IN NUMBER
3302 , p_item_id IN NUMBER
3303 , p_location_id IN NUMBER
3304 , p_rcv_qty IN NUMBER
3305 , p_rcv_uom IN VARCHAR2
3306 , p_rcv_uom_code IN VARCHAR2
3307 , p_source_type IN VARCHAR2
3308 , p_lpn_id IN NUMBER
3309 , p_lot_control_code IN NUMBER
3310 , p_revision IN VARCHAR2
3311 , p_inspect IN NUMBER
3312 , x_status OUT NOCOPY VARCHAR2
3313 , x_message OUT NOCOPY VARCHAR2
3314 , p_project_id IN NUMBER DEFAULT NULL
3315 , p_task_id IN NUMBER DEFAULT NULL
3316 , p_country_code IN VARCHAR2 DEFAULT NULL
3317 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL -- RCVLOCATORSSUPPORT
3318 , p_rcv_locator_id IN NUMBER DEFAULT NULL
3319 , p_original_rti_id IN NUMBER DEFAULT NULL --Lot/Serial Support
3320 , p_secondary_uom IN VARCHAR2 DEFAULT NULL-- OPM Convergence
3321 , p_secondary_uom_code IN VARCHAR2 DEFAULT NULL-- OPM Convergence
3322 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
3323 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
3324 , p_attribute1 IN VARCHAR2 DEFAULT NULL
3325 , p_attribute2 IN VARCHAR2 DEFAULT NULL
3326 , p_attribute3 IN VARCHAR2 DEFAULT NULL
3327 , p_attribute4 IN VARCHAR2 DEFAULT NULL
3328 , p_attribute5 IN VARCHAR2 DEFAULT NULL
3329 , p_attribute6 IN VARCHAR2 DEFAULT NULL
3330 , p_attribute7 IN VARCHAR2 DEFAULT NULL
3331 , p_attribute8 IN VARCHAR2 DEFAULT NULL
3332 , p_attribute9 IN VARCHAR2 DEFAULT NULL
3333 , p_attribute10 IN VARCHAR2 DEFAULT NULL
3334 , p_attribute11 IN VARCHAR2 DEFAULT NULL
3335 , p_attribute12 IN VARCHAR2 DEFAULT NULL
3336 , p_attribute13 IN VARCHAR2 DEFAULT NULL
3337 , p_attribute14 IN VARCHAR2 DEFAULT NULL
3338 , p_attribute15 IN VARCHAR2 DEFAULT NULL
3339 ) IS
3340 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
3341 l_rcv_transaction_rec rcv_transaction_rec_tp; -- rcv_transaction block
3342 l_interface_transaction_id NUMBER := NULL;
3343 -- this is used to keep track of the id used to insert the row in rti
3344
3345 l_transaction_type VARCHAR2(20) := 'RECEIVE';
3346 l_total_primary_qty NUMBER := 0;
3347 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
3348 l_msg_count NUMBER;
3349 l_msg_data VARCHAR2(4000);
3350 l_progress VARCHAR2(10);
3351 l_err_message VARCHAR2(100);
3352 l_temp_message VARCHAR2(100);
3353 l_msg_prod VARCHAR2(5);
3354 l_group_id NUMBER;
3355 l_rcv_rcpt_rec rcv_enter_receipts_rec_tp;
3356 l_inspect NUMBER;
3357 l_default_routing_id NUMBER;
3358
3359 CURSOR l_curs_rcpt_detail(v_oe_order_line_id NUMBER) IS
3360 SELECT 'N' line_chkbox
3361 , 'CUSTOMER' source_type_code
3362 , 'CUSTOMER' receipt_source_code
3363 , '' order_type_code
3364 , '' order_type
3365 , TO_NUMBER(NULL) po_header_id
3366 , NULL po_number
3367 , TO_NUMBER(NULL) po_line_id
3368 , TO_NUMBER(NULL) po_line_number
3369 , TO_NUMBER(NULL) po_line_location_id
3370 , TO_NUMBER(NULL) po_shipment_number
3371 , TO_NUMBER(NULL) po_release_id
3372 , TO_NUMBER(NULL) po_release_number
3373 , TO_NUMBER(NULL) req_header_id
3374 , NULL req_number
3375 , TO_NUMBER(NULL) req_line_id
3376 , TO_NUMBER(NULL) req_line
3377 , TO_NUMBER(NULL) req_distribution_id
3378 , TO_NUMBER(NULL) rcv_shipment_header_id
3379 , NULL rcv_shipment_number
3380 , TO_NUMBER(NULL) rcv_shipment_line_id
3381 , TO_NUMBER(NULL) rcv_line_number
3382 , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) from_organization_id
3383 , NVL(oel.ship_from_org_id, oeh.ship_from_org_id) to_organization_id
3384 , TO_NUMBER(NULL) vendor_id
3385 , '' SOURCE
3386 , TO_NUMBER(NULL) vendor_site_id
3387 , NULL outside_operation_flag
3388 , oel.inventory_item_id item_id
3389 , -- Bug 2073164
3390 NULL uom_code
3391 , mum.unit_of_measure primary_uom
3392 , mum.uom_class primary_uom_class
3393 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
3394 , NVL(msi.location_control_code, 1) item_locator_control
3395 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
3396 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
3397 , NVL(msi.shelf_life_code, 1) shelf_life_code
3398 , NVL(msi.shelf_life_days, 0) shelf_life_days
3399 , msi.serial_number_control_code serial_number_control_code
3400 , msi.lot_control_code lot_control_code
3401 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
3402 , NULL item_rev_control_flag_from
3403 , msi.segment1 item_number
3404 , oel.item_revision item_revision
3405 , msi.description item_description
3406 , TO_NUMBER(NULL) item_category_id
3407 , NULL hazard_class
3408 , NULL un_number
3409 , NULL vendor_item_number
3410 , oel.ship_from_org_id ship_to_location_id
3411 , '' ship_to_location
3412 , NULL packing_slip
3413 , TO_NUMBER(NULL) routing_id
3414 , NULL routing_name
3415 , oel.request_date need_by_date
3416 , NVL(oel.promise_date, oel.request_date) expected_receipt_date
3417 , oel.ordered_quantity ordered_qty
3418 , '' ordered_uom
3419 , NULL ussgl_transaction_code
3420 , NULL government_context
3421 , DECODE(msi.return_inspection_requirement, 1, 'Y', 'N') inspection_required_flag
3422 , 'Y' receipt_required_flag
3423 , 'N' enforce_ship_to_location_code
3424 , oel.unit_selling_price unit_price
3425 , oeh.transactional_curr_code currency_code
3426 , oeh.conversion_type_code currency_conversion_type
3427 , oeh.conversion_rate_date currency_conversion_date
3428 , oeh.conversion_rate currency_conversion_rate
3429 , NULL note_to_receiver
3430 , NULL destination_type_code
3431 , oel.deliver_to_contact_id deliver_to_person_id
3432 , oel.deliver_to_org_id deliver_to_location_id
3433 , NULL destination_subinventory
3434 , oel.CONTEXT attribute_category
3435 , oel.attribute1 attribute1
3436 , oel.attribute2 attribute2
3437 , oel.attribute3 attribute3
3438 , oel.attribute4 attribute4
3439 , oel.attribute5 attribute5
3440 , oel.attribute6 attribute6
3441 , oel.attribute7 attribute7
3442 , oel.attribute8 attribute8
3443 , oel.attribute9 attribute9
3444 , oel.attribute10 attribute10
3445 , oel.attribute11 attribute11
3446 , oel.attribute12 attribute12
3447 , oel.attribute13 attribute13
3448 , oel.attribute14 attribute14
3449 , oel.attribute15 attribute15
3450 , NULL closed_code
3451 , NULL asn_type
3452 , NULL bill_of_lading
3453 , TO_DATE(NULL) shipped_date
3454 , NULL freight_carrier_code
3455 , NULL waybill_airbill_num
3456 , NULL freight_bill_num
3457 , NULL vendor_lot_num
3458 , NULL container_num
3459 , NULL truck_num
3460 , NULL bar_code_label
3461 , NULL rate_type_display
3462 , NULL match_option
3463 , NULL country_of_origin_code
3464 , oel.header_id oe_order_header_id
3465 , oeh.order_number oe_order_num
3466 , oel.line_id oe_order_line_id
3467 , oel.line_number oe_order_line_num
3468 , oel.sold_to_org_id customer_id
3469 , NVL(oel.ship_to_org_id, oeh.ship_to_org_id) customer_site_id
3470 , '' customer_item_num
3471 , '' pll_note_to_receiver
3472 , NULL po_distribution_id
3473 , NULL qty_ordered
3474 , NULL wip_entity_id
3475 , NULL wip_operation_seq_num
3476 , NULL wip_resource_seq_num
3477 , NULL wip_repetitive_schedule_id
3478 , NULL wip_line_id
3479 , NULL bom_resource_id
3480 , '' destination_type
3481 , '' LOCATION
3482 , NULL currency_conversion_rate_pod
3483 , NULL currency_conversion_date_pod
3484 , project_id project_id
3485 , task_id task_id
3486 , NULL secondary_uom --OPM Convergence
3487 , NULL secondary_uom_code --OPM Convergence
3488 , NULL secondary_quantity --OPM Convergence
3489 FROM oe_order_lines_all oel
3490 , oe_order_headers_all oeh
3491 , mtl_system_items msi
3492 , mtl_units_of_measure mum
3493 WHERE oel.line_category_code = 'RETURN'
3494 AND oel.header_id = oeh.header_id
3495 AND oel.inventory_item_id = msi.inventory_item_id
3496 AND oel.ship_from_org_id = msi.organization_id
3497 AND msi.primary_uom_code = mum.uom_code
3498 AND oel.booked_flag = 'Y'
3499 AND oel.ordered_quantity > NVL(oel.shipped_quantity, 0)
3500 AND msi.mtl_transactions_enabled_flag = 'Y'
3501 AND oel.line_id = v_oe_order_line_id
3502 AND(
3503 (p_project_id IS NULL
3504 OR(p_project_id = -9999
3505 AND oel.project_id IS NULL) --bug#2669021
3506 OR oel.project_id = p_project_id)
3507 AND(p_task_id IS NULL
3508 OR oel.task_id = p_task_id)
3509 );
3510 -- don't need from and to org for the query since both have 1-to-1 relationship to shipment header
3511
3512 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3513 --table to store all RTId, quantity and original_rti_id for lot/serial splits
3514 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
3515 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
3516 l_line_id NUMBER;
3517 BEGIN
3518 IF (l_debug = 1) THEN
3519 print_debug('create_rma_rcpt_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3520 END IF;
3521
3522 -- print_debug('project id ' || p_project_id);
3523 -- print_debug('task_id ' || p_task_id);
3524 SAVEPOINT crt_rma_rti_sp;
3525 x_status := fnd_api.g_ret_sts_success;
3526 l_progress := '10';
3527
3528 -- query po_startup_value
3529 BEGIN
3530 inv_rcv_common_apis.init_startup_values(p_organization_id);
3531 EXCEPTION
3532 WHEN NO_DATA_FOUND THEN
3533 fnd_message.set_name('INV', 'INV_RCV_PARAM');
3534 fnd_msg_pub.ADD;
3535 RAISE fnd_api.g_exc_error;
3536 END;
3537
3538 IF (l_debug = 1) THEN
3539 print_debug('create_rma_rcpt_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3540 END IF;
3541
3542 -- default header level non-DB items in rcv_transaction block
3543 -- and default other values need to be insert into RTI
3544
3545 l_progress := '20';
3546
3547 -- default l_group_id ? clear group id after done
3548 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
3549 SELECT rcv_interface_groups_s.NEXTVAL
3550 INTO l_group_id
3551 FROM DUAL;
3552
3553 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
3554 ELSE
3555 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
3556 END IF;
3557
3558 l_progress := '30';
3559 -- call matching algorithm ?
3560
3561 -- initialize input record for matching algorithm
3562 g_rcpt_match_table_gross(g_receipt_detail_index).GROUP_ID := l_group_id;
3563 g_rcpt_match_table_gross(g_receipt_detail_index).transaction_type := 'RECEIVE';
3564 g_rcpt_match_table_gross(g_receipt_detail_index).quantity := p_rcv_qty;
3565 g_rcpt_match_table_gross(g_receipt_detail_index).unit_of_measure := p_rcv_uom;
3566 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := p_item_id;
3567 g_rcpt_match_table_gross(g_receipt_detail_index).oe_order_header_id := p_oe_order_header_id;
3568 g_rcpt_match_table_gross(g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
3569 g_rcpt_match_table_gross(g_receipt_detail_index).ship_to_location_id := p_location_id; -- for tolerance checks in matching.
3570 g_rcpt_match_table_gross(g_receipt_detail_index).tax_amount := 0; -- ?
3571 g_rcpt_match_table_gross(g_receipt_detail_index).error_status := 'S'; -- ?
3572 g_rcpt_match_table_gross(g_receipt_detail_index).to_organization_id := p_organization_id;
3573 g_rcpt_match_table_gross(g_receipt_detail_index).project_id := p_project_id;
3574 g_rcpt_match_table_gross(g_receipt_detail_index).task_id := p_task_id;
3575 l_progress := '60';
3576
3577 SELECT primary_unit_of_measure
3578 INTO g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure
3579 FROM mtl_system_items
3580 WHERE mtl_system_items.inventory_item_id = p_item_id
3581 AND mtl_system_items.organization_id = p_organization_id;
3582
3583 l_progress := '70';
3584
3585 IF (l_debug = 1) THEN
3586 print_debug('create_rma_rcpt_intf_rec: 30 before matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3587 END IF;
3588
3589 inv_rcv_txn_match.matching_logic(
3590 x_return_status => l_return_status
3591 , --?
3592 x_msg_count => l_msg_count
3593 , x_msg_data => l_msg_data
3594 , x_cascaded_table => g_rcpt_match_table_gross
3595 , n => g_receipt_detail_index
3596 , temp_cascaded_table => l_rcpt_match_table_detail
3597 , p_receipt_num => NULL
3598 , p_match_type => 'RMA'
3599 , p_lpn_id => NULL
3600 );
3601
3602 IF (l_debug = 1) THEN
3603 print_debug('create_rma_rcpt_intf_rec: 40 after matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3604 print_debug('create_rma_rcpt_intf_rec: 40.1 - after matching l_return_status = ' || l_return_status, 4);
3605 print_debug('create_rma_rcpt_intf_rec: 40.2 - after matching l_msg_count = ' || l_msg_count, 4);
3606 print_debug('create_rma_rcpt_intf_rec: 40.3 - after matching l_msg_data = ' || l_msg_data, 4);
3607 END IF;
3608
3609 IF l_return_status = fnd_api.g_ret_sts_error THEN
3610 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3611 fnd_msg_pub.ADD;
3612
3613 IF (l_debug = 1) THEN
3614 print_debug('create_rma_rcpt_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3615 END IF;
3616
3617 RAISE fnd_api.g_exc_error;
3618 END IF;
3619
3620 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
3621 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
3622 fnd_msg_pub.ADD;
3623
3624 IF (l_debug = 1) THEN
3625 print_debug('create_rma_rcpt_intf_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3626 END IF;
3627
3628 RAISE fnd_api.g_exc_unexpected_error;
3629 END IF;
3630
3631 IF g_rcpt_match_table_gross(g_receipt_detail_index).error_status = 'E' THEN
3632 l_err_message := g_rcpt_match_table_gross(g_receipt_detail_index).error_message;
3633 fnd_message.set_name('INV', l_err_message);
3634 fnd_msg_pub.ADD;
3635
3636 IF (l_debug = 1) THEN
3637 print_debug('create_rma_rcpt_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3638 END IF;
3639
3640 RAISE fnd_api.g_exc_error;
3641 END IF;
3642
3643 l_err_message := '@@@';
3644
3645 FOR i IN g_receipt_detail_index ..(g_receipt_detail_index + l_rcpt_match_table_detail.COUNT - 1) LOOP
3646 IF l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_status = 'W' THEN
3647 x_status := 'W';
3648 l_temp_message := l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_message;
3649
3650 IF l_temp_message IS NULL THEN
3651 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3652 l_msg_prod := 'INV';
3653 EXIT;
3654 END IF;
3655
3656 IF l_err_message = '@@@' THEN
3657 l_err_message := l_temp_message;
3658 l_msg_prod := 'INV';
3659 ELSIF l_temp_message <> l_err_message THEN
3660 l_msg_prod := 'INV';
3661 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
3662 EXIT;
3663 END IF;
3664 END IF;
3665 END LOOP;
3666
3667 IF l_err_message <> '@@@' THEN
3668 fnd_message.set_name(l_msg_prod, l_err_message);
3669 fnd_msg_pub.ADD;
3670
3671 IF (l_debug = 1) THEN
3672 print_debug('create_rma_rcpt_intf_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3673 END IF;
3674 END IF;
3675
3676 -- load the matching algorithm result into input data structure
3677 -- based on return from matching algorithm,
3678 -- determine which line in rcv_transaction block to be inserted into RTI
3679 -- loop through results returned by matching algorithm
3680 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
3681 l_progress := '72';
3682 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).oe_order_line_id);
3683 l_progress := '74';
3684 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
3685 l_progress := '76';
3686 -- print_debug('receipt source code before passing ' || l_rcv_rcpt_rec.source_type_code,4);
3687 -- print_debug('OE project id = ' || l_rcv_rcpt_rec.project_id,4);
3688 -- print_debug('OE task id = ' || l_rcv_rcpt_rec.task_id,4);
3689 CLOSE l_curs_rcpt_detail;
3690 l_progress := '78';
3691 l_rcv_transaction_rec.oe_order_line_id := l_rcpt_match_table_detail(match_result_count).oe_order_line_id;
3692 -- update following fields from matching algorithm return value
3693
3694 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
3695 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
3696 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
3697 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
3698 --BUG 3308727 issue 129
3699 l_rcv_transaction_rec.item_revision := p_revision;
3700 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
3701
3702 l_rcv_transaction_rec.destination_subinventory := p_rcv_subinventory_code;
3703 l_rcv_transaction_rec.locator_id := p_rcv_locator_id;
3704
3705 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
3706
3707 -- following fileds can have distribution level values
3708 -- therefore they are set here instead of in the common insert code
3709 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.ordered_qty;
3710 --Bug 2073164
3711 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
3712 /* Bug 8270256: Assign secondary quantity and uoms */
3713 IF p_secondary_quantity IS NOT NULL THEN
3714
3715 IF (l_debug = 1) THEN
3716 print_debug('In create_rma_std_dlvr_rti_rec 7.1: p_rcv_qty'|| p_rcv_qty, 1);
3717 print_debug('In create_rma_std_dlvr_rti_rec 7.2: l_rcpt_match_table_detail(match_result_count).quantity'|| l_rcpt_match_table_detail(match_result_count).quantity, 1);
3718 print_debug('In create_rma_std_dlvr_rti_rec 7.3: p_secondary_quantity'|| p_secondary_quantity, 1);
3719 print_debug('In create_rma_std_dlvr_rti_rec 7.4: p_secondary_uom'|| p_secondary_uom, 1);
3720 print_debug('In create_rma_std_dlvr_rti_rec 7.5: p_secondary_uom_code'|| p_secondary_uom_code, 1);
3721 END IF;
3722
3723
3724 l_rcv_transaction_rec.secondary_quantity := (l_rcpt_match_table_detail(match_result_count).quantity/p_rcv_qty) * p_secondary_quantity;
3725 l_rcv_transaction_rec.secondary_uom := p_secondary_uom;
3726 l_rcv_transaction_rec.secondary_uom_code := p_secondary_uom_code;
3727 END IF;
3728 /* End of bug 8270256 changes */
3729
3730 IF (l_debug = 1) THEN
3731 print_debug('create_rma_rcpt_intf_rec: 90 before insert_txn_interface' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3732 END IF;
3733
3734 l_progress := '80';
3735
3736 IF p_country_code IS NOT NULL THEN
3737 l_rcv_rcpt_rec.country_of_origin_code := p_country_code;
3738 END IF;
3739
3740 --Bug #4147209 - Populate the record type with the DFF attribute category
3741 --and segment values passed from the mobile UI
3742 set_attribute_vals(
3743 p_rcv_rcpt_rec => l_rcv_rcpt_rec
3744 , p_attribute_category => p_attribute_category
3745 , p_attribute1 => p_attribute1
3746 , p_attribute2 => p_attribute2
3747 , p_attribute3 => p_attribute3
3748 , p_attribute4 => p_attribute4
3749 , p_attribute5 => p_attribute5
3750 , p_attribute6 => p_attribute6
3751 , p_attribute7 => p_attribute7
3752 , p_attribute8 => p_attribute8
3753 , p_attribute9 => p_attribute9
3754 , p_attribute10 => p_attribute10
3755 , p_attribute11 => p_attribute11
3756 , p_attribute12 => p_attribute12
3757 , p_attribute13 => p_attribute13
3758 , p_attribute14 => p_attribute14
3759 , p_attribute15 => p_attribute15);
3760
3761 l_interface_transaction_id := insert_txn_interface(
3762 l_rcv_transaction_rec
3763 , l_rcv_rcpt_rec
3764 , l_group_id
3765 , l_transaction_type
3766 , p_organization_id
3767 , p_location_id
3768 , p_source_type
3769 , NULL -- p_qa_routing_id
3770 , p_project_id
3771 , p_task_id);
3772 l_progress := '90';
3773
3774 IF (l_debug = 1) THEN
3775 print_debug('create_rma_rcpt_intf_rec: 100 after insert_txn_interface' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
3776 END IF;
3777
3778 IF (l_debug = 1) THEN
3779 print_debug('create_rma_rcpt_intf_rec 135.5: INV J and PO J are installed. No Move Order creation from UI', 4);
3780 END IF;
3781 /* Populate the table to store the information of the RTIs created*/
3782 l_new_rti_info(match_result_count).orig_interface_trx_id := p_original_rti_id;
3783 l_new_rti_info(match_result_count).new_interface_trx_id := l_interface_transaction_id;
3784 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
3785 END LOOP; --END LOOP through results returned by matching algorithm
3786
3787 --Call the split_lot API to split the lots and serials inserted from the UI
3788 --based on the quantity of each RTI record
3789 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
3790 p_api_version => 1.0
3791 , p_init_msg_lst => FND_API.G_FALSE
3792 , x_return_status => l_return_status
3793 , x_msg_count => l_msg_count
3794 , x_msg_data => x_message
3795 , p_new_rti_info => l_new_rti_info);
3796 IF ( NOT l_split_lot_serial_ok) THEN
3797 IF (l_debug = 1) THEN
3798 print_debug('create_rama_rcpt_intf_rec 110.1: Failure in split_lot_serial', 4);
3799 END IF;
3800 RAISE FND_API.G_EXC_ERROR;
3801 END IF;
3802
3803 IF (l_debug = 1) THEN
3804 print_debug('create_rma_rcpt_intf_rec 110.2: Call split_lot_serial is OK', 4);
3805 END IF;
3806
3807 IF l_curs_rcpt_detail%ISOPEN THEN
3808 CLOSE l_curs_rcpt_detail;
3809 END IF;
3810
3811 -- append index in input table where the line to be detailed needs to be inserted
3812 --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
3813
3814 -- clear the lot/qty data structure
3815 g_rcpt_lot_qty_rec_tb.DELETE;
3816 l_progress := '120';
3817 inv_rcv_common_apis.do_check(
3818 p_organization_id => p_organization_id
3819 , p_inventory_item_id => p_item_id
3820 , p_transaction_type_id => 15
3821 , p_primary_quantity => l_total_primary_qty
3822 , x_return_status => l_return_status
3823 , x_msg_count => l_msg_count
3824 , x_msg_data => x_message
3825 );
3826
3827 IF l_return_status <> fnd_api.g_ret_sts_success THEN
3828 x_status := l_return_status;
3829 END IF;
3830
3831 l_progress := '130';
3832
3833 IF (l_debug = 1) THEN
3834 print_debug('About exit create_rma_rcpt_intf_rec: 140 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3835 END IF;
3836 EXCEPTION
3837 WHEN fnd_api.g_exc_error THEN
3838 ROLLBACK TO crt_rma_rti_sp;
3839 x_status := fnd_api.g_ret_sts_error;
3840
3841 IF l_curs_rcpt_detail%ISOPEN THEN
3842 CLOSE l_curs_rcpt_detail;
3843 END IF;
3844
3845 fnd_msg_pub.count_and_get(
3846 p_encoded => fnd_api.g_false
3847 , p_count => l_msg_count
3848 , p_data => x_message);
3849
3850 IF (l_debug = 1) THEN
3851 print_debug('create_rma_rcpt_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3852 END IF;
3853 WHEN fnd_api.g_exc_unexpected_error THEN
3854 ROLLBACK TO crt_rma_rti_sp;
3855 x_status := fnd_api.g_ret_sts_unexp_error;
3856
3857 IF l_curs_rcpt_detail%ISOPEN THEN
3858 CLOSE l_curs_rcpt_detail;
3859 END IF;
3860
3861 fnd_msg_pub.count_and_get(
3862 p_encoded => fnd_api.g_false
3863 , p_count => l_msg_count
3864 , p_data => x_message);
3865
3866 IF (l_debug = 1) THEN
3867 print_debug('create_rma_rcpt_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3868 END IF;
3869 WHEN OTHERS THEN
3870 ROLLBACK TO crt_rma_rti_sp;
3871 x_status := fnd_api.g_ret_sts_unexp_error;
3872
3873 IF l_curs_rcpt_detail%ISOPEN THEN
3874 CLOSE l_curs_rcpt_detail;
3875 END IF;
3876
3877 IF SQLCODE IS NOT NULL THEN
3878 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_rma_rcpt_intf_rec', l_progress, SQLCODE);
3879 END IF;
3880
3881 fnd_msg_pub.count_and_get(
3882 p_encoded => fnd_api.g_false
3883 , p_count => l_msg_count
3884 , p_data => x_message);
3885
3886 IF (l_debug = 1) THEN
3887 print_debug('create_rma_rcpt_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
3888 END IF;
3889 END create_rma_rcpt_intf_rec;
3890
3891 PROCEDURE create_asn_con_rcpt_intf_rec(
3892 p_move_order_header_id IN OUT NOCOPY NUMBER
3893 , p_organization_id IN NUMBER
3894 , p_shipment_header_id IN NUMBER
3895 , p_po_header_id IN NUMBER
3896 , p_item_id IN NUMBER
3897 , p_location_id IN NUMBER
3898 , p_rcv_qty IN NUMBER
3899 , p_rcv_uom IN VARCHAR2
3900 , p_rcv_uom_code IN VARCHAR2
3901 , p_source_type IN VARCHAR2
3902 , p_from_lpn_id IN NUMBER
3903 , p_lpn_id IN NUMBER
3904 , p_lot_control_code IN NUMBER
3905 , p_revision IN VARCHAR2
3906 , p_inspect IN NUMBER
3907 , x_status OUT NOCOPY VARCHAR2
3908 , x_message OUT NOCOPY VARCHAR2
3909 , p_item_desc IN VARCHAR2 DEFAULT NULL
3910 , p_project_id IN NUMBER DEFAULT NULL
3911 , p_task_id IN NUMBER DEFAULT NULL
3912 , p_country_code IN VARCHAR2 DEFAULT NULL
3913 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL -- RCVLOCATORSSUPPORT
3914 , p_rcv_locator_id IN NUMBER DEFAULT NULL
3915 , p_original_rti_id IN NUMBER DEFAULT NULL --Lot/Serial Support
3916 , p_secondary_uom IN VARCHAR2 DEFAULT NULL-- OPM Convergence
3917 , p_secondary_uom_code IN VARCHAR2 DEFAULT NULL-- OPM Convergence
3918 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
3919 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
3920 , p_attribute1 IN VARCHAR2 DEFAULT NULL
3921 , p_attribute2 IN VARCHAR2 DEFAULT NULL
3922 , p_attribute3 IN VARCHAR2 DEFAULT NULL
3923 , p_attribute4 IN VARCHAR2 DEFAULT NULL
3924 , p_attribute5 IN VARCHAR2 DEFAULT NULL
3925 , p_attribute6 IN VARCHAR2 DEFAULT NULL
3926 , p_attribute7 IN VARCHAR2 DEFAULT NULL
3927 , p_attribute8 IN VARCHAR2 DEFAULT NULL
3928 , p_attribute9 IN VARCHAR2 DEFAULT NULL
3929 , p_attribute10 IN VARCHAR2 DEFAULT NULL
3930 , p_attribute11 IN VARCHAR2 DEFAULT NULL
3931 , p_attribute12 IN VARCHAR2 DEFAULT NULL
3932 , p_attribute13 IN VARCHAR2 DEFAULT NULL
3933 , p_attribute14 IN VARCHAR2 DEFAULT NULL
3934 , p_attribute15 IN VARCHAR2 DEFAULT NULL
3935 , p_express_transaction IN VARCHAR2 DEFAULT NULL
3936 ) IS
3937 l_rcpt_match_table_detail inv_rcv_common_apis.cascaded_trans_tab_type; -- output for matching algorithm
3938 l_rcv_transaction_rec rcv_transaction_rec_tp; -- rcv_transaction block
3939 l_interface_transaction_id NUMBER := NULL;
3940 -- this is used to keep track of the id used to insert the row in rti
3941
3942 l_transaction_type VARCHAR2(20) := 'RECEIVE';
3943 l_total_primary_qty NUMBER := 0;
3944 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
3945 l_msg_count NUMBER;
3946 l_msg_data VARCHAR2(4000);
3947 l_progress VARCHAR2(10);
3948 l_err_message VARCHAR2(100);
3949 l_temp_message VARCHAR2(100);
3950 l_msg_prod VARCHAR2(5);
3951 l_group_id NUMBER;
3952 l_rcv_rcpt_rec rcv_enter_receipts_rec_tp;
3953 l_inspect NUMBER;
3954 l_match_type VARCHAR2(30);
3955 l_receipt_num VARCHAR2(30);
3956 -- Added for bug# 6967549
3957 l_qa_availability VARCHAR2(30) := fnd_api.g_false;
3958 l_evaluation_result VARCHAR2(20);
3959 l_project_id NUMBER := p_project_id;
3960 l_task_id NUMBER := p_task_id;
3961 l_lot_number VARCHAR2(80) ; --12339922
3962
3963 CURSOR l_curs_rcpt_detail(v_shipment_line_id NUMBER) IS
3964 SELECT 'N' line_chkbox
3965 -- For Bug 7440217
3966 , p_source_type source_type_code
3967 -- End for Bug 7440217
3968 , 'VENDOR' receipt_source_code
3969 , 'PO' order_type_code
3970 , '' order_type
3971 , poll.po_header_id po_header_id
3972 , poh.segment1 po_number
3973 , poll.po_line_id po_line_id
3974 , pol.line_num po_line_number
3975 , poll.line_location_id po_line_location_id
3976 , poll.shipment_num po_shipment_number
3977 , poll.po_release_id po_release_id
3978 , por.release_num po_release_number
3979 , TO_NUMBER(NULL) req_header_id
3980 , NULL req_number
3981 , TO_NUMBER(NULL) req_line_id
3982 , TO_NUMBER(NULL) req_line
3983 , TO_NUMBER(NULL) req_distribution_id
3984 , rsh.shipment_header_id rcv_shipment_header_id
3985 , rsh.shipment_num rcv_shipment_number
3986 , rsl.shipment_line_id rcv_shipment_line_id
3987 , rsl.line_num rcv_line_number
3988 , rsl.from_organization_id from_organization_id --Bug #3878174
3989 /*
3990 , NVL(rsl.from_organization_id, poh.po_header_id) from_organization_id
3991 */
3992 , rsl.to_organization_id to_organization_id
3993 , rsh.vendor_id vendor_id
3994 , '' SOURCE
3995 , poh.vendor_site_id vendor_site_id -- Bug 6403165
3996 , '' outside_operation_flag
3997 , rsl.item_id item_id
3998 , -- Bug 2073164
3999 NULL uom_code
4000 , rsl.unit_of_measure primary_uom
4001 , mum.uom_class primary_uom_class
4002 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
4003 , NVL(msi.location_control_code, 1) item_locator_control
4004 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
4005 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
4006 , NVL(msi.shelf_life_code, 1) shelf_life_code
4007 , NVL(msi.shelf_life_days, 0) shelf_life_days
4008 , msi.serial_number_control_code serial_number_control_code
4009 , msi.lot_control_code lot_control_code
4010 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
4011 , NULL item_rev_control_flag_from
4012 , NULL item_number
4013 , rsl.item_revision item_revision
4014 , rsl.item_description item_description
4015 , rsl.category_id item_category_id
4016 , '' hazard_class
4017 , '' un_number
4018 , rsl.vendor_item_num vendor_item_number
4019 , rsl.ship_to_location_id ship_to_location_id
4020 , '' ship_to_location
4021 , rsl.packing_slip packing_slip
4022 , rsl.routing_header_id routing_id
4023 , '' routing_name
4024 , poll.need_by_date need_by_date
4025 , rsh.expected_receipt_date expected_receipt_date
4026 , poll.quantity ordered_qty
4027 , pol.unit_meas_lookup_code ordered_uom
4028 , rsl.ussgl_transaction_code ussgl_transaction_code
4029 , rsl.government_context government_context
4030 , poll.inspection_required_flag inspection_required_flag
4031 , poll.receipt_required_flag receipt_required_flag
4032 , poll.enforce_ship_to_location_code enforce_ship_to_location_code
4033 , NVL(poll.price_override, pol.unit_price) unit_price
4034 , poh.currency_code currency_code
4035 , poh.rate_type currency_conversion_type
4036 , poh.rate_date currency_conversion_date
4037 , poh.rate currency_conversion_rate
4038 , poh.note_to_receiver note_to_receiver
4039 , rsl.destination_type_code destination_type_code
4040 , rsl.deliver_to_person_id deliver_to_person_id
4041 , rsl.deliver_to_location_id deliver_to_location_id
4042 , rsl.to_subinventory destination_subinventory
4043 , rsl.attribute_category attribute_category
4044 , rsl.attribute1 attribute1
4045 , rsl.attribute2 attribute2
4046 , rsl.attribute3 attribute3
4047 , rsl.attribute4 attribute4
4048 , rsl.attribute5 attribute5
4049 , rsl.attribute6 attribute6
4050 , rsl.attribute7 attribute7
4051 , rsl.attribute8 attribute8
4052 , rsl.attribute9 attribute9
4053 , rsl.attribute10 attribute10
4054 , rsl.attribute11 attribute11
4055 , rsl.attribute12 attribute12
4056 , rsl.attribute13 attribute13
4057 , rsl.attribute14 attribute14
4058 , rsl.attribute15 attribute15
4059 , poll.closed_code closed_code
4060 , rsh.asn_type asn_type
4061 , rsh.bill_of_lading bill_of_lading
4062 , rsh.shipped_date shipped_date
4063 , rsh.freight_carrier_code freight_carrier_code
4064 , rsh.waybill_airbill_num waybill_airbill_num
4065 , rsh.freight_bill_number freight_bill_num
4066 , rsl.vendor_lot_num vendor_lot_num
4067 , rsl.container_num container_num
4068 , rsl.truck_num truck_num
4069 , rsl.bar_code_label bar_code_label
4070 , '' rate_type_display
4071 , poll.match_option match_option
4072 , rsl.country_of_origin_code country_of_origin_code
4073 , TO_NUMBER(NULL) oe_order_header_id
4074 , TO_NUMBER(NULL) oe_order_num
4075 , TO_NUMBER(NULL) oe_order_line_id
4076 , TO_NUMBER(NULL) oe_order_line_num
4077 , TO_NUMBER(NULL) customer_id
4078 , TO_NUMBER(NULL) customer_site_id
4079 , NULL customer_item_num
4080 , NULL pll_note_to_receiver
4081 , --POLL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
4082 NULL po_distribution_id
4083 , NULL qty_ordered
4084 , NULL wip_entity_id
4085 , NULL wip_operation_seq_num
4086 , NULL wip_resource_seq_num
4087 , NULL wip_repetitive_schedule_id
4088 , NULL wip_line_id
4089 , NULL bom_resource_id
4090 , '' destination_type
4091 , '' LOCATION
4092 , NULL currency_conversion_rate_pod
4093 , NULL currency_conversion_date_pod
4094 , NULL project_id
4095 , NULL task_id
4096 , NULL secondary_uom --OPM Convergence
4097 , NULL secondary_uom_code --OPM Convergence
4098 , NULL secondary_quantity --OPM Convergence
4099 FROM rcv_shipment_lines rsl
4100 , rcv_shipment_headers rsh
4101 , po_headers poh
4102 , po_line_locations poll
4103 , po_lines pol
4104 , po_releases por
4105 , mtl_system_items msi
4106 , mtl_units_of_measure mum
4107 WHERE NVL(poll.approved_flag, 'N') = 'Y'
4108 AND NVL(poll.cancel_flag, 'N') = 'N'
4109 AND NVL(poll.closed_code, 'OPEN') <> 'FINALLY CLOSED'
4110 AND poll.shipment_type IN('STANDARD', 'BLANKET', 'SCHEDULED')
4111 AND poh.po_header_id = poll.po_header_id
4112 AND pol.po_line_id = poll.po_line_id
4113 AND poll.po_release_id = por.po_release_id(+)
4114 AND mum.unit_of_measure(+) = rsl.unit_of_measure
4115 AND NVL(msi.organization_id, rsl.to_organization_id) = rsl.to_organization_id
4116 AND msi.inventory_item_id(+) = rsl.item_id
4117 AND poll.line_location_id = rsl.po_line_location_id
4118 AND rsl.shipment_header_id = rsh.shipment_header_id
4119 -- For Bug 7440217 Added type LCM also
4120 AND rsh.asn_type IN('ASN', 'ASBN', 'LCM')
4121 -- End for Bug 7440217
4122 AND rsl.shipment_line_status_code <> 'CANCELLED'
4123 AND rsl.shipment_line_id = v_shipment_line_id
4124 AND poll.line_location_id IN(
4125 SELECT pod.line_location_id
4126 FROM po_distributions_all pod
4127 WHERE (
4128 p_project_id IS NULL
4129 OR(p_project_id = -9999
4130 AND pod.project_id IS NULL)
4131 OR --bug#2669021
4132 NVL(pod.project_id, -9999) = p_project_id
4133 )
4134 AND(p_task_id IS NULL
4135 OR NVL(pod.task_id, -9999) = p_task_id)
4136 AND pod.po_header_id = poll.po_header_id
4137 AND pod.po_line_id = poll.po_line_id
4138 AND pod.line_location_id = poll.line_location_id)
4139 UNION
4140 SELECT 'N' line_chkbox
4141 , 'INTERNAL' source_type_code
4142 , DECODE(rsl.source_document_code, 'INVENTORY', 'INVENTORY', 'REQ', 'INTERNAL ORDER') receipt_source_code
4143 , rsl.source_document_code order_type_code
4144 , '' order_type
4145 , rsh.shipment_header_id po_header_id
4146 , rsh.shipment_num po_number
4147 , rsl.shipment_line_id po_line_id
4148 , rsl.line_num po_line_number
4149 , rsl.shipment_line_id po_line_location_id
4150 , rsl.line_num po_shipment_number
4151 , rsh.shipment_header_id po_release_id
4152 , rsh.shipment_header_id po_release_number
4153 , porh.requisition_header_id req_header_id
4154 , porh.segment1 req_number
4155 , porl.requisition_line_id req_line_id
4156 , porl.line_num req_line
4157 , rsl.req_distribution_id req_distribution_id
4158 , rsl.shipment_header_id rcv_shipment_header_id
4159 , rsh.shipment_num rcv_shipment_number
4160 , rsl.shipment_line_id rcv_shipment_line_id
4161 , rsl.line_num rcv_line_number
4162 , rsl.from_organization_id from_organization_id
4163 , rsl.to_organization_id to_organization_id
4164 , rsl.shipment_line_id vendor_id
4165 , '' SOURCE
4166 , TO_NUMBER(NULL) vendor_site_id
4167 , 'N' outside_operation_flag
4168 , rsl.item_id item_id
4169 , -- Bug 2073164
4170 NULL uom_code
4171 , rsl.unit_of_measure primary_uom
4172 , mum.uom_class primary_uom_class
4173 , NVL(msi.allowed_units_lookup_code, 2) item_allowed_units_lookup_code
4174 , NVL(msi.location_control_code, 1) item_locator_control
4175 , DECODE(msi.restrict_locators_code, 1, 'Y', 'N') restrict_locators_code
4176 , DECODE(msi.restrict_subinventories_code, 1, 'Y', 'N') restrict_subinventories_code
4177 , NVL(msi.shelf_life_code, 1) shelf_life_code
4178 , NVL(msi.shelf_life_days, 0) shelf_life_days
4179 , msi.serial_number_control_code serial_number_control_code
4180 , msi.lot_control_code lot_control_code
4181 , DECODE(msi.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_to
4182 , DECODE(msi1.revision_qty_control_code, 1, 'N', 2, 'Y', 'N') item_rev_control_flag_from
4183 , NULL item_number
4184 , rsl.item_revision item_revision
4185 , rsl.item_description item_description
4186 , rsl.category_id item_category_id
4187 , '' hazard_class
4188 , '' un_number
4189 , rsl.vendor_item_num vendor_item_number
4190 , rsh.ship_to_location_id ship_to_location_id
4191 , '' ship_to_location
4192 , rsh.packing_slip packing_slip
4193 , rsl.routing_header_id routing_id
4194 , '' routing_name
4195 , porl.need_by_date need_by_date
4196 , rsh.expected_receipt_date expected_receipt_date
4197 , rsl.quantity_shipped ordered_qty
4198 , rsl.primary_unit_of_measure ordered_uom
4199 , rsh.ussgl_transaction_code ussgl_transaction_code
4200 , rsh.government_context government_context
4201 , NULL inspection_required_flag
4202 , NULL receipt_required_flag
4203 , NULL enforce_ship_to_location_code
4204 , TO_NUMBER(NULL) unit_price
4205 , NULL currency_code
4206 , NULL currency_conversion_type
4207 , TO_DATE(NULL) currency_conversion_date
4208 , TO_NUMBER(NULL) currency_conversion_rate
4209 , NULL note_to_receiver
4210 , --PORL.NOTE_TO_RECEIVER NOTE_TO_RECEIVER,
4211 rsl.destination_type_code destination_type_code
4212 , rsl.deliver_to_person_id deliver_to_person_id
4213 , rsl.deliver_to_location_id deliver_to_location_id
4214 , rsl.to_subinventory destination_subinventory
4215 , rsl.attribute_category attribute_category
4216 , rsl.attribute1 attribute1
4217 , rsl.attribute2 attribute2
4218 , rsl.attribute3 attribute3
4219 , rsl.attribute4 attribute4
4220 , rsl.attribute5 attribute5
4221 , rsl.attribute6 attribute6
4222 , rsl.attribute7 attribute7
4223 , rsl.attribute8 attribute8
4224 , rsl.attribute9 attribute9
4225 , rsl.attribute10 attribute10
4226 , rsl.attribute11 attribute11
4227 , rsl.attribute12 attribute12
4228 , rsl.attribute13 attribute13
4229 , rsl.attribute14 attribute14
4230 , rsl.attribute15 attribute15
4231 , 'OPEN' closed_code
4232 , NULL asn_type
4233 , rsh.bill_of_lading bill_of_lading
4234 , rsh.shipped_date shipped_date
4235 , rsh.freight_carrier_code freight_carrier_code
4236 , rsh.waybill_airbill_num waybill_airbill_num
4237 , rsh.freight_bill_number freight_bill_num
4238 , rsl.vendor_lot_num vendor_lot_num
4239 , rsl.container_num container_num
4240 , rsl.truck_num truck_num
4241 , rsl.bar_code_label bar_code_label
4242 , NULL rate_type_display
4243 , 'P' match_option
4244 , NULL country_of_origin_code
4245 , TO_NUMBER(NULL) oe_order_header_id
4246 , TO_NUMBER(NULL) oe_order_num
4247 , TO_NUMBER(NULL) oe_order_line_id
4248 , TO_NUMBER(NULL) oe_order_line_num
4249 , TO_NUMBER(NULL) customer_id
4250 , TO_NUMBER(NULL) customer_site_id
4251 , NULL customer_item_num
4252 , NULL pll_note_to_receiver
4253 , --PORL.NOTE_TO_RECEIVER PLL_NOTE_TO_RECEIVER,
4254 NULL po_distribution_id
4255 , NULL qty_ordered
4256 , NULL wip_entity_id
4257 , NULL wip_operation_seq_num
4258 , NULL wip_resource_seq_num
4259 , NULL wip_repetitive_schedule_id
4260 , NULL wip_line_id
4261 , NULL bom_resource_id
4262 , '' destination_type
4263 , '' LOCATION
4264 , NULL currency_conversion_rate_pod
4265 , NULL currency_conversion_date_pod
4266 , NULL project_id
4267 , NULL task_id
4268 , NULL secondary_uom --OPM Convergence
4269 , NULL secondary_uom_code --OPM Convergence
4270 , NULL secondary_quantity --OPM Convergence temp
4271 FROM rcv_shipment_headers rsh
4272 , rcv_shipment_lines rsl
4273 , po_requisition_headers porh
4274 , po_requisition_lines porl
4275 , mtl_system_items msi
4276 , mtl_system_items msi1
4277 , mtl_units_of_measure mum
4278 WHERE rsh.receipt_source_code <> 'VENDOR'
4279 AND rsl.requisition_line_id = porl.requisition_line_id(+)
4280 AND porl.requisition_header_id = porh.requisition_header_id(+)
4281 AND rsh.shipment_header_id = rsl.shipment_header_id
4282 AND mum.unit_of_measure(+) = rsl.unit_of_measure
4283 AND msi.organization_id(+) = rsl.to_organization_id
4284 AND msi.inventory_item_id(+) = rsl.item_id
4285 AND msi1.organization_id(+) = rsl.from_organization_id
4286 AND msi1.inventory_item_id(+) = rsl.item_id
4287 AND rsh.asn_type IS NULL
4288 AND rsl.shipment_line_id = v_shipment_line_id;
4289 -- dont need from and to org for the query since both have 1-to-1 relationship to shipment header
4290
4291 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4292 --table to store all RTId, quantity and original_rti_id for lot/serial splits
4293 l_new_rti_info inv_rcv_integration_apis.child_rec_tb_tp;
4294 l_split_lot_serial_ok BOOLEAN; --Return status of lot_serial_split API
4295 l_lpn_id NUMBER := p_lpn_id;
4296 l_msni_count NUMBER := 0;
4297 l_line_id NUMBER;
4298 BEGIN
4299 IF (l_debug = 1) THEN
4300 print_debug('create_asn_con_rcpt_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4301 print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
4302 print_debug('p_organization_id = ' || p_organization_id, 4);
4303 print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
4304 print_debug('p_po_header_id = ' || p_po_header_id, 4);
4305 print_debug('p_item_id = ' || p_item_id, 4);
4306 print_debug('p_location_id = ' || p_location_id, 4);
4307 print_debug('p_rcv_qty = ' || p_rcv_qty, 4);
4308 print_debug('p_rcv_uom = ' || p_rcv_uom, 4);
4309 print_debug('p_rcv_uom_code = ' || p_rcv_uom_code, 4);
4310 print_debug('p_source_type = ' || p_source_type, 4);
4311 print_debug('p_from_lpn_id = ' || p_from_lpn_id, 4);
4312 print_debug('p_lpn_id = ' || p_lpn_id, 4);
4313 print_debug('p_lot_control_code = ' || p_lot_control_code, 4);
4314 print_debug('p_revision = ' || p_revision, 4);
4315 print_debug('p_inspect = ' || p_inspect, 4);
4316 print_debug('p_item_desc = ' || p_item_desc, 4);
4317 print_debug('p_project_id = ' || p_project_id, 4);
4318 print_debug('p_task_id = ' || p_task_id, 4);
4319 print_debug('p_secondary_uom = ' || p_secondary_uom, 4); --Added for Bug 12732516
4320 print_debug('p_secondary_uom_code = ' || p_secondary_uom_code, 4); --Added for Bug 12732516
4321 print_debug('p_secondary_quantity = ' || p_secondary_quantity, 4); --Added for Bug 12732516
4322 END IF;
4323
4324 SAVEPOINT crt_asn_con_rti_sp;
4325 x_status := fnd_api.g_ret_sts_success;
4326 l_progress := '10';
4327
4328 -- query po_startup_value
4329 BEGIN
4330 /* Bug #2516729
4331 * Fetch rcv_shipment_headers.receipt_number for the given shipment_header_id.
4332 * If it exists , assign it to the global variable for receipt # (g_rcv_global_var.receipt_num)
4333 * in order that a new receipt # is not created everytime and the existing receipt # is used
4334 */
4335 BEGIN
4336 SELECT receipt_num
4337 INTO l_receipt_num
4338 FROM rcv_shipment_headers
4339 WHERE shipment_header_id = p_shipment_header_id
4340 AND ship_to_org_id = p_organization_id;
4341
4342 /* Bug# 6339752 the global variable inv_rcv_common_apis.g_rcv_global_var.receipt_num is to be set only if
4343 * there is non-null value from RSH.
4344 */
4345
4346 IF (l_receipt_num IS NOT NULL) THEN
4347 inv_rcv_common_apis.g_rcv_global_var.receipt_num := l_receipt_num;
4348 END IF;
4349
4350 IF (l_debug = 1) THEN
4351 print_debug('create_asn_con_rcpt_intf_rec: 10.1 ' || inv_rcv_common_apis.g_rcv_global_var.receipt_num, 1);
4352 END IF;
4353 EXCEPTION
4354 WHEN NO_DATA_FOUND THEN
4355 l_receipt_num := NULL;
4356 END;
4357
4358 inv_rcv_common_apis.init_startup_values(p_organization_id);
4359 EXCEPTION
4360 WHEN NO_DATA_FOUND THEN
4361 fnd_message.set_name('INV', 'INV_RCV_PARAM');
4362 fnd_msg_pub.ADD;
4363 RAISE fnd_api.g_exc_error;
4364 END;
4365
4366 -- default header level non-DB items in rcv_transaction block
4367 -- and default other values need to be insert into RTI
4368
4369 IF (l_debug = 1) THEN
4370 print_debug('create_asn_con_rcpt_intf_rec: 20 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4371 END IF;
4372
4373 l_progress := '20';
4374
4375 -- default l_group_id ? clear group id after done
4376 IF inv_rcv_common_apis.g_rcv_global_var.interface_group_id IS NULL THEN
4377 SELECT rcv_interface_groups_s.NEXTVAL
4378 INTO l_group_id
4379 FROM DUAL;
4380
4381 inv_rcv_common_apis.g_rcv_global_var.interface_group_id := l_group_id;
4382 ELSE
4383 l_group_id := inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
4384 END IF;
4385
4386 l_progress := '30';
4387 -- call matching algorithm ?
4388
4389 --12339922-starts
4390 BEGIN
4391 SELECT lot_number INTO l_lot_number
4392 FROM mtl_transaction_lots_interface
4393 WHERE product_transaction_id = p_original_rti_id ;
4394 EXCEPTION
4395 WHEN No_Data_Found THEN
4396 IF (l_debug = 1) THEN
4397 print_debug('The value of create_intship_rcpt_intf_rec: No Lot records in MTLI for id :'||p_original_rti_id,4);
4398 END IF;
4399 l_lot_number :=NULL;
4400 WHEN too_many_rows THEN
4401 IF (l_debug = 1) THEN
4402 print_debug('The value of create_intship_rcpt_intf_rec: More than one records in MTLI for id :'||p_original_rti_id,4);
4403 END IF;
4404 l_lot_number :=NULL; --For multiple lots dont input to matching logic
4405 END;
4406 IF (l_debug = 1) THEN
4407 print_debug('The value of create_intship_rcpt_intf_rec: 30.2 lot_number: ' || l_lot_number, 4);
4408 END IF;
4409 --12339922-ends
4410
4411 -- Added for bug 12732516 -- Start
4412 BEGIN
4413 IF l_lot_number is not null THEN
4414 select lot_num
4415 into l_lot_number
4416 from rcv_lots_supply
4417 where lot_num = l_lot_number
4418 and supply_type_code = 'SHIPMENT'
4419 and primary_quantity > 0
4420 and shipment_line_id in
4421 (select shipment_line_id
4422 from rcv_shipment_headers
4423 where shipment_header_id = p_shipment_header_id)
4424 and rownum = 1;
4425 END IF;
4426
4427 EXCEPTION
4428 WHEN OTHERS THEN
4429 l_lot_number := NULL;
4430 IF (l_debug = 1) THEN
4431 print_debug('create_asn_con_rcpt_intf_rec: 30.3 lot_number: ' || l_lot_number, 4);
4432 END IF;
4433
4434 END;
4435
4436 IF (l_debug = 1) THEN
4437 print_debug('create_asn_con_rcpt_intf_rec: 30.4 lot_number: ' || l_lot_number, 4);
4438 END IF;
4439 -- Added for bug 12732516 -- End
4440
4441 -- initialize input record for matching algorithm
4442 g_rcpt_match_table_gross(g_receipt_detail_index).GROUP_ID := l_group_id;
4443 g_rcpt_match_table_gross(g_receipt_detail_index).transaction_type := 'RECEIVE';
4444 g_rcpt_match_table_gross(g_receipt_detail_index).quantity := p_rcv_qty;
4445 g_rcpt_match_table_gross(g_receipt_detail_index).unit_of_measure := p_rcv_uom;
4446
4447 IF p_item_id IS NOT NULL THEN
4448 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := p_item_id;
4449 ELSE
4450 g_rcpt_match_table_gross(g_receipt_detail_index).item_id := NULL;
4451 g_rcpt_match_table_gross(g_receipt_detail_index).item_desc := p_item_desc;
4452 END IF;
4453
4454 g_rcpt_match_table_gross(g_receipt_detail_index).to_organization_id := p_organization_id;
4455 g_rcpt_match_table_gross(g_receipt_detail_index).shipment_header_id := p_shipment_header_id;
4456 g_rcpt_match_table_gross(g_receipt_detail_index).po_header_id := p_po_header_id;
4457 g_rcpt_match_table_gross(g_receipt_detail_index).expected_receipt_date := SYSDATE; --?
4458 g_rcpt_match_table_gross(g_receipt_detail_index).ship_to_location_id := p_location_id; -- for tolerance checks in matching.
4459 g_rcpt_match_table_gross(g_receipt_detail_index).tax_amount := 0; -- ?
4460 g_rcpt_match_table_gross(g_receipt_detail_index).error_status := 'S'; -- ?
4461 g_rcpt_match_table_gross(g_receipt_detail_index).project_id := p_project_id; --BUG# 2794612
4462 g_rcpt_match_table_gross(g_receipt_detail_index).task_id := p_task_id; --BUG# 2794612
4463 g_rcpt_match_table_gross(g_receipt_detail_index).lot_number := l_lot_number; --Bug 12339922
4464
4465 /* Begin of bug 14377377 Pass inspection status to matching logic */
4466 IF (l_debug = 1) THEN
4467 print_debug('create_asn_con_rcpt_intf_rec: 30.5 - p_inspect = '||p_inspect, 4);
4468 END IF;
4469
4470 IF p_inspect IS NOT NULL AND p_inspect = 1 THEN
4471 g_rcpt_match_table_gross(g_receipt_detail_index).inspection_status_code := 'Y';
4472 ELSE
4473 g_rcpt_match_table_gross(g_receipt_detail_index).inspection_status_code := 'N';
4474 END IF;
4475 /* End of Bug 14377377 */
4476
4477 /* Bug 13598673 */
4478 IF p_source_type = 'ASN' THEN
4479 g_rcpt_match_table_gross(g_receipt_detail_index).revision := p_revision;
4480 END IF;
4481 /* End of Bug 13598673 */
4482
4483 l_progress := '60';
4484
4485 IF p_item_id IS NOT NULL THEN
4486 BEGIN
4487 SELECT primary_unit_of_measure
4488 INTO g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure
4489 FROM mtl_system_items
4490 WHERE mtl_system_items.inventory_item_id = p_item_id
4491 AND mtl_system_items.organization_id = p_organization_id;
4492 EXCEPTION
4493 WHEN OTHERS THEN
4494 IF (l_debug = 1) THEN
4495 print_debug('Primary_uom is null should not be null', 4);
4496 END IF;
4497
4498 l_progress := '65';
4499 RAISE fnd_api.g_exc_error;
4500 END;
4501 ELSE
4502 g_rcpt_match_table_gross(g_receipt_detail_index).primary_unit_of_measure := NULL;
4503 END IF;
4504
4505 l_progress := '70';
4506
4507 IF (l_debug = 1) THEN
4508 print_debug('create_asn_con_rcpt_intf_rec: 30 before matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4509 END IF;
4510
4511 -- For Bug 7440217 Added LCM Type also
4512 IF p_source_type IN ('ASN', 'LCM') THEN
4513 l_match_type := p_source_type;
4514 -- End for Bug 7440217
4515
4516 ELSE
4517 l_match_type := 'INTRANSIT SHIPMENT';
4518
4519 BEGIN
4520 SELECT cost_group_id
4521 INTO l_rcv_transaction_rec.cost_group_id
4522 FROM wms_lpn_contents wlpnc
4523 WHERE organization_id = p_organization_id
4524 AND parent_lpn_id = p_lpn_id
4525 AND wlpnc.inventory_item_id = p_item_id
4526 AND EXISTS(SELECT 1
4527 FROM cst_cost_group_accounts
4528 WHERE organization_id = p_organization_id
4529 AND cost_group_id = wlpnc.cost_group_id);
4530 EXCEPTION
4531 WHEN OTHERS THEN
4532 l_rcv_transaction_rec.cost_group_id := NULL;
4533 END;
4534
4535 IF l_rcv_transaction_rec.cost_group_id IS NULL THEN
4536 UPDATE wms_lpn_contents wlpnc
4537 SET cost_group_id = NULL
4538 WHERE organization_id = p_organization_id
4539 AND parent_lpn_id = p_from_lpn_id
4540 AND wlpnc.inventory_item_id = p_item_id
4541 AND NOT EXISTS(SELECT 1
4542 FROM cst_cost_group_accounts
4543 WHERE organization_id = p_organization_id
4544 AND cost_group_id = wlpnc.cost_group_id);
4545 END IF;
4546 END IF;
4547
4548 l_lpn_id := p_from_lpn_id;
4549
4550 inv_rcv_txn_match.matching_logic(
4551 x_return_status => l_return_status
4552 , --?
4553 x_msg_count => l_msg_count
4554 , x_msg_data => l_msg_data
4555 , x_cascaded_table => g_rcpt_match_table_gross
4556 , n => g_receipt_detail_index
4557 , temp_cascaded_table => l_rcpt_match_table_detail
4558 , p_receipt_num => NULL
4559 , p_match_type => l_match_type
4560 , p_lpn_id => l_lpn_id
4561 );
4562
4563 IF (l_debug = 1) THEN
4564 print_debug('create_asn_con_rcpt_intf_rec: 40 after matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4565 print_debug('create_asn_con_rcpt_intf_rec: 40.1 - after matching l_return_status = ' || l_return_status, 4);
4566 print_debug('create_asn_con_rcpt_intf_rec: 40.2 - after matching l_msg_count = ' || l_msg_count, 4);
4567 print_debug('create_asn_con_rcpt_intf_rec: 40.3 - after matching l_msg_data = ' || l_msg_data, 4);
4568 END IF;
4569
4570 IF l_return_status = fnd_api.g_ret_sts_error THEN
4571 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
4572 fnd_msg_pub.ADD;
4573
4574 IF (l_debug = 1) THEN
4575 print_debug('create_asn_con_rcpt_intf_rec 60.1: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4576 END IF;
4577
4578 RAISE fnd_api.g_exc_error;
4579 END IF;
4580
4581 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4582 fnd_message.set_name('INV', 'INV_RCV_MATCH_ERROR');
4583 fnd_msg_pub.ADD;
4584
4585 IF (l_debug = 1) THEN
4586 print_debug('create_asn_con_rcpt_intf_rec 60.2: Unexpect error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
4587 , 1);
4588 END IF;
4589
4590 RAISE fnd_api.g_exc_unexpected_error;
4591 END IF;
4592
4593 IF g_rcpt_match_table_gross(g_receipt_detail_index).error_status = 'E' THEN
4594 l_err_message := g_rcpt_match_table_gross(g_receipt_detail_index).error_message;
4595 fnd_message.set_name('INV', l_err_message);
4596 fnd_msg_pub.ADD;
4597
4598 IF (l_debug = 1) THEN
4599 print_debug('create_asn_con_rcpt_intf_rec 70: error calling matching' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4600 END IF;
4601
4602 RAISE fnd_api.g_exc_error;
4603 END IF;
4604
4605 l_err_message := '@@@';
4606
4607 FOR i IN g_receipt_detail_index ..(g_receipt_detail_index + l_rcpt_match_table_detail.COUNT - 1) LOOP
4608 IF l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_status = 'W' THEN
4609 x_status := 'W';
4610 l_temp_message := l_rcpt_match_table_detail(i - g_receipt_detail_index + 1).error_message;
4611
4612 IF l_temp_message IS NULL THEN
4613 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
4614 l_msg_prod := 'INV';
4615 EXIT;
4616 END IF;
4617
4618 IF l_err_message = '@@@' THEN
4619 l_err_message := l_temp_message;
4620 l_msg_prod := 'INV';
4621 ELSIF l_temp_message <> l_err_message THEN
4622 l_msg_prod := 'INV';
4623 l_err_message := 'INV_RCV_GEN_TOLERANCE_EXCEED';
4624 EXIT;
4625 END IF;
4626 END IF;
4627 END LOOP;
4628
4629 IF l_err_message <> '@@@' THEN
4630 fnd_message.set_name(l_msg_prod, l_err_message);
4631 fnd_msg_pub.ADD;
4632
4633 IF (l_debug = 1) THEN
4634 print_debug('create_asn_con_rcpt_intf_rec 80: adding tolerance message ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4635 END IF;
4636 END IF;
4637
4638 -- load the matching algorithm result into input data structure
4639 -- based on return from matching algorithm,
4640 -- determine which line in rcv_transaction block to be inserted into RTI
4641
4642 -- loop through results returned by matching algorithm
4643 FOR match_result_count IN 1 .. l_rcpt_match_table_detail.COUNT LOOP
4644 l_progress := '72';
4645 OPEN l_curs_rcpt_detail(l_rcpt_match_table_detail(match_result_count).shipment_line_id);
4646 l_progress := '74';
4647 FETCH l_curs_rcpt_detail INTO l_rcv_rcpt_rec;
4648 l_progress := '76';
4649 CLOSE l_curs_rcpt_detail;
4650 l_progress := '78';
4651 l_rcv_transaction_rec.rcv_shipment_line_id := l_rcpt_match_table_detail(match_result_count).shipment_line_id;
4652
4653 IF (l_debug = 1) THEN
4654 print_debug(
4655 'create_asn_con_rcpt_intf_rec: 90.1 - the '
4656 || match_result_count
4657 || 'th record of matching results - rcv_shipment_line_id = '
4658 || l_rcpt_match_table_detail(match_result_count).shipment_line_id
4659 , 4
4660 );
4661 END IF;
4662
4663 -- update following fields from matching algorithm return value
4664 l_rcv_transaction_rec.transaction_qty := l_rcpt_match_table_detail(match_result_count).quantity;
4665 l_rcv_transaction_rec.transaction_uom := l_rcpt_match_table_detail(match_result_count).unit_of_measure;
4666 l_rcv_transaction_rec.primary_quantity := l_rcpt_match_table_detail(match_result_count).primary_quantity;
4667 l_rcv_transaction_rec.primary_uom := l_rcpt_match_table_detail(match_result_count).primary_unit_of_measure;
4668
4669 -- Added for Bug 12732516 --Start.To pass sec qty values enterd by user only when matching logic returns one row.
4670
4671 IF (l_rcpt_match_table_detail.COUNT = 1) THEN
4672
4673 l_rcv_transaction_rec.secondary_quantity := p_secondary_quantity;
4674 l_rcv_transaction_rec.secondary_uom := p_secondary_uom;
4675 l_rcv_transaction_rec.secondary_uom_code := p_secondary_uom_code;
4676
4677 END IF;
4678 -- Added for bug 12732516 -- End
4679
4680 -- Nested LPN changes pass p_from_lpn_id
4681 -- are at J then pass From_lpn_id as lpn_id otherwise use old code.
4682 -- IF p_from_lpn_id IS NOT NULL
4683 l_rcv_transaction_rec.lpn_id := p_from_lpn_id;
4684 l_rcv_transaction_rec.transfer_lpn_id := p_lpn_id;
4685
4686 l_total_primary_qty := l_total_primary_qty + l_rcv_transaction_rec.primary_quantity;
4687 -- following fileds can have distribution level values
4688 -- therefore they are set here instead of in the common insert code
4689 l_rcv_transaction_rec.ordered_qty := l_rcv_rcpt_rec.ordered_qty;
4690 --Bug 2073164
4691 l_rcv_rcpt_rec.uom_code := p_rcv_uom_code;
4692
4693 IF (l_debug = 1) THEN
4694 print_debug('create_asn_con_rcpt_intf_rec: 100 before insert_txn_interface' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4695 END IF;
4696
4697 l_progress := '80';
4698
4699 l_rcv_transaction_rec.destination_subinventory := p_rcv_subinventory_code;
4700 l_rcv_transaction_rec.locator_id := p_rcv_locator_id;
4701 -- Bug 3211452
4702 -- Putting the Revision also
4703 l_rcv_transaction_rec.item_revision := p_revision;
4704
4705 IF p_country_code IS NOT NULL THEN
4706 l_rcv_transaction_rec.country_of_origin_code := p_country_code;
4707 END IF;
4708
4709 IF (p_inspect IS NOT NULL AND p_inspect = 1) THEN
4710
4711 -- Bug# 6967549, Check to see if Skip Lot functionality is enabled for the
4712 -- current org or not and activate the same only for ASN receipts.
4713 IF p_source_type = 'ASN' THEN
4714
4715 -- Calling function QA_SKIPLOT_RCV_GRP.CHECK_AVAILABILITY to check if Skip/Lot
4716 -- is enabled for the given org or not.
4717 -- returns fnd_api.g_true/false
4718 BEGIN
4719 l_progress := '81';
4720 qa_skiplot_rcv_grp.check_availability(
4721 p_api_version => 1.0
4722 , p_init_msg_list => fnd_api.g_false
4723 , p_commit => fnd_api.g_false
4724 , p_validation_level => fnd_api.g_valid_level_full
4725 , p_organization_id => p_organization_id
4726 , x_qa_availability => l_qa_availability
4727 , x_return_status => l_return_status
4728 , x_msg_count => l_msg_count
4729 , x_msg_data => l_msg_data
4730 );
4731 l_progress := '82';
4732 EXCEPTION
4733 WHEN OTHERS THEN
4734 IF (l_debug = 1) THEN
4735 print_debug( 'create_asn_con_rcpt_intf_rec: 101 - Exception in calling QA_SKIPLOT_RCV_GRP.CHECK_AVAILABILITY'
4736 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4737 END IF;
4738 RAISE fnd_api.g_exc_error;
4739 END;
4740
4741 IF NVL(l_return_status, fnd_api.g_ret_sts_success) = fnd_api.g_ret_sts_success THEN
4742
4743 -- If the Quaility Skip Lot function is available, then gets the interface transaction id and
4744 -- call QA_SKIPLOT_RCV_GRP.EVALUATE_LOT
4745 -- returns 'Standard' or 'Inspect' to x_evaluation_result.
4746 IF NVL(l_qa_availability, fnd_api.g_false) = fnd_api.g_true THEN
4747 l_rcv_rcpt_rec.inspection_required_flag := 'Y';
4748 l_rcv_rcpt_rec.routing_id := 2;
4749
4750 BEGIN
4751 SELECT rcv_transactions_interface_s.NEXTVAL
4752 INTO l_rcv_transaction_rec.interface_transaction_id
4753 FROM DUAL;
4754
4755 l_progress := '83';
4756 l_project_id := p_project_id;
4757 l_task_id := p_task_id;
4758
4759 IF l_project_id = '' THEN
4760 l_project_id := NULL;
4761 END IF;
4762
4763 IF l_task_id = '' THEN
4764 l_task_id := NULL;
4765 END IF;
4766
4767 IF (l_debug = 1) THEN
4768 print_debug('create_asn_con_rcpt_intf_rec 101 calling qa_skiplot_rcv_grp.evaluate_lot', 4);
4769 print_debug('create_asn_con_rcpt_intf_rec 101 with l_rcv_rcpt_rec.item_revision = '|| l_rcv_rcpt_rec.item_revision, 4);
4770 END IF;
4771
4772 -- Bug# 6967549, Same as previous version except now passing p_lpn_id directly
4773 -- to the p_lpn_id parameter in the qa_skiplot_rcv_grp.evaluate_lot() API call.
4774
4775 l_progress := '84';
4776 qa_skiplot_rcv_grp.evaluate_lot(
4777 p_api_version => 1.0
4778 , p_init_msg_list => fnd_api.g_false
4779 , p_commit => fnd_api.g_false
4780 , p_validation_level => fnd_api.g_valid_level_full
4781 , p_interface_txn_id => l_rcv_transaction_rec.interface_transaction_id
4782 , p_organization_id => p_organization_id
4783 , p_vendor_id => l_rcv_rcpt_rec.vendor_id
4784 , p_vendor_site_id => l_rcv_rcpt_rec.vendor_site_id
4785 , p_item_id => l_rcv_rcpt_rec.item_id
4786 , p_item_revision => l_rcv_rcpt_rec.item_revision
4787 , p_item_category_id => l_rcv_rcpt_rec.item_category_id
4788 , p_project_id => l_project_id
4789 , p_task_id => l_task_id
4790 , p_manufacturer_id => NULL
4791 , p_source_inspected => NULL
4792 , p_receipt_qty => l_rcv_transaction_rec.transaction_qty
4793 , p_receipt_date => SYSDATE
4794 , p_primary_uom => l_rcv_transaction_rec.primary_uom
4795 , p_transaction_uom => l_rcv_transaction_rec.transaction_uom
4796 , p_po_header_id => l_rcv_rcpt_rec.po_header_id
4797 , p_po_line_id => l_rcv_rcpt_rec.po_line_id
4798 , p_po_line_location_id => l_rcv_rcpt_rec.po_line_location_id
4799 , p_po_distribution_id => l_rcv_rcpt_rec.po_distribution_id
4800 , p_lpn_id => p_lpn_id
4801 , p_wms_flag => 'Y'
4802 , x_evaluation_result => l_evaluation_result
4803 , x_return_status => l_return_status
4804 , x_msg_count => l_msg_count
4805 , x_msg_data => l_msg_data
4806 );
4807
4808 IF l_return_status = fnd_api.g_ret_sts_error THEN
4809 IF (l_debug = 1) THEN
4810 print_debug('create_asn_con_rcpt_intf_rec 84.1: QA CALL RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4811 END IF;
4812 RAISE fnd_api.g_exc_error;
4813 END IF;
4814
4815 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
4816 IF (l_debug = 1) THEN
4817 print_debug('create_asn_con_rcpt_intf_rec 135.2: QA CALL RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4818 END IF;
4819 RAISE fnd_api.g_exc_unexpected_error;
4820 END IF;
4821
4822 -- If QA_SKIPLOT_RCV_GRP returns 'Standard', sets the routing id to 1.
4823 -- If QA_SKIPLOT_RCV_GRP returns 'Inspect', leaves the routing id as 2.
4824 IF l_evaluation_result = 'STANDARD' THEN
4825 l_rcv_rcpt_rec.inspection_required_flag := 'N';
4826 l_rcv_rcpt_rec.routing_id := 1;
4827 END IF;
4828
4829 EXCEPTION
4830 WHEN OTHERS THEN
4831 IF (l_debug = 1) THEN
4832 print_debug('create_asn_con_rcpt_intf_rec: 135.3 - Exception in calling QA_SKIPLOT_RCV_GRP.EVALUATE_LOT'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4833 END IF;
4834 RAISE fnd_api.g_exc_error;
4835 END;
4836
4837 END IF;
4838 END IF;
4839
4840 ELSE -- p_source_type is <> ASN
4841 l_rcv_rcpt_rec.inspection_required_flag := 'Y';
4842 l_rcv_rcpt_rec.routing_id := 2;
4843 END IF;
4844
4845 ELSE
4846 l_rcv_rcpt_rec.routing_id := 1;
4847 END IF;
4848
4849 --Bug #4147209 - Populate the record type with the DFF attribute category
4850 --and segment values passed from the mobile UI
4851 set_attribute_vals(
4852 p_rcv_rcpt_rec => l_rcv_rcpt_rec
4853 , p_attribute_category => p_attribute_category
4854 , p_attribute1 => p_attribute1
4855 , p_attribute2 => p_attribute2
4856 , p_attribute3 => p_attribute3
4857 , p_attribute4 => p_attribute4
4858 , p_attribute5 => p_attribute5
4859 , p_attribute6 => p_attribute6
4860 , p_attribute7 => p_attribute7
4861 , p_attribute8 => p_attribute8
4862 , p_attribute9 => p_attribute9
4863 , p_attribute10 => p_attribute10
4864 , p_attribute11 => p_attribute11
4865 , p_attribute12 => p_attribute12
4866 , p_attribute13 => p_attribute13
4867 , p_attribute14 => p_attribute14
4868 , p_attribute15 => p_attribute15);
4869
4870 l_interface_transaction_id := insert_txn_interface(
4871 l_rcv_transaction_rec
4872 , l_rcv_rcpt_rec
4873 , l_group_id
4874 , l_transaction_type
4875 , p_organization_id
4876 , p_location_id
4877 , p_source_type
4878 , l_rcv_rcpt_rec.routing_id
4879 , p_project_id
4880 , p_task_id
4881 , p_express_transaction
4882 );
4883 l_progress := '90';
4884
4885 IF (l_debug = 1) THEN
4886 print_debug('create_asn_con_rcpt_intf_rec: 110 after insert_txn_interface' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
4887 END IF;
4888
4889 IF (l_debug = 1) THEN
4890 print_debug('create_asn_con_rcpt_intf_rec 135.5: INV J and PO J are installed. No Move Order creation from UI', 4);
4891 END IF;
4892 /* Populate the table to store the information of the RTIs created*/
4893 l_new_rti_info(match_result_count).orig_interface_trx_id := p_original_rti_id;
4894 l_new_rti_info(match_result_count).new_interface_trx_id := l_interface_transaction_id;
4895 l_new_rti_info(match_result_count).quantity := l_rcv_transaction_rec.transaction_qty;
4896 END LOOP; --END LOOP through results returned by matching algorithm
4897
4898 --Call the split_lot API to split the lots and serials inserted from the UI
4899 --based on the quantity of each RTI record
4900
4901 --BUG 3326408,3346758,3405320
4902 --If there are any serials confirmed from the UI for an item that is
4903 --lot controlled and serial control dynamic at SO issue,
4904 --do not NULL out serial_transaction_temp_id. In other cases,
4905 --NULL OUT serial_temp_id so that split_lot_serial does not look at MSNI
4906 l_msni_count := 0;
4907 IF (l_rcv_rcpt_rec.lot_control_code = 2 AND
4908 l_rcv_rcpt_rec.serial_number_control_code IN (1,6)) THEN
4909 IF (l_debug = 1) THEN
4910 print_debug('create_asn_con_rcpt_intf_rec 135.6: serial_control_code IS 6, need TO NULL OUT mtli', 4);
4911 END IF;
4912
4913 BEGIN
4914 IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
4915 SELECT count(1)
4916 INTO l_msni_count
4917 FROM mtl_serial_numbers_interface
4918 WHERE product_transaction_id = p_original_rti_id
4919 AND product_code = 'RCV';
4920 END IF;
4921
4922 IF l_msni_count = 0 THEN
4923 UPDATE mtl_transaction_lots_interface
4924 SET serial_transaction_temp_id = NULL
4925 WHERE product_transaction_id = p_original_rti_id
4926 AND product_code = 'RCV';
4927 END IF;
4928 EXCEPTION
4929 WHEN OTHERS THEN
4930 IF (l_debug = 1) THEN
4931 print_debug('create_asn_con_rcpt_intf_rec 135.7: Error nulling serial temp id OF MTLI', 4);
4932 END IF;
4933 END ;
4934 END IF;--IF (l_rcv_rcpt_rec.serial_number_control_code = 6) THEN
4935
4936 l_split_lot_serial_ok := inv_rcv_integration_apis.split_lot_serial(
4937 p_api_version => 1.0
4938 , p_init_msg_lst => FND_API.G_FALSE
4939 , x_return_status => l_return_status
4940 , x_msg_count => l_msg_count
4941 , x_msg_data => x_message
4942 , p_new_rti_info => l_new_rti_info);
4943 IF ( NOT l_split_lot_serial_ok) THEN
4944 IF (l_debug = 1) THEN
4945 print_debug('create_asn_con_rcpt_intf_rec 95.1: Failure in split_lot_serial', 4);
4946 END IF;
4947 RAISE FND_API.G_EXC_ERROR;
4948 END IF;
4949
4950 IF (l_debug = 1) THEN
4951 print_debug('create_asn_con_rcpt_intf_rec 05.2: Call split_lot_serial is OK', 4);
4952 END IF;
4953
4954 IF l_curs_rcpt_detail%ISOPEN THEN
4955 CLOSE l_curs_rcpt_detail;
4956 END IF;
4957
4958 -- append index in input table where the line to be detailed needs to be inserted
4959 --g_receipt_detail_index := l_rcpt_match_table_detail.COUNT + g_receipt_detail_index;
4960
4961 l_progress := '110';
4962 -- clear the lot/qty data structure
4963 -- Called after Calling the INV_CR_ASN_DETAILS
4964 -- g_rcpt_lot_qty_rec_tb.DELETE;
4965
4966 l_progress := '120';
4967
4968 IF p_item_id IS NOT NULL THEN
4969 inv_rcv_common_apis.do_check(
4970 p_organization_id => p_organization_id
4971 , p_inventory_item_id => p_item_id
4972 , p_transaction_type_id => 18
4973 , p_primary_quantity => l_total_primary_qty
4974 , x_return_status => l_return_status
4975 , x_msg_count => l_msg_count
4976 , x_msg_data => x_message
4977 );
4978 END IF;
4979
4980 IF l_return_status <> fnd_api.g_ret_sts_success THEN
4981 x_status := l_return_status;
4982 END IF;
4983
4984 l_progress := '130';
4985
4986 -- Calling The ASN Discrepnacy Details
4987 IF (l_debug = 1) THEN
4988 print_debug('Before Calling ASN Ddetails ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
4989 END IF;
4990
4991 inv_cr_asn_details.create_asn_details(
4992 p_organization_id
4993 , l_group_id
4994 , l_rcv_rcpt_rec
4995 , l_rcv_transaction_rec
4996 , g_rcpt_lot_qty_rec_tb
4997 , l_interface_transaction_id
4998 , l_return_status
4999 , l_msg_data
5000 );
5001
5002 IF l_return_status <> fnd_api.g_ret_sts_success THEN
5003 x_status := l_return_status;
5004 END IF;
5005
5006 g_rcpt_lot_qty_rec_tb.DELETE;
5007
5008 IF (l_debug = 1) THEN
5009 print_debug('About exit create_asn_con_rcpt_intf_rec: 140' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5010 END IF;
5011 EXCEPTION
5012 WHEN fnd_api.g_exc_error THEN
5013 ROLLBACK TO crt_asn_con_rti_sp;
5014 x_status := fnd_api.g_ret_sts_error;
5015
5016 IF l_curs_rcpt_detail%ISOPEN THEN
5017 CLOSE l_curs_rcpt_detail;
5018 END IF;
5019
5020 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5021
5022 IF (l_debug = 1) THEN
5023 print_debug('create_asn_con_rcpt_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5024 END IF;
5025 WHEN fnd_api.g_exc_unexpected_error THEN
5026 ROLLBACK TO crt_asn_con_rti_sp;
5027 x_status := fnd_api.g_ret_sts_unexp_error;
5028
5029 IF l_curs_rcpt_detail%ISOPEN THEN
5030 CLOSE l_curs_rcpt_detail;
5031 END IF;
5032
5033 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5034
5035 IF (l_debug = 1) THEN
5036 print_debug('create_asn_con_rcpt_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5037 END IF;
5038 WHEN OTHERS THEN
5039 ROLLBACK TO crt_asn_con_rti_sp;
5040 x_status := fnd_api.g_ret_sts_unexp_error;
5041
5042 IF l_curs_rcpt_detail%ISOPEN THEN
5043 CLOSE l_curs_rcpt_detail;
5044 END IF;
5045
5046 IF SQLCODE IS NOT NULL THEN
5047 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_con_rcpt_intf_rec', l_progress, SQLCODE);
5048 END IF;
5049
5050 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => l_msg_count, p_data => x_message);
5051
5052 IF (l_debug = 1) THEN
5053 print_debug(
5054 'create_asn_con_rcpt_intf_rec: Other exception - l_progress = '
5055 || l_progress
5056 || ' '
5057 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5058 , 1
5059 );
5060 END IF;
5061 END create_asn_con_rcpt_intf_rec;
5062
5063 PROCEDURE create_asn_exp_rcpt_intf_rec(
5064 p_move_order_header_id IN OUT NOCOPY NUMBER
5065 , p_organization_id IN NUMBER
5066 , p_shipment_header_id IN NUMBER
5067 , p_po_header_id IN NUMBER
5068 , p_location_id IN NUMBER
5069 , p_source_type IN VARCHAR2
5070 , p_lpn_id IN NUMBER
5071 , p_inspect IN NUMBER
5072 , x_status OUT NOCOPY VARCHAR2
5073 , x_message OUT NOCOPY VARCHAR2
5074 , p_project_id IN NUMBER DEFAULT NULL
5075 , p_task_id IN NUMBER DEFAULT NULL
5076 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL
5077 , p_rcv_locator_id IN NUMBER DEFAULT NULL
5078 , p_original_rti_id IN NUMBER DEFAULT NULL
5079 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
5080 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
5081 , p_attribute1 IN VARCHAR2 DEFAULT NULL
5082 , p_attribute2 IN VARCHAR2 DEFAULT NULL
5083 , p_attribute3 IN VARCHAR2 DEFAULT NULL
5084 , p_attribute4 IN VARCHAR2 DEFAULT NULL
5085 , p_attribute5 IN VARCHAR2 DEFAULT NULL
5086 , p_attribute6 IN VARCHAR2 DEFAULT NULL
5087 , p_attribute7 IN VARCHAR2 DEFAULT NULL
5088 , p_attribute8 IN VARCHAR2 DEFAULT NULL
5089 , p_attribute9 IN VARCHAR2 DEFAULT NULL
5090 , p_attribute10 IN VARCHAR2 DEFAULT NULL
5091 , p_attribute11 IN VARCHAR2 DEFAULT NULL
5092 , p_attribute12 IN VARCHAR2 DEFAULT NULL
5093 , p_attribute13 IN VARCHAR2 DEFAULT NULL
5094 , p_attribute14 IN VARCHAR2 DEFAULT NULL
5095 , p_attribute15 IN VARCHAR2 DEFAULT NULL
5096 ) IS
5097 -- get unit_of_measure in a later query because of some
5098 -- SQL problem, ???
5099
5100 /* FP-J Lot/Serial Support Enhancement
5101 * Fetch the item's serial control code and item's primary uom code
5102 */
5103 CURSOR l_curs_asn_lpn_content IS
5104 SELECT lpn.lpn_id
5105 , lpnc.inventory_item_id
5106 , lpnc.revision
5107 , lpnc.quantity
5108 , lpnc.uom_code
5109 , msi.lot_control_code
5110 , ''
5111 , --uom.unit_of_measure,
5112 p_po_header_id
5113 , lpnc.lot_number
5114 , lpn.organization_id
5115 , msi.serial_number_control_code
5116 , msi.primary_uom_code
5117 , lpnc.secondary_quantity -- Bug 7708998
5118 FROM wms_lpn_contents lpnc, wms_license_plate_numbers lpn, mtl_system_items_b msi, rcv_shipment_headers rsh
5119 WHERE rsh.shipment_header_id = p_shipment_header_id
5120 AND((lpn.source_header_id = rsh.shipment_header_id)
5121 OR (lpn.source_header_id IS NULL AND lpn.source_name = rsh.shipment_num)) --BUG14846625/16711363
5122 AND lpn.lpn_context IN(6, 7) -- only those pre-ASN receiving ones
5123 -- Nested LPN changes to explode the LPN
5124 -- AND wlpnc.parent_lpn_id = Nvl(p_lpn_id, wlpn.lpn_id)
5125 -- In case user tries to to ASN reciept by giving only PO Number
5126 -- LPN id will be NULL, In this case we should not expand the LPN
5127 -- in which case start with lpn_id = p_lpn_id will fail.
5128 AND(lpn.lpn_id = NVL(p_lpn_id, lpn.lpn_id)
5129 OR lpn.lpn_id IN(SELECT lpn_id
5130 FROM wms_license_plate_numbers
5131 START WITH lpn_id = p_lpn_id
5132 CONNECT BY parent_lpn_id = PRIOR lpn_id))
5133 --AND lpn.lpn_id = nvl(p_lpn_id, lpn.lpn_id)
5134 AND lpn.lpn_id = lpnc.parent_lpn_id
5135 AND lpnc.inventory_item_id = msi.inventory_item_id
5136 AND msi.organization_id = p_organization_id
5137 AND(
5138 lpnc.source_line_id IN(SELECT pola.po_line_id
5139 FROM po_lines_all pola
5140 WHERE pola.po_header_id = NVL(p_po_header_id, pola.po_header_id))
5141 OR lpnc.source_line_id IS NULL
5142 );
5143
5144 /* FP-J Lot/Serial Support Enhancement
5145 * Cursor to create MSNI records for serials in the LPN
5146 */
5147 CURSOR l_curs_serial_number(v_inventory_item_id NUMBER, v_revision VARCHAR2
5148 , v_lot_number VARCHAR2, v_lpn_id NUMBER) IS
5149 SELECT serial_number,
5150 status_id
5151 FROM mtl_serial_numbers
5152 WHERE inventory_item_id = v_inventory_item_id
5153 AND(revision = v_revision
5154 OR(revision IS NULL
5155 AND v_revision IS NULL))
5156 AND(lot_number = v_lot_number
5157 OR(lot_number IS NULL
5158 AND v_lot_number IS NULL))
5159 AND lpn_id = v_lpn_id;
5160
5161 l_lpn_id NUMBER;
5162 l_inventory_item_id NUMBER;
5163 l_revision VARCHAR2(30);
5164 l_quantity NUMBER;
5165 l_uom_code VARCHAR2(3);
5166 l_lot_control_code NUMBER;
5167 l_unit_of_measure VARCHAR2(25);
5168 l_po_header_id NUMBER;
5169 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
5170 l_lot_number VARCHAR2(80);
5171 l_lpn_org NUMBER;
5172 l_expiration_date DATE;
5173 l_object_id NUMBER;
5174 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
5175 l_msg_count NUMBER;
5176 l_msg_data VARCHAR2(4000);
5177 l_progress VARCHAR2(10);
5178 l_label_status VARCHAR2(500);
5179 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5180
5181 l_serial_control_code NUMBER;
5182 l_transaction_interface_id NUMBER;
5183 l_product_transaction_id NUMBER;
5184 l_serial_transaction_temp_id NUMBER;
5185 l_serial_number mtl_serial_numbers.serial_number%type;
5186 l_primary_uom_code mtl_system_items.primary_uom_code%TYPE;
5187 l_lot_prm_quantity NUMBER; --lot quantity in primary uom
5188 l_lot_status_id NUMBER;
5189 l_serial_status_id NUMBER;
5190 l_from_org_id NUMBER;
5191
5192 l_secondary_quantity NUMBER; --Bug 7708998
5193 l_msni_count NUMBER; --Bug 10288330
5194
5195 BEGIN
5196 IF (l_debug = 1) THEN
5197 print_debug('create_asn_exp_rcpt_intf_rec: 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5198 print_debug('p_move_order_header_id = ' || p_move_order_header_id, 4);
5199 print_debug('p_organization_id = ' || p_organization_id, 4);
5200 print_debug('p_shipment_header_id = ' || p_shipment_header_id, 4);
5201 print_debug('p_po_header_id = ' || p_po_header_id, 4);
5202 print_debug('p_location_id = ' || p_location_id, 4);
5203 print_debug('p_source_type = ' || p_source_type, 4);
5204 print_debug('p_lpn_id = ' || p_lpn_id, 4);
5205 print_debug('p_inspect = ' || p_inspect, 4);
5206 END IF;
5207
5208 --bug 10288330
5209 SAVEPOINT create_asn_exp_rcpt_intf_rec;
5210
5211 x_status := fnd_api.g_ret_sts_success;
5212 l_progress := '10';
5213 OPEN l_curs_asn_lpn_content;
5214 l_progress := '20';
5215
5216 LOOP
5217 FETCH l_curs_asn_lpn_content INTO
5218 l_lpn_id
5219 , l_inventory_item_id
5220 , l_revision
5221 , l_quantity
5222 , l_uom_code
5223 , l_lot_control_code
5224 , l_unit_of_measure
5225 , l_po_header_id
5226 , l_lot_number
5227 , l_lpn_org
5228 , l_serial_control_code
5229 , l_primary_uom_code
5230 , l_secondary_quantity; --Bug 7708998
5231 EXIT WHEN l_curs_asn_lpn_content%NOTFOUND;
5232 l_progress := '30';
5233
5234 --Reset the variables that store interface Ids
5235 l_transaction_interface_id := NULL;
5236 l_serial_transaction_temp_id := NULL;
5237 l_product_transaction_id := NULL;
5238
5239 IF (p_source_type = 'INTERNAL'
5240 AND l_lot_control_code = 2) THEN
5241 BEGIN
5242 SELECT expiration_date
5243 INTO l_expiration_date
5244 FROM mtl_lot_numbers
5245 WHERE inventory_item_id = l_inventory_item_id
5246 AND organization_id = l_lpn_org
5247 AND lot_number = l_lot_number;
5248 EXCEPTION
5249 WHEN OTHERS THEN
5250 l_expiration_date := NULL;
5251 END;
5252
5253 inv_rcv_common_apis.insert_dynamic_lot(
5254 p_api_version => 1.0
5255 , --p_init_msg_list => p_init_msg_list,
5256 --p_commit => p_commit,
5257 --p_validation_level => p_validation_level,
5258 p_inventory_item_id => l_inventory_item_id
5259 , p_organization_id => p_organization_id
5260 , p_lot_number => l_lot_number
5261 , p_expiration_date => l_expiration_date
5262 , --p_transaction_temp_id => p_transaction_temp_id,
5263 --p_transaction_action_id => p_transaction_action_id,
5264 p_transfer_organization_id => l_lpn_org, --uncommenting and setting the transfer_org_id to l_lpn_org_id to
5265 --populate lot attributes bug3368089
5266 p_status_id => ''
5267 , p_update_status => 'FALSE'
5268 , x_object_id => l_object_id
5269 , x_return_status => l_return_status
5270 , x_msg_count => l_msg_count
5271 , x_msg_data => l_msg_data
5272 );
5273
5274 IF l_return_status = fnd_api.g_ret_sts_error THEN
5275 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
5276 fnd_msg_pub.ADD;
5277
5278 IF (l_debug = 1) THEN
5279 print_debug(
5280 'create_asn_exp_rcpt_intf_rec 30.1:create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
5281 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5282 , 4
5283 );
5284 END IF;
5285 RAISE fnd_api.g_exc_error;
5286 END IF;
5287
5288 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5289 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
5290 fnd_msg_pub.ADD;
5291
5292 IF (l_debug = 1) THEN
5293 print_debug(
5294 'create_asn_exp_rcpt_intf_rec 30.2: create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5295 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5296 , 4
5297 );
5298 END IF;
5299
5300 RAISE fnd_api.g_exc_unexpected_error;
5301 END IF;
5302 END IF;
5303
5304 l_progress := '33';
5305
5306 -- should we be updating the org for the lpn here instead of in the lpnexit??????
5307 l_progress := '35';
5308
5309 SELECT unit_of_measure
5310 INTO l_unit_of_measure
5311 FROM mtl_item_uoms_view
5312 WHERE uom_code = l_uom_code
5313 AND organization_id = p_organization_id
5314 AND inventory_item_id = l_inventory_item_id;
5315
5316 l_progress := '40';
5317
5318 IF (l_debug = 1) THEN
5319 print_debug('create_asn_exp_rcpt_intf_rec: 20.1 before populate_lot_rec : ', 4);
5320 print_debug('l_lot_number => ' || l_lot_number, 4);
5321 print_debug('l_quantity => ' || l_quantity, 4);
5322 print_debug('l_uom_code => ' || l_uom_code, 4);
5323 print_debug('p_organization_id => ' || p_organization_id, 4);
5324 print_debug('l_inventory_item_id => ' || l_inventory_item_id, 4);
5325 END IF;
5326
5327 populate_lot_rec(
5328 p_lot_number => l_lot_number
5329 , p_primary_qty => l_quantity
5330 , p_txn_uom_code => l_uom_code
5331 , p_org_id => p_organization_id
5332 , p_item_id => l_inventory_item_id
5333 );
5334 l_progress := '50';
5335
5336 --Create the MTLI and MSNI records for the lots and serials in the LPN
5337 IF l_lot_control_code > 1 THEN
5338 IF l_lot_number IS NOT NULL THEN
5339 --Convert the lot quantity into Item's Primary UOM code
5340 IF l_uom_code <> l_primary_uom_code THEN
5341 l_lot_prm_quantity := inv_rcv_cache.convert_qty
5342 (p_inventory_item_id => l_inventory_item_id
5343 ,p_from_qty => l_quantity
5344 ,p_from_uom_code => l_uom_code
5345 ,p_to_uom_code => l_primary_uom_code);
5346
5347 --Check for failure
5348 IF l_lot_prm_quantity = -99999 THEN
5349 fnd_message.set_name('INV', 'INV_INT_UOMCONVCODE');
5350 fnd_msg_pub.ADD;
5351 IF (l_debug = 1) THEN
5352 print_debug('create_asn_exp_rcpt_intf_rec: 20.2 - txn/primary uom conversion failed', 4);
5353 END IF;
5354 RAISE fnd_api.g_exc_error;
5355 END IF; --END IF check for failure
5356
5357 ELSE
5358 l_lot_prm_quantity := l_quantity;
5359 END IF;
5360
5361 --Get the lot expiration date
5362 SELECT expiration_date
5363 , status_id
5364 INTO l_expiration_date
5365 , l_lot_status_id
5366 FROM mtl_lot_numbers
5367 WHERE inventory_item_id = l_inventory_item_id
5368 AND organization_id = l_lpn_org
5369 AND lot_number = l_lot_number;
5370
5371 IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
5372 l_from_org_id := l_lpn_org;
5373 ELSE
5374 l_from_org_id := p_organization_id;
5375 END IF;
5376
5377 --Create MTLI record for the lot and the lot quantity for this content
5378 --Set the flag for the API to populate the lot attributes
5379 inv_rcv_integration_apis.insert_mtli(
5380 p_api_version => 1.0
5381 , p_init_msg_lst => FND_API.G_FALSE
5382 , x_return_status => l_return_status
5383 , x_msg_count => l_msg_count
5384 , x_msg_data => l_msg_data
5385 , p_transaction_interface_id => l_transaction_interface_id
5386 , p_lot_number => l_lot_number
5387 , p_transaction_quantity => l_quantity
5388 , p_primary_quantity => l_lot_prm_quantity
5389 , p_secondary_quantity => l_secondary_quantity --Bug 7708998
5390 , p_organization_id => l_from_org_id
5391 , p_inventory_item_id => l_inventory_item_id
5392 , p_expiration_date => l_expiration_date
5393 , p_status_id => l_lot_status_id
5394 , x_serial_transaction_temp_id => l_serial_transaction_temp_id
5395 , p_product_transaction_id => l_product_transaction_id
5396 , p_product_code => 'RCV'
5397 , p_att_exist => 'Y'
5398 , p_update_mln => 'N'
5399 );
5400
5401 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5402 IF (l_debug = 1) THEN
5403 print_debug('create_asn_exp_rcpt_intf_rec 20.3: Error in MTLI creation', 4);
5404 END IF;
5405 RAISE FND_API.G_EXC_ERROR;
5406 END IF;
5407
5408 IF (l_debug = 1) THEN
5409 print_debug('create_asn_exp_rcpt_intf_rec 20.4 : txn i/f id: ' || l_transaction_interface_id
5410 || ' serial temp : ' || l_serial_transaction_temp_id || ' prod txn id: ' || l_product_transaction_id, 4);
5411 END IF;
5412 END IF; --END IF l_lot_number IS NOT NULL
5413
5414 --Create MSNI records for the serials within lots
5415 --Bug #3405320
5416 --Create MSNI records even if serial control code is dynamic at SO Issue in
5417 --receiving org if there are serials shipped
5418 IF ((l_serial_control_code IN (2, 5)) OR
5419 (l_serial_control_code = 6 AND p_source_type = 'INTERNAL')) THEN
5420 -- bug 3196554
5421 OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
5422 --Loop through the serials in the lot
5423 LOOP
5424 FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
5425 EXIT WHEN l_curs_serial_number%NOTFOUND;
5426 --For each serial number in the lot create one MSNI record. The
5427 --serial attributes would be populated by the API
5428 IF (l_debug = 1) THEN
5429 print_debug('create_asn_exp_rcpt_intf_rec 20.4.1: Before MSNI creation', 4);
5430 END IF;
5431 inv_rcv_integration_apis.insert_msni(
5432 p_api_version => 1.0
5433 , p_init_msg_lst => FND_API.G_FALSE
5434 , x_return_status => l_return_status
5435 , x_msg_count => l_msg_count
5436 , x_msg_data => l_msg_data
5437 , p_transaction_interface_id => l_serial_transaction_temp_id
5438 , p_fm_serial_number => l_serial_number
5439 , p_to_serial_number => l_serial_number
5440 , p_organization_id => p_organization_id
5441 , p_inventory_item_id => l_inventory_item_id
5442 , p_status_id => l_serial_status_id
5443 , p_product_transaction_id => l_product_transaction_id
5444 , p_product_code => 'RCV'
5445 , p_att_exist => 'Y'
5446 , p_update_msn => 'N'
5447 );
5448
5449 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5450 IF (l_debug = 1) THEN
5451 print_debug('create_asn_exp_rcpt_intf_rec 20.5: Error in MSNI creation', 4);
5452 END IF;
5453 RAISE FND_API.G_EXC_ERROR;
5454 END IF;
5455 END LOOP; --END LOOP through serials for the lot
5456
5457 --Close the serial cursor
5458 IF l_curs_serial_number%ISOPEN THEN
5459 CLOSE l_curs_serial_number;
5460 END IF;
5461 END IF; --END IF item is lot and serial controlled
5462
5463 --If the item is serial controlled, loop through the serials within
5464 --the LPN and create one MSNI record for each serial number
5465 --The attributes for each serial number would be fetched by the API
5466 ELSIF (l_serial_control_code IN (2, 5) OR
5467 (l_serial_control_code = 6 AND p_source_type = 'INTERNAL')) THEN
5468 -- bug 3196554
5469 OPEN l_curs_serial_number(l_inventory_item_id, l_revision, l_lot_number, l_lpn_id);
5470 --Loop through the serials in the lot
5471 LOOP
5472 FETCH l_curs_serial_number INTO l_serial_number, l_serial_status_id;
5473 EXIT WHEN l_curs_serial_number%NOTFOUND;
5474 --For each serial number in the lot create one MSNI record. The
5475 --serial attributes would be populated by the API
5476 IF (l_debug = 1) THEN
5477 print_debug('create_asn_exp_rcpt_intf_rec 20.5.1: Before MSNI creation', 4);
5478 END IF;
5479 inv_rcv_integration_apis.insert_msni(
5480 p_api_version => 1.0
5481 , p_init_msg_lst => FND_API.G_FALSE
5482 , x_return_status => l_return_status
5483 , x_msg_count => l_msg_count
5484 , x_msg_data => l_msg_data
5485 , p_transaction_interface_id => l_transaction_interface_id
5486 , p_fm_serial_number => l_serial_number
5487 , p_to_serial_number => l_serial_number
5488 , p_organization_id => p_organization_id
5489 , p_inventory_item_id => l_inventory_item_id
5490 , p_status_id => l_serial_status_id
5491 , p_product_transaction_id => l_product_transaction_id
5492 , p_product_code => 'RCV'
5493 , p_att_exist => 'Y'
5494 , p_update_msn => 'N'
5495 );
5496
5497 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5498 IF (l_debug = 1) THEN
5499 print_debug('create_asn_exp_rcpt_intf_rec 20.6: Error in MSNI creation', 4);
5500 END IF;
5501 RAISE FND_API.G_EXC_ERROR;
5502 END IF;
5503 IF (l_debug = 1) THEN
5504 print_debug('create_asn_exp_rcpt_intf_rec 20.7 : txn i/f id: ' || l_transaction_interface_id || ' prod txn id: ' || l_product_transaction_id, 4);
5505 END IF;
5506 END LOOP; --END LOOP through serials for the lot
5507
5508 --Close the serial cursor
5509 IF l_curs_serial_number%ISOPEN THEN
5510 CLOSE l_curs_serial_number;
5511 END IF;
5512 END IF; --END IF check lot and serial control codes
5513
5514 IF (l_debug = 1) THEN
5515 print_debug('create_asn_exp_rcpt_intf_rec: 30 before create_asn_con_rcpt_intf_rec'
5516 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5517 , 4);
5518 END IF;
5519
5520 IF (l_debug = 1) THEN
5521 print_debug('before create_asn_con_rcpt_intf_rec: l_product_transaction_id: ' || l_product_transaction_id, 4);
5522 END IF;
5523
5524 create_asn_con_rcpt_intf_rec(
5525 p_move_order_header_id => p_move_order_header_id
5526 , p_organization_id => p_organization_id
5527 , p_shipment_header_id => p_shipment_header_id
5528 , p_po_header_id => l_po_header_id
5529 , p_item_id => l_inventory_item_id
5530 , p_location_id => p_location_id
5531 , p_rcv_qty => l_quantity
5532 , p_rcv_uom => l_unit_of_measure
5533 , p_rcv_uom_code => l_uom_code
5534 , p_source_type => p_source_type
5535 , p_from_lpn_id => l_lpn_id
5536 , p_lpn_id => l_lpn_id
5537 , p_lot_control_code => l_lot_control_code
5538 , p_revision => l_revision
5539 , p_inspect => p_inspect
5540 , x_status => l_return_status
5541 , x_message => l_msg_data
5542 , p_item_desc => NULL
5543 , p_project_id => p_project_id
5544 , p_task_id => p_task_id
5545 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
5546 , p_rcv_locator_id => p_rcv_locator_id
5547 , p_original_rti_id => l_product_transaction_id
5548 , p_attribute_category => p_attribute_category --Bug #4147209
5549 , p_attribute1 => p_attribute1
5550 , p_attribute2 => p_attribute2
5551 , p_attribute3 => p_attribute3
5552 , p_attribute4 => p_attribute4
5553 , p_attribute5 => p_attribute5
5554 , p_attribute6 => p_attribute6
5555 , p_attribute7 => p_attribute7
5556 , p_attribute8 => p_attribute8
5557 , p_attribute9 => p_attribute9
5558 , p_attribute10 => p_attribute10
5559 , p_attribute11 => p_attribute11
5560 , p_attribute12 => p_attribute12
5561 , p_attribute13 => p_attribute13
5562 , p_attribute14 => p_attribute14
5563 , p_attribute15 => p_attribute15
5564 , p_express_transaction => 'Y'
5565 );
5566
5567 IF (l_debug = 1) THEN
5568 print_debug('after create_asn_con_rcpt_intf_rec: l_product_transaction_id: ' || l_product_transaction_id, 4);
5569 END IF;
5570
5571 IF l_return_status = fnd_api.g_ret_sts_error THEN
5572 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
5573 fnd_msg_pub.ADD;
5574
5575 IF (l_debug = 1) THEN
5576 print_debug(
5577 'create_asn_exp_rcpt_intf_rec 40.1:create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
5578 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5579 , 4
5580 );
5581 END IF;
5582
5583 RAISE fnd_api.g_exc_error;
5584 END IF;
5585
5586 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5587 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
5588 fnd_msg_pub.ADD;
5589
5590 IF (l_debug = 1) THEN
5591 print_debug(
5592 'create_asn_exp_rcpt_intf_rec 40.2: create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5593 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5594 , 4
5595 );
5596 END IF;
5597
5598 RAISE fnd_api.g_exc_unexpected_error;
5599 END IF;
5600
5601 IF (l_debug = 1) THEN
5602 print_debug('create_asn_exp_rcpt_intf_rec: 50 after create_asn_con_rcpt_intf_rec'
5603 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5604 , 4);
5605 END IF;
5606
5607 /*bug 10288330 start*/
5608 /* For ASN express receipt, if there is a mismatch between MSNI and RTI in terms of serial number quantity, error out.
5609 Keeping the validation inside the LPN loop, so that it can be done per LPN basis; that way we can also handle the scenario
5610 where multiple LPNs exists in an ASN and not all LPNs are problematic.
5611 Moreover, the call insert_msni (see above) inserts 1 record per serial number. This will be the underlying assumption of
5612 following validation.
5613 */
5614 l_msni_count := 0;
5615 IF (l_debug = 1) THEN
5616 print_debug('create_asn_exp_rcpt_intf_rec: 60 Validate RTI-MSNI mismatch for serial numbers', 4);
5617 END IF;
5618 IF ((l_serial_control_code IN (2, 5)) AND p_source_type = 'ASN') THEN
5619 IF (l_debug = 1) THEN
5620 print_debug('create_asn_exp_rcpt_intf_rec: 61 Item is serial controlled', 4);
5621 END IF;
5622
5623 select count(1) into
5624 l_msni_count
5625 from mtl_serial_numbers_interface msni, rcv_transactions_interface rti,
5626 wms_license_plate_numbers lpn, rcv_shipment_headers rsh,
5627 mtl_serial_numbers msn -- Bug 16517269
5628 where rti.interface_transaction_id = msni.product_transaction_id
5629 and rsh.shipment_header_id = p_shipment_header_id
5630 and (lpn.source_header_id = rsh.shipment_header_id
5631 or lpn.source_name = rsh.shipment_num)
5632 and lpn.lpn_id = l_lpn_id
5633 and rti.lpn_id = l_lpn_id
5634 and msn.lpn_id = l_lpn_id -- Bug 16517269
5635 and rti.item_id = l_inventory_item_id
5636 and msn.inventory_item_id = l_inventory_item_id -- Bug 16517269
5637 and nvl (msn.revision,'@@@') = nvl (l_revision,'@@@') -- Bug 16517269
5638 and nvl (rti.item_revision,'@@@') = nvl (l_revision,'@@@')
5639 and nvl (msn.lot_number, '@@@') = nvl (l_lot_number, '@@@') -- Bug 16517269
5640 and msn.serial_number = msni.fm_serial_number -- Bug 16517269
5641 and msni.product_code = 'RCV'
5642 and rti.processing_status_code <> 'ERROR'
5643 and rti.transaction_status_code <> 'ERROR';
5644
5645 IF (l_debug = 1) THEN
5646 print_debug('create_asn_exp_rcpt_intf_rec: No of MSNIs found: ' || l_msni_count, 4);
5647 print_debug('create_asn_exp_rcpt_intf_rec: l_quantity : ' || l_quantity , 4); -- Bug 16517269
5648 END IF;
5649
5650 IF l_msni_count <> l_quantity THEN
5651 IF (l_debug = 1) THEN
5652 print_debug('create_asn_exp_rcpt_intf_rec: 62 quantity mismatch for serial numbers between RTI and MSNI', 4);
5653 END IF;
5654 --fnd_message.clear;
5655 --fnd_message.retrieve(l_fnd_msg_out);
5656 fnd_message.set_name('WMS', 'WMS_MISSING_SERIALS_EXP_RCPT');
5657 fnd_msg_pub.ADD;
5658
5659 IF (l_debug = 1) THEN
5660 print_debug(
5661 'create_asn_exp_rcpt_intf_rec: 63 : RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
5662 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5663 , 4
5664 );
5665 END IF;
5666
5667 ROLLBACK to create_asn_exp_rcpt_intf_rec;
5668 RAISE fnd_api.g_exc_unexpected_error;
5669 END IF;
5670 END IF;
5671 /*bug 10288330 end*/
5672
5673 END LOOP; --END LOOP fetch LPN contents
5674
5675 -- insert WLPNI for FromLPN with parent as NULL.
5676 IF (l_debug = 1) THEN
5677 print_debug(
5678 'create_asn_exp_dd_intf_rec: 50.1 - Before inserting into wlpni for p_lpn_id with parent NULL '
5679 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5680 , 4
5681 );
5682 END IF;
5683
5684 IF ((p_source_type = 'INTERNAL') AND (l_lpn_org <> p_organization_id)) THEN
5685 l_from_org_id := l_lpn_org;
5686 ELSE
5687 l_from_org_id := p_organization_id;
5688 END IF;
5689
5690 -- Nested LPN changes. Insert WLPNI
5691 inv_rcv_integration_apis.insert_wlpni(
5692 p_api_version => 1.0
5693 ,x_return_status => l_return_status
5694 ,x_msg_count => l_msg_count
5695 ,x_msg_data => l_msg_data
5696 ,p_organization_id => l_from_org_id --BUG 4096028: Should use from org_id
5697 ,p_lpn_id => p_lpn_id
5698 ,p_license_plate_number => NULL
5699 ,p_lpn_group_id => inv_rcv_common_apis.g_rcv_global_var.interface_group_id
5700 ,p_parent_lpn_id => NULL
5701 );
5702
5703 IF l_return_status = fnd_api.g_ret_sts_error THEN
5704 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL');
5705 fnd_msg_pub.ADD;
5706
5707 IF (l_debug = 1) THEN
5708 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);
5709 END IF;
5710
5711 RAISE fnd_api.g_exc_error;
5712 END IF;
5713
5714 IF (l_debug = 1) THEN
5715 print_debug(
5716 'create_asn_exp_dd_intf_rec: 50.3 - After inserting into wlpni for p_lpn_id with parent NULL '
5717 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5718 , 4
5719 );
5720 END IF;
5721
5722 l_progress := '60';
5723
5724 IF l_curs_asn_lpn_content%ISOPEN THEN
5725 CLOSE l_curs_asn_lpn_content;
5726 END IF;
5727
5728 l_progress := '70';
5729
5730 IF (l_debug = 1) THEN
5731 print_debug('Exit create_asn_exp_rcpt_intf_rec: 70 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
5732 END IF;
5733 EXCEPTION
5734 WHEN fnd_api.g_exc_error THEN
5735 x_status := fnd_api.g_ret_sts_error;
5736
5737 IF l_curs_asn_lpn_content%ISOPEN THEN
5738 CLOSE l_curs_asn_lpn_content;
5739 END IF;
5740
5741 IF l_curs_serial_number%ISOPEN THEN
5742 CLOSE l_curs_serial_number;
5743 END IF;
5744
5745 fnd_msg_pub.count_and_get(
5746 p_encoded => fnd_api.g_false
5747 , p_count => l_msg_count
5748 , p_data => x_message);
5749
5750 IF (l_debug = 1) THEN
5751 print_debug('create_asn_exp_rcpt_intf_rec: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5752 END IF;
5753 WHEN fnd_api.g_exc_unexpected_error THEN
5754 x_status := fnd_api.g_ret_sts_unexp_error;
5755
5756 IF l_curs_asn_lpn_content%ISOPEN THEN
5757 CLOSE l_curs_asn_lpn_content;
5758 END IF;
5759
5760 IF l_curs_serial_number%ISOPEN THEN
5761 CLOSE l_curs_serial_number;
5762 END IF;
5763
5764 fnd_msg_pub.count_and_get(
5765 p_encoded => fnd_api.g_false
5766 , p_count => l_msg_count
5767 , p_data => x_message);
5768
5769 IF (l_debug = 1) THEN
5770 print_debug('create_asn_exp_rcpt_intf_rec: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5771 END IF;
5772 WHEN OTHERS THEN
5773 x_status := fnd_api.g_ret_sts_unexp_error;
5774
5775 IF l_curs_asn_lpn_content%ISOPEN THEN
5776 CLOSE l_curs_asn_lpn_content;
5777 END IF;
5778
5779 IF l_curs_serial_number%ISOPEN THEN
5780 CLOSE l_curs_serial_number;
5781 END IF;
5782
5783 IF SQLCODE IS NOT NULL THEN
5784 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_asn_exp_rcpt_intf_rec', l_progress, SQLCODE);
5785 END IF;
5786
5787 fnd_msg_pub.count_and_get(
5788 p_encoded => fnd_api.g_false
5789 , p_count => l_msg_count
5790 , p_data => x_message);
5791
5792 IF (l_debug = 1) THEN
5793 print_debug('create_asn_exp_rcpt_intf_rec: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5794 END IF;
5795 END create_asn_exp_rcpt_intf_rec;
5796
5797 /* FP-J Lot/Serial Support
5798 * Added a new parameter p_original_rti_id to store the product_transaction_id
5799 * passed from the UI to split the lots and serials based on RTI quantity
5800 */
5801 PROCEDURE create_std_rcpt_intf_rec(
5802 p_move_order_header_id IN OUT NOCOPY NUMBER
5803 , p_organization_id IN NUMBER
5804 , p_po_header_id IN NUMBER
5805 , p_po_release_number_id IN NUMBER
5806 , p_po_line_id IN NUMBER
5807 , p_shipment_header_id IN NUMBER
5808 , p_req_header_id IN NUMBER
5809 , p_oe_order_header_id IN NUMBER
5810 , p_item_id IN NUMBER
5811 , p_location_id IN NUMBER
5812 , p_rcv_qty IN NUMBER
5813 , p_rcv_uom IN VARCHAR2
5814 , p_rcv_uom_code IN VARCHAR2
5815 , p_source_type IN VARCHAR2
5816 , p_from_lpn_id IN NUMBER
5817 , p_lpn_id IN NUMBER
5818 , p_lot_control_code IN NUMBER
5819 , p_revision IN VARCHAR2
5820 , p_inspect IN NUMBER
5821 , x_status OUT NOCOPY VARCHAR2
5822 , x_message OUT NOCOPY VARCHAR2
5823 , p_inv_item_id IN NUMBER DEFAULT NULL
5824 , p_item_desc IN VARCHAR2 DEFAULT NULL
5825 , p_project_id IN NUMBER DEFAULT NULL
5826 , p_task_id IN NUMBER DEFAULT NULL
5827 , p_country_code IN VARCHAR2 DEFAULT NULL
5828 , p_rcv_subinventory_code IN VARCHAR2 DEFAULT NULL --RCVLOCATORSSUPPORT
5829 , p_rcv_locator_id IN NUMBER DEFAULT NULL
5830 , p_original_rti_id IN NUMBER DEFAULT NULL
5831 --OPM convergence
5832 , p_secondary_uom IN VARCHAR2 DEFAULT NULL
5833 , p_secondary_uom_code IN VARCHAR2 DEFAULT NULL
5834 , p_secondary_quantity IN NUMBER DEFAULT NULL
5835 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
5836 , p_attribute1 IN VARCHAR2 DEFAULT NULL
5837 , p_attribute2 IN VARCHAR2 DEFAULT NULL
5838 , p_attribute3 IN VARCHAR2 DEFAULT NULL
5839 , p_attribute4 IN VARCHAR2 DEFAULT NULL
5840 , p_attribute5 IN VARCHAR2 DEFAULT NULL
5841 , p_attribute6 IN VARCHAR2 DEFAULT NULL
5842 , p_attribute7 IN VARCHAR2 DEFAULT NULL
5843 , p_attribute8 IN VARCHAR2 DEFAULT NULL
5844 , p_attribute9 IN VARCHAR2 DEFAULT NULL
5845 , p_attribute10 IN VARCHAR2 DEFAULT NULL
5846 , p_attribute11 IN VARCHAR2 DEFAULT NULL
5847 , p_attribute12 IN VARCHAR2 DEFAULT NULL
5848 , p_attribute13 IN VARCHAR2 DEFAULT NULL
5849 , p_attribute14 IN VARCHAR2 DEFAULT NULL
5850 , p_attribute15 IN VARCHAR2 DEFAULT NULL
5851 ) IS
5852 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
5853 l_msg_count NUMBER;
5854 l_msg_data VARCHAR2(4000);
5855 l_progress VARCHAR2(10);
5856 l_label_status VARCHAR2(500);
5857 l_txn_id_tbl inv_label.transaction_id_rec_type;
5858 l_counter NUMBER := 0;
5859
5860 -- For LCM
5861 l_tx_type VARCHAR2(40);
5862 -- END FOR LCM
5863
5864 /* Bug 2200851 */
5865 /* Changed min to max */
5866 /* Group BY LPN_ID is changed for Express Receipts */
5867 /* Also duplicate print of LPN labels is avoided */
5868 CURSOR c_rti_txn_id IS
5869 SELECT MAX(rti.interface_transaction_id)
5870 FROM rcv_transactions_interface rti
5871 WHERE rti.GROUP_ID = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
5872 GROUP BY DECODE(p_source_type,
5873 'ASNEXP', rti.interface_transaction_id
5874 , 'SHIPMENTEXP', rti.interface_transaction_id, NULL);
5875
5876 -- GROUP BY rti.lpn_id;
5877 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5878 BEGIN
5879 x_status := fnd_api.g_ret_sts_success;
5880 l_progress := '10';
5881
5882 IF (l_debug = 1) THEN
5883 print_debug('create_std_rcpt_intf_rec: 1' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5884 print_debug('original_rti_id: ' || p_original_rti_id, 4);
5885 print_debug(p_secondary_uom,1);
5886 print_debug(p_secondary_uom_code,1);
5887 print_debug(p_secondary_quantity,1);
5888 END IF;
5889
5890 IF inv_rcv_common_apis.g_po_startup_value.sob_id IS NULL THEN
5891 --BUG 3444210: For performance reason, use the follow query
5892 --instead of gl_sets_of_books
5893 SELECT TO_NUMBER(hoi.org_information1)
5894 INTO inv_rcv_common_apis.g_po_startup_value.sob_id
5895 FROM hr_organization_information hoi
5896 WHERE hoi.organization_id = p_organization_id
5897 AND (hoi.org_information_context || '') = 'Accounting Information';
5898 END IF;
5899
5900 l_progress := '15';
5901 -- first check if the transaction date satisfies the validation.
5902 inv_rcv_common_apis.validate_trx_date(
5903 p_trx_date => SYSDATE
5904 , p_organization_id => p_organization_id
5905 , p_sob_id => inv_rcv_common_apis.g_po_startup_value.sob_id
5906 , x_return_status => x_status
5907 , x_error_code => x_message
5908 );
5909
5910 IF x_status <> fnd_api.g_ret_sts_success THEN
5911 RETURN;
5912 END IF;
5913
5914 x_status := fnd_api.g_ret_sts_success;
5915 IF p_source_type = 'VENDOR' THEN
5916 IF (l_debug = 1) THEN
5917 print_debug('create_std_rcpt_intf_rec: 2 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
5918 END IF;
5919
5920 l_progress := '20';
5921 create_po_rcpt_intf_rec(
5922 p_move_order_header_id => p_move_order_header_id
5923 , p_organization_id => p_organization_id
5924 , p_po_header_id => p_po_header_id
5925 , p_po_release_number_id => p_po_release_number_id
5926 , p_po_line_id => p_po_line_id
5927 , p_item_id => p_item_id
5928 , p_location_id => p_location_id
5929 , p_rcv_qty => p_rcv_qty
5930 , p_rcv_uom => p_rcv_uom
5931 , p_rcv_uom_code => p_rcv_uom_code
5932 , p_source_type => p_source_type
5933 , p_lpn_id => p_lpn_id
5934 , p_lot_control_code => p_lot_control_code
5935 , p_revision => p_revision
5936 , p_inspect => p_inspect
5937 , x_status => l_return_status
5938 , x_message => l_msg_data
5939 , p_inv_item_id => p_inv_item_id
5940 , p_item_desc => p_item_desc
5941 , p_project_id => p_project_id
5942 , p_task_id => p_task_id
5943 , p_country_code => p_country_code
5944 , p_rcv_subinventory_code => p_rcv_subinventory_code --RCVLOCATORSSUPPORT
5945 , p_rcv_locator_id => p_rcv_locator_id
5946 , p_original_rti_id => p_original_rti_id --Lot/Serial Support
5947 --OPM convergence
5948 , p_secondary_uom => p_secondary_uom
5949 , p_secondary_uom_code => p_secondary_uom_code
5950 , p_secondary_quantity => p_secondary_quantity
5951 , p_attribute_category => p_attribute_category --Bug #4147209
5952 , p_attribute1 => p_attribute1
5953 , p_attribute2 => p_attribute2
5954 , p_attribute3 => p_attribute3
5955 , p_attribute4 => p_attribute4
5956 , p_attribute5 => p_attribute5
5957 , p_attribute6 => p_attribute6
5958 , p_attribute7 => p_attribute7
5959 , p_attribute8 => p_attribute8
5960 , p_attribute9 => p_attribute9
5961 , p_attribute10 => p_attribute10
5962 , p_attribute11 => p_attribute11
5963 , p_attribute12 => p_attribute12
5964 , p_attribute13 => p_attribute13
5965 , p_attribute14 => p_attribute14
5966 , p_attribute15 => p_attribute15
5967 );
5968
5969 IF l_return_status = fnd_api.g_ret_sts_error THEN
5970 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5971 fnd_msg_pub.ADD;
5972
5973 IF (l_debug = 1) THEN
5974 print_debug(
5975 'create_std_rcpt_intf_rec 2.1: create_po_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
5976 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5977 , 4
5978 );
5979 END IF;
5980
5981 RAISE fnd_api.g_exc_error;
5982 END IF;
5983
5984 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
5985 fnd_message.set_name('INV', 'INV_RCV_CREATE_PO_RTI_FAIL'); -- MSGTBD
5986 fnd_msg_pub.ADD;
5987
5988 IF (l_debug = 1) THEN
5989 print_debug(
5990 'create_std_rcpt_intf_rec 2.2: create_po_rcpt_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
5991 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
5992 , 4
5993 );
5994 END IF;
5995
5996 RAISE fnd_api.g_exc_unexpected_error;
5997 END IF;
5998 ELSIF p_source_type = 'INTERNAL' THEN
5999 l_progress := '30';
6000
6001 IF (l_debug = 1) THEN
6002 print_debug('create_std_rcpt_intf_rec: 3 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6003 END IF;
6004
6005 create_intship_rcpt_intf_rec(
6006 p_move_order_header_id => p_move_order_header_id
6007 , p_organization_id => p_organization_id
6008 , p_shipment_header_id => p_shipment_header_id
6009 , p_req_header_id => p_req_header_id
6010 , p_item_id => p_item_id
6011 , p_location_id => p_location_id
6012 , p_rcv_qty => p_rcv_qty
6013 , p_rcv_uom => p_rcv_uom
6014 , p_rcv_uom_code => p_rcv_uom_code
6015 , p_source_type => p_source_type
6016 , p_from_lpn_id => p_from_lpn_id
6017 , p_lpn_id => p_lpn_id
6018 , p_lot_control_code => p_lot_control_code
6019 , p_revision => p_revision
6020 , p_inspect => p_inspect
6021 , x_status => l_return_status
6022 , x_message => l_msg_data
6023 , p_project_id => p_project_id
6024 , p_task_id => p_task_id
6025 , p_country_code => p_country_code
6026 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
6027 , p_rcv_locator_id => p_rcv_locator_id
6028 , p_original_rti_id => p_original_rti_id --Lot/Serial Support
6029 --OPM convergence
6030 , p_secondary_uom => p_secondary_uom
6031 , p_secondary_uom_code => p_secondary_uom_code
6032 , p_secondary_quantity => p_secondary_quantity
6033 , p_attribute_category => p_attribute_category --Bug #4147209
6034 , p_attribute1 => p_attribute1
6035 , p_attribute2 => p_attribute2
6036 , p_attribute3 => p_attribute3
6037 , p_attribute4 => p_attribute4
6038 , p_attribute5 => p_attribute5
6039 , p_attribute6 => p_attribute6
6040 , p_attribute7 => p_attribute7
6041 , p_attribute8 => p_attribute8
6042 , p_attribute9 => p_attribute9
6043 , p_attribute10 => p_attribute10
6044 , p_attribute11 => p_attribute11
6045 , p_attribute12 => p_attribute12
6046 , p_attribute13 => p_attribute13
6047 , p_attribute14 => p_attribute14
6048 , p_attribute15 => p_attribute15
6049 );
6050
6051 IF l_return_status = fnd_api.g_ret_sts_error THEN
6052 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
6053 fnd_msg_pub.ADD;
6054
6055 IF (l_debug = 1) THEN
6056 print_debug(
6057 'create_std_rcpt_intf_rec 3.1: create_intship_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
6058 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6059 , 4
6060 );
6061 END IF;
6062
6063 RAISE fnd_api.g_exc_error;
6064 END IF;
6065
6066 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6067 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
6068 fnd_msg_pub.ADD;
6069
6070 IF (l_debug = 1) THEN
6071 print_debug(
6072 'create_std_rcpt_intf_rec 3.2: create_intship_rcpt_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
6073 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6074 , 4
6075 );
6076 END IF;
6077
6078 RAISE fnd_api.g_exc_unexpected_error;
6079 END IF;
6080 ELSIF p_source_type = 'CUSTOMER' THEN
6081 l_progress := '40';
6082
6083 IF (l_debug = 1) THEN
6084 print_debug('create_std_rcpt_intf_rec: 4 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6085 END IF;
6086
6087 create_rma_rcpt_intf_rec(
6088 p_move_order_header_id => p_move_order_header_id
6089 , p_organization_id => p_organization_id
6090 , p_oe_order_header_id => p_oe_order_header_id
6091 , p_item_id => p_item_id
6092 , p_location_id => p_location_id
6093 , p_rcv_qty => p_rcv_qty
6094 , p_rcv_uom => p_rcv_uom
6095 , p_rcv_uom_code => p_rcv_uom_code
6096 , p_source_type => p_source_type
6097 , p_lpn_id => p_lpn_id
6098 , p_lot_control_code => p_lot_control_code
6099 , p_revision => p_revision
6100 , p_inspect => p_inspect
6101 , x_status => l_return_status
6102 , x_message => l_msg_data
6103 , p_project_id => p_project_id
6104 , p_task_id => p_task_id
6105 , p_country_code => p_country_code
6106 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
6107 , p_rcv_locator_id => p_rcv_locator_id
6108 , p_original_rti_id => p_original_rti_id --Lot/Serial Support
6109 --OPM convergence
6110 , p_secondary_uom => p_secondary_uom
6111 , p_secondary_uom_code => p_secondary_uom_code
6112 , p_secondary_quantity => p_secondary_quantity
6113 , p_attribute_category => p_attribute_category --Bug #4147209
6114 , p_attribute1 => p_attribute1
6115 , p_attribute2 => p_attribute2
6116 , p_attribute3 => p_attribute3
6117 , p_attribute4 => p_attribute4
6118 , p_attribute5 => p_attribute5
6119 , p_attribute6 => p_attribute6
6120 , p_attribute7 => p_attribute7
6121 , p_attribute8 => p_attribute8
6122 , p_attribute9 => p_attribute9
6123 , p_attribute10 => p_attribute10
6124 , p_attribute11 => p_attribute11
6125 , p_attribute12 => p_attribute12
6126 , p_attribute13 => p_attribute13
6127 , p_attribute14 => p_attribute14
6128 , p_attribute15 => p_attribute15
6129 );
6130
6131 IF l_return_status = fnd_api.g_ret_sts_error THEN
6132 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
6133 fnd_msg_pub.ADD;
6134
6135 IF (l_debug = 1) THEN
6136 print_debug(
6137 'create_std_rcpt_intf_rec 4.1: create_rma_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
6138 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6139 , 4
6140 );
6141 END IF;
6142
6143 RAISE fnd_api.g_exc_error;
6144 END IF;
6145
6146 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6147 fnd_message.set_name('INV', 'INV_RCV_CREATE_RMA_RTI_FAIL'); -- MSGTBD
6148 fnd_msg_pub.ADD;
6149
6150 IF (l_debug = 1) THEN
6151 print_debug(
6152 'create_std_rcpt_intf_rec 4.2: create_rma_rcpt_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
6153 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6154 , 4
6155 );
6156 END IF;
6157
6158 RAISE fnd_api.g_exc_unexpected_error;
6159 END IF;
6160 ELSIF p_source_type = 'ASNEXP'
6161 OR p_source_type = 'SHIPMENTEXP'
6162 OR p_source_type = 'SHIPMENT'
6163 OR p_source_type = 'REQEXP' THEN
6164 IF p_source_type = 'ASNEXP' THEN
6165 l_progress := '50';
6166
6167 IF (l_debug = 1) THEN
6168 print_debug(
6169 'create_std_rcpt_intf_rec: 5 - calling create_asn_exp_rcpt_intf_rec for ASN' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6170 , 1
6171 );
6172 END IF;
6173
6174 create_asn_exp_rcpt_intf_rec(
6175 p_move_order_header_id => p_move_order_header_id
6176 , p_organization_id => p_organization_id
6177 , p_shipment_header_id => p_shipment_header_id
6178 , p_po_header_id => p_po_header_id
6179 , p_location_id => p_location_id
6180 , p_source_type => 'ASN'
6181 , p_lpn_id => p_from_lpn_id
6182 , p_inspect => p_inspect
6183 , x_status => l_return_status
6184 , x_message => l_msg_data
6185 , p_project_id => p_project_id
6186 , p_task_id => p_task_id
6187 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
6188 , p_rcv_locator_id => p_rcv_locator_id
6189 , p_attribute_category => p_attribute_category --Bug #4147209
6190 , p_attribute1 => p_attribute1
6191 , p_attribute2 => p_attribute2
6192 , p_attribute3 => p_attribute3
6193 , p_attribute4 => p_attribute4
6194 , p_attribute5 => p_attribute5
6195 , p_attribute6 => p_attribute6
6196 , p_attribute7 => p_attribute7
6197 , p_attribute8 => p_attribute8
6198 , p_attribute9 => p_attribute9
6199 , p_attribute10 => p_attribute10
6200 , p_attribute11 => p_attribute11
6201 , p_attribute12 => p_attribute12
6202 , p_attribute13 => p_attribute13
6203 , p_attribute14 => p_attribute14
6204 , p_attribute15 => p_attribute15
6205 );
6206
6207 IF l_return_status = fnd_api.g_ret_sts_error THEN
6208 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
6209 fnd_msg_pub.ADD;
6210
6211 IF (l_debug = 1) THEN
6212 print_debug(
6213 'create_std_rcpt_intf_rec 5.1: create_asn_exp_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
6214 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6215 , 4
6216 );
6217 END IF;
6218
6219 RAISE fnd_api.g_exc_error;
6220 END IF;
6221
6222 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6223 fnd_message.set_name('INV', 'INV_RCV_CREATE_ASNEXP_RTI_FAIL'); -- MSGTBD
6224 fnd_msg_pub.ADD;
6225
6226 IF (l_debug = 1) THEN
6227 print_debug(
6228 'create_std_rcpt_intf_rec 5.2: create_asn_exp_rcpt_intf_rec FND_API.G_EXC_UNEXPECTED_ERROR;'
6229 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6230 , 4
6231 );
6232 END IF;
6233
6234 RAISE fnd_api.g_exc_unexpected_error;
6235 END IF;
6236 ELSE
6237 l_progress := '50';
6238
6239 IF (l_debug = 1) THEN
6240 print_debug(
6241 'create_std_rcpt_intf_rec: 6 - calling create_asn_exp_rcpt_intf_rec for intransit shipment'
6242 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6243 , 1
6244 );
6245 END IF;
6246
6247 create_asn_exp_rcpt_intf_rec(
6248 p_move_order_header_id => p_move_order_header_id
6249 , p_organization_id => p_organization_id
6250 , p_shipment_header_id => p_shipment_header_id
6251 , p_po_header_id => p_po_header_id
6252 , p_location_id => p_location_id
6253 , p_source_type => 'INTERNAL'
6254 , p_lpn_id => p_from_lpn_id
6255 , p_inspect => p_inspect
6256 , x_status => l_return_status
6257 , x_message => l_msg_data
6258 , p_project_id => p_project_id
6259 , p_task_id => p_task_id
6260 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
6261 , p_rcv_locator_id => p_rcv_locator_id
6262 );
6263
6264 IF l_return_status = fnd_api.g_ret_sts_error THEN
6265 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
6266 fnd_msg_pub.ADD;
6267
6268 IF (l_debug = 1) THEN
6269 print_debug(
6270 'create_std_rcpt_intf_rec 6.1: create_asn_exp_rcpt_intf_rec for IntShip RAISE FND_API.G_EXC_ERROR;'
6271 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6272 , 4
6273 );
6274 END IF;
6275
6276 RAISE fnd_api.g_exc_error;
6277 END IF;
6278
6279 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6280 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
6281 fnd_msg_pub.ADD;
6282
6283 IF (l_debug = 1) THEN
6284 print_debug(
6285 'create_std_rcpt_intf_rec 6.2: create_asn_exp_rcpt_intf_rec for IntShip RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
6286 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6287 , 4
6288 );
6289 END IF;
6290
6291 RAISE fnd_api.g_exc_unexpected_error;
6292 END IF;
6293 END IF;
6294
6295 -- For Bug 7440217 added LCMCONFM also
6296 ELSIF p_source_type IN ('ASNCONFM', 'LCMCONFM') THEN
6297 -- End for Bug 7440217
6298
6299 l_progress := '60';
6300
6301 -- For Bug 7440217 added code to handle LCM Doc also
6302 IF p_source_type = 'ASNCONFM' THEN
6303 l_tx_type := 'ASN';
6304 ELSIF p_source_type = 'LCMCONFM' THEN
6305 l_tx_type := 'LCM';
6306 END IF;
6307 -- End for Bug 7440217
6308
6309 IF (l_debug = 1) THEN
6310 print_debug('create_std_rcpt_intf_rec: 7 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6311 END IF;
6312
6313 create_asn_con_rcpt_intf_rec(
6314 p_move_order_header_id => p_move_order_header_id
6315 , p_organization_id => p_organization_id
6316 , p_shipment_header_id => p_shipment_header_id
6317 , p_po_header_id => p_po_header_id
6318 , p_item_id => p_item_id
6319 , p_location_id => p_location_id
6320 , p_rcv_qty => p_rcv_qty
6321 , p_rcv_uom => p_rcv_uom
6322 , p_rcv_uom_code => p_rcv_uom_code
6323 -- For Bug 7440217 Modified code to handle LCM Doc also
6324 , p_source_type => l_tx_type
6325 -- End for Bug 7440217
6326 , p_from_lpn_id => p_from_lpn_id
6327 , p_lpn_id => p_lpn_id
6328 , p_lot_control_code => p_lot_control_code
6329 , p_revision => p_revision
6330 , p_inspect => p_inspect
6331 , x_status => l_return_status
6332 , x_message => l_msg_data
6333 , p_item_desc => p_item_desc
6334 , p_project_id => p_project_id
6335 , p_task_id => p_task_id
6336 , p_country_code => p_country_code
6337 , p_rcv_subinventory_code => p_rcv_subinventory_code -- RCVLOCATORSSUPPORT
6338 , p_rcv_locator_id => p_rcv_locator_id
6339 , p_original_rti_id => p_original_rti_id --Lot/Serial Support
6340 --OPM convergence -- Uncommented the secondary paramters for Bug 12732516
6341 , p_secondary_uom => p_secondary_uom
6342 , p_secondary_uom_code => p_secondary_uom_code
6343 , p_secondary_quantity => p_secondary_quantity
6344 , p_attribute_category => p_attribute_category --Bug #4147209
6345 , p_attribute1 => p_attribute1
6346 , p_attribute2 => p_attribute2
6347 , p_attribute3 => p_attribute3
6348 , p_attribute4 => p_attribute4
6349 , p_attribute5 => p_attribute5
6350 , p_attribute6 => p_attribute6
6351 , p_attribute7 => p_attribute7
6352 , p_attribute8 => p_attribute8
6353 , p_attribute9 => p_attribute9
6354 , p_attribute10 => p_attribute10
6355 , p_attribute11 => p_attribute11
6356 , p_attribute12 => p_attribute12
6357 , p_attribute13 => p_attribute13
6358 , p_attribute14 => p_attribute14
6359 , p_attribute15 => p_attribute15
6360 , p_express_transaction => NULL--Bug 5550783
6361 );
6362
6363 IF l_return_status = fnd_api.g_ret_sts_error THEN
6364 fnd_message.set_name('INV', 'INV_RCV_CRT_ASNCON_RTI_FAIL'); -- MSGTBD
6365 fnd_msg_pub.ADD;
6366
6367 IF (l_debug = 1) THEN
6368 print_debug(
6369 'create_std_rcpt_intf_rec 7.1: create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_ERROR;'
6370 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6371 , 4
6372 );
6373 END IF;
6374
6375 RAISE fnd_api.g_exc_error;
6376 END IF;
6377
6378 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
6379 fnd_message.set_name('INV', 'INV_RCV_CRT_INSHP_RTI_FAIL'); -- MSGTBD
6380 fnd_msg_pub.ADD;
6381
6382 IF (l_debug = 1) THEN
6383 print_debug(
6384 'create_std_rcpt_intf_rec 7.2: create_asn_con_rcpt_intf_rec RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
6385 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6386 , 4
6387 );
6388 END IF;
6389
6390 RAISE fnd_api.g_exc_unexpected_error;
6391 END IF;
6392 END IF;
6393
6394 IF (l_debug = 1) THEN
6395 print_debug('create_std_rcpt_intf_rec: 8 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6396 END IF;
6397
6398 l_progress := '70';
6399 x_status := l_return_status; -- l_return_status can be 'W', we want to carry that over
6400
6401 -- calling label printing API
6402
6403 IF l_return_status <> fnd_api.g_ret_sts_error THEN
6404 l_progress := '80';
6405
6406 IF (l_debug = 1) THEN
6407 print_debug('create_std_rcpt_intf_rec: 8.1 before inv_label.print_label ', 4);
6408 END IF;
6409
6410 /* FP-J Lot/Serial Support Enhancement
6411 * If INV J and PO J are installed, do not call label printing API at this stage
6412 */
6413 IF ((inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po) OR
6414 (inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j)) THEN
6415 IF (p_source_type <> 'VENDOR') THEN --bug 3630412 for normal PO receipt moved the code to rcv_insert_update_header
6416 l_counter := 1;
6417 OPEN c_rti_txn_id;
6418
6419 LOOP
6420 FETCH c_rti_txn_id INTO l_txn_id_tbl(l_counter);
6421 EXIT WHEN c_rti_txn_id%NOTFOUND;
6422
6423 IF (l_debug = 1) THEN
6424 print_debug('create_std_rcpt_intf_rec calling printing for:' || l_txn_id_tbl(l_counter)||'p_source_type'||p_source_type, 4);
6425 END IF;
6426
6427 l_counter := l_counter + 1;
6428 END LOOP;
6429
6430 CLOSE c_rti_txn_id;
6431
6432 inv_label.print_label(
6433 x_return_status => l_return_status
6434 , x_msg_count => l_msg_count
6435 , x_msg_data => l_msg_data
6436 , x_label_status => l_label_status
6437 , p_api_version => 1.0
6438 , p_print_mode => 1
6439 , p_business_flow_code => 1
6440 , p_transaction_id => l_txn_id_tbl
6441 );
6442
6443 IF (l_debug = 1) THEN
6444 print_debug('create_std_rcpt_intf_rec: 8.15 after inv_label.print_label ', 4);
6445 END IF;
6446
6447 IF l_return_status <> fnd_api.g_ret_sts_success THEN
6448 fnd_message.set_name('INV', 'INV_RCV_CRT_PRINT_LAB_FAIL'); -- MSGTBD
6449 fnd_msg_pub.ADD;
6450 x_status := 'W';
6451
6452 IF (l_debug = 1) THEN
6453 print_debug('create_std_rcpt_intf_rec 8.2: inv_label.print_label FAILED;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6454 END IF;
6455 END IF;
6456 END IF; --bug3630412
6457 ELSE
6458 IF (l_debug = 1) THEN
6459 print_debug('INV J and PO J are installed. NO label printing from UI', 4);
6460 END IF;
6461 END IF; --END IF check INV J and PO J installed
6462 END IF;
6463
6464 l_progress := '90';
6465
6466 IF (l_debug = 1) THEN
6467 print_debug('create_std_rcpt_intf_rec exitting: 9' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6468 END IF;
6469 EXCEPTION
6470 WHEN fnd_api.g_exc_error THEN
6471 x_status := fnd_api.g_ret_sts_error;
6472 IF c_rti_txn_id%ISOPEN THEN
6473 CLOSE c_rti_txn_id;
6474 END IF;
6475 fnd_msg_pub.count_and_get(
6476 p_encoded => fnd_api.g_false
6477 , p_count => l_msg_count
6478 , p_data => x_message);
6479 WHEN fnd_api.g_exc_unexpected_error THEN
6480 x_status := fnd_api.g_ret_sts_unexp_error;
6481 IF c_rti_txn_id%ISOPEN THEN
6482 CLOSE c_rti_txn_id;
6483 END IF;
6484 fnd_msg_pub.count_and_get(
6485 p_encoded => fnd_api.g_false
6486 , p_count => l_msg_count
6487 , p_data => x_message);
6488 WHEN OTHERS THEN
6489 x_status := fnd_api.g_ret_sts_unexp_error;
6490 IF c_rti_txn_id%ISOPEN THEN
6491 CLOSE c_rti_txn_id;
6492 END IF;
6493 IF SQLCODE IS NOT NULL THEN
6494 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_std_rcpt_intf_rec', l_progress, SQLCODE);
6495 END IF;
6496 fnd_msg_pub.count_and_get(
6497 p_encoded => fnd_api.g_false
6498 , p_count => l_msg_count
6499 , p_data => x_message);
6500 END create_std_rcpt_intf_rec;
6501
6502 PROCEDURE create_mo_for_correction(
6503 p_move_order_header_id IN OUT NOCOPY NUMBER
6504 , p_po_line_location_id IN NUMBER DEFAULT NULL
6505 , p_po_distribution_id IN NUMBER DEFAULT NULL
6506 , p_shipment_line_id IN NUMBER DEFAULT NULL
6507 , p_oe_order_line_id IN NUMBER DEFAULT NULL
6508 , p_routing IN NUMBER
6509 , p_lot_control_code IN NUMBER
6510 , p_org_id IN NUMBER
6511 , p_item_id IN NUMBER
6512 , p_qty IN NUMBER
6513 , p_uom_code IN VARCHAR2
6514 , p_lpn IN NUMBER
6515 , p_revision IN VARCHAR2 DEFAULT NULL
6516 , p_inspect IN NUMBER
6517 , p_txn_source_id IN NUMBER
6518 , x_status OUT NOCOPY VARCHAR2
6519 , x_message OUT NOCOPY VARCHAR2
6520 , p_transfer_org_id IN NUMBER DEFAULT NULL
6521 , p_wms_process_flag IN NUMBER DEFAULT NULL
6522 , p_secondary_qty IN NUMBER DEFAULT NULL --OPM Convergence
6523 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
6524 ) IS
6525 l_dummy VARCHAR2(5);
6526 l_object_id NUMBER;
6527 l_msg_count NUMBER;
6528
6529 CURSOR c_mlt IS
6530 SELECT lot_number
6531 , transaction_quantity
6532 , primary_quantity -- 3648908
6533 , lot_expiration_date
6534 , transaction_temp_id
6535 , secondary_quantity --OPM Convergence
6536 FROM mtl_transaction_lots_temp
6537 WHERE transaction_temp_id = p_txn_source_id
6538 UNION ALL
6539 SELECT mtln.lot_number
6540 , mtln.transaction_quantity
6541 , mtln.primary_quantity
6542 , TO_DATE(NULL)
6543 , TO_NUMBER(NULL)
6544 , mtln.secondary_transaction_quantity --OPM Convergence
6545 FROM mtl_material_transactions mmt
6546 , mtl_transaction_lot_numbers mtln
6547 , rcv_transactions rt
6548 , rcv_shipment_lines rsl
6549 , mtl_system_items msi
6550 WHERE rt.interface_transaction_id = p_txn_source_id
6551 AND mmt.rcv_transaction_id = rt.transaction_id
6552 AND mmt.transaction_id = mtln.transaction_id
6553 AND(rt.transaction_type = 'RETURN TO RECEIVING'
6554 OR(rt.transaction_type = 'CORRECT'
6555 AND rt.quantity < 0))
6556 AND msi.lot_control_code = 2
6557 AND EXISTS(SELECT 1
6558 FROM rcv_transactions rt1
6559 WHERE rt1.transaction_id = rt.parent_transaction_id
6560 AND rt1.transaction_type = 'DELIVER')
6561 AND rt.user_entered_flag = 'Y'
6562 AND rsl.shipment_line_id = rt.shipment_line_id
6563 AND msi.inventory_item_id = rsl.item_id
6564 AND msi.organization_id = rt.organization_id;
6565
6566 /*******************************************************************************
6567 * Bug # : 1922526
6568 * Description:
6569 * Cursor c_mlt in procedure
6570 * create_mo_for_correction is modified
6571 * so that it selects the lot and qty
6572 * from mtln instead of mtlt, if the txn
6573 * is post-inv txn processing, because
6574 * mtlt records will not exist post-inv
6575 * txn processing.
6576 ******************************************************************************/
6577 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
6578 l_line_id NUMBER;
6579 BEGIN
6580 IF p_lot_control_code = 2 THEN
6581 g_rcpt_lot_qty_rec_tb.DELETE;
6582
6583 IF (l_debug = 1) THEN
6584 print_debug('Opening Lots loop ', 1);
6585 END IF;
6586
6587 FOR i IN c_mlt LOOP
6588 IF (l_debug = 1) THEN
6589 print_debug('Checking if ' || i.lot_number || ' exists', 1);
6590 END IF;
6591
6592 /* Before creating move orders, lot numbers should exist in
6593 ** mtl_lot_numbers. So, insert the lot number from
6594 ** mtl_transactions_lot_temp into mtl_lot_numbers
6595 ** by calling API INV_LOT_API_PUB.insertLot.
6596 ** This API takes care of populating attributes also.
6597 */
6598 BEGIN
6599 SELECT '1'
6600 INTO l_dummy
6601 FROM mtl_lot_numbers
6602 WHERE lot_number = i.lot_number
6603 AND inventory_item_id = p_item_id
6604 AND organization_id = p_org_id; --Added bug3466942
6605
6606 EXCEPTION
6607 WHEN NO_DATA_FOUND THEN
6608 IF (l_debug = 1) THEN
6609 print_debug('Lot insertion ' || i.lot_number, 1);
6610 END IF;
6611
6612 inv_lot_api_pub.insertlot(
6613 p_api_version => 1.0
6614 , p_init_msg_list => fnd_api.g_false
6615 , p_commit => fnd_api.g_false
6616 , p_validation_level => fnd_api.g_valid_level_full
6617 , p_inventory_item_id => p_item_id
6618 , p_organization_id => p_org_id
6619 , p_lot_number => i.lot_number
6620 , p_expiration_date => i.lot_expiration_date
6621 , p_transaction_temp_id => i.transaction_temp_id
6622 , p_transaction_action_id => NULL
6623 , p_transfer_organization_id => NULL
6624 , x_object_id => l_object_id
6625 , x_return_status => x_status
6626 , x_msg_count => l_msg_count
6627 , x_msg_data => x_message
6628 );
6629
6630 IF x_status <> fnd_api.g_ret_sts_success THEN
6631 IF (l_debug = 1) THEN
6632 print_debug('maintain move order - unable to insert lot ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6633 END IF;
6634
6635 RETURN;
6636 END IF;
6637
6638 IF (l_debug = 1) THEN
6639 print_debug('Lot inserted ', 1);
6640 END IF;
6641 END;
6642
6643 IF (l_debug = 1) THEN
6644 print_debug('p_primary_qty : '|| i.primary_quantity || ' txn_uom : '|| p_uom_code, 1);
6645 END IF;
6646
6647 populate_lot_rec(
6648 p_lot_number => i.lot_number
6649 , p_primary_qty => ABS(i.primary_quantity)
6650 , p_txn_uom_code => p_uom_code
6651 , p_org_id => p_org_id
6652 , p_item_id => p_item_id
6653 , p_secondary_quantity => i.secondary_quantity --OPM Convergence
6654 );
6655 END LOOP;
6656 END IF;
6657
6658 IF (l_debug = 1) THEN
6659 print_debug('Calling create_move_order ', 1);
6660 END IF;
6661
6662 create_move_order(
6663 p_move_order_header_id => p_move_order_header_id
6664 , p_po_line_location_id => p_po_line_location_id
6665 , p_po_distribution_id => p_po_distribution_id
6666 , p_shipment_line_id => p_shipment_line_id
6667 , p_oe_order_line_id => p_oe_order_line_id
6668 , p_routing => p_routing
6669 , p_lot_control_code => p_lot_control_code
6670 , p_org_id => p_org_id
6671 , p_item_id => p_item_id
6672 , p_qty => p_qty
6673 , p_uom_code => p_uom_code
6674 , p_lpn => p_lpn
6675 , p_project_id => NULL
6676 , p_task_id => NULL
6677 , p_revision => p_revision
6678 , p_inspect => p_inspect
6679 , p_txn_source_id => p_txn_source_id
6680 , x_status => x_status
6681 , x_message => x_message
6682 , p_transfer_org_id => p_transfer_org_id
6683 , p_wms_process_flag => p_wms_process_flag
6684 , p_secondary_quantity => p_secondary_qty --OPM Convergence
6685 , p_secondary_uom => p_secondary_uom --OPM Convergence
6686 , x_line_id => l_line_id
6687 );
6688 g_rcpt_lot_qty_rec_tb.DELETE;
6689 END create_mo_for_correction;
6690
6691
6692 -- For LCM Project BUG 7702666
6693 PROCEDURE lcm_call_rcv_rtp(
6694 p_lcmOrgID IN NUMBER
6695 , p_lcmReceiptNum IN VARCHAR2
6696 , x_lcmvalid_status OUT NOCOPY VARCHAR2
6697 , x_return_status OUT NOCOPY VARCHAR2
6698 , x_msg_data OUT NOCOPY VARCHAR2
6699 ) IS
6700
6701 v_processing_status_code varchar2(10);
6702
6703 BEGIN
6704
6705 SELECT PROCESSING_STATUS_CODE
6706 INTO v_processing_status_code
6707 FROM RCV_TRANSACTIONS_INTERFACE
6708 WHERE HEADER_INTERFACE_ID in
6709 (SELECT HEADER_INTERFACE_ID
6710 FROM RCV_HEADERS_INTERFACE
6711 WHERE receipt_num = p_lcmReceiptNum
6712 AND SHIP_TO_ORGANIZATION_ID = p_lcmOrgID)
6713 AND ROWNUM < 2;
6714
6715 IF nvl(v_processing_status_code, '@@@') = 'LC_PENDING' THEN
6716 x_lcmvalid_status := 'true';
6717 x_return_status := '';
6718 x_msg_data := '';
6719 ELSE
6720 x_lcmvalid_status := 'false';
6721 x_return_status := '';
6722 x_msg_data := '';
6723 END IF;
6724 END lcm_call_rcv_rtp;
6725 -- For LCM Project BUG 7702666
6726
6727
6728 PROCEDURE create_move_order(
6729 p_move_order_header_id IN OUT NOCOPY NUMBER
6730 , p_po_line_location_id IN NUMBER
6731 , p_po_distribution_id IN NUMBER
6732 , p_shipment_line_id IN NUMBER
6733 , p_oe_order_line_id IN NUMBER
6734 , p_routing IN VARCHAR2
6735 , p_lot_control_code IN NUMBER
6736 , p_org_id IN NUMBER
6737 , p_item_id IN NUMBER
6738 , p_qty IN NUMBER
6739 , p_uom_code IN VARCHAR2
6740 , p_lpn IN NUMBER
6741 , p_project_id IN NUMBER DEFAULT NULL
6742 , p_task_id IN NUMBER DEFAULT NULL
6743 , p_revision IN VARCHAR2 DEFAULT NULL
6744 , p_inspect IN NUMBER
6745 , p_txn_source_id IN NUMBER
6746 , x_status OUT NOCOPY VARCHAR2
6747 , x_message OUT NOCOPY VARCHAR2
6748 , p_transfer_org_id IN NUMBER DEFAULT NULL
6749 , p_wms_process_flag IN NUMBER DEFAULT NULL
6750 , p_lot_number IN VARCHAR2 DEFAULT NULL
6751 , p_secondary_quantity IN NUMBER DEFAULT NULL --OPM Convergence
6752 , p_secondary_uom IN VARCHAR2 DEFAULT NULL --OPM Convergence
6753 , x_line_id OUT NOCOPY NUMBER
6754 ) IS
6755 l_project_id NUMBER := '';
6756 l_task_id NUMBER := '';
6757 l_lot_qty_rec_tb rcpt_lot_qty_rec_tb_tp;
6758 l_line_id NUMBER;
6759 l_reference VARCHAR2(2000);
6760 l_reference_type_code NUMBER;
6761 l_reference_id NUMBER;
6762 l_count NUMBER;
6763 l_from_cost_group_id NUMBER;
6764 l_return_status VARCHAR2(1):= fnd_api.g_ret_sts_success;
6765 l_msg_count NUMBER;
6766 l_msg_data VARCHAR2(4000);
6767 l_progress VARCHAR2(10);
6768 l_wms_process_flag NUMBER := 2;
6769 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
6770 --Added for bug #3989521
6771 l_po_line_location_id NUMBER := NULL;
6772 l_po_distribution_id NUMBER := NULL;
6773 l_is_asn VARCHAR2(1);
6774 l_is_req VARCHAR2(1) := 'N'; -- Bug 5460505
6775 l_source_document_code rcv_shipment_lines.source_document_code%TYPE;
6776 BEGIN
6777 IF (l_debug = 1) THEN
6778 print_debug('create_move_order: 1 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
6779 END IF;
6780
6781 x_status := fnd_api.g_ret_sts_success;
6782 l_progress := '10';
6783
6784 IF p_project_id <> -9999 THEN
6785 l_project_id := p_project_id;
6786 l_task_id := p_task_id;
6787 END IF;
6788
6789 SAVEPOINT rcv_crt_mo_sp;
6790
6791 IF p_wms_process_flag IS NOT NULL THEN
6792 l_wms_process_flag := p_wms_process_flag;
6793 END IF;
6794
6795 --R12: If Shipment_line_id is passed, first checked if it is an ASN
6796 --If it is ASN, then REFERENCE should be SHIPMENT_LINE_ID. If not,
6797 --Reference should be PO_LINE_LOCATION_ID
6798 IF (p_shipment_line_id IS NOT NULL) THEN
6799 BEGIN
6800 SELECT rsl.po_line_location_id,rsl.po_distribution_id,
6801 decode(rsh.asn_type,'ASN','Y','N'),Decode(rsh.receipt_source_code,'INTERNAL ORDER','Y','N')
6802 INTO l_po_line_location_id,l_po_distribution_id,l_is_asn,l_is_req
6803 FROM rcv_shipment_lines rsl, rcv_shipment_headers rsh
6804 WHERE rsl.shipment_line_id = p_shipment_line_id
6805 AND rsl.shipment_header_id = rsh.shipment_header_id;
6806 EXCEPTION
6807 WHEN OTHERS THEN
6808 IF (l_debug = 1) THEN
6809 print_debug( 'create_move_order 4.1: RAISE FND_API.G_EXC_ERROR - ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS') , 4 );
6810 END IF;
6811 RAISE fnd_api.g_exc_error;
6812 END;
6813
6814 print_debug( 'create_move_order 4.2 : PLL ID : '||l_po_line_location_id ||
6815 ' POD ID : ' || l_po_distribution_id ||
6816 ' IS ASN?: ' || l_is_asn,4);
6817
6818 END IF;
6819
6820 IF (p_po_line_location_id IS NOT NULL AND l_is_asn = 'N') THEN
6821 IF (l_debug = 1) THEN
6822 print_debug('create_move_order: 2 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6823 END IF;
6824
6825 IF p_project_id IS NULL THEN
6826 get_project_task(
6827 p_po_line_location_id => p_po_line_location_id
6828 , p_oe_order_line_id => NULL
6829 , x_project_id => l_project_id
6830 , x_task_id => l_task_id
6831 );
6832 END IF;
6833
6834 l_reference_id := p_po_line_location_id;
6835 l_reference := 'PO_LINE_LOCATION_ID';
6836 l_reference_type_code := 4; -- for purchase orders
6837
6838 IF (l_debug = 1) THEN
6839 print_debug('create_move_order: 3 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6840 END IF;
6841 --14730177 Commenting this code. Now PO_DISTRIBUTION_ID will not be stamped
6842 --on the MO LINE.
6843 /*ELSIF p_po_distribution_id IS NOT NULL THEN
6844 -- l_project_id := p_project_id;
6845 -- l_task_id := p_task_id;
6846 l_reference_id := p_po_distribution_id;
6847 l_reference := 'PO_DISTRIBUTION_ID';
6848 l_reference_type_code := 4; -- for purchase orders
6849 */--14730177
6850
6851 ELSIF p_oe_order_line_id IS NOT NULL AND l_is_req = 'N' THEN
6852 IF (l_debug = 1) THEN
6853 print_debug('create_move_order: 5 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6854 END IF;
6855
6856 l_reference_id := p_oe_order_line_id;
6857 l_reference_type_code := 7; -- for RMA
6858 get_project_task(
6859 p_po_line_location_id => NULL
6860 , p_oe_order_line_id => p_oe_order_line_id
6861 , x_project_id => l_project_id
6862 , x_task_id => l_task_id
6863 );
6864
6865 IF p_routing = 'DIRECT' THEN
6866 l_reference := 'DIRECT ORDER_LINE_ID';
6867 ELSE
6868 l_reference := 'ORDER_LINE_ID';
6869 END IF;
6870 ELSIF p_shipment_line_id IS NOT NULL THEN
6871 IF (l_debug = 1) THEN
6872 print_debug('create_move_order: 4 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6873 END IF;
6874
6875 l_reference_id := p_shipment_line_id;
6876
6877 BEGIN
6878 SELECT po_line_location_id, po_distribution_id, source_document_code
6879 INTO l_po_line_location_id, l_po_distribution_id, l_source_document_code
6880 FROM rcv_shipment_lines
6881 WHERE shipment_line_id = p_shipment_line_id;
6882 EXCEPTION
6883 WHEN OTHERS THEN
6884 IF (l_debug = 1) THEN
6885 print_debug( 'create_move_order 4.1: RAISE FND_API.G_EXC_ERROR - ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS') , 4 );
6886 END IF;
6887
6888 END;
6889 print_debug( 'create_move_order 4.2 : PLL ID : ' || l_po_line_location_id || ' POD ID : ' || l_po_distribution_id || ' p_shipment_line_id ' || p_shipment_line_id || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS') , 4 );
6890
6891 IF l_po_line_location_id IS NOT NULL OR l_po_distribution_id IS NOT NULL THEN
6892 l_reference_type_code := 4; --Considering the ASN
6893
6894 ELSIF l_source_document_code = 'INVENTORY' THEN
6895 l_reference_type_code := 6;
6896 ELSE
6897 l_reference_type_code := 8;
6898 END IF;
6899 --End of fix for Bug #3989521
6900
6901 -- for internal reqs
6902 --???????????????????????????????? Ans:
6903 -- how to populate the project and task ids
6904
6905 IF p_routing = 'DIRECT' THEN
6906 l_reference := 'DIRECT SHIPMENT_LINE_ID';
6907 ELSE
6908 l_reference := 'SHIPMENT_LINE_ID';
6909 END IF;
6910 END IF;
6911
6912 l_progress := '20';
6913
6914 IF p_lot_control_code = 2 THEN
6915 IF (l_debug = 1) THEN
6916 print_debug('create_move_order: 6 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
6917 END IF;
6918
6919 l_progress := '30';
6920 --If INV and PO J are installed,
6921 -- execute the old split logic else just update the local table
6922 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
6923 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
6924 IF (l_debug = 1) THEN
6925 print_debug('Calling to insert RHI for J code', 4);
6926 END IF;
6927 l_lot_qty_rec_tb(1).lot_number := p_lot_number;
6928 l_lot_qty_rec_tb(1).txn_quantity := p_qty;
6929 ELSE
6930 split_qty_for_lot(p_qty, l_lot_qty_rec_tb);
6931 END IF;
6932 l_progress := '40';
6933
6934 FOR i IN 1 .. l_lot_qty_rec_tb.COUNT LOOP
6935 IF (l_debug = 1) THEN
6936 print_debug(
6937 'create_move_order 7: before calling wms_task_dispatch_put_away.create_mo ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
6938 , 4
6939 );
6940 END IF;
6941
6942 IF p_shipment_line_id IS NOT NULL THEN
6943 IF p_lpn IS NOT NULL THEN
6944 BEGIN
6945 SELECT cost_group_id
6946 INTO l_from_cost_group_id
6947 FROM wms_lpn_contents wlpnc
6948 WHERE organization_id = p_org_id
6949 AND parent_lpn_id = p_lpn
6950 AND wlpnc.inventory_item_id = p_item_id
6951 AND Nvl(wlpnc.lot_number,'@@@') = Nvl(l_lot_qty_rec_tb(i).lot_number,Nvl(wlpnc.lot_number,'@@@'))
6952 AND EXISTS(
6953 SELECT 1
6954 FROM cst_cost_group_accounts
6955 WHERE organization_id = p_org_id
6956 AND cost_group_id = wlpnc.cost_group_id);
6957 EXCEPTION
6958 WHEN OTHERS THEN
6959 l_from_cost_group_id := NULL;
6960 END;
6961 /*ELSE--START commented for bug 16711363
6962 BEGIN
6963 SELECT cost_group_id
6964 INTO l_from_cost_group_id
6965 FROM rcv_shipment_lines rsl
6966 WHERE shipment_line_id = p_shipment_line_id
6967 AND exists (
6968 SELECT 1
6969 FROM cst_cost_group_accounts
6970 WHERE organization_id = p_org_id
6971 AND cost_group_id = rsl.cost_group_id)
6972 AND ROWNUM = 1;
6973 EXCEPTION
6974 WHEN OTHERS THEN
6975 l_from_cost_group_id := NULL;
6976 END; */--END commented for bug 16711363
6977 END IF;
6978 END IF;
6979
6980 IF p_project_id = -9999 THEN
6981 l_project_id := NULL;
6982 l_task_id := NULL;
6983 END IF;
6984
6985 IF (l_debug = 1) THEN
6986 print_debug('create_move_order 7.1 parameters organization -' || p_org_id, 4);
6987 print_debug('create_move_order 7.1 parameters p_item_id -' || p_item_id, 4);
6988 print_debug('create_move_order 7.1 parameters txn_quantity -' || l_lot_qty_rec_tb(i).txn_quantity, 4);
6989 print_debug('create_move_order 7.1 parameters p_uom_code -' || p_uom_code, 4);
6990 print_debug('create_move_order 7.1 parameters p_lpn -' || p_lpn, 4);
6991 print_debug('create_move_order 7.1 parameters l_project_id -' || l_project_id, 4);
6992 print_debug('create_move_order 7.1 parameters l_task_id -' || l_task_id, 4);
6993 print_debug('create_move_order 7.1 parameters l_reference -' || l_reference, 4);
6994 print_debug('create_move_order 7.1 parameters l_reference_type_code -' || l_reference_type_code, 4);
6995 print_debug('create_move_order 7.1 parameters l_reference_id -' || l_reference_id, 4);
6996 print_debug('create_move_order 7.1 parameters lot_number -' || l_lot_qty_rec_tb(i).lot_number, 4);
6997 print_debug('create_move_order 7.1 parameters p_revision -' || p_revision, 4);
6998 print_debug('create_move_order 7.1 parameters p_move_order_header_id -' || p_move_order_header_id, 4);
6999 print_debug('create_move_order 7.1 parameters p_inspect -' || p_inspect, 4);
7000 print_debug('create_move_order 7.1 parameters p_txn_source_id -' || p_txn_source_id, 4);
7001 print_debug('create_move_order 7.1 parameters l_from_cost_group_id -' || l_from_cost_group_id, 4);
7002 print_debug('create_move_order 7.1 parameters p_transfer_org_id -' || p_transfer_org_id, 4);
7003 END IF;
7004
7005 wms_task_dispatch_put_away.create_mo(
7006 p_org_id => p_org_id
7007 , p_inventory_item_id => p_item_id
7008 , p_qty => l_lot_qty_rec_tb(i).txn_quantity
7009 , p_uom => p_uom_code
7010 , p_lpn => p_lpn
7011 , p_project_id => l_project_id
7012 , p_task_id => l_task_id
7013 , p_reference => l_reference
7014 , p_reference_type_code => l_reference_type_code
7015 , p_reference_id => l_reference_id
7016 , p_lot_number => l_lot_qty_rec_tb(i).lot_number
7017 , p_revision => p_revision
7018 , p_header_id => p_move_order_header_id
7019 , x_line_id => l_line_id
7020 , x_return_status => l_return_status
7021 , x_msg_count => l_count
7022 , x_msg_data => l_msg_data
7023 , p_inspection_status => p_inspect
7024 , p_txn_source_id => p_txn_source_id
7025 , p_wms_process_flag => l_wms_process_flag
7026 , p_from_cost_group_id => l_from_cost_group_id
7027 , p_transfer_org_id => p_transfer_org_id
7028 , p_sec_qty => p_secondary_quantity --OPM Convergence
7029 , p_sec_uom => p_secondary_uom --OPM Convergence
7030 );
7031
7032 IF (l_debug = 1) THEN
7033 print_debug(
7034 'create_move_order 7: after calling wms_task_dispatch_put_away.create_mo ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7035 , 4
7036 );
7037 END IF;
7038
7039 IF l_return_status = fnd_api.g_ret_sts_error THEN
7040 IF (l_debug = 1) THEN
7041 print_debug(
7042 'create_move_order 7.1: wms_task_dispatch_put_away.create_mo RAISE FND_API.G_EXC_ERROR;'
7043 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7044 , 4
7045 );
7046 END IF;
7047
7048 RAISE fnd_api.g_exc_error;
7049 END IF;
7050
7051 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
7052 IF (l_debug = 1) THEN
7053 print_debug(
7054 'create_move_order 7.2: wms_task_dispatch_put_away.create_mo RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
7055 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7056 , 4
7057 );
7058 END IF;
7059
7060 RAISE fnd_api.g_exc_unexpected_error;
7061 END IF;
7062 -- Should set wms_process_flag to 2 (do not allocate), then
7063 -- rcvtp will call rcv_txn_clean_up to update this flag to 1,
7064 -- if receipt transaction goes through successfully.
7065 -- We set this flag to 1 right now for testing purpose since
7066 -- rcvtp is not calling our code yet.
7067 END LOOP;
7068 ELSE
7069 IF (l_debug = 1) THEN
7070 print_debug('create_move_order 8: before calling wms_task_dispatch_put_away.create_mo '
7071 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7072 , 4);
7073 END IF;
7074
7075 IF p_shipment_line_id IS NOT NULL THEN
7076 IF p_lpn IS NOT NULL THEN
7077 BEGIN
7078 SELECT cost_group_id
7079 INTO l_from_cost_group_id
7080 FROM wms_lpn_contents wlpnc
7081 WHERE organization_id = p_org_id
7082 AND parent_lpn_id = p_lpn
7083 AND wlpnc.inventory_item_id = p_item_id
7084 AND EXISTS(
7085 SELECT 1
7086 FROM cst_cost_group_accounts
7087 WHERE organization_id = p_org_id
7088 AND cost_group_id = wlpnc.cost_group_id);
7089 EXCEPTION
7090 WHEN OTHERS THEN
7091 l_from_cost_group_id := NULL;
7092 END;
7093 /*ELSE --START commented for bug 16711363
7094 BEGIN
7095 SELECT cost_group_id
7096 INTO l_from_cost_group_id
7097 FROM rcv_shipment_lines rsl
7098 WHERE shipment_line_id = p_shipment_line_id
7099 AND exists (
7100 SELECT 1
7101 FROM cst_cost_group_accounts
7102 WHERE organization_id = p_org_id
7103 AND cost_group_id = rsl.cost_group_id)
7104 AND ROWNUM = 1;
7105 EXCEPTION
7106 WHEN OTHERS THEN
7107 l_from_cost_group_id := NULL;
7108 END;*/ --END commented for bug 16711363
7109 END IF;
7110 END IF;
7111
7112 IF (l_debug = 1) THEN
7113 print_debug('create_move_order 8.1 parameters organization -' || p_org_id, 4);
7114 print_debug('create_move_order 8.1 parameters p_item_id -' || p_item_id, 4);
7115 print_debug('create_move_order 8.1 parameters p_uom_code -' || p_uom_code, 4);
7116 print_debug('create_move_order 8.1 parameters p_lpn -' || p_lpn, 4);
7117 print_debug('create_move_order 8.1 parameters l_project_id -' || l_project_id, 4);
7118 print_debug('create_move_order 8.1 parameters l_task_id -' || l_task_id, 4);
7119 print_debug('create_move_order 8.1 parameters l_reference -' || l_reference, 4);
7120 print_debug('create_move_order 8.1 parameters l_reference_type_code -' || l_reference_type_code, 4);
7121 print_debug('create_move_order 8.1 parameters l_reference_id -' || l_reference_id, 4);
7122 print_debug('create_move_order 8.1 parameters p_revision -' || p_revision, 4);
7123 print_debug('create_move_order 8.1 parameters p_move_order_header_id -' || p_move_order_header_id, 4);
7124 print_debug('create_move_order 8.1 parameters p_inspect -' || p_inspect, 4);
7125 print_debug('create_move_order 8.1 parameters p_txn_source_id -' || p_txn_source_id, 4);
7126 print_debug('create_move_order 8.1 parameters l_from_cost_group_id -' || l_from_cost_group_id, 4);
7127 print_debug('create_move_order 8.1 parameters p_transfer_org_id -' || p_transfer_org_id, 4);
7128 END IF;
7129
7130 wms_task_dispatch_put_away.create_mo(
7131 p_org_id => p_org_id
7132 , p_inventory_item_id => p_item_id
7133 , p_qty => p_qty
7134 , p_uom => p_uom_code
7135 , p_lpn => p_lpn
7136 , p_project_id => l_project_id
7137 , p_task_id => l_task_id
7138 , p_reference => l_reference
7139 , p_reference_type_code => l_reference_type_code
7140 , p_reference_id => l_reference_id
7141 , p_lot_number => NULL
7142 , p_revision => p_revision
7143 , p_header_id => p_move_order_header_id
7144 , x_line_id => l_line_id
7145 , x_return_status => l_return_status
7146 , x_msg_count => l_count
7147 , x_msg_data => l_msg_data
7148 , p_inspection_status => p_inspect
7149 , p_txn_source_id => p_txn_source_id
7150 , p_wms_process_flag => l_wms_process_flag
7151 , p_from_cost_group_id => l_from_cost_group_id
7152 , p_transfer_org_id => p_transfer_org_id
7153 -- Bug #8212440
7154 , p_sec_qty => p_secondary_quantity --OPM Convergence
7155 , p_sec_uom => p_secondary_uom --OPM Convergence
7156 );
7157
7158 IF (l_debug = 1) THEN
7159 print_debug('create_move_order 8: after calling wms_task_dispatch_put_away.create_mo '
7160 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7161 , 1);
7162 END IF;
7163
7164 IF l_return_status = fnd_api.g_ret_sts_error THEN
7165 IF (l_debug = 1) THEN
7166 print_debug(
7167 'create_move_order 8.1: wms_task_dispatch_put_away.create_mo RAISE FND_API.G_EXC_ERROR;'
7168 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7169 , 4
7170 );
7171 END IF;
7172
7173 RAISE fnd_api.g_exc_error;
7174 END IF;
7175
7176 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
7177 IF (l_debug = 1) THEN
7178 print_debug(
7179 'create_move_order 8.2: wms_task_dispatch_put_away.create_mo RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
7180 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7181 , 4
7182 );
7183 END IF;
7184
7185 RAISE fnd_api.g_exc_unexpected_error;
7186 END IF;
7187 END IF;
7188
7189 x_line_id := l_line_id;
7190
7191 IF (l_debug = 1) THEN
7192 print_debug(
7193 'create_move_order returns with success'
7194 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7195 , 4
7196 );
7197 END IF;
7198
7199 EXCEPTION
7200 WHEN fnd_api.g_exc_error THEN
7201 ROLLBACK TO rcv_crt_mo_sp;
7202 x_status := fnd_api.g_ret_sts_error;
7203 fnd_msg_pub.count_and_get(
7204 p_encoded => fnd_api.g_false
7205 , p_count => l_msg_count
7206 , p_data => x_message);
7207
7208 IF (l_debug = 1) THEN
7209 print_debug('create_move_order: FND_API.g_exc_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7210 END IF;
7211 WHEN fnd_api.g_exc_unexpected_error THEN
7212 ROLLBACK TO rcv_crt_mo_sp;
7213 x_status := fnd_api.g_ret_sts_unexp_error;
7214 fnd_msg_pub.count_and_get(
7215 p_encoded => fnd_api.g_false
7216 , p_count => l_msg_count
7217 , p_data => x_message);
7218
7219 IF (l_debug = 1) THEN
7220 print_debug('create_move_order: fnd_api.g_exc_unexpected_error ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7221 END IF;
7222 WHEN OTHERS THEN
7223 ROLLBACK TO rcv_crt_mo_sp;
7224 x_status := fnd_api.g_ret_sts_unexp_error;
7225
7226 IF SQLCODE IS NOT NULL THEN
7227 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.create_move_order', l_progress, SQLCODE);
7228 END IF;
7229
7230 fnd_msg_pub.count_and_get(
7231 p_encoded => fnd_api.g_false
7232 , p_count => l_msg_count
7233 , p_data => x_message);
7234
7235 IF (l_debug = 1) THEN
7236 print_debug('create_move_order: Other exception ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7237 END IF;
7238 END create_move_order;
7239
7240 PROCEDURE rcv_update_rti_from_header(
7241 p_shipment_num VARCHAR
7242 , p_freight_carrier_code VARCHAR2
7243 , p_bill_of_lading VARCHAR2
7244 , p_packing_slip VARCHAR2
7245 , p_num_of_containers NUMBER
7246 , p_waybill_airbill_num VARCHAR2
7247 , x_return_status OUT NOCOPY VARCHAR2
7248 , x_msg_count OUT NOCOPY NUMBER
7249 , x_msg_data OUT NOCOPY VARCHAR2
7250 ) IS
7251 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
7252 l_msg_count NUMBER;
7253 l_msg_data VARCHAR2(4000);
7254 l_progress VARCHAR2(10);
7255 l_process_status VARCHAR2(10);
7256 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
7257 BEGIN
7258 l_progress := '10';
7259 x_return_status := fnd_api.g_ret_sts_success;
7260
7261 IF (l_debug = 1) THEN
7262 print_debug('rcv_update_rti_from_header 5: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7263 END IF;
7264
7265 BEGIN
7266 --If INV and PO J are installed,
7267 -- then query using the group_id as RTI is not stamped with shipment_header_id
7268 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
7269 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
7270 IF (l_debug = 1) THEN
7271 print_debug('Calling to insert RHI for J code', 4);
7272 END IF;
7273
7274 SELECT transaction_status_code
7275 INTO l_process_status
7276 FROM rcv_transactions_interface
7277 WHERE group_id = inv_rcv_common_apis.g_rcv_global_var.interface_group_id
7278 AND ROWNUM = 1;
7279 ELSE
7280 SELECT transaction_status_code
7281 INTO l_process_status
7282 FROM rcv_transactions_interface
7283 WHERE shipment_header_id = g_shipment_header_id
7284 AND ROWNUM < 2;
7285 END IF;
7286
7287 IF (l_process_status = 'ERROR') THEN
7288 x_return_status := fnd_api.g_ret_sts_error;
7289 fnd_message.set_name('INV', 'INV_FAILED');
7290 fnd_msg_pub.ADD;
7291 RAISE fnd_api.g_exc_error;
7292 END IF;
7293 EXCEPTION
7294 WHEN NO_DATA_FOUND THEN
7295 x_return_status := fnd_api.g_ret_sts_error;
7296 fnd_message.set_name('INV', 'INV_FAILED');
7297 fnd_msg_pub.ADD;
7298 RAISE fnd_api.g_exc_error;
7299 END;
7300
7301 IF (l_debug = 1) THEN
7302 print_debug('rcv_update_rti_from_header 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7303 END IF;
7304
7305 --If INV and PO J are installed,
7306 -- then query using the group_id as RTI is not stamped with shipment_header_id
7307 IF ((inv_rcv_common_apis.g_inv_patch_level >= inv_rcv_common_apis.g_patchset_j) AND
7308 (inv_rcv_common_apis.g_po_patch_level >= inv_rcv_common_apis.g_patchset_j_po)) THEN
7309 IF (l_debug = 1) THEN
7310 print_debug('Calling to insert RHI for J code', 4);
7311 END IF;
7312 UPDATE rcv_transactions_interface
7313 SET shipment_num = p_shipment_num
7314 , freight_carrier_code = p_freight_carrier_code
7315 , bill_of_lading = p_bill_of_lading
7316 , packing_slip = p_packing_slip
7317 , num_of_containers = p_num_of_containers
7318 , waybill_airbill_num = p_waybill_airbill_num
7319 WHERE group_id = inv_rcv_common_apis.g_rcv_global_var.interface_group_id;
7320 ELSE
7321 UPDATE rcv_transactions_interface
7322 SET shipment_num = p_shipment_num
7323 , freight_carrier_code = p_freight_carrier_code
7324 , bill_of_lading = p_bill_of_lading
7325 , packing_slip = p_packing_slip
7326 , num_of_containers = p_num_of_containers
7327 , waybill_airbill_num = p_waybill_airbill_num
7328 WHERE shipment_header_id = g_shipment_header_id;
7329 END IF;
7330 l_progress := '20';
7331
7332 IF (l_debug = 1) THEN
7333 print_debug('rcv_update_rti_from_header 20: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7334 END IF;
7335 EXCEPTION
7336 WHEN fnd_api.g_exc_error THEN
7337 x_return_status := fnd_api.g_ret_sts_error;
7338 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7339 WHEN fnd_api.g_exc_unexpected_error THEN
7340 x_return_status := fnd_api.g_ret_sts_unexp_error;
7341 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7342 WHEN OTHERS THEN
7343 x_return_status := fnd_api.g_ret_sts_unexp_error;
7344
7345 IF SQLCODE IS NOT NULL THEN
7346 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.rcv_update_rti_from_header', l_progress, SQLCODE);
7347 END IF;
7348
7349 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7350 END rcv_update_rti_from_header;
7351
7352 -- Only called if patchset J or higher from rcv_insert_update_header
7353 -- This is called instead of rcv_insert_header
7354 PROCEDURE rcv_insert_header_interface(
7355 p_organization_id NUMBER
7356 , p_source_type VARCHAR2
7357 , p_receipt_num OUT NOCOPY VARCHAR2
7358 , p_vendor_id NUMBER
7359 , p_vendor_site_id NUMBER
7360 , p_shipment_num VARCHAR2
7361 , p_ship_to_location_id NUMBER
7362 , p_bill_of_lading VARCHAR2
7363 , p_packing_slip VARCHAR2
7364 , p_shipped_date DATE
7365 , p_freight_carrier_code VARCHAR2
7366 , p_expected_receipt_date DATE
7367 , p_num_of_containers NUMBER
7368 , p_waybill_airbill_num VARCHAR2
7369 , p_comments VARCHAR2
7370 , p_ussgl_transaction_code VARCHAR2
7371 , p_government_context VARCHAR2
7372 , p_request_id NUMBER
7373 , p_program_application_id NUMBER
7374 , p_program_id NUMBER
7375 , p_program_update_date DATE
7376 , p_customer_id NUMBER
7377 , p_customer_site_id NUMBER
7378 , x_return_status OUT NOCOPY VARCHAR2
7379 , x_msg_count OUT NOCOPY NUMBER
7380 , x_msg_data OUT NOCOPY VARCHAR2
7381 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
7382 , p_attribute1 IN VARCHAR2 DEFAULT NULL
7383 , p_attribute2 IN VARCHAR2 DEFAULT NULL
7384 , p_attribute3 IN VARCHAR2 DEFAULT NULL
7385 , p_attribute4 IN VARCHAR2 DEFAULT NULL
7386 , p_attribute5 IN VARCHAR2 DEFAULT NULL
7387 , p_attribute6 IN VARCHAR2 DEFAULT NULL
7388 , p_attribute7 IN VARCHAR2 DEFAULT NULL
7389 , p_attribute8 IN VARCHAR2 DEFAULT NULL
7390 , p_attribute9 IN VARCHAR2 DEFAULT NULL
7391 , p_attribute10 IN VARCHAR2 DEFAULT NULL
7392 , p_attribute11 IN VARCHAR2 DEFAULT NULL
7393 , p_attribute12 IN VARCHAR2 DEFAULT NULL
7394 , p_attribute13 IN VARCHAR2 DEFAULT NULL
7395 , p_attribute14 IN VARCHAR2 DEFAULT NULL
7396 , p_attribute15 IN VARCHAR2 DEFAULT NULL
7397 ) IS
7398 l_header rcv_headers_interface%ROWTYPE;
7399 l_rowid VARCHAR2(40);
7400 l_sysdate DATE := SYSDATE;
7401 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
7402 l_msg_count NUMBER;
7403 l_msg_data VARCHAR2(4000);
7404 l_progress VARCHAR2(10);
7405 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
7406 BEGIN
7407 IF (l_debug = 1) THEN
7408 print_debug('rcv_insert_header_interface 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7409 END IF;
7410
7411 l_progress := '10';
7412 x_return_status := fnd_api.g_ret_sts_success;
7413 SAVEPOINT rcv_insert_ship_header_sp;
7414 l_header.last_update_date := l_sysdate;
7415 l_header.creation_date := l_sysdate;
7416 l_header.last_update_login := inv_rcv_common_apis.g_po_startup_value.user_id;
7417 l_header.created_by := inv_rcv_common_apis.g_po_startup_value.user_id;
7418 l_header.last_updated_by := inv_rcv_common_apis.g_po_startup_value.user_id;
7419 -- Bug 3443989 for Internal Requition we have to enter receipt_source_code as INTERNAL ORDER
7420 -- According to PO
7421
7422 IF p_source_type = 'CUSTOMER' THEN
7423 l_header.receipt_source_code := 'CUSTOMER';
7424 elsif p_source_type = 'INVENTORY' THEN
7425 l_header.receipt_source_code := 'INVENTORY';
7426 elsif p_source_type = 'INTERNAL ORDER' THEN
7427 l_header.receipt_source_code := 'INTERNAL ORDER';
7428 END IF;
7429
7430 l_progress := '13';
7431 l_header.receipt_num := inv_rcv_common_apis.g_rcv_global_var.receipt_num;
7432 IF l_header.receipt_num IS NULL THEN
7433 RAISE fnd_api.g_exc_error;
7434 END IF;
7435
7436 l_progress := '15';
7437 l_header.vendor_id := p_vendor_id;
7438 l_header.vendor_site_id := p_vendor_site_id;
7439 l_header.ship_to_organization_id := p_organization_id;
7440 l_header.shipment_num := p_shipment_num;
7441 l_header.bill_of_lading := p_bill_of_lading;
7442 l_header.packing_slip := p_packing_slip;
7443 l_header.shipped_date := p_shipped_date;
7444 l_header.freight_carrier_code := p_freight_carrier_code;
7445 /*
7446 --Bug 14770902 begin Fetch expected_receipt_date from rsh
7447 --l_header.expected_receipt_date := Nvl(p_expected_receipt_date,l_sysdate);
7448 IF p_expected_receipt_date IS NULL AND p_shipment_num IS NOT NULL THEN
7449 SELECT expected_receipt_date
7450 INTO l_header.expected_receipt_date
7451 FROM rcv_shipment_headers
7452 WHERE shipment_num = p_shipment_num;
7453 ELSE
7454 l_header.expected_receipt_date := Nvl(p_expected_receipt_date,l_sysdate);
7455 END IF;
7456 --End of Bug 14770902
7457 */
7458 --Bug 16495716 revert the fix in 14770902, Fetch expected_receipt_date from rsh by shipment_header_id
7459 BEGIN
7460 IF p_expected_receipt_date IS NULL AND p_shipment_num IS NOT NULL AND g_shipment_header_id IS NOT NULL THEN
7461 SELECT Nvl(expected_receipt_date, SYSDATE)
7462 INTO l_header.expected_receipt_date
7463 FROM rcv_shipment_headers
7464 WHERE shipment_num = p_shipment_num
7465 AND shipment_header_id = g_shipment_header_id;
7466 ELSE
7467 l_header.expected_receipt_date := Nvl(p_expected_receipt_date,l_sysdate);
7468 END IF;
7469 EXCEPTION
7470 WHEN OTHERS THEN
7471 l_header.expected_receipt_date := Nvl(p_expected_receipt_date,l_sysdate);
7472 END;
7473 -- End Bug 16495716
7474
7475 l_header.employee_id := inv_rcv_common_apis.g_po_startup_value.employee_id;
7476 l_header.num_of_containers := p_num_of_containers;
7477 l_header.waybill_airbill_num := p_waybill_airbill_num;
7478 l_header.comments := p_comments;
7479 l_header.usggl_transaction_code := p_ussgl_transaction_code;
7480 l_header.processing_request_id := p_request_id;
7481 l_header.customer_id := p_customer_id;
7482 l_header.customer_site_id := p_customer_site_id;
7483
7484 --Bug #4147209 - Populate the header record with the DFF attribute category
7485 --and segment values passed from the mobile UI
7486 l_header.attribute_category := p_attribute_category;
7487 l_header.attribute1 := p_attribute1;
7488 l_header.attribute2 := p_attribute2;
7489 l_header.attribute3 := p_attribute3;
7490 l_header.attribute4 := p_attribute4;
7491 l_header.attribute5 := p_attribute5;
7492 l_header.attribute6 := p_attribute6;
7493 l_header.attribute7 := p_attribute7;
7494 l_header.attribute8 := p_attribute8;
7495 l_header.attribute9 := p_attribute9;
7496 l_header.attribute10 := p_attribute10;
7497 l_header.attribute10 := p_attribute10;
7498 l_header.attribute11 := p_attribute11;
7499 l_header.attribute12 := p_attribute12;
7500 l_header.attribute13 := p_attribute13;
7501 l_header.attribute14 := p_attribute14;
7502 l_header.attribute15 := p_attribute15;
7503
7504 IF (l_debug = 1) THEN
7505 print_debug('rcv_insert_header_interface 20: before rcv_shipment_headers_pkg.insert_row ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7506 , 1);
7507 END IF;
7508
7509 l_progress := '20';
7510
7511 IF g_header_intf_id IS NULL THEN
7512 SELECT rcv_headers_interface_s.NEXTVAL
7513 INTO g_header_intf_id
7514 FROM SYS.DUAL;
7515 END IF;
7516
7517 l_progress := '25';
7518
7519 INSERT INTO rcv_headers_interface
7520 (
7521 header_interface_id
7522 , group_id
7523 , processing_status_code
7524 , transaction_type
7525 , validation_flag
7526 , auto_transact_code
7527 , last_update_date
7528 , last_updated_by
7529 , creation_date
7530 , created_by
7531 , last_update_login
7532 , receipt_source_code
7533 , vendor_id
7534 , vendor_site_id
7535 , ship_to_organization_id
7536 , shipment_num
7537 , receipt_num
7538 , bill_of_lading
7539 , packing_slip
7540 , shipped_date
7541 , freight_carrier_code
7542 , expected_receipt_date
7543 , employee_id
7544 , num_of_containers
7545 , waybill_airbill_num
7546 , comments
7547 , attribute_category
7548 , attribute1
7549 , attribute2
7550 , attribute3
7551 , attribute4
7552 , attribute5
7553 , attribute6
7554 , attribute7
7555 , attribute8
7556 , attribute9
7557 , attribute10
7558 , attribute11
7559 , attribute12
7560 , attribute13
7561 , attribute14
7562 , attribute15
7563 , usggl_transaction_code
7564 , processing_request_id
7565 , customer_id
7566 , customer_site_id
7567 )
7568 VALUES (
7569 g_header_intf_id
7570 , inv_rcv_common_apis.g_rcv_global_var.interface_group_id
7571 , 'PENDING' -- processing_status_code
7572 , 'NEW' -- transaction_type
7573 , 'Y' -- validation_flag
7574 , 'RECEIVE' -- auto_transact_code
7575 , l_header.last_update_date
7576 , l_header.last_updated_by
7577 , l_header.creation_date
7578 , l_header.created_by
7579 , l_header.last_update_login
7580 , NVL(l_header.receipt_source_code, 'VENDOR')
7581 , l_header.vendor_id
7582 , l_header.vendor_site_id
7583 , l_header.ship_to_organization_id
7584 , l_header.shipment_num
7585 , l_header.receipt_num
7586 , l_header.bill_of_lading
7587 , l_header.packing_slip
7588 , l_header.shipped_date
7589 , l_header.freight_carrier_code
7590 , l_header.expected_receipt_date
7591 , l_header.employee_id
7592 , l_header.num_of_containers
7593 , l_header.waybill_airbill_num
7594 , l_header.comments
7595 , l_header.attribute_category
7596 , l_header.attribute1
7597 , l_header.attribute2
7598 , l_header.attribute3
7599 , l_header.attribute4
7600 , l_header.attribute5
7601 , l_header.attribute6
7602 , l_header.attribute7
7603 , l_header.attribute8
7604 , l_header.attribute9
7605 , l_header.attribute10
7606 , l_header.attribute11
7607 , l_header.attribute12
7608 , l_header.attribute13
7609 , l_header.attribute14
7610 , l_header.attribute15
7611 , l_header.usggl_transaction_code
7612 , l_header.processing_request_id
7613 , l_header.customer_id
7614 , l_header.customer_site_id
7615 );
7616
7617 l_progress := '30';
7618
7619 IF (l_debug = 1) THEN
7620 print_debug('rcv_insert_header_interface 30: after insert_row ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7621 END IF;
7622
7623 p_receipt_num := l_header.receipt_num;
7624
7625 IF (l_debug = 1) THEN
7626 print_debug('rcv_insert_header_interface 40: before rcv_update_rti_from_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
7627 END IF;
7628
7629 EXCEPTION
7630 WHEN fnd_api.g_exc_error THEN
7631 ROLLBACK TO rcv_insert_ship_header_sp;
7632 x_return_status := fnd_api.g_ret_sts_error;
7633
7634 IF (l_debug = 1) THEN
7635 print_debug('INV_RCV_STD_RCPT_APIS.rcv_insert_header_interface 50.1: RAISE FND_API.G_EXC_ERROR;' || l_progress, 4);
7636 END IF;
7637
7638 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7639 WHEN fnd_api.g_exc_unexpected_error THEN
7640 ROLLBACK TO rcv_insert_ship_header_sp;
7641 x_return_status := fnd_api.g_ret_sts_unexp_error;
7642
7643 IF (l_debug = 1) THEN
7644 print_debug('INV_RCV_STD_RCPT_APIS.rcv_insert_header_interface 50.2: RAISE FND_API.G_EXC_ERROR;' || l_progress, 4);
7645 END IF;
7646
7647 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7648 WHEN OTHERS THEN
7649 ROLLBACK TO rcv_insert_ship_header_sp;
7650 x_return_status := fnd_api.g_ret_sts_unexp_error;
7651
7652 IF SQLCODE IS NOT NULL THEN
7653 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.rcv_insert_header_interface', l_progress, SQLCODE);
7654 END IF;
7655
7656 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7657 END rcv_insert_header_interface;
7658
7659 PROCEDURE rcv_update_header_interface(
7660 p_organization_id NUMBER
7661 , p_header_intf_id NUMBER
7662 , p_source_type VARCHAR2
7663 , p_receipt_num VARCHAR2
7664 , p_vendor_id NUMBER
7665 , p_vendor_site_id NUMBER
7666 , p_shipment_num VARCHAR2
7667 , p_ship_to_location_id NUMBER
7668 , p_bill_of_lading VARCHAR2
7669 , p_packing_slip VARCHAR2
7670 , p_shipped_date DATE
7671 , p_freight_carrier_code VARCHAR2
7672 , p_expected_receipt_date DATE
7673 , p_num_of_containers NUMBER
7674 , p_waybill_airbill_num VARCHAR2
7675 , p_comments VARCHAR2
7676 , p_ussgl_transaction_code VARCHAR2
7677 , p_program_request_id NUMBER
7678 , p_customer_id NUMBER
7679 , p_customer_site_id NUMBER
7680 , x_return_status OUT NOCOPY VARCHAR2
7681 , x_msg_count OUT NOCOPY NUMBER
7682 , x_msg_data OUT NOCOPY VARCHAR2
7683 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209
7684 , p_attribute1 IN VARCHAR2 DEFAULT NULL
7685 , p_attribute2 IN VARCHAR2 DEFAULT NULL
7686 , p_attribute3 IN VARCHAR2 DEFAULT NULL
7687 , p_attribute4 IN VARCHAR2 DEFAULT NULL
7688 , p_attribute5 IN VARCHAR2 DEFAULT NULL
7689 , p_attribute6 IN VARCHAR2 DEFAULT NULL
7690 , p_attribute7 IN VARCHAR2 DEFAULT NULL
7691 , p_attribute8 IN VARCHAR2 DEFAULT NULL
7692 , p_attribute9 IN VARCHAR2 DEFAULT NULL
7693 , p_attribute10 IN VARCHAR2 DEFAULT NULL
7694 , p_attribute11 IN VARCHAR2 DEFAULT NULL
7695 , p_attribute12 IN VARCHAR2 DEFAULT NULL
7696 , p_attribute13 IN VARCHAR2 DEFAULT NULL
7697 , p_attribute14 IN VARCHAR2 DEFAULT NULL
7698 , p_attribute15 IN VARCHAR2 DEFAULT NULL
7699 ) IS
7700
7701 l_sysdate DATE := SYSDATE;
7702 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
7703 l_msg_count NUMBER;
7704 l_msg_data VARCHAR2(4000);
7705 l_progress VARCHAR2(10);
7706 l_check_asn VARCHAR2(25);--Bug 4551595
7707 l_vendor_site_id NUMBER; --bug9409867
7708
7709 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
7710 BEGIN
7711 -- receving api is using row_id in where clause
7712 -- so query row_id based on shipment_header_id
7713 IF (l_debug = 1) THEN
7714 print_debug('rcv_update_header_interface 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7715 END IF;
7716
7717 l_progress := '10';
7718 x_return_status := fnd_api.g_ret_sts_success;
7719 SAVEPOINT rcv_update_ship_header_sp;
7720 l_progress := '20';
7721
7722 IF (l_debug = 1) THEN
7723 print_debug('rcv_update_header_interface 20: before update_row ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7724 , 4);
7725 END IF;
7726 --bug9409867,if vendor_site_id not passed from caller,then we should fetch vendor_site_id from rsh.
7727 l_vendor_site_id := p_vendor_site_id;
7728 --bug9588190,for bug9409867 fix,it is only for ASN receipt,it should be owned by source type='VENDOR' .
7729 if(nvl(l_vendor_site_id,-1)=-1 and p_source_type='VENDOR') then
7730 SELECT vendor_site_id
7731 INTO l_vendor_site_id
7732 FROM rcv_shipment_headers
7733 WHERE shipment_header_id = g_shipment_header_id;
7734 end if;
7735 --bug9409867 end
7736 l_progress := '40';
7737 UPDATE rcv_headers_interface
7738 SET customer_id = Nvl(p_customer_id, customer_id)
7739 , last_update_date = l_sysdate
7740 , last_update_login = NVL(inv_rcv_common_apis.g_po_startup_value.user_id, last_update_login)
7741 , last_updated_by = NVL(inv_rcv_common_apis.g_po_startup_value.user_id, last_updated_by)
7742 , vendor_id = NVL(p_vendor_id, vendor_id)
7743 , vendor_site_id = NVL(l_vendor_site_id, vendor_site_id)--bug9409867
7744 , ship_to_organization_id = NVL(p_organization_id, ship_to_organization_id)
7745 , receipt_num = NVL(p_receipt_num, receipt_num)
7746 , bill_of_lading = p_bill_of_lading
7747 , waybill_airbill_num = Nvl(p_waybill_airbill_num,waybill_airbill_num)--BUG 5111375 (FP of BUG 4500055)
7748 , packing_slip = p_packing_slip
7749 , shipped_date = NVL(p_shipped_date, shipped_date)
7750 , freight_carrier_code = p_freight_carrier_code
7751 , expected_receipt_date = NVL(p_expected_receipt_date, expected_receipt_date)
7752 , employee_id = NVL(inv_rcv_common_apis.g_po_startup_value.employee_id, employee_id)
7753 , num_of_containers = NVL(p_num_of_containers, num_of_containers)
7754 , comments = p_comments
7755 , attribute_category = p_attribute_category
7756 , attribute1 = p_attribute1
7757 , attribute2 = p_attribute2
7758 , attribute3 = p_attribute3
7759 , attribute4 = p_attribute4
7760 , attribute5 = p_attribute5
7761 , attribute6 = p_attribute6
7762 , attribute7 = p_attribute7
7763 , attribute8 = p_attribute8
7764 , attribute9 = p_attribute9
7765 , attribute10 = p_attribute10
7766 , attribute11 = p_attribute11
7767 , attribute12 = p_attribute12
7768 , attribute13 = p_attribute13
7769 , attribute14 = p_attribute14
7770 , attribute15 = p_attribute15
7771 WHERE header_interface_id = p_header_intf_id;
7772
7773 l_progress := '50';
7774
7775 IF (l_debug = 1) THEN
7776 print_debug(
7777 'rcv_update_header_interface 30: after update_row before rcv_update_rti_from_header '
7778 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7779 , 4
7780 );
7781 END IF;
7782
7783 rcv_update_rti_from_header(
7784 p_shipment_num => p_shipment_num
7785 , p_freight_carrier_code => p_freight_carrier_code
7786 , p_bill_of_lading => p_bill_of_lading
7787 , p_packing_slip => p_packing_slip
7788 , p_num_of_containers => p_num_of_containers
7789 , p_waybill_airbill_num => p_waybill_airbill_num
7790 , x_return_status => l_return_status
7791 , x_msg_count => l_msg_count
7792 , x_msg_data => l_msg_data
7793 );
7794
7795 IF l_return_status = fnd_api.g_ret_sts_error THEN
7796 fnd_message.set_name('INV', 'INV_RCV_UPDATE_RTI_FAIL');
7797 fnd_msg_pub.ADD;
7798
7799 IF (l_debug = 1) THEN
7800 print_debug(
7801 'rcv_update_header_interface 30.1: rcv_update_rti_from_header RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7802 , 4
7803 );
7804 END IF;
7805
7806 RAISE fnd_api.g_exc_error;
7807 END IF;
7808
7809 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
7810 fnd_message.set_name('INV', 'INV_RCV_UPDATE_RTI_FAIL');
7811 fnd_msg_pub.ADD;
7812
7813 IF (l_debug = 1) THEN
7814 print_debug(
7815 'rcv_update_header_interface 30.2: rcv_update_rti_from_header RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
7816 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
7817 , 4
7818 );
7819 END IF;
7820
7821 RAISE fnd_api.g_exc_unexpected_error;
7822 END IF;
7823
7824 IF (l_debug = 1) THEN
7825 print_debug('rcv_update_header_interface 40: after rcv_update_rti_from_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
7826 END IF;
7827
7828 --BUG 4563411:Added the call to the new procedure to update
7829 --wms_asn_Details for the item
7830 BEGIN
7831 SELECT NVL(ASN_TYPE,'@@@')
7832 INTO l_check_asn
7833 FROM rcv_shipment_headers
7834 WHERE shipment_header_id = g_shipment_header_id;
7835 EXCEPTION
7836 WHEN OTHERS THEN
7837 IF (l_debug = 1) THEN
7838 print_debug('No RSH found. SQLCODE:'||SQLCODE||' SQLERRM:'||Sqlerrm,4);
7839 END IF;
7840 l_check_asn := '@@@';
7841 END;
7842
7843 IF l_check_asn ='ASN' THEN
7844
7845 IF (l_debug = 1) THEN
7846 print_debug('In type ASN before call to new procedure', 4);
7847 print_debug('group_id:'||inv_rcv_common_apis.g_rcv_global_var.interface_group_id,4);
7848 END IF;
7849
7850 --Calling the procedure
7851 INV_CR_ASN_DETAILS.update_asn_item_details
7852 (p_group_id=>inv_rcv_common_apis.g_rcv_global_var.interface_group_id);
7853
7854 IF (l_debug = 1) THEN
7855 print_debug('In type ASN after call to new procedure.', 4);
7856 print_debug('# of WAD updated:'||SQL%rowcount,4);
7857 END IF;
7858 END IF;
7859 --End of fix for Bug 4563411
7860
7861 EXCEPTION
7862 WHEN fnd_api.g_exc_error THEN
7863 ROLLBACK TO rcv_update_ship_header_sp;
7864
7865 x_return_status := fnd_api.g_ret_sts_error;
7866 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7867 WHEN fnd_api.g_exc_unexpected_error THEN
7868 ROLLBACK TO rcv_update_ship_header_sp;
7869
7870 x_return_status := fnd_api.g_ret_sts_unexp_error;
7871 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7872 WHEN OTHERS THEN
7873 ROLLBACK TO rcv_update_ship_header_sp;
7874 x_return_status := fnd_api.g_ret_sts_unexp_error;
7875
7876 IF SQLCODE IS NOT NULL THEN
7877 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.rcv_update_header_interface', l_progress, SQLCODE);
7878 END IF;
7879
7880 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7881 END rcv_update_header_interface;
7882
7883 PROCEDURE rcv_insert_update_header(
7884 p_organization_id IN NUMBER
7885 , p_shipment_header_id IN OUT NOCOPY NUMBER
7886 , p_source_type IN VARCHAR2
7887 , p_receipt_num IN OUT NOCOPY VARCHAR2
7888 , p_vendor_id IN NUMBER
7889 , p_vendor_site_id IN NUMBER
7890 , p_shipment_num IN VARCHAR2
7891 , p_ship_to_location_id IN NUMBER
7892 , p_bill_of_lading IN VARCHAR2
7893 , p_packing_slip IN VARCHAR2
7894 , p_shipped_date IN DATE
7895 , p_freight_carrier_code IN VARCHAR2
7896 , p_expected_receipt_date IN DATE
7897 , p_num_of_containers IN NUMBER
7898 , p_waybill_airbill_num IN VARCHAR2
7899 , p_comments IN VARCHAR2
7900 , p_ussgl_transaction_code IN VARCHAR2
7901 , p_government_context IN VARCHAR2
7902 , p_request_id IN NUMBER
7903 , p_program_application_id IN NUMBER
7904 , p_program_id IN NUMBER
7905 , p_program_update_date IN DATE
7906 , p_customer_id IN NUMBER
7907 , p_customer_site_id IN NUMBER
7908 , x_return_status OUT NOCOPY VARCHAR2
7909 , x_msg_count OUT NOCOPY NUMBER
7910 , x_msg_data OUT NOCOPY VARCHAR2
7911 , p_attribute_category IN VARCHAR2 DEFAULT NULL --Bug #4147209 - Added DFF cols
7912 , p_attribute1 IN VARCHAR2 DEFAULT NULL
7913 , p_attribute2 IN VARCHAR2 DEFAULT NULL
7914 , p_attribute3 IN VARCHAR2 DEFAULT NULL
7915 , p_attribute4 IN VARCHAR2 DEFAULT NULL
7916 , p_attribute5 IN VARCHAR2 DEFAULT NULL
7917 , p_attribute6 IN VARCHAR2 DEFAULT NULL
7918 , p_attribute7 IN VARCHAR2 DEFAULT NULL
7919 , p_attribute8 IN VARCHAR2 DEFAULT NULL
7920 , p_attribute9 IN VARCHAR2 DEFAULT NULL
7921 , p_attribute10 IN VARCHAR2 DEFAULT NULL
7922 , p_attribute11 IN VARCHAR2 DEFAULT NULL
7923 , p_attribute12 IN VARCHAR2 DEFAULT NULL
7924 , p_attribute13 IN VARCHAR2 DEFAULT NULL
7925 , p_attribute14 IN VARCHAR2 DEFAULT NULL
7926 , p_attribute15 IN VARCHAR2 DEFAULT NULL
7927 ) IS
7928 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
7929 l_msg_count NUMBER;
7930 l_msg_data VARCHAR2(4000);
7931 l_progress VARCHAR2(10);
7932 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
7933 -- Changes for BUG 3630412
7934 l_label_status VARCHAR2(500);
7935 l_txn_id_tbl inv_label.transaction_id_rec_type;
7936 l_counter NUMBER := 0;
7937 l_receipt_number VARCHAR2(30);
7938 CURSOR c_rti_txn_id(p_shipment_header_id NUMBER) IS
7939 SELECT rti.interface_transaction_id
7940 FROM rcv_transactions_interface rti
7941 WHERE rti.shipment_header_id = p_shipment_header_id;
7942 BEGIN
7943 l_progress := '10';
7944 l_receipt_number := p_receipt_num; --bug 3630412
7945 x_return_status := fnd_api.g_ret_sts_success;
7946
7947 IF p_shipment_header_id IS NULL THEN
7948 IF (l_debug = 1) THEN
7949 print_debug('rcv_insert_update_header 10: before calling rcv_insert_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
7950 END IF;
7951
7952 -- insert RHI else insert RSH
7953 IF (l_debug = 1) THEN
7954 print_debug('Calling to insert RHI for J code', 4);
7955 END IF;
7956 rcv_insert_header_interface(
7957 p_organization_id => p_organization_id
7958 , p_source_type => p_source_type
7959 , p_receipt_num => p_receipt_num
7960 , p_vendor_id => p_vendor_id
7961 , p_vendor_site_id => p_vendor_site_id
7962 , p_shipment_num => p_shipment_num
7963 , p_ship_to_location_id => p_ship_to_location_id
7964 , p_bill_of_lading => p_bill_of_lading
7965 , p_packing_slip => p_packing_slip
7966 , p_shipped_date => p_shipped_date
7967 , p_freight_carrier_code => p_freight_carrier_code
7968 , p_expected_receipt_date => p_expected_receipt_date
7969 , p_num_of_containers => p_num_of_containers
7970 , p_waybill_airbill_num => p_waybill_airbill_num
7971 , p_comments => p_comments
7972 , p_ussgl_transaction_code => p_ussgl_transaction_code
7973 , p_government_context => p_government_context
7974 , p_request_id => p_request_id
7975 , p_program_application_id => p_program_application_id
7976 , p_program_id => p_program_id
7977 , p_program_update_date => p_program_update_date
7978 , p_customer_id => p_customer_id
7979 , p_customer_site_id => p_customer_site_id
7980 , x_return_status => l_return_status
7981 , x_msg_count => l_msg_count
7982 , x_msg_data => l_msg_data
7983 , p_attribute_category => p_attribute_category --Bug #4147209
7984 , p_attribute1 => p_attribute1
7985 , p_attribute2 => p_attribute2
7986 , p_attribute3 => p_attribute3
7987 , p_attribute4 => p_attribute4
7988 , p_attribute5 => p_attribute5
7989 , p_attribute6 => p_attribute6
7990 , p_attribute7 => p_attribute7
7991 , p_attribute8 => p_attribute8
7992 , p_attribute9 => p_attribute9
7993 , p_attribute10 => p_attribute10
7994 , p_attribute11 => p_attribute11
7995 , p_attribute12 => p_attribute12
7996 , p_attribute13 => p_attribute13
7997 , p_attribute14 => p_attribute14
7998 , p_attribute15 => p_attribute15
7999 );
8000
8001 IF (l_debug = 1) THEN
8002 print_debug('rcv_insert_update_header 20: after calling rcv_insert_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8003 END IF;
8004
8005 IF l_return_status = fnd_api.g_ret_sts_error THEN
8006 fnd_message.set_name('INV', 'INV_RCV_INS_SHIP_HDR_FAIL');
8007 fnd_msg_pub.ADD;
8008
8009 IF (l_debug = 1) THEN
8010 print_debug(
8011 'rcv_insert_update_header 20.1: rcv_insert_header RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8012 , 4
8013 );
8014 END IF;
8015
8016 RAISE fnd_api.g_exc_error;
8017 END IF;
8018
8019 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8020 fnd_message.set_name('INV', 'INV_RCV_INS_SHIP_HDR_FAIL');
8021 fnd_msg_pub.ADD;
8022
8023 IF (l_debug = 1) THEN
8024 print_debug(
8025 'rcv_insert_update_header 20.2: rcv_insert_header RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8026 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8027 , 4
8028 );
8029 END IF;
8030
8031 RAISE fnd_api.g_exc_unexpected_error;
8032 END IF;
8033
8034 -- to pass back the shipment header id that was created.
8035
8036 --The header_interface_id should be passed back to the UI as
8037 --the ui will always INSERT a rhi ON pageentered which should be always
8038 --updated ON processtxn FROM rcptInfoPage
8039 IF (l_debug = 1) THEN
8040 print_debug('Setting the lpn_group_id and validation_flag for J code', 4);
8041 END IF;
8042 p_shipment_header_id := g_header_intf_id;
8043
8044 l_progress := '20';
8045 ELSE
8046 IF (l_debug = 1) THEN
8047 print_debug('rcv_insert_update_header 30: before calling rcv_update_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8048 END IF;
8049
8050 --If INV and PO J are installed,
8051 -- then update RHI else update RSH
8052 IF (l_debug = 1) THEN
8053 print_debug('Calling to insert RHI for J code', 4);
8054 END IF;
8055 rcv_update_header_interface
8056 (
8057 p_organization_id => p_organization_id
8058 , p_header_intf_id => p_shipment_header_id
8059 , p_source_type => p_source_type
8060 , p_receipt_num => p_receipt_num
8061 , p_vendor_id => p_vendor_id
8062 , p_vendor_site_id => p_vendor_site_id
8063 , p_shipment_num => p_shipment_num
8064 , p_ship_to_location_id => p_ship_to_location_id
8065 , p_bill_of_lading => p_bill_of_lading
8066 , p_packing_slip => p_packing_slip
8067 , p_shipped_date => p_shipped_date
8068 , p_freight_carrier_code => p_freight_carrier_code
8069 , p_expected_receipt_date => p_expected_receipt_date
8070 , p_num_of_containers => p_num_of_containers
8071 , p_waybill_airbill_num => p_waybill_airbill_num
8072 , p_comments => p_comments
8073 , p_ussgl_transaction_code => p_ussgl_transaction_code
8074 , p_program_request_id => p_request_id
8075 , p_customer_id => p_customer_id
8076 , p_customer_site_id => p_customer_site_id
8077 , x_return_status => l_return_status
8078 , x_msg_count => l_msg_count
8079 , x_msg_data => l_msg_data
8080 , p_attribute_category => p_attribute_category --Bug #4147209
8081 , p_attribute1 => p_attribute1
8082 , p_attribute2 => p_attribute2
8083 , p_attribute3 => p_attribute3
8084 , p_attribute4 => p_attribute4
8085 , p_attribute5 => p_attribute5
8086 , p_attribute6 => p_attribute6
8087 , p_attribute7 => p_attribute7
8088 , p_attribute8 => p_attribute8
8089 , p_attribute9 => p_attribute9
8090 , p_attribute10 => p_attribute10
8091 , p_attribute11 => p_attribute11
8092 , p_attribute12 => p_attribute12
8093 , p_attribute13 => p_attribute13
8094 , p_attribute14 => p_attribute14
8095 , p_attribute15 => p_attribute15
8096 );
8097
8098 IF (l_debug = 1) THEN
8099 print_debug('rcv_insert_update_header 40: after calling rcv_update_header ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8100 END IF;
8101
8102 IF l_return_status = fnd_api.g_ret_sts_error THEN
8103 fnd_message.set_name('INV', 'INV_RCV_UPD_SHIP_HDR_FAIL');
8104 fnd_msg_pub.ADD;
8105
8106 IF (l_debug = 1) THEN
8107 print_debug(
8108 'rcv_insert_update_header 40.1: rcv_update_header RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8109 , 4
8110 );
8111 END IF;
8112
8113 RAISE fnd_api.g_exc_error;
8114 END IF;
8115
8116 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8117 fnd_message.set_name('INV', 'INV_RCV_UPD_SHIP_HDR_FAIL');
8118 fnd_msg_pub.ADD;
8119
8120 IF (l_debug = 1) THEN
8121 print_debug(
8122 'rcv_insert_update_header 40.2: rcv_update_header RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8123 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8124 , 4
8125 );
8126 END IF;
8127
8128 RAISE fnd_api.g_exc_unexpected_error;
8129 END IF;
8130
8131 l_progress := '30';
8132 END IF;
8133 IF (l_debug = 1) THEN
8134 print_debug('Exit rcv_insert_update_header 50: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8135 END IF;
8136 EXCEPTION
8137 WHEN fnd_api.g_exc_error THEN
8138 x_return_status := fnd_api.g_ret_sts_error;
8139 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8140 WHEN fnd_api.g_exc_unexpected_error THEN
8141 x_return_status := fnd_api.g_ret_sts_unexp_error;
8142 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8143 WHEN OTHERS THEN
8144 x_return_status := fnd_api.g_ret_sts_unexp_error;
8145
8146 IF SQLCODE IS NOT NULL THEN
8147 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.rcv_update_insert_header', l_progress, SQLCODE);
8148 END IF;
8149
8150 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8151 END rcv_insert_update_header;
8152
8153 PROCEDURE packunpack_container(
8154 p_api_version IN NUMBER
8155 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
8156 , p_commit IN VARCHAR2 := fnd_api.g_false
8157 , x_return_status OUT NOCOPY VARCHAR2
8158 , x_msg_count OUT NOCOPY NUMBER
8159 , x_msg_data OUT NOCOPY VARCHAR2
8160 , p_from_lpn_id IN NUMBER := NULL
8161 , p_lpn_id IN NUMBER
8162 , p_content_lpn_id IN NUMBER := NULL
8163 , p_content_item_id IN NUMBER := NULL
8164 , p_content_item_desc IN VARCHAR2 := NULL
8165 , p_revision IN VARCHAR2 := NULL
8166 , p_lot_number IN VARCHAR2 := NULL
8167 , p_from_serial_number IN VARCHAR2 := NULL
8168 , p_to_serial_number IN VARCHAR2 := NULL
8169 , p_quantity IN NUMBER := NULL
8170 , p_uom IN VARCHAR2 := NULL
8171 , p_organization_id IN NUMBER
8172 , p_subinventory IN VARCHAR2 := NULL
8173 , p_locator_id IN NUMBER := NULL
8174 , p_enforce_wv_constraints IN NUMBER := 2
8175 , p_operation IN NUMBER
8176 , p_cost_group_id IN NUMBER := NULL
8177 , p_source_type_id IN NUMBER := NULL
8178 , p_source_header_id IN NUMBER := NULL
8179 , p_source_name IN VARCHAR2 := NULL
8180 , p_source_line_id IN NUMBER := NULL
8181 , p_source_line_detail_id IN NUMBER := NULL
8182 , p_homogeneous_container IN NUMBER := 2
8183 , p_match_locations IN NUMBER := 2
8184 , p_match_lpn_context IN NUMBER := 2
8185 , p_match_lot IN NUMBER := 2
8186 , p_match_cost_groups IN NUMBER := 2
8187 , p_match_mtl_status IN NUMBER := 2
8188 ) IS
8189 l_to_lpn_id NUMBER;
8190 l_to_lpn VARCHAR2(30);
8191 l_process_id NUMBER;
8192 l_lpn_rec wms_container_pub.lpn;
8193 l_quantity NUMBER;
8194 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
8195 l_msg_count NUMBER;
8196 l_msg_data VARCHAR2(4000);
8197 l_progress VARCHAR2(10);
8198 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8199 BEGIN
8200 IF (l_debug = 1) THEN
8201 print_debug('PackUnpack_Container 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8202 print_debug('Parameters passed : 10.1: p_from_lpn_id - ' || p_from_lpn_id, 4);
8203 print_debug('Parameters passed : 10.2: p_lpn_id - ' || p_lpn_id, 4);
8204 print_debug('Parameters passed : 10.3: p_content_item_id - ' || p_content_item_id, 4);
8205 print_debug('Parameters passed : 10.4: p_revision - ' || p_revision, 4);
8206 print_debug('Parameters passed : 10.5: p_lot_number - ' || p_lot_number, 4);
8207 print_debug('Parameters passed : 10.6: p_from_serial_number - ' || p_from_serial_number, 4);
8208 print_debug('Parameters passed : 10.7: p_to_serial_number - ' || p_to_serial_number, 4);
8209 print_debug('Parameters passed : 10.8: p_organization_id - ' || p_organization_id, 4);
8210 print_debug('Parameters passed : 10.9: p_quantity - ' || p_quantity, 4);
8211 END IF;
8212
8213 l_progress := '10';
8214 x_return_status := fnd_api.g_ret_sts_success;
8215 SAVEPOINT rcv_pack_unpack_sp;
8216 /* comment out unpack from LPN and generate dummy LPN code,
8217 since we are not doing discrepancy check at realy time any more. */
8218
8219 /* IF p_from_lpn_id = p_lpn_id
8220 AND g_dummy_lpn_id IS NULL THEN
8221 IF (l_debug = 1) THEN
8222 print_debug('PackUnpack_Container 2: generate dummy LPN '|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8223 END IF;
8224 -- generate a dummy lpn
8225 wms_container_pub.generate_lpn
8226 (p_api_version => 1.0,
8227 x_return_status => l_return_status,
8228 x_msg_count => l_msg_count,
8229 x_msg_data => l_msg_data,
8230 p_organization_id => p_organization_id,
8231 p_lpn_out => l_to_lpn,
8232 p_lpn_id_out => l_to_lpn_id,
8233 p_process_id => l_process_id,
8234 p_validation_level => FND_API.G_VALID_LEVEL_NONE
8235 );
8236
8237 l_progress := '20';
8238
8239 g_dummy_lpn_id := l_to_lpn_id;
8240
8241 IF l_return_status = FND_API.g_ret_sts_error THEN
8242 FND_MESSAGE.SET_NAME('WMS', 'WMS_LPN_GENERATION_FAIL');
8243 FND_MSG_PUB.ADD;
8244 IF (l_debug = 1) THEN
8245 print_debug('PackUnpack_Container 2.1: generate dummy LPN RAISE FND_API.G_EXC_ERROR;'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8246 END IF;
8247 RAISE FND_API.G_EXC_ERROR;
8248 END IF;
8249
8250 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8251 FND_MESSAGE.SET_NAME('WMS', 'WMS_LPN_GENERATION_FAIL');
8252 FND_MSG_PUB.ADD;
8253 IF (l_debug = 1) THEN
8254 print_debug('PackUnpack_Container 2.2: generate dummy LPN RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8255 END IF;
8256 RAISE FND_API.g_exc_unexpected_error;
8257 END IF;
8258
8259
8260
8261 ELSIF g_dummy_lpn_id IS NOT NULL THEN
8262 IF (l_debug = 1) THEN
8263 print_debug('PackUnpack_Container 3: g_dummy_lpn_id = '|| g_dummy_lpn_id || ' ' || to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8264 END IF;
8265 l_to_lpn_id := g_dummy_lpn_id;
8266 ELSE
8267 IF (l_debug = 1) THEN
8268 print_debug('PackUnpack_Container 4: l_to_lpn_id = '|| l_to_lpn_id || ' ' || to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8269 END IF;
8270 l_to_lpn_id := p_lpn_id;
8271 END IF;
8272
8273 */
8274 l_to_lpn_id := p_lpn_id;
8275 l_progress := '30';
8276
8277 IF (l_debug = 1) THEN
8278 print_debug(
8279 'PackUnpack_Container 5: before calling WMS_Container_PUB.PackUnpack_Container ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8280 , 4
8281 );
8282 END IF;
8283
8284 IF p_from_serial_number IS NULL THEN
8285 l_quantity := p_quantity;
8286 ELSE
8287 l_quantity := NULL;
8288 END IF;
8289
8290 IF (l_debug = 1) THEN
8291 print_debug('PackUnpack_Container 5.1: qty - ' || l_quantity, 4);
8292 END IF;
8293
8294 wms_container_pub.packunpack_container(
8295 p_api_version => p_api_version
8296 , p_init_msg_list => p_init_msg_list
8297 , p_commit => p_commit
8298 , x_return_status => l_return_status
8299 , x_msg_count => l_msg_count
8300 , x_msg_data => l_msg_data
8301 , p_lpn_id => l_to_lpn_id
8302 , p_content_lpn_id => p_content_lpn_id
8303 , p_content_item_id => p_content_item_id
8304 , p_content_item_desc => p_content_item_desc
8305 , p_revision => p_revision
8306 , p_lot_number => p_lot_number
8307 , p_from_serial_number => p_from_serial_number
8308 , p_to_serial_number => p_to_serial_number
8309 , p_quantity => l_quantity
8310 , p_uom => p_uom
8311 , p_organization_id => p_organization_id
8312 , p_subinventory => p_subinventory
8313 , p_locator_id => p_locator_id
8314 , p_enforce_wv_constraints => p_enforce_wv_constraints
8315 , p_operation => p_operation
8316 , p_cost_group_id => p_cost_group_id
8317 , p_source_type_id => p_source_type_id
8318 , p_source_header_id => inv_rcv_common_apis.g_rcv_global_var.interface_group_id
8319 , p_source_name => p_source_name
8320 , p_source_line_id => p_source_line_id
8321 , p_source_line_detail_id => p_source_line_detail_id
8322 , p_homogeneous_container => p_homogeneous_container
8323 , p_match_locations => p_match_locations
8324 , p_match_lpn_context => p_match_lpn_context
8325 , p_match_lot => p_match_lot
8326 , p_match_cost_groups => p_match_cost_groups
8327 , p_match_mtl_status => p_match_mtl_status
8328 , p_validation_level => fnd_api.g_valid_level_none
8329 , p_concurrent_pack => 1
8330 /* uncomment after changes to WMSCONTB.pls are complete
8331 , p_secondary_qty => p_secondary_qty --OPM Convergence
8332 , p_secondary_uom => p_secondary_uom --OPM Convergence */
8333 );
8334 l_progress := '40';
8335
8336 IF l_return_status = fnd_api.g_ret_sts_error THEN
8337 fnd_message.set_name('WMS', 'WMS_PACK_CONTAINER_FAIL'); -- cannot pack LPN MSGTBD
8338 fnd_msg_pub.ADD;
8339
8340 IF (l_debug = 1) THEN
8341 print_debug(
8342 'PackUnpack_Container 5.1: WMS_Container_PUB.PackUnpack_Container RAISE FND_API.G_EXC_ERROR;'
8343 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8344 , 4
8345 );
8346 END IF;
8347
8348 RAISE fnd_api.g_exc_error;
8349 END IF;
8350
8351 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8352 fnd_message.set_name('WMS', 'WMS_PACK_CONTAINER_FAIL');
8353 fnd_msg_pub.ADD;
8354
8355 IF (l_debug = 1) THEN
8356 print_debug(
8357 'PackUnpack_Container 5.2: WMS_Container_PUB.PackUnpack_Container FND_API.G_EXC_UNEXPECTED_ERROR;'
8358 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8359 , 4
8360 );
8361 END IF;
8362
8363 RAISE fnd_api.g_exc_unexpected_error;
8364 END IF;
8365
8366 IF (l_debug = 1) THEN
8367 print_debug(
8368 'PackUnpack_Container 6: after calling WMS_Container_PUB.PackUnpack_Container ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8369 , 4
8370 );
8371 END IF;
8372
8373 /*
8374 IF l_return_status = fnd_api.g_ret_sts_success
8375 AND p_from_lpn_id IS NOT NULL
8376 AND p_from_lpn_id <> 0 THEN
8377 -- unpack the from lpn
8378
8379 IF (l_debug = 1) THEN
8380 print_debug('PackUnpack_Container 7: before calling WMS_Container_PUB.PackUnpack_Container for unpack - lpn_id = ' || p_from_lpn_id ||' ' || to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8381 END IF;
8382
8383
8384 WMS_Container_PUB.PackUnpack_Container
8385 (p_api_version => p_api_version,
8386 p_init_msg_list => p_init_msg_list,
8387 p_commit => p_commit,
8388 x_return_status => l_return_status,
8389 x_msg_count => l_msg_count,
8390 x_msg_data => l_msg_data,
8391 p_lpn_id => p_from_lpn_id,
8392 p_content_lpn_id => p_content_lpn_id,
8393 p_content_item_id => p_content_item_id,
8394 p_content_item_desc => p_content_item_desc,
8395 p_revision => p_revision,
8396 p_lot_number => p_lot_number,
8397 p_from_serial_number => p_from_serial_number,
8398 p_to_serial_number => p_to_serial_number,
8399 p_quantity => l_quantity,
8400 p_uom => p_uom,
8401 p_organization_id => p_organization_id,
8402 p_subinventory => p_subinventory,
8403 p_locator_id => p_locator_id,
8404 p_enforce_wv_constraints => p_enforce_wv_constraints,
8405 p_operation => 2, -- unpack flag
8406 p_cost_group_id => p_cost_group_id,
8407 p_source_type_id => p_source_type_id,
8408 p_source_header_id => p_source_header_id,
8409 p_source_name => p_source_name,
8410 p_source_line_id => p_source_line_id,
8411 p_source_line_detail_id => p_source_line_detail_id,
8412 p_homogeneous_container => p_homogeneous_container,
8413 p_match_locations => p_match_locations,
8414 p_match_lpn_context => p_match_lpn_context,
8415 p_match_lot => p_match_lot,
8416 p_match_cost_groups => p_match_cost_groups,
8417 p_match_mtl_status => p_match_mtl_status,
8418 p_validation_level => FND_API.G_VALID_LEVEL_NONE
8419 );
8420
8421 l_progress := '50';
8422
8423 IF (l_debug = 1) THEN
8424 print_debug('PackUnpack_Container 8: after calling WMS_Container_PUB.PackUnpack_Container x_msg_data = '|| x_msg_data || ' ' || to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8425 END IF;
8426
8427 IF l_return_status = FND_API.g_ret_sts_error THEN
8428 FND_MESSAGE.SET_NAME('WMS', 'WMS_PACK_CONTAINER_FAIL'); -- cannot pack LPN MSGTBD
8429 FND_MSG_PUB.ADD;
8430 IF (l_debug = 1) THEN
8431 print_debug('PackUnpack_Container 8.1: - Unpack - WMS_Container_PUB.PackUnpack_Container RAISE FND_API.G_EXC_ERROR;'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8432 END IF;
8433 RAISE FND_API.G_EXC_ERROR;
8434 END IF;
8435
8436
8437 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8438 FND_MESSAGE.SET_NAME('WMS', 'WMS_PACK_CONTAINER_FAIL');
8439 FND_MSG_PUB.ADD;
8440 IF (l_debug = 1) THEN
8441 print_debug('PackUnpack_Container 8.2: - Unpack - WMS_Container_PUB.PackUnpack_Container FND_API.G_EXC_UNEXPECTED_ERROR;'|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8442 END IF;
8443 RAISE FND_API.g_exc_unexpected_error;
8444 END IF;
8445
8446 END IF;
8447 */
8448
8449
8450 /* move populating global record to process_lot
8451 -- populate the lot/qty data structure for lot split
8452 IF (p_lot_number IS NOT NULL AND Nvl(g_prev_lot_number,'@@@') <> p_lot_number) THEN
8453 IF (l_debug = 1) THEN
8454 print_debug('PackUnpack_Container 9: before calling populate_lot_rec '|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 4);
8455 END IF;
8456 g_prev_lot_number := p_lot_number;
8457
8458 l_progress := '60';
8459
8460 populate_lot_rec(p_lot_number => p_lot_number,
8461 p_primary_qty => p_quantity,
8462 p_txn_uom_code => p_uom,
8463 p_org_id => p_organization_id,
8464 p_item_id => p_content_item_id);
8465
8466 l_progress := '70';
8467
8468
8469 IF (l_debug = 1) THEN
8470 print_debug('PackUnpack_Container 10: after calling populate_lot_rec '|| to_char(sysdate, 'YYYY-MM-DD HH:DD:SS'), 1);
8471 END IF;
8472 END IF;
8473
8474 */
8475 IF l_return_status <> fnd_api.g_ret_sts_success THEN
8476 ROLLBACK TO rcv_pack_unpack_sp;
8477 END IF;
8478 EXCEPTION
8479 WHEN fnd_api.g_exc_error THEN
8480 ROLLBACK TO rcv_pack_unpack_sp;
8481 x_return_status := fnd_api.g_ret_sts_error;
8482 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8483 WHEN fnd_api.g_exc_unexpected_error THEN
8484 ROLLBACK TO rcv_pack_unpack_sp;
8485 x_return_status := fnd_api.g_ret_sts_unexp_error;
8486 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8487 WHEN OTHERS THEN
8488 ROLLBACK TO rcv_pack_unpack_sp;
8489 x_return_status := fnd_api.g_ret_sts_unexp_error;
8490
8491 IF SQLCODE IS NOT NULL THEN
8492 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.packunpack_container', l_progress, SQLCODE);
8493 END IF;
8494
8495 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8496 END packunpack_container;
8497
8498 PROCEDURE detect_asn_discrepancy(
8499 p_shipment_header_id NUMBER
8500 , p_lpn_id NUMBER
8501 , p_po_header_id NUMBER
8502 , x_discrepancy_flag OUT NOCOPY NUMBER
8503 , x_return_status OUT NOCOPY VARCHAR2
8504 , x_msg_count OUT NOCOPY NUMBER
8505 , x_msg_data OUT NOCOPY VARCHAR2
8506 ) IS
8507 CURSOR l_curs_remaining_asn IS --modified for bug 4951745
8508 SELECT 1
8509 FROM wms_lpn_contents_v lpnc, wms_license_plate_numbers lpn, rcv_shipment_headers rsh
8510 WHERE (lpn.source_header_id = rsh.shipment_header_id
8511 OR lpn.source_name = rsh.shipment_num)
8512 AND rsh.shipment_header_id = p_shipment_header_id
8513 AND (p_lpn_id IS NULL OR lpn.lpn_id=p_lpn_id)
8514 AND lpn.lpn_id = lpnc.parent_lpn_id
8515 AND(
8516 lpnc.source_line_id IN(SELECT pola.po_line_id
8517 FROM po_lines_all pola
8518 WHERE (p_po_header_id IS NULL OR pola.po_header_id=p_po_header_id)
8519 )
8520 OR lpnc.source_line_id IS NULL
8521 );
8522
8523 --Added for Bug 4951745
8524 CURSOR l_curs_remaining_asn_has_lpn IS
8525 SELECT 1
8526 FROM wms_lpn_contents_v lpnc, wms_license_plate_numbers lpn, rcv_shipment_headers rsh
8527 WHERE (lpn.source_header_id = rsh.shipment_header_id
8528 OR lpn.source_name = rsh.shipment_num)
8529 AND rsh.shipment_header_id = p_shipment_header_id
8530 AND lpn.lpn_id = p_lpn_id
8531 AND lpn.lpn_id = lpnc.parent_lpn_id
8532 AND(
8533 lpnc.source_line_id IN(SELECT pola.po_line_id
8534 FROM po_lines_all pola
8535 WHERE (p_po_header_id IS NULL OR pola.po_header_id=p_po_header_id)
8536 )
8537 OR lpnc.source_line_id IS NULL
8538 );
8539
8540 l_remaining_asn_line NUMBER;
8541 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
8542 l_msg_count NUMBER;
8543 l_msg_data VARCHAR2(4000);
8544 l_progress VARCHAR2(10);
8545 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8546 BEGIN
8547 IF (l_debug = 1) THEN
8548 print_debug('Enter detect_ASN_discrepancy 10 ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8549 print_debug('p_lpn_id ' || p_lpn_id , 1);
8550 END IF;
8551
8552 x_return_status := fnd_api.g_ret_sts_success;
8553 x_discrepancy_flag := 0;
8554 l_progress := '10';
8555
8556 IF p_lpn_id IS NULL THEN
8557 OPEN l_curs_remaining_asn;
8558 FETCH l_curs_remaining_asn INTO l_remaining_asn_line;
8559 l_progress := '20';
8560 CLOSE l_curs_remaining_asn;
8561 ELSE
8562 OPEN l_curs_remaining_asn_has_lpn;
8563 FETCH l_curs_remaining_asn_has_lpn INTO l_remaining_asn_line;
8564 l_progress := '30';
8565 CLOSE l_curs_remaining_asn_has_lpn;
8566 END IF;
8567
8568
8569 IF nvl(l_remaining_asn_line,0) > 0 THEN
8570 x_discrepancy_flag := 1;
8571 END IF;
8572
8573
8574 l_progress := '40';
8575
8576 IF (l_debug = 1) THEN
8577 print_debug(
8578 'About exit detect_ASN_discrepancy 20 - x_discrepancy_flag = '
8579 || x_discrepancy_flag
8580 || ' '
8581 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8582 , 1
8583 );
8584 END IF;
8585 EXCEPTION
8586 WHEN fnd_api.g_exc_error THEN
8587 IF l_curs_remaining_asn%ISOPEN THEN
8588 CLOSE l_curs_remaining_asn;
8589 END IF;
8590 IF l_curs_remaining_asn_has_lpn%ISOPEN THEN
8591 CLOSE l_curs_remaining_asn_has_lpn;
8592 END IF;
8593
8594 x_return_status := fnd_api.g_ret_sts_error;
8595 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8596 WHEN fnd_api.g_exc_unexpected_error THEN
8597 ROLLBACK TO rcv_insert_ship_header_sp;
8598
8599 IF l_curs_remaining_asn%ISOPEN THEN
8600 CLOSE l_curs_remaining_asn;
8601 END IF;
8602 IF l_curs_remaining_asn_has_lpn%ISOPEN THEN
8603 CLOSE l_curs_remaining_asn_has_lpn;
8604 END IF;
8605
8606 x_return_status := fnd_api.g_ret_sts_unexp_error;
8607 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8608 WHEN OTHERS THEN
8609 ROLLBACK TO rcv_insert_ship_header_sp;
8610
8611 IF l_curs_remaining_asn%ISOPEN THEN
8612 CLOSE l_curs_remaining_asn;
8613 END IF;
8614 IF l_curs_remaining_asn_has_lpn%ISOPEN THEN
8615 CLOSE l_curs_remaining_asn_has_lpn;
8616 END IF;
8617
8618 x_return_status := fnd_api.g_ret_sts_unexp_error;
8619
8620 IF SQLCODE IS NOT NULL THEN
8621 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.detect_ASN_discrepancy', l_progress, SQLCODE);
8622 END IF;
8623
8624 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8625 END detect_asn_discrepancy;
8626
8627 PROCEDURE remove_lpn_contents(
8628 p_lpn_id IN NUMBER
8629 , x_return_status OUT NOCOPY VARCHAR2
8630 , x_msg_count OUT NOCOPY NUMBER
8631 , x_msg_data OUT NOCOPY VARCHAR2
8632 , p_routing_id IN NUMBER DEFAULT NULL
8633 ) IS
8634 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
8635 l_msg_count NUMBER;
8636 l_msg_data VARCHAR2(4000);
8637 l_progress VARCHAR2(10);
8638 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8639 BEGIN
8640 IF (l_debug = 1) THEN
8641 print_debug('remove_lpn_contents 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8642 END IF;
8643
8644 l_progress := '10';
8645 x_return_status := fnd_api.g_ret_sts_success;
8646 SAVEPOINT rcv_remove_lpn_cont_sp;
8647
8648 -- delete the contents of the putaway LPN
8649 DELETE wms_lpn_contents
8650 WHERE parent_lpn_id = p_lpn_id;
8651
8652 -- clear serial numbers table
8653 UPDATE mtl_serial_numbers
8654 SET lpn_id = NULL
8655 WHERE lpn_id = p_lpn_id;
8656
8657 l_progress := '20';
8658
8659 -- update LPN context to receiving
8660 UPDATE wms_license_plate_numbers
8661 SET lpn_context = 5
8662 WHERE lpn_id = p_lpn_id;
8663
8664 l_progress := '30';
8665
8666 IF (l_debug = 1) THEN
8667 print_debug('remove_lpn_contents 20: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8668 END IF;
8669 EXCEPTION
8670 WHEN OTHERS THEN
8671 ROLLBACK TO rcv_remove_lpn_cont_sp;
8672 x_return_status := fnd_api.g_ret_sts_unexp_error;
8673
8674 IF SQLCODE IS NOT NULL THEN
8675 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.remove_lpn_contents', l_progress, SQLCODE);
8676 END IF;
8677
8678 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8679 END remove_lpn_contents;
8680
8681 PROCEDURE clear_lpn_for_ship(
8682 p_organization_id IN NUMBER
8683 , p_shipment_header_id IN NUMBER
8684 , x_return_status OUT NOCOPY VARCHAR2
8685 , x_msg_count OUT NOCOPY NUMBER
8686 , x_msg_data OUT NOCOPY VARCHAR2
8687 , p_routing_id IN NUMBER DEFAULT NULL
8688 ) IS
8689 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
8690 l_msg_count NUMBER;
8691 l_msg_data VARCHAR2(4000);
8692 l_progress VARCHAR2(10);
8693 l_asn_type VARCHAR2(10);
8694 l_lpn_id NUMBER;
8695 l_wms_enabled VARCHAR2(1);
8696
8697 CURSOR l_curs_lpn_for_ship IS
8698 SELECT lpn_id
8699 FROM wms_license_plate_numbers
8700 WHERE source_name = (SELECT shipment_num
8701 FROM rcv_shipment_headers
8702 WHERE shipment_header_id = p_shipment_header_id);
8703
8704 CURSOR l_curs_lpn_for_asn IS
8705 SELECT lpn_id
8706 FROM wms_license_plate_numbers
8707 WHERE source_header_id = p_shipment_header_id;
8708
8709 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8710 BEGIN
8711 IF (l_debug = 1) THEN
8712 print_debug('clear_LPN_for_ship 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8713 END IF;
8714
8715 l_progress := '10';
8716 x_return_status := fnd_api.g_ret_sts_success;
8717 SAVEPOINT rcv_clear_lpn_cont_sp;
8718
8719 IF (l_debug = 1) THEN
8720 print_debug('clear_LPN_for_ship 10.1: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8721 END IF;
8722
8723 SELECT SUBSTR(asn_type, 1, 3)
8724 INTO l_asn_type
8725 FROM rcv_shipment_headers
8726 WHERE shipment_header_id = p_shipment_header_id;
8727
8728 IF (l_debug = 1) THEN
8729 print_debug('clear_LPN_for_ship 10.2 ASN_TYPE =: ' || l_asn_type, 1);
8730 END IF;
8731
8732 SELECT wms_enabled_flag
8733 INTO l_wms_enabled
8734 FROM mtl_parameters
8735 WHERE organization_id = p_organization_id;
8736
8737 IF (l_debug = 1) THEN
8738 print_debug('clear_LPN_for_ship 10.3 WMS_ENABLED_FLAG : ' || l_wms_enabled, 1);
8739 END IF;
8740
8741 IF UPPER(l_asn_type) = 'ASN' THEN
8742 OPEN l_curs_lpn_for_asn;
8743
8744 LOOP
8745 FETCH l_curs_lpn_for_asn INTO l_lpn_id;
8746 EXIT WHEN l_curs_lpn_for_asn%NOTFOUND;
8747
8748 IF (l_debug = 1) THEN
8749 print_debug('clear_LPN_for_ASN 20: - calling update_lpn_org for:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8750 print_debug('lpn_id => ' || l_lpn_id, 4);
8751 print_debug('org_id => ' || p_organization_id, 4);
8752 END IF;
8753
8754 l_progress := '20';
8755
8756 IF (l_wms_enabled = 'Y') THEN --Update lpn org only if the current org is wms enabled
8757 update_lpn_org(
8758 p_organization_id => p_organization_id
8759 , p_lpn_id => l_lpn_id
8760 , x_return_status => l_return_status
8761 , x_msg_count => l_msg_count
8762 , x_msg_data => l_msg_data
8763 );
8764
8765 IF l_return_status = fnd_api.g_ret_sts_error THEN
8766 IF (l_debug = 1) THEN
8767 print_debug('clear_LPN_for_ASN 20.1 : update_lpn_org RAISE FND_API.G_EXC_ERROR;'
8768 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8769 , 4);
8770 END IF;
8771
8772 RAISE fnd_api.g_exc_error;
8773 END IF;
8774
8775 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8776 IF (l_debug = 1) THEN
8777 print_debug(
8778 'clear_LPN_for_ASN 20.2: update_lpn_org RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8779 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8780 , 4
8781 );
8782 END IF;
8783
8784 RAISE fnd_api.g_exc_unexpected_error;
8785 END IF;
8786 END IF;
8787
8788 IF (l_debug = 1) THEN
8789 print_debug('clear_LPN_for_ASN 30: - calling remove_lpn_contents' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8790 END IF;
8791
8792 l_progress := '30';
8793 remove_lpn_contents(
8794 p_lpn_id => l_lpn_id
8795 , x_return_status => l_return_status
8796 , x_msg_count => l_msg_count
8797 , x_msg_data => l_msg_data
8798 , p_routing_id => p_routing_id
8799 );
8800
8801 IF l_return_status = fnd_api.g_ret_sts_error THEN
8802 IF (l_debug = 1) THEN
8803 print_debug(
8804 'clear_LPN_for_ASN 30.1 : remove_lpn_contents RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8805 , 4
8806 );
8807 END IF;
8808
8809 RAISE fnd_api.g_exc_error;
8810 END IF;
8811
8812 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8813 IF (l_debug = 1) THEN
8814 print_debug(
8815 'clear_LPN_for_ASN 30.2: remove_lpn_contents RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8816 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8817 , 4
8818 );
8819 END IF;
8820
8821 RAISE fnd_api.g_exc_unexpected_error;
8822 END IF;
8823 END LOOP;
8824
8825 CLOSE l_curs_lpn_for_asn;
8826 ELSE
8827 OPEN l_curs_lpn_for_ship;
8828
8829 LOOP
8830 FETCH l_curs_lpn_for_ship INTO l_lpn_id;
8831 EXIT WHEN l_curs_lpn_for_ship%NOTFOUND;
8832
8833 IF (l_debug = 1) THEN
8834 print_debug('clear_LPN_for_ship 20: - calling update_lpn_org for:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8835 print_debug('lpn_id => ' || l_lpn_id, 4);
8836 print_debug('org_id => ' || p_organization_id, 4);
8837 END IF;
8838
8839 l_progress := '20';
8840
8841 IF (l_wms_enabled = 'Y') THEN --Update lpn org only if the current org is wms enabled
8842 update_lpn_org(
8843 p_organization_id => p_organization_id
8844 , p_lpn_id => l_lpn_id
8845 , x_return_status => l_return_status
8846 , x_msg_count => l_msg_count
8847 , x_msg_data => l_msg_data
8848 );
8849
8850 IF l_return_status = fnd_api.g_ret_sts_error THEN
8851 IF (l_debug = 1) THEN
8852 print_debug('clear_LPN_for_ship 20.1 : update_lpn_org RAISE FND_API.G_EXC_ERROR;'
8853 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8854 , 4);
8855 END IF;
8856
8857 RAISE fnd_api.g_exc_error;
8858 END IF;
8859
8860 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8861 IF (l_debug = 1) THEN
8862 print_debug(
8863 'clear_LPN_for_ship 20.2: update_lpn_org RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8864 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8865 , 4
8866 );
8867 END IF;
8868
8869 RAISE fnd_api.g_exc_unexpected_error;
8870 END IF;
8871 END IF;
8872
8873 IF (l_debug = 1) THEN
8874 print_debug('clear_LPN_for_ship 30: - calling remove_lpn_contents' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 4);
8875 END IF;
8876
8877 l_progress := '30';
8878 remove_lpn_contents(
8879 p_lpn_id => l_lpn_id
8880 , x_return_status => l_return_status
8881 , x_msg_count => l_msg_count
8882 , x_msg_data => l_msg_data
8883 , p_routing_id => p_routing_id
8884 );
8885
8886 IF l_return_status = fnd_api.g_ret_sts_error THEN
8887 IF (l_debug = 1) THEN
8888 print_debug(
8889 'clear_LPN_for_ship 30.1 : remove_lpn_contents RAISE FND_API.G_EXC_ERROR;' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8890 , 4
8891 );
8892 END IF;
8893
8894 RAISE fnd_api.g_exc_error;
8895 END IF;
8896
8897 IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
8898 IF (l_debug = 1) THEN
8899 print_debug(
8900 'clear_LPN_for_ship 30.2: remove_lpn_contents RAISE FND_API.G_EXC_UNEXPECTED_ERROR;'
8901 || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
8902 , 4
8903 );
8904 END IF;
8905
8906 RAISE fnd_api.g_exc_unexpected_error;
8907 END IF;
8908 END LOOP;
8909
8910 CLOSE l_curs_lpn_for_ship;
8911 END IF;
8912
8913 IF (l_debug = 1) THEN
8914 print_debug('clear_LPN_for_ship 20: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8915 END IF;
8916 EXCEPTION
8917 WHEN OTHERS THEN
8918 ROLLBACK TO rcv_clear_lpn_cont_sp;
8919
8920 IF l_curs_lpn_for_ship%ISOPEN THEN
8921 CLOSE l_curs_lpn_for_ship;
8922 END IF;
8923
8924 IF l_curs_lpn_for_asn%ISOPEN THEN
8925 CLOSE l_curs_lpn_for_asn;
8926 END IF;
8927
8928 x_return_status := fnd_api.g_ret_sts_unexp_error;
8929
8930 IF SQLCODE IS NOT NULL THEN
8931 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.clear_LPN_for_ship', l_progress, SQLCODE);
8932 END IF;
8933
8934 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
8935 END clear_lpn_for_ship;
8936
8937 -- Check if there are LPNs on this shipment
8938 -- If theres LPN on this shipment, lpn_flag = 1, else lpn_flag = 0
8939
8940 PROCEDURE check_lpn_on_shipment(
8941 p_shipment_number IN VARCHAR2
8942 , p_from_organization_id IN NUMBER
8943 , p_to_organization_id IN NUMBER
8944 , x_lpn_flag OUT NOCOPY NUMBER
8945 , x_return_status OUT NOCOPY VARCHAR2
8946 , x_msg_count OUT NOCOPY NUMBER
8947 , x_msg_data OUT NOCOPY VARCHAR2
8948 ) IS
8949 l_lpn_count NUMBER := 0;
8950 l_lot_serial_flag NUMBER := 1;
8951 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
8952 l_msg_count NUMBER;
8953 l_msg_data VARCHAR2(4000);
8954 l_progress VARCHAR2(10);
8955 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8956 BEGIN
8957 IF (l_debug = 1) THEN
8958 print_debug('check_lpn_on_shipment 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
8959 END IF;
8960
8961 l_progress := '10';
8962 x_return_status := fnd_api.g_ret_sts_success;
8963 x_lpn_flag := 0;
8964
8965 SELECT COUNT(*)
8966 INTO l_lpn_count
8967 FROM wms_license_plate_numbers
8968 WHERE organization_id = p_from_organization_id
8969 AND lpn_context = 6
8970 AND source_name = p_shipment_number;
8971
8972 l_progress := '20';
8973
8974 /* bug# 2783559
8975 We dont need to check for incompatible serial/lot/revision codes here,
8976 but in individual lpns
8977 IF l_lpn_count > 0 THEN
8978 -- fix for bug 2403033
8979 BEGIN
8980 SELECT 1
8981 INTO l_lot_serial_flag
8982 FROM rcv_shipment_lines rsl
8983 , rcv_shipment_headers rsh
8984 , mtl_system_items msi1
8985 , mtl_system_items msi2
8986 WHERE rsh.shipment_num = p_shipment_number
8987 AND rsl.shipment_header_id = rsh.shipment_header_id
8988 AND rsl.item_id = msi1.inventory_item_id
8989 AND msi1.organization_id = p_from_organization_id
8990 AND (Nvl(msi1.lot_control_code,1) <> Nvl(msi2.lot_control_code,1)
8991 OR (Nvl(msi1.serial_number_control_code,1) in (1,6)
8992 AND Nvl(msi2.serial_number_control_code,1) IN (2,5))
8993 OR (Nvl(msi1.serial_number_control_code,1) in (2,5)
8994 AND Nvl(msi2.serial_number_control_code,1) IN (1,6)))
8995 AND rsl.item_id = msi2.inventory_item_id
8996 AND msi2.organization_id = rsl.to_organization_id
8997 AND ROWNUM = 1;
8998 l_lot_serial_flag := 2;
8999 EXCEPTION
9000 WHEN no_data_found THEN
9001 l_lot_serial_flag := 0;
9002 WHEN OTHERS THEN
9003 l_lot_serial_flag := 1;
9004 END;
9005 IF l_lot_serial_flag = 0 THEN
9006 x_lpn_flag := 1;
9007 ELSIF l_lot_serial_flag = 2 THEN
9008 x_lpn_flag := 2;
9009 ELSE
9010 x_lpn_flag := 0;
9011 END IF;
9012 END IF;
9013 */
9014 IF l_lpn_count > 0 THEN
9015 x_lpn_flag := 1;
9016 END IF;
9017
9018 IF (l_debug = 1) THEN
9019 print_debug('Exit check_lpn_on_shipment 20: l_lpn_count = ' || l_lpn_count || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')
9020 , 1);
9021 END IF;
9022 EXCEPTION
9023 WHEN NO_DATA_FOUND THEN
9024 x_lpn_flag := 0;
9025 WHEN OTHERS THEN
9026 x_return_status := fnd_api.g_ret_sts_unexp_error;
9027
9028 IF SQLCODE IS NOT NULL THEN
9029 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.check_lpn_on_shipment', l_progress, SQLCODE);
9030 END IF;
9031
9032 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9033 END check_lpn_on_shipment;
9034
9035 PROCEDURE check_lpn_on_asn(
9036 p_shipment_header_id IN VARCHAR2
9037 , x_lpn_flag OUT NOCOPY NUMBER
9038 , x_return_status OUT NOCOPY VARCHAR2
9039 , x_msg_count OUT NOCOPY NUMBER
9040 , x_msg_data OUT NOCOPY VARCHAR2
9041 ) IS
9042 l_lpn_count NUMBER := 0;
9043 l_lot_serial_flag NUMBER := 1;
9044 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
9045 l_msg_count NUMBER;
9046 l_msg_data VARCHAR2(4000);
9047 l_progress VARCHAR2(10);
9048 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9049 BEGIN
9050 IF (l_debug = 1) THEN
9051 print_debug('check_lpn_on_ASN 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
9052 END IF;
9053
9054 l_progress := '10';
9055 x_lpn_flag := 0;
9056 x_return_status := fnd_api.g_ret_sts_success;
9057
9058 SELECT COUNT(*)
9059 INTO l_lpn_count
9060 FROM wms_license_plate_numbers
9061 WHERE lpn_context = 7
9062 AND source_header_id = p_shipment_header_id;
9063
9064 l_progress := '20';
9065
9066 /* bug# 2783559
9067 We dont need to check for incompatible serial/lot/revision codes here,
9068 but in individual lpns
9069
9070 IF l_lpn_count > 0 THEN
9071 -- fix for bug 2403033
9072 BEGIN
9073 SELECT 1
9074 INTO l_lot_serial_flag
9075 FROM rcv_shipment_lines rsl
9076 , rcv_shipment_headers rsh
9077 , mtl_system_items msi1
9078 , mtl_system_items msi2
9079 WHERE rsh.shipment_header_id = p_shipment_header_id
9080 AND rsl.shipment_header_id = rsh.shipment_header_id
9081 AND rsl.item_id = msi1.inventory_item_id
9082 AND msi1.organization_id = rsl.from_organization_id
9083 AND (Nvl(msi1.lot_control_code,1) <> Nvl(msi2.lot_control_code,1)
9084 OR (Nvl(msi1.serial_number_control_code,1) in (1,6)
9085 AND Nvl(msi2.serial_number_control_code,1) IN (2,5))
9086 OR (Nvl(msi1.serial_number_control_code,1) in (2,5)
9087 AND Nvl(msi2.serial_number_control_code,1) IN (1,6)))
9088 AND rsl.item_id = msi2.inventory_item_id
9089 AND msi2.organization_id = rsl.to_organization_id
9090 AND ROWNUM = 1;
9091 l_lot_serial_flag := 1;
9092 EXCEPTION
9093 WHEN no_data_found THEN
9094 l_lot_serial_flag := 0;
9095 WHEN OTHERS THEN
9096 l_lot_serial_flag := 1;
9097 END;
9098 IF l_lot_serial_flag = 0 THEN
9099 x_lpn_flag := 1;
9100 ELSE
9101 x_lpn_flag := 0;
9102 END IF;
9103 END IF;
9104 */
9105 IF l_lpn_count > 0 THEN
9106 x_lpn_flag := 1;
9107 ELSE
9108 x_lpn_flag := 0;
9109 END IF;
9110
9111 IF (l_debug = 1) THEN
9112 print_debug('Exit check_lpn_on_ASN 20: l_lpn_count = ' || l_lpn_count || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
9113 END IF;
9114 EXCEPTION
9115 WHEN NO_DATA_FOUND THEN
9116 x_lpn_flag := 0;
9117 WHEN OTHERS THEN
9118 x_return_status := fnd_api.g_ret_sts_unexp_error;
9119
9120 IF SQLCODE IS NOT NULL THEN
9121 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.check_lpn_on_ASN', l_progress, SQLCODE);
9122 END IF;
9123
9124 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9125 END check_lpn_on_asn;
9126
9127 -- Express Int Req Receiving
9128 PROCEDURE check_lpn_on_req(
9129 p_req_num IN VARCHAR2
9130 , x_lpn_flag OUT NOCOPY NUMBER
9131 , x_return_status OUT NOCOPY VARCHAR2
9132 , x_msg_count OUT NOCOPY NUMBER
9133 , x_msg_data OUT NOCOPY VARCHAR2
9134 ) IS
9135 l_lpn_flag NUMBER := 0;
9136 l_lpn_id NUMBER := NULL;
9137 l_order_header_id NUMBER;
9138 l_order_line_id NUMBER;
9139 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
9140 l_msg_count NUMBER;
9141 l_msg_data VARCHAR2(4000);
9142 l_progress VARCHAR2(10);
9143 l_shipping_org NUMBER;
9144 l_lpn_org NUMBER;
9145 l_lpn_context NUMBER;
9146 l_exit_outer BOOLEAN := FALSE;
9147 CURSOR c_order_lines IS
9148 SELECT line_id
9149 FROM oe_order_lines_all
9150 WHERE header_id = l_order_header_id;
9151
9152 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9153
9154 -- bug 3209246
9155 CURSOR c_delivery_details(v_order_header_id NUMBER, v_order_line_id NUMBER) IS
9156 SELECT wdd1.lpn_id
9157 , wdd1.organization_id
9158 FROM wsh_delivery_details_ob_grp_v wdd, wsh_delivery_assignments_v wda
9159 , wsh_delivery_details_ob_grp_v wdd1
9160 WHERE wdd.source_header_id = v_order_header_id
9161 AND wdd.source_line_id = v_order_line_id
9162 AND wdd.delivery_detail_id = wda.delivery_detail_id
9163 AND wdd1.delivery_detail_id = wda.parent_delivery_detail_id;
9164 BEGIN
9165 l_progress := '10';
9166 SELECT header_id
9167 INTO l_order_header_id
9168 FROM oe_order_headers_all
9169 WHERE orig_sys_document_ref = p_req_num
9170 AND order_source_id = 10;
9171 --and order_type_id = 1023;
9172
9173 IF (l_debug = 1) THEN
9174 print_debug('header_id: ' || TO_CHAR(l_order_header_id), 1);
9175 END IF;
9176
9177 OPEN c_order_lines;
9178 l_progress := '20';
9179
9180 LOOP
9181 FETCH c_order_lines INTO l_order_line_id;
9182 EXIT WHEN c_order_lines%NOTFOUND;
9183 l_progress := '30';
9184
9185 /* Exp Int Req */
9186 IF (l_debug = 1) THEN
9187 print_debug('line_id: ' || TO_CHAR(l_order_line_id), 1);
9188 END IF;
9189
9190 /* Bug #2778747
9191 * To check if the requisition contains a valid LPN, check for:
9192 * -> Get the lpn_id and org_id FROM wsh_delivery_details
9193 * -> If there is an LPN which belongs to the shipping org and the LPN context
9194 * is "Resides in Intransit", then set the lpn_flag to 1 to indicate that the
9195 * req contains a valid LPN that can be received and break out of the loop
9196 * -> If the LPN org is different from the shipping org, set the lpn_flag to 0
9197 * and check for the next wsh_delivery_detail record.
9198 * -> If the LPN context is not "Resides in Intransit", i.e., the LPN was not
9199 * shipped, set the lpn_flag to 0 and check for the next wsh_delivery_detail record
9200 */
9201 BEGIN
9202 l_exit_outer := FALSE;
9203 OPEN c_delivery_details(l_order_header_id, l_order_line_id);
9204
9205 LOOP
9206 FETCH c_delivery_details INTO l_lpn_id, l_shipping_org;
9207 EXIT WHEN c_delivery_details%NOTFOUND;
9208 l_progress := 35;
9209 IF l_lpn_id IS NOT NULL THEN
9210 -- Nested LPN changes. Check whether the given LPN has content.
9211 IF inv_rcv_common_apis.g_po_patch_level < inv_rcv_common_apis.g_patchset_j_po
9212 OR inv_rcv_common_apis.g_inv_patch_level < inv_rcv_common_apis.g_patchset_j
9213 OR inv_rcv_common_apis.g_wms_patch_level < inv_rcv_common_apis.g_patchset_j THEN
9214 SELECT organization_id
9215 , lpn_context
9216 INTO l_lpn_org
9217 , l_lpn_context
9218 FROM wms_license_plate_numbers
9219 WHERE lpn_id = l_lpn_id;
9220 ELSE
9221 SELECT organization_id
9222 , lpn_context
9223 INTO l_lpn_org
9224 , l_lpn_context
9225 FROM wms_license_plate_numbers
9226 WHERE lpn_id = l_lpn_id
9227 AND lpn_id IN(SELECT parent_lpn_id
9228 FROM wms_lpn_contents
9229 WHERE parent_lpn_id = l_lpn_id);
9230 END IF;
9231 IF (l_debug = 1) THEN
9232 print_debug('lpn_id: ' || TO_CHAR(l_lpn_id), 1);
9233 print_debug('lpn_org: ' || TO_CHAR(l_lpn_org), 1);
9234 print_debug('lpn_context: ' || TO_CHAR(l_lpn_context), 1);
9235 END IF;
9236
9237 IF l_lpn_org <> l_shipping_org THEN
9238 l_lpn_flag := 0;
9239
9240 IF (l_debug = 1) THEN
9241 print_debug('lpn org and shipping org do not match', 1);
9242 END IF;
9243 ELSIF l_lpn_org = l_shipping_org
9244 AND l_lpn_context <> 6 THEN
9245 l_lpn_flag := 0;
9246
9247 IF (l_debug = 1) THEN
9248 print_debug('lpn context is not resides in intransit', 1);
9249 END IF;
9250 ELSE
9251 l_lpn_flag := 1;
9252 l_exit_outer := TRUE;
9253
9254 IF (l_debug = 1) THEN
9255 print_debug('Found a valid LPN. Should come out of the loop', 1);
9256 END IF;
9257
9258 EXIT;
9259 END IF;
9260 END IF;
9261 END LOOP;
9262
9263 CLOSE c_delivery_details;
9264 EXCEPTION
9265 WHEN NO_DATA_FOUND THEN
9266 l_lpn_flag := 0;
9267
9268 IF c_delivery_details%ISOPEN THEN
9269 CLOSE c_delivery_details;
9270 END IF;
9271 END;
9272
9273 IF (l_debug = 1) THEN
9274 print_debug('lpn_id: ' || TO_CHAR(l_lpn_id), 1);
9275 END IF;
9276
9277 IF l_lpn_flag = 1 THEN
9278 EXIT;
9279 END IF;
9280
9281 /* Exp Int Req */
9282 l_progress := '40';
9283 END LOOP;
9284
9285 CLOSE c_order_lines;
9286 l_progress := '50';
9287 /* bug 2783559 Dont need to check it here but, in individual lpn
9288 FOR ASN,Int Req and Int Shipment
9289
9290 IF l_lpn_flag = 1 THEN
9291
9292 BEGIN
9293 SELECT 2
9294 INTO l_lpn_flag
9295 FROM po_requisition_headers prh
9296 , po_requisition_lines prl
9297 , rcv_shipment_lines rsl
9298 , mtl_system_items msi1
9299 , mtl_system_items msi2
9300 WHERE prh.segment1 = p_req_num
9301 AND prl.requisition_header_id = prh.requisition_header_id
9302 AND rsl.requisition_line_id = prl.requisition_line_id
9303 AND rsl.item_id = msi1.inventory_item_id
9304 AND msi1.organization_id = rsl.from_organization_id
9305 AND (Nvl(msi1.lot_control_code,1) <> Nvl(msi2.lot_control_code,1)
9306 OR (Nvl(msi1.serial_number_control_code,1) in (1,6)
9307 AND Nvl(msi2.serial_number_control_code,1) IN (2,5))
9308 OR (Nvl(msi1.serial_number_control_code,1) in (2,5)
9309 AND Nvl(msi2.serial_number_control_code,1) IN (1,6)))
9310 AND rsl.item_id = msi2.inventory_item_id
9311 AND msi2.organization_id = rsl.to_organization_id
9312 AND ROWNUM = 1;
9313 l_lpn_flag := 2;
9314 EXCEPTION
9315 WHEN no_data_found THEN
9316 NULL;
9317 END;
9318 END IF;
9319 */
9320 x_lpn_flag := l_lpn_flag;
9321 x_return_status := l_return_status;
9322 EXCEPTION
9323 WHEN NO_DATA_FOUND THEN
9324 x_lpn_flag := 0;
9325 x_return_status := l_return_status;
9326 WHEN OTHERS THEN
9327 -- Nested LPN changes
9328 -- Close delivery detials cusror if it is open
9329 IF c_delivery_details%ISOPEN THEN
9330 CLOSE c_delivery_details;
9331 END IF;
9332
9333 x_return_status := fnd_api.g_ret_sts_unexp_error;
9334
9335 IF SQLCODE IS NOT NULL THEN
9336 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.check_lpn_on_REQ', l_progress, SQLCODE);
9337 END IF;
9338
9339 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9340 END;
9341
9342 -- Express Int Req Receiving
9343
9344 PROCEDURE update_lpn_org(
9345 p_organization_id IN NUMBER
9346 , p_lpn_id IN NUMBER
9347 , x_return_status OUT NOCOPY VARCHAR2
9348 , x_msg_count OUT NOCOPY NUMBER
9349 , x_msg_data OUT NOCOPY VARCHAR2
9350 ) IS
9351 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
9352 l_msg_count NUMBER;
9353 l_msg_data VARCHAR2(4000);
9354 l_progress VARCHAR2(10);
9355 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9356 --variables below are added for bug# 2814405
9357 l_serial_code NUMBER;
9358 l_lot_code NUMBER;
9359 l_item_id NUMBER;
9360 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
9361 l_lot_number VARCHAR2(80);
9362
9363 CURSOR lpn_lot_items IS
9364 SELECT distinct inventory_item_id
9365 FROM wms_lpn_contents
9366 WHERE lot_number IS NOT NULL
9367 AND parent_lpn_id = p_lpn_id;
9368
9369 CURSOR lpn_serial_items IS
9370 SELECT DISTINCT inventory_item_id
9371 FROM mtl_serial_numbers
9372 WHERE lpn_id = p_lpn_id;
9373 BEGIN
9374 IF (l_debug = 1) THEN
9375 print_debug('Enter update_LPN_Org 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
9376 END IF;
9377
9378 x_return_status := fnd_api.g_ret_sts_success;
9379 SAVEPOINT rcv_update_lpn_org_sp;
9380 l_progress := '10';
9381
9382 UPDATE wms_license_plate_numbers
9383 SET organization_id = p_organization_id
9384 , subinventory_code = ''
9385 , locator_id = NULL
9386 WHERE lpn_id = p_lpn_id;
9387
9388 l_progress := '20';
9389 --bug# 2814405 start
9390 OPEN lpn_lot_items;
9391
9392 LOOP
9393 FETCH lpn_lot_items INTO l_item_id;
9394 EXIT WHEN lpn_lot_items%NOTFOUND;
9395
9396 BEGIN
9397 SELECT lot_control_code
9398 INTO l_lot_code
9399 FROM mtl_system_items
9400 WHERE inventory_item_id = l_item_id
9401 AND organization_id = p_organization_id;
9402
9403 print_debug('item id ' || l_item_id || ' lot code ' || l_lot_code );
9404
9405 IF (l_lot_code = 1) THEN
9406 UPDATE wms_lpn_contents
9407 SET lot_number = NULL /* 3835398 */
9408 WHERE parent_lpn_id = p_lpn_id
9409 AND inventory_item_id = l_item_id;
9410 END IF;
9411 EXCEPTION
9412 WHEN NO_DATA_FOUND THEN
9413 NULL;
9414 print_debug('Failed to get lot control codes ' || l_progress);
9415 END;
9416 END LOOP;
9417
9418 OPEN lpn_serial_items;
9419
9420 LOOP
9421 FETCH lpn_serial_items INTO l_item_id;
9422 EXIT WHEN lpn_serial_items%NOTFOUND;
9423
9424 BEGIN
9425 l_progress := '25';
9426
9427 SELECT serial_number_control_code
9428 INTO l_serial_code
9429 FROM mtl_system_items
9430 WHERE organization_id = p_organization_id
9431 AND inventory_item_id = l_item_id;
9432
9433 IF l_serial_code IN(2, 5) THEN
9434 -- bug 2167174
9435 UPDATE mtl_serial_numbers
9436 SET current_organization_id = p_organization_id
9437 WHERE lpn_id = p_lpn_id
9438 AND inventory_item_id = l_item_id; /* 3835398 */
9439
9440 ELSIF (l_serial_code = 1 ) THEN
9441 UPDATE wms_lpn_contents
9442 SET serial_summary_entry = 2
9443 WHERE parent_lpn_id = p_lpn_id
9444 AND inventory_item_id = l_item_id; /* 3835398 */
9445
9446 END IF;
9447
9448 l_progress := '30';
9449 EXCEPTION
9450 WHEN NO_DATA_FOUND THEN
9451 NULL;
9452 print_debug('Failed to get serial control codes ' || l_progress);
9453 END;
9454 END LOOP;
9455
9456 -- bug# 2814405 end;
9457
9458 UPDATE wms_lpn_contents
9459 SET organization_id = p_organization_id
9460 WHERE parent_lpn_id = p_lpn_id;
9461
9462 l_progress := '40';
9463
9464 IF (l_debug = 1) THEN
9465 print_debug('Exit update_LPN_Org 10: ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
9466 END IF;
9467 EXCEPTION
9468 WHEN OTHERS THEN
9469 ROLLBACK TO rcv_update_lpn_org_sp;
9470 x_return_status := fnd_api.g_ret_sts_unexp_error;
9471
9472 IF SQLCODE IS NOT NULL THEN
9473 inv_mobile_helper_functions.sql_error('INV_RCV_STD_RCPT_APIS.update_LPN_Org', l_progress, SQLCODE);
9474 END IF;
9475
9476 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9477 END update_lpn_org;
9478
9479 --Start of fix for the Bug #4037082
9480 --This procedure will validate the entered lot quantity
9481 --against the shipped lot quantity
9482 PROCEDURE validate_lot_qty(
9483 p_lot_number IN VARCHAR2
9484 , p_inventory_item_id IN NUMBER
9485 , p_lot_txn_qty IN NUMBER
9486 , p_lot_primary_qty IN NUMBER
9487 , p_shipment_header_id IN NUMBER
9488 , p_rcv_org_id IN NUMBER
9489 , x_return_status OUT NOCOPY VARCHAR2
9490 )
9491 IS
9492 l_rlsu_quantity RCV_LOTS_SUPPLY.QUANTITY%TYPE := 0;
9493 l_rlsu_primary_quantity RCV_LOTS_SUPPLY.PRIMARY_QUANTITY%TYPE := 0;
9494 l_index NUMBER := 0;
9495 l_diff_txn_qty NUMBER := 0;
9496 l_partial_rcpt NUMBER := 0;
9497 l_rec_count NUMBER := 0;
9498 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9499
9500 BEGIN
9501
9502 IF (l_debug = 1) THEN
9503 print_debug('validate_lot_qty: 10 Entering into Lot Qty Validation Procedure' , 4);
9504 print_debug('validate_lot_qty: 20 Validating for lot: ' || p_lot_number || ' Item: ' || p_inventory_item_id || ' shipment_hdr_id: '|| p_shipment_header_id , 4);
9505 print_debug('validate_lot_qty: 30 txn_qty :' || p_lot_txn_qty || ' p_lot_primary_qty: ' || p_lot_primary_qty || ' p_rcv_org_id: ' || p_rcv_org_id , 4);
9506 END IF;
9507
9508 x_return_status := fnd_api.g_ret_sts_success;
9509
9510 BEGIN
9511 SELECT count(1)
9512 INTO l_partial_rcpt
9513 FROM dual
9514 WHERE EXISTS ( SELECT 1
9515 FROM rcv_transactions
9516 WHERE shipment_header_id = p_shipment_header_id
9517 AND organization_id = p_rcv_org_id
9518 );
9519 EXCEPTION
9520 WHEN OTHERS THEN
9521 l_partial_rcpt := 0;
9522 END;
9523
9524 IF l_partial_rcpt = 0 THEN
9525 BEGIN
9526 SELECT count(1)
9527 INTO l_partial_rcpt
9528 FROM dual
9529 WHERE EXISTS ( SELECT 1
9530 FROM rcv_transactions_interface
9531 WHERE shipment_header_id = p_shipment_header_id
9532 AND to_organization_id = p_rcv_org_id
9533 );
9534 EXCEPTION
9535 WHEN OTHERS THEN
9536 l_partial_rcpt := 0;
9537 END;
9538 END IF;
9539
9540 IF l_partial_rcpt = 1 THEN
9541 print_debug('validate_lot_qty: 30.1 Not doing Qty Validation for Partial Receipts..Hence Returning..' , 4);
9542 RETURN;
9543 END IF;
9544
9545 BEGIN
9546
9547 SELECT NVL(SUM(rlsu.quantity),0) ,
9548 NVL(SUM(rlsu.primary_quantity),0)
9549 INTO l_rlsu_quantity,
9550 l_rlsu_primary_quantity
9551 FROM rcv_lots_supply rlsu,
9552 rcv_shipment_lines rsl
9553 WHERE rlsu.shipment_line_id = rsl.shipment_line_id
9554 AND rsl.item_id = p_inventory_item_id
9555 AND rsl.to_organization_id = p_rcv_org_id
9556 AND rsl.shipment_header_id = p_shipment_header_id
9557 AND rlsu.lot_num = p_lot_number
9558 AND rlsu.supply_type_code = 'SHIPMENT' ;
9559 EXCEPTION
9560 WHEN OTHERS THEN
9561 IF (l_debug = 1) THEN
9562 print_debug('validate_lot_qty: 40 When Others Exception' , 4);
9563 END IF;
9564 l_rlsu_quantity := 0 ;
9565 l_rlsu_primary_quantity := 0 ;
9566 END;
9567
9568 IF NVL(p_lot_primary_qty,0) <> 0 AND l_rlsu_primary_quantity <> 0 THEN
9569 IF p_lot_primary_qty > l_rlsu_primary_quantity THEN
9570 fnd_message.set_name('INV', 'INV_MAX_QTY');
9571 fnd_message.set_token('TOKEN', l_rlsu_primary_quantity);
9572 fnd_msg_pub.add;
9573 IF (l_debug = 1) THEN
9574 print_debug('validate_lot_qty: 50 Receiving Lot Qty : ' || p_lot_primary_qty || ' cannot be more than Shipped Qty : ' || l_rlsu_primary_quantity , 4);
9575 END IF;
9576
9577 --Removing the errored Lot from g_rcpt_lot_qty_rec_tb table
9578 l_rec_count := g_rcpt_lot_qty_rec_tb.COUNT;
9579
9580 FOR i IN 1 .. l_rec_count LOOP
9581 IF g_rcpt_lot_qty_rec_tb(i).lot_number = p_lot_number THEN
9582 l_diff_txn_qty := g_rcpt_lot_qty_rec_tb(i).txn_quantity - p_lot_txn_qty ;
9583 l_index := i;
9584 EXIT;
9585 END IF;
9586 END LOOP;
9587
9588 IF l_diff_txn_qty = 0 THEN
9589 IF l_rec_count = 1 THEN
9590 g_rcpt_lot_qty_rec_tb.DELETE;
9591 ELSE
9592 g_rcpt_lot_qty_rec_tb.DELETE(l_index);
9593 END IF;
9594 ELSE
9595 g_rcpt_lot_qty_rec_tb(l_index).txn_quantity := l_diff_txn_qty ;
9596 END IF;
9597
9598 x_return_status := fnd_api.g_ret_sts_error;
9599 RETURN;
9600 END IF;
9601 END IF;
9602
9603 IF (l_debug = 1) THEN
9604 print_debug('validate_lot_qty: 60 Exitting from Lot Qty Validation Procedure' , 4);
9605 END IF;
9606
9607 END validate_lot_qty;
9608 --End of fix for the Bug #4037082
9609
9610 --Added to fix the Bug #4086191
9611 --overload the procedure created above
9612 --with one more parameter, p_product_transaction_id
9613 PROCEDURE validate_lot_qty(
9614 p_lot_number IN VARCHAR2
9615 , p_inventory_item_id IN NUMBER
9616 , p_lot_txn_qty IN NUMBER
9617 , p_lot_primary_qty IN NUMBER
9618 , p_shipment_header_id IN NUMBER
9619 , p_rcv_org_id IN NUMBER
9620 , p_product_txn_id IN NUMBER
9621 , x_return_status OUT NOCOPY VARCHAR2
9622 ) IS
9623 l_rlsu_primary_quantity RCV_LOTS_SUPPLY.PRIMARY_QUANTITY%TYPE := 0;
9624 l_mtli_primary_quantity NUMBER := 0;
9625 l_current_grp_prim_qty NUMBER := 0;
9626 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9627
9628 BEGIN
9629 IF (l_debug = 1) THEN
9630 print_debug('validate_lot_qty J: 10 Entering into Lot Qty Validation Procedure' , 4);
9631 print_debug('validate_lot_qty J: 20 Validating for lot: ' || p_lot_number || ' Item: ' || p_inventory_item_id || ' shipment_hdr_id: '|| p_shipment_header_id , 4);
9632 print_debug('validate_lot_qty J: 30 txn_qty :' || p_lot_txn_qty || ' p_lot_primary_qty: ' || p_lot_primary_qty || ' p_rcv_org_id: ' || p_rcv_org_id , 4);
9633 print_debug('validate_lot_qty J: 31 p_shipment_header_id:' || p_shipment_header_id);
9634 print_debug('validate_lot_qty J: 31 p_prod_txn_id:' || p_product_txn_id);
9635 END IF;
9636
9637 x_return_status := fnd_api.g_ret_sts_success;
9638
9639 BEGIN
9640 SELECT NVL(SUM(rlsu.primary_quantity),0)
9641 INTO l_rlsu_primary_quantity
9642 FROM rcv_lots_supply rlsu,
9643 rcv_shipment_lines rsl
9644 WHERE rlsu.shipment_line_id = rsl.shipment_line_id
9645 AND rsl.item_id = p_inventory_item_id
9646 AND rsl.to_organization_id = p_rcv_org_id
9647 AND rsl.shipment_header_id = p_shipment_header_id
9648 AND rlsu.lot_num = p_lot_number
9649 AND rlsu.supply_type_code = 'SHIPMENT' ;
9650 EXCEPTION
9651 WHEN OTHERS THEN
9652 IF (l_debug = 1) THEN
9653 print_debug('validate_lot_qty: 31 When Others Exception' , 4);
9654 END IF;
9655 l_rlsu_primary_quantity := 0 ;
9656 END;
9657
9658 BEGIN
9659 SELECT NVL(SUM(mtli.primary_quantity),0)
9660 INTO l_mtli_primary_quantity
9661 FROM mtl_transaction_lots_interface mtli,
9662 rcv_transactions_interface rti
9663 WHERE rti.processing_status_code <> 'ERROR'
9664 AND rti.transaction_status_code <> 'ERROR'
9665 AND rti.to_organization_id = p_rcv_org_id
9666 AND rti.item_id = p_inventory_item_id
9667 AND rti.shipment_header_id = p_shipment_header_id
9668 AND rti.interface_transaction_id = mtli.product_transaction_id
9669 AND mtli.lot_number = p_lot_number
9670 AND mtli.product_code = 'RCV';
9671 EXCEPTION
9672 WHEN OTHERS THEN
9673 IF (l_debug = 1) THEN
9674 print_debug('validate_lot_qty: 32 When Others Exception' , 4);
9675 END IF;
9676 l_mtli_primary_quantity := 0;
9677 END;
9678
9679 IF (p_product_txn_id IS NOT NULL) THEN
9680 BEGIN
9681 SELECT Nvl(SUM(primary_quantity),0)
9682 INTO l_current_grp_prim_qty
9683 FROM mtl_transaction_lots_interface
9684 WHERE product_transaction_id = p_product_txn_id
9685 AND lot_number = p_lot_number
9686 AND product_code = 'RCV';
9687 EXCEPTION
9688 WHEN OTHERS THEN
9689 IF (l_debug = 1) THEN
9690 print_debug('validate_lot_qty: 32 When Others Exception' , 4);
9691 END IF;
9692 l_current_grp_prim_qty := 0;
9693 END;
9694 ELSE
9695 l_current_grp_prim_qty := 0;
9696 END IF;
9697
9698 IF (l_debug = 1) THEN
9699 print_debug('validate_lot_qty: 33 RLS Qty : ' || l_rlsu_primary_quantity,4);
9700 print_debug('validate_lot_qty: 34 MTLI QTY : ' || l_mtli_primary_quantity,4);
9701 print_debug('validate_lot_qty: 34 l_current_grp_prim_qty : ' || l_current_grp_prim_qty,4);
9702 END IF;
9703
9704 IF (p_lot_primary_qty > (l_rlsu_primary_quantity - (l_mtli_primary_quantity + l_current_grp_prim_qty) )) THEN
9705 fnd_message.set_name('INV', 'INV_MAX_QTY');
9706 fnd_message.set_token('TOKEN', l_rlsu_primary_quantity - (l_mtli_primary_quantity + l_current_grp_prim_qty));
9707 fnd_msg_pub.add;
9708 x_return_status := fnd_api.g_ret_sts_error;
9709 IF (l_debug = 1) THEN
9710 print_debug('validate_lot_qty: 33 Receiving Lot Qty : ' || p_lot_primary_qty || ' cannot be more than Shipped Qty : ' || l_rlsu_primary_quantity , 4);
9711 END IF;
9712 ELSE
9713 RETURN;
9714 END IF;
9715
9716 EXCEPTION
9717 WHEN OTHERS THEN
9718 x_return_status := fnd_api.g_ret_sts_error;
9719 IF (l_debug = 1) THEN
9720 print_debug('validate_lot_qty: Exception occured! Exiting...', 4);
9721 END IF;
9722 END validate_lot_qty;
9723
9724 --Added to fix the Bug #6908946
9725 --overload the procedure created above
9726 --with one more parameter, p_from_lpn_id
9727 PROCEDURE validate_lot_qty(
9728 p_lot_number IN VARCHAR2
9729 , p_inventory_item_id IN NUMBER
9730 , p_lot_txn_qty IN NUMBER
9731 , p_lot_primary_qty IN NUMBER
9732 , p_shipment_header_id IN NUMBER
9733 , p_rcv_org_id IN NUMBER
9734 , p_product_txn_id IN NUMBER
9735 , p_from_lpn_id IN NUMBER
9736 , x_return_status OUT NOCOPY VARCHAR2
9737 ) IS
9738 l_rlsu_primary_quantity RCV_LOTS_SUPPLY.PRIMARY_QUANTITY%TYPE := 0;
9739 l_mtli_primary_quantity NUMBER := 0;
9740 l_current_grp_prim_qty NUMBER := 0;
9741 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
9742 l_lot_code NUMBER := 0; --bug number 12814511
9743
9744 BEGIN
9745 IF (l_debug = 1) THEN
9746 print_debug('validate_lot_qty J: 10 Entering into Lot Qty Validation Procedure' , 4);
9747 print_debug('validate_lot_qty J: 20 Validating for lot: ' || p_lot_number || ' Item: ' || p_inventory_item_id || ' shipment_hdr_id: '|| p_shipment_header_id , 4);
9748 print_debug('validate_lot_qty J: 30 txn_qty :' || p_lot_txn_qty || ' p_lot_primary_qty: ' || p_lot_primary_qty || ' p_rcv_org_id: ' || p_rcv_org_id , 4);
9749 print_debug('validate_lot_qty J: 31 p_shipment_header_id:' || p_shipment_header_id);
9750 print_debug('validate_lot_qty J: 32 p_prod_txn_id:' || p_product_txn_id);
9751 print_debug('validate_lot_qty J: 33 p_from_lpn_id:' || p_from_lpn_id);
9752 END IF;
9753
9754 x_return_status := fnd_api.g_ret_sts_success;
9755
9756 --start bug 12814511
9757 BEGIN
9758 SELECT lot_control_code
9759 INTO l_lot_code
9760 FROM mtl_system_items_b
9761 WHERE inventory_item_id = p_inventory_item_id
9762 AND ORGANIZATION_id = (SELECT ORGANIZATION_id FROM
9763 rcv_shipment_headers WHERE SHIPMENT_HEADER_ID =p_shipment_header_id);
9764 IF (l_debug = 1) THEN
9765 print_debug(' l_lot_code: '|| l_lot_code , 4);
9766 END IF;
9767
9768 EXCEPTION
9769 WHEN OTHERS THEN
9770 IF (l_debug = 1) THEN
9771 print_debug('lot_control_code: 34 When Others Exception' , 4);
9772 END IF;
9773 l_lot_code := 0;
9774 END;
9775
9776
9777 IF(l_lot_code = 1) THEN
9778 -- condition added to return success for the bug number 12814511,
9779 -- No validation required for the receiving of lot controlled item when the source org has a plain item control,
9780 -- as the above validation procedure is based on the rcv_lots_supply
9781 -- where as in case of plain item in source org the rcv_lots_supply is not present
9782 -- so the total qty would be validated against the entered qty.
9783 RETURN;
9784 END IF;
9785 -- end bug 12814511
9786
9787 BEGIN
9788 SELECT NVL(SUM(rlsu.primary_quantity),0)
9789 INTO l_rlsu_primary_quantity
9790 FROM rcv_lots_supply rlsu,
9791 rcv_shipment_lines rsl
9792 WHERE rlsu.shipment_line_id = rsl.shipment_line_id
9793 AND rsl.item_id = p_inventory_item_id
9794 AND rsl.to_organization_id = p_rcv_org_id
9795 AND rsl.shipment_header_id = p_shipment_header_id
9796 AND rlsu.lot_num = p_lot_number
9797 AND rlsu.supply_type_code = 'SHIPMENT'
9798 AND Nvl(rsl.asn_lpn_id,-1) = Nvl(decode(p_from_lpn_id,0,NULL,p_from_lpn_id),Nvl(rsl.asn_lpn_id,-1));
9799
9800 print_debug('validate_lot_qty: 31 l_rlsu_primary_quantity' || l_rlsu_primary_quantity , 4);
9801 EXCEPTION
9802 WHEN OTHERS THEN
9803 IF (l_debug = 1) THEN
9804 print_debug('validate_lot_qty: 31 When Others Exception' , 4);
9805 END IF;
9806 l_rlsu_primary_quantity := 0 ;
9807 END;
9808
9809 BEGIN
9810 SELECT NVL(SUM(mtli.primary_quantity),0)
9811 INTO l_mtli_primary_quantity
9812 FROM mtl_transaction_lots_interface mtli,
9813 rcv_transactions_interface rti
9814 WHERE rti.processing_status_code <> 'ERROR'
9815 AND rti.transaction_status_code <> 'ERROR'
9816 AND rti.to_organization_id = p_rcv_org_id
9817 AND rti.item_id = p_inventory_item_id
9818 AND rti.shipment_header_id = p_shipment_header_id
9819 AND rti.interface_transaction_id = mtli.product_transaction_id
9820 AND mtli.lot_number = p_lot_number
9821 AND mtli.product_code = 'RCV'
9822 AND Nvl(rti.lpn_id,-1) = Nvl(decode(p_from_lpn_id,0,NULL,p_from_lpn_id),Nvl(rti.lpn_id,-1));
9823 EXCEPTION
9824 WHEN OTHERS THEN
9825 IF (l_debug = 1) THEN
9826 print_debug('validate_lot_qty: 32 When Others Exception' , 4);
9827 END IF;
9828 l_mtli_primary_quantity := 0;
9829 END;
9830
9831 IF (p_product_txn_id IS NOT NULL) THEN
9832 BEGIN
9833 SELECT Nvl(SUM(primary_quantity),0)
9834 INTO l_current_grp_prim_qty
9835 FROM mtl_transaction_lots_interface
9836 WHERE product_transaction_id = p_product_txn_id
9837 AND lot_number = p_lot_number
9838 AND product_code = 'RCV';
9839 EXCEPTION
9840 WHEN OTHERS THEN
9841 IF (l_debug = 1) THEN
9842 print_debug('validate_lot_qty: 32 When Others Exception' , 4);
9843 END IF;
9844 l_current_grp_prim_qty := 0;
9845 END;
9846 ELSE
9847 l_current_grp_prim_qty := 0;
9848 END IF;
9849
9850 IF (l_debug = 1) THEN
9851 print_debug('validate_lot_qty: 33 RLS Qty : ' || l_rlsu_primary_quantity,4);
9852 print_debug('validate_lot_qty: 34 MTLI QTY : ' || l_mtli_primary_quantity,4);
9853 print_debug('validate_lot_qty: 34 l_current_grp_prim_qty : ' || l_current_grp_prim_qty,4);
9854 END IF;
9855
9856 IF (p_lot_primary_qty > (l_rlsu_primary_quantity - (l_mtli_primary_quantity + l_current_grp_prim_qty) )) THEN
9857 fnd_message.set_name('INV', 'INV_MAX_QTY');
9858 fnd_message.set_token('TOKEN', l_rlsu_primary_quantity - (l_mtli_primary_quantity + l_current_grp_prim_qty));
9859 fnd_msg_pub.add;
9860 x_return_status := fnd_api.g_ret_sts_error;
9861 IF (l_debug = 1) THEN
9862 print_debug('validate_lot_qty: 33 Receiving Lot Qty : ' || p_lot_primary_qty || ' cannot be more than Shipped Qty : ' || l_rlsu_primary_quantity , 4);
9863 END IF;
9864 ELSE
9865 RETURN;
9866 END IF;
9867
9868 EXCEPTION
9869 WHEN OTHERS THEN
9870 x_return_status := fnd_api.g_ret_sts_error;
9871 IF (l_debug = 1) THEN
9872 print_debug('validate_lot_qty: Exception occured! Exiting...', 4);
9873 END IF;
9874 END validate_lot_qty;
9875
9876 END inv_rcv_std_rcpt_apis;