DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_POPULATE_TEMP

Source


1 PACKAGE BODY WIP_POPULATE_TEMP as
2 /* $Header: wiputmtb.pls 120.7.12010000.4 2010/02/16 20:15:04 hliew ship $ */
3 
4 PROCEDURE INSERT_TEMP
5 (p_transaction_mode IN NUMBER,
6  p_wip_entity_id IN NUMBER,
7  p_line_id IN NUMBER,
8  p_transaction_date IN DATE,
9  p_transaction_type_id IN NUMBER,
10  p_transaction_action_id IN NUMBER,
11  p_subinventory IN VARCHAR2,
12  p_locator_id IN NUMBER,
13  p_repetitive_days IN NUMBER,
14  p_assembly_quantity IN NUMBER,
15  p_operation_seq_num IN NUMBER,
16  p_department_id IN NUMBER,
17  p_criteria_sub IN VARCHAR2,
18  p_organization_id IN NUMBER,
19  p_acct_period_id IN NUMBER,
20  p_last_updated_by IN NUMBER,
21  p_entity_type IN NUMBER,
22  p_next_seq_num IN NUMBER,
23  p_calendar_code IN VARCHAR2,
24  p_exception_set_id IN NUMBER,
25  p_transaction_header_id IN NUMBER,
26  p_commit_counter OUT  NOCOPY NUMBER)
27 IS
28  x_transaction_source_type_id NUMBER;
29  x_transaction_source_id NUMBER;
30  x_item_segments VARCHAR2(2000);
31  x_locator_id NUMBER;
32  x_locator_control NUMBER;
33  x_locator_segments VARCHAR2(2000);
34  x_valid_locator_flag VARCHAR2(2);
35  x_valid_subinventory_flag VARCHAR2(2);
36  x_dummy BOOLEAN;
37  x_rev VARCHAR2(5) := NULL;
38  x_wip_commit_flag VARCHAR2(2);
39  i NUMBER := 0;
40  x_commit_counter NUMBER := 0;
41  x_released_revs_type 		NUMBER ;
42  x_released_revs_meaning 	Varchar2(30);
43  l_include_yield            NUMBER;  /* ER 4369064: Component Yield Enhancement */
44 
45 
46 CURSOR CDIS IS
47 --bug 7654664: rounding the transaction_quantity to inventory precision
48 SELECT	round(WIP_COMPONENT.Determine_Txn_Quantity
49                 (p_transaction_action_id,
50                  wro.quantity_per_assembly,
51                  wro.required_quantity,
52                  wro.quantity_issued,
53                  p_assembly_quantity,
54                  l_include_yield, /* ER 4369064: Component Yield Enhancement */
55                  nvl(wro.component_yield_factor, 1), /* Bug 8319533: component_yield_factor could be null
56 							for jobs created prior to R12 */
57                  wro.basis_type),wip_constants.inv_max_precision) transaction_quantity,  /* LBM Project */
58 	wro.inventory_item_id,
59 	msinv.secondary_inventory_name subinventory_code,
60 	wro.quantity_issued,
61 	wro.required_quantity,
62 	wro.quantity_per_assembly,
63 	bd.department_id,
64 	bd.department_code,
65 	wro.operation_seq_num,
66 	wro.wip_supply_type,
67 	wro.supply_subinventory,
68 	wro.supply_locator_id,
69 	msi.mtl_transactions_enabled_flag,
70 	msi.description,
71 	msi.location_control_code,
72 	msi.restrict_subinventories_code,
73 	msi.restrict_locators_code,
74 	msi.revision_qty_control_code,
75 	msi.primary_uom_code,
76 	mum.uom_class,
77 	msi.inventory_asset_flag,
78 	msi.allowed_units_lookup_code,
79 	msi.shelf_life_code,
80 	msi.shelf_life_days,
81 	/* decode(msi.serial_number_control_code,2,2,5,2,1) serial_control_code, */
82         decode(msi.serial_number_control_code,2,2,5,5,1) serial_control_code, /* Bug 2914137 */
83 	msi.lot_control_code,
84 	msinv.locator_type,
85 	msi.start_auto_lot_number,
86 	msi.auto_lot_alpha_prefix,
87 	msi.start_auto_serial_number,
88 	msi.auto_serial_alpha_prefix,
89 	mil.inventory_location_id,
90 	mil.disable_date locator_disable_date,
91 	mp.stock_locator_control_code,
92 	WIP_COMPONENT.Valid_Subinventory(msinv.secondary_inventory_name,
93 				     msi.inventory_item_id,
94 				     p_organization_id)
95 		valid_subinventory_flag,
96 	mil.project_id,
97 	mil.task_id,
98 	wdj.project_id source_project_id,
99 	wdj.task_id source_task_id,
100         msi.eam_item_type
101 FROM	mtl_parameters mp,
102 	mtl_item_locations mil,
103 	mtl_secondary_inventories msinv,
104 	mtl_units_of_measure mum,
105 	bom_departments bd,
106 	mtl_system_items msi,
107 	wip_discrete_jobs wdj,
108 	wip_requirement_operations wro
109 WHERE   wro.wip_entity_id = p_wip_entity_id
110 AND	wro.organization_id = p_organization_id
111 AND	WIP_COMPONENT.is_valid(
112 		p_transaction_action_id,
113 		wro.wip_supply_type,
114 		wro.required_quantity,
115 		wro.quantity_issued,
116 		p_assembly_quantity,
117 		p_entity_type) = WIP_CONSTANTS.YES
118 AND	WIP_COMPONENT.meets_criteria(
119 		wro.operation_seq_num,
120 		p_operation_seq_num,
121 		wro.department_id,
122 		p_department_id,
123 		wro.supply_subinventory,
124 		p_criteria_sub) = WIP_CONSTANTS.YES
125 AND     wdj.wip_entity_id = wro.wip_entity_id
126 AND	wdj.organization_id = wro.organization_id
127 AND	bd.department_id(+) = wro.department_id
128 AND	bd.organization_id(+) = wro.organization_id
129 AND	msi.inventory_item_id = wro.inventory_item_id
130 AND	msi.organization_id = wro.organization_id
131 AND	mum.uom_code = msi.primary_uom_code
132 AND	msinv.organization_id(+) = wro.organization_id
133 AND	msinv.secondary_inventory_name(+) =
134 		decode(p_transaction_action_id,
135 			WIP_CONSTANTS.SUBTRFR_ACTION, p_subinventory,
136 			NVL(wro.supply_subinventory, p_subinventory))
137 AND	mil.organization_id(+) = wro.organization_id
138 AND	mil.inventory_location_id(+) =
139 		decode(p_transaction_action_id,
140 			WIP_CONSTANTS.SUBTRFR_ACTION, p_locator_id,
141 			NVL(wro.supply_locator_id, p_locator_id))
142 AND	mp.organization_id = wro.organization_id
143 ORDER BY
144 wro.operation_seq_num;
145 
146 CURSOR CREP IS
147 SELECT
148 	wro.inventory_item_id,
149 	msinv.secondary_inventory_name subinventory_code,
150 	sum(wro.quantity_issued) quantity_issued,
151 	sum(wro.required_quantity) required_quantity,
152 	sum(wro.quantity_per_assembly) quantity_per_assembly,
153 	bd.department_id,
154 	bd.department_code,
155 	wro.operation_seq_num,
156 	wro.wip_supply_type,
157 	wro.supply_subinventory,
158 	wro.supply_locator_id,
159 	msi.mtl_transactions_enabled_flag,
160 	msi.description,
161 	msi.location_control_code,
162 	msi.restrict_subinventories_code,
163 	msi.restrict_locators_code,
164 	msi.revision_qty_control_code,
165 	msi.primary_uom_code,
166 	mum.uom_class,
167 	msi.inventory_asset_flag,
168 	msi.allowed_units_lookup_code,
169 	msi.shelf_life_code,
170 	msi.shelf_life_days,
171 	decode(msi.serial_number_control_code,2,2,5,5,1) serial_control_code, /* Bug 2914137 */
172 	msi.lot_control_code,
173 	msinv.locator_type,
174 	msi.start_auto_lot_number,
175 	msi.auto_lot_alpha_prefix,
176 	msi.start_auto_serial_number,
177 	msi.auto_serial_alpha_prefix,
178 	mil.inventory_location_id,
179 	mil.disable_date locator_disable_date,
180 	mp.stock_locator_control_code,
181 --bug 7654664: rounding the transaction_quantity to inventory precision
182 	round(SUM((LEAST(bcd1.next_seq_num+wrs.processing_work_days,
183 		   p_next_seq_num + p_repetitive_days) -
184 	     GREATEST(bcd1.next_seq_num, p_next_seq_num)) *
185 	     wro.quantity_per_assembly * wrs.daily_production_rate *
186 	     decode(p_transaction_action_id, 1, -1, 2, -1, 33, -1, 1)/
187          decode(l_include_yield,2,1,nvl(wro.component_yield_factor,1))),
188 	 wip_constants.inv_max_precision) transaction_quantity /* ER 4369064: Component Yield Enhancement */
189 FROM	mtl_parameters mp,
190 	mtl_item_locations mil,
191 	mtl_secondary_inventories msinv,
192 	mtl_units_of_measure mum,
193 	bom_departments bd,
194 	mtl_system_items msi,
195 	bom_calendar_dates bcd1,
196 	wip_requirement_operations wro,
197 	wip_repetitive_schedules wrs
198 WHERE   wro.wip_entity_id = wrs.wip_entity_id
199 AND	wro.organization_id = wrs.organization_id
200 AND	wro.repetitive_schedule_id = wrs.repetitive_schedule_id
201 AND	wrs.wip_entity_id = p_wip_entity_id
202 AND	wrs.organization_id = p_organization_id
203 AND	wrs.line_id = p_line_id
204 AND	bcd1.calendar_code(+) = p_calendar_code
205 AND	bcd1.exception_set_id(+) = p_exception_set_id
206 --bug 5470386 truncating the time factor from both the date fields as
207 -- calendar date doesnot have the time factor but date required field includes the time factor
208 --and therefore repetitive schedule is not defaulting
209 --AND     bcd1.calendar_date(+) = trunc(wro.date_required)
210 AND	trunc(bcd1.calendar_date(+)) = trunc(wro.date_required)
211 AND	bcd1.next_seq_num(+) < p_next_seq_num + p_repetitive_days
212 AND	bcd1.next_seq_num + wrs.processing_work_days > p_next_seq_num
213 AND	WIP_COMPONENT.is_valid(
214 		p_transaction_action_id,
215 		wro.wip_supply_type,
216 		wro.required_quantity,
217 		wro.quantity_issued,
218 		NULL,
219 		p_entity_type) = WIP_CONSTANTS.YES
220 AND	WIP_COMPONENT.meets_criteria(
221 		wro.operation_seq_num,
222 		p_operation_seq_num,
223 		wro.department_id,
224 		p_department_id,
225 		wro.supply_subinventory,
226 		p_criteria_sub) = WIP_CONSTANTS.YES
227 AND	bd.department_id(+) = wro.department_id
228 AND	bd.organization_id(+) = wro.organization_id
229 AND	msi.inventory_item_id = wro.inventory_item_id
230 AND	msi.organization_id = wro.organization_id
231 AND	mum.uom_code = msi.primary_uom_code
232 AND	msinv.organization_id(+) = wro.organization_id
233 AND	msinv.secondary_inventory_name(+) =
234 		decode(p_transaction_action_id,
235 			WIP_CONSTANTS.SUBTRFR_ACTION, p_subinventory,
236 			NVL(wro.supply_subinventory, p_subinventory))
237 AND	mil.organization_id(+) = wro.organization_id
238 AND	mil.inventory_location_id(+) =
239 		decode(p_transaction_action_id,
240 			WIP_CONSTANTS.SUBTRFR_ACTION, p_locator_id,
241 			NVL(wro.supply_locator_id, p_locator_id))
242 AND	mp.organization_id = wro.organization_id
243 /* Fix for bug 2570492 Adding filtering by status_type */
244 AND     status_type in (WIP_CONSTANTS.RELEASED, WIP_CONSTANTS.COMP_CHRG)
245 GROUP BY
246         wro.inventory_item_id,
247         msinv.secondary_inventory_name,
248         bd.department_id,
249         bd.department_code,
250         wro.operation_seq_num,
251         wro.wip_supply_type,
252         wro.supply_subinventory,
253         wro.supply_locator_id,
254         msi.mtl_transactions_enabled_flag,
255         msi.description,
256         msi.location_control_code,
257         msi.restrict_subinventories_code,
258         msi.restrict_locators_code,
259         msi.revision_qty_control_code,
260         msi.primary_uom_code,
261         mum.uom_class,
262         msi.inventory_asset_flag,
263         msi.allowed_units_lookup_code,
264         msi.shelf_life_code,
265         msi.shelf_life_days,
266         decode(msi.serial_number_control_code,2,2,5,5,1), /* Bug 2914137 */
267         msi.lot_control_code,
268         msinv.locator_type,
269         msi.start_auto_lot_number,
270         msi.auto_lot_alpha_prefix,
271         msi.start_auto_serial_number,
272         msi.auto_serial_alpha_prefix,
273         mil.inventory_location_id,
274         mil.disable_date,
275         mp.stock_locator_control_code
276 ORDER BY
277 wro.operation_seq_num,
278 wro.supply_subinventory
279 ;
280 
281 BEGIN
282         x_wip_commit_flag := 'Y';
283 
284 	X_COMMIT_COUNTER := 0;
285 
286 	/* Source Type and Source are set differently for Subinventory Replen */
287 
288 	IF p_transaction_action_id = WIP_CONSTANTS.SUBTRFR_ACTION THEN
289 	/*Start: Bug 6460181: Instead of a constant value for x_transaction_source_type_id, the value is selected from mtl_transaction_type table*/
290 
291 		SELECT transaction_source_type_id
292 		into x_transaction_source_type_id
293 		from mtl_transaction_types where transaction_type_id = p_transaction_type_id ;
294 		--x_transaction_source_type_id := 13;
295 		x_transaction_source_id := NULL;
296 	ELSE
297 		x_transaction_source_type_id := 5;
298 		x_transaction_source_id := p_wip_entity_id;
299 	END IF;
300 
301     /* ER 4369064: Component Yield Enhancement */
302     select nvl(include_component_yield,1) /* Handled Null value */
303       into l_include_yield
304       from wip_parameters
305      where organization_id = p_organization_id;
306 
307           --  set up release type
308           /* 2999230 */
309           wip_common.Get_Released_Revs_Type_Meaning (x_released_revs_type,
310                                                      x_released_revs_meaning
311                                                     );
312 
313         --6 is eAM job
314 	IF p_entity_type in (WIP_CONSTANTS.DISCRETE,WIP_CONSTANTS.LOTBASED,6) THEN
315  	    FOR C IN CDIS LOOP
316 
317 		x_dummy := FND_FLEX_KEYVAL.validate_ccid(
318 				appl_short_name => 'INV',
319 				key_flex_code => 'MSTK',
320 				structure_number => 101,
321 				combination_id => C.inventory_item_id,
322 				data_set => p_organization_id);
323 
324 		x_item_segments := FND_FLEX_KEYVAL.concatenated_values;
325 
326 		x_locator_id := C.inventory_location_id;
327                /* Fix for Bug# 2149033. Added x_locator_id condition in if condition */
328                 IF(C.subinventory_code IS NOT NULL) and (x_locator_id IS NOT NULL)  THEN
329 			x_valid_locator_flag := WIP_COMPONENT.Valid_Locator
330 			(x_locator_id,
331 			 C.inventory_item_id,
332 			 p_organization_id,
333 			 C.stock_locator_control_code,
334 			 C.locator_type,
335 			 C.location_control_code,
336 			 C.restrict_locators_code,
337 			 C.locator_disable_date,
338 			 x_locator_control);
339 
340 			IF x_locator_control = 1 THEN
341 				x_locator_segments := NULL;
342 			ELSE
343 
344 				x_dummy := FND_FLEX_KEYVAL.validate_ccid(
345 					appl_short_name => 'INV',
346 					key_flex_code => 'MTLL',
347 					structure_number => 101,
348 					combination_id => x_locator_id,
349 					data_set => p_organization_id);
350 
351                                 -- fix for bug 4084598
352 				--x_locator_segments := FND_FLEX_KEYVAL.concatenated_values;
353 			END IF;
354 		ELSE
355 			x_valid_locator_flag := 'N';
356 			x_locator_id := null; --no locator when sub is not populated
357 			x_locator_segments := NULL;
358 		END IF;
359 
360 		IF C.revision_qty_control_code = WIP_CONSTANTS.REV THEN
361 			BOM_REVISIONS.Get_Revision
362 			(type => 'PART',
363 			 eco_status => x_released_revs_meaning,
364 			 examine_type => 'ALL',
365 			 org_id => P_Organization_Id,
366 			 item_id => C.inventory_item_id,
367 			 rev_date => p_transaction_date,
368 			 itm_rev => x_rev);
369                 ELSE
370                        x_rev := NULL;
371 		END IF;
372 
373 		IF C.mtl_transactions_enabled_flag = 'N'
374 		   OR (C.valid_subinventory_flag = 'N')
375 		   OR (x_valid_locator_flag = 'N')
376 		   OR (C.lot_control_code <> 1
377 			AND C.transaction_quantity <> 0)
378 		   OR (C.serial_control_code <> 1
379 			AND C.transaction_quantity <> 0)
380 		   OR (C.lot_control_code <> 1
381 			AND C.serial_control_code <> 1)
382 		   OR (C.transaction_quantity = 0
383 			AND p_assembly_quantity IS NOT NULL
384 			AND p_transaction_action_id IN
385 				(WIP_CONSTANTS.RETNEGC_ACTION,
386 				 WIP_CONSTANTS.RETCOMP_ACTION)) THEN
387 			x_wip_commit_flag := 'N';
388 			X_COMMIT_COUNTER := X_COMMIT_COUNTER + 1;
389 		ELSE
390 			x_wip_commit_flag := 'Y';
391 		END IF;
392 
393                 -- bug3430508: do not insert subinv/loc if material status
394                 --             disables it
395                 if (inv_material_status_grp.is_status_applicable(
396                            NULL, -- p_wms_installed,
397                            NULL,
398                            p_transaction_type_id, -- p_trx_type_id (is this same as trx_type_id?)
399                            NULL,
400                            NULL,
401                            p_organization_id,
402                            C.inventory_item_id,
403                            C.subinventory_code,
404                            NULL,
405                            NULL,
406                            NULL,
407                            'Z') = 'N') then
408                                   C.subinventory_code := null;
409                                   x_locator_id := null;
410                 end if;
411 
412                 if (inv_material_status_grp.is_status_applicable(
413                            NULL, -- p_wms_installed,
414                            NULL,
415                            p_transaction_type_id, -- p_trx_type_id (is this same as trx_type_id?)
416                            NULL,
417                            NULL,
418                            p_organization_id,
419                            C.inventory_item_id,
420                            NULL,
421                            x_locator_id,
422                            NULL,
423                            NULL,
424                            'L') = 'N') then
425                                   x_locator_id := null;
426                 end if;
427 
428                 INSERT INTO mtl_material_transactions_temp
429                     (item_segments,
430                      locator_segments,
431                      primary_switch,
432                      transaction_header_id,
433                      transaction_mode,
434                      lock_flag,
435                      inventory_item_id,
436                      subinventory_code,
437                      primary_quantity,
438                      transaction_quantity,
439                      transaction_date,
440                      organization_id,
441                      acct_period_id,
442                      last_update_date,
443                      last_updated_by,
444                      creation_date,
445                      created_by,
446                      transaction_source_id,
447                      transaction_source_type_id,
448                      transaction_type_id,
449                      transaction_action_id,
450                      wip_entity_type,
451                      repetitive_line_id,
452                      department_id,
453                      department_code,
454                      locator_id,
455                      required_flag,
456                      operation_seq_num,
457                      transfer_subinventory,
458                      transfer_to_location,
459                      wip_supply_type,
460                      supply_subinventory,
461                      supply_locator_id,
462                      item_trx_enabled_flag,
463                      item_description,
464                      item_location_control_code,
465                      item_restrict_subinv_code,
466                      item_restrict_locators_code,
467                      item_revision_qty_control_code,
468                      revision,
469                      item_primary_uom_code,
470                      transaction_uom,
471                      item_uom_class,
472                      item_inventory_asset_flag,
473                      allowed_units_lookup_code,
474                      item_shelf_life_code,
475                      item_shelf_life_days,
476                      item_serial_control_code,
477                      item_lot_control_code,
478                      current_locator_control_code,
479                      wip_commit_flag,
480                      number_of_lots_entered,
481                      next_lot_number,
482                      next_serial_number,
483                      lot_alpha_prefix,
484                      serial_alpha_prefix,
485                      valid_subinventory_flag,
486                      valid_locator_flag,
487                      negative_req_flag,
488                      posting_flag,
489                      process_flag,
490 		     project_id,
491 		     task_id,
492 		     source_project_id,
493 		     source_task_id)
494 		VALUES
495                     (x_item_segments,
496                      x_locator_segments,
497                      i,
498                      p_transaction_header_id,
499                      decode(p_transaction_mode,2,2,1),
500                      'N',
501                      C.inventory_item_id,
502                      C.subinventory_code,
503                      /*Fix for bug 9371748*/
504                      decode(C.eam_item_type, WIP_CONSTANTS.REBUILD_ITEM_TYPE, decode(p_entity_type,WIP_CONSTANTS.EAM,1,C.transaction_quantity), C.transaction_quantity),
505                      decode(C.eam_item_type, WIP_CONSTANTS.REBUILD_ITEM_TYPE, decode(p_entity_type,WIP_CONSTANTS.EAM,1,C.transaction_quantity), C.transaction_quantity),
506                      p_transaction_date,
507                      p_organization_id,
508                      p_acct_period_id,
509                      SYSDATE,
510                      p_last_updated_by,
511                      SYSDATE,
512                      p_last_updated_by,
513                      x_transaction_source_id,
514                      x_transaction_source_type_id,
515                      p_transaction_type_id,
516                      p_transaction_action_id,
517                      p_entity_type,
518                      p_line_id,
519                      C.department_id,
520                      C.department_code,
521                      x_locator_id,
522                      1,
523                      C.operation_seq_num,
524                      DECODE(    p_transaction_action_id,
525                                 2,C.supply_subinventory,
526                                 NULL),
527                      DECODE(    p_transaction_action_id,
528                                 2,C.supply_locator_id,
529                                 NULL),
530                      C.wip_supply_type,
531                      C.supply_subinventory,
532                      C.supply_locator_id,
533                      C.mtl_transactions_enabled_flag,
534                      C.description,
535                      C.location_control_code,
536                      C.restrict_subinventories_code,
537                      C.restrict_locators_code,
538                      C.revision_qty_control_code,
539                      x_rev,
540                      C.primary_uom_code,
541                      C.primary_uom_code,
542                      C.uom_class,
543                      C.inventory_asset_flag,
544                      C.allowed_units_lookup_code,
545                      C.shelf_life_code,
546                      C.shelf_life_days,
547                      C.serial_control_code,
548                      C.lot_control_code,
549                      C.locator_type,
550                      x_wip_commit_flag,
551                      0,
552                      C.start_auto_lot_number,
553                      C.start_auto_serial_number,
554                      C.auto_lot_alpha_prefix,
555                      C.auto_serial_alpha_prefix,
556                      C.valid_subinventory_flag,
557                      x_valid_locator_flag,
558                      sign(C.required_quantity),
559                      'Y',
560                      'Y',
561 		     C.project_id,
562 		     C.task_id,
563 		     C.source_project_id,
564 		     C.source_task_id);
565 
566 		i := i + 1;
567 
568 	    END LOOP;
569 
570 	ELSE
571 
572  	    FOR C IN CREP LOOP
573 
574 		x_dummy := FND_FLEX_KEYVAL.validate_ccid(
575 				appl_short_name => 'INV',
576 				key_flex_code => 'MSTK',
577 				structure_number => 101,
578 				combination_id => C.inventory_item_id,
579 				data_set => p_organization_id);
580 
581 		x_item_segments := FND_FLEX_KEYVAL.concatenated_values;
582                 IF(C.subinventory_code IS NULL) THEN
583 			x_valid_subinventory_flag := 'N';
584 			x_valid_locator_flag := 'N';
585 		ELSE
586 			x_valid_subinventory_flag := WIP_COMPONENT.Valid_Subinventory
587 				(C.subinventory_code,
588 				 C.inventory_item_id,
589 				 p_organization_id);
590 
591 			x_locator_id := C.inventory_location_id;
592 
593 			x_valid_locator_flag := WIP_COMPONENT.Valid_Locator
594 			(x_locator_id,
595 			 C.inventory_item_id,
596 			 p_organization_id,
597 			 C.stock_locator_control_code,
598 			 C.locator_type,
599 			 C.location_control_code,
600 			 C.restrict_locators_code,
601 			 C.locator_disable_date,
602 			 x_locator_control);
603 
604 			IF x_locator_control = 1 THEN
605 				x_locator_segments := NULL;
606 			ELSE
607 
608 				x_dummy := FND_FLEX_KEYVAL.validate_ccid(
609 					appl_short_name => 'INV',
610 					key_flex_code => 'MTLL',
611 					structure_number => 101,
612 					combination_id => x_locator_id,
613 					data_set => p_organization_id);
614 
615                                 -- fix for bug 4084598
616 				--x_locator_segments := FND_FLEX_KEYVAL.concatenated_values;
617 			END IF;
618 		END IF;
619 
620 		IF C.revision_qty_control_code = WIP_CONSTANTS.REV THEN
621 			BOM_REVISIONS.Get_Revision
622 			(type => 'PART',
623 			 eco_status => x_released_revs_meaning,
624 			 examine_type => 'ALL',
625 			 org_id => P_Organization_Id,
626 			 item_id => C.inventory_item_id,
627 			 rev_date => p_transaction_date,
628 			 itm_rev => x_rev);
629                 ELSE
630                      x_rev := NULL;
631 		END IF;
632 
633 		IF C.mtl_transactions_enabled_flag = 'N'
634 		   OR (x_valid_subinventory_flag = 'N')
635 		   OR (x_valid_locator_flag = 'N')
636 		   OR (C.lot_control_code <> 1
637 			AND C.transaction_quantity <> 0)
638 		   OR (C.serial_control_code <> 1
639 			AND C.transaction_quantity <> 0)
640 		   OR (C.lot_control_code <> 1
641 			AND C.serial_control_code <> 1)
642 		   OR (C.transaction_quantity = 0
643 			AND p_assembly_quantity IS NOT NULL
644 			AND p_transaction_action_id IN
645 				(WIP_CONSTANTS.RETNEGC_ACTION,
646 				 WIP_CONSTANTS.RETCOMP_ACTION)) THEN
647 			x_wip_commit_flag := 'N';
648 			X_COMMIT_COUNTER := X_COMMIT_COUNTER + 1;
649 		ELSE
650 			x_wip_commit_flag := 'Y';
651 		END IF;
652 
653                 INSERT INTO mtl_material_transactions_temp
654                     (item_segments,
655                      locator_segments,
656                      primary_switch,
657                      transaction_header_id,
658                      transaction_mode,
659                      lock_flag,
660                      inventory_item_id,
661                      subinventory_code,
662                      primary_quantity,
663                      transaction_quantity,
664                      transaction_date,
665                      organization_id,
666                      acct_period_id,
667                      last_update_date,
668                      last_updated_by,
669                      creation_date,
670                      created_by,
671                      transaction_source_id,
672                      transaction_source_type_id,
673                      transaction_type_id,
674                      transaction_action_id,
675                      wip_entity_type,
676                      repetitive_line_id,
677                      department_id,
678                      department_code,
679                      locator_id,
680                      required_flag,
681                      operation_seq_num,
682                      transfer_subinventory,
683                      transfer_to_location,
684                      wip_supply_type,
685                      supply_subinventory,
686                      supply_locator_id,
687                      item_trx_enabled_flag,
688                      item_description,
689                      item_location_control_code,
690                      item_restrict_subinv_code,
691                      item_restrict_locators_code,
692                      item_revision_qty_control_code,
693                      revision,
694                      item_primary_uom_code,
695                      transaction_uom,
696                      item_uom_class,
697                      item_inventory_asset_flag,
698                      allowed_units_lookup_code,
699                      item_shelf_life_code,
700                      item_shelf_life_days,
701                      item_serial_control_code,
702                      item_lot_control_code,
703                      current_locator_control_code,
704                      wip_commit_flag,
705                      number_of_lots_entered,
706                      next_lot_number,
707                      next_serial_number,
708                      lot_alpha_prefix,
709                      serial_alpha_prefix,
710                      valid_subinventory_flag,
711                      valid_locator_flag,
712                      negative_req_flag,
713                      posting_flag,
714                      process_flag)
715 		VALUES
716                     (x_item_segments,
717                      x_locator_segments,
718                      i,
719                      p_transaction_header_id,
720                      decode(p_transaction_mode,2,2,1),
721                      'N',
722                      C.inventory_item_id,
723                      C.subinventory_code,
724                      C.transaction_quantity,
725                      C.transaction_quantity,
726                      p_transaction_date,
727                      p_organization_id,
728                      p_acct_period_id,
729                      SYSDATE,
730                      p_last_updated_by,
731                      SYSDATE,
732                      p_last_updated_by,
733                      x_transaction_source_id,
734                      x_transaction_source_type_id,
735                      p_transaction_type_id,
736                      p_transaction_action_id,
737                      p_entity_type,
738                      p_line_id,
739                      C.department_id,
740                      C.department_code,
741                      x_locator_id,
742                      1,				/* Required_Flag */
743                      C.operation_seq_num,
744                      DECODE(	p_transaction_action_id,
745 				2,C.supply_subinventory,
746 				NULL),
747                      DECODE(	p_transaction_action_id,
748 				2,C.supply_locator_id,
749 				NULL),
750                      C.wip_supply_type,
751                      C.supply_subinventory,
752                      C.supply_locator_id,
753                      C.mtl_transactions_enabled_flag,
754                      C.description,
755                      C.location_control_code,
756                      C.restrict_subinventories_code,
757                      C.restrict_locators_code,
758                      C.revision_qty_control_code,
759                      x_rev,
760                      C.primary_uom_code,
761                      C.primary_uom_code,
762                      C.uom_class,
763                      C.inventory_asset_flag,
764                      C.allowed_units_lookup_code,
765                      C.shelf_life_code,
766                      C.shelf_life_days,
767                      C.serial_control_code,
768                      C.lot_control_code,
769                      C.locator_type,
770                      x_wip_commit_flag,
771                      0,				/* Num Lots Entered */
772                      C.start_auto_lot_number,
773                      C.start_auto_serial_number,
774                      C.auto_lot_alpha_prefix,
775                      C.auto_serial_alpha_prefix,
776                      x_valid_subinventory_flag,
777                      x_valid_locator_flag,
778                      sign(C.required_quantity),
779                      'Y',
780                      'Y');
781 
782 		i := i + 1;
783 
784 	    END LOOP;
785 
786 	END IF;
787 
788 	P_COMMIT_COUNTER := X_COMMIT_COUNTER;
789 
790 END INSERT_TEMP;
791 
792 END WIP_POPULATE_TEMP;