DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSTPPCIT

Source


1 PACKAGE BODY CSTPPCIT AS
2 /* $Header: CSTPCITB.pls 115.4 2002/11/09 00:40:41 awwang ship $ */
3 
4 PROCEDURE periodic_cost_validate (
5   i_org_cost_group_id	    in number,
6   i_cost_type_id            in number,
7   i_transaction_date        in date,
8   i_txn_interface_id        in number,
9   i_org_id		    in number,
10   i_item_id		    in number,
11   i_new_avg_cost	    in number,
12   i_per_change		    in number,
13   i_val_change		    in number,
14   i_mat_accnt		    in number,
15   i_mat_ovhd_accnt	    in number,
16   i_res_accnt		    in number,
17   i_osp_accnt		    in number,
18   i_ovhd_accnt		    in number,
19   o_err_num                 out NOCOPY number,
20   o_err_code		    out NOCOPY varchar2,
21   o_err_msg                 out NOCOPY varchar2
22 ) IS
23   l_err_num                 number;
24   l_err_code                varchar2(240);
25   l_err_msg                 varchar2(240);
26   process_error   	    EXCEPTION;
27   l_count		    number;
28   l_master_org_id	    number;
29   l_legal_entity	    number;
30   l_sob_id		    number;
31   l_chart_account_id	    number;
32   l_period_set_name         varchar2(15);
33   l_period_type             varchar2(15);
34   l_period_id               number;
35   l_open_flag               varchar2(1);
36   l_num_details             number;
37   l_sum_value_change        number;
38   l_sum_new_cost            number;
39   l_stmt_num		    number;
40 
41 BEGIN
42   l_err_num := 0;
43   l_err_code := '';
44   l_err_msg := '';
45 
46   l_stmt_num := 10;
47   /* Validate org_cost_group_id */
48   l_count := 0;
49   SELECT count(*)
50   INTO l_count
51   FROM CST_COST_GROUPS
52   WHERE cost_group_id = i_org_cost_group_id
53     AND TRUNC(NVL(disable_date, sysdate)) >= TRUNC(sysdate)
54     AND cost_group_type = 2;
55 
56   IF (l_count = 0) THEN
57     l_err_num := 999;
58     l_err_code := 'CST_PAC_CG_INVALID';
59     FND_MESSAGE.set_name('BOM', 'CST_PAC_CG_INVALID');
60     l_err_msg := FND_MESSAGE.Get;
61     raise process_error;
62   END IF;
63 
64   l_stmt_num := 20;
65   /* Find the master org id and legal_entity for the cost group */
66   SELECT legal_entity, organization_id
67   INTO l_legal_entity, l_master_org_id
68   FROM CST_COST_GROUPS
69   WHERE cost_group_id = i_org_cost_group_id;
70 
71   l_stmt_num := 30;
72   /* Validate cost_type_id */
73   l_count := 0;
74   SELECT count(*)
75   INTO l_count
76   FROM CST_LE_COST_TYPES
77   WHERE legal_entity = l_legal_entity
78     AND cost_type_id = i_cost_type_id;
79 
80   IF (l_count = 0) THEN
81     l_err_num := 999;
82     l_err_code := 'CST_PAC_CT_INVALID';
83     FND_MESSAGE.set_name('BOM', 'CST_PAC_CT_INVALID');
84     l_err_msg := FND_MESSAGE.Get;
85     raise process_error;
86   END IF;
87 
88   l_stmt_num := 40;
89   /* Get set_of_books_id ,chart_of_accounts_id,
90      period_set_name and chart_of_accounts_id */
91   SELECT gl.set_of_books_id, gl.chart_of_accounts_id,
92          gl.period_set_name, gl.accounted_period_type
93   INTO l_sob_id, l_chart_account_id,
94        l_period_set_name, l_period_type
95   FROM CST_LE_COST_TYPES clct, GL_SETS_OF_BOOKS gl
96   WHERE clct.set_of_books_id = gl.set_of_books_id
97     AND clct.legal_entity = l_legal_entity
98     AND cost_type_id = i_cost_type_id;
99 
100   l_stmt_num := 50;
101   /* Validate organization_id */
102   l_count := 0;
103   SELECT count(*)
104   INTO l_count
105   FROM MTL_PARAMETERS
106   WHERE organization_id = i_org_id
107     AND master_organization_id = i_org_id
108     AND i_org_id = l_master_org_id;
109 
110   IF (l_count = 0) THEN
111     l_err_num := 999;
112     l_err_code := 'CST_NO_TXN_INVALID_ORG';
113     FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_ORG');
114     l_err_msg := FND_MESSAGE.Get;
115     raise process_error;
116   END IF;
117 
118   l_stmt_num := 60;
119   /* Validate transaction_date */
120   SELECT NVL(MAX(pac_period_id),-1)
121   INTO l_period_id
122   FROM CST_PAC_PERIODS
123   WHERE legal_entity = l_legal_entity
124     AND cost_type_id = i_cost_type_id
125     AND i_transaction_date between period_start_date and period_end_date;
126 
127   IF (l_period_id <> -1) THEN
128     l_stmt_num := 70;
129     SELECT decode(open_flag,'Y',decode(period_close_date,NULL,'Y','N'),'N')
130     INTO l_open_flag
131     FROM CST_PAC_PERIODS
132     WHERE pac_period_id = l_period_id;
133 
134     IF (l_open_flag = 'N') THEN
135       l_err_num := 999;
136       l_err_code := 'CST_PAC_CLOSE_PERIOD';
137       FND_MESSAGE.set_name('BOM', 'CST_PAC_CLOSE_PERIOD');
138       l_err_msg := FND_MESSAGE.Get;
139       raise process_error;
140     END IF;
141   END IF;
142 
143   l_stmt_num := 80;
144   l_count := 0;
145   SELECT count(*)
146   INTO l_count
147   FROM GL_PERIODS
148   WHERE period_set_name = l_period_set_name
149     AND period_type = l_period_type
150     AND i_transaction_date between start_date and end_date;
151 
152   IF (l_count = 0) THEN
153     l_err_num := 999;
154     l_err_code := 'CST_PAC_TXN_DATE_INVALID';
155     FND_MESSAGE.set_name('BOM', 'CST_PAC_TXN_DATE_INVALID');
156     l_err_msg := FND_MESSAGE.Get;
157     raise process_error;
158   END IF;
159 
160 
161   l_stmt_num := 90;
162   /* Validate that all accounts do exists in given chart of accounts. */
163   l_count := 0;
164   IF (i_mat_accnt IS NOT NULL) THEN
165     l_count := l_count + validate_account(i_mat_accnt,l_chart_account_id);
166   END IF;
167   IF (i_mat_ovhd_accnt IS NOT NULL) THEN
168     l_count := l_count + validate_account(i_mat_ovhd_accnt,l_chart_account_id);
169   END IF;
170   IF (i_res_accnt IS NOT NULL) THEN
171     l_count := l_count + validate_account(i_res_accnt,l_chart_account_id);
172   END IF;
173   IF (i_osp_accnt IS NOT NULL) THEN
174     l_count := l_count + validate_account(i_osp_accnt,l_chart_account_id);
175   END IF;
176   IF (i_ovhd_accnt IS NOT NULL) THEN
177     l_count := l_count + validate_account(i_ovhd_accnt,l_chart_account_id);
178   END IF;
179   IF (l_count > 0) THEN
180     l_err_num := 999;
181     l_err_code := 'CST_NO_TXN_INVALID_ACCOUNT';
182     FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_ACCOUNT');
183     l_err_msg := FND_MESSAGE.Get;
184     raise process_error;
185   END IF;
186 
187   /* Validate the consistency of data
188      The following must be true for periodic cost update :
189      - Among new_cost, value change, percentage change column on the mti,
190        the user can only enter it one. Also can't have null value
191      - The same is true in detail.
192      - The sum of new_cost in mtcdi must be the same with one in mti.
193        New cost must be >= 0
194      - The sum of value change in mtcdi must be the same with one in mti.
195      - Percentage change >= -100
196   */
197   l_stmt_num := 100;
198   SELECT count(*)
199   INTO l_num_details
200   FROM MTL_TXN_COST_DET_INTERFACE
201   WHERE TRANSACTION_INTERFACE_ID = i_txn_interface_id;
202 
203   IF ( i_new_avg_cost IS NOT NULL AND i_per_change IS NULL AND i_val_change IS NULL ) THEN
204     l_stmt_num := 110;
205     l_count := 0;
206     SELECT count(*), SUM(new_average_cost)
207     INTO l_count, l_sum_new_cost
208     FROM MTL_TXN_COST_DET_INTERFACE
209     WHERE TRANSACTION_INTERFACE_ID = i_txn_interface_id AND NVL(new_average_cost,-1) >= 0
210       AND percentage_change IS NULL AND value_change IS NULL;
211     IF (l_count <> l_num_details OR l_sum_new_cost <> i_new_avg_cost) THEN
212       l_err_num := 999;
213       l_err_code := 'CST_NO_TXN_INVALID_COST_CHANGE';
214       FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_COST_CHANGE');
215       l_err_msg := FND_MESSAGE.Get;
216       raise process_error;
217     END IF;
218   ELSIF ( i_new_avg_cost IS NULL AND i_per_change IS NOT NULL AND i_val_change IS NULL ) THEN
219     l_stmt_num := 120;
220     l_count := 0;
221     SELECT count(*)
222     INTO l_count
223     FROM MTL_TXN_COST_DET_INTERFACE
224     WHERE TRANSACTION_INTERFACE_ID = i_txn_interface_id AND new_average_cost IS NULL
225       AND NVL(percentage_change,-999) >= -100 AND value_change IS NULL;
226     IF (l_count <> l_num_details) THEN
227       l_err_num := 999;
228       l_err_code := 'CST_NO_TXN_INVALID_COST_CHANGE';
229       FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_COST_CHANGE');
230       l_err_msg := FND_MESSAGE.Get;
231       raise process_error;
232     END IF;
233   ELSIF ( i_new_avg_cost IS NULL AND i_per_change IS NULL AND i_val_change IS NOT NULL ) THEN
234     l_stmt_num := 130;
235     l_count := 0;
236     SELECT count(*), SUM(value_change)
237     INTO l_count, l_sum_value_change
238     FROM MTL_TXN_COST_DET_INTERFACE
239     WHERE TRANSACTION_INTERFACE_ID = i_txn_interface_id AND new_average_cost IS NULL
240       AND percentage_change IS NULL AND value_change IS NOT NULL;
241     IF (l_count <> l_num_details OR l_sum_value_change <> i_val_change) THEN
242       l_err_num := 999;
243       l_err_code := 'CST_NO_TXN_INVALID_COST_CHANGE';
244       FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_COST_CHANGE');
245       l_err_msg := FND_MESSAGE.Get;
246       raise process_error;
247     END IF;
248   ELSE
249     l_err_num := 999;
250     l_err_code := 'CST_NO_TXN_INVALID_COST_CHANGE';
251     FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_COST_CHANGE');
252     l_err_msg := FND_MESSAGE.Get;
253     raise process_error;
254   END IF;
255 
256   l_stmt_num := 140;
257   CSTPACIT.cost_det_validate(i_txn_interface_id, i_org_id, i_item_id,
258                     i_new_avg_cost,
259 		    i_per_change, i_val_change, i_mat_accnt, i_mat_ovhd_accnt,
260                     i_res_accnt, i_osp_accnt, i_ovhd_accnt,
261                     l_err_num, l_err_code, l_err_msg);
262   IF (l_err_num <> 0) THEN
263     raise process_error;
264   END IF;
265 
266 EXCEPTION
267   WHEN process_error THEN
268     o_err_num := l_err_num;
269     o_err_code := l_err_code;
270     o_err_msg := 'CSTPPCIT.PERIODIC_COST_VALIDATE:' || l_err_msg;
271   WHEN OTHERS THEN
272     o_err_num := SQLCODE;
273     o_err_msg := 'CSTPPCIT.PERIODIC_COST_VALIDATE: (' || to_char(l_stmt_num)
274                 || '): ' || substr(SQLERRM,1,150);
275 
276 END periodic_cost_validate;
277 
278 
279 
280 
281 FUNCTION validate_account(
282   i_accnt		in number,
283   i_chart_of_accounts	in number)
284 RETURN number
285 IS
286   l_count		number;
287 BEGIN
288   l_count := 0;
289 
290   SELECT count(*)
291   INTO l_count
292   FROM GL_CODE_COMBINATIONS
293   WHERE code_combination_id = i_accnt
294     AND chart_of_accounts_id = i_chart_of_accounts;
295 
296   IF (l_count = 1) THEN
297     return 0;	/* Means the account does exists and valid */
298   ELSE
299     return 1;	/* Means the account doesn't exists or invalid */
300   END IF;
301 
302 
303 END validate_account;
304 
305 PROCEDURE periodic_cost_det_move (
306   i_cost_type_id	    in number,
307   i_transaction_date        in date,
308   i_txn_id                  in number,
309   i_txn_interface_id        in number,
310   i_txn_action_id	    in number,
311   i_org_id	            in number,
312   i_item_id		    in number,
313   i_org_cost_group_id	    in number,
314   i_txn_cost		    in number,
315   i_new_avg_cost	    in number,
316   i_per_change		    in number,
317   i_val_change		    in number,
318   i_mat_accnt		    in number,
319   i_mat_ovhd_accnt	    in number,
320   i_res_accnt		    in number,
321   i_osp_accnt		    in number,
322   i_ovhd_accnt		    in number,
323   i_user_id                 in number,
324   i_login_id                in number,
325   i_request_id              in number,
326   i_prog_appl_id            in number,
327   i_prog_id                 in number,
328   o_err_num                 out NOCOPY number,
329   o_err_code		    out NOCOPY varchar2,
330   o_err_msg                 out NOCOPY varchar2
331 ) IS
332   l_err_num                 number;
333   l_err_code                varchar2(240);
334   l_err_msg                 varchar2(240);
335   l_num_detail              number;
336   l_legal_entity	    number;
337   l_pac_period_id	    number;
338   process_error       	    EXCEPTION;
339 BEGIN
340   /*
341   ** initialize local variables
342   */
343   l_err_num := 0;
344   l_err_code := '';
345   l_err_msg := '';
346 
347 
348   SELECT count(*)
349   INTO   l_num_detail
350   FROM   MTL_TXN_COST_DET_INTERFACE
351   WHERE  TRANSACTION_INTERFACE_ID = i_txn_interface_id;
352 
353   SELECT legal_entity
354   INTO l_legal_entity
355   FROM CST_COST_GROUPS
356   WHERE cost_group_id = i_org_cost_group_id;
357 
358   SELECT NVL(MAX(pac_period_id),-1)
359   INTO l_pac_period_id
360   FROM CST_PAC_PERIODS
361   WHERE cost_type_id = i_cost_type_id
362     AND legal_entity = l_legal_entity
363     AND i_transaction_date between period_start_date and period_end_date;
364 
365   /*  l_num_detail = 0	: No corresponding rows in MTL_TXN_COST_DET_INTERFACE
366    *			  OR i_txn_interface_id is null.
367    *  In this case, call cstpacit.cost_det_new_insert.
368    */
369 
370   IF (l_num_detail = 0) THEN
371     cstppcit.periodic_cost_det_new_insert(l_pac_period_id, l_legal_entity,
372                                  i_cost_type_id,
373                                  i_txn_id, i_txn_action_id, i_org_id,
374 				 i_item_id, i_org_cost_group_id, i_txn_cost,
375 				 i_new_avg_cost, i_per_change, i_val_change,
376 				 i_mat_accnt, i_mat_ovhd_accnt, i_res_accnt,
377 				 i_osp_accnt, i_ovhd_accnt,
378 				 i_user_id, i_login_id, i_request_id,
379 				 i_prog_appl_id, i_prog_id,
380 				 l_err_num, l_err_code, l_err_msg);
381     IF (l_err_num <> 0) THEN
382 	RAISE process_error;
383     END IF;
384 
385   ELSE
386     INSERT INTO MTL_PAC_TXN_COST_DETAILS (
387       pac_period_id,
388       cost_group_id,
389       cost_type_id,
390       transaction_id,
391       inventory_item_id,
392       cost_element_id,
393       level_type,
394       transaction_cost,
395       new_periodic_cost,
396       percentage_change,
397       value_change,
398       last_update_date,
399       last_updated_by,
400       creation_date,
401       created_by,
402       last_update_login,
403       request_id,
404       program_application_id,
405       program_id,
406       program_update_date
407     ) SELECT
408       l_pac_period_id,
409       i_org_cost_group_id,
410       i_cost_type_id,
411       i_txn_id,
412       i_item_id,
413       cost_element_id,
414       level_type,
415       transaction_cost,
416       new_average_cost,
417       percentage_change,
418       value_change,
419       sysdate,
420       i_user_id,
421       sysdate,
422       i_user_id,
423       i_login_id,
424       i_request_id,
425       i_prog_appl_id,
426       i_prog_id,
427       sysdate
428     FROM MTL_TXN_COST_DET_INTERFACE
429     WHERE TRANSACTION_INTERFACE_ID = i_txn_interface_id;
430 
431   END IF;
432 
433 EXCEPTION
434   WHEN process_error THEN
435     o_err_num := l_err_num;
436     o_err_code := l_err_code;
437     o_err_msg := 'CSTPPCIT.PERIODIC_COST_DET_MOVE:' || l_err_msg;
438   WHEN OTHERS THEN
439     o_err_num := SQLCODE;
440     o_err_msg := 'CSTPPCIT.PERIODIC_COST_DET_MOVE:' || substr(SQLERRM,1,150);
441 
442 END periodic_cost_det_move;
443 
444 
445 
446 
447 PROCEDURE periodic_cost_det_new_insert (
448   i_pac_period_id           in number,
449   i_legal_entity            in number,
450   i_cost_type_id            in number,
451   i_txn_id                  in number,
452   i_txn_action_id           in number,
453   i_org_id	            in number,
454   i_item_id		    in number,
455   i_org_cost_group_id	    in number,
456   i_txn_cost		    in number,
457   i_new_avg_cost	    in number,
458   i_per_change		    in number,
459   i_val_change		    in number,
460   i_mat_accnt		    in number,
461   i_mat_ovhd_accnt	    in number,
462   i_res_accnt		    in number,
463   i_osp_accnt		    in number,
464   i_ovhd_accnt		    in number,
465   i_user_id                 in number,
466   i_login_id                in number,
467   i_request_id              in number,
468   i_prog_appl_id            in number,
469   i_prog_id                 in number,
470   o_err_num                 out NOCOPY number,
471   o_err_code		    out NOCOPY varchar2,
472   o_err_msg                 out NOCOPY varchar2
473 ) IS
474   l_err_num                 number;
475   l_err_code                varchar2(240);
476   l_err_msg                 varchar2(240);
477   l_prior_close_period_id   number;
478   l_item_cost		    number;
479   cost_element_count	    number;
480   l_cost_layer_id	    number;
481   l_qty_layer_id	    number;
482   process_error 	    EXCEPTION;
483 
484 
485   CURSOR cost_element_cursor (l_layer_id number) IS
486     SELECT cpicd.cost_element_id
487     FROM   CST_PAC_ITEM_COST_DETAILS cpicd
488     WHERE  cpicd.cost_layer_id = l_layer_id;
489 
490 
491 BEGIN
492   /*
493   ** initialize local variables
494   */
495   l_err_num := 0;
496   l_err_code := '';
497   l_err_msg := '';
498   l_cost_layer_id := 0;
499   l_qty_layer_id  := 0;
500   cost_element_count := 0;
501 
502   /* Find last close period */
503   SELECT NVL(MAX(pac_period_id), -1)
504   INTO l_prior_close_period_id
505   FROM CST_PAC_PERIODS
506   WHERE cost_type_id = i_cost_type_id AND legal_entity = i_legal_entity
507     AND open_flag = 'N' AND period_close_date IS NOT NULL;
508 
509   IF (l_prior_close_period_id <> -1) THEN
510     CSTPPCLM.layer_id (l_prior_close_period_id, i_legal_entity,
511                        i_item_id, i_org_cost_group_id, l_cost_layer_id,
512                        l_qty_layer_id, l_err_num, l_err_code, l_err_msg);
513     IF (l_err_num <> 0) THEN
514       raise process_error;
515     END IF;
516   END IF;
517 
518 
519   /*  If layer detail exist for that item, then calculate proportional costs and
520    *  insert each elements into MTL_PAC_TXN_COST_DETAILS.
521    */
522 
523   IF (l_cost_layer_id <> 0) THEN
524 
525     FOR l_cost_element IN cost_element_cursor(l_cost_layer_id) LOOP
526 
527       IF ((l_cost_element.cost_element_id = 1 AND i_mat_accnt IS NULL) OR
528           (l_cost_element.cost_element_id = 2 AND i_mat_ovhd_accnt IS NULL) OR
529           (l_cost_element.cost_element_id = 3 AND i_res_accnt IS NULL) OR
530           (l_cost_element.cost_element_id = 4 AND i_osp_accnt IS NULL) OR
531           (l_cost_element.cost_element_id = 5 AND i_ovhd_accnt IS NULL)) THEN
532         -- Error occured
533 
534         FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_ACCOUNT');
535         l_err_num := 999;
536         l_err_code := 'Invalid accounts.';
537         l_err_msg := FND_MESSAGE.Get;
538 
539         RAISE process_error;
540       END IF;
541 
542     END LOOP;
543 
544     SELECT item_cost
545     INTO l_item_cost
546     FROM CST_PAC_ITEM_COSTS
547     WHERE cost_layer_id = l_cost_layer_id;
548 
549     /* for the case of item cost equal zero */
550     /* split cost evenly among cost elements */
551 
552     IF (l_item_cost = 0) THEN
553       SELECT count(cost_element_id)
554       INTO cost_element_count
555       FROM CST_PAC_ITEM_COST_DETAILS
556       WHERE cost_layer_id = l_cost_layer_id;
557     END IF;
558 
559     INSERT INTO MTL_PAC_TXN_COST_DETAILS (
560       pac_period_id,
561       cost_group_id,
562       cost_type_id,
563       transaction_id,
564       inventory_item_id,
565       cost_element_id,
566       level_type,
567       transaction_cost,
568       new_periodic_cost,
569       percentage_change,
570       value_change,
571       last_update_date,
572       last_updated_by,
573       creation_date,
574       created_by,
575       last_update_login,
576       request_id,
577       program_application_id,
578       program_id,
579       program_update_date
580       )
581     SELECT
582       i_pac_period_id,
583       i_org_cost_group_id,
584       i_cost_type_id,
585       i_txn_id,
586       i_item_id,
587       cost_element_id,
588       level_type,
589       DECODE(l_item_cost, 0, i_txn_cost/cost_element_count,
590                              i_txn_cost * item_cost/l_item_cost),
591       DECODE(l_item_cost, 0, i_new_avg_cost/cost_element_count,
592                              i_new_avg_cost * item_cost/l_item_cost),
593       i_per_change,
594       DECODE(l_item_cost, 0, i_val_change/cost_element_count,
595                              i_val_change * item_cost/l_item_cost),
596       sysdate,
597       i_user_id,
598       sysdate,
599       i_user_id,
600       i_login_id,
601       i_request_id,
602       i_prog_appl_id,
603       i_prog_id,
604       sysdate
605     FROM CST_PAC_ITEM_COST_DETAILS
606     WHERE cost_layer_id = l_cost_layer_id;
607 
608   /*  If layer detail does not exist, then insert a new row
609    *  as a this level material.
610    */
611   ELSE
612 
613     IF (i_mat_accnt is null) THEN
614       FND_MESSAGE.set_name('BOM', 'CST_NO_TXN_INVALID_ACCOUNT');
615       l_err_num := 999;
616       l_err_code := 'Invalid accounts.';
617       l_err_msg := FND_MESSAGE.Get;
618 
619       RAISE process_error;
620     END IF;
621 
622     INSERT INTO MTL_PAC_TXN_COST_DETAILS (
623       pac_period_id,
624       cost_group_id,
625       cost_type_id,
626       transaction_id,
627       inventory_item_id,
628       cost_element_id,
629       level_type,
630       transaction_cost,
631       new_periodic_cost,
632       percentage_change,
633       value_change,
634       last_update_date,
635       last_updated_by,
636       creation_date,
637       created_by,
638       last_update_login,
639       request_id,
640       program_application_id,
641       program_id,
642       program_update_date
643       )
644     VALUES (
645       i_pac_period_id,
646       i_org_cost_group_id,
647       i_cost_type_id,
648       i_txn_id,
649       i_item_id,
650       1,
651       1,
652       i_txn_cost,
653       i_new_avg_cost,
654       i_per_change,
655       i_val_change,
656       sysdate,
657       i_user_id,
658       sysdate,
659       i_user_id,
660       i_login_id,
661       i_request_id,
662       i_prog_appl_id,
663       i_prog_id,
664       sysdate);
665 
666   END IF;
667 
668 EXCEPTION
669   WHEN process_error THEN
670     o_err_num := l_err_num;
671     o_err_code := l_err_code;
672     o_err_msg := 'CSTPPCIT.PERIODIC_COST_DET_NEW_INSERT:' || l_err_msg;
673   WHEN OTHERS THEN
674     o_err_num := SQLCODE;
675     o_err_msg := 'CSTPPCIT.PERIODIC_COST_DET_NEW_INSERT:' ||
676                  substr(SQLERRM,1,150);
677 
678 END periodic_cost_det_new_insert;
679 
680 END cstppcit;