DBA Data[Home] [Help]

PACKAGE BODY: APPS.MSC_CONFIG_FF

Source


1 PACKAGE BODY MSC_CONFIG_FF AS
2 /* $Header: MSCCONFB.pls 115.31 2003/10/29 19:59:02 jarora ship $ */
3 
4 
5    PROCEDURE LOG_MESSAGE( pBUFF                     IN  VARCHAR2)
6    IS
7    BEGIN
8      IF fnd_global.conc_request_id > 0 THEN   -- concurrent program
9          FND_FILE.PUT_LINE( FND_FILE.LOG, pBUFF);
10      ELSE
11        --DBMS_OUTPUT.PUT_LINE( pBUFF);
12        null;
13      END IF;
14    END LOG_MESSAGE;
15 
16  PROCEDURE Configure_forecast_flex(
17  	ERRBUF      	OUT NOCOPY VARCHAR2,
18  	RETCODE     	OUT NOCOPY NUMBER,
19  	item_attr1		IN  NUMBER,
20  	org_attr1		IN  NUMBER,
21  	cust_attr1		IN  NUMBER)
22 
23  as
24 
25  	req_id 		NUMBER;
26  	conc_failure 	EXCEPTION;
27  --	abp_failure  	EXCEPTION;
28 
29  	msgbuf		VARCHAR2(2000);
30 
31  Begin
32 
33      	fnd_flex_dsc_api.debug_on;
34      	fnd_flex_dsc_api.set_session_mode('seed_data');
35 
36  IF item_attr1 IS NOT NULL THEN
37 
38      fnd_flex_dsc_api.enable_context('INV',
39                           'MTL_SYSTEM_ITEMS',
40                           'Global Data Elements',
41                           TRUE);
42 
43      IF fnd_flex_dsc_api.segment_exists(
44  	p_appl_short_name=>'INV',
45  	p_flexfield_name=>'MTL_SYSTEM_ITEMS',
46  	p_context_code=>'Global Data Elements',
47  	p_segment_name=>'Service Level') = TRUE THEN
48 
49          FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
50          FND_MESSAGE.set_token('SEGMENT','Service Level');
51          FND_MESSAGE.set_token('TABLE','MTL_SYSTEM_ITEMS');
52          msgbuf := FND_MESSAGE.get;
53          LOG_MESSAGE(msgbuf);
54 
55      ELSE
56 
57          fnd_flex_dsc_api.create_segment(
58          appl_short_name => 'INV',
59          flexfield_name => 'MTL_SYSTEM_ITEMS',
60          context_name => 'Global Data Elements',
61          name => 'Service Level',
62          column => 'ATTRIBUTE'|| to_char(item_attr1),
63          description => 'Service Level',
64          sequence_number => 150,
65          enabled => 'Y',
66          displayed => 'Y',
67          value_set => 'FND_NUMBER',
68          default_type => NULL,
69          default_value => NULL,
70          required => 'N',
71          security_enabled => 'N',
72          display_size => 25,
73          description_size => 50,
74          concatenated_description_size => 50,
75          list_of_values_prompt => 'Service Level',
76          window_prompt => 'Service Level',
77          range => NULL,
78          srw_parameter => NULL);
79 
80      END IF;
81 
82  END IF;  -- item_attr1 is not null
83 
84 
85  IF org_attr1 IS NOT NULL THEN
86 
87          fnd_flex_dsc_api.enable_context('INV',
88                           'MTL_PARAMETERS',
89                           'Global Data Elements',
90                           TRUE);
91 
92      IF fnd_flex_dsc_api.segment_exists(
93  	p_appl_short_name=>'INV',
94  	p_flexfield_name=>'MTL_PARAMETERS',
95  	p_context_code=>'Global Data Elements',
96  	p_segment_name=>'Service Level') = TRUE THEN
97 
98          FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
99          FND_MESSAGE.set_token('SEGMENT','Service Level');
100          FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
101          msgbuf := FND_MESSAGE.get;
102          LOG_MESSAGE(msgbuf);
103 
104  	ELSE
105 
106          fnd_flex_dsc_api.create_segment(
107          appl_short_name => 'INV',
108          flexfield_name => 'MTL_PARAMETERS',
109          context_name => 'Global Data Elements',
110          name => 'Service Level',
111          column => 'ATTRIBUTE'|| to_char(org_attr1),
112          description => 'Service Level',
113          sequence_number => 150,
114          enabled => 'Y',
115          displayed => 'Y',
116          value_set => 'FND_NUMBER',
117          default_type => NULL,
118          default_value => NULL,
119          required => 'N',
120          security_enabled => 'N',
121          display_size => 25,
122          description_size => 50,
123          concatenated_description_size => 50,
124          list_of_values_prompt => 'Service Level',
125          window_prompt => 'Service Level',
126          range => NULL,
127          srw_parameter => NULL);
128 
129    END IF;
130 
131 
132  END IF; -- org_attr1 is not null
133 
134  IF cust_attr1 IS NOT NULL THEN
135 
136          fnd_flex_dsc_api.enable_context('AR',
137                           'RA_CUSTOMERS_HZ',
138                           'Global Data Elements',
139                           TRUE);
140 
141      IF fnd_flex_dsc_api.segment_exists(
142  	p_appl_short_name=>'AR',
143  	p_flexfield_name=>'RA_CUSTOMERS_HZ',
144  	p_context_code=>'Global Data Elements',
145  	p_segment_name=>'Service Level') = TRUE THEN
146 
147          FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
148          FND_MESSAGE.set_token('SEGMENT','Service Level');
149          FND_MESSAGE.set_token('TABLE','HZ_CUST_ACCOUNTS');
150          msgbuf := FND_MESSAGE.get;
151          LOG_MESSAGE(msgbuf);
152 
153  	ELSE
154 
155          fnd_flex_dsc_api.create_segment(
156          appl_short_name => 'AR',
157          flexfield_name => 'RA_CUSTOMERS_HZ',
158          context_name => 'Global Data Elements',
159          name => 'Service Level',
160          column => 'ATTRIBUTE'|| to_char(cust_attr1),
161          description => 'Service Level',
162          sequence_number => 150,
163          enabled => 'Y',
164          displayed => 'Y',
165          value_set => 'FND_NUMBER',
166          default_type => NULL,
167          default_value => NULL,
168          required => 'N',
169          security_enabled => 'N',
170          display_size => 25,
171          description_size => 50,
172          concatenated_description_size => 50,
173          list_of_values_prompt => 'Service Level',
174          window_prompt => 'Service Level',
175          range => NULL,
176          srw_parameter => NULL);
177 
178    END IF;
179 
180  END IF;  -- cust_attr1 is not null
181 
182  commit;
183 
184      req_id := fnd_request.submit_request(
185                  'FND', 'FDFVGN', '', '', FALSE,
186                  '3', 401,
187                  'MTL_SYSTEM_ITEMS');
188      IF (req_id = 0) THEN
189        raise conc_failure;
190      END IF;
191 
192      req_id := fnd_request.submit_request( 'FND', 'FDFVGN', '', '', FALSE,
193                  '3', 401,
194                  'MTL_PARAMETERS');
195      IF (req_id = 0) THEN
196        raise conc_failure;
197      END IF;
198 
199      req_id := fnd_request.submit_request(
200                  'FND', 'FDFVGN', '', '', FALSE,
201                  '3', 222,
202                  'RA_CUSTOMERS_HZ');
203      IF (req_id = 0) THEN
204        raise conc_failure;
205      END IF;
206 
207      COMMIT;
208      errbuf := 'Created flexfields - submitted requests to recompile flexfields';
209      retcode := 0; -- success
210  EXCEPTION
211     WHEN conc_failure THEN
212       errbuf := 'Error ' ||
213                    substr(fnd_message.get,1,240);
214       retcode := 2;
215     WHEN OTHERS THEN
216     rollback;
217      if (fnd_flex_dsc_api.message is null) then
218        errbuf := 'Sql Error:' || to_char(sqlcode);
219      else
220        errbuf := fnd_flex_dsc_api.message;
221      end if;
222      retcode := 2; -- failure
223 
224  END Configure_forecast_flex;
225 
226 
227 PROCEDURE Configure(
228 	ERRBUF      	OUT NOCOPY VARCHAR2,
229 	RETCODE     	OUT NOCOPY NUMBER,
230 	item_attr1		IN  NUMBER,
231 	item_attr2		IN  NUMBER,
232 	org_attr1		IN  NUMBER,
233 	org_attr2		IN  NUMBER,
234 	org_attr3		IN  NUMBER,
235 	org_attr4		IN  NUMBER,
236 	dept_attr1		IN  NUMBER,
237 	dept_attr2		IN  NUMBER,
238 	supp_attr1		IN  NUMBER,
239 	subst_attr1		IN  NUMBER,
240 	trans_attr1		IN  NUMBER,
241 	bom_attr1		IN  NUMBER,
242 	forecast_attr1	        IN  NUMBER,
243 	line_attr1		IN  NUMBER,
244         schedule_attr1          IN  NUMBER
245 )
246 AS
247 	req_id 		NUMBER;
248 	conc_failure 	EXCEPTION;
249 --	abp_failure  	EXCEPTION;
250 
251 	msgbuf		VARCHAR2(2000);
252 
253 ------------------------------
254 
255 BEGIN
256 
257     fnd_flex_dsc_api.debug_on;
258     fnd_flex_dsc_api.set_session_mode('seed_data');
259 
260  IF item_attr1 is NOT NULL THEN
261 
262     fnd_flex_dsc_api.enable_context('INV',
263                          'MTL_SYSTEM_ITEMS',
264                          'Global Data Elements',
265                          TRUE);
266     IF fnd_flex_dsc_api.is_column_used(
267 		p_application_id => '401',
268 		p_table_name => 'MTL_SYSTEM_ITEMS_B',
269 		p_column_name => 'ATTRIBUTE'||to_char(item_attr1),
270 		x_message => msgbuf) = TRUE THEN
271 
272 
273         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
274         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(item_attr1));
275         FND_MESSAGE.set_token('TABLE','MTL_SYSTEM_ITEMS');
276         msgbuf := FND_MESSAGE.get;
277         LOG_MESSAGE(msgbuf);
278 
279     ELSIF fnd_flex_dsc_api.segment_exists(
280 	p_appl_short_name=>'INV',
281 	p_flexfield_name=>'MTL_SYSTEM_ITEMS',
282 	p_context_code=>'Global Data Elements',
283 	p_segment_name=>'Late Demands Penalty') = TRUE THEN
284 
285         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
286         FND_MESSAGE.set_token('SEGMENT','Late Demands Penalty');
287         FND_MESSAGE.set_token('TABLE','MTL_SYSTEM_ITEMS');
288         msgbuf := FND_MESSAGE.get;
289         LOG_MESSAGE(msgbuf);
290 
291     ELSE
292 
293         fnd_flex_dsc_api.create_segment(
294         appl_short_name => 'INV',
295         flexfield_name => 'MTL_SYSTEM_ITEMS',
296         context_name => 'Global Data Elements',
297         name => 'Late Demands Penalty',
298         column => 'ATTRIBUTE'|| to_char(item_attr1),
299         description => 'Penalty Cost Factor for Late Demands',
300         sequence_number => 10,
301         enabled => 'Y',
302         displayed => 'Y',
303         value_set => 'FND_NUMBER',
304         default_type => NULL,
305         default_value => NULL,
306         required => 'N',
307         security_enabled => 'N',
308         display_size => 25,
309         description_size => 50,
310         concatenated_description_size => 50,
311         list_of_values_prompt => 'Late Demands Penalty',
312         window_prompt => 'Late Demands Penalty',
313         range => NULL,
314         srw_parameter => NULL);
315 
316     update fnd_profile_option_values
317     set profile_option_value = to_char(item_attr1)
318     where application_id = 723
319     and level_id = 10001
320     and profile_option_id = (select profile_option_id
321 		from fnd_profile_options
322 		where application_id = 723
323 		and  profile_option_name = 'MSO_ITEM_DMD_PENALTY');
324 
325    END IF;
326 
327  END IF; --item_attr1 is not null
328 
329 
330  IF item_attr2 IS NOT NULL THEN
331 
332     IF fnd_flex_dsc_api.is_column_used(
333 		p_application_id => '401',
334 		p_table_name => 'MTL_SYSTEM_ITEMS_B',
335 		p_column_name => 'ATTRIBUTE'||to_char(item_attr2),
336 		x_message => msgbuf) = TRUE THEN
337 
338         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
339         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(item_attr2));
340         FND_MESSAGE.set_token('TABLE','MTL_SYSTEM_ITEMS');
341         msgbuf := FND_MESSAGE.get;
342         LOG_MESSAGE(msgbuf);
343 
344     ELSIF fnd_flex_dsc_api.segment_exists(
345 	p_appl_short_name=>'INV',
346 	p_flexfield_name=>'MTL_SYSTEM_ITEMS',
347 	p_context_code=>'Global Data Elements',
348 	p_segment_name=>'Material Over-Capacity Penalty') = TRUE THEN
349 
350         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
351         FND_MESSAGE.set_token('SEGMENT','Material Over-Capacity Penalty');
352         FND_MESSAGE.set_token('TABLE','MTL_SYSTEM_ITEMS');
353         msgbuf := FND_MESSAGE.get;
354         LOG_MESSAGE(msgbuf);
355 
356     ELSE
357 
358         fnd_flex_dsc_api.create_segment(
359         appl_short_name => 'INV',
360         flexfield_name => 'MTL_SYSTEM_ITEMS',
361         context_name => 'Global Data Elements',
362         name => 'Material Over-Capacity Penalty',
363         column => 'ATTRIBUTE'|| to_char(item_attr2),
364         description => 'Penalty Cost Factor for Exceeding Material Capacity',
365         sequence_number => 20,
366         enabled => 'Y',
367         displayed => 'Y',
368         value_set => 'FND_NUMBER',
369         default_type => NULL,
370         default_value => NULL,
371         required => 'N',
372         security_enabled => 'N',
373         display_size => 25,
374         description_size => 50,
375         concatenated_description_size => 50,
376         list_of_values_prompt => 'Material Over-Capacity Penalty',
377         window_prompt => 'Material Over-Capacity Penalty',
378         range => NULL,
379         srw_parameter => NULL);
380 
381     update fnd_profile_option_values
382     set profile_option_value = to_char(item_attr2)
383     where application_id = 723
384     and level_id = 10001
385     and profile_option_id = (select profile_option_id
386 		from fnd_profile_options
387 		where application_id = 723
388 		and  profile_option_name = 'MSO_ITEM_CAP_PENALTY');
389 
390   END IF;
391 
392  END IF; -- item_attr2 is not null
393 
394 
395  IF org_attr1 IS NOT NULL THEN
396 
397         fnd_flex_dsc_api.enable_context('INV',
398                          'MTL_PARAMETERS',
399                          'Global Data Elements',
400                          TRUE);
401 
402     IF fnd_flex_dsc_api.is_column_used(
403 		p_application_id => '401',
404 		p_table_name => 'MTL_PARAMETERS',
405 		p_column_name => 'ATTRIBUTE'||to_char(org_attr1),
406 		x_message => msgbuf) = TRUE THEN
407 
408         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
409         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(org_attr1));
410         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
411         msgbuf := FND_MESSAGE.get;
412         LOG_MESSAGE(msgbuf);
413 
414     ELSIF fnd_flex_dsc_api.segment_exists(
415 	p_appl_short_name=>'INV',
416 	p_flexfield_name=>'MTL_PARAMETERS',
417 	p_context_code=>'Global Data Elements',
418 	p_segment_name=>'Late Demands Penalty') = TRUE THEN
419 
420         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
424         LOG_MESSAGE(msgbuf);
421         FND_MESSAGE.set_token('SEGMENT','Late Demands Penalty');
422         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
423         msgbuf := FND_MESSAGE.get;
425 
426     ELSE
427 
428         fnd_flex_dsc_api.create_segment(
429         appl_short_name => 'INV',
430         flexfield_name => 'MTL_PARAMETERS',
431         context_name => 'Global Data Elements',
432         name => 'Late Demands Penalty',
433         column => 'ATTRIBUTE'|| to_char(org_attr1),
434         description => 'Penalty Cost Factor for Late Demands',
435         sequence_number => 10,
436         enabled => 'Y',
437         displayed => 'Y',
438         value_set => 'FND_NUMBER',
439         default_type => NULL,
440         default_value => NULL,
441         required => 'N',
442         security_enabled => 'N',
443         display_size => 25,
444         description_size => 50,
445         concatenated_description_size => 50,
446         list_of_values_prompt => 'Late Demands Penalty',
447         window_prompt => 'Late Demands Penalty',
448         range => NULL,
449         srw_parameter => NULL);
450 
451     update fnd_profile_option_values
452     set profile_option_value = to_char(org_attr1)
453     where application_id = 723
454     and level_id = 10001
455     and profile_option_id = (select profile_option_id
456 		from fnd_profile_options
457 		where application_id = 723
458 		and  profile_option_name = 'MSO_ORG_DMD_PENALTY');
459 
460    END IF;
461 
462  END IF;   -- org_attr1 is not null
463 
464 
465  IF org_attr2 IS NOT NULL THEN
466 
467     IF fnd_flex_dsc_api.is_column_used(
468 		p_application_id => '401',
469 		p_table_name => 'MTL_PARAMETERS',
470 		p_column_name => 'ATTRIBUTE'||to_char(org_attr2),
471 		x_message => msgbuf) = TRUE THEN
472 
473         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
474         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(org_attr2));
475         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
476         msgbuf := FND_MESSAGE.get;
477         LOG_MESSAGE(msgbuf);
478 
479     ELSIF fnd_flex_dsc_api.segment_exists(
480 	p_appl_short_name=>'INV',
481 	p_flexfield_name=>'MTL_PARAMETERS',
482 	p_context_code=>'Global Data Elements',
483 	p_segment_name=>'Material Over-Capacity Penalty') = TRUE THEN
484 
485         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
486         FND_MESSAGE.set_token('SEGMENT','Material Over-Capacity Penalty');
487         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
488         msgbuf := FND_MESSAGE.get;
489         LOG_MESSAGE(msgbuf);
490 
491     ELSE
492 
493         fnd_flex_dsc_api.create_segment(
494         appl_short_name => 'INV',
495         flexfield_name => 'MTL_PARAMETERS',
496         context_name => 'Global Data Elements',
497         name => 'Material Over-Capacity Penalty',
498         column => 'ATTRIBUTE'|| to_char(org_attr2),
499         description => 'Penalty Cost Factor for Exceeding Material Capacity',
500         sequence_number => 20,
501         enabled => 'Y',
502         displayed => 'Y',
503         value_set => 'FND_NUMBER',
504         default_type => NULL,
505         default_value => NULL,
506         required => 'N',
507         security_enabled => 'N',
508         display_size => 25,
509         description_size => 50,
510         concatenated_description_size => 50,
511         list_of_values_prompt => 'Material Over-Capacity Penalty',
512         window_prompt => 'Material Over-Capacity Penalty',
513         range => NULL,
514         srw_parameter => NULL);
515 
516     update fnd_profile_option_values
517     set profile_option_value = to_char(org_attr2)
518     where application_id = 723
519     and level_id = 10001
520     and profile_option_id = (select profile_option_id
521 		from fnd_profile_options
522 		where application_id = 723
523 		and  profile_option_name = 'MSO_ORG_ITEM_PENALTY');
524 
525    END IF;
526 
527  END IF;  -- org_attr2 is not null
528 
529 
530  IF org_attr3 IS NOT NULL THEN
531 
532     IF fnd_flex_dsc_api.is_column_used(
533 		p_application_id => '401',
534 		p_table_name => 'MTL_PARAMETERS',
535 		p_column_name => 'ATTRIBUTE'||to_char(org_attr3),
536 		x_message => msgbuf) = TRUE THEN
537 
538         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
539         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(org_attr3));
540         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
541         msgbuf := FND_MESSAGE.get;
542         LOG_MESSAGE(msgbuf);
543 
544     ELSIF fnd_flex_dsc_api.segment_exists(
545 	p_appl_short_name=>'INV',
546 	p_flexfield_name=>'MTL_PARAMETERS',
547 	p_context_code=>'Global Data Elements',
548 	p_segment_name=>'Resource Over-Capacity Penalty') = TRUE THEN
549 
550         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
551         FND_MESSAGE.set_token('SEGMENT','Resource Over-Capacity Penalty');
552         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
553         msgbuf := FND_MESSAGE.get;
554         LOG_MESSAGE(msgbuf);
555 
556     ELSE
557 
558 
559         fnd_flex_dsc_api.create_segment(
560         appl_short_name => 'INV',
561         flexfield_name => 'MTL_PARAMETERS',
562         context_name => 'Global Data Elements',
563         name => 'Resource Over-Capacity Penalty',
564         column => 'ATTRIBUTE'|| to_char(org_attr3),
565         description => 'Penalty Cost Factor for Exceeding Resource Capacity',
566         sequence_number => 30,
567         enabled => 'Y',
568         displayed => 'Y',
569         value_set => 'FND_NUMBER',
570         default_type => NULL,
574         display_size => 25,
571         default_value => NULL,
572         required => 'N',
573         security_enabled => 'N',
575         description_size => 50,
576         concatenated_description_size => 50,
577         list_of_values_prompt => 'Resource Over-Capacity Penalty',
578         window_prompt => 'Resource Over-Capacity Penalty',
579         range => NULL,
580         srw_parameter => NULL);
581 
582     update fnd_profile_option_values
583     set profile_option_value = to_char(org_attr3)
584     where application_id = 723
585     and level_id = 10001
586     and profile_option_id = (select profile_option_id
587 		from fnd_profile_options
588 		where application_id = 723
589 		and  profile_option_name = 'MSO_ORG_RES_PENALTY');
590 
591      END IF;
592 
593   END IF;   -- org_attr3 is not null
594 
595 
596   IF org_attr4 IS NOT NULL THEN
597 
598     IF fnd_flex_dsc_api.is_column_used(
599 		p_application_id => '401',
600 		p_table_name => 'MTL_PARAMETERS',
601 		p_column_name => 'ATTRIBUTE'||to_char(org_attr4),
602 		x_message => msgbuf) = TRUE THEN
603 
604         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
605         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(org_attr4));
606         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
607         msgbuf := FND_MESSAGE.get;
608         LOG_MESSAGE(msgbuf);
609 
610     ELSIF fnd_flex_dsc_api.segment_exists(
611 	p_appl_short_name=>'INV',
612 	p_flexfield_name=>'MTL_PARAMETERS',
613 	p_context_code=>'Global Data Elements',
614 	p_segment_name=>'Transport Over-Cap Penalty') = TRUE THEN
615 
616         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
617         FND_MESSAGE.set_token('SEGMENT','Transport Over-Cap Penalty');
618         FND_MESSAGE.set_token('TABLE','MTL_PARAMETERS');
619         msgbuf := FND_MESSAGE.get;
620         LOG_MESSAGE(msgbuf);
621 
622     ELSE
623 
624 
625         fnd_flex_dsc_api.create_segment(
626         appl_short_name => 'INV',
627         flexfield_name => 'MTL_PARAMETERS',
628         context_name => 'Global Data Elements',
629         name => 'Transport Over-Cap Penalty',
630         column => 'ATTRIBUTE'|| to_char(org_attr4),
631         description => 'Penalty Cost Factor for Exceeding Transportation Capacity',
632         sequence_number => 40,
633         enabled => 'Y',
634         displayed => 'Y',
635         value_set => 'FND_NUMBER',
636         default_type => NULL,
637         default_value => NULL,
638         required => 'N',
639         security_enabled => 'N',
640         display_size => 25,
641         description_size => 50,
642         concatenated_description_size => 50,
643         list_of_values_prompt => 'Transport Over-Cap Penalty',
644         window_prompt => 'Transport Over-Cap Penalty',
645         range => NULL,
646         srw_parameter => NULL);
647 
648     update fnd_profile_option_values
649     set profile_option_value = to_char(org_attr4)
650     where application_id = 723
651     and level_id = 10001
652     and profile_option_id = (select profile_option_id
653 		from fnd_profile_options
654 		where application_id = 723
655 		and  profile_option_name = 'MSO_ORG_TRSP_PENALTY');
656 
657      END IF;
658 
659   END IF;  -- org_attr4 is not null
660 
661 
662   IF dept_attr1 IS NOT NULL THEN
663 
664         fnd_flex_dsc_api.enable_context('BOM',
665                          'BOM_DEPARTMENT_RESOURCES',
666                          'Global Data Elements',
667                          TRUE);
668 
669 
670     IF fnd_flex_dsc_api.is_column_used(
671 		p_application_id => '702',
672 		p_table_name => 'BOM_DEPARTMENT_RESOURCES',
673 		p_column_name => 'ATTRIBUTE'||to_char(dept_attr1),
674 		x_message => msgbuf) = TRUE THEN
675 
676         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
677         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(dept_attr1));
678         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
679         msgbuf := FND_MESSAGE.get;
680         LOG_MESSAGE(msgbuf);
681 
682     ELSIF fnd_flex_dsc_api.segment_exists(
683 	p_appl_short_name=>'BOM',
684 	p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
685 	p_context_code=>'Global Data Elements',
686 	p_segment_name=>'Aggregate Resource') = TRUE THEN
687 
688         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
689         FND_MESSAGE.set_token('SEGMENT','Aggregate Resource');
690         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
691         msgbuf := FND_MESSAGE.get;
692         LOG_MESSAGE(msgbuf);
693 
694     ELSE
695 
696         fnd_flex_dsc_api.create_segment(
697         appl_short_name => 'BOM',
698         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
699         context_name => 'Global Data Elements',
700         name => 'Aggregate Resource',
701         column => 'ATTRIBUTE'|| to_char(dept_attr1),
702         description => 'Aggregate Resource Name',
703         sequence_number => 10,
704         enabled => 'Y',
705         displayed => 'Y',
706         value_set => 'MSC_AGGREGATE_RESOURCE',
707         default_type => NULL,
708         default_value => NULL,
709         required => 'N',
710         security_enabled => 'N',
711         display_size => 25,
712         description_size => 50,
713         concatenated_description_size => 50,
714         list_of_values_prompt => 'Aggregate Resource',
715         window_prompt => 'Aggregate Resource',
716         range => NULL,
717         srw_parameter => NULL);
718 
719     update fnd_profile_option_values
720     set profile_option_value = to_char(dept_attr1)
721     where application_id = 724
725 		where application_id = 724
722     and level_id = 10001
723     and profile_option_id = (select profile_option_id
724 		from fnd_profile_options
726 		and  profile_option_name = 'MSC_AGGREG_RES_NAME');
727 
728      END IF;
729 
730   END IF; -- dept_attr1 is not null
731 
732 
733 /*	IF fnd_flex_dsc_api.segment_exists(
734 		p_appl_short_name => 'BOM',
735 		p_flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
736 		p_context_code => 'Global Data Elements',
737 		p_segment_name => NULL,
738 		p_column_name => 'ATTRIBUTE'||to_char(dept_attr2)) = TRUE THEN
739 */
740 
741   IF dept_attr2 IS NOT NULL THEN
742 
743     IF fnd_flex_dsc_api.is_column_used(
744 		p_application_id => '702',
745 		p_table_name => 'BOM_DEPARTMENT_RESOURCES',
746 		p_column_name => 'ATTRIBUTE'||to_char(dept_attr2),
747 		x_message => msgbuf) = TRUE THEN
748 
749         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
750         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(dept_attr2));
751         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
752         msgbuf := FND_MESSAGE.get;
753         LOG_MESSAGE(msgbuf);
754 
755     ELSIF fnd_flex_dsc_api.segment_exists(
756 	p_appl_short_name=>'BOM',
757 	p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
758 	p_context_code=>'Global Data Elements',
759 	p_segment_name=>'Resource Over-Capacity Penalty') = TRUE THEN
760 
761         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
762         FND_MESSAGE.set_token('SEGMENT','Resource Over-Capacity Penalty');
763         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
764         msgbuf := FND_MESSAGE.get;
765         LOG_MESSAGE(msgbuf);
766 
767     ELSE
768 
769         fnd_flex_dsc_api.create_segment(
770         appl_short_name => 'BOM',
771         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
772         context_name => 'Global Data Elements',
773         name => 'Resource Over-Capacity Penalty',
774         column => 'ATTRIBUTE'|| to_char(dept_attr2),
775         description => 'Penalty Cost Factor for Exceeding Resource Capacity',
776         sequence_number => 20,
777         enabled => 'Y',
778         displayed => 'Y',
779         value_set => 'FND_NUMBER',
780         default_type => NULL,
781         default_value => NULL,
782         required => 'N',
783         security_enabled => 'N',
784         display_size => 25,
785         description_size => 50,
786         concatenated_description_size => 50,
787         list_of_values_prompt => 'Resource Over-Capacity Penalty',
788         window_prompt => 'Resource Over-Capacity Penalty',
789         range => NULL,
790         srw_parameter => NULL);
791 
792     update fnd_profile_option_values
793     set profile_option_value = to_char(dept_attr2)
794     where application_id = 723
795     and level_id = 10001
796     and profile_option_id = (select profile_option_id
797 		from fnd_profile_options
798 		where application_id = 723
799 		and  profile_option_name = 'MSO_RES_PENALTY');
800 
801      END IF;
802 
803   END IF;  --  dept_attr2 is not null
804 
805 
806   IF supp_attr1 IS NOT NULL THEN
807 
808 	  fnd_flex_dsc_api.enable_context('PO',
809                          'PO_ASL_ATTRIBUTES',
810                          'Global Data Elements',
811                          TRUE);
812 
813     IF fnd_flex_dsc_api.is_column_used(
814 		p_application_id => '201',
815 		p_table_name => 'PO_ASL_ATTRIBUTES',
816 		p_column_name => 'ATTRIBUTE'||to_char(supp_attr1),
817 		x_message => msgbuf) = TRUE THEN
818 
819         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
820         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(supp_attr1));
821         FND_MESSAGE.set_token('TABLE','PO_ASL_ATTRIBUTES');
822         msgbuf := FND_MESSAGE.get;
823         LOG_MESSAGE(msgbuf);
824 
825     ELSIF fnd_flex_dsc_api.segment_exists(
826 	p_appl_short_name=>'PO',
827 	p_flexfield_name=>'PO_ASL_ATTRIBUTES',
828 	p_context_code=>'Global Data Elements',
829 	p_segment_name=>'Material Over-Capacity Penalty') = TRUE THEN
830 
831         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
832         FND_MESSAGE.set_token('SEGMENT','Material Over-Capacity Penalty');
833         FND_MESSAGE.set_token('TABLE','PO_ASL_ATTRIBUTES');
834         msgbuf := FND_MESSAGE.get;
835         LOG_MESSAGE(msgbuf);
836 
837     ELSE
838 
839         fnd_flex_dsc_api.create_segment(
840         appl_short_name => 'PO',
841         flexfield_name => 'PO_ASL_ATTRIBUTES',
842         context_name => 'Global Data Elements',
843         name => 'Material Over-Capacity Penalty',
844         column => 'ATTRIBUTE'|| to_char(supp_attr1),
845         description => 'Penalty Cost Factor for Exceeding Material Capacity',
846         sequence_number => 10,
847         enabled => 'Y',
848         displayed => 'Y',
849         value_set => 'FND_NUMBER',
850         default_type => NULL,
851         default_value => NULL,
852         required => 'N',
853         security_enabled => 'N',
854         display_size => 25,
855         description_size => 50,
856         concatenated_description_size => 50,
857         list_of_values_prompt => 'Material Over-Capacity Penalty',
858         window_prompt => 'Material Over-Capacity Penalty',
859         range => NULL,
860         srw_parameter => NULL);
861 
862     update fnd_profile_option_values
863     set profile_option_value = to_char(supp_attr1)
864     where application_id = 723
865     and level_id = 10001
866     and profile_option_id = (select profile_option_id
867 		from fnd_profile_options
868 		where application_id = 723
869 		and  profile_option_name = 'MSO_SUP_CAP_PENALTY');
873   END IF; -- supp_attr1 is not null
870 
871      END IF;
872 
874 
875 
876   IF subst_attr1 IS NOT NULL THEN
877 
878         fnd_flex_dsc_api.enable_context('BOM',
879                          'BOM_SUBSTITUTE_COMPONENTS',
880                          'Global Data Elements',
881                          TRUE);
882 
883 
884     IF fnd_flex_dsc_api.is_column_used(
885 		p_application_id => '702',
886 		p_table_name => 'BOM_SUBSTITUTE_COMPONENTS',
887 		p_column_name => 'ATTRIBUTE'||to_char(subst_attr1),
888 		x_message => msgbuf) = TRUE THEN
889 
890         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
891         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(subst_attr1));
892         FND_MESSAGE.set_token('TABLE','BOM_SUBSTITUTE_COMPONENTS');
893         msgbuf := FND_MESSAGE.get;
894         LOG_MESSAGE(msgbuf);
895 
896     ELSIF fnd_flex_dsc_api.segment_exists(
897 	p_appl_short_name=>'BOM',
898 	p_flexfield_name=>'BOM_SUBSTITUTE_COMPONENTS',
899 	p_context_code=>'Global Data Elements',
900 	p_segment_name=>'Substitute Priority') = TRUE THEN
901 
902         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
903         FND_MESSAGE.set_token('SEGMENT','Substitute Priority');
904         FND_MESSAGE.set_token('TABLE','BOM_SUBSTITUTE_COMPONENTS');
905         msgbuf := FND_MESSAGE.get;
906         LOG_MESSAGE(msgbuf);
907 
908     ELSE
909 
910        fnd_flex_dsc_api.create_segment(
911         appl_short_name => 'BOM',
912         flexfield_name => 'BOM_SUBSTITUTE_COMPONENTS',
913         context_name => 'Global Data Elements',
914         name => 'Substitute Priority',
915         column => 'ATTRIBUTE'|| to_char(subst_attr1),
916         description => 'Priority for Substitute Items',
917         sequence_number => 10,
918         enabled => 'Y',
919         displayed => 'Y',
920         value_set => 'FND_NUMBER',
921         default_type => NULL,
922         default_value => NULL,
923         required => 'N',
924         security_enabled => 'N',
925         display_size => 25,
926         description_size => 50,
927         concatenated_description_size => 50,
928         list_of_values_prompt => 'Substitute Priority',
929         window_prompt => 'Substitute Priority',
930         range => NULL,
931         srw_parameter => NULL);
932 
933     update fnd_profile_option_values
934     set profile_option_value = to_char(subst_attr1)
935     where application_id = 724
936     and level_id = 10001
937     and profile_option_id = (select profile_option_id
938 		from fnd_profile_options
939 		where application_id = 724
940 		and  profile_option_name = 'MSC_BOM_SUBST_PRIORITY');
941 
942      END IF;
943 
944   END IF;  -- subst_attr1 is not null
945 
946 
947   IF trans_attr1 IS NOT NULL THEN
948 
949         fnd_flex_dsc_api.enable_context('INV',
950                          'MTL_INTERORG_SHIP_METHODS',
951                          'Global Data Elements',
952                          TRUE);
953 
954 
955     IF fnd_flex_dsc_api.is_column_used(
956 		p_application_id => '401',
957 		p_table_name => 'MTL_INTERORG_SHIP_METHODS',
958 		p_column_name => 'ATTRIBUTE'||to_char(trans_attr1),
959 		x_message => msgbuf) = TRUE THEN
960 
961         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
962         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(trans_attr1));
963         FND_MESSAGE.set_token('TABLE','MTL_INTERORG_SHIP_METHODS');
964         msgbuf := FND_MESSAGE.get;
965         LOG_MESSAGE(msgbuf);
966 
967     ELSIF fnd_flex_dsc_api.segment_exists(
968 	p_appl_short_name=>'INV',
969 	p_flexfield_name=>'MTL_INTERORG_SHIP_METHODS',
970 	p_context_code=>'Global Data Elements',
971 	p_segment_name=>'Transport Over-Cap Penalty') = TRUE THEN
972 
973         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
974         FND_MESSAGE.set_token('SEGMENT','Transport Over-Cap Penalty');
975         FND_MESSAGE.set_token('TABLE','MTL_INTERORG_SHIP_METHODS');
976         msgbuf := FND_MESSAGE.get;
977         LOG_MESSAGE(msgbuf);
978 
979     ELSE
980 
981         fnd_flex_dsc_api.create_segment(
982         appl_short_name => 'INV',
983         flexfield_name => 'MTL_INTERORG_SHIP_METHODS',
984         context_name => 'Global Data Elements',
985         name => 'Transport Over-Cap Penalty',
986         column => 'ATTRIBUTE'|| to_char(trans_attr1),
987         description => 'Penalty Cost Factor for Exceeding Transportation Capacity',
988         sequence_number => 10,
989         enabled => 'Y',
990         displayed => 'Y',
991         value_set => 'FND_NUMBER',
992         default_type => NULL,
993         default_value => NULL,
994         required => 'N',
995         security_enabled => 'N',
996         display_size => 25,
997         description_size => 50,
998         concatenated_description_size => 50,
999         list_of_values_prompt => 'Transport Over-Cap Penalty',
1000         window_prompt => 'Transport Over-Cap Penalty',
1001         range => NULL,
1002         srw_parameter => NULL);
1003 
1004     update fnd_profile_option_values
1005     set profile_option_value = to_char(trans_attr1)
1006     where application_id = 723
1007     and level_id = 10001
1008     and profile_option_id = (select profile_option_id
1009 		from fnd_profile_options
1010 		where application_id = 723
1011 		and  profile_option_name = 'MSO_TRSP_PENALTY');
1012 
1013      END IF;
1014 
1015   END IF;  -- trans_attr1 is not null
1016 
1017 
1018   IF bom_attr1 IS NOT NULL THEN
1019 
1020         fnd_flex_dsc_api.enable_context('BOM',
1021                          'BOM_BILL_OF_MATERIALS',
1025 
1022                          'Global Data Elements',
1023                          TRUE);
1024 
1026     IF fnd_flex_dsc_api.is_column_used(
1027 		p_application_id => '702',
1028 		p_table_name => 'BOM_BILL_OF_MATERIALS',
1029 		p_column_name => 'ATTRIBUTE'||to_char(bom_attr1),
1030 		x_message => msgbuf) = TRUE THEN
1031 
1032         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1033         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr1));
1034         FND_MESSAGE.set_token('TABLE','BOM_BILL_OF_MATERIALS');
1035         msgbuf := FND_MESSAGE.get;
1036         LOG_MESSAGE(msgbuf);
1037 
1038     ELSIF fnd_flex_dsc_api.segment_exists(
1039 	p_appl_short_name=>'BOM',
1040 	p_flexfield_name=>'BOM_BILL_OF_MATERIALS',
1041 	p_context_code=>'Global Data Elements',
1042 	p_segment_name=>'Cost of Using a BOM/Routing') = TRUE THEN
1043 
1044         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1045         FND_MESSAGE.set_token('SEGMENT','Cost of Using a BOM/Routing');
1046         FND_MESSAGE.set_token('TABLE','BOM_BILL_OF_MATERIALS');
1047         msgbuf := FND_MESSAGE.get;
1048         LOG_MESSAGE(msgbuf);
1049 
1050     ELSE
1051 
1052         fnd_flex_dsc_api.create_segment(
1053         appl_short_name => 'BOM',
1054         flexfield_name => 'BOM_BILL_OF_MATERIALS',
1055         context_name => 'Global Data Elements',
1056         name => 'Cost of Using a BOM/Routing',
1057         column => 'ATTRIBUTE'|| to_char(bom_attr1),
1058         description => 'Cost of Using a BOM/Routing',
1059         sequence_number => 10,
1060         enabled => 'Y',
1061         displayed => 'Y',
1062         value_set => 'FND_NUMBER',
1063         default_type => NULL,
1064         default_value => NULL,
1065         required => 'N',
1066         security_enabled => 'N',
1067         display_size => 25,
1068         description_size => 50,
1069         concatenated_description_size => 50,
1070         list_of_values_prompt => 'Cost of Using a BOM/Routing',
1071         window_prompt => 'Cost of Using a BOM/Routing',
1072         range => NULL,
1073         srw_parameter => NULL);
1074 
1075     update fnd_profile_option_values
1076     set profile_option_value = to_char(bom_attr1)
1077     where application_id = 724
1078     and level_id = 10001
1079     and profile_option_id = (select profile_option_id
1080 		from fnd_profile_options
1081 		where application_id = 724
1082 		and  profile_option_name = 'MSC_ALT_BOM_COST');
1083 
1084      END IF;
1085 
1086   END IF;  --bom_attr1 is not null
1087 
1088 
1089   IF forecast_attr1 IS NOT NULL THEN
1090 
1091         fnd_flex_dsc_api.enable_context('MRP',
1092                          'MRP_FORECAST_DATES',
1093                          'Global Data Elements',
1094                          TRUE);
1095 
1096 
1097     IF fnd_flex_dsc_api.is_column_used(
1098 		p_application_id => '704',
1099 		p_table_name => 'MRP_FORECAST_DATES',
1100 		p_column_name => 'ATTRIBUTE'||to_char(forecast_attr1),
1101 		x_message => msgbuf) = TRUE THEN
1102 
1103         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1104         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(forecast_attr1));
1105         FND_MESSAGE.set_token('TABLE','MRP_FORECAST_DATES');
1106         msgbuf := FND_MESSAGE.get;
1107         LOG_MESSAGE(msgbuf);
1108 
1109     ELSIF fnd_flex_dsc_api.segment_exists(
1110 	p_appl_short_name=>'MRP',
1111 	p_flexfield_name=>'MRP_FORECAST_DATES',
1112 	p_context_code=>'Global Data Elements',
1113 	p_segment_name=>'Late Forecasts Penalty') = TRUE THEN
1114 
1115         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1116         FND_MESSAGE.set_token('SEGMENT','Late Forecasts Penalty');
1117         FND_MESSAGE.set_token('TABLE','MRP_FORECAST_DATES');
1118         msgbuf := FND_MESSAGE.get;
1119         LOG_MESSAGE(msgbuf);
1120 
1121     ELSE
1122 
1123        fnd_flex_dsc_api.create_segment(
1124         appl_short_name => 'MRP',
1125         flexfield_name => 'MRP_FORECAST_DATES',
1126         context_name => 'Global Data Elements',
1127         name => 'Late Forecasts Penalty',
1128         column => 'ATTRIBUTE'|| to_char(forecast_attr1),
1129         description => 'Penalty Cost Factor for Late Forecasts',
1130         sequence_number => 10,
1131         enabled => 'Y',
1132         displayed => 'Y',
1133         value_set => 'FND_NUMBER',
1134         default_type => NULL,
1135         default_value => NULL,
1136         required => 'N',
1137         security_enabled => 'N',
1138         display_size => 25,
1139         description_size => 50,
1140         concatenated_description_size => 50,
1141         list_of_values_prompt => 'Late Forecasts Penalty',
1142         window_prompt => 'Late Forecasts Penalty',
1143         range => NULL,
1144         srw_parameter => NULL);
1145 
1146     update fnd_profile_option_values
1147     set profile_option_value = to_char(forecast_attr1)
1148     where application_id = 723
1149     and level_id = 10001
1150     and profile_option_id = (select profile_option_id
1151 		from fnd_profile_options
1152 		where application_id = 723
1153 		and  profile_option_name = 'MSO_FCST_PENALTY');
1154 
1155      END IF;
1156 
1157   END IF;   -- forecast_attr1 is not null
1158 
1159 
1160   IF line_attr1 IS NOT NULL THEN
1161 
1162      fnd_flex_dsc_api.enable_context('WIP',
1163                          'WIP_LINES',
1164                          'Global Data Elements',
1165                          TRUE);
1166 
1167     IF fnd_flex_dsc_api.is_column_used(
1168 		p_application_id => '706',
1169 		p_table_name => 'WIP_LINES',
1170 		p_column_name => 'ATTRIBUTE'||to_char(line_attr1),
1171 		x_message => msgbuf) = TRUE THEN
1172 
1176         msgbuf := FND_MESSAGE.get;
1173         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1174         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(line_attr1));
1175         FND_MESSAGE.set_token('TABLE','WIP_LINES');
1177         LOG_MESSAGE(msgbuf);
1178 
1179     ELSIF fnd_flex_dsc_api.segment_exists(
1180 	p_appl_short_name=>'WIP',
1181 	p_flexfield_name=>'WIP_LINES',
1182 	p_context_code=>'Global Data Elements',
1183 	p_segment_name=>'Resource Group') = TRUE THEN
1184 
1185         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1186         FND_MESSAGE.set_token('SEGMENT','Resource Group');
1187         FND_MESSAGE.set_token('TABLE','WIP_LINES');
1188         msgbuf := FND_MESSAGE.get;
1189         LOG_MESSAGE(msgbuf);
1190 
1191     ELSE
1192 
1193         fnd_flex_dsc_api.create_segment(
1194         appl_short_name => 'WIP',
1195         flexfield_name => 'WIP_LINES',
1196         context_name => 'Global Data Elements',
1197         name => 'Resource Group',
1198         column => 'ATTRIBUTE'|| to_char(line_attr1),
1199         description => 'Resource Group',
1200         sequence_number => 30,
1201         enabled => 'Y',
1202         displayed => 'Y',
1203         value_set => 'FND_NUMBER',
1204         default_type => NULL,
1205         default_value => NULL,
1206         required => 'N',
1207         security_enabled => 'N',
1208         display_size => 25,
1209         description_size => 50,
1210         concatenated_description_size => 50,
1211         list_of_values_prompt => 'Resource Group',
1212         window_prompt => 'Resource Group',
1213         range => NULL,
1214         srw_parameter => NULL);
1215 
1216     update fnd_profile_option_values
1217     set profile_option_value = to_char(line_attr1)
1218     where application_id = 724
1219     and level_id = 10001
1220     and profile_option_id = (select profile_option_id
1221 		from fnd_profile_options
1222 		where application_id = 724
1223 		and  profile_option_name = 'MSC_LINE_RES_GROUP');
1224 
1225      END IF;
1226 
1227   END IF;  --line_attr1 is not null
1228 
1229   if schedule_attr1 is not null then
1230     fnd_flex_dsc_api.enable_context('MRP',
1231                          'MRP_SCHEDULE_DATES',
1232                          'Global Data Elements',
1233                          TRUE);
1234     IF fnd_flex_dsc_api.is_column_used(
1235 		p_application_id => '704',
1236 		p_table_name => 'MRP_SCHEDULE_DATES',
1237 		p_column_name => 'ATTRIBUTE'||to_char(schedule_attr1),
1238 		x_message => msgbuf) = TRUE THEN
1239 
1240         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1241         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(schedule_attr1));
1242         FND_MESSAGE.set_token('TABLE','MRP_SCHEDULE_DATES');
1243         msgbuf := FND_MESSAGE.get;
1244         LOG_MESSAGE(msgbuf);
1245     ELSIF fnd_flex_dsc_api.segment_exists(
1246 	p_appl_short_name=>'MRP',
1247 	p_flexfield_name=>'MRP_SCHEDULE_DATES',
1248 	p_context_code=>'Global Data Elements',
1249 	p_segment_name=>'Demand Priority') = TRUE THEN
1250 
1251         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1252         FND_MESSAGE.set_token('SEGMENT','Demand Priority');
1253         FND_MESSAGE.set_token('TABLE','MRP_SCHEDULE_DATES');
1254         msgbuf := FND_MESSAGE.get;
1255         LOG_MESSAGE(msgbuf);
1256 
1257     ELSE
1258         fnd_flex_dsc_api.create_segment(
1259         appl_short_name => 'MRP',
1260         flexfield_name => 'MRP_SCHEDULE_DATES',
1261         context_name => 'Global Data Elements',
1262         name => 'Demand Priority',
1263         column => 'ATTRIBUTE'|| to_char(schedule_attr1),
1264         description => 'Demand Priority',
1265         sequence_number => 10,
1266         enabled => 'Y',
1267         displayed => 'Y',
1268         value_set => 'FND_NUMBER',
1269         default_type => NULL,
1270         default_value => NULL,
1271         required => 'N',
1272         security_enabled => 'N',
1273         display_size => 25,
1274         description_size => 50,
1275         concatenated_description_size => 50,
1276         list_of_values_prompt => 'Demand Priority',
1277         window_prompt => 'Demand Priority',
1278         range => NULL,
1279         srw_parameter => NULL);
1280 
1281         update fnd_profile_option_values
1282            set profile_option_value = to_char(schedule_attr1)
1283            where application_id = 704
1284            and level_id = 10001
1285            and profile_option_id = (select profile_option_id
1286 		from fnd_profile_options
1287 		where application_id = 704
1288 		and  profile_option_name = 'MRP_DMD_PRIORITY_FLEX_NUM');
1289 
1290     END IF;
1291   end if; --schedule_attr1 is not null
1292 
1293     COMMIT;
1294     -- this commit is required so that the conc requests will see this data
1295     -- we need to submit concurrent requests to recompile flex views
1296 
1297     req_id := fnd_request.submit_request(
1298                 'FND', 'FDFVGN', '', '', FALSE,
1299                 '3', 401,
1300                 'MTL_SYSTEM_ITEMS');
1301     IF (req_id = 0) THEN
1302       raise conc_failure;
1303     END IF;
1304 
1305     req_id := fnd_request.submit_request(
1306                 'FND', 'FDFVGN', '', '', FALSE,
1307                 '3', 401,
1308                 'MTL_PARAMETERS');
1309     IF (req_id = 0) THEN
1310       raise conc_failure;
1311     END IF;
1312 
1313     req_id := fnd_request.submit_request(
1314                 'FND', 'FDFVGN', '', '', FALSE,
1315                 '3', 702,
1316                 'BOM_DEPARTMENT_RESOURCES');
1317     IF (req_id = 0) THEN
1318       raise conc_failure;
1319     END IF;
1320 
1321     req_id := fnd_request.submit_request(
1325     IF (req_id = 0) THEN
1322                 'FND', 'FDFVGN', '', '', FALSE,
1323                 '3', 201,
1324                 'PO_ASL_ATTRIBUTES');
1326       raise conc_failure;
1327     END IF;
1328 
1329     req_id := fnd_request.submit_request(
1330                 'FND', 'FDFVGN', '', '', FALSE,
1331                 '3', 702,
1332                 'BOM_SUBSTITUTE_COMPONENTS');
1333     IF (req_id = 0) THEN
1334       raise conc_failure;
1335     END IF;
1336 
1337 
1338     req_id := fnd_request.submit_request(
1339                 'FND', 'FDFVGN', '', '', FALSE,
1340                 '3', 401,
1341                 'MTL_INTERORG_SHIP_METHODS');
1342     IF (req_id = 0) THEN
1343       raise conc_failure;
1344     END IF;
1345 
1346 
1347     req_id := fnd_request.submit_request(
1348                 'FND', 'FDFVGN', '', '', FALSE,
1349                 '3', 702,
1350                 'BOM_BILL_OF_MATERIALS');
1351     IF (req_id = 0) THEN
1352       raise conc_failure;
1353     END IF;
1354 
1355 
1356     req_id := fnd_request.submit_request(
1357                 'FND', 'FDFVGN', '', '', FALSE,
1358                 '3', 704,
1359                 'MRP_FORECAST_DATES');
1360     IF (req_id = 0) THEN
1361       raise conc_failure;
1362     END IF;
1363 
1364     req_id := fnd_request.submit_request(
1365                 'FND', 'FDFVGN', '', '', FALSE,
1366                 '3', 706,
1367                 'WIP_LINES');
1368     IF (req_id = 0) THEN
1369       raise conc_failure;
1370     END IF;
1371 
1372 
1373     req_id := fnd_request.submit_request(
1374                 'FND', 'FDFVGN', '', '', FALSE,
1375                 '3', 704,
1376                 'MRP_SCHEDULE_DATES');
1377     IF (req_id = 0) THEN
1378       raise conc_failure;
1379     END IF;
1380 
1381     COMMIT;
1382     errbuf := 'Created flexfields, updates profile values and submitted requests to recompile flexfields';
1383     retcode := 0; -- success
1384 EXCEPTION
1385    WHEN conc_failure THEN
1386      errbuf := 'Error ' ||
1387                   substr(fnd_message.get,1,240);
1388      retcode := 2;
1389    WHEN OTHERS THEN
1390    rollback;
1391     if (fnd_flex_dsc_api.message is null) then
1392       errbuf := 'Sql Error:' || to_char(sqlcode);
1393     else
1394       errbuf := fnd_flex_dsc_api.message;
1395     end if;
1396     retcode := 2; -- failure
1397 END Configure;
1398 
1399 PROCEDURE Configure_strn_flex(
1400 	ERRBUF      	OUT NOCOPY VARCHAR2,
1401 	RETCODE     	OUT NOCOPY NUMBER,
1402 	oper_attr1      IN  NUMBER)
1403 AS
1404 
1405 	req_id 		NUMBER;
1406 	conc_failure 	EXCEPTION;
1407 
1408 	msgbuf		VARCHAR2(2000);
1409 
1410 BEGIN
1411 
1412    fnd_flex_dsc_api.debug_on;
1413    fnd_flex_dsc_api.set_session_mode('seed_data');
1414 
1415    fnd_flex_dsc_api.enable_context('BOM',
1416                          'OPERATION_RESOURCES',
1417                          'Global Data Elements',
1418                          TRUE);
1419 
1420     IF
1421        fnd_flex_dsc_api.is_column_used(
1422                         p_application_id => '702',
1423                         p_table_name => 'OPERATION_RESOURCES',
1424                         p_column_name => 'ATTRIBUTE'||to_char(oper_attr1),
1425                         x_message => msgbuf) = TRUE THEN
1426 
1427         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1428         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(oper_attr1));
1429         FND_MESSAGE.set_token('TABLE','OPERATION_RESOURCES');
1430         msgbuf := FND_MESSAGE.get;
1431         LOG_MESSAGE(msgbuf);
1432     ELSIF
1433        fnd_flex_dsc_api.segment_exists(
1434 	p_appl_short_name=>'BOM',
1435 	p_flexfield_name=>'OPERATION_RESOURCES',
1436 	p_context_code=>'Global Data Elements',
1437 	p_segment_name=>'Activity Group Id') = TRUE THEN
1438         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1439         FND_MESSAGE.set_token('SEGMENT','Activity Group Id');
1440         FND_MESSAGE.set_token('TABLE','OPERATION_RESOURCES');
1441         msgbuf := FND_MESSAGE.get;
1442         LOG_MESSAGE(msgbuf);
1443     ELSE
1444         fnd_flex_dsc_api.create_segment(
1445         appl_short_name => 'BOM',
1446         flexfield_name => 'OPERATION_RESOURCES',
1447         context_name => 'Global Data Elements',
1448         name => 'Activity Group Id',
1449         column => 'ATTRIBUTE'|| to_char(oper_attr1),
1450         description => 'Activity Group Id for Setup and Run Operation',
1451         sequence_number => 150,
1452         enabled => 'Y',
1453         displayed => 'Y',
1454         value_set => 'FND_NUMBER',
1455         default_type => NULL,
1456         default_value => NULL,
1457         required => 'N',
1458         security_enabled => 'N',
1459         display_size => 25,
1460         description_size => 50,
1461         concatenated_description_size => 50,
1462         list_of_values_prompt => 'Activity Group Id',
1463         window_prompt => 'Activity Group Id',
1464         range => NULL,
1465         srw_parameter => NULL);
1466      END IF;
1467 
1468 
1469     fnd_flex_dsc_api.enable_context('BOM',
1470                          'SUB_OPERATION_RESOURCES',
1471                          'Global Data Elements',
1472                          TRUE);
1473  -- fix for Bug 2748600
1474     IF
1475        fnd_flex_dsc_api.segment_exists(
1476         p_appl_short_name=>'BOM',
1477         p_flexfield_name=>'SUB_OPERATION_RESOURCES',
1478         p_context_code=>'Global Data Elements',
1479         p_segment_name=>'Activity Grp Id - Alt Resource') = TRUE THEN
1480         fnd_flex_dsc_api.delete_segment(
1481         appl_short_name => 'BOM',
1485      END IF;
1482         flexfield_name => 'SUB_OPERATION_RESOURCES',
1483         context => 'Global Data Elements',
1484         segment => 'Activity Grp Id - Alt Resource');
1486 
1487 
1488    COMMIT;
1489 
1490     req_id := fnd_request.submit_request(
1491                 'FND', 'FDFVGN', '', '', FALSE,
1492                 '3', 702,
1493                 'OPERATION_RESOURCES');
1494 
1495 /*
1496     req_id := fnd_request.submit_request(
1497                 'FND', 'FDFVGN', '', '', FALSE,
1498                 '3', 702,
1499                 'SUB_OPERATION_RESOURCES');
1500 */
1501 
1502     IF (req_id = 0) THEN
1503       raise conc_failure;
1504     END IF;
1505 
1506     COMMIT;
1507     errbuf := 'Created flexfields - submitted requests to recompile flexfields';
1508     retcode := 0; -- success
1509 
1510 EXCEPTION
1511 
1512    WHEN conc_failure THEN
1513      errbuf := 'Error ' ||
1514                   substr(fnd_message.get,1,240);
1515      retcode := 2;
1516 
1517    WHEN OTHERS THEN
1518    rollback;
1519     if (fnd_flex_dsc_api.message is null) then
1520       errbuf := 'Sql Error:' || to_char(sqlcode);
1521     else
1522       errbuf := fnd_flex_dsc_api.message;
1523     end if;
1524     retcode := 2; -- failure
1525 
1526 END Configure_strn_flex;
1527 
1528 PROCEDURE Configure_reba_flex(
1529         ERRBUF          OUT NOCOPY VARCHAR2,
1530         RETCODE         OUT NOCOPY NUMBER,
1531         bom_attr1       IN NUMBER,
1532 	bom_attr2       IN NUMBER,
1533  	bom_attr3	IN NUMBER,
1534 	bom_attr4	IN NUMBER,
1535 	bom_attr5	IN NUMBER)
1536 
1537 as
1538 
1539         req_id          NUMBER;
1540         conc_failure    EXCEPTION;
1541 
1542         msgbuf          VARCHAR2(2000);
1543 
1544 Begin
1545 
1546    fnd_flex_dsc_api.debug_on;
1547    fnd_flex_dsc_api.set_session_mode('seed_data');
1548 
1549    fnd_flex_dsc_api.enable_context('BOM',
1550                          'BOM_DEPARTMENT_RESOURCES',
1551                          'Global Data Elements',
1552                          TRUE);
1553 
1554     IF
1555        fnd_flex_dsc_api.is_column_used(
1556                         p_application_id => '702',
1557                         p_table_name => 'BOM_DEPARTMENT_RESOURCES',
1558                         p_column_name => 'ATTRIBUTE'||to_char(bom_attr1),
1559                         x_message => msgbuf) = TRUE THEN
1560 
1561         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1562         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr1));
1563         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1564         msgbuf := FND_MESSAGE.get;
1565         LOG_MESSAGE(msgbuf);
1566     ELSIF
1567        fnd_flex_dsc_api.segment_exists(
1568         p_appl_short_name=>'BOM',
1569         p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
1570         p_context_code=>'Global Data Elements',
1571         p_segment_name=>'Batchable Flag') = TRUE THEN
1572         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1573         FND_MESSAGE.set_token('SEGMENT','Batchable Flag');
1574         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1575         msgbuf := FND_MESSAGE.get;
1576         LOG_MESSAGE(msgbuf);
1577     ELSE
1578         fnd_flex_dsc_api.create_segment(
1579         appl_short_name => 'BOM',
1580         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
1581         context_name => 'Global Data Elements',
1582         name => 'Batchable Flag',
1583         column => 'ATTRIBUTE'|| to_char(bom_attr1),
1584         description => 'Batchable Flag',
1585         sequence_number => 150,
1586         enabled => 'Y',
1587         displayed => 'Y',
1588         value_set => 'MSC_SRS_SYS_YES_NO',
1589         default_type => NULL,
1590         default_value => NULL,
1591         required => 'N',
1592         security_enabled => 'N',
1593         display_size => 25,
1594         description_size => 50,
1595         concatenated_description_size => 50,
1596         list_of_values_prompt => 'Batchable Flag',
1597         window_prompt => 'Batchable Flag',
1598         range => NULL,
1599         srw_parameter => NULL);
1600 
1601 	update fnd_profile_option_values
1602            set profile_option_value = to_char(bom_attr1)
1603            where application_id = 724
1604            and level_id = 10001
1605            and profile_option_id = (select profile_option_id
1606                 from fnd_profile_options
1607                 where application_id = 724
1608                 and  profile_option_name = 'MSC_BATCHABLE_FLAG');
1609 
1610     END IF;
1611 
1612     COMMIT;
1613 
1614 
1615     IF
1616        fnd_flex_dsc_api.is_column_used(
1617                         p_application_id => '702',
1618                         p_table_name => 'BOM_DEPARTMENT_RESOURCES',
1619                         p_column_name => 'ATTRIBUTE'||to_char(bom_attr2),
1620                         x_message => msgbuf) = TRUE THEN
1621 
1622         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1623         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr2));
1624         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1625         msgbuf := FND_MESSAGE.get;
1626         LOG_MESSAGE(msgbuf);
1627     ELSIF
1628        fnd_flex_dsc_api.segment_exists(
1629         p_appl_short_name=>'BOM',
1630         p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
1631         p_context_code=>'Global Data Elements',
1632         p_segment_name=>'Batching Window') = TRUE THEN
1633         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1634         FND_MESSAGE.set_token('SEGMENT','Batching Window');
1635         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1639         fnd_flex_dsc_api.create_segment(
1636         msgbuf := FND_MESSAGE.get;
1637         LOG_MESSAGE(msgbuf);
1638     ELSE
1640         appl_short_name => 'BOM',
1641         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
1642         context_name => 'Global Data Elements',
1643         name => 'Batching Window',
1644         column => 'ATTRIBUTE'||to_char(bom_attr2),
1645         description => 'Batching Window',
1646         sequence_number => 160,
1647         enabled => 'Y',
1648         displayed => 'Y',
1649         value_set => 'MSC_SRS_DECIMAL',
1650         default_type => NULL,
1651         default_value => NULL,
1652         required => 'N',
1653         security_enabled => 'N',
1654         display_size => 25,
1655         description_size => 50,
1656         concatenated_description_size => 50,
1657         list_of_values_prompt => 'Batching Window',
1658         window_prompt => 'Batching Window',
1659         range => NULL,
1660         srw_parameter => NULL);
1661 
1662       update fnd_profile_option_values
1663            set profile_option_value = to_char(bom_attr2)
1664            where application_id = 724
1665            and level_id = 10001
1666            and profile_option_id = (select profile_option_id
1667                 from fnd_profile_options
1668                 where application_id = 724
1669                 and  profile_option_name = 'MSC_BATCHING_WINDOW');
1670 
1671     END IF;
1672     COMMIT;
1673 
1674     IF
1675        fnd_flex_dsc_api.is_column_used(
1676                         p_application_id => '702',
1677                         p_table_name => 'BOM_DEPARTMENT_RESOURCES',
1678                         p_column_name => 'ATTRIBUTE'||to_char(bom_attr3),
1679                         x_message => msgbuf) = TRUE THEN
1680 
1681         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1682         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr3));
1683         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1684         msgbuf := FND_MESSAGE.get;
1685         LOG_MESSAGE(msgbuf);
1686     ELSIF
1687        fnd_flex_dsc_api.segment_exists(
1688         p_appl_short_name=>'BOM',
1689         p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
1690         p_context_code=>'Global Data Elements',
1691         p_segment_name=>'Minimum Batch Capacity') = TRUE THEN
1692         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1693         FND_MESSAGE.set_token('SEGMENT','Minimum Batch Capacity');
1694         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1695         msgbuf := FND_MESSAGE.get;
1696         LOG_MESSAGE(msgbuf);
1697     ELSE
1698         fnd_flex_dsc_api.create_segment(
1699         appl_short_name => 'BOM',
1700         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
1701         context_name => 'Global Data Elements',
1702         name => 'Minimum Batch Capacity',
1703         column => 'ATTRIBUTE'||to_char(bom_attr3),
1704         description => 'Minimum Batch Capacity',
1705         sequence_number => 170,
1706         enabled => 'Y',
1707         displayed => 'Y',
1708         value_set => 'MSC_SRS_DECIMAL',
1709         default_type => NULL,
1710         default_value => NULL,
1711         required => 'N',
1712         security_enabled => 'N',
1713         display_size => 25,
1714         description_size => 50,
1715         concatenated_description_size => 50,
1716         list_of_values_prompt => 'Minimum Batch Capacity',
1717         window_prompt => 'Minimum Batch Capacity',
1718         range => NULL,
1719         srw_parameter => NULL);
1720 
1721       update fnd_profile_option_values
1722            set profile_option_value = to_char(bom_attr3)
1723            where application_id = 724
1724            and level_id = 10001
1725            and profile_option_id = (select profile_option_id
1726                 from fnd_profile_options
1727                 where application_id = 724
1728                 and  profile_option_name = 'MSC_MIN_CAPACITY');
1729 
1730     END IF;
1731     COMMIT;
1732 
1733     IF
1734        fnd_flex_dsc_api.is_column_used(
1735                         p_application_id => '702',
1736                         p_table_name => 'BOM_DEPARTMENT_RESOURCES',
1737                         p_column_name => 'ATTRIBUTE'||to_char(bom_attr4),
1738                         x_message => msgbuf) = TRUE THEN
1739 
1740         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1741         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr4));
1742         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1743         msgbuf := FND_MESSAGE.get;
1744         LOG_MESSAGE(msgbuf);
1745     ELSIF
1746        fnd_flex_dsc_api.segment_exists(
1747         p_appl_short_name=>'BOM',
1748         p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
1749         p_context_code=>'Global Data Elements',
1750         p_segment_name=>'Maximum Batch Capacity') = TRUE THEN
1751         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1752         FND_MESSAGE.set_token('SEGMENT','Maximum Batch Capacity');
1753         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1754         msgbuf := FND_MESSAGE.get;
1755         LOG_MESSAGE(msgbuf);
1756     ELSE
1757         fnd_flex_dsc_api.create_segment(
1758         appl_short_name => 'BOM',
1759         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
1760         context_name => 'Global Data Elements',
1761         name => 'Maximum Batch Capacity',
1762         column => 'ATTRIBUTE'||to_char(bom_attr4),
1763         description => 'Maximum Capacity',
1764         sequence_number => 180,
1765         enabled => 'Y',
1766         displayed => 'Y',
1767         value_set => 'MSC_SRS_DECIMAL',
1768         default_type => NULL,
1769         default_value => NULL,
1770         required => 'N',
1771         security_enabled => 'N',
1775         list_of_values_prompt => 'Maximum Batch Capacity',
1772         display_size => 25,
1773         description_size => 50,
1774         concatenated_description_size => 50,
1776         window_prompt => 'Maximum Batch Capacity',
1777         range => NULL,
1778         srw_parameter => NULL);
1779 
1780      update fnd_profile_option_values
1781            set profile_option_value = to_char(bom_attr4)
1782            where application_id = 724
1783            and level_id = 10001
1784            and profile_option_id = (select profile_option_id
1785                 from fnd_profile_options
1786                 where application_id = 724
1787                 and  profile_option_name = 'MSC_MAX_CAPACITY');
1788 
1789     END IF;
1790     COMMIT;
1791 
1792     IF
1793        fnd_flex_dsc_api.is_column_used(
1794                         p_application_id => '702',
1795                         p_table_name => 'BOM_DEPARTMENT_RESOURCES',
1796                         p_column_name => 'ATTRIBUTE'||to_char(bom_attr5),
1797                         x_message => msgbuf) = TRUE THEN
1798 
1799         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1800         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(bom_attr5));
1801         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1802         msgbuf := FND_MESSAGE.get;
1803         LOG_MESSAGE(msgbuf);
1804     ELSIF
1805        fnd_flex_dsc_api.segment_exists(
1806         p_appl_short_name=>'BOM',
1807         p_flexfield_name=>'BOM_DEPARTMENT_RESOURCES',
1808         p_context_code=>'Global Data Elements',
1809         p_segment_name=>'Batchable Unit of Measure') = TRUE THEN
1810         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1811         FND_MESSAGE.set_token('SEGMENT','Batchable Unit of Measure');
1812         FND_MESSAGE.set_token('TABLE','BOM_DEPARTMENT_RESOURCES');
1813         msgbuf := FND_MESSAGE.get;
1814         LOG_MESSAGE(msgbuf);
1815     ELSE
1816         fnd_flex_dsc_api.create_segment(
1817         appl_short_name => 'BOM',
1818         flexfield_name => 'BOM_DEPARTMENT_RESOURCES',
1819         context_name => 'Global Data Elements',
1820         name => 'Batchable Unit of Measure',
1821         column => 'ATTRIBUTE'||to_char(bom_attr5),
1822         description => 'Batchable Unit of Measure',
1823         sequence_number => 190,
1824         enabled => 'Y',
1825         displayed => 'Y',
1826         value_set => 'MSC_SRS_UNIT_OF_MEASURE',
1827         default_type => NULL,
1828         default_value => NULL,
1829         required => 'N',
1830         security_enabled => 'N',
1831         display_size => 25,
1832         description_size => 50,
1833         concatenated_description_size => 50,
1834         list_of_values_prompt => 'Batchable Unit Of Measure',
1835         window_prompt => 'Batchable Unit of Measure',
1836         range => NULL,
1837         srw_parameter => NULL);
1838 
1839      update fnd_profile_option_values
1840            set profile_option_value = to_char(bom_attr5)
1841            where application_id = 724
1842            and level_id = 10001
1843            and profile_option_id = (select profile_option_id
1844                 from fnd_profile_options
1845                 where application_id = 724
1846                 and  profile_option_name = 'MSC_UNIT_OF_MEASURE');
1847 
1848     END IF;
1849     COMMIT;
1850 
1851   req_id := fnd_request.submit_request(
1852                 'FND', 'FDFVGN', '', '', FALSE,
1853                 '3', 702,
1854                 'BOM_DEPARTMENT_RESOURCES');
1855 
1856     IF (req_id = 0) THEN
1857       raise conc_failure;
1858     END IF;
1859 
1860     COMMIT;
1861 
1862     errbuf := 'Created flexfields - submitted requests to recompile flexfields';
1863     retcode := 0; -- success
1864 
1865   EXCEPTION
1866      WHEN conc_failure THEN
1867         errbuf := 'Error ' ||
1868                   substr(fnd_message.get,1,240);
1869         retcode := 2;
1870 
1871      WHEN OTHERS THEN
1872         rollback;
1873     if (fnd_flex_dsc_api.message is null) then
1874       errbuf := 'Sql Error:' || to_char(sqlcode);
1875     else
1876       errbuf := fnd_flex_dsc_api.message;
1877     end if;
1878     retcode := 2; -- failure
1879 
1880 END Configure_reba_flex;
1881 
1882 PROCEDURE Configure_fcst_flex(
1883         ERRBUF          OUT NOCOPY VARCHAR2,
1884         RETCODE         OUT NOCOPY NUMBER,
1885         fcst_attr1 IN NUMBER)
1886  AS
1887         req_id          NUMBER;
1888         conc_failure    EXCEPTION;
1889 
1890         msgbuf          VARCHAR2(2000);
1891 
1892  BEGIN
1893 
1894    fnd_flex_dsc_api.debug_on;
1895    fnd_flex_dsc_api.set_session_mode('seed_data');
1896 
1897    fnd_flex_dsc_api.enable_context('MRP',
1898                          'MRP_FORECAST_DATES',
1899                          'Global Data Elements',
1900                          TRUE);
1901 
1902    IF fnd_flex_dsc_api.is_column_used(
1903                 p_application_id => '704',
1904                 p_table_name => 'MRP_FORECAST_DATES',
1905                 p_column_name => 'ATTRIBUTE'||to_char(fcst_attr1),
1906                 x_message => msgbuf) = TRUE THEN
1907 
1908         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
1909         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(fcst_attr1));
1910         FND_MESSAGE.set_token('TABLE','MRP_FORECAST_DATES');
1911         msgbuf := FND_MESSAGE.get;
1912         LOG_MESSAGE(msgbuf);
1913 
1914    ELSIF fnd_flex_dsc_api.segment_exists(
1915         p_appl_short_name=>'MRP',
1916         p_flexfield_name=>'MRP_FORECAST_DATES',
1917         p_context_code=>'Global Data Elements',
1918         p_segment_name=>'Forecast Priority') = TRUE THEN
1919 
1923         msgbuf := FND_MESSAGE.get;
1920         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
1921         FND_MESSAGE.set_token('SEGMENT','Forecast Priority');
1922         FND_MESSAGE.set_token('TABLE','MRP_FORECAST_DATES');
1924         LOG_MESSAGE(msgbuf);
1925 
1926     ELSE
1927         fnd_flex_dsc_api.create_segment(
1928         appl_short_name => 'MRP',
1929         flexfield_name => 'MRP_FORECAST_DATES',
1930         context_name => 'Global Data Elements',
1931         name => 'Forecast Priority',
1932         column => 'ATTRIBUTE'|| to_char(fcst_attr1),
1933         description => 'Forecast Priority',
1934         sequence_number => 20,
1935         enabled => 'Y',
1936         displayed => 'Y',
1937         value_set => 'FND_NUMBER',
1938         default_type => NULL,
1939         default_value => NULL,
1940         required => 'N',
1941         security_enabled => 'N',
1942         display_size => 25,
1943         description_size => 50,
1944         concatenated_description_size => 50,
1945         list_of_values_prompt => 'Forecast Priority',
1946         window_prompt => 'Forecast Priority',
1947         range => NULL,
1948         srw_parameter => NULL);
1949 
1950     update fnd_profile_option_values
1951     set profile_option_value = to_char(fcst_attr1)
1952     where application_id = 724
1953     and level_id = 10001
1954     and profile_option_id = (select profile_option_id
1955                 from fnd_profile_options
1956                 where application_id = 724
1957                 and  profile_option_name = 'MSC_FCST_PRIORITY_FLEX_NUM');
1958 
1959     END IF;
1960     COMMIT;
1961 
1962   req_id := fnd_request.submit_request(
1963                 'FND', 'FDFVGN', '', '', FALSE,
1964                 '3', 704,
1965                 'MRP_FORECAST_DATES');
1966     IF (req_id = 0) THEN
1967       raise conc_failure;
1968     END IF;
1969 
1970     COMMIT;
1971 
1972     errbuf := 'Created flexfields - submitted requests to recompile flexfields';
1973     retcode := 0; -- success
1974 
1975   EXCEPTION
1976    WHEN conc_failure THEN
1977      errbuf := 'Error ' ||
1978                   substr(fnd_message.get,1,240);
1979      retcode := 2;
1980    WHEN OTHERS THEN
1981    rollback;
1982     if (fnd_flex_dsc_api.message is null) then
1983       errbuf := 'Sql Error:' || to_char(sqlcode);
1984     else
1985       errbuf := fnd_flex_dsc_api.message;
1986     end if;
1987     retcode := 2; -- failure
1988 
1989  END Configure_fcst_flex;
1990 
1991 PROCEDURE Configure_regions_flex(
1992 	ERRBUF      	OUT NOCOPY VARCHAR2,
1993 	RETCODE     	OUT NOCOPY NUMBER,
1994 	oper_attr1      IN  NUMBER)
1995 AS
1996 
1997 	req_id 		NUMBER;
1998 	conc_failure 	EXCEPTION;
1999 
2000 	msgbuf		VARCHAR2(2000);
2001 
2002 BEGIN
2003 
2004    fnd_flex_dsc_api.debug_on;
2005    fnd_flex_dsc_api.set_session_mode('seed_data');
2006 
2007    fnd_flex_dsc_api.enable_context('WSH',
2008                          'WSH_REGIONS',
2009                          'ZONES_DFF',
2010                          TRUE);
2011 
2012     IF
2013        fnd_flex_dsc_api.is_column_used(
2014                         p_application_id => '665',
2015                         p_table_name => 'WSH_REGIONS',
2016                         p_column_name => 'ATTRIBUTE'||to_char(oper_attr1),
2017                         x_message => msgbuf) = TRUE THEN
2018 
2019         FND_MESSAGE.set_name('MSC','MSC_ATTRIBUTE_EXISTS');
2020         FND_MESSAGE.set_token('ATTRIBUTE','ATTRIBUTE'||to_char(oper_attr1));
2021         FND_MESSAGE.set_token('TABLE','WSH_REGIONS');
2022         msgbuf := FND_MESSAGE.get;
2023         LOG_MESSAGE(msgbuf);
2024     ELSIF
2025        fnd_flex_dsc_api.segment_exists(
2026 	p_appl_short_name=>'WSH',
2027 	p_flexfield_name=>'WSH_REGIONS',
2028 	p_context_code=>'ZONES_DFF',
2029 	p_segment_name=>'Zone Usage') = TRUE THEN
2030         FND_MESSAGE.set_name('MSC','MSC_SEGMENT_EXISTS');
2031         FND_MESSAGE.set_token('SEGMENT','Zone Usage');
2032         FND_MESSAGE.set_token('TABLE','WSH_REGIONS');
2033         msgbuf := FND_MESSAGE.get;
2034         LOG_MESSAGE(msgbuf);
2035     ELSE
2036         fnd_flex_dsc_api.create_segment(
2037         appl_short_name => 'WSH',
2038         flexfield_name => 'WSH_REGIONS',
2039         context_name => 'ZONES_DFF',
2040         name => 'Zone Usage',
2041         column => 'ATTRIBUTE'|| to_char(oper_attr1),
2042         description => 'Zone Usage for Global Forecasting',
2043         sequence_number => 10,
2044         enabled => 'Y',
2045         displayed => 'Y',
2046         value_set => 'MSC_DP_ZONE_USAGE_SET',
2047         default_type => NULL,
2048         default_value => NULL,
2049         required => 'N',
2050         security_enabled => 'N',
2051         display_size => 25,
2052         description_size => 50,
2053         concatenated_description_size => 50,
2054         list_of_values_prompt => 'Zone Usage',
2055         window_prompt => 'Zone Usage',
2056         range => NULL,
2057         srw_parameter => NULL);
2058      END IF;
2059 
2060 
2061    COMMIT;
2062 
2063     req_id := fnd_request.submit_request(
2064                 'FND', 'FDFVGN', '', '', FALSE,
2065                 '3', 665,
2066                 'WSH_REGIONS');
2067 
2068     IF (req_id = 0) THEN
2069       raise conc_failure;
2070     END IF;
2071 
2072     COMMIT;
2073     errbuf := 'Created flexfields - submitted requests to recompile flexfields';
2074     retcode := 0; -- success
2075 
2076 EXCEPTION
2077 
2078    WHEN conc_failure THEN
2079      errbuf := 'Error ' ||
2080                   substr(fnd_message.get,1,240);
2081      retcode := 2;
2085     if (fnd_flex_dsc_api.message is null) then
2082 
2083    WHEN OTHERS THEN
2084    rollback;
2086       errbuf := 'Sql Error:' || to_char(sqlcode);
2087     else
2088       errbuf := fnd_flex_dsc_api.message;
2089     end if;
2090     retcode := 2; -- failure
2091 
2092 END Configure_regions_flex;
2093 
2094 END MSC_CONFIG_FF;