DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSTPDPPC

Source


1 PACKAGE BODY CSTPDPPC AS
2 /* $Header: CSTDPPCB.pls 115.10 2002/11/08 03:19:45 awwang ship $ */
3 
4 /*============================================================================+
5 | This function of this procedure is to run the requested procedure using     |
6 | Dynamic SQL. The input parameter i_proc_name is the name of the procedure   |
7 | to be run dynamically. The input parameters to the procedure to be run are  |
8 | populated in the l_parameters dynamic PL/SQL table, and then the procedure  |
9 | run_dyn_proc is called to execute the procedure.                            |
10 |============================================================================*/
11 
12 PROCEDURE set_phase_status (
13 	i_cost_group_id		IN		NUMBER,
14 	i_period_id		IN		NUMBER,
15 	i_status		IN		NUMBER,
16         i_user_id               IN		NUMBER,
17         i_login_id              IN		NUMBER,
18         i_prog_appl_id          IN		NUMBER,
19         i_prog_id               IN		NUMBER,
20 	i_request_id		IN		NUMBER
21 )
22 IS
23 BEGIN
24 	UPDATE
25 	cst_pac_process_phases
26 	SET
27 	process_status = i_status,
28         process_date = SYSDATE,
29         process_upto_date = (select decode(i_status,4,process_upto_date,NULL)
30                            from cst_pac_process_phases
31                            where process_phase = 5
32                            and cost_group_id = i_cost_group_id
33                            and pac_period_id = i_period_id),
34         last_update_date = SYSDATE,
35         last_updated_by = nvl(i_user_id,-1),
36         request_id = i_request_id,
37         program_application_id = i_prog_appl_id,
38         program_id = i_prog_id,
39         program_update_date = SYSDATE,
40         last_update_login = i_login_id
41         WHERE pac_period_id = i_period_id
42         AND cost_group_id = i_cost_group_id
43         AND process_phase = 6;
44 
45 	COMMIT;
46 END set_phase_status;
47 
48 
49 PROCEDURE dyn_proc_call (
50 	i_proc_name		IN		VARCHAR2,
51 	i_acct_lib_id		IN		NUMBER,
52 	i_legal_entity		IN		NUMBER,
53 	i_cost_type		IN		NUMBER,
54 	i_cost_group		IN		NUMBER,
55 	i_period_id		IN		NUMBER,
56 	i_mode			IN		NUMBER,
57 	o_err_num		OUT NOCOPY		NUMBER,
58 	o_err_code		OUT NOCOPY		VARCHAR2,
59 	o_err_msg		OUT NOCOPY		VARCHAR2
60 )
61 IS
62 --  l_parameters    	cst_ae_lib_par_tbl_type := cst_ae_lib_par_tbl_type();
63   l_sql_to_run  	VARCHAR2(500);
64   --l_num_params		NUMBER;
65   l_err			NUMBER;
66   l_stmt_num		NUMBER;
67   CST_PKG_FAIL		EXCEPTION;
68   CST_PKG_FAIL2		EXCEPTION;
69 BEGIN
70   ---------------------------------------------------------------------------
71   -- First set the number of parameters. Then populate the l_parameters array
72   -- with the input parameters
73   -- datatype codes are as follows :
74   -- 1 = varchar2
75   -- 2 = number
76   -- inout variable is set to 0 for in, 1 for in out, and 2 for out
77   --------------------------------------------------------------------------
78 /*-------------------------------------------------------------------------
79   l_num_params 				:= 8;
80   l_parameters.extend(l_num_params);
81 
82   l_parameters(1).i_name 		:= 'I_ACCT_LIB_ID';
83   l_parameters(1).i_num_value 		:= I_ACCT_LIB_ID;
84   l_parameters(1).i_datatype 		:= 2;
85   l_parameters(1).i_inout 		:= 0;
86 
87   l_parameters(2).i_name 		:= 'I_LEGAL_ENTITY';
88   l_parameters(2).i_num_value 		:= I_LEGAL_ENTITY;
89   l_parameters(2).i_datatype 		:= 2;
90   l_parameters(2).i_inout 		:= 0;
91 
92   l_parameters(3).i_name 		:= 'I_COST_TYPE_ID';
93   l_parameters(3).i_num_value 		:= I_COST_TYPE;
94   l_parameters(3).i_datatype 		:= 2;
95   l_parameters(3).i_inout 		:= 0;
96 
97   l_parameters(4).i_name 		:= 'I_COST_GROUP_ID';
98   l_parameters(4).i_num_value 		:= I_COST_GROUP;
99   l_parameters(4).i_datatype 		:= 2;
100   l_parameters(4).i_inout 		:= 0;
101 
102   l_parameters(5).i_name 		:= 'I_PERIOD_ID';
103   l_parameters(5).i_num_value 		:= I_PERIOD_ID;
104   l_parameters(5).i_datatype 		:= 2;
105   l_parameters(5).i_inout 		:= 0;
106 
107   l_parameters(6).i_name 		:= 'O_ERR_NUM';
108   l_parameters(6).i_datatype 		:= 2;
109   l_parameters(6).i_inout 		:= 2;
110 
111   l_parameters(7).i_name 		:= 'O_ERR_CODE';
112   l_parameters(7).i_datatype 		:= 1;
113   l_parameters(7).i_inout 		:= 2;
114 
115   l_parameters(8).i_name 		:= 'O_ERR_MSG';
116   l_parameters(8).i_datatype 		:= 1;
117   l_parameters(8).i_inout 		:= 2;
118 
119   --------------------------------------------------------------------------
120   -- call run_dyn_proc with the inpute parameters populated in l_parameters
121   --------------------------------------------------------------------------
122 
123   run_dyn_proc(
124 	l_num_params,
125 	i_proc_name,
126 	l_parameters,
127 	l_err);
128 ---------------------------------------------------------------------------*/
129 
130   l_sql_to_run := 'BEGIN ' || i_proc_name || '(';
131   l_sql_to_run := l_sql_to_run || ':I_ACCT_LIB_ID';
132   l_sql_to_run := l_sql_to_run || ', :I_LEGAL_ENTITY';
133   l_sql_to_run := l_sql_to_run || ', :I_COST_TYPE_ID';
134   l_sql_to_run := l_sql_to_run || ', :I_COST_GROUP_ID';
135   l_sql_to_run := l_sql_to_run || ', :I_PERIOD_ID';
136   l_sql_to_run := l_sql_to_run || ', :I_MODE';
137   l_sql_to_run := l_sql_to_run || ', :O_ERR_NUM';
138   l_sql_to_run := l_sql_to_run || ', :O_ERR_CODE';
139   l_sql_to_run := l_sql_to_run || ', :O_ERR_MSG';
140   l_sql_to_run := l_sql_to_run || '); END;';
141 
142   l_stmt_num := 10;
143 
144   EXECUTE IMMEDIATE l_sql_to_run USING
145 			I_ACCT_LIB_ID,
146 			I_LEGAL_ENTITY,
147 			I_COST_TYPE,
148 			I_COST_GROUP,
149 			I_PERIOD_ID,
150 			I_MODE,
151 			OUT O_ERR_NUM,
152 			OUT O_ERR_CODE,
153 			OUT O_ERR_MSG;
154   -------------------------------------------------------------------------
155   -- l_parameters(6) is l_err_num
156   -------------------------------------------------------------------------
157 
158   IF (o_err_num <> 0 and o_err_num is not null) THEN
159     RAISE CST_PKG_FAIL;
160   END IF;
161 
162   IF (l_err <> 0) THEN
163     RAISE CST_PKG_FAIL2;
164   END IF;
165 
166 EXCEPTION
167   WHEN CST_PKG_FAIL THEN
168   fnd_file.put_line(fnd_file.log,'CSTPDPPC.dyn_proc_call : Error Calling Package');
169   WHEN CST_PKG_FAIL2 THEN
170         o_err_num := l_err;
171         o_err_code := SQLCODE;
172         o_err_msg :=  'CSTPDPPC.dyn_proc_call : Error Calling Package';
173   WHEN OTHERS THEN
174         o_err_num := 30000;
175         o_err_code := SQLCODE;
176   	o_err_msg := 'CSTPDPPC.dyn_proc_call : ' || to_char(l_stmt_num) || ':'|| substr(SQLERRM,1,180);
177 END dyn_proc_call;
178 
179 /*============================================================================+
180 | This function of this procedure is to actually execute the requested        |
181 | procedureQL. The input parameter i_proc_name is the name of the procedure   |
182 | to be run dynamically. The input parameters to the procedure to be run are  |
183 | populated in the l_parameters dynamic PL/SQL table, and then the procedure  |
184 | run_dyn_proc is called to execute the procedure.                            |
185 |============================================================================*/
186 /*------------------------------------------------------
187 PROCEDURE run_dyn_proc ( (
188 	i_num_params    	IN      	NUMBER,
189 	i_proc_name     	IN      	VARCHAR2,
190 	io_parameters   	IN OUT  	CST_AE_LIB_PAR_TBL_TYPE,
191 	o_err			OUT		NUMBER
192 ) IS
193   l_cursor      	NUMBER;
194   l_err         	NUMBER 		:= 0;
195   l_sql_to_run  	VARCHAR2(500);
196   l_stmt_num		NUMBER;
197   cst_invalid_type_error EXCEPTION;
198 BEGIN
199   l_sql_to_run := 'BEGIN ' || i_proc_name || '(';
200 
201   FOR i IN 1..i_num_params LOOP
202     IF ( i = 1) THEN
203       l_sql_to_run := l_sql_to_run || ':' || io_parameters(i).i_name;
204     ELSE
205       l_sql_to_run := l_sql_to_run || ', :' || io_parameters(i).i_name;
206     END IF;
207   END LOOP;
208 
209   l_sql_to_run := l_sql_to_run || '); END;';
210 
211   l_stmt_num := 10;
212 
213   EXECUTE IMMEDIATE l_sql_to_run USING
214 			io_parameters(1).i_num_value,
215 			io_parameters(2).i_num_value,
216 			io_parameters(3).i_num_value,
217 			io_parameters(4).i_num_value,
218 			io_parameters(5).i_num_value,
219 			OUT io_parameters(6).i_num_value,
220 			OUT io_parameters(7).i_vchar_value,
221 			OUT io_parameters(8).i_vchar_value;
222 
223   l_cursor := DBMS_SQL.OPEN_CURSOR;
224   DBMS_SQL.PARSE(l_cursor,l_sql_to_run,DBMS_SQL.V7);
225 
226   FOR i IN 1..i_num_params LOOP
227       IF (io_parameters(i).i_datatype = 2) THEN
228         dbms_sql.bind_variable(l_cursor,io_parameters(i).i_name,io_parameters(i).i_num_value);
229       ELSIF (io_parameters(i).i_datatype = 1) THEN
230         dbms_sql.bind_variable(l_cursor,io_parameters(i).i_name,io_parameters(i).i_vchar_value ,500);
231       ELSIF (io_parameters(i).i_datatype = 12) THEN
232         dbms_sql.bind_variable(l_cursor,io_parameters(i).i_name,io_parameters(i).i_date_value) ;
233       ELSIF (io_parameters(i).i_datatype = 96) THEN
234         dbms_sql.bind_variable(l_cursor,io_parameters(i).i_name,io_parameters(i).i_char_value) ;
235       ELSE
236        RAISE cst_invalid_type_error;
237       END IF;
238   END LOOP;
239   l_stmt_num := 20;
240   l_err := DBMS_SQL.EXECUTE(l_cursor);
241 
242   FOR i IN 1..i_num_params LOOP
243     IF (io_parameters(i).i_inout in (1,2)) THEN
244         IF (io_parameters(i).i_datatype = 2) THEN
245           DBMS_SQL.VARIABLE_VALUE(l_cursor,':' || io_parameters(i).i_name,io_parameters(i).i_num_value);
246         ELSIF (io_parameters(i).i_datatype = 1) THEN
247           DBMS_SQL.VARIABLE_VALUE(l_cursor,':' || io_parameters(i).i_name,io_parameters(i).i_vchar_value);
248         ELSIF (io_parameters(i).i_datatype = 12) THEN
249           DBMS_SQL.VARIABLE_VALUE(l_cursor,':' || io_parameters(i).i_name,io_parameters(i).i_date_value);
250         ELSIF (io_parameters(i).i_datatype = 96) THEN
251           DBMS_SQL.VARIABLE_VALUE(l_cursor,':' || io_parameters(i).i_name,io_parameters(i).i_char_value);
252         ELSE
253           RAISE cst_invalid_type_error;
254         END IF;
255     END IF;
256   END LOOP;
257 
258 EXCEPTION
259 WHEN CST_INVALID_TYPE_ERROR THEN
260 	o_err := -1;
261 WHEN OTHERS THEN
262 	o_err := -2;
263 
264 END run_dyn_proc;
265 -----------------------------------------------------*/
266 
267 PROCEDURE dist_processor_main (
268 	errbuf     		OUT NOCOPY	VARCHAR2,
269 	retcode    		OUT NOCOPY	NUMBER,
270 	i_legal_entity		IN	NUMBER ,
271 	i_cost_type_id		IN	NUMBER ,
272 	i_cost_group_id		IN	NUMBER ,
273 	i_period_id		IN	NUMBER ,
274 	i_mode			IN	NUMBER DEFAULT 0
275 ) IS
276 	l_le_exists     	NUMBER;
277 	l_ct_exists     	NUMBER;
278 	l_cg_exists     	NUMBER;
279 	l_per_exists    	NUMBER;
280 	l_acct_lib_exists    	NUMBER;
281 	l_acct_lib_id		NUMBER;
282 	l_lib_name		VARCHAR2(100);
283 	l_stmt_num		NUMBER;
284 	l_running_period	NUMBER;
285 	cst_no_acct_lib_error 	EXCEPTION;
286 	l_request_id		NUMBER;
287 	l_user_id		NUMBER;
288 	l_login_id		NUMBER;
289 	l_prog_appl_id		NUMBER;
290 	l_prog_id		NUMBER;
291 	l_err_num		NUMBER;
292 	l_err_code		VARCHAR2(240);
293 	l_err_msg		VARCHAR2(240);
294 	CONC_STATUS		BOOLEAN;
295 	CST_NO_LE      		EXCEPTION;
296 	CST_NO_CT      		EXCEPTION;
297 	CST_NO_CG      		EXCEPTION;
298 	CST_NO_PER     		EXCEPTION;
299 	CST_LIB_CALL_FAIL	EXCEPTION;
300 	CST_PURGE_FAIL     	EXCEPTION;
301 	CST_NO_DIST_PER		EXCEPTION;
302 	CST_ALREADY_RUNNING	EXCEPTION;
303 BEGIN
304 
305   l_request_id          := FND_GLOBAL.conc_request_id;
306   l_user_id             := FND_GLOBAL.user_id;
307   l_login_id            := FND_GLOBAL.login_id;
308   l_prog_appl_id        := FND_GLOBAL.prog_appl_id;
309   l_prog_id             := FND_GLOBAL.conc_program_id;
310 
311   fnd_file.put_line(fnd_file.log,'Legal Entity : '||to_char(i_legal_entity));
312   fnd_file.put_line(fnd_file.log,'Cost Type : '||to_char(i_cost_type_id));
313   fnd_file.put_line(fnd_file.log,'Cost Group : '||to_char(i_cost_group_id));
314   fnd_file.put_line(fnd_file.log,'Period : '||to_char(i_period_id));
315 
316   SELECT
317   count(*)
318   INTO
319   l_le_exists
320   FROM
321   cst_le_cost_types
322   WHERE
323   legal_entity = i_legal_entity AND
324   create_acct_entries ='Y';
325 
326   IF (l_le_exists = 0) THEN
327     RAISE CST_NO_LE;
328   END IF;
329 
330   l_stmt_num := 20;
331 
332   SELECT
333   count(*)
334   INTO
335   l_ct_exists
336   FROM
337   cst_le_cost_types clct, cst_cost_types cct
338   WHERE
339   clct.legal_entity = i_legal_entity AND
340   clct.cost_type_id = i_cost_type_id AND
341   clct.create_acct_entries = 'Y' AND
342   clct.cost_type_id = cct.cost_type_id AND
343   nvl(cct.disable_date, sysdate +1) > sysdate;
344 
345   IF (l_ct_exists = 0) THEN
346     RAISE CST_NO_CT;
347   END IF;
348 
349   l_stmt_num := 30;
350 
351   SELECT
352   count(*)
353   INTO
354   l_cg_exists
355   FROM
356   cst_cost_groups ccg
357   WHERE
358   legal_entity = i_legal_entity AND
359   cost_group_id = i_cost_group_id;
360 
361   IF (l_cg_exists = 0) THEN
362     RAISE CST_NO_CG;
363   END IF;
364 
365   l_stmt_num := 40;
366 
367   IF (i_mode = 0) THEN
368     SELECT
369     count(*)
370     INTO
371     l_per_exists
372     FROM
376     cost_type_id = i_cost_type_id AND
373     cst_pac_periods
374     WHERE
375     legal_entity = i_legal_entity AND
377     pac_period_id = i_period_id AND
378     open_flag = 'Y' AND
379     pac_period_id IN
380         (SELECT
381          DISTINCT pac_period_id
382          FROM
383          cst_pac_process_phases
384          WHERE
385          cost_group_id = i_cost_group_id AND
386          process_phase = 5 AND
387          process_status = 4);
388 
389     IF (l_per_exists = 0) THEN
390       RAISE CST_NO_PER;
391     END IF;
392 
393     SELECT
394     count(*)
395     INTO
396     l_running_period
397     FROM
398     cst_pac_process_phases
399     WHERE
400     pac_period_id = i_period_id AND
401     cost_group_id = i_cost_group_id AND
402     process_phase = 6 AND
403     process_status = 2;
404 
405     IF (l_running_period > 0) THEN
406       RAISE CST_ALREADY_RUNNING;
407     END IF;
408 
409     set_phase_status (
410   	  i_cost_group_id,
411           i_period_id,
412           2,
413           l_user_id,
414           l_login_id,
415           l_prog_appl_id,
416           l_prog_id,
417 	  l_request_id);
418   ELSE
419     SELECT
420     count(*)
421     INTO
422     l_per_exists
423     FROM
424     cst_pac_periods
425     WHERE
426     legal_entity = i_legal_entity AND
427     cost_type_id = i_cost_type_id AND
428     pac_period_id = i_period_id AND
429     open_flag IN ('Y','P') AND
430     pac_period_id IN
431         (SELECT
432          DISTINCT pac_period_id
433          FROM
434          cst_pac_process_phases
435          WHERE
436          cost_group_id = i_cost_group_id AND
437          process_phase = 6 AND
438          process_status = 4);
439 
440     IF (l_per_exists = 0) THEN
441       RAISE CST_NO_DIST_PER;
442     END IF;
443   END IF;
444 
445   SELECT
446   count(*)
447   INTO
448   l_acct_lib_exists
449   FROM
450   cst_le_cost_types clct1,
451   cst_accounting_libraries cal
452   WHERE
453   clct1.legal_entity = i_legal_entity AND
454   clct1.cost_type_id = i_cost_type_id AND
455   clct1.accounting_library_id = cal.accounting_lib_id;
456 
457   IF (l_acct_lib_exists = 0) THEN
458     RAISE CST_NO_ACCT_LIB_ERROR;
459   END IF;
460 
461 
462 
463   IF (i_mode = 0) THEN
464   fnd_file.put_line(fnd_file.log,'Purging Data  ...');
465   CSTPPPUR.purge_distribution_data(
466 			i_period_id,
467 			i_legal_entity,
468 			i_cost_group_id,
469 			l_user_id,
470 			l_login_id,
471 			l_request_id,
472                         l_prog_id,
473                         l_prog_appl_id,
474                         l_err_num,
475                         l_err_code,
476                         l_err_msg );
477 
478   IF (l_err_num <> 0 and l_err_num is not null) THEN
479     RAISE CST_PURGE_FAIL;
480   END IF;
481   END IF;
482 
483   SELECT
484   accounting_library_id,
485   lib_pkg_name
486   INTO
487   l_acct_lib_id,
488   l_lib_name
489   FROM
490   cst_le_cost_types clct,
491   cst_accounting_libraries cal
492   WHERE clct.accounting_library_id = cal.ACCOUNTING_LIB_ID AND
493   clct.legal_entity = i_legal_entity AND
494   clct.cost_type_id = i_cost_type_id;
495 
496   fnd_file.put_line(fnd_file.log,'Calling Accounting Library ...');
497 
498   dyn_proc_call(
499 	l_lib_name,
500 	l_acct_lib_id,
501 	i_legal_entity,
502 	i_cost_type_id   ,
503 	i_cost_group_id  ,
504 	i_period_id   ,
505 	i_mode,
506 	l_err_num     ,
507 	l_err_code    ,
508 	l_err_msg
509 );
510 
511 
512   IF (l_err_num <> 0 and l_err_num is not null) THEN
513     RAISE CST_LIB_CALL_FAIL;
514   END IF;
515 
516   IF (i_mode = 0) THEN
517   set_phase_status (
518                 i_cost_group_id,
519                 i_period_id,
520                 4,
521                 l_user_id,
522                 l_login_id,
523                 l_prog_appl_id,
524                 l_prog_id,
525                 l_request_id);
526   else
527     retcode := 0;
528   END IF;
529 
530 
531 
532 EXCEPTION
533   WHEN CST_NO_ACCT_LIB_ERROR THEN
534   	l_err_num := 30000;
535   	l_err_code := SQLCODE;
536         FND_MESSAGE.set_name('BOM', 'CST_PAC_INVALID_ACCT_LIB');
537         l_err_msg := FND_MESSAGE.Get;
538   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
539 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
540 	fnd_file.put_line(fnd_file.log,l_err_msg);
541         IF (i_mode = 0) THEN
542 	set_phase_status (
543         	i_cost_group_id,
544         	i_period_id,
545         	3,
546         	l_user_id,
547         	l_login_id,
548         	l_prog_appl_id,
549         	l_prog_id,
550 		l_request_id);
551         ELSE
552           retcode := l_err_num;
553         END IF;
554 
555   WHEN CST_NO_LE THEN
556         l_err_num := 30001;
557         l_err_code := SQLCODE;
558         FND_MESSAGE.set_name('BOM', 'CST_PAC_INVALID_LE');
559         l_err_msg := FND_MESSAGE.Get;
560   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
561 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
562 	fnd_file.put_line(fnd_file.log,l_err_msg);
563 	if (i_mode <> 0) THEN
564 	  retcode := l_err_num;
565     	end if;
566   WHEN CST_ALREADY_RUNNING THEN
567         l_err_num := 30007;
568         l_err_code := SQLCODE;
569   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):Processor already running for the Legal Entity, Cost Group, Cost Type and Period';
570 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
571 	fnd_file.put_line(fnd_file.log,l_err_msg);
572 	if (i_mode <> 0) THEN
573 	  retcode := l_err_num;
574     	end if;
575   WHEN CST_NO_CT THEN
576         l_err_num := 30002;
577         l_err_code := SQLCODE;
578         FND_MESSAGE.set_name('BOM', 'CST_PAC_INVALID_CT');
579         l_err_msg := FND_MESSAGE.Get;
580   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
581 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
582 	fnd_file.put_line(fnd_file.log,l_err_msg);
583         if (i_mode <> 0) THEN
584           retcode := l_err_num;
585         end if;
586   WHEN CST_NO_CG THEN
587         l_err_num := 30003;
588         l_err_code := SQLCODE;
589         FND_MESSAGE.set_name('BOM', 'CST_PAC_CG_INVALID');
590         l_err_msg := FND_MESSAGE.Get;
591   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
592 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
593 	fnd_file.put_line(fnd_file.log,l_err_msg);
594 	if (i_mode <> 0) THEN
595 	  retcode := l_err_num;
596     	end if;
597   WHEN CST_NO_PER THEN
598         l_err_num := 30004;
599         l_err_code := SQLCODE;
600         FND_MESSAGE.set_name('BOM', 'CST_PAC_INVALID_PER');
601         l_err_msg := FND_MESSAGE.Get;
602   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
603 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
604 	fnd_file.put_line(fnd_file.log,l_err_msg);
605 	if (i_mode <> 0) THEN
606 	  retcode := l_err_num;
607     	end if;
608   WHEN CST_NO_DIST_PER THEN
609         l_err_num := 30005;
610         l_err_code := SQLCODE;
611         FND_MESSAGE.set_name('BOM', 'CST_PAC_INVALID_DIST_PER');
612         l_err_msg := FND_MESSAGE.Get;
613   	l_err_msg := 'CSTPDPPC.dist_processor_main : (' || to_char(l_err_num) || '):'|| l_err_code ||' : '||l_err_msg;
614 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
615 	fnd_file.put_line(fnd_file.log,l_err_msg);
616 	if (i_mode <> 0) THEN
617 	  retcode := l_err_num;
618     	end if;
619   WHEN CST_LIB_CALL_FAIL THEN
620         l_err_num := l_err_num;
621         l_err_code := l_err_code;
622         l_err_msg :=  l_err_msg;
623 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
624 	fnd_file.put_line(fnd_file.log,l_err_msg);
625         IF (i_mode = 0) THEN
626 	set_phase_status (
627         	i_cost_group_id,
628         	i_period_id,
629         	3,
630         	l_user_id,
631         	l_login_id,
632         	l_prog_appl_id,
633         	l_prog_id,
634 		l_request_id);
635 	else
636 	  retcode := l_err_num;
637         END IF;
638 
639   WHEN CST_PURGE_FAIL THEN
640         l_err_num := l_err_num;
641         l_err_code := l_err_code;
642         l_err_msg :=  l_err_msg;
643 	CONC_STATUS := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR',l_err_msg);
644 	fnd_file.put_line(fnd_file.log,l_err_msg);
645         IF (i_mode = 0) THEN
646 	set_phase_status (
647         	i_cost_group_id,
648         	i_period_id,
649         	3,
650         	l_user_id,
651         	l_login_id,
652         	l_prog_appl_id,
653         	l_prog_id,
654 		l_request_id);
655 	else
656 	  retcode := l_err_num;
657         END IF;
658 
659   WHEN OTHERS THEN
660         l_err_num := 30006;
661         l_err_code := SQLCODE;
662   	l_err_msg := 'CSTPDPPC.dist_processor_main : ' || to_char(l_stmt_num) || ':'|| substr(SQLERRM,1,180);
663         IF (i_mode = 0) THEN
664 	set_phase_status (
665         	i_cost_group_id,
666         	i_period_id,
667         	3,
668         	l_user_id,
669         	l_login_id,
670         	l_prog_appl_id,
671         	l_prog_id,
672 		l_request_id);
673 	else
674 	  retcode := l_err_num;
675         END IF;
676 
677 
678 END dist_processor_main;
679 
680 
681 
682 END CSTPDPPC;
683