[Home] [Help]
PACKAGE BODY: APPS.BOM_VALIDATE_BOM_COMPONENT
Source
1 PACKAGE BODY BOM_Validate_Bom_Component AS
2 /* $Header: BOMLCMPB.pls 120.43.12010000.3 2008/10/03 12:58:58 naaddepa ship $ */
3 /*************************************************************************
4 --
5 -- Copyright (c) 1996 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- BOMLCMPB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package BOM_Validate_Bom_Component
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 11-JUN-99 Rahul Chitko Initial Creation
21 --
22 -- 08-MAY-2001 Refai Farook EAM related changes
23 --
24 -- 30-AUG-01 Refai Farook One To Many support changes
25 --
26 -- 25-SEP-01 Refai Farook Added new function (Check_Unit_Number) and changes to the Check_Entity
27 -- procedure. (Mass changes for unit effectivity changes)
28 --
29 -- 15-NOV-02 Anirban Dey Added support for Auto_Request_Material in 11.5.9
30 --
31 -- 06-May-05 Abhishek Rudresh Common BOM Attrs update
32
33 -- 20-Jun-05 Vani Hymavathi Validations for to OPM convergence project
34 **************************************************************************/
35
36 G_PKG_NAME VARCHAR2(30) :=
37 'BOM_Validate_Bom_Component';
38
39 l_dummy VARCHAR2(80);
40 /*
41 l_MODEL CONSTANT NUMBER := 1;
42 l_OPTION_CLASS CONSTANT NUMBER := 2;
43 l_PLANNING CONSTANT NUMBER := 3;
44 l_STANDARD CONSTANT NUMBER := 4;
45 l_PRODUCT_FAMILY CONSTANT NUMBER := 5;
46 */
47 l_Sub_Locator_Control NUMBER;
48 l_locator_control NUMBER;
49 l_org_locator_control NUMBER;
50 l_item_locator_control NUMBER;
51 l_item_loc_restricted NUMBER; -- 1,Locator is Restricted,else 2
52
53 g_Comp_Item_Type NUMBER; -- Bom_Item_Type of Component
54 g_Assy_Item_Type NUMBER; -- Bom_Item_Type of Assembly
55 g_Comp_ATO_flag CHAR; -- ATO flag for Component
56 g_Assy_ATO_flag CHAR; -- ATO flag for Assembly
57 g_Comp_PTO_flag CHAR; -- PTO flag for Component
58 g_Assy_PTO_flag CHAR; -- PTO flag for Assembly
59 g_Comp_Config CHAR; -- Is component a config item
60 g_Comp_ATO_Forecast_Control NUMBER; -- Component items ATO Frcst Ctrl
61 g_Assy_Config CHAR; -- Is assembly a config item
62 g_Comp_Eng_Flag CHAR; -- Is component an Engineering Item
63 g_Assy_Eng_Flag CHAR; -- Is assembly an Engineering Item
64 g_Comp_ATP_Comp_flag CHAR; -- Components ATP Component Flag
65 g_Assy_ATP_Comp_flag CHAR; -- Assembly's ATP Component flag
66 g_Comp_ATP_Check_flag CHAR; -- Components ATP check flag
67 g_Assy_ATP_Check_flag CHAR; -- Assembly's ATP check flag
68 g_Assy_Wip_supply_Type NUMBER; -- Assembly 's wip supply type
69 g_Comp_Wip_Supply_Type NUMBER; -- Components WIP Supply Type
70 g_Assy_Bom_Enabled_flag CHAR; -- Assembly's bom_enabled_flag
71 g_Comp_Bom_Enabled_flag CHAR; -- Component's bom_enabled_flag
72 g_Assy_Effectivity_Control NUMBER; --2044133
73 g_Comp_Effectivity_Control NUMBER; --2044133
74 g_Comp_Tracking_Quantity_Ind VARCHAR2(30);
75 g_Assy_Tracking_Quantity_Ind VARCHAR2(30);
76 g_Assy_Assembly_Type NUMBER; --4161794
77
78 g_rev_component_rec Bom_bo_Pub.Rev_Component_Rec_Type;
79 g_Rev_Comp_Unexp_Rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
80 g_Token_Tbl Error_Handler.Token_Tbl_Type;
81
82 FUNCTION Item_Revision_Exists (p_item_id IN NUMBER,
83 p_org_id IN NUMBER,
84 p_eff_dt IN DATE)
85 RETURN BOOLEAN
86 IS
87 CURSOR c1 IS
88 SELECT REVISION
89 FROM MTL_ITEM_REVISIONS_B MIR
90 WHERE INVENTORY_ITEM_ID = p_item_id
91 AND ORGANIZATION_ID = p_org_id
92 AND MIR.EFFECTIVITY_DATE <= p_eff_dt;
93 BEGIN
94 Error_Handler.Write_Debug('In Item Check Revisio' );
95 Error_Handler.Write_Debug('Item id '||to_char(p_item_id));
96 Error_Handler.Write_Debug('Org id '||to_char(p_org_id));
97 Error_Handler.Write_Debug('Eff Dt '||to_char(p_eff_dt));
98 FOR r1 IN c1
99 LOOP
100 Error_Handler.Write_Debug('In loop');
101 Return TRUE;
102 END LOOP;
103 Error_Handler.Write_Debug('Returning False' );
104 Return FALSE;
105 END;
106
107
108 /*******************************************************************
109 * PROCEDURE : Check_Component_Type_Rule
110 * Parameters IN : p_parent_item_id parent item id
111 * p_child_item_id child item id
112 * p_organization_id org id.
113 * p_init_msg_list Default value is TRUE.By default
114 * the error handler is initialized.If the caller does not
115 * want the error handler to get initialized, the caller
116 * has to pass FALSE.
117 * Parameters OUT: x_return_status is FND_API.G_RET_STS_SUCCESS or
118 * FND_API.G_RET_STS_ERROR
119 * x_error_message The error message passed to the
120 caller
121 * Purpose : This procedure will actually check if any component
122 * type rule exists between the two item types of the item
123 * which are to be associated.If such any component type
124 * rule exists then the procedure checks if these items
125 * can be associated according to the rule.If not the
126 * procedure returns the error staus and error message.
127 * If the items can be associated then it returns success.
128 *******************************************************************/
129
130 PROCEDURE Check_Component_Type_Rule(
131 x_return_status IN OUT NOCOPY VARCHAR2
132 , x_error_message IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2
133 , p_init_msg_list IN BOOLEAN := TRUE
134 , p_parent_item_id IN NUMBER
135 , p_child_item_id IN NUMBER
136 , p_organization_id IN NUMBER
137 )
138 IS
139 l_customization_code AK_CUSTOMIZATIONS.CUSTOMIZATION_CODE%TYPE;
140 l_parent_item_type MTL_SYSTEM_ITEMS.ITEM_TYPE%TYPE;
141 l_child_item_type MTL_SYSTEM_ITEMS.ITEM_TYPE%TYPE;
142 l_parent_item_type_name FND_LOOKUP_VALUES_VL.MEANING%TYPE;
143 l_child_item_type_name FND_LOOKUP_VALUES_VL.MEANING%TYPE;
144 l_return_status VARCHAR2(1);
145 l_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_Type;
146 l_token_tbl Error_Handler.Token_Tbl_Type;
147 l_message_list Error_Handler.Error_Tbl_Type;
148 l_parent_name VARCHAR2(700);
149 l_child_name VARCHAR2(700);
150
151 BEGIN
152
153 --
154 -- Initialize the message list if the user has set the
155 -- Init Message List parameter
156 --
157 IF p_init_msg_list
158 THEN
159 Error_Handler.Initialize;
160 END IF;
161
162
163 x_return_status := FND_API.G_RET_STS_SUCCESS;
164 l_return_status := 'N';
165
166 SELECT MSI.ITEM_TYPE, LOOKUP.MEANING ,MSI.CONCATENATED_SEGMENTS
167 INTO l_parent_item_type,l_parent_item_type_name,l_parent_name
168 FROM MTL_SYSTEM_ITEMS_KFV MSI ,FND_COMMON_LOOKUPS LOOKUP
169 WHERE
170 INVENTORY_ITEM_ID = p_parent_item_id AND ORGANIZATION_ID = p_organization_id
171 AND MSI.ITEM_TYPE = LOOKUP.LOOKUP_CODE(+)
172 AND LOOKUP.LOOKUP_TYPE(+) = 'ITEM_TYPE'
173 AND LOOKUP.ENABLED_FLAG(+) = 'Y'
174 AND (LOOKUP.START_DATE_ACTIVE IS NULL OR LOOKUP.START_DATE_ACTIVE < SYSDATE)
175 AND (LOOKUP.END_DATE_ACTIVE IS NULL OR LOOKUP.END_DATE_ACTIVE > SYSDATE);
176
177 --dbms_output.put_line('l_parent_item_type_name '||l_parent_item_type_name);
178 --dbms_output.put_line('l_parent_name '||l_parent_name);
179 --dbms_output.put_line('l_parent_item_type '||l_parent_item_type);
180
181 SELECT MSI.ITEM_TYPE, LOOKUP.MEANING ,MSI.CONCATENATED_SEGMENTS
182 INTO l_child_item_type , l_child_item_type_name,l_child_name
183 FROM MTL_SYSTEM_ITEMS_KFV MSI ,FND_COMMON_LOOKUPS LOOKUP
184 WHERE
185 INVENTORY_ITEM_ID = p_child_item_id AND ORGANIZATION_ID = p_organization_id
186 AND MSI.ITEM_TYPE = LOOKUP.LOOKUP_CODE(+)
187 AND LOOKUP.LOOKUP_TYPE(+) = 'ITEM_TYPE'
188 AND LOOKUP.ENABLED_FLAG(+) = 'Y'
189 AND (LOOKUP.START_DATE_ACTIVE IS NULL OR LOOKUP.START_DATE_ACTIVE < SYSDATE)
190 AND (LOOKUP.END_DATE_ACTIVE IS NULL OR LOOKUP.END_DATE_ACTIVE > SYSDATE);
191
192 --dbms_output.put_line('l_child_item_type_name '||l_child_item_type_name);
193 --dbms_output.put_line('l_child_name '||l_child_name);
194 --dbms_output.put_line('l_child_item_type '||l_child_item_type);
195
196 -- dbms_output.put_line('CHILD ITEM TYPE '||l_child_item_type_name);
197 IF (l_parent_item_type IS NOT NULL)
198 THEN
199 SELECT TEMPLATES.CUSTOMIZATION_CODE INTO l_customization_code
200 FROM FND_COMMON_LOOKUPS LOOKUP,
201 EGO_CRITERIA_TEMPLATES_V TEMPLATES
202 WHERE LOOKUP.LOOKUP_TYPE = 'ITEM_TYPE'
203 AND LOOKUP.ENABLED_FLAG = 'Y'
204 AND (LOOKUP.START_DATE_ACTIVE IS NULL OR LOOKUP.START_DATE_ACTIVE < SYSDATE)
205 AND (LOOKUP.END_DATE_ACTIVE IS NULL OR LOOKUP.END_DATE_ACTIVE > SYSDATE)
206 AND LOOKUP.LOOKUP_CODE = TEMPLATES.CLASSIFICATION1
207 AND TEMPLATES.CUSTOMIZATION_APPLICATION_ID = 702
208 AND TEMPLATES.REGION_APPLICATION_ID = 702
209 AND TEMPLATES.REGION_CODE = 'BOM_ITEM_TYPE_REGION'
210 AND LOOKUP_CODE = l_parent_item_type
211 AND TEMPLATES.CLASSIFICATION1 = l_parent_item_type;
212 --dbms_output.put_line('l_customization_code '||l_customization_code);
213 BEGIN
214
215 SELECT 'Y' INTO l_return_status FROM DUAL
216 WHERE l_child_item_type IN
217 (
218 SELECT VALUE_VARCHAR2 FROM EGO_CRITERIA_V
219 WHERE
220 CUSTOMIZATION_APPLICATION_ID = 702 AND
221 REGION_APPLICATION_ID = 702 AND
222 REGION_CODE = 'BOM_ITEM_TYPE_REGION'
223 AND CUSTOMIZATION_CODE = l_customization_code
224 );
225 EXCEPTION
226 WHEN NO_DATA_FOUND THEN
227 IF l_return_status <> 'Y'
228 THEN
229 l_token_tbl(1).token_name := 'PARENT_ITEM_NAME';
230 l_token_tbl(1).token_value := l_parent_name;
231 l_token_tbl(2).token_name := 'PARENT_ITEM_TYPE';
232 l_token_tbl(2).token_value := l_parent_item_type_name;
233 l_token_tbl(3).token_name := 'CHILD_ITEM_NAME';
234 l_token_tbl(3).token_value := l_child_name;
235 l_token_tbl(4).token_name := 'CHILD_ITEM_TYPE';
236 l_token_tbl(4).token_value := l_child_item_type_name;
237
238 Error_Handler.Add_Error_Token
239 ( p_Message_Name => 'BOM_COMP_ASSOC_DENIED'
240 , p_Mesg_Token_Tbl => l_mesg_token_tbl
241 , x_Mesg_Token_Tbl => l_mesg_token_tbl
242 , p_Token_Tbl => l_token_tbl
243 );
244
245 Error_Handler.Translate_And_Insert_Messages
246 ( p_mesg_token_tbl => l_mesg_token_tbl
247 , p_application_id => 'BOM'
248 );
249
250 Error_Handler.Get_Message_List( x_message_list => l_message_list);
251 x_error_message := l_message_list(1).Message_Text;
252 x_return_status := FND_API.G_RET_STS_ERROR;
253 -- dbms_output.put_line('RETURN STATUS WITH EXCEPTION '||l_return_status);
254 -- dbms_output.put_line('RETURN STATUS '||x_return_status);
255 -- dbms_output.put_line('RETURN MESSAGE '||x_error_message);
256 IF p_init_msg_list
257 THEN
258 Error_Handler.Write_To_DebugFile;
259 Error_Handler.Close_Debug_Session;
260 END IF;
261 END IF;
262 END;
263 ELSE
264 l_return_status := 'Y' ;
265 END IF;
266
267 IF l_return_status = 'Y'
268 THEN
269 x_return_status := FND_API.G_RET_STS_SUCCESS;
270 -- dbms_output.put_line('CRITERIA TEMPLATE FOUND.ITEM TYPES MATCH FOUND.');
271 -- dbms_output.put_line('RETURN STATUS '||x_return_status);
272 -- dbms_output.put_line('RETURN MESSAGE '||x_error_message);
273 END IF;
274
275 EXCEPTION
276 WHEN NO_DATA_FOUND THEN
277 x_return_status := FND_API.G_RET_STS_SUCCESS;
278 -- dbms_output.put_line('NO CRITERIA TEMPLATE FOUND. SO ANYTHING CAN BE ADDED');
279 -- dbms_output.put_line('RETURN STATUS '||x_return_status);
280 -- dbms_output.put_line('RETURN MESSAGE '||x_error_message);
281
282 END Check_Component_Type_Rule;
283
284 /*******************************************************************
285 * Procedure : Check_Entity
286 * Parameters IN : Bom Component Exposed Column record
287 * Bom Component unexposed column record
288 * Bom Component old exposed column record
289 * Bom Component old unexposed column record
290 * Parameters OUT: Return Status
291 * Message Token Table
292 * Purpose : Procedure will execute the business logic and will
293 * also perform any required cross entity validations
294 *******************************************************************/
295 PROCEDURE Check_Entity
296 ( x_return_status IN OUT NOCOPY VARCHAR2
297 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
298 , p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
299 , p_bom_Comp_Unexp_Rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
300 , p_old_bom_Component_Rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
301 , p_old_bom_Comp_Unexp_Rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
302 )
303 IS
304 l_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
305 l_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
306 l_old_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
307 l_old_rev_comp_unexp_rec
308 Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
309 BEGIN
310 x_return_status := FND_API.G_RET_STS_SUCCESS;
311
312 -- Convert BOM record into ECO record
313
314 Bom_Bo_Pub.Convert_BomComp_To_EcoComp
315 ( p_bom_component_rec => p_bom_component_rec
316 , p_bom_comp_unexp_rec => p_bom_comp_unexp_rec
317 , x_rev_component_rec => l_rev_component_rec
318 , x_rev_comp_unexp_rec => l_rev_comp_unexp_rec
319 );
320
321 -- Also convert Old BOM component record into ECO
322 Bom_Bo_Pub.Convert_BomComp_To_EcoComp
323 ( p_bom_component_rec => p_old_bom_component_rec
324 , p_bom_comp_unexp_rec => p_old_bom_comp_unexp_rec
325 , x_rev_component_rec => l_old_rev_component_rec
326 , x_rev_comp_unexp_rec => l_old_rev_comp_unexp_rec
327 );
328
329 -- Call Check Entity
330 Bom_Validate_Bom_Component.Check_Entity
331 ( p_rev_component_rec => l_rev_component_rec
332 , p_rev_comp_unexp_rec => l_rev_comp_unexp_rec
333 , p_old_rev_component_rec => l_old_rev_component_rec
334 , p_old_rev_comp_unexp_rec => l_old_rev_comp_unexp_rec
335 , x_return_status => x_return_status
336 , x_mesg_token_tbl => x_mesg_token_tbl
337 );
338
339 END Check_Entity;
340
341
342 /********************************************************************
343 * Procedure : Check_Attributes
344 * Parameters IN : Bom Component exposed column record
345 * Bom component unexposed column record
346 * Parameters OUT: Return Status
347 * Message Token Table
348 * Purpose : Check_Attributes will verify the exposed attributes
349 * of the component record in their own entirety. No
350 * cross entity validations will be performed.
351 ********************************************************************/
352 PROCEDURE Check_Attributes
353 ( x_return_status IN OUT NOCOPY VARCHAR2
354 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
355 , p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
356 , p_bom_Comp_Unexp_Rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
357 )
358 IS
359
360 l_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
361 l_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
362 BEGIN
363 Bom_Bo_Pub.Convert_BomComp_To_EcoComp
364 ( p_bom_component_rec => p_bom_component_rec
365 , p_bom_comp_unexp_rec => p_bom_comp_unexp_rec
366 , x_rev_component_rec => l_rev_component_rec
367 , x_rev_comp_unexp_rec => l_rev_comp_unexp_rec
368 );
369
370 -- Call Check Attributes procedure
371 Bom_Validate_Bom_Component.Check_Attributes
372 ( p_rev_component_rec => l_rev_component_rec
373 , p_rev_comp_unexp_rec => l_rev_comp_unexp_rec
374 , x_return_status => x_return_status
375 , x_mesg_token_tbl => x_mesg_token_tbl
376 );
377
378 END Check_Attributes;
379
380 PROCEDURE Check_Entity_Delete
381 ( x_return_status IN OUT NOCOPY VARCHAR2
382 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
383 , p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
384 , p_bom_Comp_Unexp_Rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
385 )
386 IS
387 BEGIN
388 NULL;
389 END Check_Entity_Delete;
390
391
392 PROCEDURE Check_Required
393 ( x_return_status IN OUT NOCOPY VARCHAR2
394 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
395 , p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
396 )
397 IS
398 l_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
399 l_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
400 BEGIN
401 Bom_Bo_Pub.Convert_BomComp_to_EcoComp
402 ( p_bom_component_rec => p_bom_component_rec
403 , x_rev_component_rec => l_rev_component_rec
404 , x_rev_comp_unexp_rec => l_rev_comp_unexp_rec
405 );
406
407 Bom_Validate_Bom_Component.Check_required
408 ( p_rev_component_rec => l_rev_component_rec
409 , x_return_status => x_return_status
410 , x_mesg_token_tbl => x_mesg_token_tbl
411 );
412 END Check_Required;
413
414
415 PROCEDURE Check_Existence
416 ( p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
417 , p_bom_comp_unexp_rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
418 , x_old_bom_component_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Rec_Type
419 , x_old_bom_comp_unexp_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
420 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
421 , x_return_status IN OUT NOCOPY VARCHAR2
422 )
423 IS
424 l_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
425 l_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
426 l_old_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
427 l_old_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
428 BEGIN
429 -- Convert bom component to eco component
430 Bom_Bo_Pub.Convert_BomComp_To_EcoComp
431 ( p_bom_component_rec => p_bom_component_rec
432 , p_bom_comp_unexp_rec => p_bom_comp_unexp_rec
433 , x_rev_component_rec => l_rev_component_rec
434 , x_rev_comp_unexp_rec => l_rev_comp_unexp_rec
435 );
436
437 Bom_Validate_Bom_Component.Check_Existence
438 ( p_rev_component_rec => l_rev_component_rec
439 , p_rev_comp_unexp_rec => l_rev_comp_unexp_rec
440 , x_old_rev_component_rec => l_old_rev_component_rec
441 , x_old_rev_comp_unexp_rec => l_old_rev_comp_unexp_rec
442 , x_return_status => x_return_status
443 , x_mesg_token_tbl => x_mesg_token_tbl
444 );
445
446 -- Convert old Eco Record back to Comp
447
448 Bom_Bo_Pub.Convert_EcoComp_To_BomComp
449 ( p_rev_component_rec => l_old_rev_component_rec
450 , p_rev_comp_unexp_rec => l_old_rev_comp_unexp_rec
451 , x_bom_component_rec => x_old_bom_component_rec
452 , x_bom_comp_unexp_rec => x_old_bom_comp_unexp_rec
453 );
454
455 END Check_Existence;
456
457 /* Component count under a bill cannot exceed 9999 */
458
459 PROCEDURE Check_ComponentCount
460 ( p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
461 , p_bom_comp_unexp_rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
462 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
463 , x_Return_Status IN OUT NOCOPY VARCHAR2
464 )
465 IS
466
467 l_total NUMBER := 0;
468 l_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_type;
469
470 BEGIN
471
472 x_return_status := FND_API.G_RET_STS_SUCCESS;
473
474 /* Added condition for date through bug 3238782 */
475
476 SELECT count(*) INTO l_total FROM bom_inventory_components WHERE
477 bill_sequence_id = p_bom_comp_unexp_rec.bill_sequence_id
478 and sysdate between effectivity_date and
479 nvl(disable_date,sysdate + 1);
480
481 IF l_total > BOM_GLOBALS.G_COMPS_LIMIT THEN
482 g_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
483 g_token_tbl(1).token_value :=
484 p_bom_component_rec.assembly_item_name;
485 Error_Handler.Add_Error_Token
486 ( p_message_name => 'BOM_COMP_COUNT_EXCEEDS_LIMIT'
487 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
488 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
489 , p_Token_Tbl => g_Token_Tbl
490 , p_message_type => 'W' -- Bug 3238782
491 );
492 --x_return_status := FND_API.G_RET_STS_ERROR; -- bug 3238782
493 END IF;
494
495 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
496
497 END Check_ComponentCount;
498
499 PROCEDURE Check_Lineage
500 ( p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
501 , p_bom_comp_unexp_rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
502 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
503 , x_Return_Status IN OUT NOCOPY VARCHAR2
504 )
505 IS
506 BEGIN
507 NULL;
508
509 END Check_Lineage;
510
511 /**********************************************************************
512 * Procedure : Check_Acces
513 * Parameters IN : Organization_Id
514 * Component Item Id and Name
515 * Message Token Table
516 * Parameters OUT: Message Token Table
517 * Return Status
518 * Purpose : This procedure will check if the user has access to
519 * the inventory components BOM_ITEM_TYPE.
520 **********************************************************************/
521 PROCEDURE Check_Access
522 ( p_organization_id IN NUMBER
523 , p_component_item_id IN NUMBER
524 , p_component_name IN VARCHAR2
525 , p_Mesg_Token_Tbl IN Error_Handler.Mesg_Token_Tbl_Type :=
526 Error_Handler.G_MISS_MESG_TOKEN_TBL
527 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
528 , x_Return_Status IN OUT NOCOPY VARCHAR2
529 )
530 IS
531 l_bom_comp_item_type NUMBER;
532 l_OPM_org VARCHAR2(1);
533 l_return_status VARCHAR2(1):=FND_API.G_RET_STS_SUCCESS;
534 l_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_type;
535 l_token_tbl Error_Handler.Token_Tbl_Type;
536 BEGIN
537 /*************************************************************
538 --
539 -- Check if the user has access to the revised component's
540 -- bom_item_type
541 --
542 **************************************************************/
543 SELECT bom_item_type
544 INTO l_Bom_comp_item_type
545 FROM mtl_system_items
546 WHERE inventory_item_id = p_component_item_id
547 AND organization_id = p_organization_id;
548
549 SELECT process_enabled_flag
550 INTO l_OPM_org
551 FROM mtl_parameters
552 WHERE organization_id = p_organization_id;
553
554 /* Validations for OPM Convergence Project
555 Model/Option class items are not allowed in OPM organizations*/
556
557 IF (l_OPM_org='Y' and l_bom_comp_item_type in ( Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS))THEN
558 Error_Handler.Add_Error_Token
559 ( p_Message_name => 'BOM_OPM_ORG_MODEL_OC'
560 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
561 , x_mesg_token_tbl => l_mesg_token_tbl
562 );
563 l_return_status := FND_API.G_RET_STS_ERROR;
564 END IF;
565
566 IF l_bom_comp_item_type NOT IN
567 (NVL(BOM_Globals.Get_MDL_Item_Access,0),
568 NVL(BOM_Globals.Get_OC_Item_Access,0),
569 NVL(BOM_Globals.Get_PLN_Item_Access,0),
570 NVL(BOM_Globals.Get_STD_Item_Access,0)
571 )
572 THEN
573 l_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
574 l_token_tbl(1).token_value := p_component_name;
575 l_token_tbl(2).token_name := 'BOM_ITEM_TYPE';
576 l_token_tbl(2).translate := TRUE;
577
578 IF l_bom_comp_Item_Type = 1
579 THEN
580 l_Token_Tbl(2).Token_Value := 'BOM_MODEL';
581 ELSIF l_bom_comp_Item_Type = 2
582 THEN
583 l_Token_Tbl(2).Token_Value:='BOM_OPTION_CLASS';
584 ELSIF l_bom_comp_Item_Type = 3
585 THEN
586 l_Token_Tbl(2).Token_Value := 'BOM_PLANNING';
587 ELSIF l_bom_comp_Item_Type = 4
588 THEN
589 l_Token_Tbl(2).Token_Value := 'BOM_STANDARD';
590 END IF;
591
592 Error_Handler.Add_Error_Token
593 ( p_Message_Name => 'BOM_BOM_COMP_ACCESS_DENIED'
594 , p_Mesg_Token_Tbl => l_mesg_token_tbl
595 , x_Mesg_Token_Tbl => l_mesg_token_tbl
596 , p_Token_Tbl => l_token_tbl
597 );
598 l_token_tbl.DELETE(2);
599 l_return_status := FND_API.G_RET_STS_ERROR;
600 END IF;
601
602 END Check_Access;
603
604 /*******************************************************************
605 -- Since ENG and BOM Business object share the entities Revised comp.
606 -- Reference Designator and Substitute Component but use a different
607 -- Record structure for exposed and unexposed columns, there are two
608 -- sets of procedures. Internally the Bom Bo will call the ECO's
609 -- Check_<Funtion> procedure since ECO was coded earlier than BOM BO.
610 --
611 -- Parameters to the ECO's BO are revised component where are the
612 -- parameter to the BOM's BO are Bom Component.
613 *********************************************************************/
614
615 /*****************************************************************
616 * Procedure : Check_Required
617 * Parameters IN : Revised Component exposed column record
618 * Paramaters OUT: Return Status
619 * Mesg Token Table
620 * Purpose : Procedure will check if the user has given all the
621 * required columns for the type of operation user is
622 * trying to perform. If the required columns are not
623 * filled in, then the record would get an error.
624 ********************************************************************/
625 PROCEDURE Check_Required
626 ( x_return_status IN OUT NOCOPY VARCHAR2
627 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
628 , p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
629 )
630 IS
631 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
632 BEGIN
633 x_return_status := FND_API.G_RET_STS_SUCCESS;
634
635 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
636 g_token_tbl(1).token_value :=
637 p_rev_component_rec.component_item_name;
638
639 IF ( p_rev_component_rec.acd_type IS NULL OR
640 p_rev_component_rec.acd_type = FND_API.G_MISS_NUM
641 ) AND
642 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
643 THEN
644 Error_Handler.Add_Error_Token
645 ( p_message_name => 'BOM_ACD_TYPE_MISSING'
646 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
647 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
648 , p_Token_Tbl => g_Token_Tbl
649 );
650 x_return_status := FND_API.G_RET_STS_ERROR;
651 END IF;
652
653 IF ( p_rev_component_rec.start_effective_date IS NULL OR
654 p_rev_component_rec.start_effective_date = FND_API.G_MISS_DATE
655 ) AND
656 ( p_rev_component_rec.from_end_item_unit_number IS NULL OR
657 p_rev_component_rec.from_end_item_unit_number = FND_API.G_MISS_CHAR
658 )
659 THEN
660 Error_Handler.Add_Error_Token
661 ( p_message_name => 'BOM_EFFECTIVITY_MISSING'
662 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
663 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
664 , p_Token_Tbl => g_Token_Tbl
665 );
666 x_return_status := FND_API.G_RET_STS_ERROR;
667 END IF;
668
669 -- Return the message table.
670
671 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
672
673 END Check_Required;
674
675
676 /*****************************************************************
677 * Function : Control
678 * Parameter IN : Org Level Control
679 * Subinventory Level Control
680 * Item Level Control
681 * Returns : Number
682 * Purpose : Control procedure will take the various level control
683 * values and decide if the Locator is controlled at the
684 * org,subinventory or item level. It will also decide
685 * if the locator is pre-specified or dynamic.
686 *******************************************************************/
687 FUNCTION CONTROL(org_control IN number,
688 sub_control IN number,
689 item_control IN number default NULL)
690 RETURN NUMBER
691 IS
692 locator_control number;
693 BEGIN
694
695 IF (org_control = 1) then
696 locator_control := 1;
697 ELSIF (org_control = 2) then
698 locator_control := 2;
699 ELSIF (org_control = 3) then
700 locator_control := 3;
701 ELSIF (org_control = 4) then
702 IF (sub_control = 1) then
703 locator_control := 1;
704 ELSIF (sub_control = 2) then
705 locator_control := 2;
706 ELSIF (sub_control = 3) then
707 locator_control := 3;
708 ELSIF (sub_control = 5) then
709 IF (item_control = 1) then
710 locator_control := 1;
711 ELSIF (item_control = 2) then
712 locator_control := 2;
713 ELSIF (item_control = 3) then
714 locator_control := 3;
715 ELSIF (item_control IS NULL) then
716 locator_control := sub_control;
717 END IF;
718 END IF;
719 END IF;
720
721 RETURN locator_control;
722
723 END CONTROL;
724
725 /*******************************************************************
726 * Function : Check_Overlap_Dates (Local function)
727 * Parameter IN: Effectivity Date
728 * Disable Date
729 * Bill Sequence Id
730 * Component Item Id
731 * Return : True if dates are overlapping else false.
732 * Purpose : The function will check if the same component is
733 * entered with overlapping dates. Components with
734 * overlapping dates will get a warning.
735 ******************************************************************/
736 FUNCTION Check_Overlap_Dates
737 ( X_Effectivity_Date DATE,
738 X_Disable_Date DATE,
739 X_Member_Item_Id NUMBER,
740 X_Bill_Sequence_Id NUMBER,
741 X_Rowid VARCHAR2,
742 X_Comp_Seq_Id NUMBER,
743 X_Operation_Seq_Num NUMBER)
744 RETURN BOOLEAN
745 IS
746 X_Count NUMBER := 0;
747 CURSOR X_All_Dates IS
748 SELECT 'X' date_available FROM sys.dual
749 WHERE EXISTS (
750 SELECT 1 from BOM_Inventory_Components
751 WHERE Component_Item_Id = X_Member_Item_Id
752 AND Bill_Sequence_Id = X_Bill_Sequence_Id
753 AND Operation_Seq_Num = X_Operation_Seq_Num
754 AND Component_Sequence_Id <> X_Comp_Seq_Id
755 AND (( RowId <> X_RowID ) or
756 (X_RowId IS NULL))
757 AND ( X_Disable_Date IS NULL
758 OR ( Trunc(X_Disable_Date) >
759 Trunc(Effectivity_Date)
760 )
761 )
762 AND ( Trunc(X_Effectivity_Date) <
763 Trunc(Disable_Date)
764 OR Disable_Date IS NULL
765 )
766 );
767 BEGIN
768
769 FOR X_Date IN X_All_Dates LOOP
770 X_Count := X_Count + 1;
771 END LOOP;
772
773 -- If count <> 0 that means the current date is overlapping with
774 -- some record.
775 IF X_Count <> 0 THEN
776 RETURN TRUE;
777 ELSE
778 RETURN FALSE;
779 END IF;
780
781 END Check_Overlap_Dates;
782
783
784 /*******************************************************************
785 * Function : Check_Overlap_Numbers (Local function)
786 * Parameter IN: from end item unit number
787 * to end item unit number
788 * Bill Sequence Id
789 * Component Item Id
790 * Return : True if unit numbers are overlapping, else false.
791 * Purpose : The function will check if the same component is entered
792 * with overlapping unit numbers. Components with
793 * overlapping unit numbers will get a warning.
794 * History : Created by AS on 07/08/99 as part of unit effectivity
795 * functionality.
796 *********************************************************************/
797 FUNCTION Check_Overlap_Numbers
798 ( X_From_End_Item_Number VARCHAR2
799 , X_To_End_Item_Number VARCHAR2
800 , X_Member_Item_Id NUMBER
801 , X_Bill_Sequence_Id NUMBER
802 , X_Rowid VARCHAR2
803 , X_Comp_Seq_Id NUMBER
804 , X_Operation_Seq_Num NUMBER)
805 RETURN BOOLEAN
806 IS
807 X_Count NUMBER := 0;
808 CURSOR X_All_Numbers IS
809 SELECT 'X' unit_available FROM sys.dual
810 WHERE EXISTS (
811 SELECT 1 from BOM_Inventory_Components
812 WHERE Component_Item_Id = X_Member_Item_Id
813 AND Bill_Sequence_Id = X_Bill_Sequence_Id
814 AND Operation_Seq_Num = X_Operation_Seq_Num
815 AND DISABLE_DATE IS NULL --bug:5347036 Consider only enabled components
816 AND Component_Sequence_Id <> X_Comp_Seq_Id
817 AND (RowId <> X_RowID
818 OR X_RowId IS NULL)
819 AND (X_To_End_Item_Number IS NULL
820 OR X_To_End_Item_Number >
821 From_End_Item_Unit_Number)
822 AND (X_From_End_Item_Number <
823 To_End_Item_Unit_Number
824 OR To_End_Item_Unit_Number IS NULL
825 )
826 );
827 BEGIN
828
829 FOR X_Unit IN X_All_Numbers LOOP
830 X_Count := X_Count + 1;
831 END LOOP;
832
833 -- If count <> 0 that means the unit numbers are overlapping
834 IF X_Count <> 0 THEN
835 RETURN TRUE;
836 ELSE
837 RETURN FALSE;
838 END IF;
839
840 END Check_Overlap_Numbers;
841
842
843 /********************************************************************
844 * Function : Verify_Item_Attributes
845 * Prameters IN : Organization_Id
846 * Component Item Id
847 * Assembly Item Id
848 * Eng Bill flag for Assembly
849 * Parameters OUT: Mesg Token_Tbl
850 * Return : True if no attributes are invalid and False otherwise
851 * Purpose : The function will validate the following BOM Matrix.
852 *----------------------------------------------------------------------
853 * Component Types
854 *----------------------------------------------------------------------
855 *Bill PTO ATO PTO ATO ATO PTO Std
856 *Types Model Model OC OC Planning Item Item Item
857 *------------- --------------------------------------------------------
858 *PTO Model Yes Yes Yes No No Yes Yes Yes
859 *ATO Model No Yes No Yes No Yes No Yes
860 *PTO OC Yes Yes Yes No No Yes Yes Yes
861 *ATO OC No Yes No Yes No Yes No Yes
862 *Planning Yes Yes Yes Yes Yes Yes Yes Yes
863 *ATO Item No No No No No Yes No Yes
864 *PTO Item No No No No No No Yes Yes
865 *Standard Item No No No No No Yes No Yes
866 *Config Item No Yes No Yes No Yes No Yes
867 *
868 **********************************************************************/
869 FUNCTION Verify_Item_Attributes
870 ( p_Mesg_token_tbl IN Error_Handler.Mesg_Token_Tbl_Type
871 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type)
872 RETURN BOOLEAN
873 IS
874 dummy NUMBER;
875 l_allow_eng_comps VARCHAR2(10);
876 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
877
878 BEGIN
879 l_Mesg_Token_Tbl := p_Mesg_Token_Tbl;
880
881 -- dbms_output.put_line
882 -- ('Within the Verify Item Attributes procedure . . . ');
883
884 -- Verify Eng flag for Assembly and Component
885 l_allow_eng_comps := fnd_profile.value('ENG:ALLOW_ENG_COMPS');
886 IF (g_Assy_Assembly_Type = 1 and -- Bill is manufacturing
887 -- Introduced new global variable to hold assembly_type of
888 -- bill header.
889 --bug: 4161794
890 g_Comp_Eng_Flag = 'Y' and -- and component is Engineering
891 (l_allow_eng_comps is NULL or l_allow_eng_comps <> '1'))
892 THEN
893 Error_Handler.Add_Error_Token
894 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
895 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
896 , p_message_name => 'BOM_ASSY_COMP_ENG_FLG_MISMATCH'
897 , p_Token_Tbl => g_Token_Tbl
898 );
899 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
900 RETURN FALSE;
901 END IF;
902
903 /************************************************************
904 -- Verify ATO MODEL OR ATO OPTION CLASS Assembly(not config)
905 -- Attributes ATO Model does not allow
906 -- 1. Planning Components
907 -- 2. PTO Model or PTO Option Class
908 -- 3. PTO Standard
909 -- If the Assembly is ATO Standard, then it does not allow the
910 -- above three types and
911 -- 4. ATO Model or
912 -- 5. ATO Option Class
913 **************************************************************/
914 IF ( ( ( g_Assy_Item_Type IN
915 (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS, Bom_Globals.G_STANDARD) AND
916 g_Assy_ATO_flag = 'Y' AND
917 g_Assy_Config = 'N'
918 )
919 ) AND
920 ( g_Comp_Item_Type = Bom_Globals.G_PLANNING OR
921 ( g_Comp_Item_Type IN
922 (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS, Bom_Globals.G_STANDARD) AND
923 g_Comp_PTO_Flag = 'Y'
924 )
925 )
926 ) OR
927 (
928 g_Assy_Item_Type = Bom_Globals.G_STANDARD AND
929 g_Assy_ATO_flag = 'Y' AND
930 g_Assy_Config = 'N' AND
931 ( g_Comp_Item_Type IN (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS) AND
932 g_Comp_ATO_Flag = 'Y'
933 )
934 )
935 THEN
936 IF g_Assy_Item_Type = Bom_Globals.G_MODEL
937 THEN
938 g_Token_Tbl(2).Token_Name := 'ITEM_TYPE';
939 g_Token_Tbl(2).Token_Value := 'BOM_MODEL_TYPE';
940 g_Token_Tbl(2).Translate := TRUE;
941 ELSIF g_Assy_Item_Type = Bom_Globals.G_OPTION_CLASS
942 THEN
943 g_Token_Tbl(2).Token_Name := 'ITEM_TYPE';
944 g_Token_Tbl(2).Token_Value :=
945 'BOM_OPTION_CLASS_TYPE';
946 g_Token_Tbl(2).Translate := TRUE;
947 ELSE
948 g_Token_Tbl(2).Token_Name := 'ITEM_TYPE';
949 g_Token_Tbl(2).Token_Value :=
950 'BOM_STANDARD_TYPE';
951 g_Token_Tbl(2).Translate := TRUE;
952 END IF;
953 g_token_tbl(3).token_name := 'REVISED_ITEM_NAME';
954 g_token_tbl(3).token_value :=
955 g_rev_component_rec.revised_item_name;
956
957 IF g_Assy_Item_Type IN ( Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
958 THEN
959 Error_Handler.Add_Error_Token
960 ( p_message_name => 'BOM_ATO_PROP_MISMATCH'
961 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
962 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
963 , p_Token_Tbl => g_Token_Tbl
964 );
965 ELSE
966 Error_Handler.Add_Error_Token
967 ( p_message_name => 'BOM_ATO_STD_PROP_MISMATCH'
968 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
969 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
970 , p_Token_Tbl => g_Token_Tbl
971 );
972 END IF;
973 g_Token_Tbl.DELETE(2);
974 g_Token_Tbl.DELETE(3);
975
976 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
977 RETURN FALSE;
978
979 /*************************************************************
980 -- If the Assembly is a Config Item i.e. ATO with Base_Item_Id
981 -- NOT NULL then it will allow
982 -- 1. ATO Standard or
983 -- 2. Standard item
984 -- and
985 -- 1. ATO Model
986 -- 2. ATO Option Class
987 -- only if the assemly is Phantom is Wip_Supply_Type is 6
988 -- validation is changed by vhymavat for bug 2595175
989 *************************************************************/
990 ELSIF g_Assy_ATO_Flag = 'Y' AND
991 g_Assy_Config = 'Y'
992 THEN
993 IF( g_rev_component_rec.Wip_Supply_Type <> 6 AND
994 g_Comp_Item_Type IN
995 (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
996 AND
997 g_Comp_ATO_Flag = 'Y'
998 )
999
1000 THEN
1001 g_token_tbl(2).token_name:='REVISED_ITEM_NAME';
1002 g_token_tbl(2).token_value :=
1003 g_rev_component_rec.revised_item_name;
1004
1005 Error_Handler.Add_Error_Token
1006 ( p_message_name => 'BOM_CFG_SUPPLY_NOT_PHANTOM'
1007 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1008 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1009 , p_Token_Tbl => g_Token_Tbl
1010 );
1011 g_token_tbl.delete(2);
1012
1013 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1014 RETURN FALSE;
1015
1016 /****************************************************
1017 -- Assembly is Config item with Wip Supply of Phantom
1018 -- but the component item types do not match
1019 ****************************************************/
1020 ELSIF
1021 NOT
1022 ( ( g_Comp_Item_Type IN
1023 (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS, Bom_Globals.G_STANDARD)
1024 AND
1025 g_Comp_ATO_Flag = 'Y'
1026 ) OR
1027 g_Comp_Item_Type = Bom_Globals.G_STANDARD
1028 )
1029 THEN
1030 g_token_tbl(2).token_name:= 'REVISED_ITEM_NAME';
1031 g_token_tbl(2).token_value :=
1032 g_rev_component_rec.revised_item_name;
1033
1034 Error_Handler.Add_Error_Token
1035 ( p_message_name => 'BOM_CONFIG_PROP_MISMATCH'
1036 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1037 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1038 , p_Token_Tbl => g_Token_Tbl
1039 );
1040
1041 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1042 g_token_tbl.delete(2);
1043 RETURN FALSE;
1044 END IF;
1045
1046 /*************************************************************
1047 -- Verify PTO MODEL or OPTION CLASS Assembly Attributes
1048 -- PTO Models do not allow
1049 -- 1. ATO Option Class and
1050 -- 2. Planning components
1051 **************************************************************/
1052 ELSIF g_Assy_Item_Type IN ( Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS) AND
1053 g_Assy_PTO_flag = 'Y' AND
1054 ( g_Comp_Item_Type = Bom_Globals.G_PLANNING OR
1055 ( g_Comp_Item_Type = Bom_Globals.G_OPTION_CLASS AND
1056 g_Comp_ATO_flag = 'Y'
1057 )
1058 )
1059 THEN
1060 IF g_Assy_Item_Type = Bom_Globals.G_MODEL
1061 THEN
1062 g_Token_Tbl(2).Token_Name := 'ITEM_TYPE';
1063 g_Token_Tbl(2).Token_Value := 'BOM_MODEL_TYPE';
1064 g_Token_Tbl(2).Translate := TRUE;
1065 ELSIF g_Assy_Item_Type = Bom_Globals.G_OPTION_CLASS
1066 THEN
1067 g_Token_Tbl(2).Token_Name := 'ITEM_TYPE';
1068 g_Token_Tbl(2).Token_Value :=
1069 'BOM_OPTION_CLASS_TYPE';
1070 g_Token_Tbl(2).Translate := TRUE;
1071 END IF;
1072
1073 g_token_tbl(3).token_name := 'REVISED_ITEM_NAME';
1074 g_token_tbl(3).token_value :=
1075 g_rev_component_rec.revised_item_name;
1076
1077 Error_Handler.Add_Error_Token
1078 ( p_message_name => 'BOM_MODEL_OC_PROP_MISMATCH'
1079 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1080 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1081 , p_Token_Tbl => g_Token_Tbl
1082 );
1083
1084 g_Token_Tbl.DELETE(2);
1085 g_token_tbl.delete(3);
1086 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1087 RETURN FALSE;
1088
1089 /****************************************************
1090 --
1091 -- PTO STandard will only allow Standard or PTO Standard
1092 --
1093 *****************************************************/
1094 ELSIF g_Assy_Item_Type = Bom_Globals.G_STANDARD AND
1095 g_Assy_PTO_Flag = 'Y' AND
1096 NOT
1097 ( g_Comp_Item_Type = Bom_Globals.G_STANDARD AND
1098 ( ( g_Comp_PTO_Flag = 'Y' AND
1099 g_comp_ATO_Flag = 'N'
1100 ) OR
1101 ( g_comp_ATO_Flag = 'N' AND
1102 g_comp_PTO_Flag = 'N'
1103 )
1104 )
1105 )
1106 /* Commenting for Bug 2627352
1107 NOT ( ( g_Comp_Item_Type = Bom_Globals.G_STANDARD AND
1108 g_Comp_PTO_flag = 'Y'
1109 ) OR
1110 ( g_Comp_Item_Type = Bom_Globals.G_STANDARD)
1111 )
1112 */
1113 THEN
1114 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
1115 g_token_tbl(2).token_value :=
1116 g_rev_component_rec.revised_item_name;
1117 Error_Handler.Add_Error_Token
1118 ( p_message_name => 'BOM_PTO_STD_PROP_MISMATCH'
1119 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1120 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1121 , p_Token_Tbl => g_Token_Tbl
1122 );
1123 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1124 g_token_tbl.delete(2);
1125 RETURN FALSE;
1126
1127 /************************************************************
1128 --
1129 -- A STANDARD bill will only allow ATO Standard and Standard
1130 -- items as components
1131 --
1132 *************************************************************/
1133 ELSIF g_Assy_Item_Type = Bom_Globals.G_STANDARD AND
1134 g_Assy_PTO_Flag = 'N' AND
1135 g_Assy_ATO_Flag = 'N' AND
1136 NOT
1137 ( g_Comp_Item_Type = Bom_Globals.G_STANDARD AND
1138 ( ( g_Comp_ATO_Flag = 'Y' AND
1139 g_comp_PTO_Flag = 'N'
1140 ) OR
1141 ( g_comp_ATO_Flag = 'N' AND
1142 g_comp_PTO_Flag = 'N'
1143 )
1144 )
1145 )
1146 THEN
1147 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
1148 g_token_tbl(2).token_value :=
1149 g_rev_component_rec.revised_item_name;
1150 Error_Handler.Add_Error_Token
1151 ( p_message_name => 'BOM_STANDARD_PROP_MISMATCH'
1152 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1153 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1154 , p_Token_Tbl => g_Token_Tbl
1155 );
1156 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1157 g_token_tbl.delete(2);
1158 RETURN FALSE;
1159
1160 END IF;
1161
1162 /**************************************************************
1163 -- ATP Validation for components is changed and now there is no restriction
1164 -- Comment out by MK on 06/05/2001
1165
1166 -- Once the matrix is verified then check the ATP Components
1167 -- and ATP Check attributes
1168
1169 IF BOM_Globals.get_debug = 'Y' THEN
1170 error_handler.write_debug('Check the ATP Components and ATP Check attribute.' );
1171 error_handler.write_debug('Assy ATP Comp Flag : ' || g_Assy_ATP_Comp_flag );
1172 error_handler.write_debug('Comp ATP Check Flag : ' || g_Comp_Atp_Check_Flag );
1173 END IF;
1174
1175 IF ( g_Assy_ATP_Comp_flag = 'N' AND
1176 g_Comp_Atp_Check_Flag = 'Y'
1177 )
1178 THEN
1179 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
1180 g_token_tbl(2).token_value :=
1181 g_rev_component_rec.revised_item_name;
1182
1183 Error_Handler.Add_Error_Token
1184 ( p_message_name => 'BOM_ASSY_COMP_ATP_MISMATCH'
1185 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1186 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1187 , p_Token_Tbl => g_Token_Tbl
1188 );
1189 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1190 g_token_tbl.delete(2);
1191 RETURN FALSE; -- ATP Item Attribute Invalid
1192 END IF;
1193 -- dbms_output.put_line('End of Item Attribute Validation . . .');
1194
1195 IF BOM_Globals.get_debug = 'Y' THEN
1196 error_handler.write_debug('Check the ATP Components and ATP Check attribute.' );
1197 END IF;
1198
1199 **************************************************************/
1200
1201 -- If control comes till this point then it would mean a success of
1202 -- attribute validation. Hence,
1203
1204 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1205 RETURN TRUE;
1206
1207 END Verify_Item_Attributes;
1208
1209 /********************************************************************
1210 * Function : Check_PTO_ATO_For_Optional (Local Function)
1211 * Returns : 0 if Success
1212 * 1 if Optional value is incorrect for ATO/PTO Model/OC
1213 * 2 if Optional value is incorrect for Plan/Stdd Bill
1214 * Purpose : Function will verify the following things:
1215 * 1. Optional must be NO (2) if Bill if Pln or Standard
1216 * 2. If Bill is PTO Model or OC and component is
1217 * ATO Std with no base mdl then Optional must be Yes
1218 * (1)
1219 ***********************************************************************/
1220 --
1221 -- Check if the PTO and ATO flags of Assembly and Component for the
1222 -- Optional flag to be correct.
1223 --
1224
1225 FUNCTION Check_PTO_ATO_for_Optional
1226 RETURN NUMBER
1227 IS
1228 BEGIN
1229
1230 -- dbms_output.put_line
1231 -- ('Value of Optional when checking ATO / PTO . . .');
1232
1233 IF ( g_Assy_PTO_flag = 'Y' AND
1234 g_Assy_Item_Type IN ( Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS) AND
1235 g_Comp_ATO_flag = 'Y' AND
1236 g_Comp_Item_Type = Bom_Globals.G_STANDARD AND
1237 g_Comp_Config = 'N' AND
1238 g_Rev_Component_Rec.optional = 2
1239 )
1240 THEN
1241 RETURN 1;
1242 ELSIF ( g_Assy_Item_Type IN (Bom_Globals.G_STANDARD, Bom_Globals.G_PLANNING) AND
1243 g_Rev_Component_Rec.optional = 1
1244 )
1245 THEN
1246 RETURN 2;
1247 ELSE
1248 RETURN 0;
1249 END IF;
1250
1251 END Check_PTO_ATO_for_Optional;
1252
1253 /********************************************************************
1254 * Function : Check_Planning_Percent
1255 * Returns : 0 for Success else 1, 2, or 3 for errors
1256 * Purpose : The function will verify the following:
1257 * Planning percent can be <> 100 only if
1258 * 1. Bill is Planning else RETURN error code 1 Or
1259 * 2. Bill is a Model/Option Class and Component is
1260 * optional Or else return error code 2.
1261 * 3. Bill is a Model/Option Class and component is not
1262 * Optional and forecase control is = 2
1263 * (Consume and Derive)
1264 ********************************************************************/
1265 FUNCTION Check_Planning_Percent RETURN NUMBER
1266 IS
1267 BEGIN
1268 IF g_rev_component_rec.planning_percent <> 100 THEN
1269 IF g_Assy_Item_Type = Bom_Globals.G_STANDARD THEN
1270 RETURN 1;
1271 ELSIF ( g_Assy_Item_Type IN (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
1272 AND
1273 g_rev_component_rec.optional <> 1 AND
1274 g_Comp_ATO_Forecast_Control <> 2
1275 )
1276 THEN
1277 RETURN 2;
1278 ELSIF ( g_Assy_Item_Type IN (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
1279 AND
1280 ( g_rev_component_rec.optional = 1 AND -- changed for Bug3163342
1281 g_Comp_ATO_Forecast_Control <> 2
1282 )
1283 )
1284 THEN
1285 RETURN 3;
1286 ELSE
1287 RETURN 0;
1288 END IF;
1289 ELSE
1290 RETURN -1;
1291 END IF;
1292
1293 END Check_Planning_Percent;
1294
1295
1296 /*******************************************************************
1297 * Function : Chk_Req_For_Rev_Or_Shp
1298 * Returns : 1 if Required for Revenue is invalid
1299 * 2 if Required to Ship is invalid
1300 * 3 if both are incorrect
1301 * 0 if both are correct
1302 * Purpose : Function will verify the following:
1303 * Required for Revenue / Required to Ship must be NO if
1304 * Replenish_To_Order_Flag is 'Y' for the Bill
1305 ********************************************************************/
1306 FUNCTION Chk_Req_For_Rev_Or_Shp
1307 RETURN NUMBER
1308 IS
1309 BEGIN
1310
1311 IF g_rev_component_rec.required_for_revenue = 1 AND
1312 g_rev_component_rec.required_to_ship = 2 AND
1313 g_Assy_ATO_Flag = 'Y'
1314 THEN
1315 RETURN 1;
1316 ELSIF g_rev_component_rec.required_to_ship = 1 AND
1317 g_rev_component_rec.required_for_revenue = 2 AND
1318 g_Assy_ATO_Flag = 'Y'
1319 THEN
1320 RETURN 2;
1321 ELSIF g_rev_component_rec.required_to_ship = 1 AND
1322 g_rev_component_rec.required_for_revenue = 1 AND
1323 g_Assy_ATO_Flag = 'Y'
1324 THEN
1325 RETURN 3;
1326 ELSE
1327 RETURN 0;
1328 END IF;
1329
1330 END Chk_Req_For_Rev_Or_Shp;
1331
1332
1333 -- Local Function for Product Family Members
1334 /********************************************************************
1335 *Function : CheckUnique_PF_Member
1336 *Returns : 1 This component exits in an other Product Family
1337 * Bill
1338 * 0 This component does not exist in other product
1339 * family Bill.
1340 *Purpose : Function will verify if the component exists in
1341 * other product family Bills.
1342 **********************************************************************/
1343 FUNCTION CheckUnique_PF_Member RETURN NUMBER
1344 IS
1345 Pf_Item_Id Number ;
1346 BEGIN
1347 --dbms_output.put_line('Withing Function CheckUnique_PF_Member . . .');
1348
1349 IF g_Assy_Item_Type = Bom_Globals.G_PRODUCT_FAMILY
1350 THEN
1351 BEGIN
1352 SELECT product_family_item_id
1353 INTO Pf_Item_Id
1354 FROM mtl_system_items_b
1355 WHERE inventory_item_id = g_rev_comp_Unexp_rec.component_item_id
1356 AND organization_id = g_rev_comp_Unexp_rec.organization_id;
1357
1358 If (Pf_Item_Id is NULL) THEN
1359 RETURN 0;
1360 ELSE
1361 RETURN 1;
1362 END IF;
1363 END;
1364 END IF;
1365 RETURN 0; -- This should never happen. CheckUnique_PF_Member should be called if item type is PF.
1366
1367 END CheckUnique_PF_Member;
1368
1369 -- Local Function Check_ATP
1370 /********************************************************************
1371 *Function : Check_ATP
1372 *Returns : 1 if ATP invalid because qty is -ve
1373 * 2 if ATP invalid because qty is fractional
1374 * 0 if the ATP value is valid.
1375 *Purpose : Function will verify if the Check_Atp value is correct
1376 * wrt to the check_atp and atp_components_flag of the
1377 * parent and component. It will also check if the
1378 * component quantity is greater than 0 for the
1379 * check_atp to be yes.
1380 **********************************************************************/
1381 FUNCTION Check_ATP RETURN NUMBER
1382 IS
1383 BEGIN
1384 -- dbms_output.put_line('Withing Function Check_ATP . . .');
1385
1386 IF g_Assy_ATP_Comp_flag IN ('Y','R','C') AND
1387 g_Comp_ATP_Check_flag in ('Y', 'C', 'R')
1388 THEN
1389 IF g_rev_component_rec.quantity_per_assembly < 0 THEN
1390 RETURN 1;
1391 ELSIF round(g_rev_component_rec.quantity_per_assembly)
1392 <> g_rev_component_rec.quantity_per_assembly
1393 THEN
1394 RETURN 2;
1395 ELSE
1396 RETURN 0;
1397 END IF;
1398 ELSE
1399 RETURN 1;
1400 END IF;
1401
1402 END Check_ATP;
1403
1404 /********************************************************************
1405 * Function : Check_Mutually_Exclusive
1406 * Returns : 0 if the Mutually exlusive values is correct
1407 * 1 if BOM is not Installed
1408 * 2 if Revised Component is Model or Option Class
1409 * Purpose : Will verify the value of mutually exclusive options
1410 * column by verifying if BOM is Installed and the
1411 * component is either a Model or Option Class.
1412 * In only this case the column can have a value of
1413 * Yes (1).
1414 *********************************************************************/
1415 --Local function to validate Mutually_Exclusive_Option
1416 FUNCTION Check_Mutually_Exclusive RETURN NUMBER
1417 IS
1418 X_Bom_Status VARCHAR2(80);
1419 X_Industry VARCHAR2(80);
1420 X_Install_Bom BOOLEAN;
1421 BEGIN
1422 -- dbms_output.put_Line
1423 -- ('Checking Mutually Exclusive for value : ' ||
1424 -- to_char(g_rev_component_rec.Mutually_Exclusive));
1425
1426 IF g_rev_component_rec.Mutually_Exclusive = 1 THEN
1427 X_install_bom := Fnd_Installation.Get
1428 ( appl_id => '702',
1429 dep_appl_id => '702',
1430 status => X_bom_status,
1431 industry => X_industry);
1432 IF X_install_bom AND
1433 g_Comp_Item_Type IN (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
1434 THEN
1435 RETURN 0;
1436 ELSIF g_Comp_Item_Type NOT IN (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
1437 THEN
1438 RETURN 2;
1439 ELSE
1440 RETURN 1;
1441 END IF;
1442 ELSE
1443 RETURN 0;
1444 END IF;
1445
1446 END Check_Mutually_Exclusive;
1447
1448
1449 /******************************************************************
1450 * Function : Check_Supply_Type
1451 * Returns : TRUE if the supply type is correct, false otherwise
1452 * Purpose : Function will verify if the Wip_supply_Type value is
1453 * is correct by doing the following checks:
1454 * 1. Wip_Supply_Type = 6 (Phantom), then component must
1455 * have a bill, else log a warning.
1456 * 2. Wip_Supply_Type must be Phantom if the component is
1457 * Model or Option Class
1458 ********************************************************************/
1459 FUNCTION Check_Supply_Type
1460 ( p_Mesg_Token_Tbl IN Error_Handler.Mesg_Token_Tbl_Type
1461 , x_Mesg_token_tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type)
1462 RETURN BOOLEAN
1463 IS
1464 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
1465 BEGIN
1466 l_Mesg_token_Tbl := p_Mesg_Token_Tbl;
1467
1468 IF g_rev_component_rec.WIP_Supply_Type IS NOT NULL
1469 THEN
1470 IF g_rev_component_rec.wip_supply_type = 6 /* PHANTOM */
1471 THEN
1472 BEGIN
1473 -- If Phantom then Component must be a Bill
1474 SELECT 'Valid'
1475 INTO l_dummy
1476 FROM bom_bill_of_materials
1477 WHERE assembly_item_id =
1478 g_rev_comp_unexp_rec.component_item_id
1479 AND organization_id =
1480 g_rev_comp_unexp_rec.organization_id
1481 AND rownum < 2; -- bug 2986752
1482
1483 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1484 RETURN TRUE;
1485
1486 EXCEPTION
1487 WHEN NO_DATA_FOUND THEN
1488 Error_Handler.Add_Error_Token
1489 ( p_message_name => 'BOM_NO_BILL'
1490 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1491 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1492 , p_message_type => 'W'
1493 );
1494 x_Mesg_token_tbl := l_Mesg_Token_Tbl;
1495 RETURN TRUE;
1496 -- Since this is a warning return true
1497 END; -- Check if phantom block
1498
1499 /* bug 2681317 this restriction is removed as per CTO team's suggestions ref1588889
1500 ELSE
1501 -- If component is Model/OC then
1502 -- WIP_Supply Type must be Phantom
1503 IF g_Comp_Item_Type IN
1504 (l_MODEL, l_OPTION_CLASS) AND
1505 g_rev_component_rec.wip_supply_type <> 6
1506 THEN
1507 Error_Handler.Add_Error_Token
1508 ( p_message_name => 'BOM_WIP_SUPPLY_PHANTOM'
1509 ,p_Mesg_Token_Tbl=> l_Mesg_token_Tbl
1510 ,x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
1511 ,p_token_tbl => g_Token_Tbl
1512 , p_message_type => 'W'
1513 );
1514 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1515 -- dbms_output.put_line
1516 -- ('Returing False Check Supply Type....');
1517
1518 RETURN TRUE;
1519 END IF;
1520 */
1521 END IF;
1522 END IF;
1523 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1524 RETURN TRUE;
1525 END Check_Supply_Type;
1526
1527 -- Local Function to verify Minimum Quantity.
1528 FUNCTION Check_Min_Quantity RETURN BOOLEAN
1529 IS
1530 BEGIN
1531 -- dbms_output.put_line('Low Quantity : ' ||
1532 -- to_char(g_rev_component_rec.minimum_allowed_quantity));
1533 -- dbms_output.put_line('Component Quantity : ' ||
1534 -- to_char(g_rev_component_rec.quantity_per_assembly));
1535 IF NVL(g_rev_component_rec.minimum_allowed_quantity, 0) >
1536 NVL(g_rev_component_rec.quantity_per_assembly, 0) THEN
1537 RETURN FALSE;
1538 ELSE
1539 RETURN TRUE;
1540 END IF;
1541
1542 END Check_Min_Quantity;
1543
1544 -- Local function to verify High Quantity
1545 FUNCTION Check_Max_Quantity RETURN BOOLEAN
1546 IS
1547 BEGIN
1548 -- dbms_output.put_line('High Quantity : ' ||
1549 -- to_char(g_rev_component_rec.maximum_allowed_quantity));
1550 -- dbms_output.put_line('Component Quantity : ' ||
1551 -- to_char(g_rev_component_rec.quantity_per_assembly));
1552
1553 IF NVL(g_rev_component_rec.maximum_allowed_quantity, 0) <
1554 NVL(g_rev_component_rec.quantity_per_assembly, 0) THEN
1555 RETURN FALSE;
1556 ELSE
1557 RETURN TRUE;
1558 END IF;
1559
1560 END Check_Max_Quantity;
1561
1562 -- Local function to check supply subinventory
1563 FUNCTION Check_Supply_SubInventory RETURN BOOLEAN
1564 IS
1565 l_allow_expense_to_asset VARCHAR2(10);
1566 l_RestrictSubInventory VARCHAR2(1);
1567 l_InventoryAsset VARCHAR2(1);
1568
1569 CURSOR c_Restrict_SubInv_Asset IS
1570 SELECT locator_type
1571 FROM mtl_item_sub_ast_trk_val_v
1572 WHERE inventory_item_id = g_rev_comp_Unexp_rec.component_item_id
1573 AND organization_id = g_rev_comp_Unexp_rec.organization_id
1574 AND secondary_inventory_name =
1575 g_rev_component_rec.supply_subinventory;
1576
1577 CURSOR c_Restrict_SubInv_Trk IS
1578 SELECT locator_type
1579 FROM mtl_item_sub_trk_val_v
1580 WHERE inventory_item_id = g_rev_comp_Unexp_rec.component_item_id
1581 AND organization_id = g_rev_comp_Unexp_rec.organization_id
1582 AND secondary_inventory_name =
1583 g_rev_component_rec.supply_subinventory;
1584
1585 CURSOR c_SubInventory_Asset IS
1586 SELECT locator_type
1587 FROM mtl_sub_ast_trk_val_v
1588 WHERE organization_id = g_rev_comp_Unexp_rec.organization_id
1589 AND secondary_inventory_name =
1590 g_rev_component_rec.supply_subinventory;
1591
1592 CURSOR c_Subinventory_Tracked IS
1593 SELECT locator_type
1594 FROM mtl_subinventories_trk_val_v
1595 WHERE organization_id = g_rev_comp_Unexp_rec.organization_id
1596 AND secondary_inventory_name =
1597 g_rev_component_rec.supply_subinventory;
1598
1599 BEGIN
1600
1601 -- dbms_output.put_line('Checking Subinv value . . . ' ||
1602 -- g_rev_component_rec.supply_subinventory);
1603
1604 l_allow_expense_to_asset := fnd_profile.value
1605 ('INV:EXPENSE_TO_ASSET_TRANSFER');
1606
1607 -- Get Restrict_Subinventory_Flag for the Item
1608 SELECT DECODE(restrict_subinventories_code, 1, 'Y', 'N'),
1609 inventory_asset_flag
1610 INTO l_RestrictSubInventory,
1611 l_InventoryAsset
1612 FROM mtl_system_items
1613 WHERE inventory_item_id = g_rev_comp_Unexp_rec.component_item_id
1614 AND organization_id = g_rev_comp_Unexp_rec.organization_id;
1615
1616 IF l_RestrictSubInventory = 'Y' THEN
1617
1618 -- dbms_output.put_line('Subinventory is Restricted...');
1619
1620 IF l_allow_expense_to_asset = '1' THEN
1621
1622 -- dbms_output.put_line
1623 -- ('Allow Expense to Asset 1 . . .');
1624
1625 OPEN c_Restrict_SubInv_Trk;
1626 FETCH c_Restrict_SubInv_Trk INTO
1627 l_Sub_Locator_Control;
1628 -- dbms_output.put_line('Within locator check ' ||
1629 -- to_char(l_Sub_Locator_Control));
1630
1631 IF c_Restrict_SubInv_Trk%Found THEN
1632 CLOSE c_Restrict_SubInv_Trk;
1633 RETURN TRUE;
1634 ELSE
1635 -- dbms_output.put_line
1636 -- ('Sub loc in Subinv: ' ||
1637 -- to_char(l_Sub_Locator_Control));
1638
1639 CLOSE c_Restrict_SubInv_Trk;
1640 RETURN FALSE;
1641 END IF;
1642 ELSE
1643 IF l_InventoryAsset = 'Y' THEN
1644
1645 -- dbms_output.put_line
1646 -- ('Inventory Asset Yes . . .');
1647
1648 OPEN c_Restrict_SubInv_Asset;
1649 FETCH c_Restrict_SubInv_Asset INTO
1650 l_Sub_Locator_Control;
1651 IF c_Restrict_SubInv_Asset%Found THEN
1652 CLOSE c_Restrict_SubInv_Asset;
1653 RETURN TRUE;
1654 ELSE
1655 CLOSE c_Restrict_SubInv_Asset;
1656 RETURN FALSE;
1657 END IF;
1658 ELSE
1659 -- dbms_output.put_line
1660 -- ('Inventory Asset No . . .');
1661
1662 OPEN c_Restrict_SubInv_Trk;
1663 FETCH c_Restrict_SubInv_Trk INTO
1664 l_Sub_Locator_Control;
1665 IF c_Restrict_SubInv_Trk%Found THEN
1666 CLOSE c_Restrict_SubInv_Trk;
1667 RETURN TRUE;
1668 ELSE
1669 CLOSE c_Restrict_SubInv_Trk;
1670 RETURN FALSE;
1671 END IF;
1672
1673 END IF;
1674 END IF;
1675 ELSE
1676
1677 -- dbms_output.put_line('Subinventory not restricted...');
1678
1679 IF l_Allow_Expense_To_Asset = '1' THEN
1680
1681 -- dbms_output.put_line
1682 -- ('Allow Expense to Asset = 1 ...');
1683
1684 OPEN c_SubInventory_Tracked;
1685 FETCH c_SubInventory_Tracked INTO
1686 l_Sub_Locator_Control;
1687 IF c_SubInventory_Tracked%FOUND THEN
1688 CLOSE c_SubInventory_Tracked;
1689 RETURN TRUE;
1690 ELSE
1691 CLOSE c_SubInventory_Tracked;
1692 RETURN FALSE;
1693 END IF;
1694 ELSE
1695 IF l_InventoryAsset = 'Y' THEN
1696 -- dbms_output.put_line
1697 -- ('Inventory Asset = Y . . .');
1698
1699 OPEN c_SubInventory_Asset;
1700 FETCH c_SubInventory_Asset INTO
1701 l_Sub_Locator_Control;
1702 IF c_SubInventory_Asset%FOUND THEN
1703 CLOSE c_SubInventory_Asset;
1704 RETURN TRUE;
1705 ELSE
1706 CLOSE c_SubInventory_Asset;
1707 RETURN FALSE;
1708 END IF;
1709 ELSE
1710 -- dbms_output.put_line
1711 -- ('Fetched from Subinventory Tracked..');
1712
1713 OPEN c_Subinventory_Tracked;
1714 FETCH c_Subinventory_Tracked INTO
1715 l_Sub_Locator_Control;
1716 IF c_SubInventory_Tracked%FOUND THEN
1717 CLOSE c_Subinventory_Tracked;
1718 RETURN TRUE;
1719 ELSE
1720 CLOSE c_Subinventory_Tracked;
1721 RETURN FALSE;
1722 END IF;
1723 END IF;
1724 END IF;
1725 END IF;
1726 END Check_Supply_SubInventory;
1727
1728 -- Local function to verify locators
1729 FUNCTION Check_Locators RETURN BOOLEAN
1730 IS
1731 Cursor CheckDuplicate is
1732 SELECT 'checking for duplicates' dummy
1733 FROM sys.dual
1734 WHERE EXISTS (
1735 SELECT null
1736 FROM mtl_item_locations
1737 WHERE organization_id =
1738 g_rev_comp_Unexp_rec.organization_id
1739 AND inventory_location_id =
1740 g_rev_comp_Unexp_rec.supply_locator_id
1741 AND subinventory_code <>
1742 g_rev_component_rec.supply_subinventory
1743 );
1744
1745 x_Control NUMBER;
1746 l_Success BOOLEAN;
1747 BEGIN
1748
1749 l_org_locator_control := 0 ;
1750 l_item_locator_control := 0;
1751
1752
1753 -- dbms_output.put_line('Within Check Locators function. . .');
1754
1755 -- Get Value of Org_Locator and item_Locator.
1756 SELECT stock_locator_control_code
1757 INTO l_org_locator_control
1758 FROM mtl_parameters
1759 WHERE organization_id = g_rev_comp_Unexp_rec.organization_id;
1760
1761 -- Get Value of Item Locator
1762 SELECT location_control_code
1763 INTO l_item_locator_control
1764 FROM mtl_system_items
1765 WHERE organization_id = g_rev_comp_Unexp_rec.organization_id
1766 AND inventory_item_id = g_rev_comp_Unexp_rec.component_item_id;
1767
1768 -- Get if locator is restricted or unrestricted
1769
1770 SELECT RESTRICT_LOCATORS_CODE
1771 INTO l_item_loc_restricted
1772 FROM mtl_system_items
1773 WHERE organization_id = g_rev_comp_Unexp_rec.organization_id
1774 AND inventory_item_id = g_rev_comp_Unexp_rec.component_item_id;
1775
1776 --
1777 -- When a SubInventory is validated, then depending on the
1778 -- Cursor being
1779 -- used in the Check_SubInventory procedure, the value of
1780 -- l_Sub_Locator_Control would be set.
1781 -- Else if there is no change in subinv
1782 -- then excute subinv check.
1783 --
1784
1785 -- dbms_output.put_line('Checking Subinventory locator control,
1786 -- calling Check_Supply_SubInventory . . .');
1787
1788
1789 IF Bom_Globals.Get_Debug = 'Y' THEN
1790 Error_Handler.Write_Debug('L_SUB_LOC_CONTROL :' || to_number( l_Sub_Locator_Control) );
1791 Error_Handler.Write_Debug('Now calling Check SupplySubInv: '|| g_rev_component_rec.supply_subinventory );
1792 END IF;
1793
1794 IF l_Sub_Locator_Control IS NULL AND
1795 g_rev_component_rec.supply_subinventory IS NOT NULL
1796 THEN
1797
1798 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1799 ('Now calling Check SupplySubInv. . .');
1800 END IF;
1801
1802
1803 l_Success := Check_Supply_SubInventory;
1804 END IF;
1805
1806 -- dbms_output.put_line
1807 -- ('After calling Check_Supply_SubInventory in Check_Locators..');
1808
1809 /*
1810 Locator is not required. But that validation should not be combined with Sub Inventory
1811 level locator control value. So commenting this validation. Bug 5032528
1812 --
1813 -- Locator cannot be NULL is if locator restricted
1814 --
1815 IF g_rev_comp_Unexp_rec.supply_locator_id IS NULL
1816 AND l_item_loc_restricted = 1
1817 THEN
1818 l_locator_control := 4;
1819 RETURN FALSE;
1820 ELSIF g_rev_comp_Unexp_rec.supply_locator_id IS NULL
1821 AND l_item_loc_restricted = 2
1822 THEN
1823 RETURN TRUE;
1824 END IF;
1825 */
1826 -- dbms_output.put_line('Within Check locators . . .');
1827
1828 IF l_org_locator_control is not null AND
1829 l_sub_locator_control is not null AND
1830 l_item_locator_control is not null
1831 THEN
1832 -- dbms_output.put_line
1833 -- ('Org _Control: ' || to_char(l_org_locator_control));
1834 -- dbms_output.put_line('Sub _Control: ' ||
1835 -- to_char(l_sub_locator_control));
1836 -- dbms_output.put_line('Item Control: ' ||
1837 -- to_char(l_item_locator_control));
1838
1839 x_control := Control
1840 ( Org_Control => l_org_locator_control,
1841 Sub_Control => l_sub_locator_control,
1842 Item_Control => l_item_locator_control
1843 );
1844
1845 l_locator_control := x_control;
1846 -- Variable to identify if the dynamic loc.
1847 -- Message must be logged.
1848
1849 IF x_Control = 1
1850 -- Added for bug 5032528, If locator is set, when locator control is none then only throw error
1851 AND g_rev_comp_Unexp_rec.supply_locator_id IS NOT NULL THEN -- No Locator Control
1852 RETURN FALSE; -- No Locator and Locator Id is
1853 -- supplied then raise Error
1854 ELSIF x_Control = 2 OR x_Control = 3 THEN -- PRESPECIFIED
1855 /*
1856 * Added OR x_Control = 3 as part of FP fix for bug 3624635
1857 * Even for dynamic locators if the locators are
1858 * in the system then we should be allowing.
1859 */
1860 BEGIN
1861
1862 -- dbms_output.put_line
1863 -- ('Checking when x_control returned 2 and ' ||
1864 -- ' item locator is ' ||
1865 -- to_char(l_item_locator_control));
1866
1867 -- If restrict locators is Y then check in
1868 -- mtl_secondary_locators if the item is
1869 -- assigned to the subinventory/location
1870 -- combination If restrict locators is N then
1871 -- check that the locator exists
1872 -- and is assigned to the subinventory and this
1873 -- combination is found in mtl_item_locations.
1874
1875 IF l_item_loc_restricted = 1
1876 -- Restrict Locators = YES
1877 THEN
1878
1879 --** Check for restrict Locators YES**
1880 SELECT 'Valid'
1881 INTO l_dummy
1882 FROM mtl_item_locations mil,
1883 mtl_secondary_locators msl
1884 WHERE msl.inventory_item_id =
1885 g_rev_comp_Unexp_rec.component_item_id
1886 AND msl.organization_id =
1887 g_rev_comp_Unexp_rec.organization_id
1888 AND msl.subinventory_code =
1889 g_rev_component_rec.supply_subinventory
1890 AND msl.secondary_locator =
1891 g_rev_comp_Unexp_rec.supply_locator_id
1892 AND mil.inventory_location_id =
1893 msl.secondary_locator
1894 AND mil.organization_id =
1895 msl.organization_id
1896 AND NVL(mil.disable_date, SYSDATE+1) >
1897 SYSDATE ;
1898
1899 -- If no exception is raised then the
1900 -- Locator is Valid
1901 RETURN TRUE;
1902 ELSE
1903 --**Check for restrict Locators NO**
1904 -- dbms_output.put_line
1905 -- ('Item restrict locators is NO . . .');
1906
1907 SELECT 'Valid'
1908 INTO l_dummy
1909 FROM mtl_item_locations mil
1910 WHERE mil.subinventory_code =
1911 g_rev_component_rec.supply_subinventory
1912 AND mil.inventory_location_id =
1913 g_rev_comp_Unexp_rec.supply_locator_id
1914 AND mil.organization_id =
1915 g_rev_comp_Unexp_rec.organization_id
1916 AND NVL(mil.DISABLE_DATE, SYSDATE+1) >
1917 SYSDATE;
1918
1919 -- If no exception is raised then the
1920 -- Locator is Valid
1921 RETURN TRUE;
1922
1923 END IF;
1924
1925 EXCEPTION
1926 WHEN NO_DATA_FOUND THEN
1927 RETURN FALSE;
1928 END; -- x-control=2 OR x_Control = 3 Ends
1929 /* Commented as part of FP fix for bug 3624635
1930 ELSIF x_Control = 3 THEN
1931 -- DYNAMIC LOCATORS ARE NOT ALLOWED IN OI.
1932 -- Dynamic locators are not allowed in open
1933 -- interface, so raise an error if the locator
1934 -- control is dynamic.
1935 l_locator_control := 3;
1936 RETURN FALSE;
1937 */
1938 ELSE
1939 -- dbms_output.put_line
1940 -- ('Finally returing a true value . . .');
1941 RETURN TRUE;
1942
1943 END IF; -- X_control Checking Ends
1944
1945 ELSE
1946 RETURN TRUE;
1947 END IF; -- If Locator Control check Ends.
1948
1949 END Check_Locators;
1950
1951 /*******************************************************************
1952 * Function : Check_Routing_Exists
1953 * Returns : TRUE if routing exists for revised item
1954 * FALSE if no routing exists for the revised item
1955 * Purpose : Verify the following:
1956 * Function Check_Routing_Exists checks if there is a
1957 * routing for the revised item.
1958 * If there is no routing, the user can only enter an
1959 * Operation Sequence Number of 1. Otherwise, the user
1960 * enter a NOT 1 value to indicate the routing operation.
1961 * History : Created by AS on 08/20. This validation modifies the
1962 original Operation Sequence Number validation slightly.
1963 **********************************************************************/
1964
1965 FUNCTION Check_Routing_Exists
1966 RETURN BOOLEAN
1967 IS
1968 l_alternate_bom_designator VARCHAR2(10) := NULL;
1969
1970 CURSOR GetAlternate IS
1971 SELECT alternate_bom_designator
1972 FROM bom_bill_of_materials
1973 WHERE bill_sequence_id = g_rev_comp_unexp_rec.bill_sequence_id;
1974
1975 CURSOR CheckRouting IS
1976 SELECT 'x'
1977 FROM bom_operation_sequences bos, bom_operational_routings bor
1978 WHERE bor.common_routing_sequence_id = bos.routing_sequence_id
1979 AND bor.organization_id = g_rev_comp_unexp_rec.organization_id
1980 AND bor.assembly_item_id = g_rev_comp_unexp_rec.revised_item_id
1981 AND nvl(bor.alternate_routing_designator,
1982 nvl(l_alternate_bom_designator, 'NONE')) =
1983 nvl(l_alternate_bom_designator, 'NONE');
1984
1985 l_dummy VARCHAR2(1);
1986
1987 BEGIN
1988 IF g_rev_comp_unexp_rec.bill_sequence_id IS NULL
1989 THEN
1990 RETURN FALSE;
1991 END IF;
1992
1993 OPEN GetAlternate;
1994 FETCH GetAlternate INTO l_alternate_bom_designator;
1995 Close GetAlternate;
1996
1997 OPEN CheckRouting;
1998 FETCH CheckRouting INTO l_dummy;
1999 IF CheckRouting%FOUND THEN
2000 CLOSE CheckRouting;
2001 RETURN TRUE;
2002 ELSE
2003 CLOSE CheckRouting;
2004 RETURN FALSE;
2005 END IF;
2006 END Check_Routing_Exists;
2007
2008 /*******************************************************************
2009 * Function : Check_Op_Seq
2010 * Parameters : l_unit_controlled_item - indicates whether revised
2011 * item is unit or date controlled
2012 * Returns : 0 if new op_seq or op_seq is valid
2013 * 1 if new_op_seq or op_seq does not exist
2014 * 2 if new_op_seq or op_seq is not unique
2015 3 if comp Operations exist with same op seq num
2016 * Purpose : Verify the following:
2017 * Function Check_Op_Seq will check if the op_seq_num
2018 * or the new_op_seq_num exists.
2019 * If they exist, then it will go ahead and check if
2020 * the the same component does not already exist with
2021 * the same op_seq_num
2022 **********************************************************************/
2023 FUNCTION Check_Op_Seq
2024 ( l_unit_controlled_item BOOLEAN
2025 )
2026 RETURN NUMBER
2027 IS
2028
2029 /* Bug 2573061
2030 The cursor Valid_Op_Seq is checking whether the operation_seq_num of the
2031 alternate_bill is existing in the alternate_routing or not. If alternating
2032 routing not exists for that alternate bill then it is returning error.
2033 But it should not do that. If alternate routing not exists it should validate
2034 the operation_seq_nums from the primary routing. so modified the cursor.
2035 */
2036
2037 CURSOR Valid_Op_Seq (p_eco_for_production NUMBER) IS
2038 SELECT 'Valid' valid_op_seq
2039 FROM
2040 /* bom_operational_routings bor,
2041 bom_operation_sequences bos
2042 WHERE bor.assembly_item_id =
2043 g_rev_comp_Unexp_rec.revised_item_id
2044 AND bor.organization_id =
2045 g_rev_comp_Unexp_rec.organization_id
2046 AND NVL(bor.alternate_routing_designator, 'NONE') =
2047 NVL(g_rev_component_rec.alternate_bom_code, 'NONE')
2048 AND bos.routing_sequence_id = bor.common_routing_sequence_id
2049 */
2050 bom_operation_sequences bos
2051 WHERE
2052 bos.routing_sequence_id =
2053 (
2054 select common_routing_sequence_id
2055 from bom_operational_routings
2056 where assembly_item_id = g_rev_comp_Unexp_rec.revised_item_id
2057 and organization_id = g_rev_comp_Unexp_rec.organization_id
2058 and nvl(alternate_routing_designator,
2059 nvl(g_rev_component_rec.alternate_bom_code, 'NONE')) =
2060 nvl(g_rev_component_rec.alternate_bom_code, 'NONE')
2061 and (g_rev_component_rec.alternate_bom_code is null
2062 or (g_rev_component_rec.alternate_bom_code is not null
2063 and (alternate_routing_designator =
2064 g_rev_component_rec.alternate_bom_code
2065 or not exists
2066 (select null
2067 from bom_operational_routings bor2
2068 where bor2.assembly_item_id =
2069 g_rev_comp_Unexp_rec.revised_item_id
2070 and bor2.organization_id = g_rev_comp_Unexp_rec.organization_id
2071 and bor2.alternate_routing_designator =
2072 g_rev_component_rec.alternate_bom_code
2073 )
2074 )
2075 )
2076 )
2077 )
2078 AND bos.operation_seq_num =
2079 decode(g_rev_component_rec.new_operation_sequence_number,
2080 NULL,
2081 g_rev_component_rec.Operation_Sequence_Number,
2082 g_rev_component_rec.new_Operation_sequence_number
2083 )
2084 -- commented following AND condition for bug 7339077
2085 -- AND nvl(trunc(disable_date), trunc(sysdate)+1) > trunc(sysdate)
2086 -- added following AND conditon for bug 7339077
2087 AND nvl(disable_date, trunc(sysdate)+1) >= sysdate
2088
2089
2090 AND ( ( p_eco_for_production = 2
2091 AND nvl(bos.eco_for_production, 2) <> 1
2092 )
2093 OR ( p_eco_for_production = 1
2094 AND ( bos.implementation_date IS NOT NULL
2095 OR ( bos.revised_item_sequence_id
2096 = g_rev_comp_unexp_rec.revised_item_sequence_id)
2097 )
2098 )
2099 ) ;
2100
2101 -- Added above conditions for Eco for Production by MK 02/02/2001
2102 -- Form has this validation in LOV for New Operation Sequence Number filed
2103
2104 l_eco_for_production NUMBER ; -- Added by MK 02/02/2001
2105
2106 CURSOR c_Op_Seq_Date_Used IS
2107 /* Check same component is not already effective */
2108 SELECT 'Already Used' op_seq_used
2109 FROM bom_inventory_components bic
2110 WHERE bic.bill_sequence_id =
2111 g_rev_comp_Unexp_rec.bill_sequence_id
2112 AND bic.component_item_id =
2113 g_rev_comp_Unexp_rec.component_item_id
2114 AND bic.operation_seq_num =
2115 decode(g_rev_component_rec.new_operation_sequence_number,
2116 NULL,
2117 g_rev_component_rec.operation_sequence_number,
2118 g_rev_component_rec.new_operation_sequence_number
2119 )
2120 /* Added extra condition to accomodate bill components
2121 */
2122 AND bic.component_sequence_id <>
2123 g_rev_comp_Unexp_rec.component_sequence_id
2124 /*added extra condition to avoid validation against the same comp*/
2125 AND (trunc(bic.effectivity_date)
2126 < trunc(g_rev_component_rec.start_effective_date)
2127 AND nvl(trunc(bic.disable_date),
2128 trunc(g_rev_component_rec.start_effective_date) + 2)
2129 > trunc(g_rev_component_rec.start_effective_date));
2130
2131 CURSOR c_Op_Seq_Unit_Used IS
2132 /* Check same component is not already effective */
2133 SELECT 'Already Used' op_seq_used
2134 FROM bom_inventory_components bic
2135 WHERE bic.bill_sequence_id =
2136 g_rev_comp_Unexp_rec.bill_sequence_id
2137 AND bic.component_item_id =
2138 g_rev_comp_Unexp_rec.component_item_id
2139 AND bic.operation_seq_num =
2140 decode(g_rev_component_rec.new_operation_sequence_number,
2141 NULL,
2142 g_rev_component_rec.operation_sequence_number,
2143 g_rev_component_rec.new_operation_sequence_number
2144 )
2145 AND DECODE(g_rev_component_rec.new_effectivity_date,
2146 NULL,
2147 g_rev_component_rec.start_effective_date,
2148 g_rev_component_rec.new_effectivity_date
2149 ) between bic.effectivity_date AND NVL(bic.disable_date, SYSDATE)
2150 AND bic.component_sequence_id <> g_rev_comp_unexp_rec.component_sequence_id
2151 /* Added extra condition to accomodate bill components
2152 */
2153 AND (bic.from_end_item_unit_number
2154 <= g_rev_component_rec.from_end_item_unit_number
2155 AND NVL(bic.to_end_item_unit_number,
2156 g_rev_component_rec.from_end_item_unit_number)
2157 >= g_rev_component_rec.from_end_item_unit_number);
2158 /* bug:4240031 Checking for the existence of Component Operation
2159 * with the same Op_seq_num
2160 */
2161 CURSOR c_Comp_Operation_Exist IS
2162 SELECT 'Already Exists' op_seq_exists
2163 FROM bom_component_operations bco
2164 WHERE bco.component_sequence_id =
2165 g_rev_comp_Unexp_rec.component_sequence_id
2166 AND bco.operation_seq_num =
2167 decode(g_rev_component_rec.new_operation_sequence_number,
2168 NULL,
2169 g_rev_component_rec.operation_sequence_number,
2170 g_rev_component_rec.new_operation_sequence_number
2171 );
2172
2173 BEGIN
2174
2175 -- If a record is found then it will mean that though
2176 -- the Operation Sequence exists in the Routings table
2177 -- a component already exist with that operation sequence abd
2178 -- Effectivity date so it cannot be inserted. So return an error
2179 -- hence, this function will return a false.
2180
2181 l_eco_for_production := NVL(Bom_Globals.Get_Eco_For_Production,2) ;
2182
2183 FOR l_valid_op IN Valid_Op_Seq(l_eco_for_production) LOOP
2184 -- if operation_seq exists in Operation_Sequences then
2185 -- verify that the same component does not already exist
2186 -- for that bill with the same operation seq.
2187 -- bug :4240031
2188 OPEN c_Comp_Operation_Exist;
2189 FETCH c_Comp_Operation_Exist INTO l_dummy;
2190 IF c_Comp_Operation_Exist%FOUND THEN
2191 CLOSE c_Comp_Operation_Exist;
2192 RETURN 3;
2193 ELSE
2194 CLOSE c_Comp_Operation_Exist;
2195 END IF;
2196 -- bug:4240031 ends
2197 IF l_unit_controlled_item
2198 THEN
2199 FOR l_Op_Seq_Unit_Used IN c_Op_Seq_Unit_Used LOOP
2200 RETURN 2;
2201 -- Op_seq_num or the new_op_seq_num not unique
2202 END LOOP;
2203 ELSE
2204 FOR l_Op_Seq_Date_Used IN c_Op_Seq_Date_Used LOOP
2205 RETURN 2;
2206 -- Op_seq_num or the new_op_seq_num not unique
2207 END LOOP;
2208 --For date eff bills, editable common bills may exist. The operation seq num
2209 --must be valid for those bils too.
2210 IF NOT BOMPCMBM.Check_Op_Seq_In_Ref_Boms(p_src_bill_seq_id => g_rev_comp_Unexp_rec.bill_sequence_id
2211 , p_op_seq => nvl(g_rev_component_rec.new_operation_sequence_number,
2212 g_rev_component_rec.operation_sequence_number)
2213 )
2214 THEN RETURN 4;
2215 END IF;
2216
2217 END IF;
2218
2219 -- dbms_output.put_line
2220 -- ('Check Op Seq returing with Success (0) ');
2221
2222 RETURN 0; -- op_seq_num or new_op_seq_num is valid
2223
2224 END LOOP;
2225
2226 RETURN 1;
2227 -- op_seq_num or new_op_seq_num is invalid
2228 -- i.e does not exist in bom_oper_sequences
2229
2230 END Check_Op_Seq;
2231
2232 /*
2233 ** Function Check_Unit_Number
2234 ** Will be called when the user is attempting to modify a unit effective BOM
2235 ** If the new unit number is creating a component with overlapping effectivity
2236 ** then this method will return 1
2237 ** else it will return 0
2238 */
2239 FUNCTION Check_Unit_Number
2240 RETURN NUMBER
2241 IS
2242 CURSOR c_Unit_Num_Used IS
2243 /* Check same component is not already effective */
2244 SELECT 'Already Used' unit_num_used
2245 FROM bom_inventory_components bic
2246 WHERE bic.bill_sequence_id =
2247 g_rev_comp_Unexp_rec.bill_sequence_id
2248 AND bic.component_item_id =
2249 g_rev_comp_Unexp_rec.component_item_id
2250 AND bic.operation_seq_num =
2251 decode(g_rev_component_rec.new_operation_sequence_number,
2252 NULL,
2253 g_rev_component_rec.operation_sequence_number,
2254 g_rev_component_rec.new_operation_sequence_number
2255 )
2256 AND DECODE(g_rev_component_rec.new_effectivity_date,
2257 NULL,
2258 g_rev_component_rec.start_effective_date,
2259 g_rev_component_rec.new_effectivity_date
2260 ) between bic.effectivity_date AND NVL(bic.disable_date, SYSDATE)
2261 AND bic.component_sequence_id <> g_rev_comp_unexp_rec.component_sequence_id
2262 /* Added extra condition to accomodate bill components
2263 */
2264 AND (( bic.from_end_item_unit_number
2265 <= DECODE(g_rev_component_rec.new_from_end_item_unit_number,FND_API.G_MISS_NUM,
2266 g_rev_component_rec.from_end_item_unit_number,
2267 NULL, g_rev_component_rec.from_end_item_unit_number,
2268 g_rev_component_rec.new_from_end_item_unit_number
2269 )
2270 AND NVL(bic.to_end_item_unit_number,g_rev_component_rec.from_end_item_unit_number)
2271 >= g_rev_component_rec.from_end_item_unit_number
2272 )
2273 OR
2274 ( bic.from_end_item_unit_number
2275 > DECODE(g_rev_component_rec.new_from_end_item_unit_number,FND_API.G_MISS_NUM,
2276 g_rev_component_rec.from_end_item_unit_number,
2277 NULL, g_rev_component_rec.from_end_item_unit_number,
2278 g_rev_component_rec.new_from_end_item_unit_number
2279 )
2280 AND NVL(bic.to_end_item_unit_number,g_rev_component_rec.from_end_item_unit_number)
2281 <= g_rev_component_rec.from_end_item_unit_number
2282 )
2283 );
2284
2285 BEGIN
2286
2287 FOR is_overlap_unit_num IN c_Unit_Num_Used LOOP
2288 RETURN 1;
2289 END LOOP;
2290
2291
2292 -- else return 0 for success
2293
2294 return 0;
2295
2296 END Check_Unit_Number;
2297
2298 /*----------------- bug:4240031 creating a new function-------------*/
2299 /*
2300 * Bug:4240031 :Adding a function to validate the case of changing the Attribute Optional.
2301 * If there are component operations defined for the component then the value of the
2302 * Attribtue Optional can not be changed from Yes to No
2303 */
2304 FUNCTION Check_Optional_For_Comp_Ops RETURN BOOLEAN
2305 IS
2306 CURSOR c_Change_Optional IS
2307 SELECT 'Exist' there_Exist
2308 FROM bom_component_operations bco,
2309 bom_components_b comp
2310 WHERE bco.component_sequence_id = comp.component_sequence_id
2311 AND comp.component_sequence_id = g_rev_comp_Unexp_rec.component_sequence_id
2312 AND comp.optional = 1
2313 AND g_rev_component_rec.Optional = 2;
2314 BEGIN
2315 OPEN c_Change_Optional;
2316 FETCH c_Change_Optional INTO l_dummy;
2317 IF c_Change_Optional%FOUND THEN
2318 CLOSE c_Change_Optional;
2319 RETURN TRUE;
2320 ELSE
2321 CLOSE c_Change_Optional;
2322 RETURN FALSE;
2323 END IF;
2324 END Check_Optional_For_Comp_Ops;
2325
2326 /*--------------------Changes for bug:4240031 end-----------------*/
2327
2328 FUNCTION Check_Optional RETURN BOOLEAN
2329 IS
2330 CURSOR c_CheckOptional IS
2331 SELECT 'Valid' is_Valid
2332 FROM mtl_system_items assy,
2333 mtl_system_items comp
2334 WHERE assy.organization_id = g_rev_comp_Unexp_rec.organization_id
2335 AND assy.inventory_item_id =
2336 g_rev_comp_Unexp_rec.revised_item_id
2337 AND comp.organization_id = g_rev_comp_Unexp_rec.organization_id
2338 AND comp.inventory_item_id =
2339 g_rev_comp_Unexp_rec.component_item_id
2340 AND ( ( assy.bom_item_type IN ( Bom_Globals.G_PLANNING, Bom_Globals.G_STANDARD)
2341 AND g_rev_component_rec.optional = 2 /* NO */
2342 )
2343 OR
2344 ( assy.bom_item_type IN ( Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS)
2345 AND assy.pick_components_flag = 'Y'
2346 /* PTO Model or PTO Option Class */
2347 AND comp.bom_item_type = Bom_Globals.G_STANDARD
2348 AND comp.replenish_to_order_flag = 'Y'
2349 AND comp.base_item_id IS NULL
2350 AND g_rev_component_rec.Optional = 1
2351 )
2352 );
2353
2354 BEGIN
2355 -- Optional must be 2 if Bill is Planning or Standard.
2356 -- If the Bill is PTO Model or PTO OC and the Component
2357 -- is an ATO Std item with no Base Model then Optional must be 1
2358 -- Else it can be anything from 1 and 2.
2359
2360
2361
2362 OPEN c_CheckOptional;
2363 FETCH c_CheckOptional INTO l_dummy;
2364 IF c_CheckOptional%FOUND THEN
2365 CLOSE c_CheckOptional;
2366 RETURN TRUE;
2367 ELSE
2368 CLOSE c_CheckOptional;
2369 RETURN FALSE;
2370 END IF;
2371
2372 END Check_Optional;
2373
2374
2375 /******************************************************************
2376 * Function : Check_Common_Other_Orgs
2377 * Return : True if component exists in other orgs, else False
2378 * Purpose : If component is being added to a bill that is being
2379 * referenced by items (bills) in other orgs
2380 * (as a common), the component must exist in those orgs
2381 * as well, with the correct item attributes.
2382 * This function will verify this and will return True
2383 * on success and false on failure.
2384 *********************************************************************/
2385 FUNCTION Check_Common_Other_Orgs
2386 RETURN NUMBER
2387 IS
2388 l_other_orgs BOOLEAN;
2389 l_invalid_bill NUMBER;
2390 l_allow_eng_comps varchar2(10) := nvl(fnd_profile.value('ENG:ALLOW_ENG_COMPS'), '2'); -- Bug 6274872
2391 CURSOR bom_enabled_in_other_orgs IS
2392 SELECT 1
2393 FROM BOM_BILL_OF_MATERIALS bom
2394 WHERE bom.source_bill_sequence_id =
2395 g_rev_comp_Unexp_rec.bill_sequence_id
2396 AND bom.organization_id <>
2397 g_rev_comp_Unexp_rec.organization_id
2398 AND NOT EXISTS (SELECT 1
2399 FROM MTL_SYSTEM_ITEMS msi
2400 WHERE msi.organization_id =
2401 bom.organization_id
2402 AND msi.inventory_item_id =
2403 g_rev_comp_Unexp_rec.component_item_id
2404 AND msi.bom_enabled_flag = 'Y' -- Uncommented for bug 5925020
2405 );
2406
2407 CURSOR in_other_orgs IS
2408 SELECT 1
2409 FROM BOM_BILL_OF_MATERIALS bom
2410 WHERE bom.source_bill_sequence_id =
2411 g_rev_comp_Unexp_rec.bill_sequence_id
2412 AND bom.organization_id <> g_rev_comp_Unexp_rec.organization_id
2413 AND NOT EXISTS (SELECT 1
2414 FROM MTL_SYSTEM_ITEMS msi
2415 WHERE msi.organization_id = bom.organization_id
2416 AND msi.inventory_item_id =
2417 g_rev_comp_Unexp_rec.component_item_id
2418 );
2419
2420 CURSOR eng_flag_in_other_orgs
2421 IS
2422 SELECT 1
2423 FROM BOM_BILL_OF_MATERIALS bom
2424 WHERE bom.source_bill_sequence_id =
2425 g_rev_comp_Unexp_rec.bill_sequence_id
2426 AND bom.organization_id <> g_rev_comp_Unexp_rec.organization_id
2427 AND NOT EXISTS (SELECT 1
2428 FROM MTL_SYSTEM_ITEMS msi
2429 WHERE msi.organization_id = bom.organization_id
2430 AND msi.inventory_item_id =
2431 g_rev_comp_Unexp_rec.component_item_id
2432 AND msi.bom_enabled_flag = 'Y' -- Uncommented for bug 5925020
2433
2434 AND (( bom.assembly_type = 1 AND
2435 ((msi.eng_item_flag = 'N' and l_allow_eng_comps = '2' ) or l_allow_eng_comps = '1' ) -- Bug 6274872
2436 )
2437 OR bom.assembly_type = 2
2438 )
2439 );
2440
2441 /*Cursor editable_common_bom_other_org
2442 IS
2443 SELECT bill_Sequence_id
2444 FROM BOM_BILL_OF_MATERIALS
2445 WHERE common_bill_Sequence_id <> source_bill_sequence_id
2446 AND source_bill_sequence_id = g_rev_comp_Unexp_rec.bill_sequence_id
2447 AND organization_id <> g_rev_comp_Unexp_rec.organization_id;
2448
2449 Cursor valid_op_seq(p_bill_seq_id NUMBER)
2450 IS
2451 SELECT 1
2452 FROM BOM_OPERATION_SEQUENCES bos, BOM_OPERATIONAL_ROUTINGS bor, BOM_BILL_OF_MATERIALS bom
2453 WHERE (bor.routing_sequence_id = bos.routing_sequence_id
2454 AND bor.assembly_item_id = bom.assembly_item_id
2455 AND bor.organization_id = bom.organization_id
2456 AND nvl(bor.alternate_routing_designator, 'XXX') = nvl(bom.alternate_bom_designator, 'XXX')
2457 AND bom.bill_sequence_id = p_bill_seq_id
2458 AND bos.operation_sequence_id <> g_rev_component_rec.New_Operation_Sequence_Number)
2459 OR g_rev_component_rec.New_Operation_Sequence_Number = 1;*/
2460
2461 BEGIN
2462
2463 -- If component not in other Orgs that refer the bill as common
2464 -- then return an error code of 1
2465
2466 -- dbms_output.put_line
2467 -- ('Checking if comp exists in other ORGS when bill is common..');
2468
2469 FOR c_other_orgs IN in_other_orgs LOOP
2470 RETURN 1;
2471 END LOOP;
2472
2473 -- dbms_output.put_line
2474 -- ('Checking if component is BOM enabled in other ORGS . . .');
2475
2476 FOR c_bom_enabled IN bom_enabled_in_other_orgs LOOP
2477 RETURN 2;
2478 END LOOP;
2479
2480 -- dbms_output.put_line('Checking if component is ENG flag is compatible in other ORGS . . .');
2481
2482 FOR c_eng_flag IN eng_flag_in_other_orgs LOOP
2483 RETURN 3;
2484 END LOOP;
2485
2486 /*FOR c_editable_comm_bill in editable_common_bom_other_org
2487 LOOP
2488 OPEN invalid_op_seq(c_editable_comm_bill.bill_Sequence_id);
2489 FETCH invalid_op_seq INTO l_invalid_Bill;
2490 IF invalid_op_seq%FOUND
2491 THEN
2492 RETURN 4;
2493 END IF;
2494 END LOOP;*/
2495 --Moved this to check_op_seq as this should be caled even for commoning withing the org.
2496
2497 RETURN 0;
2498
2499 END Check_Common_Other_Orgs;
2500
2501 --
2502 -- Function Check_Prrimary Bill
2503 --
2504 FUNCTION Check_PrimaryBill
2505 RETURN BOOLEAN
2506 IS
2507 CURSOR c_CheckPrimary IS
2508 SELECT 1
2509 FROM bom_bill_of_materials
2510 WHERE assembly_item_id = g_Rev_Comp_Unexp_Rec.revised_item_id
2511 AND organization_id = g_Rev_Comp_Unexp_Rec.Organization_Id
2512 AND NVL(alternate_bom_designator, 'NONE') = 'NONE';
2513 BEGIN
2514 FOR CheckPrimary IN c_CheckPrimary LOOP
2515 RETURN TRUE;
2516 END LOOP;
2517
2518 -- If the loop does not execute then
2519 -- return false
2520
2521 RETURN FALSE;
2522 END Check_PrimaryBill;
2523
2524 --
2525 -- Function Check_RevItem_Alternate
2526 -- Added by MK on 11/01/2000
2527 -- Called from Check_Access
2528 --
2529 -- This fuction moved to Engineering space to resolove ECO dependency
2530 -- by MK on 12/03/00
2531 /*
2532 FUNCTION Check_RevItem_Alternate( p_revised_item_id IN NUMBER
2533 , p_organization_id IN NUMBER
2534 , p_change_notice IN VARCHAR2
2535 , p_new_item_revision IN VARCHAR2
2536 , p_new_routing_revsion IN VARCHAR2
2537 , p_effective_date IN DATE
2538 , p_from_end_item_number IN VARCHAR2
2539 )
2540 RETURN BOOLEAN
2541 IS
2542
2543 l_return_status BOOLEAN ;
2544
2545 CURSOR c_CheckPrimary ( p_revied_item_id NUMBER
2546 , p_organization_id NUMBER)
2547 IS
2548
2549 SELECT 1
2550 FROM bom_bill_of_materials
2551 WHERE assembly_item_id = p_revied_item_id
2552 AND organization_id = p_organization_id
2553 AND NVL(alternate_bom_designator, 'NONE') = 'NONE';
2554
2555 CURSOR c_Alternate_Check ( p_revised_item_id NUMBER
2556 , p_organization_id NUMBER
2557 , p_change_notice VARCHAR2
2558 , p_new_item_revision VARCHAR2
2559 , p_new_routing_revsion VARCHAR2
2560 , p_from_end_item_number VARCHAR2
2561 , p_effective_date DATE
2562 )
2563 IS
2564
2565 SELECT 'Rev Item is only Eco for altenate routing'
2566 FROM ENG_REVISED_ITEMS eri
2567 , BOM_OPERATIONAL_ROUTINGS bor
2568 WHERE bor.alternate_routing_designator IS NOT NULL
2569 AND eri.routing_sequence_id = bor.routing_sequence_id(+)
2570 AND eri.routing_sequence_id IS NOT NULL
2571 AND eri.bill_sequence_id IS NULL
2572 AND NVL(eri.from_end_item_unit_number, 'NONE')
2573 = NVL(p_from_end_item_number, 'NONE')
2574 AND NVL(eri.new_item_revision,'NULL') = NVL(p_new_item_revision ,'NULL')
2575 AND NVL(eri.new_routing_revision,'NULL') = NVL(p_new_routing_revsion,'NULL')
2576 AND TRUNC(eri.scheduled_date) = TRUNC(p_effective_date)
2577 AND eri.change_notice = p_change_notice
2578 AND eri.organization_id = p_organization_id
2579 AND eri.revised_item_id = p_revised_item_id ;
2580
2581
2582 BEGIN
2583
2584 FOR CheckPrimary IN c_CheckPrimary(p_revised_item_id, p_organization_id)
2585 LOOP
2586 RETURN TRUE ;
2587 END LOOP;
2588
2589
2590 FOR CheckRevAlt IN c_Alternate_Check
2591 ( p_revised_item_id
2592 , p_organization_id
2593 , p_change_notice
2594 , p_new_item_revision
2595 , p_new_routing_revsion
2596 , p_from_end_item_number
2597 , p_effective_date
2598 )
2599
2600 LOOP
2601 RETURN FALSE ;
2602 END LOOP;
2603
2604
2605
2606 -- If the loop does not execute then
2607 -- return True`
2608
2609 RETURN TRUE ;
2610
2611 END ;
2612 */ -- Comment out by MK on 12/03/00
2613
2614
2615 /*****************************************************
2616 * Added by MK on 01/26/2001 for ECO New Effectivities
2617 * This function is copied from
2618 * ENG_Validate.Check_RevCmp_In_ECO_By_WO which is
2619 * no longer used and modified.
2620 *
2621 * Function : Check_RevCmp_In_ECO_By_WO
2622 * Parameters IN : Revised Item Sequence Id
2623 * Component Item Id
2624 * Operation Seq Num
2625 * Returns : True if All Jobs in ECO by Lot, WO, Cum Qty have the
2626 * Rev Component and Op Seq Number else False.
2627 * Purpose : Check if Component Item, Op Seq Num exists in material requirements
2628 * info of jobs and schedules Verify the user can create a revised
2629 * component record in ECO by WO
2630 *****************************************************************************/
2631 FUNCTION Check_RevCmp_In_ECO_By_WO
2632 ( p_revised_item_sequence_id IN NUMBER
2633 , p_rev_comp_item_id IN NUMBER
2634 , p_operation_seq_num IN NUMBER
2635 , p_organization_id IN NUMBER
2636 , p_rev_item_id IN NUMBER
2637 )
2638
2639 RETURN BOOLEAN
2640 IS
2641 l_ret_status BOOLEAN := TRUE ;
2642
2643 l_lot_number varchar2(30) := NULL;
2644 l_from_wip_entity_id NUMBER :=0;
2645 l_to_wip_entity_id NUMBER :=0;
2646 l_from_cum_qty NUMBER :=0;
2647
2648
2649 CURSOR l_check_lot_num_csr ( p_lot_number VARCHAR2
2650 , p_rev_comp_item_id NUMBER
2651 , p_operation_seq_num NUMBER
2652 , p_organization_id NUMBER
2653 , p_rev_item_id NUMBER )
2654 IS
2655 SELECT 'Cmp does not exist'
2656 FROM SYS.DUAL
2657 WHERE EXISTS (SELECT NULL
2658 FROM WIP_DISCRETE_JOBS wdj
2659 WHERE (wdj.status_type <> 1
2660 OR
2661 NOT EXISTS(SELECT NULL
2662 FROM WIP_REQUIREMENT_OPERATIONS wro
2663 WHERE (wro.operation_seq_num = p_operation_seq_num
2664 OR p_operation_seq_num = 1)
2665 AND wro.inventory_item_id = p_rev_comp_item_id
2666 AND wro.wip_entity_id = wdj.wip_entity_id)
2667 )
2668 AND wdj.lot_number = p_lot_number
2669 AND wdj.organization_id = p_organization_id
2670 AND wdj.primary_item_id = p_rev_item_id
2671 ) ;
2672
2673 CURSOR l_check_wo_csr ( p_from_wip_entity_id NUMBER
2674 , p_to_wip_entity_id NUMBER
2675 , p_rev_comp_item_id NUMBER
2676 , p_operation_seq_num NUMBER
2677 , p_organization_id NUMBER )
2678 IS
2679 SELECT 'Cmp does not exist'
2680 FROM SYS.DUAL
2681 WHERE EXISTS (SELECT NULL
2682 FROM WIP_DISCRETE_JOBS wdj
2683 , WIP_ENTITIES we
2684 , WIP_ENTITIES we1
2685 , WIP_ENTITIES we2
2686 WHERE (wdj.status_type <> 1
2687 OR
2688 NOT EXISTS (SELECT NULL
2689 FROM WIP_REQUIREMENT_OPERATIONS wro
2690 WHERE (wro.operation_seq_num = p_operation_seq_num
2691 OR p_operation_seq_num = 1)
2692 AND wro.inventory_item_id = p_rev_comp_item_id
2693 AND wro.wip_entity_id = wdj.wip_entity_id)
2694 )
2695 AND wdj.wip_entity_id = we.wip_entity_id
2696 AND we.organization_Id = p_organization_id
2697 AND we.wip_entity_name >= we1.wip_entity_name
2698 AND we.wip_entity_name <= we2.wip_entity_name
2699 AND we1.wip_entity_id = p_from_wip_entity_id
2700 AND we2.wip_entity_id = NVL(p_to_wip_entity_id, p_from_wip_entity_id)
2701 ) ;
2702
2703
2704 CURSOR l_check_cum_csr ( p_from_wip_entity_id NUMBER
2705 , p_rev_comp_item_id NUMBER
2706 , p_operation_seq_num NUMBER)
2707 IS
2708 SELECT 'Cmp does not exist'
2709 FROM SYS.DUAL
2710 WHERE EXISTS (SELECT NULL
2711 FROM WIP_DISCRETE_JOBS wdj
2712 WHERE (wdj.status_type <> 1
2713 OR
2714 NOT EXISTS(SELECT NULL
2715 FROM WIP_REQUIREMENT_OPERATIONS wro
2716 WHERE (wro.operation_seq_num = p_operation_seq_num
2717 OR p_operation_seq_num = 1)
2718 AND wro.inventory_item_id = p_rev_comp_item_id
2719 AND wro.wip_entity_id = wdj.wip_entity_id)
2720 )
2721 AND wdj.wip_entity_id = p_from_wip_entity_id
2722 ) ;
2723
2724 BEGIN
2725
2726
2727 l_lot_number := BOM_Globals.Get_Lot_Number;
2728 l_from_wip_entity_id := BOM_Globals.Get_From_Wip_Entity_Id;
2729 l_to_wip_entity_id := BOM_Globals.Get_To_Wip_Entity_Id;
2730 l_from_cum_qty := BOM_Globals.Get_From_Cum_Qty;
2731
2732 IF Bom_Globals.Get_Debug = 'Y' THEN
2733 Error_Handler.Write_Debug('Check if the rev component is valid in Eco by Prod. . .' );
2734 Error_Handler.Write_Debug('Lot Number in parent rev item : ' || l_lot_number );
2735 Error_Handler.Write_Debug('From WIP Entity Id in parent rev item : ' || to_char(l_from_wip_entity_id) );
2736 Error_Handler.Write_Debug('To WIP Entity Id in parent rev item : ' || to_char(l_to_wip_entity_id) );
2737 Error_Handler.Write_Debug('Cum Qty in parent rev item : ' || to_char(l_from_cum_qty) );
2738 END IF;
2739
2740
2741 -- Check if comp exists in ECO by Lot
2742 IF l_lot_number IS NOT NULL
2743 AND l_from_wip_entity_id IS NULL
2744 AND l_to_wip_entity_id IS NULL
2745 AND l_from_cum_qty IS NULL
2746 THEN
2747
2748 FOR l_lot_num_rec IN l_check_lot_num_csr
2749 ( p_lot_number => l_lot_number
2750 , p_rev_comp_item_id => p_rev_comp_item_id
2751 , p_operation_seq_num => p_operation_seq_num
2752 , p_organization_id => p_organization_id
2753 , p_rev_item_id => p_rev_item_id
2754 )
2755 LOOP
2756
2757 IF Bom_Globals.Get_Debug = 'Y' THEN
2758 Error_Handler.Write_Debug('In Eco by Lot Number, this rev component is invalid. . .' );
2759 END IF;
2760 l_ret_status := FALSE ;
2761 END LOOP ;
2762
2763
2764 -- Check if comp exists in ECO by Cum
2765 ELSIF l_lot_number IS NULL
2766 AND l_from_wip_entity_id IS NOT NULL
2767 AND l_to_wip_entity_id IS NULL
2768 AND l_from_cum_qty IS NOT NULL
2769 THEN
2770
2771 FOR l_cum_rec IN l_check_cum_csr
2772 ( p_from_wip_entity_id => l_from_wip_entity_id
2773 , p_rev_comp_item_id => p_rev_comp_item_id
2774 , p_operation_seq_num => p_operation_seq_num )
2775 LOOP
2776
2777 IF Bom_Globals.Get_Debug = 'Y' THEN
2778 Error_Handler.Write_Debug('In Eco by Cum Qty, this rev component is invalid. . .' );
2779 END IF;
2780
2781 l_ret_status := FALSE ;
2782 END LOOP ;
2783
2784 -- Check if comp exists in ECO by WO
2785 ELSIF l_lot_number IS NULL
2786 AND l_from_wip_entity_id IS NOT NULL
2787 AND l_from_cum_qty IS NULL
2788 THEN
2789
2790 FOR l_wo_rec IN l_check_wo_csr
2791 ( p_from_wip_entity_id => l_from_wip_entity_id
2792 , p_to_wip_entity_id => l_to_wip_entity_id
2793 , p_rev_comp_item_id => p_rev_comp_item_id
2794 , p_operation_seq_num => p_operation_seq_num
2795 , p_organization_id => p_organization_Id )
2796 LOOP
2797
2798 IF Bom_Globals.Get_Debug = 'Y' THEN
2799 Error_Handler.Write_Debug('In Eco by range work order, this rev component is invalid. . .' );
2800 END IF;
2801
2802 l_ret_status := FALSE ;
2803 END LOOP ;
2804
2805 ELSIF l_lot_number IS NULL
2806 AND l_from_wip_entity_id IS NULL
2807 AND l_to_wip_entity_id IS NULL
2808 AND l_from_cum_qty IS NULL
2809 THEN
2810
2811 IF Bom_Globals.Get_Debug = 'Y' THEN
2812 Error_Handler.Write_Debug('Parent revised item is not Eco by production. . .' );
2813 END IF;
2814
2815 NULL ;
2816
2817 -- ELSE
2818 -- l_ret_status := FALSE ;
2819 --
2820
2821 END IF ;
2822
2823 RETURN l_ret_status ;
2824
2825 END Check_RevCmp_In_ECO_By_WO ;
2826
2827
2828 /******************** Local Procedures End **********************/
2829
2830
2831 /******************************************************************
2832 * Procedure : Set_Item_Attributes
2833 * Purpose : Set the global attribute flags. This procedure is
2834 * called ONLY by the ECO FORM. The open interfaces
2835 * will perform this step in the Entity validation
2836 * procedure.
2837 **********************************************************************/
2838
2839 PROCEDURE Set_Item_Attributes
2840 ( p_RI_bom_item_type NUMBER
2841 , p_RC_bom_item_type NUMBER
2842 , p_RC_replenish_to_order_flag CHAR
2843 , p_RI_replenish_to_order_flag CHAR
2844 , p_RC_pick_components_flag CHAR
2845 , p_RI_pick_components_flag CHAR
2846 , p_RC_base_item_id NUMBER
2847 , p_RC_ato_forecast_control NUMBER
2848 , p_RI_base_item_id NUMBER
2849 , p_RC_eng_item_flag CHAR
2850 , p_RI_eng_item_flag CHAR
2851 , p_RC_atp_components_flag CHAR
2852 , p_RI_atp_components_flag CHAR
2853 , p_RC_atp_flag CHAR
2854 , p_RI_wip_supply_type NUMBER
2855 , p_RC_wip_supply_type NUMBER
2856 , p_RI_bom_enabled_flag CHAR
2857 , p_RC_bom_enabled_flag CHAR
2858 )
2859 IS
2860 BEGIN
2861
2862 IF p_RI_base_item_id IS NULL OR
2863 p_RI_base_item_id = 0
2864 THEN
2865 g_Assy_Config := 'N';
2866 ELSE
2867 g_Assy_Config := 'Y';
2868 END IF;
2869
2870 IF p_RC_base_item_id IS NULL OR
2871 p_RC_base_item_id = 0
2872 THEN
2873 g_Comp_Config := 'N';
2874 ELSE
2875 g_Comp_Config := 'Y';
2876 END IF;
2877
2878 g_Assy_Item_Type := p_RI_bom_item_type;
2879 g_Assy_PTO_flag := p_RI_pick_components_flag;
2880 g_Assy_ATO_flag := p_RI_replenish_to_order_flag;
2881 g_Assy_Wip_Supply_Type := p_RI_wip_supply_type;
2882 g_Assy_Eng_Flag := p_RI_eng_item_flag;
2883 g_Assy_ATP_Comp_flag := p_RI_atp_components_flag;
2884 g_Assy_Bom_Enabled_flag := p_RI_bom_enabled_flag;
2885 g_Comp_Item_Type := p_RC_bom_item_type;
2886 g_Comp_PTO_flag := p_RC_pick_components_flag;
2887 g_Comp_ATO_flag := p_RC_replenish_to_order_flag;
2888 g_Comp_Wip_Supply_Type := p_RC_wip_supply_type;
2889 g_Comp_Eng_Flag := p_RC_eng_item_flag;
2890 g_Comp_ATP_Comp_flag := p_RC_atp_components_flag;
2891 g_Comp_ATP_Check_flag := p_RC_atp_flag;
2892 g_Comp_Bom_Enabled_flag := p_RC_bom_enabled_flag;
2893 g_Comp_ATO_Forecast_Control := p_RC_ato_forecast_control;
2894 END Set_Item_Attributes;
2895
2896
2897
2898
2899
2900 FUNCTION Dereferenced_Bom(p_bill_sequence_id NUMBER)
2901 Return boolean
2902 IS
2903 l_deref_bom varchar2(1);
2904 BEGIN
2905 SELECT 'Y' into l_deref_bom
2906 FROM BOM_BILL_OF_MATERIALS
2907 WHERE bill_sequence_id = common_bill_sequence_id
2908 AND bill_sequence_id <> nvl(source_bill_sequence_id, common_bill_sequence_id)
2909 AND bill_sequence_id = p_bill_sequence_id;
2910 IF l_deref_bom = 'Y' THEN
2911 Return true;
2912 END IF;
2913 Return false;
2914 EXCEPTION
2915 WHEN NO_DATA_FOUND THEN
2916 return false;
2917 END;
2918
2919
2920 FUNCTION Is_Bill_Common(p_bill_sequence_id IN NUMBER)
2921 RETURN Boolean
2922 IS
2923 l_dummy VARCHAR2(1);
2924 BEGIN
2925 SELECT 'Y'
2926 INTO l_dummy
2927 FROM BOM_STRUCTURES_B
2928 WHERE BILL_SEQUENCE_ID = p_bill_sequence_id
2929 AND BILL_SEQUENCE_ID <> SOURCE_BILL_SEQUENCE_ID;
2930 Return true;
2931 EXCEPTION
2932 WHEN NO_DATA_FOUND THEN
2933 return false;
2934 END;
2935
2936
2937
2938 FUNCTION valid_common_bom_change( p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
2939 , p_Old_Rev_Component_Rec IN Bom_Bo_Pub.Rev_Component_Rec_Type)
2940 RETURN boolean
2941 IS
2942 BEGIN
2943 IF p_Old_Rev_Component_Rec.Organization_Code <> p_rev_component_rec.Organization_Code
2944 OR p_Old_Rev_Component_Rec.Revised_Item_Name <> p_rev_component_rec.Revised_Item_Name
2945 --OR p_Old_Rev_Component_Rec.New_revised_Item_Revision <> p_rev_component_rec.New_revised_Item_Revision
2946 --OR p_Old_Rev_Component_Rec.Start_Effective_Date <> p_rev_component_rec.Start_Effective_Date
2947 OR p_Old_Rev_Component_Rec.New_Effectivity_Date <> p_rev_component_rec.New_Effectivity_Date
2948 OR p_Old_Rev_Component_Rec.Disable_Date <> p_rev_component_rec.Disable_Date
2949 -- OR p_Old_Rev_Component_Rec.Operation_Sequence_Number <> p_rev_component_rec.Operation_Sequence_Number
2950 OR p_Old_Rev_Component_Rec.Component_Item_Name <> p_rev_component_rec.Component_Item_Name
2951 OR p_Old_Rev_Component_Rec.Alternate_BOM_Code <> p_rev_component_rec.Alternate_BOM_Code
2952 --OR p_Old_Rev_Component_Rec.ACD_Type <> p_rev_component_rec.ACD_Type
2953 OR p_Old_Rev_Component_Rec.Old_Effectivity_Date <> p_rev_component_rec.Old_Effectivity_Date
2954 OR p_Old_Rev_Component_Rec.Old_Operation_Sequence_Number <> p_rev_component_rec.Old_Operation_Sequence_Number
2955 OR p_Old_Rev_Component_Rec.New_Operation_Sequence_Number <> p_rev_component_rec.New_Operation_Sequence_Number
2956 OR p_Old_Rev_Component_Rec.Item_Sequence_Number <> p_rev_component_rec.Item_Sequence_Number
2957 OR p_Old_Rev_Component_Rec.Quantity_Per_Assembly <> p_rev_component_rec.Quantity_Per_Assembly
2958 OR p_Old_Rev_Component_Rec.Inverse_Quantity <> p_rev_component_rec.Inverse_Quantity
2959 OR p_Old_Rev_Component_Rec.Planning_Percent <> p_rev_component_rec.Planning_Percent
2960 OR p_Old_Rev_Component_Rec.Projected_Yield <> p_rev_component_rec.Projected_Yield
2961 -- OR p_Old_Rev_Component_Rec.Include_In_Cost_Rollup <> p_rev_component_rec.Include_In_Cost_Rollup
2962 OR p_Old_Rev_Component_Rec.So_Basis <> p_rev_component_rec.So_Basis
2963 OR p_Old_Rev_Component_Rec.Optional <> p_rev_component_rec.Optional
2964 OR p_Old_Rev_Component_Rec.Mutually_Exclusive <> p_rev_component_rec.Mutually_Exclusive
2965 OR p_Old_Rev_Component_Rec.Check_Atp <> p_rev_component_rec.Check_Atp
2966 OR p_Old_Rev_Component_Rec.Shipping_Allowed <> p_rev_component_rec.Shipping_Allowed
2967 OR p_Old_Rev_Component_Rec.Required_To_Ship <> p_rev_component_rec.Required_To_Ship
2968 OR p_Old_Rev_Component_Rec.Required_For_Revenue<> p_rev_component_rec.Required_For_Revenue
2969 OR p_Old_Rev_Component_Rec.Include_On_Ship_Docs <> p_rev_component_rec.Include_On_Ship_Docs
2970 OR p_Old_Rev_Component_Rec.Quantity_Related <> p_rev_component_rec.Quantity_Related
2971 OR p_Old_Rev_Component_Rec.Minimum_Allowed_Quantity <> p_rev_component_rec.Minimum_Allowed_Quantity
2972 OR p_Old_Rev_Component_Rec.Maximum_Allowed_Quantity <> p_rev_component_rec.Maximum_Allowed_Quantity
2973 OR p_Old_Rev_Component_Rec.comments <> p_rev_component_rec.comments
2974 OR p_Old_Rev_Component_Rec.cancel_comments <> p_rev_component_rec.cancel_comments
2975 OR p_Old_Rev_Component_Rec.Attribute_category <> p_rev_component_rec.Attribute_category
2976 OR p_Old_Rev_Component_Rec.Attribute1 <> p_rev_component_rec.Attribute1
2977 OR p_Old_Rev_Component_Rec.Attribute2 <> p_rev_component_rec.Attribute2
2978 OR p_Old_Rev_Component_Rec.Attribute3 <> p_rev_component_rec.Attribute3
2979 OR p_Old_Rev_Component_Rec.Attribute4 <> p_rev_component_rec.Attribute4
2980 OR p_Old_Rev_Component_Rec.Attribute5 <> p_rev_component_rec.Attribute5
2981 OR p_Old_Rev_Component_Rec.Attribute6 <> p_rev_component_rec.Attribute6
2982 OR p_Old_Rev_Component_Rec.Attribute7 <> p_rev_component_rec.Attribute7
2983 OR p_Old_Rev_Component_Rec.Attribute8 <> p_rev_component_rec.Attribute8
2984 OR p_Old_Rev_Component_Rec.Attribute9 <> p_rev_component_rec.Attribute9
2985 OR p_Old_Rev_Component_Rec.Attribute10 <> p_rev_component_rec.Attribute10
2986 OR p_Old_Rev_Component_Rec.Attribute11 <> p_rev_component_rec.Attribute11
2987 OR p_Old_Rev_Component_Rec.Attribute12 <> p_rev_component_rec.Attribute12
2988 OR p_Old_Rev_Component_Rec.Attribute13 <> p_rev_component_rec.Attribute13
2989 OR p_Old_Rev_Component_Rec.Attribute14 <> p_rev_component_rec.Attribute14
2990 OR p_Old_Rev_Component_Rec.Attribute15 <> p_rev_component_rec.Attribute15
2991 OR p_Old_Rev_Component_Rec.From_End_Item_Unit_Number <> p_rev_component_rec.From_End_Item_Unit_Number
2992 OR p_Old_Rev_Component_Rec.Old_From_End_Item_Unit_Number <> p_rev_component_rec.Old_From_End_Item_Unit_Number
2993 OR p_Old_Rev_Component_Rec.New_From_End_Item_Unit_Number <> p_rev_component_rec.New_From_End_Item_Unit_Number
2994 OR p_Old_Rev_Component_Rec.To_End_Item_Unit_Number <> p_rev_component_rec.To_End_Item_Unit_Number
2995 OR p_Old_Rev_Component_Rec.New_Routing_Revision <> p_rev_component_rec.New_Routing_Revision
2996 OR p_Old_Rev_Component_Rec.Enforce_Int_Requirements <> p_rev_component_rec.Enforce_Int_Requirements
2997 OR p_Old_Rev_Component_Rec.Auto_Request_Material <> p_rev_component_rec.Auto_Request_Material
2998 OR p_Old_Rev_Component_Rec.Suggested_Vendor_Name <> p_rev_component_rec.Suggested_Vendor_Name
2999 OR p_Old_Rev_Component_Rec.Unit_Price <> p_rev_component_rec.Unit_Price
3000 OR p_Old_Rev_Component_Rec.Original_System_Reference <> p_rev_component_rec.Original_System_Reference
3001 THEN return false;
3002 END IF;
3003 RETURN true;
3004 END;
3005
3006
3007
3008
3009 /******************************************************************
3010 * Procedure : Check_Entity
3011 * Parameters IN : Revised component exposed column record
3012 * Revised component unexposed column record
3013 * Revised component old exposed column record
3014 * Revised component old unexposed column record
3015 * Control record
3016 * Parameters OUT: Mesg _Token_Tbl
3017 * Return Status
3018 * Purpose : Check_Entity validate the entity for the correct
3019 * business logic. It will verify the values by running
3020 * checks on inter-dependent columns.
3021 * It will also verify that changes in one column value
3022 * does not invalidate some other columns.
3023 **********************************************************************/
3024 PROCEDURE Check_Entity
3025 ( x_return_status IN OUT NOCOPY VARCHAR2
3026 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
3027 , p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
3028 , p_Rev_Comp_Unexp_Rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
3029 , p_control_rec IN BOM_BO_PUB.Control_Rec_Type
3030 := BOM_BO_PUB.G_DEFAULT_CONTROL_REC
3031 , p_Old_Rev_Component_Rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
3032 , p_Old_Rev_Comp_Unexp_Rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
3033 )
3034 IS
3035 l_return_status VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
3036 l_bill_sequence_id NUMBER;
3037 l_processed BOOLEAN;
3038 l_result NUMBER;
3039 l_Err_Text VARCHAR2(2000);
3040 l_bom_item_type NUMBER;
3041 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
3042 l_is_comp_unit_Controlled BOOLEAN := FALSE;
3043 l_is_item_unit_controlled BOOLEAN := FALSE;
3044 l_debug_error_mesg VARCHAR2(2000);
3045 l_new_compare_date DATE;
3046 l_total_rds NUMBER;
3047 l_Token_Tbl Error_Handler.Token_Tbl_Type;
3048 l_Structure_Type_Name VARCHAR2(30);
3049
3050
3051 CURSOR c_RefDesgs IS
3052 SELECT count(component_sequence_id) number_of_desgs
3053 FROM bom_reference_designators
3054 WHERE component_sequence_id =
3055 p_rev_comp_unexp_rec.component_sequence_id;
3056
3057 CURSOR c_NewBill IS
3058 SELECT revised_item_id, change_notice, organization_id
3059 FROM eng_revised_items
3060 WHERE revised_item_sequence_id =
3061 p_rev_comp_Unexp_rec.revised_item_sequence_id;
3062
3063 CURSOR CheckForNew IS
3064 SELECT 'Valid'
3065 FROM eng_revised_items eri
3066 WHERE eri.revised_item_sequence_id =
3067 p_rev_comp_Unexp_rec.revised_item_sequence_id
3068 AND eri.bill_sequence_id IS NULL
3069 AND NOT EXISTS (SELECT 1
3070 FROM bom_bill_of_materials bom
3071 WHERE bom.bill_sequence_id =
3072 p_rev_comp_Unexp_rec.bill_sequence_id
3073 );
3074
3075 item_num_for_bill number := 0;
3076 CURSOR c_ItemDateNum IS
3077 SELECT 'Valid'
3078 FROM BOM_inventory_components
3079 WHERE item_num = p_rev_component_rec.item_sequence_number
3080 AND component_item_id <> p_rev_comp_unexp_rec.component_item_id
3081 AND trunc(effectivity_date) <=
3082 trunc(p_rev_component_rec.start_effective_date)
3083 AND nvl(trunc(disable_date),
3084 trunc(p_rev_component_rec.start_effective_date) + 1) >=
3085 trunc(p_rev_component_rec.start_effective_date)
3086 AND bill_sequence_id = p_Rev_Comp_Unexp_rec.bill_sequence_id;
3087
3088 CURSOR c_ItemUnitNum IS
3089 SELECT 'Valid'
3090 FROM BOM_inventory_components
3091 WHERE item_num = p_rev_component_rec.item_sequence_number
3092 AND component_item_id <> p_rev_comp_unexp_rec.component_item_id
3093 AND disable_date is NULL
3094 AND from_end_item_unit_number <=
3095 p_rev_component_rec.from_end_item_unit_number
3096 AND NVL(to_end_item_unit_number,
3097 p_rev_component_rec.from_end_item_unit_number) >=
3098 p_rev_component_rec.from_end_item_unit_number
3099 AND bill_sequence_id = p_Rev_Comp_Unexp_rec.bill_sequence_id;
3100
3101 l_bom_ifce_key VARCHAR2(80);
3102
3103 -------------------------------------------------
3104 -- Added since quantity cannot be fractional
3105 -- if OE is installed and revised item is
3106 -- ATO/PTO.
3107
3108 -- Fix made by AS 04/27/98
3109 -- Bug 651689
3110 -------------------------------------------------
3111 Is_OE_Installed VARCHAR2(1) := 'N';
3112
3113 -- Modified by MK on 11/13/00
3114 CURSOR c_OE_installed IS
3115 SELECT distinct 'I'
3116 FROM fnd_product_installations
3117 -- WHERE application_id = 300 -- Order Entry
3118 WHERE application_id = 660 -- ONT: Order Management
3119 AND status = 'I';
3120
3121 Is_Item_ATO VARCHAR2(1) := 'N';
3122 Is_Item_PTO VARCHAR2(1) := 'N';
3123
3124 CURSOR c_ATO_PTO IS
3125 SELECT replenish_to_order_flag, pick_components_flag
3126 FROM mtl_system_items
3127 WHERE inventory_item_id =
3128 p_rev_comp_unexp_rec.revised_item_id
3129 AND organization_id = p_rev_comp_unexp_rec.organization_id;
3130
3131 Cursor Unit_Controlled_Item IS
3132 SELECT effectivity_control
3133 FROM mtl_system_items
3134 WHERE inventory_item_id = p_rev_comp_unexp_rec.revised_item_id
3135 AND organization_id = p_rev_comp_unexp_rec.organization_id;
3136
3137 l_bill_to_end_number VARCHAR2(30);
3138 CURSOR c_To_End_Item_Number IS
3139 SELECT To_End_Item_Unit_Number
3140 FROM BOM_Inventory_Components
3141 WHERE component_sequence_id =
3142 g_rev_comp_unexp_rec.old_component_sequence_id;
3143
3144
3145 -- Added by MK on 02/02/2001
3146 -- Form has this validation LOV for Old Operation Sequence Number
3147 l_eco_for_production NUMBER ;
3148
3149 CURSOR old_comp_csr (p_old_comp_seq_id NUMBER ,
3150 p_eco_for_production NUMBER)
3151 IS
3152 SELECT 'Old Comp is invalid'
3153 FROM SYS.DUAL
3154 WHERE NOT EXISTS ( SELECT NULL
3155 FROM BOM_INVENTORY_COMPONENTS ic
3156 WHERE TRUNC(ic.effectivity_date) <=
3157 TRUNC(p_rev_component_rec.start_effective_date)
3158 AND NVL(ic.disable_date,
3159 TRUNC(p_rev_component_rec.start_effective_date)+1)
3160 > p_rev_component_rec.start_effective_date
3161 AND NVL(ic.disable_date , SYSDATE + 1) > SYSDATE
3162 AND NVL(ic.revised_item_sequence_id, -999)
3163 <> NVL(p_rev_comp_unexp_rec.revised_item_sequence_id, -100)
3164 AND NOT EXISTS (SELECT NULL
3165 FROM bom_inventory_components ic2
3166 WHERE ic2.revised_item_sequence_id
3167 = NVL(p_rev_comp_unexp_rec.revised_item_sequence_id,
3168 -888)
3169 AND decode(ic2.implementation_date,
3170 null,
3171 ic2.old_component_sequence_id,
3172 ic2.component_sequence_id) =
3173 decode(ic.implementation_date,
3174 null,
3175 ic.old_component_sequence_id,
3176 ic.component_sequence_id)
3177 AND ic2.component_sequence_id <>
3178 p_rev_comp_unexp_rec.component_sequence_id
3179 )
3180 AND (( p_eco_for_production = 2
3181 AND NVL(ic.eco_for_production, 2) <> 1 )
3182 OR (p_eco_for_production = 1
3183 AND ic.implementation_date IS NOT NULL
3184 )
3185 )
3186 AND ic.component_sequence_id = p_old_comp_seq_id
3187 ) ;
3188
3189 BEGIN
3190
3191 g_rev_component_rec := p_rev_component_rec;
3192 g_Rev_Comp_Unexp_Rec := p_Rev_Comp_Unexp_Rec;
3193
3194 /* 5134934 */
3195 -- Basis type cannot be Lot if there are existing Reference Desigantors.
3196 IF (p_rev_component_rec.transaction_type = Bom_Globals.G_OPR_UPDATE) THEN
3197
3198 If(p_rev_component_rec.Basis_type = 2) THEN
3199 select count(*) into l_total_rds from bom_reference_designators
3200 where nvl(p_rev_component_rec.acd_type,1) <>3 and component_sequence_id=p_Rev_Comp_Unexp_Rec.component_sequence_id;
3201 IF(l_total_rds <>0) THEN
3202 l_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
3203 l_Token_Tbl(1).Token_Value := p_rev_component_rec.component_item_name;
3204 Error_Handler.Add_Error_Token
3205 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3206 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3207 , p_message_name => 'BOM_LOT_BASED_RDS'
3208 , p_Token_Tbl => l_Token_Tbl
3209 );
3210 l_return_status := FND_API.G_RET_STS_ERROR;
3211 END IF;
3212 END IF;
3213 END IF;
3214
3215
3216
3217 IF Bom_Globals.Get_Debug = 'Y'
3218 THEN
3219 Error_Handler.Write_Debug('Performing Revised component Entity Validation. . .');
3220 END IF;
3221
3222 l_is_comp_unit_controlled := BOM_GLOBALS.Get_Unit_Controlled_Component;
3223 l_is_item_unit_controlled := BOM_GLOBALS.Get_Unit_Controlled_Item;
3224
3225 IF Bom_Globals.Get_Debug = 'Y' THEN
3226 Error_Handler.Write_Debug('Checked if revised item is unit controlled. . .');
3227 Error_Handler.Write_Debug('Org id: ' || to_char(g_rev_Comp_Unexp_Rec.Organization_Id));
3228 Error_Handler.Write_Debug('Item id: ' || to_char(g_rev_Comp_Unexp_Rec.revised_item_id));
3229 Error_Handler.Write_Debug('Comp id: ' || to_char(g_rev_Comp_Unexp_Rec.Component_item_id));
3230 Error_Handler.Write_Debug('Trans type: ' || g_rev_component_rec.transaction_type);
3231 END IF;
3232
3233 -- First Query all the attributes for the Assembly item and
3234 -- component item.
3235 SELECT assy.bom_item_type,
3236 assy.pick_components_flag,
3237 assy.replenish_to_order_flag,
3238 assy.wip_supply_type,
3239 DECODE(NVL(assy.base_item_id, 0), 0 , 'N', 'Y'),
3240 assy.eng_item_flag,
3241 assy.atp_components_flag,
3242 assy.atp_flag,
3243 assy.bom_enabled_flag,
3244 assy.effectivity_control, --2044133
3245 assy.tracking_quantity_ind,
3246 comp.bom_item_type,
3247 comp.pick_components_flag,
3248 comp.replenish_to_order_flag,
3249 comp.wip_supply_type,
3250 DECODE(NVL(comp.base_item_id, 0), 0 , 'N', 'Y'),
3251 comp.eng_item_flag,
3252 comp.atp_components_flag,
3253 comp.atp_flag,
3254 comp.bom_enabled_flag,
3255 comp.ato_forecast_control,
3256 comp.effectivity_control, --2044133
3257 comp.tracking_quantity_ind
3258 INTO g_Assy_Item_Type,
3259 g_Assy_PTO_flag,
3260 g_Assy_ATO_flag,
3261 g_Assy_Wip_Supply_Type,
3262 g_Assy_Config,
3263 g_Assy_Eng_Flag,
3264 g_Assy_ATP_Comp_flag,
3265 g_Assy_ATP_Check_flag,
3266 g_Assy_Bom_Enabled_flag,
3267 g_Assy_Effectivity_Control, --2044133
3268 G_Assy_Tracking_Quantity_Ind,
3269 g_Comp_Item_Type,
3270 g_Comp_PTO_flag,
3271 g_Comp_ATO_flag,
3272 g_Comp_Wip_Supply_Type,
3273 g_Comp_Config,
3274 g_Comp_Eng_Flag,
3275 g_Comp_ATP_Comp_flag,
3276 g_Comp_ATP_Check_flag,
3277 g_Comp_Bom_Enabled_flag,
3278 g_Comp_ATO_Forecast_Control,
3279 g_Comp_Effectivity_Control, --2044133
3280 G_Comp_Tracking_Quantity_Ind
3281 FROM mtl_system_items assy,
3282 mtl_system_items comp
3283 WHERE assy.organization_id = g_rev_Comp_Unexp_Rec.Organization_Id
3284 AND assy.inventory_item_id = g_rev_Comp_Unexp_Rec.revised_item_id
3285 AND comp.organization_id = g_rev_Comp_Unexp_Rec.Organization_Id
3286 AND comp.inventory_item_id = g_rev_Comp_Unexp_Rec.Component_item_id;
3287 -- dbms_output.put_line('Queried all assembly and component attributes. . .');
3288
3289
3290 --
3291 -- Set the assembly Type of the Assembly
3292 --
3293
3294 IF Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
3295 THEN
3296 select assembly_type
3297 into g_Assy_Assembly_Type
3298 --bug: 4161794. Introduced new global variable to hold value of assembly type
3299 -- of the header.
3300 from bom_bill_of_materials
3301 where bill_sequence_id = p_rev_comp_Unexp_rec.bill_sequence_id;
3302 END IF;
3303
3304 --
3305 -- Set the 1st token of Token Table to Revised Component value
3306 --
3307 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
3308 g_Token_Tbl(1).Token_Value := p_rev_component_rec.component_item_name;
3309
3310 -- The ECO can be updated but a warning needs to be generated and
3311 -- scheduled revised items need to be update to Open
3312 -- and the ECO status need to be changed to Not Submitted for Approval
3313
3314
3315 IF Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3316 THEN
3317 BOM_GLOBALS.Check_Approved_For_Process
3318 (p_change_notice => p_rev_component_rec.eco_name,
3319 p_organization_id => p_rev_comp_unexp_rec.organization_id,
3320 x_processed => l_processed,
3321 x_err_text => l_err_text
3322 );
3323 IF l_processed = TRUE
3324 THEN
3325 -- If the above process returns true then set the ECO approval.
3326 BEGIN
3327 BOM_GLOBALS.Set_Request_For_Approval
3328 (p_change_notice =>
3329 p_rev_component_rec.eco_name,
3330 p_organization_id =>
3331 p_rev_comp_unexp_rec.organization_id,
3332 x_err_text => l_err_text
3333 );
3334
3335 EXCEPTION
3336 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3337 l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3338 END;
3339 END IF;
3340 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check Eco Status . . .' || l_return_status); END IF;
3341
3342 -- Added by MK on 01/26/2001 for ECO New Effectivities
3343 -- Verify the ECO Effectivity, If ECO by WO, Lot Num, Or Cum Qty, then
3344 -- Check if the component exists in the WO or Lot Num.
3345 --
3346 IF p_rev_component_rec.transaction_type = BOM_Globals.G_OPR_CREATE
3347 AND p_rev_component_rec.acd_type IN (2 , 3) -- Change or Disable
3348 THEN
3349
3350 IF NOT Check_RevCmp_In_ECO_By_WO
3351 ( p_revised_item_sequence_id => p_rev_comp_unexp_rec.revised_item_sequence_id
3352 , p_rev_comp_item_id => p_rev_comp_unexp_rec.component_item_id
3353 , p_operation_seq_num => p_rev_component_rec.old_operation_sequence_number
3354 , p_organization_id => p_rev_comp_unexp_rec.organization_id
3355 , p_rev_item_id => p_rev_comp_unexp_rec.revised_item_id
3356 )
3357 THEN
3358 g_token_tbl.delete;
3359 g_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
3360 g_token_tbl(1).token_value := p_rev_component_rec.revised_item_name;
3361 g_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
3362 g_token_tbl(2).token_value :=
3363 g_rev_component_rec.component_item_name;
3364
3365 Error_Handler.Add_Error_Token
3366 ( p_message_name => 'BOM_CMP_RIT_ECO_WO_EFF_INVALID'
3367 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3368 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3369 , p_token_tbl => g_token_tbl
3370 );
3371 l_return_status := FND_API.G_RET_STS_ERROR;
3372 g_token_tbl.delete;
3373 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
3374 g_Token_Tbl(1).Token_Value := p_rev_component_rec.component_item_name;
3375 END IF ;
3376 IF Bom_Globals.Get_Debug = 'Y' THEN
3377 Error_Handler.Write_Debug('Check if the rev component is valid in Eco by Prod. . .' || l_return_status);
3378 END IF;
3379 END IF ;
3380
3381
3382 END IF; -- validations called by only ECO BO
3383 -- To End Item Unit Number must be greater than or equal to
3384 -- From End Item Unit Number
3385
3386 IF (p_rev_component_rec.To_End_Item_Unit_Number IS NOT NULL AND
3387 p_rev_component_rec.To_End_Item_Unit_Number <> FND_API.G_MISS_CHAR AND
3388 p_rev_component_rec.From_End_Item_Unit_Number IS NOT NULL AND
3389 p_rev_component_rec.From_End_Item_Unit_Number <> FND_API.G_MISS_CHAR
3390 )
3391 AND
3392 (p_rev_component_rec.From_End_Item_Unit_Number > p_rev_component_rec.To_End_Item_Unit_Number)
3393 THEN
3394 g_token_tbl.delete;
3395 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3396 g_token_tbl(1).token_value :=
3397 g_rev_component_rec.component_item_name;
3398 Error_Handler.Add_Error_Token
3399 ( p_message_name => 'BOM_TOUNIT_LESS_THAN_FROMUNIT'
3400 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3401 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3402 , p_token_tbl => g_token_tbl
3403 );
3404
3405 l_return_status := FND_API.G_RET_STS_ERROR;
3406
3407 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check to end item unit number. . .' || l_return_status); END IF;
3408
3409 END IF;
3410
3411 --
3412 -- Verify that the Parent is BOM Enabled
3413 --
3414 IF g_Assy_Bom_Enabled_flag <> 'Y'
3415 THEN
3416 g_token_tbl.delete;
3417 g_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
3418 g_token_tbl(1).token_value :=
3419 g_rev_component_rec.revised_item_name;
3420
3421 Error_Handler.Add_Error_Token
3422 ( p_message_name => 'BOM_REV_ITEM_BOM_NOT_ENABLED'
3423 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3424 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3425 , p_token_tbl => g_token_tbl
3426 );
3427
3428 l_return_status := FND_API.G_RET_STS_ERROR;
3429 /* g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3430 g_token_tbl(1).token_value :=
3431 p_rev_component_rec.component_item_name;*/
3432
3433 END IF;
3434
3435
3436 --
3437 -- All validations that only apply to Operation Type CREATE
3438 --
3439 IF p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE THEN
3440
3441 -- When disabling a component, to end item number must be the same
3442 -- as the value in the bill component being disabled.
3443
3444 IF NVL(g_rev_component_rec.acd_type, 1) = 3 AND
3445 l_is_comp_unit_controlled
3446 THEN
3447 FOR To_End_Item_Number IN c_To_End_Item_Number
3448 LOOP
3449 l_bill_to_end_number :=
3450 To_End_Item_Number.To_End_Item_Unit_Number;
3451 END LOOP;
3452
3453 IF l_bill_to_end_number <>
3454 p_rev_component_rec.to_end_item_unit_number
3455 THEN
3456 g_token_tbl.delete;
3457 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3458 g_token_tbl(1).token_value :=
3459 g_rev_component_rec.component_item_name;
3460
3461 Error_Handler.Add_Error_Token
3462 ( p_message_name => 'BOM_DISABLE_TOUNIT_INVALID'
3463 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3464 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3465 , p_token_tbl => g_token_tbl
3466 );
3467
3468 l_return_status := FND_API.G_RET_STS_ERROR;
3469 END IF;
3470 END IF;
3471 -- Component can be unit controlled only if parent revised item is
3472 -- unit controlled.
3473 -- Added by AS on 07/08/99 as part of unit effectivity changes
3474
3475 -- Bug 2044133 Fix Begin
3476 -- IF NVL(g_rev_component_rec.acd_type, 1) = 1 AND
3477 -- l_is_comp_unit_controlled AND
3478 -- NOT l_is_item_unit_controlled
3479 IF NVL(g_rev_component_rec.acd_type, 1) = 1 AND
3480 g_Assy_Effectivity_Control = 1 AND
3481 g_Comp_Effectivity_Control = 2
3482 -- Bug 2044133 Fix End
3483
3484 THEN
3485 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3486 g_token_tbl(1).token_value :=
3487 g_rev_component_rec.component_item_name;
3488 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
3489 g_token_tbl(2).token_value :=
3490 g_rev_component_rec.revised_item_name;
3491
3492 Error_Handler.Add_Error_Token
3493 ( p_message_name => 'BOM_CMP_UNIT_RIT_NOT_UNIT'
3494 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3495 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3496 , p_token_tbl => g_token_tbl
3497 );
3498
3499 l_return_status := FND_API.G_RET_STS_ERROR;
3500 END IF;
3501 -- Unit controlled revised items can only have non-ATO or non-PTO
3502 -- standard items as components.
3503 -- Added by AS on 07/08/99 as part of unit effectivity changes
3504
3505 IF NVL(g_rev_component_rec.acd_type, 1) = 1 AND
3506 l_is_comp_unit_controlled AND
3507 (g_comp_item_type <> 4 OR
3508 g_comp_ato_flag = 'Y' OR
3509 g_comp_pto_flag = 'Y')
3510 THEN
3511 g_token_tbl.delete;
3512 g_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
3513 g_token_tbl(1).token_value :=
3514 g_rev_component_rec.revised_item_name;
3515
3516 Error_Handler.Add_Error_Token
3517 ( p_message_name => 'BOM_CMP_UNIT_TYPE_NOT_VALID'
3518 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3519 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3520 , p_token_tbl => g_token_tbl
3521 );
3522
3523 l_return_status := FND_API.G_RET_STS_ERROR;
3524 END IF;
3525 --
3526 -- Verify that the Parent has BOM Enabled
3527 --
3528 --Moved this check out, so that its applicable for all transaction types
3529 /* IF g_Assy_Bom_Enabled_flag <> 'Y'
3530 THEN
3531 g_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
3532 g_token_tbl(1).token_value :=
3533 g_rev_component_rec.revised_item_name;
3534
3535 Error_Handler.Add_Error_Token
3536 ( p_message_name => 'BOM_REV_ITEM_BOM_NOT_ENABLED'
3537 , p_mesg_token_tbl => l_Mesg_Token_Tbl
3538 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3539 , p_token_tbl => g_token_tbl
3540 );
3541
3542 l_return_status := FND_API.G_RET_STS_ERROR;
3543 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3544 g_token_tbl(1).token_value :=
3545 p_rev_component_rec.component_item_name;
3546
3547 END IF; */
3548 IF NOT Check_PrimaryBill AND Nvl(Bom_Globals.Get_Validate_For_Plm,'N') = 'N'
3549 THEN
3550 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('ACD type to be add if primary bill does not exist . . .'); END IF;
3551 IF NVL(p_rev_component_rec.acd_type, 1) <> 1 AND
3552 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3553 THEN
3554 /*****************************************************
3555 --
3556 -- If the primary bill does not exist then the acd type
3557 -- of the component cannot be other that add.
3558 --
3559 ******************************************************/
3560 IF FND_MSG_PUB.Check_Msg_Level
3561 (FND_MSG_PUB.G_MSG_LVL_ERROR)
3562 THEN
3563 Error_Handler.Add_Error_Token
3564 ( p_message_name => 'BOM_CMP_ACD_TYPE_ADD'
3565 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3566 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3567 , p_token_tbl => g_token_tbl
3568 );
3569 END IF;
3570 l_return_status := FND_API.G_RET_STS_ERROR;
3571 END IF;
3572
3573 END IF; -- End checking of ACD Type
3574
3575 -- Component cannot be added if the Bill is referencing another
3576 -- bill as common
3577 BEGIN
3578 SELECT 'Valid'
3579 INTO l_dummy
3580 FROM bom_bill_of_materials bom
3581 WHERE bom.bill_sequence_id = p_rev_comp_unexp_rec.bill_sequence_id
3582 AND bom.source_bill_sequence_id <> bom.bill_sequence_id
3583 AND nvl(p_rev_component_rec.acd_type, 1) in (1,3);
3584 --Dont reject updates outright. Some updates are allowed on Common BOM.
3585 --This is for updates through CO.
3586
3587 -- If no exception is raised then Bill is referencing another
3588 -- bill
3589
3590 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3591 THEN
3592 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
3593 g_token_tbl(2).token_value :=
3594 p_rev_component_rec.revised_item_name;
3595 Error_Handler.Add_Error_Token
3596 ( p_Message_Name => 'BOM_BILL_COMMON'
3597 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3598 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3599 , p_Token_Tbl => g_Token_Tbl
3600 );
3601 END IF;
3602 l_return_status := FND_API.G_RET_STS_ERROR;
3603 -- END IF;
3604
3605 EXCEPTION
3606 WHEN NO_DATA_FOUND THEN
3607 --if the acd type is update, check if its a valid common bom update
3608 IF nvl(p_rev_component_rec.acd_type, 1) in (1,3)
3609 OR (nvl(p_rev_component_rec.acd_type, 1) = 2
3610 AND valid_common_bom_change( p_rev_component_rec => p_rev_component_rec
3611 , p_Old_Rev_Component_Rec => p_Old_Rev_Component_Rec))
3612 OR not Is_Bill_Common(p_bill_sequence_id =>
3613 p_rev_comp_unexp_rec.bill_sequence_id)
3614 THEN
3615 NULL;
3616 ELSE
3617 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3618 THEN
3619 g_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
3620 g_token_tbl(2).token_value :=
3621 p_rev_component_rec.revised_item_name;
3622 Error_Handler.Add_Error_Token
3623 ( p_Message_Name => 'BOM_BILL_COMMON'
3624 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3625 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3626 , p_Token_Tbl => g_Token_Tbl
3627 );
3628 END IF;
3629 l_return_status := FND_API.G_RET_STS_ERROR;
3630 END IF;
3631 WHEN OTHERS THEN
3632 IF FND_MSG_PUB.Check_Msg_Level
3633 (FND_MSG_PUB.G_MSG_LVL_ERROR)
3634 THEN
3635 Error_Handler.Add_Error_Token
3636 ( p_message_name => NULL
3637 , p_message_text => 'Common Bill Check ' ||
3638 SUBSTR(SQLERRM, 1, 30) || ' '||
3639 TO_CHAR(SQLCODE)
3640 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3641 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3642 );
3643 END IF;
3644 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
3645 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3646
3647 END; -- Check if parent Common Ends
3648
3649 /*****************************************************************
3650 --
3651 -- Verify that the component item and revised item are not the same
3652 --
3653 ******************************************************************/
3654 IF p_rev_comp_unexp_rec.revised_item_id =
3655 p_rev_comp_unexp_rec.component_item_id
3656 THEN
3657 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3658 THEN
3659 g_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
3660 g_token_tbl(1).token_value :=
3661 g_rev_component_rec.revised_item_name;
3662
3663 Error_Handler.Add_Error_Token
3664 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3665 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3666 , p_Message_name => 'BOM_COMP_SAME_AS_BILL'
3667 , p_token_tbl => g_token_tbl
3668 );
3669 END IF;
3670 l_return_status := FND_API.G_RET_STS_ERROR;
3671 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3672 g_token_tbl(1).token_value :=
3673 p_rev_component_rec.component_item_name;
3674
3675 END IF;
3676
3677 /*************************************************************
3678 --
3679 -- Verify BOM_Enabled_Flag of the component being added.
3680 -- Only components with value Yes can be added.
3681 --
3682 **************************************************************/
3683 /* This validation will not be required anymore as items which are not BOM allowed can
3684 be components, but will just not be able to have BOMs --- Deepu
3685 */
3686 /*Uncommented for bug 5925020*/
3687
3688 IF g_Comp_Bom_Enabled_Flag = 'N' THEN
3689 -- Bom_Enabled is N, so cannot add a component .
3690 -- Check if ACD type is not Disable or Update
3691 IF( nvl(p_rev_component_rec.acd_type, 1) NOT IN (2 , 3)) THEN -- Change or Disable
3692 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3693 THEN
3694 Error_Handler.Add_Error_Token
3695 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3696 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3697 , p_Message_name => 'BOM_COMP_ITEM_BOM_NOT_ENABLED'
3698 , p_token_tbl => g_token_tbl
3699 );
3700 END IF;
3701 l_return_status := FND_API.G_RET_STS_ERROR;
3702 END IF;
3703 END IF;
3704
3705
3706 /*******************************************************************
3707 --
3708 -- Item Num Check
3709 --
3710 ********************************************************************/
3711 IF p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE
3712 AND
3713 ( NVL(p_rev_component_rec.acd_type,1) = 1 OR
3714 ( p_rev_component_rec.acd_type = 2 AND
3715 p_rev_component_rec.item_sequence_number <>
3716 p_old_rev_component_rec.item_sequence_number
3717 )
3718 )
3719 AND
3720 ((p_Control_rec.caller_type = 'FORM' AND
3721 p_control_rec.validation_controller = 'ITEM_SEQUENCE_NUMBER')
3722 OR
3723 p_control_rec.caller_type <> 'FORM')
3724 THEN
3725 -- Verify if a component is already added using this item_num
3726 -- If there is, log a WARNING.
3727
3728 item_num_for_bill := 0;
3729 g_Token_Tbl.Delete;
3730 g_token_tbl(1).token_name := 'ITEM_SEQUENCE_NUMBER';
3731 g_token_tbl(1).token_value := p_rev_component_rec.item_sequence_number;
3732 g_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
3733 g_token_tbl(2).token_value := p_rev_component_rec.component_item_name;
3734
3735 IF NOT l_is_item_unit_controlled
3736 THEN
3737 FOR Item_Num in c_ItemDateNum LOOP
3738 item_num_for_bill := 1;
3739 END LOOP;
3740 ELSE
3741 FOR Item_Num in c_ItemUnitNum LOOP
3742 item_num_for_bill := 1;
3743 END LOOP;
3744 END IF;
3745
3746 IF item_num_for_bill = 1 THEN
3747 Error_Handler.Add_Error_Token
3748 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3749 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3750 , p_message_name => 'BOM_ITEM_NUM_NOT_UNIQUE'
3751 , p_Token_Tbl => g_Token_Tbl
3752 , p_message_type => 'W'
3753 );
3754 END IF;
3755
3756 END IF; -- Item Num Check ends
3757
3758
3759 /********************************************************************
3760 --
3761 -- Also verify that the component being added is not a Product Family
3762 --
3763 *********************************************************************/
3764
3765 g_token_tbl.delete;
3766 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
3767 g_token_tbl(1).token_value :=
3768 g_rev_component_rec.component_item_name;
3769
3770 IF g_Comp_Item_Type = 5
3771 THEN
3772 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3773 THEN
3774 Error_Handler.Add_Error_Token
3775 ( p_message_name => 'BOM_ITEM_PRODUCT_FAMILY'
3776 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3777 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3778 , p_token_tbl => g_token_tbl
3779 );
3780 END IF;
3781
3782 END IF ; -- Product Family Check Ends
3783 IF NOT Verify_Item_Attributes( p_Mesg_token_Tbl => l_Mesg_Token_Tbl
3784 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3785 )
3786 THEN
3787 l_return_status := FND_API.G_RET_STS_ERROR;
3788 END IF;
3789
3790 IF BOM_Globals.get_debug = 'Y' THEN
3791 error_handler.write_debug('Check Item Attribute Validation. . .' || l_Return_Status );
3792 END IF;
3793
3794 --
3795 -- Verify if the revised item is being referenced as common in
3796 -- other orgs then it satisfies all the criteria required for the
3797 -- component to be on the bill.
3798 --
3799 l_result := Check_Common_Other_Orgs;
3800
3801 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check Common_Other_Orgs returned with result ' || to_char(l_result)); END IF;
3802
3803 IF l_result <> 0
3804 THEN
3805 IF l_result = 1
3806 THEN
3807 l_err_text := 'BOM_COMP_NOTEXIST_IN_OTHER_ORG';
3808 ELSIF l_result = 2 THEN
3809 l_err_text := 'BOM_COMP_NOT_BOMENABLED';
3810 ELSIF l_result = 3 THEN
3811 l_err_text := 'BOM_COMP_NOT_ENG_IN_OTHER_ORGS';
3812 /*ELSIF l_result = 4 THEN
3813 l_err_text := 'BOM_COMMON_OP_SEQ_INVALID';*/
3814 END IF;
3815
3816 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3817 THEN
3818 Error_Handler.Add_Error_Token
3819 ( p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3820 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3821 , p_message_name => l_err_text
3822 , p_token_tbl => g_token_tbl
3823 );
3824 END IF;
3825 l_return_status := FND_API.G_RET_STS_ERROR;
3826 END IF; -- Check if exists in other orgs if common Ends
3827
3828 END IF; -- End of Operation Type CREATE
3829
3830 /**************************************************************************
3831 --
3832 -- Operations specific to the Transaction Type of Update
3833 --
3834 **************************************************************************/
3835
3836 IF p_control_rec.caller_type <> 'FORM' AND
3837 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
3838 THEN
3839
3840 --
3841 -- Verify that the user is not trying to Update non-updateable columns
3842 --
3843 IF p_Old_Rev_Component_Rec.Shipping_Allowed <>
3844 p_rev_component_rec.shipping_allowed
3845 THEN
3846 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3847 THEN
3848 Error_Handler.Add_Error_Token
3849 ( p_message_name => 'BOM_SHIP_ALLOWED_NOT_UPDATE'
3850 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3851 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3852 , p_token_tbl => g_token_tbl
3853 );
3854 END IF;
3855 l_return_status := FND_API.G_RET_STS_ERROR;
3856 END IF;
3857
3858 --Since now we can update some attributes of common bills as well,
3859 --ensure that:
3860 --1. These updates on common bills are allowed
3861 --2. No other attribute other than material conrol attrs gets updated in common bills
3862
3863
3864 IF dereferenced_bom(p_rev_comp_unexp_rec.bill_sequence_id)
3865 THEN
3866 IF valid_common_bom_change(p_rev_component_rec => p_rev_component_rec,
3867 p_Old_Rev_Component_Rec=>p_Old_Rev_Component_Rec)
3868 AND p_rev_component_rec.transaction_type = BOM_Globals.G_OPR_UPDATE
3869 THEN
3870 --if the change on common bom is only in the wip attributes,
3871 --allow it.
3872 NULL;
3873 ELSE
3874 Error_Handler.Add_Error_Token
3875 ( p_message_name => 'BOM_INVALID_COMMON_BOM_CHANGE'
3876 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3877 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3878 , p_token_tbl => g_token_tbl
3879 );
3880 l_return_status := FND_API.G_RET_STS_ERROR;
3881 END IF;
3882 END IF;
3883
3884 /*******************************************************************
3885 -- Bug:4240031
3886 -- Checks whether component operations exist when changing Optional
3887 -- from Yes to No
3888 --
3889 *******************************************************************/
3890 IF Check_Optional_For_Comp_Ops
3891 THEN
3892 g_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
3893 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
3894 Error_Handler.Add_Error_Token
3895 ( p_message_name => 'BOM_COMP_OPERATION_EXIST'
3896 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3897 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3898 , p_token_tbl => g_token_tbl
3899 );
3900 l_return_status := FND_API.G_RET_STS_ERROR;
3901 END IF;
3902
3903
3904 /*******************bug:4240031 ends here***********************************/
3905
3906 IF p_rev_component_rec.old_effectivity_date IS NOT NULL AND
3907 p_rev_component_rec.old_effectivity_date <> FND_API.G_MISS_DATE AND
3908 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3909 THEN
3910 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3911 THEN
3912 Error_Handler.Add_Error_Token
3913 ( p_message_name => 'BOM_OLD_EFFECTIVITY_GIVEN'
3914 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3915 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3916 , p_token_tbl => g_token_tbl
3917 );
3918 END IF;
3919 l_return_status := FND_API.G_RET_STS_ERROR;
3920
3921 END IF;
3922
3923 IF p_rev_component_rec.old_operation_sequence_number IS NOT NULL AND
3924 p_rev_component_rec.old_operation_sequence_number <>
3925 FND_API.G_MISS_NUM AND
3926 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3927 THEN
3928 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3929 THEN
3930 Error_Handler.Add_Error_Token
3931 ( p_message_name => 'BOM_OLD_OP_SEQ_NUM_GIVEN'
3932 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3933 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3934 , p_token_tbl => g_token_tbl
3935 );
3936 END IF;
3937 l_return_status := FND_API.G_RET_STS_ERROR;
3938
3939 END IF;
3940 --
3941 -- ACD Type not updateable
3942 --
3943 IF p_rev_component_rec.acd_type <>
3944 p_old_rev_component_rec.acd_type AND
3945 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3946 THEN
3947 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3948 THEN
3949 Error_Handler.Add_Error_Token
3950 ( p_message_name => 'BOM_ACD_TYPE_NOT_UPDATEABLE'
3951 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3952 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3953 , p_token_tbl => g_token_tbl
3954 );
3955 END IF;
3956 l_return_status := FND_API.G_RET_STS_ERROR;
3957 END IF;
3958
3959 --
3960 -- Verify that the user is not trying to update a component which
3961 -- is Disabled on the ECO
3962 --
3963 IF p_old_rev_component_rec.acd_type = 3 AND
3964 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
3965 THEN
3966 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3967 THEN
3968 Error_Handler.Add_Error_Token
3969 ( p_message_name => 'BOM_COMPONENT_DISABLED'
3970 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3971 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3972 , p_token_tbl => g_token_tbl
3973 );
3974 END IF;
3975 l_return_status := FND_API.G_RET_STS_ERROR;
3976 END IF;
3977
3978 -- User cannot update to_end_item_unit_number when the component
3979 -- is disabled.
3980
3981 IF NVL(p_rev_component_rec.acd_type, 1) = 3 AND
3982 p_rev_component_rec.to_end_item_unit_number <>
3983 p_old_rev_component_rec.to_end_item_unit_number
3984 THEN
3985 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3986 THEN
3987 Error_Handler.Add_Error_Token
3988 ( p_message_name => 'BOM_DISABLE_TOUNIT_NONUPD'
3989 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3990 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3991 , p_token_tbl => g_token_tbl
3992 );
3993 END IF;
3994 l_return_status := FND_API.G_RET_STS_ERROR;
3995 END IF;
3996
3997 END IF; /* Operation UPDATE ENDS */
3998
3999 /*************************************************************************
4000 --
4001 -- All operations that would be common for Create and Update with slight
4002 --variation in
4003 -- checks.
4004 --
4005 **************************************************************************/
4006 IF p_rev_component_rec.Transaction_Type IN
4007 (BOM_GLOBALS.G_OPR_CREATE, BOM_GLOBALS.G_OPR_UPDATE)
4008 THEN
4009 /*********************************************************************
4010 --
4011 -- Verify yield factor
4012 -- IF Component is Option Class or bill is planning
4013 -- then yield must be 1
4014 -- If yield is >0 and less than 1 then give a warning.
4015 --
4016 *********************************************************************/
4017 IF ((p_control_rec.caller_type = 'FORM' AND
4018 p_control_rec.validation_controller = 'YIELD')
4019 OR
4020 p_control_rec.caller_type <> 'FORM')
4021 AND
4022 p_rev_component_rec.projected_yield <> 1 THEN
4023 IF g_assy_item_type = 3 -- Planning parent
4024 OR
4025 g_comp_item_type = 2 -- Option Class component
4026 THEN
4027 IF FND_MSG_PUB.Check_Msg_Level
4028 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4029 THEN
4030 g_token_tbl(2).token_name :=
4031 'REVISED_ITEM_NAME';
4032 g_token_tbl(2).token_value :=
4033 g_rev_component_Rec.revised_item_name;
4034 Error_Handler.Add_Error_Token
4035 ( p_Message_Name => 'BOM_COMP_YIELD_NOT_ONE'
4036 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4037 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4038 , p_Token_Tbl => g_Token_Tbl
4039 );
4040 g_token_tbl.delete(2);
4041 END IF;
4042 l_return_status := FND_API.G_RET_STS_ERROR;
4043 END IF;
4044
4045 IF p_rev_component_rec.projected_yield <=0
4046 THEN
4047 IF FND_MSG_PUB.Check_Msg_Level
4048 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4049 THEN
4050 g_token_tbl(2).token_name :=
4051 'REVISED_ITEM_NAME';
4052 g_token_tbl(2).token_value :=
4053 g_rev_component_Rec.revised_item_name;
4054 Error_Handler.Add_Error_Token
4055 ( p_Message_Name => 'BOM_COMP_YIELD_NOT_NEGATIVE'
4056 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4057 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4058 , p_Token_Tbl => g_Token_Tbl
4059 );
4060 g_token_tbl.delete(2);
4061 END IF;
4062 l_return_status := FND_API.G_RET_STS_ERROR;
4063 END IF;
4064
4065 IF p_rev_component_rec.projected_yield > 1
4066 THEN
4067 IF FND_MSG_PUB.Check_Msg_Level
4068 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4069 THEN
4070 -- Log warning
4071
4072 Error_Handler.Add_Error_Token
4073 ( p_Message_Name => 'BOM_YIELD_WARNING'
4074 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4075 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4076 , p_message_type => 'W'
4077 );
4078 END IF;
4079 END IF;
4080 END IF;
4081
4082 -- BASIS type should be 2 or null
4083
4084 IF not(p_rev_component_rec.BASIS_TYPE is null or p_rev_component_rec.BASIS_TYPE=2
4085 or p_rev_component_rec.BASIS_TYPE =FND_API.G_MISS_NUM)
4086 THEN
4087 Error_Handler.Add_Error_Token
4088 ( p_Message_Name => 'BOM_BASIS_TYPE_INVALID'
4089 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4090 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4091 , p_message_type => 'E'
4092 );
4093 l_return_status := FND_API.G_RET_STS_ERROR;
4094 END IF;
4095
4096 -- Validations Related to Basis Type : Basis_type can not be lot if the
4097 -- WIP supply type is Phantom. Basis_type can not be lot for Model/OC items
4098
4099 IF (p_rev_component_rec.WIP_SUPPLY_TYPE =6 AND p_rev_component_rec.BASIS_TYPE=2)
4100 THEN
4101 Error_Handler.Add_Error_Token
4102 ( p_Message_Name => 'BOM_LOT_BASED_PHANTOM'
4103 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4104 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4105 , p_message_type => 'E'
4106 );
4107 l_return_status := FND_API.G_RET_STS_ERROR;
4108 END IF;
4109
4110 -- For Components of PTO Kits, Models, Option Classes, Basis type should be item.
4111 IF(g_Assy_PTO_flag ='Y' and p_rev_component_rec.BASIS_TYPE=2) then
4112 Error_Handler.Add_Error_Token
4113 ( p_Message_Name => 'BOM_LOT_BASED_PTO'
4114 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4115 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4116 , p_message_type => 'E'
4117 );
4118 l_return_status := FND_API.G_RET_STS_ERROR;
4119 END IF;
4120
4121 --For ATO model, option class bills, optional,model,option class
4122 -- components should not be lot based.
4123 IF ( p_rev_component_rec.BASIS_TYPE=2
4124 and (p_rev_component_rec.OPTIONAL=1
4125 or g_Comp_Item_Type in (Bom_Globals.G_MODEL, Bom_Globals.G_OPTION_CLASS) )) THEN
4126 Error_Handler.Add_Error_Token
4127 ( p_Message_Name => 'BOM_LOT_BASED_ATO'
4128 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4129 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4130 , p_message_type => 'E'
4131 );
4132 l_return_status := FND_API.G_RET_STS_ERROR;
4133 END IF;
4134
4135 /* Validations for OPM convergence Project, Dual UOM tracking items should not be allowed
4136 for updates and creates */
4137 IF (G_Assy_Tracking_Quantity_Ind <>'P' or G_Comp_Tracking_Quantity_Ind <>'P') then
4138 Error_Handler.Add_Error_Token
4139 ( p_Message_Name => 'BOM_DUAL_UOM_ITEMS'
4140 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4141 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4142 , p_message_type => 'E'
4143 );
4144 l_return_status := FND_API.G_RET_STS_ERROR;
4145 END IF;
4146
4147 IF p_control_rec.caller_type <> 'FORM'
4148 THEN
4149 --
4150 -- Verify that the disable date is greater than effectivity date
4151 -- for both operations Create and Update
4152 --
4153
4154 -- If the transaction type is CREATE, then the new_effective_date column is
4155 -- ignored.
4156 -- but if the transaction type is update, then the new_effectivity_date can be
4157 -- used to update the effectivity date of a future effective component to bring it closer
4158 -- in its effectivity cyle. In this the validation for Insert and Update will differ
4159 -- If the new_effectivity_date col is not null and missing then it must be greater or =
4160 -- to SYSDATE.
4161 -- Also, disable_date must be greater or equal to the new_effective_date
4162 IF p_rev_component_rec.transaction_type in (BOM_GLOBALS.G_OPR_CREATE,
4163 BOM_GLOBALS.G_OPR_UPDATE) AND
4164 p_rev_component_rec.disable_date <
4165 p_rev_component_rec.start_effective_date THEN
4166 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4167 THEN
4168 Error_Handler.Add_Error_Token
4169 ( p_message_name => 'BOM_COMP_DIS_DATE_INVALID'
4170 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4171 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4172 , p_Token_Tbl => g_Token_Tbl
4173 );
4174 END IF;
4175 l_return_status := FND_API.G_RET_STS_ERROR;
4176
4177 ELSIF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_UPDATE AND
4178 p_rev_component_rec.new_effectivity_date IS NOT NULL AND
4179 p_rev_component_rec.new_effectivity_date <> FND_API.G_MISS_DATE AND
4180 (
4181 -- p_rev_component_rec.new_effectivity_date < SYSDATE OR -- Bug3281414
4182 p_rev_component_rec.disable_date < p_rev_component_rec.new_effectivity_date
4183 )
4184 THEN
4185 Error_Handler.Add_Error_Token
4186 ( p_message_name => 'BOM_COMP_DIS_DATE_INVALID'
4187 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4188 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4189 , p_Token_Tbl => g_Token_Tbl
4190 );
4191 l_return_status := FND_API.G_RET_STS_ERROR;
4192 END IF;
4193
4194 -- dbms_output.put_line('Verified disable date . . . ' || l_return_status);
4195
4196 /********************************************************************
4197 --
4198 -- Verify that the number of reference designators equals the component
4199 -- quantity if quantity related = 1
4200 --
4201 **********************************************************************/
4202 /* -- Bug No: 3522842. Quantity Related checks will be done in BOM_Bo_Pvt package.
4203 IF p_rev_component_rec.quantity_related = 1
4204 THEN
4205 FOR cnt_desg IN c_RefDesgs
4206 LOOP
4207 IF cnt_desg.number_of_desgs <>
4208 p_rev_component_rec.quantity_per_assembly
4209 THEN
4210 -- GIVE A WARNING
4211 --
4212 Error_Handler.Add_Error_Token
4213 ( p_message_name => 'BOM_QTY_REL_QTY_REF_DESG'
4214 , p_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
4215 , x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
4216 , p_Token_Tbl => g_Token_Tbl
4217 , p_message_type => 'W'
4218 );
4219 END IF;
4220 END LOOP;
4221 END IF;
4222 */
4223
4224 /********************************************************************
4225 --
4226 -- Verify that if the user is trying to create or update rev. comp
4227 -- to quantity related when the quantity_per_assembly is fractional
4228 --
4229 *********************************************************************/
4230 IF round(p_rev_component_rec.quantity_per_assembly) <>
4231 p_rev_component_rec.quantity_per_assembly AND
4232 p_rev_component_rec.quantity_related = 1
4233 THEN
4234 Error_Handler.Add_Error_Token
4235 ( p_message_name => 'BOM_QTY_REL_QTY_FRACTIONAL'
4236 , p_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
4237 , x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
4238 , p_Token_Tbl => g_Token_Tbl
4239 );
4240
4241 l_return_status := FND_API.G_RET_STS_ERROR;
4242 END IF;
4243
4244 /********************************************************************
4245 --
4246 -- If the Operation is Create with an Acd_Type of Change or Disable
4247 -- then component pointed to by old_component_sequence_id should
4248 -- already be implemented
4249 --
4250 *********************************************************************/
4251
4252 /** This allowed thru the form and should be allowed thru the BO
4253 as well
4254
4255 IF p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE AND
4256 p_rev_component_rec.acd_type IN (2, 3)
4257 THEN
4258 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Old sequence: ' || to_char(p_rev_comp_Unexp_rec.old_component_sequence_id)); END IF;
4259 BEGIN
4260 SELECT 'Component Implemented'
4261 INTO l_dummy
4262 FROM bom_inventory_components
4263 WHERE component_sequence_id =
4264 p_rev_comp_Unexp_rec.old_component_sequence_id
4265 AND implementation_date IS NOT NULL;
4266
4267 EXCEPTION
4268 WHEN NO_DATA_FOUND THEN
4269 -- component is yet not implemented
4270 IF FND_MSG_PUB.Check_Msg_Level
4271 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4272 THEN
4273 Error_Handler.Add_Error_Token
4274 ( p_message_name => 'BOM_OLD_COMP_SEQ_ID_INVALID'
4275 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4276 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4277 , p_Token_Tbl => g_Token_Tbl
4278 );
4279 END IF;
4280 l_return_status := FND_API.G_RET_STS_ERROR;
4281 WHEN OTHERS THEN
4282 -- dbms_output.put_line(SQLERRM);
4283 Error_Handler.Add_Error_Token
4284 ( p_message_name => NULL
4285 , p_message_text => 'ERROR Rev Cmp entity validate ' ||
4286 SUBSTR(SQLERRM, 1, 30) || ' ' ||
4287 TO_CHAR(SQLCODE)
4288 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4289 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4290 );
4291 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4292 END;
4293 END IF;
4294
4295 ** End of Comment **/
4296
4297 -- If the user is attempting to change the from_end_item_unit number or to_end_item_unit_number
4298 -- then verify that the change is not creating a component with overlapping dates
4299 IF (p_rev_component_rec.from_end_item_unit_number IS NOT NULL AND
4300 p_rev_component_rec.new_from_end_item_unit_number IS NOT NULL AND
4301 p_rev_component_rec.new_from_end_item_unit_number <> FND_API.G_MISS_CHAR
4302 )
4303 THEN
4304 l_result := Check_Unit_Number();
4305
4306 IF (l_result = 1)
4307 THEN
4308 g_Token_Tbl(1).Token_Name := 'REVISED_ITEM_NAME';
4309 g_Token_Tbl(1).Token_Value :=
4310 g_Rev_Component_rec.revised_item_name;
4311 g_Token_Tbl(1).Token_Name := 'NEW_FROM_UNIT_NUMBER';
4312 g_Token_Tbl(1).Token_Value := g_Rev_Component_rec.new_from_end_item_unit_number;
4313
4314 Error_Handler.Add_Error_Token
4315 ( p_Message_Name => 'BOM_NEW_FROM_UNIT_NUM_OVERLAP'
4316 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4317 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4318 , p_Token_Tbl => g_Token_Tbl
4319 );
4320 --
4321 -- reset the first token to revised component name.
4322 --
4323 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
4324 g_Token_Tbl(1).Token_Value :=
4325 g_Rev_Component_rec.component_item_name;
4326 l_return_status := FND_API.G_RET_STS_ERROR;
4327 END IF;
4328 END IF;
4329
4330
4331 /********************************************************************
4332 -- Added by MK on 02/02/2001
4333 -- If the rev component is Create with an Acd_Type of Change or Disable
4334 -- then component pointed to by old_component_sequence_id should
4335 -- be valid against cusror old_comp_csr's conditions.
4336 *********************************************************************/
4337 IF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_CREATE AND
4338 p_rev_component_rec.acd_type IN (2, 3)
4339 THEN
4340
4341 IF Bom_Globals.Get_Debug = 'Y' THEN
4342 Error_Handler.Write_Debug('Checking old component : '|| to_char(p_rev_comp_unexp_rec.old_component_sequence_id));
4343 END IF;
4344
4345 l_eco_for_production := NVL(Bom_Globals.Get_Eco_For_Production,2) ;
4346
4347 FOR old_comp_rec IN old_comp_csr
4348 (p_rev_comp_unexp_rec.old_component_sequence_id,
4349 l_eco_for_production)
4350 LOOP
4351 -- component is invalid
4352 IF FND_MSG_PUB.Check_Msg_Level
4353 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4354 THEN
4355 Error_Handler.Add_Error_Token
4356 ( p_message_name => 'BOM_OLD_COMP_SEQ_ID_INVALID'
4357 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4358 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4359 , p_Token_Tbl => g_Token_Tbl
4360 );
4361 END IF;
4362 l_return_status := FND_API.G_RET_STS_ERROR;
4363 END LOOP ;
4364
4365 IF Bom_Globals.Get_Debug = 'Y' THEN
4366 Error_Handler.Write_Debug('After checking old component. Return status is '|| l_return_status);
4367 END IF;
4368
4369 END IF;
4370
4371 --IF Nvl(Bom_Globals.Get_Validate_For_Plm,'N') = 'N'
4372 --THEN
4373 -- Modified by MK on 11/13/00
4374 IF ( p_rev_component_rec.operation_sequence_number <> 1 AND
4375 -- NVL(p_rev_Component_rec.ACD_Type, 1) = 1
4376 p_rev_Component_rec.ACD_Type = 1
4377 ) OR -- bug 5386719
4378 ( p_rev_component_rec.operation_sequence_number <> 1 AND
4379 p_rev_Component_rec.ACD_Type is NULL and
4380 p_rev_component_rec.transaction_type = BOM_Globals.G_OPR_CREATE
4381 ) OR
4382 ( p_rev_component_rec.operation_sequence_number <> 1 AND
4383 NVL(p_rev_Component_rec.ACD_Type, 1) = 2 AND
4384 NVL(p_rev_component_rec.new_operation_sequence_number,FND_API.G_MISS_NUM)
4385 = FND_API.G_MISS_NUM
4386 ) OR
4387 ( NVL(p_rev_component_rec.new_operation_sequence_number,1) <> 1 AND
4388 ( ( p_rev_component_rec.ACD_Type = 2 AND
4389 p_rev_component_rec.transaction_type =
4390 BOM_Globals.G_OPR_CREATE
4391 ) OR
4392 p_rev_component_rec.transaction_type =
4393 BOM_Globals.G_OPR_UPDATE
4394 ) AND
4395 (
4396 NVL(p_old_rev_component_rec.operation_sequence_number, 1) <>
4397 NVL(p_rev_component_rec.new_operation_sequence_number, 1) AND
4398 p_rev_component_rec.new_operation_sequence_number <> FND_API.G_MISS_NUM
4399 )
4400 )
4401 THEN
4402
4403 /*************************************************************
4404 --
4405 -- If Operation_Seq_Num is not 1 then there must be a routing
4406 -- for the revised item.
4407 -- Added by AS on 08/20/99 to accomodate calls from the
4408 -- ECO form to perform this validation.
4409 *************************************************************/
4410
4411 IF NOT Check_Routing_Exists
4412 THEN
4413 IF FND_MSG_PUB.Check_Msg_Level
4414 (FND_MSG_PUB.G_MSG_LVL_ERROR)
4415 THEN
4416 Error_Handler.Add_Error_Token
4417 ( p_message_name => 'BOM_ONLY_ONE'
4418 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4419 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4420 , p_Token_Tbl => g_Token_Tbl
4421 );
4422 END IF;
4423 l_return_status := FND_API.G_RET_STS_ERROR;
4424 ELSE
4425
4426 /*************************************************************
4427 --
4428 -- If Operation_Seq_Num is not NULL then it must be unique in
4429 -- case of Creates and in Case of Updates new_operation_sequence
4430 -- must be valid if the user is trying to update
4431 -- operation_sequence_number
4432 **************************************************************/
4433
4434 l_result := Check_Op_Seq(l_is_item_unit_controlled);
4435 --arudresh_debug('Result after check_op_seq '||l_result);
4436
4437 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check_Op_Seq returned with : ' || l_result); END IF;
4438 IF l_result = 1
4439 THEN
4440 g_Token_Tbl(1).Token_Name := 'REVISED_ITEM_NAME';
4441 g_Token_Tbl(1).Token_Value :=
4442 g_Rev_Component_rec.revised_item_name;
4443 Error_Handler.Add_Error_Token
4444 ( p_Message_Name => 'BOM_OP_SEQ_NUM_INVALID'
4445 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4446 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4447 , p_Token_Tbl => g_Token_Tbl
4448 );
4449 --
4450 -- reset the first token to revised component name.
4451 --
4452 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
4453 g_Token_Tbl(1).Token_Value :=
4454 g_Rev_Component_rec.component_item_name;
4455 l_return_status := FND_API.G_RET_STS_ERROR;
4456 /* bug:4240031 If there are comp ops then op seq num can not be
4457 * changed to that
4458 */
4459 ELSIF l_result = 3 THEN
4460 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
4461 g_Token_Tbl(1).Token_Value := g_Rev_Component_rec.component_item_name;
4462 Error_Handler.Add_Error_Token
4463 ( p_Message_Name => 'BOM_COMP_OPS_OP_SEQ'
4464 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4465 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4466 , p_Token_Tbl => g_Token_Tbl
4467 );
4468 l_return_status := FND_API.G_RET_STS_ERROR;
4469 ELSIF l_result = 2 THEN
4470 IF Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO THEN
4471 g_Token_Tbl(2).Token_Name := 'OP_SEQ_NUM';
4472 g_Token_Tbl(2).Token_Value :=
4473 to_char
4474 (g_Rev_Component_rec.operation_sequence_number);
4475 Error_Handler.Add_Error_Token
4476 ( p_message_name => 'BOM_OP_SEQ_NUM_NOT_UNIQUE'
4477 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4478 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4479 , p_Token_Tbl => g_Token_Tbl
4480 );
4481 g_Token_Tbl.DELETE(2);
4482 l_return_status := FND_API.G_RET_STS_ERROR;
4483 ELSE
4484 g_Token_Tbl(2).Token_Name := 'OP_SEQ_NUM';
4485 g_Token_Tbl(2).Token_Value :=
4486 to_char
4487 (g_Rev_Component_rec.operation_sequence_number);
4488 Error_Handler.Add_Error_Token
4489 ( p_message_name => 'BOM_OP_SEQ_NUM_NOT_UNIQUE'
4490 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4491 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4492 , p_Token_Tbl => g_Token_Tbl
4493 , p_message_type => 'W'
4494 );
4495 g_Token_Tbl.DELETE(2);
4496 END IF;
4497 ELSIF l_result = 4 THEN
4498 Error_Handler.Add_Error_Token
4499 ( p_Message_Name => 'BOM_COMMON_OP_SEQ_INVALID'
4500 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4501 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4502 , p_Token_Tbl => g_Token_Tbl
4503 );
4504 l_return_status := FND_API.G_RET_STS_ERROR;
4505 ELSIF l_result = 0 AND
4506 p_Rev_Component_rec.old_operation_sequence_number
4507 IS NOT NULL AND
4508 p_Rev_Component_rec.old_operation_sequence_number <>
4509 FND_API.G_MISS_NUM AND Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
4510 THEN
4511 BEGIN
4512 SELECT operation_seq_num
4513 INTO l_result
4514 FROM bom_inventory_components
4515 WHERE component_sequence_id =
4516 p_rev_comp_unexp_rec.old_component_sequence_id
4517 AND operation_seq_num =
4518 p_Rev_Component_rec.old_operation_sequence_number;
4519
4520 EXCEPTION
4521 WHEN OTHERS THEN
4522 l_result := 0;
4523 END;
4524
4525 IF l_result = 0
4526 THEN
4527 g_Token_Tbl(2).Token_Name := 'OLD_OP_SEQUENCE_NUM';
4528 g_Token_Tbl(2).Token_Value :=
4529 to_char
4530 (g_Rev_Component_rec.old_operation_sequence_number);
4531 Error_Handler.Add_Error_Token
4532 ( p_message_name => 'BOM_OLD_OP_SEQ_NUM_GIVEN'
4533 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4534 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4535 , p_Token_Tbl => g_Token_Tbl
4536 );
4537 g_Token_Tbl.DELETE(2);
4538 l_return_status := FND_API.G_RET_STS_ERROR;
4539 END IF;
4540 END IF;
4541 END IF;
4542 END IF; -- Operation_seq_Num Check Ends.
4543 --END IF; -- Validate for plm ends
4544 END IF;
4545
4546 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Op seq num validation completed with ' || l_return_status); END IF;
4547
4548 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('BO identifier is '||Bom_Globals.Get_Bo_Identifier); END IF;
4549
4550 IF Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO AND NVL(p_rev_Component_rec.ACD_Type,1) <> 3 THEN
4551 IF Nvl(Bom_Globals.Get_Validate_For_Plm,'N') = 'N'
4552 THEN
4553 IF (p_control_rec.caller_type = 'FORM' AND
4554 p_control_rec.write_to_db)
4555 OR
4556 p_control_rec.caller_type <> 'FORM'
4557 THEN
4558
4559 IF NOT l_is_item_unit_controlled
4560 THEN
4561
4562 /********************************************************************
4563 --
4564 -- Check for Overlapping dates for the component being inserted.
4565 --
4566 *********************************************************************/
4567
4568 IF Check_Overlap_Dates
4569 (X_Effectivity_date => p_rev_component_rec.start_effective_date,
4570 X_Disable_date => p_rev_component_rec.disable_date,
4571 X_Member_Item_Id => p_rev_comp_unexp_rec.component_item_id,
4572 X_Bill_Sequence_id => p_rev_comp_unexp_rec.bill_sequence_id,
4573 X_Rowid => NULL,
4574 X_Comp_Seq_id => p_rev_comp_unexp_rec.old_component_sequence_id, --Fixed for Bug No 6688502
4575 X_Operation_Seq_Num => p_rev_component_rec.operation_sequence_number)
4576 THEN
4577 --if function return true then component dates overlapp
4578
4579 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
4580 THEN
4581 Error_Handler.Add_Error_Token
4582 ( p_Message_Name => 'BOM_COMP_OPSEQ_DATE_OVERLAP'
4583 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4584 , p_token_tbl => g_token_tbl
4585 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4586 , p_message_type => 'W'
4587 );
4588 END IF;
4589 -- Since Open Interface allows for Dates to be
4590 -- overlapping do set the error status.
4591 END IF;
4592 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Verified overlapping dates . . . ' || l_return_status); END IF;
4593
4594 ELSE
4595
4596 /********************************************************************
4597 --
4598 -- Check for Overlapping numbers for the component being inserted.
4599 --
4600 *********************************************************************/
4601 IF Check_Overlap_Numbers
4602 (X_From_end_item_number
4603 => p_rev_component_rec.from_end_item_unit_number,
4604 X_to_end_item_number
4605 => p_rev_component_rec.to_end_item_unit_number,
4606 X_Member_Item_Id => p_rev_comp_unexp_rec.component_item_id,
4607 X_Bill_Sequence_id => p_rev_comp_unexp_rec.bill_sequence_id,
4608 X_Rowid => NULL,
4609 X_Comp_Seq_id => p_rev_comp_unexp_rec.component_sequence_id,
4610 X_Operation_Seq_Num =>
4611 p_rev_component_rec.operation_sequence_number)
4612 THEN
4613 --if function return true then component dates overlapp
4614
4615 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
4616 THEN
4617 Error_Handler.Add_Error_Token
4618 ( p_Message_Name => 'BOM_COMP_OPSEQ_UNIT_OVERLAP'
4619 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4620 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4621 , p_token_tbl => g_token_tbl
4622 , p_message_type => 'W'
4623 );
4624 END IF;
4625 -- Since Open Interface allows for Dates to be
4626 -- overlapping do set the error status.
4627 END IF;
4628 END IF;
4629 END IF;
4630 END IF; -- Validate for PLM check ends
4631 ELSIF Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO THEN
4632 IF Nvl(Bom_Globals.Get_Validate_For_Plm,'N') = 'N'
4633 THEN
4634
4635 IF NOT l_is_item_unit_controlled
4636 THEN
4637
4638
4639 /********************************************************************
4640 --
4641 -- Check for Overlapping dates for the component being inserted.
4642 --
4643 *********************************************************************/
4644
4645 /* Fix for bug 4585076 - While calling check_overlap_dates function, if txn type is create then pass start_effective_date
4646 else if txn type is update then pass new_effectivity_date.
4647 */
4648 IF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_CREATE THEN
4649 l_new_compare_date := p_rev_component_rec.start_effective_date;
4650 ELSIF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_UPDATE THEN
4651 l_new_compare_date := p_rev_component_rec.new_effectivity_date;
4652 END IF;
4653
4654 IF Bom_Validate_Comp_Operation.Check_Overlap_Dates
4655 (p_Effectivity_date => l_new_compare_date, /*p_rev_component_rec.start_effective_date,*/
4656 p_Disable_date => p_rev_component_rec.disable_date,
4657 p_Component_Item_Id => p_rev_comp_unexp_rec.component_item_id,
4658 p_Bill_Sequence_id => p_rev_comp_unexp_rec.bill_sequence_id,
4659 p_Component_Sequence_id => p_rev_comp_unexp_rec.component_sequence_id,
4660 p_Rowid => p_rev_comp_unexp_rec.rowid,
4661 p_Operation_Seq_Num => p_rev_component_rec.operation_sequence_number,
4662 p_entity => 'RC')
4663 THEN
4664 --if function return true then component dates overlapp
4665
4666 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
4667 THEN
4668 Error_Handler.Add_Error_Token
4669 ( p_Message_Name => 'BOM_COMP_OPSEQ_DATE_OVERLAP'
4670 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4671 , p_token_tbl => g_token_tbl
4672 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4673 , p_message_type => 'E'
4674 );
4675 END IF;
4676 l_return_status := FND_API.G_RET_STS_ERROR;
4677 END IF;
4678 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Verified overlapping dates . . . ' || l_return_status); END IF;
4679
4680 ELSE
4681 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('I am here Inside Unit Eff'); END IF;
4682
4683 /********************************************************************
4684 --
4685 -- Check for Overlapping numbers for the component being inserted.
4686 --
4687 *********************************************************************/
4688 IF Bom_Validate_Comp_Operation.Check_Overlap_Numbers
4689 (p_From_end_item_number
4690 => p_rev_component_rec.from_end_item_unit_number,
4691 p_to_end_item_number
4692 => p_rev_component_rec.to_end_item_unit_number,
4693 p_Component_Item_Id => p_rev_comp_unexp_rec.component_item_id,
4694 p_Bill_Sequence_id => p_rev_comp_unexp_rec.bill_sequence_id,
4695 p_Rowid => p_rev_comp_unexp_rec.rowid,
4696 p_Component_Sequence_id => p_rev_comp_unexp_rec.component_sequence_id,
4697 p_Operation_Seq_Num =>
4698 p_rev_component_rec.operation_sequence_number,
4699 p_entity => 'RC')
4700 THEN
4701 --if function return true then component unit numbers overlapp
4702
4703 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
4704 THEN
4705 Error_Handler.Add_Error_Token
4706 ( p_Message_Name => 'BOM_COMP_OPSEQ_UNIT_OVERLAP'
4707 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4708 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4709 , p_token_tbl => g_token_tbl
4710 , p_message_type => 'E'
4711 );
4712 END IF;
4713 l_return_status := FND_API.G_RET_STS_ERROR;
4714 END IF;
4715 END IF;
4716 END IF; -- Validate for Plm check ends
4717 END IF;
4718
4719 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Verified overlapping unit numbers. . .' || l_return_status); END IF;
4720
4721
4722 If (p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND g_Assy_Item_Type = Bom_Globals.G_PRODUCT_FAMILY) THEN
4723 l_Result := CheckUnique_PF_Member;
4724 IF l_Result = 1 Then
4725 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4726 THEN
4727 g_Token_Tbl(2).Token_Name := 'pf_item';
4728 g_Token_Tbl(2).Token_Value :=
4729 g_rev_component_rec.revised_item_name;
4730 Error_Handler.Add_Error_Token
4731 ( p_message_name => 'BOM_PF_MEMBER_ALREADY_EXISTS'
4732 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4733 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4734 , p_Token_Tbl => g_Token_Tbl
4735 );
4736 END IF;
4737 l_return_status := FND_API.G_RET_STS_ERROR;
4738 END IF;
4739 End if;
4740
4741 /*********************************************************************
4742 --
4743 -- Check whether the entered attributes match with the current
4744 -- component attributes
4745 --
4746 **********************************************************************/
4747 IF (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4748 NVL(p_rev_component_rec.acd_type, 1) = 1
4749 ) OR
4750 (((p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4751 p_rev_component_rec.acd_type = 2
4752 ) OR
4753 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
4754 )
4755 AND
4756 NVL(p_Old_rev_component_rec.optional, 0) <>
4757 p_rev_component_rec.optional
4758 )
4759 )
4760 THEN
4761 l_Result := Check_PTO_ATO_for_Optional;
4762 IF l_Result = 1 THEN
4763 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4764 THEN
4765 Error_Handler.Add_Error_Token
4766 ( p_message_name => 'BOM_COMP_OPTIONAL'
4767 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4768 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4769 , p_Token_Tbl => g_Token_Tbl
4770 );
4771 END IF;
4772 l_return_status := FND_API.G_RET_STS_ERROR;
4773 ELSIF l_Result = 2
4774 THEN
4775 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4776 THEN
4777 Error_Handler.Add_Error_Token
4778 ( p_message_name => 'BOM_COMP_NOT_OPTIONAL'
4779 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4780 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4781 );
4782 END IF;
4783 l_return_status := FND_API.G_RET_STS_ERROR;
4784 END IF;
4785 END IF;
4786
4787 -- dbms_output.put_line('Verified PTO / ATO . . .' || l_return_status);
4788
4789 /*********************************************************************
4790 --
4791 -- Planning Percent can be other than 100 for only some combination of
4792 -- Assembly and component_types.
4793 --
4794 **********************************************************************/
4795 --
4796 IF p_control_rec.caller_type <> 'FORM' AND
4797 (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4798 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
4799 p_rev_component_rec.planning_percent <> 100
4800 ) OR
4801 (((p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4802 p_rev_component_rec.acd_type = 2
4803 ) OR
4804 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
4805 )
4806 AND
4807 NVL(p_Old_rev_component_rec.planning_percent, 0) <>
4808 p_rev_component_rec.planning_percent
4809 )
4810 )
4811 THEN
4812 l_Result := Check_Planning_Percent;
4813 IF l_Result = 1 THEN
4814 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4815 THEN
4816 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4817 g_Token_Tbl(2).Token_Value :=
4818 g_rev_component_rec.revised_item_name;
4819 Error_Handler.Add_Error_Token
4820 ( p_Message_Name => 'BOM_NOT_A_PLANNING_PARENT'
4821 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4822 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4823 , p_Token_Tbl => g_Token_Tbl
4824 );
4825 g_Token_Tbl.DELETE(2);
4826 END IF;
4827 l_return_status := FND_API.G_RET_STS_ERROR;
4828 ELSIF l_Result = 2 THEN
4829 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4830 THEN
4831 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4832 g_Token_Tbl(2).Token_Value :=
4833 g_rev_component_rec.revised_item_name;
4834 g_Token_Tbl(3).Token_Name := 'ITEM_TYPE';
4835 IF g_Assy_Item_Type = Bom_Globals.G_MODEL
4836 THEN
4837 g_Token_Tbl(3).Token_Value := 'BOM_MODEL_TYPE';
4838 ELSIF g_Assy_Item_Type = Bom_Globals.G_OPTION_CLASS THEN
4839 g_Token_Tbl(3).Token_Value :=
4840 'BOM_OPTION_CLASS_TYPE';
4841 END IF;
4842 g_Token_Tbl(3).Translate := TRUE;
4843 Error_Handler.Add_Error_Token
4844 ( p_Message_Name => 'BOM_COMP_MODEL_OC_OPTIONAL'
4845 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4846 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4847 , p_Token_Tbl => g_Token_Tbl
4848 );
4849 g_Token_Tbl.DELETE(2);
4850 g_Token_Tbl.DELETE(3);
4851 l_return_status := FND_API.G_RET_STS_ERROR;
4852 END IF;
4853 ELSIF l_Result = 3 THEN
4854 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4855 THEN
4856 g_Token_Tbl(1).Token_Name := 'REVISED_ITEM_NAME';
4857 g_Token_Tbl(1).Token_Value :=
4858 g_rev_component_rec.revised_item_name;
4859
4860 Error_Handler.Add_Error_Token
4861 ( p_Message_Name =>
4862 'BOM_COMP_OPTIONAL_ATO_FORECAST'
4863 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4864 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4865 , p_Token_Tbl => g_Token_Tbl
4866 );
4867 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
4868 g_Token_Tbl(1).Token_Value :=
4869 g_rev_component_rec.component_item_name;
4870
4871 END IF;
4872 l_return_status := FND_API.G_RET_STS_ERROR;
4873 END IF; -- If Result Ends
4874 END IF; -- If Plannng <> 100 Ends
4875
4876 -- dbms_output.put_line('Verified Planning % . . .' || l_return_status);
4877
4878 /*********************************************************************
4879 --
4880 -- Check Required for Revenue / Required to Ship
4881 --
4882 **********************************************************************/
4883 IF (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4884 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
4885 ( p_rev_component_rec.required_for_revenue = 1 OR
4886 p_rev_component_rec.required_to_ship = 1
4887 )
4888 ) OR
4889 (((p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4890 p_rev_component_rec.acd_type = 2
4891 ) OR
4892 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
4893 )
4894 AND
4895 ( NVL(p_Old_rev_component_rec.required_for_revenue, 0) <>
4896 p_rev_component_rec.required_for_revenue OR
4897 NVL(p_old_rev_component_rec.required_to_ship, 0) <>
4898 p_rev_component_rec.required_to_ship
4899 )
4900 )
4901 )
4902 THEN
4903
4904 l_Result := Chk_Req_For_Rev_Or_Shp;
4905 IF l_Result = 1 THEN
4906 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4907 THEN
4908 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4909 g_Token_Tbl(2).Token_Value :=
4910 g_rev_component_rec.revised_item_name;
4911 Error_Handler.Add_Error_Token
4912 ( p_message_name => 'BOM_COMP_REQ_FOR_REV_INVALID'
4913 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4914 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4915 , p_Token_Tbl => g_Token_Tbl
4916 );
4917 g_Token_Tbl.DELETE(2);
4918 END IF;
4919 l_return_status := FND_API.G_RET_STS_ERROR;
4920 ELSIF l_Result = 2 THEN
4921 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4922 g_Token_Tbl(2).Token_Value :=
4923 g_rev_component_rec.revised_item_name;
4924 Error_Handler.Add_Error_Token
4925 ( p_message_name => 'BOM_COMP_REQ_TO_SHIP_INVALID'
4926 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4927 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4928 , p_Token_Tbl => g_Token_Tbl
4929 );
4930 g_Token_Tbl.DELETE(2);
4931 l_return_status := FND_API.G_RET_STS_ERROR;
4932 ELSIF l_Result = 3 THEN
4933 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4934 g_Token_Tbl(2).Token_Value :=
4935 g_rev_component_rec.revised_item_name;
4936 Error_Handler.Add_Error_Token
4937 ( p_message_name => 'BOM_COMP_REQ_TO_SHIP_INVALID'
4938 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4939 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4940 , p_Token_Tbl => g_Token_Tbl
4941 );
4942
4943 g_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
4944 g_Token_Tbl(2).Token_Value :=
4945 g_rev_component_rec.revised_item_name;
4946 Error_Handler.Add_Error_Token
4947 ( p_message_name => 'BOM_COMP_REQ_FOR_REV_INVALID'
4948 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4949 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4950 , p_Token_Tbl => g_Token_Tbl
4951 );
4952
4953 g_Token_Tbl.DELETE(2);
4954 l_return_status := FND_API.G_RET_STS_ERROR;
4955 END IF;
4956 END IF;
4957
4958 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Verified Req for Rev and Shipping . . . ' || l_return_status); END IF;
4959
4960 /*********************************************************************
4961 --
4962 -- Verify the value of SO_Basis
4963 -- first conditon is removed by MK on 11/13/00
4964 *********************************************************************/
4965 IF -- p_control_rec.caller_type = 'FORM' AND
4966 p_rev_component_rec.so_basis = 1 AND
4967 g_Comp_Item_Type <> Bom_Globals.G_OPTION_CLASS
4968 THEN
4969 Error_Handler.Add_Error_Token
4970 ( p_message_name => 'BOM_SO_BASIS_ONE'
4971 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4972 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4973 , p_Token_Tbl => g_Token_Tbl
4974 );
4975 l_Return_Status := FND_API.G_RET_STS_ERROR;
4976 END IF;
4977
4978 /********************************************************************
4979 -- ATP Validation for components is changed and now there is no restriction
4980 -- Comment out by MK on 06/05/2001
4981 --
4982 -- Check Check_ATP Flag. Check_ATP can be True only if Assembly has
4983 -- Atp Components flag = Y and the Component has a Check_ATP.
4984 --
4985
4986 IF (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
4987 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
4988 p_rev_component_rec.check_atp = 1
4989 ) OR
4990 ( ( ( p_rev_component_rec.Transaction_Type =
4991 BOM_GLOBALS.G_OPR_CREATE AND
4992 p_rev_component_rec.acd_type = 2
4993 ) OR
4994 p_rev_component_rec.Transaction_Type =
4995 BOM_GLOBALS.G_OPR_UPDATE
4996 ) AND
4997 NVL(p_old_rev_component_rec.check_atp, 0) <>
4998 p_rev_component_rec.check_atp
4999 AND p_rev_component_rec.check_atp = 1 -- Added by MK on 11/13/00
5000 )
5001 )
5002 THEN
5003 l_result := Check_ATP;
5004 -- We will not be using the result of the check_atp procedure
5005 -- to decide the translatable token since the message text
5006 -- is now changed. Please refer to text for BOM_ATP_CHECK_NOT_NO
5007
5008 -- Modified by MK on 11/13/00
5009 -- IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) AND
5010 -- l_result <> 0
5011 -- THEN
5012
5013 IF l_result <> 0
5014 THEN
5015 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5016 THEN
5017 Error_Handler.Add_Error_Token
5018 ( p_message_name => 'BOM_ATP_CHECK_NOT_NO'
5019 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5020 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5021 , p_Token_Tbl => g_Token_Tbl
5022 );
5023 g_Token_Tbl.DELETE(2);
5024 -- l_return_status := FND_API.G_RET_STS_ERROR;
5025 END IF;
5026 l_return_status := FND_API.G_RET_STS_ERROR;
5027 END IF ;
5028 END IF;
5029
5030 IF Bom_Globals.Get_Debug = 'Y' THEN
5031 Error_Handler.Write_Debug('After verification of Check ATP . . . ' || l_return_status);
5032 END IF;
5033 -- dbms_output.put_line('After verification of Check ATP, Req for Rev' );
5034 ********************************************************************/
5035
5036 /********************************************************************
5037 --
5038 -- Check Mutually Exclusive, which can be set only if the
5039 -- Component is an Option Class and BOM is installed.
5040 --
5041 *********************************************************************/
5042
5043 IF ( p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE OR
5044 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5045 )
5046 AND
5047 NVL(p_rev_component_rec.mutually_exclusive, 2) = 1
5048 THEN
5049 l_result := Check_Mutually_Exclusive;
5050 IF l_result <> 0 THEN
5051 IF l_result = 1 THEN
5052 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5053 THEN
5054 Error_Handler.Add_Error_Token
5055 ( p_message_name => 'BOM_MUT_EXCL_BOM_NOT_INST'
5056 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5057 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5058 );
5059 END IF;
5060 ELSIF l_result = 2 THEN
5061 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5062 THEN
5063 Error_Handler.Add_Error_Token
5064 ( p_message_name => 'BOM_MUT_EXCL_NOT_MDL_OPTCLASS'
5065 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5066 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5067 , p_Token_Tbl => g_Token_Tbl
5068 );
5069 END IF;
5070 END IF;
5071
5072 l_return_status := FND_API.G_RET_STS_ERROR;
5073 END IF;
5074 END IF;
5075
5076 -- dbms_output.put_line('After verification of Mutually exclusive . . .' ||
5077 -- l_return_status);
5078
5079 -- So process can continue in case of a warning. Since it has
5080 -- indecisive o/p to continue or not, the function will
5081 -- log the error or warning and return TRUE if warning
5082 -- so the process can continue or will return an FALSE if
5083 -- process needs to return
5084 IF ((p_control_rec.caller_type = 'FORM' AND
5085 p_control_rec.validation_controller = 'SUPPLY_TYPE')
5086 OR
5087 p_control_rec.caller_type <> 'FORM')
5088 AND
5089 ((( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5090 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
5091 p_rev_component_rec.wip_supply_type IS NOT NULL
5092 ) OR
5093 ((p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5094 p_rev_component_rec.acd_type = 2
5095 ) OR
5096 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5097 ))
5098 AND
5099 NVL(p_Old_rev_component_rec.wip_supply_type, 0) <>
5100 p_rev_component_rec.wip_supply_type
5101 )
5102 AND
5103 NOT Check_Supply_Type
5104 ( p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5105 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl )
5106 THEN
5107 l_return_status := FND_API.G_RET_STS_ERROR;
5108 END IF;
5109
5110 -- dbms_output.put_line
5111 -- ('After verification of Supply Type . . .' || l_return_status);
5112
5113 IF (p_control_rec.caller_type = 'FORM' AND
5114 p_control_rec.validation_controller IN
5115 ('MINIMUM_QUANTITY', 'MAXIMUM_QUANTITY'))
5116 OR
5117 p_control_rec.caller_type <> 'FORM'
5118 THEN
5119 -- Check Minimum Quantity which must be <= Component Quantity
5120 IF ( p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE OR
5121 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5122 ) AND
5123 p_rev_component_rec.minimum_allowed_quantity is not null
5124 AND
5125 NOT Check_Min_Quantity THEN
5126 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5127 THEN
5128 Error_Handler.Add_Error_Token
5129 ( p_message_name => 'BOM_MIN_QUANTITY_INVALID'
5130 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5131 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5132 , p_Token_Tbl => g_Token_Tbl
5133 );
5134 END IF;
5135 l_return_status := FND_API.G_RET_STS_ERROR;
5136 END IF;
5137
5138 -- Check Maximun Quantity which must be >= Component Quantity or
5139 -- should be NULL if the minimum quantity is NULL.
5140 IF ( p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE OR
5141 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5142 ) AND
5143 p_rev_component_rec.maximum_allowed_quantity IS NOT NULL
5144 AND
5145 NOT Check_Max_Quantity THEN
5146 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5147 THEN
5148 Error_Handler.Add_Error_Token
5149 ( p_message_name => 'BOM_MAX_QUANTITY_INVALID'
5150 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5151 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5152 , p_Token_Tbl => g_Token_Tbl
5153 );
5154 END IF;
5155 l_return_status := FND_API.G_RET_STS_ERROR;
5156 END IF;
5157 END IF;
5158
5159 -- dbms_output.put_line('After verification of Min / Max quantity . . .');
5160
5161 -------------------------------------------------
5162 -- Required since quantity cannot be fractional
5163 -- if OE is installed and revised item is
5164 -- ATO/PTO.
5165 -- Fix made by AS 04/27/98
5166 -- Bug 651689
5167 -- Fractional qty allowed for ATO revised items
5168 -- fix made by skagarwa 11/27/00
5169 -- Bug 1490837
5170 -------------------------------------------------
5171 /* commenting for bug 5011929
5172 OPEN c_OE_Installed;
5173 FETCH c_OE_Installed INTO Is_OE_Installed;
5174 CLOSE c_OE_Installed;
5175
5176 Is_Item_ATO := 'N';
5177 IS_Item_PTO := 'N';
5178
5179 FOR Is_Item_ATO_PTO IN c_ATO_PTO
5180 LOOP
5181 Is_Item_ATO := Is_Item_ATO_PTO.replenish_to_order_flag;
5182 Is_Item_PTO := Is_Item_ATO_PTO.pick_components_flag;
5183 END LOOP;
5184
5185 IF ( p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE OR
5186 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5187 ) AND
5188 (Is_OE_Installed = 'I'
5189 AND ( ( Is_Item_PTO = 'Y'
5190 ) AND
5191 (round(p_rev_component_rec.quantity_per_assembly)
5192 <> p_rev_component_rec.quantity_per_assembly)
5193 )
5194 )
5195 THEN
5196 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5197 THEN
5198 Error_Handler.Add_Error_Token
5199 ( p_message_name => 'BOM_COMP_QTY_FRACTIONAL'
5200 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5201 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5202 , p_Token_Tbl => g_Token_Tbl
5203 );
5204 END IF;
5205 l_return_status := FND_API.G_RET_STS_ERROR;
5206 END IF;
5207 commented for bug 5011929 */
5208 -- dbms_output.put_line('Checked if fractional quantity is valid . . .' ||
5209 -- l_return_status);
5210
5211
5212 /********************************************************************
5213 --
5214 -- Verify if the Check_Atp is Yes and the Component quantity is
5215 -- negative. If it is then give out an error.
5216 --
5217 ********************************************************************/
5218
5219 IF p_rev_component_rec.check_atp = 1 AND -- Bug Fix 3688325
5220 p_rev_component_rec.quantity_per_assembly < 0
5221 THEN
5222 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5223 THEN
5224 Error_Handler.Add_Error_Token
5225 ( p_message_name => 'BOM_COMP_QTY_NEGATIVE'
5226 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5227 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5228 , p_Token_Tbl => g_Token_Tbl
5229 );
5230 END IF;
5231 l_return_status := FND_API.G_RET_STS_ERROR;
5232 END IF;
5233
5234 /********************************************************************
5235 --
5236 -- If component is a PTO Option Class, then component quantity cannot
5237 -- be negative
5238 --
5239 ********************************************************************/
5240 IF g_Comp_PTO_Flag = 'Y' AND
5241 p_rev_component_rec.quantity_per_assembly < 0
5242 THEN
5243 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5244 THEN
5245 Error_Handler.Add_Error_Token
5246 ( p_message_name => 'BOM_COMP_PTO_QTY_NEGATIVE'
5247 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5248 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5249 , p_Token_Tbl => g_Token_Tbl
5250 );
5251 END IF;
5252 l_return_status := FND_API.G_RET_STS_ERROR;
5253 END IF;
5254
5255 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Checking Supply Subinventory . . . ' || p_rev_component_rec.Supply_SubInventory); END IF;
5256
5257 /*******************************************************************
5258 --
5259 -- Check Supply Subinventory
5260 --
5261 ********************************************************************/
5262
5263 IF -- p_control_rec.caller_type = 'FORM' -- Comment out by MK on 11/13/00
5264 -- AND
5265 p_rev_component_rec.Supply_SubInventory <> FND_API.G_MISS_CHAR AND
5266 (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5267 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
5268 p_rev_component_rec.Supply_SubInventory IS NOT NULL
5269 ) OR
5270 (((p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5271 p_rev_component_rec.acd_type = 2
5272 ) OR
5273 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5274 )
5275 AND
5276 NVL(p_Old_rev_component_rec.supply_subinventory, 'NONE') <>
5277 NVL(p_rev_component_rec.supply_subinventory, 'NONE')
5278 )
5279 )
5280 AND
5281 NOT Check_Supply_SubInventory THEN
5282
5283 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5284 THEN
5285 Error_Handler.Add_Error_Token
5286 ( p_message_name => 'BOM_SUBINV_INVALID'
5287 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5288 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5289 );
5290 END IF;
5291 l_return_status := FND_API.G_RET_STS_ERROR;
5292 END IF;
5293 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('After checking Subinventory . . . ' || l_return_status); END IF;
5294
5295 -- dbms_output.put_line('Checking Locators . . . .');
5296 /********************************************************************
5297 --
5298 -- Check Locators
5299 --
5300 ********************************************************************/
5301 IF p_control_rec.caller_type <> 'FORM'
5302 AND (Bom_globals.Get_Caller_Type <> BOM_GLOBALS.G_MASS_CHANGE) -- Bug2739314
5303 AND
5304 (( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5305 NVL(p_rev_component_rec.acd_type, 1) = 1 AND
5306 p_rev_component_rec.Supply_SubInventory IS NOT NULL AND
5307 p_rev_component_rec.Supply_SubInventory <> FND_API.G_MISS_CHAR
5308 ) OR
5309 ((( p_rev_component_rec.Transaction_Type=BOM_GLOBALS.G_OPR_CREATE AND
5310 p_rev_component_rec.acd_type = 2
5311 ) OR
5312 p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_UPDATE
5313 )
5314 AND
5315 NVL(p_Old_rev_comp_unexp_rec.supply_locator_id, 0) <>
5316 NVL(p_rev_comp_unexp_rec.supply_locator_id, 0)
5317 )
5318 )
5319 AND
5320 NOT Check_Locators
5321 THEN
5322 -- dbms_output.put_line('Locators check returned with an error-' ||
5323 -- to_char(l_locator_control));
5324
5325 IF l_locator_control = 4 THEN
5326 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5327 THEN
5328 Error_Handler.Add_Error_Token
5329 ( p_message_name => 'BOM_LOCATOR_REQUIRED'
5330 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5331 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5332 , p_Token_Tbl => g_Token_Tbl
5333 );
5334 END IF;
5335 /* Error message should be proper. Since dynamic locators are supported
5336 same validation for pre-specified can be used. Bug 5032528
5337 ELSIF l_locator_control = 3 THEN
5338 -- Log the Dynamic locator control message.
5339 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5340 THEN
5341 g_Token_Tbl(1).token_name := 'REVISED_COMPONENT_NAME';
5342 g_Token_Tbl(1).token_value:= p_rev_component_rec.component_item_name;
5343
5344 Error_Handler.Add_Error_Token
5345 ( p_message_name => 'BOM_LOCATOR_CANNOT_BE_DYNAMIC'
5346 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5347 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5348 , p_Token_Tbl => g_Token_Tbl
5349 );
5350 END IF;
5351 */
5352 -- Added OR l_locator_control = 3 for bug 5032528
5353 ELSIF (l_locator_control = 2 OR l_locator_control = 3 ) THEN
5354 IF l_item_loc_restricted = 1 THEN
5355
5356 -- if error occured when item_locator_control was
5357 -- restrcited
5358
5359 IF FND_MSG_PUB.Check_Msg_Level
5360 (FND_MSG_PUB.G_MSG_LVL_ERROR)
5361 THEN
5362 -- Added Token by MK on 12/06/00
5363 g_Token_Tbl(2).Token_Name := 'SUPPLY_SUBINVENTORY';
5364 g_Token_Tbl(2).Token_Value := p_rev_component_rec.Supply_SubInventory ;
5365
5366 Error_Handler.Add_Error_Token
5367 ( p_message_name => 'BOM_ITEM_LOCATOR_RESTRICTED'
5368 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5369 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5370 , p_Token_Tbl => g_Token_Tbl
5371 );
5372
5373 g_Token_Tbl.DELETE(2);
5374
5375 END IF;
5376 ELSE
5377 IF FND_MSG_PUB.Check_Msg_Level
5378 (FND_MSG_PUB.G_MSG_LVL_ERROR)
5379 THEN
5380 g_Token_Tbl(2).token_name := 'REVISED_COMPONENT_NAME';
5381 g_Token_Tbl(2).token_value:= p_rev_component_rec.component_item_name;
5382 Error_Handler.Add_Error_Token
5383 ( p_message_name => 'BOM_LOCATOR_NOT_IN_SUBINV'
5384 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5385 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5386 , p_Token_Tbl => g_Token_Tbl
5387 );
5388
5389 END IF;
5390 END IF;
5391 ELSIF l_locator_control = 1 THEN
5392 IF FND_MSG_PUB.Check_Msg_Level
5393 (FND_MSG_PUB.G_MSG_LVL_ERROR)
5394 THEN
5395 Error_Handler.Add_Error_Token
5396 ( p_message_name => 'BOM_ITEM_NO_LOCATOR_CONTROL'
5397 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5398 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5399 , p_Token_Tbl => g_Token_Tbl
5400 );
5401 END IF;
5402
5403 END IF;
5404 l_return_status := FND_API.G_RET_STS_ERROR;
5405 ELSIF p_rev_component_rec.location_name IS NOT NULL AND
5406 p_rev_component_rec.supply_subinventory IS NULL
5407 THEN
5408 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
5409 THEN
5410 Error_Handler.Add_Error_Token
5411 ( p_message_name => 'BOM_LOCATOR_MUST_BE_NULL'
5412 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5413 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5414 , p_Token_Tbl => g_Token_Tbl
5415 );
5416 END IF;
5417 l_return_status := FND_API.G_RET_STS_ERROR;
5418 END IF;
5419
5420 -- dbms_output.put_line('Operation CREATE ENDS . . .' || l_return_status);
5421 /*******************************************************************
5422 --
5423 -- Item Num Check
5424 --
5425 ********************************************************************/
5426 /*Fix for bug 5053977- This validation should be done from ECO form.
5427 It is not done for BOM/ECO BO because it is performance intensive. */
5428 IF (p_Control_rec.caller_type = 'FORM' AND
5429 p_control_rec.validation_controller = 'ITEM_SEQUENCE_NUMBER')
5430 AND
5431 ( NVL(p_rev_component_rec.acd_type,1) = 1 OR
5432 ( p_rev_component_rec.acd_type = 2 AND
5433 ( p_rev_component_rec.item_sequence_number <>
5434 p_old_rev_component_rec.item_sequence_number)
5435 )
5436 )
5437 THEN
5438 -- Verify if a component is already added using this item_num
5439 -- If there is, log a WARNING.
5440
5441 item_num_for_bill := 0;
5442 g_Token_Tbl.Delete;
5443 g_token_tbl(1).token_name := 'ITEM_SEQUENCE_NUMBER';
5444 g_token_tbl(1).token_value := p_rev_component_rec.item_sequence_number;
5445 g_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
5446 g_token_tbl(2).token_value := p_rev_component_rec.component_item_name;
5447
5448 IF NOT l_is_item_unit_controlled
5449 THEN
5450 FOR Item_Num in c_ItemDateNum LOOP
5451 item_num_for_bill := 1;
5452 END LOOP;
5453 ELSE
5454 FOR Item_Num in c_ItemUnitNum LOOP
5455 item_num_for_bill := 1;
5456 END LOOP;
5457 END IF;
5458
5459 IF item_num_for_bill = 1 THEN
5460 Error_Handler.Add_Error_Token
5461 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5462 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5463 , p_message_name => 'BOM_ITEM_NUM_NOT_UNIQUE'
5464 , p_Token_Tbl => g_Token_Tbl
5465 , p_message_type => 'W'
5466 );
5467 END IF;
5468
5469 END IF; -- Item Num Check ends
5470 /* Fix for bug 5053977 ends here. */
5471
5472 END IF; -- Operation in UPDATE or CREATE
5473
5474
5475 -- Added by MK on 06/04/2001
5476 IF BOM_Globals.Get_Bo_Identifier = BOM_Globals.G_BOM_BO AND
5477 p_rev_component_rec.transaction_type = BOM_Globals.G_OPR_DELETE
5478 THEN
5479 IF p_rev_comp_unexp_rec.Delete_Group_Name IS NULL OR
5480 p_rev_comp_unexp_rec.Delete_Group_Name = FND_API.G_MISS_CHAR
5481 THEN
5482
5483 Error_Handler.Add_Error_Token
5484 ( p_message_name => 'BOM_DG_NAME_MISSING'
5485 , p_mesg_token_tbl => l_mesg_token_tbl
5486 , x_mesg_token_tbl => l_mesg_token_tbl
5487 );
5488
5489 l_return_status := FND_API.G_RET_STS_ERROR;
5490
5491 END IF;
5492
5493 IF BOM_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
5494 ('Check if Delete Group is missing . . . ' || l_return_status) ;
5495 END IF ;
5496
5497
5498 END IF ;
5499
5500 /********************************************************************
5501 -- If the structure type is Packaging Hierarchy the we will do the
5502 -- following validations
5503 ********************************************************************/
5504 IF p_Control_rec.caller_type <> 'FORM' THEN
5505 SELECT STRUCTURE_TYPE_NAME
5506 INTO
5507 l_Structure_Type_Name
5508 FROM BOM_STRUCTURE_TYPES_B STRUCT_TYPE,
5509 BOM_STRUCTURES_B BOM_STRUCT
5510 WHERE BOM_STRUCT.STRUCTURE_TYPE_ID = STRUCT_TYPE.STRUCTURE_TYPE_ID
5511 AND BOM_STRUCT.BILL_SEQUENCE_ID = g_Rev_Comp_Unexp_Rec.BILL_SEQUENCE_ID;
5512
5513 IF (l_Structure_Type_Name ='Packaging Hierarchy') THEN
5514 IF p_rev_component_rec.quantity_per_assembly < 0
5515 THEN
5516 Error_Handler.Add_Error_Token
5517 ( p_message_name => 'BOM_PKG_HIER_NEGATIVE_QTY'
5518 , p_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
5519 , x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
5520 , p_Token_Tbl => g_Token_Tbl
5521 );
5522
5523 l_return_status := FND_API.G_RET_STS_ERROR;
5524 END IF;
5525 IF round(p_rev_component_rec.quantity_per_assembly) <> p_rev_component_rec.quantity_per_assembly
5526 THEN
5527 Error_Handler.Add_Error_Token
5528 ( p_message_name => 'BOM_PKG_HIER_FRACTIONAL_QTY'
5529 , p_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
5530 , x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
5531 , p_Token_Tbl => g_Token_Tbl
5532 );
5533
5534 l_return_status := FND_API.G_RET_STS_ERROR;
5535 END IF;
5536 END IF;
5537 END IF;
5538
5539 -- Component Type Rule Validations.
5540 -- Bug No: 4397973. Check Component types only when the current retrun status is success.
5541 IF (l_return_status = FND_API.G_RET_STS_SUCCESS)
5542 THEN
5543 IF ( p_rev_component_rec.Transaction_Type = BOM_GLOBALS.G_OPR_CREATE )
5544 THEN
5545 Bom_Validate_Bom_Component.Check_Component_Type_Rule
5546 ( x_return_status => l_return_status
5547 , x_error_message => l_debug_error_mesg
5548 , p_init_msg_list => FALSE
5549 , p_parent_item_id => p_Rev_Comp_Unexp_Rec.Revised_Item_Id
5550 , p_child_item_id => p_Rev_Comp_Unexp_Rec.Component_Item_Id
5551 , p_organization_id => p_Rev_Comp_Unexp_Rec.Organization_Id
5552 );
5553
5554 IF (l_return_status = FND_API.G_RET_STS_ERROR)
5555 THEN
5556 Error_Handler.Add_Error_Token
5557 ( p_Message_Text => l_debug_error_mesg
5558 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5559 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5560 );
5561 END IF;
5562 END IF;
5563 END IF;
5564
5565 IF BOM_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
5566 ('Check Component Type Rule . . . ' || l_return_status) ;
5567 END IF ;
5568
5569 x_return_status := l_return_status;
5570 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
5571
5572 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity Validation done . . . Return Status is ' || l_return_status); END IF;
5573
5574 EXCEPTION
5575
5576 WHEN FND_API.G_EXC_ERROR THEN
5577
5578 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Expected Error in Rev. Comp. Entity Validation . . .'); END IF;
5579
5580 x_return_status := FND_API.G_RET_STS_ERROR;
5581 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
5582
5583 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5584
5585 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('UNExpected Error in Rev. Comp. Entity Validation . . .'); END IF;
5586
5587 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5588 IF FND_MSG_PUB.Check_Msg_Level
5589 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5590 THEN
5591 l_err_text := G_PKG_NAME ||
5592 ' : (Entity Validation) ' ||
5593 substrb(SQLERRM,1,200);
5594 Error_Handler.Add_Error_Token
5595 ( p_Message_Text => l_err_text
5596 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5597 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5598 );
5599 END IF;
5600 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
5601
5602 WHEN OTHERS THEN
5603 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug(SQLERRM || ' ' || TO_CHAR(SQLCODE)); END IF;
5604 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5605 IF FND_MSG_PUB.Check_Msg_Level
5606 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5607 THEN
5608 l_err_text := G_PKG_NAME ||
5609 ' : (Entity Validation) ' ||
5610 substrb(SQLERRM,1,200);
5611 Error_Handler.Add_Error_Token
5612 ( p_Message_Text => l_err_text
5613 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5614 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5615 );
5616 END IF;
5617 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
5618
5619 END Check_Entity;
5620
5621 /***************************************************************
5622 * Procedure : Check_Attribute (Validation)
5623 * Parameters IN : Revised Component Record of exposed columns
5624 * Parameters OUT: Mesg_Token_Tbl
5625 * Return_Status
5626 * Purpose : Attribute validation procedure will validate each
5627 * attribute of Revised component in its entirety. If
5628 * the validation of a column requires looking at some
5629 * other columns value then the validation is done at
5630 * the Entity level instead.
5631 * All errors in the attribute validation are accumulated
5632 * before the procedure returns with a Return_Status
5633 * of 'E'.
5634 *********************************************************************/
5635 PROCEDURE Check_Attributes
5636 ( x_return_status IN OUT NOCOPY VARCHAR2
5637 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
5638 , p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
5639 , p_Rev_Comp_Unexp_Rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
5640 )
5641 IS
5642
5643 l_return_status VARCHAR2(1);
5644 l_err_text VARCHAR2(2000);
5645 l_assembly_item_id NUMBER;
5646 l_org_id NUMBER;
5647 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
5648
5649 CURSOR c_Geteffcontrol IS SELECT effectivity_control FROM mtl_system_items
5650 WHERE inventory_item_id = p_rev_comp_unexp_rec.component_item_id AND
5651 organization_id = l_org_id;
5652
5653 BEGIN
5654
5655 x_return_status := FND_API.G_RET_STS_SUCCESS;
5656 l_return_status := FND_API.G_RET_STS_SUCCESS;
5657
5658 g_rev_component_rec := p_rev_component_rec;
5659
5660 -- Set the first token to be equal to the component_name
5661 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
5662 g_Token_Tbl(1).Token_Value :=
5663 p_rev_component_rec.component_item_name;
5664
5665 l_assembly_item_id := Bom_Globals.Get_Assembly_item_Id;
5666 l_org_id := Bom_Globals.Get_Org_Id;
5667
5668 --
5669 -- Check if the user is trying to create/update a record with
5670 -- missing value when the column value is required.
5671 --
5672 IF p_rev_component_rec.item_sequence_number = FND_API.G_MISS_NUM
5673 THEN
5674 Error_Handler.Add_Error_Token
5675 ( p_Message_Name => 'BOM_ITEM_NUM_MISSING'
5676 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5677 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5678 , p_Token_Tbl => g_Token_Tbl
5679 );
5680 l_return_status := FND_API.G_RET_STS_ERROR;
5681 END IF;
5682
5683 IF p_rev_component_rec.quantity_per_assembly =
5684 FND_API.G_MISS_NUM
5685 THEN
5686 Error_Handler.Add_Error_Token
5687 ( p_Message_Name => 'BOM_COMP_QUANTITY_MISSING'
5688 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5689 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5690 , p_Token_Tbl => g_Token_Tbl
5691 );
5692 l_return_status := FND_API.G_RET_STS_ERROR;
5693 END IF;
5694
5695 IF p_rev_component_rec.projected_yield = FND_API.G_MISS_NUM
5696 THEN
5697 Error_Handler.Add_Error_Token
5698 ( p_Message_Name => 'BOM_COMP_YIELD_MISSING'
5699 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5700 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5701 , p_Token_Tbl => g_Token_Tbl
5702 );
5703 l_return_status := FND_API.G_RET_STS_ERROR;
5704 END IF;
5705
5706 IF p_rev_component_rec.planning_percent = FND_API.G_MISS_NUM
5707 THEN
5708 Error_Handler.Add_Error_Token
5709 ( p_Message_Name => 'BOM_PLAN_PERCENT_MISSING'
5710 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5711 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5712 , p_Token_Tbl => g_Token_Tbl
5713 );
5714 l_return_status := FND_API.G_RET_STS_ERROR;
5715 END IF;
5716
5717 IF p_rev_component_rec.quantity_related = FND_API.G_MISS_NUM
5718 THEN
5719 Error_Handler.Add_Error_Token
5720 ( p_Message_Name => 'BOM_QUANTITY_RELATED_MISSING'
5721 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5722 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5723 , p_Token_Tbl => g_Token_Tbl
5724 );
5725 l_return_status := FND_API.G_RET_STS_ERROR;
5726 END IF;
5727
5728 IF p_rev_component_rec.include_in_cost_rollup = FND_API.G_MISS_NUM
5729 THEN
5730 Error_Handler.Add_Error_Token
5731 ( p_Message_Name => 'BOM_INCL_IN_CST_ROLLUP_MISSING'
5732 -- 'BOM_INCL_IN_COST_ROLLUP_MISSING'
5733 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5734 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5735 , p_Token_Tbl => g_Token_Tbl
5736 );
5737 l_return_status := FND_API.G_RET_STS_ERROR;
5738 END IF;
5739
5740 IF p_rev_component_rec.check_atp = FND_API.G_MISS_NUM
5741 THEN
5742 Error_Handler.Add_Error_Token
5743 ( p_Message_Name => 'BOM_CHECK_ATP_MISSING'
5744 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5745 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5746 , p_Token_Tbl => g_Token_Tbl
5747 );
5748 l_return_status := FND_API.G_RET_STS_ERROR;
5749 END IF;
5750
5751
5752 IF p_rev_component_rec.acd_type IS NOT NULL AND
5753 p_rev_component_rec.acd_type NOT IN (1, 2, 3) AND
5754 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_ECO_BO
5755 THEN
5756 g_token_tbl(2).token_name := 'ACD_TYPE';
5757 g_token_tbl(2).token_value := p_rev_component_rec.acd_type;
5758
5759 Error_Handler.Add_Error_Token
5760 ( p_Message_Name => 'BOM_ACD_TYPE_INVALID'
5761 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5762 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5763 , p_Token_Tbl => g_Token_Tbl
5764 );
5765 l_return_status := FND_API.G_RET_STS_ERROR;
5766 END IF;
5767
5768 -- Validate rev_component attributes
5769
5770 -- The following validation should not be done for serial effective items
5771
5772 -- Validate from_end_item_unit_number 5482117
5773
5774 IF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_CREATE
5775 AND (p_rev_component_rec.from_end_item_unit_number IS NOT NULL AND p_rev_component_rec.from_end_item_unit_number <> FND_API.G_MISS_CHAR)
5776 AND BOM_EAMUTIL.Asset_group_Item(item_id => l_assembly_item_id, org_id => l_org_Id) = 'N'
5777 THEN
5778 IF NOT Bom_Validate.End_Item_Unit_Number
5779 ( p_from_end_item_unit_number => p_rev_component_rec.from_end_item_unit_number
5780 , p_revised_item_id => p_rev_comp_unexp_rec.component_item_id
5781 , x_err_text => l_err_text
5782 )
5783 THEN
5784 g_token_tbl(1).token_name := 'FROM_END_ITEM_UNIT_NUMBER';
5785 g_token_tbl(1).token_value := p_rev_component_rec.from_end_item_unit_number;
5786 g_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
5787 g_token_tbl(2).token_value := p_rev_component_rec.component_item_name;
5788 g_token_tbl(3).token_name := 'ORGANIZATION_CODE';
5789 g_token_tbl(3).token_value := p_rev_component_rec.organization_code;
5790 Error_Handler.Add_Error_Token
5791 ( p_Message_Name=> 'BOM_CMP_FROM_UNIT_NUM_INVALID'
5792 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5793 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5794 , p_Token_Tbl => g_Token_Tbl
5795 );
5796 l_return_status := FND_API.G_RET_STS_ERROR;
5797 END IF;
5798 END IF;
5799
5800 IF p_rev_component_rec.transaction_type =
5801 BOM_GLOBALS.G_OPR_CREATE AND
5802 (p_rev_component_rec.to_end_item_unit_number IS NOT NULL
5803 AND
5804 p_rev_component_rec.to_end_item_unit_number <>
5805 FND_API.G_MISS_CHAR) AND
5806 BOM_EAMUTIL.Asset_group_Item(
5807 item_id => l_assembly_item_id,
5808 org_id => l_org_Id) = 'N'
5809 THEN
5810 IF NOT Bom_Validate.End_Item_Unit_Number
5811 ( p_from_end_item_unit_number =>
5812 p_rev_component_rec.to_end_item_unit_number
5813 , p_revised_item_id =>
5814 p_rev_comp_unexp_rec.component_item_id
5815 , x_err_text => l_err_text
5816 )
5817 THEN
5818 l_return_status := FND_API.G_RET_STS_ERROR;
5819 g_token_tbl(1).token_name :=
5820 'FROM_END_ITEM_UNIT_NUMBER';
5821 g_token_tbl(1).token_value :=
5822 p_rev_component_rec.to_end_item_unit_number;
5823 g_token_tbl(2).token_name :=
5824 'REVISED_COMPONENT_NAME';
5825 g_token_tbl(2).token_value :=
5826 p_rev_component_rec.component_item_name;
5827 g_token_tbl(3).token_name :=
5828 'ORGANIZATION_CODE';
5829 g_token_tbl(3).token_value :=
5830 p_rev_component_rec.organization_code;
5831 Error_Handler.Add_Error_Token
5832 ( p_Message_Name=> 'BOM_CMP_TO_UNIT_NUM_INVALID'
5833 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5834 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5835 , p_Token_Tbl => g_Token_Tbl
5836 );
5837 END IF;
5838 END IF;
5839
5840
5841 -- END IF;
5842
5843 -- Added in 11.5.9 by ADEY
5844 IF p_rev_component_rec.auto_request_material IS NOT NULL AND
5845 UPPER(p_rev_component_rec.auto_request_material) NOT IN ('Y','N')
5846 THEN
5847 g_token_tbl(2).token_name := 'AUTO_REQ_MATERIAL';
5848 g_token_tbl(2).token_value := p_rev_component_rec.auto_request_material;
5849
5850 Error_Handler.Add_Error_Token
5851 ( p_Message_Name => 'BOM_AUTO_REQ_MAT_INVALID'
5852 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5853 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5854 , p_Token_Tbl => g_Token_Tbl
5855 );
5856 l_return_status := FND_API.G_RET_STS_ERROR;
5857 END IF;
5858
5859
5860 /* Comment Out by MK on 11/20/00
5861 -- This validation is not required
5862 -- Modified condition by MK on 11/08/00
5863 IF p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_CREATE AND
5864 ( p_rev_component_rec.from_end_item_unit_number <> FND_API.G_MISS_CHAR OR
5865 p_rev_component_rec.from_end_item_unit_number IS NOT NULL ) AND
5866 ( p_rev_component_rec.to_end_item_unit_number = FND_API.G_MISS_CHAR OR
5867 p_rev_component_rec.to_end_item_unit_number IS NULL )
5868 THEN
5869 Error_Handler.Add_Error_Token
5870 ( p_Message_Name => 'BOM_CMP_TO_UNIT_NUM_NULL'
5871 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5872 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5873 , p_Token_Tbl => g_Token_Tbl
5874 );
5875 l_return_status := FND_API.G_RET_STS_ERROR;
5876 END IF;
5877 */
5878
5879 -- Validations specific to EAM items (Asset Groups and Asset Activities)
5880
5881 IF BOM_EAMUTIL.Enabled = 'Y' THEN
5882
5883 IF BOM_EAMUTIL.Asset_group_Item( item_id => l_assembly_item_id,
5884 org_id => l_org_id ) = 'Y' THEN
5885
5886 -- An asset group can have only date effective components
5887
5888 FOR effctrlrec IN c_Geteffcontrol
5889 LOOP
5890 IF effctrlrec.effectivity_control <> 1 THEN
5891 Error_Handler.Add_Error_Token
5892 ( p_Message_Name => 'BOM_EFFCONTROL_INVALID'
5893 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5894 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5895 , p_Token_Tbl => g_Token_Tbl
5896 );
5897 l_return_status := FND_API.G_RET_STS_ERROR;
5898 END IF;
5899 END LOOP;
5900
5901 -- Validate the from_end_item_unit_number
5902
5903 IF NOT Bom_Validate.Asset_Group_Serial_Number
5904 ( p_assembly_item_id => l_assembly_item_id,
5905 p_organization_id => l_org_id,
5906 p_serial_number => p_rev_component_rec.from_end_item_unit_number,
5907 X_err_text => l_err_text ) THEN
5908 g_token_tbl(2).token_name := 'FROM_END_ITEM_UNIT_NUMBER';
5909 g_token_tbl(2).token_value :=
5910 p_rev_component_rec.from_end_item_unit_number;
5911 Error_Handler.Add_Error_Token
5912 ( p_Message_Name => 'BOM_INVALID_FROM_SERIAL_NO'
5913 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5914 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5915 , p_Token_Tbl => g_Token_Tbl
5916 , p_message_text => l_err_text
5917 );
5918 l_return_status := FND_API.G_RET_STS_ERROR;
5919 END IF;
5920
5921 -- Validate the to_end_item_unit_number
5922
5923 IF p_rev_component_rec.to_end_item_unit_number IS NOT NULL AND
5924 p_rev_component_rec.to_end_item_unit_number <> FND_API.G_MISS_CHAR
5925 THEN
5926
5927 IF NOT Bom_Validate.Asset_Group_Serial_Number
5928 ( p_assembly_item_id => l_assembly_item_id,
5929 p_organization_id => l_org_id,
5930 p_serial_number => p_rev_component_rec.to_end_item_unit_number,
5931 X_err_text => l_err_text ) THEN
5932 g_token_tbl(2).token_name := 'TO_END_ITEM_UNIT_NUMBER';
5933 g_token_tbl(2).token_value :=
5934 p_rev_component_rec.to_end_item_unit_number;
5935 Error_Handler.Add_Error_Token
5936 ( p_Message_Name => 'BOM_INVALID_TO_SERIAL_NO'
5937 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5938 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5939 , p_Token_Tbl => g_Token_Tbl
5940 , p_message_text => l_err_text
5941 );
5942 l_return_status := FND_API.G_RET_STS_ERROR;
5943 END IF;
5944 END IF;
5945
5946 -- An asset group or activity cannnot be a component of another asset group
5947
5948 IF BOM_EAMUTIL.Asset_Activity_Item(
5949 item_id => p_rev_comp_unexp_rec.component_item_id,
5950 org_id => l_org_id )= 'Y'
5951 OR
5952 BOM_EAMUTIL.Asset_Group_Item(
5953 item_id => p_rev_comp_unexp_rec.component_item_id,
5954 org_id => l_org_id ) = 'Y' THEN
5955
5956 g_token_tbl(2).token_name := 'COMPONENT_ITEM_NAME';
5957 g_token_tbl(2).token_value :=
5958 p_rev_component_rec.component_item_name;
5959 Error_Handler.Add_Error_Token
5960 ( p_Message_Name => 'BOM_COMP_CANNOT_BE_AN_AG'
5961 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5962 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5963 , p_Token_Tbl => g_Token_Tbl
5964 );
5965 l_return_status := FND_API.G_RET_STS_ERROR;
5966 END IF;
5967
5968 END IF;
5969
5970 -- Asset activity items cannot have any supply types other than Push
5971 -- and Bulk
5972
5973 IF BOM_EAMUTIL.Asset_Activity_Item( item_id => l_assembly_item_id,
5974 org_id => l_org_id ) = 'Y' THEN
5975 IF p_rev_component_rec.wip_supply_type NOT IN (1,4) THEN
5976 g_token_tbl(2).token_name := 'WIP_SUPPLY_TYPE';
5977 g_token_tbl(2).token_value :=
5978 p_rev_component_rec.wip_supply_type;
5979 Error_Handler.Add_Error_Token
5980 ( p_Message_Name => 'BOM_INVALID_AA_SUPTYPES'
5981 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5982 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5983 , p_Token_Tbl => g_Token_Tbl
5984 );
5985 l_return_status := FND_API.G_RET_STS_ERROR;
5986 END IF;
5987
5988 -- An asset group cannnot be a component for an asset activity
5989
5990 IF BOM_EAMUTIL.Asset_Group_Item(
5991 item_id => p_rev_comp_unexp_rec.component_item_id,
5992 org_id => l_org_id ) = 'Y' THEN
5993
5994 g_token_tbl(2).token_name := 'COMPONENT_ITEM_NAME';
5995 g_token_tbl(2).token_value :=
5996 p_rev_component_rec.component_item_name;
5997 Error_Handler.Add_Error_Token
5998 ( p_Message_Name => 'BOM_COMP_CANNOT_BE_AN_AG'
5999 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6000 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6001 , p_Token_Tbl => g_Token_Tbl
6002 );
6003 l_return_status := FND_API.G_RET_STS_ERROR;
6004 END IF;
6005
6006 END IF;
6007
6008 END IF; -- End of attribute validations for EAM items
6009
6010
6011 IF p_rev_component_rec.wip_supply_type IS NOT NULL AND
6012 p_rev_component_rec.wip_supply_type = 7
6013 THEN
6014 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6015 THEN
6016 g_token_tbl(2).token_name := 'WIP_SUPPLY_TYPE';
6017 g_token_tbl(2).token_value :=
6018 p_rev_component_rec.wip_supply_type;
6019 Error_Handler.Add_Error_Token
6020 ( p_Message_Name => 'BOM_WIP_SUPPLY_TYPE_7'
6021 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6022 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6023 , p_Token_Tbl => g_Token_Tbl
6024 );
6025 g_token_tbl.delete(2);
6026 END IF;
6027 l_return_status := FND_API.G_RET_STS_ERROR;
6028
6029 ELSIF p_rev_component_rec.wip_supply_type IS NOT NULL AND
6030 p_rev_component_rec.wip_supply_type <> 7 AND
6031 NOT Bom_Validate.Wip_Supply_Type
6032 ( p_wip_supply_type => p_rev_component_rec.wip_supply_type
6033 , x_err_text => l_err_text
6034 )
6035 THEN
6036 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6037 THEN
6038 g_token_tbl(1).token_name := 'WIP_SUPPLY_TYPE';
6039 g_token_tbl(1).token_value :=
6040 p_rev_component_rec.wip_supply_type;
6041
6042 Error_Handler.Add_Error_Token
6043 ( p_Message_Name => 'BOM_WIP_SUPPLY_TYPE_INVALID'
6044 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6045 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6046 , p_Token_Tbl => g_Token_Tbl
6047 );
6048 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
6049 g_token_tbl(1).token_value :=
6050 p_rev_component_rec.component_item_name;
6051
6052 END IF;
6053 l_return_status := FND_API.G_RET_STS_ERROR;
6054 END IF;
6055
6056 IF p_rev_component_rec.operation_sequence_number IS NOT NULL AND
6057 p_rev_component_rec.operation_sequence_number <= 0
6058 THEN
6059 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6060 THEN
6061 Error_Handler.Add_Error_Token
6062 ( p_Message_Name => 'BOM_OPSEQ_LESS_THAN_ZERO'
6063 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6064 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6065 , p_Token_Tbl => g_Token_Tbl
6066 );
6067 END IF;
6068 l_return_status := FND_API.G_RET_STS_ERROR;
6069 END IF;
6070
6071 -- dbms_output.put_line('After Operation Sequence Num . . . ' || l_return_status);
6072
6073 IF p_rev_component_rec.item_sequence_number IS NOT NULL AND
6074 ( p_rev_component_rec.item_sequence_number < 0 OR
6075 /* p_rev_component_rec.item_sequence_number > 9999999 */
6076 p_rev_component_rec.item_sequence_number > (power(10,38)-1) /*
6077 bug 7437710 */
6078 )
6079 THEN
6080 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6081 THEN
6082 Error_Handler.Add_Error_Token
6083 ( p_Message_Name => 'BOM_ITEM_NUM_INVALID'
6084 , p_Mesg_token_Tbl => l_Mesg_token_Tbl
6085 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6086 , p_token_tbl => g_Token_Tbl
6087 );
6088 END IF;
6089 l_return_status := FND_API.G_RET_STS_ERROR;
6090 END IF;
6091
6092 IF p_rev_component_rec.projected_yield IS NOT NULL AND
6093 p_rev_component_rec.projected_yield < 0 OR
6094 p_rev_component_rec.projected_yield > 1
6095 THEN
6096 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6097 THEN
6098 g_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
6099 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
6100 Error_Handler.Add_Error_Token
6101 ( p_Message_Name => 'BOM_COMPYIELD_OUT_OF_RANGE'
6102 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6103 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6104 , p_token_tbl => g_token_tbl
6105 , p_message_type => 'W' -- Bug 3226917
6106 );
6107 END IF;
6108 --l_return_status := FND_API.G_RET_STS_ERROR;
6109 END IF;
6110
6111 IF p_rev_component_rec.include_in_cost_rollup IS NOT NULL AND
6112 p_rev_component_rec.include_in_cost_rollup NOT IN (1,2)
6113 THEN
6114 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6115 THEN
6116 Error_Handler.Add_Error_Token
6117 ( p_Message_Name => 'BOM_INCL_IN_COST_ROLL_INVALID'
6118 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6119 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6120 , p_Token_Tbl => g_Token_Tbl
6121 );
6122 END IF;
6123 l_return_status := FND_API.G_RET_STS_ERROR;
6124 END IF;
6125
6126 IF p_rev_component_rec.SO_Basis IS NOT NULL AND
6127 p_rev_component_rec.SO_Basis NOT IN (1, 2)
6128 THEN
6129 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6130 THEN
6131 Error_Handler.Add_Error_Token
6132 ( p_Message_Name => 'BOM_SO_BASIS_INVALID'
6133 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6134 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6135 , p_Token_Tbl => g_Token_Tbl
6136 );
6137 END IF;
6138 l_return_status := FND_API.G_RET_STS_ERROR;
6139 END IF;
6140
6141 IF p_rev_component_rec.optional IS NOT NULL AND
6142 p_rev_component_rec.optional NOT IN (1, 2)
6143 THEN
6144 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6145 THEN
6146 Error_Handler.Add_Error_Token
6147 ( p_Message_Name => 'BOM_OPTIONAL_INVALID'
6148 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6149 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6150 , p_Token_Tbl => g_Token_Tbl
6151 );
6152 END IF;
6153 l_return_status := FND_API.G_RET_STS_ERROR;
6154 END IF;
6155
6156 IF p_rev_component_rec.mutually_exclusive IS NOT NULL AND
6157 p_rev_component_rec.mutually_exclusive NOT IN (1, 2)
6158 THEN
6159 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6160 THEN
6161 Error_Handler.Add_Error_Token
6162 ( p_Message_Name => 'BOM_MUTUALLY_EXCLUSIVE_INVALID'
6163 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6164 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6165 , p_Token_Tbl => g_Token_Tbl
6166 );
6167 END IF;
6168 l_return_status := FND_API.G_RET_STS_ERROR;
6169 END IF;
6170
6171 IF p_rev_component_rec.check_atp IS NOT NULL AND
6172 p_rev_component_rec.check_atp NOT IN (1, 2)
6173 THEN
6174 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6175 THEN
6176 Error_Handler.Add_Error_Token
6177 ( p_Message_Name => 'BOM_CHECK_ATP_INVALID'
6178 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6179 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6180 , p_Token_Tbl => g_Token_Tbl
6181 );
6182 END IF;
6183 l_return_status := FND_API.G_RET_STS_ERROR;
6184 END IF;
6185
6186 IF p_rev_component_rec.shipping_allowed IS NOT NULL AND
6187 p_rev_component_rec.shipping_allowed NOT IN (1, 2)
6188 THEN
6189 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6190 THEN
6191 Error_Handler.Add_Error_Token
6192 ( p_Message_Name => 'BOM_SHIPPING_ALLOWED_INVALID'
6193 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6194 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6195 , p_Token_Tbl => g_Token_Tbl
6196 );
6197 END IF;
6198 l_return_status := FND_API.G_RET_STS_ERROR;
6199 END IF;
6200
6201 IF p_rev_component_rec.required_to_ship IS NOT NULL AND
6202 p_rev_component_rec.required_to_ship NOT IN (1, 2)
6203 THEN
6204 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6205 THEN
6206 Error_Handler.Add_Error_Token
6207 ( p_Message_Name => 'BOM_REQUIRED_TO_SHIP_INVALID'
6208 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6209 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6210 , p_Token_Tbl => g_Token_Tbl
6211 );
6212 END IF;
6213 l_return_status := FND_API.G_RET_STS_ERROR;
6214 END IF;
6215
6216 IF p_rev_component_rec.required_for_revenue IS NOT NULL AND
6217 p_rev_component_rec.required_for_revenue NOT IN (1, 2)
6218 THEN
6219 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6220 THEN
6221 Error_Handler.Add_Error_Token
6222 ( p_Message_Name => 'BOM_REQ_FOR_REVENUE_INVALID'
6223 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6224 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6225 , p_Token_Tbl => g_Token_Tbl
6226 );
6227 END IF;
6228 l_return_status := FND_API.G_RET_STS_ERROR;
6229 END IF;
6230
6231 IF p_rev_component_rec.include_on_ship_docs IS NOT NULL AND
6232 p_rev_component_rec.include_on_ship_docs NOT IN (1, 2)
6233 THEN
6234 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6235 THEN
6236 Error_Handler.Add_Error_Token
6237 ( p_Message_Name => 'BOM_INCL_ON_SHIP_DOCS_INVALID'
6238 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6239 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6240 , p_Token_Tbl => g_Token_Tbl
6241 );
6242 END IF;
6243 l_return_status := FND_API.G_RET_STS_ERROR;
6244 END IF;
6245
6246 IF p_rev_component_rec.quantity_related IS NOT NULL AND
6247 p_rev_component_rec.quantity_related NOT IN (1, 2)
6248 THEN
6249 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_SUCCESS)
6250 THEN
6251 Error_Handler.Add_Error_Token
6252 ( p_Message_Name => 'BOM_QTY_RELATED_INVALID'
6253 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6254 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6255 , p_Token_Tbl => g_Token_Tbl
6256 );
6257 END IF;
6258 l_return_status := FND_API.G_RET_STS_ERROR;
6259 END IF;
6260
6261 -- Validation specific to unimplemented BOM
6262 Error_handler.write_debug ('BOM Implementation date is '||p_rev_comp_unexp_rec.bom_implementation_date);
6263
6264 IF p_rev_comp_unexp_rec.bom_implementation_date IS NULL
6265 /* added a dummy condition to make sure this validation happens for any BOM, no matter whether the BOM is fluid or not */
6266 OR 1=1
6267 THEN
6268 IF p_rev_component_rec.new_effectivity_date IS NOT NULL AND
6269 p_rev_component_rec.new_effectivity_date <> FND_API.G_MISS_DATE AND
6270 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
6271 THEN
6272 /* Check revision exists for revised item */
6273 IF NOT Item_Revision_Exists(p_rev_comp_unexp_rec.revised_item_id,
6274 p_rev_comp_unexp_rec.organization_id,
6275 p_rev_component_rec.new_effectivity_date)
6276 THEN
6277 g_token_tbl(1).token_name := 'ITEM_NAME';
6278 g_token_tbl(1).token_value := p_rev_component_rec.revised_item_name;
6279 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6280 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6281 g_token_tbl(3).token_name := 'NEW_EFFECTIVE_DATE';
6282 g_token_tbl(3).token_value := p_rev_component_rec.new_effectivity_date;
6283
6284 Error_Handler.Add_Error_Token
6285 ( p_Message_Name => 'BOM_DATE_LESS_ITEMREV'
6286 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6287 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6288 , p_Token_Tbl => g_Token_Tbl
6289 );
6290 l_return_status := FND_API.G_RET_STS_ERROR;
6291 END IF;
6292
6293 /* Check revision exists for component item */
6294
6295 IF NOT Item_Revision_Exists(p_rev_comp_unexp_rec.component_item_id,
6296 p_rev_comp_unexp_rec.organization_id,
6297 p_rev_component_rec.new_effectivity_date)
6298 THEN
6299 g_token_tbl(1).token_name := 'ITEM_NAME';
6300 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
6301 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6302 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6303 g_token_tbl(3).token_name := 'NEW_EFFECTIVE_DATE';
6304 g_token_tbl(3).token_value := p_rev_component_rec.new_effectivity_date;
6305
6306 Error_Handler.Add_Error_Token
6307 ( p_Message_Name => 'BOM_DATE_LESS_ITEMREV'
6308 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6309 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6310 , p_Token_Tbl => g_Token_Tbl
6311 );
6312 l_return_status := FND_API.G_RET_STS_ERROR;
6313 END IF;
6314 END IF;
6315
6316 ELSE
6317 /* The validation to check the new effective date < sysdate has been commented since the business objects should be able to support migrating the old data from legacy system into apps. The new date validation is always done
6318 in the UI */
6319
6320 Null;
6321
6322 /* commented for bug 3281414
6323 IF p_rev_component_rec.new_effectivity_date IS NOT NULL AND
6324 p_rev_component_rec.new_effectivity_date <> FND_API.G_MISS_DATE AND
6325 p_rev_component_rec.new_effectivity_date < SYSDATE AND
6326 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
6327 THEN
6328 g_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
6329 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
6330 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6331 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6332 g_token_tbl(3).token_name := 'NEW_EFFECTIVE_DATE';
6333 g_token_tbl(3).token_value := p_rev_component_rec.new_effectivity_date;
6334
6335 Error_Handler.Add_Error_Token
6336 ( p_Message_Name => 'BOM_NEW_DATE_LESS_CURR'
6337 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6338 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6339 , p_Token_Tbl => g_Token_Tbl
6340 );
6341 l_return_status := FND_API.G_RET_STS_ERROR;
6342
6343 END IF;
6344 */
6345 END IF;
6346
6347 /* added a condition to make sure this validation happens during create for any BOM, no matter whether the BOM is fluid or not */
6348 IF (p_rev_comp_unexp_rec.bom_implementation_date IS NULL )
6349 /* OR (p_rev_component_rec.transaction_type = BOM_GLOBALS.G_OPR_CREATE)*/
6350 --Commented for bug 5702625.
6351 THEN
6352 IF p_rev_component_rec.start_effective_date IS NOT NULL AND
6353 p_rev_component_rec.start_effective_date <> FND_API.G_MISS_DATE AND
6354 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
6355 THEN
6356 /* Check revision exists for revised item */
6357 Error_handler.write_debug ('Checking for item revision start date');
6358 IF NOT Item_Revision_Exists(p_rev_comp_unexp_rec.revised_item_id,
6359 p_rev_comp_unexp_rec.organization_id,
6360 p_rev_component_rec.start_effective_date)
6361 THEN
6362 Error_handler.write_debug ('Checking for item revision start date error');
6363 g_token_tbl(1).token_name := 'ITEM_NAME';
6364 g_token_tbl(1).token_value := p_rev_component_rec.revised_item_name;
6365 --g_token_tbl(1).token_value := to_char(p_rev_comp_unexp_rec.revised_item_id)||':'||to_char(p_rev_comp_unexp_rec.organization_id)||':'||to_char(p_rev_component_rec.start_effective_date,'dd-mon-yyyy hh24:mi:ss');
6366 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6367 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6368
6369 Error_Handler.Add_Error_Token(
6370 p_Message_Name => 'BOM_SDATE_LESS_ITEMREV'
6371 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6372 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6373 , p_Token_Tbl => g_Token_Tbl
6374 );
6375 l_return_status := FND_API.G_RET_STS_ERROR;
6376 END IF;
6377
6378 /* Check revision exists for component item */
6379
6380 IF NOT Item_Revision_Exists(p_rev_comp_unexp_rec.component_item_id,
6381 p_rev_comp_unexp_rec.organization_id,
6382 p_rev_component_rec.start_effective_date)
6383 THEN
6384 g_token_tbl(1).token_name := 'ITEM_NAME';
6385 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
6386 --g_token_tbl(1).token_value := to_char(p_rev_comp_unexp_rec.component_item_id)||':'||to_char(p_rev_comp_unexp_rec.organization_id)||':'||to_char(p_rev_component_rec.start_effective_date,'dd-mon-yyyy hh24:mi:ss');
6387 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6388 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6389
6390 Error_Handler.Add_Error_Token
6391 ( p_Message_Name => 'BOM_SDATE_LESS_ITEMREV'
6392 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6393 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6394 , p_Token_Tbl => g_Token_Tbl
6395 );
6396 l_return_status := FND_API.G_RET_STS_ERROR;
6397 END IF;
6398 END IF;
6399
6400 ELSE
6401
6402 /* The validation to check the start effective date > sysdate has been commented
6403 since the business objects should be able to support migrating the old data
6404 from legacy system into apps. The start date validation is always done in the UI*/
6405
6406 Null;
6407
6408 /*
6409 IF p_rev_component_rec.start_effective_date IS NOT NULL AND
6410 p_rev_component_rec.start_effective_date <> FND_API.G_MISS_DATE AND
6411 trunc(p_rev_component_rec.start_effective_date) < trunc(SYSDATE) AND
6412 Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO
6413 THEN
6414 g_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
6415 g_token_tbl(1).token_value := p_rev_component_rec.component_item_name;
6416 g_token_tbl(2).token_name := 'EFFECTIVITY_DATE';
6417 g_token_tbl(2).token_value := p_rev_component_rec.start_effective_date;
6418
6419 Error_Handler.Add_Error_Token
6420 ( p_Message_Name => 'BOM_START_DATE_LESS_CURR'
6421 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6422 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6423 , p_Token_Tbl => g_Token_Tbl
6424 );
6425 l_return_status := FND_API.G_RET_STS_ERROR;
6426
6427 END IF;
6428 */
6429
6430 END IF;
6431
6432 -- Validation specific to enforce integer requirements
6433
6434 IF p_rev_comp_unexp_rec.enforce_int_requirements_code = 1 /* If the enforce int req is 'Up' */
6435 THEN
6436
6437 BEGIN
6438 /* Enforce_Integer can be UP only if the component item's rounding control type allows
6439 to round order quantities */
6440
6441 SELECT 'x' INTO l_dummy FROM mtl_system_items WHERE
6442 inventory_item_id = p_rev_comp_unexp_rec.component_item_id
6443 AND organization_id = p_rev_comp_unexp_rec.organization_id
6444 AND rounding_control_type = 1;
6445
6446 EXCEPTION WHEN NO_DATA_FOUND THEN
6447 g_token_tbl.DELETE;
6448 Error_Handler.Add_Error_Token
6449 ( p_Message_Name => 'BOM_ENFORCE_INT_INVALID'
6450 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6451 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6452 , p_Token_Tbl => g_Token_Tbl
6453 );
6454 l_return_status := FND_API.G_RET_STS_ERROR;
6455 END;
6456
6457 END IF;
6458
6459 --Validation to ensure that a pending structure header cannot be modified without an ECO
6460 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Checking if the BOM header is implemented . . .'); END IF;
6461
6462 IF BOM_GLOBALS.Get_Bill_Header_ECN(p_rev_comp_unexp_rec.bill_Sequence_id) IS NOT NULL
6463 AND (p_rev_component_rec.eco_name IS NULL OR p_rev_component_rec.eco_name = FND_API.G_MISS_CHAR)
6464 THEN
6465 g_token_tbl(1).token_name := 'ALTERNATE';
6466 g_token_tbl(1).token_value := nvl(p_rev_component_rec.Alternate_BOM_Code, bom_globals.retrieve_message('BOM', 'BOM_PRIMARY'));
6467 g_token_tbl(2).token_name := 'ASSY_ITEM';
6468 g_token_tbl(2).token_value := p_rev_component_rec.Revised_Item_Name;
6469 g_token_tbl(3).token_name := 'CHANGE_NOTICE';
6470 g_token_tbl(3).token_value := BOM_GLOBALS.Get_Bill_Header_ECN(p_rev_comp_unexp_rec.bill_Sequence_id);
6471
6472 Error_Handler.Add_Error_Token
6473 ( p_Message_Name => 'BOM_HEADER_UNIMPLEMENTED'
6474 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6475 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6476 , p_Token_Tbl => g_Token_Tbl
6477 );
6478 l_return_status := FND_API.G_RET_STS_ERROR;
6479
6480 END IF;
6481
6482 -- Done validating attributes
6483
6484 x_return_status := l_return_status;
6485 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6486
6487 EXCEPTION
6488
6489 WHEN OTHERS THEN
6490 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Some unknown error in Attribute Validation . . .' || SQLERRM ); END IF;
6491
6492 Error_Handler.Add_Error_Token
6493 ( p_Message_Name => NULL
6494 , p_Message_Text =>
6495 'Error in Rev Comp Attr. Validation '
6496 || SUBSTR(SQLERRM, 1, 30) || ' ' ||
6497 to_char(SQLCODE)
6498 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6499 , p_Mesg_Token_Tbl => l_Mesg_token_Tbl
6500 );
6501 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6502 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6503
6504 END Check_Attributes;
6505
6506
6507 /*******************************************************************
6508 * Procedure : Check_Entity_Delete
6509 * Parameters IN : Revised Component Exposed Column Record
6510 * Revised Component unexposed column record
6511 * Parameters OUT: Message Token Table
6512 * Return Status
6513 * Procedure : Will check if a component can be deleted.
6514 *******************************************************************/
6515 PROCEDURE Check_Entity_Delete
6516 ( x_return_status IN OUT NOCOPY VARCHAR2
6517 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
6518 , p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
6519 , p_Rev_Comp_Unexp_Rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
6520 )
6521 IS
6522 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6523 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
6524
6525 BEGIN
6526
6527 g_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
6528 g_Token_Tbl(1).Token_Value :=
6529 p_rev_component_rec.component_item_name;
6530
6531 --
6532 -- Verify that the component is not already cancelled.
6533 --
6534 IF p_rev_component_rec.Transaction_Type =
6535 BOM_GLOBALS.G_OPR_DELETE
6536 THEN
6537 BEGIN
6538 SELECT 'Component cancelled'
6539 INTO l_dummy
6540 FROM sys.dual
6541 WHERE NOT EXISTS
6542 (SELECT 1 from bom_inventory_components
6543 WHERE component_sequence_id =
6544 p_rev_comp_Unexp_rec.component_sequence_id
6545 )
6546 AND EXISTS (SELECT 1 from eng_revised_components
6547 WHERE component_sequence_id =
6548 p_rev_comp_Unexp_rec.component_sequence_id);
6549
6550 --
6551 -- if not exception is raised then record is deleted.
6552 -- so raise an error.
6553 --
6554 IF FND_MSG_PUB.Check_Msg_Level
6555 (FND_MSG_PUB.G_MSG_LVL_ERROR)
6556 THEN
6557 Error_Handler.Add_Error_Token
6558 ( p_Message_Name=> 'BOM_COMP_CANCELLED'
6559 , p_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
6560 , x_Mesg_Token_Tbl=> l_Mesg_Token_Tbl
6561 , p_Token_Tbl => g_Token_Tbl
6562 );
6563 END IF;
6564 l_return_status := FND_API.G_RET_STS_ERROR;
6565 EXCEPTION
6566 WHEN NO_DATA_FOUND THEN
6567 null; -- do nothing the record is valid.
6568 END;
6569 END IF;
6570
6571 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6572 x_return_status := l_return_status;
6573
6574 EXCEPTION
6575
6576 WHEN FND_API.G_EXC_ERROR THEN
6577
6578 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6579 x_return_status := FND_API.G_RET_STS_ERROR;
6580
6581 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6582 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6583 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6584
6585 WHEN OTHERS THEN
6586 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6587 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6588
6589 END Check_Entity_Delete;
6590
6591 /******************************************************************
6592 * Procedure : Check_Existence
6593 * Parameters IN : Revised component exposed column record
6594 * Revised component unexposed column record
6595 * Parameters OUT: Old Revised component exposed column record
6596 * Old Revised component unexposed column record
6597 * Mesg Token Table
6598 * Return Status
6599 * Purpose : Check_Existence will query using the primary key
6600 * information and return a success if the operation is
6601 * CREATE and the record EXISTS or will return an
6602 * error if the operation is UPDATE and record DOES NOT
6603 * EXIST.
6604 * In case of UPDATE if record exists, then the procedure
6605 * will return old record in the old entity parameters
6606 * with a success status.
6607 *********************************************************************/
6608 PROCEDURE Check_Existence
6609 ( p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
6610 , p_rev_comp_unexp_rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
6611 , x_old_rev_component_rec IN OUT NOCOPY Bom_Bo_Pub.Rev_Component_Rec_Type
6612 , x_old_rev_comp_unexp_rec IN OUT NOCOPY Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
6613 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
6614 , x_return_status IN OUT NOCOPY VARCHAR2
6615 )
6616 IS
6617 l_token_tbl Error_Handler.Token_Tbl_Type;
6618 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
6619 l_return_status VARCHAR2(1);
6620 BEGIN
6621 l_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
6622 l_Token_Tbl(1).Token_Value :=
6623 p_rev_component_rec.component_item_name;
6624 l_Token_Tbl(2).Token_Name := 'REVISED_ITEM_NAME';
6625 l_Token_Tbl(2).Token_Value :=
6626 p_rev_component_rec.revised_item_name;
6627
6628 Bom_Bom_Component_Util.Query_Row
6629 ( p_Component_Item_Id => p_rev_comp_unexp_rec.component_item_id
6630 , p_Operation_Sequence_Number =>
6631 p_rev_component_rec.operation_sequence_number
6632 , p_Effectivity_Date =>
6633 p_rev_component_rec.start_effective_date
6634 , p_Bill_Sequence_Id => p_rev_comp_unexp_rec.bill_sequence_id
6635 , p_from_end_item_number=>
6636 p_rev_component_rec.from_end_item_unit_number
6637 , p_mesg_Token_tbl => l_mesg_token_tbl
6638 , x_Rev_Component_Rec => x_old_rev_component_rec
6639 , x_Rev_Comp_Unexp_Rec => x_old_rev_comp_unexp_rec
6640 , x_mesg_Token_tbl => l_mesg_token_tbl
6641 , x_Return_Status => l_return_status
6642 );
6643
6644 IF l_return_status = BOM_Globals.G_RECORD_FOUND AND
6645 p_rev_component_rec.transaction_type = BOM_Globals.G_OPR_CREATE
6646 THEN
6647 Error_Handler.Add_Error_Token
6648 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
6649 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6650 , p_message_name => 'BOM_REV_COMP_ALREADY_EXISTS'
6651 , p_token_tbl => l_token_tbl
6652 );
6653 l_return_status := FND_API.G_RET_STS_ERROR;
6654 ELSIF l_return_status = BOM_Globals.G_RECORD_NOT_FOUND AND
6655 p_rev_component_rec.transaction_type IN
6656 (BOM_Globals.G_OPR_UPDATE, BOM_Globals.G_OPR_DELETE)
6657 THEN
6658 Error_Handler.Add_Error_Token
6659 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
6660 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6661 , p_message_name => 'BOM_REV_COMP_DOESNOT_EXIST'
6662 , p_token_tbl => l_token_tbl
6663 );
6664 l_return_status := FND_API.G_RET_STS_ERROR;
6665 ELSIF l_Return_status = FND_API.G_RET_STS_UNEXP_ERROR
6666 THEN
6667 Error_Handler.Add_Error_Token
6668 ( x_Mesg_token_tbl => l_Mesg_Token_Tbl
6669 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6670 , p_message_name => NULL
6671 , p_message_text =>
6672 'Unexpected error while existence verification of ' ||
6673 'Revised component '||
6674 p_rev_component_rec.component_item_name
6675 , p_token_tbl => l_token_tbl
6676 );
6677 ELSE
6678
6679
6680 /* Assign the relevant transaction type for SYNC operations */
6681
6682 IF p_rev_component_rec.transaction_type = 'SYNC' THEN
6683 IF l_return_status = Bom_Globals.G_RECORD_FOUND THEN
6684 x_old_rev_component_rec.transaction_type :=
6685 Bom_Globals.G_OPR_UPDATE;
6686 ELSE
6687 x_old_rev_component_rec.transaction_type :=
6688 Bom_Globals.G_OPR_CREATE;
6689 END IF;
6690 END IF;
6691 l_return_status := FND_API.G_RET_STS_SUCCESS;
6692
6693 END IF;
6694
6695 x_return_status := l_return_status;
6696 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
6697
6698 END Check_Existence;
6699
6700 /******************************************************************
6701 * Prcoedure : Check_Lineage
6702 * Parameters IN : Revised Component exposed column record
6703 * Revised Component unexposed column record
6704 * Parameters OUT: Mesg_Token_Tbl
6705 * Return_Status
6706 * Purpose : Check_Lineage procedure will verify that the entity
6707 * record that the user has passed is for the right
6708 * parent and that the parent exists.
6709 *********************************************************************/
6710 PROCEDURE Check_Lineage
6711 ( p_rev_component_rec IN Bom_Bo_Pub.Rev_Component_Rec_Type
6712 , p_rev_comp_unexp_rec IN Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
6713 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
6714 , x_Return_Status IN OUT NOCOPY VARCHAR2
6715 )
6716 IS
6717 CURSOR c_GetComponent IS
6718 SELECT revised_item_sequence_id
6719 FROM bom_inventory_components
6720 WHERE component_item_id = p_rev_comp_unexp_rec.component_item_id
6721 AND bill_sequence_id = p_rev_comp_unexp_rec.bill_sequence_id
6722 AND operation_seq_num =
6723 p_rev_component_rec.operation_sequence_number
6724 AND effectivity_date = p_rev_component_rec.start_effective_date;
6725
6726 l_Token_Tbl Error_Handler.Token_Tbl_Type;
6727 l_return_status VARCHAR2(1);
6728 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
6729
6730 BEGIN
6731 l_return_status := FND_API.G_RET_STS_SUCCESS;
6732
6733 /*************************************************************
6734 --
6735 -- In case of an update, based on the revised item information
6736 -- Bill Sequence Id and Revised Item Sequence Id is queried from
6737 -- the database. The revised item sequence id can however be
6738 -- different from that in the database and should be checked
6739 -- and given an error.
6740 *************************************************************/
6741
6742 IF p_rev_component_rec.transaction_type IN
6743 (BOM_Globals.G_OPR_UPDATE, BOM_Globals.G_OPR_DELETE,
6744 BOM_Globals.G_OPR_CANCEL)
6745 THEN
6746 FOR Component IN c_GetComponent LOOP
6747 IF NVL(Component.revised_item_sequence_id, 0) <>
6748 NVL(p_rev_comp_unexp_rec.revised_item_sequence_id,0)
6749 THEN
6750 l_Token_Tbl(1).token_name :=
6751 'REVISED_COMPONENT_NAME';
6752 l_Token_Tbl(1).token_value :=
6753 p_rev_component_rec.component_item_name;
6754 l_Token_Tbl(2).token_name :=
6755 'REVISED_ITEM_NAME';
6756 l_Token_Tbl(2).token_value :=
6757 p_rev_component_rec.revised_item_name;
6758 l_token_tbl(3).token_name := 'ECO_NAME';
6759 l_token_tbl(3).token_value :=
6760 p_rev_component_rec.eco_name;
6761
6762 Error_Handler.Add_Error_Token
6763 ( p_Message_Name =>
6764 'BOM_REV_ITEM_MISMATCH'
6765 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6766 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6767 , p_Token_Tbl => l_Token_Tbl
6768 );
6769 l_return_status :=
6770 FND_API.G_RET_STS_ERROR;
6771 END IF;
6772 END LOOP;
6773 END IF;
6774
6775 x_return_status := l_return_status;
6776 x_mesg_token_tbl := l_mesg_token_tbl;
6777
6778 END Check_Lineage;
6779
6780 /*************************************************************
6781 * Procedure : Check_Access
6782 * Parameters IN : Revised Item Unique Key
6783 * Revised Component unique key
6784 * Parameters OUT: Mesg_Token_Tbl
6785 * Return_Status
6786 * Purpose : Procedure will verify that the revised item and the
6787 * revised component is accessible to the user.
6788 ********************************************************************/
6789 PROCEDURE Check_Access
6790 ( p_revised_item_name IN VARCHAR2
6791 , p_revised_item_id IN NUMBER
6792 , p_organization_id IN NUMBER
6793 , p_change_notice IN VARCHAR2
6794 , p_new_item_revision IN VARCHAR2
6795 , p_effectivity_date IN DATE
6796 , p_new_routing_revsion IN VARCHAR2 := NULL -- Added by MK on 11/02/00
6797 , p_from_end_item_number IN VARCHAR2 := NULL -- Added by MK on 11/02/00
6798 , p_component_item_id IN NUMBER
6799 , p_operation_seq_num IN NUMBER
6800 , p_bill_sequence_id IN NUMBER
6801 , p_component_name IN VARCHAR2
6802 , p_Mesg_Token_Tbl IN Error_Handler.Mesg_Token_Tbl_Type :=
6803 Error_Handler.G_MISS_MESG_TOKEN_TBL
6804 , p_entity_processed IN VARCHAR2 := 'RC'
6805 , p_rfd_sbc_name IN VARCHAR2 := NULL
6806 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
6807 , x_Return_Status IN OUT NOCOPY VARCHAR2
6808 )
6809 IS
6810 l_Token_Tbl Error_Handler.Token_Tbl_Type;
6811 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type :=
6812 p_Mesg_Token_Tbl;
6813 l_return_status VARCHAR2(1);
6814 l_Rev_Comp_Item_Type NUMBER;
6815 l_error_name VARCHAR2(30);
6816 l_is_comp_unit_controlled BOOLEAN := FALSE;
6817 l_is_item_unit_controlled BOOLEAN := FALSE;
6818
6819 CURSOR c_CheckCancelled IS
6820 SELECT 1
6821 FROM sys.dual
6822 WHERE NOT EXISTS
6823 ( SELECT component_sequence_id
6824 FROM bom_inventory_components
6825 WHERE component_item_id = p_component_item_id
6826 AND bill_sequence_id = p_bill_sequence_id
6827 AND effectivity_date = p_effectivity_date
6828 AND operation_seq_num = p_operation_seq_num
6829 ) AND
6830 EXISTS
6831 ( SELECT component_sequence_id
6832 FROM eng_revised_components
6833 WHERE component_item_id = p_component_item_id
6834 AND bill_sequence_id = p_bill_sequence_id
6835 AND effectivity_date = p_effectivity_date
6836 AND operation_sequence_num = p_operation_seq_num
6837 );
6838
6839 CURSOR c_CheckDisabled IS
6840 SELECT component_item_id
6841 FROM bom_inventory_components
6842 WHERE component_item_id = p_component_item_id
6843 AND bill_sequence_id = p_bill_sequence_id
6844 AND effectivity_date = p_effectivity_date
6845 AND operation_seq_num = p_operation_seq_num
6846 AND acd_type = 3;
6847
6848 CURSOR c_Check_Unit_Effective IS
6849 SELECT effectivity_control
6850 FROM mtl_system_items
6851 WHERE inventory_item_id = p_component_item_id
6852 AND organization_id = p_organization_id;
6853
6854
6855 BEGIN
6856 l_return_status := FND_API.G_RET_STS_SUCCESS;
6857
6858 /**********************************************************
6859 --
6860 -- Check if the user has access to the revised component's
6861 -- bom_item_type
6862 --
6863 ***********************************************************/
6864 SELECT bom_item_type
6865 INTO l_rev_comp_item_type
6866 FROM mtl_system_items
6867 WHERE inventory_item_id = p_component_item_id
6868 AND organization_id = p_organization_id;
6869
6870 IF l_rev_comp_item_type NOT IN
6871 (NVL(BOM_Globals.Get_MDL_Item_Access,0),
6872 NVL(BOM_Globals.Get_OC_Item_Access,0),
6873 NVL(BOM_Globals.Get_PLN_Item_Access,0),
6874 NVL(BOM_Globals.Get_STD_Item_Access,0)
6875 )
6876 THEN
6877 l_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
6878 l_token_tbl(1).token_value := p_component_name;
6879 l_token_tbl(2).token_name := 'BOM_ITEM_TYPE';
6880 l_token_tbl(2).translate := TRUE;
6881
6882 IF l_rev_comp_Item_Type = 1
6883 THEN
6884 l_Token_Tbl(2).Token_Value := 'BOM_MODEL';
6885 ELSIF l_rev_comp_Item_Type = 2
6886 THEN
6887 l_Token_Tbl(2).Token_Value:='BOM_OPTION_CLASS';
6888 ELSIF l_rev_comp_Item_Type = 3
6889 THEN
6890 l_Token_Tbl(2).Token_Value := 'BOM_PLANNING';
6891 ELSIF l_rev_comp_Item_Type = 4
6892 THEN
6893 l_Token_Tbl(2).Token_Value := 'BOM_STANDARD';
6894 END IF;
6895
6896 Error_Handler.Add_Error_Token
6897 ( p_Message_Name => 'BOM_REV_COMP_ACCESS_DENIED'
6898 , p_Mesg_Token_Tbl => l_mesg_token_tbl
6899 , x_Mesg_Token_Tbl => l_mesg_token_tbl
6900 , p_Token_Tbl => l_token_tbl
6901 );
6902 l_token_tbl.DELETE(2);
6903 l_return_status := FND_API.G_RET_STS_ERROR;
6904 END IF;
6905
6906 IF l_rev_comp_item_type = 5 /* Product Family */
6907 THEN
6908 Error_Handler.Add_Error_Token
6909 ( p_Message_Name => 'BOM_REV_COMP_PRODUCT_FAMILY'
6910 , p_Mesg_Token_Tbl => l_mesg_token_tbl
6911 , x_Mesg_Token_Tbl => l_mesg_token_tbl
6912 , p_Token_Tbl => l_token_tbl
6913 );
6914 l_return_status := FND_API.G_RET_STS_ERROR;
6915 END IF;
6916
6917 /****************************************************************
6918 --
6919 -- If revised item check is successful, then check if the revised
6920 -- component is not cancelled. This check will not prove useful for
6921 -- the revised item itself, since the check existence for a cancelled
6922 -- component would fail. But this procedure can be called by the
6923 -- child records of the revised component and make sure that the
6924 -- parent record is not cancelled.
6925 --
6926 ********************************************************************/
6927
6928 IF BOM_Globals.Is_RComp_Cancl IS NULL THEN
6929 FOR RevComp IN c_CheckCancelled
6930 LOOP
6931 l_token_tbl.DELETE;
6932 l_Token_Tbl(1).Token_Name := 'REVISED_COMPONENT_NAME';
6933 l_Token_Tbl(1).Token_value := p_component_name;
6934 Error_Handler.Add_Error_Token
6935 ( p_Message_Name => 'BOM_REV_COMP_CANCELLED'
6936 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6937 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
6938 , p_Token_Tbl => l_token_tbl
6939 );
6940 l_return_status := FND_API.G_RET_STS_ERROR;
6941 END LOOP;
6942 END IF;
6943
6944 /*********************************************************************
6945 -- Added by AS on 07/06/99
6946 -- Checks that unit effective items are allowed only if the profile
6947 -- value allows them (profile value stored in system_information)
6948 *********************************************************************/
6949
6950 IF NOT BOM_Globals.Get_Unit_Effectivity
6951 THEN
6952 IF BOM_Globals.Get_Unit_Controlled_Component
6953 THEN
6954 l_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
6955 l_token_tbl(1).token_value :=
6956 p_component_name;
6957 l_token_tbl(2).token_name := 'ECO_NAME';
6958 l_token_tbl(2).token_value :=
6959 p_change_notice;
6960 Error_Handler.Add_Error_Token
6961 ( p_Message_Name => 'BOM_REV_COMP_UNIT_CONTROL'
6962 , p_Mesg_Token_Tbl => l_mesg_token_tbl
6963 , x_Mesg_Token_Tbl => l_mesg_token_tbl
6964 , p_Token_Tbl => l_token_tbl
6965 );
6966 l_return_status := FND_API.G_RET_STS_ERROR;
6967 END IF;
6968 ELSE
6969 IF NOT BOM_Globals.Get_Unit_Controlled_Item AND
6970 BOM_Globals.Get_Unit_Controlled_Component
6971 THEN
6972 l_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
6973 l_token_tbl(1).token_value :=
6974 p_component_name;
6975 l_token_tbl(2).token_name := 'ECO_NAME';
6976 l_token_tbl(2).token_value :=
6977 p_change_notice;
6978 Error_Handler.Add_Error_Token
6979 ( p_Message_Name => 'BOM_REV_ITEM_NOT_UNIT_CONTROL'
6980 , p_Mesg_Token_Tbl => l_mesg_token_tbl
6981 , x_Mesg_Token_Tbl => l_mesg_token_tbl
6982 , p_Token_Tbl => l_token_tbl
6983 );
6984 l_return_status := FND_API.G_RET_STS_ERROR;
6985 END IF;
6986 END IF;
6987
6988
6989 /**************************************************************
6990 -- Added by MK on 11/01/2000
6991 -- If bill sequence id is null(Trans Type : CREATE) and this revised
6992 -- item does not have primary bill, verify that parent revised
6993 -- item does not have routing sequence id which has alternate code.
6994 -- (Verify this eco is not only for alternate routing)
6995 --
6996 -- Moved to Engineering space to reslove ECO dependency
6997 -- by MK on 12/03/00
6998 IF p_bill_sequence_id IS NULL
6999 AND Not Check_RevItem_Alternate
7000 ( p_revised_item_id => p_revised_item_id
7001 , p_organization_id => p_organization_id
7002 , p_change_notice => p_change_notice
7003 , p_new_item_revision => p_new_item_revision
7004 , p_new_routing_revsion => p_new_routing_revsion
7005 , p_effective_date => p_effectivity_date
7006 , p_from_end_item_number => p_from_end_item_number
7007 )
7008
7009 THEN
7010
7011 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
7012 THEN
7013 l_token_tbl.delete;
7014 l_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
7015 l_token_tbl(1).token_value := p_revised_item_name ;
7016
7017 Error_Handler.Add_Error_Token
7018 ( p_Message_Name => 'ENG_CANNOT_ADD_ALTERNATE'
7019 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7020 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7021 , p_Token_Tbl => l_Token_Tbl
7022 );
7023
7024 END IF;
7025 l_return_status := FND_API.G_RET_STS_ERROR;
7026 END IF;
7027 **************************************************************/
7028
7029
7030
7031 /**************************************************************
7032 --
7033 -- If the Entity being processed is Reference Designator
7034 -- or subsitute component then check if the parent component is
7035 -- disabled. If it is then Error this record and also all the
7036 -- siblings
7037 --
7038 **************************************************************/
7039 IF p_entity_processed IN ('RFD', 'SBC')
7040 THEN
7041 FOR isdisabled IN c_CheckDisabled LOOP
7042 IF p_entity_processed = 'RFD'
7043 THEN
7044 l_error_name := 'BOM_RFD_COMP_ACD_TYPE_DISABLE';
7045 l_token_tbl(1).token_name :=
7046 'REFERENCE_DESIGNATOR_NAME';
7047 l_token_tbl(1).token_value := p_rfd_sbc_name;
7048 ELSE
7049 l_error_name := 'BOM_SBC_COMP_ACD_TYPE_DISABLE';
7050 l_token_tbl(1).token_name :=
7051 'SUBSTITUTE_ITEM_NAME';
7052 l_token_tbl(1).token_value := p_rfd_sbc_name;
7053 END IF;
7054
7055 l_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
7056 l_token_tbl(2).token_value := p_component_name;
7057
7058 l_return_status := FND_API.G_RET_STS_ERROR;
7059
7060 Error_Handler.Add_Error_Token
7061 ( p_Message_Name => l_error_name
7062 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7063 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7064 , p_Token_Tbl => l_token_tbl
7065 );
7066 END LOOP;
7067 END IF;
7068
7069 x_Return_Status := l_return_status;
7070 x_Mesg_Token_Tbl := l_mesg_token_tbl;
7071
7072 END Check_Access;
7073
7074 /*************************************************************
7075 * Procedure : Check_Direct_item_comps
7076 * Parameters IN : Component Record
7077 * Parameters OUT: Component Record
7078 * Mesg_Token_Tbl
7079 * Return_Status
7080 * Purpose : Procedure will verify that the component record, if
7081 * is a direct item component, is for EAM BOMs only,
7082 * has correct values for direct item specific attributes,
7083 * for normal item components, these attributes should
7084 * be ignored.
7085 ********************************************************************/
7086 PROCEDURE Check_Direct_item_comps
7087 ( p_bom_component_rec IN Bom_Bo_Pub.Bom_Comps_Rec_Type
7088 , p_bom_comp_unexp_rec IN Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type
7089 , x_bom_component_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Rec_Type
7090 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
7091 , x_Return_Status IN OUT NOCOPY VARCHAR2
7092 ) IS
7093 -- l_bom_component_rec Bom_Bo_Pub.Bom_Comps_Rec_Type;
7094 l_Token_Tbl Error_Handler.Token_Tbl_Type;
7095 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
7096 l_return_status VARCHAR2(1);
7097 BEGIN
7098 l_return_status := FND_API.G_RET_STS_SUCCESS;
7099 IF BOM_EAMUTIL.Direct_Item ( item_id => p_bom_comp_unexp_rec.Component_Item_Id,
7100 org_id => p_bom_comp_unexp_rec.Organization_Id ) = 'N' THEN
7101 IF (p_bom_component_rec.Suggested_Vendor_Name IS NOT NULL
7102 OR p_bom_component_rec.Suggested_Vendor_Name <> FND_API.G_MISS_CHAR)
7103 THEN
7104 x_bom_component_rec.Suggested_Vendor_Name := '';
7105 -- x_bom_component_rec.Vendor_Id := '';
7106 Error_Handler.Add_Error_Token
7107 ( p_Message_Name => 'BOM_COMP_SUPPLIER_IGNORED'
7108 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7109 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7110 , p_Token_Tbl => l_token_tbl
7111 );
7112 END IF;
7113 IF (p_bom_component_rec.Unit_Price IS NOT NULL
7114 OR p_bom_component_rec.Unit_Price <> FND_API.G_MISS_NUM)
7115 THEN
7116 x_bom_component_rec.Unit_Price := '';
7117 Error_Handler.Add_Error_Token
7118 ( p_Message_Name => 'BOM_COMP_PRICE_IGNORED'
7119 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7120 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7121 , p_Token_Tbl => l_token_tbl
7122 );
7123 END IF;
7124 /* Commented as part of bug fix 3741040
7125 ELSE
7126 IF BOM_EAMUTIL.Asset_Group_Item ( item_id => p_bom_comp_unexp_rec.Assembly_Item_Id,
7127 org_id => p_bom_comp_unexp_rec.Organization_Id ) = 'N'
7128 AND BOM_EAMUTIL.Asset_Activity_Item ( item_id => p_bom_comp_unexp_rec.Assembly_Item_Id,
7129 org_id => p_bom_comp_unexp_rec.Organization_Id ) = 'N'
7130 THEN
7131 l_return_status := FND_API.G_RET_STS_ERROR;
7132 END IF;
7133 */
7134 END IF;
7135 -- l_bom_component_rec := x_bom_component_rec;
7136 x_Return_Status := l_return_status;
7137 x_Mesg_Token_Tbl := l_mesg_token_tbl;
7138
7139 END Check_Direct_item_comps;
7140
7141 PROCEDURE Validate_All_Attributes
7142 ( p_bo_identifier IN VARCHAR2 := 'BOM',
7143 p_transaction_type IN VARCHAR2,
7144 p_revised_item_id IN NUMBER,
7145 p_organization_id IN NUMBER,
7146 p_organization_code IN VARCHAR2,
7147 p_alternate_bom_code IN VARCHAR2,
7148 p_bill_sequence_id IN NUMBER,
7149 p_bom_implementation_date IN DATE,
7150 p_component_sequence_id IN NUMBER,
7151 p_item_sequence_number IN NUMBER,
7152 p_operation_sequence_number IN NUMBER,
7153 p_new_operation_sequence_num IN NUMBER := NULL,
7154 p_component_item_id IN NUMBER,
7155 p_from_end_item_unit_number IN VARCHAR2 := NULL,
7156 p_to_end_item_unit_number IN VARCHAR2 := NULL,
7157 p_new_from_end_item_unit_num IN VARCHAR2 := NULL,
7158 p_start_effective_date IN DATE,
7159 p_new_effectivity_date IN DATE := NULL,
7160 p_disable_date IN DATE := NULL,
7161 p_basis_type IN NUMBER := NULL,
7162 p_quantity_per_assembly IN NUMBER := NULL,
7163 p_projected_yield IN NUMBER := NULL,
7164 p_planning_percent IN NUMBER := NULL,
7165 p_quantity_related IN NUMBER := NULL,
7166 p_include_in_cost_rollup IN NUMBER := NULL,
7167 p_check_atp IN NUMBER := NULL,
7168 p_acd_type IN NUMBER := NULL,
7169 p_auto_request_material IN VARCHAR2 := NULL,
7170 p_wip_supply_type IN NUMBER := NULL,
7171 p_Supply_SubInventory IN VARCHAR2 := NULL,
7172 p_supply_locator_id IN NUMBER := NULL,
7173 p_location_name IN VARCHAR2 := NULL,
7174 p_SO_Basis IN NUMBER := NULL,
7175 p_Optional IN NUMBER := NULL,
7176 p_mutually_exclusive IN NUMBER := NULL,
7177 p_shipping_allowed IN NUMBER := NULL,
7178 p_required_to_ship IN NUMBER := NULL,
7179 p_required_for_revenue IN NUMBER := NULL,
7180 p_include_on_ship_docs IN NUMBER := NULL,
7181 p_enforce_int_reqs_code IN NUMBER := NULL,
7182 p_revised_item_name IN VARCHAR2 := NULL,
7183 p_component_item_name IN VARCHAR2 := NULL,
7184 p_minimum_allowed_quantity IN NUMBER := NULL,
7185 p_maximum_allowed_quantity IN NUMBER := NULL,
7186 p_Delete_Group_Name IN VARCHAR2 := NULL,
7187 p_eco_name IN VARCHAR2 := NULL,
7188 p_comments IN VARCHAR2 := NULL,
7189 p_pick_components IN NUMBER := NULL,
7190 p_revised_item_sequence_id IN NUMBER := NULL,
7191 p_old_operation_sequence_num IN NUMBER := NULL,
7192 p_old_component_sequence_id IN NUMBER := NULL,
7193 p_old_effectivity_date IN DATE := NULL,
7194 p_old_rec_item_sequence_number IN NUMBER := NULL,
7195 p_Old_Rec_shipping_Allowed IN NUMBER := NULL,
7196 p_Old_rec_supply_locator_id IN NUMBER := NULL,
7197 p_Old_rec_supply_subinventory IN VARCHAR2 := NULL,
7198 p_old_rec_check_atp IN NUMBER := NULL,
7199 p_old_rec_acd_type IN NUMBER := NULL,
7200 p_old_rec_to_end_item_unit_num IN VARCHAR2 := NULL,
7201 p_original_system_reference IN VARCHAR2 := NULL,
7202 p_rowid IN VARCHAR2 := NULL,
7203 x_return_status IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
7204 x_error_message IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2) IS
7205
7206 l_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
7207 l_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
7208 l_old_rev_component_rec Bom_Bo_Pub.Rev_Component_Rec_Type;
7209 l_old_rev_comp_unexp_rec Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
7210 l_return_status VARCHAR2(1);
7211 l_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_Type;
7212
7213 l_message_list Error_Handler.Error_Tbl_Type;
7214 l_debug_error_status VARCHAR2(1);
7215 l_debug_error_mesg VARCHAR2(2000);
7216 l_debug_filename VARCHAR2(20) := 'compjbo'||to_char(sysdate,'MISS');
7217 l_Assembly_Item_Name VARCHAR2(2000);
7218 l_Component_Item_Name VARCHAR2(2000);
7219
7220
7221 EXC_ERR_PVT_API_MAIN EXCEPTION;
7222
7223 BEGIN
7224
7225 /* Construct the exposed and unexposed records for
7226 component and call check_attributes. check_entity */
7227
7228 Error_Handler.Initialize;
7229 Error_Handler.Set_Debug ('Y');
7230 Bom_Globals.Set_Debug ('Y');
7231
7232
7233 Error_Handler.Open_Debug_Session
7234 ( p_debug_filename => l_debug_filename
7235 , p_output_dir =>'/appslog/bis_top/utl/plm115dv/out'
7236 , x_return_status => l_debug_error_status
7237 , x_error_mesg => l_debug_error_mesg
7238 );
7239
7240 if x_return_status <> 'S'
7241 then
7242 x_return_status := 'E';
7243 x_error_message := l_debug_error_mesg;
7244 return;
7245 end if;
7246
7247 --Load environment information into the SYSTEM_INFORMATION record
7248 -- (USER_ID, LOGIN_ID, PROG_APPID, PROG_ID)
7249
7250 Bom_Globals.Init_System_Info_Rec
7251 ( x_mesg_token_tbl => l_mesg_token_tbl
7252 , x_return_status => l_return_status
7253 );
7254
7255 -- Initialize System_Information Unit_Effectivity flag
7256
7257 IF (FND_PROFILE.DEFINED('PJM:PJM_UNITEFF_NO_EFFECT') AND
7258 FND_PROFILE.VALUE('PJM:PJM_UNITEFF_NO_EFFECT') = 'Y')
7259 OR (BOM_EAMUTIL.Enabled = 'Y')
7260 THEN
7261 Bom_Globals.Set_Unit_Effectivity (TRUE);
7262 ELSE
7263 Bom_Globals.Set_Unit_Effectivity (FALSE);
7264 END IF;
7265
7266 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
7267 THEN
7268 RAISE EXC_ERR_PVT_API_MAIN;
7269 END IF;
7270
7271 Error_Handler.Write_Debug('After open debug ');
7272
7273 Error_Handler.Set_BO_Identifier(p_bo_identifier);
7274 Bom_Globals.Set_BO_Identifier(p_bo_identifier);
7275
7276 /* Set the system information record values for assembly_item_id
7277 and org_id. These values will be used for validating serial effective
7278 assemblies */
7279
7280 Bom_Globals.Set_Org_Id (p_organization_id);
7281 Bom_Globals.Set_Assembly_Item_Id (p_revised_item_id);
7282
7283 Error_Handler.Write_Debug('after set org ');
7284
7285 x_return_status := 'S';
7286
7287 /*Added code to get the parent name
7288 as the parent name is passed null
7289 BOM_VALIDATE_BOM_COMPONENT.Validate_All_Attributes from
7290 java call.*/
7291 IF (p_revised_item_name IS NULL)
7292 THEN
7293 l_Assembly_Item_Name := Bom_Globals.Get_Item_Name(p_revised_item_id,
7294 p_organization_id);
7295 ELSE
7296 l_Assembly_Item_Name := p_revised_item_name;
7297 END IF;
7298
7299 IF (p_component_item_name IS NULL)
7300 THEN
7301 l_Component_Item_Name := Bom_Globals.Get_Item_Name(p_component_item_id,
7302 p_organization_id);
7303 ELSE
7304 l_Component_Item_Name := p_component_item_name;
7305 END IF;
7306
7307
7308 l_rev_component_rec.eco_name := p_eco_name; -- ECO Specific
7309
7310 l_rev_component_rec.organization_code :=
7311 p_organization_code;
7312 l_rev_component_rec.revised_item_name :=
7313 l_Assembly_Item_Name;
7314 l_rev_component_rec.new_revised_item_revision := NULL;
7315 Error_Handler.Write_Debug('0 ');
7316 Error_Handler.Write_Debug('p_start_Effective_date '||to_char(p_start_Effective_date,'YYYY-MM-DD HH24:MI:SS'));
7317 l_rev_component_rec.start_effective_date := p_start_Effective_date;
7318 -- l_rev_component_rec.start_effective_date :=
7319 -- to_date(p_start_Effective_date,'YYYY-MM-DD HH24:MI:SS');
7320
7321 l_rev_component_rec.new_effectivity_date :=
7322 p_new_effectivity_date;
7323
7324 l_rev_component_rec.disable_date :=
7325 p_disable_date;
7326
7327 Error_Handler.Write_Debug('1 ');
7328 l_rev_component_rec.operation_sequence_number :=
7329 p_operation_sequence_number;
7330 l_rev_component_rec.component_item_name :=
7331 l_Component_Item_Name;
7332 l_rev_component_rec.alternate_bom_code :=
7333 p_alternate_bom_code;
7334
7335 l_rev_component_rec.acd_type := p_acd_type; -- ECO Specific
7336
7337 l_rev_component_rec.old_effectivity_date :=
7338 p_old_effectivity_date; -- ECO Specific
7339
7340 Error_Handler.Write_Debug('2 ');
7341 l_rev_component_rec.old_operation_sequence_number := p_old_operation_sequence_num; -- ECO Specific
7342
7343 l_rev_component_rec.new_operation_sequence_number :=
7344 p_new_operation_sequence_num;
7345 l_rev_component_rec.item_sequence_number :=
7346 p_item_sequence_number;
7347 l_rev_component_rec.basis_type:=
7348 p_basis_type;
7349 l_rev_component_rec.quantity_per_assembly :=
7350 p_quantity_per_assembly;
7351 l_rev_component_rec.Planning_Percent :=
7352 p_Planning_Percent;
7353 l_rev_component_rec.projected_yield :=
7354 p_projected_yield;
7355
7356 l_rev_component_rec.include_in_cost_rollup :=
7357 p_include_in_cost_rollup;
7358 l_rev_component_rec.wip_supply_type :=
7359 p_wip_supply_type;
7360 l_rev_component_rec.so_basis :=
7361 p_so_basis;
7362 l_rev_component_rec.optional :=
7363 p_optional;
7364 l_rev_component_rec.mutually_exclusive :=
7365 p_mutually_exclusive;
7366 l_rev_component_rec.check_atp :=
7367 p_check_atp;
7368 l_rev_component_Rec.shipping_allowed :=
7369 p_shipping_allowed;
7370 l_rev_component_rec.required_to_ship :=
7371 p_required_to_ship;
7372 l_rev_component_rec.required_for_revenue :=
7373 p_required_for_revenue;
7374 l_rev_component_rec.include_on_ship_docs :=
7375 p_include_on_ship_docs;
7376 l_rev_component_rec.quantity_related :=
7377 p_quantity_related;
7378 l_rev_component_rec.supply_subinventory :=
7379 p_supply_subinventory;
7380 l_rev_component_rec.location_name :=
7381 p_location_name;
7382 l_rev_component_rec.minimum_allowed_quantity :=
7383 p_minimum_allowed_quantity;
7384 l_rev_component_rec.maximum_allowed_quantity :=
7385 p_maximum_allowed_quantity;
7386 l_rev_component_rec.comments :=
7387 p_comments;
7388 /*
7389 l_rev_component_rec.attribute_category :=
7390 p_attribute_category;
7391 l_rev_component_rec.attribute1 :=
7392 p_attribute1;
7393 l_rev_component_rec.attribute2 :=
7394 p_attribute2;
7395 l_rev_component_rec.attribute3 :=
7396 p_attribute3;
7397 l_rev_component_rec.attribute4 :=
7398 p_attribute4;
7399 l_rev_component_rec.attribute5 :=
7400 p_attribute5;
7401 l_rev_component_rec.attribute6 :=
7402 p_attribute6;
7403 l_rev_component_rec.attribute7 :=
7404 p_attribute7;
7405 l_rev_component_rec.attribute8 :=
7406 p_attribute8;
7407 l_rev_component_rec.attribute9 :=
7408 p_attribute9;
7409 l_rev_component_rec.attribute10 :=
7410 p_attribute10;
7411 l_rev_component_rec.attribute11 :=
7412 p_attribute11;
7413 l_rev_component_rec.attribute12 :=
7414 p_attribute12;
7415 l_rev_component_rec.attribute13 :=
7416 p_attribute13;
7417 l_rev_component_rec.attribute14 :=
7418 p_attribute14;
7419 l_rev_component_rec.attribute15 :=
7420 p_attribute15;
7421 */
7422 l_rev_component_rec.original_system_reference :=
7423 p_original_system_reference;
7424 l_rev_component_rec.transaction_type :=
7425 p_transaction_type;
7426 Error_Handler.Write_Debug('3 ');
7427 l_rev_component_rec.From_End_Item_Unit_Number :=
7428 p_From_End_Item_Unit_Number;
7429 l_rev_component_rec.To_End_Item_Unit_Number :=
7430 p_To_End_Item_Unit_Number;
7431 l_rev_component_rec.New_From_End_Item_Unit_Number :=
7432 p_New_From_End_Item_Unit_Num;
7433 l_rev_component_rec.New_Routing_Revision := NULL ;
7434 l_rev_component_rec.auto_request_material :=
7435 p_auto_request_material;
7436
7437 l_rev_comp_unexp_rec.organization_id :=
7438 p_organization_id;
7439 l_rev_comp_unexp_rec.component_item_id :=
7440 p_component_item_id;
7441 l_rev_comp_unexp_rec.component_sequence_id :=
7442 p_component_sequence_id;
7443 l_rev_comp_unexp_rec.old_component_sequence_id :=
7444 p_old_component_sequence_id;
7445 l_rev_comp_unexp_rec.revised_item_id :=
7446 p_revised_item_id;
7447 l_rev_comp_unexp_rec.bill_sequence_id :=
7448 p_bill_sequence_id;
7449
7450 l_rev_comp_unexp_rec.pick_components :=
7451 p_pick_components;
7452 l_rev_comp_unexp_rec.supply_locator_id :=
7453 p_supply_locator_id;
7454
7455 Error_Handler.Write_Debug('Rowid is '||p_rowid);
7456 l_rev_comp_unexp_rec.Rowid :=
7457 p_rowid ;
7458 /*
7459 l_rev_comp_unexp_rec.bom_item_type :=
7460 p_bom_comp_unexp_rec.bom_item_type;
7461 l_rev_comp_unexp_rec.Delete_Group_Name :=
7462 p_Delete_Group_Name ;
7463 l_rev_comp_unexp_rec.DG_Description :=
7464 p_DG_Description ;
7465 l_rev_comp_unexp_rec.DG_Sequence_Id :=
7466 p_bom_comp_unexp_rec.DG_Sequence_Id ;
7467 l_rev_component_rec.Enforce_Int_Requirements :=
7468 p_Enforce_Int_Requirements;
7469 l_rev_component_rec.Row_Identifier := p_Row_Identifier;
7470 l_rev_component_rec.return_status :=
7471 p_return_status;
7472 */
7473
7474 l_rev_comp_unexp_rec.revised_item_sequence_id := p_revised_item_sequence_id; -- ECO Specific
7475
7476 l_rev_comp_unexp_rec.Enforce_Int_Requirements_Code :=
7477 p_Enforce_Int_Reqs_Code;
7478 Error_Handler.Write_Debug('4 ');
7479
7480 l_rev_comp_unexp_rec.bom_implementation_date :=
7481 p_bom_implementation_date;
7482
7483 /* Assign the values for teh OLD record */
7484
7485 l_old_rev_component_rec.item_sequence_number :=
7486 p_old_rec_item_sequence_number;
7487 l_old_rev_component_rec.shipping_allowed :=
7488 p_Old_Rec_shipping_Allowed;
7489 l_old_rev_comp_unexp_rec.supply_locator_id :=
7490 p_Old_rec_supply_locator_id;
7491 l_old_rev_component_rec.supply_subinventory :=
7492 p_Old_rec_supply_subinventory;
7493 l_old_rev_component_rec.check_atp :=
7494 p_old_rec_check_atp;
7495 l_old_rev_component_rec.acd_type :=
7496 p_old_rec_acd_type;
7497 l_old_rev_component_rec.to_end_item_unit_number :=
7498 p_old_rec_to_end_item_unit_num;
7499
7500 Error_Handler.Write_Debug('after assignement ');
7501 /* validate parent access */
7502
7503 Bom_Validate_Bom_Header.Check_Access
7504 ( p_assembly_item_id => p_revised_item_id
7505 , p_organization_id => p_organization_id
7506 , p_alternate_bom_code => p_alternate_bom_code
7507 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7508 , x_Return_Status => x_return_status
7509 );
7510
7511 Error_Handler.Write_Debug('after check access ');
7512 IF x_return_status <> 'S'
7513 THEN
7514 Error_Handler.Translate_And_Insert_Messages
7515 ( p_mesg_token_tbl => l_mesg_token_tbl
7516 , p_application_id => 'BOM'
7517 );
7518
7519 Error_Handler.Get_Message_List( x_message_list => l_message_list);
7520 x_error_message := l_message_list(1).Message_Text;
7521 Error_Handler.Write_To_DebugFile;
7522 Error_Handler.Close_Debug_Session;
7523
7524 Return;
7525 END IF;
7526
7527 /* validate component access */
7528
7529 Bom_Validate_Bom_Component.Check_Access
7530 ( p_organization_id => p_organization_id
7531 , p_component_item_id => p_component_item_id
7532 , p_component_name => p_component_item_name
7533 , p_Mesg_Token_Tbl => l_mesg_token_tbl
7534 , x_Mesg_Token_Tbl => l_mesg_token_tbl
7535 , x_Return_Status => x_return_status
7536 );
7537
7538 Error_Handler.Write_Debug('after component access ');
7539 IF x_return_status <> 'S'
7540 THEN
7541 Error_Handler.Translate_And_Insert_Messages
7542 ( p_mesg_token_tbl => l_mesg_token_tbl
7543 , p_application_id => 'BOM'
7544 );
7545
7546 Error_Handler.Get_Message_List( x_message_list => l_message_list);
7547 x_error_message := l_message_list(1).Message_Text;
7548 Error_Handler.Write_To_DebugFile;
7549 Error_Handler.Close_Debug_Session;
7550
7551 Return;
7552 END IF;
7553
7554 /* Set the value for unit controlled item in system information record*/
7555
7556 Bom_Globals.Set_Unit_Controlled_Item (
7557 p_inventory_item_id => p_revised_item_id,
7558 p_organization_id => p_organization_id);
7559
7560 /* Perform the attribute validation */
7561
7562 Bom_Validate_Bom_Component.Check_Attributes
7563 ( x_return_status => x_return_status
7564 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7565 , p_rev_component_rec => l_rev_component_rec
7566 , p_rev_comp_unexp_rec => l_rev_comp_unexp_rec
7567 );
7568
7569 IF x_return_status <> 'S'
7570 THEN
7571 Error_Handler.Translate_And_Insert_Messages
7572 ( p_mesg_token_tbl => l_mesg_token_tbl
7573 , p_application_id => 'BOM'
7574 );
7575
7576 Error_Handler.Get_Message_List( x_message_list => l_message_list);
7577 x_error_message := l_message_list(1).Message_Text;
7578 Error_Handler.Write_To_DebugFile;
7579 Error_Handler.Close_Debug_Session;
7580
7581 Return;
7582 END IF;
7583
7584 /* Mark the Validate plm flag in BOM Globals to 'Y' to avoid the
7585 following validations
7586 1. Overlap
7587 2. Check Operation sequence number uniqueness
7588 3. Checking ACD TYPE when there is no primary bill
7589 */
7590 Bom_Globals.Set_Validate_For_Plm('Y');
7591
7592 /* Perform the entity validation */
7593
7594 Bom_Validate_Bom_Component.Check_Entity
7595 ( p_rev_component_rec => l_rev_component_rec
7596 , p_rev_comp_unexp_rec => l_rev_comp_unexp_rec
7597 , p_old_rev_component_rec => l_old_rev_component_rec
7598 , p_old_rev_comp_unexp_rec => l_old_rev_comp_unexp_rec
7599 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
7600 , x_return_status => x_Return_Status
7601 );
7602
7603 Error_Handler.Write_Debug('after check entity ');
7604 IF x_return_status <> 'S'
7605 THEN
7606 Error_Handler.Translate_And_Insert_Messages
7607 ( p_mesg_token_tbl => l_mesg_token_tbl
7608 , p_application_id => 'BOM'
7609 );
7610
7611 Error_Handler.Get_Message_List( x_message_list => l_message_list);
7612 x_error_message := l_message_list(1).Message_Text;
7613
7614 Error_Handler.Write_To_DebugFile;
7615 Error_Handler.Close_Debug_Session;
7616
7617 END IF;
7618 EXCEPTION WHEN OTHERS THEN
7619 x_error_message := SQLCODE||'/'||SQLERRM;
7620 Error_Handler.Write_To_DebugFile;
7621 Error_Handler.Close_Debug_Session;
7622
7623 END;
7624
7625
7626
7627
7628
7629 END BOM_Validate_Bom_Component;