DBA Data[Home] [Help]

PACKAGE BODY: APPS.PJI_PA_DEL_MAIN

Source


1 package body PJI_PA_DEL_MAIN as
2   /* $Header: PJIDFW1B.pls 120.2.12020000.2 2012/07/18 10:53:04 admarath ship $ */
3 
4   -- -----------------------------------------------------
5   -- procedure DELETE
6   --
7   -- This the the main procedure, it is invoked from
8   -- a concurrent program.
9   -- -----------------------------------------------------
10   g_wp_option   VARCHAR2(50);
11   g_fp_option   VARCHAR2(50);
12   procedure DELETE
13   (
14     errbuf                    out nocopy varchar2,
15     retcode                   out nocopy varchar2,
16     p_operating_unit          in         number   default null,
17     p_from_project            in         varchar2 default null,
18     p_to_project              in         varchar2 default null,
19     p_fp_option               in         varchar2 default null,
20     p_plan_type               in         number   default null,
21     p_wp_option               in         varchar2 default null,
22     p_rep_only                in         varchar2 default 'Y'
23   )
24 is
25     l_from_project_num         varchar2(25);
26     l_to_project_num           varchar2(25);
27     l_return_status            varchar2(2);
28     l_plan_type_id             number(15);
29     l_rep_only                 varchar2(1);
30     l_from_project_id          number(20);
31     l_to_project_id            number(20);
32 
33     cursor proj is
34     select project_id
35     from pa_projects_all
36     where segment1 between l_from_project_num and l_to_project_num;
37 
38   begin
39 
40     g_retcode := 0;
41     g_from_conc := 'Y';
42 
43     pa_debug.set_process('PLSQL');
44     pa_debug.log_message('=======Concurrent Program Parameters Start =======', 1);
45     pa_debug.log_message('Argument => Operating Unit ['||p_operating_unit||']', 1);
46     pa_debug.log_message('Argument => From Project Number ['||p_from_project||']', 1);
47     pa_debug.log_message('Argument => To Project Number ['||p_to_project||']', 1);
48     pa_debug.log_message('Argument => Delete Financial Plans ['||p_fp_option||']', 1);
49     pa_debug.log_message('Argument => Financial Plan Type ['||p_plan_type||']', 1);
50     pa_debug.log_message('Argument => Delete Workplans ['||p_wp_option||']', 1);
51     pa_debug.log_message('Argument => Reporting Data Only ['||p_rep_only||']', 1);
52     pa_debug.log_message('=======Concurrent Program Parameters End =======', 1);
53 
54       /*Check for minimum imput parameters */
55     if (p_operating_unit is null and p_from_project is null and p_to_project is null) then
56          FND_MESSAGE.SET_NAME('PJI', 'PJI_NO_PARAMETER');
57          dbms_standard.raise_application_error(-20090, FND_MESSAGE.GET);
58     end if;
59 
60     /* User should not be able to run for entire operating unit without specifying some
61        project range */
62     if (p_operating_unit is not null and p_from_project is null and p_to_project is null) then
63          FND_MESSAGE.SET_NAME('PJI', 'PJI_NO_PARAMETER');
64          dbms_standard.raise_application_error(-20090, FND_MESSAGE.GET);
65     end if;
66 
67     if p_from_project > p_to_project then
68          FND_MESSAGE.SET_NAME('PJI', 'PJI_INVALID_RANGE');
69          dbms_standard.raise_application_error(-20091, FND_MESSAGE.GET);
70     end if;
71 
72     IF  p_from_project is not null or p_to_project is not null then
73         select min(segment1) ,max(segment1)
74         into l_from_project_num, l_to_project_num
75         from pa_projects_all
76         where segment1 between nvl(p_from_project,segment1) and nvl(p_to_project,segment1)
77         and decode(p_operating_unit,NULL,org_id,p_operating_unit) = org_id; /* Added for bug 9072943 */
78     END if;
79 
80     /* Plan Type id */
81     if (p_plan_type is not null) then
82         l_plan_type_id := p_plan_type;
83     else
84         l_plan_type_id := 0;
85     end if;
86 
87     /* Reporting Only */
88     if (p_rep_only is not null) then
89         l_rep_only := p_rep_only;
90     else
91         l_rep_only := 'Y';
92     end if;
93 
94     pa_debug.log_message('Validated inputs :', 1);
95     pa_debug.log_message('From Project Num :'||l_from_project_num, 1);
96     pa_debug.log_message('To Project Num :'||l_to_project_num, 1);
97     pa_debug.log_message('Plan Type ID :'||l_plan_type_id, 1);
98     pa_debug.log_message('Reporting Only :'||l_rep_only, 1);
99 
100     g_wp_option := p_wp_option;
101     g_fp_option := p_fp_option;
102 
103     for c1 in proj loop
104 
105         if p_wp_option = 'DEL_NLE_PUB_VER'  then
106             /* Call procedure to delete eligible workplan versions */
107             DELETE_WP(p_project_id     => c1.project_id,
108                       p_rep_only       => l_rep_only,
109                       p_return_status  => l_return_status);
110 
111             if l_return_status = 'S' then
112                COMMIT;
113             end if;
114         end if;
115 
116         if p_fp_option = 'DEL_NC_NO_BSL_VER'  then
117             /* Call procedure to delete eligible financial plan versions */
118             DELETE_FP(p_project_id     => c1.project_id,
119                       p_plan_type_id   => l_plan_type_id,
120                       p_rep_only       => l_rep_only,
121                       p_return_status  => l_return_status);
122 
123             if l_return_status = 'S' then
124                COMMIT;
125             end if;
126         end if;
127 
128     end loop;
129 
130     retcode := g_retcode;
131 
132     PRINT_OUTPUT(p_from_project => l_from_project_num,
133                  p_to_project   => l_to_project_num);
134 
135     exception when others then
136       rollback;
137       IF SQLCODE = -20041 then
138         retcode := 1;
139       ELSE
140         retcode := 2;
141         errbuf := sqlerrm;
142       END IF;
143 
144   end DELETE;
145 
146   -- -----------------------------------------------------
147   -- procedure PRINT_OUTPUT
148   --
149   -- This procedure will generate the output report.
150   -- -----------------------------------------------------
151   procedure PRINT_OUTPUT(p_from_project IN varchar2,
152                          p_to_project   IN varchar2)
153   is
154 
155     l_newline varchar2(10) := '';
156     l_rpt_header varchar2(60);
157     l_proj_number varchar2(30);
158     l_version_name varchar2(30);
159     l_proj_name varchar2(30);
160     l_rpt_footer varchar2(60);
161     l_wp_version  varchar2(60);
162     l_from_proj_num  varchar2(30);
163     l_to_proj_num  varchar2(30);
164 
165     l_temp_proj_num varchar2(30);
166     l_temp_plan_name varchar2(100);
167 
168     cursor proj_wp(p_from_proj varchar2,p_to_proj varchar2) is
169     select pa.segment1 num,wp.name wp_name
170     from pa_projects_all pa, pa_proj_elem_ver_structure wp
171     where pa.segment1 between p_from_proj and p_to_proj
172     and pa.project_id = wp.project_id
173     and wp.purged_flag = 'Y'
174     and wp.conc_request_id = FND_GLOBAL.CONC_REQUEST_ID; /* Modified for bug 9049425 */
175 
176     cursor proj_fp(p_from_proj varchar2,p_to_proj varchar2) is
177     select pa.segment1 num,fp.version_name fp_name
178     from pa_projects_all pa, pa_budget_versions fp
179     where pa.segment1 between p_from_proj and p_to_proj
180     and pa.project_id = fp.project_id
181     and fp.purged_flag = 'Y'
182     and fp.fin_plan_type_id <> 10
183     and fp.request_id = FND_GLOBAL.CONC_REQUEST_ID;  /* Modified for bug 9049425 */
184 
185   begin
186 
187   l_from_proj_num := p_from_project;
188   l_to_proj_num := p_to_project;
189 
190     pa_debug.log_message('======= Print Output ========== :', 1);
191     pa_debug.log_message('From Project Num :'||l_from_proj_num, 1);
192     pa_debug.log_message('To Project Num :'||l_from_proj_num, 1);
193 
194     FND_MESSAGE.SET_NAME('PA', 'PA_CISI_TEXT_DELETE');
195     l_rpt_header := FND_MESSAGE.GET;
196 
197     FND_MESSAGE.SET_NAME('PA', 'PA_XC_REPORT');
198     l_rpt_header := l_rpt_header||' '||FND_MESSAGE.GET;
199 
200         FND_MESSAGE.SET_NAME('PA', 'PA_XC_PROJECT_NUMBER');
201     l_proj_number := FND_MESSAGE.GET;
202 
203         FND_MESSAGE.SET_NAME('PA', 'PA_XC_PROJECT_NAME');
204     l_proj_name := FND_MESSAGE.GET;
205 
206         FND_MESSAGE.SET_NAME('PA', 'PA_PMC_FINANCIAL');
207     l_version_name := FND_MESSAGE.GET;
208 
209         FND_MESSAGE.SET_NAME('PJI', 'PJI_PJP_SUM_PLAN_VER');
210     l_version_name := l_version_name||' '||FND_MESSAGE.GET;
211 
212     FND_MESSAGE.SET_NAME('PJI', 'PJI_PJP_RPT_FOOTER');
213     l_rpt_footer := FND_MESSAGE.GET;
214 
215     FND_MESSAGE.SET_NAME('PA', 'PA_PMC_WORKPLAN_VER');
216     l_wp_version := FND_MESSAGE.GET;
217 
218         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
219                                '-----------------------------------------------------------------------------------------------------------------------------------------' );
220 
221         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
222                                '                                                         '||l_rpt_header);
223         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
224                                '-----------------------------------------------------------------------------------------------------------------------------------------' );
225 
226         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
227                                l_Proj_Number||'             '||l_wp_version );
228         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
229 	                   '======================     =================' );
230 
231         for rec in proj_wp(l_from_proj_num,l_to_proj_num) loop
232           PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||rpad(rec.num,27,' ')||rec.wp_name);
233         END LOOp;
234 
235         IF g_wp_option IS NOT NULL THEN
236           OPEN proj_wp(l_from_proj_num,l_to_proj_num);
237           FETCH proj_wp INTO  l_temp_proj_num, l_temp_plan_name;
238           IF l_temp_proj_num IS NULL THEN
239 
240             PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||'No workplan version found eligible for deleting');
241 
242           END IF;
243           CLOSE proj_wp;
244         END IF;
245         l_temp_proj_num := '';
246         l_temp_plan_name := '';
247 
248 
249         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
250                                '-----------------------------------------------------------------------------------------------------------------------------------------' );
251 
252         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
253                                l_Proj_Number||'             '||l_version_name );
254         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
255 	                   '======================     ======================' );
256 
257         for rec in proj_fp(l_from_proj_num,l_to_proj_num) loop
258           PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||rpad(rec.num,27,' ')||rec.fp_name);
259         END LOOp;
260 
261         IF g_fp_option IS NOT NULL THEN
262           OPEN proj_fp(l_from_proj_num,l_to_proj_num);
263           FETCH proj_fp INTO  l_temp_proj_num, l_temp_plan_name;
264           IF l_temp_proj_num IS NULL THEN
265 
266             PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||'No financial plan found eligible for deleting');
267 
268           END IF;
269           CLOSE proj_fp;
270         END IF;
271         PJI_UTILS.WRITE2OUT(fnd_global.local_chr(10)       ||
272                                '----------------------------------------------------------'||l_rpt_footer||'----------------------------------------------------------');
273 
274     pa_debug.log_message('======= Print Output End ========== :', 1);
275 
276   end PRINT_OUTPUT;
277 
278   -- -----------------------------------------------------
279   -- procedure DELETE_WP
280   --
281   -- This procedure will delete eligible workplan versions.
282   -- -----------------------------------------------------
283   procedure DELETE_WP(p_project_id IN number,
284                       p_rep_only   IN varchar2,
285                       p_return_status OUT nocopy varchar2) is
286 
287   l_api_version_number          NUMBER(10,3) := 1.0; -- API Version
288   l_return_status               VARCHAR2(1);
289   l_init_msg_list               VARCHAR2(1) := 'T';
290   l_msg_count                   NUMBER(20);
291   l_msg_index_out               NUMBER(10);
292   l_msg_data                    VARCHAR2(2000);
293   l_data                        VARCHAR2(2000);
294 
295   API_ERROR                     EXCEPTION;
296 
297   l_project_id                  NUMBER(15);
298   l_budget_version_id           number(20);
299   l_structure_version_id_tbl    SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
300   l_record_version_number_tbl   SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
301 
302   -- Bug 13908783
303   CURSOR c1 IS
304   select element_version_id, record_version_number
305   from pa_proj_elem_ver_structure struct_ver
306   where project_id = l_project_id
307   and status_code = 'STRUCTURE_PUBLISHED'
308   and current_flag <> 'Y'
309   and original_flag <> 'Y'
310   and nvl(purged_flag,'N') <> 'Y'
311   and latest_eff_published_flag <> 'Y'
312   and NOT EXISTS (
313         SELECT por.object_relationship_id
314         FROM pa_object_relationships por,
315          pa_proj_element_versions ppev
316         WHERE por.object_id_from1 = ppev.element_version_id
317         AND por.relationship_type in ('LW', 'LF')
318         AND ppev.parent_structure_version_id = struct_ver.element_version_id
319         UNION ALL
320         SELECT por. object_relationship_id
321         FROM pa_object_relationships por,
322          pa_proj_element_versions ppev
323         WHERE por.object_id_to1 = ppev.element_version_id
324         AND por.relationship_type in ('LW', 'LF')
325         AND ppev.parent_structure_version_id = struct_ver.element_version_id);
326    -- End Bug 13908783
327 
328   BEGIN
329 
330   pa_debug.log_message('=======Delete Workplans Start =======', 1);
331   pa_debug.log_message('Project ID :'||p_project_id, 1);
332   pa_debug.log_message('Reporting Only :'||p_rep_only, 1);
333 
334   l_project_id := p_project_id;
335 
336   -- Delete only reporting data only
337   if p_rep_only = 'Y' then
338      pa_debug.log_message('** Delete only Reporting Data **', 1);
339 
340      for rec1 in c1 loop
341 
342          begin
343 
344               select budget_version_id
345               into l_budget_version_id
346               from pa_budget_versions
347               where project_id = l_project_id
348               and fin_plan_type_id = 10
349               and project_structure_version_id = rec1.element_version_id;
350 
351               pa_debug.log_message('To Delete Plan Version id :'||l_budget_version_id, 1);
352 
353               delete from pji_fp_xbs_accum_f
354               where project_id = l_project_id
355               and plan_type_id = 10
356               and plan_version_id = l_budget_version_id;
357 
358               pa_debug.log_message('Records deleted :'||sql%rowcount, 1);
359 
360          exception
361               when no_data_found then
362                    null;
363               when others then
364                    --DBMS_OUTPUT.PUT_LINE('An error occurred, sqlcode = ' || sqlcode);
365                    rollback;
366                    raise_application_error(-20002, 'ORACLE error: '||sqlerrm);
367          end;
368 
369      end loop;
370 
371   else /* else of Delete only reporting data only */
372 
373    -- Fetching all the Published Workplan Version except Latest Pubished,
374    -- Original Baseline and Current Working Versions.
375    FOR rec IN c1 LOOP
376    		 l_structure_version_id_tbl.extend(1);
377    		 l_record_version_number_tbl.extend(1);
378    		 l_structure_version_id_tbl(l_structure_version_id_tbl.count)   := rec.element_version_id;
379    		 l_record_version_number_tbl(l_record_version_number_tbl.count) := rec.record_version_number;
380    END LOOP;
381 
382    if l_structure_version_id_tbl.count >0 then
383    -- Calling DELETE_PUBLISHED_STRUCTURE_VER API
384    pa_debug.log_message('Calling Delete API for workplans', 1);
385    PA_PROJECT_STRUCTURE_PUB1.DELETE_PUBLISHED_STRUCTURE_VER
386    ( p_api_version                => l_api_version_number
387     ,p_init_msg_list              => l_init_msg_list
388     ,p_project_id                 => l_project_id
389     ,p_structure_version_id_tbl   => l_structure_version_id_tbl
390     ,p_record_version_number_tbl  => l_record_version_number_tbl
391     ,x_return_status              => l_return_status
392     ,x_msg_count                  => l_msg_count
393     ,x_msg_data                   => l_msg_data
394    );
395     -- Bug 13908783
396     IF l_return_status <> 'S' THEN
397       If l_msg_data IS NULL THEN
398         FND_MSG_PUB.Count_And_Get
399         ( p_encoded => 'F',
400           p_count               =>      l_msg_count,
401           p_data                =>      l_msg_data
402         );
403        end if;
404       pa_debug.Log_Message( p_message => l_msg_data, p_write_mode => 1, p_write_file => 'LOG');
405       pa_debug.Log_Message( p_message => l_msg_data,  p_write_mode => 1, p_write_file => 'OUT');
406     END IF;
407     -- End Bug 13908783
408 
409    else
410      pa_debug.log_message('No workplan versions found eligible for deleting', 1);
411    end if;
412 
413 end if; /* else of Delete only reporting data only */
414 
415    pa_debug.log_message('Done deleting workplans', 1);
416    pa_debug.log_message('Return status :'||l_return_status, 1);
417 
418    IF l_return_status <> 'S' THEN
419     raise API_ERROR;
420    END IF;
421 
422    p_return_status := l_return_status;
423    pa_debug.log_message('=======Delete Workplans End =======', 1);
424 
425   EXCEPTION
426      WHEN NO_DATA_FOUND then
427         NULL;
428      When OTHERS then
429         --DBMS_OUTPUT.PUT_LINE('An error occurred, sqlcode = ' || sqlcode);
430         if l_msg_count >= 1 then
431           for i in 1..l_msg_count loop
432             pa_interface_utils_pub.get_messages(
433                     p_msg_count     => l_msg_count,
434                     p_encoded       => 'F',
435                     p_msg_data      => l_msg_data,
436                     p_data          => l_data,
437                     p_msg_index_out => l_msg_index_out);
438             --DBMS_OUTPUT.PUT_LINE('error message: ' || l_data);
439           end loop;
440           rollback;
441         end if;
442         raise_application_error(-20002, 'ORACLE error: '||sqlerrm);
443 
444   END DELETE_WP;
445 
446   -- -----------------------------------------------------
447   -- procedure DELETE_FP
448   --
449   -- This procedure will delete eligible financial plan
450   -- versions.
451   -- -----------------------------------------------------
452   procedure DELETE_FP(p_project_id IN number,
453                       p_plan_type_id IN number,
454                       p_rep_only   IN varchar2,
455                       p_return_status OUT nocopy varchar2) is
456 
457   l_return_status               VARCHAR2(1);
458   l_init_msg_list               VARCHAR2(1) := 'T';
459   l_msg_count                   NUMBER(20);
460   l_msg_index_out               NUMBER(10);
461   l_msg_data                    VARCHAR2(2000);
462   l_data                        VARCHAR2(2000);
463 
464   API_ERROR                     EXCEPTION;
465 
466   l_project_id                  NUMBER(15);
467   l_plan_type_id                number(15);
468   -- Fetching the Baselined Versions eligible for deletion
469   CURSOR c1 IS
470   SELECT budget_version_id,record_version_number
471   FROM pa_budget_versions
472   WHERE project_id = l_project_id
473   AND fin_plan_type_id <> 10
474   AND budget_status_code = 'B'
475   AND current_flag <> 'Y'
476   AND current_original_flag <> 'Y'
477   and nvl(purged_flag,'N') <> 'Y';
478 
479   CURSOR c2 IS
480   SELECT budget_version_id,record_version_number
481   FROM pa_budget_versions
482   WHERE project_id = l_project_id
483   AND fin_plan_type_id = l_plan_type_id
484   AND budget_status_code = 'B'
485   AND current_flag <> 'Y'
486   AND current_original_flag <> 'Y'
487   and nvl(purged_flag,'N') <> 'Y';
488 
489   BEGIN
490 
491   pa_debug.log_message('=======Delete Financial Plans Start =======', 1);
492   pa_debug.log_message('Project ID :'||p_project_id, 1);
493   pa_debug.log_message('Plan Type ID :'||p_plan_type_id, 1);
494 
495   l_project_id := p_project_id;
496   l_plan_type_id := p_plan_type_id;
497 
498   if (p_plan_type_id <> 0) then
499 
500        pa_debug.log_message('Plan Type ID is passed', 1);
501        FOR rec IN c2 LOOP
502 
503         if p_rep_only = 'Y' then
504             pa_debug.log_message('** Delete only Reporting Data **', 1);
505 
506             begin
507               pa_debug.log_message('To Delete Plan Version id :'||rec.budget_version_id, 1);
508 
509               delete from pji_fp_xbs_accum_f
510               where project_id = l_project_id
511               and plan_version_id = rec.budget_version_id;
512 
513               pa_debug.log_message('Records deleted :'||sql%rowcount, 1);
514 
515            exception
516                 when no_data_found then
517                      null;
518                 when others then
519                      --DBMS_OUTPUT.PUT_LINE('An error occurred, sqlcode = ' || sqlcode);
520                      rollback;
521                      raise_application_error(-20002, 'ORACLE error: '||sqlerrm);
522            end;
523 
524         else
525             pa_debug.log_message('To Delete Plan Version id :'||rec.budget_version_id, 1);
526             pa_fin_plan_pub.Delete_Version
527               (p_project_id              => l_project_id,
528                p_budget_version_id       => rec.budget_version_id,
529                p_record_version_number   => rec.record_version_number,
530                x_return_status           => l_return_status,
531                x_msg_count               => l_msg_count,
532                x_msg_data                => l_msg_data);
533             -- Bug 13908783
534            IF l_return_status <> 'S' THEN
535              If l_msg_data IS NULL THEN
536                FND_MSG_PUB.Count_And_Get
537                ( p_encoded => 'F',
538                  p_count               =>      l_msg_count,
539                  p_data                =>      l_msg_data
540                );
541              end if;
542              pa_debug.Log_Message( p_message => l_msg_data, p_write_mode => 1, p_write_file => 'LOG');
543              pa_debug.Log_Message( p_message => l_msg_data,  p_write_mode => 1, p_write_file => 'OUT');
544            END IF;
545            -- End Bug 13908783
546 
547        end if;
548 
549        END LOOP;
550 
551        IF l_return_status <> 'S' THEN
552         raise API_ERROR;
553        END IF;
554 
555        pa_debug.log_message('Done deleting Financial Plans', 1);
556        pa_debug.log_message('Return status :'||l_return_status, 1);
557 
558        p_return_status := l_return_status;
559        pa_debug.log_message('=======Delete Financial Plans End =======', 1);
560 
561   else
562 
563        pa_debug.log_message('Plan Type ID is not passed', 1);
564        FOR rec IN c1 LOOP
565 
566         if p_rep_only = 'Y' then
567             pa_debug.log_message('** Delete only Reporting Data **', 1);
568 
569             begin
570               pa_debug.log_message('To Delete Plan Version id :'||rec.budget_version_id, 1);
571 
572               delete from pji_fp_xbs_accum_f
573               where project_id = l_project_id
574               and plan_version_id = rec.budget_version_id;
575 
576               pa_debug.log_message('Records deleted :'||sql%rowcount, 1);
577 
578            exception
579                 when no_data_found then
580                      null;
581                 when others then
582                      --DBMS_OUTPUT.PUT_LINE('An error occurred, sqlcode = ' || sqlcode);
583                      rollback;
584                      raise_application_error(-20002, 'ORACLE error: '||sqlerrm);
585            end;
586 
587         else
588             pa_debug.log_message('To Delete Plan Version id :'||rec.budget_version_id, 1);
589             pa_fin_plan_pub.Delete_Version
590               (p_project_id              => l_project_id,
591                p_budget_version_id       => rec.budget_version_id,
592                p_record_version_number   => rec.record_version_number,
593                x_return_status           => l_return_status,
594                x_msg_count               => l_msg_count,
595                x_msg_data                => l_msg_data);
596        end if;
597 
598        END LOOP;
599 
600        IF l_return_status <> 'S' THEN
601         raise API_ERROR;
602        END IF;
603 
604        pa_debug.log_message('Done deleting Financial Plans', 1);
605        pa_debug.log_message('Return status :'||l_return_status, 1);
606 
607        p_return_status := l_return_status;
608        pa_debug.log_message('=======Delete Financial Plans End =======', 1);
609 
610   end if;
611 
612   EXCEPTION
613      WHEN NO_DATA_FOUND then
614         NULL;
615      When OTHERS then
616         --DBMS_OUTPUT.PUT_LINE('An error occurred, sqlcode = ' || sqlcode);
617         if l_msg_count >= 1 then
618           for i in 1..l_msg_count loop
619             pa_interface_utils_pub.get_messages(
620                     p_msg_count     => l_msg_count,
621                     p_encoded       => 'F',
622                     p_msg_data      => l_msg_data,
623                     p_data          => l_data,
624                     p_msg_index_out => l_msg_index_out);
625             --DBMS_OUTPUT.PUT_LINE('error message: ' || l_data);
626           end loop;
627           rollback;
628         end if;
629         raise_application_error(-20002, 'ORACLE error: '||sqlerrm);
630 
631   END DELETE_FP;
632 
633 end PJI_PA_DEL_MAIN;