DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_FP_CI_INCLUDE_PKG

Source


1 PACKAGE BODY pa_fp_ci_include_pkg AS
2 /* $Header: PAFPINCB.pls 120.1 2005/08/19 16:26:49 mwasowic noship $ */
3 
4 
5 
6 
7 PROCEDURE FP_CI_COPY_CONTROL_ITEMS
8 (
9   p_project_id          IN pa_budget_versions.project_id%TYPE,
10   p_source_ci_id_tbl    IN PA_PLSQL_DATATYPES.IdTabTyp,
11   p_target_ci_id        IN pa_budget_versions.ci_id%TYPE,
12   p_merge_unmerge_mode  IN VARCHAR2 ,
13   p_commit_flag         IN VARCHAR2 ,
14   p_init_msg_list       IN VARCHAR2 ,
15   p_calling_context     IN VARCHAR2,
16   x_warning_flag        OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
17   x_msg_data            OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
18   x_msg_count           OUT NOCOPY NUMBER, --File.Sql.39 bug 4440895
19   x_return_status       OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
20  )
21  IS
22        --Defining amount variables
23        l_approved_cost_flag pa_budget_versions.approved_cost_plan_type_flag%TYPE;
24        l_approved_rev_flag  pa_budget_versions.approved_rev_plan_type_flag%TYPE;
25        l_ci_id              pa_budget_versions.ci_id%TYPE;
26        l_second_bv_id       pa_budget_versions.budget_version_id%TYPE;
27 
28        --Defining PL/SQL local variables
29        l_s_fp_version_id_tbl    PA_PLSQL_DATATYPES.IdTabTyp;
30        l_t_fp_version_id_tbl    PA_PLSQL_DATATYPES.IdTabTyp;
31 
32        l_s_fp_ci_id_tbl     PA_PLSQL_DATATYPES.IdTabTyp;
33        l_t_fp_ci_id_tbl     PA_PLSQL_DATATYPES.IdTabTyp;
34 
35        l_s_fp_ci_id     pa_budget_versions.ci_id%TYPE;
36        l_t_fp_ci_id     pa_budget_versions.ci_id%TYPE;
37 
38        l_source_version_id  pa_budget_versions.budget_version_id%TYPE;
39        l_target_version_id  pa_budget_versions.budget_version_id%TYPE;
40 
41        l_s_fin_plan_pref_code   pa_proj_fp_options. fin_plan_preference_code%TYPE;
42        l_s_multi_curr_flag      pa_proj_fp_options. plan_in_multi_curr_flag%TYPE;
43        l_s_time_phased_code     pa_proj_fp_options. all_time_phased_code%TYPE;
44        l_s_resource_list_id     pa_proj_fp_options.all_resource_list_id%TYPE;
45        l_s_fin_plan_level_code  pa_proj_fp_options.all_fin_plan_level_code%TYPE;
46        l_s_uncategorized_flag   pa_resource_lists_all_bg.uncategorized_flag %TYPE;
47        l_s_group_res_type_id    pa_resource_lists_all_bg.group_resource_type_id%TYPE;
48        l_s_version_type         pa_budget_versions.version_type%TYPE;
49        l_s_ci_id                pa_budget_versions.ci_id%TYPE;
50 
51        l_copy_version_flag  VARCHAR2(1);
52        l_copy_possible_flag VARCHAR2(1);
53        l_debug_mode         VARCHAR2(30);
54        l_bulk_fetch_count   NUMBER := 0;
55        l_index              NUMBER := 1;
56        l_count              NUMBER := 0;
57        l_count_versions     NUMBER := 0;
58        l_count_projects     NUMBER := 0;
59        l_target_plan_types_cnt  NUMBER := 0;
60        l_merged_count       NUMBER := 0;
61        l_source_project_id  pa_control_items.project_id%TYPE;
62 
63  BEGIN
64     savepoint before_copy_control_items;
65         pa_debug.init_err_stack('PAFPINCB.FP_CI_COPY_CONTROL_ITEMS');
66         IF NVL(p_init_msg_list,'N') = 'Y' THEN
67         FND_MSG_PUB.initialize;
68         END IF;
69         fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
70         l_debug_mode := NVL(l_debug_mode, 'Y');
71         pa_debug.set_process('PLSQL','LOG',l_debug_mode);
72         x_return_status := FND_API.G_RET_STS_SUCCESS;
73         x_msg_count := 0;
74 
75         IF (p_calling_context = 'COPY') THEN
76             --A change document is being copied to another change document
77             --This means only one source change order and one target change order exists
78 
79             For i in p_source_ci_id_tbl.FIRST.. p_source_ci_id_tbl.LAST
80             LOOP
81                 --Getting the lone source ci_id from the PlSql Table
82                 l_s_fp_ci_id := p_source_ci_id_tbl(i);
83             END LOOP;
84 
85             --Getting the target ci_id from the parameter
86             l_t_fp_ci_id := p_target_ci_id;
87 
88             --DBMS_OUTPUT.PUT_LINE('l_s_fp_ci_id : ' || l_s_fp_ci_id);
89             --DBMS_OUTPUT.PUT_LINE('l_t_fp_ci_id : ' || l_t_fp_ci_id);
90 
91             --Checking if control item id is null
92             IF l_s_fp_ci_id IS NULL THEN
93                 PA_UTILS.Add_Message ( p_app_short_name => 'PA',
94                                p_msg_name => 'PA_FP_CI_NULL_CI_ID'
95                              );
96                 x_warning_flag := 'Y';
97                 RETURN;
98             END IF;
99                 IF l_t_fp_ci_id IS NULL THEN
100                 PA_UTILS.Add_Message ( p_app_short_name => 'PA',
101                                p_msg_name => 'PA_FP_CI_NULL_CI_ID'
102                              );
103                 x_warning_flag := 'Y';
104                 RETURN;
105             END IF;
106             IF p_project_id IS NULL THEN
107                 PA_UTILS.Add_Message ( p_app_short_name => 'PA',
108                                p_msg_name => 'PA_FP_CI_NULL_PARAM_PASSED'
109                              );
110                 x_warning_flag := 'Y';
111                 RETURN;
112             END IF;
113 
114             --Check if the source control item id belongs
115             --to the same project or not as the target control item id
116 
117             SELECT bv.project_id
118             INTO l_source_project_id
119             FROM pa_control_items bv
120             WHERE
121             bv.ci_id = l_s_fp_ci_id;
122 
123             --DBMS_OUTPUT.PUT_LINE('l_source_project_id : ' || l_source_project_id);
124 
125             IF (l_source_project_id <> p_project_id) THEN
126                 PA_UTILS.ADD_MESSAGE
127                     ( p_app_short_name => 'PA',
128                       p_msg_name       => 'PA_FP_CI_INV_PROJECT_MATCH'
129                     );
130                 x_warning_flag := 'Y';
131                 RETURN;
132             END IF;
133 
134             -- Bug 3677924 Raja 02-Jul-04  Create impact records for the target ci
135             populate_ci_fin_impact_records
136                  (
137                   p_project_id         => p_project_id
138                   ,p_source_ci_id      => l_s_fp_ci_id
139                   ,p_target_ci_id      => l_t_fp_ci_id
140                   ,p_calling_context   => 'COPY'
141                   ,x_return_status     => x_return_status
142                   ,x_msg_count         => x_msg_count
143                   ,x_msg_data          => x_msg_data
144                  );
145             IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
146                 ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 9');
147                 x_warning_flag := 'Y';
148                 ROLLBACK TO before_copy_control_items;
149                 RETURN;
150             END IF;
151 
152             --If the source belongs to the same project
153             --as the target then go ahead with processing
154 
155             Pa_Fp_Ci_Merge.FP_CI_MERGE_CI_ITEMS
156                (
157                 p_project_id            => p_project_id,
158                 p_s_fp_ci_id            => l_s_fp_ci_id,
159                 p_t_fp_ci_id            => l_t_fp_ci_id,
160                 p_merge_unmerge_mode    => p_merge_unmerge_mode,
161                 p_commit_flag           => 'N',
162                 p_init_msg_list         => 'N',
163                 p_calling_context       => 'COPY',
164                 x_warning_flag          => x_warning_flag,
165                 x_return_status         => x_return_status,
166                 x_msg_count             => x_msg_count,
167                 x_msg_data              => x_msg_data
168                );
169             IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
170                 ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 9');
171                 x_warning_flag := 'Y';
172                 RETURN;
173             END IF;
174             IF x_warning_flag = 'Y' THEN
175                 ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 10');
176                 ROLLBACK TO before_copy_control_items;
177                 PA_UTILS.ADD_MESSAGE
178                     ( p_app_short_name => 'PA',
179                       p_msg_name       => 'PA_FP_CI_NO_COPY_POSSIBLE'
180                     );
181                     x_return_status := FND_API.G_RET_STS_ERROR;
182                 RETURN;
183             END IF;
184         ELSIF (p_calling_context = 'INCLUDE') THEN
185             --One or more change documents are being copied to another change document
186             --This means only one source change order and one target change order exists
187 
188             For i in p_source_ci_id_tbl.FIRST.. p_source_ci_id_tbl.LAST
189             LOOP
190                 BEGIN
191                     --Getting the source ci_id from the PlSql Table
192                     l_s_fp_ci_id := p_source_ci_id_tbl(i);
193 
194                     --Getting the target ci_id from the parameter
195                     l_t_fp_ci_id := p_target_ci_id;
196 
197                     --DBMS_OUTPUT.PUT_LINE('l_s_fp_ci_id : ' || l_s_fp_ci_id);
198                     --DBMS_OUTPUT.PUT_LINE('l_t_fp_ci_id : ' || l_t_fp_ci_id);
199 
200                     --Checking if control item id is null
201                     IF l_s_fp_ci_id IS NULL THEN
202                         PA_UTILS.Add_Message ( p_app_short_name => 'PA',
203                                        p_msg_name => 'PA_FP_CI_NULL_CI_ID'
204                                      );
205                         raise RAISE_COPY_CI_ERROR;
206                     END IF;
207                     IF l_t_fp_ci_id IS NULL THEN
208                         PA_UTILS.Add_Message ( p_app_short_name => 'PA',
209                                        p_msg_name => 'PA_FP_CI_NULL_CI_ID'
210                                      );
211                         raise RAISE_COPY_CI_ERROR;
212                     END IF;
213                     IF p_project_id IS NULL THEN
214                         PA_UTILS.Add_Message ( p_app_short_name => 'PA',
215                                        p_msg_name => 'PA_FP_CI_NULL_PARAM_PASSED'
216                                      );
217                         raise RAISE_COPY_CI_ERROR;
218                     END IF;
219 
220                     --Check if the source control item id belongs
221                     --to the same project or not as the target control item id
222                     SELECT bv.project_id
223                     INTO l_source_project_id
224                     FROM pa_control_items bv
225                     WHERE
226                     bv.ci_id = l_s_fp_ci_id;
227 
228                     --DBMS_OUTPUT.PUT_LINE('l_source_project_id : ' || l_source_project_id);
229 
230                     IF (l_source_project_id <> p_project_id) THEN
231                         PA_UTILS.ADD_MESSAGE
232                             ( p_app_short_name => 'PA',
233                               p_msg_name       => 'PA_FP_CI_INV_PROJECT_MATCH'
234                             );
235                         raise RAISE_COPY_CI_ERROR;
236                     END IF;
237 
238                     -- Bug 3677924 Raja 02-Jul-04  Create impact records for the target ci
239                     populate_ci_fin_impact_records
240                          (
241                           p_project_id         => p_project_id
242                           ,p_source_ci_id      => l_s_fp_ci_id
243                           ,p_target_ci_id      => l_t_fp_ci_id
244                           ,p_calling_context   => 'COPY'
245                           ,x_return_status     => x_return_status
246                           ,x_msg_count         => x_msg_count
247                           ,x_msg_data          => x_msg_data
248                          );
249                     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
250                         ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 9');
251                         x_warning_flag := 'Y';
252                         ROLLBACK TO before_copy_control_items;
253                         RETURN;
254                     END IF;
255 
256                     --If the source belongs to the same project
257                     --as the target then go ahead with processing
258 
259                     Pa_Fp_Ci_Merge.FP_CI_MERGE_CI_ITEMS
260                        (
261                         p_project_id            => p_project_id,
262                         p_s_fp_ci_id            => l_s_fp_ci_id,
263                         p_t_fp_ci_id            => l_t_fp_ci_id,
264                         p_merge_unmerge_mode    => p_merge_unmerge_mode,
265                         p_commit_flag           => 'N',
266                         p_init_msg_list         => 'N',
267                         p_calling_context       => 'COPY',
268                         x_warning_flag          => x_warning_flag,
269                         x_return_status         => x_return_status,
270                         x_msg_count             => x_msg_count,
271                         x_msg_data              => x_msg_data
272                        );
273                     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
274                         ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 9');
275                         x_warning_flag := 'Y';
276                         RETURN;
277                     END IF;
278                     IF x_warning_flag = 'Y' THEN
279                         raise RAISE_COPY_CI_ERROR;
280                         ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 10');
281                     END IF;
282                 EXCEPTION
283                     WHEN RAISE_COPY_CI_ERROR THEN
284                         x_warning_flag := 'Y';
285                         x_return_status := FND_API.G_RET_STS_ERROR;
286                 END;
287             END LOOP;
288             IF x_warning_flag = 'Y' THEN
289             ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 10');
290             ROLLBACK TO before_copy_control_items;
291             PA_UTILS.ADD_MESSAGE
292                 ( p_app_short_name => 'PA',
293                   p_msg_name       => 'PA_FP_CI_NO_COPY_POSSIBLE'
294                 );
295             END IF;
296         END IF;
297         IF NVL(p_commit_flag,'N') = 'Y' THEN
298              COMMIT;
299         END IF;
300  EXCEPTION
301     WHEN OTHERS THEN
302         ROLLBACK TO before_copy_control_items;
303         FND_MSG_PUB.add_exc_msg
304                ( p_pkg_name       => 'pa_fp_ci_include_pkg.' ||
305                 'FP_CI_COPY_CONTROL_ITEMS'
306                 ,p_procedure_name => PA_DEBUG.G_Err_Stack);
307         PA_DEBUG.g_err_stage := 'Unexpected error in FP_CI_COPY_CONTROL_ITEMS';
308         PA_DEBUG.Log_Message(p_message => PA_DEBUG.g_err_stage);
309         ----DBMS_OUTPUT.PUT_LINE('FP_CI_COPY_CONTROL_ITEMS - 11*****');
310         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
311         PA_DEBUG.Reset_Curr_Function;
312         RAISE;
313 
314  END FP_CI_COPY_CONTROL_ITEMS;
315 --end of FP_CI_COPY_CONTROL_ITEMS
316 
317 /*=============================================================================
318  This api is called to create financial realted impacts in pa_ci_impacts during
319  change document inclusion or change document copy.
320 
321  02-Jul-2004   rravipat  Bug 3677924
322                          Initial Creation
323 ==============================================================================*/
324 
325 PROCEDURE populate_ci_fin_impact_records(
326           p_project_id           IN   pa_projects_all.project_id%TYPE
327           ,p_source_ci_id        IN   pa_budget_versions.ci_id%TYPE
328           ,p_target_ci_id        IN   pa_budget_versions.ci_id%TYPE
329           ,p_calling_context     IN   VARCHAR2
330           ,x_return_status       OUT  NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
331           ,x_msg_count           OUT  NOCOPY NUMBER --File.Sql.39 bug 4440895
332           ,x_msg_data            OUT  NOCOPY VARCHAR2) --File.Sql.39 bug 4440895
333 AS
334 
335     --Start of variables used for debugging
336 
337     l_return_status      VARCHAR2(1);
338     l_msg_count          NUMBER := 0;
339     l_msg_data           VARCHAR2(2000);
340     l_data               VARCHAR2(2000);
341     l_msg_index_out      NUMBER;
342     l_debug_mode         VARCHAR2(30);
343     l_module_name        VARCHAR2(30) := 'pa_fp_ci_include_pkg';
344 
345     --End of variables used for debugging
346 
347     l_appr_bdgt_pt_exists     VARCHAR2(1);
348     l_allowed_impacts_count   NUMBER;
349 
350     l_impact_type_code VARCHAR2(30);
351     l_desp VARCHAR2(4000);
352     l_comment VARCHAR2(4000);
353     l_ci_impact_id NUMBER;
354     l_implementation_date DATE;
355     l_implemented_by NUMBER;
356     l_record_ver_number NUMBER;
357     l_temp VARCHAR2(1);
358 
359     l_rowid VARCHAR(100);
360     l_new_ci_impact_id NUMBER;
361     l_task_id NUMBER;
362     l_temp2 VARCHAR2(4000);
363 
364 
365     -- get source CI impacts
366     -- note FINPLAN record is not compulsory
367     CURSOR get_source_ci_impacts
368     IS
369       SELECT  a.*
370         FROM  pa_ci_impacts a
371        WHERE  a.ci_id = p_source_ci_id
372          AND  a.impact_type_code IN ('FINPLAN_COST','FINPLAN_REVENUE','FINPLAN')
373          AND (a.impact_type_code = 'FINPLAN' OR
374                 EXISTS (SELECT 1
375                           FROM pa_control_items targetCi,
376                                pa_ci_impact_type_usage targetUsage
377                          WHERE targetCi.ci_id = p_target_ci_id
378                            AND targetCi.ci_type_id = targetUsage.ci_type_id
379                            AND targetUsage.impact_type_code = a.impact_type_code));
380 
381 
382     -- get the copy to CI impacts
383     CURSOR get_orig_info
384     IS
385       SELECT ci_impact_id, description, implementation_comment,
386              implementation_date, implemented_by, record_version_number,
387              impacted_task_id
388       FROM   pa_ci_impacts
389       WHERE  ci_id = p_target_ci_id
390       AND    impact_type_code = l_impact_type_code;
391 
392 BEGIN
393 
394     x_msg_count := 0;
395     x_return_status := FND_API.G_RET_STS_SUCCESS;
396 
397     fnd_profile.get('PA_DEBUG_MODE',l_debug_mode);
398     l_debug_mode := NVL(l_debug_mode, 'Y');
399 
400     -- Set curr function
401     pa_debug.set_curr_function(
402                 p_function   =>'PAFPINCB.populate_ci_fin_impact_records'
403                ,p_debug_mode => l_debug_mode );
404 
405     -- Check for business rules violations
406     IF l_debug_mode = 'Y' THEN
407         pa_debug.g_err_stage:='Validating input parameters';
408         pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,3);
409     END IF;
410 
411     IF (p_project_id IS NULL) OR
412        (p_target_ci_id IS NULL) OR
413        (p_source_ci_id IS NULL) OR
414        (p_calling_context NOT IN ('INCLUDE','COPY'))
415     THEN
416 
417         IF l_debug_mode = 'Y' THEN
418            pa_debug.g_err_stage:='Project_id = '||p_project_id;
419            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
420 
421            pa_debug.g_err_stage:='p_target_ci_id = '||p_target_ci_id;
422            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
423 
424            pa_debug.g_err_stage:='p_source_ci_id = '||p_source_ci_id;
425            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
426 
427            pa_debug.g_err_stage:='p_calling_context = '||p_calling_context;
428            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
429         END IF;
430 
431         PA_UTILS.ADD_MESSAGE( p_app_short_name => 'PA',
432                               p_msg_name       => 'PA_FP_INV_PARAM_PASSED',
433                               p_token1         => 'PROCEDURENAME',
434                               p_value1         => 'FP_CI_COPY_CONTROL_ITEMS.populate_ci_fin_impact_records');
435 
436         RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
437 
438     END IF;
439 
440     -- if target project has an approved budget meaning 'Cost and Rev Together' setup
441     -- then for a change document to have financial impact the change document type
442     -- should allow both cost impact and revenue impacts.
443     Begin
444         select 'Y'
445         into   l_appr_bdgt_pt_exists
446         from   dual
447         where  exists
448                (select 1 from pa_proj_fp_options
449                 where  project_id = p_project_id
450                 and    approved_cost_plan_type_flag = 'Y'
451                 and    approved_rev_plan_type_flag = 'Y'
452                 and    fin_plan_option_level_code = 'PLAN_TYPE'
453                 and    fin_plan_preference_code = 'COST_AND_REV_SAME');
454     Exception
455         When no_data_found then
456             l_appr_bdgt_pt_exists := 'N';
457     End;
458 
459 
460     -- Check if change order type allows either of cost, revenue impacts
461     SELECT count(*)
462     INTO   l_allowed_impacts_count
463     FROM   pa_control_items pci,
464            pa_ci_impact_type_usage pcit
465     WHERE  pci.ci_type_id = pcit.ci_type_id
466     AND    pci.ci_id = p_target_ci_id
467     AND    impact_type_code IN ('FINPLAN_COST','FINPLAN_REVENUE');
468 
469     IF l_allowed_impacts_count = 0 THEN
470        -- target change order type does not allow financail impact
471        pa_debug.reset_curr_function();
472        return;
473     ELSIF l_allowed_impacts_count = 1 THEN
474 
475         IF l_appr_bdgt_pt_exists = 'Y' THEN
476            -- if its approved budget create impact records only if change
477            -- type allows both cost and revenue impacts
478            pa_debug.reset_curr_function();
479            return;
480         END IF;
481     END IF;
482 
483     -- fetch all the financial impact records that are present in source change
484     -- document, if a record already exists its updated else a new record is created
485     FOR rec IN get_source_ci_impacts
486     LOOP
487 
488         l_impact_type_code := rec.impact_type_code;
489 
490         OPEN get_orig_info;
491 
492         FETCH get_orig_info INTO l_ci_impact_id, l_desp, l_comment,
493           l_implementation_date, l_implemented_by, l_record_ver_number, l_task_id;
494 
495         IF get_orig_info%notfound THEN
496            -- insert a new record to the new impact
497            pa_ci_impacts_pkg.insert_row(
498                          l_rowid,
499                          l_new_ci_impact_id,
500                          p_target_ci_id,
501                          rec.impact_type_code,
502                          'CI_IMPACT_PENDING',
503                          rec.description,
504                          NULL,
505                          NULL,
506                          NULL,
507                          rec.impacted_task_id,
508                          sysdate,
509                          fnd_global.user_id,
510                          Sysdate,
511                          fnd_global.user_id,
512                          fnd_global.login_id
513                         );
514         ELSE
515            l_temp2 := Substr(l_desp || ' ' || rec.description, 1, 4000);
516 
517            -- update the existing one
518            pa_ci_impacts_pkg.update_row(
519                          l_ci_impact_id,
520                          p_target_ci_id,
521                          l_impact_type_code,
522                          NULL,
523                          l_temp2,
524                          l_implementation_date,
525                          l_implemented_by,
526                          l_comment,
527                          Nvl(l_task_id, rec.impacted_task_id),
528                          sysdate,
529                          fnd_global.user_id,
530                          fnd_global.login_id,
531                          l_record_ver_number
532                         );
533         END IF;
534 
535         CLOSE get_orig_info;
536     END LOOP;
537 
538 
539     IF l_debug_mode = 'Y' THEN
540         pa_debug.g_err_stage:='Exiting populate_ci_fin_impact_records';
541         pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,3);
542     END IF;
543 
544     -- reset curr function
545     pa_debug.reset_curr_function();
546 
547 EXCEPTION
548 
549    WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc THEN
550        l_msg_count := FND_MSG_PUB.count_msg;
551        IF l_msg_count = 1 THEN
552            PA_INTERFACE_UTILS_PUB.get_messages
553                  (p_encoded        => FND_API.G_TRUE
554                   ,p_msg_index      => 1
555                   ,p_msg_count      => l_msg_count
556                   ,p_msg_data       => l_msg_data
557                   ,p_data           => l_data
558                   ,p_msg_index_out  => l_msg_index_out);
559 
560            x_msg_data := l_data;
561            x_msg_count := l_msg_count;
562        ELSE
563            x_msg_count := l_msg_count;
564        END IF;
565 
566        x_return_status := FND_API.G_RET_STS_ERROR;
567 
568        IF l_debug_mode = 'Y' THEN
569            pa_debug.g_err_stage:='Invalid Arguments Passed Or called api raised an error';
570            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
571 
572        END IF;
573 
574        -- reset curr function
575        pa_debug.reset_curr_function();
576 
577        RETURN;
578    WHEN Others THEN
579        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
580        x_msg_count     := 1;
581        x_msg_data      := SQLERRM;
582 
583        FND_MSG_PUB.add_exc_msg( p_pkg_name        => 'FP_CI_COPY_CONTROL_ITEMS'
584                                ,p_procedure_name  => 'populate_ci_fin_impact_records');
585 
586        IF l_debug_mode = 'Y' THEN
587            pa_debug.g_err_stage:='Unexpected Error'||SQLERRM;
588            pa_debug.write('populate_ci_fin_impact_records: ' || l_module_name,pa_debug.g_err_stage,5);
589        END IF;
590 
591        -- reset curr function
592        pa_debug.Reset_Curr_Function();
593 
594        RAISE;
595 END populate_ci_fin_impact_records;
596 
597 
598 
599 END pa_fp_ci_include_pkg;
600 --end of PACKAGE pa_fp_ci_include_pkg