[Home] [Help]
PACKAGE BODY: APPS.BSC_KPI_PVT
Source
1 package body BSC_KPI_PVT as
2 /* $Header: BSCVKPPB.pls 120.7 2007/03/20 06:38:30 vtulasi ship $ */
3 /*
4 +======================================================================================+
5 | Copyright (c) 2001 Oracle Corporation, Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +======================================================================================+
8 | FILENAME |
9 | BSCVKPPB.pls |
10 | |
11 | Creation Date: |
12 | October 22, 2001 |
13 | |
14 | Creator: |
15 | Mario-Jair Campos |
16 | |
17 | Description: |
18 | Private Body version. |
19 | This package Creates, Retrieve, Update, Delete |
20 | for BSC KPI information. |
21 | |
22 | History: |
23 | |
24 | 04-MAR-2003 PAJOHRI MLS Bug #2721899 |
25 | 1. Modified Update Query for BSC_KPIS_TL, BSC_KPI_DEFAULTS_TL|
26 | 2. Modified Insert Query for BSC_KPI_DEFAULTS_TL. |
27 | 3. Changed nvl(<record_name>.Bsc_Language, userenv('LANG')) |
28 | to userenv('LANG') |
29 | 20-MAR-03 PWALI for bug #2843082 |
30 | 13-MAY-2003 PWALI Bug #2942895, SQL BIND COMPLIANCE |
31 | 24-JUL-2003 Adeulgao fixed bug#3047536 |
32 | Granted access of KPIS to BSC_PMD_USER |
33 | 14-NOV-2003 ADRAO Modified for Bug #3248729, |
34 | 02-MAR-2004 WLEUNG Modified for Bug #3476004 |
35 | new procedure Set_Default_Value_By_Option_ID |
36 | 06-MAR-2004 kyadamak for the bug#3439029 |
37 | 11-MAR-2004 PAJOHRI Bug #3500012 |
38 | 30-MAR-2003 PAJOHRI Bug #3539639, modified closing of cursor c_old_option_id |
39 | 18-MAY-04 adrao Modified PL/SQL records and CRUD to accept SHORT_NAME |
40 | 18-JUN-04 adrao added BSC_KPI_ANALYSIS_GROUP.SHORT_NAME to PL/SQL APIs |
41 | Bug#3691035 |
42 | 21-JUL-04 adrao made short_name nonunique. prototype_flag =2 Bug#3781764 |
43 | 11-APR-05 adrao fixed API Create_Kpi_Analysis to pass appropriate name |
44 | for Bug#4294920 |
45 | 27-APR-05 adrao Fixed Bug#4331964 |
46 | 21-JUL-2005 ashankar Bug#4314386 |
47 | 16-NOV-2006 ankgoel Color By KPI enh#5244136 |
48 | 16-NOV-2006 vtulasi Color By KPI enh#5244136 |
49 | 09-feb-2007 ashankar Simulation Tree Enhacement 5386112 |
50 +======================================================================================+
51 */
52 G_PKG_NAME CONSTANT varchar2(30) := 'BSC_KPI_PVT';
53
54 procedure Create_Kpi(
55 p_commit IN varchar2 := FND_API.G_FALSE
56 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
57 ,x_return_status OUT NOCOPY varchar2
58 ,x_msg_count OUT NOCOPY number
59 ,x_msg_data OUT NOCOPY varchar2
60 ) is
61
62 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
63
64 l_db_object VARCHAR2(30);
65 l_count NUMBER;
66 l_No_Ind NUMBER;
67
68 begin
69 FND_MSG_PUB.Initialize;
70 x_return_status := FND_API.G_RET_STS_SUCCESS;
71 SAVEPOINT BscKpiPvt_CrtKPI;
72 --DBMS_OUTPUT.PUT_LINE(' -- Begin Create_Kpi ');
73
74 -- Assign all values in the passed "Record" parameter to the locally defined
75 -- "Record" variable.
76 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
77
78
79 -- Check that KPI Id does not exist yet.
80 IF l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL THEN
81
82 SELECT COUNT(1) INTO l_Count
83 FROM BSC_KPIS_B
84 WHERE INDICATOR = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
85
86 IF l_count <> 0 THEN
87 FND_MESSAGE.SET_NAME('BSC','BSC_KPI_ID_EXISTS');
88 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
89 FND_MSG_PUB.ADD;
90 RAISE FND_API.G_EXC_ERROR;
91 END IF;
92 ELSE
93 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
94 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
95 FND_MSG_PUB.ADD;
96 RAISE FND_API.G_EXC_ERROR;
97 END IF;
98
99
100 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi - Flag 1');
101
102 -- Check that a valid KPI group id has been entered.
103
104
105 -- Fixed for Bug#3781764 added PROTOTYPE_FLAG
106 IF l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name IS NOT NULL THEN
107 SELECT COUNT(1) INTO l_Count
108 FROM BSC_KPIS_B
109 WHERE SHORT_NAME = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name
110 AND PROTOTYPE_FLAG <> BSC_KPI_PUB.DELETE_KPI_FLAG;
111
112 IF l_Count <> 0 THEN
113 FND_MESSAGE.SET_NAME('BSC','BSC_UNIQUE_NAME_REQUIRED');
114 FND_MESSAGE.SET_TOKEN('SHORT_NAME', BSC_APPS.GET_LOOKUP_VALUE('BSC_UI_BUILDER', 'MEASURE_SHORT_NAME'));
115 FND_MESSAGE.SET_TOKEN('NAME_VALUE', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name );
116 FND_MSG_PUB.ADD;
117 RAISE FND_API.G_EXC_ERROR;
118 END IF;
119 END IF;
120
121
122 -- If display order value for KPI is null assign next value within Kpi group.
123 -- if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order is null then
124 select count(1) + 1
125 into l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order
126 from BSC_KPIS_B
127 where ind_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id;
128 -- end if;
129
130 -- Set some null values to defaults, such as dates.
131 if l_Bsc_Kpi_Entity_Rec.Creation_Date is null then
132 l_Bsc_Kpi_Entity_Rec.Creation_Date := sysdate;
133 end if;
134
135 if l_Bsc_Kpi_Entity_Rec.Last_Update_Date is null then
136 l_Bsc_Kpi_Entity_Rec.Last_Update_Date := sysdate;
137 end if;
138
139 l_db_object := 'BSC_KPIS_B';
140 l_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type := BSC_COLOR_CALC_UTIL.DEFAULT_KPI;
141 l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id := BSC_COLOR_REPOSITORY.EXCELLENT_COLOR;
142 l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id := 0;
143 l_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method := 1;
144
145 insert into BSC_KPIS_B( INDICATOR
146 ,CSF_ID
147 ,IND_GROUP_ID
148 ,DISP_ORDER
149 ,PROTOTYPE_FLAG
150 ,INDICATOR_TYPE
151 ,CONFIG_TYPE
152 ,PERIODICITY_ID
153 ,BM_GROUP_ID
154 ,APPLY_COLOR_FLAG
155 ,PROTOTYPE_COLOR
156 ,SHARE_FLAG
157 ,SOURCE_INDICATOR
158 ,PUBLISH_FLAG
159 ,CREATED_BY
160 ,CREATION_DATE
161 ,LAST_UPDATED_BY
162 ,LAST_UPDATE_DATE
163 ,LAST_UPDATE_LOGIN
164 ,EDW_FLAG
165 ,CALENDAR_ID
166 ,SHORT_NAME
167 ,COLOR_ROLLUP_TYPE
168 ,PROTOTYPE_COLOR_ID
169 ,PROTOTYPE_TREND_ID
170 ,WEIGHTED_COLOR_METHOD)
171 values( l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
172 ,l_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id
173 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id
174 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order
175 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag
176 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type
177 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type
178 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id
179 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id
180 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag
181 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color
182 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag
183 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind
184 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag
185 ,l_Bsc_Kpi_Entity_Rec.Created_By
186 ,sysdate
187 ,l_Bsc_Kpi_Entity_Rec.Last_Updated_By
188 ,sysdate
189 ,l_Bsc_Kpi_Entity_Rec.Last_Update_Login
190 ,l_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag
191 ,l_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id
192 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name
193 ,l_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type
194 ,l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id
195 ,l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id
196 ,l_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method);
197
198 l_db_object := 'BSC_KPIS_TL';
199
200 -- Fixed bug 2635468 ISSUE FIFTH
201 insert into BSC_KPIS_TL (
202 INDICATOR,
203 LANGUAGE,
204 SOURCE_LANG,
205 NAME,
206 HELP
207 ) select
208 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id,
209 L.LANGUAGE_CODE,
210 userenv('LANG'),
211 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name,
212 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help
213 from FND_LANGUAGES L
214 where L.INSTALLED_FLAG in ('I', 'B')
215 and not exists
216 (select NULL
217 from BSC_KPIS_TL T
218 where T.INDICATOR = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
219 and T.LANGUAGE = L.LANGUAGE_CODE);
220
221 if (p_commit = FND_API.G_TRUE) then
222 commit;
223 end if;
224
225 select count(indicator)
226 into l_count
227 from bsc_kpis_b
228 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id ;
229
230
231 EXCEPTION
232 WHEN FND_API.G_EXC_ERROR THEN
233 ROLLBACK TO BscKpiPvt_CrtKPI;
234 FND_MSG_PUB.Count_And_Get
235 ( p_encoded => FND_API.G_FALSE
236 , p_count => x_msg_count
237 , p_data => x_msg_data
238 );
239 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
240 x_return_status := FND_API.G_RET_STS_ERROR;
241
242 RAISE;
243 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
244 ROLLBACK TO BscKpiPvt_CrtKPI;
245 FND_MSG_PUB.Count_And_Get
246 ( p_encoded => FND_API.G_FALSE
247 , p_count => x_msg_count
248 , p_data => x_msg_data
249 );
250 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
251 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
252 RAISE;
253 WHEN NO_DATA_FOUND THEN
254 ROLLBACK TO BscKpiPvt_CrtKPI;
255 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
256 IF (x_msg_data IS NOT NULL) THEN
257 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi ';
258 ELSE
259 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi ';
260 END IF;
261 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
262 RAISE;
263 WHEN OTHERS THEN
264 ROLLBACK TO BscKpiPvt_CrtKPI;
265 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
266 if (SQLCODE = -01400) then
267 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
268 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
269 FND_MSG_PUB.ADD;
270 RAISE FND_API.G_EXC_ERROR;
271 end if;
272 IF (x_msg_data IS NOT NULL) THEN
273 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi ';
274 ELSE
275 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi ';
276 END IF;
277 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
278 RAISE;
279 end Create_Kpi;
280
281 /************************************************************************************
282 ************************************************************************************/
283
284
285 procedure Retrieve_Kpi(
286 p_commit IN varchar2 := FND_API.G_FALSE
287 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
288 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
289 ,x_return_status OUT NOCOPY varchar2
290 ,x_msg_count OUT NOCOPY number
291 ,x_msg_data OUT NOCOPY varchar2
292 ) is
293
294 l_db_object varchar2(30);
295
296 l_count number;
297
298 begin
299 FND_MSG_PUB.Initialize;
300 x_return_status := FND_API.G_RET_STS_SUCCESS;
301 l_db_object := 'Retrieve_Kpi';
302
303 SELECT DISTINCT A.CSF_ID
304 ,A.IND_GROUP_ID
305 ,A.DISP_ORDER
306 ,A.PROTOTYPE_FLAG
307 ,A.INDICATOR_TYPE
308 ,A.CONFIG_TYPE
309 ,A.PERIODICITY_ID
310 ,A.BM_GROUP_ID
311 ,A.APPLY_COLOR_FLAG
312 ,A.PROTOTYPE_COLOR
313 ,A.SHARE_FLAG
314 ,A.SOURCE_INDICATOR
315 ,A.PUBLISH_FLAG
316 ,A.CREATED_BY
317 ,A.CREATION_DATE
318 ,A.LAST_UPDATED_BY
319 ,A.LAST_UPDATE_DATE
320 ,A.LAST_UPDATE_LOGIN
321 ,A.EDW_FLAG
322 ,A.CALENDAR_ID
323 ,A.SHORT_NAME
324 ,A.COLOR_ROLLUP_TYPE
325 ,A.PROTOTYPE_COLOR_ID
326 ,A.PROTOTYPE_TREND_ID
327 ,A.WEIGHTED_COLOR_METHOD
328 ,B.NAME
329 ,B.HELP
330 ,B.SOURCE_LANG
331 INTO x_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id
332 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id
333 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order
334 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag
335 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type
336 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type
337 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id
338 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id
339 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag
340 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color
341 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag
342 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind
343 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag
344 ,x_Bsc_Kpi_Entity_Rec.Created_By
345 ,x_Bsc_Kpi_Entity_Rec.Creation_Date
346 ,x_Bsc_Kpi_Entity_Rec.Last_Updated_By
347 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Date
348 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Login
349 ,x_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag
350 ,x_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id
351 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name
352 ,x_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type
353 ,x_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id
354 ,x_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id
355 ,x_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method
356 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name
357 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help
358 ,x_Bsc_Kpi_Entity_Rec.Bsc_Source_Language
359 FROM BSC_KPIS_B A
360 ,BSC_KPIS_TL B
361 WHERE A.INDICATOR = B.INDICATOR
362 AND A.INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
363 AND B.LANGUAGE = USERENV('LANG');
364 -- Fixed Third issue in bug 2635468
365
366 IF (p_commit = FND_API.G_TRUE) THEN
367 COMMIT;
368 END IF;
369
370 EXCEPTION
371 WHEN FND_API.G_EXC_ERROR THEN
372 FND_MSG_PUB.Count_And_Get
373 ( p_encoded => FND_API.G_FALSE
374 , p_count => x_msg_count
375 , p_data => x_msg_data
376 );
377 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
378 x_return_status := FND_API.G_RET_STS_ERROR;
379 RAISE;
380 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
381 FND_MSG_PUB.Count_And_Get
382 ( p_encoded => FND_API.G_FALSE
383 , p_count => x_msg_count
384 , p_data => x_msg_data
385 );
386 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
387 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
388 RAISE;
389 WHEN NO_DATA_FOUND THEN
390 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
391 FND_MSG_PUB.Initialize;
392 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
393 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
394 FND_MSG_PUB.ADD;
395 RAISE FND_API.G_EXC_ERROR;
396 WHEN OTHERS THEN
397 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
398 IF (x_msg_data IS NOT NULL) THEN
399 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi ';
400 ELSE
401 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi ';
402 END IF;
403 RAISE;
404 end Retrieve_Kpi;
405
406 /************************************************************************************
407 ************************************************************************************/
408
409 procedure Update_Kpi(
410 p_commit IN varchar2 := FND_API.G_FALSE
411 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
412 ,x_return_status OUT NOCOPY varchar2
413 ,x_msg_count OUT NOCOPY number
414 ,x_msg_data OUT NOCOPY varchar2
415 ) is
416
417 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
418
419 l_count number;
420
421 begin
422 FND_MSG_PUB.Initialize;
423 x_return_status := FND_API.G_RET_STS_SUCCESS;
424 SAVEPOINT BscKpiPvt_UptKPI;
425 -- Check that valid id was entered.
426 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
427 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
428 ,'indicator'
429 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
430 if l_count = 0 then
431 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
432 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
433 FND_MSG_PUB.ADD;
434 RAISE FND_API.G_EXC_ERROR;
435 end if;
436 else
437 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
438 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
439 FND_MSG_PUB.ADD;
440 RAISE FND_API.G_EXC_ERROR;
441 end if;
442
443
444 -- Not all values will be passed. We need to make sure values not passed are not
445 -- changed by procedure, therefore we get what is there before we do any updates.
446 Retrieve_Kpi( p_commit
447 ,p_Bsc_Kpi_Entity_Rec
448 ,l_Bsc_Kpi_Entity_Rec
449 ,x_return_status
450 ,x_msg_count
451 ,x_msg_data);
452
453 -- update LOCAL language ,source language and KPI Id values with PASSED values.
454 l_Bsc_Kpi_Entity_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
455 l_Bsc_Kpi_Entity_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
456 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
457
458 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
459 -- which are NOT NULL.
460 if p_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id is not null then
461 l_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id;
462 end if;
463 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id is not null then
464 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id;
465 end if;
466 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order is not null then
467 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order;
468 end if;
469 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag is not null then
470 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag;
471 end if;
472 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type is not null then
473 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type;
474 end if;
475 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type is not null then
476 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type;
477 end if;
478 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id is not null then
479 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
480 end if;
481 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id is not null then
482 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id;
483 end if;
484 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag is not null then
485 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag;
486 end if;
487 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color is not null then
488 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color;
489 end if;
490 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag is not null then
491 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag;
492 end if;
493 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind is not null then
494 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind;
495 end if;
496 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag is not null then
497 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag;
498 end if;
499 if p_Bsc_Kpi_Entity_Rec.Created_By is not null then
500 l_Bsc_Kpi_Entity_Rec.Created_By := p_Bsc_Kpi_Entity_Rec.Created_By;
501 end if;
502 if p_Bsc_Kpi_Entity_Rec.Creation_Date is not null then
503 l_Bsc_Kpi_Entity_Rec.Creation_Date := p_Bsc_Kpi_Entity_Rec.Creation_Date;
504 end if;
505 if p_Bsc_Kpi_Entity_Rec.Last_Updated_By is not null then
506 l_Bsc_Kpi_Entity_Rec.Last_Updated_By := p_Bsc_Kpi_Entity_Rec.Last_Updated_By;
507 end if;
508 if p_Bsc_Kpi_Entity_Rec.Last_Update_Date is not null then
509 l_Bsc_Kpi_Entity_Rec.Last_Update_Date := p_Bsc_Kpi_Entity_Rec.Last_Update_Date;
510 end if;
511 if p_Bsc_Kpi_Entity_Rec.Last_Update_Login is not null then
512 l_Bsc_Kpi_Entity_Rec.Last_Update_Login := p_Bsc_Kpi_Entity_Rec.Last_Update_Login;
513 end if;
514 if p_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag is not null then
515 l_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag;
516 end if;
517 if p_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id is not null then
518 l_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id;
519 end if;
520 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name is not null then
521 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name;
522 end if;
523 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help is not null then
524 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help;
525 end if;
526 if p_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type is not null then
527 l_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type := p_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type;
528 end if;
529 if p_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id is not null then
530 l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id;
531 end if;
532 if p_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id is not null then
533 l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id;
534 end if;
535 if p_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method is not null then
536 l_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method := p_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method;
537 end if;
538
539
540 update BSC_KPIS_B
541 set csf_id = l_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id
542 ,ind_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id
543 ,disp_order = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Display_Order
544 ,prototype_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag
545 ,indicator_type = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Indicator_Type
546 ,config_type = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Config_Type
547 ,periodicity_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id
548 ,bm_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Bm_Group_Id
549 ,apply_color_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Flag
550 ,prototype_color = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Color
551 ,share_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag
552 ,source_indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind
553 ,publish_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Publish_Flag
554 ,created_by = l_Bsc_Kpi_Entity_Rec.Created_By
555 ,creation_date = l_Bsc_Kpi_Entity_Rec.Creation_Date
556 ,last_updated_by = l_Bsc_Kpi_Entity_Rec.Last_Updated_By
557 ,last_update_date = l_Bsc_Kpi_Entity_Rec.Last_Update_Date
558 ,last_update_login = l_Bsc_Kpi_Entity_Rec.Last_Update_Login
559 ,edw_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Edw_Flag
560 ,calendar_id = l_Bsc_Kpi_Entity_Rec.Bsc_Calendar_Id
561 ,color_rollup_type = l_Bsc_Kpi_Entity_Rec.Bsc_Color_Rollup_Type
562 ,prototype_color_id = l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Color_Id
563 ,prototype_trend_id = l_Bsc_Kpi_Entity_Rec.Bsc_Prototype_Trend_Id
564 ,weighted_color_method = l_Bsc_Kpi_Entity_Rec.Bsc_Weighted_Color_Method
565 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
566
567 update BSC_KPIS_TL
568 set name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name
569 ,help = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help
570 ,SOURCE_LANG = userenv('LANG')
571 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
572 and userenv('LANG') IN (LANGUAGE, SOURCE_LANG);
573
574 if (p_commit = FND_API.G_TRUE) then
575 commit;
576 end if;
577
578
579 EXCEPTION
580 WHEN FND_API.G_EXC_ERROR THEN
581 ROLLBACK TO BscKpiPvt_UptKPI;
582 FND_MSG_PUB.Count_And_Get
583 ( p_encoded => FND_API.G_FALSE
584 , p_count => x_msg_count
585 , p_data => x_msg_data
586 );
587 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
588 x_return_status := FND_API.G_RET_STS_ERROR;
589 RAISE;
590 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
591 ROLLBACK TO BscKpiPvt_UptKPI;
592 FND_MSG_PUB.Count_And_Get
593 ( p_encoded => FND_API.G_FALSE
594 , p_count => x_msg_count
595 , p_data => x_msg_data
596 );
597 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
598 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
599 RAISE;
600 WHEN NO_DATA_FOUND THEN
601 ROLLBACK TO BscKpiPvt_UptKPI;
602 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
603 IF (x_msg_data IS NOT NULL) THEN
604 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi ';
605 ELSE
606 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi ';
607 END IF;
608 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
609 RAISE;
610 WHEN OTHERS THEN
611 ROLLBACK TO BscKpiPvt_UptKPI;
612 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
613 IF (x_msg_data IS NOT NULL) THEN
614 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi ';
615 ELSE
616 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi ';
617 END IF;
618 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
619 RAISE;
620 end Update_Kpi;
621
622 /************************************************************************************
623 ************************************************************************************/
624
625 procedure Delete_Kpi(
626 p_commit IN varchar2 := FND_API.G_FALSE
627 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
628 ,x_return_status OUT NOCOPY varchar2
629 ,x_msg_count OUT NOCOPY number
630 ,x_msg_data OUT NOCOPY varchar2
631 ) is
632
633 l_count number;
634 l_Delete_Kpi_b BOOLEAN := TRUE;
635
636 begin
637 FND_MSG_PUB.Initialize;
638 x_return_status := FND_API.G_RET_STS_SUCCESS;
639 SAVEPOINT BscKpiPvt_DelKPI;
640 -- Check that valid id was entered.
641 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
642 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
643 ,'indicator'
644 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
645 if l_count = 0 then
646 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
647 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
648 FND_MSG_PUB.ADD;
649 RAISE FND_API.G_EXC_ERROR;
650 end if;
651 else
652 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
653 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
654 FND_MSG_PUB.ADD;
655 RAISE FND_API.G_EXC_ERROR;
656 end if;
657
658
659 -- Added for Bug #3248729
660 IF BSC_UTILITY.isBscInProductionMode THEN
661 -- Validate Records in BSC_KPI_DATA_TABLES
662 SELECT COUNT(INDICATOR)
663 INTO l_count
664 FROM BSC_KPI_DATA_TABLES
665 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
666 AND TABLE_NAME IS NOT NULL; -- need to check if actual KPI Tables are there
667
668 IF l_count > 0 THEN
669 l_Delete_Kpi_b := FALSE;
670 END IF;
671 END IF;
672 IF l_Delete_Kpi_b THEN
673 DELETE FROM BSC_KPIS_B
674 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
675
676 DELETE FROM BSC_KPIS_TL
677 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
678 ELSE
679 UPDATE BSC_KPIS_B
680 SET PROTOTYPE_FLAG = BSC_KPI_PUB.DELETE_KPI_FLAG
681 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
682 END IF;
683
684 -- Added for Bug #3248729
685
686 if (p_commit = FND_API.G_TRUE) then
687 commit;
688 end if;
689
690 EXCEPTION
691 WHEN FND_API.G_EXC_ERROR THEN
692 ROLLBACK TO BscKpiPvt_DelKPI;
693 FND_MSG_PUB.Count_And_Get
694 ( p_encoded => FND_API.G_FALSE
695 , p_count => x_msg_count
696 , p_data => x_msg_data
697 );
698 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
699 x_return_status := FND_API.G_RET_STS_ERROR;
700 RAISE;
701 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
702 ROLLBACK TO BscKpiPvt_DelKPI;
703 FND_MSG_PUB.Count_And_Get
704 ( p_encoded => FND_API.G_FALSE
705 , p_count => x_msg_count
706 , p_data => x_msg_data
707 );
708 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
709 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
710 RAISE;
711 WHEN NO_DATA_FOUND THEN
712 ROLLBACK TO BscKpiPvt_DelKPI;
713 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
714 IF (x_msg_data IS NOT NULL) THEN
715 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi ';
716 ELSE
717 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi ';
718 END IF;
719 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
720 RAISE;
721 WHEN OTHERS THEN
722 ROLLBACK TO BscKpiPvt_DelKPI;
723 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
724 IF (x_msg_data IS NOT NULL) THEN
725 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi ';
726 ELSE
727 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi ';
728 END IF;
729 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
730 RAISE;
731 end Delete_Kpi;
732
733 /************************************************************************************
734 ************************************************************************************/
735
736 procedure Create_Kpi_Defaults(
737 p_commit IN varchar2 := FND_API.G_FALSE
738 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
739 ,x_return_status OUT NOCOPY varchar2
740 ,x_msg_count OUT NOCOPY number
741 ,x_msg_data OUT NOCOPY varchar2
742 ) is
743
744 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
745
746 l_Bsc_Dim_Rec BSC_DIMENSION_SETS_PUB.Bsc_Dim_Set_Rec_Type;
747
748 l_db_object varchar2(30);
749
750 l_count number;
751
752 begin
753 FND_MSG_PUB.Initialize;
754 x_return_status := FND_API.G_RET_STS_SUCCESS;
755 SAVEPOINT BscKpiPvt_CrtKPIDef;
756 --BSC_DEBUG.PUT_LINE('-- Begin Create_Kpi_Defaults');
757 --BSC_DEBUG.PUT_LINE(' Create_Kpi_Defaults - p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id = ' || p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
758
759
760 -- Assign all values in the passed "Record" parameter to the locally defined
761 -- "Record" variable.
762 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
763
764 -- Check that valid id was entered.
765 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
766
767 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
768 ,'indicator'
769 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
770 if l_count = 0 then
771
772 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - BSC_INVALID_KPI_ID');
773 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id = ' || l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
774
775 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
776 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
777 FND_MSG_PUB.ADD;
778 RAISE FND_API.G_EXC_ERROR;
779 end if;
780 else
781 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - BSC_NO_KPI_ID_ENTERED');
782 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
783 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
784 FND_MSG_PUB.ADD;
785 RAISE FND_API.G_EXC_ERROR;
786 end if;
787
788 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - Flag 1');
789
790 -- Set values needed to populate default Dimension set.
791 l_Bsc_Dim_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
792 l_Bsc_Dim_Rec.Bsc_Dim_Set_Id := 0;
793 l_Bsc_Dim_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
794 l_Bsc_Dim_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
795
796 l_db_object := 'Create_Bsc_Kpi_Dim_Sets_Tl';
797
798 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - Flag 2');
799
800 -- Call procedure to Populate Dimension sets.
801 BSC_DIMENSION_SETS_PUB.Create_Bsc_Kpi_Dim_Sets_Tl( p_commit
802 ,l_Bsc_Dim_Rec
803 ,x_return_status
804 ,x_msg_count
805 ,x_msg_data);
806
807 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - Flag 3');
808
809 -- Set values needed to populate default Dimension Levels for the Kpi.
810 l_Bsc_Dim_Rec.Bsc_Dset_Dim_Level_Index := 1; -- This is set to one because the API
811 -- that actually sets this value subtracts 1
812 -- from the value passed, thus making the value 0.
813 l_Bsc_Dim_Rec.Bsc_Level_Name := 'XXX';
814 l_Bsc_Dim_Rec.Bsc_Pk_Col := 'XXX';
815 l_Bsc_Dim_Rec.Bsc_Dim_Level_Long_Name := 'XXX';
816 l_Bsc_Dim_Rec.Bsc_Dim_Level_Help := 'XXX';
817 l_Bsc_Dim_Rec.Bsc_Dset_Value_Order := 0;
818 l_Bsc_Dim_Rec.Bsc_Dset_Comp_Order := 0;
819 l_Bsc_Dim_Rec.Bsc_Dset_Parent_Level_Rel := 'XXX';
820 l_Bsc_Dim_Rec.Bsc_Dset_Status := 0;
821 l_Bsc_Dim_Rec.Bsc_Dset_Position := 0;
822 l_Bsc_Dim_Rec.Bsc_Dset_User_Level0 := 0;
823 l_Bsc_Dim_Rec.Bsc_Dset_User_Level1 := 0;
824 l_Bsc_Dim_Rec.Bsc_Dset_User_Level1_Default := 0;
825 l_Bsc_Dim_Rec.Bsc_Dset_User_Level2 := 0;
826 l_Bsc_Dim_Rec.Bsc_Dset_User_Level2_Default := 0;
827 l_Bsc_Dim_Rec.Bsc_Dset_Target_Level := 1;
828 l_Bsc_Dim_Rec.Bsc_Dim_Tot_Disp_Name := 'XXX';
829 l_Bsc_Dim_Rec.Bsc_Dim_Comp_Disp_Name := 'XXX';
830
831 l_db_object := 'Create_Dim_Levels';
832
833 --DBMS_OUTPUT.PUT_LINE(' Create_Kpi_Defaults - Flag 4');
834
835 BSC_DIMENSION_SETS_PUB.Create_Dim_Levels( p_commit
836 ,l_Bsc_Dim_Rec
837 ,x_return_status
838 ,x_msg_count
839 ,x_msg_data);
840
841 if (p_commit = FND_API.G_TRUE) then
842 commit;
843 end if;
844
845 --DBMS_OUTPUT.PUT_LINE('-- Ene Create_Kpi_Defaults');
846
847 EXCEPTION
848 WHEN FND_API.G_EXC_ERROR THEN
849 ROLLBACK TO BscKpiPvt_CrtKPIDef;
850 FND_MSG_PUB.Count_And_Get
851 ( p_encoded => FND_API.G_FALSE
852 , p_count => x_msg_count
853 , p_data => x_msg_data
854 );
855 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
856 x_return_status := FND_API.G_RET_STS_ERROR;
857 RAISE;
858 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
859 ROLLBACK TO BscKpiPvt_CrtKPIDef;
860 FND_MSG_PUB.Count_And_Get
861 ( p_encoded => FND_API.G_FALSE
862 , p_count => x_msg_count
863 , p_data => x_msg_data
864 );
865 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
866 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
867 RAISE;
868 WHEN NO_DATA_FOUND THEN
869 ROLLBACK TO BscKpiPvt_CrtKPIDef;
870 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
871 if (SQLCODE = -01400) then
872 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
873 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
874 FND_MSG_PUB.ADD;
875 RAISE FND_API.G_EXC_ERROR;
876 end if;
877 IF (x_msg_data IS NOT NULL) THEN
878 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Defaults ';
879 ELSE
880 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Defaults ';
881 END IF;
882 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
883 RAISE;
884 WHEN OTHERS THEN
885 ROLLBACK TO BscKpiPvt_CrtKPIDef;
886 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
887 IF (x_msg_data IS NOT NULL) THEN
888 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Defaults ';
889 ELSE
890 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Defaults ';
891 END IF;
892 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
893 RAISE;
894 end Create_Kpi_Defaults;
895
896 /************************************************************************************
897 ************************************************************************************/
898
899 procedure Retrieve_Kpi_Defaults(
900 p_commit IN varchar2 := FND_API.G_FALSE
901 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
902 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
903 ,x_return_status OUT NOCOPY varchar2
904 ,x_msg_count OUT NOCOPY number
905 ,x_msg_data OUT NOCOPY varchar2
906 ) is
907
908 l_Bsc_Dim_Rec BSC_DIMENSION_SETS_PUB.Bsc_Dim_Set_Rec_Type;
909 x_Bsc_Dim_Rec BSC_DIMENSION_SETS_PUB.Bsc_Dim_Set_Rec_Type;
910
911 l_db_object varchar2(30);
912
913 l_count number;
914
915 begin
916 FND_MSG_PUB.Initialize;
917 x_return_status := FND_API.G_RET_STS_SUCCESS;
918 l_db_object := 'Retrieve_Kpi_Defaults';
919
920 -- Set values needed to retrieve default Dimension set.
921 l_Bsc_Dim_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
922 l_Bsc_Dim_Rec.Bsc_Dim_Set_Id := 0;
923 l_Bsc_Dim_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
924 l_Bsc_Dim_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
925
926 BSC_DIMENSION_SETS_PUB.Retrieve_Bsc_Kpi_Dim_Sets_Tl( p_commit
927 ,l_Bsc_Dim_Rec
928 ,x_Bsc_Dim_Rec
929 ,x_return_status
930 ,x_msg_count
931 ,x_msg_data);
932
933 -- Set values needed to retrieve default Dimension set.
934 x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := x_Bsc_Dim_Rec.Bsc_Kpi_Id;
935 x_Bsc_Kpi_Entity_Rec.Bsc_Dim_Set_Id := x_Bsc_Dim_Rec.Bsc_Dim_Set_Id;
936 x_Bsc_Kpi_Entity_Rec.Bsc_Language := x_Bsc_Dim_Rec.Bsc_Language;
937 x_Bsc_Kpi_Entity_Rec.Bsc_Source_Language := x_Bsc_Dim_Rec.Bsc_Source_Language;
938
939 if (p_commit = FND_API.G_TRUE) then
940 commit;
941 end if;
942
943
944 EXCEPTION
945 WHEN FND_API.G_EXC_ERROR THEN
946 FND_MSG_PUB.Count_And_Get
947 ( p_encoded => FND_API.G_FALSE
948 , p_count => x_msg_count
949 , p_data => x_msg_data
950 );
951 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
952 x_return_status := FND_API.G_RET_STS_ERROR;
953 RAISE;
954 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
955 FND_MSG_PUB.Count_And_Get
956 ( p_encoded => FND_API.G_FALSE
957 , p_count => x_msg_count
958 , p_data => x_msg_data
959 );
960 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
961 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
962 RAISE;
963 WHEN NO_DATA_FOUND THEN
964 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
965 FND_MSG_PUB.Initialize;
966 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
967 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
968 FND_MSG_PUB.ADD;
969 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
970 RAISE FND_API.G_EXC_ERROR;
971 WHEN OTHERS THEN
972 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
973 IF (x_msg_data IS NOT NULL) THEN
974 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Defaults ';
975 ELSE
976 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Defaults ';
977 END IF;
978 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
979 RAISE;
980 end Retrieve_Kpi_Defaults;
981
982 /************************************************************************************
983 ************************************************************************************/
984
985 procedure Update_Kpi_Defaults(
986 p_commit IN varchar2 := FND_API.G_FALSE
987 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
988 ,x_return_status OUT NOCOPY varchar2
989 ,x_msg_count OUT NOCOPY number
990 ,x_msg_data OUT NOCOPY varchar2
991 ) is
992
993
994 begin
995 FND_MSG_PUB.Initialize;
996 x_return_status := FND_API.G_RET_STS_SUCCESS;
997 -- This procedure does not really update anything. Public version handles the calls
998 -- to the other procedures.
999
1000 if (p_commit = FND_API.G_TRUE) then
1001 commit;
1002 end if;
1003
1004 EXCEPTION
1005 WHEN FND_API.G_EXC_ERROR THEN
1006 FND_MSG_PUB.Count_And_Get
1007 ( p_encoded => FND_API.G_FALSE
1008 , p_count => x_msg_count
1009 , p_data => x_msg_data
1010 );
1011 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1012 x_return_status := FND_API.G_RET_STS_ERROR;
1013 RAISE;
1014 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1015 FND_MSG_PUB.Count_And_Get
1016 ( p_encoded => FND_API.G_FALSE
1017 , p_count => x_msg_count
1018 , p_data => x_msg_data
1019 );
1020 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1021 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1022 RAISE;
1023 WHEN NO_DATA_FOUND THEN
1024 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1025 IF (x_msg_data IS NOT NULL) THEN
1026 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Defaults ';
1027 ELSE
1028 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Defaults ';
1029 END IF;
1030 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1031 RAISE;
1032 WHEN OTHERS THEN
1033 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1034 IF (x_msg_data IS NOT NULL) THEN
1035 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Defaults ';
1036 ELSE
1037 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Defaults ';
1038 END IF;
1039 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1040 RAISE;
1041 end Update_Kpi_Defaults;
1042
1043 /************************************************************************************
1044 ************************************************************************************/
1045
1046 procedure Delete_Kpi_Defaults(
1047 p_commit IN varchar2 := FND_API.G_FALSE
1048 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1049 ,x_return_status OUT NOCOPY varchar2
1050 ,x_msg_count OUT NOCOPY number
1051 ,x_msg_data OUT NOCOPY varchar2
1052 ) is
1053
1054 begin
1055 FND_MSG_PUB.Initialize;
1056 x_return_status := FND_API.G_RET_STS_SUCCESS;
1057
1058 if (p_commit = FND_API.G_TRUE) then
1059 commit;
1060 end if;
1061
1062 EXCEPTION
1063 WHEN FND_API.G_EXC_ERROR THEN
1064 FND_MSG_PUB.Count_And_Get
1065 ( p_encoded => FND_API.G_FALSE
1066 , p_count => x_msg_count
1067 , p_data => x_msg_data
1068 );
1069 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1070 x_return_status := FND_API.G_RET_STS_ERROR;
1071 RAISE;
1072 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1073 FND_MSG_PUB.Count_And_Get
1074 ( p_encoded => FND_API.G_FALSE
1075 , p_count => x_msg_count
1076 , p_data => x_msg_data
1077 );
1078 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1079 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1080 RAISE;
1081 WHEN NO_DATA_FOUND THEN
1082 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1083 IF (x_msg_data IS NOT NULL) THEN
1084 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Defaults ';
1085 ELSE
1086 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Defaults ';
1087 END IF;
1088 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1089 RAISE;
1090 WHEN OTHERS THEN
1091 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1092 IF (x_msg_data IS NOT NULL) THEN
1093 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Defaults ';
1094 ELSE
1095 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Defaults ';
1096 END IF;
1097 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1098 RAISE;
1099 end Delete_Kpi_Defaults;
1100
1101 /************************************************************************************
1102 ************************************************************************************/
1103
1104 procedure Create_Kpi_Properties(
1105 p_commit IN varchar2 := FND_API.G_FALSE
1106 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1107 ,x_return_status OUT NOCOPY varchar2
1108 ,x_msg_count OUT NOCOPY number
1109 ,x_msg_data OUT NOCOPY varchar2
1110 ) is
1111
1112 l_db_object varchar2(30);
1113
1114 l_count number;
1115
1116 begin
1117 FND_MSG_PUB.Initialize;
1118 x_return_status := FND_API.G_RET_STS_SUCCESS;
1119 SAVEPOINT BscKpiPvt_CrtKPIProp;
1120 -- Check that valid id was entered.
1121 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
1122 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1123 ,'indicator'
1124 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1125 if l_count = 0 then
1126 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1127 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1128 FND_MSG_PUB.ADD;
1129 RAISE FND_API.G_EXC_ERROR;
1130 end if;
1131 else
1132 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1133 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1134 FND_MSG_PUB.ADD;
1135 RAISE FND_API.G_EXC_ERROR;
1136 end if;
1137
1138 l_db_object := 'BSC_KPI_PROPERTIES';
1139
1140 insert into BSC_KPI_PROPERTIES( indicator
1141 ,property_code
1142 ,property_value
1143 ,secondary_value)
1144 values( p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1145 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Code
1146 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value
1147 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value);
1148
1149 if (p_commit = FND_API.G_TRUE) then
1150 commit;
1151 end if;
1152
1153
1154 EXCEPTION
1155 WHEN FND_API.G_EXC_ERROR THEN
1156 ROLLBACK TO BscKpiPvt_CrtKPIProp;
1157 FND_MSG_PUB.Count_And_Get
1158 ( p_encoded => FND_API.G_FALSE
1159 , p_count => x_msg_count
1160 , p_data => x_msg_data
1161 );
1162 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1163 x_return_status := FND_API.G_RET_STS_ERROR;
1164 RAISE;
1165 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1166 ROLLBACK TO BscKpiPvt_CrtKPIProp;
1167 FND_MSG_PUB.Count_And_Get
1168 ( p_encoded => FND_API.G_FALSE
1169 , p_count => x_msg_count
1170 , p_data => x_msg_data
1171 );
1172 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1173 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1174 RAISE;
1175 WHEN NO_DATA_FOUND THEN
1176 ROLLBACK TO BscKpiPvt_CrtKPIProp;
1177 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1178 IF (x_msg_data IS NOT NULL) THEN
1179 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Defaults ';
1180 ELSE
1181 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Defaults ';
1182 END IF;
1183 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1184 RAISE;
1185 WHEN OTHERS THEN
1186 ROLLBACK TO BscKpiPvt_CrtKPIProp;
1187 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1188 if (SQLCODE = -01400) then
1189 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
1190 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
1191 FND_MSG_PUB.ADD;
1192 RAISE FND_API.G_EXC_ERROR;
1193 end if;
1194 IF (x_msg_data IS NOT NULL) THEN
1195 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Properties ';
1196 ELSE
1197 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Properties ';
1198 END IF;
1199 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1200 RAISE;
1201 end Create_Kpi_Properties;
1202
1203 /************************************************************************************
1204 ************************************************************************************/
1205
1206 procedure Retrieve_Kpi_Properties(
1207 p_commit IN varchar2 := FND_API.G_FALSE
1208 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1209 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1210 ,x_return_status OUT NOCOPY varchar2
1211 ,x_msg_count OUT NOCOPY number
1212 ,x_msg_data OUT NOCOPY varchar2
1213 ) is
1214
1215 l_count number;
1216
1217 l_db_object varchar2(30);
1218
1219 begin
1220 FND_MSG_PUB.Initialize;
1221 x_return_status := FND_API.G_RET_STS_SUCCESS;
1222 l_db_object := 'Retrieve_Kpi_Properties';
1223
1224 select distinct property_value
1225 ,secondary_value
1226 into x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value
1227 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value
1228 from BSC_KPI_PROPERTIES
1229 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1230 and property_code = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Code;
1231
1232 if (p_commit = FND_API.G_TRUE) then
1233 commit;
1234 end if;
1235 EXCEPTION
1236 WHEN FND_API.G_EXC_ERROR THEN
1237 FND_MSG_PUB.Count_And_Get
1238 ( p_encoded => FND_API.G_FALSE
1239 , p_count => x_msg_count
1240 , p_data => x_msg_data
1241 );
1242 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1243 x_return_status := FND_API.G_RET_STS_ERROR;
1244 RAISE;
1245 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1246 FND_MSG_PUB.Count_And_Get
1247 ( p_encoded => FND_API.G_FALSE
1248 , p_count => x_msg_count
1249 , p_data => x_msg_data
1250 );
1251 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1252 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1253 RAISE;
1254 WHEN NO_DATA_FOUND THEN
1255 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1256 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1257 FND_MSG_PUB.Initialize;
1258 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
1259 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
1260 FND_MSG_PUB.ADD;
1261 RAISE FND_API.G_EXC_ERROR;
1262 WHEN OTHERS THEN
1263 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1264 IF (x_msg_data IS NOT NULL) THEN
1265 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Properties ';
1266 ELSE
1267 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Properties ';
1268 END IF;
1269 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1270 RAISE;
1271 end Retrieve_Kpi_Properties;
1272
1273 /************************************************************************************
1274 ************************************************************************************/
1275
1276 procedure Update_Kpi_Properties(
1277 p_commit IN varchar2 := FND_API.G_FALSE
1278 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1279 ,x_return_status OUT NOCOPY varchar2
1280 ,x_msg_count OUT NOCOPY number
1281 ,x_msg_data OUT NOCOPY varchar2
1282 ) is
1283
1284 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
1285
1286 l_count number;
1287
1288 begin
1289 FND_MSG_PUB.Initialize;
1290 x_return_status := FND_API.G_RET_STS_SUCCESS;
1291 SAVEPOINT BscKpiPvt_UptKPIProp;
1292 -- Check that valid id was entered.
1293 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
1294 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1295 ,'indicator'
1296 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1297 if l_count = 0 then
1298 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1299 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1300 FND_MSG_PUB.ADD;
1301 RAISE FND_API.G_EXC_ERROR;
1302 end if;
1303 else
1304 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1305 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1306 FND_MSG_PUB.ADD;
1307 RAISE FND_API.G_EXC_ERROR;
1308 end if;
1309
1310 -- Not all values will be passed. We need to make sure values not passed are not
1311 -- changed by procedure, therefore we get what is there before we do any updates.
1312 Retrieve_Kpi_Properties( p_commit
1313 ,p_Bsc_Kpi_Entity_Rec
1314 ,l_Bsc_Kpi_Entity_Rec
1315 ,x_return_status
1316 ,x_msg_count
1317 ,x_msg_data);
1318
1319 -- update LOCAL Kpi Id values with PASSED values.
1320 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1321 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Code := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Code;
1322
1323
1324 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
1325 -- which are NOT NULL.
1326 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value is not null then
1327 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value;
1328 end if;
1329 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value is not null then
1330 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value;
1331 end if;
1332
1333 update BSC_KPI_PROPERTIES
1334 set property_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Value
1335 ,secondary_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Secondary_Value
1336 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1337 and property_code = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Property_Code;
1338
1339 if (p_commit = FND_API.G_TRUE) then
1340 commit;
1341 end if;
1342
1343
1344 EXCEPTION
1345 WHEN FND_API.G_EXC_ERROR THEN
1346 ROLLBACK TO BscKpiPvt_UptKPIProp;
1347 FND_MSG_PUB.Count_And_Get
1348 ( p_encoded => FND_API.G_FALSE
1349 , p_count => x_msg_count
1350 , p_data => x_msg_data
1351 );
1352 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1353 x_return_status := FND_API.G_RET_STS_ERROR;
1354 RAISE;
1355 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1356 ROLLBACK TO BscKpiPvt_UptKPIProp;
1357 FND_MSG_PUB.Count_And_Get
1358 ( p_encoded => FND_API.G_FALSE
1359 , p_count => x_msg_count
1360 , p_data => x_msg_data
1361 );
1362 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1363 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1364 RAISE;
1365 WHEN NO_DATA_FOUND THEN
1366 ROLLBACK TO BscKpiPvt_UptKPIProp;
1367 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1368 IF (x_msg_data IS NOT NULL) THEN
1369 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Properties ';
1370 ELSE
1371 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Properties ';
1372 END IF;
1373 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1374 RAISE;
1375 WHEN OTHERS THEN
1376 ROLLBACK TO BscKpiPvt_UptKPIProp;
1377 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1378 IF (x_msg_data IS NOT NULL) THEN
1379 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Properties ';
1380 ELSE
1381 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Properties ';
1382 END IF;
1383 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1384 RAISE;
1385 end Update_Kpi_Properties;
1386
1387 /************************************************************************************
1388 ************************************************************************************/
1389
1390 procedure Delete_Kpi_Properties(
1391 p_commit IN varchar2 := FND_API.G_FALSE
1392 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1393 ,x_return_status OUT NOCOPY varchar2
1394 ,x_msg_count OUT NOCOPY number
1395 ,x_msg_data OUT NOCOPY varchar2
1396 ) is
1397
1398 l_count number;
1399
1400 begin
1401 FND_MSG_PUB.Initialize;
1402 x_return_status := FND_API.G_RET_STS_SUCCESS;
1403 SAVEPOINT BscKpiPvt_DelKPIProp;
1404 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
1405 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1406 ,'indicator'
1407 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1408 if l_count = 0 then
1409 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1410 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1411 FND_MSG_PUB.ADD;
1412 RAISE FND_API.G_EXC_ERROR;
1413 end if;
1414 else
1415 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1416 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1417 FND_MSG_PUB.ADD;
1418 RAISE FND_API.G_EXC_ERROR;
1419 end if;
1420
1421
1422 delete from BSC_KPI_PROPERTIES
1423 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1424
1425 if (p_commit = FND_API.G_TRUE) then
1426 commit;
1427 end if;
1428
1429 EXCEPTION
1430 WHEN FND_API.G_EXC_ERROR THEN
1431 ROLLBACK TO BscKpiPvt_DelKPIProp;
1432 FND_MSG_PUB.Count_And_Get
1433 ( p_encoded => FND_API.G_FALSE
1434 , p_count => x_msg_count
1435 , p_data => x_msg_data
1436 );
1437 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1438 x_return_status := FND_API.G_RET_STS_ERROR;
1439 RAISE;
1440 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1441 ROLLBACK TO BscKpiPvt_DelKPIProp;
1442 FND_MSG_PUB.Count_And_Get
1443 ( p_encoded => FND_API.G_FALSE
1444 , p_count => x_msg_count
1445 , p_data => x_msg_data
1446 );
1447 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1448 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1449 RAISE;
1450 WHEN NO_DATA_FOUND THEN
1451 ROLLBACK TO BscKpiPvt_DelKPIProp;
1452 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1453 IF (x_msg_data IS NOT NULL) THEN
1454 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Properties ';
1455 ELSE
1456 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Properties ';
1457 END IF;
1458 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1459 RAISE;
1460 WHEN OTHERS THEN
1461 ROLLBACK TO BscKpiPvt_DelKPIProp;
1462 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1463 IF (x_msg_data IS NOT NULL) THEN
1464 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Properties ';
1465 ELSE
1466 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Properties ';
1467 END IF;
1468 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1469 RAISE;
1470 end Delete_Kpi_Properties;
1471
1472 /************************************************************************************
1473 ************************************************************************************/
1474
1475 procedure Create_Kpi_Analysis(
1476 p_commit IN varchar2 := FND_API.G_FALSE
1477 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1478 ,x_return_status OUT NOCOPY varchar2
1479 ,x_msg_count OUT NOCOPY number
1480 ,x_msg_data OUT NOCOPY varchar2
1481 ) is
1482
1483 l_Bsc_Kpi_Rec BSC_ANALYSIS_OPTION_PUB.Bsc_Option_Rec_Type;
1484
1485 l_db_object varchar2(30);
1486
1487 l_count number;
1488
1489 no_kpi_id exception;
1490
1491 begin
1492 FND_MSG_PUB.Initialize;
1493 x_return_status := FND_API.G_RET_STS_SUCCESS;
1494 SAVEPOINT BscKpiPvt_CrtKPIAnal;
1495 -- Check that valid id was entered.
1496 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
1497 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1498 ,'indicator'
1499 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1500 if l_count = 0 then
1501 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1502 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1503 FND_MSG_PUB.ADD;
1504 RAISE FND_API.G_EXC_ERROR;
1505 end if;
1506 else
1507 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1508 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1509 FND_MSG_PUB.ADD;
1510 RAISE FND_API.G_EXC_ERROR;
1511 end if;
1512
1513 l_db_object := 'BSC_KPI_ANALYSIS_GROUPS';
1514
1515 insert into BSC_KPI_ANALYSIS_GROUPS( INDICATOR
1516 ,ANALYSIS_GROUP_ID
1517 ,NUM_OF_OPTIONS
1518 ,DEPENDENCY_FLAG
1519 ,PARENT_ANALYSIS_ID
1520 ,CHANGE_DIM_SET
1521 ,DEFAULT_VALUE
1522 ,SHORT_NAME)
1523 values( p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1524 ,p_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1525 ,p_Bsc_Kpi_Entity_Rec.Bsc_Num_Options
1526 ,p_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag
1527 ,p_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id
1528 ,p_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set
1529 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1530 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name);
1531
1532 -- Set the necessary values to create the Default Analysis Option.
1533 l_Bsc_Kpi_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1534 l_Bsc_Kpi_Rec.Bsc_Analysis_Group_Id := 0;
1535 l_Bsc_Kpi_Rec.Bsc_Parent_Option_Id := 0;
1536 l_Bsc_Kpi_Rec.Bsc_Grandparent_Option_Id := 0;
1537 l_Bsc_Kpi_Rec.Bsc_Dim_Set_Id := 0;
1538 l_Bsc_Kpi_Rec.Bsc_Analysis_Option_Id := 0;
1539 l_Bsc_Kpi_Rec.Bsc_New_Kpi := 'Y';
1540 l_Bsc_Kpi_Rec.Bsc_Option_Group0 := 0;
1541 l_Bsc_Kpi_Rec.Bsc_Option_Group1 := 0;
1542 l_Bsc_Kpi_Rec.Bsc_Option_Group2 := 0;
1543 l_Bsc_Kpi_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
1544 l_Bsc_Kpi_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
1545
1546 -- fixed Bug#4294920 for AG Report Designer
1547 -- NOTE: Need to review "Option 0" being hardcoded, which incidently is being
1548 -- used in Objective designer to maintain references.
1549 -- An ideal fix would be to get this Option 0 from a lookup so that it is
1550 -- clearly translatable.
1551
1552 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name IS NOT NULL) THEN
1553 l_Bsc_Kpi_Rec.Bsc_Option_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name;
1554 l_Bsc_Kpi_Rec.Bsc_Option_Help := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help;
1555 l_Bsc_Kpi_Rec.Bsc_Measure_Long_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Name;
1556 l_Bsc_Kpi_Rec.Bsc_Measure_Help := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Help;
1557
1558 --added for Bug#4331964
1559 l_Bsc_Kpi_Rec.Bsc_Option_Short_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name;
1560 ELSE
1561 l_Bsc_Kpi_Rec.Bsc_Option_Name := 'Option 0';
1562 l_Bsc_Kpi_Rec.Bsc_Option_Help := 'Option 0';
1563 l_Bsc_Kpi_Rec.Bsc_Measure_Long_Name := 'Default 0';
1564 l_Bsc_Kpi_Rec.Bsc_Measure_Help := 'Default 0';
1565 END IF;
1566
1567
1568 l_Bsc_Kpi_Rec.Bsc_User_Level0 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0;
1569 l_Bsc_Kpi_Rec.Bsc_User_Level1 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1;
1570
1571 l_db_object := 'Create_Analysis_Options';
1572
1573 BSC_ANALYSIS_OPTION_PUB.Create_Analysis_Options( p_commit
1574 ,l_Bsc_Kpi_Rec
1575 ,x_return_status
1576 ,x_msg_count
1577 ,x_msg_data);
1578
1579 if (p_commit = FND_API.G_TRUE) then
1580 commit;
1581 end if;
1582
1583
1584 EXCEPTION
1585 WHEN FND_API.G_EXC_ERROR THEN
1586 ROLLBACK TO BscKpiPvt_CrtKPIAnal;
1587 FND_MSG_PUB.Count_And_Get
1588 ( p_encoded => FND_API.G_FALSE
1589 , p_count => x_msg_count
1590 , p_data => x_msg_data
1591 );
1592 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1593 x_return_status := FND_API.G_RET_STS_ERROR;
1594 RAISE;
1595 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1596 ROLLBACK TO BscKpiPvt_CrtKPIAnal;
1597 FND_MSG_PUB.Count_And_Get
1598 ( p_encoded => FND_API.G_FALSE
1599 , p_count => x_msg_count
1600 , p_data => x_msg_data
1601 );
1602 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1603 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1604 RAISE;
1605 WHEN NO_DATA_FOUND THEN
1606 ROLLBACK TO BscKpiPvt_CrtKPIAnal;
1607 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1608 IF (x_msg_data IS NOT NULL) THEN
1609 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Properties ';
1610 ELSE
1611 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Properties ';
1612 END IF;
1613 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1614 RAISE;
1615 WHEN OTHERS THEN
1616 ROLLBACK TO BscKpiPvt_CrtKPIAnal;
1617 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1618 if (SQLCODE = -01400) then
1619 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
1620 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
1621 FND_MSG_PUB.ADD;
1622 RAISE FND_API.G_EXC_ERROR;
1623 end if;
1624 IF (x_msg_data IS NOT NULL) THEN
1625 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Analysis ';
1626 ELSE
1627 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Analysis ';
1628 END IF;
1629 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1630 RAISE;
1631 end Create_Kpi_Analysis;
1632
1633 /************************************************************************************
1634 ************************************************************************************/
1635
1636 procedure Retrieve_Kpi_Analysis(
1637 p_commit IN varchar2 := FND_API.G_FALSE
1638 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1639 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1640 ,x_return_status OUT NOCOPY varchar2
1641 ,x_msg_count OUT NOCOPY number
1642 ,x_msg_data OUT NOCOPY varchar2
1643 ) is
1644
1645 l_count number;
1646
1647 l_db_object varchar2(30);
1648
1649 begin
1650 FND_MSG_PUB.Initialize;
1651 x_return_status := FND_API.G_RET_STS_SUCCESS;
1652 l_db_object := 'Retrieve_Kpi_Analysis';
1653 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id IS NOT NULL) THEN
1654 select distinct analysis_group_id
1655 ,num_of_options
1656 ,dependency_flag
1657 ,parent_analysis_id
1658 ,change_dim_set
1659 ,default_value
1660 ,short_name
1661 into x_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1662 ,x_Bsc_Kpi_Entity_Rec.Bsc_Num_Options
1663 ,x_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag
1664 ,x_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id
1665 ,x_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set
1666 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1667 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name
1668 from BSC_KPI_ANALYSIS_GROUPS
1669 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1670 and analysis_group_id = p_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id;
1671 ELSE
1672 select distinct analysis_group_id
1673 ,num_of_options
1674 ,dependency_flag
1675 ,parent_analysis_id
1676 ,change_dim_set
1677 ,default_value
1678 ,short_name
1679 into x_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1680 ,x_Bsc_Kpi_Entity_Rec.Bsc_Num_Options
1681 ,x_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag
1682 ,x_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id
1683 ,x_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set
1684 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1685 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name
1686 from BSC_KPI_ANALYSIS_GROUPS
1687 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1688 END IF;
1689 if (p_commit = FND_API.G_TRUE) then
1690 commit;
1691 end if;
1692
1693
1694 EXCEPTION
1695 WHEN FND_API.G_EXC_ERROR THEN
1696 FND_MSG_PUB.Count_And_Get
1697 ( p_encoded => FND_API.G_FALSE
1698 , p_count => x_msg_count
1699 , p_data => x_msg_data
1700 );
1701 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1702 x_return_status := FND_API.G_RET_STS_ERROR;
1703 RAISE;
1704 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1705 FND_MSG_PUB.Count_And_Get
1706 ( p_encoded => FND_API.G_FALSE
1707 , p_count => x_msg_count
1708 , p_data => x_msg_data
1709 );
1710 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1711 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1712 RAISE;
1713 WHEN NO_DATA_FOUND THEN
1714 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1715 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1716 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
1717 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
1718 FND_MSG_PUB.ADD;
1719 RAISE FND_API.G_EXC_ERROR;
1720 WHEN OTHERS THEN
1721 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1722 IF (x_msg_data IS NOT NULL) THEN
1723 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Analysis ';
1724 ELSE
1725 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Analysis ';
1726 END IF;
1727 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1728 RAISE;
1729 end Retrieve_Kpi_Analysis;
1730
1731 /************************************************************************************
1732 ************************************************************************************/
1733
1734 procedure Update_Kpi_Analysis(
1735 p_commit IN varchar2 := FND_API.G_FALSE
1736 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1737 ,x_return_status OUT NOCOPY varchar2
1738 ,x_msg_count OUT NOCOPY number
1739 ,x_msg_data OUT NOCOPY varchar2
1740 ) is
1741
1742 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
1743
1744 l_count number;
1745
1746 begin
1747 FND_MSG_PUB.Initialize;
1748 x_return_status := FND_API.G_RET_STS_SUCCESS;
1749 SAVEPOINT BscKpiPvt_UpdKPIAnal;
1750 -- Check that valid id was entered.
1751 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
1752 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1753 ,'indicator'
1754 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1755 if l_count = 0 then
1756 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1757 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1758 FND_MSG_PUB.ADD;
1759 RAISE FND_API.G_EXC_ERROR;
1760 end if;
1761 else
1762 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1763 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1764 FND_MSG_PUB.ADD;
1765 RAISE FND_API.G_EXC_ERROR;
1766 end if;
1767
1768 -- Not all values will be passed. We need to make sure values not passed are not
1769 -- changed by procedure, therefore we get what is there before we do any updates.
1770 Retrieve_Kpi_Analysis( p_commit
1771 ,p_Bsc_Kpi_Entity_Rec
1772 ,l_Bsc_Kpi_Entity_Rec
1773 ,x_return_status
1774 ,x_msg_count
1775 ,x_msg_data);
1776
1777 -- update LOCAL language ,source language and level Id values with PASSED values.
1778 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1779
1780
1781 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
1782 -- which are NOT NULL.
1783 if p_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id is not null then
1784 l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id;
1785 end if;
1786 if p_Bsc_Kpi_Entity_Rec.Bsc_Num_Options is not null then
1787 l_Bsc_Kpi_Entity_Rec.Bsc_Num_Options := p_Bsc_Kpi_Entity_Rec.Bsc_Num_Options;
1788 end if;
1789 if p_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag is not null then
1790 l_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag;
1791 end if;
1792 if p_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id is not null then
1793 l_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id;
1794 end if;
1795 if p_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set is not null then
1796 l_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set := p_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set;
1797 end if;
1798 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value is not null then
1799 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value;
1800 end if;
1801
1802 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name is not null then
1803 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name;
1804 end if;
1805
1806
1807 IF (l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id IS NOT NULL) THEN
1808 IF (l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value IS NOT NULL) THEN
1809 Set_Default_Value_By_Option_ID
1810 ( p_Kpi_Id => l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1811 , p_group_id => l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1812 , p_parent_option_Id => l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Analysis_Option1
1813 , p_grand_parent_option_Id => l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Analysis_Option0
1814 , p_option_Id => l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1815 );
1816 END IF;
1817 update BSC_KPI_ANALYSIS_GROUPS
1818 set analysis_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1819 ,num_of_options = l_Bsc_Kpi_Entity_Rec.Bsc_Num_Options
1820 ,dependency_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag
1821 ,parent_analysis_id = l_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id
1822 ,change_dim_set = l_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set
1823 ,default_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1824 ,short_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name
1825 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
1826 AND analysis_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id;
1827 ELSE
1828 update BSC_KPI_ANALYSIS_GROUPS
1829 set analysis_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Anal_Group_Id
1830 ,num_of_options = l_Bsc_Kpi_Entity_Rec.Bsc_Num_Options
1831 ,dependency_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Dependency_Flag
1832 ,parent_analysis_id = l_Bsc_Kpi_Entity_Rec.Bsc_Parent_Anal_Id
1833 ,change_dim_set = l_Bsc_Kpi_Entity_Rec.Bsc_Change_Dim_Set
1834 ,default_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
1835 ,short_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Ana_Group_Short_Name
1836 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1837 END IF;
1838
1839 if (p_commit = FND_API.G_TRUE) then
1840 commit;
1841 end if;
1842
1843
1844 EXCEPTION
1845 WHEN FND_API.G_EXC_ERROR THEN
1846 ROLLBACK TO BscKpiPvt_UpdKPIAnal;
1847 FND_MSG_PUB.Count_And_Get
1848 ( p_encoded => FND_API.G_FALSE
1849 , p_count => x_msg_count
1850 , p_data => x_msg_data
1851 );
1852 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1853 x_return_status := FND_API.G_RET_STS_ERROR;
1854 RAISE;
1855 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1856 ROLLBACK TO BscKpiPvt_UpdKPIAnal;
1857 FND_MSG_PUB.Count_And_Get
1858 ( p_encoded => FND_API.G_FALSE
1859 , p_count => x_msg_count
1860 , p_data => x_msg_data
1861 );
1862 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1863 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1864 RAISE;
1865 WHEN NO_DATA_FOUND THEN
1866 ROLLBACK TO BscKpiPvt_UpdKPIAnal;
1867 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1868 IF (x_msg_data IS NOT NULL) THEN
1869 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Analysis ';
1870 ELSE
1871 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Analysis ';
1872 END IF;
1873 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1874 RAISE;
1875 WHEN OTHERS THEN
1876 ROLLBACK TO BscKpiPvt_UpdKPIAnal;
1877 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1878 IF (x_msg_data IS NOT NULL) THEN
1879 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Analysis ';
1880 ELSE
1881 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Analysis ';
1882 END IF;
1883 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1884 RAISE;
1885 end Update_Kpi_Analysis;
1886
1887 /************************************************************************************
1888 ************************************************************************************/
1889
1890 procedure Delete_Kpi_Analysis(
1891 p_commit IN varchar2 := FND_API.G_FALSE
1892 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
1893 ,x_return_status OUT NOCOPY varchar2
1894 ,x_msg_count OUT NOCOPY number
1895 ,x_msg_data OUT NOCOPY varchar2
1896 ) is
1897
1898 l_count number;
1899
1900 begin
1901 FND_MSG_PUB.Initialize;
1902 x_return_status := FND_API.G_RET_STS_SUCCESS;
1903 SAVEPOINT BscKpiPvt_DelKPIAnal;
1904 -- Check that valid id was entered.
1905 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL) THEN
1906 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
1907 ,'indicator'
1908 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1909 IF(l_count = 0 )THEN
1910 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
1911 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1912 FND_MSG_PUB.ADD;
1913 RAISE FND_API.G_EXC_ERROR;
1914 END IF;
1915 ELSE
1916 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
1917 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
1918 FND_MSG_PUB.ADD;
1919 RAISE FND_API.G_EXC_ERROR;
1920 END IF;
1921
1922 DELETE
1923 FROM bsc_kpi_analysis_groups
1924 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1925
1926 DELETE
1927 FROM bsc_kpi_analysis_options_b
1928 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1929
1930 DELETE
1931 FROM bsc_kpi_analysis_options_tl
1932 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1933
1934 DELETE
1935 FROM bsc_kpi_analysis_measures_b
1936 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1937
1938 DELETE
1939 FROM bsc_kpi_analysis_measures_tl
1940 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1941
1942 DELETE
1943 FROM bsc_kpi_analysis_opt_user
1944 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1945
1946
1947 IF (p_commit = FND_API.G_TRUE) THEN
1948 COMMIT;
1949 END IF;
1950
1951 EXCEPTION
1952 WHEN FND_API.G_EXC_ERROR THEN
1953 ROLLBACK TO BscKpiPvt_DelKPIAnal;
1954 FND_MSG_PUB.Count_And_Get
1955 ( p_encoded => FND_API.G_FALSE
1956 , p_count => x_msg_count
1957 , p_data => x_msg_data
1958 );
1959 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
1960 x_return_status := FND_API.G_RET_STS_ERROR;
1961 RAISE;
1962 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1963 ROLLBACK TO BscKpiPvt_DelKPIAnal;
1964 FND_MSG_PUB.Count_And_Get
1965 ( p_encoded => FND_API.G_FALSE
1966 , p_count => x_msg_count
1967 , p_data => x_msg_data
1968 );
1969 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1970 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
1971 RAISE;
1972 WHEN NO_DATA_FOUND THEN
1973 ROLLBACK TO BscKpiPvt_DelKPIAnal;
1974 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1975 IF (x_msg_data IS NOT NULL) THEN
1976 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Analysis ';
1977 ELSE
1978 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Analysis ';
1979 END IF;
1980 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
1981 RAISE;
1982 WHEN OTHERS THEN
1983 ROLLBACK TO BscKpiPvt_DelKPIAnal;
1984 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1985 IF (x_msg_data IS NOT NULL) THEN
1986 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Analysis ';
1987 ELSE
1988 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Analysis ';
1989 END IF;
1990 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
1991 RAISE;
1992 end Delete_Kpi_Analysis;
1993
1994 /************************************************************************************
1995 ************************************************************************************/
1996
1997 procedure Delete_Objective_Color_Data(
1998 p_commit IN varchar2 := FND_API.G_FALSE
1999 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2000 ,x_return_status OUT NOCOPY varchar2
2001 ,x_msg_count OUT NOCOPY number
2002 ,x_msg_data OUT NOCOPY varchar2
2003 ) is
2004
2005 l_count number;
2006
2007 begin
2008 FND_MSG_PUB.Initialize;
2009 x_return_status := FND_API.G_RET_STS_SUCCESS;
2010 SAVEPOINT BscKpiPvt_DelObjColo;
2011 -- Check that valid id was entered.
2012 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL) THEN
2013 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2014 ,'indicator'
2015 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2016 IF(l_count = 0 )THEN
2017 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2018 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2019 FND_MSG_PUB.ADD;
2020 RAISE FND_API.G_EXC_ERROR;
2021 END IF;
2022 ELSE
2023 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2024 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2025 FND_MSG_PUB.ADD;
2026 RAISE FND_API.G_EXC_ERROR;
2027 END IF;
2028
2029 bsc_kpi_measure_props_pub.Delete_Obj_Kpi_Measure_Props (
2030 p_commit => FND_API.G_FALSE
2031 ,p_objective_id => p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2032 ,p_cascade_shared => FALSE
2033 ,x_return_status => x_return_status
2034 ,x_msg_count => x_msg_count
2035 ,x_msg_data => x_Msg_Data
2036 );
2037 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2038 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2039 END IF;
2040
2041 bsc_color_ranges_pub.Delete_Color_Prop_Ranges (
2042 p_commit => FND_API.G_FALSE
2043 ,p_objective_id => p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2044 ,p_kpi_measure_id => NULL
2045 ,p_cascade_shared => FALSE
2046 ,x_return_status => x_return_status
2047 ,x_msg_count => x_msg_count
2048 ,x_msg_data => x_Msg_Data
2049 );
2050 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2051 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2052 END IF;
2053
2054 bsc_kpi_measure_weights_pub.Del_Obj_Kpi_Measure_Weights (
2055 p_commit => FND_API.G_FALSE
2056 ,p_objective_id => p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2057 ,x_return_status => x_return_status
2058 ,x_msg_count => x_msg_count
2059 ,x_msg_data => x_Msg_Data
2060 );
2061 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2062 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2063 END IF;
2064
2065 IF (p_commit = FND_API.G_TRUE) THEN
2066 COMMIT;
2067 END IF;
2068
2069 EXCEPTION
2070 WHEN FND_API.G_EXC_ERROR THEN
2071 ROLLBACK TO BscKpiPvt_DelObjColo;
2072 FND_MSG_PUB.Count_And_Get
2073 ( p_encoded => FND_API.G_FALSE
2074 , p_count => x_msg_count
2075 , p_data => x_msg_data
2076 );
2077 x_return_status := FND_API.G_RET_STS_ERROR;
2078 RAISE;
2079 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2080 ROLLBACK TO BscKpiPvt_DelObjColo;
2081 FND_MSG_PUB.Count_And_Get
2082 ( p_encoded => FND_API.G_FALSE
2083 , p_count => x_msg_count
2084 , p_data => x_msg_data
2085 );
2086 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2087 RAISE;
2088 WHEN NO_DATA_FOUND THEN
2089 ROLLBACK TO BscKpiPvt_DelObjColo;
2090 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2091 IF (x_msg_data IS NOT NULL) THEN
2092 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Objective_Color_Data ';
2093 ELSE
2094 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Objective_Color_Data ';
2095 END IF;
2096 RAISE;
2097 WHEN OTHERS THEN
2098 ROLLBACK TO BscKpiPvt_DelObjColo;
2099 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2100 IF (x_msg_data IS NOT NULL) THEN
2101 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Objective_Color_Data ';
2102 ELSE
2103 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Objective_Color_Data ';
2104 END IF;
2105 RAISE;
2106 end Delete_Objective_Color_Data;
2107
2108 /************************************************************************************
2109 ************************************************************************************/
2110
2111 procedure Create_Kpi_Periodicity(
2112 p_commit IN varchar2 := FND_API.G_FALSE
2113 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2114 ,x_return_status OUT NOCOPY varchar2
2115 ,x_msg_count OUT NOCOPY number
2116 ,x_msg_data OUT NOCOPY varchar2
2117 ) is
2118
2119 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
2120
2121 l_db_object varchar2(30);
2122
2123 l_count number;
2124
2125 begin
2126 FND_MSG_PUB.Initialize;
2127 x_return_status := FND_API.G_RET_STS_SUCCESS;
2128 SAVEPOINT BscKpiPvt_CrtKPIPerid;
2129 -- Assign all values in the passed "Record" parameter to the locally defined
2130 -- "Record" variable.
2131 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
2132
2133 -- Check that valid id was entered.
2134 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2135 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2136 ,'indicator'
2137 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2138 if l_count = 0 then
2139 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2140 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2141 FND_MSG_PUB.ADD;
2142 RAISE FND_API.G_EXC_ERROR;
2143 end if;
2144 else
2145 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2146 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2147 FND_MSG_PUB.ADD;
2148 RAISE FND_API.G_EXC_ERROR;
2149 end if;
2150
2151 -- Check that periodicity is valid. If periodicity is null then make it 5, default
2152 -- periodicity.
2153 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id is not null then
2154 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_SYS_PERIODICITIES'
2155 ,'periodicity_id'
2156 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id);
2157 if l_count = 0 then
2158 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_PERIODICITY_ID');
2159 FND_MESSAGE.SET_TOKEN('BSC_PERIODICITY', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id);
2160 FND_MSG_PUB.ADD;
2161 RAISE FND_API.G_EXC_ERROR;
2162 end if;
2163 else
2164 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id := 5;
2165 end if;
2166
2167 -- set value for display order.
2168 select count(display_order)
2169 into l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display
2170 from BSC_KPI_PERIODICITIES
2171 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
2172
2173 l_db_object := 'BSC_KPI_PERIODICITIES';
2174
2175 insert into BSC_KPI_PERIODICITIES( indicator
2176 ,periodicity_id
2177 ,display_order
2178 ,previous_years
2179 ,num_of_years
2180 ,viewport_flag
2181 ,viewport_default_size
2182 ,user_level0
2183 ,user_level1
2184 ,user_level1_default
2185 ,user_level2
2186 ,user_level2_default
2187 ,current_period
2188 ,last_update_date)
2189 values( l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2190 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id
2191 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display
2192 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years
2193 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years
2194 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag
2195 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size
2196 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
2197 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
2198 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
2199 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
2200 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
2201 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period
2202 ,sysdate);
2203
2204 if (p_commit = FND_API.G_TRUE) then
2205 commit;
2206 end if;
2207
2208
2209 EXCEPTION
2210 WHEN FND_API.G_EXC_ERROR THEN
2211 ROLLBACK TO BscKpiPvt_CrtKPIPerid;
2212 FND_MSG_PUB.Count_And_Get
2213 ( p_encoded => FND_API.G_FALSE
2214 , p_count => x_msg_count
2215 , p_data => x_msg_data
2216 );
2217 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2218 x_return_status := FND_API.G_RET_STS_ERROR;
2219 RAISE;
2220 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2221 ROLLBACK TO BscKpiPvt_CrtKPIPerid;
2222 FND_MSG_PUB.Count_And_Get
2223 ( p_encoded => FND_API.G_FALSE
2224 , p_count => x_msg_count
2225 , p_data => x_msg_data
2226 );
2227 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2228 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2229 RAISE;
2230 WHEN NO_DATA_FOUND THEN
2231 ROLLBACK TO BscKpiPvt_CrtKPIPerid;
2232 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2233 IF (x_msg_data IS NOT NULL) THEN
2234 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Periodicity ';
2235 ELSE
2236 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Periodicity ';
2237 END IF;
2238 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2239 RAISE;
2240 WHEN OTHERS THEN
2241 ROLLBACK TO BscKpiPvt_CrtKPIPerid;
2242 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2243 if (SQLCODE = -01400) then
2244 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
2245 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
2246 FND_MSG_PUB.ADD;
2247 RAISE FND_API.G_EXC_ERROR;
2248 end if;
2249 IF (x_msg_data IS NOT NULL) THEN
2250 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Periodicity ';
2251 ELSE
2252 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Periodicity ';
2253 END IF;
2254 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2255 RAISE;
2256 end Create_Kpi_Periodicity;
2257
2258 /************************************************************************************
2259 ************************************************************************************/
2260
2261 procedure Retrieve_Kpi_Periodicity(
2262 p_commit IN varchar2 := FND_API.G_FALSE
2263 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2264 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2265 ,x_return_status OUT NOCOPY varchar2
2266 ,x_msg_count OUT NOCOPY number
2267 ,x_msg_data OUT NOCOPY varchar2
2268 ) is
2269
2270 l_db_object varchar2(30);
2271
2272 begin
2273 FND_MSG_PUB.Initialize;
2274 x_return_status := FND_API.G_RET_STS_SUCCESS;
2275
2276 l_db_object := 'Retrieve_Kpi_Periodicity';
2277
2278 select distinct display_order
2279 ,previous_years
2280 ,num_of_years
2281 ,viewport_flag
2282 ,viewport_default_size
2283 ,user_level0
2284 ,user_level1
2285 ,user_level1_default
2286 ,user_level2
2287 ,user_level2_default
2288 ,current_period
2289 ,last_update_date
2290 into x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display
2291 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years
2292 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years
2293 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag
2294 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size
2295 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
2296 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
2297 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
2298 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
2299 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
2300 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period
2301 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Date
2302 from BSC_KPI_PERIODICITIES
2303 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2304 and periodicity_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2305
2306 if (p_commit = FND_API.G_TRUE) then
2307 commit;
2308 end if;
2309
2310 EXCEPTION
2311 WHEN FND_API.G_EXC_ERROR THEN
2312 FND_MSG_PUB.Count_And_Get
2313 ( p_encoded => FND_API.G_FALSE
2314 , p_count => x_msg_count
2315 , p_data => x_msg_data
2316 );
2317 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2318 x_return_status := FND_API.G_RET_STS_ERROR;
2319 RAISE;
2320 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2321 FND_MSG_PUB.Count_And_Get
2322 ( p_encoded => FND_API.G_FALSE
2323 , p_count => x_msg_count
2324 , p_data => x_msg_data
2325 );
2326 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2327 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2328 RAISE;
2329 WHEN NO_DATA_FOUND THEN
2330 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2331 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2332 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
2333 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
2334 FND_MSG_PUB.ADD;
2335 RAISE FND_API.G_EXC_ERROR;
2336 WHEN OTHERS THEN
2337 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2338 IF (x_msg_data IS NOT NULL) THEN
2339 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Periodicity ';
2340 ELSE
2341 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Periodicity ';
2342 END IF;
2343 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2344 RAISE;
2345 end Retrieve_Kpi_Periodicity;
2346
2347 /************************************************************************************
2348 ************************************************************************************/
2349
2350 procedure Update_Kpi_Periodicity(
2351 p_commit IN varchar2 := FND_API.G_FALSE
2352 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2353 ,x_return_status OUT NOCOPY varchar2
2354 ,x_msg_count OUT NOCOPY number
2355 ,x_msg_data OUT NOCOPY varchar2
2356 ) is
2357
2358 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
2359
2360 l_count number;
2361
2362 begin
2363 FND_MSG_PUB.Initialize;
2364 x_return_status := FND_API.G_RET_STS_SUCCESS;
2365 SAVEPOINT BscKpiPvt_UptKPIPerid;
2366 -- Check that valid id was entered.
2367 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2368 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2369 ,'indicator'
2370 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2371 if l_count = 0 then
2372 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2373 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2374 FND_MSG_PUB.ADD;
2375 RAISE FND_API.G_EXC_ERROR;
2376 end if;
2377 else
2378 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2379 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2380 FND_MSG_PUB.ADD;
2381 RAISE FND_API.G_EXC_ERROR;
2382 end if;
2383
2384 -- Not all values will be passed. We need to make sure values not passed are not
2385 -- changed by procedure, therefore we get what is there before we do any updates.
2386 Retrieve_Kpi_Periodicity( p_commit
2387 ,p_Bsc_Kpi_Entity_Rec
2388 ,l_Bsc_Kpi_Entity_Rec
2389 ,x_return_status
2390 ,x_msg_count
2391 ,x_msg_data);
2392
2393 -- update LOCAL language ,source language and Kpi Id values with PASSED values.
2394 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
2395 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2396
2397
2398 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
2399 -- which are NOT NULL.
2400 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display is not null then
2401 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display;
2402 end if;
2403 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years is not null then
2404 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years;
2405 end if;
2406 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years is not null then
2407 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years;
2408 end if;
2409 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag is not null then
2410 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag;
2411 end if;
2412 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size is not null then
2413 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size;
2414 end if;
2415 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0 is not null then
2416 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0;
2417 end if;
2418 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1 is not null then
2419 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1;
2420 end if;
2421 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default is not null then
2422 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default;
2423 end if;
2424 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2 is not null then
2425 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2;
2426 end if;
2427 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default is not null then
2428 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default;
2429 end if;
2430 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period is not null then
2431 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period;
2432 end if;
2433 if p_Bsc_Kpi_Entity_Rec.Last_Update_Date is not null then
2434 l_Bsc_Kpi_Entity_Rec.Last_Update_Date := p_Bsc_Kpi_Entity_Rec.Last_Update_Date;
2435 end if;
2436
2437 update BSC_KPI_PERIODICITIES
2438 set display_order = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Display
2439 ,previous_years = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Previous_Years
2440 ,num_of_years = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Num_Years
2441 ,viewport_flag = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Flag
2442 ,viewport_default_size = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Viewport_Default_Size
2443 ,user_level0 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
2444 ,user_level1 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
2445 ,user_level1_default = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
2446 ,user_level2 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
2447 ,user_level2_default = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
2448 ,current_period = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Current_Period
2449 ,last_update_date = l_Bsc_Kpi_Entity_Rec.Last_Update_Date
2450 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2451 and periodicity_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2452
2453 if (p_commit = FND_API.G_TRUE) then
2454 commit;
2455 end if;
2456
2457
2458 EXCEPTION
2459 WHEN FND_API.G_EXC_ERROR THEN
2460 ROLLBACK TO BscKpiPvt_UptKPIPerid;
2461 FND_MSG_PUB.Count_And_Get
2462 ( p_encoded => FND_API.G_FALSE
2463 , p_count => x_msg_count
2464 , p_data => x_msg_data
2465 );
2466 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2467 x_return_status := FND_API.G_RET_STS_ERROR;
2468 RAISE;
2469 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2470 ROLLBACK TO BscKpiPvt_UptKPIPerid;
2471 FND_MSG_PUB.Count_And_Get
2472 ( p_encoded => FND_API.G_FALSE
2473 , p_count => x_msg_count
2474 , p_data => x_msg_data
2475 );
2476 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2477 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2478 RAISE;
2479 WHEN NO_DATA_FOUND THEN
2480 ROLLBACK TO BscKpiPvt_UptKPIPerid;
2481 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2482 IF (x_msg_data IS NOT NULL) THEN
2483 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Periodicity ';
2484 ELSE
2485 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Periodicity ';
2486 END IF;
2487 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2488 RAISE;
2489 WHEN OTHERS THEN
2490 ROLLBACK TO BscKpiPvt_UptKPIPerid;
2491 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2492 IF (x_msg_data IS NOT NULL) THEN
2493 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Periodicity ';
2494 ELSE
2495 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Periodicity ';
2496 END IF;
2497 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2498 RAISE;
2499 end Update_Kpi_Periodicity;
2500
2501 /************************************************************************************
2502 ************************************************************************************/
2503
2504 procedure Delete_Kpi_Periodicity(
2505 p_commit IN varchar2 := FND_API.G_FALSE
2506 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2507 ,x_return_status OUT NOCOPY varchar2
2508 ,x_msg_count OUT NOCOPY number
2509 ,x_msg_data OUT NOCOPY varchar2
2510 ) is
2511
2512 l_count number;
2513
2514 begin
2515 FND_MSG_PUB.Initialize;
2516 x_return_status := FND_API.G_RET_STS_SUCCESS;
2517 SAVEPOINT BscKpiPvt_DelKPIPerid;
2518 -- Check that valid id was entered.
2519 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2520 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2521 ,'indicator'
2522 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2523 if l_count = 0 then
2524 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2525 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2526 FND_MSG_PUB.ADD;
2527 RAISE FND_API.G_EXC_ERROR;
2528 end if;
2529 else
2530 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2531 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2532 FND_MSG_PUB.ADD;
2533 RAISE FND_API.G_EXC_ERROR;
2534 end if;
2535
2536 delete from BSC_KPI_PERIODICITIES
2537 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
2538
2539 if (p_commit = FND_API.G_TRUE) then
2540 commit;
2541 end if;
2542
2543 EXCEPTION
2544 WHEN FND_API.G_EXC_ERROR THEN
2545 ROLLBACK TO BscKpiPvt_DelKPIPerid;
2546 FND_MSG_PUB.Count_And_Get
2547 ( p_encoded => FND_API.G_FALSE
2548 , p_count => x_msg_count
2549 , p_data => x_msg_data
2550 );
2551 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2552 x_return_status := FND_API.G_RET_STS_ERROR;
2553 RAISE;
2554 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2555 ROLLBACK TO BscKpiPvt_DelKPIPerid;
2556 FND_MSG_PUB.Count_And_Get
2557 ( p_encoded => FND_API.G_FALSE
2558 , p_count => x_msg_count
2559 , p_data => x_msg_data
2560 );
2561 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2562 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2563 RAISE;
2564 WHEN NO_DATA_FOUND THEN
2565 ROLLBACK TO BscKpiPvt_DelKPIPerid;
2566 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2567 IF (x_msg_data IS NOT NULL) THEN
2568 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Periodicity ';
2569 ELSE
2570 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Periodicity ';
2571 END IF;
2572 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2573 RAISE;
2574 WHEN OTHERS THEN
2575 ROLLBACK TO BscKpiPvt_DelKPIPerid;
2576 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2577 IF (x_msg_data IS NOT NULL) THEN
2578 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Periodicity ';
2579 ELSE
2580 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Periodicity ';
2581 END IF;
2582 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2583 RAISE;
2584
2585 end Delete_Kpi_Periodicity;
2586
2587 /************************************************************************************
2588 ************************************************************************************/
2589
2590 procedure Create_Kpi_Data_Tables(
2591 p_commit IN varchar2 := FND_API.G_FALSE
2592 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2593 ,x_return_status OUT NOCOPY varchar2
2594 ,x_msg_count OUT NOCOPY number
2595 ,x_msg_data OUT NOCOPY varchar2
2596 ) is
2597
2598 l_db_object varchar2(30);
2599
2600 l_count number;
2601
2602 begin
2603 FND_MSG_PUB.Initialize;
2604 x_return_status := FND_API.G_RET_STS_SUCCESS;
2605 SAVEPOINT BscKpiPvt_CrtKPIDaTab;
2606 -- Check that valid id was entered.
2607 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2608 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2609 ,'indicator'
2610 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2611 if l_count = 0 then
2612 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2613 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2614 FND_MSG_PUB.ADD;
2615 RAISE FND_API.G_EXC_ERROR;
2616 end if;
2617 else
2618 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2619 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2620 FND_MSG_PUB.ADD;
2621 RAISE FND_API.G_EXC_ERROR;
2622 end if;
2623
2624 l_db_object := 'BSC_KPI_DATA_TABLES';
2625
2626 insert into BSC_KPI_DATA_TABLES( indicator
2627 ,periodicity_id
2628 ,dim_set_id
2629 ,level_comb
2630 ,table_name
2631 ,filter_condition)
2632 values( p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2633 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id
2634 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
2635 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb
2636 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name
2637 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition);
2638
2639 if (p_commit = FND_API.G_TRUE) then
2640 commit;
2641 end if;
2642
2643
2644 EXCEPTION
2645 WHEN FND_API.G_EXC_ERROR THEN
2646 ROLLBACK TO BscKpiPvt_CrtKPIDaTab;
2647 FND_MSG_PUB.Count_And_Get
2648 ( p_encoded => FND_API.G_FALSE
2649 , p_count => x_msg_count
2650 , p_data => x_msg_data
2651 );
2652 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2653 x_return_status := FND_API.G_RET_STS_ERROR;
2654 RAISE;
2655 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2656 ROLLBACK TO BscKpiPvt_CrtKPIDaTab;
2657 FND_MSG_PUB.Count_And_Get
2658 ( p_encoded => FND_API.G_FALSE
2659 , p_count => x_msg_count
2660 , p_data => x_msg_data
2661 );
2662 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2663 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2664 RAISE;
2665 WHEN NO_DATA_FOUND THEN
2666 ROLLBACK TO BscKpiPvt_CrtKPIDaTab;
2667 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2668 IF (x_msg_data IS NOT NULL) THEN
2669 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Data_Tables ';
2670 ELSE
2671 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Data_Tables ';
2672 END IF;
2673 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2674 RAISE;
2675 WHEN OTHERS THEN
2676 ROLLBACK TO BscKpiPvt_CrtKPIDaTab;
2677 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2678 if (SQLCODE = -01400) then
2679 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
2680 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
2681 FND_MSG_PUB.ADD;
2682 RAISE FND_API.G_EXC_ERROR;
2683 end if;
2684 IF (x_msg_data IS NOT NULL) THEN
2685 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Data_Tables ';
2686 ELSE
2687 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Data_Tables ';
2688 END IF;
2689 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2690 RAISE;
2691 end Create_Kpi_Data_Tables;
2692
2693 /************************************************************************************
2694 ************************************************************************************/
2695
2696 procedure Retrieve_Kpi_Data_Tables(
2697 p_commit IN varchar2 := FND_API.G_FALSE
2698 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2699 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2700 ,x_return_status OUT NOCOPY varchar2
2701 ,x_msg_count OUT NOCOPY number
2702 ,x_msg_data OUT NOCOPY varchar2
2703 ) is
2704
2705 l_db_object varchar2(30);
2706
2707 begin
2708 FND_MSG_PUB.Initialize;
2709 x_return_status := FND_API.G_RET_STS_SUCCESS;
2710 l_db_object := 'Retrieve_Kpi_Data_Tables';
2711
2712 select distinct level_comb
2713 ,table_name
2714 ,filter_condition
2715 into x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb
2716 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name
2717 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition
2718 from BSC_KPI_DATA_TABLES
2719 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2720 and dim_set_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
2721 and periodicity_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2722
2723 if (p_commit = FND_API.G_TRUE) then
2724 commit;
2725 end if;
2726
2727 EXCEPTION
2728 WHEN FND_API.G_EXC_ERROR THEN
2729 FND_MSG_PUB.Count_And_Get
2730 ( p_encoded => FND_API.G_FALSE
2731 , p_count => x_msg_count
2732 , p_data => x_msg_data
2733 );
2734 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2735 x_return_status := FND_API.G_RET_STS_ERROR;
2736 RAISE;
2737 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2738 FND_MSG_PUB.Count_And_Get
2739 ( p_encoded => FND_API.G_FALSE
2740 , p_count => x_msg_count
2741 , p_data => x_msg_data
2742 );
2743 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2744 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2745 RAISE;
2746 WHEN NO_DATA_FOUND THEN
2747 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2748 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2749 FND_MSG_PUB.Initialize;
2750 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
2751 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
2752 FND_MSG_PUB.ADD;
2753 RAISE FND_API.G_EXC_ERROR;
2754 WHEN OTHERS THEN
2755 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2756 IF (x_msg_data IS NOT NULL) THEN
2757 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Data_Tables ';
2758 ELSE
2759 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Data_Tables ';
2760 END IF;
2761 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2762 RAISE;
2763 end Retrieve_Kpi_Data_Tables;
2764
2765 /************************************************************************************
2766 ************************************************************************************/
2767
2768 procedure Update_Kpi_Data_Tables(
2769 p_commit IN varchar2 := FND_API.G_FALSE
2770 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2771 ,x_return_status OUT NOCOPY varchar2
2772 ,x_msg_count OUT NOCOPY number
2773 ,x_msg_data OUT NOCOPY varchar2
2774 ) is
2775
2776 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
2777
2778 l_count number;
2779
2780 begin
2781 FND_MSG_PUB.Initialize;
2782 x_return_status := FND_API.G_RET_STS_SUCCESS;
2783 SAVEPOINT BscKpiPvt_UptKPIDaTab;
2784 -- Check that valid id was entered.
2785 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2786 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2787 ,'indicator'
2788 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2789 if l_count = 0 then
2790 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2791 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2792 FND_MSG_PUB.ADD;
2793 RAISE FND_API.G_EXC_ERROR;
2794 end if;
2795 else
2796 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2797 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2798 FND_MSG_PUB.ADD;
2799 RAISE FND_API.G_EXC_ERROR;
2800 end if;
2801
2802 -- Not all values will be passed. We need to make sure values not passed are not
2803 -- changed by procedure, therefore we get what is there before we do any updates.
2804 Retrieve_Kpi_Data_Tables( p_commit
2805 ,p_Bsc_Kpi_Entity_Rec
2806 ,l_Bsc_Kpi_Entity_Rec
2807 ,x_return_status
2808 ,x_msg_count
2809 ,x_msg_data);
2810
2811 -- update LOCAL language ,source language and Kpi Id values with PASSED values.
2812 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
2813 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id;
2814 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2815
2816
2817 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
2818 -- which are NOT NULL.
2819 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb is not null then
2820 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb;
2821 end if;
2822 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name is not null then
2823 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name;
2824 end if;
2825 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition is not null then
2826 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition;
2827 end if;
2828
2829 update BSC_KPI_DATA_TABLES
2830 set level_comb = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Level_Comb
2831 ,table_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Table_Name
2832 ,filter_condition = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Filter_Condition
2833 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2834 and dim_set_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
2835 and periodicity_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Periodicity_Id;
2836
2837 if (p_commit = FND_API.G_TRUE) then
2838 commit;
2839 end if;
2840
2841 EXCEPTION
2842 WHEN FND_API.G_EXC_ERROR THEN
2843 ROLLBACK TO BscKpiPvt_UptKPIDaTab;
2844 FND_MSG_PUB.Count_And_Get
2845 ( p_encoded => FND_API.G_FALSE
2846 , p_count => x_msg_count
2847 , p_data => x_msg_data
2848 );
2849 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2850 x_return_status := FND_API.G_RET_STS_ERROR;
2851 RAISE;
2852 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2853 ROLLBACK TO BscKpiPvt_UptKPIDaTab;
2854 FND_MSG_PUB.Count_And_Get
2855 ( p_encoded => FND_API.G_FALSE
2856 , p_count => x_msg_count
2857 , p_data => x_msg_data
2858 );
2859 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2860 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2861 RAISE;
2862 WHEN NO_DATA_FOUND THEN
2863 ROLLBACK TO BscKpiPvt_UptKPIDaTab;
2864 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2865 IF (x_msg_data IS NOT NULL) THEN
2866 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Data_Tables ';
2867 ELSE
2868 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Data_Tables ';
2869 END IF;
2870 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2871 RAISE;
2872 WHEN OTHERS THEN
2873 ROLLBACK TO BscKpiPvt_UptKPIDaTab;
2874 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2875 IF (x_msg_data IS NOT NULL) THEN
2876 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Data_Tables ';
2877 ELSE
2878 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Data_Tables ';
2879 END IF;
2880 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2881 RAISE;
2882 end Update_Kpi_Data_Tables;
2883
2884 /************************************************************************************
2885 ************************************************************************************/
2886
2887 procedure Delete_Kpi_Data_Tables(
2888 p_commit IN varchar2 := FND_API.G_FALSE
2889 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2890 ,x_return_status OUT NOCOPY varchar2
2891 ,x_msg_count OUT NOCOPY number
2892 ,x_msg_data OUT NOCOPY varchar2
2893 ) is
2894
2895 l_count number;
2896 l_Delete_Kpi_Data BOOLEAN := TRUE;
2897
2898 begin
2899 FND_MSG_PUB.Initialize;
2900 x_return_status := FND_API.G_RET_STS_SUCCESS;
2901 SAVEPOINT BscKpiPvt_DelKPIDaTab;
2902 -- Check that valid id was entered.
2903 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
2904 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
2905 ,'indicator'
2906 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2907 if l_count = 0 then
2908 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
2909 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2910 FND_MSG_PUB.ADD;
2911 RAISE FND_API.G_EXC_ERROR;
2912 end if;
2913 else
2914 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
2915 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
2916 FND_MSG_PUB.ADD;
2917 RAISE FND_API.G_EXC_ERROR;
2918 end if;
2919
2920 -- Added for Bug #3248729
2921 IF BSC_UTILITY.isBscInProductionMode THEN
2922
2923 SELECT COUNT(INDICATOR)
2924 INTO l_count
2925 FROM BSC_KPI_DATA_TABLES
2926 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
2927 AND TABLE_NAME IS NOT NULL; -- need to check if actual KPI Tables are there
2928
2929 IF l_count > 0 THEN
2930 l_Delete_Kpi_Data := FALSE;
2931 END IF;
2932
2933 END IF;
2934
2935
2936 IF (l_Delete_Kpi_Data) THEN
2937
2938 DELETE FROM BSC_KPI_DATA_TABLES
2939 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
2940
2941 END IF;
2942
2943 if (p_commit = FND_API.G_TRUE) then
2944 commit;
2945 end if;
2946 -- Added for Bug #3248729
2947
2948 EXCEPTION
2949 WHEN FND_API.G_EXC_ERROR THEN
2950 ROLLBACK TO BscKpiPvt_DelKPIDaTab;
2951 FND_MSG_PUB.Count_And_Get
2952 ( p_encoded => FND_API.G_FALSE
2953 , p_count => x_msg_count
2954 , p_data => x_msg_data
2955 );
2956 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
2957 x_return_status := FND_API.G_RET_STS_ERROR;
2958 RAISE;
2959 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2960 ROLLBACK TO BscKpiPvt_DelKPIDaTab;
2961 FND_MSG_PUB.Count_And_Get
2962 ( p_encoded => FND_API.G_FALSE
2963 , p_count => x_msg_count
2964 , p_data => x_msg_data
2965 );
2966 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2967 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
2968 RAISE;
2969 WHEN NO_DATA_FOUND THEN
2970 ROLLBACK TO BscKpiPvt_DelKPIDaTab;
2971 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2972 IF (x_msg_data IS NOT NULL) THEN
2973 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Data_Tables ';
2974 ELSE
2975 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Data_Tables ';
2976 END IF;
2977 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
2978 RAISE;
2979 WHEN OTHERS THEN
2980 ROLLBACK TO BscKpiPvt_DelKPIDaTab;
2981 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2982 IF (x_msg_data IS NOT NULL) THEN
2983 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Data_Tables ';
2984 ELSE
2985 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Data_Tables ';
2986 END IF;
2987 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
2988 RAISE;
2989 end Delete_Kpi_Data_Tables;
2990
2991 /************************************************************************************
2992 ************************************************************************************/
2993
2994 procedure Create_Kpi_Calculations(
2995 p_commit IN varchar2 := FND_API.G_FALSE
2996 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
2997 ,x_return_status OUT NOCOPY varchar2
2998 ,x_msg_count OUT NOCOPY number
2999 ,x_msg_data OUT NOCOPY varchar2
3000 ) is
3001
3002 l_db_object varchar2(30);
3003
3004 l_count number;
3005
3006 begin
3007 FND_MSG_PUB.Initialize;
3008 x_return_status := FND_API.G_RET_STS_SUCCESS;
3009 SAVEPOINT BscKpiPvt_CrtKPICalc;
3010 -- Check that valid id was entered.
3011 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3012 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3013 ,'indicator'
3014 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3015 if l_count = 0 then
3016 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3017 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3018 FND_MSG_PUB.ADD;
3019 RAISE FND_API.G_EXC_ERROR;
3020 end if;
3021 else
3022 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3023 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3024 FND_MSG_PUB.ADD;
3025 RAISE FND_API.G_EXC_ERROR;
3026 end if;
3027
3028 l_db_object := 'BSC_KPI_CALCULATIONS';
3029
3030 insert into BSC_KPI_CALCULATIONS( indicator
3031 ,calculation_id
3032 ,user_level0
3033 ,user_level1
3034 ,user_level1_default
3035 ,user_level2
3036 ,user_level2_default
3037 ,default_value)
3038 values( p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3039 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id
3040 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
3041 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
3042 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
3043 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
3044 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
3045 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value);
3046
3047 if (p_commit = FND_API.G_TRUE) then
3048 commit;
3049 end if;
3050
3051 EXCEPTION
3052 WHEN FND_API.G_EXC_ERROR THEN
3053 ROLLBACK TO BscKpiPvt_CrtKPICalc;
3054 FND_MSG_PUB.Count_And_Get
3055 ( p_encoded => FND_API.G_FALSE
3056 , p_count => x_msg_count
3057 , p_data => x_msg_data
3058 );
3059 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3060 x_return_status := FND_API.G_RET_STS_ERROR;
3061 RAISE;
3062 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3063 ROLLBACK TO BscKpiPvt_CrtKPICalc;
3064 FND_MSG_PUB.Count_And_Get
3065 ( p_encoded => FND_API.G_FALSE
3066 , p_count => x_msg_count
3067 , p_data => x_msg_data
3068 );
3069 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3070 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3071 RAISE;
3072 WHEN NO_DATA_FOUND THEN
3073 ROLLBACK TO BscKpiPvt_CrtKPICalc;
3074 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3075 IF (x_msg_data IS NOT NULL) THEN
3076 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Calculations ';
3077 ELSE
3078 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Calculations ';
3079 END IF;
3080 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3081 RAISE;
3082 WHEN OTHERS THEN
3083 ROLLBACK TO BscKpiPvt_CrtKPICalc;
3084 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3085 if (SQLCODE = -01400) then
3086 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
3087 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
3088 FND_MSG_PUB.ADD;
3089 RAISE FND_API.G_EXC_ERROR;
3090 end if;
3091 IF (x_msg_data IS NOT NULL) THEN
3092 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Calculations ';
3093 ELSE
3094 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Calculations ';
3095 END IF;
3096 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3097 RAISE;
3098 end Create_Kpi_Calculations;
3099
3100 /************************************************************************************
3101 ************************************************************************************/
3102
3103 procedure Retrieve_Kpi_Calculations(
3104 p_commit IN varchar2 := FND_API.G_FALSE
3105 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3106 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3107 ,x_return_status OUT NOCOPY varchar2
3108 ,x_msg_count OUT NOCOPY number
3109 ,x_msg_data OUT NOCOPY varchar2
3110 ) is
3111
3112 l_db_object varchar2(30);
3113
3114 begin
3115 FND_MSG_PUB.Initialize;
3116 x_return_status := FND_API.G_RET_STS_SUCCESS;
3117 l_db_object := 'Retrieve_Kpi_Calculations';
3118
3119 select distinct user_level0
3120 ,user_level1
3121 ,user_level1_default
3122 ,user_level2
3123 ,user_level2_default
3124 ,default_value
3125 into x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
3126 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
3127 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
3128 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
3129 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
3130 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
3131 from BSC_KPI_CALCULATIONS
3132 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3133 and calculation_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id;
3134
3135 if (p_commit = FND_API.G_TRUE) then
3136 commit;
3137 end if;
3138
3139 EXCEPTION
3140 WHEN FND_API.G_EXC_ERROR THEN
3141 FND_MSG_PUB.Count_And_Get
3142 ( p_encoded => FND_API.G_FALSE
3143 , p_count => x_msg_count
3144 , p_data => x_msg_data
3145 );
3146 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3147 x_return_status := FND_API.G_RET_STS_ERROR;
3148 RAISE;
3149 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3150 FND_MSG_PUB.Count_And_Get
3151 ( p_encoded => FND_API.G_FALSE
3152 , p_count => x_msg_count
3153 , p_data => x_msg_data
3154 );
3155 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3156 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3157 RAISE;
3158 WHEN NO_DATA_FOUND THEN
3159 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3160 FND_MSG_PUB.Initialize;
3161 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
3162 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
3163 FND_MSG_PUB.ADD;
3164 RAISE FND_API.G_EXC_ERROR;
3165 WHEN OTHERS THEN
3166 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3167 IF (x_msg_data IS NOT NULL) THEN
3168 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Calculations ';
3169 ELSE
3170 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Calculations ';
3171 END IF;
3172 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3173 RAISE;
3174 end Retrieve_Kpi_Calculations;
3175
3176 /************************************************************************************
3177 ************************************************************************************/
3178
3179 procedure Update_Kpi_Calculations(
3180 p_commit IN varchar2 := FND_API.G_FALSE
3181 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3182 ,x_return_status OUT NOCOPY varchar2
3183 ,x_msg_count OUT NOCOPY number
3184 ,x_msg_data OUT NOCOPY varchar2
3185 ) is
3186
3187 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
3188
3189 l_count number;
3190
3191 begin
3192 FND_MSG_PUB.Initialize;
3193 x_return_status := FND_API.G_RET_STS_SUCCESS;
3194 SAVEPOINT BscKpiPvt_UptKPICalc;
3195 -- Check that valid id was entered.
3196 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3197 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3198 ,'indicator'
3199 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3200 if l_count = 0 then
3201 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3202 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3203 FND_MSG_PUB.ADD;
3204 RAISE FND_API.G_EXC_ERROR;
3205 end if;
3206 else
3207 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3208 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3209 FND_MSG_PUB.ADD;
3210 RAISE FND_API.G_EXC_ERROR;
3211 end if;
3212
3213 -- Check that valid id was entered.
3214 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id is not null then
3215 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPI_CALCULATIONS'
3216 ,'calculation_id'
3217 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id);
3218 if l_count = 0 then
3219 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_CALCULATION_ID');
3220 FND_MESSAGE.SET_TOKEN('BSC_CALCULATION', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id);
3221 FND_MSG_PUB.ADD;
3222 RAISE FND_API.G_EXC_ERROR;
3223 end if;
3224 else
3225 FND_MESSAGE.SET_NAME('BSC','BSC_NO_CALCULATION_ID_ENTERED');
3226 FND_MESSAGE.SET_TOKEN('BSC_CALCULATION', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id);
3227 FND_MSG_PUB.ADD;
3228 RAISE FND_API.G_EXC_ERROR;
3229 end if;
3230
3231 -- Not all values will be passed. We need to make sure values not passed are not
3232 -- changed by procedure, therefore we get what is there before we do any updates.
3233 Retrieve_Kpi_Calculations( p_commit
3234 ,p_Bsc_Kpi_Entity_Rec
3235 ,l_Bsc_Kpi_Entity_Rec
3236 ,x_return_status
3237 ,x_msg_count
3238 ,x_msg_data);
3239
3240 -- update LOCAL Kpi Id values with PASSED values.
3241 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3242 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id;
3243
3244 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
3245 -- which are NOT NULL.
3246 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0 is not null then
3247 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0;
3248 end if;
3249 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1 is not null then
3250 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1;
3251 end if;
3252 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default is not null then
3253 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default;
3254 end if;
3255 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2 is not null then
3256 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2 := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2;
3257 end if;
3258 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default is not null then
3259 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default;
3260 end if;
3261 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value is not null then
3262 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value;
3263 end if;
3264
3265 update BSC_KPI_CALCULATIONS
3266 set user_level0 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level0
3267 ,user_level1 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1
3268 ,user_level1_default = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level1_Default
3269 ,user_level2 = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2
3270 ,user_level2_default = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_User_Level2_Default
3271 ,default_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Default_Value
3272 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3273 and calculation_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Calculation_Id;
3274
3275 if (p_commit = FND_API.G_TRUE) then
3276 commit;
3277 end if;
3278
3279 EXCEPTION
3280 WHEN FND_API.G_EXC_ERROR THEN
3281 ROLLBACK TO BscKpiPvt_UptKPICalc;
3282 FND_MSG_PUB.Count_And_Get
3283 ( p_encoded => FND_API.G_FALSE
3284 , p_count => x_msg_count
3285 , p_data => x_msg_data
3286 );
3287 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3288 x_return_status := FND_API.G_RET_STS_ERROR;
3289 RAISE;
3290 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3291 ROLLBACK TO BscKpiPvt_UptKPICalc;
3292 FND_MSG_PUB.Count_And_Get
3293 ( p_encoded => FND_API.G_FALSE
3294 , p_count => x_msg_count
3295 , p_data => x_msg_data
3296 );
3297 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3298 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3299 RAISE;
3300 WHEN NO_DATA_FOUND THEN
3301 ROLLBACK TO BscKpiPvt_UptKPICalc;
3302 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3303 IF (x_msg_data IS NOT NULL) THEN
3304 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Calculations ';
3305 ELSE
3306 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Calculations ';
3307 END IF;
3308 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3309 RAISE;
3310 WHEN OTHERS THEN
3311 ROLLBACK TO BscKpiPvt_UptKPICalc;
3312 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3313 IF (x_msg_data IS NOT NULL) THEN
3314 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Calculations ';
3315 ELSE
3316 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Calculations ';
3317 END IF;
3318 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3319 RAISE;
3320 end Update_Kpi_Calculations;
3321
3322 /************************************************************************************
3323 ************************************************************************************/
3324
3325 procedure Delete_Kpi_Calculations(
3326 p_commit IN varchar2 := FND_API.G_FALSE
3327 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3328 ,x_return_status OUT NOCOPY varchar2
3329 ,x_msg_count OUT NOCOPY number
3330 ,x_msg_data OUT NOCOPY varchar2
3331 ) is
3332
3333 l_count number;
3334
3335 BEGIN
3336 FND_MSG_PUB.Initialize;
3337 x_return_status := FND_API.G_RET_STS_SUCCESS;
3338 SAVEPOINT BscKpiPvt_DelKPICalc;
3339 -- Check that valid id was entered.
3340 IF(p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL) THEN
3341 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3342 ,'indicator'
3343 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3344 IF (l_count = 0) THEN
3345 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3346 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3347 FND_MSG_PUB.ADD;
3348 RAISE FND_API.G_EXC_ERROR;
3349 END IF;
3350 ELSE
3351 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3352 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3353 FND_MSG_PUB.ADD;
3354 RAISE FND_API.G_EXC_ERROR;
3355 END IF;
3356
3357 DELETE
3358 FROM bsc_kpi_calculations
3359 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3360
3361 DELETE
3362 FROM bsc_kpi_calculations_user
3363 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3364
3365 IF (p_commit = FND_API.G_TRUE) THEN
3366 COMMIT;
3367 END IF;
3368
3369 EXCEPTION
3370 WHEN FND_API.G_EXC_ERROR THEN
3371 ROLLBACK TO BscKpiPvt_DelKPICalc;
3372 FND_MSG_PUB.Count_And_Get
3373 ( p_encoded => FND_API.G_FALSE
3374 , p_count => x_msg_count
3375 , p_data => x_msg_data
3376 );
3377 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3378 x_return_status := FND_API.G_RET_STS_ERROR;
3379 RAISE;
3380 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3381 ROLLBACK TO BscKpiPvt_DelKPICalc;
3382 FND_MSG_PUB.Count_And_Get
3383 ( p_encoded => FND_API.G_FALSE
3384 , p_count => x_msg_count
3385 , p_data => x_msg_data
3386 );
3387 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3388 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3389 RAISE;
3390 WHEN NO_DATA_FOUND THEN
3391 ROLLBACK TO BscKpiPvt_DelKPICalc;
3392 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3393 IF (x_msg_data IS NOT NULL) THEN
3394 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Calculations ';
3395 ELSE
3396 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Calculations ';
3397 END IF;
3398 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3399 RAISE;
3400 WHEN OTHERS THEN
3401 ROLLBACK TO BscKpiPvt_DelKPICalc;
3402 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3403 IF (x_msg_data IS NOT NULL) THEN
3404 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Calculations ';
3405 ELSE
3406 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Calculations ';
3407 END IF;
3408 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3409 RAISE;
3410 end Delete_Kpi_Calculations;
3411
3412 /************************************************************************************
3413 ************************************************************************************/
3414
3415 procedure Create_Kpi_User_Access(
3416 p_commit IN varchar2 := FND_API.G_FALSE
3417 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3418 ,x_return_status OUT NOCOPY varchar2
3419 ,x_msg_count OUT NOCOPY number
3420 ,x_msg_data OUT NOCOPY varchar2
3421 ) is
3422
3423 l_db_object varchar2(30);
3424
3425 l_count number;
3426
3427 begin
3428 FND_MSG_PUB.Initialize;
3429 x_return_status := FND_API.G_RET_STS_SUCCESS;
3430 SAVEPOINT BscKpiPvt_CrtKPIUsrAcc;
3431 -- Check that valid id was entered.
3432 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3433 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3434 ,'indicator'
3435 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3436 if l_count = 0 then
3437 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3438 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3439 FND_MSG_PUB.ADD;
3440 RAISE FND_API.G_EXC_ERROR;
3441 end if;
3442 else
3443 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3444 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3445 FND_MSG_PUB.ADD;
3446 RAISE FND_API.G_EXC_ERROR;
3447 end if;
3448
3449 l_db_object := 'BSC_USER_KPI_ACCESS';
3450
3451
3452 insert into BSC_USER_KPI_ACCESS( responsibility_id
3453 ,indicator
3454 ,creation_date
3455 ,created_by
3456 ,last_update_date
3457 ,last_updated_by
3458 ,last_update_login
3459 ,start_date
3460 ,end_date)
3461 values( p_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id
3462 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3463 ,sysdate
3464 ,p_Bsc_Kpi_Entity_Rec.Created_By
3465 ,sysdate
3466 ,p_Bsc_Kpi_Entity_Rec.Last_Updated_By
3467 ,p_Bsc_Kpi_Entity_Rec.Last_Update_Login
3468 ,p_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date
3469 ,p_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date);
3470
3471
3472
3473
3474 if (p_commit = FND_API.G_TRUE) then
3475 commit;
3476 end if;
3477
3478
3479 EXCEPTION
3480 WHEN FND_API.G_EXC_ERROR THEN
3481 ROLLBACK TO BscKpiPvt_CrtKPIUsrAcc;
3482 FND_MSG_PUB.Count_And_Get
3483 ( p_encoded => FND_API.G_FALSE
3484 , p_count => x_msg_count
3485 , p_data => x_msg_data
3486 );
3487 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3488 x_return_status := FND_API.G_RET_STS_ERROR;
3489 RAISE;
3490 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3491 ROLLBACK TO BscKpiPvt_CrtKPIUsrAcc;
3492 FND_MSG_PUB.Count_And_Get
3493 ( p_encoded => FND_API.G_FALSE
3494 , p_count => x_msg_count
3495 , p_data => x_msg_data
3496 );
3497 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3498 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3499 RAISE;
3500 WHEN NO_DATA_FOUND THEN
3501 ROLLBACK TO BscKpiPvt_CrtKPIUsrAcc;
3502 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3503 if (SQLCODE = -01400) then
3504 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
3505 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
3506 FND_MSG_PUB.ADD;
3507 RAISE FND_API.G_EXC_ERROR;
3508 end if;
3509 IF (x_msg_data IS NOT NULL) THEN
3510 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_User_Access ';
3511 ELSE
3512 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_User_Access ';
3513 END IF;
3514 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3515 RAISE;
3516 WHEN OTHERS THEN
3517 ROLLBACK TO BscKpiPvt_CrtKPIUsrAcc;
3518 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3519 IF (x_msg_data IS NOT NULL) THEN
3520 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_User_Access ';
3521 ELSE
3522 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_User_Access ';
3523 END IF;
3524 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3525 RAISE;
3526 end Create_Kpi_User_Access;
3527
3528 /************************************************************************************
3529 ************************************************************************************/
3530
3531 procedure Retrieve_Kpi_User_Access(
3532 p_commit IN varchar2 := FND_API.G_FALSE
3533 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3534 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3535 ,x_return_status OUT NOCOPY varchar2
3536 ,x_msg_count OUT NOCOPY number
3537 ,x_msg_data OUT NOCOPY varchar2
3538 ) is
3539
3540 l_db_object varchar2(30);
3541
3542 begin
3543 FND_MSG_PUB.Initialize;
3544 x_return_status := FND_API.G_RET_STS_SUCCESS;
3545 l_db_object := 'Retrieve_Kpi_User_Access';
3546
3547 select distinct responsibility_id
3548 ,creation_date
3549 ,created_by
3550 ,last_update_date
3551 ,last_updated_by
3552 ,last_update_login
3553 ,start_date
3554 ,end_date
3555 into x_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id
3556 ,x_Bsc_Kpi_Entity_Rec.Creation_Date
3557 ,x_Bsc_Kpi_Entity_Rec.Created_By
3558 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Date
3559 ,x_Bsc_Kpi_Entity_Rec.Last_Updated_By
3560 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Login
3561 ,x_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date
3562 ,x_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date
3563 from BSC_USER_KPI_ACCESS
3564 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3565 and responsibility_id = p_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id;
3566
3567
3568 if (p_commit = FND_API.G_TRUE) then
3569 commit;
3570 end if;
3571
3572 EXCEPTION
3573 WHEN FND_API.G_EXC_ERROR THEN
3574 FND_MSG_PUB.Count_And_Get
3575 ( p_encoded => FND_API.G_FALSE
3576 , p_count => x_msg_count
3577 , p_data => x_msg_data
3578 );
3579 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3580 x_return_status := FND_API.G_RET_STS_ERROR;
3581 RAISE;
3582 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3583 FND_MSG_PUB.Count_And_Get
3584 ( p_encoded => FND_API.G_FALSE
3585 , p_count => x_msg_count
3586 , p_data => x_msg_data
3587 );
3588 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3589 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3590 RAISE;
3591 WHEN NO_DATA_FOUND THEN
3592 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3593 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3594 FND_MSG_PUB.Initialize;
3595 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
3596 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
3597 FND_MSG_PUB.ADD;
3598 RAISE FND_API.G_EXC_ERROR;
3599 WHEN OTHERS THEN
3600 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3601 IF (x_msg_data IS NOT NULL) THEN
3602 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_User_Access ';
3603 ELSE
3604 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_User_Access ';
3605 END IF;
3606 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3607 RAISE;
3608 end Retrieve_Kpi_User_Access;
3609
3610 /************************************************************************************
3611 ************************************************************************************/
3612
3613 procedure Update_Kpi_User_Access(
3614 p_commit IN varchar2 := FND_API.G_FALSE
3615 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3616 ,x_return_status OUT NOCOPY varchar2
3617 ,x_msg_count OUT NOCOPY number
3618 ,x_msg_data OUT NOCOPY varchar2
3619 ) is
3620
3621 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
3622
3623 l_count number;
3624
3625 begin
3626 FND_MSG_PUB.Initialize;
3627 x_return_status := FND_API.G_RET_STS_SUCCESS;
3628 SAVEPOINT BscKpiPvt_UptKPIUsrAcc;
3629 -- Check that valid id was entered.
3630 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3631 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3632 ,'indicator'
3633 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3634 if l_count = 0 then
3635 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3636 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3637 FND_MSG_PUB.ADD;
3638 RAISE FND_API.G_EXC_ERROR;
3639 end if;
3640 else
3641 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3642 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3643 FND_MSG_PUB.ADD;
3644 RAISE FND_API.G_EXC_ERROR;
3645 end if;
3646
3647 -- Not all values will be passed. We need to make sure values not passed are not
3648 -- changed by procedure, therefore we get what is there before we do any updates.
3649 Retrieve_Kpi_User_Access( p_commit
3650 ,p_Bsc_Kpi_Entity_Rec
3651 ,l_Bsc_Kpi_Entity_Rec
3652 ,x_return_status
3653 ,x_msg_count
3654 ,x_msg_data);
3655
3656 -- update LOCAL language ,source language and Kpi Id values with PASSED values.
3657 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3658
3659 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
3660 -- which are NOT NULL.
3661 if p_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id is not null then
3662 l_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id;
3663 end if;
3664 if p_Bsc_Kpi_Entity_Rec.Creation_Date is not null then
3665 l_Bsc_Kpi_Entity_Rec.Creation_Date := p_Bsc_Kpi_Entity_Rec.Creation_Date;
3666 end if;
3667 if p_Bsc_Kpi_Entity_Rec.Created_By is not null then
3668 l_Bsc_Kpi_Entity_Rec.Created_By := p_Bsc_Kpi_Entity_Rec.Created_By;
3669 end if;
3670 if p_Bsc_Kpi_Entity_Rec.Last_Update_Date is not null then
3671 l_Bsc_Kpi_Entity_Rec.Last_Update_Date := p_Bsc_Kpi_Entity_Rec.Last_Update_Date;
3672 end if;
3673 if p_Bsc_Kpi_Entity_Rec.Last_Updated_By is not null then
3674 l_Bsc_Kpi_Entity_Rec.Last_Updated_By := p_Bsc_Kpi_Entity_Rec.Last_Updated_By;
3675 end if;
3676 if p_Bsc_Kpi_Entity_Rec.Last_Update_Login is not null then
3677 l_Bsc_Kpi_Entity_Rec.Last_Update_Login := p_Bsc_Kpi_Entity_Rec.Last_Update_Login;
3678 end if;
3679 if p_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date is not null then
3680 l_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date := p_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date;
3681 end if;
3682 if p_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date is not null then
3683 l_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date := p_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date;
3684 end if;
3685
3686 update BSC_USER_KPI_ACCESS
3687 set responsibility_id = l_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id
3688 ,creation_date = l_Bsc_Kpi_Entity_Rec.Creation_Date
3689 ,created_by = l_Bsc_Kpi_Entity_Rec.Created_By
3690 ,last_update_date = l_Bsc_Kpi_Entity_Rec.Last_Update_Date
3691 ,last_updated_by = l_Bsc_Kpi_Entity_Rec.Last_Updated_By
3692 ,last_update_login = l_Bsc_Kpi_Entity_Rec.Last_Update_Login
3693 ,start_date = l_Bsc_Kpi_Entity_Rec.Bsc_Resp_Start_Date
3694 ,end_date = l_Bsc_Kpi_Entity_Rec.Bsc_Resp_End_Date
3695 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3696
3697 if (p_commit = FND_API.G_TRUE) then
3698 commit;
3699 end if;
3700
3701 EXCEPTION
3702 WHEN FND_API.G_EXC_ERROR THEN
3703 ROLLBACK TO BscKpiPvt_UptKPIUsrAcc;
3704 FND_MSG_PUB.Count_And_Get
3705 ( p_encoded => FND_API.G_FALSE
3706 , p_count => x_msg_count
3707 , p_data => x_msg_data
3708 );
3709 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3710 x_return_status := FND_API.G_RET_STS_ERROR;
3711 RAISE;
3712 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3713 ROLLBACK TO BscKpiPvt_UptKPIUsrAcc;
3714 FND_MSG_PUB.Count_And_Get
3715 ( p_encoded => FND_API.G_FALSE
3716 , p_count => x_msg_count
3717 , p_data => x_msg_data
3718 );
3719 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3720 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3721 RAISE;
3722 WHEN NO_DATA_FOUND THEN
3723 ROLLBACK TO BscKpiPvt_UptKPIUsrAcc;
3724 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3725 IF (x_msg_data IS NOT NULL) THEN
3726 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_User_Access ';
3727 ELSE
3728 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_User_Access ';
3729 END IF;
3730 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3731 RAISE;
3732 WHEN OTHERS THEN
3733 ROLLBACK TO BscKpiPvt_UptKPIUsrAcc;
3734 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3735 IF (x_msg_data IS NOT NULL) THEN
3736 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_User_Access ';
3737 ELSE
3738 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_User_Access ';
3739 END IF;
3740 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3741 RAISE;
3742 end Update_Kpi_User_Access;
3743
3744 /************************************************************************************
3745 ************************************************************************************/
3746
3747 procedure Delete_Kpi_User_Access(
3748 p_commit IN varchar2 := FND_API.G_FALSE
3749 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3750 ,x_return_status OUT NOCOPY varchar2
3751 ,x_msg_count OUT NOCOPY number
3752 ,x_msg_data OUT NOCOPY varchar2
3753 ) is
3754
3755 l_count number;
3756
3757 begin
3758 FND_MSG_PUB.Initialize;
3759 x_return_status := FND_API.G_RET_STS_SUCCESS;
3760 SAVEPOINT BscKpiPvt_DelKPIUsrAcc;
3761 -- Check that valid id was entered.
3762 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3763 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3764 ,'indicator'
3765 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3766 if l_count = 0 then
3767 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3768 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3769 FND_MSG_PUB.ADD;
3770 RAISE FND_API.G_EXC_ERROR;
3771 end if;
3772 else
3773 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3774 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3775 FND_MSG_PUB.ADD;
3776 RAISE FND_API.G_EXC_ERROR;
3777 end if;
3778
3779 delete from BSC_USER_KPI_ACCESS
3780 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
3781
3782 if (p_commit = FND_API.G_TRUE) then
3783 commit;
3784 end if;
3785
3786 EXCEPTION
3787 WHEN FND_API.G_EXC_ERROR THEN
3788 ROLLBACK TO BscKpiPvt_DelKPIUsrAcc;
3789 FND_MSG_PUB.Count_And_Get
3790 ( p_encoded => FND_API.G_FALSE
3791 , p_count => x_msg_count
3792 , p_data => x_msg_data
3793 );
3794 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3795 x_return_status := FND_API.G_RET_STS_ERROR;
3796 RAISE;
3797 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3798 ROLLBACK TO BscKpiPvt_DelKPIUsrAcc;
3799 FND_MSG_PUB.Count_And_Get
3800 ( p_encoded => FND_API.G_FALSE
3801 , p_count => x_msg_count
3802 , p_data => x_msg_data
3803 );
3804 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3805 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
3806 RAISE;
3807 WHEN NO_DATA_FOUND THEN
3808 ROLLBACK TO BscKpiPvt_DelKPIUsrAcc;
3809 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3810 IF (x_msg_data IS NOT NULL) THEN
3811 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_User_Access ';
3812 ELSE
3813 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_User_Access ';
3814 END IF;
3815 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
3816 RAISE;
3817 WHEN OTHERS THEN
3818 ROLLBACK TO BscKpiPvt_DelKPIUsrAcc;
3819 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3820 IF (x_msg_data IS NOT NULL) THEN
3821 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_User_Access ';
3822 ELSE
3823 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_User_Access ';
3824 END IF;
3825 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
3826 RAISE;
3827 end Delete_Kpi_User_Access;
3828
3829 /************************************************************************************
3830 ************************************************************************************/
3831 procedure Create_Kpi_Default_Values(
3832 p_commit IN varchar2 := FND_API.G_FALSE
3833 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
3834 ,x_return_status OUT NOCOPY varchar2
3835 ,x_msg_count OUT NOCOPY number
3836 ,x_msg_data OUT NOCOPY varchar2
3837 ) is
3838
3839 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
3840
3841 l_db_object varchar2(30);
3842
3843 l_count number;
3844
3845 begin
3846 FND_MSG_PUB.Initialize;
3847 x_return_status := FND_API.G_RET_STS_SUCCESS;
3848 SAVEPOINT BscKpiPvt_CrtKPIDefVals;
3849 -- Assign all values in the passed "Record" parameter to the locally defined
3850 -- "Record" variable.
3851 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
3852
3853 -- Check that valid id was entered.
3854 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
3855 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
3856 ,'indicator'
3857 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3858 if l_count = 0 then
3859 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
3860 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3861 FND_MSG_PUB.ADD;
3862 RAISE FND_API.G_EXC_ERROR;
3863 end if;
3864 else
3865 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
3866 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
3867 FND_MSG_PUB.ADD;
3868 RAISE FND_API.G_EXC_ERROR;
3869 end if;
3870
3871 -- If Analysis Option 0 name is null assign default.
3872 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name is null then
3873 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name := 'Option ' || to_char(l_Bsc_Kpi_Entity_Rec.Bsc_Num_Options - 1);
3874 end if;
3875
3876 l_db_object := 'BSC_KPI_DEFAULTS_B';
3877
3878 insert into BSC_KPI_DEFAULTS_B( tab_id
3879 ,indicator
3880 ,format_mask
3881 ,color_method
3882 ,dim_set_id
3883 ,dim_level1_value
3884 ,dim_level2_value
3885 ,dim_level3_value
3886 ,dim_level4_value
3887 ,dim_level5_value
3888 ,dim_level6_value
3889 ,dim_level7_value
3890 ,dim_level8_value
3891 ,last_update_date
3892 ,last_updated_by
3893 ,creation_date
3894 ,created_by
3895 ,last_update_login
3896 ,measure_source)
3897 values( -1
3898 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3899 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask
3900 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method
3901 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
3902 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value
3903 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value
3904 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value
3905 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value
3906 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value
3907 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value
3908 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value
3909 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value
3910 ,sysdate
3911 ,l_Bsc_Kpi_Entity_Rec.Last_Updated_By
3912 ,sysdate
3913 ,l_Bsc_Kpi_Entity_Rec.Created_By
3914 ,l_Bsc_Kpi_Entity_Rec.Last_Update_Login
3915 ,l_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source);
3916
3917 l_db_object := 'BSC_KPI_DEFAULTS_TL';
3918
3919 insert into BSC_KPI_DEFAULTS_TL( tab_id
3920 ,indicator
3921 ,language
3922 ,source_lang
3923 ,analysis_option0_name
3924 ,analysis_option1_name
3925 ,analysis_option2_name
3926 ,period_name
3927 ,series_name
3928 ,dim_level1_name
3929 ,dim_level2_name
3930 ,dim_level3_name
3931 ,dim_level4_name
3932 ,dim_level5_name
3933 ,dim_level6_name
3934 ,dim_level7_name
3935 ,dim_level8_name
3936 ,dim_level1_text
3937 ,dim_level2_text
3938 ,dim_level3_text
3939 ,dim_level4_text
3940 ,dim_level5_text
3941 ,dim_level6_text
3942 ,dim_level7_text
3943 ,dim_level8_text)
3944 SELECT -1
3945 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3946 , L.LANGUAGE_CODE
3947 , USERENV('LANG')
3948 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name
3949 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name
3950 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name
3951 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name
3952 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name
3953 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name
3954 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name
3955 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name
3956 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name
3957 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name
3958 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name
3959 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name
3960 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name
3961 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text
3962 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text
3963 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text
3964 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text
3965 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text
3966 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text
3967 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text
3968 , l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text
3969 FROM FND_LANGUAGES L
3970 WHERE L.INSTALLED_FLAG IN ('I', 'B')
3971 AND NOT EXISTS
3972 ( SELECT NULL
3973 FROM BSC_KPI_DEFAULTS_TL T
3974 WHERE T.indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
3975 AND T.LANGUAGE = L.LANGUAGE_CODE);
3976
3977
3978 if (p_commit = FND_API.G_TRUE) then
3979 commit;
3980 end if;
3981
3982 EXCEPTION
3983 WHEN FND_API.G_EXC_ERROR THEN
3984 ROLLBACK TO BscKpiPvt_CrtKPIDefVals;
3985 FND_MSG_PUB.Count_And_Get
3986 ( p_encoded => FND_API.G_FALSE
3987 , p_count => x_msg_count
3988 , p_data => x_msg_data
3989 );
3990 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
3991 x_return_status := FND_API.G_RET_STS_ERROR;
3992 RAISE;
3993 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3994 ROLLBACK TO BscKpiPvt_CrtKPIDefVals;
3995 FND_MSG_PUB.Count_And_Get
3996 ( p_encoded => FND_API.G_FALSE
3997 , p_count => x_msg_count
3998 , p_data => x_msg_data
3999 );
4000 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4001 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4002 RAISE;
4003 WHEN NO_DATA_FOUND THEN
4004 ROLLBACK TO BscKpiPvt_CrtKPIDefVals;
4005 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4006 IF (x_msg_data IS NOT NULL) THEN
4007 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Default_Values ';
4008 ELSE
4009 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Default_Values ';
4010 END IF;
4011 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4012 RAISE;
4013 WHEN OTHERS THEN
4014 ROLLBACK TO BscKpiPvt_CrtKPIDefVals;
4015 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4016 if (SQLCODE = -01400) then
4017 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
4018 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
4019 FND_MSG_PUB.ADD;
4020 RAISE FND_API.G_EXC_ERROR;
4021 end if;
4022 IF (x_msg_data IS NOT NULL) THEN
4023 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_Default_Values ';
4024 ELSE
4025 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_Default_Values ';
4026 END IF;
4027 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4028 RAISE;
4029 end Create_Kpi_Default_Values;
4030
4031 /************************************************************************************
4032 ************************************************************************************/
4033
4034 procedure Retrieve_Kpi_Default_Values(
4035 p_commit IN varchar2 := FND_API.G_FALSE
4036 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4037 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4038 ,x_return_status OUT NOCOPY varchar2
4039 ,x_msg_count OUT NOCOPY number
4040 ,x_msg_data OUT NOCOPY varchar2
4041 ) is
4042
4043 l_db_object varchar2(30);
4044
4045 begin
4046 FND_MSG_PUB.Initialize;
4047 x_return_status := FND_API.G_RET_STS_SUCCESS;
4048 l_db_object := 'Retrieve_Kpi_Default_Values';
4049
4050 select distinct a.tab_id
4051 ,a.format_mask
4052 ,a.color_method
4053 ,a.dim_set_id
4054 ,a.dim_level1_value
4055 ,a.dim_level2_value
4056 ,a.dim_level3_value
4057 ,a.dim_level4_value
4058 ,a.dim_level5_value
4059 ,a.dim_level6_value
4060 ,a.dim_level7_value
4061 ,a.dim_level8_value
4062 ,a.last_update_date
4063 ,a.last_updated_by
4064 ,a.creation_date
4065 ,a.created_by
4066 ,a.last_update_login
4067 ,a.measure_source
4068 ,b.analysis_option0_name
4069 ,b.analysis_option1_name
4070 ,b.analysis_option2_name
4071 ,b.period_name
4072 ,b.series_name
4073 ,b.dim_level1_name
4074 ,b.dim_level2_name
4075 ,b.dim_level3_name
4076 ,b.dim_level4_name
4077 ,b.dim_level5_name
4078 ,b.dim_level6_name
4079 ,b.dim_level7_name
4080 ,b.dim_level8_name
4081 ,b.dim_level1_text
4082 ,b.dim_level2_text
4083 ,b.dim_level3_text
4084 ,b.dim_level4_text
4085 ,b.dim_level5_text
4086 ,b.dim_level6_text
4087 ,b.dim_level7_text
4088 ,b.dim_level8_text
4089 into x_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4090 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask
4091 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method
4092 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
4093 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value
4094 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value
4095 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value
4096 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value
4097 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value
4098 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value
4099 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value
4100 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value
4101 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Date
4102 ,x_Bsc_Kpi_Entity_Rec.Last_Updated_By
4103 ,x_Bsc_Kpi_Entity_Rec.Creation_Date
4104 ,x_Bsc_Kpi_Entity_Rec.Created_By
4105 ,x_Bsc_Kpi_Entity_Rec.Last_Update_Login
4106 ,x_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source
4107 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name
4108 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name
4109 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name
4110 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name
4111 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name
4112 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name
4113 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name
4114 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name
4115 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name
4116 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name
4117 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name
4118 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name
4119 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name
4120 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text
4121 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text
4122 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text
4123 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text
4124 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text
4125 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text
4126 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text
4127 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text
4128 from BSC_KPI_DEFAULTS_B a
4129 ,BSC_KPI_DEFAULTS_TL b
4130 where a.indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
4131 and a.indicator = b.indicator
4132 and b.language = USERENV('LANG');
4133
4134 if (p_commit = FND_API.G_TRUE) then
4135 commit;
4136 end if;
4137
4138 EXCEPTION
4139 WHEN FND_API.G_EXC_ERROR THEN
4140 FND_MSG_PUB.Count_And_Get
4141 ( p_encoded => FND_API.G_FALSE
4142 , p_count => x_msg_count
4143 , p_data => x_msg_data
4144 );
4145 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4146 x_return_status := FND_API.G_RET_STS_ERROR;
4147 RAISE;
4148 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4149 FND_MSG_PUB.Count_And_Get
4150 ( p_encoded => FND_API.G_FALSE
4151 , p_count => x_msg_count
4152 , p_data => x_msg_data
4153 );
4154 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4155 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4156 RAISE;
4157 WHEN NO_DATA_FOUND THEN
4158 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4159 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4160 FND_MSG_PUB.Initialize;
4161 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
4162 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
4163 FND_MSG_PUB.ADD;
4164 RAISE FND_API.G_EXC_ERROR;
4165 WHEN OTHERS THEN
4166 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4167 IF (x_msg_data IS NOT NULL) THEN
4168 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_Default_Values ';
4169 ELSE
4170 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_Default_Values ';
4171 END IF;
4172 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4173 RAISE;
4174 end Retrieve_Kpi_Default_Values;
4175
4176 /************************************************************************************
4177 ************************************************************************************/
4178
4179 procedure Update_Kpi_Default_Values(
4180 p_commit IN varchar2 := FND_API.G_FALSE
4181 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4182 ,x_return_status OUT NOCOPY varchar2
4183 ,x_msg_count OUT NOCOPY number
4184 ,x_msg_data OUT NOCOPY varchar2
4185 ) is
4186
4187 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
4188
4189 l_count number;
4190
4191 begin
4192 FND_MSG_PUB.Initialize;
4193 x_return_status := FND_API.G_RET_STS_SUCCESS;
4194 SAVEPOINT BscKpiPvt_UpdKPIDefVals;
4195 -- Check that valid id was entered.
4196 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
4197 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
4198 ,'indicator'
4199 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4200 if l_count = 0 then
4201 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
4202 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4203 FND_MSG_PUB.ADD;
4204 RAISE FND_API.G_EXC_ERROR;
4205 end if;
4206 else
4207 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
4208 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4209 FND_MSG_PUB.ADD;
4210 RAISE FND_API.G_EXC_ERROR;
4211 end if;
4212
4213 -- Not all values will be passed. We need to make sure values not passed are not
4214 -- changed by procedure, therefore we get what is there before we do any updates.
4215 Retrieve_Kpi_Default_Values( p_commit
4216 ,p_Bsc_Kpi_Entity_Rec
4217 ,l_Bsc_Kpi_Entity_Rec
4218 ,x_return_status
4219 ,x_msg_count
4220 ,x_msg_data);
4221
4222 -- update LOCAL language ,source language and Kpi Id values with PASSED values.
4223 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4224
4225
4226 -- Copy PASSED Record values into LOCAL Record values for the PASSED Record values
4227 -- which are NOT NULL.
4228 if p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id is not null then
4229 l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id;
4230 end if;
4231 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask is not null then
4232 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask;
4233 end if;
4234 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method is not null then
4235 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method;
4236 end if;
4237 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id is not null then
4238 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id;
4239 end if;
4240 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value is not null then
4241 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value;
4242 end if;
4243 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value is not null then
4244 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value;
4245 end if;
4246 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value is not null then
4247 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value;
4248 end if;
4249 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value is not null then
4250 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value;
4251 end if;
4252 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value is not null then
4253 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value;
4254 end if;
4255 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value is not null then
4256 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value;
4257 end if;
4258 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value is not null then
4259 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value;
4260 end if;
4261 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value is not null then
4262 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value;
4263 end if;
4264 if p_Bsc_Kpi_Entity_Rec.Last_Update_Date is not null then
4265 l_Bsc_Kpi_Entity_Rec.Last_Update_Date := p_Bsc_Kpi_Entity_Rec.Last_Update_Date;
4266 end if;
4267 if p_Bsc_Kpi_Entity_Rec.Last_Updated_By is not null then
4268 l_Bsc_Kpi_Entity_Rec.Last_Updated_By := p_Bsc_Kpi_Entity_Rec.Last_Updated_By;
4269 end if;
4270 if p_Bsc_Kpi_Entity_Rec.Creation_Date is not null then
4271 l_Bsc_Kpi_Entity_Rec.Creation_Date := p_Bsc_Kpi_Entity_Rec.Creation_Date;
4272 end if;
4273 if p_Bsc_Kpi_Entity_Rec.Created_By is not null then
4274 l_Bsc_Kpi_Entity_Rec.Created_By := p_Bsc_Kpi_Entity_Rec.Created_By;
4275 end if;
4276 if p_Bsc_Kpi_Entity_Rec.Last_Update_Login is not null then
4277 l_Bsc_Kpi_Entity_Rec.Last_Update_Login := p_Bsc_Kpi_Entity_Rec.Last_Update_Login;
4278 end if;
4279 if p_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source is not null then
4280 l_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source := p_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source;
4281 end if;
4282 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name is not null then
4283 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name;
4284 end if;
4285 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name is not null then
4286 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name;
4287 end if;
4288 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name is not null then
4289 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name;
4290 end if;
4291 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name is not null then
4292 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name;
4293 end if;
4294 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name is not null then
4295 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name;
4296 end if;
4297 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name is not null then
4298 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name;
4299 end if;
4300 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name is not null then
4301 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name;
4302 end if;
4303 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name is not null then
4304 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name;
4305 end if;
4306 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name is not null then
4307 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name;
4308 end if;
4309 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name is not null then
4310 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name;
4311 end if;
4312 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name is not null then
4313 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name;
4314 end if;
4315 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name is not null then
4316 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name;
4317 end if;
4318 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name is not null then
4319 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name;
4320 end if;
4321 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text is not null then
4322 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text;
4323 end if;
4324 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text is not null then
4325 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text;
4326 end if;
4327 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text is not null then
4328 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text;
4329 end if;
4330 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text is not null then
4331 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text;
4332 end if;
4333 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text is not null then
4334 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text;
4335 end if;
4336 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text is not null then
4337 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text;
4338 end if;
4339 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text is not null then
4340 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text;
4341 end if;
4342 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text is not null then
4343 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text := p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text;
4344 end if;
4345
4346 update BSC_KPI_DEFAULTS_B
4347 set tab_id = l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4348 ,format_mask = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Format_Mask
4349 ,color_method = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Color_Method
4350 ,dim_set_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Set_Id
4351 ,dim_level1_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Value
4352 ,dim_level2_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Value
4353 ,dim_level3_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Value
4354 ,dim_level4_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Value
4355 ,dim_level5_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Value
4356 ,dim_level6_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Value
4357 ,dim_level7_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Value
4358 ,dim_level8_value = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Value
4359 ,last_update_date = l_Bsc_Kpi_Entity_Rec.Last_Update_Date
4360 ,last_updated_by = l_Bsc_Kpi_Entity_Rec.Last_Updated_By
4361 ,creation_date = l_Bsc_Kpi_Entity_Rec.Creation_Date
4362 ,created_by = l_Bsc_Kpi_Entity_Rec.Created_By
4363 ,last_update_login = l_Bsc_Kpi_Entity_Rec.Last_Update_Login
4364 ,measure_source = l_Bsc_Kpi_Entity_Rec.Bsc_Measure_Source
4365 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4366
4367 update BSC_KPI_DEFAULTS_TL
4368 set analysis_option0_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt0_Name
4369 ,analysis_option1_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt1_Name
4370 ,analysis_option2_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Anal_Opt2_Name
4371 ,period_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Period_Name
4372 ,series_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Series_Name
4373 ,dim_level1_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Name
4374 ,dim_level2_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Name
4375 ,dim_level3_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Name
4376 ,dim_level4_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Name
4377 ,dim_level5_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Name
4378 ,dim_level6_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Name
4379 ,dim_level7_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Name
4380 ,dim_level8_name = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Name
4381 ,dim_level1_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level1_Text
4382 ,dim_level2_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level2_Text
4383 ,dim_level3_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level3_Text
4384 ,dim_level4_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level4_Text
4385 ,dim_level5_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level5_Text
4386 ,dim_level6_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level6_Text
4387 ,dim_level7_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level7_Text
4388 ,dim_level8_text = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Dim_Level8_Text
4389 ,SOURCE_LANG = userenv('LANG')
4390 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
4391 and userenv('LANG') IN (LANGUAGE, SOURCE_LANG);
4392
4393 if (p_commit = FND_API.G_TRUE) then
4394 commit;
4395 end if;
4396
4397 EXCEPTION
4398 WHEN FND_API.G_EXC_ERROR THEN
4399 ROLLBACK TO BscKpiPvt_UpdKPIDefVals;
4400 FND_MSG_PUB.Count_And_Get
4401 ( p_encoded => FND_API.G_FALSE
4402 , p_count => x_msg_count
4403 , p_data => x_msg_data
4404 );
4405 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4406 x_return_status := FND_API.G_RET_STS_ERROR;
4407 RAISE;
4408 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4409 ROLLBACK TO BscKpiPvt_UpdKPIDefVals;
4410 FND_MSG_PUB.Count_And_Get
4411 ( p_encoded => FND_API.G_FALSE
4412 , p_count => x_msg_count
4413 , p_data => x_msg_data
4414 );
4415 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4416 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4417 RAISE;
4418 WHEN NO_DATA_FOUND THEN
4419 ROLLBACK TO BscKpiPvt_UpdKPIDefVals;
4420 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4421 IF (x_msg_data IS NOT NULL) THEN
4422 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Default_Values ';
4423 ELSE
4424 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Default_Values ';
4425 END IF;
4426 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4427 RAISE;
4428 WHEN OTHERS THEN
4429 ROLLBACK TO BscKpiPvt_UpdKPIDefVals;
4430 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4431 IF (x_msg_data IS NOT NULL) THEN
4432 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Default_Values ';
4433 ELSE
4434 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Default_Values ';
4435 END IF;
4436 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4437 RAISE;
4438
4439 end Update_Kpi_Default_Values;
4440
4441 /************************************************************************************
4442 ************************************************************************************/
4443
4444 procedure Delete_Kpi_Default_Values(
4445 p_commit IN varchar2 := FND_API.G_FALSE
4446 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4447 ,x_return_status OUT NOCOPY varchar2
4448 ,x_msg_count OUT NOCOPY number
4449 ,x_msg_data OUT NOCOPY varchar2
4450 ) is
4451
4452 l_count number;
4453
4454 begin
4455 FND_MSG_PUB.Initialize;
4456 x_return_status := FND_API.G_RET_STS_SUCCESS;
4457 SAVEPOINT BscKpiPvt_DelKPIDefVals;
4458 -- Check that valid id was entered.
4459 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
4460 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
4461 ,'indicator'
4462 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4463 if l_count = 0 then
4464 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
4465 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4466 FND_MSG_PUB.ADD;
4467 RAISE FND_API.G_EXC_ERROR;
4468 end if;
4469 else
4470 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
4471 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4472 FND_MSG_PUB.ADD;
4473 RAISE FND_API.G_EXC_ERROR;
4474 end if;
4475
4476 delete from BSC_KPI_DEFAULTS_B
4477 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4478
4479 delete from BSC_KPI_DEFAULTS_TL
4480 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4481
4482 if (p_commit = FND_API.G_TRUE) then
4483 commit;
4484 end if;
4485
4486 EXCEPTION
4487 WHEN FND_API.G_EXC_ERROR THEN
4488 ROLLBACK TO BscKpiPvt_DelKPIDefVals;
4489 FND_MSG_PUB.Count_And_Get
4490 ( p_encoded => FND_API.G_FALSE
4491 , p_count => x_msg_count
4492 , p_data => x_msg_data
4493 );
4494 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4495 x_return_status := FND_API.G_RET_STS_ERROR;
4496 RAISE;
4497 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4498 ROLLBACK TO BscKpiPvt_DelKPIDefVals;
4499 FND_MSG_PUB.Count_And_Get
4500 ( p_encoded => FND_API.G_FALSE
4501 , p_count => x_msg_count
4502 , p_data => x_msg_data
4503 );
4504 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4505 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4506 RAISE;
4507 WHEN NO_DATA_FOUND THEN
4508 ROLLBACK TO BscKpiPvt_DelKPIDefVals;
4509 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4510 IF (x_msg_data IS NOT NULL) THEN
4511 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Default_Values ';
4512 ELSE
4513 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Default_Values ';
4514 END IF;
4515 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4516 RAISE;
4517 WHEN OTHERS THEN
4518 ROLLBACK TO BscKpiPvt_DelKPIDefVals;
4519 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4520 IF (x_msg_data IS NOT NULL) THEN
4521 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_Default_Values ';
4522 ELSE
4523 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_Default_Values ';
4524 END IF;
4525 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4526 RAISE;
4527 end Delete_Kpi_Default_Values;
4528
4529 /************************************************************************************
4530 ************************************************************************************/
4531
4532 procedure Create_Kpi_In_Tab(
4533 p_commit IN varchar2 := FND_API.G_FALSE
4534 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4535 ,x_return_status OUT NOCOPY varchar2
4536 ,x_msg_count OUT NOCOPY number
4537 ,x_msg_data OUT NOCOPY varchar2
4538 ) is
4539
4540 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
4541 l_Bsc_Kpi_Group_Rec BSC_KPI_GROUP_PUB.Bsc_Kpi_Group_Rec;
4542
4543 l_db_object varchar2(30);
4544
4545 l_count number;
4546
4547 begin
4548 --DBMS_OUTPUT.PUT_LINE('-- Begin BSC_KPI_PVT.Create_Kpi_In_Tab');
4549 FND_MSG_PUB.Initialize;
4550 x_return_status := FND_API.G_RET_STS_SUCCESS;
4551 SAVEPOINT BscKpiPvt_CrtKPIInTab;
4552 -- Assign passed records to local record.
4553 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
4554 --DBMS_OUTPUT.PUT_LINE('l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag = ' || l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag);
4555
4556 -- Check that valid id was entered.
4557 if l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
4558 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
4559 ,'indicator'
4560 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4561 if l_count = 0 then
4562 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
4563 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4564 FND_MSG_PUB.ADD;
4565 RAISE FND_API.G_EXC_ERROR;
4566 end if;
4567 else
4568 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
4569 FND_MESSAGE.SET_TOKEN('BSC_KPI', l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4570 FND_MSG_PUB.ADD;
4571 RAISE FND_API.G_EXC_ERROR;
4572 end if;
4573
4574 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 1');
4575
4576 -- Check that valid id was entered.
4577 if l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id is not null then
4578 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 2');
4579
4580 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_TABS_B'
4581 ,'tab_id'
4582 ,l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
4583 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 3');
4584
4585 if l_count = 0 then
4586 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_TAB_ID');
4587 FND_MESSAGE.SET_TOKEN('BSC_TAB', l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
4588 FND_MSG_PUB.ADD;
4589 RAISE FND_API.G_EXC_ERROR;
4590 end if;
4591 else
4592 FND_MESSAGE.SET_NAME('BSC','BSC_NO_TAB_ID_ENTERED');
4593 FND_MESSAGE.SET_TOKEN('BSC_TAB', l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
4594 FND_MSG_PUB.ADD;
4595 RAISE FND_API.G_EXC_ERROR;
4596 end if;
4597 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 4');
4598
4599
4600 -- Check that this Group has not been assigned to the tab yet.
4601 select count(*)
4602 into l_count
4603 from BSC_TAB_IND_GROUPS_B
4604 where tab_id = l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4605 and ind_group_id = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id;
4606
4607 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 5');
4608
4609 -- if group and tab combination does not exist then assign group to Tab.
4610 if l_count < 1 then
4611
4612 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 6');
4613 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Tab_Id = ' || l_Bsc_Kpi_Group_Rec.Bsc_Tab_Id);
4614
4615 --populate appropriate values into Record.
4616 l_Bsc_Kpi_Group_Rec.Bsc_Csf_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Csf_Id;
4617 l_Bsc_Kpi_Group_Rec.Bsc_Kpi_Group_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id;
4618 l_Bsc_Kpi_Group_Rec.Bsc_Kpi_Group_Type := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Type;
4619 l_Bsc_Kpi_Group_Rec.Bsc_Name_Pos_In_Tab := l_Bsc_Kpi_Entity_Rec.Bsc_Name_Pos_In_Tab;
4620 l_Bsc_Kpi_Group_Rec.Bsc_Name_Justif_In_Tab := l_Bsc_Kpi_Entity_Rec.Bsc_Name_Justif_In_Tab;
4621 --- Bad logic comment to fixed bug 2650624 - Possition an size it is getting from tab -1
4622 --l_Bsc_Kpi_Group_Rec.Bsc_Left_Position_In_Tab := l_Bsc_Kpi_Entity_Rec.Bsc_Left_Position_In_Tab;
4623 --l_Bsc_Kpi_Group_Rec.Bsc_Top_Position_In_Tab := l_Bsc_Kpi_Entity_Rec.Bsc_Top_Position_In_Tab;
4624 --l_Bsc_Kpi_Group_Rec.Bsc_Group_Width := l_Bsc_Kpi_Entity_Rec.Bsc_Group_Width;
4625 --l_Bsc_Kpi_Group_Rec.Bsc_Group_Height := l_Bsc_Kpi_Entity_Rec.Bsc_Group_Height;
4626 l_Bsc_Kpi_Group_Rec.Bsc_Kpi_Group_Name := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Name;
4627 l_Bsc_Kpi_Group_Rec.Bsc_Kpi_Group_Help := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Help;
4628 l_Bsc_Kpi_Group_Rec.Bsc_Tab_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id;
4629 l_Bsc_Kpi_Group_Rec.Bsc_Language := l_Bsc_Kpi_Entity_Rec.Bsc_Language;
4630 l_Bsc_Kpi_Group_Rec.Bsc_Source_Language := l_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
4631
4632 l_db_object := 'Update_Kpi_Group';
4633
4634 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 7');
4635 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Tab_Id = ' || l_Bsc_Kpi_Group_Rec.Bsc_Tab_Id);
4636 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Left_Position_In_Tab = ' || l_Bsc_Kpi_Group_Rec.Bsc_Left_Position_In_Tab);
4637 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Top_Position_In_Tab = ' || l_Bsc_Kpi_Group_Rec.Bsc_Top_Position_In_Tab);
4638 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Group_Width = ' || l_Bsc_Kpi_Group_Rec.Bsc_Group_Width);
4639 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Group_Rec.Bsc_Group_Height = ' || l_Bsc_Kpi_Group_Rec.Bsc_Group_Height);
4640
4641 BSC_KPI_GROUP_PUB.Update_Kpi_Group( p_commit
4642 ,l_Bsc_Kpi_Group_Rec
4643 ,x_return_status
4644 ,x_msg_count
4645 ,x_msg_data);
4646
4647 end if;
4648
4649 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 8');
4650
4651
4652 -- Call procedure to update KPI with tab information. Set some values.
4653 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Model_Flag := 0;
4654 l_Bsc_Kpi_Entity_Rec.Bsc_Left_Position_In_Tab := null;
4655 l_Bsc_Kpi_Entity_Rec.Bsc_Top_Position_In_Tab := null;
4656 l_Bsc_Kpi_Entity_Rec.Bsc_Group_Width := null;
4657 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Backcolor := null;
4658
4659 l_db_object := 'BSC_TAB_INDICATORS';
4660
4661 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 9');
4662
4663 insert into BSC_TAB_INDICATORS( tab_id
4664 ,indicator
4665 ,bsc_model_flag
4666 ,left_position
4667 ,top_position
4668 ,width
4669 ,height
4670 ,backcolor)
4671 values( l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4672 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
4673 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Model_Flag
4674 ,l_Bsc_Kpi_Entity_Rec.Bsc_Left_Position_In_Tab
4675 ,l_Bsc_Kpi_Entity_Rec.Bsc_Top_Position_In_Tab
4676 ,l_Bsc_Kpi_Entity_Rec.Bsc_Group_Width
4677 ,l_Bsc_Kpi_Entity_Rec.Bsc_Group_Height
4678 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Backcolor);
4679
4680 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Kpi_In_Tab - Flag 10');
4681
4682 Update_Kpi_In_Tab( p_commit
4683 ,l_Bsc_Kpi_Entity_Rec
4684 ,x_return_status
4685 ,x_msg_count
4686 ,x_msg_data);
4687
4688
4689 if (p_commit = FND_API.G_TRUE) then
4690 commit;
4691 end if;
4692
4693 --DBMS_OUTPUT.PUT_LINE(' -- End BSC_KPI_PVT.Create_Kpi_In_Tab');
4694
4695
4696 EXCEPTION
4697 WHEN FND_API.G_EXC_ERROR THEN
4698 ROLLBACK TO BscKpiPvt_CrtKPIInTab;
4699 FND_MSG_PUB.Count_And_Get
4700 ( p_encoded => FND_API.G_FALSE
4701 , p_count => x_msg_count
4702 , p_data => x_msg_data
4703 );
4704 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4705 x_return_status := FND_API.G_RET_STS_ERROR;
4706 RAISE;
4707 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4708 ROLLBACK TO BscKpiPvt_CrtKPIInTab;
4709 FND_MSG_PUB.Count_And_Get
4710 ( p_encoded => FND_API.G_FALSE
4711 , p_count => x_msg_count
4712 , p_data => x_msg_data
4713 );
4714 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4715 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4716 RAISE;
4717 WHEN NO_DATA_FOUND THEN
4718 ROLLBACK TO BscKpiPvt_CrtKPIInTab;
4719 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4720 IF (x_msg_data IS NOT NULL) THEN
4721 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_In_Tab ';
4722 ELSE
4723 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_In_Tab ';
4724 END IF;
4725 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4726 RAISE;
4727 WHEN OTHERS THEN
4728 ROLLBACK TO BscKpiPvt_CrtKPIInTab;
4729 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4730 if (SQLCODE = -01400) then
4731 FND_MESSAGE.SET_NAME('BSC','BSC_TABLE_NULL_VALUE');
4732 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
4733 FND_MSG_PUB.ADD;
4734 RAISE FND_API.G_EXC_ERROR;
4735 end if;
4736 IF (x_msg_data IS NOT NULL) THEN
4737 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Kpi_In_Tab ';
4738 ELSE
4739 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Kpi_In_Tab ';
4740 END IF;
4741 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4742 RAISE;
4743 end Create_Kpi_In_Tab;
4744
4745 /************************************************************************************
4746 ************************************************************************************/
4747
4748 procedure Retrieve_Kpi_In_Tab(
4749 p_commit IN varchar2 := FND_API.G_FALSE
4750 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4751 ,x_Bsc_Kpi_Entity_Rec IN OUT NOCOPY BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4752 ,x_return_status OUT NOCOPY varchar2
4753 ,x_msg_count OUT NOCOPY number
4754 ,x_msg_data OUT NOCOPY varchar2
4755 ) is
4756
4757 l_db_object varchar2(30);
4758
4759 begin
4760 FND_MSG_PUB.Initialize;
4761 x_return_status := FND_API.G_RET_STS_SUCCESS;
4762 l_db_object := 'Retrieve_Kpi_In_Tab';
4763
4764 select distinct tab_id
4765 ,bsc_model_flag
4766 ,left_position
4767 ,top_position
4768 ,width
4769 ,height
4770 ,backcolor
4771 into x_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4772 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Model_Flag
4773 -- This is not KPI Group position and size
4774 -- It is KPI position and Size for Stratege Map View
4775 -- Not use yet it I-Builder
4776 ,x_Bsc_Kpi_Entity_Rec.Bsc_Left_Position_In_Tab
4777 ,x_Bsc_Kpi_Entity_Rec.Bsc_Top_Position_In_Tab
4778 ,x_Bsc_Kpi_Entity_Rec.Bsc_Group_Width
4779 ,x_Bsc_Kpi_Entity_Rec.Bsc_Group_Height
4780 ,x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Backcolor
4781 from BSC_TAB_INDICATORS
4782 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4783
4784
4785 if (p_commit = FND_API.G_TRUE) then
4786 commit;
4787 end if;
4788
4789 EXCEPTION
4790 WHEN FND_API.G_EXC_ERROR THEN
4791 FND_MSG_PUB.Count_And_Get
4792 ( p_encoded => FND_API.G_FALSE
4793 , p_count => x_msg_count
4794 , p_data => x_msg_data
4795 );
4796 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4797 x_return_status := FND_API.G_RET_STS_ERROR;
4798 RAISE;
4799 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4800 FND_MSG_PUB.Count_And_Get
4801 ( p_encoded => FND_API.G_FALSE
4802 , p_count => x_msg_count
4803 , p_data => x_msg_data
4804 );
4805 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4806 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4807 RAISE;
4808 WHEN NO_DATA_FOUND THEN
4809 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4810 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4811 FND_MSG_PUB.Initialize;
4812 FND_MESSAGE.SET_NAME('BSC','BSC_NO_VALUE_FOUND');
4813 FND_MESSAGE.SET_TOKEN('BSC_OBJECT', l_db_object);
4814 FND_MSG_PUB.ADD;
4815 RAISE FND_API.G_EXC_ERROR;
4816 WHEN OTHERS THEN
4817 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4818 IF (x_msg_data IS NOT NULL) THEN
4819 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Retrieve_Kpi_In_Tab ';
4820 ELSE
4821 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Retrieve_Kpi_In_Tab ';
4822 END IF;
4823 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4824 RAISE;
4825 end Retrieve_Kpi_In_Tab;
4826
4827 /************************************************************************************
4828 ************************************************************************************/
4829
4830 procedure Update_Kpi_In_Tab(
4831 p_commit IN varchar2 := FND_API.G_FALSE
4832 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4833 ,x_return_status OUT NOCOPY varchar2
4834 ,x_msg_count OUT NOCOPY number
4835 ,x_msg_data OUT NOCOPY varchar2
4836 ) is
4837
4838 l_count number;
4839
4840 begin
4841 FND_MSG_PUB.Initialize;
4842 x_return_status := FND_API.G_RET_STS_SUCCESS;
4843 SAVEPOINT BscKpiPvt_UpdKPIInTab;
4844 --DBMS_OUTPUT.PUT_LINE(' -- Begin BSC_KPI_PVT.Update_Kpi_In_Tab');
4845
4846 -- Check that valid id was entered.
4847 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
4848 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
4849 ,'indicator'
4850 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4851 if l_count = 0 then
4852 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
4853 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4854 FND_MSG_PUB.ADD;
4855 RAISE FND_API.G_EXC_ERROR;
4856 end if;
4857 else
4858 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
4859 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4860 FND_MSG_PUB.ADD;
4861 RAISE FND_API.G_EXC_ERROR;
4862 end if;
4863
4864 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Update_Kpi_In_Tab - Flag 1');
4865 --DBMS_OUTPUT.PUT_LINE(' p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag = ' || p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag);
4866
4867 -- Update prototype flag.
4868
4869 update BSC_KPIS_B
4870 set prototype_flag = nvl(p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag,7)
4871 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
4872 and decode(prototype_flag, 0, 8, prototype_flag) > 7;
4873
4874 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Update_Kpi_In_Tab - Flag 2');
4875
4876 -- Update Kpi defaults.
4877 update BSC_KPI_DEFAULTS_B
4878 set tab_id = p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4879 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4880
4881 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Update_Kpi_In_Tab - Flag 3');
4882
4883 update BSC_KPI_DEFAULTS_TL
4884 set tab_id = p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id
4885 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4886
4887 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Update_Kpi_In_Tab - Flag 4');
4888
4889 -- Update Kpi Dim Level Information
4890 update BSC_KPI_DIM_LEVELS_B
4891 set default_value = 'T'
4892 where (default_value like 'D%')
4893 and indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4894
4895 if (p_commit = FND_API.G_TRUE) then
4896 commit;
4897 end if;
4898
4899 --DBMS_OUTPUT.PUT_LINE(' -- End BSC_KPI_PVT.Update_Kpi_In_Tab ');
4900
4901 EXCEPTION
4902 WHEN FND_API.G_EXC_ERROR THEN
4903 ROLLBACK TO BscKpiPvt_UpdKPIInTab;
4904 FND_MSG_PUB.Count_And_Get
4905 ( p_encoded => FND_API.G_FALSE
4906 , p_count => x_msg_count
4907 , p_data => x_msg_data
4908 );
4909 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4910 x_return_status := FND_API.G_RET_STS_ERROR;
4911 RAISE;
4912 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4913 ROLLBACK TO BscKpiPvt_UpdKPIInTab;
4914 FND_MSG_PUB.Count_And_Get
4915 ( p_encoded => FND_API.G_FALSE
4916 , p_count => x_msg_count
4917 , p_data => x_msg_data
4918 );
4919 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4920 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
4921 RAISE;
4922 WHEN NO_DATA_FOUND THEN
4923 ROLLBACK TO BscKpiPvt_UpdKPIInTab;
4924 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4925 IF (x_msg_data IS NOT NULL) THEN
4926 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_In_Tab ';
4927 ELSE
4928 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_In_Tab ';
4929 END IF;
4930 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
4931 RAISE;
4932 WHEN OTHERS THEN
4933 ROLLBACK TO BscKpiPvt_UpdKPIInTab;
4934 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4935 IF (x_msg_data IS NOT NULL) THEN
4936 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_In_Tab ';
4937 ELSE
4938 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_In_Tab ';
4939 END IF;
4940 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
4941 RAISE;
4942 end Update_Kpi_In_Tab;
4943
4944
4945 /************************************************************************************
4946 ************************************************************************************/
4947
4948 procedure Delete_Kpi_In_Tab(
4949 p_commit IN varchar2 := FND_API.G_FALSE
4950 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
4951 ,x_return_status OUT NOCOPY varchar2
4952 ,x_msg_count OUT NOCOPY number
4953 ,x_msg_data OUT NOCOPY varchar2
4954 ) is
4955
4956 l_count number;
4957
4958 begin
4959 FND_MSG_PUB.Initialize;
4960 x_return_status := FND_API.G_RET_STS_SUCCESS;
4961 SAVEPOINT BscKpiPvt_DelKPIInTab;
4962 -- Check that valid id was entered.
4963 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
4964 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
4965 ,'indicator'
4966 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4967 if l_count = 0 then
4968 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
4969 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4970 FND_MSG_PUB.ADD;
4971 RAISE FND_API.G_EXC_ERROR;
4972 end if;
4973 else
4974 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
4975 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
4976 FND_MSG_PUB.ADD;
4977 RAISE FND_API.G_EXC_ERROR;
4978 end if;
4979
4980 delete from BSC_TAB_INDICATORS
4981 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
4982 -- Reminder: Check to see if tab id needs to be specified.
4983 -- and tab_id = p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id;
4984
4985 if (p_commit = FND_API.G_TRUE) then
4986 commit;
4987 end if;
4988
4989 EXCEPTION
4990 WHEN FND_API.G_EXC_ERROR THEN
4991 ROLLBACK TO BscKpiPvt_DelKPIInTab;
4992 FND_MSG_PUB.Count_And_Get
4993 ( p_encoded => FND_API.G_FALSE
4994 , p_count => x_msg_count
4995 , p_data => x_msg_data
4996 );
4997 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
4998 x_return_status := FND_API.G_RET_STS_ERROR;
4999 RAISE;
5000 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5001 ROLLBACK TO BscKpiPvt_DelKPIInTab;
5002 FND_MSG_PUB.Count_And_Get
5003 ( p_encoded => FND_API.G_FALSE
5004 , p_count => x_msg_count
5005 , p_data => x_msg_data
5006 );
5007 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5008 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5009 RAISE;
5010 WHEN NO_DATA_FOUND THEN
5011 ROLLBACK TO BscKpiPvt_DelKPIInTab;
5012 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5013 IF (x_msg_data IS NOT NULL) THEN
5014 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_In_Tab ';
5015 ELSE
5016 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_In_Tab ';
5017 END IF;
5018 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5019 RAISE;
5020 WHEN OTHERS THEN
5021 ROLLBACK TO BscKpiPvt_DelKPIInTab;
5022 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5023 IF (x_msg_data IS NOT NULL) THEN
5024 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Kpi_In_Tab ';
5025 ELSE
5026 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Kpi_In_Tab ';
5027 END IF;
5028 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5029 RAISE;
5030
5031 end Delete_Kpi_In_Tab;
5032
5033 /************************************************************************************
5034 ************************************************************************************/
5035
5036 procedure Update_Kpi_Time_Stamp(
5037 p_commit IN varchar2 := FND_API.G_FALSE
5038 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
5039 ,x_return_status OUT NOCOPY varchar2
5040 ,x_msg_count OUT NOCOPY number
5041 ,x_msg_data OUT NOCOPY varchar2
5042 ) is
5043
5044 begin
5045 FND_MSG_PUB.Initialize;
5046 x_return_status := FND_API.G_RET_STS_SUCCESS;
5047 SAVEPOINT BscKpiPvt_UptKPITimSta;
5048 update BSC_KPIS_B
5049 set last_update_date = sysdate
5050 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5051
5052 if (p_commit = FND_API.G_TRUE) then
5053 commit;
5054 end if;
5055
5056 EXCEPTION
5057 WHEN FND_API.G_EXC_ERROR THEN
5058 ROLLBACK TO BscKpiPvt_UptKPITimSta;
5059 FND_MSG_PUB.Count_And_Get
5060 ( p_encoded => FND_API.G_FALSE
5061 , p_count => x_msg_count
5062 , p_data => x_msg_data
5063 );
5064 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
5065 x_return_status := FND_API.G_RET_STS_ERROR;
5066 RAISE;
5067 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5068 ROLLBACK TO BscKpiPvt_UptKPITimSta;
5069 FND_MSG_PUB.Count_And_Get
5070 ( p_encoded => FND_API.G_FALSE
5071 , p_count => x_msg_count
5072 , p_data => x_msg_data
5073 );
5074 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5075 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5076 RAISE;
5077 WHEN NO_DATA_FOUND THEN
5078 ROLLBACK TO BscKpiPvt_UptKPITimSta;
5079 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5080 IF (x_msg_data IS NOT NULL) THEN
5081 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Time_Stamp ';
5082 ELSE
5083 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Time_Stamp ';
5084 END IF;
5085 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5086 RAISE;
5087 WHEN OTHERS THEN
5088 ROLLBACK TO BscKpiPvt_UptKPITimSta;
5089 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5090 IF (x_msg_data IS NOT NULL) THEN
5091 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Update_Kpi_Time_Stamp ';
5092 ELSE
5093 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Update_Kpi_Time_Stamp ';
5094 END IF;
5095 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5096 RAISE;
5097 end Update_Kpi_Time_Stamp;
5098
5099 /************************************************************************************
5100 ************************************************************************************/
5101
5102 procedure Create_Master_Kpi(
5103 p_commit IN varchar2 := FND_API.G_FALSE
5104 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
5105 ,x_return_status OUT NOCOPY varchar2
5106 ,x_msg_count OUT NOCOPY number
5107 ,x_msg_data OUT NOCOPY varchar2
5108 ) is
5109
5110 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
5111
5112 l_count number;
5113
5114 --The following variables are needed as temporary holders.
5115 l_option_ids varchar2(100);
5116 l_occur number;
5117 l_beg_str number;
5118 l_end_str number;
5119 l_opt_id varchar2(5);
5120
5121
5122 begin
5123 FND_MSG_PUB.Initialize;
5124 x_return_status := FND_API.G_RET_STS_SUCCESS;
5125 SAVEPOINT BscKpiPvt_CrtMastKPI;
5126 --DBMS_OUTPUT.PUT_LINE('-- Begin BSC_KPI_PVT.Create_Master_Kpi');
5127
5128 -- Check that valid id was entered.
5129 if p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id is not null then
5130 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_KPIS_B'
5131 ,'indicator'
5132 ,p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5133 if l_count = 0 then
5134 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
5135 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5136 FND_MSG_PUB.ADD;
5137 RAISE FND_API.G_EXC_ERROR;
5138 end if;
5139 else
5140 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
5141 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5142 FND_MSG_PUB.ADD;
5143 RAISE FND_API.G_EXC_ERROR;
5144 end if;
5145
5146 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 1');
5147
5148 -- Check that valid tab id was entered.
5149 if p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id is not null then
5150 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 2');
5151
5152 l_count := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_TABS_B'
5153 ,'tab_id'
5154 ,p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
5155 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 3');
5156
5157 if l_count = 0 then
5158 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_TAB_ID');
5159 FND_MESSAGE.SET_TOKEN('BSC_TAB', p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
5160 FND_MSG_PUB.ADD;
5161 RAISE FND_API.G_EXC_ERROR;
5162 end if;
5163 else
5164 FND_MESSAGE.SET_NAME('BSC','BSC_NO_TAB_ID_ENTERED');
5165 FND_MESSAGE.SET_TOKEN('BSC_TAB', p_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id);
5166 FND_MSG_PUB.ADD;
5167 RAISE FND_API.G_EXC_ERROR;
5168 end if;
5169 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 4');
5170
5171
5172 -- set all values of the local record equal to the record passed.
5173 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
5174
5175 -- set entry for shared flag equal to 1.
5176 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag := 1;
5177 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Source_Ind := null;
5178
5179 -- Call update procedure (this will update the shared flag).
5180
5181 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 5');
5182
5183 Update_Kpi( p_commit
5184 ,l_Bsc_Kpi_Entity_Rec
5185 ,x_return_status
5186 ,x_msg_count
5187 ,x_msg_data);
5188
5189 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 6');
5190
5191 --DBMS_OUTPUT.PUT_LINE(' l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag = ' || l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Prototype_Flag );
5192
5193
5194 -- Now assign this KPI to the tab.
5195
5196 Create_Kpi_In_Tab( p_commit
5197 ,l_Bsc_Kpi_Entity_Rec
5198 ,x_return_status
5199 ,x_msg_count
5200 ,x_msg_data);
5201
5202 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 7');
5203
5204 -- show All the analysis options.
5205 update BSC_KPI_ANALYSIS_OPTIONS_B
5206 set USER_LEVEL1 = USER_LEVEL0
5207 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5208
5209 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 10');
5210
5211 if (p_commit = FND_API.G_TRUE) then
5212 commit;
5213 end if;
5214
5215 --DBMS_OUTPUT.PUT_LINE('-- End BSC_KPI_PVT.Create_Master_Kpi');
5216
5217
5218 EXCEPTION
5219 WHEN FND_API.G_EXC_ERROR THEN
5220 ROLLBACK TO BscKpiPvt_CrtMastKPI;
5221 FND_MSG_PUB.Count_And_Get
5222 ( p_encoded => FND_API.G_FALSE
5223 , p_count => x_msg_count
5224 , p_data => x_msg_data
5225 );
5226 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
5227 x_return_status := FND_API.G_RET_STS_ERROR;
5228 RAISE;
5229 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5230 ROLLBACK TO BscKpiPvt_CrtMastKPI;
5231 FND_MSG_PUB.Count_And_Get
5232 ( p_encoded => FND_API.G_FALSE
5233 , p_count => x_msg_count
5234 , p_data => x_msg_data
5235 );
5236 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5237 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5238 RAISE;
5239 WHEN NO_DATA_FOUND THEN
5240 ROLLBACK TO BscKpiPvt_CrtMastKPI;
5241 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5242 IF (x_msg_data IS NOT NULL) THEN
5243 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Master_Kpi ';
5244 ELSE
5245 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Master_Kpi ';
5246 END IF;
5247 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5248 RAISE;
5249 WHEN OTHERS THEN
5250 ROLLBACK TO BscKpiPvt_CrtMastKPI;
5251 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5252 IF (x_msg_data IS NOT NULL) THEN
5253 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Master_Kpi ';
5254 ELSE
5255 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Master_Kpi ';
5256 END IF;
5257 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5258 RAISE;
5259 end Create_Master_Kpi;
5260
5261 /************************************************************************************
5262 ************************************************************************************/
5263 procedure Create_Shared_Kpi(
5264 p_commit IN varchar2 := FND_API.G_FALSE
5265 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
5266 ,x_return_status OUT NOCOPY varchar2
5267 ,x_msg_count OUT NOCOPY number
5268 ,x_msg_data OUT NOCOPY varchar2
5269 ) is
5270
5271 TYPE Recdc_value IS REF CURSOR;
5272 dc_value Recdc_value;
5273
5274 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec; -- local Record.
5275 l_x_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec; -- to keep values
5276 -- from retrieve procedures.
5277
5278 l_Bsc_Dim_Set_Rec BSC_DIMENSION_SETS_PUB.Bsc_Dim_Set_Rec_Type;
5279 l_x_Bsc_Dim_Set_Rec BSC_DIMENSION_SETS_PUB.Bsc_Dim_Set_Rec_Type;
5280
5281 l_Bsc_Option_Rec BSC_ANALYSIS_OPTION_PUB.Bsc_Option_Rec_Type;
5282 l_x_Bsc_Option_Rec BSC_ANALYSIS_OPTION_PUB.Bsc_Option_Rec_Type;
5283
5284 l_sql VARCHAR2(2000);
5285 l_count NUMBER;
5286 l_kpi_id NUMBER;
5287
5288 --The following variableS ARE NEEDED AS TEMPORARy holders.
5289 l_Dim_Set_Id NUMBER;
5290 l_Dset_Dim_Level_Index NUMBER;
5291 l_Level_Name VARCHAR2(30);
5292 l_option_id NUMBER;
5293
5294 l_option_ids VARCHAR2(100);
5295 l_occur NUMBER;
5296 l_beg_str NUMBER;
5297 l_end_str NUMBER;
5298
5299 l_opt_id VARCHAR2(5);
5300
5301 l_kpi_source NUMBER;
5302 l_master_opt_default NUMBER;
5303 l_def_opt NUMBER;
5304 l_prototype_flag NUMBER;
5305 l_temp VARCHAR2(2000);
5306 l_config_type BSC_KPIS_B.config_type%TYPE;
5307 l_short_name BSC_KPIS_B.short_name%TYPE;
5308
5309
5310 begin
5311 FND_MSG_PUB.Initialize;
5312 x_return_status := FND_API.G_RET_STS_SUCCESS;
5313 SAVEPOINT BscKpiPvt_CrtShaKPI;
5314 --DBMS_OUTPUT.PUT_LINE('-- Begin BSC_KPI_PVT.Create_Shared_Kpi');
5315
5316 -- set the local RECORD equal to the passed RECORD.
5317 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
5318
5319 -- In order to create a shared KPI we will use a Function (create by hcamacho)
5320 -- which copies all necessary data from a source Indicator to a Target Indicator.
5321 -- After we will change necessary values to make the new Indicator a shared
5322 -- Indicator.
5323
5324 -- Get the next id available for the current Kpi.
5325 l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := BSC_DIMENSION_LEVELS_PVT.Get_Next_Value( 'BSC_KPIS_B'
5326 ,'indicator');
5327 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 1');
5328 --DBMS_OUTPUT.PUT_LINE(' New KPI code := ' || l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5329
5330 Retrieve_Kpi( p_commit
5331 ,p_Bsc_Kpi_Entity_Rec
5332 ,l_x_Bsc_Kpi_Entity_Rec
5333 ,x_return_status
5334 ,x_msg_count
5335 ,x_msg_data);
5336
5337 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 2');
5338
5339 l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5340 l_x_Bsc_Kpi_Entity_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
5341 l_x_Bsc_Kpi_Entity_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
5342 l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Short_Name :=NULL;
5343
5344 if l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id is not null then
5345
5346 SELECT COUNT(1) INTO l_Count
5347 FROM BSC_TAB_IND_GROUPS_B
5348 WHERE IND_GROUP_ID = l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id;
5349
5350 if l_count = 0 then
5351 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KGROUP_ID');
5352 FND_MESSAGE.SET_TOKEN('BSC_KGROUP',l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Group_Id);
5353 FND_MSG_PUB.ADD;
5354 RAISE FND_API.G_EXC_ERROR;
5355 end if;
5356 else
5357 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KGROUP_ID_ENTERED');
5358 FND_MSG_PUB.ADD;
5359 RAISE FND_API.G_EXC_ERROR;
5360 end if;
5361 l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Share_Flag := 2;
5362 Create_Kpi( p_commit
5363 ,l_x_Bsc_Kpi_Entity_Rec
5364 ,x_return_status
5365 ,x_msg_count
5366 ,x_msg_data);
5367
5368 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 3');
5369 --DBMS_OUTPUT.PUT_LINE(' p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := ' || p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5370
5371 /*Retrieve_Kpi_Defaults( p_commit
5372 ,p_Bsc_Kpi_Entity_Rec
5373 ,l_x_Bsc_Kpi_Entity_Rec
5374 ,x_return_status
5375 ,x_msg_count
5376 ,x_msg_data);
5377
5378
5379 l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5380 l_x_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id;
5381 l_x_Bsc_Kpi_Entity_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
5382 l_x_Bsc_Kpi_Entity_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
5383
5384 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 4');
5385 --DBMS_OUTPUT.PUT_LINE('l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := ' || l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
5386
5387 Create_Kpi_Defaults( p_commit
5388 ,l_x_Bsc_Kpi_Entity_Rec
5389 ,x_return_status
5390 ,x_msg_count
5391 ,x_msg_data);
5392
5393 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 5');*/
5394
5395 Retrieve_Kpi_In_Tab( p_commit
5396 ,p_Bsc_Kpi_Entity_Rec
5397 ,l_x_Bsc_Kpi_Entity_Rec
5398 ,x_return_status
5399 ,x_msg_count
5400 ,x_msg_data);
5401
5402 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 6');
5403
5404 l_x_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5405 l_x_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id := l_Bsc_Kpi_Entity_Rec.Bsc_Tab_Id;
5406 l_x_Bsc_Kpi_Entity_Rec.Bsc_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Language;
5407 l_x_Bsc_Kpi_Entity_Rec.Bsc_Source_Language := p_Bsc_Kpi_Entity_Rec.Bsc_Source_Language;
5408
5409
5410 Create_Kpi_In_Tab( p_commit
5411 ,l_x_Bsc_Kpi_Entity_Rec
5412 ,x_return_status
5413 ,x_msg_count
5414 ,x_msg_data);
5415
5416 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 7');
5417
5418 BSC_DESIGNER_PVT.Duplicate_KPI_Metadata( p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
5419 ,l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
5420 ,0
5421 ,'');
5422
5423 --For Simulation type of objectives we need to copy
5424 -- data from ak_regions and tab_view_labels also
5425 SELECT config_type,short_name
5426 INTO l_config_type,l_short_name
5427 FROM bsc_kpis_vl
5428 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5429
5430 IF(l_config_type =BSC_SIMULATION_VIEW_PUB.c_TYPE AND l_short_name IS NOT NULL) THEN
5431
5432 BSC_SIMULATION_VIEW_PUB.copy_sim_metadata
5433 (
5434 p_source_kpi => p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
5435 ,p_target_kpi => l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
5436 ,x_return_status => x_return_status
5437 ,x_msg_count => x_msg_count
5438 ,x_msg_data => x_msg_data
5439 );
5440 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5441 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5442 END IF;
5443 END IF;
5444
5445
5446 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 8');
5447
5448 select decode(property_value,1,1,3)
5449 into l_prototype_flag
5450 from bsc_sys_init
5451 where property_code = 'SYSTEM_STAGE';
5452
5453 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 9');
5454
5455 -- Set shared flag values.
5456 update BSC_KPIS_B
5457 set share_flag = 2
5458 ,prototype_flag = l_prototype_flag
5459 ,source_indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
5460 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5461
5462 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 10');
5463
5464 BSC_DESIGNER_PVT.ActionFlag_Change(l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id, BSC_DESIGNER_PVT.G_ActionFlag.Prototype);
5465
5466 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 11');
5467
5468 -- show All the analysis options.
5469 update BSC_KPI_ANALYSIS_OPTIONS_B
5470 set USER_LEVEL1 = USER_LEVEL0
5471 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5472
5473 -- Fix issue in bug 3248729
5474 /* Delete Rows in BSC_KPI_DATA_TABLES for the Share KPI
5475 We can not use procedure Delete_Kpi_Data_tables because of the
5476 validation added when the KPI is deleting */
5477
5478 DELETE FROM BSC_KPI_DATA_TABLES
5479 WHERE INDICATOR = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5480 -- Fix issue in bug 3248729
5481
5482
5483 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 12');
5484
5485 -- Get a responsibility id for BSC_MANAGER
5486 select responsibility_id
5487 into l_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id
5488 from FND_RESPONSIBILITY
5489 where responsibility_key = 'BSC_Manager';
5490
5491 -- set some values
5492 l_Bsc_Kpi_Entity_Rec.Created_By:= 0;
5493 l_Bsc_Kpi_Entity_Rec.Last_Updated_By:= 0;
5494 l_Bsc_Kpi_Entity_Rec.Last_Update_Login:= 0;
5495 l_Bsc_Kpi_Entity_Rec.Last_Update_Login:= 0;
5496
5497 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 13');
5498
5499 -- Grant access
5500 BSC_KPI_PUB.Create_Kpi_User_Access( p_commit
5501 ,l_Bsc_Kpi_Entity_Rec
5502 ,x_return_status
5503 ,x_msg_count
5504 ,x_msg_data);
5505
5506
5507 -- Get a responsibility id for BSC_PMD_USER
5508
5509 /*select responsibility_id
5510 into l_Bsc_Kpi_Entity_Rec.Bsc_Responsibility_Id
5511 from FND_RESPONSIBILITY
5512 where responsibility_key = 'BSC_PMD_USER';
5513
5514 BSC_KPI_PUB.Create_Kpi_User_Access( p_commit
5515 ,l_Bsc_Kpi_Entity_Rec
5516 ,x_return_status
5517 ,x_msg_count
5518 ,x_msg_data);*/
5519
5520
5521
5522 if (p_commit = FND_API.G_TRUE) then
5523 commit;
5524 end if;
5525
5526 --DBMS_OUTPUT.PUT_LINE('-- End BSC_KPI_PVT.Create_Shared_Kpi');
5527
5528 EXCEPTION
5529 WHEN FND_API.G_EXC_ERROR THEN
5530 ROLLBACK TO BscKpiPvt_CrtShaKPI;
5531 FND_MSG_PUB.Count_And_Get
5532 ( p_encoded => FND_API.G_FALSE
5533 , p_count => x_msg_count
5534 , p_data => x_msg_data
5535 );
5536 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
5537 x_return_status := FND_API.G_RET_STS_ERROR;
5538 RAISE;
5539 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5540 ROLLBACK TO BscKpiPvt_CrtShaKPI;
5541 FND_MSG_PUB.Count_And_Get
5542 ( p_encoded => FND_API.G_FALSE
5543 , p_count => x_msg_count
5544 , p_data => x_msg_data
5545 );
5546 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5547 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5548 RAISE;
5549 WHEN NO_DATA_FOUND THEN
5550 ROLLBACK TO BscKpiPvt_CrtShaKPI;
5551 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5552 IF (x_msg_data IS NOT NULL) THEN
5553 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Shared_Kpi ';
5554 ELSE
5555 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Shared_Kpi ';
5556 END IF;
5557 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5558 RAISE;
5559 WHEN OTHERS THEN
5560 ROLLBACK TO BscKpiPvt_CrtShaKPI;
5561 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5562 IF (x_msg_data IS NOT NULL) THEN
5563 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Create_Shared_Kpi ';
5564 ELSE
5565 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Create_Shared_Kpi ';
5566 END IF;
5567 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5568 RAISE;
5569 end Create_Shared_Kpi;
5570
5571 /************************************************************************************
5572 ************************************************************************************/
5573
5574 procedure Move_Tab(
5575 p_tab_id number
5576 ,p_tab_index number
5577 ,x_return_status OUT NOCOPY varchar2
5578 ,x_msg_count OUT NOCOPY number
5579 ,x_msg_data OUT NOCOPY varchar2
5580 ) is
5581
5582 l_Bsc_Kpi_Entity_Tbl BSC_SCORECARD_PUB.Bsc_Tab_Entity_Tbl;
5583
5584 TYPE Recdc_value IS REF CURSOR;
5585 dc_value Recdc_value;
5586
5587 l_cnt number;
5588
5589 l_sql varchar2(2000);
5590
5591 begin
5592 FND_MSG_PUB.Initialize;
5593 x_return_status := FND_API.G_RET_STS_SUCCESS;
5594 SAVEPOINT BscKpiPvt_MoveTab;
5595 -- Check that valid id was entered.
5596 if p_tab_id is not null then
5597 l_cnt := BSC_DIMENSION_LEVELS_PVT.Validate_Value( 'BSC_TABS_B'
5598 ,'tab_id'
5599 ,p_tab_id);
5600 if l_cnt = 0 then
5601 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_TAB_ID');
5602 FND_MESSAGE.SET_TOKEN('BSC_TAB', p_tab_id);
5603 FND_MSG_PUB.ADD;
5604 RAISE FND_API.G_EXC_ERROR;
5605 end if;
5606 else
5607 FND_MESSAGE.SET_NAME('BSC','BSC_NO_TAB_ID_ENTERED');
5608 FND_MESSAGE.SET_TOKEN('BSC_TAB', p_tab_id);
5609 FND_MSG_PUB.ADD;
5610 RAISE FND_API.G_EXC_ERROR;
5611 end if;
5612
5613 l_sql := 'select distinct tab_id, tab_index ' ||
5614 ' from BSC_TABS_B ' ||
5615 ' where tab_index >= :1' ||
5616 ' and tab_id != :2' ||
5617 ' order by tab_index asc';
5618
5619 l_cnt := 0;
5620 open dc_value for l_sql using p_tab_index, p_tab_id ;
5621 loop
5622 fetch dc_value into l_Bsc_Kpi_Entity_Tbl(l_cnt + 1).Bsc_Tab_Id,
5623 l_Bsc_Kpi_Entity_Tbl(l_cnt + 1).Bsc_Tab_Index;
5624 exit when dc_value%NOTFOUND;
5625 l_cnt := l_cnt + 1;
5626 end loop;
5627 close dc_value;
5628
5629 for i in 1..l_Bsc_Kpi_Entity_Tbl.count loop
5630 update BSC_TABS_B
5631 set tab_index = l_Bsc_Kpi_Entity_Tbl(i).Bsc_Tab_Index + 1
5632 where tab_id = l_Bsc_Kpi_Entity_Tbl(i).Bsc_Tab_Id;
5633 end loop;
5634
5635 -- commit;
5636
5637 EXCEPTION
5638 WHEN FND_API.G_EXC_ERROR THEN
5639 ROLLBACK TO BscKpiPvt_MoveTab;
5640 FND_MSG_PUB.Count_And_Get
5641 ( p_encoded => FND_API.G_FALSE
5642 , p_count => x_msg_count
5643 , p_data => x_msg_data
5644 );
5645 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
5646 x_return_status := FND_API.G_RET_STS_ERROR;
5647 RAISE;
5648 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5649 ROLLBACK TO BscKpiPvt_MoveTab;
5650 FND_MSG_PUB.Count_And_Get
5651 ( p_encoded => FND_API.G_FALSE
5652 , p_count => x_msg_count
5653 , p_data => x_msg_data
5654 );
5655 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5656 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5657 RAISE;
5658 WHEN NO_DATA_FOUND THEN
5659 ROLLBACK TO BscKpiPvt_MoveTab;
5660 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5661 IF (x_msg_data IS NOT NULL) THEN
5662 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Move_Tab ';
5663 ELSE
5664 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Move_Tab ';
5665 END IF;
5666 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5667 RAISE;
5668 WHEN OTHERS THEN
5669 ROLLBACK TO BscKpiPvt_MoveTab;
5670 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5671 IF (x_msg_data IS NOT NULL) THEN
5672 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Move_Tab ';
5673 ELSE
5674 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Move_Tab ';
5675 END IF;
5676 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5677 RAISE;
5678
5679 end Move_Tab;
5680
5681 /************************************************************************************
5682 ************************************************************************************/
5683
5684 function Validate_Tab(
5685 p_Tab_Name IN varchar2
5686 ) return number is
5687
5688 l_count number;
5689
5690 begin
5691
5692 select count(*)
5693 into l_count
5694 from BSC_TABS_TL
5695 where upper(name) = upper(p_Tab_Name);
5696
5697 return l_count;
5698
5699 EXCEPTION
5700 when others then
5701 null;
5702
5703 end Validate_Tab;
5704
5705 /************************************************************************************
5706 ************************************************************************************/
5707
5708 function Validate_Kpi_Group(
5709 p_Kpi_Group_Name IN varchar2
5710 ) return number is
5711
5712 l_count number;
5713
5714 begin
5715
5716 select count(*)
5717 into l_count
5718 from BSC_TAB_IND_GROUPS_TL
5719 where upper(name) = upper(p_Kpi_Group_Name);
5720
5721 return l_count;
5722
5723 EXCEPTION
5724 when others then
5725 null;
5726
5727 end Validate_Kpi_Group;
5728
5729 /************************************************************************************
5730 ************************************************************************************/
5731
5732 function Validate_Kpi(
5733 p_Kpi_Name IN varchar2
5734 ) return number is
5735
5736 l_count number;
5737
5738 begin
5739
5740 select count(*)
5741 into l_count
5742 from BSC_KPIS_TL
5743 where upper(name) = upper(p_Kpi_Name);
5744
5745 return l_count;
5746
5747 EXCEPTION
5748 when others then
5749 null;
5750
5751 end Validate_Kpi;
5752
5753 /************************************************************************************
5754 ************************************************************************************/
5755
5756 procedure Set_Default_Option(
5757 p_commit IN varchar2 := FND_API.G_FALSE
5758 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
5759 ,x_return_status OUT NOCOPY varchar2
5760 ,x_msg_count OUT NOCOPY number
5761 ,x_msg_data OUT NOCOPY varchar2
5762 ) is
5763
5764 l_Bsc_Kpi_Entity_Rec BSC_KPI_PUB.Bsc_Kpi_Entity_Rec;
5765
5766 TYPE Recdc_value IS REF CURSOR;
5767 dc_value Recdc_value;
5768
5769 l_sql varchar2(5000);
5770
5771 l_count number;
5772 l_share_flag number;
5773 l_proto_flag number;
5774 l_shared_kpi number;
5775 l_def_option number;
5776
5777 CURSOR c_Select_Indicator IS
5778 SELECT INDICATOR
5779 FROM BSC_KPIS_B
5780 WHERE SOURCE_INDICATOR = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5781 AND PROTOTYPE_FLAG <> BSC_KPI_PUB.Delete_Kpi_Flag;
5782
5783 begin
5784 FND_MSG_PUB.Initialize;
5785 x_return_status := FND_API.G_RET_STS_SUCCESS;
5786 l_Bsc_Kpi_Entity_Rec := p_Bsc_Kpi_Entity_Rec;
5787 SAVEPOINT BscKpiPvt_SetDefOption;
5788 -- First step is to see if the default has been deselected. If it has, set another
5789 -- default if it is the Master KPI, if it is not the Master KPI, then reselect the
5790 -- default from the Master.
5791 select count(*)
5792 into l_count
5793 from BSC_KPI_ANALYSIS_OPTIONS_B
5794 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5795 and analysis_group_id = 0
5796 and user_level1 = 1;
5797
5798 if l_count = 0 then
5799
5800 -- Check if this is the Master KPI.
5801 SELECT SHARE_FLAG, PROTOTYPE_FLAG
5802 INTO l_share_flag, l_proto_flag
5803 FROM BSC_KPIS_B
5804 WHERE INDICATOR = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id;
5805
5806 if ((l_share_flag = 1) and (l_proto_flag <> BSC_KPI_PUB.DELETE_KPI_FLAG)) then
5807
5808 -- Second step is to set the default option (1) by selecting the first displayed
5809 -- option. At this point all displayed options are flagged with 2.
5810 update BSC_KPI_ANALYSIS_OPTIONS_B
5811 set user_level1 = 1
5812 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5813 and analysis_group_id = 0
5814 and option_id = (select option_id
5815 from BSC_KPI_ANALYSIS_OPTIONS_B
5816 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5817 and user_level1 = 2
5818 and rownum < 2);
5819
5820 -- store the default option.
5821 select option_id
5822 into l_def_option
5823 from BSC_KPI_ANALYSIS_OPTIONS_B
5824 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5825 and analysis_group_id = 0
5826 and user_level1 = 1;
5827
5828 -- update the Default option in KPI ANALYSIS GROUPS
5829 update BSC_KPI_ANALYSIS_GROUPS
5830 set default_value = l_def_option
5831 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id;
5832
5833
5834 -- Now all shared Kpis need to be updated. Get these shared Indicators.
5835
5836 FOR SrcInd IN c_Select_Indicator LOOP
5837 l_shared_kpi := SrcInd.INDICATOR;
5838
5839 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5840 SET USER_LEVEL1 = 2
5841 WHERE INDICATOR = l_shared_kpi
5842 AND ANALYSIS_GROUP_ID = 0
5843 AND USER_LEVEL1 = 1;
5844
5845 -- then set the default option.
5846 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5847 SET USER_LEVEL1 = 1
5848 WHERE INDICATOR = l_shared_kpi
5849 AND ANALYSIS_GROUP_ID = 0
5850 AND OPTION_ID = L_DEF_OPTION;
5851
5852 -- update the Default option in KPI ANALYSIS GROUPS
5853 UPDATE BSC_KPI_ANALYSIS_GROUPS
5854 SET DEFAULT_VALUE = l_def_option
5855 WHERE INDICATOR = l_shared_kpi;
5856
5857 END LOOP;
5858
5859 elsif ((l_share_flag = 2) and (l_proto_flag <> BSC_KPI_PUB.DELETE_KPI_FLAG)) then-- this is a shared indicator.
5860
5861 -- Get the source indicator for this shared indicator.
5862 select source_indicator
5863 into l_shared_kpi
5864 from BSC_KPIS_B
5865 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id;
5866
5867 -- Get the default analysis option id.
5868 select default_value
5869 into l_def_option
5870 from BSC_KPI_ANALYSIS_GROUPS
5871 where indicator = l_shared_kpi
5872 and analysis_group_id = 0;
5873
5874 update BSC_KPI_ANALYSIS_OPTIONS_B
5875 set user_level1 = 1
5876 where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5877 and analysis_group_id = 0
5878 and option_id = l_def_option;
5879
5880 end if; -- l_share_flag
5881
5882
5883 end if; -- l_count
5884
5885 -- Block for Force Default Option ends here.
5886
5887 if (p_commit = FND_API.G_TRUE) then
5888 commit;
5889 end if;
5890
5891
5892 EXCEPTION
5893 WHEN FND_API.G_EXC_ERROR THEN
5894 ROLLBACK TO BscKpiPvt_SetDefOption;
5895 FND_MSG_PUB.Count_And_Get
5896 ( p_encoded => FND_API.G_FALSE
5897 , p_count => x_msg_count
5898 , p_data => x_msg_data
5899 );
5900 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
5901 x_return_status := FND_API.G_RET_STS_ERROR;
5902 RAISE;
5903 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5904 ROLLBACK TO BscKpiPvt_SetDefOption;
5905 FND_MSG_PUB.Count_And_Get
5906 ( p_encoded => FND_API.G_FALSE
5907 , p_count => x_msg_count
5908 , p_data => x_msg_data
5909 );
5910 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5911 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
5912 RAISE;
5913 WHEN NO_DATA_FOUND THEN
5914 ROLLBACK TO BscKpiPvt_SetDefOption;
5915 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5916 IF (x_msg_data IS NOT NULL) THEN
5917 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Set_Default_Option ';
5918 ELSE
5919 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Set_Default_Option ';
5920 END IF;
5921 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
5922 RAISE;
5923 WHEN OTHERS THEN
5924 ROLLBACK TO BscKpiPvt_SetDefOption;
5925 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5926 IF (x_msg_data IS NOT NULL) THEN
5927 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Set_Default_Option ';
5928 ELSE
5929 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Set_Default_Option ';
5930 END IF;
5931 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
5932 RAISE;
5933
5934 end Set_Default_Option;
5935
5936 /************************************************************************************
5937 ************************************************************************************/
5938 PROCEDURE Set_Default_Value_By_Option_ID
5939 ( p_Kpi_Id NUMBER
5940 , p_group_Id NUMBER
5941 , p_parent_option_Id NUMBER
5942 , p_grand_parent_option_Id NUMBER
5943 , p_option_Id NUMBER
5944 ) IS
5945 l_Dependency_Flag NUMBER := 0;
5946 l_old_option_id NUMBER := 0;
5947 l_old_parent_option_Id NUMBER := 0;
5948 l_old_grandparent_option_Id NUMBER := 0;
5949 l_Default_Value NUMBER := 0;
5950 l_count NUMBER := 0;
5951
5952 CURSOR c_old_option_id IS
5953 SELECT Option_Id, Parent_Option_Id, Grandparent_Option_Id
5954 FROM BSC_KPI_ANALYSIS_OPTIONS_B
5955 WHERE Indicator = p_Kpi_Id
5956 AND Analysis_Group_ID = p_group_Id
5957 AND User_Level0 = 1;
5958 BEGIN
5959 SAVEPOINT BSCSeefaulValPVT;
5960 SELECT Dependency_Flag, Default_Value
5961 INTO l_Dependency_Flag, l_Default_Value
5962 FROM BSC_KPI_ANALYSIS_GROUPS
5963 WHERE Indicator = p_Kpi_Id
5964 AND Analysis_Group_Id = p_group_Id;
5965
5966 -- find current default options
5967 IF (c_old_option_id%ISOPEN) THEN
5968 CLOSE c_old_option_id;
5969 END IF;
5970 OPEN c_old_option_id;
5971 FETCH c_old_option_id
5972 INTO l_old_option_id
5973 , l_old_parent_option_Id
5974 , l_old_grandparent_option_Id;
5975 CLOSE c_old_option_id;
5976
5977 IF (l_Dependency_Flag = 0) THEN -- for indenpendent
5978
5979 IF (l_old_option_id <> p_option_Id) THEN
5980 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5981 SET User_Level0 = 1
5982 , User_Level1 = 1
5983 WHERE Indicator = p_Kpi_Id
5984 AND Analysis_Group_Id = p_group_Id
5985 AND Option_Id = p_option_Id;
5986
5987 UPDATE BSC_KPI_ANALYSIS_GROUPS
5988 SET Default_Value = p_option_Id
5989 WHERE Indicator = p_Kpi_Id
5990 AND Analysis_Group_Id = p_group_Id;
5991
5992 -- change previous default option id back to normal
5993 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5994 SET User_Level0 = 2
5995 , User_Level1 = 2
5996 WHERE Indicator = p_Kpi_Id
5997 AND Analysis_Group_Id = p_group_Id
5998 AND Option_Id = l_old_option_id;
5999
6000 END IF;
6001
6002 ELSE -- for dependent
6003 IF (p_group_Id = 0) THEN
6004
6005 IF (l_old_option_id <> p_option_Id) THEN
6006
6007 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6008 SET User_Level0 = 1
6009 , User_Level1 = 1
6010 WHERE Indicator = p_Kpi_Id
6011 AND Analysis_Group_Id = p_group_Id
6012 AND Option_Id = p_option_Id;
6013
6014 UPDATE BSC_KPI_ANALYSIS_GROUPS
6015 SET Default_Value = p_option_Id
6016 WHERE Indicator = p_Kpi_Id
6017 AND Analysis_Group_Id = p_group_Id;
6018
6019 -- change previous default option id back to normal
6020 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6021 SET User_Level0 = 2
6022 , User_Level1 = 2
6023 WHERE Indicator = p_Kpi_Id
6024 AND Analysis_Group_Id = p_group_Id
6025 AND Option_Id = l_old_option_id;
6026
6027 END IF;
6028 ELSIF (p_group_Id = 1) THEN
6029
6030 IF (l_old_option_id <> p_option_Id ) OR (l_old_parent_option_Id <> p_Parent_Option_Id) THEN
6031
6032 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6033 SET User_Level0 = 1
6034 , User_Level1 = 1
6035 WHERE Indicator = p_Kpi_Id
6036 AND Analysis_Group_Id = p_group_Id
6037 AND Option_Id = p_option_Id
6038 AND Parent_Option_Id = p_Parent_Option_Id;
6039
6040 UPDATE BSC_KPI_ANALYSIS_GROUPS
6041 SET Default_Value = p_option_Id
6042 WHERE Indicator = p_Kpi_Id
6043 AND Analysis_Group_Id = p_group_Id;
6044
6045 -- change previous default option id back to normal
6046 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6047 SET User_Level0 = 2
6048 , User_Level1 = 2
6049 WHERE Indicator = p_Kpi_Id
6050 AND Analysis_Group_Id = p_group_Id
6051 AND Option_Id = l_old_option_Id
6052 AND Parent_Option_Id = l_old_parent_option_Id;
6053
6054 END IF;
6055 ELSIF (p_group_Id = 2) THEN
6056
6057 IF (l_old_option_id <> p_option_Id ) OR (l_old_parent_option_Id <> p_Parent_Option_Id)
6058 OR (l_old_grandparent_option_Id <> p_Grand_Parent_Option_Id) THEN
6059
6060 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6061 SET User_Level0 = 1
6062 , User_Level1 = 1
6063 WHERE Indicator = p_Kpi_Id
6064 AND Analysis_Group_Id = p_group_Id
6065 AND Option_Id = p_option_Id
6066 AND Parent_Option_Id = p_Parent_Option_Id
6067 AND Grandparent_Option_Id = p_Grand_Parent_Option_Id;
6068
6069 UPDATE BSC_KPI_ANALYSIS_GROUPS
6070 SET Default_Value = p_option_Id
6071 WHERE Indicator = p_Kpi_Id
6072 AND Analysis_Group_Id = p_group_Id;
6073
6074 -- change previous default option id back to normal
6075 UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6076 SET User_Level0 = 2
6077 , User_Level1 = 2
6078 WHERE Indicator = p_Kpi_Id
6079 AND Analysis_Group_Id = p_group_Id
6080 AND Option_Id = l_old_option_Id
6081 AND Parent_Option_Id = l_old_parent_option_Id
6082 AND Grandparent_Option_Id = l_old_grandparent_option_Id;
6083
6084 END IF;
6085 END IF;
6086 END IF;
6087
6088 EXCEPTION
6089 WHEN OTHERS THEN
6090 ROLLBACK TO BSCSeefaulValPVT;
6091 IF (c_old_option_id%ISOPEN) THEN
6092 CLOSE c_old_option_id;
6093 END IF;
6094 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS at Set_Default_Value_By_ID '||SQLERRM);
6095 RAISE;
6096 END Set_Default_Value_By_Option_ID;
6097
6098 /************************************************************************************
6099 ************************************************************************************/
6100
6101 procedure Set_Default_Option_MG(
6102 p_commit IN varchar2 := FND_API.G_FALSE
6103 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_Kpi_Entity_Rec
6104 ,x_return_status OUT NOCOPY varchar2
6105 ,x_msg_count OUT NOCOPY number
6106 ,x_msg_data OUT NOCOPY varchar2
6107 ) is
6108
6109 l_source_kpi number;
6110 l_proto_flag number;
6111 l_default_option number;
6112 l_default_parent_option number;
6113 l_default_grandparent_option number;
6114 l_group_count number;
6115 l_dependency1_flag number;
6116 l_dependency2_flag number;
6117
6118 begin
6119 FND_MSG_PUB.Initialize;
6120 x_return_status := FND_API.G_RET_STS_SUCCESS;
6121 SAVEPOINT BscKpiPvt_SetDefOptionMG;
6122 -- Get the source indicator for this shared kpi.
6123 SELECT Source_Indicator, Prototype_Flag
6124 INTO l_source_kpi, l_proto_flag
6125 FROM BSC_KPIS_B
6126 WHERE INDICATOR = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
6127
6128 IF (l_proto_flag <> BSC_KPI_PUB.Delete_Kpi_Flag) THEN
6129 -- Get the number of analysis groups in this or in source kpi.
6130 select max(analysis_group_id)
6131 into l_group_count
6132 from BSC_KPI_ANALYSIS_GROUPS
6133 where indicator = l_source_kpi;
6134
6135 -- Get the default option id for the first analysis groups.
6136 select default_value
6137 into l_default_option
6138 from BSC_KPI_ANALYSIS_GROUPS
6139 where indicator = l_source_kpi
6140 and analysis_group_id = 0;
6141
6142 -- Set this default option for the display flag
6143 update BSC_KPI_ANALYSIS_OPTIONS_B
6144 set user_level1 = 1
6145 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6146 and analysis_group_id = 0
6147 and option_id = l_default_option;
6148
6149 -- The fact that we are in this procedure implies this is a multi group
6150 -- indicator.
6151
6152 -- Determine if there is a dependency between groups 1 and 0, and get the
6153 -- default option id.
6154 select dependency_flag, default_value
6155 into l_dependency1_flag, l_default_option
6156 from BSC_KPI_ANALYSIS_GROUPS
6157 where indicator = l_source_kpi
6158 and analysis_group_id = 1;
6159
6160 -- If there is no dependency apply This flag without filtering on parent id.
6161 if l_dependency1_flag <> 1 then
6162
6163 update BSC_KPI_ANALYSIS_OPTIONS_B
6164 set user_level1 = 1
6165 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6166 and analysis_group_id = 1
6167 and option_id = l_default_option;
6168
6169 else
6170
6171 select default_value
6172 into l_default_parent_option
6173 from BSC_KPI_ANALYSIS_GROUPS
6174 where indicator = l_source_kpi
6175 and analysis_group_id = 0;
6176
6177 update BSC_KPI_ANALYSIS_OPTIONS_B
6178 set user_level1 = 1
6179 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6180 and analysis_group_id = 1
6181 and option_id = l_default_option
6182 and parent_option_id = l_default_parent_option;
6183
6184
6185 end if;
6186
6187 -- check if this kpi has more than two analysis groups.
6188 if l_group_count > 1 then
6189
6190 -- Determine if there is a dependency between groups 2 and 1.
6191 select dependency_flag, default_value
6192 into l_dependency2_flag, l_default_option
6193 from BSC_KPI_ANALYSIS_GROUPS
6194 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6195 and analysis_group_id = 2;
6196
6197 -- if there is no dependency between groups 1 and 0, and 2 and 1 apply flag
6198 if l_dependency1_flag <> 1 and l_dependency2_flag <> 1 then
6199
6200 update BSC_KPI_ANALYSIS_OPTIONS_B
6201 set user_level1 = 1
6202 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6203 and analysis_group_id = 2
6204 and option_id = l_default_option;
6205
6206 elsif l_dependency1_flag <> 1 then
6207
6208 select default_value
6209 into l_default_parent_option
6210 from BSC_KPI_ANALYSIS_GROUPS
6211 where indicator = l_source_kpi
6212 and analysis_group_id = 1;
6213
6214 update BSC_KPI_ANALYSIS_OPTIONS_B
6215 set user_level1 = 1
6216 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6217 and analysis_group_id = 2
6218 and option_id = l_default_option
6219 and parent_option_id = l_default_parent_option;
6220
6221 else -- dependency between groups 0 and 1
6222
6223 -- If there is no dependency flag between 2 an 1 then do not filter.
6224 if l_dependency2_flag <> 1 then
6225
6226 update BSC_KPI_ANALYSIS_OPTIONS_B
6227 set user_level1 = 1
6228 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6229 and analysis_group_id = 2
6230 and option_id = l_default_option;
6231
6232 else
6233
6234 select default_value
6235 into l_default_parent_option
6236 from BSC_KPI_ANALYSIS_GROUPS
6237 where indicator = l_source_kpi
6238 and analysis_group_id = 1;
6239
6240 select default_value
6241 into l_default_grandparent_option
6242 from BSC_KPI_ANALYSIS_GROUPS
6243 where indicator = l_source_kpi
6244 and analysis_group_id = 0;
6245
6246 update BSC_KPI_ANALYSIS_OPTIONS_B
6247 set user_level1 = 1
6248 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6249 and analysis_group_id = 2
6250 and option_id = l_default_option
6251 and parent_option_id = l_default_parent_option
6252 and grandparent_option_id = l_default_grandparent_option;
6253
6254 end if;
6255
6256 end if;
6257
6258 end if;
6259
6260 END IF;
6261
6262 if (p_commit = FND_API.G_TRUE) then
6263 commit;
6264 end if;
6265
6266
6267 EXCEPTION
6268 WHEN FND_API.G_EXC_ERROR THEN
6269 ROLLBACK TO BscKpiPvt_SetDefOptionMG;
6270 FND_MSG_PUB.Count_And_Get
6271 ( p_encoded => FND_API.G_FALSE
6272 , p_count => x_msg_count
6273 , p_data => x_msg_data
6274 );
6275 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6276 x_return_status := FND_API.G_RET_STS_ERROR;
6277 RAISE;
6278 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6279 ROLLBACK TO BscKpiPvt_SetDefOptionMG;
6280 FND_MSG_PUB.Count_And_Get
6281 ( p_encoded => FND_API.G_FALSE
6282 , p_count => x_msg_count
6283 , p_data => x_msg_data
6284 );
6285 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6286 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6287 RAISE;
6288 WHEN NO_DATA_FOUND THEN
6289 ROLLBACK TO BscKpiPvt_SetDefOptionMG;
6290 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6291 IF (x_msg_data IS NOT NULL) THEN
6292 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Set_Default_Option_MG ';
6293 ELSE
6294 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Set_Default_Option_MG ';
6295 END IF;
6296 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6297 RAISE;
6298 WHEN OTHERS THEN
6299 ROLLBACK TO BscKpiPvt_SetDefOptionMG;
6300 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6301 IF (x_msg_data IS NOT NULL) THEN
6302 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Set_Default_Option_MG ';
6303 ELSE
6304 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Set_Default_Option_MG ';
6305 END IF;
6306 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6307 RAISE;
6308 end Set_Default_Option_MG;
6309
6310 /************************************************************************************
6311 ************************************************************************************/
6312
6313 procedure Assign_Analysis_Option(
6314 p_Bsc_kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_kpi_Entity_Rec
6315 ,x_return_status OUT NOCOPY varchar2
6316 ,x_msg_count OUT NOCOPY number
6317 ,x_msg_data OUT NOCOPY varchar2
6318 ) IS
6319
6320 l_option_id number;
6321 l_parent_option_id number;
6322 l_grandparent_option_id number;
6323 l_Bsc_kpi_Entity_Rec BSC_KPI_PUB.Bsc_kpi_Entity_Rec;
6324
6325 Begin
6326 FND_MSG_PUB.Initialize;
6327 x_return_status := FND_API.G_RET_STS_SUCCESS;
6328 SAVEPOINT BscKpiPvt_AssAnaOpts;
6329 --DBMS_OUTPUT.PUT_LINE('Begin BSC_KPI_PVT.Assign_Analysis_Option');
6330
6331 l_parent_option_id := 0;
6332 l_grandparent_option_id := 0;
6333
6334 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 0 then
6335 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6336 elsif p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 1 then
6337 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6338 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6339 else -- if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6340 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option2;
6341 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6342 l_grandparent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6343 end if;
6344
6345 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id = ' || p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6346 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = ' || p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id);
6347 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_option_id = ' || l_option_id);
6348 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_parent_option_id = ' || l_parent_option_id);
6349 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_grandparent_option_id = ' || l_grandparent_option_id);
6350 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag = ' || p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag);
6351
6352
6353 -- Update the Analysis Option Set the option visible
6354 update BSC_KPI_ANALYSIS_OPTIONS_B
6355 set user_level1 = user_level0
6356 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6357 and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6358 and option_id = l_option_id
6359 and parent_option_id = l_parent_option_id
6360 and grandparent_option_id = l_grandparent_option_id;
6361
6362 -- Set Visible the Parent Option if it apply
6363 if p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag <> 0 and p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id > 0 then
6364
6365 l_Bsc_kpi_Entity_Rec := p_Bsc_kpi_Entity_Rec;
6366 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6367 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 1;
6368 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := l_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag;
6369 else
6370 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 0;
6371 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := 0;
6372 end if;
6373 l_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag := 0;
6374
6375 Assign_Analysis_Option(l_Bsc_kpi_Entity_Rec
6376 ,x_return_status
6377 ,x_msg_count
6378 ,x_msg_data);
6379 end if;
6380
6381 --DBMS_OUTPUT.PUT_LINE('End BSC_KPI_PVT.Assign_Analysis_Option');
6382
6383
6384 EXCEPTION
6385 WHEN FND_API.G_EXC_ERROR THEN
6386 ROLLBACK TO BscKpiPvt_AssAnaOpts;
6387 FND_MSG_PUB.Count_And_Get
6388 ( p_encoded => FND_API.G_FALSE
6389 , p_count => x_msg_count
6390 , p_data => x_msg_data
6391 );
6392 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6393 x_return_status := FND_API.G_RET_STS_ERROR;
6394 RAISE;
6395 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6396 ROLLBACK TO BscKpiPvt_AssAnaOpts;
6397 FND_MSG_PUB.Count_And_Get
6398 ( p_encoded => FND_API.G_FALSE
6399 , p_count => x_msg_count
6400 , p_data => x_msg_data
6401 );
6402 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6403 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6404 RAISE;
6405 WHEN NO_DATA_FOUND THEN
6406 ROLLBACK TO BscKpiPvt_AssAnaOpts;
6407 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6408 IF (x_msg_data IS NOT NULL) THEN
6409 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Assign_Analysis_Option ';
6410 ELSE
6411 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Assign_Analysis_Option ';
6412 END IF;
6413 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6414 RAISE;
6415 WHEN OTHERS THEN
6416 ROLLBACK TO BscKpiPvt_AssAnaOpts;
6417 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6418 IF (x_msg_data IS NOT NULL) THEN
6419 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Assign_Analysis_Option ';
6420 ELSE
6421 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Assign_Analysis_Option ';
6422 END IF;
6423 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6424 RAISE;
6425 End Assign_Analysis_Option;
6426
6427 /************************************************************************************
6428 ************************************************************************************/
6429
6430 procedure Unassign_Analysis_Option(
6431 p_Bsc_kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_kpi_Entity_Rec
6432 ,x_return_status OUT NOCOPY varchar2
6433 ,x_msg_count OUT NOCOPY number
6434 ,x_msg_data OUT NOCOPY varchar2
6435 ) IS
6436 l_option_id number;
6437 l_parent_option_id number;
6438 l_grandparent_option_id number;
6439 l_count number;
6440 l_Bsc_kpi_Entity_Rec BSC_KPI_PUB.Bsc_kpi_Entity_Rec;
6441 Begin
6442 FND_MSG_PUB.Initialize;
6443 x_return_status := FND_API.G_RET_STS_SUCCESS;
6444 SAVEPOINT BscKpiPvt_UnAssAnaOpts;
6445 --DBMS_OUTPUT.PUT_LINE('Begin BSC_KPI_PVT.Unassign_Analysis_Option');
6446
6447 l_parent_option_id := 0;
6448 l_grandparent_option_id := 0;
6449
6450 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 0 then
6451 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6452 elsif p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 1 then
6453 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6454 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6455 else -- if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6456 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option2;
6457 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6458 l_grandparent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6459 end if;
6460
6461 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id = ' || p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6462 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = ' || p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id);
6463 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_option_id = ' || l_option_id);
6464 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_parent_option_id = ' || l_parent_option_id);
6465 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_grandparent_option_id = ' || l_grandparent_option_id);
6466 --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag = ' || p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag);
6467
6468 -- Update the Analysis Option to hide the option
6469 update BSC_KPI_ANALYSIS_OPTIONS_B
6470 set user_level1 = 0
6471 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6472 and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6473 and option_id = l_option_id
6474 and parent_option_id = l_parent_option_id
6475 and grandparent_option_id = l_grandparent_option_id
6476 and user_level0 > 1;
6477
6478 -- Hide the Parent Option if all the child Analysis Options are hide
6479 if p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag <> 0 and p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id > 0 then
6480
6481 -- count the option visible under the parent
6482 select count(option_id)
6483 into l_count
6484 from BSC_KPI_ANALYSIS_OPTIONS_B
6485 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6486 and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6487 and parent_option_id = l_parent_option_id
6488 and grandparent_option_id = l_grandparent_option_id
6489 and user_level1 > 0;
6490
6491 -- l_count = 0 means there is not more option under parent
6492 -- then the parent option must to be hide too
6493 if l_count = 0 then
6494
6495 l_Bsc_kpi_Entity_Rec := p_Bsc_kpi_Entity_Rec;
6496 l_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag := 0;
6497
6498 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6499 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 1;
6500 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := p_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag;
6501 else
6502 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 0;
6503 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := 0;
6504 end if;
6505
6506 Unassign_Analysis_Option(l_Bsc_kpi_Entity_Rec
6507 ,x_return_status
6508 ,x_msg_count
6509 ,x_msg_data);
6510 end if;
6511
6512 end if;
6513
6514 --DBMS_OUTPUT.PUT_LINE('End BSC_KPI_PVT.Unassign_Analysis_Option');
6515
6516 EXCEPTION
6517 WHEN FND_API.G_EXC_ERROR THEN
6518 ROLLBACK TO BscKpiPvt_UnAssAnaOpts;
6519 FND_MSG_PUB.Count_And_Get
6520 ( p_encoded => FND_API.G_FALSE
6521 , p_count => x_msg_count
6522 , p_data => x_msg_data
6523 );
6524 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6525 x_return_status := FND_API.G_RET_STS_ERROR;
6526 RAISE;
6527 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6528 ROLLBACK TO BscKpiPvt_UnAssAnaOpts;
6529 FND_MSG_PUB.Count_And_Get
6530 ( p_encoded => FND_API.G_FALSE
6531 , p_count => x_msg_count
6532 , p_data => x_msg_data
6533 );
6534 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6535 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6536 RAISE;
6537 WHEN NO_DATA_FOUND THEN
6538 ROLLBACK TO BscKpiPvt_UnAssAnaOpts;
6539 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6540 IF (x_msg_data IS NOT NULL) THEN
6541 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Unassign_Analysis_Option ';
6542 ELSE
6543 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Unassign_Analysis_Option ';
6544 END IF;
6545 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6546 RAISE;
6547 WHEN OTHERS THEN
6548 ROLLBACK TO BscKpiPvt_UnAssAnaOpts;
6549 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6550 IF (x_msg_data IS NOT NULL) THEN
6551 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Unassign_Analysis_Option ';
6552 ELSE
6553 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Unassign_Analysis_Option ';
6554 END IF;
6555 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6556 RAISE;
6557 End Unassign_Analysis_Option;
6558
6559
6560 /************************************************************************************
6561 ************************************************************************************/
6562
6563 function Is_Analysis_Option_Selected(
6564 p_Bsc_kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_kpi_Entity_Rec
6565 ,x_return_status OUT NOCOPY varchar2
6566 ,x_msg_count OUT NOCOPY number
6567 ,x_msg_data OUT NOCOPY varchar2
6568 ) return varchar2 IS
6569
6570 l_option_id number;
6571 l_parent_option_id number;
6572 l_grandparent_option_id number;
6573 l_count number;
6574 l_Bsc_kpi_Entity_Rec BSC_KPI_PUB.Bsc_kpi_Entity_Rec;
6575 l_temp varchar2(5);
6576 Begin
6577 FND_MSG_PUB.Initialize;
6578 x_return_status := FND_API.G_RET_STS_SUCCESS;
6579 -- p_Bsc_kpi_Entity_Rec.Bsc_kpi_Id
6580 -- p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6581 -- p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag
6582 -- p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0
6583 -- p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1
6584 -- p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option2
6585
6586
6587 --DBMS_OUTPUT.PUT_LINE('Begin BSC_KPI_PVT.Is_Analysis_Option_Selected ');
6588
6589 l_parent_option_id := 0;
6590 l_grandparent_option_id := 0;
6591
6592 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 0 then
6593 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6594 elsif p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 1 then
6595 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6596 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6597 else -- if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6598 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option2;
6599 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6600 l_grandparent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6601 end if;
6602
6603 -- see if the option is selected
6604 Select count(indicator)
6605 into l_count
6606 from BSC_KPI_ANALYSIS_OPTIONS_B
6607 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6608 and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6609 and option_id = l_option_id
6610 and parent_option_id = l_parent_option_id
6611 and grandparent_option_id = l_grandparent_option_id
6612 and user_level1 <> 0;
6613
6614 l_temp := FND_API.G_FALSE;
6615
6616 -- count > 0 means the option is selected
6617 if l_count > 0 then
6618
6619 if p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag = 0 or p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 0 then
6620 -- when option is not dependent
6621 l_temp := FND_API.G_TRUE;
6622 else
6623 -- Evalute if parent Parent Option is selected
6624 l_Bsc_kpi_Entity_Rec := p_Bsc_kpi_Entity_Rec;
6625 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6626 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 1;
6627 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := l_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag;
6628 else
6629 l_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id := 0;
6630 l_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag := 0;
6631 end if;
6632 l_Bsc_kpi_Entity_Rec.Bsc_gp_Dependency_Flag := 0;
6633
6634 l_temp := Is_Analysis_Option_Selected(l_Bsc_kpi_Entity_Rec
6635 ,x_return_status
6636 ,x_msg_count
6637 ,x_msg_data);
6638 end if;
6639
6640 end if;
6641
6642 --DBMS_OUTPUT.PUT_LINE('End BSC_KPI_PVT.Is_Analysis_Option_Selected - return ' || l_temp );
6643
6644 return l_temp ;
6645
6646 EXCEPTION
6647 WHEN FND_API.G_EXC_ERROR THEN
6648 FND_MSG_PUB.Count_And_Get
6649 ( p_encoded => FND_API.G_FALSE
6650 , p_count => x_msg_count
6651 , p_data => x_msg_data
6652 );
6653 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6654 x_return_status := FND_API.G_RET_STS_ERROR;
6655 RAISE;
6656 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6657 FND_MSG_PUB.Count_And_Get
6658 ( p_encoded => FND_API.G_FALSE
6659 , p_count => x_msg_count
6660 , p_data => x_msg_data
6661 );
6662 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6663 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6664 RAISE;
6665 WHEN NO_DATA_FOUND THEN
6666 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6667 IF (x_msg_data IS NOT NULL) THEN
6668 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Is_Analysis_Option_Selected ';
6669 ELSE
6670 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Is_Analysis_Option_Selected ';
6671 END IF;
6672 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6673 RAISE;
6674 WHEN OTHERS THEN
6675 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6676 IF (x_msg_data IS NOT NULL) THEN
6677 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Is_Analysis_Option_Selected ';
6678 ELSE
6679 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Is_Analysis_Option_Selected ';
6680 END IF;
6681 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6682 RAISE;
6683 end Is_Analysis_Option_Selected;
6684
6685 /************************************************************************************
6686 ************************************************************************************/
6687
6688 function Is_Leaf_Analysis_Option(
6689 p_Bsc_kpi_Entity_Rec IN BSC_KPI_PUB.Bsc_kpi_Entity_Rec
6690 ,x_return_status OUT NOCOPY varchar2
6691 ,x_msg_count OUT NOCOPY number
6692 ,x_msg_data OUT NOCOPY varchar2
6693 ) return varchar2 IS
6694
6695 l_option_id number;
6696 l_parent_option_id number;
6697 l_grandparent_option_id number;
6698 l_count number;
6699 l_count_child_options number;
6700 l_child_analysis_group number;
6701 l_temp varchar2(5);
6702
6703 Begin
6704 FND_MSG_PUB.Initialize;
6705 x_return_status := FND_API.G_RET_STS_SUCCESS;
6706
6707 --DBMS_OUTPUT.PUT_LINE('Begin BSC_KPI_PVT.Is_Leaf_Analysis_Option ');
6708
6709 -- Get the paramters :
6710
6711 l_parent_option_id := 0;
6712 l_grandparent_option_id := 0;
6713
6714 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 0 then
6715 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6716 elsif p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 1 then
6717 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6718 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6719 else -- if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6720 l_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option2;
6721 l_parent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option1;
6722 l_grandparent_option_id := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Analysis_Option0;
6723 end if;
6724
6725 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - l_option_id = ' || l_option_id );
6726 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - l_parent_option_id = ' || l_parent_option_id );
6727 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - l_grandparent_option_id = ' || l_grandparent_option_id );
6728 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = ' || p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id );
6729
6730 -- Evaluate the parameter to know if the option is a leaf :
6731
6732 if p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id = 2 then
6733 -- a Option from the Analysis Group 2 always is a Leaf
6734 l_temp := FND_API.G_TRUE;
6735 else
6736 -- See if there is some Analysis Group that depend of the current one
6737 select count(ANALYSIS_GROUP_ID)
6738 into l_count
6739 from BSC_KPI_ANALYSIS_GROUPS
6740 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6741 and PARENT_ANALYSIS_ID = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id;
6742
6743 if l_count = 0 then
6744 -- l_count = 0 means there is not any dependency group from the current one
6745 -- then the current Option is a Leaf
6746 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - NO Child Group ' );
6747 l_temp := FND_API.G_TRUE;
6748 else
6749 -- if l_count <> 0 means there is a dependency group
6750 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - Child Group ' );
6751
6752 -- get the dependency group which is the next one
6753 l_child_analysis_group := p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id + 1 ;
6754
6755 -- Count the option which one depending of the current one
6756 select count(option_id)
6757 into l_count_child_options
6758 from BSC_KPI_ANALYSIS_OPTIONS_B
6759 where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6760 and analysis_group_id = l_child_analysis_Group
6761 and parent_option_id = l_option_id
6762 and grandparent_option_id = l_parent_option_id;
6763
6764 if l_count_child_options = 0 then
6765 -- l_count_child_options = 0 means there is not dependency option from
6766 -- the current one, then current option is a leaft
6767 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - NO Child Options ' );
6768
6769 l_temp := FND_API.G_TRUE;
6770 else
6771 -- l_count_child_options > 0 means there are dependency option from
6772 -- the current one then the current option is not a leaft
6773 --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Is_Leaf_Analysis_Option - Child Options ' );
6774
6775 l_temp := FND_API.G_FALSE;
6776 end if;
6777 end if;
6778
6779 end if;
6780
6781 --DBMS_OUTPUT.PUT_LINE('End BSC_KPI_PVT.Is_Leaf_Analysis_Option - return ' || l_temp );
6782
6783 return l_temp ;
6784
6785 EXCEPTION
6786 WHEN FND_API.G_EXC_ERROR THEN
6787 FND_MSG_PUB.Count_And_Get
6788 ( p_encoded => FND_API.G_FALSE
6789 , p_count => x_msg_count
6790 , p_data => x_msg_data
6791 );
6792 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6793 x_return_status := FND_API.G_RET_STS_ERROR;
6794 RAISE;
6795 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6796 FND_MSG_PUB.Count_And_Get
6797 ( p_encoded => FND_API.G_FALSE
6798 , p_count => x_msg_count
6799 , p_data => x_msg_data
6800 );
6801 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6802 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6803 RAISE;
6804 WHEN NO_DATA_FOUND THEN
6805 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6806 IF (x_msg_data IS NOT NULL) THEN
6807 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Is_Leaf_Analysis_Option ';
6808 ELSE
6809 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Is_Leaf_Analysis_Option ';
6810 END IF;
6811 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6812 RAISE;
6813 WHEN OTHERS THEN
6814 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6815 IF (x_msg_data IS NOT NULL) THEN
6816 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Is_Leaf_Analysis_Option ';
6817 ELSE
6818 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Is_Leaf_Analysis_Option ';
6819 END IF;
6820 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6821 RAISE;
6822
6823 end Is_Leaf_Analysis_Option;
6824
6825 /*********************************************************
6826 Name : Delete_Ind_Cause_Effect_Rels
6827 Description : This API deletes the cause and effect relationship
6828 of the current indicator.
6829 created by : ashankar 20-JUL-2005
6830 /********************************************************/
6831
6832 PROCEDURE Delete_Ind_Cause_Effect_Rels(
6833 p_commit IN VARCHAR2 := FND_API.G_FALSE
6834 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
6835 ,x_return_status OUT NOCOPY VARCHAR2
6836 ,x_msg_count OUT NOCOPY NUMBER
6837 ,x_msg_data OUT NOCOPY VARCHAR2
6838 ) IS
6839
6840 l_count NUMBER;
6841
6842 BEGIN
6843 FND_MSG_PUB.Initialize;
6844 x_return_status := FND_API.G_RET_STS_SUCCESS;
6845 SAVEPOINT DelIndCauseEffectRels;
6846 -- Check that valid id was entered.
6847 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
6848 SELECT COUNT(0)
6849 INTO l_count
6850 FROM bsc_kpis_b
6851 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
6852
6853 IF (l_count = 0) THEN
6854 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
6855 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6856 FND_MSG_PUB.ADD;
6857 RAISE FND_API.G_EXC_ERROR;
6858 END IF;
6859 ELSE
6860 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
6861 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6862 FND_MSG_PUB.ADD;
6863 RAISE FND_API.G_EXC_ERROR;
6864 END IF;
6865
6866 DELETE
6867 FROM bsc_kpi_cause_effect_rels
6868 WHERE cause_indicator =p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6869 AND NVL(cause_level,BSC_KPI_PUB.c_IND_LEVEL)=BSC_KPI_PUB.c_IND_LEVEL
6870 AND NVL(effect_level,BSC_KPI_PUB.c_IND_LEVEL)=BSC_KPI_PUB.c_IND_LEVEL;
6871
6872 DELETE
6873 FROM bsc_kpi_cause_effect_rels
6874 WHERE effect_indicator =p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6875 AND NVL(cause_level,BSC_KPI_PUB.c_IND_LEVEL)=BSC_KPI_PUB.c_IND_LEVEL
6876 AND NVL(effect_level,BSC_KPI_PUB.c_IND_LEVEL)=BSC_KPI_PUB.c_IND_LEVEL;
6877
6878
6879 IF (p_commit = FND_API.G_TRUE) THEN
6880 COMMIT;
6881 END IF;
6882
6883 EXCEPTION
6884 WHEN FND_API.G_EXC_ERROR THEN
6885 ROLLBACK TO DelIndCauseEffectRels;
6886 FND_MSG_PUB.Count_And_Get
6887 ( p_encoded => FND_API.G_FALSE
6888 , p_count => x_msg_count
6889 , p_data => x_msg_data
6890 );
6891 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6892 x_return_status := FND_API.G_RET_STS_ERROR;
6893 RAISE;
6894 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6895 ROLLBACK TO DelIndCauseEffectRels;
6896 FND_MSG_PUB.Count_And_Get
6897 ( p_encoded => FND_API.G_FALSE
6898 , p_count => x_msg_count
6899 , p_data => x_msg_data
6900 );
6901 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6902 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
6903 RAISE;
6904 WHEN NO_DATA_FOUND THEN
6905 ROLLBACK TO DelIndCauseEffectRels;
6906 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6907 IF (x_msg_data IS NOT NULL) THEN
6908 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Cause_Effect_Rels ';
6909 ELSE
6910 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Cause_Effect_Rels ';
6911 END IF;
6912 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
6913 RAISE;
6914 WHEN OTHERS THEN
6915 ROLLBACK TO DelIndCauseEffectRels;
6916 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6917 IF (x_msg_data IS NOT NULL) THEN
6918 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Cause_Effect_Rels ';
6919 ELSE
6920 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Cause_Effect_Rels ';
6921 END IF;
6922 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
6923 RAISE;
6924 END Delete_Ind_Cause_Effect_Rels;
6925
6926
6927 /*********************************************************
6928 Name : Delete_Ind_Shell_Cmds
6929 Description : This API deletes shell cammand entries
6930 of the current indicator.
6931 created by : ashankar 20-JUL-2005
6932 /********************************************************/
6933
6934 PROCEDURE Delete_Ind_Shell_Cmds
6935 (
6936 p_commit IN VARCHAR2 := FND_API.G_FALSE
6937 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
6938 ,x_return_status OUT NOCOPY VARCHAR2
6939 ,x_msg_count OUT NOCOPY NUMBER
6940 ,x_msg_data OUT NOCOPY VARCHAR2
6941 ) IS
6942
6943 l_count NUMBER;
6944
6945 BEGIN
6946 FND_MSG_PUB.Initialize;
6947 x_return_status := FND_API.G_RET_STS_SUCCESS;
6948 SAVEPOINT DeleteIndShellCmds;
6949
6950 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
6951 SELECT COUNT(0)
6952 INTO l_count
6953 FROM bsc_kpis_b
6954 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
6955
6956 IF (l_count = 0) THEN
6957 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
6958 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6959 FND_MSG_PUB.ADD;
6960 RAISE FND_API.G_EXC_ERROR;
6961 END IF;
6962 ELSE
6963 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
6964 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
6965 FND_MSG_PUB.ADD;
6966 RAISE FND_API.G_EXC_ERROR;
6967 END IF;
6968
6969 DELETE
6970 FROM bsc_kpi_shell_cmds_tl
6971 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
6972
6973 DELETE
6974 FROM bsc_kpi_shell_cmds_user
6975 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
6976
6977
6978 IF (p_commit = FND_API.G_TRUE) THEN
6979 COMMIT;
6980 END IF;
6981
6982 EXCEPTION
6983 WHEN FND_API.G_EXC_ERROR THEN
6984 ROLLBACK TO DeleteIndShellCmds;
6985 FND_MSG_PUB.Count_And_Get
6986 ( p_encoded => FND_API.G_FALSE
6987 , p_count => x_msg_count
6988 , p_data => x_msg_data
6989 );
6990 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
6991 x_return_status := FND_API.G_RET_STS_ERROR;
6992 RAISE;
6993 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6994 ROLLBACK TO DeleteIndShellCmds;
6995 FND_MSG_PUB.Count_And_Get
6996 ( p_encoded => FND_API.G_FALSE
6997 , p_count => x_msg_count
6998 , p_data => x_msg_data
6999 );
7000 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7001 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7002 RAISE;
7003 WHEN NO_DATA_FOUND THEN
7004 ROLLBACK TO DeleteIndShellCmds;
7005 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7006 IF (x_msg_data IS NOT NULL) THEN
7007 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Shell_Cmds ';
7008 ELSE
7009 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Shell_Cmds ';
7010 END IF;
7011 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7012 RAISE;
7013 WHEN OTHERS THEN
7014 ROLLBACK TO DeleteIndShellCmds;
7015 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7016 IF (x_msg_data IS NOT NULL) THEN
7017 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Shell_Cmds ';
7018 ELSE
7019 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Shell_Cmds ';
7020 END IF;
7021 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7022 RAISE;
7023 END Delete_Ind_Shell_Cmds;
7024
7025
7026 /*********************************************************
7027 Name : Delete_Ind_MM_Controls
7028 Description : This API deletes multimedia entries
7029 of the current indicator.
7030 created by : ashankar 20-JUL-2005
7031 /********************************************************/
7032
7033 PROCEDURE Delete_Ind_MM_Controls
7034 (
7035 p_commit IN VARCHAR2 := FND_API.G_FALSE
7036 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7037 ,x_return_status OUT NOCOPY VARCHAR2
7038 ,x_msg_count OUT NOCOPY NUMBER
7039 ,x_msg_data OUT NOCOPY VARCHAR2
7040 ) IS
7041
7042 l_count NUMBER;
7043
7044 BEGIN
7045 FND_MSG_PUB.Initialize;
7046 x_return_status := FND_API.G_RET_STS_SUCCESS;
7047 SAVEPOINT DeleteIndMMControls;
7048
7049 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7050 SELECT COUNT(0)
7051 INTO l_count
7052 FROM bsc_kpis_b
7053 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7054
7055 IF (l_count = 0) THEN
7056 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7057 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7058 FND_MSG_PUB.ADD;
7059 RAISE FND_API.G_EXC_ERROR;
7060 END IF;
7061 ELSE
7062 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7063 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7064 FND_MSG_PUB.ADD;
7065 RAISE FND_API.G_EXC_ERROR;
7066 END IF;
7067
7068 DELETE
7069 FROM bsc_kpi_mm_controls
7070 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7071
7072
7073 IF (p_commit = FND_API.G_TRUE) THEN
7074 COMMIT;
7075 END IF;
7076
7077 EXCEPTION
7078 WHEN FND_API.G_EXC_ERROR THEN
7079 ROLLBACK TO DeleteIndMMControls;
7080 FND_MSG_PUB.Count_And_Get
7081 ( p_encoded => FND_API.G_FALSE
7082 , p_count => x_msg_count
7083 , p_data => x_msg_data
7084 );
7085 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7086 x_return_status := FND_API.G_RET_STS_ERROR;
7087 RAISE;
7088 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7089 ROLLBACK TO DeleteIndMMControls;
7090 FND_MSG_PUB.Count_And_Get
7091 ( p_encoded => FND_API.G_FALSE
7092 , p_count => x_msg_count
7093 , p_data => x_msg_data
7094 );
7095 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7096 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7097 RAISE;
7098 WHEN NO_DATA_FOUND THEN
7099 ROLLBACK TO DeleteIndMMControls;
7100 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7101 IF (x_msg_data IS NOT NULL) THEN
7102 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_MM_Controls ';
7103 ELSE
7104 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_MM_Controls ';
7105 END IF;
7106 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7107 RAISE;
7108 WHEN OTHERS THEN
7109 ROLLBACK TO DeleteIndMMControls;
7110 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7111 IF (x_msg_data IS NOT NULL) THEN
7112 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_MM_Controls ';
7113 ELSE
7114 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_MM_Controls ';
7115 END IF;
7116 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7117 RAISE;
7118 END Delete_Ind_MM_Controls;
7119
7120 /*********************************************************
7121 Name : Delete_Ind_Subtitles
7122 Description : This API deletes subtitle entries of the current indicator.
7123 created by : ashankar 20-JUL-2005
7124 /********************************************************/
7125
7126 PROCEDURE Delete_Ind_Subtitles
7127 (
7128 p_commit IN VARCHAR2 := FND_API.G_FALSE
7129 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7130 ,x_return_status OUT NOCOPY VARCHAR2
7131 ,x_msg_count OUT NOCOPY NUMBER
7132 ,x_msg_data OUT NOCOPY VARCHAR2
7133 ) IS
7134
7135 l_count NUMBER;
7136
7137 BEGIN
7138 FND_MSG_PUB.Initialize;
7139 x_return_status := FND_API.G_RET_STS_SUCCESS;
7140 SAVEPOINT DeleteIndSubtitles;
7141
7142 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7143 SELECT COUNT(0)
7144 INTO l_count
7145 FROM bsc_kpis_b
7146 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7147
7148 IF (l_count = 0) THEN
7149 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7150 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7151 FND_MSG_PUB.ADD;
7152 RAISE FND_API.G_EXC_ERROR;
7153 END IF;
7154 ELSE
7155 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7156 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7157 FND_MSG_PUB.ADD;
7158 RAISE FND_API.G_EXC_ERROR;
7159 END IF;
7160
7161 DELETE
7162 FROM bsc_kpi_subtitles_tl
7163 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7164
7165
7166 IF (p_commit = FND_API.G_TRUE) THEN
7167 COMMIT;
7168 END IF;
7169
7170 EXCEPTION
7171 WHEN FND_API.G_EXC_ERROR THEN
7172 ROLLBACK TO DeleteIndSubtitles;
7173 FND_MSG_PUB.Count_And_Get
7174 ( p_encoded => FND_API.G_FALSE
7175 , p_count => x_msg_count
7176 , p_data => x_msg_data
7177 );
7178 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7179 x_return_status := FND_API.G_RET_STS_ERROR;
7180 RAISE;
7181 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7182 ROLLBACK TO DeleteIndSubtitles;
7183 FND_MSG_PUB.Count_And_Get
7184 ( p_encoded => FND_API.G_FALSE
7185 , p_count => x_msg_count
7186 , p_data => x_msg_data
7187 );
7188 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7189 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7190 RAISE;
7191 WHEN NO_DATA_FOUND THEN
7192 ROLLBACK TO DeleteIndSubtitles;
7193 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7194 IF (x_msg_data IS NOT NULL) THEN
7195 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Subtitles ';
7196 ELSE
7197 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Subtitles ';
7198 END IF;
7199 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7200 RAISE;
7201 WHEN OTHERS THEN
7202 ROLLBACK TO DeleteIndSubtitles;
7203 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7204 IF (x_msg_data IS NOT NULL) THEN
7205 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Subtitles ';
7206 ELSE
7207 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Subtitles ';
7208 END IF;
7209 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7210 RAISE;
7211 END Delete_Ind_Subtitles;
7212
7213
7214 /*********************************************************
7215 Name : Delete_Ind_SeriesColors
7216 Description : This API deletes series colors of the current indicator.
7217 created by : ashankar 20-JUL-2005
7218 /********************************************************/
7219
7220 PROCEDURE Delete_Ind_SeriesColors
7221 (
7222 p_commit IN VARCHAR2 := FND_API.G_FALSE
7223 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7224 ,x_return_status OUT NOCOPY VARCHAR2
7225 ,x_msg_count OUT NOCOPY NUMBER
7226 ,x_msg_data OUT NOCOPY VARCHAR2
7227 ) IS
7228
7229 l_count NUMBER;
7230
7231 BEGIN
7232 FND_MSG_PUB.Initialize;
7233 x_return_status := FND_API.G_RET_STS_SUCCESS;
7234 SAVEPOINT DeleteIndSeriesColors;
7235
7236 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7237 SELECT COUNT(0)
7238 INTO l_count
7239 FROM bsc_kpis_b
7240 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7241
7242 IF (l_count = 0) THEN
7243 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7244 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7245 FND_MSG_PUB.ADD;
7246 RAISE FND_API.G_EXC_ERROR;
7247 END IF;
7248 ELSE
7249 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7250 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7251 FND_MSG_PUB.ADD;
7252 RAISE FND_API.G_EXC_ERROR;
7253 END IF;
7254
7255 DELETE
7256 FROM bsc_kpi_series_colors
7257 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7258
7259
7260 IF (p_commit = FND_API.G_TRUE) THEN
7261 COMMIT;
7262 END IF;
7263
7264 EXCEPTION
7265 WHEN FND_API.G_EXC_ERROR THEN
7266 ROLLBACK TO DeleteIndSeriesColors;
7267 FND_MSG_PUB.Count_And_Get
7268 ( p_encoded => FND_API.G_FALSE
7269 , p_count => x_msg_count
7270 , p_data => x_msg_data
7271 );
7272 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7273 x_return_status := FND_API.G_RET_STS_ERROR;
7274 RAISE;
7275 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7276 ROLLBACK TO DeleteIndSeriesColors;
7277 FND_MSG_PUB.Count_And_Get
7278 ( p_encoded => FND_API.G_FALSE
7279 , p_count => x_msg_count
7280 , p_data => x_msg_data
7281 );
7282 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7283 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7284 RAISE;
7285 WHEN NO_DATA_FOUND THEN
7286 ROLLBACK TO DeleteIndSeriesColors;
7287 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7288 IF (x_msg_data IS NOT NULL) THEN
7289 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_SeriesColors ';
7290 ELSE
7291 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_SeriesColors ';
7292 END IF;
7293 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7294 RAISE;
7295 WHEN OTHERS THEN
7296 ROLLBACK TO DeleteIndSeriesColors;
7297 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7298 IF (x_msg_data IS NOT NULL) THEN
7299 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_SeriesColors ';
7300 ELSE
7301 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_SeriesColors ';
7302 END IF;
7303 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7304 RAISE;
7305 END Delete_Ind_SeriesColors;
7306
7307
7308 /*********************************************************
7309 Name : DeleteIndImages
7310 Description : This API deletes all the images attached with the objective.
7311 created by : ashankar 20-JUL-2005
7312 /********************************************************/
7313
7314 PROCEDURE Delete_Ind_Images
7315 (
7316 p_commit IN VARCHAR2 := FND_API.G_FALSE
7317 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7318 ,x_return_status OUT NOCOPY VARCHAR2
7319 ,x_msg_count OUT NOCOPY NUMBER
7320 ,x_msg_data OUT NOCOPY VARCHAR2
7321 ) IS
7322
7323 l_count NUMBER;
7324
7325 BEGIN
7326 FND_MSG_PUB.Initialize;
7327 x_return_status := FND_API.G_RET_STS_SUCCESS;
7328 SAVEPOINT DeleteIndImages;
7329
7330 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7331 SELECT COUNT(0)
7332 INTO l_count
7333 FROM bsc_kpis_b
7334 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7335
7336 IF (l_count = 0) THEN
7337 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7338 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7339 FND_MSG_PUB.ADD;
7340 RAISE FND_API.G_EXC_ERROR;
7341 END IF;
7342 ELSE
7343 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7344 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7345 FND_MSG_PUB.ADD;
7346 RAISE FND_API.G_EXC_ERROR;
7347 END IF;
7348
7349 DELETE
7350 FROM bsc_sys_images
7351 WHERE image_id IN (
7352 SELECT image_id
7353 FROM bsc_kpi_graphs
7354 WHERE indicator =p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
7355 );
7356
7357 DELETE
7358 FROM bsc_kpi_graphs
7359 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7360
7361 DELETE
7362 FROM bsc_user_kpigraph_plugs
7363 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7364
7365 IF (p_commit = FND_API.G_TRUE) THEN
7366 COMMIT;
7367 END IF;
7368
7369 EXCEPTION
7370 WHEN FND_API.G_EXC_ERROR THEN
7371 ROLLBACK TO DeleteIndImages;
7372 FND_MSG_PUB.Count_And_Get
7373 ( p_encoded => FND_API.G_FALSE
7374 , p_count => x_msg_count
7375 , p_data => x_msg_data
7376 );
7377 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7378 x_return_status := FND_API.G_RET_STS_ERROR;
7379 RAISE;
7380 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7381 ROLLBACK TO DeleteIndImages;
7382 FND_MSG_PUB.Count_And_Get
7383 ( p_encoded => FND_API.G_FALSE
7384 , p_count => x_msg_count
7385 , p_data => x_msg_data
7386 );
7387 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7388 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7389 RAISE;
7390 WHEN NO_DATA_FOUND THEN
7391 ROLLBACK TO DeleteIndImages;
7392 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7393 IF (x_msg_data IS NOT NULL) THEN
7394 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Images ';
7395 ELSE
7396 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Images ';
7397 END IF;
7398 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7399 RAISE;
7400 WHEN OTHERS THEN
7401 ROLLBACK TO DeleteIndImages;
7402 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7403 IF (x_msg_data IS NOT NULL) THEN
7404 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Images ';
7405 ELSE
7406 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Images ';
7407 END IF;
7408 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7409 RAISE;
7410 END Delete_Ind_Images;
7411
7412
7413 /*********************************************************
7414 Name : Delete_Ind_Sys_Prop
7415 Description : This API deletes all the system level proeprties attached to the objective
7416 created by : ashankar 20-JUL-2005
7417 /********************************************************/
7418
7419 PROCEDURE Delete_Ind_Sys_Prop
7420 (
7421 p_commit IN VARCHAR2 := FND_API.G_FALSE
7422 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7423 ,x_return_status OUT NOCOPY VARCHAR2
7424 ,x_msg_count OUT NOCOPY NUMBER
7425 ,x_msg_data OUT NOCOPY VARCHAR2
7426 ) IS
7427
7428 l_count NUMBER;
7429
7430 BEGIN
7431 FND_MSG_PUB.Initialize;
7432 x_return_status := FND_API.G_RET_STS_SUCCESS;
7433 SAVEPOINT DeleteIndSysProp;
7434
7435 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7436 SELECT COUNT(0)
7437 INTO l_count
7438 FROM bsc_kpis_b
7439 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7440
7441 IF (l_count = 0) THEN
7442 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7443 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7444 FND_MSG_PUB.ADD;
7445 RAISE FND_API.G_EXC_ERROR;
7446 END IF;
7447 ELSE
7448 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7449 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7450 FND_MSG_PUB.ADD;
7451 RAISE FND_API.G_EXC_ERROR;
7452 END IF;
7453
7454 DELETE
7455 FROM bsc_sys_files
7456 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7457
7458
7459 DELETE
7460 FROM bsc_sys_kpi_colors
7461 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7462
7463 DELETE
7464 FROM bsc_sys_objective_colors
7465 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7466
7467 DELETE
7468 FROM bsc_sys_labels_b
7469 WHERE source_type = BSC_KPI_PUB.c_IND_TYPE
7470 AND source_code = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7471
7472 DELETE
7473 FROM bsc_sys_labels_tl
7474 WHERE source_type = BSC_KPI_PUB.c_IND_TYPE
7475 AND source_code = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7476
7477 DELETE
7478 FROM bsc_sys_lines
7479 WHERE source_type = BSC_KPI_PUB.c_IND_TYPE
7480 AND source_code = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7481
7482 DELETE
7483 FROM bsc_sys_user_options
7484 WHERE source_type = BSC_KPI_PUB.c_IND_TYPE
7485 AND source_code = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7486
7487 IF (p_commit = FND_API.G_TRUE) THEN
7488 COMMIT;
7489 END IF;
7490
7491 EXCEPTION
7492 WHEN FND_API.G_EXC_ERROR THEN
7493 ROLLBACK TO DeleteIndSysProp;
7494 FND_MSG_PUB.Count_And_Get
7495 ( p_encoded => FND_API.G_FALSE
7496 , p_count => x_msg_count
7497 , p_data => x_msg_data
7498 );
7499 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7500 x_return_status := FND_API.G_RET_STS_ERROR;
7501 RAISE;
7502 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7503 ROLLBACK TO DeleteIndSysProp;
7504 FND_MSG_PUB.Count_And_Get
7505 ( p_encoded => FND_API.G_FALSE
7506 , p_count => x_msg_count
7507 , p_data => x_msg_data
7508 );
7509 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7510 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7511 RAISE;
7512 WHEN NO_DATA_FOUND THEN
7513 ROLLBACK TO DeleteIndSysProp;
7514 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7515 IF (x_msg_data IS NOT NULL) THEN
7516 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Sys_Prop ';
7517 ELSE
7518 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Sys_Prop ';
7519 END IF;
7520 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7521 RAISE;
7522 WHEN OTHERS THEN
7523 ROLLBACK TO DeleteIndSysProp;
7524 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7525 IF (x_msg_data IS NOT NULL) THEN
7526 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Sys_Prop ';
7527 ELSE
7528 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Sys_Prop ';
7529 END IF;
7530 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7531 RAISE;
7532 END Delete_Ind_Sys_Prop;
7533
7534
7535 /*********************************************************
7536 Name : Delete_Ind_Sys_Prop
7537 Description : This API deletes objective comments
7538 created by : ashankar 20-JUL-2005
7539 /********************************************************/
7540
7541 PROCEDURE Delete_Ind_Comments
7542 (
7543 p_commit IN VARCHAR2 := FND_API.G_FALSE
7544 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7545 ,x_return_status OUT NOCOPY VARCHAR2
7546 ,x_msg_count OUT NOCOPY NUMBER
7547 ,x_msg_data OUT NOCOPY VARCHAR2
7548 ) IS
7549
7550 l_count NUMBER;
7551
7552 BEGIN
7553 FND_MSG_PUB.Initialize;
7554 x_return_status := FND_API.G_RET_STS_SUCCESS;
7555 SAVEPOINT DeleteIndComments;
7556
7557 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7558 SELECT COUNT(0)
7559 INTO l_count
7560 FROM bsc_kpis_b
7561 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7562
7563 IF (l_count = 0) THEN
7564 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7565 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7566 FND_MSG_PUB.ADD;
7567 RAISE FND_API.G_EXC_ERROR;
7568 END IF;
7569 ELSE
7570 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7571 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7572 FND_MSG_PUB.ADD;
7573 RAISE FND_API.G_EXC_ERROR;
7574 END IF;
7575
7576 DELETE
7577 FROM bsc_kpi_comments
7578 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7579
7580
7581 IF (p_commit = FND_API.G_TRUE) THEN
7582 COMMIT;
7583 END IF;
7584
7585 EXCEPTION
7586 WHEN FND_API.G_EXC_ERROR THEN
7587 ROLLBACK TO DeleteIndComments;
7588 FND_MSG_PUB.Count_And_Get
7589 ( p_encoded => FND_API.G_FALSE
7590 , p_count => x_msg_count
7591 , p_data => x_msg_data
7592 );
7593 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7594 x_return_status := FND_API.G_RET_STS_ERROR;
7595 RAISE;
7596 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7597 ROLLBACK TO DeleteIndComments;
7598 FND_MSG_PUB.Count_And_Get
7599 ( p_encoded => FND_API.G_FALSE
7600 , p_count => x_msg_count
7601 , p_data => x_msg_data
7602 );
7603 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7604 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7605 RAISE;
7606 WHEN NO_DATA_FOUND THEN
7607 ROLLBACK TO DeleteIndComments;
7608 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7609 IF (x_msg_data IS NOT NULL) THEN
7610 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Comments ';
7611 ELSE
7612 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Comments ';
7613 END IF;
7614 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7615 RAISE;
7616 WHEN OTHERS THEN
7617 ROLLBACK TO DeleteIndComments;
7618 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7619 IF (x_msg_data IS NOT NULL) THEN
7620 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Comments ';
7621 ELSE
7622 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Comments ';
7623 END IF;
7624 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7625 RAISE;
7626 END Delete_Ind_Comments;
7627
7628 /*********************************************************
7629 Name : Delete_Ind_Tree_Nodes
7630 Description : This API deletes nodes of the objectives
7631 created by : ashankar 20-JUL-2005
7632 /********************************************************/
7633
7634 PROCEDURE Delete_Ind_Tree_Nodes
7635 (
7636 p_commit IN VARCHAR2 := FND_API.G_FALSE
7637 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7638 ,x_return_status OUT NOCOPY VARCHAR2
7639 ,x_msg_count OUT NOCOPY NUMBER
7640 ,x_msg_data OUT NOCOPY VARCHAR2
7641 ) IS
7642
7643 l_count NUMBER;
7644
7645 BEGIN
7646 FND_MSG_PUB.Initialize;
7647 x_return_status := FND_API.G_RET_STS_SUCCESS;
7648 SAVEPOINT DeleteIndTreeNodes;
7649
7650 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7651 SELECT COUNT(0)
7652 INTO l_count
7653 FROM bsc_kpis_b
7654 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7655
7656 IF (l_count = 0) THEN
7657 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7658 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7659 FND_MSG_PUB.ADD;
7660 RAISE FND_API.G_EXC_ERROR;
7661 END IF;
7662 ELSE
7663 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7664 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7665 FND_MSG_PUB.ADD;
7666 RAISE FND_API.G_EXC_ERROR;
7667 END IF;
7668
7669 DELETE
7670 FROM bsc_kpi_tree_nodes_b
7671 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7672
7673 DELETE
7674 FROM bsc_kpi_tree_nodes_tl
7675 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7676
7677
7678 IF (p_commit = FND_API.G_TRUE) THEN
7679 COMMIT;
7680 END IF;
7681
7682 EXCEPTION
7683 WHEN FND_API.G_EXC_ERROR THEN
7684 ROLLBACK TO DeleteIndTreeNodes;
7685 FND_MSG_PUB.Count_And_Get
7686 ( p_encoded => FND_API.G_FALSE
7687 , p_count => x_msg_count
7688 , p_data => x_msg_data
7689 );
7690 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7691 x_return_status := FND_API.G_RET_STS_ERROR;
7692 RAISE;
7693 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7694 ROLLBACK TO DeleteIndTreeNodes;
7695 FND_MSG_PUB.Count_And_Get
7696 ( p_encoded => FND_API.G_FALSE
7697 , p_count => x_msg_count
7698 , p_data => x_msg_data
7699 );
7700 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7701 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7702 RAISE;
7703 WHEN NO_DATA_FOUND THEN
7704 ROLLBACK TO DeleteIndTreeNodes;
7705 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7706 IF (x_msg_data IS NOT NULL) THEN
7707 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Tree_Nodes ';
7708 ELSE
7709 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Tree_Nodes ';
7710 END IF;
7711 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7712 RAISE;
7713 WHEN OTHERS THEN
7714 ROLLBACK TO DeleteIndTreeNodes;
7715 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7716 IF (x_msg_data IS NOT NULL) THEN
7717 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_Tree_Nodes ';
7718 ELSE
7719 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_Tree_Nodes ';
7720 END IF;
7721 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7722 RAISE;
7723 END Delete_Ind_Tree_Nodes;
7724
7725
7726 /*********************************************************
7727 Name : Delete_Ind_User_Access
7728 Description : This API deletes nodes of the objectives
7729 created by : ashankar 20-JUL-2005
7730 /********************************************************/
7731
7732 PROCEDURE Delete_Ind_User_Access
7733 (
7734 p_commit IN VARCHAR2 := FND_API.G_FALSE
7735 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7736 ,x_return_status OUT NOCOPY VARCHAR2
7737 ,x_msg_count OUT NOCOPY NUMBER
7738 ,x_msg_data OUT NOCOPY VARCHAR2
7739 ) IS
7740
7741 l_count NUMBER;
7742
7743 BEGIN
7744 FND_MSG_PUB.Initialize;
7745 x_return_status := FND_API.G_RET_STS_SUCCESS;
7746 SAVEPOINT DeleteIndUserAccess;
7747
7748 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7749 SELECT COUNT(0)
7750 INTO l_count
7751 FROM bsc_kpis_b
7752 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7753
7754 IF (l_count = 0) THEN
7755 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7756 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7757 FND_MSG_PUB.ADD;
7758 RAISE FND_API.G_EXC_ERROR;
7759 END IF;
7760 ELSE
7761 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7762 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7763 FND_MSG_PUB.ADD;
7764 RAISE FND_API.G_EXC_ERROR;
7765 END IF;
7766
7767 DELETE
7768 FROM bsc_user_kpi_access
7769 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7770
7771
7772 IF (p_commit = FND_API.G_TRUE) THEN
7773 COMMIT;
7774 END IF;
7775
7776 EXCEPTION
7777 WHEN FND_API.G_EXC_ERROR THEN
7778 ROLLBACK TO DeleteIndUserAccess;
7779 FND_MSG_PUB.Count_And_Get
7780 ( p_encoded => FND_API.G_FALSE
7781 , p_count => x_msg_count
7782 , p_data => x_msg_data
7783 );
7784 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7785 x_return_status := FND_API.G_RET_STS_ERROR;
7786 RAISE;
7787 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7788 ROLLBACK TO DeleteIndUserAccess;
7789 FND_MSG_PUB.Count_And_Get
7790 ( p_encoded => FND_API.G_FALSE
7791 , p_count => x_msg_count
7792 , p_data => x_msg_data
7793 );
7794 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7795 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7796 RAISE;
7797 WHEN NO_DATA_FOUND THEN
7798 ROLLBACK TO DeleteIndUserAccess;
7799 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7800 IF (x_msg_data IS NOT NULL) THEN
7801 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_User_Access ';
7802 ELSE
7803 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_User_Access ';
7804 END IF;
7805 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7806 RAISE;
7807 WHEN OTHERS THEN
7808 ROLLBACK TO DeleteIndUserAccess;
7809 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7810 IF (x_msg_data IS NOT NULL) THEN
7811 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_User_Access ';
7812 ELSE
7813 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_User_Access ';
7814 END IF;
7815 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
7816 RAISE;
7817 END Delete_Ind_User_Access;
7818
7819
7820
7821 /*********************************************************
7822 Name : Delete_Sim_Tree_Data
7823 Description : This API deletes Simulation Tree Data
7824 created by : ashankar 20-JUL-2005
7825 /********************************************************/
7826
7827 PROCEDURE Delete_Sim_Tree_Data
7828 (
7829 p_commit IN VARCHAR2 := FND_API.G_FALSE
7830 ,p_Bsc_Kpi_Entity_Rec IN BSC_KPI_PUB.BSC_KPI_ENTITY_REC
7831 ,x_return_status OUT NOCOPY VARCHAR2
7832 ,x_msg_count OUT NOCOPY NUMBER
7833 ,x_msg_data OUT NOCOPY VARCHAR2
7834 ) IS
7835
7836 l_count NUMBER;
7837 l_CustView_Rec BSC_CUSTOM_VIEW_PUB.Bsc_Cust_View_Rec_Type;
7838 l_short_name BSC_KPIS_VL.short_name%TYPE;
7839
7840 CURSOR c_sys_images IS
7841 SELECT image_id
7842 FROM BSC_SYS_IMAGES
7843 WHERE image_id NOT IN
7844 ( SELECT DISTINCT(image_id)
7845 FROM BSC_SYS_IMAGES_MAP_TL
7846 );
7847
7848 BEGIN
7849 FND_MSG_PUB.Initialize;
7850 x_return_status := FND_API.G_RET_STS_SUCCESS;
7851 SAVEPOINT DeleteSimTreeData;
7852
7853 IF (p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id IS NOT NULL)THEN
7854 SELECT COUNT(0)
7855 INTO l_count
7856 FROM bsc_kpis_b
7857 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7858
7859 IF (l_count = 0) THEN
7860 FND_MESSAGE.SET_NAME('BSC','BSC_INVALID_KPI_ID');
7861 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7862 FND_MSG_PUB.ADD;
7863 RAISE FND_API.G_EXC_ERROR;
7864 END IF;
7865 ELSE
7866 FND_MESSAGE.SET_NAME('BSC','BSC_NO_KPI_ID_ENTERED');
7867 FND_MESSAGE.SET_TOKEN('BSC_KPI', p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id);
7868 FND_MSG_PUB.ADD;
7869 RAISE FND_API.G_EXC_ERROR;
7870 END IF;
7871
7872
7873 SELECT short_name
7874 INTO l_short_name
7875 FROM bsc_kpis_vl
7876 WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7877
7878
7879 DELETE
7880 FROM bsc_kpi_tree_nodes_b
7881 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7882
7883 DELETE
7884 FROM bsc_kpi_tree_nodes_tl
7885 WHERE indicator=p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7886
7887 DELETE
7888 FROM BSC_TAB_VIEW_LABELS_B
7889 WHERE tab_id =BSC_KPI_PVT.c_SIM_TAB_ID
7890 AND tab_view_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7891
7892
7893 DELETE
7894 FROM BSC_TAB_VIEW_LABELS_TL
7895 WHERE tab_id =BSC_KPI_PVT.c_SIM_TAB_ID
7896 AND tab_view_id = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
7897
7898
7899 DELETE
7900 FROM BSC_SYS_IMAGES_MAP_TL
7901 WHERE SOURCE_TYPE = 2
7902 AND SOURCE_CODE = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
7903 AND TYPE = BSC_SIMULATION_VIEW_PUB.c_TYPE;
7904
7905 -- now check if there are any unwanted images in the system and not being
7906 -- used by any of the scorecard then delete them
7907
7908 FOR cd IN c_sys_images LOOP
7909 l_CustView_Rec.Bsc_Image_Id := cd.image_id;
7910
7911 DELETE
7912 FROM BSC_SYS_IMAGES
7913 WHERE IMAGE_ID = l_CustView_Rec.Bsc_Image_Id;
7914
7915 END LOOP;
7916
7917
7918
7919 --Here delete from ak_Regions also
7920 --first we check if there exists any record in ak_Region then we will delete from the following tables
7921 SELECT COUNT(0)
7922 INTO l_count
7923 FROM ak_regions
7924 WHERE region_code =l_short_name;
7925
7926
7927 IF(l_count>0)THEN
7928
7929 BIS_FORM_FUNCTIONS_PUB.DELETE_FUNCTION_AND_MENU_ENT
7930 (
7931 p_function_name => l_short_name
7932 ,x_return_status => x_return_status
7933 ,x_msg_count => x_msg_count
7934 ,x_msg_data => x_msg_data
7935 );
7936 IF(x_return_status IS NOT NULL AND x_return_status <>FND_API.G_RET_STS_SUCCESS)THEN
7937 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7938 END IF;
7939
7940
7941 BIS_AK_REGION_PUB.DELETE_REGION_AND_REGION_ITEMS
7942 (
7943 p_REGION_CODE => l_short_name
7944 ,p_REGION_APPLICATION_ID => 271
7945 ,x_return_status => x_return_status
7946 ,x_msg_count => x_msg_count
7947 ,x_msg_data => x_msg_data
7948 );
7949
7950 IF(x_return_status IS NOT NULL AND x_return_status <>FND_API.G_RET_STS_SUCCESS)THEN
7951 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7952 END IF;
7953
7954 END IF;
7955
7956
7957
7958 IF (p_commit = FND_API.G_TRUE) THEN
7959 COMMIT;
7960 END IF;
7961
7962 EXCEPTION
7963 WHEN FND_API.G_EXC_ERROR THEN
7964 ROLLBACK TO DeleteSimTreeData;
7965 FND_MSG_PUB.Count_And_Get
7966 ( p_encoded => FND_API.G_FALSE
7967 , p_count => x_msg_count
7968 , p_data => x_msg_data
7969 );
7970 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_ERROR '||x_msg_data);
7971 x_return_status := FND_API.G_RET_STS_ERROR;
7972 RAISE;
7973 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7974 ROLLBACK TO DeleteSimTreeData;
7975 FND_MSG_PUB.Count_And_Get
7976 ( p_encoded => FND_API.G_FALSE
7977 , p_count => x_msg_count
7978 , p_data => x_msg_data
7979 );
7980 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7981 --DBMS_OUTPUT.PUT_LINE('EXCEPTION FND_API.G_EXC_UNEXPECTED_ERROR '||x_msg_data);
7982 RAISE;
7983 WHEN NO_DATA_FOUND THEN
7984 ROLLBACK TO DeleteSimTreeData;
7985 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7986 IF (x_msg_data IS NOT NULL) THEN
7987 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_User_Access ';
7988 ELSE
7989 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_User_Access ';
7990 END IF;
7991 --DBMS_OUTPUT.PUT_LINE('EXCEPTION NO_DATA_FOUND '||x_msg_data);
7992 RAISE;
7993 WHEN OTHERS THEN
7994 ROLLBACK TO DeleteSimTreeData;
7995 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7996 IF (x_msg_data IS NOT NULL) THEN
7997 x_msg_data := x_msg_data||' -> BSC_KPI_PVT.Delete_Ind_User_Access ';
7998 ELSE
7999 x_msg_data := SQLERRM||' at BSC_KPI_PVT.Delete_Ind_User_Access ';
8000 END IF;
8001 --DBMS_OUTPUT.PUT_LINE('EXCEPTION OTHERS '||x_msg_data);
8002 RAISE;
8003 END Delete_Sim_Tree_Data;
8004
8005 END BSC_KPI_PVT;