[Home] [Help]
PACKAGE BODY: APPS.GMF_LOTCOSTADJUSTMENT_PUB
Source
1 PACKAGE BODY GMF_LOTCOSTADJUSTMENT_PUB AS
2 /* $Header: GMFPLCAB.pls 120.8.12000000.2 2007/03/15 10:16:03 pmarada ship $ */
3
4 --+==========================================================================+
5 --| Copyright (c) 1998 Oracle Corporation |
6 --| Redwood Shores, CA, USA |
7 --| All rights reserved. |
8 --+==========================================================================+
9 --| File Name : GMFPLCAB.pls |
10 --| Package Name : GMF_LotCostAdjustment_PUB |
11 --| API name : GMF_LotCostAdjustment_PUB |
12 --| Type : Public |
13 --| Pre-reqs : N/A |
14 --| Function : Lot Cost Adjustment Creation, Updation, Query and |
15 --| Deletion |
16 --| |
17 --| Parameters : N/A |
18 --| |
19 --| Current Vers : 1.0 |
20 --| Previous Vers : None |
21 --| Initial Vers : 1.0 |
22 --| |
23 --| Notes |
24 --| This package contains public procedures relating to Lot Cost |
25 --| This package contains public procedures relating to Lot Cost |
26 --| Adjustment Creation, Updation, Query and Deletion |
27 --| |
28 --| HISTORY |
29 --| 22-Mar-2004 Anand Thiyagarajan Created |
30 --| 02-Jun-2004 Bug 3655773: Added g_tmp variable to initialize |
31 --| G_Msg_Level_Threshold global variable. |
32 --| |
33 --+==========================================================================+
34
35 -- Procedure to log Error messages
36 PROCEDURE log_msg(p_msg_text IN VARCHAR2);
37
38 --Procedure to add header record into error stack
39 PROCEDURE add_header_to_error_stack
40 (
41 p_header_rec GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type
42 );
43
44 --Procedure to validate parameters
45 PROCEDURE Validate_Input_Params
46 (
47 p_header_Rec IN OUT NOCOPY GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type
48 , p_dtl_Tbl IN OUT NOCOPY GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type
49 , p_operation IN VARCHAR2
50 , x_user_id OUT NOCOPY fnd_user.user_id%TYPE
51 , x_return_status OUT NOCOPY VARCHAR2
52 );
53
54 --Global Variables
55 G_PKG_NAME CONSTANT VARCHAR2(30) := 'GMF_LotCostAdjustment_PUB ';
56
57 --
58 -- Bug 3655773: Added following variable to initialize G_Msg_Level_Threshold global
59 -- variable from the profile 'FND: Message Level Threshold'. Otherwise next assignment
60 -- stmt will fail since G_Msg_Level_Threshold is initialized to 9.99E125 in FND_MSG_PUB
61 -- package and will cause ORA-6502 error.
62 --
63 -- We could made the variable just NUMBER, but it was done the following way in other APIs.
64 -- So, doing the same here.
65 --
66 G_tmp BOOLEAN := FND_MSG_PUB.Check_Msg_Level(0) ; -- temp call to initialize the
67 -- msg level threshhold gobal
68 -- variable.
69
70 G_debug_level NUMBER(2) := FND_MSG_PUB.G_Msg_Level_Threshold;
71
72 G_header_logged VARCHAR2(1) := 'N';
73
74 --+========================================================================+
75 --| API Name : Create_LotCost_Adjustment |
76 --| TYPE : Public |
77 --| Function : Creates Lot Cost Adjustment based on the input |
78 --| into table GMF_LOT_COST_ADJUSTMENTS |
79 --| Pre-reqa : None |
80 --| Parameters : |
81 --| IN : |
82 --| p_api_version IN NUMBER |
83 --| p_init_msg_list IN VARCHAR2 |
84 --| p_header_rec IN OUT NOCOPY |
85 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type |
86 --| p_dtl_Tbl IN OUT NOCOPY |
87 --| GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type |
88 --| |
89 --| OUT : |
90 --| x_return_status OUT NOCOPY VARCHAR2 |
91 --| x_msg_count OUT NOCOPY NUMBER |
92 --| x_msg_data OUT NOCOPY VARCHAR2 |
93 --| |
94 --| |
95 --| Version : |
96 --| Current Version : 2.0 |
97 --| Previous Version : 1.0 |
98 --| Initial Version : 1.0 |
99 --| |
100 --| Notes : |
101 --| Pre-defined API message levels |
102 --| |
103 --| Valid values for message levels are from 1-50. |
104 --| 1 being least severe and 50 highest. |
105 --| |
106 --| The pre-defined levels correspond to standard API |
107 --| return status. Debug levels are used to control the amount of |
108 --| debug information a program writes to the PL/SQL message table. |
109 --| |
110 --| G_MSG_LVL_UNEXP_ERROR CONSTANT NUMBER := 60; |
111 --| G_MSG_LVL_ERROR CONSTANT NUMBER := 50; |
112 --| G_MSG_LVL_SUCCESS CONSTANT NUMBER := 40; |
113 --| G_MSG_LVL_DEBUG_HIGH CONSTANT NUMBER := 30; |
114 --| G_MSG_LVL_DEBUG_MEDIUM CONSTANT NUMBER := 20; |
115 --| G_MSG_LVL_DEBUG_LOW CONSTANT NUMBER := 10; |
116 --| |
117 --| HISTORY |
118 --| 22-Mar-2004 Anand Thiyagarajan Created |
119 --| |
120 --+========================================================================+
121
122 PROCEDURE Create_LotCost_Adjustment
123 (
124 p_api_version IN NUMBER
125 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
126 , p_commit IN VARCHAR2 := FND_API.G_FALSE
127 , x_return_status OUT NOCOPY VARCHAR2
128 , x_msg_count OUT NOCOPY NUMBER
129 , x_msg_data OUT NOCOPY VARCHAR2
130 , p_header_rec IN OUT NOCOPY Lc_Adjustment_Header_Rec_Type
131 , p_dtl_Tbl IN OUT NOCOPY Lc_adjustment_dtls_Tbl_Type
132 )
133 IS
134 l_api_name CONSTANT VARCHAR2(30) := 'Create_LotCost_Adjustment';
135 l_api_version CONSTANT NUMBER := 2.0;
136 l_header_exists BOOLEAN;
137 l_detail_exists BOOLEAN;
138 user_cnt NUMBER;
139 l_user_id fnd_user.user_id%TYPE ;
140 l_return_status VARCHAR2(11) ;
141 BEGIN
142 -- Standard Start of API savepoint
143 SAVEPOINT Create_LotCost_Adjustment_PUB ;
144
145 -- Initialize message list if p_init_msg_list is set to TRUE.
146 IF FND_API.to_Boolean( p_init_msg_list )
147 THEN
148 FND_MSG_PUB.initialize;
149 END IF;
150
151 -- Standard call to check for call compatibility.
152 IF NOT FND_API.Compatible_API_Call (l_api_version ,
153 p_api_version ,
154 l_api_name ,
155 G_PKG_NAME
156 )
157 THEN
158 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
159 END IF;
160
161 -- Initialize API return status to success
162 x_return_status := FND_API.G_RET_STS_SUCCESS;
163
164 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
165 THEN
166 log_msg('Beginning Create Lot Cost Adjustment process.');
167 END IF;
168
169 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
170 THEN
171 log_msg('Validating input parameters');
172 END IF;
173
174 G_header_logged := 'N';
175
176 Validate_Input_Params
177 (
178 p_header_rec => p_header_rec
179 , p_dtl_tbl => p_dtl_tbl
180 , p_operation => 'INSERT'
181 , x_user_id => l_user_id
182 , x_return_status => l_return_status
183 );
184
185 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
186 THEN
187 log_msg('Return Status after validating : ' || l_return_status);
188 END IF;
189
190 IF l_return_status = FND_API.G_RET_STS_ERROR
191 THEN
192 add_header_to_error_stack ( p_header_Rec => p_header_rec );
193 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
194 FND_MSG_PUB.Add;
195 RAISE FND_API.G_EXC_ERROR;
196 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
197 THEN
198 add_header_to_error_stack ( p_header_Rec => p_header_rec );
199 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
200 FND_MSG_PUB.Add;
201 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
202 END IF;
203
204 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
205 THEN
206 log_msg('Calling private API to insert record...');
207 END IF;
208
209 --Call Private Procedure
210 GMF_LotCostAdjustment_PVT.Create_LotCost_Adjustment
211 (
212 p_api_version => p_api_version
213 , p_init_msg_list => FND_API.G_FALSE
214 , x_return_status => x_return_status
215 , x_msg_count => x_msg_count
216 , x_msg_data => x_msg_data
217 , p_header_rec => p_header_Rec
218 , p_dtl_Tbl => p_dtl_tbl
219 , p_user_id => l_user_id
220 );
221
222 -- Return if insert fails for any reason
223 IF l_return_status = FND_API.G_RET_STS_ERROR
224 THEN
225 add_header_to_error_stack ( p_header_Rec => p_header_rec );
226 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
227 FND_MSG_PUB.Add;
228 RAISE FND_API.G_EXC_ERROR;
229 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
230 THEN
231 add_header_to_error_stack ( p_header_Rec => p_header_rec );
232 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
233 FND_MSG_PUB.Add;
234 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
235 END IF;
236
237 FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_INS');
238 FND_MESSAGE.SET_TOKEN('NUM_ROWS',p_dtl_tbl.COUNT);
239 FND_MSG_PUB.Add;
240
241 -- Standard check of p_commit.
242 IF FND_API.To_Boolean( p_commit )
243 THEN
244 COMMIT WORK;
245 END IF;
246 -- Standard call to get message count and if count is 1, get message info.
247 FND_MSG_PUB.Count_And_Get
248 (
249 p_count => x_msg_count
250 , p_data => x_msg_data
251 );
252 EXCEPTION
253 WHEN FND_API.G_EXC_ERROR
254 THEN
255 ROLLBACK TO Create_LotCost_Adjustment_PUB;
256 add_header_to_error_stack ( p_header_Rec => p_header_rec );
257 x_return_status := FND_API.G_RET_STS_ERROR ;
258 FND_MSG_PUB.Count_And_Get
259 (
260 p_count => x_msg_count
261 , p_data => x_msg_data
262 );
263 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
264 THEN
265 ROLLBACK TO Create_LotCost_Adjustment_PUB;
266 add_header_to_error_stack ( p_header_Rec => p_header_rec );
267 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
268 FND_MSG_PUB.Count_And_Get
269 (
270 p_count => x_msg_count
271 ,p_data => x_msg_data
272 );
273 WHEN OTHERS
274 THEN
275 ROLLBACK TO Create_LotCost_Adjustment_PUB;
276 add_header_to_error_stack ( p_header_Rec => p_header_rec );
277 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
278 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
279 THEN
280 FND_MSG_PUB.Add_Exc_Msg
281 (
282 G_PKG_NAME
283 , l_api_name
284 );
285 END IF;
286 FND_MSG_PUB.Count_And_Get
287 (
288 p_count => x_msg_count
289 , p_data => x_msg_data
290 );
291 END Create_LotCost_Adjustment;
292
293 --+========================================================================+
294 --| API Name : Update_LotCost_Adjustment |
295 --| TYPE : Public |
296 --| Function : Updates Lot Cost Adjustment based on the input |
297 --| into table GMF_LOT_COST_ADJUSTMENTS |
298 --| Pre-reqa : None |
299 --| Parameters : |
300 --| IN : |
301 --| p_api_version IN NUMBER |
302 --| p_init_msg_list IN VARCHAR2 |
303 --| p_header_rec IN OUT NOCOPY |
304 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type |
305 --| p_dtl_Tbl IN OUT NOCOPY |
306 --| GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type |
307 --| |
308 --| OUT : |
309 --| x_return_status OUT NOCOPY VARCHAR2 |
310 --| x_msg_count OUT NOCOPY NUMBER |
311 --| x_msg_data OUT NOCOPY VARCHAR2 |
312 --| |
313 --| Version : |
314 --| Current Version : 2.0 |
315 --| Previous Version : 1.0 |
316 --| Initial Version : 1.0 |
317 --| |
318 --| Notes : |
319 --| Pre-defined API message levels |
320 --| |
321 --| Valid values for message levels are from 1-50. |
322 --| 1 being least severe and 50 highest. |
323 --| |
324 --| The pre-defined levels correspond to standard API |
325 --| return status. Debug levels are used to control the amount of |
326 --| debug information a program writes to the PL/SQL message table. |
327 --| |
328 --| G_MSG_LVL_UNEXP_ERROR CONSTANT NUMBER := 60; |
329 --| G_MSG_LVL_ERROR CONSTANT NUMBER := 50; |
330 --| G_MSG_LVL_SUCCESS CONSTANT NUMBER := 40; |
331 --| G_MSG_LVL_DEBUG_HIGH CONSTANT NUMBER := 30; |
332 --| G_MSG_LVL_DEBUG_MEDIUM CONSTANT NUMBER := 20; |
333 --| G_MSG_LVL_DEBUG_LOW CONSTANT NUMBER := 10; |
334 --| |
335 --| HISTORY |
336 --| 22-Mar-2004 Anand Thiyagarajan Created |
337 --| |
338 --+========================================================================+
339
340 PROCEDURE Update_LotCost_Adjustment
341 (
342 p_api_version IN NUMBER
343 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
344 , p_commit IN VARCHAR2 := FND_API.G_FALSE
345 , x_return_status OUT NOCOPY VARCHAR2
346 , x_msg_count OUT NOCOPY NUMBER
347 , x_msg_data OUT NOCOPY VARCHAR2
348 , p_header_rec IN OUT NOCOPY Lc_Adjustment_Header_Rec_Type
349 , p_dtl_Tbl IN OUT NOCOPY Lc_adjustment_dtls_Tbl_Type
350 )
351 IS
352 l_api_name CONSTANT VARCHAR2(30) := 'Update_LotCost_Adjustment';
353 l_api_version CONSTANT NUMBER := 2.0;
354 l_header_exists BOOLEAN;
355 l_detail_exists BOOLEAN;
356 user_cnt NUMBER;
357 l_user_id fnd_user.user_id%TYPE ;
358 l_return_status VARCHAR2(11) ;
359 BEGIN
360 -- Standard Start of API savepoint
361 SAVEPOINT Update_LotCost_Adjustment_PUB ;
362
363 -- Initialize message list if p_init_msg_list is set to TRUE.
364 IF FND_API.to_Boolean( p_init_msg_list )
365 THEN
366 FND_MSG_PUB.initialize;
367 END IF;
368
369 -- Standard call to check for call compatibility.
370 IF NOT FND_API.Compatible_API_Call (l_api_version ,
371 p_api_version ,
372 l_api_name ,
373 G_PKG_NAME
374 )
375 THEN
376 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
377 END IF;
378
379 -- Initialize API return status to success
380 x_return_status := FND_API.G_RET_STS_SUCCESS;
381
382 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
383 THEN
384 log_msg('Beginning Update Lot Cost Adjustment process.');
385 END IF;
386
387 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
388 THEN
389 log_msg('Validating input parameters');
390 END IF;
391
392 G_header_logged := 'N';
393
394 Validate_Input_Params
395 (
396 p_header_rec => p_header_rec
397 , p_dtl_tbl => p_dtl_tbl
398 , p_operation => 'UPDATE'
399 , x_user_id => l_user_id
400 , x_return_status => l_return_status
401 );
402
403 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
404 THEN
405 log_msg('Return Status after validating : ' || l_return_status);
406 END IF;
407
408 IF l_return_status = FND_API.G_RET_STS_ERROR
409 THEN
410 add_header_to_error_stack ( p_header_Rec => p_header_rec );
411 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
412 FND_MSG_PUB.Add;
413 RAISE FND_API.G_EXC_ERROR;
414 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
415 THEN
416 add_header_to_error_stack ( p_header_Rec => p_header_rec );
417 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
418 FND_MSG_PUB.Add;
419 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
420 END IF;
421
422 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
423 THEN
424 log_msg('Calling private API to Update record...');
425 END IF;
426
427 --Call Private Procedure
428 GMF_LotCostAdjustment_PVT.Update_LotCost_Adjustment
429 (
430 p_api_version => p_api_version
431 , p_init_msg_list => FND_API.G_FALSE
432 , x_return_status => x_return_status
433 , x_msg_count => x_msg_count
434 , x_msg_data => x_msg_data
435 , p_header_rec => p_header_Rec
436 , p_dtl_Tbl => p_dtl_tbl
437 , p_user_id => l_user_id
438 );
439
440 -- Return if update fails for any reason
441 IF l_return_status = FND_API.G_RET_STS_ERROR
442 THEN
443 add_header_to_error_stack ( p_header_Rec => p_header_rec );
444 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
445 FND_MSG_PUB.Add;
446 RAISE FND_API.G_EXC_ERROR;
447 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
448 THEN
449 add_header_to_error_stack ( p_header_Rec => p_header_rec );
450 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
451 FND_MSG_PUB.Add;
452 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
453 END IF;
454
455 FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_UPD');
456 FND_MESSAGE.SET_TOKEN('NUM_ROWS',p_dtl_tbl.COUNT);
457 FND_MSG_PUB.Add;
458
459 -- Standard check of p_commit.
460 IF FND_API.To_Boolean( p_commit )
461 THEN
462 COMMIT WORK;
463 END IF;
464 -- Standard call to get message count and if count is 1, get message info.
465 FND_MSG_PUB.Count_And_Get
466 (
467 p_count => x_msg_count
468 , p_data => x_msg_data
469 );
470 EXCEPTION
471 WHEN FND_API.G_EXC_ERROR
472 THEN
473 ROLLBACK TO Update_LotCost_Adjustment_PUB;
474 add_header_to_error_stack ( p_header_Rec => p_header_rec );
475 x_return_status := FND_API.G_RET_STS_ERROR ;
476 FND_MSG_PUB.Count_And_Get
477 (
478 p_count => x_msg_count
479 , p_data => x_msg_data
480 );
481 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
482 THEN
483 ROLLBACK TO Update_LotCost_Adjustment_PUB;
484 add_header_to_error_stack ( p_header_Rec => p_header_rec );
485 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
486 FND_MSG_PUB.Count_And_Get
487 (
488 p_count => x_msg_count
489 ,p_data => x_msg_data
490 );
491 WHEN OTHERS
492 THEN
493 ROLLBACK TO Update_LotCost_Adjustment_PUB;
494 add_header_to_error_stack ( p_header_Rec => p_header_rec );
495 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
496 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
497 THEN
498 FND_MSG_PUB.Add_Exc_Msg
499 (
500 G_PKG_NAME
501 , l_api_name
502 );
503 END IF;
504 FND_MSG_PUB.Count_And_Get
505 (
506 p_count => x_msg_count
507 , p_data => x_msg_data
508 );
509 END Update_LotCost_Adjustment;
510
511 --+========================================================================+
512 --| API Name : Delete_LotCost_Adjustment |
513 --| TYPE : Public |
514 --| Function : Deletes Lot Cost Adjustment based on the input |
515 --| from table GMF_LOT_COST_ADJUSTMENTS |
516 --| Pre-reqa : None |
517 --| Parameters : |
518 --| IN : |
519 --| p_api_version IN NUMBER |
520 --| p_init_msg_list IN VARCHAR2 |
521 --| p_header_rec IN OUT NOCOPY |
522 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type |
523 --| p_dtl_Tbl IN OUT NOCOPY |
524 --| GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type |
525 --| |
526 --| OUT : |
527 --| x_return_status OUT NOCOPY VARCHAR2 |
528 --| x_msg_count OUT NOCOPY NUMBER |
529 --| x_msg_data OUT NOCOPY VARCHAR2 |
530 --| |
531 --| Version : |
532 --| Current Version : 2.0 |
533 --| Previous Version : 1.0 |
534 --| Initial Version : 1.0 |
535 --| |
536 --| Notes : |
537 --| Pre-defined API message levels |
538 --| |
539 --| Valid values for message levels are from 1-50. |
540 --| 1 being least severe and 50 highest. |
541 --| |
542 --| The pre-defined levels correspond to standard API |
543 --| return status. Debug levels are used to control the amount of |
544 --| debug information a program writes to the PL/SQL message table. |
545 --| |
546 --| G_MSG_LVL_UNEXP_ERROR CONSTANT NUMBER := 60; |
547 --| G_MSG_LVL_ERROR CONSTANT NUMBER := 50; |
548 --| G_MSG_LVL_SUCCESS CONSTANT NUMBER := 40; |
549 --| G_MSG_LVL_DEBUG_HIGH CONSTANT NUMBER := 30; |
550 --| G_MSG_LVL_DEBUG_MEDIUM CONSTANT NUMBER := 20; |
551 --| G_MSG_LVL_DEBUG_LOW CONSTANT NUMBER := 10; |
552 --| |
553 --| HISTORY |
554 --| 22-Mar-2004 Anand Thiyagarajan Created |
555 --| |
556 --+========================================================================+
557
558 PROCEDURE Delete_LotCost_Adjustment
559 (
560 p_api_version IN NUMBER
561 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
562 , p_commit IN VARCHAR2 := FND_API.G_FALSE
563 , x_return_status OUT NOCOPY VARCHAR2
564 , x_msg_count OUT NOCOPY NUMBER
565 , x_msg_data OUT NOCOPY VARCHAR2
566 , p_header_rec IN OUT NOCOPY Lc_Adjustment_Header_Rec_Type
567 , p_dtl_Tbl IN OUT NOCOPY Lc_adjustment_dtls_Tbl_Type
568 )
569 IS
570 l_api_name CONSTANT VARCHAR2(30) := 'Delete_LotCost_Adjustment';
571 l_api_version CONSTANT NUMBER := 2.0;
572 l_header_exists BOOLEAN;
573 l_detail_exists BOOLEAN;
574 user_cnt NUMBER;
575 l_user_id fnd_user.user_id%TYPE ;
576 l_return_status VARCHAR2(2) ;
577 BEGIN
578 -- Standard Start of API savepoint
579 SAVEPOINT Delete_LotCost_Adjustment_PUB ;
580
581 -- Initialize message list if p_init_msg_list is set to TRUE.
582 IF FND_API.to_Boolean( p_init_msg_list )
583 THEN
584 FND_MSG_PUB.initialize;
585 END IF;
586
587 -- Standard call to check for call compatibility.
588 IF NOT FND_API.Compatible_API_Call (l_api_version ,
589 p_api_version ,
590 l_api_name ,
591 G_PKG_NAME
592 )
593 THEN
594 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
595 END IF;
596
597 -- Initialize API return status to success
598 x_return_status := FND_API.G_RET_STS_SUCCESS;
599
600 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
601 THEN
602 log_msg('Beginning Delete Lot Cost Adjustment process.');
603 END IF;
604
605 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
606 THEN
607 log_msg('Validating input parameters');
608 END IF;
609
610 G_header_logged := 'N';
611
612 Validate_Input_Params
613 (
614 p_header_rec => p_header_rec
615 , p_dtl_tbl => p_dtl_tbl
616 , p_operation => 'DELETE'
617 , x_user_id => l_user_id
618 , x_return_status => l_return_status
619 );
620
621 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
622 THEN
623 log_msg('Return Status after validating : ' || l_return_status);
624 END IF;
625
626 IF l_return_status = FND_API.G_RET_STS_ERROR
627 THEN
628 add_header_to_error_stack ( p_header_Rec => p_header_rec );
629 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
630 FND_MSG_PUB.Add;
631 RAISE FND_API.G_EXC_ERROR;
632 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
633 THEN
634 add_header_to_error_stack ( p_header_Rec => p_header_rec );
635 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
636 FND_MSG_PUB.Add;
637 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
638 END IF;
639
640 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
641 THEN
642 log_msg('Calling private API to Delete record...');
643 END IF;
644
645 --Call Private Procedure
646 GMF_LotCostAdjustment_PVT.Delete_LotCost_Adjustment
647 (
648 p_api_version => p_api_version
649 , p_init_msg_list => FND_API.G_FALSE
650 , x_return_status => x_return_status
651 , x_msg_count => x_msg_count
652 , x_msg_data => x_msg_data
653 , p_header_rec => p_header_Rec
654 , p_dtl_Tbl => p_dtl_tbl
655 );
656
657 -- Return if delete fails for any reason
658 IF l_return_status = FND_API.G_RET_STS_ERROR
659 THEN
660 add_header_to_error_stack ( p_header_Rec => p_header_rec );
661 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
662 FND_MSG_PUB.Add;
663 RAISE FND_API.G_EXC_ERROR;
664 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
665 THEN
666 add_header_to_error_stack ( p_header_Rec => p_header_rec );
667 FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
668 FND_MSG_PUB.Add;
669 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
670 END IF;
671
672 FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_DEL');
673 FND_MESSAGE.SET_TOKEN('NUM_ROWS',p_dtl_tbl.COUNT);
674 FND_MSG_PUB.Add;
675
676 -- Standard check of p_commit.
677 IF FND_API.To_Boolean( p_commit )
678 THEN
679 COMMIT WORK;
680 END IF;
681 -- Standard call to get message count and if count is 1, get message info.
682 FND_MSG_PUB.Count_And_Get
683 (
684 p_count => x_msg_count
685 , p_data => x_msg_data
686 );
687 EXCEPTION
688 WHEN FND_API.G_EXC_ERROR
689 THEN
690 ROLLBACK TO Delete_LotCost_Adjustment_PUB;
691 add_header_to_error_stack ( p_header_Rec => p_header_rec );
692 x_return_status := FND_API.G_RET_STS_ERROR ;
693 FND_MSG_PUB.Count_And_Get
694 (
695 p_count => x_msg_count
696 , p_data => x_msg_data
697 );
698 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
699 THEN
700 ROLLBACK TO Delete_LotCost_Adjustment_PUB;
701 add_header_to_error_stack ( p_header_Rec => p_header_rec );
702 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
703 FND_MSG_PUB.Count_And_Get
704 (
705 p_count => x_msg_count
706 ,p_data => x_msg_data
707 );
708 WHEN OTHERS
709 THEN
710 ROLLBACK TO Delete_LotCost_Adjustment_PUB;
711 add_header_to_error_stack ( p_header_Rec => p_header_rec );
712 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
713 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
714 THEN
715 FND_MSG_PUB.Add_Exc_Msg
716 (
717 G_PKG_NAME
718 , l_api_name
719 );
720 END IF;
721 FND_MSG_PUB.Count_And_Get
722 (
723 p_count => x_msg_count
724 , p_data => x_msg_data
725 );
726 END Delete_LotCost_Adjustment;
727
728 --+========================================================================+
729 --| API Name : Get_LotCost_Adjustment |
730 --| TYPE : Public |
731 --| Function : Fetchs Lot Cost Adjustment based on the input |
732 --| from table GMF_LOT_COST_ADJUSTMENTS |
733 --| Pre-reqa : None |
734 --| Parameters : |
735 --| IN : |
736 --| p_api_version IN NUMBER |
737 --| p_init_msg_list IN VARCHAR2 |
738 --| p_header_rec IN OUT NOCOPY |
739 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type |
740 --| p_dtl_Tbl IN OUT NOCOPY |
741 --| GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type |
742 --| |
743 --| OUT : |
744 --| x_return_status OUT NOCOPY VARCHAR2 |
745 --| x_msg_count OUT NOCOPY NUMBER |
746 --| x_msg_data OUT NOCOPY VARCHAR2 |
747 --| |
748 --| Version : |
749 --| Current Version : 2.0 |
750 --| Previous Version : 1.0 |
751 --| Initial Version : 1.0 |
752 --| |
753 --| Notes : |
754 --| Pre-defined API message levels |
755 --| |
756 --| Valid values for message levels are from 1-50. |
757 --| 1 being least severe and 50 highest. |
758 --| |
759 --| The pre-defined levels correspond to standard API |
760 --| return status. Debug levels are used to control the amount of |
761 --| debug information a program writes to the PL/SQL message table. |
762 --| |
763 --| G_MSG_LVL_UNEXP_ERROR CONSTANT NUMBER := 60; |
764 --| G_MSG_LVL_ERROR CONSTANT NUMBER := 50; |
765 --| G_MSG_LVL_SUCCESS CONSTANT NUMBER := 40; |
766 --| G_MSG_LVL_DEBUG_HIGH CONSTANT NUMBER := 30; |
767 --| G_MSG_LVL_DEBUG_MEDIUM CONSTANT NUMBER := 20; |
768 --| G_MSG_LVL_DEBUG_LOW CONSTANT NUMBER := 10; |
769 --| |
770 --| HISTORY |
771 --| 22-Mar-2004 Anand Thiyagarajan Created |
772 --| |
773 --+========================================================================+
774
775 PROCEDURE Get_LotCost_Adjustment
776 (
777 p_api_version IN NUMBER
778 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
779 , x_return_status OUT NOCOPY VARCHAR2
780 , x_msg_count OUT NOCOPY NUMBER
781 , x_msg_data OUT NOCOPY VARCHAR2
782 , p_header_rec IN OUT NOCOPY Lc_Adjustment_Header_Rec_Type
783 , p_dtl_Tbl OUT NOCOPY lc_adjustment_dtls_Tbl_Type
784 )
785 IS
786 l_api_name CONSTANT VARCHAR2(30) := 'Get_LotCost_Adjustment';
787 l_api_version CONSTANT NUMBER := 2.0;
788 l_header_exists BOOLEAN;
789 l_detail_exists BOOLEAN;
790 user_cnt NUMBER;
791 l_user_id fnd_user.user_id%TYPE ;
792 l_return_status VARCHAR2(2) ;
793 BEGIN
794 -- Standard Start of API savepoint
795 SAVEPOINT Get_LotCost_Adjustment_PUB ;
796
797 -- Initialize message list if p_init_msg_list is set to TRUE.
798 IF FND_API.to_Boolean( p_init_msg_list )
799 THEN
800 FND_MSG_PUB.initialize;
801 END IF;
802
803 -- Standard call to check for call compatibility.
804 IF NOT FND_API.Compatible_API_Call (l_api_version ,
805 p_api_version ,
806 l_api_name ,
807 G_PKG_NAME
808 )
809 THEN
810 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
811 END IF;
812
813 -- Initialize API return status to success
814 x_return_status := FND_API.G_RET_STS_SUCCESS;
815
816 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
817 THEN
818 log_msg('Beginning Get Lot Cost Adjustment process.');
819 END IF;
820
821 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
822 THEN
823 log_msg('Validating input parameters');
824 END IF;
825
826 G_header_logged := 'N';
827
828 Validate_Input_Params
829 (
830 p_header_rec => p_header_rec
831 , p_dtl_tbl => p_dtl_tbl
832 , p_operation => 'GET'
833 , x_user_id => l_user_id
834 , x_return_status => l_return_status
835 ) ;
836
837 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
838 THEN
839 log_msg('Return Status after validating : ' || l_return_status);
840 END IF;
841
842 IF l_return_status = FND_API.G_RET_STS_ERROR
843 THEN
844 add_header_to_error_stack ( p_header_Rec => p_header_rec );
845 RAISE FND_API.G_EXC_ERROR;
846 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
847 THEN
848 add_header_to_error_stack ( p_header_Rec => p_header_rec );
849 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
850 END IF;
851
852 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
853 THEN
854 log_msg('Calling private API to Get record...');
855 END IF;
856
857 --Call Private Procedure
858 GMF_LotCostAdjustment_PVT.Get_LotCost_Adjustment
859 (
860 p_api_version => p_api_version
861 , p_init_msg_list => FND_API.G_FALSE
862 , x_return_status => x_return_status
863 , x_msg_count => x_msg_count
864 , x_msg_data => x_msg_data
865 , p_header_rec => p_header_Rec
866 , p_dtl_Tbl => p_dtl_tbl
867 );
868
869 -- Return if Get fails for any reason
870 IF l_return_status = FND_API.G_RET_STS_ERROR
871 THEN
872 add_header_to_error_stack ( p_header_Rec => p_header_rec );
873 RAISE FND_API.G_EXC_ERROR;
874 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
875 THEN
876 add_header_to_error_stack ( p_header_Rec => p_header_rec );
877 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
878 END IF;
879
880 -- Standard call to get message count and if count is 1, get message info.
881 FND_MSG_PUB.Count_And_Get
882 ( p_count => x_msg_count ,
883 p_data => x_msg_data
884 );
885 EXCEPTION
886 WHEN FND_API.G_EXC_ERROR
887 THEN
888 ROLLBACK TO Get_LotCost_Adjustment_PUB;
889 add_header_to_error_stack ( p_header_Rec => p_header_rec );
890 x_return_status := FND_API.G_RET_STS_ERROR ;
891 FND_MSG_PUB.Count_And_Get
892 ( p_count => x_msg_count ,
893 p_data => x_msg_data
894 );
895 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
896 THEN
897 ROLLBACK TO Get_LotCost_Adjustment_PUB;
898 add_header_to_error_stack ( p_header_Rec => p_header_rec );
899 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
900 FND_MSG_PUB.Count_And_Get
901 ( p_count => x_msg_count ,
902 p_data => x_msg_data
903 );
904 WHEN OTHERS
905 THEN
906 ROLLBACK TO Get_LotCost_Adjustment_PUB;
907 add_header_to_error_stack ( p_header_Rec => p_header_rec );
908 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
909 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
910 THEN
911 FND_MSG_PUB.Add_Exc_Msg
912 ( G_PKG_NAME ,
913 l_api_name
914 );
915 END IF;
916 FND_MSG_PUB.Count_And_Get
917 ( p_count => x_msg_count ,
918 p_data => x_msg_data
919 );
920 END Get_LotCost_Adjustment ;
921
922 --+==========================================================================+
923 --| PROCEDURE NAME |
924 --| Validate_Input_Params |
925 --| |
926 --| DESCRIPTION |
927 --| Validates all the input parameters. |
928 --| |
929 --| PARAMETERS |
930 --| p_header_rec IN |
931 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type |
932 --| p_dtl_tbl IN |
933 --| GMF_LotCostAdjustment_PUB.Lc_Adjustment_dtls_tbl_Type |
934 --| p_operation IN VARCHAR2 |
935 --| x_user_id OUT fnd_user.user_id%TYPE |
936 --| x_return_status OUT VARCHAR2 |
937 --| |
938 --| HISTORY |
939 --| 22-MAR-2004 Anand Thiyagarajan - Created |
940 --| 18-dec-2006 bug 5705311, Modified the select query to fetch category_id|
941 --| for the cost class, pmarada |
942 --| 14-Mar-2007 Bug 5586137, Removed exception blk if there is no category |
943 --| id found for item, also modified code to insert correct |
944 --| values in created_by and updated_by fields |
945 --| |
946 --+==========================================================================+
947 -- Proc end of comments
948
949 PROCEDURE Validate_Input_Params
950 (
951 p_header_Rec IN OUT NOCOPY GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type
952 , p_dtl_Tbl IN OUT NOCOPY GMF_LotCostAdjustment_PUB.Lc_adjustment_dtls_Tbl_Type
953 , p_operation IN VARCHAR2
954 , x_user_id OUT NOCOPY fnd_user.user_id%TYPE
955 , x_return_status OUT NOCOPY VARCHAR2
956 )
957 IS
958 l_adjustment_date GMF_LOT_COST_ADJUSTMENTS.adjustment_date%TYPE;
959 l_reason_cnt NUMBER;
960 l_text_cnt NUMBER;
961 l_header_cnt NUMBER;
962 l_detail_cnt NUMBER;
963 l_adjustment_id GMF_LOT_COST_ADJUSTMENTS.adjustment_id%TYPE;
964 l_adjustment_dtl_id GMF_LOT_COST_ADJUSTMENT_DTLS.adjustment_dtl_id%TYPE;
965 l_adjustment_cost GMF_LOT_COST_ADJUSTMENT_DTLS.adjustment_cost%TYPE;
966 l_applied_ind GMF_LOT_COST_ADJUSTMENTS.applied_ind%TYPE;
967 l_cost_category_id NUMBER;
968 l_lot_costed_items_cnt NUMBER;
969 --l_itemcost_class IC_ITEM_MST.itemcost_class%TYPE;
970 --l_itemcost_class_cnt NUMBER;
971 BEGIN
972 -- Initialize API return status to success
973 x_return_status := FND_API.G_RET_STS_SUCCESS;
974 l_applied_ind := NULL;
975
976 IF P_OPERATION IN ('INSERT', 'UPDATE', 'DELETE', 'GET')
977 THEN
978 IF p_header_rec.adjustment_id IS NOT NULL
979 THEN
980 BEGIN
981 SELECT applied_ind
982 INTO l_applied_ind
983 FROM gmf_lot_cost_adjustments
984 WHERE adjustment_id = p_header_rec.adjustment_id
985 AND ROWNUM = 1;
986 EXCEPTION
987 WHEN NO_DATA_FOUND
988 THEN
989 l_applied_ind := NULL;
990 END;
991
992 IF l_applied_ind = 'Y'
993 AND P_OPERATION IN ('INSERT', 'UPDATE', 'DELETE')
994 THEN
995
996 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_APPLIED');
997 FND_MSG_PUB.Add;
998 RAISE FND_API.G_EXC_ERROR;
999
1000 ELSIF l_applied_ind = 'N'
1001 AND p_operation IN ('INSERT')
1002 THEN
1003
1004 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_HEADER');
1005 FND_MSG_PUB.Add;
1006
1007 ELSIF l_applied_ind IS NULL
1008 THEN
1009 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJUSTMENT_ID');
1010 FND_MSG_PUB.Add;
1011 RAISE FND_API.G_EXC_ERROR;
1012 END IF;
1013
1014 IF (p_header_Rec.legal_entity_id IS NOT NULL
1015 AND (p_header_Rec.COST_MTHD_CODE IS NOT NULL
1016 OR p_header_Rec.cost_type_id IS NOT NULL)
1017 AND (p_header_rec.organization_id IS NOT NULL
1018 OR p_header_rec.organization_code IS NOT NULL)
1019 AND p_header_Rec.ADJUSTMENT_date IS NOT NULL
1020 AND (p_header_Rec.item_id IS NOT NULL
1021 OR p_header_rec.item_number IS NOT NULL)
1022 AND p_header_rec.lot_number IS NOT NULL)
1023 THEN
1024 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)
1025 THEN
1026
1027 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_HEADER_KEYS');
1028 FND_MSG_PUB.Add;
1029
1030 END IF;
1031 END IF;
1032 ELSE
1033 --Legal Entity Validation
1034 IF ((p_header_rec.legal_entity_id <> FND_API.G_MISS_NUM)
1035 AND (p_header_rec.legal_entity_id IS NOT NULL))
1036 THEN
1037 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1038 THEN
1039 log_msg('Validating Legal_entity : ' || p_header_rec.legal_entity_id);
1040 END IF;
1041
1042 IF NOT gmf_validations_pvt.validate_legal_entity_id(p_header_rec.legal_entity_id)
1043 THEN
1044 -- jboppana have to change the message
1045 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_LE_ID');
1046 FND_MESSAGE.SET_TOKEN('LEGAL_ENTITY',p_header_rec.legal_entity_id);
1047 /*FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CO_CODE');
1048 FND_MESSAGE.SET_TOKEN('CO_CODE',p_header_rec.co_code);*/
1049 FND_MSG_PUB.Add;
1050 RAISE FND_API.G_EXC_ERROR;
1051 END IF;
1052 ELSE
1053 FND_MESSAGE.SET_NAME('GMF','GMF_API_LE_ID_REQ');
1054 -- FND_MESSAGE.SET_NAME('GMF','GMF_API_CO_CODE_REQ');
1055 FND_MSG_PUB.Add;
1056 RAISE FND_API.G_EXC_ERROR;
1057
1058 END IF;
1059
1060 --Cost type Validation
1061 IF (p_header_rec.cost_type_id <> FND_API.G_MISS_NUM)
1062 AND (p_header_rec.cost_type_id IS NOT NULL)
1063 THEN
1064 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1065 THEN
1066 log_msg('Validating cost type id: ' || p_header_rec.cost_type_id);
1067 END IF;
1068 IF NOT GMF_VALIDATIONS_PVT.Validate_lot_cost_type_Id(p_header_rec.cost_type_id)
1069 THEN
1070 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE_ID');
1071 FND_MESSAGE.SET_TOKEN('COST_TYPE_ID',p_header_rec.cost_type_id);
1072 FND_MSG_PUB.Add;
1073 RAISE FND_API.G_EXC_ERROR;
1074 END IF;
1075
1076 -- Log message if cost_mthd_code is also passed
1077 IF (p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.cost_type_id IS NOT NULL)
1078 THEN
1079
1080 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)
1081 THEN
1082
1083 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_COST_TYPE');
1084 FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header_rec.cost_mthd_code);
1085 FND_MSG_PUB.Add;
1086
1087 END IF;
1088 END IF;
1089 ELSIF ((p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR)AND (p_header_rec.cost_mthd_code IS NOT NULL))
1090 THEN
1091
1092 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1093 THEN
1094 log_msg('Validating Cost Type : ' || p_header_rec.cost_mthd_code);
1095 END IF;
1096
1097 p_header_rec.cost_type_id := gmf_validations_pvt.Validate_Lot_Cost_type(p_header_rec.cost_mthd_code);
1098
1099 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1100 THEN
1101 log_msg('cost_type_id : ' || p_header_rec.cost_type_id);
1102 END IF;
1103
1104 IF p_header_rec.cost_type_id IS NULL
1105 THEN
1106 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE');
1107 FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header_rec.cost_mthd_code);
1108 FND_MSG_PUB.Add;
1109 RAISE FND_API.G_EXC_ERROR;
1110 END IF;
1111 ELSE
1112
1113 FND_MESSAGE.SET_NAME('GMF','GMF_API_COST_TYPE_ID_REQ');
1114 FND_MSG_PUB.Add;
1115 RAISE FND_API.G_EXC_ERROR;
1116 END IF;
1117
1118
1119 --Organization Validation
1120 IF (p_header_rec.organization_id <> FND_API.G_MISS_NUM)
1121 AND (p_header_rec.organization_id IS NOT NULL)
1122 THEN
1123 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1124 THEN
1125 log_msg('Validating organization id: ' || p_header_rec.organization_id);
1126 END IF;
1127 IF NOT GMF_VALIDATIONS_PVT.Validate_organization_Id(p_header_rec.organization_id)
1128 THEN
1129 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_ID');
1130 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1131 FND_MSG_PUB.Add;
1132 RAISE FND_API.G_EXC_ERROR;
1133 END IF;
1134
1135 -- Log message if organization_code is also passed
1136 IF (p_header_rec.organization_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.organization_id IS NOT NULL)
1137 THEN
1138
1139 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)
1140 THEN
1141
1142 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ORGN_CODE');
1143 FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header_rec.organization_code);
1144 FND_MSG_PUB.Add;
1145
1146 END IF;
1147 END IF;
1148 ELSIF ((p_header_rec.organization_code <> FND_API.G_MISS_CHAR)AND (p_header_rec.organization_code IS NOT NULL))
1149 THEN
1150
1151 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1152 THEN
1153 log_msg('Validating Organization Code : ' || p_header_rec.organization_code);
1154 END IF;
1155
1156 p_header_rec.organization_id := gmf_validations_pvt.validate_organization_code(p_header_rec.organization_code);
1157
1158 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1159 THEN
1160 log_msg('organization_id : ' || p_header_rec.organization_id);
1161 END IF;
1162
1163 IF p_header_rec.organization_id IS NULL
1164 THEN
1165 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_CODE');
1166 FND_MESSAGE.SET_TOKEN('ORG_CODE',p_header_rec.organization_code);
1167 FND_MSG_PUB.Add;
1168 RAISE FND_API.G_EXC_ERROR;
1169 END IF;
1170 ELSE
1171
1172 FND_MESSAGE.SET_NAME('GMF','GMF_API_ORGANIZATION_ID_REQ');
1173 FND_MSG_PUB.Add;
1174 RAISE FND_API.G_EXC_ERROR;
1175 END IF; -- end for organization
1176
1177
1178
1179 --Item Validation
1180 IF (p_header_rec.item_id <> FND_API.G_MISS_NUM)
1181 AND (p_header_rec.item_id IS NOT NULL)
1182 THEN
1183 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1184 THEN
1185 log_msg('Validating item_id : ' || p_header_rec.item_id);
1186 END IF;
1187
1188 IF NOT GMF_VALIDATIONS_PVT.Validate_inventory_item_id(p_header_rec.item_id,p_header_rec.organization_id)
1189 THEN
1190 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_ID');
1191 FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.item_id);
1192 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1193 FND_MSG_PUB.Add;
1194 RAISE FND_API.G_EXC_ERROR;
1195 END IF;
1196
1197 -- Log message if item_number is also passed
1198 IF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND (p_header_rec.item_number IS NOT NULL)
1199 THEN
1200
1201 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)
1202 THEN
1203
1204 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ITEM_NO');
1205 FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
1206 FND_MSG_PUB.Add;
1207
1208 END IF;
1209 END IF;
1210 ELSIF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND (p_header_rec.item_number IS NOT NULL)
1211 THEN
1212 -- Convert value into ID.
1213 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1214 THEN
1215 log_msg('Validating item_number : ' || p_header_rec.item_number);
1216 END IF;
1217
1218 p_header_rec.item_id := GMF_VALIDATIONS_PVT.Validate_Item_Number(p_header_rec.item_number,p_header_rec.organization_id);
1219
1220 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1221 THEN
1222 log_msg('item_id : ' || p_header_rec.item_id);
1223 END IF;
1224
1225 IF p_header_rec.item_id IS NULL
1226 THEN
1227 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_NO');
1228 FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
1229 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1230 FND_MSG_PUB.Add;
1231 RAISE FND_API.G_EXC_ERROR;
1232 END IF;
1233 ELSE
1234 FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_ID_REQ');
1235 FND_MSG_PUB.Add;
1236 RAISE FND_API.G_EXC_ERROR;
1237 END IF;
1238
1239 -- Bug # 3755374 ANTHIYAG 12-Jul-2004 Start
1240 --Lot Costed Item Validation
1241 IF (p_header_rec.item_id IS NOT NULL and p_header_rec.item_id <> FND_API.G_MISS_NUM)
1242 THEN
1243
1244 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1245 THEN
1246 log_msg('Validating Item id : ' || p_header_rec.Item_id || ' For Lot Costing');
1247 END IF;
1248
1249 BEGIN
1250 -- modified the query for bug 5705311, pmarada
1251 SELECT mic.category_id
1252 INTO l_cost_category_id
1253 FROM mtl_default_category_sets mdc,
1254 mtl_category_sets mcs,
1255 mtl_item_categories mic,
1256 mtl_categories mc
1257 WHERE mic.inventory_item_id = p_header_rec.item_id
1258 AND mic.organization_id = p_header_rec.organization_id
1259 AND mic.category_id = mc.category_id
1260 AND mcs.structure_id = mc.structure_id
1261 AND mdc.functional_area_id = 19
1262 AND mcs.category_set_id = mic.category_set_id
1263 AND mcs.category_set_id = mdc.category_set_id;
1264 EXCEPTION
1265 WHEN NO_DATA_FOUND
1266 THEN
1267 l_cost_category_id := NULL;
1268 END;
1269
1270 BEGIN
1271 SELECT 1
1272 INTO l_lot_costed_items_cnt
1273 FROM GMF_LOT_COSTED_ITEMS
1274 WHERE legal_entity_id = p_header_Rec.legal_entity_id
1275 AND cost_type_id = p_header_rec.cost_type_id
1276 AND inventory_item_id = p_header_rec.item_id;
1277 EXCEPTION
1278 WHEN NO_DATA_FOUND
1279 THEN
1280 BEGIN
1281 SELECT 1
1282 INTO l_lot_costed_items_cnt
1283 FROM GMF_LOT_COSTED_ITEMS
1284 WHERE legal_entity_id = p_header_Rec.legal_entity_id
1285 AND cost_type_id = p_header_rec.cost_type_id
1286 AND cost_category_id = l_cost_category_id;
1287 EXCEPTION
1288 WHEN NO_DATA_FOUND
1289 THEN
1290 FND_MESSAGE.SET_NAME('GMF','GMF_ITEM_ID_NOT_LOT_COSTED');
1291 FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.item_id);
1292 FND_MSG_PUB.Add;
1293 RAISE FND_API.G_EXC_ERROR;
1294 END;
1295 END;
1296 END IF;
1297 -- Bug # 3755374 ANTHIYAG 12-Jul-2004 End
1298
1299 --Lot Validation
1300 IF (p_header_rec.lot_number <> FND_API.G_MISS_CHAR) AND (p_header_rec.lot_number IS NOT NULL)
1301 THEN
1302
1303 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1304 THEN
1305 log_msg('Validating Lot Number: ' || p_header_rec.lot_number || ' For Item '||p_header_rec.item_id );
1306 END IF;
1307 IF NOT GMF_VALIDATIONS_PVT.Validate_lot_number(p_header_rec.lot_number,p_header_rec.item_id,
1308 p_header_rec.organization_id)
1309 THEN
1310 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_LOT_NUMBER');
1311 FND_MESSAGE.SET_TOKEN('LOT_NUMBER',p_header_rec.lot_number);
1312 FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.item_number);
1313 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1314 FND_MSG_PUB.Add;
1315 RAISE FND_API.G_EXC_ERROR;
1316 END IF;
1317 ELSE
1318 FND_MESSAGE.SET_NAME('GMF','GMF_API_LOT_NUMBER_REQ');
1319 FND_MSG_PUB.Add;
1320 RAISE FND_API.G_EXC_ERROR;
1321 END IF;
1322
1323 --Adjustment_date Validation
1324 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1325 THEN
1326 log_msg('Validating Adjustment date : ' || p_header_rec.adjustment_date );
1327 END IF;
1328
1329 IF p_header_rec.adjustment_date IS NULL
1330 THEN
1331 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DATE_DEFAULT');
1332 FND_MSG_PUB.Add;
1333 p_header_rec.adjustment_date := SYSDATE;
1334 ELSE
1335 BEGIN
1336 SELECT MAX(cost_trans_date)
1337 INTO l_adjustment_date
1338 FROM gmf_material_lot_cost_txns txns, gmf_lot_costs lc
1339 WHERE lc.inventory_item_id = p_header_Rec.item_id
1340 AND lc.lot_number = p_header_Rec.lot_number
1341 AND lc.organization_id = p_header_rec.organization_id
1342 AND lc.final_cost_flag = 1
1343 AND txns.cost_header_id = lc.header_id
1344 AND txns.final_cost_flag = 1;
1345 EXCEPTION
1346 WHEN NO_DATA_FOUND
1347 THEN
1348 l_adjustment_date := NULL;
1349 END;
1350
1351 IF (l_adjustment_date IS NOT NULL
1352 AND ((l_adjustment_date > p_header_Rec.adjustment_date)
1353 OR (p_header_Rec.adjustment_date > SYSDATE)))
1354 THEN
1355 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DATE');
1356 FND_MSG_PUB.Add;
1357 RAISE FND_API.G_EXC_ERROR;
1358 ELSE
1359 IF p_header_Rec.adjustment_date > SYSDATE
1360 THEN
1361 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DATE');
1362 FND_MSG_PUB.Add;
1363 RAISE FND_API.G_EXC_ERROR;
1364 END IF;
1365 END IF;
1366 END IF;
1367
1368 --Reason Code Validation
1369 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1370 THEN
1371 log_msg('Validating Reason Code: ' || p_header_rec.reason_code );
1372 END IF;
1373
1374 IF ((p_header_rec.reason_code <> FND_API.G_MISS_CHAR)
1375 AND (p_header_rec.reason_code IS NOT NULL))
1376 THEN
1377 BEGIN
1378 SELECT 1
1379 INTO l_reason_cnt
1380 FROM cm_reas_cds
1381 WHERE reason_code = p_header_rec.reason_code
1382 AND delete_mark = 0
1383 AND ROWNUM = 1;
1384 EXCEPTION
1385 WHEN NO_DATA_FOUND
1386 THEN
1387 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_REASON_CODE');
1388 FND_MESSAGE.SET_TOKEN('REASON_CODE',p_header_rec.reason_code);
1389 FND_MSG_PUB.Add;
1390 RAISE FND_API.G_EXC_ERROR;
1391 END;
1392 ELSE
1393 FND_MESSAGE.SET_NAME('GMF','GMF_API_REASON_CODE_REQ');
1394 FND_MSG_PUB.Add;
1395 RAISE FND_API.G_EXC_ERROR;
1396 END IF;
1397
1398 -- Bug # 3755374 ANTHIYAG 12-Jul-2004 Start
1399 -- Delete Mark
1400 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1401 THEN
1402 log_msg('Validating Delete_mark : ' || p_header_Rec.delete_mark);
1403 END IF;
1404
1405 IF (p_header_Rec.delete_mark <> FND_API.G_MISS_NUM) AND (p_header_Rec.delete_mark IS NOT NULL)
1406 THEN
1407 IF p_header_Rec.delete_mark NOT IN (0,1) THEN
1408 add_header_to_error_stack(p_header_rec);
1409 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_DELETE_MARK');
1410 FND_MESSAGE.SET_TOKEN('DELETE_MARK',p_header_Rec.delete_mark);
1411 FND_MSG_PUB.Add;
1412 RAISE FND_API.G_EXC_ERROR;
1413 END IF;
1414 ELSIF (p_header_Rec.delete_mark = FND_API.G_MISS_NUM AND p_operation = 'UPDATE') OR
1415 (p_operation = 'INSERT') THEN
1416 add_header_to_error_stack(p_header_rec);
1417 FND_MESSAGE.SET_NAME('GMF','GMF_API_DELETE_MARK_REQ');
1418 FND_MSG_PUB.Add;
1419 RAISE FND_API.G_EXC_ERROR;
1420 END IF;
1421 IF ((p_operation = 'UPDATE') AND (p_header_Rec.delete_mark = 1)) THEN
1422 add_header_to_error_stack(p_header_rec);
1423 FND_MESSAGE.SET_NAME('GMF','GMF_API_CANT_MARK_FOR_PURGE');
1424 FND_MSG_PUB.Add;
1425 RAISE FND_API.G_EXC_ERROR;
1426 END IF;
1427 -- Bug # 3755374 ANTHIYAG 12-Jul-2004 End
1428
1429 --Adjustment ID validation
1430 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1431 THEN
1432 log_msg('Validating Adjustment ID');
1433 END IF;
1434
1435 IF p_operation IN ('UPDATE', 'DELETE', 'INSERT')
1436 THEN
1437 IF p_header_rec.adjustment_id IS NULL
1438 AND (p_header_Rec.legal_entity_id IS NOT NULL
1439 AND ( p_header_Rec.COST_MTHD_CODE IS NOT NULL OR p_header_Rec.cost_type_id IS NOT NULL)
1440 AND (p_header_rec.organization_code IS NOT NULL OR p_header_rec.organization_id IS NOT NULL )
1441 AND p_header_Rec.ADJUSTMENT_date IS NOT NULL
1442 AND (p_header_Rec.item_id IS NOT NULL OR p_header_rec.item_number IS NOT NULL)
1443 AND p_header_Rec.lot_number IS NOT NULL )
1444 THEN
1445 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1446 THEN
1447 log_msg('Fetching Adjustment ID for Code Combination for ' ||
1448 ' Legal Entity ' || p_header_rec.legal_entity_id ||
1449 ' Cost Type Id ' || p_header_rec.cost_type_id ||
1450 ' Cost Type ' || p_header_rec.cost_mthd_code ||
1451 ' Organization Id ' || p_header_rec.organization_id ||
1452 ' Organization Code ' || p_header_rec.organization_code ||
1453 ' Adjustment Date ' || p_header_rec.adjustment_date ||
1454 ' Item Id ' || p_header_rec.item_id ||
1455 ' Item Code ' || p_header_rec.item_number ||
1456 ' for '|| p_operation );
1457 END IF;
1458
1459 BEGIN
1460 SELECT adjustment_id, applied_ind
1461 INTO p_header_Rec.adjustment_id, l_applied_ind
1462 FROM gmf_lot_cost_adjustments
1463 WHERE legal_entity_id = p_header_rec.legal_entity_id
1464 AND cost_type_id = p_header_rec.cost_type_id
1465 AND organization_id = p_header_rec.organization_id
1466 AND inventory_item_id = p_header_rec.item_id
1467 AND lot_number = p_header_rec.lot_number
1468 AND adjustment_date = p_header_rec.adjustment_date
1469 AND ROWNUM = 1;
1470 EXCEPTION
1471 WHEN NO_DATA_FOUND
1472 THEN
1473 p_header_Rec.adjustment_id := NULL;
1474 END;
1475
1476 IF p_header_Rec.adjustment_id IS NULL
1477 AND P_OPERATION IN ('UPDATE', 'DELETE')
1478 THEN
1479 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1480 THEN
1481 log_msg('Adjustment ID for Code Combination for ' ||
1482 ' Legal Entity ' || p_header_rec.legal_entity_id ||
1483 ' Cost Type Id ' || p_header_rec.cost_type_id ||
1484 ' Cost Type ' || p_header_rec.cost_mthd_code ||
1485 ' Organization Id ' || p_header_rec.organization_id ||
1486 ' Organization Code ' || p_header_rec.organization_code ||
1487 ' Adjustment Date ' || p_header_rec.adjustment_date ||
1488 ' Item Id ' || p_header_rec.item_id ||
1489 ' Item Code ' || p_header_rec.item_number ||
1490 ' for '|| p_operation ||' doesn''t exist ');
1491 END IF;
1492
1493 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJUSTMENT_ID');
1494 FND_MSG_PUB.Add;
1495 RAISE FND_API.G_EXC_ERROR;
1496 END IF;
1497
1498 IF l_applied_ind = 'Y'
1499 AND P_OPERATION IN ('INSERT', 'UPDATE', 'DELETE')
1500 THEN
1501
1502 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_APPLIED');
1503 FND_MSG_PUB.Add;
1504 RAISE FND_API.G_EXC_ERROR;
1505
1506 ELSIF l_applied_ind = 'N'
1507 AND p_operation IN ('INSERT')
1508 THEN
1509
1510 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_HEADER');
1511 FND_MSG_PUB.Add;
1512
1513 END IF;
1514 END IF;
1515 END IF; -- end if for adjustment p_operation
1516 END IF; -- End if for adjustment ind not null
1517
1518 --Username Validation
1519 -- User name validate is required for both update and Insert,
1520 -- even adjustment id passed in update operation. bug 5586137
1521 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1522 THEN
1523 log_msg('Validating user name : ' || p_header_rec.user_name);
1524 END IF;
1525
1526 IF (p_header_rec.user_name <> FND_API.G_MISS_CHAR)
1527 AND (p_header_rec.user_name IS NOT NULL)
1528 THEN
1529 GMA_GLOBAL_GRP.Get_who(p_user_name => p_header_rec.user_name
1530 ,x_user_id => x_user_id
1531 );
1532 IF x_user_id = -1
1533 THEN
1534 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_USER_NAME');
1535 FND_MESSAGE.SET_TOKEN('USER_NAME',p_header_rec.user_name);
1536 FND_MSG_PUB.Add;
1537 RAISE FND_API.G_EXC_ERROR;
1538 END IF;
1539 ELSE
1540 FND_MESSAGE.SET_NAME('GMF','GMF_API_USER_NAME_REQ');
1541 FND_MSG_PUB.Add;
1542 RAISE FND_API.G_EXC_ERROR;
1543 END IF; -- end if for user name validation
1544 END IF; -- End if for p_operation
1545
1546 --Detail Record Validation
1547 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1548 THEN
1549 log_msg('Validating Lot Cost Adjustment Detail Records');
1550 END IF;
1551
1552 IF P_OPERATION IN ('INSERT', 'UPDATE', 'DELETE')
1553 THEN
1554 FOR i IN p_dtl_tbl.FIRST .. p_dtl_tbl.LAST
1555 LOOP
1556 IF p_dtl_tbl(i).adjustment_dtl_id IS NOT NULL
1557 THEN
1558 BEGIN
1559 SELECT 1
1560 INTO l_detail_cnt
1561 FROM gmf_lot_cost_adjustment_dtls
1562 WHERE adjustment_dtl_id = p_dtl_tbl(i).adjustment_dtl_id
1563 AND ROWNUM = 1;
1564 EXCEPTION
1565 WHEN NO_DATA_FOUND
1566 THEN
1567 l_detail_cnt := 0;
1568 END;
1569
1570 IF l_detail_cnt > 0
1571 AND P_OPERATION IN ('INSERT')
1572 THEN
1573
1574 FND_MESSAGE.SET_NAME('GMF','CM_DUP_RECORD'); -- Bug # 3755374 ANTHIYAG 12-Jul-2004
1575 FND_MSG_PUB.Add;
1576 RAISE FND_API.G_EXC_ERROR;
1577
1578 ELSIF l_detail_cnt = 0
1579 THEN
1580 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DTL_ID');
1581 FND_MSG_PUB.Add;
1582 RAISE FND_API.G_EXC_ERROR;
1583 END IF;
1584
1585 ELSE
1586
1587 --Cost Component Class Validation
1588 IF (p_dtl_tbl(i).cost_cmpntcls_id <> FND_API.G_MISS_NUM) AND (p_dtl_tbl(i).cost_cmpntcls_id IS NOT NULL)
1589 THEN
1590
1591 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1592 THEN
1593 log_msg('Validating Details Component Class ID ('||i||') :'|| p_dtl_tbl(i).cost_cmpntcls_id);
1594 END IF;
1595
1596 IF NOT GMF_VALIDATIONS_PVT.Validate_Cost_Cmpntcls_Id (p_dtl_tbl(i).cost_cmpntcls_id)
1597 THEN
1598 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CMPNTCLS_ID');
1599 FND_MESSAGE.SET_TOKEN('CMPNTCLS_ID',p_dtl_tbl(i).cost_cmpntcls_id);
1600 FND_MSG_PUB.Add;
1601 RAISE FND_API.G_EXC_ERROR;
1602 END IF;
1603
1604 IF (p_dtl_tbl(i).cost_cmpntcls_code <> FND_API.G_MISS_CHAR) AND (p_dtl_tbl(i).cost_cmpntcls_code IS NOT NULL)
1605 THEN
1606 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)
1607 THEN
1608 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_CMPNTCLS_CODE');
1609 FND_MESSAGE.SET_TOKEN('CMPNTCLS_CODE',p_dtl_tbl(i).cost_cmpntcls_code);
1610 FND_MSG_PUB.Add;
1611 END IF;
1612 END IF;
1613
1614 ELSIF (p_dtl_tbl(i).cost_cmpntcls_code <> FND_API.G_MISS_CHAR) AND (p_dtl_tbl(i).cost_cmpntcls_code IS NOT NULL)
1615 THEN
1616
1617 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1618 THEN
1619 log_msg('Validating Details Component Class Code('||i||') : ' || p_dtl_tbl(i).cost_cmpntcls_code);
1620 END IF;
1621
1622 p_dtl_tbl(i).cost_cmpntcls_id := GMF_VALIDATIONS_PVT.Validate_Cost_Cmpntcls_Code (p_dtl_tbl(i).cost_cmpntcls_code);
1623
1624 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1625 THEN
1626 log_msg('Component Class Id := ' || p_dtl_tbl(i).cost_cmpntcls_id);
1627 END IF;
1628
1629 IF p_dtl_tbl(i).cost_cmpntcls_id IS NULL
1630 THEN
1631 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CMPNTCLS_CODE');
1632 FND_MESSAGE.SET_TOKEN('CMPNTCLS_CODE',p_dtl_tbl(i).cost_cmpntcls_code);
1633 FND_MSG_PUB.Add;
1634 RAISE FND_API.G_EXC_ERROR;
1635 END IF;
1636 ELSE
1637 FND_MESSAGE.SET_NAME('GMF','GMF_API_CMPNTCLS_ID_REQ');
1638 FND_MSG_PUB.Add;
1639 RAISE FND_API.G_EXC_ERROR;
1640 END IF;
1641
1642 --Analysis Code Validation
1643 IF (p_dtl_tbl(i).cost_analysis_code <> FND_API.G_MISS_CHAR) AND (p_dtl_tbl(i).cost_analysis_code IS NOT NULL)
1644 THEN
1645 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1646 THEN
1647 log_msg('Validating Details Analysis code('||i||') :' || p_dtl_tbl(i).cost_analysis_code);
1648 END IF;
1649
1650 IF NOT GMF_VALIDATIONS_PVT.Validate_Analysis_Code(p_dtl_tbl(i).cost_analysis_code)
1651 THEN
1652 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ANALYSIS_CODE');
1653 FND_MESSAGE.SET_TOKEN('ANALYSIS_CODE',p_dtl_tbl(i).cost_analysis_code);
1654 FND_MSG_PUB.Add;
1655 RAISE FND_API.G_EXC_ERROR;
1656 END IF;
1657
1658 ELSE
1659 FND_MESSAGE.SET_NAME('GMF','GMF_API_ANALYSIS_CODE_REQ');
1660 FND_MSG_PUB.Add;
1661 RAISE FND_API.G_EXC_ERROR;
1662 END IF;
1663
1664 --Text Code Validation
1665 IF (p_dtl_tbl(i).text_code <> FND_API.G_MISS_NUM) AND (p_dtl_tbl(i).text_code IS NOT NULL)
1666 THEN
1667 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1668 THEN
1669 log_msg('Validating Details Text code('||i||') :' || p_dtl_tbl(i).text_code);
1670 END IF;
1671
1672 BEGIN
1673 SELECT 1
1674 INTO l_text_cnt
1675 FROM cm_text_hdr
1676 WHERE text_code = p_dtl_tbl(i).text_code
1677 AND ROWNUM = 1;
1678 EXCEPTION
1679 WHEN NO_DATA_FOUND
1680 THEN
1681 l_text_cnt := 0;
1682 END;
1683 IF NVL(l_text_cnt,0) = 0
1684 THEN
1685 FND_MESSAGE.SET_NAME('GMF','GMF_API_TEXT_CODE'); -- Bug # 3755374 ANTHIYAG 12-Jul-2004
1686 FND_MESSAGE.SET_TOKEN('TEXT_CODE',p_dtl_tbl(i).text_code);
1687 FND_MSG_PUB.Add;
1688 RAISE FND_API.G_EXC_ERROR;
1689 END IF;
1690 END IF;
1691 END IF;
1692
1693 --Adjustment Cost validation
1694 IF P_OPERATION IN ('UPDATE', 'INSERT')
1695 THEN
1696 IF p_dtl_tbl(i).adjustment_cost IS NULL
1697 THEN
1698 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_COST');
1699 FND_MSG_PUB.Add;
1700 RAISE FND_API.G_EXC_ERROR;
1701 END IF;
1702 END IF;
1703
1704 --Adjustment Details ID validation
1705 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1706 THEN
1707 log_msg('Validating Adjustment Detail ID');
1708 END IF;
1709
1710 IF p_operation IN ('UPDATE', 'DELETE', 'INSERT')
1711 THEN
1712 IF p_dtl_tbl(i).adjustment_dtl_id IS NULL
1713 THEN
1714 IF (p_dtl_tbl(i).cost_cmpntcls_id IS NOT NULL
1715 AND p_dtl_tbl(i).cost_analysis_code IS NOT NULL)
1716 THEN
1717 BEGIN
1718 SELECT adjustment_dtl_id
1719 INTO p_dtl_tbl(i).adjustment_dtl_id
1720 FROM gmf_lot_cost_adjustment_dtls
1721 WHERE cost_cmpntcls_id = p_dtl_tbl(i).cost_cmpntcls_id
1722 AND cost_analysis_code = p_dtl_tbl(i).cost_analysis_code
1723 AND adjustment_id = p_header_rec.adjustment_id
1724 AND ROWNUM = 1;
1725 EXCEPTION
1726 WHEN NO_DATA_FOUND
1727 THEN
1728 IF P_operation IN ('UPDATE', 'DELETE')
1729 THEN
1730 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DTL_ID');
1731 FND_MSG_PUB.Add;
1732 RAISE FND_API.G_EXC_ERROR;
1733 ELSE
1734 p_dtl_tbl(i).adjustment_dtl_id := NULL;
1735 END IF;
1736 END;
1737
1738 IF P_OPERATION IN ('INSERT')
1739 AND p_dtl_tbl(i).adjustment_dtl_id IS NOT NULL
1740 THEN
1741
1742 FND_MESSAGE.SET_NAME('GMF','CM_DUP_RECORD'); -- Bug # 3755374 ANTHIYAG 12-Jul-2004
1743 FND_MSG_PUB.Add;
1744 RAISE FND_API.G_EXC_ERROR;
1745
1746 END IF;
1747
1748 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1749 THEN
1750 log_msg('Using Adjustment Details ID ' || p_dtl_tbl(i).adjustment_id || ' for ' || p_operation);
1751 END IF;
1752 ELSE
1753 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_ADJ_DTL_ID');
1754 FND_MSG_PUB.Add;
1755 RAISE FND_API.G_EXC_ERROR;
1756 END IF;
1757 END IF;
1758 END IF;
1759 END LOOP;
1760 END IF;
1761
1762 END Validate_Input_Params;
1763
1764 --+==========================================================================+
1765 --| Procedure Name |
1766 --| log_msg |
1767 --| |
1768 --| DESCRIPTION |
1769 --| This procedure logs messages to message stack. |
1770 --| |
1771 --| PARAMETERS |
1772 --| p_msg_lvl IN NUMBER(10) - Message Level |
1773 --| p_msg_text IN NUMBER(10) - Actual Message Text |
1774 --| |
1775 --| RETURNS |
1776 --| |
1777 --| HISTORY |
1778 --| 22-MAR-2004 Anand Thiyagarajan |
1779 --| |
1780 --+==========================================================================+
1781 -- Func end of comments
1782
1783 PROCEDURE log_msg
1784 (
1785 p_msg_text IN VARCHAR2
1786 )
1787 IS
1788 BEGIN
1789
1790 FND_MESSAGE.SET_NAME('GMF','GMF_API_DEBUG');
1791 FND_MESSAGE.SET_TOKEN('MSG',p_msg_text);
1792 FND_MSG_PUB.Add;
1793
1794 END log_msg ;
1795
1796 -- Func start of comments
1797 --+==========================================================================+
1798 --| Procedure Name |
1799 --| add_header_to_error_stack |
1800 --| |
1801 --| DESCRIPTION |
1802 --| This procedure logs header to message stack. |
1803 --| |
1804 --| PARAMETERS |
1805 --| p_header Header Record to be logged |
1806 --| |
1807 --| RETURNS |
1808 --| |
1809 --| HISTORY |
1810 --| 15-APR-2004 Anand Thiyagarajan - Created |
1811 --| |
1812 --+==========================================================================+
1813 -- Func end of comments
1814
1815 PROCEDURE add_header_to_error_stack
1816 (
1817 p_header_rec GMF_LotCostAdjustment_PUB.Lc_Adjustment_Header_Rec_Type
1818 )
1819 IS
1820 BEGIN
1821
1822 IF G_header_logged = 'N'
1823 THEN
1824 G_header_logged := 'Y';
1825 FND_MESSAGE.SET_NAME('GMF','GMF_API_LCA_HEADER');
1826 FND_MESSAGE.SET_TOKEN('LEGAL_ENTITY_ID',p_header_rec.legal_entity_id);
1827 FND_MESSAGE.SET_TOKEN('COST_TYPE_ID',p_header_rec.cost_type_id);
1828 FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header_rec.cost_mthd_code);
1829 FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1830 FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header_rec.organization_code);
1831 FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.item_id);
1832 FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
1833 FND_MESSAGE.SET_TOKEN('LOT_NUMBER',p_header_rec.lot_number);
1834 FND_MESSAGE.SET_TOKEN('ADJUSTMENT_DATE',p_header_rec.adjustment_date);
1835
1836 FND_MSG_PUB.Add;
1837 END IF;
1838
1839 END add_header_to_error_stack;
1840
1841 END GMF_LotCostAdjustment_PUB;