DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_DEFAULT_LOT_SERIAL

Source


1 PACKAGE BODY OE_Default_Lot_Serial AS
2 /* $Header: OEXDSRLB.pls 120.0 2005/06/01 01:17:08 appldev noship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'OE_Default_Lot_Serial';
7 
8 --  Package global used within the package.
9 
10 g_Lot_Serial_rec              OE_Order_PUB.Lot_Serial_Rec_Type;
11 
12 --  Get functions.
13 
14 FUNCTION Get_From_Serial_Number
15 RETURN VARCHAR2
16 IS
17 --
18 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
19 --
20 BEGIN
21 
22     RETURN NULL;
23 
24 END Get_From_Serial_Number;
25 
26 FUNCTION Get_Line
27 RETURN NUMBER
28 IS
29 --
30 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
31 --
32 BEGIN
33 
34     RETURN NULL;
35 
36 END Get_Line;
37 
38 FUNCTION Get_Line_Set
39 RETURN NUMBER
40 IS
41 l_line_set_id NUMBER;
42 --
43 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
44 --
45 BEGIN
46     SELECT line_set_id
47     INTO l_line_set_id
48     FROM OE_ORDER_LINES
49     WHERE line_id = g_Lot_Serial_rec.line_id;
50 
51     RETURN l_line_set_id;
52 
53 END Get_Line_Set;
54 
55 FUNCTION Get_Lot_Number
56 RETURN VARCHAR2
57 IS
58 --
59 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
60 --
61 BEGIN
62 
63     RETURN NULL;
64 
65 END Get_Lot_Number;
66 
67 
68 /* FUNCTION Get_SubLot_Number --OPM 2380194 -- INVCONV OBSOLETE
69 RETURN VARCHAR2
70 IS
71 BEGIN
72 
73     RETURN NULL;
74 
75 END Get_SubLot_Number; */
76 
77 
78 
79 FUNCTION Get_Lot_Serial
80 RETURN NUMBER
81 IS
82 l_lot_serial_id NUMBER:= NULL;
83 --
84 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
85 --
86 BEGIN
87 
88     SELECT OE_LOT_SERIAL_S.NEXTVAL INTO l_lot_serial_id FROM DUAL;
89     RETURN l_lot_serial_id;
90 
91 END Get_Lot_Serial;
92 
93 FUNCTION Get_Quantity
94 RETURN NUMBER
95 IS
96 
97 -- OPM 3494420
98 
99 CURSOR c_lines ( p_line_id IN NUMBER ) IS
100 
101 		SELECT inventory_item_id,  ship_from_org_id, order_quantity_uom, ordered_quantity_uom2
102 	        FROM OE_ORDER_LINES
103 	       	WHERE line_id = p_line_id;
104 /*CURSOR c_opm_item ( discrete_org_id  IN NUMBER -- INVCONV
105                   , discrete_item_id IN NUMBER) IS
106        SELECT item_id
107             , lot_ctl
108            -- , sublot_ctl INVCONV
109             , dualum_ind
110        FROM  ic_item_mst
111        WHERE delete_mark = 0
112        AND   item_no in (SELECT segment1
113          	FROM mtl_system_items
114      	WHERE organization_id   = discrete_org_id
115           AND   inventory_item_id = discrete_item_id); */
116 
117 /*CURSOR c_opm_lot1 ( opm_item_id in number, -- OPM 3494420
118 		    lot_number in varchar2)  IS
119                     Select lot_id
120 			from ic_lots_mst a where a.lot_id <> 0 and a.delete_mark = 0
121 			and a.item_id = opm_item_id
122 			and a.lot_no =  lot_number; */
123 
124 
125 /*CURSOR c_opm_lot2 ( opm_item_id in number, -- OPM 3494420
126 		    lot_number in varchar2 ) Is
127 		    -- sublot_number in varchar2)  IS INVCONV
128                     Select lot_id
129 			from ic_lots_mst a where a.lot_id <> 0 and a.delete_mark = 0
130 			and a.item_id = opm_item_id
131 			and a.lot_no =  lot_number;
132 			and a.sublot_no = sublot_number; INVCONV */
133 
134 
135 
136   --  l_opm_rma_profile        VARCHAR2(30)   := nvl(fnd_profile.value('GMI_RMA_LOT_RESTRICT'), 'UNRESTRICTED');
137     l_ship_from_org_id       NUMBER;
138     l_inventory_item_id      NUMBER;
139     l_order_quantity_uom     VARCHAR2(3);
140     l_ordered_quantity_uom2  VARCHAR2(3);
141     l_lot_ctl                NUMBER;
142  --   l_sublot_ctl             NUMBER; INVCONV
143     --l_dualum_ind             NUMBER; INVCONV
144     --l_lot_id                 NUMBER; -- INVCONV
145     -- l_item_id	   	     NUMBER; INVCONV
146     l_return	   	     NUMBER;
147     l_quantity               NUMBER;
148     l_quantity2              NUMBER;
149     l_item_rec               OE_ORDER_CACHE.item_rec_type;    -- INVCONV
150     l_return_status          VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
151  -- OPM 3494420
152 UOM_CONVERSION_FAILED  EXCEPTION;             -- INVCONV
153 
154 
155 --
156 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
157 --
158 BEGIN
159 
160 
161 
162 --add code for OPM bug 3494420
163 
164 If ( OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL < '110510'
165 	OR  OE_GLOBALS.G_UI_FLAG = TRUE )
166 	Then
167 		return null;
168 ELSE
169 				IF l_debug_level  > 0 THEN
170         		oe_debug_pub.add(  'Entering OE_Default_Lot_Serial.Get_Quantity' , 1 ) ;
171     		END IF;
172 
173     		begin
174     		OPEN c_lines( g_Lot_Serial_rec.line_id );
175 	               FETCH c_lines
176 	                INTO l_inventory_item_id, l_ship_from_org_id, l_order_quantity_uom, l_ordered_quantity_uom2;
177 
178 	        	IF c_lines%NOTFOUND THEN
179 	                	l_inventory_item_id := 0;
180 	                	l_ship_from_org_id := 0;
181 	                	l_order_quantity_uom := NULL;
182 	                	l_ordered_quantity_uom2 := NULL;
183 					  END IF;
184 		     close c_lines;
185     		 end;
186 
187 		    IF oe_line_util.dual_uom_control -- INVCONV
188   			(l_inventory_item_id,l_ship_from_org_id,l_item_rec)
189   	  	Then
190 
191 				  IF l_debug_level  > 0 THEN
192         			oe_debug_pub.add(  'Dual control RMA - get_quantity defaulting ' , 1 ) ;
193     			END IF;
194     			/* begin
195     			OPEN c_opm_item( l_ship_from_org_id,
196                    			 l_inventory_item_id
197                               );
198 	               FETCH c_opm_item
199 	                INTO l_item_id,
200 		               l_lot_ctl,
201 		               --l_sublot_ctl, INVCONV
202 		               l_dualum_ind
203 		                ;
204 
205 	               IF c_opm_item%NOTFOUND THEN
206 			l_item_id := 0;
207 	                l_lot_ctl := 0;
208 		        --l_sublot_ctl := 0; INVCONV
209 		        l_dualum_ind := NULL;
210 
211 		       END IF;
212 
213 		       Close c_opm_item;
214 
215     		 	end;   */
216 
217     	        IF l_item_rec.tracking_quantity_ind = 'PS' and
218     	          l_item_rec.secondary_default_ind  = 'N'
219     	         THEN      -- INVCONV no default for type 3 - must be supplied.
220     	            return null;
221     	        END IF;
222 
223 		/* get quantity2 or check deviation but if type is 3 then quantity2 MUST be supplied */
224 
225 			-- IF  l_dualum_ind in(1,2) then
226 			  IF l_item_rec.secondary_default_ind  in ('F','D') then     -- INVCONV
227 				l_quantity := g_Lot_Serial_rec.quantity;
228 				l_quantity2 := g_Lot_Serial_rec.quantity2;
229 
230     			/*	--IF  l_lot_ctl = 1
231     				  IF l_item_rec.lot_control_code = 2
232 		          	and ( g_Lot_Serial_rec.lot_number <> FND_API.G_MISS_CHAR
233 		                and g_Lot_Serial_rec.lot_number IS NOT NULL )
234 		          	then
235 		          		begin
236 		               -- 	OPEN c_opm_lot1( l_item_rec.opm_item_id , -- INVCONV TO REVISIT
237  											OPEN c_opm_lot1( l_item_rec.inventory_item_id ,
238                                           g_Lot_Serial_rec.lot_number );
239 
240 	               			FETCH c_opm_lot1 into l_lot_id;
241 
242 	               			IF c_opm_lot1%NOTFOUND THEN
243 	               				IF l_debug_level  > 0 THEN
244 			             			oe_debug_pub.add(  'OPM NO_DATA_FOUND for type 3 tolerance check checking lot number' ) ;
245 			             		END IF;
246 			             		l_lot_id := 0;
247 	               			END IF;
248 
249 		      			Close c_opm_lot1;
250 			                end;
251 
252 		         	end if; */
253 
254 			/*	IF l_sublot_ctl = 1 INVCONV
255 			          and ( g_Lot_Serial_rec.sublot_number <> FND_API.G_MISS_CHAR
256 			                and g_Lot_Serial_rec.sublot_number IS NOT NULL )
257 			          then
258 			               begin
259 			               --OPEN c_opm_lot2( l_item_rec.opm_item_id , -- INVCONV TO REVISIT
260 			               OPEN c_opm_lot1( l_item_rec.inventory_item_id ,
261 	                                          g_lot_serial_rec.lot_number,
262 	                                          g_lot_serial_rec.sublot_number
263 	                                           );
264 
265 	               		       FETCH c_opm_lot2 into l_lot_id;
266 
267 			               IF c_opm_lot2%NOTFOUND THEN
268 			               		IF l_debug_level  > 0 THEN
269 			             			oe_debug_pub.add(  'OPM NO_DATA_FOUND for type 1,2 tolerance check checking sublot number' ) ;
270 			             		END IF;
271 			             		l_lot_id := 0;
272 			               END IF;
273 
274 		      		       Close c_opm_lot2;
275 			               end;
276 
277 				end if; */
278 
279     				  l_quantity := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
280        																								,g_Lot_Serial_rec.lot_number -- INVCONV
281        																								,l_ship_from_org_id -- INVCONV
282                                                       ,5 --NULL
283                                                       ,l_quantity2
284                                                       ,l_ordered_quantity_uom2
285                                                       ,l_order_quantity_uom
286                                                       ,NULL -- From uom name
287                                                       ,NULL -- To uom name
288                                                       );
289 
290 
291   					 IF (l_quantity < 0) THEN    -- OPM B1478461 Start
292    	 							raise UOM_CONVERSION_FAILED;
293   					 END IF;                          -- OPM B1478461 End
294   		       return l_quantity;
295 		         IF l_debug_level  > 0 THEN
296 		      	  		oe_debug_pub.add ('LOT SERIALS -  returning quantity ....');
297 		      	 END IF;
298 
299 
300 
301     				 /*l_quantity := GMI_Reservation_Util.get_opm_converted_qty( INVCONV
302 	              			p_apps_item_id    => l_inventory_item_id,
303 	              			p_organization_id => l_ship_from_org_id,
304 				        p_apps_from_uom   => l_ordered_quantity_uom2,
305 				        p_apps_to_uom     => l_order_quantity_uom ,
306 				        p_original_qty    => l_quantity2,
307 				        p_lot_id          => nvl(l_lot_id, 0) );
308 
309 		                 return l_quantity;
310 		                 IF l_debug_level  > 0 THEN
311 		        		oe_debug_pub.add ('LOT SERIALS -  returning quantity ....');
312 		      		 END IF; */
313 
314 			END IF; -- IF  l_dualum_ind in(1,2) then
315 
316 
317 		else
318 
319 		     RETURN NULL;
320 
321 		END IF; -- IF oe_line_util.dual_uom_control  -- INVCONV
322 
323 	end if;  -- If OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL < '110510' or OE_GLOBALS.G_UI_FLAG = TRUE Then
324 
325 EXCEPTION
326 
327     WHEN UOM_CONVERSION_FAILED THEN -- INVCONV
328 
329     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
330     OE_MSG_PUB.Add;
331     l_return_status := FND_API.G_RET_STS_ERROR;
332 
333     --RAISE FND_API.G_EXC_ERROR; INVCONV
334 
335 
336     WHEN FND_API.G_EXC_ERROR THEN
337 
338         l_return_status := FND_API.G_RET_STS_ERROR;
339 
340     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
341 
342         l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
343 
344     WHEN OTHERS THEN
345 
346         l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
347 
348         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
349         THEN
350             OE_MSG_PUB.Add_Exc_Msg
351             (   G_PKG_NAME
352             ,   'OE_Default_Lot_Serial'
353             );
354         END IF;
355 
356         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
357 
358 IF l_debug_level  > 0 THEN
359         		oe_debug_pub.add(  'RMA exiting OE_Default_Lot_Serial.Get_Quantity' , 1 ) ;
360 END IF;
361 
362 
363 END Get_Quantity;
364 
365 FUNCTION Get_Quantity2 --OPM 2380194 -- PAL UP TO HERE
366 RETURN NUMBER
367 IS
368 -- OPM 3494420
369 CURSOR c_lines ( p_line_id IN NUMBER ) IS
370 
371 		SELECT inventory_item_id,  ship_from_org_id, order_quantity_uom, ordered_quantity_uom2
372 	        FROM OE_ORDER_LINES
373 	       	WHERE line_id = p_line_id;
374 
375 /*CURSOR c_opm_item ( discrete_org_id  IN NUMBER
376                   , discrete_item_id IN NUMBER) IS
377        SELECT item_id
378             , lot_ctl
379            --  , sublot_ctl INVCONV
380             , dualum_ind
381        FROM  ic_item_mst
382        WHERE delete_mark = 0
383        AND   item_no in (SELECT segment1
384          	FROM mtl_system_items
385      	WHERE organization_id   = discrete_org_id
386           AND   inventory_item_id = discrete_item_id);
387 
388 CURSOR c_opm_lot1 ( opm_item_id in number, -- OPM 3494420
389 		    lot_number in varchar2)  IS
390                     Select lot_id
391 			from ic_lots_mst a where a.lot_id <> 0 and a.delete_mark = 0
392 			and a.item_id = opm_item_id
393 			and a.lot_no =  lot_number;
394 
395 
396 CURSOR c_opm_lot2 ( opm_item_id in number, -- OPM 3494420
397 		    lot_number in varchar2 ) is
398 		    -- sublot_number in varchar2)  IS INVCONV
399                     Select lot_id
400 			from ic_lots_mst a where a.lot_id <> 0 and a.delete_mark = 0
401 			and a.item_id = opm_item_id
402 			and a.lot_no =  lot_number;
403 			and a.sublot_no = sublot_number;     INVCONV      */
404 
405     --l_opm_rma_profile        VARCHAR2(30)   := nvl(fnd_profile.value('GMI_RMA_LOT_RESTRICT'), 'UNRESTRICTED'); INVCONV
406     l_ship_from_org_id       NUMBER;
407     l_inventory_item_id      NUMBER;
408     l_order_quantity_uom     VARCHAR2(3);
409     l_ordered_quantity_uom2  VARCHAR2(3);
410     --l_lot_ctl                NUMBER;
411     --l_sublot_ctl             NUMBER; INVCONV
412     --l_dualum_ind             NUMBER;
413     --l_lot_id                 NUMBER;
414     --l_item_id	   	     NUMBER;
415     l_return	   	     NUMBER;
416     l_quantity               NUMBER;
417     l_quantity2              NUMBER;
418     l_item_rec               OE_ORDER_CACHE.item_rec_type;
419     l_return_status          VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
420  -- OPM 3494420
421 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
422 UOM_CONVERSION_FAILED  EXCEPTION;             -- INVCONV
423 
424 BEGIN
425 
426 --add code for OPM bug 3494420
427 
428 If ( OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510'
429 	and OE_GLOBALS.G_UI_FLAG = TRUE )
430 	Then
431 		return null;
432 ELSE
433 		IF l_debug_level  > 0 THEN
434         		oe_debug_pub.add(  'OPM RMA entering OE_Default_Lot_Serial.Get_Quantity2' , 1 ) ;
435     		END IF;
436     		begin
437     		OPEN c_lines( g_Lot_Serial_rec.line_id );
438 	               FETCH c_lines
439 	                INTO l_inventory_item_id, l_ship_from_org_id, l_order_quantity_uom, l_ordered_quantity_uom2;
440 
441 	        	IF c_lines%NOTFOUND THEN
442 	                	l_inventory_item_id := 0;
443 	                	l_ship_from_org_id := 0;
444 	                	l_order_quantity_uom := NULL;
445 	                	l_ordered_quantity_uom2 := NULL;
446 			END IF;
447 		 close c_lines;
448     		 end;
449 
450     IF oe_line_util.dual_uom_control -- INVCONV
451 	  			(l_inventory_item_id,l_ship_from_org_id,l_item_rec)
452   	  	Then
453 
454 					IF l_debug_level  > 0 THEN
455         			oe_debug_pub.add(  'RMA - get_quantity2 defaulting ' , 1 ) ;
456     			END IF;
457 
458     			/* begin -- INVCONV
459     			OPEN c_opm_item( l_ship_from_org_id,
460                    			 l_inventory_item_id
461                               );
462 	               FETCH c_opm_item
463 	                INTO l_item_id,
464 		               l_lot_ctl,
465 		               -- l_sublot_ctl, INVCONV
466 		               l_dualum_ind
467 		                ;
468 
469 	               IF c_opm_item%NOTFOUND THEN
470 			l_item_id := 0;
471 	                l_lot_ctl := 0;
472 		        -- l_sublot_ctl := 0; INVCONV
473 		        l_dualum_ind := NULL;
474 
475 		       END IF;
476     		 	end; */
477 
478     		    	IF l_item_rec.tracking_quantity_ind <> 'PS' or -- INVCONV
479     	          l_item_rec.secondary_default_ind  = 'N'
480     	         THEN      -- INVCONV -- if not dual controlled then return null
481     	            return null;
482     	        END IF;
483 
484 		/* get quantity2 or check deviation but if type is 3 then quantity2 MUST be supplied */
485 
486 			-- INVCONV IF  l_dualum_ind in(1,2) then
487 			IF l_item_rec.secondary_default_ind  in ('F','D') then     -- INVCONV
488 				l_quantity := g_Lot_Serial_rec.quantity;
489 				l_quantity2 := g_Lot_Serial_rec.quantity2;
490 
491     				/* IF  l_lot_ctl = 1
492 		          	and ( g_Lot_Serial_rec.lot_number <> FND_API.G_MISS_CHAR
493 		                and g_Lot_Serial_rec.lot_number IS NOT NULL )
494 		          	then
495 		                	begin
496 		                	--OPEN c_opm_lot1( l_item_rec.opm_item_id , -- invconv to revisit
497 
498 		                	OPEN c_opm_lot1( l_item_rec.inventory_item_id,
499                                           g_Lot_Serial_rec.lot_number );
500 
501 	               			FETCH c_opm_lot1 into l_lot_id;
502 
503 	               			IF c_opm_lot1%NOTFOUND THEN
504 	               				IF l_debug_level  > 0 THEN
505 			             			oe_debug_pub.add(  'OPM NO_DATA_FOUND for type 1,2 tolerance check checking lot number' ) ;
506 			             		END IF;
507 			             		l_lot_id := 0;
508 	               			END IF;
509 
510 		      			Close c_opm_lot1;
511 			                end;
512 
513 		         	end if;    */
514 
515 				/* IF l_sublot_ctl = 1 -- INVCONV
516 			          and ( g_Lot_Serial_rec.sublot_number <> FND_API.G_MISS_CHAR
517 			                and g_Lot_Serial_rec.sublot_number IS NOT NULL )
518 			          then
519 			                begin
520 			               -- OPEN c_opm_lot2( l_item_rec.opm_item_id ,  -- INVCONV TO REVISIT
521 			               OPEN c_opm_lot2(  l_item_rec.inventory_item_id,
522 	                                          g_lot_serial_rec.lot_number,
523 	                                          g_lot_serial_rec.sublot_number
524 	                                           );
525 
526 	               		       FETCH c_opm_lot2 into l_lot_id;
527 
528 			               IF c_opm_lot2%NOTFOUND THEN
529 			               		IF l_debug_level  > 0 THEN
530 			             			oe_debug_pub.add(  'OPM NO_DATA_FOUND for type 1,2 tolerance check checking sublot number' ) ;
531 			             		END IF;
532 			             		l_lot_id := 0;
533 			               END IF;
534 
535 		      		       Close c_opm_lot2;
536 			               end;
537 
538 				end if; */
539 
540     	        l_quantity2 := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
541        																								,g_Lot_Serial_rec.lot_number -- INVCONV
542        																								,l_ship_from_org_id -- INVCONV
543                                                       ,5 --NULL
544                                                       ,l_quantity
545                                                       ,l_order_quantity_uom
546                                                       ,l_ordered_quantity_uom2
547                                                       ,NULL -- From uom name
548                                                       ,NULL -- To uom name
549                                                       );
550 
551 
552   					 IF (l_quantity2 < 0) THEN    -- OPM B1478461 Start
553    	 							raise UOM_CONVERSION_FAILED;
554   					 END IF;                          -- OPM B1478461 End
555   		       return l_quantity2;
556 		         IF l_debug_level  > 0 THEN
557 		      	  		oe_debug_pub.add ('LOT SERIALS -  returning quantity2 =  ' || l_quantity2 );
558 		      	 END IF;
559 
560 
561     			/* 	l_quantity2 := GMI_Reservation_Util.get_opm_converted_qty( -- INVCONV
562 	              			p_apps_item_id    => l_inventory_item_id,
563 	              			p_organization_id => l_ship_from_org_id,
564 				        p_apps_from_uom   => l_order_quantity_uom,
565 				        p_apps_to_uom     => l_ordered_quantity_uom2,
566 				        p_original_qty    => l_quantity,
567 				        p_lot_id          => nvl(l_lot_id, 0) );
568 
569 		                 IF l_debug_level  > 0 THEN
570 		        		oe_debug_pub.add ('OPM LOT SERIALS -  returning quantity2  = ' || l_quantity2 );
571 		      		 END IF;
572 
573 		                 return l_quantity2; */
574 
575 			END IF; -- IF  l_dualum_ind in(1,2,3) then
576 	  ELSE  -- OPM 3610319
577 
578 		   return null;
579 
580 		END IF; -- IF oe_line_util.dual_uom_control -- INVCONV
581 
582 	end if;  -- If OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510' and OE_GLOBALS.G_UI_FLAG = FALSE Then
583 
584 EXCEPTION
585 	WHEN UOM_CONVERSION_FAILED THEN -- INVCONV
586 
587     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
588     OE_MSG_PUB.Add;
589     l_return_status := FND_API.G_RET_STS_ERROR;
590 
591     --RAISE FND_API.G_EXC_ERROR; INVCONV
592 
593     WHEN FND_API.G_EXC_ERROR THEN
594 
595         l_return_status := FND_API.G_RET_STS_ERROR;
596 
597 
598     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
599 
600         l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
601 
602     WHEN OTHERS THEN
603 
604         l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
605 
606         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
607         THEN
608             OE_MSG_PUB.Add_Exc_Msg
609             (   G_PKG_NAME
610             ,   'OE_Default_Lot_Serial'
611             );
612         END IF;
613 
614         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
615 
616 IF l_debug_level  > 0 THEN
617       	oe_debug_pub.add(  'OPM RMA exiting OE_Default_Lot_Serial.Get_Quantity2' , 1 ) ;
618 END IF;
619 
620 
621 END Get_Quantity2;
622 
623 FUNCTION Get_To_Serial_Number
624 RETURN VARCHAR2
625 IS
626 --
627 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
628 --
629 BEGIN
630 
631     RETURN NULL;
632 
633 END Get_To_Serial_Number;
634 
635 PROCEDURE Get_Flex_Lot_Serial
636 IS
637 --
638 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
639 --
640 BEGIN
641 
642     --  In the future call Flex APIs for defaults
643 
644     IF g_Lot_Serial_rec.attribute1 = FND_API.G_MISS_CHAR THEN
645         g_Lot_Serial_rec.attribute1    := NULL;
646     END IF;
647 
648     IF g_Lot_Serial_rec.attribute10 = FND_API.G_MISS_CHAR THEN
649         g_Lot_Serial_rec.attribute10   := NULL;
650     END IF;
651 
652     IF g_Lot_Serial_rec.attribute11 = FND_API.G_MISS_CHAR THEN
653         g_Lot_Serial_rec.attribute11   := NULL;
654     END IF;
655 
656     IF g_Lot_Serial_rec.attribute12 = FND_API.G_MISS_CHAR THEN
657         g_Lot_Serial_rec.attribute12   := NULL;
658     END IF;
659 
660     IF g_Lot_Serial_rec.attribute13 = FND_API.G_MISS_CHAR THEN
661         g_Lot_Serial_rec.attribute13   := NULL;
662     END IF;
663 
664     IF g_Lot_Serial_rec.attribute14 = FND_API.G_MISS_CHAR THEN
665         g_Lot_Serial_rec.attribute14   := NULL;
666     END IF;
667 
668     IF g_Lot_Serial_rec.attribute15 = FND_API.G_MISS_CHAR THEN
669         g_Lot_Serial_rec.attribute15   := NULL;
670     END IF;
671 
672     IF g_Lot_Serial_rec.attribute2 = FND_API.G_MISS_CHAR THEN
673         g_Lot_Serial_rec.attribute2    := NULL;
674     END IF;
675 
676     IF g_Lot_Serial_rec.attribute3 = FND_API.G_MISS_CHAR THEN
677         g_Lot_Serial_rec.attribute3    := NULL;
678     END IF;
679 
680     IF g_Lot_Serial_rec.attribute4 = FND_API.G_MISS_CHAR THEN
681         g_Lot_Serial_rec.attribute4    := NULL;
682     END IF;
683 
684     IF g_Lot_Serial_rec.attribute5 = FND_API.G_MISS_CHAR THEN
685         g_Lot_Serial_rec.attribute5    := NULL;
686     END IF;
687 
688     IF g_Lot_Serial_rec.attribute6 = FND_API.G_MISS_CHAR THEN
689         g_Lot_Serial_rec.attribute6    := NULL;
690     END IF;
691 
692     IF g_Lot_Serial_rec.attribute7 = FND_API.G_MISS_CHAR THEN
693         g_Lot_Serial_rec.attribute7    := NULL;
694     END IF;
695 
696     IF g_Lot_Serial_rec.attribute8 = FND_API.G_MISS_CHAR THEN
697         g_Lot_Serial_rec.attribute8    := NULL;
698     END IF;
699 
700     IF g_Lot_Serial_rec.attribute9 = FND_API.G_MISS_CHAR THEN
701         g_Lot_Serial_rec.attribute9    := NULL;
702     END IF;
703 
704     IF g_Lot_Serial_rec.context = FND_API.G_MISS_CHAR THEN
705         g_Lot_Serial_rec.context       := NULL;
706     END IF;
707 
708 END Get_Flex_Lot_Serial;
709 
710 --  Procedure Attributes
711 
712 PROCEDURE Attributes
713 (   p_x_Lot_Serial_rec              IN OUT NOCOPY  OE_Order_PUB.Lot_Serial_Rec_Type
714 ,   p_iteration                     IN  NUMBER := 1
715 )
716 IS
717 --
718 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
719 --
720 BEGIN
721 
722     IF l_debug_level  > 0 THEN
723         oe_debug_pub.add(  'INSIDE DEFAULTING ATTRIBUTES'||TO_CHAR ( P_X_LOT_SERIAL_REC.QUANTITY ) , 1 ) ;
724     END IF;
725 
726     --  Check number of iterations.
727 
728     IF p_iteration > OE_GLOBALS.G_MAX_DEF_ITERATIONS THEN
729 
730         IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
731         THEN
732 
733             FND_MESSAGE.SET_NAME('OE','OE_DEF_MAX_ITERATION');
734             FND_MSG_PUB.Add;
735 
736         END IF;
737 
738         RAISE FND_API.G_EXC_ERROR;
739 
740     END IF;
741 
742     --  Initialize g_Lot_Serial_rec
743 
744     g_Lot_Serial_rec := p_x_Lot_Serial_rec;
745 
746 
747     --  Default missing attributes.
748 
749     IF g_Lot_Serial_rec.from_serial_number = FND_API.G_MISS_CHAR THEN
750 
751         g_Lot_Serial_rec.from_serial_number := Get_From_Serial_Number;
752 
753         IF g_Lot_Serial_rec.from_serial_number IS NOT NULL THEN
754 
755             IF OE_Validate.From_Serial_Number(g_Lot_Serial_rec.from_serial_number)
756             THEN
757                 OE_Lot_Serial_Util.Clear_Dependent_Attr
758                 (   p_attr_id                     => OE_Lot_Serial_Util.G_FROM_SERIAL_NUMBER
759                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
760                 );
761             ELSE
762                 g_Lot_Serial_rec.from_serial_number := NULL;
763             END IF;
764 
765         END IF;
766 
767     END IF;
768 
769     IF g_Lot_Serial_rec.line_id = FND_API.G_MISS_NUM THEN
770 
771         g_Lot_Serial_rec.line_id := Get_Line;
772 
773         IF g_Lot_Serial_rec.line_id IS NOT NULL THEN
774 
775             IF OE_Validate.Line(g_Lot_Serial_rec.line_id)
776             THEN
777                 OE_Lot_Serial_Util.Clear_Dependent_Attr
778                 (   p_attr_id                     => OE_Lot_Serial_Util.G_LINE
779                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
780                 );
781             ELSE
782                 g_Lot_Serial_rec.line_id := NULL;
783             END IF;
784 
785         END IF;
786 
787     END IF;
788 
789 
790     IF g_Lot_Serial_rec.line_set_id = FND_API.G_MISS_NUM THEN
791 
792         g_Lot_Serial_rec.line_set_id := Get_Line_Set;
793 
794         	IF g_Lot_Serial_rec.line_set_id IS NOT NULL THEN
795         		IF l_debug_level  > 0 THEN
796             			oe_debug_pub.add(  'INSIDE OE_DEFAULT_LOT_SERIAL.ATTRIBUTES g_Lot_Serial_rec.line_set_id IS NOT NULL') ;
797             	        end if;
798 
799             IF OE_Validate.Line_Set(g_Lot_Serial_rec.line_set_id)
800             THEN
801 
802                 OE_Lot_Serial_Util.Clear_Dependent_Attr
803                 (   p_attr_id                     => OE_Lot_Serial_Util.G_LINE_SET
804                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
805                 );
806 
807 
808             ELSE
809 
810                g_Lot_Serial_rec.line_set_id := NULL;
811             END IF;
812 
813         END IF;
814 
815     END IF;
816 
817 
818     IF g_Lot_Serial_rec.lot_number = FND_API.G_MISS_CHAR THEN
819 
820         g_Lot_Serial_rec.lot_number := Get_Lot_Number;
821 
822         IF g_Lot_Serial_rec.lot_number IS NOT NULL THEN
823 
824             IF OE_Validate.Lot_Number(g_Lot_Serial_rec.lot_number)
825             THEN
826                 OE_Lot_Serial_Util.Clear_Dependent_Attr
827                 (   p_attr_id                     => OE_Lot_Serial_Util.G_LOT_NUMBER
828                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
829                 );
830             ELSE
831                 g_Lot_Serial_rec.lot_number := NULL;
832             END IF;
833 
834         END IF;
835 
836     END IF;
837 
838     IF g_Lot_Serial_rec.lot_serial_id = FND_API.G_MISS_NUM THEN
839 
840         g_Lot_Serial_rec.lot_serial_id := Get_Lot_Serial;
841 
842         IF g_Lot_Serial_rec.lot_serial_id IS NOT NULL THEN
843 
844             IF OE_Validate.Lot_Serial(g_Lot_Serial_rec.lot_serial_id)
845             THEN
846                 OE_Lot_Serial_Util.Clear_Dependent_Attr
847                 (   p_attr_id                     => OE_Lot_Serial_Util.G_LOT_SERIAL
848                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
849                 );
850             ELSE
851                 g_Lot_Serial_rec.lot_serial_id := NULL;
852             END IF;
853 
854         END IF;
855 
856     END IF;
857 
858 
859      IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
860 
861    	 THEN
862    	 /*IF g_Lot_Serial_rec.sublot_number = FND_API.G_MISS_CHAR THEN   --OPM 2380194 INVCONV
863 
864         g_Lot_Serial_rec.sublot_number := Get_SubLot_Number;
865 
866         IF g_Lot_Serial_rec.sublot_number IS NOT NULL THEN
867 
868             	IF OE_Validate.SubLot_Number(g_Lot_Serial_rec.sublot_number) -- OPM change to proc sublot
869             	THEN
870 
871                 	OE_Lot_Serial_Util.Clear_Dependent_Attr
872                 	(   p_attr_id                     => OE_Lot_Serial_Util.G_SUBLOT_NUMBER
873                 	,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
874                 	);
875             	ELSE
876 
877                		 g_Lot_Serial_rec.sublot_number := NULL;
878             	END IF; --  IF OE_Validate.SubLot_Number(g_Lot_Serial_rec.sublot_number)
879 
880         END IF; --  IF g_Lot_Serial_rec.sublot_number IS NOT NULL THEN
881 
882     END IF; --   IF g_Lot_Serial_rec.sublot_number = FND_API.G_MISS_CHAR */
883 
884 
885     IF g_Lot_Serial_rec.quantity2 = FND_API.G_MISS_NUM
886     or g_Lot_Serial_rec.quantity2 is NULL
887 
888     THEN --OPM 2380194
889 
890         		IF l_debug_level  > 0 THEN
891         			oe_debug_pub.add(  'OE_DEFAULT_LOT_SERIAL.ATTRIBUTES g_Lot_Serial_rec.quantity2 = FND_API.G_MISS_NUM' ) ;
892     			END IF;
893 			g_Lot_Serial_rec.quantity2 := Get_Quantity2;
894 
895         IF g_Lot_Serial_rec.quantity2 IS NOT NULL THEN
896         	IF l_debug_level  > 0 THEN
897         			oe_debug_pub.add(  'OE_DEFAULT_LOT_SERIAL.ATTRIBUTES - _Lot_Serial_rec.quantity2 IS NOT NULL' ) ;
898     		END IF;
899 
900             IF OE_Validate.Quantity2(g_Lot_Serial_rec.quantity2)
901             THEN
902 
903                 OE_Lot_Serial_Util.Clear_Dependent_Attr
904                 (   p_attr_id                     => OE_Lot_Serial_Util.G_QUANTITY2
905                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
906                 );
907             ELSE
908 
909                 g_Lot_Serial_rec.quantity2 := NULL;
910             END IF; -- IF OE_Validate.Quantity2(g_Lot_Serial_rec.quantity2)
911 
912         END IF; --  IF g_Lot_Serial_rec.quantity2 IS NOT NULL THEN
913 
914     END IF; -- IF g_Lot_Serial_rec.quantity2 = FND_API.G_MISS_NUM THEN --OPM 2380194
915 
916 
917 
918    END IF; -- IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
919 
920 
921     IF g_Lot_Serial_rec.quantity = FND_API.G_MISS_NUM THEN
922 
923         g_Lot_Serial_rec.quantity := Get_Quantity;
924 
925         IF g_Lot_Serial_rec.quantity IS NOT NULL THEN
926 
927             IF OE_Validate.Quantity(g_Lot_Serial_rec.quantity)
928             THEN
929                 OE_Lot_Serial_Util.Clear_Dependent_Attr
930                 (   p_attr_id                     => OE_Lot_Serial_Util.G_QUANTITY
931                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
932                 );
933             ELSE
934                 g_Lot_Serial_rec.quantity := NULL;
935             END IF;
936 
937         END IF;
938 
939     END IF;
940 
941     IF g_Lot_Serial_rec.to_serial_number = FND_API.G_MISS_CHAR THEN
942 
943         g_Lot_Serial_rec.to_serial_number := Get_To_Serial_Number;
944 
945         IF g_Lot_Serial_rec.to_serial_number IS NOT NULL THEN
946 
947             IF OE_Validate.To_Serial_Number(g_Lot_Serial_rec.to_serial_number)
948             THEN
949                 OE_Lot_Serial_Util.Clear_Dependent_Attr
950                 (   p_attr_id                     => OE_Lot_Serial_Util.G_TO_SERIAL_NUMBER
951                 ,   p_x_Lot_Serial_rec              => g_Lot_Serial_rec
952                 );
953             ELSE
954                 g_Lot_Serial_rec.to_serial_number := NULL;
955             END IF;
956 
957         END IF;
958 
959     END IF;
960 
961     IF g_Lot_Serial_rec.attribute1 = FND_API.G_MISS_CHAR
962     OR  g_Lot_Serial_rec.attribute10 = FND_API.G_MISS_CHAR
963     OR  g_Lot_Serial_rec.attribute11 = FND_API.G_MISS_CHAR
964     OR  g_Lot_Serial_rec.attribute12 = FND_API.G_MISS_CHAR
965     OR  g_Lot_Serial_rec.attribute13 = FND_API.G_MISS_CHAR
966     OR  g_Lot_Serial_rec.attribute14 = FND_API.G_MISS_CHAR
967     OR  g_Lot_Serial_rec.attribute15 = FND_API.G_MISS_CHAR
968     OR  g_Lot_Serial_rec.attribute2 = FND_API.G_MISS_CHAR
969     OR  g_Lot_Serial_rec.attribute3 = FND_API.G_MISS_CHAR
970     OR  g_Lot_Serial_rec.attribute4 = FND_API.G_MISS_CHAR
971     OR  g_Lot_Serial_rec.attribute5 = FND_API.G_MISS_CHAR
972     OR  g_Lot_Serial_rec.attribute6 = FND_API.G_MISS_CHAR
973     OR  g_Lot_Serial_rec.attribute7 = FND_API.G_MISS_CHAR
974     OR  g_Lot_Serial_rec.attribute8 = FND_API.G_MISS_CHAR
975     OR  g_Lot_Serial_rec.attribute9 = FND_API.G_MISS_CHAR
976     OR  g_Lot_Serial_rec.context = FND_API.G_MISS_CHAR
977     THEN
978 
979         Get_Flex_Lot_Serial;
980 
981     END IF;
982 
983     IF g_Lot_Serial_rec.created_by = FND_API.G_MISS_NUM THEN
984 
985         g_Lot_Serial_rec.created_by := NULL;
986 
987     END IF;
988 
989     IF g_Lot_Serial_rec.creation_date = FND_API.G_MISS_DATE THEN
990 
991         g_Lot_Serial_rec.creation_date := NULL;
992 
993     END IF;
994 
995     IF g_Lot_Serial_rec.last_updated_by = FND_API.G_MISS_NUM THEN
996 
997         g_Lot_Serial_rec.last_updated_by := NULL;
998 
999     END IF;
1000 
1001     IF g_Lot_Serial_rec.last_update_date = FND_API.G_MISS_DATE THEN
1002 
1003         g_Lot_Serial_rec.last_update_date := NULL;
1004 
1005     END IF;
1006 
1007     IF g_Lot_Serial_rec.last_update_login = FND_API.G_MISS_NUM THEN
1008 
1009         g_Lot_Serial_rec.last_update_login := NULL;
1010 
1011     END IF;
1012 
1013     --  Redefault if there are any missing attributes.
1014 
1015     IF  g_Lot_Serial_rec.attribute1 = FND_API.G_MISS_CHAR
1016     OR  g_Lot_Serial_rec.attribute10 = FND_API.G_MISS_CHAR
1017     OR  g_Lot_Serial_rec.attribute11 = FND_API.G_MISS_CHAR
1018     OR  g_Lot_Serial_rec.attribute12 = FND_API.G_MISS_CHAR
1019     OR  g_Lot_Serial_rec.attribute13 = FND_API.G_MISS_CHAR
1020     OR  g_Lot_Serial_rec.attribute14 = FND_API.G_MISS_CHAR
1021     OR  g_Lot_Serial_rec.attribute15 = FND_API.G_MISS_CHAR
1022     OR  g_Lot_Serial_rec.attribute2 = FND_API.G_MISS_CHAR
1023     OR  g_Lot_Serial_rec.attribute3 = FND_API.G_MISS_CHAR
1024     OR  g_Lot_Serial_rec.attribute4 = FND_API.G_MISS_CHAR
1025     OR  g_Lot_Serial_rec.attribute5 = FND_API.G_MISS_CHAR
1026     OR  g_Lot_Serial_rec.attribute6 = FND_API.G_MISS_CHAR
1027     OR  g_Lot_Serial_rec.attribute7 = FND_API.G_MISS_CHAR
1028     OR  g_Lot_Serial_rec.attribute8 = FND_API.G_MISS_CHAR
1029     OR  g_Lot_Serial_rec.attribute9 = FND_API.G_MISS_CHAR
1030     OR  g_Lot_Serial_rec.context = FND_API.G_MISS_CHAR
1031     OR  g_Lot_Serial_rec.created_by = FND_API.G_MISS_NUM
1032     OR  g_Lot_Serial_rec.creation_date = FND_API.G_MISS_DATE
1033     OR  g_Lot_Serial_rec.from_serial_number = FND_API.G_MISS_CHAR
1034     OR  g_Lot_Serial_rec.last_updated_by = FND_API.G_MISS_NUM
1035     OR  g_Lot_Serial_rec.last_update_date = FND_API.G_MISS_DATE
1036     OR  g_Lot_Serial_rec.last_update_login = FND_API.G_MISS_NUM
1037     OR  g_Lot_Serial_rec.line_id = FND_API.G_MISS_NUM
1038     OR  g_Lot_Serial_rec.lot_number = FND_API.G_MISS_CHAR
1039     --OR  ( g_Lot_Serial_rec.sublot_number = FND_API.G_MISS_CHAR and OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510') --OPM 2380194 INVCONV
1040     OR  g_Lot_Serial_rec.lot_serial_id = FND_API.G_MISS_NUM
1041     OR  g_Lot_Serial_rec.quantity = FND_API.G_MISS_NUM
1042     OR  ( g_Lot_Serial_rec.quantity2 = FND_API.G_MISS_NUM and OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510')     --OPM 2380194
1043     OR  g_Lot_Serial_rec.to_serial_number = FND_API.G_MISS_CHAR
1044     OR  g_Lot_Serial_rec.line_set_id = FND_API.G_MISS_NUM
1045     THEN
1046 
1047         OE_Default_Lot_Serial.Attributes
1048         (   p_x_Lot_Serial_rec            => g_Lot_Serial_rec
1049         ,   p_iteration                   => p_iteration + 1
1050         );
1051 
1052     ELSE
1053 
1054         --  Done defaulting attributes
1055 
1056         p_x_Lot_Serial_rec := g_Lot_Serial_rec;
1057 
1058     END IF;
1059 
1060     /* 1581620 start */
1061 
1062     IF p_x_Lot_Serial_rec.orig_sys_lotserial_ref = FND_API.G_MISS_CHAR THEN
1063 	   p_x_Lot_Serial_rec.orig_sys_lotserial_ref := NULL;
1064     END IF;
1065 
1066     IF p_x_Lot_Serial_rec.lock_control = FND_API.G_MISS_NUM THEN
1067 	   p_x_Lot_Serial_rec.lock_control := NULL;
1068     END IF;
1069 
1070     /* 1581620 end */
1071     /*IF l_debug_level  > 0 THEN
1072         oe_debug_pub.add(  'INSIDE DEFAULTING ATTRIBUTES'||TO_CHAR ( P_X_LOT_SERIAL_REC.QUANTITY ) , 1 ) ;
1073     END IF; */
1074     IF l_debug_level  > 0 THEN
1075         oe_debug_pub.add(  'EXIT OE_DEFAULT_LOT_SERIAL.ATTRIBUTES' ) ;
1076     END IF;
1077 
1078 END Attributes;
1079 
1080 END OE_Default_Lot_Serial;