DBA Data[Home] [Help]

PACKAGE BODY: APPS.WSH_DETAILS_VALIDATIONS

Source


1 PACKAGE BODY WSH_DETAILS_VALIDATIONS as
2 /* $Header: WSHDDVLB.pls 120.48.12010000.3 2008/09/08 12:27:31 anvarshn ship $ */
3 
4 
5 --
6 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_DETAILS_VALIDATIONS';
7 -- Global Variable added for bug 4399278, 4418754
8 G_SUBINVENTORY      WSH_DELIVERY_DETAILS.Subinventory%TYPE;
9 --
10 
11 --public api changes
12 PROCEDURE   user_non_updatable_columns
13      (p_user_in_rec     IN wsh_glbl_var_strct_grp.delivery_details_rec_type,
14       p_out_rec         IN wsh_glbl_var_strct_grp.delivery_details_rec_type,
15       p_in_rec          IN wsh_glbl_var_strct_grp.detailInRecType,
16       x_return_status   OUT NOCOPY    VARCHAR2);
17 
18 
19 
20 
21 g_bad_header_ids wsh_util_core.id_tab_type;
22 g_good_header_ids wsh_util_core.id_tab_type;
23 
24 -- 2467416
25 -- Description:
26 --		PL/SQL table g_passed_crd_Tab: caches the line_ids that passed Credit Check
27 --		PL/SQL table g_failed_crd_Tab: caches the line_ids that failed Credit Check
28 --			   Both these table above helps in maintaining the latest record in the table
29 --			   and deleting the oldest record (Caching).
30 -- 3481194/3492870 modified logic to hash index on g_passed_crd_tab and g_failed_crd_tab
31 -- to avoid linear scans on pl/sql lists by calling function get_table_index..
32 
33 
34 g_passed_crd_Tab wsh_util_core.id_tab_type;
35 g_failed_crd_Tab wsh_util_core.id_tab_type;
36 
37 PROCEDURE Insert_PR_Header_Holds (
38 p_header_id   IN NUMBER,
39 p_status      IN VARCHAR2)
40 IS
41 
42 PRAGMA AUTONOMOUS_TRANSACTION;
43 
44 BEGIN
45 
46   INSERT INTO WSH_PR_HEADER_HOLDS (
47                                      batch_id,
48                                      header_id,
49                                      status )
50                            VALUES (
51                                      WSH_PICK_LIST.G_BATCH_ID,
52                                      p_header_id,
53                                      p_status );
54 
55   COMMIT;
56 
57 EXCEPTION
58   WHEN OTHERS THEN
59     ROLLBACK;
60 
61 END Insert_PR_Header_Holds;
62 -----------------------------------------------------------------------------
63 --
64 -- FUNCTION:		  get_table_index
65 -- Parameters:	          p_entity_id     entity_id to map to index
66 --                        p_alt_index     optional alternate index to reuse
67 --                        x_table         list of ids to map index
68 -- Returns:		number
69 -- Description:         Created to fix performance bug 3481194
70 -- 	                It returns the hashed index to map p_entity_id,
71 --                      so that x_table(index) = p_entity or
72 --                      x_table(index) does not exist (without hash collusion):
73 --                      index is always given; the caller should
74 --                      validate x_table.exists(index) is true or false.
75 --                      The caller should add index to the table if appropriate.
76 --
77 -- NOTE: For performance reason, there is no debug logic in this API.
78 -----------------------------------------------------------------------------
79 function get_table_index(p_entity_id  IN            NUMBER,
80                          p_alt_index  IN            NUMBER   DEFAULT NULL,
81                          x_table      IN OUT NOCOPY wsh_util_core.id_tab_type)
82 RETURN NUMBER
83 IS
84   c_hash_base CONSTANT NUMBER := 1;
85   c_hash_size CONSTANT NUMBER := power(2, 25);
86 
87   l_hash_string      VARCHAR2(1000) := NULL;
88   l_index            NUMBER;
89   l_hash_exists      BOOLEAN := FALSE;
90 
91 BEGIN
92 
93   IF p_alt_index IS NOT NULL THEN
94     -- check if we can reuse the hashed index.
95     IF x_table.EXISTS(p_alt_index) THEN
96       IF x_table(p_alt_index) = p_entity_id THEN
97         l_hash_exists := TRUE;
98         l_index := p_alt_index;
99       END IF;
100     END IF;
101   END IF;
102 
103   IF NOT l_hash_exists THEN
104     -- need to hash this index
105     l_hash_string := to_char(p_entity_id);
106 
107     l_index := dbms_utility.get_hash_value (
108                                           name => l_hash_string,
109                                           base => c_hash_base,
110                                      hash_size => c_hash_size );
111 
112     WHILE NOT l_hash_exists LOOP
113      IF x_table.EXISTS(l_index) THEN
114        IF (x_table(l_index) = p_entity_id) THEN
115          EXIT;
116        ELSE
117          -- Index exists but p_entity_id does not match this table element.
118          -- Bump l_index till p_entity_id matches
119          --      or table element does not exist
120          l_index := l_index + 1;
121        END IF;
122      ELSE
123        -- Table element does not exist, so the caller can use this new index.
124        l_hash_exists := TRUE;
125      END IF;
126    END LOOP;
127   END IF;
128 
129   RETURN l_index;
130 
131 END get_table_index;
132 
133 
134 -----------------------------------------------------------------------------
135 --
136 -- FUNCTION:		  Trx_ID
137 -- Parameters:	  p_mode, p_source_line_id, p_source_document_type_id
138 -- Returns:		number
139 -- Trx_ID:		It reurns the trx_id depending on the given mode, source
140 --				line id and source_document_type_id
141 -----------------------------------------------------------------------------
142 
143 FUNCTION trx_id(
144 	p_mode varchar2,
145 	p_source_line_id number,
146 	p_source_document_type_id number) return number is
147 l_dest_type varchar2(30);
148 l_from_org number;
149 l_to_org number;
150 --
151 l_debug_on BOOLEAN;
152 --
153 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'TRX_ID';
154 --
155 begin
156 	--
157 	-- Debug Statements
158 	--
159 	--
160 	l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
161 	--
162 	IF l_debug_on IS NULL
163 	THEN
164 		l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
165 	END IF;
166 	--
167 	IF l_debug_on THEN
168 		WSH_DEBUG_SV.push(l_module_name);
169 		--
170 		WSH_DEBUG_SV.log(l_module_name,'P_MODE',P_MODE);
171 		WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
172 		WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_DOCUMENT_TYPE_ID',P_SOURCE_DOCUMENT_TYPE_ID);
173 	END IF;
174 	--
175 	if (p_source_document_type_id <> 10) then /* regular order */
176 		if (p_mode = 'TRX_ACTION_ID') then
177 			--
178 			-- Debug Statements
179 			--
180 			IF l_debug_on THEN
181 				WSH_DEBUG_SV.pop(l_module_name);
182 			END IF;
183 			--
184 			return(1); /* 1 = Issue */
185 		elsif (p_mode = 'TRX_TYPE_ID') then
186 			--
187 			-- Debug Statements
188 			--
189 			IF l_debug_on THEN
190 				WSH_DEBUG_SV.pop(l_module_name);
191 			END IF;
192 			--
193 			return(33); /* 33 = Sales Order Issue */
194 		end if;
195 
196 	elsif (p_source_document_type_id = 10) then
197 		SELECT	 nvl(destination_type_code,'@'),source_organization_id,
198 				 destination_organization_id
199 		INTO	 l_Dest_Type,l_From_Org,l_To_Org
200 		FROM	 po_requisition_lines_all pl,
201 				oe_order_lines_all ol
202 		WHERE	 pl.line_num = to_number(ol.orig_sys_line_ref)
203 		AND		pl.requisition_header_id = ol.source_document_id
204 		AND		pl.requisition_line_id = ol.source_document_line_id
205 		AND		 ol.line_id = p_source_line_id;
206 		If (p_Mode = 'TRX_TYPE_ID') then
207 			 If (l_Dest_Type = 'EXPENSE') then
208 				--
209 				-- Debug Statements
210 				--
211 				IF l_debug_on THEN
212 					WSH_DEBUG_SV.pop(l_module_name);
213 				END IF;
214 				--
215 				Return(34); /* 34 = Stores Issue */
216 			 Elsif (l_From_Org = l_To_Org) then
217 				--
218 				-- Debug Statements
219 				--
220 				IF l_debug_on THEN
221 					WSH_DEBUG_SV.pop(l_module_name);
222 				END IF;
223 				--
224 				Return(50); /* 50 = */
225 			 Elsif (l_From_Org <> l_To_Org) then
226 				--
227 				-- Debug Statements
228 				--
229 				IF l_debug_on THEN
230 					WSH_DEBUG_SV.pop(l_module_name);
231 				END IF;
232 				--
233 				Return(62); /* 62 = Transit Shipment */
234 			 End If;
235 		Elsif (p_Mode = 'TRX_ACTION_ID') then
236 			 If (l_Dest_Type = 'EXPENSE') then
237 				--
238 				-- Debug Statements
239 				--
240 				IF l_debug_on THEN
241 					WSH_DEBUG_SV.pop(l_module_name);
242 				END IF;
243 				--
244 				Return(1); /* 1 = Issue */
245 			 Elsif (l_From_Org = l_To_Org) then
246 				--
247 				-- Debug Statements
248 				--
249 				IF l_debug_on THEN
250 					WSH_DEBUG_SV.pop(l_module_name);
251 				END IF;
252 				--
253 				Return(2); /* 2 = Subinv transfer*/
254 			 Elsif (l_From_Org <> l_To_Org) then
255 				--
256 				-- Debug Statements
257 				--
258 				IF l_debug_on THEN
259 					WSH_DEBUG_SV.pop(l_module_name);
260 				END IF;
261 				--
262 				Return(21); /* 62 = Interorg Transfer */
263 			 End If;
264 		  End If;
265 	end if;
266 	EXCEPTION
267 		WHEN NO_DATA_FOUND THEN
268 		  -- Debug Statements
269 		  --
270 		  IF l_debug_on THEN
271 			  WSH_DEBUG_SV.logmsg(l_module_name,'NO_DATA_FOUND exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
272 			  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:NO_DATA_FOUND');
273 		  END IF;
274 		  --
275 		  Return(0);
276 		WHEN OTHERS THEN
277 		   --
278 		   -- Debug Statements
279 		   --
280 		   IF l_debug_on THEN
281 			   WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
282 			   WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
283 		   END IF;
284 		   --
285 		   Return(0);
286 		END;
287 
288 --
289 --  Function:	serial_num_ctl_req
290 --  Parameters:  p_inventory_item_id
291 --			   p_org_id
292 --  Description: This function returns a boolean value to
293 --			   indicate if the inventory item in that org is
294 --			   requires a serial number or not
295 --
296 
297 
298 FUNCTION serial_num_ctl_req(p_inventory_item_id number, p_org_id number)
299 RETURN BOOLEAN IS
300 serial_num_ctl_code number;
301 cursor c_serial_ctl_info is
302 	select  serial_number_control_code
303 	   from	mtl_system_items
304 	   where   inventory_item_id = p_inventory_item_id
305 	and	 organization_id = p_org_id;
306 l_serial_ctl_info c_serial_ctl_info%ROWTYPE;
307 --
308 l_debug_on BOOLEAN;
309 --
310 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'SERIAL_NUM_CTL_REQ';
311 --
312 begin
313 		--
314 		-- Debug Statements
315 		--
316 		--
317 		l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
318 		--
319 		IF l_debug_on IS NULL
320 		THEN
321 			l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
322 		END IF;
323 		--
324 		IF l_debug_on THEN
325 			WSH_DEBUG_SV.push(l_module_name);
326 			--
327 			WSH_DEBUG_SV.log(l_module_name,'P_INVENTORY_ITEM_ID',P_INVENTORY_ITEM_ID);
328 			WSH_DEBUG_SV.log(l_module_name,'P_ORG_ID',P_ORG_ID);
329 		END IF;
330 		--
331 		serial_num_ctl_code := l_serial_ctl_info.serial_number_control_code;
332 		IF ( serial_num_ctl_code = 2 OR serial_num_ctl_code = 5 OR
333 			serial_num_ctl_code = 6) THEN
334 		 -- 2 : predefined serial numbers
335 		 -- 5 : dynamic entry at inventory receipt
336 		 -- 6 : dynamic entry at sales order issue
337 			   --
338 			   -- Debug Statements
339 			   --
340 			   IF l_debug_on THEN
341 				   WSH_DEBUG_SV.pop(l_module_name);
342 			   END IF;
343 			   --
344 			   RETURN TRUE;
345 		ELSE -- serial_num_ctl_code = 1
346 			-- No serial number control
347 			--
348 			-- Debug Statements
349 			--
350 			IF l_debug_on THEN
351 				WSH_DEBUG_SV.pop(l_module_name);
352 			END IF;
353 			--
354 			RETURN FALSE;
355 																		END IF;
356 
357 end serial_num_ctl_req;
358 
359 
360 -- 2467416
361 --   Purges the bad/good Header id Table followed by
362 --	passed/failed line_id tables
363 PROCEDURE purge_crd_chk_tab IS
364 --
365 l_debug_on BOOLEAN;
366 --
367 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PURGE_CRD_CHK_TAB';
368 --
369 begin
370 
371 	  --
372 	  -- Debug Statements
373 	  --
374 	  --
375 	  l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
376 	  --
377 	  IF l_debug_on IS NULL
378 	  THEN
379 		  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
380 	  END IF;
381 	  --
382 	  IF l_debug_on THEN
383 		  WSH_DEBUG_SV.push(l_module_name);
384 	  END IF;
385 	  --
386 	  g_bad_header_ids.delete;
387 	  g_good_header_ids.delete;
388 
389 	  g_passed_crd_Tab.delete;
390 	  g_failed_crd_Tab.delete;
391 
392 	 --
393 	 -- Debug Statements
394 	 --
395 	 IF l_debug_on THEN
396 		 WSH_DEBUG_SV.pop(l_module_name);
397 	 END IF;
398 	 --
399 end purge_crd_chk_tab;
400 
401 --
402 --  Procedure:   Check_Shipped_Quantity
403 --  Parameters:  p_ship_above_tolerance number,
404 --			   p_requested_quantity number,
405 --			   p_picked_quantity	number,
406 --			   p_shipped_quantity number,
407 --			   p_cycle_count_quantity number,
408 --			   x_return_status	   OUT VARCHAR2
409 --  Description: This procedure validates the entered shipped quantity
410 
411 
412 PROCEDURE check_shipped_quantity(
413 		p_ship_above_tolerance IN  number,
414 		p_requested_quantity   IN  number,
415 		p_picked_quantity	  IN  NUMBER,
416 		p_shipped_quantity	 IN  number,
417 		p_cycle_count_quantity IN  number,
418 		x_return_status		OUT NOCOPY  VARCHAR2) IS
419 l_attempt_over_percent number;
420 --
421 l_debug_on BOOLEAN;
422 --
423 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_SHIPPED_QUANTITY';
424 --
425 begin
426 
427   --
428   -- Debug Statements
429   --
430   --
431   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
432   --
433   IF l_debug_on IS NULL
434   THEN
435 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
436   END IF;
437   --
438   IF l_debug_on THEN
439 	  WSH_DEBUG_SV.push(l_module_name);
440 	  --
441 	  WSH_DEBUG_SV.log(l_module_name,'P_SHIP_ABOVE_TOLERANCE',P_SHIP_ABOVE_TOLERANCE);
442 	  WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY',P_REQUESTED_QUANTITY);
443 	  WSH_DEBUG_SV.log(l_module_name,'P_PICKED_QUANTITY',P_PICKED_QUANTITY);
444 	  WSH_DEBUG_SV.log(l_module_name,'P_SHIPPED_QUANTITY',P_SHIPPED_QUANTITY);
445 	  WSH_DEBUG_SV.log(l_module_name,'P_CYCLE_COUNT_QUANTITY',P_CYCLE_COUNT_QUANTITY);
446   END IF;
447   --
448   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
449 
450   IF p_picked_quantity > p_requested_quantity THEN
451 	-- overpick scenario
452 	IF (	p_cycle_count_quantity > 0
453 		AND p_shipped_quantity > p_requested_quantity - p_cycle_count_quantity) THEN
454 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
455 	  fnd_message.set_name('WSH', 'WSH_OVERPICK_SH_QTY_EXCEED');
456 	  fnd_message.set_token('MAX_QTY', (p_requested_quantity - p_cycle_count_quantity));
457 	  wsh_util_core.add_message(x_return_status);
458 	ELSIF (p_shipped_quantity > p_picked_quantity) THEN -- Bug 2111939: Removed the check on tolerance here.
459 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
460 	  fnd_message.set_name('WSH', 'WSH_SH_QTY_ABOVE_PICKED');
461 	  wsh_util_core.add_message(x_return_status);
462 	END IF;
463 
464   ELSE
465 		-- normal scenario
466 	-- for bug 1305066.   When requested_quantity = 0, ie. cancelled line,
467 	-- return false
468 	IF (p_requested_quantity = 0) THEN
469 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
470 		fnd_message.set_name('WSH', 'WSH_UI_SHIP_QTY_ABOVE_TOL');
471 		wsh_util_core.add_message(x_return_status);
472 	END IF;
473    END IF;
474 
475 --
476 -- Debug Statements
477 --
478 IF l_debug_on THEN
479 	WSH_DEBUG_SV.pop(l_module_name);
480 END IF;
481 --
482 	exception
483 		when others then
484 			x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
485 			wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.Check_Shipped_Quantity');
486 			--
487 			-- Debug Statements
488 			--
489 			IF l_debug_on THEN
490 				WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
491 				WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
492 			END IF;
493 			--
494 END check_shipped_quantity;
495 
496 
497 
498 --
499 --  Procedure:   Check_Cycle_Count_Quantity
500 --  Parameters:  p_ship_above_tolerance number,
501 --			   p_requested_quantity number,
502 --			   p_picked_quantity	number,
503 --			   p_shipped_quantity number,
504 --			   p_cycle_count_quantity number,
505 --			   x_return_status	   OUT VARCHAR2
506 --  Description: This procedure validates the entered cycle count quantity
507 
508 PROCEDURE check_cycle_count_quantity(
509 		p_ship_above_tolerance IN  number,
510 		p_requested_quantity   IN  number,
511 		p_picked_quantity	  IN  NUMBER,
512 		p_shipped_quantity	 IN  number,
513 		p_cycle_count_quantity IN  number,
514 		x_return_status		OUT NOCOPY  VARCHAR2) IS
515    max_qty_to_bo NUMBER;
516    --
517 l_debug_on BOOLEAN;
518    --
519    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_CYCLE_COUNT_QUANTITY';
520    --
521 BEGIN
522 
523   --
524   -- Debug Statements
525   --
526   --
527   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
528   --
529   IF l_debug_on IS NULL
530   THEN
531 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
532   END IF;
533   --
534   IF l_debug_on THEN
535 	  WSH_DEBUG_SV.push(l_module_name);
536 	  --
537 	  WSH_DEBUG_SV.log(l_module_name,'P_SHIP_ABOVE_TOLERANCE',P_SHIP_ABOVE_TOLERANCE);
538 	  WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY',P_REQUESTED_QUANTITY);
539 	  WSH_DEBUG_SV.log(l_module_name,'P_PICKED_QUANTITY',P_PICKED_QUANTITY);
540 	  WSH_DEBUG_SV.log(l_module_name,'P_SHIPPED_QUANTITY',P_SHIPPED_QUANTITY);
541 	  WSH_DEBUG_SV.log(l_module_name,'P_CYCLE_COUNT_QUANTITY',P_CYCLE_COUNT_QUANTITY);
542   END IF;
543   --
544   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
545 
546   max_qty_to_bo := p_requested_quantity - NVL(p_shipped_quantity, 0);
547   IF max_qty_to_bo < 0 THEN
548 	max_qty_to_bo := 0;
549   END IF;
550 
551   IF p_cycle_count_quantity > max_qty_to_bo THEN
552 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
553 	fnd_message.set_name('WSH', 'WSH_UI_CYCLE_QTY_ABOVE_TOL');
554 	wsh_util_core.add_message(x_return_status);
555   END IF;
556 
557 --
558 -- Debug Statements
559 --
560 IF l_debug_on THEN
561 	WSH_DEBUG_SV.pop(l_module_name);
562 END IF;
563 --
564   EXCEPTION
565 	WHEN OTHERS THEN
566 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
567 	  wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.Check_Cycle_Count_Quantity');
568 	  --
569 	  -- Debug Statements
570 	  --
571 	  IF l_debug_on THEN
572 		  WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
573 		  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
574 	  END IF;
575 	  --
576 END check_cycle_count_quantity;
577 
578 
579 
580 
581 /*	Validates and returns the quantity in this manner (the caller does not need
582 	to adjust the result):
583 	This routine checks to make sure that the input quantity precision does
584 	not exceed the decimal precision. Max Precision is: 10 digits before the
585 	decimall point and 9 digits after the decimal point.
586 	The routine also makes sure that if the item is serial number controlled,
587 	the the quantity in primary UOM is an integer number.
588 	The routine also makes sure that if the item's indivisible_flag is set
589 	to yes, then the item quantity is an integer in the primary UOM
590 	The routine also checks if the profile, INV:DETECT TRUNCATION, is set
591 	to yes, the item quantity in primary UOM also obeys max precision and that
592 	it is not zero.
593 	The procedure retruns a correct output quantity in the transaction UOM,
594 	returns the primary quantity and returns a status of success, failure, or
595 	warning.
596 
597         The parameter p_max_decimal_digits has been added to determine the max precision
598         that should be applied to the quantity after the decimal point. */
599 PROCEDURE check_decimal_quantity(
600 	p_item_id number,
601 	p_organization_id number,
602 	p_input_quantity number,
603 	p_uom_code varchar2,
604 	x_output_quantity out NOCOPY  number,
605 	x_return_status  out NOCOPY  varchar2,
606 	p_top_model_line_id number,
607         p_max_decimal_digits IN NUMBER DEFAULT NULL) IS -- RV DEC_QTY
608 
609 l_primary_quantity number;
610 l_return_status varchar2(30);
611 
612 others  EXCEPTION;
613 --
614 -- RV DEC_QTY
615 l_max_decimal_digits NUMBER := p_max_decimal_digits ;
616 l_max_real_digits    CONSTANT        NUMBER := WSH_UTIL_CORE.C_MAX_REAL_DIGITS;
617 -- HW OPMCONV - Noneed for OPM variables
618 
619 -- RV DEC_QTY
620 --
621 l_debug_on BOOLEAN;
622 --
623 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_DECIMAL_QUANTITY';
624 --
625 begin
626   --
627   -- Debug Statements
628   --
629   --
630   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
631   --
632   IF l_debug_on IS NULL
633   THEN
634     l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
635   END IF;
636   --
637   IF l_debug_on THEN
638     WSH_DEBUG_SV.push(l_module_name);
639     --
640     WSH_DEBUG_SV.log(l_module_name,'P_ITEM_ID',P_ITEM_ID);
641     WSH_DEBUG_SV.log(l_module_name,'P_ORGANIZATION_ID',P_ORGANIZATION_ID);
642     WSH_DEBUG_SV.log(l_module_name,'P_INPUT_QUANTITY',P_INPUT_QUANTITY);
643     WSH_DEBUG_SV.log(l_module_name,'P_UOM_CODE',P_UOM_CODE);
644     WSH_DEBUG_SV.log(l_module_name,'P_TOP_MODEL_LINE_ID',P_TOP_MODEL_LINE_ID);
645   END IF;
646   --
647   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
648   /* Bug 2177410, skip validate quantity to avoid error for non-item delivery details */
649 
650   -- BUG 3376504
651   --
652   -- RV DEC_QTY
653 -- HW OPMCONV - No need to check for process_org
654 
655   IF (l_max_decimal_digits IS NULL) THEN
656   --{
657 -- HW OPMCONV - Re-arranged code to avoid branching
658 
659       l_max_decimal_digits := WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV;
660 
661       --}
662   END IF;
663   --
664   -- RV DEC_QTY
665   -- BUG 3376504
666   if p_item_id is not NULL then  -- {
667     if ( p_top_model_line_id is not null and p_input_quantity <> trunc ( p_input_quantity ) ) then  --{
668       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
669         fnd_message.set_name('WSH', 'WSH_CONFIG_NO_DECIMALS');
670         wsh_util_core.add_message(x_return_status);
671     else
672       --
673       -- Debug Statements
674       --
675       IF l_debug_on THEN
676         WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_DECIMALS_PUB.VALIDATE_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
677       END IF;
678       --
679       inv_decimals_pub.validate_quantity(
680         p_item_id,
681         p_organization_id,
682         p_input_quantity,
683         p_uom_code,
684         x_output_quantity,
685         l_primary_quantity,
686         x_return_status);
687 
688       -- RV DEC_QTY
689       IF l_debug_on THEN
690         WSH_DEBUG_SV.log(l_module_name,'x_return_status',x_return_status);
691       END IF;
692 -- HW OPMCONV - No need to fork the code
693 
694 
695       --{
696         -- Using the same message as inventory because this is the message set
697         -- by INV when the number of decimal digits entered by user are greater than 9.
698         -- This condition is for taking care of setting a message when the number
699         -- of decimals are between 5 and 9.
700         -- This should not cause any duplicate messages even when INV starts rounding
701         -- off to 5 digits of decimal.
702 -- HW OPMCOMV - Changed the precision from OPM to INV which is 5
703         IF (p_input_quantity = round(p_input_quantity,WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV)
704         AND x_output_quantity <> round(x_output_quantity,l_max_decimal_digits))
705         THEN
706         --{
707           fnd_message.set_name('INV', 'MAX_DECIMAL_LENGTH');
708           x_return_status := wsh_util_core.g_ret_sts_warning;
709           WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
710         --}
711         END IF;
712         x_output_quantity := round(x_output_quantity,l_max_decimal_digits);
713       --}
714 
715       -- RV DEC_QTY
716       --
717      end if; --}
718 
719   else --} {
720 
721     if ( p_input_quantity <> ROUND(p_input_quantity, l_max_decimal_digits)) then
722       IF l_debug_on THEN
723          WSH_DEBUG_SV.logmsg(l_module_name,'decimal digits exceed ');
724       END IF;
725       x_output_quantity := ROUND(p_input_quantity, l_max_decimal_digits);
726     else
727       if (x_output_quantity IS NULL) then
728         x_output_quantity := p_input_quantity;
729       end if;
730     end if;
731 
732 
733     if ( trunc(abs(p_input_quantity)) > (POWER(10,l_max_real_digits) - 1) ) then
734       IF l_debug_on THEN
735          WSH_DEBUG_SV.logmsg(l_module_name,'real part of number fail');
736       END IF;
737 
738       raise others;
739     end if;
740 
741    end if; --}
742   --
743   -- Debug Statements
744   --
745   IF l_debug_on THEN
746     WSH_DEBUG_SV.log(l_module_name,'x_output_quantity',x_output_quantity);
747     WSH_DEBUG_SV.pop(l_module_name);
748   END IF;
749   --
750 exception
751   when others then
752       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
753       wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.Check_Decimal_Quantity');
754       --
755       -- Debug Statements
756       --
757       IF l_debug_on THEN
758         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
759         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
760       END IF;
761       --
762 end check_decimal_quantity;
763 
764 
765 PROCEDURE check_unassign_from_delivery(
766 	p_detail_rows   IN  wsh_util_core.id_tab_type,
767 	x_return_status OUT NOCOPY  VARCHAR2) IS
768 
769 cursor check_unassign (detail_id IN NUMBER) is
770 select da.parent_delivery_detail_id , da.delivery_id  ,
771 	   dd.container_name  , dd.container_flag
772 from wsh_delivery_assignments da,
773 	 wsh_delivery_Details dd
774 where da.delivery_detail_id = detail_id
775 and   nvl(da.type,'S') in ('S', 'C')
776 and   da.parent_Delivery_Detail_id = dd.delivery_Detail_id (+);
777 
778 l_parent_delivery_detail_id  NUMBER ;
779 l_delivery_id				NUMBER ;
780 l_container_name			 VARCHAR2(30) ;
781 l_container_flag			 VARCHAR2(1) ;
782 
783 others	   EXCEPTION;
784 
785 --
786 l_debug_on BOOLEAN;
787 --
788 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_UNASSIGN_FROM_DELIVERY';
789 --
790 BEGIN
791 
792    --
793    -- Debug Statements
794    --
795    --
796    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
797    --
798    IF l_debug_on IS NULL
799    THEN
800 	   l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
801    END IF;
802    --
803    IF l_debug_on THEN
804 	   WSH_DEBUG_SV.push(l_module_name);
805    END IF;
806    --
807    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
808 
809    IF (p_detail_rows.count = 0) THEN
810 	 raise others;
811    END IF;
812 
813    FOR i IN 1..p_detail_rows.count LOOP
814 
815 	 OPEN check_unassign (p_detail_rows(i));
816 
817 	 FETCH check_unassign INTO l_parent_delivery_detail_id , l_delivery_id ,
818 				   l_container_name , l_container_flag ;
819 
820 	 IF check_unassign%NOTFOUND THEN
821 
822 	   raise others ;
823 	   CLOSE check_unassign;
824 	 END IF ;
825 
826 	 IF l_parent_delivery_Detail_id IS NOT NULL THEN
827 	   if ( l_container_flag IN ('Y', 'C' )) then
828 		   FND_MESSAGE.SET_NAME('WSH','WSH_PK_DET_UNASSIGN_DEL');
829 		   x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
830 		   wsh_util_core.add_message(x_return_status);
831 
832 		   --
833 		   -- Debug Statements
834 		   --
835 		   IF l_debug_on THEN
836 			   WSH_DEBUG_SV.pop(l_module_name);
837 		   END IF;
838 		   --
839 		   RETURN;
840 	   else
841 	   -- in the unlikely event that a delivery_detail's parent is
842 	   -- NOT a container.
843 	   raise others ;
844 	   end if ;
845 
846 	 END IF ;
847 
848 	 CLOSE check_unassign;
849 
850    END LOOP;
851 
852 --
853 -- Debug Statements
854 --
855 IF l_debug_on THEN
856 	WSH_DEBUG_SV.pop(l_module_name);
857 END IF;
858 --
859    EXCEPTION
860 	  WHEN others THEN
861 			IF check_unassign%ISOPEN THEN
862 			  CLOSE check_unassign;
863 			END IF;
864 		wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.CHECK_UNASSIGN_FROM_DELIVERY');
865 		x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
866 
867 --
868 -- Debug Statements
869 --
870 IF l_debug_on THEN
871 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
872 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
873 END IF;
874 --
875 END check_unassign_from_delivery ;
876 
877 
878 PROCEDURE check_assign_del_multi(
879 	p_detail_rows   IN  wsh_util_core.id_tab_type,
880 	x_del_params	OUT NOCOPY  wsh_delivery_autocreate.grp_attr_rec_type,
881 	x_return_status OUT NOCOPY  VARCHAR2) IS
882 
883 l_del_rows   wsh_util_core.id_tab_type;
884 l_group_rows wsh_util_core.id_tab_type;
885 
886 l_detail_org_id NUMBER;
887 l_delivery_id   NUMBER;
888 
889 cursor check_assign (detail_id IN NUMBER) is
890 select delivery_id
891 from wsh_delivery_assignments_v
892 where delivery_detail_id = detail_id
893 and delivery_id IS NOT NULL;
894 
895 l_attr_tab  wsh_delivery_autocreate.grp_attr_tab_type;
896 l_group_tab  wsh_delivery_autocreate.grp_attr_tab_type;
897 l_action_rec wsh_delivery_autocreate.action_rec_type;
898 l_target_rec wsh_delivery_autocreate.grp_attr_rec_type;
899 l_matched_entities wsh_util_core.id_tab_type;
900 l_out_rec wsh_delivery_autocreate.out_rec_type;
901 l_generic_flag varchar2(1);
902 
903 
904 
905 others	   EXCEPTION;
906 assign_error EXCEPTION;
907 
908 --
909 l_debug_on BOOLEAN;
910 --
911 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_ASSIGN_DEL_MULTI';
912 --
913 BEGIN
914 
915    --
916    -- Debug Statements
917    --
918    --
919    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
920    --
921    IF l_debug_on IS NULL
922    THEN
923 	   l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
924    END IF;
925    --
926    IF l_debug_on THEN
927 	   WSH_DEBUG_SV.push(l_module_name);
928    END IF;
929    --
930    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
931 
932    IF (p_detail_rows.count = 0) THEN
933 	 raise others;
934    END IF;
935 
936    FOR i IN 1..p_detail_rows.count LOOP
937 
938 	 OPEN check_assign (p_detail_rows(i));
939 
940 	 FETCH check_assign INTO l_delivery_id;
941 
942 	 IF check_assign%FOUND THEN
943 
944 	   CLOSE check_assign;
945 	   FND_MESSAGE.SET_NAME('WSH','WSH_DET_ASSIGNED_DEL');
946 	   FND_MESSAGE.SET_TOKEN('DET_NAME', p_detail_rows(i));
947 	   FND_MESSAGE.SET_TOKEN('DEL_NAME',l_delivery_id);
948 	   x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
949 	   wsh_util_core.add_message(x_return_status);
950 
951 	   --
952 	   -- Debug Statements
953 	   --
954 	   IF l_debug_on THEN
955 		   WSH_DEBUG_SV.pop(l_module_name);
956 	   END IF;
957 	   --
958 	   RETURN;
959 
960 	 ELSE
961 
962 	   CLOSE check_assign;
963 
964 	 END IF;
965 
966    END LOOP;
967 
968 
969 
970 
971 -- Call autocreate deliveries to group details together. Check if the
972 -- number of deliveries created is 1. Use the wsh_delivery_autocreate
973 -- package to return a list of matching delivery parameters and then
974 -- delete these tables so that subsequent calls are not effected.
975 --p_init_flag should be N (if it is Y, all the tables get deleted at
976 --the end of the call to autocreate_deliveries which should not
977 --happen in this case
978 
979    --
980    -- Debug Statements
981    --
982    IF l_debug_on THEN
983 	   WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_AUTOCREATE.AUTOCREATE_DELIVERIES',WSH_DEBUG_SV.C_PROC_LEVEL);
984    END IF;
985    --
986    FOR i in 1..p_detail_rows.count LOOP
987 
988        l_attr_tab(i).entity_id := p_detail_rows(i);
989        l_attr_tab(i).entity_type := 'DELIVERY_DETAIL';
990 
991    END LOOP;
992 
993    l_action_rec.action := 'MATCH_GROUPS';
994 --   l_action_rec.check_single_grp := 'Y';
995 
996 
997    WSH_DELIVERY_AUTOCREATE.Find_Matching_Groups(p_attr_tab => l_attr_tab,
998                         p_action_rec => l_action_rec,
999                         p_target_rec => l_target_rec,
1000                         p_group_tab => l_group_tab,
1001                         x_matched_entities => l_matched_entities,
1002                         x_out_rec => l_out_rec,
1003                         x_return_status => x_return_status);
1004    --
1005    IF l_debug_on THEN
1006     --
1007     WSH_DEBUG_SV.log(l_module_name, 'Return status from autocreate_deliveries: '|| x_return_status);
1008     --
1009    END IF;
1010    --
1011    -- Bug 2734531 (handle return status correctly)
1012    --
1013    IF (x_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR, WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)) THEN
1014      RAISE assign_error;
1015    END IF;
1016    --
1017    --
1018    --
1019    x_del_params := l_group_tab(l_group_tab.FIRST);
1020 
1021 
1022    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1023    IF l_debug_on THEN
1024     --
1025     WSH_DEBUG_SV.log(l_module_name, 'Done check_assign_del_multi '|| x_return_status);
1026     --
1027    END IF;
1028 --
1029 -- Debug Statements
1030 --
1031 IF l_debug_on THEN
1032 	WSH_DEBUG_SV.pop(l_module_name);
1033 END IF;
1034 --
1035    EXCEPTION
1036 	 WHEN assign_error THEN
1037 		FND_MESSAGE.SET_NAME('WSH','WSH_DET_GROUP_ERROR');
1038 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1039 		wsh_util_core.add_message(x_return_status);
1040 		--
1041 		-- Debug Statements
1042 		--
1043 		IF l_debug_on THEN
1044 			WSH_DEBUG_SV.logmsg(l_module_name,'ASSIGN_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1045 			WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:ASSIGN_ERROR');
1046 		END IF;
1047 		--
1048 	  WHEN others THEN
1049 			IF check_assign%ISOPEN THEN
1050 			  CLOSE check_assign;
1051 			END IF;
1052 		wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.CHECK_ASSIGN_DEL_MULTI');
1053 		x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1054 
1055 --
1056 -- Debug Statements
1057 --
1058 IF l_debug_on THEN
1059 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1060 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1061 END IF;
1062 --
1063 END check_assign_del_multi;
1064 
1065 -----------------------------------------------------------------------------
1066 --
1067 -- Procedure:		check_credit_holds
1068 -- Parameters:		p_detail_id - delivery detail id
1069 --				  p_activity_type - 'PICK','PACK','SHIP'
1070 --				  p_source_line_id - optional
1071 --				  p_source_header_id - optional
1072 --				  p_init_flag - 'Y' initializes the table of bad header ids
1073 --				x_return_status
1074 -- Description:	   Checks if there are any credit checks or holds on a line.
1075 --				  Returns a status of FND_API.G_RET_STS_SUCCESS if no such
1076 --				  checks or holds exist
1077 --
1078 -----------------------------------------------------------------------------
1079 
1080 PROCEDURE check_credit_holds(
1081 	p_detail_id	 IN  NUMBER,
1082 	p_activity_type IN  VARCHAR2,
1083 	p_source_line_id   IN NUMBER,
1084 	p_source_header_id IN NUMBER,
1085 		p_source_code	  IN  VARCHAR2,
1086 	p_init_flag	 IN  VARCHAR2,
1087 	x_return_status OUT NOCOPY  VARCHAR2) IS
1088 
1089 -- BUG#:1549665 hwahdani retrieve ship_from_location_id,order_number,line number
1090 CURSOR get_source_info IS
1091 SELECT source_header_id, source_line_id,ship_from_location_id,
1092 	  source_header_number, source_line_number, org_id, container_flag
1093 FROM   wsh_delivery_details
1094 WHERE  delivery_detail_id = p_detail_id;
1095 
1096 -- BUG#:1549665 hwahdani get order information
1097 --Bug 1697471: added source_line_id in the where clause
1098 CURSOR get_order_info IS
1099 SELECT ship_from_location_id,source_header_number, source_line_number, org_id, container_flag
1100 FROM   wsh_delivery_details
1101 WHERE  source_header_id = p_source_header_id
1102 AND	source_code	= p_source_code
1103 AND	source_line_id = p_source_line_id;
1104 
1105 CURSOR get_pr_credit_cache IS
1106 SELECT status
1107 FROM   wsh_pr_header_holds
1108 WHERE  header_id = p_source_header_id
1109 AND    batch_id = WSH_PICK_LIST.G_BATCH_ID;
1110 
1111 l_header_id NUMBER := p_source_header_id;
1112 l_line_id   NUMBER := p_source_line_id;
1113 -- BUG#: 1549665 hwahdani variable to hold ship_from_location_id
1114 l_ship_from_location_id NUMBER;
1115 l_skip_header_flag VARCHAR2(1) := 'N';
1116 l_cache_status     VARCHAR2(1) ;
1117 
1118 l_result_out VARCHAR2(1);
1119 l_msg_count  NUMBER;
1120 l_msg_data   VARCHAR2(2000);
1121 -- BUG#:1549665 hwahdani variables for log_exception;
1122 l_request_id NUMBER;
1123 l_exception_return_status		  VARCHAR2(30);
1124 l_exception_msg_count			  NUMBER;
1125 l_exception_msg_data			   VARCHAR2(4000) := NULL;
1126 l_exception_assignment_id		  NUMBER;
1127 l_exception_error_message		  VARCHAR2(2000) := NULL;
1128 l_exception_location_id			NUMBER;
1129 l_dummy_exception_id			   NUMBER;
1130 l_dummy_detail_id				  NUMBER;
1131 l_order_number					 VARCHAR2(150);
1132 l_container_flag                        VARCHAR2(3);
1133 l_line_number					  VARCHAR2(150);
1134 l_org_id						   NUMBER;
1135 l_msg							  VARCHAR2(2000):= NULL;
1136 
1137 -- 3481194/3492870: add index variables to hash lists of headers and lines
1138 l_bad_index          NUMBER;
1139 l_good_index         NUMBER;
1140 l_passed_index       NUMBER;
1141 l_failed_index       NUMBER;
1142 
1143 -- bug 2429004
1144 l_activity_type					VARCHAR2(30);
1145 
1146 credit_hold_error EXCEPTION;
1147 header_hold_error EXCEPTION;
1148 line_hold_error   EXCEPTION;
1149 
1150 -- 2467416
1151   l_exists_flag VARCHAR2(1):= 'N';
1152   l_counter NUMBER := 0;
1153 
1154 --
1155 l_debug_on BOOLEAN;
1156 --
1157 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_CREDIT_HOLDS';
1158 --
1159 BEGIN
1160 
1161    --
1162    -- Debug Statements
1163    --
1164    --
1165    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1166    --
1167    IF l_debug_on IS NULL
1168    THEN
1169 	   l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1170    END IF;
1171    --
1172    IF l_debug_on THEN
1173 	   WSH_DEBUG_SV.push(l_module_name);
1174 	   --
1175 	   WSH_DEBUG_SV.log(l_module_name,'P_DETAIL_ID',P_DETAIL_ID);
1176 	   WSH_DEBUG_SV.log(l_module_name,'P_ACTIVITY_TYPE',P_ACTIVITY_TYPE);
1177 	   WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
1178 	   WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
1179 	   WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
1180 	   WSH_DEBUG_SV.log(l_module_name,'P_INIT_FLAG',P_INIT_FLAG);
1181    END IF;
1182    --
1183    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1184 
1185    IF p_source_code <> 'OE' THEN
1186 	 --
1187 	 -- Debug Statements
1188 	 --
1189 	 IF l_debug_on THEN
1190 		 WSH_DEBUG_SV.pop(l_module_name);
1191 	 END IF;
1192 	 --
1193 	 return;
1194    END IF;
1195 
1196 -- 2467416: In this check to include purge of the line_id tables also
1197    IF (p_init_flag = 'Y') THEN
1198 	 g_bad_header_ids.delete;
1199 	 g_good_header_ids.delete;
1200 
1201 	 g_passed_crd_Tab.delete;
1202 	 g_failed_crd_Tab.delete;
1203 
1204    END IF;
1205 
1206    IF (l_header_id IS NULL) OR (l_line_id IS NULL) THEN
1207 
1208 -- BUG#: 1549665 hwahdani - added ship_from_location_id
1209 -- order_number and line number
1210 	 OPEN  get_source_info;
1211 	 FETCH get_source_info INTO l_header_id, l_line_id,
1212 	 l_ship_from_location_id,l_order_number, l_line_number, l_org_id, l_container_flag;
1213 	 CLOSE get_source_info;
1214 
1215 -- BUG#:1549665 hwahdani added else
1216    ELSE
1217 	OPEN get_order_info;
1218 	 FETCH get_order_info into l_ship_from_location_id,
1219 		 l_order_number,l_line_number, l_org_id, l_container_flag;
1220 	CLOSE get_order_info ;
1221    END IF;
1222 
1223    IF l_container_flag = 'Y'
1224    THEN
1225 	 --
1226 	 -- Debug Statements
1227 	 --
1228 	 IF l_debug_on THEN
1229 		 WSH_DEBUG_SV.pop(l_module_name);
1230 	 END IF;
1231 	 --
1232 	 return;
1233    END IF;
1234 
1235    l_bad_index := get_table_index(p_entity_id=>l_header_id, x_table=>g_bad_header_ids);
1236    IF g_bad_header_ids.EXISTS(l_bad_index) THEN
1237 	--
1238 	-- Debug Statements
1239 	--
1240 	IF l_debug_on THEN
1241 		WSH_DEBUG_SV.logmsg(l_module_name,  'ORDER HEADER '||TO_CHAR ( L_HEADER_ID ) ||' FAILED CREDIT CHECK OR IS ON HOLD'  );
1242 	END IF;
1243 	--
1244 	raise credit_hold_error;
1245    END IF;
1246 
1247    l_good_index := get_table_index(p_entity_id=>l_header_id, p_alt_index=>l_bad_index, x_table=>g_good_header_ids);
1248    IF g_good_header_ids.EXISTS(l_good_index) THEN
1249 	l_skip_header_flag := 'Y';
1250    END IF;
1251 
1252    -- Check if Header exists in WSH_PR_HEADER_HOLDS Table for Pick Release process
1253    IF (l_skip_header_flag = 'N') AND (p_activity_type = 'PICK') AND (WSH_PICK_LIST.G_BATCH_ID IS NOT NULL)
1254    AND (WSH_PICK_LIST.G_PICK_REL_PARALLEL) THEN
1255       OPEN  get_pr_credit_cache;
1256       FETCH get_pr_credit_cache INTO l_cache_status;
1257       IF get_pr_credit_cache%NOTFOUND THEN
1258          l_cache_status := 'N'; -- not present in cache
1259       END IF;
1260       CLOSE get_pr_credit_cache;
1261       IF l_cache_status = 'F' THEN
1262          g_bad_header_ids(l_bad_index) := l_header_id;
1263          IF l_debug_on THEN
1264             WSH_DEBUG_SV.logmsg(l_module_name,  'ORDER HEADER '||TO_CHAR ( L_HEADER_ID )
1265                                   ||' FAILED CREDIT CHECK OR IS ON HOLD'  );
1266          END IF;
1267          RAISE credit_hold_error;
1268       ELSIF l_cache_status = 'P' THEN
1269  	 l_skip_header_flag := 'Y';
1270          g_good_header_ids(l_good_index) := l_header_id;
1271       END IF;
1272    END IF;
1273 
1274 -- Bug: 1580603
1275    --
1276 
1277    IF (l_skip_header_flag = 'N') THEN
1278 
1279      IF l_org_id IS NULL THEN
1280         SELECT ORG_ID
1281         INTO l_org_id
1282         FROM OE_ORDER_HEADERS_ALL
1283         WHERE HEADER_ID = l_header_id;
1284      END IF;
1285 
1286      IF l_debug_on THEN
1287 	   WSH_DEBUG_SV.logmsg(l_module_name,  'SETTING THE POLICY CONTEXT FOR ORG_ID:' || TO_CHAR ( L_ORG_ID )  );
1288      END IF;
1289      --
1290      MO_GLOBAL.set_policy_context('S', l_org_id);
1291 
1292 
1293 -- bug 2429004
1294 	  IF (p_activity_type = 'PICK') THEN
1295 		 l_activity_type := 'PICKING';
1296 	  ELSIF (p_activity_type = 'PACK') THEN
1297 		 l_activity_type := 'PACKING';
1298 	  ELSE
1299 		 l_activity_type := 'SHIPPING';
1300 	  END IF;
1301 -- end bug 2429004
1302 
1303 	  -- Check header level credit
1304 
1305 	  --
1306 	  -- Debug Statements
1307 	  --
1308 	  IF l_debug_on THEN
1309 		  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit OE_VERIFY_PAYMENT_PUB.VERIFY_PAYMENT',WSH_DEBUG_SV.C_PROC_LEVEL);
1310 	  END IF;
1311 	  --
1312 	  oe_verify_payment_pub.verify_payment(
1313 		 p_header_id	   => l_header_id,
1314 		p_calling_action  => l_activity_type, -- bug 2429004 - passing the corresponding activity type.
1315 		p_msg_count	   => l_msg_count,
1316 		p_msg_data		=> l_msg_data,
1317 		p_return_status   => x_return_status);
1318 
1319 	  IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1320 		g_bad_header_ids(l_bad_index) := l_header_id;
1321                 IF (p_activity_type = 'PICK') AND (WSH_PICK_LIST.G_BATCH_ID IS NOT NULL)
1322                 AND (WSH_PICK_LIST.G_PICK_REL_PARALLEL) THEN
1323                    Insert_PR_Header_Holds (p_header_id => l_header_id, p_status => 'F');
1324                 END IF;
1325 		--
1326 		-- Debug Statements
1327 		--
1328 		IF l_debug_on THEN
1329 			WSH_DEBUG_SV.logmsg(l_module_name,  'ORDER HEADER '||TO_CHAR ( L_HEADER_ID ) ||' FAILED CREDIT CHECK'  );
1330 		END IF;
1331 		--
1332 		raise credit_hold_error;
1333 	  END IF;
1334 
1335 
1336 	  -- Check generic header holds
1337 
1338 	  --
1339 	  -- Debug Statements
1340 	  --
1341 	  IF l_debug_on THEN
1342 		  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit OE_HOLDS_PUB.CHECK_HOLDS',WSH_DEBUG_SV.C_PROC_LEVEL);
1343 	  END IF;
1344 	  --
1345 	  oe_holds_pub.check_holds(
1346 		p_api_version		 => 1.0,
1347 		p_header_id		=> l_header_id,
1348 		 p_wf_item			=> NULL,
1349 		p_wf_activity		=> NULL,
1350 		x_result_out		 => l_result_out,
1351 		x_return_status	 => x_return_status,
1352 		x_msg_count		 => l_msg_count,
1353 		x_msg_data			=> l_msg_data);
1354 
1355 	  -- If hold is found return back
1356 
1357 	  IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) OR (l_result_out = FND_API.G_TRUE) THEN
1358 		   g_bad_header_ids(l_bad_index) := l_header_id;
1359                    IF (p_activity_type = 'PICK') AND (WSH_PICK_LIST.G_BATCH_ID IS NOT NULL)
1360                    AND (WSH_PICK_LIST.G_PICK_REL_PARALLEL) THEN
1361                       Insert_PR_Header_Holds (p_header_id => l_header_id, p_status => 'F');
1362                    END IF;
1363 		--
1364 		-- Debug Statements
1365 		--
1366 		IF l_debug_on THEN
1367 			WSH_DEBUG_SV.logmsg(l_module_name,  'ORDER HEADER '||TO_CHAR ( L_HEADER_ID ) ||' IS ON HOLD'  );
1368 		END IF;
1369 		--
1370 --BUG#:1549665 hwahdani - check if process was run from conc. request and get id
1371 -- and log exception if order is on hold
1372 		l_request_id := fnd_global.conc_request_id;
1373 	-- 1729516
1374 		IF l_debug_on THEN
1375 		   WSH_DEBUG_SV.log(l_module_name,'l_request_id', l_request_id );
1376 		   WSH_DEBUG_SV.log(l_module_name,'WSH_PICK_LIST.G_BATCH_ID', WSH_PICK_LIST.G_BATCH_ID );
1377 		END IF;
1378 
1379 		IF ( l_request_id = -1 AND  WSH_PICK_LIST.G_BATCH_ID IS NULL ) THEN
1380 			   raise header_hold_error;
1381 		ELSE
1382 		   FND_MESSAGE.SET_NAME('WSH','WSH_PICK_HOLD');
1383 		   FND_MESSAGE.SET_TOKEN('ORDER',l_order_number);
1384 			 l_msg := FND_MESSAGE.GET;
1385 			 --
1386 			 -- Debug Statements
1387 			 --
1388 			 IF l_debug_on THEN
1389 				 WSH_DEBUG_SV.logmsg(l_module_name,  L_MSG  );
1390 			 END IF;
1391 			 --
1392 
1393 		         l_dummy_exception_id :=null;
1394 			 --
1395 			 -- Debug Statements
1396 			 --
1397 			 IF l_debug_on THEN
1398 				 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_XC_UTIL.LOG_EXCEPTION',WSH_DEBUG_SV.C_PROC_LEVEL);
1399 			 END IF;
1400 			 --
1401 			 wsh_xc_util.log_exception(
1402 			 p_api_version			 => 1.0,
1403 			 x_return_status		   => l_exception_return_status,
1404 			 x_msg_count			   => l_exception_msg_count,
1405 			 x_msg_data				=> l_exception_msg_data,
1406 			 x_exception_id			=> l_dummy_exception_id ,
1407 			 p_logged_at_location_id   => l_ship_from_location_id,
1408 			 p_exception_location_id   => l_ship_from_location_id,
1409 			 p_logging_entity		  => 'SHIPPER',
1410 			 p_logging_entity_id	   => FND_GLOBAL.USER_ID,
1411 			 p_exception_name		  => 'WSH_PICK_HOLD',
1412 			 p_message				 => l_msg,
1413 			 p_error_message		   => l_exception_error_message,
1414 			 p_request_id			  => l_request_id,
1415 			 p_batch_id				=> WSH_PICK_LIST.g_batch_id				 -- Bug: 1729516
1416 			 );
1417 
1418 			 IF (l_exception_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
1419 			--
1420 			-- Debug Statements
1421 			--
1422 			IF l_debug_on THEN
1423 				WSH_DEBUG_SV.logmsg(l_module_name,  'WSH_XC_UTIL.LOG_EXCEPTION DID NOT RETURN SUCCESS'  );
1424 			END IF;
1425 			--
1426 			END IF;
1427 --Bug: 1573703 Return status needs to be set to 'E'
1428 		   x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1429                    raise header_hold_error;  --bugfix 6263535
1430 
1431 		  END IF;
1432 		END IF;
1433 
1434 	  g_good_header_ids(l_good_index) := l_header_id;
1435           IF (p_activity_type = 'PICK') AND (WSH_PICK_LIST.G_BATCH_ID IS NOT NULL)
1436           AND (WSH_PICK_LIST.G_PICK_REL_PARALLEL) THEN
1437              Insert_PR_Header_Holds (p_header_id => l_header_id, p_status => 'P');
1438           END IF;
1439 
1440    END IF;
1441 
1442    --  2467416  changes Begin
1443    -- First Check in g_passed_crd_Tab, then in the g_failed_crd_Tab
1444    -- 3481194/3492870: hash indexes; if this is a new line,
1445    -- both l_passed_index and l_failed_index will be populated
1446 
1447    l_passed_index := get_table_index(p_entity_id=>l_line_id, x_table=>g_passed_crd_tab);
1448    IF g_passed_crd_Tab.exists(l_passed_index)  THEN
1449      l_exists_flag := 'Y';
1450      x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1451    END IF;
1452 
1453    IF (l_exists_flag = 'N')  THEN
1454      l_failed_index := get_table_index(p_entity_id=>l_line_id, p_alt_index=>l_passed_index, x_table=>g_failed_crd_tab);
1455      IF g_failed_crd_Tab.exists(l_failed_index)  THEN
1456        l_exists_flag := 'Y';
1457        RAISE line_hold_error;
1458      END IF;
1459    END IF;
1460 
1461    -- 2467416 changes End
1462 
1463    -- Check line holds, only if the incoming line_id doesn't exists in the either passed/failed tables
1464 
1465    IF l_exists_flag = 'N' THEN
1466 
1467 	  --
1468 	  -- Debug Statements
1469 	  --
1470 	  IF l_debug_on THEN
1471 		  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit OE_HOLDS_PUB.CHECK_HOLDS',WSH_DEBUG_SV.C_PROC_LEVEL);
1472 	  END IF;
1473 	  --
1474 	  oe_holds_pub.check_holds(
1475 	 p_api_version			=> 1.0,
1476 	 p_line_id			=> l_line_id,
1477 		 p_wf_item			=> 'OEOL',
1478 	 p_wf_activity				  => p_activity_type||'_LINE',
1479 	 x_result_out				   => l_result_out,
1480 	 x_return_status		 => x_return_status,
1481 	 x_msg_count			 => l_msg_count,
1482 	 x_msg_data			=> l_msg_data);
1483 
1484 	  IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) OR (l_result_out = FND_API.G_TRUE) THEN
1485 	   --
1486 	   -- Debug Statements
1487 	   --
1488 	   IF l_debug_on THEN
1489 		   WSH_DEBUG_SV.logmsg(l_module_name,  'ORDER LINE '||TO_CHAR ( L_LINE_ID ) ||' IS ON HOLD'  );
1490 	   END IF;
1491 	   --
1492 
1493 	-- BUG#: 1549665 hwahdani - check if process was run from conc. request and
1494 	-- and log exception
1495 
1496 	-- 2467416
1497 	   g_failed_crd_Tab(l_failed_index) := l_line_id;
1498 
1499 	   l_request_id := fnd_global.conc_request_id;
1500 
1501 	-- 1729516
1502 	   IF ( l_request_id = -1 AND WSH_PICK_LIST.G_BATCH_ID IS NULL ) THEN
1503 			 raise line_hold_error;
1504 	   ELSE
1505 		 FND_MESSAGE.SET_NAME('WSH','WSH_PICK_ORDER_LINE_HOLD');
1506 		 FND_MESSAGE.SET_TOKEN('ORDER',l_order_number);
1507 		 FND_MESSAGE.SET_TOKEN('LINE',l_line_number);
1508 			 l_msg := FND_MESSAGE.GET;
1509 			 --
1510 			 -- Debug Statements
1511 			 --
1512 			 IF l_debug_on THEN
1513 				 WSH_DEBUG_SV.logmsg(l_module_name,  L_MSG  );
1514 			 END IF;
1515 			 --
1516 
1517 		 l_dummy_exception_id :=null;
1518 			 --
1519 			 -- Debug Statements
1520 			 --
1521 			 IF l_debug_on THEN
1522 				 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_XC_UTIL.LOG_EXCEPTION',WSH_DEBUG_SV.C_PROC_LEVEL);
1523 			 END IF;
1524 			 --
1525 			 wsh_xc_util.log_exception(
1526 			 p_api_version			 => 1.0,
1527 			 x_return_status		   => l_exception_return_status,
1528 			 x_msg_count			   => l_exception_msg_count,
1529 			 x_msg_data				=> l_exception_msg_data,
1530 			 x_exception_id			=> l_dummy_exception_id ,
1531 			 p_logged_at_location_id   => l_ship_from_location_id,
1532 			 p_exception_location_id   => l_ship_from_location_id,
1533 			 p_logging_entity		  => 'SHIPPER',
1534 			 p_logging_entity_id	   => FND_GLOBAL.USER_ID,
1535 			 p_exception_name		  => 'WSH_PICK_HOLD',
1536 			 p_message				 => l_msg ,
1537 			 p_error_message		   => l_exception_error_message,
1538 			 p_request_id			  => l_request_id,
1539 			 p_batch_id				=> WSH_PICK_LIST.g_batch_id				 -- Bug: 1729516
1540 			 );
1541 
1542 			IF (l_exception_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
1543 			--
1544 			-- Debug Statements
1545 			--
1546 			IF l_debug_on THEN
1547 				WSH_DEBUG_SV.logmsg(l_module_name,  'WSH_XC_UTIL.LOG_EXCEPTION DID NOT RETURN SUCCESS'  );
1548 			END IF;
1549 			--
1550 			END IF;
1551 --Bug: 1573703 Return status needs to be set to 'E'
1552 		   x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1553 		   -- bug 2882720: set message in case the concurrent program rolls back so that the exception is gone.
1554 		   IF p_activity_type = 'PICK' THEN
1555 		      FND_MESSAGE.SET_NAME('WSH','WSH_PICK_LINE_HOLD_ERROR');
1556 		      FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1557 		   ELSIF p_activity_type = 'PACK' THEN
1558 		      FND_MESSAGE.SET_NAME('WSH','WSH_PACK_LINE_HOLD_ERROR');
1559 		      FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1560 		   ELSE
1561 		      FND_MESSAGE.SET_NAME('WSH','WSH_SHIP_LINE_HOLD_ERROR');
1562 		      FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1563 		   END IF;
1564 		   wsh_util_core.add_message(x_return_status);
1565 		   -- bug 2882720 change end
1566 
1567 		   END IF;   /* 1729516  */
1568 
1569 		ELSE
1570 		 --   /* i.e. When HOLD is FALSE , No Hold on the Line */
1571 		 -- 2467416
1572 		  g_passed_crd_Tab(l_passed_index) := l_line_id;
1573 
1574 		END IF;  /* if HOLD is TRUE */
1575    END IF;  /* if l_exists_flag = N */
1576 
1577 --
1578 -- Debug Statements
1579 --
1580 IF l_debug_on THEN
1581 	WSH_DEBUG_SV.pop(l_module_name);
1582 END IF;
1583 --
1584    EXCEPTION
1585          WHEN header_hold_error THEN
1586 		FND_MESSAGE.SET_NAME('WSH','WSH_HEADER_HOLD_ERROR');
1587 		FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1588 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1589 		wsh_util_core.add_message(x_return_status);
1590 		--
1591 		-- Debug Statements
1592 		--
1593 		IF l_debug_on THEN
1594 			WSH_DEBUG_SV.logmsg(l_module_name,'HEADER_HOLD_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1595 			WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:HEADER_HOLD_ERROR');
1596 		END IF;
1597 
1598          WHEN line_hold_error THEN
1599                 IF p_activity_type = 'PICK' THEN
1600   		   FND_MESSAGE.SET_NAME('WSH','WSH_PICK_LINE_HOLD_ERROR');
1601   		   FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1602                 ELSIF p_activity_type = 'PACK' THEN
1603    		   FND_MESSAGE.SET_NAME('WSH','WSH_PACK_LINE_HOLD_ERROR');
1604   		   FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1605                 ELSE
1606   		   FND_MESSAGE.SET_NAME('WSH','WSH_SHIP_LINE_HOLD_ERROR');
1607   		   FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1608   		END IF;
1609   		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1610   		wsh_util_core.add_message(x_return_status);
1611   		--
1612   		-- Debug Statements
1613   		--
1614   		IF l_debug_on THEN
1615   			WSH_DEBUG_SV.logmsg(l_module_name, p_activity_type ||'_LINE_HOLD_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1616   			WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:LINE_HOLD_ERROR');
1617 		END IF;
1618 
1619 	 WHEN credit_hold_error THEN
1620 		FND_MESSAGE.SET_NAME('WSH','WSH_DET_CREDIT_HOLD_ERROR');
1621 		FND_MESSAGE.SET_TOKEN('DET_NAME',p_detail_id);
1622 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1623 		wsh_util_core.add_message(x_return_status);
1624 		--
1625 		-- Debug Statements
1626 		--
1627 		IF l_debug_on THEN
1628 			WSH_DEBUG_SV.logmsg(l_module_name,'CREDIT_HOLD_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1629 			WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:CREDIT_HOLD_ERROR');
1630 		END IF;
1631 		--
1632 	  WHEN others THEN
1633 		wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.Check_Credit_Holds');
1634 		x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1635 
1636 --
1637 -- Debug Statements
1638 --
1639 IF l_debug_on THEN
1640 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1641 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1642 END IF;
1643 --
1644 END check_credit_holds;
1645 
1646 
1647 
1648 -----------------------------------------------------------------------------
1649 --
1650 -- Procedure:		check_quantity_to_pick
1651 -- Parameters:		p_order_line_id,   - order line being picked
1652 --					  p_quantity_to_pick - quantity to transact that
1653 --										   will be checked
1654 --					  x_allowed_flag - 'Y' = allowed, 'N' = not allowed
1655 --					  x_max_quantity_allowed - maximum quantity
1656 --											   that can be picked
1657 --					  x_avail_req_quantity - req quantity not yet staged
1658 --			x_return_status
1659 -- Description:	   Checks if the quantity to pick is within overshipment
1660 --					  tolerance, based on the quantities requested and
1661 --					  staged and assignments to deliveries or containers.
1662 --					  Also returns the maximum quantity allowed to pick.
1663 -- History:			 HW Added Qty2 for OPM and changed procedure parameters
1664 -----------------------------------------------------------------------------
1665 
1666 PROCEDURE check_quantity_to_pick(
1667 	p_order_line_id		   IN  NUMBER,
1668 		p_quantity_to_pick		IN  NUMBER,
1669 		p_quantity2_to_pick	   IN  NUMBER,
1670 		x_allowed_flag			OUT NOCOPY  VARCHAR2,
1671 		x_max_quantity_allowed	OUT NOCOPY  NUMBER,
1672 		x_max_quantity2_allowed   OUT NOCOPY  NUMBER,
1673 		x_avail_req_quantity	  OUT NOCOPY  NUMBER,
1674 		x_avail_req_quantity2	 OUT NOCOPY  NUMBER,
1675 	x_return_status		   OUT NOCOPY  VARCHAR2) IS
1676 
1677 
1678 -- HW OPM retrieve uom2
1679 CURSOR c_detail_info(x_source_line_id IN NUMBER) IS
1680   SELECT inventory_item_id,
1681 		 organization_id,
1682 		 requested_quantity_uom,
1683 		 requested_quantity_uom2,
1684 		 ship_tolerance_above,
1685 		 ship_tolerance_below, -- 2181132 added following fields
1686 		 source_header_id,
1687 		 source_line_set_id,
1688 		 source_code
1689   FROM   wsh_delivery_details
1690   WHERE  source_line_id = x_source_line_id
1691   AND	source_code = 'OE'  -- pick confirm supports only OE lines
1692   AND	container_flag = 'N'
1693   AND	released_status <> 'D'
1694   AND	rownum = 1;
1695 
1696 
1697 -- HW OPM added qty2
1698 -- along with Bug 2181132
1699 -- change the cursor because it was not looking at shipped
1700 -- quantity and there can be cases where shipped quantity is not
1701 -- the same as picked quantity for a shipped delivery line
1702 CURSOR c_detail_staged_quantities(x_source_line_id IN NUMBER) IS
1703   SELECT NVL(SUM(requested_quantity), 0) net_requested_qty,
1704 		 NVL(SUM(decode (released_status,'C',nvl(shipped_quantity,0),
1705 			 NVL(picked_quantity, requested_quantity))
1706 			), 0) net_staged_qty,
1707 		 --NVL(SUM(NVL(picked_quantity, requested_quantity)), 0) net_staged_qty,
1708 		 NVL(SUM(NVL(requested_quantity2,0)), 0) net_requested_qty2,
1709 		 NVL(SUM(NVL(picked_quantity2, requested_quantity2)), 0) net_staged_qty2
1710   FROM   wsh_delivery_details
1711   WHERE  source_line_id = x_source_line_id
1712   AND	source_code	= 'OE'
1713   AND	container_flag = 'N'
1714   AND	released_status IN ('X', 'Y', 'C');
1715 
1716 -- HW OPMCONV -Retrieve Qty2 and UOM2
1717 
1718 CURSOR c_ordered_quantity(x_source_line_id  IN NUMBER,
1719 						  x_item_id		 IN NUMBER,
1720 						  x_primary_uom	 IN VARCHAR2) IS
1721   SELECT WSH_WV_UTILS.CONVERT_UOM(order_quantity_uom,
1722 				  x_primary_uom,
1723 				  ordered_quantity,
1724 				  x_item_id) quantity ,
1725 		                  order_quantity_uom,
1726 		                  ordered_quantity2,
1727 		                  ordered_quantity_uom2
1728   FROM   oe_order_lines_all
1729   WHERE  line_id = x_source_line_id;
1730 
1731 
1732 l_found_flag	  BOOLEAN;
1733 l_detail_info	 c_detail_info%ROWTYPE;
1734 l_staged_info	 c_detail_staged_quantities%ROWTYPE;
1735 l_order_line	  c_ordered_quantity%ROWTYPE;
1736 --HW OPM variable for OPM cursor
1737 -- HW OPMCONV - No need for OPM specific cursor
1738 
1739 quantity		  NUMBER;
1740 l_max_quantity2   NUMBER;
1741 l_min_quantity2   NUMBER;
1742 l_max_quantity	NUMBER;
1743 l_min_quantity	NUMBER;
1744 l_msg_count	   NUMBER;
1745 l_msg_data   VARCHAR2(2000);
1746 l_return_status varchar2(30);
1747 
1748 l_apps_uom_ordered_quantity NUMBER := 0; -- Bug 2922649
1749 
1750 l_req_qty_left	NUMBER;
1751 others	   EXCEPTION;
1752 
1753 -- HW OPM new varibales
1754 -- HW OPMCONV - No need for OPM local variables
1755 
1756 l_req_qty2_left	NUMBER;
1757 
1758 -- 2181132
1759   l_minmaxinrectype MinMaxInRecType;
1760   l_minmaxinoutrectype MinMaxInOutRecType;
1761   l_minmaxoutrectype MinMaxOutRecType;
1762   l_quantity_uom  WSH_DELIVERY_DETAILS.requested_quantity_uom%TYPE;
1763   l_quantity_uom2  WSH_DELIVERY_DETAILS.requested_quantity_uom2%TYPE;
1764 
1765 --
1766 l_debug_on BOOLEAN;
1767 --
1768 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_QUANTITY_TO_PICK';
1769 --
1770 BEGIN
1771 
1772   --
1773   -- Debug Statements
1774   --
1775   --
1776   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1777   --
1778   IF l_debug_on IS NULL
1779   THEN
1780 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1781   END IF;
1782   --
1783   IF l_debug_on THEN
1784 	  WSH_DEBUG_SV.push(l_module_name);
1785 	  --
1786 	  WSH_DEBUG_SV.log(l_module_name,'P_ORDER_LINE_ID',P_ORDER_LINE_ID);
1787 	  WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY_TO_PICK',P_QUANTITY_TO_PICK);
1788 	  WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY2_TO_PICK',P_QUANTITY2_TO_PICK);
1789   END IF;
1790   --
1791   OPEN  c_detail_info(p_order_line_id);
1792   FETCH c_detail_info INTO l_detail_info;
1793   l_found_flag := c_detail_info%FOUND;
1794   CLOSE c_detail_info;
1795 
1796 -- HW OPM Added qty2
1797   IF NOT l_found_flag THEN
1798 	FND_MESSAGE.SET_NAME('WSH','NO_DATA_FOUND');
1799 	x_allowed_flag		 := 'N';
1800 	x_max_quantity_allowed := NULL;
1801 	x_avail_req_quantity   := NULL;
1802 	x_max_quantity2_allowed := NULL;
1803 	x_avail_req_quantity2   := NULL;
1804 
1805 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1806 	--
1807 	-- Debug Statements
1808 	--
1809 	IF l_debug_on THEN
1810 		WSH_DEBUG_SV.pop(l_module_name);
1811 	END IF;
1812 	--
1813 	RETURN;
1814   END IF;
1815 
1816 -- HW OPM Need to check the org for forking
1817   --
1818   -- Debug Statements
1819   --
1820 
1821 
1822   OPEN  c_detail_staged_quantities(p_order_line_id);
1823   FETCH c_detail_staged_quantities INTO l_staged_info;
1824   l_found_flag := c_detail_staged_quantities%FOUND;
1825   CLOSE c_detail_staged_quantities;
1826 
1827 -- HW OPM Added qty2
1828   IF NOT l_found_flag THEN
1829 	FND_MESSAGE.SET_NAME('WSH','NO_DATA_FOUND');
1830 	x_allowed_flag		 := 'N';
1831 	x_max_quantity_allowed := NULL;
1832 	x_avail_req_quantity   := NULL;
1833 	x_max_quantity2_allowed := NULL;
1834 	x_avail_req_quantity2   := NULL;
1835 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1836 	--
1837 	-- Debug Statements
1838 	--
1839 	IF l_debug_on THEN
1840 		WSH_DEBUG_SV.pop(l_module_name);
1841 	END IF;
1842 	--
1843 	RETURN;
1844   END IF;
1845 
1846 -- HW OPMCONV - No need to branch code
1847 -- HW OPM for debugging puproses. Print values
1848 -- HW OPM Need to branch
1849 
1850 	OPEN  c_ordered_quantity(p_order_line_id,
1851 	 l_detail_info.inventory_item_id,
1852 	 l_detail_info.requested_quantity_uom);
1853 	FETCH c_ordered_quantity INTO l_order_line;
1854 	l_found_flag := c_ordered_quantity%FOUND;
1855 	CLOSE c_ordered_quantity;
1856 
1857 -- HW OPM Added qty2
1858   IF NOT l_found_flag THEN
1859 	FND_MESSAGE.SET_NAME('WSH','NO_DATA_FOUND');
1860 	x_allowed_flag		 := 'N';
1861 	x_max_quantity_allowed := NULL;
1862 	x_avail_req_quantity   := NULL;
1863 	x_max_quantity2_allowed := NULL;
1864 	x_avail_req_quantity2   := NULL;
1865 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1866 	--
1867 	-- Debug Statements
1868 	--
1869 	IF l_debug_on THEN
1870 		WSH_DEBUG_SV.pop(l_module_name);
1871 	END IF;
1872 	--
1873 	RETURN;
1874   END IF;
1875 
1876   -- Debug Statements
1877   --
1878   IF l_debug_on THEN
1879 	  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.GET_MIN_MAX_TOLERANCE_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
1880   END IF;
1881   --
1882 -- Bug 2181132
1883 
1884 -- in attributes
1885 
1886 	l_minmaxinrectype.source_code := l_detail_info.source_code;
1887 	l_minmaxinrectype.line_id := p_order_line_id;
1888 	l_minmaxinrectype.source_header_id := l_detail_info.source_header_id;
1889 	l_minmaxinrectype.source_line_set_id := l_detail_info.source_line_set_id;
1890 	l_minmaxinrectype.ship_tolerance_above := l_detail_info.ship_tolerance_above;
1891 	l_minmaxinrectype.ship_tolerance_below := l_detail_info.ship_tolerance_below;
1892 	l_minmaxinrectype.action_flag := 'P'; -- pick confirm
1893 	l_minmaxinrectype.lock_flag := 'N';
1894 	l_minmaxinrectype.quantity_uom := l_detail_info.requested_quantity_uom;
1895 	l_minmaxinrectype.quantity_uom2 := l_detail_info.requested_quantity_uom2;
1896 
1897    WSH_DETAILS_VALIDATIONS.get_min_max_tolerance_quantity
1898 		(p_in_attributes  => l_minmaxinrectype,
1899 		 x_out_attributes  => l_minmaxoutrectype,
1900 		 p_inout_attributes  => l_minmaxinoutrectype,
1901 		 x_return_status  => l_return_status,
1902 		 x_msg_count  =>  l_msg_count,
1903 		 x_msg_data => l_msg_data
1904 		 );
1905 
1906 	l_quantity_uom := l_minmaxoutrectype.quantity_uom;
1907 	l_min_quantity := l_minmaxoutrectype.min_remaining_quantity;
1908 	l_max_quantity := l_minmaxoutrectype.max_remaining_quantity;
1909 	l_quantity_uom2 := l_minmaxoutrectype.quantity2_uom;
1910 	l_min_quantity2 := l_minmaxoutrectype.min_remaining_quantity2;
1911 	l_max_quantity2 := l_minmaxoutrectype.max_remaining_quantity2;
1912 
1913 
1914   IF l_debug_on THEN
1915     WSH_DEBUG_SV.log(l_module_name,'Return Status'||l_return_status);
1916     WSH_DEBUG_SV.log(l_module_name,'Max Qty'||l_max_quantity);
1917     WSH_DEBUG_SV.log(l_module_name,'Min Qty'||l_min_quantity);
1918     WSH_DEBUG_SV.log(l_module_name,'Qty UOM'||l_quantity_uom);
1919   END IF;
1920 
1921   IF l_return_status <> FND_API.G_RET_STS_SUCCESS  THEN
1922 	raise others ;
1923   END IF;
1924 
1925 
1926 
1927 -- HW OPMCONV - Need to branch
1928 
1929 	 --
1930 	 -- Debug Statements
1931 	 --
1932 	 IF l_debug_on THEN
1933 		 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.CONVERT_UOM',WSH_DEBUG_SV.C_PROC_LEVEL);
1934 	 END IF;
1935 	 --
1936 	 l_max_quantity :=  l_max_quantity
1937 			   - l_staged_info.net_staged_qty;
1938 
1939 
1940 	  l_req_qty_left := GREATEST(0,
1941 			 (l_order_line.quantity
1942 			  - l_staged_info.net_requested_qty)
1943 							);
1944 
1945 
1946 	 l_max_quantity2 := nvl(l_max_quantity2,0) - nvl(l_staged_info.net_staged_qty2,0);
1947 
1948 	 l_req_qty2_left := GREATEST(0,
1949 			 (l_order_line.ordered_quantity2
1950 			  - l_staged_info.net_requested_qty2)
1951 							);
1952 
1953 -- HW added for debugging purposes
1954 -- HW OPMCONV - No need to branch
1955 
1956   IF p_quantity_to_pick < 0 THEN
1957 	x_allowed_flag	:= 'N';
1958 -- HW OPM added a checj for qty2
1959   ELSIF (p_quantity_to_pick > l_max_quantity) THEN
1960        -- Begin BUG 2675737
1961        -- OR
1962        -- nvl(p_quantity2_to_pick,0) > nvl(l_max_quantity2,0) THEN
1963        -- End   BUG 2675737
1964 	x_allowed_flag	:= 'N';
1965   ELSE
1966 	x_allowed_flag	:= 'Y';
1967   END IF;
1968 
1969   x_max_quantity_allowed := l_max_quantity;
1970   x_avail_req_quantity   := l_req_qty_left;
1971 -- HW OPM added qty2
1972   x_max_quantity2_allowed := l_max_quantity2;
1973   x_avail_req_quantity2   := l_req_qty2_left;
1974 
1975 -- HW OPMCONV _ Removed print statements
1976   -- HW for debugging purposes, print values
1977 
1978   x_return_status		:= WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1979 
1980 
1981 --
1982 -- Debug Statements
1983 --
1984 IF l_debug_on THEN
1985 	WSH_DEBUG_SV.pop(l_module_name);
1986 END IF;
1987 --
1988   EXCEPTION
1989 	WHEN others THEN
1990 	  IF c_detail_info%ISOPEN THEN
1991 		CLOSE c_detail_info;
1992 	  END IF;
1993 	  IF c_detail_staged_quantities%ISOPEN THEN
1994 		CLOSE c_detail_staged_quantities;
1995 	  END IF;
1996 	  IF c_ordered_quantity%ISOPEN THEN
1997 		CLOSE c_ordered_quantity;
1998 	  END IF;
1999 -- HW closing OPM cursor
2000 
2001 	  x_allowed_flag		 := 'N';
2002 	  x_max_quantity_allowed := NULL;
2003 	  x_avail_req_quantity   := NULL;
2004 -- HW Added for OPM
2005 	  x_max_quantity2_allowed := NULL;
2006 	  x_avail_req_quantity2   := NULL;
2007 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2008 	  wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.check_quantity_to_pick');
2009 
2010 --
2011 -- Debug Statements
2012 --
2013 IF l_debug_on THEN
2014 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2015 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2016 END IF;
2017 --
2018 END check_quantity_to_pick;
2019 
2020 -- Overloaded  check_quantity_to_pick
2021 -- Same as above procedure but is w/o
2022 -- the quantity2's in the signature
2023 
2024 
2025 PROCEDURE check_quantity_to_pick(
2026 		p_order_line_id		   IN  NUMBER,
2027 		p_quantity_to_pick		IN  NUMBER,
2028 		x_allowed_flag			OUT NOCOPY  VARCHAR2,
2029 		x_max_quantity_allowed	OUT NOCOPY  NUMBER,
2030 		x_avail_req_quantity	  OUT NOCOPY  NUMBER,
2031 		x_return_status		   OUT NOCOPY  VARCHAR2) IS
2032 
2033 l_dummy_quantity2_to_pick	NUMBER;
2034 l_dummy_max_quantity2_allowed   NUMBER;
2035 l_dummy_avail_req_quantity2	NUMBER;
2036 
2037 
2038 --
2039 l_debug_on BOOLEAN;
2040 --
2041 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_QUANTITY_TO_PICK';
2042 --
2043 BEGIN
2044 
2045 --
2046 -- Debug Statements
2047 --
2048 --
2049 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2050 --
2051 IF l_debug_on IS NULL
2052 THEN
2053 	l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2054 END IF;
2055 --
2056 IF l_debug_on THEN
2057 	WSH_DEBUG_SV.push(l_module_name);
2058 	--
2059 	WSH_DEBUG_SV.log(l_module_name,'P_ORDER_LINE_ID',P_ORDER_LINE_ID);
2060 	WSH_DEBUG_SV.log(l_module_name,'P_QUANTITY_TO_PICK',P_QUANTITY_TO_PICK);
2061 END IF;
2062 --
2063 --
2064 -- Debug Statements
2065 --
2066 IF l_debug_on THEN
2067 	WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_QUANTITY_TO_PICK',WSH_DEBUG_SV.C_PROC_LEVEL);
2068 END IF;
2069 --
2070 wsh_details_validations.check_quantity_to_pick(
2071 		p_order_line_id		   => p_order_line_id,
2072 		p_quantity_to_pick		=> p_quantity_to_pick,
2073 		p_quantity2_to_pick	   => l_dummy_quantity2_to_pick,
2074 		x_allowed_flag			=> x_allowed_flag,
2075 		x_max_quantity_allowed	=> x_max_quantity_allowed,
2076 		x_max_quantity2_allowed   => l_dummy_max_quantity2_allowed,
2077 		x_avail_req_quantity	  => x_avail_req_quantity,
2078 		x_avail_req_quantity2	 => l_dummy_avail_req_quantity2,
2079 		x_return_status		   => x_return_status);
2080 
2081 --
2082 -- Debug Statements
2083 --
2084 IF l_debug_on THEN
2085 	WSH_DEBUG_SV.pop(l_module_name);
2086 END IF;
2087 --
2088 EXCEPTION
2089    WHEN OTHERS THEN
2090 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2091 	  wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.check_quantity_to_pick');
2092 
2093 --
2094 -- Debug Statements
2095 --
2096 IF l_debug_on THEN
2097 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2098 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2099 END IF;
2100 --
2101 END check_quantity_to_pick;
2102 
2103 
2104 -----------------------------------------------------------------------------
2105 --
2106 -- Procedure:		check_zero_req_confirm
2107 -- Parameters:		p_delivery_id	  - delivery being confirmed
2108 --			x_return_status
2109 -- Description:	   Ensure that delivery details with zero requested
2110 --					  quantities will not be alone after Ship Confirm.
2111 --
2112 -----------------------------------------------------------------------------
2113 
2114 PROCEDURE check_zero_req_confirm(
2115 	p_delivery_id		  IN  NUMBER,
2116 	x_return_status		OUT NOCOPY  VARCHAR2) IS
2117 
2118   CURSOR c_check_qty_inside_del (del_id IN NUMBER) IS
2119   select sum(wdd.requested_quantity), wdd.source_code, wdd.source_line_id
2120   from wsh_delivery_details wdd, wsh_delivery_assignments_v wda
2121   where wdd.delivery_detail_id = wda.delivery_detail_id
2122   and wda.delivery_id is not null
2123   and wda.delivery_id = del_id
2124   and wdd.released_status <> 'D'
2125   group by source_line_id, source_code
2126   having sum(wdd.requested_quantity) = 0;
2127 
2128 
2129   CURSOR c_source_info IS
2130   select distinct wdd.source_line_id, wdd.source_code
2131   from wsh_delivery_details wdd, wsh_delivery_assignments_v wda
2132   where wdd.delivery_detail_id = wda.delivery_detail_id
2133   and wdd.released_status <> 'D'
2134   and wda.delivery_id is not null
2135   and wda.delivery_id = p_delivery_id;
2136 
2137   l_req_qty		NUMBER;
2138   l_source_code	VARCHAR2(3);
2139   l_source_line_id NUMBER;
2140 
2141   req_qty_zero EXCEPTION;
2142 
2143 --
2144 l_debug_on BOOLEAN;
2145 --
2146 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CHECK_ZERO_REQ_CONFIRM';
2147 --
2148 BEGIN
2149   --
2150   -- Debug Statements
2151   --
2152   --
2153   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2154   --
2155   IF l_debug_on IS NULL
2156   THEN
2157 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2158   END IF;
2159   --
2160   IF l_debug_on THEN
2161 	  WSH_DEBUG_SV.push(l_module_name);
2162 	  --
2163 	  WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_ID',P_DELIVERY_ID);
2164   END IF;
2165   --
2166   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2167 
2168   open c_check_qty_inside_del (p_delivery_id);
2169   fetch c_check_qty_inside_del into l_req_qty, l_source_code, l_source_line_id;
2170   IF c_check_qty_inside_del%FOUND THEN
2171 	FND_MESSAGE.SET_NAME('WSH','WSH_REQ_ZERO_INSIDE_ERROR');
2172 	close c_check_qty_inside_del;
2173 	raise req_qty_zero;
2174   END IF;
2175   close c_check_qty_inside_del;
2176 
2177   FOR source_rec IN c_source_info LOOP
2178       BEGIN
2179          select sum(wdd.requested_quantity)
2180          into   l_req_qty
2181          from   wsh_delivery_details wdd, wsh_delivery_assignments_v wda, wsh_new_deliveries wnd
2182          where  wdd.delivery_detail_id = wda.delivery_detail_id
2183          and    wnd.delivery_id(+) = wda.delivery_id
2184          and    (wda.delivery_id <> p_delivery_id or wda.delivery_id is NULL)
2185          and    wdd.released_status not in ('C', 'D')
2186          and    NVL(wnd.status_code,'OP') <> 'CO'
2187          and    wdd.source_line_id = source_rec.source_line_id
2188          and    wdd.source_code = source_rec.source_code
2189          having sum(wdd.requested_quantity) = 0;
2190       EXCEPTION
2191         WHEN NO_DATA_FOUND THEN
2192              l_req_qty := 99;
2193       END;
2194 
2195       IF l_req_qty = 0 THEN
2196          FND_MESSAGE.SET_NAME('WSH','WSH_REQ_ZERO_OUTSIDE_ERROR');
2197          l_source_line_id := source_rec.source_line_id;
2198          l_source_code := source_rec.source_code;
2199          raise req_qty_zero;
2200       END IF;
2201   END LOOP;
2202 
2203 --
2204 -- Debug Statements
2205 --
2206 IF l_debug_on THEN
2207 	WSH_DEBUG_SV.pop(l_module_name);
2208 END IF;
2209 --
2210   EXCEPTION
2211 
2212 	WHEN req_qty_zero THEN
2213 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2214 	  FND_MESSAGE.SET_TOKEN('DELIVERY', p_delivery_id);
2215 	  FND_MESSAGE.SET_TOKEN('SOURCE_CODE', l_source_code);
2216 	  FND_MESSAGE.SET_TOKEN('SOURCE_LINE', l_source_line_id);
2217 	  wsh_util_core.add_message(x_return_status);
2218 
2219 --
2220 -- Debug Statements
2221 --
2222 IF l_debug_on THEN
2223 	WSH_DEBUG_SV.logmsg(l_module_name,'REQ_QTY_ZERO exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2224 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:REQ_QTY_ZERO');
2225 END IF;
2226 --
2227 	WHEN others THEN
2228 	  IF c_check_qty_inside_del%ISOPEN THEN
2229 		close c_check_qty_inside_del;
2230 	  END IF;
2231 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2232 	  wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.check_zero_req_confirm');
2233 
2234 --
2235 -- Debug Statements
2236 --
2237 IF l_debug_on THEN
2238 	WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2239 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2240 END IF;
2241 --
2242 END check_zero_req_confirm;
2243 
2244 
2245 --
2246 --  Procedure:	 Get_Disabled_List
2247 --
2248 --  Parameters:	  p_detail_id -- ID for delivery detail
2249 --						p_delivery_id -- delivery the detail is assigned to
2250 --				p_list_type -- 'FORM', will return list of form field names
2251 --							   'TABLE', will return list of table column names
2252 --				x_return_status  -- return status for execution of this API
2253 --				x_msg_count -- number of error message
2254 --				x_msg_data  -- error message if API failed
2255 --
2256 PROCEDURE Get_Disabled_List(
2257   p_delivery_detail_id		   IN	 NUMBER
2258 , p_delivery_id			   IN	NUMBER
2259 , p_list_type						 IN	 VARCHAR2
2260 , x_return_status				OUT NOCOPY	  VARCHAR2
2261 , x_disabled_list				OUT NOCOPY	  WSH_UTIL_CORE.column_tab_type
2262 , x_msg_count						OUT NOCOPY	NUMBER
2263 , x_msg_data						OUT NOCOPY	  VARCHAR2
2264 , p_caller IN VARCHAR2 -- DEFAULT NULL, --public api changes
2265 )
2266 IS
2267 
2268 CURSOR get_delivery_status
2269 IS
2270 SELECT status_code
2271 FROM   wsh_new_deliveries
2272 WHERE  delivery_id = p_delivery_id;
2273 
2274 -- OPM 09/11/00
2275 CURSOR dd_info
2276 IS
2277 SELECT requested_quantity_uom2,
2278 	  nvl(inspection_flag,'N'),
2279 	   released_status,
2280 	   picked_quantity,
2281 	   container_flag,
2282 	   organization_id,
2283 	   inventory_item_id,
2284 	   pickable_flag,
2285 	   subinventory,
2286            source_code,
2287            inventory_item_id,
2288            nvl(line_direction,'O') line_direction   -- J-IB-NPARIKH
2289 FROM wsh_delivery_details
2290 WHERE delivery_detail_id = p_delivery_detail_id;
2291 
2292 -- end of OPM 09/11/00
2293 
2294 l_status_code			  VARCHAR2(2);
2295 -- OPM 09/11/00 variables to hold value of qty_uom2
2296 l_qty_uom2					  VARCHAR2(3);
2297 -- end of OPM 09/11/00
2298 i								NUMBER := 0;
2299 WSH_DP_NO_ENTITY		  EXCEPTION;
2300 WSH_DEL_NOT_EXIST				EXCEPTION; -- Bug fix 2650464
2301 WSH_INV_LIST_TYPE		 EXCEPTION;
2302 l_msg_summary		   VARCHAR2(2000) := NULL;
2303 l_msg_details		   VARCHAR2(4000) := NULL;
2304 l_inspection_flag	   VARCHAR2(1)	:= NULL;
2305 l_released_status	   VARCHAR2(1)	:= NULL;
2306 l_picked_quantity	   NUMBER;
2307 l_container_flag		VARCHAR2(1)   := 'N';
2308 l_organization_id	   NUMBER;
2309 l_item_id			   NUMBER;
2310 l_pickable_flag		 VARCHAR2(1);
2311 l_subinventory		  VARCHAR2(30);
2312 l_line_direction      VARCHAR2(30);
2313 l_inv_controls		  WSH_DELIVERY_DETAILS_INV.inv_control_flag_rec;
2314 
2315 -- BUG FIX 2887330
2316 l_inventory_item_id      NUMBER;
2317 l_reservable_flag        VARCHAR2(1);
2318 l_source_code            VARCHAR2(30);
2319 l_delivery_detail_id	NUMBER;
2320 l_delivery_id		NUMBER;
2321 l_debug_on BOOLEAN;
2322 
2323 e_all_disabled EXCEPTION ; --public api changes
2324 
2325 --
2326 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_DISABLED_LIST';
2327 --
2328 BEGIN
2329    --
2330    -- Debug Statements
2331    --
2332    --
2333    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2334    --
2335    IF l_debug_on IS NULL
2336    THEN
2337 	   l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2338    END IF;
2339    --
2340    IF l_debug_on THEN
2341 	   WSH_DEBUG_SV.push(l_module_name);
2342 	   --
2343 	   WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',P_DELIVERY_DETAIL_ID);
2344 	   WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_ID',P_DELIVERY_ID);
2345 	   WSH_DEBUG_SV.log(l_module_name,'P_LIST_TYPE',P_LIST_TYPE);
2346    END IF;
2347    --
2348    x_return_status := FND_API.G_RET_STS_SUCCESS;
2349    -- clear the disabled list first
2350    x_disabled_list.delete;
2351    -- OPM 09/11/00
2352    OPEN dd_info;
2353    FETCH dd_info
2354    INTO l_qty_uom2,
2355 		l_inspection_flag,
2356 		l_released_status,
2357 		l_picked_quantity,
2358 		l_container_flag,l_organization_id,
2359 		l_item_id, l_pickable_flag, l_subinventory,
2360                 l_source_code, l_inventory_item_id, l_line_direction;
2361 
2362    IF (dd_info%NOTFOUND) THEN
2363 	  CLOSE dd_info ;
2364 	  RAISE wsh_dp_no_entity;
2365    END IF;
2366    CLOSE dd_info ;
2367    --
2368    -- J-IB-NPARIKH-{
2369    --
2370    IF l_line_direction NOT IN ('O','IO')
2371    THEN
2372    --{
2373         --
2374         i:=i+1; x_disabled_list(i) := 'FULL';
2375         --
2376         IF l_released_status = 'X'
2377         THEN
2378         --{
2379             i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2380             i:=i+1; x_disabled_list(i) := 'TP_FLEXFIELD';
2381             i:=i+1; x_disabled_list(i) := 'SHIPPING_INSTRUCTIONS';
2382             i:=i+1; x_disabled_list(i) := 'PACKING_INSTRUCTIONS';
2383             i:=i+1; x_disabled_list(i) := 'TRACKING_NUMBER';
2384             i:=i+1; x_disabled_list(i) := 'GROSS_WEIGHT';
2385             i:=i+1; x_disabled_list(i) := 'TARE_WEIGHT';
2386             i:=i+1; x_disabled_list(i) := 'NET_WEIGHT';
2387             i:=i+1; x_disabled_list(i) := 'VOLUME';
2388         --}
2389         ELSIF l_released_status IN ('C','L','P')
2390         THEN
2391         --{
2392             i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2393             i:=i+1; x_disabled_list(i) := 'TP_FLEXFIELD';
2394             i:=i+1; x_disabled_list(i) := 'GROSS_WEIGHT';
2395             i:=i+1; x_disabled_list(i) := 'TARE_WEIGHT';
2396             i:=i+1; x_disabled_list(i) := 'NET_WEIGHT';
2397             i:=i+1; x_disabled_list(i) := 'VOLUME';
2398             --
2399             IF l_released_status = 'C'
2400             THEN
2401                 i:=i+1; x_disabled_list(i) := 'TRACKING_NUMBER';
2402             END IF;
2403         --}
2404         END IF;
2405         --
2406        IF l_debug_on THEN
2407           WSH_DEBUG_SV.pop(l_module_name);
2408        END IF;
2409        --
2410        RETURN;
2411    --}
2412    END IF;
2413    --
2414    -- J-IB-NPARIKH-}
2415    --
2416 
2417    IF l_debug_on THEN
2418       WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.GET_RESERVABLE_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
2419    END IF;
2420 
2421    l_reservable_flag :=  WSH_DELIVERY_DETAILS_INV.get_reservable_flag(
2422                              x_item_id => l_inventory_item_id,
2423                              x_organization_id => l_organization_id,
2424                              x_pickable_flag => l_pickable_flag);
2425      if l_debug_on then
2426         wsh_debug_sv.log(l_module_name, 'l_reservable_flag', l_reservable_flag);
2427         wsh_debug_sv.log(l_module_name, 'l_pickable_flag', l_pickable_flag);
2428         wsh_debug_sv.log(l_module_name, 'l_source_code', l_source_code);
2429      end if;
2430 
2431    -- If delivery line is released to warehouse, shipped, or deleted,
2432    -- disable its fields.
2433    -- :Bug #2586286  : Enabled the DESC_FLEX even when relead_status 'C' or 'D'
2434    IF (l_released_status IN ('S', 'C', 'D')) THEN
2435 	  i:=i+1; x_disabled_list(i) := 'FULL';
2436 	  i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2437           if l_debug_on then
2438             wsh_debug_sv.log(l_module_name, 'l_released_status', l_released_status);
2439             wsh_debug_sv.log(l_module_name, 'l_picked_quantity', l_picked_quantity);
2440           end if;
2441 	  IF ( l_released_status = 'S'
2442 		   AND l_picked_quantity IS NULL) THEN
2443 		 -- can update some fields if the delivery line
2444 		 -- is released to warehouse and is not pending overpick.
2445 		 i:=i+1; x_disabled_list(i) := 'TP_FLEXFIELD';
2446 		 --i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2447 		 i:=i+1; x_disabled_list(i) := 'SHIPPING_INSTRUCTIONS';
2448 		 i:=i+1; x_disabled_list(i) := 'PACKING_INSTRUCTIONS';
2449 		 i:=i+1; x_disabled_list(i) := 'TRACKING_NUMBER';
2450 		 i:=i+1; x_disabled_list(i) := 'SEAL_CODE';
2451                  --X-dock change, allow update from WMS for X-dock lines
2452                  IF p_caller like 'WMS_XDOCK%' THEN
2453                    i:=i+1; x_disabled_list(i) := 'RELEASED_STATUS';
2454                  END IF;
2455 	  END IF;
2456 	  --
2457 	  -- Debug Statements
2458 	  --
2459 	  IF l_debug_on THEN
2460 		  WSH_DEBUG_SV.pop(l_module_name);
2461 	  END IF;
2462 	  --
2463 	  RETURN;
2464 
2465    END IF;
2466 
2467    IF p_delivery_id is NOT NULL THEN
2468 
2469 	  OPEN get_delivery_status;
2470 	  FETCH get_delivery_status INTO l_status_code;
2471 	  IF (get_delivery_status%NOTFOUND) THEN
2472 		 CLOSE get_delivery_status;
2473 		 -- Bug fix 2650464
2474 		 RAISE WSH_DEL_NOT_EXIST;
2475 	  END IF;
2476 	  CLOSE get_delivery_status;
2477 
2478    END IF;
2479 
2480 
2481    -- OPM 09/11/00  if line is not assigned, need to add OPM attributes to list
2482    IF (p_delivery_id IS NULL) OR (l_status_code IN ('OP','PA', 'SA')) THEN
2483 
2484 	  -- disabling the gross and tare weights for non-container items
2485 	  -- bug fix 2061295
2486 
2487 	  -- commenting the gross weight to make it enable for non-container items
2488 	  -- for the bug #2554087
2489           -- Commenting the Tare Weight Field to make it enable for
2490           -- non-container items for bug 2890559
2491 /*
2492 	  IF (l_container_flag = 'N') THEN
2493 	--   i := i+1; x_disabled_list(i) := 'GROSS_WEIGHT';
2494 		 i := i+1; x_disabled_list(i) := 'TARE_WEIGHT';
2495 	  END IF;
2496 */
2497 
2498 	  IF (l_released_status NOT IN ('X', 'Y')) THEN
2499 
2500 		 i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY';
2501 		 i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY2';
2502 
2503 	  END IF;  -- if l_released_status...
2504 
2505 	  IF (l_qty_uom2 is NULL) THEN
2506 		 i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY2';
2507 		 i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY2';
2508 		 i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY2';
2509 		 i:=i+1; x_disabled_list(i) := 'CYCLE_COUNT_QUANTITY2';
2510 	  END IF;
2511 
2512 	  IF (l_inspection_flag = 'N') THEN
2513 		 i:=i+1; x_disabled_list(i) := 'INSPECTION_FLAG';
2514 	  END IF;
2515 
2516         -- LPN sync-up
2517         IF (l_container_flag = 'N') THEN
2518 		i:=i+1; x_disabled_list(i) := 'CONTAINER_NAME';
2519 		i:=i+1; x_disabled_list(i) := 'LPN_ID';
2520         END IF;
2521 
2522         -- R12 MDC
2523 	IF l_container_flag = 'C'  and NVL(p_caller, 'WSH_FSTRX') not like 'WMS%' THEN
2524 	   i:=i+1; x_disabled_list(i) := 'NET_WEIGHT';
2525 	END IF;
2526         --
2527 
2528 	ELSIF p_delivery_id is not NULL THEN
2529 
2530 	  IF (l_status_code = 'PA') THEN
2531 		 i:=i+1; x_disabled_list(i) := 'CONTAINER_NAME';
2532  		 -- LPN sync-up
2533         	 IF (l_container_flag = 'N') THEN
2534 			i:=i+1; x_disabled_list(i) := 'LPN_ID';
2535              END IF;
2536 
2537 		 IF NVL(p_caller,'!!!') LIKE 'FTE%' THEN --public api changes
2538                     i:=i+1; x_disabled_list(i) := 'MASTER_CONTAINER_ITEM_ID';
2539                     i:=i+1; x_disabled_list(i) := 'DETAIL_CONTAINER_ITEM_ID';
2540 		 ELSE
2541                     i:=i+1; x_disabled_list(i) := 'MASTER_CONTAINER_ITEM_NAME';
2542                     i:=i+1; x_disabled_list(i) := 'DETAIL_CONTAINER_ITEM_NAME';
2543 		 END IF;
2544 		 i:=i+1; x_disabled_list(i) := 'LOAD_SEQ_NUMBER';
2545 
2546 		 /* H integration: 940 data protection  wrudge */
2547 	  ELSIF (l_status_code IN ('SR', 'SC')) THEN
2548 		 i:=i+1; x_disabled_list(i) := 'FULL';
2549 		 i:=i+1; x_disabled_list(i) := 'TP_FLEXFIELD';
2550 		 i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2551 		 i:=i+1; x_disabled_list(i) := 'SHIPPING_INSTRUCTIONS';
2552 		 i:=i+1; x_disabled_list(i) := 'PACKING_INSTRUCTIONS';
2553 		 i:=i+1; x_disabled_list(i) := 'TRACKING_NUMBER';
2554 		 i:=i+1; x_disabled_list(i) := 'SEAL_CODE';
2555 	  ELSIF (l_status_code IN ('CO', 'IT', 'CL')) THEN
2556 		 i:=i+1; x_disabled_list(i) := 'FULL';
2557 		 i:=i+1; x_disabled_list(i) := 'TP_FLEXFIELD';
2558 		 i:=i+1; x_disabled_list(i) := 'DESC_FLEX';
2559 		 IF (l_status_code = 'IT') THEN
2560 			i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY';
2561 			-- LPN sync-up
2562              	IF (nvl(l_container_flag, 'N') = 'N') THEN
2563 				i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY';
2564 			END IF;
2565 
2566 			-- OPM 09/11/00
2567 			-- if process_org, then add the following to the list
2568 			IF (l_qty_uom2 is NOT NULL) THEN
2569 			   -- LPN sync-up
2570              	   IF (nvl(l_container_flag, 'N') = 'N') THEN
2571 			   	i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY2';
2572 			   	i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY2';
2573 			   END IF;
2574 			END IF;
2575 
2576 		 ELSIF (l_status_code = 'CO') THEN
2577 			i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY';
2578 			-- LPN sync-up
2579              	IF (nvl(l_container_flag, 'N') = 'N') THEN
2580 				i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY';
2581 			END IF;
2582 			i:=i+1; x_disabled_list(i) := 'SHIPPING_INSTRUCTIONS';
2583 			i:=i+1; x_disabled_list(i) := 'TRACKING_NUMBER';
2584 			i:=i+1; x_disabled_list(i) := 'SEAL_CODE';
2585 			IF (l_qty_uom2 is NOT NULL) THEN
2586 				-- LPN sync-up
2587              		IF (nvl(l_container_flag, 'N') = 'N') THEN
2588 			   		i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY2';
2589 			   		i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY2';
2590 				END IF;
2591 			END IF;
2592 			-- OPM 09/11/00
2593 		 END IF;
2594 	  END IF;  -- (l_status_code = 'PA')
2595 
2596    END IF; -- assigned to delviery
2597 
2598    -- bug 2263249 - added SHIPPED_QUANTITY, SHIPPED_QUANTITY2, CYCLE_COUNT_QUANTITY, and CYCLE_COUNT_QUANTITY2
2599    --			   to disable_list when organization is wms enabled.
2600    IF ((i = 0) OR (i > 0 AND x_disabled_list(1) <> 'FULL') ) THEN
2601 	  --
2602 	  -- Debug Statements
2603 	  --
2604 	  IF l_debug_on THEN
2605 		  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.CHECK_WMS_ORG',WSH_DEBUG_SV.C_PROC_LEVEL);
2606 	  END IF;
2607 	  --
2608 	  IF (wsh_util_validate.Check_Wms_Org(l_organization_id)='Y') THEN
2609              -- Bug fix 2887330
2610              -- Disable shipped qty only if item is reservable, transactable and has source code = OM
2611              -- Or in otherwords, shipped qty should be enabled if item is
2612              -- non-reservable OR item is non-transactable OR has source code <> OM
2613              IF l_pickable_flag = 'Y' AND
2614                 l_reservable_flag = 'Y' AND
2615                 l_source_code = 'OE'
2616              THEN
2617 		 i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY';
2618              END IF;
2619 		 i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY2';
2620 		 i:=i+1; x_disabled_list(i) := 'CYCLE_COUNT_QUANTITY';
2621 		 i:=i+1; x_disabled_list(i) := 'CYCLE_COUNT_QUANTITY2';
2622 
2623  		 -- LPN sync-up
2624              IF (nvl(l_container_flag, 'N') IN ('Y','C')) THEN
2625 			i:=i+1; x_disabled_list(i) := 'CONTAINER_NAME';
2626 		 END IF;
2627 
2628 	  END IF;
2629           -- J: W/V Changes
2630           IF l_container_flag = 'N' THEN
2631              i:=i+1; x_disabled_list(i) := 'FILLED_VOLUME';
2632              i:=i+1; x_disabled_list(i) := 'FILL_PERCENT';
2633           END IF;
2634 
2635    END IF;
2636 
2637    -- LPN sync-up
2638    IF ((i = 0) OR (i > 0 AND x_disabled_list(1) <> 'FULL') ) THEN
2639 	i := x_disabled_list.COUNT;
2640 	IF (nvl(l_container_flag, 'N') IN ('Y','C')) THEN
2641 		i:=i+1; x_disabled_list(i) := 'PREFERED_GRADE';
2642 		i:=i+1; x_disabled_list(i) := 'SRC_REQUESTED_QUANTITY2';
2643 		i:=i+1; x_disabled_list(i) := 'SRC_REQUESTED_QUANTITY_UOM2';
2644 		i:=i+1; x_disabled_list(i) := 'REQUESTED_QUANTITY2';
2645 		i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY2';
2646 		i:=i+1; x_disabled_list(i) := 'DELIVERED_QUANTITY2';
2647 		i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY2';
2648 		i:=i+1; x_disabled_list(i) := 'QUALITY_CONTROL_QUANTITY2';
2649 		i:=i+1; x_disabled_list(i) := 'CYCLE_COUNT_QUANTITY2';
2650 		i:=i+1; x_disabled_list(i) := 'REQUESTED_QUANTITY_UOM2';
2651 		i:=i+1; x_disabled_list(i) := 'SUBLOT_NUMBER';
2652 		i:=i+1; x_disabled_list(i) := 'RETURNED_QUANTITY2';
2653 		i:=i+1; x_disabled_list(i) := 'RECEIVED_QUANTITY2';
2654 		i:=i+1; x_disabled_list(i) := 'PICKED_QUANTITY2';
2655 		i:=i+1; x_disabled_list(i) := 'TO_SERIAL_NUMBER';
2656 		i:=i+1; x_disabled_list(i) := 'SERIAL_NUMBER';
2657 		i:=i+1; x_disabled_list(i) := 'TRANSACTION_TEMP_ID';
2658 		i:=i+1; x_disabled_list(i) := 'SHIPPED_QUANTITY';
2659 		i:=i+1; x_disabled_list(i) := 'CANCELLED_QUANTITY';
2660 		i:=i+1; x_disabled_list(i) := 'CYCLE_COUNT_QUANTITY';
2661 		i:=i+1; x_disabled_list(i) := 'REVISION';
2662 		i:=i+1; x_disabled_list(i) := 'LOT_NUMBER';
2663 		i:=i+1; x_disabled_list(i) := 'REQUESTED_QUANTITY_UOM';
2664 		i:=i+1; x_disabled_list(i) := 'SUBINVENTORY';
2665 		IF nvl(p_caller, '!!!') LIKE 'FTE%' THEN
2666 			i:=i+1; x_disabled_list(i) := 'LOCATOR_ID';
2667 		ELSE
2668 			i:=i+1; x_disabled_list(i) := 'LOCATOR_NAME';
2669 		END IF;
2670 	END IF;
2671 
2672    END IF;
2673    -- end bug 2263249
2674 
2675     -- J-IB-NPARIKH-{
2676     -- public api changes
2677     --
2678     -- Update on inbound/drop-ship lines are allowed only if caller
2679     -- starts with  one of the following:
2680     --     - FTE
2681     --     - WSH_IB
2682     --     - WSH_PUB
2683     --     - WSH_TP_RELEASE
2684     --
2685     IF  NVL(l_line_direction,'O') NOT IN   ('O','IO')
2686     AND NVL(p_caller, '!!!') NOT LIKE 'FTE%'
2687     AND NVL(p_caller, '!!!') NOT LIKE 'WSH_PUB%'
2688     AND NVL(p_caller, '!!!') NOT LIKE 'WSH_IB%'
2689     AND NVL(p_caller, '!!!') NOT LIKE 'WSH_TP_RELEASE%'
2690     THEN
2691         RAISE e_all_disabled;
2692     END IF;
2693     --
2694     -- J-IB-NPARIKH-}
2695 
2696     IF l_debug_on THEN
2697         WSH_DEBUG_SV.log(l_module_name,'count of x_disabled_list', x_disabled_list.COUNT);
2698     END IF;
2699   -- public api changes
2700   IF (x_disabled_list.COUNT = 0) or (x_disabled_list(1) <> 'FULL') THEN
2701       i :=  x_disabled_list.COUNT;
2702 
2703       IF (l_released_status = 'Y')  THEN
2704 
2705          IF (WSH_DELIVERY_DETAILS_INV.get_reservable_flag(x_item_id => l_item_id,
2706                                                           x_organization_id => l_organization_id,
2707                                                           x_pickable_flag => l_pickable_flag) = 'Y')
2708          THEN
2709 
2710              i:=i+1; x_disabled_list(i) := 'SUBINVENTORY';
2711              i:=i+1; x_disabled_list(i) := 'REVISION';
2712 	     IF NVL(p_caller,'!!!') LIKE 'FTE%' THEN --public api changes
2713                 i:=i+1; x_disabled_list(i) := 'LOCATOR_ID';
2714 	     ELSE
2715                 i:=i+1; x_disabled_list(i) := 'LOCATOR_NAME';
2716 	     END IF;
2717              i:=i+1; x_disabled_list(i) := 'LOT_NUMBER';
2718 
2719          ELSE
2720             -- Added for bug 4399278, 4418754
2721             -- Copy Subinventory passed from public API
2722             IF ( G_SUBINVENTORY is not null ) THEN
2723                l_subinventory := G_SUBINVENTORY;
2724                G_SUBINVENTORY := NULL;
2725             END IF;
2726 
2727 
2728             WSH_DELIVERY_DETAILS_INV.Fetch_Inv_Controls(p_delivery_detail_id => p_delivery_detail_id,
2729                                                         p_inventory_item_id => l_item_id,
2730                                                         p_organization_id => l_organization_id,
2731                                                         p_subinventory => l_subinventory,
2732                                                         x_inv_controls_rec => l_inv_controls,
2733                                                         x_return_status => x_return_status);
2734 
2735             IF l_inv_controls.rev_flag = 'N' THEN
2736 
2737                i:=i+1; x_disabled_list(i) := 'REVISION';
2738 
2739             END IF;
2740             IF l_inv_controls.loc_flag = 'N' THEN
2741 
2742 	     IF NVL(p_caller,'!!!') LIKE 'FTE%' THEN --public api changes
2743                 i:=i+1; x_disabled_list(i) := 'LOCATOR_ID';
2744 	     ELSE
2745                 i:=i+1; x_disabled_list(i) := 'LOCATOR_NAME';
2746 	     END IF;
2747 
2748 
2749             END IF;
2750             IF l_inv_controls.lot_flag = 'N' THEN
2751 
2752              i:=i+1; x_disabled_list(i) := 'LOT_NUMBER';
2753 
2754             END IF;
2755 
2756          END IF;
2757 
2758       END IF;  -- if l_released_status...
2759 
2760     END IF;
2761 
2762 --
2763 -- Debug Statements
2764 --
2765 IF l_debug_on THEN
2766 	WSH_DEBUG_SV.pop(l_module_name);
2767 END IF;
2768 --
2769 	EXCEPTION
2770 	    WHEN e_all_disabled THEN --public api changes
2771 	      x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2772 	      FND_MESSAGE.SET_NAME('WSH','WSH_ALL_COLS_DISABLED');
2773 	      FND_MESSAGE.Set_Token('ENTITY_ID',p_delivery_detail_id);
2774 	      wsh_util_core.add_message(x_return_status,l_module_name);
2775 	      IF l_debug_on THEN
2776 		-- Nothing is updateable
2777 		WSH_DEBUG_SV.pop(l_module_name,'e_all_disabled');
2778 	      END IF;
2779 
2780 		WHEN wsh_dp_no_entity THEN
2781 			x_return_status := FND_API.G_RET_STS_ERROR;
2782 			-- Bug fix 2650464
2783 			-- new message for invalid delivery details
2784 			FND_MESSAGE.SET_NAME('WSH', 'WSH_DETAIL_NOT_EXIST');
2785                         IF p_delivery_detail_id = FND_API.G_MISS_NUM THEN
2786                          l_delivery_detail_id := NULL;
2787 			ELSE
2788 			 l_delivery_detail_id := p_delivery_detail_id;
2789 			END IF;
2790 			FND_MESSAGE.SET_TOKEN('DETAIL_ID', l_delivery_detail_id);
2791 			WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
2792 			WSH_UTIL_CORE.get_messages('Y', l_msg_summary, l_msg_details, x_msg_count);
2793 			IF x_msg_count > 1 then
2794 		 	  x_msg_data := l_msg_summary || l_msg_details;
2795 			ELSE
2796 			  x_msg_data := l_msg_summary;
2797 			END IF;
2798 
2799 --
2800 -- Debug Statements
2801 --
2802 IF l_debug_on THEN
2803 	WSH_DEBUG_SV.logmsg(l_module_name,'WSH_DP_NO_ENTITY exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2804 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_DP_NO_ENTITY');
2805 END IF;
2806 --
2807 		WHEN wsh_del_not_exist THEN  -- Bug fix 2650464
2808 			x_return_status := FND_API.G_RET_STS_ERROR;
2809 			FND_MESSAGE.SET_NAME('WSH', 'WSH_DELIVERY_NOT_EXIST');
2810 			IF p_delivery_id = FND_API.G_MISS_NUM THEN
2811 			  l_delivery_id := NULL;
2812                         ELSE
2813                           l_delivery_id := p_delivery_id;
2814                         END IF;
2815 			FND_MESSAGE.SET_TOKEN('DELIVERY_NAME', l_delivery_id);
2816 			WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
2817 			WSH_UTIL_CORE.get_messages('Y', l_msg_summary, l_msg_details, x_msg_count);
2818 			IF x_msg_count > 1 then
2819 				x_msg_data := l_msg_summary || l_msg_details;
2820 			ELSE
2821 				x_msg_data := l_msg_summary;
2822 			END IF;
2823                         --
2824 			IF l_debug_on THEN
2825 			  WSH_DEBUG_SV.logmsg(l_module_name,'WSH_DEL_NOT_EXIST exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2826 			  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_DP_NO_ENTITY');
2827 			END IF;
2828 
2829 		WHEN wsh_inv_list_type THEN
2830 			x_return_status := FND_API.G_RET_STS_ERROR;
2831 			FND_MESSAGE.SET_NAME('WSH', 'WSH_INV_LIST_TYPE');
2832 			WSH_UTIL_CORE.ADD_MESSAGE(x_return_status);
2833 			WSH_UTIL_CORE.get_messages('Y', l_msg_summary, l_msg_details, x_msg_count);
2834 			IF x_msg_count > 1 then
2835 				x_msg_data := l_msg_summary || l_msg_details;
2836 			ELSE
2837 				x_msg_data := l_msg_summary;
2838 			END IF;
2839 
2840 --
2841 -- Debug Statements
2842 --
2843 IF l_debug_on THEN
2844 	WSH_DEBUG_SV.logmsg(l_module_name,'WSH_INV_LIST_TYPE exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2845 	WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INV_LIST_TYPE');
2846 END IF;
2847 --
2848 		 WHEN others THEN
2849 			IF (get_delivery_status%ISOPEN) THEN
2850 				CLOSE get_delivery_status;
2851 			END IF;
2852 			wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.get_disabled_list');
2853 		   x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2854 
2855 
2856 	--
2857 	-- Debug Statements
2858 	--
2859 	IF l_debug_on THEN
2860 		WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2861 		WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2862 	END IF;
2863 	--
2864 END Get_Disabled_list;
2865 
2866 
2867 --
2868 -- PROCEDURE - Get_Min_Max_Tolerance_Quantity
2869 -- Bug 2181132
2870 --
2871 -- Description - This API is created to take owner ship of Tolerance from OM
2872 -- Parameters are
2873 --  p_in_attributes - In record of type MinMaxInRecType
2874 --        action_flag values:
2875 --              'P' - Pick confirm (always populate ship_tolerance_above etc.)
2876 --              'S' - Ship confirm (always populate ship_tolerance_above etc.)
2877 --              'C' - CTO / call from WSH_INTEGRATION API
2878 --              'I' - call from OM Interface (check_tolerance)
2879 --  x_out_attributes - Out record of type MinMaxOutRecType
2880 --  p_inout_attributes - In Out record of type MinMaxInOutRecType
2881 --  x_return_status - return status
2882 --  x_msg_count - Message Count
2883 --  x_msg_data - Message Data
2884 --
2885 
2886 PROCEDURE Get_Min_Max_Tolerance_Quantity
2887 	( p_in_attributes	IN	         MinMaxInRecType,
2888 	  x_out_attributes	   OUT NOCOPY	 MinMaxOutRecType,
2889 	  p_inout_attributes	IN OUT NOCOPY    MinMaxInOutRecType,
2890 	  x_return_status	   OUT NOCOPY	 VARCHAR2,
2891 	  x_msg_count		   OUT NOCOPY	 NUMBER,
2892 	  x_msg_data		   OUT NOCOPY	 VARCHAR2
2893 	)
2894 IS
2895   l_quantity_uom	     VARCHAR2(3);
2896   l_min_remaining_quantity   NUMBER;
2897   l_max_remaining_quantity   NUMBER;
2898   l_quantity2_uom	     VARCHAR2(3);
2899   l_min_remaining_quantity2  NUMBER;
2900   l_max_remaining_quantity2  NUMBER;
2901   l_shipped_quantity	     NUMBER;
2902   l_shipped_quantity2	     NUMBER;
2903 
2904   -- cannot combine Cursor 1 and 2 because of <> line_id clause
2905   -- Get the sum within line set id
2906   -- HW added requested_quantity2
2907   CURSOR c_sum_ordered_qty(x_header_id IN NUMBER, x_line_set_id IN NUMBER) IS
2908   SELECT SUM(requested_quantity),
2909          SUM(NVL(requested_quantity2,0))
2910 	FROM  wsh_delivery_details
2911    WHERE  source_line_set_id = x_line_set_id
2912 	 AND  source_code = p_in_attributes.source_code
2913 	 AND  container_flag = 'N'
2914 	 AND  released_status <> 'D'
2915 	 AND  source_header_id = x_header_id;
2916 
2917   -- Get the sum within line set id for staged and shipped lines
2918   -- but with different source_line_id
2919   -- same for shipped or picked lines
2920   -- HW added qty2
2921   CURSOR c_sum_picked_qty(x_header_id IN NUMBER, x_line_set_id IN NUMBER) IS
2922   SELECT nvl(SUM(GREATEST(nvl(shipped_quantity,0),
2923 			 nvl(picked_quantity,requested_quantity))),0),
2924 	 nvl(SUM(GREATEST(nvl(shipped_quantity2,0),
2925 			 nvl(picked_quantity2,requested_quantity2))),0)
2926 	FROM wsh_delivery_details
2927    WHERE  source_line_set_id = x_line_set_id
2928 	 AND released_status <> 'D'
2929 	 AND source_line_id <> p_in_attributes.line_id
2930 	 AND source_code = p_in_attributes.source_code
2931 	 AND  container_flag = 'N'
2932 	 AND source_header_id = x_header_id;
2933 
2934   -- bug 4319050: CTO can call before the line actually gets interfaced.
2935   -- get the total quantity that has left the warehouse.
2936   --   oe_interfaced_flag is not checked because we are looking
2937   --   at the single line; if it were interfaced at this time,
2938   --   the line would not be split (since line_set_id has to be NULL
2939   --   to use this cursor) and therefore the source line is fulfilled.
2940   CURSOR c_sum_line_shp_qty IS
2941   SELECT NVL(SUM(shipped_quantity), 0)
2942   FROM wsh_delivery_details
2943   WHERE  source_line_id = p_in_attributes.line_id
2944   AND  released_status = 'C'
2945   AND  source_code = p_in_attributes.source_code
2946   AND  container_flag = 'N';
2947 
2948 
2949   -- this is a line set version of c_sum_line_shp_qty
2950   --  sum the current line's shipped quantities
2951   --  and those of only the interfaced lines in the set.
2952   CURSOR c_sum_line_set_shp_qty(x_header_id   IN NUMBER,
2953                                 x_line_set_id IN NUMBER) IS
2954   SELECT NVL(SUM(shipped_quantity), 0)
2955   FROM wsh_delivery_details
2956   WHERE source_code = p_in_attributes.source_code
2957   AND released_status = 'C'
2958   AND (
2959           source_line_id = p_in_attributes.line_id
2960        OR oe_interfaced_flag = 'Y'
2961       )
2962   AND container_flag = 'N'
2963   AND source_header_id = x_header_id
2964   AND source_line_set_id = x_line_set_id;
2965 
2966 
2967   -- bug 5196082: ITS needs to recognize the full quantity shipped
2968   -- regardless of oe_interfaced_flag value.
2969   -- this cursor is copied from  c_sum_line_set_shp_qty
2970   -- and modified to total all shipped details in the line set.
2971   CURSOR c_sum_line_set_shp_qty_ITS(x_header_id   IN NUMBER,
2972                                     x_line_set_id IN NUMBER) IS
2973   SELECT NVL(SUM(shipped_quantity), 0)
2974   FROM wsh_delivery_details
2975   WHERE source_code = p_in_attributes.source_code
2976   AND released_status = 'C'
2977   AND container_flag = 'N'
2978   AND source_header_id = x_header_id
2979   AND source_line_set_id = x_line_set_id;
2980 
2981 
2982   -- get delivery details information for CTO which will pass
2983   -- source_line_id and source_code
2984   CURSOR c_get_details_CTO IS
2985 	SELECT ship_tolerance_below,
2986 		   ship_tolerance_above,
2987 		   source_line_set_id,
2988 		   source_header_id,
2989 		   src_requested_quantity_uom,
2990 		   inventory_item_id,
2991 		   requested_quantity_uom
2992 	  FROM wsh_delivery_details
2993 	 WHERE source_line_id = p_in_attributes.line_id
2994 	   AND container_flag = 'N'
2995 	   AND released_status <> 'D'
2996 	   AND source_code = p_in_attributes.source_code
2997 	   AND rownum = 1;
2998 
2999   -- Get the total ordered quantity, when the line set id is NULL
3000 
3001   -- HW added requested_quantity2
3002 
3003   CURSOR c_sum_ordered_qty1(x_header_id number) IS
3004   SELECT  SUM(requested_quantity),
3005           SUM(NVL(requested_quantity2,0))
3006 	FROM  wsh_delivery_details
3007    WHERE  source_line_id =p_in_attributes.line_id
3008 	 AND  source_code = p_in_attributes.source_code
3009 	 AND  container_flag = 'N'
3010 	 AND  released_status <> 'D'
3011 	 AND  source_header_id = x_header_id;
3012 
3013   -- Lock the Delivery Details within a line set
3014   CURSOR c_lock_delivery_det(x_header_id IN NUMBER,
3015                            x_line_set_id IN NUMBER) IS
3016 	SELECT delivery_detail_id
3017 	  FROM wsh_delivery_details
3018 	 WHERE source_line_set_id = x_line_set_id
3019 	   AND source_code = p_in_attributes.source_code
3020 	   AND source_header_id = x_header_id
3021          FOR UPDATE;
3022 
3023   -- Lock the Delivery Details within a source line id
3024   CURSOR c_lock_delivery_det1 IS
3025 	SELECT delivery_detail_id
3026 	  FROM wsh_delivery_details
3027 	 WHERE source_line_id = p_in_attributes.line_id
3028 	   FOR UPDATE;
3029 
3030   l_ship_tolerance_above        NUMBER;
3031   l_ship_tolerance_below        NUMBER;
3032   l_source_line_set_id          NUMBER;
3033   l_source_header_id            NUMBER;
3034   l_req_quantity_uom            VARCHAR2(3);
3035   l_req_quantity_uom2           VARCHAR2(3);
3036   l_shipping_quantity_uom       VARCHAR2(3);
3037   l_del_shipping_quantity       NUMBER;
3038   -- HW added l_del_shipping_quantity2
3039   l_del_shipping_quantity2      NUMBER;
3040   l_OPM_shipped_quantity        NUMBER(19,9);
3041   l_OPM_shipping_quantity_uom   VARCHAR2(4);
3042   l_OPM_order_quantity_uom      VARCHAR2(4);
3043   l_inventory_item_id           NUMBER;
3044   l_delivery_detail_id          NUMBER;
3045   l_total_ordered_quantity      NUMBER;
3046   l_total_ordered_quantity2     NUMBER;
3047   l_tolerance_quantity_below    NUMBER;
3048   l_tolerance_quantity_above    NUMBER;
3049   l_tolerance_quantity_below2   NUMBER;
3050   l_tolerance_quantity_above2   NUMBER;
3051   -- csun max_tol chnage
3052   l_ordered_quantity_uom    wsh_delivery_details.SRC_REQUESTED_QUANTITY_UOM%TYPE;
3053   l_requested_quantity_uom  wsh_delivery_details.REQUESTED_QUANTITY_UOM%TYPE;
3054   l_requested_quantity_uom2  wsh_delivery_details.REQUESTED_QUANTITY_UOM2%TYPE;
3055 --
3056 l_debug_on BOOLEAN;
3057 --
3058 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_MIN_MAX_TOLERANCE_QUANTITY';
3059 --
3060 BEGIN
3061 -- Bug 2181132
3062   --
3063   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3064   --
3065   IF l_debug_on IS NULL
3066   THEN
3067     l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3068   END IF;
3069   --
3070   x_return_status := FND_API.G_RET_STS_SUCCESS;
3071 
3072   l_del_shipping_quantity  := 0;
3073   l_del_shipping_quantity2 := 0;
3074 
3075   IF l_debug_on THEN
3076     WSH_DEBUG_SV.push(l_module_name);
3077     WSH_DEBUG_SV.log(l_module_name,'api_version_number',p_in_attributes.api_version_number);
3078     WSH_DEBUG_SV.log(l_module_name,'source_code',p_in_attributes.source_code);
3079     WSH_DEBUG_SV.log(l_module_name,'line_id',p_in_attributes.line_id);
3080     WSH_DEBUG_SV.log(l_module_name,'dummy_quantity',p_inout_attributes.dummy_quantity);
3081     WSH_DEBUG_SV.logmsg(l_module_name, 'Action flag-'||p_in_attributes.action_flag);
3082     WSH_DEBUG_SV.logmsg(l_module_name, 'SHP TOL ABOVE-'||p_in_attributes.ship_tolerance_above);
3083   END IF;
3084 
3085   IF ( p_in_attributes.source_code IS NULL ) THEN
3086     x_msg_count := 1;
3087     x_msg_data := 'INVALID SOURCE_CODE';
3088     x_return_status := FND_API.G_RET_STS_ERROR;
3089   END IF;
3090 
3091   IF p_in_attributes.ship_tolerance_above IS NULL  OR
3092      p_in_attributes.action_flag IN ('C', 'I') THEN
3093 
3094     IF l_debug_on THEN
3095       WSH_DEBUG_SV.logmsg(l_module_name, 'Looking up details');
3096     END IF;
3097 
3098     -- fetch the values for CTO and OM Interface
3099     OPEN c_get_details_CTO;
3100     FETCH c_get_details_CTO
3101     INTO l_ship_tolerance_below,
3102 	 l_ship_tolerance_above,
3103 	 l_source_line_set_id,
3104 	 l_source_header_id,
3105 	 l_ordered_quantity_uom,
3106 	 l_inventory_item_id,
3107 	 l_requested_quantity_uom;
3108     CLOSE c_get_details_CTO;
3109   ELSE
3110     -- these values will be passed from Pick Confirm and Ship Confirm
3111     -- because this is delivery line information and should be
3112     -- available without extra SELECT
3113     l_ship_tolerance_below    := p_in_attributes.ship_tolerance_below;
3114     l_ship_tolerance_above    := p_in_attributes.ship_tolerance_above;
3115     l_source_line_set_id      := p_in_attributes.source_line_set_id;
3116     l_source_header_id        := p_in_attributes.source_header_id;
3117     l_requested_quantity_uom  := p_in_attributes.quantity_uom;
3118     l_requested_quantity_uom2 := p_in_attributes.quantity_uom2;
3119 
3120   END IF;
3121 
3122   IF l_debug_on THEN
3123     WSH_DEBUG_SV.log(l_module_name, 'l_source_header_id', l_source_header_id);
3124     WSH_DEBUG_SV.log(l_module_name, 'l_source_line_set_id', l_source_line_set_id);
3125     WSH_DEBUG_SV.log(l_module_name, 'SHP TOL ABOVE',l_ship_tolerance_above);
3126     WSH_DEBUG_SV.log(l_module_name, 'SHP TOL BELOW',l_ship_tolerance_below);
3127   END IF;
3128 
3129 
3130   -- bug 3511424
3131   -- Locking the delivery lines within a line set or source line id
3132   -- if not done already by calling API
3133   IF (p_in_attributes.lock_flag = 'Y') THEN
3134     IF (l_source_line_set_id IS NOT NULL) THEN
3135 
3136       FOR rec in c_lock_delivery_det(l_source_header_id, l_source_line_set_id)
3137       LOOP
3138 	l_delivery_detail_id := rec.delivery_detail_id;
3139       END LOOP;
3140     ELSIF (p_in_attributes.line_id IS NOT NULL) THEN
3141       FOR rec in c_lock_delivery_det1
3142       LOOP
3143 	l_delivery_detail_id := rec.delivery_detail_id;
3144       END LOOP;
3145     END IF;
3146   END IF;
3147 
3148   --Line set Id is not null
3149   IF  l_source_line_set_id IS NOT NULL THEN
3150     OPEN c_sum_ordered_qty(l_source_header_id, l_source_line_set_id);
3151     FETCH c_sum_ordered_qty
3152     INTO l_total_ordered_quantity,
3153 	 l_total_ordered_quantity2;
3154     CLOSE c_sum_ordered_qty;
3155 
3156     IF l_debug_on THEN
3157       WSH_DEBUG_SV.logmsg(l_module_name, 'Ordered_qty-'||l_total_ordered_quantity);
3158       WSH_DEBUG_SV.logmsg(l_module_name, 'Ordered_qty2-'||l_total_ordered_quantity2);
3159     END IF;
3160 
3161     IF p_in_attributes.ship_tolerance_above IS NOT NULL THEN  -- Pick Confirm
3162       x_out_attributes.min_remaining_quantity := 0;
3163 
3164       OPEN  c_sum_picked_qty(l_source_header_id, l_source_line_set_id);
3165       FETCH c_sum_picked_qty
3166       INTO l_del_shipping_quantity,
3167 	   l_del_shipping_quantity2;
3168       CLOSE c_sum_picked_qty;
3169 
3170       IF l_debug_on THEN
3171         WSH_DEBUG_SV.logmsg(l_module_name, 'l_del_shipping_qty-'||l_del_shipping_quantity);
3172         WSH_DEBUG_SV.logmsg(l_module_name, 'l_del_shipping_qty2-'||l_del_shipping_quantity2);
3173       END IF;
3174 
3175     END IF;
3176 
3177   ELSE	 --if source line set id is not null
3178     -- HW added l_total_ordered_quantity2
3179     OPEN c_sum_ordered_qty1(l_source_header_id);
3180     FETCH c_sum_ordered_qty1
3181     INTO l_total_ordered_quantity,
3182          l_total_ordered_quantity2;
3183     CLOSE c_sum_ordered_qty1;
3184 
3185   END IF;  --source_line set id is not null
3186 
3187   IF p_in_attributes.action_flag IN ('C', 'I') THEN
3188     -- CTO/Integration API
3189     IF l_source_line_set_id IS NOT NULL THEN
3190       IF p_in_attributes.action_flag = 'I' THEN
3191         OPEN c_sum_line_set_shp_qty_ITS(l_source_header_id,
3192                                         l_source_line_set_id);
3193         FETCH c_sum_line_set_shp_qty_ITS
3194          INTO l_del_shipping_quantity;
3195         CLOSE c_sum_line_set_shp_qty_ITS;
3196       ELSE
3197         OPEN c_sum_line_set_shp_qty(l_source_header_id,
3198                                     l_source_line_set_id);
3199         FETCH c_sum_line_set_shp_qty
3200          INTO l_del_shipping_quantity;
3201         CLOSE c_sum_line_set_shp_qty;
3202       END IF;
3203     ELSE
3204       OPEN c_sum_line_shp_qty;
3205       FETCH c_sum_line_shp_qty
3206        INTO l_del_shipping_quantity;
3207       CLOSE c_sum_line_shp_qty;
3208     END IF;
3209 
3210     IF l_debug_on THEN
3211       WSH_DEBUG_SV.log(l_module_name, 'CTO/Interface: l_del_shipping_quantity',
3212                                       l_del_shipping_quantity);
3213     END IF;
3214 
3215   END IF;
3216 
3217 
3218   l_shipped_quantity := l_del_shipping_quantity;
3219   l_shipped_quantity2 := l_del_shipping_quantity2;
3220 
3221   l_tolerance_quantity_below := l_total_ordered_quantity*nvl(l_ship_tolerance_below,0)/100;
3222   l_tolerance_quantity_above := l_total_ordered_quantity*nvl(l_ship_tolerance_above,0)/100;
3223 
3224   l_tolerance_quantity_below2 := l_total_ordered_quantity2*nvl(l_ship_tolerance_below,0)/100;
3225   l_tolerance_quantity_above2 := l_total_ordered_quantity2*nvl(l_ship_tolerance_above,0)/100;
3226 
3227 
3228   l_min_remaining_quantity := GREATEST(l_total_ordered_quantity - l_shipped_quantity -
3229 						 l_tolerance_quantity_below,0);
3230 
3231   l_max_remaining_quantity := (l_total_ordered_quantity - l_shipped_quantity +
3232 						 l_tolerance_quantity_above);
3233   IF (p_in_attributes.action_flag <> 'I') THEN
3234     l_max_remaining_quantity := GREATEST(l_max_remaining_quantity, 0);
3235   END IF;
3236 
3237 
3238   -- HW OPMCONV - Let's treat qty2 similar to qty1
3239   l_min_remaining_quantity2 := GREATEST(l_total_ordered_quantity2 - l_shipped_quantity2 -
3240 						 l_tolerance_quantity_below2,0);
3241   l_max_remaining_quantity2 := GREATEST(l_total_ordered_quantity2 - l_shipped_quantity2 +
3242 						 l_tolerance_quantity_above2,0);
3243 
3244   -- HW OPMCONV - No need to branch
3245   -- bug 3511424
3246 
3247   --{
3248   --
3249   IF l_debug_on THEN
3250     WSH_DEBUG_SV.log(l_module_name, 'l_max_remaining_quantity before the modification',l_max_remaining_quantity);
3251     WSH_DEBUG_SV.log(l_module_name, 'l_min_remaining_quantity before the modification',l_min_remaining_quantity);
3252   END IF;
3253   --
3254   l_max_remaining_quantity := trunc(l_max_remaining_quantity, wsh_util_core.c_max_decimal_digits_inv);
3255   IF (round(l_min_remaining_quantity,wsh_util_core.c_max_decimal_digits_inv) < l_min_remaining_quantity) THEN
3256     --{
3257     l_min_remaining_quantity := round(l_min_remaining_quantity + 0.000005, wsh_util_core.c_max_decimal_digits_inv);
3258     --}
3259   ELSE
3260     --{
3261     l_min_remaining_quantity := round(l_min_remaining_quantity, wsh_util_core.c_max_decimal_digits_inv);
3262     --}
3263   END IF;
3264   --
3265   IF l_debug_on THEN
3266     WSH_DEBUG_SV.log(l_module_name, 'l_max_remaining_quantity after the modification',l_max_remaining_quantity);
3267     WSH_DEBUG_SV.log(l_module_name, 'l_min_remaining_quantity after the modification',l_min_remaining_quantity);
3268   END IF;
3269   --
3270   --}
3271 
3272   -- bug 3511424
3273   -- HW Get min and max qty2 for OPM
3274 
3275   --In WSH, there can be multiple lines with same source_line_id, so
3276   --OPM needs to look and calculate secondary quantities accordingly
3277   -- HW OPM.
3278 
3279   -- HW OPMCONV - Let's treat Qtys similar to Qty1
3280 
3281   IF l_debug_on THEN
3282     WSH_DEBUG_SV.log(l_module_name, 'l_max_remaining_quantity2 before the modification',l_max_remaining_quantity2);
3283     WSH_DEBUG_SV.log(l_module_name, 'l_min_remaining_quantity2 before the modification',l_min_remaining_quantity2);
3284   END IF;
3285   --
3286   l_max_remaining_quantity2 := trunc(l_max_remaining_quantity2, wsh_util_core.c_max_decimal_digits_inv);
3287   IF (round(l_min_remaining_quantity2,wsh_util_core.c_max_decimal_digits_inv) < l_min_remaining_quantity2) THEN
3288     --{
3289     l_min_remaining_quantity2 := round(l_min_remaining_quantity2 + 0.000005, wsh_util_core.c_max_decimal_digits_inv);
3290     --}
3291   ELSE
3292     --{
3293     l_min_remaining_quantity2 := round(l_min_remaining_quantity2, wsh_util_core.c_max_decimal_digits_inv);
3294     --}
3295   END IF;
3296   --
3297   IF l_debug_on THEN
3298     WSH_DEBUG_SV.log(l_module_name, 'l_max_remaining_quantity2 after the modification',l_max_remaining_quantity2);
3299     WSH_DEBUG_SV.log(l_module_name, 'l_min_remaining_quantity2 after the modification',l_min_remaining_quantity2);
3300   END IF;
3301 
3302 
3303 
3304 
3305   x_out_attributes.min_remaining_quantity := l_min_remaining_quantity;
3306   x_out_attributes.max_remaining_quantity := l_max_remaining_quantity;
3307 
3308 
3309   -- HW added qty2 for OPM
3310   x_out_attributes.min_remaining_quantity2 := l_min_remaining_quantity2;
3311   x_out_attributes.max_remaining_quantity2 := l_max_remaining_quantity2;
3312   -- ADD RETURN VALUES FOR UOM and UOM2
3313   x_out_attributes.quantity_uom  := l_requested_quantity_uom;
3314   x_out_attributes.quantity2_uom := l_requested_quantity_uom2;
3315 
3316   -- csun max_tol, convert shipping quantity to order quantity for CTO
3317   IF p_in_attributes.action_flag = 'C' THEN
3318     -- convert to order line UOM
3319     IF l_ordered_quantity_uom <> l_requested_quantity_uom THEN
3320 
3321       IF l_min_remaining_quantity > 0 THEN
3322         x_out_attributes.min_remaining_quantity := WSH_WV_UTILS.convert_uom(
3323                               from_uom => l_requested_quantity_uom,
3324                               to_uom   => l_ordered_quantity_uom,
3325                               quantity => l_min_remaining_quantity,
3326                               item_id  => l_inventory_item_id);
3327       END IF;
3328       IF l_max_remaining_quantity > 0 THEN
3329         x_out_attributes.max_remaining_quantity := WSH_WV_UTILS.convert_uom(
3330                               from_uom => l_requested_quantity_uom,
3331                               to_uom   => l_ordered_quantity_uom,
3332                               quantity => l_max_remaining_quantity,
3333                               item_id  => l_inventory_item_id);
3334       END IF;
3335       x_out_attributes.quantity_uom  := l_ordered_quantity_uom;
3336 
3337     END IF;
3338 
3339   END IF;
3340 
3341 
3342   IF l_debug_on THEN
3343     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.quantity_uom', x_out_attributes.quantity_uom);
3344     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.min_remaining_quantity',x_out_attributes.min_remaining_quantity);
3345     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.max_remaining_quantity',x_out_attributes.max_remaining_quantity);
3346     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.quantity2_uom', x_out_attributes.quantity2_uom);
3347     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.min_remaining_quantity2',x_out_attributes.min_remaining_quantity2);
3348     WSH_DEBUG_SV.log(l_module_name,'x_out_attributes.max_remaining_quantity2',x_out_attributes.max_remaining_quantity2);
3349     WSH_DEBUG_SV.pop(l_module_name);
3350   END IF;
3351 
3352 EXCEPTION
3353   WHEN OTHERS THEN
3354     x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3355     wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.get_min_max_tolerance_quantity',
3356                                   l_module_name);
3357 
3358     x_out_attributes.min_remaining_quantity := 0;
3359     x_out_attributes.max_remaining_quantity := 0;
3360     x_out_attributes.min_remaining_quantity2 := 0;
3361     x_out_attributes.max_remaining_quantity2 := 0;
3362     x_out_attributes.quantity_uom := NULL;
3363     x_out_attributes.quantity2_uom := NULL;
3364 
3365     IF c_sum_ordered_qty1%ISOPEN THEN
3366       CLOSE c_sum_ordered_qty1;
3367     END IF;
3368     IF c_sum_line_shp_qty%ISOPEN THEN
3369       CLOSE c_sum_line_shp_qty;
3370     END IF;
3371     IF c_sum_line_set_shp_qty%ISOPEN THEN
3372       CLOSE c_sum_line_set_shp_qty;
3373     END IF;
3374     IF c_sum_line_set_shp_qty_ITS%ISOPEN THEN
3375       CLOSE c_sum_line_set_shp_qty_ITS;
3376     END IF;
3377     IF c_sum_picked_qty%ISOPEN THEN
3378       CLOSE c_sum_picked_qty;
3379     END IF;
3380     IF c_sum_ordered_qty%ISOPEN THEN
3381       CLOSE c_sum_ordered_qty;
3382     END IF;
3383     IF c_get_details_CTO%ISOPEN THEN
3384       CLOSE c_get_details_CTO;
3385     END IF;
3386 
3387     IF l_debug_on THEN
3388       WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured.Oracle error Message is '||SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3389       WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3390     END IF;
3391 
3392 END Get_Min_Max_Tolerance_Quantity;
3393 
3394 
3395 --Harmonization Project I
3396 PROCEDURE Is_Action_Enabled(
3397 				p_del_detail_rec_tab	IN	  detail_rec_tab_type,
3398 				p_action				IN	  VARCHAR2,
3399 				p_caller				IN	  VARCHAR2,
3400                                 p_deliveryid                IN      NUMBER DEFAULT null,
3401 				x_return_status		 OUT NOCOPY	  VARCHAR2,
3402 				x_valid_ids			 OUT NOCOPY	  wsh_util_core.id_tab_type,
3403 				x_error_ids			 OUT NOCOPY	  wsh_util_core.id_tab_type,
3404 				x_valid_index_tab	   OUT NOCOPY	  wsh_util_core.id_tab_type
3405 			  ) IS
3406 
3407 cursor  det_to_del_cur( p_del_det_id IN NUMBER ) is
3408 select  wnd.organization_id,
3409 		wnd.status_code,
3410 		wnd.planned_flag,
3411 		wnd.delivery_id,
3412                 nvl(wnd.shipment_direction, 'O'),  -- J inbound logistics jckwok
3413                 nvl(wnd.ignore_for_planning, 'N'), -- OTM R12 : WSHDEVLS record
3414                 nvl(wnd.tms_interface_flag, WSH_NEW_DELIVERIES_PVT.C_TMS_NOT_TO_BE_SENT)                                           -- OTM R12 : WSHDEVLS record
3415 from	wsh_new_deliveries wnd,
3416 	wsh_delivery_assignments_v wda
3417 where   wnd.delivery_id = wda.delivery_id
3418 and	wda.delivery_detail_id = p_del_det_id;
3419 
3420 -- frontport bug 5478065 of 11i10 performance bug 5439331:
3421 -- this cursor is tuned to check for existence.
3422 CURSOR c_staged_content( p_container_id IN NUMBER) IS
3423 SELECT 1 FROM DUAL
3424 WHERE  EXISTS
3425      ( SELECT wdd.delivery_detail_id
3426        FROM   wsh_delivery_details wdd
3427        WHERE wdd.delivery_detail_id IN
3428              (SELECT  wda.delivery_detail_id
3429               FROM  wsh_delivery_assignments_v wda
3430               START WITH parent_delivery_detail_id = p_container_id
3431               CONNECT BY prior delivery_detail_id = parent_delivery_detail_id)
3432        AND   wdd.container_flag = 'N'
3433        AND   wdd.released_status = 'Y' );
3434 
3435 CURSOR c_isdelfirm(p_deliveryid IN NUMBER) IS
3436 SELECT 'Y'
3437 FROM wsh_new_deliveries wnd
3438 WHERE wnd.delivery_id=p_deliveryid
3439 AND wnd.planned_flag='F';
3440 
3441 CURSOR c_isvalidtpdel(p_detid IN NUMBER, p_deliveryid IN NUMBER) IS
3442 SELECT 'Y'
3443 FROM wsh_new_deliveries wnd
3444 WHERE wnd.delivery_id=p_deliveryid
3445 AND (nvl(wnd.ignore_for_planning, 'N') <>
3446             (select nvl(ignore_for_planning,'N') from wsh_delivery_details where delivery_detail_id=p_detid)
3447     );
3448 
3449 l_content_id  NUMBER := NULL;
3450 
3451 
3452 l_detail_actions_tab	 DetailActionsTabType;
3453 l_valid_ids		wsh_util_core.id_tab_type;
3454 l_error_ids		wsh_util_core.id_tab_type;
3455 l_valid_index_tab	wsh_util_core.id_tab_type;
3456 l_dlvy_rec_tab		  WSH_DELIVERY_VALIDATIONS.dlvy_rec_tab_type;
3457 
3458 l_pass_section_a	VARCHAR2(1):='Y';
3459 l_organization_id	 NUMBER;
3460 l_delivery_id NUMBER;
3461 l_delivery_detail_id NUMBER;
3462 l_planned_flag VARCHAR2(1);
3463 l_status_code VARCHAR2(2);
3464 l_shipment_direction VARCHAR(30);  -- J inbound logistics jckwok
3465 l_source_code VARCHAR2(30);
3466 l_released_status VARCHAR2(30);
3467 l_ship_from_location_id   NUMBER;
3468 l_cnt_flag VARCHAR2(2);
3469 l_counter NUMBER;
3470 l_wh_type VARCHAR2(30);
3471 l_return_status VARCHAR2(1);
3472 -- Bug fix: 2644558 Harmonization Project Patchset I.
3473 l_wms_installed		 VARCHAR2(1);
3474 
3475 l_org_type VARCHAR2(30);
3476 l_wms_org_type VARCHAR2(30);
3477 l_wms_org_id NUMBER;
3478 l_non_wms_org_id NUMBER;
3479 
3480 l_caller      VARCHAR2(50);
3481 
3482 error_in_init_actions	EXCEPTION;
3483 e_record_ineligible	 EXCEPTION;
3484 e_wms_record_ineligible EXCEPTION;
3485 e_tp_record_ineligible EXCEPTION;
3486 
3487 -- OTM R12 : due to record changes in WSHDEVLS
3488 l_ignore              WSH_NEW_DELIVERIES.IGNORE_FOR_PLANNING%TYPE;
3489 l_tms_interface_flag  WSH_NEW_DELIVERIES.TMS_INTERFACE_FLAG%TYPE;
3490 -- OTM R12-Org specific -Bug 5399341
3491 l_param_info WSH_SHIPPING_PARAMS_PVT.Parameter_Rec_Typ;
3492 -- End of OTM R12 : due to record changes in WSHDEVLS
3493 
3494 
3495 l_debug_on BOOLEAN;
3496 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'IS_ACTION_ENABLED';
3497 l_wms_table WMS_SHIPPING_INTERFACE_GRP.g_delivery_detail_tbl;
3498 
3499 
3500 l_msg_count NUMBER := 0;
3501 l_msg_data  VARCHAR2(2000);
3502 BEGIN
3503  --
3504  l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3505  --
3506  IF l_debug_on IS NULL
3507  THEN
3508 	 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3509  END IF;
3510  --
3511  IF l_debug_on THEN
3512 	WSH_DEBUG_SV.push(l_module_name);
3513 	--
3514 	WSH_DEBUG_SV.log(l_module_name,'p_action',p_action);
3515 	WSH_DEBUG_SV.log(l_module_name,'p_caller',p_caller);
3516  END IF;
3517 
3518  Init_Detail_Actions_Tbl(
3519 	p_action => p_action,
3520 	x_detail_actions_tab => l_detail_actions_tab,
3521 	x_return_status => x_return_status);
3522 
3523  IF l_debug_on THEN
3524 	WSH_DEBUG_SV.log(l_module_name,'Init_Detail_Actions_Tbl x_return_status',x_return_status);
3525  END IF;
3526 
3527  IF (x_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
3528 	raise error_in_init_actions;
3529  END IF;
3530 
3531  -- Loop through the given table
3532  For  j  IN p_del_detail_rec_tab.FIRST..p_del_detail_rec_tab.LAST LOOP
3533 
3534    BEGIN
3535 
3536    l_source_code := p_del_detail_rec_tab(j).source_code;
3537 
3538    l_wms_org_type := NULL;
3539    --
3540    IF (p_caller NOT LIKE 'WMS%') THEN
3541 
3542 	   if l_debug_on then
3543 		  wsh_debug_sv.log(l_module_name, 'Organization Id', p_del_detail_rec_tab(j).organization_id);
3544 		  wsh_debug_sv.log(l_module_name, 'WMS Organization Id', l_wms_org_id);
3545 		  wsh_debug_sv.log(l_module_name, 'Non WMS Organization Id', l_non_wms_org_id);
3546 	   end if;
3547 
3548 	   IF p_del_detail_rec_tab(j).organization_id = l_wms_org_id THEN
3549 		  l_wms_org_type := 'WMS';
3550 	   ELSIF p_del_detail_rec_tab(j).organization_id = l_non_wms_org_id THEN
3551 		  l_wms_org_type := NULL;
3552 	   ELSE
3553 		  IF l_debug_on THEN
3554 			 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.GET_ORG_TYPE',WSH_DEBUG_SV.C_PROC_LEVEL);
3555 		  END IF;
3556 
3557                   l_org_type := wsh_util_validate.get_org_type(
3558                                   p_organization_id => p_del_detail_rec_tab(j).organization_id,
3559                                   p_delivery_detail_id => p_del_detail_rec_tab(j).delivery_detail_id,
3560 				  p_msg_display => 'N', -- Bug# 3332656
3561                                   x_return_status => l_return_status );
3562 		  IF l_debug_on THEN
3563 		    wsh_debug_sv.log(l_module_name, 'Return status after wsh_util_validate.get_org_type', l_return_status);
3564 		  END IF;
3565                   IF l_return_status = wsh_util_core.g_ret_sts_unexp_error THEN
3566                     raise FND_API.G_EXC_UNEXPECTED_ERROR;
3567                   ELSIF l_return_status = wsh_util_core.g_ret_sts_error THEN
3568                     raise e_record_ineligible;
3569                     exit;
3570                   END IF;
3571 
3572 	          IF l_org_type IS NOT NULL THEN
3573                     l_wms_org_type := substrb(l_org_type, instrb(l_org_type, 'WMS'),3);
3574                     IF nvl(l_wms_org_type,'!') = 'WMS' THEN
3575 		      l_wms_org_id := p_del_detail_rec_tab(j).organization_id;
3576                     ELSE
3577 		      l_non_wms_org_id := p_del_detail_rec_tab(j).organization_id;
3578                     END IF;
3579                   END IF;
3580 	   END IF;
3581 
3582 
3583    END IF;
3584    --
3585    IF l_debug_on THEN
3586      wsh_debug_sv.log(l_module_name, 'l_wms_org_type', l_wms_org_type);
3587      wsh_debug_sv.log(l_module_name, 'l_detail_actions_tab.Count', l_detail_actions_tab.count);
3588    END IF;
3589    -- OTM R12 - Bug 5399341: Get shipping params to figure if the org is OTM enabled.
3590 
3591    WSH_SHIPPING_PARAMS_PVT.Get(
3592                       p_organization_id => p_del_detail_rec_tab(j).organization_id,
3593                       x_param_info      => l_param_info,
3594                       x_return_status   => x_return_status
3595                       );
3596    --
3597    -- R12, X-dock
3598    -- The piece of code which determines if split is not to be allowed for 'Released to Warehouse'
3599    -- line has been commented in WSHDDVLB.init_details_action_tbl
3600    -- As per the requirement, Split should be allowed if
3601    -- if caller = WMS_XDOCK%
3602    -- and action = SPLIT-LINE
3603    -- and released_status for the detail = 'S'
3604    -- and a) Move order line id is null(Planned X-dock line) OR
3605    --     b) Move order line id is not null and move_order_type = 'PUTAWAY' (Planned X-dock line progressed)
3606    --     c) Move order line id is not null and move_order_type = 'PICK_WAVE' (Priotize Inventory case)
3607    IF p_action = 'SPLIT-LINE' AND
3608       p_del_detail_rec_tab(j).released_status = WSH_DELIVERY_DETAILS_PKG.C_RELEASED_TO_WAREHOUSE THEN
3609 
3610      IF l_debug_on THEN
3611        wsh_debug_sv.log(l_module_name, 'Released_status', p_del_detail_rec_tab(j).released_status);
3612        wsh_debug_sv.log(l_module_name, 'Caller',p_caller );
3613      END IF;
3614      IF p_caller like 'WMS_XDOCK%' THEN
3615        null; -- allow action
3616      ELSE
3617      -- Else Split should not be allowed
3618      -- Same as the condition which existed before in WSHDDVLB.init_details_action_tbl
3619        raise e_record_ineligible;
3620      END IF;
3621    END IF;
3622    --
3623    -- End of R12, X-dock
3624    --
3625 	-- Section A
3626 	l_pass_section_a :='Y';
3627 	IF (l_DETAIL_actions_tab.COUNT > 0) THEN
3628 	   For k in l_DETAIL_actions_tab.FIRST..l_DETAIL_actions_tab.LAST LOOP
3629 
3630           -- J-IB-NPARIKH-{
3631           l_released_status       := p_del_detail_rec_tab(j).released_status;
3632           l_ship_from_location_id := p_del_detail_rec_tab(j).ship_from_location_id;
3633           l_caller                := p_caller;
3634           --
3635           --
3636           --
3637           IF l_debug_on THEN
3638              wsh_debug_sv.log(l_module_name, 'l_released_status', l_released_status);
3639              wsh_debug_sv.log(l_module_name, 'l_ship_from_location_id', l_ship_from_location_id);
3640              wsh_debug_sv.log(l_module_name, 'l_caller', l_caller);
3641           END IF;
3642           --
3643           --
3644           -- Actions on inbound/drop-ship lines are allowed only if caller
3645           -- starts with  one of the following:
3646           --     - FTE
3647           --     - WSH_IB
3648           --     - WSH_PUB
3649           --     - WSH_TP_RELEASE
3650           -- For any other callers, set l_caller to WSH_FSTRX
3651           -- Since for caller, WSH_FSTRX, all actions are disabled
3652           -- on inbound/drop-ship lines
3653           --
3654           --
3655           IF  nvl(p_del_detail_rec_tab(j).line_direction,'O') NOT IN ('O','IO')  -- Inbound/Drop-ship
3656           THEN
3657           --{
3658                 IF l_caller LIKE 'FTE%'
3659                 OR l_caller LIKE 'WSH_PUB%'
3660                 OR l_caller LIKE 'WSH_IB%'
3661                 OR l_caller LIKE 'WSH_TP_RELEASE%'
3662                 THEN
3663                     NULL;
3664                 ELSE
3665                     l_caller := 'WSH_FSTRX';
3666                 END IF;
3667           --}
3668           END IF;
3669           --
3670           IF  nvl(p_del_detail_rec_tab(j).line_direction,'O') NOT IN ('O','IO')  -- Inbound/Drop-ship
3671           AND l_released_status                               IN ('C','L','P')  -- Shipped/Closed
3672           AND l_ship_from_location_id                          = WSH_UTIL_CORE.C_NULL_SF_LOCN_ID
3673                                             -- Supplier-managed freight (/Buyer-RReq. not recvd)
3674           THEN
3675           --{
3676 	      /*
3677               IF p_action = 'SPLIT-LINE'
3678               THEN
3679                     l_released_status := 'X';
3680               ELSIF p_action IN ( 'AUTOCREATE-DEL', 'UNASSIGN' )
3681               THEN
3682               --{
3683                   IF p_caller like '%' || WSH_UTIL_CORE.C_SPLIT_DLVY_SUFFIX
3684                   THEN
3685                   --{
3686                       l_released_status       := 'X';
3687                       l_ship_from_location_id := WSH_UTIL_CORE.C_NOTNULL_SF_LOCN_ID;
3688                   --}
3689                   END IF;
3690               --}
3691               END IF;
3692 	      */
3693               --
3694               --
3695               --
3696               IF l_debug_on THEN
3697                  wsh_debug_sv.logmsg(l_module_name, 'After Inbound Checks');
3698                  wsh_debug_sv.log(l_module_name, 'l_released_status', l_released_status);
3699                  wsh_debug_sv.log(l_module_name, 'l_ship_from_location_id', l_ship_from_location_id);
3700                  wsh_debug_sv.log(l_module_name, 'l_caller', l_caller);
3701               END IF;
3702               --
3703           --}
3704           END IF;
3705           --
3706           --
3707           -- J-IB-NPARIKH-}
3708           --
3709           IF( nvl(l_detail_actions_tab(k).released_status,l_released_status) =
3710                 l_released_status   --p_del_detail_rec_tab(j).released_status -- J-IB-NPARIKH
3711               AND nvl(l_detail_actions_tab(k).ship_from_location_id,l_ship_from_location_id)
3712                     = l_ship_from_location_id -- J-IB-NPARIKH
3713 			   AND  nvl(l_detail_actions_tab(k).container_flag,p_del_detail_rec_tab(j).container_flag) =
3714 				p_del_detail_rec_tab(j).container_flag
3715 			   AND  nvl(l_detail_actions_tab(k).source_code,l_source_code) = l_source_code
3716            AND  nvl(l_detail_actions_tab(k).caller,l_caller) = l_caller   -- J-IB-NPARIKH
3717                            AND nvl(l_detail_actions_tab(k).org_type,nvl(l_wms_org_type,'!')) = nvl(l_wms_org_type,'!')
3718 			   AND l_detail_actions_tab(k).action_not_allowed = p_action
3719                            /* J new condition to check line_direction jckwok */
3720                            AND nvl(l_detail_actions_tab(k).line_direction,
3721                                    nvl(p_del_detail_rec_tab(j).line_direction, 'O'))
3722                                    = nvl(p_del_detail_rec_tab(j).line_direction, 'O')
3723                            AND nvl(l_detail_actions_tab(k).otm_enabled, nvl(l_param_info.otm_enabled, 'N'))
3724                                = nvl(l_param_info.otm_enabled, 'N')
3725                          ) THEN
3726 			 l_pass_section_a :='N';
3727                          IF l_detail_actions_tab(k).message_name IS NOT NULL THEN
3728 		           IF l_debug_on THEN
3729 			     wsh_debug_sv.log(l_module_name, 'Message Name is', l_detail_actions_tab(k).message_name);
3730 		           END IF;
3731                            FND_MESSAGE.SET_NAME('WSH',l_detail_actions_tab(k).message_name);
3732                            wsh_util_core.add_message(wsh_util_core.g_ret_sts_error);
3733                          END IF;
3734 			 raise e_record_ineligible;
3735 			 exit;
3736 		  END IF;
3737 	   END LOOP;
3738 	END IF;
3739 
3740 	IF l_debug_on THEN
3741 	   WSH_DEBUG_SV.log(l_module_name,'l_pass_section_a ',l_pass_section_a);
3742 	END IF;
3743 	-- Section B
3744 	IF (l_pass_section_a = 'Y' ) THEN
3745 	   open det_to_del_cur(p_del_detail_rec_tab(j).delivery_detail_id);
3746 	   Fetch det_to_del_cur into l_organization_id, l_status_code, l_planned_flag,
3747                                      l_delivery_id, l_shipment_direction,
3748                                      l_ignore, l_tms_interface_flag; -- OTM R12
3749 
3750 	   IF ( p_action IN ('CYCLE-COUNT','PICK-RELEASE','AUTO-PACK','AUTO-PACK-MASTER',
3751 				  'PACK','UNPACK','PACKING-WORKBENCH') ) THEN
3752 		  IF ( det_to_del_cur%NOTFOUND ) THEN
3753 			 close det_to_del_cur;
3754 
3755 		 l_wh_type := WSH_EXTERNAL_INTERFACE_SV.Get_Warehouse_Type
3756 				(p_organization_id => p_del_detail_rec_tab(j).organization_id,
3757 								 x_return_status   => l_return_status,
3758 				 p_delivery_id	 => l_delivery_id,
3759 				 p_delivery_detail_id => p_del_detail_rec_tab(j).delivery_detail_id,
3760 								 p_msg_display	 => 'N');
3761 
3762 			 IF l_debug_on THEN
3763 			   WSH_DEBUG_SV.log(l_module_name,'Get_Warehouse_Type l_wh_type,l_return_status',l_wh_type||l_return_status);
3764 			 END IF;
3765 
3766 		 IF ( nvl(l_wh_type, FND_API.G_MISS_CHAR) = 'TPW' ) THEN
3767 			IF ( p_del_detail_rec_tab(j).source_code = 'WSH' and p_del_detail_rec_tab(j).container_flag = 'N' ) THEN
3768 			   x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3769 				   x_valid_index_tab(j) := j;
3770 			ELSE
3771 				   raise e_record_ineligible;
3772 			END IF;
3773 		 ELSE
3774 			x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3775 				x_valid_index_tab(j) := j;
3776 		 END IF;
3777 		  ELSE
3778 			 l_dlvy_rec_tab(1).delivery_id := l_delivery_id;
3779 			 l_dlvy_rec_tab(1).organization_id := l_organization_id;
3780 			 l_dlvy_rec_tab(1).status_code := l_status_code;
3781 			 l_dlvy_rec_tab(1).planned_flag := l_planned_flag;
3782                          l_dlvy_rec_tab(1).shipment_direction := l_shipment_direction;  -- J inbound logistics jckwok
3783                          -- OTM R12 : due to record changes in WSHDEVLS
3784                          l_dlvy_rec_tab(1).ignore_for_planning :=  l_ignore;
3785                          l_dlvy_rec_tab(1).tms_interface_flag  :=  l_tms_interface_flag;
3786                          -- End of OTM R12 : due to record changes in WSHDEVLS
3787 
3788 
3789 			 WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled(
3790 				p_dlvy_rec_tab		  => l_dlvy_rec_tab,
3791 				p_action				=> p_action,
3792 				p_caller				=> p_caller,
3793 				x_return_status		 => l_return_status,
3794 				x_valid_ids			 => l_valid_ids,
3795 				x_error_ids			 => l_error_ids,
3796 				x_valid_index_tab	   => l_valid_index_tab);
3797 
3798 			 IF l_debug_on THEN
3799 				WSH_DEBUG_SV.log(l_module_name,'WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled l_return_status',
3800 											   l_return_status);
3801 			 END IF;
3802 
3803 			 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS)
3804                           AND (l_return_status <> WSH_UTIL_CORE.G_RET_STS_WARNING) THEN
3805 				raise e_record_ineligible;
3806 			 ELSE
3807 			x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3808 				x_valid_index_tab(j) := j;
3809 			 END IF;
3810 		  END IF; -- IF ( det_to_del_cur%
3811 
3812 	   ELSIF ( p_action = 'SPLIT-LINE') THEN
3813 		  IF ( det_to_del_cur%NOTFOUND ) THEN
3814 			 close det_to_del_cur;
3815 		 x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3816 			 x_valid_index_tab(j) := j;
3817 		  ELSE
3818 			 l_dlvy_rec_tab(1).delivery_id := l_delivery_id;
3819 			 l_dlvy_rec_tab(1).organization_id := l_organization_id;
3820 			 l_dlvy_rec_tab(1).status_code := l_status_code;
3821 			 l_dlvy_rec_tab(1).planned_flag := l_planned_flag;
3822                          l_dlvy_rec_tab(1).shipment_direction := l_shipment_direction;  -- jckwok
3823                          -- OTM R12 : due to record changes in WSHDEVLS
3824                          l_dlvy_rec_tab(1).ignore_for_planning :=  l_ignore;
3825                          l_dlvy_rec_tab(1).tms_interface_flag  :=  l_tms_interface_flag;
3826                          -- End of OTM R12 : due to record changes in WSHDEVLS
3827 
3828 			 WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled(
3829 				p_dlvy_rec_tab		  => l_dlvy_rec_tab,
3830 				p_action				=> p_action,
3831 				p_caller				=> p_caller,
3832 				x_return_status		 => l_return_status,
3833 				x_valid_ids			 => l_valid_ids,
3834 				x_error_ids			 => l_error_ids,
3835 				x_valid_index_tab	   => l_valid_index_tab);
3836 
3837 			 IF l_debug_on THEN
3838 				WSH_DEBUG_SV.log(l_module_name,'WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled l_return_status',
3839 											   l_return_status);
3840 			 END IF;
3841 
3842 			 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS)
3843                            AND (l_return_status <> WSH_UTIL_CORE.G_RET_STS_WARNING) THEN
3844 				raise e_record_ineligible;
3845 			 ELSE
3846 				x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3847 				x_valid_index_tab(j) := j;
3848 			 END IF;
3849 		  END IF;
3850 
3851 	   ELSIF ( p_action = 'UNASSIGN') THEN
3852 		  IF ( det_to_del_cur%NOTFOUND ) THEN
3853 			 close det_to_del_cur;
3854 		 x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3855 			 x_valid_index_tab(j) := j;
3856 		  ELSE
3857 			 l_dlvy_rec_tab(1).delivery_id := l_delivery_id;
3858 			 l_dlvy_rec_tab(1).organization_id := l_organization_id;
3859 			 l_dlvy_rec_tab(1).status_code := l_status_code;
3860 			 l_dlvy_rec_tab(1).planned_flag := l_planned_flag;
3861                          l_dlvy_rec_tab(1).shipment_direction := l_shipment_direction;  -- jckwok
3862                          -- OTM R12 : due to record changes in WSHDEVLS
3863                          l_dlvy_rec_tab(1).ignore_for_planning :=  l_ignore;
3864                          l_dlvy_rec_tab(1).tms_interface_flag  :=  l_tms_interface_flag;
3865                          -- End of OTM R12 : due to record changes in WSHDEVLS
3866 
3867 			 l_wms_installed := wsh_util_validate.check_wms_org(p_del_detail_rec_tab(j).organization_id);
3868                          -- bug 2750960: call WMS only if record is a container that contains a staged line
3869 			 IF     l_wms_installed = 'Y'
3870                             AND p_del_detail_rec_tab(j).container_flag in ('Y', 'C')
3871                          THEN
3872 
3873                            OPEN  c_staged_content(p_del_detail_rec_tab(j).delivery_detail_id);
3874                            FETCH c_staged_content INTO l_content_id;
3875                            IF c_staged_content%NOTFOUND THEN
3876                              l_content_id := NULL;
3877                            END IF;
3878                            CLOSE c_staged_content;
3879 
3880                            IF l_content_id IS NOT NULL THEN
3881 
3882 			     l_wms_table(1).delivery_detail_id := p_del_detail_rec_tab(j).delivery_detail_id;
3883 			     l_wms_table(1).organization_id    := p_del_detail_rec_tab(j).organization_id;
3884 			     l_wms_table(1).released_status    := p_del_detail_rec_tab(j).released_status;
3885 			     l_wms_table(1).container_flag     := p_del_detail_rec_tab(j).container_flag;
3886 			     l_wms_table(1).source_code	       := p_del_detail_rec_tab(j).source_code;
3887 			     l_wms_table(1).lpn_id	       := p_del_detail_rec_tab(j).lpn_id;
3888 
3889 			     WMS_SHIPPING_INTERFACE_GRP.process_delivery_details (
3890 					p_api_version	=> 1.0,
3891 					p_action		 => WMS_SHIPPING_INTERFACE_GRP.g_action_unassign_delivery,
3892 					p_delivery_detail_tbl  => l_wms_table,
3893 					x_return_status  => l_return_status,
3894 					x_msg_count	  => l_msg_count,
3895 					x_msg_data	   => l_msg_data);
3896 
3897 
3898 				 IF l_debug_on THEN
3899 					WSH_DEBUG_SV.log(l_module_name,'WMS_SHIPPING_INTERFACE_GRP.process_delivery_details l_wms_table(1).return_status',
3900 												   l_wms_table(1).return_status);
3901 				 END IF;
3902 
3903 			     IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS OR l_wms_table(1).return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
3904 				  raise e_wms_record_ineligible;
3905 			     END IF;
3906                            END IF; -- l_content_id IS NOT NULL
3907 			 END IF;--l_wms_installed
3908 
3909 			 WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled(
3910 				p_dlvy_rec_tab		  => l_dlvy_rec_tab,
3911 				p_action				=> p_action,
3912 				p_caller				=> p_caller,
3913 				x_return_status		 => l_return_status,
3914 				x_valid_ids			 => l_valid_ids,
3915 				x_error_ids			 => l_error_ids,
3916 				x_valid_index_tab	   => l_valid_index_tab);
3917 
3918 			 IF l_debug_on THEN
3919 				WSH_DEBUG_SV.log(l_module_name,'WSH_DELIVERY_VALIDATIONS.Is_Action_Enabled l_return_status',
3920 											   l_return_status);
3921 			 END IF;
3922 
3923 			 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS)
3924                            AND (l_return_status <> WSH_UTIL_CORE.G_RET_STS_WARNING) THEN
3925 				raise e_record_ineligible;
3926 			 ELSE
3927                                 IF (p_del_detail_rec_tab(j).source_code = 'WSH' and p_del_detail_rec_tab(j).container_flag = 'N' ) THEN
3928                                    raise e_record_ineligible;
3929                                 END IF;
3930 				x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3931 				x_valid_index_tab(j) := j;
3932 			 END IF;
3933 		  END IF;
3934 
3935            ELSIF (p_caller<>'TP_RELEASE' AND p_action='ASSIGN') THEN
3936               FOR cur IN c_isdelfirm(p_deliveryid) LOOP
3937                   raise e_record_ineligible;
3938               END LOOP;
3939               FOR cur IN c_isvalidtpdel(p_del_detail_rec_tab(j).delivery_detail_id, p_deliveryid) LOOP
3940                   raise e_tp_record_ineligible;
3941               END LOOP;
3942               -- TKT
3943               x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3944               x_valid_index_tab(j) := j;
3945 
3946 	   ELSIF ( p_action IN ('IGNORE_PLAN','INCLUDE_PLAN')) THEN
3947               l_wms_installed := wsh_util_validate.check_wms_org(p_del_detail_rec_tab(j).organization_id);
3948 
3949               IF l_wms_installed='Y' AND p_del_detail_rec_tab(j).released_status='S' THEN
3950                   raise e_wms_record_ineligible;
3951               ELSE
3952                   x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3953                   x_valid_index_tab(j) := j;
3954               END IF;
3955 
3956 	   ELSIF ( p_action =  'AUTOCREATE-TRIP')  THEN
3957 		  IF ( det_to_del_cur%NOTFOUND ) THEN
3958 			 close det_to_del_cur;
3959 
3960 		 l_wh_type := WSH_EXTERNAL_INTERFACE_SV.Get_Warehouse_Type
3961 				(p_organization_id => p_del_detail_rec_tab(j).organization_id,
3962 								 x_return_status   => l_return_status,
3963 				 p_delivery_id	 => l_delivery_id,
3964 								 p_delivery_detail_id => p_del_detail_rec_tab(j).delivery_detail_id,
3965 								 p_msg_display	 => 'N');
3966 
3967 			 IF l_debug_on THEN
3968 			   WSH_DEBUG_SV.log(l_module_name,'Get_Warehouse_Type l_wh_type,l_return_status',l_wh_type||l_return_status);
3969 			 END IF;
3970 
3971 		 IF ( nvl(l_wh_type, FND_API.G_MISS_CHAR) in ('CMS','TPW')) THEN
3972 				  IF (p_del_detail_rec_tab(j).source_code = 'WSH' and p_del_detail_rec_tab(j).container_flag = 'N' ) THEN
3973 				   x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3974 				   x_valid_index_tab(j) := j;
3975 				ELSE
3976 				   raise e_record_ineligible;
3977 				END IF;
3978 		 ELSE
3979 				x_valid_ids(x_valid_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
3980 				x_valid_index_tab(j) := j;
3981 		 END IF;
3982 	  ELSE
3983 				raise e_record_ineligible;
3984 	  END IF;
3985 
3986 
3987 	   ELSE
3988 	   x_valid_ids(x_valid_ids.COUNT + 1) :=  p_del_detail_rec_tab(j).delivery_detail_id;
3989 		   x_valid_index_tab(j) := j;
3990 	   END IF;
3991 
3992 	   IF ( det_to_del_cur%ISOPEN ) THEN
3993 		  close det_to_del_cur;
3994 	   END IF;
3995 
3996 	 END IF; --pass section a
3997 	EXCEPTION -- for the local BEGIN
3998 		 WHEN e_record_ineligible THEN
3999                           IF det_to_del_cur%ISOPEN THEN
4000                             CLOSE det_to_del_cur;
4001                           END IF;
4002 
4003 			  IF l_debug_on THEN
4004 				 wsh_debug_sv.log(l_module_name, 'Error Id', p_del_detail_rec_tab(j).delivery_detail_id);
4005 			  END IF;
4006 			  x_error_ids(x_error_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
4007 			  IF nvl(p_caller, FND_API.G_MISS_CHAR) = 'WSH_PUB'
4008                              OR p_caller like 'FTE%' THEN
4009 				 FND_MESSAGE.SET_NAME('WSH', 'WSH_DETAIL_ACTION_INELIGIBLE');
4010 				 FND_MESSAGE.SET_TOKEN('DETAIL_ID', p_del_detail_rec_tab(j).delivery_detail_id);
4011 				 FND_MESSAGE.SET_TOKEN('ACTION', wsh_util_core.get_action_meaning('DLVB',p_action));
4012 				 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
4013 			  END IF;
4014 
4015 		 WHEN e_wms_record_ineligible THEN
4016                           IF det_to_del_cur%ISOPEN THEN
4017                             CLOSE det_to_del_cur;
4018                           END IF;
4019 			  IF l_debug_on THEN
4020 				 wsh_debug_sv.log(l_module_name, 'Error Id', p_del_detail_rec_tab(j).delivery_detail_id);
4021 			  END IF;
4022 			  x_error_ids(x_error_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
4023 			  IF nvl(p_caller, FND_API.G_MISS_CHAR) = 'WSH_PUB'
4024                              OR p_caller like 'FTE%' THEN
4025 				 FND_MESSAGE.SET_NAME('WSH', 'WSH_DETAIL_ACTION_INELIGIBLE');
4026 				 FND_MESSAGE.SET_TOKEN('DETAIL_ID', p_del_detail_rec_tab(j).delivery_detail_id);
4027 				 FND_MESSAGE.SET_TOKEN('ACTION', wsh_util_core.get_action_meaning('DLVB',p_action));
4028 				 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
4029 			  END IF;
4030 
4031 		 WHEN e_tp_record_ineligible THEN
4032                           IF det_to_del_cur%ISOPEN THEN
4033                             CLOSE det_to_del_cur;
4034                           END IF;
4035 			  IF l_debug_on THEN
4036 				 wsh_debug_sv.log(l_module_name, 'Error Id', p_del_detail_rec_tab(j).delivery_detail_id);
4037 			  END IF;
4038 			  x_error_ids(x_error_ids.COUNT + 1) := p_del_detail_rec_tab(j).delivery_detail_id;
4039 			  IF nvl(p_caller, FND_API.G_MISS_CHAR) = 'WSH_PUB'
4040                              OR p_caller like 'FTE%' THEN
4041 				 FND_MESSAGE.SET_NAME('WSH', 'WSH_DET_ASSIGN_FIRMDEL_ERROR');
4042 				 FND_MESSAGE.SET_TOKEN('DETAIL_ID', p_del_detail_rec_tab(j).delivery_detail_id);
4043 				 FND_MESSAGE.SET_TOKEN('DEL_NAME', wsh_new_deliveries_pvt.get_name(p_deliveryid));
4044 				 wsh_util_core.add_message(wsh_util_core.g_ret_sts_error, l_module_name);
4045 			  END IF;
4046 
4047 		 WHEN others THEN
4048                           IF det_to_del_cur%ISOPEN THEN
4049                             CLOSE det_to_del_cur;
4050                           END IF;
4051 			  raise FND_API.G_EXC_UNEXPECTED_ERROR;
4052 	END; -- Local BEGIN
4053 
4054  END LOOP;
4055 
4056  IF (x_valid_ids.COUNT = 0 ) THEN
4057 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4058         --
4059         IF NOT (l_caller LIKE 'FTE%' OR l_caller = 'WSH_PUB') THEN
4060 	  FND_MESSAGE.SET_NAME('WSH','WSH_ACTION_ENABLED');
4061 	  wsh_util_core.add_message(x_return_status,l_module_name);
4062         END IF;
4063         --
4064  ELSIF (x_valid_ids.COUNT = p_del_detail_rec_tab.COUNT) THEN
4065 	x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4066  ELSIF (x_valid_ids.COUNT < p_del_detail_rec_tab.COUNT ) THEN
4067 	x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4068         --
4069         IF NOT (l_caller LIKE 'FTE%' OR l_caller = 'WSH_PUB') THEN
4070 	  FND_MESSAGE.SET_NAME('WSH','WSH_ACTION_ENABLED_WARN');
4071 	  wsh_util_core.add_message(x_return_status,l_module_name);
4072         END IF;
4073         --
4074  ELSE
4075 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4076         --
4077         IF NOT (l_caller LIKE 'FTE%' OR l_caller = 'WSH_PUB') THEN
4078 	  FND_MESSAGE.SET_NAME('WSH','WSH_ACTION_ENABLED');
4079 	  wsh_util_core.add_message(x_return_status,l_module_name);
4080         END IF;
4081         --
4082  END IF;
4083 
4084  IF l_debug_on THEN
4085 	WSH_DEBUG_SV.pop(l_module_name);
4086  END IF;
4087 
4088 EXCEPTION
4089   WHEN error_in_init_actions THEN
4090    IF l_debug_on THEN
4091 	  WSH_DEBUG_SV.logmsg(l_module_name,'error_in_init_actions exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4092 	  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:error_in_init_actions');
4093    END IF;
4094 
4095   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4096 				x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4097 			   wsh_util_core.add_message(x_return_status, l_module_name);
4098 		   IF l_debug_on THEN
4099 				WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4100 				WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
4101 		   END IF;
4102    IF c_staged_content%ISOPEN THEN
4103       CLOSE c_staged_content;
4104    END IF;
4105 
4106   WHEN OTHERS THEN
4107    x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
4108    IF l_debug_on THEN
4109 	  WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '||
4110 						  SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4111 	  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4112    END IF;
4113    IF c_staged_content%ISOPEN THEN
4114       CLOSE c_staged_content;
4115    END IF;
4116 END Is_Action_Enabled;
4117 
4118 
4119 
4120 PROCEDURE eliminate_displayonly_fields (
4121   p_delivery_detail_rec   IN wsh_glbl_var_strct_grp.delivery_details_rec_type
4122 , p_in_rec                IN wsh_glbl_var_strct_grp.detailInRecType
4123 , x_delivery_detail_rec   IN OUT NOCOPY
4124  							 wsh_glbl_var_strct_grp.delivery_details_rec_type
4125 )
4126 IS
4127 
4128 -- Bug 5728048
4129 CURSOR c_isvalidUOM_Code (p_uom_code VARCHAR2) IS
4130  SELECT uom.uom_code
4131  FROM   mtl_uom_conversions conv, mtl_units_of_measure_vl uom
4132  WHERE  uom.unit_of_measure = conv.unit_of_measure
4133  AND    uom.uom_code = p_uom_code
4134  AND    conv.inventory_item_id = 0
4135  AND    NVL(uom.disable_date, sysdate+1) > sysdate
4136  AND    NVL(conv.disable_date, sysdate+1) > sysdate ;
4137 
4138  l_uom_code VARCHAR2(3);
4139 
4140 BEGIN
4141 
4142 	/*
4143 	   Enable the x_delivery_detail_rec, with the columns that are not
4144 	   permanently  disabled.
4145 	*/
4146 
4147 	--
4148 	IF p_delivery_detail_rec.container_name <>  FND_API.G_MISS_CHAR
4149 	  OR p_delivery_detail_rec.container_name IS NULL THEN
4150 	  x_delivery_detail_rec.container_name :=
4151 						  p_delivery_detail_rec.container_name;
4152 	END IF;
4153 	IF p_delivery_detail_rec.shipped_quantity <>  FND_API.G_MISS_NUM
4154 	  OR p_delivery_detail_rec.shipped_quantity IS NULL THEN
4155 	  x_delivery_detail_rec.shipped_quantity :=
4156 						  p_delivery_detail_rec.shipped_quantity;
4157 	END IF;
4158 	IF p_delivery_detail_rec.shipped_quantity2 <>  FND_API.G_MISS_NUM
4159 	  OR p_delivery_detail_rec.shipped_quantity2 IS NULL THEN
4160 	  x_delivery_detail_rec.shipped_quantity2 :=
4161 						  p_delivery_detail_rec.shipped_quantity2;
4162 	END IF;
4163 	IF p_delivery_detail_rec.cycle_count_quantity <>  FND_API.G_MISS_NUM
4164 	  OR p_delivery_detail_rec.cycle_count_quantity IS NULL THEN
4165 	  x_delivery_detail_rec.cycle_count_quantity :=
4166 						  p_delivery_detail_rec.cycle_count_quantity;
4167 	END IF;
4168 	IF p_delivery_detail_rec.cycle_count_quantity2 <>  FND_API.G_MISS_NUM
4169 	  OR p_delivery_detail_rec.cycle_count_quantity2 IS NULL THEN
4170 	  x_delivery_detail_rec.cycle_count_quantity2 :=
4171 						  p_delivery_detail_rec.cycle_count_quantity2;
4172 	END IF;
4173 	IF p_delivery_detail_rec.delivered_quantity <>  FND_API.G_MISS_NUM
4174 	  OR p_delivery_detail_rec.delivered_quantity IS NULL THEN
4175 	  x_delivery_detail_rec.delivered_quantity :=
4176 						  p_delivery_detail_rec.delivered_quantity;
4177 	END IF;
4178 	IF p_delivery_detail_rec.delivered_quantity2 <>  FND_API.G_MISS_NUM
4179 	  OR p_delivery_detail_rec.delivered_quantity2 IS NULL THEN
4180 	  x_delivery_detail_rec.delivered_quantity2 :=
4181 						  p_delivery_detail_rec.delivered_quantity2;
4182 	END IF;
4183 	IF p_delivery_detail_rec.cancelled_quantity <>  FND_API.G_MISS_NUM
4184 	  OR p_delivery_detail_rec.cancelled_quantity IS NULL THEN
4185 	  x_delivery_detail_rec.cancelled_quantity :=
4186 						  p_delivery_detail_rec.cancelled_quantity;
4187 	END IF;
4188 	IF p_delivery_detail_rec.cancelled_quantity2 <>  FND_API.G_MISS_NUM
4189 	  OR p_delivery_detail_rec.cancelled_quantity2 IS NULL THEN
4190 	  x_delivery_detail_rec.cancelled_quantity2 :=
4191 						  p_delivery_detail_rec.cancelled_quantity2;
4192 	END IF;
4193 	IF p_delivery_detail_rec.load_seq_number <>  FND_API.G_MISS_NUM
4194 	  OR p_delivery_detail_rec.load_seq_number IS NULL THEN
4195 	  x_delivery_detail_rec.load_seq_number :=
4196 						  p_delivery_detail_rec.load_seq_number;
4197 	END IF;
4198 	IF p_delivery_detail_rec.gross_weight <>  FND_API.G_MISS_NUM
4199 	  OR p_delivery_detail_rec.gross_weight IS NULL THEN
4200 	  x_delivery_detail_rec.gross_weight :=
4201 						  p_delivery_detail_rec.gross_weight;
4202 	END IF;
4203 	IF p_delivery_detail_rec.net_weight <>  FND_API.G_MISS_NUM
4204 	  OR p_delivery_detail_rec.net_weight IS NULL THEN
4205 	  x_delivery_detail_rec.net_weight :=
4206 						  p_delivery_detail_rec.net_weight;
4207 	END IF;
4208 	IF p_delivery_detail_rec.volume <>  FND_API.G_MISS_NUM
4209 	  OR p_delivery_detail_rec.volume IS NULL THEN
4210 	  x_delivery_detail_rec.volume :=
4211 						  p_delivery_detail_rec.volume;
4212 	END IF;
4213 
4214         -- Update of UOM Codes is allowed only if they are Null and new codes are Valid UOM Codes
4215         IF p_in_rec.action_code = 'UPDATE' THEN
4216            IF p_delivery_detail_rec.weight_uom_code <>  FND_API.G_MISS_CHAR
4217              AND p_delivery_detail_rec.weight_uom_code IS NOT NULL
4218              AND x_delivery_detail_rec.weight_uom_code IS NULL THEN
4219              OPEN c_isvalidUOM_Code(p_delivery_detail_rec.weight_uom_code);
4220              FETCH c_isvalidUOM_Code INTO l_uom_code;
4221              IF c_isvalidUOM_Code%FOUND THEN
4222                 x_delivery_detail_rec.weight_uom_code :=
4223                                                   p_delivery_detail_rec.weight_uom_code;
4224              END IF;
4225              CLOSE c_isvalidUOM_Code;
4226            END IF;
4227            IF p_delivery_detail_rec.volume_uom_code <>  FND_API.G_MISS_CHAR
4228              AND p_delivery_detail_rec.volume_uom_code IS NOT NULL
4229              AND x_delivery_detail_rec.volume_uom_code IS NULL THEN
4230              OPEN c_isvalidUOM_Code(p_delivery_detail_rec.volume_uom_code);
4231              FETCH c_isvalidUOM_Code INTO l_uom_code;
4232              IF c_isvalidUOM_Code%FOUND THEN
4233                 x_delivery_detail_rec.volume_uom_code :=
4234                                                   p_delivery_detail_rec.volume_uom_code;
4235              END IF;
4236              CLOSE c_isvalidUOM_Code;
4237            END IF;
4238         END IF;
4239 
4240 	IF p_delivery_detail_rec.fill_percent <>  FND_API.G_MISS_NUM
4241 	  OR p_delivery_detail_rec.fill_percent IS NULL THEN
4242 	  x_delivery_detail_rec.fill_percent :=
4243 						  p_delivery_detail_rec.fill_percent;
4244 	END IF;
4245 	IF p_delivery_detail_rec.master_serial_number <>  FND_API.G_MISS_CHAR
4246 	  OR p_delivery_detail_rec.master_serial_number IS NULL THEN
4247 	  x_delivery_detail_rec.master_serial_number :=
4248 						  p_delivery_detail_rec.master_serial_number;
4249 	END IF;
4250 	IF p_delivery_detail_rec.master_container_item_id <>  FND_API.G_MISS_NUM
4251 	  OR p_delivery_detail_rec.master_container_item_id IS NULL THEN
4252 	  x_delivery_detail_rec.master_container_item_id :=
4253 						  p_delivery_detail_rec.master_container_item_id;
4254 	END IF;
4255 	IF p_delivery_detail_rec.detail_container_item_id <>  FND_API.G_MISS_NUM
4256 	  OR p_delivery_detail_rec.detail_container_item_id IS NULL THEN
4257 	  x_delivery_detail_rec.detail_container_item_id :=
4258 						  p_delivery_detail_rec.detail_container_item_id;
4259 	END IF;
4260 	IF p_delivery_detail_rec.shipping_instructions <>  FND_API.G_MISS_CHAR
4261 	  OR p_delivery_detail_rec.shipping_instructions IS NULL THEN
4262 	  x_delivery_detail_rec.shipping_instructions :=
4263 						  p_delivery_detail_rec.shipping_instructions;
4264 	END IF;
4265 	IF p_delivery_detail_rec.packing_instructions <>  FND_API.G_MISS_CHAR
4266 	  OR p_delivery_detail_rec.packing_instructions IS NULL THEN
4267 	  x_delivery_detail_rec.packing_instructions :=
4268 						  p_delivery_detail_rec.packing_instructions;
4269 	END IF;
4270 	IF p_delivery_detail_rec.revision <>  FND_API.G_MISS_CHAR
4271 	  OR p_delivery_detail_rec.revision IS NULL THEN
4272 	  x_delivery_detail_rec.revision :=
4273 						  p_delivery_detail_rec.revision;
4274 	END IF;
4275 	IF p_delivery_detail_rec.subinventory <>  FND_API.G_MISS_CHAR
4276 	  OR p_delivery_detail_rec.subinventory IS NULL THEN
4277 	  x_delivery_detail_rec.subinventory :=
4278 						  p_delivery_detail_rec.subinventory;
4279 	END IF;
4280 	IF p_delivery_detail_rec.lot_number <>  FND_API.G_MISS_CHAR
4281 	  OR p_delivery_detail_rec.lot_number IS NULL THEN
4282 	  x_delivery_detail_rec.lot_number :=
4283 						  p_delivery_detail_rec.lot_number;
4284 	END IF;
4285 -- HW OPMCONV - No need for sublot_number
4286 
4287 	IF p_delivery_detail_rec.locator_id <>  FND_API.G_MISS_NUM
4288 	  OR p_delivery_detail_rec.locator_id IS NULL THEN
4289 	  x_delivery_detail_rec.locator_id :=
4290 						  p_delivery_detail_rec.locator_id;
4291 	END IF;
4292 	IF p_delivery_detail_rec.serial_number <>  FND_API.G_MISS_CHAR
4293 	  OR p_delivery_detail_rec.serial_number IS NULL THEN
4294 	  x_delivery_detail_rec.serial_number :=
4295 						  p_delivery_detail_rec.serial_number;
4296 	END IF;
4297 	-- Bug Fix: 2651882. KVENKATE.
4298 	-- Need to enable 'to_serial_number'
4299 	IF p_delivery_detail_rec.to_serial_number <>  FND_API.G_MISS_CHAR
4300 	  OR p_delivery_detail_rec.to_serial_number IS NULL THEN
4301 	  x_delivery_detail_rec.to_serial_number :=
4302 						  p_delivery_detail_rec.to_serial_number;
4303 	END IF;
4304 	-- Bug Fix: 2651882. KVENKATE.
4305 
4306 	IF p_delivery_detail_rec.preferred_grade <>  FND_API.G_MISS_CHAR
4307 	  OR p_delivery_detail_rec.preferred_grade IS NULL THEN
4308 	  x_delivery_detail_rec.preferred_grade :=
4309 						  p_delivery_detail_rec.preferred_grade;
4310 	END IF;
4311 	IF p_delivery_detail_rec.seal_code <>  FND_API.G_MISS_CHAR
4312 	  OR p_delivery_detail_rec.seal_code IS NULL THEN
4313 	  x_delivery_detail_rec.seal_code :=
4314 						  p_delivery_detail_rec.seal_code;
4315 	END IF;
4316 	IF p_delivery_detail_rec.inspection_flag <>  FND_API.G_MISS_CHAR
4317 	  OR p_delivery_detail_rec.inspection_flag IS NULL THEN
4318 	  x_delivery_detail_rec.inspection_flag :=
4319 						  p_delivery_detail_rec.inspection_flag;
4320 	END IF;
4321 	IF p_delivery_detail_rec.transaction_temp_id <>  FND_API.G_MISS_NUM
4322 	  OR p_delivery_detail_rec.transaction_temp_id IS NULL THEN
4323 	  x_delivery_detail_rec.transaction_temp_id :=
4324 						  p_delivery_detail_rec.transaction_temp_id;
4325 	END IF;
4326 
4327 
4328 	IF p_delivery_detail_rec.tp_attribute1 <>  FND_API.G_MISS_CHAR
4329 	  OR p_delivery_detail_rec.tp_attribute1 IS NULL THEN
4330 	  x_delivery_detail_rec.tp_attribute1 :=
4331 						  p_delivery_detail_rec.tp_attribute1;
4332 	END IF;
4333 	IF p_delivery_detail_rec.tp_attribute2 <>  FND_API.G_MISS_CHAR
4334 	  OR p_delivery_detail_rec.tp_attribute2 IS NULL THEN
4335 	  x_delivery_detail_rec.tp_attribute2 :=
4336 						  p_delivery_detail_rec.tp_attribute2;
4337 	END IF;
4338 	IF p_delivery_detail_rec.tp_attribute3 <>  FND_API.G_MISS_CHAR
4339 	  OR p_delivery_detail_rec.tp_attribute3 IS NULL THEN
4340 	  x_delivery_detail_rec.tp_attribute3 :=
4341 						  p_delivery_detail_rec.tp_attribute3;
4342 	END IF;
4343 	IF p_delivery_detail_rec.tp_attribute4 <>  FND_API.G_MISS_CHAR
4344 	  OR p_delivery_detail_rec.tp_attribute4 IS NULL THEN
4345 	  x_delivery_detail_rec.tp_attribute4 :=
4346 						  p_delivery_detail_rec.tp_attribute4;
4347 	END IF;
4348 	IF p_delivery_detail_rec.tp_attribute5 <>  FND_API.G_MISS_CHAR
4349 	  OR p_delivery_detail_rec.tp_attribute5 IS NULL THEN
4350 	  x_delivery_detail_rec.tp_attribute5 :=
4351 						  p_delivery_detail_rec.tp_attribute5;
4352 	END IF;
4353 	IF p_delivery_detail_rec.tp_attribute6 <>  FND_API.G_MISS_CHAR
4354 	  OR p_delivery_detail_rec.tp_attribute6 IS NULL THEN
4355 	  x_delivery_detail_rec.tp_attribute6 :=
4356 						  p_delivery_detail_rec.tp_attribute6;
4357 	END IF;
4358 	IF p_delivery_detail_rec.tp_attribute7 <>  FND_API.G_MISS_CHAR
4359 	  OR p_delivery_detail_rec.tp_attribute7 IS NULL THEN
4360 	  x_delivery_detail_rec.tp_attribute7 :=
4361 						  p_delivery_detail_rec.tp_attribute7;
4362 	END IF;
4363 	IF p_delivery_detail_rec.tp_attribute8 <>  FND_API.G_MISS_CHAR
4364 	  OR p_delivery_detail_rec.tp_attribute8 IS NULL THEN
4365 	  x_delivery_detail_rec.tp_attribute8 :=
4366 						  p_delivery_detail_rec.tp_attribute8;
4367 	END IF;
4368 	IF p_delivery_detail_rec.tp_attribute9 <>  FND_API.G_MISS_CHAR
4369 	  OR p_delivery_detail_rec.tp_attribute9 IS NULL THEN
4370 	  x_delivery_detail_rec.tp_attribute9 :=
4371 						  p_delivery_detail_rec.tp_attribute9;
4372 	END IF;
4373 	IF p_delivery_detail_rec.tp_attribute10 <>  FND_API.G_MISS_CHAR
4374 	  OR p_delivery_detail_rec.tp_attribute10 IS NULL THEN
4375 	  x_delivery_detail_rec.tp_attribute10 :=
4376 						  p_delivery_detail_rec.tp_attribute10;
4377 	END IF;
4378 	IF p_delivery_detail_rec.tp_attribute11 <>  FND_API.G_MISS_CHAR
4379 	  OR p_delivery_detail_rec.tp_attribute11 IS NULL THEN
4380 	  x_delivery_detail_rec.tp_attribute11 :=
4381 						  p_delivery_detail_rec.tp_attribute11;
4382 	END IF;
4383 	IF p_delivery_detail_rec.tp_attribute12 <>  FND_API.G_MISS_CHAR
4384 	  OR p_delivery_detail_rec.tp_attribute12 IS NULL THEN
4385 	  x_delivery_detail_rec.tp_attribute12 :=
4386 						  p_delivery_detail_rec.tp_attribute12;
4387 	END IF;
4388 	IF p_delivery_detail_rec.tp_attribute13 <>  FND_API.G_MISS_CHAR
4389 	  OR p_delivery_detail_rec.tp_attribute13 IS NULL THEN
4390 	  x_delivery_detail_rec.tp_attribute13 :=
4391 						  p_delivery_detail_rec.tp_attribute13;
4392 	END IF;
4393 	IF p_delivery_detail_rec.tp_attribute14 <>  FND_API.G_MISS_CHAR
4394 	  OR p_delivery_detail_rec.tp_attribute14 IS NULL THEN
4395 	  x_delivery_detail_rec.tp_attribute14 :=
4396 						  p_delivery_detail_rec.tp_attribute14;
4397 	END IF;
4398 	IF p_delivery_detail_rec.tp_attribute15 <>  FND_API.G_MISS_CHAR
4399 	  OR p_delivery_detail_rec.tp_attribute15 IS NULL THEN
4400 	  x_delivery_detail_rec.tp_attribute15 :=
4401 						  p_delivery_detail_rec.tp_attribute15;
4402 	END IF;
4403 	IF p_delivery_detail_rec.tp_attribute_category <>  FND_API.G_MISS_CHAR
4404 	  OR p_delivery_detail_rec.tp_attribute_category IS NULL THEN
4405 	  x_delivery_detail_rec.tp_attribute_category :=
4406 						  p_delivery_detail_rec.tp_attribute_category;
4407 	END IF;
4408 	IF p_delivery_detail_rec.attribute1 <>  FND_API.G_MISS_CHAR
4409 	  OR p_delivery_detail_rec.attribute1 IS NULL THEN
4410 
4411 	  x_delivery_detail_rec.attribute1 :=
4412 						  p_delivery_detail_rec.attribute1;
4413 	END IF;
4414 	IF p_delivery_detail_rec.attribute2 <>  FND_API.G_MISS_CHAR
4415 	  OR p_delivery_detail_rec.attribute2 IS NULL THEN
4416 	  x_delivery_detail_rec.attribute2 :=
4417 						  p_delivery_detail_rec.attribute2;
4418 	END IF;
4419 	IF p_delivery_detail_rec.attribute3 <>  FND_API.G_MISS_CHAR
4420 	  OR p_delivery_detail_rec.attribute3 IS NULL THEN
4421 	  x_delivery_detail_rec.attribute3 :=
4422 						  p_delivery_detail_rec.attribute3;
4423 	END IF;
4424 	IF p_delivery_detail_rec.attribute4 <>  FND_API.G_MISS_CHAR
4425 	  OR p_delivery_detail_rec.attribute4 IS NULL THEN
4426 	  x_delivery_detail_rec.attribute4 :=
4427 						  p_delivery_detail_rec.attribute4;
4428 	END IF;
4429 	IF p_delivery_detail_rec.attribute5 <>  FND_API.G_MISS_CHAR
4430 	  OR p_delivery_detail_rec.attribute5 IS NULL THEN
4431 	  x_delivery_detail_rec.attribute5 :=
4432 						  p_delivery_detail_rec.attribute5;
4433 	END IF;
4434 	IF p_delivery_detail_rec.attribute6 <>  FND_API.G_MISS_CHAR
4435 	  OR p_delivery_detail_rec.attribute6 IS NULL THEN
4436 	  x_delivery_detail_rec.attribute6 :=
4437 						  p_delivery_detail_rec.attribute6;
4438 	END IF;
4439 	IF p_delivery_detail_rec.attribute7 <>  FND_API.G_MISS_CHAR
4440 	  OR p_delivery_detail_rec.attribute7 IS NULL THEN
4441 	  x_delivery_detail_rec.attribute7 :=
4442 						  p_delivery_detail_rec.attribute7;
4443 	END IF;
4444 	IF p_delivery_detail_rec.attribute8 <>  FND_API.G_MISS_CHAR
4445 	  OR p_delivery_detail_rec.attribute8 IS NULL THEN
4446 	  x_delivery_detail_rec.attribute8 :=
4447 						  p_delivery_detail_rec.attribute8;
4448 	END IF;
4449 	IF p_delivery_detail_rec.attribute9 <>  FND_API.G_MISS_CHAR
4450 	  OR p_delivery_detail_rec.attribute9 IS NULL THEN
4451 	  x_delivery_detail_rec.attribute9 :=
4452 						  p_delivery_detail_rec.attribute9;
4453 	END IF;
4454 	IF p_delivery_detail_rec.attribute10 <>  FND_API.G_MISS_CHAR
4455 	  OR p_delivery_detail_rec.attribute10 IS NULL THEN
4456 	  x_delivery_detail_rec.attribute10 :=
4457 						  p_delivery_detail_rec.attribute10;
4458 	END IF;
4459 	IF p_delivery_detail_rec.attribute11 <>  FND_API.G_MISS_CHAR
4460 	  OR p_delivery_detail_rec.attribute11 IS NULL THEN
4461 	  x_delivery_detail_rec.attribute11 :=
4462 						  p_delivery_detail_rec.attribute11;
4463 	END IF;
4464 	IF p_delivery_detail_rec.attribute12 <>  FND_API.G_MISS_CHAR
4465 	  OR p_delivery_detail_rec.attribute12 IS NULL THEN
4466 	  x_delivery_detail_rec.attribute12 :=
4467 						  p_delivery_detail_rec.attribute12;
4468 	END IF;
4469 	IF p_delivery_detail_rec.attribute13 <>  FND_API.G_MISS_CHAR
4470 	  OR p_delivery_detail_rec.attribute13 IS NULL THEN
4471 	  x_delivery_detail_rec.attribute13 :=
4472 						  p_delivery_detail_rec.attribute13;
4473 	END IF;
4474 	IF p_delivery_detail_rec.attribute14 <>  FND_API.G_MISS_CHAR
4475 	  OR p_delivery_detail_rec.attribute14 IS NULL THEN
4476 	  x_delivery_detail_rec.attribute14 :=
4477 						  p_delivery_detail_rec.attribute14;
4478 	END IF;
4479 	IF p_delivery_detail_rec.attribute15 <>  FND_API.G_MISS_CHAR
4480 	  OR p_delivery_detail_rec.attribute15 IS NULL THEN
4481 	  x_delivery_detail_rec.attribute15 :=
4482 						  p_delivery_detail_rec.attribute15;
4483 	END IF;
4484 	IF p_delivery_detail_rec.attribute_category <>  FND_API.G_MISS_CHAR
4485 	  OR p_delivery_detail_rec.attribute_category IS NULL THEN
4486 	  x_delivery_detail_rec.attribute_category :=
4487 						  p_delivery_detail_rec.attribute_category;
4488 	END IF;
4489 
4490         -- Need to enable 'Tracking Number'. This is not a permanently disabled field
4491 	IF p_delivery_detail_rec.tracking_number <>  FND_API.G_MISS_CHAR
4492 	  OR p_delivery_detail_rec.tracking_number IS NULL THEN
4493 	  x_delivery_detail_rec.tracking_number :=
4494 						  p_delivery_detail_rec.tracking_number;
4495 	END IF;
4496 
4497         -- J: W/V Changes
4498 	IF p_delivery_detail_rec.filled_volume <>  FND_API.G_MISS_NUM
4499 	  OR p_delivery_detail_rec.filled_volume IS NULL THEN
4500 	  x_delivery_detail_rec.filled_volume :=
4501 						  p_delivery_detail_rec.filled_volume;
4502 	END IF;
4503 
4504         IF p_in_rec.caller='WSH_TP_RELEASE' THEN
4505            IF p_delivery_detail_rec.tp_delivery_detail_id <> FND_API.G_MISS_NUM
4506               OR p_delivery_detail_rec.tp_delivery_detail_id IS NULL THEN
4507               x_delivery_detail_rec.tp_delivery_detail_id :=
4508                           p_delivery_detail_rec.tp_delivery_detail_id;
4509            END IF;
4510         END IF;
4511 
4512 
4513 END eliminate_displayonly_fields;
4514 
4515 /*----------------------------------------------------------
4516 -- Procedure disable_from_list will update the record x_out_rec
4517 -- and disables the field contained in p_disabled_list.
4518 -----------------------------------------------------------*/
4519 
4520 PROCEDURE disable_from_list(
4521   p_disabled_list IN		 WSH_UTIL_CORE.column_tab_type
4522 , p_in_rec         IN            wsh_glbl_var_strct_grp.delivery_details_rec_type
4523 , x_out_rec       IN OUT NOCOPY wsh_glbl_var_strct_grp.delivery_details_rec_type
4524 , x_return_status OUT NOCOPY		 VARCHAR2
4525 , x_field_name	OUT NOCOPY		 VARCHAR2
4526 
4527 ) IS
4528 BEGIN
4529   --
4530   --
4531   FOR i IN 1..p_disabled_list.COUNT
4532   LOOP
4533 	IF p_disabled_list(i)  = 'CONTAINER_NAME' THEN
4534 	  x_out_rec.container_name := p_in_rec.container_name ;
4535 	ELSIF p_disabled_list(i)  = 'CYCLE_COUNT_QUANTITY' THEN
4536 	  x_out_rec.cycle_count_quantity := p_in_rec.cycle_count_quantity ;
4537         --
4538 	ELSIF p_disabled_list(i)  = 'PREFERED_GRADE' THEN
4539 	  x_out_rec.PREFERRED_GRADE := p_in_rec.PREFERRED_GRADE ;
4540 	ELSIF p_disabled_list(i)  = 'LPN_ID' THEN
4541 	  x_out_rec.lpn_id := p_in_rec.lpn_id ;
4542 	ELSIF p_disabled_list(i)  = 'SRC_REQUESTED_QUANTITY2' THEN
4543 	  x_out_rec.SRC_REQUESTED_QUANTITY2 := p_in_rec.SRC_REQUESTED_QUANTITY2 ;
4544 	ELSIF p_disabled_list(i)  = 'SRC_REQUESTED_QUANTITY_UOM2' THEN
4545 	  x_out_rec.SRC_REQUESTED_QUANTITY_UOM2 := p_in_rec.SRC_REQUESTED_QUANTITY_UOM2 ;
4546 	ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY_UOM2' THEN
4547 	  x_out_rec.REQUESTED_QUANTITY_UOM2 := p_in_rec.REQUESTED_QUANTITY_UOM2 ;
4548 	ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY2' THEN
4549 	  x_out_rec.REQUESTED_QUANTITY2 := p_in_rec.REQUESTED_QUANTITY2 ;
4550 	ELSIF p_disabled_list(i)  = 'QUALITY_CONTROL_QUANTITY2' THEN
4551 	  x_out_rec.QUALITY_CONTROL_QUANTITY2 := p_in_rec.QUALITY_CONTROL_QUANTITY2 ;
4552 	ELSIF p_disabled_list(i)  = 'SUBLOT_NUMBER' THEN
4553 	  --x_out_rec.SUBLOT_NUMBER := p_in_rec.SUBLOT_NUMBER ;
4554           NULL;
4555 	ELSIF p_disabled_list(i)  = 'RETURNED_QUANTITY2' THEN
4556 	  x_out_rec.RETURNED_QUANTITY2 := p_in_rec.RETURNED_QUANTITY2 ;
4557 	ELSIF p_disabled_list(i)  = 'RECEIVED_QUANTITY2' THEN
4558 	  x_out_rec.RECEIVED_QUANTITY2 := p_in_rec.RECEIVED_QUANTITY2 ;
4559 	ELSIF p_disabled_list(i)  = 'PICKED_QUANTITY2' THEN
4560 	  x_out_rec.PICKED_QUANTITY2 := p_in_rec.PICKED_QUANTITY2 ;
4561 	ELSIF p_disabled_list(i)  = 'TO_SERIAL_NUMBER' THEN
4562 	  x_out_rec.TO_SERIAL_NUMBER := p_in_rec.TO_SERIAL_NUMBER ;
4563 	ELSIF p_disabled_list(i)  = 'SERIAL_NUMBER' THEN
4564 	  x_out_rec.SERIAL_NUMBER := p_in_rec.SERIAL_NUMBER ;
4565 	ELSIF p_disabled_list(i)  = 'TRANSACTION_TEMP_ID' THEN
4566 	  x_out_rec.TRANSACTION_TEMP_ID := p_in_rec.TRANSACTION_TEMP_ID ;
4567 	ELSIF p_disabled_list(i)  = 'REVISION' THEN
4568 	  x_out_rec.REVISION := p_in_rec.REVISION ;
4569 	ELSIF p_disabled_list(i)  = 'LOT_NUMBER' THEN
4570 	  x_out_rec.LOT_NUMBER := p_in_rec.LOT_NUMBER ;
4571 	ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY_UOM' THEN
4572 	  x_out_rec.REQUESTED_QUANTITY_UOM := p_in_rec.REQUESTED_QUANTITY_UOM ;
4573         --
4574 	ELSIF p_disabled_list(i)  = 'CYCLE_COUNT_QUANTITY2' THEN
4575 	  x_out_rec.cycle_count_quantity2 := p_in_rec.cycle_count_quantity2 ;
4576 	ELSIF p_disabled_list(i)  = 'CANCELLED_QUANTITY2' THEN
4577 	  x_out_rec.cancelled_quantity2 := p_in_rec.cancelled_quantity2 ;
4578 	ELSIF p_disabled_list(i)  = 'CANCELLED_QUANTITY' THEN
4579 	  x_out_rec.cancelled_quantity := p_in_rec.cancelled_quantity ;
4580 	ELSIF p_disabled_list(i)  = 'INSPECTION_FLAG' THEN
4581 	  x_out_rec.INSPECTION_FLAG := p_in_rec.INSPECTION_FLAG ;
4582 	ELSIF p_disabled_list(i)  = 'DESC_FLEX' THEN
4583 	  x_out_rec.attribute1 := p_in_rec.attribute1 ;
4584 	  x_out_rec.attribute2 := p_in_rec.attribute2 ;
4585 	  x_out_rec.attribute3 := p_in_rec.attribute3 ;
4586 	  x_out_rec.attribute4 := p_in_rec.attribute4 ;
4587 	  x_out_rec.attribute5 := p_in_rec.attribute5 ;
4588 	  x_out_rec.attribute6 := p_in_rec.attribute6 ;
4589 	  x_out_rec.attribute7 := p_in_rec.attribute7 ;
4590 	  x_out_rec.attribute8 := p_in_rec.attribute8 ;
4591 	  x_out_rec.attribute9 := p_in_rec.attribute9 ;
4592 	  x_out_rec.attribute10 := p_in_rec.attribute10 ;
4593 	  x_out_rec.attribute11 := p_in_rec.attribute11 ;
4594 	  x_out_rec.attribute12 := p_in_rec.attribute12 ;
4595 	  x_out_rec.attribute13 := p_in_rec.attribute13 ;
4596 	  x_out_rec.attribute14 := p_in_rec.attribute14 ;
4597 	  x_out_rec.attribute15 := p_in_rec.attribute15 ;
4598 	  x_out_rec.attribute_category := p_in_rec.attribute_category ;
4599 	ELSIF p_disabled_list(i)  = 'SUBINVENTORY' THEN
4600 	  x_out_rec.subinventory := p_in_rec.subinventory ;
4601 	ELSIF p_disabled_list(i)  = 'REVISION' THEN
4602 	  x_out_rec.revision := p_in_rec.revision ;
4603 	ELSIF p_disabled_list(i)  = 'LOCATOR_NAME' THEN
4604 	  x_out_rec.locator_id := p_in_rec.locator_id ;
4605 	ELSIF p_disabled_list(i)  = 'LOT_NUMBER' THEN
4606 	  x_out_rec.lot_number := p_in_rec.lot_number;
4607 	ELSIF p_disabled_list(i)  = 'DELIVERED_QUANTITY2' THEN
4608 	  x_out_rec.delivered_quantity2 := p_in_rec.delivered_quantity2 ;
4609 	ELSIF p_disabled_list(i)  = 'DELIVERED_QUANTITY' THEN
4610 	  x_out_rec.delivered_quantity := p_in_rec.delivered_quantity ;
4611 	ELSIF p_disabled_list(i)  = 'DETAIL_CONTAINER_ITEM_NAME' THEN
4612 	  x_out_rec.detail_container_item_id := p_in_rec.detail_container_item_id ;
4613 	ELSIF p_disabled_list(i)  = 'GROSS_WEIGHT' THEN
4614 	  x_out_rec.gross_weight := p_in_rec.gross_weight ;
4615         ELSIF p_disabled_list(i)  = 'TARE_WEIGHT' THEN
4616           null;
4617 -- J-IB-NPARIKH-{  ---I-bug-fix
4618  ELSIF p_disabled_list(i)  = 'NET_WEIGHT' THEN
4619    x_out_rec.net_weight := p_in_rec.net_weight ;
4620  ELSIF p_disabled_list(i)  = 'VOLUME' THEN
4621    x_out_rec.VOLUME := p_in_rec.VOLUME ;
4622 -- J-IB-NPARIKH-}
4623         -- J: W/V Changes
4624         ELSIF p_disabled_list(i)  = 'FILLED_VOLUME' THEN
4625           x_out_rec.FILLED_VOLUME := p_in_rec.FILLED_VOLUME ;
4626         ELSIF p_disabled_list(i)  = 'FILL_PERCENT' THEN
4627           x_out_rec.FILLED_VOLUME := p_in_rec.FILL_PERCENT ;
4628 
4629 	ELSIF p_disabled_list(i)  = 'LOAD_SEQ_NUMBER' THEN
4630 	  x_out_rec.load_seq_number := p_in_rec.load_seq_number ;
4631 	ELSIF p_disabled_list(i)  = 'MASTER_CONTAINER_ITEM_NAME' THEN
4632 	  x_out_rec.master_container_item_id := p_in_rec.master_container_item_id ;
4633 	ELSIF p_disabled_list(i)  = 'PACKING_INSTRUCTIONS' THEN
4634 	  x_out_rec.PACKING_INSTRUCTIONS := p_in_rec.PACKING_INSTRUCTIONS ;
4635 	ELSIF p_disabled_list(i)  = 'SHIPPING_INSTRUCTIONS' THEN
4636 	  x_out_rec.shipping_instructions := p_in_rec.shipping_instructions ;
4637 	ELSIF p_disabled_list(i)  = 'SHIPPED_QUANTITY' THEN
4638 	  x_out_rec.shipped_quantity := p_in_rec.shipped_quantity ;
4639 	ELSIF p_disabled_list(i)  = 'SEAL_CODE' THEN
4640 	  x_out_rec.seal_code := p_in_rec.seal_code ;
4641 	ELSIF p_disabled_list(i)  = 'SHIPPED_QUANTITY2' THEN
4642 	  x_out_rec.shipped_quantity2 := p_in_rec.shipped_quantity2 ;
4643 	ELSIF p_disabled_list(i)  = 'TP_FLEXFIELD' THEN
4644 	  x_out_rec.tp_attribute1 := p_in_rec.tp_attribute1 ;
4645 	  x_out_rec.tp_attribute2 := p_in_rec.tp_attribute2 ;
4646 	  x_out_rec.tp_attribute3 := p_in_rec.tp_attribute3 ;
4647 	  x_out_rec.tp_attribute4 := p_in_rec.tp_attribute4 ;
4648 	  x_out_rec.tp_attribute5 := p_in_rec.tp_attribute5 ;
4649 	  x_out_rec.tp_attribute6 := p_in_rec.tp_attribute6 ;
4650 	  x_out_rec.tp_attribute7 := p_in_rec.tp_attribute7 ;
4651 	  x_out_rec.tp_attribute8 := p_in_rec.tp_attribute8 ;
4652 	  x_out_rec.tp_attribute9 := p_in_rec.tp_attribute9 ;
4653 	  x_out_rec.tp_attribute10 := p_in_rec.tp_attribute10 ;
4654 	  x_out_rec.tp_attribute11 := p_in_rec.tp_attribute11 ;
4655 	  x_out_rec.tp_attribute12 := p_in_rec.tp_attribute12 ;
4656 	  x_out_rec.tp_attribute13 := p_in_rec.tp_attribute13 ;
4657 	  x_out_rec.tp_attribute14 := p_in_rec.tp_attribute14 ;
4658 	  x_out_rec.tp_attribute15 := p_in_rec.tp_attribute15 ;
4659 	  x_out_rec.tp_attribute_category := p_in_rec.tp_attribute_category ;
4660 	ELSIF p_disabled_list(i)  = 'TRACKING_NUMBER' THEN
4661 	  x_out_rec.tracking_number := p_in_rec.tracking_number ;
4662         -- Commenting out Tare weight Field to make it enable for non-container
4663         -- items for bug 2890559
4664 /*	ELSIF p_disabled_list(i)  = 'TARE_WEIGHT'
4665 	   OR p_disabled_list(i)  = 'FULL'		THEN*/
4666         ELSIF p_disabled_list(i)  = 'FULL' THEN
4667 	  NULL;
4668 	ELSE
4669 	  -- invalid name
4670 	  x_field_name := p_disabled_list(i);
4671 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4672 	  RETURN;
4673 	  --
4674 	END IF;
4675   END LOOP;
4676 END disable_from_list;
4677 
4678 /*----------------------------------------------------------
4679 -- Procedure enable_from_list will update the record x_out_rec for the fields
4680 --   included in p_disabled_list and will enable them
4681 -----------------------------------------------------------*/
4682 
4683 PROCEDURE enable_from_list(
4684   p_disabled_list IN		 WSH_UTIL_CORE.column_tab_type
4685 , p_in_rec        IN            wsh_glbl_var_strct_grp.delivery_details_rec_type
4686 , x_out_rec       IN OUT NOCOPY wsh_glbl_var_strct_grp.delivery_details_rec_type
4687 , x_return_status OUT NOCOPY		 VARCHAR2
4688 , x_field_name	OUT NOCOPY		 VARCHAR2
4689 
4690 ) IS
4691 --Added as a part of fix for bug # 6082324 and bug 7165744 added msi.primary_uom_code to cursor
4692 cursor get_MSI_details (p_inventory_item_id NUMBER,p_delivery_detail_id NUMBER) IS
4693  SELECT msi.container_type_code,msi.maximum_load_weight,msi.primary_uom_code
4694  FROM   mtl_system_items msi,wsh_delivery_details wdd
4695  WHERE  msi.inventory_item_id (+) = p_inventory_item_id
4696  AND    msi.organization_id   (+) = wdd.organization_id
4697  AND    wdd.container_flag = 'Y'
4698  AND    wdd.delivery_detail_id = p_delivery_detail_id;
4699 
4700  l_container_type_code     VARCHAR2(30);
4701  l_maximum_load_weight     NUMBER;
4702  l_cursor_opened_flag      NUMBER := 0;
4703 -- End of bug # 6082324
4704  l_requested_quantity_uom  VARCHAR2(30); --bug 7165744
4705 BEGIN
4706   --
4707   --
4708   FOR i IN 2..p_disabled_list.COUNT
4709   LOOP
4710 	IF p_disabled_list(i)  = 'CONTAINER_NAME' THEN
4711 	 IF p_in_rec.CONTAINER_NAME <> FND_API.G_MISS_CHAR
4712 	  OR p_in_rec.CONTAINER_NAME IS NULL THEN
4713 	   x_out_rec.container_name := p_in_rec.container_name ;
4714 	 END IF;
4715 	ELSIF p_disabled_list(i)  = 'CYCLE_COUNT_QUANTITY' THEN
4716 	 IF p_in_rec.cycle_count_quantity <> FND_API.G_MISS_NUM
4717 	  OR p_in_rec.cycle_count_quantity IS NULL THEN
4718 	   x_out_rec.cycle_count_quantity := p_in_rec.cycle_count_quantity ;
4719 	 END IF;
4720 	ELSIF p_disabled_list(i)  = 'INSPECTION_FLAG' THEN
4721 	 IF p_in_rec.INSPECTION_FLAG <> FND_API.G_MISS_CHAR
4722 	  OR p_in_rec.INSPECTION_FLAG IS NULL THEN
4723 	   x_out_rec.INSPECTION_FLAG := p_in_rec.INSPECTION_FLAG ;
4724 	 END IF;
4725 	ELSIF p_disabled_list(i)  = 'CYCLE_COUNT_QUANTITY2' THEN
4726 	 IF p_in_rec.cycle_count_quantity2 <> FND_API.G_MISS_NUM
4727 	  OR p_in_rec.cycle_count_quantity2 IS NULL THEN
4728 	   x_out_rec.cycle_count_quantity2 := p_in_rec.cycle_count_quantity2 ;
4729 	 END IF;
4730 	ELSIF p_disabled_list(i)  = 'CANCELLED_QUANTITY2' THEN
4731 	 IF p_in_rec.cancelled_quantity2 <> FND_API.G_MISS_NUM
4732 	  OR p_in_rec.cancelled_quantity2 IS NULL THEN
4733 	   x_out_rec.cancelled_quantity2 := p_in_rec.cancelled_quantity2 ;
4734 	 END IF;
4735 	ELSIF p_disabled_list(i)  = 'CANCELLED_QUANTITY' THEN
4736 	 IF p_in_rec.cancelled_quantity <> FND_API.G_MISS_NUM
4737 	  OR p_in_rec.cancelled_quantity IS NULL THEN
4738 	   x_out_rec.cancelled_quantity := p_in_rec.cancelled_quantity ;
4739 	 END IF;
4740 	ELSIF p_disabled_list(i)  = 'DELIVERED_QUANTITY2' THEN
4741 	 IF p_in_rec.delivered_quantity2 <> FND_API.G_MISS_NUM
4742 	  OR p_in_rec.delivered_quantity2 IS NULL THEN
4743 	   x_out_rec.delivered_quantity2 := p_in_rec.delivered_quantity2 ;
4744 	 END IF;
4745 	ELSIF p_disabled_list(i)  = 'DELIVERED_QUANTITY' THEN
4746 	 IF p_in_rec.delivered_quantity <> FND_API.G_MISS_NUM
4747 	  OR p_in_rec.delivered_quantity IS NULL THEN
4748 	   x_out_rec.delivered_quantity := p_in_rec.delivered_quantity ;
4749 	 END IF;
4750 	ELSIF p_disabled_list(i)  = 'DETAIL_CONTAINER_ITEM_NAME' THEN
4751 	 IF p_in_rec.detail_container_item_id <> FND_API.G_MISS_NUM
4752 	  OR p_in_rec.detail_container_item_id IS NULL THEN
4753 	   x_out_rec.detail_container_item_id := p_in_rec.detail_container_item_id ;
4754 	 END IF;
4755 -- for X-dock
4756 	ELSIF p_disabled_list(i)  = 'RELEASED_STATUS' THEN
4757 	 IF p_in_rec.released_status <> FND_API.G_MISS_CHAR
4758 	  OR p_in_rec.released_status IS NULL THEN
4759 	   x_out_rec.released_status := p_in_rec.released_status;
4760 	 END IF;
4761 	ELSIF p_disabled_list(i)  = 'MOVE_ORDER_LINE_ID' THEN
4762 	 IF p_in_rec.move_order_line_id <> FND_API.G_MISS_NUM
4763 	  OR p_in_rec.move_order_line_id IS NULL THEN
4764 	   x_out_rec.move_order_line_id := p_in_rec.move_order_line_id;
4765 	 END IF;
4766     --bug# 6689448 (replenishment project)
4767  	ELSIF p_disabled_list(i)  = 'REPLENISHMENT_STATUS' THEN
4768         IF p_in_rec.REPLENISHMENT_STATUS <> FND_API.G_MISS_CHAR
4769            OR p_in_rec. REPLENISHMENT_STATUS IS NULL THEN
4770             x_out_rec.REPLENISHMENT_STATUS:= p_in_rec.REPLENISHMENT_STATUS;
4771         END IF;
4772     ELSIF p_disabled_list(i)  = 'BATCH_ID' THEN
4773          IF p_in_rec.batch_id <> FND_API.G_MISS_NUM
4774           OR p_in_rec.batch_id IS NULL THEN
4775            x_out_rec.batch_id := p_in_rec.batch_id;
4776          END IF;
4777 -- end of X-dock changes
4778 	ELSIF p_disabled_list(i)  = 'GROSS_WEIGHT' THEN
4779 	 IF p_in_rec.gross_weight <> FND_API.G_MISS_NUM
4780 	  OR p_in_rec.gross_weight IS NULL THEN
4781 	   x_out_rec.gross_weight := p_in_rec.gross_weight ;
4782 	 END IF;
4783 	ELSIF p_disabled_list(i)  = 'TARE_WEIGHT' THEN
4784 	   null;
4785 -- J-IB-NPARIKH-{       --I-bug-fix
4786  ELSIF p_disabled_list(i)  = 'NET_WEIGHT' THEN
4787   IF p_in_rec.net_weight <> FND_API.G_MISS_NUM
4788    OR p_in_rec.net_weight IS NULL THEN
4789     x_out_rec.net_weight := p_in_rec.net_weight ;
4790   END IF;
4791  ELSIF p_disabled_list(i)  = 'VOLUME' THEN
4792   IF p_in_rec.VOLUME <> FND_API.G_MISS_NUM
4793    OR p_in_rec.VOLUME IS NULL THEN
4794     x_out_rec.VOLUME := p_in_rec.VOLUME ;
4795   END IF;
4796   -- J-IB-NPARIKH-}
4797         -- bug 5077108
4798         ELSIF p_disabled_list(i)  = 'INVENTORY_ITEM_ID' THEN
4799          IF p_in_rec.inventory_item_id <> FND_API.G_MISS_NUM
4800           OR p_in_rec.inventory_item_id IS NULL THEN
4801            x_out_rec.inventory_item_id := p_in_rec.inventory_item_id ;
4802          END IF;
4803         -- end bug 5077108
4804 
4805         --Bug 5212632 Start
4806         ELSIF p_disabled_list(i)  = 'CONTAINER_TYPE_CODE' THEN
4807             IF p_in_rec.container_type_code <> FND_API.G_MISS_CHAR
4808                OR p_in_rec.container_type_code IS NULL THEN
4809 
4810                    x_out_rec.container_type_code := p_in_rec.container_type_code;
4811             ELSIF (p_in_rec.inventory_item_id <> FND_API.G_MISS_NUM ) THEN
4812 	    IF l_cursor_opened_flag = 1 THEN
4813             x_out_rec.container_type_code:=l_container_type_code;
4814             ELSE
4815             OPEN get_MSI_details (p_in_rec.inventory_item_id,p_in_rec.delivery_detail_id);
4816             FETCH get_MSI_details INTO l_container_type_code,
4817                                     l_maximum_load_weight,
4818                                     l_requested_quantity_uom;
4819              x_out_rec.container_type_code:=l_container_type_code;
4820             CLOSE get_MSI_details ;
4821             l_cursor_opened_flag:=1;
4822             END IF;
4823             END IF;
4824             --Bug 5212632 End
4825             --Bug 7165744
4826      --requested_quantity_uom can be updated for WMS LPNs.
4827         ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY_UOM' THEN
4828          IF (p_in_rec.inventory_item_id <> FND_API.G_MISS_NUM ) THEN
4829           IF l_cursor_opened_flag = 1 THEN
4830             x_out_rec.requested_quantity_uom:=l_requested_quantity_uom;
4831           ELSE
4832           OPEN get_MSI_details (p_in_rec.inventory_item_id,p_in_rec.delivery_detail_id);
4833           FETCH get_MSI_details INTO l_container_type_code,
4834                                      l_maximum_load_weight,
4835                                      l_requested_quantity_uom;
4836            x_out_rec.requested_quantity_uom:=l_requested_quantity_uom;
4837            CLOSE get_MSI_details ;
4838            l_cursor_opened_flag:=1;
4839            END IF;
4840           END IF;
4841      -- end Bug 7165744
4842      --Added the following code as part of fix for bug 6082324
4843         ELSIF p_disabled_list(i)  = 'MAXIMUM_LOAD_WEIGHT' THEN
4844          IF p_in_rec.MAXIMUM_LOAD_WEIGHT <> FND_API.G_MISS_NUM
4845          OR p_in_rec.MAXIMUM_LOAD_WEIGHT IS NULL THEN
4846             x_out_rec.MAXIMUM_LOAD_WEIGHT := p_in_rec.MAXIMUM_LOAD_WEIGHT;
4847          ELSIF (p_in_rec.inventory_item_id <> FND_API.G_MISS_NUM ) THEN
4848           IF l_cursor_opened_flag = 1 THEN
4849              x_out_rec.MAXIMUM_LOAD_WEIGHT:=l_maximum_load_weight;
4850           ELSE
4851             OPEN get_MSI_details (p_in_rec.inventory_item_id,p_in_rec.delivery_detail_id);
4852             FETCH get_MSI_details INTO l_container_type_code,
4853                                        l_maximum_load_weight,
4854                                        l_requested_quantity_uom;
4855             CLOSE get_MSI_details ;
4856             l_cursor_opened_flag:=1;
4857             x_out_rec.MAXIMUM_LOAD_WEIGHT:=l_maximum_load_weight;
4858            END IF;
4859          END IF;
4860       --End of fix for bug # 6082324
4861 
4862 
4863 	ELSIF p_disabled_list(i)  = 'LOCATOR_NAME' THEN
4864 	 IF p_in_rec.locator_id <> FND_API.G_MISS_NUM
4865 	  OR p_in_rec.locator_id IS NULL THEN
4866 	   x_out_rec.locator_id := p_in_rec.locator_id ;
4867 	 END IF;
4868 	ELSIF p_disabled_list(i)  = 'LOAD_SEQ_NUMBER' THEN
4869 	 IF p_in_rec.load_seq_number <> FND_API.G_MISS_NUM
4870 	  OR p_in_rec.load_seq_number IS NULL THEN
4871 	   x_out_rec.load_seq_number := p_in_rec.load_seq_number ;
4872 	 END IF;
4873 	ELSIF p_disabled_list(i)  = 'LPN_ID' THEN
4874 	 IF p_in_rec.lpn_id <> FND_API.G_MISS_NUM
4875 	  OR p_in_rec.lpn_id IS NULL THEN
4876 	   x_out_rec.lpn_id := p_in_rec.lpn_id ;
4877 	 END IF;
4878 	ELSIF p_disabled_list(i)  = 'MASTER_CONTAINER_ITEM_NAME' THEN
4879 	 IF p_in_rec.master_container_item_id <> FND_API.G_MISS_NUM
4880 	  OR p_in_rec.master_container_item_id IS NULL THEN
4881 	   x_out_rec.master_container_item_id := p_in_rec.master_container_item_id ;
4882 	 END IF;
4883 	ELSIF p_disabled_list(i)  = 'PACKING_INSTRUCTIONS' THEN
4884 	 IF p_in_rec.PACKING_INSTRUCTIONS <> FND_API.G_MISS_CHAR
4885 	  OR p_in_rec.PACKING_INSTRUCTIONS IS NULL THEN
4886 	   x_out_rec.PACKING_INSTRUCTIONS := p_in_rec.PACKING_INSTRUCTIONS ;
4887 	 END IF;
4888         ELSIF p_disabled_list(i)  = 'PICKED_QUANTITY2' THEN
4889          IF p_in_rec.PICKED_QUANTITY2 <> FND_API.G_MISS_NUM
4890           OR p_in_rec.PICKED_QUANTITY2 IS NULL THEN
4891            x_out_rec.picked_quantity2 := p_in_rec.picked_quantity2 ;
4892          END IF;
4893         ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY_UOM2' THEN
4894          IF p_in_rec.REQUESTED_QUANTITY_UOM2 <> FND_API.G_MISS_CHAR
4895           OR p_in_rec.REQUESTED_QUANTITY_UOM2 IS NULL THEN
4896            x_out_rec.REQUESTED_QUANTITY_UOM2 := p_in_rec.REQUESTED_QUANTITY_UOM2 ;
4897          END IF;
4898 
4899         -- bmso
4900         ELSIF p_disabled_list(i)  = 'PREFERED_GRADE' THEN
4901          IF p_in_rec.PREFERRED_GRADE <> FND_API.G_MISS_CHAR
4902           OR p_in_rec.PREFERRED_GRADE IS NULL THEN
4903            x_out_rec.PREFERRED_GRADE := p_in_rec.PREFERRED_GRADE ;
4904          END IF;
4905         ELSIF p_disabled_list(i)  = 'SRC_REQUESTED_QUANTITY2' THEN
4906          IF p_in_rec.SRC_REQUESTED_QUANTITY2 <> FND_API.G_MISS_NUM
4907           OR p_in_rec.SRC_REQUESTED_QUANTITY2 IS NULL THEN
4908            x_out_rec.SRC_REQUESTED_QUANTITY2 := p_in_rec.SRC_REQUESTED_QUANTITY2 ;
4909          END IF;
4910         ELSIF p_disabled_list(i)  = 'SRC_REQUESTED_QUANTITY_UOM2' THEN
4911          IF p_in_rec.SRC_REQUESTED_QUANTITY_UOM2 <> FND_API.G_MISS_CHAR
4912           OR p_in_rec.SRC_REQUESTED_QUANTITY_UOM2 IS NULL THEN
4913            x_out_rec.SRC_REQUESTED_QUANTITY_UOM2 := p_in_rec.SRC_REQUESTED_QUANTITY_UOM2 ;
4914          END IF;
4915         ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY2' THEN
4916          IF p_in_rec.REQUESTED_QUANTITY2 <> FND_API.G_MISS_NUM
4917           OR p_in_rec.REQUESTED_QUANTITY2 IS NULL THEN
4918            x_out_rec.REQUESTED_QUANTITY2 := p_in_rec.REQUESTED_QUANTITY2 ;
4919          END IF;
4920         ELSIF p_disabled_list(i)  = 'QUALITY_CONTROL_QUANTITY2' THEN
4921          IF p_in_rec.QUALITY_CONTROL_QUANTITY2 <> FND_API.G_MISS_NUM
4922           OR p_in_rec.QUALITY_CONTROL_QUANTITY2 IS NULL THEN
4923            x_out_rec.QUALITY_CONTROL_QUANTITY2 := p_in_rec.QUALITY_CONTROL_QUANTITY2 ;
4924          END IF;
4925         ELSIF p_disabled_list(i)  = 'SUBLOT_NUMBER' THEN
4926          NULL;
4927          --IF p_in_rec.SUBLOT_NUMBER <> FND_API.G_MISS_CHAR
4928           --OR p_in_rec.SUBLOT_NUMBER IS NULL THEN
4929            --x_out_rec.SUBLOT_NUMBER := p_in_rec.SUBLOT_NUMBER ;
4930          --END IF;
4931         ELSIF p_disabled_list(i)  = 'RETURNED_QUANTITY2' THEN
4932          IF p_in_rec.RETURNED_QUANTITY2 <> FND_API.G_MISS_NUM
4933           OR p_in_rec.RETURNED_QUANTITY2 IS NULL THEN
4934            x_out_rec.RETURNED_QUANTITY2 := p_in_rec.RETURNED_QUANTITY2 ;
4935          END IF;
4936         ELSIF p_disabled_list(i)  = 'RECEIVED_QUANTITY2' THEN
4937          IF p_in_rec.RECEIVED_QUANTITY2 <> FND_API.G_MISS_NUM
4938           OR p_in_rec.RECEIVED_QUANTITY2 IS NULL THEN
4939            x_out_rec.RECEIVED_QUANTITY2 := p_in_rec.RECEIVED_QUANTITY2 ;
4940          END IF;
4941         ELSIF p_disabled_list(i)  = 'PICKED_QUANTITY2' THEN
4942          IF p_in_rec.PICKED_QUANTITY2 <> FND_API.G_MISS_NUM
4943           OR p_in_rec.PICKED_QUANTITY2 IS NULL THEN
4944            x_out_rec.PICKED_QUANTITY2 := p_in_rec.PICKED_QUANTITY2 ;
4945          END IF;
4946         ELSIF p_disabled_list(i)  = 'TO_SERIAL_NUMBER' THEN
4947          IF p_in_rec.TO_SERIAL_NUMBER <> FND_API.G_MISS_CHAR
4948           OR p_in_rec.TO_SERIAL_NUMBER IS NULL THEN
4949            x_out_rec.TO_SERIAL_NUMBER := p_in_rec.TO_SERIAL_NUMBER ;
4950          END IF;
4951         ELSIF p_disabled_list(i)  = 'SERIAL_NUMBER' THEN
4952          IF p_in_rec.SERIAL_NUMBER <> FND_API.G_MISS_CHAR
4953           OR p_in_rec.SERIAL_NUMBER IS NULL THEN
4954            x_out_rec.SERIAL_NUMBER := p_in_rec.SERIAL_NUMBER ;
4955          END IF;
4956         ELSIF p_disabled_list(i)  = 'TRANSACTION_TEMP_ID' THEN
4957          IF p_in_rec.TRANSACTION_TEMP_ID <> FND_API.G_MISS_NUM
4958           OR p_in_rec.TRANSACTION_TEMP_ID IS NULL THEN
4959            x_out_rec.TRANSACTION_TEMP_ID := p_in_rec.TRANSACTION_TEMP_ID ;
4960          END IF;
4961         ELSIF p_disabled_list(i)  = 'REVISION' THEN
4962          IF p_in_rec.REVISION <> FND_API.G_MISS_CHAR
4963           OR p_in_rec.REVISION IS NULL THEN
4964            x_out_rec.REVISION := p_in_rec.REVISION ;
4965          END IF;
4966         ELSIF p_disabled_list(i)  = 'LOT_NUMBER' THEN
4967          IF p_in_rec.LOT_NUMBER <> FND_API.G_MISS_CHAR
4968           OR p_in_rec.LOT_NUMBER IS NULL THEN
4969            x_out_rec.LOT_NUMBER := p_in_rec.LOT_NUMBER ;
4970          END IF;
4971         ELSIF p_disabled_list(i)  = 'REQUESTED_QUANTITY_UOM' THEN
4972          IF p_in_rec.REQUESTED_QUANTITY_UOM <> FND_API.G_MISS_CHAR
4973           OR p_in_rec.REQUESTED_QUANTITY_UOM IS NULL THEN
4974            x_out_rec.REQUESTED_QUANTITY_UOM := p_in_rec.REQUESTED_QUANTITY_UOM ;
4975          END IF;
4976         --
4977 	ELSIF p_disabled_list(i)  = 'SHIPPING_INSTRUCTIONS' THEN
4978 	 IF p_in_rec.shipping_instructions <> FND_API.G_MISS_CHAR
4979 	  OR p_in_rec.shipping_instructions IS NULL THEN
4980 	   x_out_rec.shipping_instructions := p_in_rec.shipping_instructions ;
4981 	 END IF;
4982 	ELSIF p_disabled_list(i)  = 'SHIPPED_QUANTITY' THEN
4983 	 IF p_in_rec.shipped_quantity <> FND_API.G_MISS_NUM
4984 	  OR p_in_rec.shipped_quantity IS NULL THEN
4985 	   x_out_rec.shipped_quantity := p_in_rec.shipped_quantity ;
4986 	 END IF;
4987 	ELSIF p_disabled_list(i)  = 'SEAL_CODE' THEN
4988 	 IF p_in_rec.seal_code <> FND_API.G_MISS_CHAR
4989 	  OR p_in_rec.seal_code IS NULL THEN
4990 	   x_out_rec.seal_code := p_in_rec.seal_code ;
4991 	 END IF;
4992 	ELSIF p_disabled_list(i)  = 'SHIPPED_QUANTITY2' THEN
4993 	 IF p_in_rec.shipped_quantity2 <> FND_API.G_MISS_NUM
4994 	  OR p_in_rec.shipped_quantity2 IS NULL THEN
4995 	   x_out_rec.shipped_quantity2 := p_in_rec.shipped_quantity2 ;
4996 	 END IF;
4997 	ELSIF p_disabled_list(i)  = 'SUBINVENTORY' THEN
4998 	 IF p_in_rec.subinventory <> FND_API.G_MISS_CHAR
4999 	  OR p_in_rec.subinventory IS NULL THEN
5000 	   x_out_rec.subinventory := p_in_rec.subinventory ;
5001 	 END IF;
5002 	  --Bugfix 6939348 start
5003 	ELSIF p_disabled_list(i)  = 'LOT_NUMBER' THEN
5004 	 IF p_in_rec.lot_number <> FND_API.G_MISS_CHAR
5005 	  OR p_in_rec.lot_number IS NULL THEN
5006 	   x_out_rec.lot_number := p_in_rec.lot_number;
5007 	 END IF;
5008 	-- Bugfix 6939348 end
5009 	ELSIF p_disabled_list(i)  = 'TRACKING_NUMBER' THEN
5010 	 IF p_in_rec.tracking_number <> FND_API.G_MISS_CHAR
5011 	  OR p_in_rec.tracking_number IS NULL THEN
5012 	   x_out_rec.tracking_number := p_in_rec.tracking_number ;
5013 	 END IF;
5014         ELSIF p_disabled_list(i)  = 'SHIP_METHOD_CODE' THEN
5015          IF p_in_rec.ship_method_code <> FND_API.G_MISS_CHAR
5016           OR p_in_rec.ship_method_code IS NULL THEN
5017            x_out_rec.ship_method_code := p_in_rec.ship_method_code ;
5018          END IF;
5019         ELSIF p_disabled_list(i)  = 'CARRIER_ID' THEN
5020          IF p_in_rec.carrier_id <> FND_API.G_MISS_NUM
5021           OR p_in_rec.carrier_id IS NULL THEN
5022            x_out_rec.carrier_id := p_in_rec.carrier_id ;
5023          END IF;
5024         ELSIF p_disabled_list(i)  = 'MODE_OF_TRANSPORT' THEN
5025          IF p_in_rec.ship_method_code <> FND_API.G_MISS_CHAR
5026           OR p_in_rec.mode_of_transport IS NULL THEN
5027            x_out_rec.mode_of_transport := p_in_rec.mode_of_transport ;
5028          END IF;
5029         ELSIF p_disabled_list(i)  = 'SERVICE_LEVEL' THEN
5030          IF p_in_rec.service_level <> FND_API.G_MISS_CHAR
5031           OR p_in_rec.service_level IS NULL THEN
5032            x_out_rec.service_level := p_in_rec.service_level ;
5033          END IF;
5034         ELSIF p_disabled_list(i)  = 'ITEM_NUMBER' THEN
5035          IF nvl(p_in_rec.inventory_item_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM
5036          THEN
5037            x_out_rec.inventory_item_id := p_in_rec.inventory_item_id ;
5038          END IF;
5039 	ELSIF p_disabled_list(i)  = 'DESC_FLEX' THEN
5040 	 IF p_in_rec.attribute1 <> FND_API.G_MISS_CHAR
5041 	  OR p_in_rec.attribute1 IS NULL THEN
5042 	   x_out_rec.attribute1 := p_in_rec.attribute1 ;
5043 	 END IF;
5044 	 IF p_in_rec.attribute2 <> FND_API.G_MISS_CHAR
5045 	  OR p_in_rec.attribute2  IS NULL THEN
5046 	   x_out_rec.attribute2 := p_in_rec.attribute2 ;
5047 	 END IF;
5048 	 IF p_in_rec.attribute3 <> FND_API.G_MISS_CHAR
5049 	  OR p_in_rec.attribute3 IS NULL THEN
5050 	  x_out_rec.attribute3 := p_in_rec.attribute3 ;
5051 	 END IF;
5052 	 IF p_in_rec.attribute4 <> FND_API.G_MISS_CHAR
5053 	  OR p_in_rec.attribute4 IS NULL THEN
5054 	  x_out_rec.attribute4 := p_in_rec.attribute4 ;
5055 	 END IF;
5056 	 IF p_in_rec.attribute5 <> FND_API.G_MISS_CHAR
5057 	  OR p_in_rec.attribute5 IS NULL THEN
5058 	  x_out_rec.attribute5 := p_in_rec.attribute5 ;
5059 	 END IF;
5060 	 IF p_in_rec.attribute6 <> FND_API.G_MISS_CHAR
5061 	  OR p_in_rec.attribute6 IS NULL THEN
5062 	  x_out_rec.attribute6 := p_in_rec.attribute6 ;
5063 	 END IF;
5064 	 IF p_in_rec.attribute7 <> FND_API.G_MISS_CHAR
5065 	  OR p_in_rec.attribute7 IS NULL THEN
5066 	  x_out_rec.attribute7 := p_in_rec.attribute7 ;
5067 	 END IF;
5068 	 IF p_in_rec.attribute8 <> FND_API.G_MISS_CHAR
5069 	  OR p_in_rec.attribute8 IS NULL THEN
5070 	  x_out_rec.attribute8 := p_in_rec.attribute8 ;
5071 	 END IF;
5072 	 IF p_in_rec.attribute9 <> FND_API.G_MISS_CHAR
5073 	  OR p_in_rec.attribute9 IS NULL THEN
5074 	  x_out_rec.attribute9 := p_in_rec.attribute9 ;
5075 	 END IF;
5076 	 IF p_in_rec.attribute10 <> FND_API.G_MISS_CHAR
5077 	  OR p_in_rec.attribute10 IS NULL THEN
5078 	  x_out_rec.attribute10 := p_in_rec.attribute10 ;
5079 	 END IF;
5080 	 IF p_in_rec.attribute11 <> FND_API.G_MISS_CHAR
5081 	  OR p_in_rec.attribute11 IS NULL THEN
5082 	  x_out_rec.attribute11 := p_in_rec.attribute11 ;
5083 	 END IF;
5084 	 IF p_in_rec.attribute12 <> FND_API.G_MISS_CHAR
5085 	  OR p_in_rec.attribute12 IS NULL THEN
5086 	  x_out_rec.attribute12 := p_in_rec.attribute12 ;
5087 	 END IF;
5088 	 IF p_in_rec.attribute13 <> FND_API.G_MISS_CHAR
5089 	  OR p_in_rec.attribute13 IS NULL THEN
5090 	  x_out_rec.attribute13 := p_in_rec.attribute13 ;
5091 	 END IF;
5092 	 IF p_in_rec.attribute14 <> FND_API.G_MISS_CHAR
5093 	  OR p_in_rec.attribute14 IS NULL THEN
5094 	  x_out_rec.attribute14 := p_in_rec.attribute14 ;
5095 	 END IF;
5096 	 IF p_in_rec.attribute15 <> FND_API.G_MISS_CHAR
5097 	  OR p_in_rec.attribute15 IS NULL THEN
5098 	  x_out_rec.attribute15 := p_in_rec.attribute15 ;
5099 	 END IF;
5100 	 IF p_in_rec.attribute_category <> FND_API.G_MISS_CHAR
5101 	  OR p_in_rec.attribute_category IS NULL THEN
5102 	  x_out_rec.attribute_category := p_in_rec.attribute_category ;
5103 	 END IF;
5104 	ELSIF p_disabled_list(i)  = 'TP_FLEXFIELD' THEN
5105 	 IF p_in_rec.tp_attribute1 <> FND_API.G_MISS_CHAR
5106 	  OR p_in_rec.tp_attribute1 IS NULL THEN
5107 	  x_out_rec.tp_attribute1 := p_in_rec.tp_attribute1 ;
5108 	 END IF;
5109 	 IF p_in_rec.tp_attribute2 <> FND_API.G_MISS_CHAR
5110 	  OR p_in_rec.tp_attribute2 IS NULL THEN
5111 	  x_out_rec.tp_attribute2 := p_in_rec.tp_attribute2 ;
5112 	 END IF;
5113 	 IF p_in_rec.tp_attribute3 <> FND_API.G_MISS_CHAR
5114 	  OR p_in_rec.tp_attribute3 IS NULL THEN
5115 	  x_out_rec.tp_attribute3 := p_in_rec.tp_attribute3 ;
5116 	 END IF;
5117 	 IF p_in_rec.tp_attribute4 <> FND_API.G_MISS_CHAR
5118 	  OR p_in_rec.tp_attribute4 IS NULL THEN
5119 	  x_out_rec.tp_attribute4 := p_in_rec.tp_attribute4 ;
5120 	 END IF;
5121 	 IF p_in_rec.tp_attribute5 <> FND_API.G_MISS_CHAR
5122 	  OR p_in_rec.tp_attribute5 IS NULL THEN
5123 	  x_out_rec.tp_attribute5 := p_in_rec.tp_attribute5 ;
5124 	 END IF;
5125 	 IF p_in_rec.tp_attribute6 <> FND_API.G_MISS_CHAR
5126 	  OR p_in_rec.tp_attribute6 IS NULL THEN
5127 	  x_out_rec.tp_attribute6 := p_in_rec.tp_attribute6 ;
5128 	 END IF;
5129 	 IF p_in_rec.tp_attribute7 <> FND_API.G_MISS_CHAR
5130 	  OR p_in_rec.tp_attribute7 IS NULL THEN
5131 	  x_out_rec.tp_attribute7 := p_in_rec.tp_attribute7 ;
5132 	 END IF;
5133 	 IF p_in_rec.tp_attribute8 <> FND_API.G_MISS_CHAR
5134 	  OR p_in_rec.tp_attribute8 IS NULL THEN
5135 	  x_out_rec.tp_attribute8 := p_in_rec.tp_attribute8 ;
5136 	 END IF;
5137 	 IF p_in_rec.tp_attribute9 <> FND_API.G_MISS_CHAR
5138 	  OR p_in_rec.tp_attribute9 IS NULL THEN
5139 	  x_out_rec.tp_attribute9 := p_in_rec.tp_attribute9 ;
5140 	 END IF;
5141 	 IF p_in_rec.tp_attribute10 <> FND_API.G_MISS_CHAR
5142 	  OR p_in_rec.tp_attribute10 IS NULL THEN
5143 	  x_out_rec.tp_attribute10 := p_in_rec.tp_attribute10 ;
5144 	 END IF;
5145 	 IF p_in_rec.tp_attribute11 <> FND_API.G_MISS_CHAR
5146 	  OR p_in_rec.tp_attribute11 IS NULL THEN
5147 	  x_out_rec.tp_attribute11 := p_in_rec.tp_attribute11 ;
5148 	 END IF;
5149 	 IF p_in_rec.tp_attribute12 <> FND_API.G_MISS_CHAR
5150 	  OR p_in_rec.tp_attribute12 IS NULL THEN
5151 	  x_out_rec.tp_attribute12 := p_in_rec.tp_attribute12 ;
5152 	 END IF;
5153 	 IF p_in_rec.tp_attribute13 <> FND_API.G_MISS_CHAR
5154 	  OR p_in_rec.tp_attribute13 IS NULL THEN
5155 	  x_out_rec.tp_attribute13 := p_in_rec.tp_attribute13 ;
5156 	 END IF;
5157 	 IF p_in_rec.tp_attribute14 <> FND_API.G_MISS_CHAR
5158 	  OR p_in_rec.tp_attribute14 IS NULL THEN
5159 	  x_out_rec.tp_attribute14 := p_in_rec.tp_attribute14 ;
5160 	 END IF;
5161 	 IF p_in_rec.tp_attribute15 <> FND_API.G_MISS_CHAR
5162 	  OR p_in_rec.tp_attribute15 IS NULL THEN
5163 	  x_out_rec.tp_attribute15 := p_in_rec.tp_attribute15 ;
5164 	 END IF;
5165 	 IF p_in_rec.tp_attribute_category <> FND_API.G_MISS_CHAR
5166 	  OR p_in_rec.tp_attribute_category IS NULL THEN
5167 	  x_out_rec.tp_attribute_category := p_in_rec.tp_attribute_category ;
5168 	 END IF;
5169         -- Commenting out Tare Weight field to make it enable for
5170         -- non-container items for bug 2890559
5171 /*	ELSIF p_disabled_list(i)  = 'TARE_WEIGHT'  THEN
5172 	  NULL;*/
5173 	ELSE
5174 	  -- invalid name
5175 	  x_field_name := p_disabled_list(i);
5176 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5177 	  RETURN;
5178 	  --
5179 	END IF;
5180   END LOOP;
5181 END enable_from_list;
5182 
5183 --
5184 -- Overloaded procedure
5185 --
5186 PROCEDURE Get_Disabled_List  (
5187   p_delivery_detail_rec   IN  wsh_glbl_var_strct_grp.delivery_details_rec_type
5188 , p_delivery_id		  IN  NUMBER
5189 , p_in_rec                IN  wsh_glbl_var_strct_grp.detailInRecType
5190 , x_return_status	  OUT NOCOPY VARCHAR2
5191 , x_msg_count		  OUT NOCOPY NUMBER
5192 , x_msg_data		  OUT NOCOPY VARCHAR2
5193 , x_delivery_detail_rec   OUT NOCOPY wsh_glbl_var_strct_grp.delivery_details_rec_type
5194 )
5195 IS
5196   l_disabled_list			   WSH_UTIL_CORE.column_tab_type;
5197   l_db_col_rec                             wsh_glbl_var_strct_grp.delivery_details_rec_type;
5198   l_return_status			   VARCHAR2(30);
5199   l_field_name				  VARCHAR2(100);
5200   j							 NUMBER := 0;
5201   l_status_code				 VARCHAR2(3);
5202   l_released_status			 VARCHAR2(1);
5203   l_lpn_id					  NUMBER;
5204   l_all_disabled				VARCHAR2(1):='N';
5205   l_inv_controls                         WSH_DELIVERY_DETAILS_INV.inv_control_flag_rec;
5206   l_inventory_item_id                    NUMBER;
5207   l_organization_id                      NUMBER;
5208   l_pickable_flag                        VARCHAR2(1);
5209   l_subinventory                         VARCHAR2(30);
5210   i  NUMBER;
5211 
5212 
5213 l_debug_on BOOLEAN;
5214   l_module_name CONSTANT VARCHAR2(100) :=
5215 			 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_DISABLED_LIST';
5216 
5217 
5218   CURSOR get_delivery_status IS
5219   SELECT status_code
5220   FROM   wsh_new_deliveries
5221   WHERE  delivery_id = p_delivery_id;
5222 
5223 
5224   CURSOR c_tbl_rec IS
5225   SELECT delivery_detail_id
5226 		,source_code
5227 		,source_header_id
5228 		,source_line_id
5229 		,customer_id
5230 		,sold_to_contact_id
5231 		,inventory_item_id
5232 		,item_description
5233 		,hazard_class_id
5234 		,country_of_origin
5235 		,classification
5236 		,ship_from_location_id
5237 		,ship_to_location_id
5238 		,ship_to_contact_id
5239 		,ship_to_site_use_id
5240 		,deliver_to_location_id
5241 		,deliver_to_contact_id
5242 		,deliver_to_site_use_id
5243 		,intmed_ship_to_location_id
5244 		,intmed_ship_to_contact_id
5245 		,hold_code
5246 		,ship_tolerance_above
5247 		,ship_tolerance_below
5248 		,requested_quantity
5249 		,shipped_quantity
5250 		,delivered_quantity
5251 		,requested_quantity_uom
5252 		,subinventory
5253 		,revision
5254 		,lot_number
5255 		,customer_requested_lot_flag
5256 		,serial_number
5257 		,locator_id
5258 		,date_requested
5259 		,date_scheduled
5260 		,master_container_item_id
5261 		,detail_container_item_id
5262 		,load_seq_number
5263 		,ship_method_code
5264 		,carrier_id
5265 		,freight_terms_code
5266 		,shipment_priority_code
5267 		,fob_code
5268 		,customer_item_id
5269 		,dep_plan_required_flag
5270 		,customer_prod_seq
5271 		,customer_dock_code
5272 		,cust_model_serial_number
5273 		,customer_job
5274 		,customer_production_line
5275 		,net_weight
5276 		,weight_uom_code
5277 		,volume
5278 		,volume_uom_code
5279 		,tp_attribute_category
5280 		,tp_attribute1
5281 		,tp_attribute2
5282 		,tp_attribute3
5283 		,tp_attribute4
5284 		,tp_attribute5
5285 		,tp_attribute6
5286 		,tp_attribute7
5287 		,tp_attribute8
5288 		,tp_attribute9
5289 		,tp_attribute10
5290 		,tp_attribute11
5291 		,tp_attribute12
5292 		,tp_attribute13
5293 		,tp_attribute14
5294 		,tp_attribute15
5295 		,attribute_category
5296 		,attribute1
5297 		,attribute2
5298 		,attribute3
5299 		,attribute4
5300 		,attribute5
5301 		,attribute6
5302 		,attribute7
5303 		,attribute8
5304 		,attribute9
5305 		,attribute10
5306 		,attribute11
5307 		,attribute12
5308 		,attribute13
5309 		,attribute14
5310 		,attribute15
5311 		,created_by
5312 		,creation_date
5313                 ,sysdate
5314                 ,FND_GLOBAL.LOGIN_ID
5315                 ,FND_GLOBAL.USER_ID
5316 		,program_application_id
5317 		,program_id
5318 		,program_update_date
5319 		,request_id
5320 		,mvt_stat_status
5321 		,p_delivery_detail_rec.released_flag
5322 		,organization_id
5323 		,transaction_temp_id
5324 		,ship_set_id
5325 		,arrival_set_id
5326 		,ship_model_complete_flag
5327 		,top_model_line_id
5328 		,source_header_number
5329 		,source_header_type_id
5330 		,source_header_type_name
5331 		,cust_po_number
5332 		,ato_line_id
5333 		,src_requested_quantity
5334 		,src_requested_quantity_uom
5335 		,move_order_line_id
5336 		,cancelled_quantity
5337 		,quality_control_quantity
5338 		,cycle_count_quantity
5339 		,tracking_number
5340 		,movement_id
5341 		,shipping_instructions
5342 		,packing_instructions
5343 		,project_id
5344 		,task_id
5345 		,org_id
5346 		,oe_interfaced_flag
5347 		,split_from_delivery_detail_id
5348 		,inv_interfaced_flag
5349 		,source_line_number
5350 		,inspection_flag
5351 		,released_status
5352 		,container_flag
5353 		,container_type_code
5354 		,container_name
5355 		,fill_percent
5356 		,gross_weight
5357 		,master_serial_number
5358 		,maximum_load_weight
5359 		,maximum_volume
5360 		,minimum_fill_percent
5361 		,seal_code
5362 		,unit_number
5363 		,unit_price
5364 		,currency_code
5365 		,freight_class_cat_id
5366 		,commodity_code_cat_id
5367 		,preferred_grade
5368 		,src_requested_quantity2
5369 		,src_requested_quantity_uom2
5370 		,requested_quantity2
5371 		,shipped_quantity2
5372 		,delivered_quantity2
5373 		,cancelled_quantity2
5374 		,quality_control_quantity2
5375 		,cycle_count_quantity2
5376 		,requested_quantity_uom2
5377 -- HW OPMCONV - No need for sublot_number
5378 --              ,sublot_number
5379 		,lpn_id
5380 		,pickable_flag
5381 		,original_subinventory
5382 		,to_serial_number
5383 		,picked_quantity
5384 		,picked_quantity2
5385 		,received_quantity
5386 		,received_quantity2
5387 		,source_line_set_id
5388 		,batch_id
5389 		,p_delivery_detail_rec.ROWID
5390 		,transaction_id
5391 /*J Inbound Logistics new columns. jckwok*/
5392                 ,vendor_id
5393                 ,ship_from_site_id
5394                 ,nvl(line_direction, 'O')
5395                 ,party_id
5396                 ,routing_req_id
5397                 ,shipping_control
5398                 ,source_blanket_reference_id
5399                 ,source_blanket_reference_num
5400                 ,po_shipment_line_id
5401                 ,po_shipment_line_number
5402                 ,returned_quantity
5403                 ,returned_quantity2
5404                 ,rcv_shipment_line_id
5405                 ,source_line_type_code
5406                 ,supplier_item_number
5407 /* J TP Release : New columns ttrichy*/
5408         ,nvl(IGNORE_FOR_PLANNING, 'N') ignore_for_planning
5409         ,EARLIEST_PICKUP_DATE
5410         ,LATEST_PICKUP_DATE
5411         ,EARLIEST_DROPOFF_DATE
5412         ,LATEST_DROPOFF_DATE
5413         ,REQUEST_DATE_TYPE_CODE
5414         ,tp_delivery_detail_id
5415         ,source_document_type_id
5416         -- J: W/V Changes
5417         ,unit_weight
5418         ,unit_volume
5419         ,filled_volume
5420         ,wv_frozen_flag
5421         ,mode_of_transport
5422         ,service_level
5423 /*J IB: asutar*/
5424         ,po_revision_number
5425         ,release_revision_number
5426         ,replenishment_status  --bug# 6689448 (replenishment project)
5427   FROM wsh_delivery_details
5428   WHERE delivery_detail_id = p_delivery_detail_rec.delivery_detail_id;
5429 
5430   e_dp_no_entity EXCEPTION;
5431   e_bad_field EXCEPTION;
5432   e_all_disabled EXCEPTION ;
5433 
5434   l_caller               VARCHAR2(32767);
5435   l_wms_org              VARCHAR2(100) := 'N';
5436 
5437 BEGIN
5438   --
5439   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5440   --
5441   IF l_debug_on IS NULL
5442   THEN
5443 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5444   END IF;
5445   --
5446   IF l_debug_on THEN
5447 	  WSH_DEBUG_SV.push(l_module_name);
5448 	  --
5449 	  WSH_DEBUG_SV.log(l_module_name,'DELIVERY_DETAIL_ID',p_delivery_detail_rec.DELIVERY_DETAIL_ID);
5450 	  WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_ID',P_DELIVERY_ID);
5451 	  WSH_DEBUG_SV.log(l_module_name,'p_action',p_in_rec.action_code);
5452           wsh_debug_sv.log(l_module_name, 'Caller', p_in_rec.caller);
5453   END IF;
5454   --
5455   x_return_status := FND_API.G_RET_STS_SUCCESS;
5456   --
5457   IF p_in_rec.action_code = 'CREATE' THEN
5458 	 IF l_debug_on THEN
5459 		 WSH_DEBUG_SV.log(l_module_name,'calling eliminate_displayonly_fields');
5460 	 END IF;
5461 	 --
5462 	 -- nothing else need to be disabled
5463 	 --
5464 	 eliminate_displayonly_fields (p_delivery_detail_rec, p_in_rec, x_delivery_detail_rec);
5465 	 IF l_debug_on THEN
5466 	   WSH_DEBUG_SV.log(l_module_name,'x_return_status',x_return_status);
5467 	   WSH_DEBUG_SV.pop(l_module_name);
5468 	 END IF;
5469 	 -- RETURN; --public api changes
5470   --
5471   ELSIF p_in_rec.action_code = 'UPDATE' THEN
5472     --
5473     l_caller := p_in_rec.caller;
5474     IF (l_caller like 'FTE%') THEN
5475       l_caller := 'WSH_PUB';
5476     END IF;
5477 
5478     -- Added for bug 4399278, 4418754
5479     IF ( p_in_rec.caller = 'WSH_PUB' and
5480          p_delivery_detail_rec.subinventory is not null and
5481          p_delivery_detail_rec.subinventory <> FND_API.G_MISS_CHAR ) THEN
5482        G_SUBINVENTORY := p_delivery_detail_rec.subinventory;
5483     END IF;
5484 
5485     Get_Disabled_List( p_delivery_detail_rec.DELIVERY_DETAIL_ID
5486 					 , p_delivery_id
5487 					 , 'FORM'
5488 					 , x_return_status
5489 					 , l_disabled_list
5490 					 , x_msg_count
5491 					 , x_msg_data
5492 					 , l_caller --public api changes
5493 					 );
5494     --
5495     IF x_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR OR
5496 	x_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
5497     THEN
5498 	--
5499 	IF l_debug_on THEN
5500 	  WSH_DEBUG_SV.log(l_module_name,'x_return_status',x_return_status);
5501 	  WSH_DEBUG_SV.pop(l_module_name);
5502 	END IF;
5503 	RETURN;
5504 	--
5505     END IF;
5506     --
5507     IF l_disabled_list.COUNT = 1 THEN
5508 	IF l_disabled_list(1) = 'FULL' THEN
5509 	  l_all_disabled :='Y';
5510 	  --Everything  is disabled
5511 	END IF;
5512     END IF;
5513 
5514     OPEN c_tbl_rec;
5515     FETCH c_tbl_rec INTO x_delivery_detail_rec;
5516 	IF c_tbl_rec%NOTFOUND THEN
5517 	--
5518 	   CLOSE c_tbl_rec;
5519 	   RAISE e_dp_no_entity;
5520 	--
5521 	END IF;
5522     CLOSE c_tbl_rec;
5523 
5524     --
5525     l_released_status :=  x_delivery_detail_rec.released_status;
5526 
5527   IF (l_disabled_list(1) <> 'FULL') or (l_disabled_list.COUNT <> 0) THEN
5528 
5529       i :=  l_disabled_list.COUNT;
5530 
5531       IF (l_released_status = 'Y')  THEN
5532 
5533          IF p_delivery_detail_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
5534 
5535             l_inventory_item_id := x_delivery_detail_rec.inventory_item_id;
5536 
5537          ELSE
5538 
5539             l_inventory_item_id := p_delivery_detail_rec.inventory_item_id;
5540 
5541          END IF;
5542          IF p_delivery_detail_rec.organization_id = FND_API.G_MISS_NUM THEN
5543 
5544             l_organization_id := x_delivery_detail_rec.organization_id;
5545 
5546          ELSE
5547 
5548             l_organization_id := p_delivery_detail_rec.organization_id;
5549 
5550          END IF;
5551          IF p_delivery_detail_rec.pickable_flag = FND_API.G_MISS_CHAR THEN
5552 
5553             l_pickable_flag := x_delivery_detail_rec.pickable_flag;
5554 
5555          ELSE
5556 
5557             l_pickable_flag := p_delivery_detail_rec.pickable_flag;
5558 
5559          END IF;
5560          IF p_delivery_detail_rec.subinventory = FND_API.G_MISS_CHAR THEN
5561 
5562             l_subinventory := x_delivery_detail_rec.subinventory;
5563 
5564 
5565          ELSE
5566 
5567             l_subinventory := p_delivery_detail_rec.subinventory;
5568 
5569          END IF;
5570 
5571       END IF;  -- if l_released_status...
5572 
5573     END IF;
5574 
5575 
5576 
5577     l_lpn_id := x_delivery_detail_rec.lpn_id;
5578 
5579     IF l_debug_on THEN
5580 	 WSH_DEBUG_SV.log(l_module_name,'list.COUNT',l_disabled_list.COUNT);
5581     END IF;
5582 
5583     IF l_disabled_list.COUNT = 0 THEN
5584 
5585 	 --
5586 	 IF l_debug_on THEN
5587 		 WSH_DEBUG_SV.log(l_module_name,'calling eliminate_displayonly_fields');
5588 	 END IF;
5589 	 --
5590 	 -- nothing else need to be disabled
5591 	 --
5592 	 eliminate_displayonly_fields (p_delivery_detail_rec, p_in_rec, x_delivery_detail_rec);
5593 
5594     ELSIF l_disabled_list(1) = 'FULL' THEN
5595 	IF l_disabled_list.COUNT > 1 THEN
5596 
5597 	  IF l_debug_on THEN
5598 		  FOR i in 1..l_disabled_list.COUNT
5599 		  LOOP
5600 			WSH_DEBUG_SV.log(l_module_name,'list values',l_disabled_list(i));
5601 		  END LOOP;
5602 		  WSH_DEBUG_SV.log(l_module_name,'calling enable_from_list');
5603 	  END IF;
5604 	  --enable the columns matching the l_disabled_list
5605 	  enable_from_list(l_disabled_list,
5606 					  p_delivery_detail_rec,
5607 					  x_delivery_detail_rec,
5608 					  l_return_status,
5609 					  l_field_name);
5610 	  IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
5611 		 RAISE e_bad_field;
5612 	  END IF;
5613 	END IF;
5614     ELSE -- list.count > 1 and list(1) <> 'FULL'
5615 	l_db_col_rec := x_delivery_detail_rec ;
5616 	--
5617 	FOR i in 1..l_disabled_list.COUNT
5618 	LOOP
5619   	  IF l_debug_on THEN
5620 	    WSH_DEBUG_SV.log(l_module_name,'list values',l_disabled_list(i));
5621 	  END IF;
5622 	  -- Added for bug 4399278, 4418754
5623 	  IF ( p_in_rec.caller = 'WSH_PUB' and
5624 	       l_disabled_list(i) = 'LOCATOR_NAME' and
5625 	       l_db_col_rec.locator_id is not null and
5626 	       --Modified for bug 4560576, 4701803
5627 	       l_db_col_rec.released_status = 'Y'  and
5628 	       WSH_DELIVERY_DETAILS_INV.get_reservable_flag (
5629 	                             x_item_id => l_inventory_item_id,
5630 	                             x_organization_id => l_organization_id,
5631 	                             x_pickable_flag   => l_pickable_flag ) = 'N' )
5632 	  THEN
5633 	       l_db_col_rec.locator_id := NULL;
5634 	  END IF;
5635 	END LOOP;
5636 
5637 	IF l_debug_on THEN
5638 	   WSH_DEBUG_SV.log(l_module_name,'First element is not FULL');
5639 	   WSH_DEBUG_SV.log(l_module_name,'calling eliminate_displayonly_fields');
5640         END IF;
5641 	--
5642 	eliminate_displayonly_fields (p_delivery_detail_rec, p_in_rec, x_delivery_detail_rec);
5643 	--
5644 	IF l_debug_on THEN
5645 		WSH_DEBUG_SV.log(l_module_name,'calling disable_from_list');
5646 	END IF;
5647 	-- The fileds in the list are getting disabled
5648 	disable_from_list(l_disabled_list,
5649 					  l_db_col_rec,
5650 					  x_delivery_detail_rec,
5651 					  l_return_status,
5652 					  l_field_name);
5653 	IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
5654 	   RAISE e_bad_field;
5655 	END IF;
5656     END IF;
5657 
5658     -- Now enable/disable the fields that need to be enabled/disabled
5659     -- based on the caller.
5660 
5661     l_disabled_list.delete;
5662     -- rebuild the list according to the caller
5663 
5664     IF p_in_rec.caller like 'WMS%' THEN
5665 
5666 	 j:=j+1; l_disabled_list(j) := 'FULL';
5667 	 -- Only the elements in the list will be enabled.
5668 	 -- The other fields will remain enabled/disabled as before (untouched).
5669 
5670 	 IF p_delivery_id is not null THEN
5671 	   open get_delivery_status;
5672 	   fetch get_delivery_status into l_status_code;
5673 	   close get_delivery_status;
5674 	 END IF;
5675          --
5676          -- lpn conv.
5677          IF (nvl(l_organization_id, fnd_api.g_miss_num) = fnd_api.g_miss_num) THEN
5678            l_organization_id := x_delivery_detail_rec.organization_id;
5679          END IF;
5680 
5681          IF l_debug_on THEN
5682            WSH_DEBUG_SV.log(l_module_name,'organization_id is ', l_organization_id);
5683          END IF;
5684          l_wms_org := wsh_util_validate.Check_Wms_Org(l_organization_id);
5685          -- lpn conv.
5686          --
5687          --{
5688 	 IF NVL(l_status_code, 'OP') = 'OP' AND l_released_status = 'Y' THEN
5689 
5690 		 j:=j+1; l_disabled_list(j) := 'SUBINVENTORY';
5691 		 j:=j+1; l_disabled_list(j) := 'LOCATOR_NAME';
5692 		 j:=j+1; l_disabled_list(j) := 'PICKED_QUANTITY2';
5693 		 -- Bug 3382932
5694 		 j:=j+1; l_disabled_list(j) := 'SHIPPED_QUANTITY2';
5695 		 j:=j+1; l_disabled_list(j) := 'REQUESTED_QUANTITY_UOM2';
5696 
5697          -- X-dock changes
5698          -- Only for specific cases, let WMS update released_status and MOL
5699          ELSIF (l_released_status IN (WSH_DELIVERY_DETAILS_PKG.C_READY_TO_RELEASE,
5700                                       WSH_DELIVERY_DETAILS_PKG.C_BACKORDERED,
5701                                       WSH_DELIVERY_DETAILS_PKG.C_RELEASED_TO_WAREHOUSE)
5702                AND p_in_rec.caller like 'WMS_XDOCK%') THEN
5703            if l_debug_on then
5704              wsh_debug_sv.log(l_module_name, 'WMS Caller to update Released status and MOL', p_in_rec.caller);
5705            end if;
5706 		 j:=j+1; l_disabled_list(j) := 'RELEASED_STATUS';
5707 		 j:=j+1; l_disabled_list(j) := 'MOVE_ORDER_LINE_ID';
5708                  j:=j+1; l_disabled_list(j) := 'BATCH_ID';
5709 
5710         -- end of X-dock changes
5711 
5712         --bug# 6689448 (replenishment project): let WMS update replenishment status for ready to release and backorder dds
5713         ELSIF (l_released_status IN (WSH_DELIVERY_DETAILS_PKG.C_READY_TO_RELEASE,
5714                                       WSH_DELIVERY_DETAILS_PKG.C_BACKORDERED) AND p_in_rec.caller like 'WMS_REP%') THEN
5715             j:=j+1;
5716             l_disabled_list(j) := 'REPLENISHMENT_STATUS';
5717         ELSIF p_delivery_detail_rec.lpn_id IS NULL AND l_lpn_id is NOT NULL THEN
5718 	    -- LPN sync-up
5719 	    IF (l_wms_org='N') THEN
5720 	      j:=j+1; l_disabled_list(j) := 'CONTAINER_NAME';
5721             END IF;
5722 	    j:=j+1; l_disabled_list(j) := 'LPN_ID';
5723 	    IF l_released_status = 'X' then
5724 	      j:=j+1; l_disabled_list(j) := 'SUBINVENTORY';
5725 	      j:=j+1; l_disabled_list(j) := 'LOCATOR_NAME';
5726 	    END IF;
5727 	 ELSIF NVL(x_delivery_detail_rec.container_flag,'N') IN ('Y','C') THEN
5728 	    IF l_released_status = 'X' then
5729 	      j:=j+1; l_disabled_list(j) := 'SUBINVENTORY';
5730 	      j:=j+1; l_disabled_list(j) := 'LOCATOR_NAME';
5731 	    END IF;
5732 	END IF; --}
5733 
5734         IF( l_wms_org = 'Y'
5735             AND NVL(x_delivery_detail_rec.container_flag,'N') IN ('Y','C')
5736             AND l_released_status = 'X'
5737             AND x_delivery_detail_rec.inventory_item_id IS NULL
5738           ) THEN
5739         --{
5740 	    j:=j+1; l_disabled_list(j) := 'ITEM_NUMBER';
5741         --}
5742         END IF;
5743 
5744         -- bug 5077108
5745         IF l_db_col_rec.container_flag = 'Y' THEN
5746         --{
5747            j:=j+1; l_disabled_list(j) := 'INVENTORY_ITEM_ID';
5748            --Bug 5212632
5749            j:=j+1; l_disabled_list(j) := 'CONTAINER_TYPE_CODE';
5750         --}
5751 	-- bug 6082324 -  Adding MAXIMUM_LOAD_WEIGHT TO disabled_list
5752            j:=j+1; l_disabled_list(j) := 'MAXIMUM_LOAD_WEIGHT';
5753            -- bug 7165744 Adding REQUESTED_QUANTITY_UOM TO disabled_list
5754            j:=j+1; l_disabled_list(j) := 'REQUESTED_QUANTITY_UOM';
5755         END IF;
5756 
5757 
5758     ELSIF p_in_rec.caller = 'WSH_INBOUND' THEN
5759         if l_debug_on then
5760            wsh_debug_sv.logmsg(l_module_name, 'WSH_INBOUND: Enabling subinventory', WSH_DEBUG_SV.C_STMT_LEVEL);
5761            wsh_debug_sv.log(l_module_name, 'Input subinventory', p_delivery_detail_rec.subinventory);
5762 	   wsh_debug_sv.log(l_module_name, 'Input LOT_NUMBER', p_delivery_detail_rec.lot_number);
5763         end if;
5764         -- Subinventory should be updateable during inbound processing
5765         j:=j+1; l_disabled_list(j) := 'FULL';
5766         j:=j+1; l_disabled_list(j) := 'SUBINVENTORY';
5767          --Bugfix 6939348  start
5768           WSH_DELIVERY_DETAILS_INV.Fetch_Inv_Controls(p_delivery_detail_id => x_delivery_detail_rec.delivery_detail_id,
5769                                                         p_inventory_item_id => x_delivery_detail_rec.inventory_item_id,
5770                                                         p_organization_id => x_delivery_detail_rec.organization_id,
5771                                                         p_subinventory => x_delivery_detail_rec.subinventory,
5772                                                         x_inv_controls_rec => l_inv_controls,
5773                                                         x_return_status => x_return_status);
5774 
5775             IF l_inv_controls.lot_flag = 'Y' THEN
5776 
5777              j:=j+1; l_disabled_list(j) := 'LOT_NUMBER';
5778 
5779             END IF;
5780        --Bugfix 6939348  end
5781 
5782      ELSIF p_in_rec.caller = 'WSH_USA' THEN
5783      -- Bug 3292364
5784      -- Enable Ship Method Components to be updated for container during OM changes.
5785 
5786          IF l_debug_on THEN
5787             WSH_DEBUG_SV.logmsg(l_module_name, 'Enable SM Components for CMS changes, caller = WSH_USA'  );
5788          END IF;
5789          j:=j+1; l_disabled_list(j) := 'FULL';
5790          j:=j+1; l_disabled_list(j) := 'SERVICE_LEVEL';
5791          j:=j+1; l_disabled_list(j) := 'MODE_OF_TRANSPORT';
5792          j:=j+1; l_disabled_list(j) := 'CARRIER_ID';
5793          j:=j+1; l_disabled_list(j) := 'SHIP_METHOD_CODE';
5794     END IF;
5795 
5796     IF l_disabled_list.count > 1 and l_disabled_list(1) = 'FULL' THEN
5797 
5798 	l_all_disabled :='N';
5799 	IF l_debug_on THEN
5800 		WSH_DEBUG_SV.log(l_module_name,'calling enable_from_list');
5801 	END IF;
5802 
5803 	enable_from_list(l_disabled_list,
5804 					 p_delivery_detail_rec,
5805 					 x_delivery_detail_rec,
5806 					 l_return_status,
5807 					 l_field_name);
5808 
5809 	IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
5810 	   RAISE e_bad_field;
5811 	END IF;
5812 
5813 
5814     END IF;
5815 
5816     IF l_all_disabled ='Y' THEN
5817 	 RAISE e_all_disabled;
5818     END IF;
5819   --
5820   END IF; /* if action = 'UPDATE' */
5821 
5822   --public api changes
5823   IF (NVL(p_in_rec.caller, '!!!') <> 'WSH_FSTRX' AND
5824       NVL(p_in_rec.caller, '!!!') NOT LIKE 'FTE%'
5825       AND NVL(p_in_rec.caller, '!!!') <> 'WSH_INBOUND'
5826       AND NVL(p_in_rec.caller, '!!!') <> 'WSH_TPW_INBOUND') THEN
5827     --
5828     user_non_updatable_columns
5829      (p_user_in_rec   => p_delivery_detail_rec,
5830       p_out_rec       => x_delivery_detail_rec,
5831       p_in_rec        => p_in_rec,
5832       x_return_status => l_return_status);
5833     --
5834     IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
5835        x_return_status := l_return_status;
5836     END IF;
5837     --
5838   END IF;
5839   --
5840   IF l_debug_on THEN
5841 	WSH_DEBUG_SV.pop(l_module_name);
5842   END IF;
5843 
5844   EXCEPTION
5845 	WHEN e_all_disabled THEN
5846 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5847 	  FND_MESSAGE.SET_NAME('WSH','WSH_ALL_COLS_DISABLED');
5848 	  FND_MESSAGE.Set_Token('ENTITY_ID',p_delivery_detail_rec.delivery_detail_id);
5849 	  wsh_util_core.add_message(x_return_status,l_module_name);
5850 	  IF l_debug_on THEN
5851 		-- Nothing is updateable
5852 		WSH_DEBUG_SV.pop(l_module_name,'e_all_disabled');
5853 	  END IF;
5854 	WHEN e_dp_no_entity THEN
5855 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5856 	  -- the message for this is set in original get_disabled_list
5857 	  IF l_debug_on THEN
5858 		WSH_DEBUG_SV.pop(l_module_name,'e_dp_no_entity');
5859 	  END IF;
5860 	WHEN e_bad_field THEN
5861 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5862 	  FND_MESSAGE.SET_NAME('WSH','WSH_BAD_FIELD_NAME');
5863 	  FND_MESSAGE.Set_Token('FIELD_NAME',l_field_name);
5864 	  wsh_util_core.add_message(x_return_status,l_module_name);
5865 	  IF l_debug_on THEN
5866 		WSH_DEBUG_SV.log(l_module_name,'Bad field name passed to the list:'
5867 														,l_field_name);
5868 		WSH_DEBUG_SV.pop(l_module_name,'e_bad_field');
5869 	  END IF;
5870 
5871 	WHEN OTHERS THEN
5872 	  x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
5873 	  wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.get_disabled_list',
5874 									  l_module_name);
5875 	  IF l_debug_on THEN
5876 		WSH_DEBUG_SV.log(l_module_name,'Error:',SUBSTR(SQLERRM,1,200));
5877 		WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5878 	  END IF;
5879 END Get_Disabled_List;
5880 
5881 
5882 PROCEDURE Init_Detail_Actions_Tbl (
5883   p_action				   IN				VARCHAR2
5884 , x_detail_actions_tab	   OUT  NOCOPY			 DetailActionsTabType
5885 , x_return_status			OUT  NOCOPY			 VARCHAR2
5886 )
5887 
5888 IS
5889 i NUMBER := 0;
5890 l_debug_on BOOLEAN;
5891 l_gc3_is_installed       VARCHAR2(1);  -- OTM R12
5892   l_module_name CONSTANT VARCHAR2(100) :=
5893 		 'wsh.plsql.' || G_PKG_NAME || '.' || 'Init_Detail_Actions_Tbl';
5894 BEGIN
5895   --
5896   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5897   --
5898   IF l_debug_on IS NULL
5899   THEN
5900 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5901   END IF;
5902   --
5903   IF l_debug_on THEN
5904 	  WSH_DEBUG_SV.push(l_module_name);
5905 	  --
5906 	  WSH_DEBUG_SV.log(l_module_name,'p_action', p_action);
5907   END IF;
5908   --
5909   x_return_status :=  WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5910 
5911   -- OTM R12
5912   l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
5913 
5914   IF (l_gc3_is_installed IS NULL) THEN
5915     l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
5916   END IF;
5917   -- End of OTM R12
5918 
5919   --
5920   -- J-IB-NPARIKH-{
5921         --
5922         -- Disable all the actions for inbound/drop-ship lines
5923         -- when called from shipping transaction form
5924         --
5925         i := i+1;
5926         x_detail_actions_tab(i).line_direction := 'I';
5927         x_detail_actions_tab(i).caller := 'WSH_FSTRX';
5928         x_detail_actions_tab(i).action_not_allowed := p_action;
5929         i := i+1;
5930         x_detail_actions_tab(i).line_direction := 'D';
5931         x_detail_actions_tab(i).caller := 'WSH_FSTRX';
5932         x_detail_actions_tab(i).action_not_allowed := p_action;
5933   -- J-IB-NPARIKH-}
5934   --
5935 
5936   -- OTM R12 : disable actions for delivery detail
5937   IF l_gc3_is_installed = 'Y' THEN
5938     IF p_action IN ('RATE_WITH_UPS', 'UPS_TIME_IN_TRANSIT', 'UPS_ADDRESS_VALIDATION', 'UPS_TRACKING') THEN
5939       i := i + 1;
5940       x_detail_actions_tab(i).action_not_allowed := p_action;
5941     END IF;
5942   END IF;
5943   -- End of OTM R12 : disable actions for delivery detail
5944 
5945   -- R12 MDC
5946   IF p_action IN ( 'ASSIGN','AUTOCREATE-DEL', 'AUTO-PACK',
5947    	           'AUTO-PACK-MASTER', 'AUTOCREATE-TRIP',
5948 		   'PACK', 'UNASSIGN','UNPACK', 'DELETE',
5949 		   'PICK-SHIP', 'PICK-PACK-SHIP',
5950 		   'CYCLE-COUNT', 'SPLIT-LINE',
5951 	   	   'INCLUDE_PLAN', 'IGNORE_PLAN')
5952   THEN
5953     i := i+1;
5954     x_detail_actions_tab(i).container_flag     := 'C';
5955     x_detail_actions_tab(i).action_not_allowed := p_action;
5956     x_detail_actions_tab(i).caller := 'WSH_FSTRX';
5957     i := i+1;
5958     x_detail_actions_tab(i).container_flag     := 'C';
5959     x_detail_actions_tab(i).action_not_allowed := p_action;
5960     x_detail_actions_tab(i).caller := 'WSH_PUB';
5961   END IF;
5962   --
5963 
5964   IF p_action IN ( 'ASSIGN' ,'AUTOCREATE-DEL', 'AUTO-PACK', 'AUTO-PACK-MASTER',
5965 				   'AUTOCREATE-TRIP', 'PACK' , 'PICK-RELEASE',
5966 				   'PICK-RELEASE-UI', 'UNASSIGN','UNPACK','WT-VOL', 'DELETE',
5967 				   'RESOLVE-EXCEPTIONS-UI') THEN
5968 
5969         -- Fixed as part of bug fix 2864546
5970         -- Resolve Exceptions should be allowed for cancelled lines
5971         --Bug 7025876
5972 	      --UNASSIGN action should be allowed for cancelled delivery details assigned to planned deliveries
5973         IF p_action NOT IN ('RESOLVE-EXCEPTIONS-UI','UNASSIGN') THEN
5974            i := i+1;
5975            x_detail_actions_tab(i).released_status := 'D';
5976            x_detail_actions_tab(i).action_not_allowed := p_action;
5977         END IF;
5978 /*J Inbound Logistics disallowed actions jckwok */
5979         IF p_action IN ('AUTOCREATE-TRIP','PICK-RELEASE','PICK-RELEASE-UI','DELETE','RESOLVE-EXCEPTIONS-UI') THEN
5980            i := i+1;
5981            x_detail_actions_tab(i).line_direction := 'I';
5982 	   x_detail_actions_tab(i).action_not_allowed := p_action;
5983            i := i+1;
5984            x_detail_actions_tab(i).line_direction := 'D';
5985 	   x_detail_actions_tab(i).action_not_allowed := p_action;
5986         END IF;
5987         -- J-IB-NPARIKH-{
5988         --
5989         IF p_action = 'WT-VOL'
5990         THEN
5991            i := i+1;
5992            x_detail_actions_tab(i).line_direction := 'O';
5993            x_detail_actions_tab(i).released_status := 'C';
5994            x_detail_actions_tab(i).action_not_allowed := p_action;
5995            i := i+1;
5996            x_detail_actions_tab(i).line_direction := 'IO';
5997            x_detail_actions_tab(i).released_status := 'C';
5998            x_detail_actions_tab(i).action_not_allowed := p_action;
5999         ELSE
6000         -- J-IB-NPARIKH-}
6001           --Bug 4370491 Resolve Exception UI should be allowed for Shipped lines
6002           IF p_action <> 'RESOLVE-EXCEPTIONS-UI' THEN
6003             i := i + 1;
6004             x_detail_actions_tab(i).released_status := 'C';
6005             x_detail_actions_tab(i).action_not_allowed := p_action;
6006           END IF;
6007         END IF;
6008 	IF p_action IN ('AUTO-PACK', 'PACK', 'AUTO-PACK-MASTER', 'UNPACK') THEN
6009 	  IF p_action <> 'UNPACK' THEN
6010 		 i := i+1;
6011 		 x_detail_actions_tab(i).released_status := 'S';
6012 		 x_detail_actions_tab(i).action_not_allowed := p_action;
6013 	  END IF;
6014 	   -- Bug fix 2644558
6015 	   -- Disallow packing actions for WMS
6016 	   i := i+1;
6017 	   x_detail_actions_tab(i).org_type := 'WMS';
6018 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6019 	   -- Bug#: 2648481
6020 	   x_detail_actions_tab(i).message_name := 'WSH_WMS_PACK_NOT_ALLOWED';
6021 /*Inbound Logistics disallowed actions jckwok */
6022            i := i+1;
6023            x_detail_actions_tab(i).line_direction := 'I';
6024 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6025            i := i+1;
6026            x_detail_actions_tab(i).line_direction := 'D';
6027 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6028 	END IF;
6029     -- J-IB-NPARIKH-{
6030         /*
6031     IF p_action IN ( 'AUTOCREATE-DEL','ASSIGN', 'UNASSIGN','WT-VOL','RESOLVE-EXCEPTIONS-UI' )
6032         */
6033     --
6034     -- Disable auto-create Delivery/assign to delivery/unassign from delivery
6035     -- actions for inbound/drop-ship lines
6036     -- when line status is Closed(received) or Purged.
6037     -- or ship from location id is -1
6038     --
6039     IF p_action IN ( 'AUTOCREATE-DEL','ASSIGN', 'UNASSIGN')
6040     THEN
6041     --{
6042         i := i+1;
6043         x_detail_actions_tab(i).line_direction := 'D';
6044         x_detail_actions_tab(i).released_status := 'P';
6045         x_detail_actions_tab(i).action_not_allowed := p_action;
6046         i := i+1;
6047         x_detail_actions_tab(i).line_direction := 'I';
6048         x_detail_actions_tab(i).released_status := 'P';
6049         x_detail_actions_tab(i).action_not_allowed := p_action;
6050     --}
6051     END IF;
6052     --
6053     --
6054     IF p_action IN ( 'AUTOCREATE-DEL','ASSIGN', 'UNASSIGN' )
6055     THEN
6056     --{
6057         i := i+1;
6058         x_detail_actions_tab(i).line_direction := 'D';
6059         x_detail_actions_tab(i).released_status := 'L';
6060         x_detail_actions_tab(i).action_not_allowed := p_action;
6061         i := i+1;
6062         x_detail_actions_tab(i).line_direction := 'I';
6063         x_detail_actions_tab(i).released_status := 'L';
6064         x_detail_actions_tab(i).action_not_allowed := p_action;
6065         i := i+1;
6066         x_detail_actions_tab(i).ship_from_location_id := WSH_UTIL_CORE.C_NULL_SF_LOCN_ID;
6067         x_detail_actions_tab(i).action_not_allowed    := p_action;
6068     --}
6069     END IF;
6070     -- J-IB-NPARIKH-}
6071 
6072   ELSIF p_action IN  ('CYCLE-COUNT', 'SPLIT-LINE' )  THEN
6073         i := i+1;
6074 	x_detail_actions_tab(i).released_status := 'D';
6075 	x_detail_actions_tab(i).action_not_allowed := p_action;
6076 	i := i + 1;
6077 	x_detail_actions_tab(i).released_status := 'C';
6078 	x_detail_actions_tab(i).action_not_allowed := p_action;
6079 	i := i + 1;
6080 	x_detail_actions_tab(i).container_flag := 'Y';
6081 	x_detail_actions_tab(i).action_not_allowed := p_action;
6082         --
6083         -- Bug fix 2644558
6084 	-- Disallow cycle_count for WMS
6085         -- Bug fix 2751113 Disallow cycle-count for OKE source system
6086         -- R12 X-dock project, Split will be allowed conditionally
6087         -- for released to warehouse line and caller = WMS_XDOCK%
6088 	IF p_action = 'CYCLE-COUNT' THEN
6089 	   i := i+1;
6090 	   x_detail_actions_tab(i).released_status := WSH_DELIVERY_DETAILS_PKG.C_RELEASED_TO_WAREHOUSE;
6091 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6092 	   i := i+1;
6093 	   x_detail_actions_tab(i).org_type := 'WMS';
6094 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6095            i := i+1;
6096            x_detail_actions_tab(i).source_code := 'OKE';
6097     	   x_detail_actions_tab(i).action_not_allowed := p_action;
6098 /*Inbound Logistics disallowed actions jckwok */
6099            i := i+1;
6100            x_detail_actions_tab(i).line_direction := 'I';
6101 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6102            i := i+1;
6103            x_detail_actions_tab(i).line_direction := 'D';
6104 	   x_detail_actions_tab(i).action_not_allowed := p_action;
6105 	END IF;
6106     -- J-IB-NPARIKH-{
6107     --
6108     -- Disable split line action for inbound/drop-ship lines
6109     -- when line status is Closed(received) or Purged.
6110     --
6111     IF p_action = 'SPLIT-LINE'
6112     THEN
6113     --{
6114         i := i+1;
6115         x_detail_actions_tab(i).line_direction := 'D';
6116         x_detail_actions_tab(i).released_status := 'L';
6117         x_detail_actions_tab(i).action_not_allowed := p_action;
6118         i := i+1;
6119         x_detail_actions_tab(i).line_direction := 'I';
6120         x_detail_actions_tab(i).released_status := 'L';
6121         x_detail_actions_tab(i).action_not_allowed := p_action;
6122         i := i+1;
6123         x_detail_actions_tab(i).line_direction := 'D';
6124         x_detail_actions_tab(i).released_status := 'P';
6125         x_detail_actions_tab(i).action_not_allowed := p_action;
6126         i := i+1;
6127         x_detail_actions_tab(i).line_direction := 'I';
6128         x_detail_actions_tab(i).released_status := 'P';
6129         x_detail_actions_tab(i).action_not_allowed := p_action;
6130     --}
6131     END IF;
6132     -- J-IB-NPARIKH-}
6133   ELSIF p_action = 'PACKING-WORKBENCH' THEN
6134         i := i+1;
6135 	x_detail_actions_tab(i).released_status := 'C';
6136 	x_detail_actions_tab(i).container_flag := 'N';
6137 	x_detail_actions_tab(i).action_not_allowed := p_action;
6138 	i := i + 1;
6139 	x_detail_actions_tab(i).released_status := 'S';
6140 	x_detail_actions_tab(i).action_not_allowed := p_action;
6141 	i := i + 1;
6142 	x_detail_actions_tab(i).released_status := 'D';
6143 	x_detail_actions_tab(i).action_not_allowed := p_action;
6144 	   -- Bug fix 2644558
6145 	   -- Disallow packing actions for WMS
6146 	i := i+1;
6147 	x_detail_actions_tab(i).org_type := 'WMS';
6148 	x_detail_actions_tab(i).action_not_allowed := p_action;
6149 /*Inbound Logistics disallowed actions jckwok */
6150         i := i+1;
6151         x_detail_actions_tab(i).line_direction := 'I';
6152 	x_detail_actions_tab(i).action_not_allowed := p_action;
6153         i := i+1;
6154         x_detail_actions_tab(i).line_direction := 'D';
6155 	x_detail_actions_tab(i).action_not_allowed := p_action;
6156   ELSIF p_action = 'ASSIGN-FREIGHT-COSTS' THEN
6157 /*Inbound Logistics disallowed actions jckwok */
6158         i := i+1;
6159         x_detail_actions_tab(i).line_direction := 'I';
6160 	x_detail_actions_tab(i).action_not_allowed := p_action;
6161         i := i+1;
6162         x_detail_actions_tab(i).line_direction := 'D';
6163 	x_detail_actions_tab(i).action_not_allowed := p_action;
6164   -- J-IB-NPARIKH-{
6165   ELSIF p_Action = 'INCLUDE_PLAN'
6166   THEN
6167   --{
6168         --
6169         -- Lines cannot be included for planning if ship-from location is null
6170         --
6171         i := i+1;
6172         x_detail_actions_tab(i).ship_from_location_id := WSH_UTIL_CORE.C_NULL_SF_LOCN_ID;
6173         x_detail_actions_tab(i).action_not_allowed    := p_action;
6174         --bug 3458160
6175         IF l_gc3_is_installed = 'N' THEN
6176            -- 5746444: enforce this condition when OTM is disabled.
6177            i := i + 1;
6178            x_detail_actions_tab(i).action_not_allowed := p_action;
6179            x_detail_actions_tab(i).source_code := 'WSH';
6180            x_detail_actions_tab(i).container_flag := 'N';
6181         ELSE
6182            -- 5746110: enforce this condition when OTM is installed.
6183            i := i + 1;
6184            x_detail_actions_tab(i).action_not_allowed := p_action;
6185            x_detail_actions_tab(i).otm_enabled := 'N';
6186         END IF;
6187   --}
6188   -- J-IB-NPARIKH-}
6189   -- { IB-Phase-2
6190   ELSIF p_action = 'ASSIGN-CONSOL-LPN'  THEN
6191        --
6192        -- Inbound Lines cannot be a part of a consolidated LPN.
6193        --
6194        i := i + 1;
6195        x_detail_actions_tab(i).line_direction := 'I';
6196        x_detail_actions_tab(i).action_not_allowed := p_action;
6197        i := i + 1;
6198        x_detail_actions_tab(i).line_direction := 'D';
6199        x_detail_actions_tab(i).action_not_allowed := p_action;
6200   -- } IB-Phase-2
6201   END IF;
6202 
6203 
6204   IF l_debug_on THEN
6205 	  WSH_DEBUG_SV.pop(l_module_name);
6206   END IF;
6207   EXCEPTION
6208   WHEN OTHERS THEN
6209 	x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6210 	wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.Init_Detail_Actions_Tbl', l_module_name);
6211 	IF l_debug_on THEN
6212 		WSH_DEBUG_SV.log(l_module_name,'Error:',SUBSTR(SQLERRM,1,200));
6213 		WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6214 	END IF;
6215 
6216 END Init_Detail_Actions_Tbl;
6217 
6218 
6219 	-- ---------------------------------------------------------------------
6220 	-- Procedure:	Validate_Shipped_CC_Quantity
6221 	--
6222 	-- Parameters:
6223 	--
6224 	-- Description:  This procedure validates shipped_quantity or cycle_count_quantity
6225 	--			   This procedure consolidates the validations needed for these quantities
6226 	--
6227 	-- Created:   Harmonization Project. Patchset I
6228 	-- -----------------------------------------------------------------------
6229 	PROCEDURE Validate_Shipped_CC_Quantity(
6230 		   p_flag			IN	   VARCHAR2, -- either 'SQ' or 'CCQ'
6231 		   x_det_rec		 IN OUT NOCOPY  ValidateQuantityAttrRecType,
6232 		   x_return_status   OUT NOCOPY   VARCHAR2,
6233 		   x_msg_count	   OUT NOCOPY	 NUMBER,
6234 		   x_msg_data		OUT NOCOPY	 VARCHAR2
6235 		   ) IS
6236 
6237 		l_quantity	   NUMBER;
6238 		l_input_quantity NUMBER;
6239 
6240 		l_api_name			  CONSTANT VARCHAR2(30)   := 'Validate_Shipped_CC_Quantity';
6241 		l_api_version		   CONSTANT NUMBER		 := 1.0;
6242 		--
6243 	--
6244 	l_return_status			 VARCHAR2(32767);
6245 	l_msg_count				 NUMBER;
6246 	l_msg_data				  VARCHAR2(32767);
6247 	l_program_name			  VARCHAR2(32767);
6248 
6249 	l_number_of_errors	NUMBER := 0;
6250 	l_number_of_warnings  NUMBER := 0;
6251 
6252         --added for bug # 3266333
6253         l_field_name VARCHAR2(50);
6254 
6255 
6256 	   --
6257 l_debug_on BOOLEAN;
6258 	   --
6259 	   l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATE_SHIPPED_CC_QUANTITY';
6260 BEGIN
6261   --
6262   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6263   --
6264   IF l_debug_on IS NULL
6265   THEN
6266 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6267   END IF;
6268   --
6269   IF l_debug_on THEN
6270 	 WSH_DEBUG_SV.push(l_module_name);
6271 	 WSH_DEBUG_SV.log(l_module_name,'P_FLAG',P_FLAG);
6272 	 WSH_DEBUG_SV.log(l_module_name, 'Del detail id', x_det_rec.delivery_detail_id);
6273 	 WSH_DEBUG_SV.log(l_module_name, 'Shipped_Quantity', x_det_rec.shipped_quantity);
6274 	 WSH_DEBUG_SV.log(l_module_name, 'Cycle_Count_Quantity', x_det_rec.cycle_count_quantity);
6275 	 WSH_DEBUG_SV.log(l_module_name, 'Requested Quantity', x_det_rec.requested_quantity);
6276 	 WSH_DEBUG_SV.log(l_module_name, 'Picked Quantity', x_det_rec.picked_quantity);
6277 	 WSH_DEBUG_SV.log(l_module_name, 'Organization Id', x_det_rec.organization_id);
6278 	 WSH_DEBUG_SV.log(l_module_name, 'Inventory Item Id', x_det_rec.inventory_item_id);
6279 	 WSH_DEBUG_SV.log(l_module_name, 'Serial Qty', x_det_rec.serial_quantity);
6280 	 WSH_DEBUG_SV.log(l_module_name, 'Transaction Temp Id', x_det_rec.transaction_temp_id);
6281 	 WSH_DEBUG_SV.log(l_module_name, 'Top Model Line Id', x_det_rec.top_model_line_id);
6282 	WSH_DEBUG_SV.log(l_module_name, 'Ship Tolerance Above', x_det_rec.ship_tolerance_above);
6283 	WSH_DEBUG_SV.log(l_module_name, 'requested qty uom', x_det_rec.requested_quantity_uom);
6284 	WSH_DEBUG_SV.log(l_module_name, 'unmark_serial_server ', x_det_rec.unmark_serial_server);
6285 	WSH_DEBUG_SV.log(l_module_name, 'unmark_serial_form ', x_det_rec.unmark_serial_form);
6286   END IF;
6287 
6288 	 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6289 
6290   IF(p_flag = 'SQ') THEN
6291 	  l_input_quantity := x_det_rec.shipped_quantity;
6292           --added for Bug # 3266333
6293 	  l_field_name := 'shipped_quantity';
6294 	  --
6295   ELSIF(p_flag = 'CCQ') THEN
6296 	  l_input_quantity := x_det_rec.cycle_count_quantity;
6297           --added for Bug # 3266333
6298 	  l_field_name := 'cycle_count_quantity';
6299 	  --
6300   ELSE
6301 	 -- invalid flag
6302 	 raise fnd_api.g_exc_error;
6303   END IF;
6304 
6305   --1.a) if entered, enable backordered quantity and update it as max(requested_quantity - shipped_quantity),0)
6306   --1.b) if null, clear cycle count and secondary quantity
6307   IF(x_det_rec.shipped_quantity IS NOT NULL) THEN
6308 	x_det_rec.cycle_count_quantity := Greatest((x_det_rec.requested_quantity - x_det_rec.shipped_quantity),0);
6309   ELSE
6310 	x_det_rec.cycle_count_quantity := NULL;
6311 -- HW Harmonization project for OPM. no need to assign qty2 since it's being handleded in Validate_Shipped_CC_Quantity2
6312 --	x_det_rec.cycle_count_quantity2 := NULL;
6313 
6314   END IF;
6315 
6316    -- 2) Check for negative
6317 
6318    IF l_debug_on THEN
6319 	   WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.C_PROC_LEVEL);
6320    END IF;
6321    --Bug # 3266333
6322    WSH_UTIL_VALIDATE.validate_negative(
6323          p_value          =>  l_input_quantity,
6324 	 p_field_name     => l_field_name,
6325 	 x_return_status  => l_return_status );
6326    --
6327 
6328 	   IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6329 		  RAISE FND_API.G_EXC_ERROR;
6330 	   END IF;
6331 
6332 
6333    -- 3) check for decimal
6334 -- HW Harmonization project for OPM. No need to call this procedure for OPM
6335 -- Need to branch
6336 
6337 -- HW OPMCONV - No need to branch
6338 
6339 	  IF l_debug_on THEN
6340 		  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_DECIMAL_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6341 	  END IF;
6342 
6343 	  wsh_details_validations.check_decimal_quantity(
6344 			  p_item_id		 => x_det_rec.inventory_item_id,
6345 			  p_organization_id => x_det_rec.organization_id,
6346 			  p_input_quantity  => l_input_quantity,
6347 			  p_uom_code		=> x_det_rec.requested_quantity_uom,
6348 			  x_output_quantity => l_quantity,
6349 			  x_return_status   => l_return_status,
6350 			  p_top_model_line_id => x_det_rec.top_model_line_id
6351 	   );
6352 
6353 	   IF(p_flag = 'SQ') THEN
6354 		   x_det_rec.shipped_quantity := l_quantity;
6355 	   ELSIF(p_flag = 'CCQ') THEN
6356 		   x_det_rec.cycle_count_quantity := l_quantity;
6357 	   END IF;
6358 
6359 	  IF l_return_status <> wsh_util_core.g_ret_sts_success THEN
6360 	   IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
6361 		  RAISE WSH_UTIL_CORE.G_EXC_WARNING;
6362 	   ELSE
6363 		  RAISE FND_API.G_EXC_ERROR;
6364 	   END IF;
6365 	  END IF;
6366 
6367 -- HW OPM bug 2677054
6368 
6369 
6370 -- HW -- HW Harmonization project for OPM. end of changes
6371   -- 4) If SQ, check shipped qty
6372   --	If CCQ, check cc qty
6373   IF (p_flag = 'SQ') THEN
6374 		 IF l_debug_on THEN
6375 			 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_SHIPPED_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6376 		 END IF;
6377 		 wsh_details_validations.check_shipped_quantity(
6378 			  p_ship_above_tolerance	=> x_det_rec.ship_tolerance_above,
6379 			  p_requested_quantity	  => x_det_rec.requested_quantity,
6380 			  p_picked_quantity		 => x_det_rec.picked_quantity,
6381 			  p_shipped_quantity		=> NVL(l_quantity, 0),
6382 			  p_cycle_count_quantity	=> NVL(x_det_rec.cycle_count_quantity, 0),
6383 			  x_return_status   => l_return_status);
6384 
6385 	   IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6386 		  RAISE FND_API.G_EXC_ERROR;
6387 	   END IF;
6388 
6389 
6390   ELSIF(p_flag = 'CCQ') THEN
6391 
6392 		 IF l_debug_on THEN
6393 			 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_CYCLE_COUNT_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6394 		 END IF;
6395 
6396 		 wsh_details_validations.check_cycle_count_quantity(
6397 			  p_ship_above_tolerance	=> x_det_rec.ship_tolerance_above,
6398 			  p_requested_quantity	=> x_det_rec.requested_quantity,
6399 			  p_picked_quantity			=> x_det_rec.picked_quantity,
6400 			  p_shipped_quantity	=> NVL(x_det_rec.shipped_quantity, 0),
6401 			  p_cycle_count_quantity	=> NVL(l_quantity, 0),
6402 			  x_return_status			 => l_return_status);
6403 
6404 	   IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6405 		  RAISE FND_API.G_EXC_ERROR;
6406 	   END IF;
6407   END IF;
6408 
6409   -- 5) clear and unmark serial numbers based on quantity checks
6410 -- HW OPMCONV - No need to branch
6411 
6412 
6413 	   IF NVL(x_det_rec.picked_quantity, x_det_rec.requested_quantity)=1 THEN
6414 /*Bug 2174761 */
6415 /*
6416 		 IF ((x_det_rec.shipped_quantity >1 and x_det_rec.serial_number IS NOT NULL)
6417 			 OR -- Bug 2941879 : check for >= 0 . Treat null as 0 .
6418 			 (nvl(x_det_rec.shipped_quantity,0) >= 0 and x_det_rec.serial_quantity >
6419 											x_det_rec.shipped_quantity )) THEN
6420 */
6421                  -- Bug 3628620
6422                  IF ( -- Bug 2941879 : check for >= 0 . Treat null as 0 .
6423                      (nvl(x_det_rec.shipped_quantity,0) >= 0 and x_det_rec.serial_quantity >
6424                           x_det_rec.shipped_quantity )) THEN
6425                  -- End of Bug 3628620
6426                         -- Bug 2828503 : added warning for unmarking of serial_numbers
6427                         x_det_rec.unmark_serial_form := 'Y';
6428 			fnd_message.set_name('WSH', 'WSH_UI_UNMARK_SERIAL_NUM');
6429 		        wsh_util_core.add_message(wsh_util_core.g_ret_sts_warning);
6430                         l_number_of_warnings := l_number_of_warnings + 1;
6431 
6432 		   IF x_det_rec.serial_quantity > 0 AND x_det_rec.unmark_serial_server = 'Y' THEN
6433 
6434 			 IF l_debug_on THEN
6435 				 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.UNMARK_SERIAL_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
6436 			 END IF;
6437 			 wsh_delivery_details_inv.unmark_serial_number(
6438 				  p_delivery_detail_id  => x_det_rec.delivery_detail_id,
6439 				  p_serial_number_code  => x_det_rec.inv_ser_control_code,
6440 				  p_serial_number	   => x_det_rec.serial_number,
6441 				  p_transaction_temp_id => x_det_rec.transaction_temp_id,
6442 				  x_return_status	   => l_return_status,
6443 				  p_inventory_item_id   => x_det_rec.inventory_item_id
6444 	);
6445 		   IF l_debug_on THEN
6446 			  wsh_debug_sv.log(l_module_name, 'Return status after Unmark serial', l_return_status);
6447 		   END IF;
6448 
6449 			IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6450 				RAISE FND_API.G_EXC_ERROR;
6451 			END IF;
6452 		  END IF; -- if serial_quantity > 0
6453 
6454 			 x_det_rec.serial_quantity	 := 0;
6455 			 x_det_rec.serial_number	   := NULL;
6456 			 x_det_rec.transaction_temp_id := NULL;
6457 		 END IF;
6458 
6459 	   ELSIF x_det_rec.serial_quantity > x_det_rec.shipped_quantity
6460 		  OR nvl(x_det_rec.shipped_quantity,0) = 0
6461                   -- Bug 3628620 , Commented Code below
6462                   -- OR
6463 		  --(x_det_rec.serial_quantity = 1 AND x_det_rec.shipped_quantity > 1)  OR
6464                   --(x_det_rec.serial_quantity = 1 AND x_det_rec.shipped_quantity = 1 AND
6465                   -- x_det_rec.transaction_temp_id is not null)
6466                   -- End of Bug 3628620
6467                   THEN
6468 
6469 		  IF x_det_rec.serial_quantity > 0 THEN
6470                         -- Bug 2828503 : added warning for unmarking of serial_numbers
6471                         x_det_rec.unmark_serial_form := 'Y';
6472                         fnd_message.set_name('WSH', 'WSH_UI_UNMARK_SERIAL_NUM');
6473                         wsh_util_core.add_message(wsh_util_core.g_ret_sts_warning);
6474                         l_number_of_warnings := l_number_of_warnings + 1;
6475 
6476 		  IF l_debug_on THEN
6477 			  WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.UNMARK_SERIAL_NUMBER',WSH_DEBUG_SV.C_PROC_LEVEL);
6478 		  END IF;
6479 
6480                   IF x_det_rec.unmark_serial_server = 'Y' THEN
6481   		     wsh_delivery_details_inv.unmark_serial_number(
6482 		   		 p_delivery_detail_id  => x_det_rec.delivery_detail_id,
6483 		   		 p_serial_number_code  => x_det_rec.inv_ser_control_code,
6484 		   		 p_serial_number	   => x_det_rec.serial_number,
6485 				 p_transaction_temp_id => x_det_rec.transaction_temp_id,
6486 				 x_return_status	   => l_return_status,
6487 				 p_inventory_item_id   => x_det_rec.inventory_item_id);
6488 
6489 		      IF l_debug_on THEN
6490 	   		  wsh_debug_sv.log(l_module_name, 'Return status after Unmark serial', l_return_status);
6491 	   	      END IF;
6492 
6493 			 IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6494 				RAISE FND_API.G_EXC_ERROR;
6495 			 END IF;
6496 			END IF; -- if serial_quantity > 0
6497 
6498 			 x_det_rec.serial_quantity	 := 0;
6499 			 x_det_rec.serial_number	   := NULL;
6500 			 x_det_rec.transaction_temp_id := NULL;
6501 
6502 		  END IF;
6503 
6504 	   END IF;
6505 
6506 
6507 
6508   IF(p_flag = 'SQ') THEN
6509 	  x_det_rec.shipped_quantity := l_quantity;
6510 
6511   ELSIF(p_flag = 'CCQ') THEN
6512 	  x_det_rec.cycle_count_quantity := l_quantity;
6513   END IF;
6514 
6515 	 IF l_debug_on THEN
6516 		WSH_DEBUG_SV.log(l_module_name,'Output shipped quantity', x_det_rec.shipped_quantity);
6517 		WSH_DEBUG_SV.log(l_module_name, 'Output Cycle_Count quantity', x_det_rec.cycle_count_quantity);
6518 	 END IF;
6519 
6520   IF l_number_of_warnings > 0 THEN
6521      x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6522   END IF;
6523 
6524 	  IF l_debug_on THEN
6525 	   	 WSH_DEBUG_SV.log(l_module_name, 'Return status from api ', x_return_status);
6526 		 WSH_DEBUG_SV.pop(l_module_name);
6527 	  END IF;
6528 
6529 EXCEPTION
6530 		WHEN FND_API.G_EXC_ERROR THEN
6531 				x_return_status := FND_API.G_RET_STS_ERROR ;
6532 				wsh_util_core.add_message(x_return_status, l_module_name);
6533 				FND_MSG_PUB.Count_And_Get
6534 				  (
6535 					 p_count  => x_msg_count,
6536 					 p_data  =>  x_msg_data,
6537 				 p_encoded => FND_API.G_FALSE
6538 				  );
6539 
6540 				  IF l_debug_on THEN
6541 					  WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6542 					  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
6543 				  END IF;
6544 				  --
6545 		WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
6546 			 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6547 			 wsh_util_core.add_message(x_return_status, l_module_name);
6548 			 FND_MSG_PUB.Count_And_Get
6549 			  (
6550 				p_count  => x_msg_count,
6551 				p_data  =>  x_msg_data,
6552 				p_encoded => FND_API.G_FALSE
6553 			  );
6554 		--
6555 		IF l_debug_on THEN
6556 			WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6557 		   WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
6558 	   END IF;
6559 
6560 		WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6561 				x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6562 				FND_MSG_PUB.Count_And_Get
6563 				  (
6564 					 p_count  => x_msg_count,
6565 					 p_data  =>  x_msg_data,
6566 				 p_encoded => FND_API.G_FALSE
6567 				  );
6568 
6569 				  IF l_debug_on THEN
6570 					  WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6571 					  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
6572 				  END IF;
6573 				  --
6574 		WHEN OTHERS THEN
6575 				x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6576 				wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY');
6577 		--
6578 				 IF l_debug_on THEN
6579 					 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6580 					 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6581 				 END IF;
6582 
6583 
6584 END Validate_Shipped_CC_Quantity;
6585 --Harmonization Project I
6586 
6587 
6588 ------------------------------------------------------------------------
6589 	-- Procedure:	Validate_Shipped_CC_Quantity2
6590 	--
6591 	-- Parameters:
6592 	--
6593 	-- Description:  This procedure validates shipped_quantity2 or cycle_count_quantity2
6594 	--			   This procedure consolidates the validations needed for these quantities
6595 	--
6596 	-- Created:   Harmonization Project. Patchset I
6597 	--			HW Harmonization project for OPM
6598 	-- -----------------------------------------------------------------------
6599 	PROCEDURE Validate_Shipped_CC_Quantity2(
6600 		   p_flag			IN	   VARCHAR2, -- either 'SQ' or 'CCQ'
6601 		   x_det_rec		 IN OUT NOCOPY  ValidateQuantityAttrRecType,
6602 		   x_return_status   OUT   NOCOPY   VARCHAR2,
6603 		   x_msg_count	   OUT   NOCOPY   NUMBER,
6604 		   x_msg_data		OUT   NOCOPY   VARCHAR2
6605 		   ) IS
6606 
6607 		l_quantity	   NUMBER;
6608 		l_input_quantity NUMBER;
6609 
6610 		l_api_name			  CONSTANT VARCHAR2(30)   := 'Validate_Shipped_CC_Quantity2';
6611 		l_api_version		   CONSTANT NUMBER		 := 1.0;
6612 		--
6613 	--
6614 	l_return_status			 VARCHAR2(32767);
6615 	l_msg_count				 NUMBER;
6616 	l_msg_data				  VARCHAR2(32767);
6617 	l_program_name			  VARCHAR2(32767);
6618 
6619 	l_number_of_errors	NUMBER := 0;
6620 	l_number_of_warnings  NUMBER := 0;
6621 
6622         --added for Bug # 3266333
6623 	l_field_name   VARCHAR2(50);
6624 
6625 	   --
6626 l_debug_on BOOLEAN;
6627 	   --
6628 	   l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'VALIDATE_SHIPPED_CC_QUANTITY2';
6629 BEGIN
6630 
6631 
6632   --
6633   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6634   --
6635   IF l_debug_on IS NULL
6636   THEN
6637 	  l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6638   END IF;
6639   --
6640   IF l_debug_on THEN
6641 	 WSH_DEBUG_SV.push(l_module_name);
6642 	 WSH_DEBUG_SV.log(l_module_name,'P_FLAG',P_FLAG);
6643 	 WSH_DEBUG_SV.log(l_module_name, 'Shipped_Quantity2', x_det_rec.shipped_quantity2);
6644 	 WSH_DEBUG_SV.log(l_module_name, 'Cycle_Count_Quantity2', x_det_rec.cycle_count_quantity2);
6645 	 WSH_DEBUG_SV.log(l_module_name, 'Requested Quantity2', x_det_rec.requested_quantity2);
6646 	 WSH_DEBUG_SV.log(l_module_name, 'Picked Quantity2', x_det_rec.picked_quantity2);
6647 	 WSH_DEBUG_SV.log(l_module_name, 'Organization Id', x_det_rec.organization_id);
6648 	 WSH_DEBUG_SV.log(l_module_name, 'Inventory Item Id', x_det_rec.inventory_item_id);
6649   END IF;
6650 
6651   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6652   IF(p_flag = 'SQ') THEN
6653 	  l_input_quantity := x_det_rec.shipped_quantity2;
6654           --added for Bug # 3266333
6655 	  l_field_name     := 'shipped_quantity2';
6656 	  --
6657   ELSIF(p_flag = 'CCQ') THEN
6658 	  l_input_quantity := x_det_rec.cycle_count_quantity2;
6659           --added for Bug # 3266333
6660 	  l_field_name     := 'cycle_count_quantity2';
6661 	  --
6662   ELSE
6663 	 -- invalid flag
6664 	 raise fnd_api.g_exc_error;
6665   END IF;
6666 
6667   --1.a) if entered, enable backordered quantity and update it as max(requested_quantity2 - shipped_quantity2),0)
6668   --1.b) if null, clear cycle count and secondary quantity
6669   IF(x_det_rec.shipped_quantity2 IS NOT NULL) THEN
6670      --x_det_rec.cycle_count_quantity2 := Greatest((x_det_rec.requested_quantity2 - x_det_rec.shipped_quantity2),0);
6671      -- bug 5391211, cycle_count_qty2 should be a value that is derived from qty1
6672      x_det_rec.cycle_count_quantity2 := WSH_WV_UTILS.convert_uom
6673                     (
6674                         from_uom     => x_det_rec.requested_quantity_uom,
6675                         to_uom       => x_det_rec.requested_quantity_uom2,
6676                         quantity     => x_det_rec.cycle_count_quantity,
6677                         item_id      => x_det_rec.inventory_item_id
6678                     );
6679 
6680   -- PK Bug 3055126 added else clause
6681   ELSE
6682         x_det_rec.cycle_count_quantity2 := NULL;
6683 
6684   END IF;
6685 
6686   IF l_debug_on THEN
6687 	 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.VALIDATE_NEGATIVE',WSH_DEBUG_SV.C_PROC_LEVEL);
6688   END IF;
6689    -- 2) Check for negative
6690   --Bug # 3266333
6691   WSH_UTIL_VALIDATE.validate_negative(
6692          p_value          =>  l_input_quantity,
6693 	 p_field_name     =>  l_field_name,
6694 	 x_return_status  => l_return_status );
6695   --
6696 
6697    IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6698 		RAISE FND_API.G_EXC_ERROR;
6699    END IF;
6700 
6701 -- HW OPM BUG#:2677054
6702    IF(p_flag = 'SQ') THEN
6703 	  l_quantity := x_det_rec.shipped_quantity2;
6704 
6705    ELSIF(p_flag = 'CCQ') THEN
6706 	  l_quantity :=x_det_rec.cycle_count_quantity2;
6707    END IF;
6708 
6709   -- 4) If SQ, check shipped qty
6710   --	If CCQ, check cc qty
6711   --Bug 6668217. Uday Phadtare. Commented call wsh_details_validations.check_shipped_quantity
6712   --and wsh_details_validations.check_cycle_count_quantity for quantity2 because for quantity2
6713   --validation is not to be done.
6714   /*
6715   IF (p_flag = 'SQ') THEN
6716 
6717 		IF l_debug_on THEN
6718 			WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_SHIPPED_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6719 		END IF;
6720 		 wsh_details_validations.check_shipped_quantity(
6721 			  p_ship_above_tolerance	=> x_det_rec.ship_tolerance_above,
6722 			  p_requested_quantity	  => x_det_rec.requested_quantity2,
6723 			  p_picked_quantity		 => x_det_rec.picked_quantity2,
6724 			  p_shipped_quantity		=> NVL(l_quantity, 0),
6725 			  p_cycle_count_quantity	=> NVL(x_det_rec.cycle_count_quantity2, 0),
6726 			  x_return_status   => l_return_status);
6727 
6728 			 IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6729 			  RAISE FND_API.G_EXC_ERROR;
6730 			END IF;
6731   ELSIF(p_flag = 'CCQ') THEN
6732 
6733 	 IF l_debug_on THEN
6734 		WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DETAILS_VALIDATIONS.CHECK_CYCLE_COUNT_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6735 	 END IF;
6736 		 wsh_details_validations.check_cycle_count_quantity(
6737 			  p_ship_above_tolerance	=> x_det_rec.ship_tolerance_above,
6738 			  p_requested_quantity	=> x_det_rec.requested_quantity2,
6739 			  p_picked_quantity			=> x_det_rec.picked_quantity2,
6740 			  p_shipped_quantity	=> NVL(x_det_rec.shipped_quantity2, 0),
6741 			  p_cycle_count_quantity	=> NVL(l_quantity, 0),
6742 			  x_return_status			 => l_return_status);
6743 
6744 			  IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6745 				RAISE FND_API.G_EXC_ERROR;
6746 			  END IF;
6747   END IF;
6748   */
6749 
6750   IF(p_flag = 'SQ') THEN
6751 	  x_det_rec.shipped_quantity2 := l_quantity;
6752   ELSIF(p_flag = 'CCQ') THEN
6753 	  x_det_rec.cycle_count_quantity2 := l_quantity;
6754   END IF;
6755 
6756    IF l_debug_on THEN
6757 		WSH_DEBUG_SV.log(l_module_name,'Output shipped quantity2', x_det_rec.shipped_quantity2);
6758 		WSH_DEBUG_SV.log(l_module_name, 'Output Cycle_Count quantity2', x_det_rec.cycle_count_quantity2);
6759 	 END IF;
6760 
6761 	  IF l_debug_on THEN
6762 		 WSH_DEBUG_SV.pop(l_module_name);
6763 	  END IF;
6764 
6765 EXCEPTION
6766 		WHEN FND_API.G_EXC_ERROR THEN
6767 				x_return_status := FND_API.G_RET_STS_ERROR ;
6768 				FND_MSG_PUB.Count_And_Get
6769 				  (
6770 					 p_count  => x_msg_count,
6771 					 p_data  =>  x_msg_data,
6772 				 p_encoded => FND_API.G_FALSE
6773 				  );
6774 
6775 				  IF l_debug_on THEN
6776 					  WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6777 					  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
6778 				  END IF;
6779 				  --
6780 		WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6781 				x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6782 				FND_MSG_PUB.Count_And_Get
6783 				  (
6784 					 p_count  => x_msg_count,
6785 					 p_data  =>  x_msg_data,
6786 				 p_encoded => FND_API.G_FALSE
6787 				  );
6788 
6789 				  IF l_debug_on THEN
6790 					  WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6791 					  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
6792 				  END IF;
6793 				  --
6794 		WHEN OTHERS THEN
6795 				x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6796 				wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.VALIDATE_SHIPPED_CC_QUANTITY2');
6797 		--
6798 				 IF l_debug_on THEN
6799 					 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6800 					 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6801 				 END IF;
6802 
6803 
6804 END Validate_Shipped_CC_Quantity2;
6805 
6806 -- for Load Tender Project
6807 /*
6808 -----------------------------------------------------------------------------
6809    PROCEDURE  : Compare_Detail_Attributes
6810    PARAMETERS : p_old_table - Table of old records
6811 				p_new_table - Table of new records
6812 				p_entity - entity name -DELIVERY_DETAIL
6813 				p_action_code - action code for each action
6814 				p_phase - 1 for Before the action is performed, 2 for after.
6815 				p_caller - where is this API being called from
6816 				x_changed_id - Table of Changed ids
6817 				x_return_status - Return Status
6818   DESCRIPTION : This procedure compares the attributes for each entity.
6819 				For Delivery Detail,attributes are - weight/volume,quantity,
6820 				delivery,parent_delivery_detail
6821 				Added for Load Tender Project but this is independent of
6822 				FTE is installed or not.
6823 ------------------------------------------------------------------------------
6824 */
6825 PROCEDURE compare_detail_attributes
6826   (p_old_table	 IN wsh_interface.deliverydetailtab,
6827    p_new_table	 IN wsh_interface.deliverydetailtab,
6828    p_action_code   IN VARCHAR2,
6829    p_phase		 IN NUMBER,
6830    p_caller		IN VARCHAR2,
6831    x_changed_id_tab OUT NOCOPY wsh_util_core.id_tab_type,
6832    x_return_status OUT NOCOPY VARCHAR2
6833    ) IS
6834 
6835   l_return_status VARCHAR2(30);
6836   i NUMBER;
6837   l_id_tab WSH_UTIL_CORE.ID_TAB_TYPE;
6838 --
6839   l_debug_on BOOLEAN;
6840   l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'COMPARE_DETAIL_ATTRIBUTES';
6841 --
6842 
6843 BEGIN
6844 
6845   --
6846   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6847   --
6848   IF l_debug_on IS NULL THEN
6849 	l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6850   END IF;
6851   --
6852 
6853   IF l_debug_on THEN
6854 	WSH_DEBUG_SV.push(l_module_name);
6855 	WSH_DEBUG_SV.log(l_module_name,'P_Old_table.count',P_OLD_TABLE.COUNT);
6856 	WSH_DEBUG_SV.log(l_module_name,'P_new_table.count',P_NEW_TABLE.COUNT);
6857 	WSH_DEBUG_SV.log(l_module_name,'P_action_code',P_ACTION_CODE);
6858 	WSH_DEBUG_SV.log(l_module_name,'P_phase',P_PHASE);
6859 	WSH_DEBUG_SV.log(l_module_name,'P_caller',P_CALLER);
6860   END IF;
6861 
6862   x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6863   l_id_tab.DELETE;
6864 
6865   IF p_old_table.count = p_new_table.count THEN
6866 	FOR i in 1..p_old_table.count
6867 	LOOP
6868 	  IF (
6869 		 (p_old_table(i).requested_quantity <>
6870 			p_new_table(i).requested_quantity)
6871 		OR
6872 		 (nvl(p_old_table(i).shipped_quantity,-99) <>
6873 		   nvl(p_new_table(i).shipped_quantity,-99))
6874 		OR
6875 		 (nvl(p_old_table(i).picked_quantity,-99) <>
6876 			nvl(p_new_table(i).picked_quantity,-99))
6877 		OR
6878 		 (nvl(p_old_table(i).gross_weight,-99) <>
6879 			nvl(p_new_table(i).gross_weight,-99))
6880 		OR
6881 		 (nvl(p_old_table(i).net_weight,-99) <>
6882 			nvl(p_new_table(i).net_weight,-99))
6883 		OR
6884 		 (nvl(p_old_table(i).weight_uom_code,'XXX') <>
6885 			nvl(p_new_table(i).weight_uom_code,'XXX'))
6886 		OR
6887 		 (nvl(p_old_table(i).volume,-99) <>
6888 			nvl(p_new_table(i).volume,-99))
6889 		OR
6890 		 (nvl(p_old_table(i).volume_uom_code,'XXX') <>
6891 			nvl(p_new_table(i).volume_uom_code,'XXX'))
6892 		OR
6893 		 (nvl(p_old_table(i).delivery_id,-99) <>
6894 			nvl(p_new_table(i).delivery_id,-99))
6895 		OR
6896 		 (nvl(p_old_table(i).parent_delivery_detail_id,-99) <>
6897 			nvl(p_new_table(i).parent_delivery_detail_id,-99))
6898 		) THEN
6899 
6900 		l_id_tab(l_id_tab.count + 1) := p_old_table(i).delivery_detail_id;
6901 
6902 	  END IF;
6903 
6904 	END LOOP;
6905 
6906 	x_changed_id_tab := l_id_tab;
6907   END IF;
6908 
6909   IF l_debug_on THEN
6910 	WSH_DEBUG_SV.pop(l_module_name);
6911   END IF;
6912 
6913 EXCEPTION
6914   WHEN others THEN
6915 	wsh_util_core.default_handler('WSH_TRIP_UTILITIES.compare_detail_attributes');
6916 	x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6917 	IF l_debug_on THEN
6918 	  WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6919 	  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6920 	END IF;
6921 
6922 END compare_detail_attributes;
6923 
6924 -- End for Load Tender Project
6925 
6926 
6927 -- ----------------------------------------------------------------------
6928 -- Procedure:   validate_secondary_quantity
6929 -- Parameters:
6930 --              p_delivery_detail_id  Delivery Detail Id of line to be split
6931 --              x_quantity            Primary Quantity to be split
6932 --              x_quantity2           Secondary Quantity to be split
6933 --
6934 -- Description: Validates secondary quantity for OPM org. for tolerance.
6935 --              Following validations are performed :
6936 --              1. Primary quantity to be split is mandatory and should be positive
6937 --              2. If OPM item then secondary quantity to be split is
6938 --                  mandatory and should be positive
6939 --
6940 --              3. If item is under lot control, then validate lot number
6941 --              4. Check that secondary quantity is within tolerance for
6942 --                 items with dual UOM indicator 2 or 3
6943 --              5. get secondary quantity from primary quantity by applying UOM                    conversion
6944 --                 - for items with dual UOM indicator 1 (Always)
6945 --
6946 --  ----------------------------------------------------------------------
6947 -- HW OPMCONV - Added p_caller parameter
6948 PROCEDURE validate_secondary_quantity
6949             (
6950                p_delivery_detail_id  IN              NUMBER,
6951                x_quantity            IN OUT NOCOPY   NUMBER,
6952                x_quantity2           IN OUT NOCOPY   NUMBER,
6953                p_caller              IN              VARCHAR2 ,
6954                x_return_status       OUT    NOCOPY   VARCHAR2,
6955                x_msg_count           OUT    NOCOPY   NUMBER,
6956                x_msg_data            OUT    NOCOPY   VARCHAR2
6957             )
6958 IS
6959 --{
6960 
6961 -- HW OPMCONV - No need for OPM variables
6962 
6963     l_return              NUMBER;
6964     l_outside_tolerance   BOOLEAN := TRUE;
6965     l_qty2                NUMBER;
6966 
6967 -- HW OPMCONV - New variable
6968 out_of_deviation EXCEPTION;
6969     --
6970     -- Fetch delivery line information
6971     --
6972     CURSOR line_csr (p_delivery_detail_id IN NUMBER)
6973     IS
6974         SELECT organization_id, inventory_item_id,
6975                lot_number, nvl(line_direction,'O') line_direction,
6976                requested_quantity_uom,
6977                requested_quantity_uom2
6978         FROM   wsh_delivery_details
6979         WHERE  delivery_detail_id = p_delivery_detail_id;
6980     --
6981     --
6982     l_line_rec            line_csr%ROWTYPE;
6983     --
6984     --
6985     -- Validate lot number for the item
6986     --
6987 -- HW OPMCONV - Validate lot against Inventory table instead of OPM's
6988     CURSOR lot_csr (p_item_id IN NUMBER, p_organization_id IN NUMBER,
6989                     p_lot_number IN VARCHAR2)
6990     IS
6991         SELECT lot_number
6992         FROM   MTL_LOT_NUMBERS
6993         WHERE  inventory_item_id = p_item_id
6994         AND    organization_id = p_organization_id
6995         AND    lot_number  = p_lot_number ;
6996     --
6997     --
6998 -- HW OPMCONV - Changed type to char from number
6999     l_lot_num             VARCHAR2(80);
7000 
7001     --
7002     --
7003     l_debug_on                    BOOLEAN;
7004     --
7005     l_module_name        CONSTANT VARCHAR2(100) := 'wsh.plsql.' || g_pkg_name || '.' || 'VALIDATE_SECONDARY_QUANTITY';
7006     --
7007     l_number_of_errors            NUMBER := 0;
7008     l_number_of_warnings          NUMBER := 0;
7009     l_msg_count                   NUMBER;
7010     l_msg_data                    VARCHAR2(32767);
7011     l_return_status               VARCHAR2(32767);
7012     --
7013 -- HW OPMCONV - New variables
7014     l_item_info                   WSH_DELIVERY_DETAILS_INV.mtl_system_items_rec;
7015     INVALID_LOT                   EXCEPTION;
7016     e_end_of_api                  EXCEPTION;
7017 --}
7018 BEGIN
7019 --{
7020     --
7021     l_debug_on := wsh_debug_interface.g_debug;
7022     --
7023     IF l_debug_on IS NULL THEN
7024       l_debug_on := wsh_debug_sv.is_debug_enabled;
7025     END IF;
7026     --
7027     IF l_debug_on THEN
7028       wsh_debug_sv.push(l_module_name);
7029       --
7030       wsh_debug_sv.LOG(l_module_name, 'p_caller', p_caller);
7031       wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_DETAIL_ID', p_delivery_detail_id);
7032       wsh_debug_sv.LOG(l_module_name, 'X_QUANTITY', x_quantity);
7033       wsh_debug_sv.LOG(l_module_name, 'X_QUANTITY2', x_quantity2);
7034     END IF;
7035     --
7036     x_return_status := wsh_util_core.g_ret_sts_success;
7037     --
7038     --
7039     -- Check that primary quantity to be split is mandatory and should be
7040     -- positive
7041     --
7042     IF x_quantity IS NULL
7043     THEN
7044     --{
7045         fnd_message.set_name('WSH', 'WSH_REQUIRED_FIELD_NULL');
7046         fnd_message.set_token('FIELD_NAME','x_quantity');
7047         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7048         RAISE FND_API.G_EXC_ERROR;
7049     --}
7050 /* HW BUG 4548713- Removed checking for Qty being 0
7051     ELSIF x_quantity = 0
7052     THEN
7053     --{
7054     	--
7055         fnd_message.set_name('WSH', 'WSH_NO_ZERO_NUM');
7056         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7057         RAISE FND_API.G_EXC_ERROR;
7058     --}
7059 */
7060     ELSIF x_quantity < 0
7061     THEN
7062     --{
7063         fnd_message.set_name('WSH', 'WSH_NO_NEG_NUM');
7064         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7065         RAISE FND_API.G_EXC_ERROR;
7066     --}
7067     END IF;
7068     --
7069     --
7070     -- Fetch Delivery Line information
7071     --
7072     OPEN  line_csr (p_delivery_detail_id);
7073     FETCH line_csr INTO l_line_rec;
7074     --
7075     IF line_csr%NOTFOUND
7076     THEN
7077     --{
7078         fnd_message.set_name('WSH', 'WSH_DET_INVALID_DETAIL');
7079         fnd_message.set_token('DETAIL_ID',p_delivery_detail_id);
7080         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7081         RAISE FND_API.G_EXC_ERROR;
7082     --}
7083     END IF;
7084     --
7085     --
7086     CLOSE line_csr;
7087     --
7088     --
7089     IF l_debug_on THEN
7090         wsh_debug_sv.LOG(l_module_name, 'l_line_rec.organization_id', l_line_rec.organization_id);
7091         wsh_debug_sv.LOG(l_module_name, 'l_line_rec.inventory_item_id', l_line_rec.inventory_item_id);
7092         wsh_debug_sv.LOG(l_module_name, 'l_line_rec.lot_number', l_line_rec.lot_number);
7093         wsh_debug_sv.LOG(l_module_name, 'l_line_rec.requested_quantity_uom', l_line_rec.requested_quantity_uom);
7094         wsh_debug_sv.LOG(l_module_name, 'l_line_rec.requested_quantity_uom2', l_line_rec.requested_quantity_uom2);
7095 
7096     END IF;
7097     --
7098     --
7099     --
7100     IF l_line_rec.inventory_item_id IS NULL
7101     THEN
7102         RAISE e_end_of_api;
7103     END IF;
7104     --
7105     --
7106 --  HW OPMCONV - No need to call OPM APIS
7107 
7108 -- HW OPMCONV - Call API to get item info
7109     IF l_debug_on THEN
7110       WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.Get_item_information',WSH_DEBUG_SV.C_PROC_LEVEL);
7111     END IF;
7112 
7113     WSH_DELIVERY_DETAILS_INV.Get_item_information
7114             (
7115                p_organization_id       => l_line_rec.organization_id
7116               , p_inventory_item_id    => l_line_rec.inventory_item_id
7117               , x_mtl_system_items_rec => l_item_info
7118               , x_return_status        => l_return_status
7119             );
7120 
7121      --
7122     wsh_util_core.api_post_call
7123       (
7124         p_return_status => l_return_status,
7125         x_num_warnings  => l_number_of_warnings,
7126         x_num_errors    => l_number_of_errors
7127       );
7128     --
7129     --
7130 -- HW OPMCONV -Print debugging statements
7131     IF l_debug_on THEN
7132         wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_control_code', l_item_info.lot_control_code);
7133         wsh_debug_sv.LOG(l_module_name, 'l_item_info.tracking_quantity_ind', l_item_info.tracking_quantity_ind);
7134     END IF;
7135     --
7136     --
7137 -- HW OPMCONV - Changed condition to check for secondary_default_ind
7138     IF x_quantity2 IS NULL
7139     AND l_item_info.secondary_default_ind in ('F','D','N')
7140     THEN
7141     --{
7142         fnd_message.set_name('WSH', 'WSH_OPM_SEC_QTY_REQD_ERROR');
7143         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7144         RAISE FND_API.G_EXC_ERROR;
7145     --}
7146 -- HW OPMCONV - Changed condition to check for secondary_default_ind
7147 -- HW BUG 4548713 - Added check for x_quantity
7148     ELSIF x_quantity2 = 0
7149     AND l_item_info.secondary_default_ind in ('F','D','N')
7150     AND x_quantity > 0
7151     THEN
7152     --{
7153     	--
7154 
7155 
7156         fnd_message.set_name('WSH', 'WSH_NO_ZERO_NUM');
7157         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7158         RAISE FND_API.G_EXC_ERROR;
7159     --}
7160 -- HW OPMCONV - Changed condition to check for secondary_default_ind
7161     ELSIF x_quantity2 < 0
7162     AND l_item_info.secondary_default_ind in ('F','D','N')
7163     THEN
7164     --{
7165         fnd_message.set_name('WSH', 'WSH_NO_NEG_NUM');
7166         wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7167         RAISE FND_API.G_EXC_ERROR;
7168     --}
7169     END IF;
7170     --
7171     --
7172     -- If item is under lot control, validate lot number.
7173     --
7174 -- HW OPMCONV - Changed condition to check for lot_control_code
7175 -- and lot_number
7176     IF  l_item_info.lot_control_code > 0
7177     AND l_line_rec.lot_number     IS NOT NULL
7178     THEN
7179     --{
7180         OPEN  lot_csr (l_line_rec.inventory_item_id,
7181                        l_line_rec.organization_id,l_line_rec.lot_number);
7182         FETCH lot_csr INTO l_lot_num;
7183         --
7184         IF lot_csr%NOTFOUND
7185         THEN
7186         --{
7187             --fnd_message.set_name('GMI', 'IC_INVALID_LOT');
7188             --wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7189             RAISE INVALID_LOT;
7190         --}
7191         END IF;
7192         --
7193         --
7194         CLOSE lot_csr;
7195     --}
7196     ELSE
7197 -- HW OPMCONV make lot_number NULL
7198         l_lot_num := NULL;
7199     END IF;
7200     --
7201     --
7202     -- Check if secondary quantity is within tolerance for
7203     -- items with dual UOM indicator 2 or 3
7204     --
7205 -- HW OPMCONV - Check for two types only (Default and No Default)
7206     IF ( l_item_info.secondary_default_ind in ('D','N') ) OR
7207        ( p_caller = 'WSH_PUB' AND l_item_info.secondary_default_ind in ('F','D','N'))
7208     THEN
7209     --{
7210         --
7211         IF l_debug_on THEN
7212             wsh_debug_sv.logmsg(l_module_name, 'Calling program unit
7213 	    WSH_WV_UTILS.within_deviation', wsh_debug_sv.c_proc_level);
7214         END IF;
7215         --
7216 -- HW OPMCONV - Call new API to check deviation
7217         l_return := WSH_WV_UTILS.within_deviation
7218                         (
7219                           p_organization_id      => l_line_rec.organization_id,
7220                           p_inventory_item_id    => l_line_rec.inventory_item_id,
7221                           p_lot_number           => l_lot_num,
7222                           p_precision            => WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV,
7223                           p_quantity             => x_quantity,
7224                           p_uom1                 => l_line_rec.requested_quantity_uom,
7225                           p_quantity2            => x_quantity2,
7226                           p_uom2                 =>l_line_rec.requested_quantity_uom2
7227                         );
7228         --
7229          IF ( l_return = 1 ) THEN
7230            l_outside_tolerance := FALSE;
7231          ELSE -- this includes invalids UOMs)
7232            RAISE out_of_deviation;
7233          END IF;
7234     END IF;
7235     --}
7236 
7237     --
7238     --
7239     -- get secondary quantity from primary quantity by applying UOM conversion
7240     -- for items with dual UOM indicator 1 (Always)
7241     --
7242     --
7243 -- HW OPMCONV - Changed condition to check for secondary_default_ind
7244     IF  l_outside_tolerance  AND l_item_info.secondary_default_ind in ('F','D')
7245         AND ( p_caller <> 'WSH_PUB' )
7246     THEN
7247     --{
7248         --
7249         IF l_debug_on THEN
7250             wsh_debug_sv.logmsg(l_module_name, 'Calling program unit WSH_WV_UTILS.convert_uom', wsh_debug_sv.c_proc_level);
7251         END IF;
7252         --
7253 -- HW OPMCONV - Call UOM routine passing lot_num
7254         l_qty2 := WSH_WV_UTILS.convert_uom
7255                     (
7256                         item_id      => l_line_rec.inventory_item_id,
7257                         org_id       => l_line_rec.organization_id,
7258                         from_uom     => l_line_rec.requested_quantity_uom,
7259                         to_uom       => l_line_rec.requested_quantity_uom2,
7260                         quantity     => x_quantity,
7261                         lot_number   => l_lot_num
7262                     );
7263         --
7264         IF ( l_qty2 <= 0 ) THEN
7265             FND_MESSAGE.SET_NAME('wsh','WSH_UPDATE_CANNOT_SPLIT');
7266             wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7267             RAISE FND_API.G_EXC_ERROR;
7268         END IF;
7269         --
7270         IF l_qty2 <> x_quantity2
7271         THEN
7272         --{
7273             FND_MESSAGE.SET_NAME('WSH','WSH_OPM_QTY_ERROR');
7274             FND_MESSAGE.SET_TOKEN('QUANTITY2',x_quantity2);
7275             FND_MESSAGE.SET_TOKEN('CONV_QUANTITY2',l_qty2);
7276             --wsh_util_core.add_message(FND_API.G_RET_STS_ERROR, l_module_name);
7277             --RAISE FND_API.G_EXC_ERROR;
7278             wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_WARNING, l_module_name);
7279             l_number_of_warnings := NVL(l_number_of_warnings,0) + 1;
7280         --}
7281         END IF;
7282         --
7283         x_quantity2 := l_qty2;
7284     --}
7285     END IF;
7286     --
7287     IF l_number_of_warnings > 0 THEN
7288       IF l_debug_on THEN
7289          wsh_debug_sv.log(l_module_name, 'Number of warnings', l_number_of_warnings);
7290       END IF;
7291 
7292       RAISE wsh_util_core.g_exc_warning;
7293     END IF;
7294     --
7295     fnd_msg_pub.count_and_get(
7296       p_count => x_msg_count,
7297       p_data => x_msg_data,
7298       p_encoded      => fnd_api.g_false);
7299 
7300     IF l_debug_on THEN
7301       wsh_debug_sv.LOG(l_module_name, 'X_QUANTITY2', x_quantity2);
7302       wsh_debug_sv.pop(l_module_name);
7303     END IF;
7304     --
7305 --}
7306 EXCEPTION
7307    WHEN e_end_of_api THEN
7308         x_return_status := fnd_api.g_ret_sts_success;
7309        fnd_msg_pub.count_and_get(
7310          p_count => x_msg_count,
7311          p_data => x_msg_data,
7312          p_encoded      => fnd_api.g_false);
7313       --
7314       IF l_debug_on THEN
7315          wsh_debug_sv.pop(l_module_name);
7316       END IF;
7317    --
7318 
7319    WHEN INVALID_LOT THEN
7320       x_return_status := fnd_api.g_ret_sts_error;
7321       IF l_debug_on THEN
7322          wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
7323          WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid Lot Number');
7324       END IF;
7325 
7326    WHEN OUT_OF_DEVIATION   THEN
7327      x_return_status := fnd_api.g_ret_sts_error;
7328      IF l_debug_on THEN
7329          wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
7330          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
7331       END IF;
7332 
7333    WHEN fnd_api.g_exc_error THEN
7334       x_return_status := fnd_api.g_ret_sts_error;
7335       fnd_msg_pub.count_and_get(
7336          p_count => x_msg_count,
7337          p_data => x_msg_data,
7338          p_encoded      => fnd_api.g_false);
7339       --
7340       IF l_debug_on THEN
7341          wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
7342          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
7343       END IF;
7344    --
7345    WHEN fnd_api.g_exc_unexpected_error THEN
7346       x_return_status := fnd_api.g_ret_sts_unexp_error;
7347       fnd_msg_pub.count_and_get(
7348          p_count => x_msg_count,
7349          p_data => x_msg_data,
7350          p_encoded      => fnd_api.g_false);
7351       --
7352       IF l_debug_on THEN
7353          wsh_debug_sv.logmsg(l_module_name, 'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.', wsh_debug_sv.c_excep_level);
7354          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
7355       END IF;
7356    --
7357    WHEN wsh_util_core.g_exc_warning THEN
7358       x_return_status := wsh_util_core.g_ret_sts_warning;
7359       fnd_msg_pub.count_and_get(
7360          p_count => x_msg_count,
7361          p_data => x_msg_data,
7362          p_encoded      => fnd_api.g_false);
7363       --
7364       IF l_debug_on THEN
7365          wsh_debug_sv.logmsg(l_module_name, 'WSH_UTIL_CORE.G_EXC_WARNING exception has occured ', wsh_debug_sv.c_excep_level);
7366          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
7367       END IF;
7368    WHEN OTHERS THEN
7369       x_return_status := fnd_api.g_ret_sts_unexp_error;
7370       wsh_util_core.default_handler('WSH_DETAILS_VALIDATIONS.validate_secondary_quantity',l_module_name);
7371       --
7372       fnd_msg_pub.count_and_get(
7373          p_count => x_msg_count,
7374          p_data => x_msg_data,
7375          p_encoded      => fnd_api.g_false);
7376       --
7377       IF l_debug_on THEN
7378         wsh_debug_sv.pop(l_module_name, 'EXCEPTION:OTHERS');
7379       END IF;
7380 --
7381 END validate_secondary_quantity;
7382 
7383 --public api change
7384 PROCEDURE   user_non_updatable_columns
7385      (p_user_in_rec     IN wsh_glbl_var_strct_grp.delivery_details_rec_type,
7386       p_out_rec         IN wsh_glbl_var_strct_grp.delivery_details_rec_type,
7387       p_in_rec          IN wsh_glbl_var_strct_grp.detailInRecType,
7388       x_return_status   OUT NOCOPY    VARCHAR2)
7389 
7390 IS
7391 l_attributes VARCHAR2(2500) ;
7392 k         number;
7393 l_return_status VARCHAR2(1);
7394 l_debug_on BOOLEAN;
7395 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'user_non_updatable_columns';
7396 
7397 BEGIN
7398 
7399   l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7400   --
7401   IF l_debug_on IS NULL
7402   THEN
7403       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7404   END IF;
7405   --
7406   IF l_debug_on THEN
7407     --
7408     WSH_DEBUG_SV.push(l_module_name);
7409     WSH_DEBUG_SV.log(l_module_name,'p_in_rec.caller',p_in_rec.caller);
7410     --
7411   END IF;
7412   --
7413   x_return_status := FND_API.G_RET_STS_SUCCESS;
7414   --
7415   IF     p_user_in_rec.DELIVERY_DETAIL_ID <> FND_API.G_MISS_NUM
7416       AND NVL(p_user_in_rec.DELIVERY_DETAIL_ID,-99) <> NVL(p_out_rec.DELIVERY_DETAIL_ID,-99)
7417   THEN
7418        l_attributes := l_attributes || 'DELIVERY_DETAIL_ID, ';
7419   END IF;
7420 
7421   IF     p_user_in_rec.SOURCE_CODE <> FND_API.G_MISS_CHAR
7422       AND NVL(p_user_in_rec.SOURCE_CODE,'!!!') <> NVL(p_out_rec.SOURCE_CODE,'!!!')
7423   THEN
7424        l_attributes := l_attributes || 'SOURCE_CODE, ';
7425   END IF;
7426 
7427   IF     p_user_in_rec.SOURCE_HEADER_ID <> FND_API.G_MISS_NUM
7428       AND NVL(p_user_in_rec.SOURCE_HEADER_ID,-99) <> NVL(p_out_rec.SOURCE_HEADER_ID,-99)
7429   THEN
7430        l_attributes := l_attributes || 'SOURCE_HEADER_ID, ';
7431   END IF;
7432 
7433   IF     p_user_in_rec.SOURCE_LINE_ID <> FND_API.G_MISS_NUM
7434       AND NVL(p_user_in_rec.SOURCE_LINE_ID,-99) <> NVL(p_out_rec.SOURCE_LINE_ID,-99)
7435   THEN
7436        l_attributes := l_attributes || 'SOURCE_LINE_ID, ';
7437   END IF;
7438 
7439   IF     p_user_in_rec.CUSTOMER_ID <> FND_API.G_MISS_NUM
7440       AND NVL(p_user_in_rec.CUSTOMER_ID,-99) <> NVL(p_out_rec.CUSTOMER_ID,-99)
7441   THEN
7442        l_attributes := l_attributes || 'CUSTOMER_ID, ';
7443   END IF;
7444 
7445   IF     p_user_in_rec.SOLD_TO_CONTACT_ID <> FND_API.G_MISS_NUM
7446       AND NVL(p_user_in_rec.SOLD_TO_CONTACT_ID,-99) <> NVL(p_out_rec.SOLD_TO_CONTACT_ID,-99)
7447   THEN
7448        l_attributes := l_attributes || 'SOLD_TO_CONTACT_ID, ';
7449   END IF;
7450 
7451   IF     p_user_in_rec.INVENTORY_ITEM_ID <> FND_API.G_MISS_NUM
7452       AND NVL(p_user_in_rec.INVENTORY_ITEM_ID,-99) <> NVL(p_out_rec.INVENTORY_ITEM_ID,-99)
7453   THEN
7454        l_attributes := l_attributes || 'INVENTORY_ITEM_ID, ';
7455   END IF;
7456 
7457   IF     p_user_in_rec.ITEM_DESCRIPTION <> FND_API.G_MISS_CHAR
7458       AND NVL(p_user_in_rec.ITEM_DESCRIPTION,'!!!') <> NVL(p_out_rec.ITEM_DESCRIPTION,'!!!')
7459   THEN
7460        l_attributes := l_attributes || 'ITEM_DESCRIPTION, ';
7461   END IF;
7462 
7463   IF     p_user_in_rec.HAZARD_CLASS_ID <> FND_API.G_MISS_NUM
7464       AND NVL(p_user_in_rec.HAZARD_CLASS_ID,-99) <> NVL(p_out_rec.HAZARD_CLASS_ID,-99)
7465   THEN
7466        l_attributes := l_attributes || 'HAZARD_CLASS_ID, ';
7467   END IF;
7468 
7469   IF     p_user_in_rec.COUNTRY_OF_ORIGIN <> FND_API.G_MISS_CHAR
7470       AND NVL(p_user_in_rec.COUNTRY_OF_ORIGIN,'!!!') <> NVL(p_out_rec.COUNTRY_OF_ORIGIN,'!!!')
7471   THEN
7472        l_attributes := l_attributes || 'COUNTRY_OF_ORIGIN, ';
7473   END IF;
7474 
7475   IF     p_user_in_rec.CLASSIFICATION <> FND_API.G_MISS_CHAR
7476       AND NVL(p_user_in_rec.CLASSIFICATION,'!!!') <> NVL(p_out_rec.CLASSIFICATION,'!!!')
7477   THEN
7478        l_attributes := l_attributes || 'CLASSIFICATION, ';
7479   END IF;
7480 
7481   IF     p_user_in_rec.SHIP_FROM_LOCATION_ID <> FND_API.G_MISS_NUM
7482       AND NVL(p_user_in_rec.SHIP_FROM_LOCATION_ID,-99) <> NVL(p_out_rec.SHIP_FROM_LOCATION_ID,-99)
7483   THEN
7484        l_attributes := l_attributes || 'SHIP_FROM_LOCATION_ID, ';
7485   END IF;
7486 
7487   IF     p_user_in_rec.SHIP_TO_LOCATION_ID <> FND_API.G_MISS_NUM
7488       AND NVL(p_user_in_rec.SHIP_TO_LOCATION_ID,-99) <> NVL(p_out_rec.SHIP_TO_LOCATION_ID,-99)
7489   THEN
7490        l_attributes := l_attributes || 'SHIP_TO_LOCATION_ID, ';
7491   END IF;
7492 
7493   IF     p_user_in_rec.SHIP_TO_CONTACT_ID <> FND_API.G_MISS_NUM
7494       AND NVL(p_user_in_rec.SHIP_TO_CONTACT_ID,-99) <> NVL(p_out_rec.SHIP_TO_CONTACT_ID,-99)
7495   THEN
7496        l_attributes := l_attributes || 'SHIP_TO_CONTACT_ID, ';
7497   END IF;
7498 
7499   IF     p_user_in_rec.SHIP_TO_SITE_USE_ID <> FND_API.G_MISS_NUM
7500       AND NVL(p_user_in_rec.SHIP_TO_SITE_USE_ID,-99) <> NVL(p_out_rec.SHIP_TO_SITE_USE_ID,-99)
7501   THEN
7502        l_attributes := l_attributes || 'SHIP_TO_SITE_USE_ID, ';
7503   END IF;
7504 
7505   IF     p_user_in_rec.DELIVER_TO_LOCATION_ID <> FND_API.G_MISS_NUM
7506       AND NVL(p_user_in_rec.DELIVER_TO_LOCATION_ID,-99) <> NVL(p_out_rec.DELIVER_TO_LOCATION_ID,-99)
7507   THEN
7508        l_attributes := l_attributes || 'DELIVER_TO_LOCATION_ID, ';
7509   END IF;
7510 
7511   IF     p_user_in_rec.DELIVER_TO_CONTACT_ID <> FND_API.G_MISS_NUM
7512       AND NVL(p_user_in_rec.DELIVER_TO_CONTACT_ID,-99) <> NVL(p_out_rec.DELIVER_TO_CONTACT_ID,-99)
7513   THEN
7514        l_attributes := l_attributes || 'DELIVER_TO_CONTACT_ID, ';
7515   END IF;
7516 
7517   IF     p_user_in_rec.DELIVER_TO_SITE_USE_ID <> FND_API.G_MISS_NUM
7518       AND NVL(p_user_in_rec.DELIVER_TO_SITE_USE_ID,-99) <> NVL(p_out_rec.DELIVER_TO_SITE_USE_ID,-99)
7519   THEN
7520        l_attributes := l_attributes || 'DELIVER_TO_SITE_USE_ID, ';
7521   END IF;
7522 
7523   IF     p_user_in_rec.INTMED_SHIP_TO_LOCATION_ID <> FND_API.G_MISS_NUM
7524       AND NVL(p_user_in_rec.INTMED_SHIP_TO_LOCATION_ID,-99) <> NVL(p_out_rec.INTMED_SHIP_TO_LOCATION_ID,-99)
7525   THEN
7526        l_attributes := l_attributes || 'INTMED_SHIP_TO_LOCATION_ID, ';
7527   END IF;
7528 
7529   IF     p_user_in_rec.INTMED_SHIP_TO_CONTACT_ID <> FND_API.G_MISS_NUM
7530       AND NVL(p_user_in_rec.INTMED_SHIP_TO_CONTACT_ID,-99) <> NVL(p_out_rec.INTMED_SHIP_TO_CONTACT_ID,-99)
7531   THEN
7532        l_attributes := l_attributes || 'INTMED_SHIP_TO_CONTACT_ID, ';
7533   END IF;
7534 
7535   IF     p_user_in_rec.HOLD_CODE <> FND_API.G_MISS_CHAR
7536       AND NVL(p_user_in_rec.HOLD_CODE,'!!!') <> NVL(p_out_rec.HOLD_CODE,'!!!')
7537   THEN
7538        l_attributes := l_attributes || 'HOLD_CODE, ';
7539   END IF;
7540 
7541   IF     p_user_in_rec.SHIP_TOLERANCE_ABOVE <> FND_API.G_MISS_NUM
7542       AND NVL(p_user_in_rec.SHIP_TOLERANCE_ABOVE,-99) <> NVL(p_out_rec.SHIP_TOLERANCE_ABOVE,-99)
7543   THEN
7544        l_attributes := l_attributes || 'SHIP_TOLERANCE_ABOVE, ';
7545   END IF;
7546 
7547   IF     p_user_in_rec.SHIP_TOLERANCE_BELOW <> FND_API.G_MISS_NUM
7548       AND NVL(p_user_in_rec.SHIP_TOLERANCE_BELOW,-99) <> NVL(p_out_rec.SHIP_TOLERANCE_BELOW,-99)
7549   THEN
7550        l_attributes := l_attributes || 'SHIP_TOLERANCE_BELOW, ';
7551   END IF;
7552 
7553   IF     p_user_in_rec.REQUESTED_QUANTITY <> FND_API.G_MISS_NUM
7554       AND NVL(p_user_in_rec.REQUESTED_QUANTITY,-99) <> NVL(p_out_rec.REQUESTED_QUANTITY,-99)
7555   THEN
7556        l_attributes := l_attributes || 'REQUESTED_QUANTITY, ';
7557   END IF;
7558 
7559   IF     p_user_in_rec.SHIPPED_QUANTITY <> FND_API.G_MISS_NUM
7560       AND NVL(p_user_in_rec.SHIPPED_QUANTITY,-99) <> NVL(p_out_rec.SHIPPED_QUANTITY,-99)
7561   THEN
7562        l_attributes := l_attributes || 'SHIPPED_QUANTITY, ';
7563   END IF;
7564 
7565   IF     p_user_in_rec.DELIVERED_QUANTITY <> FND_API.G_MISS_NUM
7566       AND NVL(p_user_in_rec.DELIVERED_QUANTITY,-99) <> NVL(p_out_rec.DELIVERED_QUANTITY,-99)
7567   THEN
7568        l_attributes := l_attributes || 'DELIVERED_QUANTITY, ';
7569   END IF;
7570 
7571   IF     p_user_in_rec.REQUESTED_QUANTITY_UOM <> FND_API.G_MISS_CHAR
7572       AND NVL(p_user_in_rec.REQUESTED_QUANTITY_UOM,'!!!') <> NVL(p_out_rec.REQUESTED_QUANTITY_UOM,'!!!')
7573   THEN
7574        l_attributes := l_attributes || 'REQUESTED_QUANTITY_UOM, ';
7575   END IF;
7576 
7577   IF     p_user_in_rec.SUBINVENTORY <> FND_API.G_MISS_CHAR
7578       AND NVL(p_user_in_rec.SUBINVENTORY,'!!!') <> NVL(p_out_rec.SUBINVENTORY,'!!!')
7579   THEN
7580        l_attributes := l_attributes || 'SUBINVENTORY, ';
7581   END IF;
7582 
7583   IF     p_user_in_rec.REVISION <> FND_API.G_MISS_CHAR
7584       AND NVL(p_user_in_rec.REVISION,'!!!') <> NVL(p_out_rec.REVISION,'!!!')
7585   THEN
7586        l_attributes := l_attributes || 'REVISION, ';
7587   END IF;
7588 
7589   IF     p_user_in_rec.LOT_NUMBER <> FND_API.G_MISS_CHAR
7590       AND NVL(p_user_in_rec.LOT_NUMBER,'!!!') <> NVL(p_out_rec.LOT_NUMBER,'!!!')
7591   THEN
7592        l_attributes := l_attributes || 'LOT_NUMBER, ';
7593   END IF;
7594 
7595   IF     p_user_in_rec.CUSTOMER_REQUESTED_LOT_FLAG <> FND_API.G_MISS_CHAR
7596       AND NVL(p_user_in_rec.CUSTOMER_REQUESTED_LOT_FLAG,'!!!') <> NVL(p_out_rec.CUSTOMER_REQUESTED_LOT_FLAG,'!!!')
7597   THEN
7598        l_attributes := l_attributes || 'CUSTOMER_REQUESTED_LOT_FLAG, ';
7599   END IF;
7600 
7601   IF     p_user_in_rec.SERIAL_NUMBER <> FND_API.G_MISS_CHAR
7602       AND NVL(p_user_in_rec.SERIAL_NUMBER,'!!!') <> NVL(p_out_rec.SERIAL_NUMBER,'!!!')
7603   THEN
7604        l_attributes := l_attributes || 'SERIAL_NUMBER, ';
7605   END IF;
7606 
7607   IF     p_user_in_rec.LOCATOR_ID <> FND_API.G_MISS_NUM
7608       AND NVL(p_user_in_rec.LOCATOR_ID,-99) <> NVL(p_out_rec.LOCATOR_ID,-99)
7609   THEN
7610        l_attributes := l_attributes || 'LOCATOR_ID, ';
7611   END IF;
7612 
7613   IF     p_user_in_rec.DATE_REQUESTED <> FND_API.G_MISS_DATE
7614       AND NVL(p_user_in_rec.DATE_REQUESTED,TO_DATE('2','j')) <> NVL(p_out_rec.DATE_REQUESTED,TO_DATE('2','j'))
7615   THEN
7616        l_attributes := l_attributes || 'DATE_REQUESTED, ';
7617   END IF;
7618 
7619   IF     p_user_in_rec.DATE_SCHEDULED <> FND_API.G_MISS_DATE
7620       AND NVL(p_user_in_rec.DATE_SCHEDULED,TO_DATE('2','j')) <> NVL(p_out_rec.DATE_SCHEDULED,TO_DATE('2','j'))
7621   THEN
7622        l_attributes := l_attributes || 'DATE_SCHEDULED, ';
7623   END IF;
7624 
7625   IF     p_user_in_rec.MASTER_CONTAINER_ITEM_ID <> FND_API.G_MISS_NUM
7626       AND NVL(p_user_in_rec.MASTER_CONTAINER_ITEM_ID,-99) <> NVL(p_out_rec.MASTER_CONTAINER_ITEM_ID,-99)
7627   THEN
7628        l_attributes := l_attributes || 'MASTER_CONTAINER_ITEM_ID, ';
7629   END IF;
7630 
7631   IF     p_user_in_rec.DETAIL_CONTAINER_ITEM_ID <> FND_API.G_MISS_NUM
7632       AND NVL(p_user_in_rec.DETAIL_CONTAINER_ITEM_ID,-99) <> NVL(p_out_rec.DETAIL_CONTAINER_ITEM_ID,-99)
7633   THEN
7634        l_attributes := l_attributes || 'DETAIL_CONTAINER_ITEM_ID, ';
7635   END IF;
7636 
7637   IF     p_user_in_rec.LOAD_SEQ_NUMBER <> FND_API.G_MISS_NUM
7638       AND NVL(p_user_in_rec.LOAD_SEQ_NUMBER,-99) <> NVL(p_out_rec.LOAD_SEQ_NUMBER,-99)
7639   THEN
7640        l_attributes := l_attributes || 'LOAD_SEQ_NUMBER, ';
7641   END IF;
7642 
7643   IF     p_user_in_rec.SHIP_METHOD_CODE <> FND_API.G_MISS_CHAR
7644       AND NVL(p_user_in_rec.SHIP_METHOD_CODE,'!!!') <> NVL(p_out_rec.SHIP_METHOD_CODE,'!!!')
7645   THEN
7646        l_attributes := l_attributes || 'SHIP_METHOD_CODE, ';
7647   END IF;
7648 
7649   IF     p_user_in_rec.CARRIER_ID <> FND_API.G_MISS_NUM
7650       AND NVL(p_user_in_rec.CARRIER_ID,-99) <> NVL(p_out_rec.CARRIER_ID,-99)
7651   THEN
7652        l_attributes := l_attributes || 'CARRIER_ID, ';
7653   END IF;
7654 
7655   IF     p_user_in_rec.FREIGHT_TERMS_CODE <> FND_API.G_MISS_CHAR
7656       AND NVL(p_user_in_rec.FREIGHT_TERMS_CODE,'!!!') <> NVL(p_out_rec.FREIGHT_TERMS_CODE,'!!!')
7657   THEN
7658        l_attributes := l_attributes || 'FREIGHT_TERMS_CODE, ';
7659   END IF;
7660 
7661   IF     p_user_in_rec.SHIPMENT_PRIORITY_CODE <> FND_API.G_MISS_CHAR
7662       AND NVL(p_user_in_rec.SHIPMENT_PRIORITY_CODE,'!!!') <> NVL(p_out_rec.SHIPMENT_PRIORITY_CODE,'!!!')
7663   THEN
7664        l_attributes := l_attributes || 'SHIPMENT_PRIORITY_CODE, ';
7665   END IF;
7666 
7667   IF     p_user_in_rec.FOB_CODE <> FND_API.G_MISS_CHAR
7668       AND NVL(p_user_in_rec.FOB_CODE,'!!!') <> NVL(p_out_rec.FOB_CODE,'!!!')
7669   THEN
7670        l_attributes := l_attributes || 'FOB_CODE, ';
7671   END IF;
7672 
7673   IF     p_user_in_rec.CUSTOMER_ITEM_ID <> FND_API.G_MISS_NUM
7674       AND NVL(p_user_in_rec.CUSTOMER_ITEM_ID,-99) <> NVL(p_out_rec.CUSTOMER_ITEM_ID,-99)
7675   THEN
7676        l_attributes := l_attributes || 'CUSTOMER_ITEM_ID, ';
7677   END IF;
7678 
7679   IF     p_user_in_rec.DEP_PLAN_REQUIRED_FLAG <> FND_API.G_MISS_CHAR
7680       AND NVL(p_user_in_rec.DEP_PLAN_REQUIRED_FLAG,'!!!') <> NVL(p_out_rec.DEP_PLAN_REQUIRED_FLAG,'!!!')
7681   THEN
7682        l_attributes := l_attributes || 'DEP_PLAN_REQUIRED_FLAG, ';
7683   END IF;
7684 
7685   IF     p_user_in_rec.CUSTOMER_PROD_SEQ <> FND_API.G_MISS_CHAR
7686       AND NVL(p_user_in_rec.CUSTOMER_PROD_SEQ,'!!!') <> NVL(p_out_rec.CUSTOMER_PROD_SEQ,'!!!')
7687   THEN
7688        l_attributes := l_attributes || 'CUSTOMER_PROD_SEQ, ';
7689   END IF;
7690 
7691   IF     p_user_in_rec.CUSTOMER_DOCK_CODE <> FND_API.G_MISS_CHAR
7692       AND NVL(p_user_in_rec.CUSTOMER_DOCK_CODE,'!!!') <> NVL(p_out_rec.CUSTOMER_DOCK_CODE,'!!!')
7693   THEN
7694        l_attributes := l_attributes || 'CUSTOMER_DOCK_CODE, ';
7695   END IF;
7696 
7697   IF     p_user_in_rec.CUST_MODEL_SERIAL_NUMBER <> FND_API.G_MISS_CHAR
7698       AND NVL(p_user_in_rec.CUST_MODEL_SERIAL_NUMBER,'!!!') <> NVL(p_out_rec.CUST_MODEL_SERIAL_NUMBER,'!!!')
7699   THEN
7700        l_attributes := l_attributes || 'CUST_MODEL_SERIAL_NUMBER, ';
7701   END IF;
7702 
7703   IF     p_user_in_rec.CUSTOMER_JOB <> FND_API.G_MISS_CHAR
7704       AND NVL(p_user_in_rec.CUSTOMER_JOB,'!!!') <> NVL(p_out_rec.CUSTOMER_JOB,'!!!')
7705   THEN
7706        l_attributes := l_attributes || 'CUSTOMER_JOB, ';
7707   END IF;
7708 
7709   IF     p_user_in_rec.CUSTOMER_PRODUCTION_LINE <> FND_API.G_MISS_CHAR
7710       AND NVL(p_user_in_rec.CUSTOMER_PRODUCTION_LINE,'!!!') <> NVL(p_out_rec.CUSTOMER_PRODUCTION_LINE,'!!!')
7711   THEN
7712        l_attributes := l_attributes || 'CUSTOMER_PRODUCTION_LINE, ';
7713   END IF;
7714 
7715   IF     p_user_in_rec.NET_WEIGHT <> FND_API.G_MISS_NUM
7716       AND NVL(p_user_in_rec.NET_WEIGHT,-99) <> NVL(p_out_rec.NET_WEIGHT,-99)
7717   THEN
7718        l_attributes := l_attributes || 'NET_WEIGHT, ';
7719   END IF;
7720 
7721   IF     p_user_in_rec.WEIGHT_UOM_CODE <> FND_API.G_MISS_CHAR
7722       AND NVL(p_user_in_rec.WEIGHT_UOM_CODE,'!!!') <> NVL(p_out_rec.WEIGHT_UOM_CODE,'!!!')
7723   THEN
7724        IF (NVL(p_in_rec.caller,'WSH')  LIKE 'WMS%')
7725          AND (NVL(p_in_rec.action_code,'CREATE') = 'UPDATE') THEN
7726           NULL;
7727        ELSE
7728           l_attributes := l_attributes || 'WEIGHT_UOM_CODE, ';
7729        END IF;
7730   END IF;
7731 
7732   IF     p_user_in_rec.VOLUME <> FND_API.G_MISS_NUM
7733       AND NVL(p_user_in_rec.VOLUME,-99) <> NVL(p_out_rec.VOLUME,-99)
7734   THEN
7735        l_attributes := l_attributes || 'VOLUME, ';
7736   END IF;
7737 
7738   IF     p_user_in_rec.VOLUME_UOM_CODE <> FND_API.G_MISS_CHAR
7739       AND NVL(p_user_in_rec.VOLUME_UOM_CODE,'!!!') <> NVL(p_out_rec.VOLUME_UOM_CODE,'!!!')
7740   THEN
7741        IF (NVL(p_in_rec.caller,'WSH')  LIKE 'WMS%')
7742          AND (NVL(p_in_rec.action_code,'CREATE') = 'UPDATE') THEN
7743           NULL;
7744        ELSE
7745           l_attributes := l_attributes || 'VOLUME_UOM_CODE, ';
7746        END IF;
7747   END IF;
7748 
7749   IF     p_user_in_rec.TP_ATTRIBUTE_CATEGORY <> FND_API.G_MISS_CHAR
7750       AND NVL(p_user_in_rec.TP_ATTRIBUTE_CATEGORY,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE_CATEGORY,'!!!')
7751   THEN
7752        l_attributes := l_attributes || 'TP_ATTRIBUTE_CATEGORY, ';
7753   END IF;
7754 
7755   IF     p_user_in_rec.TP_ATTRIBUTE1 <> FND_API.G_MISS_CHAR
7756       AND NVL(p_user_in_rec.TP_ATTRIBUTE1,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE1,'!!!')
7757   THEN
7758        l_attributes := l_attributes || 'TP_ATTRIBUTE1, ';
7759   END IF;
7760 
7761   IF     p_user_in_rec.TP_ATTRIBUTE2 <> FND_API.G_MISS_CHAR
7762       AND NVL(p_user_in_rec.TP_ATTRIBUTE2,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE2,'!!!')
7763   THEN
7764        l_attributes := l_attributes || 'TP_ATTRIBUTE2, ';
7765   END IF;
7766 
7767   IF     p_user_in_rec.TP_ATTRIBUTE3 <> FND_API.G_MISS_CHAR
7768       AND NVL(p_user_in_rec.TP_ATTRIBUTE3,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE3,'!!!')
7769   THEN
7770        l_attributes := l_attributes || 'TP_ATTRIBUTE3, ';
7771   END IF;
7772 
7773   IF     p_user_in_rec.TP_ATTRIBUTE4 <> FND_API.G_MISS_CHAR
7774       AND NVL(p_user_in_rec.TP_ATTRIBUTE4,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE4,'!!!')
7775   THEN
7776        l_attributes := l_attributes || 'TP_ATTRIBUTE4, ';
7777   END IF;
7778 
7779   IF     p_user_in_rec.TP_ATTRIBUTE5 <> FND_API.G_MISS_CHAR
7780       AND NVL(p_user_in_rec.TP_ATTRIBUTE5,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE5,'!!!')
7781   THEN
7782        l_attributes := l_attributes || 'TP_ATTRIBUTE5, ';
7783   END IF;
7784 
7785   IF     p_user_in_rec.TP_ATTRIBUTE6 <> FND_API.G_MISS_CHAR
7786       AND NVL(p_user_in_rec.TP_ATTRIBUTE6,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE6,'!!!')
7787   THEN
7788        l_attributes := l_attributes || 'TP_ATTRIBUTE6, ';
7789   END IF;
7790 
7791   IF     p_user_in_rec.TP_ATTRIBUTE7 <> FND_API.G_MISS_CHAR
7792       AND NVL(p_user_in_rec.TP_ATTRIBUTE7,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE7,'!!!')
7793   THEN
7794        l_attributes := l_attributes || 'TP_ATTRIBUTE7, ';
7795   END IF;
7796 
7797   IF     p_user_in_rec.TP_ATTRIBUTE8 <> FND_API.G_MISS_CHAR
7798       AND NVL(p_user_in_rec.TP_ATTRIBUTE8,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE8,'!!!')
7799   THEN
7800        l_attributes := l_attributes || 'TP_ATTRIBUTE8, ';
7801   END IF;
7802 
7803   IF     p_user_in_rec.TP_ATTRIBUTE9 <> FND_API.G_MISS_CHAR
7804       AND NVL(p_user_in_rec.TP_ATTRIBUTE9,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE9,'!!!')
7805   THEN
7806        l_attributes := l_attributes || 'TP_ATTRIBUTE9, ';
7807   END IF;
7808 
7809   IF     p_user_in_rec.TP_ATTRIBUTE10 <> FND_API.G_MISS_CHAR
7810       AND NVL(p_user_in_rec.TP_ATTRIBUTE10,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE10,'!!!')
7811   THEN
7812        l_attributes := l_attributes || 'TP_ATTRIBUTE10, ';
7813   END IF;
7814 
7815   IF     p_user_in_rec.TP_ATTRIBUTE11 <> FND_API.G_MISS_CHAR
7816       AND NVL(p_user_in_rec.TP_ATTRIBUTE11,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE11,'!!!')
7817   THEN
7818        l_attributes := l_attributes || 'TP_ATTRIBUTE11, ';
7819   END IF;
7820 
7821   IF     p_user_in_rec.TP_ATTRIBUTE12 <> FND_API.G_MISS_CHAR
7822       AND NVL(p_user_in_rec.TP_ATTRIBUTE12,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE12,'!!!')
7823   THEN
7824        l_attributes := l_attributes || 'TP_ATTRIBUTE12, ';
7825   END IF;
7826 
7827   IF     p_user_in_rec.TP_ATTRIBUTE13 <> FND_API.G_MISS_CHAR
7828       AND NVL(p_user_in_rec.TP_ATTRIBUTE13,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE13,'!!!')
7829   THEN
7830        l_attributes := l_attributes || 'TP_ATTRIBUTE13, ';
7831   END IF;
7832 
7833   IF     p_user_in_rec.TP_ATTRIBUTE14 <> FND_API.G_MISS_CHAR
7834       AND NVL(p_user_in_rec.TP_ATTRIBUTE14,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE14,'!!!')
7835   THEN
7836        l_attributes := l_attributes || 'TP_ATTRIBUTE14, ';
7837   END IF;
7838 
7839   IF     p_user_in_rec.TP_ATTRIBUTE15 <> FND_API.G_MISS_CHAR
7840       AND NVL(p_user_in_rec.TP_ATTRIBUTE15,'!!!') <> NVL(p_out_rec.TP_ATTRIBUTE15,'!!!')
7841   THEN
7842        l_attributes := l_attributes || 'TP_ATTRIBUTE15, ';
7843   END IF;
7844 
7845   IF     p_user_in_rec.ATTRIBUTE_CATEGORY <> FND_API.G_MISS_CHAR
7846       AND NVL(p_user_in_rec.ATTRIBUTE_CATEGORY,'!!!') <> NVL(p_out_rec.ATTRIBUTE_CATEGORY,'!!!')
7847   THEN
7848        l_attributes := l_attributes || 'ATTRIBUTE_CATEGORY, ';
7849   END IF;
7850 
7851   IF     p_user_in_rec.ATTRIBUTE1 <> FND_API.G_MISS_CHAR
7852       AND NVL(p_user_in_rec.ATTRIBUTE1,'!!!') <> NVL(p_out_rec.ATTRIBUTE1,'!!!')
7853   THEN
7854        l_attributes := l_attributes || 'ATTRIBUTE1, ';
7855   END IF;
7856 
7857   IF     p_user_in_rec.ATTRIBUTE2 <> FND_API.G_MISS_CHAR
7858       AND NVL(p_user_in_rec.ATTRIBUTE2,'!!!') <> NVL(p_out_rec.ATTRIBUTE2,'!!!')
7859   THEN
7860        l_attributes := l_attributes || 'ATTRIBUTE2, ';
7861   END IF;
7862 
7863   IF     p_user_in_rec.ATTRIBUTE3 <> FND_API.G_MISS_CHAR
7864       AND NVL(p_user_in_rec.ATTRIBUTE3,'!!!') <> NVL(p_out_rec.ATTRIBUTE3,'!!!')
7865   THEN
7866        l_attributes := l_attributes || 'ATTRIBUTE3, ';
7867   END IF;
7868 
7869   IF     p_user_in_rec.ATTRIBUTE4 <> FND_API.G_MISS_CHAR
7870       AND NVL(p_user_in_rec.ATTRIBUTE4,'!!!') <> NVL(p_out_rec.ATTRIBUTE4,'!!!')
7871   THEN
7872        l_attributes := l_attributes || 'ATTRIBUTE4, ';
7873   END IF;
7874 
7875   IF     p_user_in_rec.ATTRIBUTE5 <> FND_API.G_MISS_CHAR
7876       AND NVL(p_user_in_rec.ATTRIBUTE5,'!!!') <> NVL(p_out_rec.ATTRIBUTE5,'!!!')
7877   THEN
7878        l_attributes := l_attributes || 'ATTRIBUTE5, ';
7879   END IF;
7880 
7881   IF     p_user_in_rec.ATTRIBUTE6 <> FND_API.G_MISS_CHAR
7882       AND NVL(p_user_in_rec.ATTRIBUTE6,'!!!') <> NVL(p_out_rec.ATTRIBUTE6,'!!!')
7883   THEN
7884        l_attributes := l_attributes || 'ATTRIBUTE6, ';
7885   END IF;
7886 
7887   IF     p_user_in_rec.ATTRIBUTE7 <> FND_API.G_MISS_CHAR
7888       AND NVL(p_user_in_rec.ATTRIBUTE7,'!!!') <> NVL(p_out_rec.ATTRIBUTE7,'!!!')
7889   THEN
7890        l_attributes := l_attributes || 'ATTRIBUTE7, ';
7891   END IF;
7892 
7893   IF     p_user_in_rec.ATTRIBUTE8 <> FND_API.G_MISS_CHAR
7894       AND NVL(p_user_in_rec.ATTRIBUTE8,'!!!') <> NVL(p_out_rec.ATTRIBUTE8,'!!!')
7895   THEN
7896        l_attributes := l_attributes || 'ATTRIBUTE8, ';
7897   END IF;
7898 
7899   IF     p_user_in_rec.ATTRIBUTE9 <> FND_API.G_MISS_CHAR
7900       AND NVL(p_user_in_rec.ATTRIBUTE9,'!!!') <> NVL(p_out_rec.ATTRIBUTE9,'!!!')
7901   THEN
7902        l_attributes := l_attributes || 'ATTRIBUTE9, ';
7903   END IF;
7904 
7905   IF     p_user_in_rec.ATTRIBUTE10 <> FND_API.G_MISS_CHAR
7906       AND NVL(p_user_in_rec.ATTRIBUTE10,'!!!') <> NVL(p_out_rec.ATTRIBUTE10,'!!!')
7907   THEN
7908        l_attributes := l_attributes || 'ATTRIBUTE10, ';
7909   END IF;
7910 
7911   IF     p_user_in_rec.ATTRIBUTE11 <> FND_API.G_MISS_CHAR
7912       AND NVL(p_user_in_rec.ATTRIBUTE11,'!!!') <> NVL(p_out_rec.ATTRIBUTE11,'!!!')
7913   THEN
7914        l_attributes := l_attributes || 'ATTRIBUTE11, ';
7915   END IF;
7916 
7917   IF     p_user_in_rec.ATTRIBUTE12 <> FND_API.G_MISS_CHAR
7918       AND NVL(p_user_in_rec.ATTRIBUTE12,'!!!') <> NVL(p_out_rec.ATTRIBUTE12,'!!!')
7919   THEN
7920        l_attributes := l_attributes || 'ATTRIBUTE12, ';
7921   END IF;
7922 
7923   IF     p_user_in_rec.ATTRIBUTE13 <> FND_API.G_MISS_CHAR
7924       AND NVL(p_user_in_rec.ATTRIBUTE13,'!!!') <> NVL(p_out_rec.ATTRIBUTE13,'!!!')
7925   THEN
7926        l_attributes := l_attributes || 'ATTRIBUTE13, ';
7927   END IF;
7928 
7929   IF     p_user_in_rec.ATTRIBUTE14 <> FND_API.G_MISS_CHAR
7930       AND NVL(p_user_in_rec.ATTRIBUTE14,'!!!') <> NVL(p_out_rec.ATTRIBUTE14,'!!!')
7931   THEN
7932        l_attributes := l_attributes || 'ATTRIBUTE14, ';
7933   END IF;
7934 
7935   IF     p_user_in_rec.ATTRIBUTE15 <> FND_API.G_MISS_CHAR
7936       AND NVL(p_user_in_rec.ATTRIBUTE15,'!!!') <> NVL(p_out_rec.ATTRIBUTE15,'!!!')
7937   THEN
7938        l_attributes := l_attributes || 'ATTRIBUTE15, ';
7939   END IF;
7940 
7941   /**
7942   -- Bug 3613650 : Need not compare WHO columns
7943   --
7944   IF     p_user_in_rec.CREATED_BY <> FND_API.G_MISS_NUM
7945       AND NVL(p_user_in_rec.CREATED_BY,-99) <> NVL(p_out_rec.CREATED_BY,-99)
7946   THEN
7947        l_attributes := l_attributes || 'CREATED_BY, ';
7948   END IF;
7949 
7950   IF     p_user_in_rec.CREATION_DATE <> FND_API.G_MISS_DATE
7951       AND NVL(p_user_in_rec.CREATION_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.CREATION_DATE,TO_DATE('2','j'))
7952   THEN
7953        l_attributes := l_attributes || 'CREATION_DATE, ';
7954   END IF;
7955 
7956   IF     p_user_in_rec.LAST_UPDATE_DATE <> FND_API.G_MISS_DATE
7957       AND NVL(p_user_in_rec.LAST_UPDATE_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.LAST_UPDATE_DATE,TO_DATE('2','j'))
7958   THEN
7959        l_attributes := l_attributes || 'LAST_UPDATE_DATE, ';
7960   END IF;
7961 
7962   IF     p_user_in_rec.LAST_UPDATE_LOGIN <> FND_API.G_MISS_NUM
7963       AND NVL(p_user_in_rec.LAST_UPDATE_LOGIN,-99) <> NVL(p_out_rec.LAST_UPDATE_LOGIN,-99)
7964   THEN
7965        l_attributes := l_attributes || 'LAST_UPDATE_LOGIN, ';
7966   END IF;
7967 
7968   IF     p_user_in_rec.LAST_UPDATED_BY <> FND_API.G_MISS_NUM
7969       AND NVL(p_user_in_rec.LAST_UPDATED_BY,-99) <> NVL(p_out_rec.LAST_UPDATED_BY,-99)
7970   THEN
7971        l_attributes := l_attributes || 'LAST_UPDATED_BY, ';
7972   END IF;
7973 
7974   IF     p_user_in_rec.PROGRAM_APPLICATION_ID <> FND_API.G_MISS_NUM
7975       AND NVL(p_user_in_rec.PROGRAM_APPLICATION_ID,-99) <> NVL(p_out_rec.PROGRAM_APPLICATION_ID,-99)
7976   THEN
7977        l_attributes := l_attributes || 'PROGRAM_APPLICATION_ID, ';
7978   END IF;
7979 
7980   IF     p_user_in_rec.PROGRAM_ID <> FND_API.G_MISS_NUM
7981       AND NVL(p_user_in_rec.PROGRAM_ID,-99) <> NVL(p_out_rec.PROGRAM_ID,-99)
7982   THEN
7983        l_attributes := l_attributes || 'PROGRAM_ID, ';
7984   END IF;
7985 
7986   IF     p_user_in_rec.PROGRAM_UPDATE_DATE <> FND_API.G_MISS_DATE
7987       AND NVL(p_user_in_rec.PROGRAM_UPDATE_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.PROGRAM_UPDATE_DATE,TO_DATE('2','j'))
7988   THEN
7989        l_attributes := l_attributes || 'PROGRAM_UPDATE_DATE, ';
7990   END IF;
7991 
7992   IF     p_user_in_rec.REQUEST_ID <> FND_API.G_MISS_NUM
7993       AND NVL(p_user_in_rec.REQUEST_ID,-99) <> NVL(p_out_rec.REQUEST_ID,-99)
7994   THEN
7995        l_attributes := l_attributes || 'REQUEST_ID, ';
7996   END IF;
7997   **/
7998 
7999   IF     p_user_in_rec.MVT_STAT_STATUS <> FND_API.G_MISS_CHAR
8000       AND NVL(p_user_in_rec.MVT_STAT_STATUS,'!!!') <> NVL(p_out_rec.MVT_STAT_STATUS,'!!!')
8001   THEN
8002        l_attributes := l_attributes || 'MVT_STAT_STATUS, ';
8003   END IF;
8004 
8005   IF     p_user_in_rec.RELEASED_FLAG <> FND_API.G_MISS_CHAR
8006       AND NVL(p_user_in_rec.RELEASED_FLAG,'!!!') <> NVL(p_out_rec.RELEASED_FLAG,'!!!')
8007   THEN
8008        l_attributes := l_attributes || 'RELEASED_FLAG, ';
8009   END IF;
8010 
8011   IF     p_user_in_rec.ORGANIZATION_ID <> FND_API.G_MISS_NUM
8012       AND NVL(p_user_in_rec.ORGANIZATION_ID,-99) <> NVL(p_out_rec.ORGANIZATION_ID,-99)
8013   THEN
8014        l_attributes := l_attributes || 'ORGANIZATION_ID, ';
8015   END IF;
8016 
8017   IF     p_user_in_rec.TRANSACTION_TEMP_ID <> FND_API.G_MISS_NUM
8018       AND NVL(p_user_in_rec.TRANSACTION_TEMP_ID,-99) <> NVL(p_out_rec.TRANSACTION_TEMP_ID,-99)
8019   THEN
8020        l_attributes := l_attributes || 'TRANSACTION_TEMP_ID, ';
8021   END IF;
8022 
8023   IF     p_user_in_rec.SHIP_SET_ID <> FND_API.G_MISS_NUM
8024       AND NVL(p_user_in_rec.SHIP_SET_ID,-99) <> NVL(p_out_rec.SHIP_SET_ID,-99)
8025   THEN
8026        l_attributes := l_attributes || 'SHIP_SET_ID, ';
8027   END IF;
8028 
8029   IF     p_user_in_rec.ARRIVAL_SET_ID <> FND_API.G_MISS_NUM
8030       AND NVL(p_user_in_rec.ARRIVAL_SET_ID,-99) <> NVL(p_out_rec.ARRIVAL_SET_ID,-99)
8031   THEN
8032        l_attributes := l_attributes || 'ARRIVAL_SET_ID, ';
8033   END IF;
8034 
8035   IF     p_user_in_rec.SHIP_MODEL_COMPLETE_FLAG <> FND_API.G_MISS_CHAR
8036       AND NVL(p_user_in_rec.SHIP_MODEL_COMPLETE_FLAG,'!!!') <> NVL(p_out_rec.SHIP_MODEL_COMPLETE_FLAG,'!!!')
8037   THEN
8038        l_attributes := l_attributes || 'SHIP_MODEL_COMPLETE_FLAG, ';
8039   END IF;
8040 
8041   IF     p_user_in_rec.TOP_MODEL_LINE_ID <> FND_API.G_MISS_NUM
8042       AND NVL(p_user_in_rec.TOP_MODEL_LINE_ID,-99) <> NVL(p_out_rec.TOP_MODEL_LINE_ID,-99)
8043   THEN
8044        l_attributes := l_attributes || 'TOP_MODEL_LINE_ID, ';
8045   END IF;
8046 
8047   IF     p_user_in_rec.SOURCE_HEADER_NUMBER <> FND_API.G_MISS_CHAR
8048       AND NVL(p_user_in_rec.SOURCE_HEADER_NUMBER,'!!!') <> NVL(p_out_rec.SOURCE_HEADER_NUMBER,'!!!')
8049   THEN
8050        l_attributes := l_attributes || 'SOURCE_HEADER_NUMBER, ';
8051   END IF;
8052 
8053   IF     p_user_in_rec.SOURCE_HEADER_TYPE_ID <> FND_API.G_MISS_NUM
8054       AND NVL(p_user_in_rec.SOURCE_HEADER_TYPE_ID,-99) <> NVL(p_out_rec.SOURCE_HEADER_TYPE_ID,-99)
8055   THEN
8056        l_attributes := l_attributes || 'SOURCE_HEADER_TYPE_ID, ';
8057   END IF;
8058 
8059   IF     p_user_in_rec.SOURCE_HEADER_TYPE_NAME <> FND_API.G_MISS_CHAR
8060       AND NVL(p_user_in_rec.SOURCE_HEADER_TYPE_NAME,'!!!') <> NVL(p_out_rec.SOURCE_HEADER_TYPE_NAME,'!!!')
8061   THEN
8062        l_attributes := l_attributes || 'SOURCE_HEADER_TYPE_NAME, ';
8063   END IF;
8064 
8065   IF     p_user_in_rec.CUST_PO_NUMBER <> FND_API.G_MISS_CHAR
8066       AND NVL(p_user_in_rec.CUST_PO_NUMBER,'!!!') <> NVL(p_out_rec.CUST_PO_NUMBER,'!!!')
8067   THEN
8068        l_attributes := l_attributes || 'CUST_PO_NUMBER, ';
8069   END IF;
8070 
8071   IF     p_user_in_rec.ATO_LINE_ID <> FND_API.G_MISS_NUM
8072       AND NVL(p_user_in_rec.ATO_LINE_ID,-99) <> NVL(p_out_rec.ATO_LINE_ID,-99)
8073   THEN
8074        l_attributes := l_attributes || 'ATO_LINE_ID, ';
8075   END IF;
8076 
8077   IF     p_user_in_rec.SRC_REQUESTED_QUANTITY <> FND_API.G_MISS_NUM
8078       AND NVL(p_user_in_rec.SRC_REQUESTED_QUANTITY,-99) <> NVL(p_out_rec.SRC_REQUESTED_QUANTITY,-99)
8079   THEN
8080        l_attributes := l_attributes || 'SRC_REQUESTED_QUANTITY, ';
8081   END IF;
8082 
8083   IF     p_user_in_rec.SRC_REQUESTED_QUANTITY_UOM <> FND_API.G_MISS_CHAR
8084       AND NVL(p_user_in_rec.SRC_REQUESTED_QUANTITY_UOM,'!!!') <> NVL(p_out_rec.SRC_REQUESTED_QUANTITY_UOM,'!!!')
8085   THEN
8086        l_attributes := l_attributes || 'SRC_REQUESTED_QUANTITY_UOM, ';
8087   END IF;
8088 
8089   IF     p_user_in_rec.MOVE_ORDER_LINE_ID <> FND_API.G_MISS_NUM
8090       AND NVL(p_user_in_rec.MOVE_ORDER_LINE_ID,-99) <> NVL(p_out_rec.MOVE_ORDER_LINE_ID,-99)
8091   THEN
8092        l_attributes := l_attributes || 'MOVE_ORDER_LINE_ID, ';
8093   END IF;
8094   --bug# 6689448 (replenishment project)
8095   IF     p_user_in_rec.REPLENISHMENT_STATUS <> FND_API.G_MISS_CHAR
8096       AND NVL(p_user_in_rec.REPLENISHMENT_STATUS,'!!!') <> NVL(p_out_rec.REPLENISHMENT_STATUS,'!!!')
8097   THEN
8098        l_attributes := l_attributes || 'REPLENISHMENT_STATUS, ';
8099   END IF;
8100 
8101   IF     p_user_in_rec.CANCELLED_QUANTITY <> FND_API.G_MISS_NUM
8102       AND NVL(p_user_in_rec.CANCELLED_QUANTITY,-99) <> NVL(p_out_rec.CANCELLED_QUANTITY,-99)
8103   THEN
8104        l_attributes := l_attributes || 'CANCELLED_QUANTITY, ';
8105   END IF;
8106 
8107   IF     p_user_in_rec.QUALITY_CONTROL_QUANTITY <> FND_API.G_MISS_NUM
8108       AND NVL(p_user_in_rec.QUALITY_CONTROL_QUANTITY,-99) <> NVL(p_out_rec.QUALITY_CONTROL_QUANTITY,-99)
8109   THEN
8110        l_attributes := l_attributes || 'QUALITY_CONTROL_QUANTITY, ';
8111   END IF;
8112 
8113   IF     p_user_in_rec.CYCLE_COUNT_QUANTITY <> FND_API.G_MISS_NUM
8114       AND NVL(p_user_in_rec.CYCLE_COUNT_QUANTITY,-99) <> NVL(p_out_rec.CYCLE_COUNT_QUANTITY,-99)
8115   THEN
8116        l_attributes := l_attributes || 'CYCLE_COUNT_QUANTITY, ';
8117   END IF;
8118 
8119   IF     p_user_in_rec.TRACKING_NUMBER <> FND_API.G_MISS_CHAR
8120       AND NVL(p_user_in_rec.TRACKING_NUMBER,'!!!') <> NVL(p_out_rec.TRACKING_NUMBER,'!!!')
8121   THEN
8122        l_attributes := l_attributes || 'TRACKING_NUMBER, ';
8123   END IF;
8124 
8125   IF     p_user_in_rec.MOVEMENT_ID <> FND_API.G_MISS_NUM
8126       AND NVL(p_user_in_rec.MOVEMENT_ID,-99) <> NVL(p_out_rec.MOVEMENT_ID,-99)
8127   THEN
8128        l_attributes := l_attributes || 'MOVEMENT_ID, ';
8129   END IF;
8130 
8131   IF     p_user_in_rec.SHIPPING_INSTRUCTIONS <> FND_API.G_MISS_CHAR
8132       AND NVL(p_user_in_rec.SHIPPING_INSTRUCTIONS,'!!!') <> NVL(p_out_rec.SHIPPING_INSTRUCTIONS,'!!!')
8133   THEN
8134        l_attributes := l_attributes || 'SHIPPING_INSTRUCTIONS, ';
8135   END IF;
8136 
8137   IF     p_user_in_rec.PACKING_INSTRUCTIONS <> FND_API.G_MISS_CHAR
8138       AND NVL(p_user_in_rec.PACKING_INSTRUCTIONS,'!!!') <> NVL(p_out_rec.PACKING_INSTRUCTIONS,'!!!')
8139   THEN
8140        l_attributes := l_attributes || 'PACKING_INSTRUCTIONS, ';
8141   END IF;
8142 
8143   IF     p_user_in_rec.PROJECT_ID <> FND_API.G_MISS_NUM
8144       AND NVL(p_user_in_rec.PROJECT_ID,-99) <> NVL(p_out_rec.PROJECT_ID,-99)
8145   THEN
8146        l_attributes := l_attributes || 'PROJECT_ID, ';
8147   END IF;
8148 
8149   IF     p_user_in_rec.TASK_ID <> FND_API.G_MISS_NUM
8150       AND NVL(p_user_in_rec.TASK_ID,-99) <> NVL(p_out_rec.TASK_ID,-99)
8151   THEN
8152        l_attributes := l_attributes || 'TASK_ID, ';
8153   END IF;
8154 
8155   IF     p_user_in_rec.ORG_ID <> FND_API.G_MISS_NUM
8156       AND NVL(p_user_in_rec.ORG_ID,-99) <> NVL(p_out_rec.ORG_ID,-99)
8157   THEN
8158        l_attributes := l_attributes || 'ORG_ID, ';
8159   END IF;
8160 
8161   IF     p_user_in_rec.OE_INTERFACED_FLAG <> FND_API.G_MISS_CHAR
8162       AND NVL(p_user_in_rec.OE_INTERFACED_FLAG,'!!!') <> NVL(p_out_rec.OE_INTERFACED_FLAG,'!!!')
8163   THEN
8164        l_attributes := l_attributes || 'OE_INTERFACED_FLAG, ';
8165   END IF;
8166 
8167   IF     p_user_in_rec.SPLIT_FROM_DETAIL_ID <> FND_API.G_MISS_NUM
8168       AND NVL(p_user_in_rec.SPLIT_FROM_DETAIL_ID,-99) <> NVL(p_out_rec.SPLIT_FROM_DETAIL_ID,-99)
8169   THEN
8170        l_attributes := l_attributes || 'SPLIT_FROM_DETAIL_ID, ';
8171   END IF;
8172 
8173   IF     p_user_in_rec.INV_INTERFACED_FLAG <> FND_API.G_MISS_CHAR
8174       AND NVL(p_user_in_rec.INV_INTERFACED_FLAG,'!!!') <> NVL(p_out_rec.INV_INTERFACED_FLAG,'!!!')
8175   THEN
8176        l_attributes := l_attributes || 'INV_INTERFACED_FLAG, ';
8177   END IF;
8178 
8179   IF     p_user_in_rec.SOURCE_LINE_NUMBER <> FND_API.G_MISS_CHAR
8180       AND NVL(p_user_in_rec.SOURCE_LINE_NUMBER,'!!!') <> NVL(p_out_rec.SOURCE_LINE_NUMBER,'!!!')
8181   THEN
8182        l_attributes := l_attributes || 'SOURCE_LINE_NUMBER, ';
8183   END IF;
8184 
8185   IF     p_user_in_rec.INSPECTION_FLAG <> FND_API.G_MISS_CHAR
8186       AND NVL(p_user_in_rec.INSPECTION_FLAG,'!!!') <> NVL(p_out_rec.INSPECTION_FLAG,'!!!')
8187   THEN
8188        l_attributes := l_attributes || 'INSPECTION_FLAG, ';
8189   END IF;
8190 
8191   IF     p_user_in_rec.RELEASED_STATUS <> FND_API.G_MISS_CHAR
8192       AND NVL(p_user_in_rec.RELEASED_STATUS,'!!!') <> NVL(p_out_rec.RELEASED_STATUS,'!!!')
8193   THEN
8194        l_attributes := l_attributes || 'RELEASED_STATUS, ';
8195   END IF;
8196 
8197   IF     p_user_in_rec.CONTAINER_FLAG <> FND_API.G_MISS_CHAR
8198       AND NVL(p_user_in_rec.CONTAINER_FLAG,'!!!') <> NVL(p_out_rec.CONTAINER_FLAG,'!!!')
8199   THEN
8200        l_attributes := l_attributes || 'CONTAINER_FLAG, ';
8201   END IF;
8202 
8203   IF     p_user_in_rec.CONTAINER_TYPE_CODE <> FND_API.G_MISS_CHAR
8204       AND NVL(p_user_in_rec.CONTAINER_TYPE_CODE,'!!!') <> NVL(p_out_rec.CONTAINER_TYPE_CODE,'!!!')
8205   THEN
8206        l_attributes := l_attributes || 'CONTAINER_TYPE_CODE, ';
8207   END IF;
8208 
8209   IF     p_user_in_rec.CONTAINER_NAME <> FND_API.G_MISS_CHAR
8210       AND NVL(p_user_in_rec.CONTAINER_NAME,'!!!') <> NVL(p_out_rec.CONTAINER_NAME,'!!!')
8211   THEN
8212        l_attributes := l_attributes || 'CONTAINER_NAME, ';
8213   END IF;
8214 
8215   IF     p_user_in_rec.FILL_PERCENT <> FND_API.G_MISS_NUM
8216       AND NVL(p_user_in_rec.FILL_PERCENT,-99) <> NVL(p_out_rec.FILL_PERCENT,-99)
8217   THEN
8218        l_attributes := l_attributes || 'FILL_PERCENT, ';
8219   END IF;
8220 
8221   IF     p_user_in_rec.GROSS_WEIGHT <> FND_API.G_MISS_NUM
8222       AND NVL(p_user_in_rec.GROSS_WEIGHT,-99) <> NVL(p_out_rec.GROSS_WEIGHT,-99)
8223   THEN
8224        l_attributes := l_attributes || 'GROSS_WEIGHT, ';
8225   END IF;
8226 
8227   IF     p_user_in_rec.MASTER_SERIAL_NUMBER <> FND_API.G_MISS_CHAR
8228       AND NVL(p_user_in_rec.MASTER_SERIAL_NUMBER,'!!!') <> NVL(p_out_rec.MASTER_SERIAL_NUMBER,'!!!')
8229   THEN
8230        l_attributes := l_attributes || 'MASTER_SERIAL_NUMBER, ';
8231   END IF;
8232 
8233   IF     p_user_in_rec.MAXIMUM_LOAD_WEIGHT <> FND_API.G_MISS_NUM
8234       AND NVL(p_user_in_rec.MAXIMUM_LOAD_WEIGHT,-99) <> NVL(p_out_rec.MAXIMUM_LOAD_WEIGHT,-99)
8235   THEN
8236        l_attributes := l_attributes || 'MAXIMUM_LOAD_WEIGHT, ';
8237   END IF;
8238 
8239   IF     p_user_in_rec.MAXIMUM_VOLUME <> FND_API.G_MISS_NUM
8240       AND NVL(p_user_in_rec.MAXIMUM_VOLUME,-99) <> NVL(p_out_rec.MAXIMUM_VOLUME,-99)
8241   THEN
8242        l_attributes := l_attributes || 'MAXIMUM_VOLUME, ';
8243   END IF;
8244 
8245   IF     p_user_in_rec.MINIMUM_FILL_PERCENT <> FND_API.G_MISS_NUM
8246       AND NVL(p_user_in_rec.MINIMUM_FILL_PERCENT,-99) <> NVL(p_out_rec.MINIMUM_FILL_PERCENT,-99)
8247   THEN
8248        l_attributes := l_attributes || 'MINIMUM_FILL_PERCENT, ';
8249   END IF;
8250 
8251   IF     p_user_in_rec.SEAL_CODE <> FND_API.G_MISS_CHAR
8252       AND NVL(p_user_in_rec.SEAL_CODE,'!!!') <> NVL(p_out_rec.SEAL_CODE,'!!!')
8253   THEN
8254        l_attributes := l_attributes || 'SEAL_CODE, ';
8255   END IF;
8256 
8257   IF     p_user_in_rec.UNIT_NUMBER <> FND_API.G_MISS_CHAR
8258       AND NVL(p_user_in_rec.UNIT_NUMBER,'!!!') <> NVL(p_out_rec.UNIT_NUMBER,'!!!')
8259   THEN
8260        l_attributes := l_attributes || 'UNIT_NUMBER, ';
8261   END IF;
8262 
8263   IF     p_user_in_rec.UNIT_PRICE <> FND_API.G_MISS_NUM
8264       AND NVL(p_user_in_rec.UNIT_PRICE,-99) <> NVL(p_out_rec.UNIT_PRICE,-99)
8265   THEN
8266        l_attributes := l_attributes || 'UNIT_PRICE, ';
8267   END IF;
8268 
8269   IF     p_user_in_rec.CURRENCY_CODE <> FND_API.G_MISS_CHAR
8270       AND NVL(p_user_in_rec.CURRENCY_CODE,'!!!') <> NVL(p_out_rec.CURRENCY_CODE,'!!!')
8271   THEN
8272        l_attributes := l_attributes || 'CURRENCY_CODE, ';
8273   END IF;
8274 
8275   IF     p_user_in_rec.FREIGHT_CLASS_CAT_ID <> FND_API.G_MISS_NUM
8276       AND NVL(p_user_in_rec.FREIGHT_CLASS_CAT_ID,-99) <> NVL(p_out_rec.FREIGHT_CLASS_CAT_ID,-99)
8277   THEN
8278        l_attributes := l_attributes || 'FREIGHT_CLASS_CAT_ID, ';
8279   END IF;
8280 
8281   IF     p_user_in_rec.COMMODITY_CODE_CAT_ID <> FND_API.G_MISS_NUM
8282       AND NVL(p_user_in_rec.COMMODITY_CODE_CAT_ID,-99) <> NVL(p_out_rec.COMMODITY_CODE_CAT_ID,-99)
8283   THEN
8284        l_attributes := l_attributes || 'COMMODITY_CODE_CAT_ID, ';
8285   END IF;
8286 
8287   IF     p_user_in_rec.PREFERRED_GRADE <> FND_API.G_MISS_CHAR
8288       AND NVL(p_user_in_rec.PREFERRED_GRADE,'!!!') <> NVL(p_out_rec.PREFERRED_GRADE,'!!!')
8289   THEN
8290        l_attributes := l_attributes || 'PREFERRED_GRADE, ';
8291   END IF;
8292 
8293   IF     p_user_in_rec.SRC_REQUESTED_QUANTITY2 <> FND_API.G_MISS_NUM
8294       AND NVL(p_user_in_rec.SRC_REQUESTED_QUANTITY2,-99) <> NVL(p_out_rec.SRC_REQUESTED_QUANTITY2,-99)
8295   THEN
8296        l_attributes := l_attributes || 'SRC_REQUESTED_QUANTITY2, ';
8297   END IF;
8298 
8299   IF     p_user_in_rec.SRC_REQUESTED_QUANTITY_UOM2 <> FND_API.G_MISS_CHAR
8300       AND NVL(p_user_in_rec.SRC_REQUESTED_QUANTITY_UOM2,'!!!') <> NVL(p_out_rec.SRC_REQUESTED_QUANTITY_UOM2,'!!!')
8301   THEN
8302        l_attributes := l_attributes || 'SRC_REQUESTED_QUANTITY_UOM2, ';
8303   END IF;
8304 
8305   IF     p_user_in_rec.REQUESTED_QUANTITY2 <> FND_API.G_MISS_NUM
8306       AND NVL(p_user_in_rec.REQUESTED_QUANTITY2,-99) <> NVL(p_out_rec.REQUESTED_QUANTITY2,-99)
8307   THEN
8308        l_attributes := l_attributes || 'REQUESTED_QUANTITY2, ';
8309   END IF;
8310 
8311   IF     p_user_in_rec.SHIPPED_QUANTITY2 <> FND_API.G_MISS_NUM
8312       AND NVL(p_user_in_rec.SHIPPED_QUANTITY2,-99) <> NVL(p_out_rec.SHIPPED_QUANTITY2,-99)
8313   THEN
8314        l_attributes := l_attributes || 'SHIPPED_QUANTITY2, ';
8315   END IF;
8316 
8317   IF     p_user_in_rec.DELIVERED_QUANTITY2 <> FND_API.G_MISS_NUM
8318       AND NVL(p_user_in_rec.DELIVERED_QUANTITY2,-99) <> NVL(p_out_rec.DELIVERED_QUANTITY2,-99)
8319   THEN
8320        l_attributes := l_attributes || 'DELIVERED_QUANTITY2, ';
8321   END IF;
8322 
8323   IF     p_user_in_rec.CANCELLED_QUANTITY2 <> FND_API.G_MISS_NUM
8324       AND NVL(p_user_in_rec.CANCELLED_QUANTITY2,-99) <> NVL(p_out_rec.CANCELLED_QUANTITY2,-99)
8325   THEN
8326        l_attributes := l_attributes || 'CANCELLED_QUANTITY2, ';
8327   END IF;
8328 
8329   IF     p_user_in_rec.QUALITY_CONTROL_QUANTITY2 <> FND_API.G_MISS_NUM
8330       AND NVL(p_user_in_rec.QUALITY_CONTROL_QUANTITY2,-99) <> NVL(p_out_rec.QUALITY_CONTROL_QUANTITY2,-99)
8331   THEN
8332        l_attributes := l_attributes || 'QUALITY_CONTROL_QUANTITY2, ';
8333   END IF;
8334 
8335   IF     p_user_in_rec.CYCLE_COUNT_QUANTITY2 <> FND_API.G_MISS_NUM
8336       AND NVL(p_user_in_rec.CYCLE_COUNT_QUANTITY2,-99) <> NVL(p_out_rec.CYCLE_COUNT_QUANTITY2,-99)
8337   THEN
8338        l_attributes := l_attributes || 'CYCLE_COUNT_QUANTITY2, ';
8339   END IF;
8340 
8341   IF     p_user_in_rec.REQUESTED_QUANTITY_UOM2 <> FND_API.G_MISS_CHAR
8342       AND NVL(p_user_in_rec.REQUESTED_QUANTITY_UOM2,'!!!') <> NVL(p_out_rec.REQUESTED_QUANTITY_UOM2,'!!!')
8343   THEN
8344        l_attributes := l_attributes || 'REQUESTED_QUANTITY_UOM2, ';
8345   END IF;
8346 
8347 -- HW OPMCONV - No need for sublot_number
8348 
8349   IF     p_user_in_rec.LPN_ID <> FND_API.G_MISS_NUM
8350       AND NVL(p_user_in_rec.LPN_ID,-99) <> NVL(p_out_rec.LPN_ID,-99)
8351   THEN
8352        l_attributes := l_attributes || 'LPN_ID, ';
8353   END IF;
8354 
8355   IF     p_user_in_rec.PICKABLE_FLAG <> FND_API.G_MISS_CHAR
8356       AND NVL(p_user_in_rec.PICKABLE_FLAG,'!!!') <> NVL(p_out_rec.PICKABLE_FLAG,'!!!')
8357   THEN
8358        l_attributes := l_attributes || 'PICKABLE_FLAG, ';
8359   END IF;
8360 
8361   IF     p_user_in_rec.ORIGINAL_SUBINVENTORY <> FND_API.G_MISS_CHAR
8362       AND NVL(p_user_in_rec.ORIGINAL_SUBINVENTORY,'!!!') <> NVL(p_out_rec.ORIGINAL_SUBINVENTORY,'!!!')
8363   THEN
8364        l_attributes := l_attributes || 'ORIGINAL_SUBINVENTORY, ';
8365   END IF;
8366 
8367   IF     p_user_in_rec.TO_SERIAL_NUMBER <> FND_API.G_MISS_CHAR
8368       AND NVL(p_user_in_rec.TO_SERIAL_NUMBER,'!!!') <> NVL(p_out_rec.TO_SERIAL_NUMBER,'!!!')
8369   THEN
8370        l_attributes := l_attributes || 'TO_SERIAL_NUMBER, ';
8371   END IF;
8372 
8373   IF     p_user_in_rec.PICKED_QUANTITY <> FND_API.G_MISS_NUM
8374       AND NVL(p_user_in_rec.PICKED_QUANTITY,-99) <> NVL(p_out_rec.PICKED_QUANTITY,-99)
8375   THEN
8376        l_attributes := l_attributes || 'PICKED_QUANTITY, ';
8377   END IF;
8378 
8379   IF     p_user_in_rec.PICKED_QUANTITY2 <> FND_API.G_MISS_NUM
8380       AND NVL(p_user_in_rec.PICKED_QUANTITY2,-99) <> NVL(p_out_rec.PICKED_QUANTITY2,-99)
8381   THEN
8382        l_attributes := l_attributes || 'PICKED_QUANTITY2, ';
8383   END IF;
8384 
8385   IF     p_user_in_rec.RECEIVED_QUANTITY <> FND_API.G_MISS_NUM
8386       AND NVL(p_user_in_rec.RECEIVED_QUANTITY,-99) <> NVL(p_out_rec.RECEIVED_QUANTITY,-99)
8387   THEN
8388        l_attributes := l_attributes || 'RECEIVED_QUANTITY, ';
8389   END IF;
8390 
8391   IF     p_user_in_rec.RECEIVED_QUANTITY2 <> FND_API.G_MISS_NUM
8392       AND NVL(p_user_in_rec.RECEIVED_QUANTITY2,-99) <> NVL(p_out_rec.RECEIVED_QUANTITY2,-99)
8393   THEN
8394        l_attributes := l_attributes || 'RECEIVED_QUANTITY2, ';
8395   END IF;
8396 
8397   IF     p_user_in_rec.SOURCE_LINE_SET_ID <> FND_API.G_MISS_NUM
8398       AND NVL(p_user_in_rec.SOURCE_LINE_SET_ID,-99) <> NVL(p_out_rec.SOURCE_LINE_SET_ID,-99)
8399   THEN
8400        l_attributes := l_attributes || 'SOURCE_LINE_SET_ID, ';
8401   END IF;
8402 
8403   IF     p_user_in_rec.BATCH_ID <> FND_API.G_MISS_NUM
8404       AND NVL(p_user_in_rec.BATCH_ID,-99) <> NVL(p_out_rec.BATCH_ID,-99)
8405   THEN
8406        l_attributes := l_attributes || 'BATCH_ID, ';
8407   END IF;
8408 
8409   IF     p_user_in_rec.ROWID <> FND_API.G_MISS_CHAR
8410       AND NVL(p_user_in_rec.ROWID,'!!!') <> NVL(p_out_rec.ROWID,'!!!')
8411   THEN
8412        l_attributes := l_attributes || 'ROWID, ';
8413   END IF;
8414 
8415   IF     p_user_in_rec.TRANSACTION_ID <> FND_API.G_MISS_NUM
8416       AND NVL(p_user_in_rec.TRANSACTION_ID,-99) <> NVL(p_out_rec.TRANSACTION_ID,-99)
8417   THEN
8418        l_attributes := l_attributes || 'TRANSACTION_ID, ';
8419   END IF;
8420 
8421   IF     p_user_in_rec.VENDOR_ID <> FND_API.G_MISS_NUM
8422       AND NVL(p_user_in_rec.VENDOR_ID,-99) <> NVL(p_out_rec.VENDOR_ID,-99)
8423   THEN
8424        l_attributes := l_attributes || 'VENDOR_ID, ';
8425   END IF;
8426 
8427   IF     p_user_in_rec.SHIP_FROM_SITE_ID <> FND_API.G_MISS_NUM
8428       AND NVL(p_user_in_rec.SHIP_FROM_SITE_ID,-99) <> NVL(p_out_rec.SHIP_FROM_SITE_ID,-99)
8429   THEN
8430        l_attributes := l_attributes || 'SHIP_FROM_SITE_ID, ';
8431   END IF;
8432 
8433   IF     p_user_in_rec.LINE_DIRECTION <> FND_API.G_MISS_CHAR
8434       AND NVL(p_user_in_rec.LINE_DIRECTION,'!!!') <> NVL(p_out_rec.LINE_DIRECTION,'!!!')
8435   THEN
8436        l_attributes := l_attributes || 'LINE_DIRECTION, ';
8437   END IF;
8438 
8439   IF     p_user_in_rec.PARTY_ID <> FND_API.G_MISS_NUM
8440       AND NVL(p_user_in_rec.PARTY_ID,-99) <> NVL(p_out_rec.PARTY_ID,-99)
8441   THEN
8442        l_attributes := l_attributes || 'PARTY_ID, ';
8443   END IF;
8444 
8445   IF     p_user_in_rec.ROUTING_REQ_ID <> FND_API.G_MISS_NUM
8446       AND NVL(p_user_in_rec.ROUTING_REQ_ID,-99) <> NVL(p_out_rec.ROUTING_REQ_ID,-99)
8447   THEN
8448        l_attributes := l_attributes || 'ROUTING_REQ_ID, ';
8449   END IF;
8450 
8451   IF     p_user_in_rec.SHIPPING_CONTROL <> FND_API.G_MISS_CHAR
8452       AND NVL(p_user_in_rec.SHIPPING_CONTROL,'!!!') <> NVL(p_out_rec.SHIPPING_CONTROL,'!!!')
8453   THEN
8454        l_attributes := l_attributes || 'SHIPPING_CONTROL, ';
8455   END IF;
8456 
8457   IF     p_user_in_rec.SOURCE_BLANKET_REFERENCE_ID <> FND_API.G_MISS_NUM
8458       AND NVL(p_user_in_rec.SOURCE_BLANKET_REFERENCE_ID,-99) <> NVL(p_out_rec.SOURCE_BLANKET_REFERENCE_ID,-99)
8459   THEN
8460        l_attributes := l_attributes || 'SOURCE_BLANKET_REFERENCE_ID, ';
8461   END IF;
8462 
8463   IF     p_user_in_rec.SOURCE_BLANKET_REFERENCE_NUM <> FND_API.G_MISS_NUM
8464       AND NVL(p_user_in_rec.SOURCE_BLANKET_REFERENCE_NUM,-99) <> NVL(p_out_rec.SOURCE_BLANKET_REFERENCE_NUM,-99)
8465   THEN
8466        l_attributes := l_attributes || 'SOURCE_BLANKET_REFERENCE_NUM, ';
8467   END IF;
8468 
8469   IF     p_user_in_rec.PO_SHIPMENT_LINE_ID <> FND_API.G_MISS_NUM
8470       AND NVL(p_user_in_rec.PO_SHIPMENT_LINE_ID,-99) <> NVL(p_out_rec.PO_SHIPMENT_LINE_ID,-99)
8471   THEN
8472        l_attributes := l_attributes || 'PO_SHIPMENT_LINE_ID, ';
8473   END IF;
8474 
8475   IF     p_user_in_rec.PO_SHIPMENT_LINE_NUMBER <> FND_API.G_MISS_NUM
8476       AND NVL(p_user_in_rec.PO_SHIPMENT_LINE_NUMBER,-99) <> NVL(p_out_rec.PO_SHIPMENT_LINE_NUMBER,-99)
8477   THEN
8478        l_attributes := l_attributes || 'PO_SHIPMENT_LINE_NUMBER, ';
8479   END IF;
8480 
8481   IF     p_user_in_rec.RETURNED_QUANTITY <> FND_API.G_MISS_NUM
8482       AND NVL(p_user_in_rec.RETURNED_QUANTITY,-99) <> NVL(p_out_rec.RETURNED_QUANTITY,-99)
8483   THEN
8484        l_attributes := l_attributes || 'RETURNED_QUANTITY, ';
8485   END IF;
8486 
8487   IF     p_user_in_rec.RETURNED_QUANTITY2 <> FND_API.G_MISS_NUM
8488       AND NVL(p_user_in_rec.RETURNED_QUANTITY2,-99) <> NVL(p_out_rec.RETURNED_QUANTITY2,-99)
8489   THEN
8490        l_attributes := l_attributes || 'RETURNED_QUANTITY2, ';
8491   END IF;
8492 
8493   IF     p_user_in_rec.RCV_SHIPMENT_LINE_ID <> FND_API.G_MISS_NUM
8494       AND NVL(p_user_in_rec.RCV_SHIPMENT_LINE_ID,-99) <> NVL(p_out_rec.RCV_SHIPMENT_LINE_ID,-99)
8495   THEN
8496        l_attributes := l_attributes || 'RCV_SHIPMENT_LINE_ID, ';
8497   END IF;
8498 
8499   IF     p_user_in_rec.SOURCE_LINE_TYPE_CODE <> FND_API.G_MISS_CHAR
8500       AND NVL(p_user_in_rec.SOURCE_LINE_TYPE_CODE,'!!!') <> NVL(p_out_rec.SOURCE_LINE_TYPE_CODE,'!!!')
8501   THEN
8502        l_attributes := l_attributes || 'SOURCE_LINE_TYPE_CODE, ';
8503   END IF;
8504 
8505   IF     p_user_in_rec.SUPPLIER_ITEM_NUMBER <> FND_API.G_MISS_CHAR
8506       AND NVL(p_user_in_rec.SUPPLIER_ITEM_NUMBER,'!!!') <> NVL(p_out_rec.SUPPLIER_ITEM_NUMBER,'!!!')
8507   THEN
8508        l_attributes := l_attributes || 'SUPPLIER_ITEM_NUMBER, ';
8509   END IF;
8510 
8511   IF     p_user_in_rec.IGNORE_FOR_PLANNING <> FND_API.G_MISS_CHAR
8512       AND NVL(p_user_in_rec.IGNORE_FOR_PLANNING,'!!!') <> NVL(p_out_rec.IGNORE_FOR_PLANNING,'!!!')
8513   THEN
8514        l_attributes := l_attributes || 'IGNORE_FOR_PLANNING, ';
8515   END IF;
8516 
8517   IF     p_user_in_rec.EARLIEST_PICKUP_DATE <> FND_API.G_MISS_DATE
8518       AND NVL(p_user_in_rec.EARLIEST_PICKUP_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.EARLIEST_PICKUP_DATE,TO_DATE('2','j'))
8519   THEN
8520        l_attributes := l_attributes || 'EARLIEST_PICKUP_DATE, ';
8521   END IF;
8522 
8523   IF     p_user_in_rec.LATEST_PICKUP_DATE <> FND_API.G_MISS_DATE
8524       AND NVL(p_user_in_rec.LATEST_PICKUP_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.LATEST_PICKUP_DATE,TO_DATE('2','j'))
8525   THEN
8526        l_attributes := l_attributes || 'LATEST_PICKUP_DATE, ';
8527   END IF;
8528 
8529   IF     p_user_in_rec.EARLIEST_DROPOFF_DATE <> FND_API.G_MISS_DATE
8530       AND NVL(p_user_in_rec.EARLIEST_DROPOFF_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.EARLIEST_DROPOFF_DATE,TO_DATE('2','j'))
8531   THEN
8532        l_attributes := l_attributes || 'EARLIEST_DROPOFF_DATE, ';
8533   END IF;
8534 
8535   IF     p_user_in_rec.LATEST_DROPOFF_DATE <> FND_API.G_MISS_DATE
8536       AND NVL(p_user_in_rec.LATEST_DROPOFF_DATE,TO_DATE('2','j')) <> NVL(p_out_rec.LATEST_DROPOFF_DATE,TO_DATE('2','j'))
8537   THEN
8538        l_attributes := l_attributes || 'LATEST_DROPOFF_DATE, ';
8539   END IF;
8540 
8541   IF     p_user_in_rec.REQUEST_DATE_TYPE_CODE <> FND_API.G_MISS_CHAR
8542       AND NVL(p_user_in_rec.REQUEST_DATE_TYPE_CODE,'!!!') <> NVL(p_out_rec.REQUEST_DATE_TYPE_CODE,'!!!')
8543   THEN
8544        l_attributes := l_attributes || 'REQUEST_DATE_TYPE_CODE, ';
8545   END IF;
8546 
8547   IF     p_user_in_rec.TP_DELIVERY_DETAIL_ID <> FND_API.G_MISS_NUM
8548       AND NVL(p_user_in_rec.TP_DELIVERY_DETAIL_ID,-99) <> NVL(p_out_rec.TP_DELIVERY_DETAIL_ID,-99)
8549   THEN
8550        l_attributes := l_attributes || 'TP_DELIVERY_DETAIL_ID, ';
8551   END IF;
8552 
8553   IF     p_user_in_rec.SOURCE_DOCUMENT_TYPE_ID <> FND_API.G_MISS_NUM
8554       AND NVL(p_user_in_rec.SOURCE_DOCUMENT_TYPE_ID,-99) <> NVL(p_out_rec.SOURCE_DOCUMENT_TYPE_ID,-99)
8555   THEN
8556        l_attributes := l_attributes || 'SOURCE_DOCUMENT_TYPE_ID, ';
8557   END IF;
8558 
8559   IF     p_user_in_rec.UNIT_WEIGHT <> FND_API.G_MISS_NUM
8560       AND NVL(p_user_in_rec.UNIT_WEIGHT,-99) <> NVL(p_out_rec.UNIT_WEIGHT,-99)
8561   THEN
8562        l_attributes := l_attributes || 'UNIT_WEIGHT, ';
8563   END IF;
8564 
8565   IF     p_user_in_rec.UNIT_VOLUME <> FND_API.G_MISS_NUM
8566       AND NVL(p_user_in_rec.UNIT_VOLUME,-99) <> NVL(p_out_rec.UNIT_VOLUME,-99)
8567   THEN
8568        l_attributes := l_attributes || 'UNIT_VOLUME, ';
8569   END IF;
8570 
8571   IF     p_user_in_rec.FILLED_VOLUME <> FND_API.G_MISS_NUM
8572       AND NVL(p_user_in_rec.FILLED_VOLUME,-99) <> NVL(p_out_rec.FILLED_VOLUME,-99)
8573   THEN
8574        l_attributes := l_attributes || 'FILLED_VOLUME, ';
8575   END IF;
8576 
8577   IF     p_user_in_rec.WV_FROZEN_FLAG <> FND_API.G_MISS_CHAR
8578       AND NVL(p_user_in_rec.WV_FROZEN_FLAG,'!!!') <> NVL(p_out_rec.WV_FROZEN_FLAG,'!!!')
8579   THEN
8580        l_attributes := l_attributes || 'WV_FROZEN_FLAG, ';
8581   END IF;
8582 
8583   IF     p_user_in_rec.MODE_OF_TRANSPORT <> FND_API.G_MISS_CHAR
8584       AND NVL(p_user_in_rec.MODE_OF_TRANSPORT,'!!!') <> NVL(p_out_rec.MODE_OF_TRANSPORT,'!!!')
8585   THEN
8586        l_attributes := l_attributes || 'MODE_OF_TRANSPORT, ';
8587   END IF;
8588 
8589   IF     p_user_in_rec.SERVICE_LEVEL <> FND_API.G_MISS_CHAR
8590       AND NVL(p_user_in_rec.SERVICE_LEVEL,'!!!') <> NVL(p_out_rec.SERVICE_LEVEL,'!!!')
8591   THEN
8592        l_attributes := l_attributes || 'SERVICE_LEVEL, ';
8593   END IF;
8594 
8595   IF     p_user_in_rec.PO_REVISION_NUMBER <> FND_API.G_MISS_NUM
8596       AND NVL(p_user_in_rec.PO_REVISION_NUMBER,-99) <> NVL(p_out_rec.PO_REVISION_NUMBER,-99)
8597   THEN
8598        l_attributes := l_attributes || 'PO_REVISION_NUMBER, ';
8599   END IF;
8600 
8601   IF     p_user_in_rec.RELEASE_REVISION_NUMBER <> FND_API.G_MISS_NUM
8602       AND NVL(p_user_in_rec.RELEASE_REVISION_NUMBER,-99) <> NVL(p_out_rec.RELEASE_REVISION_NUMBER,-99)
8603   THEN
8604        l_attributes := l_attributes || 'RELEASE_REVISION_NUMBER, ';
8605   END IF;
8606 
8607 
8608 
8609   IF l_debug_on THEN
8610        WSH_DEBUG_SV.log(l_module_name,'l_attributes',l_attributes);
8611        WSH_DEBUG_SV.log(l_module_name,'length(l_attributes)',length(l_attributes));
8612   END IF;
8613 
8614 
8615   IF l_attributes IS NULL    THEN
8616      --no message to be shown to the user
8617      IF l_debug_on THEN
8618        WSH_DEBUG_SV.pop(l_module_name);
8619      END IF;
8620      RETURN;
8621   ELSE
8622      Wsh_Utilities.process_message(
8623                                    p_entity => 'DLVB',
8624                                    p_entity_name => p_out_rec.DELIVERY_DETAIL_ID,
8625                                    p_attributes => l_attributes,
8626                                    x_return_status => l_return_status
8627                                    );
8628 
8629      IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR,WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR)
8630      THEN
8631        x_return_status := l_return_status;
8632        IF l_debug_on THEN
8633          wsh_debug_sv.logmsg(l_module_name,'Error returned by wsh_utilities.process_message',WSH_DEBUG_SV.C_PROC_LEVEL);
8634          WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
8635          wsh_debug_sv.pop(l_module_name);
8636        END IF;
8637        return;
8638      ELSE
8639        x_return_status := wsh_util_core.G_RET_STS_WARNING;
8640      END IF;
8641   END IF;
8642   --
8643   IF l_debug_on THEN
8644     WSH_DEBUG_SV.pop(l_module_name);
8645   END IF;
8646   --
8647 EXCEPTION
8648     WHEN OTHERS THEN
8649         x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
8650         --
8651         IF l_debug_on THEN
8652            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
8653         END IF;
8654         --
8655 END user_non_updatable_columns;
8656 
8657 -- HW OPMCONV - Added new function to check if line is elibible for split
8658 /*
8659 -----------------------------------------------------------------------------
8660    FUNCTION   : is_split_allowed
8661    PARAMETERS : p_delivery_detail_id - delivery detail id
8662                 p_organization_id    - organization id
8663                 p_inventory_item_id  - inventory item id
8664                 p_released_status    - released status for this wdd line
8665 
8666   DESCRIPTION : This function checks if delivery detail line
8667                 is eligible for a split
8668                 e.g if delivery detail has an item that is lot
8669                 indivisible and it's staged, split actions will not be permitted
8670 ------------------------------------------------------------------------------
8671 */
8672 
8673 FUNCTION is_split_allowed(
8674            p_delivery_detail_id  IN  NUMBER,
8675            p_organization_id     IN  NUMBER,
8676            p_inventory_item_id   IN  NUMBER,
8677            p_released_status     IN  VARCHAR2)
8678 RETURN BOOLEAN
8679 IS
8680 
8681 l_item_info              WSH_DELIVERY_DETAILS_INV.mtl_system_items_rec;
8682 l_released_status VARCHAR2(1);
8683 l_debug_on                    BOOLEAN;
8684 l_return_status VARCHAR2(1);
8685 l_number_of_errors            NUMBER ;
8686 l_number_of_warnings          NUMBER ;
8687 l_source_line_id              NUMBER;
8688 l_exist                       NUMBER ;
8689 no_entry EXCEPTION;
8690 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'is_split_allowed';
8691 
8692  Cursor get_indiv_reservation Is
8693  Select 1
8694  From mtl_reservations
8695  Where demand_source_type_id = 2
8696    and demand_source_line_id = l_source_line_id
8697    and rownum = 1
8698    ;
8699 
8700  BEGIN
8701 
8702 
8703    l_debug_on := wsh_debug_interface.g_debug;
8704    l_exist := 0;
8705    l_number_of_errors   := 0;
8706    l_number_of_warnings := 0;
8707    l_released_status    := p_released_status ;
8708     --
8709     IF l_debug_on IS NULL THEN
8710       l_debug_on := wsh_debug_sv.is_debug_enabled;
8711     END IF;
8712     --
8713     IF l_debug_on THEN
8714       wsh_debug_sv.push(l_module_name);
8715       --
8716       wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_DETAIL_ID', p_delivery_detail_id);
8717       wsh_debug_sv.LOG(l_module_name, 'p_organization_id', p_organization_id);
8718       wsh_debug_sv.LOG(l_module_name, 'p_inventory_item_id', p_inventory_item_id);
8719     END IF;
8720     --
8721 
8722     WSH_DELIVERY_DETAILS_INV.Get_item_information
8723             (
8724                p_organization_id       =>  p_organization_id,
8725                p_inventory_item_id     =>  p_inventory_item_id,
8726                x_mtl_system_items_rec  =>  l_item_info,
8727                x_return_status         =>  l_return_status
8728             );
8729     --
8730     wsh_util_core.api_post_call
8731       (
8732         p_return_status => l_return_status,
8733         x_num_warnings  => l_number_of_warnings,
8734         x_num_errors    => l_number_of_errors
8735       );
8736 
8737     IF ( l_item_info.lot_divisible_flag = 'N' AND
8738          l_item_info.lot_control_code = 2 AND l_released_status ='Y') THEN
8739          IF l_debug_on THEN
8740            wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_divisible_flag', l_item_info.lot_divisible_flag);
8741            wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_control_code', l_item_info.lot_control_code);
8742            wsh_debug_sv.LOG(l_module_name, 'l_released_status', l_released_status);
8743            WSH_DEBUG_SV.pop(l_module_name);
8744          END IF;
8745          return(FALSE);
8746 
8747     ELSE
8748       /* Lgao, bug 5141589, if reservation exists for the line, no split allowed for indivisible items*/
8749       IF ( l_item_info.lot_divisible_flag = 'N' and l_item_info.lot_control_code = 2) THEN
8750         Open get_indiv_reservation;
8751         Fetch get_indiv_reservation into l_exist;
8752         Close get_indiv_reservation;
8753         If l_exist = 1 Then
8754             IF l_debug_on THEN
8755               wsh_debug_sv.LOG(l_module_name, 'lot_divisible_flag', l_item_info.lot_divisible_flag);
8756               wsh_debug_sv.LOG(l_module_name, 'Reservation Exists' );
8757               wsh_debug_sv.LOG(l_module_name, 'Split Not Allowed' );
8758               WSH_DEBUG_SV.pop(l_module_name);
8759             End if;
8760             return(FALSE);
8761         End if;
8762       End if;
8763       IF l_debug_on THEN
8764         wsh_debug_sv.LOG(l_module_name, 'lot_divisible_flag', l_item_info.lot_divisible_flag);
8765         wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_control_code', l_item_info.lot_control_code);
8766         wsh_debug_sv.LOG(l_module_name, 'l_released_status', l_released_status);
8767 
8768         WSH_DEBUG_SV.pop(l_module_name);
8769       END IF;
8770 
8771       return(TRUE);
8772     END IF;
8773 
8774     IF l_debug_on THEN
8775       WSH_DEBUG_SV.pop(l_module_name);
8776     END IF;
8777 
8778     return(TRUE);
8779 
8780 EXCEPTION
8781           WHEN NO_DATA_FOUND THEN
8782 		  -- Debug Statements
8783 		  --
8784        -- CLOSE line_status;
8785           IF l_debug_on THEN
8786 	    WSH_DEBUG_SV.logmsg(l_module_name,'NO_DATA_FOUND exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
8787             WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:NO_DATA_FOUND');
8788           END IF;
8789 		  --
8790 	  return(FALSE);
8791 
8792 	  WHEN others THEN
8793           IF get_indiv_reservation%ISOPEN THEN
8794              Close get_indiv_reservation;
8795           END IF;
8796               --
8797           IF l_debug_on THEN
8798              WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
8799              WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
8800           END IF;
8801 		   --
8802           return(FALSE);
8803 
8804  END is_split_allowed;
8805 
8806 FUNCTION is_cycle_count_allowed(
8807            p_delivery_detail_id  IN  NUMBER,
8808            p_organization_id     IN  NUMBER,
8809            p_inventory_item_id   IN  NUMBER,
8810            p_released_status     IN  VARCHAR2,
8811            p_picked_qty          IN  NUMBER,
8812            p_cycle_qty           IN  NUMBER)
8813 RETURN BOOLEAN
8814 IS
8815 
8816 l_item_info              WSH_DELIVERY_DETAILS_INV.mtl_system_items_rec;
8817 l_released_status VARCHAR2(1);
8818 l_debug_on                    BOOLEAN;
8819 l_return_status VARCHAR2(1);
8820 l_number_of_errors            NUMBER ;
8821 l_number_of_warnings          NUMBER ;
8822 l_picked_qty                  NUMBER;
8823 l_exist                       NUMBER ;
8824 no_entry EXCEPTION;
8825 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'is_cycle_count_allowed';
8826 
8827  BEGIN
8828 
8829 
8830    l_debug_on := wsh_debug_interface.g_debug;
8831    l_exist := 0;
8832    l_number_of_errors   := 0;
8833    l_number_of_warnings := 0;
8834    l_released_status    := p_released_status;
8835    l_picked_qty         := p_picked_qty;
8836     --
8837     IF l_debug_on IS NULL THEN
8838       l_debug_on := wsh_debug_sv.is_debug_enabled;
8839     END IF;
8840     --
8841     IF l_debug_on THEN
8842       wsh_debug_sv.push(l_module_name);
8843       --
8844       wsh_debug_sv.LOG(l_module_name, 'P_DELIVERY_DETAIL_ID', p_delivery_detail_id);
8845       wsh_debug_sv.LOG(l_module_name, 'p_organization_id', p_organization_id);
8846       wsh_debug_sv.LOG(l_module_name, 'p_inventory_item_id', p_inventory_item_id);
8847     END IF;
8848     --
8849 
8850     WSH_DELIVERY_DETAILS_INV.Get_item_information
8851             (
8852                p_organization_id       =>  p_organization_id,
8853                p_inventory_item_id     =>  p_inventory_item_id,
8854                x_mtl_system_items_rec  =>  l_item_info,
8855                x_return_status         =>  l_return_status
8856             );
8857     --
8858     wsh_util_core.api_post_call
8859       (
8860         p_return_status => l_return_status,
8861         x_num_warnings  => l_number_of_warnings,
8862         x_num_errors    => l_number_of_errors
8863       );
8864 
8865     IF ( l_item_info.lot_divisible_flag = 'N' AND p_cycle_qty <> l_picked_qty AND
8866          l_item_info.lot_control_code = 2 AND l_released_status ='Y') THEN
8867          IF l_debug_on THEN
8868            wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_divisible_flag', l_item_info.lot_divisible_flag);
8869            wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_control_code', l_item_info.lot_control_code);
8870            wsh_debug_sv.LOG(l_module_name, 'l_released_status', l_released_status);
8871            WSH_DEBUG_SV.pop(l_module_name);
8872          END IF;
8873          return(FALSE);
8874 
8875     ELSE
8876       IF l_debug_on THEN
8877         wsh_debug_sv.LOG(l_module_name, 'lot_divisible_flag', l_item_info.lot_divisible_flag);
8878         wsh_debug_sv.LOG(l_module_name, 'l_item_info.lot_control_code', l_item_info.lot_control_code);
8879         wsh_debug_sv.LOG(l_module_name, 'l_released_status', l_released_status);
8880 
8881         WSH_DEBUG_SV.pop(l_module_name);
8882       END IF;
8883 
8884       return(TRUE);
8885     END IF;
8886 
8887     IF l_debug_on THEN
8888       WSH_DEBUG_SV.pop(l_module_name);
8889     END IF;
8890 
8891     return(TRUE);
8892 
8893 EXCEPTION
8894           WHEN NO_DATA_FOUND THEN
8895 		  -- Debug Statements
8896 		  --
8897        -- CLOSE line_status;
8898           IF l_debug_on THEN
8899             WSH_DEBUG_SV.logmsg(l_module_name,'NO_DATA_FOUND exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
8900             WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:NO_DATA_FOUND');
8901           END IF;
8902 		  --
8903 	  return(FALSE);
8904 
8905 	  WHEN others THEN
8906           /*IF line_status%ISOPEN THEN
8907              CLOSE line_status;
8908           END IF;
8909           */
8910               --
8911           IF l_debug_on THEN
8912              WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
8913              WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
8914           END IF;
8915 		   --
8916           return(FALSE);
8917 
8918  END is_cycle_count_allowed;
8919 
8920 END WSH_DETAILS_VALIDATIONS;