DBA Data[Home] [Help]

PACKAGE BODY: APPS.CST_PERIODIC_ABSORPTION_CP

Source


1 PACKAGE BODY CST_PERIODIC_ABSORPTION_CP AS
2 -- $Header: CSTCITPB.pls 120.2.12000000.3 2007/05/10 05:41:14 vmutyala ship $
3 --+=======================================================================+
4 --|               Copyright (c) 2003 Oracle Corporation                   |
5 --|                       Redwood Shores, CA, USA                         |
6 --|                         All rights reserved.                          |
7 --+=======================================================================+
8 --| FILENAME                                                              |
9 --|     CSTCITPB.pls                                                      |
10 --|                                                                       |
11 --| DESCRIPTION                                                           |
12 --|    Periodic Absorption Cost Processor Concurrent Program Wrapper      |
13 --|                                                                       |
14 --| PROCEDURE LIST                                                        |
15 --|     Periodic_Absorb_Cost_Process                                      |
16 --|                                                                       |
17 --| HISTORY                                                               |
18 --|     07/21/03   dherring    Created                                    |
19 --|     10/27/2003 vjavli      p_tolerance parameter updated              |
20 --|     11/25/03   David Herring moved order of run option parameter      |
21 --|     01/20/04   vjavli      transfer_cp_manager to add two more out    |
22 --|                            parameters for return status and error msg |
23 --|     04/10/2004 vjavli      Concurrent program name change             |
24 --|                            new name:Periodic_Absorb_Cost_Process      |
25 --| ----------------------------------------------------------------------|
26 --| ----------------------- R12 ENHANCEMENTS -----------------------------|
27 --| ----------------------------------------------------------------------|
28 --|     06/15/2005 vjavli     Bug#4358239 fix:  Regression caused due to  |
29 --|                           TZ bug#3720424 fix by Oracle Costing        |
30 --|                           INV_LE_TIMEZONE_PUB.GET_SERVER_DAY_TIME_FOR |
31 --|                           _LE invoke to be modified                   |
32 --|     06/15/2005 vjavli     Bug#4351270 fix: timzone issue:             |
33 --|                           process_upto_date validation should be for  |
34 --|                           Legal Entity; l_le_process_upto_date        |
35 --|                           Procedure transfer_cp_manager modified with |
36 --|                           p_le_process_upto_date                      |
37 --|     01/30/2006 vjavli     FND Debug Log Messages implemented          |
38 --+========================================================================
39 
40 -- ==================================================================
41 -- GLOBALS
42 -- ==================================================================
43 G_PKG_NAME CONSTANT    VARCHAR2(30) := 'CST_PERIODIC_ABSORPTION_CP';
44 
45 --========================================================================
46 -- PRIVATE CONSTANTS AND VARIABLES
47 --========================================================================
48 G_MODULE_HEAD CONSTANT  VARCHAR2(50) := 'cst.plsql.' || G_PKG_NAME || '.';
49 
50 --========================================================================
51 -- PROCEDURE : Periodic_Absorb_Cost_Process      PRIVATE
52 -- COMMENT   : This procedure acts as a wrapper around the code that will
53 --             process periodic absorption cost of transactions according
54 --             to the periodic weighted average costing (PWAC) cost method
55 --             based on a new periodic absorption cost rollup algorithm
56 --=========================================================================
57 PROCEDURE Periodic_Absorb_Cost_Process
58 ( x_errbuf                  OUT NOCOPY VARCHAR2
59 , x_retcode                 OUT NOCOPY VARCHAR2
60 , p_legal_entity_id         IN  VARCHAR2
61 , p_cost_type_id            IN  VARCHAR2
62 , p_period_id               IN  VARCHAR2
63 , p_run_options             IN  VARCHAR2
64 , p_process_upto_date       IN  VARCHAR2 DEFAULT NULL
65 , p_tolerance               IN  VARCHAR2
66 , p_number_of_iterations    IN  VARCHAR2
67 , p_number_of_workers       IN  VARCHAR2 DEFAULT '1'
68 )
69 IS
70 
71 l_routine CONSTANT VARCHAR2(30) := 'periodic_absorb_cost_process';
72 
73 -- Exception
74 transfer_cp_mgr_error_exc  EXCEPTION;
75 
76 l_return_status         VARCHAR2(1);
77 l_msg_count             NUMBER;
78 
79 -- bug#3720424: convert LE to server time zone used to retrieve
80 -- transactions stored in server time zone
81 l_process_upto_date_stz   VARCHAR2(50);
82 
83 -- process upto date for a legal entity
84 l_le_process_upto_date  VARCHAR2(50);
85 
86 l_legal_entity_id       NUMBER;
87 l_cost_type_id          NUMBER;
88 l_period_id             NUMBER;
89 l_run_options           NUMBER;
90 l_tolerance             NUMBER;
91 l_number_of_iterations  NUMBER;
92 l_number_of_workers     NUMBER;
93 BEGIN
94 
95   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
96     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
97                   ,G_MODULE_HEAD || l_routine || '.begin'
98                   ,l_routine || '<'
99                   );
100   END IF;
101 
102 -- =====================================================================
103 -- Bug#4351270 fix: Time zone -  validate process upto date of the
104 -- Legal Entity
105 -- =====================================================================
106 l_le_process_upto_date := p_process_upto_date;
107 
108  l_legal_entity_id := FND_NUMBER.CANONICAL_TO_NUMBER(p_legal_entity_id);
109  l_cost_type_id := FND_NUMBER.CANONICAL_TO_NUMBER(p_cost_type_id);
110  l_period_id := FND_NUMBER.CANONICAL_TO_NUMBER(p_period_id);
111  l_run_options := FND_NUMBER.CANONICAL_TO_NUMBER(p_run_options);
112  l_tolerance := FND_NUMBER.CANONICAL_TO_NUMBER(p_tolerance);
113  l_number_of_iterations := FND_NUMBER.CANONICAL_TO_NUMBER(p_number_of_iterations);
114  l_number_of_workers := FND_NUMBER.CANONICAL_TO_NUMBER(p_number_of_workers);
115 -- ======================================================================
116 -- Added below conversion as part of bug#3720424 by Oracle Costing
117 -- Converting LE timezone to server timezone
118 -- bug#4358239 fix as regression of bug#3720424
119 -- ======================================================================
120 l_process_upto_date_stz :=
121   fnd_date.date_to_canonical(INV_LE_TIMEZONE_PUB.GET_SERVER_DAY_TIME_FOR_LE(fnd_date.canonical_to_date(p_process_upto_date),l_legal_entity_id));
122 
123 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
124   FND_LOG.string(FND_LOG.LEVEL_STATEMENT
125                 ,G_MODULE_HEAD || l_routine || '.srvtz'
126                 ,'server time zone process upto date:' || l_process_upto_date_stz
127                 );
128 END IF;
129 
130   CST_PERIODIC_ABSORPTION_PROC.transfer_cp_manager
131   ( p_legal_entity          => l_legal_entity_id
132   , p_cost_type_id          => l_cost_type_id
133   , p_period_id             => l_period_id
134   , p_process_upto_date     => l_process_upto_date_stz
135   , p_le_process_upto_date  => l_le_process_upto_date
136   , p_tolerance             => l_tolerance
137   , p_number_of_iterations  => l_number_of_iterations
138   , p_number_of_workers     => l_number_of_workers
139   , p_run_options           => l_run_options
140   , x_return_status         => l_return_status
141   , x_msg_count             => l_msg_count
142   , x_msg_data              => x_errbuf
143   );
144 
145   IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
146     RAISE transfer_cp_mgr_error_exc;
147   END IF;
148 
149   -- Concurrent program return status Successful
150   x_retcode := '0';
151 
152   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
153     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
154                   ,G_MODULE_HEAD || l_routine || '.end'
155                   ,l_routine || '>'
156                   );
157   END IF;
158 
159 EXCEPTION
160   WHEN transfer_cp_mgr_error_exc THEN
161     -- Concurrent program return status Error
162     x_retcode := '2';
163 
164   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
165     x_retcode := '2';
166     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE)
167                         ,1
168                         ,250);
169 
170   WHEN OTHERS THEN
171     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
172     THEN
173       x_retcode := '2';
174       x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE)
175                           ,1
176                           ,250);
177 
178     END IF;
179 
180 END Periodic_Absorb_Cost_Process;
181 
182 END CST_PERIODIC_ABSORPTION_CP;