DBA Data[Home] [Help]

APPS.WMS_TASK_LOAD SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 26

  g_debug                          NUMBER  := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0); --13860546 selecting from profile earlier hard coded to 1
Line: 38

PROCEDURE proc_insert_update_task
			  (p_action                          IN            VARCHAR2
			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_temp_id                         IN            NUMBER
			  ,p_new_temp_id                     IN            NUMBER
			  ,p_merge_temp_id                   IN            NUMBER
			  ,p_task_status                     IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2);
Line: 51

PROCEDURE proc_insert_update_mmtt
			  (p_action                          IN            VARCHAR2
			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_organization_id                 IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,p_transaction_header_id           IN            NUMBER
			  ,p_transaction_temp_id             IN            NUMBER
			  ,p_transaction_temp_id_to_merge    IN            NUMBER
			  ,p_lpn_id                          IN            NUMBER
			  ,p_content_lpn_id                  IN            NUMBER
			  ,p_transfer_lpn_id                 IN            NUMBER
			  ,p_confirmed_sub                   IN            VARCHAR2
			  ,p_confirmed_locator_id            IN            NUMBER
			  ,p_confirmed_uom                   IN            VARCHAR2
			  ,p_suggested_uom                   IN            VARCHAR2
			  ,p_primary_uom                     IN            VARCHAR2
			  ,p_inventory_item_id               IN            NUMBER
			  ,p_revision                        IN            VARCHAR2
			  ,p_confirmed_trx_qty               IN            NUMBER
			  ,p_confirmed_lots                  IN            VARCHAR2
			  ,p_confirmed_lot_trx_qty           IN            VARCHAR2
			  ,p_confirmed_sec_uom               IN            VARCHAR2
			  ,p_confirmed_sec_qty               IN            VARCHAR2
			  ,p_confirmed_serials               IN            VARCHAR2
			  ,p_container_item_id               IN            NUMBER
			  ,p_wms_task_status                 IN            NUMBER
			  ,p_lpn_match                       IN            NUMBER
			  ,p_lpn_match_lpn_id                IN            NUMBER
			  ,p_serial_allocated_flag           IN            VARCHAR2
			  ,p_lot_controlled                  IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled               IN            VARCHAR2  -- Y/N
			  ,p_exception                       IN            VARCHAR2  -- OVER/SHORT
			  ,p_parent_lpn_id                   IN            NUMBER
			  ,x_new_transaction_temp_id         OUT NOCOPY    NUMBER
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots                 IN	           VARCHAR2 --/* Bug 9448490 Lot Substitution Project */
			  ,p_full_lot_allocation             IN            VARCHAR2 DEFAULT 'Y' ); -- Added for 14699845 (Flexible Lot Allocation)
Line: 94

			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_organization_id                 IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,p_transaction_header_id           IN            NUMBER
			  ,p_transaction_temp_id             IN            NUMBER
			  ,p_new_transaction_temp_id         IN            NUMBER
			  ,p_transaction_temp_id_to_merge    IN            NUMBER
			  ,p_inventory_item_id               IN            NUMBER
			  ,p_revision                        IN            VARCHAR2
			  ,p_suggested_uom                   IN            VARCHAR2
			  ,p_confirmed_uom                   IN            VARCHAR2
			  ,p_primary_uom                     IN            VARCHAR2
			  ,p_confirmed_lots                  IN            VARCHAR2
			  ,p_confirmed_lot_trx_qty           IN            VARCHAR2
			  ,p_confirmed_serials               IN            VARCHAR2
			  ,p_serial_allocated_flag           IN            VARCHAR2
			  ,p_lpn_match                       IN            NUMBER
			  ,p_lpn_match_lpn_id                IN            NUMBER
			  ,p_confirmed_sec_uom               IN            VARCHAR2
			  ,p_confirmed_sec_qty               IN            VARCHAR2
			  ,p_lot_controlled                  IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled               IN            VARCHAR2  -- Y/N
			  ,p_exception                       IN            VARCHAR2  -- OVER/SHORT
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots		         IN	           VARCHAR2 --/* Bug 9448490 Lot Substitution Project */
			  ,p_full_lot_allocation             IN            VARCHAR2 DEFAULT 'Y'
			  ,p_fulfillment_base                IN            VARCHAR2
			  ,p_orig_mmtt_txn_uom               IN            VARCHAR2); -- Added for 14699845 (Flexible Lot Allocation)
Line: 128

			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_organization_id                 IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,p_transaction_header_id           IN            NUMBER
			  ,p_transaction_temp_id             IN            NUMBER
			  ,p_new_transaction_temp_id         IN            NUMBER
			  ,p_transaction_temp_id_to_merge    IN            NUMBER
			  ,p_serial_transaction_temp_id      IN            NUMBER
			  ,p_mtlt_serial_temp_id             IN            NUMBER
			  ,p_inventory_item_id               IN            NUMBER
			  ,p_revision                        IN            VARCHAR2
			  ,p_suggested_uom                   IN            VARCHAR2
			  ,p_confirmed_uom                   IN            VARCHAR2
			  ,p_primary_uom                     IN            VARCHAR2
			  ,p_serial_lot_number               IN            VARCHAR2
			  ,p_confirmed_serials               IN            VARCHAR2
			  ,p_serial_allocated_flag           IN            VARCHAR2
			  ,p_lpn_match                       IN            NUMBER
			  ,p_lpn_match_lpn_id                IN            NUMBER
			  ,p_lot_controlled                  IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled               IN            VARCHAR2  -- Y/N
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots		         IN	           VARCHAR2 --/* Bug 12670785 Lot Substitution enhancement for Serial Items ER */
			  ,p_full_lot_allocation             IN            VARCHAR2); -- Added for 14699845 (Flexible Lot Allocation)
Line: 156

PROCEDURE proc_insert_mtlt
			  (p_lot_record                      IN      mtl_transaction_lots_temp%ROWTYPE
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2);
Line: 162

PROCEDURE proc_insert_msnt
			  (p_transaction_temp_id             IN          NUMBER
			  ,p_organization_id                 IN          NUMBER
			  ,p_inventory_item_id               IN          NUMBER
			  ,p_revision                        IN          VARCHAR2
			  ,p_confirmed_serials               IN          VARCHAR2
			  ,p_serial_number                   IN          VARCHAR2
			  ,p_lpn_id                          IN          NUMBER
			  ,p_serial_lot_number               IN          VARCHAR2
			  ,p_user_id                         IN          NUMBER
			  ,x_return_status                   OUT NOCOPY  VARCHAR2
			  ,x_msg_count                       OUT NOCOPY  NUMBER
			  ,x_msg_data                        OUT NOCOPY  VARCHAR2);
Line: 274

PROCEDURE insert_mtlt (
		p_new_temp_id     IN  NUMBER
	  , p_serial_temp_id  IN  NUMBER := NULL
	  , p_pri_att_qty     IN  NUMBER
	  , p_sec_att_qty     IN  NUMBER := NULL
	  , p_trx_att_qty     IN  NUMBER
	  , p_lot_number      IN  VARCHAR2
	  , p_item_id         IN  NUMBER
	  , p_organization_id IN  NUMBER
	  ,x_return_status    OUT NOCOPY    VARCHAR2) ;
Line: 288

PROCEDURE insert_serials_temp (
   p_transaction_temp_id   IN             NUMBER,
   p_lpn_id                IN             NUMBER,
   p_org_id                IN             NUMBER,
   p_item_id               IN             NUMBER,
   p_rev                   IN             VARCHAR2,
   p_confirmed_trx_qty     IN             NUMBER,
   x_return_status         OUT  NOCOPY    VARCHAR2,
   x_msg                   OUT  NOCOPY    VARCHAR2
);
Line: 337

PROCEDURE update_loaded_part
  (p_user_id                   IN            NUMBER,
   p_organization_id 		   IN 			 NUMBER, --BUG12622871LSC
   p_transaction_temp_id1      IN            NUMBER,
   p_transaction_temp_id2      IN            NUMBER,
   p_transfer_lpn_id           IN            NUMBER,
   p_transaction_uom           IN            VARCHAR2,
   p_transaction_quantity      IN            NUMBER,
   p_lot_numbers               IN            VARCHAR2,
   p_lot_transaction_quantity  IN            VARCHAR2,
   p_secondary_uom             IN            VARCHAR2,
   p_secondary_quantity        IN            VARCHAR2,
   p_serial_numbers            IN            VARCHAR2,
   p_serial_allocated_flag     IN            VARCHAR2,  -- Y/N
   p_lot_controlled            IN            VARCHAR2,  -- Y/N
   p_serial_controlled         IN            VARCHAR2,  -- Y/N
   x_return_status             OUT NOCOPY    VARCHAR2,
   x_msg_count                 OUT NOCOPY    NUMBER,
   x_msg_data                  OUT NOCOPY    VARCHAR2)
  IS
	 l_serial_transaction_temp_id      NUMBER;
Line: 390

		update_mtlt                    BOOLEAN,
		delete_mtlt                    BOOLEAN);
Line: 397

		delete_msnt                    BOOLEAN);
Line: 406

		SELECT inventory_item_id, transaction_temp_id, primary_quantity
	 , item_primary_uom_code, transaction_quantity, transaction_uom
	 , secondary_transaction_quantity, secondary_uom_code
		  FROM mtl_material_transactions_temp
		  WHERE transaction_temp_id IN (v_transaction_temp_id1, v_transaction_temp_id2)
		  FOR UPDATE;
Line: 414

		SELECT lot_number, primary_quantity, transaction_quantity, secondary_quantity
			, serial_transaction_temp_id
		  FROM mtl_transaction_lots_temp
		  WHERE transaction_temp_id = v_transaction_temp_id
		  ORDER BY lot_number
		  FOR UPDATE;
Line: 422

		SELECT fm_serial_number
		  FROM mtl_serial_numbers_temp
		  WHERE transaction_temp_id = v_transaction_temp_id
		  ORDER BY fm_serial_number
		  FOR UPDATE;
Line: 429

		SELECT
		  transaction_temp_id,
		  lot_number,
		  serial_number,
		  SUM(transaction_quantity) transaction_quantity,
		  SUM(primary_quantity) primary_quantity,
		  SUM(secondary_quantity) secondary_quantity
		FROM mtl_allocations_gtmp
		WHERE (lot_number IS NOT NULL OR serial_number IS NOT NULL)
		GROUP BY transaction_temp_id, lot_number, serial_number, secondary_quantity
		ORDER BY transaction_temp_id, lot_number, serial_number;
Line: 445

	  mydebug('Inside UPDATE_LOADED_PART', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 477

	  mydebug('Conversion Factor: ' || l_conversion_factor, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 478

	  mydebug('Conversion Factor1: ' || l_conversion_factor1, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 479

	  mydebug('Conversion Factor2: ' || l_conversion_factor2, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 483

		 fnd_message.set_token('ROUTINE', '- proc_insert_update_task' );
Line: 501

		 p_confirmed_sugg_qty       => l_secondary_quantity1,--need to revisit on testing case for update_loaded_part for fulfill base 'S'
		 p_confirmed_sec_qty        => p_secondary_quantity,
		 x_return_status            => x_return_status,
		 x_msg_count                => x_msg_count,
		 x_msg_data                 => x_msg_data);
Line: 508

		 mydebug('Return Status from Lot Serial Parse: ' || x_return_status, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 524

			mydebug('Loaded...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 531

			   mydebug(i || ' Lot Number: ' || mtlt_record.lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 542

			mydebug('Confirmed...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 555

				  mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be deleted', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 557

			   l_lot_table1(i).delete_mtlt := TRUE;
Line: 564

			   mydebug(i || ' Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 573

					 mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be updated', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 576

				  l_lot_table1(i).update_mtlt := TRUE;
Line: 590

			l_lot_table1(i).delete_mtlt := TRUE;
Line: 599

			   SELECT serial_transaction_temp_id
				 INTO l_serial_transaction_temp_id
				 FROM mtl_transaction_lots_temp
				 WHERE transaction_temp_id = p_transaction_temp_id2
				 AND lot_number = l_lot_table1(i).lot_number;
Line: 613

				  mydebug(i || 'Lot Number: ' || l_lot_table1(i).lot_number || ' exists in remaining', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 615

				  mydebug(i || 'Lot Number: ' || l_lot_table1(i).lot_number || ' does not exist in remaining', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 621

			   mydebug(i || 'Delta: ' || l_lot_table1(i).delta_primary_quantity, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 622

	 mydebug(i || 'Sec Delta: ' || l_lot_table1(i).delta_secondary_quantity, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 625

			IF l_lot_table1(i).delete_mtlt THEN

			   IF l_row_exists = 1 THEN

				  IF (l_debug = 1) THEN
					 mydebug(i || 'Deleting Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 633

				  UPDATE mtl_transaction_lots_temp
					SET primary_quantity = primary_quantity + l_lot_table1(i).delta_primary_quantity,
						transaction_quantity = transaction_quantity +
											   Round(l_lot_table1(i).delta_primary_quantity * l_conversion_factor2,
													 l_g_decimal_precision),
		secondary_quantity = secondary_quantity + l_lot_table1(i).delta_secondary_quantity,
						last_update_date     = Sysdate,
						last_updated_by      = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id2
					AND lot_number = l_lot_table1(i).lot_number;
Line: 644

				  DELETE FROM mtl_transaction_lots_temp
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 651

					 mydebug(i || 'Transferring Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 654

				  UPDATE mtl_transaction_lots_temp
					SET transaction_temp_id        = p_transaction_temp_id2,
						transaction_quantity       = Round(primary_quantity * l_conversion_factor2, l_g_decimal_precision),
						last_update_date     = Sysdate,
						last_updated_by      = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 664

			 ELSIF l_lot_table1(i).update_mtlt THEN

			   UPDATE mtl_transaction_lots_temp
				 SET primary_quantity     = l_lot_table1(i).primary_quantity,
					 transaction_quantity = Round(l_lot_table1(i).primary_quantity * l_conversion_factor, l_g_decimal_precision),
					 secondary_quantity   = l_lot_table1(i).secondary_quantity,
					 last_update_date     = Sysdate,
					 last_updated_by      = p_user_id
				 WHERE transaction_temp_id = p_transaction_temp_id1
				 AND lot_number = l_lot_table1(i).lot_number;
Line: 678

					 mydebug(i || 'Updating Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 681

				  UPDATE mtl_transaction_lots_temp
					SET primary_quantity     = primary_quantity + l_lot_table1(i).delta_primary_quantity,
						transaction_quantity = transaction_quantity + Round(l_lot_table1(i).delta_primary_quantity * l_conversion_factor2,
																			l_g_decimal_precision),
		secondary_quantity     = secondary_quantity + l_lot_table1(i).delta_secondary_quantity,
						last_update_date     = Sysdate,
						last_updated_by      = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id2
					AND lot_number = l_lot_table1(i).lot_number;
Line: 693

					 mydebug(i || 'Inserting Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 696

				  SELECT *
					INTO l_mtlt_rec
					FROM mtl_transaction_lots_temp
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 705

				  proc_insert_mtlt
				   (p_lot_record         => l_mtlt_rec,
					x_return_status      => x_return_status,
					x_msg_count          => x_msg_count,
					x_msg_data           => x_msg_data);
Line: 718

			END IF; -- delete/update mtlt
Line: 724

			mydebug('Loaded...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 732

			   mydebug(j || ' Serial Number: ' || msnt_record.fm_serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 740

			mydebug('Confirmed...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 750

			   l_serial_table1(j).delete_msnt := TRUE;
Line: 755

			   mydebug(j || ' Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 763

			l_serial_table1(j).delete_msnt := TRUE;
Line: 771

			IF l_serial_table1(j).delete_msnt THEN

			   IF p_serial_allocated_flag = 'Y' THEN

				  IF (l_debug = 1) THEN
					 mydebug(j || 'Transferring Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 779

				  UPDATE mtl_serial_numbers_temp
					SET transaction_temp_id = p_transaction_temp_id2,
						last_update_date    = Sysdate,
						last_updated_by     = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND fm_serial_number = l_serial_table1(j).serial_number;
Line: 788

					 mydebug(j || 'Deleting Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 791

				  DELETE FROM mtl_serial_numbers_temp
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND fm_serial_number = l_serial_table1(j).serial_number;
Line: 796

				  UPDATE mtl_serial_numbers
					SET group_mark_id       = NULL,
						last_update_date    = Sysdate,
						last_updated_by     = p_user_id
					WHERE serial_number = l_serial_table1(j).serial_number
					AND inventory_item_id = l_inventory_item_id;
Line: 812

			mydebug('Loaded...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 820

			   mydebug(i || ' Lot Number: ' || mtlt_record.lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 828

				  mydebug(j || ' Serial Number: ' || msnt_record.fm_serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 842

			mydebug('Confirmed...', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 853

			   mydebug(i || ' Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 863

				  mydebug(j || 'Marking Serial Number: ' || l_serial_table1(j).serial_number || ' to be deleted', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 866

			   l_serial_table1(j).delete_msnt := TRUE;
Line: 870

			   l_lot_table1(i).update_mtlt := TRUE;
Line: 873

				  l_lot_table1(i).delete_mtlt := TRUE;
Line: 876

					mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be deleted', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 882

					mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be updated', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 893

					 mydebug('Incrementing i', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 900

			   mydebug(j || ' Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 910

			   mydebug(j || 'Marking Serial Number: ' || l_serial_table1(j).serial_number || ' to be deleted', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 913

			l_serial_table1(j).delete_msnt := TRUE;
Line: 917

			l_lot_table1(i).update_mtlt := TRUE;
Line: 920

			   l_lot_table1(i).delete_mtlt := TRUE;
Line: 923

				  mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be deleted', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 929

				  mydebug(i || 'Marking Lot Number: ' || l_lot_table1(i).lot_number || ' to be updated', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 940

				  mydebug('Incrementing i', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 952

			   SELECT serial_transaction_temp_id
				 INTO l_serial_transaction_temp_id
				 FROM mtl_transaction_lots_temp
				 WHERE transaction_temp_id = p_transaction_temp_id2
				 AND lot_number = l_lot_table1(i).lot_number;
Line: 964

					 SELECT mtl_material_transactions_s.NEXTVAL
					   INTO l_serial_transaction_temp_id
					   FROM dual;
Line: 972

				  mydebug(i || 'Lot Number: ' || l_lot_table1(i).lot_number || ' exists in remaining', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 974

				  mydebug(i || 'Lot Number: ' || l_lot_table1(i).lot_number || ' does not exist in remaining', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 980

			   IF l_serial_table1(j).delete_msnt THEN

				  IF p_serial_allocated_flag = 'Y' THEN

					 IF (l_debug = 1) THEN
						mydebug(j || 'Transferring Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 988

					 UPDATE mtl_serial_numbers_temp
					   SET transaction_temp_id = l_serial_transaction_temp_id,
						   last_update_date    = Sysdate,
						   last_updated_by     = p_user_id
					   WHERE transaction_temp_id = l_serial_table1(j).transaction_temp_id
					   AND fm_serial_number = l_serial_table1(j).serial_number;
Line: 997

						mydebug(j || 'Deleting Serial Number: ' || l_serial_table1(j).serial_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1000

					 DELETE FROM mtl_serial_numbers_temp
					   WHERE transaction_temp_id = l_serial_table1(j).transaction_temp_id
					   AND fm_serial_number = l_serial_table1(j).serial_number;
Line: 1005

					 UPDATE mtl_serial_numbers
					   SET group_mark_id       = NULL,
						   last_update_date    = Sysdate,
						   last_updated_by     = p_user_id
					   WHERE serial_number = l_serial_table1(j).serial_number
					   AND inventory_item_id = l_inventory_item_id;
Line: 1015

					 mydebug(j || ' Serial Number: ' || l_serial_table1(j).serial_number || ' left untouched', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1023

			IF l_lot_table1(i).delete_mtlt THEN

			   IF l_row_exists = 1 THEN

				  IF (l_debug = 1) THEN
					 mydebug(i || 'Deleting Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1031

				  UPDATE mtl_transaction_lots_temp
					SET primary_quantity = primary_quantity + l_lot_table1(i).delta_primary_quantity,
						transaction_quantity = transaction_quantity +
											   Round(l_lot_table1(i).delta_primary_quantity * l_conversion_factor2,
													 l_g_decimal_precision),
						last_update_date     = Sysdate,
						last_updated_by      = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id2
					AND lot_number = l_lot_table1(i).lot_number;
Line: 1041

				  DELETE FROM mtl_transaction_lots_temp
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 1048

					 mydebug(i || 'Transferring Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1051

				  UPDATE mtl_transaction_lots_temp
					SET transaction_temp_id        = p_transaction_temp_id2,
						serial_transaction_temp_id = l_serial_transaction_temp_id,
						transaction_quantity       = Round(primary_quantity * l_conversion_factor2, l_g_decimal_precision),
						last_update_date           = Sysdate,
						last_updated_by            = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 1062

			 ELSIF l_lot_table1(i).update_mtlt THEN

			   UPDATE mtl_transaction_lots_temp
				 SET primary_quantity     = l_lot_table1(i).primary_quantity,
					 transaction_quantity = Round(l_lot_table1(i).primary_quantity * l_conversion_factor, l_g_decimal_precision),
					 secondary_quantity   = l_lot_table1(i).secondary_quantity,
					 last_update_date     = Sysdate,
					 last_updated_by      = p_user_id
				 WHERE transaction_temp_id = p_transaction_temp_id1
				 AND lot_number = l_lot_table1(i).lot_number;
Line: 1076

					 mydebug(i || 'Updating Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1079

				  UPDATE mtl_transaction_lots_temp
					SET primary_quantity     = primary_quantity + l_lot_table1(i).delta_primary_quantity,
						transaction_quantity = transaction_quantity + Round(l_lot_table1(i).delta_primary_quantity * l_conversion_factor2,
																			l_g_decimal_precision),
						last_update_date     = Sysdate,
						last_updated_by      = p_user_id
					WHERE transaction_temp_id = p_transaction_temp_id2
					AND lot_number = l_lot_table1(i).lot_number;
Line: 1090

					 mydebug(i || 'Inserting Lot Number: ' || l_lot_table1(i).lot_number, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1093

				  SELECT *
					INTO l_mtlt_rec
					FROM mtl_transaction_lots_temp
					WHERE transaction_temp_id = p_transaction_temp_id1
					AND lot_number = l_lot_table1(i).lot_number;
Line: 1103

				  proc_insert_mtlt
				   (p_lot_record         => l_mtlt_rec,
					x_return_status      => x_return_status,
					x_msg_count          => x_msg_count,
					x_msg_data           => x_msg_data);
Line: 1109

				  mydebug('Return status from insert MTLT : ' || x_return_status, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1116

			END IF; -- delete/update mtlt
Line: 1128

	  mydebug('Updating MMTT with delta qty: ' || l_delta_primary_quantity, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1129

  mydebug('Updating MMTT with delta sec qty: ' || l_delta_secondary_quantity, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1132

   UPDATE mtl_material_transactions_temp
	 SET transaction_quantity           = Round(l_primary_quantity*l_conversion_factor, l_g_decimal_precision),
		 transaction_uom                = p_transaction_uom,
		 primary_quantity               = l_primary_quantity,
		 secondary_transaction_quantity = l_secondary_quantity,
		 secondary_uom_code             = p_secondary_uom,
		 lpn_id                         = content_lpn_id,
		 content_lpn_id                 = NULL,
		 transfer_lpn_id                = p_transfer_lpn_id,
		 last_update_date               = Sysdate,
		 last_updated_by                = p_user_id
	 WHERE transaction_temp_id = p_transaction_temp_id1
	 returning lpn_id INTO l_lpn_id;
Line: 1147

   UPDATE wms_license_plate_numbers
	 SET lpn_context = 1
	   --, last_update_date = SYSDATE /* Bug 9448490 Lot Substitution Project */
	   --, last_updated_by = fnd_global.user_id /* Bug 9448490 Lot Substitution Project */
	 WHERE lpn_id = l_lpn_id;
Line: 1154

   UPDATE mtl_material_transactions_temp
	 SET transaction_quantity = transaction_quantity +  Round(l_delta_primary_quantity*l_conversion_factor2, l_g_decimal_precision),
		 primary_quantity     = primary_quantity + l_delta_primary_quantity,
   secondary_transaction_quantity = secondary_transaction_quantity+l_delta_secondary_quantity,
		 last_update_date     = Sysdate,
		 last_updated_by      = p_user_id
	 WHERE transaction_temp_id = p_transaction_temp_id2;
Line: 1168

		 mydebug('Error', 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1176

		 mydebug('Error: ' || Sqlerrm, 'WMS_TASK_LOAD.UPDATE_LOADED_PART');
Line: 1179

END update_loaded_part;
Line: 1182

			   p_action                    IN            VARCHAR2  -- LOAD_MULTIPLE/LOAD_SINGLE/SPLIT/UPDATE_LOADED
			  ,p_exception                 IN            VARCHAR2  -- SHORT/OVER
			  ,p_organization_id           IN            NUMBER
			  ,p_user_id                   IN            NUMBER
			  ,p_transaction_header_id     IN            NUMBER
			  ,p_transaction_temp_id       IN            NUMBER
			  ,p_parent_line_id            IN            NUMBER
			  ,p_remaining_temp_id         IN            NUMBER
			  ,p_lpn_id                    IN            NUMBER
			  ,p_content_lpn_id            IN            NUMBER
			  ,p_transfer_lpn_id           IN            NUMBER
			  ,p_confirmed_sub             IN            VARCHAR2
			  ,p_confirmed_locator_id      IN            NUMBER
			  ,p_confirmed_uom             IN            VARCHAR2
			  ,p_suggested_uom             IN            VARCHAR2
			  ,p_primary_uom               IN            VARCHAR2
			  ,p_inventory_item_id         IN            NUMBER
			  ,p_revision                  IN            VARCHAR2
			  ,p_confirmed_trx_qty         IN            NUMBER
			  ,p_confirmed_lots            IN            VARCHAR2
			  ,p_confirmed_lot_trx_qty     IN            VARCHAR2
			  ,p_confirmed_sec_uom         IN            VARCHAR2
			  ,p_confirmed_sec_qty         IN            VARCHAR2
			  ,p_confirmed_serials         IN            VARCHAR2
			  ,p_container_item_id         IN            NUMBER
			  ,p_lpn_match                 IN            NUMBER
			  ,p_lpn_match_lpn_id          IN            NUMBER
			  ,p_serial_allocated_flag     IN            VARCHAR2
			  ,p_lot_controlled            IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled         IN            VARCHAR2  -- Y/N
			  ,p_parent_lpn_id             IN            NUMBER
			  ,x_new_transaction_temp_id   OUT NOCOPY    NUMBER
			  ,x_cms_check                 OUT NOCOPY    VARCHAR2  -- FAIL/PASS
			  ,x_return_status             OUT NOCOPY    VARCHAR2
			  ,x_msg_count                 OUT NOCOPY    NUMBER
			  ,x_msg_data                  OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots	       IN	         VARCHAR2--/* Bug 9448490 Lot Substitution Project */
			  ,p_full_lot_allocation       IN            VARCHAR2 DEFAULT 'Y'  --Added for 14699845 (Flexible Lot Allocation)
			  ,p_fulfillment_base          IN            VARCHAR2 DEFAULT 'P') --16070349
IS
   --PRAGMA AUTONOMOUS_TRANSACTION;
Line: 1228

   l_insert                         VARCHAR2(2)  :=  NULL;
Line: 1229

   l_update                         VARCHAR2(2)  :=  NULL;
Line: 1247

	  SELECT transaction_temp_id
	  FROM   mtl_material_transactions_temp
	  WHERE  transaction_header_id  = p_transaction_header_id
	  AND    transaction_temp_id   <> p_transaction_temp_id
	  AND    inventory_item_id      = p_inventory_item_id
	  AND    nvl(revision,'@@')     = nvl(p_revision,'@@')
	  AND    subinventory_code      = p_confirmed_sub
	  AND    locator_id             = p_confirmed_locator_id
	  AND    transaction_uom        = p_confirmed_uom
	  AND    transfer_lpn_id        = p_transfer_lpn_id
	  AND    nvl(content_lpn_id,0)  = nvl(p_content_lpn_id,0)
	  AND    nvl(lpn_id,0)          = nvl(p_lpn_id,0);
Line: 1329

	--Insert the MSNTs HWSNIssue 13860546
	IF (    NVL (p_lot_controlled,'N') = 'Y'
		AND NVL (p_serial_controlled,'N') = 'Y'
		AND NVL (p_serial_allocated_flag, 'N') = 'N'
		AND p_lpn_match IN (1, 3)
		AND lpn_has_unalloc_lots (NVL (l_content_lpn_id,l_lpn_id),
								  p_organization_id,
								  p_inventory_item_id,
								  p_revision,
								  p_transaction_temp_id
								 )
	   )
	THEN
	  --Have to review this condition
	   mydebug ('Inserting msnts');
Line: 1344

	   insert_serials_temp (p_transaction_temp_id      => p_transaction_temp_id,
							p_lpn_id                   => NVL (l_content_lpn_id , l_lpn_id),
							p_org_id                   => p_organization_id,
							p_item_id                  => p_inventory_item_id,
							p_rev                      => p_revision,
							p_confirmed_trx_qty        => p_confirmed_trx_qty,
							x_return_status            => x_return_status,
							x_msg                      => x_msg_data
						   );
Line: 1356

		  mydebug ('Error while inserting MSNTs');
Line: 1363

   IF p_action = 'UPDATE_LOADED' THEN
	  update_loaded_part
		(p_user_id                   => p_user_id,
		 p_organization_id 			 => p_organization_id, --BUG12622871LSC
		 p_transaction_temp_id1      => p_transaction_temp_id,
		 p_transaction_temp_id2      => p_remaining_temp_id,
		 p_transfer_lpn_id           => l_transfer_lpn_id,
		 p_transaction_uom           => p_confirmed_uom,
		 p_transaction_quantity      => p_confirmed_trx_qty,
		 p_lot_numbers               => p_confirmed_lots,
		 p_lot_transaction_quantity  => p_confirmed_lot_trx_qty,
		 p_secondary_uom             => p_confirmed_sec_uom,
		 p_secondary_quantity        => p_confirmed_sec_qty,
		 p_serial_numbers            => p_confirmed_serials,
		 p_serial_allocated_flag     => p_serial_allocated_flag,
		 p_lot_controlled            => p_lot_controlled,
		 p_serial_controlled         => p_serial_controlled,
		 x_return_status             => x_return_status,
		 x_msg_count                 => x_msg_count,
		 x_msg_data                  => x_msg_data);
Line: 1407

	   /* Update the LPN context to "Packing context" (8).
	   -- if p_lpn_match = 1,3 (exact match or fully consumable LPN) then
	   -- p_lpn_match_lpn_id will be set to Packing context(8) otherwise , we will not
	   -- change the context of from lpn .
	   -- Always set the status of p_transfer_lpn_id = Packing context(8) , whether
	   -- pre-generated or already in Packing context" */
	   --
		l_progress    :=  '200';
Line: 1423

			 -- Bug5659809: update last_update_date and last_update_by as well
			  UPDATE wms_license_plate_numbers
				SET lpn_context = l_lpn_context_packing
				   ,catch_weight_flag = NULL --16466288
				 -- , last_update_date = SYSDATE /* Bug 9448490 Lot Substitution Project */
				 -- , last_updated_by = fnd_global.user_id /* Bug 9448490 Lot Substitution Project */
			  WHERE lpn_id = l_lpn_match_lpn_id
				AND lpn_context = l_lpn_context_inv --, l_transfer_lpn_id)
				AND organization_id = p_organization_id;
Line: 1434

				 mydebug ('Cannot find LPNs to update the context' );
Line: 1447

		ELSIF (p_lpn_match = 4 AND l_transfer_lpn_id = l_lpn_match_lpn_id) THEN 	--added following so that lpn context is updated properly after load bug 12595055  OR (l_lpn_id = l_lpn_match_lpn_id))
			 mydebug ('Coming to the elseif portion with lpn match values as ' || p_lpn_match );
Line: 1450

				UPDATE wms_license_plate_numbers
				SET lpn_context = l_lpn_context_packing
				   ,catch_weight_flag = NULL --16466288
			  WHERE lpn_id = l_lpn_match_lpn_id
				AND lpn_context = l_lpn_context_inv --, l_transfer_lpn_id)
				AND organization_id = p_organization_id;
Line: 1458

				 mydebug ('Cannot find LPNs to update the context' );
Line: 1483

		   -- Bug5659809: update last_update_date and last_update_by as well
		   UPDATE wms_license_plate_numbers
			 SET lpn_context = l_lpn_context_packing
				,catch_weight_flag = NULL --16466288
			   --, last_update_date = SYSDATE /* Bug 9448490 Lot Substitution Project */
			   --, last_updated_by = fnd_global.user_id /* Bug 9448490 Lot Substitution Project */
		   WHERE lpn_id = l_transfer_lpn_id
			 AND lpn_context in (l_lpn_context_packing , l_lpn_context_pregenerated)
			 AND organization_id = p_organization_id;
Line: 1494

			  mydebug ('Cannot find LPNs to update the context' );
Line: 1544

			l_insert      := 'Y';  --insert new MMTT
Line: 1545

			l_update      := 'Y1'; -- update original MMTT to reduce qty
Line: 1547

			l_insert      := 'N';  -- do not insert new MMTT
Line: 1548

			l_update      := 'Y1'; -- update original MMTT = conmfirmed qty
Line: 1551

		 l_insert      := 'N';  -- Do not insert new MMTT
Line: 1552

		 l_update      := 'Y2'; -- 2 updates. 1- original MMTT to reduce qty
Line: 1555

	  mydebug('l_insert:' || l_insert || ':l_update:'|| l_update);
Line: 1556

	  proc_insert_update_mmtt
		(p_action                             => l_action
		 ,p_insert                             => l_insert
		 ,p_update                             => l_update
		 ,p_organization_id                    => p_organization_id
		 ,p_user_id                            => p_user_id
		 ,p_transaction_header_id              => p_transaction_header_id
		 ,p_transaction_temp_id                => p_transaction_temp_id
		 ,p_transaction_temp_id_to_merge       => l_transaction_temp_id_to_merge
		 ,p_lpn_id                             => l_lpn_id
		 ,p_content_lpn_id                     => l_content_lpn_id
		 ,p_transfer_lpn_id                    => l_transfer_lpn_id
		 ,p_confirmed_sub                      => p_confirmed_sub
		 ,p_confirmed_locator_id               => p_confirmed_locator_id
		 ,p_confirmed_uom                      => p_confirmed_uom
		 ,p_suggested_uom                      => p_suggested_uom
		 ,p_primary_uom                        => p_primary_uom
		 ,p_inventory_item_id                  => p_inventory_item_id
		 ,p_revision                           => p_revision
		 ,p_confirmed_trx_qty                  => p_confirmed_trx_qty
		 ,p_confirmed_lots                     => p_confirmed_lots
		 ,p_confirmed_lot_trx_qty              => p_confirmed_lot_trx_qty
		 ,p_confirmed_sec_uom                  => p_confirmed_sec_uom
		 ,p_confirmed_sec_qty                  => p_confirmed_sec_qty
		 ,p_confirmed_serials                  => p_confirmed_serials
		 ,p_container_item_id                  => l_container_item_id
		 ,p_lpn_match                          => p_lpn_match
		 ,p_lpn_match_lpn_id                   => l_lpn_match_lpn_id
		 ,p_serial_allocated_flag              => p_serial_allocated_flag
		 ,p_lot_controlled                     => p_lot_controlled
		 ,p_serial_controlled                  => p_serial_controlled
		 ,p_wms_task_status                    => l_g_task_loaded
		 ,p_exception                          => p_exception
		 ,p_parent_lpn_id                      => l_parent_lpn_id
		 ,x_new_transaction_temp_id            => l_new_transaction_temp_id
		 ,x_return_status                      => x_return_status
		 ,x_msg_count                          => x_msg_count
		 ,x_msg_data                           => x_msg_data
		 ,p_substitute_lots	                   => p_substitute_lots --/* Bug 9448490 Lot Substitution Project */
		 ,p_full_lot_allocation                => p_full_lot_allocation); -- Added for 14699845 (Flexible Lot Allocation)
Line: 1605

	  Action l_insert   L_update  update orginalTSK UpdMergeTSK   InsertNewTSK
		SPLIT Y   Y1  N   N  Y
		SPLIT N   Y2  Y   Y  N
		LOAD_M N   Y1  Y   N  N
		LOAD_M N   Y2  Y-Delete  Y  N
		LOAD_S N   Y1  Y   N  N
		*/

		l_progress    :=  '500';
Line: 1615

	  proc_insert_update_task -- new task using p_transaction_temp_id);
Line: 1617

		 ,p_insert                    => l_insert
		 ,p_update                    => l_update
		 ,p_temp_id                   => p_transaction_temp_id
		 ,p_new_temp_id               => l_new_transaction_temp_id -- will be notNULL only if p_insert=Y
		 ,p_merge_temp_id             => l_transaction_temp_id_to_merge
		 ,p_task_status               => l_g_task_loaded
		 ,p_user_id                   => p_user_id
		 ,x_return_status             => x_return_status
		 ,x_msg_count                 => x_msg_count
		 ,x_msg_data                  => x_msg_data);
Line: 1667

PROCEDURE  proc_insert_update_task
  (p_action                    IN            VARCHAR2
   ,p_insert                    IN            VARCHAR2
   ,p_update                    IN            VARCHAR2
   ,p_temp_id                   IN            NUMBER
   ,p_new_temp_id               IN            NUMBER
   ,p_merge_temp_id             IN            NUMBER
   ,p_task_status               IN            NUMBER
   ,p_user_id                   IN            NUMBER
   ,x_return_status             OUT NOCOPY    VARCHAR2
   ,x_msg_count                 OUT NOCOPY    NUMBER
   ,x_msg_data                  OUT NOCOPY    VARCHAR2)
  IS
	 l_proc_name               VARCHAR2(30) :=  'proc_insert_update_task';
Line: 1684

   mydebug(l_proc_name || ': Before Insert into WMSDT');
Line: 1689

   mydebug ('p_insert         = ' || p_insert);
Line: 1690

   mydebug ('p_update         = ' || p_update);
Line: 1696

   IF p_insert = 'Y' THEN
	   INSERT INTO wms_dispatched_tasks
						  (task_id
						  ,transaction_temp_id
						  ,organization_id
						  ,user_task_type
						  ,person_id
						  ,effective_start_date
						  ,effective_end_date
						  ,equipment_id
						  ,equipment_instance
						  ,person_resource_id
						  ,machine_resource_id
						  ,status
						  ,dispatched_time
						  ,loaded_time
						  ,drop_off_time
						  ,last_update_date
						  ,last_updated_by
						  ,creation_date
						  ,created_by
						  ,last_update_login
						  ,attribute_category
						  ,attribute1
						  ,attribute2
						  ,attribute3
						  ,attribute4
						  ,attribute5
						  ,attribute6
						  ,attribute7
						  ,attribute8
						  ,attribute9
						  ,attribute10
						  ,attribute11
						  ,attribute12
						  ,attribute13
						  ,attribute14
						  ,attribute15
						  ,task_type
						  ,priority
						  ,task_group_id
						  ,device_id
						  ,device_inVoked
						  ,device_request_id
						  ,suggested_dest_subinventory
						  ,suggested_dest_locator_id
						  ,operation_plan_id
						  ,move_order_line_id
						  ,transfer_lpn_id )
		  (SELECT wms_dispatched_tasks_s.NEXTVAL
						  ,p_new_temp_id             -- parameter
						  ,organization_id
						  ,user_task_type
						  ,person_id
						  ,effective_start_date
						  ,effective_end_date
						  ,equipment_id
						  ,equipment_instance
						  ,person_resource_id
						  ,machine_resource_id
						  ,p_task_status                -- parameter
						  ,dispatched_time
						  ,SYSDATE
						  ,drop_off_time
						  ,SYSDATE
						  ,last_updated_by
						  ,SYSDATE
						  ,p_user_id         -- parameter
						  ,last_update_login
						  ,attribute_category
						  ,attribute1
						  ,attribute2
						  ,attribute3
						  ,attribute4
						  ,attribute5
						  ,attribute6
						  ,attribute7
						  ,attribute8
						  ,attribute9
						  ,attribute10
						  ,attribute11
						  ,attribute12
						  ,attribute13
						  ,attribute14
						  ,attribute15
						  ,task_type
						  ,priority
						  ,task_group_id
						  ,device_id
						  ,device_invoked
						  ,device_request_id
						  ,suggested_dest_subinventory
						  ,suggested_dest_locator_id
						  ,operation_plan_id
						  ,move_order_line_id
						  ,transfer_lpn_id
			FROM   wms_dispatched_tasks
			WHERE transaction_temp_id = p_temp_id);
Line: 1795

		 myDebug('Error inserting a new task using WDT record for : '|| p_temp_id);
Line: 1798

		 fnd_message.set_token('ROUTINE', '- proc_insert_update_task' );
Line: 1805

	  IF p_update = 'Y1' THEN
		 l_transaction_temp_id := p_temp_id; -- update only the original task
Line: 1808

		 l_transaction_temp_id := p_merge_temp_id; -- update the merged task
Line: 1813

	  UPDATE  wms_dispatched_tasks
	  SET     status =  p_task_status
			  ,loaded_time = SYSDATE
			  ,last_update_date = SYSDATE
			  ,last_updated_by   = p_user_id
	  WHERE transaction_temp_id = l_transaction_temp_id;
Line: 1824

		 fnd_message.set_token('ROUTINE', '- proc_insert_update_task' );
Line: 1828

	  IF p_update = 'Y2' AND p_action = l_g_action_load_multiple THEN
		 fnd_message.set_token('ROUTINE', '- proc_insert_update_task' );
Line: 1833

		 -- delete the original one with p_transaction_temp_id
		 DELETE  wms_dispatched_tasks
		  WHERE  transaction_temp_id = p_temp_id;
Line: 1840

			fnd_message.set_token('ROUTINE', '- proc_insert_update_task' );
Line: 1873

END proc_insert_update_task;
Line: 2403

PROCEDURE proc_insert_update_mmtt
			  (p_action                               IN            VARCHAR2
			  ,p_insert                               IN            VARCHAR2
			  ,p_update                               IN            VARCHAR2
			  ,p_organization_id                      IN            NUMBER
			  ,p_user_id                              IN            NUMBER
			  ,p_transaction_header_id                IN            NUMBER
			  ,p_transaction_temp_id                  IN            NUMBER
			  ,p_transaction_temp_id_to_merge         IN            NUMBER
			  ,p_lpn_id                               IN            NUMBER
			  ,p_content_lpn_id                       IN            NUMBER
			  ,p_transfer_lpn_id                      IN            NUMBER
			  ,p_confirmed_sub                        IN            VARCHAR2
			  ,p_confirmed_locator_id                 IN            NUMBER
			  ,p_confirmed_uom                        IN            VARCHAR2
			  ,p_suggested_uom                        IN            VARCHAR2
			  ,p_primary_uom                          IN            VARCHAR2
			  ,p_inventory_item_id                    IN            NUMBER
			  ,p_revision                             IN            VARCHAR2
			  ,p_confirmed_trx_qty                    IN            NUMBER
			  ,p_confirmed_lots                       IN            VARCHAR2
			  ,p_confirmed_lot_trx_qty                IN            VARCHAR2
			  ,p_confirmed_sec_uom                    IN            VARCHAR2
			  ,p_confirmed_sec_qty                    IN            VARCHAR2
			  ,p_confirmed_serials                    IN            VARCHAR2
			  ,p_container_item_id                    IN            NUMBER
			  ,p_wms_task_status                      IN            NUMBER
			  ,p_lpn_match                            IN            NUMBER
			  ,p_lpn_match_lpn_id                     IN            NUMBER
			  ,p_serial_allocated_flag                IN            VARCHAR2
			  ,p_lot_controlled                       IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled                    IN            VARCHAR2  -- Y/N
			  ,p_exception                            IN            VARCHAR2 -- SHORT/OVER
			  ,p_parent_lpn_id                        IN            NUMBER
			  ,x_new_transaction_temp_id              OUT NOCOPY    NUMBER
			  ,x_return_status                        OUT NOCOPY    VARCHAR2
			  ,x_msg_count                            OUT NOCOPY    NUMBER
			  ,x_msg_data                             OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots		              IN	        VARCHAR2 --/* Bug 9448490 Lot Substitution Project */
			  ,p_full_lot_allocation                  IN            VARCHAR2 DEFAULT 'Y')
IS
   l_proc_name                   VARCHAR2(30) :=  'PROC_INSERT_UPDATE_MMTT';
Line: 2475

	  SELECT NVL(fulfillment_base, 'P'),
			 transaction_uom,
			 primary_quantity,
			 transaction_quantity,
			 secondary_transaction_quantity
		INTO l_fulfillment_base,
			 l_orig_mmtt_txn_uom,
			 l_orig_mmtt_pri_qty,
			 l_orig_mmtt_txn_qty,
			 l_orig_mmtt_sec_qty
		FROM mtl_material_transactions_temp
	   WHERE transaction_temp_id = p_transaction_temp_id;
Line: 2496

   mydebug ('p_insert                 = ' || p_insert                 );
Line: 2497

   mydebug ('p_update                 = ' || p_update                 );
Line: 2522

   mydebug ('check for p_substitute_lots as the MTLT in spl case not deleted = ' || p_substitute_lots);
Line: 2605

		mydebug ('l_confirmed_sec_qty post processing before MMTT insert is ' || l_confirmed_sec_qty);
Line: 2607

   IF p_insert = 'Y' THEN
	  l_progress   :=  '110';
Line: 2609

	  SELECT mtl_material_transactions_s.NEXTVAL
	  INTO l_new_transaction_temp_id
	  FROM DUAL;
Line: 2616

	  INSERT INTO mtl_material_transactions_temp
					( TRANSACTION_HEADER_ID
					 ,TRANSACTION_TEMP_ID
					 ,SOURCE_CODE
					 ,SOURCE_LINE_ID
					 ,TRANSACTION_MODE
					 ,LOCK_FLAG
					 ,LAST_UPDATE_DATE
					 ,LAST_UPDATED_BY
					 ,CREATION_DATE
					 ,CREATED_BY
					 ,LAST_UPDATE_LOGIN
					 ,REQUEST_ID
					 ,PROGRAM_APPLICATION_ID
					 ,PROGRAM_ID
					 ,PROGRAM_UPDATE_DATE
					 ,INVENTORY_ITEM_ID
					 ,REVISION
					 ,ORGANIZATION_ID
					 ,SUBINVENTORY_CODE
					 ,LOCATOR_ID
					 ,TRANSACTION_QUANTITY
					 ,PRIMARY_QUANTITY
					 ,TRANSACTION_UOM
					 ,TRANSACTION_COST
					 ,TRANSACTION_TYPE_ID
					 ,TRANSACTION_ACTION_ID
					 ,TRANSACTION_SOURCE_TYPE_ID
					 ,TRANSACTION_SOURCE_ID
					 ,TRANSACTION_SOURCE_NAME
					 ,TRANSACTION_DATE
					 ,ACCT_PERIOD_ID
					 ,DISTRIBUTION_ACCOUNT_ID
					 ,TRANSACTION_REFERENCE
					 ,REQUISITION_LINE_ID
					 ,REQUISITION_DISTRIBUTION_ID
					 ,REASON_ID
					 ,LOT_NUMBER
					 ,LOT_EXPIRATION_DATE
					 ,SERIAL_NUMBER
					 ,RECEIVING_DOCUMENT
					 ,DEMAND_ID
					 ,RCV_TRANSACTION_ID
					 ,MOVE_TRANSACTION_ID
					 ,COMPLETION_TRANSACTION_ID
					 ,WIP_ENTITY_TYPE
					 ,SCHEDULE_ID
					 ,REPETITIVE_LINE_ID
					 ,EMPLOYEE_CODE
					 ,PRIMARY_SWITCH
					 ,SCHEDULE_UPDATE_CODE
					 ,SETUP_TEARDOWN_CODE
					 ,ITEM_ORDERING
					 ,NEGATIVE_REQ_FLAG
					 ,OPERATION_SEQ_NUM
					 ,PICKING_LINE_ID
					 ,TRX_SOURCE_LINE_ID
					 ,TRX_SOURCE_DELIVERY_ID
					 ,PHYSICAL_ADJUSTMENT_ID
					 ,CYCLE_COUNT_ID
					 ,RMA_LINE_ID
					 ,CUSTOMER_SHIP_ID
					 ,CURRENCY_CODE
					 ,CURRENCY_CONVERSION_RATE
					 ,CURRENCY_CONVERSION_TYPE
					 ,CURRENCY_CONVERSION_DATE
					 ,USSGL_TRANSACTION_CODE
					 ,VENDOR_LOT_NUMBER
					 ,ENCUMBRANCE_ACCOUNT
					 ,ENCUMBRANCE_AMOUNT
					 ,SHIP_TO_LOCATION
					 ,SHIPMENT_NUMBER
					 ,TRANSFER_COST
					 ,TRANSPORTATION_COST
					 ,TRANSPORTATION_ACCOUNT
					 ,FREIGHT_CODE
					 ,CONTAINERS
					 ,WAYBILL_AIRBILL
					 ,EXPECTED_ARRIVAL_DATE
					 ,TRANSFER_SUBINVENTORY
					 ,TRANSFER_ORGANIZATION
					 ,TRANSFER_TO_LOCATION
					 ,NEW_AVERAGE_COST
					 ,VALUE_CHANGE
					 ,PERCENTAGE_CHANGE
					 ,MATERIAL_ALLOCATION_TEMP_ID
					 ,DEMAND_SOURCE_HEADER_ID
					 ,DEMAND_SOURCE_LINE
					 ,DEMAND_SOURCE_DELIVERY
					 ,ITEM_SEGMENTS
					 ,ITEM_DESCRIPTION
					 ,ITEM_TRX_ENABLED_FLAG
					 ,ITEM_LOCATION_CONTROL_CODE
					 ,ITEM_RESTRICT_SUBINV_CODE
					 ,ITEM_RESTRICT_LOCATORS_CODE
					 ,ITEM_REVISION_QTY_CONTROL_CODE
					 ,ITEM_PRIMARY_UOM_CODE
					 ,ITEM_UOM_CLASS
					 ,ITEM_SHELF_LIFE_CODE
					 ,ITEM_SHELF_LIFE_DAYS
					 ,ITEM_LOT_CONTROL_CODE
					 ,ITEM_SERIAL_CONTROL_CODE
					 ,ITEM_INVENTORY_ASSET_FLAG
					 ,ALLOWED_UNITS_LOOKUP_CODE
					 ,DEPARTMENT_ID
					 ,DEPARTMENT_CODE
					 ,WIP_SUPPLY_TYPE
					 ,SUPPLY_SUBINVENTORY
					 ,SUPPLY_LOCATOR_ID
					 ,VALID_SUBINVENTORY_FLAG
					 ,VALID_LOCATOR_FLAG
					 ,LOCATOR_SEGMENTS
					 ,CURRENT_LOCATOR_CONTROL_CODE
					 ,NUMBER_OF_LOTS_ENTERED
					 ,WIP_COMMIT_FLAG
					 ,NEXT_LOT_NUMBER
					 ,LOT_ALPHA_PREFIX
					 ,NEXT_SERIAL_NUMBER
					 ,SERIAL_ALPHA_PREFIX
					 ,SHIPPABLE_FLAG
					 ,POSTING_FLAG
					 ,REQUIRED_FLAG
					 ,PROCESS_FLAG
					 ,ERROR_CODE
					 ,ERROR_EXPLANATION
					 ,ATTRIBUTE_CATEGORY
					 ,ATTRIBUTE1
					 ,ATTRIBUTE2
					 ,ATTRIBUTE3
					 ,ATTRIBUTE4
					 ,ATTRIBUTE5
					 ,ATTRIBUTE6
					 ,ATTRIBUTE7
					 ,ATTRIBUTE8
					 ,ATTRIBUTE9
					 ,ATTRIBUTE10
					 ,ATTRIBUTE11
					 ,ATTRIBUTE12
					 ,ATTRIBUTE13
					 ,ATTRIBUTE14
					 ,ATTRIBUTE15
					 ,MOVEMENT_ID
					 ,RESERVATION_QUANTITY
					 ,SHIPPED_QUANTITY
					 ,TRANSACTION_LINE_NUMBER
					 ,TASK_ID
					 ,TO_TASK_ID
					 ,SOURCE_TASK_ID
					 ,PROJECT_ID
					 ,SOURCE_PROJECT_ID
					 ,PA_EXPENDITURE_ORG_ID
					 ,TO_PROJECT_ID
					 ,EXPENDITURE_TYPE
					 ,FINAL_COMPLETION_FLAG
					 ,TRANSFER_PERCENTAGE
					 ,TRANSACTION_SEQUENCE_ID
					 ,MATERIAL_ACCOUNT
					 ,MATERIAL_OVERHEAD_ACCOUNT
					 ,RESOURCE_ACCOUNT
					 ,OUTSIDE_PROCESSING_ACCOUNT
					 ,OVERHEAD_ACCOUNT
					 ,FLOW_SCHEDULE
					 ,COST_GROUP_ID
					 ,TRANSFER_COST_GROUP_ID
					 ,DEMAND_CLASS
					 ,QA_COLLECTION_ID
					 ,KANBAN_CARD_ID
					 ,OVERCOMPLETION_TRANSACTION_QTY
					 ,OVERCOMPLETION_PRIMARY_QTY
					 ,OVERCOMPLETION_TRANSACTION_ID
					 ,END_ITEM_UNIT_NUMBER
					 ,SCHEDULED_PAYBACK_DATE
					 ,LINE_TYPE_CODE
					 ,PARENT_TRANSACTION_TEMP_ID
					 ,PUT_AWAY_STRATEGY_ID
					 ,PUT_AWAY_RULE_ID
					 ,PICK_STRATEGY_ID
					 ,PICK_RULE_ID
					 ,MOVE_ORDER_LINE_ID
					 ,TASK_GROUP_ID
					 ,PICK_SLIP_NUMBER
					 ,RESERVATION_ID
					 ,COMMON_BOM_SEQ_ID
					 ,COMMON_ROUTING_SEQ_ID
					 ,ORG_COST_GROUP_ID
					 ,COST_TYPE_ID
					 ,TRANSACTION_STATUS
					 ,STANDARD_OPERATION_ID
					 ,TASK_PRIORITY
					 ,WMS_TASK_TYPE
					 ,PARENT_LINE_ID
					 ,LPN_ID
					 ,TRANSFER_LPN_ID
					 ,WMS_TASK_STATUS
					 ,CONTENT_LPN_ID
					 ,CONTAINER_ITEM_ID
					 ,CARTONIZATION_ID
					 ,PICK_SLIP_DATE
					 ,REBUILD_ITEM_ID
					 ,REBUILD_SERIAL_NUMBER
					 ,REBUILD_ACTIVITY_ID
					 ,REBUILD_JOB_NAME
					 ,ORGANIZATION_TYPE
					 ,TRANSFER_ORGANIZATION_TYPE
					 ,OWNING_ORGANIZATION_ID
					 ,OWNING_TP_TYPE
					 ,XFR_OWNING_ORGANIZATION_ID
					 ,TRANSFER_OWNING_TP_TYPE
					 ,PLANNING_ORGANIZATION_ID
					 ,PLANNING_TP_TYPE
					 ,XFR_PLANNING_ORGANIZATION_ID
					 ,TRANSFER_PLANNING_TP_TYPE
					 ,SECONDARY_UOM_CODE
					 ,SECONDARY_TRANSACTION_QUANTITY
					 ,TRANSACTION_BATCH_ID
					 ,TRANSACTION_BATCH_SEQ
					 ,ALLOCATED_LPN_ID
					 ,SCHEDULE_NUMBER
					 ,SCHEDULED_FLAG
					 ,CLASS_CODE
					 ,SCHEDULE_GROUP
					 ,BUILD_SEQUENCE
					 ,BOM_REVISION
					 ,ROUTING_REVISION
					 ,BOM_REVISION_DATE
					 ,ROUTING_REVISION_DATE
					 ,ALTERNATE_BOM_DESIGNATOR
					 ,ALTERNATE_ROUTING_DESIGNATOR
					 ,OPERATION_PLAN_ID
					 ,INTRANSIT_ACCOUNT
					 ,FOB_POINT
					 ,MOVE_ORDER_HEADER_ID
					 ,SERIAL_ALLOCATED_FLAG
					 ,FULFILLMENT_BASE
					)
		  (SELECT
					 TRANSACTION_HEADER_ID
					 ,l_new_transaction_temp_id
					 ,SOURCE_CODE
					 ,SOURCE_LINE_ID
					 ,TRANSACTION_MODE
					 ,LOCK_FLAG
					 ,SYSDATE -- it should not copy from original MMTT
					 ,p_user_id -- it should not copy from original MMTT
					 ,SYSDATE
					 ,p_user_id
					 ,LAST_UPDATE_LOGIN
					 ,REQUEST_ID
					 ,PROGRAM_APPLICATION_ID
					 ,PROGRAM_ID
					 ,PROGRAM_UPDATE_DATE
					 ,INVENTORY_ITEM_ID
					 ,REVISION
					 ,ORGANIZATION_ID
					 ,p_confirmed_sub
					 ,p_confirmed_locator_id
					 ,p_confirmed_trx_qty
					 ,l_confirmed_prim_qty
					 ,NVL(p_confirmed_uom, DECODE(fulfillment_base, 'S', secondary_uom_code, item_primary_uom_code))--MUOM the transaction uom should be confirmed uom
																													--or secondary uom for fulfillment_base 'S' else primary uom
					 ,TRANSACTION_COST
					 ,TRANSACTION_TYPE_ID
					 ,TRANSACTION_ACTION_ID
					 ,TRANSACTION_SOURCE_TYPE_ID
					 ,TRANSACTION_SOURCE_ID
					 ,TRANSACTION_SOURCE_NAME
					 ,TRANSACTION_DATE
					 ,ACCT_PERIOD_ID
					 ,DISTRIBUTION_ACCOUNT_ID
					 ,TRANSACTION_REFERENCE
					 ,REQUISITION_LINE_ID
					 ,REQUISITION_DISTRIBUTION_ID
					 ,REASON_ID
					 ,LOT_NUMBER
					 ,LOT_EXPIRATION_DATE
					 ,SERIAL_NUMBER
					 ,RECEIVING_DOCUMENT
					 ,DEMAND_ID
					 ,RCV_TRANSACTION_ID
					 ,MOVE_TRANSACTION_ID
					 ,COMPLETION_TRANSACTION_ID
					 ,WIP_ENTITY_TYPE
					 ,SCHEDULE_ID
					 ,REPETITIVE_LINE_ID
					 ,EMPLOYEE_CODE
					 ,PRIMARY_SWITCH
					 ,SCHEDULE_UPDATE_CODE
					 ,SETUP_TEARDOWN_CODE
					 ,ITEM_ORDERING
					 ,NEGATIVE_REQ_FLAG
					 ,OPERATION_SEQ_NUM
					 ,PICKING_LINE_ID
					 ,TRX_SOURCE_LINE_ID
					 ,TRX_SOURCE_DELIVERY_ID
					 ,PHYSICAL_ADJUSTMENT_ID
					 ,CYCLE_COUNT_ID
					 ,RMA_LINE_ID
					 ,CUSTOMER_SHIP_ID
					 ,CURRENCY_CODE
					 ,CURRENCY_CONVERSION_RATE
					 ,CURRENCY_CONVERSION_TYPE
					 ,CURRENCY_CONVERSION_DATE
					 ,USSGL_TRANSACTION_CODE
					 ,VENDOR_LOT_NUMBER
					 ,ENCUMBRANCE_ACCOUNT
					 ,ENCUMBRANCE_AMOUNT
					 ,SHIP_TO_LOCATION
					 ,SHIPMENT_NUMBER
					 ,TRANSFER_COST
					 ,TRANSPORTATION_COST
					 ,TRANSPORTATION_ACCOUNT
					 ,FREIGHT_CODE
					 ,CONTAINERS
					 ,WAYBILL_AIRBILL
					 ,EXPECTED_ARRIVAL_DATE
					 ,TRANSFER_SUBINVENTORY
					 ,TRANSFER_ORGANIZATION
					 ,TRANSFER_TO_LOCATION
					 ,NEW_AVERAGE_COST
					 ,VALUE_CHANGE
					 ,PERCENTAGE_CHANGE
					 ,MATERIAL_ALLOCATION_TEMP_ID
					 ,DEMAND_SOURCE_HEADER_ID
					 ,DEMAND_SOURCE_LINE
					 ,DEMAND_SOURCE_DELIVERY
					 ,ITEM_SEGMENTS
					 ,ITEM_DESCRIPTION
					 ,ITEM_TRX_ENABLED_FLAG
					 ,ITEM_LOCATION_CONTROL_CODE
					 ,ITEM_RESTRICT_SUBINV_CODE
					 ,ITEM_RESTRICT_LOCATORS_CODE
					 ,ITEM_REVISION_QTY_CONTROL_CODE
					 ,ITEM_PRIMARY_UOM_CODE
					 ,ITEM_UOM_CLASS
					 ,ITEM_SHELF_LIFE_CODE
					 ,ITEM_SHELF_LIFE_DAYS
					 ,ITEM_LOT_CONTROL_CODE
					 ,ITEM_SERIAL_CONTROL_CODE
					 ,ITEM_INVENTORY_ASSET_FLAG
					 ,ALLOWED_UNITS_LOOKUP_CODE
					 ,DEPARTMENT_ID
					 ,DEPARTMENT_CODE
					 ,WIP_SUPPLY_TYPE
					 ,SUPPLY_SUBINVENTORY
					 ,SUPPLY_LOCATOR_ID
					 ,VALID_SUBINVENTORY_FLAG
					 ,VALID_LOCATOR_FLAG
					 ,LOCATOR_SEGMENTS
					 ,CURRENT_LOCATOR_CONTROL_CODE
					 ,NUMBER_OF_LOTS_ENTERED
					 ,WIP_COMMIT_FLAG
					 ,NEXT_LOT_NUMBER
					 ,LOT_ALPHA_PREFIX
					 ,NEXT_SERIAL_NUMBER
					 ,SERIAL_ALPHA_PREFIX
					 ,SHIPPABLE_FLAG
					 ,POSTING_FLAG
					 ,REQUIRED_FLAG
					 ,PROCESS_FLAG
					 ,ERROR_CODE
					 ,ERROR_EXPLANATION
					 ,ATTRIBUTE_CATEGORY
					 ,ATTRIBUTE1
					 ,ATTRIBUTE2
					 ,ATTRIBUTE3
					 ,ATTRIBUTE4
					 ,ATTRIBUTE5
					 ,ATTRIBUTE6
					 ,ATTRIBUTE7
					 ,ATTRIBUTE8
					 ,ATTRIBUTE9
					 ,ATTRIBUTE10
					 ,ATTRIBUTE11
					 ,ATTRIBUTE12
					 ,ATTRIBUTE13
					 ,ATTRIBUTE14
					 ,ATTRIBUTE15
					 ,MOVEMENT_ID
					 ,RESERVATION_QUANTITY
					 ,SHIPPED_QUANTITY
					 ,TRANSACTION_LINE_NUMBER
					 ,TASK_ID
					 ,TO_TASK_ID
					 ,SOURCE_TASK_ID
					 ,PROJECT_ID
					 ,SOURCE_PROJECT_ID
					 ,PA_EXPENDITURE_ORG_ID
					 ,TO_PROJECT_ID
					 ,EXPENDITURE_TYPE
					 ,FINAL_COMPLETION_FLAG
					 ,TRANSFER_PERCENTAGE
					 ,TRANSACTION_SEQUENCE_ID
					 ,MATERIAL_ACCOUNT
					 ,MATERIAL_OVERHEAD_ACCOUNT
					 ,RESOURCE_ACCOUNT
					 ,OUTSIDE_PROCESSING_ACCOUNT
					 ,OVERHEAD_ACCOUNT
					 ,FLOW_SCHEDULE
					 ,COST_GROUP_ID
					 ,TRANSFER_COST_GROUP_ID
					 ,DEMAND_CLASS
					 ,QA_COLLECTION_ID
					 ,KANBAN_CARD_ID
					 ,OVERCOMPLETION_TRANSACTION_QTY
					 ,OVERCOMPLETION_PRIMARY_QTY
					 ,OVERCOMPLETION_TRANSACTION_ID
					 ,END_ITEM_UNIT_NUMBER
					 ,SCHEDULED_PAYBACK_DATE
					 ,LINE_TYPE_CODE
					 ,PARENT_TRANSACTION_TEMP_ID
					 ,PUT_AWAY_STRATEGY_ID
					 ,PUT_AWAY_RULE_ID
					 ,PICK_STRATEGY_ID
					 ,PICK_RULE_ID
					 ,MOVE_ORDER_LINE_ID
					 ,TASK_GROUP_ID
					 ,PICK_SLIP_NUMBER
					 ,reservation_id
					 ,COMMON_BOM_SEQ_ID
					 ,COMMON_ROUTING_SEQ_ID
					 ,ORG_COST_GROUP_ID
					 ,COST_TYPE_ID
					 ,TRANSACTION_STATUS
					 ,STANDARD_OPERATION_ID
					 ,TASK_PRIORITY
					 ,WMS_TASK_TYPE
					 ,DECODE(PARENT_LINE_ID, NULL,NULL,l_new_transaction_temp_id) -- Take care of BULK parent
					 ,NVL(p_lpn_id,p_parent_lpn_id)     -- process the nesting
														-- fully consumble LPN Pick
					 ,p_transfer_lpn_id                 -- Bug4185621: instead of inheriting previous line's status, use loaded as status for new line
					 ,p_wms_task_status                 -- WMS Task Status
					 ,p_content_lpn_id
					 ,NVL(p_container_item_id,container_item_id)
					 ,CARTONIZATION_ID
					 ,PICK_SLIP_DATE
					 ,REBUILD_ITEM_ID
					 ,REBUILD_SERIAL_NUMBER
					 ,REBUILD_ACTIVITY_ID
					 ,REBUILD_JOB_NAME
					 ,ORGANIZATION_TYPE
					 ,TRANSFER_ORGANIZATION_TYPE
					 ,OWNING_ORGANIZATION_ID
					 ,OWNING_TP_TYPE
					 ,XFR_OWNING_ORGANIZATION_ID
					 ,TRANSFER_OWNING_TP_TYPE
					 ,PLANNING_ORGANIZATION_ID
					 ,PLANNING_TP_TYPE
					 ,XFR_PLANNING_ORGANIZATION_ID
					 ,TRANSFER_PLANNING_TP_TYPE
					 ,p_confirmed_sec_uom
					 ,DECODE(p_confirmed_sec_uom, NULL, NULL, l_confirmed_sec_qty)--Bug4576653/MUOM for fulfill base 'S' assumption is confirmed_sec_uom won't be NULL
					 ,TRANSACTION_BATCH_ID
					 ,TRANSACTION_BATCH_SEQ
					 ,ALLOCATED_LPN_ID
					 ,SCHEDULE_NUMBER
					 ,SCHEDULED_FLAG
					 ,CLASS_CODE
					 ,SCHEDULE_GROUP
					 ,BUILD_SEQUENCE
					 ,BOM_REVISION
					 ,ROUTING_REVISION
					 ,BOM_REVISION_DATE
					 ,ROUTING_REVISION_DATE
					 ,ALTERNATE_BOM_DESIGNATOR
					 ,ALTERNATE_ROUTING_DESIGNATOR
					 ,OPERATION_PLAN_ID
					 ,INTRANSIT_ACCOUNT
					 ,FOB_POINT
					 ,MOVE_ORDER_HEADER_ID
					 ,SERIAL_ALLOCATED_FLAG
					 ,FULFILLMENT_BASE
			 FROM mtl_material_transactions_temp
			WHERE transaction_temp_id = p_transaction_temp_id);
Line: 3091

			  fnd_message.set_name('WMS', 'WMS_INSERT_ALLOCATION'); -- NEWMSG
Line: 3092

			  -- "Error Inserting Allocation ."
			  fnd_msg_pub.ADD;
Line: 3098

   END IF ; -- insert MMTT only if p_insert = 'Y'
Line: 3142

				  ,p_insert                               =>  p_insert
				  ,p_update                               =>  p_update
				  ,p_organization_id                      =>  p_organization_id
				  ,p_user_id                              =>  p_user_id
				  ,p_transaction_header_id                =>  p_transaction_header_id
				  ,p_transaction_temp_id                  =>  p_transaction_temp_id
				  ,p_new_transaction_temp_id              =>  l_new_transaction_temp_id
				  ,p_transaction_temp_id_to_merge         =>  p_transaction_temp_id_to_merge
				  ,p_inventory_item_id                    =>  p_inventory_item_id
				  ,p_revision                             =>  p_revision
				  ,p_suggested_uom                        =>  p_suggested_uom
				  ,p_confirmed_uom                        =>  p_confirmed_uom
				  ,p_primary_uom                          =>  p_primary_uom
				  ,p_confirmed_lots                       =>  p_confirmed_lots
				  ,p_confirmed_lot_trx_qty                =>  p_confirmed_lot_trx_qty
				  ,p_confirmed_serials                    =>  p_confirmed_serials
				  ,p_serial_allocated_flag                =>  p_serial_allocated_flag
				  ,p_lpn_match                            =>  p_lpn_match
				  ,p_lpn_match_lpn_id                     =>  p_lpn_match_lpn_id
				  ,p_confirmed_sec_uom                    =>  p_confirmed_sec_uom
				  ,p_confirmed_sec_qty                    =>  p_confirmed_sec_qty
				  ,p_lot_controlled                       =>  p_lot_controlled
				  ,p_serial_controlled                    =>  p_serial_controlled
				  ,p_exception                            =>  p_exception
				  ,x_return_status                        =>  x_return_status
				  ,x_msg_count                            =>  x_msg_count
				  ,x_msg_data                             =>  x_msg_data
				  ,p_substitute_lots			          =>  p_substitute_lots         -- Bug 9448490 Lot Substitution Project
				  ,p_full_lot_allocation                  =>  p_full_lot_allocation     -- Added for 14699845 (Flexible Lot Allocation)
				  ,p_fulfillment_base                     =>  NVL(l_fulfillment_base, 'P')  -- 16070349
				  ,p_orig_mmtt_txn_uom                    =>  l_orig_mmtt_txn_uom);         -- 16070349
Line: 3188

	   -- may not be necessary to call if p_insert = N , LOAD_SINGLE
	   proc_process_confirmed_serials
				  (p_action                               =>  p_action
				  ,p_insert                               =>  p_insert
				  ,p_update                               =>  p_update
				  ,p_organization_id                      =>  p_organization_id
				  ,p_user_id                              =>  p_user_id
				  ,p_transaction_header_id                =>  p_transaction_header_id
				  ,p_transaction_temp_id                  =>  p_transaction_temp_id
				  ,p_new_transaction_temp_id              =>  l_new_transaction_temp_id
				  ,p_transaction_temp_id_to_merge         =>  p_transaction_temp_id_to_merge
				  ,p_serial_transaction_temp_id           =>  NULL
				  ,p_mtlt_serial_temp_id                  =>  NULL
				  ,p_inventory_item_id                    =>  p_inventory_item_id
				  ,p_revision                             =>  p_revision
				  ,p_suggested_uom                        =>  p_suggested_uom
				  ,p_confirmed_uom                        =>  p_confirmed_uom
				  ,p_primary_uom                          =>  p_primary_uom
				  ,p_serial_lot_number                    =>  NULL
				  ,p_confirmed_serials                    =>  p_confirmed_serials
				  ,p_serial_allocated_flag                =>  p_serial_allocated_flag
				  ,p_lpn_match                            =>  p_lpn_match
				  ,p_lpn_match_lpn_id                     =>  p_lpn_match_lpn_id
				  ,p_lot_controlled                       =>  p_lot_controlled
				  ,p_serial_controlled                    =>  p_serial_controlled
				  ,x_return_status                        =>  x_return_status
				  ,x_msg_count                            =>  x_msg_count
				  ,x_msg_data                             =>  x_msg_data
				  ,p_substitute_lots			          =>  p_substitute_lots       --BUG12670785
				  ,p_full_lot_allocation                  =>  p_full_lot_allocation); -- Added for 14699845 (Flexible Lot Allocation)
Line: 3298

   IF p_update = 'Y1' -- update p_transaction_temp_id  to reduce primary/trxqty
   THEN
	  IF p_action = l_g_action_split  THEN
		 l_progress    :=  '190';
Line: 3302

		 mydebug('l_progress for p_update Y1 in split case ' || l_progress);
Line: 3305

			SELECT SUM(primary_quantity), SUM(transaction_quantity), SUM(SECONDARY_QUANTITY)
			INTO l_rem_lot_pri_qty, l_rem_lot_trx_qty, l_rem_lot_sec_qty
			FROM mtl_transaction_lots_temp
			WHERE transaction_temp_id = p_transaction_temp_id
			GROUP BY transaction_temp_id;
Line: 3311

			 UPDATE  mtl_material_transactions_temp
			 SET     transaction_quantity   = l_rem_lot_trx_qty
			   , primary_quantity           = l_rem_lot_pri_qty
			   , secondary_transaction_quantity = l_rem_lot_sec_qty
			   , last_update_date           =  SYSDATE
			   , last_updated_by            =  p_user_id
			 WHERE   transaction_temp_id    =  p_transaction_temp_id;
Line: 3320

		   UPDATE mtl_material_transactions_temp
		   SET    transaction_quantity      =  l_calc_mmtt_txn_qty
				, primary_quantity          =  l_calc_mmtt_pri_qty
				, secondary_transaction_quantity  =  secondary_transaction_quantity - l_confirmed_sec_qty
				, last_update_date          =  SYSDATE
				, last_updated_by           =  p_user_id
		   WHERE   transaction_temp_id      =  p_transaction_temp_id;
Line: 3335

		 UPDATE  mtl_material_transactions_temp
		 SET     transaction_quantity   =  p_confirmed_trx_qty
			   , primary_quantity       =  l_confirmed_prim_qty -- muom:sk added decode this is for full pick again..  SSK
			   , secondary_transaction_quantity    =  DECODE(p_confirmed_sec_uom, NULL, NULL, l_confirmed_sec_qty)
			   , secondary_uom_code     =  p_confirmed_sec_uom
			   , lpn_id                 =  NVL(p_lpn_id,p_parent_lpn_id)  -- process the nesting -- fully consumble LPN Pick
			   , content_lpn_id         =  p_content_lpn_id
			   , transfer_lpn_id        =  p_transfer_lpn_id
			   , subinventory_code      =  p_confirmed_sub
			   , locator_id             =  p_confirmed_locator_id
			   , transaction_uom        =  p_confirmed_uom
			   , container_item_id      =  p_container_item_id
			   , last_update_date       =  SYSDATE
			   , last_updated_by        =  p_user_id
			   , wms_task_status        =  p_wms_task_status    -- Bug4185621: update mmtt task status to loaded
		 WHERE  transaction_temp_id     =  p_transaction_temp_id;
Line: 3360

   IF p_update = 'Y2' -- and update p_transaction_temp_id_to_merge to add qty)
   THEN
		 l_progress    :=  '190';
Line: 3364

		 UPDATE  mtl_material_transactions_temp
		 SET     transaction_quantity  =  transaction_quantity + p_confirmed_trx_qty
			   , primary_quantity      =  primary_quantity + NVL(l_confirmed_prim_qty  ,0)
			   , secondary_transaction_quantity    =  secondary_transaction_quantity +  NVL(l_confirmed_sec_qty, 0)
			   , secondary_uom_code    =  p_confirmed_sec_uom
			   , last_update_date      = SYSDATE
			   , last_updated_by       = p_user_id
		 WHERE   transaction_temp_id = p_transaction_temp_id_to_merge;
Line: 3377

			l_progress    :=  '190'; -- Delete the original MMTT, if merging into another MMTT
Line: 3379

			DELETE  mtl_material_transactions_temp
			WHERE   transaction_temp_id = p_transaction_temp_id;
Line: 3388

			UPDATE  mtl_material_transactions_temp
			SET     transaction_quantity    =  l_calc_mmtt_txn_qty
				   , primary_quantity       =  l_calc_mmtt_pri_qty
				   , secondary_transaction_quantity  =  secondary_transaction_quantity -  l_confirmed_sec_qty
				   , last_update_date       = SYSDATE
				   , last_updated_by        = p_user_id
			WHERE   transaction_temp_id     = p_transaction_temp_id;
Line: 3426

END proc_insert_update_mmtt;
Line: 3430

			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_organization_id                 IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,p_transaction_header_id           IN            NUMBER
			  ,p_transaction_temp_id             IN            NUMBER
			  ,p_new_transaction_temp_id         IN            NUMBER
			  ,p_transaction_temp_id_to_merge    IN            NUMBER
			  ,p_inventory_item_id               IN            NUMBER
			  ,p_revision                        IN            VARCHAR2
			  ,p_suggested_uom                   IN            VARCHAR2
			  ,p_confirmed_uom                   IN            VARCHAR2
			  ,p_primary_uom                     IN            VARCHAR2
			  ,p_confirmed_lots                  IN            VARCHAR2
			  ,p_confirmed_lot_trx_qty           IN            VARCHAR2
			  ,p_confirmed_serials               IN            VARCHAR2
			  ,p_serial_allocated_flag           IN            VARCHAR2
			  ,p_lpn_match                       IN            NUMBER
			  ,p_lpn_match_lpn_id                IN            NUMBER
			  ,p_confirmed_sec_uom               IN            VARCHAR2
			  ,p_confirmed_sec_qty               IN            VARCHAR2
			  ,p_lot_controlled                  IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled               IN            VARCHAR2  -- Y/N
			  ,p_exception                       IN            VARCHAR2 -- SHORT/OVER
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots		         IN	           VARCHAR2 --/* Bug 9448490 Lot Substitution Project */
			  ,p_full_lot_allocation             IN            VARCHAR2 DEFAULT 'Y' -- Added for 14699845 (Flexible Lot Allocation)
			  ,p_fulfillment_base                IN            VARCHAR2
			  ,p_orig_mmtt_txn_uom               IN            VARCHAR2)
IS
   l_proc_name                         VARCHAR2(30) :=  'PROC_PROCESS_CONFIRMED_LOTS';
Line: 3493

   SELECT  mtlt.*
   FROM    mtl_transaction_lots_temp mtlt
   WHERE   transaction_temp_id = p_lot_transaction_temp_id
   AND     lot_number = p_lot_number;
Line: 3501

   SELECT  DISTINCT              -- so that we get only lot records in case of lot+Serial item control
		   lot_number
		  ,transaction_temp_id
		  ,serial_number
		  ,transaction_quantity
		  ,primary_quantity
		  ,suggested_quantity
		  ,secondary_quantity
	 FROM  mtl_allocations_gtmp
	ORDER BY
		   transaction_temp_id
		  ,lot_number;
Line: 3517

	  SELECT DISTINCT lot_number, transaction_quantity,
					  primary_quantity, secondary_quantity  --BUG12670785
	FROM mtl_allocations_gtmp
				WHERE lot_number NOT IN (
						 SELECT DISTINCT lot_number
				 FROM mtl_transaction_lots_temp
				 WHERE transaction_temp_id = p_lot_transaction_temp_id)
	ORDER BY lot_number;
Line: 3526

	CURSOR cur_mtlts_deleted_ls IS
	SELECT mtlt.transaction_temp_id, mtlt.lot_number, mtlt.primary_quantity FROM mtl_transaction_lots_temp mtlt
		WHERE mtlt.lot_number NOT IN (SELECT mag.lot_number FROM mtl_allocations_gtmp mag)
		AND mtlt.transaction_temp_id = p_transaction_temp_id;
Line: 3535

	  Action    l_insert        L_update        update orginalMMTT      UpdMergeMMTT    InsertNewMMTT
	  -----------------------------------------------------------------------------------------------
	  SPLIT     Y               Y1              N                       N               Y
	  SPLIT     N               Y2              Y                       Y               N
	  LOAD_M    N               Y1              Y                       N               N
	  LOAD_M    N               Y2              Y-Delete                Y               N
	  LOAD_S    N               Y1              Y                       N               N

	  ****MTLT ****
	  Action    l_insert        L_update        update orginalMTLT      UpdMergeMTLT
	  -----------------------------------------------------------------------------------------------
	  SPLIT     Y               Y1              Y-upd original OR       N
												-ins new/upd orig
	  SPLIT     N               Y2              Y                       Y if MTLT exist
																		OR ins new/upd orig
	  LOAD_M    N               Y1              N                       N
	  LOAD_M    N               Y2              Y                       Y if MTLT exist
																		OR ins new/upd orig
	  LOAD_S    N               Y1              N-not necessary         N

	  */

   x_return_status  := l_g_ret_sts_success;
Line: 3560

   mydebug ('p_insert                 = ' || p_insert                 );
Line: 3561

   mydebug ('p_update                 = ' || p_update                 );
Line: 3616

		mydebug('Inserting into MTLT - p_transaction_temp_id :' || p_transaction_temp_id);
Line: 3617

		mydebug('Inserting into MTLT - l_lot_prim_qty_ls     :' || l_lot_prim_qty_ls);
Line: 3618

		mydebug('Inserting into MTLT - l_lot_sec_qty_ls      :' || l_lot_sec_qty_ls);
Line: 3619

		mydebug('Inserting into MTLT - l_lot_trx_qty_ls      :' || l_lot_trx_qty_ls);
Line: 3620

		mydebug('Inserting into MTLT - l_lot_number_ls       :' || l_lot_number_ls);
Line: 3621

		mydebug('Inserting into MTLT - p_inventory_item_id   :' || p_inventory_item_id);
Line: 3622

		mydebug('Inserting into MTLT - p_organization_id     :' || p_organization_id);
Line: 3624

		insert_mtlt (
		p_new_temp_id => p_transaction_temp_id
		, p_serial_temp_id  => NULL
		, p_pri_att_qty     => l_lot_prim_qty_ls
		, p_sec_att_qty     => l_lot_sec_qty_ls
		, p_trx_att_qty     => l_lot_trx_qty_ls
		, p_lot_number      => l_lot_number_ls
		, p_item_id         => p_inventory_item_id
		, p_organization_id => p_organization_id
		, x_return_status   => l_return_status_ls) ;
Line: 3634

		mydebug('Inserting into MTLT - l_return_status_ls-' || l_return_status_ls);
Line: 3643

		mydebug('The value of  p_insert :' || p_insert);
Line: 3647

IF ((p_action in ('LOAD_SINGLE', 'LOAD_MULTIPLE'))  AND p_insert = 'N' ) THEN --12871057

	--The following loop is only to print debug messages..
		OPEN cur_mtlts_deleted_ls;
Line: 3652

			FETCH cur_mtlts_deleted_ls INTO l_ls_temp_id, l_ls_lot_number, l_ls_lot_prim_qty;
Line: 3653

			EXIT WHEN cur_mtlts_deleted_ls%NOTFOUND;
Line: 3659

		CLOSE cur_mtlts_deleted_ls;
Line: 3662

	DELETE FROM mtl_transaction_lots_temp mtlt
	WHERE mtlt.lot_number NOT IN (SELECT NVL(lot_number, '@####') FROM mtl_allocations_gtmp)  --Added NVL as in some cases p_lot_numbers had ':' extra causing insert with null values
	AND mtlt.transaction_temp_id = p_transaction_temp_id;
Line: 3680

		  -- Only p_insert = y means a new MMTT is created and therefore new MTLT will have to
		  -- be created.

	  IF l_prev_lot_number <> rec_confirmed_lots_serials.lot_number
	  THEN
		  l_prev_lot_number := rec_confirmed_lots_serials.lot_number ;
Line: 3686

		  IF p_insert = 'Y' or p_update = 'Y2'  THEN

			 -- we need this only if we ever need to create a new MTLT
			 FOR rec_mtlt_to_copy_from  IN cur_mtlt_to_copy_from
						   (p_lot_number                => rec_confirmed_lots_serials.lot_number,
							p_lot_transaction_temp_id   => p_transaction_temp_id)
			 LOOP
				l_progress    :=  '150';
Line: 3726

			 SELECT mtl_material_transactions_s.NEXTVAL
			   INTO l_serial_transaction_temp_id
			   FROM DUAL;
Line: 3766

		  mydebug ('p_insert: ' || p_insert);
Line: 3767

		  IF p_insert = 'Y' THEN
			 l_progress    :=  '190';
Line: 3773

				 -- lot qty in the selected, in the above cursor, MTLT equals qty that is needed for the new MTLT
				 -- update the MTLT with new temp id  instead of inserting a new and then deleting the old one
				 l_progress    :=  '200';
Line: 3777

				 UPDATE mtl_transaction_lots_temp
				 SET    transaction_temp_id        = p_new_transaction_temp_id
					  , transaction_quantity       = rec_confirmed_lots_serials.transaction_quantity
					  , primary_quantity           = rec_confirmed_lots_serials.primary_quantity
					  , secondary_quantity         = rec_confirmed_lots_serials.secondary_quantity
					  , secondary_unit_of_measure  = p_confirmed_sec_uom
					  , serial_transaction_temp_id = l_serial_transaction_temp_id
					  , last_update_date           = SYSDATE
					  , last_updated_by            = p_user_id
				 WHERE  transaction_temp_id        = l_rec_mtlt_to_copy_from.transaction_temp_id
				 AND    lot_number                 = rec_confirmed_lots_serials.lot_number;
Line: 3792

				 -- insert a new MTLT
				 l_progress    :=  '210';
Line: 3803

				 proc_insert_mtlt
					 (p_lot_record                      => l_rec_mtlt_to_copy_from
					 ,x_return_status                   => x_return_status
					 ,x_msg_count                       => x_msg_count
					 ,x_msg_data                        => x_msg_data);
Line: 3814

				 -- If new MTLT is inserted for p_new_transaction_temp_id this means
				 -- the original MTLT still has some qty remaining...so update it.
				 -- the original MTLT need not be adjusted for secondary quantity.
				 -- It is not expected to be populated
				 IF(p_fulfillment_base = 'S') THEN
					UPDATE  mtl_transaction_lots_temp
					SET  transaction_quantity     = l_calc_lot_txn_qty
						,primary_quantity         = primary_quantity - rec_confirmed_lots_serials.primary_quantity
						,secondary_quantity       = secondary_quantity - rec_confirmed_lots_serials.secondary_quantity
						,last_update_date         = SYSDATE
						,last_updated_by          = p_user_id
					WHERE   transaction_temp_id   = p_transaction_temp_id
					AND     lot_number = rec_confirmed_lots_serials.lot_number;
Line: 3831

					UPDATE  mtl_transaction_lots_temp
					SET  transaction_quantity     = transaction_quantity - rec_confirmed_lots_serials.suggested_quantity
						,primary_quantity         = primary_quantity - rec_confirmed_lots_serials.primary_quantity
						,secondary_quantity       = NVL(secondary_quantity, rec_confirmed_lots_serials.secondary_quantity) - rec_confirmed_lots_serials.secondary_quantity
						,last_update_date         = SYSDATE
						,last_updated_by          = p_user_id
					WHERE   transaction_temp_id   = p_transaction_temp_id
					AND     lot_number = rec_confirmed_lots_serials.lot_number;
Line: 3848

		  mydebug ('p_update: ' || p_update);
Line: 3849

		  -- p_update = 'Y2' means, p_insert = N which means that current MMTT (in this call)
		  -- was merged with another existing MMTT. In this case, it is possible that existing MMTT already has
		  -- MTLT record for this lot number. If this is the case then update the MTLT otherwise ,
		  -- insert a new MTLT  using l_rec_mtlt_to_copy_from from the above cursor
		  IF p_update = 'Y2'
		  THEN
			 l_progress    :=  '240';
Line: 3857

			 UPDATE   mtl_transaction_lots_temp
			 SET      transaction_quantity       = transaction_quantity + rec_confirmed_lots_serials.transaction_quantity
					 ,primary_quantity           = primary_quantity     + rec_confirmed_lots_serials.primary_quantity
					 ,secondary_quantity         = secondary_quantity   + rec_confirmed_lots_serials.secondary_quantity
					 ,last_update_date           = SYSDATE
					 ,last_updated_by            = p_user_id
			 WHERE   transaction_temp_id         = p_transaction_temp_id_to_merge
			 AND     lot_number                  = rec_confirmed_lots_serials.lot_number
			 -- For lot + serial controlled items
			 RETURNING serial_transaction_temp_id INTO l_serial_transaction_temp_id;
Line: 3872

					--lot qty in the selected MTLT = qty that is needed for the new MTLT
					--update the MTLT with new temp id  instead of inserting a new and then deleting the old one
					l_progress    :=  '250';
Line: 3876

					UPDATE mtl_transaction_lots_temp
					SET    transaction_temp_id = p_transaction_temp_id_to_merge --p_new_transaction_temp_id
						 , secondary_quantity  = rec_confirmed_lots_serials.secondary_quantity
						 , secondary_unit_of_measure  = p_confirmed_sec_uom
						   -- For lot + serial controlled items
						 , serial_transaction_temp_id = l_serial_transaction_temp_id
						 , last_update_date    = SYSDATE
						 , last_updated_by     = p_user_id
					WHERE  transaction_temp_id = l_rec_mtlt_to_copy_from.transaction_temp_id
					AND    lot_number = rec_confirmed_lots_serials.lot_number;
Line: 3899

				   proc_insert_mtlt
					   (p_lot_record                      => l_rec_mtlt_to_copy_from
					   ,x_return_status                   => x_return_status
					   ,x_msg_count                       => x_msg_count
					   ,x_msg_data                        => x_msg_data);
Line: 3910

				   -- If new MTLT is inserted for p_transaction_temp_id_to_merge this means
				   -- the original MTLT still has some qty remaining...so update it.
				   IF(p_fulfillment_base = 'S') THEN
							UPDATE  mtl_transaction_lots_temp
							SET     transaction_quantity      = l_calc_lot_txn_qty
									,primary_quantity         = primary_quantity - rec_confirmed_lots_serials.primary_quantity
									,secondary_quantity       = secondary_quantity - rec_confirmed_lots_serials.secondary_quantity
									,last_update_date         = SYSDATE
									,last_updated_by          = p_user_id
							WHERE   transaction_temp_id       = p_transaction_temp_id --  l_rec_mtlt_to_copy_from.transaction_temp_id
							AND     lot_number                = rec_confirmed_lots_serials.lot_number;
Line: 3925

						UPDATE  mtl_transaction_lots_temp
						SET     transaction_quantity      = transaction_quantity - rec_confirmed_lots_serials.suggested_quantity
								,primary_quantity         = primary_quantity     - rec_confirmed_lots_serials.primary_quantity
								,secondary_quantity       = NVL(secondary_quantity, rec_confirmed_lots_serials.secondary_quantity) - rec_confirmed_lots_serials.secondary_quantity
								,last_update_date         = SYSDATE
								,last_updated_by          = p_user_id
						WHERE   transaction_temp_id = p_transaction_temp_id --  l_rec_mtlt_to_copy_from.transaction_temp_id
						AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 3943

				-- delete it.
				IF ((l_rec_mtlt_to_copy_from.primary_quantity = rec_confirmed_lots_serials.primary_quantity AND NVL(p_fulfillment_base, 'P') = 'P') OR
					(l_rec_mtlt_to_copy_from.secondary_quantity = rec_confirmed_lots_serials.secondary_quantity AND p_fulfillment_base = 'S'))THEN
				   l_progress    :=  '290';
Line: 3949

				   -- p_transaction_temp_id_to_merge we do not need the original MTLT ..delete it
				   DELETE  mtl_transaction_lots_temp
				   WHERE   transaction_temp_id = p_transaction_temp_id -- l_rec_mtlt_to_copy_from.transaction_temp_id
				   AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 3957

				   -- If all the qty from the original MTLT is not consumed then update the original MTLT
				   -- attached to p_transaction_temp_id .. as selected in the cursor above
				   l_progress    :=  '300';
Line: 3962

						UPDATE  mtl_transaction_lots_temp
						SET     transaction_quantity     = l_calc_lot_txn_qty
								,primary_quantity        = primary_quantity - rec_confirmed_lots_serials.primary_quantity
								,secondary_quantity      = rec_confirmed_lots_serials.secondary_quantity - rec_confirmed_lots_serials.secondary_quantity
								,last_update_date        = SYSDATE
								,last_updated_by         = p_user_id
						WHERE   transaction_temp_id = p_transaction_temp_id -- l_rec_mtlt_to_copy_from.transaction_temp_id
						AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 3974

						UPDATE  mtl_transaction_lots_temp
						SET     transaction_quantity     = transaction_quantity - rec_confirmed_lots_serials.suggested_Quantity
								,primary_quantity        = primary_quantity - rec_confirmed_lots_serials.primary_quantity
								,secondary_quantity      = NVL(secondary_quantity, rec_confirmed_lots_serials.secondary_quantity) - rec_confirmed_lots_serials.secondary_quantity
								,last_update_date        = SYSDATE
								,last_updated_by         = p_user_id
						WHERE   transaction_temp_id = p_transaction_temp_id -- l_rec_mtlt_to_copy_from.transaction_temp_id
						AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 3989

		  /* Usually for p_update = 'Y1' one does not need to update MTLT since nothing would have changed
			 But, for catch weight enabled items, it is necessary */
		  /* If serials are not allocateed and lpn_match = 1/3 , MSNT records need to be populated
			 so, update serial_transaction_temp_id  mtlt*. MSNT gets created in process_confirmed_serials */


		  IF (p_update = 'Y1' AND
			  p_insert = 'N'  AND
			  p_serial_controlled     = 'Y'        AND
			  p_serial_allocated_flag = 'N'        AND
			  ((p_lpn_match  IN (1,3)
			  AND(p_substitute_lots IS NULL OR (p_substitute_lots IS NOT NULL
			  AND check_if_lot_is_substituted(p_substitute_lots, rec_confirmed_lots_serials.lot_number, p_full_lot_allocation)))) OR --HWSNIssue 13860546 -- Modified for 14699845 (Flexible Lot Allocation)
			  ((p_lpn_match = 4 or (nvl(p_lpn_match,0) <=0)) AND check_if_lot_is_substituted(p_substitute_lots, rec_confirmed_lots_serials.lot_number,p_full_lot_allocation)))) --BUG 12670785 only in case of lot substitution for serila items
			  -- Modified for 14699845 (Flexible Lot Allocation)

		  THEN
			  l_progress    :=  '350';
Line: 4008

			  UPDATE   mtl_transaction_lots_temp
			  SET
					  transaction_quantity       = rec_confirmed_lots_serials.transaction_quantity
					 ,primary_quantity           = rec_confirmed_lots_serials.primary_quantity
					 ,secondary_quantity         = rec_confirmed_lots_serials.secondary_quantity
					 ,secondary_unit_of_measure  = p_confirmed_sec_uom
					 ,serial_transaction_temp_id = l_serial_transaction_temp_id
					 ,last_update_date           = SYSDATE
					 ,last_updated_by            = p_user_id
			  WHERE   transaction_temp_id = p_transaction_temp_id
			  AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 4023

		  /* Usually for p_update = 'Y1' one does not need to update MTLT since nothing would have changed
			 But, for catch weight enabled items, Overpicking or changed TXN-UOM it is necessary
			 */
		  /* following condition is independent of the above condition in that :
 *             for serial controlled items, UOM cannot be different from primary
 *             UOM (atleast as of this patchset (11.5.10)) .
 *             for lpn_match 1,3 , it cannot be a case of overpick. */
		  IF (p_update = 'Y1' AND
			  p_insert = 'N' ) AND
			  (p_confirmed_sec_qty is NOT NULL   OR
			   p_confirmed_uom <> p_primary_uom  OR
			   p_confirmed_uom <> p_suggested_uom OR --BUG13491033
			   p_exception = 'OVER')
		  THEN
			  l_progress    :=  '360';
Line: 4039

			  UPDATE   mtl_transaction_lots_temp
			  SET
					  transaction_quantity       = rec_confirmed_lots_serials.transaction_quantity
					 ,primary_quantity           = rec_confirmed_lots_serials.primary_quantity
					 ,secondary_quantity         = rec_confirmed_lots_serials.secondary_quantity
					 ,secondary_unit_of_measure  = p_confirmed_sec_uom
					 ,last_update_date           = SYSDATE
					 ,last_updated_by            = p_user_id
			  WHERE   transaction_temp_id = p_transaction_temp_id
			  AND     lot_number          = rec_confirmed_lots_serials.lot_number;
Line: 4064

			  -- update all serial records with the serial_transaction_temp_id to be populated
			  UPDATE  mtl_allocations_gtmp
				 SET  child_transaction_temp_id = l_serial_transaction_temp_id
			   WHERE  lot_number          = rec_confirmed_lots_serials.lot_number
				 AND  transaction_temp_id = rec_confirmed_lots_serials.transaction_temp_id  ;
Line: 4077

					  ,p_insert                               =>  p_insert
					  ,p_update                               =>  p_update
					  ,p_organization_id                      =>  p_organization_id
					  ,p_user_id                              =>  p_user_id
					  ,p_transaction_header_id                =>  p_transaction_header_id
					  ,p_transaction_temp_id                  =>  p_transaction_temp_id
					  ,p_new_transaction_temp_id              =>  p_new_transaction_temp_id --??l_serial_transaction_temp_id
					  ,p_transaction_temp_id_to_merge         =>  p_transaction_temp_id_to_merge
					  ,p_serial_transaction_temp_id           =>  l_serial_transaction_temp_id
					  ,p_mtlt_serial_temp_id                  =>  l_mtlt_serial_temp_id
					  ,p_inventory_item_id                    =>  p_inventory_item_id
					  ,p_revision                             =>  p_revision
					  ,p_suggested_uom                        =>  p_suggested_uom
					  ,p_confirmed_uom                        =>  p_confirmed_uom
					  ,p_primary_uom                          =>  p_primary_uom
					  ,p_serial_lot_number                    =>  rec_confirmed_lots_serials.lot_number
					  ,p_confirmed_serials                    =>  p_confirmed_serials
					  ,p_serial_allocated_flag                =>  p_serial_allocated_flag
					  ,p_lpn_match                            =>  p_lpn_match
					  ,p_lpn_match_lpn_id                     =>  p_lpn_match_lpn_id
					  ,p_lot_controlled                       =>  p_lot_controlled
					  ,p_serial_controlled                    =>  p_serial_controlled
					  ,x_return_status                        =>  x_return_status
					  ,x_msg_count                            =>  x_msg_count
					  ,x_msg_data                             =>  x_msg_data
					  ,p_substitute_lots			          =>  p_substitute_lots--BUG12670785
					  ,p_full_lot_allocation                  =>  p_full_lot_allocation); -- Added for 14699845 (Flexible Lot Allocation)
Line: 4141

			  ,p_insert                          IN            VARCHAR2
			  ,p_update                          IN            VARCHAR2
			  ,p_organization_id                 IN            NUMBER
			  ,p_user_id                         IN            NUMBER
			  ,p_transaction_header_id           IN            NUMBER
			  ,p_transaction_temp_id             IN            NUMBER
			  ,p_new_transaction_temp_id         IN            NUMBER
			  ,p_transaction_temp_id_to_merge    IN            NUMBER
			  ,p_serial_transaction_temp_id      IN            NUMBER
			  ,p_mtlt_serial_temp_id             IN            NUMBER
			  ,p_inventory_item_id               IN            NUMBER
			  ,p_revision                        IN            VARCHAR2
			  ,p_suggested_uom                   IN            VARCHAR2
			  ,p_confirmed_uom                   IN            VARCHAR2
			  ,p_primary_uom                     IN            VARCHAR2
			  ,p_serial_lot_number               IN            VARCHAR2
			  ,p_confirmed_serials               IN            VARCHAR2
			  ,p_serial_allocated_flag           IN            VARCHAR2
			  ,p_lpn_match                       IN            NUMBER
			  ,p_lpn_match_lpn_id                IN            NUMBER
			  ,p_lot_controlled                  IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled               IN            VARCHAR2  -- Y/N
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2
			  ,p_substitute_lots		         IN	           VARCHAR2 --for BUG12670785
			  ,p_full_lot_allocation             IN            VARCHAR2) -- Added for 14699845 (Flexible Lot Allocation)
IS
   l_proc_name                        VARCHAR2(30) :=  'PROC_PROCESS_CONFIRMED_SERIALS';
Line: 4179

   SELECT  transaction_temp_id
		  ,lot_number
		  ,serial_number
		  ,transaction_quantity
		  ,primary_quantity
	 FROM  mtl_allocations_gtmp
	WHERE  NVL(lot_number,'@@') = nvl(p_serial_lot_number,'@@')
	ORDER BY
		   transaction_temp_id
		  --,nvl(lot_number,'@@')
		  ,serial_number;
Line: 4193

	  Action    l_insert        L_update        update orginalMMTT      UpdMergeMMTT    InsertNewMMTT
	  -----------------------------------------------------------------------------------------------
	  SPLIT     Y               Y1              N                       N               Y
	  SPLIT     N               Y2              Y                       Y               N
	  LOAD_M    N               Y1              Y                       N               N
	  LOAD_M    N               Y2              Y-Delete                Y               N
	  LOAD_S    N               Y1              Y                       N               N

	  ****MSNT ****
	  Action    l_insert        L_update        update orginalMSNT
	  -----------------------------------------------------------------------------------------------
	  SPLIT     Y               Y1              Y-set temp_id = new temp_id
	  SPLIT     N               Y2              Y-set temp_id= merge temp_id
	  LOAD_M    N               Y1              N
	  LOAD_M    N               Y2              Y-set temp_id= merge temp_id
	  LOAD_S    N               Y1              N-not necessary
	  */

   mydebug ('In : ' || l_proc_name);
Line: 4213

   mydebug ('p_insert                 = ' || p_insert                 );
Line: 4214

   mydebug ('p_update                 = ' || p_update                 );
Line: 4246

	  IF (p_insert = 'Y' ) THEN
		  l_n_msnt_transaction_temp_id := p_new_transaction_temp_id;
Line: 4248

		  -- if a new mmtt ininserted then the MSNT
		  -- should be attached to p_new_transaction_temp_id
	  ELSE
		 IF p_update = 'Y2' THEN
			 l_n_msnt_transaction_temp_id := p_transaction_temp_id_to_merge;
Line: 4256

		 IF (p_update = 'Y1' ) THEN
			   l_n_msnt_transaction_temp_id := p_transaction_temp_id; -- original MMTT
Line: 4258

			   --  and this will be used only if we are inserting MSNTs for
			   -- no allocated serIals
		 END IF;
Line: 4267

	   ((p_insert = 'Y'  OR p_update = 'Y2') AND (NOT check_if_lot_is_substituted(p_substitute_lots, p_serial_lot_number , p_full_lot_allocation))) --BUG12670785  -- Modified for 14699845 (Flexible Lot Allocation)

   THEN
	  -- AND ( p_serial_allocated_flag = 'Y'))
	  /* If serials are allocted then MSNT records will be associated with p_transaction_temp_id.
		 If serials are not allocated but confirmed_serials is not null that means Java-UI created MSNT
			records and associated them with p_transaction_temp_id. there fore, for a case of SPLIT
			(leading to Merge or split) these MSNT records have to be moved to the confirmed_mmtt created.
			 identified by l_n_msnt_transaction_temp_id */
	   l_progress    :=  '110';
Line: 4278

	   -- update the existing msnt record and  set its transaction-temp_id = new_transaction-temp_id
	   UPDATE mtl_serial_numbers_temp
		  SET transaction_temp_id = l_n_msnt_transaction_temp_id
			, last_update_date    = SYSDATE
			, last_updated_by     = p_user_id
		WHERE transaction_temp_id = l_o_msnt_transaction_temp_id
		  AND fm_serial_number IN
			  (SELECT  serial_number
				 FROM  mtl_allocations_gtmp
				WHERE  NVL(lot_number,'@@') = nvl(p_serial_lot_number,'@@'));
Line: 4290

		  mydebug('11 msnt not updateed..');
Line: 4295

		  UPDATE  MTL_SERIAL_NUMBERS
			 SET  group_mark_id   = l_n_msnt_transaction_temp_id
				 ,last_update_date= SYSDATE
				 ,last_updated_by = p_user_id
		   WHERE  current_organization_id = p_organization_id
			 AND  inventory_item_id       = p_inventory_item_id
			 --AND  group_mark_id           IS NULL
			 AND  serial_number           IN
				 (SELECT  serial_number
					FROM  mtl_allocations_gtmp
				   WHERE  NVL(lot_number,'@@') = nvl(p_serial_lot_number,'@@'));
Line: 4321

		 -- Pick Load page will insert these MSNTs
	  THEN
		 l_progress    :=  '180';
Line: 4326

		 --proc_insert_msnt inserts into MSNT using the data from MSN and also marks MSN
		 proc_insert_msnt (p_transaction_temp_id            => l_n_msnt_transaction_temp_id
						   ,p_organization_id               => p_organization_id
						   ,p_inventory_item_id             => p_inventory_item_id
						   ,p_revision                      => p_revision
						   ,p_confirmed_serials             => p_confirmed_serials
						   ,p_serial_number                 => NULL
						   ,p_lpn_id                        => p_lpn_match_lpn_id -- NULL if lpn_match!=(1,3)
						   ,p_serial_lot_number             => p_serial_lot_number
						   ,p_user_id                       => p_user_id
						   ,x_return_status                 => x_return_status
						   ,x_msg_count                     => x_msg_count
						   ,x_msg_data                      => x_msg_data);
Line: 4350

		 (p_insert = 'Y'  OR  p_update = 'Y2')
	  THEN
		 l_progress    :=  '200';
Line: 4355

		  -- update the existing msnt record and  set its transaction-temp_id = new_transaction-temp_id
		  UPDATE mtl_serial_numbers_temp
			 SET transaction_temp_id = l_n_msnt_transaction_temp_id
			   , last_update_date    = SYSDATE
			   , last_updated_by     = p_user_id
		   WHERE transaction_temp_id = l_o_msnt_transaction_temp_id
			 AND fm_serial_number IN
				 (SELECT  serial_number
					FROM  mtl_serial_numbers msn
						 ,mtl_serial_numbers_temp msnt
				   WHERE  msn.serial_number = msnt.fm_serial_number
					 AND  msnt.transaction_temp_id = l_o_msnt_transaction_temp_id
					 AND  NVL(msn.lot_number,'@@') = nvl(p_serial_lot_number,'@@')
					 AND  msn.lpn_id = p_lpn_match_lpn_id);
Line: 4371

			 mydebug('msnt not updateed..');
Line: 4376

			 UPDATE  MTL_SERIAL_NUMBERS
				SET  group_mark_id   = l_n_msnt_transaction_temp_id
					,last_update_date= SYSDATE
					,last_updated_by = p_user_id
			  WHERE  current_organization_id = p_organization_id
				AND  inventory_item_id       = p_inventory_item_id
				AND  serial_number IN
				 (SELECT  serial_number
					FROM  mtl_serial_numbers msn
						 ,mtl_serial_numbers_temp msnt
				   WHERE  msn.serial_number = msnt.fm_serial_number
					 AND  msnt.transaction_temp_id = l_n_msnt_transaction_temp_id
					 AND  NVL(msn.lot_number,'@@') = nvl(p_serial_lot_number,'@@')
					 AND  msn.lpn_id = p_lpn_match_lpn_id);
Line: 4401

		 (p_insert = 'N'  OR  p_update = 'Y1') AND
		 (check_if_lot_is_substituted (p_substitute_lots, p_serial_lot_number, p_full_lot_allocation))  --BUG12670785 -- Modified for 14699845 (Flexible Lot Allocation)
	   THEN
		 l_progress    :=  '200111';
Line: 4414

		  -- update the existing msnt record and  set its transaction-temp_id = new_transaction-temp_id
		  UPDATE mtl_serial_numbers_temp
			 SET transaction_temp_id = l_n_msnt_transaction_temp_id
			   , last_update_date    = SYSDATE
			   , last_updated_by     = p_user_id
		   WHERE transaction_temp_id = p_transaction_temp_id
			 AND fm_serial_number IN
				 (SELECT  serial_number
					FROM  mtl_serial_numbers msn
						 ,mtl_serial_numbers_temp msnt
				   WHERE  msn.serial_number = msnt.fm_serial_number
					 AND  msnt.transaction_temp_id = p_transaction_temp_id
					 AND  msn.current_organization_id = p_organization_id	--HWSNIssue 13860546(Performance Issue)
					 AND  NVL(msn.lot_number,'@@') = nvl(p_serial_lot_number,'@@')
					 AND  Nvl(msn.lpn_id,'-999') = Nvl(p_lpn_match_lpn_id ,'-999'));--12871057
Line: 4431

			 mydebug('msnt not updateed coming to AMO code....');
Line: 4436

			 UPDATE  MTL_SERIAL_NUMBERS
				SET  group_mark_id   = l_n_msnt_transaction_temp_id
					,last_update_date= SYSDATE
					,last_updated_by = p_user_id
			  WHERE  current_organization_id = p_organization_id
				AND  inventory_item_id       = p_inventory_item_id
				AND  serial_number IN
				 (SELECT  serial_number
					FROM  mtl_serial_numbers msn
						 ,mtl_serial_numbers_temp msnt
				   WHERE  msn.serial_number = msnt.fm_serial_number
					 AND  msn.current_organization_id = p_organization_id	--HWSNIssue 13860546(Performance Issue)
					 AND  msnt.transaction_temp_id = l_n_msnt_transaction_temp_id
					 AND  NVL(msn.lot_number,'@@') = nvl(p_serial_lot_number,'@@')
					 AND  Nvl(msn.lpn_id,'-999') = Nvl(p_lpn_match_lpn_id ,'-999'));
Line: 4487

PROCEDURE proc_insert_mtlt
			 ( p_lot_record                      IN            mtl_transaction_lots_temp%ROWTYPE
			  ,x_return_status                   OUT NOCOPY    VARCHAR2
			  ,x_msg_count                       OUT NOCOPY    NUMBER
			  ,x_msg_data                        OUT NOCOPY    VARCHAR2)
IS
   l_proc_name                   VARCHAR2(30) :=  'PROC_INSERT_MTLT';
Line: 4498

   INSERT  INTO mtl_transaction_lots_temp
			   (transaction_temp_id
			   ,last_update_date
			   ,last_updated_by
			   ,creation_date
			   ,created_by
			   ,last_update_login
			   ,request_id
			   ,program_application_id
			   ,program_id
			   ,program_update_date
			   ,transaction_quantity
			   ,primary_quantity
			   ,lot_number
			   ,lot_expiration_date
			   ,error_code
			   ,serial_transaction_temp_id
			   ,group_header_id
			   ,put_away_rule_id
			   ,pick_rule_id
			   ,description
			   ,vendor_id
			   ,supplier_lot_number
			   ,territory_code
			   ,origination_date
			   ,date_code
			   ,grade_code
			   ,change_date
			   ,maturity_date
			   ,status_id
			   ,retest_date
			   ,age
			   ,item_size
			   ,color
			   ,volume
			   ,volume_uom
			   ,place_of_origin
			   ,best_by_date
			   ,length
			   ,length_uom
			   ,recycled_content
			   ,thickness
			   ,thickness_uom
			   ,width
			   ,width_uom
			   ,curl_wrinkle_fold
			   ,lot_attribute_category
			   ,c_attribute1
			   ,c_attribute2
			   ,c_attribute3
			   ,c_attribute4
			   ,c_attribute5
			   ,c_attribute6
			   ,c_attribute7
			   ,c_attribute8
			   ,c_attribute9
			   ,c_attribute10
			   ,c_attribute11
			   ,c_attribute12
			   ,c_attribute13
			   ,c_attribute14
			   ,c_attribute15
			   ,c_attribute16
			   ,c_attribute17
			   ,c_attribute18
			   ,c_attribute19
			   ,c_attribute20
			   ,d_attribute1
			   ,d_attribute2
			   ,d_attribute3
			   ,d_attribute4
			   ,d_attribute5
			   ,d_attribute6
			   ,d_attribute7
			   ,d_attribute8
			   ,d_attribute9
			   ,d_attribute10
			   ,n_attribute1
			   ,n_attribute2
			   ,n_attribute3
			   ,n_attribute4
			   ,n_attribute5
			   ,n_attribute6
			   ,n_attribute7
			   ,n_attribute8
			   ,n_attribute9
			   ,n_attribute10
			   ,vendor_name
			   ,sublot_num
			   ,secondary_quantity
			   ,secondary_unit_of_measure
			   ,qc_grade
			   ,reason_code
			   ,product_code
			   ,product_transaction_id
			   ,attribute_category
			   ,attribute1
			   ,attribute2
			   ,attribute3
			   ,attribute4
			   ,attribute5
			   ,attribute6
			   ,attribute7
			   ,attribute8
			   ,attribute9
			   ,attribute10
			   ,attribute11
			   ,attribute12
			   ,attribute13
			   ,attribute14
			   ,attribute15)
   VALUES (
				p_lot_record.transaction_temp_id
			   ,p_lot_record.last_update_date
			   ,p_lot_record.last_updated_by
			   ,SYSDATE
			   ,p_lot_record.created_by
			   ,p_lot_record.last_update_login
			   ,p_lot_record.request_id
			   ,p_lot_record.program_application_id
			   ,p_lot_record.program_id
			   ,SYSDATE
			   ,p_lot_record.transaction_quantity
			   ,p_lot_record.primary_quantity
			   ,p_lot_record.lot_number
			   ,p_lot_record.lot_expiration_date
			   ,p_lot_record.error_code
			   ,p_lot_record.serial_transaction_temp_id
			   ,p_lot_record.group_header_id
			   ,p_lot_record.put_away_rule_id
			   ,p_lot_record.pick_rule_id
			   ,p_lot_record.description
			   ,p_lot_record.vendor_id
			   ,p_lot_record.supplier_lot_number
			   ,p_lot_record.territory_code
			   ,p_lot_record.origination_date
			   ,p_lot_record.date_code
			   ,p_lot_record.grade_code
			   ,p_lot_record.change_date
			   ,p_lot_record.maturity_date
			   ,p_lot_record.status_id
			   ,p_lot_record.retest_date
			   ,p_lot_record.age
			   ,p_lot_record.item_size
			   ,p_lot_record.color
			   ,p_lot_record.volume
			   ,p_lot_record.volume_uom
			   ,p_lot_record.place_of_origin
			   ,p_lot_record.best_by_date
			   ,p_lot_record.length
			   ,p_lot_record.length_uom
			   ,p_lot_record.recycled_content
			   ,p_lot_record.thickness
			   ,p_lot_record.thickness_uom
			   ,p_lot_record.width
			   ,p_lot_record.width_uom
			   ,p_lot_record.curl_wrinkle_fold
			   ,p_lot_record.lot_attribute_category
			   ,p_lot_record.c_attribute1
			   ,p_lot_record.c_attribute2
			   ,p_lot_record.c_attribute3
			   ,p_lot_record.c_attribute4
			   ,p_lot_record.c_attribute5
			   ,p_lot_record.c_attribute6
			   ,p_lot_record.c_attribute7
			   ,p_lot_record.c_attribute8
			   ,p_lot_record.c_attribute9
			   ,p_lot_record.c_attribute10
			   ,p_lot_record.c_attribute11
			   ,p_lot_record.c_attribute12
			   ,p_lot_record.c_attribute13
			   ,p_lot_record.c_attribute14
			   ,p_lot_record.c_attribute15
			   ,p_lot_record.c_attribute16
			   ,p_lot_record.c_attribute17
			   ,p_lot_record.c_attribute18
			   ,p_lot_record.c_attribute19
			   ,p_lot_record.c_attribute20
			   ,p_lot_record.d_attribute1
			   ,p_lot_record.d_attribute2
			   ,p_lot_record.d_attribute3
			   ,p_lot_record.d_attribute4
			   ,p_lot_record.d_attribute5
			   ,p_lot_record.d_attribute6
			   ,p_lot_record.d_attribute7
			   ,p_lot_record.d_attribute8
			   ,p_lot_record.d_attribute9
			   ,p_lot_record.d_attribute10
			   ,p_lot_record.n_attribute1
			   ,p_lot_record.n_attribute2
			   ,p_lot_record.n_attribute3
			   ,p_lot_record.n_attribute4
			   ,p_lot_record.n_attribute5
			   ,p_lot_record.n_attribute6
			   ,p_lot_record.n_attribute7
			   ,p_lot_record.n_attribute8
			   ,p_lot_record.n_attribute9
			   ,p_lot_record.n_attribute10
			   ,p_lot_record.vendor_name
			   ,p_lot_record.sublot_num
			   ,p_lot_record.secondary_quantity
			   ,p_lot_record.secondary_unit_of_measure
			   ,p_lot_record.qc_grade
			   ,p_lot_record.reason_code
			   ,p_lot_record.product_code
			   ,p_lot_record.product_transaction_id
			   ,p_lot_record.attribute_category
			   ,p_lot_record.attribute1
			   ,p_lot_record.attribute2
			   ,p_lot_record.attribute3
			   ,p_lot_record.attribute4
			   ,p_lot_record.attribute5
			   ,p_lot_record.attribute6
			   ,p_lot_record.attribute7
			   ,p_lot_record.attribute8
			   ,p_lot_record.attribute9
			   ,p_lot_record.attribute10
			   ,p_lot_record.attribute11
			   ,p_lot_record.attribute12
			   ,p_lot_record.attribute13
			   ,p_lot_record.attribute14
			   ,p_lot_record.attribute15);
Line: 4747

END proc_insert_mtlt;
Line: 4750

PROCEDURE proc_insert_msnt
			  (p_transaction_temp_id             IN          NUMBER
			  ,p_organization_id                 IN          NUMBER
			  ,p_inventory_item_id               IN          NUMBER
			  ,p_revision                        IN          VARCHAR2
			  ,p_confirmed_serials               IN          VARCHAR2
			  ,p_serial_number                   IN          VARCHAR2
			  ,p_lpn_id                          IN          NUMBER
			  ,p_serial_lot_number               IN          VARCHAR2
			  ,p_user_id                         IN          NUMBER
			  ,x_return_status                   OUT NOCOPY  VARCHAR2
	   ,x_msg_count                       OUT NOCOPY  NUMBER
			  ,x_msg_data                        OUT NOCOPY  VARCHAR2)
IS
   --p_transaction_temp_id := transaction_temp_id of the new MSNT
   l_proc_name                VARCHAR2(30) :=  'PROC_INSERT_MSNT';
Line: 4785

	-- copied the logic from INV_TRX_UTIL_PUB.INSERT_SER_TRX
	l_real_serial_prefix  := RTRIM(p_serial_number, '0123456789');
Line: 4797

	SELECT '1' INTO l_check FROM DUAL WHERE (SELECT Count(1) FROM mtl_serial_numbers
	WHERE inventory_item_id = p_inventory_item_id
	 AND current_organization_id = p_organization_id
	 AND NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@')
	 AND lpn_id = p_lpn_id   AND current_status = 3) = (SELECT Sum(primary_transaction_quantity) FROM mtl_onhand_quantities_detail
														WHERE inventory_item_id = p_inventory_item_id
														AND NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@')
														AND lpn_id = p_lpn_id AND organization_id = p_organization_id );
Line: 4823

	-- P_serial_number is null means we are inserting a group of serials either
	-- 1. using LPN_ID passed in or serial_lot_number  passed in (p-confirmed_serials is NULL)
	-- OR 2. using the data from the gtmp table (when p_confirmed_serials is nOT NULL)
	IF p_serial_number   IS NULL
	THEN
	   INSERT  INTO  mtl_serial_numbers_temp
			   (transaction_temp_id
			   ,last_update_date
			   ,last_updated_by
			   ,creation_date
			   ,created_by
			   ,last_update_login
			   ,request_id
			   ,program_application_id
			   ,program_id
			   ,program_update_date
			   ,vendor_serial_number
			   ,vendor_lot_number
			   ,fm_serial_number
			   ,to_serial_number
			   ,serial_prefix
			   ,error_code
			   ,parent_serial_number
			   ,group_header_id
			   ,end_item_unit_number
			   ,serial_attribute_category
			   ,territory_code
			   ,origination_date
			   ,c_attribute1
			   ,c_attribute2
			   ,c_attribute3
			   ,c_attribute4
			   ,c_attribute5
			   ,c_attribute6
			   ,c_attribute7
			   ,c_attribute8
			   ,c_attribute9
			   ,c_attribute10
			   ,c_attribute11
			   ,c_attribute12
			   ,c_attribute13
			   ,c_attribute14
			   ,c_attribute15
			   ,c_attribute16
			   ,c_attribute17
			   ,c_attribute18
			   ,c_attribute19
			   ,c_attribute20
			   ,d_attribute1
			   ,d_attribute2
			   ,d_attribute3
			   ,d_attribute4
			   ,d_attribute5
			   ,d_attribute6
			   ,d_attribute7
			   ,d_attribute8
			   ,d_attribute9
			   ,d_attribute10
			   ,n_attribute1
			   ,n_attribute2
			   ,n_attribute3
			   ,n_attribute4
			   ,n_attribute5
			   ,n_attribute6
			   ,n_attribute7
			   ,n_attribute8
			   ,n_attribute9
			   ,n_attribute10
			   ,status_id
			   ,time_since_new
			   ,cycles_since_new
			   ,time_since_overhaul
			   ,cycles_since_overhaul
			   ,time_since_repair
			   ,cycles_since_repair
			   ,time_since_visit
			   ,cycles_since_visit
			   ,time_since_mark
			   ,cycles_since_mark
			   ,number_of_repairs
			   ,product_code
			   ,product_transaction_id )
		 (SELECT
				p_transaction_temp_id
			   ,SYSDATE
			   ,-1
			   ,SYSDATE
			   ,p_user_id
			   ,msn.last_update_login
			   ,msn.request_id
			   ,msn.program_application_id
			   ,msn.program_id
			   ,msn.program_update_date
			   ,msn.vendor_serial_number
			   ,msn.vendor_lot_number
			   ,msn.serial_number
			   ,msn.serial_number
			   ,NVL(l_serial_prefix, 1)
			   ,NULL -- error code
			   ,msn.parent_serial_number
			   ,NULL --group_header_id
			   ,msn.end_item_unit_number
			   ,msn.serial_attribute_category
			   ,msn.territory_code
			   ,msn.origination_date
			   ,msn.c_attribute1
			   ,msn.c_attribute2
			   ,msn.c_attribute3
			   ,msn.c_attribute4
			   ,msn.c_attribute5
			   ,msn.c_attribute6
			   ,msn.c_attribute7
			   ,msn.c_attribute8
			   ,msn.c_attribute9
			   ,msn.c_attribute10
			   ,msn.c_attribute11
			   ,msn.c_attribute12
			   ,msn.c_attribute13
			   ,msn.c_attribute14
			   ,msn.c_attribute15
			   ,msn.c_attribute16
			   ,msn.c_attribute17
			   ,msn.c_attribute18
			   ,msn.c_attribute19
			   ,msn.c_attribute20
			   ,msn.d_attribute1
			   ,msn.d_attribute2
			   ,msn.d_attribute3
			   ,msn.d_attribute4
			   ,msn.d_attribute5
			   ,msn.d_attribute6
			   ,msn.d_attribute7
			   ,msn.d_attribute8
			   ,msn.d_attribute9
			   ,msn.d_attribute10
			   ,msn.n_attribute1
			   ,msn.n_attribute2
			   ,msn.n_attribute3
			   ,msn.n_attribute4
			   ,msn.n_attribute5
			   ,msn.n_attribute6
			   ,msn.n_attribute7
			   ,msn.n_attribute8
			   ,msn.n_attribute9
			   ,msn.n_attribute10
			   ,msn.status_id
			   ,msn.time_since_new
			   ,msn.cycles_since_new
			   ,msn.time_since_overhaul
			   ,msn.cycles_since_overhaul
			   ,msn.time_since_repair
			   ,msn.cycles_since_repair
			   ,msn.time_since_visit
			   ,msn.cycles_since_visit
			   ,msn.time_since_mark
			   ,msn.cycles_since_mark
			   ,msn.number_of_repairs
			   ,NULL --product_code
			   ,NULL --product_transaction_id
	   FROM    mtl_serial_numbers  msn
	   WHERE   msn.current_organization_id  = p_organization_id
	   AND     msn.inventory_item_id        = p_inventory_item_id
	   AND     lpn_id                       = p_lpn_id
	   AND     NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@'));
Line: 5014

	   INSERT  INTO  mtl_serial_numbers_temp
			   (transaction_temp_id
			   ,last_update_date
			   ,last_updated_by
			   ,creation_date
			   ,created_by
			   ,last_update_login
			   ,request_id
			   ,program_application_id
			   ,program_id
			   ,program_update_date
			   ,vendor_serial_number
			   ,vendor_lot_number
			   ,fm_serial_number
			   ,to_serial_number
			   ,serial_prefix
			   ,error_code
			   ,parent_serial_number
			   ,group_header_id
			   ,end_item_unit_number
			   ,serial_attribute_category
			   ,territory_code
			   ,origination_date
			   ,c_attribute1
			   ,c_attribute2
			   ,c_attribute3
			   ,c_attribute4
			   ,c_attribute5
			   ,c_attribute6
			   ,c_attribute7
			   ,c_attribute8
			   ,c_attribute9
			   ,c_attribute10
			   ,c_attribute11
			   ,c_attribute12
			   ,c_attribute13
			   ,c_attribute14
			   ,c_attribute15
			   ,c_attribute16
			   ,c_attribute17
			   ,c_attribute18
			   ,c_attribute19
			   ,c_attribute20
			   ,d_attribute1
			   ,d_attribute2
			   ,d_attribute3
			   ,d_attribute4
			   ,d_attribute5
			   ,d_attribute6
			   ,d_attribute7
			   ,d_attribute8
			   ,d_attribute9
			   ,d_attribute10
			   ,n_attribute1
			   ,n_attribute2
			   ,n_attribute3
			   ,n_attribute4
			   ,n_attribute5
			   ,n_attribute6
			   ,n_attribute7
			   ,n_attribute8
			   ,n_attribute9
			   ,n_attribute10
			   ,status_id
			   ,time_since_new
			   ,cycles_since_new
			   ,time_since_overhaul
			   ,cycles_since_overhaul
			   ,time_since_repair
			   ,cycles_since_repair
			   ,time_since_visit
			   ,cycles_since_visit
			   ,time_since_mark
			   ,cycles_since_mark
			   ,number_of_repairs
			   ,product_code
			   ,product_transaction_id )
		 (SELECT
				p_transaction_temp_id
			   ,SYSDATE
			   ,-1
			   ,SYSDATE
			   ,p_user_id
			   ,msn.last_update_login
			   ,msn.request_id
			   ,msn.program_application_id
			   ,msn.program_id
			   ,msn.program_update_date
			   ,msn.vendor_serial_number
			   ,msn.vendor_lot_number
			   ,msn.serial_number
			   ,msn.serial_number
			   ,NVL(l_serial_prefix, 1)
			   ,NULL -- error code
			   ,msn.parent_serial_number
			   ,NULL --group_header_id
			   ,msn.end_item_unit_number
			   ,msn.serial_attribute_category
			   ,msn.territory_code
			   ,msn.origination_date
			   ,msn.c_attribute1
			   ,msn.c_attribute2
			   ,msn.c_attribute3
			   ,msn.c_attribute4
			   ,msn.c_attribute5
			   ,msn.c_attribute6
			   ,msn.c_attribute7
			   ,msn.c_attribute8
			   ,msn.c_attribute9
			   ,msn.c_attribute10
			   ,msn.c_attribute11
			   ,msn.c_attribute12
			   ,msn.c_attribute13
			   ,msn.c_attribute14
			   ,msn.c_attribute15
			   ,msn.c_attribute16
			   ,msn.c_attribute17
			   ,msn.c_attribute18
			   ,msn.c_attribute19
			   ,msn.c_attribute20
			   ,msn.d_attribute1
			   ,msn.d_attribute2
			   ,msn.d_attribute3
			   ,msn.d_attribute4
			   ,msn.d_attribute5
			   ,msn.d_attribute6
			   ,msn.d_attribute7
			   ,msn.d_attribute8
			   ,msn.d_attribute9
			   ,msn.d_attribute10
			   ,msn.n_attribute1
			   ,msn.n_attribute2
			   ,msn.n_attribute3
			   ,msn.n_attribute4
			   ,msn.n_attribute5
			   ,msn.n_attribute6
			   ,msn.n_attribute7
			   ,msn.n_attribute8
			   ,msn.n_attribute9
			   ,msn.n_attribute10
			   ,msn.status_id
			   ,msn.time_since_new
			   ,msn.cycles_since_new
			   ,msn.time_since_overhaul
			   ,msn.cycles_since_overhaul
			   ,msn.time_since_repair
			   ,msn.cycles_since_repair
			   ,msn.time_since_visit
			   ,msn.cycles_since_visit
			   ,msn.time_since_mark
			   ,msn.cycles_since_mark
			   ,msn.number_of_repairs
			   ,NULL --product_code
			   ,NULL --product_transaction_id
		  FROM  mtl_serial_numbers  msn
		  WHERE msn.current_organization_id  = p_organization_id
		  AND   msn.inventory_item_id        = p_inventory_item_id
		  AND   nvl(lpn_id,0)                = nvl(p_lpn_id,0)
		  AND   NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@')
		  --AND   group_mark_id                IS NULL
		  AND   msn.serial_number  IN
			   (SELECT serial_number
				  FROM mtl_allocations_gtmp
				 WHERE NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@'))
			  );
Line: 5227

END proc_insert_msnt ;
Line: 5262

	   UPDATE  MTL_SERIAL_NUMBERS
	   SET     group_mark_id   = p_group_mark_id
			 , last_updated_by = p_user_id
	   WHERE   current_organization_id     = p_organization_id
	   AND     inventory_item_id           = p_inventory_item_id
	   AND     lpn_id                      = p_lpn_id ;
Line: 5279

	   UPDATE  MTL_SERIAL_NUMBERS  msn
		  SET  group_mark_id   = p_group_mark_id
			 , last_updated_by = p_user_id
		WHERE  msn.current_organization_id  = p_organization_id
		  AND  msn.inventory_item_id        = p_inventory_item_id
		  AND  nvl(lpn_id,0)                = nvl(p_lpn_id,0)
		  AND  NVL(lot_number,'@@')         = nvl(p_serial_lot_number,'@@')
		  --AND  group_mark_id                IS NULL
		  AND  msn.serial_number  IN
			   (SELECT serial_number
				  FROM mtl_allocations_gtmp
				 WHERE NVL(lot_number,'@@') = nvl(p_serial_lot_number,'@@'));
Line: 5353

	UPDATE  MTL_SERIAL_NUMBERS
	SET     group_mark_id   = p_group_mark_id
		  , last_updated_by = p_user_id
	WHERE   current_organization_id     = p_organization_id
	AND     inventory_item_id           = p_inventory_item_id
	AND     nvl(lpn_id,0)               = nvl(p_lpn_id,0)
	AND     DECODE(p_serial_number,NULL,'@@',serial_number) = nvl(p_serial_number,'@@')  ;
Line: 5395

 * newly inserted/updated details, the rollback has to be done manually.
*/
PROCEDURE process_F2(
			   p_action                 IN            VARCHAR2 -- NULL, CMS
			  ,p_organization_id        IN            NUMBER
			  ,p_user_id                IN            NUMBER
			  ,p_employee_id            IN            NUMBER
			  ,p_transaction_header_id  IN            NUMBER
			  ,p_transaction_temp_id    IN            NUMBER
			  ,p_original_sub           IN            VARCHAR2
			  ,p_original_locator_id    IN            NUMBER
			  ,p_lot_controlled         IN            VARCHAR2  -- Y/N
			  ,p_serial_controlled      IN            VARCHAR2  -- Y/N
			  ,p_serial_allocated_flag  IN            VARCHAR2 -- Y/N
			  ,p_suggested_uom          IN            VARCHAR2  -- original allocation UOM
			  ,p_start_over             IN            VARCHAR2   -- Y/N  start_over
			  ,p_retain_task            IN            VARCHAR2 -- Y/N for bug 4310093
			  ,x_start_over_taskno      OUT NOCOPY    NUMBER   -- start_over task
			  ,x_return_status          OUT NOCOPY    VARCHAR2
			  ,x_msg_count              OUT NOCOPY    NUMBER
			  ,x_msg_data               OUT NOCOPY    VARCHAR2)
IS
   --PRAGMA AUTONOMOUS_TRANSACTION;
Line: 5433

   l_op_msnt_to_delete           NUMBER       := 0;
Line: 5446

	 -- update one of the MMTTs(min temp_id) from each group and delete rest from that group */

   CURSOR  cur_mmtt1
   IS
	  SELECT   sum(primary_quantity) mmtt_primary_quantity
	  -- bug #4141928 INV CONV
	  , sum(secondary_transaction_quantity) mmtt_secondary_quantity
	  , COUNT(*) mmtt_group_count
	  , MIN(transaction_temp_id) group_temp_id
	  , MIN(parent_line_id) parent_line_id -- Bug#4185621
			 , inventory_item_id
			 , revision
			 , subinventory_code
			 , locator_id
			 , item_primary_uom_code
			 , SECONDARY_UOM_CODE --BUG12622871LSC
			 , fulfillment_base
	  FROM   mtl_material_transactions_temp mmtt
	  WHERE  mmtt.transaction_header_id  = p_transaction_header_id
	  GROUP BY
			  inventory_item_id
			 ,revision
			 ,subinventory_code
			 ,locator_id
			 ,item_primary_uom_code
			 ,SECONDARY_UOM_CODE --BUG12622871LSC
			 ,fulfillment_base;
Line: 5481

	  SELECT  sum(mtlt.primary_quantity)      group_lot_primary_quantity
	  -- bug #4141928 INV CONV
	  , sum(mtlt.secondary_quantity)          group_lot_secondary_quantity
	  ,COUNT(*)                               group_lot_count
	  ,MIN(mtlt.transaction_temp_id)   group_lot_temp_id
			 ,mtlt.lot_number
	  FROM    mtl_transaction_lots_temp mtlt
			, mtl_material_transactions_temp mmtt
	  WHERE   mmtt.transaction_header_id =  p_transaction_header_id
	  AND     mmtt.transaction_temp_id   =  mtlt.transaction_temp_id
	  AND     mmtt.subinventory_code     =  p_subinventory_code
	  AND     mmtt.locator_id            =  p_locator_id
	  AND     mmtt.item_primary_uom_code =  p_uom_code
	  AND     mmtt.inventory_item_id     =  p_inventory_item_id
	  AND     nvl(mmtt.revision,'@@')    =  nvl(p_revision,'@@')
	  GROUP BY
			  mtlt.lot_number;
Line: 5499

   CURSOR cur_msnt_to_delete ( p_rec_mmtt1_subinventory_code   VARCHAR2
							  ,p_rec_mmtt1_locator_id          NUMBER
							  ,p_rec_mmtt1_item_primary_uom    VARCHAR2
							  ,p_rec_mmtt1_inventory_item_id   NUMBER
							  ,p_rec_mmtt1_revision            VARCHAR2)
   IS
			  SELECT   msnt.transaction_temp_id
					  ,msnt.fm_serial_number
					  ,mmtt.organization_id
					  ,mmtt.inventory_item_id
					  ,msnt.creation_date
				FROM   mtl_serial_numbers_temp msnt
					  ,mtl_material_transactions_temp mmtt
			   WHERE   mmtt.transaction_header_id  = p_transaction_header_id
				 AND   mmtt.transaction_temp_id   =  msnt.transaction_temp_id
				 AND   mmtt.subinventory_code     =  p_rec_mmtt1_subinventory_code
				 AND   mmtt.locator_id            =  p_rec_mmtt1_locator_id
				 AND   mmtt.item_primary_uom_code =  p_rec_mmtt1_item_primary_uom
				 AND   mmtt.inventory_item_id     =  p_rec_mmtt1_inventory_item_id
				 AND   nvl(mmtt.revision,'@@')    =  nvl(p_rec_mmtt1_revision,'@@')
			   ORDER BY msnt.creation_date DESC;
Line: 5521

   CURSOR cur_msnt_to_delete_LS (p_serial_transaction_temp_id    NUMBER)
   IS
			  SELECT   msnt.transaction_temp_id
					  ,msnt.fm_serial_number
					  ,msnt.creation_date
				FROM   mtl_serial_numbers_temp msnt
			   WHERE   msnt.transaction_temp_id   =  p_serial_transaction_temp_id
			   ORDER BY msnt.creation_date DESC;
Line: 5566

 *  as done before.All task would return to pending wdd would be deleted.
 *}}
 */

  IF p_start_over ='N' and p_retain_task='N' THEN --bug 4310093
   mydebug('viks start_over button not pressed:');
Line: 5627

	-- update one of the MMTTs(min temp_id) from each group and delete rest from that group
	l_progress := 500;
Line: 5631

	DELETE  mtl_allocations_gtmp ;
Line: 5660

	  -- MMTTs should be deleted that belong to the p_transaction-header_id but are not
	  -- in this list
	  l_progress := 600;
Line: 5663

	  INSERT
		INTO mtl_allocations_gtmp
			 (transaction_temp_id)
	  VALUES ( rec_mmtt1.group_temp_id);
Line: 5667

	  mydebug('Inserted temp_id into mtl_allocations_gtmp: ' || rec_mmtt1.group_temp_id);
Line: 5702

	  -- Bug#4185621: decide whether to update posting flag
	  IF (rec_mmtt1.parent_line_id = rec_mmtt1.group_temp_id) THEN
		  l_parent_posting_flag := 'N';  -- bulk parent, need to update posting flag back to 'N'
Line: 5710

	   /* Update the MMTT record with transacttion-temp_id = group_temp_id.
		Updating transaction_quantity same as primary_quantity since
		the transaction_qty should be IN same uom AS primary qty FOR this mmtt */
	   UPDATE   mtl_material_transactions_temp
		  SET    primary_quantity     = rec_mmtt1.mmtt_primary_quantity
			   , transaction_quantity = l_suggested_mmtt_qty
			   , secondary_transaction_quantity = DECODE(secondary_transaction_quantity, NULL, NULL, l_suggested_mmtt_sec_qty)
			   , transaction_uom      = p_suggested_uom
			   , transfer_lpn_id      = NULL
			   , lpn_id               = NULL
			   , content_lpn_id       = NULL
			   , last_update_date     = SYSDATE
			   , last_updated_by      = p_user_id
			   , wms_task_status = l_g_task_pending -- Bug4185621: update mmtt task status back to pending
			   , posting_flag = l_parent_posting_flag -- Bug4185621: updating posting flag
		WHERE    transaction_temp_id  = rec_mmtt1.group_temp_id;
Line: 5730

		-- Bug# 4185621: update child line posting flag back to 'Y' for bulk picking
		IF (l_parent_posting_flag = 'N') THEN
			UPDATE mtl_material_transactions_temp mmtt
			   SET posting_flag = 'Y'
			 WHERE parent_line_id = rec_mmtt1.group_temp_id
			   AND parent_line_id <> transaction_temp_id;
Line: 5756

		  SELECT 'Y'
			INTO l_lot_alloc_exist
			FROM mtl_transaction_lots_temp
		   WHERE transaction_temp_id = p_transaction_temp_id
			 AND ROWNUM = 1;
Line: 5796

			 SELECT mtl_material_transactions_s.NEXTVAL
			 INTO   l_serial_transaction_temp_id
			 FROM   DUAL;
Line: 5841

				   UPDATE  mtl_serial_numbers_temp
					  SET  transaction_temp_id = l_serial_transaction_temp_id
						 , last_update_date    = SYSDATE
						 , last_updated_by     = p_user_id
					WHERE  transaction_temp_id  IN
						   (SELECT  mtlt.serial_transaction_temp_id
							  FROM  mtl_transaction_lots_temp mtlt
								  , mtl_material_transactions_temp mmtt
							  WHERE   mmtt.transaction_header_id =  p_transaction_header_id
							  AND     mmtt.transaction_temp_id   =  mtlt.transaction_temp_id
							  AND     mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
							  AND     mmtt.locator_id            =  rec_mmtt1.locator_id
							  AND     mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
							  AND     mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
							  AND     mtlt.lot_number            =  rec_mtlt1.lot_number
							  AND     nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@') );
Line: 5863

				   UPDATE  MTL_SERIAL_NUMBERS
					  SET  group_mark_id    = l_serial_transaction_temp_id
						 , last_updated_by  = p_user_id
						 , last_update_date = SYSDATE
					WHERE  current_organization_id = p_organization_id
					  AND  inventory_item_id       = rec_mmtt1.inventory_item_id
					  AND  serial_number          IN
						   (SELECT fm_serial_number
							  FROM mtl_serial_numbers_temp msnt
							 WHERE msnt.transaction_temp_id   =  l_serial_transaction_temp_id);
Line: 5881

				   UPDATE  MTL_SERIAL_NUMBERS
				   SET     group_mark_id   = NULL
						 , last_updated_by = p_user_id
						 , last_update_date = SYSDATE
				   WHERE  (current_organization_id
						  ,inventory_item_id
						  ,serial_number)
					  IN  (SELECT  mmtt.organization_id
								  ,mmtt.inventory_item_id
								  ,msnt.fm_serial_number
							 FROM  mtl_transaction_lots_temp      mtlt
								  ,mtl_serial_numbers_temp        msnt
								  ,mtl_material_transactions_temp mmtt
							WHERE  mmtt.transaction_header_id      = p_transaction_header_id
							  AND  mmtt.transaction_temp_id        = mtlt.transaction_temp_id
							  AND  mtlt.serial_transaction_temp_id = msnt.transaction_temp_id
							  AND  mmtt.subinventory_code          = rec_mmtt1.subinventory_code
							  AND  mmtt.locator_id                 = rec_mmtt1.locator_id
							  AND  mmtt.item_primary_uom_code      = rec_mmtt1.item_primary_uom_code
							  AND  mmtt.inventory_item_id          = rec_mmtt1.inventory_item_id
							  AND  mtlt.lot_number                 =  rec_mtlt1.lot_number
							  AND  nvl(mmtt.revision,'@@')         =  nvl(rec_mmtt1.revision,'@@')
							  UNION --For lot substitution of lot and serial items when serial are confirmed we insert msnt with mmtt.transaction_temp_id
							  --at that time their is no MTLT for substituted lot..
							  (SELECT  mmtt.organization_id
								  ,mmtt.inventory_item_id
								  ,msnt.fm_serial_number
							 FROM  mtl_serial_numbers_temp        msnt
								  ,mtl_material_transactions_temp mmtt
							WHERE  mmtt.transaction_header_id      = p_transaction_header_id
							  AND  mmtt.transaction_temp_id        = msnt.transaction_temp_id
							  AND  mmtt.subinventory_code          = rec_mmtt1.subinventory_code
							  AND  mmtt.locator_id                 = rec_mmtt1.locator_id
							  AND  mmtt.item_primary_uom_code      = rec_mmtt1.item_primary_uom_code
							  AND  mmtt.inventory_item_id          = rec_mmtt1.inventory_item_id
							  AND  nvl(mmtt.revision,'@@')         =  nvl(rec_mmtt1.revision,'@@') )
							  );
Line: 5923

					  -- Now delete MSNTs
					  l_progress := 1400;
Line: 5926

					  DELETE  mtl_serial_numbers_temp
					   WHERE  transaction_temp_id
						  IN
							  (SELECT  mtlt.serial_transaction_temp_id
								 FROM  mtl_transaction_lots_temp mtlt
									 , mtl_material_transactions_temp mmtt
								 WHERE   mmtt.transaction_header_id =  p_transaction_header_id
								 AND     mmtt.transaction_temp_id   =  mtlt.transaction_temp_id
								 AND     mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
								 AND     mmtt.locator_id            =  rec_mmtt1.locator_id
								 AND     mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
								 AND     mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
								 AND     mtlt.lot_number            =  rec_mtlt1.lot_number
								 AND     nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@')
								 UNION --For lot substitution of lot and serial items when serial are confirmed we insert msnt with mmtt.transaction_temp_id
							  --at that time their is no MTLT for substituted lot..
							  (SELECT msnt.transaction_temp_id
							 FROM  mtl_serial_numbers_temp        msnt
								  ,mtl_material_transactions_temp mmtt
							WHERE  mmtt.transaction_header_id      = p_transaction_header_id
							  AND  mmtt.transaction_temp_id        = msnt.transaction_temp_id
							  AND  mmtt.subinventory_code          = rec_mmtt1.subinventory_code
							  AND  mmtt.locator_id                 = rec_mmtt1.locator_id
							  AND  mmtt.item_primary_uom_code      = rec_mmtt1.item_primary_uom_code
							  AND  mmtt.inventory_item_id          = rec_mmtt1.inventory_item_id
							  AND  nvl(mmtt.revision,'@@')         =  nvl(rec_mmtt1.revision,'@@') )
								);
Line: 5958

				l_op_msnt_to_delete  := 0;
Line: 5959

				IF p_serial_allocated_flag = 'Y' THEN  -- to delete all overpicked serials
				   l_progress := 4000;
Line: 5962

				   SELECT  count(*)
					 INTO  l_op_msnt_to_delete
					 FROM  mtl_serial_numbers_temp msnt
					WHERE  msnt.transaction_temp_id   =  l_serial_transaction_temp_id;
Line: 5966

				   mydebug('l_op_msnt_to_delete : ' || l_op_msnt_to_delete
							|| ':' || rec_mtlt1.group_lot_primary_quantity);
Line: 5971

				   IF rec_mtlt1.group_lot_primary_quantity < l_op_msnt_to_delete
				   THEN
				   FOR rec_msnt_to_delete_LS IN cur_msnt_to_delete_LS
												( l_serial_transaction_temp_id)
				   LOOP
					  mydebug('rec_msnt_to_delete_ls.fm_serial_number : ' || rec_msnt_to_delete_ls.fm_serial_number);
Line: 5977

					  mydebug('rec_msnt_to_delete_ls.transaction_temp_id : ' || rec_msnt_to_delete_ls.transaction_temp_id);
Line: 5979

					   * assumption that the overpicked serials are newly inserted MSNT records and
					   * they will have creation date higher than the originally allocated serials. */
					  IF l_op_msnt_to_delete <= rec_mtlt1.group_lot_primary_quantity
					  THEN
						 mydebug('l_op_msnt_to_delete : ' || l_op_msnt_to_delete);
Line: 5986

						 l_op_msnt_to_delete := l_op_msnt_to_delete - 1;
Line: 5987

						 mydebug('l_op_msnt_to_delete : ' || l_op_msnt_to_delete);
Line: 5992

					  UPDATE  MTL_SERIAL_NUMBERS
						 SET  group_mark_id    = NULL
							  ,last_updated_by  = p_user_id
							  ,last_update_date = SYSDATE
					   WHERE  current_organization_id = p_organization_id
						 AND  inventory_item_id       = rec_mmtt1.inventory_item_id
						 AND  serial_number           = rec_msnt_to_delete_ls.fm_serial_number;
Line: 6000

						  mydebug('No MSN found to be updated..not good' );
Line: 6005

							DELETE  mtl_serial_numbers_temp
							 WHERE  transaction_temp_id = rec_msnt_to_delete_ls.transaction_temp_id
							   AND  fm_serial_number = rec_msnt_to_delete_ls.fm_serial_number;
Line: 6015

				END IF; -- serial_allocated_flag = Y and delete overpicked serials
Line: 6018

			 /* even if the # of records in MTLT for this lot is 1, it has to be updated
				with serial-transaction-temp_id and user_id, sysdate.
				So, there is no harm is updating qty too */
			 l_progress := 1500;
Line: 6024

			 UPDATE   MTL_transaction_lots_temp mtlt
			 SET      transaction_temp_id  = rec_mmtt1.group_temp_id
					, primary_quantity     = rec_mtlt1.group_lot_primary_quantity
					, transaction_quantity = l_suggested_mtlt_qty
					, secondary_quantity   = decode (secondary_quantity, null, null, l_suggested_mtlt_sec_qty)
					, mtlt.serial_transaction_temp_id = l_serial_transaction_temp_id
					, last_update_date     = SYSDATE
					, last_updated_by      = p_user_id
			 WHERE    lot_number           = rec_mtlt1.lot_number
			 AND      transaction_temp_id  = rec_mtlt1.group_lot_temp_id;
Line: 6043

				DELETE  mtl_transaction_lots_temp
				 WHERE  lot_number  =  rec_mtlt1.lot_number
				   AND  transaction_temp_id
					IN
					   (SELECT  mtlt.transaction_temp_id
						  FROM  mtl_material_transactions_temp  mmtt
							   ,mtl_transaction_lots_temp       mtlt
						 WHERE  mmtt.transaction_header_id =  p_transaction_header_id
						   AND  mmtt.transaction_temp_id   <> rec_mmtt1.group_temp_id
						   AND  mmtt.transaction_temp_id   =  mtlt.transaction_temp_id
						   AND  mtlt.lot_number            =  rec_mtlt1.lot_number
						   AND  mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
						   AND  mmtt.locator_id            =  rec_mmtt1.locator_id
						   AND  mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
						   AND  mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
						   AND  mtlt.lot_number            =  rec_mtlt1.lot_number
						   AND  nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@') );
Line: 6082

				-- Now update MSNT
				l_progress := 1900;
Line: 6086

				UPDATE  mtl_serial_numbers_temp
				   SET  transaction_temp_id = rec_mmtt1.group_temp_id
					  , last_update_date    = SYSDATE
					  , last_updated_by     = p_user_id
				 WHERE  transaction_temp_id
					IN
						(SELECT  msnt.transaction_temp_id
						   FROM  mtl_serial_numbers_temp msnt,
								 mtl_material_transactions_temp mmtt
						  WHERE  mmtt.transaction_header_id = p_transaction_header_id
							AND  mmtt.transaction_temp_id   <> rec_mmtt1.group_temp_id
							AND  mmtt.transaction_temp_id   =  msnt.transaction_temp_id
							AND  mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
							AND  mmtt.locator_id            =  rec_mmtt1.locator_id
							AND  mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
							AND  mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
							AND  nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@') );
Line: 6111

				UPDATE  MTL_SERIAL_NUMBERS
				SET     group_mark_id       = rec_mmtt1.group_temp_id
					  , last_updated_by     = p_user_id
					  , last_update_date    = SYSDATE
				 WHERE  current_organization_id = p_organization_id
				   AND  inventory_item_id       = rec_mmtt1.inventory_item_id
				   AND  serial_number
					IN
						(SELECT fm_serial_number
						   FROM mtl_serial_numbers_temp
						  WHERE transaction_temp_id   =  rec_mmtt1.group_temp_id);
Line: 6129

				-- delete all msnts and unmark all these serials in MSN.
			 l_progress := 2100;
Line: 6132

			 UPDATE  MTL_SERIAL_NUMBERS
			 SET     group_mark_id  = NULL
				   , last_updated_by = p_user_id
				   , last_update_date = SYSDATE
			 WHERE  (current_organization_id
					,inventory_item_id
					,serial_number)
				IN  (SELECT  mmtt.organization_id
							,mmtt.inventory_item_id
							,msnt.fm_serial_number
					   FROM  mtl_serial_numbers_temp        msnt
							,mtl_material_transactions_temp mmtt
					  WHERE   mmtt.transaction_header_id  = p_transaction_header_id
						AND   mmtt.transaction_temp_id   =  msnt.transaction_temp_id
						AND   mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
						AND   mmtt.locator_id            =  rec_mmtt1.locator_id
						AND   mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
						AND   mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
						AND   nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@') );
Line: 6159

				DELETE  mtl_serial_numbers_temp
				WHERE   transaction_temp_id  IN
				(SELECT  msnt.transaction_temp_id
				 FROM    mtl_serial_numbers_temp msnt,
						 mtl_material_transactions_temp mmtt
				 WHERE   mmtt.transaction_header_id  = p_transaction_header_id
				   AND   mmtt.transaction_temp_id   =  msnt.transaction_temp_id
				   AND   mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
				   AND   mmtt.locator_id            =  rec_mmtt1.locator_id
				   AND   mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
				   AND   mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
				   AND   nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@') );
Line: 6177

		  l_op_msnt_to_delete  := 0;
Line: 6178

		  IF p_serial_allocated_flag = 'Y' THEN  -- to delete all overpicked serials
			l_progress := 3000;
Line: 6181

			SELECT count(*)
			INTO l_op_msnt_to_delete
			FROM mtl_serial_numbers_temp
			WHERE (transaction_temp_id   ,
				   fm_serial_number)
			IN
			  (SELECT   msnt.transaction_temp_id
					  ,msnt.fm_serial_number
				FROM   mtl_serial_numbers_temp msnt
					  ,mtl_material_transactions_temp mmtt
			   WHERE   mmtt.transaction_header_id  = p_transaction_header_id
				 AND   mmtt.transaction_temp_id   =  msnt.transaction_temp_id
				 AND   mmtt.subinventory_code     =  rec_mmtt1.subinventory_code
				 AND   mmtt.locator_id            =  rec_mmtt1.locator_id
				 AND   mmtt.item_primary_uom_code =  rec_mmtt1.item_primary_uom_code
				 AND   mmtt.inventory_item_id     =  rec_mmtt1.inventory_item_id
				 AND   nvl(mmtt.revision,'@@')    =  nvl(rec_mmtt1.revision,'@@'));
Line: 6198

			mydebug('l_op_msnt_to_delete : ' || l_op_msnt_to_delete);
Line: 6202

			IF rec_mmtt1.mmtt_primary_quantity < l_op_msnt_to_delete
			THEN
			 FOR rec_msnt_to_delete IN cur_msnt_to_delete
							 ( rec_mmtt1.subinventory_code
							  ,rec_mmtt1.locator_id
							  ,rec_mmtt1.item_primary_uom_code
							  ,rec_mmtt1.inventory_item_id
							  ,rec_mmtt1.revision    )
			 LOOP
				mydebug('rec_msnt_to_delete.fm_serial_number : ' || rec_msnt_to_delete.fm_serial_number);
Line: 6212

				mydebug('rec_msnt_to_delete.transaction_temp_id : ' || rec_msnt_to_delete.transaction_temp_id);
Line: 6213

				mydebug('rec_msnt_to_delete.organization_id : ' || rec_msnt_to_delete.organization_id);
Line: 6214

				mydebug('rec_msnt_to_delete.inventory_item_id : ' || rec_msnt_to_delete.inventory_item_id);
Line: 6215

				mydebug('rec_msnt_to_delete.creation_date : ' ||
					  to_char(rec_msnt_to_delete.creation_date,'dd:mon-yyyy:hh24:mi:ss'));
Line: 6220

				 * assumption that the overpicked serials are newly inserted MSNT records and
				 * they will have creation date higher than the originally allocated serials. */
				IF l_op_msnt_to_delete <= rec_mmtt1.mmtt_primary_quantity
				THEN
				   l_progress := 3200;
Line: 6228

				   l_op_msnt_to_delete := l_op_msnt_to_delete - 1;
Line: 6229

				   mydebug('l_op_msnt_to_delete : ' || l_op_msnt_to_delete);
Line: 6233

				UPDATE  MTL_SERIAL_NUMBERS
				   SET  group_mark_id    = NULL
						,last_updated_by  = p_user_id
						,last_update_date = SYSDATE
				 WHERE  current_organization_id = p_organization_id
				   AND  inventory_item_id       = rec_mmtt1.inventory_item_id
				   AND  serial_number           = rec_msnt_to_delete.fm_serial_number;
Line: 6241

					mydebug('No MSN found to be updated..not good' );
Line: 6246

					  DELETE  mtl_serial_numbers_temp
					   WHERE  transaction_temp_id = rec_msnt_to_delete.transaction_temp_id
						 AND  fm_serial_number = rec_msnt_to_delete.fm_serial_number;
Line: 6298

  wms_picking_pkg.g_start_over_tempid.DELETE;
Line: 6301

	  UPDATE wms_dispatched_tasks
	  SET status = l_g_task_dispatched
		  ,last_update_date = SYSDATE
		  ,last_updated_by = p_user_id
	  WHERE transaction_temp_id IN
			(SELECT transaction_temp_id
					 FROM mtl_allocations_gtmp);
Line: 6309

	  UPDATE  wms_dispatched_tasks
	   SET   device_invoked = null
			 -- Following two statement are commnet for bug 4560814
			 --task_method = NULL  -- for cluster picking
			 -- ,task_group_id = NULL
			,last_update_date = SYSDATE
			,last_updated_by = p_user_id
	   WHERE  person_id = p_employee_id
		  AND  status = l_g_task_dispatched;
Line: 6331

	  -- are confirmed to stay back in MMTT and WDT. Using this we will delete WDT and MMTT

	DELETE wms_dispatched_tasks
	WHERE  transaction_temp_id IN
		  (SELECT transaction_temp_id
			 FROM mtl_material_transactions_temp
			WHERE transaction_header_id  = p_transaction_header_id
			  AND transaction_temp_id NOT IN
				  (SELECT transaction_temp_id
					 FROM mtl_allocations_gtmp));
Line: 6342

	   mydebug('no extra WDTs to delete :' );
Line: 6349

	  -- are confirmed to stay back in MMTT and WDT. Using this we will delete WDT and MMTT
	/* {{ If start over is pressed wdd would be deleted .Lines need to stay in
 * status dispatched.
 * }}
 */

   IF p_start_over ='N' and p_retain_task='N' THEN --bug 4310093

	DELETE wms_dispatched_tasks
	WHERE  transaction_temp_id IN
		  (SELECT transaction_temp_id
			 FROM mtl_allocations_gtmp)
	  AND  status <> l_g_task_queued;
Line: 6363

	   mydebug('no non queued WDTs to delete :' );
Line: 6370

	DELETE mtl_material_transactions_temp
	 WHERE transaction_header_id  = p_transaction_header_id
	   AND transaction_temp_id NOT IN
		   (SELECT transaction_temp_id
			  FROM mtl_allocations_gtmp);
Line: 6376

	   mydebug('no extra MMTTs to delete :' );
Line: 6454

	  -- select all tasks that belong to this employee
	  CURSOR cur_wdt_for_emp IS
	  SELECT transaction_temp_id
		   , device_request_id
		FROM wms_dispatched_tasks
	   WHERE person_id = p_employee_id
	   AND (  status  <= l_g_task_dispatched  OR
			  status  = l_g_task_active)    -- (<=3, OR 9 ) ;
Line: 6464

	  -- select task that belong to this employee and p_transaction_temp_id
	  CURSOR cur_wdt_for_temp_id IS
	  SELECT transaction_temp_id
		   , device_request_id
		FROM wms_dispatched_tasks
	   WHERE person_id = p_employee_id
		 AND transaction_temp_id = p_transaction_temp_id
		 AND device_request_id IS NOT NULL;
Line: 6568

	l_deleted_mmtt_qty      NUMBER       := 0;
Line: 6569

	l_deleted_mmtt_sec_qty  NUMBER       := 0;
Line: 6571

	-- Select all MOLs that are cancelled , so that cancelled tasks can be reduced
	CURSOR   cur_cancelled_MOLs IS
	  SELECT mtrl.line_id
		   , mtrl.uom_code
		FROM mtl_material_transactions_temp mmtt
		   , mtl_txn_request_lines mtrl
	   WHERE (mmtt.transaction_temp_id = p_transaction_temp_id
		-- shld add : and mmtt.mmtt.transaction_temp_id <> mmtt.parent_line_id
		   OR mmtt.parent_line_id      = p_transaction_temp_id)
		 AND mtrl.line_id = mmtt.move_order_line_id
		 AND mtrl.line_status = INV_GLOBALS.G_TO_STATUS_CANCEL_BY_SOURCE;
Line: 6588

	  SELECT mmtt.transaction_temp_id
		   , mmtt.inventory_item_id
		   , mmtt.primary_quantity
		   , mmtt.item_primary_uom_code
		   , NVL(mmtt.secondary_transaction_quantity, 0) secondary_transaction_quantity
		FROM mtl_material_transactions_temp mmtt
	   WHERE mmtt.move_order_line_id = p_mo_line_id
		 AND NOT EXISTS(SELECT 1
						  FROM mtl_material_transactions_temp t1
						 WHERE t1.parent_line_id = mmtt.transaction_temp_id)
		 AND NOT EXISTS(SELECT 1
						  FROM wms_dispatched_tasks wdt
						 WHERE wdt.transaction_temp_id = mmtt.transaction_temp_id);
Line: 6608

	  l_deleted_mmtt_qty      := 0;
Line: 6609

	  l_deleted_mmtt_sec_qty  := 0;
Line: 6615

		 inv_trx_util_pub.delete_transaction(
		   x_return_status       => x_return_status
		 , x_msg_data            => x_msg_data
		 , x_msg_count           => x_msg_count
		 , p_transaction_temp_id => rec_mmtt_to_del.transaction_temp_id);
Line: 6622

			   mydebug('Not able to delete the Txn = ' || rec_mmtt_to_del.transaction_temp_id);
Line: 6629

			 l_deleted_mmtt_qty  := l_deleted_mmtt_qty +
									INV_Convert.inv_um_convert
									   ( item_id         => rec_mmtt_to_del.inventory_item_id
										,precision       => 5
										,from_quantity   => rec_mmtt_to_del.primary_quantity
										,from_unit       => rec_mmtt_to_del.item_primary_uom_code
										,to_unit         => rec_cancelled_mols.uom_code
										,from_name       => NULL
										,to_name         => NULL);
Line: 6641

			l_deleted_mmtt_qty  := l_deleted_mmtt_qty + rec_mmtt_to_del.primary_quantity;
Line: 6643

			l_deleted_mmtt_sec_qty  := l_deleted_mmtt_sec_qty + rec_mmtt_to_del.secondary_transaction_quantity;
Line: 6647

	  SELECT count(*)
		INTO l_mmtt_count
		FROM mtl_material_transactions_temp mmtt
	   WHERE mmtt.move_order_line_id = rec_cancelled_mols.line_id
		 AND NOT EXISTS ( SELECT 1
							FROM mtl_material_transactions_temp t1
						   WHERE t1.parent_line_id = mmtt.transaction_temp_id);
Line: 6655

	  UPDATE mtl_txn_request_lines
		 SET quantity_detailed =(quantity_detailed - l_deleted_mmtt_qty)
		   , SECONDARY_QUANTITY_DETAILED = (SECONDARY_QUANTITY_DETAILED - l_deleted_mmtt_sec_qty)
		   , line_status = DECODE(l_mmtt_count, 0, INV_GLOBALS.G_TO_STATUS_CLOSED, line_status)
		   , last_update_date = SYSDATE
		   , last_updated_by  = p_user_id
	   WHERE line_id = rec_cancelled_mols.line_id;
Line: 6715

   SELECT DISTINCT lpn_id
	 FROM mtl_material_transactions_temp
	WHERE transaction_header_id = p_transaction_header_id
	  AND lpn_id IS NOT NULL;
Line: 6721

   SELECT DISTINCT content_lpn_id
	 FROM mtl_material_transactions_temp
	WHERE transaction_header_id = p_transaction_header_id
	  AND content_lpn_id IS NOT NULL;
Line: 6728

   SELECT DISTINCT transfer_lpn_id
	 FROM mtl_material_transactions_temp mmtt
	WHERE transaction_header_id = p_transaction_header_id
	  AND nvl(content_lpn_id , nvl(lpn_id,-999)) <> transfer_lpn_id
	aND not exists ( select 1 from mtl_material_transactions_temp mmtt1
	 where mmtt1.transaction_header_id = p_transaction_header_id
	  and mmtt.transfer_lpn_id=mmtt1.transfer_lpn_id
	 and (mmtt1.lpn_id=mmtt1.transfer_lpn_id or
						   mmtt1.content_lpn_id=mmtt1.transfer_lpn_id  )); --BUG 12803567
Line: 6752

		   SELECT 1
			INTO l_other_tasks
			FROM DUAL
		   WHERE EXISTS(SELECT 1
						 FROM mtl_material_transactions_temp
						WHERE transaction_header_id <> p_transaction_header_id
						  AND transfer_lpn_id = rec_transfer_lpns.transfer_lpn_id);
Line: 6766

		 -- Bug5659809: update last_update_date and last_update_by as well
		 UPDATE wms_license_plate_numbers
			SET lpn_context = l_lpn_context_PREGENERATED
			 -- , last_update_date = SYSDATE  /* Bug 9448490 Lot Substitution Project */
			 -- , last_updated_by = fnd_global.user_id /* Bug 9448490 Lot Substitution Project */
		  WHERE lpn_id = rec_transfer_lpns.transfer_lpn_id
			AND lpn_context <> l_lpn_context_picked;
Line: 6789

		 -- Bug5659809: update last_update_date and last_update_by as well
		 UPDATE wms_license_plate_numbers
			SET lpn_context = l_lpn_context_INV
			  --, last_update_date = SYSDATE  /* Bug 9448490 Lot Substitution Project */
			  --, last_updated_by = fnd_global.user_id /* Bug 9448490 Lot Substitution Project */
		  WHERE lpn_id = rec_from_lpns.lpn_id
			AND lpn_context = l_lpn_context_packing;
Line: 6810

		 SELECT 1
		  INTO l_other_tasks
		  FROM DUAL
		 WHERE EXISTS(SELECT 1
					   FROM mtl_material_transactions_temp
					  WHERE transaction_header_id <> p_transaction_header_id
						AND content_lpn_id = rec_content_lpns.content_lpn_id);
Line: 6824

		   -- Bug5659809: update last_update_date and last_update_by as well
		   UPDATE wms_license_plate_numbers
			  SET lpn_context = l_lpn_context_inv
				--, last_update_date = SYSDATE  /* Bug 9448490 Lot Substitution Project */
				--, last_updated_by = fnd_global.user_id  /* Bug 9448490 Lot Substitution Project */
			WHERE lpn_id = rec_content_lpns.content_lpn_id
			  AND lpn_context <> l_lpn_context_picked;
Line: 6882

SELECT transaction_temp_id
	  ,task_id
  FROM wms_dispatched_tasks
 WHERE  person_id = p_employee_id
   AND (  status  = l_g_task_dispatched  OR
		  status  = l_g_task_active);  -- IN (3,9 ) ;
Line: 6900

	  DELETE wms_dispatched_tasks
	  WHERE  transaction_temp_id IN
			(SELECT transaction_temp_id
			   FROM mtl_material_transactions_temp
			  WHERE transaction_header_id  = p_transaction_header_id);
Line: 6906

		 mydebug('no WDTs to delete for this header:' );
Line: 6908

		 mydebug('WDTs deleted for this header:' );
Line: 6913

	-- The idea is to delete all tasks belonging to the same header_id (as in case of splits)
	-- and also to delete all dscpatched and active tasks
	-- Decide to delete all tasks with status = dispatched (3 or Active 9).
	-- There is no need to check for a specific header_id . For F2, we anyway always
	-- delete all dispatched and active tasks

	BEGIN
	   l_prev_task_status := wms_picking_pkg.g_previous_task_status(p_transaction_temp_id);
Line: 6921

	   wms_picking_pkg.g_previous_task_status.delete(p_transaction_temp_id);
Line: 6930

	mydebug('l_progress =  ' || l_progress || ' Update status for all temp_ids in thie header_id');
Line: 6933

	/* this update is seperate because for a pick nmore case, there can be multiple temp_ids (MMTTs)
	   for the given header id ...current task) */
	UPDATE  wms_dispatched_tasks
	   SET  status = l_prev_task_status
		   ,last_update_date = SYSDATE
		   ,last_updated_by = p_user_id
	 WHERE  person_id = p_employee_id
	   AND (  status  = l_g_task_dispatched  OR
			  status  = l_g_task_active)  -- IN (3,9 ) ;
Line: 6942

	   AND  transaction_temp_id in (SELECT transaction_temp_id
									  FROM mtl_material_transactions_temp
									 WHERE transaction_header_id = p_transaction_header_id);
Line: 6947

		mydebug('no WDT to update  for this employee id  for this header id with stat in ( 3,9) ' );
Line: 6951

	mydebug('l_progress =  ' || l_progress || ' Update status of all other tasks in this group' );
Line: 6956

		  wms_picking_pkg.g_previous_task_status.delete(rec_reset_task_status.transaction_temp_id);
Line: 6965

		  UPDATE  wms_dispatched_tasks
			 SET  status =  l_prev_task_status
				 ,last_update_date = SYSDATE
				 ,last_updated_by = p_user_id
		   WHERE  task_id = rec_reset_task_status.task_id;
Line: 6972

			  mydebug('task_id : ' || rec_reset_task_status.task_id || ' : not found to be updated');
Line: 6980

	DELETE  wms_dispatched_tasks
	 WHERE  person_id = p_employee_id
	  AND (status  = l_g_task_pending OR
		   status  = l_g_task_dispatched  OR
		   status  = l_g_task_active) ; -- IN (3,9 ) ;
Line: 6987

		mydebug('no WDT with status 3,9,1 remaining to delete for this employee id   ' );
Line: 6988

	   --It is OK not to find even one task to delete
	ELSE
	   mydebug('Deleted all WDT with staus 3,9,1 for p_employee_id =  ' || p_employee_id);
Line: 6995

	UPDATE  wms_dispatched_tasks
	   SET  task_method = NULL  -- for cluster picking
	 WHERE  person_id = p_employee_id
	   AND  status = l_g_task_queued;
Line: 7001

		mydebug('no WDT to update for this employee id to be updated for cluster picking case' );
Line: 7002

	   --It is OK not to find even one task to update
	END IF;
Line: 7065

  SELECT transaction_temp_id from mtl_allocations_gtmp
  WHERE transaction_temp_id <> v_transaction_temp_id
  ORDER BY  transaction_temp_id;
Line: 7080

 SELECT count(*)  into new_mmtt_count from mtl_allocations_gtmp;
Line: 7107

		   wms_picking_pkg.g_start_over_tempid.DELETE(i);
Line: 7138

	   UPDATE  wms_dispatched_tasks
	   SET  status = l_g_task_dispatched
		   ,last_update_date = SYSDATE
		   ,last_updated_by = p_user_id
	   WHERE transaction_temp_id = wms_picking_pkg.g_start_over_tempid(L);
Line: 7144

		  mydebug('transaction_temp_id : ' ||wms_picking_pkg.g_start_over_tempid(L) ||' : not found to be updated');
Line: 7153

		  mydebug('transaction_temp_id : ' ||wms_picking_pkg.g_start_over_tempid(L) ||' : not found to be updated');
Line: 7245

   DELETE  mtl_allocations_gtmp ;
Line: 7396

					   INSERT
						 INTO mtl_allocations_gtmp
							   (transaction_temp_id
							  , lot_number
							  , serial_number
							  , transaction_quantity
							  , primary_quantity
							  , suggested_quantity
							  , secondary_quantity)
					   VALUES  (l_group_number
							  , l_lot_number
							  , l_serial_number
							  , l_lot_trx_qty
							  , l_lot_prim_qty
							  , l_lot_sugg_qty
							  , l_sec_qty );
Line: 7416

			 INSERT
			   INTO mtl_allocations_gtmp
					 (transaction_temp_id
					, lot_number
					, serial_number
					, transaction_quantity
					, primary_quantity
					, suggested_quantity
					, secondary_quantity)
			 VALUES  (l_group_number
					, l_lot_number
					, NULL
					, l_lot_trx_qty
					, l_lot_prim_qty
					, l_lot_sugg_qty
					, l_sec_qty );
Line: 7536

	   SELECT mmtt.transaction_temp_id
		 FROM mtl_material_transactions_temp mmtt
		WHERE mmtt.transaction_header_id = p_transaction_header_id;
Line: 7541

	 SELECT lot_number, serial_transaction_temp_id
	  FROM  mtl_transaction_lots_temp
	  WHERE transaction_temp_id = p_temp_id;
Line: 7545

  CURSOR insert_serial_allocated_csr (p_serial_lot_number  VARCHAR2) IS
   SELECT serial_number
	FROM  mtl_serial_numbers  msn
	WHERE msn.current_organization_id  = p_organization_id
	AND   msn.inventory_item_id        = p_item_id
	AND   lpn_id                       =  p_lpn_match_lpn_id
	AND   NVL(msn.lot_number,'@@')     =  NVL(p_serial_lot_number, '@@')
	AND   msn.serial_number  NOT IN
		  ( select msnt.fm_serial_number
			from mtl_serial_numbers_temp  msnt,
				 mtl_transaction_lots_temp mtlt,
				 mtl_material_transactions_temp  mmtt
			where mmtt.inventory_item_id = p_item_id
			 AND mmtt.organization_id = p_organization_id
			 and mtlt.transaction_temp_id(+) = mmtt.transaction_temp_id
			 AND msnt.transaction_temp_id = NVL(mtlt.serial_transaction_temp_id, mmtt.transaction_temp_id)
			 and NVL(mtlt.lot_number, '@@') = NVL(p_serial_lot_number, '@@')
			 and mmtt.transaction_temp_id = p_temp_id);
Line: 7565

	SELECT NVL(SUM(mtlt.primary_quantity) , SUM(mmtt.primary_quantity))
	  FROM mtl_material_transactions_temp mmtt, mtl_transaction_lots_temp mtlt
	 WHERE mmtt.reservation_id = p_reservation_id
	   AND mmtt.transaction_temp_id = mtlt.transaction_temp_id(+);
Line: 7645

		wms_picking_pkg.g_previous_task_status.delete(p_temp_id);
Line: 7654

	   SELECT move_order_line_id
	   INTO   l_mo_line_id
	   FROM   mtl_material_transactions_temp
	   WHERE  transaction_temp_id = p_temp_id;
Line: 7665

		SELECT Sum(quantity) INTO l_lpn_quantity
		FROM wms_lpn_contents
		WHERE parent_lpn_id = p_lpn_id
		AND organization_id = p_organization_id
		AND inventory_item_id = p_item_id ;
Line: 7694

			 SELECT parent_lpn_id INTO l_parent_lpn_id
			 FROM WMS_LICENSE_PLATE_NUMBERS
			 WHERE lpn_id=l_content_lpn_id ;
Line: 7733

						 FOR serial_rec in insert_serial_allocated_csr(lot_rec.lot_number) LOOP
							-- insert serial into msnt and mark msn
							  insert_serial(
								  p_serial_transaction_temp_id  => lot_rec.serial_transaction_temp_id,
								  p_organization_id             => p_organization_id,
								  p_item_id                     => p_item_id,
								  p_revision                    => p_revision,
								  p_lot                         => lot_rec.lot_number,
								  p_transaction_temp_id         => p_temp_id,
								  p_created_by                  => p_user_id,
								  p_from_serial                 => serial_rec.serial_number,
								  p_to_serial                   => serial_rec.serial_number,
								  p_status_id                   => NULL,
								  x_return_status               => l_return_status,
								  x_msg_data                    => l_msg_data);
Line: 7752

									  fnd_message.set_token('ROUTINE', '-INSERT_SERIAL API - ' || p_action);
Line: 7766

					 FOR serial_rec IN insert_serial_allocated_csr(NULL) LOOP
						  -- insert serial into msnt and mark msn
						  insert_serial(
								  p_serial_transaction_temp_id  => l_transaction_temp_id,
								  p_organization_id             => p_organization_id,
								  p_item_id                     => p_item_id,
								  p_revision                    => p_revision,
								  p_lot                         => NULL,
								  p_transaction_temp_id         => p_temp_id,
								  p_created_by                  => p_user_id,
								  p_from_serial                 => serial_rec.serial_number,
								  p_to_serial                   => serial_rec.serial_number,
								  p_status_id                   => NULL,
								  x_return_status               => l_return_status,
								  x_msg_data                    => l_msg_data);
Line: 7785

								  fnd_message.set_token('ROUTINE', '- INSERT_SERIAL API - ');
Line: 8069

	 --At the end of the load process, we need to update the quantity_detailed
	 --of the move order line. Do this for non-bulk tasks
	 IF (l_mo_line_id IS NOT NULL AND l_parent_line_id IS NULL) THEN

	   IF (l_debug = 1) THEN
		 mydebug('Should update quantity_detailed for MO Line ID: ' || l_mo_line_id);
Line: 8078

	   SELECT uom_code, SECONDARY_UOM_CODE  -- muom:sk
	   INTO   l_mol_uom, l_sec_mol_uom -- muom:sk
	   FROM   mtl_txn_request_lines
	   WHERE  line_id = l_mo_line_id
	   FOR UPDATE;
Line: 8086

	   SELECT ABS(SUM(primary_quantity)), ABS(SUM(secondary_transaction_quantity))
	   INTO   l_sum_mmtt_qty, l_sum_mmtt_sec_txn_qty
	   FROM   mtl_material_transactions_temp
	   WHERE  move_order_line_id = l_mo_line_id;
Line: 8120

		 mydebug('update quantity_detailed in MOL with: ' || l_mmtt_qty_in_mol_uom);
Line: 8122

		 mydebug('update secondary_quantity_detailed in MOL with: ' || l_sum_mmtt_sec_txn_qty);
Line: 8125

	   --Now update quantity_detailed as quanity_delivered + sum(mmtt qty)
	   --Bug#10120826 Now update secondary_quantity_detailed as secondary_quanity_delivered + l_sum_mmtt_sec_txn_qty
	   -- muom:sk ssk: this takes care of full pick only..
	  UPDATE mtl_txn_request_lines
		 SET quantity_detailed           = DECODE(l_fulfillment_base, 'S', l_sum_mmtt_qty, (NVL(quantity_delivered, 0) +l_mmtt_qty_in_mol_uom)),
			 secondary_quantity_detailed = DECODE(l_fulfillment_base, 'S', l_mmtt_sec_qty_in_mol_uom, (NVL(secondary_quantity_delivered,0) + l_sum_mmtt_sec_txn_qty)),
			 last_update_date            = SYSDATE,
			 last_updated_by             = p_user_id
	   WHERE line_id = l_mo_line_id;
Line: 8142

	  SELECT reservation_id
	    INTO l_reservation_id
	    FROM mtl_material_transactions_temp
	   WHERE transaction_temp_id = p_temp_id
	     FOR UPDATE;
Line: 8155

	  UPDATE mtl_reservations
         SET detailed_quantity = LEAST(l_new_mmtt_qty, primary_reservation_quantity)
	   WHERE reservation_id    = l_reservation_id;
Line: 8162

        mydebug('Could not find MMTT to update the Detailed quantity for FB=S ');
Line: 8421

	  SELECT serial_number
		FROM mtl_serial_numbers
	   WHERE lpn_id = p_fromlpn_id
		 AND inventory_item_id = p_item_id
		 AND NVL(lot_number, -999) = NVL(p_lot, -999);
Line: 8428

	  SELECT mtlt.primary_quantity
	   , NVL(mtlt.secondary_quantity, 0)   -- Bug #4141928
		   , mtlt.lot_number
		FROM mtl_transaction_lots_temp mtlt
	   WHERE mtlt.transaction_temp_id = p_temp_id
	   --added material status check for lot under bug8398578
	   AND inv_material_status_grp.is_status_applicable(
										p_wms_installed
								,       NULL
								,       p_transaction_type_id
								,       NULL
								,       NULL
								,       p_org_id
								,       p_item_id
								,       NULL
								,       null
								,       mtlt.lot_number
								,       NULL
								,       'O') = 'Y'
	ORDER BY LOT_NUMBER;
Line: 8451

	  SELECT lot_number, sum(transaction_quantity) transaction_quantity
		from wms_ALLOCATIONS_GTMP
	GROUP BY LOT_NUMBER
	ORDER BY LOT_NUMBER;
Line: 8458

	   SELECT NVL(SUM(primary_transaction_quantity),0)
		  , lot_number , Nvl(Sum(secondary_transaction_quantity),0) --16267113
			 FROM mtl_onhand_quantities_detail
			 WHERE organization_id = p_org_id
		 AND Nvl(containerized_flag, 2) = 1
		 AND lpn_id = p_fromlpn_id
			 AND subinventory_code = p_confirmed_sub
			 AND locator_id = p_confirmed_loc_id
			 AND inventory_item_id = p_item_id
			 AND (revision = p_rev OR (revision IS NULL AND p_rev IS NULL))
			 AND lot_number NOT IN (
					   SELECT mtlt.lot_number
				   FROM mtl_transaction_lots_temp mtlt
				   WHERE mtlt.transaction_temp_id = p_temp_id
				   )
		AND lot_number IS NOT NULL
		GROUP BY lot_number
		ORDER BY lot_number;
Line: 8536

	t_lpn_lot_qty_table.DELETE;
Line: 8541

	 SELECT primary_uom_code
		  , secondary_uom_code
		  , lot_control_code
		  , serial_number_control_code
	   INTO l_primary_uom
		  , l_secondary_uom
		  , l_lot_code
		  , l_serial_code
	   FROM mtl_system_items
	  WHERE organization_id = p_org_id
		AND inventory_item_id = p_item_id;
Line: 8554

	   select value
	   into l_value
	   from v$nls_parameters
	   where parameter = 'NLS_NUMERIC_CHARACTERS';
Line: 8643

	 SELECT 1
		   , lpn_context
		   , parent_lpn_id
		   , subinventory_code
		   , locator_id
		INTO l_lpn_exists
		   , l_lpn_context
		   , x_parent_lpn_id
		   , l_lpn_sub
		   , l_lpn_loc
		FROM wms_license_plate_numbers wlpn
	   WHERE wlpn.organization_id = p_org_id
		 AND wlpn.lpn_id = p_fromlpn_id;
Line: 8689

	  SELECT 1
		INTO l_loaded
		FROM DUAL
	   WHERE EXISTS(SELECT 1
					  FROM mtl_material_transactions_temp
					 WHERE (transfer_lpn_id = p_fromlpn_id
							OR content_lpn_id = p_fromlpn_id)
							AND organization_id = p_org_id); -- this AND organization_id condition is added for Bug# 12541060
Line: 8715

	  -- WMS PJM Integration, Selecting the resolved concatenated segments instead of concatenated segments
	  SELECT w.subinventory_code
		   , inv_project.get_locsegs(w.locator_id, w.organization_id)
		   , w.license_plate_number
		   , w.locator_id
		   , w.lpn_context
		INTO l_sub
		   , l_loc
		   , l_from_lpn
		   , l_loc_id
		   , l_lpn_context
		FROM wms_license_plate_numbers w
	   WHERE w.lpn_id = p_fromlpn_id
		 AND w.locator_id IS NOT NULL;
Line: 8741

	  SELECT COUNT(*)
		INTO l_sub_active
		FROM mtl_secondary_inventories
	   WHERE NVL(disable_date, SYSDATE + 1) > SYSDATE
		 AND organization_id = p_org_id
		 AND secondary_inventory_name = l_sub;
Line: 8756

	  SELECT COUNT(*)
		INTO l_loc_active
		FROM mtl_item_locations_kfv
	   WHERE NVL(disable_date, SYSDATE + 1) > SYSDATE
		 AND organization_id = p_org_id
		 AND subinventory_code = l_sub
		 AND inventory_location_id = l_loc_id;
Line: 8772

	   SELECT locator_id,organization_id,
			  transaction_header_id,
			  transaction_uom,
			  SECONDARY_UOM_CODE,         -- Bug #4141928
			  transaction_source_type_id  --11068325
		 INTO l_locator_id, l_organization_id,
			  l_transaction_header_id,
			  l_transaction_uom,
			  l_sec_transaction_uom,      -- Bug #4141928
			  l_transaction_source_type_id  --11068325
		from mtl_material_transactions_temp
		where transaction_temp_id = p_temp_id;
Line: 8785

		 select nvl(project_id ,-999) , nvl(task_id ,-999)
		into  l_mmtt_proj_id , l_mmtt_task_id
		from  mtl_item_locations
		where inventory_location_id = l_locator_id
		and organization_id = l_organization_id ;
Line: 8791

	  select nvl(project_id, -999) , nvl(task_id ,-999)
		into l_mil_proj_id , l_mil_task_id
		from mtl_item_locations
		where inventory_location_id = l_loc_id
		and organization_id = p_org_id ;
Line: 8836

	  SELECT 1
		INTO l_so_cnt
		FROM wms_license_plate_numbers
	   WHERE lpn_context = 11
		 AND lpn_id = p_fromlpn_id
		 AND organization_id = p_org_id;
Line: 8865

   SELECT mmtt.transfer_subinventory
		 , mmtt.subinventory_code
		 , mmtt.locator_id
	  INTO l_xfr_sub_code
		 , l_mmtt_sub
		 , l_mmtt_loc
	  FROM mtl_material_transactions_temp mmtt
	 WHERE mmtt.transaction_temp_id = p_temp_id;
Line: 8886

	  SELECT 1
		INTO l_item_cnt
		FROM DUAL
	   WHERE EXISTS(
			   SELECT 1
				 FROM wms_lpn_contents wlc
				WHERE wlc.parent_lpn_id = p_fromlpn_id
				  AND wlc.organization_id = p_org_id
				  AND wlc.inventory_item_id = p_item_id
				  AND NVL(wlc.revision, '-999') = NVL(p_rev, '-999'));
Line: 8916

		SELECT 1
		  INTO l_item_cnt
		  FROM DUAL
		WHERE EXISTS( SELECT 1
						FROM wms_lpn_contents wlc
					   WHERE wlc.parent_lpn_id = p_fromlpn_id
						 AND wlc.organization_id = p_org_id
						 AND wlc.inventory_item_id = p_item_id
						 AND NVL(wlc.revision, '-999') = NVL(p_rev, '-999')
						 AND (p_changelotNoException <> 'N'
						  OR (p_full_lot_allocation IN ('N', 'P'))
						  OR EXISTS (SELECT 1
									   FROM mtl_transaction_lots_temp mtlt
									  WHERE mtlt.transaction_temp_id = p_temp_id
										AND mtlt.lot_number = wlc.lot_number)
							  )); -- Modified for 14699845 (Flexible Lot Allocation)
Line: 8985

	  SELECT allocated_lpn_id
		INTO l_allocated_lpn_id
		FROM mtl_material_transactions_temp
	   WHERE transaction_temp_id = p_temp_id;
Line: 9019

	SELECT COUNT(DISTINCT inventory_item_id)
		 , COUNT(DISTINCT lot_number)
		 , COUNT(DISTINCT revision)
		 , COUNT(DISTINCT cost_group_id)
	  INTO l_item_cnt2
		 , l_lot_cnt
		 , l_rev_cnt
		 , l_cg_cnt
	  FROM wms_lpn_contents
	 WHERE parent_lpn_id = p_fromlpn_id
	   AND organization_id = p_org_id;
Line: 9031

	SELECT COUNT(*)
	  INTO l_lpn_include_lpn
	  FROM wms_license_plate_numbers
	 WHERE outermost_lpn_id = p_fromlpn_id
	   AND organization_id = p_org_id;
Line: 9059

			SELECT COUNT(fm_serial_number)
			  INTO l_serial_exist_cnt
			  FROM mtl_serial_numbers_temp msnt, mtl_transaction_lots_temp mtlt
			 WHERE mtlt.transaction_temp_id = p_temp_id
			   AND msnt.transaction_temp_id = mtlt.serial_transaction_temp_id
			   AND msnt.fm_serial_number IN(
										  SELECT serial_number
											FROM mtl_serial_numbers
										   WHERE lpn_id = p_fromlpn_id
											 AND inventory_item_id = p_item_id
											 AND NVL(revision, '-999') = NVL(p_rev, '-999'));
Line: 9104

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			--in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_mtlt_primary_qty
			, p_secondary_quantity         => -l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			, p_lpn_id                     => p_fromlpn_id
			--, p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9143

				mydebug('after update qty tree for lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9144

				mydebug('after update qty tree for lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);
Line: 9148

				mydebug('calling update qty tree with lpn 1st time failed ');
Line: 9156

		  --Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_mtlt_primary_qty
			, p_secondary_quantity         => -l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			--  , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
		   -- , p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9195

				mydebug('after update qty tree without lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9196

				mydebug('after update qty tree without lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);
Line: 9200

				mydebug('calling update qty tree back without lpn 1st time failed ');
Line: 9315

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			-- in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_mtlt_primary_qty
			, p_secondary_quantity         => l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh                 -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			, p_lpn_id                     => p_fromlpn_id
			--, p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9354

				mydebug('after update qty tree back for lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9355

				mydebug('after update qty tree back for lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);
Line: 9359

				mydebug('calling update qty tree back with lpn 1st time failed ');
Line: 9367

		  --Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_mtlt_primary_qty
			, p_secondary_quantity         => l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			--  , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
			--, p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9406

				mydebug('after update qty tree back without lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9407

				mydebug('after update qty tree back without lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);
Line: 9411

				mydebug('calling update qty tree back without lpn 1st time failed ');
Line: 9450

			 SELECT COUNT(fm_serial_number)
			   INTO l_serial_exist_cnt
			   FROM mtl_serial_numbers_temp msnt
			  WHERE msnt.transaction_temp_id = p_temp_id
				AND msnt.fm_serial_number IN(
								   SELECT serial_number
									 FROM mtl_serial_numbers
									WHERE lpn_id = p_fromlpn_id
									  AND inventory_item_id = p_item_id
									  AND NVL(revision, '-999') = NVL(p_rev, '-999'));
Line: 9484

		  --from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
		  -- in order to get correct att.
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => -l_pr_qty
		  , p_secondary_quantity         => -l_sec_qty -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh                 -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  , p_lpn_id                     => p_fromlpn_id
		 -- , p_transfer_subinventory_code => l_xfr_sub_code  -- Bug #14753999
		  );
Line: 9523

				mydebug('update qty tree with lpn 2nd time: l_att :' || l_att);
Line: 9524

				mydebug('update qty tree with lpn 2nd time: l_satt:' || l_satt); -- Bug #4141928
Line: 9528

				mydebug('calling update qty tree with lpn 2nd time failed ');
Line: 9536

		--Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => -l_pr_qty
		  , p_secondary_quantity         => -l_sec_qty -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh         -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
	   -- , p_lpn_id                     => p_fromlpn_id      withour lpn_id, only to locator level
	   -- , p_transfer_subinventory_code => l_xfr_sub_code   -- Bug #14753999
		  );
Line: 9575

				mydebug('update qty tree without lpn 2nd time: l_att :' || l_att);
Line: 9576

				mydebug('update qty tree without lpn 2nd time: l_satt:' || l_satt);
Line: 9580

				mydebug('calling update qty tree back without lpn 2nd time failed ');
Line: 9663

		  --from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
		  -- in order to get correct att.
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => l_pr_qty
		  , p_secondary_quantity         => l_sec_qty   -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh         -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  , p_lpn_id                     => p_fromlpn_id
		 -- , p_transfer_subinventory_code => l_xfr_sub_code  -- Bug #14753999
		  );
Line: 9702

				mydebug('update qty tree back with lpn 2nd time: l_att :' || l_att);
Line: 9703

				mydebug('update qty tree back with lpn 2nd time: l_satt:' || l_satt);
Line: 9707

			  mydebug('calling update qty tree with lpn 2nd time failed ');
Line: 9715

		--Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => l_pr_qty
		  , p_secondary_quantity         => l_sec_qty   -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh         -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		 -- , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
		 -- , p_transfer_subinventory_code => l_xfr_sub_code  -- Bug #14753999
		  );
Line: 9754

				mydebug('update qty tree back without lpn 2nd time:l_att :' || l_att);
Line: 9755

				mydebug('update qty tree back without lpn 2nd time:l_satt:' || l_satt);
Line: 9759

			  mydebug('calling update qty tree back without lpn 2nd time failed ');
Line: 9780

		SELECT primary_quantity, NVL(secondary_transaction_quantity, 0) -- Bug #4141928
		INTO l_mmtt_qty, l_mmtt_sec_qty           -- Bug #4141928
		FROM mtl_material_transactions_temp
		WHERE transaction_temp_id = p_temp_id;
Line: 9807

		  SELECT COUNT(fm_serial_number)
			INTO l_serial_exist_cnt
			FROM mtl_serial_numbers_temp msnt, mtl_transaction_lots_temp mtlt
		   WHERE mtlt.transaction_temp_id = p_temp_id
			 AND msnt.transaction_temp_id = mtlt.serial_transaction_temp_id
			 AND msnt.fm_serial_number IN(
										SELECT serial_number
										  FROM mtl_serial_numbers
										 WHERE lpn_id = p_fromlpn_id
										   AND inventory_item_id = p_item_id
										   AND NVL(revision, '-999') = NVL(p_rev, '-999'));
Line: 9863

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			-- in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_mtlt_primary_qty
			, p_secondary_quantity         => -l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			, p_lpn_id                     => p_fromlpn_id
		   -- , p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9902

				mydebug('update qty tree 3rd time for lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9903

				mydebug('update qty tree 3rd time for lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);  -- Bug #4141928
Line: 9907

				mydebug('calling update qty tree with lpn 3rd time failed ');
Line: 9915

		  --Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_mtlt_primary_qty
			, p_secondary_quantity         => -l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
		   -- , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
		   -- , p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 9954

				mydebug('after update without lpn 3rd time l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 9955

				mydebug('after update without lpn 3rd time l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);
Line: 9959

				mydebug('calling update qty tree back 3rd time without lpn 3rd time failed ');
Line: 10215

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			--in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_mtlt_primary_qty
			, p_secondary_quantity         => l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh                 -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			, p_lpn_id                     => p_fromlpn_id
			--, p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 10254

				mydebug('update qty tree back 3rd time for lpn l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 10255

				mydebug('update qty tree back 3rd time for lpn l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);  -- Bug #4141928
Line: 10259

				mydebug('calling update qty tree with lpn 3rd time failed ');
Line: 10267

		  --Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_mtlt_primary_qty
			, p_secondary_quantity         => l_mtlt_secondary_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh        -- Bug #4141928
			, x_srqoh                      => l_srqoh                -- Bug #4141928
			, x_sqr                        => l_sqr                  -- Bug #4141928
			, x_sqs                        => l_sqs                  -- Bug #4141928
			, x_satt                       => l_satt                 -- Bug #4141928
			, x_satr                       => l_satr                 -- Bug #4141928
			--  , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
			--, p_transfer_subinventory_code => l_xfr_sub_code       -- Bug #14753999
			);
Line: 10306

				mydebug('after update qty tree back without lpn 3rd time l_att :' || l_att || ' for lot:' || l_mtlt_lot_number);
Line: 10307

				mydebug('after update qty tree back without lpn 3rd time l_satt:' || l_satt || ' for lot:' || l_mtlt_lot_number);   -- Bug #4141928
Line: 10311

				mydebug('calling update qty tree back without lpn 3rd time failed ');
Line: 10342

		   SELECT COUNT(fm_serial_number)
			 INTO l_total_serial_cnt
			 FROM mtl_serial_numbers_temp msnt, mtl_transaction_lots_temp mtlt
			WHERE mtlt.transaction_temp_id = p_temp_id
			  AND msnt.transaction_temp_id = mtlt.serial_transaction_temp_id;
Line: 10407

				SELECT COUNT(fm_serial_number)
				INTO l_serial_exist_cnt
				FROM mtl_serial_numbers_temp msnt
				WHERE msnt.transaction_temp_id = p_temp_id
				AND msnt.fm_serial_number IN(
										SELECT serial_number
										  FROM mtl_serial_numbers
										 WHERE lpn_id = p_fromlpn_id
										   AND inventory_item_id = p_item_id
										   AND NVL(revision, '-999') = NVL(p_rev, '-999'));
Line: 10443

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			-- in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => -l_mmtt_qty
		  , p_secondary_quantity         => -l_mmtt_sec_qty  -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh                 -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  , p_lpn_id                     => p_fromlpn_id
		  --, p_transfer_subinventory_code => l_xfr_sub_code    -- Bug #14753999
		  );
Line: 10482

					mydebug('update qty tree with lpn 4th time: l_att :' || l_att);
Line: 10483

					mydebug('update qty tree with lpn 4th time: l_satt:' || l_satt);
Line: 10487

					mydebug('calling update qty tree with lpn 4th time failed ');
Line: 10495

			--Bug#5649056: only update if subinventory and locator match
			ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN

			inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => -l_mmtt_qty
		  , p_secondary_quantity         => -l_mmtt_sec_qty  -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh                 -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  -- , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
		  -- , p_transfer_subinventory_code => l_xfr_sub_code     -- Bug #14753999
		  );
Line: 10535

				mydebug('update qty tree without lpn 4th time:l_att :' || l_att);
Line: 10536

				mydebug('update qty tree without lpn 4th time:l_satt:' || l_satt);  -- Bug #4141928
Line: 10540

				mydebug('calling update qty tree without lpn 4th time failed ');
Line: 10657

		  --from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
		  -- in order to get correct att.
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => l_mmtt_qty
		  , p_secondary_quantity         => l_mmtt_sec_qty -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh         -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  , p_lpn_id                     => p_fromlpn_id
		  --, p_transfer_subinventory_code => l_xfr_sub_code  -- Bug #14753999
		  );
Line: 10696

				mydebug('update qty tree back with lpn 4th time: l_att :' || l_att);
Line: 10697

				mydebug('update qty tree back with lpn 4th time: l_satt:' || l_satt);  -- Bug #4141928
Line: 10701

				mydebug('calling update qty tree back with lpn 4th time failed ');
Line: 10709

		--Bug#5649056: only update if subinventory and locator match
		ELSIF ( l_lpn_sub = l_mmtt_sub AND l_lpn_loc = l_mmtt_loc ) THEN
		  inv_quantity_tree_pub.update_quantities(
			p_api_version_number         => 1.0
		  , p_init_msg_lst               => fnd_api.g_false
		  , x_return_status              => l_return_status
		  , x_msg_count                  => l_msg_cnt
		  , x_msg_data                   => l_msg_data
		  , p_organization_id            => p_org_id
		  , p_inventory_item_id          => p_item_id
		  , p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
		  , p_is_revision_control        => b_is_revision_control
		  , p_is_lot_control             => FALSE
		  , p_is_serial_control          => b_is_serial_control
		  , p_revision                   => NVL(p_rev, NULL)
		  , p_lot_number                 => NULL
		  , p_subinventory_code          => l_sub
		  , p_locator_id                 => l_loc_id
		  , p_primary_quantity           => l_mmtt_qty
		  , p_secondary_quantity         => l_mmtt_sec_qty -- Bug #4141928
		  , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
		  , x_qoh                        => l_qoh
		  , x_rqoh                       => l_rqoh
		  , x_qr                         => l_qr
		  , x_qs                         => l_qs
		  , x_att                        => l_att
		  , x_atr                        => l_atr
		  , x_sqoh                       => l_sqoh                 -- Bug #4141928
		  , x_srqoh                      => l_srqoh                -- Bug #4141928
		  , x_sqr                        => l_sqr                  -- Bug #4141928
		  , x_sqs                        => l_sqs                  -- Bug #4141928
		  , x_satt                       => l_satt                 -- Bug #4141928
		  , x_satr                       => l_satr                 -- Bug #4141928
		  --  , p_lpn_id                =>   p_fromlpn_id      withour lpn_id, only to locator level
		  --, p_transfer_subinventory_code => l_xfr_sub_code   -- Bug #14753999
		  );
Line: 10748

				mydebug('update qty tree back without lpn 4th time l_att :' || l_att);
Line: 10749

				mydebug('update qty tree back without lpn 4th time l_satt:' || l_satt);
Line: 10753

				mydebug('calling update qty tree back without lpn 4th time failed ');
Line: 10770

				SELECT COUNT(fm_serial_number)
				INTO l_total_serial_cnt
				FROM mtl_serial_numbers_temp msnt
				WHERE msnt.transaction_temp_id = p_temp_id;
Line: 10840

	/* In Case of Flexible Lot Allocation, we would need to update the Qty Tree
	   with Negative values before query tree since we are not passing the demand information 16267113 */

--*******************************************************--
-- Start for 16267113 Flexible Lot Allocation

		IF (p_full_lot_allocation IN ('N', 'P')) THEN
		  IF NVL(l_allocated_lpn_id, 0) = p_fromlpn_id THEN
			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			-- in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => NULL
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_task_pri_qty
			, p_secondary_quantity         => -l_task_sec_qty
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			, p_lpn_id                     => p_fromlpn_id
			);
Line: 10886

				mydebug('update qty tree for FlexiLotAlloc lpn l_att:'  || l_att  || ' at Locator Level');
Line: 10887

				mydebug('update qty tree for FlexiLotAlloc lpn l_satt:' || l_satt || ' at Locator Level');
Line: 10891

				mydebug('calling update qty tree with lpn for FlexiLotAlloc failed ');
Line: 10901

			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => NULL
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => -l_task_pri_qty
			, p_secondary_quantity         => -l_task_sec_qty -- Bug #4141928
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			);
Line: 10936

				mydebug('after update without lpn for FlexiLotAlloc l_att:'  || l_att  || ' at Locator Level');
Line: 10937

				mydebug('after update without lpn for FlexiLotAlloc l_satt:' || l_satt || ' at Locator Level');
Line: 10941

				mydebug('calling update qty tree for FlexiLotAlloc without lpn failed ');
Line: 11096

			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => NULL
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_task_pri_qty
			, p_secondary_quantity         => l_task_sec_qty
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			, p_lpn_id                     => p_fromlpn_id
			);
Line: 11132

				mydebug('update qty tree back with +ve qty for FlexiLotAlloc lpn l_att:'  || l_att  || ' at Locator Level');
Line: 11133

				mydebug('update qty tree back with +ve qty for FlexiLotAlloc lpn l_satt:' || l_satt || ' at Locator Level');  -- Bug #4141928
Line: 11137

				mydebug('calling update qty tree with lpn for FlexiLotAlloc failed ');
Line: 11146

			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => l_mtlt_lot_number
			, p_subinventory_code          => l_sub
			, p_locator_id                 => l_loc_id
			, p_primary_quantity           => l_task_pri_qty
			, p_secondary_quantity         => l_task_sec_qty
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			);
Line: 11181

				mydebug('after update qty tree back for +ve qty without lpn for FlexiLotAlloc l_att:'  || l_att  || ' at Locator Level');
Line: 11182

				mydebug('after update qty tree back for +ve qty without lpn for FlexiLotAlloc l_satt:' || l_satt || ' at Locator Level');   -- Bug #4141928
Line: 11186

				mydebug('calling update qty tree back for +ve qty without lpn for FlexiLotAlloc failed ');
Line: 11215

			SELECT NVL(SUM(primary_quantity),0), NVL(SUM(secondary_quantity),0)
			INTO l_lpn_qoh, l_lpn_sqoh
			FROM wms_lpn_contents
			WHERE parent_lpn_id = p_fromlpn_id
		   AND inventory_item_id = p_item_id;
Line: 11503

	DELETE FROM wms_allocations_gtmp;
Line: 11515

			 INSERT INTO WMS_ALLOCATIONS_GTMP
			 (lot_number,
			  serial_number,
			  transaction_quantity,
			  primary_quantity)
			  SELECT mtlt.lot_number,fm_serial_number,1,1
			  FROM mtl_serial_numbers_temp msnt,
				   mtl_transaction_lots_temp mtlt,
				   mtl_serial_numbers msn
			  WHERE mtlt.transaction_temp_id = p_temp_id
				AND msnt.transaction_temp_id = mtlt.serial_transaction_temp_id
				AND msnt.fm_serial_number = msn.serial_number
				AND msn.lpn_id = p_fromlpn_id
				AND msn.inventory_item_id = p_item_id;
Line: 11568

			INSERT INTO WMS_ALLOCATIONS_GTMP
			 (serial_number,
			  transaction_quantity,
			  primary_quantity)
			  SELECT fm_serial_number,1,1
			  FROM mtl_serial_numbers_temp msnt,
				   mtl_serial_numbers msn
			  WHERE  msnt.transaction_temp_id = p_temp_id
				AND msnt.fm_serial_number = msn.serial_number
				AND msn.lpn_id = p_fromlpn_id
				AND msn.inventory_item_id = p_item_id;
Line: 11603

				INSERT INTO wms_allocations_gtmp
				(lot_number,
				 serial_number,
				 transaction_quantity,
				 primary_quantity)
				SELECT mtlt.lot_number, serial_number, 1, 1
				FROM mtl_transaction_lots_temp mtlt,
					 mtl_serial_numbers msn
				WHERE mtlt.transaction_temp_id = p_temp_id
				  AND msn.lpn_id = p_fromlpn_id
				  AND mtlt.lot_number = msn.lot_number
				  AND msn.inventory_item_id = p_item_id
				  AND Nvl(msn.group_mark_id, -1) = -1;
Line: 11617

			   INSERT INTO wms_allocations_gtmp
				(serial_number,
				 transaction_quantity,
				 primary_quantity)
				SELECT serial_number,1,1
				FROM mtl_serial_numbers msn
				WHERE msn.lpn_id = p_fromlpn_id
				AND msn.inventory_item_id = p_item_id
				AND Nvl(msn.group_mark_id, -1) = -1;
Line: 11645

			INSERT INTO wms_allocations_gtmp(lot_number, primary_quantity,
											 transaction_quantity, secondary_quantity)  -- Bug #4141928
				   values(t_lpn_lot_qty_table(l_table_count).lot_number,
						  t_lpn_lot_qty_table(l_table_count).pri_qty,
						  t_lpn_lot_qty_table(l_table_count).trx_qty,
		  t_lpn_lot_qty_table(l_table_count).sec_qty
		  );                     -- Bug #4141928
Line: 11808

	SELECT NVL(SUM(primary_transaction_quantity),0), NVL(SUM(secondary_transaction_quantity),0)
	INTO l_qoh, l_sqoh
	FROM mtl_onhand_quantities_detail
	WHERE lpn_id = p_fromlpn_id
	AND organization_id = p_org_id;
Line: 11859

 *  We will select this LPN for Update , so that otehr processes cannot get it.
 *  yes, there is a possibility that
 */
	IF (x_match = 3) Or (x_match = 1) THEN   -- added x_match=1
	   IF (l_debug = 1) THEN
		 mydebug('Lock lpn_ID : ' || p_fromlpn_id);
Line: 11868

		 SELECT lpn_context
		   INTO l_lpn_context
		   FROM wms_license_plate_numbers
		  WHERE lpn_id = p_fromlpn_id
			FOR UPDATE NOWAIT;
Line: 12060

	  SELECT mtlt.primary_quantity
		   , mtlt.transaction_quantity
		   , NVL(mtlt.secondary_quantity, 0)    -- Bug #4141928
		   , mtlt.lot_number
		FROM mtl_transaction_lots_temp mtlt
	   WHERE mtlt.transaction_temp_id = p_temp_id
	   --added material status check for lot under bug8398578
	   AND inv_material_status_grp.is_status_applicable(
										NULL
								,       NULL
								,       p_transaction_type_id
								,       NULL
								,       NULL
								,       p_org_id
								,       p_item_id
								,       NULL
								,       null
								,       mtlt.lot_number
								,       NULL
								,       'O') = 'Y'
	ORDER BY LOT_NUMBER;
Line: 12083

	  SELECT lot_number, sum(transaction_quantity) transaction_quantity
	  from wms_ALLOCATIONS_GTMP
	  GROUP BY LOT_NUMBER
	  ORDER BY LOT_NUMBER;
Line: 12089

	  SELECT transfer_subinventory
	  FROM mtl_material_transactions_temp
	  WHERE transaction_temp_id = p_temp_id; -- Bug #7257709
Line: 12095

	   SELECT NVL(SUM(primary_transaction_quantity),0)
		  , NVL(SUM(transaction_quantity), 0)
		  , lot_number
			 FROM mtl_onhand_quantities_detail
			 WHERE organization_id = p_org_id
		 AND Nvl(containerized_flag, 2) = 2 -- different from lpn_match
			 AND subinventory_code = p_confirmed_sub
			 AND locator_id = p_confirmed_locator
			 AND inventory_item_id = p_item_id
			 AND (revision = p_rev OR (revision IS NULL AND p_rev IS NULL))
			 AND lot_number NOT IN (
					   SELECT mtlt.lot_number
				   FROM mtl_transaction_lots_temp mtlt
				   WHERE mtlt.transaction_temp_id = p_temp_id
				   )
		AND lot_number IS NOT NULL
		GROUP BY lot_number
	  UNION
	  SELECT mtlt.primary_quantity
		   , mtlt.transaction_quantity
		   , mtlt.lot_number
		FROM mtl_transaction_lots_temp mtlt
	   WHERE mtlt.transaction_temp_id = p_temp_id
			ORDER BY lot_number;
Line: 12139

	DELETE wms_allocations_gtmp;
Line: 12140

	t_lpn_lot_qty_table.DELETE;
Line: 12162

				 INSERT INTO wms_allocations_gtmp
				 (lot_number,
				  serial_number,
				  transaction_quantity,
				  primary_quantity)
				  SELECT mtlt.lot_number,fm_serial_number,1,1
				  FROM mtl_serial_numbers_temp msnt,
					   mtl_transaction_lots_temp mtlt,
					   mtl_serial_numbers msn
				  WHERE mtlt.transaction_temp_id = p_temp_id
					AND msnt.transaction_temp_id = mtlt.serial_transaction_temp_id
					AND msnt.fm_serial_number = msn.serial_number
					AND msn.lpn_id is null -- make sure it is loose pick
					AND msn.inventory_item_id = p_item_id;
Line: 12189

				INSERT INTO wms_ALLOCATIONS_GTMP
				 (serial_number,
				  transaction_quantity,
				  primary_quantity)
				  SELECT fm_serial_number,1,1
				  FROM mtl_serial_numbers_temp msnt,
					   mtl_serial_numbers msn
				  WHERE  msnt.transaction_temp_id = p_temp_id
					AND msnt.fm_serial_number = msn.serial_number
					AND msn.lpn_id is null
					AND msn.inventory_item_id = p_item_id;
Line: 12262

			UPDATE mtl_material_transactions_temp mmtt
			SET posting_flag = 'N'
			WHERE transaction_temp_id = p_temp_id;
Line: 12296

					 UPDATE mtl_material_transactions_temp mmtt
						SET posting_flag = 'Y'
					  WHERE transaction_temp_id = p_temp_id;
Line: 12415

						   mydebug('inserting into global temp table for serial is non allocated....');
Line: 12417

					-- If negative Balance allowed then update vikas 09/07/04 V1
					IF (p_is_negbal_allowed ='true') THEN
						INSERT INTO wms_ALLOCATIONS_GTMP
						 (lot_number,
						  primary_quantity,
						  transaction_quantity,
						  secondary_quantity) -- Bug #4141928
						VALUES( l_lot_number,
								l_lot_primary_qty,
								l_trx_lot_qty,
								l_trx_lot_sec_qty);
Line: 12431

						INSERT INTO wms_ALLOCATIONS_GTMP
						  (lot_number,
						   primary_quantity,
						   transaction_quantity,
						   secondary_quantity) -- Bug #4141928
						   VALUES( l_lot_number,
						   LEAST(l_lot_primary_qty,l_att),
						   LEAST(l_trx_lot_qty,l_att_trx_qty),
						   LEAST(l_trx_lot_sec_qty,l_att_trx_sec_qty));
Line: 12604

		--SELECT decode(mmtt.transaction_type_id, 35,'N',51,'N','Y')
		SELECT 'FAIL'
		  FROM mtl_material_transactions_temp mmtt, mtl_txn_request_lines mol
		 WHERE mmtt.transaction_temp_id = p_transaction_temp_id
		   AND mmtt.move_order_line_id = mol.line_id
		   AND mol.line_status = inv_globals.g_to_status_cancel_by_source
		   AND ROWNUM = 1;
Line: 12670

		SELECT lpn_context
			 , organization_id
			 , locator_id
			 , lpn_id
			 , outermost_lpn_id
		  INTO lpn_cont
			 , l_org_id
			 , l_locator_id
			 , x_lpn_id
			 , x_outermost_lpn_id
		  FROM wms_license_plate_numbers
		 WHERE license_plate_number = p_lpn;
Line: 12707

		 l_CursorStmt := 'SELECT count (*) FROM mtl_material_transactions_temp mmtt, wms_user_task_type_attributes wutta '||
						 'WHERE mmtt.transaction_temp_id = :x_temp_id ' ||
						 ' AND mmtt.standard_operation_id = wutta.user_task_type_id '||
						 ' AND mmtt.organization_id = wutta.organization_id '||
						 ' AND wutta.honor_case_pick_flag = ''Y'' ';  --Added for Bug#7584906
Line: 12940

	  wsh_update_tbl  WSH_GLBL_VAR_STRCT_GRP.delivery_details_Attr_tbl_Type;
Line: 12964

		SELECT wda.delivery_id
		  FROM wsh_delivery_assignments_v        wda
			 , wsh_delivery_details_ob_grp_v   wdd
			 , mtl_material_transactions_temp  mmtt
		 WHERE mmtt.transfer_lpn_id   = l_lpn_id
		   AND wda.delivery_detail_id = wdd.delivery_detail_id
		   AND wdd.move_order_line_id = mmtt.move_order_line_id
		   AND wdd.organization_id    = mmtt.organization_id;
Line: 12975

		SELECT lpn_id
		FROM   wms_license_plate_numbers
		START  WITH lpn_id = l_lpn_id
		CONNECT BY parent_lpn_id = PRIOR lpn_id;
Line: 12983

		SELECT wda.delivery_id
		  FROM wsh_delivery_assignments_v        wda
			 , wsh_delivery_details_ob_grp_v   wdd
			 , mtl_material_transactions_temp  mmtt
		 WHERE wda.delivery_detail_id   = wdd.delivery_detail_id
		   AND wdd.move_order_line_id   = mmtt.move_order_line_id
		   AND wdd.organization_id      = mmtt.organization_id
		   AND mmtt.transaction_temp_id = p_temp_id
		   AND mmtt.organization_id     = p_organization_id;
Line: 12994

		SELECT wda.delivery_id
		  FROM wsh_delivery_assignments_v       wda
			 , wsh_delivery_details_ob_grp_v  wdd
		 WHERE wda.parent_delivery_detail_id = wdd.delivery_detail_id
		   AND wdd.lpn_id = l_lpn_id
		   AND wdd.organization_id = p_organization_id
		   AND wdd.released_status = 'X';  -- For LPN reusability ER : 6845650
Line: 13007

		SELECT NVL(mil.project_id, -1)
			 , NVL(mil.task_id, -1)
		  FROM mtl_item_locations mil, mtl_material_transactions_temp mmtt
		 WHERE mil.inventory_location_id = mmtt.transfer_to_location
		   AND mil.organization_id       = mmtt.organization_id
		   AND mmtt.transfer_lpn_id      = p_pick_to_lpn_id
		   AND mmtt.organization_id      = p_organization_id;
Line: 13020

		SELECT NVL(mil.project_id, -1)
			 , NVL(mil.task_id, -1)
		  FROM mtl_item_locations mil, mtl_material_transactions_temp mmtt
		 WHERE mil.inventory_location_id = mmtt.transfer_to_location
		   AND mil.organization_id       = mmtt.organization_id
		   AND mmtt.organization_id      = p_organization_id
		   AND mmtt.transaction_temp_id  = p_temp_id;
Line: 13029

		SELECT mol.carton_grouping_id
		  FROM mtl_txn_request_lines mol, mtl_material_transactions_temp mmtt
		 WHERE mmtt.transaction_temp_id = p_temp_id
		   AND mmtt.organization_id     = mol.organization_id
		   AND mmtt.move_order_line_id  = mol.line_id;
Line: 13036

		SELECT DISTINCT mol.carton_grouping_id
				   FROM mtl_txn_request_lines mol, mtl_material_transactions_temp mmtt
				  WHERE mmtt.transfer_lpn_id = p_lpn_id
					AND mmtt.organization_id = mol.organization_id
					AND mmtt.move_order_line_id = mol.line_id;
Line: 13045

	  SELECT distinct wda.delivery_id
	  FROM wsh_delivery_details wdd, wsh_delivery_assignments wda
	  WHERE wdd.lpn_id IN (select lpn_id from wms_license_plate_numbers
						where organization_id = p_organization_id
						and (lpn_id = p_lpn_id
						or parent_lpn_id = p_lpn_id
						or outermost_lpn_id = p_lpn_id))
	  AND wda.parent_delivery_detail_id = wdd.delivery_detail_id
	  AND wdd.released_status = 'X';  -- For LPN reusability ER : 6845650
Line: 13139

						   SELECT wlpn.LICENSE_PLATE_NUMBER
						   INTO l_lpn_name
						   FROM Wms_License_Plate_Numbers wlpn
						   WHERE organization_id = p_organization_id
						   and (lpn_id = pick_to_lpn_rec.lpn_id
						   or parent_lpn_id = pick_to_lpn_rec.lpn_id
						   or outermost_lpn_id = pick_to_lpn_rec.lpn_id);
Line: 13147

						   SELECT wdd.released_status,wdd.delivery_detail_id
						   INTO l_status_code,l_delivery_detail_id
						   FROM wsh_delivery_details_ob_grp_v wdd
							WHERE wdd.container_name = l_lpn_name
						   AND wdd.released_status = 'X';      -- For LPN reusability ER : 6845650
Line: 13157

			   2. Replace API call to wsh_container_grp.update_container
				  with new API call WSH_WMS_LPN_GRP.Create_Update_Containers
			   */

			   IF l_status_code = 'C' THEN

				  l_wsh_dd_upd_rec.delivery_detail_id := l_delivery_detail_id;
Line: 13166

				  wsh_update_tbl(1) := l_wsh_dd_upd_rec;
Line: 13169

				  l_IN_rec.action_code := 'UPDATE_NULL';
Line: 13171

				  WSH_WMS_LPN_GRP.Create_Update_Containers (
					  p_api_version     => 1.0
					, p_init_msg_list   => fnd_api.g_false
					, p_commit          => fnd_api.g_false
					, x_return_status   => x_return_status
					, x_msg_count       => x_msg_count
					, x_msg_data        => x_msg_data
					, p_detail_info_tab => wsh_update_tbl
					, p_IN_rec          => l_IN_rec
					, x_OUT_rec         => l_OUT_rec );
Line: 13216

					 SELECT nvl(inventory_item_id, -999)
					   INTO l_container_item_id
					  FROM  wms_license_plate_numbers
					  WHERE license_plate_number = p_pick_to_lpn
						AND organization_id = p_organization_id
						AND lpn_context IN (wms_container_pub.lpn_context_packing, wms_container_pub.LPN_CONTEXT_PREGENERATED);
Line: 13246

						  SELECT CONCATENATED_SEGMENTS
							INTO  l_concatenated_segments
							FROM  MTL_SYSTEM_ITEMS_KFV
						   WHERE  inventory_item_id = l_container_item_id
							 AND  organization_id = p_organization_id;
Line: 13363

	  SELECT mmtt.transfer_subinventory
	, mmtt.transfer_to_location
	, mmtt.inventory_item_id
	, mmtt.operation_plan_id
	, nvl(mmtt.parent_line_id,-1)
	, mmtt.transaction_header_id
	  INTO l_xfr_sub
	, l_xfr_to_location
	, l_item_id
	, l_operation_plan_id
	, l_parent_line_id
	, l_transaction_header_id
	  FROM mtl_material_transactions_temp mmtt
	  WHERE mmtt.transaction_temp_id = p_temp_id;
Line: 13388

		  select 'N'
		  into l_multiple_pick
		  from dual
		  where exists (select 1
			from mtl_material_transactions_temp
			where transfer_lpn_id = pick_to_lpn_rec.lpn_id
	   and transaction_header_id <>l_transaction_header_id);
Line: 13405

							   select 'Y'
							   into l_bulk_task_exist
							   from dual
							   where exists (select 1
											 from mtl_material_transactions_temp
											 where transfer_lpn_id = pick_to_lpn_rec.lpn_id
											 and transaction_temp_id = parent_line_id  -- bulk task
											 );
Line: 13433

	  SELECT mtrh.move_order_type
		   , mmtt.transaction_type_id
		   , mmtt.wip_entity_type
		INTO l_mmtt_mo_type
		   , l_mmtt_txn_type_id
		   , l_mmtt_wip_entity_type
		FROM mtl_txn_request_headers         mtrh
		   , mtl_txn_request_lines           mtrl
		   , mtl_material_transactions_temp  mmtt
	   WHERE mtrh.header_id           = mtrl.header_id
		 AND mtrl.line_id             = mmtt.move_order_line_id
		 AND mmtt.transaction_temp_id = p_temp_id;
Line: 13447

		 SELECT mtrh.move_order_type
			  , mmtt.wip_entity_type
		   INTO l_mo_type_in_lpn
			  , l_wip_entity_type_in_lpn
		   FROM mtl_txn_request_headers         mtrh
			  , mtl_txn_request_lines           mtrl
			  , mtl_material_transactions_temp  mmtt
		  WHERE mtrh.header_id       = mtrl.header_id
			AND mtrl.line_id         = mmtt.move_order_line_id
			AND mmtt.transfer_lpn_id = pick_to_lpn_rec.lpn_id
			AND ROWNUM < 2;
Line: 13501

					  SELECT mmtt.transfer_subinventory
		   , mmtt.transfer_to_location
		   , mmtt.inventory_item_id
		   , mmtt.operation_plan_id
		INTO l_xfr_sub
		   , l_xfr_to_location
		   , l_item_id
		   , l_operation_plan_id
		FROM mtl_material_transactions_temp mmtt
	   WHERE mmtt.transaction_temp_id = p_temp_id; */
Line: 13515

		 SELECT lpn_controlled_flag
		   INTO l_lpn_controlled_flag
		   FROM mtl_secondary_inventories
		  WHERE organization_id = p_organization_id
			AND secondary_inventory_name = l_xfr_sub;
Line: 13534

			SELECT COUNT(*)
			  INTO l_count
			  FROM mtl_material_transactions_temp mmtt
			 WHERE mmtt.transaction_temp_id <> p_temp_id
			   AND mmtt.transfer_lpn_id = pick_to_lpn_rec.lpn_id
			   AND ( NVL(mmtt.transfer_subinventory, 0) <> l_xfr_sub
					 OR
					 NVL(mmtt.transfer_to_location, 0)  <> l_xfr_to_location
				   );
Line: 13572

			SELECT 1
			  INTO l_count
			  FROM DUAL
			 WHERE EXISTS
				 ( SELECT 'x'
					 FROM mtl_material_transactions_temp  mmtt
						, mtl_secondary_inventories       msi
					WHERE mmtt.transaction_temp_id    <> p_temp_id
					  AND mmtt.transfer_lpn_id         = pick_to_lpn_rec.lpn_id
					  AND msi.organization_id          = p_organization_id
					  AND msi.secondary_inventory_name = mmtt.transfer_subinventory
					  AND msi.lpn_controlled_flag      = wms_globals.g_lpn_controlled_sub
				 );
Line: 13605

	   SELECT 'Y'
		 INTO l_fb_comingle
		 FROM mtl_material_transactions_temp mmtt
		WHERE mmtt.transaction_temp_id = p_temp_id
		  AND mmtt.organization_id = p_organization_id
		  AND EXISTS(SELECT 1
					   FROM mtl_material_transactions_temp mmtt1
					  WHERE mmtt1.transaction_temp_id <> p_temp_id
						AND mmtt1.organization_id = p_organization_id
						AND mmtt1.inventory_item_id = p_inventory_item_id
						AND (mmtt1.transfer_lpn_id = pick_to_lpn_rec.lpn_id
						  OR mmtt1.content_lpn_id = pick_to_lpn_rec.lpn_id)
						AND NVL(mmtt.fulfillment_base, 'P') <> NVL(mmtt1.fulfillment_base,'P'));
Line: 13642

		SELECT COUNT(1)
		  INTO l_count
		  FROM mtl_material_transactions_temp mmtt
		 WHERE mmtt.transaction_temp_id <> p_temp_id
		   AND mmtt.transfer_lpn_id      = pick_to_lpn_rec.lpn_id
		   AND mmtt.operation_plan_id   <> l_operation_plan_id;
Line: 13785

				SELECT wdd.delivery_detail_id INTO  l_line_rows(1)
				FROM wsh_delivery_details    wdd
					, mtl_material_transactions_temp  mmtt
				WHERE mmtt.transaction_temp_id = p_temp_id
				AND wdd.move_order_line_id = mmtt.move_order_line_id
				AND wdd.organization_id    = mmtt.organization_id;
Line: 13792

				SELECT wdd.delivery_detail_id  INTO  l_line_rows(2)
				FROM wsh_delivery_details  wdd
					 , mtl_material_transactions_temp  mmtt
				WHERE mmtt.transfer_lpn_id   = pick_to_lpn_rec.lpn_id
				AND wdd.move_order_line_id = mmtt.move_order_line_id
				AND wdd.organization_id    = mmtt.organization_id
				AND rownum<2;
Line: 14155

	  SELECT mmtt.transaction_type_id
		   , mmtt.organization_id
		   , mmtt.inventory_item_id
		INTO l_transaction_type_id
		   , l_org_id
		   , l_item_id
		FROM mtl_material_transactions_temp mmtt
	   WHERE mmtt.transaction_temp_id = p_temp_id;
Line: 14227

PROCEDURE insert_serial(
	p_serial_transaction_temp_id IN OUT NOCOPY NUMBER,
	p_organization_id            IN     NUMBER,
	p_item_id                    IN     NUMBER,
	p_revision                   IN     VARCHAR2,
	p_lot                        IN     VARCHAR2,
	p_transaction_temp_id        IN     NUMBER,
	p_created_by                 IN     NUMBER,
	p_from_serial                IN     VARCHAR2,
	p_to_serial                  IN     VARCHAR2,
	p_status_id                  IN     NUMBER := NULL,
	x_return_status              OUT    NOCOPY VARCHAR2,
	x_msg_data                   OUT    NOCOPY VARCHAR2
  ) IS

	  PRAGMA AUTONOMOUS_TRANSACTION;
Line: 14256

		 mydebug('Enter insert_serial: 10:'|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
Line: 14258

	  --SAVEPOINT rcv_insert_serial_sp;
Line: 14266

			 SELECT 1
			 INTO l_count
			 FROM mtl_serial_numbers_temp msnt, mtl_transaction_lots_temp mtlt,
				  mtl_material_transactions_temp mmtt
			 WHERE (p_from_serial BETWEEN msnt.fm_serial_number AND msnt.to_serial_number
				OR p_to_serial BETWEEN msnt.fm_serial_number AND msnt.to_serial_number)
			   AND mmtt.inventory_item_id = p_item_id
			   AND mmtt.organization_id = p_organization_id
			   AND mtlt.transaction_temp_id(+) = mmtt.transaction_temp_id
			   AND msnt.transaction_temp_id = nvl(mtlt.serial_transaction_temp_id, mmtt.transaction_temp_id);
Line: 14294

		 SELECT serial_transaction_temp_id
		   INTO p_serial_transaction_temp_id
		   FROM mtl_transaction_lots_temp
		  WHERE transaction_temp_id = p_transaction_temp_id
			AND lot_number= p_lot;
Line: 14308

			  SELECT mtl_material_transactions_s.NEXTVAL
				INTO p_serial_transaction_temp_id
				FROM DUAL;
Line: 14314

			  UPDATE mtl_transaction_lots_temp
				 SET serial_transaction_temp_id = p_serial_transaction_temp_id
			   WHERE transaction_temp_id = p_transaction_temp_id
				 AND lot_number= p_lot;
Line: 14324

	   l_return         := inv_trx_util_pub.insert_ser_trx(
							 p_trx_tmp_id => p_serial_transaction_temp_id,
							 p_user_id    => p_created_by,
							 p_fm_ser_num => p_from_serial,
							 p_to_ser_num => p_to_serial,
							 p_status_id  => p_status_id,
							 x_proc_msg   => x_msg_data
						   );
Line: 14335

		 UPDATE mtl_serial_numbers
			SET group_mark_id = p_serial_transaction_temp_id
		  WHERE inventory_item_id = p_item_id
			AND serial_number BETWEEN p_from_serial AND p_to_serial
			AND LENGTH(serial_number) = LENGTH(p_from_serial);
Line: 14348

		  mydebug('Insert serial vals'|| p_item_id || ':' || p_from_serial || ':' || p_to_serial, 4);
Line: 14349

		  mydebug('Insert serial, inserted with '|| p_serial_transaction_temp_id || ':' || l_success, 4);
Line: 14352

	   -- if the trx manager returned a 1 then it could not insert the row
	   IF l_return = 1 THEN
		 RAISE fnd_api.g_exc_error;
Line: 14359

		  mydebug('Exitting insert_serial : 90  '|| TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
Line: 14366

		 --ROLLBACK TO rcv_insert_serial_sp;
Line: 14370

			mydebug('Exitting insert_serial - execution error:'|| l_progress || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
Line: 14378

		   inv_mobile_helper_functions.sql_error('wms_task_load.insert_serial', l_progress, SQLCODE);
Line: 14382

			mydebug('Exitting insert_serial - other exception:'|| l_progress || ' ' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS'), 1);
Line: 14387

		   fnd_msg_pub.add_exc_msg(g_pkg_name, 'insert_serial');
Line: 14390

END insert_serial;
Line: 14443

		 select mmtt.subinventory_code,
				mmtt.locator_id,
				mmtt.revision,
				mmtt.lpn_id,
				null,
				null,
				mmtt.transaction_action_id, -- Bug 4632519
				mmtt.transaction_type_id -- Bug 4632519
		   INTO l_sub,
				l_loc,
				l_rev,
				l_lpn,
				l_ser,l_lot,
				l_transaction_action_id, -- Bug 4632519
				l_transaction_type_id -- Bug 4632519
		   from mtl_material_Transactions_temp mmtt
		  where mmtt.inventory_item_id = p_inventory_item_id
			and mmtt.organization_id = p_organization_id
			and mmtt.transfer_lpn_id = p_transfer_lpn_id
			and mmtt.content_lpn_id is null
			and decode(p_revision_control,2,mmtt.revision,1,'~~') = nvl(p_revision,'~~')
			and rownum<2;
Line: 14466

		 select mmtt.subinventory_code,
				mmtt.locator_id,
				mmtt.revision,
				mmtt.lpn_id,
				null,
				mtlt.lot_number,
				mmtt.transaction_action_id,
				mmtt.transaction_type_id
		 INTO l_sub,
			  l_loc,
			  l_rev,
			  l_lpn,
			  l_ser,
			  l_lot,
			  l_transaction_action_id, -- Bug 4632519
			  l_transaction_type_id -- Bug 4632519
		 from mtl_material_Transactions_temp mmtt,
			  mtl_transaction_lots_temp mtlt
		where mmtt.inventory_item_id = p_inventory_item_id
		  and mmtt.organization_id = p_organization_id
		  and mmtt.transfer_lpn_id = p_transfer_lpn_id
		  and mmtt.content_lpn_id is null
		  and decode(p_revision_control,2,mmtt.revision,1,'~~') = nvl(p_revision,'~~')
		  and mmtt.transaction_temp_id = mtlt.transaction_temp_id
		  and mtlt.lot_number = p_lot_number
		  and rownum<2;
Line: 14509

	 inv_cost_group_update.proc_determine_costgroup(
		p_organization_id       => p_organization_id,
		p_inventory_item_id     => p_inventory_item_id,
		p_subinventory_code     => p_subinventory_code,
		p_locator_id            => p_locator_id,
		p_revision              => p_revision,
		p_lot_number            => p_lot_number,
		p_serial_number         => null,
		p_containerized_flag    => null,
		p_lpn_id                => p_lpn_id,
		p_transaction_action_id => p_trx_action_id,
		p_is_backflush_txn      => l_is_bf,
		x_cost_group_id         => l_cur_cost_group_id,
		x_return_status         => x_return_status);
Line: 14531

	 inv_cost_group_update.proc_determine_costgroup(
		   p_organization_id       => p_organization_id,
		   p_inventory_item_id     => p_inventory_item_id,
		   p_subinventory_code     => l_sub,
		   p_locator_id            => l_loc,
		   p_revision              => l_rev,
		   p_lot_number            => l_lot,
		   p_serial_number         => l_ser,
		   p_containerized_flag    => null,
		   p_lpn_id                => l_lpn,
		   p_transaction_action_id => l_transaction_action_id,
		   p_is_backflush_txn      => l_is_bf,
		   x_cost_group_id         => l_exist_cost_group_id,
		   x_return_status         => x_return_status);
Line: 14570

PROCEDURE insert_mtlt (
		p_new_temp_id     IN  NUMBER
	  , p_serial_temp_id  IN  NUMBER := NULL
	  , p_pri_att_qty         IN  NUMBER
	  , p_sec_att_qty         IN  NUMBER := NULL
	  , p_trx_att_qty         IN  NUMBER
	  , p_lot_number      IN  VARCHAR2
	  , p_item_id         IN  NUMBER
	  , p_organization_id IN  NUMBER
	  , x_return_status   OUT NOCOPY VARCHAR2)  IS

  BEGIN
	x_return_status  := fnd_api.g_ret_sts_success;
Line: 14583

	mydebug('  Inside insert mtlt' );
Line: 14584

	INSERT INTO mtl_transaction_lots_temp
				(
				 transaction_temp_id
			   , last_update_date
			   , last_updated_by
			   , creation_date
			   , created_by
			   , transaction_quantity
			   , primary_quantity
			   , secondary_quantity
			   , lot_number
			   , lot_expiration_date
			   , serial_transaction_temp_id
			   , description
			   , vendor_name
			   , supplier_lot_number
			   , origination_date
			   , date_code
			   , grade_code
			   , change_date
			   , maturity_date
			   , retest_date
			   , age
			   , item_size
			   , color
			   , volume
			   , volume_uom
			   , place_of_origin
			   , best_by_date
			   , LENGTH
			   , length_uom
			   , recycled_content
			   , thickness
			   , thickness_uom
			   , width
			   , width_uom
			   , curl_wrinkle_fold
			   , lot_attribute_category
			   , c_attribute1
			   , c_attribute2
			   , c_attribute3
			   , c_attribute4
			   , c_attribute5
			   , c_attribute6
			   , c_attribute7
			   , c_attribute8
			   , c_attribute9
			   , c_attribute10
			   , c_attribute11
			   , c_attribute12
			   , c_attribute13
			   , c_attribute14
			   , c_attribute15
			   , c_attribute16
			   , c_attribute17
			   , c_attribute18
			   , c_attribute19
			   , c_attribute20
			   , d_attribute1
			   , d_attribute2
			   , d_attribute3
			   , d_attribute4
			   , d_attribute5
			   , d_attribute6
			   , d_attribute7
			   , d_attribute8
			   , d_attribute9
			   , d_attribute10
			   , n_attribute1
			   , n_attribute2
			   , n_attribute3
			   , n_attribute4
			   , n_attribute5
			   , n_attribute6
			   , n_attribute7
			   , n_attribute8
			   , n_attribute9
			   , n_attribute10
			   , vendor_id
			   , territory_code
				)
	  (SELECT p_new_temp_id
			, sysdate
			, -9999
			, sysdate
			, -9999
			, p_trx_att_qty
			, p_pri_att_qty
			, p_sec_att_qty
			, p_lot_number
			, mln.expiration_date
			, p_serial_temp_id
			, mln.description
			, mln.vendor_name
			, mln.supplier_lot_number
			, mln.origination_date
			, mln.date_code
			, mln.grade_code
			, mln.change_date
			, mln.maturity_date
			, mln.retest_date
			, mln.age
			, mln.item_size
			, mln.color
			, mln.volume
			, mln.volume_uom
			, mln.place_of_origin
			, mln.best_by_date
			, mln.LENGTH
			, mln.length_uom
			, mln.recycled_content
			, mln.thickness
			, mln.thickness_uom
			, mln.width
			, mln.width_uom
			, mln.curl_wrinkle_fold
			, mln.lot_attribute_category
			, mln.c_attribute1
			, mln.c_attribute2
			, mln.c_attribute3
			, mln.c_attribute4
			, mln.c_attribute5
			, mln.c_attribute6
			, mln.c_attribute7
			, mln.c_attribute8
			, mln.c_attribute9
			, mln.c_attribute10
			, mln.c_attribute11
			, mln.c_attribute12
			, mln.c_attribute13
			, mln.c_attribute14
			, mln.c_attribute15
			, mln.c_attribute16
			, mln.c_attribute17
			, mln.c_attribute18
			, mln.c_attribute19
			, mln.c_attribute20
			, mln.d_attribute1
			, mln.d_attribute2
			, mln.d_attribute3
			, mln.d_attribute4
			, mln.d_attribute5
			, mln.d_attribute6
			, mln.d_attribute7
			, mln.d_attribute8
			, mln.d_attribute9
			, mln.d_attribute10
			, mln.n_attribute1
			, mln.n_attribute2
			, mln.n_attribute3
			, mln.n_attribute4
			, mln.n_attribute5
			, mln.n_attribute6
			, mln.n_attribute7
			, mln.n_attribute8
			, mln.n_attribute9
			, mln.n_attribute10
			, mln.vendor_id
			, mln.territory_code
	   FROM    mtl_lot_numbers mln
	   WHERE   mln.lot_number = p_lot_number
	   AND    mln.inventory_item_id = p_item_id
	   AND    mln.organization_id = p_organization_id);
Line: 14751

	mydebug(' Insert mtlt returns exception' );
Line: 14862

	   SELECT NVL(SUM(primary_transaction_quantity),0)
		  , lot_number
			 FROM mtl_onhand_quantities_detail
			 WHERE organization_id = p_org_id
		 AND Nvl(containerized_flag, 2) = 1 -- different from loose_match
		 AND lpn_id = p_fromlpn_id
			 AND subinventory_code = p_confirmed_sub
			 AND locator_id = p_confirmed_loc_id
			 AND inventory_item_id = p_item_id
			 AND (revision = p_rev OR (revision IS NULL AND p_rev IS NULL))
			 AND lot_number NOT IN (
					   SELECT mtlt.lot_number
				   FROM mtl_transaction_lots_temp mtlt
				   WHERE mtlt.transaction_temp_id = p_temp_id
				   )
		AND lot_number IS NOT NULL
		GROUP BY lot_number
		ORDER BY lot_number;
Line: 14882

	   SELECT NVL(SUM(primary_transaction_quantity),0)
		  , lot_number
			 FROM mtl_onhand_quantities_detail
			 WHERE organization_id = p_org_id
		 AND Nvl(containerized_flag, 2) <> 1
			 AND subinventory_code = p_confirmed_sub
			 AND locator_id = p_confirmed_loc_id
			 AND inventory_item_id = p_item_id
			 AND (revision = p_rev OR (revision IS NULL AND p_rev IS NULL))
			 AND lot_number NOT IN (
					   SELECT mtlt.lot_number
				   FROM mtl_transaction_lots_temp mtlt
				   WHERE mtlt.transaction_temp_id = p_temp_id
				   )
		AND lot_number IS NOT NULL
		GROUP BY lot_number
		ORDER BY lot_number;
Line: 14903

	t_lpn_lot_qty_table.DELETE;
Line: 14905

	 SELECT primary_uom_code
		  , lot_control_code
		  , serial_number_control_code
	   INTO l_primary_uom
		  , l_lot_code
		  , l_serial_code
	   FROM mtl_system_items
	  WHERE organization_id = p_org_id
		AND inventory_item_id = p_item_id;
Line: 14915

	select value
	into l_value
	from v$nls_parameters
	where parameter = 'NLS_NUMERIC_CHARACTERS';
Line: 15134

			INSERT INTO wms_allocations_gtmp(lot_number, primary_quantity,
											 transaction_quantity)
				   values(t_lpn_lot_qty_table(l_table_count).lot_number,
						  t_lpn_lot_qty_table(l_table_count).pri_qty,
						  t_lpn_lot_qty_table(l_table_count).trx_qty);
Line: 15265

			SELECT mmtt.ITEM_PRIMARY_UOM_CODE, mmtt.TRANSACTION_UOM, mmtt.SECONDARY_UOM_CODE, mmtt.INVENTORY_ITEM_ID,
					DECODE(mmtt.fulfillment_base, NULL, 'P', mmtt.fulfillment_base), mmtt.organization_id
			INTO l_puom, l_tuom, l_suom, l_item_id, l_fulfillment_base, l_organization_id
			FROM mtl_material_transactions_temp mmtt
			WHERE transaction_temp_id = p_temp_id;
Line: 15367

		mydebug ('Inside proc_decrement_allocated_mtlts before update to MTLT l_prim_qty :' || l_prim_qty);
Line: 15369

		mydebug ('Inside proc_decrement_allocated_mtlts before update to MTLT l_sec_qty  :' || l_sec_qty);
Line: 15371

		mydebug ('Inside proc_decrement_allocated_mtlts before update to MTLT l_txn_qty  :' || l_txn_qty);
Line: 15373

	  UPDATE mtl_transaction_lots_temp
	  SET transaction_quantity = l_txn_qty,
	   primary_quantity = l_prim_qty,
	   secondary_quantity = l_sec_qty
	  WHERE transaction_temp_id = p_temp_id
	  AND lot_number = l_lot_number;
Line: 15380

		  DELETE FROM mtl_transaction_lots_temp
		  WHERE transaction_quantity = 0
		  AND transaction_temp_id = p_temp_id
		  AND lot_number = l_lot_number;
Line: 15452

PROCEDURE insert_serials_temp (
   p_transaction_temp_id   IN             NUMBER,
   p_lpn_id                IN             NUMBER,
   p_org_id                IN             NUMBER,
   p_item_id               IN             NUMBER,
   p_rev                   IN             VARCHAR2,
   p_confirmed_trx_qty     IN             NUMBER,
   x_return_status         OUT  NOCOPY    VARCHAR2,
   x_msg                   OUT  NOCOPY    VARCHAR2
)
IS
   CURSOR c_lots_in_lpn
   IS
	  SELECT mtlt.lot_number, 'Y' allocated_lot
		FROM wms_lpn_contents wlc, mtl_transaction_lots_temp mtlt
	   WHERE wlc.parent_lpn_id = p_lpn_id
		 AND wlc.organization_id = p_org_id
		 AND wlc.inventory_item_id = p_item_id
		 AND NVL (wlc.revision, '-999') = NVL (p_rev, '-999')
		 AND mtlt.transaction_temp_id = p_transaction_temp_id
		 AND mtlt.lot_number = wlc.lot_number
	  UNION ALL
	  SELECT lot_number, 'N' allocated_lot
		FROM wms_lpn_contents wlc
	   WHERE wlc.parent_lpn_id = p_lpn_id
		 AND wlc.organization_id = p_org_id
		 AND wlc.inventory_item_id = p_item_id
		 AND NVL (wlc.revision, '-999') = NVL (p_rev, '-999')
		 AND NOT EXISTS (
				SELECT 1
				  FROM mtl_transaction_lots_temp mtlt
				 WHERE mtlt.transaction_temp_id = p_transaction_temp_id
				   AND mtlt.lot_number = wlc.lot_number);
Line: 15488

	  SELECT serial_number
		FROM mtl_serial_numbers
	   WHERE lpn_id = v_lpn_id
		 AND lot_number = v_lot_number
		 AND inventory_item_id = p_item_id
		 AND NVL (revision, '-999') = NVL (p_rev, '-999')
		 AND current_organization_id = p_org_id
		 AND (group_mark_id IS NULL
		  OR group_mark_id = -1
		 ); --Added this Condition as while inserting serials, the same is not checked
Line: 15506

	  mydebug ('In insert_serials_temp');
Line: 15507

	  mydebug ('insert_serials_temp: p_transaction_temp_id : ' || p_transaction_temp_id);
Line: 15508

	  mydebug ('insert_serials_temp: p_lpn_id : ' || p_lpn_id);
Line: 15509

	  mydebug ('insert_serials_temp: p_org_id : ' || p_org_id);
Line: 15510

	  mydebug ('insert_serials_temp: p_item_id : ' || p_item_id);
Line: 15511

	  mydebug ('insert_serials_temp: p_rev : ' || p_rev);
Line: 15512

	/* Loop through all the Lots in the LPN and insert serials associated with the Lots.
	   For lots which are allocated, we pass the serial_transaction_temp_id as NULL and the api itself
	   generates one. In case we have an unallocated Lot in the LPN, the serial_transaction_temp_id
	   is passed as the transaction_temp_id of the task itself.
	*/
   FOR rec_lots_in_lpn IN c_lots_in_lpn
   LOOP
	  FOR rec_serials_in_lpn IN c_serials_in_lpn (p_lpn_id, rec_lots_in_lpn.lot_number)
	  LOOP
		 IF (rec_lots_in_lpn.allocated_lot = 'Y')
		 THEN
		 mydebug ('insert_serials_temp: Its an allocated Lot');
Line: 15526

		 mydebug ('insert_serials_temp: Its an unallocated Lot');
Line: 15530

			mydebug ('insert_serials_temp: Inside Loop');
Line: 15531

			mydebug ('insert_serials_temp: Lot Number : ' || rec_lots_in_lpn.lot_number);
Line: 15532

			mydebug ('insert_serials_temp: Serial Number : ' || rec_serials_in_lpn.serial_number);
Line: 15533

			mydebug ('insert_serials_temp: l_serial_temp_id : ' || l_serial_temp_id);
Line: 15534

			mydebug ('insert_serials_temp: p_rev : ' || p_rev);
Line: 15536

		 insert_serial (p_serial_transaction_temp_id      => l_serial_temp_id,
						p_organization_id                 => p_org_id,
						p_item_id                         => p_item_id,
						p_revision                        => p_rev,
						p_lot                             => rec_lots_in_lpn.lot_number,
						p_transaction_temp_id             => p_transaction_temp_id,
						p_created_by                      => fnd_global.user_id,
						p_from_serial                     => rec_serials_in_lpn.serial_number,
						p_to_serial                       => rec_serials_in_lpn.serial_number,
						p_status_id                       => NULL,
						x_return_status                   => l_ser_return_status,
						x_msg_data                        => l_ser_msg
					   );
Line: 15554

			x_msg := 'Error while calling insert_serial';
Line: 15556

			   mydebug ('insert_serials_temp: Error while calling insert_serial');
Line: 15557

			   mydebug ('insert_serials_temp: l_ser_return_status ' || l_ser_return_status);
Line: 15558

			   mydebug ('insert_serials_temp: l_ser_msg ' || l_ser_msg);
Line: 15570

		 mydebug ('insert_serials_temp: p_confirmed_trx_qty ' || p_confirmed_trx_qty);
Line: 15571

		 mydebug ('insert_serials_temp: l_serial_cnt ' || l_serial_cnt);
Line: 15575

END insert_serials_temp;
Line: 15593

   SELECT 1
	 INTO l_unalloc_lots
	 FROM wms_lpn_contents wlc
	WHERE wlc.parent_lpn_id = p_lpn_id -- add revision I think No need to add rev since x_match should take care.
	  AND wlc.inventory_item_id = p_item_id
	  AND NVL(wlc.revision,'-999') = NVL(p_rev,'-999')
	  AND wlc.organization_id = p_organization_id
	  AND NOT EXISTS (
			 SELECT 1
			   FROM mtl_transaction_lots_temp mtlt
			  WHERE mtlt.transaction_temp_id = p_transaction_temp_id
				AND mtlt.lot_number = wlc.lot_number);
Line: 15638

				   UPDATE  MTL_SERIAL_NUMBERS
				   SET     group_mark_id   = NULL
						 , last_updated_by = fnd_global.user_id
						 , last_update_date = SYSDATE
				   WHERE  (current_organization_id
						  ,inventory_item_id
						  ,serial_number)
					  IN  (SELECT  mmtt.organization_id
								  ,mmtt.inventory_item_id
								  ,msnt.fm_serial_number
							 FROM  mtl_transaction_lots_temp      mtlt
								  ,mtl_serial_numbers_temp        msnt
								  ,mtl_material_transactions_temp mmtt
							WHERE  mmtt.transaction_header_id      = p_transaction_header_id
							  AND  mmtt.transaction_temp_id        = mtlt.transaction_temp_id
							  AND  mtlt.serial_transaction_temp_id = msnt.transaction_temp_id
							  UNION --For lot substitution of lot and serial items when serial are confirmed we insert msnt with mmtt.transaction_temp_id
									--at that time their is no MTLT for substituted lot..
							  SELECT  mmtt.organization_id
								  ,mmtt.inventory_item_id
								  ,msnt.fm_serial_number
							 FROM  mtl_serial_numbers_temp        msnt
								  ,mtl_material_transactions_temp mmtt
							WHERE  mmtt.transaction_header_id      = p_transaction_header_id
							  AND  mmtt.transaction_temp_id        = msnt.transaction_temp_id
							  );
Line: 15664

  mydebug (p_api_name||' Updated '||SQL%ROWCOUNT||' rows in MSN');
Line: 15666

	DELETE FROM mtl_serial_numbers_temp
	 WHERE transaction_temp_id IN ((SELECT serial_transaction_temp_id
									  FROM mtl_transaction_lots_temp
									 WHERE transaction_temp_id IN (SELECT transaction_temp_id
																	 FROM mtl_material_transactions_temp
																	WHERE transaction_header_id = p_transaction_header_id))
								   UNION
								   (SELECT transaction_temp_id
									  FROM mtl_material_transactions_temp
									 WHERE transaction_header_id = p_transaction_header_id));
Line: 15677

  mydebug (p_api_name||' Deleted '||SQL%ROWCOUNT||' rows from MSNT');
Line: 15680

 DELETE FROM mtl_transaction_lots_temp
  WHERE transaction_temp_id IN (SELECT transaction_temp_id
								  FROM mtl_material_transactions_temp
								 WHERE transaction_header_id = p_transaction_header_id);
Line: 15701

SELECT  NVL(lot_divisible_flag, 'Y')
FROM mtl_system_items_b
WHERE organization_id = org_id
AND inventory_item_id = item_id;
Line: 15731

PROCEDURE Update_Tree_Flex_Lot (p_fromlpn_id            IN NUMBER,
								p_org_id                IN NUMBER,
								p_item_id               IN NUMBER,
								p_rev                   IN VARCHAR2,
								p_trx_qty               IN NUMBER,
								p_trx_uom               IN VARCHAR2,
								p_sec_qty               IN NUMBER,
								p_sec_uom               IN VARCHAR2,
								p_lot                   IN VARCHAR2,
								p_temp_id               IN NUMBER,
								p_transaction_type_id   IN NUMBER,
								p_user_id               IN NUMBER,
								p_transaction_action_id IN NUMBER ,
								p_confirmed_sub         IN VARCHAR2,
								p_confirmed_loc_id      IN NUMBER,
								p_full_lot_allocation   IN VARCHAR2,
								p_fulfillment_base      IN VARCHAR2,
								x_lpn_lot_vector        OUT NOCOPY VARCHAR2,
								x_lpn_lot_vector2       OUT NOCOPY VARCHAR2,
								x_lpn_lot_vector3       OUT NOCOPY VARCHAR2,
								x_lpn_lot_vector4       OUT NOCOPY VARCHAR2,
								x_return_status         OUT NOCOPY VARCHAR2)
IS

	l_proc_name              VARCHAR2(30) := 'Update_Tree_Flex_Lot' ;
Line: 15797

	t_lpn_lot_qty_table.DELETE;
Line: 15807

	 SELECT primary_uom_code
	   INTO l_primary_uom
	   FROM mtl_system_items
	  WHERE organization_id = p_org_id
		AND inventory_item_id = p_item_id;
Line: 15814

	   SELECT mmtt.subinventory_code
			 ,mmtt.locator_id
			 ,allocated_lpn_id
	  INTO l_mmtt_sub
		 , l_mmtt_loc
		 , l_allocated_lpn_id
	  FROM mtl_material_transactions_temp mmtt
	 WHERE mmtt.transaction_temp_id = p_temp_id;
Line: 15841

		  SELECT subinventory_code
		   , locator_id
		INTO l_lpn_sub
		   , l_lpn_loc
		FROM wms_license_plate_numbers wlpn
	   WHERE wlpn.organization_id = p_org_id
		 AND wlpn.lpn_id = p_fromlpn_id;
Line: 15850

	select value
	into l_value
	from v$nls_parameters
	where parameter = 'NLS_NUMERIC_CHARACTERS';
Line: 15866

			mydebug('In Update_Tree_Flex_Lot Fulfillment basis is S and transaction UOM is different than secondary UOM');
Line: 15870

			mydebug('In Update_Tree_Flex_Lot Fulfillment basis is S and transaction UOM is same than secondary UOM');
Line: 15895

			 mydebug('In Update_Tree_Flex_Lot Fulfillment basis is P and transaction UOM is different than Primary UOM');
Line: 15901

			mydebug('In Update_Tree_Flex_Lot Fulfillment basis is P and transaction UOM is same as Primary UOM');
Line: 15932

			inv_log_util.trace( 'Value of p_transaction_type_id          :  '  ||p_transaction_type_id,   'Inside Update_Tree_Flex_Lot  ',   9);
Line: 15933

			inv_log_util.trace( 'Value of l_transaction_action_id        :  '  ||l_transaction_action_id, 'Inside Update_Tree_Flex_Lot  ',   9);
Line: 15934

			inv_log_util.trace( 'Value of l_txn_source_type_id           :  '  ||l_txn_source_type_id,    'Inside Update_Tree_Flex_Lot  ',   9);
Line: 15957

			--from lpn is the same as allocated_lpn, we need to update qty tree as negative qty
			-- in order to get correct att.
			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => NULL
			, p_subinventory_code          => l_lpn_sub
			, p_locator_id                 => l_lpn_loc
			, p_primary_quantity           => -l_pr_qty
			, p_secondary_quantity         => -l_sec_qty
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			, p_lpn_id                     => p_fromlpn_id
			);
Line: 15995

				mydebug('update qty tree for FlexiLotAlloc lpn l_att:'  || l_att  || ' at Locator Level');
Line: 15996

				mydebug('update qty tree for FlexiLotAlloc lpn l_satt:' || l_satt || ' at Locator Level');
Line: 16000

				mydebug('calling update qty tree with lpn for FlexiLotAlloc failed ');
Line: 16010

			inv_quantity_tree_pub.update_quantities(
			  p_api_version_number         => 1.0
			, p_init_msg_lst               => fnd_api.g_false
			, x_return_status              => l_return_status
			, x_msg_count                  => l_msg_cnt
			, x_msg_data                   => l_msg_data
			, p_organization_id            => p_org_id
			, p_inventory_item_id          => p_item_id
			, p_tree_mode                  => inv_quantity_tree_pub.g_transaction_mode
			, p_is_revision_control        => b_is_revision_control
			, p_is_lot_control             => TRUE
			, p_is_serial_control          => b_is_serial_control
			, p_revision                   => NVL(p_rev, NULL)
			, p_lot_number                 => NULL
			, p_subinventory_code          => l_mmtt_sub
			, p_locator_id                 => l_mmtt_loc
			, p_primary_quantity           => -l_pr_qty
			, p_secondary_quantity         => -l_sec_qty
			, p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
			, x_qoh                        => l_qoh
			, x_rqoh                       => l_rqoh
			, x_qr                         => l_qr
			, x_qs                         => l_qs
			, x_att                        => l_att
			, x_atr                        => l_atr
			, x_sqoh                       => l_sqoh
			, x_srqoh                      => l_srqoh
			, x_sqr                        => l_sqr
			, x_sqs                        => l_sqs
			, x_satt                       => l_satt
			, x_satr                       => l_satr
			);
Line: 16045

				mydebug('after update without lpn for FlexiLotAlloc l_att:'  || l_att  || ' at Locator Level');
Line: 16046

				mydebug('after update without lpn for FlexiLotAlloc l_satt:' || l_satt || ' at Locator Level');
Line: 16050

				mydebug('calling update qty tree for FlexiLotAlloc without lpn failed ');
Line: 16217

END Update_Tree_Flex_Lot;