DBA Data[Home] [Help]

PACKAGE: APPS.CSTPLENG

Source


1 PACKAGE CSTPLENG AUTHID CURRENT_USER AS
2 /* $Header: CSTLENGS.pls 115.11 2004/07/21 00:35:59 rthng ship $ */
3 
4 TYPE cst_layer_rec_type IS RECORD(inv_layer_id	NUMBER,
5 				  table_header	VARCHAR2(30),
6 				  layer_quantity  NUMBER);
7 TYPE cst_layer_tbl_type IS TABLE OF cst_layer_rec_type;
8 
9 TYPE LayerCurType IS REF CURSOR;
10 
11 ----------------------------------------------------------------------------
12 -- PROCEDURE                                                              --
13 --   compute_layer_actual_cost                                            --
14 --                                                                        --
15 -- DESCRIPTION                                                            --
16 --   This procedure is analogous to the compute_layer_actual_cost( ) in   --
17 --   average costing. It is called by the cost processor for each         --
18 --   transaction, so that MCLACD can be populated, and                    --
19 --   FIFO/LIFO layers consumed or created as necessary                    --
20 --                                                                        --
21 -- PURPOSE:                                                               --
22 --   FIFO/LIFO layer cost processing for Oracle Applications Rel 11i.2    --
23 --                                                                        --
24 -- PARAMETERS:                                                            --
25 --            i_org_id	      : worker organization ID		          --
26 --            i_layer_id      : layer ID from CQL                         --
27 --                              (for organization, item, cost group)      --
28 --            i_cost_method   : FIFO or LIFO cost method                  --
29 --            i_cost_hook     : presence of actual cost hook              --
30 --                                                                        --
31 -- HISTORY:                                                               --
32 --    04/20/00     Anitha B       Created                                 --
33 ----------------------------------------------------------------------------
34 
35 FUNCTION compute_layer_actual_cost(
36 				i_org_id 		IN	NUMBER,
37 				i_cost_method		IN	NUMBER,
38                         	i_txn_id 		IN	NUMBER,
39                         	i_layer_id 		IN	NUMBER,
40 				i_cost_hook		IN	NUMBER,
41                         	i_cost_type 		IN	NUMBER,
42                         	i_mat_ct_id 		IN	NUMBER,
43 			  	i_avg_rates_id		IN	NUMBER,
44 				i_item_id		IN	NUMBER,
45 				i_txn_qty		IN	NUMBER,
46 				i_txn_action_id		IN	NUMBER,
47 				i_txn_src_type		IN	NUMBER,
48 				i_interorg_rec		IN	NUMBER,
49 				i_exp_flag		IN	NUMBER,
50 				i_user_id		IN	NUMBER,
51 				i_login_id		IN	NUMBER,
52 				i_req_id		IN	NUMBER,
53 				i_prg_appl_id		IN	NUMBER,
54 				i_prg_id		IN	NUMBER,
55 				o_err_num		OUT NOCOPY	NUMBER,
56 				o_err_code		OUT NOCOPY	VARCHAR2,
57 				o_err_msg		OUT NOCOPY	VARCHAR2
58 )
59 return integer;
60 
61 ----------------------------------------------------------------------------
62 -- PROCEDURE                                                              --
63 --   consume_create_layers                                                --
64 --                                                                        --
65 -- DESCRIPTION                                                            --
66 --   This procedure determines whether to create or consume inventory     --
67 --   layers depending on the transaction  action and primary quantity     --
68 --                                                                        --
69 -- PURPOSE:                                                               --
70 --   * Differentiate consumption and receipt transactions                 --
71 --   * For scrap transactions, it merely populates MCACD, since no        --
72 --     inventory layers are involved                                      --
73 --   * If expense flag is 1, then pick up current cost from CQL (similar  --
74 --     to average costing). Only MCACD is populated since no inventory    --
75 --     layers are involved.                                               --
76 --                                                                        --
77 -- PARAMETERS:                                                            --
78 --            i_org_id	      : organization ID			          --
79 --            i_layer_id      : layer ID from CQL                         --
80 --                              (for organization, item, cost group)      --
81 --            i_txn_action_id : Transaction action ID                     --
82 --            i_txn_qty       : primary quantity                          --
83 --            i_exp_flag      : Expense flag for item/subinventory        --
84 --                                                                        --
85 -- HISTORY:                                                               --
86 --    04/20/00     Anitha B       Created                                 --
87 ----------------------------------------------------------------------------
88 
89 PROCEDURE consume_create_layers(
90 				i_org_id		IN	NUMBER,
91 				i_txn_id		IN	NUMBER,
92 				i_layer_id		IN	NUMBER,
93  				i_cost_hook		IN	NUMBER,
94 				i_item_id		IN	NUMBER,
95 				i_txn_qty		IN	NUMBER,
96 				i_cost_method		IN	NUMBER,
97 				i_txn_src_type		IN	NUMBER,
98 				i_txn_action_id 	IN	NUMBER,
99 				i_interorg_rec		IN	NUMBER,
100 				i_cost_type		IN	NUMBER,
101 				i_mat_ct_id		IN	NUMBER,
102 				i_avg_rates_id		IN	NUMBER,
103 				i_exp_flag		IN	NUMBER,
104 				i_user_id		IN	NUMBER,
105 				i_login_id		IN	NUMBER,
106 				i_req_id		IN	NUMBER,
107 				i_prg_appl_id		IN	NUMBER,
108 				i_prg_id		IN	NUMBER,
109 				o_err_num		OUT NOCOPY	NUMBER,
110 				o_err_code		OUT NOCOPY	VARCHAR2,
111  				o_err_msg		OUT NOCOPY	VARCHAR2
112 				);
113 
114 ----------------------------------------------------------------------------
115 -- FUNCTION                                                               --
116 --   get_source_number	                                                  --
117 --                                                                        --
118 -- DESCRIPTION                                                            --
119 --   This function is used to obtain the transaction source               --
120 --  for user identification of each transaction that creates an inventory --
121 --  layer                                                                 --
122 --    The transaction_source is identified based on the transaction       --
123 --  source type. It defaults to the transaction_id                        --
124 --                                                                        --
125 -- PURPOSE:                                                               --
126 --   obtain user identifiable transaction source to identify inventory    --
127 --   layers  								  --
128 --                                                                        --
129 -- PARAMETERS:                                                            --
130 --    i_txn_id   :  transaction id					  --
131 --    i_src_id   :  transaction source id 				  --
132 --    i_src_type : transaction source type                                --
133 --            								  --
134 --                                                                        --
135 -- HISTORY:                                                               --
136 --    04/20/00     Anitha B       Created                                 --
137 ----------------------------------------------------------------------------
138 
139 FUNCTION get_source_number (i_txn_id	 IN	NUMBER,			    				i_txn_src_type 	 IN	NUMBER,
140 		       i_src_id	 	IN	NUMBER
141 			)
142 return VARCHAR2;
143 
144 ----------------------------------------------------------------------------
145 -- PROCEDURE                                                              --
146 --   insert_mclacd                                                        --
147 --                                                                        --
148 -- DESCRIPTION                                                            --
149 --   * Based on the actual_cost_table flag, this procedure picks up costs --
150 --     from the view cst_layer_actual_costs_v and inserts the cost        --
151 --     details into MCLACD                                                --
152 --   * The view is built on top of MCACD,MCTCD and CILCD, with a table    --
153 --     flag that indicates which portion of the UNION clause needs to be  --
154 --     execuated during each select against the view.                     --
155 --                                                                        --
156 -- PURPOSE:                                                               --
157 --   A single function used to insert transaction cost details into       --
158 --    MCLACD. 								  --
159 --                                                                        --
160 -- PARAMETERS:                                                            --
161 --      i_actual_cost_table : table from which actual costs are obtained  --
162 --      i_layer_cost_table  : table from which layers costs are obtained  --
163 --      i_cur_layer_id      : the inventory layer inserted into MCLACD    --
164 --      i_actual_layer_id   : inventory layer whose costs are used        --
165 --      i_mode              : (CREATE,CONSUME,REPLENISH), determines if   --
166 --                            outer join is required                      --
167 --                                                                        --
168 -- HISTORY:                                                               --
169 --    04/20/00     Anitha B       Created                                 --
170 ----------------------------------------------------------------------------
171 
172 PROCEDURE insert_mclacd (
173 			i_txn_id		IN	NUMBER,
174 			i_org_id		IN	NUMBER,
175 			i_item_id		IN	NUMBER,
176 			i_layer_id		IN	NUMBER,
177 			i_cur_layer_id		IN	NUMBER,
178 			i_qty			IN	NUMBER,
179 			i_txn_action_id		IN	NUMBER,
180 			i_user_id		IN	NUMBER,
181 			i_login_id		IN	NUMBER,
182 			i_req_id		IN	NUMBER,
183 			i_prg_id		IN	NUMBER,
184 			i_prg_appl_id		IN	NUMBER,
185 			i_actual_cost_table 	IN	VARCHAR2,
186 			i_layer_cost_table	IN	VARCHAR2,
187 			i_actual_layer_id	IN	NUMBER,
188                         i_mode			IN	VARCHAR2,
189 			o_err_num 		OUT NOCOPY	NUMBER,
190 			o_err_code		OUT NOCOPY	VARCHAR2,
191 			o_err_msg		OUT NOCOPY	VARCHAR2
192 			);
193 
194 ----------------------------------------------------------------------------
195 -- PROCEDURE                                                              --
196 --   create_layers                                                        --
197 --                                                                        --
198 -- DESCRIPTION                                                            --
199 --   * Create inventory layers for i_txn_qty (maybe negative)             --
200 --       insert into CIL,CILCD,MCLACD using costs from MCACD(cost hook),  --
201 --       MCTCD(if available), CILCD(latest layer cost,the layer may or    --
202 --       may not have positive qty), 0 cost if no costs available         --
203 --                                                                        --
204 --       update CIL layer cost, burden cost and unburdened cost           --
205 --   * If layer created has positive quantity, then replenish all         --
206 --     negative inventory layers                                          --
207 --                                                                        --
208 -- PURPOSE:                                                               --
209 --     create inventory layers using the sequence cst_inv_layers_s        --
210 --                                                                        --
211 -- PARAMETERS:                                                            --
212 --      i_txn_qty      : primary quantity                                 --
213 --      i_interorg_rec : interorg shimpment (= 0),                        --
214 --                       interorg receipt (= 1)                           --
215 --                       subinv transfer with no layer change (= 3)       --
216 --                       otherwise (= null)                               --
217 --                                                                        --
218 -- HISTORY:                                                               --
219 --    04/20/00     Anitha B       Created                                 --
220 ----------------------------------------------------------------------------
221 
222 PROCEDURE create_layers(
223  			i_org_id		IN	NUMBER,
224 			i_txn_id		IN	NUMBER,
225 			i_layer_id		IN	NUMBER,
226 			i_item_id		IN	NUMBER,
227 			i_txn_qty		IN	NUMBER,
228 			i_cost_method		IN	NUMBER,
229 			i_txn_src_type		IN	NUMBER,
230                   	i_txn_action_id   	IN    	NUMBER,
231                   	i_cost_hook		IN	NUMBER,
232 			i_interorg_rec		IN	NUMBER,
233 			i_cost_type		IN	NUMBER,
234 			i_mat_ct_id		IN	NUMBER,
235 			i_avg_rates_id		IN	NUMBER,
236 			i_exp_flag		IN	NUMBER,
237 			i_user_id		IN	NUMBER,
238 			i_login_id		IN	NUMBER,
239 			i_req_id		IN	NUMBER,
240 			i_prg_appl_id		IN	NUMBER,
241 			i_prg_id		IN	NUMBER,
242 			o_err_num		OUT NOCOPY	NUMBER,
243 			o_err_code		OUT NOCOPY	VARCHAR2,
244 			o_err_msg		OUT NOCOPY	VARCHAR2
245                   );
246 
247 ----------------------------------------------------------------------------
248 -- PROCEDURE                                                              --
249 --   consume_layers                                                       --
250 --                                                                        --
251 -- DESCRIPTION                                                            --
252 --   * Consume inventory layer, insert into MCLACD using inventory layer  --
253 --     cost. If cost hook or MCTCD is present, then drive to variance     --
254 --   * Uses inventory layer table to insert costs and update layer qty    --
255 --                                                                        --
256 -- PURPOSE:                                                               --
257 --   consumption of inventory layers                                      --
258 --                                                                        --
259 -- PARAMETERS:                                                            --
260 --      i_txn_qty      : primary quantity                                 --
261 --      i_interorg_rec : interorg shimpment (= 0),                        --
262 --                       interorg receipt (= 1)                           --
263 --                       subinv transfer with no layer change (= 3)       --
264 --                       otherwise (= null)                               --
265 --                                                                        --
269 
266 -- HISTORY:                                                               --
267 --    04/20/00     Anitha B       Created                                 --
268 ----------------------------------------------------------------------------
270 PROCEDURE consume_layers(
271  			i_org_id		IN	NUMBER,
272 			i_txn_id		IN	NUMBER,
273 			i_layer_id		IN	NUMBER,
274 			i_item_id		IN	NUMBER,
275 			i_txn_qty		IN	NUMBER,
276 			i_cost_method		IN	NUMBER,
277 			i_txn_src_type		IN	NUMBER,
278                   	i_txn_action_id   	IN    	NUMBER,
279                   	i_cost_hook		IN	NUMBER,
280                         i_interorg_rec		IN	NUMBER,
281 			i_cost_type		IN	NUMBER,
282 			i_mat_ct_id		IN	NUMBER,
283 			i_avg_rates_id		IN	NUMBER,
284 			i_exp_flag		IN	NUMBER,
285 			i_user_id		IN	NUMBER,
286 			i_login_id		IN	NUMBER,
287 			i_req_id		IN	NUMBER,
288 			i_prg_appl_id		IN	NUMBER,
289 			i_prg_id		IN	NUMBER,
290 			o_err_num		OUT NOCOPY	NUMBER,
291 			o_err_code		OUT NOCOPY	VARCHAR2,
292 			o_err_msg		OUT NOCOPY	VARCHAR2
293                   );
294 ----------------------------------------------------------------------------
295 -- PROCEDURE                                                              --
296 --   get_layers_consumed                                                  --
297 --                                                                        --
298 -- DESCRIPTION                                                            --
299 --   This procedure builds the select statement that needs to be executed --
300 --  for each transaction type, (layer specific, regular FIFO/LIFO,        --
301 --  driving last layer negative) and returns the PL/SQL consumption table --
302 --  to the consume_layers function for consumption                        --
303 --                                                                        --
304 -- PURPOSE:                                                               --
305 --  a procedure that can return a PL/SQL table of all inventory layers    --
306 --  and the quantity that should eb consuemd from that layer, for a given --
307 --  transaction quantity                                                  --
308 --                                                                        --
309 -- PARAMETERS:                                                            --
310 --       i_txn_qty     :  priamry quantity, that needs to be consumed     --
311 --       i_cost_method : FIFO/LIFO consumption logic                      --
312 --       i_layer_id    : cost group layer ID                              --
313 --       consume_mode  : SPECIFIC(for layer hook, RTV, assembly           --
314 --                       completion), NORMAL (otherwise)                  --
315 --       l_inv_layer_table : PL/SQL table, IN OUT variable                --
316 --       i_layer_hook  : if layer hook is present                         --
317 --       i_src_id      : for RTV and assembly completion, ignored         --
318 --                       otherwise                                        --
319 ----------------------------------------------------------------------------
320 PROCEDURE get_layers_consumed (
321   i_txn_qty         IN            NUMBER,
322   i_cost_method     IN            NUMBER,
323   i_layer_id	    IN  	  NUMBER,
324   consume_mode      IN            VARCHAR2,
325   i_layer_hook      IN            NUMBER DEFAULT NULL,
326   i_src_id          IN            NUMBER DEFAULT NULL,
327   i_txn_id          IN            NUMBER DEFAULT NULL,
328   l_inv_layer_table IN OUT NOCOPY cst_layer_tbl_type,
329   o_err_num         OUT NOCOPY    NUMBER,
330   o_err_code        OUT NOCOPY    VARCHAR2,
331   o_err_msg         OUT NOCOPY    VARCHAR2
332 );
333 
334 ----------------------------------------------------------------------------
335 -- PROCEDURE                                                              --
336 --   populate_layer_table                                                 --
337 --                                                                        --
338 -- DESCRIPTION                                                            --
339 --   * This procedure loops through the records fetched by the layer      --
340 --     cursor (IN parameter), and populates the PL/SQL table with the     --
341 --     inventory layer ID and the quantity that needs to be consumed      --
342 --     from that layer                                                    --
343 --   * If no layers are fetched, the procedure issues a return            --
344 --                                                                        --
345 -- PURPOSE:                                                               --
346 --   a single function to loop through records fetched by the inventory   --
347 --   layer cursor and populate the PL/SQL table with the inv layer ID     --
348 --   and the quantity to be consuemd from that layer                      --
349 --                                                                        --
350 -- PARAMETERS:                                                            --
351 --     l_inv_layer_table  :  PL/SQL parameter that is populated           --
352 --     inv_layer_cursor   : cursor that is used to fetch inventory layers --
353 --     i_qty_required     : total quantity left to be consumed            --
354 ----------------------------------------------------------------------------
355 PROCEDURE populate_layer_table(l_inv_layer_table IN OUT NOCOPY cst_layer_tbl_type,
356                                          inv_layer_cursor IN LayerCurType,
357                                          i_qty_required IN OUT NOCOPY NUMBER,
358                                          o_err_num      OUT NOCOPY NUMBER,
359                                          o_err_code OUT NOCOPY VARCHAR2,
363 -- PROCEDURE                                                              --
360                                          o_err_msg  OUT NOCOPY VARCHAR2);
361 
362 ----------------------------------------------------------------------------
364 --   insert_record                                                        --
365 --                                                                        --
366 -- DESCRIPTION                                                            --
367 --   This procedure extends the PL/SQL table and inserts a new record     --
368 --                                                                        --
369 -- PURPOSE:                                                               --
370 --   This procedure extends the PL/SQL table and inserts a new record     --
371 --                                                                        --
372 -- PARAMETERS:                                                            --
373 --       l_inv_layer_rec   : record to be inserted                        --
374 --       l_inv_layer_table : PL/SQL table into which record is inserted   --
375 ----------------------------------------------------------------------------
376 PROCEDURE insert_record(l_inv_layer_rec IN cst_layer_rec_type,
377                                 l_inv_layer_table IN OUT NOCOPY cst_layer_tbl_type,
378                                 o_err_num       OUT NOCOPY      NUMBER,
379                                 o_err_code  OUT NOCOPY  VARCHAR2,
380                                 o_err_msg   OUT NOCOPY  VARCHAR2);
381 
382 ----------------------------------------------------------------------------
383 -- PROCEDURE apply_layer_material_ovh
384 -- created by Dieu-Thuong Le  21-Apr-2000
385 
386 -- This procedure will compute material overheads based on the rates
387 -- defined in the rate cost type specified for the current costing org.
388 -- The computed movh will be applied to this level material overhead of
389 -- the specified inventory layer.
390 -- This procedure will insert MACS rows for each applicable material
391 -- overhead and insert or update MCLACD.
392 --     Inserting MCLACD: populate both layer_cost and actual_cost with the
393 --                       total costs of all MACS rows created for tranx.
394 --     Updating MCLACD:  add MACS costs to actual_cost, layer_cost will
395 --                       not be touched.
396 -- Assumption:  when this procedure is called, MCLACD material row should
397 -- already be inserted for the transaction.
398 -----------------------------------------------------------------------------
399 
400 procedure apply_layer_material_ovhd(
401   I_ORG_ID        IN      NUMBER,
402   I_TXN_ID        IN      NUMBER,
403   I_LAYER_ID      IN      NUMBER,
404   I_INV_LAYER_ID  IN      NUMBER,
405   I_LAYER_QTY     IN      NUMBER,
406   I_COST_TYPE     IN      NUMBER,
407   I_MAT_CT_ID     IN      NUMBER,
408   I_AVG_RATES_ID  IN      NUMBER,
409   I_ITEM_ID       IN      NUMBER,
410   I_TXN_QTY       IN      NUMBER,
411   I_TXN_ACTION_ID IN      NUMBER,
412   I_LEVEL         IN      NUMBER,
413   I_USER_ID       IN      NUMBER,
414   I_LOGIN_ID      IN      NUMBER,
415   I_REQ_ID        IN      NUMBER,
416   I_PRG_APPL_ID   IN      NUMBER,
417   I_PRG_ID        IN      NUMBER,
418   I_INTERORG_REC  IN      NUMBER, --bug 2280515
419   O_Err_Num       OUT NOCOPY     NUMBER,
420   O_Err_Code      OUT NOCOPY     VARCHAR2,
421   O_Err_Msg       OUT NOCOPY     VARCHAR2
422 );
423 
424 /*********************************************************************************
425 ** PROCEDURE                                                                    **
426 **     calc_layer_average_cost                                                  **
427 **                                                                              **
428 ** DESCRIPTION                                                                  **
429 ** It main function is to perform the following for the specified transaction:  **
430 **      . insert into MCACD with MCLACD's summarized costs                      **
431 **      . update CLCD with CILCD's summarized costs                             **
432 **      . update CQL's costs from CLCD                                          **
433 **      . update CICD's costs from CLCD                                         **
434 **      . update CIC's costs from CICD                                          **
435 ** This procedure assumes that all MCLACD rows have already been inserted by    **
436 ** calling program.                                                             **
437 ** Set I_NO_UPDATE_MMT = 1 if the calling program does not want mmt to be       **
438 **                       update; otherwise, set it to 0                         **
439 ** Set I_NO_UPDATE_QTY = 1 if clcd, cql, cic and cicd should not be updated;    **
440 **                       otherwise, set it to 0                                 **
441 **                                                                              **
442 ** HISTORY                                                                      **
443 **   4/24/00     Dieu-Thuong Le              Creation                           **
444 **                                                                              **
445 *********************************************************************************/
446 
447 procedure calc_layer_average_cost(
448   I_ORG_ID	   IN	NUMBER,
449   I_TXN_ID	   IN 	NUMBER,
450   I_LAYER_ID	   IN	NUMBER,
451   I_COST_TYPE	   IN	NUMBER,
452   I_ITEM_ID	   IN	NUMBER,
453   I_TXN_QTY	   IN	NUMBER,
454   I_TXN_ACTION_ID  IN	NUMBER,
455   I_COST_HOOK      IN   NUMBER,
456   I_NO_UPDATE_MMT  IN	NUMBER,
460   I_REQ_ID	   IN	NUMBER,
457   I_NO_UPDATE_QTY  IN   NUMBER,
458   I_USER_ID	   IN	NUMBER,
459   I_LOGIN_ID	   IN 	NUMBER,
461   I_PRG_APPL_ID    IN	NUMBER,
462   I_PRG_ID	   IN	NUMBER,
463   O_Err_Num	   OUT NOCOPY	NUMBER,
464   O_Err_Code	   OUT NOCOPY	VARCHAR2,
465   O_Err_Msg	   OUT NOCOPY	VARCHAR2
466 );
467 
468 /************************************************************************
469 **  PROCEDURE                                                          **
470 **     layer_cost_update                                               **
471 **                                                                     **
472 **  DESCRIPTION                                                        **
473 **     This function is called to update inventory layer cost.         **
474 **     It will determine the new elemental costs of the layer based    **
475 **     on user-enter values and compute the adjustment amounts to      **
476 **     inventory valuation.                                            **
477 **     MTL_CST_LAYER_ACT_COST_DETAILS will be populated and the other  **
478 **     cost tables (CILCD, CIL, CLCD, CQL, CICD, CIC) will be updated  **
479 **     accordingly with the new cost information.                      **
480 **     This function is duplicated from CSTPAVCP.average_cost_update.  **
481 **                                                                     **
482 **  HISTORY                                                            **
483 **     12-MAY-2000        Dieu-Thuong Le          Creation             **
484 **                                                                     **
485 ************************************************************************/
486 PROCEDURE layer_cost_update(
487   I_ORG_ID      IN      NUMBER,
488   I_TXN_ID      IN      NUMBER,
489   I_LAYER_ID    IN      NUMBER,
490   I_COST_TYPE   IN      NUMBER,
491   I_ITEM_ID     IN      NUMBER,
492   I_TXN_QTY     IN      NUMBER,
493   I_TXN_ACT_ID  IN      NUMBER,
494   I_USER_ID     IN      NUMBER,
495   I_LOGIN_ID    IN      NUMBER,
496   I_REQ_ID      IN      NUMBER,
497   I_PRG_APPL_ID IN      NUMBER,
498   I_PRG_ID      IN      NUMBER,
499   O_Err_Num     OUT NOCOPY     NUMBER,
500   O_Err_Code    OUT NOCOPY     VARCHAR2,
501   O_Err_Msg     OUT NOCOPY     VARCHAR2
502 );
503 
504 ----------------------------------------------------------------------------
505 -- FUNCTION
506 --  get_current_layer
507 --  This function is called to return the inv layer id whose cost needs to be
508 --  used if a issue is done. It is called from WIP to create layers when there
509 --  are no layers at all in WIP. In that case WIP needs to know which layer cost--  has to be used.
510 --
511 -- INPUT PARAMETERS
512 --  I_ORG_ID
513 --  I_TXN_ID
514 --  I_LAYER_ID
515 --  I_ITEM_ID
516 --  I_TXN_ACT_ID
517 --
518 -- RETURN VALUES
519 --  integer             1       Successful
520 --                      0       Error
521 -----------------------------------------------------------------------------
522 function get_current_layer(
523   I_ORG_ID      IN      NUMBER,
524   I_TXN_ID      IN      NUMBER,
525   I_LAYER_ID    IN      NUMBER,
526   I_ITEM_ID     IN      NUMBER,
527   I_USER_ID     IN      NUMBER,
528   I_LOGIN_ID    IN      NUMBER,
529   I_REQ_ID      IN      NUMBER,
530   I_PRG_APPL_ID IN      NUMBER,
531   I_PRG_ID      IN      NUMBER,
532   I_TXN_SRC_TYPE_ID IN  NUMBER,
533   I_TXN_SRC_ID  IN      NUMBER,
534   O_Err_Num     OUT NOCOPY     NUMBER,
535   O_Err_Code    OUT NOCOPY     VARCHAR2,
536   O_Err_Msg     OUT NOCOPY     VARCHAR2
537 )
538 return integer;
539 
540 ----------------------------------------------------------------------------
541 --  layer_cost_det_move
542 --      This procedure inserts into MCTCD for Layer Cost Update through
543 --   open interface
544 ----------------------------------------------------------------------------
545 procedure layer_cost_det_move (
546   i_txn_id                  in number,
547   i_txn_interface_id        in number,
548   i_txn_action_id           in number,
549   i_org_id                  in number,
550   i_item_id                 in number,
551   i_cost_group_id           in number,
552   i_inv_layer_id            in number,
553   i_txn_cost                in number,
554   i_new_avg_cost            in number,
555   i_per_change              in number,
556   i_val_change              in number,
557   i_mat_accnt               in number,
558   i_mat_ovhd_accnt          in number,
559   i_res_accnt               in number,
560   i_osp_accnt               in number,
561   i_ovhd_accnt              in number,
562   i_user_id                 in number,
563   i_login_id                in number,
564   i_request_id              in number,
565   i_prog_appl_id            in number,
566   i_prog_id                 in number,
567   o_err_num                 out NOCOPY number,
568   o_err_code                out NOCOPY varchar2,
569   o_err_msg                 out NOCOPY varchar2
570 );
571 
572 --------------------------------------------------------------------------
573 --  PROCEDURE layer_cost_det_new_insert
574 --     procedure used by layer cost update through open interface
575 --------------------------------------------------------------------------
576 procedure layer_cost_det_new_insert (
577   i_txn_id                  in number,
578   i_txn_action_id           in number,
579   i_org_id                  in number,
580   i_item_id                 in number,
584   i_new_avg_cost            in number,
581   i_cost_group_id           in number,
582   i_inv_layer_id            in number,
583   i_txn_cost                in number,
585   i_per_change              in number,
586   i_val_change              in number,
587   i_mat_accnt               in number,
588   i_mat_ovhd_accnt          in number,
589   i_res_accnt               in number,
590   i_osp_accnt               in number,
591   i_ovhd_accnt              in number,
592   i_user_id                 in number,
593   i_login_id                in number,
594   i_request_id              in number,
595   i_prog_appl_id            in number,
596   i_prog_id                 in number,
597   o_err_num                 out NOCOPY number,
598   o_err_code                out NOCOPY varchar2,
599   o_err_msg                 out NOCOPY varchar2
600 );
601 
602 ----------------------------------------------------------------------------
603 -- PROCEDURE                                                              --
604 --   layer_cost_update_dist                                               --
605 --                                                                        --
606 -- DESCRIPTION                                                            --
607 --   This procedure is called by CSTPLCIN package for layer cost update   --
608 --  transaction, since distributions need o be done using layer cost      --
609 --  from MCLACD rather than MCLACD                                        --
610 --                                                                        --
611 -- PURPOSE:                                                               --
612 --   Post distributions into MTA for layer cost update transactions       --
613 --                                                                        --
614 -- PARAMETERS:                                                            --
615 --   all transaction related details                                      --
616 ----------------------------------------------------------------------------
617 procedure layer_cost_update_dist(
618   I_ORG_ID              IN      NUMBER,
619   I_TXN_ID              IN      NUMBER,
620   I_LAYER_ID            IN      NUMBER,
621   I_EXP_ITEM            IN      NUMBER,
622   I_USER_ID             IN      NUMBER,
623   I_LOGIN_ID            IN      NUMBER,
624   I_REQ_ID              IN      NUMBER,
625   I_PRG_APPL_ID         IN      NUMBER,
626   I_PRG_ID              IN      NUMBER,
627   O_Error_Num           OUT NOCOPY     NUMBER,
628   O_Error_Code          OUT NOCOPY     VARCHAR2,
629   O_Error_Message       OUT NOCOPY     VARCHAR2
630 );
631 
632 ----------------------------------------------------------------------------
633 -- PROCEDURE                                                              --
634 --   update_inv_layer_cost                                                --
635 --                                                                        --
636 -- DESCRIPTION                                                            --
637 --   This procedure is called by the Define Items form (INVIDITM), to     --
638 -- set costs as zero, when an item is changed from asset to expense       --
639 --                                                                        --
640 -- PURPOSE:                                                               --
641 --   FIFO/LIFO layer cost processing for Oracle Applications Rel 11i.2    --
642 --                                                                        --
643 -- PARAMETERS:                                                            --
644 --            i_org_id          : organization ID                         --
645 --            i_item_id         : inventory_item_id for the item whose    --
646 --                                expense flag is changed                 --
647 --                                                                        --
648 -- HISTORY:                                                               --
649 --    04/20/00     Anitha B       Created                                 --
650 ----------------------------------------------------------------------------
651 
652 PROCEDURE update_inv_layer_cost (i_org_id IN NUMBER,
656 
653                                 i_item_id IN NUMBER,
654                                 i_userid IN NUMBER,
655                                 i_login_id IN NUMBER);
657 END CSTPLENG;