1 PACKAGE BODY CSD_ANALYSIS_UTIL AS
2 /* $Header: csdvanub.pls 115.0 2002/11/19 22:28:58 swai noship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'CSD_ANALYSIS_UTIL';
5 G_FILE_NAME CONSTANT VARCHAR2(12) := 'csdvanub.pls';
6 l_debug NUMBER := fnd_profile.value('CSD_DEBUG_LEVEL');
7
8 /*----------------------------------------------------------------*/
9 /* function name: Get_CurrencyCode */
10 /* description : Gets the currency from GL_SETS_OF_BOOKS for an */
11 /* organization */
12 /* */
13 /* p_organization_id Organization ID to get currency */
14 /* */
15 /*----------------------------------------------------------------*/
16 FUNCTION Get_CurrencyCode (
17 p_organization_id IN NUMBER
18 )
19 RETURN VARCHAR2
20 IS
21 BEGIN
22 RETURN NULL;
23 END Get_CurrencyCode;
24
25 /*----------------------------------------------------------------*/
26 /* procedure name: Convert_CurrencyAmount */
27 /* description : Converts an amount from one currency to */
28 /* another currency */
29 /* */
30 /* p_api_version Standard IN param */
31 /* p_commit Standard IN param */
32 /* p_init_msg_list Standard IN param */
33 /* p_validation_level Standard IN param */
34 /* p_from_currency Currency code to convert from */
35 /* p_to_currency Currency code to convert to */
36 /* p_eff_date Conversion Date */
37 /* p_amount Amount to convert */
38 /* p_conv_type Conversion type */
39 /* x_conv_amount Converted amount */
40 /* x_return_status Standard OUT param */
41 /* x_msg_count Standard OUT param */
42 /* x_msg_data Standard OUT param */
43 /* */
44 /*----------------------------------------------------------------*/
45 PROCEDURE Convert_CurrencyAmount (
46 p_api_version IN NUMBER,
47 p_commit IN VARCHAR2,
48 p_init_msg_list IN VARCHAR2,
49 p_validation_level IN NUMBER,
50 p_from_currency IN VARCHAR2,
51 p_to_currency IN VARCHAR2,
52 p_eff_date IN DATE,
53 p_amount IN NUMBER,
54 p_conv_type IN VARCHAR2,
55 x_conv_amount OUT NOCOPY NUMBER,
56 x_return_status OUT NOCOPY VARCHAR2,
57 x_msg_count OUT NOCOPY NUMBER,
58 x_msg_data OUT NOCOPY VARCHAR2
59 )
60 IS
61 l_api_name CONSTANT VARCHAR2(30) := 'Convert_CurrencyAmount';
62 l_api_version CONSTANT NUMBER := 1.0;
63 BEGIN
64 -- Standard Start of API savepoint
65 SAVEPOINT Convert_CurrencyAmount_Utl;
66
67 -- Standard call to check for call compatibility.
68 IF NOT FND_API.Compatible_API_Call (l_api_version,
69 p_api_version,
70 l_api_name,
71 G_PKG_NAME)
72 THEN
73 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
74 END IF;
75
76 -- Initialize message list if p_init_msg_list is set to TRUE.
77 IF FND_API.to_Boolean(p_init_msg_list) THEN
78 FND_MSG_PUB.initialize;
79 END IF;
80
81 -- Initialize API return status to success
82 x_return_status := FND_API.G_RET_STS_SUCCESS;
83
84 --
85 -- Begin API Body
86 --
87
88 --
89 -- End API Body
90 --
91
92 -- Standard check of p_commit.
93 IF FND_API.To_Boolean( p_commit ) THEN
94 COMMIT WORK;
95 END IF;
96
97 -- Standard call to get message count and IF count is get message info.
98 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
99 p_data => x_msg_data );
100 EXCEPTION
101 WHEN FND_API.G_EXC_ERROR THEN
102 ROLLBACK TO Convert_CurrencyAmount_Utl;
103 x_return_status := FND_API.G_RET_STS_ERROR ;
104 FND_MSG_PUB.Count_And_Get
105 (p_count => x_msg_count,
106 p_data => x_msg_data
107 );
108 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
109 ROLLBACK TO Convert_CurrencyAmount_Utl;
110 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
111 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
112 p_data => x_msg_data );
113 WHEN OTHERS THEN
114 ROLLBACK TO Convert_CurrencyAmount_Utl;
115 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
116 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
117 THEN
118 FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
119 l_api_name );
120 END IF;
121 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
122 p_data => x_msg_data );
123 END Convert_CurrencyAmount;
124
125 /*----------------------------------------------------------------*/
126 /* procedure name: Get_TotalActCosts */
127 /* description : Given a repair line id, gets the total MLE */
128 /* actual costs. */
129 /* */
130 /* p_api_version Standard IN param */
131 /* p_commit Standard IN param */
132 /* p_init_msg_list Standard IN param */
133 /* p_validation_level Standard IN param */
134 /* p_repair_line_id Repair Line ID to get actual costs*/
135 /* p_currency_code Currency to convert costs to */
136 /* x_costs Total MLE costs for repair line */
137 /* x_return_status Standard OUT param */
138 /* x_msg_count Standard OUT param */
139 /* x_msg_data Standard OUT param */
140 /* */
141 /*----------------------------------------------------------------*/
142 PROCEDURE Get_TotalActCosts
143 (
144 p_api_version IN NUMBER,
145 p_commit IN VARCHAR2,
146 p_init_msg_list IN VARCHAR2,
147 p_validation_level IN NUMBER,
148 p_repair_line_id IN NUMBER,
149 p_currency_code IN VARCHAR2, --currency to convert costs to
150 x_costs OUT NOCOPY MLE_TOTALS_REC_TYPE,
151 x_return_status OUT NOCOPY VARCHAR2,
152 x_msg_count OUT NOCOPY NUMBER,
153 x_msg_data OUT NOCOPY VARCHAR2
154 )
155 IS
156 l_api_name CONSTANT VARCHAR2(30) := 'Get_TotalActCosts';
157 l_api_version CONSTANT NUMBER := 1.0;
158 BEGIN
159 -- Standard Start of API savepoint
160 SAVEPOINT Get_TotalActCosts_Utl;
161
162 -- Standard call to check for call compatibility.
163 IF NOT FND_API.Compatible_API_Call (l_api_version,
164 p_api_version,
165 l_api_name,
166 G_PKG_NAME)
167 THEN
168 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
169 END IF;
170
171 -- Initialize message list if p_init_msg_list is set to TRUE.
172 IF FND_API.to_Boolean(p_init_msg_list) THEN
173 FND_MSG_PUB.initialize;
174 END IF;
175
176 -- Initialize API return status to success
177 x_return_status := FND_API.G_RET_STS_SUCCESS;
178
179 --
180 -- Begin API Body
181 --
182
183 --
184 -- End API Body
185 --
186
187 -- Standard check of p_commit.
188 IF FND_API.To_Boolean( p_commit ) THEN
189 COMMIT WORK;
190 END IF;
191
192 -- Standard call to get message count and IF count is get message info.
193 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
194 p_data => x_msg_data );
195 EXCEPTION
196 WHEN FND_API.G_EXC_ERROR THEN
197 ROLLBACK TO Get_TotalActCosts_Utl;
198 x_return_status := FND_API.G_RET_STS_ERROR ;
199 FND_MSG_PUB.Count_And_Get
200 (p_count => x_msg_count,
201 p_data => x_msg_data
202 );
203 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
204 ROLLBACK TO Get_TotalActCosts_Utl;
205 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
206 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
207 p_data => x_msg_data );
208 WHEN OTHERS THEN
209 ROLLBACK TO Get_TotalActCosts_Utl;
210 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
211 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
212 THEN
213 FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
214 l_api_name );
215 END IF;
216 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
217 p_data => x_msg_data );
218 END Get_TotalActCosts;
219
220
221 /*----------------------------------------------------------------*/
222 /* procedure name: Get_TotalEstCosts */
223 /* description : Given an estimate header, gets the total MLE */
224 /* estimated costs. */
225 /* */
226 /* p_api_version Standard IN param */
227 /* p_commit Standard IN param */
228 /* p_init_msg_list Standard IN param */
229 /* p_validation_level Standard IN param */
230 /* p_estimate_header_id Est header ID to get est costs for*/
231 /* p_currency_code Currency to convert costs to */
232 /* x_costs Total MLE costs for repair line */
233 /* x_return_status Standard OUT param */
234 /* x_msg_count Standard OUT param */
235 /* x_msg_data Standard OUT param */
236 /* */
237 /*----------------------------------------------------------------*/
238 PROCEDURE Get_TotalEstCosts (
239 p_api_version IN NUMBER,
240 p_commit IN VARCHAR2,
241 p_init_msg_list IN VARCHAR2,
242 p_validation_level IN NUMBER,
243 p_estimate_header_id IN NUMBER,
244 x_costs OUT NOCOPY MLE_TOTALS_REC_TYPE,
245 x_return_status OUT NOCOPY VARCHAR2,
246 x_msg_count OUT NOCOPY NUMBER,
247 x_msg_data OUT NOCOPY VARCHAR2
248 )
249 IS
250 l_api_name CONSTANT VARCHAR2(30) := 'Get_TotalEstCosts';
251 l_api_version CONSTANT NUMBER := 1.0;
252 BEGIN
253 -- Standard Start of API savepoint
254 SAVEPOINT Get_TotalEstCosts_Utl;
255
256 -- Standard call to check for call compatibility.
257 IF NOT FND_API.Compatible_API_Call (l_api_version,
258 p_api_version,
259 l_api_name,
260 G_PKG_NAME)
261 THEN
262 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
263 END IF;
264
265 -- Initialize message list if p_init_msg_list is set to TRUE.
266 IF FND_API.to_Boolean(p_init_msg_list) THEN
267 FND_MSG_PUB.initialize;
268 END IF;
269
270 -- Initialize API return status to success
271 x_return_status := FND_API.G_RET_STS_SUCCESS;
272
273 --
274 -- Begin API Body
275 --
276
277 --
278 -- End API Body
279 --
280
281 -- Standard check of p_commit.
282 IF FND_API.To_Boolean( p_commit ) THEN
283 COMMIT WORK;
284 END IF;
285
286 -- Standard call to get message count and IF count is get message info.
287 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
288 p_data => x_msg_data );
289 EXCEPTION
290 WHEN FND_API.G_EXC_ERROR THEN
291 ROLLBACK TO Get_TotalEstCosts_Utl;
292 x_return_status := FND_API.G_RET_STS_ERROR ;
293 FND_MSG_PUB.Count_And_Get
294 (p_count => x_msg_count,
295 p_data => x_msg_data
296 );
297 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
298 ROLLBACK TO Get_TotalEstCosts_Utl;
299 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
300 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
301 p_data => x_msg_data );
302 WHEN OTHERS THEN
303 ROLLBACK TO Get_TotalEstCosts_Utl;
304 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
305 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
306 THEN
307 FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
308 l_api_name );
309 END IF;
310 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
311 p_data => x_msg_data );
312 END Get_TotalEstCosts;
313
314 /*----------------------------------------------------------------*/
315 /* procedure name: Compare_MLETotals */
316 /* description : Compares any two records of */
317 /* MLE_total_record_type by amount and percent. */
318 /* Difference is calculated by basis - compare. */
319 /* Percent is determined by dividing difference */
320 /* by the basis. If currencies are different, */
321 /* Difference will be in currency of compare amts */
322 /* */
323 /* p_api_version Standard IN param */
324 /* p_commit Standard IN param */
325 /* p_init_msg_list Standard IN param */
326 /* p_validation_level Standard IN param */
327 /* p_mle_totals_basis Totals to use as basis */
328 /* p_mle_totals_compare Totals to compare to basis */
329 /* x_diff Basis - Compare */
330 /* x_pct_diff (Basis - Compare)*100/Basis */
331 /* x_return_status Standard OUT param */
332 /* x_msg_count Standard OUT param */
333 /* x_msg_data Standard OUT param */
334 /* */
335 /*----------------------------------------------------------------*/
336 PROCEDURE Compare_MLETotals (
337 p_api_version IN NUMBER,
338 p_commit IN VARCHAR2,
339 p_init_msg_list IN VARCHAR2,
340 p_validation_level IN NUMBER,
341 p_mle_totals_basis IN MLE_TOTALS_REC_TYPE,
342 p_mle_totals_compare IN MLE_TOTALS_REC_TYPE,
343 x_diff OUT NOCOPY MLE_TOTALS_REC_TYPE,
344 x_pct_diff OUT NOCOPY MLE_TOTALS_REC_TYPE,
345 x_return_status OUT NOCOPY VARCHAR2,
346 x_msg_count OUT NOCOPY NUMBER,
347 x_msg_data OUT NOCOPY VARCHAR2
348 )
349 IS
350 l_api_name CONSTANT VARCHAR2(30) := 'Compare_MLETotals';
351 l_api_version CONSTANT NUMBER := 1.0;
352 BEGIN
353 -- Standard Start of API savepoint
354 SAVEPOINT Compare_MLETotals_Utl;
355
356 -- Standard call to check for call compatibility.
357 IF NOT FND_API.Compatible_API_Call (l_api_version,
358 p_api_version,
359 l_api_name,
360 G_PKG_NAME)
361 THEN
362 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
363 END IF;
364
365 -- Initialize message list if p_init_msg_list is set to TRUE.
366 IF FND_API.to_Boolean(p_init_msg_list) THEN
367 FND_MSG_PUB.initialize;
368 END IF;
369
370 -- Initialize API return status to success
371 x_return_status := FND_API.G_RET_STS_SUCCESS;
372
373 --
374 -- Begin API Body
375 --
376
377 --
378 -- End API Body
379 --
380
381 -- Standard check of p_commit.
382 IF FND_API.To_Boolean( p_commit ) THEN
383 COMMIT WORK;
384 END IF;
385
386 -- Standard call to get message count and IF count is get message info.
387 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
388 p_data => x_msg_data );
389 EXCEPTION
390 WHEN FND_API.G_EXC_ERROR THEN
391 ROLLBACK TO Compare_MLETotals_Utl;
392 x_return_status := FND_API.G_RET_STS_ERROR ;
393 FND_MSG_PUB.Count_And_Get
394 (p_count => x_msg_count,
395 p_data => x_msg_data
396 );
397 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
398 ROLLBACK TO Compare_MLETotals_Utl;
399 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
400 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
401 p_data => x_msg_data );
402 WHEN OTHERS THEN
403 ROLLBACK TO Compare_MLETotals_Utl;
404 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
405 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
406 THEN
407 FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
408 l_api_name );
409 END IF;
410 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
411 p_data => x_msg_data );
412 END Compare_MLETotals;
413
414 END CSD_ANALYSIS_UTIL ;