[Home] [Help]
PACKAGE BODY: APPS.CSTPLCWP
Source
1 PACKAGE BODY CSTPLCWP AS
2 /* $Header: CSTLCWPB.pls 120.2 2010/05/05 20:58:25 jkwac ship $ */
3
4 PROCEDURE cost_wip_trx (
5 l_trx_id IN NUMBER,
6 l_comm_iss_flag IN NUMBER,
7 l_cost_type_id IN NUMBER,
8 l_cost_method IN NUMBER,
9 l_rates_cost_type_id IN NUMBER,
10 l_cost_grp_id IN NUMBER,
11 l_txfr_cost_grp_id IN NUMBER,
12 l_exp_flag IN NUMBER,
13 l_exp_item_flag IN NUMBER,
14 l_flow_schedule IN NUMBER,
15 l_user_id IN NUMBER,
16 l_login_id IN NUMBER,
17 l_request_id IN NUMBER,
18 l_prog_id IN NUMBER,
19 l_prog_app_id IN NUMBER,
20 err_num OUT NOCOPY NUMBER,
21 err_code OUT NOCOPY VARCHAR2,
22 err_msg OUT NOCOPY VARCHAR2
23 )
24 is
25
26 l_layer_id NUMBER;
27 l_cost_group_id NUMBER;
28 l_inv_item_id NUMBER;
29 l_org_id NUMBER;
30 l_txn_date DATE;
31 l_period_id NUMBER;
32 l_action_id NUMBER;
33 l_src_type_id NUMBER;
34 l_txn_qty NUMBER;
35 l_wip_entity_id NUMBER;
36 l_op_seq_num NUMBER;
37 l_final_comp_flag VARCHAR2(1);
38 l_movhd_cost_type_id NUMBER;
39 stmt_num NUMBER;
40 l_return NUMBER;
41 l_row_count NUMBER;
42 l_mtl_txn_exists NUMBER;
43 l_entity_type NUMBER;
44 l_err_num NUMBER;
45 l_err_code VARCHAR2(240);
46 l_err_msg VARCHAR2(240);
47 proc_fail EXCEPTION;
48
49
50 l_trx_info CST_XLA_PVT.t_xla_inv_trx_info;
51
52 l_msg_data VARCHAR2(8000);
53 l_msg_count NUMBER;
54 l_return_status VARCHAR2(1);
55 l_msg_return_status VARCHAR2(1);
56 BEGIN
57
58 --
59 -- initialize l_movhd_cost_type_id. Bug 609 -
60 l_movhd_cost_type_id := l_rates_cost_type_id;
61
62 err_num:=0;
63 l_err_num := 0;
64
65 stmt_num := 110;
66
67 select
68 inventory_item_id,
69 organization_id,
70 transaction_date,
71 transaction_action_id,
72 transaction_source_type_id,
73 primary_quantity,
74 transaction_source_id,
75 operation_seq_num,
76 nvl(final_completion_flag,'N'),
77 acct_period_id
78 into
79 l_inv_item_id,
80 l_org_id,
81 l_txn_date,
82 l_action_id,
83 l_src_type_id,
84 l_txn_qty,
85 l_wip_entity_id,
86 l_op_seq_num,
87 l_final_comp_flag,
88 l_period_id
89 from
90 mtl_material_transactions
91 where
92 transaction_id = l_trx_id;
93
94 /* Bug9502821 : Updating the prior completed quantity and
95 prior scrap quantity at the time of costing
96 as these might not be correct at the time
97 of creation due to constraints in Iventory
98 transaction manager
99 */
100 IF ( l_action_id IN (30,31,32) ) THEN
101 UPDATE cst_comp_snapshot cocd1
102 SET
103 (cocd1.prior_completion_quantity, cocd1.prior_scrap_quantity) =
104 (SELECT
105 NVL
106 (SUM(
107 DECODE(mmt.transaction_action_id,
108 30,0,
109 cocd2.primary_quantity)
110 ),
111 0),
112 NVL(SUM(
113 DECODE(mmt.transaction_action_id,
114 31,0,
115 32,0,
116 cocd2.primary_quantity)
117 ),
118 0)
119 FROM
120 cst_comp_snapshot cocd2,
121 mtl_material_transactions mmt
122 WHERE cocd2.transaction_id = mmt.transaction_id
123 AND cocd2.wip_entity_id = cocd1.wip_entity_id
124 AND cocd2.operation_seq_num = cocd1.operation_seq_num
125 AND mmt.transaction_action_id in (30,31,32)
126 AND mmt.organization_id = l_org_id
127 AND mmt.transaction_source_id = l_wip_entity_id
128 AND mmt.transaction_source_type_id = 5
129 AND (mmt.transaction_date < l_txn_date
130 OR (mmt.transaction_date = l_txn_date
131 AND mmt.transaction_id < l_trx_id)
132 )
133 )
134 WHERE cocd1.transaction_id = l_trx_id
135 AND cocd1.wip_entity_id = l_wip_entity_id;
136 END IF;
137
138 -- Check to see if the item has a row in cst_quantity_layers.
139
140 -- For a regular transaction the layer_id in MCACD corresponds to
141 -- the cost_group_id in MMT. For a CITW txn however, the WIP issue
142 -- is being done from the txfr_cost_group in MMT and so we should
143 -- fetch the layer_id corresponding to this.
144
145 IF l_comm_iss_flag <> 1 THEN
146
147 l_layer_id := CSTPACLM.layer_id
148 (
149 l_org_id,
150 l_inv_item_id,
151 l_cost_grp_id,
152 l_err_num,
153 l_err_code,
154 l_err_msg
155 );
156
157 ELSE
158
159 l_layer_id := CSTPACLM.layer_id
160 (
161 l_org_id,
162 l_inv_item_id,
163 l_txfr_cost_grp_id,
164 l_err_num,
165 l_err_code,
166 l_err_msg
167 );
168
169 END IF;
170
171 IF l_err_num <> 0 THEN
172 raise proc_fail;
173 END IF;
174
175
176 -- If row exists proceed, else create row.
177
178 IF l_layer_id = 0 THEN
179 l_layer_id:= CSTPACLM.create_layer
180 (
181 i_org_id => l_org_id,
182 i_item_id => l_inv_item_id,
183 i_cost_group_id => l_cost_grp_id,
184 i_user_id => l_user_id,
185 i_request_id => l_request_id,
186 i_prog_id => l_prog_id,
187 i_prog_appl_id => l_prog_app_id,
188 i_txn_id => l_trx_id,
189 o_err_num => l_err_num,
190 o_err_code => l_err_code,
191 o_err_msg => l_err_msg
192 );
193
194 IF (l_err_num<>0) THEN
195 raise proc_fail;
196 END IF;
197
198 END IF;
199
200
201
202
203 -- Prior to doing any further processing, check for a CFM txn if a row
204 -- exists in WPB for that schedule. If no row exists then this fn will
205 -- create a row automatically.
206
207
208 If (l_flow_schedule = 1) THEN
209
210 l_return := CSTPCFMS.wip_cfm_cbr
211 (
212 i_org_id => l_org_id,
213 i_user_id => l_user_id,
214 i_login_id => l_user_id,
215 i_acct_period_id => l_period_id,
216 i_wip_entity_id => l_wip_entity_id,
217 err_buf => l_err_msg
218 );
219
220 If (l_return <> 0) THEN
221 raise proc_fail;
222 END IF;
223
224 END IF;
225
226
227 -- Based on transaction_action_id call appropriate function for processing.
228 -- Need to also account for the 2 new wip txns.
229
230
231
232 IF ( l_action_id = 1 OR l_action_id = 34 ) THEN
233
234 CSTPLCIR.component_issue
235 (
236 i_cost_method_id => l_cost_method,
237 i_txn_id => l_trx_id,
238 i_layer_id => l_layer_id,
239 i_inv_item_id => l_inv_item_id,
240 i_org_id => l_org_id,
241 i_wip_entity_id => l_wip_entity_id,
242 i_txn_qty => l_txn_qty,
243 i_op_seq_num => l_op_seq_num,
244 i_cost_type_id => l_cost_type_id,
245 i_exp_flag => l_exp_flag,
246 i_user_id => l_user_id,
247 i_login_id => l_login_id,
248 i_request_id => l_request_id,
249 i_prog_id => l_prog_id,
250 i_prog_appl_id => l_prog_app_id,
251 o_err_num => l_err_num,
252 o_err_msg => l_err_msg
253 );
254
255 ELSIF ( l_action_id = 27 OR l_action_id = 33 ) THEN
256
257 CSTPLCIR.component_return
258 (
259 i_cost_method_id => l_cost_method,
260 i_txn_id => l_trx_id,
261 i_layer_id => l_layer_id,
262 i_inv_item_id => l_inv_item_id,
263 i_org_id => l_org_id,
264 i_wip_entity_id => l_wip_entity_id,
265 i_txn_qty => l_txn_qty,
266 i_op_seq_num => l_op_seq_num,
267 i_user_id => l_user_id,
268 i_login_id => l_login_id,
269 i_request_id => l_request_id,
270 i_prog_id => l_prog_id,
271 i_prog_appl_id => l_prog_app_id,
272 o_err_num => l_err_num,
273 o_err_msg => l_err_msg
274 );
275
276 ELSIF ( l_action_id = 31 and l_flow_schedule <> 1 ) THEN
277
278 CSTPLCAC.assembly_completion
279 (
280 i_cost_method_id => l_cost_method,
281 i_txn_id => l_trx_id,
282 i_txn_date => l_txn_date,
283 i_layer_id => l_layer_id,
284 i_inv_item_id => l_inv_item_id,
285 i_org_id => l_org_id,
286 i_wip_entity_id => l_wip_entity_id,
287 i_txn_qty => l_txn_qty,
288 i_final_comp_flag => l_final_comp_flag,
289 i_cost_type_id => l_cost_type_id,
290 i_res_cost_type_id => l_rates_cost_type_id,
291 i_cost_group_id => l_cost_grp_id,
292 i_acct_period_id => l_period_id,
293 i_user_id => l_user_id,
294 i_login_id => l_login_id,
295 i_request_id => l_request_id,
296 i_prog_id => l_prog_id,
297 i_prog_appl_id => l_prog_app_id,
298 o_movhd_cost_type_id => l_movhd_cost_type_id,
299 o_err_num => l_err_num,
300 o_err_msg => l_err_msg
301 );
302
303 ELSIF ( l_action_id = 32 and l_flow_schedule <> 1 ) THEN
304
305 -- Note that we're not passing the l_movhd_cost_type_id anymore;
306 -- this is because we always return at the WIP component layer
307 -- cost, so we'll ignore the user-specified cost type for
308 -- assembly returns.
309
310 CSTPLCAC.assembly_return
311 (
312 i_cost_method_id => l_cost_method,
313 i_txn_id => l_trx_id,
314 i_layer_id => l_layer_id,
315 i_inv_item_id => l_inv_item_id,
316 i_org_id => l_org_id,
317 i_wip_entity_id => l_wip_entity_id,
318 i_txn_qty => l_txn_qty,
319 i_user_id => l_user_id,
320 i_login_id => l_login_id,
321 i_request_id => l_request_id,
322 i_prog_id => l_prog_id,
323 i_prog_appl_id => l_prog_app_id,
324 o_err_num => l_err_num,
325 o_err_msg => l_err_msg
326 );
327
328 ELSIF ( l_action_id = 30 and l_txn_qty >= 0 and l_flow_schedule <> 1 ) THEN
329
330 CSTPLCAS.scrap
331 (
332 i_cost_method_id => l_cost_method,
333 i_txn_id => l_trx_id,
334 i_layer_id => l_layer_id,
335 i_inv_item_id => l_inv_item_id,
336 i_org_id => l_org_id,
337 i_wip_entity_id => l_wip_entity_id,
338 i_txn_qty => l_txn_qty,
339 i_op_seq_num => l_op_seq_num,
340 i_user_id => l_user_id,
341 i_login_id => l_login_id,
342 i_request_id => l_request_id,
343 i_prog_id => l_prog_id,
344 i_prog_appl_id => l_prog_app_id,
345 o_err_num => l_err_num,
346 o_err_msg => l_err_msg
347 );
348
349 ELSIF ( l_action_id = 30 and l_txn_qty < 0 and l_flow_schedule <> 1 ) THEN
350
351 CSTPLCAS.scrap_return
352 (
353 i_cost_method_id => l_cost_method,
354 i_txn_id => l_trx_id,
355 i_layer_id => l_layer_id,
356 i_inv_item_id => l_inv_item_id,
357 i_org_id => l_org_id,
358 i_wip_entity_id => l_wip_entity_id,
359 i_txn_qty => l_txn_qty,
360 i_op_seq_num => l_op_seq_num,
361 i_user_id => l_user_id,
362 i_login_id => l_login_id,
363 i_request_id => l_request_id,
364 i_prog_id => l_prog_id,
365 i_prog_appl_id => l_prog_app_id,
366 o_err_num => l_err_num,
367 o_err_msg => l_err_msg
368 );
369
370 ELSIF ( (l_action_id = 31 OR (l_action_id=30 AND l_txn_qty>0) ) AND
371 l_flow_schedule = 1 ) THEN
372
373 CSTPCFMS.wip_cfm_complete
374 (
375 i_trx_id => l_trx_id,
376 i_org_id => l_org_id,
377 i_inv_item_id => l_inv_item_id,
378 i_txn_qty => l_txn_qty,
379 i_wip_entity_id => l_wip_entity_id,
380 i_txn_src_type_id => 5,
381 i_flow_schedule => l_flow_schedule,
382 i_txn_action_id => l_action_id,
383 i_user_id => l_user_id,
384 i_login_id => l_login_id,
385 i_request_id => l_request_id,
386 i_prog_id => l_prog_id,
387 i_prog_appl_id => l_prog_app_id,
388 err_num => l_err_num,
389 err_code => l_err_code,
390 err_msg => l_err_msg
391 );
392
393 ELSIF ( (l_action_id = 32 OR (l_action_id=30 AND l_txn_qty<0) ) AND
394 l_flow_schedule = 1 ) THEN
395
396 CSTPCFMS.wip_cfm_assy_return
397 (
398 i_trx_id => l_trx_id,
399 i_org_id => l_org_id,
400 i_inv_item_id => l_inv_item_id,
401 i_txn_qty => l_txn_qty,
402 i_wip_entity_id => l_wip_entity_id,
403 i_txn_src_type_id => 5,
404 i_flow_schedule => l_flow_schedule,
405 i_txn_action_id => l_action_id,
406 i_user_id => l_user_id,
407 i_login_id => l_login_id,
408 i_request_id => l_request_id,
409 i_prog_id => l_prog_id,
410 i_prog_appl_id => l_prog_app_id,
411 err_num => l_err_num,
412 err_code => l_err_code,
413 err_msg => l_err_msg
414 );
415
416 ELSE
417
418 l_err_num := 1101;
419 l_err_code := 'CSTPLCWP: Unsupported MMT transaction type';
420 l_err_msg := 'CSTPLCWP: Unsupported MMT transaction type';
421
422 END IF;
423
424
425 -- Check if processing is succesful, if not, pass control back to calling
426 -- module.
427
428 IF (l_err_num<>0) THEN
429 raise proc_fail;
430 END IF;
431
432
433
434
435 -- Flush out all WIP layer quantities after CFM completion, return,
436 -- or scrap transactions
437
438 IF ( l_flow_schedule = 1 and l_action_id in (30, 31, 32) ) THEN
439
440 stmt_num := 120;
441 update cst_wip_layers CWL
442 set
443 CWL.relieved_matl_comp_qty =
444 ( CWL.applied_matl_qty -
445 CWL.relieved_matl_scrap_qty -
446 CWL.relieved_matl_final_comp_qty ),
447 CWL.temp_relieved_qty =
448 ( CWL.applied_matl_qty -
449 CWL.relieved_matl_comp_qty -
450 CWL.relieved_matl_scrap_qty -
451 CWL.relieved_matl_final_comp_qty )
452 where
453 CWL.wip_entity_id = l_wip_entity_id and
454 ( CWL.applied_matl_qty -
455 CWL.relieved_matl_comp_qty -
456 CWL.relieved_matl_scrap_qty -
457 CWL.relieved_matl_final_comp_qty ) >= 0;
458
459 stmt_num := 130;
460 update cst_wip_layers CWL
461 set
462 CWL.relieved_matl_final_comp_qty =
463 ( CWL.applied_matl_qty -
464 CWL.relieved_matl_comp_qty -
465 CWL.relieved_matl_scrap_qty ),
466 CWL.temp_relieved_qty =
467 ( CWL.applied_matl_qty -
468 CWL.relieved_matl_comp_qty -
469 CWL.relieved_matl_scrap_qty -
470 CWL.relieved_matl_final_comp_qty )
471 where
472 CWL.wip_entity_id = l_wip_entity_id and
473 ( CWL.applied_matl_qty -
474 CWL.relieved_matl_comp_qty -
475 CWL.relieved_matl_scrap_qty -
476 CWL.relieved_matl_final_comp_qty ) < 0;
477
478 END IF;
479
480
481
482
483 -- All the logic below should be exectued only if the transaction
484 -- is not a CITW txn. If it is then the cost proc and distbn proc
485 -- is done within CSTPACIn, the Inv library.
486
487 IF (l_comm_iss_flag <> 1) THEN
488
489
490 /*----------------------------------------------------
491 | The cost processor operates under the assumption that
492 | if there are no rows in the transaction cost table,
493 | then the transaction occured at the current average
494 | cost. For component issue/return transactions we
495 | therefore deliberately refrain from inserting a
496 | cost row. For completions, assembly returns and
497 | scrap transactions however, in the respective
498 | packages, we do not insert row if the cost is zero.
499 | To prevent such transactions from being processed at
500 | current average cost, we need to insert a dummy
501 | TL materil row into the cost table with zero cost.
502 |------------------------------------------------------*/
503
504
505
506 stmt_num := 140;
507
508 select count(*)
509 into l_mtl_txn_exists
510 from mtl_cst_txn_cost_details
511 where transaction_id = l_trx_id;
512
513 IF( l_mtl_txn_exists=0 AND
514 ( l_action_id=30 OR l_action_id=31 OR l_action_id=32 ) ) THEN
515
516
517 stmt_num := 150;
518
519 INSERT INTO mtl_cst_txn_cost_details
520 (
521 TRANSACTION_ID,
522 ORGANIZATION_ID,
523 INVENTORY_ITEM_ID,
524 COST_ELEMENT_ID,
525 LEVEL_TYPE,
526 TRANSACTION_COST,
527 NEW_AVERAGE_COST,
528 PERCENTAGE_CHANGE,
529 VALUE_CHANGE,
530 LAST_UPDATE_DATE,
531 LAST_UPDATED_BY,
532 CREATION_DATE,
533 CREATED_BY,
534 LAST_UPDATE_LOGIN,
535 REQUEST_ID,
536 PROGRAM_APPLICATION_ID,
537 PROGRAM_ID,
538 PROGRAM_UPDATE_DATE
539 )
540 VALUES
541 (
542 l_trx_id,
543 l_org_id,
544 l_inv_item_id,
545 1,
546 1,
547 0,
548 NULL,
549 NULL,
550 NULL,
551 SYSDATE,
552 l_user_id,
553 SYSDATE,
554 l_user_id,
555 l_login_id,
556 l_request_id,
557 l_prog_app_id,
558 l_prog_id,
559 SYSDATE
560 );
561
562 END IF;
563
564
565
566
567 -- For all txns call the cost processor, then the distribution
568 -- processor. Note that for scrap there is no avg cost recomputed though.
569
570 -- This calls the new FIFO cost processor
571
572 CSTPLVCP.cost_processor
573 (
574 i_org_id => l_org_id,
575 i_txn_id => l_trx_id,
576 i_layer_id => l_layer_id,
577 i_cost_type => l_cost_type_id,
578 i_cost_method => l_cost_method,
579 i_mat_ct_id => l_movhd_cost_type_id,
580 i_avg_rates_id => l_rates_cost_type_id,
581 i_item_id => l_inv_item_id,
582 i_txn_qty => l_txn_qty,
583 i_txn_action_id => l_action_id,
584 i_txn_src_type => 5,
585 i_txn_org_id => l_org_id,
586 i_txfr_org_id => NULL,
587 i_cost_grp_id => l_cost_grp_id,
588 i_txfr_cost_grp => l_txfr_cost_grp_id,
589 i_txfr_layer_id => NULL,
590 i_fob_point => NULL,
591 i_exp_item => l_exp_item_flag,
592 i_exp_flag => l_exp_flag,
593 i_citw_flag => 0,
594 i_flow_schedule => l_flow_schedule,
595 i_user_id => l_user_id,
596 i_login_id => l_login_id,
597 i_req_id => l_request_id,
598 i_prg_appl_id => l_prog_app_id,
599 i_prg_id => l_prog_id,
600 i_tprice_option => 0,
601 i_txf_price => 0,
602 o_err_num => l_err_num,
603 o_err_code => l_err_code,
604 o_err_msg => l_err_msg
605 );
606
607
608 /****************************************************
609 *Call distribution processor - if the avg cost proc**
610 *succeeds **
611 *****************************************************/
612
613 IF (l_err_num<>0) THEN
614 raise proc_fail;
615 ELSE
616
617 CSTPACDP.cost_txn
618 (
619 i_org_id => l_org_id,
620 i_txn_id => l_trx_id,
621 i_layer_id => l_layer_id,
622 i_fob_point => NULL,
623 i_exp_item => l_exp_item_flag,
624 I_COMM_ISS_FLAG => L_COMM_ISS_FLAG,
625 i_flow_schedule => l_flow_schedule,
626 I_USER_ID => l_user_id,
627 i_login_id => l_login_id,
628 i_req_id => l_request_id,
629 i_prg_appl_id => l_prog_app_id,
630 i_prg_id => l_prog_id,
631 i_tprice_option => 0,
632 i_txf_price => 0,
633 o_error_num => l_err_num,
634 o_error_code => l_err_code,
635 o_error_message => l_err_msg
636 );
637
638 END IF;
639
640
641
642 IF (l_err_num<>0) THEN
643 raise proc_fail;
644 END IF;
645
646 /* Create SLA Event */
647 l_trx_info.TRANSACTION_ID := l_trx_id;
648 l_trx_info.TXN_ACTION_ID := l_action_id;
649 l_trx_info.TXN_ORGANIZATION_ID := l_org_id;
650 l_trx_info.TXN_SRC_TYPE_ID := l_src_type_id;
651 l_trx_info.TRANSACTION_DATE := l_txn_date;
652
653 CST_XLA_PVT.Create_INVXLAEvent (
654 p_api_version => 1.0,
655 p_init_msg_list => FND_API.G_FALSE,
656 p_commit => FND_API.G_FALSE,
657 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
658 x_return_status => l_return_status,
659 x_msg_count => l_msg_count,
660 x_msg_data => l_msg_data,
661 p_trx_info => l_trx_info
662 );
663 IF l_return_status <> 'S' THEN
664 l_err_num := -1;
665 l_err_code := 'Error raising SLA Event for transaction: '||to_char(l_trx_id);
666 RAISE proc_fail;
667 END IF;
668
669
670 END IF; -- CITW condition check IF statement ends here.
671
672 /*---------------------------------------------------------
673 | If processing was succesful in the prior step, we need
674 | to update wip_period_balances.
675 |----------------------------------------------------------*/
676
677 stmt_num := 160;
678
679 select count(*)
680 into l_row_count
681 from mtl_cst_actual_cost_details
682 where transaction_id = l_trx_id;
683
684
685 IF (l_row_count <> 0) THEN
686
687 IF ( l_action_id = 1 OR
688 l_action_id = 27 OR
689 l_action_id = 33 OR
690 l_action_id = 34 ) THEN
691
692 CSTPACWB.cost_in
693 (
694 i_trx_id => l_trx_id,
695 i_layer_id => l_layer_id,
696 i_comm_iss_flag => l_comm_iss_flag,
697 I_COST_TXN_ACTION_ID => l_action_id,
698 i_txn_qty => l_txn_qty,
699 i_period_id => l_period_id,
700 i_wip_entity_id => l_wip_entity_id,
701 i_org_id => l_org_id,
702 i_user_id => l_user_id,
703 i_request_id => l_request_id,
704 err_num => l_err_num,
705 err_code => l_err_code,
706 err_msg => l_err_msg
707 );
708
709 /* Bug 3062249 - Call EAM API only if transaction is not CITW
710 This is because, distributions have not yet been created for
711 CITW txns. For these, EAM API will be called in CSTPACIN */
712 if (l_comm_iss_flag <> 1) then
713
714 /* Check if the job is EAM. If yes, then update material asset cost */
715 if (l_err_num = 0) then
716 select entity_type
717 into l_entity_type
718 from wip_entities
719 where wip_entity_id = l_wip_entity_id;
720
721 if (l_entity_type in (6,7)) then
722 CST_eamCost_PUB.process_matCost (
723 p_api_version => 1.0,
724 x_return_status => l_return_status,
725 x_msg_count => l_msg_count,
726 x_msg_data => l_msg_data,
727 p_txn_id => l_trx_id,
728 p_user_id => l_user_id,
729 p_request_id => l_request_id,
730 p_prog_id => l_prog_id,
731 p_prog_app_id => l_prog_app_id,
732 p_login_id => l_login_id
733 );
734
735 if (l_return_status <> fnd_api.g_ret_sts_success) then
736 CST_UTILITY_PUB.writelogmessages
737 ( p_api_version => 1.0,
738 p_msg_count => l_msg_count,
739 p_msg_data => l_msg_data,
740 x_return_status => l_msg_return_status );
741 l_err_num := l_msg_count;
742 else
743 l_err_num := 0;
744 end if;
745 end if;
746 end if;
747 end if; --not citw for EAM API check
748
749 ELSIF( (l_action_id = 31 OR
750 l_action_id = 32 OR
751 l_action_id = 30) AND l_exp_item_flag <>1 ) THEN
752
753 CSTPACWB.cost_out
754 (
755 i_trx_id => l_trx_id,
756 i_txn_qty => l_txn_qty,
757 i_period_id => l_period_id,
758 i_wip_entity_id => l_wip_entity_id,
759 i_org_id => l_org_id,
760 i_user_id => l_user_id,
761 i_request_id => l_request_id,
762 err_num => l_err_num,
763 err_code => l_err_code,
764 err_msg => l_err_msg
765 );
766
767 END IF;
768
769
770
771 -- Raise exception if there is an error in updating WPB.
772
773 IF (l_err_num<>0) THEN
774 raise proc_fail;
775 END IF;
776
777 END IF;
778
779
780
781
782 EXCEPTION
783
784 WHEN proc_fail THEN
785 err_num := l_err_num;
786 err_code := l_err_code;
787 err_msg := l_err_msg;
788 ROLLBACK;
789
790 WHEN OTHERS THEN
791 err_num := SQLCODE;
792 err_msg := 'CSTPLCWP:' || to_char(stmt_num) || substr(SQLERRM,1,150);
793 ROLLBACK;
794
795 END cost_wip_trx;
796
797
798 END CSTPLCWP;