[Home] [Help]
PACKAGE BODY: APPS.CST_MGD_INFL_ADJUSTMENT_PUB
Source
1 PACKAGE BODY CST_MGD_INFL_ADJUSTMENT_PUB AS
2 /* $Header: CSTPIADB.pls 115.6 2004/04/03 02:56:56 vjavli ship $ */
3
4 --===================
5 -- CONSTANTS
6 --===================
7 G_PKG_NAME CONSTANT VARCHAR2(30) := 'CST_MGD_INFL_ADJUSTMENT_PUB';
8
9 --===================
10 -- PUBLIC PROCEDURES
11 --===================
12
13 --========================================================================
14 -- PROCEDURE : Create_Period_Final_Status PRIVATE
15 -- PARAMETERS: p_org_id Organization ID
16 -- p_acct_period_id Account period ID
17 -- x_return_status Return error if failed
18 -- COMMENT : This procedure makes the inflation adjusted period status
19 -- to FINAL
20 -- USAGE : This procedue is used in Create Historical Costs to set the
21 -- inflation status FINAL
22 -- EXCEPTIONS: g_exception1 exception description
23 --========================================================================
24 PROCEDURE Create_Period_Final_Status
25 ( p_org_id IN NUMBER
26 , p_acct_period_id IN NUMBER
27 , x_return_status OUT NOCOPY VARCHAR2
28 )
29 IS
30 BEGIN
31
32 x_return_status := FND_API.G_RET_STS_SUCCESS;
33
34 INSERT INTO
35 CST_MGD_INFL_ADJ_PER_STATUSES(
36 Organization_ID
37 , Acct_Period_ID
38 , Last_Update_Date
39 , Last_Updated_By
40 , Creation_Date
41 , Created_By
42 , Last_Update_Login
43 , Request_ID
44 , Program_Application_ID
45 , Program_ID
46 , Program_Update_Date
47 , STATUS
48 )
49 VALUES(
50 p_org_id
51 , p_acct_period_id
52 , SYSDATE
53 , NVL(TO_NUMBER(FND_PROFILE.Value('USER_ID')),0)
54 , SYSDATE
55 , NVL(TO_NUMBER(FND_PROFILE.Value('USER_ID')),0)
56 , TO_NUMBER(FND_PROFILE.Value('LOGIN_ID'))
57 , TO_NUMBER(FND_PROFILE.Value('CONC_REQUEST_ID'))
58 , TO_NUMBER(FND_PROFILE.Value('PROG_APPL_ID'))
59 , TO_NUMBER(FND_PROFILE.Value('CONC_PROG_ID'))
60 , SYSDATE
61 , 'FINAL'
62 );
63
64 EXCEPTION
65
66 WHEN OTHERS THEN
67 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
68 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
69 THEN
70 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
71 , 'Create_Period_Final_Status'
72 );
73 END IF;
74 RAISE;
75
76 END Create_Period_Final_Status;
77
78
79 --========================================================================
80 PROCEDURE Create_Historical_Cost (
81 p_api_version_number IN NUMBER
82 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
83 , x_return_status OUT NOCOPY VARCHAR2
84 , x_msg_count OUT NOCOPY NUMBER
85 , x_msg_data OUT NOCOPY VARCHAR2
86 , p_historical_infl_adj_rec IN Inflation_Adjustment_Rec_Type
87 )
88 IS
89 l_return_status VARCHAR2(1);
90 l_api_version_number NUMBER := 1.0;
91 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Historical_Cost';
92 l_historical_infl_adj_rec Inflation_Adjustment_Rec_Type;
93 BEGIN
94
95 -- Standard call to check for call compatibility
96 IF NOT FND_API.Compatible_API_Call
97 ( l_api_version_number
98 , p_api_version_number
99 , L_API_NAME
100 , G_PKG_NAME
101 )
102 THEN
103 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
104 END IF;
105
106 -- Initialize message stack if required
107 IF FND_API.to_Boolean(p_init_msg_list)
108 THEN
109 FND_MSG_PUB.initialize;
110 END IF;
111
112 x_return_status := FND_API.G_RET_STS_SUCCESS;
113
114 l_historical_infl_adj_rec := p_historical_infl_adj_rec;
115
116 -- Clear status table
117 DELETE FROM CST_MGD_INFL_ADJ_PER_STATUSES
118 WHERE ORGANIZATION_ID = l_historical_infl_adj_rec.organization_id
119 AND ACCT_PERIOD_ID = l_historical_infl_adj_rec.acct_period_id;
120
121 -- Attribute level validation
122 CST_MGD_INFL_ADJUSTMENT_PVT.Validate_Hist_Attributes
123 ( p_historical_infl_adj_rec => l_historical_infl_adj_rec
124 , x_return_status => l_return_status
125 );
126
127 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
128 THEN
129 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
130 ELSIF l_return_status = FND_API.G_RET_STS_ERROR
131 THEN
132 RAISE FND_API.G_EXC_ERROR;
133 END IF;
134
135 -- Default missing attributes
136 CST_MGD_INFL_ADJUSTMENT_PVT.Hist_Default
137 ( p_historical_infl_adj_rec => l_historical_infl_adj_rec
138 , x_historical_infl_adj_rec => l_historical_infl_adj_rec
139 );
140
141 CST_MGD_INFL_ADJUSTMENT_PVT.Insert_Inflation_Adj
142 ( p_inflation_adjustment_rec => l_historical_infl_adj_rec
143 );
144
145 -- Make period final
146 Create_Period_Final_Status
147 ( p_org_id => l_historical_infl_adj_rec.organization_id
148 , p_acct_period_id => l_historical_infl_adj_rec.acct_period_id
149 , x_return_status => l_return_status
150 );
151
152 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
153 THEN
154 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
155 ELSIF l_return_status = FND_API.G_RET_STS_ERROR
156 THEN
157 RAISE FND_API.G_EXC_ERROR;
158 END IF;
159
160 EXCEPTION
161
162 WHEN FND_API.G_EXC_ERROR THEN
163 x_return_status := FND_API.G_RET_STS_ERROR;
164 DELETE FROM CST_MGD_INFL_ADJUSTED_COSTS
165 WHERE Organization_ID = l_historical_infl_adj_rec.organization_id
166 AND Acct_Period_ID = l_historical_infl_adj_rec.acct_period_id;
167
168 -- Get message count and data
169 FND_MSG_PUB.Count_And_Get
170 ( p_count => x_msg_count
171 , p_data => x_msg_data
172 );
173 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
174 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
175 DELETE FROM CST_MGD_INFL_ADJUSTED_COSTS
176 WHERE Organization_ID = l_historical_infl_adj_rec.organization_id
177 AND Acct_Period_ID = l_historical_infl_adj_rec.acct_period_id;
178
179 -- Get message count and data
180 FND_MSG_PUB.Count_And_Get
181 ( p_count => x_msg_count
182 , p_data => x_msg_data
183 );
184 WHEN OTHERS THEN
185 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
186 DELETE FROM CST_MGD_INFL_ADJUSTED_COSTS
187 WHERE Organization_ID = l_historical_infl_adj_rec.organization_id
188 AND Acct_Period_ID = l_historical_infl_adj_rec.acct_period_id;
189
190 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
191 THEN
192 FND_MSG_PUB.Add_Exc_Msg
193 ( G_PKG_NAME
194 , 'Create_Historical_Cost'
195 );
196 END IF;
197 -- Get message count and data
198 FND_MSG_PUB.Count_And_Get
199 ( p_count => x_msg_count
200 , p_data => x_msg_data
201 );
202
203 END Create_Historical_Cost;
204
205
206 --========================================================================
207 -- PROCEDURE : Delete_All_Historical_Costs PUBLIC
208 -- PARAMETERS: p_api_version_number known api version error buffer
209 -- p_init_msg_list FND_API.G_TRUE to reset list
210 -- x_return_status return status
211 -- x_msg_count number of messages in the list
212 -- x_msg_data text of messages
213 -- VERSION : current version 1.0
214 -- initial version 1.0
215 -- COMMENT : User use this API to refresh the inflation adjustment
216 -- process
217 --========================================================================
218 PROCEDURE Delete_All_Historical_Costs (
219 p_api_version_number IN NUMBER
220 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
221 , x_return_status OUT NOCOPY VARCHAR2
222 , x_msg_count OUT NOCOPY NUMBER
223 , x_msg_data OUT NOCOPY VARCHAR2
224 )
225 IS
226 l_return_status VARCHAR2(1);
227 l_api_version_number NUMBER := 1.0;
228 L_API_NAME CONSTANT VARCHAR2(30) := 'Delete_All_Historical_Costs';
229 BEGIN
230
231 -- Standard call to check for call compatibility
232 IF NOT FND_API.Compatible_API_Call
233 ( l_api_version_number
234 , p_api_version_number
235 , L_API_NAME
236 , G_PKG_NAME
237 )
238 THEN
239 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
240 END IF;
241
242 -- Initialize message stack if required
243 IF FND_API.to_Boolean(p_init_msg_list)
244 THEN
245 FND_MSG_PUB.initialize;
246 END IF;
247
248 DELETE FROM CST_MGD_INFL_ADJUSTED_COSTS;
249
250 DELETE FROM CST_MGD_INFL_TSF_ORG_ENTRIES;
251
252 DELETE FROM CST_MGD_INFL_ADJ_PER_STATUSES;
253
254 EXCEPTION
255
256 WHEN FND_API.G_EXC_ERROR THEN
257 x_return_status := FND_API.G_RET_STS_ERROR;
258 -- Get message count and data
259 FND_MSG_PUB.Count_And_Get
260 ( p_count => x_msg_count
261 , p_data => x_msg_data
262 );
263 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
264 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
265 -- Get message count and data
266 FND_MSG_PUB.Count_And_Get
267 ( p_count => x_msg_count
268 , p_data => x_msg_data
269 );
270 WHEN OTHERS THEN
271 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
272 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
273 THEN
274 FND_MSG_PUB.Add_Exc_Msg
275 ( G_PKG_NAME
276 , 'Delete_All_Historical_Costs'
277 );
278 END IF;
279 -- Get message count and data
280 FND_MSG_PUB.Count_And_Get
281 ( p_count => x_msg_count
282 , p_data => x_msg_data
283 );
284
285 END Delete_All_Historical_Costs;
286
287
288 END CST_MGD_INFL_ADJUSTMENT_PUB;