DBA Data[Home] [Help]

PACKAGE: APPS.CST_EAMCOST_PUB

Source


1 PACKAGE CST_eamCost_PUB AS
2 /* $Header: CSTPEACS.pls 120.4.12010000.1 2008/07/24 17:22:08 appldev ship $ */
3 
4 /*=========================================================================== */
5 -- PROCEDURE
6 -- Process_MatCost
7 --
8 -- DESCRIPTION
9 -- This API retrieves  the charges of the costed MTL_MATERIAL_TRANSACTIONS
10 -- row, then called Update_eamCost to populate the eAM tables.
11 -- This API should be called for a specific MMT transaction which has been
12 -- costed successfully.
13 --
14 -- PURPOSE
15 -- To support eAM job costing for Rel 11i.6
16 --
17 -------------------------------------------------------------------------------
18 
19 PROCEDURE Process_MatCost(
20      p_api_version               IN      NUMBER,
21      p_init_msg_list             IN      VARCHAR2 := FND_API.G_FALSE,
22      p_commit                    IN      VARCHAR2 := FND_API.G_FALSE,
23      p_validation_level          IN      VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
24      x_return_status             OUT NOCOPY     VARCHAR2,
25      x_msg_count                 OUT NOCOPY     NUMBER,
26      x_msg_data                  OUT NOCOPY     VARCHAR2,
27      p_txn_id                    IN      NUMBER,
28      p_user_id                   IN      NUMBER,
29      p_request_id                IN      NUMBER,
30      p_prog_id                   IN      NUMBER,
31      p_prog_app_id               IN      NUMBER,
32      p_login_id                  IN      NUMBER
33      );
34 
35 /*=========================================================================== */
36 -- PROCEDURE
37 -- Process_ResCost
38 --
39 -- DESCRIPTION
40 -- This API processes all resources transactions in WIP_TRANSACTIONS for a
41 -- specified group id.  For each transaction, it identifies the correct
42 -- eAM cost element, department type, then populate eAM tables accordingly.
43 -- The calling program should ensure that all transactions for a
44 -- specific group id are costed successfully before calling this API.
45 --
46 -- PURPOSE
47 -- To support eAM job costing for Rel 11i.6
48 --
49 -------------------------------------------------------------------------------
50 
51 PROCEDURE Process_ResCost(
52           p_api_version               IN      NUMBER,
53           p_init_msg_list             IN      VARCHAR2 := FND_API.G_FALSE,
54           p_commit                    IN      VARCHAR2 := FND_API.G_FALSE,
55           p_validation_level          IN      VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
56           x_return_status             OUT NOCOPY     VARCHAR2,
57           x_msg_count                 OUT NOCOPY     NUMBER,
58           x_msg_data                  OUT NOCOPY     VARCHAR2,
59           p_group_id                  IN      NUMBER,
60           p_user_id                   IN      NUMBER,
61           p_request_id                IN      NUMBER,
62           p_prog_id                   IN      NUMBER,
63           p_prog_app_id               IN      NUMBER,
64           p_login_id                  IN      NUMBER
65           );
66 
67 /* ========================================================================== */
68 -- PROCEDURE
69 --   Update_eamCost
70 --
71 -- DESCRIPTION
72 --   This API insert or updates WIP_EAM_PERIOD_BALANCES and CST_EAM_ASSET_PER_BALANCES
73 --   with the amount passed by the calling program.
74 --
75 -- PURPOSE:
76 -- Support eAM job costing in Oracle Applications Rel 11i.6
77 --
78 --   PARAMETERS:
79 --   p_txn_mode:       indicates if it is a material cost (inventory items or direct
80 --                     item) or resource cost.  Values:
81 --                        1 = material transaction
82 --                        2 = resource transaction
83 --   p_wip_entity_id:   current job for which the charge is incurred
84 --   p_resource_id:     if it is a resource transaction (p_txn_mode = 2), a resource id
85 --                      must be passed by the calling program.
86 --                      Do not pass param for material or dept-based overhead.
87 --   p_res_seq_num:     if it is a resource transaction (p_txn_mode = 2),
88 --                      the operation resource seq num must be passed.
89 --                      Do not pass param for material or dept-based overhead.
90 --   p_value_type:      1 = actual cost
91 --                      2 = estimated cost
92 ---------------------------------------------------------------------------------------
93 
94 PROCEDURE Update_eamCost (
95           p_api_version                   IN      NUMBER,
96           p_init_msg_list                 IN      VARCHAR2 := FND_API.G_FALSE,
97           p_commit                        IN      VARCHAR2 := FND_API.G_FALSE,
98           p_validation_level              IN      VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
99           x_return_status                 OUT NOCOPY     VARCHAR2,
100           x_msg_count                     OUT NOCOPY     NUMBER,
101           x_msg_data                      OUT NOCOPY     VARCHAR2,
102           p_txn_mode                      IN      NUMBER, -- 1=material 2=resource
103           p_period_id                     IN      NUMBER := null, -- period where cost s/b charged
104           p_period_set_name               IN      VARCHAR2 := null,
105           p_period_name                   IN      VARCHAR2 := null,
106           p_org_id                        IN      NUMBER,
107           p_wip_entity_id                 IN      NUMBER,
108           p_opseq_num                     IN      NUMBER, -- routing operation sequence
109           p_resource_id                   IN      NUMBER := null,
110           p_res_seq_num                   IN      NUMBER := null,
111           p_value_type                    IN      NUMBER, -- 1=actual, 2=estimated
112           p_value                         IN      NUMBER,
113           p_user_id                       IN      NUMBER,
114           p_request_id                    IN      NUMBER,
115           p_prog_id                       IN      NUMBER,
116           p_prog_app_id                   IN      NUMBER,
117           p_login_id                      IN      NUMBER,
118           p_txn_date                      IN      VARCHAR2 DEFAULT to_char(sysdate,'YYYY/MM/DD HH24:MI:SS'),
119           p_txn_id                          IN          NUMBER DEFAULT -1
120           );
121 
122 /* ======================================================================== */
123 -- PROCEDURE
124 -- InsertUpdate_eamPerBal
125 --
126 -- DESCRIPTION
127 -- This procedure inserts or updates a row in wip_eam_period_balances table,
128 -- according to the parameters passed by the calling program.
129 -- Subsequently, it also inserts or update the related row in
130 -- cst_eam_asset_per_balances.
131 --
132 -- PURPOSE
133 -- Oracle Application Rel 11i.6
134 -- eAM Job Costing support
135 --
136 -- PARAMETERS
137 --        p_period_id
138 --        p_period_set_name  : for an open period, passing period id,
139 --                             instead of set name and period name,
140 --                             would be sufficient
141 --        p_period_name
142 --        p_org_id
143 --        p_wip_entity_id
144 --        p_dept_id          : department assigned to operation
145 --        p_owning_id        : department owning resource
146 --        p_dept_type_id     : department tyoe of cost incurred
147 --        p_opseq_num        : routing op seq
148 --        p_eam_cost_element : eam cost element id
149 --        p_asset_group_id   : inventory item id
150 --        p_asset_number     : serial number of asset item
151 --        p_value_type       : 1= actual cost, 2=system estimated cost
152 --        p_value            : cost amount
153 --
154 ------------------------------------------------------------------------------
155 
156 PROCEDURE InsertUpdate_eamPerBal (
157           p_api_version                   IN      NUMBER,
158           p_init_msg_list                 IN      VARCHAR2 := FND_API.G_FALSE,
159           p_commit                        IN      VARCHAR2 := FND_API.G_FALSE,
160           p_validation_level              IN      VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
161           x_return_status                 OUT NOCOPY     VARCHAR2,
162           x_msg_count                     OUT NOCOPY     NUMBER,
163           x_msg_data                      OUT NOCOPY     VARCHAR2,
164           p_period_id                     IN      NUMBER := null,
165           p_period_set_name               IN      VARCHAR2 := null,
166           p_period_name                   IN      VARCHAR2 := null,
167           p_org_id                        IN      NUMBER,
168           p_wip_entity_id                 IN      NUMBER,
169           p_owning_dept_id                IN      NUMBER,
170           p_dept_id                       IN      NUMBER,
171           p_maint_cost_cat                IN      NUMBER,
172           p_opseq_num                     IN      NUMBER,
173           p_eam_cost_element              IN      NUMBER,
174           p_asset_group_id                IN      NUMBER,
175           p_asset_number                  IN      VARCHAR2,
176           p_value_type                    IN      NUMBER,
177           p_value                         IN      NUMBER,
178           p_user_id                       IN      NUMBER,
179           p_request_id                    IN      NUMBER,
180           p_prog_id                       IN      NUMBER,
181           p_prog_app_id                   IN      NUMBER,
182           p_login_id                      IN      NUMBER,
183           p_txn_date                      IN      VARCHAR2 DEFAULT to_char(sysdate,'YYYY/MM/DD HH24:MI:SS')
184           ) ;
185 
186 /* ========================================================================= */
187 -- PROCEDURE
188 -- InsertUpdate_assetPerBal
189 --
190 -- DESCRIPTION
191 --
192 -- PURPOSE
193 -- Oracle Application Rel 11i.5
194 -- eAM Job Costing support
195 --
196 -- PARAMETERS
197 --        p_period_id
198 --        p_period_set_name  : for an open period, passing period id,
199 --                             instead of set name and period name,
200 --                             would be sufficient
201 --        p_period_name
202 --        p_org_id
203 --        p_maint_cost_dat   : department tyoe of cost incurred
204 --        p_eam_cost_element : eam cost element id
205 --        p_asset_group_id   : inventory item id
206 --        p_asset_number     : serial number of asset item
207 --        p_value_type       : 1= actual cost, 2=system estimated cost
208 --        p_value            : cost amount
209 --        p_maint_obj_id     : CII.instance_id if serialized asset or
210 --                             serialized rebuildable item, MSI.inventory_item_id
211 --                             if non-serialized rebuildable item.
212 --        p_maint_obj_type   : 3 if serialized asset or serialized rebuildable
213 --                             item, 2 if non-serialized rebuildable item
214 --
215 -- HISTORY
216 --    09/18/02      Anitha     Initial creation
217 --
218 ------------------------------------------------------------------------------
219 
220 PROCEDURE InsertUpdate_assetPerBal (
221           p_api_version                   IN      NUMBER,
222           p_init_msg_list                 IN      VARCHAR2 := FND_API.G_FALSE,
223           p_commit                        IN      VARCHAR2 := FND_API.G_FALSE,
224           p_validation_level              IN      VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
225           x_return_status                 OUT NOCOPY     VARCHAR2,
226           x_msg_count                     OUT NOCOPY     NUMBER,
227           x_msg_data                      OUT NOCOPY     VARCHAR2,
228           p_period_id                     IN      NUMBER := null,
229           p_period_set_name               IN      VARCHAR2 := null,
230           p_period_name                   IN      VARCHAR2 := null,
231           p_org_id                        IN      NUMBER,
232           p_maint_cost_cat                IN      NUMBER,
233           p_asset_group_id                IN      NUMBER,
234           p_asset_number                  IN      VARCHAR2,
235           p_value                         IN      NUMBER,
236           p_column                        IN      VARCHAR2,
237           p_col_type                      IN      NUMBER,
238           p_period_start_date             IN      DATE,
239           p_maint_obj_id                  IN          NUMBER,
240           p_maint_obj_type                IN      NUMBER,
241           p_user_id                       IN      NUMBER,
242           p_request_id                    IN      NUMBER,
243           p_prog_id                       IN      NUMBER,
244           p_prog_app_id                   IN      NUMBER,
245           p_login_id                      IN      NUMBER
246           );
247 
248 
249 /* ============================================================== */
250 -- FUNCTION
251 -- Get_eamCostElement()
252 --
253 -- DESCRIPTION
254 -- Function to return the correct eAM cost element, based on
255 -- the transaction mode and the resource id of a transaction.
256 --
257 -- PARAMETERS
258 -- p_txn_mode (1=material, 2=resource)
259 -- p_org_id
260 -- p_resource_id (optional; to be passed only for a resource tranx)
261 --
262 /* ================================================================= */
263 
264 FUNCTION Get_eamCostElement(
265           p_txn_mode             IN  NUMBER,
266           p_org_id               IN  NUMBER,
267           p_resource_id          IN  NUMBER := null)
268    RETURN number;
269 
270 /* ==================================================================== */
271 -- PROCEDURE
272 -- Get_MaintCostCat
273 --
274 -- DESCRIPTION
275 --
276 -- This procedure identifies the using, owning departments and the
277 -- related maint. cost cat for a resource or overhead charge based
278 -- on the transaction mode, wip entity id, routing operation, and
279 -- resource id.
280 /* ==================================================================== */
281 
282 PROCEDURE Get_MaintCostCat(
283           p_txn_mode           IN       NUMBER,
284           p_wip_entity_id      IN       NUMBER,
285           p_opseq_num          IN       NUMBER,
286           p_resource_id        IN       NUMBER := null,
287           p_res_seq_num        IN       NUMBER := null,
288           x_return_status      OUT NOCOPY      VARCHAR2,
292           );
289           x_operation_dept     OUT NOCOPY      NUMBER,
290           x_owning_dept        OUT NOCOPY      NUMBER,
291           x_maint_cost_cat     OUT NOCOPY      NUMBER
293 
294 /* =====================================================================  */
295 -- PROCEDURE                                                              --
296 --   Delete_eamPerBal                                                     --
297 -- DESCRIPTION                                                            --
298 --   This API removes the cost of a specific type, such as system         --
299 --   or manual estimates from wip_eam_per_balances and delete the rows    --
300 --   if all the costs are zeros.  It also update the corresponding amount --
301 --   It also update the corresponding amount in                           --
302 --   cst_eam_asset_per_balances.                                          --
303 --   NOTE:  This process is at the wip entity level.                      --
304 --                                                                        --
305 --   p_type = 1  (system estimates)                                       --
306 --            2 (manual estimates)                                        --
307 -- PURPOSE:                                                               --
308 --   Oracle Applications Rel 11i.6                                        --
309 -- HISTORY:                                                               --
310 --    05/02/01      Dieu-thuong Le        Initial creation                --
311 /* ======================================================================= */
312 
313 PROCEDURE Delete_eamPerBal (
314           p_api_version         IN       NUMBER,
315           p_init_msg_list       IN       VARCHAR2 := FND_API.G_FALSE,
316           p_commit              IN       VARCHAR2 := FND_API.G_FALSE,
317           p_validation_level    IN       VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
318           x_return_status       OUT NOCOPY      VARCHAR2,
319           x_msg_count           OUT NOCOPY      NUMBER,
320           x_msg_data            OUT NOCOPY      VARCHAR2,
321           p_entity_id_tab         IN      CSTPECEP.wip_entity_id_type,
322           p_org_id              IN       NUMBER,
323           p_type                IN       NUMBER :=1
324           );
325 
326 
327 ----------------------------------------------------------------------------
328 -- PROCEDURE                                                              --
329 --   Compute_Job_Estimate                                                 --
330 --                                                                        --
331 --                                                                        --
332 -- DESCRIPTION                                                            --
333 --   This API Computes the estimate for a Job                             --
334 --                                                                        --
335 -- PURPOSE:                                                               --
336 --   Oracle Applications Rel 11i.6                                        --
337 --                                                                        --
338 --                                                                        --
339 -- HISTORY:                                                               --
340 --    04/17/01     Hemant G       Created                                 --
341 ----------------------------------------------------------------------------
342 
343 PROCEDURE Compute_Job_Estimate (
344                             p_api_version        IN   NUMBER,
345                             p_init_msg_list      IN   VARCHAR2
346                                                   := FND_API.G_FALSE,
347                             p_commit             IN   VARCHAR2
348                                                   := FND_API.G_FALSE,
349                             p_validation_level   IN   NUMBER
350                                                   := FND_API.G_VALID_LEVEL_FULL,
351                             p_debug              IN   VARCHAR2 := 'N',
352                             p_wip_entity_id      IN   NUMBER,
353 
354                             p_user_id            IN   NUMBER,
355                             p_request_id         IN   NUMBER,
356                             p_prog_id            IN   NUMBER,
357                             p_prog_app_id        IN   NUMBER,
358                             p_login_id           IN   NUMBER,
359 
360                             x_return_status      OUT NOCOPY  VARCHAR2,
361                             x_msg_count          OUT NOCOPY  NUMBER,
362                             x_msg_data           OUT NOCOPY  VARCHAR2 );
363 ----------------------------------------------------------------------------
364 -- PROCEDURE                                                              --
365 --   Rollup_Cost                                                          --
366 --                                                                        --
367 --                                                                        --
368 -- DESCRIPTION                                                            --
369 --   This API Computes RollUp Cost for an asset Item                      --
370 --                                                                        --
371 -- PURPOSE:                                                               --
372 --   Oracle Applications Rel 11i.6                                        --
373 --                                                                        --
374 --                                                                        --
375 -- HISTORY:                                                               --
379            p_api_version                IN NUMBER,
376 --    04/17/01     Terence Chan         Genesis                                  --
377 ----------------------------------------------------------------------------
378 PROCEDURE Rollup_Cost (
380         p_init_msg_list                        IN VARCHAR2 := FND_API.G_FALSE ,
381         p_commit                        IN VARCHAR2 := FND_API.G_FALSE ,
382         p_validation_level                IN NUMBER   := FND_API.G_VALID_LEVEL_FULL ,
383         x_return_status                        OUT NOCOPY VARCHAR2 ,
384         x_msg_count                        OUT NOCOPY NUMBER ,
385         x_msg_data                        OUT NOCOPY VARCHAR2 ,
386 
387         p_inventory_item_id                   IN NUMBER ,
388         p_serial_number                       IN VARCHAR2 ,
389         P_period_set_name                IN VARCHAR2 ,
390         p_beginning_period_name         IN VARCHAR2 ,
391         p_ending_period_name                 IN VARCHAR2 ,
392 
393         x_group_id                            OUT NOCOPY NUMBER );
394 
395 
396 ----------------------------------------------------------------------------
397 -- PROCEDURE                                                              --
398 --   Purge_Rollup_Cost                                                    --
399 --                                                                        --
400 --                                                                        --
401 -- DESCRIPTION                                                            --
402 --   This API Purge Computes RollUp Cost for an asset Item                --
403 --                                                                        --
404 -- PURPOSE:                                                               --
405 --   Oracle Applications Rel 11i.6                                        --
406 --                                                                        --
407 --                                                                        --
408 -- HISTORY:                                                               --
409 --    04/17/01     Terence Chan         Genesis                                  --
410 ----------------------------------------------------------------------------
411 PROCEDURE Purge_Rollup_Cost (
412            p_api_version                IN NUMBER,
413         p_init_msg_list                        IN VARCHAR2 := FND_API.G_FALSE ,
414         p_commit                        IN VARCHAR2 := FND_API.G_FALSE ,
415         p_validation_level                IN NUMBER   := FND_API.G_VALID_LEVEL_FULL ,
416         x_return_status                        OUT NOCOPY VARCHAR2 ,
417         x_msg_count                        OUT NOCOPY NUMBER ,
418         x_msg_data                        OUT NOCOPY VARCHAR2 ,
419 
420         p_group_id                            IN NUMBER );
421 
422 
423 ----------------------------------------------------------------------------
424 -- PROCEDURE                                                              --
425 --   check_if_direct_item                                                 --
426 --                                                                        --
427 -- DESCRIPTION                                                            --
428 --   checks if this is a direct item transaction                          --
429 --    * Organization should be EAM enabled                                --
430 --    * Destination should be EAM job                                     --
431 --    * Item number is null or the item should not be of type OSP         --
432 -- PURPOSE:                                                               --
433 --    Called by the function process_OSP_Transaction in the receiving     --
434 --    transaction processor                                               --
435 --                                                                        --
436 -- HISTORY:                                                               --
437 --    05/01/01  Anitha Dixit    Created                                          --
438 ----------------------------------------------------------------------------
439 
440 PROCEDURE check_if_direct_item (
441                 p_api_version                        IN        NUMBER,
442                  p_init_msg_list                        IN        VARCHAR2 := FND_API.G_FALSE,
443                 p_commit                        IN        VARCHAR2 := FND_API.G_FALSE,
444                 p_validation_level                IN        VARCHAR2 DEFAULT FND_API.G_VALID_LEVEL_FULL,
445 
446                 p_interface_txn_id              IN      NUMBER,
447 
448                 x_direct_item_flag              OUT NOCOPY     NUMBER,
449                 x_return_status                        OUT NOCOPY        VARCHAR2,
450                 x_msg_count                        OUT NOCOPY        NUMBER,
451                 x_msg_data                        OUT NOCOPY        VARCHAR2
452                 );
453 
454 
455 ----------------------------------------------------------------------------
456 -- PROCEDURE                                                              --
457 --   process_direct_item_txn                                              --
458 -- DESCRIPTION                                                            --
459 --   This is the wrapper function to do direct item costing               --
460 --    * Inserts transaction into wip_cost_txn_interface                   --
461 -- PURPOSE:                                                               --
462 --    API to process direct item transaction. Called from the function    --
463 --    process_OSP_transaction in the receiving transaction processor      --
464 -- HISTORY:                                                               --
468 PROCEDURE process_direct_item_txn (
465 --    05/01/01          Anitha Dixit        Created                                  --
466 ----------------------------------------------------------------------------
467 
469                 p_api_version                        IN        NUMBER,
470                  p_init_msg_list                        IN        VARCHAR2 := FND_API.G_FALSE,
471                 p_commit                        IN        VARCHAR2 := FND_API.G_FALSE,
472                 p_validation_level                IN        VARCHAR2 DEFAULT FND_API.G_VALID_LEVEL_FULL,
473 
474                 p_directItem_rec                IN      WIP_Transaction_PUB.Res_Rec_Type,
475 
476                 x_directItem_rec                IN OUT NOCOPY     WIP_Transaction_PUB.Res_Rec_Type,
477                 x_return_status                        OUT NOCOPY        VARCHAR2,
478                 x_msg_count                        OUT NOCOPY        NUMBER,
479                 x_msg_data                        OUT NOCOPY        VARCHAR2
480                 );
481 
482 
483 ----------------------------------------------------------------------------
484 -- PROCEDURE                                                              --
485 --   cost_direct_item_txn                                                 --
486 -- DESCRIPTION                                                            --
487 --   cost a transaction record from wip_cost_txn_interface                --
488 --    * new transaction type called Direct Shopfloor Delivery             --
489 --    * called by cmlctw                                                  --
490 --    * inserts debits and credits into wip_transaction_accounts          --
491 --    * update eam asset cost and asset period balances                   --
492 -- PURPOSE:                                                               --
493 --   procedure that costs a direct item transaction and does              --
494 --   accounting                                                           --
495 -- HISTORY:                                                               --
496 --   05/01/01           Anitha Dixit            Created                   --
497 ----------------------------------------------------------------------------
498 PROCEDURE cost_direct_item_txn (
499                 p_api_version                   IN      NUMBER,
500                 p_init_msg_list                 IN      VARCHAR2 := FND_API.G_FALSE,
501                 p_commit                        IN      VARCHAR2 := FND_API.G_FALSE,
502                 p_validation_level              IN      VARCHAR2 DEFAULT FND_API.G_VALID_LEVEL_FULL,
503 
504                 p_group_id                      IN      NUMBER,
505                 p_prg_appl_id                   IN      NUMBER,
506                 p_prg_id                        IN      NUMBER,
507                 p_request_id                    IN      NUMBER,
508                 p_user_id                       IN      NUMBER,
509                 p_login_id                      IN      NUMBER,
510 
511                 x_return_status                 OUT NOCOPY     VARCHAR2,
512                 x_msg_count                     OUT NOCOPY     NUMBER,
513                 x_msg_data                      OUT NOCOPY     VARCHAR2
514                 );
515 
516 
517 ----------------------------------------------------------------------------
518 -- PROCEDURE                                                              --
519 --   insert_direct_item_distr                                             --
520 --                                                                        --
521 -- DESCRIPTION                                                            --
522 --   insert accounting into wip_transaction_accounts                      --
523 --    * WIP valuation account used is material account                    --
524 --    * Offset against Receiving Inspection account                       --
525 --    * Accounting done at actuals (PO price + non recoverable tax)       --
526 -- PURPOSE:                                                               --
527 --   insert accounting into wip_transaction_accounts                      --
528 -- HISTORY:                                                               --
529 --   05/01/01           Anitha Dixit                Created                          --
530 --                      Vinit                   Added p_base_txn_value    --
531 --                                              parameter                 --
532 ----------------------------------------------------------------------------
533 PROCEDURE insert_direct_item_distr (
534                 p_api_version                        IN        NUMBER,
535                  p_init_msg_list                        IN        VARCHAR2 := FND_API.G_FALSE,
536                 p_commit                        IN        VARCHAR2 := FND_API.G_FALSE,
537                 p_validation_level                IN        VARCHAR2 DEFAULT FND_API.G_VALID_LEVEL_FULL,
538 
539                 p_txn_id                        IN         NUMBER,
540                 p_ref_acct                        IN        NUMBER,
541                 p_txn_value                        IN        NUMBER,
542                 p_base_txn_value                IN      NUMBER,
543                 p_wip_entity_id                        IN        NUMBER,
544                 p_acct_line_type                IN        NUMBER,
545                 p_prg_appl_id                   IN      NUMBER,
546                 p_prg_id                        IN      NUMBER,
547                 p_request_id                    IN      NUMBER,
548                 p_user_id                       IN      NUMBER,
549                 p_login_id                      IN      NUMBER,
550 
551                 x_return_status                        OUT NOCOPY        VARCHAR2,
555 
552                 x_msg_count                        OUT NOCOPY        NUMBER,
553                 x_msg_data                        OUT NOCOPY        VARCHAR2
554                 );
556 ----------------------------------------------------------------------------
557 -- PROCEDURE                                                              --
558 --   update_wip_period_balances                                           --
559 -- DESCRIPTION                                                            --
560 --   This function updates the tl_material_in in wip_period_balances      --
561 --   for the Direct Item Shopfloor delivery transaction                   --
562 -- PURPOSE:                                                               --
563 --   Oracle Applications - Enterprise asset management                    --
564 --   Beta on 11i Patchset G                                               --
565 --   Costing Support for EAM                                              --
566 --                                                                        --
567 -- HISTORY:                                                               --
568 --    07/18/01                  Anitha Dixit            Created           --
569 ----------------------------------------------------------------------------
570 PROCEDURE update_wip_period_balances (
571                     p_api_version        IN   NUMBER,
572                     p_init_msg_list      IN   VARCHAR2 := FND_API.G_FALSE,
573                     p_commit             IN   VARCHAR2 := FND_API.G_FALSE,
574                     p_validation_level   IN   NUMBER := FND_API.G_VALID_LEVEL_FULL,
575 
576                     p_wip_entity_id      IN   NUMBER,
577                     p_acct_period_id     IN   NUMBER,
578                     p_txn_id             IN   NUMBER,
579                     p_prg_appl_id        IN   NUMBER,
580                     p_prg_id             IN   NUMBER,
581                     p_request_id         IN   NUMBER,
582                     p_user_id            IN   NUMBER,
583                     p_login_id           IN   NUMBER,
584 
585                     x_return_status      OUT NOCOPY  VARCHAR2,
586                     x_msg_count          OUT NOCOPY  NUMBER,
587                     x_msg_data           OUT NOCOPY  VARCHAR2 );
588 
589 ----------------------------------------------------------------------------
590 -- PROCEDURE                                                              --
591 --   insert_direct_item_txn                                               --
592 -- DESCRIPTION                                                            --
593 --   insert a transaction record into wip_transactions                    --
594 --    * new transaction type called Direct Shopfloor Delivery             --
595 --    * called by cost_direct_item_txn                                    --
596 -- PURPOSE:                                                               --
597 --   procedure that inserts a transaction into wip_transactions and       --
598 --   deletes the record from wip_cost_txn_interface                       --
599 -- HISTORY:                                                               --
600 --   05/01/01           Anitha Dixit            Created                   --
601 ----------------------------------------------------------------------------
602 PROCEDURE insert_direct_item_txn (
603                 p_api_version                   IN      NUMBER,
604                 p_init_msg_list                 IN      VARCHAR2 := FND_API.G_FALSE,
605                 p_commit                        IN      VARCHAR2 := FND_API.G_FALSE,
606                 p_validation_level              IN      VARCHAR2 DEFAULT FND_API.G_VALID_LEVEL_FULL,
607 
608                 p_group_id                      IN      NUMBER,
609                 p_prg_appl_id                   IN      NUMBER,
610                 p_prg_id                        IN      NUMBER,
611                 p_request_id                    IN      NUMBER,
612                 p_user_id                       IN      NUMBER,
613                 p_login_id                      IN      NUMBER,
614 
615                 x_return_status                 OUT NOCOPY     VARCHAR2,
616                 x_msg_count                     OUT NOCOPY     NUMBER,
617                 x_msg_data                      OUT NOCOPY     VARCHAR2
618                 );
619 
620 ----------------------------------------------------------------------------
621 -- PROCEDURE                                                              --
622 --   get_Direct_Item_Charge_Acct                                          --
623 --                                                                        --
624 -- DESCRIPTION                                                            --
625 --  This API determines returns the material account number
626 --  given a EAM job (entity type = 6,7)                                   --
627 --  If the wip identity doesn't refer to an EAM job type then             --
628 --  -1 is returned, -1 is also returned if material account is not        --
629 --  defined for that particular wip entity.
630 --
631 --  This API has been moved to CST_Utility_PUB to limit dependencies for  --
632 --  PO.  Any changes J (11.5.10) and higher made to this API should NOT be--
633 --  made here, but at CST_Utiltiy_PUB.get_Direct_Item_Charge_Acct.
634 --
635 -- PURPOSE:                                                               --
636 --   Oracle Applications Rel 11i.6                                        --
637 --   Costing Support for EAM                                              --
638 --   Called by the PO account generator
639 --                                                                        --
640 --                                                                        --
644 PROCEDURE get_Direct_Item_Charge_Acct (
641 -- HISTORY:                                                               --
642 --    07/18/01          Vinit Srivastava         Created
643 ----------------------------------------------------------------------------
645                             p_api_version        IN   NUMBER,
646                             p_init_msg_list      IN   VARCHAR2
647                                                 := FND_API.G_FALSE,
648                             p_commit             IN   VARCHAR2
649                                                 := FND_API.G_FALSE,
650                             p_validation_level   IN   NUMBER
651                                                 := FND_API.G_VALID_LEVEL_FULL,
652                             p_wip_entity_id      IN   NUMBER DEFAULT NULL,
653                             x_material_acct     OUT NOCOPY  NUMBER,
654                             x_return_status      OUT NOCOPY  VARCHAR2,
655                             x_msg_count          OUT NOCOPY  NUMBER,
656                             x_msg_data           OUT NOCOPY  VARCHAR2 );
657 
658 ----------------------------------------------------------------------------
659 -- PROCEDURE                                                              --
660 --  validate_for_reestimation                                             --
661 --                                                                        --
662 -- DESCRIPTION                                                            --
663 --  validates if the re-estimation flag on the work order value summary   --
664 --  form, can be updated                                                  --
665 --    * Calls validate_est_status_hook. If hook is used, default          --
666 --      validation will be overridden                                     --
667 --    * Default Validation :                                              --
668 --      If curr_est_status is Complete, flag can be checked to re-estimate -
669 --      If curr_est_status is Re-estimate, flag can be unchecked to complete
670 -- PURPOSE:                                                               --
671 --    called by work order value summary form                             --
672 --                                                                        --
673 -- HISTORY:                                                               --
674 --    08/26/01  Anitha Dixit    Created                                   --
675 ----------------------------------------------------------------------------
676 PROCEDURE validate_for_reestimation (
677                 p_api_version           IN      NUMBER,
678                 p_init_msg_list         IN      VARCHAR2 := fnd_api.g_false,
679                 p_commit                IN      VARCHAR2 := fnd_api.g_false,
680                 p_validation_level      IN      VARCHAR2 DEFAULT fnd_api.g_valid_level_full,
681 
682                 p_wip_entity_id         IN      NUMBER,
683                 p_job_status            IN      NUMBER,
684                 p_curr_est_status       IN      NUMBER,
685 
686                 x_validate_flag         OUT NOCOPY     NUMBER,
687                 x_return_status         OUT NOCOPY     VARCHAR2,
688                 x_msg_count             OUT NOCOPY     NUMBER,
689                 x_msg_data              OUT NOCOPY     VARCHAR2
690                 );
691 
692 ----------------------------------------------------------------------------
693 -- PROCEDURE                                                              --
694 --   Redistribute_WIP_Accounts                                            --
695 --                                                                        --
696 --                                                                        --
697 -- DESCRIPTION                                                            --
698 --   This API redistributes  accounts values from the Accounting class    --
699 --   of the route job to the accounting class of the memeber assets.      --
700 --   It does so for the variance accounts of the corresponding WACs.      --
701 --   This API should be called from period close(CSTPWPVR)                --
702 --   and job close (cmlwjv)                                               --
703 --                                                                        --
704 -- PURPOSE:                                                               --
705 --   Oracle Applications Rel 11i.9                                        --
706 --                                                                        --
707 --                                                                        --
708 -- HISTORY:                                                               --
709 --   11/26/02  Anitha         Modified to support close through SRS       --
710 --                            merged accounting entry creation into       --
711 --                            single SQL against the job close txn        --
712 --   09/26/02  Hemant G       Created                                     --
713 ----------------------------------------------------------------------------
714 PROCEDURE Redistribute_WIP_Accounts (
715                             p_api_version        IN   NUMBER,
716                             p_init_msg_list      IN   VARCHAR2 := FND_API.G_FALSE,
717                             p_commit             IN   VARCHAR2 := FND_API.G_FALSE,
718                             p_validation_level   IN   VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
719                             p_wcti_group_id      IN   NUMBER,
720 
721                             p_user_id            IN   NUMBER,
722                             p_request_id         IN   NUMBER,
723                             p_prog_id            IN   NUMBER,
724                             p_prog_app_id        IN   NUMBER,
728                             x_msg_count          OUT  NOCOPY NUMBER,
725                             p_login_id           IN   NUMBER,
726 
727                             x_return_status      OUT  NOCOPY VARCHAR2,
729                             x_msg_data           OUT  NOCOPY VARCHAR2 );
730 
731 ----------------------------------------------------------------------------
732 -- PROCEDURE                                                              --
733 --  get_charge_asset                                                      --
734 --                                                                        --
735 -- DESCRIPTION                                                            --
736 --  This API will be called instead of obtaining charge asset             --
737 --  from wdj.asset_group_id                                               --
738 --  It will provide support for the following                             --
739 --   * regular asset work orders                                          --
740 --   * rebuild work orders with parent asset                              --
741 --   * standalone rebuild work orders                                     --
742 --   * installed base items - future                                      --
743 -- PURPOSE:                                                               --
744 --   Oracle Applications 11i.9                                            --
745 --                                                                        --
746 -- HISTORY:                                                               --
747 --    11/26/02  Ray Thng    Created                                       --
748 ----------------------------------------------------------------------------
749   PROCEDURE get_charge_asset (
750     p_api_version               IN         NUMBER,
751     p_init_msg_list             IN         VARCHAR2 := FND_API.G_FALSE,
752     p_wip_entity_id             IN         NUMBER,
753     x_inventory_item_id         OUT NOCOPY csi_item_instances.inventory_item_id%TYPE,
754     x_serial_number             OUT NOCOPY csi_item_instances.serial_number%TYPE,
755     x_maintenance_object_id     OUT NOCOPY mtl_serial_numbers.gen_object_id%TYPE,
756     x_return_status             OUT NOCOPY VARCHAR2,
757     x_msg_count                 OUT NOCOPY NUMBER,
758     x_msg_data                  OUT NOCOPY VARCHAR2);
759 
760 ----------------------------------------------------------------------------
761 -- PROCEDURE                                                              --
762 --  get_CostEle_for_DirectItem                                            --
763 --                                                                        --
764 -- DESCRIPTION                                                            --
765 --   This API will return which cost element ID is to be charged for the  --
766 --   the direct item transactions                                         --
767 -- PURPOSE:                                                               --
768 --   Oracle Applications 11i.10                                           --
769 --                                                                        --
770 -- HISTORY:                                                               --
771 --    06/26/03  Linda Soo        Created                                   --
772 --    27/26/05  Siddharth Khanna Added var p_pac_or_perp which is 1 when  --
773 --                               called from PAC code. eAM support in PAC --
774 ----------------------------------------------------------------------------
775   PROCEDURE get_CostEle_for_DirectItem (
776     p_api_version               IN         NUMBER,
777     p_init_msg_list             IN         VARCHAR2 := FND_API.G_FALSE,
778     p_commit                    IN           VARCHAR2 := FND_API.G_FALSE,
779     p_validation_level          IN           NUMBER := FND_API.G_VALID_LEVEL_FULL,
780     p_txn_id                    IN           NUMBER,
781     p_mnt_or_mfg                IN           NUMBER, -- 1: eam cost element,
782                                                    -- 2: manufacturing cost ele
783     p_pac_or_perp               IN         NUMBER := 0, -- 1 for PAC, 0 for Perpetual
784     x_cost_element_id           OUT NOCOPY NUMBER,
785     x_return_status             OUT NOCOPY VARCHAR2,
786     x_msg_count                 OUT NOCOPY NUMBER,
787     x_msg_data                  OUT NOCOPY VARCHAR2);
788 
789 ----------------------------------------------------------------------------
790 -- PROCEDURE                                                              --
791 --  get_ExpType_for_DirectItem                                            --
792 --                                                                        --
793 -- DESCRIPTION                                                            --
794 --   *
795 -- PURPOSE:                                                               --
796 --   Oracle Applications 11i.9                                            --
797 --                                                                        --
798 -- HISTORY:                                                               --
799 --    06/26/03  Linda Soo        Created                                   --
800 ----------------------------------------------------------------------------
801   PROCEDURE get_ExpType_for_DirectItem (
802     p_api_version               IN         NUMBER,
803     p_init_msg_list             IN         VARCHAR2 := FND_API.G_FALSE,
804     p_commit                    IN           VARCHAR2 := FND_API.G_FALSE,
805     p_validation_level          IN           NUMBER := FND_API.G_VALID_LEVEL_FULL,
806     p_txn_id                    IN           NUMBER,
807     x_expenditure_type          OUT NOCOPY VARCHAR2,
811 
808     x_return_status             OUT NOCOPY VARCHAR2,
809     x_msg_count                 OUT NOCOPY NUMBER,
810     x_msg_data                  OUT NOCOPY VARCHAR2);
812 ----------------------------------------------------------------------------
813 -- PROCEDURE                                                              --
814 --  Rollup_WorkOrderCost                                                  --
815 --                                                                        --
816 -- DESCRIPTION                                                            --
817 --  This procedure can be called to rollup the cost in a work order       --
818 --  hierarchy. The hierarchy must already be inserted in                  --
819 --  CST_EAM_HIEARCHY_SNAPSHOT.                                            --
820 --  For more information about this procedure, visit:                     --
821 --  http://www-apps.us.oracle.com:1100/cst/project/rel11i.10proj/WOCR/    --
822 ----------------------------------------------------------------------------
823   PROCEDURE Rollup_WorkOrderCost (
824     p_api_version     IN         NUMBER,
825     p_init_msg_list   IN         VARCHAR2 := FND_API.G_FALSE,
826     p_commit          IN         VARCHAR2 := FND_API.G_FALSE,
827     p_group_id        IN         NUMBER,
828     p_organization_id IN         NUMBER,
829     p_user_id         IN         NUMBER,
830     p_prog_appl_id    IN         NUMBER,
831     x_return_status   OUT NOCOPY VARCHAR2);
832 
833 ----------------------------------------------------------------------------
834 -- PROCEDURE                                                              --
835 --  Purge_RollupCost                                                      --
836 --                                                                        --
837 -- DESCRIPTION                                                            --
838 --  This procedure can be called to remove temporary cost rollup          --
839 --  information in CST_EAM_HIEARCHY_SNAPSHOT and CST_EAM_ROLLUP_COSTS.    --
840 --  For more information about this procedure, visit:                     --
841 --  http://www-apps.us.oracle.com:1100/cst/project/rel11i.10proj/WOCR/    --
842 ----------------------------------------------------------------------------
843   PROCEDURE Purge_RollupCost (
844     p_api_version      IN         NUMBER,
845     p_init_msg_list    IN         VARCHAR2 := FND_API.G_FALSE,
846     p_commit          IN         VARCHAR2 := FND_API.G_FALSE,
847     p_group_id         IN         NUMBER   := NULL,
848     p_prog_appl_id     IN         NUMBER   := NULL,
849     p_last_update_date IN         DATE     := NULL,
850     x_return_status    OUT NOCOPY VARCHAR2);
851 
852 
853 
854 --------------------------------------------------------------------------
855 --      API name        : Insert_eamBalAcct
856 --      Type            : Public
857 --      Function        : This API inserts data in CST_EAM_BALANCE_BY_ACCOUNTS
858 --                        table.
859 --      Pre-reqs        : None.
860 --      Parameters      :
861 --      IN              :p_api_version                  IN NUMBER       Required
862 --                      p_init_msg_list                 IN VARCHAR2     Required
863 --                      p_commit                        IN VARCHAR2     Required
864 --                      p_validation_level              IN NUMBER       Required
865 --                      p_period_id                     IN NUMBER       Required
866 --                      p_period_set_name               IN VARCHAR2     Required
867 --                      p_period_name                   IN VARCHAR2     Required
868 --                      p_org_id                        IN NUMBER       Required
869 --                      p_wip_entity_id                 IN NUMBER       Required
870 --                      p_owning_dept_id                IN NUMBER       Required
871 --                      p_dept_id                       IN NUMBER       Required
872 --                      p_maint_cost_cat                IN NUMBER       Required
873 --                      p_opseq_num                     IN NUMBER       Required
874 --                      p_period_start_dat              IN DATE         Required
875 --                      p_account_ccid                  IN NUMBER       Required
876 --                      p_value                         IN NUMBER       Required
877 --                      p_txn_type                      IN NUMBER       Required
878 --                      p_wip_acct_class                IN VARCHAR2     Required
879 --                      p_mfg_cost_element_id           IN NUMBER       Required
880 --                      p_user_id                       IN NUMBER       Required
881 --                      p_request_id                    IN NUMBER       Required
882 --                      p_prog_id                       IN NUMBER       Required
883 --                      p_prog_app_id                   IN NUMBER       Required
884 --                      p_login_id                      IN NUMBER       Required
885 --      OUT             x_return_status                 OUT     VARCHAR2(1)
886 --                      x_msg_count                     OUT     NUMBER
887 --                      x_msg_data                      OUT     VARCHAR2(2000)
888 --      Version : Current version       1.0
889 --                        Initial version       1.0
890 --
891 --      HISTORY
892 --      04/29/05   Anjali R    Added as part of eAM Requirements Project (R12)
893 --
894 --------------------------------------------------------------------------
895 
896   PROCEDURE Insert_eamBalAcct(
897         p_api_version                IN        NUMBER,
901         x_return_status         OUT NOCOPY        VARCHAR2,
898         p_init_msg_list                IN        VARCHAR2,
899         p_commit                IN        VARCHAR2,
900         p_validation_level        IN        NUMBER,
902         x_msg_count             OUT NOCOPY        NUMBER,
903         x_msg_data              OUT NOCOPY        VARCHAR2,
904         p_period_id             IN          NUMBER,
905         p_period_set_name       IN          VARCHAR2,
906         p_period_name           IN      VARCHAR2,
907         p_org_id                IN          NUMBER,
908         p_wip_entity_id         IN          NUMBER,
909         p_owning_dept_id        IN          NUMBER,
910         p_dept_id               IN          NUMBER,
911         p_maint_cost_cat        IN      NUMBER,
912         p_opseq_num             IN      NUMBER,
913         p_period_start_date     IN          DATE,
914         p_account_ccid          IN          NUMBER,
915         p_value                 IN          NUMBER,
916         p_txn_type              IN          NUMBER,
917         p_wip_acct_class        IN          VARCHAR2,
918         p_mfg_cost_element_id   IN      NUMBER,
919         p_user_id               IN          NUMBER,
920         p_request_id            IN          NUMBER,
921         p_prog_id               IN          NUMBER,
922         p_prog_app_id           IN      NUMBER,
923         p_login_id              IN          NUMBER
924 );
925 
926 
927 -------------------------------------------------------------------------------
928 --      API name        : Delete_eamBalAcct
929 --      Type            : Public
930 --      Function        : This API deletes data from CST_EAM_BALANCE_BY_ACCOUNTS
931 --                        table for a given wip_entity_id and period.
932 --      Pre-reqs        : None.
933 --      Parameters      :
934 --      IN              :
935 --        p_api_version                 IN NUMBER       Required
936 --        p_init_msg_list               IN VARCHAR2     Required
937 --        p_commit                      IN VARCHAR2     Required
938 --        p_validation_level            IN NUMBER       Required
939 --        p_org_id                      IN NUMBER       Required
940 --        p_entity_id_tab               IN CSTPECEP.wip_entity_id_type
941 --        p_period_set_name             IN VARCHAR2     Required
942 --        p_period_name                 IN VARCHAR2     Required
943 --      OUT             :
944 --        x_return_status               OUT NOCOPY      VARCHAR2(1)
945 --        x_msg_count                   OUT NOCOPY      NUMBER
946 --        x_msg_data                    OUT NOCOPY      VARCHAR2(2000)
947 --      Version : Current version       1.0
948 --        Initial version       1.0
949 --
950 --      History         :
951 --      03/29/05  Anjali R    Added as part of eAM requirements Project (R12)
952 --
953 -------------------------------------------------------------------------------
954 PROCEDURE Delete_eamBalAcct
955 (
956         p_api_version                IN        NUMBER,
957         p_init_msg_list                IN        VARCHAR2 ,
958         p_commit                IN        VARCHAR2 ,
959         p_validation_level        IN        NUMBER,
960         x_return_status         OUT NOCOPY        VARCHAR2,
961         x_msg_count             OUT NOCOPY        VARCHAR2,
962         x_msg_data              OUT NOCOPY        VARCHAR2,
963         p_org_id                IN          NUMBER,
964         p_entity_id_tab         IN      CSTPECEP.wip_entity_id_type
965 );
966 
967 -------------------------------------------------------------------------------
968 --      API name        : Insert_tempEstimateDetails
969 --      Type            : Public
970 --      Function        : This API inserts data into Global Temporary table
971 --                        CST_EAM_DIRECT_ITEMS_TEMP
972 --      Pre-reqs        : None.
973 --      Parameters      :
974 --      IN              :
975 --        p_api_version                 IN NUMBER       Required
976 --        p_init_msg_list               IN VARCHAR2     Required
977 --        p_commit                      IN VARCHAR2     Required
978 --        p_validation_level            IN NUMBER       Required
979 --        p_entity_id_tab               IN CSTPECEP.wip_entity_id_type
980 --      OUT             :
981 --        x_return_status               OUT NOCOPY      VARCHAR2(1)
982 --        x_msg_count                   OUT NOCOPY      NUMBER
983 --        x_msg_data                    OUT NOCOPY      VARCHAR2(2000)
984 --      Version : Current version       1.0
985 --        Initial version       1.0
986 --
987 --      History         :
991 PROCEDURE Insert_tempEstimateDetails
992 (
993     p_api_version          IN  NUMBER,
994     p_init_msg_list        IN  VARCHAR2 := FND_API.G_FALSE,
995     p_commit               IN  VARCHAR2 := FND_API.G_FALSE,
996     p_validation_level     IN  VARCHAR2 := FND_API.G_VALID_LEVEL_FULL,
997     x_return_status        OUT NOCOPY  VARCHAR2,
998     x_msg_count            OUT NOCOPY  NUMBER,
999     x_msg_data             OUT NOCOPY  VARCHAR2,
1000     p_entity_id_tab        IN  CSTPECEP.wip_entity_id_type
1001 );
1002 
1003 END CST_eamCost_PUB;
990 -------------------------------------------------------------------------------
988 --      02/10/06  Anjali R    Added as part of eAM requirements Project (R12)
989 --