[Home] [Help]
PACKAGE BODY: APPS.INV_LOT_API_PUB
Source
1 PACKAGE BODY inv_lot_api_pub AS
2 /* $Header: INVPLOTB.pls 120.17.12010000.5 2008/11/18 08:44:41 mporecha ship $ */
3
4 -- Global constant holding the package name
5 g_pkg_name CONSTANT VARCHAR2 ( 30 ) := 'INV_LOT_API_PUB';
6
7
8 /*****************************************************************************
9 Bug - 2181558 Additions Starts
10 1. Added a new 'type' called 'non_wms_lot_att_rec_type' to store the values
11 of Non WMS Attributes
12 2. Added a new 'procedure' called get_lot_att_from_source() to get the
13 WMS and Non WMS Lot Attributes from the Source Lot if the transaction
14 is an Intransit Transaction
15 *****************************************************************************/
16 TYPE non_wms_lot_att_rec_type IS RECORD
17 (
18 attribute_category mtl_lot_numbers.attribute_category%TYPE,
19 attribute1 mtl_lot_numbers.attribute1%TYPE,
20 attribute2 mtl_lot_numbers.attribute2%TYPE,
21 attribute3 mtl_lot_numbers.attribute3%TYPE,
22 attribute4 mtl_lot_numbers.attribute4%TYPE,
23 attribute5 mtl_lot_numbers.attribute5%TYPE,
24 attribute6 mtl_lot_numbers.attribute6%TYPE,
25 attribute7 mtl_lot_numbers.attribute7%TYPE,
26 attribute8 mtl_lot_numbers.attribute8%TYPE,
27 attribute9 mtl_lot_numbers.attribute9%TYPE,
28 attribute10 mtl_lot_numbers.attribute10%TYPE,
29 attribute11 mtl_lot_numbers.attribute11%TYPE,
30 attribute12 mtl_lot_numbers.attribute12%TYPE,
31 attribute13 mtl_lot_numbers.attribute13%TYPE,
32 attribute14 mtl_lot_numbers.attribute14%TYPE,
33 attribute15 mtl_lot_numbers.attribute15%TYPE
34 );
35
36 PROCEDURE get_lot_att_from_source (
37 x_return_status OUT NOCOPY VARCHAR2,
38 x_count OUT NOCOPY NUMBER,
39 x_source_wms_lot_att_tbl OUT NOCOPY inv_lot_sel_attr.lot_sel_attributes_tbl_type,
40 x_source_non_wms_lot_att_rec OUT NOCOPY non_wms_lot_att_rec_type,
41 p_from_organization_id IN NUMBER,
42 p_inventory_item_id IN NUMBER,
43 p_lot_number IN VARCHAR2,
44 p_count IN NUMBER,
45 p_source_wms_lot_att_tbl IN inv_lot_sel_attr.lot_sel_attributes_tbl_type
46 );
47
48 /********************** Bug - 2181558 Additions Ends ************************/
49
50
51 PROCEDURE print_debug ( p_err_msg VARCHAR2, p_level NUMBER DEFAULT 1)
52 IS
53 --l_debug number := 1;--NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
54 BEGIN
55 IF (g_debug = 1) THEN
56 inv_mobile_helper_functions.tracelog (
57 p_err_msg => p_err_msg,
58 p_module => 'INV_LOT_API_PUB',
59 p_level => p_level
60 );
61 --DBMS_OUTPUT.PUT_LINE(p_err_msg);
62 END IF;
63 --DBMS_OUTPUT.PUT_LINE(p_err_msg);
64 END print_debug;
65
66 PROCEDURE set_firstscan ( p_firstscan BOOLEAN )
67 IS
68 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
69 BEGIN
70 g_firstscan := p_firstscan;
71 END;
72
73 PROCEDURE populateattributescolumn
74 IS
75 l_column_idx BINARY_INTEGER;
76 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
77 BEGIN
78 g_lot_attributes_tbl ( 1 ).column_name := 'VENDOR_ID';
79 g_lot_attributes_tbl ( 1 ).column_type := 'NUMBER';
80 g_lot_attributes_tbl ( 2 ).column_name := 'GRADE_CODE';
81 g_lot_attributes_tbl ( 2 ).column_type := 'VARCHAR2';
82 g_lot_attributes_tbl ( 3 ).column_name := 'ORIGINATION_DATE';
83 g_lot_attributes_tbl ( 3 ).column_type := 'DATE';
84 g_lot_attributes_tbl ( 4 ).column_name := 'DATE_CODE';
85 g_lot_attributes_tbl ( 4 ).column_type := 'VARCHAR2';
86 g_lot_attributes_tbl ( 5 ).column_name := 'STATUS_ID';
87 g_lot_attributes_tbl ( 5 ).column_type := 'NUMBER';
88 g_lot_attributes_tbl ( 6 ).column_name := 'CHANGE_DATE';
89 g_lot_attributes_tbl ( 6 ).column_type := 'DATE';
90 g_lot_attributes_tbl ( 7 ).column_name := 'AGE';
91 g_lot_attributes_tbl ( 7 ).column_type := 'NUMBER';
92 g_lot_attributes_tbl ( 8 ).column_name := 'RETEST_DATE';
93 g_lot_attributes_tbl ( 8 ).column_type := 'DATE';
94 g_lot_attributes_tbl ( 9 ).column_name := 'MATURITY_DATE';
95 g_lot_attributes_tbl ( 9 ).column_type := 'DATE';
96 g_lot_attributes_tbl ( 10 ).column_name := 'LOT_ATTRIBUTE_CATEGORY';
97 g_lot_attributes_tbl ( 10 ).column_type := 'VARCHAR2';
98 g_lot_attributes_tbl ( 11 ).column_name := 'ITEM_SIZE';
99 g_lot_attributes_tbl ( 11 ).column_type := 'NUMBER';
100 g_lot_attributes_tbl ( 12 ).column_name := 'COLOR';
101 g_lot_attributes_tbl ( 12 ).column_type := 'VARCHAR2';
102 g_lot_attributes_tbl ( 13 ).column_name := 'VOLUME';
103 g_lot_attributes_tbl ( 13 ).column_type := 'NUMBER';
104 g_lot_attributes_tbl ( 14 ).column_name := 'VOLUME_UOM';
105 g_lot_attributes_tbl ( 14 ).column_type := 'VARCHAR2';
106 g_lot_attributes_tbl ( 15 ).column_name := 'PLACE_OF_ORIGIN';
107 g_lot_attributes_tbl ( 15 ).column_type := 'VARCHAR2';
108 g_lot_attributes_tbl ( 16 ).column_name := 'BEST_BY_DATE';
109 g_lot_attributes_tbl ( 16 ).column_type := 'DATE';
110 g_lot_attributes_tbl ( 17 ).column_name := 'LENGTH';
111 g_lot_attributes_tbl ( 17 ).column_type := 'NUMBER';
112 g_lot_attributes_tbl ( 18 ).column_name := 'LENGTH_UOM';
113 g_lot_attributes_tbl ( 18 ).column_type := 'VARCHAR2';
114 g_lot_attributes_tbl ( 19 ).column_name := 'RECYCLED_CONTENT';
115 g_lot_attributes_tbl ( 19 ).column_type := 'NUMBER';
116 g_lot_attributes_tbl ( 20 ).column_name := 'THICKNESS';
117 g_lot_attributes_tbl ( 20 ).column_type := 'NUMBER';
118 g_lot_attributes_tbl ( 21 ).column_name := 'THICKNESS_UOM';
119 g_lot_attributes_tbl ( 21 ).column_type := 'VARCHAR2';
120 g_lot_attributes_tbl ( 22 ).column_name := 'WIDTH';
121 g_lot_attributes_tbl ( 22 ).column_type := 'NUMBER';
122 g_lot_attributes_tbl ( 23 ).column_name := 'WIDTH_UOM';
123 g_lot_attributes_tbl ( 23 ).column_type := 'VARCHAR2';
124 g_lot_attributes_tbl ( 24 ).column_name := 'CURL_WRINKLE_FOLD';
125 g_lot_attributes_tbl ( 24 ).column_type := 'VARCHAR2';
126 g_lot_attributes_tbl ( 25 ).column_name := 'C_ATTRIBUTE1';
127 g_lot_attributes_tbl ( 25 ).column_type := 'VARCHAR2';
128 g_lot_attributes_tbl ( 26 ).column_name := 'C_ATTRIBUTE2';
129 g_lot_attributes_tbl ( 26 ).column_type := 'VARCHAR2';
130 g_lot_attributes_tbl ( 27 ).column_name := 'C_ATTRIBUTE3';
131 g_lot_attributes_tbl ( 27 ).column_type := 'VARCHAR2';
132 g_lot_attributes_tbl ( 28 ).column_name := 'C_ATTRIBUTE4';
133 g_lot_attributes_tbl ( 28 ).column_type := 'VARCHAR2';
134 g_lot_attributes_tbl ( 29 ).column_name := 'C_ATTRIBUTE5';
135 g_lot_attributes_tbl ( 29 ).column_type := 'VARCHAR2';
136 g_lot_attributes_tbl ( 30 ).column_name := 'C_ATTRIBUTE6';
137 g_lot_attributes_tbl ( 30 ).column_type := 'VARCHAR2';
138 g_lot_attributes_tbl ( 31 ).column_name := 'C_ATTRIBUTE7';
139 g_lot_attributes_tbl ( 31 ).column_type := 'VARCHAR2';
140 g_lot_attributes_tbl ( 32 ).column_name := 'C_ATTRIBUTE8';
141 g_lot_attributes_tbl ( 32 ).column_type := 'VARCHAR2';
142 g_lot_attributes_tbl ( 33 ).column_name := 'C_ATTRIBUTE9';
143 g_lot_attributes_tbl ( 33 ).column_type := 'VARCHAR2';
144 g_lot_attributes_tbl ( 34 ).column_name := 'C_ATTRIBUTE10';
145 g_lot_attributes_tbl ( 34 ).column_type := 'VARCHAR2';
146 g_lot_attributes_tbl ( 35 ).column_name := 'C_ATTRIBUTE11';
147 g_lot_attributes_tbl ( 35 ).column_type := 'VARCHAR2';
148 g_lot_attributes_tbl ( 36 ).column_name := 'C_ATTRIBUTE12';
149 g_lot_attributes_tbl ( 36 ).column_type := 'VARCHAR2';
150 g_lot_attributes_tbl ( 37 ).column_name := 'C_ATTRIBUTE13';
151 g_lot_attributes_tbl ( 37 ).column_type := 'VARCHAR2';
152 g_lot_attributes_tbl ( 38 ).column_name := 'C_ATTRIBUTE14';
153 g_lot_attributes_tbl ( 38 ).column_type := 'VARCHAR2';
154 g_lot_attributes_tbl ( 39 ).column_name := 'C_ATTRIBUTE15';
155 g_lot_attributes_tbl ( 39 ).column_type := 'VARCHAR2';
156 g_lot_attributes_tbl ( 40 ).column_name := 'C_ATTRIBUTE16';
157 g_lot_attributes_tbl ( 40 ).column_type := 'VARCHAR2';
158 g_lot_attributes_tbl ( 41 ).column_name := 'C_ATTRIBUTE17';
159 g_lot_attributes_tbl ( 41 ).column_type := 'VARCHAR2';
160 g_lot_attributes_tbl ( 42 ).column_name := 'C_ATTRIBUTE18';
161 g_lot_attributes_tbl ( 42 ).column_type := 'VARCHAR2';
162 g_lot_attributes_tbl ( 43 ).column_name := 'C_ATTRIBUTE19';
163 g_lot_attributes_tbl ( 43 ).column_type := 'VARCHAR2';
164 g_lot_attributes_tbl ( 44 ).column_name := 'C_ATTRIBUTE20';
165 g_lot_attributes_tbl ( 44 ).column_type := 'VARCHAR2';
166 g_lot_attributes_tbl ( 45 ).column_name := 'D_ATTRIBUTE1';
167 g_lot_attributes_tbl ( 45 ).column_type := 'DATE';
168 g_lot_attributes_tbl ( 46 ).column_name := 'D_ATTRIBUTE2';
169 g_lot_attributes_tbl ( 46 ).column_type := 'DATE';
170 g_lot_attributes_tbl ( 47 ).column_name := 'D_ATTRIBUTE3';
171 g_lot_attributes_tbl ( 47 ).column_type := 'DATE';
172 g_lot_attributes_tbl ( 48 ).column_name := 'D_ATTRIBUTE4';
173 g_lot_attributes_tbl ( 48 ).column_type := 'DATE';
174 g_lot_attributes_tbl ( 49 ).column_name := 'D_ATTRIBUTE5';
175 g_lot_attributes_tbl ( 49 ).column_type := 'DATE';
176 g_lot_attributes_tbl ( 50 ).column_name := 'D_ATTRIBUTE6';
177 g_lot_attributes_tbl ( 50 ).column_type := 'DATE';
178 g_lot_attributes_tbl ( 51 ).column_name := 'D_ATTRIBUTE7';
179 g_lot_attributes_tbl ( 51 ).column_type := 'DATE';
180 g_lot_attributes_tbl ( 52 ).column_name := 'D_ATTRIBUTE8';
181 g_lot_attributes_tbl ( 52 ).column_type := 'DATE';
182 g_lot_attributes_tbl ( 53 ).column_name := 'D_ATTRIBUTE9';
183 g_lot_attributes_tbl ( 53 ).column_type := 'DATE';
184 g_lot_attributes_tbl ( 54 ).column_name := 'D_ATTRIBUTE10';
185 g_lot_attributes_tbl ( 54 ).column_type := 'DATE';
186 g_lot_attributes_tbl ( 55 ).column_name := 'N_ATTRIBUTE1';
187 g_lot_attributes_tbl ( 55 ).column_type := 'NUMBER';
188 g_lot_attributes_tbl ( 56 ).column_name := 'N_ATTRIBUTE2';
189 g_lot_attributes_tbl ( 56 ).column_type := 'NUMBER';
190 g_lot_attributes_tbl ( 57 ).column_name := 'N_ATTRIBUTE3';
191 g_lot_attributes_tbl ( 57 ).column_type := 'NUMBER';
192 g_lot_attributes_tbl ( 58 ).column_name := 'N_ATTRIBUTE4';
193 g_lot_attributes_tbl ( 58 ).column_type := 'NUMBER';
194 g_lot_attributes_tbl ( 59 ).column_name := 'N_ATTRIBUTE5';
195 g_lot_attributes_tbl ( 59 ).column_type := 'NUMBER';
196 g_lot_attributes_tbl ( 60 ).column_name := 'N_ATTRIBUTE6';
197 g_lot_attributes_tbl ( 60 ).column_type := 'NUMBER';
198 g_lot_attributes_tbl ( 61 ).column_name := 'N_ATTRIBUTE7';
199 g_lot_attributes_tbl ( 61 ).column_type := 'NUMBER';
200 g_lot_attributes_tbl ( 62 ).column_name := 'N_ATTRIBUTE8';
201 g_lot_attributes_tbl ( 62 ).column_type := 'NUMBER';
202 g_lot_attributes_tbl ( 63 ).column_name := 'N_ATTRIBUTE10';
203 g_lot_attributes_tbl ( 63 ).column_type := 'NUMBER';
204 g_lot_attributes_tbl ( 64 ).column_name := 'SUPPLIER_LOT_NUMBER';
205 g_lot_attributes_tbl ( 64 ).column_type := 'VARCHAR2';
206 g_lot_attributes_tbl ( 65 ).column_name := 'N_ATTRIBUTE9';
207 g_lot_attributes_tbl ( 65 ).column_type := 'NUMBER';
208 g_lot_attributes_tbl ( 66 ).column_name := 'TERRITORY_CODE';
209 g_lot_attributes_tbl ( 66 ).column_type := 'VARCHAR2';
210 -- Added 05/16/2001
211 g_lot_attributes_tbl ( 67 ).column_name := 'VENDOR_NAME';
212 g_lot_attributes_tbl ( 67 ).column_type := 'VARCHAR2';
213 g_lot_attributes_tbl ( 68 ).column_name := 'DESCRIPTION';
214 g_lot_attributes_tbl ( 68 ).column_type := 'VARCHAR2';
215 END;
216
217 PROCEDURE insertlot (
218 p_api_version IN NUMBER,
219 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
220 p_commit IN VARCHAR2 := fnd_api.g_false,
221 p_validation_level IN NUMBER
222 := fnd_api.g_valid_level_full,
223 p_inventory_item_id IN NUMBER,
224 p_organization_id IN NUMBER,
225 p_lot_number IN VARCHAR2,
226 p_expiration_date IN OUT NOCOPY DATE,
227 p_transaction_temp_id IN NUMBER DEFAULT NULL,
228 p_transaction_action_id IN NUMBER DEFAULT NULL,
229 p_transfer_organization_id IN NUMBER DEFAULT NULL,
230 x_object_id OUT NOCOPY NUMBER,
231 x_return_status OUT NOCOPY VARCHAR2,
232 x_msg_count OUT NOCOPY NUMBER,
233 x_msg_data OUT NOCOPY VARCHAR2
234 )
235 IS
236 l_api_version CONSTANT NUMBER := 1.0;
237 l_api_name CONSTANT VARCHAR2 ( 30 ) := 'insertLot';
238 l_lot_control_code NUMBER;
239 l_lotunique NUMBER;
240 l_lotcount NUMBER;
241 l_userid NUMBER;
242 l_loginid NUMBER;
243 l_shelf_life_code NUMBER;
244 l_shelf_life_days NUMBER;
245 l_attributes_default inv_lot_sel_attr.lot_sel_attributes_tbl_type;
246 l_attributes_default_count NUMBER;
247 l_attributes_in inv_lot_sel_attr.lot_sel_attributes_tbl_type;
248 l_column_idx BINARY_INTEGER;
249 l_return_status VARCHAR2 ( 1 );
250 l_msg_data VARCHAR2 ( 2000 );
251 l_msg_count NUMBER;
252 l_input_idx BINARY_INTEGER;
253
254 -- Bug# 1520495
255 l_lot_status_enabled VARCHAR2 ( 1 );
256 l_default_lot_status_id NUMBER := NULL;
257 l_serial_status_enabled VARCHAR2 ( 1 );
258 l_default_serial_status_id NUMBER;
259 l_status_rec inv_material_status_pub.mtl_status_update_rec_type;
260
261 -- Bug 2181558 Variable Declaration Starts
262 l_att_after_source_copy inv_lot_sel_attr.lot_sel_attributes_tbl_type;
263 l_source_non_wms_lot_att_rec non_wms_lot_att_rec_type;
264 l_num_wms_lot_att_copied NUMBER;
265 -- Bug 2181558 Variable Declaration Ends
266 l_dest_status_enabled VARCHAR2(1); --Added bug4066234
267
268 CURSOR lot_temp_csr ( p_lot_number VARCHAR2, p_trx_temp_id NUMBER )
269 IS
270 SELECT TO_CHAR ( vendor_id ),
271 grade_code,
272 fnd_date.date_to_canonical ( origination_date ),
273 date_code,
274 TO_CHAR ( status_id ),
275 fnd_date.date_to_canonical ( change_date ),
276 TO_NUMBER ( age ),
277 fnd_date.date_to_canonical ( retest_date ),
278 fnd_date.date_to_canonical ( maturity_date ),
279 lot_attribute_category,
280 TO_CHAR ( item_size ),
281 color,
282 TO_CHAR ( volume ),
283 volume_uom,
284 place_of_origin,
285 fnd_date.date_to_canonical ( best_by_date ),
286 TO_CHAR ( LENGTH ),
287 length_uom,
288 TO_CHAR ( recycled_content ),
289 TO_CHAR ( thickness ),
290 thickness_uom,
291 TO_CHAR ( width ),
292 width_uom,
293 curl_wrinkle_fold,
294 c_attribute1,
295 c_attribute2,
296 c_attribute3,
297 c_attribute4,
298 c_attribute5,
299 c_attribute6,
300 c_attribute7,
301 c_attribute8,
302 c_attribute9,
303 c_attribute10,
304 c_attribute11,
305 c_attribute12,
306 c_attribute13,
307 c_attribute14,
308 c_attribute15,
309 c_attribute16,
310 c_attribute17,
311 c_attribute18,
312 c_attribute19,
313 c_attribute20,
314 fnd_date.date_to_canonical ( d_attribute1 ),
315 fnd_date.date_to_canonical ( d_attribute2 ),
316 fnd_date.date_to_canonical ( d_attribute3 ),
317 fnd_date.date_to_canonical ( d_attribute4 ),
318 fnd_date.date_to_canonical ( d_attribute5 ),
319 fnd_date.date_to_canonical ( d_attribute6 ),
320 fnd_date.date_to_canonical ( d_attribute7 ),
321 fnd_date.date_to_canonical ( d_attribute8 ),
322 fnd_date.date_to_canonical ( d_attribute9 ),
323 fnd_date.date_to_canonical ( d_attribute10 ),
324 TO_CHAR ( n_attribute1 ),
325 TO_CHAR ( n_attribute2 ),
326 TO_CHAR ( n_attribute3 ),
327 TO_CHAR ( n_attribute4 ),
328 TO_CHAR ( n_attribute5 ),
329 TO_CHAR ( n_attribute6 ),
330 TO_CHAR ( n_attribute7 ),
331 TO_CHAR ( n_attribute8 ),
332 TO_CHAR ( n_attribute10 ),
333 supplier_lot_number,
334 TO_CHAR ( n_attribute9 ),
335 territory_code,
336 vendor_name,
337 description
338 FROM mtl_transaction_lots_temp
339 WHERE lot_number = p_lot_number
340 AND transaction_temp_id = p_trx_temp_id;
341 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
342 BEGIN
343 IF (l_debug = 1) THEN
344 inv_pick_wave_pick_confirm_pub.tracelog ( 'Inside InsertLot API' , 'INV_LOT_API_PUB');
345 END IF;
346 -- Standard Start of API savepoint
347 SAVEPOINT apiinsertlot_apipub;
348
349 -- Standard call to check for call compatibility.
350 IF NOT fnd_api.compatible_api_call ( l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
351 RAISE fnd_api.g_exc_unexpected_error;
352 END IF;
353
354 -- Initialize message list if p_init_msg_list is set to TRUE.
355 IF fnd_api.to_boolean ( p_init_msg_list ) THEN
356 fnd_msg_pub.initialize;
357 END IF;
358
359 -- Initialize API return status to success
360 x_return_status := fnd_api.g_ret_sts_success;
361
362 -- API body
363 IF ( g_firstscan = TRUE AND p_transaction_action_id = 3) THEN
364 x_return_status := fnd_api.g_ret_sts_success;
365 ELSE
366 BEGIN
367 SELECT lot_control_code
368 INTO l_lot_control_code
369 FROM mtl_system_items
370 WHERE inventory_item_id = p_inventory_item_id
371 AND organization_id = p_organization_id;
372
373 IF ( l_lot_control_code = 1 )
374 THEN
375 fnd_message.set_name ('INV' , 'INV_NO_LOT_CONTROL' );
376 fnd_msg_pub.ADD;
377 x_return_status := fnd_api.g_ret_sts_error;
378 RAISE fnd_api.g_exc_unexpected_error;
379 END IF;
380 EXCEPTION
381 WHEN NO_DATA_FOUND
382 THEN
383 IF (l_debug = 1) THEN
384 inv_pick_wave_pick_confirm_pub.tracelog ( 'Exception in LOT_CONTROL_CODE' , 'INV_LOT_API_PUB');
385 END IF;
386 fnd_message.set_name ('INV' , 'INV_INVALID_ITEM' );
387 fnd_msg_pub.ADD;
388 x_return_status := fnd_api.g_ret_sts_error;
389 RAISE fnd_api.g_exc_unexpected_error;
390 END;
391
392 SELECT lot_number_uniqueness
393 INTO l_lotunique
394 FROM mtl_parameters
395 WHERE organization_id = p_organization_id;
396
397 SELECT lot_status_enabled --Added select for bug4066234
398 INTO l_dest_status_enabled
399 FROM mtl_system_items
400 WHERE
401 inventory_item_id=p_inventory_item_id and
402 organization_id=p_organization_id;
403
404 IF ( l_lotunique = 1 ) THEN
405 SELECT COUNT ( 1 )
406 INTO l_lotcount
407 FROM mtl_lot_numbers
408 WHERE inventory_item_id <> p_inventory_item_id
409 AND lot_number = p_lot_number
410 AND NOT EXISTS ( SELECT NULL
411 FROM mtl_lot_numbers lot
412 WHERE lot.lot_number = p_lot_number
413 AND lot.organization_id = p_organization_id
414 AND lot.inventory_item_id = p_inventory_item_id );
415
416 IF ( l_lotcount > 0 ) THEN
417 fnd_message.set_name ('INV' , 'INV_INT_LOTUNIQEXP' );
418 fnd_msg_pub.ADD;
419 x_return_status := fnd_api.g_ret_sts_error;
420 RAISE fnd_api.g_exc_unexpected_error;
421 IF (l_debug = 1) THEN
422 inv_pick_wave_pick_confirm_pub.tracelog ( 'Exception in MTL_LOT_NUMBER' , 'INV_LOT_API_PUB');
423 END IF;
424 END IF;
425 END IF;
426
427 l_lotcount := 0;
428
429 SELECT COUNT ( 1 )
430 INTO l_lotcount
431 FROM mtl_lot_numbers
432 WHERE inventory_item_id = p_inventory_item_id
433 AND organization_id = p_organization_id
434 AND lot_number = p_lot_number;
435
436 IF ( l_lotcount = 0 ) THEN
437 l_userid := fnd_global.user_id;
438 l_loginid := fnd_global.login_id;
439
440 IF ( p_expiration_date IS NULL ) THEN
441 SELECT shelf_life_code,
442 shelf_life_days
443 INTO l_shelf_life_code,
444 l_shelf_life_days
445 FROM mtl_system_items
446 WHERE inventory_item_id = p_inventory_item_id
447 AND organization_id = p_organization_id;
448
449 IF ( l_shelf_life_code = 2 ) THEN
450 SELECT SYSDATE + l_shelf_life_days
451 INTO p_expiration_date
452 FROM DUAL;
453 ELSIF ( l_shelf_life_code = 4 ) THEN
454 fnd_message.set_name ('INV' , 'INV_LOT_EXPREQD' );
455 fnd_msg_pub.ADD;
456 x_return_status := fnd_api.g_ret_sts_error;
457 RAISE fnd_api.g_exc_unexpected_error;
458 END IF;
459 END IF;
460
461 IF (l_debug = 1) THEN
462 inv_pick_wave_pick_confirm_pub.tracelog ( 'Before calling populateattributesColumn' , 'INV_LOT_API_PUB');
463 END IF;
464
465 SELECT mtl_gen_object_id_s.NEXTVAL
466 INTO x_object_id
467 FROM DUAL;
468
469 populateattributescolumn ( );
470 IF (l_debug = 1) THEN
471 inv_pick_wave_pick_confirm_pub.tracelog ( 'After calling populateattributesColumn' , 'INV_LOT_API_PUB');
472 END IF;
473
474 IF ( p_transaction_temp_id IS NOT NULL ) THEN
475 IF (l_debug = 1) THEN
476 inv_pick_wave_pick_confirm_pub.tracelog ( 'p_transaction_temp_id' || p_transaction_temp_id, 'INV_LOT_API_PUB');
477 END IF;
478 OPEN lot_temp_csr ( p_lot_number, p_transaction_temp_id );
479
480 LOOP
481 FETCH lot_temp_csr INTO g_lot_attributes_tbl ( 1 ).column_value,
482 g_lot_attributes_tbl ( 2 ).column_value,
483 g_lot_attributes_tbl ( 3 ).column_value,
484 g_lot_attributes_tbl ( 4 ).column_value,
485 g_lot_attributes_tbl ( 5 ).column_value,
486 g_lot_attributes_tbl ( 6 ).column_value,
487 g_lot_attributes_tbl ( 7 ).column_value,
488 g_lot_attributes_tbl ( 8 ).column_value,
489 g_lot_attributes_tbl ( 9 ).column_value,
490 g_lot_attributes_tbl ( 10 ).column_value,
491 g_lot_attributes_tbl ( 11 ).column_value,
492 g_lot_attributes_tbl ( 12 ).column_value,
493 g_lot_attributes_tbl ( 13 ).column_value,
494 g_lot_attributes_tbl ( 14 ).column_value,
495 g_lot_attributes_tbl ( 15 ).column_value,
496 g_lot_attributes_tbl ( 16 ).column_value,
497 g_lot_attributes_tbl ( 17 ).column_value,
498 g_lot_attributes_tbl ( 18 ).column_value,
499 g_lot_attributes_tbl ( 19 ).column_value,
500 g_lot_attributes_tbl ( 20 ).column_value,
501 g_lot_attributes_tbl ( 21 ).column_value,
502 g_lot_attributes_tbl ( 22 ).column_value,
503 g_lot_attributes_tbl ( 23 ).column_value,
504 g_lot_attributes_tbl ( 24 ).column_value,
505 g_lot_attributes_tbl ( 25 ).column_value,
506 g_lot_attributes_tbl ( 26 ).column_value,
507 g_lot_attributes_tbl ( 27 ).column_value,
508 g_lot_attributes_tbl ( 28 ).column_value,
509 g_lot_attributes_tbl ( 29 ).column_value,
510 g_lot_attributes_tbl ( 30 ).column_value,
511 g_lot_attributes_tbl ( 31 ).column_value,
512 g_lot_attributes_tbl ( 32 ).column_value,
513 g_lot_attributes_tbl ( 33 ).column_value,
514 g_lot_attributes_tbl ( 34 ).column_value,
515 g_lot_attributes_tbl ( 35 ).column_value,
516 g_lot_attributes_tbl ( 36 ).column_value,
517 g_lot_attributes_tbl ( 37 ).column_value,
518 g_lot_attributes_tbl ( 38 ).column_value,
519 g_lot_attributes_tbl ( 39 ).column_value,
520 g_lot_attributes_tbl ( 40 ).column_value,
521 g_lot_attributes_tbl ( 41 ).column_value,
522 g_lot_attributes_tbl ( 42 ).column_value,
523 g_lot_attributes_tbl ( 43 ).column_value,
524 g_lot_attributes_tbl ( 44 ).column_value,
525 g_lot_attributes_tbl ( 45 ).column_value,
526 g_lot_attributes_tbl ( 46 ).column_value,
527 g_lot_attributes_tbl ( 47 ).column_value,
528 g_lot_attributes_tbl ( 48 ).column_value,
529 g_lot_attributes_tbl ( 49 ).column_value,
530 g_lot_attributes_tbl ( 50 ).column_value,
531 g_lot_attributes_tbl ( 51 ).column_value,
532 g_lot_attributes_tbl ( 52 ).column_value,
533 g_lot_attributes_tbl ( 53 ).column_value,
534 g_lot_attributes_tbl ( 54 ).column_value,
535 g_lot_attributes_tbl ( 55 ).column_value,
536 g_lot_attributes_tbl ( 56 ).column_value,
537 g_lot_attributes_tbl ( 57 ).column_value,
538 g_lot_attributes_tbl ( 58 ).column_value,
539 g_lot_attributes_tbl ( 59 ).column_value,
540 g_lot_attributes_tbl ( 60 ).column_value,
541 g_lot_attributes_tbl ( 61 ).column_value,
542 g_lot_attributes_tbl ( 62 ).column_value,
543 g_lot_attributes_tbl ( 63 ).column_value,
544 g_lot_attributes_tbl ( 64 ).column_value,
545 g_lot_attributes_tbl ( 65 ).column_value,
546 g_lot_attributes_tbl ( 66 ).column_value,
547 g_lot_attributes_tbl ( 67 ).column_value,
548 g_lot_attributes_tbl ( 68 ).column_value;
549 EXIT WHEN lot_temp_csr%NOTFOUND;
550 END LOOP;
551
552 CLOSE lot_temp_csr;
553 l_input_idx := 0;
554
555 FOR x IN 1 .. 68
556 LOOP
557 IF ( g_lot_attributes_tbl ( x ).column_value IS NOT NULL ) THEN
558 l_input_idx := l_input_idx + 1;
559 l_attributes_in ( l_input_idx ).column_name := g_lot_attributes_tbl ( x ).column_name;
560 l_attributes_in ( l_input_idx ).column_value := g_lot_attributes_tbl ( x ).column_value;
561 l_attributes_in ( l_input_idx ).column_type := g_lot_attributes_tbl ( x ).column_type;
562 END IF;
563 END LOOP;
564 END IF;
565
566 IF (( p_transaction_action_id IS NOT NULL AND p_transaction_action_id = 3 AND g_firstscan = FALSE)
567 OR ( p_transaction_action_id is not null AND p_transaction_action_id = 12 )) THEN
568 IF (l_debug = 1) THEN
569 inv_pick_wave_pick_confirm_pub.tracelog ( 'Before Insert action_id=3' , 'INV_LOT_API_PUB');
570 END IF;
571 BEGIN
572 select count(*)
573 into l_lotcount
574 From mtl_lot_numbers
575 where organization_id = p_transfer_organization_id
576 and inventory_item_id = p_inventory_item_id
577 and lot_number = p_lot_number;
578
579 if( l_lotcount > 0 ) then
580 INSERT INTO mtl_lot_numbers
581 (
582 inventory_item_id,
583 organization_id,
584 lot_number,
585 last_update_date,
586 last_updated_by,
587 creation_date,
588 created_by,
589 last_update_login,
590 expiration_date,
591 disable_flag,
592 attribute_category,
593 attribute1,
594 attribute2,
595 attribute3,
596 attribute4,
597 attribute5,
598 attribute6,
599 attribute7,
600 attribute8,
601 attribute9,
602 attribute10,
603 attribute11,
604 attribute12,
605 attribute13,
606 attribute14,
607 attribute15,
608 request_id,
609 program_application_id,
610 program_id,
611 program_update_date,
612 gen_object_id,
613 description,
614 vendor_id,
615 grade_code,
616 origination_date,
617 date_code,
618 status_id,
619 change_date,
620 age,
621 retest_date,
622 maturity_date,
623 lot_attribute_category,
624 item_size,
625 color,
626 volume,
627 volume_uom,
628 place_of_origin,
629 best_by_date,
630 LENGTH,
631 length_uom,
632 recycled_content,
633 thickness,
634 thickness_uom,
635 width,
636 width_uom,
637 curl_wrinkle_fold,
638 c_attribute1,
639 c_attribute2,
640 c_attribute3,
641 c_attribute4,
642 c_attribute5,
643 c_attribute6,
644 c_attribute7,
645 c_attribute8,
646 c_attribute9,
647 c_attribute10,
648 c_attribute11,
649 c_attribute12,
650 c_attribute13,
651 c_attribute14,
652 c_attribute15,
653 c_attribute16,
654 c_attribute17,
655 c_attribute18,
656 c_attribute19,
657 c_attribute20,
658 d_attribute1,
659 d_attribute2,
660 d_attribute3,
661 d_attribute4,
662 d_attribute5,
663 d_attribute6,
664 d_attribute7,
665 d_attribute8,
666 d_attribute9,
667 d_attribute10,
668 n_attribute1,
669 n_attribute2,
670 n_attribute3,
671 n_attribute4,
672 n_attribute5,
673 n_attribute6,
674 n_attribute7,
675 n_attribute8,
676 n_attribute9,
677 supplier_lot_number,
678 n_attribute10,
679 territory_code,
680 vendor_name
681 )
682 SELECT inventory_item_id,
683 p_organization_id,
684 p_lot_number,
685 SYSDATE,
686 l_userid,
687 creation_date,
688 created_by,
689 last_update_login,
690 expiration_date,
691 disable_flag,
692 attribute_category,
693 attribute1,
694 attribute2,
695 attribute3,
696 attribute4,
697 attribute5,
698 attribute6,
699 attribute7,
700 attribute8,
701 attribute9,
702 attribute10,
703 attribute11,
704 attribute12,
705 attribute13,
706 attribute14,
707 attribute15,
708 request_id,
709 program_application_id,
710 program_id,
711 program_update_date,
712 x_object_id,
713 description,
714 vendor_id,
715 grade_code,
716 origination_date,
717 date_code,
718 decode(l_dest_status_enabled,'Y',status_id,1), --Added bug4066234,
719 change_date,
720 age,
721 retest_date,
722 maturity_date,
723 lot_attribute_category,
724 item_size,
725 color,
726 volume,
727 volume_uom,
728 place_of_origin,
729 best_by_date,
730 LENGTH,
731 length_uom,
732 recycled_content,
733 thickness,
734 thickness_uom,
735 width,
736 width_uom,
737 curl_wrinkle_fold,
738 c_attribute1,
739 c_attribute2,
740 c_attribute3,
741 c_attribute4,
742 c_attribute5,
743 c_attribute6,
744 c_attribute7,
745 c_attribute8,
746 c_attribute9,
747 c_attribute10,
748 c_attribute11,
749 c_attribute12,
750 c_attribute13,
751 c_attribute14,
752 c_attribute15,
753 c_attribute16,
754 c_attribute17,
755 c_attribute18,
756 c_attribute19,
757 c_attribute20,
758 d_attribute1,
759 d_attribute2,
760 d_attribute3,
761 d_attribute4,
762 d_attribute5,
763 d_attribute6,
764 d_attribute7,
765 d_attribute8,
766 d_attribute9,
767 d_attribute10,
768 n_attribute1,
769 n_attribute2,
770 n_attribute3,
771 n_attribute4,
772 n_attribute5,
773 n_attribute6,
774 n_attribute7,
775 n_attribute8,
776 n_attribute9,
777 supplier_lot_number,
778 n_attribute10,
779 territory_code,
780 vendor_name
781 FROM mtl_lot_numbers
782 WHERE organization_id = p_transfer_organization_id
783 AND inventory_item_id = p_inventory_item_id
784 AND lot_number = p_lot_number
785 AND NOT EXISTS ( SELECT NULL
786 FROM mtl_lot_numbers lot
787 WHERE lot.lot_number = p_lot_number
788 AND lot.organization_id = p_organization_id
789 AND lot.inventory_item_id = p_inventory_item_id );
790 else
791 INSERT INTO mtl_lot_numbers
792 (
793 inventory_item_id,
794 organization_id,
795 lot_number,
796 last_update_date,
797 last_updated_by,
798 creation_date,
799 created_by,
800 last_update_login,
801 expiration_date,
802 request_id,
803 program_application_id,
804 program_id,
805 program_update_date,
806 gen_object_id,
807 description,
808 vendor_id,
809 grade_code,
810 origination_date,
811 date_code,
812 status_id,
813 change_date,
814 age,
815 retest_date,
816 maturity_date,
817 lot_attribute_category,
818 item_size,
819 color,
820 volume,
821 volume_uom,
822 place_of_origin,
823 best_by_date,
824 LENGTH,
825 length_uom,
826 recycled_content,
827 thickness,
828 thickness_uom,
829 width,
830 width_uom,
831 curl_wrinkle_fold,
832 c_attribute1,
833 c_attribute2,
834 c_attribute3,
835 c_attribute4,
836 c_attribute5,
837 c_attribute6,
838 c_attribute7,
839 c_attribute8,
840 c_attribute9,
841 c_attribute10,
842 c_attribute11,
843 c_attribute12,
844 c_attribute13,
845 c_attribute14,
846 c_attribute15,
847 c_attribute16,
848 c_attribute17,
849 c_attribute18,
850 c_attribute19,
851 c_attribute20,
852 d_attribute1,
853 d_attribute2,
854 d_attribute3,
855 d_attribute4,
856 d_attribute5,
857 d_attribute6,
858 d_attribute7,
859 d_attribute8,
860 d_attribute9,
861 d_attribute10,
862 n_attribute1,
863 n_attribute2,
864 n_attribute3,
865 n_attribute4,
866 n_attribute5,
867 n_attribute6,
868 n_attribute7,
869 n_attribute8,
870 n_attribute9,
871 supplier_lot_number,
872 n_attribute10,
873 territory_code,
874 vendor_name
875 )
876 SELECT mmtt.inventory_item_id,
877 p_organization_id,
878 p_lot_number,
879 SYSDATE,
880 l_userid,
881 mtlt.creation_date,
882 mtlt.created_by,
883 mtlt.last_update_login,
884 mtlt.lot_expiration_date,
885 mtlt.request_id,
886 mtlt.program_application_id,
887 mtlt.program_id,
888 mtlt.program_update_date,
889 x_object_id,
890 mtlt.description,
891 mtlt.vendor_id,
892 mtlt.grade_code,
893 mtlt.origination_date,
894 mtlt.date_code,
895 decode(l_dest_status_enabled,'Y',mtlt.status_id,1), --Added bug4066234,
896 mtlt.change_date,
897 mtlt.age,
898 mtlt.retest_date,
899 mtlt.maturity_date,
900 mtlt.lot_attribute_category,
901 mtlt.item_size,
902 mtlt.color,
903 mtlt.volume,
904 mtlt.volume_uom,
905 mtlt.place_of_origin,
906 mtlt.best_by_date,
907 mtlt.LENGTH,
908 mtlt.length_uom,
909 mtlt.recycled_content,
910 mtlt.thickness,
911 mtlt.thickness_uom,
912 mtlt.width,
913 mtlt.width_uom,
914 mtlt.curl_wrinkle_fold,
915 mtlt.c_attribute1,
916 mtlt.c_attribute2,
917 mtlt.c_attribute3,
918 mtlt.c_attribute4,
919 mtlt.c_attribute5,
920 mtlt.c_attribute6,
921 mtlt.c_attribute7,
922 mtlt.c_attribute8,
923 mtlt.c_attribute9,
924 mtlt.c_attribute10,
925 mtlt.c_attribute11,
926 mtlt.c_attribute12,
927 mtlt.c_attribute13,
928 mtlt.c_attribute14,
929 mtlt.c_attribute15,
930 mtlt.c_attribute16,
931 mtlt.c_attribute17,
932 mtlt.c_attribute18,
933 mtlt.c_attribute19,
934 mtlt.c_attribute20,
935 mtlt.d_attribute1,
936 mtlt.d_attribute2,
937 mtlt.d_attribute3,
938 mtlt.d_attribute4,
939 mtlt.d_attribute5,
940 mtlt.d_attribute6,
941 mtlt.d_attribute7,
942 mtlt.d_attribute8,
943 mtlt.d_attribute9,
944 mtlt.d_attribute10,
945 mtlt.n_attribute1,
946 mtlt.n_attribute2,
947 mtlt.n_attribute3,
948 mtlt.n_attribute4,
949 mtlt.n_attribute5,
950 mtlt.n_attribute6,
951 mtlt.n_attribute7,
952 mtlt.n_attribute8,
953 mtlt.n_attribute9,
954 mtlt.supplier_lot_number,
955 mtlt.n_attribute10,
956 mtlt.territory_code,
957 mtlt.vendor_name
958 FROM mtl_transaction_lots_temp mtlt, mtl_material_transactions_temp mmtt
959 WHERE mtlt.transaction_temp_id = p_transaction_temp_id
960 AND mtlt.lot_number = p_lot_number
961 AND mtlt.transaction_temp_id = mmtt.transaction_temp_id
962 AND NOT EXISTS ( SELECT NULL
963 FROM mtl_lot_numbers lot
964 WHERE lot.lot_number = p_lot_number
965 AND lot.organization_id = p_organization_id
966 AND lot.inventory_item_id = p_inventory_item_id );
967
968 end if;
969 EXCEPTION
970 when no_data_found THEN
971 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
972 IF (l_debug = 1) THEN
973 inv_log_util.trace('SQL : ' || substr(sqlerrm, 1, 200), 'INV_LOT_API_PUB','9');
974 inv_log_util.trace('Error in insertLot : ', 'INV_LOT_API_PUB','9');
975 END IF;
976 raise FND_API.G_EXC_UNEXPECTED_ERROR;
977 when others then
978 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
979 IF (l_debug = 1) THEN
980 inv_log_util.trace('SQL : ' || substr(sqlerrm, 1, 200), 'INV_LOT_API_PUB','9');
981 inv_log_util.trace('Error in insertLot : ', 'INV_LOT_API_PUB','9');
982 END IF;
983 raise FND_API.G_EXC_UNEXPECTED_ERROR;
984
985 end;
986
987 -- to prepare to insert the status to status history table for the initial status
988 -- bug 1870120
989 SELECT status_id
990 INTO l_default_lot_status_id
991 FROM mtl_lot_numbers
992 WHERE lot_number = p_lot_number
993 AND organization_id = p_organization_id
994 AND inventory_item_id = p_inventory_item_id;
995
996 IF (l_debug = 1) THEN
997 inv_pick_wave_pick_confirm_pub.tracelog ( 'After Insert action_id=3' , 'INV_LOT_API_PUB');
998 END IF;
999 ELSE -- if transaction_action_id is not 3
1000 /* ---------------------------------------------------------
1001 * call inv_lot_sel_attr.get_default to get the default value
1002 * of the lot attributes
1003 * ---------------------------------------------------------*/
1004 IF ( inv_install.adv_inv_installed ( NULL ) = TRUE ) THEN
1005
1006 IF (l_debug = 1) THEN
1007 inv_pick_wave_pick_confirm_pub.tracelog ( 'Before calling get_default' , 'INV_LOT_API_PUB');
1008 END IF;
1009 inv_lot_sel_attr.get_default (
1010 x_attributes_default => l_attributes_default,
1011 x_attributes_default_count => l_attributes_default_count,
1012 x_return_status => l_return_status,
1013 x_msg_count => l_msg_count,
1014 x_msg_data => l_msg_data,
1015 p_table_name => 'MTL_LOT_NUMBERS',
1016 p_attributes_name => 'Lot Attributes',
1017 p_inventory_item_id => p_inventory_item_id,
1018 p_organization_id => p_organization_id,
1019 p_lot_serial_number => p_lot_number,
1020 p_attributes => l_attributes_in
1021 );
1022 IF (l_debug = 1) THEN
1023 inv_pick_wave_pick_confirm_pub.tracelog ( 'After get_default' , 'INV_LOT_API_PUB');
1024 END IF;
1025
1026 IF ( l_return_status <> fnd_api.g_ret_sts_success ) THEN
1027 IF (l_debug = 1) THEN
1028 inv_pick_wave_pick_confirm_pub.tracelog ( 'exception of get_default' , 'INV_LOT_API_PUB');
1029 END IF;
1030 x_return_status := l_return_status;
1031 RAISE fnd_api.g_exc_unexpected_error;
1032 END IF;
1033
1034 /********************************************************************
1035 Bug 2181558 - Code Starts
1036 To Copy the Lot Attributes from the Start Lot to this Lot
1037 if this is a intransit transfer transaction
1038 Check for Transfer Organization ID being not null will
1039 suffice the fact that it is called only for Intrasit Receipt.
1040 ********************************************************************/
1041 l_source_non_wms_lot_att_rec.attribute_category := NULL;
1042 l_source_non_wms_lot_att_rec.attribute1 := NULL;
1043 l_source_non_wms_lot_att_rec.attribute2 := NULL;
1044 l_source_non_wms_lot_att_rec.attribute3 := NULL;
1045 l_source_non_wms_lot_att_rec.attribute4 := NULL;
1046 l_source_non_wms_lot_att_rec.attribute5 := NULL;
1047 l_source_non_wms_lot_att_rec.attribute6 := NULL;
1048 l_source_non_wms_lot_att_rec.attribute7 := NULL;
1049 l_source_non_wms_lot_att_rec.attribute8 := NULL;
1050 l_source_non_wms_lot_att_rec.attribute9 := NULL;
1051 l_source_non_wms_lot_att_rec.attribute10 := NULL;
1052 l_source_non_wms_lot_att_rec.attribute11 := NULL;
1053 l_source_non_wms_lot_att_rec.attribute12 := NULL;
1054 l_source_non_wms_lot_att_rec.attribute13 := NULL;
1055 l_source_non_wms_lot_att_rec.attribute14 := NULL;
1056 l_source_non_wms_lot_att_rec.attribute15 := NULL;
1057
1058 IF p_transfer_organization_id IS NOT NULL THEN
1059 IF (l_debug = 1) THEN
1060 inv_pick_wave_pick_confirm_pub.tracelog ( 'Before calling get_lot_att_from_source' , 'INV_LOT_API_PUB');
1061 END IF;
1062
1063 get_lot_att_from_source
1064 (
1065 x_return_status => l_return_status,
1066 x_count => l_num_wms_lot_att_copied,
1067 x_source_wms_lot_att_tbl => l_att_after_source_copy,
1068 x_source_non_wms_lot_att_rec => l_source_non_wms_lot_att_rec,
1069 p_from_organization_id => p_transfer_organization_id,
1070 p_inventory_item_id => p_inventory_item_id,
1071 p_lot_number => p_lot_number,
1072 p_count => l_attributes_default_count,
1073 p_source_wms_lot_att_tbl => l_attributes_default
1074 );
1075
1076 IF ( l_return_status <> fnd_api.g_ret_sts_success ) THEN
1077 x_return_status := l_return_status;
1078 RAISE fnd_api.g_exc_unexpected_error;
1079 END IF;
1080
1081 l_attributes_default := l_att_after_source_copy;
1082 l_attributes_default_count := l_num_wms_lot_att_copied;
1083
1084 IF (l_debug = 1) THEN
1085 inv_pick_wave_pick_confirm_pub.tracelog ( 'After calling get_lot_att_from_source' , 'INV_LOT_API_PUB');
1086 END IF;
1087 END IF;
1088
1089 /* Bug 2181558 - Code Ends */
1090
1091 IF ( l_attributes_default_count > 0 )
1092 THEN
1093 FOR i IN 1 .. l_attributes_default_count LOOP
1094 FOR j IN 1 .. g_lot_attributes_tbl.COUNT LOOP
1095 IF (UPPER(l_attributes_default(i).column_name) = UPPER(g_lot_attributes_tbl(j).column_name)) THEN
1096 g_lot_attributes_tbl ( j ).column_value := l_attributes_default ( i ).column_value;
1097 END IF;
1098
1099 EXIT WHEN (UPPER(l_attributes_default(i).column_name) =
1100 UPPER(g_lot_attributes_tbl(j).column_name));
1101 END LOOP;
1102 END LOOP;
1103 END IF;
1104 END IF;
1105
1106
1107 /***********************************************************************
1108 * Comments related to Bug 1520495 fix:
1109 * g_lot_attributes_tbl(5) points to 'STATUS_ID' information. But ,
1110 * 'STATUS_ID' is not part of descriptive flex field columns yet
1111 * for DFF 'Lot Attributes'. So the above code can never find default
1112 * value for 'STATUS_ID' in DFF segment definition. Like 'VENDOR_ID',
1113 * 'STATUS_ID' could be added to DFF columns in future.
1114 * Nevertheless, to fix the bug 1520495, we need to have an application
1115 * logic to get the default value for 'STATUS_ID'. This can be got
1116 * by using API INV_MATERIAL_STATUS_GRP.get_lot_serial_status_control()
1117 * and assigning OUT parameter 'default_lot_status_id' to
1118 * g_lot_attributes_tbl(5).COLUMN_VALUE if OUT parameter
1119 * 'lot_status_enabled' is 'Y'.
1120 ***********************************************************************/
1121 IF (l_debug = 1) THEN
1122 inv_pick_wave_pick_confirm_pub.tracelog ( 'before calling get_lot_Serial_status_control' , 'INV_LOT_API_PUB');
1123 END IF;
1124 inv_material_status_grp.get_lot_serial_status_control (
1125 p_organization_id => p_organization_id,
1126 p_inventory_item_id => p_inventory_item_id,
1127 x_return_status => l_return_status,
1128 x_msg_count => l_msg_count,
1129 x_msg_data => l_msg_data,
1130 x_lot_status_enabled => l_lot_status_enabled,
1131 x_default_lot_status_id => l_default_lot_status_id,
1132 x_serial_status_enabled => l_serial_status_enabled,
1133 x_default_serial_status_id => l_default_serial_status_id
1134 );
1135 IF (l_debug = 1) THEN
1136 inv_pick_wave_pick_confirm_pub.tracelog ( 'After get_lot_Serial_status_control' , 'INV_LOT_API_PUB');
1137 END IF;
1138
1139 IF ( l_return_status <> fnd_api.g_ret_sts_success ) THEN
1140 x_return_status := l_return_status;
1141 RAISE fnd_api.g_exc_unexpected_error;
1142 END IF;
1143
1144 IF ( NVL ( l_lot_status_enabled, 'Y' ) = 'Y' ) THEN
1145 -- For consistency, fill after converting to 'char'
1146 g_lot_attributes_tbl ( 5 ).column_value := TO_CHAR ( l_default_lot_status_id );
1147 END IF;
1148
1149 --print_debug('before get_context_code 20', 4);
1150
1151 /** Populate Lot Attribute Category info. **/
1152 inv_lot_sel_attr.get_context_code
1153 (
1154 g_lot_attributes_tbl ( 10 ).column_value,
1155 p_organization_id,
1156 p_inventory_item_id,
1157 'Lot Attributes'
1158 );
1159 IF (l_debug = 1) THEN
1160 inv_pick_wave_pick_confirm_pub.tracelog ( 'before inserting into mtl_lot_numbers' , 'INV_LOT_API_PUB');
1161 END IF;
1162
1163 --print_debug('after get_context_code 30', 4);
1164
1165 INSERT INTO mtl_lot_numbers
1166 (
1167 inventory_item_id,
1168 organization_id,
1169 lot_number,
1170 last_update_date,
1171 last_updated_by,
1172 creation_date,
1173 created_by,
1174 last_update_login,
1175 expiration_date,
1176 disable_flag,
1177 attribute_category,
1178 attribute1,
1179 attribute2,
1180 attribute3,
1181 attribute4,
1182 attribute5,
1183 attribute6,
1184 attribute7,
1185 attribute8,
1186 attribute9,
1187 attribute10,
1188 attribute11,
1189 attribute12,
1190 attribute13,
1191 attribute14,
1192 attribute15,
1193 request_id,
1194 program_application_id,
1195 program_id,
1196 program_update_date,
1197 gen_object_id,
1198 description,
1199 vendor_id,
1200 grade_code,
1201 origination_date,
1202 date_code,
1203 status_id,
1204 change_date,
1205 age,
1206 retest_date,
1207 maturity_date,
1208 lot_attribute_category,
1209 item_size,
1210 color,
1211 volume,
1212 volume_uom,
1213 place_of_origin,
1214 best_by_date,
1215 LENGTH,
1216 length_uom,
1217 recycled_content,
1218 thickness,
1219 thickness_uom,
1220 width,
1221 width_uom,
1222 curl_wrinkle_fold,
1223 c_attribute1,
1224 c_attribute2,
1225 c_attribute3,
1226 c_attribute4,
1227 c_attribute5,
1228 c_attribute6,
1229 c_attribute7,
1230 c_attribute8,
1231 c_attribute9,
1232 c_attribute10,
1233 c_attribute11,
1234 c_attribute12,
1235 c_attribute13,
1236 c_attribute14,
1237 c_attribute15,
1238 c_attribute16,
1239 c_attribute17,
1240 c_attribute18,
1241 c_attribute19,
1242 c_attribute20,
1243 d_attribute1,
1244 d_attribute2,
1245 d_attribute3,
1246 d_attribute4,
1247 d_attribute5,
1248 d_attribute6,
1249 d_attribute7,
1250 d_attribute8,
1251 d_attribute9,
1252 d_attribute10,
1253 n_attribute1,
1254 n_attribute2,
1255 n_attribute3,
1256 n_attribute4,
1257 n_attribute5,
1258 n_attribute6,
1259 n_attribute7,
1260 n_attribute8,
1261 n_attribute10,
1262 supplier_lot_number,
1263 n_attribute9,
1264 territory_code,
1265 vendor_name
1266 )
1267 VALUES (
1268 p_inventory_item_id,
1269 p_organization_id,
1270 p_lot_number,
1271 SYSDATE,
1272 l_userid,
1273 SYSDATE,
1274 l_userid,
1275 l_loginid,
1276 p_expiration_date,
1277 NULL,
1278 l_source_non_wms_lot_att_rec.attribute_category,
1279 l_source_non_wms_lot_att_rec.attribute1,
1280 l_source_non_wms_lot_att_rec.attribute2,
1281 l_source_non_wms_lot_att_rec.attribute3,
1282 l_source_non_wms_lot_att_rec.attribute4,
1283 l_source_non_wms_lot_att_rec.attribute5,
1284 l_source_non_wms_lot_att_rec.attribute6,
1285 l_source_non_wms_lot_att_rec.attribute7,
1286 l_source_non_wms_lot_att_rec.attribute8,
1287 l_source_non_wms_lot_att_rec.attribute9,
1288 l_source_non_wms_lot_att_rec.attribute10,
1289 l_source_non_wms_lot_att_rec.attribute11,
1290 l_source_non_wms_lot_att_rec.attribute12,
1291 l_source_non_wms_lot_att_rec.attribute13,
1292 l_source_non_wms_lot_att_rec.attribute14,
1293 l_source_non_wms_lot_att_rec.attribute15,
1294 NULL,
1295 NULL,
1296 NULL,
1297 NULL,
1298 x_object_id,
1299 g_lot_attributes_tbl(68).column_value,
1300 TO_NUMBER(g_lot_attributes_tbl(1).column_value),
1301 g_lot_attributes_tbl(2).column_value,
1302 fnd_date.canonical_to_date(g_lot_attributes_tbl(3).column_value),
1303 g_lot_attributes_tbl(4).column_value,
1304 decode(l_dest_status_enabled,'Y',TO_NUMBER(g_lot_attributes_tbl(5).column_value),1), --Added bug 4066234
1305 fnd_date.canonical_to_date (g_lot_attributes_tbl(6).column_value),
1306 TO_NUMBER(g_lot_attributes_tbl(7).column_value),
1307 fnd_date.canonical_to_date(g_lot_attributes_tbl(8).column_value),
1308 fnd_date.canonical_to_date(g_lot_attributes_tbl(9).column_value),
1309 g_lot_attributes_tbl(10).column_value,
1310 TO_NUMBER(g_lot_attributes_tbl(11).column_value),
1311 g_lot_attributes_tbl(12).column_value,
1312 TO_NUMBER(g_lot_attributes_tbl(13).column_value),
1313 g_lot_attributes_tbl(14).column_value,
1314 g_lot_attributes_tbl(15).column_value,
1315 fnd_date.canonical_to_date(g_lot_attributes_tbl(16).column_value),
1316 TO_NUMBER(g_lot_attributes_tbl(17).column_value),
1317 g_lot_attributes_tbl(18).column_value,
1318 TO_NUMBER(g_lot_attributes_tbl(19).column_value),
1319 TO_NUMBER(g_lot_attributes_tbl(20).column_value),
1320 g_lot_attributes_tbl(21).column_value,
1321 TO_NUMBER(g_lot_attributes_tbl(22).column_value),
1322 g_lot_attributes_tbl(23).column_value,
1323 g_lot_attributes_tbl(24).column_value,
1324 g_lot_attributes_tbl(25).column_value,
1325 g_lot_attributes_tbl(26).column_value,
1326 g_lot_attributes_tbl(27).column_value,
1327 g_lot_attributes_tbl(28).column_value,
1328 g_lot_attributes_tbl(29).column_value,
1329 g_lot_attributes_tbl(30).column_value,
1330 g_lot_attributes_tbl(31).column_value,
1331 g_lot_attributes_tbl(32).column_value,
1332 g_lot_attributes_tbl(33).column_value,
1333 g_lot_attributes_tbl(34).column_value,
1334 g_lot_attributes_tbl(35).column_value,
1335 g_lot_attributes_tbl(36).column_value,
1336 g_lot_attributes_tbl(37).column_value,
1337 g_lot_attributes_tbl(38).column_value,
1338 g_lot_attributes_tbl(39).column_value,
1339 g_lot_attributes_tbl(40).column_value,
1340 g_lot_attributes_tbl(41).column_value,
1341 g_lot_attributes_tbl(42).column_value,
1342 g_lot_attributes_tbl(43).column_value,
1343 g_lot_attributes_tbl(44).column_value,
1344 fnd_date.canonical_to_date(g_lot_attributes_tbl(45).column_value),
1345 fnd_date.canonical_to_date(g_lot_attributes_tbl(46).column_value),
1346 fnd_date.canonical_to_date(g_lot_attributes_tbl(47).column_value),
1347 fnd_date.canonical_to_date(g_lot_attributes_tbl(48).column_value),
1348 fnd_date.canonical_to_date(g_lot_attributes_tbl(49).column_value),
1349 fnd_date.canonical_to_date(g_lot_attributes_tbl(50).column_value),
1350 fnd_date.canonical_to_date(g_lot_attributes_tbl(51).column_value),
1351 fnd_date.canonical_to_date(g_lot_attributes_tbl(52).column_value),
1352 fnd_date.canonical_to_date(g_lot_attributes_tbl(53).column_value),
1353 fnd_date.canonical_to_date(g_lot_attributes_tbl(54).column_value),
1354 TO_NUMBER(g_lot_attributes_tbl(55).column_value),
1355 TO_NUMBER(g_lot_attributes_tbl(56).column_value),
1356 TO_NUMBER(g_lot_attributes_tbl(57).column_value),
1357 TO_NUMBER(g_lot_attributes_tbl(58).column_value),
1358 TO_NUMBER(g_lot_attributes_tbl(59).column_value),
1359 TO_NUMBER(g_lot_attributes_tbl(60).column_value),
1360 TO_NUMBER(g_lot_attributes_tbl(61).column_value),
1361 TO_NUMBER(g_lot_attributes_tbl(62).column_value),
1362 TO_NUMBER(g_lot_attributes_tbl(63).column_value),
1363 g_lot_attributes_tbl(64).column_value,
1364 TO_NUMBER(g_lot_attributes_tbl(65).column_value),
1365 g_lot_attributes_tbl(66).column_value,
1366 g_lot_attributes_tbl(67).column_value
1367 );
1368
1369 IF (l_debug = 1) THEN
1370 inv_pick_wave_pick_confirm_pub.tracelog ( 'After inserting the lot' , 'INV_LOT_API_PUB');
1371 END IF;
1372
1373 END IF;
1374
1375 -- insert into status update history table, bug 1870120
1376 IF ( l_default_lot_status_id IS NOT NULL AND l_dest_status_enabled = 'Y' ) THEN -- bug #4201246
1377 l_status_rec.update_method := inv_material_status_pub.g_update_method_auto;
1378 l_status_rec.organization_id := p_organization_id;
1379 l_status_rec.inventory_item_id := p_inventory_item_id;
1380 l_status_rec.lot_number := p_lot_number;
1381 l_status_rec.status_id := l_default_lot_status_id;
1382 l_status_rec.initial_status_flag := 'Y';
1383 inv_material_status_pkg.insert_status_history ( l_status_rec);
1384 IF (l_debug = 1) THEN
1385 inv_pick_wave_pick_confirm_pub.tracelog ( 'after calling insert_status_history' , 'INV_LOT_API_PUB');
1386 END IF;
1387 END IF;
1388
1389 x_return_status := fnd_api.g_ret_sts_success;
1390 ELSE
1391 IF (l_debug = 1) THEN
1392 inv_pick_wave_pick_confirm_pub.tracelog ( 'INV_LOT_EXISTS' , 'INV_LOT_API_PUB');
1393 END IF;
1394 fnd_message.set_name ('INV' , 'INV_LOT_EXISTS' );
1395 fnd_msg_pub.ADD;
1396 --l_return_status := FND_API.G_RET_STS_SUCCESS;
1397 x_return_status := fnd_api.g_ret_sts_success;
1398 END IF;
1399
1400 IF (l_lotcount > 0 AND p_expiration_date IS NOT NULL) THEN
1401
1402 l_userid := fnd_global.user_id;
1403
1404 --Lot exists, but now the user has entered the lot expiration date
1405 IF (l_debug = 1) THEN
1406 inv_pick_wave_pick_confirm_pub.tracelog ('Update the expiration date', 'INV_LOT_API_PUB');
1407 END IF;
1408
1409 UPDATE mtl_lot_numbers
1410 SET expiration_date = p_expiration_date,
1411 last_update_date = SYSDATE,
1412 last_updated_by = l_userid
1413 WHERE inventory_item_id = p_inventory_item_id
1414 AND organization_id = p_organization_id
1415 AND lot_number = p_lot_number
1416 AND expiration_date IS NULL ;
1417
1418 END IF;
1419 END IF;
1420
1421 -- End of API body.
1422 -- Standard check of p_commit.
1423 IF (l_debug = 1) THEN
1424 inv_pick_wave_pick_confirm_pub.tracelog ( 'Inserted the Lot ' || p_lot_number, 'INV_LOT_API_PUB');
1425 END IF;
1426
1427 IF fnd_api.to_boolean ( p_commit ) THEN
1428 COMMIT WORK;
1429 END IF;
1430
1431 -- Standard call to get message count and if count is 1, get message info.
1432 fnd_msg_pub.count_and_get ( p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
1433 --x_return_status := l_return_status;
1434
1435 --print_debug('end insertlot', 4);
1436
1437 EXCEPTION
1438 WHEN OTHERS THEN
1439 IF (l_debug = 1) THEN
1440 inv_pick_wave_pick_confirm_pub.tracelog ( 'Inside the exception ' || p_lot_number, 'INV_LOT_API_PUB');
1441 END IF;
1442 --print_debug('insertlot other exception', 4);
1443
1444 ROLLBACK TO apiinsertlot_apipub;
1445
1446 IF fnd_msg_pub.check_msg_level ( fnd_msg_pub.g_msg_lvl_unexp_error) THEN
1447 fnd_msg_pub.add_exc_msg ('INV_LOT_API_PUB' , 'insertLot' );
1448 END IF;
1449
1450 x_return_status := fnd_api.g_ret_sts_unexp_error;
1451 END insertlot;
1452
1453 PROCEDURE inserttrxlot (
1454 p_api_version IN NUMBER,
1455 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
1456 p_commit IN VARCHAR2 := fnd_api.g_false,
1457 p_validation_level IN NUMBER
1458 := fnd_api.g_valid_level_full,
1459 p_primary_quantity IN NUMBER DEFAULT NULL,
1460 p_transaction_id IN NUMBER,
1461 p_inventory_item_id IN NUMBER,
1462 p_organization_id IN NUMBER,
1463 p_transaction_date IN DATE,
1464 p_transaction_source_id IN NUMBER,
1465 p_transaction_source_name IN VARCHAR2,
1466 p_transaction_source_type_id IN NUMBER,
1467 p_transaction_temp_id IN NUMBER,
1468 p_transaction_action_id IN NUMBER,
1469 p_serial_transaction_id IN NUMBER,
1470 p_lot_number IN VARCHAR2,
1471 x_return_status OUT NOCOPY VARCHAR2,
1472 x_msg_count OUT NOCOPY NUMBER,
1473 x_msg_data OUT NOCOPY VARCHAR2
1474 )
1475 IS
1476 l_attributes_default inv_lot_sel_attr.lot_sel_attributes_tbl_type;
1477 l_attributes_default_count NUMBER;
1478 l_attributes_in inv_lot_sel_attr.lot_sel_attributes_tbl_type;
1479 l_column_idx BINARY_INTEGER;
1480 l_return_status VARCHAR2 ( 1 );
1481 l_msg_data VARCHAR2 ( 2000 );
1482 l_msg_count NUMBER;
1483 l_input_idx BINARY_INTEGER;
1484 l_userid NUMBER;
1485 l_loginid NUMBER;
1486 l_api_version CONSTANT NUMBER := 1.0;
1487 l_api_name CONSTANT VARCHAR2 ( 30 ) := 'insertTrxLot';
1488 l_mmtt_pri_quantity NUMBER := 0;
1489 l_transaction_quantity NUMBER;
1490 l_primary_quantity NUMBER;
1491
1492 CURSOR lot_temp_csr ( p_lot_number VARCHAR2, p_trx_temp_id NUMBER )
1493 IS
1494 SELECT TO_CHAR ( vendor_id ),
1495 grade_code,
1496 fnd_date.date_to_canonical ( origination_date ),
1497 date_code,
1498 TO_CHAR ( status_id ),
1499 fnd_date.date_to_canonical ( change_date ),
1500 TO_NUMBER ( age ),
1501 fnd_date.date_to_canonical ( retest_date ),
1502 fnd_date.date_to_canonical ( maturity_date ),
1503 lot_attribute_category,
1504 TO_CHAR ( item_size ),
1505 color,
1506 TO_CHAR ( volume ),
1507 volume_uom,
1508 place_of_origin,
1509 fnd_date.date_to_canonical ( best_by_date ),
1510 TO_CHAR ( LENGTH ),
1511 length_uom,
1512 TO_CHAR ( recycled_content ),
1513 TO_CHAR ( thickness ),
1514 thickness_uom,
1515 TO_CHAR ( width ),
1516 width_uom,
1517 curl_wrinkle_fold,
1518 c_attribute1,
1519 c_attribute2,
1520 c_attribute3,
1521 c_attribute4,
1522 c_attribute5,
1523 c_attribute6,
1524 c_attribute7,
1525 c_attribute8,
1526 c_attribute9,
1527 c_attribute10,
1528 c_attribute11,
1529 c_attribute12,
1530 c_attribute13,
1531 c_attribute14,
1532 c_attribute15,
1533 c_attribute16,
1534 c_attribute17,
1535 c_attribute18,
1536 c_attribute19,
1537 c_attribute20,
1538 fnd_date.date_to_canonical ( d_attribute1 ),
1539 fnd_date.date_to_canonical ( d_attribute2 ),
1540 fnd_date.date_to_canonical ( d_attribute3 ),
1541 fnd_date.date_to_canonical ( d_attribute4 ),
1542 fnd_date.date_to_canonical ( d_attribute5 ),
1543 fnd_date.date_to_canonical ( d_attribute6 ),
1544 fnd_date.date_to_canonical ( d_attribute7 ),
1545 fnd_date.date_to_canonical ( d_attribute8 ),
1546 fnd_date.date_to_canonical ( d_attribute9 ),
1547 fnd_date.date_to_canonical ( d_attribute10 ),
1548 TO_CHAR ( n_attribute1 ),
1549 TO_CHAR ( n_attribute2 ),
1550 TO_CHAR ( n_attribute3 ),
1551 TO_CHAR ( n_attribute4 ),
1552 TO_CHAR ( n_attribute5 ),
1553 TO_CHAR ( n_attribute6 ),
1554 TO_CHAR ( n_attribute7 ),
1555 TO_CHAR ( n_attribute8 ),
1556 TO_CHAR ( n_attribute10 ),
1557 supplier_lot_number,
1558 TO_CHAR ( n_attribute9 ),
1559 territory_code,
1560 vendor_name
1561 FROM mtl_transaction_lots_temp
1562 WHERE lot_number = p_lot_number
1563 AND transaction_temp_id = p_trx_temp_id;
1564 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1565 BEGIN
1566 -- Standard Start of API savepoint
1567 SAVEPOINT apiinsertlot_apipub;
1568
1569 -- Standard call to check for call compatibility.
1570 IF NOT fnd_api.compatible_api_call (
1571 l_api_version,
1572 p_api_version,
1573 l_api_name,
1574 g_pkg_name
1575 )
1576 THEN
1577 RAISE fnd_api.g_exc_unexpected_error;
1578 END IF;
1579
1580 -- Initialize message list if p_init_msg_list is set to TRUE.
1581 IF fnd_api.to_boolean ( p_init_msg_list )
1582 THEN
1583 fnd_msg_pub.initialize;
1584 END IF;
1585
1586 -- Initialize API return status to success
1587 x_return_status := fnd_api.g_ret_sts_success;
1588 -- API body
1589
1590 if( l_debug = 1 ) then
1591 print_debug('Calling populateattributescolumn()', 10);
1592 print_debug('p_transaction_temp_id is ' || p_transaction_temp_id, 10);
1593 print_debug('p_transaction_action_id is ' || p_transaction_action_id, 10);
1594 if( g_firstScan = false ) then
1595 print_debug('g_firstscan is false', 10);
1596 else
1597 print_debug('g_firstscan is true', 10);
1598 end if;
1599 end if;
1600
1601 populateattributescolumn ( );
1602 l_userid := fnd_global.user_id;
1603 l_loginid := fnd_global.login_id;
1604 l_mmtt_pri_quantity := 0;
1605
1606 IF ( p_primary_quantity IS NOT NULL )
1607 THEN
1608 IF p_primary_quantity < 0
1609 THEN
1610 l_mmtt_pri_quantity := 1;
1611 ELSE
1612 l_mmtt_pri_quantity := 0;
1613 END IF;
1614 ELSE
1615 l_mmtt_pri_quantity := 0;
1616 END IF;
1617
1618 IF ( p_transaction_temp_id IS NOT NULL )
1619 THEN
1620 OPEN lot_temp_csr ( p_lot_number, p_transaction_temp_id );
1621
1622 LOOP
1623 FETCH lot_temp_csr INTO g_lot_attributes_tbl ( 1 ).column_value,
1624 g_lot_attributes_tbl ( 2 ).column_value,
1625 g_lot_attributes_tbl ( 3 ).column_value,
1626 g_lot_attributes_tbl ( 4 ).column_value,
1627 g_lot_attributes_tbl ( 5 ).column_value,
1628 g_lot_attributes_tbl ( 6 ).column_value,
1629 g_lot_attributes_tbl ( 7 ).column_value,
1630 g_lot_attributes_tbl ( 8 ).column_value,
1631 g_lot_attributes_tbl ( 9 ).column_value,
1632 g_lot_attributes_tbl ( 10 ).column_value,
1633 g_lot_attributes_tbl ( 11 ).column_value,
1634 g_lot_attributes_tbl ( 12 ).column_value,
1635 g_lot_attributes_tbl ( 13 ).column_value,
1636 g_lot_attributes_tbl ( 14 ).column_value,
1637 g_lot_attributes_tbl ( 15 ).column_value,
1638 g_lot_attributes_tbl ( 16 ).column_value,
1639 g_lot_attributes_tbl ( 17 ).column_value,
1640 g_lot_attributes_tbl ( 18 ).column_value,
1641 g_lot_attributes_tbl ( 19 ).column_value,
1642 g_lot_attributes_tbl ( 20 ).column_value,
1643 g_lot_attributes_tbl ( 21 ).column_value,
1644 g_lot_attributes_tbl ( 22 ).column_value,
1645 g_lot_attributes_tbl ( 23 ).column_value,
1646 g_lot_attributes_tbl ( 24 ).column_value,
1647 g_lot_attributes_tbl ( 25 ).column_value,
1648 g_lot_attributes_tbl ( 26 ).column_value,
1649 g_lot_attributes_tbl ( 27 ).column_value,
1650 g_lot_attributes_tbl ( 28 ).column_value,
1651 g_lot_attributes_tbl ( 29 ).column_value,
1652 g_lot_attributes_tbl ( 30 ).column_value,
1653 g_lot_attributes_tbl ( 31 ).column_value,
1654 g_lot_attributes_tbl ( 32 ).column_value,
1655 g_lot_attributes_tbl ( 33 ).column_value,
1656 g_lot_attributes_tbl ( 34 ).column_value,
1657 g_lot_attributes_tbl ( 35 ).column_value,
1658 g_lot_attributes_tbl ( 36 ).column_value,
1659 g_lot_attributes_tbl ( 37 ).column_value,
1660 g_lot_attributes_tbl ( 38 ).column_value,
1661 g_lot_attributes_tbl ( 39 ).column_value,
1662 g_lot_attributes_tbl ( 40 ).column_value,
1663 g_lot_attributes_tbl ( 41 ).column_value,
1664 g_lot_attributes_tbl ( 42 ).column_value,
1665 g_lot_attributes_tbl ( 43 ).column_value,
1666 g_lot_attributes_tbl ( 44 ).column_value,
1667 g_lot_attributes_tbl ( 45 ).column_value,
1668 g_lot_attributes_tbl ( 46 ).column_value,
1669 g_lot_attributes_tbl ( 47 ).column_value,
1670 g_lot_attributes_tbl ( 48 ).column_value,
1671 g_lot_attributes_tbl ( 49 ).column_value,
1672 g_lot_attributes_tbl ( 50 ).column_value,
1673 g_lot_attributes_tbl ( 51 ).column_value,
1674 g_lot_attributes_tbl ( 52 ).column_value,
1675 g_lot_attributes_tbl ( 53 ).column_value,
1676 g_lot_attributes_tbl ( 54 ).column_value,
1677 g_lot_attributes_tbl ( 55 ).column_value,
1678 g_lot_attributes_tbl ( 56 ).column_value,
1679 g_lot_attributes_tbl ( 57 ).column_value,
1680 g_lot_attributes_tbl ( 58 ).column_value,
1681 g_lot_attributes_tbl ( 59 ).column_value,
1682 g_lot_attributes_tbl ( 60 ).column_value,
1683 g_lot_attributes_tbl ( 61 ).column_value,
1684 g_lot_attributes_tbl ( 62 ).column_value,
1685 g_lot_attributes_tbl ( 63 ).column_value,
1686 g_lot_attributes_tbl ( 64 ).column_value,
1687 g_lot_attributes_tbl ( 65 ).column_value,
1688 g_lot_attributes_tbl ( 66 ).column_value,
1689 g_lot_attributes_tbl ( 67 ).column_value;
1690 EXIT WHEN lot_temp_csr%NOTFOUND;
1691 END LOOP;
1692
1693 CLOSE lot_temp_csr;
1694 l_input_idx := 0;
1695
1696 FOR x IN 1 .. 67
1697 LOOP
1698 IF ( g_lot_attributes_tbl ( x ).column_value IS NOT NULL )
1699 THEN
1700 l_input_idx := l_input_idx + 1;
1701 l_attributes_in ( l_input_idx ).column_name :=
1702 g_lot_attributes_tbl ( x ).column_name;
1703 l_attributes_in ( l_input_idx ).column_value :=
1704 g_lot_attributes_tbl ( x ).column_value;
1705 l_attributes_in ( l_input_idx ).column_type :=
1706 g_lot_attributes_tbl ( x ).column_type;
1707 END IF;
1708 END LOOP;
1709 END IF;
1710
1711 IF ( p_transaction_action_id IS NOT NULL AND p_transaction_action_id = 3 ) THEN
1712
1713 -- Changes for bug 2221892 for same lot being provided as
1714 -- multiple lots with different quantities for inter-org
1715 -- transfer transactions
1716 /* SELECT transaction_quantity,
1717 primary_quantity
1718 INTO l_transaction_quantity,
1719 l_primary_quantity
1720 FROM mtl_transaction_lots_temp
1721 WHERE transaction_temp_id = p_transaction_temp_id
1722 AND lot_number = p_lot_number;
1723 */
1724
1725 INSERT INTO mtl_transaction_lot_numbers
1726 (
1727 transaction_id,
1728 last_update_date,
1729 last_updated_by,
1730 creation_date,
1731 created_by,
1732 last_update_login,
1733 inventory_item_id,
1734 organization_id,
1735 transaction_date,
1736 transaction_source_id,
1737 transaction_source_type_id,
1738 transaction_source_name,
1739 transaction_quantity,
1740 primary_quantity,
1741 lot_number,
1742 serial_transaction_id,
1743 description,
1744 supplier_lot_number,
1745 origination_date,
1746 date_code,
1747 grade_code,
1748 change_date,
1749 maturity_date,
1750 status_id,
1751 retest_date,
1752 age,
1753 item_size,
1754 color,
1755 volume,
1756 volume_uom,
1757 place_of_origin,
1758 best_by_date,
1759 LENGTH,
1760 length_uom,
1761 width,
1762 width_uom,
1763 recycled_content,
1764 thickness,
1765 thickness_uom,
1766 curl_wrinkle_fold,
1767 lot_attribute_category,
1768 c_attribute1,
1769 c_attribute2,
1770 c_attribute3,
1771 c_attribute4,
1772 c_attribute5,
1773 c_attribute6,
1774 c_attribute7,
1775 c_attribute8,
1776 c_attribute9,
1777 c_attribute10,
1778 c_attribute11,
1779 c_attribute12,
1780 c_attribute13,
1781 c_attribute14,
1782 c_attribute15,
1783 c_attribute16,
1784 c_attribute17,
1785 c_attribute18,
1786 c_attribute19,
1787 c_attribute20,
1788 d_attribute1,
1789 d_attribute2,
1790 d_attribute3,
1791 d_attribute4,
1792 d_attribute5,
1793 d_attribute6,
1794 d_attribute7,
1795 d_attribute8,
1796 d_attribute9,
1797 d_attribute10,
1798 n_attribute1,
1799 n_attribute2,
1800 n_attribute3,
1801 n_attribute4,
1802 n_attribute5,
1803 n_attribute6,
1804 n_attribute7,
1805 n_attribute8,
1806 n_attribute9,
1807 n_attribute10,
1808 vendor_id,
1809 territory_code,
1810 vendor_name,
1811 product_code,
1812 product_transaction_id
1813 )
1814 SELECT p_transaction_id,
1815 SYSDATE,
1816 l_userid,
1817 MLN.creation_date,
1818 MLN.created_by,
1819 MLN.last_update_login,
1820 p_inventory_item_id,
1821 p_organization_id,
1822 p_transaction_date,
1823 p_transaction_source_id,
1824 p_transaction_source_type_id,
1825 p_transaction_source_name,
1826 ROUND ( ABS ( MTLT.transaction_quantity ), 5 ),
1827 ROUND ( ABS ( MTLT.primary_quantity ), 5 ),
1828 MLN.lot_number,
1829 p_serial_transaction_id,
1830 MLN.description,
1831 MLN.supplier_lot_number,
1832 MLN.origination_date,
1833 MLN.date_code,
1834 MLN.grade_code,
1835 MLN.change_date,
1836 MLN.maturity_date,
1837 MLN.status_id,
1838 MLN.retest_date,
1839 MLN.age,
1840 MLN.item_size,
1841 MLN.color,
1842 MLN.volume,
1843 MLN.volume_uom,
1844 MLN.place_of_origin,
1845 MLN.best_by_date,
1846 MLN.LENGTH,
1847 MLN.length_uom,
1848 MLN.width,
1849 MLN.width_uom,
1850 MLN.recycled_content,
1851 MLN.thickness,
1852 MLN.thickness_uom,
1853 MLN.curl_wrinkle_fold,
1854 MLN.lot_attribute_category,
1855 MLN.c_attribute1,
1856 MLN.c_attribute2,
1857 MLN.c_attribute3,
1858 MLN.c_attribute4,
1859 MLN.c_attribute5,
1860 MLN.c_attribute6,
1861 MLN.c_attribute7,
1862 MLN.c_attribute8,
1863 MLN.c_attribute9,
1864 MLN.c_attribute10,
1865 MLN.c_attribute11,
1866 MLN.c_attribute12,
1867 MLN.c_attribute13,
1868 MLN.c_attribute14,
1869 MLN.c_attribute15,
1870 MLN.c_attribute16,
1871 MLN.c_attribute17,
1872 MLN.c_attribute18,
1873 MLN.c_attribute19,
1874 MLN.c_attribute20,
1875 MLN.d_attribute1,
1876 MLN.d_attribute2,
1877 MLN.d_attribute3,
1878 MLN.d_attribute4,
1879 MLN.d_attribute5,
1880 MLN.d_attribute6,
1881 MLN.d_attribute7,
1882 MLN.d_attribute8,
1883 MLN.d_attribute9,
1884 MLN.d_attribute10,
1885 MLN.n_attribute1,
1886 MLN.n_attribute2,
1887 MLN.n_attribute3,
1888 MLN.n_attribute4,
1889 MLN.n_attribute5,
1890 MLN.n_attribute6,
1891 MLN.n_attribute7,
1892 MLN.n_attribute8,
1893 MLN.n_attribute9,
1894 MLN.n_attribute10,
1895 MLN.vendor_id,
1896 MLN.territory_code,
1897 MLN.vendor_name,
1898 mtlt.product_code,
1899 mtlt.product_transaction_id
1900 FROM mtl_lot_numbers MLN,
1901 mtl_transaction_lots_temp MTLT
1902 WHERE MLN.organization_id = p_organization_id
1903 AND MLN.inventory_item_id = p_inventory_item_id
1904 AND MLN.lot_number = p_lot_number
1905 AND MTLT.lot_number = MLN.lot_number
1906 AND MTLT.transaction_temp_id = p_transaction_temp_id
1907 -- AND MTLT.LOT_NUMBER = p_lot_number
1908 and not exists (
1909 select null
1910 from mtl_transaction_lot_numbers mtln
1911 where mtln.lot_number = p_lot_number
1912 and mtln.primary_quantity = round(abs(MTLT.PRIMARY_QUANTITY),5)
1913 and mtln.inventory_item_id = p_inventory_item_id
1914 and mtln.organization_id = p_organization_id
1915 and mtln.transaction_date = p_transaction_date
1916 and nvl(mtln.transaction_source_id,-1) = nvl(p_transaction_source_id,-1)
1917 and nvl(mtln.transaction_source_type_id,-1) = nvl(p_transaction_source_type_id,-1)
1918 and nvl(mtln.transaction_source_name,'$$$') = nvl(p_transaction_source_name,'$$$')
1919 and mtln.transaction_id = p_transaction_id
1920 );
1921
1922 -- AND ROWNUM < 2;
1923
1924 /*
1925 and not exists
1926 (select NULL
1927 from MTL_LOT_NUMBERS LOT
1928 where LOT.lot_number = p_lot_number
1929 and LOT.organization_id = p_organization_id
1930 and LOT.inventory_item_id = p_inventory_item_id);
1931 */
1932 ELSE
1933 /* ---------------------------------------------------------
1934 * call inv_lot_sel_attr.get_default to get the default value
1935 * of the lot attributes
1936 * ---------------------------------------------------------*/
1937 IF ( inv_install.adv_inv_installed ( NULL ) = TRUE )
1938 THEN
1939 inv_lot_sel_attr.get_default (
1940 x_attributes_default => l_attributes_default,
1941 x_attributes_default_count => l_attributes_default_count,
1942 x_return_status => l_return_status,
1943 x_msg_count => l_msg_count,
1944 x_msg_data => l_msg_data,
1945 p_table_name => 'MTL_LOT_NUMBERS',
1946 p_attributes_name => 'Lot Attributes',
1947 p_inventory_item_id => p_inventory_item_id,
1948 p_organization_id => p_organization_id,
1949 p_lot_serial_number => p_lot_number,
1950 p_attributes => l_attributes_in
1951 );
1952
1953 IF ( l_return_status <> fnd_api.g_ret_sts_success )
1954 THEN
1955 x_return_status := l_return_status;
1956 RAISE fnd_api.g_exc_unexpected_error;
1957 END IF;
1958
1959 IF ( l_attributes_default_count > 0 )
1960 THEN
1961 FOR i IN 1 .. l_attributes_default_count
1962 LOOP
1963 FOR j IN 1 .. g_lot_attributes_tbl.COUNT
1964 LOOP
1965 IF ( UPPER (
1966 l_attributes_default ( i ).column_name
1967 ) = UPPER (
1968 g_lot_attributes_tbl ( j ).column_name
1969 )
1970 )
1971 THEN
1972 g_lot_attributes_tbl ( j ).column_value :=
1973 l_attributes_default ( i ).column_value;
1974 END IF;
1975
1976 EXIT WHEN ( UPPER (
1977 l_attributes_default ( i ).column_name
1978 ) =
1979 UPPER (
1980 g_lot_attributes_tbl ( j ).column_name
1981 )
1982 );
1983 END LOOP;
1984 END LOOP;
1985 END IF;
1986 END IF;
1987
1988 /** Populate Lot Attribute Category info. **/
1989 inv_lot_sel_attr.get_context_code (
1990 g_lot_attributes_tbl ( 10 ).column_value,
1991 p_organization_id,
1992 p_inventory_item_id,
1993 'Lot Attributes'
1994 );
1995
1996 INSERT INTO mtl_transaction_lot_numbers
1997 (
1998 transaction_id,
1999 last_update_date,
2000 last_updated_by,
2001 creation_date,
2002 created_by,
2003 last_update_login,
2004 inventory_item_id,
2005 organization_id,
2006 transaction_date,
2007 transaction_source_id,
2008 transaction_source_type_id,
2009 transaction_source_name,
2010 transaction_quantity,
2011 primary_quantity,
2012 lot_number,
2013 serial_transaction_id,
2014 description,
2015 vendor_id,
2016 grade_code,
2017 origination_date,
2018 date_code,
2019 status_id,
2020 change_date,
2021 age,
2022 retest_date,
2023 maturity_date,
2024 lot_attribute_category,
2025 item_size,
2026 color,
2027 volume,
2028 volume_uom,
2029 place_of_origin,
2030 best_by_date,
2031 LENGTH,
2032 length_uom,
2033 recycled_content,
2034 thickness,
2035 thickness_uom,
2036 width,
2037 width_uom,
2038 curl_wrinkle_fold,
2039 c_attribute1,
2040 c_attribute2,
2041 c_attribute3,
2042 c_attribute4,
2043 c_attribute5,
2044 c_attribute6,
2045 c_attribute7,
2046 c_attribute8,
2047 c_attribute9,
2048 c_attribute10,
2049 c_attribute11,
2050 c_attribute12,
2051 c_attribute13,
2052 c_attribute14,
2053 c_attribute15,
2054 c_attribute16,
2055 c_attribute17,
2056 c_attribute18,
2057 c_attribute19,
2058 c_attribute20,
2059 d_attribute1,
2060 d_attribute2,
2061 d_attribute3,
2062 d_attribute4,
2063 d_attribute5,
2064 d_attribute6,
2065 d_attribute7,
2066 d_attribute8,
2067 d_attribute9,
2068 d_attribute10,
2069 n_attribute1,
2070 n_attribute2,
2071 n_attribute3,
2072 n_attribute4,
2073 n_attribute5,
2074 n_attribute6,
2075 n_attribute7,
2076 n_attribute8,
2077 n_attribute10,
2078 supplier_lot_number,
2079 n_attribute9,
2080 territory_code,
2081 vendor_name,
2082 product_code,
2083 product_transaction_id
2084 )
2085 SELECT p_transaction_id,
2086 SYSDATE,
2087 l_userid,
2088 SYSDATE,
2089 l_userid,
2090 l_loginid,
2091 p_inventory_item_id,
2092 p_organization_id,
2093 p_transaction_date,
2094 p_transaction_source_id,
2095 p_transaction_source_type_id,
2096 p_transaction_source_name,
2097 DECODE (
2098 l_mmtt_pri_quantity,
2099 1, ROUND (
2100 ( ABS ( transaction_quantity ) * -1 ),
2101 5
2102 ),
2103 ROUND ( ABS ( transaction_quantity ), 5 )
2104 ),
2105 DECODE (
2106 l_mmtt_pri_quantity,
2107 1, ROUND ( ( ABS ( primary_quantity ) * -1 ), 5 ),
2108 ROUND ( ABS ( primary_quantity ), 5 )
2109 ),
2110 p_lot_number,
2111 p_serial_transaction_id,
2112 description,
2113 TO_NUMBER ( g_lot_attributes_tbl ( 1 ).column_value ),
2114 g_lot_attributes_tbl ( 2 ).column_value,
2115 fnd_date.canonical_to_date (
2116 g_lot_attributes_tbl ( 3 ).column_value
2117 ),
2118 g_lot_attributes_tbl ( 4 ).column_value,
2119 TO_NUMBER ( g_lot_attributes_tbl ( 5 ).column_value ),
2120 fnd_date.canonical_to_date (
2121 g_lot_attributes_tbl ( 6 ).column_value
2122 ),
2123 TO_NUMBER ( g_lot_attributes_tbl ( 7 ).column_value ),
2124 fnd_date.canonical_to_date (
2125 g_lot_attributes_tbl ( 8 ).column_value
2126 ),
2127 fnd_date.canonical_to_date (
2128 g_lot_attributes_tbl ( 9 ).column_value
2129 ),
2130 g_lot_attributes_tbl ( 10 ).column_value,
2131 TO_NUMBER ( g_lot_attributes_tbl ( 11 ).column_value ),
2132 g_lot_attributes_tbl ( 12 ).column_value,
2133 TO_NUMBER ( g_lot_attributes_tbl ( 13 ).column_value ),
2134 g_lot_attributes_tbl ( 14 ).column_value,
2135 g_lot_attributes_tbl ( 15 ).column_value,
2136 fnd_date.canonical_to_date (
2137 g_lot_attributes_tbl ( 16 ).column_value
2138 ),
2139 TO_NUMBER ( g_lot_attributes_tbl ( 17 ).column_value ),
2140 g_lot_attributes_tbl ( 18 ).column_value,
2141 TO_NUMBER ( g_lot_attributes_tbl ( 19 ).column_value ),
2142 TO_NUMBER ( g_lot_attributes_tbl ( 20 ).column_value ),
2143 g_lot_attributes_tbl ( 21 ).column_value,
2144 TO_NUMBER ( g_lot_attributes_tbl ( 22 ).column_value ),
2145 g_lot_attributes_tbl ( 23 ).column_value,
2146 g_lot_attributes_tbl ( 24 ).column_value,
2147 g_lot_attributes_tbl ( 25 ).column_value,
2148 g_lot_attributes_tbl ( 26 ).column_value,
2149 g_lot_attributes_tbl ( 27 ).column_value,
2150 g_lot_attributes_tbl ( 28 ).column_value,
2151 g_lot_attributes_tbl ( 29 ).column_value,
2152 g_lot_attributes_tbl ( 30 ).column_value,
2153 g_lot_attributes_tbl ( 31 ).column_value,
2154 g_lot_attributes_tbl ( 32 ).column_value,
2155 g_lot_attributes_tbl ( 33 ).column_value,
2156 g_lot_attributes_tbl ( 34 ).column_value,
2157 g_lot_attributes_tbl ( 35 ).column_value,
2158 g_lot_attributes_tbl ( 36 ).column_value,
2159 g_lot_attributes_tbl ( 37 ).column_value,
2160 g_lot_attributes_tbl ( 38 ).column_value,
2161 g_lot_attributes_tbl ( 39 ).column_value,
2162 g_lot_attributes_tbl ( 40 ).column_value,
2163 g_lot_attributes_tbl ( 41 ).column_value,
2164 g_lot_attributes_tbl ( 42 ).column_value,
2165 g_lot_attributes_tbl ( 43 ).column_value,
2166 g_lot_attributes_tbl ( 44 ).column_value,
2167 fnd_date.canonical_to_date (
2168 g_lot_attributes_tbl ( 45 ).column_value
2169 ),
2170 fnd_date.canonical_to_date (
2171 g_lot_attributes_tbl ( 46 ).column_value
2172 ),
2173 fnd_date.canonical_to_date (
2174 g_lot_attributes_tbl ( 47 ).column_value
2175 ),
2176 fnd_date.canonical_to_date (
2177 g_lot_attributes_tbl ( 48 ).column_value
2178 ),
2179 fnd_date.canonical_to_date (
2180 g_lot_attributes_tbl ( 49 ).column_value
2181 ),
2182 fnd_date.canonical_to_date (
2183 g_lot_attributes_tbl ( 50 ).column_value
2184 ),
2185 fnd_date.canonical_to_date (
2186 g_lot_attributes_tbl ( 51 ).column_value
2187 ),
2188 fnd_date.canonical_to_date (
2189 g_lot_attributes_tbl ( 52 ).column_value
2190 ),
2191 fnd_date.canonical_to_date (
2192 g_lot_attributes_tbl ( 53 ).column_value
2193 ),
2194 fnd_date.canonical_to_date (
2195 g_lot_attributes_tbl ( 54 ).column_value
2196 ),
2197 TO_NUMBER ( g_lot_attributes_tbl ( 55 ).column_value ),
2198 TO_NUMBER ( g_lot_attributes_tbl ( 56 ).column_value ),
2199 TO_NUMBER ( g_lot_attributes_tbl ( 57 ).column_value ),
2200 TO_NUMBER ( g_lot_attributes_tbl ( 58 ).column_value ),
2201 TO_NUMBER ( g_lot_attributes_tbl ( 59 ).column_value ),
2202 TO_NUMBER ( g_lot_attributes_tbl ( 60 ).column_value ),
2203 TO_NUMBER ( g_lot_attributes_tbl ( 61 ).column_value ),
2204 TO_NUMBER ( g_lot_attributes_tbl ( 62 ).column_value ),
2205 TO_NUMBER ( g_lot_attributes_tbl ( 63 ).column_value ),
2206 g_lot_attributes_tbl ( 64 ).column_value,
2207 TO_NUMBER ( g_lot_attributes_tbl ( 65 ).column_value ),
2208 g_lot_attributes_tbl ( 66 ).column_value,
2209 g_lot_attributes_tbl ( 67 ).column_value,
2210 mtlt.product_code,
2211 mtlt.product_transaction_id
2212 FROM mtl_transaction_lots_temp mtlt
2213 WHERE transaction_temp_id = p_transaction_temp_id
2214 AND lot_number = p_lot_number
2215 -- Hack for bug 2130268
2216 -- What if any transaction has the same lot 'p_lot_number' twice !!
2217 -- The insert statement then inserts two records instead of one,
2218 -- hence the following 'not exists' clause
2219 AND NOT EXISTS (
2220 SELECT NULL
2221 FROM mtl_transaction_lot_numbers mtln
2222 WHERE mtln.lot_number = p_lot_number
2223 AND mtln.primary_quantity =
2224 DECODE (
2225 l_mmtt_pri_quantity,
2226 1, ROUND (
2227 ( ABS (
2228 mtlt.primary_quantity
2229 )
2230 * -1
2231 ),
2232 5
2233 ),
2234 ROUND (
2235 ABS (
2236 mtlt.primary_quantity
2237 ),
2238 5
2239 )
2240 )
2241 AND mtln.inventory_item_id =
2242 p_inventory_item_id
2243 AND mtln.organization_id = p_organization_id
2244 AND mtln.transaction_date =
2245 p_transaction_date
2246 AND NVL ( mtln.transaction_source_id, -1 ) =
2247 NVL ( p_transaction_source_id, -1 )
2248 AND NVL (
2249 mtln.transaction_source_type_id,
2250 -1
2251 ) = NVL (
2252 p_transaction_source_type_id,
2253 -1
2254 )
2255 AND NVL (
2256 mtln.transaction_source_name,
2257 '$$$'
2258 ) = NVL (
2259 p_transaction_source_name,
2260 '$$$'
2261 )
2262 AND mtln.transaction_id = p_transaction_id );
2263
2264 -- Hack for bug 2130268
2265 x_return_status := fnd_api.g_ret_sts_success;
2266 END IF;
2267
2268 IF ( fnd_api.to_boolean ( p_commit ) )
2269 THEN
2270 COMMIT;
2271 END IF;
2272
2273 -- Standard call to get message count and if count is 1, get message info.
2274 fnd_msg_pub.count_and_get (
2275 p_encoded => fnd_api.g_false,
2276 p_count => x_msg_count,
2277 p_data => x_msg_data
2278 );
2279 EXCEPTION
2280 WHEN OTHERS
2281 THEN
2282 ROLLBACK TO apiinsertlot_apipub;
2283
2284 IF fnd_msg_pub.check_msg_level (
2285 fnd_msg_pub.g_msg_lvl_unexp_error
2286 )
2287 THEN
2288 fnd_msg_pub.add_exc_msg ('INV_LOT_API_PUB' , 'insertLot' );
2289 END IF;
2290
2291 x_return_status := fnd_api.g_ret_sts_unexp_error;
2292 END inserttrxlot;
2293
2294 FUNCTION validate_unique_lot (
2295 p_org_id IN NUMBER,
2296 p_inventory_item_id IN NUMBER,
2297 p_lot_uniqueness IN NUMBER,
2298 p_auto_lot_number IN VARCHAR2
2299 )
2300 RETURN BOOLEAN
2301 IS
2302 l_lot_number NUMBER := 0;
2303 l_lot_uniqueness NUMBER := p_lot_uniqueness;
2304 l_count NUMBER := 0;
2305 l_api_name CONSTANT VARCHAR2 ( 50 )
2306 := 'INV_LOT_API_PUB.validate_unique_lot';
2307
2308 CURSOR mln_cur_2
2309 IS
2310 SELECT lot_number
2311 FROM mtl_lot_numbers
2312 WHERE lot_number = p_auto_lot_number
2313 AND inventory_item_id <> p_inventory_item_id;
2314
2315 CURSOR mtln_cur_2
2316 IS
2317 SELECT lot_number
2318 FROM mtl_transaction_lot_numbers
2319 WHERE lot_number = p_auto_lot_number
2320 AND inventory_item_id <> p_inventory_item_id;
2321
2322 CURSOR mtlt_cur_2
2323 IS
2324 SELECT lot.lot_number
2325 FROM mtl_transaction_lots_temp lot,
2326 mtl_material_transactions_temp mmtt
2327 WHERE lot.transaction_temp_id = mmtt.transaction_temp_id
2328 AND lot.lot_number = p_auto_lot_number
2329 AND mmtt.inventory_item_id <> p_inventory_item_id;
2330
2331 CURSOR mmtt_cur_2
2332 IS
2333 SELECT lot_number
2334 FROM mtl_material_transactions_temp lot
2335 WHERE lot_number = p_auto_lot_number
2336 AND inventory_item_id <> p_inventory_item_id;
2337 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2338 BEGIN
2339 IF l_lot_uniqueness IS NULL
2340 THEN
2341 BEGIN
2342 SELECT lot_number_uniqueness
2343 INTO l_lot_uniqueness
2344 FROM mtl_parameters
2345 WHERE organization_id = p_org_id;
2346 EXCEPTION
2347 WHEN NO_DATA_FOUND
2348 THEN
2349 RAISE fnd_api.g_exc_error;
2350 END;
2351 END IF;
2352
2353 IF ( l_lot_uniqueness = 1 ) -- Item level control
2354 THEN
2355 BEGIN
2356 FOR mln_rec IN mln_cur_2
2357 LOOP
2358 l_count := 1;
2359 EXIT;
2360 END LOOP;
2361
2362 IF ( l_count > 0 )
2363 THEN
2364 RETURN FALSE;
2365 ELSE
2366 l_count := 0;
2367 END IF;
2368
2369 FOR mtln_rec IN mtln_cur_2
2370 LOOP
2371 l_count := 1;
2372 EXIT;
2373 END LOOP;
2374
2375 IF ( l_count > 0 )
2376 THEN
2377 RETURN FALSE;
2378 ELSE
2379 l_count := 0;
2380 END IF;
2381
2382 FOR mtlt_rec IN mtlt_cur_2
2383 LOOP
2384 l_count := 1;
2385 EXIT;
2386 END LOOP;
2387
2388 IF ( l_count > 0 )
2389 THEN
2390 RETURN FALSE;
2391 ELSE
2392 l_count := 0;
2393 END IF;
2394
2395 FOR mtlt_rec IN mtlt_cur_2
2396 LOOP
2397 l_count := 1;
2398 EXIT;
2399 END LOOP;
2400
2401 IF ( l_count > 0 )
2402 THEN
2403 RETURN FALSE;
2404 END IF;
2405 END;
2406 END IF;
2407
2408 RETURN TRUE;
2409 EXCEPTION
2410 WHEN OTHERS
2411 THEN
2412 IF fnd_msg_pub.check_msg_level (
2413 fnd_msg_pub.g_msg_lvl_unexp_error
2414 )
2415 THEN
2416 fnd_msg_pub.add_exc_msg ( g_pkg_name, l_api_name );
2417 END IF;
2418
2419 RETURN FALSE;
2420 END validate_unique_lot;
2421
2422 PROCEDURE update_msi (
2423 p_org_id IN NUMBER,
2424 p_inventory_item_id IN NUMBER,
2425 p_new_suffix IN VARCHAR2,
2426 p_lot_uniqueness IN NUMBER DEFAULT NULL,
2427 p_lot_generation IN NUMBER DEFAULT NULL,
2428 x_return_status OUT NOCOPY VARCHAR2,
2429 p_lot_prefix IN VARCHAR2 -- Bug# 7298723
2430 )
2431 IS
2432 PRAGMA AUTONOMOUS_TRANSACTION;
2433 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2434 l_update_count number := 0; -- Bug# 7298723
2435 BEGIN
2436 x_return_status := fnd_api.g_ret_sts_success;
2437 IF (l_debug =1 ) THEN
2438 print_debug('before updating msi '||p_lot_prefix,9);
2439 END IF;
2440
2441 if( p_lot_generation = 2 AND p_lot_uniqueness = 1 ) THEN
2442 UPDATE mtl_system_items_b
2443 SET start_auto_lot_number = p_new_suffix
2444 -- Bug# 7298723
2445 -- WHERE organization_id = p_org_id
2446 WHERE auto_lot_alpha_prefix = p_lot_prefix
2447 AND lot_control_code = 2;
2448 -- End of Bug# 7298723
2449 --AND inventory_item_id = p_inventory_item_id;
2450 l_update_count := SQL%ROWCOUNT; -- Bug# 7298723
2451
2452 elsif( p_lot_generation = 2 and p_lot_uniqueness <> 1 ) THEN
2453 UPDATE mtl_system_items
2454 SET start_auto_lot_number = p_new_suffix
2455 WHERE organization_id = p_org_id
2456 AND inventory_item_id = p_inventory_item_id;
2457
2458 l_update_count := SQL%ROWCOUNT; -- Bug# 7298723
2459
2460 end if;
2461 -- Bug 2700722.. commit the transaction after confirming that records exist
2462 -- else, return an error status
2463 -- COMMIT;
2464
2465 IF l_update_count > 0 THEN -- Bug# 7298723
2466 IF (l_debug =1 ) THEN
2467 print_debug('commiting',9);
2468 END IF;
2469
2470 COMMIT;
2471
2472 ELSE
2473 ROLLBACK;
2474 IF (l_debug =1 ) THEN
2475 print_debug('not found',9);
2476 END IF;
2477 fnd_message.set_name ('INV' , 'INV_LOT_AUTOGEN_FAILED' ); -- Bug# 7298723
2478 -- fnd_message.set_token ('ENTITY1' , 'Item with last lot number' ); -- Bug# 7298723
2479 fnd_msg_pub.ADD;
2480 x_return_status := fnd_api.g_ret_sts_error;
2481 --AND inventory_item_id = p_inventory_item_id;
2482 END IF;
2483 END;
2484
2485 /*=============================================================
2486 Autonomous function to insert to mtl_child_lot_numbers.
2487 Added by Joe DiIorio for OPM Convergence. 05/18/2004
2488 =============================================================*/
2489
2490
2491 FUNCTION ins_mtl_child_lot_num (
2492 p_org_id IN NUMBER,
2493 p_inventory_item_id IN NUMBER,
2494 p_parent_lot_number IN VARCHAR2,
2495 p_last_child_lot_seq IN NUMBER
2496 )
2497 RETURN NUMBER
2498 IS
2499 PRAGMA AUTONOMOUS_TRANSACTION;
2500
2501 l_userid FND_USER.USER_ID%TYPE;
2502 l_loginid NUMBER;
2503
2504 BEGIN
2505
2506 l_userid := fnd_global.user_id;
2507 l_loginid := fnd_global.login_id;
2508
2509 INSERT into mtl_child_lot_numbers
2510 (organization_id, inventory_item_id,
2511 parent_lot_number, last_child_lot_number_seq,
2512 creation_date, created_by, last_update_date,
2513 last_updated_by, last_update_login)
2514 VALUES (p_org_id, p_inventory_item_id, p_parent_lot_number,
2515 p_last_child_lot_seq, SYSDATE, l_userid,
2516 SYSDATE, l_userid, l_loginid);
2517
2518 COMMIT;
2519 RETURN SQLCODE;
2520
2521 END ins_mtl_child_lot_num;
2522
2523
2524 /*=============================================================
2525 Autonomous function to update to mtl_child_lot_numbers.
2526 Added by Joe DiIorio for OPM Convergence. 05/18/2004
2527 =============================================================*/
2528
2529 FUNCTION upd_mtl_child_lot_num (
2530 p_org_id IN NUMBER,
2531 p_inventory_item_id IN NUMBER,
2532 p_parent_lot_number IN VARCHAR2,
2533 p_last_child_lot_seq IN NUMBER
2534 )
2535 RETURN NUMBER
2536 IS
2537 PRAGMA AUTONOMOUS_TRANSACTION;
2538
2539 l_userid FND_USER.USER_ID%TYPE;
2540 l_loginid NUMBER;
2541
2542 BEGIN
2543
2544 l_userid := fnd_global.user_id;
2545 l_loginid := fnd_global.login_id;
2546 UPDATE mtl_child_lot_numbers
2547 SET last_child_lot_number_seq = p_last_child_lot_seq,
2548 last_updated_by = l_userid,
2549 last_update_date = SYSDATE,
2550 last_update_login = l_loginid
2551 WHERE organization_id = p_org_id
2552 AND inventory_item_id = p_inventory_item_id
2553 AND parent_lot_number = p_parent_lot_number;
2554
2555 COMMIT;
2556 RETURN SQLCODE;
2557
2558 END upd_mtl_child_lot_num;
2559
2560
2561
2562 --
2563 FUNCTION auto_gen_lot (
2564 p_org_id IN NUMBER,
2565 p_inventory_item_id IN NUMBER,
2566 p_lot_generation IN NUMBER := NULL,
2567 p_lot_uniqueness IN NUMBER := NULL,
2568 p_lot_prefix IN VARCHAR2 := NULL,
2569 p_zero_pad IN NUMBER := NULL,
2570 p_lot_length IN NUMBER := NULL,
2571 p_transaction_date IN DATE := NULL,
2572 p_revision IN VARCHAR2 := NULL,
2573 p_subinventory_code IN VARCHAR2 := NULL,
2574 p_locator_id IN NUMBER := NULL,
2575 p_transaction_type_id IN NUMBER := NULL,
2576 p_transaction_action_id IN NUMBER := NULL,
2577 p_transaction_source_type_id IN NUMBER := NULL,
2578 p_lot_number IN VARCHAR2 := NULL,
2579 p_api_version IN NUMBER,
2580 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
2581 p_commit IN VARCHAR2 := fnd_api.g_false,
2582 p_validation_level IN NUMBER
2583 := fnd_api.g_valid_level_full,
2584 p_parent_lot_number IN VARCHAR2,
2585 x_return_status OUT NOCOPY VARCHAR2,
2586 x_msg_count OUT NOCOPY NUMBER,
2587 x_msg_data OUT NOCOPY VARCHAR2
2588 )
2589 RETURN VARCHAR2
2590 IS
2591 /* Mrana : - New version of auto lot gen that calls the user_defined lot_number
2592 generation routine */
2593 lot_generation NUMBER := p_lot_generation;
2594 lot_uniqueness NUMBER := p_lot_uniqueness;
2595 lot_prefix VARCHAR2 ( 80 ) := p_lot_prefix;
2596 zero_pad NUMBER := p_zero_pad;
2597 lot_length NUMBER := p_lot_length;
2598 l_lot_prefix VARCHAR2 ( 80 );
2599 l_lot_prefix_length NUMBER;
2600 l_new_suffix VARCHAR2 ( 80 );
2601 l_lot_suffix VARCHAR2 ( 80 );
2602 l_lot_suffix_length NUMBER;
2603 l_found BOOLEAN;
2604 l_lot_control_code NUMBER;
2605 auto_lot_number VARCHAR2 ( 80 ) := NULL;
2606 l_unique_lot BOOLEAN := FALSE;
2607 l_lotcount NUMBER;
2608 l_api_version CONSTANT NUMBER := 1.0;
2609 l_api_name CONSTANT VARCHAR2 ( 50 ) := 'INV_LOT_API_PUB.auto_gen_lot';
2610 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2611 -- The following 2 variables are added as a part of bug fix for: Bug #3330855
2612 v_org_code VARCHAR2 ( 3 );
2613 v_item_name VARCHAR2 ( 80 );
2614
2615 /*======================================
2616 OPM Convergence
2617 Added cursors to check for existence
2618 of parent lot in temp or permanent
2619 table.
2620 Removed check for existing parent lot.
2621 CURSOR mtlt_cur_1 IS
2622 SELECT lot.lot_number
2623 FROM mtl_transaction_lots_temp lot,
2624 mtl_material_transactions_temp mmtt
2625 WHERE lot.transaction_temp_id = mmtt.transaction_temp_id
2626 AND lot.lot_number = p_parent_lot_number
2627 AND inventory_item_id = p_inventory_item_id;
2628
2629
2630 CURSOR get_mtl_lot IS
2631 SELECT lot_number
2632 FROM mtl_lot_numbers
2633 WHERE lot_number = p_parent_lot_number
2634 AND organization_id = p_org_id
2635 AND inventory_item_id = p_inventory_item_id;
2636
2637 x_lot_number MTL_LOT_NUMBERS.LOT_NUMBER%TYPE := NULL;
2638 ===========================================*/
2639
2640 /*=============================================
2641 Following variable controls looping until a
2642 valid child lot is found.
2643 =============================================*/
2644 l_unique_child_lot BOOLEAN := FALSE;
2645
2646 /*====================================
2647 OPM Convergence
2648 Added cursor to get Item Master setup.
2649 Variables following this cursor are
2650 used to receive the values from the
2651 cursor.
2652 ======================================*/
2653 CURSOR get_item_data IS
2654 SELECT child_lot_flag, parent_child_generation_flag,
2655 child_lot_prefix, child_lot_starting_number
2656 FROM mtl_system_items_b -- NSRIVAST, Changed the name to MTL_SYSTEM_ITEMS_B as per review comments by Shelly
2657 WHERE organization_id = p_org_id
2658 AND inventory_item_id = p_inventory_item_id;
2659
2660 x_child_lot_flag MTL_SYSTEM_ITEMS.CHILD_LOT_FLAG%TYPE;
2661 x_item_parent_child_gen_flag MTL_SYSTEM_ITEMS.PARENT_CHILD_GENERATION_FLAG%TYPE;
2662 x_item_child_lot_prefix MTL_SYSTEM_ITEMS.CHILD_LOT_PREFIX%TYPE;
2663 x_child_lot_starting_number MTL_SYSTEM_ITEMS.CHILD_LOT_STARTING_NUMBER%TYPE;
2664
2665
2666 /*====================================
2667 OPM Convergence
2668 Added cursor to get child mtl parms.
2669 Variables that follow the cursor are
2670 used to accept the data returned
2671 from the cursor.
2672 ====================================*/
2673 CURSOR get_child_parms IS
2674 SELECT lot_number_generation,
2675 parent_child_generation_flag,
2676 child_lot_zero_padding_flag,
2677 child_lot_alpha_prefix, NVL(child_lot_number_length,80)
2678 FROM mtl_parameters
2679 WHERE organization_id = p_org_id;
2680
2681 x_parent_child_generation_flag MTL_PARAMETERS.PARENT_CHILD_GENERATION_FLAG%TYPE;
2682 x_child_lot_zero_padding_flag MTL_PARAMETERS.CHILD_LOT_ZERO_PADDING_FLAG%TYPE;
2683 x_child_lot_alpha_prefix MTL_PARAMETERS.CHILD_LOT_ALPHA_PREFIX%TYPE;
2684 x_child_lot_number_length MTL_PARAMETERS.CHILD_LOT_NUMBER_LENGTH%TYPE;
2685 x_lot_number_generation MTL_PARAMETERS.LOT_NUMBER_GENERATION%TYPE;
2686
2687 /*======================================
2688 x_pad_value is the number of
2689 characters to be padded in the child
2690 lot suffix.
2691 ====================================*/
2692
2693 x_pad_value NUMBER;
2694
2695 /*======================================
2696 x_parent_lot_number is a placeholder to
2697 pass null in this value when recalling
2698 the generation routine.
2699 x_parent_call is the lot returned from
2700 the recall.
2701 ====================================*/
2702
2703 x_parent_lot_number MTL_LOT_NUMBERS.LOT_NUMBER%TYPE;
2704 x_parent_call MTL_LOT_NUMBERS.LOT_NUMBER%TYPE;
2705
2706 /*========================================
2707 interim_child_lot_number is the generated
2708 child lot that is a candidate to be
2709 passed back. Becomes passed back if
2710 it does not exist already.
2711 interim prefix is child lot prefix
2712 concatenated with parent lot.
2713 ======================================*/
2714
2715
2716 /*=======================================
2717 BUG#4145437 - increased interim size.
2718 =======================================*/
2719 interim_child_lot_number VARCHAR2(300);
2720 x_interim_child_prefix VARCHAR2(200);
2721
2722 /*========================================
2723 Cursor to check if candidate child lot
2724 exists already. Variable l_sublotcount
2725 is used with this cursor.
2726 ======================================*/
2727
2728 CURSOR check_lot_exists IS
2729 SELECT count( 1 )
2730 FROM mtl_lot_numbers
2731 WHERE inventory_item_id = p_inventory_item_id
2732 AND organization_id = p_org_id
2733 AND lot_number = interim_child_lot_number;
2734
2735 l_sublotcount NUMBER;
2736
2737 /*====================================
2738 l_ret is used in calls to functions
2739 to insert/update child lot table.
2740 ====================================*/
2741 l_ret NUMBER;
2742
2743 /*====================================
2744 Cursor to get next child number.
2745 x_last_child_seq is used with this
2746 cursor.
2747 ====================================*/
2748
2749 CURSOR get_next_child IS
2750 SELECT last_child_lot_number_seq
2751 FROM mtl_child_lot_numbers
2752 WHERE inventory_item_id = p_inventory_item_id
2753 AND organization_id = p_org_id
2754 AND parent_lot_number = p_parent_lot_number;
2755
2756 x_last_child_seq NUMBER;
2757
2758 /*====================================
2759 x_last_child_seq_pad holds the
2760 padded format of x_last_child_seq.
2761 ====================================*/
2762
2763 x_last_child_seq_pad VARCHAR2(80);
2764
2765
2766
2767 BEGIN
2768 -- Standard Start of API savepoint
2769 SAVEPOINT apiauto_gen_lot_apipub;
2770 IF (l_debug = 1) THEN
2771 print_debug('in auto_gen_lot',9);
2772 END IF;
2773 -- Standard call to check for call compatibility.
2774
2775 IF NOT fnd_api.compatible_api_call (
2776 l_api_version,
2777 p_api_version,
2778 l_api_name,
2779 g_pkg_name
2780 )
2781 THEN
2782 RAISE fnd_api.g_exc_unexpected_error;
2783 END IF;
2784
2785 -- Initialize message list if p_init_msg_list is set to TRUE.
2786 IF fnd_api.to_boolean ( p_init_msg_list )
2787 THEN
2788 fnd_msg_pub.initialize;
2789 END IF;
2790
2791 -- Initialize API return status to success
2792 x_return_status := fnd_api.g_ret_sts_success;
2793
2794 -- API body
2795
2796 /*================================================
2797 Joe DiIorio 05/17/2004 OPM Convergence.
2798 Added logic upfront to deal with parent_lot.
2799 Standard lot generation will bypass this
2800 and proceed as usual. Entry of parent lot
2801 means you want to generate a child lot.
2802 ==============================================*/
2803 IF (p_parent_lot_number IS NOT NULL) THEN
2804 /*===========================================
2805 Check if child_lot_split is allowed and
2806 retrieve all item master parms.
2807 ===========================================*/
2808 OPEN get_item_data;
2809 FETCH get_item_data INTO
2810 x_child_lot_flag, x_item_parent_child_gen_flag,
2811 x_item_child_lot_prefix, x_child_lot_starting_number;
2812 IF (get_item_data%NOTFOUND) THEN
2813 CLOSE get_item_data;
2814 fnd_message.set_name ('INV' , 'INV_CL_GET_ITEM_ERR' );
2815 fnd_msg_pub.ADD;
2816 RAISE fnd_api.g_exc_error;
2817 END IF;
2818 CLOSE get_item_data;
2819 /*===========================================
2820 Is child_lot split allowed?
2821 ===========================================*/
2822 IF (nvl(x_child_lot_flag,'N') = 'N') THEN
2823 fnd_message.set_name ('INV' , 'INV_CL_CHILD_LOT_DISABLED');
2824 fnd_msg_pub.ADD;
2825 RAISE fnd_api.g_exc_error;
2826 END IF;
2827 /*===========================================
2828 Get the Child lot generation parameters.
2829 ===========================================*/
2830 OPEN get_child_parms;
2831 FETCH get_child_parms INTO
2832 x_lot_number_generation,
2833 x_parent_child_generation_flag,
2834 x_child_lot_zero_padding_flag,
2835 x_child_lot_alpha_prefix, x_child_lot_number_length;
2836 IF (get_child_parms%NOTFOUND) THEN
2837 CLOSE get_child_parms;
2838 fnd_message.set_name ('INV' , 'INV_CL_GET_PARM_ERR');
2839 fnd_msg_pub.ADD;
2840 RAISE fnd_api.g_exc_error;
2841 END IF;
2842 CLOSE get_child_parms;
2843
2844
2845 /*===========================================
2846 Loop until we have a valid unique lot.
2847 ===========================================*/
2848 WHILE NOT ( l_unique_child_lot = TRUE )
2849 LOOP
2850 /*===========================================
2851 Parent Lot Logic First Check User Defined.
2852 Added parent lot number to call parameters.
2853 ===========================================*/
2854 IF (x_lot_number_generation = 3) THEN
2855 interim_child_lot_number :=
2856 user_pkg_lot.generate_lot_number (
2857 p_org_id,
2858 p_inventory_item_id,
2859 p_transaction_date,
2860 p_revision,
2861 p_subinventory_code,
2862 p_locator_id,
2863 p_transaction_type_id,
2864 p_transaction_action_id,
2865 p_transaction_source_type_id,
2866 p_lot_number,
2867 p_parent_lot_number,
2868 x_return_status
2869 );
2870
2871 IF ( x_return_status = fnd_api.g_ret_sts_error )
2872 THEN
2873 RAISE fnd_api.g_exc_error;
2874 END IF;
2875
2876 IF ( x_return_status = fnd_api.g_ret_sts_unexp_error )
2877 THEN
2878 RAISE fnd_api.g_exc_unexpected_error;
2879 END IF;
2880 /*===========================================
2881 If child lot generated by user routine then
2882 return it, Otherwise if null then return
2883 ===========================================*/
2884 IF (interim_child_lot_number IS NULL) THEN
2885 fnd_message.set_name ('INV' , 'INV_CL_USER_PGM_ERR');
2886 fnd_msg_pub.ADD;
2887 RAISE fnd_api.g_exc_error;
2888 END IF;
2889 /*=================================
2890 BUG#4145437
2891 =================================*/
2892 IF (lengthb(interim_child_lot_number) > 80) THEN
2893 fnd_message.set_name ('INV' , 'INV_CL_MAX_FLD_LENGTH' );
2894 fnd_msg_pub.ADD;
2895 RAISE fnd_api.g_exc_error;
2896 END IF;
2897
2898 ELSIF (x_lot_number_generation = 1) THEN
2899 /*====================================
2900 Organization Level Generation
2901 ===================================*/
2902 IF (x_parent_child_generation_flag = 'C') THEN
2903 OPEN get_next_child;
2904 FETCH get_next_child INTO x_last_child_seq;
2905 IF get_next_child%NOTFOUND THEN
2906 CLOSE get_next_child;
2907 x_last_child_seq := 1;
2908 /*=======================================
2909 Insert mtl_child_lot_numbers record.
2910 =======================================*/
2911 l_ret := ins_mtl_child_lot_num(p_org_id,
2912 p_inventory_item_id,
2913 p_parent_lot_number,
2914 x_last_child_seq);
2915 IF (l_ret <> 0 ) THEN
2916 fnd_message.set_name ('INV','INV_CL_INS_CHILD_ERR');
2917 fnd_msg_pub.ADD;
2918 RAISE fnd_api.g_exc_error;
2919 END IF;
2920 ELSE
2921 CLOSE get_next_child;
2922 x_last_child_seq := x_last_child_seq + 1;
2923 /*=======================================
2924 Update mtl_child_lot_numbers record.
2925 =======================================*/
2926 l_ret := upd_mtl_child_lot_num(p_org_id,
2927 p_inventory_item_id,
2928 p_parent_lot_number,
2929 x_last_child_seq);
2930 IF (l_ret <> 0 ) THEN
2931 fnd_message.set_name ('INV','INV_CL_UPD_CHILD_ERR');
2932 fnd_msg_pub.ADD;
2933 RAISE fnd_api.g_exc_error;
2934 END IF;
2935 END IF;
2936 /*===============================
2937 Append Parent to alpha prefix.
2938 ===============================*/
2939 x_interim_child_prefix :=
2940 p_parent_lot_number||x_child_lot_alpha_prefix;
2941
2942
2943 IF ( (lengthb(x_interim_child_prefix)
2944 + lengthb(x_last_child_seq)) > 80 ) THEN
2945 fnd_message.set_name ('INV' , 'INV_CL_MAX_FLD_LENGTH' );
2946 fnd_msg_pub.ADD;
2947 RAISE fnd_api.g_exc_error;
2948 END IF;
2949 IF ( (lengthb(x_interim_child_prefix)
2950 + lengthb(x_last_child_seq)) >
2951 x_child_lot_number_length ) THEN
2952 fnd_message.set_name ('INV' , 'INV_CL_MAX_CHLD_ERR' );
2953 fnd_msg_pub.ADD;
2954 RAISE fnd_api.g_exc_error;
2955 END IF;
2956
2957 IF (x_child_lot_zero_padding_flag = 'Y') THEN
2958 x_pad_value :=
2959 x_child_lot_number_length -
2960 length(x_interim_child_prefix);
2961 x_last_child_seq_pad :=
2962 LPAD (x_last_child_seq,x_pad_value,'0');
2963 interim_child_lot_number :=
2964 x_interim_child_prefix||x_last_child_seq_pad;
2965 ELSE
2966 interim_child_lot_number :=
2967 x_interim_child_prefix||x_last_child_seq;
2968 END IF;
2969 ELSE
2970 /*=========================================
2971 Recall this api with parent lot = NULL;
2972 *=========================================*/
2973 x_parent_lot_number := NULL;
2974 x_parent_call := inv_lot_api_pub.auto_gen_lot (
2975 p_org_id,
2976 p_inventory_item_id,
2977 p_lot_generation,
2978 p_lot_uniqueness,
2979 p_lot_prefix,
2980 p_zero_pad,
2981 p_lot_length,
2982 p_transaction_date,
2983 p_revision,
2984 p_subinventory_code,
2985 p_locator_id,
2986 p_transaction_type_id ,
2987 p_transaction_action_id,
2988 p_transaction_source_type_id,
2989 p_lot_number,
2990 p_api_version,
2991 p_init_msg_list,
2992 p_commit,
2993 p_validation_level,
2994 x_parent_lot_number,
2995 x_return_status,
2996 x_msg_count,
2997 x_msg_data
2998 );
2999 RETURN (x_parent_call);
3000 END IF;
3001
3002
3003 ELSE
3004 /*====================================
3005 Item Level Generation
3006 ===================================*/
3007 IF (x_item_parent_child_gen_flag = 'C') THEN
3008 OPEN get_next_child;
3009 FETCH get_next_child INTO x_last_child_seq;
3010 IF get_next_child%NOTFOUND THEN
3011 CLOSE get_next_child;
3012 x_last_child_seq := x_child_lot_starting_number;
3013 /*=======================================
3014 Insert mtl_child_lot_numbers record.
3015 =======================================*/
3016 l_ret := ins_mtl_child_lot_num(p_org_id,
3017 p_inventory_item_id,
3018 p_parent_lot_number,
3019 x_last_child_seq);
3020 IF (l_ret <> 0 ) THEN
3021 fnd_message.set_name ('INV','INV_CL_INS_CHILD_ERR');
3022 fnd_msg_pub.ADD;
3023 RAISE fnd_api.g_exc_error;
3024 END IF;
3025 ELSE
3026 CLOSE get_next_child;
3027 x_last_child_seq := x_last_child_seq + 1;
3028 /*=======================================
3029 Update mtl_child_lot_numbers record.
3030 =======================================*/
3031 l_ret := upd_mtl_child_lot_num(p_org_id,
3032 p_inventory_item_id,
3033 p_parent_lot_number,
3034 x_last_child_seq);
3035 IF (l_ret <> 0 ) THEN
3036 fnd_message.set_name ('INV','INV_CL_UPD_CHILD_ERR');
3037 fnd_msg_pub.ADD;
3038 RAISE fnd_api.g_exc_error;
3039 END IF;
3040 END IF;
3041 /*===============================
3042 Append Parent to alpha prefix.
3043 ===============================*/
3044 x_interim_child_prefix :=
3045 p_parent_lot_number||x_item_child_lot_prefix;
3046 IF ( (lengthb(x_interim_child_prefix)
3047 + lengthb(x_last_child_seq)) > 80 ) THEN
3048 fnd_message.set_name ('INV' , 'INV_CL_MAX_FLD_ERR' );
3049 fnd_msg_pub.ADD;
3050 RAISE fnd_api.g_exc_error;
3051 END IF;
3052 --temp joe what is length for item child?
3053 interim_child_lot_number :=
3054 x_interim_child_prefix||x_last_child_seq;
3055 ELSE
3056 /*=========================================
3057 Recall this api with parent lot = NULL;
3058 *=========================================*/
3059 x_parent_lot_number := NULL;
3060 x_parent_call := inv_lot_api_pub.auto_gen_lot (
3061 p_org_id,
3062 p_inventory_item_id,
3063 p_lot_generation,
3064 p_lot_uniqueness,
3065 p_lot_prefix,
3066 p_zero_pad,
3067 p_lot_length,
3068 p_transaction_date,
3069 p_revision,
3070 p_subinventory_code,
3071 p_locator_id,
3072 p_transaction_type_id,
3073 p_transaction_action_id,
3074 p_transaction_source_type_id,
3075 p_lot_number,
3076 p_api_version,
3077 p_init_msg_list,
3078 p_commit,
3079 p_validation_level,
3080 x_parent_lot_number,
3081 x_return_status,
3082 x_msg_count,
3083 x_msg_data
3084 );
3085 RETURN x_parent_call;
3086 END IF;
3087 END IF; -- end of generation checks.
3088 /*======================================
3089 Check if generated child lot exists.
3090 IF unique, then stop.
3091 ======================================*/
3092 OPEN check_lot_exists;
3093 FETCH check_lot_exists INTO l_sublotcount;
3094 CLOSE check_lot_exists;
3095
3096 IF ( l_sublotcount = 0 )
3097 THEN
3098 l_unique_child_lot := TRUE;
3099 ELSE
3100 l_unique_child_lot := FALSE;
3101 END IF;
3102 END LOOP;
3103 RETURN (interim_child_lot_number);
3104
3105 END IF; -- parent_lot_number is null.
3106
3107
3108 /* call the procedure (USER_GENERATE_LOT_NUMBER) to allow the users to
3109 have custom defined lot numbers instead of using the lot numbers
3110 generated by Inventory) . If this procedure is not coded by the users
3111 then it will return a NULL lot number, x_return_status =
3112 FND_API.G_RET_STS_SUCCESS */
3113 /* Fixed bug 2075044 -- added the while loop to generate the lot number.
3114 Check if the generated lot is existed in the mtl_lot_number, then generate
3115 a new lot again. */
3116
3117 WHILE NOT ( l_unique_lot = TRUE ) LOOP
3118 /*=======================================
3119 OPM Convergence Added parent lot no.
3120 =====================================*/
3121 /*===========================
3122 BUG#4089972
3123 ===========================*/
3124 /*===========================================
3125 Get the Child lot generation parameters.
3126 ===========================================*/
3127 OPEN get_child_parms;
3128 FETCH get_child_parms INTO
3129 x_lot_number_generation,
3130 x_parent_child_generation_flag,
3131 x_child_lot_zero_padding_flag,
3132 x_child_lot_alpha_prefix, x_child_lot_number_length;
3133 IF (get_child_parms%NOTFOUND) THEN
3134 CLOSE get_child_parms;
3135 fnd_message.set_name ('INV' , 'INV_CL_GET_PARM_ERR');
3136 fnd_msg_pub.ADD;
3137 RAISE fnd_api.g_exc_error;
3138 END IF;
3139 CLOSE get_child_parms;
3140 IF (x_lot_number_generation = 3) THEN
3141 auto_lot_number :=
3142 user_pkg_lot.generate_lot_number (
3143 p_org_id,
3144 p_inventory_item_id,
3145 p_transaction_date,
3146 p_revision,
3147 p_subinventory_code,
3148 p_locator_id,
3149 p_transaction_type_id,
3150 p_transaction_action_id,
3151 p_transaction_source_type_id,
3152 p_lot_number,
3153 p_parent_lot_number,
3154 x_return_status
3155 );
3156
3157 IF ( x_return_status = fnd_api.g_ret_sts_error ) THEN
3158 RAISE fnd_api.g_exc_error;
3159 END IF;
3160
3161 IF ( x_return_status = fnd_api.g_ret_sts_unexp_error ) THEN
3162 RAISE fnd_api.g_exc_unexpected_error;
3163 END IF;
3164
3165 END IF; -- gen is 3
3166 /* If i/p parameter p_lot_generation or p_lot_uniqueness are null that means we do
3167 not know at what level the lot number control is therefore Retrieve the following
3168 information for the input organization_id */
3169
3170 IF ( lot_generation IS NULL OR lot_uniqueness IS NULL) THEN
3171 BEGIN
3172 /*=================================
3173 OPM Default 80 in length not 30.
3174 =================================*/
3175 SELECT lot_number_generation,
3176 lot_number_uniqueness,
3177 NVL ( lot_number_zero_padding, 2 ),
3178 NVL ( lot_number_length, 80 ),
3179 auto_lot_alpha_prefix
3180 INTO lot_generation,
3181 lot_uniqueness,
3182 zero_pad,
3183 lot_length,
3184 lot_prefix
3185 FROM mtl_parameters
3186 WHERE organization_id = p_org_id;
3187 EXCEPTION
3188 WHEN NO_DATA_FOUND THEN
3189 fnd_message.set_name ('INV' , 'INV_FIELD_INVALID' );
3190 fnd_message.set_token ('ENTITY1' , 'p_org_id' );
3191 fnd_msg_pub.ADD;
3192 RAISE fnd_api.g_exc_error;
3193 END;
3194 END IF;
3195
3196 /* If the lot number (auto_lot_number) returned by user_defined_procedure is null
3197 then we should proceed with the generation of lot number as defined in Oracle
3198 inventory */
3199
3200 IF ( auto_lot_number IS NULL ) THEN
3201 IF ( lot_generation = 2 ) THEN -- item-level
3202 BEGIN
3203 IF (l_debug = 1) THEN
3204 print_debug('lot generation is at item level', 9);
3205 END IF;
3206
3207 SELECT lot_control_code
3208 INTO l_lot_control_code
3209 FROM mtl_system_items
3210 WHERE organization_id = p_org_id
3211 AND inventory_item_id = p_inventory_item_id;
3212
3213 IF ( l_lot_control_code = 1 ) THEN
3214 fnd_message.set_name ( 'INV' , 'INV_NO_LOT_CONTROL');
3215 fnd_msg_pub.ADD;
3216 RAISE fnd_api.g_exc_error;
3217 END IF;
3218 EXCEPTION
3219 WHEN NO_DATA_FOUND THEN
3220 fnd_message.set_name ('INV' , 'INV_INVALID_ITEM' );
3221 fnd_msg_pub.ADD;
3222 RAISE fnd_api.g_exc_error;
3223 END;
3224
3225 BEGIN
3226 -- get prefix and default lot number
3227 SELECT auto_lot_alpha_prefix,
3228 start_auto_lot_number
3229 INTO l_lot_prefix,
3230 l_lot_suffix
3231 FROM mtl_system_items
3232 WHERE organization_id = p_org_id
3233 AND inventory_item_id = p_inventory_item_id;
3234 IF (l_debug = 1) THEN
3235 print_debug('lot prefix and start number is ' || l_lot_prefix || ' & ' ||l_lot_suffix,9);
3236 END IF;
3237 IF ( l_lot_suffix IS NOT NULL ) THEN
3238 IF (l_debug = 1) THEN
3239 print_debug('lot suffix is not null',9);
3240 END IF;
3241 -- find lengths
3242 l_lot_prefix_length := NVL ( LENGTHB ( l_lot_prefix ), 0 );
3243 l_lot_suffix_length := NVL ( LENGTHB ( l_lot_suffix ), 0 );
3244 IF (l_debug = 1) THEN
3245 print_debug('lot prefixlength and suffix length is ' || l_lot_prefix_length || ' & ' ||l_lot_suffix_length,9);
3246 print_debug('lot length is ' || nvl(lot_length,80),9); -- INVCONV
3247 END IF;
3248 -- generate only if total length lot less than or equal to lot_length
3249 IF ( l_lot_prefix_length + l_lot_suffix_length <= nvl(lot_length,80)) THEN -- INVCONV
3250 IF (l_debug = 1) THEN
3251 print_debug('l_lot_prefix_length + l_lot_suffix_length <= nvl(lot_length,80)',9); -- INVCONV
3252 END IF;
3253 -- create lot number
3254 auto_lot_number := l_lot_prefix || l_lot_suffix;
3255
3256 -- left pad with zero if lot number begins with zero
3257 IF ( SUBSTR ( l_lot_suffix, 1, 1 ) = '0' ) THEN
3258 -- increment and left pad with zeros
3259 l_new_suffix := LPAD ( TO_CHAR ( TO_NUMBER ( l_lot_suffix ) + 1), l_lot_suffix_length, '0');
3260 ELSE
3261 -- increment lot number
3262 l_new_suffix := TO_CHAR ( TO_NUMBER ( l_lot_suffix ) + 1);
3263 END IF;
3264
3265 -- set new lot number
3266 -- OPM changed to 80.
3267 IF ( LENGTHB ( l_new_suffix ) <= 80 ) THEN
3268 IF (l_debug = 1) THEN
3269 print_debug('setting new lot number..calling update_msi with params' ||
3270 p_org_id || ' ' || p_inventory_item_id || ' ' || l_new_suffix,9);
3271 END IF;
3272
3273 update_msi (
3274 p_org_id,
3275 p_inventory_item_id,
3276 l_new_suffix,
3277 lot_uniqueness,
3278 lot_generation,
3279 x_return_status,
3280 l_lot_prefix -- Bug# 7298723
3281 );
3282 IF x_return_status = fnd_api.g_ret_sts_error THEN
3283 IF (l_debug = 1) THEN
3284 print_debug('it is an error ',9);
3285 END IF;
3286 RAISE fnd_api.g_exc_error;
3287 END IF;
3288 END IF;
3289 ELSE -- lot length exceeds 80
3290 fnd_message.set_name ( 'INV' , 'INV_SERIAL_LOT_TOO_LONG');
3291 fnd_message.set_token( 'LENGTH', nvl(lot_length, 80)); -- INVCONV
3292 fnd_msg_pub.ADD;
3293 RAISE fnd_api.g_exc_error;
3294 END IF;
3295 ELSE -- l_lot_suffix is NULL
3296 fnd_message.set_name ( 'INV' , 'INV_FIELD_INVALID');
3297
3298 -- Following query added as a part of the bug fix for Bug # 3330855
3299 SELECT ORGANIZATION_CODE, CONCATENATED_SEGMENTS
3300 INTO v_org_code, v_item_name
3301 FROM MTL_PARAMETERS ORG, MTL_SYSTEM_ITEMS_KFV ITEM
3302 WHERE ORG.ORGANIZATION_ID = p_org_id
3303 AND INVENTORY_ITEM_ID = p_inventory_item_id
3304 AND ITEM.ORGANIZATION_ID = p_org_id;
3305
3306 fnd_message.set_token ( 'ENTITY1' , 'Lot Suffix for Org: ' || v_org_code || ' and Item: ' || v_item_name);
3307 fnd_msg_pub.ADD;
3308 RAISE fnd_api.g_exc_error;
3309 END IF;
3310 EXCEPTION
3311 WHEN NO_DATA_FOUND THEN
3312 IF (l_debug=1) THEN
3313 print_debug('no data found',9);
3314 END IF;
3315 fnd_message.set_name ('INV' , 'INV_INVALID_ITEM' );
3316 fnd_message.set_token ( 'ENTITY1' , 'p_org_id, p_inventory_item_id');
3317 fnd_msg_pub.ADD;
3318 RAISE fnd_api.g_exc_error;
3319 END;
3320 ELSIF ( lot_generation = 1 ) THEN -- org-level
3321 BEGIN
3322 IF (l_debug =1 ) THEN
3323 print_debug('lot generation is at org level ',9);
3324 END IF;
3325 -- set lot prefix
3326 l_lot_prefix := lot_prefix;
3327
3328 -- get next org level lot number
3329 SELECT TO_CHAR ( mtl_lot_numeric_suffix_s.NEXTVAL )
3330 INTO l_lot_suffix
3331 FROM sys.DUAL;
3332 IF (l_debug =1 ) THEN
3333 print_debug('lot prefix is ' || l_lot_prefix || 'suffix is ' || l_lot_suffix,9);
3334 END IF;
3335 -- find lengths
3336 l_lot_prefix_length := NVL ( LENGTHB ( l_lot_prefix ), 0 );
3337 l_lot_suffix_length := NVL ( LENGTHB ( l_lot_suffix ), 0 );
3338 IF (l_debug =1 ) THEN
3339 print_debug('lot prefix length is ' || l_lot_prefix_length || ' suffix length is ' || l_lot_suffix_length,9);
3340 END IF;
3341 -- generate only if total lot length less than or equal to lot_length
3342 IF ( l_lot_prefix_length + l_lot_suffix_length <= lot_length) THEN
3343 IF (l_debug =1 ) THEN
3344 print_debug('sum < lot length',9);
3345 END IF;
3346 IF ( zero_pad = 1 ) THEN -- YES = 1 AND 2 = NO
3347 auto_lot_number := lot_prefix || LPAD ( l_lot_suffix, lot_length - l_lot_prefix_length, '0');
3348 ELSE
3349 auto_lot_number := l_lot_prefix || l_lot_suffix;
3350 END IF;
3351 ELSE -- lot length exceeds 80
3352 fnd_message.set_name ( 'INV' , 'INV_SERIAL_LOT_TOO_LONG');
3353 fnd_message.set_token( 'LENGTH', nvl(lot_length, 80)); -- INVCONV
3354 fnd_msg_pub.ADD;
3355 RAISE fnd_api.g_exc_error;
3356 END IF;
3357 END;
3358 END IF;
3359 END IF;
3360
3361
3362 --RETURN (auto_lot_number);
3363 /*
3364 IF inv_lot_api_pub.validate_unique_lot
3365 ( p_org_id,
3366 p_inventory_item_id,
3367 lot_uniqueness,
3368 auto_lot_number)
3369 THEN
3370 RETURN (auto_lot_number);
3371 ELSE
3372 fnd_message.set_name('INV', 'INV_LOT_NUMBER_EXISTS');
3373 fnd_msg_pub.add;
3374 RAISE fnd_api.g_exc_error ;
3375 END IF;
3376 */
3377
3378 /* Check if the generated lot is already existed in the mtl_lot_number,
3379 set the l_unique_lot = FALSE and go back to the while loop to generate
3380 a new lot, otherwise l_unique_lot = TRUE and return the lot number */
3381 --Bug 3750324 Validating the uniqueness of lot through existing api for checking validation so that the unique lot is
3382 -- generated at first go on the form
3383 /* SELECT COUNT ( 1 )
3384 INTO l_lotcount
3385 FROM mtl_lot_numbers
3386 WHERE
3387 inventory_item_id = p_inventory_item_id AND
3388 organization_id = p_org_id AND
3389 lot_number = auto_lot_number;
3390
3391 IF ( l_lotcount = 0 )
3392 THEN
3393 l_unique_lot := TRUE;
3394 ELSE
3395 l_unique_lot := FALSE;
3396 END IF; */
3397 l_unique_lot :=
3398 inv_lot_api_pub.validate_unique_lot(
3399 p_org_id
3400 , p_inventory_item_id
3401 , p_lot_uniqueness
3402 , auto_lot_number
3403 );
3404 --Bug 3750324 Ends
3405 END LOOP;
3406 IF (l_debug =1 ) THEN
3407 print_debug('returning lot number ' || auto_lot_number,9);
3408 END IF;
3409 RETURN ( auto_lot_number );
3410 EXCEPTION
3411 WHEN fnd_api.g_exc_error THEN
3412 ROLLBACK TO apiauto_gen_lot_apipub;
3413 x_return_status := fnd_api.g_ret_sts_error;
3414 fnd_msg_pub.count_and_get (
3415 p_encoded => fnd_api.g_false,
3416 p_count => x_msg_count,
3417 p_data => x_msg_data
3418 );
3419 --Bugfix 3940851 {
3420 if( x_msg_count > 1 ) then
3421 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
3422 end if;
3423 --Bugfix 3940851 }
3424 RETURN ( NULL );
3425 WHEN fnd_api.g_exc_unexpected_error THEN
3426 ROLLBACK TO apiauto_gen_lot_apipub;
3427 x_return_status := fnd_api.g_ret_sts_unexp_error;
3428 fnd_msg_pub.count_and_get (
3429 p_encoded => fnd_api.g_false,
3430 p_count => x_msg_count,
3431 p_data => x_msg_data
3432 );
3433 --Bugfix 3940851 {
3434 if( x_msg_count > 1 ) then
3435 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
3436 end if;
3437 --Bugfix 3940851 }
3438 RETURN ( NULL );
3439 WHEN OTHERS THEN
3440 ROLLBACK TO apiauto_gen_lot_apipub;
3441 x_return_status := fnd_api.g_ret_sts_unexp_error;
3442
3443 IF fnd_msg_pub.check_msg_level ( fnd_msg_pub.g_msg_lvl_unexp_error) THEN
3444 fnd_msg_pub.add_exc_msg ( g_pkg_name, l_api_name );
3445 END IF;
3446
3447 fnd_msg_pub.count_and_get (
3448 p_encoded => fnd_api.g_false,
3449 p_count => x_msg_count,
3450 p_data => x_msg_data
3451 );
3452 --Bugfix 3940851 {
3453 if( x_msg_count > 1 ) then
3454 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
3455 end if;
3456 --Bugfix 3940851 }
3457 RETURN ( NULL );
3458 END auto_gen_lot;
3459
3460
3461 /* Created a wrapper around validate_unique_lot to be able to call it thru Mobile apps */
3462 PROCEDURE validate_unique_lot (
3463 p_org_id IN NUMBER,
3464 p_inventory_item_id IN NUMBER,
3465 p_lot_uniqueness IN NUMBER,
3466 p_auto_lot_number IN VARCHAR2,
3467 p_check_same_item IN VARCHAR2,
3468 x_is_unique OUT NOCOPY VARCHAR2
3469 )
3470 IS
3471 l_lot_number NUMBER := 0;
3472 l_lot_uniqueness NUMBER := p_lot_uniqueness;
3473 l_count NUMBER := 0;
3474 l_api_name CONSTANT VARCHAR2 ( 50 )
3475 := 'INV_LOT_API_PUB.validate_unique_lot';
3476
3477 CURSOR mln_cur_1
3478 IS
3479 SELECT lot_number
3480 FROM mtl_lot_numbers
3481 WHERE lot_number = p_auto_lot_number
3482 AND inventory_item_id = p_inventory_item_id;
3483
3484 CURSOR mtln_cur_1
3485 IS
3486 SELECT lot_number
3487 FROM mtl_transaction_lot_numbers
3488 WHERE lot_number = p_auto_lot_number
3489 AND inventory_item_id = p_inventory_item_id;
3490
3491 CURSOR mtlt_cur_1
3492 IS
3493 SELECT lot.lot_number
3494 FROM mtl_transaction_lots_temp lot,
3495 mtl_material_transactions_temp mmtt
3496 WHERE lot.transaction_temp_id = mmtt.transaction_temp_id
3497 AND lot.lot_number = p_auto_lot_number
3498 AND mmtt.inventory_item_id = p_inventory_item_id;
3499
3500 CURSOR mmtt_cur_1
3501 IS
3502 SELECT lot_number
3503 FROM mtl_material_transactions_temp lot
3504 WHERE lot_number = p_auto_lot_number
3505 AND inventory_item_id = p_inventory_item_id;
3506 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3507 BEGIN
3508 IF l_lot_uniqueness IS NULL
3509 THEN
3510 BEGIN
3511 SELECT lot_number_uniqueness
3512 INTO l_lot_uniqueness
3513 FROM mtl_parameters
3514 WHERE organization_id = p_org_id;
3515 EXCEPTION
3516 WHEN NO_DATA_FOUND
3517 THEN
3518 RAISE fnd_api.g_exc_error;
3519 END;
3520 END IF;
3521
3522 IF ( l_lot_uniqueness = 1 ) -- Item level control
3523 THEN
3524 IF ( validate_unique_lot (
3525 p_org_id,
3526 p_inventory_item_id,
3527 l_lot_uniqueness,
3528 p_auto_lot_number
3529 )
3530 )
3531 AND p_check_same_item = 'Y'
3532 THEN
3533 BEGIN
3534 x_is_unique := 'true';
3535
3536 FOR mln_rec IN mln_cur_1
3537 LOOP
3538 l_count := 1;
3539 EXIT;
3540 END LOOP;
3541
3542 IF ( l_count > 0 )
3543 THEN
3544 x_is_unique := 'false';
3545 ELSE
3546 l_count := 0;
3547 END IF;
3548
3549 FOR mtln_rec IN mtln_cur_1
3550 LOOP
3551 l_count := 1;
3552 EXIT;
3553 END LOOP;
3554
3555 IF ( l_count > 0 )
3556 THEN
3557 x_is_unique := 'false';
3558 ELSE
3559 l_count := 0;
3560 END IF;
3561
3562 FOR mtlt_rec IN mtlt_cur_1
3563 LOOP
3564 l_count := 1;
3565 EXIT;
3566 END LOOP;
3567
3568 IF ( l_count > 0 )
3569 THEN
3570 x_is_unique := 'false';
3571 ELSE
3572 l_count := 0;
3573 END IF;
3574
3575 FOR mtlt_rec IN mtlt_cur_1
3576 LOOP
3577 l_count := 1;
3578 EXIT;
3579 END LOOP;
3580
3581 IF ( l_count > 0 )
3582 THEN
3583 x_is_unique := 'false';
3584 END IF;
3585 END;
3586 ELSE
3587 x_is_unique := 'false';
3588 END IF;
3589 ELSE
3590 x_is_unique := 'true';
3591 END IF;
3592 EXCEPTION
3593 WHEN OTHERS
3594 THEN
3595 IF fnd_msg_pub.check_msg_level (
3596 fnd_msg_pub.g_msg_lvl_unexp_error
3597 )
3598 THEN
3599 fnd_msg_pub.add_exc_msg ( g_pkg_name, l_api_name );
3600 END IF;
3601
3602 x_is_unique := 'false';
3603 END validate_unique_lot;
3604
3605
3606 /***************************************************************************************
3607 Bug - 2181558
3608 Procedure to copy the WMS and Non WMS Lot Attributes from the Source Lot to this Lot
3609 ***************************************************************************************/
3610 PROCEDURE get_lot_att_from_source (
3611 x_return_status OUT NOCOPY VARCHAR2,
3612 x_count OUT NOCOPY NUMBER,
3613 x_source_wms_lot_att_tbl OUT NOCOPY inv_lot_sel_attr.lot_sel_attributes_tbl_type,
3614 x_source_non_wms_lot_att_rec OUT NOCOPY non_wms_lot_att_rec_type,
3615 p_from_organization_id IN NUMBER,
3616 p_inventory_item_id IN NUMBER,
3617 p_lot_number IN VARCHAR2,
3618 p_count IN NUMBER,
3619 p_source_wms_lot_att_tbl IN inv_lot_sel_attr.lot_sel_attributes_tbl_type
3620 )
3621 IS
3622 temp_tbl inv_lot_sel_attr.lot_sel_attributes_tbl_type;
3623 v_found BOOLEAN := FALSE;
3624 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3625 BEGIN
3626 IF (l_debug = 1) THEN
3627 print_debug ('Getting the WMS and NON WMS LOT Attributes From the Source LOT',4);
3628 END IF;
3629
3630 SELECT TO_CHAR ( vendor_id ),
3631 grade_code,
3632 fnd_date.date_to_canonical ( origination_date ),
3633 date_code,
3634 TO_CHAR ( status_id ),
3635 fnd_date.date_to_canonical ( change_date ),
3636 TO_NUMBER ( age ),
3637 fnd_date.date_to_canonical ( retest_date ),
3638 fnd_date.date_to_canonical ( maturity_date ),
3639 lot_attribute_category,
3640 TO_CHAR ( item_size ),
3641 color,
3642 TO_CHAR ( volume ),
3643 volume_uom,
3644 place_of_origin,
3645 fnd_date.date_to_canonical ( best_by_date ),
3646 TO_CHAR ( LENGTH ),
3647 length_uom,
3648 TO_CHAR ( recycled_content ),
3649 TO_CHAR ( thickness ),
3650 thickness_uom,
3651 TO_CHAR ( width ),
3652 width_uom,
3653 curl_wrinkle_fold,
3654 c_attribute1,
3655 c_attribute2,
3656 c_attribute3,
3657 c_attribute4,
3658 c_attribute5,
3659 c_attribute6,
3660 c_attribute7,
3661 c_attribute8,
3662 c_attribute9,
3663 c_attribute10,
3664 c_attribute11,
3665 c_attribute12,
3666 c_attribute13,
3667 c_attribute14,
3668 c_attribute15,
3669 c_attribute16,
3670 c_attribute17,
3671 c_attribute18,
3672 c_attribute19,
3673 c_attribute20,
3674 fnd_date.date_to_canonical ( d_attribute1 ),
3675 fnd_date.date_to_canonical ( d_attribute2 ),
3676 fnd_date.date_to_canonical ( d_attribute3 ),
3677 fnd_date.date_to_canonical ( d_attribute4 ),
3678 fnd_date.date_to_canonical ( d_attribute5 ),
3679 fnd_date.date_to_canonical ( d_attribute6 ),
3680 fnd_date.date_to_canonical ( d_attribute7 ),
3681 fnd_date.date_to_canonical ( d_attribute8 ),
3682 fnd_date.date_to_canonical ( d_attribute9 ),
3683 fnd_date.date_to_canonical ( d_attribute10 ),
3684 TO_CHAR ( n_attribute1 ),
3685 TO_CHAR ( n_attribute2 ),
3686 TO_CHAR ( n_attribute3 ),
3687 TO_CHAR ( n_attribute4 ),
3688 TO_CHAR ( n_attribute5 ),
3689 TO_CHAR ( n_attribute6 ),
3690 TO_CHAR ( n_attribute7 ),
3691 TO_CHAR ( n_attribute8 ),
3692 TO_CHAR ( n_attribute10 ),
3693 supplier_lot_number,
3694 TO_CHAR ( n_attribute9 ),
3695 territory_code,
3696 vendor_name,
3697 description,
3698 attribute_category,
3699 attribute1,
3700 attribute2,
3701 attribute3,
3702 attribute4,
3703 attribute5,
3704 attribute6,
3705 attribute7,
3706 attribute8,
3707 attribute9,
3708 attribute10,
3709 attribute11,
3710 attribute12,
3711 attribute13,
3712 attribute14,
3713 attribute15
3714 INTO temp_tbl ( 1 ).column_value,
3715 temp_tbl ( 2 ).column_value,
3716 temp_tbl ( 3 ).column_value,
3717 temp_tbl ( 4 ).column_value,
3718 temp_tbl ( 5 ).column_value,
3719 temp_tbl ( 6 ).column_value,
3720 temp_tbl ( 7 ).column_value,
3721 temp_tbl ( 8 ).column_value,
3722 temp_tbl ( 9 ).column_value,
3723 temp_tbl ( 10 ).column_value,
3724 temp_tbl ( 11 ).column_value,
3725 temp_tbl ( 12 ).column_value,
3726 temp_tbl ( 13 ).column_value,
3727 temp_tbl ( 14 ).column_value,
3728 temp_tbl ( 15 ).column_value,
3729 temp_tbl ( 16 ).column_value,
3730 temp_tbl ( 17 ).column_value,
3731 temp_tbl ( 18 ).column_value,
3732 temp_tbl ( 19 ).column_value,
3733 temp_tbl ( 20 ).column_value,
3734 temp_tbl ( 21 ).column_value,
3735 temp_tbl ( 22 ).column_value,
3736 temp_tbl ( 23 ).column_value,
3737 temp_tbl ( 24 ).column_value,
3738 temp_tbl ( 25 ).column_value,
3739 temp_tbl ( 26 ).column_value,
3740 temp_tbl ( 27 ).column_value,
3741 temp_tbl ( 28 ).column_value,
3742 temp_tbl ( 29 ).column_value,
3743 temp_tbl ( 30 ).column_value,
3744 temp_tbl ( 31 ).column_value,
3745 temp_tbl ( 32 ).column_value,
3746 temp_tbl ( 33 ).column_value,
3747 temp_tbl ( 34 ).column_value,
3748 temp_tbl ( 35 ).column_value,
3749 temp_tbl ( 36 ).column_value,
3750 temp_tbl ( 37 ).column_value,
3751 temp_tbl ( 38 ).column_value,
3752 temp_tbl ( 39 ).column_value,
3753 temp_tbl ( 40 ).column_value,
3754 temp_tbl ( 41 ).column_value,
3755 temp_tbl ( 42 ).column_value,
3756 temp_tbl ( 43 ).column_value,
3757 temp_tbl ( 44 ).column_value,
3758 temp_tbl ( 45 ).column_value,
3759 temp_tbl ( 46 ).column_value,
3760 temp_tbl ( 47 ).column_value,
3761 temp_tbl ( 48 ).column_value,
3762 temp_tbl ( 49 ).column_value,
3763 temp_tbl ( 50 ).column_value,
3764 temp_tbl ( 51 ).column_value,
3765 temp_tbl ( 52 ).column_value,
3766 temp_tbl ( 53 ).column_value,
3767 temp_tbl ( 54 ).column_value,
3768 temp_tbl ( 55 ).column_value,
3769 temp_tbl ( 56 ).column_value,
3770 temp_tbl ( 57 ).column_value,
3771 temp_tbl ( 58 ).column_value,
3772 temp_tbl ( 59 ).column_value,
3773 temp_tbl ( 60 ).column_value,
3774 temp_tbl ( 61 ).column_value,
3775 temp_tbl ( 62 ).column_value,
3776 temp_tbl ( 63 ).column_value,
3777 temp_tbl ( 64 ).column_value,
3778 temp_tbl ( 65 ).column_value,
3779 temp_tbl ( 66 ).column_value,
3780 temp_tbl ( 67 ).column_value,
3781 temp_tbl ( 68 ).column_value,
3782 x_source_non_wms_lot_att_rec.attribute_category,
3783 x_source_non_wms_lot_att_rec.attribute1,
3784 x_source_non_wms_lot_att_rec.attribute2,
3785 x_source_non_wms_lot_att_rec.attribute3,
3786 x_source_non_wms_lot_att_rec.attribute4,
3787 x_source_non_wms_lot_att_rec.attribute5,
3788 x_source_non_wms_lot_att_rec.attribute6,
3789 x_source_non_wms_lot_att_rec.attribute7,
3790 x_source_non_wms_lot_att_rec.attribute8,
3791 x_source_non_wms_lot_att_rec.attribute9,
3792 x_source_non_wms_lot_att_rec.attribute10,
3793 x_source_non_wms_lot_att_rec.attribute11,
3794 x_source_non_wms_lot_att_rec.attribute12,
3795 x_source_non_wms_lot_att_rec.attribute13,
3796 x_source_non_wms_lot_att_rec.attribute14,
3797 x_source_non_wms_lot_att_rec.attribute15
3798 FROM mtl_lot_numbers
3799 WHERE organization_id = p_from_organization_id
3800 AND inventory_item_id = p_inventory_item_id
3801 AND lot_number = p_lot_number;
3802
3803 x_count := p_count;
3804 x_source_wms_lot_att_tbl := p_source_wms_lot_att_tbl;
3805
3806 FOR x IN 1..68 LOOP
3807 v_found := FALSE;
3808 FOR y IN 1..p_count LOOP
3809 IF ( upper(temp_tbl(y).column_name) = upper(p_source_wms_lot_att_tbl(y).column_name)) THEN
3810 v_found := TRUE;
3811 END IF;
3812 END LOOP;
3813
3814 IF(v_found = FALSE) THEN
3815 IF temp_tbl(x).column_value IS NOT NULL THEN
3816 x_count := x_count + 1;
3817 x_source_wms_lot_att_tbl(x_count).column_name := g_lot_attributes_tbl(x).column_name;
3818 x_source_wms_lot_att_tbl(x_count).column_type := g_lot_attributes_tbl(x).column_type;
3819 x_source_wms_lot_att_tbl(x_count).column_value := temp_tbl(x).column_value;
3820 END IF;
3821 END IF;
3822 END LOOP;
3823 EXCEPTION
3824 WHEN no_data_found THEN
3825 IF (l_debug = 1) THEN
3826 print_debug('The selected lot_number, organization, item combination doesnt exist in MLN',4);
3827 END IF;
3828 x_count := p_count;
3829 x_source_wms_lot_att_tbl := p_source_wms_lot_att_tbl;
3830 WHEN OTHERS
3831 THEN
3832 x_return_status := fnd_api.g_ret_sts_unexp_error;
3833 IF (l_debug = 1) THEN
3834 print_debug ('Exitting populatelotattributes - other exception:' || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' ),1);
3835 END IF;
3836 IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error) THEN
3837 fnd_msg_pub.add_exc_msg (g_pkg_name,'get_lot_att_from_source');
3838 END IF;
3839 END get_lot_att_from_source;
3840
3841
3842 -----------------------------------------------------------J Develop--------------------------------
3843
3844 PROCEDURE validate_lot_attr_info(
3845 x_return_status OUT NOCOPY VARCHAR2
3846 , x_msg_count OUT NOCOPY NUMBER
3847 , x_msg_data OUT NOCOPY VARCHAR2
3848 , p_wms_is_installed IN VARCHAR2
3849 , p_attribute_category IN VARCHAR2
3850 , p_lot_attribute_category IN VARCHAR2
3851 , p_inventory_item_id IN NUMBER
3852 , p_organization_id IN NUMBER
3853 , p_attributes_tbl IN inv_lot_api_pub.char_tbl
3854 , p_c_attributes_tbl IN inv_lot_api_pub.char_tbl
3855 , p_n_attributes_tbl IN inv_lot_api_pub.number_tbl
3856 , p_d_attributes_tbl IN inv_lot_api_pub.date_tbl
3857 , p_disable_flag IN NUMBER
3858 , p_grade_code IN VARCHAR2
3859 , p_origination_date IN DATE
3860 , p_date_code IN VARCHAR2
3861 , p_change_date IN DATE
3862 , p_age IN NUMBER
3863 , p_retest_date IN DATE
3864 , p_maturity_date IN DATE
3865 , p_item_size IN NUMBER
3866 , p_color IN VARCHAR2
3867 , p_volume IN NUMBER
3868 , p_volume_uom IN VARCHAR2
3869 , p_place_of_origin IN VARCHAR2
3870 , p_best_by_date IN DATE
3871 , p_length IN NUMBER
3872 , p_length_uom IN VARCHAR2
3873 , p_recycled_content IN NUMBER
3874 , p_thickness IN NUMBER
3875 , p_thickness_uom IN VARCHAR2
3876 , p_width IN NUMBER
3877 , p_width_uom IN VARCHAR2
3878 , p_territory_code IN VARCHAR2
3879 , p_supplier_lot_number IN VARCHAR2
3880 , p_vendor_name IN VARCHAR2
3881 ) IS
3882 TYPE seg_name IS TABLE OF VARCHAR2(1000)
3883 INDEX BY BINARY_INTEGER;
3884
3885 l_context VARCHAR2(1000);
3886 l_context_r fnd_dflex.context_r;
3887 l_contexts_dr fnd_dflex.contexts_dr;
3888 l_dflex_r fnd_dflex.dflex_r;
3889 l_segments_dr fnd_dflex.segments_dr;
3890 l_enabled_seg_name seg_name;
3891 l_wms_all_segs_tbl seg_name;
3892 l_nsegments BINARY_INTEGER;
3893 l_global_context BINARY_INTEGER;
3894 v_index NUMBER := 1;
3895 v_index1 NUMBER := 1;
3896 l_chk_flag NUMBER := 0;
3897 l_char_count NUMBER;
3898 l_num_count NUMBER;
3899 l_date_count NUMBER;
3900 l_wms_attr_chk NUMBER := 1;
3901 l_return_status VARCHAR2(1);
3902 l_msg_count NUMBER;
3903 l_msg_data VARCHAR2(1000);
3904 /*Return status definition
3905 G_RET_STS_SUCCESS CONSTANT VARCHAR2(1) :='S';
3906 G_RET_STS_ERROR CONSTANT VARCHAR2(1) :='E';
3907 G_RET_STS_UNEXP_ERROR CONSTANT VARCHAR2(1) :='U'; */
3908
3909
3910 /*Exception definitions
3911 G_EXC_ERROR EXCEPTION;
3912 G_EXC_UNEXPECTED_ERROR EXCEPTION;*/
3913
3914 /* Variables used for Validate_desccols procedure */
3915 error_segment VARCHAR2(30);
3916 errors_received EXCEPTION;
3917 error_msg VARCHAR2(5000);
3918 s NUMBER;
3919 e NUMBER;
3920 --g_debug NUMBER := 1 ;--NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'),0);
3921 l_null_char_val VARCHAR2(1000);
3922 l_null_num_val NUMBER;
3923 l_null_date_val DATE;
3924 l_global_nsegments NUMBER := 0;
3925 BEGIN
3926 x_return_status := g_ret_sts_success;
3927 SAVEPOINT get_lot_attr_information;
3928
3929 /* Populate the flex field record */
3930 --IF p_attribute_category IS NOT NULL THEN
3931 --AND p_attributes_tbl.COUNT > 0 THEN
3932 l_dflex_r.application_id := 401;
3933 l_dflex_r.flexfield_name := 'MTL_LOT_NUMBERS';
3934 /* Get all contexts */
3935 fnd_dflex.get_contexts(flexfield => l_dflex_r, contexts => l_contexts_dr);
3936
3937 IF g_debug = 1 THEN
3938 print_debug('Found contexts for the Flexfield MTL_LOT_NUMBERS', 9);
3939 END IF;
3940
3941 /* From the l_contexts_dr, get the position of the global context */
3942 l_global_context := l_contexts_dr.global_context;
3943
3944 IF g_debug = 1 THEN
3945 print_debug('Found the position of the global context ', 9);
3946 END IF;
3947
3948 /* Using the position get the segments in the global context which are enabled */
3949 l_context := l_contexts_dr.context_code(l_global_context);
3950
3951 /* Prepare the context_r type for getting the segments associated with the global context */
3952 l_context_r.flexfield := l_dflex_r;
3953 l_context_r.context_code := l_context;
3954 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
3955
3956 IF g_debug = 1 THEN
3957 print_debug('After successfully getting all the enabled segmenst for the Global Context ', 9);
3958 END IF;
3959
3960 /* read through the segments */
3961 l_nsegments := l_segments_dr.nsegments;
3962 l_global_nsegments := l_segments_dr.nsegments;
3963 IF g_debug = 1 THEN
3964 print_debug('The number of enabled segments for the Global Context are ' || l_nsegments, 9);
3965 END IF;
3966
3967 FOR i IN 1 .. l_nsegments LOOP
3968 print_debug('v_index is ' || v_index, 9);
3969 print_debug('application_column_name is ' || l_segments_dr.application_column_name(i), 9);
3970
3971 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
3972
3973 IF g_debug = 1 THEN
3974 print_debug('The segment is ' || l_segments_dr.segment_name(i), 9);
3975 END IF;
3976
3977 print_debug(p_attributes_tbl.count, 9);
3978
3979 IF l_segments_dr.is_required(i) THEN
3980 IF NOT p_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
3981 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
3982 fnd_message.set_name('INV', 'INV_REQ_SEG_MISS');
3983 fnd_message.set_token('SEGMENT', l_segments_dr.segment_name(i));
3984 fnd_msg_pub.ADD;
3985
3986 IF g_debug = 1 THEN
3987 print_debug('Req segment is not populated', 9);
3988 END IF;
3989
3990 RAISE g_exc_error;
3991 END IF;
3992 ELSE
3993 IF g_debug = 1 THEN
3994 print_debug('This segment is not required', 9);
3995 END IF;
3996 END IF;
3997
3998 IF p_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
3999 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
4000 fnd_flex_descval.set_column_value(
4001 l_segments_dr.application_column_name(i)
4002 , p_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i)
4003 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9))
4004 );
4005 ELSE
4006 fnd_flex_descval.set_column_value(l_segments_dr.application_column_name(i), l_null_char_val);
4007 END IF;
4008
4009 --fnd_flex_descval.set_column_value(l_segments_dr.application_column_name(i),p_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i),INSTR(l_segments_dr.application_column_name(i),'ATTRIBUTE')+9)));
4010 v_index := v_index + 1;
4011 END LOOP;
4012
4013 IF l_enabled_seg_name.COUNT > 0 THEN
4014 FOR i IN l_enabled_seg_name.FIRST .. l_enabled_seg_name.LAST LOOP
4015 IF g_debug = 1 THEN
4016 print_debug('The enabled segment : ' || l_enabled_seg_name(i), 9);
4017 END IF;
4018 END LOOP;
4019 END IF;
4020
4021 /* Initialise the l_context_value to null */
4022 l_context := NULL;
4023 l_nsegments := 0;
4024
4025 /*Get the context for the item passed */
4026 IF p_attribute_category IS NOT NULL THEN
4027 l_context := p_attribute_category;
4028 /* Set flex context for validation of the value set */
4029 fnd_flex_descval.set_context_value(l_context);
4030
4031 IF g_debug = 1 THEN
4032 print_debug('The value of INV context is ' || l_context, 9);
4033 END IF;
4034
4035 /* Prepare the context_r type */
4036 l_context_r.flexfield := l_dflex_r;
4037 l_context_r.context_code := l_context;
4038 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
4039 /* read through the segments */
4040 l_nsegments := l_segments_dr.nsegments;
4041 IF g_debug = 1 THEN
4042 print_debug('No of segments enabled for context ' || l_context || ' are ' || l_nsegments, 9);
4043 END IF;
4044
4045 print_Debug('v_index is ' || v_index, 9);
4046 FOR i IN 1 .. l_nsegments LOOP
4047 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
4048
4049 print_debug('The segment is ' || l_segments_dr.segment_name(i), 9);
4050
4051 IF l_segments_dr.is_required(i) THEN
4052 IF NOT p_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
4053 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
4054 fnd_message.set_name('INV', 'INV_REQ_SEG_MISS');
4055 fnd_message.set_token('SEGMENT', l_segments_dr.segment_name(i));
4056 fnd_msg_pub.ADD;
4057 RAISE g_exc_error;
4058
4059 IF g_debug = 1 THEN
4060 print_debug('Req segment is not populated', 9);
4061 END IF;
4062 END IF;
4063 END IF;
4064
4065 IF p_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
4066 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
4067 fnd_flex_descval.set_column_value(
4068 l_segments_dr.application_column_name(i)
4069 , p_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i)
4070 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9))
4071 );
4072 ELSE
4073 fnd_flex_descval.set_column_value(l_segments_dr.application_column_name(i), l_null_char_val);
4074 END IF;
4075
4076 v_index := v_index + 1;
4077 END LOOP;
4078
4079 --IF l_enabled_seg_name.count = P_ATTRIBUTES_TBL.count THEN
4080 /*v_index1 := p_attributes_tbl.FIRST;
4081
4082 print_debug('l_enabled_seg_name.count is ' || l_enabled_seg_name.COUNT, 9);
4083 WHILE v_index1 <= p_attributes_tbl.LAST LOOP
4084 IF g_debug = 1 THEN
4085 print_debug('The value of segment is ' || v_index1, 9);
4086 END IF;
4087
4088 FOR i IN 1 .. l_enabled_seg_name.COUNT LOOP
4089 IF l_enabled_seg_name(i) = 'ATTRIBUTE' || v_index1 THEN
4090 print_debug('The value of segmentS have matched '||l_enabled_seg_name(i), 9);
4091 l_chk_flag := 1;
4092 EXIT;
4093 END IF;
4094 END LOOP;
4095
4096 IF l_chk_flag = 0 AND p_attributes_tbl(v_index1) IS NOT NULL THEN
4097 fnd_message.set_name('INV', 'INV_WRONG_SEG_POPULATE');
4098 fnd_message.set_token('SEGMENT', 'ATTRIBUTE' || v_index1);
4099 fnd_message.set_token('CONTEXT', l_context);
4100 fnd_msg_pub.ADD;
4101 --dbms_output.put_line('Error out. Correct segmenst are not populated ');
4102 RAISE g_exc_error;
4103 END IF;
4104
4105 v_index1 := p_attributes_tbl.NEXT(v_index1);
4106 l_chk_flag := 0;
4107 END LOOP;*/
4108 END IF;
4109 /*Make a call to FND_FLEX_DESCVAL.validate_desccols */
4110 IF (l_global_nsegments > 0 AND p_attribute_Category IS NULL ) THEN
4111 l_context := l_contexts_dr.context_code(l_global_context);
4112 fnd_flex_descval.set_context_value(l_context);
4113 end if;
4114 IF( l_global_nsegments > 0 OR p_attribute_category IS NOT NULL ) then
4115 IF fnd_flex_descval.validate_desccols(appl_short_name => 'INV', desc_flex_name => 'MTL_LOT_NUMBERS', values_or_ids => 'I'
4116 , validation_date => SYSDATE) THEN
4117 IF g_debug = 1 THEN
4118 print_debug('Value set validation successful', 9);
4119 END IF;
4120 ELSE
4121 IF g_debug = 1 THEN
4122 error_segment := fnd_flex_descval.error_segment;
4123 print_debug('Value set validation failed for segment ' || error_segment, 9);
4124 RAISE errors_received;
4125 END IF;
4126 END IF;
4127 END IF; /*If P attribute category is not null */
4128 --END IF; /* p_attribute_category IS NOT NULL */
4129
4130 /*Check If WMS is installed */
4131 IF p_wms_is_installed = 'TRUE' THEN
4132 wms_lot_attr_validate(
4133 x_return_status => l_return_status
4134 , x_msg_count => l_msg_count
4135 , x_msg_data => l_msg_data
4136 , p_inventory_item_id => p_inventory_item_id
4137 , p_organization_id => p_organization_id
4138 , p_disable_flag => p_disable_flag
4139 , p_lot_attribute_category => p_lot_attribute_category
4140 , p_c_attributes_tbl => p_c_attributes_tbl
4141 , p_n_attributes_tbl => p_n_attributes_tbl
4142 , p_d_attributes_tbl => p_d_attributes_tbl
4143 , p_grade_code => p_grade_code
4144 , p_origination_date => p_origination_date
4145 , p_date_code => p_date_code
4146 , p_change_date => p_change_date
4147 , p_age => p_age
4148 , p_retest_date => p_retest_date
4149 , p_maturity_date => p_maturity_date
4150 , p_item_size => p_item_size
4151 , p_color => p_color
4152 , p_volume => p_volume
4153 , p_volume_uom => p_volume_uom
4154 , p_place_of_origin => p_place_of_origin
4155 , p_best_by_date => p_best_by_date
4156 , p_length => p_length
4157 , p_length_uom => p_length_uom
4158 , p_recycled_content => p_recycled_content
4159 , p_thickness => p_thickness
4160 , p_thickness_uom => p_thickness_uom
4161 , p_width => p_width
4162 , p_width_uom => p_width_uom
4163 , p_territory_code => p_territory_code
4164 , p_supplier_lot_number => p_supplier_lot_number
4165 , p_vendor_name => p_vendor_name
4166 );
4167
4168 IF l_return_status = g_ret_sts_error THEN
4169 IF g_debug = 1 THEN
4170 print_debug('Program WMS_LOT_ATTR_VALIDATE has failed with a user defined exception', 9);
4171 print_debug('l_msg_data is ' || l_msg_data, 9);
4172 END IF;
4173 RAISE g_exc_error;
4174 ELSIF l_return_status = g_ret_sts_unexp_error THEN
4175 IF g_debug = 1 THEN
4176 print_debug('Program WMS_LOT_ATTR_VALIDATE has failed with a Unexpected exception', 9);
4177 END IF;
4178 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
4179 FND_MESSAGE.SET_TOKEN('PROG_NAME','WMS_LOT_ATTR_VALIDATE');
4180 fnd_msg_pub.ADD;
4181 RAISE g_exc_unexpected_error;
4182 END IF;
4183 END IF; /* If wms_is installed */
4184 EXCEPTION
4185 WHEN errors_received THEN
4186 x_return_status := g_ret_sts_error;
4187 error_msg := fnd_flex_descval.error_message;
4188 s := 1;
4189 e := 200;
4190
4191 --print_debug('Here are the error messages: ',9);
4192 WHILE e < 5001
4193 AND SUBSTR(error_msg, s, e) IS NOT NULL LOOP
4194 fnd_message.set_name('INV', 'INV_FND_GENERIC_MSG');
4195 fnd_message.set_token('MSG', SUBSTR(error_msg, s, e));
4196 fnd_msg_pub.ADD;
4197 print_debug(SUBSTR(error_msg, s, e), 9);
4198 s := s + 200;
4199 e := e + 200;
4200 END LOOP;
4201
4202 ROLLBACK TO get_lot_attr_information;
4203 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4204 WHEN g_exc_error THEN
4205 x_return_status := g_ret_sts_error;
4206 ROLLBACK TO get_lot_attr_information;
4207 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4208 WHEN g_exc_unexpected_error THEN
4209 x_return_status := g_ret_sts_unexp_error;
4210 ROLLBACK TO get_lot_attr_information;
4211 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4212 WHEN OTHERS THEN
4213 x_return_status := g_ret_sts_unexp_error;
4214 ROLLBACK TO get_lot_attr_information;
4215 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4216 print_debug('Error ' || SQLERRM, 9);
4217 END validate_lot_attr_info;
4218
4219
4220 PROCEDURE validate_lot_attr_in_param(
4221 x_return_status OUT NOCOPY VARCHAR2
4222 , x_msg_count OUT NOCOPY NUMBER
4223 , x_msg_data OUT NOCOPY VARCHAR2
4224 , p_inventory_item_id IN NUMBER
4225 , p_organization_id IN NUMBER
4226 , p_lot_number IN VARCHAR2
4227 , p_attribute_category IN VARCHAR2
4228 , p_lot_attribute_category IN VARCHAR2
4229 , p_attributes_tbl IN inv_lot_api_pub.char_tbl
4230 , p_c_attributes_tbl IN inv_lot_api_pub.char_tbl
4231 , p_n_attributes_tbl IN inv_lot_api_pub.number_tbl
4232 , p_d_attributes_tbl IN inv_lot_api_pub.date_tbl
4233 , p_wms_is_installed IN VARCHAR2
4234 , p_source IN NUMBER
4235 , p_disable_flag IN NUMBER
4236 , p_grade_code IN VARCHAR2
4237 , p_origination_date IN DATE
4238 , p_date_code IN VARCHAR2
4239 , p_change_date IN DATE
4240 , p_age IN NUMBER
4241 , p_retest_date IN DATE
4242 , p_maturity_date IN DATE
4243 , p_item_size IN NUMBER
4244 , p_color IN VARCHAR2
4245 , p_volume IN NUMBER
4246 , p_volume_uom IN VARCHAR2
4247 , p_place_of_origin IN VARCHAR2
4248 , p_best_by_date IN DATE
4249 , p_length IN NUMBER
4250 , p_length_uom IN VARCHAR2
4251 , p_recycled_content IN NUMBER
4252 , p_thickness IN NUMBER
4253 , p_thickness_uom IN VARCHAR2
4254 , p_width IN NUMBER
4255 , p_width_uom IN VARCHAR2
4256 , p_territory_code IN VARCHAR2
4257 , p_supplier_lot_number IN VARCHAR2
4258 , p_vendor_name IN VARCHAR2
4259 ) IS
4260 /*Program variables declaration */
4261 l_lot_control_code mtl_system_items_b.lot_control_code%TYPE;
4262 l_chk_lot_uniqueness BOOLEAN;
4263 l_wms_installed VARCHAR2(5);
4264 l_lot_number_uniqueness NUMBER;
4265 l_return_status VARCHAR2(1);
4266 l_msg_count NUMBER;
4267 l_msg_data VARCHAR2(3000);
4268 l_status NUMBER;
4269 BEGIN
4270 x_return_status := g_ret_sts_success;
4271 SAVEPOINT val_lot_attr;
4272
4273 BEGIN
4274 SELECT lot_control_code
4275 INTO l_lot_control_code
4276 FROM mtl_system_items
4277 WHERE inventory_item_id = p_inventory_item_id
4278 AND organization_id = p_organization_id;
4279
4280 /* If not lot controlled , then error out */
4281 IF (l_lot_control_code = 1) THEN
4282 IF g_debug = 1 THEN
4283 print_debug('Item is not lot controlled ', 9);
4284 END IF;
4285
4286 fnd_message.set_name('INV', 'INV_NO_LOT_CONTROL');
4287 fnd_msg_pub.ADD;
4288 x_return_status := fnd_api.g_ret_sts_error;
4289 RAISE g_exc_error;
4290 END IF;
4291 EXCEPTION
4292 WHEN NO_DATA_FOUND THEN
4293 IF (g_debug = 1) THEN
4294 print_debug('Exception in LOT_CONTROL_CODE', 9);
4295 END IF;
4296
4297 fnd_message.set_name('INV', 'INV_INVALID_ITEM');
4298 fnd_msg_pub.ADD;
4299 RAISE g_exc_error;
4300 END;
4301
4302 IF g_debug = 1 THEN
4303 print_debug('Item is lot controlled ', 9);
4304 END IF;
4305
4306 /* Get the Lot number uniqueness from mtl_parameters for the passed org_id
4307 oNE MESSAGE TO BE ADDED
4308 */
4309 BEGIN
4310 SELECT lot_number_uniqueness
4311 INTO l_lot_number_uniqueness
4312 FROM mtl_parameters
4313 WHERE organization_id = p_organization_id;
4314 EXCEPTION
4315 WHEN NO_DATA_FOUND THEN
4316 IF (g_debug = 1) THEN
4317 print_debug('Lot Number Uniqueness is not defined ', 9);
4318 END IF;
4319
4320 fnd_message.set_name('INV', 'INV_NO_UNIQUENESS_DEFN');
4321 /* Lot Number Uniqueness is not defined*/
4322 fnd_msg_pub.ADD;
4323 RAISE NO_DATA_FOUND;
4324 END;
4325
4326 /* Call the function to check the Lot Uniqueness */
4327 l_chk_lot_uniqueness :=
4328 inv_lot_api_pub.validate_unique_lot(
4329 p_org_id => p_organization_id
4330 , p_inventory_item_id => p_inventory_item_id
4331 , p_lot_uniqueness => l_lot_number_uniqueness
4332 , p_auto_lot_number => p_lot_number
4333 );
4334
4335 IF NOT l_chk_lot_uniqueness THEN
4336 fnd_message.set_name('INV', 'INV_LOT_UNIQUENESS');
4337 fnd_msg_pub.ADD;
4338
4339 IF g_debug = 1 THEN
4340 print_debug('Lot Number Uniqueness check failed ', 9);
4341 END IF;
4342
4343 RAISE g_exc_error;
4344 END IF;
4345
4346 IF g_debug = 1 THEN
4347 print_debug('Lot Number Uniqueness check passed successfully ', 9);
4348 END IF;
4349
4350 l_wms_installed := p_wms_is_installed;
4351
4352 /*If WMS is installed then accept both the inventory attributes and
4353 WMS attributes. If WMS is not installed then accept only Inventory
4354 attributes
4355 */
4356 --IF l_wms_installed = 'TRUE' THEN
4357 IF g_debug = 1 THEN
4358 print_debug('WMS installed is ' || l_wms_installed, 9);
4359 print_debug('p_attributes_tbl.count = ' || p_attributes_tbl.count, 9);
4360 END IF;
4361
4362 /* Check if the Attribute_Category has been populated */
4363
4364 /*IF p_attribute_category IS NULL THEN
4365 for i in 1..p_attributes_tbl.count LOOP
4366 if p_attributes_tbl(i) IS NOT NULL THEN
4367 fnd_message.set_name('INV', 'INV_NO_ATTRIBUTE_CATEGORY');
4368 fnd_msg_pub.ADD;
4369
4370 IF g_debug = 1 THEN
4371 print_debug('Attribute Category value is null', 9);
4372 END IF;
4373
4374 RAISE g_exc_error;
4375 end if;
4376 end loop;
4377 END IF;*/
4378
4379 /* Find out if the Inventory attributes are populated*/
4380 IF p_attributes_tbl.COUNT > 0 THEN
4381 IF g_debug = 1 THEN
4382 print_debug('The Inventory attributes are populated ', 9);
4383 END IF;
4384 END IF;
4385
4386 IF p_source NOT IN(osfm_form_no_validate) THEN
4387 validate_lot_attr_info(
4388 x_return_status => l_return_status
4389 , x_msg_count => l_msg_count
4390 , x_msg_data => l_msg_data
4391 , p_wms_is_installed => l_wms_installed
4392 , p_attribute_category => p_attribute_category
4393 , p_lot_attribute_category => p_lot_attribute_category
4394 , p_inventory_item_id => p_inventory_item_id
4395 , p_organization_id => p_organization_id
4396 , p_attributes_tbl => p_attributes_tbl
4397 , p_c_attributes_tbl => p_c_attributes_tbl
4398 , p_n_attributes_tbl => p_n_attributes_tbl
4399 , p_d_attributes_tbl => p_d_attributes_tbl
4400 , p_disable_flag => p_disable_flag
4401 , p_grade_code => p_grade_code
4402 , p_origination_date => p_origination_date
4403 , p_date_code => p_date_code
4404 , p_change_date => p_change_date
4405 , p_age => p_age
4406 , p_retest_date => p_retest_date
4407 , p_maturity_date => p_maturity_date
4408 , p_item_size => p_item_size
4409 , p_color => p_color
4410 , p_volume => p_volume
4411 , p_volume_uom => p_volume_uom
4412 , p_place_of_origin => p_place_of_origin
4413 , p_best_by_date => p_best_by_date
4414 , p_length => p_length
4415 , p_length_uom => p_length_uom
4416 , p_recycled_content => p_recycled_content
4417 , p_thickness => p_thickness
4418 , p_thickness_uom => p_thickness_uom
4419 , p_width => p_width
4420 , p_width_uom => p_width_uom
4421 , p_territory_code => p_territory_code
4422 , p_supplier_lot_number => p_supplier_lot_number
4423 , p_vendor_name => p_vendor_name
4424 );
4425
4426 IF l_return_status = g_ret_sts_error THEN
4427 IF g_debug = 1 THEN
4428 print_debug('Program get_lot_attr_info has failed with a user defined exception', 9);
4429 END IF;
4430 RAISE g_exc_error;
4431 ELSIF l_return_status = g_ret_sts_unexp_error THEN
4432 IF g_debug = 1 THEN
4433 print_debug('Program get_lot_attr_info has failed with a Unexpected exception', 9);
4434 END IF;
4435 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
4436 FND_MESSAGE.SET_TOKEN('PROG_NAME','get_lot_attr_info');
4437 fnd_msg_pub.ADD;
4438 RAISE g_exc_unexpected_error;
4439 END IF;
4440 END IF;
4441 EXCEPTION
4442 WHEN NO_DATA_FOUND THEN
4443 x_return_status := g_ret_sts_error;
4444 ROLLBACK TO val_lot_attr;
4445 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4446 print_debug('In No data found -val_lot_attr ' || SQLERRM, 9);
4447 WHEN g_exc_error THEN
4448 x_return_status := g_ret_sts_error;
4449 ROLLBACK TO val_lot_attr;
4450 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4451 print_debug('In g_exc_error -val_lot_attr' || SQLERRM, 9);
4452 WHEN g_exc_unexpected_error THEN
4453 x_return_status := g_ret_sts_unexp_error;
4454 ROLLBACK TO val_lot_attr;
4455 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4456 print_debug('In g_exc_unexpected_error val_lot_attr' || SQLERRM, 9);
4457 WHEN OTHERS THEN
4458 x_return_status := g_ret_sts_unexp_error;
4459 ROLLBACK TO val_lot_attr;
4460 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
4461 print_debug('In others val_lot_attr' || SQLERRM, 9);
4462 END validate_lot_attr_in_param;
4463
4464 -- nsinghi 5209065 START. Created new overloaded procedure.
4465 PROCEDURE update_inv_lot(
4466 x_return_status OUT NOCOPY VARCHAR2
4467 , x_msg_count OUT NOCOPY NUMBER
4468 , x_msg_data OUT NOCOPY VARCHAR2
4469 , x_lot_rec OUT NOCOPY MTL_LOT_NUMBERS%ROWTYPE
4470 , p_lot_rec IN MTL_LOT_NUMBERS%ROWTYPE
4471 , p_source IN NUMBER
4472 , p_api_version IN NUMBER
4473 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
4474 , p_commit IN VARCHAR2 := fnd_api.g_false
4475 )
4476 IS
4477 CURSOR inv_attributes_cur IS
4478 SELECT attribute1
4479 , attribute2
4480 , attribute3
4481 , attribute4
4482 , attribute5
4483 , attribute6
4484 , attribute7
4485 , attribute8
4486 , attribute9
4487 , attribute10
4488 , attribute11
4489 , attribute12
4490 , attribute13
4491 , attribute14
4492 , attribute15
4493 FROM mtl_lot_numbers
4494 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4495 AND organization_id = p_lot_rec.organization_id
4496 AND lot_number = p_lot_rec.lot_number;
4497
4498 CURSOR c_attributes_cur IS
4499 SELECT c_attribute1
4500 , c_attribute2
4501 , c_attribute3
4502 , c_attribute4
4503 , c_attribute5
4504 , c_attribute6
4505 , c_attribute7
4506 , c_attribute8
4507 , c_attribute9
4508 , c_attribute10
4509 , c_attribute11
4510 , c_attribute12
4511 , c_attribute13
4512 , c_attribute14
4513 , c_attribute15
4514 , c_attribute16
4515 , c_attribute17
4516 , c_attribute18
4517 , c_attribute19
4518 , c_attribute20
4519 FROM mtl_lot_numbers
4520 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4521 AND organization_id = p_lot_rec.organization_id
4522 AND lot_number = p_lot_rec.lot_number;
4523
4524 CURSOR n_attributes_cur IS
4525 SELECT n_attribute1
4526 , n_attribute2
4527 , n_attribute3
4528 , n_attribute4
4529 , n_attribute5
4530 , n_attribute6
4531 , n_attribute7
4532 , n_attribute8
4533 , n_attribute9
4534 , n_attribute10
4535 FROM mtl_lot_numbers
4536 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4537 AND organization_id = p_lot_rec.organization_id
4538 AND lot_number = p_lot_rec.lot_number;
4539
4540 CURSOR d_attributes_cur IS
4541 SELECT d_attribute1
4542 , d_attribute2
4543 , d_attribute3
4544 , d_attribute4
4545 , d_attribute5
4546 , d_attribute6
4547 , d_attribute7
4548 , d_attribute8
4549 , d_attribute9
4550 , d_attribute10
4551 FROM mtl_lot_numbers
4552 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4553 AND organization_id = p_lot_rec.organization_id
4554 AND lot_number = p_lot_rec.lot_number;
4555
4556 CURSOR attr_category_cur IS
4557 SELECT attribute_category
4558 , lot_attribute_category
4559 FROM mtl_lot_numbers
4560 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4561 AND organization_id = p_lot_rec.organization_id
4562 AND lot_number = p_lot_rec.lot_number;
4563
4564 CURSOR wms_named_attr IS
4565 SELECT grade_code
4566 , DISABLE_FLAG
4567 , origination_date
4568 , date_code
4569 , change_date
4570 , age
4571 , retest_date
4572 , maturity_date
4573 , item_size
4574 , color
4575 , volume
4576 , volume_uom
4577 , place_of_origin
4578 , best_by_date
4579 , length
4580 , length_uom
4581 , recycled_content
4582 , thickness
4583 , thickness_uom
4584 , width
4585 , width_uom
4586 , territory_code
4587 , supplier_lot_number
4588 , VENDOR_NAME
4589 FROM MTL_LOT_NUMBERS
4590 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4591 AND organization_id = p_lot_rec.organization_id
4592 AND lot_number = p_lot_rec.lot_number;
4593
4594 l_wms_named_attributes INV_LOT_API_PUB.wms_named_attributes;
4595 l_wms_named_attr wms_named_attr%ROWTYPE;
4596 l_attr_category_cur attr_category_cur%ROWTYPE;
4597 l_c_attributes_cur c_attributes_cur%ROWTYPE;
4598 l_n_attributes_cur n_attributes_cur%ROWTYPE;
4599 l_d_attributes_cur d_attributes_cur%ROWTYPE;
4600 l_inv_attributes_cur inv_attributes_cur%ROWTYPE;
4601 l_inv_attributes_tbl inv_lot_api_pub.char_tbl;
4602 l_c_attributes_tbl inv_lot_api_pub.char_tbl;
4603 l_n_attributes_tbl inv_lot_api_pub.number_tbl;
4604 l_d_attributes_tbl inv_lot_api_pub.date_tbl;
4605 /* Index variables for looping through the input tables*/
4606 l_attr_index NUMBER;
4607 l_c_attr_index NUMBER;
4608 l_n_attr_index NUMBER;
4609 l_d_attr_index NUMBER;
4610 l_return_status VARCHAR2(1);
4611 l_msg_data VARCHAR2(2000);
4612 l_msg_count NUMBER;
4613 l_wms_installed VARCHAR2(5);
4614 l_chk NUMBER;
4615 l_context VARCHAR2(1000);
4616 l_global_context BINARY_INTEGER;
4617 l_context_r fnd_dflex.context_r;
4618 l_contexts_dr fnd_dflex.contexts_dr;
4619 l_dflex_r fnd_dflex.dflex_r;
4620 l_segments_dr fnd_dflex.segments_dr;
4621 inv_global_index NUMBER;
4622 inv_context_index NUMBER;
4623 wms_global_index NUMBER;
4624 wms_context_index NUMBER;
4625 l_res_inv_attributes_tbl inv_lot_api_pub.char_tbl;
4626 l_res_c_attributes_tbl inv_lot_api_pub.char_tbl;
4627 l_res_n_attributes_tbl inv_lot_api_pub.number_tbl;
4628 l_res_d_attributes_tbl inv_lot_api_pub.date_tbl;
4629 /* Shelf life code constants */
4630 no_shelf_life_control CONSTANT NUMBER := 1;
4631 item_shelf_life_days CONSTANT NUMBER := 2;
4632 user_defined_exp_date CONSTANT NUMBER := 4;
4633 l_shelf_life_days mtl_system_items.shelf_life_days%TYPE;
4634 l_shelf_life_code mtl_system_items.shelf_life_code%TYPE;
4635 l_expiration_date mtl_lot_numbers.expiration_date%TYPE;
4636 l_global_nsegments NUMBER := 0;
4637 BEGIN
4638 x_return_status := g_ret_sts_success;
4639 SAVEPOINT upd_lot_attr;
4640
4641 IF g_debug = 1 THEN
4642 print_debug(p_err_msg => 'Update Lot Attr: The value of the input parametsrs are :', p_level => 9);
4643 print_debug(p_err_msg => 'Update Lot Attr: The value of the INVENTORY_ITEM_ID : ' || p_lot_rec.inventory_item_id, p_level => 9);
4644 print_debug(p_err_msg => 'Update Lot Attr: The value of ORGANIZATION_ID :' || p_lot_rec.organization_id, p_level => 9);
4645 print_debug(p_err_msg => 'Update Lot Attr: The value of LOT_NUMBER :' || p_lot_rec.lot_number, p_level => 9);
4646 print_debug(p_err_msg => 'Update Lot Attr: The value of PARENT LOT_NUMBER :' || p_lot_rec.parent_lot_number, p_level => 9);
4647
4648 print_debug(p_err_msg => 'Update Lot Attr: The value of the EXPIRATION_DATE :' || p_lot_rec.expiration_date, p_level => 9);
4649 print_debug(p_err_msg => 'Update Lot Attr: The value of the DISABLE_FLAG :' || p_lot_rec.disable_flag, p_level => 9);
4650 print_debug(p_err_msg => 'Update Lot Attr: The value of the ATTRIBUTE_CATEGORY :' || p_lot_rec.attribute_category, p_level => 9);
4651 print_debug(p_err_msg => 'Update Lot Attr: The value of the LOT_ATTRIBUTE_CATEGORY :' || p_lot_rec.lot_attribute_category, p_level => 9);
4652 print_debug(p_err_msg => 'Update Lot Attr: The value of the GRADE_CODE :' || p_lot_rec.grade_code, p_level => 9);
4653 print_debug(p_err_msg => 'Update Lot Attr: The value of the ORIGINATION_DATE :' || p_lot_rec.origination_date, p_level => 9);
4654 print_debug(p_err_msg => 'Update Lot Attr: The value of the DATE_CODE :' || p_lot_rec.date_code, p_level => 9);
4655 print_debug(p_err_msg => 'Update Lot Attr: The value of the STATUS_ID :' || p_lot_rec.status_id, p_level => 9);
4656 print_debug(p_err_msg => 'Update Lot Attr: The value of the CHANGE_DATE :' || p_lot_rec.change_date, p_level => 9);
4657 print_debug(p_err_msg => 'Update Lot Attr: The value of the AGE :' || p_lot_rec.age, p_level => 9);
4658 print_debug(p_err_msg => 'Update Lot Attr: The value of the RETEST_DATE :' || p_lot_rec.retest_date, p_level => 9);
4659 print_debug(p_err_msg => 'Update Lot Attr: The value of the MATURITY_DATE :' || p_lot_rec.maturity_date, p_level => 9);
4660 print_debug(p_err_msg => 'Update Lot Attr: The value of the ITEM_SIZE :' || p_lot_rec.item_size, p_level => 9);
4661 print_debug(p_err_msg => 'Update Lot Attr: The value of COLOR :' || p_lot_rec.color, p_level => 9);
4662 print_debug(p_err_msg => 'Update Lot Attr: The value of VOLUME :' || p_lot_rec.volume, p_level => 9);
4663 print_debug(p_err_msg => 'Update Lot Attr: The value of VOLUME_UOM :' || p_lot_rec.volume_uom, p_level => 9);
4664 print_debug(p_err_msg => 'Update Lot Attr: The value of PLACE_OF_ORIGIN :' || p_lot_rec.place_of_origin, p_level => 9);
4665 print_debug(p_err_msg => 'Update Lot Attr: The value of BEST_BY_DATE :' || p_lot_rec.best_by_date, p_level => 9);
4666 print_debug(p_err_msg => 'Update Lot Attr: The value of LENGTH :' || p_lot_rec.length, p_level => 9);
4667 print_debug(p_err_msg => 'Update Lot Attr: The value of LENGTH_UOM:' || p_lot_rec.length_uom, p_level => 9);
4668 print_debug(p_err_msg => 'Update Lot Attr: The value of RECYCLED_CONTENT :' || p_lot_rec.recycled_content, p_level => 9);
4669 print_debug(p_err_msg => 'Update Lot Attr: The value of THICKNESS :' || p_lot_rec.thickness, p_level => 9);
4670 print_debug(p_err_msg => 'Update Lot Attr: The value of THICKNESS_UOM :' || p_lot_rec.thickness_uom, p_level => 9);
4671 print_debug(p_err_msg => 'Update Lot Attr: The value of WIDTH :' || p_lot_rec.width, p_level => 9);
4672 print_debug(p_err_msg => 'Update Lot Attr: The value of WIDTH_UOM :' || p_lot_rec.width_uom, p_level => 9);
4673 print_debug(p_err_msg => 'Update Lot Attr: The value of Territory Code :' || p_lot_rec.territory_code, p_level => 9);
4674 print_debug(p_err_msg => 'Update Lot Attr: The value of VENDOR_NAME :' || p_lot_rec.vendor_name, p_level => 9);
4675 print_debug(p_err_msg => 'Update Lot Attr: The value of SUPPLIER_LOT_NUMBER :' || p_lot_rec.supplier_lot_number, p_level => 9);
4676 print_debug(p_err_msg => 'Update Lot Attr: The value of SUPPLIER_LOT_NUMBER :' || p_lot_rec.supplier_lot_number, p_level => 9);
4677 print_debug(p_err_msg => 'Update Lot Attr: The value of P_SOURCE :' || p_source, p_level => 9);
4678 END IF;
4679
4680 /* Check if this combination is valid */
4681 BEGIN
4682 SELECT 1
4683 INTO l_chk
4684 FROM mtl_lot_numbers
4685 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4686 AND organization_id = p_lot_rec.organization_id
4687 AND lot_number = p_lot_rec.lot_number;
4688 EXCEPTION
4689 WHEN NO_DATA_FOUND THEN
4690 IF g_debug = 1 THEN
4691 print_debug('Upd Lot Attr : Conmbination of Lot number,Item and Org does not exists', 9);
4692 END IF;
4693
4694 fnd_message.set_name('INV', 'INV_LOT_NOT_EXISTS');
4695 fnd_msg_pub.add;
4696 --fnd_message.set_token('LOT',p_lot_rec.lot_number);
4697 RAISE g_exc_error;
4698 END;
4699
4700 BEGIN
4701 SELECT shelf_life_days
4702 , shelf_life_code
4703 INTO l_shelf_life_days
4704 , l_shelf_life_code
4705 FROM mtl_system_items
4706 WHERE inventory_item_id = p_lot_rec.inventory_item_id
4707 AND organization_id = p_lot_rec.organization_id;
4708 EXCEPTION
4709 WHEN NO_DATA_FOUND THEN
4710 NULL;
4711 END;
4712
4713 /*Start of changes for bug 4888300 */
4714 IF ( l_shelf_life_code IN (item_shelf_life_days ,user_defined_exp_date)
4715 AND p_lot_rec.expiration_date IS NOT NULL ) THEN
4716 IF g_debug = 1 THEN
4717 print_debug('Shelf_life code is of type USER_DEFINED_EXP_DATE OR ITEM_SHELF_LIFE_DAYS', 9);
4718 END IF;
4719
4720 IF p_lot_rec.expiration_date <> g_miss_date THEN
4721 l_expiration_date := p_lot_rec.expiration_date;
4722 ELSE
4723 l_expiration_date := NULL;
4724 END IF;
4725 /*End of changes for bug 4888300 */
4726
4727 ELSE
4728 l_expiration_date := NULL; --4888300
4729 IF g_debug = 1 THEN
4730 print_debug('Shelf_life code is of type NO_SHELF_LIFE_CONTROL', 9);
4731 END IF;
4732 END IF;
4733
4734 --END IF; /* IF NOT in (OSFM_FORM.OSFM_OPEN_INTERFACE)*/ --4888300
4735
4736 OPEN attr_category_cur;
4737 FETCH attr_category_cur INTO l_attr_category_cur;
4738 CLOSE attr_category_cur;
4739
4740 IF g_debug = 1 THEN
4741 print_debug('Upd Lot Attr: After gteting the attribte category', 9);
4742 END IF;
4743
4744 OPEN inv_attributes_cur;
4745 FETCH inv_attributes_cur INTO l_inv_attributes_cur;
4746 CLOSE inv_attributes_cur;
4747 l_inv_attributes_tbl(1) := l_inv_attributes_cur.attribute1;
4748 l_inv_attributes_tbl(2) := l_inv_attributes_cur.attribute2;
4749 l_inv_attributes_tbl(3) := l_inv_attributes_cur.attribute3;
4750 l_inv_attributes_tbl(4) := l_inv_attributes_cur.attribute4;
4751 l_inv_attributes_tbl(5) := l_inv_attributes_cur.attribute5;
4752 l_inv_attributes_tbl(6) := l_inv_attributes_cur.attribute6;
4753 l_inv_attributes_tbl(7) := l_inv_attributes_cur.attribute7;
4754 l_inv_attributes_tbl(8) := l_inv_attributes_cur.attribute8;
4755 l_inv_attributes_tbl(9) := l_inv_attributes_cur.attribute9;
4756 l_inv_attributes_tbl(10) := l_inv_attributes_cur.attribute10;
4757 l_inv_attributes_tbl(11) := l_inv_attributes_cur.attribute11;
4758 l_inv_attributes_tbl(12) := l_inv_attributes_cur.attribute12;
4759 l_inv_attributes_tbl(13) := l_inv_attributes_cur.attribute13;
4760 l_inv_attributes_tbl(14) := l_inv_attributes_cur.attribute14;
4761 l_inv_attributes_tbl(15) := l_inv_attributes_cur.attribute15;
4762
4763 /* **************************New additions ************************************ */
4764 /*Get the Contexts for the flex definition and check if any of the columns are required.
4765 If it is required, populate the value in a new table l_res_inv_attributes_tbl with
4766 the l_inv_attributes_tbl. This is done INV attributes and wms attributes
4767 Following will be pseudo code
4768 1. Get the Global context from INV attributes
4769 2. Check if any of the segment is required(mandatory)
4770 3. If required populate the value in l_res_inv_attributes_tbl
4771 which is obtained from l_inv_attributes_tbl table
4772 4. Set the context to INV context and fetch the segments for this context
4773 5. Loop through the segments and find out if any of the segments are
4774 required (mandatory)
4775 6. If so populate the value at the corresponding index with the value obtained
4776 from l_inv_attributes_tbl table
4777 7. Now at this point of time we have l_res_inv_attributes_tbl has only those
4778 segments whose value are required(mandatory)
4779 8. Loop through the input table p_attributes_tbl and populate the
4780 corresponding values in the l_res_inv_attributes_tbl
4781 9. Set the flex field defn to Lot Attributes
4782 10. Get the global context for WMS attributes
4783 11. check if the applicaton column name is C_attribute,D_attribute or N_Attribute
4784 12. Check if the corresponding column is required or not. If req, populate the new
4785 table l_res_c_attributes_tbl, or l_res_d_attributes_tbl or l_res_n_attributes_tbl
4786 13. Set the context to Lot Attribute Category
4787 14. Fetch all the segments for the context
4788 15. Check if the corresponding column is required or not. If req, populate the new
4789 table l_res_c_attributes_tbl, or l_res_d_attributes_tbl or l_res_n_attributes_tbl
4790 16. Loop through the input tables p_c_attributes,p_d_attributes and p_n_attributes
4791 and populate the corresponding value in l_res_c_attributes_tbl,
4792 l_res_d_attributes_tbl,l_res_n_attributes_tbl
4793 */
4794 IF p_source NOT IN(osfm_form_no_validate) THEN
4795 IF g_debug = 1 THEN
4796 print_debug(p_err_msg => 'Source is Not From OSFM_FORM So validating the Inventory Attributes ..... ' , p_level => 9);
4797 END IF;
4798 --IF l_attr_category_cur.attribute_category IS NOT NULL THEN
4799 -- AND p_attributes_tbl.COUNT > 0 THEN
4800 /* Populate the flex field record */
4801 l_dflex_r.application_id := 401;
4802 l_dflex_r.flexfield_name := 'MTL_LOT_NUMBERS';
4803 /* Get all contexts */
4804 fnd_dflex.get_contexts(flexfield => l_dflex_r, contexts => l_contexts_dr);
4805 /* From the l_contexts_dr, get the position of the global context */
4806 l_global_context := l_contexts_dr.global_context;
4807 l_context := l_contexts_dr.context_code(l_global_context);
4808 /* Prepare the context_r type for getting the segments associated with the global context */
4809 l_context_r.flexfield := l_dflex_r;
4810 l_context_r.context_code := l_context;
4811 /*Get the segments for the context */
4812 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
4813
4814 /*Loop through the Segments table to see if any segments are required */
4815 --inv_global_index :=l_segments_dr.first;
4816 l_global_nsegments := l_segments_dr.nsegments;
4817
4818 FOR inv_global_index IN 1 .. l_segments_dr.nsegments LOOP
4819 IF l_segments_dr.is_required(inv_global_index) THEN
4820 l_res_inv_attributes_tbl(
4821 SUBSTR(
4822 l_segments_dr.application_column_name(inv_global_index)
4823 , INSTR(l_segments_dr.application_column_name(inv_global_index), 'ATTRIBUTE') + 9
4824 )
4825 ) :=
4826 l_inv_attributes_tbl(
4827 SUBSTR(
4828 l_segments_dr.application_column_name(inv_global_index)
4829 , INSTR(l_segments_dr.application_column_name(inv_global_index), 'ATTRIBUTE') + 9
4830 )
4831 );
4832 END IF;
4833 --inv_global_index :=l_segments_dr.next(inv_global_index);
4834 END LOOP;
4835 IF g_debug = 1 THEN
4836 print_debug(p_err_msg => 'Successfully validated INV global segments ..... ' , p_level => 9);
4837 END IF;
4838
4839
4840 /* Prepare the context_r type for getting the segments associated with the
4841 attribute_category */
4842 if( nvl(p_lot_rec.attribute_category, l_attr_category_cur.attribute_Category) IS NOT NULL ) THEN
4843
4844 l_context_r.flexfield := l_dflex_r;
4845 l_context_r.context_code := nvl(p_lot_rec.attribute_category, l_attr_category_cur.attribute_category);
4846 /*Get the segments for the context */
4847 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
4848 /*Loop through the Segments table to see if any segments are required */
4849 inv_context_index := NULL;
4850
4851 --inv_context_index :=l_segments_dr.first;
4852 FOR inv_context_index IN 1 .. l_segments_dr.nsegments LOOP
4853 IF l_segments_dr.is_required(inv_context_index) THEN
4854 l_res_inv_attributes_tbl(
4855 SUBSTR(
4856 l_segments_dr.application_column_name(inv_context_index)
4857 , INSTR(l_segments_dr.application_column_name(inv_context_index), 'ATTRIBUTE') + 9
4858 )
4859 ) :=
4860 l_inv_attributes_tbl(
4861 SUBSTR(
4862 l_segments_dr.application_column_name(inv_context_index)
4863 , INSTR(l_segments_dr.application_column_name(inv_context_index), 'ATTRIBUTE') + 9
4864 )
4865 );
4866 END IF;
4867 END LOOP;
4868 IF g_debug = 1 THEN
4869 print_debug(p_err_msg => 'Successfully validated INV input Context segments ..... ' , p_level => 9);
4870 END IF;
4871 END IF; /*IF l_attr_category_cur.attribute_category IS NOT NULL */
4872
4873 END IF; /*P_SOURCE NOT IN (OSFM_FORM)*/
4874
4875 IF (p_lot_rec.attribute1 = g_miss_char) THEN
4876 l_res_inv_attributes_tbl(1) := NULL;
4877 l_inv_attributes_tbl(1) := g_miss_char;
4878 ELSE
4879 l_res_inv_attributes_tbl(1) := p_lot_rec.attribute1;
4880 l_inv_attributes_tbl(1) := p_lot_rec.attribute1;
4881 END IF;
4882 IF (p_lot_rec.attribute2 = g_miss_char) THEN
4883 l_res_inv_attributes_tbl(2) := NULL;
4884 l_inv_attributes_tbl(2) := g_miss_char;
4885 ELSE
4886 l_res_inv_attributes_tbl(2) := p_lot_rec.attribute2;
4887 l_inv_attributes_tbl(2) := p_lot_rec.attribute2;
4888 END IF;
4889 IF (p_lot_rec.attribute3 = g_miss_char) THEN
4890 l_res_inv_attributes_tbl(3) := NULL;
4891 l_inv_attributes_tbl(3) := g_miss_char;
4892 ELSE
4893 l_res_inv_attributes_tbl(3) := p_lot_rec.attribute3;
4894 l_inv_attributes_tbl(3) := p_lot_rec.attribute3;
4895 END IF;
4896 IF (p_lot_rec.attribute4 = g_miss_char) THEN
4897 l_res_inv_attributes_tbl(4) := NULL;
4898 l_inv_attributes_tbl(4) := g_miss_char;
4899 ELSE
4900 l_res_inv_attributes_tbl(4) := p_lot_rec.attribute4;
4901 l_inv_attributes_tbl(4) := p_lot_rec.attribute4;
4902 END IF;
4903 IF (p_lot_rec.attribute5 = g_miss_char) THEN
4904 l_res_inv_attributes_tbl(5) := NULL;
4905 l_inv_attributes_tbl(5) := g_miss_char;
4906 ELSE
4907 l_res_inv_attributes_tbl(5) := p_lot_rec.attribute5;
4908 l_inv_attributes_tbl(5) := p_lot_rec.attribute5;
4909 END IF;
4910 IF (p_lot_rec.attribute6 = g_miss_char) THEN
4911 l_res_inv_attributes_tbl(6) := NULL;
4912 l_inv_attributes_tbl(6) := g_miss_char;
4913 ELSE
4914 l_res_inv_attributes_tbl(6) := p_lot_rec.attribute6;
4915 l_inv_attributes_tbl(6) := p_lot_rec.attribute6;
4916 END IF;
4917 IF (p_lot_rec.attribute7 = g_miss_char) THEN
4918 l_res_inv_attributes_tbl(7) := NULL;
4919 l_inv_attributes_tbl(7) := g_miss_char;
4920 ELSE
4921 l_res_inv_attributes_tbl(7) := p_lot_rec.attribute7;
4922 l_inv_attributes_tbl(7) := p_lot_rec.attribute7;
4923 END IF;
4924 IF (p_lot_rec.attribute8 = g_miss_char) THEN
4925 l_res_inv_attributes_tbl(8) := NULL;
4926 l_inv_attributes_tbl(8) := g_miss_char;
4927 ELSE
4928 l_res_inv_attributes_tbl(8) := p_lot_rec.attribute8;
4929 l_inv_attributes_tbl(8) := p_lot_rec.attribute8;
4930 END IF;
4931 IF (p_lot_rec.attribute9 = g_miss_char) THEN
4932 l_res_inv_attributes_tbl(9) := NULL;
4933 l_inv_attributes_tbl(9) := g_miss_char;
4934 ELSE
4935 l_res_inv_attributes_tbl(9) := p_lot_rec.attribute9;
4936 l_inv_attributes_tbl(9) := p_lot_rec.attribute9;
4937 END IF;
4938 IF (p_lot_rec.attribute10 = g_miss_char) THEN
4939 l_res_inv_attributes_tbl(10) := NULL;
4940 l_inv_attributes_tbl(10) := g_miss_char;
4941 ELSE
4942 l_res_inv_attributes_tbl(10) := p_lot_rec.attribute10;
4943 l_inv_attributes_tbl(10) := p_lot_rec.attribute10;
4944 END IF;
4945 IF (p_lot_rec.attribute11 = g_miss_char) THEN
4946 l_res_inv_attributes_tbl(11) := NULL;
4947 l_inv_attributes_tbl(11) := g_miss_char;
4948 ELSE
4949 l_res_inv_attributes_tbl(11) := p_lot_rec.attribute11;
4950 l_inv_attributes_tbl(11) := p_lot_rec.attribute11;
4951 END IF;
4952 IF (p_lot_rec.attribute12 = g_miss_char) THEN
4953 l_res_inv_attributes_tbl(12) := NULL;
4954 l_inv_attributes_tbl(12) := g_miss_char;
4955 ELSE
4956 l_res_inv_attributes_tbl(12) := p_lot_rec.attribute12;
4957 l_inv_attributes_tbl(12) := p_lot_rec.attribute12;
4958 END IF;
4959 IF (p_lot_rec.attribute13 = g_miss_char) THEN
4960 l_res_inv_attributes_tbl(13) := NULL;
4961 l_inv_attributes_tbl(13) := g_miss_char;
4962 ELSE
4963 l_res_inv_attributes_tbl(13) := p_lot_rec.attribute13;
4964 l_inv_attributes_tbl(13) := p_lot_rec.attribute13;
4965 END IF;
4966 IF (p_lot_rec.attribute14 = g_miss_char) THEN
4967 l_res_inv_attributes_tbl(14) := NULL;
4968 l_inv_attributes_tbl(14) := g_miss_char;
4969 ELSE
4970 l_res_inv_attributes_tbl(14) := p_lot_rec.attribute14;
4971 l_inv_attributes_tbl(14) := p_lot_rec.attribute14;
4972 END IF;
4973 IF (p_lot_rec.attribute15 = g_miss_char) THEN
4974 l_res_inv_attributes_tbl(15) := NULL;
4975 l_inv_attributes_tbl(15) := g_miss_char;
4976 ELSE
4977 l_res_inv_attributes_tbl(15) := p_lot_rec.attribute15;
4978 l_inv_attributes_tbl(15) := p_lot_rec.attribute15;
4979 END IF;
4980
4981
4982 IF g_debug = 1 THEN
4983 print_debug('Upd Lot Attr: After preparing the table INV_Attributes', 9);
4984 END IF;
4985
4986 IF G_WMS_INSTALLED is NULL then
4987 IF (inv_install.adv_inv_installed(NULL) = TRUE) THEN
4988 G_WMS_INSTALLED := 'TRUE';
4989 ELSE
4990 G_WMS_INSTALLED := 'FALSE';
4991 end if;
4992 end if;
4993 l_wms_installed := G_WMS_INSTALLED;
4994
4995 if g_debug = 1 then
4996 print_debug('Upd Lot Attr: l_wms_installed is ' || l_wms_installed, 9);
4997 print_debug('Upd Lot Attr: lot_attribute_category ' || p_lot_rec.lot_attribute_category, 9);
4998 end if;
4999
5000 IF l_wms_installed = 'TRUE' then
5001 IF g_debug = 1 THEN
5002 print_debug('Upd Lot Attr: WMS is installed ', 9);
5003 END IF;
5004
5005 IF p_lot_rec.lot_attribute_category IS NULL THEN
5006 inv_lot_sel_attr.get_context_code(l_context, p_lot_rec.organization_id, p_lot_rec.inventory_item_id, 'Lot Attributes');
5007 ELSE
5008 l_context := p_lot_rec.lot_attribute_category;
5009 END IF;
5010
5011 OPEN c_attributes_cur;
5012 FETCH c_attributes_cur INTO l_c_attributes_cur;
5013 CLOSE c_attributes_cur;
5014 OPEN n_attributes_cur;
5015 FETCH n_attributes_cur INTO l_n_attributes_cur;
5016 CLOSE n_attributes_cur;
5017 OPEN d_attributes_cur;
5018 FETCH d_attributes_cur INTO l_d_attributes_cur;
5019 CLOSE d_attributes_cur;
5020 OPEN wms_named_attr;
5021 FETCH wms_named_attr INTO l_wms_named_attr;
5022 CLOSE wms_named_attr;
5023 /*Populate the PL/SQL tables with the values obtained from the cursor*/
5024 l_c_attributes_tbl(1) := l_c_attributes_cur.c_attribute1;
5025 l_c_attributes_tbl(2) := l_c_attributes_cur.c_attribute2;
5026 l_c_attributes_tbl(3) := l_c_attributes_cur.c_attribute3;
5027 l_c_attributes_tbl(4) := l_c_attributes_cur.c_attribute4;
5028 l_c_attributes_tbl(5) := l_c_attributes_cur.c_attribute5;
5029 l_c_attributes_tbl(6) := l_c_attributes_cur.c_attribute6;
5030 l_c_attributes_tbl(7) := l_c_attributes_cur.c_attribute7;
5031 l_c_attributes_tbl(8) := l_c_attributes_cur.c_attribute8;
5032 l_c_attributes_tbl(9) := l_c_attributes_cur.c_attribute9;
5033 l_c_attributes_tbl(10) := l_c_attributes_cur.c_attribute10;
5034 l_c_attributes_tbl(11) := l_c_attributes_cur.c_attribute11;
5035 l_c_attributes_tbl(12) := l_c_attributes_cur.c_attribute12;
5036 l_c_attributes_tbl(13) := l_c_attributes_cur.c_attribute13;
5037 l_c_attributes_tbl(14) := l_c_attributes_cur.c_attribute14;
5038 l_c_attributes_tbl(15) := l_c_attributes_cur.c_attribute15;
5039 l_c_attributes_tbl(16) := l_c_attributes_cur.c_attribute16;
5040 l_c_attributes_tbl(17) := l_c_attributes_cur.c_attribute17;
5041 l_c_attributes_tbl(18) := l_c_attributes_cur.c_attribute18;
5042 l_c_attributes_tbl(19) := l_c_attributes_cur.c_attribute19;
5043 l_c_attributes_tbl(20) := l_c_attributes_cur.c_attribute20;
5044 l_n_attributes_tbl(1) := l_n_attributes_cur.n_attribute1;
5045 l_n_attributes_tbl(2) := l_n_attributes_cur.n_attribute2;
5046 l_n_attributes_tbl(3) := l_n_attributes_cur.n_attribute3;
5047 l_n_attributes_tbl(4) := l_n_attributes_cur.n_attribute4;
5048 l_n_attributes_tbl(5) := l_n_attributes_cur.n_attribute5;
5049 l_n_attributes_tbl(6) := l_n_attributes_cur.n_attribute6;
5050 l_n_attributes_tbl(7) := l_n_attributes_cur.n_attribute7;
5051 l_n_attributes_tbl(8) := l_n_attributes_cur.n_attribute8;
5052 l_n_attributes_tbl(9) := l_n_attributes_cur.n_attribute9;
5053 l_n_attributes_tbl(10) := l_n_attributes_cur.n_attribute10;
5054 l_d_attributes_tbl(1) := l_d_attributes_cur.d_attribute1;
5055 l_d_attributes_tbl(2) := l_d_attributes_cur.d_attribute2;
5056 l_d_attributes_tbl(3) := l_d_attributes_cur.d_attribute3;
5057 l_d_attributes_tbl(4) := l_d_attributes_cur.d_attribute4;
5058 l_d_attributes_tbl(5) := l_d_attributes_cur.d_attribute5;
5059 l_d_attributes_tbl(6) := l_d_attributes_cur.d_attribute6;
5060 l_d_attributes_tbl(7) := l_d_attributes_cur.d_attribute7;
5061 l_d_attributes_tbl(8) := l_d_attributes_cur.d_attribute8;
5062 l_d_attributes_tbl(9) := l_d_attributes_cur.d_attribute9;
5063 l_d_attributes_tbl(10) := l_d_attributes_cur.d_attribute10;
5064
5065 l_wms_named_attributes.grade_code := p_lot_rec.grade_code;
5066 l_wms_named_attributes.DISABLE_FLAG := p_lot_rec.disable_flag;
5067 l_wms_named_attributes.origination_date := p_lot_rec.origination_date;
5068 l_wms_named_attributes.date_code := p_lot_rec.date_code;
5069 l_wms_named_attributes.change_date := p_lot_rec.change_date;
5070 l_wms_named_attributes.age := p_lot_rec.age;
5071 l_wms_named_attributes.retest_date := p_lot_rec.retest_date;
5072 l_wms_named_attributes.maturity_date := p_lot_rec.maturity_date;
5073 l_wms_named_attributes.item_size := p_lot_rec.item_size;
5074 l_wms_named_attributes.color := p_lot_rec.color;
5075 l_wms_named_attributes.volume := p_lot_rec.volume;
5076 l_wms_named_attributes.volume_uom := p_lot_rec.volume_uom;
5077 l_wms_named_attributes.place_of_origin := p_lot_rec.place_of_origin;
5078 l_wms_named_attributes.best_by_date := p_lot_rec.best_by_date;
5079 l_wms_named_attributes.length := p_lot_rec.length;
5080 l_wms_named_attributes.length_uom := p_lot_rec.length_uom;
5081 l_wms_named_attributes.recycled_content := p_lot_rec.recycled_content;
5082 l_wms_named_attributes.thickness := p_lot_rec.thickness;
5083 l_wms_named_attributes.thickness_uom := p_lot_rec.thickness_uom;
5084 l_wms_named_attributes.width := p_lot_rec.width;
5085 l_wms_named_attributes.width_uom := p_lot_rec.width_uom;
5086 l_wms_named_attributes.territory_code := p_lot_rec.territory_code;
5087 l_wms_named_attributes.supplier_lot_number := p_lot_rec.supplier_lot_number;
5088 l_wms_named_attributes.VENDOR_NAME := p_lot_rec.vendor_name;
5089
5090 IF g_debug = 1 THEN
5091 print_debug('Upd Lot Attr: After getting attributes from the table MLN ' , 9);
5092 END IF;
5093
5094 IF p_source NOT IN(osfm_form_no_validate) THEN
5095 IF g_debug = 1 THEN
5096 print_debug('Validating the Global Segments for WMS context ....' , 9);
5097 END IF;
5098 IF l_context IS NOT NULL THEN
5099 /* Populate the flex field record */
5100
5101 l_dflex_r.application_id := 401;
5102 l_dflex_r.flexfield_name := 'Lot Attributes';
5103
5104 /* Get all contexts */
5105
5106 fnd_dflex.get_contexts(flexfield => l_dflex_r, contexts => l_contexts_dr);
5107 l_context := NULL;
5108 l_global_context := NULL;
5109
5110 /* From the l_contexts_dr, get the position of the global context */
5111
5112 l_global_context := l_contexts_dr.global_context;
5113 l_context := l_contexts_dr.context_code(l_global_context);
5114
5115 /* Prepare the context_r type for getting the segments associated with the global context */
5116
5117 l_context_r.flexfield := l_dflex_r;
5118 l_context_r.context_code := l_context;
5119
5120 /*Get the segments for the context */
5121
5122 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
5123
5124 /*Loop through the Segments table to see if any segments are required */
5125
5126 --wms_global_index :=l_segments_dr.first;
5127 FOR wms_global_index IN 1 .. l_segments_dr.nsegments LOOP
5128 IF l_segments_dr.is_required(wms_global_index) THEN
5129 --print_debug('Segment '|| l_segments_dr.application_column_name(wms_global_index)||'is required',9);
5130 IF SUBSTR(l_segments_dr.application_column_name(wms_global_index), INSTR(l_segments_dr.application_column_name(wms_global_index),'ATTRIBUTE')-2, 2) = 'C_' THEN
5131 l_res_c_attributes_tbl(
5132 SUBSTR(
5133 l_segments_dr.application_column_name(wms_global_index)
5134 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5135 )
5136 ) :=
5137 l_c_attributes_tbl(
5138 SUBSTR(
5139 l_segments_dr.application_column_name(wms_global_index)
5140 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5141 )
5142 );
5143 --print_debug('upd Lot Attr tHE VALUE ENTERED IS '|| l_c_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(wms_global_index), INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9)), 9);
5144 ELSIF SUBSTR(l_segments_dr.application_column_name(wms_global_index), INSTR(l_segments_dr.application_column_name(wms_global_index),'ATTRIBUTE')-2, 2) = 'N_' THEN
5145 l_res_n_attributes_tbl(
5146 SUBSTR(
5147 l_segments_dr.application_column_name(wms_global_index)
5148 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5149 )
5150 ) :=
5151 l_n_attributes_tbl(
5152 SUBSTR(
5153 l_segments_dr.application_column_name(wms_global_index)
5154 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5155 )
5156 );
5157 ELSIF SUBSTR(l_segments_dr.application_column_name(wms_global_index), INSTR(l_segments_dr.application_column_name(wms_global_index),'ATTRIBUTE')-2, 2) = 'D_' THEN
5158 l_res_d_attributes_tbl(
5159 SUBSTR(
5160 l_segments_dr.application_column_name(wms_global_index)
5161 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5162 )
5163 ) :=
5164 l_d_attributes_tbl(
5165 SUBSTR(
5166 l_segments_dr.application_column_name(wms_global_index)
5167 , INSTR(l_segments_dr.application_column_name(wms_global_index), 'ATTRIBUTE') + 9
5168 )
5169 );
5170 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'GRADE_CODE' THEN
5171 l_wms_named_attributes.grade_code := NVL(l_wms_named_attributes.grade_code,l_wms_named_attr.GRADE_CODE);
5172 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'DISABLE_FLAG' THEN
5173 l_wms_named_attributes.DISABLE_FLAG := NVL(l_wms_named_attributes.DISABLE_FLAG,l_wms_named_attr.DISABLE_FLAG);
5174 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'ORIGINATION_DATE' THEN
5175 l_wms_named_attributes.origination_date := NVL(l_wms_named_attributes.origination_date,L_WMS_NAMED_ATTR.origination_date);
5176 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'DATE_CODE' THEN
5177 l_wms_named_attributes.date_code := NVL(l_wms_named_attributes.date_code,l_wms_named_attr.DATE_CODE);
5178 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'CHANGE_DATE' THEN
5179 l_wms_named_attributes.change_date := NVL(l_wms_named_attributes.change_date,l_wms_named_attr.CHANGE_DATE);
5180 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'AGE' THEN
5181 l_wms_named_attributes.age := NVL(l_wms_named_attributes.age,l_wms_named_attr.AGE);
5182 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'RETEST_DATE' THEN
5183 l_wms_named_attributes.retest_date :=NVL(l_wms_named_attributes.retest_date ,l_wms_named_attr.retest_date);
5184 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'MATURITY_DATE' THEN
5185 l_wms_named_attributes.maturity_date := NVL(l_wms_named_attributes.maturity_date,l_wms_named_attr.MATURITY_DATE) ;
5186 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'ITEM_SIZE' THEN
5187 l_wms_named_attributes.item_size := NVL(l_wms_named_attributes.item_size,l_wms_named_attr.ITEM_SIZE);
5188 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'COLOR' THEN
5189 l_wms_named_attributes.color := nvl(l_wms_named_attributes.color,l_wms_named_attr.COLOR);
5190 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'VOLUME' THEN
5191 l_wms_named_attributes.volume := NVL(l_wms_named_attributes.volume,l_wms_named_attr.VOLUME);
5192 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'VOLUME_UOM' THEN
5193 l_wms_named_attributes.volume_uom := NVL(l_wms_named_attributes.volume_uom,l_wms_named_attr.VOLUME_UOM);
5194 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'PLACE_OF_ORIGIN' THEN
5195 l_wms_named_attributes.place_of_origin := nvl(l_wms_named_attributes.place_of_origin,l_wms_named_attr.PLACE_OF_ORIGIN);
5196 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'BEST_BY_DATE' THEN
5197 l_wms_named_attributes.best_by_date := NVL(l_wms_named_attributes.best_by_date,l_wms_named_attr.BEST_BY_DATE);
5198 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'LENGTH' THEN
5199 l_wms_named_attributes.length := nvl(l_wms_named_attributes.length,l_wms_named_attr.LENGTH);
5200 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'RECYCLED_CONTENT' THEN
5201 l_wms_named_attributes.recycled_content := NVL(l_wms_named_attributes.recycled_content,l_wms_named_attr.RECYCLED_CONTENT);
5202 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'THICKNESS' THEN
5203 l_wms_named_attributes.thickness := NVL(l_wms_named_attributes.thickness,l_wms_named_attr.THICKNESS);
5204 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'THICKNESS_UOM' THEN
5205 l_wms_named_attributes.thickness_uom := NVL(l_wms_named_attributes.thickness_uom,l_wms_named_attr.THICKNESS_UOM);
5206 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'WIDTH' THEN
5207 l_wms_named_attributes.width := NVL(l_wms_named_attributes.width,l_wms_named_attr.WIDTH);
5208 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'WIDTH_UOM' THEN
5209 l_wms_named_attributes.width_uom := NVL(l_wms_named_attributes.width_uom,l_wms_named_attr.WIDTH_UOM);
5210 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'TERRITORY_CODE' THEN
5211 l_wms_named_attributes.territory_code := NVL(l_wms_named_attributes.territory_code,l_wms_named_attr.TERRITORY_CODE);
5212 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'SUPPLIER_LOT_NUMBER' THEN
5213 l_wms_named_attributes.supplier_lot_number := NVL(l_wms_named_attributes.supplier_lot_number,l_wms_named_attr.SUPPLIER_LOT_NUMBER);
5214 ELSIF l_segments_dr.application_column_name(wms_global_index) = 'VENDOR_NAME' THEN
5215 l_wms_named_attributes.VENDOR_NAME := NVL(l_wms_named_attributes.VENDOR_NAME,l_wms_named_attr.VENDOR_NAME);
5216 END IF; /*SUBSTR(l_segments_dr.application_column_name(wms_global_index), 1, 1) = 'C' */
5217 END IF; /*l_segments_dr.is_required(wms_global_index) */
5218 --wms_global_index :=l_segments_dr.next(wms_global_index);
5219 END LOOP;
5220 IF g_debug = 1 THEN
5221 print_debug('Successfully Validated the Global Segments for WMS DFF ....' , 9);
5222 END IF;
5223
5224 l_context := NULL;
5225
5226 IF p_lot_rec.lot_attribute_category IS NULL THEN
5227 inv_lot_sel_attr.get_context_code(l_context, p_lot_rec.organization_id, p_lot_rec.inventory_item_id, 'Lot Attributes');
5228 ELSE
5229 l_context := p_lot_rec.lot_attribute_category;
5230 END IF;
5231
5232 /* Prepare the context_r type for getting the segments associated with the global context */
5233 l_context_r.flexfield := l_dflex_r;
5234 l_context_r.context_code := l_context;
5235 /*Get the segments for the context */
5236 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
5237 /*Loop through the Segments table to see if any segments are required */
5238 --wms_context_index :=l_segments_dr.first;
5239 print_debug('Before looping for wms context', 9);
5240
5241 FOR wms_context_index IN 1 .. l_segments_dr.nsegments LOOP
5242 IF l_segments_dr.is_required(wms_context_index) THEN
5243 print_debug('Segment ' || l_segments_dr.application_column_name(wms_context_index) || ' is required', 9);
5244
5245 IF SUBSTR(l_segments_dr.application_column_name(wms_context_index), INSTR(l_segments_dr.application_column_name(wms_context_index),'ATTRIBUTE')-2, 2) = 'C_' THEN
5246 l_res_c_attributes_tbl(
5247 SUBSTR(
5248 l_segments_dr.application_column_name(wms_context_index)
5249 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5250 )
5251 ) :=
5252 l_c_attributes_tbl(
5253 SUBSTR(
5254 l_segments_dr.application_column_name(wms_context_index)
5255 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5256 )
5257 );
5258 ELSIF SUBSTR(l_segments_dr.application_column_name(wms_context_index), INSTR(l_segments_dr.application_column_name(wms_context_index),'ATTRIBUTE')-2, 2) = 'N_' THEN
5259 l_res_n_attributes_tbl(
5260 SUBSTR(
5261 l_segments_dr.application_column_name(wms_context_index)
5262 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5263 )
5264 ) :=
5265 l_n_attributes_tbl(
5266 SUBSTR(
5267 l_segments_dr.application_column_name(wms_context_index)
5268 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5269 )
5270 );
5271 ELSIF SUBSTR(l_segments_dr.application_column_name(wms_context_index), INSTR(l_segments_dr.application_column_name(wms_context_index),'ATTRIBUTE')-2, 2) = 'D_' THEN
5272 l_res_d_attributes_tbl(
5273 SUBSTR(
5274 l_segments_dr.application_column_name(wms_context_index)
5275 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5276 )
5277 ) :=
5278 l_d_attributes_tbl(
5279 SUBSTR(
5280 l_segments_dr.application_column_name(wms_context_index)
5281 , INSTR(l_segments_dr.application_column_name(wms_context_index), 'ATTRIBUTE') + 9
5282 )
5283 );
5284 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'GRADE_CODE' THEN
5285 l_wms_named_attributes.grade_code := NVL(l_wms_named_attributes.grade_code,l_wms_named_attr.GRADE_CODE);
5286 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'DISABLE_FLAG' THEN
5287 l_wms_named_attributes.DISABLE_FLAG := NVL(l_wms_named_attributes.DISABLE_FLAG,l_wms_named_attr.DISABLE_FLAG);
5288 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'ORIGINATION_DATE' THEN
5289 l_wms_named_attributes.origination_date := NVL(l_wms_named_attributes.origination_date,L_WMS_NAMED_ATTR.origination_date);
5290 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'DATE_CODE' THEN
5291 l_wms_named_attributes.date_code := NVL(l_wms_named_attributes.date_code,l_wms_named_attr.DATE_CODE);
5292 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'CHANGE_DATE' THEN
5293 l_wms_named_attributes.change_date := NVL(l_wms_named_attributes.change_date,l_wms_named_attr.CHANGE_DATE);
5294 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'AGE' THEN
5295 l_wms_named_attributes.age := NVL(l_wms_named_attributes.age,l_wms_named_attr.AGE);
5296 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'RETEST_DATE' THEN
5297 l_wms_named_attributes.retest_date :=NVL(l_wms_named_attributes.retest_date ,l_wms_named_attr.retest_date);
5298 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'MATURITY_DATE' THEN
5299 l_wms_named_attributes.maturity_date := NVL(l_wms_named_attributes.maturity_date,l_wms_named_attr.MATURITY_DATE);
5300 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'ITEM_SIZE' THEN
5301 l_wms_named_attributes.item_size := NVL(l_wms_named_attributes.item_size,l_wms_named_attr.ITEM_SIZE);
5302 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'COLOR' THEN
5303 l_wms_named_attributes.color := nvl(l_wms_named_attributes.color,l_wms_named_attr.COLOR);
5304 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'VOLUME' THEN
5305 l_wms_named_attributes.volume := NVL(l_wms_named_attributes.volume,l_wms_named_attr.VOLUME);
5306 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'VOLUME_UOM' THEN
5307 l_wms_named_attributes.volume_uom := NVL(l_wms_named_attributes.volume_uom,l_wms_named_attr.VOLUME_UOM);
5308 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'PLACE_OF_ORIGIN' THEN
5309 l_wms_named_attributes.place_of_origin := nvl(l_wms_named_attributes.place_of_origin,l_wms_named_attr.PLACE_OF_ORIGIN);
5310 IF G_DEBUG =1 THEN
5311 PRINT_DEBUG('After assigninig Place of origin',9);
5312 END IF;
5313 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'BEST_BY_DATE' THEN
5314 l_wms_named_attributes.best_by_date := NVL(l_wms_named_attributes.best_by_date,l_wms_named_attr.BEST_BY_DATE);
5315 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'LENGTH' THEN
5316 l_wms_named_attributes.length := nvl(l_wms_named_attributes.length,l_wms_named_attr.LENGTH);
5317 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'RECYCLED_CONTENT' THEN
5318 l_wms_named_attributes.recycled_content := NVL(l_wms_named_attributes.recycled_content,l_wms_named_attr.RECYCLED_CONTENT);
5319 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'THICKNESS' THEN
5320 l_wms_named_attributes.thickness := NVL(l_wms_named_attributes.thickness,l_wms_named_attr.THICKNESS);
5321 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'THICKNESS_UOM' THEN
5322 l_wms_named_attributes.thickness_uom := NVL(l_wms_named_attributes.thickness_uom,l_wms_named_attr.THICKNESS_UOM);
5323 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'WIDTH' THEN
5324 l_wms_named_attributes.width := NVL(l_wms_named_attributes.width,l_wms_named_attr.WIDTH);
5325 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'WIDTH_UOM' THEN
5326 l_wms_named_attributes.width_uom := NVL(l_wms_named_attributes.width_uom,l_wms_named_attr.WIDTH_UOM);
5327 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'TERRITORY_CODE' THEN
5328 IF G_DEBUG =1 THEN
5329 PRINT_DEBUG('After Territory code '||l_wms_named_attributes.territory_code,9);
5330 PRINT_DEBUG('l_wms_named_attr Territory code '||l_wms_named_attr.TERRITORY_CODE,9);
5331 END IF;
5332 l_wms_named_attributes.territory_code := NVL(l_wms_named_attributes.territory_code,l_wms_named_attr.TERRITORY_CODE);
5333 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'SUPPLIER_LOT_NUMBER' THEN
5334 l_wms_named_attributes.supplier_lot_number := NVL(l_wms_named_attributes.supplier_lot_number,l_wms_named_attr.SUPPLIER_LOT_NUMBER);
5335 ELSIF l_segments_dr.application_column_name(wms_context_index) = 'VENDOR_NAME' THEN
5336 l_wms_named_attributes.VENDOR_NAME := NVL(l_wms_named_attributes.VENDOR_NAME,l_wms_named_attr.VENDOR_NAME);
5337 END IF; /*SUBSTR(l_segments_dr.application_column_name(wms_context_index), 1, 1) = 'C' */
5338 END IF;
5339 --wms_context_index :=l_segments_dr.next(wms_context_index);
5340 END LOOP;
5341 END IF; /*l_context IS NOT NULL */
5342 IF g_debug = 1 THEN
5343 print_debug('Successfully Validated the Segments for passed WMS context ....' , 9);
5344 END IF;
5345 END IF; /* P_SOURCE NOT IN (OSFM_FORM) */
5346
5347 IF g_debug = 1 THEN
5348 print_debug('Preparing input Table for validation ....' , 9);
5349 END IF;
5350
5351 IF (p_lot_rec.c_attribute1 = g_miss_char) THEN
5352 l_res_c_attributes_tbl(1) := NULL;
5353 l_c_attributes_tbl(1) := g_miss_char;
5354 ELSE
5355 l_res_c_attributes_tbl(1) := p_lot_rec.c_attribute1;
5356 l_c_attributes_tbl(1) := p_lot_rec.c_attribute1;
5357 END IF;
5358 IF (p_lot_rec.c_attribute2 = g_miss_char) THEN
5359 l_res_c_attributes_tbl(2) := NULL;
5360 l_c_attributes_tbl(2) := g_miss_char;
5361 ELSE
5362 l_res_c_attributes_tbl(2) := p_lot_rec.c_attribute2;
5363 l_c_attributes_tbl(2) := p_lot_rec.c_attribute2;
5364 END IF;
5365 IF (p_lot_rec.c_attribute3 = g_miss_char) THEN
5366 l_res_c_attributes_tbl(3) := NULL;
5367 l_c_attributes_tbl(3) := g_miss_char;
5368 ELSE
5369 l_res_c_attributes_tbl(3) := p_lot_rec.c_attribute3;
5370 l_c_attributes_tbl(3) := p_lot_rec.c_attribute3;
5371 END IF;
5372 IF (p_lot_rec.c_attribute4 = g_miss_char) THEN
5373 l_res_c_attributes_tbl(4) := NULL;
5374 l_c_attributes_tbl(4) := g_miss_char;
5375 ELSE
5376 l_res_c_attributes_tbl(4) := p_lot_rec.c_attribute4;
5377 l_c_attributes_tbl(4) := p_lot_rec.c_attribute4;
5378 END IF;
5379 IF (p_lot_rec.c_attribute5 = g_miss_char) THEN
5380 l_res_c_attributes_tbl(5) := NULL;
5381 l_c_attributes_tbl(5) := g_miss_char;
5382 ELSE
5383 l_res_c_attributes_tbl(5) := p_lot_rec.c_attribute5;
5384 l_c_attributes_tbl(5) := p_lot_rec.c_attribute5;
5385 END IF;
5386 IF (p_lot_rec.c_attribute6 = g_miss_char) THEN
5387 l_res_c_attributes_tbl(6) := NULL;
5388 l_c_attributes_tbl(6) := g_miss_char;
5389 ELSE
5390 l_res_c_attributes_tbl(6) := p_lot_rec.c_attribute6;
5391 l_c_attributes_tbl(6) := p_lot_rec.c_attribute6;
5392 END IF;
5393 IF (p_lot_rec.c_attribute7 = g_miss_char) THEN
5394 l_res_c_attributes_tbl(7) := NULL;
5395 l_c_attributes_tbl(7) := g_miss_char;
5396 ELSE
5397 l_res_c_attributes_tbl(7) := p_lot_rec.c_attribute7;
5398 l_c_attributes_tbl(7) := p_lot_rec.c_attribute7;
5399 END IF;
5400 IF (p_lot_rec.c_attribute8 = g_miss_char) THEN
5401 l_res_c_attributes_tbl(8) := NULL;
5402 l_c_attributes_tbl(8) := g_miss_char;
5403 ELSE
5404 l_res_c_attributes_tbl(8) := p_lot_rec.c_attribute8;
5405 l_c_attributes_tbl(8) := p_lot_rec.c_attribute8;
5406 END IF;
5407 IF (p_lot_rec.c_attribute9 = g_miss_char) THEN
5408 l_res_c_attributes_tbl(9) := NULL;
5409 l_c_attributes_tbl(9) := g_miss_char;
5410 ELSE
5411 l_res_c_attributes_tbl(9) := p_lot_rec.c_attribute9;
5412 l_c_attributes_tbl(9) := p_lot_rec.c_attribute9;
5413 END IF;
5414 IF (p_lot_rec.c_attribute10 = g_miss_char) THEN
5415 l_res_c_attributes_tbl(10) := NULL;
5416 l_c_attributes_tbl(10) := g_miss_char;
5417 ELSE
5418 l_res_c_attributes_tbl(10) := p_lot_rec.c_attribute10;
5419 l_c_attributes_tbl(10) := p_lot_rec.c_attribute10;
5420 END IF;
5421 IF (p_lot_rec.c_attribute11 = g_miss_char) THEN
5422 l_res_c_attributes_tbl(11) := NULL;
5423 l_c_attributes_tbl(11) := g_miss_char;
5424 ELSE
5425 l_res_c_attributes_tbl(11) := p_lot_rec.c_attribute11;
5426 l_c_attributes_tbl(11) := p_lot_rec.c_attribute11;
5427 END IF;
5428 IF (p_lot_rec.c_attribute12 = g_miss_char) THEN
5429 l_res_c_attributes_tbl(12) := NULL;
5430 l_c_attributes_tbl(12) := g_miss_char;
5431 ELSE
5432 l_res_c_attributes_tbl(12) := p_lot_rec.c_attribute12;
5433 l_c_attributes_tbl(12) := p_lot_rec.c_attribute12;
5434 END IF;
5435 IF (p_lot_rec.c_attribute13 = g_miss_char) THEN
5436 l_res_c_attributes_tbl(13) := NULL;
5437 l_c_attributes_tbl(13) := g_miss_char;
5438 ELSE
5439 l_res_c_attributes_tbl(13) := p_lot_rec.c_attribute13;
5440 l_c_attributes_tbl(13) := p_lot_rec.c_attribute13;
5441 END IF;
5442 IF (p_lot_rec.c_attribute14 = g_miss_char) THEN
5443 l_res_c_attributes_tbl(14) := NULL;
5444 l_c_attributes_tbl(14) := g_miss_char;
5445 ELSE
5446 l_res_c_attributes_tbl(14) := p_lot_rec.c_attribute14;
5447 l_c_attributes_tbl(14) := p_lot_rec.c_attribute14;
5448 END IF;
5449 IF (p_lot_rec.c_attribute15 = g_miss_char) THEN
5450 l_res_c_attributes_tbl(15) := NULL;
5451 l_c_attributes_tbl(15) := g_miss_char;
5452 ELSE
5453 l_res_c_attributes_tbl(15) := p_lot_rec.c_attribute15;
5454 l_c_attributes_tbl(15) := p_lot_rec.c_attribute15;
5455 END IF;
5456 IF (p_lot_rec.c_attribute16 = g_miss_char) THEN
5457 l_res_c_attributes_tbl(16) := NULL;
5458 l_c_attributes_tbl(16) := g_miss_char;
5459 ELSE
5460 l_res_c_attributes_tbl(16) := p_lot_rec.c_attribute16;
5461 l_c_attributes_tbl(16) := p_lot_rec.c_attribute16;
5462 END IF;
5463 IF (p_lot_rec.c_attribute17 = g_miss_char) THEN
5464 l_res_c_attributes_tbl(17) := NULL;
5465 l_c_attributes_tbl(17) := g_miss_char;
5466 ELSE
5467 l_res_c_attributes_tbl(17) := p_lot_rec.c_attribute17;
5468 l_c_attributes_tbl(17) := p_lot_rec.c_attribute17;
5469 END IF;
5470 IF (p_lot_rec.c_attribute18 = g_miss_char) THEN
5471 l_res_c_attributes_tbl(18) := NULL;
5472 l_c_attributes_tbl(18) := g_miss_char;
5473 ELSE
5474 l_res_c_attributes_tbl(18) := p_lot_rec.c_attribute18;
5475 l_c_attributes_tbl(18) := p_lot_rec.c_attribute18;
5476 END IF;
5477 IF (p_lot_rec.c_attribute19 = g_miss_char) THEN
5478 l_res_c_attributes_tbl(19) := NULL;
5479 l_c_attributes_tbl(19) := g_miss_char;
5480 ELSE
5481 l_res_c_attributes_tbl(19) := p_lot_rec.c_attribute19;
5482 l_c_attributes_tbl(19) := p_lot_rec.c_attribute19;
5483 END IF;
5484 IF (p_lot_rec.c_attribute20 = g_miss_char) THEN
5485 l_res_c_attributes_tbl(20) := NULL;
5486 l_c_attributes_tbl(20) := g_miss_char;
5487 ELSE
5488 l_res_c_attributes_tbl(20) := p_lot_rec.c_attribute20;
5489 l_c_attributes_tbl(20) := p_lot_rec.c_attribute20;
5490 END IF;
5491
5492 IF g_debug = 1 THEN
5493 print_debug('Upd Lot Attr: After preparing the C_ATTRIBUTES table ', 9);
5494 END IF;
5495
5496 IF (p_lot_rec.n_attribute1 = g_miss_num) THEN
5497 l_res_n_attributes_tbl(1) := NULL;
5498 l_n_attributes_tbl(1) := g_miss_num;
5499 ELSE
5500 l_res_n_attributes_tbl(1) := p_lot_rec.n_attribute1;
5501 l_n_attributes_tbl(1) := p_lot_rec.n_attribute1;
5502 END IF;
5503 IF (p_lot_rec.n_attribute2 = g_miss_num) THEN
5504 l_res_n_attributes_tbl(2) := NULL;
5505 l_n_attributes_tbl(2) := g_miss_num;
5506 ELSE
5507 l_res_n_attributes_tbl(2) := p_lot_rec.n_attribute2;
5508 l_n_attributes_tbl(2) := p_lot_rec.n_attribute2;
5509 END IF;
5510 IF (p_lot_rec.n_attribute3 = g_miss_num) THEN
5511 l_res_n_attributes_tbl(3) := NULL;
5512 l_n_attributes_tbl(3) := g_miss_num;
5513 ELSE
5514 l_res_n_attributes_tbl(3) := p_lot_rec.n_attribute3;
5515 l_n_attributes_tbl(3) := p_lot_rec.n_attribute3;
5516 END IF;
5517 IF (p_lot_rec.n_attribute4 = g_miss_num) THEN
5518 l_res_n_attributes_tbl(4) := NULL;
5519 l_n_attributes_tbl(4) := g_miss_num;
5520 ELSE
5521 l_res_n_attributes_tbl(4) := p_lot_rec.n_attribute4;
5522 l_n_attributes_tbl(4) := p_lot_rec.n_attribute4;
5523 END IF;
5524 IF (p_lot_rec.n_attribute5 = g_miss_num) THEN
5525 l_res_n_attributes_tbl(5) := NULL;
5526 l_n_attributes_tbl(5) := g_miss_num;
5527 ELSE
5528 l_res_n_attributes_tbl(5) := p_lot_rec.n_attribute5;
5529 l_n_attributes_tbl(5) := p_lot_rec.n_attribute5;
5530 END IF;
5531 IF (p_lot_rec.n_attribute6 = g_miss_num) THEN
5532 l_res_n_attributes_tbl(6) := NULL;
5533 l_n_attributes_tbl(6) := g_miss_num;
5534 ELSE
5535 l_res_n_attributes_tbl(6) := p_lot_rec.n_attribute6;
5536 l_n_attributes_tbl(6) := p_lot_rec.n_attribute6;
5537 END IF;
5538 IF (p_lot_rec.n_attribute7 = g_miss_num) THEN
5539 l_res_n_attributes_tbl(7) := NULL;
5540 l_n_attributes_tbl(7) := g_miss_num;
5541 ELSE
5542 l_res_n_attributes_tbl(7) := p_lot_rec.n_attribute7;
5543 l_n_attributes_tbl(7) := p_lot_rec.n_attribute7;
5544 END IF;
5545 IF (p_lot_rec.n_attribute8 = g_miss_num) THEN
5546 l_res_n_attributes_tbl(8) := NULL;
5547 l_n_attributes_tbl(8) := g_miss_num;
5548 ELSE
5549 l_res_n_attributes_tbl(8) := p_lot_rec.n_attribute8;
5550 l_n_attributes_tbl(8) := p_lot_rec.n_attribute8;
5551 END IF;
5552 IF (p_lot_rec.n_attribute9 = g_miss_num) THEN
5553 l_res_n_attributes_tbl(9) := NULL;
5554 l_n_attributes_tbl(9) := g_miss_num;
5555 ELSE
5556 l_res_n_attributes_tbl(9) := p_lot_rec.n_attribute9;
5557 l_n_attributes_tbl(9) := p_lot_rec.n_attribute9;
5558 END IF;
5559 IF (p_lot_rec.n_attribute10 = g_miss_num) THEN
5560 l_res_n_attributes_tbl(10) := NULL;
5561 l_n_attributes_tbl(10) := g_miss_num;
5562 ELSE
5563 l_res_n_attributes_tbl(10) := p_lot_rec.n_attribute10;
5564 l_n_attributes_tbl(10) := p_lot_rec.n_attribute10;
5565 END IF;
5566
5567 IF g_debug = 1 THEN
5568 print_debug('Upd Lot Attr: After preparing the N_ATTRIBUTES table ', 9);
5569 END IF;
5570
5571 IF (p_lot_rec.d_attribute1 = g_miss_date) THEN
5572 l_res_d_attributes_tbl(1) := NULL;
5573 l_d_attributes_tbl(1) := g_miss_date;
5574 ELSE
5575 l_res_d_attributes_tbl(1) := p_lot_rec.d_attribute1;
5576 l_d_attributes_tbl(1) := p_lot_rec.d_attribute1;
5577 END IF;
5578 IF (p_lot_rec.d_attribute2 = g_miss_date) THEN
5579 l_res_d_attributes_tbl(2) := NULL;
5580 l_d_attributes_tbl(2) := g_miss_date;
5581 ELSE
5582 l_res_d_attributes_tbl(2) := p_lot_rec.d_attribute2;
5583 l_d_attributes_tbl(2) := p_lot_rec.d_attribute2;
5584 END IF;
5585 IF (p_lot_rec.d_attribute3 = g_miss_date) THEN
5586 l_res_d_attributes_tbl(3) := NULL;
5587 l_d_attributes_tbl(3) := g_miss_date;
5588 ELSE
5589 l_res_d_attributes_tbl(3) := p_lot_rec.d_attribute3;
5590 l_d_attributes_tbl(3) := p_lot_rec.d_attribute3;
5591 END IF;
5592 IF (p_lot_rec.d_attribute4 = g_miss_date) THEN
5593 l_res_d_attributes_tbl(4) := NULL;
5594 l_d_attributes_tbl(4) := g_miss_date;
5595 ELSE
5596 l_res_d_attributes_tbl(4) := p_lot_rec.d_attribute4;
5597 l_d_attributes_tbl(4) := p_lot_rec.d_attribute4;
5598 END IF;
5599 IF (p_lot_rec.d_attribute5 = g_miss_date) THEN
5600 l_res_d_attributes_tbl(5) := NULL;
5601 l_d_attributes_tbl(5) := g_miss_date;
5602 ELSE
5603 l_res_d_attributes_tbl(5) := p_lot_rec.d_attribute5;
5604 l_d_attributes_tbl(5) := p_lot_rec.d_attribute5;
5605 END IF;
5606 IF (p_lot_rec.d_attribute6 = g_miss_date) THEN
5607 l_res_d_attributes_tbl(6) := NULL;
5608 l_d_attributes_tbl(6) := g_miss_date;
5609 ELSE
5610 l_res_d_attributes_tbl(6) := p_lot_rec.d_attribute6;
5611 l_d_attributes_tbl(6) := p_lot_rec.d_attribute6;
5612 END IF;
5613 IF (p_lot_rec.d_attribute7 = g_miss_date) THEN
5614 l_res_d_attributes_tbl(7) := NULL;
5615 l_d_attributes_tbl(7) := g_miss_date;
5616 ELSE
5617 l_res_d_attributes_tbl(7) := p_lot_rec.d_attribute7;
5618 l_d_attributes_tbl(7) := p_lot_rec.d_attribute7;
5619 END IF;
5620 IF (p_lot_rec.d_attribute8 = g_miss_date) THEN
5621 l_res_d_attributes_tbl(8) := NULL;
5622 l_d_attributes_tbl(8) := g_miss_date;
5623 ELSE
5624 l_res_d_attributes_tbl(8) := p_lot_rec.d_attribute8;
5625 l_d_attributes_tbl(8) := p_lot_rec.d_attribute8;
5626 END IF;
5627 IF (p_lot_rec.d_attribute9 = g_miss_date) THEN
5628 l_res_d_attributes_tbl(9) := NULL;
5629 l_d_attributes_tbl(9) := g_miss_date;
5630 ELSE
5631 l_res_d_attributes_tbl(9) := p_lot_rec.d_attribute9;
5632 l_d_attributes_tbl(9) := p_lot_rec.d_attribute9;
5633 END IF;
5634 IF (p_lot_rec.d_attribute10 = g_miss_date) THEN
5635 l_res_d_attributes_tbl(10) := NULL;
5636 l_d_attributes_tbl(10) := g_miss_date;
5637 ELSE
5638 l_res_d_attributes_tbl(10) := p_lot_rec.d_attribute10;
5639 l_d_attributes_tbl(10) := p_lot_rec.d_attribute10;
5640 END IF;
5641
5642 IF g_debug = 1 THEN
5643 print_debug('Upd Lot Attr: After preparing the D_ATTRIBUTES table ', 9);
5644 END IF;
5645 END IF; /* end if for Wms is installed */
5646
5647 IF g_debug = 1 THEN
5648 print_debug(' Before the call to The procedure validate_lot_attr_in_param ....' , 9);
5649 END IF;
5650
5651 validate_lot_attr_in_param(
5652 x_return_status => l_return_status
5653 , x_msg_count => l_msg_count
5654 , x_msg_data => l_msg_data
5655 , p_inventory_item_id => p_lot_rec.inventory_item_id
5656 , p_organization_id => p_lot_rec.organization_id
5657 , p_lot_number => p_lot_rec.lot_number
5658 , p_attribute_category => p_lot_rec.attribute_category
5659 , p_lot_attribute_category => p_lot_rec.lot_attribute_category
5660 , p_attributes_tbl => l_res_inv_attributes_tbl
5661 , p_c_attributes_tbl => l_res_c_attributes_tbl
5662 , p_n_attributes_tbl => l_res_n_attributes_tbl
5663 , p_d_attributes_tbl => l_res_d_attributes_tbl
5664 , p_wms_is_installed => l_wms_installed
5665 , p_source => p_source
5666 , p_disable_flag => l_wms_named_attributes.disable_flag
5667 , p_grade_code => l_wms_named_attributes.grade_code
5668 , p_origination_date => l_wms_named_attributes.origination_date
5669 , p_date_code => l_wms_named_attributes.date_code
5670 , p_change_date => l_wms_named_attributes.change_date
5671 , p_age => l_wms_named_attributes.age
5672 , p_retest_date => l_wms_named_attributes.retest_date
5673 , p_maturity_date => l_wms_named_attributes.maturity_date
5674 , p_item_size => l_wms_named_attributes.item_size
5675 , p_color => l_wms_named_attributes.color
5676 , p_volume => l_wms_named_attributes.volume
5677 , p_volume_uom => l_wms_named_attributes.volume_uom
5678 , p_place_of_origin => l_wms_named_attributes.place_of_origin
5679 , p_best_by_date => l_wms_named_attributes.best_by_date
5680 , p_length => l_wms_named_attributes.length
5681 , p_length_uom => l_wms_named_attributes.length_uom
5682 , p_recycled_content => l_wms_named_attributes.recycled_content
5683 , p_thickness => l_wms_named_attributes.thickness
5684 , p_thickness_uom => l_wms_named_attributes.thickness_uom
5685 , p_width => l_wms_named_attributes.width
5686 , p_width_uom => l_wms_named_attributes.width_uom
5687 , p_territory_code => l_wms_named_attributes.territory_code
5688 , p_supplier_lot_number => l_wms_named_attributes.supplier_lot_number
5689 , p_vendor_name => l_wms_named_attributes.vendor_name
5690 );
5691
5692 IF l_return_status = g_ret_sts_error THEN
5693 IF g_debug = 1 THEN
5694 print_debug('Update Lot Attr: Program validate_lot_attr_in_param has failed with a user defined exception', 9);
5695 END IF;
5696
5697 RAISE g_exc_error;
5698 ELSIF l_return_status = g_ret_sts_unexp_error THEN
5699 IF g_debug = 1 THEN
5700 print_debug('Update Lot Attr: Program validate_lot_attr_in_param has failed with a Unexpected exception', 9);
5701 END IF;
5702
5703 RAISE g_exc_unexpected_error;
5704 END IF;
5705
5706 IF g_debug = 1 THEN
5707 print_debug('Upd Lot Attr: Call to validate_lot_attr_in_param is success ', 9);
5708 END IF;
5709 IF g_debug = 1 THEN
5710 print_debug('Updating MTL_LOT_NUMBERS table ....' , 9);
5711 END IF;
5712 inv_log_util.trace('l_expiration_date is:'||l_expiration_date, 'INV_LOT_API_PUB','9'); --For bug 4888300
5713
5714 IF l_wms_installed = 'TRUE' THEN
5715 UPDATE mtl_lot_numbers
5716 SET expiration_date =
5717 DECODE(l_expiration_date, NULL, expiration_date, l_expiration_date )
5718 , disable_flag =
5719 DECODE(
5720 p_source
5721 , 2, DECODE(p_lot_rec.disable_flag, g_miss_char, NULL, NULL, disable_flag, p_lot_rec.disable_flag)
5722 , DECODE(p_lot_rec.disable_flag, g_miss_char, disable_flag, NULL, NULL, p_lot_rec.disable_flag)
5723 )
5724 , attribute_category =
5725 DECODE(
5726 p_source
5727 , 2, DECODE(p_lot_rec.attribute_category, g_miss_char, NULL, NULL, attribute_category, p_lot_rec.attribute_category)
5728 , DECODE(p_lot_rec.attribute_category, g_miss_char, attribute_category, NULL, NULL, p_lot_rec.attribute_category)
5729 )
5730 , lot_attribute_category =
5731 DECODE(
5732 p_source
5733 , 2, DECODE(p_lot_rec.lot_attribute_category, g_miss_char, NULL, NULL, lot_attribute_category, p_lot_rec.lot_attribute_category)
5734 , DECODE(p_lot_rec.lot_attribute_category, g_miss_char, lot_attribute_category, NULL, NULL, p_lot_rec.lot_attribute_category)
5735 )
5736 , grade_code =
5737 DECODE(
5738 p_source
5739 , 2, DECODE(p_lot_rec.grade_code, g_miss_char, NULL, NULL, grade_code, p_lot_rec.grade_code)
5740 , DECODE(p_lot_rec.grade_code, g_miss_char, grade_code, NULL, NULL, p_lot_rec.grade_code)
5741 )
5742 , origination_date =
5743 DECODE(
5744 p_source
5745 , 2, DECODE(p_lot_rec.origination_date, g_miss_date, NULL, NULL, origination_date, p_lot_rec.origination_date)
5746 , DECODE(p_lot_rec.origination_date, g_miss_date, origination_date, NULL, NULL, p_lot_rec.origination_date)
5747 )
5748 , date_code =
5749 DECODE(
5750 p_source
5751 , 2, DECODE(p_lot_rec.date_code, g_miss_char, NULL, NULL, date_code, p_lot_rec.date_code)
5752 , DECODE(p_lot_rec.date_code, g_miss_char, date_code, NULL, NULL, p_lot_rec.date_code)
5753 )
5754 , status_id =
5755 DECODE(
5756 p_source
5757 , 2, DECODE(p_lot_rec.status_id, g_miss_num, NULL, NULL, status_id, p_lot_rec.status_id)
5758 , DECODE(p_lot_rec.status_id, g_miss_num, status_id, NULL, NULL, p_lot_rec.status_id)
5759 )
5760 , change_date =
5761 DECODE(
5762 p_source
5763 , 2, DECODE(p_lot_rec.change_date, g_miss_date, NULL, NULL, change_date, p_lot_rec.change_date)
5764 , DECODE(p_lot_rec.change_date, g_miss_date, change_date, NULL, NULL, p_lot_rec.change_date)
5765 )
5766 , age = DECODE(
5767 p_source
5768 , 2, DECODE(p_lot_rec.age, g_miss_num, NULL, NULL, age, p_lot_rec.age)
5769 , DECODE(p_lot_rec.age, g_miss_num, age, NULL, NULL, p_lot_rec.age)
5770 )
5771 , retest_date =
5772 DECODE(
5773 p_source
5774 , 2, DECODE(p_lot_rec.retest_date, g_miss_date, NULL, NULL, retest_date, p_lot_rec.retest_date)
5775 , DECODE(p_lot_rec.retest_date, g_miss_date, retest_date, NULL, NULL, p_lot_rec.retest_date)
5776 )
5777 , maturity_date =
5778 DECODE(
5779 p_source
5780 , 2, DECODE(p_lot_rec.maturity_date, g_miss_date, NULL, NULL, maturity_date, p_lot_rec.maturity_date)
5781 , DECODE(p_lot_rec.maturity_date, g_miss_date, maturity_date, NULL, NULL, p_lot_rec.maturity_date)
5782 )
5783 , item_size =
5784 DECODE(
5785 p_source
5786 , 2, DECODE(p_lot_rec.item_size, g_miss_num, NULL, NULL, item_size, p_lot_rec.item_size)
5787 , DECODE(p_lot_rec.item_size, g_miss_num, item_size, NULL, NULL, p_lot_rec.item_size)
5788 )
5789 , color =
5790 DECODE(
5791 p_source
5792 , 2, DECODE(p_lot_rec.color, g_miss_char, NULL, NULL, color, p_lot_rec.color)
5793 , DECODE(p_lot_rec.color, g_miss_char, color, NULL, NULL, p_lot_rec.color)
5794 )
5795 , volume =
5796 DECODE(
5797 p_source
5798 , 2, DECODE(p_lot_rec.volume, g_miss_num, NULL, NULL, volume, p_lot_rec.volume)
5799 , DECODE(p_lot_rec.volume, g_miss_num, volume, NULL, NULL, p_lot_rec.volume)
5800 )
5801 , volume_uom =
5802 DECODE(
5803 p_source
5804 , 2, DECODE(p_lot_rec.volume_uom, g_miss_char, NULL, NULL, volume_uom, p_lot_rec.volume_uom)
5805 , DECODE(p_lot_rec.volume_uom, g_miss_char, volume_uom, NULL, NULL, p_lot_rec.volume_uom)
5806 )
5807 , place_of_origin =
5808 DECODE(
5809 p_source
5810 , 2, DECODE(p_lot_rec.place_of_origin, g_miss_char, NULL, NULL, place_of_origin, p_lot_rec.place_of_origin)
5811 , DECODE(p_lot_rec.place_of_origin, g_miss_char, place_of_origin, NULL, place_of_origin, p_lot_rec.place_of_origin)
5812 )
5813 , best_by_date =
5814 DECODE(
5815 p_source
5816 , 2, DECODE(p_lot_rec.best_by_date, g_miss_date, NULL, NULL, best_by_date, p_lot_rec.best_by_date)
5817 , DECODE(p_lot_rec.best_by_date, g_miss_date, best_by_date, NULL, NULL, p_lot_rec.best_by_date)
5818 )
5819 , LENGTH =
5820 DECODE(
5821 p_source
5822 , 2, DECODE(p_lot_rec.length, g_miss_num, NULL, NULL, LENGTH, p_lot_rec.length)
5823 , DECODE(p_lot_rec.length, g_miss_num, LENGTH, NULL, NULL, p_lot_rec.length)
5824 )
5825 , length_uom =
5826 DECODE(
5827 p_source
5828 , 2, DECODE(p_lot_rec.length_uom, g_miss_char, NULL, NULL, length_uom, p_lot_rec.length_uom)
5829 , DECODE(p_lot_rec.length_uom, g_miss_char, length_uom, NULL, NULL, p_lot_rec.length_uom)
5830 )
5831 , recycled_content =
5832 DECODE(
5833 p_source
5834 , 2, DECODE(p_lot_rec.recycled_content, g_miss_num, NULL, NULL, recycled_content, p_lot_rec.recycled_content)
5835 , DECODE(p_lot_rec.recycled_content, g_miss_num, recycled_content, NULL, NULL, p_lot_rec.recycled_content)
5836 )
5837 , thickness =
5838 DECODE(
5839 p_source
5840 , 2, DECODE(p_lot_rec.thickness, g_miss_num, NULL, NULL, thickness, p_lot_rec.thickness)
5841 , DECODE(p_lot_rec.thickness, g_miss_num, thickness, NULL, NULL, p_lot_rec.thickness)
5842 )
5843 , thickness_uom =
5844 DECODE(
5845 p_source
5846 , 2, DECODE(p_lot_rec.thickness_uom, g_miss_char, NULL, NULL, thickness_uom, p_lot_rec.thickness_uom)
5847 , DECODE(p_lot_rec.thickness_uom, g_miss_char, thickness_uom, NULL, NULL, p_lot_rec.thickness_uom)
5848 )
5849 , width =
5850 DECODE(
5851 p_source
5852 , 2, DECODE(p_lot_rec.width, g_miss_num, NULL, NULL, width, p_lot_rec.width)
5853 , DECODE(p_lot_rec.width, g_miss_num, width, NULL, NULL, p_lot_rec.width)
5854 )
5855 , width_uom =
5856 DECODE(
5857 p_source
5858 , 2, DECODE(p_lot_rec.width_uom, g_miss_char, NULL, NULL, width_uom, p_lot_rec.width_uom)
5859 , DECODE(p_lot_rec.width_uom, g_miss_char, width_uom, NULL, NULL, p_lot_rec.width_uom)
5860 )
5861 , territory_code =
5862 DECODE(
5863 p_source
5864 , 2, DECODE(p_lot_rec.territory_code, g_miss_char, NULL, NULL, territory_code, p_lot_rec.territory_code)
5865 , DECODE(p_lot_rec.territory_code, g_miss_char, territory_code, NULL, NULL, p_lot_rec.territory_code)
5866 )
5867 , supplier_lot_number =
5868 DECODE(
5869 p_source
5870 , 2, DECODE(p_lot_rec.supplier_lot_number, g_miss_char, NULL, NULL, supplier_lot_number, p_lot_rec.supplier_lot_number)
5871 , DECODE(p_lot_rec.supplier_lot_number, g_miss_char, supplier_lot_number, NULL, NULL, p_lot_rec.supplier_lot_number)
5872 )
5873 , vendor_name =
5874 DECODE(
5875 p_source
5876 , 2, DECODE(p_lot_rec.vendor_name, g_miss_char, NULL, NULL, vendor_name, p_lot_rec.vendor_name)
5877 , DECODE(p_lot_rec.vendor_name, g_miss_char, vendor_name, NULL, NULL, p_lot_rec.vendor_name)
5878 )
5879 -- Bug 6983527 - Parent lot number should never be updated.
5880 -- nsinghi bug#5209065. Update new lot attributes
5881 -- , parent_lot_number =
5882 -- DECODE(
5883 -- p_source
5884 -- , 2, DECODE(p_lot_rec.parent_lot_number, g_miss_char, NULL, NULL, parent_lot_number, p_lot_rec.parent_lot_number)
5885 -- , DECODE(p_lot_rec.parent_lot_number, g_miss_char, parent_lot_number, NULL, NULL, p_lot_rec.parent_lot_number)
5886 -- )
5887 , origination_type =
5888 DECODE(
5889 p_source
5890 , 2, DECODE(p_lot_rec.origination_type, g_miss_num, NULL, NULL, origination_type, p_lot_rec.origination_type)
5891 , DECODE(p_lot_rec.origination_type, g_miss_num, origination_type, NULL, NULL, p_lot_rec.origination_type)
5892 )
5893 , availability_type =
5894 DECODE(
5895 p_source
5896 , 2, DECODE(p_lot_rec.availability_type, g_miss_num, NULL, NULL, availability_type, p_lot_rec.availability_type)
5897 , DECODE(p_lot_rec.availability_type, g_miss_num, availability_type, NULL, NULL, p_lot_rec.availability_type)
5898 )
5899 , expiration_action_code =
5900 DECODE(
5901 p_source
5902 , 2, DECODE(p_lot_rec.expiration_action_code, g_miss_char, NULL, NULL, expiration_action_code, p_lot_rec.expiration_action_code)
5903 , DECODE(p_lot_rec.expiration_action_code, g_miss_char, expiration_action_code, NULL, NULL, p_lot_rec.expiration_action_code)
5904 )
5905 , expiration_action_date =
5906 DECODE(
5907 p_source
5908 , 2, DECODE(p_lot_rec.expiration_action_date, g_miss_date, NULL, NULL, expiration_action_date, p_lot_rec.expiration_action_date)
5909 , DECODE(p_lot_rec.expiration_action_date, g_miss_date, expiration_action_date, NULL, NULL, p_lot_rec.expiration_action_date)
5910 )
5911 , hold_date =
5912 DECODE(
5913 p_source
5914 , 2, DECODE(p_lot_rec.hold_date, g_miss_date, NULL, NULL, hold_date, p_lot_rec.hold_date)
5915 , DECODE(p_lot_rec.hold_date, g_miss_date, hold_date, NULL, NULL, p_lot_rec.hold_date)
5916 )
5917 , inventory_atp_code =
5918 DECODE(
5919 p_source
5920 , 2, DECODE(p_lot_rec.inventory_atp_code, g_miss_num, NULL, NULL, inventory_atp_code, p_lot_rec.inventory_atp_code)
5921 , DECODE(p_lot_rec.inventory_atp_code, g_miss_num, inventory_atp_code, NULL, NULL, p_lot_rec.inventory_atp_code)
5922 )
5923 , reservable_type =
5924 DECODE(
5925 p_source
5926 , 2, DECODE(p_lot_rec.reservable_type, g_miss_num, NULL, NULL, reservable_type, p_lot_rec.reservable_type)
5927 , DECODE(p_lot_rec.reservable_type, g_miss_num, reservable_type, NULL, NULL, p_lot_rec.reservable_type)
5928 )
5929 , sampling_event_id =
5930 DECODE(
5931 p_source
5932 , 2, DECODE(p_lot_rec.sampling_event_id, g_miss_num, NULL, NULL, sampling_event_id, p_lot_rec.sampling_event_id)
5933 , DECODE(p_lot_rec.sampling_event_id, g_miss_num, sampling_event_id, NULL, NULL, p_lot_rec.sampling_event_id)
5934 )
5935 -- nsinghi bug#5209065. End.
5936 , attribute1 =
5937 DECODE(
5938 p_source
5939 , 2, DECODE(l_inv_attributes_tbl(1), g_miss_char, NULL, NULL, attribute1, l_inv_attributes_tbl(1))
5940 , DECODE(l_inv_attributes_tbl(1), g_miss_char, attribute1, NULL, NULL, l_inv_attributes_tbl(1))
5941 )
5942 , attribute2 =
5943 DECODE(
5944 p_source
5945 , 2, DECODE(l_inv_attributes_tbl(2), g_miss_char, NULL, NULL, attribute2, l_inv_attributes_tbl(2))
5946 , DECODE(l_inv_attributes_tbl(2), g_miss_char, attribute2, NULL, NULL, l_inv_attributes_tbl(2))
5947 )
5948 , attribute3 =
5949 DECODE(
5950 p_source
5951 , 2, DECODE(l_inv_attributes_tbl(3), g_miss_char, NULL, NULL, attribute3, l_inv_attributes_tbl(3))
5952 , DECODE(l_inv_attributes_tbl(3), g_miss_char, attribute3, NULL, NULL, l_inv_attributes_tbl(3))
5953 )
5954 , attribute4 =
5955 DECODE(
5956 p_source
5957 , 2, DECODE(l_inv_attributes_tbl(4), g_miss_char, NULL, NULL, attribute4, l_inv_attributes_tbl(4))
5958 , DECODE(l_inv_attributes_tbl(4), g_miss_char, attribute4, NULL, NULL, l_inv_attributes_tbl(4))
5959 )
5960 , attribute5 =
5961 DECODE(
5962 p_source
5963 , 2, DECODE(l_inv_attributes_tbl(5), g_miss_char, NULL, NULL, attribute5, l_inv_attributes_tbl(5))
5964 , DECODE(l_inv_attributes_tbl(5), g_miss_char, attribute5, NULL, NULL, l_inv_attributes_tbl(5))
5965 )
5966 , attribute6 =
5967 DECODE(
5968 p_source
5969 , 2, DECODE(l_inv_attributes_tbl(6), g_miss_char, NULL, NULL, attribute6, l_inv_attributes_tbl(6))
5970 , DECODE(l_inv_attributes_tbl(6), g_miss_char, attribute6, NULL, NULL, l_inv_attributes_tbl(6))
5971 )
5972 , attribute7 =
5973 DECODE(
5974 p_source
5975 , 2, DECODE(l_inv_attributes_tbl(7), g_miss_char, NULL, NULL, attribute7, l_inv_attributes_tbl(7))
5976 , DECODE(l_inv_attributes_tbl(7), g_miss_char, attribute7, NULL, NULL, l_inv_attributes_tbl(7))
5977 )
5978 , attribute8 =
5979 DECODE(
5980 p_source
5981 , 2, DECODE(l_inv_attributes_tbl(8), g_miss_char, NULL, NULL, attribute8, l_inv_attributes_tbl(8))
5982 , DECODE(l_inv_attributes_tbl(8), g_miss_char, attribute8, NULL, NULL, l_inv_attributes_tbl(8))
5983 )
5984 , attribute9 =
5985 DECODE(
5986 p_source
5987 , 2, DECODE(l_inv_attributes_tbl(9), g_miss_char, NULL, NULL, attribute9, l_inv_attributes_tbl(9))
5988 , DECODE(l_inv_attributes_tbl(9), g_miss_char, attribute9, NULL, NULL, l_inv_attributes_tbl(9))
5989 )
5990 , attribute10 =
5991 DECODE(
5992 p_source
5993 , 2, DECODE(l_inv_attributes_tbl(10), g_miss_char, NULL, NULL, attribute10, l_inv_attributes_tbl(10))
5994 , DECODE(l_inv_attributes_tbl(10), g_miss_char, attribute10, NULL, NULL, l_inv_attributes_tbl(10))
5995 )
5996 , attribute11 =
5997 DECODE(
5998 p_source
5999 , 2, DECODE(l_inv_attributes_tbl(11), g_miss_char, NULL, NULL, attribute11, l_inv_attributes_tbl(11))
6000 , DECODE(l_inv_attributes_tbl(11), g_miss_char, attribute11, NULL, NULL, l_inv_attributes_tbl(11))
6001 )
6002 , attribute12 =
6003 DECODE(
6004 p_source
6005 , 2, DECODE(l_inv_attributes_tbl(12), g_miss_char, NULL, NULL, attribute12, l_inv_attributes_tbl(12))
6006 , DECODE(l_inv_attributes_tbl(12), g_miss_char, attribute12, NULL, NULL, l_inv_attributes_tbl(12))
6007 )
6008 , attribute13 =
6009 DECODE(
6010 p_source
6011 , 2, DECODE(l_inv_attributes_tbl(13), g_miss_char, NULL, NULL, attribute13, l_inv_attributes_tbl(13))
6012 , DECODE(l_inv_attributes_tbl(13), g_miss_char, attribute13, NULL, NULL, l_inv_attributes_tbl(13))
6013 )
6014 , attribute14 =
6015 DECODE(
6016 p_source
6017 , 2, DECODE(l_inv_attributes_tbl(14), g_miss_char, NULL, NULL, attribute14, l_inv_attributes_tbl(14))
6018 , DECODE(l_inv_attributes_tbl(14), g_miss_char, attribute14, NULL, NULL, l_inv_attributes_tbl(14))
6019 )
6020 , attribute15 =
6021 DECODE(
6022 p_source
6023 , 2, DECODE(l_inv_attributes_tbl(15), g_miss_char, NULL, NULL, attribute15, l_inv_attributes_tbl(15))
6024 , DECODE(l_inv_attributes_tbl(15), g_miss_char, attribute15, NULL, NULL, l_inv_attributes_tbl(15))
6025 )
6026 , c_attribute1 =
6027 DECODE(
6028 p_source
6029 , 2, DECODE(l_c_attributes_tbl(1), g_miss_char, NULL, NULL, c_attribute1, l_c_attributes_tbl(1))
6030 , DECODE(l_c_attributes_tbl(1), g_miss_char, c_attribute1, NULL, NULL, l_c_attributes_tbl(1))
6031 )
6032 , c_attribute2 =
6033 DECODE(
6034 p_source
6035 , 2, DECODE(l_c_attributes_tbl(2), g_miss_char, NULL, NULL, c_attribute2, l_c_attributes_tbl(2))
6036 , DECODE(l_c_attributes_tbl(2), g_miss_char, c_attribute2, NULL, NULL, l_c_attributes_tbl(2))
6037 )
6038 , c_attribute3 =
6039 DECODE(
6040 p_source
6041 , 2, DECODE(l_c_attributes_tbl(3), g_miss_char, NULL, NULL, c_attribute3, l_c_attributes_tbl(3))
6042 , DECODE(l_c_attributes_tbl(3), g_miss_char, c_attribute3, NULL, NULL, l_c_attributes_tbl(3))
6043 )
6044 , c_attribute4 =
6045 DECODE(
6046 p_source
6047 , 2, DECODE(l_c_attributes_tbl(4), g_miss_char, NULL, NULL, c_attribute4, l_c_attributes_tbl(4))
6048 , DECODE(l_c_attributes_tbl(4), g_miss_char, c_attribute4, NULL, NULL, l_c_attributes_tbl(4))
6049 )
6050 , c_attribute5 =
6051 DECODE(
6052 p_source
6053 , 2, DECODE(l_c_attributes_tbl(5), g_miss_char, NULL, NULL, c_attribute5, l_c_attributes_tbl(5))
6054 , DECODE(l_c_attributes_tbl(5), g_miss_char, c_attribute5, NULL, NULL, l_c_attributes_tbl(5))
6055 )
6056 , c_attribute6 =
6057 DECODE(
6058 p_source
6059 , 2, DECODE(l_c_attributes_tbl(6), g_miss_char, NULL, NULL, c_attribute6, l_c_attributes_tbl(6))
6060 , DECODE(l_c_attributes_tbl(6), g_miss_char, c_attribute6, NULL, NULL, l_c_attributes_tbl(6))
6061 )
6062 , c_attribute7 =
6063 DECODE(
6064 p_source
6065 , 2, DECODE(l_c_attributes_tbl(7), g_miss_char, NULL, NULL, c_attribute7, l_c_attributes_tbl(7))
6066 , DECODE(l_c_attributes_tbl(7), g_miss_char, c_attribute7, NULL, NULL, l_c_attributes_tbl(7))
6067 )
6068 , c_attribute8 =
6069 DECODE(
6070 p_source
6071 , 2, DECODE(l_c_attributes_tbl(8), g_miss_char, NULL, NULL, c_attribute8, l_c_attributes_tbl(8))
6072 , DECODE(l_c_attributes_tbl(8), g_miss_char, c_attribute8, NULL, NULL, l_c_attributes_tbl(8))
6073 )
6074 , c_attribute9 =
6075 DECODE(
6076 p_source
6077 , 2, DECODE(l_c_attributes_tbl(9), g_miss_char, NULL, NULL, c_attribute9, l_c_attributes_tbl(9))
6078 , DECODE(l_c_attributes_tbl(9), g_miss_char, c_attribute9, NULL, NULL, l_c_attributes_tbl(9))
6079 )
6080 , c_attribute10 =
6081 DECODE(
6082 p_source
6083 , 2, DECODE(l_c_attributes_tbl(10), g_miss_char, NULL, NULL, c_attribute10, l_c_attributes_tbl(10))
6084 , DECODE(l_c_attributes_tbl(10), g_miss_char, c_attribute10, NULL, NULL, l_c_attributes_tbl(10))
6085 )
6086 , c_attribute11 =
6087 DECODE(
6088 p_source
6089 , 2, DECODE(l_c_attributes_tbl(11), g_miss_char, NULL, NULL, c_attribute11, l_c_attributes_tbl(11))
6090 , DECODE(l_c_attributes_tbl(11), g_miss_char, c_attribute11, NULL, NULL, l_c_attributes_tbl(11))
6091 )
6092 , c_attribute12 =
6093 DECODE(
6094 p_source
6095 , 2, DECODE(l_c_attributes_tbl(12), g_miss_char, NULL, NULL, c_attribute12, l_c_attributes_tbl(12))
6096 , DECODE(l_c_attributes_tbl(12), g_miss_char, c_attribute12, NULL, NULL, l_c_attributes_tbl(12))
6097 )
6098 , c_attribute13 =
6099 DECODE(
6100 p_source
6101 , 2, DECODE(l_c_attributes_tbl(13), g_miss_char, NULL, NULL, c_attribute13, l_c_attributes_tbl(13))
6102 , DECODE(l_c_attributes_tbl(13), g_miss_char, c_attribute13, NULL, NULL, l_c_attributes_tbl(13))
6103 )
6104 , c_attribute14 =
6105 DECODE(
6106 p_source
6107 , 2, DECODE(l_c_attributes_tbl(14), g_miss_char, NULL, NULL, c_attribute14, l_c_attributes_tbl(14))
6108 , DECODE(l_c_attributes_tbl(14), g_miss_char, c_attribute14, NULL, NULL, l_c_attributes_tbl(14))
6109 )
6110 , c_attribute15 =
6111 DECODE(
6112 p_source
6113 , 2, DECODE(l_c_attributes_tbl(15), g_miss_char, NULL, NULL, c_attribute15, l_c_attributes_tbl(15))
6114 , DECODE(l_c_attributes_tbl(15), g_miss_char, c_attribute15, NULL, NULL, l_c_attributes_tbl(15))
6115 )
6116 , c_attribute16 =
6117 DECODE(
6118 p_source
6119 , 2, DECODE(l_c_attributes_tbl(16), g_miss_char, NULL, NULL, c_attribute16, l_c_attributes_tbl(16))
6120 , DECODE(l_c_attributes_tbl(16), g_miss_char, c_attribute16, NULL, NULL, l_c_attributes_tbl(16))
6121 )
6122 , c_attribute17 =
6123 DECODE(
6124 p_source
6125 , 2, DECODE(l_c_attributes_tbl(17), g_miss_char, NULL, NULL, c_attribute17, l_c_attributes_tbl(17))
6126 , DECODE(l_c_attributes_tbl(17), g_miss_char, c_attribute17, NULL, NULL, l_c_attributes_tbl(17))
6127 )
6128 , c_attribute18 =
6129 DECODE(
6130 p_source
6131 , 2, DECODE(l_c_attributes_tbl(18), g_miss_char, NULL, NULL, c_attribute18, l_c_attributes_tbl(18))
6132 , DECODE(l_c_attributes_tbl(18), g_miss_char, c_attribute18, NULL, NULL, l_c_attributes_tbl(18))
6133 )
6134 , c_attribute19 =
6135 DECODE(
6136 p_source
6137 , 2, DECODE(l_c_attributes_tbl(19), g_miss_char, NULL, NULL, c_attribute19, l_c_attributes_tbl(19))
6138 , DECODE(l_c_attributes_tbl(19), g_miss_char, c_attribute19, NULL, NULL, l_c_attributes_tbl(19))
6139 )
6140 , c_attribute20 =
6141 DECODE(
6142 p_source
6143 , 2, DECODE(l_c_attributes_tbl(20), g_miss_char, NULL, NULL, c_attribute20, l_c_attributes_tbl(20))
6144 , DECODE(l_c_attributes_tbl(20), g_miss_char, c_attribute20, NULL, NULL, l_c_attributes_tbl(20))
6145 )
6146 , n_attribute1 =
6147 DECODE(
6148 p_source
6149 , 2, DECODE(l_n_attributes_tbl(1), g_miss_num, NULL, NULL, n_attribute1, l_n_attributes_tbl(1))
6150 , DECODE(l_n_attributes_tbl(1), g_miss_num, n_attribute1, NULL, NULL, l_n_attributes_tbl(1))
6151 )
6152 , n_attribute2 =
6153 DECODE(
6154 p_source
6155 , 2, DECODE(l_n_attributes_tbl(2), g_miss_num, NULL, NULL, n_attribute2, l_n_attributes_tbl(2))
6156 , DECODE(l_n_attributes_tbl(2), g_miss_num, n_attribute2, NULL, NULL, l_n_attributes_tbl(2))
6157 )
6158 , n_attribute3 =
6159 DECODE(
6160 p_source
6161 , 2, DECODE(l_n_attributes_tbl(3), g_miss_num, NULL, NULL, n_attribute3, l_n_attributes_tbl(3))
6162 , DECODE(l_n_attributes_tbl(3), g_miss_num, n_attribute3, NULL, NULL, l_n_attributes_tbl(3))
6163 )
6164 , n_attribute4 =
6165 DECODE(
6166 p_source
6167 , 2, DECODE(l_n_attributes_tbl(4), g_miss_num, NULL, NULL, n_attribute4, l_n_attributes_tbl(4))
6168 , DECODE(l_n_attributes_tbl(4), g_miss_num, n_attribute4, NULL, NULL, l_n_attributes_tbl(4))
6169 )
6170 , n_attribute5 =
6171 DECODE(
6172 p_source
6173 , 2, DECODE(l_n_attributes_tbl(5), g_miss_num, NULL, NULL, n_attribute5, l_n_attributes_tbl(5))
6174 , DECODE(l_n_attributes_tbl(5), g_miss_num, n_attribute5, NULL, NULL, l_n_attributes_tbl(5))
6175 )
6176 , n_attribute6 =
6177 DECODE(
6178 p_source
6179 , 2, DECODE(l_n_attributes_tbl(6), g_miss_num, NULL, NULL, n_attribute6, l_n_attributes_tbl(6))
6180 , DECODE(l_n_attributes_tbl(6), g_miss_num, n_attribute6, NULL, NULL, l_n_attributes_tbl(6))
6181 )
6182 , n_attribute7 =
6183 DECODE(
6184 p_source
6185 , 2, DECODE(l_n_attributes_tbl(7), g_miss_num, NULL, NULL, n_attribute7, l_n_attributes_tbl(7))
6186 , DECODE(l_n_attributes_tbl(7), g_miss_num, n_attribute7, NULL, NULL, l_n_attributes_tbl(7))
6187 )
6188 , n_attribute8 =
6189 DECODE(
6190 p_source
6191 , 2, DECODE(l_n_attributes_tbl(8), g_miss_num, NULL, NULL, n_attribute8, l_n_attributes_tbl(8))
6192 , DECODE(l_n_attributes_tbl(8), g_miss_num, n_attribute8, NULL, NULL, l_n_attributes_tbl(8))
6193 )
6194 , n_attribute9 =
6195 DECODE(
6196 p_source
6197 , 2, DECODE(l_n_attributes_tbl(9), g_miss_num, NULL, NULL, n_attribute9, l_n_attributes_tbl(9))
6198 , DECODE(l_n_attributes_tbl(9), g_miss_num, n_attribute9, NULL, NULL, l_n_attributes_tbl(9))
6199 )
6200 , n_attribute10 =
6201 DECODE(
6202 p_source
6203 , 2, DECODE(l_n_attributes_tbl(10), g_miss_num, NULL, NULL, n_attribute10, l_n_attributes_tbl(10))
6204 , DECODE(l_n_attributes_tbl(10), g_miss_num, n_attribute10, NULL, NULL, l_n_attributes_tbl(10))
6205 )
6206 , d_attribute1 =
6207 DECODE(
6208 p_source
6209 , 2, DECODE(l_d_attributes_tbl(1), g_miss_date, NULL, NULL, d_attribute1, l_d_attributes_tbl(1))
6210 , DECODE(l_d_attributes_tbl(1), g_miss_date, d_attribute1, NULL, NULL, l_d_attributes_tbl(1))
6211 )
6212 , d_attribute2 =
6213 DECODE(
6214 p_source
6215 , 2, DECODE(l_d_attributes_tbl(2), g_miss_date, NULL, NULL, d_attribute2, l_d_attributes_tbl(2))
6216 , DECODE(l_d_attributes_tbl(2), g_miss_date, d_attribute2, NULL, NULL, l_d_attributes_tbl(2))
6217 )
6218 , d_attribute3 =
6219 DECODE(
6220 p_source
6221 , 2, DECODE(l_d_attributes_tbl(3), g_miss_date, NULL, NULL, d_attribute3, l_d_attributes_tbl(3))
6222 , DECODE(l_d_attributes_tbl(3), g_miss_date, d_attribute3, NULL, NULL, l_d_attributes_tbl(3))
6223 )
6224 , d_attribute4 =
6225 DECODE(
6226 p_source
6227 , 2, DECODE(l_d_attributes_tbl(4), g_miss_date, NULL, NULL, d_attribute4, l_d_attributes_tbl(4))
6228 , DECODE(l_d_attributes_tbl(4), g_miss_date, d_attribute4, NULL, NULL, l_d_attributes_tbl(4))
6229 )
6230 , d_attribute5 =
6231 DECODE(
6232 p_source
6233 , 2, DECODE(l_d_attributes_tbl(5), g_miss_date, NULL, NULL, d_attribute5, l_d_attributes_tbl(5))
6234 , DECODE(l_d_attributes_tbl(5), g_miss_date, d_attribute5, NULL, NULL, l_d_attributes_tbl(5))
6235 )
6236 , d_attribute6 =
6237 DECODE(
6238 p_source
6239 , 2, DECODE(l_d_attributes_tbl(6), g_miss_date, NULL, NULL, d_attribute6, l_d_attributes_tbl(6))
6240 , DECODE(l_d_attributes_tbl(6), g_miss_date, d_attribute6, NULL, NULL, l_d_attributes_tbl(6))
6241 )
6242 , d_attribute7 =
6243 DECODE(
6244 p_source
6245 , 2, DECODE(l_d_attributes_tbl(7), g_miss_date, NULL, NULL, d_attribute7, l_d_attributes_tbl(7))
6246 , DECODE(l_d_attributes_tbl(7), g_miss_date, d_attribute7, NULL, NULL, l_d_attributes_tbl(7))
6247 )
6248 , d_attribute8 =
6249 DECODE(
6250 p_source
6251 , 2, DECODE(l_d_attributes_tbl(8), g_miss_date, NULL, NULL, d_attribute8, l_d_attributes_tbl(8))
6252 , DECODE(l_d_attributes_tbl(8), g_miss_date, d_attribute8, NULL, NULL, l_d_attributes_tbl(8))
6253 )
6254 , d_attribute9 =
6255 DECODE(
6256 p_source
6257 , 2, DECODE(l_d_attributes_tbl(9), g_miss_date, NULL, NULL, d_attribute9, l_d_attributes_tbl(9))
6258 , DECODE(l_d_attributes_tbl(9), g_miss_date, d_attribute9, NULL, NULL, l_d_attributes_tbl(9))
6259 )
6260 , d_attribute10 =
6261 DECODE(
6262 p_source
6263 , 2, DECODE(l_d_attributes_tbl(10), g_miss_date, NULL, NULL, d_attribute10, l_d_attributes_tbl(10))
6264 , DECODE(l_d_attributes_tbl(10), g_miss_date, d_attribute10, NULL, NULL, l_d_attributes_tbl(10))
6265 )
6266 WHERE inventory_item_id = p_lot_rec.inventory_item_id
6267 AND organization_id = p_lot_rec.organization_id
6268 AND lot_number = p_lot_rec.lot_number;
6269 ELSE
6270 UPDATE mtl_lot_numbers
6271 SET expiration_date =
6272 DECODE(l_expiration_date, NULL, expiration_date, l_expiration_date )
6273 , disable_flag =
6274 DECODE(
6275 p_source
6276 , 2, DECODE(p_lot_rec.disable_flag, g_miss_char, NULL, NULL, disable_flag, p_lot_rec.disable_flag)
6277 , DECODE(p_lot_rec.disable_flag, g_miss_char, disable_flag, NULL, NULL, p_lot_rec.disable_flag)
6278 )
6279 , attribute_category =
6280 DECODE(
6281 p_source
6282 , 2, DECODE(p_lot_rec.attribute_category, g_miss_char, NULL, NULL, attribute_category, p_lot_rec.attribute_category)
6283 , DECODE(p_lot_rec.attribute_category, g_miss_char, attribute_category, NULL, NULL, p_lot_rec.attribute_category)
6284 )
6285 , lot_attribute_category =
6286 DECODE(
6287 p_source
6288 , 2, DECODE(p_lot_rec.lot_attribute_category, g_miss_char, NULL, NULL, lot_attribute_category, p_lot_rec.lot_attribute_category)
6289 , DECODE(p_lot_rec.lot_attribute_category, g_miss_char, lot_attribute_category, NULL, NULL, p_lot_rec.lot_attribute_category)
6290 )
6291 , grade_code =
6292 DECODE(
6293 p_source
6294 , 2, DECODE(p_lot_rec.grade_code, g_miss_char, NULL, NULL, grade_code, p_lot_rec.grade_code)
6295 , DECODE(p_lot_rec.grade_code, g_miss_char, grade_code, NULL, NULL, p_lot_rec.grade_code)
6296 )
6297 , origination_date =
6298 DECODE(
6299 p_source
6300 , 2, DECODE(p_lot_rec.origination_date, g_miss_date, NULL, NULL, origination_date, p_lot_rec.origination_date)
6301 , DECODE(p_lot_rec.origination_date, g_miss_date, origination_date, NULL, NULL, p_lot_rec.origination_date)
6302 )
6303 , date_code =
6304 DECODE(
6305 p_source
6306 , 2, DECODE(p_lot_rec.date_code, g_miss_char, NULL, NULL, date_code, p_lot_rec.date_code)
6307 , DECODE(p_lot_rec.date_code, g_miss_char, date_code, NULL, NULL, p_lot_rec.date_code)
6308 )
6309 , status_id =
6310 DECODE(
6311 p_source
6312 , 2, DECODE(p_lot_rec.status_id, g_miss_num, NULL, NULL, status_id, p_lot_rec.status_id)
6313 , DECODE(p_lot_rec.status_id, g_miss_num, status_id, NULL, NULL, p_lot_rec.status_id)
6314 )
6315 , change_date =
6316 DECODE(
6317 p_source
6318 , 2, DECODE(p_lot_rec.change_date, g_miss_date, NULL, NULL, change_date, p_lot_rec.change_date)
6319 , DECODE(p_lot_rec.change_date, g_miss_date, change_date, NULL, NULL, p_lot_rec.change_date)
6320 )
6321 , age = DECODE(
6322 p_source
6323 , 2, DECODE(p_lot_rec.age, g_miss_num, NULL, NULL, age, p_lot_rec.age)
6324 , DECODE(p_lot_rec.age, g_miss_num, age, NULL, NULL, p_lot_rec.age)
6325 )
6326 , retest_date =
6327 DECODE(
6328 p_source
6329 , 2, DECODE(p_lot_rec.retest_date, g_miss_date, NULL, NULL, retest_date, p_lot_rec.retest_date)
6330 , DECODE(p_lot_rec.retest_date, g_miss_date, retest_date, NULL, NULL, p_lot_rec.retest_date)
6331 )
6332 , maturity_date =
6333 DECODE(
6334 p_source
6335 , 2, DECODE(p_lot_rec.maturity_date, g_miss_date, NULL, NULL, maturity_date, p_lot_rec.maturity_date)
6336 , DECODE(p_lot_rec.maturity_date, g_miss_date, maturity_date, NULL, NULL, p_lot_rec.maturity_date)
6337 )
6338 , item_size =
6339 DECODE(
6340 p_source
6341 , 2, DECODE(p_lot_rec.item_size, g_miss_num, NULL, NULL, item_size, p_lot_rec.item_size)
6342 , DECODE(p_lot_rec.item_size, g_miss_num, item_size, NULL, NULL, p_lot_rec.item_size)
6343 )
6344 , color =
6345 DECODE(
6346 p_source
6347 , 2, DECODE(p_lot_rec.color, g_miss_char, NULL, NULL, color, p_lot_rec.color)
6348 , DECODE(p_lot_rec.color, g_miss_char, color, NULL, NULL, p_lot_rec.color)
6349 )
6350 , volume =
6351 DECODE(
6352 p_source
6353 , 2, DECODE(p_lot_rec.volume, g_miss_num, NULL, NULL, volume, p_lot_rec.volume)
6354 , DECODE(p_lot_rec.volume, g_miss_num, volume, NULL, NULL, p_lot_rec.volume)
6355 )
6356 , volume_uom =
6357 DECODE(
6358 p_source
6359 , 2, DECODE(p_lot_rec.volume_uom, g_miss_char, NULL, NULL, volume_uom, p_lot_rec.volume_uom)
6360 , DECODE(p_lot_rec.volume_uom, g_miss_char, volume_uom, NULL, NULL, p_lot_rec.volume_uom)
6361 )
6362 , place_of_origin =
6363 DECODE(
6364 p_source
6365 , 2, DECODE(p_lot_rec.place_of_origin, g_miss_char, NULL, NULL, place_of_origin, p_lot_rec.place_of_origin)
6366 , DECODE(p_lot_rec.place_of_origin, g_miss_char, place_of_origin, NULL, place_of_origin, p_lot_rec.place_of_origin)
6367 )
6368 , best_by_date =
6369 DECODE(
6370 p_source
6371 , 2, DECODE(p_lot_rec.best_by_date, g_miss_date, NULL, NULL, best_by_date, p_lot_rec.best_by_date)
6372 , DECODE(p_lot_rec.best_by_date, g_miss_date, best_by_date, NULL, NULL, p_lot_rec.best_by_date)
6373 )
6374 , LENGTH =
6375 DECODE(
6376 p_source
6377 , 2, DECODE(p_lot_rec.length, g_miss_num, NULL, NULL, LENGTH, p_lot_rec.length)
6378 , DECODE(p_lot_rec.length, g_miss_num, LENGTH, NULL, NULL, p_lot_rec.length)
6379 )
6380 , length_uom =
6381 DECODE(
6382 p_source
6383 , 2, DECODE(p_lot_rec.length_uom, g_miss_char, NULL, NULL, length_uom, p_lot_rec.length_uom)
6384 , DECODE(p_lot_rec.length_uom, g_miss_char, length_uom, NULL, NULL, p_lot_rec.length_uom)
6385 )
6386 , recycled_content =
6387 DECODE(
6388 p_source
6389 , 2, DECODE(p_lot_rec.recycled_content, g_miss_num, NULL, NULL, recycled_content, p_lot_rec.recycled_content)
6390 , DECODE(p_lot_rec.recycled_content, g_miss_num, recycled_content, NULL, NULL, p_lot_rec.recycled_content)
6391 )
6392 , thickness =
6393 DECODE(
6394 p_source
6395 , 2, DECODE(p_lot_rec.thickness, g_miss_num, NULL, NULL, thickness, p_lot_rec.thickness)
6396 , DECODE(p_lot_rec.thickness, g_miss_num, thickness, NULL, NULL, p_lot_rec.thickness)
6397 )
6398 , thickness_uom =
6399 DECODE(
6400 p_source
6401 , 2, DECODE(p_lot_rec.thickness_uom, g_miss_char, NULL, NULL, thickness_uom, p_lot_rec.thickness_uom)
6402 , DECODE(p_lot_rec.thickness_uom, g_miss_char, thickness_uom, NULL, NULL, p_lot_rec.thickness_uom)
6403 )
6404 , width =
6405 DECODE(
6406 p_source
6407 , 2, DECODE(p_lot_rec.width, g_miss_num, NULL, NULL, width, p_lot_rec.width)
6408 , DECODE(p_lot_rec.width, g_miss_num, width, NULL, NULL, p_lot_rec.width)
6409 )
6410 , width_uom =
6411 DECODE(
6412 p_source
6413 , 2, DECODE(p_lot_rec.width_uom, g_miss_char, NULL, NULL, width_uom, p_lot_rec.width_uom)
6414 , DECODE(p_lot_rec.width_uom, g_miss_char, width_uom, NULL, NULL, p_lot_rec.width_uom)
6415 )
6416 , territory_code =
6417 DECODE(
6418 p_source
6419 , 2, DECODE(p_lot_rec.territory_code, g_miss_char, NULL, NULL, territory_code, p_lot_rec.territory_code)
6420 , DECODE(p_lot_rec.territory_code, g_miss_char, territory_code, NULL, NULL, p_lot_rec.territory_code)
6421 )
6422 , supplier_lot_number =
6423 DECODE(
6424 p_source
6425 , 2, DECODE(p_lot_rec.supplier_lot_number, g_miss_char, NULL, NULL, supplier_lot_number, p_lot_rec.supplier_lot_number)
6426 , DECODE(p_lot_rec.supplier_lot_number, g_miss_char, supplier_lot_number, NULL, NULL, p_lot_rec.supplier_lot_number)
6427 )
6428 -- Bug 6983527 - Parent lot number should never be updated.
6429 -- nsinghi bug#5209065. Update new lot attributes
6430 -- , parent_lot_number =
6431 -- DECODE(
6432 -- p_source
6433 -- , 2, DECODE(p_lot_rec.parent_lot_number, g_miss_char, NULL, NULL, parent_lot_number, p_lot_rec.parent_lot_number)
6434 -- , DECODE(p_lot_rec.parent_lot_number, g_miss_char, parent_lot_number, NULL, NULL, p_lot_rec.parent_lot_number)
6435 -- )
6436 , origination_type =
6437 DECODE(
6438 p_source
6439 , 2, DECODE(p_lot_rec.origination_type, g_miss_num, NULL, NULL, origination_type, p_lot_rec.origination_type)
6440 , DECODE(p_lot_rec.origination_type, g_miss_num, origination_type, NULL, NULL, p_lot_rec.origination_type)
6441 )
6442 , availability_type =
6443 DECODE(
6444 p_source
6445 , 2, DECODE(p_lot_rec.availability_type, g_miss_num, NULL, NULL, availability_type, p_lot_rec.availability_type)
6446 , DECODE(p_lot_rec.availability_type, g_miss_num, availability_type, NULL, NULL, p_lot_rec.availability_type)
6447 )
6448 , expiration_action_code =
6449 DECODE(
6450 p_source
6451 , 2, DECODE(p_lot_rec.expiration_action_code, g_miss_char, NULL, NULL, expiration_action_code, p_lot_rec.expiration_action_code)
6452 , DECODE(p_lot_rec.expiration_action_code, g_miss_char, expiration_action_code, NULL, NULL, p_lot_rec.expiration_action_code)
6453 )
6454 , expiration_action_date =
6455 DECODE(
6456 p_source
6457 , 2, DECODE(p_lot_rec.expiration_action_date, g_miss_date, NULL, NULL, expiration_action_date, p_lot_rec.expiration_action_date)
6458 , DECODE(p_lot_rec.expiration_action_date, g_miss_date, expiration_action_date, NULL, NULL, p_lot_rec.expiration_action_date)
6459 )
6460 , hold_date =
6461 DECODE(
6462 p_source
6463 , 2, DECODE(p_lot_rec.hold_date, g_miss_date, NULL, NULL, hold_date, p_lot_rec.hold_date)
6464 , DECODE(p_lot_rec.hold_date, g_miss_date, hold_date, NULL, NULL, p_lot_rec.hold_date)
6465 )
6466 , inventory_atp_code =
6467 DECODE(
6468 p_source
6469 , 2, DECODE(p_lot_rec.inventory_atp_code, g_miss_num, NULL, NULL, inventory_atp_code, p_lot_rec.inventory_atp_code)
6470 , DECODE(p_lot_rec.inventory_atp_code, g_miss_num, inventory_atp_code, NULL, NULL, p_lot_rec.inventory_atp_code)
6471 )
6472 , reservable_type =
6473 DECODE(
6474 p_source
6475 , 2, DECODE(p_lot_rec.reservable_type, g_miss_num, NULL, NULL, reservable_type, p_lot_rec.reservable_type)
6476 , DECODE(p_lot_rec.reservable_type, g_miss_num, reservable_type, NULL, NULL, p_lot_rec.reservable_type)
6477 )
6478 , sampling_event_id =
6479 DECODE(
6480 p_source
6481 , 2, DECODE(p_lot_rec.sampling_event_id, g_miss_num, NULL, NULL, sampling_event_id, p_lot_rec.sampling_event_id)
6482 , DECODE(p_lot_rec.sampling_event_id, g_miss_num, sampling_event_id, NULL, NULL, p_lot_rec.sampling_event_id)
6483 )
6484 -- nsinghi bug#5209065. End.
6485 , vendor_name =
6486 DECODE(
6487 p_source
6488 , 2, DECODE(p_lot_rec.vendor_name, g_miss_char, NULL, NULL, vendor_name, p_lot_rec.vendor_name)
6489 , DECODE(p_lot_rec.vendor_name, g_miss_char, vendor_name, NULL, NULL, p_lot_rec.vendor_name)
6490 )
6491 , attribute1 =
6492 DECODE(
6493 p_source
6494 , 2, DECODE(l_inv_attributes_tbl(1), g_miss_char, NULL, NULL, attribute1, l_inv_attributes_tbl(1))
6495 , DECODE(l_inv_attributes_tbl(1), g_miss_char, attribute1, NULL, NULL, l_inv_attributes_tbl(1))
6496 )
6497 , attribute2 =
6498 DECODE(
6499 p_source
6500 , 2, DECODE(l_inv_attributes_tbl(2), g_miss_char, NULL, NULL, attribute2, l_inv_attributes_tbl(2))
6501 , DECODE(l_inv_attributes_tbl(2), g_miss_char, attribute2, NULL, NULL, l_inv_attributes_tbl(2))
6502 )
6503 , attribute3 =
6504 DECODE(
6505 p_source
6506 , 2, DECODE(l_inv_attributes_tbl(3), g_miss_char, NULL, NULL, attribute3, l_inv_attributes_tbl(3))
6507 , DECODE(l_inv_attributes_tbl(3), g_miss_char, attribute3, NULL, NULL, l_inv_attributes_tbl(3))
6508 )
6509 , attribute4 =
6510 DECODE(
6511 p_source
6512 , 2, DECODE(l_inv_attributes_tbl(4), g_miss_char, NULL, NULL, attribute4, l_inv_attributes_tbl(4))
6513 , DECODE(l_inv_attributes_tbl(4), g_miss_char, attribute4, NULL, NULL, l_inv_attributes_tbl(4))
6514 )
6515 , attribute5 =
6516 DECODE(
6517 p_source
6518 , 2, DECODE(l_inv_attributes_tbl(5), g_miss_char, NULL, NULL, attribute5, l_inv_attributes_tbl(5))
6519 , DECODE(l_inv_attributes_tbl(5), g_miss_char, attribute5, NULL, NULL, l_inv_attributes_tbl(5))
6520 )
6521 , attribute6 =
6522 DECODE(
6523 p_source
6524 , 2, DECODE(l_inv_attributes_tbl(6), g_miss_char, NULL, NULL, attribute6, l_inv_attributes_tbl(6))
6525 , DECODE(l_inv_attributes_tbl(6), g_miss_char, attribute6, NULL, NULL, l_inv_attributes_tbl(6))
6526 )
6527 , attribute7 =
6528 DECODE(
6529 p_source
6530 , 2, DECODE(l_inv_attributes_tbl(7), g_miss_char, NULL, NULL, attribute7, l_inv_attributes_tbl(7))
6531 , DECODE(l_inv_attributes_tbl(7), g_miss_char, attribute7, NULL, NULL, l_inv_attributes_tbl(7))
6532 )
6533 , attribute8 =
6534 DECODE(
6535 p_source
6536 , 2, DECODE(l_inv_attributes_tbl(8), g_miss_char, NULL, NULL, attribute8, l_inv_attributes_tbl(8))
6537 , DECODE(l_inv_attributes_tbl(8), g_miss_char, attribute8, NULL, NULL, l_inv_attributes_tbl(8))
6538 )
6539 , attribute9 =
6540 DECODE(
6541 p_source
6542 , 2, DECODE(l_inv_attributes_tbl(9), g_miss_char, NULL, NULL, attribute9, l_inv_attributes_tbl(9))
6543 , DECODE(l_inv_attributes_tbl(9), g_miss_char, attribute9, NULL, NULL, l_inv_attributes_tbl(9))
6544 )
6545 , attribute10 =
6546 DECODE(
6547 p_source
6548 , 2, DECODE(l_inv_attributes_tbl(10), g_miss_char, NULL, NULL, attribute10, l_inv_attributes_tbl(10))
6549 , DECODE(l_inv_attributes_tbl(10), g_miss_char, attribute10, NULL, NULL, l_inv_attributes_tbl(10))
6550 )
6551 , attribute11 =
6552 DECODE(
6553 p_source
6554 , 2, DECODE(l_inv_attributes_tbl(11), g_miss_char, NULL, NULL, attribute11, l_inv_attributes_tbl(11))
6555 , DECODE(l_inv_attributes_tbl(11), g_miss_char, attribute11, NULL, NULL, l_inv_attributes_tbl(11))
6556 )
6557 , attribute12 =
6558 DECODE(
6559 p_source
6560 , 2, DECODE(l_inv_attributes_tbl(12), g_miss_char, NULL, NULL, attribute12, l_inv_attributes_tbl(12))
6561 , DECODE(l_inv_attributes_tbl(12), g_miss_char, attribute12, NULL, NULL, l_inv_attributes_tbl(12))
6562 )
6563 , attribute13 =
6564 DECODE(
6565 p_source
6566 , 2, DECODE(l_inv_attributes_tbl(13), g_miss_char, NULL, NULL, attribute13, l_inv_attributes_tbl(13))
6567 , DECODE(l_inv_attributes_tbl(13), g_miss_char, attribute13, NULL, NULL, l_inv_attributes_tbl(13))
6568 )
6569 , attribute14 =
6570 DECODE(
6571 p_source
6572 , 2, DECODE(l_inv_attributes_tbl(14), g_miss_char, NULL, NULL, attribute14, l_inv_attributes_tbl(14))
6573 , DECODE(l_inv_attributes_tbl(14), g_miss_char, attribute14, NULL, NULL, l_inv_attributes_tbl(14))
6574 )
6575 , attribute15 =
6576 DECODE(
6577 p_source
6578 , 2, DECODE(l_inv_attributes_tbl(15), g_miss_char, NULL, NULL, attribute15, l_inv_attributes_tbl(15))
6579 , DECODE(l_inv_attributes_tbl(15), g_miss_char, attribute15, NULL, NULL, l_inv_attributes_tbl(15))
6580 )
6581 /*, c_attribute1 = decode(p_source, 2,
6582 DECODE(l_c_attributes_tbl(1), g_miss_char, NULL, NULL, c_attribute1, l_c_attributes_tbl(1))
6583 ,DECODE(l_c_attributes_tbl(1), g_miss_char, c_attribute1, NULL, null, l_c_attributes_tbl(1)))
6584 , c_attribute2 = decode(p_source, 2,
6585 DECODE(l_c_attributes_tbl(2), g_miss_char, NULL, NULL, c_attribute2, l_c_attributes_tbl(2))
6586 ,DECODE(l_c_attributes_tbl(2), g_miss_char, c_attribute2, NULL, null, l_c_attributes_tbl(2)))
6587 , c_attribute3 = decode(p_source, 2,
6588 DECODE(l_c_attributes_tbl(3), g_miss_char, NULL, NULL, c_attribute3, l_c_attributes_tbl(3))
6589 ,DECODE(l_c_attributes_tbl(3), g_miss_char, c_attribute3, NULL, null, l_c_attributes_tbl(3)))
6590 , c_attribute4 = decode(p_source, 2,
6591 DECODE(l_c_attributes_tbl(4), g_miss_char, NULL, NULL, c_attribute4, l_c_attributes_tbl(4))
6592 ,DECODE(l_c_attributes_tbl(4), g_miss_char, c_attribute4, NULL, null, l_c_attributes_tbl(4)))
6593 , c_attribute5 = decode(p_source, 2,
6594 DECODE(l_c_attributes_tbl(5), g_miss_char, NULL, NULL, c_attribute5, l_c_attributes_tbl(5))
6595 ,DECODE(l_c_attributes_tbl(5), g_miss_char, c_attribute5, NULL, null, l_c_attributes_tbl(5)))
6596 , c_attribute6 = decode(p_source, 2,
6597 DECODE(l_c_attributes_tbl(6), g_miss_char, NULL, NULL, c_attribute6, l_c_attributes_tbl(6))
6598 ,DECODE(l_c_attributes_tbl(6), g_miss_char, c_attribute6, NULL, null, l_c_attributes_tbl(6)))
6599 , c_attribute7 = decode(p_source, 2,
6600 DECODE(l_c_attributes_tbl(7), g_miss_char, NULL, NULL, c_attribute7, l_c_attributes_tbl(7))
6601 ,DECODE(l_c_attributes_tbl(7), g_miss_char, c_attribute7, NULL, null, l_c_attributes_tbl(7)))
6602 , c_attribute8 = decode(p_source, 2,
6603 DECODE(l_c_attributes_tbl(8), g_miss_char, NULL, NULL, c_attribute8, l_c_attributes_tbl(8))
6604 ,DECODE(l_c_attributes_tbl(8), g_miss_char, c_attribute8, NULL, null, l_c_attributes_tbl(8)))
6605 , c_attribute9 = decode(p_source, 2,
6606 DECODE(l_c_attributes_tbl(9), g_miss_char, NULL, NULL, c_attribute9, l_c_attributes_tbl(9))
6607 ,DECODE(l_c_attributes_tbl(9), g_miss_char, c_attribute9, NULL, null, l_c_attributes_tbl(9)))
6608 , c_attribute10 = decode(p_source, 2,
6609 DECODE(l_c_attributes_tbl(10), g_miss_char, NULL, NULL, c_attribute10, l_c_attributes_tbl(10))
6610 ,DECODE(l_c_attributes_tbl(10), g_miss_char, c_attribute10, NULL, null, l_c_attributes_tbl(10)))
6611 , c_attribute11 = decode(p_source, 2,
6612 DECODE(l_c_attributes_tbl(11), g_miss_char, NULL, NULL, c_attribute11, l_c_attributes_tbl(11))
6613 ,DECODE(l_c_attributes_tbl(11), g_miss_char, c_attribute11, NULL, null, l_c_attributes_tbl(11)))
6614 , c_attribute12 = decode(p_source, 2,
6615 DECODE(l_c_attributes_tbl(12), g_miss_char, NULL, NULL, c_attribute12, l_c_attributes_tbl(12))
6616 ,DECODE(l_c_attributes_tbl(12), g_miss_char, c_attribute12, NULL, null, l_c_attributes_tbl(12)))
6617 , c_attribute13 = decode(p_source, 2,
6618 DECODE(l_c_attributes_tbl(13), g_miss_char, NULL, NULL, c_attribute13, l_c_attributes_tbl(13))
6619 ,DECODE(l_c_attributes_tbl(13), g_miss_char, c_attribute13, NULL, null, l_c_attributes_tbl(13)))
6620 , c_attribute14 = decode(p_source, 2,
6621 DECODE(l_c_attributes_tbl(14), g_miss_char, NULL, NULL, c_attribute14, l_c_attributes_tbl(14))
6622 ,DECODE(l_c_attributes_tbl(14), g_miss_char, c_attribute14, NULL, null, l_c_attributes_tbl(14)))
6623 , c_attribute15 = decode(p_source, 2,
6624 DECODE(l_c_attributes_tbl(15), g_miss_char, NULL, NULL, c_attribute15, l_c_attributes_tbl(15))
6625 ,DECODE(l_c_attributes_tbl(15), g_miss_char, c_attribute15, NULL, null, l_c_attributes_tbl(15)))
6626 , c_attribute16 = decode(p_source, 2,
6627 DECODE(l_c_attributes_tbl(16), g_miss_char, NULL, NULL, c_attribute16, l_c_attributes_tbl(16))
6628 ,DECODE(l_c_attributes_tbl(16), g_miss_char, c_attribute16, NULL, null, l_c_attributes_tbl(16)))
6629 , c_attribute17 = decode(p_source, 2,
6630 DECODE(l_c_attributes_tbl(17), g_miss_char, NULL, NULL, c_attribute17, l_c_attributes_tbl(17))
6631 ,DECODE(l_c_attributes_tbl(17), g_miss_char, c_attribute17, NULL, null, l_c_attributes_tbl(17)))
6632 , c_attribute18 = decode(p_source, 2,
6633 DECODE(l_c_attributes_tbl(18), g_miss_char, NULL, NULL, c_attribute18, l_c_attributes_tbl(18))
6634 ,DECODE(l_c_attributes_tbl(18), g_miss_char, c_attribute18, NULL, null, l_c_attributes_tbl(18)))
6635 , c_attribute19 = decode(p_source, 2,
6636 DECODE(l_c_attributes_tbl(19), g_miss_char, NULL, NULL, c_attribute19, l_c_attributes_tbl(19))
6637 ,DECODE(l_c_attributes_tbl(19), g_miss_char, c_attribute19, NULL, null, l_c_attributes_tbl(19)))
6638 , c_attribute20 = decode(p_source, 2,
6639 DECODE(l_c_attributes_tbl(20), g_miss_char, NULL, NULL, c_attribute20, l_c_attributes_tbl(20))
6640 ,DECODE(l_c_attributes_tbl(20), g_miss_char, c_attribute20, NULL, null, l_c_attributes_tbl(20)))
6641 , n_attribute1 = decode(p_source, 2,
6642 DECODE(l_n_attributes_tbl(1), g_miss_num, NULL, NULL, n_attribute1, l_n_attributes_tbl(1))
6643 , DECODE(l_n_attributes_tbl(1), g_miss_num, N_attribute1, NULL, null, l_n_attributes_tbl(1)))
6644 , n_attribute2 = decode(p_source, 2,
6645 DECODE(l_n_attributes_tbl(2), g_miss_num, NULL, NULL, n_attribute2, l_n_attributes_tbl(2))
6646 , DECODE(l_n_attributes_tbl(2), g_miss_num, N_attribute2, NULL, null, l_n_attributes_tbl(2)))
6647 , n_attribute3 = decode(p_source, 2,
6648 DECODE(l_n_attributes_tbl(3), g_miss_num, NULL, NULL, n_attribute3, l_n_attributes_tbl(3))
6649 , DECODE(l_n_attributes_tbl(3), g_miss_num, N_attribute3, NULL, null, l_n_attributes_tbl(3)))
6650 , n_attribute4 = decode(p_source, 2,
6651 DECODE(l_n_attributes_tbl(4), g_miss_num, NULL, NULL, n_attribute4, l_n_attributes_tbl(4))
6652 , DECODE(l_n_attributes_tbl(4), g_miss_num, N_attribute4, NULL, null, l_n_attributes_tbl(4)))
6653 , n_attribute5 = decode(p_source, 2,
6654 DECODE(l_n_attributes_tbl(5), g_miss_num, NULL, NULL, n_attribute5, l_n_attributes_tbl(5))
6655 , DECODE(l_n_attributes_tbl(5), g_miss_num, N_attribute5, NULL, null, l_n_attributes_tbl(5)))
6656 , n_attribute6 = decode(p_source, 2,
6657 DECODE(l_n_attributes_tbl(6), g_miss_num, NULL, NULL, n_attribute6, l_n_attributes_tbl(6))
6658 , DECODE(l_n_attributes_tbl(6), g_miss_num, N_attribute6, NULL, null, l_n_attributes_tbl(6)))
6659 , n_attribute7 = decode(p_source, 2,
6660 DECODE(l_n_attributes_tbl(7), g_miss_num, NULL, NULL, n_attribute7, l_n_attributes_tbl(7))
6661 , DECODE(l_n_attributes_tbl(7), g_miss_num, N_attribute7, NULL, null, l_n_attributes_tbl(7)))
6662 , n_attribute8 = decode(p_source, 2,
6663 DECODE(l_n_attributes_tbl(8), g_miss_num, NULL, NULL, n_attribute8, l_n_attributes_tbl(8))
6664 , DECODE(l_n_attributes_tbl(8), g_miss_num, N_attribute8, NULL, null, l_n_attributes_tbl(8)))
6665 , n_attribute9 = decode(p_source, 2,
6666 DECODE(l_n_attributes_tbl(9), g_miss_num, NULL, NULL, n_attribute9, l_n_attributes_tbl(9))
6667 ,DECODE(l_n_attributes_tbl(9), g_miss_num, N_attribute9, NULL, null, l_n_attributes_tbl(9)))
6668 , n_attribute10 = decode(p_source, 2,
6669 DECODE(l_n_attributes_tbl(10), g_miss_num, NULL, NULL, n_attribute10, l_n_attributes_tbl(10))
6670 ,DECODE(l_n_attributes_tbl(10), g_miss_num, n_attribute10, NULL, null, l_n_attributes_tbl(10)))
6671 , d_attribute1 = decode(p_source, 2,
6672 DECODE(l_d_attributes_tbl(1), g_miss_date, NULL, NULL, d_attribute1, l_d_attributes_tbl(1))
6673 , DECODE(l_d_attributes_tbl(1), g_miss_date, d_attribute1, NULL, null, l_d_attributes_tbl(1)))
6674 , d_attribute2 = decode(p_source, 2,
6675 DECODE(l_d_attributes_tbl(2), g_miss_date, NULL, NULL, d_attribute2, l_d_attributes_tbl(2))
6676 , DECODE(l_d_attributes_tbl(2), g_miss_date, d_attribute2, NULL, null, l_d_attributes_tbl(2)))
6677 , d_attribute3 = decode(p_source, 2,
6678 DECODE(l_d_attributes_tbl(3), g_miss_date, NULL, NULL, d_attribute3, l_d_attributes_tbl(3))
6679 , DECODE(l_d_attributes_tbl(3), g_miss_date, d_attribute3, NULL, null, l_d_attributes_tbl(3)))
6680 , d_attribute4 = decode(p_source, 2,
6681 DECODE(l_d_attributes_tbl(4), g_miss_date, NULL, NULL, d_attribute4, l_d_attributes_tbl(4))
6682 , DECODE(l_d_attributes_tbl(4), g_miss_date, d_attribute4, NULL, null, l_d_attributes_tbl(4)))
6683 , d_attribute5 = decode(p_source, 2,
6684 DECODE(l_d_attributes_tbl(5), g_miss_date, NULL, NULL, d_attribute5, l_d_attributes_tbl(5))
6685 , DECODE(l_d_attributes_tbl(5), g_miss_date, d_attribute5, NULL, null, l_d_attributes_tbl(5)))
6686 , d_attribute6 = decode(p_source, 2,
6687 DECODE(l_d_attributes_tbl(6), g_miss_date, NULL, NULL, d_attribute6, l_d_attributes_tbl(6))
6688 ,DECODE(l_d_attributes_tbl(6), g_miss_date, d_attribute6, NULL, null, l_d_attributes_tbl(6)))
6689 , d_attribute7 = decode(p_source, 2,
6690 DECODE(l_d_attributes_tbl(7), g_miss_date, NULL, NULL, d_attribute7, l_d_attributes_tbl(7))
6691 , DECODE(l_d_attributes_tbl(7), g_miss_date, d_attribute7, NULL, null, l_d_attributes_tbl(7)))
6692 , d_attribute8 = decode(p_source, 2,
6693 DECODE(l_d_attributes_tbl(8), g_miss_date, NULL, NULL, d_attribute8, l_d_attributes_tbl(8))
6694 , DECODE(l_d_attributes_tbl(8), g_miss_date, d_attribute8, NULL, null, l_d_attributes_tbl(8)))
6695 , d_attribute9 = decode(p_source, 2,
6696 DECODE(l_d_attributes_tbl(9), g_miss_date, NULL, NULL, d_attribute9, l_d_attributes_tbl(9))
6697 , DECODE(l_d_attributes_tbl(9), g_miss_date, d_attribute9, NULL, null, l_d_attributes_tbl(9)))
6698 , d_attribute10 = decode(p_source, 2,
6699 DECODE(l_d_attributes_tbl(10), g_miss_date, NULL, NULL, d_attribute10, l_d_attributes_tbl(10))
6700 ,DECODE(l_d_attributes_tbl(10), g_miss_date, d_attribute10, NULL, null, l_d_attributes_tbl(10)))*/
6701 WHERE inventory_item_id = p_lot_rec.inventory_item_id
6702 AND organization_id = p_lot_rec.organization_id
6703 AND lot_number = p_lot_rec.lot_number;
6704 END IF;
6705
6706
6707 IF SQL%FOUND THEN
6708 IF g_debug = 1 THEN
6709 print_debug('Upd Lot Attr:Update successfully completed', 9);
6710 END IF;
6711 END IF;
6712 EXCEPTION
6713 WHEN NO_DATA_FOUND THEN
6714 x_return_status := g_ret_sts_error;
6715 ROLLBACK TO upd_lot_attr;
6716 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6717 if( x_msg_count > 1 ) then
6718 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
6719 end if;
6720 print_debug('Upd Lort Attr: In No data found ' || SQLERRM, 9);
6721 WHEN g_exc_error THEN
6722 x_return_status := g_ret_sts_error;
6723 ROLLBACK TO upd_lot_attr;
6724 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6725 if( x_msg_count > 1 ) then
6726 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
6727 end if;
6728 print_debug('Upd Lot Attr: In g_exc_error ' || SQLERRM, 9);
6729 WHEN g_exc_unexpected_error THEN
6730 x_return_status := g_ret_sts_unexp_error;
6731 ROLLBACK TO upd_lot_attr;
6732 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6733 if ( x_msg_count > 1 ) then
6734 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
6735 end if;
6736 print_debug('In g_exc_unexpected_error ' || SQLERRM, 9);
6737 WHEN OTHERS THEN
6738 x_return_status := g_ret_sts_unexp_error;
6739 ROLLBACK TO upd_lot_attr;
6740 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
6741 if( x_msg_count > 1 ) then
6742 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
6743 end if;
6744 print_debug('Upd Lot Attr: In others ' || SQLERRM, 9);
6745 END update_inv_lot;
6746
6747 -- nsinghi bug#5209065. Created Overloaded procedure, which takes in lot rec as input parameter. This will help updating the new lot attributes added in R12.
6748 PROCEDURE update_inv_lot(
6749 x_return_status OUT NOCOPY VARCHAR2
6750 , x_msg_count OUT NOCOPY NUMBER
6751 , x_msg_data OUT NOCOPY VARCHAR2
6752 , p_inventory_item_id IN NUMBER
6753 , p_organization_id IN NUMBER
6754 , p_lot_number IN VARCHAR2
6755 , p_expiration_date IN DATE
6756 , p_disable_flag IN NUMBER
6757 , p_attribute_category IN VARCHAR2
6758 , p_lot_attribute_category IN VARCHAR2
6759 , p_attributes_tbl IN inv_lot_api_pub.char_tbl
6760 , p_c_attributes_tbl IN inv_lot_api_pub.char_tbl
6761 , p_n_attributes_tbl IN inv_lot_api_pub.number_tbl
6762 , p_d_attributes_tbl IN inv_lot_api_pub.date_tbl
6763 , p_grade_code IN VARCHAR2
6764 , p_origination_date IN DATE
6765 , p_date_code IN VARCHAR2
6766 , p_status_id IN NUMBER
6767 , p_change_date IN DATE
6768 , p_age IN NUMBER
6769 , p_retest_date IN DATE
6770 , p_maturity_date IN DATE
6771 , p_item_size IN NUMBER
6772 , p_color IN VARCHAR2
6773 , p_volume IN NUMBER
6774 , p_volume_uom IN VARCHAR2
6775 , p_place_of_origin IN VARCHAR2
6776 , p_best_by_date IN DATE
6777 , p_length IN NUMBER
6778 , p_length_uom IN VARCHAR2
6779 , p_recycled_content IN NUMBER
6780 , p_thickness IN NUMBER
6781 , p_thickness_uom IN VARCHAR2
6782 , p_width IN NUMBER
6783 , p_width_uom IN VARCHAR2
6784 , p_territory_code IN VARCHAR2
6785 , p_supplier_lot_number IN VARCHAR2
6786 , p_vendor_name IN VARCHAR2
6787 , p_source IN NUMBER
6788 ) IS
6789 l_in_lot_rec MTL_LOT_NUMBERS%ROWTYPE;
6790 x_lot_rec MTL_LOT_NUMBERS%ROWTYPE;
6791 l_api_version NUMBER;
6792 l_init_msg_list VARCHAR2(100);
6793 l_commit VARCHAR2(100);
6794 l_origin_txn_id NUMBER;
6795 l_return_status VARCHAR2(1) ;
6796 l_msg_data VARCHAR2(3000) ;
6797 l_msg_count NUMBER ;
6798
6799 BEGIN
6800 SAVEPOINT upd_lot_attr;
6801 x_return_status := fnd_api.g_ret_sts_success;
6802
6803 /* Populating the variables and calling the new overloaded API */
6804
6805 l_in_lot_rec.inventory_item_id := p_inventory_item_id;
6806 l_in_lot_rec.organization_id := p_organization_id;
6807 l_in_lot_rec.lot_number := p_lot_number;
6808 l_in_lot_rec.parent_lot_number := NULL;
6809 l_in_lot_rec.expiration_date := p_expiration_date;
6810 l_in_lot_rec.disable_flag := p_disable_flag;
6811 l_in_lot_rec.attribute_category := p_attribute_category;
6812 l_in_lot_rec.lot_attribute_category := p_lot_attribute_category;
6813 l_in_lot_rec.grade_code := p_grade_code;
6814 l_in_lot_rec.origination_date := p_origination_date;
6815 l_in_lot_rec.date_code := p_date_code;
6816 l_in_lot_rec.status_id := p_status_id;
6817 l_in_lot_rec.change_date := p_change_date;
6818 l_in_lot_rec.age := p_age;
6819 l_in_lot_rec.retest_date := p_retest_date;
6820 l_in_lot_rec.maturity_date := p_maturity_date;
6821 l_in_lot_rec.item_size := p_item_size;
6822 l_in_lot_rec.color := p_color;
6823 l_in_lot_rec.volume := p_volume;
6824 l_in_lot_rec.volume_uom := p_volume_uom;
6825 l_in_lot_rec.place_of_origin := p_place_of_origin;
6826 l_in_lot_rec.best_by_date := p_best_by_date;
6827 l_in_lot_rec.length := p_length;
6828 l_in_lot_rec.length_uom := p_length_uom;
6829 l_in_lot_rec.recycled_content := p_recycled_content;
6830 l_in_lot_rec.thickness := p_thickness;
6831 l_in_lot_rec.thickness_uom := p_thickness_uom;
6832 l_in_lot_rec.width := p_width;
6833 l_in_lot_rec.width_uom := p_width_uom;
6834 l_in_lot_rec.territory_code := p_territory_code;
6835 l_in_lot_rec.supplier_lot_number := p_supplier_lot_number;
6836 l_in_lot_rec.vendor_name := p_vendor_name;
6837 l_in_lot_rec.last_update_date := SYSDATE ;
6838 l_in_lot_rec.last_updated_by := FND_GLOBAL.USER_ID;
6839 l_in_lot_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
6840 --BUG 4748451: if the p%tbl are not initialized, then a no_date_found
6841 --exception would be thrown if accessed. So add clause to check for this
6842 IF (p_attributes_tbl.exists(1)) THEN
6843 l_in_lot_rec.attribute1 := p_attributes_tbl(1);
6844 END IF;
6845 IF (p_attributes_tbl.exists(2)) THEN
6846 l_in_lot_rec.attribute2 := p_attributes_tbl(2);
6847 END IF;
6848 IF (p_attributes_tbl.exists(3)) THEN
6849 l_in_lot_rec.attribute3 := p_attributes_tbl(3);
6850 END IF;
6851 IF (p_attributes_tbl.exists(4)) THEN
6852 l_in_lot_rec.attribute4 := p_attributes_tbl(4);
6853 END IF;
6854 IF (p_attributes_tbl.exists(5)) THEN
6855 l_in_lot_rec.attribute5 := p_attributes_tbl(5);
6856 END IF;
6857 IF (p_attributes_tbl.exists(6)) THEN
6858 l_in_lot_rec.attribute6 := p_attributes_tbl(6);
6859 END IF;
6860 IF (p_attributes_tbl.exists(7)) THEN
6861 l_in_lot_rec.attribute7 := p_attributes_tbl(7);
6862 END IF;
6863 IF (p_attributes_tbl.exists(8)) THEN
6864 l_in_lot_rec.attribute8 := p_attributes_tbl(8);
6865 END IF;
6866 IF (p_attributes_tbl.exists(9)) THEN
6867 l_in_lot_rec.attribute9 := p_attributes_tbl(9);
6868 END IF;
6869 IF (p_attributes_tbl.exists(10)) THEN
6870 l_in_lot_rec.attribute10 := p_attributes_tbl(10);
6871 END IF;
6872 IF (p_attributes_tbl.exists(11)) THEN
6873 l_in_lot_rec.attribute11 := p_attributes_tbl(11);
6874 END IF;
6875 IF (p_attributes_tbl.exists(12)) THEN
6876 l_in_lot_rec.attribute12 := p_attributes_tbl(12);
6877 END IF;
6878 IF (p_attributes_tbl.exists(13)) THEN
6879 l_in_lot_rec.attribute13 := p_attributes_tbl(13);
6880 END IF;
6881 IF (p_attributes_tbl.exists(14)) THEN
6882 l_in_lot_rec.attribute14 := p_attributes_tbl(14);
6883 END IF;
6884 IF (p_attributes_tbl.exists(15)) THEN
6885 l_in_lot_rec.attribute15 := p_attributes_tbl(15);
6886 END IF;
6887 IF (p_c_attributes_tbl.exists(1)) THEN
6888 l_in_lot_rec.c_attribute1 := p_c_attributes_tbl(1);
6889 END IF;
6890 IF (p_c_attributes_tbl.exists(2)) THEN
6891 l_in_lot_rec.c_attribute2 := p_c_attributes_tbl(2);
6892 END IF;
6893 IF (p_c_attributes_tbl.exists(3)) THEN
6894 l_in_lot_rec.c_attribute3 := p_c_attributes_tbl(3);
6895 END IF;
6896 IF (p_c_attributes_tbl.exists(4)) THEN
6897 l_in_lot_rec.c_attribute4 := p_c_attributes_tbl(4);
6898 END IF;
6899 IF (p_c_attributes_tbl.exists(5)) THEN
6900 l_in_lot_rec.c_attribute5 := p_c_attributes_tbl(5);
6901 END IF;
6902 IF (p_c_attributes_tbl.exists(6)) THEN
6903 l_in_lot_rec.c_attribute6 := p_c_attributes_tbl(6);
6904 END IF;
6905 IF (p_c_attributes_tbl.exists(7)) THEN
6906 l_in_lot_rec.c_attribute7 := p_c_attributes_tbl(7);
6907 END IF;
6908 IF (p_c_attributes_tbl.exists(8)) THEN
6909 l_in_lot_rec.c_attribute8 := p_c_attributes_tbl(8);
6910 END IF;
6911 IF (p_c_attributes_tbl.exists(9)) THEN
6912 l_in_lot_rec.c_attribute9 := p_c_attributes_tbl(9);
6913 END IF;
6914 IF (p_c_attributes_tbl.exists(10)) THEN
6915 l_in_lot_rec.c_attribute10 := p_c_attributes_tbl(10);
6916 END IF;
6917 IF (p_c_attributes_tbl.exists(11)) THEN
6918 l_in_lot_rec.c_attribute11 := p_c_attributes_tbl(11);
6919 END IF;
6920 IF (p_c_attributes_tbl.exists(12)) THEN
6921 l_in_lot_rec.c_attribute12 := p_c_attributes_tbl(12);
6922 END IF;
6923 IF (p_c_attributes_tbl.exists(13)) THEN
6924 l_in_lot_rec.c_attribute13 := p_c_attributes_tbl(13);
6925 END IF;
6926 IF (p_c_attributes_tbl.exists(14)) THEN
6927 l_in_lot_rec.c_attribute14 := p_c_attributes_tbl(14);
6928 END IF;
6929 IF (p_c_attributes_tbl.exists(15)) THEN
6930 l_in_lot_rec.c_attribute15 := p_c_attributes_tbl(15);
6931 END IF;
6932 IF (p_c_attributes_tbl.exists(16)) THEN
6933 l_in_lot_rec.c_attribute16 := p_c_attributes_tbl(16);
6934 END IF;
6935 IF (p_c_attributes_tbl.exists(17)) THEN
6936 l_in_lot_rec.c_attribute17 := p_c_attributes_tbl(17);
6937 END IF;
6938 IF (p_c_attributes_tbl.exists(18)) THEN
6939 l_in_lot_rec.c_attribute18 := p_c_attributes_tbl(18);
6940 END IF;
6941 IF (p_c_attributes_tbl.exists(19)) THEN
6942 l_in_lot_rec.c_attribute19 := p_c_attributes_tbl(19);
6943 END IF;
6944 IF (p_c_attributes_tbl.exists(20)) THEN
6945 l_in_lot_rec.c_attribute20 := p_c_attributes_tbl(20);
6946 END IF;
6947 IF (p_n_attributes_tbl.exists(1)) THEN
6948 l_in_lot_rec.n_attribute1 := p_n_attributes_tbl(1);
6949 END IF;
6950 IF (p_n_attributes_tbl.exists(2)) THEN
6951 l_in_lot_rec.n_attribute2 := p_n_attributes_tbl(2);
6952 END IF;
6953 IF (p_n_attributes_tbl.exists(3)) THEN
6954 l_in_lot_rec.n_attribute3 := p_n_attributes_tbl(3);
6955 END IF;
6956 IF (p_n_attributes_tbl.exists(4)) THEN
6957 l_in_lot_rec.n_attribute4 := p_n_attributes_tbl(4);
6958 END IF;
6959 IF (p_n_attributes_tbl.exists(5)) THEN
6960 l_in_lot_rec.n_attribute5 := p_n_attributes_tbl(5);
6961 END IF;
6962 IF (p_n_attributes_tbl.exists(6)) THEN
6963 l_in_lot_rec.n_attribute6 := p_n_attributes_tbl(6);
6964 END IF;
6965 IF (p_n_attributes_tbl.exists(7)) THEN
6966 l_in_lot_rec.n_attribute7 := p_n_attributes_tbl(7);
6967 END IF;
6968 IF (p_n_attributes_tbl.exists(8)) THEN
6969 l_in_lot_rec.n_attribute8 := p_n_attributes_tbl(8);
6970 END IF;
6971 IF (p_n_attributes_tbl.exists(9)) THEN
6972 l_in_lot_rec.n_attribute9 := p_n_attributes_tbl(9);
6973 END IF;
6974 IF (p_n_attributes_tbl.exists(10)) THEN
6975 l_in_lot_rec.n_attribute10 := p_n_attributes_tbl(10);
6976 END IF;
6977 IF (p_d_attributes_tbl.exists(1)) THEN
6978 l_in_lot_rec.d_attribute1 := p_d_attributes_tbl(1);
6979 END IF;
6980 IF (p_d_attributes_tbl.exists(2)) THEN
6981 l_in_lot_rec.d_attribute2 := p_d_attributes_tbl(2);
6982 END IF;
6983 IF (p_d_attributes_tbl.exists(3)) THEN
6984 l_in_lot_rec.d_attribute3 := p_d_attributes_tbl(3);
6985 END IF;
6986 IF (p_d_attributes_tbl.exists(4)) THEN
6987 l_in_lot_rec.d_attribute4 := p_d_attributes_tbl(4);
6988 END IF;
6989 IF (p_d_attributes_tbl.exists(5)) THEN
6990 l_in_lot_rec.d_attribute5 := p_d_attributes_tbl(5);
6991 END IF;
6992 IF (p_d_attributes_tbl.exists(6)) THEN
6993 l_in_lot_rec.d_attribute6 := p_d_attributes_tbl(6);
6994 END IF;
6995 IF (p_d_attributes_tbl.exists(7)) THEN
6996 l_in_lot_rec.d_attribute7 := p_d_attributes_tbl(7);
6997 END IF;
6998 IF (p_d_attributes_tbl.exists(8)) THEN
6999 l_in_lot_rec.d_attribute8 := p_d_attributes_tbl(8);
7000 END IF;
7001 IF (p_d_attributes_tbl.exists(9)) THEN
7002 l_in_lot_rec.d_attribute9 := p_d_attributes_tbl(9);
7003 END IF;
7004 IF (p_d_attributes_tbl.exists(10)) THEN
7005 l_in_lot_rec.d_attribute10 := p_d_attributes_tbl(10);
7006 END IF;
7007 --END BUG 4748451
7008 l_api_version := 1.0;
7009 l_init_msg_list := fnd_api.g_false;
7010 l_commit := fnd_api.g_false;
7011 l_origin_txn_id := NULL;
7012
7013 /* Calling the overloaded procedure */
7014 Update_Inv_lot(
7015 x_return_status => l_return_status
7016 , x_msg_count => l_msg_count
7017 , x_msg_data => l_msg_data
7018 , x_lot_rec => x_lot_rec
7019 , p_lot_rec => l_in_lot_rec
7020 , p_source => p_source
7021 , p_api_version => l_api_version
7022 , p_init_msg_list => l_init_msg_list
7023 , p_commit => l_commit
7024 );
7025
7026 IF g_debug = 1 THEN
7027 print_debug('Program Update_Inv_lot return ' || l_return_status, 9);
7028 END IF;
7029 IF l_return_status = fnd_api.g_ret_sts_error THEN
7030 IF g_debug = 1 THEN
7031 print_debug('Program Update_Inv_lot has failed with a user defined exception', 9);
7032 END IF;
7033 RAISE g_exc_error;
7034 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
7035 IF g_debug = 1 THEN
7036 print_debug('Program Update_Inv_lot has failed with a Unexpected exception', 9);
7037 END IF;
7038 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
7039 FND_MESSAGE.SET_TOKEN('PROG_NAME','Update_Inv_lot');
7040 fnd_msg_pub.ADD;
7041 RAISE g_exc_unexpected_error;
7042 END IF;
7043
7044 print_debug('End of the program Update_Inv_lot. Program has completed successfully ', 9);
7045 EXCEPTION
7046 WHEN NO_DATA_FOUND THEN
7047 x_return_status := g_ret_sts_error;
7048 ROLLBACK TO upd_lot_attr;
7049 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7050 if( x_msg_count > 1 ) then
7051 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
7052 end if;
7053 print_debug('Upd Lot Attr: In No data found ' || SQLERRM, 9);
7054 WHEN g_exc_error THEN
7055 x_return_status := g_ret_sts_error;
7056 ROLLBACK TO upd_lot_attr;
7057 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7058 if( x_msg_count > 1 ) then
7059 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
7060 end if;
7061 print_debug('Upd Lot Attr: In g_exc_error ' || SQLERRM, 9);
7062 WHEN g_exc_unexpected_error THEN
7063 x_return_status := g_ret_sts_unexp_error;
7064 ROLLBACK TO upd_lot_attr;
7065 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7066 if ( x_msg_count > 1 ) then
7067 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
7068 end if;
7069 print_debug('In g_exc_unexpected_error ' || SQLERRM, 9);
7070 WHEN OTHERS THEN
7071 x_return_status := g_ret_sts_unexp_error;
7072 ROLLBACK TO upd_lot_attr;
7073 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7074 if( x_msg_count > 1 ) then
7075 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
7076 end if;
7077 print_debug('Upd Lot Attr: In others ' || SQLERRM, 9);
7078
7079 END update_inv_lot;
7080 -- nsinghi END. Created new overloaded procedure.
7081
7082 PROCEDURE wms_lot_attr_validate(
7083 x_return_status OUT NOCOPY VARCHAR2
7084 , x_msg_count OUT NOCOPY NUMBER
7085 , x_msg_data OUT NOCOPY VARCHAR2
7086 , p_inventory_item_id IN NUMBER
7087 , p_organization_id IN NUMBER
7088 , p_disable_flag IN NUMBER
7089 , p_lot_attribute_category IN VARCHAR2
7090 , p_c_attributes_tbl IN inv_lot_api_pub.char_tbl
7091 , p_n_attributes_tbl IN inv_lot_api_pub.number_tbl
7092 , p_d_attributes_tbl IN inv_lot_api_pub.date_tbl
7093 , p_grade_code IN VARCHAR2
7094 , p_origination_date IN DATE
7095 , p_date_code IN VARCHAR2
7096 , p_change_date IN DATE
7097 , p_age IN NUMBER
7098 , p_retest_date IN DATE
7099 , p_maturity_date IN DATE
7100 , p_item_size IN NUMBER
7101 , p_color IN VARCHAR2
7102 , p_volume IN NUMBER
7103 , p_volume_uom IN VARCHAR2
7104 , p_place_of_origin IN VARCHAR2
7105 , p_best_by_date IN DATE
7106 , p_length IN NUMBER
7107 , p_length_uom IN VARCHAR2
7108 , p_recycled_content IN NUMBER
7109 , p_thickness IN NUMBER
7110 , p_thickness_uom IN VARCHAR2
7111 , p_width IN NUMBER
7112 , p_width_uom IN VARCHAR2
7113 , p_territory_code IN VARCHAR2
7114 , p_supplier_lot_number IN VARCHAR2
7115 , p_vendor_name IN VARCHAR2
7116 ) IS
7117 TYPE seg_name IS TABLE OF VARCHAR2(1000)
7118 INDEX BY BINARY_INTEGER;
7119
7120 lot_dff inv_lot_sel_attr.lot_sel_attributes_tbl_type;
7121 l_attributes_default inv_lot_sel_attr.lot_sel_attributes_tbl_type;
7122 l_attributes_default_count NUMBER;
7123 l_c_attr_index NUMBER;
7124 l_n_attr_index NUMBER;
7125 l_d_attr_index NUMBER;
7126 l_context VARCHAR2(1000);
7127 l_context_r fnd_dflex.context_r;
7128 l_contexts_dr fnd_dflex.contexts_dr;
7129 l_dflex_r fnd_dflex.dflex_r;
7130 l_segments_dr fnd_dflex.segments_dr;
7131 l_enabled_seg_name seg_name;
7132 l_wms_all_segs_tbl seg_name;
7133 l_nsegments BINARY_INTEGER;
7134 l_global_context BINARY_INTEGER;
7135 l_global_nsegments BINARY_INTEGER;
7136 l_value_not_null_flag NUMBER := NULL;
7137 v_index NUMBER := 1;
7138 l_seg_exists NUMBER;
7139 error_segment VARCHAR2(30);
7140 errors_received EXCEPTION;
7141 error_msg VARCHAR2(5000);
7142 s NUMBER;
7143 e NUMBER;
7144 l_required_flag boolean;
7145 l_return_status VARCHAR2(1);
7146 l_msg_count NUMBER;
7147 l_msg_data VARCHAR2(2000);
7148 l_enabled_attributes NUMBER;
7149 l_context_enabled BOOLEAN := false;
7150 BEGIN
7151 x_return_status := inv_lot_api_pub.g_ret_sts_success;
7152 SAVEPOINT wms_lot_dff_validate;
7153
7154 IF g_debug = 1 THEN
7155 print_debug('In the beginning of the program lot_dff_validate', 9);
7156 END IF;
7157
7158 lot_dff(1).column_name := 'DISABLE_FLAG';
7159 lot_dff(1).column_type := 'NUMBER';
7160 IF p_disable_flag =G_MISS_NUM THEN
7161 lot_dff(1).column_value := NULL;
7162 ELSE
7163 lot_dff(1).column_value := p_disable_flag;
7164 END IF;
7165
7166 lot_dff(2).column_name := 'GRADE_CODE';
7167 lot_dff(2).column_type := 'VARCHAR2';
7168 IF P_GRADE_CODE =G_MISS_CHAR THEN
7169 lot_dff(2).column_value := NULL;
7170 ELSE
7171 lot_dff(2).column_value := p_grade_code;
7172 END IF;
7173
7174 lot_dff(3).column_name := 'ORIGINATION_DATE';
7175 lot_dff(3).column_type := 'DATE';
7176 IF P_ORIGINATION_DATE =G_MISS_DATE THEN
7177 lot_dff(3).column_value := NULL;
7178 ELSE
7179 lot_dff(3).column_value := fnd_date.date_to_canonical(p_origination_date);
7180 END IF;
7181
7182 lot_dff(4).column_name := 'DATE_CODE';
7183 lot_dff(4).column_type := 'VARCHAR2';
7184 IF p_date_code = G_MISS_CHAR THEN
7185 lot_dff(4).column_value := NULL;
7186 ELSE
7187 lot_dff(4).column_value := p_date_code;
7188 END IF;
7189
7190 lot_dff(5).column_name := 'CHANGE_DATE';
7191 lot_dff(5).column_type := 'DATE';
7192 IF p_change_date= G_MISS_DATE THEN
7193 lot_dff(5).column_value := NULL;
7194 ELSE
7195 lot_dff(5).column_value := fnd_date.date_to_canonical(p_change_date);
7196 END IF;
7197
7198 lot_dff(6).column_name := 'ORIGINATION_DATE';
7199 lot_dff(6).column_type := 'DATE';
7200 IF p_origination_date=G_MISS_DATE THEN
7201 lot_dff(6).column_value := NULL;
7202 ELSE
7203 lot_dff(6).column_value := fnd_date.date_to_canonical(p_origination_date);
7204 END IF;
7205
7206 lot_dff(6).column_name := 'AGE';
7207 lot_dff(6).column_type := 'NUMBER';
7208 IF p_age =G_MISS_NUM THEN
7209 lot_dff(6).column_value := NULL;
7210 ELSE
7211 lot_dff(6).column_value := p_age;
7212 END IF;
7213
7214 lot_dff(7).column_name := 'RETEST_DATE';
7215 lot_dff(7).column_type := 'DATE';
7216 IF p_retest_date=G_MISS_DATE THEN
7217 lot_dff(7).column_value := NULL;
7218 ELSE
7219 lot_dff(7).column_value := fnd_date.date_to_canonical(p_retest_date);
7220 END IF;
7221
7222 lot_dff(8).column_name := 'MATURITY_DATE';
7223 lot_dff(8).column_type := 'DATE';
7224 IF p_maturity_date= G_MISS_DATE THEN
7225 lot_dff(8).column_value := NULL;
7226 ELSE
7227 lot_dff(8).column_value := fnd_date.date_to_canonical(p_maturity_date);
7228 END IF;
7229
7230 lot_dff(9).column_name := 'ITEM_SIZE';
7231 lot_dff(9).column_type := 'NUMBER';
7232 IF p_item_size=G_MISS_NUM THEN
7233 lot_dff(9).column_value := NULL;
7234 ELSE
7235 lot_dff(9).column_value := p_item_size;
7236 END IF;
7237
7238 lot_dff(10).column_name := 'COLOR';
7239 lot_dff(10).column_type := 'VARCHAR2';
7240 IF p_color=G_MISS_CHAR THEN
7241 lot_dff(10).column_value := NULL;
7242 ELSE
7243 lot_dff(10).column_value := p_color;
7244 END IF;
7245
7246 lot_dff(11).column_name := 'VOLUME';
7247 lot_dff(11).column_type := 'NUMBER';
7248 IF p_volume = G_MISS_NUM THEN
7249 lot_dff(11).column_value := NULL;
7250 ELSE
7251 lot_dff(11).column_value := p_volume;
7252 END IF;
7253
7254 lot_dff(12).column_name := 'VOLUME_UOM';
7255 lot_dff(12).column_type := 'VARCHAR2';
7256 IF p_volume_uom = G_MISS_CHAR THEN
7257 lot_dff(12).column_value := NULL;
7258 ELSE
7259 lot_dff(12).column_value := p_volume_uom;
7260 END IF;
7261
7262 lot_dff(13).column_name := 'PLACE_OF_ORIGIN';
7263 lot_dff(13).column_type := 'VARCHAR2';
7264 IF p_place_of_origin=G_MISS_CHAR THEN
7265 lot_dff(13).column_value := NULL;
7266 ELSE
7267 lot_dff(13).column_value := p_place_of_origin;
7268 END IF;
7269
7270 lot_dff(14).column_name := 'BEST_BY_DATE';
7271 lot_dff(14).column_type := 'DATE';
7272 IF p_best_by_date= G_MISS_DATE THEN
7273 lot_dff(14).column_value := NULL;
7274 ELSE
7275 --BUG 3784406: Call date_to_canonical, instead of canonical_to_date
7276 lot_dff(14).column_value := fnd_date.date_to_canonical(p_best_by_date);
7277 END IF;
7278
7279 lot_dff(15).column_name := 'LENGTH';
7280 lot_dff(15).column_type := 'NUMBER';
7281 IF p_length=G_MISS_NUM THEN
7282 lot_dff(15).column_value := NULL;
7283 ELSE
7284 lot_dff(15).column_value := p_length;
7285 END IF;
7286
7287 lot_dff(16).column_name := 'LENGTH_UOM';
7288 lot_dff(16).column_type := 'VARCHAR2';
7289 IF p_length_uom=G_MISS_CHAR THEN
7290 lot_dff(16).column_value := NULL;
7291 ELSE
7292 lot_dff(16).column_value := p_length_uom;
7293 END IF;
7294
7295 lot_dff(17).column_name := 'RECYCLED_CONTENT';
7296 lot_dff(17).column_type := 'NUMBER';
7297 IF p_recycled_content=G_MISS_NUM THEN
7298 lot_dff(17).column_value := NULL;
7299 ELSE
7300 lot_dff(17).column_value := p_recycled_content;
7301 END IF;
7302
7303 lot_dff(18).column_name := 'THICKNESS';
7304 lot_dff(18).column_type := 'NUMBER';
7305 IF p_thickness= G_MISS_NUM THEN
7306 lot_dff(18).column_value := NULL;
7307 ELSE
7308 lot_dff(18).column_value := p_thickness;
7309 END IF;
7310
7311 lot_dff(19).column_name := 'THICKNESS_UOM';
7312 lot_dff(19).column_type := 'VARCHAR2';
7313 IF p_thickness_uom=G_MISS_CHAR THEN
7314 lot_dff(19).column_value := NULL;
7315 ELSE
7316 lot_dff(19).column_value := p_thickness_uom;
7317 END IF;
7318
7319 lot_dff(20).column_name := 'WIDTH';
7320 lot_dff(20).column_type := 'NUMBER';
7321 IF p_width =g_miss_num THEN
7322 lot_dff(20).column_value := NULL;
7323 ELSE
7324 lot_dff(20).column_value := p_width;
7325 END IF;
7326
7327 lot_dff(21).column_name := 'WIDTH_UOM';
7328 lot_dff(21).column_type := 'NUMBER';
7329 IF p_width_uom=g_miss_char THEN
7330 lot_dff(21).column_value := NULL;
7331 ELSE
7332 lot_dff(21).column_value := p_width_uom;
7333 END IF;
7334
7335 lot_dff(22).column_name := 'TERRITORY_CODE';
7336 lot_dff(22).column_type := 'VARCHAR2';
7337 IF p_territory_code= g_miss_char THEN
7338 lot_dff(22).column_value := NULL;
7339 ELSE
7340 lot_dff(22).column_value := p_territory_code;
7341 END IF;
7342
7343 lot_dff(23).column_name := 'SUPPLIER_LOT_NUMBER';
7344 lot_dff(23).column_type := 'VARCHAR2';
7345 IF p_supplier_lot_number = g_miss_char THEN
7346 lot_dff(23).column_value := NULL;
7347 ELSE
7348 lot_dff(23).column_value := p_supplier_lot_number;
7349 END IF;
7350
7351 lot_dff(24).column_name := 'C_ATTRIBUTE1';
7352 lot_dff(24).column_type := 'VARCHAR2';
7353 lot_dff(24).column_value := NULL;
7354 lot_dff(25).column_name := 'C_ATTRIBUTE2';
7355 lot_dff(25).column_type := 'VARCHAR2';
7356 lot_dff(25).column_value := NULL;
7357 lot_dff(26).column_name := 'C_ATTRIBUTE3';
7358 lot_dff(26).column_type := 'VARCHAR2';
7359 lot_dff(26).column_value := NULL;
7360 lot_dff(27).column_name := 'C_ATTRIBUTE4';
7361 lot_dff(27).column_type := 'VARCHAR2';
7362 lot_dff(27).column_value := NULL;
7363 lot_dff(28).column_name := 'C_ATTRIBUTE5';
7364 lot_dff(28).column_type := 'VARCHAR2';
7365 lot_dff(28).column_value := NULL;
7366 lot_dff(29).column_name := 'C_ATTRIBUTE6';
7367 lot_dff(29).column_type := 'VARCHAR2';
7368 lot_dff(29).column_value := NULL;
7369 lot_dff(30).column_name := 'C_ATTRIBUTE7';
7370 lot_dff(30).column_type := 'VARCHAR2';
7371 lot_dff(30).column_value := NULL;
7372 lot_dff(31).column_name := 'C_ATTRIBUTE8';
7373 lot_dff(31).column_type := 'VARCHAR2';
7374 lot_dff(31).column_value := NULL;
7375 lot_dff(32).column_name := 'C_ATTRIBUTE9';
7376 lot_dff(32).column_type := 'VARCHAR2';
7377 lot_dff(32).column_value := NULL;
7378 lot_dff(33).column_name := 'C_ATTRIBUTE10';
7379 lot_dff(33).column_type := 'VARCHAR2';
7380 lot_dff(33).column_value := NULL;
7381 lot_dff(34).column_name := 'C_ATTRIBUTE11';
7382 lot_dff(34).column_type := 'VARCHAR2';
7383 lot_dff(34).column_value := NULL;
7384 lot_dff(35).column_name := 'C_ATTRIBUTE12';
7385 lot_dff(35).column_type := 'VARCHAR2';
7386 lot_dff(35).column_value := NULL;
7387 lot_dff(36).column_name := 'C_ATTRIBUTE13';
7388 lot_dff(36).column_type := 'VARCHAR2';
7389 lot_dff(36).column_value := NULL;
7390 lot_dff(37).column_name := 'C_ATTRIBUTE14';
7391 lot_dff(37).column_type := 'VARCHAR2';
7392 lot_dff(37).column_value := NULL;
7393 lot_dff(38).column_name := 'C_ATTRIBUTE15';
7394 lot_dff(38).column_type := 'VARCHAR2';
7395 lot_dff(38).column_value := NULL;
7396 lot_dff(39).column_name := 'C_ATTRIBUTE16';
7397 lot_dff(39).column_type := 'VARCHAR2';
7398 lot_dff(39).column_value := NULL;
7399 lot_dff(40).column_name := 'C_ATTRIBUTE17';
7400 lot_dff(40).column_type := 'VARCHAR2';
7401 lot_dff(40).column_value := NULL;
7402 lot_dff(41).column_name := 'C_ATTRIBUTE18';
7403 lot_dff(41).column_type := 'VARCHAR2';
7404 lot_dff(41).column_value := NULL;
7405 lot_dff(42).column_name := 'C_ATTRIBUTE19';
7406 lot_dff(42).column_type := 'VARCHAR2';
7407 lot_dff(42).column_value := NULL;
7408 lot_dff(43).column_name := 'C_ATTRIBUTE20';
7409 lot_dff(43).column_type := 'VARCHAR2';
7410 lot_dff(43).column_value := NULL;
7411 lot_dff(44).column_name := 'N_ATTRIBUTE1';
7412 lot_dff(44).column_type := 'NUMBER';
7413 lot_dff(44).column_value := NULL;
7414 lot_dff(45).column_name := 'N_ATTRIBUTE2';
7415 lot_dff(45).column_type := 'NUMBER';
7416 lot_dff(45).column_value := NULL;
7417 lot_dff(46).column_name := 'N_ATTRIBUTE3';
7418 lot_dff(46).column_type := 'NUMBER';
7419 lot_dff(46).column_value := NULL;
7420 lot_dff(47).column_name := 'N_ATTRIBUTE4';
7421 lot_dff(47).column_type := 'NUMBER';
7422 lot_dff(47).column_value := NULL;
7423 lot_dff(48).column_name := 'N_ATTRIBUTE5';
7424 lot_dff(48).column_type := 'NUMBER';
7425 lot_dff(48).column_value := NULL;
7426 lot_dff(49).column_name := 'N_ATTRIBUTE6';
7427 lot_dff(49).column_type := 'NUMBER';
7428 lot_dff(49).column_value := NULL;
7429 lot_dff(50).column_name := 'N_ATTRIBUTE7';
7430 lot_dff(50).column_type := 'NUMBER';
7431 lot_dff(50).column_value := NULL;
7432 lot_dff(51).column_name := 'N_ATTRIBUTE8';
7433 lot_dff(51).column_type := 'NUMBER';
7434 lot_dff(51).column_value := NULL;
7435 lot_dff(52).column_name := 'N_ATTRIBUTE9';
7436 lot_dff(52).column_type := 'NUMBER';
7437 lot_dff(52).column_value := NULL;
7438 lot_dff(53).column_name := 'N_ATTRIBUTE10';
7439 lot_dff(53).column_type := 'NUMBER';
7440 lot_dff(53).column_value := NULL;
7441 lot_dff(54).column_name := 'D_ATTRIBUTE1';
7442 lot_dff(54).column_type := 'DATE';
7443 lot_dff(54).column_value := NULL;
7444 lot_dff(55).column_name := 'D_ATTRIBUTE2';
7445 lot_dff(55).column_type := 'DATE';
7446 lot_dff(55).column_value := NULL;
7447 lot_dff(56).column_name := 'D_ATTRIBUTE3';
7448 lot_dff(56).column_type := 'DATE';
7449 lot_dff(56).column_value := NULL;
7450 lot_dff(57).column_name := 'D_ATTRIBUTE4';
7451 lot_dff(57).column_type := 'DATE';
7452 lot_dff(57).column_value := NULL;
7453 lot_dff(58).column_name := 'D_ATTRIBUTE5';
7454 lot_dff(58).column_type := 'DATE';
7455 lot_dff(58).column_value := NULL;
7456 lot_dff(59).column_name := 'D_ATTRIBUTE6';
7457 lot_dff(59).column_type := 'DATE';
7458 lot_dff(59).column_value := NULL;
7459 lot_dff(60).column_name := 'D_ATTRIBUTE7';
7460 lot_dff(60).column_type := 'DATE';
7461 lot_dff(60).column_value := NULL;
7462 lot_dff(61).column_name := 'D_ATTRIBUTE8';
7463 lot_dff(61).column_type := 'DATE';
7464 lot_dff(61).column_value := NULL;
7465 lot_dff(62).column_name := 'D_ATTRIBUTE9';
7466 lot_dff(62).column_type := 'DATE';
7467 lot_dff(62).column_value := NULL;
7468 lot_dff(63).column_name := 'D_ATTRIBUTE10';
7469 lot_dff(63).column_type := 'DATE';
7470 lot_dff(63).column_value := NULL;
7471 /* Loop through the C_ATTRIBUTES_TBL and populate the values. This starts
7472 from index 24 till 43. Find the index in the input table where data is
7473 populated. Add the index value to the starting index of the table
7474 lot_dff to get the column for which data is populated
7475 */
7476 l_c_attr_index := p_c_attributes_tbl.FIRST;
7477
7478 WHILE l_c_attr_index <= p_c_attributes_tbl.LAST LOOP
7479 lot_dff(23 + l_c_attr_index).column_value := p_c_attributes_tbl(l_c_attr_index);
7480 l_c_attr_index := p_c_attributes_tbl.NEXT(l_c_attr_index);
7481 END LOOP;
7482
7483 IF g_debug = 1 THEN
7484 print_debug('After populating the lot_dff table with C_ATTRIBUTES', 9);
7485 END IF;
7486
7487 /* Loop through the N_ATTRIBUTES_TBL and populate the values. This starts
7488 from index 44 till 53. Find the index in the input table where data is
7489 populated. Add the index value to the starting index of the table
7490 lot_dff to get the column for which data is populated
7491 */
7492 l_n_attr_index := p_n_attributes_tbl.FIRST;
7493
7494 WHILE l_n_attr_index <= p_n_attributes_tbl.LAST LOOP
7495 lot_dff(43 + l_n_attr_index).column_value := p_n_attributes_tbl(l_n_attr_index);
7496 l_n_attr_index := p_n_attributes_tbl.NEXT(l_n_attr_index);
7497 END LOOP;
7498
7499 IF g_debug = 1 THEN
7500 print_debug('After populating the lot_dff table with N_ATTRIBUTES', 9);
7501 END IF;
7502
7503 /* Loop through the D_ATTRIBUTES_TBL and populate the values. This starts
7504 from index 54 till 63. Find the index in the input table where data is
7505 populated. Add the index value to the starting index of the table
7506 lot_dff to get the column for which data is populated
7507 */
7508 l_d_attr_index := p_d_attributes_tbl.FIRST;
7509
7510 WHILE l_d_attr_index <= p_d_attributes_tbl.LAST LOOP
7511 IF p_d_attributes_tbl(l_d_attr_index) IS NOT NULL THEN
7512 -- BUG 3784406: Call fnd_date.date_to_canonical
7513 IF g_debug = 1 THEN
7514 print_debug('Date before casting into DD:MM:YYYY format'||To_char(p_d_attributes_tbl(l_d_attr_index),'DD:MM:YYYY'), 9);
7515 END IF;
7516 lot_dff(53 + l_d_attr_index).column_value := fnd_date.date_to_canonical(p_d_attributes_tbl(l_d_attr_index));
7517 IF g_debug = 1 THEN
7518 print_debug('Date after casting in canonical format ' || lot_dff(53 + l_d_attr_index).column_value,9);
7519 END IF;
7520 ELSE
7521 lot_dff(53 + l_d_attr_index).column_value := NULL;
7522 END IF;
7523
7524 l_d_attr_index := p_d_attributes_tbl.NEXT(l_d_attr_index);
7525 END LOOP;
7526
7527 IF g_debug = 1 THEN
7528 print_debug('After populating the lot_dff table with D_ATTRIBUTES', 9);
7529 END IF;
7530
7531 l_enabled_attributes := INV_LOT_SEL_ATTR.is_enabled(
7532 p_flex_name => 'Lot Attributes'
7533 , p_organization_id => p_organization_id
7534 , p_inventory_item_id => p_inventory_item_id);
7535
7536 IF g_debug = 1 THEN
7537 print_Debug('l_enabled_attributes = ' || l_enabled_attributes, 9);
7538 end if;
7539 /*
7540 * Get the default lot attribute values if any
7541 */
7542 inv_lot_sel_attr.get_default (
7543 x_attributes_default => l_attributes_default,
7544 x_attributes_default_count => l_attributes_default_count,
7545 x_return_status => l_return_status,
7546 x_msg_count => l_msg_count,
7547 x_msg_data => l_msg_data,
7548 p_table_name => 'MTL_LOT_NUMBERS',
7549 p_attributes_name => 'Lot Attributes',
7550 p_inventory_item_id => p_inventory_item_id,
7551 p_organization_id => p_organization_id,
7552 p_lot_serial_number => null,
7553 p_attributes => lot_dff
7554 );
7555
7556 IF ( l_return_status <> fnd_api.g_ret_sts_success ) THEN
7557 x_return_status := l_return_status;
7558 RAISE fnd_api.g_exc_unexpected_error;
7559 END IF;
7560
7561 IF ( l_attributes_default_count > 0 ) THEN
7562 FOR i IN 1 .. l_attributes_default_count LOOP
7563 FOR j IN 1 .. lot_dff.COUNT LOOP
7564 IF (UPPER(l_attributes_default(i).column_name) = UPPER(lot_dff(j).column_name)) THEN
7565 lot_dff(j).column_value := l_attributes_default(i).column_value;
7566 END IF;
7567
7568 EXIT WHEN (UPPER(l_attributes_default(i).column_name) =
7569 UPPER(lot_dff(j).column_name));
7570 END LOOP;
7571 END LOOP;
7572 END IF;
7573
7574 l_dflex_r.application_id := 401;
7575 l_dflex_r.flexfield_name := 'Lot Attributes';
7576
7577 IF g_debug = 1 THEN
7578 print_debug('WMS is installed ', 9);
7579 END IF;
7580
7581
7582
7583 /* Get all contexts */
7584 fnd_dflex.get_contexts(flexfield => l_dflex_r, contexts => l_contexts_dr);
7585
7586 /* From the l_contexts_dr, get the position of the global context */
7587 IF g_debug = 1 THEN
7588 print_debug('Found contexts for the Flexfield Lot Attributes ', 9);
7589 END IF;
7590
7591 l_global_context := l_contexts_dr.global_context;
7592 /* Using the position get the segments in the global context which are enabled */
7593 l_context := l_contexts_dr.context_code(l_global_context);
7594
7595 IF g_debug = 1 THEN
7596 print_debug('In WMS -Global COntext is ' || l_context, 9);
7597 END IF;
7598
7599 /* Prepare the context_r type for getting the segments associated with the global context */
7600 l_context_r.flexfield := l_dflex_r;
7601 l_context_r.context_code := l_context;
7602 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
7603 /* read through the segments */
7604 l_global_nsegments := l_segments_dr.nsegments;
7605
7606 IF g_debug = 1 THEN
7607 print_debug('WMs Installed .The number of segments enabled for Global context are ' || l_nsegments, 9);
7608 END IF;
7609
7610 FOR i IN 1 .. l_global_nsegments LOOP
7611 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
7612 l_value_not_null_flag := NULL;
7613
7614 FOR j IN 1 .. lot_dff.COUNT LOOP
7615 IF UPPER(lot_dff(j).column_name) = UPPER(l_segments_dr.application_column_name(i)) THEN
7616 IF g_debug = 1 THEN
7617 print_debug('The segment is ' || UPPER(l_segments_dr.application_column_name(i)), 9);
7618 print_debug('The column name is ' || lot_dff(j).column_name, 9);
7619 print_debug('The column value is ' || NVL(lot_dff(j).column_value, NULL), 9);
7620 print_debug('The column type is ' || NVL(lot_dff(j).column_type, NULL), 9);
7621 END IF;
7622
7623 IF lot_dff(j).column_type = 'VARCHAR2' THEN
7624 fnd_flex_descval.set_column_value(lot_dff(j).column_name, lot_dff(j).column_value);
7625 ELSIF lot_dff(j).column_type = 'NUMBER' THEN
7626 fnd_flex_descval.set_column_value(lot_dff(j).column_name, TO_NUMBER(lot_dff(j).column_value));
7627 ELSIF lot_dff(j).column_type = 'DATE' THEN
7628 fnd_flex_descval.set_column_value(lot_dff(j).column_name, fnd_date.canonical_to_date(lot_dff(j).column_value));
7629 END IF;
7630
7631 IF lot_dff(j).column_value IS NOT NULL THEN
7632 l_value_not_null_flag := 1;
7633
7634 IF g_debug = 1 THEN
7635 print_debug('Value is not null ', 9);
7636 END IF;
7637 ELSE
7638 l_value_not_null_flag := 0;
7639
7640 IF g_debug = 1 THEN
7641 print_debug('Value is null ', 9);
7642 END IF;
7643 END IF;
7644
7645 EXIT;
7646 END IF;
7647 END LOOP;
7648
7649 IF l_segments_dr.is_required(i)
7650 AND NVL(l_value_not_null_flag, 0) = 0 THEN
7651 l_required_flag := true;
7652 IF g_debug = 1 THEN
7653 print_debug('The value is required and value is null ' || l_segments_dr.application_column_name(i), 9);
7654 END IF;
7655
7656 fnd_message.set_name('INV', 'INV_REQ_SEG_MISS');
7657 fnd_message.set_token('SEGMENT', l_segments_dr.segment_name(i));
7658 fnd_msg_pub.ADD;
7659 RAISE g_exc_error;
7660 END IF;
7661
7662 v_index := v_index + 1;
7663 END LOOP;
7664
7665 /* Initialise the l_context_value to null */
7666 l_context := NULL;
7667
7668 /*Check if the Lot Attribute Category is passed or not. If not passed
7669 Get the context for the item passed
7670 */
7671 if g_debug = 1 then
7672 print_debug('p_lot_attribute_category = ' || p_lot_attribute_category, 9);
7673 end if;
7674 IF p_lot_attribute_category IS NOT NULL THEN
7675 print_debug('setting l_context = ' || p_lot_attribute_category, 9);
7676 l_context := p_lot_attribute_category;
7677 ELSE
7678 /*Get the context for the item passed */
7679 inv_lot_sel_attr.get_context_code(l_context, p_organization_id, p_inventory_item_id, 'Lot Attributes');
7680 END IF;
7681
7682 IF l_context IS NULL AND l_required_flag = TRUE THEN
7683 fnd_message.set_name('WMS', 'WMS_NO_CONTEXT');
7684 fnd_msg_pub.ADD;
7685 RAISE g_exc_error;
7686 END IF;
7687
7688 IF g_debug = 1 THEN
7689 print_debug('Context is ' || l_context, 9);
7690 END IF;
7691
7692 FOR i in 1..l_contexts_dr.ncontexts LOOP
7693 if( l_contexts_dr.is_enabled(i) AND l_context IS NOT NULL AND
7694 UPPER(l_contexts_dr.context_code(i)) = UPPER(l_context)) THEN
7695 l_context_enabled := TRUE;
7696 /* Set flex context for validation of the value set */
7697 fnd_flex_descval.set_context_value(l_context);
7698 /* Prepare the context_r type */
7699 l_context_r.flexfield := l_dflex_r;
7700 l_context_r.context_code := l_context;
7701 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
7702 /* read through the segments */
7703 l_nsegments := 0;
7704 l_nsegments := l_segments_dr.nsegments;
7705 FOR i IN 1 .. l_nsegments LOOP
7706 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
7707 l_value_not_null_flag := NULL;
7708
7709 FOR j IN 1 .. lot_dff.COUNT LOOP
7710 IF UPPER(lot_dff(j).column_name) = UPPER(l_segments_dr.application_column_name(i)) THEN
7711 IF g_debug = 1 THEN
7712 print_debug('The segment is ' || UPPER(l_segments_dr.application_column_name(i)), 9);
7713 END IF;
7714
7715 IF lot_dff(j).column_type = 'VARCHAR2' THEN
7716 fnd_flex_descval.set_column_value(lot_dff(j).column_name, lot_dff(j).column_value);
7717 ELSIF lot_dff(j).column_type = 'NUMBER' THEN
7718 fnd_flex_descval.set_column_value(lot_dff(j).column_name, TO_NUMBER(lot_dff(j).column_value));
7719 ELSIF lot_dff(j).column_type = 'DATE' THEN
7720 fnd_flex_descval.set_column_value(lot_dff(j).column_name,
7721 fnd_date.canonical_to_date(lot_dff(j).column_value));
7722 END IF;
7723
7724 IF lot_dff(j).column_value IS NOT NULL THEN
7725 l_value_not_null_flag := 1;
7726 print_debug('Value is not null', 9);
7727 ELSE
7728 l_value_not_null_flag := 0;
7729 print_debug('Value is null', 9);
7730 END IF;
7731 EXIT;
7732 END IF;
7733 END LOOP;
7734
7735 IF l_segments_dr.is_required(i) AND NVL(l_value_not_null_flag, 0) = 0 THEN
7736 IF g_debug = 1 THEN
7737 print_debug('Segment is required and value is null', 9);
7738 END IF;
7739
7740 fnd_message.set_name('INV', 'INV_REQ_SEG_MISS');
7741 fnd_message.set_token('SEGMENT', l_segments_dr.segment_name(i));
7742 fnd_msg_pub.ADD;
7743 RAISE g_exc_error;
7744 END IF;
7745 v_index := v_index + 1;
7746 END LOOP;
7747 END IF;
7748 END LOOP;
7749 IF l_context IS NOT NULL AND l_context_enabled = TRUE AND l_global_nsegments > 0 then
7750 IF fnd_flex_descval.validate_desccols(appl_short_name => 'INV', desc_flex_name => 'Lot Attributes', values_or_ids => 'I'
7751 , validation_date => SYSDATE) THEN
7752 IF g_debug = 1 THEN
7753 print_debug('Value set validation successful', 9);
7754 print_debug('Program LOT_DFF_VALIDATE has completed succcessfuly', 9);
7755 END IF;
7756 ELSE
7757 IF g_debug = 1 THEN
7758 error_segment := fnd_flex_descval.error_segment;
7759 print_debug('Value set validation failed for segment ' || error_segment, 9);
7760 RAISE errors_received;
7761 END IF;
7762 END IF;
7763 end if;
7764 EXCEPTION
7765 WHEN g_exc_error THEN
7766 print_debug('Validation error', 9);
7767 x_return_status := inv_lot_api_pub.g_ret_sts_error;
7768 ROLLBACK TO wms_lot_dff_validate;
7769
7770 IF g_debug = 1 THEN
7771 print_debug('Program LOT_DFF_VALIDATE has completed with validation errors', 9);
7772 END IF;
7773
7774 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7775 WHEN errors_received THEN
7776 x_return_status := inv_lot_api_pub.g_ret_sts_error;
7777
7778 IF g_debug = 1 THEN
7779 print_debug('Program LOT_DFF_VALIDATE has completed with errors_received', 9);
7780 END IF;
7781
7782 error_msg := fnd_flex_descval.error_message;
7783 s := 1;
7784 e := 200;
7785
7786 --print_debug('Here are the error messages: ',9);
7787 WHILE e < 5001
7788 AND SUBSTR(error_msg, s, e) IS NOT NULL LOOP
7789 fnd_message.set_name('INV', 'INV_FND_GENERIC_MSG');
7790 fnd_message.set_token('MSG', SUBSTR(error_msg, s, e));
7791 fnd_msg_pub.ADD;
7792 print_debug(SUBSTR(error_msg, s, e), 9);
7793 s := s + 200;
7794 e := e + 200;
7795 END LOOP;
7796
7797 ROLLBACK TO wms_lot_dff_validate;
7798 WHEN OTHERS THEN
7799 x_return_status := inv_lot_api_pub.g_ret_sts_unexp_error;
7800 ROLLBACK TO wms_lot_dff_validate;
7801 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
7802
7803 IF g_debug = 1 THEN
7804 print_debug('Program LOT_DFF_VALIDATE has completed with errors. In when others ', 9);
7805 print_debug('Error ' || SQLERRM, 9);
7806 END IF;
7807 END wms_lot_attr_validate;
7808
7809
7810 ---------------------------------------------------------End Of J Develop--------------------------------
7811 PROCEDURE set_wms_installed_flag (
7812 p_wms_installed_flag IN VARCHAR2)
7813 IS
7814 BEGIN
7815 G_WMS_INSTALLED := p_wms_installed_flag;
7816 END set_wms_installed_flag;
7817
7818
7819
7820 /* +==========================================================================+
7821 | PROCEDURE NAME |
7822 | validate_child_lot |
7823 | |
7824 | RETURNS |
7825 | Via x_ OUT parameters |
7826 | |
7827 | HISTORY |
7828 | Created Joe DiIorio 05/20/2004 |
7829 | |
7830 +==========================================================================+ */
7831
7832
7833 PROCEDURE validate_child_lot
7834 ( p_api_version IN NUMBER
7835 , p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE
7836 , p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE
7837 , p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL
7838 , p_organization_id IN NUMBER
7839 , p_inventory_item_id IN NUMBER
7840 , p_parent_lot_number IN VARCHAR2
7841 , p_child_lot_number IN VARCHAR2
7842 , x_return_status OUT NOCOPY VARCHAR2
7843 , x_msg_count OUT NOCOPY NUMBER
7844 , x_msg_data OUT NOCOPY VARCHAR2
7845 )
7846 IS
7847
7848
7849 l_api_name CONSTANT VARCHAR2(30) := 'validate_child_lot';
7850 l_api_version CONSTANT NUMBER := 1.0;
7851 G_PKG_NAME CONSTANT VARCHAR2(30) := 'INV_CHILD_LOT_GRP';
7852
7853 /*====================================
7854 Cursor to get Item Master setup.
7855 ======================================*/
7856
7857 CURSOR get_item_data IS
7858 SELECT child_lot_flag, parent_child_generation_flag,
7859 child_lot_prefix, child_lot_validation_flag,
7860 child_lot_starting_number
7861 FROM mtl_system_items_b -- NSRIVAST, Changed the name to MTL_SYSTEM_ITEMS_B as per review comments by Shelly
7862 WHERE organization_id = p_organization_id
7863 AND inventory_item_id = p_inventory_item_id;
7864
7865 l_item_child_lot_flag MTL_SYSTEM_ITEMS.CHILD_LOT_FLAG%TYPE;
7866 l_item_parent_child_gen_flag MTL_SYSTEM_ITEMS.PARENT_CHILD_GENERATION_FLAG%TYPE;
7867 l_item_child_lot_prefix MTL_SYSTEM_ITEMS.CHILD_LOT_PREFIX%TYPE;
7868 l_item_child_lot_validation MTL_SYSTEM_ITEMS.CHILD_LOT_VALIDATION_FLAG%TYPE;
7869 l_item_child_lot_startno MTL_SYSTEM_ITEMS.CHILD_LOT_STARTING_NUMBER%TYPE;
7870 L_ITEM_LOT_LENGTH CONSTANT NUMBER := 80;
7871
7872
7873 /*====================================
7874 Cursor to get child mtl parms.
7875 ====================================*/
7876
7877 CURSOR get_child_parms IS
7878 SELECT lot_number_generation,
7879 parent_child_generation_flag,
7880 child_lot_alpha_prefix, child_lot_number_length,
7881 child_lot_validation_flag, child_lot_zero_padding_flag
7882 FROM mtl_parameters
7883 WHERE organization_id = p_organization_id;
7884
7885 l_prm_lot_number_generation MTL_PARAMETERS.lot_number_generation%TYPE;
7886 l_prm_parent_child_gen_flag MTL_PARAMETERS.parent_child_generation_flag%TYPE;
7887 l_prm_child_lot_alpha_prefix MTL_PARAMETERS.child_lot_alpha_prefix%TYPE;
7888 l_prm_child_lot_number_length MTL_PARAMETERS.child_lot_number_length%TYPE;
7889 l_prm_child_lot_val_flag MTL_PARAMETERS.child_lot_validation_flag%TYPE;
7890 l_prm_zero_padding_flag MTL_PARAMETERS.child_lot_zero_padding_flag%TYPE;
7891
7892 l_common_child_gen_flag MTL_PARAMETERS.parent_child_generation_flag%TYPE;
7893 l_parent_length NUMBER;
7894 l_child_prefix_length NUMBER;
7895 l_child_prefix VARCHAR2(30);
7896 l_final_start NUMBER;
7897 l_final_length NUMBER;
7898 l_final_suffix VARCHAR2(80);
7899 l_final_suffix_numeric NUMBER;
7900 l_child_lot_length NUMBER;
7901 /*=========================================================
7902 For overall length if Item controlled lot generation
7903 it is = 80. For Org control it is what is specified.
7904 If not specified, the value is 80.
7905 =========================================================*/
7906 l_overall_length NUMBER;
7907
7908 l_num_error EXCEPTION;
7909 PRAGMA EXCEPTION_INIT(l_num_error,-06502);
7910
7911
7912
7913
7914 BEGIN
7915 IF FND_API.to_boolean(p_init_msg_list) THEN
7916 FND_MSG_PUB.Initialize;
7917 END IF;
7918
7919 -- Standard call to check for call compatibility.
7920 IF NOT FND_API.Compatible_API_Call ( l_api_version ,
7921 p_api_version ,
7922 l_api_name ,
7923 G_PKG_NAME ) THEN
7924 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7925 END IF;
7926 x_return_status := FND_API.G_RET_STS_SUCCESS;
7927
7928
7929 /*==========================================
7930 Get Item Information
7931 ========================================*/
7932 OPEN get_item_data;
7933 FETCH get_item_data INTO
7934 l_item_child_lot_flag, l_item_parent_child_gen_flag,
7935 l_item_child_lot_prefix, l_item_child_lot_validation,
7936 l_item_child_lot_startno;
7937 IF (get_item_data%NOTFOUND) THEN
7938 CLOSE get_item_data;
7939 fnd_message.set_name ('INV' , 'INV_CL_ITEM_ERR');
7940 fnd_msg_pub.ADD;
7941 RAISE fnd_api.g_exc_error;
7942 END IF;
7943 CLOSE get_item_data;
7944
7945 /*==========================================
7946 If Item not autosplit enabled stop.
7947 ========================================*/
7948 IF (nvl(l_item_child_lot_flag,'N') = 'N') THEN
7949 fnd_message.set_name ('INV' , 'INV_CL_CHILD_LOT_DISABLED');
7950 fnd_msg_pub.ADD;
7951 RAISE fnd_api.g_exc_error;
7952 END IF;
7953
7954 /*==========================================
7955 Get mtl_parameters information.
7956 ========================================*/
7957
7958 OPEN get_child_parms;
7959 FETCH get_child_parms INTO
7960 l_prm_lot_number_generation, l_prm_parent_child_gen_flag,
7961 l_prm_child_lot_alpha_prefix,
7962 l_prm_child_lot_number_length, l_prm_child_lot_val_flag,
7963 l_prm_zero_padding_flag;
7964 IF (get_child_parms%NOTFOUND) THEN
7965 CLOSE get_child_parms;
7966 fnd_message.set_name ('INV' , 'INV_CL_GET_PARM_ERR');
7967 fnd_msg_pub.ADD;
7968 RAISE fnd_api.g_exc_error;
7969 END IF;
7970 CLOSE get_child_parms;
7971
7972 /*==========================================
7973 If User Level Generation no check is
7974 required. Just return.
7975 ========================================*/
7976
7977 IF (l_prm_lot_number_generation = 3) THEN
7978 x_return_status := FND_API.G_RET_STS_SUCCESS;
7979 RETURN;
7980 END IF;
7981
7982 /*==========================================
7983 If Validation is off, just return.
7984 Values for prm_lot_number_generation.
7985 1 = org, 2 = item, 3 = user.
7986 ========================================*/
7987
7988 IF (l_prm_lot_number_generation = 1) THEN
7989 l_common_child_gen_flag := l_prm_parent_child_gen_flag;
7990 IF (nvl(l_prm_child_lot_val_flag,'N') = 'N') THEN
7991 RETURN;
7992 END IF;
7993 ELSE -- must be Item control
7994 l_common_child_gen_flag := l_item_parent_child_gen_flag;
7995 IF (nvl(l_item_child_lot_validation,'N') = 'N') THEN
7996 RETURN;
7997 END IF;
7998 END IF;
7999
8000
8001 /*==========================================
8002 Validate the Child Lot.
8003 Get the setup data for validation.
8004 ========================================*/
8005
8006 l_parent_length := NVL(LENGTHB(p_parent_lot_number),0);
8007
8008 IF (l_prm_lot_number_generation = 1) THEN --org
8009 l_child_prefix_length := NVL(LENGTHB(l_prm_child_lot_alpha_prefix),0);
8010 l_child_prefix := l_prm_child_lot_alpha_prefix;
8011 l_overall_length := NVL(l_prm_child_lot_number_length,80);
8012 ELSE --item
8013 l_child_prefix_length := NVL(LENGTHB(l_item_child_lot_prefix),0);
8014 l_child_prefix := l_item_child_lot_prefix;
8015 l_overall_length := L_ITEM_LOT_LENGTH;
8016 END IF;
8017
8018
8019 /*==========================================
8020 Check if Parent Lot is prefix to
8021 Child Lot when Lot+Child generation
8022 is in effect.
8023 ========================================*/
8024
8025 IF (l_common_child_gen_flag = 'C') THEN
8026 /*===================================================
8027 Prefix of child lot must match parent lot number.
8028 ===================================================*/
8029 IF (p_parent_lot_number = SUBSTRB(p_child_lot_number,1,l_parent_length)) THEN
8030 /*===================================================
8031 After the prefix the next characters must match
8032 the child lot prefix.
8033 ===================================================*/
8034 IF (NVL(l_child_prefix,'ZZZZ') = NVL(SUBSTRB(p_child_lot_number, l_parent_length + 1, l_child_prefix_length),'ZZZZ')) THEN
8035 NULL;
8036 ELSE
8037 fnd_message.set_name ('INV' , 'INV_CL_SUFFIX_MISMATCH');
8038 fnd_msg_pub.ADD;
8039 RAISE fnd_api.g_exc_error;
8040 END IF;
8041 ELSE
8042 fnd_message.set_name ('INV' , 'INV_CL_PREFIX_MISMATCH');
8043 fnd_msg_pub.ADD;
8044 RAISE fnd_api.g_exc_error;
8045 END IF;
8046 ELSE
8047 /*=======================================
8048 For Lot/Lot validation just return.
8049 =======================================*/
8050 RETURN;
8051 END IF;
8052
8053 /*============================================
8054 Now check if remaining suffix is numeric.
8055 ============================================*/
8056
8057
8058 l_final_start := l_parent_length + NVL(l_child_prefix_length,0) + 1;
8059 l_final_length := 80 - l_final_start - 1;
8060
8061 l_final_suffix :=
8062 SUBSTRB(p_child_lot_number, l_final_start);
8063
8064 IF (l_final_suffix IS NULL) THEN
8065 fnd_message.set_name ('INV' , 'INV_CL_SUFFIX_NONUMERIC');
8066 fnd_msg_pub.ADD;
8067 RAISE fnd_api.g_exc_error;
8068 END IF;
8069
8070 /*============================================
8071 Exception will trap the following command
8072 if suffix is not numeric.
8073 ============================================*/
8074
8075 l_final_suffix_numeric := TO_NUMBER(l_final_suffix);
8076
8077 /*===============================================
8078 Check if padded correctly. If padding is
8079 on must verify that total length of suffix
8080 is correct. Only done at org level control.
8081 If Item level check if starting number is
8082 above suffix number,
8083 ===============================================*/
8084
8085 l_child_lot_length := NVL(LENGTHB(p_child_lot_number),0);
8086
8087 IF (l_prm_lot_number_generation = 1) THEN --org
8088 IF (l_prm_zero_padding_flag = 'Y') THEN
8089 IF (l_overall_length <> l_child_lot_length) THEN
8090 fnd_message.set_name ('INV' , 'INV_CL_PAD_ERROR');
8091 fnd_msg_pub.ADD;
8092 RAISE fnd_api.g_exc_error;
8093 END IF;
8094 END IF;
8095 ELSE -- Item
8096 IF (NVL(l_item_child_lot_startno,0) > l_final_suffix_numeric) THEN
8097 fnd_message.set_name ('INV' , 'INV_CL_STARTING_SUFFIX_ERR');
8098 fnd_msg_pub.ADD;
8099 RAISE fnd_api.g_exc_error;
8100 END IF;
8101 END IF;
8102
8103 /*============================================
8104 Check if total length is correct.
8105 Item generation child lots can be up to 80
8106 in length. For org generated lots the
8107 length indicated is used. Otherwise use 80.
8108 ============================================*/
8109
8110 IF (l_child_lot_length > l_overall_length ) THEN
8111 fnd_message.set_name ('INV' , 'INV_CL_OVERALL_LENGTH');
8112 fnd_msg_pub.ADD;
8113 RAISE fnd_api.g_exc_error;
8114 END IF;
8115 RETURN;
8116
8117 EXCEPTION
8118
8119 WHEN l_num_error THEN
8120 fnd_message.set_name ('INV' , 'INV_CL_SUFFIX_NONUMERIC');
8121 fnd_msg_pub.ADD;
8122 x_return_status := FND_API.G_RET_STS_ERROR;
8123 FND_MSG_PUB.Count_AND_GET
8124 (p_count => x_msg_count, p_data => x_msg_data);
8125 WHEN FND_API.G_EXC_ERROR THEN
8126 x_return_status := FND_API.G_RET_STS_ERROR;
8127 FND_MSG_PUB.Count_AND_GET
8128 (p_count => x_msg_count, p_data => x_msg_data);
8129
8130 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8131 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8132 FND_MSG_PUB.Count_AND_GET
8133 (p_count => x_msg_count, p_data => x_msg_data);
8134
8135 WHEN OTHERS THEN
8136 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8137 FND_MSG_PUB.Count_AND_GET
8138 (p_count => x_msg_count, p_data => x_msg_data);
8139
8140 END validate_child_lot;
8141
8142
8143 FUNCTION validate_lot_indivisible
8144 ( p_api_version IN NUMBER
8145 , p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE
8146 , p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE
8147 , p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL
8148 , p_transaction_type_id IN NUMBER
8149 , p_organization_id IN NUMBER
8150 , p_inventory_item_id IN NUMBER
8151 , p_revision IN VARCHAR2
8152 , p_subinventory_code IN VARCHAR2
8153 , p_locator_id IN NUMBER
8154 , p_lot_number IN VARCHAR2
8155 , p_primary_quantity IN NUMBER
8156 , p_qoh IN NUMBER DEFAULT NULL
8157 , p_atr IN NUMBER DEFAULT NULL
8158 , x_return_status OUT NOCOPY VARCHAR2
8159 , x_msg_count OUT NOCOPY NUMBER
8160 , x_msg_data OUT NOCOPY VARCHAR2
8161 ) RETURN BOOLEAN
8162 IS
8163 l_primary_quantity number;
8164 l_return boolean;
8165 CREATE_TREE_ERROR EXCEPTION;
8166 QUERY_TREE_ERROR EXCEPTION;
8167 BEGIN
8168 l_return := validate_lot_indivisible
8169 ( p_api_version => p_api_version
8170 , p_init_msg_list => p_init_msg_list
8171 , p_commit => p_commit
8172 , p_validation_level => p_validation_level
8173 , p_transaction_type_id => p_transaction_type_id
8174 , p_organization_id => p_organization_id
8175 , p_inventory_item_id => p_inventory_item_id
8176 , p_revision => p_revision
8177 , p_subinventory_code => p_subinventory_code
8178 , p_locator_id => p_locator_id
8179 , p_lot_number => p_lot_number
8180 , p_primary_quantity => p_primary_quantity
8181 , p_qoh => p_qoh
8182 , p_atr => p_atr
8183 , x_primary_quantity => l_primary_quantity
8184 , x_return_status => x_return_status
8185 , x_msg_count => x_msg_count
8186 , x_msg_data => x_msg_data
8187 );
8188 RETURN l_return;
8189
8190 EXCEPTION
8191
8192 WHEN CREATE_TREE_ERROR THEN
8193 print_debug(' CREATE_TREE error...');
8194 x_return_status := FND_API.G_RET_STS_ERROR;
8195 FND_MSG_PUB.Count_AND_GET
8196 (p_count => x_msg_count, p_data => x_msg_data);
8197 RETURN FALSE;
8198
8199 WHEN QUERY_TREE_ERROR THEN
8200 print_debug(' QUERY_TREE error...');
8201 x_return_status := FND_API.G_RET_STS_ERROR;
8202 FND_MSG_PUB.Count_AND_GET
8203 (p_count => x_msg_count, p_data => x_msg_data);
8204 RETURN FALSE;
8205
8206 WHEN FND_API.G_EXC_ERROR THEN
8207 print_debug(' EXCP error...');
8208 x_return_status := FND_API.G_RET_STS_ERROR;
8209 FND_MSG_PUB.Count_AND_GET
8210 (p_count => x_msg_count, p_data => x_msg_data);
8211 RETURN FALSE;
8212
8213 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8214 print_debug(' UNEXCP error...');
8215 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8216 FND_MSG_PUB.Count_AND_GET
8217 (p_count => x_msg_count, p_data => x_msg_data);
8218 RETURN FALSE;
8219
8220 WHEN OTHERS THEN
8221 print_debug(' OTHERS error...'||SQLERRM);
8222 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8223 FND_MSG_PUB.Count_AND_GET
8224 (p_count => x_msg_count, p_data => x_msg_data);
8225 RETURN FALSE;
8226
8227 END validate_lot_indivisible;
8228
8229
8230 /*+==========================================================================+
8231 | PROCEDURE NAME |
8232 | validate_lot_indivisible |
8233 | This function validates, from the IN parameters, |
8234 | whether a lot transaction can be added into the inventory |
8235 | regarding the lot definition. |
8236 | |
8237 | IN PARAMETERS |
8238 | - the transaction details (trx_type, item, org, lot, rev) |
8239 | - the primary quantity of the transaction |
8240 | - IF qoh and atr are passed, THEN quantity tree is bypassed. |
8241 | - IF qoh and atr are NULL, THEN quantity tree is called (recommanded) |
8242 | |
8243 | RETURNS |
8244 | TRUE if the lot transaction is valid |
8245 | FALSE if the lot transaction is NOT valid because of lot indivisible |
8246 | Via x_ OUT parameters |
8247 | |
8248 | HISTORY |
8249 | Created Olivier Daboval 17-Jun-2004 |
8250 | Bug 4122106 : using p_primary_quantity as an ABS value in the tests |
8251 | |
8252 +==========================================================================+ */
8253 FUNCTION validate_lot_indivisible
8254 ( p_api_version IN NUMBER
8255 , p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE
8256 , p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE
8257 , p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL
8258 , p_transaction_type_id IN NUMBER
8259 , p_organization_id IN NUMBER
8260 , p_inventory_item_id IN NUMBER
8261 , p_revision IN VARCHAR2
8262 , p_subinventory_code IN VARCHAR2
8263 , p_locator_id IN NUMBER
8264 , p_lot_number IN VARCHAR2
8265 , p_primary_quantity IN NUMBER
8266 , p_qoh IN NUMBER DEFAULT NULL
8267 , p_atr IN NUMBER DEFAULT NULL
8268 , x_primary_quantity OUT NOCOPY NUMBER
8269 , x_return_status OUT NOCOPY VARCHAR2
8270 , x_msg_count OUT NOCOPY NUMBER
8271 , x_msg_data OUT NOCOPY VARCHAR2
8272 ) RETURN BOOLEAN
8273 IS
8274
8275
8276 l_api_name CONSTANT VARCHAR2(30) := 'validate_lot_indivisible';
8277 l_api_version CONSTANT NUMBER := 1.0;
8278 G_PKG_NAME CONSTANT VARCHAR2(30) := 'INV_LOT_API_PUB';
8279
8280 l_return BOOLEAN;
8281 l_lot_divisible VARCHAR2(1);
8282 l_lot_control_code pls_integer;
8283 l_transaction_action_id NUMBER;
8284 l_transaction_source_type_id NUMBER;
8285
8286 l_return_status VARCHAR2(2);
8287 l_msg_count NUMBER;
8288 l_msg_data VARCHAR2(2000);
8289 l_tree_mode NUMBER;
8290 l_is_revision_control BOOLEAN;
8291 l_is_lot_control BOOLEAN;
8292 l_is_serial_control BOOLEAN;
8293 l_grade_code VARCHAR2(150) := NULL;
8294 l_check_qties BOOLEAN;
8295 l_lot_no VARCHAR2(150) := NULL;
8296
8297 CREATE_TREE_ERROR EXCEPTION;
8298 QUERY_TREE_ERROR EXCEPTION;
8299 l_tree_id INTEGER;
8300 l_qoh NUMBER;
8301 l_rqoh NUMBER;
8302 l_qr NUMBER;
8303 l_qs NUMBER;
8304 l_att NUMBER;
8305 l_atr NUMBER;
8306 l_atr_plus NUMBER;
8307 l_sqoh NUMBER;
8308 l_srqoh NUMBER;
8309 l_sqr NUMBER;
8310 l_sqs NUMBER;
8311 l_satt NUMBER;
8312 l_satr NUMBER;
8313 ll_qoh NUMBER;
8314 ll_rqoh NUMBER;
8315 ll_qr NUMBER;
8316 ll_qs NUMBER;
8317 ll_att NUMBER;
8318 ll_atr NUMBER;
8319 ll_atr_plus NUMBER;
8320 ll_sqoh NUMBER;
8321 ll_srqoh NUMBER;
8322 ll_sqr NUMBER;
8323 ll_sqs NUMBER;
8324 ll_satt NUMBER;
8325 ll_satr NUMBER;
8326
8327 /*====================================
8328 Get item details:
8329 - lot_divisible_flag = Y(divisible), N(indivisible), NULL(divisible)
8330 - lot_control_code = 1(notLotControlled), 2(lotControlled)
8331 - revision_qty_control_code = 1(notRevControlled), 2(revControlled)
8332 ======================================*/
8333 CURSOR get_item_details( org_id IN NUMBER
8334 , item_id IN NUMBER) IS
8335 SELECT NVL( lot_divisible_flag, 'Y')
8336 ,lot_control_code
8337 FROM mtl_system_items_b -- NSRIVAST, Changed the name to MTL_SYSTEM_ITEMS_B as per review comments by Shelly
8338 WHERE organization_id = org_id
8339 AND inventory_item_id = item_id;
8340
8341 /*====================================
8342 Get transaction action from transaction type:
8343 ======================================*/
8344 CURSOR get_transaction_details( trx_type_id IN NUMBER) IS
8345 SELECT transaction_action_id
8346 , transaction_source_type_id
8347 FROM mtl_transaction_types
8348 WHERE transaction_type_id = trx_type_id;
8349
8350 /*====================================
8351 Get new lot information:
8352 ======================================*/
8353 /* Jalaj Srivastava Bug 4634410
8354 This cursor is no longer used */
8355 /*
8356 CURSOR get_new_lot_details( org_id IN NUMBER
8357 , item_id IN NUMBER
8358 , lot_no IN VARCHAR2) IS
8359 SELECT lot_number
8360 FROM mtl_lot_numbers
8361 WHERE lot_number = lot_no
8362 AND inventory_item_id = item_id
8363 AND organization_id = org_id; */
8364
8365 BEGIN
8366
8367 print_debug('Entering validate_lot_indivisible. transaction_type_id='||p_transaction_type_id||', prim_qty='||p_primary_quantity||'.');
8368 print_debug(' ... org='||p_organization_id||', item='||p_inventory_item_id||', rev='||p_revision||', sub='||p_subinventory_code||', loct='||p_locator_id);
8369 print_debug(' ... lot='||p_lot_number||', p_qoh='||p_qoh||', p_atr='||p_atr);
8370
8371 IF FND_API.to_boolean(p_init_msg_list) THEN
8372 FND_MSG_PUB.Initialize;
8373 END IF;
8374
8375 -- Standard call to check for call compatibility.
8376 IF NOT FND_API.Compatible_API_Call( l_api_version
8377 , p_api_version
8378 , l_api_name
8379 , G_PKG_NAME)
8380 THEN
8381 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8382 END IF;
8383 x_return_status := FND_API.G_RET_STS_SUCCESS;
8384
8385 /*==========================================
8386 Get item details:
8387 ========================================*/
8388 OPEN get_item_details( p_organization_id, p_inventory_item_id);
8389 FETCH get_item_details
8390 INTO l_lot_divisible,l_lot_control_code;
8391 IF (get_item_details%NOTFOUND)
8392 THEN
8393 CLOSE get_item_details;
8394 FND_MESSAGE.SET_NAME('INV','ITEM_NOT_FOUND');
8395 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID', p_organization_id);
8396 FND_MESSAGE.SET_TOKEN('INVENTORY_ITEM_ID', p_inventory_item_id);
8397 FND_MSG_PUB.ADD;
8398 RAISE FND_API.G_EXC_ERROR;
8399 END IF;
8400 CLOSE get_item_details;
8401
8402 /* Jalaj Srivastava Bug 4634410
8403 We should always validate
8404 because same indivisible lot could be created
8405 in 2 lines in diff sub/loc.
8406 commented new lot logic below*/
8407 /*==========================================
8408 Get new lot details:
8409 ========================================*/
8410 /*
8411 OPEN get_new_lot_details(p_organization_id, p_inventory_item_id, p_lot_number);
8412 FETCH get_new_lot_details
8413 INTO l_lot_no;
8414
8415 IF (get_new_lot_details%NOTFOUND)
8416 THEN
8417 -- The lot is a NEW lot.... The trx is always valid.
8418 print_debug(' the lot is NEW. trx valid always.');
8419 l_new_lot := TRUE;
8420 ELSE
8421 print_debug(' the lot is NOT NEW. More check to follow.');
8422 l_new_lot := FALSE;
8423 END IF;
8424 CLOSE get_new_lot_details;
8425 */
8426
8427 IF (l_lot_control_code = 2 AND l_lot_divisible = 'N' AND p_lot_number IS NOT NULL)
8428 THEN
8429 print_debug(' the lot is NOT divisible... Return can be false.');
8430 /*==========================================
8431 Get transaction details:
8432 ========================================*/
8433 OPEN get_transaction_details(p_transaction_type_id);
8434 FETCH get_transaction_details
8435 INTO l_transaction_action_id
8436 , l_transaction_source_type_id;
8437 IF (get_transaction_details%NOTFOUND)
8438 THEN
8439 CLOSE get_transaction_details;
8440 FND_MESSAGE.SET_NAME('INV','TRX_TYPE_NOT_FOUND');
8441 FND_MESSAGE.SET_TOKEN('TRANSACTION_TYPE_ID', p_transaction_type_id);
8442 FND_MSG_PUB.ADD;
8443 RAISE FND_API.G_EXC_ERROR;
8444 END IF;
8445 CLOSE get_transaction_details;
8446
8447 print_debug('... transaction_type_id='||p_transaction_type_id||', trx_action='||l_transaction_action_id||', trx_source_type='||l_transaction_source_type_id);
8448
8449 /*==========================================
8450 If check quantities is needed, then calls Quantity Tree:
8451 ========================================*/
8452 IF (p_qoh IS NULL or p_atr IS NULL)
8453 THEN
8454 l_check_qties := TRUE;
8455 END IF;
8456
8457 IF (l_check_qties = TRUE)
8458 THEN
8459 print_debug('Checking the quantities');
8460 /*==========================================
8461 Set local variables from given parameters
8462 ========================================*/
8463 -- I think that p_transaction_type_id is NEVER NULL !!!!.
8464 IF (p_transaction_type_id IS NOT NULL)
8465 THEN
8466 -- Transaction mode
8467 l_tree_mode := 2;
8468 ELSE
8469 --Reservation mode
8470 l_tree_mode := 1;
8471 END IF;
8472
8473 IF (p_revision IS NOT NULL)
8474 THEN
8475 l_is_revision_control := TRUE;
8476 ELSE
8477 l_is_revision_control := FALSE;
8478 END IF;
8479
8480 IF (p_lot_number IS NOT NULL)
8481 THEN
8482 l_is_lot_control := TRUE;
8483 ELSE
8484 l_is_lot_control := FALSE;
8485 END IF;
8486
8487 l_is_serial_control := FALSE;
8488
8489 /*==========================================
8490 Call Quantity Tree for checking whether
8491 it is possible to generate a transation for this lot.
8492 ========================================*/
8493 /* Jalaj Srivastava Bug 4634410
8494 commenting code below.
8495 we will call INV_QUANTITY_TREE_PUB to query quantities */
8496 /*
8497 print_debug('Calling INV_QUANTITY_TREE_GRP.CREATE_TREE api');
8498 INV_QUANTITY_TREE_GRP.CREATE_TREE
8499 ( p_api_version_number => p_api_version
8500 , p_init_msg_lst => p_init_msg_list
8501 , x_return_status => l_return_status
8502 , x_msg_count => l_msg_count
8503 , x_msg_data => l_msg_data
8504 , p_organization_id => p_organization_id
8505 , p_inventory_item_id => p_inventory_item_id
8506 , p_tree_mode => l_tree_mode
8507 , p_is_revision_control => l_is_revision_control
8508 , p_is_lot_control => l_is_lot_control
8509 , p_is_serial_control => l_is_serial_control
8510 , p_grade_code => l_grade_code
8511 , p_demand_source_type_id => 13
8512 , p_demand_source_header_id => -1
8513 , p_demand_source_line_id => -1
8514 , p_demand_source_name => -1
8515 , p_lot_expiration_date => sysdate
8516 , p_onhand_source => 3
8517 , x_tree_id => l_tree_id);
8518
8519 print_debug('return status INV_QUANTITY_TREE_GRP.CREATE_TREE api'||l_return_status);
8520 -- NSRIVAST, using <> as per GSCC compliance
8521 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
8522 THEN
8523 print_debug('Returning error from INV_QUANTITY_TREE_GRP.CREATE_TREE');
8524 RAISE CREATE_TREE_ERROR;
8525 END IF;
8526 */
8527 print_debug('Calling INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES api');
8528 INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES
8529 ( p_api_version_number => p_api_version
8530 , p_init_msg_lst => p_init_msg_list
8531 , x_return_status => l_return_status
8532 , x_msg_count => l_msg_count
8533 , x_msg_data => l_msg_data
8534 , p_tree_mode => l_tree_mode
8535 , p_organization_id => p_organization_id
8536 , p_inventory_item_id => p_inventory_item_id
8537 , p_is_revision_control => l_is_revision_control
8538 , p_is_lot_control => l_is_lot_control
8539 , p_is_serial_control => l_is_serial_control
8540 , p_grade_code => l_grade_code
8541 , p_revision => p_revision
8542 , p_lot_number => p_lot_number
8543 , p_subinventory_code => NULL -- p_subinventory_code Bug# 4233182 pass null instead of p_subinventory_code
8544 , p_locator_id => NULL -- p_locator_id Bug# 4233182 pass null instead of p_locator_id
8545 , x_qoh => l_qoh
8546 , x_rqoh => l_rqoh
8547 , x_qr => l_qr
8548 , x_qs => l_qs
8549 , x_att => l_att
8550 , x_atr => l_atr
8551 , x_sqoh => l_sqoh
8552 , x_srqoh => l_srqoh
8553 , x_sqr => l_sqr
8554 , x_sqs => l_sqs
8555 , x_satt => l_satt
8556 , x_satr => l_satr
8557 );
8558
8559 print_debug('Return Status INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES api'||l_return_status);
8560 print_debug(' onhand='||l_qoh||' l_atr --> '||l_atr);
8561 --Returning quantity to calling procedure
8562 x_primary_quantity := l_qoh;
8563
8564 -- NSRIVAST, using <> as per GSCC compliance
8565 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
8566 THEN
8567 print_debug('Returning error from INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES');
8568 RAISE QUERY_TREE_ERROR;
8569 END IF;
8570
8571 ELSE
8572 -- the quantities are passed as parameters
8573 l_qoh := p_qoh;
8574 l_atr := p_atr;
8575 END IF; -- l_check_qties
8576
8577 print_debug(' l_qoh -->'||l_qoh||' l_atr --> '||l_atr);
8578 /*==========================================
8579 Compare values of transaction_source and transaction_action
8580 and then decide whether the new transaction is allowed
8581
8582 ========================================*/
8583 -- action 1 = issue
8584 -- action 2 = subinv transfer
8585 -- action 3 = direct org transfer
8586 -- action 28 = staging transfer
8587 -- action 32 = assembly return
8588 -- action 34 = negative component return
8589 -- transaction_type_id = 32 (Misc Issue), always return VALID TRX if enough onhand.
8590 -- l_transaction_action_id 50,51,52 PACK,UNPACK,SPLIT. --Bug 4218736
8591 IF ( l_transaction_action_id IN ( 2, 3, 32, 34, 28)
8592 OR (l_transaction_action_id = 1 AND p_transaction_type_id NOT IN ( 1, 32) ) )
8593 OR (l_transaction_action_id IN ( 50,51,52) )
8594 THEN
8595 print_debug('within case 1 : Must issue the full onhand qty');
8596 -- bug 4122106 : added ABS in the test.
8597 IF (ABS(p_primary_quantity) <> l_qoh )
8598 THEN
8599 -- print_debug('INV_LOT_INDIV_QTY_ISSUE_CASE_1');
8600 print_debug('INV_LOT_INDIVISIBLE_VIOLATION');
8601 --l_error_exp := FND_MESSAGE.GET;
8602 FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIVISIBLE_VIOLATION'); -- bug 4121709
8603 -- FND_MESSAGE.SET_TOKEN('QOH',l_qoh);
8604 FND_MSG_PUB.ADD;
8605 --l_error_code := FND_MESSAGE.GET;
8606 /* Update MTI table with error code/explanation */
8607 --errupdate(p_rowid);
8608 RAISE FND_API.G_EXC_ERROR;
8609 END IF;
8610 END IF;
8611
8612 -- IF ( p_transaction_type_id = 32 )
8613 -- THEN
8614 -- print_debug('within case 1.1 : Misc Issue. Can issue less than onhand qty');
8615 -- IF (p_primary_quantity > l_qoh )
8616 -- THEN
8617 -- print_debug('INV_LOT_INDIV_QTY_ISSUE_CASE_1.1');
8618 -- --l_error_exp := FND_MESSAGE.GET;
8619 -- FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_ISSUE_CASE_1.1');
8620 -- FND_MSG_PUB.ADD;
8621 -- --l_error_code := FND_MESSAGE.GET;
8622 -- /* Update MTI table with error code/explanation */
8623 -- --errupdate(p_rowid);
8624 -- RAISE FND_API.G_EXC_ERROR;
8625 -- END IF;
8626 -- END IF;
8627
8628 -- action 27 = Receipt into store
8629 /*Bug#5465377 added transaction action id 41 for lot merge so that
8630 it checks for lot indivisibility for lot merge also. */
8631 IF (l_transaction_action_id IN (27,41) )
8632 THEN
8633 -- test if some inventory exist at lowest level
8634 -- if some inventory ALREADY exists for that sub/loct/lot, then that's fine. trx accepted
8635 -- IF ( l_atr = 0 )
8636 -- BUG 4146697 -- Changed the check to compare Onhand > 0.
8637 IF ( l_qoh > 0 )
8638 THEN
8639 -- No inventory for sub/loct/lot, then, need to search somewhere-else :
8640 -- Going to see whether, for that lot the qty is the same at node=lot
8641 print_debug('within case 2 prim_qty='||p_primary_quantity||', atr='||l_atr);
8642
8643 INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES
8644 ( p_api_version_number => p_api_version
8645 , p_init_msg_lst => p_init_msg_list
8646 , x_return_status => l_return_status
8647 , x_msg_count => l_msg_count
8648 , x_msg_data => l_msg_data
8649 , p_tree_mode => l_tree_mode
8650 , p_organization_id => p_organization_id
8651 , p_inventory_item_id => p_inventory_item_id
8652 , p_is_revision_control => l_is_revision_control
8653 , p_is_lot_control => l_is_lot_control
8654 , p_is_serial_control => l_is_serial_control
8655 , p_grade_code => l_grade_code
8656 , p_revision => p_revision
8657 , p_lot_number => p_lot_number
8658 , p_subinventory_code => p_subinventory_code -- NULL Bug# 4233182 removed null and passed p_subinventory_code
8659 , p_locator_id => p_locator_id -- NULL Bug# 4233182 removed null and passed p_locator_id
8660 , x_qoh => ll_qoh
8661 , x_rqoh => ll_rqoh
8662 , x_qr => ll_qr
8663 , x_qs => ll_qs
8664 , x_att => ll_att
8665 , x_atr => ll_atr_plus
8666 , x_sqoh => ll_sqoh
8667 , x_srqoh => ll_srqoh
8668 , x_sqr => ll_sqr
8669 , x_sqs => ll_sqs
8670 , x_satt => ll_satt
8671 , x_satr => ll_satr
8672 );
8673
8674 -- returning primary quantity to calling procedure
8675 x_primary_quantity := l_qoh;
8676
8677 -- NSRIVAST, using <> as per GSCC compliance
8678 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
8679 THEN
8680 print_debug('Returning error from INV_QUANTITY_TREE_GRP.QUERY_TREE');
8681 RAISE QUERY_TREE_ERROR;
8682 END IF;
8683
8684 print_debug('within case A prim_qty='||p_primary_quantity||', atr='||l_atr||', ll_atr_Plus='||ll_atr_plus);
8685
8686 -- Check Qties at Lot level
8687 -- IF ( ll_atr_plus > 0 )
8688 -- Bug 4146697 - Modified Condition.
8689 --IF ( ll_atr_plus <> l_atr ) -- This means that Inventory was found in a
8690 -- a different location.
8691 IF ( ll_qoh <> l_qoh ) --Bug#5469430
8692 THEN
8693 print_debug('INV_LOT_INDIV_QTY_RCPT_CASE_2');
8694 --l_error_exp := FND_MESSAGE.GET;
8695 FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_RCPT_CASE_2');
8696 FND_MSG_PUB.ADD;
8697 --l_error_expp := FND_MESSAGE.GET;
8698 /* Update MTI table with error code/explanation */
8699 --errupdate(p_rowid);
8700 RAISE FND_API.G_EXC_ERROR;
8701 END IF; -- ( ll_atr = 0 )
8702 -- bug 4042255 : added forgotten ELSE clause :
8703 -- Bug 4146697 - Removed ELSE condition below.
8704 -- ELSE
8705 -- print_debug('within case 3 Some Qty already available to reserve. prim_qty='||p_primary_quantity||', atr='||l_atr);
8706 -- FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_RCPT_CASE_3');
8707 -- FND_MSG_PUB.ADD;
8708
8709 -- RAISE FND_API.G_EXC_ERROR;
8710 END IF; -- ( l_atr = 0 )
8711
8712 IF ( l_qr > 0 )
8713 THEN
8714 print_debug('within case 3 Some Qty already reserved. prim_qty='||p_primary_quantity||', qr='||l_qr);
8715
8716 print_debug('INV_LOT_INDIV_QTY_RCPT_CASE_3');
8717 --l_error_exp := FND_MESSAGE.GET;
8718 FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_RCPT_CASE_3');
8719 FND_MSG_PUB.ADD;
8720 --l_error_expp := FND_MESSAGE.GET;
8721 /* Update MTI table with error code/explanation */
8722 --errupdate(p_rowid);
8723 RAISE FND_API.G_EXC_ERROR;
8724 END IF; -- ( l_qr > 0 )
8725 END IF; -- l_transaction_action_id IN (27)
8726 l_return := TRUE;
8727
8728 -- action 12 = Intransit Receipt
8729 -- action 30 = WIP Scrap Transaction
8730 -- action 31 = Assembly Completion
8731 -- Before IF (l_transaction_action_id IN ( 12, 27, 30, 31) )
8732 IF (l_transaction_action_id IN ( 12, 30, 31) )
8733 THEN
8734 -- print_debug('within case 4 prim_qty='||p_primary_quantity||', atr='||l_atr);
8735 print_debug('within case 4 prim_qty= '||p_primary_quantity||', l_qr= ' || l_qr);
8736 -- bug 4122106 : added ABS in the test.
8737 -- IF (ABS(p_primary_quantity) <> l_atr )
8738 -- fabdi bug 4486488 changes
8739 IF ( l_qr > 0 )
8740 THEN
8741 -- print_debug('INV_LOT_INDIV_QTY_RCPT_CASE_4');
8742 print_debug('INV_LOT_INDIV_QTY_RCPT_CASE_3');
8743 --l_error_exp := FND_MESSAGE.GET;
8744 -- FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_RCPT_CASE_4');
8745 ---FND_MESSAGE.SET_TOKEN('ATR',l_atr);
8746 -- FND_MSG_PUB.ADD;
8747 FND_MESSAGE.SET_NAME('INV','INV_LOT_INDIV_QTY_RCPT_CASE_3');
8748 FND_MSG_PUB.ADD;
8749 --l_error_expp := FND_MESSAGE.GET;
8750 /* Update MTI table with error code/explanation */
8751 --errupdate(p_rowid);
8752 RAISE FND_API.G_EXC_ERROR;
8753 END IF;
8754 END IF;
8755 l_return := TRUE;
8756 ELSE
8757 print_debug(' the lot is either divisible or new... Return TRUE.');
8758 l_return := TRUE;
8759 END IF; -- lot_divisible
8760
8761 RETURN l_return;
8762
8763 EXCEPTION
8764
8765 WHEN CREATE_TREE_ERROR THEN
8766 print_debug(' CREATE_TREE error...');
8767 x_return_status := FND_API.G_RET_STS_ERROR;
8768 FND_MSG_PUB.Count_AND_GET
8769 (p_count => x_msg_count, p_data => x_msg_data);
8770 RETURN FALSE;
8771
8772 WHEN QUERY_TREE_ERROR THEN
8773 print_debug(' QUERY_TREE error...');
8774 x_return_status := FND_API.G_RET_STS_ERROR;
8775 FND_MSG_PUB.Count_AND_GET
8776 (p_count => x_msg_count, p_data => x_msg_data);
8777 RETURN FALSE;
8778
8779 WHEN FND_API.G_EXC_ERROR THEN
8780 print_debug(' EXCP error...');
8781 x_return_status := FND_API.G_RET_STS_ERROR;
8782 FND_MSG_PUB.Count_AND_GET
8783 (p_count => x_msg_count, p_data => x_msg_data);
8784 RETURN FALSE;
8785
8786 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8787 print_debug(' UNEXCP error...');
8788 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8789 FND_MSG_PUB.Count_AND_GET
8790 (p_count => x_msg_count, p_data => x_msg_data);
8791 RETURN FALSE;
8792
8793 WHEN OTHERS THEN
8794 print_debug(' OTHERS error...'||SQLERRM);
8795 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8796 FND_MSG_PUB.Count_AND_GET
8797 (p_count => x_msg_count, p_data => x_msg_data);
8798 RETURN FALSE;
8799
8800 END validate_lot_indivisible;
8801
8802
8803
8804 PROCEDURE create_inv_lot(
8805 x_return_status OUT NOCOPY VARCHAR2
8806 , x_msg_count OUT NOCOPY NUMBER
8807 , x_msg_data OUT NOCOPY VARCHAR2
8808 , p_inventory_item_id IN NUMBER
8809 , p_organization_id IN NUMBER
8810 , p_lot_number IN VARCHAR2
8811 , p_expiration_date IN DATE
8812 , p_disable_flag IN NUMBER
8813 , p_attribute_category IN VARCHAR2
8814 , p_lot_attribute_category IN VARCHAR2
8815 , p_attributes_tbl IN inv_lot_api_pub.char_tbl
8816 , p_c_attributes_tbl IN inv_lot_api_pub.char_tbl
8817 , p_n_attributes_tbl IN inv_lot_api_pub.number_tbl
8818 , p_d_attributes_tbl IN inv_lot_api_pub.date_tbl
8819 , p_grade_code IN VARCHAR2
8820 , p_origination_date IN DATE
8821 , p_date_code IN VARCHAR2
8822 , p_status_id IN NUMBER
8823 , p_change_date IN DATE
8824 , p_age IN NUMBER
8825 , p_retest_date IN DATE
8826 , p_maturity_date IN DATE
8827 , p_item_size IN NUMBER
8828 , p_color IN VARCHAR2
8829 , p_volume IN NUMBER
8830 , p_volume_uom IN VARCHAR2
8831 , p_place_of_origin IN VARCHAR2
8832 , p_best_by_date IN DATE
8833 , p_length IN NUMBER
8834 , p_length_uom IN VARCHAR2
8835 , p_recycled_content IN NUMBER
8836 , p_thickness IN NUMBER
8837 , p_thickness_uom IN VARCHAR2
8838 , p_width IN NUMBER
8839 , p_width_uom IN VARCHAR2
8840 , p_territory_code IN VARCHAR2
8841 , p_supplier_lot_number IN VARCHAR2
8842 , p_vendor_name IN VARCHAR2
8843 , p_source IN NUMBER
8844 , p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false --bug 7513308
8845 ) IS
8846
8847
8848 /* Defined new variables for overloaded API call */
8849
8850 l_in_lot_rec MTL_LOT_NUMBERS%ROWTYPE;
8851 l_out_lot_rec MTL_LOT_NUMBERS%ROWTYPE;
8852 x_lot_rec MTL_LOT_NUMBERS%ROWTYPE;
8853 l_api_version NUMBER;
8854 l_init_msg_list VARCHAR2(100);
8855 l_commit VARCHAR2(100);
8856 l_validation_level NUMBER;
8857 l_origin_txn_id NUMBER;
8858 l_source NUMBER;
8859 l_return_status VARCHAR2(1) ;
8860 l_msg_data VARCHAR2(3000) ;
8861 l_msg_count NUMBER ;
8862 l_row_id ROWID ;
8863 BEGIN
8864 SAVEPOINT inv_lot;
8865 x_return_status := fnd_api.g_ret_sts_success;
8866
8867 /* Populating the variables and calling the new overloaded API */
8868
8869 l_in_lot_rec.inventory_item_id := p_inventory_item_id;
8870 l_in_lot_rec.organization_id := p_organization_id;
8871 l_in_lot_rec.lot_number := p_lot_number;
8872 l_in_lot_rec.parent_lot_number := NULL;
8873 l_in_lot_rec.expiration_date := p_expiration_date;
8874 l_in_lot_rec.disable_flag := p_disable_flag;
8875 l_in_lot_rec.attribute_category := p_attribute_category;
8876 l_in_lot_rec.lot_attribute_category := p_lot_attribute_category;
8877 l_in_lot_rec.grade_code := p_grade_code;
8878 l_in_lot_rec.origination_date := p_origination_date;
8879 l_in_lot_rec.date_code := p_date_code;
8880 l_in_lot_rec.status_id := p_status_id;
8881 l_in_lot_rec.change_date := p_change_date;
8882 l_in_lot_rec.age := p_age;
8883 l_in_lot_rec.retest_date := p_retest_date;
8884 l_in_lot_rec.maturity_date := p_maturity_date;
8885 l_in_lot_rec.item_size := p_item_size;
8886 l_in_lot_rec.color := p_color;
8887 l_in_lot_rec.volume := p_volume;
8888 l_in_lot_rec.volume_uom := p_volume_uom;
8889 l_in_lot_rec.place_of_origin := p_place_of_origin;
8890 l_in_lot_rec.best_by_date := p_best_by_date;
8891 l_in_lot_rec.length := p_length;
8892 l_in_lot_rec.length_uom := p_length_uom;
8893 l_in_lot_rec.recycled_content := p_recycled_content;
8894 l_in_lot_rec.thickness := p_thickness;
8895 l_in_lot_rec.thickness_uom := p_thickness_uom;
8896 l_in_lot_rec.width := p_width;
8897 l_in_lot_rec.width_uom := p_width_uom;
8898 l_in_lot_rec.territory_code := p_territory_code;
8899 l_in_lot_rec.supplier_lot_number := p_supplier_lot_number;
8900 l_in_lot_rec.vendor_name := p_vendor_name;
8901 l_in_lot_rec.creation_date := SYSDATE;
8902 l_in_lot_rec.last_update_date := SYSDATE ;
8903 l_in_lot_rec.created_by := FND_GLOBAL.USER_ID;
8904 l_in_lot_rec.last_updated_by := FND_GLOBAL.USER_ID;
8905 l_in_lot_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
8906 --BUG 4748451: if the p%tbl are not initialized, then a no_date_found
8907 --exception would be thrown if accessed. So add clause to check for this
8908 IF (p_attributes_tbl.exists(1)) THEN
8909 l_in_lot_rec.attribute1 := p_attributes_tbl(1);
8910 END IF;
8911 IF (p_attributes_tbl.exists(2)) THEN
8912 l_in_lot_rec.attribute2 := p_attributes_tbl(2);
8913 END IF;
8914 IF (p_attributes_tbl.exists(3)) THEN
8915 l_in_lot_rec.attribute3 := p_attributes_tbl(3);
8916 END IF;
8917 IF (p_attributes_tbl.exists(4)) THEN
8918 l_in_lot_rec.attribute4 := p_attributes_tbl(4);
8919 END IF;
8920 IF (p_attributes_tbl.exists(5)) THEN
8921 l_in_lot_rec.attribute5 := p_attributes_tbl(5);
8922 END IF;
8923 IF (p_attributes_tbl.exists(6)) THEN
8924 l_in_lot_rec.attribute6 := p_attributes_tbl(6);
8925 END IF;
8926 IF (p_attributes_tbl.exists(7)) THEN
8927 l_in_lot_rec.attribute7 := p_attributes_tbl(7);
8928 END IF;
8929 IF (p_attributes_tbl.exists(8)) THEN
8930 l_in_lot_rec.attribute8 := p_attributes_tbl(8);
8931 END IF;
8932 IF (p_attributes_tbl.exists(9)) THEN
8933 l_in_lot_rec.attribute9 := p_attributes_tbl(9);
8934 END IF;
8935 IF (p_attributes_tbl.exists(10)) THEN
8936 l_in_lot_rec.attribute10 := p_attributes_tbl(10);
8937 END IF;
8938 IF (p_attributes_tbl.exists(11)) THEN
8939 l_in_lot_rec.attribute11 := p_attributes_tbl(11);
8940 END IF;
8941 IF (p_attributes_tbl.exists(12)) THEN
8942 l_in_lot_rec.attribute12 := p_attributes_tbl(12);
8943 END IF;
8944 IF (p_attributes_tbl.exists(13)) THEN
8945 l_in_lot_rec.attribute13 := p_attributes_tbl(13);
8946 END IF;
8947 IF (p_attributes_tbl.exists(14)) THEN
8948 l_in_lot_rec.attribute14 := p_attributes_tbl(14);
8949 END IF;
8950 IF (p_attributes_tbl.exists(15)) THEN
8951 l_in_lot_rec.attribute15 := p_attributes_tbl(15);
8952 END IF;
8953 IF (p_c_attributes_tbl.exists(1)) THEN
8954 l_in_lot_rec.c_attribute1 := p_c_attributes_tbl(1);
8955 END IF;
8956 IF (p_c_attributes_tbl.exists(2)) THEN
8957 l_in_lot_rec.c_attribute2 := p_c_attributes_tbl(2);
8958 END IF;
8959 IF (p_c_attributes_tbl.exists(3)) THEN
8960 l_in_lot_rec.c_attribute3 := p_c_attributes_tbl(3);
8961 END IF;
8962 IF (p_c_attributes_tbl.exists(4)) THEN
8963 l_in_lot_rec.c_attribute4 := p_c_attributes_tbl(4);
8964 END IF;
8965 IF (p_c_attributes_tbl.exists(5)) THEN
8966 l_in_lot_rec.c_attribute5 := p_c_attributes_tbl(5);
8967 END IF;
8968 IF (p_c_attributes_tbl.exists(6)) THEN
8969 l_in_lot_rec.c_attribute6 := p_c_attributes_tbl(6);
8970 END IF;
8971 IF (p_c_attributes_tbl.exists(7)) THEN
8972 l_in_lot_rec.c_attribute7 := p_c_attributes_tbl(7);
8973 END IF;
8974 IF (p_c_attributes_tbl.exists(8)) THEN
8975 l_in_lot_rec.c_attribute8 := p_c_attributes_tbl(8);
8976 END IF;
8977 IF (p_c_attributes_tbl.exists(9)) THEN
8978 l_in_lot_rec.c_attribute9 := p_c_attributes_tbl(9);
8979 END IF;
8980 IF (p_c_attributes_tbl.exists(10)) THEN
8981 l_in_lot_rec.c_attribute10 := p_c_attributes_tbl(10);
8982 END IF;
8983 IF (p_c_attributes_tbl.exists(11)) THEN
8984 l_in_lot_rec.c_attribute11 := p_c_attributes_tbl(11);
8985 END IF;
8986 IF (p_c_attributes_tbl.exists(12)) THEN
8987 l_in_lot_rec.c_attribute12 := p_c_attributes_tbl(12);
8988 END IF;
8989 IF (p_c_attributes_tbl.exists(13)) THEN
8990 l_in_lot_rec.c_attribute13 := p_c_attributes_tbl(13);
8991 END IF;
8992 IF (p_c_attributes_tbl.exists(14)) THEN
8993 l_in_lot_rec.c_attribute14 := p_c_attributes_tbl(14);
8994 END IF;
8995 IF (p_c_attributes_tbl.exists(15)) THEN
8996 l_in_lot_rec.c_attribute15 := p_c_attributes_tbl(15);
8997 END IF;
8998 IF (p_c_attributes_tbl.exists(16)) THEN
8999 l_in_lot_rec.c_attribute16 := p_c_attributes_tbl(16);
9000 END IF;
9001 IF (p_c_attributes_tbl.exists(17)) THEN
9002 l_in_lot_rec.c_attribute17 := p_c_attributes_tbl(17);
9003 END IF;
9004 IF (p_c_attributes_tbl.exists(18)) THEN
9005 l_in_lot_rec.c_attribute18 := p_c_attributes_tbl(18);
9006 END IF;
9007 IF (p_c_attributes_tbl.exists(19)) THEN
9008 l_in_lot_rec.c_attribute19 := p_c_attributes_tbl(19);
9009 END IF;
9010 IF (p_c_attributes_tbl.exists(20)) THEN
9011 l_in_lot_rec.c_attribute20 := p_c_attributes_tbl(20);
9012 END IF;
9013 IF (p_n_attributes_tbl.exists(1)) THEN
9014 l_in_lot_rec.n_attribute1 := p_n_attributes_tbl(1);
9015 END IF;
9016 IF (p_n_attributes_tbl.exists(2)) THEN
9017 l_in_lot_rec.n_attribute2 := p_n_attributes_tbl(2);
9018 END IF;
9019 IF (p_n_attributes_tbl.exists(3)) THEN
9020 l_in_lot_rec.n_attribute3 := p_n_attributes_tbl(3);
9021 END IF;
9022 IF (p_n_attributes_tbl.exists(4)) THEN
9023 l_in_lot_rec.n_attribute4 := p_n_attributes_tbl(4);
9024 END IF;
9025 IF (p_n_attributes_tbl.exists(5)) THEN
9026 l_in_lot_rec.n_attribute5 := p_n_attributes_tbl(5);
9027 END IF;
9028 IF (p_n_attributes_tbl.exists(6)) THEN
9029 l_in_lot_rec.n_attribute6 := p_n_attributes_tbl(6);
9030 END IF;
9031 IF (p_n_attributes_tbl.exists(7)) THEN
9032 l_in_lot_rec.n_attribute7 := p_n_attributes_tbl(7);
9033 END IF;
9034 IF (p_n_attributes_tbl.exists(8)) THEN
9035 l_in_lot_rec.n_attribute8 := p_n_attributes_tbl(8);
9036 END IF;
9037 IF (p_n_attributes_tbl.exists(9)) THEN
9038 l_in_lot_rec.n_attribute9 := p_n_attributes_tbl(9);
9039 END IF;
9040 IF (p_n_attributes_tbl.exists(10)) THEN
9041 l_in_lot_rec.n_attribute10 := p_n_attributes_tbl(10);
9042 END IF;
9043 IF (p_d_attributes_tbl.exists(1)) THEN
9044 l_in_lot_rec.d_attribute1 := p_d_attributes_tbl(1);
9045 END IF;
9046 IF (p_d_attributes_tbl.exists(2)) THEN
9047 l_in_lot_rec.d_attribute2 := p_d_attributes_tbl(2);
9048 END IF;
9049 IF (p_d_attributes_tbl.exists(3)) THEN
9050 l_in_lot_rec.d_attribute3 := p_d_attributes_tbl(3);
9051 END IF;
9052 IF (p_d_attributes_tbl.exists(4)) THEN
9053 l_in_lot_rec.d_attribute4 := p_d_attributes_tbl(4);
9054 END IF;
9055 IF (p_d_attributes_tbl.exists(5)) THEN
9056 l_in_lot_rec.d_attribute5 := p_d_attributes_tbl(5);
9057 END IF;
9058 IF (p_d_attributes_tbl.exists(6)) THEN
9059 l_in_lot_rec.d_attribute6 := p_d_attributes_tbl(6);
9060 END IF;
9061 IF (p_d_attributes_tbl.exists(7)) THEN
9062 l_in_lot_rec.d_attribute7 := p_d_attributes_tbl(7);
9063 END IF;
9064 IF (p_d_attributes_tbl.exists(8)) THEN
9065 l_in_lot_rec.d_attribute8 := p_d_attributes_tbl(8);
9066 END IF;
9067 IF (p_d_attributes_tbl.exists(9)) THEN
9068 l_in_lot_rec.d_attribute9 := p_d_attributes_tbl(9);
9069 END IF;
9070 IF (p_d_attributes_tbl.exists(10)) THEN
9071 l_in_lot_rec.d_attribute10 := p_d_attributes_tbl(10);
9072 END IF;
9073 --END BUG 4748451
9074
9075 -- Bug 7513308
9076 -- Initialize message list if p_init_msg_list is set to TRUE.
9077 IF fnd_api.to_boolean(p_init_msg_list) THEN
9078 fnd_msg_pub.initialize;
9079 END IF;
9080
9081 l_source := p_source;
9082 l_api_version := 1.0;
9083 l_init_msg_list := p_init_msg_list; --fnd_api.g_false; bug 7513308
9084 l_commit := fnd_api.g_false;
9085 l_validation_level := fnd_api.g_valid_level_full;
9086 l_origin_txn_id := NULL;
9087
9088
9089
9090 /* Calling the overloaded procedure */
9091 Create_Inv_lot(
9092 x_return_status => l_return_status
9093 , x_msg_count => l_msg_count
9094 , x_msg_data => l_msg_data
9095 , x_row_id => l_row_id
9096 , x_lot_rec => x_lot_rec
9097 , p_lot_rec => l_in_lot_rec
9098 , p_source => p_source
9099 , p_api_version => l_api_version
9100 , p_init_msg_list => l_init_msg_list
9101 , p_commit => l_commit
9102 , p_validation_level => l_validation_level
9103 , p_origin_txn_id => l_origin_txn_id
9104 );
9105
9106 IF g_debug = 1 THEN
9107 print_debug('Program Create_Inv_lot return ' || l_return_status, 9);
9108 END IF;
9109 IF l_return_status = fnd_api.g_ret_sts_error THEN
9110 IF g_debug = 1 THEN
9111 print_debug('Program Create_Inv_lot has failed with a user defined exception', 9);
9112 END IF;
9113 RAISE g_exc_error;
9114 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
9115 IF g_debug = 1 THEN
9116 print_debug('Program Create_Inv_lot has failed with a Unexpected exception', 9);
9117 END IF;
9118 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
9119 FND_MESSAGE.SET_TOKEN('PROG_NAME','Create_Inv_lot');
9120 fnd_msg_pub.ADD;
9121 RAISE g_exc_unexpected_error;
9122 END IF;
9123
9124 print_debug('End of the program create_inv_lot. Program has completed successfully ', 9);
9125 EXCEPTION
9126 WHEN NO_DATA_FOUND THEN
9127 x_return_status := fnd_api.g_ret_sts_error;
9128 ROLLBACK TO inv_lot;
9129 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9130 if( x_msg_count > 1 ) then
9131 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9132 end if;
9133 print_debug('In No data found ' || SQLERRM, 9);
9134 WHEN g_exc_error THEN
9135 x_return_status := fnd_api.g_ret_sts_error;
9136 ROLLBACK TO inv_lot;
9137 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9138 if( x_msg_count > 1 ) then
9139 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9140 end if;
9141 print_debug('In g_exc_error ' || SQLERRM, 9);
9142 WHEN g_exc_unexpected_error THEN
9143 x_return_status := fnd_api.g_ret_sts_unexp_error;
9144 ROLLBACK TO inv_lot;
9145 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9146 if( x_msg_count > 1 ) then
9147 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9148 end if;
9149 print_debug('In g_exc_unexpected_error ' || SQLERRM, 9);
9150 WHEN OTHERS THEN
9151 x_return_status := fnd_api.g_ret_sts_unexp_error;
9152 ROLLBACK TO inv_lot;
9153 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9154 if( x_msg_count > 1 ) then
9155 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9156 end if;
9157 print_debug('In others ' || SQLERRM, 9);
9158 END create_inv_lot;
9159
9160
9161
9162 /* Overloaded Create_Inv_lot procedure */
9163 PROCEDURE Create_Inv_lot(
9164 x_return_status OUT NOCOPY VARCHAR2
9165 , x_msg_count OUT NOCOPY NUMBER
9166 , x_msg_data OUT NOCOPY VARCHAR2
9167 , x_row_id OUT NOCOPY ROWID
9168 , x_lot_rec OUT NOCOPY MTL_LOT_NUMBERS%ROWTYPE
9169 , p_lot_rec IN MTL_LOT_NUMBERS%ROWTYPE
9170 , p_source IN NUMBER
9171 , p_api_version IN NUMBER
9172 , p_init_msg_list IN VARCHAR2 := fnd_api.g_false
9173 , p_commit IN VARCHAR2 := fnd_api.g_false
9174 , p_validation_level IN NUMBER := fnd_api.g_valid_level_full
9175 , p_origin_txn_id IN NUMBER
9176 )
9177 IS
9178
9179 /* Cursor definition to check whether item is a valid item and it's lot controlled */
9180 CURSOR c_chk_msi_attr(cp_inventory_item_id NUMBER, cp_organization_id NUMBER) IS
9181 SELECT lot_control_code,
9182 child_lot_flag,
9183 copy_lot_attribute_flag,
9184 shelf_life_code,
9185 grade_control_flag
9186 FROM mtl_system_items_b -- NSRIVAST, Changed the name to MTL_SYSTEM_ITEMS_B as per review comments by Shelly
9187 WHERE inventory_item_id = cp_inventory_item_id
9188 AND organization_id = cp_organization_id;
9189
9190 l_chk_msi_attr_rec c_chk_msi_attr%ROWTYPE;
9191
9192 /* Cursor definition to check lot existence in Mtl_Lot_Numbers Table */
9193 CURSOR c_chk_lot_exists(cp_lot_number MTL_LOT_NUMBERS.lot_number%TYPE,cp_inventory_item_id NUMBER, cp_organization_id NUMBER) IS
9194 SELECT lot_number
9195 FROM mtl_lot_numbers
9196 WHERE lot_number = cp_lot_number AND
9197 inventory_item_id = cp_inventory_item_id AND
9198 organization_id = cp_organization_id;
9199
9200 l_chk_lot_rec c_chk_lot_exists%ROWTYPE;
9201
9202 /* Cursor definition to check if Lot UOM Conversion is needed */
9203 CURSOR c_lot_uom_conv(cp_organization_id NUMBER) IS
9204 SELECT copy_lot_attribute_flag,
9205 lot_number_generation
9206 FROM mtl_parameters
9207 WHERE organization_id = cp_organization_id;
9208
9209 l_lot_uom_conv c_lot_uom_conv%ROWTYPE ;
9210
9211 /* Cursor definition to get gen_object_id for a lot */
9212 CURSOR c_get_obj_id(cp_lot_number MTL_LOT_NUMBERS.lot_number%TYPE,cp_inventory_item_id NUMBER, cp_organization_id NUMBER) IS
9213 SELECT gen_object_id, ROWID
9214 FROM mtl_lot_numbers
9215 WHERE lot_number = cp_lot_number AND
9216 inventory_item_id = cp_inventory_item_id AND
9217 organization_id = cp_organization_id;
9218
9219 l_get_obj_id_rec c_get_obj_id%ROWTYPE;
9220
9221
9222 l_parent_lot_rec MTL_LOT_NUMBERS%ROWTYPE ;
9223 l_child_lot_rec MTL_LOT_NUMBERS%ROWTYPE ;
9224 x_parent_lot_rec MTL_LOT_NUMBERS%ROWTYPE ;
9225 x_child_lot_rec MTL_LOT_NUMBERS%ROWTYPE ;
9226
9227 l_chd_gen_obj_id NUMBER;
9228 l_prt_gen_obj_id NUMBER;
9229
9230 l_parent_exists_flag VARCHAR2(1) ; -- NSRIVAST
9231 l_copy_lot_attribute_flag VARCHAR2(1) ;
9232 l_return_status VARCHAR2(1) ;
9233 l_msg_data VARCHAR2(3000) ;
9234 l_msg_count NUMBER ;
9235 l_api_version NUMBER;
9236 l_init_msg_list VARCHAR2(100);
9237 l_commit VARCHAR2(100);
9238 l_source NUMBER;
9239 l_row_id ROWID ;
9240 BEGIN
9241
9242 SAVEPOINT inv_lot_1;
9243 x_return_status := g_ret_sts_success;
9244
9245 /* BASIC CHECKS , start */
9246 IF p_lot_rec.organization_id IS NULL THEN
9247 IF g_debug = 1 THEN
9248 print_debug('Value for mandatory field organization id cannot be null.', 9);
9249 END IF;
9250 fnd_message.set_name('INV', 'INV_NULL_ORG_EXP') ;
9251 fnd_msg_pub.ADD;
9252 RAISE fnd_api.g_exc_error;
9253 END IF ;
9254
9255
9256 /* Check item existence in Mtl_system_items Table */
9257 OPEN c_chk_msi_attr(p_lot_rec.inventory_item_id,p_lot_rec.organization_id);
9258 FETCH c_chk_msi_attr INTO l_chk_msi_attr_rec;
9259
9260 IF c_chk_msi_attr%NOTFOUND THEN
9261 CLOSE c_chk_msi_attr;
9262 IF (g_debug = 1) THEN
9263 print_debug('Item not found. Invalid item. Please re-enter.', 9);
9264 END IF;
9265
9266 fnd_message.set_name('INV', 'INV_INVALID_ITEM');
9267 fnd_msg_pub.ADD;
9268 RAISE g_exc_error;
9269 ELSE
9270 CLOSE c_chk_msi_attr;
9271
9272 l_copy_lot_attribute_flag := l_chk_msi_attr_rec.copy_lot_attribute_flag ;
9273
9274 /* If not lot controlled then error out */
9275 IF (l_chk_msi_attr_rec.lot_control_code = 1) THEN
9276 IF g_debug = 1 THEN
9277 print_debug('Item is not lot controlled ', 9);
9278 END IF;
9279
9280 fnd_message.set_name('INV', 'INV_NO_LOT_CONTROL');
9281 fnd_msg_pub.ADD;
9282 x_return_status := fnd_api.g_ret_sts_error;
9283 RAISE g_exc_error;
9284 END IF; /* l_chk_msi_attr_rec.lot_control_code = 1 */
9285
9286 /* If not child lot enabled and p_lot_rec.parent_lot_number IS NOT NULL then error out */
9287 IF (l_chk_msi_attr_rec.child_lot_flag = 'N' AND p_lot_rec.parent_lot_number IS NOT NULL) THEN
9288 IF g_debug = 1 THEN
9289 print_debug('Item is not child lot enabled ', 9);
9290 END IF;
9291
9292 fnd_message.set_name('INV', 'INV_ITEM_CLOT_DISABLE_EXP');
9293 fnd_msg_pub.ADD;
9294 x_return_status := fnd_api.g_ret_sts_error;
9295 RAISE g_exc_error;
9296 END IF; /* l_chk_msi_attr_rec.child_lot_flag = 'N' */
9297
9298 /* Check for User-defined expiration date */
9299 IF p_lot_rec.expiration_date IS NULL AND
9300 l_chk_msi_attr_rec.shelf_life_code = 4 THEN -- User-defined expiration date
9301 IF g_debug = 1 THEN
9302 print_debug('User defined expiration date cannot be null', 9);
9303 END IF;
9304
9305 fnd_message.set_name('INV', 'INV_NULL_EXPIRATION_DATE_EXP') ;
9306 fnd_msg_pub.ADD;
9307 RAISE fnd_api.g_exc_error;
9308 END IF;
9309
9310 /* Check whether item is grade controlled */
9311 IF p_lot_rec.grade_code IS NOT NULL AND
9312 l_chk_msi_attr_rec.grade_control_flag = 'N' THEN
9313 IF g_debug = 1 THEN
9314 print_debug('Item is not grade controlled.', 9);
9315 END IF;
9316
9317 fnd_message.set_name('INV', 'INV_ITEM_NOT_GRADE_CTRL_EXP');
9318 fnd_msg_pub.ADD;
9319 RAISE fnd_api.g_exc_error;
9320 END IF;
9321
9322 END IF; /* c_chk_msi_attr*/
9323
9324 /* Check for existence of Lot in Mtl_Lot_Numbers Table */
9325 IF p_lot_rec.lot_number IS NULL THEN
9326 IF g_debug = 1 THEN
9327 print_debug('Value for mandatory field Lot Number cannot be null', 9);
9328 END IF;
9329
9330 fnd_message.set_name('INV', 'INV_NULL_CLOT_EXP');
9331 fnd_msg_pub.ADD;
9332 RAISE fnd_api.g_exc_error;
9333 ELSE
9334 /* Check child lot existence in Mtl_Lot_Numbers Table */
9335 OPEN c_chk_lot_exists(p_lot_rec.lot_number,p_lot_rec.inventory_item_id,p_lot_rec.organization_id);
9336 FETCH c_chk_lot_exists INTO l_chk_lot_rec;
9337
9338 IF c_chk_lot_exists%FOUND THEN
9339 /* Child lot exists in Mtl_Lot_Numbers Table. */
9340 IF g_debug = 1 THEN
9341 print_debug('Child lot already exists in the system.', 9);
9342 END IF;
9343
9344 -- Child lot already exists in the system: LOT_NUMBER
9345 fnd_message.set_name('INV', 'INV_CLOT_EXISTS_EXP');
9346 fnd_message.set_token('LOT_NUMBER', to_char(p_lot_rec.lot_number));
9347 fnd_msg_pub.ADD;
9348 RAISE fnd_api.g_exc_error;
9349 END IF;
9350 /* Child lot DOES NOT exist in Mtl_Lot_Numbers Table. */
9351 CLOSE c_chk_lot_exists;
9352 END IF;
9353
9354 /* Check for same parent and child lot names */
9355 IF p_lot_rec.lot_number IS NOT NULL AND p_lot_rec.parent_lot_number IS NOT NULL THEN
9356 IF p_lot_rec.lot_number = p_lot_rec.parent_lot_number THEN
9357 /*Both the parent and child lots have same name*/
9358 IF g_debug = 1 THEN
9359 print_debug('Parent lot number and child lot number can not be same.', 9);
9360 END IF;
9361 fnd_message.set_name('INV', 'INV_SAME_LOT_NAMES_EXP');
9362 fnd_msg_pub.ADD;
9363 RAISE fnd_api.g_exc_error;
9364 END IF ;
9365 END IF ;
9366
9367 /* Check for existence of Parent Lot in Mtl_Lot_Numbers Table */
9368 l_parent_exists_flag := NULL;
9369
9370 OPEN c_chk_lot_exists(p_lot_rec.parent_lot_number,p_lot_rec.inventory_item_id,p_lot_rec.organization_id);
9371 FETCH c_chk_lot_exists INTO l_chk_lot_rec;
9372
9373 IF c_chk_lot_exists%FOUND THEN
9374 /* Parent lot exists in Mtl_Lot_Numbers Table. */
9375 l_parent_exists_flag := 'Y';
9376
9377 ELSIF c_chk_lot_exists%NOTFOUND AND p_lot_rec.parent_lot_number IS NOT NULL THEN
9378 /* Parent lot DOES NOT exist in Mtl_Lot_Numbers Table. */
9379 l_parent_exists_flag := 'N';
9380 END IF;
9381 CLOSE c_chk_lot_exists;
9382
9383 /* BASIC CHECKS , End */
9384
9385 IF p_validation_level = FND_API.G_VALID_LEVEL_FULL THEN
9386
9387 -- Call Populate_Lot_Records API.
9388 -- Populate_Lot_Records API returns following OUT parameters:
9389 -- x_parent_lot_rec,
9390 -- x_lot_rec
9391 l_source := p_source ;
9392 l_api_version := 1.0;
9393 l_init_msg_list := fnd_api.g_false;
9394 l_commit := fnd_api.g_false;
9395
9396 Inv_Lot_Api_Pkg.Populate_Lot_Records (
9397 p_lot_rec => p_lot_rec
9398 , p_copy_lot_attribute_flag => l_copy_lot_attribute_flag
9399 , p_source => l_source
9400 , p_api_version => l_api_version
9401 , p_init_msg_list => l_init_msg_list
9402 , p_commit => l_commit
9403 , x_child_lot_rec => x_child_lot_rec
9404 , x_return_status => l_return_status
9405 , x_msg_count => l_msg_count
9406 , x_msg_data => l_msg_data
9407 );
9408
9409 IF g_debug = 1 THEN
9410 print_debug('Program INV_LOT_API_PKG.POPULATE_LOT_RECORDS return ' || x_return_status, 9);
9411 END IF;
9412 IF l_return_status = g_ret_sts_error THEN
9413 IF g_debug = 1 THEN
9414 print_debug('Program INV_LOT_API_PKG.POPULATE_LOT_RECORDS has failed with a user defined exception', 9);
9415 END IF;
9416 RAISE g_exc_error;
9417 ELSIF l_return_status = g_ret_sts_unexp_error THEN
9418 IF g_debug = 1 THEN
9419 print_debug('Program INV_LOT_API_PKG.POPULATE_LOT_RECORDS has failed with a Unexpected exception', 9);
9420 END IF;
9421 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
9422 FND_MESSAGE.SET_TOKEN('PROG_NAME','INV_LOT_API_PKG.POPULATE_LOT_RECORDS');
9423 FND_MSG_PUB.ADD;
9424 RAISE g_exc_unexpected_error;
9425 END IF;
9426
9427 -- Populate local variable l_child_lot_rec with the values from x_child_lot_rec.
9428 l_child_lot_rec := x_child_lot_rec;
9429
9430 END IF; /* p_validation_level = G_VALID_LEVEL_FULL */
9431
9432
9433 IF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
9434 -- Populate local variable l_child_lot_rec with proper attribute's values that are passed as input parameter to this API.
9435 l_child_lot_rec := p_lot_rec ;
9436
9437 END IF; /* p_validation_level = G_VALID_LEVEL_NONE */
9438
9439
9440 -- Call mtl_lot_numbers_pkg.insert_row API passing the attribute's
9441 -- values populated in local variable l_child_lot_rec.
9442
9443 -- OPM Inventory Convergence - added column sampling_event_id to mtl_lot_number
9444 -- Bug #4115021
9445 /*Bug#5523811 passing values from l_child_lot_rec instead of NULL for fields
9446 curl_wrnkl_fold, description and vendor_id */
9447 Mtl_Lot_Numbers_Pkg.Insert_Row(
9448 x_inventory_item_id => l_child_lot_rec.inventory_item_id
9449 , x_organization_id => l_child_lot_rec.organization_id
9450 , x_lot_number => l_child_lot_rec.lot_number
9451 , x_parent_lot_number => l_child_lot_rec.parent_lot_number
9452 , x_supplier_lot_number => l_child_lot_rec.supplier_lot_number
9453 , x_grade_code => l_child_lot_rec.grade_code
9454 , x_origination_date => l_child_lot_rec.origination_date
9455 , x_date_code => l_child_lot_rec.date_code
9456 , x_status_id => l_child_lot_rec.status_id
9457 , x_change_date => l_child_lot_rec.change_date
9458 , x_age => l_child_lot_rec.age
9459 , x_retest_date => l_child_lot_rec.retest_date
9460 , x_maturity_date => l_child_lot_rec.maturity_date
9461 , x_lot_attribute_category => l_child_lot_rec.lot_attribute_category
9462 , x_item_size => l_child_lot_rec.item_size
9463 , x_color => l_child_lot_rec.color
9464 , x_volume => l_child_lot_rec.volume
9465 , x_volume_uom => l_child_lot_rec.volume_uom
9466 , x_place_of_origin => l_child_lot_rec.place_of_origin
9467 , x_best_by_date => l_child_lot_rec.best_by_date
9468 , x_length => l_child_lot_rec.length
9469 , x_length_uom => l_child_lot_rec.length_uom
9470 , x_recycled_content => l_child_lot_rec.recycled_content
9471 , x_thickness => l_child_lot_rec.thickness
9472 , x_thickness_uom => l_child_lot_rec.thickness_uom
9473 , x_width => l_child_lot_rec.width
9474 , x_width_uom => l_child_lot_rec.width_uom
9475 , x_territory_code => l_child_lot_rec.territory_code
9476 , x_expiration_date => l_child_lot_rec.expiration_date
9477 , x_disable_flag => l_child_lot_rec.disable_flag
9478 , x_attribute_category => l_child_lot_rec.attribute_category
9479 , x_origination_type => l_child_lot_rec.origination_type
9480 , x_expiration_action_date => l_child_lot_rec.expiration_action_date
9481 , x_expiration_action_code => l_child_lot_rec.expiration_action_code
9482 , x_hold_date => l_child_lot_rec.hold_date
9483 , x_last_update_date => SYSDATE
9484 , x_last_updated_by => FND_GLOBAL.USER_ID
9485 , x_creation_date => SYSDATE
9486 , x_created_by => FND_GLOBAL.USER_ID
9487 , x_last_update_login => FND_GLOBAL.LOGIN_ID
9488 , x_attribute1 => l_child_lot_rec.attribute1
9489 , x_attribute2 => l_child_lot_rec.attribute2
9490 , x_attribute3 => l_child_lot_rec.attribute3
9491 , x_attribute4 => l_child_lot_rec.attribute4
9492 , x_attribute5 => l_child_lot_rec.attribute5
9493 , x_attribute6 => l_child_lot_rec.attribute6
9494 , x_attribute7 => l_child_lot_rec.attribute7
9495 , x_attribute8 => l_child_lot_rec.attribute8
9496 , x_attribute9 => l_child_lot_rec.attribute9
9497 , x_attribute10 => l_child_lot_rec.attribute10
9498 , x_attribute11 => l_child_lot_rec.attribute11
9499 , x_attribute12 => l_child_lot_rec.attribute12
9500 , x_attribute13 => l_child_lot_rec.attribute13
9501 , x_attribute14 => l_child_lot_rec.attribute14
9502 , x_attribute15 => l_child_lot_rec.attribute15
9503 , x_c_attribute1 => l_child_lot_rec.c_attribute1
9504 , x_c_attribute2 => l_child_lot_rec.c_attribute2
9505 , x_c_attribute3 => l_child_lot_rec.c_attribute3
9506 , x_c_attribute4 => l_child_lot_rec.c_attribute4
9507 , x_c_attribute5 => l_child_lot_rec.c_attribute5
9508 , x_c_attribute6 => l_child_lot_rec.c_attribute6
9509 , x_c_attribute7 => l_child_lot_rec.c_attribute7
9510 , x_c_attribute8 => l_child_lot_rec.c_attribute8
9511 , x_c_attribute9 => l_child_lot_rec.c_attribute9
9512 , x_c_attribute10 => l_child_lot_rec.c_attribute10
9513 , x_c_attribute11 => l_child_lot_rec.c_attribute11
9514 , x_c_attribute12 => l_child_lot_rec.c_attribute12
9515 , x_c_attribute13 => l_child_lot_rec.c_attribute13
9516 , x_c_attribute14 => l_child_lot_rec.c_attribute14
9517 , x_c_attribute15 => l_child_lot_rec.c_attribute15
9518 , x_c_attribute16 => l_child_lot_rec.c_attribute16
9519 , x_c_attribute17 => l_child_lot_rec.c_attribute17
9520 , x_c_attribute18 => l_child_lot_rec.c_attribute18
9521 , x_c_attribute19 => l_child_lot_rec.c_attribute19
9522 , x_c_attribute20 => l_child_lot_rec.c_attribute20
9523 , x_d_attribute1 => l_child_lot_rec.d_attribute1
9524 , x_d_attribute2 => l_child_lot_rec.d_attribute2
9525 , x_d_attribute3 => l_child_lot_rec.d_attribute3
9526 , x_d_attribute4 => l_child_lot_rec.d_attribute4
9527 , x_d_attribute5 => l_child_lot_rec.d_attribute5
9528 , x_d_attribute6 => l_child_lot_rec.d_attribute6
9529 , x_d_attribute7 => l_child_lot_rec.d_attribute7
9530 , x_d_attribute8 => l_child_lot_rec.d_attribute8
9531 , x_d_attribute9 => l_child_lot_rec.d_attribute9
9532 , x_d_attribute10 => l_child_lot_rec.d_attribute10
9533 , x_n_attribute1 => l_child_lot_rec.n_attribute1
9534 , x_n_attribute2 => l_child_lot_rec.n_attribute2
9535 , x_n_attribute3 => l_child_lot_rec.n_attribute3
9536 , x_n_attribute4 => l_child_lot_rec.n_attribute4
9537 , x_n_attribute5 => l_child_lot_rec.n_attribute5
9538 , x_n_attribute6 => l_child_lot_rec.n_attribute6
9539 , x_n_attribute7 => l_child_lot_rec.n_attribute7
9540 , x_n_attribute8 => l_child_lot_rec.n_attribute8
9541 , x_n_attribute9 => l_child_lot_rec.n_attribute9
9542 , x_n_attribute10 => l_child_lot_rec.n_attribute10
9543 , x_request_id => NULL
9544 , x_program_application_id => NULL
9545 , x_program_id => NULL
9546 , x_program_update_date => NULL
9547 , x_curl_wrinkle_fold => l_child_lot_rec.curl_wrinkle_fold
9548 , x_description => l_child_lot_rec.description
9549 , x_vendor_id => l_child_lot_rec.vendor_id
9550 , x_sampling_event_id => l_child_lot_rec.sampling_event_id
9551 );
9552
9553 /*.Check needed for Lot UOM conversion */
9554 OPEN c_lot_uom_conv (p_lot_rec.organization_id) ;
9555 FETCH c_lot_uom_conv INTO l_lot_uom_conv ;
9556
9557 IF c_lot_uom_conv%FOUND THEN
9558 CLOSE c_lot_uom_conv ;
9559
9560 -- Possible values for mtl_parameters.lot_number_generation are:
9561 -- 1 At organization level
9562 -- 3 User defined
9563 -- 2 At item level
9564
9565 IF l_lot_uom_conv.lot_number_generation = 1 THEN
9566 l_copy_lot_attribute_flag := NVL(l_lot_uom_conv.copy_lot_attribute_flag,'N') ;
9567 ELSIF l_lot_uom_conv.lot_number_generation IN (2,3) THEN
9568 l_copy_lot_attribute_flag := NVL(l_chk_msi_attr_rec.copy_lot_attribute_flag,'N') ;
9569 END IF;
9570
9571 ELSE
9572 CLOSE c_lot_uom_conv ;
9573 END IF ;
9574
9575
9576 /* Check to see if Copy Lot UOM Conversions is required.
9577 Call MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM_CONVERSIONS */
9578
9579 IF l_copy_lot_attribute_flag = 'Y' AND l_parent_exists_flag = 'Y' THEN
9580 Mtl_Lot_Uom_Conv_Pvt.Copy_Lot_Uom_Conversions (
9581 p_from_organization_id => p_lot_rec.organization_id
9582 , p_to_organization_id => p_lot_rec.organization_id
9583 , p_inventory_item_id => p_lot_rec.inventory_item_id
9584 , p_from_lot_number => p_lot_rec.parent_lot_number
9585 , p_to_lot_number => p_lot_rec.lot_number
9586 , p_user_id => fnd_global.user_id
9587 , p_creation_date => SYSDATE
9588 , p_commit => p_commit
9589 , x_return_status => l_return_status
9590 , x_msg_count => l_msg_count
9591 , x_msg_data => l_msg_data
9592 ) ;
9593
9594 IF g_debug = 1 THEN
9595 print_debug('Program MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM return ' || l_return_status, 9);
9596 END IF;
9597 IF l_return_status = g_ret_sts_error THEN
9598 IF g_debug = 1 THEN
9599 print_debug('Program MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM has failed with a user defined exception', 9);
9600 END IF;
9601 RAISE g_exc_error;
9602 ELSIF l_return_status = g_ret_sts_unexp_error THEN
9603 IF g_debug = 1 THEN
9604 print_debug('Program MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM has failed with a Unexpected exception', 9);
9605 END IF;
9606 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
9607 FND_MESSAGE.SET_TOKEN('PROG_NAME','MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM');
9608 FND_MSG_PUB.ADD;
9609 RAISE g_exc_unexpected_error;
9610 END IF;
9611
9612 END IF; /* Call MTL_LOT_UOM_CONV_PVT.COPY_LOT_UOM_CONVERSIONS */
9613
9614
9615 OPEN c_get_obj_id (p_lot_rec.lot_number,p_lot_rec.inventory_item_id,p_lot_rec.organization_id);
9616 FETCH c_get_obj_id INTO l_get_obj_id_rec;
9617 IF c_get_obj_id%NOTFOUND THEN
9618 CLOSE c_get_obj_id;
9619 RAISE NO_DATA_FOUND ;
9620 END IF;
9621 CLOSE c_get_obj_id;
9622
9623 l_row_id := l_get_obj_id_rec.ROWID ;
9624 x_row_id := l_row_id ;
9625
9626 /* Populate the Our parameter, x_lot_rec */
9627 x_lot_rec := l_child_lot_rec ;
9628 x_lot_rec.gen_object_id := l_get_obj_id_rec.gen_object_id ;
9629
9630 print_debug('End of the program create_inv_lot. Program has completed successfully ', 9);
9631 EXCEPTION
9632 WHEN NO_DATA_FOUND THEN
9633 x_return_status := g_ret_sts_error;
9634 ROLLBACK TO inv_lot_1;
9635 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9636 if( x_msg_count > 1 ) then
9637 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9638 end if;
9639 print_debug('In No data found Create_Inv_Lot ' || SQLERRM, 9);
9640 WHEN g_exc_error THEN
9641 x_return_status := g_ret_sts_error;
9642 ROLLBACK TO inv_lot_1;
9643 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9644 if( x_msg_count > 1 ) then
9645 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9646 end if;
9647 print_debug('In g_exc_error Create_Inv_Lot ' || SQLERRM, 9);
9648 WHEN g_exc_unexpected_error THEN
9649 x_return_status := g_ret_sts_unexp_error;
9650 ROLLBACK TO inv_lot_1;
9651 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9652 if( x_msg_count > 1 ) then
9653 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9654 end if;
9655 print_debug('In g_exc_unexpected_error Create_Inv_Lot ' || SQLERRM, 9);
9656 WHEN OTHERS THEN
9657 x_return_status := g_ret_sts_unexp_error;
9658 ROLLBACK TO inv_lot_1;
9659 fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
9660 if( x_msg_count > 1 ) then
9661 x_msg_data := fnd_msg_pub.get(x_msg_count, FND_API.G_FALSE);
9662 end if;
9663 print_debug('In others Create_Inv_Lot ' || SQLERRM, 9);
9664
9665 END Create_Inv_lot;
9666
9667 /* HVERDDIN ADDED OLD routine back, this will call new version, Start */
9668
9669 FUNCTION auto_gen_lot (
9670 p_org_id IN NUMBER,
9671 p_inventory_item_id IN NUMBER,
9672 p_lot_generation IN NUMBER := NULL,
9673 p_lot_uniqueness IN NUMBER := NULL,
9674 p_lot_prefix IN VARCHAR2 := NULL,
9675 p_zero_pad IN NUMBER := NULL,
9676 p_lot_length IN NUMBER := NULL,
9677 p_transaction_date IN DATE := NULL,
9678 p_revision IN VARCHAR2 := NULL,
9679 p_subinventory_code IN VARCHAR2 := NULL,
9680 p_locator_id IN NUMBER := NULL,
9681 p_transaction_type_id IN NUMBER := NULL,
9682 p_transaction_action_id IN NUMBER := NULL,
9683 p_transaction_source_type_id IN NUMBER := NULL,
9684 p_lot_number IN VARCHAR2 := NULL,
9685 p_api_version IN NUMBER,
9686 p_init_msg_list IN VARCHAR2 := fnd_api.g_false,
9687 p_commit IN VARCHAR2 := fnd_api.g_false,
9688 p_validation_level IN NUMBER
9689 := fnd_api.g_valid_level_full,
9690 x_return_status OUT NOCOPY VARCHAR2,
9691 x_msg_count OUT NOCOPY NUMBER,
9692 x_msg_data OUT NOCOPY VARCHAR2
9693 )
9694 RETURN VARCHAR2
9695 IS
9696 l_unique_lot BOOLEAN := FALSE;
9697 l_lotcount NUMBER;
9698 l_api_version CONSTANT NUMBER := 1.0;
9699 l_api_name CONSTANT VARCHAR2 ( 50 ) := 'INV_LOT_API_PUB.auto_gen_lot';
9700 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
9701 v_org_code VARCHAR2 ( 3 );
9702 v_item_name VARCHAR2 ( 40 );
9703 x_parent_lot_number MTL_LOT_NUMBERS.LOT_NUMBER%TYPE := NULL;
9704 x_parent_call MTL_LOT_NUMBERS.LOT_NUMBER%TYPE;
9705
9706 BEGIN
9707 x_parent_call := inv_lot_api_pub.auto_gen_lot (
9708 p_org_id,
9709 p_inventory_item_id,
9710 p_lot_generation,
9711 p_lot_uniqueness,
9712 p_lot_prefix,
9713 p_zero_pad,
9714 p_lot_length,
9715 p_transaction_date,
9716 p_revision,
9717 p_subinventory_code,
9718 p_locator_id,
9719 p_transaction_type_id,
9720 p_transaction_action_id,
9721 p_transaction_source_type_id,
9722 p_lot_number,
9723 p_api_version,
9724 p_init_msg_list,
9725 p_commit,
9726 p_validation_level,
9727 x_parent_lot_number,
9728 x_return_status,
9729 x_msg_count,
9730 x_msg_data
9731 );
9732 RETURN x_parent_call;
9733
9734
9735 EXCEPTION
9736 WHEN fnd_api.g_exc_error THEN
9737 ROLLBACK TO apiauto_gen_lot_apipub;
9738 x_return_status := fnd_api.g_ret_sts_error;
9739 fnd_msg_pub.count_and_get (
9740 p_encoded => fnd_api.g_false,
9741 p_count => x_msg_count,
9742 p_data => x_msg_data
9743 );
9744 RETURN ( NULL );
9745 WHEN fnd_api.g_exc_unexpected_error THEN
9746 ROLLBACK TO apiauto_gen_lot_apipub;
9747 x_return_status := fnd_api.g_ret_sts_unexp_error;
9748 fnd_msg_pub.count_and_get (
9749 p_encoded => fnd_api.g_false,
9750 p_count => x_msg_count,
9751 p_data => x_msg_data
9752 );
9753 RETURN ( NULL );
9754 WHEN OTHERS THEN
9755 ROLLBACK TO apiauto_gen_lot_apipub;
9756 x_return_status := fnd_api.g_ret_sts_unexp_error;
9757
9758 IF fnd_msg_pub.check_msg_level ( fnd_msg_pub.g_msg_lvl_unexp_error) THEN
9759 fnd_msg_pub.add_exc_msg ( g_pkg_name, l_api_name );
9760 END IF;
9761
9762 fnd_msg_pub.count_and_get (
9763 p_encoded => fnd_api.g_false,
9764 p_count => x_msg_count,
9765 p_data => x_msg_data
9766 );
9767 RETURN ( NULL );
9768 END auto_gen_lot;
9769
9770 /* INVCONV , HVERDDIN ADDED AUTO_GEN_LOT Wrapper for MSCA , End*/
9771
9772
9773
9774
9775 /*INVCONV , Punit Kumar */
9776
9777 /*####################################################################################
9778 #
9779 # PROCEDURE : CHECK_LOT_INDIVISIBILITY
9780 #
9781 #
9782 # DESCRIPTION : This is a wrapper procedure to call lot indivisible api
9783 # and shall be called by INV TM.
9784 # it also encorporates an enhancement to handle multiple deliveries
9785 # to INV for a lot indiv item.
9786 #
9787 #
9788 # MODIFICATION HISTORY
9789 # 07-FEB-2005 Punit Kumar Created
9790 #
9791 ######################################################################################*/
9792
9793 PROCEDURE CHECK_LOT_INDIVISIBILITY ( p_api_version IN NUMBER DEFAULT 1.0
9794 ,p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE
9795 ,p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE
9796 ,p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL
9797 ,p_rti_id IN NUMBER
9798 ,p_transaction_type_id IN NUMBER
9799 ,p_lot_number IN VARCHAR2
9800 ,p_lot_quantity IN NUMBER
9801 ,p_revision IN VARCHAR2
9802 ,p_qoh IN NUMBER DEFAULT NULL
9803 ,p_atr IN NUMBER DEFAULT NULL
9804 ,x_return_status OUT NOCOPY VARCHAR2
9805 ,x_msg_count OUT NOCOPY NUMBER
9806 ,x_msg_data OUT NOCOPY VARCHAR2
9807 )
9808 IS
9809
9810 l_api_name VARCHAR2(30) := 'CHECK_LOT_INDIVISIBILITY' ;
9811 l_api_version CONSTANT NUMBER := 1.0 ;
9812 l_return_status VARCHAR2(1) ;
9813 l_msg_data VARCHAR2(3000) ;
9814 l_msg_count NUMBER ;
9815 l_progress VARCHAR2(3) := '000' ;
9816
9817 l_parent_trx_id NUMBER ;
9818 l_pmy_rcv_qty NUMBER ;
9819 l_lot_qty NUMBER ;
9820 l_pmy_unit_of_meas VARCHAR2(100) ;
9821 l_to_organization_id NUMBER ;
9822 l_subinventory_code VARCHAR2(100) ;
9823 l_locator_id NUMBER ;
9824 l_item_id NUMBER ;
9825 l_trx_unit_of_measure VARCHAR2(100) ;
9826
9827
9828
9829 CURSOR Cr_rti_values(l_rti_id NUMBER) IS
9830 SELECT TO_ORGANIZATION_ID
9831 ,SUBINVENTORY
9832 ,locator_id
9833 ,item_id
9834 ,PARENT_TRANSACTION_ID
9835 ,UNIT_OF_MEASURE
9836 FROM RCV_TRANSACTIONS_INTERFACE
9837 WHERE INTERFACE_TRANSACTION_ID = l_rti_id;
9838
9839
9840 CURSOR Cr_rt_values(l_rt_id NUMBER) IS
9841 SELECT primary_quantity , primary_unit_of_measure
9842 FROM rcv_transactions
9843 WHERE transaction_id = l_rt_id ;
9844
9845
9846
9847 BEGIN
9848
9849 -- Standard call to check for call compatibility.
9850 IF NOT fnd_api.compatible_api_call(
9851 l_api_version,
9852 p_api_version,
9853 l_api_name,
9854 'inv_lot_api_pub'
9855 ) THEN
9856 IF (g_debug = 1) THEN
9857 print_debug('FND_API not compatible INV_LOT_API_PUB.CHECK_LOT_INDIVISIBILITY: '||l_progress, 1);
9858 END IF;
9859 RAISE fnd_api.g_exc_unexpected_error;
9860 END IF;
9861
9862 l_progress := '001';
9863
9864 -- Initialize message list if p_init_msg_list is set to TRUE.
9865 IF fnd_api.to_boolean(p_init_msg_list) THEN
9866 fnd_msg_pub.initialize;
9867 END IF;
9868
9869 --Initialize the return status
9870 x_return_status := FND_API.G_RET_STS_SUCCESS;
9871
9872 l_progress := '002';
9873
9874 /*Calling the lot indivisible function only for the following
9875 1) Deliver to Inventory (PO Receipt) --- for PO or RMA or Internal Req
9876 2) Return to Vendor (from INV)
9877 3) Return to Receiving (from INV)
9878 4) Return to Customer (from INV)---RMA
9879
9880 Since the current procedure is executed only for INV related trx ,
9881 as its being called from INV TM, so we need not code for restricting
9882 RCV location related trx.
9883 Hence restrict for the above 4 types of trx only */
9884
9885 IF p_transaction_type_id IN (18,15,61,36,37) THEN
9886
9887 ----fetching values from RTI
9888 OPEN Cr_rti_values(p_rti_id);
9889 FETCH Cr_rti_values
9890 INTO l_to_organization_id
9891 ,l_subinventory_code
9892 ,l_locator_id
9893 ,l_item_id
9894 ,l_parent_trx_id
9895 ,l_trx_unit_of_measure;
9896 CLOSE Cr_rti_values;
9897
9898 l_progress := '003';
9899
9900 IF g_debug = 1 THEN
9901 print_debug('l_to_organization_id '|| l_to_organization_id , 1);
9902 print_debug('l_subinventory_code '||l_subinventory_code , 1);
9903 print_debug('l_locator_id '|| l_locator_id, 1);
9904 print_debug('l_item_id '|| l_item_id , 1);
9905 print_debug('l_parent_trx_id '|| l_parent_trx_id, 1);
9906 print_debug('l_trx_unit_of_measure '|| l_trx_unit_of_measure, 1);
9907 print_debug('Before calling INV_LOT_API_PUB.validate_lot_indivisible ',1);
9908 END IF;
9909
9910 l_progress := '004';
9911
9912 ---call the indiv function
9913 IF NOT (INV_LOT_API_PUB.validate_lot_indivisible(
9914 p_api_version =>1.0
9915 ,p_init_msg_list =>FND_API.G_FALSE
9916 ,p_commit =>FND_API.G_FALSE
9917 ,p_validation_level =>FND_API.G_VALID_LEVEL_FULL
9918 ,p_transaction_type_id =>p_transaction_type_id
9919 ,p_organization_id =>l_to_organization_id
9920 ,p_inventory_item_id =>l_item_id
9921 ,p_revision =>p_revision
9922 ,p_subinventory_code =>l_subinventory_code
9923 ,p_locator_id =>l_locator_id
9924 ,p_lot_number =>p_lot_number
9925 ,p_primary_quantity =>p_lot_quantity------------the primary quantity of the transaction
9926 ,p_qoh =>p_qoh
9927 ,p_atr =>p_atr
9928 ,x_return_status =>l_return_status
9929 ,x_msg_count =>l_msg_count
9930 ,x_msg_data =>l_msg_data
9931 ))THEN
9932
9933 IF g_debug = 1 THEN
9934 print_debug('Program INV_LOT_API_PUB.validate_lot_indivisible return FALSE ' || l_return_status || 'and '|| l_progress, 9);
9935 END IF;
9936
9937 l_progress := '005';
9938
9939 ---If lot indiv fails fro a Return trx...
9940 IF ((l_return_status <> FND_API.G_RET_STS_SUCCESS) AND p_transaction_type_id IN (36,37)) THEN
9941
9942 /*---logic to explain the values of p_transaction_type_id
9943 IF (transaction_type IN ('RETURN TO RECEIVING','RETURN TO VENDOR','RETURN TO CUSTOMER')) THEN
9944 IF (source_document_code = 'PO') THEN
9945 p_transaction_type_id := 36;
9946 ELSIF (source_document_code = 'RMA') THEN
9947 p_transaction_type_id := 37;
9948 END IF;
9949 END IF;
9950 */
9951
9952 l_progress := '006';
9953
9954 IF l_parent_trx_id IS NULL THEN
9955 IF g_debug = 1 THEN
9956 print_debug('parent txn id cannot be null for a Return trx:'|| l_progress, 1);
9957 END IF;
9958 RAISE g_exc_unexpected_error;
9959 END IF;
9960
9961 ------------------Get previously received primary quantity for the Lot.
9962 OPEN Cr_rt_values(l_parent_trx_id) ;
9963 FETCH Cr_rt_values
9964 INTO l_pmy_rcv_qty,l_pmy_unit_of_meas;
9965 CLOSE Cr_rt_values;
9966
9967 l_progress := '007';
9968
9969 --getting lot trx qty in local var.
9970 l_lot_qty :=p_lot_quantity ;
9971
9972 ---If trx uom and previously received uom are diff
9973 IF l_pmy_unit_of_meas <> l_trx_unit_of_measure THEN
9974
9975 l_progress := '008';
9976
9977 /* Convert transaction qty in p_transaction_unit_of_measure to l_pmy_unit_of_meas */
9978
9979 l_lot_qty := INV_CONVERT.inv_um_convert(
9980 item_id => l_item_id ,
9981 lot_number => p_lot_number ,
9982 organization_id => l_to_organization_id ,
9983 precision => 5 ,
9984 from_quantity => l_lot_qty ,
9985 from_unit => NULL ,
9986 to_unit => NULL ,
9987 from_name => l_trx_unit_of_measure ,
9988 to_name => l_pmy_unit_of_meas
9989 );
9990 l_progress := '009';
9991
9992 IF l_lot_qty = -99999 THEN
9993 IF g_debug = 1 THEN
9994 print_debug('INV_CONVERT.inv_um_convert has failed '|| l_progress, 1);
9995 END IF;
9996
9997 FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR');
9998 FND_MESSAGE.SET_TOKEN('PGM_NAME','INV_CONVERT.inv_um_convert');
9999 fnd_msg_pub.ADD;
10000 RAISE g_exc_unexpected_error;
10001 END IF;
10002
10003 END IF; -----------IF l_pmy_unit_of_meas <> p_transaction_unit_of_measure
10004
10005 /* If the trx quantity = total received quantity for that parent deliver trx
10006 then even though lot indivisibily fails , we shall allow the "Return" trx
10007 */
10008
10009 ---if the return qty is equal to full delivered qty in parent trx
10010 IF l_lot_qty = l_pmy_rcv_qty THEN
10011
10012 l_progress := '010';
10013
10014 --overriding the false return status of lot indiv api
10015 l_return_status := FND_API.G_RET_STS_SUCCESS ;
10016
10017 IF g_debug = 1 THEN
10018 print_debug('l_return_status'|| l_return_status, 9);
10019 print_debug('set return status of validate_lot_indivisible to true'|| l_progress, 9);
10020 END IF;
10021 END IF; ----------IF (l_lot_qty = l_pmy_rcv_qty
10022
10023 END IF; -------- IF ((l_return_status <>...... AND p_transaction_type_id IN.......
10024
10025 l_progress := '011';
10026
10027 IF l_return_status = fnd_api.g_ret_sts_error THEN
10028 IF g_debug = 1 THEN
10029 print_debug('Program INV_LOT_API_PUB.validate_lot_indivisible has failed with a user defined exception '|| l_progress, 9);
10030 END IF;
10031
10032 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
10033 FND_MESSAGE.SET_TOKEN('PGM_NAME','INV_LOT_API_PUB.validate_lot_indivisible');
10034 fnd_msg_pub.ADD;
10035 RAISE g_exc_error;
10036
10037 ELSIF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
10038 l_progress := '012' ;
10039
10040 IF g_debug = 1 THEN
10041 print_debug('Program INV_LOT_API_PUB.validate_lot_indivisible has failed with a Unexpected exception' || l_progress, 9);
10042 END IF;
10043
10044 FND_MESSAGE.SET_NAME('INV','INV_PROGRAM_ERROR');
10045 FND_MESSAGE.SET_TOKEN('PGM_NAME','INV_LOT_API_PUB.validate_lot_indivisible');
10046 fnd_msg_pub.ADD;
10047 RAISE g_exc_unexpected_error;
10048 END IF;------------IF l_return_status = fnd_api.g_ret_sts_error THEN
10049
10050
10051 END IF;--------IF NOT (INV_LOT_API_PUB.validate_lot_indivisible(
10052
10053 l_progress := '013';
10054
10055 IF g_debug = 1 THEN
10056 print_debug('Program INV_LOT_API_PUB.validate_lot_indivisible return TRUE: ' || l_return_status || 'and '|| l_progress, 9);
10057 print_debug('Exitting inv_lot_api_pub.check_lot_indivisibility :'|| l_progress, 9);
10058 END IF;
10059
10060 ELSE ----------IF p_transaction_type_id IN
10061
10062 IF g_debug = 1 THEN
10063 print_debug('p_transaction_type_id:'|| p_transaction_type_id, 9);
10064 print_debug('lot indivisiblitity is not being checked for this trx type:'|| l_progress, 9);
10065 END IF;
10066
10067 END IF; ----------IF p_transaction_type_id IN
10068
10069
10070
10071 EXCEPTION
10072
10073 WHEN NO_DATA_FOUND THEN
10074 x_return_status := fnd_api.g_ret_sts_error;
10075
10076 fnd_msg_pub.count_and_get(
10077 p_encoded => fnd_api.g_false ,
10078 p_count => x_msg_count ,
10079 p_data => x_msg_data
10080 );
10081 IF( x_msg_count > 1 ) THEN
10082 x_msg_data := fnd_msg_pub.get(
10083 x_msg_count ,
10084 FND_API.G_FALSE
10085 );
10086 END IF ;
10087
10088
10089 IF g_debug = 1 THEN
10090 print_debug('Exitting CHECK_LOT_INDIVISIBILITY - No data found error:'||TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')||':'||l_progress, 1);
10091 -----print_stacked_messages;
10092 END IF;
10093
10094 WHEN g_exc_error THEN
10095
10096 x_return_status := fnd_api.g_ret_sts_error;
10097
10098 fnd_msg_pub.count_and_get(
10099 p_encoded => fnd_api.g_false ,
10100 p_count => x_msg_count ,
10101 p_data => x_msg_data
10102 );
10103
10104 IF( x_msg_count > 1 ) THEN
10105 x_msg_data := fnd_msg_pub.get(
10106 x_msg_count ,
10107 FND_API.G_FALSE
10108 );
10109 END IF;
10110
10111 IF g_debug = 1 THEN
10112 print_debug('Exitting CHECK_LOT_INDIVISIBILITY - g_exc_error error:'||TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')||':'||l_progress, 1);
10113 -----print_stacked_messages;
10114 END IF;
10115
10116
10117 WHEN g_exc_unexpected_error THEN
10118 x_return_status := fnd_api.g_ret_sts_unexp_error;
10119
10120 fnd_msg_pub.count_and_get(
10121 p_encoded => fnd_api.g_false ,
10122 p_count => x_msg_count ,
10123 p_data => x_msg_data
10124 );
10125 IF( x_msg_count > 1 ) THEN
10126 x_msg_data := fnd_msg_pub.get(
10127 x_msg_count ,
10128 FND_API.G_FALSE
10129 );
10130 END IF ;
10131
10132 IF g_debug = 1 THEN
10133 print_debug('Exitting CHECK_LOT_INDIVISIBILITY - g_exc_unexpected_error error:'||TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')||':'||l_progress, 1);
10134 --------print_stacked_messages;
10135 END IF;
10136
10137 WHEN OTHERS THEN
10138 x_return_status := fnd_api.g_ret_sts_unexp_error;
10139 fnd_msg_pub.count_and_get(
10140 p_encoded => fnd_api.g_false ,
10141 p_count => x_msg_count ,
10142 p_data => x_msg_data
10143 );
10144 IF( x_msg_count > 1 ) THEN
10145 x_msg_data := fnd_msg_pub.get(
10146 x_msg_count ,
10147 FND_API.G_FALSE);
10148 END IF;
10149
10150 IF g_debug = 1 THEN
10151 print_debug('Exitting CHECK_LOT_INDIVISIBILITY - In others error:'||TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:DD:SS')||':'||l_progress, 1);
10152 --------print_stacked_messages;
10153 END IF;
10154
10155
10156
10157 END CHECK_LOT_INDIVISIBILITY;
10158
10159
10160
10161 /*end , INVCONV , Punit Kumar*/
10162 -----------------------------------------------------------------------
10163 -- Name : validate_quantities
10164 -- Desc : This procedure is used to validate transaction quantity2
10165 -- if primary quantity/uom is not passed then they will be
10166 -- calculated and returned'
10167 -- if primary quantity is passed in, it will not be validated
10168 -- I/P Params :
10169 -- All the relevant transaction details :
10170 -- - organization id
10171 -- - item_id
10172 -- - lot, revision, subinventory
10173 -- - transaction quantities
10174 -- O/P Params :
10175 -- x_rerturn_status.
10176 -- RETURN VALUE :
10177 -- TRUE : IF the transaction is valid regarding Quantity2 and lot indivisible
10178 -- FALSE : IF the transaction is NOT valid regarding Quantity2 and lot indivisible
10179 --
10180 -----------------------------------------------------------------------
10181 FUNCTION validate_quantities(
10182 p_api_version IN NUMBER
10183 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
10184 , p_transaction_type_id IN NUMBER
10185 , p_organization_id IN NUMBER
10186 , p_inventory_item_id IN NUMBER
10187 , p_revision IN VARCHAR2
10188 , p_subinventory_code IN VARCHAR2
10189 , p_locator_id IN NUMBER
10190 , p_lot_number IN VARCHAR2
10191 , p_transaction_quantity IN OUT NOCOPY NUMBER
10192 , p_transaction_uom_code IN VARCHAR2
10193 , p_primary_quantity IN OUT NOCOPY NUMBER
10194 , p_primary_uom_code OUT NOCOPY VARCHAR2
10195 , p_secondary_quantity IN OUT NOCOPY NUMBER
10196 , p_secondary_uom_code IN OUT NOCOPY VARCHAR2
10197 , x_return_status OUT NOCOPY VARCHAR2
10198 , x_msg_count OUT NOCOPY NUMBER
10199 , x_msg_data OUT NOCOPY VARCHAR2)
10200 RETURN BOOLEAN
10201 IS
10202 l_api_name CONSTANT VARCHAR2(30) := 'validate_quantities';
10203 l_api_version CONSTANT NUMBER := 1.0;
10204 l_lot_divisible_flag VARCHAR2(1);
10205 l_tracking_quantity_ind VARCHAR2(30);
10206 l_secondary_default_ind VARCHAR2(30);
10207 l_secondary_uom_code VARCHAR2(3);
10208 l_secondary_qty NUMBER;
10209 l_transaction_quantity NUMBER;
10210 l_primary_quantity NUMBER;
10211 l_are_qties_valid NUMBER;
10212 l_error_message VARCHAR2(500);
10213 l_lot_indiv_trx_valid BOOLEAN;
10214 l_msg VARCHAR2(2000);
10215 l_msg_index_out NUMBER;
10216 l_debug NUMBER;
10217
10218 CURSOR get_item_details( org_id IN NUMBER
10219 , item_id IN NUMBER) IS
10220 SELECT lot_divisible_flag
10221 , tracking_quantity_ind
10222 , secondary_default_ind
10223 , secondary_uom_code
10224 , primary_uom_code
10225 FROM mtl_system_items
10226 WHERE organization_id = org_id
10227 AND inventory_item_id = item_id;
10228
10229 BEGIN
10230
10231 IF (l_debug is null) THEN
10232 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
10233 END IF;
10234
10235 IF (l_debug = 1) THEN
10236 inv_log_util.trace('validate_quantities: Start ', g_pkg_name, 9);
10237 END IF;
10238
10239 IF FND_API.TO_BOOLEAN(p_init_msg_list) THEN
10240 FND_MSG_PUB.Initialize;
10241 END IF;
10242
10243 -- Standard call to check for call compatibility.
10244 IF NOT FND_API.COMPATIBLE_API_CALL( l_api_version
10245 , p_api_version
10246 , l_api_name
10247 , G_PKG_NAME)
10248 THEN
10249 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10250 END IF;
10251
10252 /* =======================================================================
10253 Init variables
10254 ======================================================================= */
10255 x_return_status := FND_API.G_RET_STS_SUCCESS;
10256
10257 OPEN get_item_details( p_organization_id
10258 , p_inventory_item_id);
10259 FETCH get_item_details
10260 INTO l_lot_divisible_flag
10261 , l_tracking_quantity_ind
10262 , l_secondary_default_ind
10263 , l_secondary_uom_code
10264 , p_primary_uom_code;
10265
10266 IF (get_item_details%NOTFOUND)
10267 THEN
10268 CLOSE get_item_details;
10269 FND_MESSAGE.SET_NAME('INV','ITEM_NOT_FOUND');
10270 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID', p_organization_id);
10271 FND_MESSAGE.SET_TOKEN('INVENTORY_ITEM_ID', p_inventory_item_id);
10272 FND_MSG_PUB.ADD;
10273 RAISE FND_API.G_EXC_ERROR;
10274 END IF;
10275 CLOSE get_item_details;
10276
10277 --{
10278 IF (l_tracking_quantity_ind = 'P') THEN
10279 IF (p_secondary_quantity IS NOT NULL) THEN
10280 FND_MESSAGE.SET_NAME('INV','INV_SECONDARY_QTY_NOT_REQUIRED');
10281 FND_MSG_PUB.ADD;
10282 RAISE FND_API.G_EXC_ERROR;
10283 END IF;
10284
10285 IF (p_secondary_uom_code IS NOT NULL) THEN
10286 FND_MESSAGE.SET_NAME('INV','INV_SECONDARY_UOM_NOT_REQUIRED');
10287 FND_MSG_PUB.ADD;
10288 RAISE FND_API.G_EXC_ERROR;
10289 END IF;
10290
10291 ELSIF (l_tracking_quantity_ind = 'PS') THEN
10292 -- the item is DUOM controlled
10293 /** UOM Validation **/
10294 /** UOM Validation **/
10295 IF (p_secondary_uom_code <> l_secondary_uom_code) THEN
10296 FND_MESSAGE.SET_NAME('INV','INV_INCORRECT_SECONDARY_UOM');
10297 FND_MSG_PUB.ADD;
10298 RAISE FND_API.G_EXC_ERROR;
10299 END IF;
10300
10301 -- Set the default UOM2 if missing or incorrect:
10302 IF (p_secondary_uom_code IS NULL) THEN
10303 p_secondary_uom_code := l_secondary_uom_code;
10304 END IF;
10305
10306 /** Quantity Validation **/
10307 IF ((p_transaction_quantity IS NULL AND p_secondary_quantity IS NULL) OR
10308 (l_secondary_default_ind = 'N' AND (p_transaction_quantity IS NULL
10309 OR p_secondary_quantity IS NULL))) THEN
10310 IF (l_debug = 1) THEN
10311 inv_log_util.trace('validate_quantities: Missing both quantities or one qty for no default item ..', g_pkg_name, 9);
10312 END IF;
10313 FND_MESSAGE.SET_NAME('INV','INV_INT_QTYCODE');
10314 FND_MSG_PUB.ADD;
10315 RAISE FND_API.G_EXC_ERROR;
10316 END IF;
10317 --{
10318 IF (p_secondary_quantity IS NULL) THEN
10319 -- Set the Qty2 from Qty1 if missing:
10320 l_secondary_qty := INV_CONVERT.INV_UM_CONVERT
10321 ( item_id => p_inventory_item_id
10322 , lot_number => p_lot_number
10323 , organization_id => p_organization_id
10324 , precision => 5
10325 , from_quantity => p_transaction_quantity
10326 , from_unit => p_transaction_uom_code
10327 , to_unit => p_secondary_uom_code
10328 , from_name => NULL
10329 , to_name => NULL);
10330
10331 IF (l_secondary_qty = -99999) THEN
10332 IF (l_debug = 1) THEN
10333 inv_log_util.trace('validate_quantities: INV_CONVERT.INV_UM_CONVERT error ', g_pkg_name, 9);
10334 END IF;
10335 FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR');
10336 FND_MSG_PUB.ADD;
10337 RAISE FND_API.G_EXC_ERROR;
10338 END IF;
10339 p_secondary_quantity := l_secondary_qty;
10340 IF (l_debug = 1) THEN
10341 inv_log_util.trace('validate_quantities: new secondary qty is: '|| l_secondary_qty , g_pkg_name, 9);
10342 END IF;
10343 ELSIF (p_transaction_quantity IS NULL) THEN
10344 -- Set the Qty1 from Qty2 if missing:
10345 l_transaction_quantity := INV_CONVERT.INV_UM_CONVERT
10346 ( item_id => p_inventory_item_id
10347 , lot_number => p_lot_number
10348 , organization_id => p_organization_id
10349 , precision => 5
10350 , from_quantity => p_secondary_quantity
10351 , from_unit => p_secondary_uom_code
10352 , to_unit => p_transaction_uom_code
10353 , from_name => NULL
10354 , to_name => NULL);
10355
10356 IF (l_transaction_quantity = -99999) THEN
10357 IF (l_debug = 1) THEN
10358 inv_log_util.trace('validate_quantities: INV_CONVERT.INV_UM_CONVERT ERROR ', g_pkg_name, 9);
10359 END IF;
10360 FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR');
10361 FND_MSG_PUB.ADD;
10362 RAISE FND_API.G_EXC_ERROR;
10363 END IF;
10364 p_transaction_quantity := l_transaction_quantity;
10365 IF (l_debug = 1) THEN
10366 inv_log_util.trace('validate_quantities: new transaction qty is: '|| l_transaction_quantity , g_pkg_name, 9);
10367 END IF;
10368 ELSIF (p_transaction_quantity IS NOT NULL AND p_secondary_quantity IS NOT NULL) THEN
10369 IF (l_debug = 1) THEN
10370 inv_log_util.trace('validate_quantities: calling INV_CONVERT.WITHIN_DEVIATION', g_pkg_name, 9);
10371 END IF;
10372 -- Validate the quantitioes within deviation :
10373 l_are_qties_valid := INV_CONVERT.within_deviation(
10374 p_organization_id => p_organization_id
10375 , p_inventory_item_id => p_inventory_item_id
10376 , p_lot_number => p_lot_number
10377 , p_precision => 5
10378 , p_quantity => ABS(p_transaction_quantity)
10379 , p_uom_code1 => p_transaction_uom_code
10380 , p_quantity2 => ABS(p_secondary_quantity)
10381 , p_uom_code2 => p_secondary_uom_code);
10382
10383 IF (l_are_qties_valid = 0) THEN
10384 IF (l_debug = 1) THEN
10385 inv_log_util.trace('validate_quantities: INV_CONVERT.within_deviation (ERROR)' , g_pkg_name, 9);
10386 inv_log_util.trace('p_transaction_quantity: ' || p_transaction_quantity ||
10387 ' p_transaction_uom_code: ' || p_transaction_uom_code, g_pkg_name, 9);
10388 inv_log_util.trace(' p_secondary_quantity: ' || p_secondary_quantity ||
10389 ' p_secondary_uom_code: ' || p_secondary_uom_code, g_pkg_name, 9);
10390 inv_log_util.trace(' p_lot_number: ' || p_lot_number || ' p_inventory_item_id: '||
10391 p_inventory_item_id || ' p_organization_id: ' || p_organization_id, g_pkg_name, 9);
10392 END IF;
10393 RAISE FND_API.G_EXC_ERROR;
10394 END IF;
10395 IF (l_debug = 1) THEN
10396 inv_log_util.trace('validate_quantities: INV_CONVERT.within_deviation (PASS)' , g_pkg_name, 9);
10397 END IF;
10398 END IF;--}
10399 END IF;--} -- l_tracking_quantity_ind != 'P'
10400 -- Set the prim Qty from transaction Qty if missing:
10401 --{
10402 IF (p_primary_quantity IS NULL) THEN
10403 l_primary_quantity := INV_CONVERT.INV_UM_CONVERT
10404 ( item_id => p_inventory_item_id
10405 , lot_number => p_lot_number
10406 , organization_id => p_organization_id
10407 , precision => 5
10408 , from_quantity => p_transaction_quantity
10409 , from_unit => p_transaction_uom_code
10410 , to_unit => p_primary_uom_code
10411 , from_name => NULL
10412 , to_name => NULL);
10413
10414 IF (l_primary_quantity = -99999) THEN
10415 IF (l_debug = 1) THEN
10416 inv_log_util.trace('validate_quantities: INV_CONVERT.INV_UM_CONVERT error ', g_pkg_name, 9);
10417 END IF;
10418 FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR');
10419 FND_MSG_PUB.ADD;
10420 RAISE FND_API.G_EXC_ERROR;
10421 END IF;
10422 p_primary_quantity := l_primary_quantity;
10423 IF (l_debug = 1) THEN
10424 inv_log_util.trace('validate_quantities: new primary qty is: '|| l_primary_quantity , g_pkg_name, 9);
10425 END IF;
10426 END IF;--} -- primary_quantity check
10427
10428 -- Lot Indivisible Validation:
10429 --{
10430 IF (l_lot_divisible_flag = 'N') THEN
10431 l_lot_indiv_trx_valid := INV_LOT_API_PUB.VALIDATE_LOT_INDIVISIBLE
10432 ( p_api_version => p_api_version
10433 , p_init_msg_list => p_init_msg_list
10434 , p_transaction_type_id => p_transaction_type_id
10435 , p_organization_id => p_organization_id
10436 , p_inventory_item_id => p_inventory_item_id
10437 , p_revision => p_revision
10438 , p_subinventory_code => p_subinventory_code
10439 , p_locator_id => p_locator_id
10440 , p_lot_number => p_lot_number
10441 , p_primary_quantity => p_primary_quantity
10442 , p_qoh => NULL
10443 , p_atr => NULL
10444 , x_return_status => x_return_status
10445 , x_msg_count => x_msg_count
10446 , x_msg_data => x_msg_data);
10447
10448
10449 IF (NOT l_lot_indiv_trx_valid) THEN
10450 -- the transaction is not valid regarding lot indivisible:
10451 IF (l_debug = 1) THEN
10452 inv_log_util.trace('validate_quantities: INV_LOT_API_PUB.VALIDATE_LOT_INDIVISIBLE (ERROR)', g_pkg_name, 9);
10453 END IF;
10454 RAISE FND_API.G_EXC_ERROR;
10455 END IF;
10456 IF (l_debug = 1) THEN
10457 inv_log_util.trace('validate_quantities: INV_LOT_API_PUB.VALIDATE_LOT_INDIVISIBLE (PASS) ', g_pkg_name, 9);
10458 END IF;
10459
10460 END IF;--} -- l_lot_divisible_flag = 'N'
10461
10462 IF (l_debug = 1) THEN
10463 inv_log_util.trace('validate_quantities: End .... ', g_pkg_name, 9);
10464 END IF;
10465
10466 RETURN TRUE;
10467
10468 EXCEPTION
10469 WHEN FND_API.G_EXC_ERROR THEN
10470 x_return_status := FND_API.G_RET_STS_ERROR;
10471 IF (l_debug = 1) THEN
10472 inv_log_util.trace('validate_quantities: FND_API.G_EXC_ERROR ', g_pkg_name, 9);
10473 END IF;
10474 FND_MSG_PUB.Count_AND_GET (p_count => x_msg_count, p_data => x_msg_data);
10475 RETURN FALSE;
10476
10477 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10478 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10479 IF (l_debug = 1) THEN
10480 inv_log_util.trace('validate_quantities:when unexp sqlcode= '||sqlcode||' sqlerrm= '||substr(sqlerrm,1,240), g_pkg_name, 9);
10481 END IF;
10482 FND_MSG_PUB.Count_AND_GET (p_count => x_msg_count, p_data => x_msg_data);
10483 RETURN FALSE;
10484
10485 WHEN OTHERS THEN
10486 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10487 IF (l_debug = 1) THEN
10488 inv_log_util.trace('validate_quantities:when others sqlcode= '||sqlcode||' sqlerrm= '||substr(sqlerrm,1,240), g_pkg_name, 9);
10489 END IF;
10490 FND_MSG_PUB.Count_AND_GET (p_count => x_msg_count, p_data => x_msg_data);
10491 RETURN FALSE;
10492
10493 END validate_quantities;
10494
10495 END inv_lot_api_pub;
10496
10497