[Home] [Help]
PACKAGE BODY: APPS.INV_LPN_TRX_PUB
Source
1 PACKAGE BODY inv_lpn_trx_pub AS
2 /* $Header: INVTRXWB.pls 120.90.12020000.24 2013/04/05 07:11:13 ssingams ship $ */
3
4 -- Name: PROCESS_LPN_TRX
5 --
6 -- Input parameters:
7 --
8 -- Output parameters:
9 -- x_proc_msg Message from the Process-Manager
10 -- return_status 0 on Success, 1 on Error
11 --
12 --
13 -- Global constant holding the package name
14 g_pkg_name CONSTANT VARCHAR2(30) := 'INV_LPN_TRX_PUB';
15 g_pkg_version CONSTANT VARCHAR2(100) := '$Header: INVTRXWB.pls 120.90.12020000.24 2013/04/05 07:11:13 ssingams ship $';
16 ret_status VARCHAR2(512);
17 ret_msgcnt NUMBER := 0;
18 ret_msgdata VARCHAR2(1000);
19 g_pack CONSTANT NUMBER := 1;
20 g_unpack CONSTANT NUMBER := 2;
21 g_adjust CONSTANT NUMBER := 3;
22 g_unpack_all CONSTANT NUMBER := 4;
23 g_precision CONSTANT NUMBER := 5;
24 -- HVERDDIN ERES START
25 g_eres_event_name VARCHAR2(60);
26
27 TYPE eres_rec IS RECORD(
28 event_id NUMBER
29 , transaction_action_id NUMBER
30 , transaction_source_type_id NUMBER
31 );
32
33 TYPE eres_tbl IS TABLE OF eres_rec
34 INDEX BY BINARY_INTEGER;
35
36 -- HVERDDIN ERES END
37
38 /******************************************************************************************************************
39 -- TRANS_ERES_ENABLED
40 -- Validate if this transaction type is being supported.
41 -- Only the following are being supported in this release
42
43 -- TRANSACTION_SOURCE_TYPE TRANSACTION_ACTION
44 ------------I---------------------------------- ------------------------
45 -- G_SOURCETYPE_ACCOUNT := 3; G_ACTION_ISSUE := 1 G_ACTION_RECEIPT := 27;
46 -- G_SOURCETYPE_ACCOUNTALIAS := 6; G_ACTION_ISSUE := 1 G_ACTION_RECEIPT := 27;
47 -- G_SOURCETYPE_INVENTORY := 13; G_ACTION_ISSUE := 1 G_ACTION_RECEIPT := 27;
48 --
49 --
50 -- Created H.Verdding - Added to support ERES FDA requirements.
51 ******************************************************************************************************************/
52 FUNCTION trans_eres_enabled(p_trans_action_id IN NUMBER, p_trans_source_type_id IN NUMBER)
53 RETURN BOOLEAN IS
54 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
55 BEGIN
56 IF (l_debug = 1) THEN
57 inv_log_util.TRACE('** Trans Eres Enabled trx_action_id = ' || p_trans_action_id, 'INV_LPN_TRX_PUB', 9);
58 inv_log_util.TRACE('** Trans Eres Enabled trx_soource_id =' || p_trans_source_type_id, 'INV_LPN_TRX_PUB', 9);
59 END IF;
60
61 IF (p_trans_action_id NOT IN(inv_globals.g_action_issue, inv_globals.g_action_receipt,INV_GLOBALS.G_ACTION_SUBXFR,
62 INV_GLOBALS.G_ACTION_ORGXFR, INV_GLOBALS.G_ACTION_INTRANSITSHIPMENT)) THEN
63 inv_log_util.TRACE(
64 '** Transactions Not ERES Supported trx_action_id =' || p_trans_action_id || ',trx_source_type_id =' || p_trans_source_type_id
65 , 'INV_LPN_TRX_PUB'
66 , 9
67 );
68 RETURN FALSE;
69 ELSIF(p_trans_action_id = inv_globals.g_action_issue) THEN
70 -- These are Issue trans types
71 IF (p_trans_source_type_id = inv_globals.g_sourcetype_account) THEN
72 g_eres_event_name := 'oracle.apps.inv.acctIssue';
73 ELSIF(p_trans_source_type_id = inv_globals.g_sourcetype_accountalias) THEN
74 g_eres_event_name := 'oracle.apps.inv.acctAliasIssue';
75 ELSIF(p_trans_source_type_id = inv_globals.g_sourcetype_inventory) THEN
76 g_eres_event_name := 'oracle.apps.inv.miscIssue';
77 ELSE
78 RETURN FALSE;
79 END IF;
80 ELSIF(p_trans_action_id = inv_globals.g_action_receipt) THEN
81 -- These are Reciept trans types
82 IF (p_trans_source_type_id = inv_globals.g_sourcetype_account) THEN
83 g_eres_event_name := 'oracle.apps.inv.acctReceipt';
84 ELSIF(p_trans_source_type_id = inv_globals.g_sourcetype_accountalias) THEN
85 g_eres_event_name := 'oracle.apps.inv.acctAliasReceipt';
86 ELSIF(p_trans_source_type_id = inv_globals.g_sourcetype_inventory) THEN
87 g_eres_event_name := 'oracle.apps.inv.miscReceipt';
88 ELSE
89 RETURN FALSE;
90 END IF;
91 -- fabdi invconv start
92 ELSIF (p_trans_action_id = INV_GLOBALS.G_ACTION_SUBXFR) THEN
93 -- These are Inter-Org Transfers trans types
94 IF (p_trans_source_type_id = INV_GLOBALS.G_SOURCETYPE_INVENTORY) THEN
95 g_eres_event_name := 'oracle.apps.inv.subinvTransfer';
96 ELSE
97 RETURN FALSE;
98 END IF;
99 ELSIF (p_trans_action_id in (INV_GLOBALS.G_ACTION_ORGXFR, INV_GLOBALS.G_ACTION_INTRANSITSHIPMENT)) THEN
100 -- These are Subinventory Transfers trans types
101 IF (p_trans_source_type_id = INV_GLOBALS.G_SOURCETYPE_INVENTORY) THEN
102 g_eres_event_name := 'oracle.apps.inv.interorgTransfer';
103 ELSE
104 RETURN FALSE;
105 END IF;
106 -- fabdi invconv end
107 ELSE
108 RETURN FALSE;
109 END IF;
110
111 IF (l_debug = 1) THEN
112 inv_log_util.TRACE('** ERES EVENT = ' || g_eres_event_name, 'INV_LPN_TRX_PUB', 9);
113 END IF;
114
115 RETURN TRUE;
116 EXCEPTION
117 WHEN OTHERS THEN
118 IF (l_debug = 1) THEN
119 inv_log_util.TRACE('** Function TRANS_ERES_ENABLED - raised when Others', 'INV_LPN_TRX_PUB', 9);
120 END IF;
121
122 fnd_message.set_name('INV', 'INV_ERES_ENABLED');
123 fnd_msg_pub.ADD;
124 RAISE fnd_api.g_exc_error;
125 RETURN FALSE;
126 END trans_eres_enabled;
127
128 --3978111 CHANGES START
129 /********************************************************************
130 * Code to insert in cst_comp_snap_temp in case of WIP LPN completion
131 * and complete LPN putaway
132 *******************************************************************/
133 procedure create_snapshot(p_temp_id NUMBER, p_org_id NUMBER)
134 IS
135 l_errNum NUMBER;
136 l_errCode VARCHAR2(1);
137 l_errMsg VARCHAR2(241);
138 l_cst_ret NUMBER(1):=0;
139 l_primary_cost_method NUMBER;
140 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
141 BEGIN
142 select primary_cost_method
143 into l_primary_cost_method
144 from mtl_parameters
145 where organization_id = p_org_id;
146
147 IF (l_debug = 1) THEN
148 inv_log_util.TRACE('INVTRXWB: cost method of org'||p_org_id||' is '||l_primary_cost_method,'INVTRXWB',1);
149 END IF;
150
151 IF l_primary_cost_method in (2,5,6) THEN
152 IF (l_debug = 1) THEN
153 inv_log_util.TRACE('PRIMARY COST METHOD IS AVG OR FIFO OR LIFO CALLING CSTACOSN.op_snapshot'||p_temp_id,'INVTRXWB',1);
154 END IF;
155
156 l_cst_ret := CSTACOSN.op_snapshot(i_txn_temp_id => p_temp_id,
157 err_num => l_errNum,
158 err_code => l_errCode,
159 err_msg => l_errMsg);
160 IF(l_cst_ret <> 1) THEN
161 fnd_message.set_name('BOM', 'CST_SNAPSHOT_FAILED');
162 fnd_msg_pub.ADD;
163 IF (l_debug = 1) THEN
164 inv_log_util.TRACE('INVTRXWB: Error from CSTACOSN.op_snapshot ','INVTRXWB',1);
165 END IF;
166 raise fnd_api.g_exc_unexpected_error;
167 ELSE
168 inv_log_util.TRACE('INVTRXWB: CALL TO CSTACOSN.op_snapshot SUCCESSFULL','INVTRXWB',1);
169 END IF;
170
171 END IF;
172 END create_snapshot;
173 --3978111 CHANGES END
174
175 /********************************************************************
176 * Insert a row into MTL_MATERIAL_TRANSACTION_TEMP
177 * If the transaction is an InterOrg transfer type, call the CostGroup
178 * API to determine cost groups.
179 *******************************************************************/
180 PROCEDURE insert_line_trx(
181 curlpnrec wms_container_pub.wms_container_content_rec_type
182 , v_trxtempid NUMBER
183 , v_trxaction NUMBER
184 , v_orgid NUMBER
185 , v_subinv VARCHAR2
186 , v_locatorid NUMBER
187 , v_trxqty NUMBER
188 , v_cost_group_id NUMBER := NULL
189 , v_mmtt_rec IN OUT NOCOPY mtl_material_transactions_temp%ROWTYPE
190 , x_trxtempid OUT NOCOPY NUMBER
191 , v_sectrxqty NUMBER := NULL --INVCONV kkillams
192 ) IS
193 l_cst_grp_id NUMBER;
194 l_xfr_cst_grp_id NUMBER := v_cost_group_id;
195 l_temp_uom_code VARCHAR(3);
196 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
197 l_sign NUMBER := 1; --Added bug3984746
198
199 --Bug 10158934
200 l_api_name VARCHAR2(30) := 'INSERT_LINE_TRX';
201 x_transfer_price NUMBER;
202 x_currency_code VARCHAR2(31);
203 x_transfer_price_priuom NUMBER;
204 x_incr_transfer_price NUMBER;
205 x_incr_currency_code VARCHAR2(31);
206 x_return_status VARCHAR2(1);
207 x_msg_data VARCHAR2(2000);
208 x_msg_count NUMBER;
209 p_from_opm_org VARCHAR2(1);
210 p_to_opm_org VARCHAR2(1);
211
212 l_wlc_prim_qty NUMBER; --13591755
213 l_wlc_trx_qty NUMBER;
214
215 BEGIN
216 SELECT mtl_material_transactions_s.NEXTVAL
217 INTO x_trxtempid
218 FROM DUAL;
219
220 v_mmtt_rec.transaction_temp_id := x_trxtempid;
221 v_mmtt_rec.subinventory_code := v_subinv;
222 v_mmtt_rec.locator_id := v_locatorid;
223 v_mmtt_rec.inventory_item_id := curlpnrec.content_item_id;
224 v_mmtt_rec.content_lpn_id := NVL(curlpnrec.parent_lpn_id, v_mmtt_rec.content_lpn_id);
225 v_mmtt_rec.transaction_quantity := v_trxqty;
226 v_mmtt_rec.transaction_uom := curlpnrec.uom;
227 v_mmtt_rec.secondary_transaction_quantity := v_sectrxqty; --INVCONV kkillams
228 v_mmtt_rec.secondary_uom_code := curlpnrec.sec_uom;--INVCONV kkillams
229 v_mmtt_rec.lot_number :=curlpnrec.lot_number; --bug 8526601
230
231 SELECT primary_uom_code
232 INTO l_temp_uom_code
233 FROM mtl_system_items
234 WHERE inventory_item_id = v_mmtt_rec.inventory_item_id
235 AND organization_id = v_mmtt_rec.organization_id;
236
237 SELECT sum(primary_quantity) , sum(quantity)
238 INTO l_wlc_prim_qty , l_wlc_trx_qty
239 FROM wms_lpn_contents
240 where parent_lpn_id = v_mmtt_rec.content_lpn_id
241 and lot_number = v_mmtt_rec.lot_number
242 and inventory_item_id = v_mmtt_rec.inventory_item_id
243 and organization_id = v_mmtt_rec.organization_id
244 and revision = v_mmtt_rec.revision
245 and uom_code = v_mmtt_rec.TRANSACTION_UOM;
246
247 IF v_mmtt_rec.transaction_uom <> l_temp_uom_code THEN --Added bug 3984746
248 IF v_mmtt_rec.primary_quantity < 0 THEN
249 l_sign := -1;
250 END IF; --End of bug fix3984746
251 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
252 /*IF (v_mmtt_rec.transaction_quantity = l_wlc_trx_qty) THEN
253 v_mmtt_rec.primary_quantity := l_wlc_prim_qty;
254 ELSE
255 v_mmtt_rec.primary_quantity :=
256 inv_convert.inv_um_convert(v_mmtt_rec.inventory_item_id,v_mmtt_rec.lot_number,v_mmtt_rec.organization_id,5, abs(v_mmtt_rec.transaction_quantity), v_mmtt_rec.transaction_uom
257 , l_temp_uom_code, NULL, NULL);
258 END IF;
259
260 IF (v_mmtt_rec.primary_quantity = -99999) THEN --Changed from '<=' bug 3984746
261 fnd_message.set_name('INV', 'INV_UOM_CONVERSION_ERROR');
262 fnd_message.set_token('uom1', v_mmtt_rec.transaction_uom);
263 fnd_message.set_token('uom2', l_temp_uom_code);
264 fnd_message.set_token('module', 'INSERT_LINE_TRX');
265 fnd_msg_pub.ADD;
266 RAISE fnd_api.g_exc_error;
267 END IF;*/
268 --16445970 --Commented the above
269 v_mmtt_rec.primary_quantity := curlpnrec.primary_quantity;
270 IF (l_debug = 1) THEN
271 inv_log_util.TRACE('Extracting the Primary Qty from WLC. No need to convert ', 'INV_LPN_TRX_PUB', 1);
272 inv_log_util.TRACE('v_mmtt_rec.primary_quantity: '||v_mmtt_rec.primary_quantity, 'INV_LPN_TRX_PUB', 1);
273 END IF;
274 --16445970
275
276 v_mmtt_rec.primary_quantity := v_mmtt_rec.primary_quantity * l_sign; --Added bug3984746
277 ELSE
278 v_mmtt_rec.primary_quantity := v_mmtt_rec.transaction_quantity; --Added bug 4080241
279 END IF;
280
281 v_mmtt_rec.revision := curlpnrec.revision;
282 v_mmtt_rec.cost_group_id := NVL(v_cost_group_id, v_mmtt_rec.cost_group_id);
283
284 -- If the transaction action is OrgXfr, IntrShipment or IntrRcpt
285 -- then set the cost_group_id to null. The CostGroup API will
286 -- determine the cost-group-id in this case. Insert into MMTT using
287 -- the passed MMTT_Record type.
288 IF (v_trxaction = inv_globals.g_action_orgxfr)
289 OR(v_trxaction = inv_globals.g_action_intransitshipment)
290 OR(v_trxaction = inv_globals.g_action_intransitreceipt) THEN
291 l_xfr_cst_grp_id := NULL;
292 END IF;
293
294 -- Start Bug 10158934
295 -- Call GMF_get_transfer_price_PUB.get_transfer_price API if either from or to org is process enabled.
296 IF ( inv_cache.set_org_rec(v_mmtt_rec.organization_id ) ) THEN
297 IF ( NVL(inv_cache.org_rec.process_enabled_flag,'N') = 'Y') THEN
298 p_from_opm_org := 'Y';
299 inv_log_util.trace('p_from_opm_org is:' ||p_from_opm_org, g_pkg_name || '.' || l_api_name, 5);
300
301 END IF;
302 END IF;
303
304 IF ( inv_cache.set_org_rec(v_mmtt_rec.transfer_organization ) ) THEN
305 IF ( NVL(inv_cache.org_rec.process_enabled_flag,'N') = 'Y') THEN
306 p_to_opm_org := 'Y';
307 inv_log_util.trace('p_to_opm_org is:' ||p_to_opm_org, g_pkg_name || '.' || l_api_name, 5);
308 END IF;
309 END IF;
310
311 IF (p_from_opm_org = 'Y' OR p_to_opm_org = 'Y') THEN
312 inv_log_util.trace('Calling GMF_get_transfer_price_PUB.get_transfer_price', g_pkg_name || '.' || l_api_name, 5);
313 inv_log_util.trace('v_mmtt_rec.inventory_item_id is:' || v_mmtt_rec.inventory_item_id, g_pkg_name || '.' || l_api_name, 5);
314 inv_log_util.trace('v_mmtt_rec.transaction_quantity is:' || v_mmtt_rec.transaction_quantity, g_pkg_name || '.' || l_api_name, 5);
315 inv_log_util.trace('v_mmtt_rec.transaction_uom is:' ||v_mmtt_rec.transaction_uom, g_pkg_name || '.' || l_api_name, 5);
316 inv_log_util.trace('v_mmtt_rec.organization_id is:' ||v_mmtt_rec.organization_id, g_pkg_name || '.' || l_api_name, 5);
317 inv_log_util.trace('v_mmtt_rec.transfer_organization is:' ||v_mmtt_rec.transfer_organization, g_pkg_name || '.' || l_api_name, 5);
318
319 GMF_get_transfer_price_PUB.get_transfer_price (
320 p_api_version => 1.0
321 , p_init_msg_list => 'F'
322
323 , p_inventory_item_id => v_mmtt_rec.inventory_item_id
324 , p_transaction_qty => v_mmtt_rec.transaction_quantity
325 , p_transaction_uom => v_mmtt_rec.transaction_uom
326
327 , p_transaction_id => NULL -- mtl_trx_line.transaction_id ***
328 , p_global_procurement_flag => 'N'
329 , p_drop_ship_flag => 'N'
330
331 , p_from_organization_id => v_mmtt_rec.organization_id
332 , p_from_ou => 1 -- Passing dummy value as this is fetched again in GMF.
333 , p_to_organization_id => v_mmtt_rec.transfer_organization
334 , p_to_ou => 1 -- Passing dummy value as this is fetched again in GMF.
335
336 , p_transfer_type => 'INTORG'
337 , p_transfer_source => 'INTORG'
338
339 , x_return_status => x_return_status
340 , x_msg_data => x_msg_data
341 , x_msg_count => x_msg_count
342
343 , x_transfer_price => x_transfer_price
344 , x_transfer_price_priuom => x_transfer_price_priuom /* Store Transfer Price in pri uom */
345 , x_currency_code => x_currency_code
346 , x_incr_transfer_price => x_incr_transfer_price
347 , x_incr_currency_code => x_incr_currency_code
348 );
349
350 IF x_return_status <> FND_API.G_RET_STS_SUCCESS
351 THEN
352 inv_log_util.trace('X_return status is <> S',g_pkg_name || '.' || l_api_name, 5);
353 x_transfer_price := 0;
354 END IF;
355
356 inv_log_util.trace('x_transfer_price is:' || x_transfer_price, g_pkg_name || '.' || l_api_name, 5);
357 inv_log_util.trace('x_currency_code is :' || x_currency_code, g_pkg_name || '.' || l_api_name, 5);
358 END IF;
359
360 -- End Bug 10158934
361 --BUG13657375 Begin
362 inv_log_util.trace('v_trxtempid is:' || v_trxtempid, g_pkg_name || '.' || l_api_name, 5);
363 inv_log_util.trace('v_orgid is :' || v_orgid, g_pkg_name || '.' || l_api_name, 5);
364 inv_log_util.trace('v_mmtt_rec.transaction_reference is :' || v_mmtt_rec.transaction_reference, g_pkg_name || '.' || l_api_name, 5);
365
366 BEGIN
367 select transaction_reference into v_mmtt_rec.transaction_reference
368 from mtl_material_transactions_temp
369 where transaction_temp_id = v_trxtempid
370 and organization_id = v_orgid;
371
372 EXCEPTION
373 WHEN NO_DATA_FOUND THEN
374 IF (l_debug = 1) THEN
375 inv_log_util.TRACE('no data found insert_line_trx', 'INV_LPN_TRX_PUB', 1);
376 END IF;
377 END;
378 --BUG13657375 end
379
380 -- Added two columns to MMTT for International drop shipments -
381 -- trx_flow_header_id and logical_trx_type_code
382 -- Added original_transaction_temp_id to MMTT as part of ERES changes
383 -- Added source_line_id and source_code for bug 4931515
384 -- Added SOURCE_PROJECT_ID and SOURCE_TASK_ID for bug#5224902
385 INSERT INTO mtl_material_transactions_temp
386 (
387 transaction_header_id
388 , transaction_temp_id
389 , source_code
390 , source_line_id
391 , process_flag
392 , creation_date
393 , created_by
394 , last_update_date
395 , last_updated_by
396 , last_update_login
397 , inventory_item_id
398 , organization_id
399 , subinventory_code
400 , locator_id
401 , transfer_to_location
402 , transaction_quantity
403 , primary_quantity
404 , transaction_uom
405 , transaction_source_name --16100381
406 , transaction_type_id
407 , transaction_action_id
408 , transaction_source_type_id
409 , transaction_date
410 , acct_period_id
411 , transfer_organization
412 , transfer_subinventory
413 , reason_id
414 , shipment_number
415 , distribution_account_id
416 , waybill_airbill
417 , expected_arrival_date
418 , freight_code
419 , revision
420 , lpn_id
421 , content_lpn_id
422 , transfer_lpn_id
423 , cost_group_id
424 , transaction_source_id
425 , trx_source_line_id
426 , demand_source_header_id
427 , demand_source_line
428 , posting_flag
429 , pick_rule_id
430 , pick_strategy_id
431 , put_away_rule_id
432 , put_away_strategy_id
433 , move_order_line_id
434 , pick_slip_number
435 , reservation_id
436 , transaction_status
437 , standard_operation_id
438 , task_priority
439 , wms_task_type
440 , transfer_cost_group_id
441 , wip_entity_type
442 , repetitive_line_id
443 , operation_seq_num
444 , department_id
445 , department_code
446 , lock_flag
447 , primary_switch
448 , wip_supply_type
449 , negative_req_flag
450 , required_flag
451 , completion_transaction_id
452 , flow_schedule
453 , transaction_batch_id
454 , transaction_batch_seq
455 , transaction_mode
456 , owning_organization_id
457 , owning_tp_type
458 , xfr_owning_organization_id
459 , transfer_owning_tp_type
460 , planning_organization_id
461 , planning_tp_type
462 , xfr_planning_organization_id
463 , transfer_planning_tp_type
464 , fob_point
465 , intransit_account
466 , trx_flow_header_id
467 , logical_trx_type_code
468 , original_transaction_temp_id
469 , secondary_uom_code --kkillams
470 , secondary_transaction_quantity --kkillams
471 , ship_to_location --eIB Build; Bug# 4348541
472 , relieve_reservations_flag /*** {{ R12 Enhanced reservations code changes ***/
473 , relieve_high_level_rsv_flag /*** {{ R12 Enhanced reservations code changes ***/
474 , cycle_count_id -- bug 5060715
475 , physical_adjustment_id -- Changes for Phy Inv ER - bug 13865417
476 , source_project_id -- bug 5224902
477 , source_task_id
478 , MATERIAL_ALLOCATION_TEMP_ID -- Added for bug # 5689491
479 , transfer_price -- Bug 10158934
480 , ATTRIBUTE_CATEGORY --bug for 12876009 from
481 , ATTRIBUTE1
482 , ATTRIBUTE2
483 , ATTRIBUTE3
484 , ATTRIBUTE4
485 , ATTRIBUTE5
486 , ATTRIBUTE6
487 , ATTRIBUTE7
488 , ATTRIBUTE8
489 , ATTRIBUTE9
490 , ATTRIBUTE10
491 , ATTRIBUTE11
492 , ATTRIBUTE12
493 , ATTRIBUTE13
494 , ATTRIBUTE14
495 , ATTRIBUTE15 --bug for 12876009 end
496 , transaction_reference -- bug 13657375
497 )
498 VALUES (
499 v_mmtt_rec.transaction_header_id
500 , v_mmtt_rec.transaction_temp_id
501 , v_mmtt_rec.source_code
502 , v_mmtt_rec.source_line_id
503 , v_mmtt_rec.process_flag
504 , v_mmtt_rec.creation_date
505 , v_mmtt_rec.created_by
506 , v_mmtt_rec.last_update_date
507 , v_mmtt_rec.last_updated_by
508 , v_mmtt_rec.last_update_login
509 , v_mmtt_rec.inventory_item_id
510 , v_mmtt_rec.organization_id
511 , v_mmtt_rec.subinventory_code
512 , v_mmtt_rec.locator_id
513 , v_mmtt_rec.transfer_to_location
514 , v_mmtt_rec.transaction_quantity
515 , v_mmtt_rec.primary_quantity
516 , v_mmtt_rec.transaction_uom
517 , v_mmtt_rec.transaction_source_name --16100381
518 , v_mmtt_rec.transaction_type_id
519 , v_mmtt_rec.transaction_action_id
520 , v_mmtt_rec.transaction_source_type_id
521 , v_mmtt_rec.transaction_date
522 , v_mmtt_rec.acct_period_id
523 , v_mmtt_rec.transfer_organization
524 , v_mmtt_rec.transfer_subinventory
525 , v_mmtt_rec.reason_id
526 , v_mmtt_rec.shipment_number
527 , v_mmtt_rec.distribution_account_id
528 , v_mmtt_rec.waybill_airbill
529 , v_mmtt_rec.expected_arrival_date
530 , v_mmtt_rec.freight_code
531 , v_mmtt_rec.revision
532 , v_mmtt_rec.lpn_id
533 , v_mmtt_rec.content_lpn_id
534 , v_mmtt_rec.transfer_lpn_id
535 , NVL(v_cost_group_id, v_mmtt_rec.cost_group_id)
536 , v_mmtt_rec.transaction_source_id
537 , v_mmtt_rec.trx_source_line_id
538 , v_mmtt_rec.demand_source_header_id
539 , v_mmtt_rec.demand_source_line
540 , v_mmtt_rec.posting_flag
541 , v_mmtt_rec.pick_rule_id
542 , v_mmtt_rec.pick_strategy_id
543 , v_mmtt_rec.put_away_rule_id
544 , v_mmtt_rec.put_away_strategy_id
545 , v_mmtt_rec.move_order_line_id
546 , v_mmtt_rec.pick_slip_number
547 , v_mmtt_rec.reservation_id
548 , v_mmtt_rec.transaction_status
549 , v_mmtt_rec.standard_operation_id
550 , v_mmtt_rec.task_priority
551 , v_mmtt_rec.wms_task_type
552 , l_xfr_cst_grp_id
553 , v_mmtt_rec.wip_entity_type
554 , v_mmtt_rec.repetitive_line_id
555 , v_mmtt_rec.operation_seq_num
556 , v_mmtt_rec.department_id
557 , v_mmtt_rec.department_code
558 , v_mmtt_rec.lock_flag
559 , v_mmtt_rec.primary_switch
560 , v_mmtt_rec.wip_supply_type
561 , v_mmtt_rec.negative_req_flag
562 , v_mmtt_rec.required_flag
563 , v_mmtt_rec.completion_transaction_id
564 , v_mmtt_rec.flow_schedule
565 , v_mmtt_rec.transaction_batch_id
566 , v_mmtt_rec.transaction_batch_seq
567 , v_mmtt_rec.transaction_mode
568 , v_mmtt_rec.owning_organization_id
569 , v_mmtt_rec.owning_tp_type
570 , v_mmtt_rec.xfr_owning_organization_id
571 , v_mmtt_rec.transfer_owning_tp_type
572 , v_mmtt_rec.planning_organization_id
573 , v_mmtt_rec.planning_tp_type
574 , v_mmtt_rec.xfr_planning_organization_id
575 , v_mmtt_rec.transfer_planning_tp_type
576 , v_mmtt_rec.fob_point
577 , v_mmtt_rec.intransit_account
578 , v_mmtt_rec.trx_flow_header_id
579 , v_mmtt_rec.logical_trx_type_code
580 , v_mmtt_rec.original_transaction_temp_id
581 , v_mmtt_rec.secondary_uom_code --kkillams
582 , v_mmtt_rec.secondary_transaction_quantity --kkillams
583 , v_mmtt_rec.ship_to_location --eIB Build; Bug# 4348541
584 , v_mmtt_rec.relieve_reservations_flag /*** {{ R12 Enhanced reservations code changes ***/
585 , v_mmtt_rec.relieve_high_level_rsv_flag /*** {{ R12 Enhanced reservations code changes ***/
586 , v_mmtt_rec.cycle_count_id --bug 5060715
587 , v_mmtt_rec.physical_adjustment_id -- Changes for Phy Inv ER - bug 13865417
588 , v_mmtt_rec.source_project_id --bug 5224902
589 , v_mmtt_rec.source_task_id
590 , v_mmtt_rec.MATERIAL_ALLOCATION_TEMP_ID -- Added for bug # 5689491
591 , x_transfer_price -- Bug 10158934
592 , v_mmtt_rec.ATTRIBUTE_CATEGORY --bug for 12876009 from
593 , v_mmtt_rec.ATTRIBUTE1
594 , v_mmtt_rec.ATTRIBUTE2
595 , v_mmtt_rec.ATTRIBUTE3
596 , v_mmtt_rec.ATTRIBUTE4
597 , v_mmtt_rec.ATTRIBUTE5
598 , v_mmtt_rec.ATTRIBUTE6
599 , v_mmtt_rec.ATTRIBUTE7
600 , v_mmtt_rec.ATTRIBUTE8
601 , v_mmtt_rec.ATTRIBUTE9
602 , v_mmtt_rec.ATTRIBUTE10
603 , v_mmtt_rec.ATTRIBUTE11
604 , v_mmtt_rec.ATTRIBUTE12
605 , v_mmtt_rec.ATTRIBUTE13
606 , v_mmtt_rec.ATTRIBUTE14
607 , v_mmtt_rec.ATTRIBUTE15 --bug for 12876009 end
608 , v_mmtt_rec.transaction_reference -- bug 13657375
609 );
610
611 --Added bug 3978111
612 IF v_mmtt_rec.content_lpn_id is not null
613 AND v_mmtt_rec.transaction_action_id=31
614 AND v_mmtt_rec.transaction_type_id=44 THEN
615 create_snapshot(x_trxtempid,v_mmtt_rec.organization_id);
616 END IF;
617 --Added bug 3978111
618 END;
619
620 /********************************************************************
621 * Insert a row into MTL_TRANSACTION_LOTS_TEMP
622 *******************************************************************/
623 FUNCTION insert_lot_trx(curlpnrec wms_container_pub.wms_container_content_rec_type, trxtmpid NUMBER)
624 RETURN NUMBER IS
625 lotobjid NUMBER;
626 sertrxid NUMBER;
627 retval NUMBER;
628 l_exp_date DATE;
629 l_primary_uom VARCHAR2(3);
630 l_primary_qty NUMBER;
631 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
632 l_parent_lot_number MTL_LOT_NUMBERS.PARENT_LOT_NUMBER%TYPE := NULL; --12949776
633 BEGIN
634 -- retrieve the expiration-date for the lot number
635 -- being inserted
636 BEGIN
637 /*12949776
638 Added parent_lot_number to fetch from MLN and pass to insert api.
639 */
640 IF (l_debug = 1) THEN
641 inv_log_util.TRACE('Fetching the Exp Date and Parent Lot Number', 'INV_LPN_TRX_PUB', 1);
642 END IF;
643
644 SELECT expiration_date, parent_lot_number
645 INTO l_exp_date, l_parent_lot_number
646 FROM mtl_lot_numbers
647 WHERE organization_id = curlpnrec.organization_id
648 AND inventory_item_id = curlpnrec.content_item_id
649 AND lot_number = curlpnrec.lot_number;
650 EXCEPTION
651 WHEN OTHERS THEN
652 l_exp_date := NULL;
653 l_parent_lot_number := NULL; --12949776
654 END;
655 --12949776
656 IF (l_debug = 1) THEN
657 inv_log_util.TRACE(' After Fetching the Exp Date and Parent Lot Number - exp_date : ParentLot' ||l_exp_date||' : '||l_parent_lot_number , 'INV_LPN_TRX_PUB', 1);
658 END IF;
659
660 SELECT primary_uom_code
661 INTO l_primary_uom
662 FROM mtl_system_items
663 WHERE inventory_item_id = curlpnrec.content_item_id
664 AND organization_id = curlpnrec.organization_id;
665
666 --bug 8526601 added lot number and org id to make the inv_convert call lot specific
667 --l_primary_qty := inv_convert.inv_um_convert(curlpnrec.content_item_id,curlpnrec.lot_number,curlpnrec.organization_id,5, curlpnrec.quantity, curlpnrec.uom, l_primary_uom, NULL, NULL);
668
669 /*IF (l_primary_qty <= -99999) THEN
670 fnd_message.set_name('INV', 'INV_UOM_CONVERSION_ERROR');
671 fnd_message.set_token('uom1', curlpnrec.uom);
672 fnd_message.set_token('uom2', l_primary_uom);
673 fnd_message.set_token('module', 'INSERT_LOT_TRX');
674 fnd_msg_pub.ADD;
675 RAISE fnd_api.g_exc_error;
676 END IF;*/
677 --16445970 Commented the above conversion of Primary quantity
678 l_primary_qty := curlpnrec.primary_quantity;
679
680 IF (l_debug = 1) THEN
681 inv_log_util.TRACE('Extracting the Primary Qty from WLC. No need to convert ', 'INV_LPN_TRX_PUB', 1);
682 inv_log_util.TRACE('l_primary_qty: '||l_primary_qty, 'INV_LPN_TRX_PUB', 1);
683 END IF;
684 --16445970
685
686 retval :=
687 inv_trx_util_pub.insert_lot_trx(
688 p_trx_tmp_id => trxtmpid
689 , p_user_id => 1
690 , p_lot_number => curlpnrec.lot_number
691 , p_trx_qty => curlpnrec.quantity
692 , p_pri_qty => l_primary_qty
693 , p_secondary_qty => curlpnrec.sec_quantity --INVCONV kkillams
694 , p_secondary_uom => curlpnrec.sec_uom --INVCONV kkillams
695 , x_ser_trx_id => sertrxid
696 , x_proc_msg => ret_msgdata
697 , p_exp_date => l_exp_date
698 , p_parent_lot_number => l_parent_lot_number /*12949776*/
699 );
700
701 IF (retval <> 0) THEN
702 IF (l_debug = 1) THEN
703 inv_log_util.TRACE('**Error from insertLot :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
704 END IF;
705
706 fnd_message.set_name('INV', 'INV_FAILED');
707 fnd_msg_pub.ADD;
708 RAISE fnd_api.g_exc_error;
709 END IF;
710
711 IF (l_debug = 1) THEN
712 inv_log_util.TRACE('*Inserted Lot :' || curlpnrec.lot_number, 'INV_LPN_TRX_PUB', 9);
713 END IF;
714
715 RETURN sertrxid;
716 END;
717
718 /********************************************************************
719 * Insert a row into MTL_SERIAL_NUMBERS_TEMP
720 *******************************************************************/
721 FUNCTION insert_ser_trx(p_ser_number VARCHAR2, p_sertrxid NUMBER)
722 RETURN NUMBER IS
723 retval NUMBER;
724 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
725 BEGIN
726 retval :=
727 inv_trx_util_pub.insert_ser_trx(p_trx_tmp_id => p_sertrxid, p_user_id => 1, p_fm_ser_num => p_ser_number
728 , p_to_ser_num => p_ser_number, x_proc_msg => ret_msgdata);
729
730 IF (retval <> 0) THEN
731 IF (l_debug = 1) THEN
732 inv_log_util.TRACE('**Error from insertSerial :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
733 END IF;
734
735 fnd_message.set_name('INV', 'INV_FAILED');
736 fnd_msg_pub.ADD;
737 RAISE fnd_api.g_exc_error;
738 END IF;
739
740 IF (l_debug = 1) THEN
741 inv_log_util.TRACE('*Inserted Serial:' || p_ser_number || ',trxid=' || p_sertrxid, 'INV_LPN_TRX_PUB', 9);
742 END IF;
743
744 RETURN 0;
745 END;
746 /* Bug#5486052. Added the below function. This function takes itemID, quantity and 2 UOM codes as input parameters.
747 * It returns the quantity, which was expressed in the 1st UOM, converted to the 2nd UOM.*/
748 ----bug 8526601 added lot number and org id as IN parameters to make the inv_convert call lot specific
749 FUNCTION get_converted_qty(p_inventory_item_id NUMBER,p_lot_number VARCHAR2,p_organization_id NUMBER, p_qty NUMBER, p_uom1 VARCHAR2, p_uom2 VARCHAR2)
750 RETURN NUMBER IS
751 l_converted_qty NUMBER;
752 BEGIN
753 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
754 l_converted_qty := inv_convert.inv_um_convert( p_inventory_item_id
755 ,p_lot_number
756 ,p_organization_id
757 , 6
758 , p_qty
759 , p_uom1
760 , p_uom2
761 , NULL
762 , NULL);
763 IF ( l_converted_qty = -99999 ) THEN
764 fnd_message.set_name('INV', 'INV_UOM_CONVERSION_ERROR');
765 fnd_message.set_token('uom1', p_uom1);
766 fnd_message.set_token('uom2', p_uom2);
767 fnd_message.set_token('module', 'GET_CONVERTED_QTY');
768 fnd_msg_pub.ADD;
769 RAISE fnd_api.g_exc_error;
770 END IF;
771
772 RETURN l_converted_qty;
773 END;
774
775 /********************************************************************
776 * Explode the contents of the lpn and insert into MMTT, MSNT and MTLT
777 *******************************************************************/
778 FUNCTION explode_and_insert(p_lpn_id NUMBER, p_hdr_id NUMBER, p_mmtt IN OUT NOCOPY mtl_material_transactions_temp%ROWTYPE)
779 RETURN NUMBER IS
780 tb_lpn_cnts wms_container_pub.wms_container_tbl_type;
781 lpnitndx NUMBER;
782 curlpnrec wms_container_pub.wms_container_content_rec_type;
783 insrowcnt NUMBER := 0;
784 trxtmpid NUMBER;
785 sertrxid NUMBER;
786 l_pre_sertrxid NUMBER;
787 retval NUMBER;
788 itemqty NUMBER;
789 itemsecqty NUMBER; --INVCONV kkillams
790 orgid NUMBER;
791 subinv VARCHAR2(32);
792 locatorid NUMBER;
793 lastitemid NUMBER := NULL;
794 lastrevison VARCHAR2(3);
795 lastcostgroupid NUMBER := NULL;
796 lastparentlpnid NUMBER := NULL;
797 lotexpdate DATE;
798 lotobjid NUMBER;
799 v_lasttrxtmpid NUMBER;
800 v_lastitemqty NUMBER;
801 v_lastitemsecqty NUMBER; ---INVCONV KKILLAMS
802 lastlotnum mtl_transaction_lots_temp.lot_number%TYPE;
803 itemqtychanged BOOLEAN := FALSE;
804 lotqtychanged BOOLEAN := FALSE;
805 lotqty NUMBER;
806 lotsecqty NUMBER; --invconv kkillams
807 l_lpn_subinv VARCHAR2(32) := p_mmtt.subinventory_code;
808 l_lpn_locator_id NUMBER := p_mmtt.locator_id;
809 l_cst_grp_id NUMBER;
810 l_xfr_cst_grp_id NUMBER;
811 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
812 /* Bug 2712046, add cost group comingle check if the transfer location is non-LPN controlled
813 new variable to check LPN controlled flag of the transfer subinventory */
814 l_skip_comingle_check NUMBER := 0;
815 --l_lpn_controlled_flag number := 0;
816 ret_status VARCHAR2(10);
817 ret_msgcnt NUMBER;
818 ret_msgdata VARCHAR2(2000);
819 l_comingling_occurs VARCHAR2(1);
820 l_count NUMBER;
821 l_cst_grp VARCHAR2(30);
822 lastuom VARCHAR2(3); /*Bug#5486052*/
823 l_conv_fact NUMBER := 1; /*Bug#5486052*/
824 l_primary_uom VARCHAR2(3); /*Bug#5486052*/
825 l_converted_qty NUMBER; /*Bug#5486052*/
826
827 v_lastitempriqty NUMBER;--16445970
828 lotpriqty NUMBER;--16445970
829 BEGIN
830 IF (l_debug = 1) THEN
831 inv_log_util.TRACE('** exploding lpn_id =' || p_lpn_id || ',qty=' || p_mmtt.primary_quantity, 'INV_LPN_TRX_PUB', 9);
832 END IF;
833
834 -- Bug 5103408 Add check for explode_lpn failure status.
835 -- Transaction should not continue if an error occurs during explosion
836 WMS_Container_PVT.Explode_LPN(1.0, fnd_api.g_false, fnd_api.g_false, ret_status, ret_msgcnt, ret_msgdata, p_lpn_id, 0, tb_lpn_cnts);
837
838 IF ( ret_status <> fnd_api.g_ret_sts_success) THEN
839 IF (l_debug = 1) THEN
840 inv_log_util.TRACE('**Error: Failed in wms_container_pub.explode_lpn API :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
841 END IF;
842
843 RAISE fnd_api.g_exc_error;
844 END IF;
845
846 -- Retrieve LPN's SUB and Locator
847 SELECT subinventory_code
848 , locator_id
849 INTO l_lpn_subinv
850 , l_lpn_locator_id
851 FROM wms_license_plate_numbers
852 WHERE lpn_id = p_lpn_id;
853
854 -- If No Subinventory associated with LPN, then pick sub and locator from MMT
855 IF (l_lpn_subinv IS NULL) THEN
856 l_lpn_subinv := p_mmtt.subinventory_code;
857 l_lpn_locator_id := p_mmtt.locator_id;
858 END IF;
859
860 IF (l_debug = 1) THEN
861 inv_log_util.TRACE('LPN sub : ' || l_lpn_subinv || ',loc=' || l_lpn_locator_id, 'INV_LPN_TRX_PUB', 9);
862 END IF;
863
864 --Check for batch ID and batch sequence. If they do not exist, populate them
865 --Also set inventory_item_id to -1 to ensure this record is processed first
866 --in the batch
867 IF (l_debug = 1) THEN
868 inv_log_util.TRACE('batch id=' || p_mmtt.transaction_batch_id || 'seq_id =' || p_mmtt.transaction_batch_seq, 'INV_LPN_TRX_PUB', 9);
869 END IF;
870
871 IF (p_mmtt.transaction_batch_id IS NULL OR p_mmtt.transaction_batch_seq IS NULL) THEN
872 -- Batch id and sequence pair should be unique for this header_id.
873 -- Going to used the transaction_temp_id for the batch and 1 for the sequence.
874 p_mmtt.transaction_batch_id := NVL(p_mmtt.transaction_batch_id, p_mmtt.transaction_temp_id);
875 p_mmtt.transaction_batch_seq := NVL(p_mmtt.transaction_batch_seq, 1);
876
877 UPDATE mtl_material_transactions_temp
878 SET inventory_item_id = -1
879 , transaction_batch_id = p_mmtt.transaction_batch_id
880 , transaction_batch_seq = p_mmtt.transaction_batch_seq
881 , subinventory_code = NVL(subinventory_code, l_lpn_subinv)
882 , locator_id = NVL(locator_id, l_lpn_locator_id)
883 WHERE transaction_temp_id = p_mmtt.transaction_temp_id;
884
885 -- If transaction came from MTI, need to also update MTI with
886 -- the same batch and sequence so java tm can update delete MTIs
887 IF ( p_mmtt.transaction_mode = inv_txn_manager_pub.proc_mode_mti ) THEN
888 UPDATE mtl_transactions_interface
889 SET transaction_batch_id = p_mmtt.transaction_batch_id
890 , transaction_batch_seq = p_mmtt.transaction_batch_seq
891 WHERE transaction_interface_id = p_mmtt.transaction_temp_id;
892
893 IF (l_debug = 1) THEN
894 inv_log_util.TRACE('From MTI, try update MTI batch and seq rowcount='||sql%rowcount, 'INV_LPN_TRX_PUB', 9);
895 END IF;
896
897 IF ( sql%rowcount = 0 ) THEN
898 fnd_message.set_name('INV', 'INV_NO_RECORDS');
899 fnd_message.set_token('ENTITY', 'MTL_TRANSACTIONS_INTERFACE');
900 fnd_msg_pub.ADD;
901 RAISE fnd_api.g_exc_error;
902 END IF;
903 END IF;
904 ELSIF(p_mmtt.inventory_item_id <> -1) THEN
905 UPDATE mtl_material_transactions_temp
906 SET inventory_item_id = -1
907 WHERE transaction_temp_id = p_mmtt.transaction_temp_id;
908 END IF;
909
910 -- Bug 2712046, add cost group comingle check if transfer location is non-LPN controlled
911 -- Set value for l_check_cg_comingle, this only need to be checked once before the Loop
912 IF (p_mmtt.transaction_action_id <> inv_globals.g_action_orgxfr)
913 AND(p_mmtt.transaction_action_id <> inv_globals.g_action_intransitshipment)
914 AND(p_mmtt.transaction_action_id <> inv_globals.g_action_intransitreceipt)
915 AND(NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code) IS NOT NULL) THEN
916 SELECT NVL(lpn_controlled_flag, 2)
917 INTO l_skip_comingle_check
918 FROM mtl_secondary_inventories
919 WHERE organization_id = NVL(p_mmtt.transfer_organization, p_mmtt.organization_id)
920 AND secondary_inventory_name = NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code);
921
922 IF SQL%NOTFOUND THEN
923 IF (l_debug = 1) THEN
924 inv_log_util.TRACE('No sub found when checking lpn_controlled_flag', 'INV_LPN_TRX_PUB', 5);
925 END IF;
926
927 fnd_message.set_name('INV', 'INV_INT_XSUBCODE');
928 fnd_msg_pub.ADD;
929 RAISE fnd_api.g_exc_error;
930 END IF;
931
932 IF (l_debug = 1) THEN
933 inv_log_util.TRACE(
934 'Checked lpn_controlled_flag for txnAction '
935 || p_mmtt.transaction_action_id
936 || ' and Sub '
937 || NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
938 || ', result='
939 || l_skip_comingle_check
940 , 'INV_LPN_TRX_PUB'
941 , 9
942 );
943 END IF;
944
945 -- If sub in not subinventory controlled check locator to see if is
946 -- a pjm locator. If it is no comingle check is requires since the
947 -- locators will be changed anyway.
948 IF (l_skip_comingle_check = 2) THEN
949 BEGIN
950 SELECT 1
951 INTO l_skip_comingle_check
952 FROM mtl_item_locations
953 WHERE project_id IS NOT NULL
954 AND inventory_location_id = NVL(p_mmtt.transfer_to_location, p_mmtt.locator_id)
955 AND subinventory_code = NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
956 AND organization_id = NVL(p_mmtt.transfer_organization, p_mmtt.organization_id);
957 EXCEPTION
958 WHEN NO_DATA_FOUND THEN
959 l_skip_comingle_check := 2;
960 inv_log_util.TRACE('NOTFOUND l_skip_comingle_check=' || l_skip_comingle_check, 'INV_LPN_TRX_PUB', 5);
961 END;
962
963 IF (l_debug = 1) THEN
964 inv_log_util.TRACE('Checked if is a pjm locator l_skip_comingle_check=' || l_skip_comingle_check, 'INV_LPN_TRX_PUB', 5);
965 END IF;
966 END IF;
967 ELSE
968 l_skip_comingle_check := 1;
969 END IF;
970
971 -- Loop and Insert all the LPN contents into MMTT
972 lpnitndx := tb_lpn_cnts.FIRST;
973
974 LOOP
975 curlpnrec := tb_lpn_cnts(lpnitndx);
976
977 IF (l_debug = 1) THEN
978 inv_log_util.TRACE(
979 ' cntlpnid = '
980 || curlpnrec.content_lpn_id
981 || ',par lpnid='
982 || curlpnrec.parent_lpn_id
983 || ', item_id='
984 || curlpnrec.content_item_id
985 || ',qty='
986 || curlpnrec.quantity
987 || ',sec_qty='
988 || curlpnrec.sec_quantity
989 || ',rev='
990 || curlpnrec.revision
991 , 'INV_LPN_TRX_PUB'
992 , 9
993 );
994 END IF;
995
996 -- We need to pupulate new MMTTs only for items within LPN. We need to
997 -- weed-out the curlpnrec which stands for these cases :
998 -- * LPN inside another LPN
999 -- * LPN which has item associated with it
1000 -- * LPN which has no item inside it
1001 IF (curlpnrec.content_item_id IS NOT NULL)
1002 AND(curlpnrec.content_lpn_id IS NULL) THEN
1003 insrowcnt := insrowcnt + 1;
1004
1005 -- Check if itemid and revision is same as last processed record.
1006 -- If it is, then this is for a Lot or Serial attribute
1007 IF (
1008 curlpnrec.content_item_id = lastitemid
1009 AND curlpnrec.parent_lpn_id = lastparentlpnid
1010 AND curlpnrec.cost_group_id = lastcostgroupid
1011 AND NVL(curlpnrec.revision, '@@') = NVL(lastrevison, '@@')
1012 AND lastuom = curlpnrec.uom --15837832
1013 ) THEN
1014 sertrxid := v_lasttrxtmpid;
1015 itemqtychanged := TRUE;
1016 /*Bug#5486052. If the UOM of the current record is not same as that of the last record,
1017 then convert the qty of the current record into the UOM of the last record.*/
1018 IF ( lastuom <> curlpnrec.uom ) THEN
1019 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
1020 l_converted_qty := get_converted_qty( curlpnrec.content_item_id
1021 ,curlpnrec.lot_number
1022 ,curlpnrec.organization_id
1023 , curlpnrec.quantity
1024 , curlpnrec.uom
1025 , lastuom);
1026 curlpnrec.quantity := l_converted_qty;
1027 curlpnrec.uom := lastuom;
1028 END IF;
1029 /*Bug#5486052. End*/
1030 v_lastitemqty := v_lastitemqty + curlpnrec.quantity;
1031 v_lastitemsecqty := NVL(v_lastitemsecqty,0) + NVL(curlpnrec.sec_quantity,0); --INVCONV kkillams
1032 v_lastitempriqty := NVL(v_lastitempriqty,0) + NVL(curlpnrec.primary_quantity,0); --16445970
1033 --Check Lot number
1034 IF (curlpnrec.lot_number IS NOT NULL) THEN
1035 IF (curlpnrec.lot_number <> lastlotnum) THEN
1036 IF (lotqtychanged) THEN
1037 IF (l_debug = 1) THEN
1038 inv_log_util.TRACE('** Going to update last Lot rec1 qty = ' || lotqty, 'INV_LPN_TRX_PUB', 9);
1039 END IF;
1040
1041 UPDATE mtl_transaction_lots_temp
1042 SET transaction_quantity = lotqty
1043 -- , primary_quantity = lotqty * l_conv_fact /*Bug#5486052.*/
1044 , primary_quantity = lotpriqty --16445970
1045 , secondary_quantity = lotsecqty --INVCONV kkillams
1046 WHERE transaction_temp_id = v_lasttrxtmpid
1047 AND lot_number = lastlotnum;
1048
1049 lotqtychanged := FALSE;
1050 END IF;
1051
1052 IF (l_debug = 1) THEN
1053 inv_log_util.TRACE('** Inserting Lot Number ' || curlpnrec.lot_number, 'INV_LPN_TRX_PUB', 9);
1054 END IF;
1055
1056 -- Bug 2795134/2712046 Comingle check failed when sub-transfer LPN to non-LPN controlled sub
1057 -- Need to add check here as well for same item but different lot numbers
1058 -- Bug 2795042, add condition of curlpnrec.cost_group_id IS NOT NULL
1059 -- because for WIP putaway where cost group will be derived later, so
1060 -- comingle_check will fail if cost_group_id is NULL
1061 -- Bug 2886342. Add Or condition of p_mmtt.cost_group_id IS NOT NULL
1062 -- This is the cases when cost group suggestion has been stamped on MMTT
1063 -- which will be transferred to MOQD or WMS_LPN_CONTENTS later.
1064 -- assign_cost_group will not be called, so need to do the comingling check here
1065 IF (l_skip_comingle_check = 2)
1066 AND((curlpnrec.cost_group_id IS NOT NULL)
1067 OR(p_mmtt.cost_group_id IS NOT NULL)) THEN
1068 -- Non LPN Controlled, check cost group comingle
1069 IF (l_debug = 1) THEN
1070 inv_log_util.TRACE(
1071 'Transfer to non-LPN controlled location, calling comingle_check with '
1072 || 'p_org_id='
1073 || NVL(p_mmtt.transfer_organization, p_mmtt.organization_id)
1074 || ',p_item_id='
1075 || curlpnrec.content_item_id
1076 || ',p_rev='
1077 || curlpnrec.revision
1078 || ',p_lot='
1079 || curlpnrec.lot_number
1080 || ',sub='
1081 || NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
1082 || ',p_loc='
1083 || NVL(p_mmtt.transfer_to_location, p_mmtt.locator_id)
1084 || ',p_cg_id='
1085 || NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id)
1086 , 'INV_LPN_TRX_PUB'
1087 , 9
1088 );
1089 END IF;
1090
1091 l_comingling_occurs := 'N';
1092 inv_comingling_utils.comingle_check(
1093 x_return_status => ret_status
1094 , x_msg_count => ret_msgcnt
1095 , x_msg_data => ret_msgdata
1096 , x_comingling_occurs => l_comingling_occurs
1097 , x_count => l_count
1098 , p_organization_id => NVL(p_mmtt.transfer_organization, p_mmtt.organization_id)
1099 , p_inventory_item_id => curlpnrec.content_item_id
1100 , p_revision => curlpnrec.revision
1101 , p_lot_number => curlpnrec.lot_number
1102 , p_subinventory_code => NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
1103 , p_locator_id => NVL(p_mmtt.transfer_to_location, p_mmtt.locator_id)
1104 , p_lpn_id => NULL
1105 , p_cost_group_id => NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id)
1106 );
1107
1108 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1109 IF (l_debug = 1) THEN
1110 inv_log_util.TRACE('**Error: Failed in comingling_check API :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1111 END IF;
1112
1113 RAISE fnd_api.g_exc_error;
1114 END IF;
1115
1116 IF (l_comingling_occurs = 'Y') THEN
1117 IF (l_debug = 1) THEN
1118 inv_log_util.TRACE('**Error: Transaction results in co-mingling :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1119 END IF;
1120
1121 SELECT cost_group
1122 INTO l_cst_grp
1123 FROM cst_cost_groups
1124 WHERE cost_group_id = NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id);
1125
1126 fnd_message.set_name('INV', 'INV_COMINGLE_FAIL');
1127 fnd_message.set_token('CG', l_cst_grp);
1128 fnd_msg_pub.ADD;
1129 RAISE fnd_api.g_exc_error;
1130 END IF;
1131 END IF;
1132
1133 sertrxid := insert_lot_trx(curlpnrec, v_lasttrxtmpid);
1134 lastlotnum := curlpnrec.lot_number;
1135 lotqty := curlpnrec.quantity;
1136 lotsecqty := curlpnrec.sec_quantity; --INVCONV kkillams
1137 lotpriqty := curlpnrec.primary_quantity; --16445970
1138 ELSE
1139 -- Item and LotNumber same as previous. Use the transactionId
1140 -- used by the last serial insertions.
1141 sertrxid := l_pre_sertrxid;
1142 lotqty := lotqty + curlpnrec.quantity;
1143 lotsecqty := NVL(lotsecqty,0) + NVL(curlpnrec.sec_quantity,0); --INVCONV kkillams
1144 lotpriqty := NVL(lotpriqty,0) + curlpnrec.primary_quantity; --16445970
1145 lotqtychanged := TRUE;
1146 END IF;
1147 ELSE
1148 IF (lotqtychanged) THEN
1149 IF (l_debug = 1) THEN
1150 inv_log_util.TRACE('** Going to update last Lot rec2 qty = ' || lotqty, 'INV_LPN_TRX_PUB', 9);
1151 END IF;
1152
1153 UPDATE mtl_transaction_lots_temp
1154 SET transaction_quantity = lotqty
1155 --, primary_quantity = lotqty * l_conv_fact /*Bug#5486052.*/
1156 , primary_quantity = lotpriqty --16445970
1157 , secondary_quantity = lotsecqty --INVCONV kkillams
1158 WHERE transaction_temp_id = v_lasttrxtmpid
1159 AND lot_number = lastlotnum;
1160
1161 lotqtychanged := FALSE;
1162 END IF;
1163 END IF;
1164
1165 IF (curlpnrec.serial_number IS NOT NULL) THEN
1166 IF (l_debug = 1) THEN
1167 inv_log_util.TRACE('** Inserting Serial Number ' || curlpnrec.serial_number, 'INV_LPN_TRX_PUB', 9);
1168 END IF;
1169
1170 retval := insert_ser_trx(curlpnrec.serial_number, sertrxid);
1171 l_pre_sertrxid := sertrxid;
1172 END IF;
1173 ELSE -- New item record
1174 -- Bug 2712046 Need to check cost group comingling if the transfer location
1175 -- is non-LPN controlled.
1176 -- Bug 2795042, add condition of curlpnrec.cost_group_id IS NOT NULL
1177 -- because for WIP putaway where cost group will be derived later, so
1178 -- comingle_check will fail if cost_group_id is NULL
1179 -- Bug 2886342. Add Or condition of p_mmtt.cost_group_id IS NOT NULL
1180 -- This is the cases when cost group suggestion has been stamped on MMTT
1181 -- which will be transferred to MOQD or WMS_LPN_CONTENTS later.
1182 -- assign_cost_group will not be called, so need to do the comingling check here
1183
1184 IF (l_skip_comingle_check = 2)
1185 AND((curlpnrec.cost_group_id IS NOT NULL)
1186 OR(p_mmtt.cost_group_id IS NOT NULL)) THEN
1187 -- Non LPN Controlled, check cost group comingle
1188 IF (l_debug = 1) THEN
1189 inv_log_util.TRACE(
1190 'Transfer to non-LPN controlled location, calling comingle_check with '
1191 || 'p_org_id='
1192 || NVL(p_mmtt.transfer_organization, p_mmtt.organization_id)
1193 || ',p_item_id='
1194 || curlpnrec.content_item_id
1195 || ',p_rev='
1196 || curlpnrec.revision
1197 || ',p_lot='
1198 || curlpnrec.lot_number
1199 || ',sub='
1200 || NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
1201 || ',p_loc='
1202 || NVL(p_mmtt.transfer_to_location, p_mmtt.locator_id)
1203 || ',p_cg_id='
1204 || NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id)
1205 , 'INV_LPN_TRX_PUB'
1206 , 9
1207 );
1208 END IF;
1209
1210 inv_comingling_utils.comingle_check(
1211 x_return_status => ret_status
1212 , x_msg_count => ret_msgcnt
1213 , x_msg_data => ret_msgdata
1214 , x_comingling_occurs => l_comingling_occurs
1215 , x_count => l_count
1216 , p_organization_id => NVL(p_mmtt.transfer_organization, p_mmtt.organization_id)
1217 , p_inventory_item_id => curlpnrec.content_item_id
1218 , p_revision => curlpnrec.revision
1219 , p_lot_number => curlpnrec.lot_number
1220 , p_subinventory_code => NVL(p_mmtt.transfer_subinventory, p_mmtt.subinventory_code)
1221 , p_locator_id => NVL(p_mmtt.transfer_to_location, p_mmtt.locator_id)
1222 , p_lpn_id => NULL
1223 , p_cost_group_id => NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id)
1224 );
1225
1226 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1227 IF (l_debug = 1) THEN
1228 inv_log_util.TRACE('**Error: Failed in comingling_check API :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1229 END IF;
1230
1231 RAISE fnd_api.g_exc_error;
1232 END IF;
1233
1234 IF (l_comingling_occurs = 'Y') THEN
1235 IF (l_debug = 1) THEN
1236 inv_log_util.TRACE('**Error: Transaction results in co-mingling :' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1237 END IF;
1238
1239 SELECT cost_group
1240 INTO l_cst_grp
1241 FROM cst_cost_groups
1242 WHERE cost_group_id = NVL(curlpnrec.cost_group_id, p_mmtt.cost_group_id);
1243
1244 fnd_message.set_name('INV', 'INV_COMINGLE_FAIL');
1245 fnd_message.set_token('CG', l_cst_grp);
1246 fnd_msg_pub.ADD;
1247 RAISE fnd_api.g_exc_error;
1248 END IF;
1249 END IF;
1250
1251 -- End Bug 2712046
1252
1253 -- if the previous item's qty was changed, then update record
1254 IF (itemqtychanged) THEN
1255 IF (p_mmtt.transaction_action_id = inv_globals.g_action_issue)
1256 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment) THEN
1257 v_lastitemqty := -1 * v_lastitemqty;
1258
1259 IF v_lastitemsecqty <> 0 THEN -- INVCONV KKILLAMS
1260 v_lastitemsecqty := -1 * v_lastitemsecqty;
1261 END IF;
1262 v_lastitempriqty := -1* v_lastitempriqty; --16445970
1263 END IF;
1264
1265 IF (l_debug = 1) THEN
1266 inv_log_util.TRACE('** Going to upd lst rec1. qty = ' || v_lastitemqty, 'INV_LPN_TRX_PUB', 9);
1267 END IF;
1268
1269 UPDATE mtl_material_transactions_temp
1270 SET transaction_quantity = v_lastitemqty
1271 --, primary_quantity = v_lastitemqty * l_conv_fact /*Bug#5486052.*/
1272 , primary_quantity = v_lastitempriqty --16445970
1273 , secondary_transaction_quantity = CASE WHEN v_lastitemsecqty <> 0 THEN v_lastitemsecqty ELSE secondary_transaction_quantity END --INVCONV kkillams
1274 WHERE transaction_temp_id = v_lasttrxtmpid;
1275
1276 itemqtychanged := FALSE;
1277 p_mmtt.transaction_quantity := v_lastitemqty;
1278 p_mmtt.primary_quantity := v_lastitemqty;
1279 p_mmtt.secondary_transaction_quantity := CASE WHEN v_lastitemsecqty <> 0 THEN v_lastitemsecqty ELSE p_mmtt.secondary_transaction_quantity END; --INVCONV kkillams
1280
1281 IF (lotqtychanged) THEN
1282 IF (l_debug = 1) THEN
1283 inv_log_util.TRACE('** Going to upd lst lot3. qty = ' || lotqty, 'INV_LPN_TRX_PUB', 9);
1284 END IF;
1285
1286 UPDATE mtl_transaction_lots_temp
1287 SET transaction_quantity = lotqty
1288 --, primary_quantity = lotqty * l_conv_fact /*Bug#5486052.*/
1289 , primary_quantity = lotpriqty --16445970
1290 , secondary_quantity = lotsecqty --INVCONV kkillams
1291 WHERE transaction_temp_id = v_lasttrxtmpid
1292 AND lot_number = lastlotnum;
1293 END IF;
1294 END IF;
1295
1296 -- If this an InterOrg Xfer transaction, then call the CostGroup API
1297 -- for the previously entered content Item. At this stage all the
1298 -- rows for this item would have been entered to the temp tables.
1299 IF (lastitemid IS NOT NULL) THEN
1300 IF (p_mmtt.transaction_action_id = inv_globals.g_action_orgxfr)
1301 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
1302 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitreceipt)
1303 OR
1304 -- Bug 2712046 Cost group and comingling check is not executed when putaway a whole LPN for WIP
1305 -- Changed to add the condition that if cost group ID is null then also need to call cost group API
1306 ( p_mmtt.cost_group_id IS NULL) THEN
1307 inv_cost_group_pvt.assign_cost_group(
1308 x_return_status => ret_status
1309 , x_msg_count => ret_msgcnt
1310 , x_msg_data => ret_msgdata
1311 , p_organization_id => p_mmtt.organization_id
1312 , p_mmtt_rec => p_mmtt
1313 , p_fob_point => NULL
1314 , p_line_id => p_mmtt.transaction_temp_id
1315 , p_input_type => inv_cost_group_pub.g_input_mmtt
1316 , x_cost_group_id => l_cst_grp_id
1317 , x_transfer_cost_group_id => l_xfr_cst_grp_id
1318 );
1319
1320 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1321 IF (l_debug = 1) THEN
1322 inv_log_util.TRACE(' Error from CostGrpAPI:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1323 END IF;
1324
1325 fnd_message.set_name('INV', 'INV_COST_GROUP_FAILURE');
1326 fnd_msg_pub.ADD;
1327 RAISE fnd_api.g_exc_error;
1328 END IF;
1329 -- If this is for an OrgXfr transaction, update the cost_group_id
1330 -- of the content item for this LPN as this could have been
1331 -- changed by the CG API.
1332 END IF;
1333 END IF;
1334
1335 itemqtychanged := FALSE;
1336 lotqtychanged := FALSE;
1337 lotqty := 0;
1338 lotsecqty := 0; --INVCONV kkillams
1339 lotpriqty := 0; --16445970
1340 v_lastitemqty := curlpnrec.quantity;
1341 v_lastitemsecqty := curlpnrec.sec_quantity; --INVCONV kkillams
1342 v_lastitempriqty := curlpnrec.primary_quantity; --16445970
1343
1344 -- insert a record into MMTT.
1345 IF (p_mmtt.transaction_action_id = inv_globals.g_action_issue)
1346 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
1347 OR((p_mmtt.transaction_action_id = inv_globals.g_action_inv_lot_translate)
1348 AND(p_mmtt.transaction_quantity < 0)) THEN
1349 itemqty := -1 * curlpnrec.quantity;
1350 itemsecqty := -1 * curlpnrec.sec_quantity; --INVCONV kkillams
1351 ELSE
1352 itemqty := curlpnrec.quantity;
1353 itemsecqty := -1 * curlpnrec.sec_quantity; --INVCONV kkillams
1354 END IF;
1355
1356 IF (l_debug = 1) THEN
1357 inv_log_util.TRACE(
1358 '** inserting into MMTT. Mode-Normal. Qty=' || itemqty || ',sub=' || l_lpn_subinv || ',loc=' || l_lpn_locator_id
1359 , 'INV_LPN_TRX_PUB'
1360 , 9
1361 );
1362 END IF;
1363
1364 insert_line_trx(
1365 curlpnrec
1366 , p_mmtt.transaction_temp_id
1367 , p_mmtt.transaction_action_id
1368 , p_mmtt.organization_id
1369 , l_lpn_subinv
1370 , l_lpn_locator_id
1371 , itemqty
1372 , curlpnrec.cost_group_id
1373 , p_mmtt
1374 , v_lasttrxtmpid
1375 , itemsecqty --INCONV kkillams
1376 );
1377 sertrxid := v_lasttrxtmpid;
1378
1379 /*Bug#5486052. Added the below code to get the primary UOM code and the conversion factor
1380 between the primary UOM and current U0M for the current item.*/
1381 BEGIN
1382 SELECT primary_uom_code
1383 INTO l_primary_uom
1384 FROM mtl_system_items_b
1385 WHERE inventory_item_id = curlpnrec.content_item_id
1386 AND organization_id = curlpnrec.organization_id;
1387 EXCEPTION WHEN OTHERS THEN
1388 NULL;
1389 END;
1390 If ( curlpnrec.uom <> l_primary_uom ) THEN
1391 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
1392 l_conv_fact := get_converted_qty( curlpnrec.content_item_id
1393 ,curlpnrec.lot_number
1394 ,curlpnrec.organization_id
1395 , 1
1396 , curlpnrec.uom
1397 , l_primary_uom);
1398 ELSE
1399 l_conv_fact := 1;
1400 END IF;
1401 /*Bug#5486052. End.*/
1402
1403
1404 IF (l_debug = 1) THEN
1405 inv_log_util.TRACE('MMTT.retval=' || retval || ',lasttrxtmpid=' || v_lasttrxtmpid, 'INV_LPN_TRX_PUB', 9);
1406 END IF;
1407
1408 IF (curlpnrec.lot_number IS NOT NULL) THEN
1409 sertrxid := insert_lot_trx(curlpnrec, v_lasttrxtmpid);
1410 lastlotnum := curlpnrec.lot_number;
1411 lotqty := v_lastitemqty;
1412 lotsecqty := v_lastitemsecqty; --INVCONV kkillams
1413 lotpriqty := v_lastitempriqty; -- 16445970
1414 END IF;
1415
1416 IF (curlpnrec.serial_number IS NOT NULL) THEN
1417 retval := insert_ser_trx(curlpnrec.serial_number, sertrxid);
1418 l_pre_sertrxid := sertrxid;
1419 END IF;
1420 END IF;
1421
1422 lastitemid := curlpnrec.content_item_id;
1423 lastrevison := curlpnrec.revision;
1424 lastcostgroupid := curlpnrec.cost_group_id;
1425 lastparentlpnid := curlpnrec.parent_lpn_id;
1426 lastuom := curlpnrec.uom; /*Bug#5486052.*/
1427 END IF; -- curlpnrec.content_item_id is not null
1428
1429 EXIT WHEN lpnitndx = tb_lpn_cnts.LAST;
1430 lpnitndx := tb_lpn_cnts.NEXT(lpnitndx);
1431 END LOOP;
1432
1433 -- Any item or lot qty need to be updated ??
1434 IF (itemqtychanged) THEN
1435 IF (p_mmtt.transaction_action_id = inv_globals.g_action_issue)
1436 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
1437 OR((p_mmtt.transaction_action_id = inv_globals.g_action_inv_lot_translate)
1438 AND(p_mmtt.transaction_quantity < 0)) THEN
1439 v_lastitemqty := -1 * v_lastitemqty;
1440 IF v_lastitemsecqty IS NOT NULL THEN
1441 v_lastitemsecqty := -1 * v_lastitemsecqty; --INVCONV kkillams
1442 END IF;
1443 v_lastitempriqty := -1 * v_lastitempriqty; --16445970
1444 END IF;
1445
1446
1447 UPDATE mtl_material_transactions_temp
1448 SET transaction_quantity = v_lastitemqty
1449 --, primary_quantity = v_lastitemqty * l_conv_fact /*Bug#5486052.*/
1450 , primary_quantity = v_lastitempriqty --16445970
1451 -- nsinghi bug#5553546 v_lastitemsecqty is being wrongly assigned as v_lastitemqty in THEN part. change it to v_lastitemsecqty
1452 -- , secondary_transaction_quantity = CASE WHEN v_lastitemsecqty <> 0 THEN v_lastitemqty ELSE secondary_transaction_quantity END
1453 , secondary_transaction_quantity = CASE WHEN v_lastitemsecqty <> 0 THEN v_lastitemsecqty ELSE secondary_transaction_quantity END
1454 WHERE transaction_temp_id = v_lasttrxtmpid;
1455
1456 p_mmtt.transaction_quantity := v_lastitemqty;
1457 p_mmtt.primary_quantity := v_lastitemqty;
1458 p_mmtt.secondary_transaction_quantity := CASE WHEN v_lastitemsecqty <> 0 THEN v_lastitemsecqty ELSE p_mmtt.secondary_transaction_quantity END; --INVCONV kkillams
1459 itemqtychanged := FALSE;
1460
1461 IF (lotqtychanged) THEN
1462 UPDATE mtl_transaction_lots_temp
1463 SET transaction_quantity = lotqty
1464 --, primary_quantity = lotqty * l_conv_fact /*Bug#5486052.*/
1465 , primary_quantity = lotpriqty --16445970
1466 , secondary_quantity = lotsecqty --INVCONV kkillams
1467 WHERE transaction_temp_id = v_lasttrxtmpid
1468 AND lot_number = lastlotnum;
1469 END IF;
1470 END IF;
1471
1472 -- If this an InterOrg Xfer transaction, then call the CostGroup API
1473 -- for the previously entered content Item. At this stage all the
1474 -- rows for this item would have been entered to the temp tables.
1475 IF (p_mmtt.transaction_action_id = inv_globals.g_action_orgxfr)
1476 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
1477 OR(p_mmtt.transaction_action_id = inv_globals.g_action_intransitreceipt)
1478 OR
1479 -- Bug 2712046 Cost group and comingling check is not executed when putaway a whole LPN for WIP
1480 -- Changed to add the condition that if cost group ID is null then also need to call cost group API
1481 ( p_mmtt.cost_group_id IS NULL) THEN
1482 inv_cost_group_pvt.assign_cost_group(
1483 x_return_status => ret_status
1484 , x_msg_count => ret_msgcnt
1485 , x_msg_data => ret_msgdata
1486 , p_organization_id => p_mmtt.organization_id
1487 , p_mmtt_rec => p_mmtt
1488 , p_fob_point => NULL
1489 , p_line_id => p_mmtt.transaction_temp_id
1490 , p_input_type => inv_cost_group_pub.g_input_mmtt
1491 , x_cost_group_id => l_cst_grp_id
1492 , x_transfer_cost_group_id => l_xfr_cst_grp_id
1493 );
1494
1495 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1496 IF (l_debug = 1) THEN
1497 inv_log_util.TRACE(' Error from CostGrpAPI:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
1498 END IF;
1499
1500 fnd_message.set_name('INV', 'INV_COST_GROUP_FAILURE');
1501 fnd_msg_pub.ADD;
1502 RAISE fnd_api.g_exc_error;
1503 END IF;
1504 -- If this is for an OrgXfr transaction, update the cost_group_id
1505 -- of the content item for this LPN as this could have been
1506 -- changed by the CG API.
1507 END IF;
1508
1509 RETURN insrowcnt;
1510 END;
1511
1512 --FOB changes. Patchset J. This API is only called wif PO pathset J is installed
1513 -- We track the FOB info in MMTT + MMT.
1514 PROCEDURE update_fob_point(
1515 v_mmtt IN OUT NOCOPY mtl_material_transactions_temp%ROWTYPE
1516 , x_return_status IN OUT NOCOPY VARCHAR2
1517 , x_msg_data IN OUT NOCOPY VARCHAR2
1518 , x_msg_count IN OUT NOCOPY NUMBER
1519 ) IS
1520 l_fob_point NUMBER;
1521 l_intransit_inv_account NUMBER;
1522 l_transfer_transaction_id NUMBER;
1523 l_shipment_line_id NUMBER;
1524 l_mmt_transaction_id NUMBER;
1525 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1526 BEGIN
1527 x_return_status := fnd_api.g_ret_sts_success;
1528
1529 IF (l_debug = 1) THEN
1530 inv_log_util.TRACE('PO J installed', 'INV_LPN_TRX_PUB', 1);
1531 inv_log_util.TRACE('Updating FOB_POINT', 'INV_LPN_TRX_PUB', 1);
1532 inv_log_util.TRACE('organization_id' || v_mmtt.organization_id, 'INV_LPN_TRX_PUB', 1);
1533 inv_log_util.TRACE('xfr_organization_id' || v_mmtt.transfer_organization, 'INV_LPN_TRX_PUB', 1);
1534 inv_log_util.TRACE('trx_action_id' || v_mmtt.transaction_action_id, 'INV_LPN_TRX_PUB', 1);
1535 inv_log_util.TRACE('trx_temp_id' || v_mmtt.transaction_temp_id, 'INV_LPN_TRX_PUB', 1);
1536 END IF;
1537
1538 IF (v_mmtt.transaction_temp_id IS NULL) THEN
1539 x_msg_data := 'Trx_temp_id is null return success';
1540
1541 IF (l_debug = 1) THEN
1542 inv_log_util.TRACE('Trx_temp_id is null return success', 'INV_LPN_TRX_PUB', 1);
1543 END IF;
1544
1545 RETURN;
1546 END IF;
1547
1548 IF (v_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment) THEN
1549 BEGIN
1550 SELECT fob_point
1551 , intransit_inv_account
1552 INTO l_fob_point
1553 , l_intransit_inv_account
1554 FROM mtl_interorg_parameters
1555 WHERE from_organization_id = v_mmtt.organization_id
1556 AND to_organization_id = v_mmtt.transfer_organization;
1557 EXCEPTION
1558 WHEN NO_DATA_FOUND THEN
1559 IF (l_debug = 1) THEN
1560 inv_log_util.TRACE('no data found INV_FOB_NOT_DEFINED', 'INV_LPN_TRX_PUB', 1);
1561 END IF;
1562
1563 fnd_message.set_name('INV', 'INV_FOB_NOT_DEFINED');
1564 fnd_message.set_token('ENTITY1', v_mmtt.organization_id);
1565 fnd_msg_pub.ADD;
1566 RAISE fnd_api.g_exc_error;
1567 END;
1568
1569 UPDATE mtl_material_transactions_temp
1570 SET fob_point = l_fob_point
1571 , intransit_account = l_intransit_inv_account
1572 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
1573
1574 /**bug 3371548 assign values to the cursor*/
1575 v_mmtt.fob_point := l_fob_point;
1576 v_mmtt.intransit_account := l_intransit_inv_account;
1577 ELSIF(v_mmtt.transaction_action_id = inv_globals.g_action_intransitreceipt) THEN
1578 BEGIN
1579 SELECT shipment_line_id
1580 INTO l_shipment_line_id
1581 FROM rcv_transactions
1582 WHERE transaction_id =v_mmtt.rcv_transaction_id;
1583 EXCEPTION
1584 WHEN NO_DATA_FOUND THEN
1585 IF (l_debug = 1) THEN
1586 inv_log_util.TRACE('no data found rcv_transactions', 'INV_LPN_TRX_PUB', 1);
1587 END IF;
1588
1589 RAISE fnd_api.g_exc_error;
1590 END;
1591
1592 SELECT Nvl(mmt_transaction_id,-1)
1593 INTO l_mmt_transaction_id
1594 FROM rcv_shipment_lines
1595 WHERE shipment_line_id = l_shipment_line_id;
1596
1597 IF (l_mmt_transaction_id = -1) then
1598 /**bug 3527331
1599 we have an issue on FOB point backward
1600 compatibility when deliver a shipment created before FOB point
1601 feature was enabled. Inv trxn mgr should take care of this
1602 corner case.
1603 In case rcv record does not have the reference to the
1604 correspoding shipment transaction, we shoudl populate the
1605 rcpt transaction with the fob_point by running a fresh query
1606 int mtl_interorg parameters*/
1607 BEGIN
1608 SELECT fob_point
1609 , intransit_inv_account
1610 INTO l_fob_point
1611 , l_intransit_inv_account
1612 FROM mtl_interorg_parameters
1613 WHERE from_organization_id = v_mmtt.transfer_organization
1614 AND to_organization_id = v_mmtt.organization_id;
1615 EXCEPTION
1616 WHEN NO_DATA_FOUND THEN
1617 IF (l_debug = 1) THEN
1618 inv_log_util.TRACE('no data found INV_FOB_NOT_DEFINED', 'INV_LPN_TRX_PUB', 1);
1619 END IF;
1620 fnd_message.set_name('INV', 'INV_FOB_NOT_DEFINED');
1621 fnd_message.set_token('ENTITY1', v_mmtt.organization_id);
1622 fnd_msg_pub.ADD;
1623 RAISE fnd_api.g_exc_error;
1624 END;
1625 else
1626 BEGIN
1627 SELECT fob_point
1628 , intransit_account
1629 INTO l_fob_point
1630 , l_intransit_inv_account
1631 FROM mtl_material_transactions
1632 WHERE transaction_id = l_mmt_transaction_id;
1633 EXCEPTION
1634 WHEN NO_DATA_FOUND THEN
1635 IF (l_debug = 1) THEN
1636 inv_log_util.TRACE('no data found mtl_material_transactions', 'INV_LPN_TRX_PUB', 1);
1637 END IF;
1638 RAISE fnd_api.g_exc_error;
1639 END;
1640 END IF;
1641 UPDATE mtl_material_transactions_temp
1642 SET fob_point = l_fob_point
1643 , intransit_account = l_intransit_inv_account
1644 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
1645
1646 /**bug 3371548 assign values to the cursor*/
1647 v_mmtt.fob_point := l_fob_point;
1648 v_mmtt.intransit_account := l_intransit_inv_account;
1649 END IF; -- intransit Rcpt
1650 EXCEPTION
1651 WHEN fnd_api.g_exc_error THEN
1652 x_return_status := fnd_api.g_ret_sts_error;
1653 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1654 WHEN OTHERS THEN
1655 x_return_status := fnd_api.g_ret_sts_unexp_error;
1656 END update_fob_point;
1657
1658 /********************************************************************
1659 * Pack or Unpack item/lpn. If lot or serial controlled, then
1660 * query corresponding lot or serial records
1661 *******************************************************************/
1662 PROCEDURE Call_Pack_Unpack (
1663 p_tempid NUMBER
1664 , p_content_lpn NUMBER
1665 , p_lpn NUMBER
1666 , p_item_rec inv_validate.item
1667 , p_revision VARCHAR2
1668 , p_primary_qty NUMBER
1669 , p_qty NUMBER
1670 , p_uom VARCHAR2
1671 , p_org_id NUMBER
1672 , p_subinv VARCHAR2
1673 , p_locator NUMBER
1674 , p_operation NUMBER
1675 , p_cost_grp_id NUMBER
1676 , p_trx_action NUMBER
1677 , p_source_header_id NUMBER
1678 , p_source_name VARCHAR2
1679 , p_source_type_id NUMBER --bug 3158847
1680 , p_sec_qty NUMBER --INVCONV kkillams
1681 , p_sec_uom VARCHAR2 --INVCONV kkillams
1682 , p_source_trx_id NUMBER
1683 ) IS
1684 v_sertrxid NUMBER;
1685 v_lotfound BOOLEAN := FALSE;
1686 v_serfound BOOLEAN := FALSE;
1687 item_id NUMBER := NULL;
1688 v_lotnum mtl_transaction_lots_temp.lot_number%TYPE;
1689 v_lotqty NUMBER;
1690 v_lotsecqty NUMBER;
1691 v_serqty NUMBER;
1692 l_operation NUMBER := p_operation;
1693 l_ignore_item_controls NUMBER;
1694
1695 CURSOR c_sertmp IS
1696 SELECT fm_serial_number
1697 , to_serial_number
1698 FROM mtl_serial_numbers_temp
1699 WHERE transaction_temp_id = v_sertrxid;
1700
1701 CURSOR c_lottmp IS
1702 SELECT lot_number
1703 , primary_quantity
1704 , transaction_quantity
1705 , secondary_quantity
1706 , serial_transaction_temp_id
1707 FROM mtl_transaction_lots_temp
1708 WHERE transaction_temp_id = p_tempid;
1709
1710 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
1711 BEGIN
1712 IF ( p_operation = g_unpack AND p_content_lpn IS NULL
1713 AND ( (p_source_type_id = inv_globals.g_sourcetype_purchaseorder AND p_trx_action = inv_globals.g_action_receipt)
1714 OR (p_source_type_id = inv_globals.g_sourcetype_rma AND p_trx_action = inv_globals.g_action_receipt)
1715 OR (p_source_type_id = inv_globals.g_sourcetype_intreq AND p_trx_action = inv_globals.g_action_intransitreceipt)
1716 OR (p_source_type_id = inv_globals.g_sourcetype_inventory AND p_trx_action = inv_globals.g_action_intransitreceipt)))
1717 THEN
1718 -- For the above types ignore the item controls
1719 l_ignore_item_controls := 1;
1720 ELSE
1721 -- Enforce item controls
1722 l_ignore_item_controls := 2;
1723 END IF;
1724
1725 /*IF ( l_lpn.lpn_context = 4 AND p_trx_action_id = 8 ) THEN
1726 -- Change operation to new Adjust type
1727 l_operation := g_adjust;
1728 END IF;*/
1729
1730 IF (p_content_lpn IS NOT NULL) THEN
1731 -- If content_lpn_id column has value then discard the item_id
1732 -- If content_lpn_id is Not NULL then we are packing/unpacking a
1733 -- whole LPN to/from another LPN, so no need to consider Lots and Serials
1734 IF (l_debug = 1) THEN
1735 inv_log_util.TRACE('** pack/unpack of whole LPN **', 'INV_LPN_TRX_PUB', 9);
1736 END IF;
1737
1738 WMS_Container_PVT.PackUnpack_Container(
1739 p_api_version => 1.0
1740 , p_init_msg_list => fnd_api.g_false
1741 , p_validation_level => fnd_api.g_valid_level_none
1742 , x_return_status => ret_status
1743 , x_msg_count => ret_msgcnt
1744 , x_msg_data => ret_msgdata
1745 , p_caller => 'INV_TRNSACTION'
1746 , p_lpn_id => p_lpn
1747 , p_content_lpn_id => p_content_lpn
1748 , p_content_item_id => item_id
1749 , p_revision => p_revision
1750 , p_primary_quantity => ABS(p_primary_qty)
1751 , p_quantity => ABS(p_qty)
1752 , p_uom => p_uom
1753 , p_sec_quantity => ABS(p_sec_qty) --INVCONV kkillams
1754 , p_sec_uom => p_sec_uom --INVCONV kkillams
1755 , p_organization_id => p_org_id
1756 , p_subinventory => p_subinv
1757 , p_locator_id => p_locator
1758 , p_operation => l_operation
1759 , p_cost_group_id => p_cost_grp_id
1760 , p_source_header_id => p_source_header_id
1761 , p_source_name => p_source_name
1762 , p_source_transaction_id => p_source_trx_id
1763 );
1764
1765 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1766 IF (l_debug = 1) THEN
1767 inv_log_util.TRACE('**Error from LPN pack/unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
1768 inv_log_util.TRACE(
1769 '**p_lpn='
1770 || p_lpn
1771 || ',p_content_lpn='
1772 || p_content_lpn
1773 || ',item_id='
1774 || item_id
1775 || ',p_revision='
1776 || p_revision
1777 || ',p_org_id='
1778 || p_org_id
1779 , 'INV_LPN_TRX_PUB'
1780 , 1
1781 );
1782 END IF;
1783
1784 IF (l_debug = 1) THEN
1785 inv_log_util.TRACE(
1786 ',p_subinv=' || p_subinv || ',p_locator=' || p_locator || ',p_operation=' || p_operation || ',p_cost_grp_id=' || p_cost_grp_id
1787 , 'INV_LPN_TRX_PUB'
1788 , 1
1789 );
1790 END IF;
1791
1792 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
1793 fnd_msg_pub.ADD;
1794 RAISE fnd_api.g_exc_error;
1795 END IF;
1796 ELSE
1797 -- We are packing/unpacking an Item. Check for Lot and Serials
1798 item_id := p_item_rec.inventory_item_id;
1799
1800 -- retrieve corresponding lot numbers
1801 FOR v_lottmp IN c_lottmp LOOP
1802 v_lotfound := TRUE;
1803 v_sertrxid := v_lottmp.serial_transaction_temp_id;
1804 v_lotnum := v_lottmp.lot_number;
1805 v_lotqty := v_lottmp.primary_quantity;
1806 v_lotsecqty := v_lottmp.secondary_quantity; --INVCONV kkillams
1807 v_serfound := FALSE;
1808
1809 FOR v_sertmp IN c_sertmp LOOP
1810 IF (l_debug = 1) THEN
1811 inv_log_util.TRACE('** Lot and Serial controlled**', 'INV_LPN_TRX_PUB', 9);
1812 END IF;
1813
1814 v_serfound := TRUE;
1815
1816 IF (v_sertmp.to_serial_number IS NULL)
1817 OR(v_sertmp.fm_serial_number = v_sertmp.to_serial_number) THEN
1818 v_serqty := 1;
1819 ELSE
1820 v_serqty := inv_serial_number_pub.get_serial_diff(v_sertmp.fm_serial_number, v_sertmp.to_serial_number);
1821 END IF;
1822
1823 /*3158847*/
1824 IF (
1825 p_item_rec.serial_number_control_code = 6 /*so issue*/
1826 AND p_source_type_id = 12 /*rma*/
1827 AND p_trx_action = 27 /*receipt*/
1828 AND p_operation = 1 /*pack*/
1829 ) THEN /*pack as vanilla*/
1830 inv_log_util.TRACE('** Packing rma so issue serial as vanilla for receipt**', 'INV_LPN_TRX_PUB', 9);
1831 WMS_Container_PVT.PackUnpack_Container (
1832 p_api_version => 1.0
1833 , p_init_msg_list => fnd_api.g_false
1834 , x_return_status => ret_status
1835 , p_validation_level => fnd_api.g_valid_level_none
1836 , x_msg_count => ret_msgcnt
1837 , x_msg_data => ret_msgdata
1838 , p_caller => 'INV_TRNSACTION'
1839 , p_lpn_id => p_lpn
1840 , p_content_lpn_id => p_content_lpn
1841 , p_content_item_id => item_id
1842 , p_revision => p_revision
1843 , p_lot_number => v_lotnum
1844 , p_from_serial_number => NULL --3158847
1845 , p_to_serial_number => NULL --3158847v_sertmp.to_serial_number
1846 , p_primary_quantity => v_serqty
1847 , p_quantity => v_serqty
1848 , p_uom => p_item_rec.primary_uom_code
1849 , p_organization_id => p_org_id
1850 , p_subinventory => p_subinv
1851 , p_locator_id => p_locator
1852 , p_operation => l_operation
1853 , p_cost_group_id => p_cost_grp_id
1854 , p_source_header_id => p_source_header_id
1855 , p_source_name => p_source_name
1856 , p_source_transaction_id => p_source_trx_id
1857 );
1858 ELSE
1859 WMS_Container_PVT.PackUnpack_Container (
1860 p_api_version => 1.0
1861 , p_init_msg_list => fnd_api.g_false
1862 , x_return_status => ret_status
1863 , p_validation_level => fnd_api.g_valid_level_none
1864 , x_msg_count => ret_msgcnt
1865 , x_msg_data => ret_msgdata
1866 , p_caller => 'INV_TRNSACTION'
1867 , p_lpn_id => p_lpn
1868 , p_content_lpn_id => p_content_lpn
1869 , p_content_item_id => item_id
1870 , p_revision => p_revision
1871 , p_lot_number => v_lotnum
1872 , p_from_serial_number => v_sertmp.fm_serial_number
1873 , p_to_serial_number => v_sertmp.to_serial_number
1874 , p_primary_quantity => v_serqty
1875 , p_quantity => v_serqty
1876 , p_uom => p_item_rec.primary_uom_code
1877 , p_organization_id => p_org_id
1878 , p_subinventory => p_subinv
1879 , p_locator_id => p_locator
1880 , p_operation => l_operation
1881 , p_cost_group_id => p_cost_grp_id
1882 , p_source_header_id => p_source_header_id
1883 , p_source_name => p_source_name
1884 , p_source_transaction_id => p_source_trx_id
1885 );
1886 END IF; /*end of 3158847*/
1887
1888 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1889 IF (l_debug = 1) THEN
1890 inv_log_util.TRACE('**Error from pack/unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
1891 inv_log_util.TRACE(
1892 '**p_lpn='
1893 || p_lpn
1894 || ',p_content_lpn='
1895 || p_content_lpn
1896 || ',item_id='
1897 || item_id
1898 || ',p_revision='
1899 || p_revision
1900 || ',v_lotnum='
1901 || v_lotnum
1902 || ',ser='
1903 || v_sertmp.fm_serial_number
1904 , 'INV_LPN_TRX_PUB'
1905 , 1
1906 );
1907 inv_log_util.TRACE(
1908 ',p_org_id='
1909 || p_org_id
1910 || ',p_subinv='
1911 || p_subinv
1912 || ',p_locator='
1913 || p_locator
1914 || ',p_operation='
1915 || p_operation
1916 || ',p_cost_grp_id='
1917 || p_cost_grp_id
1918 , 'INV_LPN_TRX_PUB'
1919 , 1
1920 );
1921 END IF;
1922
1923 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
1924 fnd_msg_pub.ADD;
1925 RAISE fnd_api.g_exc_error;
1926 END IF;
1927 END LOOP;
1928
1929 IF (NOT v_serfound) THEN
1930 IF (l_debug = 1) THEN
1931 inv_log_util.TRACE('**** Lot controlled **', 'INV_LPN_TRX_PUB', 9);
1932 END IF;
1933
1934 WMS_Container_PVT.PackUnpack_Container (
1935 p_api_version => 1.0
1936 , p_init_msg_list => fnd_api.g_false
1937 , p_validation_level => fnd_api.g_valid_level_none
1938 , x_return_status => ret_status
1939 , x_msg_count => ret_msgcnt
1940 , x_msg_data => ret_msgdata
1941 , p_caller => 'INV_TRNSACTION'
1942 , p_lpn_id => p_lpn
1943 , p_content_lpn_id => p_content_lpn
1944 , p_content_item_id => item_id
1945 , p_revision => p_revision
1946 , p_lot_number => v_lotnum
1947 , p_primary_quantity => ABS(v_lottmp.primary_quantity)
1948 , p_quantity => ABS(v_lottmp.transaction_quantity)
1949 , p_uom => p_uom
1950 , p_sec_quantity => ABS(v_lotsecqty) --INVCONV kkillams
1951 , p_sec_uom => p_item_rec.secondary_uom_code --INVCONV kkillams
1952 , p_organization_id => p_org_id
1953 , p_subinventory => p_subinv
1954 , p_locator_id => p_locator
1955 , p_operation => l_operation
1956 , p_cost_group_id => p_cost_grp_id
1957 , p_source_header_id => p_source_header_id
1958 , p_source_name => p_source_name
1959 , p_source_transaction_id => p_source_trx_id
1960 );
1961
1962 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
1963 IF (l_debug = 1) THEN
1964 inv_log_util.TRACE('**Error from pack/unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
1965 inv_log_util.TRACE(
1966 '**p_lpn='
1967 || p_lpn
1968 || ',p_content_lpn='
1969 || p_content_lpn
1970 || ',item_id='
1971 || item_id
1972 || ',p_revision='
1973 || p_revision
1974 || 'lot='
1975 || v_lotnum
1976 || ',p_org_id='
1977 || p_org_id
1978 , 'INV_LPN_TRX_PUB'
1979 , 1
1980 );
1981 inv_log_util.TRACE(
1982 ',p_subinv=' || p_subinv || ',p_locator=' || p_locator || ',p_operation=' || p_operation || ',p_cost_grp_id='
1983 || p_cost_grp_id
1984 , 'INV_LPN_TRX_PUB'
1985 , 1
1986 );
1987 END IF;
1988
1989 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
1990 fnd_msg_pub.ADD;
1991 RAISE fnd_api.g_exc_error;
1992 END IF;
1993 END IF;
1994 END LOOP;
1995
1996 IF (NOT v_lotfound) THEN
1997 v_sertrxid := p_tempid;
1998 v_serfound := FALSE;
1999
2000 FOR v_sertmp IN c_sertmp LOOP
2001 IF (l_debug = 1) THEN
2002 inv_log_util.TRACE('** Serial controlled**.fmser=' || v_sertmp.fm_serial_number || ', toser=' || v_sertmp.to_serial_number
2003 , 'INV_LPN_TRX_PUB', 9);
2004 END IF;
2005
2006 v_serfound := TRUE;
2007
2008 IF (v_sertmp.to_serial_number IS NULL)
2009 OR(v_sertmp.fm_serial_number = v_sertmp.to_serial_number) THEN
2010 v_serqty := 1;
2011 ELSE
2012 v_serqty := inv_serial_number_pub.get_serial_diff(v_sertmp.fm_serial_number, v_sertmp.to_serial_number);
2013 END IF;
2014
2015 /*3158847*/
2016 IF (
2017 p_item_rec.serial_number_control_code = 6 /*so issue*/
2018 AND p_source_type_id = 12 /*rma*/
2019 AND p_trx_action = 27 /*receipt*/
2020 AND p_operation = 1 /*pack*/
2021 ) THEN /*pack as vanilla*/
2022 inv_log_util.TRACE('** Packing rma so issue serial as vanilla for receipt**', 'INV_LPN_TRX_PUB', 9);
2023 WMS_Container_PVT.PackUnpack_Container (
2024 p_api_version => 1.0
2025 , p_init_msg_list => fnd_api.g_false
2026 , x_return_status => ret_status
2027 , p_validation_level => fnd_api.g_valid_level_none
2028 , x_msg_count => ret_msgcnt
2029 , x_msg_data => ret_msgdata
2030 , p_caller => 'INV_TRNSACTION'
2031 , p_lpn_id => p_lpn
2032 , p_content_lpn_id => p_content_lpn
2033 , p_content_item_id => item_id
2034 , p_revision => p_revision
2035 , p_lot_number => v_lotnum
2036 , p_from_serial_number => NULL --3158847
2037 , p_to_serial_number => NULL --3158847v_sertmp.to_serial_number
2038 , p_primary_quantity => v_serqty
2039 , p_quantity => v_serqty
2040 , p_uom => p_item_rec.primary_uom_code
2041 , p_organization_id => p_org_id
2042 , p_subinventory => p_subinv
2043 , p_locator_id => p_locator
2044 , p_operation => l_operation
2045 , p_cost_group_id => p_cost_grp_id
2046 , p_source_header_id => p_source_header_id
2047 , p_source_name => p_source_name
2048 , p_source_transaction_id => p_source_trx_id
2049 );
2050 ELSE
2051 WMS_Container_PVT.PackUnpack_Container (
2052 p_api_version => 1.0
2053 , p_init_msg_list => fnd_api.g_false
2054 , x_return_status => ret_status
2055 , x_msg_count => ret_msgcnt
2056 , x_msg_data => ret_msgdata
2057 , p_validation_level => fnd_api.g_valid_level_none
2058 , p_caller => 'INV_TRNSACTION'
2059 , p_lpn_id => p_lpn
2060 , p_content_lpn_id => p_content_lpn
2061 , p_content_item_id => item_id
2062 , p_revision => p_revision
2063 , p_from_serial_number => v_sertmp.fm_serial_number
2064 , p_to_serial_number => v_sertmp.to_serial_number
2065 , p_primary_quantity => v_serqty
2066 , p_quantity => v_serqty
2067 , p_uom => p_item_rec.primary_uom_code
2068 , p_organization_id => p_org_id
2069 , p_subinventory => p_subinv
2070 , p_locator_id => p_locator
2071 , p_operation => l_operation
2072 , p_cost_group_id => p_cost_grp_id
2073 , p_source_header_id => p_source_header_id
2074 , p_source_name => p_source_name
2075 , p_source_transaction_id => p_source_trx_id
2076 );
2077 END IF; /*3158847*/
2078
2079 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2080 IF (l_debug = 1) THEN
2081 inv_log_util.TRACE(
2082 '**Error from pack/unpack :'
2083 || ret_status
2084 || ',p_lpn='
2085 || p_lpn
2086 || ',p_content_lpn='
2087 || p_content_lpn
2088 || ',item_id='
2089 || item_id
2090 || ',fmser='
2091 || v_sertmp.fm_serial_number
2092 , 'INV_LPN_TRX_PUB'
2093 , 1
2094 );
2095 inv_log_util.TRACE(
2096 'toser=' || v_sertmp.to_serial_number || ',org=' || p_org_id || ',p_subinv=' || p_subinv || ',p_locator=' || p_locator
2097 , 'INV_LPN_TRX_PUB'
2098 , 9
2099 );
2100 END IF;
2101
2102 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
2103 fnd_msg_pub.ADD;
2104 RAISE fnd_api.g_exc_error;
2105 END IF;
2106 END LOOP;
2107
2108 IF (NOT v_serfound) THEN
2109 IF (l_debug = 1) THEN
2110 inv_log_util.TRACE('** NOT Lot OR Serial controlled**', 'INV_LPN_TRX_PUB', 9);
2111 END IF;
2112
2113 WMS_Container_PVT.PackUnpack_Container (
2114 p_api_version => 1.0
2115 , p_init_msg_list => fnd_api.g_false
2116 , x_return_status => ret_status
2117 , x_msg_count => ret_msgcnt
2118 , x_msg_data => ret_msgdata
2119 , p_caller => 'INV_TRNSACTION'
2120 , p_lpn_id => p_lpn
2121 , p_validation_level => fnd_api.g_valid_level_none
2122 , p_content_lpn_id => p_content_lpn
2123 , p_content_item_id => item_id
2124 , p_revision => p_revision
2125 , p_primary_quantity => ABS(p_primary_qty)
2126 , p_quantity => ABS(p_qty)
2127 , p_uom => p_uom
2128 , p_sec_quantity => ABS(p_sec_qty) --INVCONV kkillams
2129 , p_sec_uom => p_item_rec.secondary_uom_code --INVCONV kkillams
2130 , p_organization_id => p_org_id
2131 , p_subinventory => p_subinv
2132 , p_locator_id => p_locator
2133 , p_operation => l_operation
2134 , p_cost_group_id => p_cost_grp_id
2135 , p_source_header_id => p_source_header_id
2136 , p_source_name => p_source_name
2137 , p_source_transaction_id => p_source_trx_id
2138 );
2139
2140 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2141 IF (l_debug = 1) THEN
2142 inv_log_util.TRACE('**Error from pack/unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
2143 inv_log_util.TRACE(
2144 '**p_lpn='
2145 || p_lpn
2146 || ',p_content_lpn='
2147 || p_content_lpn
2148 || ',item_id='
2149 || item_id
2150 || ',p_revision='
2151 || p_revision
2152 || ',p_org_id='
2153 || p_org_id
2154 , 'INV_LPN_TRX_PUB'
2155 , 1
2156 );
2157 END IF;
2158
2159 IF (l_debug = 1) THEN
2160 inv_log_util.TRACE(
2161 ',p_subinv=' || p_subinv || ',p_locator=' || p_locator || ',p_operation=' || p_operation || ',p_cost_grp_id='
2162 || p_cost_grp_id
2163 , 'INV_LPN_TRX_PUB'
2164 , 1
2165 );
2166 END IF;
2167
2168 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
2169 fnd_msg_pub.ADD;
2170 RAISE fnd_api.g_exc_error;
2171 END IF;
2172 END IF;
2173 END IF;
2174 END IF; -- p_content_lpn is NULL
2175
2176 IF (p_operation = g_pack) THEN
2177 IF (l_debug = 1) THEN
2178 inv_log_util.TRACE('** Pack OK', 'INV_LPN_TRX_PUB', 9);
2179 END IF;
2180 ELSIF(p_operation = g_unpack) THEN
2181 IF (l_debug = 1) THEN
2182 inv_log_util.TRACE('** Unpack OK', 'INV_LPN_TRX_PUB', 9);
2183 END IF;
2184 END IF;
2185 END;
2186
2187 /********************************************************************
2188 * Update the status of the LPN
2189 *******************************************************************/
2190 PROCEDURE update_lpn_status(v_lpn wms_container_pub.lpn) IS
2191 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2192 BEGIN
2193 WMS_Container_PVT.Modify_LPN (
2194 p_api_version => 1.0
2195 , p_init_msg_list => fnd_api.g_true
2196 , p_commit => fnd_api.g_false
2197 , p_validation_level => fnd_api.g_valid_level_none
2198 , x_return_status => ret_status
2199 , x_msg_count => ret_msgcnt
2200 , x_msg_data => ret_msgdata
2201 , p_caller => 'INV_TRNSACTION'
2202 , p_lpn => v_lpn
2203 );
2204
2205 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2206 IF (l_debug = 1) THEN
2207 inv_log_util.TRACE('Error from modify_lpn :' || ret_status, 'INV_LPN_TRX_PUB', 1);
2208 inv_log_util.TRACE('Error msg :' || ret_msgdata || 'msgcnt=' || ret_msgcnt, 'INV_LPN_TRX_PUB', 1);
2209 END IF;
2210
2211 fnd_message.set_name('INV', 'INV_LPN_UPDATE_FAILURE');
2212 fnd_msg_pub.ADD;
2213 RAISE fnd_api.g_exc_error;
2214 END IF;
2215 END;
2216
2217 /********************************************************************
2218 * Insert a row into MTL_SERIAL_NUMBERS_TEMP which is a copy of another msnt row
2219 *******************************************************************/
2220 PROCEDURE copy_msnt(p_source_row_id ROWID, p_new_sertrxid NUMBER, p_new_fm_serial VARCHAR2, p_new_to_serial VARCHAR2) IS
2221 l_api_name CONSTANT VARCHAR2(30) := 'COPY_MSNT';
2222 l_api_version CONSTANT NUMBER := 1.0;
2223 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2224 l_sertmp_rec mtl_serial_numbers_temp%ROWTYPE;
2225 BEGIN
2226 IF (l_debug = 1) THEN
2227 inv_log_util.TRACE('Call to Copy_MSNT rowid=' || p_source_row_id, 'INV_LPN_TRX_PUB', 9);
2228 inv_log_util.TRACE('newsertrxid=' || p_new_sertrxid || ' newfsn=' || p_new_fm_serial || ' newtsn=' || p_new_to_serial
2229 , 'INV_LPN_TRX_PUB', 9);
2230 END IF;
2231
2232 SELECT *
2233 INTO l_sertmp_rec
2234 FROM mtl_serial_numbers_temp
2235 WHERE ROWID = p_source_row_id;
2236
2237 --Insert new record for split serials
2238 INSERT INTO mtl_serial_numbers_temp
2239 (
2240 transaction_temp_id
2241 , last_update_date
2242 , last_updated_by
2243 , creation_date
2244 , created_by
2245 , last_update_login
2246 , request_id
2247 , program_application_id
2248 , program_id
2249 , program_update_date
2250 , vendor_serial_number
2251 , vendor_lot_number
2252 , fm_serial_number
2253 , to_serial_number
2254 , serial_prefix
2255 , ERROR_CODE
2256 , group_header_id
2257 , parent_serial_number
2258 , end_item_unit_number
2259 , serial_attribute_category
2260 , origination_date
2261 , c_attribute1
2262 , c_attribute2
2263 , c_attribute3
2264 , c_attribute4
2265 , c_attribute5
2266 , c_attribute6
2267 , c_attribute7
2268 , c_attribute8
2269 , c_attribute9
2270 , c_attribute10
2271 , c_attribute11
2272 , c_attribute12
2273 , c_attribute13
2274 , c_attribute14
2275 , c_attribute15
2276 , c_attribute16
2277 , c_attribute17
2278 , c_attribute18
2279 , c_attribute19
2280 , c_attribute20
2281 , d_attribute1
2282 , d_attribute2
2283 , d_attribute3
2284 , d_attribute4
2285 , d_attribute5
2286 , d_attribute6
2287 , d_attribute7
2288 , d_attribute8
2289 , d_attribute9
2290 , d_attribute10
2291 , n_attribute1
2292 , n_attribute2
2293 , n_attribute3
2294 , n_attribute4
2295 , n_attribute5
2296 , n_attribute6
2297 , n_attribute7
2298 , n_attribute8
2299 , n_attribute9
2300 , n_attribute10
2301 , status_id
2302 , territory_code
2303 , time_since_new
2304 , cycles_since_new
2305 , time_since_overhaul
2306 , cycles_since_overhaul
2307 , time_since_repair
2308 , cycles_since_repair
2309 , time_since_visit
2310 , cycles_since_visit
2311 , time_since_mark
2312 , cycles_since_mark
2313 , number_of_repairs
2314 )
2315 VALUES (
2316 p_new_sertrxid
2317 , SYSDATE
2318 , l_sertmp_rec.last_updated_by
2319 , SYSDATE
2320 , l_sertmp_rec.created_by
2321 , l_sertmp_rec.last_update_login
2322 , l_sertmp_rec.request_id
2323 , l_sertmp_rec.program_application_id
2324 , l_sertmp_rec.program_id
2325 , l_sertmp_rec.program_update_date
2326 , l_sertmp_rec.vendor_serial_number
2327 , l_sertmp_rec.vendor_lot_number
2328 , p_new_fm_serial
2329 , p_new_to_serial
2330 , l_sertmp_rec.serial_prefix
2331 , l_sertmp_rec.ERROR_CODE
2332 , l_sertmp_rec.group_header_id
2333 , l_sertmp_rec.parent_serial_number
2334 , l_sertmp_rec.end_item_unit_number
2335 , l_sertmp_rec.serial_attribute_category
2336 , l_sertmp_rec.origination_date
2337 , l_sertmp_rec.c_attribute1
2338 , l_sertmp_rec.c_attribute2
2339 , l_sertmp_rec.c_attribute3
2340 , l_sertmp_rec.c_attribute4
2341 , l_sertmp_rec.c_attribute5
2342 , l_sertmp_rec.c_attribute6
2343 , l_sertmp_rec.c_attribute7
2344 , l_sertmp_rec.c_attribute8
2345 , l_sertmp_rec.c_attribute9
2346 , l_sertmp_rec.c_attribute10
2347 , l_sertmp_rec.c_attribute11
2348 , l_sertmp_rec.c_attribute12
2349 , l_sertmp_rec.c_attribute13
2350 , l_sertmp_rec.c_attribute14
2351 , l_sertmp_rec.c_attribute15
2352 , l_sertmp_rec.c_attribute16
2353 , l_sertmp_rec.c_attribute17
2354 , l_sertmp_rec.c_attribute18
2355 , l_sertmp_rec.c_attribute19
2356 , l_sertmp_rec.c_attribute20
2357 , l_sertmp_rec.d_attribute1
2358 , l_sertmp_rec.d_attribute2
2359 , l_sertmp_rec.d_attribute3
2360 , l_sertmp_rec.d_attribute4
2361 , l_sertmp_rec.d_attribute5
2362 , l_sertmp_rec.d_attribute6
2363 , l_sertmp_rec.d_attribute7
2364 , l_sertmp_rec.d_attribute8
2365 , l_sertmp_rec.d_attribute9
2366 , l_sertmp_rec.d_attribute10
2367 , l_sertmp_rec.n_attribute1
2368 , l_sertmp_rec.n_attribute2
2369 , l_sertmp_rec.n_attribute3
2370 , l_sertmp_rec.n_attribute4
2371 , l_sertmp_rec.n_attribute5
2372 , l_sertmp_rec.n_attribute6
2373 , l_sertmp_rec.n_attribute7
2374 , l_sertmp_rec.n_attribute8
2375 , l_sertmp_rec.n_attribute9
2376 , l_sertmp_rec.n_attribute10
2377 , l_sertmp_rec.status_id
2378 , l_sertmp_rec.territory_code
2379 , l_sertmp_rec.time_since_new
2380 , l_sertmp_rec.cycles_since_new
2381 , l_sertmp_rec.time_since_overhaul
2382 , l_sertmp_rec.cycles_since_overhaul
2383 , l_sertmp_rec.time_since_repair
2384 , l_sertmp_rec.cycles_since_repair
2385 , l_sertmp_rec.time_since_visit
2386 , l_sertmp_rec.cycles_since_visit
2387 , l_sertmp_rec.time_since_mark
2388 , l_sertmp_rec.cycles_since_mark
2389 , l_sertmp_rec.number_of_repairs
2390 );
2391 EXCEPTION
2392 WHEN OTHERS THEN
2393 IF (l_debug = 1) THEN
2394 inv_log_util.TRACE(l_api_name || ' Error', l_api_name, 1);
2395
2396 IF (SQLCODE IS NOT NULL) THEN
2397 inv_log_util.TRACE('SQL error: ' || SQLERRM(SQLCODE), l_api_name, 1);
2398 END IF;
2399 END IF;
2400
2401 RAISE fnd_api.g_exc_unexpected_error;
2402 END copy_msnt;
2403
2404 /********************************************************************
2405 * Split Delivery Details. If serial controlled, then
2406 * query corresponding lot or serial records
2407 *******************************************************************/
2408 PROCEDURE split_delivery_details(
2409 p_organization_id NUMBER
2410 , p_lpn_id NUMBER
2411 , p_xfr_lpn_id NUMBER
2412 , p_item_rec inv_validate.item
2413 , p_revision VARCHAR2
2414 , p_lot_number VARCHAR2
2415 , p_quantity NUMBER
2416 , p_uom_code VARCHAR2
2417 , p_secondary_trx_quantity NUMBER := NULL
2418 , p_secondary_uom_code VARCHAR2 := NULL
2419 , p_serial_trx_temp_id NUMBER
2420 , p_subinventory_code VARCHAR2
2421 , p_locator_id NUMBER
2422 , p_xfr_subinventory VARCHAR2 := NULL
2423 , p_xfr_to_location NUMBER := NULL
2424 , p_transaction_source_id NUMBER := NULL
2425 , p_trx_source_line_id NUMBER := NULL
2426 ) IS
2427 l_api_name CONSTANT VARCHAR2(30) := 'Split_Delivery_Details';
2428 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
2429 l_progress VARCHAR2(500) := '0';
2430
2431 -- Vaiables for call to Update_Shipping_Attributes
2432 l_shipping_attr wsh_interface.changedattributetabtype;
2433 l_invpcinrectype wsh_integration.invpcinrectype;
2434
2435 -- Types needed for WSH_WMS_LPN_GRP.Delivery_Detail_Action
2436 l_wsh_lpn_id_tbl wsh_util_core.id_tab_type;
2437 l_wsh_del_det_id_tbl wsh_util_core.id_tab_type;
2438 l_wsh_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
2439 l_wsh_defaults WSH_GLBL_VAR_STRCT_GRP.dd_default_parameters_rec_type;
2440 l_wsh_action_out_rec WSH_GLBL_VAR_STRCT_GRP.dd_action_out_rec_type;
2441
2442 -- New shipping API table types for Create_Update_Delivery_Detail
2443 l_del_det_attr wsh_interface_ext_grp.delivery_details_attr_tbl_type;
2444 l_del_det_in_rec wsh_interface_ext_grp.detailinrectype;
2445 l_del_det_out_rec wsh_interface_ext_grp.detailoutrectype;
2446 l_dd_ct NUMBER := 1;
2447 l_msg_details VARCHAR2(3000);
2448
2449 -- New shipping API table types for New Delivery_Detail_Action
2450 l_detail_id_tab wsh_util_core.id_tab_type;
2451 l_action_prms wsh_interface_ext_grp.det_action_parameters_rec_type;
2452 l_action_out_rec wsh_interface_ext_grp.det_action_out_rec_type;
2453
2454 CURSOR delivery_detail_cursor(lot VARCHAR2) IS
2455 /*Bug 7037834: Replaced the NVL statements with their equivalents in the where clause of below query for performance*/
2456 /* SELECT wdd2.delivery_detail_id
2457 , wdd2.src_requested_quantity_uom
2458 , NVL(wdd2.picked_quantity, wdd2.requested_quantity) requested_quantity
2459 , wdd2.requested_quantity_uom
2460 , wdd1.delivery_detail_id lpn_detail_id
2461 , wdd2.picked_quantity2
2462 , wdd2.requested_quantity_uom2
2463 , wdd2.transaction_temp_id
2464 , wdd2.serial_number
2465 , wdd2.source_header_id
2466 , wdd2.source_line_id
2467 FROM wsh_delivery_details wdd1, wsh_delivery_details wdd2, wsh_delivery_assignments_v wda
2468 WHERE wdd1.organization_id = p_organization_id
2469 AND wdd1.lpn_id = p_lpn_id
2470 AND wdd1.released_status = 'X' -- For LPN reuse ER : 6845650
2471 AND wda.parent_delivery_detail_id = wdd1.delivery_detail_id
2472 AND wdd2.delivery_detail_id = wda.delivery_detail_id
2473 AND wdd2.inventory_item_id = p_item_rec.inventory_item_id
2474 AND NVL(wdd2.revision, '@') = NVL(p_revision, '@')
2475 AND NVL(wdd2.lot_number, -999) = NVL(lot, -999)
2476 AND wdd2.source_header_id = NVL(p_transaction_source_id, wdd2.source_header_id)
2477 AND wdd2.source_line_id = NVL(p_trx_source_line_id, wdd2.source_line_id); */
2478
2479 SELECT wdd2.delivery_detail_id
2480 , wdd2.src_requested_quantity_uom
2481 , NVL(wdd2.picked_quantity, wdd2.requested_quantity) requested_quantity
2482 , wdd2.requested_quantity_uom
2483 , wdd1.delivery_detail_id lpn_detail_id
2484 , wdd2.picked_quantity2
2485 , wdd2.requested_quantity_uom2
2486 , wdd2.transaction_temp_id
2487 , wdd2.serial_number
2488 , wdd2.source_header_id
2489 , wdd2.source_line_id
2490 , wdd2.source_code --16197273
2491 FROM wsh_delivery_details wdd1, wsh_delivery_details wdd2, wsh_delivery_assignments wda
2492 WHERE wdd1.organization_id = p_organization_id
2493 AND wdd1.lpn_id = p_lpn_id
2494 AND wda.parent_delivery_detail_id = wdd1.delivery_detail_id
2495 AND wdd2.delivery_detail_id = wda.delivery_detail_id
2496 AND wdd2.inventory_item_id = p_item_rec.inventory_item_id
2497 AND ((WDD2.REVISION IS NULL AND p_revision IS NULL ) OR WDD2.REVISION = p_revision )
2498
2499 --AND NVL(wdd2.revision, '@') = NVL(p_revision, '@')
2500 AND ((WDD2.LOT_NUMBER IS NULL AND lot IS null) OR WDD2.LOT_NUMBER =lot )
2501
2502 --AND NVL(wdd2.lot_number, -999) = NVL(lot, -999)
2503 AND ((p_transaction_source_id IS NULL AND WDD2.SOURCE_HEADER_ID=wdd2.source_header_id) OR WDD2.SOURCE_HEADER_ID=p_transaction_source_id)
2504
2505 --AND wdd2.source_header_id = NVL(p_transaction_source_id, wdd2.source_header_id)
2506 AND ((p_trx_source_line_id IS NULL AND WDD2.SOURCE_LINE_ID =wdd2.source_line_id) OR WDD2.SOURCE_LINE_ID=p_trx_source_line_id );
2507
2508 --AND wdd2.source_line_id = NVL(p_trx_source_line_id, wdd2.source_line_id);
2509
2510 -- Bug 7037834
2511
2512 l_dd_rec delivery_detail_cursor%ROWTYPE;
2513
2514 CURSOR del_serial_cursor(p_wdd_trx_tmp_id NUMBER) IS
2515 SELECT DISTINCT msn.serial_number
2516 FROM mtl_serial_numbers msn, mtl_serial_numbers_temp wddmsnt, mtl_serial_numbers_temp trxmsnt
2517 WHERE msn.current_organization_id = p_organization_id
2518 AND msn.inventory_item_id = p_item_rec.inventory_item_id
2519 AND wddmsnt.transaction_temp_id = p_wdd_trx_tmp_id
2520 AND LENGTH(msn.serial_number) = LENGTH(wddmsnt.fm_serial_number)
2521 AND msn.serial_number BETWEEN wddmsnt.fm_serial_number AND NVL(wddmsnt.to_serial_number, wddmsnt.fm_serial_number)
2522 AND trxmsnt.transaction_temp_id = p_serial_trx_temp_id
2523 AND LENGTH(msn.serial_number) = LENGTH(trxmsnt.fm_serial_number)
2524 AND msn.serial_number BETWEEN trxmsnt.fm_serial_number AND NVL(trxmsnt.to_serial_number, trxmsnt.fm_serial_number)
2525 ORDER BY serial_number;
2526
2527 TYPE delserialtabtype IS TABLE OF VARCHAR2(30)
2528 INDEX BY BINARY_INTEGER;
2529
2530 ser_tbl delserialtabtype;
2531 l_tbl_cnt NUMBER;
2532
2533 CURSOR wdd_ser_cur(p_wdd_trx_tmp_id NUMBER, p_start_serial VARCHAR2) IS
2534 SELECT DISTINCT ROWID
2535 , fm_serial_number
2536 , to_serial_number
2537 FROM mtl_serial_numbers_temp msnt
2538 WHERE transaction_temp_id = p_wdd_trx_tmp_id
2539 AND fm_serial_number >= p_start_serial
2540 AND LENGTH(p_start_serial) = LENGTH(fm_serial_number)
2541 ORDER BY fm_serial_number;
2542
2543 -- Variables for call to Inv_Serial_Info
2544 l_serial_def_flag BOOLEAN;
2545 l_new_to_serial VARCHAR2(30);
2546 l_new_fm_serial VARCHAR2(30);
2547 l_serial_prefix VARCHAR2(30);
2548 l_fm_serial_suffix NUMBER;
2549 l_to_serial_suffix NUMBER;
2550 l_serial_suffix_length NUMBER := 0;
2551 x_error_code NUMBER;
2552 l_temp_num NUMBER;
2553 l_current_serial VARCHAR2(30);
2554 l_split_quantity NUMBER;
2555 l_split_quantity2 NUMBER := NULL;
2556 l_remaining_quantity NUMBER := p_quantity;
2557 l_remaining_qty_uom VARCHAR2(3) := p_uom_code;
2558 l_remaining_quantity2 NUMBER := p_secondary_trx_quantity;
2559 l_total_split_qty2 NUMBER := 0;
2560 qty2_remainder NUMBER := 0;
2561 l_done_with_range BOOLEAN := FALSE;
2562 l_loop_counter NUMBER := 0;
2563 l_demand_source_name NUMBER := NULL; --RTV 16197273
2564 l_demand_source_line_id NUMBER ; --RTV 16197273
2565
2566 BEGIN
2567 --initalizing l_InvPCInRecType to use for updating wdd with transaction_temp_id
2568 l_invpcinrectype.transaction_id := NULL;
2569 l_invpcinrectype.transaction_temp_id := NULL;
2570 l_invpcinrectype.source_code := 'INV';
2571 l_invpcinrectype.api_version_number := 1.0;
2572 --initalizing params for Delivery_Detail_Action
2573 l_action_prms.caller := 'WMS';
2574 l_action_prms.action_code := 'SPLIT-LINE';
2575 --initalizing params for Update_Shipping_Attributes
2576 l_shipping_attr(1).transfer_lpn_id := p_xfr_lpn_id;
2577 l_shipping_attr(1).action_flag := 'U';
2578
2579 IF (l_debug = 1) THEN
2580 inv_log_util.TRACE(l_api_name || ' Entered ' || g_pkg_version, l_api_name, 1);
2581 inv_log_util.TRACE('orgid='||p_organization_id||' lpn='||p_lpn_id||' xfrlpn='||p_xfr_lpn_id||' item='||p_item_rec.inventory_item_id||' rev='||p_revision||' lot='||p_lot_number, l_api_name, 9);
2582 inv_log_util.TRACE('sctl='||p_item_rec.serial_number_control_code||' qty='||p_quantity||' uom='||p_uom_code||' qty2='||p_secondary_trx_quantity||' uom2='||p_secondary_uom_code||' strxtmp='||p_serial_trx_temp_id, l_api_name, 4);
2583 inv_log_util.TRACE('xfrsub='||p_xfr_subinventory||' xfrloc='||p_xfr_to_location||' srcid='||p_transaction_source_id||' srcln='||p_trx_source_line_id, l_api_name, 4);
2584 END IF;
2585
2586 FOR dd_rec IN delivery_detail_cursor(p_lot_number) LOOP
2587 IF (l_debug = 1) THEN
2588 inv_log_util.TRACE('Got WDD: dd_id='||dd_rec.delivery_detail_id||' pckqty='||dd_rec.requested_quantity||' requom='||dd_rec.requested_quantity_uom||' sn='||dd_rec.serial_number||' trxtmpid='|| dd_rec.transaction_temp_id, l_api_name, 9);
2589 inv_log_util.TRACE('lpnddid='||dd_rec.lpn_detail_id||' pckqty2='||dd_rec.picked_quantity2||' requom2='||dd_rec.requested_quantity_uom2||' shdrid='||dd_rec.source_header_id||' slnid='||dd_rec.source_line_id, l_api_name, 9);
2590 inv_log_util.TRACE('remqty='||l_remaining_quantity||' remuom='||l_remaining_qty_uom, l_api_name, 9);
2591 END IF;
2592
2593 -- Check to see if there needs to be any serial handling
2594 IF (dd_rec.serial_number IS NOT NULL) THEN
2595 -- Only one serial in this line check to see if it is part of split.
2596 BEGIN
2597 SELECT 1
2598 INTO l_split_quantity
2599 FROM mtl_serial_numbers_temp
2600 WHERE transaction_temp_id = p_serial_trx_temp_id
2601 AND dd_rec.serial_number BETWEEN fm_serial_number AND NVL(to_serial_number, fm_serial_number)
2602 AND LENGTH(fm_serial_number) = LENGTH(dd_rec.serial_number)
2603 AND ROWNUM < 2;
2604 EXCEPTION
2605 WHEN NO_DATA_FOUND THEN
2606 l_split_quantity := 0;
2607 END;
2608 ELSIF(dd_rec.transaction_temp_id IS NOT NULL) THEN
2609 -- WDD lines have serials need to find the number of serial that need to be split
2610 OPEN del_serial_cursor(dd_rec.transaction_temp_id);
2611
2612 FETCH del_serial_cursor
2613 BULK COLLECT INTO ser_tbl;
2614
2615 l_split_quantity := ser_tbl.COUNT;
2616
2617 IF (l_debug = 1) THEN
2618 inv_log_util.TRACE('ser_tbl.COUNT=' || l_split_quantity, l_api_name, 9);
2619 END IF;
2620
2621 /*
2622 -In case there exist only one MSNT for complete range of serials.we hav one latent issue.
2623 The below code under split_delivery_details,which will split MSNT ,before calling Shipping.
2624 Actually shipping itself will take care of spliting MSNT and WDD.
2625 For normal Mobile split scenarios,we always have MSNT for each serial,hence didnt faced this problem till now.
2626 Hence skipping the logic for RTV,in order not to distrub the exisitng flows.
2627 Reference:16553521
2628
2629 */
2630
2631 IF (dd_rec.source_code <> 'RTV') THEN --Skipping the logic for RTV ER.
2632
2633
2634
2635 -- Is some split serials were found for this WDD. Otherwise bypass
2636 -- If not all serials in this detail are part of split. no need to split ranges
2637 IF (l_split_quantity > 0
2638 AND l_split_quantity < dd_rec.requested_quantity) THEN
2639
2640 SELECT mtl_material_transactions_s.NEXTVAL
2641 INTO l_invpcinrectype.transaction_temp_id
2642 FROM DUAL;
2643
2644 IF (l_debug = 1) THEN
2645 inv_log_util.TRACE('Created new trxtmpid=' || l_invpcinrectype.transaction_temp_id || ' ser_tbl.count=' || l_split_quantity
2646 , l_api_name, 9);
2647 END IF;
2648
2649 l_shipping_attr(1).serial_number := NULL;
2650
2651
2652 l_new_fm_serial := ser_tbl(1);
2653 l_new_to_serial := ser_tbl(1);
2654 l_tbl_cnt := 1;
2655
2656 FOR wdd_ser_rec IN wdd_ser_cur(dd_rec.transaction_temp_id, l_new_fm_serial) LOOP
2657 -- If a serial exists in this range of serials from WDD
2658 -- Go through each SN until it is beyond the rec range or not contiguous
2659 IF (l_new_fm_serial <= wdd_ser_rec.to_serial_number) THEN
2660 LOOP
2661 l_tbl_cnt := l_tbl_cnt + 1;
2662
2663 IF (l_tbl_cnt <= ser_tbl.COUNT) THEN
2664 l_current_serial := ser_tbl(l_tbl_cnt);
2665 END IF;
2666
2667 IF (l_debug = 1) THEN
2668 inv_log_util.TRACE('Got new sn='||l_current_serial||' nfmsn='||l_new_fm_serial||' ntosn='||l_new_to_serial||' wfmsn='||wdd_ser_rec.fm_serial_number||' wtosn='||wdd_ser_rec.to_serial_number, l_api_name, 9);
2669 END IF;
2670
2671 -- If the the to and from serials consume the whole range from MSNT
2672 -- or the current serial is outside the range, We are done with the MSNT
2673 -- line and can bypass parsing the serials
2674 IF (
2675 l_current_serial > wdd_ser_rec.to_serial_number
2676 OR(l_new_fm_serial = wdd_ser_rec.fm_serial_number
2677 AND l_new_to_serial = wdd_ser_rec.to_serial_number)
2678 ) THEN
2679 -- Current serial is not in the this MSNT line
2680 l_done_with_range := TRUE;
2681 ELSE -- Serial still within serial range. See if it is contiguous
2682 IF (l_serial_prefix IS NULL) THEN
2683 l_serial_def_flag :=
2684 mtl_serial_check.inv_serial_info(l_new_fm_serial, l_new_fm_serial, l_serial_prefix, l_temp_num, l_fm_serial_suffix
2685 , l_to_serial_suffix, x_error_code);
2686
2687 IF (x_error_code <> 0) THEN
2688 IF (l_debug = 1) THEN
2689 inv_log_util.TRACE('Failed MTL_SERIAL_CHECK.Inv_Serial_Info', l_api_name, 1);
2690 END IF;
2691
2692 fnd_message.set_name('WMS', 'WMS_CONT_INVALID_SER');
2693 fnd_msg_pub.ADD;
2694 RAISE fnd_api.g_exc_error;
2695 END IF;
2696
2697 -- calculate the length of the serial number suffix
2698 --l_serial_suffix_length := LENGTH(l_new_fm_serial) - LENGTH(l_serial_prefix);
2699 l_serial_suffix_length := LENGTH(l_new_fm_serial) - NVL(LENGTH(l_serial_prefix), 0);
2700 /* 3406810 */
2701 l_to_serial_suffix := l_to_serial_suffix + 1;
2702
2703 IF (l_debug = 1) THEN
2704 inv_log_util.TRACE('New prefix='||l_serial_prefix||' suffix='||l_fm_serial_suffix||' sfxlgth='||l_serial_suffix_length, l_api_name, 1);
2705 END IF;
2706 END IF;
2707
2708 -- Check if Serial is contiguous. If so, make current serial the new to_serial
2709 IF (l_current_serial = l_serial_prefix || LPAD(TO_CHAR(l_to_serial_suffix), l_serial_suffix_length, '0')) THEN
2710 l_to_serial_suffix := l_to_serial_suffix + 1;
2711 l_new_to_serial := l_current_serial;
2712 ELSE -- Serial is not contiguous. Range is done.
2713 l_done_with_range := TRUE;
2714 END IF;
2715 END IF;
2716
2717 IF (l_done_with_range) THEN
2718 -- If we are done with the range separate it from the rest
2719 IF (l_new_fm_serial = wdd_ser_rec.fm_serial_number
2720 AND l_new_to_serial = wdd_ser_rec.to_serial_number) THEN
2721 -- Whole serial range in wdd is part of split.
2722 IF (l_invpcinrectype.transaction_temp_id IS NOT NULL) THEN
2723 -- More than one serial to be put new temp id on it
2724 UPDATE mtl_serial_numbers_temp
2725 SET transaction_temp_id = l_invpcinrectype.transaction_temp_id
2726 WHERE ROWID = wdd_ser_rec.ROWID;
2727 ELSE
2728 -- Single serial being split, remove record from MSNT
2729 DELETE FROM mtl_serial_numbers_temp
2730 WHERE ROWID = wdd_ser_rec.ROWID;
2731 END IF;
2732 ELSE -- Create records for the new serial sub ranges
2733 -- If not a single serial being split, create an new MSNT line for new split WDD line
2734 IF (l_invpcinrectype.transaction_temp_id IS NOT NULL) THEN
2735 copy_msnt(
2736 p_source_row_id => wdd_ser_rec.ROWID
2737 , p_new_sertrxid => l_invpcinrectype.transaction_temp_id
2738 , p_new_fm_serial => l_new_fm_serial
2739 , p_new_to_serial => l_new_to_serial
2740 );
2741 END IF;
2742
2743 --Update the delivery's msnt line with the non split ranges
2744 IF (l_new_fm_serial > wdd_ser_rec.fm_serial_number) THEN
2745 --If split serial range came from the middle of the delivery range,
2746 --a new msnt line needs to be created to represent the second half
2747 -- of the unsplit wdd serials.
2748 IF (l_new_to_serial < wdd_ser_rec.to_serial_number) THEN
2749 copy_msnt(
2750 p_source_row_id => wdd_ser_rec.ROWID
2751 , p_new_sertrxid => dd_rec.transaction_temp_id
2752 , p_new_fm_serial => l_serial_prefix || LPAD(l_to_serial_suffix, l_serial_suffix_length, '0')
2753 , p_new_to_serial => wdd_ser_rec.to_serial_number
2754 );
2755 END IF;
2756
2757 --Update the to serial one less than the beginning of the split serial range
2758 wdd_ser_rec.to_serial_number := l_serial_prefix || LPAD(l_fm_serial_suffix - 1, l_serial_suffix_length, '0');
2759
2760 UPDATE mtl_serial_numbers_temp
2761 SET to_serial_number = wdd_ser_rec.to_serial_number
2762 WHERE ROWID = wdd_ser_rec.ROWID;
2763 ELSIF(l_new_to_serial < wdd_ser_rec.to_serial_number) THEN
2764 --Update the from serial one greater than the end of the split serial range
2765 wdd_ser_rec.fm_serial_number := l_serial_prefix || LPAD(l_to_serial_suffix, l_serial_suffix_length, '0');
2766
2767 UPDATE mtl_serial_numbers_temp
2768 SET fm_serial_number = wdd_ser_rec.fm_serial_number
2769 WHERE ROWID = wdd_ser_rec.ROWID;
2770 END IF;
2771 END IF;
2772
2773 -- Finished processing range, reset params
2774 l_new_fm_serial := l_current_serial;
2775 l_new_to_serial := l_current_serial;
2776 l_serial_prefix := NULL;
2777 l_done_with_range := FALSE;
2778 END IF;
2779
2780 EXIT WHEN l_tbl_cnt > ser_tbl.COUNT
2781 OR l_current_serial > wdd_ser_rec.to_serial_number;
2782 END LOOP;
2783 END IF; -- Done finding all the serials for this WDD-MSNT line
2784
2785 EXIT WHEN l_tbl_cnt > ser_tbl.COUNT;
2786 END LOOP;
2787
2788 --Call shipping api to set transaction_temp_id global variable
2789 IF (l_debug = 1) THEN
2790 inv_log_util.TRACE('Calling Set_Inv_PC_Attributes transaction_temp_id=' || l_invpcinrectype.transaction_temp_id, l_api_name);
2791 END IF;
2792
2793 wsh_integration.set_inv_pc_attributes(p_in_attributes => l_invpcinrectype, x_return_status => ret_status
2794 , x_msg_count => ret_msgcnt, x_msg_data => ret_msgdata);
2795
2796 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2797 IF (l_debug = 1) THEN
2798 inv_log_util.TRACE('return error from Set_Inv_PC_Attributes', l_api_name);
2799 END IF;
2800
2801 RAISE fnd_api.g_exc_error;
2802 END IF;
2803 END IF;
2804
2805 END IF ;--dd_rec.source_code <> 'RTV'
2806
2807
2808 -- End of serial number handling code
2809 CLOSE del_serial_cursor;
2810
2811 -- Convert split quantity from primary UOM into the UOM of the WDD line if different
2812 IF (p_uom_code <> dd_rec.requested_quantity_uom) THEN
2813 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
2814 l_split_quantity :=
2815 inv_convert.inv_um_convert(p_item_rec.inventory_item_id,p_lot_number,p_organization_id, 5, l_split_quantity, p_uom_code, dd_rec.requested_quantity_uom, NULL
2816 , NULL);
2817
2818 IF (l_remaining_quantity < 0) THEN
2819 fnd_message.set_name('INV', 'INV_UOM_CONVERSION_ERROR');
2820 fnd_message.set_token('uom1', p_uom_code);
2821 fnd_message.set_token('uom2', dd_rec.requested_quantity_uom);
2822 fnd_message.set_token('module', l_api_name);
2823 fnd_msg_pub.ADD;
2824 RAISE fnd_api.g_exc_error;
2825 END IF;
2826 END IF;
2827 ELSE -- Not serial controlled
2828 l_split_quantity := dd_rec.requested_quantity;
2829 END IF;
2830
2831 IF (l_split_quantity > 0) THEN
2832 IF (l_remaining_qty_uom <> dd_rec.requested_quantity_uom) THEN
2833 -- convert remaining quantity into the UOM of the WDD line
2834 ----bug 8526601 added lot number and org id to make the inv_convert call lot specific
2835 l_remaining_quantity :=
2836 inv_convert.inv_um_convert(p_item_rec.inventory_item_id,p_lot_number,p_organization_id, 5, l_remaining_quantity, l_remaining_qty_uom
2837 , dd_rec.requested_quantity_uom, NULL, NULL);
2838
2839 IF (l_remaining_quantity < 0) THEN
2840 fnd_message.set_name('INV', 'INV_UOM_CONVERSION_ERROR');
2841 fnd_message.set_token('uom1', l_remaining_qty_uom);
2842 fnd_message.set_token('uom2', dd_rec.requested_quantity_uom);
2843 fnd_message.set_token('module', l_api_name);
2844 fnd_msg_pub.ADD;
2845 RAISE fnd_api.g_exc_error;
2846 END IF;
2847
2848 l_remaining_qty_uom := dd_rec.requested_quantity_uom;
2849 END IF;
2850
2851 --12432643
2852 IF (l_debug = 1) THEN
2853 inv_log_util.TRACE('l_split_quantity: '||l_split_quantity, l_api_name);
2854 inv_log_util.TRACE('l_remaining_quantity: '||l_remaining_quantity, l_api_name);
2855 END IF;
2856 --12432643
2857
2858
2859 IF ((l_remaining_quantity < dd_rec.requested_quantity) AND dd_rec.transaction_temp_id IS NULL ) THEN --12432643
2860 l_split_quantity := ROUND(l_remaining_quantity, g_precision);
2861 ELSE -- need to round split qty
2862 l_split_quantity := ROUND(l_split_quantity, g_precision);
2863 END IF;
2864 --12432643
2865 IF (l_debug = 1) THEN
2866 inv_log_util.TRACE('l_split_quantity: '||l_split_quantity, l_api_name);
2867 END IF;
2868 --12432643
2869
2870 IF (l_remaining_quantity2 > 0) THEN
2871 IF (dd_rec.picked_quantity2 IS NULL) THEN
2872 -- If the from lpn has items without catch weights defined, must null
2873 -- secondary quantity and uom for all WDD records for this lpn
2874 l_remaining_quantity2 := 0;
2875 ELSIF(dd_rec.requested_quantity_uom2 <> p_secondary_uom_code) THEN
2876 -- Sanity check to make sure that we are transacting in the same UOM
2877 fnd_message.set_name('WMS', 'WMS_SEC_UOM_MISMATCH_ERROR');
2878 fnd_message.set_token('UOM1', p_secondary_uom_code);
2879 fnd_message.set_token('UOM2', dd_rec.requested_quantity_uom2);
2880 fnd_msg_pub.ADD;
2881 RAISE fnd_api.g_exc_unexpected_error;
2882 ELSE
2883 -- Everything checks out determine the amount of qty2 to split
2884 -- Calculate the theoretical proportionate quantity2 to be split
2885 --l_split_quantity2 := p_secondary_trx_quantity*dd_rec.requested_quantity/p_quantity;
2886 l_split_quantity2 := l_remaining_quantity2 * l_split_quantity / l_remaining_quantity;
2887 l_remaining_quantity2 := l_remaining_quantity2 - l_split_quantity2;
2888 -- Keep track of the total quantity2 removed from soruce LPN
2889 l_total_split_qty2 := l_total_split_qty2 + LEAST(dd_rec.picked_quantity2, l_split_quantity2);
2890
2891 IF (l_split_quantity = dd_rec.requested_quantity) THEN
2892 -- Whole WDD line will be split. Add record to table type to update catch weights
2893 l_del_det_attr(l_dd_ct).delivery_detail_id := dd_rec.delivery_detail_id;
2894 l_del_det_attr(l_dd_ct).picked_quantity2 := l_split_quantity2;
2895 l_del_det_attr(l_dd_ct).requested_quantity_uom2 := p_secondary_uom_code;
2896 l_dd_ct := l_dd_ct + 1;
2897 END IF;
2898
2899 IF (l_debug = 1) THEN
2900 inv_log_util.TRACE(
2901 'new split_qty2=' || l_split_quantity2 || ' rem_qty2=' || l_remaining_quantity2 || ' splitfmqty=' || l_total_split_qty2
2902 , l_api_name
2903 , 9
2904 );
2905 END IF;
2906 END IF;
2907 END IF;
2908
2909 IF (l_split_quantity = ROUND(dd_rec.requested_quantity, g_precision)) THEN
2910 -- Disassociate existing delivery line with old lpn
2911 l_shipping_attr(1).delivery_detail_id := dd_rec.delivery_detail_id;
2912 ELSIF(l_split_quantity < dd_rec.requested_quantity) THEN
2913 -- We need only part of this WDD line need to split it
2914 l_detail_id_tab(1) := dd_rec.delivery_detail_id;
2915 l_action_prms.split_quantity := l_split_quantity;
2916 l_action_prms.split_quantity2 := LEAST(dd_rec.picked_quantity2, l_split_quantity2);
2917
2918 -- Call new Shipping API to split line
2919 IF (l_debug = 1) THEN
2920 inv_log_util.TRACE('Calling Delivery_Detail_Action ddid='||l_detail_id_tab(1)||' qty='||l_action_prms.split_quantity||' qty2='||l_action_prms.split_quantity2, l_api_name, 1);
2921 END IF;
2922
2923 wsh_interface_ext_grp.delivery_detail_action(
2924 p_api_version_number => 1.0
2925 , p_init_msg_list => fnd_api.g_false
2926 , p_commit => fnd_api.g_false
2927 , x_return_status => ret_status
2928 , x_msg_count => ret_msgcnt
2929 , x_msg_data => ret_msgdata
2930 , p_detail_id_tab => l_detail_id_tab
2931 , p_action_prms => l_action_prms
2932 , x_action_out_rec => l_action_out_rec
2933 );
2934
2935 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2936 IF (l_debug = 1) THEN
2937 inv_log_util.TRACE('**Error Delivery_Detail_Action: ' || ret_msgdata, l_api_name, 1);
2938 END IF;
2939
2940 fnd_message.set_name('INV', 'INV_SPLIT_LINE_FAILURE');
2941 fnd_msg_pub.ADD;
2942 RAISE fnd_api.g_exc_error;
2943 END IF;
2944
2945 l_shipping_attr(1).delivery_detail_id := l_action_out_rec.result_id_tab(1);
2946
2947 IF (l_debug = 1) THEN
2948 inv_log_util.TRACE('Created new delivery line: dd_id=' || l_shipping_attr(1).delivery_detail_id, l_api_name, 9);
2949 END IF;
2950 ELSE -- Split qty is > dd_rec.delivery_detail_id logic error;
2951 IF (l_debug = 1) THEN
2952 inv_log_util.TRACE('Split qty ' || l_split_quantity || ' is greater than what is available on WDD '
2953 || dd_rec.delivery_detail_id, l_api_name, 9);
2954 END IF;
2955
2956 RAISE fnd_api.g_exc_unexpected_error;
2957 END IF;
2958
2959 IF (l_debug = 1) THEN
2960 inv_log_util.TRACE('Call to WSH Delivery_Detail_Action unassign delivery from lpn', l_api_name, 4);
2961 END IF;
2962
2963 l_wsh_action_prms.caller := 'WMS';
2964 l_wsh_action_prms.action_code := 'UNPACK';
2965 l_wsh_del_det_id_tbl(1) := l_shipping_attr(1).delivery_detail_id;
2966
2967 WSH_WMS_LPN_GRP.Delivery_Detail_Action (
2968 p_api_version_number => 1.0
2969 , p_init_msg_list => fnd_api.g_false
2970 , p_commit => fnd_api.g_false
2971 , x_return_status => ret_status
2972 , x_msg_count => ret_msgcnt
2973 , x_msg_data => ret_msgdata
2974 , p_lpn_id_tbl => l_wsh_lpn_id_tbl
2975 , p_del_det_id_tbl => l_wsh_del_det_id_tbl
2976 , p_action_prms => l_wsh_action_prms
2977 , x_defaults => l_wsh_defaults
2978 , x_action_out_rec => l_wsh_action_out_rec );
2979
2980 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
2981 IF (l_debug = 1) THEN
2982 inv_log_util.TRACE('Error WSH_WMS_LPN_GRP.Delivery_Detail_Action' || ret_status, l_api_name, 1);
2983 END IF;
2984
2985 fnd_message.set_name('INV', 'INV_UNASSIGN_DEL_FAILURE');
2986 fnd_msg_pub.ADD;
2987 RAISE fnd_api.g_exc_error;
2988 ELSIF (l_debug = 1) THEN
2989 inv_log_util.TRACE('Done with call to WSH Create_Update_Containers', l_api_name, 4);
2990 END IF;
2991
2992 --Associate New Delivery Line with transfer LPN
2993 IF (p_xfr_subinventory IS NOT NULL) THEN
2994 IF (l_debug = 1) THEN
2995 inv_log_util.TRACE('Replacing sub: ' || l_shipping_attr(1).subinventory || ' with xfr sub: ' || p_xfr_subinventory, l_api_name
2996 , 9);
2997 END IF;
2998
2999 l_shipping_attr(1).subinventory := p_xfr_subinventory;
3000 END IF;
3001
3002 IF (p_xfr_to_location <> 0) THEN
3003 IF (l_debug = 1) THEN
3004 inv_log_util.TRACE('Replacing loc: ' || l_shipping_attr(1).locator_id || ' with xfr loc: ' || p_xfr_to_location, l_api_name, 9);
3005 END IF;
3006
3007 l_shipping_attr(1).locator_id := p_xfr_to_location;
3008 END IF;
3009
3010 -- Bug 3386829: Need to repopualte the picked quantity for shipping api
3011 l_shipping_attr(1).picked_quantity := l_split_quantity;
3012 l_shipping_attr(1).picked_quantity2 := l_split_quantity2;
3013 wsh_interface.update_shipping_attributes(p_source_code => 'INV', p_changed_attributes => l_shipping_attr
3014 , x_return_status => ret_status);
3015
3016 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3017 IF (l_debug = 1) THEN
3018 inv_log_util.TRACE('***Error in update shipping attribures for split trx', l_api_name, 9);
3019 END IF;
3020
3021 fnd_message.set_name('WMS', 'WMS_TD_UPD_SHP_ERROR');
3022 fnd_msg_pub.ADD;
3023 RAISE fnd_api.g_exc_error;
3024 END IF;
3025
3026 -- Need to also to transfer the item reservation
3027 IF (l_debug = 1) THEN
3028 inv_log_util.TRACE('Calling Upd_Reservation_PUP_New qty='||l_split_quantity||' uom='||dd_rec.requested_quantity_uom, l_api_name, 9);
3029 END IF;
3030 l_loop_counter := l_loop_counter + 1;
3031
3032 --16197273
3033 IF (l_debug = 1) THEN
3034 inv_log_util.TRACE('RTV ER Changes:Passing demand source name to fetch MR for Return order::'||dd_rec.source_header_id, l_api_name, 9);
3035 END IF;
3036
3037 IF (dd_rec.source_code = 'RTV') THEN
3038
3039 l_demand_source_name := dd_rec.source_header_id ;
3040 l_demand_source_line_id := NULL ;
3041
3042 ELSE
3043
3044 l_demand_source_line_id := dd_rec.source_line_id ;
3045
3046 END IF ;
3047
3048 --16197273
3049
3050 INV_RESERVATION_PVT.Upd_Reservation_PUP_New (
3051 x_return_status => ret_status
3052 , x_msg_count => ret_msgcnt
3053 , x_msg_data => ret_msgdata
3054 , p_organization_id => p_organization_id
3055 , p_demand_source_header_id => dd_rec.source_header_id
3056 , p_demand_source_line_id => l_demand_source_line_id
3057 , p_from_subinventory_code => p_subinventory_code
3058 , p_from_locator_id => p_locator_id
3059 , p_to_subinventory_code => NVL(p_xfr_subinventory, p_subinventory_code)
3060 , p_to_locator_id => NVL(p_xfr_to_location, p_locator_id)
3061 , p_inventory_item_id => p_item_rec.inventory_item_id
3062 , p_revision => p_revision
3063 , p_lot_number => p_lot_number
3064 , p_quantity => l_split_quantity
3065 , p_uom => dd_rec.requested_quantity_uom
3066 , p_lpn_id => p_xfr_lpn_id
3067 , p_force_reservation_flag => fnd_api.g_true
3068 , p_requirement_date => (Sysdate + l_loop_counter/(24*3600))
3069 , p_source_lpn_id => p_lpn_id
3070 ,p_demand_source_name => l_demand_source_name);
3071
3072 IF ( ret_status <> fnd_api.g_ret_sts_success ) THEN
3073 IF (l_debug = 1) THEN
3074 inv_log_util.TRACE('upd_reservation_pup failed '||ret_msgdata, l_api_name, 1);
3075 END IF;
3076 fnd_message.set_name('WMS', 'UPD_RESERVATION_PUP_FAIL');
3077 fnd_msg_pub.ADD;
3078 RAISE fnd_api.g_exc_error;
3079 END IF;
3080 l_progress := 'Done with call to Upd_Reservation_PUP_New';
3081
3082 -- Subtract the split quantity from the remaining quantity
3083 l_remaining_quantity := l_remaining_quantity - l_split_quantity;
3084
3085 IF (l_debug = 1) THEN
3086 inv_log_util.TRACE(
3087 'Assoc new line remqty=' || l_remaining_quantity || ' remqty2=' || l_remaining_quantity2 || ' tsplt2=' || l_total_split_qty2
3088 , l_api_name
3089 , 9
3090 );
3091 END IF;
3092 END IF; -- l_split_quantity > 0
3093
3094 EXIT WHEN ROUND(l_remaining_quantity, g_precision) <= 0;
3095 END LOOP;
3096
3097 IF (l_remaining_quantity > 0) THEN
3098 inv_log_util.TRACE('***Error while splittng delivery not enough quantity found in wdd', l_api_name, 1);
3099 fnd_message.set_name('WMS', 'INV_INSUFFICIENT_WDD_QTY');
3100 fnd_msg_pub.ADD;
3101 RAISE fnd_api.g_exc_error;
3102 END IF;
3103
3104 IF (p_secondary_trx_quantity IS NOT NULL) THEN
3105 -- We have consumed all of the primary quantity. Calculate the amount of qty2
3106 -- That needs to be added back or removed from soruce LPN.
3107 qty2_remainder := p_secondary_trx_quantity - l_total_split_qty2;
3108
3109 IF (l_debug = 1) THEN
3110 inv_log_util.TRACE('qty2_remainder=' || qty2_remainder, l_api_name, 9);
3111 END IF;
3112
3113 IF (qty2_remainder <> 0) THEN
3114 OPEN delivery_detail_cursor(p_lot_number);
3115
3116 FETCH delivery_detail_cursor
3117 INTO l_dd_rec;
3118
3119 IF (delivery_detail_cursor%FOUND
3120 AND l_dd_rec.picked_quantity2 IS NOT NULL) THEN
3121 WHILE(delivery_detail_cursor%FOUND) LOOP
3122 IF (l_debug = 1) THEN
3123 inv_log_util.TRACE(
3124 'Got WDD: dd_id='
3125 || l_dd_rec.delivery_detail_id
3126 || ' pkqty='
3127 || l_dd_rec.requested_quantity
3128 || ' requom='
3129 || l_dd_rec.requested_quantity_uom
3130 || ' sn='
3131 || l_dd_rec.serial_number
3132 || ' txtmpid='
3133 || l_dd_rec.transaction_temp_id
3134 , l_api_name
3135 , 9
3136 );
3137 inv_log_util.TRACE(
3138 'lpnddid='
3139 || l_dd_rec.lpn_detail_id
3140 || ' pckqty2='
3141 || l_dd_rec.picked_quantity2
3142 || ' requom2='
3143 || l_dd_rec.requested_quantity_uom2
3144 || ' remqty='
3145 || l_remaining_quantity
3146 || ' remuom='
3147 || l_remaining_qty_uom
3148 , l_api_name
3149 , 9
3150 );
3151 END IF;
3152
3153 IF (l_dd_rec.requested_quantity_uom2 <> p_secondary_uom_code) THEN
3154 -- Sanity check to make sure that we are transacting in the same UOM
3155 fnd_message.set_name('WMS', 'WMS_SEC_UOM_MISMATCH_ERROR');
3156 fnd_message.set_token('UOM1', p_secondary_uom_code);
3157 fnd_message.set_token('UOM2', l_dd_rec.requested_quantity_uom2);
3158 fnd_msg_pub.ADD;
3159 RAISE fnd_api.g_exc_unexpected_error;
3160 ELSIF(l_dd_rec.picked_quantity2 > qty2_remainder) THEN
3161 -- This WDD record can consume the entire remaining qty. subtract that
3162 -- amount from the line and set remaining to zero
3163 l_del_det_attr(l_dd_ct).picked_quantity2 := l_dd_rec.picked_quantity2 - qty2_remainder;
3164 l_del_det_attr(l_dd_ct).delivery_detail_id := l_dd_rec.delivery_detail_id;
3165 l_del_det_attr(l_dd_ct).requested_quantity_uom2 := p_secondary_uom_code;
3166 l_dd_ct := l_dd_ct + 1;
3167 qty2_remainder := 0;
3168 ELSIF(l_dd_rec.picked_quantity2 <> 0) THEN
3169 -- This WDD record cannot consume the entire remaining qty. consume all
3170 -- of the qty2 and subtract the amount from the total remaining
3171 l_del_det_attr(l_dd_ct).picked_quantity2 := 0;
3172 l_del_det_attr(l_dd_ct).delivery_detail_id := l_dd_rec.delivery_detail_id;
3173 l_del_det_attr(l_dd_ct).requested_quantity_uom2 := p_secondary_uom_code;
3174 l_dd_ct := l_dd_ct + 1;
3175 qty2_remainder := qty2_remainder - l_dd_rec.picked_quantity2;
3176 END IF;
3177
3178 IF (l_debug = 1) THEN
3179 inv_log_util.TRACE('new qty2_remainder=' || qty2_remainder, l_api_name, 9);
3180 END IF;
3181
3182 FETCH delivery_detail_cursor
3183 INTO l_dd_rec;
3184 END LOOP;
3185
3186 IF (qty2_remainder <> 0) THEN
3187 inv_log_util.TRACE('***Error while splittng delivery not enough quantity2 found in wdd', l_api_name, 9);
3188 fnd_message.set_name('WMS', 'INV_INSUFFICIENT_WDD_QTY');
3189 fnd_msg_pub.ADD;
3190 RAISE fnd_api.g_exc_error;
3191 END IF;
3192 ELSIF(l_debug = 1) THEN
3193 inv_log_util.TRACE('no WDD rows left in source lpn...ok', l_api_name, 9);
3194 END IF;
3195
3196 CLOSE delivery_detail_cursor;
3197 END IF;
3198 END IF;
3199
3200 -- For catch weights update delivery lines with
3201 IF (l_del_det_attr.COUNT > 0) THEN
3202 l_del_det_in_rec.caller := 'WMS';
3203 l_del_det_in_rec.action_code := 'UPDATE';
3204
3205 IF (l_debug = 1) THEN
3206 inv_log_util.TRACE('Calling Create_Update_Delivery_Detail count=' || l_del_det_attr.COUNT, l_api_name, 9);
3207 END IF;
3208
3209 wsh_interface_ext_grp.create_update_delivery_detail(
3210 p_api_version_number => 1.0
3211 , p_init_msg_list => fnd_api.g_false
3212 , p_commit => fnd_api.g_false
3213 , x_return_status => ret_status
3214 , x_msg_count => ret_msgcnt
3215 , x_msg_data => ret_msgdata
3216 , p_detail_info_tab => l_del_det_attr
3217 , p_in_rec => l_del_det_in_rec
3218 , x_out_rec => l_del_det_out_rec
3219 );
3220
3221 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3222 --Get error messages from shipping
3223 wsh_util_core.get_messages('Y', ret_msgdata, l_msg_details, ret_msgcnt);
3224
3225 IF (ret_msgcnt > 1) THEN
3226 ret_msgdata := ret_msgdata || l_msg_details;
3227 END IF;
3228
3229 IF (l_debug = 1) THEN
3230 inv_log_util.TRACE('Error calling Create_Update_Delivery_Detail: ' || ret_msgdata, l_api_name, 1);
3231 END IF;
3232
3233 fnd_message.set_name('WMS', 'WMS_UPD_DELIVERY_ERROR');
3234 fnd_message.set_token('MSG1', ret_msgdata);
3235 fnd_msg_pub.ADD;
3236 RAISE fnd_api.g_exc_unexpected_error;
3237 END IF;
3238 END IF;
3239 END split_delivery_details;
3240
3241 PROCEDURE split_delivery(
3242 p_tempid NUMBER
3243 , p_lpn_id NUMBER
3244 , p_xfr_lpn_id NUMBER
3245 , p_item_rec inv_validate.item
3246 , p_revision VARCHAR2
3247 , p_qty NUMBER
3248 , p_uom VARCHAR2
3249 , p_secondary_trx_quantity NUMBER := NULL
3250 , p_secondary_uom_code VARCHAR2 := NULL
3251 , p_org_id NUMBER
3252 , p_subinventory_code VARCHAR2
3253 , p_locator_id NUMBER
3254 , p_xfr_subinventory VARCHAR2 := NULL
3255 , p_xfr_to_location NUMBER := NULL
3256 , p_transaction_source_id NUMBER := NULL
3257 , p_trx_source_line_id NUMBER := NULL
3258 ) IS
3259 l_api_name CONSTANT VARCHAR2(30) := 'Split_Delivery';
3260 l_api_version CONSTANT NUMBER := 1.0;
3261 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3262 l_progress VARCHAR2(10) := '0';
3263 l_lotfound BOOLEAN := FALSE;
3264 l_prev_lot VARCHAR2(30) := -999;
3265 l_secondary_trx_quantity NUMBER := p_secondary_trx_quantity;
3266 l_secondary_uom_code VARCHAR2(3) := p_secondary_uom_code;
3267 l_pricing_ind VARCHAR2(30);
3268 l_valid_sec_qty_split NUMBER;
3269 l_tracking_quantity_ind VARCHAR2(5); -- 16493898
3270
3271 CURSOR lottmp_cur IS
3272 SELECT lot_number
3273 , primary_quantity
3274 , serial_transaction_temp_id
3275 , secondary_quantity
3276 , secondary_unit_of_measure
3277 FROM mtl_transaction_lots_temp
3278 WHERE transaction_temp_id = p_tempid
3279 ORDER BY lot_number;
3280 BEGIN
3281 -- Check if pricing is tracked by secondary qty
3282 l_pricing_ind :=
3283 wms_catch_weight_pvt.get_ont_pricing_qty_source(
3284 p_api_version => 1.0
3285 , x_return_status => ret_status
3286 , x_msg_count => ret_msgcnt
3287 , x_msg_data => ret_msgdata
3288 , p_organization_id => p_org_id
3289 , p_inventory_item_id => p_item_rec.inventory_item_id
3290 );
3291
3292 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3293 fnd_message.set_name('INV', 'WMS_GET_CATCH_WEIGHT_ATT_FAIL');
3294 fnd_msg_pub.ADD;
3295 RAISE fnd_api.g_exc_unexpected_error;
3296 END IF;
3297
3298 -- 16493898 start
3299 SELECT tracking_quantity_ind
3300 INTO l_tracking_quantity_ind
3301 FROM mtl_system_items_b
3302 WHERE organization_id = p_org_id
3303 AND inventory_item_id = p_item_rec.inventory_item_id;
3304 -- 16493898 end
3305
3306 -- retrieve corresponding lot numbers
3307 FOR lottmp_rec IN lottmp_cur LOOP
3308 l_lotfound := TRUE;
3309
3310 IF l_tracking_quantity_ind = 'P' THEN -- 16493898
3311 IF (l_pricing_ind = wms_catch_weight_pvt.g_price_secondary) THEN
3312 IF (l_prev_lot <> lottmp_rec.lot_number) THEN
3313 l_prev_lot := lottmp_rec.lot_number;
3314 wms_catch_weight_pvt.show_ct_wt_for_split(
3315 x_return_status => ret_status
3316 , x_msg_data => ret_msgcnt
3317 , x_msg_count => ret_msgdata
3318 , p_org_id => p_org_id
3319 , p_from_lpn_id => p_lpn_id
3320 , p_from_item_id => p_item_rec.inventory_item_id
3321 , p_from_item_revision => p_revision
3322 , p_from_item_lot_number => lottmp_rec.lot_number
3323 , p_to_lpn_id => p_xfr_lpn_id
3324 , x_show_ct_wt => l_valid_sec_qty_split
3325 );
3326
3327 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3328 fnd_message.set_name('INV', 'WMS_GET_CATCH_WEIGHT_ATT_FAIL');
3329 fnd_msg_pub.ADD;
3330 RAISE fnd_api.g_exc_unexpected_error;
3331 END IF;
3332
3333 IF (l_debug = 1) THEN
3334 inv_log_util.TRACE('l_valid_sec_qty_split=' || l_valid_sec_qty_split, l_api_name, 9);
3335 END IF;
3336
3337 IF (l_valid_sec_qty_split <> 1) THEN
3338 --Clear the secondary quantity fields for the from LPN
3339 wms_catch_weight_pvt.update_lpn_secondary_quantity(
3340 p_api_version => 1.0
3341 , x_return_status => ret_status
3342 , x_msg_count => ret_msgcnt
3343 , x_msg_data => ret_msgdata
3344 , p_record_source => 'WDD'
3345 , p_organization_id => p_org_id
3346 , p_lpn_id => p_lpn_id
3347 , p_inventory_item_id => p_item_rec.inventory_item_id
3348 , p_revision => p_revision
3349 , p_lot_number => lottmp_rec.lot_number
3350 , p_quantity => NULL
3351 , p_uom_code => NULL
3352 , p_secondary_quantity => NULL
3353 , p_secondary_uom_code => NULL
3354 );
3355
3356 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3357 IF (l_debug = 1) THEN
3358 inv_log_util.TRACE('Error calling Update_LPN_Secondary_Quantity: ' || ret_msgdata, l_api_name, 1);
3359 END IF;
3360
3361 RAISE fnd_api.g_exc_unexpected_error;
3362 END IF;
3363
3364 --Clear the secondary quantity fields for the to LPN
3365 wms_catch_weight_pvt.update_lpn_secondary_quantity(
3366 p_api_version => 1.0
3367 , x_return_status => ret_status
3368 , x_msg_count => ret_msgcnt
3369 , x_msg_data => ret_msgdata
3370 , p_record_source => 'WDD'
3371 , p_organization_id => p_org_id
3372 , p_lpn_id => p_xfr_lpn_id
3373 , p_inventory_item_id => p_item_rec.inventory_item_id
3374 , p_revision => p_revision
3375 , p_lot_number => lottmp_rec.lot_number
3376 , p_quantity => NULL
3377 , p_uom_code => NULL
3378 , p_secondary_quantity => NULL
3379 , p_secondary_uom_code => NULL
3380 );
3381
3382 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3383 IF (l_debug = 1) THEN
3384 inv_log_util.TRACE('Error calling Update_LPN_Secondary_Quantity: ' || ret_msgdata, l_api_name, 1);
3385 END IF;
3386
3387 RAISE fnd_api.g_exc_unexpected_error;
3388 END IF;
3389 END IF;
3390 END IF;
3391
3392 -- Secondary quantities are not allowed do not pass it to
3393 -- the Split_Delivery_Details API
3394 IF (l_valid_sec_qty_split <> 1) THEN
3395 lottmp_rec.secondary_quantity := NULL;
3396 lottmp_rec.secondary_unit_of_measure := NULL;
3397 END IF;
3398 ELSIF(lottmp_rec.secondary_quantity IS NOT NULL) THEN
3399 -- secondary qty populated even though item is not catch weight
3400 -- enabled. Do not pass values to split delivery details api
3401 lottmp_rec.secondary_quantity := NULL;
3402 lottmp_rec.secondary_unit_of_measure := NULL;
3403 END IF;
3404 END IF ; -- 16493898
3405
3406 -- Call Split_Delivery_Details API for each lot
3407 split_delivery_details(
3408 p_organization_id => p_org_id
3409 , p_lpn_id => p_lpn_id
3410 , p_xfr_lpn_id => p_xfr_lpn_id
3411 , p_item_rec => p_item_rec
3412 , p_revision => p_revision
3413 , p_lot_number => lottmp_rec.lot_number
3414 , p_quantity => lottmp_rec.primary_quantity
3415 , p_uom_code => p_uom
3416 , p_secondary_trx_quantity => ABS(lottmp_rec.secondary_quantity)
3417 , p_secondary_uom_code => lottmp_rec.secondary_unit_of_measure
3418 , p_serial_trx_temp_id => lottmp_rec.serial_transaction_temp_id
3419 , p_subinventory_code => p_subinventory_code
3420 , p_locator_id => p_locator_id
3421 , p_xfr_subinventory => p_xfr_subinventory
3422 , p_xfr_to_location => p_xfr_to_location
3423 , p_transaction_source_id => p_transaction_source_id
3424 , p_trx_source_line_id => p_trx_source_line_id
3425 );
3426 END LOOP;
3427
3428 IF (NOT l_lotfound) THEN
3429
3430 IF l_tracking_quantity_ind = 'P' THEN -- 16493898
3431 IF (l_pricing_ind = wms_catch_weight_pvt.g_price_secondary) THEN
3432 wms_catch_weight_pvt.show_ct_wt_for_split(
3433 x_return_status => ret_status
3434 , x_msg_data => ret_msgcnt
3435 , x_msg_count => ret_msgdata
3436 , p_org_id => p_org_id
3437 , p_from_lpn_id => p_lpn_id
3438 , p_from_item_id => p_item_rec.inventory_item_id
3439 , p_from_item_revision => p_revision
3440 , p_from_item_lot_number => NULL
3441 , p_to_lpn_id => p_xfr_lpn_id
3442 , x_show_ct_wt => l_valid_sec_qty_split
3443 );
3444
3445 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3446 fnd_message.set_name('INV', 'WMS_GET_CATCH_WEIGHT_ATT_FAIL');
3447 fnd_msg_pub.ADD;
3448 RAISE fnd_api.g_exc_unexpected_error;
3449 END IF;
3450
3451 IF (l_debug = 1) THEN
3452 inv_log_util.TRACE('l_valid_sec_qty_split=' || l_valid_sec_qty_split, l_api_name, 9);
3453 END IF;
3454
3455 -- Secondary quantities are not allowed do not pass it to
3456 -- the Split_Delivery_Details API
3457 IF (l_valid_sec_qty_split <> 1) THEN
3458 l_secondary_trx_quantity := NULL;
3459 l_secondary_uom_code := NULL;
3460 --Clear the secondary quantity fields for the from LPN
3461 wms_catch_weight_pvt.update_lpn_secondary_quantity(
3462 p_api_version => 1.0
3463 , x_return_status => ret_status
3464 , x_msg_count => ret_msgcnt
3465 , x_msg_data => ret_msgdata
3466 , p_record_source => 'WDD'
3467 , p_organization_id => p_org_id
3468 , p_lpn_id => p_lpn_id
3469 , p_inventory_item_id => p_item_rec.inventory_item_id
3470 , p_revision => p_revision
3471 , p_quantity => NULL
3472 , p_uom_code => NULL
3473 , p_secondary_quantity => NULL
3474 , p_secondary_uom_code => NULL
3475 );
3476
3477 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3478 IF (l_debug = 1) THEN
3479 inv_log_util.TRACE('Error calling Update_LPN_Secondary_Quantity: ' || ret_msgdata, l_api_name, 1);
3480 END IF;
3481
3482 RAISE fnd_api.g_exc_unexpected_error;
3483 END IF;
3484
3485 --Clear the secondary quantity fields for the to LPN
3486 wms_catch_weight_pvt.update_lpn_secondary_quantity(
3487 p_api_version => 1.0
3488 , x_return_status => ret_status
3489 , x_msg_count => ret_msgcnt
3490 , x_msg_data => ret_msgdata
3491 , p_record_source => 'WDD'
3492 , p_organization_id => p_org_id
3493 , p_lpn_id => p_xfr_lpn_id
3494 , p_inventory_item_id => p_item_rec.inventory_item_id
3495 , p_revision => p_revision
3496 , p_quantity => NULL
3497 , p_uom_code => NULL
3498 , p_secondary_quantity => NULL
3499 , p_secondary_uom_code => NULL
3500 );
3501
3502 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
3503 IF (l_debug = 1) THEN
3504 inv_log_util.TRACE('Error calling Update_LPN_Secondary_Quantity: ' || ret_msgdata, l_api_name, 1);
3505 END IF;
3506
3507 RAISE fnd_api.g_exc_unexpected_error;
3508 END IF;
3509 END IF;
3510 ELSIF(l_secondary_trx_quantity IS NOT NULL) THEN
3511 -- secondary qty populated even though item is not catch weight
3512 -- enabled. Do not pass values to split delivery details api
3513 l_secondary_trx_quantity := NULL;
3514 l_secondary_uom_code := NULL;
3515 END IF;
3516 END IF; -- 16493898
3517
3518 -- Call Split_Delivery_Details API once for the MMTT record
3519 split_delivery_details(
3520 p_organization_id => p_org_id
3521 , p_lpn_id => p_lpn_id
3522 , p_xfr_lpn_id => p_xfr_lpn_id
3523 , p_item_rec => p_item_rec
3524 , p_revision => p_revision
3525 , p_lot_number => NULL
3526 , p_quantity => p_qty
3527 , p_uom_code => p_uom
3528 , p_secondary_trx_quantity => ABS(l_secondary_trx_quantity)
3529 , p_secondary_uom_code => l_secondary_uom_code
3530 , p_serial_trx_temp_id => p_tempid
3531 , p_subinventory_code => p_subinventory_code
3532 , p_locator_id => p_locator_id
3533 , p_xfr_subinventory => p_xfr_subinventory
3534 , p_xfr_to_location => p_xfr_to_location
3535 , p_transaction_source_id => p_transaction_source_id
3536 , p_trx_source_line_id => p_trx_source_line_id
3537 );
3538 END IF;
3539
3540 IF (l_debug = 1) THEN
3541 inv_log_util.TRACE('** Split Delivery OK', l_api_name, 1);
3542 END IF;
3543 END split_delivery;
3544
3545
3546 /********************************************************************
3547 *
3548 * Transaction Manager Wrapper
3549 * This function does the LPN-related processing and then calls the
3550 * Java Transaction manager (replacement of inltpu) based on the
3551 * parameter p_process_trx
3552 *
3553 *******************************************************************/
3554
3555 FUNCTION process_lpn_trx(
3556 p_trx_hdr_id IN NUMBER
3557 , p_commit IN VARCHAR2 := fnd_api.g_false
3558 , x_proc_msg OUT NOCOPY VARCHAR2
3559 , p_proc_mode IN NUMBER := NULL
3560 , p_process_trx IN VARCHAR2 := fnd_api.g_true
3561 , p_atomic IN VARCHAR2 := fnd_api.g_false
3562 , p_business_flow_code IN NUMBER := NULL
3563 )
3564 RETURN NUMBER IS
3565 BEGIN
3566 RETURN process_lpn_trx(p_trx_hdr_id, p_commit, x_proc_msg, p_proc_mode, p_process_trx, p_atomic, p_business_flow_code, TRUE);
3567 END process_lpn_trx;
3568
3569
3570
3571 /********************************************************************
3572 *
3573 * Transaction Manager Wrapper
3574 * This function does the LPN-related processing and then calls the
3575 * Java Transaction manager (replacement of inltpu) based on the
3576 * parameter p_process_trx
3577 * The message stack is initialized only if the new parameter
3578 * p_init_msg_list is true.
3579 *
3580 *******************************************************************/
3581 FUNCTION process_lpn_trx(
3582 p_trx_hdr_id IN NUMBER
3583 , p_commit IN VARCHAR2 := fnd_api.g_false
3584 , x_proc_msg OUT NOCOPY VARCHAR2
3585 , p_proc_mode IN NUMBER := NULL
3586 , p_process_trx IN VARCHAR2 := fnd_api.g_true
3587 , p_atomic IN VARCHAR2 := fnd_api.g_false
3588 , p_business_flow_code IN NUMBER := NULL
3589 , p_init_msg_list IN BOOLEAN
3590 )
3591 RETURN NUMBER IS
3592
3593 -- Bug# 7435480 Added trasanction_batch_seq in the order by clause
3594 CURSOR c_mmtt IS
3595 SELECT *
3596 FROM mtl_material_transactions_temp
3597 WHERE transaction_header_id = p_trx_hdr_id
3598 AND NVL(transaction_status, 1) <> 2 -- don't consider suggestions
3599 AND process_flag = 'Y'
3600 ORDER BY transaction_batch_id,transaction_batch_seq;
3601
3602 /* Jalaj Srivastava Bug 4634410
3603 Added cursor c_mtlt */
3604 /* Jalaj Srivastava Bug 5446542
3605 Cursor c_mtlt is no longer used */
3606 /* *****************************************************
3607 CURSOR c_mtlt (p_transaction_temp_id NUMBER) IS
3608 SELECT lot_number
3609 ,primary_quantity
3610 FROM mtl_transaction_lots_temp
3611 WHERE transaction_temp_id = p_transaction_temp_id;
3612 *****************************************************
3613
3614
3615 /* Jalaj Srivastava
3616 Cursor to select transactions
3617 for which OPM-QM workflow event will be raised */
3618 CURSOR cur_get_txn_for_opm_qm IS
3619 SELECT mmt.transaction_id
3620 ,mmt.transaction_action_id
3621 ,mmt.transaction_source_type_id
3622 FROM mtl_material_transactions mmt
3623 WHERE mmt.transaction_set_id = p_trx_hdr_id
3624 AND mmt.transaction_quantity > 0
3625 AND exists (select 1
3626 from mtl_parameters mp
3627 where mp.organization_id = mmt.organization_id
3628 and process_enabled_flag = 'Y')
3629 AND exists (select 1
3630 from mtl_system_items_b msib
3631 where msib.inventory_item_id = mmt.inventory_item_id
3632 and msib.organization_id = mmt.organization_id
3633 and msib.process_quality_enabled_flag = 'Y')
3634 AND ( ( ( ( (mmt.transaction_action_id IN ( inv_globals.g_action_issue
3635 ,inv_globals.g_action_receipt
3636 ,inv_globals.g_action_subxfr
3637 ,inv_globals.g_action_orgxfr
3638 ,inv_globals.g_action_intransitshipment
3639 ,inv_globals.g_action_intransitreceipt))
3640 --Bug#6509707.Included Account Alias Receipt.
3641 AND (mmt.transaction_source_type_id IN (inv_globals.g_sourcetype_inventory,inv_globals.g_sourcetype_accountalias)
3642 ) )
3643 -- Pawan Kumar added bug 5533472
3644 OR (
3645 (mmt.transaction_action_id = inv_globals.g_action_assycomplete)
3646 AND (mmt.transaction_source_type_id = inv_globals.g_sourcetype_wip)
3647 )
3648 OR (
3649 (mmt.transaction_action_id = inv_globals.g_action_cyclecountadj)
3650 AND (mmt.transaction_source_type_id = inv_globals.g_sourcetype_cyclecount)
3651 )
3652 OR (
3653 (mmt.transaction_action_id = inv_globals.g_action_physicalcountadj)
3654 AND (mmt.transaction_source_type_id = inv_globals.g_sourcetype_physicalcount)
3655 )
3656
3657 )
3658 AND (exists (select gisv.spec_id
3659 from gmd_inventory_spec_vrs gisv, gmd_specifications_b gsb
3660 where gsb.inventory_item_id = mmt.inventory_item_id
3661 and gsb.spec_status in (400,700)
3662 and gsb.delete_mark = 0
3663 and gisv.spec_id = gsb.spec_id
3664 and gisv.delete_mark = 0
3665 and (gisv.organization_id is null OR gisv.organization_id = mmt.organization_id)))
3666 )
3667 OR ( (mmt.transaction_action_id = inv_globals.g_action_receipt)
3668 AND (mmt.transaction_source_type_id in ( inv_globals.g_sourcetype_purchaseorder
3669 ,inv_globals.g_sourcetype_rma
3670 ,inv_globals.g_sourcetype_intreq))
3671 AND ( (exists (select gssv.spec_id
3672 from gmd_supplier_spec_vrs gssv, gmd_specifications_b gsb
3673 where gsb.inventory_item_id = mmt.inventory_item_id
3674 and gsb.spec_status in (400,700)
3675 and gsb.delete_mark = 0
3676 and gssv.spec_id = gsb.spec_id
3677 and gssv.delete_mark = 0
3678 and (gssv.organization_id is null OR gssv.organization_id = mmt.organization_id)))
3679 OR (exists (select gisv.spec_id
3680 from gmd_inventory_spec_vrs gisv, gmd_specifications_b gsb
3681 where gsb.inventory_item_id = mmt.inventory_item_id
3682 and gsb.spec_status in (400,700)
3683 and gsb.delete_mark = 0
3684 and gisv.spec_id = gsb.spec_id
3685 and gisv.delete_mark = 0
3686 and (gisv.organization_id is null OR gisv.organization_id = mmt.organization_id)))
3687
3688 )
3689 )
3690 );
3691 /* BUG 5361705 - raise opm qm event for every distinct lot */
3692 Cursor cr_get_distinct_lots(l_txn_id NUMBER) IS
3693 select distinct mtln.product_transaction_id,mln.gen_object_id
3694 from mtl_transaction_lot_numbers mtln,mtl_lot_numbers mln
3695 where transaction_id = l_txn_id
3696 and mln.lot_number = mtln.lot_number
3697 and mln.inventory_item_id = mtln.inventory_item_id
3698 and mln.organization_id = mtln.organization_id;
3699
3700 i NUMBER := 0; -- 13557341
3701
3702 l_trx_temp_id NUMBER;
3703 l_lotfound BOOLEAN := FALSE;
3704 insrowcnt NUMBER := 0;
3705 failedrowcnt NUMBER := 0;
3706 expldrowcnt NUMBER := 0;
3707 retval NUMBER := 0;
3708 v_mmtt mtl_material_transactions_temp%ROWTYPE;
3709 v_lpn wms_container_pub.lpn;
3710 v_deleterow BOOLEAN := FALSE; -- Should the original row in MMTT be deleted ?
3711 l_cst_grp VARCHAR2(30);
3712 l_req_id NUMBER;
3713 l_proc_mode NUMBER := p_proc_mode;
3714 l_process_trx VARCHAR2(1) := p_process_trx;
3715 l_atomic NUMBER := 0; -- Do not treat all rows with same HdrId as one unit.
3716 l_commit NUMBER := 0; -- Do not commit yet
3717 l_comingling_occurs VARCHAR2(1);
3718 l_count NUMBER;
3719 l_wms_org_flag BOOLEAN;
3720 l_comingle_sub VARCHAR2(64);
3721 l_comingle_loc NUMBER;
3722 l_comingle_org NUMBER;
3723 l_comingle_cg NUMBER;
3724 label_status VARCHAR2(512);
3725 --l_call_tm BOOLEAN := FALSE;
3726 l_wms_installed BOOLEAN := FALSE;
3727 l_org NUMBER;
3728 l_containers NUMBER;
3729 l_is_cartonization NUMBER;
3730 l_prev_trx_batch_id NUMBER;
3731 l_current_group_status VARCHAR2(512);
3732 l_error_code VARCHAR2(256);
3733 l_num_ret_rows NUMBER;
3734 l_is_from_mti NUMBER;
3735 l_err_msg VARCHAR2(2000) := NULL;
3736 l_cst_grp_id NUMBER;
3737 l_xfr_cst_grp_id NUMBER;
3738 -- for bug 2726323
3739 l_return_status BOOLEAN := FALSE;
3740 --fob enhencement for J
3741 l_fob_ret_sts VARCHAR2(1);
3742 l_fob_ret_msg VARCHAR2(2000);
3743 l_fob_msg_count NUMBER;
3744 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
3745 -- Nested lpn changes
3746 l_putway_explode_req VARCHAR2(1) := 'N';
3747 -- HVERDDIN ERES START
3748 l_erecord_id NUMBER;
3749 l_trans_status VARCHAR2(30) := 'SUCCESS';
3750 l_eres_enabled VARCHAR2(3) := NVL(fnd_profile.VALUE('EDR_ERES_ENABLED'), 'N');
3751 tbl_index BINARY_INTEGER := 1;
3752 l_eres_tbl eres_tbl;
3753 -- HVERDDIN ERES END
3754 l_process NUMBER := 0;
3755 l_dcp_profile NUMBER;
3756 l_dcp_return_status VARCHAR2(1);
3757 l_lot_indiv_trx_valid boolean;
3758 l_secondary_txn_quantity number;
3759 l_gen_object_id NUMBER := 0; -- 9756188
3760 l_wms_enabled_org VARCHAR2(1) ;-- Bug 14341547
3761 l_rtv_exist NUMBER := 0; --16514543
3762
3763 /*Bug14298387,populate the physical locator to resolve the corrupted logic locator*/
3764 l_project_ref_enabled NUMBER := 0;
3765 l_phy_result BOOLEAN := TRUE;
3766 --Bug14298387 end
3767
3768 BEGIN
3769 IF (l_debug = 1) THEN
3770 inv_log_util.TRACE(
3771 'Call to PROCESS_LPN_TRX trxhdr=' || p_trx_hdr_id || ',procmode=' || p_proc_mode || ',bflow=' || p_business_flow_code
3772 , 'INV_LPN_TRX_PUB'
3773 , 9
3774 );
3775 END IF;
3776
3777 --Bug 4338316
3778 --Setting the local variable l_commit to honor the p_commit, if passed as true.
3779 IF fnd_api.to_boolean(p_commit) THEN
3780 l_commit := 1;
3781 END IF;
3782
3783 -- Release 12 - Call to Enhanced Diagnostics Check Implemented
3784 -- Enhanced Diagnostics Check API is called if Profile is set.
3785 -- Errors are ignored since this should not stop the txn flow.
3786 BEGIN --{
3787 l_dcp_profile := INV_DCP_PVT.G_CHECK_DCP;
3788 IF l_dcp_profile IS NULL THEN
3789 l_dcp_profile := inv_dcp_pvt.is_dcp_enabled;
3790 END IF;
3791 IF (l_debug = 1) THEN
3792 inv_log_util.TRACE('l_dcp_profile :'||l_dcp_profile,'INV_LPN_TRX_PUB',9);
3793 END IF;
3794 IF (l_dcp_profile =1) then
3795 INV_DCP_PVT.validate_data(
3796 p_dcp_event => 'Validate MMTT',
3797 p_trx_hdr_id => p_trx_hdr_id,
3798 p_temp_id => Null,
3799 p_batch_id => Null,
3800 p_raise_exception => 'N',
3801 x_return_status => l_dcp_return_status);
3802 END IF;
3803 IF (l_debug = 1) THEN
3804 inv_log_util.TRACE('After DCP Call -'||l_dcp_return_status,'INV_LPN_TRX_PUB',9);
3805 END IF;
3806 EXCEPTION
3807 WHEN OTHERS THEN
3808 IF (l_debug = 1) THEN
3809 inv_log_util.TRACE('DCP Error :'||substr(sqlerrm,1,240),'INV_LPN_TRX_PUB',9);
3810 END IF;
3811 END; ---}
3812
3813
3814 -- For BUG 2919763, initializing the message stack only if the new parameter
3815 -- p_init_msg_list is true.
3816 IF (p_init_msg_list = TRUE) THEN
3817 IF (l_debug = 1) THEN
3818 inv_log_util.TRACE('Initializing the message list', 'INV_LPN_TRX_PUB', 9);
3819 END IF;
3820 fnd_msg_pub.initialize;
3821 END IF;
3822
3823
3824
3825 -- Set a save point. In case of error, rollback to this point
3826 -- we would still have the exploded contents in MMTT
3827 SAVEPOINT process_lpn_trx;
3828
3829 -- If l_proc_mode is not filled, then check mode from profile
3830 IF (l_proc_mode IS NULL) THEN
3831 l_proc_mode := fnd_profile.VALUE('TRANSACTION_PROCESS_MODE');
3832
3833 IF (l_debug = 1) THEN
3834 inv_log_util.TRACE('TRANSACTION_PROCESS_MODE for ProcMode= ' || l_proc_mode, 'INV_LPN_TRX_PUB', 9);
3835 END IF;
3836
3837 -- if trx_process_mode is set for control at form level, then query
3838 -- form level profiles
3839 IF (l_proc_mode = 4) THEN
3840 l_proc_mode := NULL;
3841 END IF;
3842 END IF;
3843
3844
3845
3846 -- for bug 2726323 : Calling this funtion so as the variable
3847 -- WMS_INSTALL.G_WMS_INSTALLATION_STATUS gets set properly.
3848 l_return_status :=
3849 wms_install.check_install(x_return_status => ret_status, x_msg_count => ret_msgcnt, x_msg_data => ret_msgdata
3850 , p_organization_id => NULL);
3851
3852
3853
3854 -- Check if WMS is installed, if so check for cartonization transaction
3855 IF (wms_install.g_wms_installation_status = 'I') THEN
3856 BEGIN
3857 SELECT 1
3858 INTO l_is_cartonization
3859 FROM DUAL
3860 WHERE EXISTS(
3861 SELECT 1
3862 FROM mtl_material_transactions_temp
3863 WHERE transaction_action_id = inv_globals.g_action_containerpack
3864 AND transfer_lpn_id IS NULL
3865 AND transaction_header_id = p_trx_hdr_id);
3866 EXCEPTION
3867 WHEN NO_DATA_FOUND THEN
3868 l_is_cartonization := 0;
3869 END;
3870
3871 IF (l_debug = 1) THEN
3872 inv_log_util.TRACE('l_is_cartonization=' || l_is_cartonization, 'INV_LPN_TRX_PUB', 9);
3873 END IF;
3874
3875 IF (l_is_cartonization = 1) THEN
3876 -- Cartonization request call cartonization process
3877 IF (l_debug = 1) THEN
3878 inv_log_util.TRACE('**** Cartonization transaction', 'INV_LPN_TRX_PUB', 9);
3879 END IF;
3880
3881 -- Retrieve level and organization information for cartonization
3882 -- If there is a mix of contaner levels, take the maxium level. If
3883 -- all levels are null, cartonize until end.
3884 BEGIN
3885 SELECT organization_id
3886 , MAX(containers)
3887 INTO l_org
3888 , l_containers
3889 FROM mtl_material_transactions_temp
3890 WHERE transaction_header_id = p_trx_hdr_id
3891 AND NVL(transaction_status, 1) <> 2
3892 AND process_flag = 'Y'
3893 GROUP BY organization_id;
3894 EXCEPTION
3895 WHEN NO_DATA_FOUND THEN
3896 IF (l_debug = 1) THEN
3897 inv_log_util.TRACE('no rows retrieve when finding org and level for Cartonization', 'INV_LPN_TRX_PUB', 1);
3898 END IF;
3899
3900 RAISE fnd_api.g_exc_unexpected_error;
3901 WHEN OTHERS THEN
3902 IF (l_debug = 1) THEN
3903 inv_log_util.TRACE('Unexpected error when finding org and level for Cartonization', 'INV_LPN_TRX_PUB', 1);
3904 END IF;
3905
3906 RAISE fnd_api.g_exc_unexpected_error;
3907 END;
3908
3909 wms_cartnzn_wrap.cartonize(
3910 p_api_version => 1.0
3911 , p_init_msg_list => fnd_api.g_false
3912 , p_commit => fnd_api.g_false
3913 ,
3914 --p_validation_level => ,
3915 x_return_status => ret_status
3916 , x_msg_count => ret_msgcnt
3917 , x_msg_data => ret_msgdata
3918 ,
3919 --p_out_bound => ,
3920 p_org_id => l_org
3921 ,
3922 --p_move_order_header_id => ,
3923 --p_disable_cartonization => ,
3924 p_transaction_header_id => p_trx_hdr_id
3925 , p_stop_level => l_containers
3926 , p_packaging_mode => 2
3927 );
3928
3929 IF (ret_status = fnd_api.g_ret_sts_error) THEN
3930 IF (l_debug = 1) THEN
3931 inv_log_util.TRACE('Error in calling Cartonization', 'INV_LPN_TRX_PUB', 1);
3932 END IF;
3933
3934 RAISE fnd_api.g_exc_error;
3935 ELSIF(ret_status = fnd_api.g_ret_sts_unexp_error) THEN
3936 IF (l_debug = 1) THEN
3937 inv_log_util.TRACE('Unexpectied error in calling Cartonization', 'INV_LPN_TRX_PUB', 1);
3938 END IF;
3939
3940 RAISE fnd_api.g_exc_unexpected_error;
3941 ELSIF(ret_status <> fnd_api.g_ret_sts_success) THEN
3942 IF (l_debug = 1) THEN
3943 inv_log_util.TRACE('Undefined error in calling Cartonization', 'INV_LPN_TRX_PUB', 1);
3944 END IF;
3945
3946 RAISE fnd_api.g_exc_unexpected_error;
3947 END IF;
3948
3949 IF (l_debug = 1) THEN
3950 inv_log_util.TRACE('Done with call to Cartonization', 'INV_LPN_TRX_PUB', 9);
3951 END IF;
3952
3953 --Need to transfer cartonization_id to transfer_lpn_id to pack into
3954 --suggested LPN
3955 IF (l_debug = 1) THEN
3956 inv_log_util.TRACE('Transfering Cartonization suggestions', 'INV_LPN_TRX_PUB', 9);
3957 END IF;
3958
3959 UPDATE mtl_material_transactions_temp
3960 SET transfer_lpn_id = cartonization_id
3961 WHERE transaction_header_id = p_trx_hdr_id;
3962
3963 IF (l_debug = 1) THEN
3964 inv_log_util.TRACE('Done transfering Cartonization suggestions', 'INV_LPN_TRX_PUB', 9);
3965 END IF;
3966 END IF;
3967 END IF;
3968
3969
3970
3971 -- For atomic transactions create a single savepoint for the batch
3972 IF fnd_api.to_boolean(p_atomic) THEN
3973 SAVEPOINT group_savepoint;
3974 END IF;
3975
3976 l_process := 0;
3977
3978 --************* Open cursor into MMTT *************
3979 FOR v_mmtt IN c_mmtt LOOP
3980 IF (l_debug = 1) THEN
3981 inv_log_util.TRACE('trxtempid='||v_mmtt.transaction_temp_id||'srctypeid='||v_mmtt.transaction_source_type_id||'actid='||v_mmtt.transaction_action_id||',batchid='||v_mmtt.transaction_batch_id, 'INV_LPN_TRX_PUB', 9);
3982 inv_log_util.TRACE('seqid='||v_mmtt.transaction_sequence_id||',lpnid='||v_mmtt.lpn_id||',cntlpnid='||v_mmtt.content_lpn_id||'xfrlpnid='||v_mmtt.transfer_lpn_id, 'INV_LPN_TRX_PUB', 9);
3983 inv_log_util.TRACE('item_id='||v_mmtt.inventory_item_id||'qty='||v_mmtt.transaction_quantity||'uom='||v_mmtt.transaction_uom||'CG='||v_mmtt.cost_group_id||',XCG='||v_mmtt.transfer_cost_group_id, 'INV_LPN_TRX_PUB', 9);
3984 inv_log_util.TRACE('ccid='||v_mmtt.cycle_count_id, 'INV_LPN_TRX_PUB', 9);
3985 END IF;
3986
3987 BEGIN
3988 /* Jalaj Srivastava Bug 4634410
3989 Check lot indivisibility.
3990 check is needed here since same lot could be
3991 created in two locations within the same session.
3992 quantity tree built/updated in forms session was not getting
3993 picked up in pl/sql layer which would
3994 have enabled to catch the error earlier than this point */
3995 --Jalaj Srivastava Bug 5515181
3996 --pass primary_quantity instead of txn qty
3997 /* Jalaj Srivastava Bug 5446542
3998 Lot indivisibility check will not be done
3999 here. it will be done through the forms
4000 or by the txn group layer */
4001 /* ********************************************************************
4002 IF (v_mmtt.lot_number IS NOT NULL) THEN
4003 l_lot_indiv_trx_valid := INV_LOT_API_PUB.VALIDATE_LOT_INDIVISIBLE
4004 ( p_api_version => 1.0
4005 , p_init_msg_list => fnd_api.g_false
4006 , p_transaction_type_id => v_mmtt.transaction_type_id
4007 , p_organization_id => v_mmtt.organization_id
4008 , p_inventory_item_id => v_mmtt.inventory_item_id
4009 , p_revision => v_mmtt.revision
4010 , p_subinventory_code => v_mmtt.subinventory_code
4011 , p_locator_id => v_mmtt.locator_id
4012 , p_lot_number => v_mmtt.lot_number
4013 , p_primary_quantity => v_mmtt.primary_quantity
4014 , p_qoh => NULL
4015 , p_atr => NULL
4016 , x_return_status => ret_status
4017 , x_msg_count => ret_msgcnt
4018 , x_msg_data => ret_msgdata);
4019
4020 IF (NOT l_lot_indiv_trx_valid) THEN
4021 -- the transaction is not valid regarding lot indivisible:
4022 IF (l_debug = 1) THEN
4023 inv_log_util.trace('in proc process_lpn_trx. lot indivisibility error', 'INV_LPN_TRX_PUB', 9);
4024 END IF;
4025 RAISE FND_API.G_EXC_ERROR;
4026 END IF;
4027 ELSE
4028 FOR v_mtlt in c_mtlt(v_mmtt.transaction_temp_id) LOOP
4029 l_lot_indiv_trx_valid := INV_LOT_API_PUB.VALIDATE_LOT_INDIVISIBLE
4030 ( p_api_version => 1.0
4031 , p_init_msg_list => fnd_api.g_false
4032 , p_transaction_type_id => v_mmtt.transaction_type_id
4033 , p_organization_id => v_mmtt.organization_id
4034 , p_inventory_item_id => v_mmtt.inventory_item_id
4035 , p_revision => v_mmtt.revision
4036 , p_subinventory_code => v_mmtt.subinventory_code
4037 , p_locator_id => v_mmtt.locator_id
4038 , p_lot_number => v_mtlt.lot_number
4039 , p_primary_quantity => v_mtlt.primary_quantity
4040 , p_qoh => NULL
4041 , p_atr => NULL
4042 , x_return_status => ret_status
4043 , x_msg_count => ret_msgcnt
4044 , x_msg_data => ret_msgdata);
4045
4046 IF (NOT l_lot_indiv_trx_valid) THEN
4047 -- the transaction is not valid regarding lot indivisible:
4048 IF (l_debug = 1) THEN
4049 inv_log_util.trace('in proc process_lpn_trx. lot indivisibility error', 'INV_LPN_TRX_PUB', 9);
4050 END IF;
4051 RAISE FND_API.G_EXC_ERROR;
4052 END IF;
4053
4054 END LOOP;
4055 END IF;
4056 ******************************************************************** */
4057
4058 /* HVERDDIN ADDED Following code to support ERES */
4059 /* Only execute code if ERES enabled */
4060 IF l_eres_enabled <> 'N' THEN
4061 l_eres_tbl(tbl_index).event_id := v_mmtt.original_transaction_temp_id;
4062 l_eres_tbl(tbl_index).transaction_action_id := v_mmtt.transaction_action_id;
4063 l_eres_tbl(tbl_index).transaction_source_type_id := v_mmtt.transaction_source_type_id;
4064
4065 IF (l_debug = 1) THEN
4066 inv_log_util.TRACE('ERES event id => ' || l_eres_tbl(tbl_index).event_id, 'INV_LPN_TRX_PUB', 9);
4067 inv_log_util.TRACE('Transaction Action Id => ' || l_eres_tbl(tbl_index).transaction_action_id, 'INV_LPN_TRX_PUB', 9);
4068 inv_log_util.TRACE('Transaction Source Type Id => ' || l_eres_tbl(tbl_index).transaction_source_type_id, 'INV_LPN_TRX_PUB', 9);
4069 END IF;
4070 END IF;
4071
4072 /*------------------------------------------------------+
4073 | Validate Logical Transactions.
4074 |========================================================
4075 | Add a check to prevent processing logical transactions
4076 | that are populated directly to the transactions table.
4077 | No new logical transactions should go through MMTT.
4078 | Opened up the logical po receipt and logical delivery
4079 | adjustment to go through TM for lot serial support
4080 +------------------------------------------------------*/
4081 IF (
4082 (
4083 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_inventory
4084 AND v_mmtt.transaction_action_id IN
4085 (
4086 inv_globals.g_action_logicalissue
4087 , inv_globals.g_action_logicalicsales
4088 , inv_globals.g_action_logicalicreceipt
4089 , inv_globals.g_action_logicalicrcptreturn
4090 , inv_globals.g_action_logicalicsalesreturn
4091 , inv_globals.g_action_logicalreceipt
4092 )
4093 )
4094 OR(
4095 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_rma
4096 AND v_mmtt.transaction_action_id = inv_globals.g_action_logicalreceipt
4097 )
4098 OR(
4099 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
4100 AND v_mmtt.transaction_action_id IN(inv_globals.g_action_logicalissue,
4101 -- inv_globals.G_action_logicaldeladj,
4102 -- inv_globals.G_action_logicalreceipt,
4103 inv_globals.g_action_retropriceupdate)
4104 )
4105 OR(
4106 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_rma
4107 AND v_mmtt.transaction_action_id = inv_globals.g_action_logicalreceipt
4108 )
4109 OR(
4110 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_intreq
4111 AND v_mmtt.transaction_action_id = inv_globals.g_action_logicalexpreqreceipt
4112 )
4113 OR(
4114 v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_salesorder
4115 AND v_mmtt.transaction_action_id = inv_globals.g_action_logicalissue
4116 )
4117 ) THEN
4118 fnd_message.set_name('INV', 'INV_INT_TRXACTCODE');
4119 fnd_msg_pub.ADD;
4120 RAISE fnd_api.g_exc_error;
4121 END IF;
4122
4123 -- For new or null transaction groups that are non atomic, create a new savepoint
4124 IF (NVL(v_mmtt.transaction_batch_id, -88) <> NVL(l_prev_trx_batch_id, -99)
4125 AND NOT fnd_api.to_boolean(p_atomic)) THEN
4126 SAVEPOINT group_savepoint;
4127 l_prev_trx_batch_id := v_mmtt.transaction_batch_id;
4128 l_current_group_status := fnd_api.g_ret_sts_success;
4129
4130 IF (l_debug = 1) THEN
4131 inv_log_util.TRACE('new group savepoint prevbatchid=' || l_prev_trx_batch_id, 'INV_LPN_TRX_PUB', 9);
4132 END IF;
4133 END IF;
4134
4135 -- Skip records that are of the same trx group where a record has failed
4136 -- Else run records normally
4137 IF NOT(
4138 v_mmtt.transaction_batch_id = l_prev_trx_batch_id
4139 AND NVL(l_current_group_status, fnd_api.g_ret_sts_success) <> fnd_api.g_ret_sts_success
4140 ) THEN
4141 insrowcnt := insrowcnt + 1;
4142
4143 --For planning xfr and consigned xfr transactions, make sure the
4144 --transactions are always processed in online mode. bug 3453619
4145 --For any transaction in mmtt which is an explicit transaction,
4146 --implying that the owning_org or planning_org is populated in
4147 --mmtt make sure the transactions are alwaya processed in online
4148 -- mode bug 3691234
4149 IF ((v_mmtt.transaction_action_id = inv_globals.g_action_planxfr)
4150 OR(v_mmtt.transaction_action_id = inv_globals.g_action_ownxfr)
4151 OR (Nvl(v_mmtt.owning_organization_id,v_mmtt.organization_id)
4152 <> v_mmtt.organization_id)
4153 OR (Nvl(v_mmtt.planning_organization_id,v_mmtt.organization_id)
4154 <> v_mmtt.organization_id)) THEN
4155 l_proc_mode := 1;
4156 END IF;
4157
4158 -- If l_proc_mode is not set at this stage, it means control is at
4159 -- Forms-level Transaction-process profiles based on Transaction
4160 IF (l_proc_mode IS NULL) THEN
4161 IF (
4162 (v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_inventory)
4163 AND(v_mmtt.transaction_action_id = inv_globals.g_action_subxfr)
4164 ) THEN
4165 l_proc_mode := fnd_profile.VALUE('SUBINV_TRANS_TXN');
4166
4167 IF (l_debug = 1) THEN
4168 inv_log_util.TRACE('Using SUBINV_TRANS_TXN to set process_mode. ProcMode=' || l_proc_mode, 'INV_LPN_TRX_PUB', 9);
4169 END IF;
4170 ELSIF(
4171 (
4172 (v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_inventory)
4173 OR(v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_account)
4174 )
4175 AND(
4176 (v_mmtt.transaction_action_id = inv_globals.g_action_issue)
4177 OR(v_mmtt.transaction_action_id = inv_globals.g_action_receipt)
4178 )
4179 ) THEN
4180 l_proc_mode := fnd_profile.VALUE('ACCOUNT_ISSUE_TXN');
4181
4182 IF (l_debug = 1) THEN
4183 inv_log_util.TRACE('Using ACCOUNT_ISSUE_TXN to set process_mode. ProcMode = ' || l_proc_mode, 'INV_LPN_TRX_PUB', 9);
4184 END IF;
4185 ELSIF(
4186 (v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_moveorder)
4187 AND(
4188 (v_mmtt.transaction_action_id = inv_globals.g_action_receipt)
4189 OR(v_mmtt.transaction_action_id = inv_globals.g_action_issue)
4190 )
4191 ) THEN
4192 l_proc_mode := fnd_profile.VALUE('TRANSFER_ORDER_TXN');
4193
4194 IF (l_debug = 1) THEN
4195 inv_log_util.TRACE('Using TRANSFER_ORDER_TXN to set process_mode. ProcMode = ' || l_proc_mode, 'INV_LPN_TRX_PUB', 9);
4196 END IF;
4197 ELSIF(
4198 (v_mmtt.transaction_source_type_id = inv_globals.g_sourcetype_inventory)
4199 AND(
4200 (v_mmtt.transaction_action_id = inv_globals.g_action_orgxfr)
4201 OR(v_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
4202 )
4203 ) THEN
4204 l_proc_mode := fnd_profile.VALUE('INTER_ORG_SHIP_TXN');
4205
4206 IF (l_debug = 1) THEN
4207 inv_log_util.TRACE('Using INTER_ORG_SHIP_TXN to set process_mode. ProcMode = ' || l_proc_mode, 'INV_LPN_TRX_PUB', 9);
4208 END IF;
4209 END IF;
4210 END IF;
4211
4212 -- Sanity check. If the transaction-process mode is still Not set, then
4213 -- perform an online transaction
4214 IF (l_proc_mode IS NULL) THEN
4215 IF (l_debug = 1) THEN
4216 inv_log_util.TRACE('Warning: TrxProcess profile not set ', 'INV_LPN_TRX_PUB', 2);
4217 END IF;
4218
4219 l_proc_mode := 1;
4220 END IF;
4221
4222 -- If this transaction involves any LPN based processing, then
4223 -- should ensure that the process-mode is not 'background'
4224 -- This is because pending LPN transactions in MMTT
4225 -- are currently not handled properly. Check bug 3027283 for details.
4226 -- For this case, change the process_mode to asynchronous .
4227 IF ((v_mmtt.lpn_id IS NOT NULL)
4228 OR(v_mmtt.content_lpn_id IS NOT NULL)
4229 OR(v_mmtt.transfer_lpn_id IS NOT NULL))
4230 AND(l_proc_mode = inv_txn_manager_pub.proc_mode_mmtt_bgrnd) THEN
4231 l_proc_mode := inv_txn_manager_pub.proc_mode_mmtt_async;
4232 END IF;
4233
4234 -- Changes added to Patchet J. This is only to be done if PO pathset J
4235 -- is installed. API update_fob_point, will derive and update
4236 -- mmtt record with the fob_point and inv_intransit_account in
4237 -- case of an intransit Rcpt or intransit Shipment transaction
4238 IF (po_code_release_grp.current_release >= po_code_release_grp.prc_11i_family_pack_j) THEN
4239 IF (
4240 (v_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
4241 OR(v_mmtt.transaction_action_id = inv_globals.g_action_intransitreceipt)
4242 ) THEN
4243 update_fob_point(v_mmtt => v_mmtt, x_return_status => l_fob_ret_sts, x_msg_data => l_fob_ret_msg
4244 , x_msg_count => l_fob_msg_count);
4245
4246 IF (l_fob_ret_sts <> fnd_api.g_ret_sts_success) THEN
4247 IF (l_debug = 1) THEN
4248 inv_log_util.TRACE(' Error from update_fob_point:' || l_fob_ret_msg, 'INV_LPN_TRX_PUB', 1);
4249 END IF;
4250
4251 fnd_message.set_name('INV', 'INV_FOB_NOT_DEFINED');
4252 fnd_message.set_token('ENTITY1', v_mmtt.organization_id);
4253 fnd_msg_pub.ADD;
4254 RAISE fnd_api.g_exc_error;
4255 END IF;
4256 END IF;
4257 END IF; --(PO pathset J installed)
4258
4259 --Changes made for WIP TM Integration: Patchet J.
4260 --We call a WIP API which tells us wether to update the mmtt
4261 --record, With the MATERIAL_ALLOCATION_TEMP_ID with the next
4262 -- sequence. This will only be done in case of WIP.J being
4263 --installed.
4264 IF (v_mmtt.transaction_source_type_id = 5
4265 AND wip_constants.dmf_patchset_level >= wip_constants.dmf_patchset_j_value) THEN
4266 IF (wip_mtltempproc_grp.istxnidrequired(v_mmtt.transaction_temp_id)) THEN
4267 inv_log_util.TRACE('Going to update mmtt with material_allocation_temp_id', 'INV_LPN_TRX_PUB', 1);
4268
4269 UPDATE mtl_material_transactions_temp
4270 SET material_allocation_temp_id = mtl_material_transactions_s.NEXTVAL
4271 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4272 END IF;
4273 END IF;
4274
4275 --End patchset J changes for WIP.
4276
4277 -- Call the CostGroup API for this line
4278 -- Call CostGroupAPI which will update the cost_group_id and
4279 -- xfr_cost_group_id in MMTT for this record.
4280 -- Note: This API could create additional rows into MMTT if lots/serials
4281 -- are specified which have different cost-groups., that is why our
4282 -- MMTT cursor (c_mmtt) is being opened after calling this API
4283
4284 -- Call CG API for all cases except when content_lpn_id is not null AND transaction_type
4285 -- is neither S.O nor I.O
4286
4287 -- Bug 14341547 added for project contracts type .
4288
4289 IF (inv_cache.set_org_rec(v_mmtt.organization_id)) THEN
4290 l_wms_enabled_org := inv_cache.org_rec.WMS_ENABLED_FLAG;
4291 END IF;
4292
4293 inv_log_util.TRACE('Wms_enabled_flag: '||l_wms_enabled_org, 'INV_LPN_TRX_PUB', 1);
4294 IF NOT(
4295 (v_mmtt.content_lpn_id IS NOT NULL)
4296 AND
4297 v_mmtt.transaction_source_type_id <> inv_globals.g_sourcetype_intorder
4298 AND
4299 v_mmtt.transaction_source_type_id <> inv_globals.g_sourcetype_salesorder
4300 AND -- Bug 14341547 added the project contratcs type also.
4301 ( l_wms_enabled_org='Y' OR v_mmtt.transaction_source_type_id <> inv_globals.G_SOURCETYPE_PRJCONTRACTS )
4302 ) THEN
4303 inv_cost_group_pvt.assign_cost_group(
4304 x_return_status => ret_status
4305 , x_msg_count => ret_msgcnt
4306 , x_msg_data => ret_msgdata
4307 , p_organization_id => v_mmtt.organization_id
4308 , p_mmtt_rec => v_mmtt
4309 , p_fob_point => NULL
4310 , p_line_id => v_mmtt.transaction_temp_id
4311 , p_input_type => inv_cost_group_pub.g_input_mmtt
4312 , x_cost_group_id => l_cst_grp_id
4313 , x_transfer_cost_group_id => l_xfr_cst_grp_id
4314 );
4315
4316 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
4317 IF (l_debug = 1) THEN
4318 inv_log_util.TRACE(' Error from CostGrpAPI:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
4319 END IF;
4320 --Bug 3804314: The message from the cost group API is
4321 --overwritten by INV_COST_GROUP_FAILURE. Commenting the message.
4322 --fnd_message.set_name('INV', 'INV_COST_GROUP_FAILURE');
4323 --fnd_msg_pub.ADD;
4324 RAISE fnd_api.g_exc_error;
4325 END IF;
4326 END IF;
4327
4328 -- Continue with the process based on the value of l_proc_mode
4329 IF l_proc_mode = 2 THEN -- Concurrent Mode
4330 -- Concurrent request. Submit request and return to caller
4331 UPDATE mtl_material_transactions_temp
4332 SET transaction_mode = inv_txn_manager_pub.proc_mode_mmtt_async
4333 WHERE transaction_header_id = p_trx_hdr_id;
4334
4335 l_req_id := fnd_request.submit_request(application => 'INV', program => 'INVMBTRX', argument1 => p_trx_hdr_id);
4336 COMMIT; -- Need to commit for the request to be submitted
4337
4338 IF (l_req_id = 0) THEN
4339 -- display error message
4340 fnd_message.set_name(application => 'INV', NAME => 'INV_SUBMIT_FAIL');
4341 fnd_message.set_token(token => 'TOKEN', VALUE => TO_CHAR(p_trx_hdr_id), TRANSLATE => FALSE);
4342 fnd_msg_pub.ADD;
4343 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4344 RETURN -1;
4345 ELSE
4346 -- display request ID
4347 fnd_message.set_name(application => 'INV', NAME => 'INV_CONC_TRANSACT');
4348 fnd_message.set_token(token => 'REQUEST_ID', VALUE => TO_CHAR(l_req_id), TRANSLATE => FALSE);
4349 fnd_msg_pub.ADD;
4350 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4351
4352 IF (l_debug = 1) THEN
4353 inv_log_util.TRACE('Concurrent Req. submitted: ' || l_req_id, 'INV_LPN_TRX_PUB', 9);
4354 END IF;
4355
4356 RETURN 0;
4357 END IF;
4358 ELSIF l_proc_mode = 3 THEN -- Background mode
4359 IF (l_debug = 1) THEN
4360 inv_log_util.TRACE('** Background request submitted **', 'INV_LPN_TRX_PUB', 9);
4361 END IF;
4362
4363 -- In this case, the background transaction manager would pick
4364 -- up this row from MMTT. Update transaction_mode and return to caller
4365 UPDATE mtl_material_transactions_temp
4366 SET transaction_mode = inv_txn_manager_pub.proc_mode_mmtt_bgrnd
4367 WHERE transaction_header_id = p_trx_hdr_id;
4368
4369 fnd_message.set_name('INV', 'INV_TXN_REQ_QUEUED');
4370 fnd_msg_pub.ADD;
4371 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4372
4373 IF fnd_api.to_boolean(p_commit) THEN
4374 COMMIT WORK;
4375 END IF;
4376
4377 RETURN 0;
4378 END IF;
4379
4380 -- If here, it means that this transaction is to be processed 'on-line'
4381 v_deleterow := FALSE;
4382
4383 -- If the transaction action is either Issue or Intransit Shipment, and
4384 -- the sign of quantity is not -ve, make it -ve.
4385 -- Bug 3736797, added update to MMTT, since MMTT was never getting updated with sign changed.
4386 IF (
4387 (
4388 (v_mmtt.transaction_action_id = inv_globals.g_action_issue)
4389 OR(v_mmtt.transaction_action_id = inv_globals.g_action_intransitshipment)
4390 --Bug 12534588 Adding the updation of MMTT for assembly return action also.
4391 OR(v_mmtt.transaction_action_id = inv_globals.g_action_assyreturn)
4392 )
4393 AND(v_mmtt.primary_quantity > 0)
4394 ) THEN
4395
4396 IF (l_debug = 1) THEN
4397 inv_log_util.trace('sign of quantity is not -ve for temp_id '||v_mmtt.transaction_temp_id, 'INV_LPN_TRX_PUB',9);
4398 END IF;
4399
4400 v_mmtt.primary_quantity := -1 * v_mmtt.primary_quantity;
4401 v_mmtt.transaction_quantity := -1 * ABS(v_mmtt.transaction_quantity);
4402 --INVCONV kkillams
4403 IF v_mmtt.secondary_transaction_quantity IS NOT NULL THEN
4404 --Jalaj Srivastava Bug 5138445
4405 --get -ve of absolute
4406 v_mmtt.secondary_transaction_quantity := -1 * abs(v_mmtt.secondary_transaction_quantity);
4407 END IF;
4408 --END INVCONV kkillams
4409 UPDATE MTL_MATERIAL_TRANSACTIONS_TEMP
4410 SET PRIMARY_QUANTITY = v_mmtt.primary_quantity,
4411 TRANSACTION_QUANTITY = v_mmtt.transaction_quantity,
4412 SECONDARY_TRANSACTION_QUANTITY = CASE WHEN v_mmtt.secondary_uom_code IS NOT NULL THEN v_mmtt.secondary_transaction_quantity
4413 ELSE SECONDARY_TRANSACTION_QUANTITY
4414 END --INVCONV kkillams
4415 WHERE TRANSACTION_TEMP_ID = v_mmtt.transaction_temp_id
4416 AND PRIMARY_QUANTITY > 0;
4417
4418 IF (l_debug = 1) THEN
4419 inv_log_util.trace('Made the sign -ve for temp_id '||v_mmtt.transaction_temp_id, 'INV_LPN_TRX_PUB',9);
4420 END IF;
4421
4422 END IF;
4423
4424 IF (wms_control.get_current_release_level >= inv_release.get_j_release_level) THEN
4425 BEGIN
4426 SELECT 'Y'
4427 INTO l_putway_explode_req
4428 FROM mtl_txn_request_headers mtrh, mtl_txn_request_lines mtrl
4429 WHERE v_mmtt.move_order_line_id IS NOT NULL
4430 AND mtrl.line_id = v_mmtt.move_order_line_id
4431 AND mtrh.header_id = mtrl.header_id
4432 AND v_mmtt.transaction_source_type_id IN(4, 5)
4433 AND mtrh.move_order_type = 6
4434 AND ROWNUM < 2;
4435
4436 inv_log_util.TRACE(' Patchset J code. Do not explode LPN for Putaway ', 'INV_LPN_TRX_PUB', 1);
4437 EXCEPTION
4438 WHEN OTHERS THEN
4439 inv_log_util.TRACE(' Exception while exploding ', 'INV_LPN_TRX_PUB', 1);
4440 l_putway_explode_req := 'N';
4441 END;
4442 END IF;
4443
4444 -- If contentLPN is not NULL, then need to explode and insert contents
4445 -- into MMTT , unless this is a Pack/Unpack/split/SO/IO Transaction.
4446 -- Note: For SO and IO transactions, there is no need
4447 -- to explode the LPN as there will be a seperate MMTT line for each
4448 -- item inside the LPN
4449
4450 inv_log_util.TRACE('Wms_enabled_flag: '||l_wms_enabled_org, 'INV_LPN_TRX_PUB', 1);
4451 IF (v_mmtt.content_lpn_id IS NOT NULL) THEN
4452 IF ( v_mmtt.transaction_action_id <> inv_globals.g_action_containerpack AND
4453 v_mmtt.transaction_action_id <> inv_globals.g_action_containerunpack AND
4454 v_mmtt.transaction_action_id <> inv_globals.g_action_containersplit AND
4455 v_mmtt.transaction_source_type_id <> inv_globals.g_sourcetype_intorder AND
4456 v_mmtt.transaction_source_type_id <> inv_globals.g_sourcetype_salesorder AND
4457 -- Bug 14341547 added the project contratcs type also.
4458 (l_wms_enabled_org='Y' OR v_mmtt.transaction_source_type_id <> inv_globals.G_SOURCETYPE_PRJCONTRACTS) AND
4459 l_putway_explode_req = 'N' )
4460 THEN
4461
4462 --Done changes to skip the call to explode lpn,in case of return order is created
4463 --from different org,other than the receipt org. --16514543
4464
4465 IF (v_mmtt.transaction_type_id = 3) THEN
4466
4467 SELECT Count(1) INTO l_rtv_exist FROM
4468 rcv_transactions_interface rti,mtl_material_transactions_temp mmtt
4469 WHERE rti.interface_transaction_id = mmtt.source_line_id
4470 AND rti.processing_status_code = 'WSH_INTERFACED'
4471 AND rti.group_id = mmtt.transaction_source_name
4472 AND mmtt.transaction_temp_id = v_mmtt.transaction_temp_id ;
4473
4474 END IF ;
4475
4476 IF (l_rtv_exist <> 1 ) THEN
4477
4478
4479 expldrowcnt := explode_and_insert(v_mmtt.content_lpn_id, p_trx_hdr_id, v_mmtt);
4480
4481 IF (expldrowcnt = -1) THEN
4482 IF (l_debug = 1) THEN
4483 inv_log_util.TRACE(' Failed in EXPLODE_AND_INSERT!!', 'INV_LPN_TRX_PUB', 1);
4484 END IF;
4485
4486 fnd_message.set_name('INV', 'INV_FAILED');
4487 fnd_msg_pub.ADD;
4488 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4489 RETURN -1;
4490 END IF;
4491
4492 insrowcnt := insrowcnt + expldrowcnt;
4493
4494 IF (l_debug = 1) THEN
4495 inv_log_util.TRACE('Done exploding new lpn expldrowcnt=' || expldrowcnt || ' insrowcnt=' || insrowcnt, 'INV_LPN_TRX_PUB', 9);
4496 END IF;
4497 ELSIF ( l_putway_explode_req = 'Y' AND v_mmtt.cost_group_id IS NULL ) THEN
4498 -- bug4475607 For WIP putaway transactions contents are not exploded, but the
4499 -- cost group id may not exist on the record. Call cost group api
4500 inv_cost_group_pvt.assign_cost_group(
4501 x_return_status => ret_status
4502 , x_msg_count => ret_msgcnt
4503 , x_msg_data => ret_msgdata
4504 , p_organization_id => v_mmtt.organization_id
4505 , p_mmtt_rec => v_mmtt
4506 , p_fob_point => NULL
4507 , p_line_id => v_mmtt.transaction_temp_id
4508 , p_input_type => inv_cost_group_pub.g_input_mmtt
4509 , x_cost_group_id => l_cst_grp_id
4510 , x_transfer_cost_group_id => l_xfr_cst_grp_id );
4511
4512 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
4513 IF (l_debug = 1) THEN
4514 inv_log_util.TRACE(' Error from CostGrpAPI:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
4515 END IF;
4516 RAISE fnd_api.g_exc_error;
4517 END IF;
4518
4519 END IF ;--end of l_rtv_exist --16514543
4520 END IF;
4521 END IF; -- content_lpn_id populated
4522
4523 -- Logic to determine whether JavaTM is to be called. We don't need to
4524 -- call the JavaTM if this batch in MMTT contained no records OR if
4525 -- contained only one record which was later removed by EXPLODE API
4526 -- because it had no contents.
4527 /** bug 3618385, don't use l_call_tm because it doesn't determine correctly whether JavaTM
4528 needs to be called.
4529 IF (NOT l_call_tm) THEN
4530 IF (insrowcnt > 0) THEN
4531 l_call_tm := TRUE;
4532 END IF;
4533 END IF;
4534 **/
4535 END IF; -- not same or failed transactions group
4536
4537
4538 EXCEPTION
4539 WHEN OTHERS THEN
4540 IF (l_debug = 1) THEN
4541 inv_log_util.TRACE(
4542 '***Error g_exec in c_mmtt loop trxtmpid=' || v_mmtt.transaction_temp_id || ',Sqlerrm:' || SUBSTR(SQLERRM, 1, 100)
4543 , 'INV_LPN_TRX_PUB'
4544 , 1
4545 );
4546 END IF;
4547
4548 l_current_group_status := fnd_api.g_ret_sts_error;
4549 l_error_code := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4550 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, 'F');
4551 failedrowcnt := failedrowcnt + 1;
4552
4553 IF (l_debug = 1) THEN
4554 inv_log_util.TRACE('failedrowcnt=' || failedrowcnt || ' msg=' || x_proc_msg, 'INV_LPN_TRX_PUB', 1);
4555 END IF;
4556
4557 ROLLBACK TO group_savepoint;
4558
4559 IF fnd_api.to_boolean(p_atomic) THEN
4560 --Set message in MMTT line based in header id
4561 -- Bug 3804314: Changed the where clause to transaction_header_id
4562 BEGIN
4563 -- Update MMTT records with error message and set status to error
4564 UPDATE mtl_material_transactions_temp
4565 SET ERROR_CODE = l_error_code
4566 , error_explanation = x_proc_msg
4567 , process_flag = 'E'
4568 , lock_flag = 'N'
4569 WHERE transaction_header_id = p_trx_hdr_id;
4570 EXCEPTION
4571 WHEN OTHERS THEN
4572 IF (l_debug = 1) THEN
4573 inv_log_util.TRACE('Error in updating MMTT for trxhdrid=' || p_trx_hdr_id, 1);
4574 END IF;
4575 END;
4576
4577 -- Batch Failed exit from loop
4578 EXIT;
4579 ELSIF(v_mmtt.transaction_mode = inv_txn_manager_pub.proc_mode_mti) THEN
4580 BEGIN
4581 IF (v_mmtt.transaction_batch_id IS NOT NULL) THEN
4582 -- This record was part of a batch and it originated from MTI
4583 -- Update MTI records with error message and set status to error
4584 -- and delete all rows belonging to this group from MMTT/MTLT/MSNT
4585 UPDATE mtl_transactions_interface
4586 SET ERROR_CODE = substrb(l_error_code,1,240)/*added substrb for 3632722*/
4587 , error_explanation = substrb(x_proc_msg,1,240)/*added substrb for 3632722*/
4588 , process_flag = 3
4589 , lock_flag = 2
4590 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4591 and transaction_batch_id = v_mmtt.transaction_batch_id;
4592
4593 l_num_ret_rows := SQL%ROWCOUNT;
4594
4595 IF (l_debug = 1) THEN
4596 inv_log_util.TRACE('Updated error msg for ' || l_num_ret_rows || ' rows form MTI with txnbatchid='
4597 || v_mmtt.transaction_batch_id, 1);
4598 END IF;
4599
4600 -- Remove from MSNT rows with same MMTT transaction_temp_id
4601 DELETE FROM mtl_serial_numbers_temp
4602 WHERE transaction_temp_id IN(SELECT transaction_temp_id
4603 FROM mtl_material_transactions_temp
4604 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4605 AND transaction_batch_id = v_mmtt.transaction_batch_id);
4606
4607 -- Remove from MSNT rows with same MTNT transaction_temp_id
4608 DELETE FROM mtl_serial_numbers_temp
4609 WHERE transaction_temp_id IN(SELECT serial_transaction_temp_id
4610 FROM mtl_transaction_lots_temp
4611 WHERE transaction_temp_id IN(SELECT transaction_temp_id
4612 FROM mtl_material_transactions_temp
4613 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4614 AND transaction_batch_id = v_mmtt.transaction_batch_id));
4615
4616 -- Remove from MTLT rows with same MMTT transaction_temp_id
4617 DELETE FROM mtl_transaction_lots_temp
4618 WHERE transaction_temp_id IN(SELECT transaction_temp_id
4619 FROM mtl_material_transactions_temp
4620 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4621 AND transaction_batch_id = v_mmtt.transaction_batch_id);
4622
4623 -- Remove from MMTT rows with same transaction group id
4624 DELETE FROM mtl_material_transactions_temp
4625 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4626 AND transaction_batch_id = v_mmtt.transaction_batch_id;
4627
4628 ELSE -- IF v_mmtt.transaction_batch_id IS NULL
4629 -- This record was not part of a batch and it originated from MTI
4630 -- Update MTI record with error message and set status to error
4631 -- and delete the corresponding record from MMTT/MTLT/MSNT
4632 UPDATE mtl_transactions_interface
4633 SET ERROR_CODE = substrb(l_error_code,1,240)/*added substrb for 3632722*/
4634 , error_explanation = substrb(x_proc_msg,1,240)/*added substrb for 3632722*/
4635 , process_flag = 3
4636 , lock_flag = 2
4637 WHERE transaction_interface_id = v_mmtt.transaction_temp_id;
4638
4639 l_num_ret_rows := SQL%ROWCOUNT;
4640
4641 IF (l_debug = 1) THEN
4642 inv_log_util.TRACE('Updated error msg for ' || l_num_ret_rows || ' rows form MTI with txntempid='
4643 || v_mmtt.transaction_temp_id, 1);
4644 END IF;
4645
4646 -- Remove from MSNT rows with same MMTT transaction_temp_id
4647 DELETE FROM mtl_serial_numbers_temp
4648 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4649
4650 -- Remove from MSNT rows with same MTNT transaction_temp_id
4651 DELETE FROM mtl_serial_numbers_temp
4652 WHERE transaction_temp_id IN(SELECT serial_transaction_temp_id
4653 FROM mtl_transaction_lots_temp
4654 WHERE transaction_temp_id = v_mmtt.transaction_temp_id);
4655
4656 -- Remove from MTLT rows with same MMTT transaction_temp_id
4657 DELETE FROM mtl_transaction_lots_temp
4658 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4659
4660 -- Remove from MMTT rows with same transaction group id
4661 DELETE FROM mtl_material_transactions_temp
4662 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4663 END IF;
4664 EXCEPTION
4665 WHEN OTHERS THEN
4666 IF (l_debug = 1) THEN
4667 inv_log_util.TRACE('Error in updating MTI or deleting MMTT for trxbatchid=' || v_mmtt.transaction_batch_id, 1);
4668 END IF;
4669 END;
4670 ELSE -- record originated in MMTT
4671 IF (v_mmtt.transaction_batch_id IS NOT NULL) THEN
4672 -- This record belongs to a batch. Fail all records of this batch
4673 -- stamp error-explanation only on the row that caused error
4674 UPDATE mtl_material_transactions_temp
4675 SET ERROR_CODE = l_error_code
4676 , error_explanation = x_proc_msg
4677 , process_flag = 'E'
4678 , lock_flag = 'N'
4679 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4680
4681 -- stamp error-code on all records of the batch
4682 UPDATE mtl_material_transactions_temp
4683 SET ERROR_CODE = l_error_code
4684 , process_flag = 'E'
4685 , lock_flag = 'N'
4686 WHERE transaction_header_id = p_trx_hdr_id -- Bug 5748351
4687 AND transaction_batch_id = v_mmtt.transaction_batch_id;
4688 ELSE
4689 -- This record does not belong to a batch.
4690 -- Update MMTT records with error message and set status to error
4691 UPDATE mtl_material_transactions_temp
4692 SET ERROR_CODE = l_error_code
4693 , error_explanation = x_proc_msg
4694 , process_flag = 'E'
4695 , lock_flag = 'N'
4696 WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
4697 END IF;
4698 END IF;
4699 END; -- WHEN OTHERS THEN
4700
4701 -- HVERDDIN ERES START
4702 tbl_index := tbl_index + 1;
4703 -- HVERDDIN ERES END
4704 --Jalaj Srivastava Bug 5138445
4705 --update secondary transaction quantity with the sign of transaction quantity
4706 l_secondary_txn_quantity := v_mmtt.secondary_transaction_quantity;
4707
4708 /* Begin of Bug 9569657 */
4709 IF v_mmtt.transaction_source_type_id = 9 AND v_mmtt.transaction_type_id = 4 AND v_mmtt.transaction_action_id = 4 THEN
4710 NULL;
4711 ELSE
4712 /* End of Bug 9569657 */
4713 IF (v_mmtt.secondary_transaction_quantity IS NOT NULL)
4714 AND (v_mmtt.secondary_transaction_quantity <> 0)
4715 AND (sign(v_mmtt.secondary_transaction_quantity) <> sign(v_mmtt.transaction_quantity))
4716 AND (v_mmtt.transaction_type_id not in (1004, 97)) /* Fix for 13435268 and 13536869. Do not update secondary transaction for lot uom decrease and increase txn */
4717 --Bug# 5453879 - if trx qty is 0 leave the sec qty as it is.
4718 AND (v_mmtt.transaction_quantity <> 0) THEN
4719 l_secondary_txn_quantity := sign(v_mmtt.transaction_quantity) * abs(v_mmtt.secondary_transaction_quantity);
4720 update mtl_material_transactions_temp
4721 set secondary_transaction_quantity = l_secondary_txn_quantity
4722 where transaction_temp_id = v_mmtt.transaction_temp_id;
4723 END IF;
4724 END IF; -- Bug 9569657
4725
4726 IF (v_mmtt.move_order_line_id IS NOT null ) THEN --Bug15837987 begin for those allocation type mmtt records.
4727 IF (l_debug = 1) THEN
4728 inv_log_util.TRACE('Update WHO Columns for allocation type.','INV_LPN_TRX_PUB', 1);
4729 END IF;
4730 update mtl_material_transactions_temp
4731 set last_update_date = SYSDATE,
4732 last_updated_by = FND_PROFILE.VALUE('USER_ID'),
4733 last_update_login = FND_PROFILE.VALUE('LOGIN_ID'),
4734 CREATED_BY = FND_PROFILE.VALUE('USER_ID')
4735 where transaction_temp_id = v_mmtt.transaction_temp_id;
4736 END IF; --Bug15837987 End
4737
4738 IF (l_debug = 1) THEN
4739 inv_log_util.trace('before calling java TM transaction quantity='||v_mmtt.transaction_quantity, 'INV_LPN_TRX_PUB',9);
4740 inv_log_util.trace('before calling java TM secondary transaction quantity='||l_secondary_txn_quantity, 'INV_LPN_TRX_PUB',9);
4741 inv_log_util.trace('before calling java TM primary quantity='||v_mmtt.primary_quantity, 'INV_LPN_TRX_PUB',9);
4742 END IF;
4743 /*Bug14298387,added the validation on logic locator to call pjm api GET_PHYSICAL_LOCATION*/
4744 BEGIN
4745 SELECT DECODE(NVL(PROJECT_REFERENCE_ENABLED, 2),1,1,0)
4746 INTO l_project_ref_enabled
4747 FROM MTL_PARAMETERS
4748 WHERE ORGANIZATION_ID = v_mmtt.organization_id ;
4749 EXCEPTION
4750 WHEN NO_DATA_FOUND THEN
4751 l_project_ref_enabled := 0;
4752 END;
4753 IF l_project_ref_enabled = 1 AND nvl(v_mmtt.locator_id,-1) <> -1 THEN
4754 l_phy_result := inv_projectlocator_pub.GET_PHYSICAL_LOCATION(
4755 P_ORGANIZATION_ID => v_mmtt.organization_id
4756 , P_LOCATOR_ID => v_mmtt.locator_id
4757 );
4758 IF (l_phy_result = FALSE) THEN
4759 IF (l_debug = 1) THEN
4760 inv_log_util.TRACE('Calling inv_projectlocator_pub.GET_PHYSICAL_LOCATION returned with error for locator_id'||v_mmtt.locator_id, 'INV_LPN_TRX_PUB', 9);
4761 END IF;
4762 fnd_message.set_name('INV', 'INV_INT_LOCEXP');
4763 fnd_msg_pub.ADD;
4764 RAISE fnd_api.g_exc_error;
4765 END IF;
4766 END IF;
4767 --for move order/direct org xfer/sub xfer,we need also check the transfer location
4768 IF(v_mmtt.transaction_source_type_id=4) then--move order
4769 IF l_project_ref_enabled = 1 AND nvl(v_mmtt.transfer_to_location,-1) <> -1 THEN
4770 l_phy_result := inv_projectlocator_pub.GET_PHYSICAL_LOCATION(
4771 P_ORGANIZATION_ID => v_mmtt.organization_id
4772 , P_LOCATOR_ID => v_mmtt.transfer_to_location
4773 );
4774 IF (l_phy_result = FALSE) THEN
4775 IF (l_debug = 1) THEN
4776 inv_log_util.TRACE('Calling inv_projectlocator_pub.GET_PHYSICAL_LOCATION returned with error for transfer_to_location'||v_mmtt.transfer_to_location, 'INV_LPN_TRX_PUB', 9);
4777 END IF;
4778 fnd_message.set_name('INV', 'INV_INT_LOCEXP');
4779 fnd_msg_pub.ADD;
4780 RAISE fnd_api.g_exc_error;
4781 END IF;
4782 END IF;
4783 ELSIF(v_mmtt.transaction_source_type_id=13 AND v_mmtt.transaction_action_id=2) THEN --sub xfer
4784 IF l_project_ref_enabled = 1 AND nvl(v_mmtt.transfer_to_location,-1) <> -1 THEN
4785 l_phy_result := inv_projectlocator_pub.GET_PHYSICAL_LOCATION(
4786 P_ORGANIZATION_ID => v_mmtt.organization_id
4787 , P_LOCATOR_ID => v_mmtt.transfer_to_location
4788 );
4789 IF (l_phy_result = FALSE) THEN
4790 IF (l_debug = 1) THEN
4791 inv_log_util.TRACE('Calling inv_projectlocator_pub.GET_PHYSICAL_LOCATION returned with error for transfer_to_location'||v_mmtt.transfer_to_location, 'INV_LPN_TRX_PUB', 9);
4792 END IF;
4793 fnd_message.set_name('INV', 'INV_INT_LOCEXP');
4794 fnd_msg_pub.ADD;
4795 RAISE fnd_api.g_exc_error;
4796 END IF;
4797 END IF;
4798 ELSIF(v_mmtt.transaction_source_type_id=13 AND v_mmtt.transaction_action_id=3)THEN --org direct xfer
4799 BEGIN
4800 SELECT DECODE(NVL(PROJECT_REFERENCE_ENABLED, 2),1,1,0)
4801 INTO l_project_ref_enabled
4802 FROM MTL_PARAMETERS
4803 WHERE ORGANIZATION_ID = v_mmtt.transfer_organization ;
4804 EXCEPTION
4805 WHEN NO_DATA_FOUND THEN
4806 l_project_ref_enabled := 0;
4807 END;
4808 IF l_project_ref_enabled = 1 AND nvl(v_mmtt.transfer_to_location,-1) <> -1 THEN
4809 l_phy_result := inv_projectlocator_pub.GET_PHYSICAL_LOCATION(
4810 P_ORGANIZATION_ID => v_mmtt.transfer_organization
4811 , P_LOCATOR_ID => v_mmtt.transfer_to_location
4812 );
4813 IF (l_phy_result = FALSE) THEN
4814 IF (l_debug = 1) THEN
4815 inv_log_util.TRACE('Calling inv_projectlocator_pub.GET_PHYSICAL_LOCATION returned with error for transfer_to_location'||v_mmtt.transfer_to_location, 'INV_LPN_TRX_PUB', 9);
4816 END IF;
4817 fnd_message.set_name('INV', 'INV_INT_LOCEXP');
4818 fnd_msg_pub.ADD;
4819 RAISE fnd_api.g_exc_error;
4820 END IF;
4821 END IF;
4822 END IF;
4823 --Bug14298387 end
4824 END LOOP;
4825
4826 --************* Close cursor loop into MMTT *************
4827 IF (l_debug = 1) THEN
4828 inv_log_util.TRACE('Done with MMTT cursor insrowcnt=' || insrowcnt || ' failedrowcnt=' || failedrowcnt, 'INV_LPN_TRX_PUB', 9);
4829 END IF;
4830
4831 -- Bug 3618385
4832 -- For a transaction_header_id, when there's only one batch and a record is failed in the batch
4833 -- the whole batch should fail and should not call the java TM, but l_call_tm is not set probably
4834 -- to check if we need to call the java TM. We'll call the java TM only if there's any record
4835 -- exist for the transaction_header_id in MMTT.
4836 -- Bug 3804314: Included process_flag = 'Y' as the rows in MMTT are not
4837 -- deleted for transactions coming thorugh MMTT. We will have to check
4838 -- by process code also. Otherwise, we will still call the TM.
4839 BEGIN
4840 SELECT COUNT(1)
4841 INTO l_process
4842 FROM mtl_material_transactions_temp
4843 WHERE transaction_header_id = p_trx_hdr_id
4844 AND process_flag = 'Y'
4845 AND ROWNUM < 2;
4846 IF (l_debug = 1) THEN
4847 inv_log_util.TRACE('l_process: ' || l_process, 'INV_LPN_TRX_PUB', 9);
4848 END IF;
4849 EXCEPTION
4850 WHEN NO_DATA_FOUND THEN
4851 IF (l_debug = 1) THEN
4852 inv_log_util.TRACE('No records in MMTT for trx_header_id: ' || p_trx_hdr_id || ' ,will not call JAVATM', 'INV_LPN_TRX_PUB', 9);
4853 END IF;
4854 l_process := 0;
4855 END;
4856
4857
4858 -- All preprocessing done. Call the Inventory Transactions Manager
4859 IF (fnd_api.to_boolean(l_process_trx))
4860 AND (l_process <> 0) THEN
4861 -- AND(l_call_tm) THEN
4862 -- Should all the rows in MMTT with the specified TrxHdrId be considered
4863 -- as one unit
4864 IF fnd_api.to_boolean(p_atomic) THEN
4865 l_atomic := 1;
4866 END IF;
4867
4868 IF (l_debug = 1) THEN
4869 inv_log_util.TRACE('***Calling TM **', 'INV_LPN_TRX_PUB', 9);
4870 END IF;
4871
4872 retval := inv_trx_mgr.process_trx_batch(p_trx_hdr_id, l_commit, l_atomic, NVL(p_business_flow_code, 0), ret_msgdata);
4873
4874 IF (l_debug = 1) THEN
4875 inv_log_util.TRACE('retval=' || retval || ', regmsg=' || ret_msgdata, 'INV_LPN_TRX_PUB', 9);
4876 END IF;
4877 --------------------
4878 -- Bug no 3540288
4879 -- Adding call to clear picked quantity.
4880 --------------------
4881 IF (l_debug = 1) THEN
4882 inv_log_util.trace('calling API to clear the picked quantity', 'INV_LPN_TRX_PUB',9);
4883 END IF;
4884 BEGIN
4885 inv_transfer_order_pvt.clear_picked_quantity;
4886 END;
4887 IF (l_debug = 1) THEN
4888 inv_log_util.trace('API call to clear picked quantity successful', 'INV_LPN_TRX_PUB',9);
4889 END IF;
4890 END IF;
4891
4892 IF (retval <> 0) THEN
4893 x_proc_msg := ret_msgdata;
4894
4895 IF (failedrowcnt > 0) THEN
4896 RETURN -1 * failedrowcnt;
4897 ELSE
4898 RETURN -1;
4899 END IF;
4900 END IF;
4901
4902 -- If cartonization was called make call to print
4903 -- cartonzation flow labels
4904 IF (l_is_cartonization = 1) THEN
4905 inv_label.print_label(
4906 x_return_status => ret_status
4907 , x_msg_count => ret_msgcnt
4908 , x_msg_data => ret_msgdata
4909 , x_label_status => label_status
4910 , p_api_version => 1.0
4911 , p_print_mode => 1
4912 , p_business_flow_code => 22
4913 , p_transaction_id => wms_cartnzn_wrap.get_lpns_generated_tb
4914 );
4915
4916 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
4917 IF (l_debug = 1) THEN
4918 inv_log_util.TRACE('**Error Label Printing :' || ret_status, 'INV_LPN_TRX_PUB', 1);
4919 END IF;
4920 END IF;
4921 END IF;
4922
4923 -- If any of the rows in MMTT fail return number of failed rows.
4924 IF (failedrowcnt > 0) THEN
4925 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
4926 RETURN -1 * failedrowcnt;
4927 END IF;
4928
4929 IF fnd_api.to_boolean(p_commit) THEN
4930 COMMIT WORK;
4931 END IF;
4932
4933 --
4934 -- HVERDDIN START OF ERES CHANGES
4935 --
4936 IF l_eres_enabled <> 'N' THEN
4937 -- ERES is Enabled, Verify if Transaction type is supported
4938 IF l_eres_tbl.COUNT > 0 THEN
4939 IF (l_debug = 1) THEN
4940 inv_log_util.TRACE('TBL COUNT =' || l_eres_tbl.COUNT, 'INV_LPN_TRX_PUB', 9);
4941 END IF;
4942
4943 FOR tbl_index IN 1 .. l_eres_tbl.COUNT LOOP
4944 IF (l_debug = 1) THEN
4945 inv_log_util.TRACE('counter =' || tbl_index, 'INV_LPN_TRX_PUB', 9);
4946 END IF;
4947
4948 IF (
4949 trans_eres_enabled(
4950 p_trans_action_id => l_eres_tbl(tbl_index).transaction_action_id
4951 , p_trans_source_type_id => l_eres_tbl(tbl_index).transaction_source_type_id
4952 )
4953 ) THEN
4954 IF (l_debug = 1) THEN
4955 inv_log_util.TRACE('This is an ERES enabled Event', 'INV_LPN_TRX_PUB', 1);
4956 inv_log_util.TRACE(' EVENT_NAME => ' || g_eres_event_name, 'INV_LPN_TRX_PUB', 1);
4957 inv_log_util.TRACE(' EVENT_ID => ' || l_eres_tbl(tbl_index).event_id, 'INV_LPN_TRX_PUB', 1);
4958 END IF;
4959
4960 -- Get Erecord Id
4961 qa_edr_standard.get_erecord_id(
4962 p_api_version => 1.0
4963 , p_init_msg_list => 'F'
4964 , p_event_name => g_eres_event_name
4965 , p_event_key => l_eres_tbl(tbl_index).event_id
4966 , x_return_status => ret_status
4967 , x_msg_count => ret_msgcnt
4968 , x_msg_data => ret_msgdata
4969 , x_erecord_id => l_erecord_id
4970 );
4971
4972 IF (l_debug = 1) THEN
4973 inv_log_util.TRACE('Status of Get_Erecord_Id => ' || ret_status, 'INV_LPN_TRX_PUB', 1);
4974 inv_log_util.TRACE(' Return Message => ' || ret_status, 'INV_LPN_TRX_PUB', 1);
4975 inv_log_util.TRACE('ERECORD => ' || ret_status, 'INV_LPN_TRX_PUB', 1);
4976 END IF;
4977
4978 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
4979 IF (l_debug = 1) THEN
4980 inv_log_util.TRACE(' ERROR generated from getErecordIdAPI:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
4981 END IF;
4982
4983 fnd_message.set_name('INV', 'INV_ERECORD_INVALID');
4984 fnd_msg_pub.ADD;
4985 RAISE fnd_api.g_exc_error;
4986 END IF;
4987
4988 /* If an eRecord exists, then acknowledge it
4989 ===========================================*/
4990 IF l_erecord_id IS NOT NULL THEN
4991 qa_edr_standard.send_ackn(
4992 p_api_version => 1.0
4993 , p_init_msg_list => 'F'
4994 , p_event_name => g_eres_event_name
4995 , p_event_key => l_eres_tbl(tbl_index).event_id
4996 , p_erecord_id => l_erecord_id
4997 , p_trans_status => l_trans_status
4998 , p_ackn_by => 'Inventory Transaction Manager'
4999 , p_ackn_note => 'SERVER SIDE'
5000 , p_autonomous_commit => 'F'
5001 , x_return_status => ret_status
5002 , x_msg_count => ret_msgcnt
5003 , x_msg_data => ret_msgdata
5004 );
5005
5006 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
5007 IF (l_debug = 1) THEN
5008 inv_log_util.TRACE(' Error from Send ERES ACKNOWLEDGE API:' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
5009 END IF;
5010
5011 fnd_message.set_name('INV', 'INV_ERECORD_INVALID');
5012 fnd_msg_pub.ADD;
5013 RAISE fnd_api.g_exc_error;
5014 END IF;
5015 END IF; /* IF ERECORD ID not NULL */
5016 END IF; /* IF TRANS NOT ERES SUPPORTED */
5017 END LOOP; /* LOOP THROUGH ALL ERECORDS in TBL*/
5018 END IF; /* IF ERES TBL has more than 1 row*/
5019 END IF; /* IF ERES NOT SUPPORTED */
5020
5021 -- bug 9756188 restructured the OPM code here so that for batch creation and PO receipt creation for material transactions ,
5022 -- multiple lots will each generate a workflow notification for event oracle.apps.gmi.inventory.created for which gen_object_id is passed to AME
5023 -- as well as event oracle.apps.gmi.inv.po.receipt with gen_object_id representing the lot number.
5024 -- SO commented block out below and replaced by code underneath it.
5025
5026 /* Jalaj Srivastava
5027 Raise workflow event for OPM-QM */
5028 /* FOR c1_rec IN cur_get_txn_for_opm_qm
5029 LOOP
5030 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inventory.created'
5031 ,p_event_key => c1_rec.transaction_id);
5032 IF c1_rec.transaction_source_type_id in ( inv_globals.g_sourcetype_purchaseorder
5033 ,inv_globals.g_sourcetype_rma
5034 ,inv_globals.g_sourcetype_intreq) THEN
5035 -- Bug 5361705 - Raise the opm qm quality event for every distinct lot
5036 FOR c2_rec IN cr_get_distinct_lots(c1_rec.transaction_id)
5037 LOOP
5038
5039 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inv.po.receipt'
5040 ,p_event_key => to_char(c2_rec.product_transaction_id)||'-'||to_Char(c2_rec.gen_object_id));
5041 END LOOP;
5042
5043 END IF;
5044 END LOOP; */
5045
5046
5047 /* Jalaj Srivastava
5048
5049 Raise workflow event for OPM-QM */
5050
5051 inv_log_util.TRACE(' OPM part ', 'INV_LPN_TRX_PUB', 1);
5052 FOR c1_rec IN cur_get_txn_for_opm_qm
5053 LOOP
5054
5055 inv_log_util.TRACE('in cur_get_txn_for_opm_qm - c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5056 inv_log_util.TRACE('in cur_get_txn_for_opm_qm - c1_rec.transaction_source_type_id = ' || c1_rec.transaction_source_type_id, 'INV_LPN_TRX_PUB', 1);
5057 IF c1_rec.transaction_source_type_id <> inv_globals.G_SOURCETYPE_WIP then -- -- 9756188
5058 inv_log_util.TRACE('about to raise event oracle.apps.gmi.inventory.created for NON G_SOURCETYPE_WIP for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5059 inv_log_util.TRACE(' gen_object_id = ' || l_gen_object_id, 'INV_LPN_TRX_PUB', 1);
5060 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inventory.created'
5061 --,p_event_key => c1_rec.transaction_id);
5062 ,p_event_key => to_char(c1_rec.transaction_id)||'-'||to_Char(l_gen_object_id)); -- pass a dummy gen_object_id as there is no lot for this pass
5063 end if;
5064 IF c1_rec.transaction_source_type_id in ( inv_globals.g_sourcetype_purchaseorder
5065 ,inv_globals.g_sourcetype_rma
5066 ,inv_globals.G_SOURCETYPE_WIP -- 9756188
5067 ,inv_globals.g_sourcetype_intreq) THEN
5068 -- Bug 5361705 - Raise the opm qm quality event for every distinct lot
5069 inv_log_util.TRACE('about to get into cr_get_distinct_lots - c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5070 i := 0; -- 13557341
5071 FOR c2_rec IN cr_get_distinct_lots(c1_rec.transaction_id)
5072 LOOP
5073 IF c1_rec.transaction_source_type_id = inv_globals.G_SOURCETYPE_WIP THEN -- 9756188
5074 inv_log_util.TRACE(' about to raise event oracle.apps.gmi.inventory.created for G_SOURCETYPE_WIP for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5075 inv_log_util.TRACE(' G_SOURCETYPE_WIP gen_object_id = ' || c2_rec.gen_object_id , 'INV_LPN_TRX_PUB', 1);
5076 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inventory.created'
5077 --,p_event_key => c1_rec.transaction_id);
5078 ,p_event_key => to_char(c1_rec.transaction_id)||'-'||to_Char(c2_rec.gen_object_id)); -- pass lot number as gen_object_id
5079 ELSE
5080 inv_log_util.TRACE(' about to raise event oracle.apps.gmi.inv.po.receipt for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5081 inv_log_util.TRACE(' gen_object_id = ' || c2_rec.gen_object_id , 'INV_LPN_TRX_PUB', 1);
5082 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inv.po.receipt'
5083 ,p_event_key =>to_char(c2_rec.product_transaction_id)||'-'||to_Char(c2_rec.gen_object_id));
5084 END IF;
5085 i := i + 1; -- 13557341
5086
5087 END LOOP;
5088
5089 --13557341 start if no lots found then raise event event oracle.apps.gmi.inventory.created for G_SOURCETYPE_WIP with not lot
5090 IF i = 0 then
5091 inv_log_util.TRACE('cursor cr_get_distinct_lots returns zero rows for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5092
5093 IF c1_rec.transaction_source_type_id <> inv_globals.G_SOURCETYPE_WIP then -- 13686877 start added if
5094 inv_log_util.TRACE(' about to raise event oracle.apps.gmi.inv.po.receipt for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5095 inv_log_util.TRACE(' dummy gen_object_id as there is no lot for this pass gen_object_id = ' || l_gen_object_id, 'INV_LPN_TRX_PUB', 1);
5096 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inv.po.receipt'
5097 ,p_event_key =>to_char(c1_rec.transaction_id)||'-'||to_Char(l_gen_object_id)); -- pass a dummy gen_object_id as there is no lot for this pass
5098
5099
5100 ELSE
5101 inv_log_util.TRACE('SO about to raise event oracle.apps.gmi.inventory.created for G_SOURCETYPE_WIP for c1_rec.transaction_id = ' || c1_rec.transaction_id, 'INV_LPN_TRX_PUB', 1);
5102 inv_log_util.TRACE(' dummy gen_object_id as there is no lot for this pass gen_object_id = ' || l_gen_object_id, 'INV_LPN_TRX_PUB', 1);
5103 wf_event.raise2( p_event_name => 'oracle.apps.gmi.inventory.created'
5104 ,p_event_key => to_char(c1_rec.transaction_id)||'-'||to_Char(l_gen_object_id)); -- pass a dummy gen_object_id as there is no lot for this pass
5105
5106 END IF; -- 13686877 end
5107
5108
5109 end if ; -- IF i = o then
5110 -- 13557341 end
5111
5112 END IF; -- IF c1_rec.transaction_source_type_id in ( inv_globals.g_sourcetype_purchaseorder
5113 END LOOP; -- FOR c1_rec IN cur_get_txn_for_opm_qm
5114 inv_log_util.TRACE(' @@@@@@@@@@@@@@@@@@ OPM part end @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@', 'INV_LPN_TRX_PUB', 1);
5115
5116 -- HVERDDIN END OF ERES CHANGES
5117 --
5118
5119 fnd_message.set_name('WMS', 'WMS_TXN_SUCCESS');
5120 fnd_msg_pub.ADD;
5121 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
5122 RETURN 0;
5123 EXCEPTION
5124 WHEN OTHERS THEN
5125 -- rollback to the savepoint
5126 IF (l_debug = 1) THEN
5127 inv_log_util.TRACE('ERROR : Code' || SQLCODE || ',Msg:' || SUBSTR(SQLERRM, 1, 100), 'INV_LPN_TRX_PUB', 1);
5128 END IF;
5129
5130 ROLLBACK TO process_lpn_trx;
5131 --bug 2894323 fix made changes to return all the messages in the
5132 --stack in x_proc_msg out variable
5133 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => ret_msgcnt, p_data => x_proc_msg);
5134
5135 IF ret_msgcnt IS NULL THEN
5136 ret_msgcnt := 0;
5137 END IF;
5138
5139 FOR x IN 1 .. ret_msgcnt LOOP
5140 ret_msgdata := SUBSTR(fnd_msg_pub.get(ret_msgcnt - x + 1, 'F'), 0, 200);
5141
5142 IF (l_debug = 1) THEN
5143 inv_log_util.TRACE(x || ':' || ret_msgdata, 'INV_LPN_TRX_PUB', 1);
5144 END IF;
5145
5146 IF x <> 1 THEN
5147 ret_msgdata := ' | ' || ret_msgdata;
5148 END IF;
5149
5150 l_err_msg := SUBSTR(l_err_msg || ret_msgdata, 1, 2000);
5151 END LOOP;
5152
5153 x_proc_msg := SUBSTR(l_err_msg, 1, 170);
5154 -- Update MMTT with error_code
5155 fnd_message.set_name('INV', 'INV_INT_PROCCODE');
5156 fnd_msg_pub.ADD;
5157 l_error_code := fnd_msg_pub.get(fnd_msg_pub.g_last, 'F');
5158
5159 BEGIN
5160 SELECT 1
5161 INTO l_is_from_mti
5162 FROM DUAL
5163 WHERE EXISTS(SELECT 1
5164 FROM mtl_material_transactions_temp
5165 WHERE transaction_header_id = p_trx_hdr_id
5166 AND transaction_mode = inv_txn_manager_pub.proc_mode_mti);
5167 EXCEPTION
5168 WHEN NO_DATA_FOUND THEN
5169 IF (l_debug = 1) THEN
5170 inv_log_util.TRACE('no record found in mmtt', 'INV_LPN_TRX_PUB', 1);
5171 END IF;
5172 END;
5173
5174 IF (l_is_from_mti = 1) THEN
5175 -- record originated from MTI. Update all records in MTI for this batch
5176 -- Delete from MMTT, MTLT and MSNT. Records from MTI get copied to MMTT
5177 -- in tmpinsert() in INV_TXN_MANAGER_PUB
5178 UPDATE mtl_transactions_interface
5179 SET ERROR_CODE = substrb(l_error_code,1,240)/*added substrb for 3632722*/
5180 , error_explanation = substrb(x_proc_msg,1,240)/*added substrb for 3632722*/
5181 , process_flag = 3
5182 , lock_flag = 2
5183 WHERE transaction_header_id = p_trx_hdr_id;
5184
5185 -- Remove from MSNT rows with same MMTT Transaction_header_id
5186 DELETE FROM mtl_serial_numbers_temp
5187 WHERE transaction_temp_id IN(SELECT transaction_temp_id
5188 FROM mtl_material_transactions_temp
5189 WHERE transaction_header_id = p_trx_hdr_id);
5190
5191 -- Remove from MSNT rows with same MTNT Transaction_header_id
5192 DELETE FROM mtl_serial_numbers_temp
5193 WHERE transaction_temp_id IN(SELECT serial_transaction_temp_id
5194 FROM mtl_transaction_lots_temp
5195 WHERE transaction_temp_id IN(SELECT transaction_temp_id
5196 FROM mtl_material_transactions_temp
5197 WHERE transaction_header_id = p_trx_hdr_id));
5198
5199 -- Remove from MTLT rows with same MMTT Transaction_header_id
5200 DELETE FROM mtl_transaction_lots_temp
5201 WHERE transaction_temp_id IN(SELECT transaction_temp_id
5202 FROM mtl_material_transactions_temp
5203 WHERE transaction_header_id = p_trx_hdr_id);
5204
5205 -- Remove from MMTT rows with same Transaction_header_id
5206 DELETE FROM mtl_material_transactions_temp
5207 WHERE transaction_header_id = p_trx_hdr_id;
5208 ELSE
5209 UPDATE mtl_material_transactions_temp
5210 SET ERROR_CODE = l_error_code
5211 , error_explanation = x_proc_msg
5212 , process_flag = 'E'
5213 , lock_flag = 'N'
5214 WHERE transaction_header_id = p_trx_hdr_id;
5215 END IF;
5216
5217 IF (l_debug = 1) THEN
5218 inv_log_util.TRACE('Exiting PROCESS_LPN_TRX with exception from_mti=' || l_is_from_mti || ' trx_hdr_id=' || p_trx_hdr_id
5219 , 'INV_LPN_TRX_PUB', 1);
5220 END IF;
5221
5222 RETURN -1;
5223 END process_lpn_trx;
5224
5225 /********************************************************************
5226 *
5227 * PROCESS_LPN_TRX_LINE
5228 * This procedure does all the LPN related processing on an MMTT record.
5229 * The logic in this API is based on the transaction_action and the contents
5230 * of columns LPN_ID, CONTENT_LPN_ID, and TRANSFER_LPN_ID
5231 * LPN_ID : LPN from where item/other-LPN should be unpacked
5232 * CONTENT_LPN : If the transaction is based on a whole LPN
5233 * TRANSFER_LPN : LPN to which item/other-LPN is to be packed
5234 *******************************************************************/
5235 PROCEDURE process_lpn_trx_line(
5236 x_return_status OUT NOCOPY VARCHAR2
5237 , x_proc_msg OUT NOCOPY VARCHAR2
5238 , p_transaction_temp_id IN NUMBER
5239 , p_business_flow_code IN NUMBER := NULL
5240 , p_transaction_source_type_id IN NUMBER
5241 , p_transaction_action_id IN NUMBER
5242 , p_lpn_id IN NUMBER := NULL
5243 , p_content_lpn_id IN NUMBER := NULL
5244 , p_transfer_lpn_id IN NUMBER := NULL
5245 , p_organization_id IN NUMBER
5246 , p_subinventory_code IN VARCHAR2
5247 , p_locator_id IN NUMBER := NULL
5248 , p_transfer_organization IN NUMBER := NULL
5249 , p_transfer_subinventory IN VARCHAR2 := NULL
5250 , p_transfer_to_location IN NUMBER := NULL
5251 , p_primary_quantity IN NUMBER
5252 , p_primary_uom IN VARCHAR2 := NULL
5253 , p_transaction_quantity IN NUMBER
5254 , p_transaction_uom IN VARCHAR2
5255 , p_secondary_trx_quantity IN NUMBER := NULL
5256 , p_secondary_uom_code IN VARCHAR2 := NULL
5257 , p_inventory_item_id IN NUMBER
5258 , p_revision IN VARCHAR2 := NULL
5259 , p_lot_number IN VARCHAR2 := NULL
5260 , p_cost_group_id IN NUMBER
5261 , p_transfer_cost_group_id IN NUMBER := NULL
5262 , p_rcv_transaction_id IN NUMBER := NULL
5263 , p_shipment_number IN VARCHAR2 := NULL
5264 , p_transaction_source_id IN NUMBER := NULL
5265 , p_trx_source_line_id IN NUMBER := NULL
5266 , p_serial_control_code IN NUMBER := NULL
5267 , p_po_dest_expense IN NUMBER := NULL
5268 , p_manual_receipt_expense IN VARCHAR2 := NULL
5269 , p_source_transaction_id IN NUMBER := NULL
5270 ) IS
5271 l_api_name CONSTANT VARCHAR2(30) := 'Process_LPN_Trx_Line';
5272 l_api_version CONSTANT NUMBER := 1.0;
5273 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
5274 l_progress VARCHAR2(500) := '0';
5275 l_msgdata VARCHAR2(1000);
5276 l_item_rec inv_validate.item;
5277 v_lpn wms_container_pub.lpn;
5278 v_lpn_ctx NUMBER;
5279 v_cnt_lpn_ctx NUMBER;
5280 v_xfrlpn_ctx NUMBER;
5281 v_autounpack NUMBER := 1;
5282 v_xfr_org NUMBER;
5283 l_primary_quantity NUMBER := p_primary_quantity;
5284 l_transaction_quantity NUMBER := p_transaction_quantity;
5285 l_secondary_trx_quantity NUMBER := p_secondary_trx_quantity; --INVCONV kkillams
5286 l_xfr_sub VARCHAR2(64);
5287 l_xfr_loc NUMBER;
5288 l_temp_num NUMBER;
5289 l_rcv_interface_txn_id NUMBER;
5290 l_rcv_txn_type VARCHAR2(64);
5291 label_status VARCHAR2(512);
5292 l_system_task_type NUMBER; -- bug 2879208
5293 l_ret_bool BOOLEAN;
5294 --Start of fix for Bug 4891916
5295 --Added the following variables to check for the profile value and
5296 --to pass the transaction_identifer to the label label printing api
5297 l_print_label NUMBER := NVL(FND_PROFILE.VALUE('WMS_LABEL_FOR_CYCLE_COUNT'),2);
5298 l_transaction_identifier NUMBER := NULL ;
5299 --End of fix for Bug 4891916
5300
5301 l_cyclpn_id NUMBER := NULL; --Bug#6043776
5302 l_lpn_ctx_tmp NUMBER ; --Bug 6007873
5303
5304 --Bug 6374764
5305 l_sub VARCHAR2(30);
5306 l_loc_id number;
5307
5308 --BUG13578531 Begin
5309 l_wlpn_sub VARCHAR2(30);
5310 l_wlpn_loc_id NUMBER;
5311 --BUG13578531 End
5312 --Bug 9740452
5313 l_transaction_type_id NUMBER;
5314 l_business_flow_code NUMBER;
5315 l_reservation_id NUMBER; --9869993
5316
5317 l_loaded_tasks_count NUMBER := 0; -- Added for bug 7010169
5318 l_trx_hdr_id NUMBER := 0; -- Added for bug 7010169
5319
5320 -- Start of bug 7226314, 7355087
5321
5322 l_lpn_name VARCHAR2(30);
5323 l_status_code VARCHAR2(1);
5324 l_delivery_id NUMBER;
5325 l_xfrlpn_ctx NUMBER;
5326 l_delivery_detail_id NUMBER;
5327 l_container_name wsh_delivery_details.container_name%TYPE;
5328 l_container_new_name wsh_delivery_details.container_name%TYPE;
5329 l_container_flag wsh_delivery_details.container_flag%TYPE;
5330 l_container_rec wsh_container_grp.changedattributetabtype;
5331
5332 l_rtv_transaction_id NUMBER ;--RTV Change 16197273
5333 l_source_header_id NUMBER :=NULL ;
5334 l_source_name VARCHAR2(100) := NULL ;
5335
5336 CURSOR c_wdd_exists(p_transfer_lpn_id NUMBER,p_organization_id NUMBER) is
5337 SELECT distinct wda.delivery_id,wdd.delivery_detail_id,wdd.released_status
5338 FROM wsh_delivery_details wdd, wsh_delivery_assignments wda
5339 WHERE wdd.lpn_id IN (select lpn_id from wms_license_plate_numbers
5340 where organization_id = p_organization_id
5341 and (lpn_id = p_transfer_lpn_id
5342 or parent_lpn_id = p_transfer_lpn_id
5343 or outermost_lpn_id = p_transfer_lpn_id))
5344 AND wda.parent_delivery_detail_id = wdd.delivery_detail_id;
5345
5346 -- End of bug 7226314,7355087
5347
5348 CURSOR c_rtv_exists (p_lpn_id NUMBER ,p_organization_id NUMBER ) IS --RTV Change 16197273
5349 SELECT interface_transaction_id FROM rcv_transactions_interface rti,wms_lpn_contents wlc
5350 WHERE rti.interface_transaction_id = wlc.source_header_id
5351 AND rti.processing_status_code = 'WSH_INTERFACED'
5352 AND rti.to_organization_id = wlc.organization_id
5353 AND wlc.parent_lpn_id = p_lpn_id
5354 AND ROWNUM < 2 ;
5355
5356
5357 BEGIN
5358 IF (l_debug = 1) THEN
5359 inv_log_util.TRACE(
5360 'Call to PROCESS_LPN_TRX_LINE trxtmpid='
5361 || p_transaction_temp_id
5362 || ' flwcode='
5363 || p_business_flow_code
5364 || ' srctype='
5365 || p_transaction_source_type_id
5366 || ' actid='
5367 || p_transaction_action_id
5368 , 'INV_LPN_TRX_PUB'
5369 , 9
5370 );
5371 inv_log_util.TRACE(
5372 'lpn='
5373 || p_lpn_id
5374 || ' cntlpn='
5375 || p_content_lpn_id
5376 || ' xfrlpn='
5377 || p_transfer_lpn_id
5378 || ' orgid='
5379 || p_organization_id
5380 || ' sub='
5381 || p_subinventory_code
5382 || ' loc='
5383 || p_locator_id
5384 , 'INV_LPN_TRX_PUB'
5385 , 9
5386 );
5387 inv_log_util.TRACE(
5388 'xfrorg='
5389 || p_transfer_organization
5390 || ' xfrsub='
5391 || p_transfer_subinventory
5392 || ' xfrloc='
5393 || p_transfer_to_location
5394 || ' priqty='
5395 || p_primary_quantity
5396 || ' trxqty='
5397 || p_transaction_quantity
5398 || ' uom='
5399 || p_transaction_uom
5400 , 'INV_LPN_TRX_PUB'
5401 , 9
5402 );
5403 inv_log_util.TRACE(
5404 'item='
5405 || p_inventory_item_id
5406 || ' rev='
5407 || p_revision
5408 || ' lot='
5409 || p_lot_number
5410 || ' cg='
5411 || p_cost_group_id
5412 || ' rcvtrxid='
5413 || p_rcv_transaction_id
5414 || ' shipnum='
5415 || p_shipment_number
5416 , 'INV_LPN_TRX_PUB'
5417 , 9
5418 );
5419 inv_log_util.TRACE(
5420 'srcid='
5421 || p_transaction_source_id
5422 || ' slnid='
5423 || p_trx_source_line_id
5424 || ' qty2='
5425 || p_secondary_trx_quantity
5426 || ' uom2='
5427 || p_secondary_uom_code
5428 || ' podst='
5429 || p_po_dest_expense
5430 || ' rcptex='
5431 || p_manual_receipt_expense
5432 || ' strxid='
5433 || p_source_transaction_id
5434 , 'INV_LPN_TRX_PUB'
5435 , 9
5436 );
5437 END IF;
5438
5439 x_return_status := fnd_api.g_ret_sts_success;
5440
5441 --SAVEPOINT PROCESS_LPN_TRX_LINE;
5442
5443 IF inv_cache.set_item_rec(p_organization_id => p_organization_id, p_item_id => p_inventory_item_id) THEN
5444 IF inv_cache.item_rec.tracking_quantity_ind = 'PS' THEN
5445 IF l_secondary_trx_quantity IS NULL THEN
5446 IF inv_cache.item_rec.secondary_default_ind = 'F' THEN
5447 l_secondary_trx_quantity := inv_convert.inv_um_convert(
5448 item_id => p_inventory_item_id
5449 , lot_number => p_lot_number
5450 , organization_id => p_organization_id
5451 , precision => NULL
5452 , from_quantity => p_primary_quantity
5453 , from_unit => p_primary_uom
5454 , to_unit => p_secondary_uom_code
5455 , from_name => NULL
5456 , to_name => NULL
5457 );
5458 ELSE
5459 l_secondary_trx_quantity := 0;
5460 END IF;
5461 END IF; -- sec qty is NULL
5462 END IF; -- item qty tracking is 'PS'
5463 END IF;
5464
5465 -- Continue with this record ONLY if atleast one of the field
5466 -- lpn_id, content_lpn_id, transfer_lpn_id is NOT NULL
5467 IF NOT((p_lpn_id IS NULL)
5468 AND(p_content_lpn_id IS NULL)
5469 AND(p_transfer_lpn_id IS NULL)) THEN
5470 -- Retrieve item properties if not passed by TM: used by bug 3158847 as well
5471 IF (p_inventory_item_id > 0) THEN
5472 IF (p_primary_uom IS NULL
5473 OR p_serial_control_code IS NULL) THEN
5474 l_progress := 'Calling INV_CACHE.Set_Item_Rec to get item values';
5475 l_ret_bool := inv_cache.set_item_rec(p_organization_id => p_organization_id, p_item_id => p_inventory_item_id);
5476
5477 IF (l_ret_bool) THEN
5478 l_progress := 'Found item assigning it to l_item_rec';
5479 l_item_rec := inv_cache.item_rec;
5480
5481 IF (l_debug = 1) THEN
5482 inv_log_util.TRACE(
5483 'Got item properties puom=' || l_item_rec.primary_uom_code || ' sctl=' || l_item_rec.serial_number_control_code
5484 , 'INV_LPN_TRX_PUB'
5485 , 9
5486 );
5487 END IF;
5488 ELSE --failed to get item info
5489 l_progress := 'Error calling INV_CACHE.Set_Item_Rec to get item info';
5490 RAISE fnd_api.g_exc_unexpected_error;
5491 END IF;
5492 ELSE --Values already passed, assign to item rec type
5493 l_item_rec.organization_id := p_organization_id;
5494 l_item_rec.inventory_item_id := p_inventory_item_id;
5495 l_item_rec.primary_uom_code := p_primary_uom;
5496 l_item_rec.serial_number_control_code := p_serial_control_code;
5497 l_item_rec.secondary_uom_code := p_secondary_uom_code; -- INVCONV kkillams
5498 END IF;
5499 END IF;
5500
5501 -- If the transaction action is either Issue or Intransit Shipment, and
5502 -- the sign of quantity is not -ve, make it -ve.
5503 IF (
5504 (
5505 (p_transaction_action_id = inv_globals.g_action_issue)
5506 OR(p_transaction_action_id = inv_globals.g_action_intransitshipment)
5507 OR(p_transaction_action_id = inv_globals.g_action_intransitshipment)
5508 OR(p_transaction_action_id = inv_globals.g_action_intransitshipment)
5509 OR(p_transaction_action_id = inv_globals.g_action_intransitshipment)
5510 )
5511 AND(p_primary_quantity > 0)
5512 ) THEN
5513 l_primary_quantity := -1 * p_primary_quantity;
5514 l_transaction_quantity := -1 * p_transaction_quantity;
5515 l_secondary_trx_quantity := CASE WHEN l_secondary_trx_quantity IS NOT NULL THEN -1 * l_secondary_trx_quantity
5516 ELSE l_secondary_trx_quantity
5517 END; --INVCONV kkillams
5518 END IF;
5519
5520 IF (
5521 (
5522 (p_transaction_action_id = inv_globals.g_action_subxfr)
5523 OR(p_transaction_action_id = inv_globals.g_action_orgxfr)
5524 OR(p_transaction_action_id = inv_globals.g_action_stgxfr)
5525 OR(p_transaction_action_id = inv_globals.g_action_costgroupxfr)
5526 OR(p_transaction_action_id = inv_globals.g_action_planxfr)
5527 OR(p_transaction_action_id = inv_globals.g_action_containerpack)
5528 OR(p_transaction_action_id = inv_globals.g_action_containerunpack)
5529 OR(p_transaction_action_id = inv_globals.g_action_containersplit)
5530 )
5531 AND(p_primary_quantity < 0)
5532 ) THEN
5533 l_primary_quantity := -1 * p_primary_quantity;
5534 l_transaction_quantity := -1 * p_transaction_quantity;
5535 l_secondary_trx_quantity := CASE WHEN l_secondary_trx_quantity IS NOT NULL THEN -1 * l_secondary_trx_quantity
5536 ELSE l_secondary_trx_quantity
5537 END; --INVCONV kkillams
5538 END IF;
5539
5540 -- WMS Correction changes.
5541 -- MMTT will have a transaction_action_id of
5542 -- G_Action_DeliveryAdj for a source type of PO or RMA
5543 -- IDS: Logical Transactions for lot and serials - Opened up TM to
5544 -- handle logical receipts and logical corrections.
5545 IF (
5546 (
5547 p_transaction_action_id = inv_globals.g_action_deliveryadj
5548 AND(
5549 p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
5550 OR p_transaction_source_type_id = inv_globals.g_sourcetype_rma
5551 )
5552 )
5553 OR(
5554 p_transaction_action_id = inv_globals.g_action_logicaldeladj
5555 AND p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
5556 )
5557 ) THEN
5558 -- Corrections. Need to retrieve interface_transaction_id and transaction_type
5559 BEGIN
5560 SELECT interface_transaction_id
5561 , transaction_type
5562 INTO l_rcv_interface_txn_id
5563 , l_rcv_txn_type
5564 FROM rcv_transactions
5565 WHERE transaction_id = p_rcv_transaction_id;
5566 EXCEPTION
5567 WHEN OTHERS THEN
5568 l_rcv_interface_txn_id := NULL;
5569 l_rcv_txn_type := NULL;
5570 END;
5571
5572 IF (l_debug = 1) THEN
5573 inv_log_util.TRACE('** transaction_type=' || l_rcv_txn_type, 'INV_LPN_TRX_PUB', 9);
5574 END IF;
5575
5576 IF (l_rcv_txn_type = 'CORRECT') THEN
5577 IF (l_primary_quantity < 0) THEN -- -ve correction on delivery
5578 IF (l_debug = 1) THEN
5579 inv_log_util.TRACE('** -ve correction on delivery unpacking', 'INV_LPN_TRX_PUB', 9);
5580 END IF;
5581
5582 -- Unpack items from lpn
5583 -- IF p_transfer_lpn_id IS NOT NULL THEN
5584 IF (p_transfer_lpn_id IS NOT NULL) AND((NVL(p_lpn_id, 0) <> p_transfer_lpn_id)) THEN --14547482
5585
5586
5587 -- delivery could have been done as loose
5588 Call_Pack_Unpack (
5589 p_tempid => p_transaction_temp_id
5590 , p_content_lpn => p_content_lpn_id
5591 , p_lpn => p_transfer_lpn_id
5592 , p_item_rec => l_item_rec
5593 , p_revision => p_revision
5594 , p_primary_qty => ABS(l_primary_quantity)
5595 , p_qty => ABS(l_transaction_quantity)
5596 , p_uom => p_transaction_uom
5597 , p_org_id => p_organization_id
5598 , p_subinv => p_subinventory_code
5599 , p_locator => p_locator_id
5600 , p_operation => g_unpack
5601 , p_cost_grp_id => p_cost_group_id
5602 , p_trx_action => p_transaction_action_id
5603 , p_source_header_id => NULL
5604 , p_source_name => NULL
5605 , p_source_type_id => NULL
5606 , p_sec_qty => ABS(l_secondary_trx_quantity) --INVCONV kkillams
5607 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5608 , p_source_trx_id => p_source_transaction_id
5609 );
5610 END IF;
5611
5612 IF (l_debug = 1) THEN
5613 inv_log_util.TRACE('** -ve correction on delivery packing', 'INV_LPN_TRX_PUB', 9);
5614 END IF;
5615
5616
5617 IF ((NVL(p_lpn_id, 0) <> NVL(p_transfer_lpn_id,0))) THEN ----14547482
5618 -- Repack items into transfer lpn nulling cost group,sub and locator
5619 Call_Pack_Unpack (
5620 p_tempid => p_transaction_temp_id
5621 , p_content_lpn => p_content_lpn_id
5622 , p_lpn => p_lpn_id
5623 , p_item_rec => l_item_rec
5624 , p_revision => p_revision
5625 , p_primary_qty => ABS(l_primary_quantity)
5626 , p_qty => ABS(l_transaction_quantity)
5627 , p_uom => p_transaction_uom
5628 , p_org_id => p_organization_id
5629 , p_subinv => NULL
5630 , p_locator => NULL
5631 , p_operation => g_pack
5632 , p_cost_grp_id => NULL
5633 , p_trx_action => p_transaction_action_id
5634 , p_source_header_id => NULL
5635 , p_source_name => NULL
5636 , p_source_type_id => NULL
5637 , p_sec_qty => ABS(l_secondary_trx_quantity) --INVCONV kkillams
5638 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5639 , p_source_trx_id => p_source_transaction_id
5640 );
5641
5642 END IF;
5643
5644 -- Update the context of lpn to resides in receiving
5645 -- if it's a adj of whole lpn. lpn_id = transfer_lpn_id
5646 IF (p_lpn_id = p_transfer_lpn_id) THEN
5647 UPDATE wms_license_plate_numbers
5648 SET lpn_context = wms_container_pub.lpn_context_rcv
5649 WHERE lpn_id = p_lpn_id;
5650 END IF;
5651 ELSE
5652 IF (l_debug = 1) THEN
5653 inv_log_util.TRACE('** +ve correction on delivery', 'INV_LPN_TRX_PUB', 9);
5654 END IF;
5655
5656 -- Unpack items from lpn with null sub, locator and cost group
5657 Call_Pack_Unpack (
5658 p_tempid => p_transaction_temp_id
5659 , p_content_lpn => p_content_lpn_id
5660 , p_lpn => p_lpn_id
5661 , p_item_rec => l_item_rec
5662 , p_revision => p_revision
5663 , p_primary_qty => ABS(l_primary_quantity)
5664 , p_qty => ABS(l_transaction_quantity)
5665 , p_uom => p_transaction_uom
5666 , p_org_id => p_organization_id
5667 , p_subinv => NULL
5668 , p_locator => NULL
5669 , p_operation => g_unpack
5670 , p_cost_grp_id => NULL
5671 , p_trx_action => p_transaction_action_id
5672 , p_source_header_id => NULL
5673 , p_source_name => NULL
5674 , p_source_type_id => NULL
5675 , p_sec_qty => ABS(l_secondary_trx_quantity) --INVCONV kkillams
5676 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5677 , p_source_trx_id => p_source_transaction_id
5678 );
5679
5680 IF (l_debug = 1) THEN
5681 inv_log_util.TRACE('** +ve correction on delivery packing', 'INV_LPN_TRX_PUB', 9);
5682 END IF;
5683
5684 IF p_transfer_lpn_id IS NOT NULL THEN
5685 -- Repack items into transfer lpn if it is not null
5686 Call_Pack_Unpack (
5687 p_tempid => p_transaction_temp_id
5688 , p_content_lpn => p_content_lpn_id
5689 , p_lpn => p_transfer_lpn_id
5690 , p_item_rec => l_item_rec
5691 , p_revision => p_revision
5692 , p_primary_qty => ABS(l_primary_quantity)
5693 , p_qty => ABS(l_transaction_quantity)
5694 , p_uom => p_transaction_uom
5695 , p_org_id => p_organization_id
5696 , p_subinv => p_subinventory_code
5697 , p_locator => p_locator_id
5698 , p_operation => g_pack
5699 , p_cost_grp_id => p_cost_group_id
5700 , p_trx_action => p_transaction_action_id
5701 , p_source_header_id => NULL
5702 , p_source_name => NULL
5703 , p_source_type_id => NULL
5704 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams.
5705 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5706 , p_source_trx_id => p_source_transaction_id
5707 );
5708 END IF;
5709 END IF;
5710 END IF;
5711 END IF;
5712
5713 /***** ISSUE/LotSplit/LotMerge/Cycle,PhysicalCnt/IntransitShipment trx ****/
5714 IF (p_transaction_action_id = inv_globals.g_action_issue)
5715 OR((p_transaction_action_id = inv_globals.g_action_inv_lot_split)
5716 AND(l_primary_quantity < 0))
5717 OR((p_transaction_action_id = inv_globals.g_action_inv_lot_translate)
5718 AND(l_primary_quantity < 0))
5719 OR((p_transaction_action_id = inv_globals.g_action_inv_lot_merge)
5720 AND(l_primary_quantity < 0))
5721 OR(p_transaction_action_id = inv_globals.g_action_intransitshipment)
5722 OR((p_transaction_action_id = inv_globals.g_action_cyclecountadj)
5723 AND l_primary_quantity < 0)
5724 OR ((p_transaction_action_id = inv_globals.g_action_assyreturn)
5725 AND l_primary_quantity < 0) --bug#9223918
5726 OR((p_transaction_action_id = inv_globals.g_action_physicalcountadj)
5727 AND l_primary_quantity < 0) THEN
5728 IF (l_debug = 1) THEN
5729 inv_log_util.TRACE(' Action = Issue, lpn=' || p_lpn_id || ',qty=' || l_primary_quantity, 'INV_LPN_TRX_PUB', 9);
5730 END IF;
5731
5732 IF (p_content_lpn_id IS NOT NULL) THEN
5733 -- This is an Issue of LPN from system
5734 IF (l_debug = 1) THEN
5735 inv_log_util.TRACE('** content_lpn_id Not null:' || p_content_lpn_id, 'INV_LPN_TRX_PUB', 9);
5736 END IF;
5737
5738 v_lpn.lpn_id := p_content_lpn_id;
5739
5740 IF (
5741 p_transaction_action_id = inv_globals.g_action_intransitshipment
5742 OR(p_transaction_action_id = inv_globals.g_action_issue
5743 AND p_transaction_source_type_id = inv_globals.g_sourcetype_intorder)
5744 ) THEN
5745 IF (p_po_dest_expense = 1 AND (nvl(p_manual_receipt_expense,'N') <> 'Y')) THEN -- 8491908
5746 -- Bug4663000 instead of unpacking expense contents.
5747 -- Change context of LPN to issued out of stores, but only if the
5748 -- context for the LPN is not already "intransit". Assuming that if
5749 -- LPN is in intransit state, that the LPN has non expense items in them
5750 IF ( v_cnt_lpn_ctx IS NULL ) THEN
5751 SELECT lpn_context
5752 INTO v_cnt_lpn_ctx
5753 FROM wms_license_plate_numbers
5754 WHERE lpn_id = p_content_lpn_id;
5755
5756 IF (l_debug = 1) THEN
5757 inv_log_util.TRACE('Got v_cnt_lpn_ctx='||v_cnt_lpn_ctx, 'INV_LPN_TRX_PUB', 9);
5758 END IF;
5759 END IF;
5760
5761 IF ( v_cnt_lpn_ctx <> wms_container_pub.lpn_context_intransit ) THEN
5762 v_lpn.lpn_context := wms_container_pub.lpn_context_stores;
5763 END IF;
5764 ELSE
5765 -- For manual rcpt, both Inventory and Expense Internal orders lpns context
5766 -- should be marked as intransit for recieving
5767 v_lpn.lpn_context := wms_container_pub.lpn_context_intransit;
5768 END IF;
5769 ELSIF(p_transaction_action_id = inv_globals.g_action_issue
5770 AND p_transaction_source_type_id = inv_globals.g_sourcetype_wip) THEN
5771 -- For WIP Issues the LPN set to be defined but not used
5772 v_lpn.lpn_context := wms_container_pub.lpn_context_pregenerated;
5773
5774 IF (l_debug = 1) THEN
5775 inv_log_util.TRACE('WIP Issue, unpack all items', 'INV_LPN_TRX_PUB', 9);
5776 END IF;
5777 --Bug 16245192 start
5778 SELECT subinventory_code, locator_id
5779 INTO l_wlpn_sub, l_wlpn_loc_id
5780 FROM wms_license_plate_numbers
5781 WHERE lpn_id = p_content_lpn_id;
5782
5783 IF (l_debug = 1) THEN
5784 inv_log_util.TRACE('p_content_lpn_id: '||p_content_lpn_id , 'INV_LPN_TRX_PUB', 1);
5785 inv_log_util.TRACE('LPN Sub: '||l_wlpn_sub , 'INV_LPN_TRX_PUB', 1);
5786 inv_log_util.TRACE('LPN Loc: '||l_wlpn_loc_id, 'INV_LPN_TRX_PUB', 1);
5787 inv_log_util.TRACE('p_subinventory_code: '||p_subinventory_code, 'INV_LPN_TRX_PUB', 1);
5788 inv_log_util.TRACE('p_locator_id: '||p_locator_id, 'INV_LPN_TRX_PUB', 1);
5789 END IF;
5790 --Bug 16245192 end
5791
5792 -- LPN must be unpacked into the current sub
5793 WMS_Container_PVT.PackUnpack_Container(
5794 p_api_version => 1.0
5795 , p_init_msg_list => fnd_api.g_false
5796 , p_commit => fnd_api.g_false
5797 , p_validation_level => fnd_api.g_valid_level_none
5798 , x_return_status => ret_status
5799 , x_msg_count => ret_msgcnt
5800 , x_msg_data => ret_msgdata
5801 , p_caller => 'INV_TRNSACTION'
5802 , p_lpn_id => p_content_lpn_id
5803 , p_organization_id => p_organization_id
5804 , p_subinventory => Nvl(l_wlpn_sub, p_subinventory_code) -- p_subinventory_code --Bug 16245192
5805 , p_locator_id => Nvl(l_wlpn_loc_id, p_locator_id) --p_locator_id --Bug 16245192
5806 , p_operation => g_unpack_all
5807 , p_source_transaction_id => p_source_transaction_id );
5808
5809 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
5810 IF (l_debug = 1) THEN
5811 inv_log_util.TRACE('**Error Full unpack for wip issue:' || ret_status, 'INV_LPN_TRX_PUB', 1);
5812 END IF;
5813
5814 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
5815 fnd_msg_pub.ADD;
5816 RAISE fnd_api.g_exc_error;
5817 END IF;
5818 --13884722
5819 ELSIF(p_transaction_action_id = inv_globals.g_action_issue
5820 AND p_transaction_source_type_id= inv_globals.g_sourcetype_moveorder
5821 AND p_lpn_id IS NOT NULL AND p_lpn_id <> NVL(p_transfer_lpn_id,-9999)) THEN
5822 v_lpn.lpn_context := wms_container_pub.lpn_context_stores;
5823
5824 IF (l_debug = 1) THEN
5825 inv_log_util.TRACE('MO Issue, unpack the content LPN', 'INV_LPN_TRX_PUB', 9);
5826 END IF;
5827
5828 -- LPN must be unpacked from the current parent LPN
5829 WMS_Container_PVT.PackUnpack_Container(
5830 p_api_version => 1.0
5831 , p_init_msg_list => fnd_api.g_false
5832 , p_commit => fnd_api.g_false
5833 , p_validation_level => fnd_api.g_valid_level_none
5834 , x_return_status => ret_status
5835 , x_msg_count => ret_msgcnt
5836 , x_msg_data => ret_msgdata
5837 , p_caller => 'INV_TRNSACTION'
5838 , p_lpn_id => p_lpn_id
5839 , p_content_lpn_id => p_content_lpn_id
5840 , p_organization_id => p_organization_id
5841 , p_subinventory => p_subinventory_code
5842 , p_locator_id => p_locator_id
5843 , p_operation => g_unpack
5844 , p_source_transaction_id => p_source_transaction_id );
5845
5846 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
5847 IF (l_debug = 1) THEN
5848 inv_log_util.TRACE('**Error During unpacking Content LPN for MO issue:' || ret_status, 'INV_LPN_TRX_PUB', 1);
5849 END IF;
5850
5851 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
5852 fnd_msg_pub.ADD;
5853 RAISE fnd_api.g_exc_error;
5854 END IF;
5855 --13884722
5856 ELSE
5857 v_lpn.lpn_context := wms_container_pub.lpn_context_stores; --ISSUED OUT
5858 END IF;
5859
5860 -- For an Intransit Shipment, update the LPN with the shipmentNumber
5861 -- so that this LPN can be tracked during the corresponding receipt
5862 IF (p_transaction_action_id = inv_globals.g_action_intransitshipment) THEN
5863 v_lpn.source_name := p_shipment_number;
5864 END IF;
5865
5866 inv_log_util.TRACE('** 3361969 setting lpn org id to : ' || p_organization_id, 'INV_LPN_TRX_PUB', 9);
5867 v_lpn.organization_id := p_organization_id;
5868 v_lpn.subinventory_code := NULL;
5869 v_lpn.locator_id := NULL;
5870 v_lpn.inventory_item_id := NULL;
5871 update_lpn_status(v_lpn);
5872
5873 IF (l_debug = 1) THEN
5874 inv_log_util.TRACE('*** Issued out LPN :' || p_content_lpn_id, 'INV_LPN_TRX_PUB', 9);
5875 END IF;
5876 ELSIF(
5877 p_transaction_action_id = inv_globals.g_action_issue
5878 AND(
5879 p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
5880 OR p_transaction_source_type_id = inv_globals.g_sourcetype_rma
5881 )
5882 ) THEN
5883 -- Return or corrections. Need to retrieve interface_transaction_id and transaction_type
5884 BEGIN
5885 SELECT interface_transaction_id
5886 , transaction_type
5887 INTO l_rcv_interface_txn_id
5888 , l_rcv_txn_type
5889 FROM (SELECT interface_transaction_id
5890 , transaction_type
5891 , creation_date
5892 FROM rcv_transactions
5893 WHERE interface_transaction_id = (SELECT interface_transaction_id
5894 FROM rcv_transactions
5895 WHERE transaction_id = p_rcv_transaction_id)
5896 ORDER BY transaction_id DESC)
5897 WHERE ROWNUM < 2;
5898 --SELECT interface_transaction_id, transaction_type
5899 --INTO l_rcv_interface_txn_id, l_rcv_txn_type
5900 --FROM rcv_transactions
5901 --WHERE transaction_id = p_rcv_transaction_id;
5902 EXCEPTION
5903 WHEN OTHERS THEN
5904 l_rcv_interface_txn_id := NULL;
5905 l_rcv_txn_type := NULL;
5906 END;
5907
5908 IF (l_rcv_txn_type = 'RETURN TO RECEIVING') THEN
5909 --6374764:While returning to receiving, stamp lpn with the sub and loc
5910 --stamped on the corresponding RT record.
5911 --p_rcv_transaction_id corresponds to the Return transaction.
5912 select subinventory,locator_id
5913 into l_sub,l_loc_id
5914 from rcv_transactions
5915 where transaction_id = p_rcv_transaction_id;
5916
5917 IF (p_lpn_id IS NULL
5918 AND p_transfer_lpn_id IS NOT NULL) THEN
5919 -- Change context of transfer lpn to recieving
5920 UPDATE wms_license_plate_numbers
5921 SET lpn_context = wms_container_pub.lpn_context_rcv
5922 , subinventory_code = nvl(l_sub,subinventory_code) --6374764
5923 , locator_id = nvl(l_loc_id,locator_id) --6374764
5924 WHERE lpn_id = p_transfer_lpn_id;
5925
5926 -- Pack items into transfer lpn
5927 Call_Pack_Unpack (
5928 p_tempid => p_transaction_temp_id
5929 , p_content_lpn => p_content_lpn_id
5930 , p_lpn => p_transfer_lpn_id
5931 , p_item_rec => l_item_rec
5932 , p_revision => p_revision
5933 , p_primary_qty => ABS(l_primary_quantity)
5934 , p_qty => ABS(l_transaction_quantity)
5935 , p_uom => p_transaction_uom
5936 , p_org_id => p_organization_id
5937 , p_subinv => NULL
5938 , p_locator => NULL
5939 , p_operation => g_pack
5940 , p_cost_grp_id => NULL
5941 , p_trx_action => p_transaction_action_id
5942 , p_source_header_id => NULL
5943 , p_source_name => NULL
5944 , p_source_type_id => NULL
5945 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
5946 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5947 , p_source_trx_id => p_source_transaction_id
5948 );
5949 ELSIF(p_lpn_id <> p_transfer_lpn_id) THEN
5950 -- Unpack items from lpn with appropriate source name and trx action id
5951 Call_Pack_Unpack (
5952 p_tempid => p_transaction_temp_id
5953 , p_content_lpn => p_content_lpn_id
5954 , p_lpn => p_lpn_id
5955 , p_item_rec => l_item_rec
5956 , p_revision => p_revision
5957 , p_primary_qty => ABS(l_primary_quantity)
5958 , p_qty => ABS(l_transaction_quantity)
5959 , p_uom => p_transaction_uom
5960 , p_org_id => p_organization_id
5961 , p_subinv => p_subinventory_code
5962 , p_locator => p_locator_id
5963 , p_operation => g_unpack
5964 , p_cost_grp_id => p_cost_group_id
5965 , p_trx_action => p_transaction_action_id
5966 , p_source_header_id => l_rcv_interface_txn_id
5967 , p_source_name => l_rcv_txn_type
5968 , p_source_type_id => NULL
5969 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
5970 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
5971 , p_source_trx_id => p_source_transaction_id
5972 );
5973
5974 -- Change context of transfer lpn to recieving
5975 UPDATE wms_license_plate_numbers
5976 SET lpn_context = wms_container_pub.lpn_context_rcv
5977 , subinventory_code = nvl(l_sub,subinventory_code) --6374764
5978 , locator_id = nvl(l_loc_id,locator_id) --6374764
5979 WHERE lpn_id = p_transfer_lpn_id;
5980
5981 -- Repack items into transfer lpn
5982 -- changing source name, souce header, and cost group id to null
5983 -- Also changing the sub AND locator
5984 Call_Pack_Unpack (
5985 p_tempid => p_transaction_temp_id
5986 , p_content_lpn => p_content_lpn_id
5987 , p_lpn => p_transfer_lpn_id
5988 , p_item_rec => l_item_rec
5989 , p_revision => p_revision
5990 , p_primary_qty => ABS(l_primary_quantity)
5991 , p_qty => ABS(l_transaction_quantity)
5992 , p_uom => p_transaction_uom
5993 , p_org_id => p_organization_id
5994 , p_subinv => NULL
5995 , p_locator => NULL
5996 , p_operation => g_pack
5997 , p_cost_grp_id => NULL
5998 , p_trx_action => p_transaction_action_id
5999 , p_source_header_id => NULL
6000 , p_source_name => NULL
6001 , p_source_type_id => NULL
6002 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6003 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6004 , p_source_trx_id => p_source_transaction_id
6005 );
6006 ELSE
6007 --lpn is same as transfer lpn just need to null the source name,
6008 --source header id and cost group columns for all items inside
6009 --that lpn.
6010 UPDATE wms_lpn_contents
6011 SET source_name = NULL
6012 , source_header_id = NULL
6013 , cost_group_id = NULL
6014 WHERE parent_lpn_id = p_lpn_id;
6015
6016 -- Change context of transfer lpn to recieving
6017 UPDATE wms_license_plate_numbers
6018 SET lpn_context = wms_container_pub.lpn_context_rcv
6019 , subinventory_code = nvl(l_sub,subinventory_code) --6374764
6020 , locator_id = nvl(l_loc_id,locator_id) --6374764
6021 WHERE lpn_id = p_lpn_id;
6022
6023 --Same needs to be done in the serial numbers table
6024 UPDATE mtl_serial_numbers
6025 SET cost_group_id = NULL
6026 WHERE lpn_id = p_lpn_id;
6027 END IF;
6028 ELSIF(l_rcv_txn_type = 'RETURN TO VENDOR'
6029 OR l_rcv_txn_type = 'RETURN TO CUSTOMER') THEN
6030 -- Unpack items from lpn with appropriate source name and trx action id
6031 Call_Pack_Unpack (
6032 p_tempid => p_transaction_temp_id
6033 , p_content_lpn => p_content_lpn_id
6034 , p_lpn => p_lpn_id
6035 , p_item_rec => l_item_rec
6036 , p_revision => p_revision
6037 , p_primary_qty => ABS(l_primary_quantity)
6038 , p_qty => ABS(l_transaction_quantity)
6039 , p_uom => p_transaction_uom
6040 , p_org_id => p_organization_id
6041 , p_subinv => p_subinventory_code
6042 , p_locator => p_locator_id
6043 , p_operation => g_unpack
6044 , p_cost_grp_id => p_cost_group_id
6045 , p_trx_action => p_transaction_action_id
6046 , p_source_header_id => l_rcv_interface_txn_id
6047 , p_source_name => l_rcv_txn_type
6048 , p_source_type_id => NULL
6049 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6050 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6051 , p_source_trx_id => p_source_transaction_id
6052 );
6053 ELSIF(l_rcv_txn_type = 'CORRECT') THEN
6054 IF (p_lpn_id <> p_transfer_lpn_id) THEN
6055 -- Unpack items from lpn with null source name and trx action id
6056 Call_Pack_Unpack (
6057 p_tempid => p_transaction_temp_id
6058 , p_content_lpn => p_content_lpn_id
6059 , p_lpn => p_lpn_id
6060 , p_item_rec => l_item_rec
6061 , p_revision => p_revision
6062 , p_primary_qty => ABS(l_primary_quantity)
6063 , p_qty => ABS(l_transaction_quantity)
6064 , p_uom => p_transaction_uom
6065 , p_org_id => p_organization_id
6066 , p_subinv => p_subinventory_code
6067 , p_locator => p_locator_id
6068 , p_operation => g_unpack
6069 , p_cost_grp_id => p_cost_group_id
6070 , p_trx_action => p_transaction_action_id
6071 , p_source_header_id => NULL
6072 , p_source_name => NULL
6073 , p_source_type_id => NULL
6074 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6075 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6076 , p_source_trx_id => p_source_transaction_id
6077 );
6078 -- Repack items into transfer lpn nulling cost group column
6079 Call_Pack_Unpack (
6080 p_tempid => p_transaction_temp_id
6081 , p_content_lpn => p_content_lpn_id
6082 , p_lpn => p_transfer_lpn_id
6083 , p_item_rec => l_item_rec
6084 , p_revision => p_revision
6085 , p_primary_qty => ABS(l_primary_quantity)
6086 , p_qty => ABS(l_transaction_quantity)
6087 , p_uom => p_transaction_uom
6088 , p_org_id => p_organization_id
6089 , p_subinv => p_subinventory_code
6090 , p_locator => p_locator_id
6091 , p_operation => g_pack
6092 , p_cost_grp_id => NULL
6093 , p_trx_action => p_transaction_action_id
6094 , p_source_header_id => NULL
6095 , p_source_name => NULL
6096 , p_source_type_id => NULL
6097 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6098 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6099 , p_source_trx_id => p_source_transaction_id
6100 );
6101 ELSE
6102 --lpn is same as transfer lpn just need to null the cost group column
6103 --for all items inside that lpn.
6104 UPDATE wms_lpn_contents
6105 SET cost_group_id = NULL
6106 WHERE parent_lpn_id = p_lpn_id;
6107
6108 --Same needs to be done in the serial numbers table
6109 UPDATE mtl_serial_numbers
6110 SET cost_group_id = NULL
6111 WHERE lpn_id = p_lpn_id;
6112
6113 -- Since correction is in same lpn, need to change context
6114 -- of lpn to recieving
6115 -- Change context of transfer lpn to recieving
6116 UPDATE wms_license_plate_numbers
6117 SET lpn_context = wms_container_pub.lpn_context_rcv
6118 WHERE lpn_id = p_lpn_id;
6119 END IF;
6120 ELSE
6121 -- Default Action
6122 Call_Pack_Unpack (
6123 p_tempid => p_transaction_temp_id
6124 , p_content_lpn => p_content_lpn_id
6125 , p_lpn => p_lpn_id
6126 , p_item_rec => l_item_rec
6127 , p_revision => p_revision
6128 , p_primary_qty => ABS(l_primary_quantity)
6129 , p_qty => ABS(l_transaction_quantity)
6130 , p_uom => p_transaction_uom
6131 , p_org_id => p_organization_id
6132 , p_subinv => p_subinventory_code
6133 , p_locator => p_locator_id
6134 , p_operation => g_unpack
6135 , p_cost_grp_id => p_cost_group_id
6136 , p_trx_action => p_transaction_action_id
6137 , p_source_header_id => NULL
6138 , p_source_name => NULL
6139 , p_source_type_id => NULL
6140 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6141 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6142 , p_source_trx_id => p_source_transaction_id
6143 );
6144 END IF;
6145 --Added code to handle issue for bug 12714013
6146 ELSIF (p_transfer_lpn_id = p_lpn_id
6147 AND p_transaction_action_id = inv_globals.g_action_issue
6148 AND p_transaction_source_type_id= inv_globals.G_SOURCETYPE_MOVEORDER) THEN
6149 IF (l_debug = 1) THEN
6150 inv_log_util.TRACE('** p_lpn_id = p_transfer_lpn_id *** :' , 'INV_LPN_TRX_PUB', 9);
6151 inv_log_util.TRACE('** Updating lpn to issued out :' || p_lpn_id, 'INV_LPN_TRX_PUB', 9);
6152 END IF;
6153
6154 v_lpn.lpn_id := p_lpn_id;
6155 v_lpn.lpn_context := wms_container_pub.lpn_context_stores;
6156 v_lpn.organization_id := p_organization_id;
6157 v_lpn.subinventory_code := NULL;
6158 v_lpn.locator_id := NULL;
6159 v_lpn.inventory_item_id := NULL;
6160 update_lpn_status(v_lpn);
6161 ELSIF(p_lpn_id IS NOT NULL) THEN
6162 -- this is an Issue of Item from LPN. Collect all the lot and
6163 -- serial records associated with this item and call packAPI
6164 Call_Pack_Unpack (
6165 p_tempid => p_transaction_temp_id
6166 , p_content_lpn => p_content_lpn_id
6167 , p_lpn => p_lpn_id
6168 , p_item_rec => l_item_rec
6169 , p_revision => p_revision
6170 , p_primary_qty => ABS(l_primary_quantity)
6171 , p_qty => ABS(l_transaction_quantity)
6172 , p_uom => p_transaction_uom
6173 , p_org_id => p_organization_id
6174 , p_subinv => p_subinventory_code
6175 , p_locator => p_locator_id
6176 , p_operation => g_unpack
6177 , p_cost_grp_id => p_cost_group_id
6178 , p_trx_action => p_transaction_action_id
6179 , p_source_header_id => NULL
6180 , p_source_name => NULL
6181 , p_source_type_id => NULL
6182 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6183 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6184 , p_source_trx_id => p_source_transaction_id
6185 );
6186
6187 -- Adding for Case lpn_id and transfer_lpn_id are stamped and content_lpn_id is null
6188 -- for MO issue, if the x_match is 4 and content_lpn_id is
6189 -- not stamped
6190 -- 12714013
6191 IF (p_transfer_lpn_id IS NOT NULL) THEN
6192
6193 select subinventory_code,locator_id
6194 into l_wlpn_sub,l_wlpn_loc_id
6195 from wms_license_plate_numbers
6196 where lpn_id = p_transfer_lpn_id
6197 and organization_id = p_organization_id;
6198
6199 IF (l_debug = 1) THEN
6200 inv_log_util.TRACE('** p_transfer_lpn_id Not null :' || p_transfer_lpn_id, 'INV_LPN_TRX_PUB', 9);
6201 inv_log_util.TRACE('** Calling Pack unpack with action Pack for lpn_id :' || p_transfer_lpn_id, 'INV_LPN_TRX_PUB', 9);
6202 inv_log_util.TRACE('Value of subinventory_code on WLPN :' || l_wlpn_sub, 'INV_LPN_TRX_PUB', 9);
6203 inv_log_util.TRACE('Value of locator_id on WLPN :' || l_wlpn_loc_id, 'INV_LPN_TRX_PUB', 9);
6204 inv_log_util.TRACE('Value of p_subinventory_code:' || p_subinventory_code, 'INV_LPN_TRX_PUB', 9);
6205 inv_log_util.TRACE('Value of p_locator_id :' || p_locator_id, 'INV_LPN_TRX_PUB', 9);
6206 END IF;
6207
6208 Call_Pack_Unpack (
6209 p_tempid => p_transaction_temp_id
6210 , p_content_lpn => p_content_lpn_id
6211 , p_lpn => p_transfer_lpn_id
6212 , p_item_rec => l_item_rec
6213 , p_revision => p_revision
6214 , p_primary_qty => ABS(l_primary_quantity)
6215 , p_qty => ABS(l_transaction_quantity)
6216 , p_uom => p_transaction_uom
6217 , p_org_id => p_organization_id
6218 , p_subinv => NVL(l_wlpn_sub, p_subinventory_code) --BUG13578531
6219 , p_locator => NVL(l_wlpn_loc_id, p_locator_id) --BUG13578531
6220 , p_operation => g_pack
6221 , p_cost_grp_id => p_cost_group_id
6222 , p_trx_action => p_transaction_action_id
6223 , p_source_header_id => NULL
6224 , p_source_name => NULL
6225 , p_source_type_id => NULL
6226 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6227 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6228 , p_source_trx_id => p_source_transaction_id
6229 );
6230 END IF;
6231 --12714013 End
6232
6233 END IF;
6234 /***** RECEIPT/LotSplit/LotMerge/Cycle/PhysicalCount/IntransitRcpt trx ****/
6235 ELSIF (p_transaction_action_id = inv_globals.g_action_receipt)
6236 OR(p_transaction_action_id = inv_globals.g_action_inv_lot_split)
6237 OR((p_transaction_action_id = inv_globals.g_action_inv_lot_translate)
6238 AND(l_primary_quantity > 0))
6239 OR(p_transaction_action_id = inv_globals.g_action_inv_lot_merge)
6240 OR(p_transaction_action_id = inv_globals.g_action_intransitreceipt)
6241 OR(p_transaction_action_id = inv_globals.g_action_assycomplete)
6242 OR((p_transaction_action_id = inv_globals.g_action_cyclecountadj)
6243 AND l_primary_quantity > 0)
6244 OR((p_transaction_action_id = inv_globals.g_action_physicalcountadj)
6245 AND l_primary_quantity > 0)
6246 OR(p_transaction_action_id = inv_globals.g_action_logicalreceipt)
6247 -- IDS: Logical Transactions for lot serial support
6248 -- IDS: Logical Transactions for lot and serials - Opened up TM to
6249 -- handle logical receipts and logical corrections.
6250 THEN
6251 IF (l_debug = 1) THEN
6252 inv_log_util.TRACE(' Action = Receipt', 'INV_LPN_TRX_PUB', 9);
6253 END IF;
6254 --BUG13656377 begin
6255 IF(p_transaction_action_id = inv_globals.g_action_assycomplete
6256 AND p_transaction_source_type_id = inv_globals.G_SOURCETYPE_WIP
6257 AND (p_content_lpn_id IS NOT NULL OR p_lpn_id = p_transfer_lpn_id))THEN
6258
6259 IF (l_debug = 1) THEN
6260 inv_log_util.TRACE('It is WIP LPN completion and content LPN is not null or txfer LPN equals LPN id', 'INV_LPN_TRX_PUB', 9);
6261 inv_log_util.TRACE('Updating WLC to make source_type_id null', 'INV_LPN_TRX_PUB', 9);
6262 END IF;
6263
6264 UPDATE wms_lpn_contents
6265 SET source_type_id = NULL
6266 WHERE parent_lpn_id = NVL(p_content_lpn_id, p_lpn_id);
6267 END IF;
6268 --BUG13656377 end
6269 -- Check if a receipt with PO or RMA source types check to see if it is a correction
6270 IF (
6271 p_transaction_action_id = inv_globals.g_action_receipt
6272 AND(
6273 p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
6274 OR p_transaction_source_type_id = inv_globals.g_sourcetype_rma
6275 )
6276 )
6277 OR(
6278 p_transaction_action_id = inv_globals.g_action_logicalreceipt
6279 AND p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
6280 )
6281 -- IDS:Logical Transaction lot serial support
6282 -- IDS: Logical Transactions for lot and serials - Opened up TM to
6283 -- handle logical receipts and logical corrections.
6284 THEN
6285 BEGIN
6286 SELECT transaction_type
6287 INTO l_rcv_txn_type
6288 FROM rcv_transactions
6289 WHERE transaction_id = p_rcv_transaction_id;
6290 EXCEPTION
6291 WHEN OTHERS THEN
6292 l_rcv_txn_type := NULL;
6293 END;
6294 END IF;
6295
6296 IF (l_debug = 1) THEN
6297 inv_log_util.TRACE('Got l_rcv_txn_typ=' || l_rcv_txn_type, 'INV_LPN_TRX_PUB', 9);
6298 END IF;
6299
6300 -- If receipt is a correction, then special logic is needed
6301 -- otherwise use default behavior
6302 IF (
6303 (
6304 (
6305 p_transaction_action_id = inv_globals.g_action_receipt
6306 AND(
6307 p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
6308 OR p_transaction_source_type_id = inv_globals.g_sourcetype_rma
6309 )
6310 )
6311 OR(
6312 p_transaction_action_id = inv_globals.g_action_logicalreceipt
6313 AND p_transaction_source_type_id = inv_globals.g_sourcetype_purchaseorder
6314 )
6315 )
6316 -- IDS: Logical Transactions for lot and serials - Opened up TM to
6317 -- handle logical receipts and logical corrections.
6318 AND l_rcv_txn_type = 'CORRECT'
6319 ) THEN
6320 -- Unpack items from lpn with null source name and trx action id
6321 Call_Pack_Unpack (
6322 p_tempid => p_transaction_temp_id
6323 , p_content_lpn => p_content_lpn_id
6324 , p_lpn => p_lpn_id
6325 , p_item_rec => l_item_rec
6326 , p_revision => p_revision
6327 , p_primary_qty => ABS(l_primary_quantity)
6328 , p_qty => ABS(l_transaction_quantity)
6329 , p_uom => p_transaction_uom
6330 , p_org_id => p_organization_id
6331 , p_subinv => p_subinventory_code
6332 , p_locator => p_locator_id
6333 , p_operation => g_unpack
6334 , p_cost_grp_id => p_cost_group_id
6335 , p_trx_action => p_transaction_action_id
6336 , p_source_header_id => NULL
6337 , p_source_name => NULL
6338 , p_source_type_id => p_transaction_source_type_id
6339 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6340 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6341 , p_source_trx_id => p_source_transaction_id
6342 );
6343 -- Repack items into transfer lpn with null source name and trx action id
6344 Call_Pack_Unpack (
6345 p_tempid => p_transaction_temp_id
6346 , p_content_lpn => p_content_lpn_id
6347 , p_lpn => p_transfer_lpn_id
6348 , p_item_rec => l_item_rec
6349 , p_revision => p_revision
6350 , p_primary_qty => ABS(l_primary_quantity)
6351 , p_qty => ABS(l_transaction_quantity)
6352 , p_uom => p_transaction_uom
6353 , p_org_id => p_organization_id
6354 , p_subinv => p_subinventory_code
6355 , p_locator => p_locator_id
6356 , p_operation => g_pack
6357 , p_cost_grp_id => p_cost_group_id
6358 , p_trx_action => p_transaction_action_id
6359 , p_source_header_id => NULL
6360 , p_source_name => NULL
6361 , p_source_type_id => NULL
6362 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6363 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6364 , p_source_trx_id => p_source_transaction_id
6365 );
6366 ELSE
6367 -- Do an unpack if (from)LPN_ID column is not null and (from)LPN_ID
6368 -- is not equal to Xfr_LPN_ID
6369 -- also need to unpack if its receipt of RMA so issue
6370 IF (p_lpn_id IS NOT NULL)
6371 AND(
6372 (p_lpn_id <> NVL(p_transfer_lpn_id, 0))
6373 OR
6374 /*added for 3158847*/
6375 ( l_item_rec.serial_number_control_code = 6
6376 AND p_transaction_action_id = 27
6377 AND p_transaction_source_type_id = 12)
6378 ) THEN
6379 -- Do an unpack of the item/LPN. Disregard the cost group.
6380 -- This is because when the item was prepacked, it could n't
6381 -- have had a cost group
6382 Call_Pack_Unpack (
6383 p_tempid => p_transaction_temp_id
6384 , p_content_lpn => p_content_lpn_id
6385 , p_lpn => p_lpn_id
6386 , p_item_rec => l_item_rec
6387 , p_revision => p_revision
6388 , p_primary_qty => ABS(l_primary_quantity)
6389 , p_qty => ABS(l_transaction_quantity)
6390 , p_uom => p_transaction_uom
6391 , p_org_id => p_organization_id
6392 , p_subinv => p_subinventory_code
6393 , p_locator => p_locator_id
6394 , p_operation => g_unpack
6395 , p_cost_grp_id => NULL
6396 , p_trx_action => p_transaction_action_id
6397 , p_source_header_id => /*3158847*/NULL
6398 , p_source_name => /*3158847*/NULL
6399 , p_source_type_id => /*3158847*/p_transaction_source_type_id
6400 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6401 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6402 , p_source_trx_id => p_source_transaction_id
6403 );
6404 END IF;
6405
6406 IF (p_transfer_lpn_id IS NOT NULL)
6407 AND(
6408 (NVL(p_lpn_id, 0) <> p_transfer_lpn_id)
6409 OR
6410 /*added for 3158847*/
6411 ( l_item_rec.serial_number_control_code = 6
6412 AND p_transaction_action_id = 27
6413 AND p_transaction_source_type_id = 12)
6414 ) THEN
6415 -- Transfering to an existing LPN. need to do a pack operation here
6416 Call_Pack_Unpack (
6417 p_tempid => p_transaction_temp_id
6418 , p_content_lpn => p_content_lpn_id
6419 , p_lpn => p_transfer_lpn_id
6420 , p_item_rec => l_item_rec
6421 , p_revision => p_revision
6422 , p_primary_qty => ABS(l_primary_quantity)
6423 , p_qty => ABS(l_transaction_quantity)
6424 , p_uom => p_transaction_uom
6425 , p_org_id => p_organization_id
6426 , p_subinv => p_subinventory_code
6427 , p_locator => p_locator_id
6428 , p_operation => g_pack
6429 , p_cost_grp_id => p_cost_group_id
6430 , p_trx_action => p_transaction_action_id
6431 , p_source_header_id => /*3158847*/NULL
6432 , p_source_name => /*3158847*/NULL
6433 , p_source_type_id => /*3158847*/p_transaction_source_type_id
6434 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6435 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6436 , p_source_trx_id => p_source_transaction_id
6437 );
6438 END IF;
6439
6440 -- For the case where the from_lpn_id = to_lpn_id, then need
6441 -- to manually update COST_GROUP_ID, as we are not calling Pack in this case
6442 IF (p_lpn_id = p_transfer_lpn_id) THEN
6443
6444 -- 6733277
6445 --for intransit shipments, update the wlc's serial summary entry to 2 if the
6446 --serial_control_code is 6.
6447 --Also null out the LPN_id and cost group from MSN.
6448 IF (l_debug = 1) THEN
6449 inv_log_util.TRACE('p_action is:'||p_transaction_action_id ,'INV_LPN_TRX_PUB', 9);
6450 inv_log_util.TRACE('p_sr_Code is:'||p_serial_control_code ,'INV_LPN_TRX_PUB', 9);
6451 END IF;
6452 IF (p_transaction_action_id = inv_globals.g_action_intransitreceipt AND
6453 p_serial_control_code = 6 ) THEN
6454 UPDATE wms_lpn_contents
6455 SET serial_summary_entry = 2
6456 WHERE parent_lpn_id = p_lpn_id
6457 AND organization_id = p_organization_id
6458 AND inventory_item_id = p_inventory_item_id
6459 AND serial_summary_entry <> 2 ;
6460 END IF;
6461
6462 UPDATE wms_lpn_contents
6463 SET cost_group_id = p_cost_group_id
6464 WHERE organization_id = p_organization_id
6465 AND inventory_item_id = p_inventory_item_id
6466 AND parent_lpn_id = p_lpn_id
6467 AND SERIAL_SUMMARY_ENTRY=2 ;
6468 /* Bug 3910656- Added the last condition to the query to update only those
6469 records with the serial_summary_entry as 2. */
6470
6471 -- If this item is Serial controlled, set cost_group_id for Serials
6472 --bug# 9651496,9764650
6473 IF (p_transaction_action_id = inv_globals.g_action_intransitreceipt) THEN
6474 UPDATE mtl_serial_numbers
6475 SET cost_group_id = p_cost_group_id
6476 WHERE inventory_item_id = p_inventory_item_id
6477 AND lpn_id = p_lpn_id
6478 AND serial_number IN ( SELECT fm_serial_number
6479 FROM mtl_serial_numbers_temp
6480 WHERE transaction_temp_id = p_transaction_temp_id);
6481 ELSE
6482 UPDATE mtl_serial_numbers
6483 SET cost_group_id = p_cost_group_id
6484 WHERE inventory_item_id = p_inventory_item_id
6485 AND lpn_id = p_lpn_id;
6486 IF (l_debug = 1) THEN
6487 inv_log_util.TRACE('**Updated WMS_Contents cost_grp_id for lpn=' || p_lpn_id || ' and cg=' || p_cost_group_id, 'INV_LPN_TRX_PUB', 9);
6488 END IF;
6489 END IF;
6490 --End of bug# 9651496,9764650
6491 END IF;
6492
6493 -- Update the status of the received LPN, or the LPN to which the item
6494 -- is received
6495 IF (p_content_lpn_id IS NOT NULL)
6496 OR(p_transfer_lpn_id IS NOT NULL) THEN
6497 IF (p_content_lpn_id IS NOT NULL) THEN
6498 -- If receiving a complete LPN, then check for the autoUnpack
6499 -- status of the subinventory to which it is received
6500 SELECT lpn_controlled_flag
6501 INTO v_autounpack
6502 FROM mtl_secondary_inventories
6503 WHERE organization_id = p_organization_id
6504 AND secondary_inventory_name = p_subinventory_code;
6505
6506 v_lpn.lpn_id := p_content_lpn_id;
6507 ELSE
6508 v_lpn.lpn_id := p_transfer_lpn_id;
6509 END IF;
6510
6511 -- Update the LPN status and location
6512 SELECT lpn_context
6513 INTO v_lpn_ctx
6514 FROM wms_license_plate_numbers
6515 WHERE lpn_id = v_lpn.lpn_id;
6516
6517 IF (v_lpn_ctx <> wms_container_pub.lpn_context_picked) THEN
6518 v_lpn.lpn_context := wms_container_pub.lpn_context_inv;
6519 ELSE
6520 v_lpn.lpn_context := wms_container_pub.lpn_context_picked;
6521 END IF;
6522
6523 v_lpn.organization_id := p_organization_id;
6524 v_lpn.subinventory_code := p_subinventory_code;
6525 v_lpn.locator_id := p_locator_id;
6526
6527 IF (l_rcv_txn_type = 'DELIVER') THEN --Bug 8295406
6528 BEGIN
6529 v_lpn.source_name := FND_API.G_MISS_CHAR;
6530 v_lpn.source_header_id := FND_API.G_MISS_NUM;
6531 END;
6532
6533 END IF;
6534
6535 update_lpn_status(v_lpn);
6536
6537 -- If the autounpack is set for the receiving sub, then unpack the
6538 -- contents of the LPN.
6539 IF (v_autounpack = 2) THEN
6540 WMS_Container_PVT.PackUnpack_Container (
6541 p_api_version => 1.0
6542 , p_init_msg_list => fnd_api.g_false
6543 , p_commit => fnd_api.g_false
6544 , p_validation_level => fnd_api.g_valid_level_none
6545 , x_return_status => ret_status
6546 , x_msg_count => ret_msgcnt
6547 , x_msg_data => ret_msgdata
6548 , p_caller => 'INV_TRNSACTION'
6549 , p_lpn_id => p_content_lpn_id
6550 , p_organization_id => p_organization_id
6551 , p_subinventory => p_subinventory_code
6552 , p_locator_id => p_locator_id
6553 , p_operation => g_unpack_all
6554 , p_source_transaction_id => p_source_transaction_id );
6555
6556 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
6557 IF (l_debug = 1) THEN
6558 inv_log_util.TRACE('**Error Full unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
6559 END IF;
6560
6561 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
6562 fnd_msg_pub.ADD;
6563 RAISE fnd_api.g_exc_error;
6564 END IF;
6565 END IF;
6566 END IF;
6567 END IF;
6568 /***** Actions for SUBXFR / ORGXFR / STGXFR transactions ****/
6569 ELSIF (p_transaction_action_id = inv_globals.g_action_subxfr)
6570 OR(p_transaction_action_id = inv_globals.g_action_planxfr)
6571 OR(p_transaction_action_id = inv_globals.g_action_orgxfr)
6572 OR(p_transaction_action_id = inv_globals.g_action_stgxfr)
6573 OR(p_transaction_action_id = inv_globals.g_action_costgroupxfr) THEN
6574 IF (l_debug = 1) THEN
6575 inv_log_util.TRACE(' Action = SubXfr/OrgXfr/StgXfr/CGXfr', 'INV_LPN_TRX_PUB', 9);
6576 END IF;
6577
6578 -- sanity check. If CostGroupXfr, then both cost_group_id and
6579 -- xfr_cost_group_id should be filled
6580 IF (p_transaction_action_id = inv_globals.g_action_costgroupxfr) THEN
6581 IF (p_cost_group_id IS NULL)
6582 OR(p_transfer_cost_group_id IS NULL) THEN
6583 x_proc_msg := 'Error. Cost Groups not specified. CG=' || p_cost_group_id || ',XfrCG=' || p_transfer_cost_group_id;
6584
6585 IF (l_debug = 1) THEN
6586 inv_log_util.TRACE('Error. Cost Groups not specified. CG=' || p_cost_group_id || ',XfrCG=' || p_transfer_cost_group_id
6587 , 'INV_LPN_TRX_PUB', 1);
6588 END IF;
6589
6590 fnd_message.set_name('INV', 'BAD_INPUT_ARGUMENTS');
6591 fnd_msg_pub.ADD;
6592 RAISE fnd_api.g_exc_error;
6593 END IF;
6594 END IF;
6595
6596 -- If transaction is subtransfer
6597 IF ( p_transaction_action_id = inv_globals.g_action_subxfr OR
6598 p_transaction_action_id = inv_globals.g_action_planxfr )
6599 THEN
6600 IF(p_transfer_lpn_id IS NOT NULL AND p_lpn_id IS NOT NULL) THEN
6601 IF ( v_lpn_ctx IS NULL ) THEN
6602 SELECT lpn_context
6603 INTO v_lpn_ctx
6604 FROM wms_license_plate_numbers
6605 WHERE lpn_id = p_lpn_id;
6606 END IF;
6607
6608 IF (l_debug = 1) THEN
6609 inv_log_util.TRACE('SUBXFER from LPN context=' || v_lpn_ctx, 'INV_LPN_TRX_PUB', 9);
6610 END IF;
6611
6612 IF (v_lpn_ctx = wms_container_pub.lpn_context_picked) THEN
6613 split_delivery(
6614 p_tempid => p_transaction_temp_id
6615 , p_lpn_id => p_lpn_id
6616 , p_xfr_lpn_id => p_transfer_lpn_id
6617 , p_item_rec => l_item_rec
6618 , p_revision => p_revision
6619 , p_qty => l_primary_quantity
6620 , p_uom => l_item_rec.primary_uom_code
6621 , p_secondary_trx_quantity => l_secondary_trx_quantity --INVCONV kkillams
6622 , p_secondary_uom_code => p_secondary_uom_code
6623 , p_org_id => p_organization_id
6624 , p_subinventory_code => p_subinventory_code
6625 , p_locator_id => p_locator_id
6626 , p_xfr_subinventory => p_transfer_subinventory
6627 , p_xfr_to_location => p_transfer_to_location
6628 , p_transaction_source_id => p_transaction_source_id
6629 , p_trx_source_line_id => p_trx_source_line_id );
6630 END IF;
6631 END IF;
6632 END IF;
6633
6634 -- If the (from)_lpn_id is not NULL, then unpack the item/lpn from the
6635 -- this LPN, but only if not packing back to the same LPN,
6636 -- unless this is a CostGroup Transfer transaction
6637 IF (p_lpn_id IS NOT NULL)
6638 AND((p_lpn_id <> NVL(p_transfer_lpn_id, 0))
6639 OR(p_transaction_action_id = inv_globals.g_action_costgroupxfr)) THEN
6640 -- Verify that the context of this LPN is 'Resides in Inventory'
6641 SELECT lpn_context, subinventory_code, locator_id /*14189803 Fetching LPN Sub/Loc */
6642 INTO v_lpn_ctx, l_wlpn_sub, l_wlpn_loc_id
6643 FROM wms_license_plate_numbers
6644 WHERE lpn_id = p_lpn_id;
6645 --14189803
6646 IF (l_debug = 1) THEN
6647 inv_log_util.TRACE('LPN Sub: '||l_wlpn_sub , 'INV_LPN_TRX_PUB', 1);
6648 inv_log_util.TRACE('LPN Loc: '||l_wlpn_loc_id, 'INV_LPN_TRX_PUB', 1);
6649 inv_log_util.TRACE('p_subinventory_code: '||p_subinventory_code, 'INV_LPN_TRX_PUB', 1);
6650 inv_log_util.TRACE('p_locator_id: '||p_locator_id, 'INV_LPN_TRX_PUB', 1);
6651 END IF;
6652 --14189803
6653 IF (v_lpn_ctx = wms_container_pub.lpn_context_packing
6654 AND p_transaction_action_id IN (inv_globals.g_action_stgxfr,inv_globals.g_action_subxfr)) THEN -- 12736705
6655
6656 IF (l_debug = 1) THEN
6657 inv_log_util.TRACE('LPN Packing context and transaction is staging xfer/sub xfer:' || v_lpn_ctx, 'INV_LPN_TRX_PUB', 1);
6658 END IF;
6659
6660 ELSIF (v_lpn_ctx <> wms_container_pub.lpn_context_inv
6661 AND v_lpn_ctx <> wms_container_pub.lpn_context_picked
6662
6663 ) THEN
6664 x_proc_msg := 'Error. Invalid LPN context for Transfer Trx:' || v_lpn_ctx;
6665
6666 IF (l_debug = 1) THEN
6667 inv_log_util.TRACE('Error. Invalid LPN context for Transfer Trx:' || v_lpn_ctx, 'INV_LPN_TRX_PUB', 1);
6668 END IF;
6669
6670 fnd_message.set_name('INV', 'INV_INVALID_LPN_CONTEXT');
6671 fnd_msg_pub.ADD;
6672 RAISE fnd_api.g_exc_error;
6673 END IF;
6674
6675 -- An item or LPN is being unpacked from this LPN.
6676 Call_Pack_Unpack (
6677 p_tempid => p_transaction_temp_id
6678 , p_content_lpn => p_content_lpn_id
6679 , p_lpn => p_lpn_id
6680 , p_item_rec => l_item_rec
6681 , p_revision => p_revision
6682 , p_primary_qty => ABS(l_primary_quantity)
6683 , p_qty => ABS(l_transaction_quantity)
6684 , p_uom => p_transaction_uom
6685 , p_org_id => p_organization_id
6686 , p_subinv => Nvl(l_wlpn_sub, p_subinventory_code)--14189803
6687 , p_locator => Nvl(l_wlpn_loc_id, p_locator_id)--14189803
6688 , p_operation => g_unpack
6689 , p_cost_grp_id => p_cost_group_id
6690 , p_trx_action => NULL
6691 , p_source_header_id => NULL
6692 , p_source_name => NULL
6693 , p_source_type_id => NULL
6694 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
6695 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
6696 , p_source_trx_id => p_source_transaction_id
6697 );
6698
6699 --bug2747049
6700 IF (p_transaction_action_id = inv_globals.g_action_costgroupxfr) THEN
6701 UPDATE wms_license_plate_numbers
6702 SET lpn_context = v_lpn_ctx
6703 , subinventory_code = p_subinventory_code
6704 , locator_id = p_locator_id
6705 WHERE lpn_id = p_lpn_id
6706 AND lpn_context = wms_container_pub.lpn_context_pregenerated;
6707 END IF;
6708 END IF;
6709
6710 IF (p_transaction_action_id = inv_globals.g_action_orgxfr) THEN
6711 v_xfr_org := p_transfer_organization;
6712 ELSE
6713 v_xfr_org := p_organization_id;
6714 END IF;
6715
6716 IF (p_transaction_action_id <> inv_globals.g_action_costgroupxfr) THEN
6717 -- Check transfer org to see if it is wms enabled
6718 IF (
6719 wms_install.check_install(x_return_status => ret_status, x_msg_count => ret_msgcnt, x_msg_data => ret_msgdata
6720 , p_organization_id => v_xfr_org)
6721 ) THEN
6722 -- Get the LPN_CONTROLLED_FLAG status of the transfer subinventory
6723 SELECT lpn_controlled_flag
6724 INTO v_autounpack
6725 FROM mtl_secondary_inventories
6726 WHERE organization_id = v_xfr_org
6727 AND secondary_inventory_name = p_transfer_subinventory;
6728
6729 IF (l_debug = 1) THEN
6730 inv_log_util.TRACE(
6731 'orgid=' || v_xfr_org || ' sub=' || p_transfer_subinventory || ' lpn_controlled_flag=' || v_autounpack
6732 , 'INV_LPN_TRX_PUB'
6733 , 9
6734 );
6735 END IF;
6736 ELSE -- Not a WMS organization unpack all lpns
6737 IF (l_debug = 1) THEN
6738 inv_log_util.TRACE('orgid=' || v_xfr_org || ' not wms enabled unpacking all', 'INV_LPN_TRX_PUB', 9);
6739 END IF;
6740
6741 v_autounpack := 2;
6742 -- Also need to prevent the LPN from being assigned to a non wms org
6743 v_xfr_org := p_organization_id;
6744 END IF;
6745 END IF;
6746
6747 -- bug 2879208
6748 SELECT wms_task_type, reservation_id , transaction_header_id --9869993,fetching reservation_id -- Modified for bug 7010169
6749 INTO l_system_task_type , l_reservation_id, l_trx_hdr_id -- Modified for bug 7010169
6750 FROM mtl_material_transactions_temp
6751 WHERE transaction_temp_id = p_transaction_temp_id;
6752
6753 IF (l_debug = 1) THEN
6754 inv_log_util.TRACE('l_system_task_type = ' || l_system_task_type, 'INV_LPN_TRX_PUB', 9);
6755 inv_log_util.TRACE('l_reservation_id = ' || l_reservation_id , 'INV_LPN_TRX_PUB', 9);
6756 inv_log_util.TRACE('l_trx_hdr_id = ' || l_trx_hdr_id, 'INV_LPN_TRX_PUB', 9); -- Added for bug 7010169
6757 END IF;
6758
6759 -- bug 2879208
6760
6761 --Bug 6007873
6762 IF (p_lpn_id IS NOT NULL) THEN
6763
6764 SELECT lpn_context
6765 INTO l_lpn_ctx_tmp
6766 FROM wms_license_plate_numbers
6767 WHERE lpn_id = p_lpn_id;
6768
6769 -- For Sub transfers reservations should be transfered
6770 -- for content lpn of who's context is not picked
6771 IF (p_transaction_action_id = inv_globals.g_action_subxfr
6772 AND(l_lpn_ctx_tmp <> wms_container_pub.lpn_context_picked
6773 AND ((NVL(l_system_task_type, -1) <> 7) AND (NVL(l_system_task_type, -1) <> 5))) -- Added for Bug 14741165
6774 AND l_reservation_id IS NULL --9869993
6775 ) THEN
6776 IF (l_debug = 1) THEN
6777 inv_log_util.TRACE('Sub Xfer of LPN, calling Transfer_LPN_Reservations ', 'INV_LPN_TRX_PUB', 9);
6778 END IF;
6779
6780 IF p_transfer_lpn_id = p_lpn_id THEN --For bug 14778937
6781 IF (l_debug = 1) THEN
6782 inv_log_util.TRACE('p_transfer_lpn_id = p_lpn_id ', 'INV_LPN_TRX_PUB', 9);
6783 END IF;
6784 inv_lpn_reservations_pvt.transfer_lpn_reservations(
6785 x_return_status => ret_status
6786 , x_msg_count => ret_msgcnt
6787 , x_msg_data => ret_msgdata
6788 , p_organization_id => p_organization_id
6789 , p_lpn_id => p_lpn_id
6790 , p_to_subinventory_code => p_transfer_subinventory
6791 , p_to_locator_id => p_transfer_to_location
6792 , p_system_task_type => l_system_task_type --9794776
6793 );
6794
6795 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
6796 IF (l_debug = 1) THEN
6797 inv_log_util.TRACE('Undefined error in calling Transfer_LPN_Reservations', 'INV_LPN_TRX_PUB', 1);
6798 END IF;
6799
6800 RAISE fnd_api.g_exc_error;
6801 END IF;
6802
6803 IF (l_debug = 1) THEN
6804 inv_log_util.TRACE('Done with call to Transfer_LPN_Reservations', 'INV_LPN_TRX_PUB', 9);
6805 END IF;
6806 ELSE --p_transfer_lpn_id <> p_lpn_id For bug 14778937
6807 IF (l_debug = 1) THEN
6808 inv_log_util.TRACE('transfer_reserved_lpn_contents p_lpn_id :' || p_lpn_id, 'INV_LPN_TRX_PUB', 1);
6809 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_lpn_id :' || p_transfer_lpn_id, 'INV_LPN_TRX_PUB', 1);
6810 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_subinventory :' || p_transfer_subinventory, 'INV_LPN_TRX_PUB', 1);
6811 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_to_location :' ||p_transfer_to_location , 'INV_LPN_TRX_PUB', 1);
6812 inv_log_util.TRACE('transfer_reserved_lpn_contents p_inventory_item_id :' || p_inventory_item_id , 'INV_LPN_TRX_PUB', 1);
6813 END IF;
6814
6815 inv_lpn_reservations_pvt.transfer_reserved_lpn_contents(
6816 x_return_status => ret_status
6817 , x_msg_count => ret_msgcnt
6818 , x_msg_data => ret_msgdata
6819 , p_organization_id => p_organization_id
6820 , p_inventory_item_id => p_inventory_item_id
6821 , p_lpn_id => p_lpn_id
6822 , p_transfer_lpn_id => p_transfer_lpn_id
6823 , p_to_subinventory_code => p_transfer_subinventory
6824 , p_to_locator_id => p_transfer_to_location
6825 , p_system_task_type => l_system_task_type
6826
6827 );
6828
6829 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
6830 IF (l_debug = 1) THEN
6831 inv_log_util.TRACE('Undefined error in calling transfer_reserved_lpn_contents', 'INV_LPN_TRX_PUB', 1);
6832 END IF;
6833
6834 RAISE fnd_api.g_exc_error;
6835 END IF;
6836
6837 IF (l_debug = 1) THEN
6838 inv_log_util.TRACE('Done with call to transfer_reserved_lpn_contents', 'INV_LPN_TRX_PUB', 9);
6839 END IF;
6840 END IF; --end transfer_lpn_id = p_lpn_id For bug 14778937
6841 END IF;
6842 END IF;
6843 -- bug 6007873
6844
6845 -- Is this is a transfer of a complete LPN
6846 IF (p_content_lpn_id IS NOT NULL) THEN
6847 -- Update the LPN status and location
6848 SELECT lpn_context
6849 INTO v_cnt_lpn_ctx
6850 FROM wms_license_plate_numbers
6851 WHERE lpn_id = p_content_lpn_id;
6852
6853
6854 -- Bug 6733277 :Update WLC's serial_summary entry to 2 is serial control is 6 and transaction in intransit receipt
6855 IF (p_transaction_action_id = inv_globals.g_action_intransitreceipt AND p_serial_control_code = 6 ) THEN
6856 UPDATE wms_lpn_contents
6857 SET serial_summary_entry = 2
6858 WHERE parent_lpn_id = p_content_lpn_id
6859 AND organization_id = p_organization_id
6860 AND inventory_item_id = p_inventory_item_id
6861 AND serial_summary_entry <> 2;
6862 END IF;
6863
6864 -- For Sub transfers reservations should be transfered
6865 -- for content lpn of who's context is not picked
6866 IF (
6867 p_transaction_action_id = inv_globals.g_action_subxfr
6868 AND(v_cnt_lpn_ctx <> wms_container_pub.lpn_context_picked
6869 AND NVL(l_system_task_type, -1) <> 7)
6870 AND l_reservation_id IS NULL --9869993
6871 ) -- bug 2879208 added nv for 3240617
6872 THEN
6873 IF (l_debug = 1) THEN
6874 inv_log_util.TRACE('Sub Xfer of LPN, calling Transfer_LPN_Reservations', 'INV_LPN_TRX_PUB', 9);
6875 END IF;
6876
6877 /*Added for Bug#6043776*/
6878 l_cyclpn_id:=p_content_lpn_id;
6879 /*if the transaction is cyclecount use outer LPN to update reservations*/
6880 IF(p_transaction_source_type_id=inv_globals.G_SOURCETYPE_CYCLECOUNT) THEN
6881 IF (l_debug = 1) THEN
6882 inv_log_util.TRACE('entered here cyclecount.. ','INV_LPN_TRX_PUB', 9);
6883 END IF;
6884 SELECT OUTERMOST_LPN_ID into l_cyclpn_id
6885 from wms_license_plate_numbers
6886 where lpn_id=p_content_lpn_id;
6887 END IF;
6888 /*End of Bug#6043776*/
6889
6890 inv_lpn_reservations_pvt.transfer_lpn_reservations(
6891 x_return_status => ret_status
6892 , x_msg_count => ret_msgcnt
6893 , x_msg_data => ret_msgdata
6894 , p_organization_id => p_organization_id
6895 -- , p_lpn_id => p_content_lpn_id commented for Bug 6043776
6896 , p_lpn_id => l_cyclpn_id --Bug # 6043776
6897 , p_to_subinventory_code => p_transfer_subinventory
6898 , p_to_locator_id => p_transfer_to_location
6899 , p_system_task_type => l_system_task_type --9794776
6900 );
6901
6902 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
6903 IF (l_debug = 1) THEN
6904 inv_log_util.TRACE('Undefined error in calling Transfer_LPN_Reservations', 'INV_LPN_TRX_PUB', 1);
6905 END IF;
6906
6907 RAISE fnd_api.g_exc_error;
6908 END IF;
6909
6910 IF (l_debug = 1) THEN
6911 inv_log_util.TRACE('Done with call to Transfer_LPN_Reservations', 'INV_LPN_TRX_PUB', 9);
6912 END IF;
6913 END IF;
6914
6915 /*if ( v_lpn_ctx <> WMS_Container_PUB.LPN_CONTEXT_PICKED ) then
6916 v_lpn.lpn_context := WMS_Container_PUB.LPN_CONTEXT_INV;
6917 else
6918 v_lpn.lpn_context := WMS_Container_PUB.LPN_CONTEXT_PICKED;
6919 end if;
6920 */
6921 v_lpn.lpn_id := p_content_lpn_id;
6922 v_lpn.organization_id := v_xfr_org;
6923
6924 --v_lpn.SUBINVENTORY_CODE := p_transfer_subinventory;
6925 --v_lpn.LOCATOR_ID := p_transfer_to_location;
6926 --UPDATE_LPN_STATUS(v_lpn);
6927
6928 -- If the autounpack is set for the transfer sub, then unpack the
6929 -- contents of the LPN.
6930 IF (v_autounpack = 2) THEN
6931 IF (l_debug = 1) THEN
6932 inv_log_util.TRACE('**Calling fullunpack lpn:' || p_content_lpn_id, 'INV_LPN_TRX_PUB', 9);
6933 END IF;
6934
6935 -- bug 5531237 LPN org has not changed yet need to use original org not xfer org
6936 WMS_Container_PVT.PackUnpack_Container (
6937 p_api_version => 1.0
6938 , p_init_msg_list => fnd_api.g_false
6939 , p_commit => fnd_api.g_false
6940 , p_validation_level => fnd_api.g_valid_level_none
6941 , x_return_status => ret_status
6942 , x_msg_count => ret_msgcnt
6943 , x_msg_data => ret_msgdata
6944 , p_caller => 'INV_TRNSACTION'
6945 , p_lpn_id => p_content_lpn_id
6946 , p_organization_id => p_organization_id
6947 , p_subinventory => NULL
6948 , p_locator_id => NULL
6949 , p_operation => g_unpack_all
6950 , p_source_transaction_id => p_source_transaction_id );
6951
6952 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
6953 IF (l_debug = 1) THEN
6954 inv_log_util.TRACE('**Error Full unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
6955 END IF;
6956
6957 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
6958 fnd_msg_pub.ADD;
6959 RAISE fnd_api.g_exc_error;
6960 END IF;
6961 ELSE
6962 IF ( l_system_task_type = 7 AND
6963 v_cnt_lpn_ctx = wms_container_pub.lpn_loaded_in_stage )
6964 THEN
6965 -- Bug 4247497 Staging Move. Context should be changed to pick
6966 v_lpn.lpn_context := wms_container_pub.lpn_context_picked;
6967 ELSIF (v_cnt_lpn_ctx <> wms_container_pub.lpn_context_picked) THEN
6968 v_lpn.lpn_context := wms_container_pub.lpn_context_inv;
6969 ELSE
6970 --Bug 5509764
6971 --For direct org transfer against an internal req, set the lpn_context
6972 --to "In Inventory" from Picked to reflect the correct status
6973 IF ( p_transaction_source_type_id = inv_globals.G_SOURCETYPE_INTORDER AND
6974 p_transaction_action_id IN (inv_globals.G_ACTION_ORGXFR,inv_globals.G_ACTION_SUBXFR) --8395505.Added SUBXFR
6975 ) THEN
6976 IF (l_debug = 1) THEN
6977 inv_log_util.trace('int req direct org/sub xfr. setting lpn_ctxt to in inventory','INV_LPN_TRX_PUB',1);
6978 END IF;
6979 v_lpn.lpn_context := wms_container_pub.lpn_context_inv;
6980 ELSE
6981 v_lpn.lpn_context := wms_container_pub.lpn_context_picked;
6982 END IF; --END IF check txn_source_type intorder and action direct org xfr
6983 END IF; --END IF LPN context is picked
6984
6985 v_lpn.subinventory_code := p_transfer_subinventory;
6986 v_lpn.locator_id := p_transfer_to_location;
6987 END IF;
6988
6989 -- Bug 4247497 Moving update of context to TM. If this is a stagexfr transaction
6990 -- then lpn-context should be updated to 'picked'
6991 IF ( p_transaction_action_id = inv_globals.G_ACTION_STGXFR ) THEN
6992 v_lpn.lpn_context := wms_container_pub.LPN_CONTEXT_PICKED;
6993 END IF;
6994
6995 /** moved update here to fix bug3299521, this way we would avoid updating
6996 the parent_lpn context for unpacked inner lpns**/
6997 update_lpn_status(v_lpn);
6998 END IF;
6999
7000 -- If the transfer_lpn_id is not NULL, then pack the item/LPN to
7001 -- this LPN, but only if not unpacked from the same LPN,
7002 -- unless this is a CostGroup Transfer transaction
7003 IF (p_transfer_lpn_id IS NOT NULL)
7004 AND((NVL(p_lpn_id, 0) <> p_transfer_lpn_id)
7005 OR(p_transaction_action_id = inv_globals.g_action_costgroupxfr)) THEN
7006 SELECT lpn_context
7007 INTO v_xfrlpn_ctx
7008 FROM wms_license_plate_numbers
7009 WHERE lpn_id = p_transfer_lpn_id;
7010
7011 -- If the item/lpn is transfered to another LPN, then update the
7012 -- status of that LPN, provided the context is 2, 3, or 8
7013 -- and xfr sub is not non-LPN controlled sub
7014 IF (
7015 (v_xfrlpn_ctx = wms_container_pub.lpn_context_wip)
7016 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_rcv)
7017 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_packing)
7018 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_pregenerated)
7019 )
7020 AND(v_autounpack <> 2) THEN
7021 -- If context is pre-generated, then inherit the context of the contentLPN or fromLPN
7022 -- if that context is INV or PICKED
7023 IF (v_xfrlpn_ctx = wms_container_pub.lpn_context_pregenerated)
7024 AND NVL(v_cnt_lpn_ctx, v_lpn_ctx) NOT IN
7025 (
7026 wms_container_pub.lpn_context_wip
7027 , wms_container_pub.lpn_context_rcv
7028 , wms_container_pub.lpn_context_packing
7029 , wms_container_pub.lpn_context_vendor
7030 ) THEN
7031 v_lpn.lpn_context := NVL(v_cnt_lpn_ctx, v_lpn_ctx);
7032
7033 IF (l_debug = 1) THEN
7034 inv_log_util.TRACE('Changing context of xfrlpn cntlpnctx=' || v_cnt_lpn_ctx || ' lpnctx=' || v_lpn_ctx, 'INV_LPN_TRX_PUB'
7035 , 9);
7036 END IF;
7037 ELSE
7038 -- Bug 4247497 Moving update of context to TM
7039 IF ( p_transaction_action_id = inv_globals.g_action_stgxfr ) THEN
7040 v_lpn.lpn_context := wms_container_pub.lpn_context_picked;
7041 ELSE
7042 v_lpn.lpn_context := wms_container_pub.lpn_context_inv;
7043 END IF;
7044 END IF;
7045
7046 v_lpn.lpn_id := p_transfer_lpn_id;
7047 v_lpn.organization_id := v_xfr_org;
7048 v_lpn.subinventory_code := p_transfer_subinventory;
7049 v_lpn.locator_id := p_transfer_to_location;
7050 v_xfrlpn_ctx := v_lpn.lpn_context; --BUG13810580
7051 update_lpn_status(v_lpn);
7052 ELSIF(
7053 v_xfrlpn_ctx <> wms_container_pub.lpn_context_inv
7054 AND v_xfrlpn_ctx <> wms_container_pub.lpn_context_picked
7055 AND v_xfrlpn_ctx <> wms_container_pub.lpn_context_pregenerated
7056 AND v_xfrlpn_ctx <> wms_container_pub.lpn_context_packing /*added for 3160462*/
7057 ) THEN
7058 -- Verify that the context of this LPN is 'Resides in Inventory'
7059 x_proc_msg := 'Error. Invalid LPN context for XFR_LPN:' || v_xfrlpn_ctx;
7060
7061 IF (l_debug = 1) THEN
7062 inv_log_util.TRACE('Error. Invalid LPN context for XFR_LPN :' || v_xfrlpn_ctx, 'INV_LPN_TRX_PUB', 1);
7063 END IF;
7064
7065 fnd_message.set_name('INV', 'INV_INVALID_LPN_CONTEXT');
7066 fnd_msg_pub.ADD;
7067 RAISE fnd_api.g_exc_error;
7068 END IF;
7069
7070 IF (l_debug = 1) THEN
7071 inv_log_util.TRACE(' p_lpn_id :' || p_lpn_id, 'INV_LPN_TRX_PUB', 1);
7072 inv_log_util.TRACE(' p_transfer_lpn_id :' || p_transfer_lpn_id, 'INV_LPN_TRX_PUB', 1);
7073 inv_log_util.TRACE(' v_xfrlpn_ctx :' || v_xfrlpn_ctx, 'INV_LPN_TRX_PUB', 1);
7074 END IF;
7075 -- For CostGroupTransfer transactions, use the xfr_cost_group_id
7076 -- column from MMTT. For all other transactions, use the cost_group_id
7077 -- For CostGrpTrx, sub and location are same as that of source side.
7078 IF (p_transaction_action_id = inv_globals.g_action_costgroupxfr) THEN
7079 l_xfr_sub := p_subinventory_code;
7080 l_xfr_loc := p_locator_id;
7081 ELSE
7082 l_xfr_sub := p_transfer_subinventory;
7083 l_xfr_loc := p_transfer_to_location;
7084 END IF;
7085
7086 /*We should do transfer reservation only for subxfer actions*/
7087 IF ( p_transaction_action_id = inv_globals.g_action_subxfr
7088 AND l_reservation_id IS NULL --9869993
7089 AND NOT(v_xfrlpn_ctx = wms_container_pub.lpn_context_picked --BUG13810580
7090 AND NVL(l_system_task_type, -1) <> 7
7091 AND p_lpn_id <> p_transfer_lpn_id)
7092 AND NVL(l_system_task_type, -1) <> 5 -- Added for Bug 14741165
7093 ) THEN --Bug7692251
7094 -- ER 7307189 changes start
7095 IF (l_debug = 1) THEN
7096 inv_log_util.TRACE('transfer_reserved_lpn_contents p_lpn_id :' || p_lpn_id, 'INV_LPN_TRX_PUB', 1);
7097 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_lpn_id :' || p_transfer_lpn_id, 'INV_LPN_TRX_PUB', 1);
7098 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_subinventory :' || p_transfer_subinventory, 'INV_LPN_TRX_PUB', 1);
7099 inv_log_util.TRACE('transfer_reserved_lpn_contents p_transfer_to_location :' ||p_transfer_to_location , 'INV_LPN_TRX_PUB', 1);
7100 inv_log_util.TRACE('transfer_reserved_lpn_contents p_inventory_item_id :' || p_inventory_item_id , 'INV_LPN_TRX_PUB', 1);
7101 END IF;
7102
7103
7104
7105 inv_lpn_reservations_pvt.transfer_reserved_lpn_contents(
7106 x_return_status => ret_status
7107 , x_msg_count => ret_msgcnt
7108 , x_msg_data => ret_msgdata
7109 , p_organization_id => p_organization_id
7110 , p_inventory_item_id => p_inventory_item_id
7111 , p_lpn_id => p_lpn_id
7112 , p_transfer_lpn_id => p_transfer_lpn_id
7113 , p_to_subinventory_code => p_transfer_subinventory
7114 , p_to_locator_id => p_transfer_to_location
7115 , p_system_task_type => l_system_task_type --9794776
7116
7117 );
7118
7119 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
7120 IF (l_debug = 1) THEN
7121 inv_log_util.TRACE('Undefined error in calling transfer_reserved_lpn_contents', 'INV_LPN_TRX_PUB', 1);
7122 END IF;
7123
7124 RAISE fnd_api.g_exc_error;
7125 END IF;
7126
7127 IF (l_debug = 1) THEN
7128 inv_log_util.TRACE('Done with call to transfer_reserved_lpn_contents', 'INV_LPN_TRX_PUB', 9);
7129 END IF;
7130
7131 -- ER 7307189 changes end
7132 END IF;
7133 -- Because if the Destination Sub Inventory is not LPN controlled we would skip the call to pack_unpack....bug # 1869761
7134 IF (v_autounpack <> 2) THEN
7135 -- An item or LPN is being packed to another LPN.
7136 Call_Pack_Unpack (
7137 p_tempid => p_transaction_temp_id
7138 , p_content_lpn => p_content_lpn_id
7139 , p_lpn => p_transfer_lpn_id
7140 , p_item_rec => l_item_rec
7141 , p_revision => p_revision
7142 , p_primary_qty => ABS(l_primary_quantity)
7143 , p_qty => ABS(l_transaction_quantity)
7144 , p_uom => p_transaction_uom
7145 , p_org_id => v_xfr_org
7146 , p_subinv => l_xfr_sub
7147 , p_locator => l_xfr_loc
7148 , p_operation => g_pack
7149 , p_cost_grp_id => NVL(p_transfer_cost_group_id, p_cost_group_id)
7150 , p_trx_action => NULL
7151 , p_source_header_id => NULL
7152 , p_source_name => NULL
7153 , p_source_type_id => NULL
7154 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
7155 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
7156 , p_source_trx_id => p_source_transaction_id
7157 );
7158 ELSIF(v_xfrlpn_ctx = wms_container_pub.lpn_context_packing) THEN
7159 -- Since the transfer sub is non lpn controlled, change xfer lpn
7160 -- is not packed into and should become defined but not used again.
7161
7162 --Bug#7010169,We need to chekc for other tasks loaded into same LPN.
7163 SELECT count(transaction_temp_id)
7164 INTO l_loaded_tasks_count
7165 FROM mtl_material_transactions_temp mmtt
7166 WHERE transfer_lpn_id = p_transfer_lpn_id
7167 AND transaction_header_id <> l_trx_hdr_id ;
7168
7169 IF (l_debug = 1) THEN
7170 inv_log_util.TRACE('Count of other tasks loaded to this LPN='||l_loaded_tasks_count,'INV_LPN_TRX_PUB', 5);
7171 END IF;
7172
7173 IF (l_loaded_tasks_count = 0 ) THEN
7174
7175 v_lpn.organization_id := v_xfr_org;
7176 v_lpn.lpn_id := p_transfer_lpn_id;
7177 v_lpn.lpn_context := wms_container_pub.lpn_context_pregenerated;
7178 update_lpn_status(v_lpn);
7179 END IF;
7180 END IF;
7181 END IF;
7182
7183 -- For cases of bulk picking the lpn_id and xfr_lpn_id will be same
7184 -- need to change the sub and locator information to the xfer location
7185 IF /*(p_transaction_action_id = inv_globals.g_action_stgxfr
7186 AND Removing this Condition for Bug#12595055*/
7187 (p_lpn_id = p_transfer_lpn_id) THEN
7188 SELECT lpn_context
7189 INTO v_xfrlpn_ctx
7190 FROM wms_license_plate_numbers
7191 WHERE lpn_id = p_transfer_lpn_id;
7192
7193 -- bug 5620764: add debug
7194 IF (l_debug = 1) THEN
7195 inv_log_util.TRACE('Got xfrlpn ctx=' || v_xfrlpn_ctx, 'INV_LPN_TRX_PUB', 5);
7196 END IF;
7197
7198 -- If the lpn is transfered update the status of that LPN
7199 -- provided the context is 2, 3, or 8
7200 IF (p_transaction_source_type_id <> inv_globals.g_sourcetype_salesorder)
7201 AND(
7202 (v_xfrlpn_ctx = wms_container_pub.lpn_context_wip)
7203 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_rcv)
7204 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_packing)
7205 OR(v_xfrlpn_ctx = wms_container_pub.lpn_context_pregenerated)
7206 ) THEN
7207 v_lpn.lpn_context := wms_container_pub.lpn_context_inv;
7208 ELSE
7209 IF (p_transaction_action_id = inv_globals.g_action_stgxfr) THEN --15851366 start
7210
7211 -- bug 5620764
7212 -- For staging transfer transactions change context to picked
7213 v_lpn.lpn_context := wms_container_pub.lpn_context_picked;
7214 --v_lpn.lpn_context := NULL;
7215 END IF; --15851366 end
7216
7217 -- Verify that the context of this LPN is 'Resides in Inventory'
7218 IF (
7219 v_xfrlpn_ctx <> wms_container_pub.lpn_context_inv
7220 AND v_xfrlpn_ctx <> wms_container_pub.lpn_context_picked
7221 AND v_xfrlpn_ctx <> wms_container_pub.lpn_context_packing
7222 ) THEN
7223 x_proc_msg := 'Error. Invalid LPN context for XFR_LPN:' || v_xfrlpn_ctx;
7224
7225 IF (l_debug = 1) THEN
7226 inv_log_util.TRACE('Error. Invalid LPN context for XFR_LPN :' || v_xfrlpn_ctx, 'INV_LPN_TRX_PUB', 1);
7227 END IF;
7228
7229 fnd_message.set_name('INV', 'INV_INVALID_LPN_CONTEXT');
7230 fnd_msg_pub.ADD;
7231 RAISE fnd_api.g_exc_error;
7232 END IF;
7233 END IF;
7234
7235 IF (l_debug = 1) THEN
7236 inv_log_util.TRACE('Updating lpn=' || p_transfer_lpn_id || ' ctx=' || v_lpn.lpn_context || ' org=' || v_xfr_org
7237 , 'INV_LPN_TRX_PUB', 1);
7238 END IF;
7239 --12595055 Begin
7240 IF (v_autounpack = 2) THEN
7241 IF (l_debug = 1) THEN
7242 inv_log_util.TRACE('*** Added to handle non LPN control sub Calling fullunpack lpn:' || p_content_lpn_id, 'INV_LPN_TRX_PUB', 9);
7243 END IF;
7244
7245 -- bug 5531237 LPN org has not changed yet need to use original org not xfer org
7246 WMS_Container_PVT.PackUnpack_Container (
7247 p_api_version => 1.0
7248 , p_init_msg_list => fnd_api.g_false
7249 , p_commit => fnd_api.g_false
7250 , p_validation_level => fnd_api.g_valid_level_none
7251 , x_return_status => ret_status
7252 , x_msg_count => ret_msgcnt
7253 , x_msg_data => ret_msgdata
7254 , p_caller => 'INV_TRNSACTION'
7255 , p_lpn_id => p_lpn_id
7256 , p_organization_id => p_organization_id
7257 , p_subinventory => NULL
7258 , p_locator_id => NULL
7259 , p_operation => g_unpack_all
7260 , p_source_transaction_id => p_source_transaction_id );
7261
7262 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
7263 IF (l_debug = 1) THEN
7264 inv_log_util.TRACE('****Error Full unpack :' || ret_status, 'INV_LPN_TRX_PUB', 1);
7265 END IF;
7266
7267 fnd_message.set_name('INV', 'INV_PACKUNPACK_FAILURE');
7268 fnd_msg_pub.ADD;
7269 RAISE fnd_api.g_exc_error;
7270 END IF;
7271 ELSE
7272 IF (l_debug = 1) THEN
7273 inv_log_util.TRACE('*** Coming to else portion ie LPN controlled sub' || p_content_lpn_id, 'INV_LPN_TRX_PUB', 9);
7274 END IF;
7275 v_lpn.lpn_id := p_transfer_lpn_id;
7276 v_lpn.organization_id := v_xfr_org;
7277 v_lpn.subinventory_code := p_transfer_subinventory;
7278 v_lpn.locator_id := p_transfer_to_location;
7279 update_lpn_status(v_lpn);
7280
7281 END IF;
7282 --12595055 END
7283 END IF;
7284
7285 -- If transaction is subtransfer
7286 IF ( p_transaction_action_id = inv_globals.g_action_subxfr OR
7287 p_transaction_action_id = inv_globals.g_action_planxfr )
7288 THEN
7289 IF (p_content_lpn_id IS NOT NULL) THEN
7290 SELECT lpn_context
7291 INTO v_cnt_lpn_ctx
7292 FROM wms_license_plate_numbers
7293 WHERE lpn_id = p_content_lpn_id;
7294
7295 IF (l_debug = 1) THEN
7296 inv_log_util.TRACE('SUBXFER cont LPN context=' || v_cnt_lpn_ctx, 'INV_LPN_TRX_PUB', 9);
7297 END IF;
7298
7299 IF (v_cnt_lpn_ctx = wms_container_pub.lpn_context_picked)
7300 OR (NVL(l_system_task_type, -1) = 7) THEN --Bug 3620318
7301 --A call to transfer the reservation is also needed if LPN is of the picked context
7302 --Consolidating lpn across subinventories, must transfer reservations
7303 inv_reservation_pvt.transfer_lpn_trx_reservation(
7304 x_return_status => ret_status
7305 , x_msg_count => ret_msgcnt
7306 , x_msg_data => ret_msgdata
7307 , p_transaction_temp_id => p_transaction_temp_id
7308 , p_organization_id => p_organization_id
7309 , p_lpn_id => p_content_lpn_id
7310 , p_from_subinventory_code => p_subinventory_code
7311 , p_from_locator_id => p_locator_id
7312 , p_to_subinventory_code => p_transfer_subinventory
7313 , p_to_locator_id => p_transfer_to_location
7314 );
7315
7316 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
7317 IF (l_debug = 1) THEN
7318 inv_log_util.TRACE('**Error from transfer_lpn_trx_reservation :' || ret_status, 'INV_LPN_TRX_PUB', 1);
7319 END IF;
7320
7321 fnd_message.set_name('INV', 'INV_XFR_RSV_FAILURE');
7322 fnd_msg_pub.ADD;
7323 RAISE fnd_api.g_exc_error;
7324 END IF;
7325 END IF;
7326 END IF;
7327 END IF;
7328 /***** Actions for PACK transactions ****/
7329 ELSIF(p_transaction_action_id = inv_globals.g_action_containerpack) THEN
7330 IF (l_debug = 1) THEN
7331 inv_log_util.TRACE(' Action = Pack', 'INV_LPN_TRX_PUB', 9);
7332 END IF;
7333
7334 Call_Pack_Unpack (
7335 p_tempid => p_transaction_temp_id
7336 , p_content_lpn => p_content_lpn_id
7337 , p_lpn => p_transfer_lpn_id
7338 , p_item_rec => l_item_rec
7339 , p_revision => p_revision
7340 , p_primary_qty => ABS(l_primary_quantity)
7341 , p_qty => ABS(l_transaction_quantity)
7342 , p_uom => p_transaction_uom
7343 , p_org_id => p_organization_id
7344 , p_subinv => p_subinventory_code
7345 , p_locator => p_locator_id
7346 , p_operation => g_pack
7347 , p_cost_grp_id => p_cost_group_id
7348 , p_trx_action => NULL
7349 , p_source_header_id => NULL
7350 , p_source_name => NULL
7351 , p_source_type_id => NULL
7352 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
7353 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
7354 , p_source_trx_id => p_source_transaction_id
7355 );
7356
7357 -- It is possible that the LPN to which the packing is done could be in
7358 -- Receiving. However, after packing, the LPN has to be Inventory.
7359 -- Note: Since only the context of LPN is changed, directly modifying on Table
7360 -- instead of calling modify_LPN API except when the context is picking
7361 UPDATE wms_license_plate_numbers
7362 SET lpn_context = wms_container_pub.lpn_context_inv
7363 WHERE lpn_id = p_transfer_lpn_id
7364 AND lpn_context <> wms_container_pub.lpn_context_picked;
7365 /***** Actions for UNPACK transactions ****/
7366 ELSIF(p_transaction_action_id = inv_globals.g_action_containerunpack) THEN
7367 IF (l_debug = 1) THEN
7368 inv_log_util.TRACE(' Action = UnPack', 'INV_LPN_TRX_PUB', 9);
7369 END IF;
7370
7371 Call_Pack_Unpack (
7372 p_tempid => p_transaction_temp_id
7373 , p_content_lpn => p_content_lpn_id
7374 , p_lpn => p_lpn_id
7375 , p_item_rec => l_item_rec
7376 , p_revision => p_revision
7377 , p_primary_qty => ABS(l_primary_quantity)
7378 , p_qty => ABS(l_transaction_quantity)
7379 , p_uom => p_transaction_uom
7380 , p_org_id => p_organization_id
7381 , p_subinv => p_subinventory_code
7382 , p_locator => p_locator_id
7383 , p_operation => g_unpack
7384 , p_cost_grp_id => p_cost_group_id
7385 , p_trx_action => NULL
7386 , p_source_header_id => NULL
7387 , p_source_name => NULL
7388 , p_source_type_id => NULL
7389 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
7390 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
7391 , p_source_trx_id => p_source_transaction_id
7392 );
7393 -- If LPN is item-tracked, then need to change container status. TODO
7394
7395 /***** Actions for SLPIT transactions ****/
7396 ELSIF(p_transaction_action_id = inv_globals.g_action_containersplit) THEN
7397 IF (l_debug = 1) THEN
7398 inv_log_util.TRACE(' Action = Split, First Unpack', 'INV_LPN_TRX_PUB', 9);
7399 END IF;
7400
7401 -- Start of bug 7226314 7355087
7402
7403 IF (p_transfer_lpn_id IS NOT NULL) THEN
7404
7405 BEGIN
7406
7407 SELECT license_plate_number,lpn_context
7408 INTO l_lpn_name,l_xfrlpn_ctx
7409 FROM wms_license_plate_numbers
7410 WHERE organization_id = p_organization_id
7411 AND (lpn_id = p_transfer_lpn_id
7412 OR parent_lpn_id = p_transfer_lpn_id
7413 or outermost_lpn_id = p_transfer_lpn_id)
7414 AND rownum<2; --Added for bug13629931
7415
7416 EXCEPTION
7417 WHEN No_Data_Found THEN
7418 IF (l_debug = 1) THEN
7419 inv_log_util.trace('no data found', 'INV_LPN_TRX_PUB', 9);
7420 END IF;
7421 END;
7422
7423 IF(l_xfrlpn_ctx = wms_container_pub.lpn_context_pregenerated)THEN
7424 OPEN c_wdd_exists(p_transfer_lpn_id,p_organization_id);
7425 FETCH c_wdd_exists into l_delivery_id,l_delivery_detail_id,l_status_code;
7426 IF c_wdd_exists%NOTFOUND THEN
7427 CLOSE c_wdd_exists;
7428 ELSE
7429 BEGIN
7430 IF(l_delivery_id IS NOT NULL AND l_status_code = 'C') THEN
7431
7432 l_container_new_name := wms_shipping_transaction_pub.get_container_name(l_lpn_name);
7433 l_container_rec(1).container_name := l_container_new_name;
7434 l_container_rec(1).delivery_detail_id := l_delivery_detail_id;
7435 l_container_rec(1).lpn_id := NULL;
7436 l_container_rec(1).container_flag := 'Y';
7437
7438 wsh_container_grp.update_container(
7439 p_api_version => 1.0
7440 , p_init_msg_list => fnd_api.g_false
7441 , p_commit => fnd_api.g_false
7442 , p_validation_level => fnd_api.g_valid_level_full
7443 , x_return_status => ret_status
7444 , x_msg_count => ret_msgcnt
7445 , x_msg_data => ret_msgdata
7446 , p_container_rec => l_container_rec
7447 );
7448
7449 IF ret_status = fnd_api.g_ret_sts_unexp_error
7450 OR ret_status = fnd_api.g_ret_sts_error THEN
7451 RAISE fnd_api.g_exc_error;
7452 END IF;
7453 ELSE
7454 fnd_message.set_name('WMS','WMS_INVALID_PACK_DELIVERY');
7455 fnd_msg_pub.ADD;
7456 RAISE fnd_api.g_exc_error;
7457 END IF;
7458 END;
7459
7460 CLOSE c_wdd_exists;
7461 END IF;
7462 END IF;
7463 END IF;
7464
7465 -- End of bug 7226314,7355087
7466
7467
7468
7469 IF (p_content_lpn_id IS NULL) THEN
7470 SELECT lpn_context
7471 INTO v_lpn_ctx
7472 FROM wms_license_plate_numbers
7473 WHERE lpn_id = p_lpn_id;
7474
7475 IF (v_lpn_ctx = wms_container_pub.lpn_context_picked) THEN
7476 split_delivery(
7477 p_tempid => p_transaction_temp_id
7478 , p_lpn_id => p_lpn_id
7479 , p_xfr_lpn_id => p_transfer_lpn_id
7480 , p_item_rec => l_item_rec
7481 , p_revision => p_revision
7482 , p_qty => l_primary_quantity
7483 , p_uom => l_item_rec.primary_uom_code
7484 , p_secondary_trx_quantity => l_secondary_trx_quantity --INVCONV kkillams
7485 , p_secondary_uom_code => p_secondary_uom_code
7486 , p_org_id => p_organization_id
7487 , p_subinventory_code => p_subinventory_code
7488 , p_locator_id => p_locator_id
7489 , p_transaction_source_id => p_transaction_source_id
7490 , p_trx_source_line_id => p_trx_source_line_id
7491 );
7492 END IF;
7493
7494 -- It is possible that the LPN to which the packing is done could be in
7495 -- Receiving. However, after packing, the LPN has to be Inventory.
7496 -- Note: Since only the context of LPN is changed, directly modifying on Table
7497 -- instead of calling modify_LPN API
7498 SELECT lpn_context
7499 INTO v_xfrlpn_ctx
7500 FROM wms_license_plate_numbers
7501 WHERE lpn_id = p_transfer_lpn_id;
7502
7503 -- If context is pre-generated, then inherit the context of the contentLPN or fromLPN
7504 -- If that context is INV or PICKED
7505 IF (
7506 v_xfrlpn_ctx = wms_container_pub.lpn_context_pregenerated
7507 AND v_lpn_ctx NOT IN
7508 (
7509 wms_container_pub.lpn_context_wip
7510 , wms_container_pub.lpn_context_rcv
7511 , wms_container_pub.lpn_context_packing
7512 , wms_container_pub.lpn_context_vendor
7513 )
7514 ) THEN
7515 v_lpn.lpn_id := p_transfer_lpn_id;
7516 v_lpn.lpn_context := v_lpn_ctx;
7517 update_lpn_status(v_lpn);
7518 END IF;
7519 END IF;
7520
7521 OPEN c_rtv_exists(p_lpn_id,p_organization_id); --RTV Change 16197273
7522
7523 FETCH c_rtv_exists
7524 INTO l_rtv_transaction_id;
7525 CLOSE c_rtv_exists;
7526
7527
7528 IF (l_debug = 1) THEN
7529 inv_log_util.trace('RTV ER Split' || l_rtv_transaction_id , 'INV_LPN_TRX_PUB', 9);
7530 END IF;
7531
7532
7533 IF (l_rtv_transaction_id IS NOT NULL )THEN --RTV Change 16197273
7534
7535 l_source_header_id := l_rtv_transaction_id;
7536 l_source_name := 'RETURN TO VENDOR';
7537
7538 inv_log_util.TRACE('Calling split delivery for RTV ER '|| p_transaction_temp_id, 'INV_LPN_TRX_PUB', 1);
7539
7540 split_delivery(
7541 p_tempid => p_transaction_temp_id
7542 , p_lpn_id => p_lpn_id
7543 , p_xfr_lpn_id => p_transfer_lpn_id
7544 , p_item_rec => l_item_rec
7545 , p_revision => p_revision
7546 , p_qty => l_primary_quantity
7547 , p_uom => l_item_rec.primary_uom_code
7548 , p_secondary_trx_quantity => l_secondary_trx_quantity --INVCONV kkillams
7549 , p_secondary_uom_code => p_secondary_uom_code
7550 , p_org_id => p_organization_id
7551 , p_subinventory_code => p_subinventory_code
7552 , p_locator_id => p_locator_id
7553 , p_transaction_source_id => p_transaction_source_id
7554 , p_trx_source_line_id => p_trx_source_line_id
7555 );
7556
7557
7558
7559 END IF ;
7560
7561 IF (l_debug = 1) THEN
7562 inv_log_util.TRACE('RTV ER Split: l_source_header_id '|| l_source_header_id, 'INV_LPN_TRX_PUB', 1);
7563 inv_log_util.TRACE('RTV ER Split: l_source_name'|| l_source_name, 'INV_LPN_TRX_PUB', 1);
7564 END IF;
7565
7566
7567 Call_Pack_Unpack (
7568 p_tempid => p_transaction_temp_id
7569 , p_content_lpn => p_content_lpn_id
7570 , p_lpn => p_lpn_id
7571 , p_item_rec => l_item_rec
7572 , p_revision => p_revision
7573 , p_primary_qty => ABS(l_primary_quantity)
7574 , p_qty => ABS(l_transaction_quantity)
7575 , p_uom => p_transaction_uom
7576 , p_org_id => p_organization_id
7577 , p_subinv => p_subinventory_code
7578 , p_locator => p_locator_id
7579 , p_operation => g_unpack
7580 , p_cost_grp_id => p_cost_group_id
7581 , p_trx_action => NULL
7582 , p_source_header_id => l_source_header_id --RTV Change 16197273
7583 , p_source_name => l_source_name ----RTV Change 16197273
7584 , p_source_type_id => NULL
7585 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
7586 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
7587 , p_source_trx_id => p_source_transaction_id
7588 );
7589 Call_Pack_Unpack (
7590 p_tempid => p_transaction_temp_id
7591 , p_content_lpn => p_content_lpn_id
7592 , p_lpn => p_transfer_lpn_id
7593 , p_item_rec => l_item_rec
7594 , p_revision => p_revision
7595 , p_primary_qty => ABS(l_primary_quantity)
7596 , p_qty => ABS(l_transaction_quantity)
7597 , p_uom => p_transaction_uom
7598 , p_org_id => p_organization_id
7599 , p_subinv => p_subinventory_code
7600 , p_locator => p_locator_id
7601 , p_operation => g_pack
7602 , p_cost_grp_id => p_cost_group_id
7603 , p_trx_action => NULL
7604 , p_source_header_id => l_source_header_id --RTV Change 16197273
7605 , p_source_name => l_source_name ----RTV Change 16197273
7606 , p_source_type_id => NULL
7607 , p_sec_qty => abs(l_secondary_trx_quantity) --INVCONV kkillams
7608 , p_sec_uom => p_secondary_uom_code --INVCONV kkillams
7609 , p_source_trx_id => p_source_transaction_id
7610 );
7611
7612 /* 8579396 :start */
7613 ELSIF ( p_transaction_action_id = inv_globals.G_ACTION_ASSYRETURN AND
7614 p_transaction_source_type_id = inv_globals.G_SOURCETYPE_WIP AND
7615 NVL(p_lpn_id,-1) > 0
7616 ) THEN
7617 IF ( inv_cache.set_org_rec(p_organization_id) ) THEN
7618 IF ( NVL(inv_cache.org_rec.process_enabled_flag,'N') = 'Y') THEN --We will do this only for OPM
7619
7620 Call_Pack_Unpack (
7621 p_tempid => p_transaction_temp_id
7622 , p_content_lpn => NULL
7623 , p_lpn => p_lpn_id
7624 , p_item_rec => l_item_rec
7625 , p_revision => p_revision
7626 , p_primary_qty => ABS(l_primary_quantity)
7627 , p_qty => ABS(l_transaction_quantity)
7628 , p_uom => p_transaction_uom
7629 , p_org_id => p_organization_id
7630 , p_subinv => p_subinventory_code
7631 , p_locator => p_locator_id
7632 , p_operation => g_unpack
7633 , p_cost_grp_id => p_cost_group_id
7634 , p_trx_action => p_transaction_action_id
7635 , p_source_header_id => NULL
7636 , p_source_name => NULL
7637 , p_source_type_id => p_transaction_source_type_id
7638 , p_sec_qty => abs(l_secondary_trx_quantity)
7639 , p_sec_uom => p_secondary_uom_code
7640 , p_source_trx_id => p_source_transaction_id
7641 );
7642 IF (l_debug = 1) THEN
7643 inv_log_util.TRACE('Done with unpack for OPM return transaction from LPN :'|| p_lpn_id, 'INV_LPN_TRX_PUB', 1);
7644 END IF;
7645 END IF;
7646 ELSE
7647 IF (l_debug = 1) THEN
7648 inv_log_util.TRACE('Error. While getting org parameters :' , 'INV_LPN_TRX_PUB', 1);
7649 END IF;
7650 RAISE fnd_api.g_exc_error;
7651 END IF;
7652 /* 8579396 :End */
7653 END IF; -- end of if loop based on transaction_type
7654 -- Bug 2392622 removed for now cannot be updated before TM call should be done in MMT
7655 -- If Sales Order Issue or Int.Order Issue/SubXfr/Intransit Shipment
7656 -- need to popluate the content_lpn in MMTT with the outermost lpn
7657 -- for shipping
7658 /*if p_content_lpn_id is not NULL AND
7659 ((p_transaction_source_type_id = inv_globals.G_SourceType_SalesOrder AND
7660 p_transaction_action_id = inv_globals.G_Action_Issue) OR
7661 (p_transaction_source_type_id = inv_globals.G_SourceType_IntOrder AND
7662 (p_transaction_action_id = inv_globals.G_Action_Issue OR
7663 p_transaction_action_id =
7664 inv_globals.G_Action_Subxfr OR
7665 p_transaction_action_id = inv_globals.G_Action_Planxfr OR
7666 p_transaction_action_id = inv_globals.G_Action_Orgxfr OR
7667 p_transaction_action_id = inv_globals.G_Action_IntransitShipment))) then
7668 BEGIN
7669 UPDATE mtl_material_transactions_temp
7670 SET content_lpn_id = (SELECT outermost_lpn_id
7671 FROM wms_license_plate_numbers
7672 WHERE lpn_id = p_content_lpn_id
7673 AND rownum < 2)
7674 WHERE transaction_temp_id = p_transaction_temp_id;
7675 EXCEPTION
7676 when others then
7677 IF (l_debug = 1) THEN
7678 inv_log_util.trace('Error updating content_lpn_id in MMTT line ttid='||p_transaction_temp_id, 'INV_LPN_TRX_PUB', 9);
7679 END IF;
7680 END;
7681 end if;*/
7682 END IF; --lpn_id = null AND content_lpn_id = null and xfr_lpn_id = null
7683
7684 -- Start 9740452
7685
7686 IF (NOT inv_cache.Set_org_rec(p_organization_id => p_organization_id)) THEN
7687 IF (l_debug = 1) THEN
7688 inv_log_util.TRACE(l_api_name||' : '||p_organization_id||' is an invalid organization id', 'INV_LPN_TRX_PUB', 1);
7689 END IF;
7690 fnd_message.Set_name('WMS','WMS_CONT_INVALID_ORG');
7691 fnd_msg_pub.ADD;
7692 RAISE fnd_api.g_exc_error;
7693 END IF;
7694
7695 IF NVL(inv_cache.org_rec.PROCESS_ENABLED_FLAG,'N') = 'Y' then
7696
7697 -- Start 8379698
7698 SELECT transaction_type_id INTO l_transaction_type_id
7699 FROM mtl_material_transactions_temp
7700 WHERE transaction_temp_id = p_transaction_temp_id;
7701
7702 IF (l_transaction_type_id = 44 AND p_transaction_action_id = 31 AND p_transaction_source_type_id = 5) THEN
7703 l_business_flow_code := 26;
7704 ELSE
7705 l_business_flow_code:= p_business_flow_code;
7706 END IF;
7707 -- End 8379698
7708
7709 ELSE
7710 l_business_flow_code:= p_business_flow_code;
7711 END IF;
7712
7713 -- End 9740452
7714
7715 l_progress := 'Call to Label Printing API if l_business_flow_code is passed';
7716 IF (NVL(l_business_flow_code, 0) <> 0) THEN -- Bug # 9740452
7717
7718 -- Start of fix for Bug: 4891916
7719 IF (l_debug = 1) THEN
7720 inv_log_util.TRACE('Value of Business flow:'|| l_business_flow_code || 'l_print_label:'
7721 || l_print_label, 'INV_LPN_TRX_PUB', 1); -- Bug # 9740452
7722 END IF;
7723 -- Checking for the business flow and the value of the profile
7724 -- and setting the value of the transaction identifier accordingly.
7725
7726 IF ((l_business_flow_code = 8) AND (l_print_label IN (2,3))) THEN -- Bug # 9740452
7727 l_transaction_identifier:= 5;
7728 END IF;
7729
7730 -- End of fix for Bug: 4891916
7731
7732 /* Calling with the value of p_transaction_identifier as 5. In the label printing code,
7733 this value will indicate that the call is at the time of approving the cycle count
7734 entry. The value of p_transaction_identifier 4 in the label printing api indicates
7735 that the call is at the time of performing the cycle count entry.*/
7736
7737 inv_label.print_label_wrap(
7738 x_return_status => ret_status
7739 , x_msg_count => ret_msgcnt
7740 , x_msg_data => ret_msgdata
7741 , x_label_status => label_status
7742 , p_business_flow_code => l_business_flow_code -- Bug # 9740452
7743 , p_transaction_id => p_transaction_temp_id
7744 , p_transaction_identifier => l_transaction_identifier --Added for Bug 4891916
7745 );
7746
7747 IF (ret_status <> fnd_api.g_ret_sts_success) THEN
7748 IF (l_debug = 1) THEN
7749 inv_log_util.TRACE('**Error Label Printing :' || ret_status, 'INV_LPN_TRX_PUB', 1);
7750 END IF;
7751 --RAISE FND_API.G_EXC_ERROR; Since TM should not fail, even if
7752 --this call fails bug#2555226
7753 END IF;
7754 END IF;
7755
7756 -- Bug 2767841. Pick Drop is causing delivery lines to split.
7757 -- The reason is that after the content LPN is exploded, the original MMTT line
7758 -- is not deleted, so finalize_pick_confirm counts it with the child record so
7759 -- the requested quantity doubled and then causing the delivery line to split
7760 -- After all the LPN related txn is done, delete the original MMTT record that
7761 -- has inventory_item_id = -1
7762 IF p_inventory_item_id = -1 THEN
7763 IF (l_debug = 1) THEN
7764 inv_log_util.TRACE('* Done with process_lpn_trx_line, deleting MMTT record for tmpID=' || p_transaction_temp_id, 'INV_LPN_TRX_PUB'
7765 , 1);
7766 END IF;
7767
7768 DELETE FROM mtl_serial_numbers_temp
7769 WHERE transaction_temp_id = (SELECT transaction_temp_id
7770 FROM mtl_material_transactions_temp
7771 WHERE transaction_temp_id = p_transaction_temp_id
7772 AND inventory_item_id = -1);
7773
7774 IF SQL%ROWCOUNT = 0 THEN
7775 DELETE FROM mtl_serial_numbers_temp
7776 WHERE transaction_temp_id IN(
7777 SELECT serial_transaction_temp_id
7778 FROM mtl_transaction_lots_temp
7779 WHERE transaction_temp_id =
7780 (SELECT transaction_temp_id
7781 FROM mtl_material_transactions_temp
7782 WHERE transaction_temp_id = p_transaction_temp_id
7783 AND inventory_item_id = -1));
7784 END IF;
7785
7786 IF (l_debug = 1) THEN
7787 inv_log_util.TRACE('* No of MSNT records deleted =' || SQL%ROWCOUNT, 'INV_LPN_TRX_PUB', 1);
7788 END IF;
7789
7790 DELETE FROM mtl_transaction_lots_temp
7791 WHERE transaction_temp_id = (SELECT transaction_temp_id
7792 FROM mtl_material_transactions_temp
7793 WHERE transaction_temp_id = p_transaction_temp_id
7794 AND inventory_item_id = -1);
7795
7796 IF (l_debug = 1) THEN
7797 inv_log_util.TRACE('* No of MTLT records deleted =' || SQL%ROWCOUNT, 'INV_LPN_TRX_PUB', 1);
7798 END IF;
7799
7800 DELETE FROM mtl_material_transactions_temp
7801 WHERE transaction_temp_id = p_transaction_temp_id
7802 AND inventory_item_id = -1;
7803
7804 IF (l_debug = 1) THEN
7805 inv_log_util.TRACE('* No. of MMTT record deleted ' || SQL%ROWCOUNT, 'INV_LPN_TRX_PUB', 1);
7806 END IF;
7807 END IF;
7808 EXCEPTION
7809 WHEN fnd_api.g_exc_error THEN
7810 x_return_status := fnd_api.g_ret_sts_error;
7811 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, 'F');
7812
7813 IF (l_debug = 1) THEN
7814 inv_log_util.TRACE(l_api_name || ' Exc err prog=' || l_progress || ' SQL err: ' || SQLERRM(SQLCODE), l_api_name, 1);
7815 fnd_msg_pub.count_and_get(p_count => ret_msgcnt, p_data => ret_msgdata);
7816
7817 FOR i IN 1 .. ret_msgcnt LOOP
7818 l_msgdata := SUBSTR(l_msgdata || ' | ' || SUBSTR(fnd_msg_pub.get(ret_msgcnt - i + 1, 'F'), 0, 200), 1, 2000);
7819 END LOOP;
7820
7821 inv_log_util.TRACE('msg: ' || l_msgdata, l_api_name, 1);
7822 END IF;
7823 WHEN OTHERS THEN
7824 x_return_status := fnd_api.g_ret_sts_unexp_error;
7825 x_proc_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, 'F');
7826
7827 IF (l_debug = 1) THEN
7828 inv_log_util.TRACE(l_api_name || ' Unexp err prog=' || l_progress || ' SQL err: ' || SQLERRM(SQLCODE), l_api_name, 1);
7829 inv_log_util.TRACE('msg=' || x_proc_msg, l_api_name, 1);
7830 END IF;
7831 END process_lpn_trx_line;
7832
7833 END inv_lpn_trx_pub;