DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_RBS_PREC_PUB

Source


1 PACKAGE BODY PA_RBS_PREC_PUB AS
2 /* $Header: PARBSPRB.pls 120.0 2005/05/29 14:46:24 appldev noship $ */
3 
4 ---------------------------------------------------
5 --calculate resource class precedence for each rule
6 ---------------------------------------------------
7 FUNCTION	calc_rc_precedence
8 		(
9 		resource_type_id	number,
10 		res_class_id		number
11 		)
12 		RETURN NUMBER
13 IS
14 TYPE res_type_rec IS RECORD
15 (res_type_id	number,
16 per_rc_prec	number,
17 equip_rc_prec	number,
18 mat_rc_prec	number,
19 fin_rc_prec	number);
20 TYPE res_type_rec_tab IS TABLE OF res_type_rec INDEX BY BINARY_INTEGER;
21 
22 res_type_rec_t	res_type_rec_tab;
23 
24 BEGIN
25 
26 --below precedence values for 16 resource types are taken from RBS FD
27 
28 res_type_rec_t(1).res_type_id := 1;
29 res_type_rec_t(1).per_rc_prec := 2;
30 res_type_rec_t(1).equip_rc_prec := 2;
31 res_type_rec_t(1).mat_rc_prec := 2;
32 res_type_rec_t(1).fin_rc_prec := 2;
33 
34 res_type_rec_t(2).res_type_id := 2;
35 res_type_rec_t(2).per_rc_prec := 4;
36 res_type_rec_t(2).equip_rc_prec := 4;
37 res_type_rec_t(2).mat_rc_prec := 4;
38 res_type_rec_t(2).fin_rc_prec := 4;
39 
40 res_type_rec_t(3).res_type_id := 3;
41 res_type_rec_t(3).per_rc_prec := 1;
42 res_type_rec_t(3).equip_rc_prec := 1;
43 res_type_rec_t(3).mat_rc_prec := 1;
44 res_type_rec_t(3).fin_rc_prec := 1;
45 
46 res_type_rec_t(4).res_type_id := 4;
47 res_type_rec_t(4).per_rc_prec := 10;
48 res_type_rec_t(4).equip_rc_prec := 10;
49 res_type_rec_t(4).mat_rc_prec := 10;
50 res_type_rec_t(4).fin_rc_prec := 10;
51 
52 res_type_rec_t(5).res_type_id := 5;
53 res_type_rec_t(5).per_rc_prec := 11;
54 res_type_rec_t(5).equip_rc_prec := 11;
55 res_type_rec_t(5).mat_rc_prec := 11;
56 res_type_rec_t(5).fin_rc_prec := 11;
57 
58 res_type_rec_t(6).res_type_id := 6;
59 res_type_rec_t(6).per_rc_prec := 9;
60 res_type_rec_t(6).equip_rc_prec := 9;
61 res_type_rec_t(6).mat_rc_prec := 9;
62 res_type_rec_t(6).fin_rc_prec := 9;
63 
64 res_type_rec_t(7).res_type_id := 7;
65 res_type_rec_t(7).per_rc_prec := 8;
66 res_type_rec_t(7).equip_rc_prec := 8;
67 res_type_rec_t(7).mat_rc_prec := 8;
68 res_type_rec_t(7).fin_rc_prec := 8;
69 
70 res_type_rec_t(8).res_type_id := 8;
71 res_type_rec_t(8).per_rc_prec := 5;
72 res_type_rec_t(8).equip_rc_prec := 5;
73 res_type_rec_t(8).mat_rc_prec := 5;
74 res_type_rec_t(8).fin_rc_prec := 5;
75 
76 res_type_rec_t(9).res_type_id := 9;
77 res_type_rec_t(9).per_rc_prec := 6;
78 res_type_rec_t(9).equip_rc_prec := 6;
79 res_type_rec_t(9).mat_rc_prec := 6;
80 res_type_rec_t(9).fin_rc_prec := 6;
81 
82 res_type_rec_t(10).res_type_id := 10;
83 res_type_rec_t(10).per_rc_prec := 13;
84 res_type_rec_t(10).equip_rc_prec := 13;
85 res_type_rec_t(10).mat_rc_prec := 15;
86 res_type_rec_t(10).fin_rc_prec := 15;
87 
88 res_type_rec_t(11).res_type_id := 11;
89 res_type_rec_t(11).per_rc_prec := 14;
90 res_type_rec_t(11).equip_rc_prec := 14;
91 res_type_rec_t(11).mat_rc_prec := 14;
92 res_type_rec_t(11).fin_rc_prec := 14;
93 
94 res_type_rec_t(12).res_type_id := 12;
95 res_type_rec_t(12).per_rc_prec := 3;
96 res_type_rec_t(12).equip_rc_prec := 3;
97 res_type_rec_t(12).mat_rc_prec := 3;
98 res_type_rec_t(12).fin_rc_prec := 3;
99 
100 res_type_rec_t(13).res_type_id := 13;
101 res_type_rec_t(13).per_rc_prec := 16;
102 res_type_rec_t(13).equip_rc_prec := 16;
103 res_type_rec_t(13).mat_rc_prec := 16;
104 res_type_rec_t(13).fin_rc_prec := 16;
105 
106 res_type_rec_t(14).res_type_id := 14;
107 res_type_rec_t(14).per_rc_prec := 12;
108 res_type_rec_t(14).equip_rc_prec := 12;
109 res_type_rec_t(14).mat_rc_prec := 12;
110 res_type_rec_t(14).fin_rc_prec := 12;
111 
112 res_type_rec_t(15).res_type_id := 15;
113 res_type_rec_t(15).per_rc_prec := 7;
114 res_type_rec_t(15).equip_rc_prec := 7;
115 res_type_rec_t(15).mat_rc_prec := 7;
116 res_type_rec_t(15).fin_rc_prec := 7;
117 
118 res_type_rec_t(16).res_type_id := 16;
119 res_type_rec_t(16).per_rc_prec := 15;
120 res_type_rec_t(16).equip_rc_prec := 15;
121 res_type_rec_t(16).mat_rc_prec := 13;
122 res_type_rec_t(16).fin_rc_prec := 13;
123 
124 
125 FOR i IN 1..16 LOOP
126 	IF res_type_rec_t(i).res_type_id = resource_type_id THEN
127 		IF res_class_id = 1 THEN
128 			RETURN res_type_rec_t(i).per_rc_prec;
129 		ELSIF res_class_id = 2 THEN
130 			RETURN res_type_rec_t(i).equip_rc_prec;
131 		ELSIF res_class_id = 3 THEN
132 			RETURN res_type_rec_t(i).mat_rc_prec;
133 		ELSIF res_class_id = 4 THEN
134 			RETURN res_type_rec_t(i).fin_rc_prec;
135 		END IF;
136 	END IF;
137 END LOOP;
138 
139 -- added for custom nodes
140 	IF resource_type_id = 18 THEN
141 		IF res_class_id = 1 THEN
142 			RETURN 20;  --bug#3908476
143 		ELSIF res_class_id = 2 THEN
144 			RETURN 20;  --bug#3908476
145 		ELSIF res_class_id = 3 THEN
146 			RETURN 20;  --bug#3908476
147 		ELSIF res_class_id = 4 THEN
148 			RETURN 20;  --bug#3908476
149 		END IF;
150 	END IF;
151 
152 END;
153 
154 FUNCTION	calc_rule_precedence
155 		(
156 		rule_type_id	varchar,
157 		res_class_id		number
158 		)
159 		RETURN NUMBER
160 IS
161 TYPE res_type_rec IS RECORD
162 (rule_type      varchar(150),
163 per_rc_prec	number,
164 equip_rc_prec	number,
165 mat_rc_prec	number,
166 fin_rc_prec	number);
167 TYPE res_type_rec_tab IS TABLE OF res_type_rec INDEX BY BINARY_INTEGER;
168 
169 res_type_rec_t	res_type_rec_tab;
170 
171 BEGIN
172 
173 --below precedence values for 16 resource types are taken from RBS FD
174 
175 res_type_rec_t(1).rule_type :='BML';
176 res_type_rec_t(1).per_rc_prec := 2;
177 res_type_rec_t(1).equip_rc_prec := 2;
178 res_type_rec_t(1).mat_rc_prec := 2;
179 res_type_rec_t(1).fin_rc_prec := 2;
180 
181 res_type_rec_t(2).rule_type := 'BME';
182 res_type_rec_t(2).per_rc_prec := 4;
183 res_type_rec_t(2).equip_rc_prec := 4;
184 res_type_rec_t(2).mat_rc_prec := 4;
185 res_type_rec_t(2).fin_rc_prec := 4;
186 
187 res_type_rec_t(3).rule_type := 'PER';
188 res_type_rec_t(3).per_rc_prec := 1;
189 res_type_rec_t(3).equip_rc_prec := 1;
190 res_type_rec_t(3).mat_rc_prec := 1;
191 res_type_rec_t(3).fin_rc_prec := 1;
192 
193 res_type_rec_t(4).rule_type := 'EVT';
194 res_type_rec_t(4).per_rc_prec := 10;
195 res_type_rec_t(4).equip_rc_prec := 10;
196 res_type_rec_t(4).mat_rc_prec := 10;
197 res_type_rec_t(4).fin_rc_prec := 10;
198 
199 res_type_rec_t(5).rule_type := 'EXC';
200 res_type_rec_t(5).per_rc_prec := 11;
201 res_type_rec_t(5).equip_rc_prec := 11;
202 res_type_rec_t(5).mat_rc_prec := 11;
203 res_type_rec_t(5).fin_rc_prec := 11;
204 
205 res_type_rec_t(6).rule_type := 'EXT';
206 res_type_rec_t(6).per_rc_prec := 9;
207 res_type_rec_t(6).equip_rc_prec := 9;
208 res_type_rec_t(6).mat_rc_prec := 9;
209 res_type_rec_t(6).fin_rc_prec := 9;
210 
211 res_type_rec_t(7).rule_type := 'ITC';
212 res_type_rec_t(7).per_rc_prec := 8;
213 res_type_rec_t(7).equip_rc_prec := 8;
214 res_type_rec_t(7).mat_rc_prec := 8;
215 res_type_rec_t(7).fin_rc_prec := 8;
216 
217 res_type_rec_t(8).rule_type := 'ITM';
218 res_type_rec_t(8).per_rc_prec := 5;
219 res_type_rec_t(8).equip_rc_prec := 5;
220 res_type_rec_t(8).mat_rc_prec := 5;
221 res_type_rec_t(8).fin_rc_prec := 5;
222 
223 res_type_rec_t(9).rule_type := 'JOB';
224 res_type_rec_t(9).per_rc_prec := 6;
225 res_type_rec_t(9).equip_rc_prec := 6;
226 res_type_rec_t(9).mat_rc_prec := 6;
227 res_type_rec_t(9).fin_rc_prec := 6;
228 
229 res_type_rec_t(10).rule_type := 'ORG';
230 res_type_rec_t(10).per_rc_prec := 13;
231 res_type_rec_t(10).equip_rc_prec := 13;
232 res_type_rec_t(10).mat_rc_prec := 15;
233 res_type_rec_t(10).fin_rc_prec := 15;
234 
235 res_type_rec_t(11).rule_type := 'PTP';
236 res_type_rec_t(11).per_rc_prec := 14;
237 res_type_rec_t(11).equip_rc_prec := 14;
238 res_type_rec_t(11).mat_rc_prec := 14;
239 res_type_rec_t(11).fin_rc_prec := 14;
240 
241 res_type_rec_t(12).rule_type := 'NLR';
242 res_type_rec_t(12).per_rc_prec := 3;
243 res_type_rec_t(12).equip_rc_prec := 3;
244 res_type_rec_t(12).mat_rc_prec := 3;
245 res_type_rec_t(12).fin_rc_prec := 3;
246 
247 res_type_rec_t(13).rule_type := 'RES';
248 res_type_rec_t(13).per_rc_prec := 16;
249 res_type_rec_t(13).equip_rc_prec := 16;
250 res_type_rec_t(13).mat_rc_prec := 16;
251 res_type_rec_t(13).fin_rc_prec := 16;
252 
253 res_type_rec_t(14).rule_type := 'RVC';
254 res_type_rec_t(14).per_rc_prec := 12;
255 res_type_rec_t(14).equip_rc_prec := 12;
256 res_type_rec_t(14).mat_rc_prec := 12;
257 res_type_rec_t(14).fin_rc_prec := 12;
258 
259 res_type_rec_t(15).rule_type := 'ROL';
260 res_type_rec_t(15).per_rc_prec := 7;
261 res_type_rec_t(15).equip_rc_prec := 7;
262 res_type_rec_t(15).mat_rc_prec := 7;
263 res_type_rec_t(15).fin_rc_prec := 7;
264 
265 res_type_rec_t(16).rule_type :='SUP';
266 res_type_rec_t(16).per_rc_prec := 15;
267 res_type_rec_t(16).equip_rc_prec := 15;
268 res_type_rec_t(16).mat_rc_prec := 13;
269 res_type_rec_t(16).fin_rc_prec := 13;
270 
271 
272 FOR i IN 1..16 LOOP
273 	IF res_type_rec_t(i).rule_type = rule_type_id THEN
274 		IF res_class_id = 1 THEN
275 			RETURN res_type_rec_t(i).per_rc_prec;
276 		ELSIF res_class_id = 2 THEN
277 			RETURN res_type_rec_t(i).equip_rc_prec;
278 		ELSIF res_class_id = 3 THEN
279 			RETURN res_type_rec_t(i).mat_rc_prec;
280 		ELSIF res_class_id = 4 THEN
281 			RETURN res_type_rec_t(i).fin_rc_prec;
282 		END IF;
283 	END IF;
284 END LOOP;
285 
286 -- added for custom nodes
287 	IF rule_type_id in ('CU1','CU2','CU3','CU4','CU5') THEN
288 		IF res_class_id = 1 THEN
289 			RETURN 20;  --bug#3908476
290 		ELSIF res_class_id = 2 THEN
291 			RETURN 20;  --bug#3908476
292 		ELSIF res_class_id = 3 THEN
293 			RETURN 20;  --bug#3908476
294 		ELSIF res_class_id = 4 THEN
295 			RETURN 20;  --bug#3908476
296 		END IF;
297 	END IF;
298 
299 END;
300 
301 END; --end package PA_RBS_PREC_PUB