1 PACKAGE BODY rcv_roi_return
2 /* $Header: RCVPRERB.pls 120.6.12020000.2 2012/07/10 09:27:37 ptkumar ship $*/
3 AS
4 g_asn_debug VARCHAR2(1) := asn_debug.is_debug_on; -- Bug 9152790
5 x_progress VARCHAR2(3);
6 p_trx_record rcv_roi_header_common.common_default_record_type;
7 default_return_info default_return%ROWTYPE;
8
9 PROCEDURE derive_return_line(
10 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
11 n IN OUT NOCOPY BINARY_INTEGER,
12 temp_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
13 x_header_record IN rcv_roi_preprocessor.header_rec_type
14 ) IS
15 BEGIN
16 x_progress := '010';
17 asn_debug.put_line('enter derive_return_line ');
18 /* Derive the to_org_id */
19 derive_ship_to_org_info(x_cascaded_table,
20 n,
21 x_header_record
22 );
23
24 IF (x_cascaded_table(n).unit_of_measure IS NOT NULL) THEN
25 IF (g_asn_debug = 'Y') THEN
26 asn_debug.put_line('X_progress ' || x_progress);
27 END IF;
28
29 SELECT muom.uom_code
30 INTO x_cascaded_table(n).uom_code
31 FROM mtl_units_of_measure muom
32 WHERE muom.unit_of_measure = x_cascaded_table(n).unit_of_measure;
33 ELSE
34 IF (g_asn_debug = 'Y') THEN
35 asn_debug.put_line('uom_code not dereived as unit_of_measure is null');
36 END IF;
37 END IF;
38
39 x_progress := '020';
40 derive_reason_info(x_cascaded_table, n);
41 /* Auto_transact_code is null for all these transaction types */
42 x_cascaded_table(n).auto_transact_code := NULL;
43 rcv_roi_transaction.derive_from_locator_id(x_cascaded_table, n); -- WMS Change
44 rcv_roi_transaction.derive_to_locator_id(x_cascaded_table, n); -- WMS Change
45 derive_return_line_qty(x_cascaded_table,
46 n,
47 temp_cascaded_table
48 );
49 END derive_return_line;
50
51 PROCEDURE default_return_line(
52 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
53 n IN BINARY_INTEGER
54 ) IS
55 BEGIN
56 asn_debug.put_line('Enter Default');
57 default_common_lines(x_cascaded_table, n);
58
59 IF (x_cascaded_table(n).derive = 'Y') THEN --{
60 IF (x_cascaded_table(n).derive_index <> 0) THEN --{
61 NULL;
62 /* Get the values from pl/sql table */
63 ELSE --} {
64 asn_debug.put_line('open cursor Default');
65 OPEN default_return_rti(x_cascaded_table(n).parent_interface_txn_id);
66 END IF; --}
67 ELSE -- } {
68 OPEN default_return(x_cascaded_table(n).parent_transaction_id);
69 END IF; --}
70
71 IF (default_return%ISOPEN) THEN
72 asn_debug.put_line('fetch cursor Default ' || x_cascaded_table(n).parent_transaction_id);
73 FETCH default_return INTO default_return_info;
74 ELSIF(default_return_rti%ISOPEN) THEN
75 FETCH default_return_rti INTO default_return_info;
76 END IF;
77
78 IF ( ( default_return%ISOPEN
79 AND default_return%FOUND)
80 OR ( default_return_rti%ISOPEN
81 AND default_return_rti%FOUND)) THEN --{
82 IF (x_cascaded_table(n).transaction_type = 'RETURN TO VENDOR')
83 OR ( x_cascaded_table(n).transaction_type = 'RETURN TO RECEIVING'
84 AND x_cascaded_table(n).source_document_code = 'PO') THEN
85
86 default_po_info(x_cascaded_table,
87 n,
88 default_return_info
89 );
90 default_vendor_info(x_cascaded_table,
91 n,
92 default_return_info
93 );
94 ELSIF (x_cascaded_table(n).transaction_type = 'RETURN TO CUSTOMER')
95 OR ( x_cascaded_table(n).transaction_type = 'RETURN TO RECEIVING'
96 AND x_cascaded_table(n).source_document_code = 'RMA') THEN
97 default_oe_info(x_cascaded_table,
98 n,
99 default_return_info
100 );
101 default_customer_info(x_cascaded_table,
102 n,
103 default_return_info
104 );
105 END IF;
106
107 default_shipment_info(x_cascaded_table,
108 n,
109 default_return_info
110 );
111 default_wip_info(x_cascaded_table,
112 n,
113 default_return_info
114 );
115 default_currency_info(x_cascaded_table,
116 n,
117 default_return_info
118 );
119 default_deliver_to_info(x_cascaded_table,
120 n,
121 default_return_info
122 );
123 default_source_info(x_cascaded_table,
124 n,
125 default_return_info
126 );
127 default_item_info(x_cascaded_table,
128 n,
129 default_return_info
130 );
131 default_destination_info(x_cascaded_table,
132 n,
133 default_return_info
134 );
135 default_location_info(x_cascaded_table,
136 n,
137 default_return_info
138 );
139 default_movement_id(x_cascaded_table,
140 n,
141 default_return_info
142 );
143 default_bom_resource_id(x_cascaded_table,
144 n,
145 default_return_info
146 );
147 -- default the parent's to_lpn into the child's from_lpn
148 END IF; -- if default_return%FOUND is true }
149
150 /* FPJ WMS CHANGES START */
151 IF (x_cascaded_table(n).from_subinventory IS NULL) THEN
152 rcv_roi_transaction.default_from_subloc_info(x_cascaded_table, n);
153 END IF;
154
155 rcv_roi_transaction.default_to_subloc_info(x_cascaded_table, n);
156 /* FPJ WMS CHANGES END */
157
158 IF (g_asn_debug = 'Y') THEN
159 asn_debug.put_line('Set Location_id = ' || TO_CHAR(x_cascaded_table(n).location_id));
160 END IF;
161
162 IF (g_asn_debug = 'Y') THEN
163 asn_debug.put_line('Exit default_vendor_correct');
164 END IF;
165
166 IF default_return%ISOPEN THEN
167 CLOSE default_return;
168 END IF;
169
170 IF default_return_rti%ISOPEN THEN
171 CLOSE default_return_rti;
172 END IF;
173 EXCEPTION
174 WHEN OTHERS THEN
175 NULL;
176 END default_return_line;
177
178 PROCEDURE derive_reason_info(
179 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
180 n IN OUT NOCOPY BINARY_INTEGER
181 ) IS
182 reason_id_record rcv_shipment_line_sv.reason_id_record_type;
183 BEGIN
184 IF (x_cascaded_table(n).error_status IN('S', 'W'))
185 AND ( x_cascaded_table(n).reason_id IS NULL
186 AND x_cascaded_table(n).reason_name IS NOT NULL) THEN
187 IF (g_asn_debug = 'Y') THEN
188 asn_debug.put_line('X_progress ' || x_progress);
189 END IF;
190
191 reason_id_record.reason_name := x_cascaded_table(n).reason_name;
192 reason_id_record.error_record.error_status := 'S';
193 reason_id_record.error_record.error_message := NULL;
194
195 IF (g_asn_debug = 'Y') THEN
196 asn_debug.put_line('Derive Reason_id');
197 END IF;
198
199 rcv_transactions_interface_sv.get_reason_id(reason_id_record);
200 x_cascaded_table(n).reason_id := reason_id_record.reason_id;
201 x_cascaded_table(n).error_status := reason_id_record.error_record.error_status;
202 x_cascaded_table(n).error_message := reason_id_record.error_record.error_message;
203 END IF;
204 END derive_reason_info;
205
206 PROCEDURE derive_ship_to_org_info(
207 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
208 n IN OUT NOCOPY BINARY_INTEGER,
209 x_header_record IN rcv_roi_preprocessor.header_rec_type
210 ) IS
211 ship_to_org_record rcv_shipment_object_sv.organization_id_record_type;
212 x_to_organization_code VARCHAR2(5);
213 BEGIN
214 -- default org from header in case it is null at the line level
215
216 IF x_cascaded_table(n).to_organization_code IS NULL
217 AND x_cascaded_table(n).error_status IN('S', 'W') THEN
218 IF (g_asn_debug = 'Y') THEN
219 asn_debug.put_line('Attempting to default the org from the ship to location');
220 END IF;
221
222 IF (x_cascaded_table(n).ship_to_location_code IS NOT NULL) THEN
223 SELECT max(mp.organization_code)
224 INTO x_to_organization_code
225 FROM hr_locations hl,
226 mtl_parameters mp
227 WHERE x_cascaded_table(n).ship_to_location_code = hl.location_code
228 AND hl.inventory_organization_id = mp.organization_id;
229
230 x_cascaded_table(n).to_organization_code := x_to_organization_code;
231
232 IF (g_asn_debug = 'Y') THEN
233 asn_debug.put_line('Set Org Code using location code = ' || x_cascaded_table(n).to_organization_code);
234 END IF;
235 END IF;
236
237 IF ( x_cascaded_table(n).to_organization_code IS NULL
238 AND x_header_record.header_record.ship_to_organization_code IS NOT NULL) THEN
239 IF (g_asn_debug = 'Y') THEN
240 asn_debug.put_line('Will default org change DUH to ' || x_header_record.header_record.ship_to_organization_code);
241 END IF;
242
243 x_cascaded_table(n).to_organization_code := x_header_record.header_record.ship_to_organization_code;
244 END IF;
245 END IF;
246
247 -- call derivation procedures if conditions are met
248
249 IF (x_cascaded_table(n).error_status IN('S', 'W'))
250 AND ( x_cascaded_table(n).to_organization_id IS NULL
251 AND x_cascaded_table(n).to_organization_code IS NOT NULL) THEN
252 IF (g_asn_debug = 'Y') THEN
253 asn_debug.put_line('X_Progress ' || x_progress);
254 END IF;
255
256 ship_to_org_record.organization_code := x_cascaded_table(n).to_organization_code;
257 ship_to_org_record.organization_id := x_cascaded_table(n).to_organization_id;
258 ship_to_org_record.error_record.error_status := 'S';
259 ship_to_org_record.error_record.error_message := NULL;
260
261 IF (g_asn_debug = 'Y') THEN
262 asn_debug.put_line('Into Derive Organization Record Procedure');
263 END IF;
264
265 po_orgs_sv.derive_org_info(ship_to_org_record);
266
267 IF (g_asn_debug = 'Y') THEN
268 asn_debug.put_line('Debug Output after organization procedure');
269 asn_debug.put_line(ship_to_org_record.organization_code);
270 asn_debug.put_line(TO_CHAR(ship_to_org_record.organization_id));
271 asn_debug.put_line(ship_to_org_record.error_record.error_status);
272 asn_debug.put_line('Debug organization output over');
273 END IF;
274
275 x_cascaded_table(n).to_organization_code := ship_to_org_record.organization_code;
276 x_cascaded_table(n).to_organization_id := ship_to_org_record.organization_id;
277 x_cascaded_table(n).error_status := ship_to_org_record.error_record.error_status;
278 x_cascaded_table(n).error_message := ship_to_org_record.error_record.error_message;
279 END IF;
280 END derive_ship_to_org_info;
281
282 PROCEDURE derive_return_line_qty(
283 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
284 n IN OUT NOCOPY BINARY_INTEGER,
285 temp_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type
286 ) IS
287 quantity_not_postive_exception EXCEPTION;
288 no_parent_line_exception EXCEPTION;
289 reject_exception EXCEPTION;
290 po_shipment_cancel_exception EXCEPTION; -- bug 8640033
291 x_record_count NUMBER;
292 x_remaining_quantity NUMBER := 0;
293 x_remaining_qty_po_uom NUMBER := 0;
294 x_bkp_qty NUMBER := 0;
295 x_progress VARCHAR2(3);
296 x_to_organization_code VARCHAR2(5);
297 x_converted_trx_qty NUMBER := 0;
298 transaction_ok BOOLEAN := FALSE;
299 rows_fetched NUMBER := 0;
300 x_tolerable_qty NUMBER := 0;
301 x_first_trans BOOLEAN := TRUE;
302 x_sysdate DATE := SYSDATE;
303 current_n BINARY_INTEGER := 0;
304 insert_into_table BOOLEAN := FALSE;
305 x_qty_rcv_exception_code po_line_locations.qty_rcv_exception_code%TYPE;
306 tax_amount_factor NUMBER;
307 po_asn_uom_qty NUMBER;
308 po_primary_uom_qty NUMBER;
309 already_allocated_qty NUMBER := 0;
310 x_item_id NUMBER;
311 x_approved_flag VARCHAR(1);
312 x_cancel_flag VARCHAR(1);
313 x_closed_code VARCHAR(25);
314 x_shipment_type VARCHAR(25);
315 x_ship_to_organization_id NUMBER;
316 x_ship_to_location_id NUMBER;
317 x_vendor_product_num VARCHAR(25);
318 x_temp_count NUMBER;
319 x_full_name VARCHAR2(240) := NULL; -- Bug 2392074
320 x_secondary_available_qty NUMBER := 0;
321
322 /********************************************************************/
323 CURSOR derive_return(
324 v_parent_trx_id NUMBER
325 ) IS
326 SELECT rsl.item_id,
327 rt.po_line_id,
328 rt.transaction_type,
329 rt.po_header_id,
330 rt.po_line_location_id,
331 rt.parent_transaction_id,
332 rt.primary_unit_of_measure,
333 rt.quantity,
334 rt.transaction_id,
335 rt.unit_of_measure
336 FROM rcv_transactions rt,
337 rcv_shipment_lines rsl
338 WHERE transaction_id = v_parent_trx_id
339 AND rt.shipment_line_id = rsl.shipment_line_id
340 -- bug 8640033
341 AND NOT EXISTS(SELECT 'purchase order shipment cancelled or fc'
342 FROM po_line_locations pll
343 WHERE pll.line_location_id = rt.po_line_location_id
344 AND ( NVL(pll.cancel_flag, 'N') = 'Y'
345 OR NVL(pll.closed_code, 'OPEN') = 'FINALLY CLOSED'));
346 -- end bug 8640033
347
348 CURSOR derive_return_rti(
349 v_parent_interface_txn_id NUMBER
350 ) IS
351 SELECT rti.item_id,
352 rti.po_line_id,
353 rti.transaction_type,
354 rti.po_header_id,
355 rti.po_line_location_id,
356 rti.parent_transaction_id,
357 rti.primary_unit_of_measure,
358 rti.quantity,
359 rti.interface_transaction_id transaction_id,
360 rti.unit_of_measure
361 FROM rcv_transactions_interface rti
362 WHERE interface_transaction_id = v_parent_interface_txn_id;
363
364 x_derive_returnrec derive_return%ROWTYPE;
365 x_temp_parent_trx_qty NUMBER := 0;
366 x_converted_parent_trx_qty NUMBER := 0;
367 x_temp_convert_parent_trx_qty NUMBER := 0;
368 x_remaining_qty_parent_uom NUMBER := 0;
369 l_to_organization_id NUMBER := 0;
370 l_supply_type_code rcv_supply.supply_type_code%TYPE;
371 l_transaction_type rcv_transactions.transaction_type%TYPE;
372 x_temp_already_allocated_qty NUMBER := 0;
373 derive_values_from_table BOOLEAN := FALSE;
374 derive_values_from_rti BOOLEAN := FALSE;
375 already_derived BOOLEAN := FALSE;
376 cascaded_table_index NUMBER;
377 l_parent_transaction_type rcv_transactions.transaction_type%TYPE;
378 l_grand_parent_trx_id rcv_transactions.parent_transaction_id%TYPE;
379 temp_index NUMBER;
380 l_po_header_id po_headers_all.po_header_id%type;
381 l_return_status VARCHAR2(1) :='S';
382 l_complex_flag varchar2(1);
383 l_exist VARCHAR2(30); -- bug 8640033
384
385 BEGIN
386 asn_debug.put_line('enter derive_quantity ' || x_cascaded_table(n).parent_transaction_id);
387
388 -- try to derive the parent_trx_id from rt. if the parent line is not in rt,
389 -- try get it from rti or plsql table.
390 IF (x_cascaded_table(n).parent_transaction_id IS NULL) THEN
391 rcv_roi_transaction.derive_parent_id(x_cascaded_table, n);
392 END IF;
393
394 IF (x_cascaded_table(n).parent_transaction_id IS NOT NULL) THEN --{
395 asn_debug.put_line('open rt cursor with parent_trx_id: ' || x_cascaded_table(n).parent_transaction_id);
396 OPEN derive_return(x_cascaded_table(n).parent_transaction_id);
397 ELSE
398 IF --{
399 ( (x_cascaded_table(n).error_status <> 'E')
400 AND (x_cascaded_table(n).derive_index = 0)) THEN
401 /** This means that there was no error in derive_parent_id()
402 * but the parent_trx_id is not populated. The line is a child
403 * and need to get the values from the rti or the plsql table.
404 * If derive_values_from_table is true we will
405 * derive the values from the pl/sql tables later
406 * at the time when we try to see which cursor is open.
407 */
408 asn_debug.put_line('open rti cursor');
409 OPEN derive_return_rti(x_cascaded_table(n).parent_interface_txn_id);
410 END IF;
411 END IF; --}
412
413 /******************************************************************/
414 --check line quanity > 0
415 x_progress := '097';
416
417 IF (g_asn_debug = 'Y') THEN
418 asn_debug.put_line('X_progress ' || x_progress);
419 END IF;
420
421 IF x_cascaded_table(n).error_status IN('S', 'W')
422 AND x_cascaded_table(n).quantity <= 0 THEN --{
423 IF (g_asn_debug = 'Y') THEN
424 asn_debug.put_line('Quantity is <= zero. quantity derive will fail');
425 END IF;
426
427 RAISE quantity_not_postive_exception;
428 END IF; --} end qty > 0 check
429
430 -- the following steps will create a set of rows linking the line_record with
431 -- its corresponding po_line_location rows until the quantity value from
432 -- the asn is consumed. (Cascade)
433 -- For return, there will be no cascade since there's only 1 parent txn per
434 -- return, the temp_cascade_table will be deprecated in phase 2 -pjiang
435
436 /* 2119137 : If the user populates rcv_transactions_interface
437 with po_line_id, then ROI errors out with
438 RCV_ASN_NO_PO_LINE_LOCATION_ID when the document_line_num
439 is not provided for one time items. Modified the "if" criteria in
440 such a way that the ROI validation does'nt error out when
441 po_line_id is populated for one time items. */
442 x_progress := '098';
443
444 IF (g_asn_debug = 'Y') THEN
445 asn_debug.put_line('X_progress ' || x_progress);
446 END IF;
447
448 IF ( ( x_cascaded_table(n).parent_transaction_id IS NOT NULL
449 OR x_cascaded_table(n).parent_interface_txn_id IS NOT NULL)
450 AND x_cascaded_table(n).error_status IN('S', 'W')) THEN --{
451 -- Copy record from main table to temp table
452 IF (g_asn_debug = 'Y') THEN
453 asn_debug.put_line('Copy record from main table to temp table');
454 END IF;
455
456 current_n := 1;
457 temp_cascaded_table(current_n) := x_cascaded_table(n);
458
459 -- Get all rows which meet this condition
460 IF (g_asn_debug = 'Y') THEN
461 asn_debug.put_line('Get all rows which meet this condition');
462 asn_debug.put_line('Transaction Type = ' || x_cascaded_table(n).transaction_type);
463 asn_debug.put_line('Auto Transact Code = ' || x_cascaded_table(n).auto_transact_code);
464 END IF;
465
466 -- Assign shipped quantity to remaining quantity
467 IF (g_asn_debug = 'Y') THEN
468 asn_debug.put_line('Assign populated quantity to remaining quantity');
469 asn_debug.put_line('Pointer in temp_cascade ' || TO_CHAR(current_n));
470 END IF;
471
472 x_remaining_quantity := temp_cascaded_table(current_n).quantity;
473 x_bkp_qty := x_remaining_quantity; -- used for decrementing cum qty for first record
474 x_remaining_qty_po_uom := 0;
475
476 IF (g_asn_debug = 'Y') THEN
477 asn_debug.put_line('Have assigned the quantity');
478 END IF;
479
480 -- Calculate tax_amount_factor for calculating tax_amount for
481 -- each cascaded line
482
483 tax_amount_factor := NVL(temp_cascaded_table(current_n).tax_amount, 0) / x_remaining_quantity;
484
485 IF (g_asn_debug = 'Y') THEN
486 asn_debug.put_line('Tax Factor ' || TO_CHAR(tax_amount_factor));
487 asn_debug.put_line('transaction Quantity : ' || TO_CHAR(x_remaining_quantity));
488 END IF;
489
490 x_first_trans := TRUE;
491 transaction_ok := FALSE;
492
493 IF (g_asn_debug = 'Y') THEN
494 asn_debug.put_line('Before starting Cascade');
495 END IF;
496
497 IF (g_asn_debug = 'Y') THEN
498 asn_debug.put_line('Record Count = ' || x_record_count);
499 END IF;
500
501 LOOP --{ The loop will be removed since there is no cascading.
502 IF (g_asn_debug = 'Y') THEN
503 asn_debug.put_line('Backup Qty ' || TO_CHAR(x_bkp_qty));
504 asn_debug.put_line('Remaining Quantity ' || TO_CHAR(x_remaining_quantity));
505 END IF;
506
507 /*
508 ** Fetch the appropriate record
509 */
510 IF (g_asn_debug = 'Y') THEN
511 asn_debug.put_line('DEBUG: transaction_type = ' || x_cascaded_table(n).transaction_type);
512 END IF;
513
514 IF (derive_return%ISOPEN) THEN --{
515 asn_debug.put_line('fetch derive_return');
516 FETCH derive_return INTO x_derive_returnrec;
517
518 IF (derive_return%NOTFOUND) THEN
519 EXIT;
520 END IF;
521
522 rows_fetched := derive_return%ROWCOUNT;
523 ELSIF(derive_return_rti%ISOPEN) THEN --}{
524 asn_debug.put_line('pjiang fetch derive_return_rti');
525 FETCH derive_return_rti INTO x_derive_returnrec;
526
527 IF (derive_return_rti%NOTFOUND) THEN
528 EXIT;
529 END IF;
530
531 rows_fetched := derive_return_rti%ROWCOUNT;
532 ELSIF(temp_cascaded_table(current_n).derive = 'Y') THEN --}{
533 /* GET VALUES FROM THE PLSQL TABLE */
534 asn_debug.put_line('pjiang: fetch pl/sql table');
535 temp_index := temp_cascaded_table(current_n).derive_index;
536 x_derive_returnrec.po_line_location_id := x_cascaded_table(temp_index).po_line_location_id;
537 x_derive_returnrec.po_header_id := x_cascaded_table(temp_index).po_header_id;
538 x_derive_returnrec.po_line_id := x_cascaded_table(temp_index).po_line_id;
539 x_derive_returnrec.unit_of_measure := x_cascaded_table(temp_index).unit_of_measure;
540 x_derive_returnrec.parent_transaction_id := x_cascaded_table(temp_index).parent_transaction_id;
541 x_derive_returnrec.transaction_type := x_cascaded_table(temp_index).transaction_type;
542 x_derive_returnrec.quantity := x_cascaded_table(temp_index).quantity;
543 x_derive_returnrec.primary_unit_of_measure := x_cascaded_table(temp_index).primary_unit_of_measure;
544 x_derive_returnrec.item_id := x_cascaded_table(temp_index).item_id;
545 x_derive_returnrec.transaction_id := NULL;
546 rows_fetched := 1;
547 END IF; --}
548
549
550 /* R12 Complex work.
551 * We do not support any other receiving transactions other
552 * than direct receipt. Error out if it is complex work PO.
553 */
554
555 PO_COMPLEX_WORK_GRP.is_complex_work_po(
556 1.0,
557 x_cascaded_table(n).po_header_id,
558 l_return_status,
559 l_complex_flag);
560
561 IF (l_return_status IS NOT NULL AND
562 l_return_status = FND_API.g_ret_sts_success) THEN
563 IF( g_asn_debug = 'Y' ) THEN
564 asn_debug.put_line('l_return_status ' || l_return_status);
565 asn_debug.put_line('l_po_header_id ' || l_po_header_id);
566 END IF;
567 ELSE
568 IF( g_asn_debug = 'Y') THEN
569 asn_debug.put_line('l_return_status ' || l_return_status);
570 END IF;
571 END IF;
572
573 IF (l_complex_flag = 'Y') THEN
574 asn_debug.put_line('We do not support transaction type ' || x_cascaded_table(n).transaction_type || ' for complex work POs');
575 rcv_error_pkg.set_error_message('RCV_INVALID_TRANSACTION_TYPE');
576 rcv_error_pkg.log_interface_error('TRANSACTION_TYPE');
577 End if;
578
579 l_parent_transaction_type := x_derive_returnrec.transaction_type;
580 l_grand_parent_trx_id := x_derive_returnrec.parent_transaction_id;
581
582 IF (g_asn_debug = 'Y') THEN
583 asn_debug.put_line('Parent transaction rows fetched: (should always be 1 for return) ' || TO_CHAR(rows_fetched));
584 asn_debug.put_line('po_line_id ' || TO_CHAR(x_derive_returnrec.po_line_id));
585 asn_debug.put_line('po_line_location_id ' || TO_CHAR(x_derive_returnrec.po_line_location_id));
586 -- since there can only be one parent trx, there will be only one allocating
587 asn_debug.put_line('the quantity available for return in parent txn: ' || x_remaining_quantity);
588 END IF;
589
590 temp_cascaded_table(current_n).unit_of_measure := x_derive_returnrec.unit_of_measure;
591 asn_debug.put_line(' Entering qty calculation for return');
592
593 IF (x_first_trans)
594 AND temp_cascaded_table(current_n).item_id IS NULL THEN
595 temp_cascaded_table(current_n).item_id := x_derive_returnrec.item_id;
596 temp_cascaded_table(current_n).primary_unit_of_measure := x_derive_returnrec.primary_unit_of_measure;
597 END IF;
598
599 insert_into_table := FALSE;
600 already_allocated_qty := 0;
601 rcv_roi_transaction.get_interface_available_qty(temp_cascaded_table,
602 current_n,
603 x_converted_parent_trx_qty
604 );
605
606 IF (g_asn_debug = 'Y') THEN
607 asn_debug.put_line('return interface qty ' || x_converted_parent_trx_qty);
608 END IF;
609
610 IF (x_converted_parent_trx_qty = 0) THEN --{
611 IF (temp_cascaded_table(current_n).derive = 'Y') -- derive from plsql table or rti
612 THEN --{
613 x_converted_parent_trx_qty := x_derive_returnrec.quantity;
614 asn_debug.put_line(' derive parent ' || temp_cascaded_table(current_n).parent_interface_txn_id);
615 asn_debug.put_line(' from derive quantity ' || TO_CHAR(x_converted_parent_trx_qty));
616 /* Get x_converted_parent_trx_qty from the pl/sql table or cascaded_table as needed.*/
617 ELSE --}{
618 IF (g_asn_debug = 'Y') THEN --{_
619 asn_debug.put_line('calling get_available_qty for return (Negative Correct)' || x_derive_returnrec.transaction_type);
620 asn_debug.put_line('parameters passed in ............');
621 asn_debug.put_line('1. transaction_type: ' || x_cascaded_table(n).transaction_type);
622 asn_debug.put_line('2. parent id: ' || x_derive_returnrec.transaction_id);
623 asn_debug.put_line('3. receipt source code: ' || x_cascaded_table(n).receipt_source_code);
624 asn_debug.put_line('4. parent transaction_type: ' || x_derive_returnrec.transaction_type);
625 asn_debug.put_line('5. grand parent id: ' || 'NULL');
626 asn_debug.put_line('6. correction type: ' || 'NEGATIVE');
627 asn_debug.put_line('7. available quantity: ' || TO_CHAR(x_converted_parent_trx_qty));
628 asn_debug.put_line('8. tolerable_quantity: ' || TO_CHAR(x_tolerable_qty));
629 asn_debug.put_line('9. unit of measure: ' || x_derive_returnrec.unit_of_measure);
630 asn_debug.put_line('10. 2nd available quantity : ' || TO_CHAR(x_secondary_available_qty));
631 END IF; --}
632
633 /*begin fix of bug 13892629, we were not able perform return from different subinventory*/
634 IF x_derive_returnrec.transaction_type = 'DELIVER' THEN
635
636 rcv_quantities_s.get_deliver_quantity(x_derive_returnrec.transaction_id,
637 x_cascaded_table(n).interface_transaction_id,
638 x_converted_parent_trx_qty,
639 x_derive_returnrec.unit_of_measure,
640 x_secondary_available_qty
641 );
642
643 ELSE
644
645 rcv_quantities_s.get_available_quantity(x_cascaded_table(n).transaction_type,
646 x_derive_returnrec.transaction_id,
647 x_cascaded_table(n).receipt_source_code,
648 x_derive_returnrec.transaction_type,
649 NULL,
650 'NEGATIVE',
651 x_converted_parent_trx_qty,
652 x_tolerable_qty,
653 x_derive_returnrec.unit_of_measure,
654 x_secondary_available_qty
655 );
656
657 END IF;
658 /*end fix of bug 13892629*/
659 --}
660
661 asn_debug.put_line('qty from GET_AVAILABLE_QUANTITY for return is ' || x_converted_parent_trx_qty);
662
663 IF already_allocated_qty > 0 --?????what if <0 caused by positive return?
664 THEN --{
665 x_converted_parent_trx_qty := x_converted_parent_trx_qty - already_allocated_qty;
666 x_tolerable_qty := x_tolerable_qty - already_allocated_qty;
667
668 IF (g_asn_debug = 'Y') THEN
669 asn_debug.put_line(' For return some allocated quantity. Will reduce qty');
670 asn_debug.put_line('Allocated Qty ' || TO_CHAR(already_allocated_qty));
671 asn_debug.put_line('After reducing by allocated qty');
672 asn_debug.put_line('Available Quantity ' || TO_CHAR(x_converted_parent_trx_qty));
673 asn_debug.put_line('Tolerable Quantity ' || TO_CHAR(x_tolerable_qty));
674 asn_debug.put_line('Pointer to temp table ' || TO_CHAR(current_n));
675 END IF;
676 END IF; /* if already_allocated_qty is >0 for return */ --}
677 END IF; /*derive_values_from_rti is false */--}
678 END IF; --} interface_available_qty is 0.
679
680 x_remaining_qty_parent_uom := rcv_transactions_interface_sv.convert_into_correct_qty(x_remaining_quantity,
681 temp_cascaded_table(1).unit_of_measure,
682 temp_cascaded_table(1).item_id,
683 x_derive_returnrec.unit_of_measure
684 );
685
686 IF (x_remaining_qty_parent_uom <= 0) -- this is redundant with the qty check????
687 THEN
688 IF (g_asn_debug = 'Y') THEN
689 asn_debug.put_line(' Return Needs an error message in the interface tables');
690 RAISE quantity_not_postive_exception;
691 END IF;
692 ELSE
693 /* Converted successfully and have some quantity on which we can act */
694 IF (g_asn_debug = 'Y') THEN
695 asn_debug.put_line('Converted trx qty that is available ' || x_converted_parent_trx_qty);
696 asn_debug.put_line('Remaining qty in parents uom that is available ' || x_remaining_qty_parent_uom);
697 END IF;
698
699 IF (x_converted_parent_trx_qty > 0) THEN --{
700 IF (x_converted_parent_trx_qty < x_remaining_qty_parent_uom) THEN --{
701 /* Total quantity available to return is less than the qty
702 * that the user wants to return. Hence we would error out but
703 * to keep the old code we will get the remaining code here and
704 * error out later.
705 */
706 x_remaining_qty_parent_uom := x_remaining_qty_parent_uom - x_converted_parent_trx_qty;
707
708 IF (temp_cascaded_table(current_n).unit_of_measure <> x_derive_returnrec.unit_of_measure) THEN
709 x_remaining_quantity := rcv_transactions_interface_sv.convert_into_correct_qty(x_remaining_qty_parent_uom,
710 x_derive_returnrec.unit_of_measure,
711 temp_cascaded_table(1).item_id,
712 temp_cascaded_table(1).unit_of_measure
713 );
714 ELSE
715 x_remaining_quantity := x_remaining_qty_parent_uom;
716 END IF;
717
718 insert_into_table := TRUE;
719 ELSE --}{
720 IF (g_asn_debug = 'Y') THEN
721 asn_debug.put_line('We are in >= Qty branch ');
722 END IF;
723
724 x_converted_parent_trx_qty := x_remaining_qty_parent_uom;
725 insert_into_table := TRUE;
726 x_remaining_qty_parent_uom := 0;
727 x_remaining_quantity := 0;
728 END IF; --} /* if (x_converted_parent_trx_qty < x_remaining_quantity) then */
729 ELSE /* x_converted_parent_trx_qty >0 */ --}{
730 IF rows_fetched = x_record_count THEN -- {
731 -- last row needs to be inserted anyway
732 -- so that the row can be used based on qty tolerance checks
733 IF (g_asn_debug = 'Y') THEN
734 asn_debug.put_line('Quantity is less then 0 but last record');
735 END IF;
736
737 insert_into_table := TRUE;
738 x_converted_trx_qty := 0;
739 ELSE --}{
740 IF (g_asn_debug = 'Y') THEN
741 asn_debug.put_line('<= 0 Quantity but more records in cursor');
742 END IF;
743
744 x_remaining_qty_po_uom := 0; -- we may have a diff uom on the next iteration
745
746 IF (g_asn_debug = 'Y') THEN
747 asn_debug.put_line('We have to deal with remaining_qty > 0 and x_converted_trx_qty -ve');
748 END IF;
749
750 insert_into_table := FALSE;
751 END IF; --}
752 END IF; /*x_converted_parent_trx_qty >0 */ --}
753 END IF;
754
755 /* Converted qty successfully and we have some quantity on which we can act */
756 asn_debug.put_line('Transaction qty in terms of the parents uom is ' || x_converted_parent_trx_qty);
757
758 IF insert_into_table THEN --{ --start pjiang
759 IF (x_first_trans) THEN --{
760 IF (g_asn_debug = 'Y') THEN
761 asn_debug.put_line('First Time ' || TO_CHAR(current_n));
762 END IF;
763
764 x_first_trans := FALSE;
765 ELSE --}{
766 IF (g_asn_debug = 'Y') THEN
767 asn_debug.put_line('Next Time ' || TO_CHAR(current_n));
768 END IF;
769
770 temp_cascaded_table(current_n) := temp_cascaded_table(current_n - 1);
771 END IF; --}
772
773 temp_cascaded_table(current_n).po_header_id := x_derive_returnrec.po_header_id;
774 temp_cascaded_table(current_n).po_line_id := x_derive_returnrec.po_line_id;
775 temp_cascaded_table(current_n).po_line_location_id := x_derive_returnrec.po_line_location_id;
776 temp_cascaded_table(current_n).primary_unit_of_measure := x_derive_returnrec.primary_unit_of_measure;
777 temp_cascaded_table(current_n).quantity := x_converted_parent_trx_qty;
778
779 IF (temp_cascaded_table(current_n).primary_unit_of_measure <> x_derive_returnrec.unit_of_measure) THEN
780 temp_cascaded_table(current_n).primary_quantity := rcv_transactions_interface_sv.convert_into_correct_qty(x_converted_parent_trx_qty,
781 x_derive_returnrec.unit_of_measure,
782 temp_cascaded_table(current_n).item_id,
783 temp_cascaded_table(current_n).primary_unit_of_measure
784 );
785 ELSE
786 temp_cascaded_table(current_n).primary_quantity := x_converted_parent_trx_qty;
787 END IF;
788
789 asn_debug.put_line('Transaction qty in terms of the primary uom is ' || temp_cascaded_table(current_n).primary_quantity);
790 current_n := current_n + 1;
791 END IF; --}
792 /* Get the available qty in PRIMARY UOM */
793 /*
794 PO_UOM_S.UOM_CONVERT (x_converted_trx_qty,
795 l_uom,
796 x_item_id,
797 x_primary_uom,
798 l_primary_available_qty );
799 */
800 END LOOP; --}
801
802 -- post_fetch_action (x_cascaded_table, n, temp_cascaded_table);
803
804 /* WMS CHANGE.
805 * If derive_inv_quantity returns error, then we set error_status
806 * to E. Close the cursors and return.
807 */
808 IF (x_cascaded_table(n).error_status = 'E') THEN
809 IF derive_return%ISOPEN THEN
810 CLOSE derive_return;
811 END IF;
812
813 IF derive_return_rti%ISOPEN THEN
814 CLOSE derive_return_rti;
815 END IF;
816
817 RETURN;
818 END IF;
819
820 IF (g_asn_debug = 'Y') THEN
821 asn_debug.put_line('Out of the loop');
822 END IF;
823
824 IF NOT x_first_trans THEN
825 -- x_first_trans has been reset which means some cascade has
826 -- happened. Otherwise current_n = 1
827 asn_debug.put_line('current_n before is ' || current_n);
828 current_n := current_n - 1;
829 END IF;
830
831 -- do the tolerance act here
832 IF (g_asn_debug = 'Y') THEN
833 asn_debug.put_line('Temp table pointer ' || TO_CHAR(current_n));
834 asn_debug.put_line('Check which condition has occured');
835 END IF;
836
837
838 -- bug 8640033
839 SELECT MAX('record_exist')
840 INTO l_exist
841 FROM rcv_transactions rt,
842 po_line_locations pll
843 WHERE pll.line_location_id = rt.po_line_location_id
844 AND transaction_id = x_cascaded_table(n).parent_transaction_id
845 AND ( NVL(pll.cancel_flag, 'N') = 'Y'
846 OR NVL(pll.closed_code, 'OPEN') = 'FINALLY CLOSED');
847
848 IF l_exist = 'record_exist' THEN
849 RAISE po_shipment_cancel_exception;
850
851 IF (g_asn_debug = 'Y') THEN
852 asn_debug.put_line('The PO shipment has been cancelled or finally closed ');
853 asn_debug.put_line('Parent transaction id is ' || x_cascaded_table(n).parent_transaction_id );
854 END IF;
855
856 ELSE
857 -- end bug 8640033
858
859 -- lastrecord...we have run out of rows and we still have quantity to allocate
860 -- for return, this means we are trying to return more than the quantity of parent.
861 -- We should simply error out this situation.
862 IF x_remaining_quantity > 0 THEN --{
863 -- reject the transaction if this is the case. Can't return more than what we have.
864 RAISE reject_exception;
865
866 IF (g_asn_debug = 'Y') THEN
867 asn_debug.put_line('There is quantity remaining ');
868 asn_debug.put_line('tolerable quantity now in plsql table ' || temp_cascaded_table(current_n).quantity);
869 END IF;
870 ELSE -- }{
871 IF (g_asn_debug = 'Y') THEN
872 asn_debug.put_line('Remaining UOM quantity is zero ' || TO_CHAR(x_remaining_quantity));
873 asn_debug.put_line('Return the cascaded rows back to the calling procedure');
874 END IF;
875 END IF; --} ends the check for whether last record has been reached
876 END IF; -- end bug 8640033
877
878 asn_debug.put_line('before exit current_n is ' || current_n);
879 ELSE --} {
880 -- error_status and error_message are set after validate_quantity_shipped
881 IF (g_asn_debug = 'Y') THEN
882 asn_debug.put_line('No parent_transaction_id/parent_interface_trx_id ');
883 END IF;
884
885 IF (g_asn_debug = 'Y') THEN
886 asn_debug.put_line('Status = ' || x_cascaded_table(n).error_status);
887 END IF;
888
889 IF x_cascaded_table(n).error_status IN('S', 'W', 'F') THEN --{
890 RAISE no_parent_line_exception;
891 END IF; --}
892
893 RETURN;
894 END IF; -- } of (asn quantity_shipped was valid)
895
896 asn_debug.put_line('before closing cursors current_n is ' || temp_cascaded_table.COUNT);
897
898 IF derive_return%ISOPEN THEN
899 CLOSE derive_return;
900 END IF;
901
902 IF derive_return_rti%ISOPEN THEN
903 CLOSE derive_return_rti;
904 END IF;
905
906 IF (g_asn_debug = 'Y') THEN
907 asn_debug.put_line('Exit explode_line_quantity');
908 END IF;
909 -- handle errors and warnings in exception block
910 EXCEPTION
911 WHEN quantity_not_postive_exception THEN
912 x_cascaded_table(n).error_status := 'F';
913 /* Bug 3250532 : Changed the error message from 'TBD' to 'RCV_ENTER_QTY_GT_ZERO'.
914 */
915 x_cascaded_table(n).error_message := 'RCV_ENTER_QTY_GT_ZERO';
916 rcv_error_pkg.set_error_message(x_cascaded_table(n).error_message);
917 rcv_error_pkg.set_token('ITEM', x_cascaded_table(n).item_num);
918 rcv_error_pkg.log_interface_error('QUANTITY', FALSE);
919 WHEN no_parent_line_exception THEN
920 x_cascaded_table(n).error_status := 'E';
921
922 IF (x_cascaded_table(n).error_message IS NULL) THEN
923 /* Bug 3250532 : Changed the error message from 'TBD' to 'RCV_NO_PARENT_TRANSACTION'.
924 */
925 x_cascaded_table(n).error_message := 'RCV_NO_PARENT_TRANSACTION';
926 END IF;
927
928 rcv_error_pkg.set_error_message(x_cascaded_table(n).error_message);
929 rcv_error_pkg.set_token('DOCUMENT_NUM', x_cascaded_table(n).document_num);
930 rcv_error_pkg.log_interface_error('NUMBER', FALSE);
931 WHEN reject_exception THEN
932 x_cascaded_table(n).error_status := 'E';
933 /* Bug 3250532 : Changed the error message from 'TBD' to 'RCV_TRX_QTY_EXCEEDS_AVAILABLE'.
934 */
935 x_cascaded_table(n).error_message := 'RCV_TRX_QTY_EXCEEDS_AVAILABLE';
936 rcv_error_pkg.set_error_message(x_cascaded_table(n).error_message);
937 rcv_error_pkg.set_token('QTY_A', x_cascaded_table(n).quantity);
938 rcv_error_pkg.set_token('QTY_B', x_cascaded_table(n).quantity - x_remaining_quantity);
939 rcv_error_pkg.log_interface_error('QUANTITY', FALSE);
940 temp_cascaded_table.DELETE;
941
942 -- bug 8640033
943 WHEN po_shipment_cancel_exception THEN
944 x_cascaded_table(n).error_status := 'E';
945
946 x_cascaded_table(n).error_message := 'RCV_PO_SHIPMENT_CANCELLED';
947 rcv_error_pkg.set_error_message(x_cascaded_table(n).error_message);
948 rcv_error_pkg.log_interface_error('PARENT_TRANSACTION_ID', FALSE);
949 -- end bug 8640033
950
951 WHEN OTHERS THEN
952 IF derive_return%ISOPEN THEN
953 CLOSE derive_return;
954 END IF;
955
956 IF derive_return_rti%ISOPEN THEN
957 CLOSE derive_return_rti;
958 END IF;
959
960 x_cascaded_table(n).error_status := 'F';
961
962 IF (g_asn_debug = 'Y') THEN
963 asn_debug.put_line(TO_CHAR(n));
964 asn_debug.put_line(SQLERRM);
965 asn_debug.put_line('error ' || x_progress);
966 END IF;
967 END derive_return_line_qty;
968
969 PROCEDURE default_common_lines(
970 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
971 n IN BINARY_INTEGER
972 ) IS
973 BEGIN
974 p_trx_record.destination_type_code := x_cascaded_table(n).destination_type_code;
975 p_trx_record.transaction_type := x_cascaded_table(n).transaction_type;
976 p_trx_record.processing_mode_code := x_cascaded_table(n).processing_mode_code;
977 p_trx_record.processing_status_code := x_cascaded_table(n).processing_status_code;
978 p_trx_record.transaction_status_code := x_cascaded_table(n).transaction_status_code;
979 p_trx_record.auto_transact_code := x_cascaded_table(n).auto_transact_code;
980 rcv_roi_header_common.commondefaultcode(p_trx_record);
981 x_cascaded_table(n).destination_type_code := p_trx_record.destination_type_code;
982 x_cascaded_table(n).transaction_type := p_trx_record.transaction_type;
983 x_cascaded_table(n).processing_mode_code := p_trx_record.processing_mode_code;
984 x_cascaded_table(n).processing_status_code := p_trx_record.processing_status_code;
985 x_cascaded_table(n).transaction_status_code := p_trx_record.transaction_status_code;
986 x_cascaded_table(n).auto_transact_code := p_trx_record.auto_transact_code;
987 END default_common_lines;
988
989 PROCEDURE default_po_info(
990 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
991 n IN BINARY_INTEGER,
992 default_return_rec IN default_return%ROWTYPE
993 ) IS
994 BEGIN
995 IF (g_asn_debug = 'Y') THEN
996 asn_debug.put_line('Defaulting return po_revision_num ' || default_return_rec.po_revision_num);
997 asn_debug.put_line('Defaulting return po_header_id ' || default_return_rec.po_header_id);
998 asn_debug.put_line('Defaulting return po_release_id ' || default_return_rec.po_release_id);
999 asn_debug.put_line('Defaulting return po_unit_price ' || default_return_rec.po_unit_price);
1000 asn_debug.put_line('Defaulting return po_line_id ' || default_return_rec.po_line_id);
1001 asn_debug.put_line('Defaulting return po_line_location_id ' || default_return_rec.po_line_location_id);
1002 asn_debug.put_line('Defaulting return po_distribution_id ' || default_return_rec.po_distribution_id);
1003 END IF;
1004
1005 x_cascaded_table(n).po_revision_num := default_return_rec.po_revision_num;
1006 x_cascaded_table(n).po_header_id := default_return_rec.po_header_id;
1007 x_cascaded_table(n).po_release_id := default_return_rec.po_release_id;
1008
1009 /* We used to get the unit_price from the cursor where it picks
1010 * up from the parent. But since PO unit_price can be change
1011 * retroactively, we need to pick up the unit_price from PO
1012 * directly. Since we would have derived line_location_id
1013 * and po_line_id at this point, use the values here.
1014 * x_cascaded_table (n).po_unit_price :=
1015 * default_return_rec.po_unit_price;
1016 */
1017 SELECT NVL(pll.price_override, pl.unit_price)
1018 INTO x_cascaded_table(n).po_unit_price
1019 FROM po_line_locations pll,
1020 po_lines pl
1021 WHERE pll.line_location_id = x_cascaded_table(n).po_line_location_id
1022 AND pl.po_line_id = x_cascaded_table(n).po_line_id
1023 AND pl.po_line_id = pll.po_line_id;
1024
1025 IF (g_asn_debug = 'Y') THEN
1026 asn_debug.put_line('Defaulting Return po_unit_price' || x_cascaded_table(n).po_unit_price);
1027 END IF;
1028
1029 x_cascaded_table(n).po_line_id := default_return_rec.po_line_id;
1030 x_cascaded_table(n).po_line_location_id := default_return_rec.po_line_location_id;
1031 x_cascaded_table(n).po_distribution_id := default_return_rec.po_distribution_id;
1032 END default_po_info;
1033
1034 PROCEDURE default_shipment_info(
1035 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1036 n IN BINARY_INTEGER,
1037 default_return_rec IN default_return%ROWTYPE
1038 ) IS
1039 BEGIN
1040 IF (g_asn_debug = 'Y') THEN
1041 asn_debug.put_line('Defaulting Return shipment_header_id ' || default_return_rec.shipment_header_id);
1042 asn_debug.put_line('Defaulting Return shipment_line_id ' || default_return_rec.shipment_line_id);
1043 END IF;
1044
1045 x_cascaded_table(n).shipment_header_id := default_return_rec.shipment_header_id;
1046 x_cascaded_table(n).shipment_line_id := default_return_rec.shipment_line_id;
1047 END default_shipment_info;
1048
1049 PROCEDURE default_wip_info(
1050 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1051 n IN BINARY_INTEGER,
1052 default_return_rec IN default_return%ROWTYPE
1053 ) IS
1054 BEGIN
1055 IF (g_asn_debug = 'Y') THEN
1056 asn_debug.put_line('Defaulting return wip_entity_id ' || default_return_rec.wip_entity_id);
1057 asn_debug.put_line('Defaulting return wip_line_id ' || default_return_rec.wip_line_id);
1058 asn_debug.put_line('Defaulting return wip_repetitive_schedule_id ' || default_return_rec.wip_repetitive_schedule_id);
1059 asn_debug.put_line('Defaulting return wip_operation_seq_num ' || default_return_rec.wip_operation_seq_num);
1060 asn_debug.put_line('Defaulting return wip_resource_seq_num ' || default_return_rec.wip_resource_seq_num);
1061 END IF;
1062
1063 x_cascaded_table(n).wip_entity_id := default_return_rec.wip_entity_id;
1064 x_cascaded_table(n).wip_line_id := default_return_rec.wip_line_id;
1065 x_cascaded_table(n).wip_repetitive_schedule_id := default_return_rec.wip_repetitive_schedule_id;
1066 x_cascaded_table(n).wip_operation_seq_num := default_return_rec.wip_operation_seq_num;
1067 x_cascaded_table(n).wip_resource_seq_num := default_return_rec.wip_resource_seq_num;
1068 END default_wip_info;
1069
1070 PROCEDURE default_oe_info(
1071 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1072 n IN BINARY_INTEGER,
1073 default_return_rec IN default_return%ROWTYPE
1074 ) IS
1075 BEGIN
1076 IF (g_asn_debug = 'Y') THEN
1077 asn_debug.put_line('Defaulting return oe_order_header_id ' || default_return_rec.oe_order_header_id);
1078 asn_debug.put_line('Defaulting return oe_order_line_id ' || default_return_rec.oe_order_line_id);
1079 END IF;
1080
1081 x_cascaded_table(n).oe_order_header_id := default_return_rec.oe_order_header_id;
1082 x_cascaded_table(n).oe_order_line_id := default_return_rec.oe_order_line_id;
1083 END default_oe_info;
1084
1085 PROCEDURE default_currency_info(
1086 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1087 n IN BINARY_INTEGER,
1088 default_return_rec IN default_return%ROWTYPE
1089 ) IS
1090 BEGIN
1091 IF (g_asn_debug = 'Y') THEN
1092 asn_debug.put_line('Defaulting return currency_code ' || default_return_rec.currency_code);
1093 asn_debug.put_line('Defaulting return currency_conversion_type ' || default_return_rec.currency_conversion_type);
1094 asn_debug.put_line('Defaulting return currency_conversion_rate ' || default_return_rec.currency_conversion_rate);
1095 asn_debug.put_line('Defaulting return currency_conversion_date ' || default_return_rec.currency_conversion_date);
1096 END IF;
1097
1098 x_cascaded_table(n).currency_code := default_return_rec.currency_code;
1099 x_cascaded_table(n).currency_conversion_type := default_return_rec.currency_conversion_type;
1100 x_cascaded_table(n).currency_conversion_rate := default_return_rec.currency_conversion_rate;
1101 x_cascaded_table(n).currency_conversion_date := default_return_rec.currency_conversion_date;
1102 END default_currency_info;
1103
1104 PROCEDURE default_vendor_info(
1105 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1106 n IN BINARY_INTEGER,
1107 default_return_rec IN default_return%ROWTYPE
1108 ) IS
1109 BEGIN
1110 IF (g_asn_debug = 'Y') THEN
1111 asn_debug.put_line('Defaulting Return vendor_id ' || default_return_rec.vendor_id);
1112 asn_debug.put_line('Defaulting Return vendor_site_id ' || default_return_rec.vendor_site_id);
1113 END IF;
1114
1115 x_cascaded_table(n).vendor_id := default_return_rec.vendor_id;
1116 x_cascaded_table(n).vendor_site_id := default_return_rec.vendor_site_id;
1117 END default_vendor_info;
1118
1119 PROCEDURE default_customer_info(
1120 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1121 n IN BINARY_INTEGER,
1122 default_return_rec IN default_return%ROWTYPE
1123 ) IS
1124 BEGIN
1125 IF (g_asn_debug = 'Y') THEN
1126 asn_debug.put_line('Defaulting Return customer_id ' || default_return_rec.customer_id);
1127 asn_debug.put_line('Defaulting Return customer_site_id ' || default_return_rec.customer_site_id);
1128 END IF;
1129
1130 x_cascaded_table(n).customer_id := default_return_rec.customer_id;
1131 x_cascaded_table(n).customer_site_id := default_return_rec.customer_site_id;
1132 END default_customer_info;
1133
1134 PROCEDURE default_deliver_to_info(
1135 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1136 n IN BINARY_INTEGER,
1137 default_return_rec IN default_return%ROWTYPE
1138 ) IS
1139 BEGIN
1140 IF (g_asn_debug = 'Y') THEN
1141 asn_debug.put_line('Defaulting Return deliver_to_person_id ' || default_return_rec.deliver_to_person_id);
1142 asn_debug.put_line('Defaulting Return deliver_to_location_id ' || default_return_rec.deliver_to_location_id);
1143 END IF;
1144
1145 x_cascaded_table(n).deliver_to_person_id := default_return_rec.deliver_to_person_id;
1146 x_cascaded_table(n).deliver_to_location_id := default_return_rec.deliver_to_location_id;
1147 END default_deliver_to_info;
1148
1149 PROCEDURE default_source_info(
1150 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1151 n IN BINARY_INTEGER,
1152 default_return_rec IN default_return%ROWTYPE
1153 ) IS
1154 BEGIN
1155 IF (g_asn_debug = 'Y') THEN
1156 asn_debug.put_line('Defaulting return receipt_source_code ' || default_return_rec.receipt_source_code);
1157 asn_debug.put_line('Defaulting return source_document_code ' || default_return_rec.source_document_code);
1158 END IF;
1159
1160 x_cascaded_table(n).receipt_source_code := default_return_rec.receipt_source_code;
1161 x_cascaded_table(n).source_document_code := default_return_rec.source_document_code;
1162 END default_source_info;
1163
1164 PROCEDURE default_item_info(
1165 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1166 n IN BINARY_INTEGER,
1167 default_return_rec IN default_return%ROWTYPE
1168 ) IS
1169 BEGIN
1170 IF (g_asn_debug = 'Y') THEN
1171 asn_debug.put_line('Defaulting return primary_unit_of_measure ' || default_return_rec.primary_unit_of_measure);
1172 asn_debug.put_line('Defaulting return item_description ' || default_return_rec.item_description);
1173 asn_debug.put_line('Defaulting return category_id ' || default_return_rec.category_id);
1174 asn_debug.put_line('Defaulting return department_code ' || default_return_rec.department_code);
1175 asn_debug.put_line('Defaulting return inspection_status_code ' || default_return_rec.inspection_status_code);
1176 asn_debug.put_line('Defaulting return subinventory ' || default_return_rec.subinventory);
1177 END IF;
1178
1179 x_cascaded_table(n).primary_unit_of_measure := default_return_rec.primary_unit_of_measure;
1180 x_cascaded_table(n).item_description := default_return_rec.item_description;
1181 x_cascaded_table(n).category_id := default_return_rec.category_id;
1182 x_cascaded_table(n).department_code := default_return_rec.department_code;
1183 x_cascaded_table(n).inspection_status_code := default_return_rec.inspection_status_code;
1184 x_cascaded_table(n).subinventory := default_return_rec.subinventory;
1185 END default_item_info;
1186
1187 PROCEDURE default_destination_info(
1188 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1189 n IN BINARY_INTEGER,
1190 default_return_rec IN default_return%ROWTYPE
1191 ) IS
1192 BEGIN
1193 IF (g_asn_debug = 'Y') THEN
1194 asn_debug.put_line('Defaulting return destination_context ' || default_return_rec.destination_context);
1195 asn_debug.put_line('Defaulting return to_organization_id ' || default_return_rec.OID);
1196 END IF;
1197
1198 x_cascaded_table(n).destination_context := default_return_rec.destination_context;
1199 x_cascaded_table(n).to_organization_id := default_return_rec.OID;
1200 END default_destination_info;
1201
1202 PROCEDURE default_location_info(
1203 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1204 n IN BINARY_INTEGER,
1205 default_return_rec IN default_return%ROWTYPE
1206 ) IS
1207 BEGIN
1208 IF (g_asn_debug = 'Y') THEN
1209 asn_debug.put_line('Defaulting return location_id ' || default_return_rec.location_id);
1210 asn_debug.put_line('Defaulting return locator_id ' || default_return_rec.locator_id);
1211 END IF;
1212
1213 x_cascaded_table(n).location_id := default_return_rec.location_id;
1214 x_cascaded_table(n).locator_id := default_return_rec.locator_id;
1215 END default_location_info;
1216
1217 PROCEDURE default_movement_id(
1218 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1219 n IN BINARY_INTEGER,
1220 default_return_rec IN default_return%ROWTYPE
1221 ) IS
1222 BEGIN
1223 IF (g_asn_debug = 'Y') THEN
1224 asn_debug.put_line('Defaulting return movement_id ' || default_return_rec.movement_id);
1225 END IF;
1226
1227 x_cascaded_table(n).movement_id := default_return_rec.movement_id;
1228 END default_movement_id;
1229
1230 PROCEDURE default_bom_resource_id(
1231 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1232 n IN BINARY_INTEGER,
1233 default_return_rec IN default_return%ROWTYPE
1234 ) IS
1235 BEGIN
1236 IF (g_asn_debug = 'Y') THEN
1237 asn_debug.put_line('Defaulting return bom_resource_id ' || default_return_rec.bom_resource_id);
1238 END IF;
1239
1240 x_cascaded_table(n).bom_resource_id := default_return_rec.bom_resource_id;
1241 END default_bom_resource_id;
1242
1243 /* WMS Changes Start */
1244 PROCEDURE derive_inv_qty(
1245 x_cascaded_table IN OUT NOCOPY rcv_roi_preprocessor.cascaded_trans_tab_type,
1246 n IN BINARY_INTEGER
1247 ) IS
1248 BEGIN
1249 /* Bug 3639667.
1250 * We are calling the new procedure instead of changing the calls
1251 * in all the other files where we call the original procedure
1252 * derive_inv_qty.
1253 */
1254 derive_inv_qty_1(x_cascaded_table(n).destination_type_code,
1255 x_cascaded_table(n).transaction_type,
1256 x_cascaded_table(n).quantity,
1257 x_cascaded_table(n).interface_transaction_id,
1258 x_cascaded_table(n).to_organization_id,
1259 x_cascaded_table(n).item_id,
1260 x_cascaded_table(n).item_revision,
1261 x_cascaded_table(n).receipt_source_code,
1262 x_cascaded_table(n).po_header_id,
1263 x_cascaded_table(n).unit_of_measure,
1264 x_cascaded_table(n).primary_unit_of_measure,
1265 x_cascaded_table(n).subinventory,
1266 x_cascaded_table(n).locator_id,
1267 x_cascaded_table(n).transfer_lpn_id,
1268 x_cascaded_table(n).lpn_id,
1269 x_cascaded_table(n).error_status,
1270 x_cascaded_table(n).error_message
1271 );
1272 END derive_inv_qty;
1273
1274 /* Bug 3639667.
1275 * The code here was originally in derive_inv_qty. But we have changed
1276 * the parameters here so that this can be called from the client side
1277 * library for the Enter returns and Enter corrections forms also.
1278 */
1279 PROCEDURE derive_inv_qty_1(
1280 p_destination_type_code IN rcv_transactions_interface.destination_type_code%TYPE,
1281 p_transaction_type IN rcv_transactions_interface.transaction_type%TYPE,
1282 p_quantity IN rcv_transactions_interface.quantity%TYPE,
1283 p_interface_transaction_id IN rcv_transactions_interface.interface_transaction_id%TYPE,
1284 p_to_organization_id IN rcv_transactions_interface.to_organization_id%TYPE,
1285 p_item_id IN rcv_transactions_interface.item_id%TYPE,
1286 p_item_revision IN rcv_transactions_interface.item_revision%TYPE,
1287 p_receipt_source_code IN rcv_transactions_interface.receipt_source_code%TYPE,
1288 p_po_header_id IN rcv_transactions_interface.po_header_id%TYPE,
1289 p_unit_of_measure IN rcv_transactions_interface.unit_of_measure%TYPE,
1290 p_primary_unit_of_measure IN rcv_transactions_interface.primary_unit_of_measure%TYPE,
1291 p_subinventory IN rcv_transactions_interface.subinventory%TYPE,
1292 p_locator_id IN rcv_transactions_interface.locator_id%TYPE,
1293 p_transfer_lpn_id IN rcv_transactions_interface.transfer_lpn_id%TYPE,
1294 p_lpn_id IN rcv_transactions_interface.lpn_id%TYPE,
1295 x_error_status IN OUT NOCOPY VARCHAR2,
1296 x_error_message IN OUT NOCOPY VARCHAR2
1297 ) IS
1298 CURSOR lot_rows(
1299 l_interface_id NUMBER
1300 ) IS
1301 SELECT lot_number,
1302 transaction_quantity
1303 FROM mtl_transaction_lots_interface
1304 WHERE product_transaction_id = l_interface_id;
1305
1306 l_lot lot_rows%ROWTYPE;
1307
1308 CURSOR rti_rows(
1309 l_interface_id NUMBER
1310 ) IS
1311 SELECT quantity
1312 FROM rcv_transactions_interface
1313 WHERE interface_transaction_id = l_interface_id;
1314
1315 l_rti rti_rows%ROWTYPE;
1316 l_negative_inv_receipt_code NUMBER;
1317 l_interface_id NUMBER;
1318 l_return_status VARCHAR2(10);
1319 l_msg_count NUMBER;
1320 l_msg_data VARCHAR2(2000);
1321 l_tree_mode NUMBER;
1322 l_is_serial_control BOOLEAN := FALSE;
1323 l_is_lot_control BOOLEAN := FALSE;
1324 l_is_revision_control BOOLEAN := FALSE;
1325 l_demand_source_type_id NUMBER;
1326 l_demand_source_header_id NUMBER;
1327 l_lot_number VARCHAR2(30);
1328 l_update_quantity NUMBER;
1329 l_qoh NUMBER;
1330 l_att NUMBER;
1331 l_rqoh NUMBER;
1332 l_qr NUMBER;
1333 l_qs NUMBER;
1334 l_atr NUMBER;
1335 l_lot_control_code mtl_system_items.lot_control_code%TYPE;
1336 l_serial_number_control_code mtl_system_items.serial_number_control_code%TYPE;
1337 l_revision_qty_control_code mtl_system_items.revision_qty_control_code%TYPE;
1338 l_revision rcv_transactions_interface.item_revision%TYPE;
1339 l_primary_qty NUMBER;
1340 l_table_name po_interface_errors.table_name%TYPE;
1341 BEGIN
1342 /* We need to do this only for returns and -ve corrections.
1343 * So return if it is not any of this transaction type.
1344 */
1345 IF ( (p_destination_type_code = 'INVENTORY')
1346 AND (p_transaction_type NOT IN('RETURN TO RECEIVING', 'RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'CORRECT'))) THEN --{
1347 RETURN;
1348 END IF; --}
1349
1350 /* We should return if it is a +ve correction. */
1351 IF ( p_transaction_type = 'CORRECT'
1352 AND p_quantity > 0) THEN
1353 RETURN;
1354 END IF;
1355
1356 l_interface_id := p_interface_transaction_id;
1357
1358 SELECT NVL(mp.negative_inv_receipt_code, -999)
1359 INTO l_negative_inv_receipt_code
1360 FROM mtl_system_items msi,
1361 mtl_parameters mp
1362 WHERE mp.organization_id = p_to_organization_id
1363 AND msi.organization_id = mp.organization_id
1364 AND msi.inventory_item_id = p_item_id;
1365
1366 IF (l_negative_inv_receipt_code = -999) THEN
1367 SELECT negative_inv_receipt_code
1368 INTO l_negative_inv_receipt_code
1369 FROM mtl_parameters
1370 WHERE organization_id = p_to_organization_id;
1371 END IF;
1372
1373 l_tree_mode := inv_quantity_tree_pub.g_transaction_mode;
1374
1375 SELECT msi.revision_qty_control_code,
1376 msi.lot_control_code,
1377 msi.serial_number_control_code
1378 INTO l_revision_qty_control_code,
1379 l_lot_control_code,
1380 l_serial_number_control_code
1381 FROM mtl_system_items msi
1382 WHERE inventory_item_id = p_item_id
1383 AND NVL(msi.organization_id, p_to_organization_id) = p_to_organization_id;
1384
1385 IF l_revision_qty_control_code <> '2' THEN
1386 l_is_revision_control := FALSE;
1387 ELSE
1388 l_is_revision_control := TRUE;
1389 l_revision := p_item_revision;
1390 END IF;
1391
1392 IF NVL(l_lot_control_code, 0) = 2 THEN
1393 l_is_lot_control := TRUE;
1394 END IF;
1395
1396 IF (NVL(l_serial_number_control_code, 1) <> 1) THEN
1397 l_is_serial_control := TRUE;
1398 END IF;
1399
1400 /* WE can return only a PO or RMA */
1401 IF (p_receipt_source_code = 'VENDOR') THEN
1402 l_demand_source_type_id := 1;
1403 l_demand_source_header_id := p_po_header_id;
1404 ELSE
1405 l_demand_source_type_id := -9999;
1406 l_demand_source_header_id := -9999;
1407 END IF;
1408
1409 IF (l_negative_inv_receipt_code = 2) THEN --{
1410 IF (l_is_lot_control) THEN
1411 OPEN lot_rows(l_interface_id);
1412 ELSE /* Serial control or not a lot/serial control */
1413 OPEN rti_rows(l_interface_id);
1414 END IF;
1415
1416 LOOP --{
1417 /* Get the primary quantity.*/
1418 IF (lot_rows%ISOPEN) THEN --{
1419 FETCH lot_rows INTO l_lot;
1420 EXIT WHEN lot_rows%NOTFOUND;
1421
1422 IF (g_asn_debug = 'Y') THEN
1423 asn_debug.put_line('lot_number ' || l_lot.lot_number);
1424 END IF;
1425
1426 l_lot_number := l_lot.lot_number;
1427 l_primary_qty := ABS(rcv_transactions_interface_sv.convert_into_correct_qty(l_lot.transaction_quantity,
1428 p_unit_of_measure,
1429 p_item_id,
1430 p_primary_unit_of_measure
1431 ));
1432 ELSIF(rti_rows%ISOPEN) THEN --}{
1433 FETCH rti_rows INTO l_rti;
1434 EXIT WHEN rti_rows%NOTFOUND;
1435 l_lot_number := NULL;
1436 l_primary_qty := ABS(rcv_transactions_interface_sv.convert_into_correct_qty(l_rti.quantity,
1437 p_unit_of_measure,
1438 p_item_id,
1439 p_primary_unit_of_measure
1440 ));
1441 END IF; --}
1442
1443 inv_quantity_tree_pub.query_quantities(p_api_version_number => 1.0,
1444 p_init_msg_lst => fnd_api.g_false,
1445 x_return_status => l_return_status,
1446 x_msg_count => l_msg_count,
1447 x_msg_data => l_msg_data,
1448 p_organization_id => p_to_organization_id,
1449 p_inventory_item_id => p_item_id,
1450 p_tree_mode => l_tree_mode,
1451 p_is_revision_control => l_is_revision_control,
1452 p_is_lot_control => l_is_lot_control,
1453 p_is_serial_control => l_is_serial_control,
1454 p_demand_source_type_id => l_demand_source_type_id,
1455 p_demand_source_header_id => l_demand_source_header_id,
1456 p_demand_source_line_id => NULL,
1457 p_demand_source_name => NULL,
1458 p_lot_expiration_date => NULL,
1459 p_revision => p_item_revision,
1460 p_lot_number => l_lot_number,
1461 p_subinventory_code => p_subinventory,
1462 p_locator_id => p_locator_id,
1463 p_onhand_source => 3,
1464 x_qoh => l_qoh,
1465 x_rqoh => l_rqoh,
1466 x_qr => l_qr,
1467 x_qs => l_qs,
1468 x_att => l_att,
1469 x_atr => l_atr,
1470 p_transfer_subinventory_code => NULL,
1471 p_cost_group_id => NULL,
1472 p_lpn_id => p_transfer_lpn_id,
1473 p_transfer_locator_id => NULL
1474 );
1475
1476 IF (lot_rows%ISOPEN) THEN
1477 l_table_name := 'MTL_TRANSACTION_LOTS_INTERFACE';
1478 ELSE
1479 l_table_name := 'RCV_TRANSACTIONS_INTERFACE';
1480 END IF;
1481
1482 IF (l_return_status = 'S') THEN --{
1483 x_error_status := 'S';
1484
1485 IF (l_primary_qty > NVL(l_att, 0)) THEN --{
1486 x_error_status := 'E';
1487 x_error_message := 'RCV_TRX_QTY_EXCEEDS_INV_AVAIL';
1488 rcv_error_pkg.set_error_message(x_error_message);
1489 rcv_error_pkg.set_token('PRIMARY', l_primary_qty);
1490 rcv_error_pkg.set_token('SUB', l_att);
1491 rcv_error_pkg.log_interface_error('PRIMARY_QUANTITY', FALSE);
1492 EXIT;
1493 ELSE -- }{
1494 x_error_status := 'S';
1495 END IF; --}
1496 ELSE --}{
1497 x_error_status := 'E';
1498 x_error_message := 'RCV_TRX_QTY_EXCEEDS_INV_AVAIL';
1499 rcv_error_pkg.set_error_message(x_error_message);
1500 rcv_error_pkg.set_token('PRIMARY', l_primary_qty);
1501 rcv_error_pkg.set_token('SUB', l_att);
1502 rcv_error_pkg.log_interface_error('PRIMARY_QUANTITY', FALSE);
1503 EXIT;
1504 END IF; --}
1505
1506 IF (p_transaction_type = 'CORRECT') THEN --{
1507 IF (SIGN(p_quantity) = 1) THEN
1508 l_update_quantity := l_primary_qty;
1509 ELSIF(SIGN(p_quantity) = -1) THEN
1510 l_update_quantity := -l_primary_qty;
1511 END IF;
1512 ELSE --}{
1513 l_update_quantity := -l_primary_qty;
1514 END IF; --}
1515
1516 inv_quantity_tree_pub.update_quantities(p_api_version_number => 1.0,
1517 p_init_msg_lst => fnd_api.g_false,
1518 x_return_status => l_return_status,
1519 x_msg_count => l_msg_count,
1520 x_msg_data => l_msg_data,
1521 p_organization_id => p_to_organization_id,
1522 p_inventory_item_id => p_item_id,
1523 p_tree_mode => l_tree_mode,
1524 p_is_revision_control => l_is_revision_control,
1525 p_is_lot_control => l_is_lot_control,
1526 p_is_serial_control => l_is_serial_control,
1527 p_demand_source_type_id => l_demand_source_type_id,
1528 p_demand_source_header_id => l_demand_source_header_id,
1529 p_revision => l_revision,
1530 p_lot_number => l_lot_number,
1531 p_subinventory_code => p_subinventory,
1532 p_locator_id => p_locator_id,
1533 p_primary_quantity => l_update_quantity,
1534 p_quantity_type => inv_quantity_tree_pub.g_qoh,
1535 x_qoh => l_qoh,
1536 x_rqoh => l_rqoh,
1537 x_qr => l_qr,
1538 x_qs => l_qs,
1539 x_att => l_att,
1540 x_atr => l_atr,
1541 p_lpn_id => p_lpn_id
1542 );
1543 END LOOP; --}
1544
1545 IF (lot_rows%ISOPEN) THEN
1546 CLOSE lot_rows;
1547 ELSIF(rti_rows%ISOPEN) THEN
1548 CLOSE rti_rows;
1549 END IF;
1550 END IF; --}
1551 END derive_inv_qty_1;
1552 /* WMS Changes End */
1553 END rcv_roi_return;