DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_RATE_ATTR_PKG

Source


1 package body PA_RATE_ATTR_PKG AS
2 /* $Header: PARATTRB.pls 120.4 2007/02/06 09:46:22 dthakker noship $ */
3 procedure RATE_ATTR_UPGRD(
4   P_BUDGET_VER_TBL            IN   SYSTEM.PA_NUM_TBL_TYPE,
5   X_RETURN_STATUS             OUT  NOCOPY VARCHAR2,
6   X_MSG_COUNT                 OUT  NOCOPY NUMBER,
7   X_MSG_DATA                  OUT  NOCOPY VARCHAR2) IS
8 
9 
10     -- Bug 3787658, 06-AUG-2004, jwhite -------------------------------------------------
11     -- Added column project_structure_version_id  to select cluase
12     -- Bug 3799921, 26-AUG-2004, jwhite -------------------------------------------------
13     -- Removed columns project_structure_version_id and wp_version_flag
14 
15     cursor get_budget_ver_csr(c_budget_version_id pa_budget_versions.budget_version_id%type) is
16     select bv.budget_version_id,bv.project_id,bv.resource_list_id
17     from pa_budget_versions bv
18     where bv.fin_plan_type_id is not null
19     and bv.budget_version_id = c_budget_version_id
20     and exists (select 'X' from pa_resource_assignments ra
21     where bv.budget_version_id = ra.budget_version_id);
22 
23     -- End Bug 3787658, 06-AUG-2004, jwhite ----------------------------------------------
24 
25 
26     cursor get_res_assign_id_csr(c_budget_version_id pa_budget_versions.budget_version_id%type, c_project_id pa_projects_all.project_id%type) is
27     select ra.resource_assignment_id,ra.resource_list_member_id,
28     rlm.migrated_rbs_element_id,
29     min(bl.start_date) min_date,max(bl.end_date) max_date
30     from pa_resource_assignments ra,pa_resource_list_members rlm,pa_budget_lines bl
31     where ra.budget_version_id = c_budget_version_id and
32     ra.project_id = c_project_id
33     AND ra.resource_list_member_id = rlm.resource_list_member_id
34     AND rlm.res_format_id is not null  -- Added for bug#4765774
35     and ra.budget_version_id = bl.budget_version_id
36     group by ra.resource_assignment_id,ra.resource_list_member_id,rlm.migrated_rbs_element_id
37     order by  ra.resource_assignment_id,ra.resource_list_member_id;
38 
39 
40     -- End Bug 3787658, 06-AUG-2004, jwhite -------------------------------------------------
41 
42 
43     TYPE res_assign_id_tbl is table of pa_resource_assignments.resource_assignment_id%type
44     index by binary_integer;
45     l_res_assign_id_tbl res_assign_id_tbl;
46 
47     TYPE rbs_element_id_tbl is table of pa_resource_list_members.migrated_rbs_element_id%type
48     index by binary_integer;
49     l_rbs_element_id_tbl rbs_element_id_tbl;
50 
51     TYPE max_date_tbl is table of pa_proj_period_profiles.period1_start_date%TYPE
52     index by binary_integer;
53     l_max_date_tbl max_date_tbl;
54 
55     TYPE min_date_tbl is table of pa_proj_period_profiles.period1_start_date%TYPE
56     index by binary_integer;
57     l_min_date_tbl min_date_tbl;
58 
59 
60     l_resource_class_flag_tbl       SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
61     l_resource_class_code_tbl       SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
62     l_resource_class_id_tbl     SYSTEM.PA_NUM_TBL_TYPE;
63     l_res_type_code_tbl         SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
64     l_incur_by_res_type_tbl     SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
65     l_person_id_tbl         SYSTEM.PA_NUM_TBL_TYPE;
66     l_job_id_tbl            SYSTEM.PA_NUM_TBL_TYPE;
67     l_person_type_code_tbl      SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
68     l_named_role_tbl            SYSTEM.PA_VARCHAR2_80_TBL_TYPE;
69     l_bom_resource_id_tbl       SYSTEM.PA_NUM_TBL_TYPE;
70     l_non_labor_resource_tbl        SYSTEM.PA_VARCHAR2_20_TBL_TYPE;
71     l_inventory_item_id_tbl     SYSTEM.PA_NUM_TBL_TYPE;
72     l_item_category_id_tbl      SYSTEM.PA_NUM_TBL_TYPE;
73     l_project_role_id_tbl       SYSTEM.PA_NUM_TBL_TYPE;
74     l_organization_id_tbl       SYSTEM.PA_NUM_TBL_TYPE;
75     l_fc_res_type_code_tbl      SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
76     l_expenditure_type_tbl      SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
77     l_expenditure_category_tbl      SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
78     l_event_type_tbl            SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
79     l_revenue_category_code_tbl     SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
80     l_supplier_id_tbl           SYSTEM.PA_NUM_TBL_TYPE;
81     l_spread_curve_id_tbl       SYSTEM.PA_NUM_TBL_TYPE;
82     l_etc_method_code_tbl       SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
83     l_mfc_cost_type_id_tbl      SYSTEM.PA_NUM_TBL_TYPE;
84     l_incurred_by_res_flag_tbl      SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
85     l_incur_by_res_class_code_tbl   SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
86     l_incur_by_role_id_tbl      SYSTEM.PA_NUM_TBL_TYPE;
87     l_unit_of_measure_tbl       SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
88     l_org_id_tbl            SYSTEM.PA_NUM_TBL_TYPE;
89     l_rate_based_flag_tbl       SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
90     l_rate_expenditure_type_tbl     SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
91     l_rate_exp_func_curr_code_tbl   SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
92     l_sys_rlm_ids_tbl                   SYSTEM.PA_NUM_TBL_TYPE;
93     l_msg_data              VARCHAR2(2000);
94     l_msg_count             NUMBER;
95     l_return_status         VARCHAR2(1):= NULL;
96 
97     l_budget_version_id                  pa_budget_versions.budget_version_id%type;
98 
99 
100     l_debug_mode varchar2(30);
101     l_module_name VARCHAR2(100):= 'pa.plsql.PA_RATE_ATTR_PKG';
102     l_msg_index_out                 NUMBER;
103     l_data                          VARCHAR2(2000);
104 
105     l_spread_curve_id         pa_spread_curves_b.spread_curve_id%TYPE; -- Bug 3988345
106 
107 
108     BEGIN
109 
110        -- FND_MSG_PUB.initialize; /* bug 3800485 */
111 
112        x_msg_count := 0;
113        x_return_status := FND_API.G_RET_STS_SUCCESS;
114        pa_debug.init_err_stack('PA_RATE_ATTR_PKG.Rate_Attr_Upgrd');
115        fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
116        l_debug_mode := NVL(l_debug_mode, 'Y');
117        pa_debug.set_process('PLSQL','LOG',l_debug_mode);
118        IF l_debug_mode = 'Y' THEN
119          pa_debug.g_err_stage := 'Entered Budget Attribute Upgrade';
120          pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
121 
122          pa_debug.g_err_stage := 'Checking for valid parameters';
123          pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
124        END IF;
125 
126     if (p_budget_ver_tbl.count <= 0 ) then
127         IF l_debug_mode = 'Y' THEN
128                pa_debug.g_err_stage := 'Budget Version='||to_char(l_budget_version_id);
129                pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
130           END IF;
131           PA_UTILS.ADD_MESSAGE(p_app_short_name=> 'PA',
132                                p_msg_name      => 'PA_FP_INV_PARAM_PASSED');
133           RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
134     end if;
135 
136     l_sys_rlm_ids_tbl := SYSTEM.PA_NUM_TBL_TYPE();
137     l_resource_class_flag_tbl    :=         SYSTEM.PA_VARCHAR2_1_TBL_TYPE();
138     l_resource_class_code_tbl    :=         SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
139     l_resource_class_id_tbl    :=       SYSTEM.PA_NUM_TBL_TYPE();
140     l_res_type_code_tbl    :=           SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
141     l_incur_by_res_type_tbl    :=       SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
142     l_person_id_tbl    :=           SYSTEM.PA_NUM_TBL_TYPE();
143     l_job_id_tbl    :=              SYSTEM.PA_NUM_TBL_TYPE();
144     l_person_type_code_tbl    :=        SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
145     l_named_role_tbl    :=              SYSTEM.PA_VARCHAR2_80_TBL_TYPE();
146     l_bom_resource_id_tbl    :=         SYSTEM.PA_NUM_TBL_TYPE();
147     l_non_labor_resource_tbl    :=          SYSTEM.PA_VARCHAR2_20_TBL_TYPE();
148     l_inventory_item_id_tbl    :=       SYSTEM.PA_NUM_TBL_TYPE();
149     l_item_category_id_tbl    :=        SYSTEM.PA_NUM_TBL_TYPE();
150     l_project_role_id_tbl    :=         SYSTEM.PA_NUM_TBL_TYPE();
151     l_organization_id_tbl    :=         SYSTEM.PA_NUM_TBL_TYPE();
152     l_fc_res_type_code_tbl    :=        SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
153     l_expenditure_type_tbl    :=        SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
154     l_expenditure_category_tbl    :=        SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
155     l_event_type_tbl    :=              SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
156     l_revenue_category_code_tbl    :=       SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
157     l_supplier_id_tbl    :=             SYSTEM.PA_NUM_TBL_TYPE();
158     l_spread_curve_id_tbl    :=         SYSTEM.PA_NUM_TBL_TYPE();
159     l_etc_method_code_tbl    :=         SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
160     l_mfc_cost_type_id_tbl    :=        SYSTEM.PA_NUM_TBL_TYPE();
161     l_incurred_by_res_flag_tbl    :=        SYSTEM.PA_VARCHAR2_1_TBL_TYPE();
162     l_incur_by_res_class_code_tbl    :=     SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
163     l_incur_by_role_id_tbl    :=        SYSTEM.PA_NUM_TBL_TYPE();
164     l_unit_of_measure_tbl    :=         SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
165     l_org_id_tbl    :=              SYSTEM.PA_NUM_TBL_TYPE();
166     l_rate_based_flag_tbl    :=         SYSTEM.PA_VARCHAR2_1_TBL_TYPE();
167     l_rate_expenditure_type_tbl    :=       SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
168     l_rate_exp_func_curr_code_tbl    :=     SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
169 
170     select spread_curve_id
171     INTO   l_spread_curve_id
172     from   pa_spread_curves_b
173     where  spread_curve_code='FIXED_DATE';
174 
175     for j in p_budget_ver_tbl.first .. p_budget_ver_tbl.last
176     loop
177          l_budget_version_id := p_budget_ver_tbl(j);
178 
179          -- Budget Version Cursor Loop starts here
180          for l_get_budget_ver_csr in get_budget_ver_csr(p_budget_ver_tbl(j))
181          loop
182 
183             -- Resource List Assignment Cursor Loop starts here
184             OPEN get_res_assign_id_csr(l_get_budget_ver_csr.budget_version_id, l_get_budget_ver_csr.project_id);
185             LOOP
186                  l_res_assign_id_tbl.delete;
187                  l_max_date_tbl.delete;
188                  l_min_date_tbl.delete;
189                  l_rbs_element_id_tbl.delete;
190                  l_sys_rlm_ids_tbl.delete;
191                  l_resource_class_flag_tbl.delete;
192                  l_resource_class_code_tbl.delete;
193                  l_resource_class_id_tbl.delete;
194                  l_res_type_code_tbl.delete;
195                  l_person_id_tbl.delete;
196                  l_job_id_tbl.delete;
197                  l_person_type_code_tbl.delete;
198                  l_named_role_tbl.delete;
199                  l_bom_resource_id_tbl.delete;
200                  l_non_labor_resource_tbl.delete;
201                  l_inventory_item_id_tbl.delete;
202                  l_item_category_id_tbl.delete;
203                  l_project_role_id_tbl.delete;
204                  l_organization_id_tbl.delete;
205                  l_fc_res_type_code_tbl.delete;
206                  l_expenditure_type_tbl.delete;
207                  l_expenditure_category_tbl.delete;
208                  l_event_type_tbl.delete;
209                  l_revenue_category_code_tbl.delete;
210                  l_supplier_id_tbl.delete;
211                  l_unit_of_measure_tbl.delete;
212                  l_spread_curve_id_tbl.delete;
213                  l_etc_method_code_tbl.delete;
214                  l_mfc_cost_type_id_tbl.delete;
215                  l_incurred_by_res_flag_tbl.delete;
216                  l_incur_by_res_class_code_tbl.delete;
217                  l_Incur_by_role_id_tbl.delete;
218                  l_org_id_tbl.delete;
219                  l_rate_based_flag_tbl.delete;
220                  l_rate_expenditure_type_tbl.delete;
221                  l_rate_exp_func_curr_code_tbl.delete;
222                  l_incur_by_res_type_tbl.delete;
223 
224                  FETCH get_res_assign_id_csr
225                  BULK COLLECT INTO
226                       l_res_assign_id_tbl,
227                       l_sys_rlm_ids_tbl,
228                       l_rbs_element_id_tbl,
229                       l_min_date_tbl,
230                       l_max_date_tbl
231                  LIMIT 1000;
232                  EXIT WHEN l_sys_rlm_ids_tbl.count=0;
233 
234                  -- Call the following API for getting resource attributes. The first two paramteers are IN and the remaining are OUT parameters.
235                  IF l_debug_mode = 'Y' THEN
236                       pa_debug.g_err_stage := 'Entering GET_RESOURCE_DEFAULTS API';
237                       pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
238                  end if;
239 
240                  if (l_sys_rlm_ids_tbl.count > 0) then
241                       PA_PLANNING_RESOURCE_UTILS.get_resource_defaults (
242                       p_resource_list_members        =>  l_sys_rlm_ids_tbl,
243                       p_project_id                   =>  l_get_budget_ver_csr.project_id,
244                       x_resource_class_flag          =>  l_resource_class_flag_tbl,
245                       x_resource_class_code          =>  l_resource_class_code_tbl,
246                       x_resource_class_id            =>  l_resource_class_id_tbl,
247                       x_res_type_code                =>  l_res_type_code_tbl,
248                       x_incur_by_res_type            =>  l_incur_by_res_type_tbl,
249                       x_person_id                    =>  l_person_id_tbl,
250                       x_job_id                       =>  l_job_id_tbl,
251                       x_person_type_code             =>  l_person_type_code_tbl,
252                       x_named_role                   =>  l_named_role_tbl,
253                       x_bom_resource_id              =>  l_bom_resource_id_tbl,
254                       x_non_labor_resource           =>  l_non_labor_resource_tbl,
255                       x_inventory_item_id            =>  l_inventory_item_id_tbl,
256                       x_item_category_id             =>  l_item_category_id_tbl,
257                       x_project_role_id              =>  l_project_role_id_tbl,
258                       x_organization_id              =>  l_organization_id_tbl,
259                       x_fc_res_type_code             =>  l_fc_res_type_code_tbl,
260                       x_expenditure_type             =>  l_expenditure_type_tbl,
261                       x_expenditure_category         =>  l_expenditure_category_tbl,
262                       x_event_type                   =>  l_event_type_tbl,
263                       x_revenue_category_code        =>  l_revenue_category_code_tbl,
264                       x_supplier_id                  =>  l_supplier_id_tbl,
265                       x_unit_of_measure              =>  l_unit_of_measure_tbl,
266                       x_spread_curve_id              =>  l_spread_curve_id_tbl,
267                       x_etc_method_code              =>  l_etc_method_code_tbl,
268                       x_mfc_cost_type_id             =>  l_mfc_cost_type_id_tbl,
269                       x_incurred_by_res_flag         =>  l_incurred_by_res_flag_tbl,
270                       x_incur_by_res_class_code      =>  l_incur_by_res_class_code_tbl,
271                       x_Incur_by_role_id             =>  l_Incur_by_role_id_tbl,
272                       x_org_id                       =>  l_org_id_tbl,
273                       x_rate_based_flag              =>  l_rate_based_flag_tbl,
274                       x_rate_expenditure_type        =>  l_rate_expenditure_type_tbl,
275                       x_rate_func_curr_code          =>  l_rate_exp_func_curr_code_tbl,
276                       x_msg_data                     =>  l_msg_data,
277                       x_msg_count                    =>  l_msg_count,
278                       x_return_status                =>  l_return_status);
279 
280                       IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
281                            RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
282                       END IF;
283 
284                  end if;
285 
286 
287                  IF l_debug_mode = 'Y' THEN
288                       pa_debug.g_err_stage := 'Exited GET_RESOURCE_DEFAULTS API';
289                       pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
290                  END IF;
291 
292                  -- Check if the called API returns succes
293                  if (l_return_status =  'S') then
294 
295                      IF l_debug_mode = 'Y' THEN
296                         pa_debug.g_err_stage := 'Updating pa_resource_assignments table';
297                         pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
298                      END IF;
299 
300 
301                      FORALL j IN l_res_assign_id_tbl.FIRST..l_res_assign_id_tbl.LAST
302                          update pa_resource_assignments
303                          set
304                          record_version_number             = record_version_number + 1,
305                          rbs_element_id                    = l_rbs_element_id_tbl(j),
306                          resource_class_code               = l_resource_class_code_tbl(j) ,
307                          spread_curve_id                   = decode(l_spread_curve_id,l_spread_curve_id_tbl(j),NULL,l_spread_curve_id_tbl(j)),
308                          sp_fixed_date                     = NULL,
309                          etc_method_code                   = l_etc_method_code_tbl(j),
310                          res_type_code                     = l_res_type_code_tbl(j),
311                          organization_id                   = l_organization_id_tbl(j),
312                          job_id                            = l_job_id_tbl(j),
313                          person_id                         = l_person_id_tbl(j),
314                          expenditure_type                  = l_expenditure_type_tbl(j),
315                          expenditure_category              = l_expenditure_category_tbl(j),
316                          revenue_category_code             = l_revenue_category_code_tbl(j),
317                          event_type                        = l_event_type_tbl(j),
318                          supplier_id                       = l_supplier_id_tbl(j),
319                          project_role_id                   = l_project_role_id_tbl(j),
320                          person_type_code                  = l_person_type_code_tbl(j),
321                          non_labor_resource                = l_non_labor_resource_tbl(j),
322                          bom_resource_id                   = l_bom_resource_id_tbl(j),
323                          inventory_item_id                 = l_inventory_item_id_tbl(j),
324                          item_category_id                  = l_item_category_id_tbl(j),
325                          transaction_source_code           = null,
326                          mfc_cost_type_id                  = l_mfc_cost_type_id_tbl(j),
327                          procure_resource_flag             = null,
328                          incurred_by_res_flag              = l_incurred_by_res_flag_tbl(j),
329                          rate_job_id                       = null,
330                          rate_expenditure_type             = l_rate_expenditure_type_tbl(j),
331                          rate_based_flag                   = l_rate_based_flag_tbl(j),
332                          use_task_schedule_flag            = null,
333                          rate_exp_func_curr_code           = l_rate_exp_func_curr_code_tbl(j),
334                          rate_expenditure_org_id           = l_org_id_tbl(j),    /* bug: 3799921: assigned local var */
335                          incur_by_res_class_code           = l_incur_by_res_class_code_tbl(j),
336                          incur_by_role_id                  = l_incur_by_role_id_tbl(j),
337                          resource_class_flag               = l_resource_class_flag_tbl(j),
338                          named_role                        = l_named_role_tbl(j),
339                          planning_start_date               = l_min_date_tbl(j),
340                          planning_end_date                 = l_max_date_tbl(j),
341                          fc_res_type_code                  = l_fc_res_type_code_tbl(j),          /* Bug 3799921 */
342                          unit_of_measure                   = l_unit_of_measure_tbl(j),           /* Bug 3799921 */
343                          resource_rate_based_flag          = l_rate_based_flag_tbl(j)            /* Bug 5144013: IPM Changes */
344                          where resource_assignment_id = l_res_assign_id_tbl(j);
345                  end if;
346 
347             end loop; -- Resource List Assignment Cursor Loop ends here
348             CLOSE get_res_assign_id_csr;
349 
350             IF l_debug_mode = 'Y' THEN
351                  pa_debug.g_err_stage := 'Updating pa_resource_list_assignments table';
352                  pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL3);
353             END IF;
354 
355 
356          end loop;
357          -- Budget Version Cursor loop ends here.
358     end loop;  -- parameter table loop
359 EXCEPTION
360       WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc then
361       l_msg_count := FND_MSG_PUB.count_msg;
362         IF l_msg_count = 1 THEN
363              PA_INTERFACE_UTILS_PUB.get_messages
364                    (p_encoded         => FND_API.G_TRUE
365                     ,p_msg_index      => 1
366                     ,p_msg_count      => l_msg_count
367                     ,p_msg_data       => l_msg_data
368                     ,p_data           => l_data
369                     ,p_msg_index_out  => l_msg_index_out);
370              x_msg_data := l_data;
371              x_msg_count := l_msg_count;
372         ELSE
373             x_msg_count := l_msg_count;
374             x_msg_data := l_msg_data;
375         END IF;
376 
377         IF l_debug_mode = 'Y' THEN
378              pa_debug.g_err_stage:='Invalid Arguments Passed';
379              pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
380         END IF;
381          x_return_status:= FND_API.G_RET_STS_ERROR;
382         pa_debug.write_file('RATE_ATTR_UPGRD: Upgrade has failed for the budget_version: '||l_budget_version_id,5);
383         pa_debug.write_file('RATE_ATTR_UPGRD: Failure Reason:'||x_msg_data,5);
384         pa_debug.reset_err_stack;
385         -- ROLLBACK;  /* Commented-out rollback to avoid issues the the UPG savepoint */
386         RAISE;
387       WHEN OTHERS THEN
388         if get_budget_ver_csr%ISOPEN then
389            close get_budget_ver_csr;
390         end if;
391         if get_res_assign_id_csr%ISOPEN then
392            close get_res_assign_id_csr;
393         end if;
394         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
395         x_msg_count     := 1;
396         x_msg_data      := SQLERRM;
397 
398         FND_MSG_PUB.add_exc_msg( p_pkg_name=> 'PA_RATE_ATTR_PKG',p_procedure_name  => 'RATE_ATTR_UPGRD');
399         IF l_debug_mode = 'Y' THEN
400              pa_debug.g_err_stage:='Unexpected Error'||SQLERRM;
401              pa_debug.write(l_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
402         END IF;
403 
404         pa_debug.write_file('RATE_ATTR_UPGRD : Upgrade has failed for the budget version '||l_budget_version_id,5);
405         pa_debug.write_file('RATE_ATTR_UPGRD: Failure Reason:'||pa_debug.G_Err_Stack,5);
406         pa_debug.reset_err_stack;
407         -- ROLLBACK; /* Commented-out rollback to avoid issues the the UPG savepoint */
408         RAISE;
409 end RATE_ATTR_UPGRD;
410 end PA_RATE_ATTR_PKG;