DBA Data[Home] [Help]

PACKAGE BODY: APPS.GMF_BURDENDETAILS_PUB

Source


1 PACKAGE BODY GMF_BurdenDetails_PUB AS
2 /* $Header: GMFPBRDB.pls 120.5.12010000.2 2008/10/30 21:18:26 pkanetka ship $ */
3 
4 -- Start of comments
5 --+==========================================================================+
6 --|                   Copyright (c) 1998 Oracle Corporation                  |
7 --|                          Redwood Shores, CA, USA                         |
8 --|                            All rights reserved.                          |
9 --+==========================================================================+
10 --| File Name          : GMFPBRDB.pls                                        |
11 --| Package Name       : GMF_BurdenDetails_PUB                               |
12 --| API name           : GMF_BurdenDetails_PUB                               |
13 --| Type               : Public                                              |
14 --| Pre-reqs           : N/A                                                 |
15 --| Function           : Burden Details creation, updatation and deletion.   |
16 --|                                                                          |
17 --| Parameters         : N/A                                                 |
18 --|                                                                          |
19 --| Current Vers       : 2.0                                                 |
20 --| Previous Vers      : 1.0                                                 |
21 --| Initial Vers       : 1.0                                                 |
22 --|                                                                          |
23 --| Contents                                                                 |
24 --|     Create_Burden_Details                                                |
25 --|     Update_Burden_Details                                                |
26 --|     Delete_Burden_Details                                                |
27 --|     Get_Item_Cost                                                        |
28 --|                                                                          |
29 --| Notes                                                                    |
30 --|     This package contains public procedures relating to Burden Details   |
31 --|     creation, updatation and deletetion.                                 |
32 --|                                                                          |
33 --|                                                                          |
34 --|  Pre-defined API message levels                                          |
35 --|                                                                          |
36 --|     Valid values for message levels are from 1-50.                       |
37 --|      1 being least severe and 50 highest.                                |
38 --|                                                                          |
39 --|     The pre-defined levels correspond to standard API                    |
40 --|     return status. Debug levels are used to control the amount of        |
41 --|      debug information a program writes to the PL/SQL message table.     |
42 --|                                                                          |
43 --| G_MSG_LVL_UNEXP_ERROR   CONSTANT NUMBER := 60;                           |
44 --| G_MSG_LVL_ERROR         CONSTANT NUMBER := 50;                           |
45 --| G_MSG_LVL_SUCCESS       CONSTANT NUMBER := 40;                           |
46 --| G_MSG_LVL_DEBUG_HIGH    CONSTANT NUMBER := 30;                           |
47 --| G_MSG_LVL_DEBUG_MEDIUM  CONSTANT NUMBER := 20;                           |
48 --| G_MSG_LVL_DEBUG_LOW     CONSTANT NUMBER := 10;                           |
49 --| HISTORY                                                                  |
50 --|    10/Apr/2001  Uday Moogala  Created  Bug# 1418689                      |
51 --|    13/Aug/2001  Uday Moogala  Bug# 1935297                               |
52 --|                 UOM conversion fails even in case of same UOMs. This is  |
53 --|                 happenning since item id is not getting passed to the    |
54 --|                 UOM conversion routine. And this happens only when Item  |
55 --|                 No is passed instead of Item_Id. Fix is done to pass the |
56 --|                 Item_Id to UOM conversion routine.                       |
57 --|                                                                          |
58 --|    05/NOV/2002  Uday Moogala  Bug# 2659435                               |
59 --|      Performance related fixes.                                          |
60 --|      1. remove G_MISS_xxx assignments.                                   |
61 --|      2. Conditionally calling debug routine.                             |
62 --|      Also, fixed issues found during unit testing. Search for the bug    |
63 --|      number to find the fixes.                                           |
64 --|    30/Oct/2002  R.Sharath Kumar Bug# 2641405 Added NOCOPY hint           |
65 --|    21/NOV/2002  Uday Moogala  Bug# 2681243                               |
66 --|      1. Return value of GMA_GLOBAL_GRP.set_who has changed to -1 from 0  |
67 --|         in case of invalid users.                                        |
68 --|      2. Removed "when others" section in validate_input_params           |
69 --|      3. Also made changes to query brdn details from db to use for UOM   |
70 --|         conversions, if not passed in case of update only                |
71 --|    12/May/2004 Dinesh Vadivel Bug# 3314310                               |
72 --|                Removed Validation code for the item BURDEN_USAGE in      |
73 --|                VALIDATE_INPUT_PARAMS proc so that it takes negative      |
74 --|                values                                                    |
75 --|   20-Oct-2005  Prasad marada, Bug 4689137 Modified as per convergence    |
76 --+==========================================================================+
77 -- End of comments
78 
79 
80 PROCEDURE Validate_Input_Params
81 (
82  p_header_rec      IN  Burden_Header_Rec_Type
83 ,p_dtl_tbl         IN  Burden_Dtl_Tbl_Type
84 ,p_operation       IN  VARCHAR2
85 ,x_header_rec      OUT NOCOPY Burden_Header_Rec_Type
86 ,x_dtl_tbl         OUT NOCOPY Burden_Dtl_Tbl_Type
87 ,x_user_id         OUT NOCOPY fnd_user.user_id%TYPE
88 ,x_brdn_factor_tbl OUT NOCOPY GMF_BurdenDetails_PVT.Burden_factor_Tbl_Type
89 ,x_return_status   OUT NOCOPY VARCHAR2
90 ) ;
91 --
92 PROCEDURE log_msg       -- Bug 2659435: Removed first param for debug level
93 (
94  p_msg_text      IN VARCHAR2
95 );
96 --
97 -- Bug 2659435: Added new procedure to log header message
98 PROCEDURE add_header_to_error_stack
99 (
100  p_header       Burden_Header_Rec_Type
101 );
102 --
103 
104 -- Global variables
105 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'GMF_BurdenDetails_PUB';
106 
107 -- Bug 2659435
108 G_tmp           BOOLEAN := FND_MSG_PUB.Check_Msg_Level(0) ; -- temp call to initialize the
109                                                             -- msg level threshhold gobal
110                                                             -- variable.
111 G_debug_level   NUMBER(2) := FND_MSG_PUB.G_Msg_Level_Threshold; -- Use this variable everywhere
112                                                                  -- to decide to log a debug msg.
113 G_header_logged VARCHAR2(1);  -- to indicate whether header is already in
114                               -- error stack or not - avoid logging duplicate headers
115 
116 
117 --Start of comments
118 --+========================================================================+
119 --| API Name    : Create_Burden_Details                                    |
120 --| TYPE        : Public                                                   |
121 --| Function    : Creates a new Burden Details based on the input into table|
122 --|               CM_CMPT_DTL                                              |
123 --| Pre-reqa    : None.                                                    |
124 --| Parameters  :                                                          |
125 --| IN          :                                                          |
126 --|               p_api_version         IN  NUMBER       - Required        |
127 --|               p_init_msg_list       IN  VARCHAR2     - Optional        |
128 --|               p_commit              IN  VARCHAR2     - Optional        |
129 --|               p_header_rec          IN  Burden_Header_Rec_Type         |
130 --|               p_dtl_tbl             IN  Burden_Dtl_Tbl_Type            |
131 --|               p_user_id             IN  NUMBER                         |
132 --| OUT         :                                                          |
133 --|               x_return_status    OUT VARCHAR2                          |
134 --|               x_msg_count        OUT NUMBER                            |
135 --|               x_msg_data         OUT VARCHAR2                          |
136 --|               x_burdenline_ids   OUT Burdenline_Ids_Tbl_Type           |
137 --|                                                                        |
138 --| Version     :                                                          |
139 --|               Current Version       : 2.0                              |
140 --|               Previous Version      : 1.0                              |
141 --|               Initial Version       : 1.0                              |
142 --|                                                                        |
143 --| Notes       :                                                          |
144 --|                                                                        |
145 --| HISTORY                                                                |
146 --| 01-Mar-01     Uday Moogala - Created                                   |
147 --|                                                                        |
148 --+========================================================================+
149 -- End of comments
150 
151 PROCEDURE Create_Burden_Details
152 (
153   p_api_version                 IN  NUMBER                      ,
154   p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE ,
155   p_commit                      IN  VARCHAR2 := FND_API.G_FALSE ,
156 
157   x_return_status               OUT NOCOPY VARCHAR2                    ,
158   x_msg_count                   OUT NOCOPY VARCHAR2                    ,
159   x_msg_data                    OUT NOCOPY VARCHAR2                    ,
160 
161   p_header_rec                  IN  Burden_Header_Rec_Type      ,
162   p_dtl_tbl                     IN  Burden_Dtl_Tbl_Type         ,
163 
164   x_burdenline_ids              OUT NOCOPY Burdenline_Ids_Tbl_Type
165 )
166 IS
167 
168         l_api_name              CONSTANT VARCHAR2(30)   := 'Create_Burden_Details' ;
169         l_api_version           CONSTANT NUMBER         := 2.0 ;
170 
171         l_header_rec            Burden_Header_Rec_Type ;
172         l_dtl_tbl               Burden_Dtl_Tbl_Type ;
173         l_brdn_factor_tbl       GMF_BurdenDetails_PVT.Burden_factor_Tbl_Type ;
174         l_user_id               fnd_user.user_id%TYPE ;
175         l_return_status         VARCHAR2(2) ;
176         l_count                 NUMBER(10) ;
177         l_data                  VARCHAR2(2000) ;
178 
179 BEGIN
180 
181     -- Standard Start of API savepoint
182     SAVEPOINT    Create_Burden_Details_PUB ;
183 
184     -- Initialize message list if p_init_msg_list is set to TRUE.
185     IF FND_API.to_Boolean( p_init_msg_list ) THEN
186         FND_MSG_PUB.initialize;
187     END IF;
188 
189     -- Standard call to check for call compatibility.
190     IF NOT FND_API.Compatible_API_Call ( l_api_version          ,
191                                          p_api_version          ,
192                                          l_api_name             ,
193                                          G_PKG_NAME )
194     THEN
195         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
196     END IF;
197 
198     --  Initialize API return status to success
199     x_return_status := FND_API.G_RET_STS_SUCCESS;
200 
201     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
202         log_msg('Beginning Create Burden details process.');
203     END IF;
204 
205     G_header_logged := 'N';     -- to avoid logging duplicate header for errors
206 
207     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
208         log_msg('In public API. # of Detail records : ' || p_dtl_tbl.count);
209     END IF;
210 
211     IF p_dtl_tbl.count > 0 THEN
212       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
213         log_msg('Validating  input parameters');
214       END IF;
215       -- Validate all the input parameters.
216       Validate_Input_Params
217        (
218         p_header_rec      => p_header_rec
219        ,p_dtl_tbl         => p_dtl_tbl
220        ,p_operation       => 'INSERT'
221        ,x_header_rec      => l_header_rec
222        ,x_dtl_tbl         => l_dtl_tbl
223        ,x_user_id         => l_user_id
224        ,x_brdn_factor_tbl => l_brdn_factor_tbl
225        ,x_return_status   => l_return_status
226        ) ;
227 
228       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2681243
229         log_msg('Return Status after validating : ' || l_return_status);
230       END IF;
231 
232       -- Return if validation failures detected
233       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
234         add_header_to_error_stack(p_header_rec); -- Bug 2659435
235         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
236         FND_MSG_PUB.Add;
237         RAISE FND_API.G_EXC_ERROR;
238       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
239         add_header_to_error_stack(p_header_rec); -- Bug 2659435
240         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
241         FND_MSG_PUB.Add;
242         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
243       END IF;
244     END IF;
245 
246     IF l_dtl_tbl.count > 0 THEN
247       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
248         log_msg('Calling private API to insert record...');
249       END IF;
250       GMF_BurdenDetails_PVT.Create_Burden_Details
251         (
252           p_api_version         => 2.0
253         , p_init_msg_list       => FND_API.G_FALSE
254         , p_commit              => FND_API.G_FALSE
255 
256         , x_return_status       => l_return_status
257         , x_msg_count           => l_count
258         , x_msg_data            => l_data
259 
260         , p_header_rec          => l_header_rec
261         , p_dtl_tbl             => l_dtl_tbl
262         , p_user_id             => l_user_id
263         , p_burden_factor_tbl   => l_brdn_factor_tbl
264 
265         , x_burdenline_ids      => x_burdenline_ids
266       );
267 
268       -- Return if insert fails for any reason
269       IF l_return_status = FND_API.G_RET_STS_ERROR
270       THEN
271         add_header_to_error_stack(l_header_rec); -- Bug 2659435
272         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
273         FND_MSG_PUB.Add;
274         RAISE FND_API.G_EXC_ERROR;
275       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
276       THEN
277         add_header_to_error_stack(l_header_rec); -- Bug 2659435
278         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
279         FND_MSG_PUB.Add;
280         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
281       END IF;
282 
283       add_header_to_error_stack(l_header_rec); -- Bug 2659435
284       FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_INS');
285       FND_MESSAGE.SET_TOKEN('NUM_ROWS',x_burdenline_ids.count);
286       FND_MSG_PUB.Add;
287     ELSE
288       add_header_to_error_stack(p_header_rec); -- Bug 2659435
289       FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_INS');
290       FND_MSG_PUB.Add;
291     END IF ;
292 
293     -- Standard check of p_commit.
294     IF FND_API.To_Boolean( p_commit ) THEN
295         COMMIT WORK;
296     END IF;
297 
298     -- Standard call to get message count and if count is 1, get message info.
299     FND_MSG_PUB.Count_And_Get
300         (       p_count         =>      x_msg_count             ,
301                 p_data          =>      x_msg_data
302         );
303 
304 EXCEPTION
305     WHEN FND_API.G_EXC_ERROR THEN
306         ROLLBACK TO  Create_Burden_Details_PUB;
307         x_return_status := FND_API.G_RET_STS_ERROR ;
308         FND_MSG_PUB.Count_And_Get
309         (       p_count                 =>      x_msg_count     ,
310                 p_data                  =>      x_msg_data
311         );
312     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
313         ROLLBACK TO  Create_Burden_Details_PUB;
314         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
315         FND_MSG_PUB.Count_And_Get
316         (       p_count                 =>      x_msg_count     ,
317                 p_data                  =>      x_msg_data
318         );
319     WHEN OTHERS THEN
320         ROLLBACK TO  Create_Burden_Details_PUB;
321         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
322         IF FND_MSG_PUB.Check_Msg_Level
323            (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
324         THEN
325            FND_MSG_PUB.Add_Exc_Msg
326                 (       G_PKG_NAME      ,
327                         l_api_name
328                 );
329         END IF;
330         FND_MSG_PUB.Count_And_Get
331                 (       p_count                 =>      x_msg_count     ,
332                         p_data                  =>      x_msg_data
333                 );
334 
335 END Create_Burden_Details;
336 
337 
338 --Start of comments
339 --+========================================================================+
340 --| API Name    : Update_Burden_Details                                    |
341 --| TYPE        : Public                                                   |
342 --| Function    : Updates Burden Details based on the input in CM_BRDN_DTL |
343 --| Pre-reqa    : None.                                                    |
344 --| Parameters  :                                                          |
345 --| IN          :                                                          |
346 --|               p_api_version         IN  NUMBER       - Required        |
347 --|               p_init_msg_list       IN  VARCHAR2     - Optional        |
348 --|               p_commit              IN  VARCHAR2     - Optional        |
349 --|               p_header_rec          IN  Burden_Header_Rec_Type         |
350 --|               p_dtl_tbl             IN  Burden_Dtl_Tbl_Type            |
351 --|               p_user_id             IN  NUMBER                         |
352 --| OUT         :                                                          |
353 --|               x_return_status    OUT VARCHAR2                          |
354 --|               x_msg_count        OUT NUMBER                            |
355 --|               x_msg_data         OUT VARCHAR2                          |
356 --|                                                                        |
357 --| Version     :                                                          |
358 --|               Current Version       : 2.0                              |
359 --|               Previous Version      : 1.0                              |
360 --|               Initial Version       : 1.0                              |
361 --|                                                                        |
362 --| Notes       :                                                          |
363 --|                                                                        |
364 --| HISTORY                                                                |
365 --| 10-Apr-01     Uday Moogala - Created                                   |
366 --|                                                                        |
367 --+========================================================================+
368 -- End of comments
369 
370 PROCEDURE Update_Burden_Details
371 (
372   p_api_version                 IN  NUMBER                              ,
373   p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE ,
374   p_commit                      IN  VARCHAR2 := FND_API.G_FALSE ,
375 
376   x_return_status               OUT NOCOPY VARCHAR2                    ,
377   x_msg_count                   OUT NOCOPY VARCHAR2                    ,
378   x_msg_data                    OUT NOCOPY VARCHAR2                    ,
379 
380   p_header_rec                  IN  Burden_Header_Rec_Type      ,
381   p_dtl_tbl                     IN  Burden_Dtl_Tbl_Type
382 )
383 IS
384         l_api_name              CONSTANT VARCHAR2(30)   := 'Update_Burden_Details' ;
385         l_api_version           CONSTANT NUMBER         := 2.0 ;
386 
387         l_header_rec            Burden_Header_Rec_Type ;
388         l_dtl_tbl               Burden_Dtl_Tbl_Type ;
389         l_brdn_factor_tbl       GMF_BurdenDetails_PVT.Burden_factor_Tbl_Type ;
390         l_user_id               fnd_user.user_id%TYPE ;
391         l_return_status         VARCHAR2(2) ;
392         l_count                 NUMBER(10) ;
393         l_data                  VARCHAR2(2000) ;
394         l_no_rows_upd           NUMBER(10) ;
395 
396 BEGIN
397     -- Standard Start of API savepoint
398     SAVEPOINT    Update_Burden_Details_PUB;
399 
400     -- Initialize message list if p_init_msg_list is set to TRUE.
401     IF FND_API.to_Boolean( p_init_msg_list ) THEN
402         FND_MSG_PUB.initialize;
403     END IF;
404 
405     -- Standard call to check for call compatibility.
406     IF NOT FND_API.Compatible_API_Call ( l_api_version          ,
407                                          p_api_version          ,
408                                          l_api_name             ,
409                                          G_PKG_NAME )
410     THEN
411         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
412     END IF;
413 
414     --  Initialize API return status to success
415     x_return_status := FND_API.G_RET_STS_SUCCESS;
416 
417     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
418         log_msg('Beginning Update Burden Details Definition process.');
419     END IF;
420 
421     G_header_logged := 'N';     -- to avoid logging duplicate header for errors
422 
423     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
424         log_msg('In public API. # of detail records : ' || p_dtl_tbl.count);
425     END IF;
426 
427     IF p_dtl_tbl.count > 0 THEN
428       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
429         log_msg('Validating  input parameters');
430       END IF;
431       -- Validate all the input parameters.
432       Validate_Input_Params
433        (
434         p_header_rec      => p_header_rec
435        ,p_dtl_tbl         => p_dtl_tbl
436        ,p_operation       => 'UPDATE'
437        ,x_header_rec      => l_header_rec
438        ,x_dtl_tbl         => l_dtl_tbl
439        ,x_user_id         => l_user_id
440        ,x_brdn_factor_tbl => l_brdn_factor_tbl
441        ,x_return_status   => l_return_status
442        ) ;
443 
444       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2681243
445         log_msg('Return Status after validating : ' || l_return_status);
446       END IF;
447 
448       -- Return if validation failures detected
449       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
450         add_header_to_error_stack(p_header_rec); -- Bug 2659435
451         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
452         FND_MSG_PUB.Add;
453         RAISE FND_API.G_EXC_ERROR;
454       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
455         add_header_to_error_stack(p_header_rec); -- Bug 2659435
456         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
457         FND_MSG_PUB.Add;
458         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
459       END IF;
460     END IF;
461 
462     IF l_dtl_tbl.count > 0 THEN
463       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
464         log_msg('Calling private API to update records...');
465       END IF;
466       GMF_BurdenDetails_PVT.Update_Burden_Details
467         (
468           p_api_version         => 2.0
469         , p_init_msg_list       => FND_API.G_FALSE
470         , p_commit              => FND_API.G_FALSE
471 
472         , x_return_status       => l_return_status
473         , x_msg_count           => l_count
474         , x_msg_data            => l_data
475 
476         , p_header_rec          => l_header_rec
477         , p_dtl_tbl             => l_dtl_tbl
478         , p_user_id             => l_user_id
479         , p_burden_factor_tbl   => l_brdn_factor_tbl
480       );
481 
482       -- Return if update fails for any reason
483       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
484         add_header_to_error_stack(l_header_rec); -- Bug 2659435
485         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
486         FND_MSG_PUB.Add;
487         RAISE FND_API.G_EXC_ERROR;
488       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
489         add_header_to_error_stack(l_header_rec); -- Bug 2659435
490         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
491         FND_MSG_PUB.Add;
492         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
493       END IF;
494 
495       add_header_to_error_stack(l_header_rec); -- Bug 2659435
496       FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_UPD');
497       FND_MESSAGE.SET_TOKEN('NUM_ROWS',l_dtl_tbl.count);
498       FND_MSG_PUB.Add;
499 
500     ELSE
501       FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_UPD');
502       add_header_to_error_stack(p_header_rec); -- Bug 2659435
503       FND_MSG_PUB.Add;
504     END IF ;
505     --log_msg( l_no_rows_upd  || ' rows updated.');
506 
507 
508     -- Standard check of p_commit.
509     IF FND_API.To_Boolean( p_commit ) THEN
510         COMMIT WORK;
511     END IF;
512 
513     -- Standard call to get message count and if count is 1, get message info.
514     FND_MSG_PUB.Count_And_Get
515         (       p_count         =>      x_msg_count             ,
516                 p_data          =>      x_msg_data
517         );
518 
519 EXCEPTION
520     WHEN FND_API.G_EXC_ERROR THEN
521         ROLLBACK TO  Update_Burden_Details_PUB;
522         x_return_status := FND_API.G_RET_STS_ERROR ;
523         FND_MSG_PUB.Count_And_Get
524         (       p_count                 =>      x_msg_count     ,
525                 p_data                  =>      x_msg_data
526         );
527     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
528         ROLLBACK TO  Update_Burden_Details_PUB;
529         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
530         FND_MSG_PUB.Count_And_Get
531         (       p_count                 =>      x_msg_count     ,
532                 p_data                  =>      x_msg_data
533         );
534     WHEN OTHERS THEN
535         ROLLBACK TO  Update_Burden_Details_PUB;
536         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
537         IF FND_MSG_PUB.Check_Msg_Level
538            (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
539         THEN
540            FND_MSG_PUB.Add_Exc_Msg
541                 (       G_PKG_NAME      ,
542                         l_api_name
543                 );
544         END IF;
545         FND_MSG_PUB.Count_And_Get
546                 (       p_count                 =>      x_msg_count     ,
547                         p_data                  =>      x_msg_data
548                 );
549 
550 END Update_Burden_Details ;
551 
552 
553 --Start of comments
554 --+========================================================================+
555 --| API Name    : Delete_Burden_Details                                    |
556 --| TYPE        : Public                                                   |
557 --| Function    : Deletes Burden Details based on the input from CM_BRDN_DTL|
558 --| Pre-reqa    : None.                                                    |
559 --| Parameters  :                                                          |
560 --| IN          :                                                          |
561 --|               p_api_version         IN  NUMBER       - Required        |
562 --|               p_init_msg_list       IN  VARCHAR2     - Optional        |
563 --|               p_commit              IN  VARCHAR2     - Optional        |
564 --|               p_header_rec          IN  Burden_Header_Rec_Type         |
565 --|               p_dtl_tbl             IN  Burden_Dtl_Tbl_Type            |
566 --| OUT         :                                                          |
567 --|               x_return_status    OUT VARCHAR2                          |
568 --|               x_msg_count        OUT NUMBER                            |
569 --|               x_msg_data         OUT VARCHAR2                          |
570 --|                                                                        |
571 --| Version     :                                                          |
572 --|               Current Version       : 2.0                              |
573 --|               Previous Version      : 1.0                              |
574 --|               Initial Version       : 1.0                              |
575 --|                                                                        |
576 --| Notes       :                                                          |
577 --|                                                                        |
578 --| HISTORY                                                                |
579 --| 10-Apr-01     Uday Moogala - Created                                   |
580 --|                                                                        |
581 --+========================================================================+
582 -- End of comments
583 
584 PROCEDURE Delete_Burden_Details
585 (
586   p_api_version                 IN  NUMBER                              ,
587   p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE ,
588   p_commit                      IN  VARCHAR2 := FND_API.G_FALSE ,
589 
590   x_return_status               OUT NOCOPY VARCHAR2                    ,
591   x_msg_count                   OUT NOCOPY VARCHAR2                    ,
592   x_msg_data                    OUT NOCOPY VARCHAR2                    ,
593 
594   p_header_rec                  IN  Burden_Header_Rec_Type      ,
595   p_dtl_tbl                     IN  Burden_Dtl_Tbl_Type
596 )
597 IS
598         l_api_name              CONSTANT VARCHAR2(30)   := 'Delete_Burden_Details' ;
599         l_api_version           CONSTANT NUMBER         := 2.0 ;
600 
601         l_header_rec            Burden_Header_Rec_Type ;
602         l_dtl_tbl               Burden_Dtl_Tbl_Type ;
603         l_brdn_factor_tbl       GMF_BurdenDetails_PVT.Burden_factor_Tbl_Type ;
604         l_user_id               fnd_user.user_id%TYPE ;
605         l_return_status         VARCHAR2(2) ;
606         l_count                 NUMBER(10) ;
607         l_data                  VARCHAR2(2000) ;
608         l_no_rows_del           NUMBER(10) ;
609         -- l_user_name             fnd_user.user_name%TYPE := FND_API.G_MISS_CHAR ; Bug 2659435
610 
611 BEGIN
612 
613     -- Standard Start of API savepoint
614     SAVEPOINT    Delete_Burden_Details_PUB;
615 
616     -- Initialize message list if p_init_msg_list is set to TRUE.
617     IF FND_API.to_Boolean( p_init_msg_list ) THEN
618         FND_MSG_PUB.initialize;
619     END IF;
620 
621     -- Standard call to check for call compatibility.
622     IF NOT FND_API.Compatible_API_Call ( l_api_version          ,
623                                          p_api_version          ,
624                                          l_api_name             ,
625                                          G_PKG_NAME )
626     THEN
627         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
628     END IF;
629 
630     --  Initialize API return status to success
631     x_return_status := FND_API.G_RET_STS_SUCCESS;
632 
633     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
634         log_msg('Beginning Delete Burden Details process.');
635     END IF;
636 
637     G_header_logged := 'N';     -- to avoid logging duplicate header for errors
638 
639     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
640         log_msg('In public API. # of detail records : ' || p_dtl_tbl.count);
641     END IF;
642 
643     IF p_dtl_tbl.count > 0 THEN
644       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
645         log_msg('Validating  input parameters');
646       END IF;
647 
648       -- Validate all the input parameters.
649       Validate_Input_Params
650        (
651         p_header_rec      => p_header_rec
652        ,p_dtl_tbl         => p_dtl_tbl
653        ,p_operation       => 'DELETE'
654        ,x_header_rec      => l_header_rec
655        ,x_dtl_tbl         => l_dtl_tbl
656        ,x_user_id         => l_user_id
657        ,x_brdn_factor_tbl => l_brdn_factor_tbl
658        ,x_return_status   => l_return_status
659        ) ;
660 
661       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2681243
662         log_msg('Return Status after validating : ' || l_return_status);
663       END IF;
664 
665       -- Return if validation failures detected
666       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
667         add_header_to_error_stack(p_header_rec); -- Bug 2659435
668         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
669         FND_MSG_PUB.Add;
670         RAISE FND_API.G_EXC_ERROR;
671       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
672         add_header_to_error_stack(p_header_rec); -- Bug 2659435
673         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
674         FND_MSG_PUB.Add;
675         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
676       END IF;
677     END IF;
678 
679     IF l_dtl_tbl.count > 0 THEN
680       IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN  -- Bug 2659435
681         log_msg('Calling private API to delete records...');
682       END IF;
683 
684       GMF_BurdenDetails_PVT.Update_Burden_Details
685         (
686           p_api_version         => 2.0
687         , p_init_msg_list       => FND_API.G_FALSE
688         , p_commit              => FND_API.G_FALSE
689 
690         , x_return_status       => l_return_status
691         , x_msg_count           => l_count
692         , x_msg_data            => l_data
693 
694         , p_header_rec          => l_header_rec
695         , p_dtl_tbl             => l_dtl_tbl
696         , p_user_id             => l_user_id
697         , p_burden_factor_tbl   => l_brdn_factor_tbl
698       );
699 
700       -- Return if update fails for any reason
701       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
702         add_header_to_error_stack(l_header_rec); -- Bug 2659435
703         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
704         FND_MSG_PUB.Add;
705         RAISE FND_API.G_EXC_ERROR;
706       ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
707         add_header_to_error_stack(l_header_rec); -- Bug 2659435
708         FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
709         FND_MSG_PUB.Add;
710         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
711       END IF;
712 
713       add_header_to_error_stack(l_header_rec); -- Bug 2659435
714       FND_MESSAGE.SET_NAME('GMF','GMF_API_ROWS_DEL');
715       FND_MESSAGE.SET_TOKEN('NUM_ROWS',l_dtl_tbl.count);
716       FND_MSG_PUB.Add;
717 
718     ELSE
719       add_header_to_error_stack(l_header_rec); -- Bug 2659435
720       FND_MESSAGE.SET_NAME('GMF','GMF_API_NO_ROWS_DEL');
721       FND_MSG_PUB.Add;
722     END IF ;
723 
724     --log_msg(l_no_rows_del || ' rows deleted.');
725 
726     -- Standard check of p_commit.
727     IF FND_API.To_Boolean( p_commit ) THEN
728         COMMIT WORK;
729     END IF;
730 
731     -- Standard call to get message count and if count is 1, get message info.
732     FND_MSG_PUB.Count_And_Get
733         (       p_count         =>      x_msg_count             ,
734                 p_data          =>      x_msg_data
735         );
736 
737 EXCEPTION
738     WHEN FND_API.G_EXC_ERROR THEN
739         ROLLBACK TO  Delete_Burden_Details_PUB;
740         x_return_status := FND_API.G_RET_STS_ERROR ;
741         FND_MSG_PUB.Count_And_Get
742         (       p_count                 =>      x_msg_count     ,
743                 p_data                  =>      x_msg_data
744         );
745     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
746         ROLLBACK TO  Delete_Burden_Details_PUB;
747         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
748         FND_MSG_PUB.Count_And_Get
749         (       p_count                 =>      x_msg_count     ,
750                 p_data                  =>      x_msg_data
751         );
752     WHEN OTHERS THEN
753         ROLLBACK TO  Delete_Burden_Details_PUB;
754         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
755         IF FND_MSG_PUB.Check_Msg_Level
756            (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
757         THEN
758            FND_MSG_PUB.Add_Exc_Msg
759                 (       G_PKG_NAME      ,
760                         l_api_name
761                 );
762         END IF;
763         FND_MSG_PUB.Count_And_Get
764                 (       p_count                 =>      x_msg_count     ,
765                         p_data                  =>      x_msg_data
766                 );
767 
768 END Delete_Burden_Details ;
769 
770 --Start of comments
771 --+========================================================================+
772 --| API Name    : Get_Burden_Details                                       |
773 --| TYPE        : Public                                                   |
774 --| Function    : Retrieve Burden Details based on the input from CM_BRDN_DTL|
775 --| Pre-reqa    : None.                                                    |
776 --| Parameters  :                                                          |
777 --| IN          :                                                          |
778 --|               p_api_version         IN  NUMBER       - Required        |
779 --|               p_init_msg_list       IN  VARCHAR2     - Optional        |
780 --|               p_header_rec          IN  Burden_Header_Rec_Type         |
781 --| OUT         :                                                          |
782 --|               x_return_status    OUT VARCHAR2                          |
783 --|               x_msg_count        OUT NUMBER                            |
784 --|               x_msg_data         OUT VARCHAR2                          |
785 --|               x_dtl_tbl          OUT Burden_Dtl_Tbl_Type               |
786 --|                                                                        |
787 --| Version     :                                                          |
788 --|               Current Version       : 2.0                              |
789 --|               Previous Version      : 1.0                              |
790 --|               Initial Version       : 1.0                              |
791 --|                                                                        |
792 --| Notes       :                                                          |
793 --|                                                                        |
794 --| HISTORY                                                                |
795 --| 26-Apr-01     Uday Moogala - Created                                   |
796 --| 20-Oct-2005  Prasad marada, Bug 4689137 Modified the record type as    |
797 --|                             per inventory convergence                  |
798 --|                                                                        |
799 --+========================================================================+
800 -- End of comments
801 
802 PROCEDURE Get_Burden_Details
803 (
804   p_api_version                 IN  NUMBER                              ,
805   p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE ,
806 
807   x_return_status               OUT NOCOPY VARCHAR2                    ,
808   x_msg_count                   OUT NOCOPY VARCHAR2                    ,
809   x_msg_data                    OUT NOCOPY VARCHAR2                    ,
810 
811   p_header_rec                  IN  Burden_Header_Rec_Type      ,
812 
813   x_dtl_tbl                     OUT NOCOPY Burden_Dtl_Tbl_Type
814 )
815 IS
816         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Burden_Details' ;
817         l_api_version           CONSTANT NUMBER         := 2.0 ;
818 
819         l_return_status         VARCHAR2(2) ;
820         l_count                 NUMBER(10) ;
821         l_data                  VARCHAR2(2000) ;
822 
823         l_header_rec            Burden_Header_Rec_Type ;
824         l_act_item_uom          cm_brdn_dtl.item_uom%TYPE ;
825         l_period_status         cm_cldr_dtl.period_status%TYPE ;
826         l_user_id               fnd_user.user_id%TYPE ;
827         l_lc_cost_type_id       cm_mthd_mst.cost_type_id%TYPE;
828 
829 BEGIN
830 
831     -- Standard Start of API savepoint
832     SAVEPOINT    Get_Burden_Details_PUB;
833 
834     -- Initialize message list if p_init_msg_list is set to TRUE.
835     IF FND_API.to_Boolean( p_init_msg_list ) THEN
836         FND_MSG_PUB.initialize;
837     END IF;
838 
839     -- Standard call to check for call compatibility.
840 
841     IF NOT FND_API.Compatible_API_Call ( l_api_version          ,
842                                          p_api_version          ,
843                                          l_api_name             ,
844                                          G_PKG_NAME )
845     THEN
846         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
847     END IF;
848 
849     --  Initialize API return status to success
850     x_return_status := FND_API.G_RET_STS_SUCCESS;
851 
852     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
853         log_msg('Beginning Get Burden Details process.');
854     END IF;
855 
856     G_header_logged := 'N';     -- to avoid logging duplicate header for errors
857 
858     /* Validating Header Record */
859     --------------------------
860     -- organization validation
861     --------------------------
862     -- If organization id is sent then use organization id else
863     -- use organization code
864     -- organization id
865     IF (p_header_rec.organization_id <> FND_API.G_MISS_NUM) AND
866        (p_header_rec.organization_id IS NOT NULL)  THEN
867         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
868            log_msg('validating organization_id : ' || p_header_rec.organization_id);
869         END IF;
870         IF NOT GMF_VALIDATIONS_PVT.Validate_organization_id(p_header_rec.organization_id)
871         THEN
872           add_header_to_error_stack(p_header_rec); -- Bug 2659435
873           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_ID');
874           FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
875           FND_MSG_PUB.Add;
876           RAISE FND_API.G_EXC_ERROR;
877         END IF;
878           -- Log message to ignore if organization_Code is also passed
879         IF (p_header_rec.organization_code <> FND_API.G_MISS_CHAR) AND
880            (p_header_rec.organization_code IS NOT NULL) THEN
881           IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
882                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
883                 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ORGN_CODE');
884                 FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header_rec.organization_code);
885                 FND_MSG_PUB.Add;
886           END IF;
887         END IF;
888           -- organization code
889     ELSIF (p_header_rec.organization_code <> FND_API.G_MISS_CHAR) AND
890        (p_header_rec.organization_code IS NOT NULL)  THEN
891         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN -- Bug 2659435
892            log_msg('validating organization_code : ' || p_header_rec.organization_code);
893         END IF;
894 
895         l_header_rec.organization_id := GMF_VALIDATIONS_PVT.Validate_organization_Code(p_header_rec.organization_code);
896         IF l_header_rec.organization_id IS NULL THEN
897           add_header_to_error_stack(p_header_rec); -- Bug 2659435
898           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_CODE');
899           FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header_rec.organization_code);
900           FND_MSG_PUB.Add;
901           RAISE FND_API.G_EXC_ERROR;
902         ELSE
903           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 5589409, pmarada
904              log_msg('Organization Id : ' || l_header_rec.organization_id );
905           END IF;
906         END IF;
907     ELSE
908           add_header_to_error_stack(p_header_rec);
909           FND_MESSAGE.SET_NAME('GMF','GMF_API_ORGANIZATION_ID_REQ');
910           FND_MSG_PUB.Add;
911           RAISE FND_API.G_EXC_ERROR;
912     END IF;
913     -- End organization validation
914     --
915     ------------------------
916     -- Item Validation
917     ------------------------
918     -- Use inventory item_id if sent otherwise use item_number
919     -- If both are sent then use only item_id and ignore other params and log a message
920     -- If both are not sent then raise error.
921     --
922     IF (p_header_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
923        (p_header_rec.inventory_item_id IS NOT NULL)  THEN
924         -- validate inventory_item_id
925         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN
926            log_msg('validating inventory_item_id : ' || p_header_rec.inventory_item_id);
927         END IF;
928 
929         IF NOT (GMF_VALIDATIONS_PVT.Validate_inventory_item_Id(p_header_rec.inventory_item_id, p_header_rec.organization_id))
930         THEN
931           add_header_to_error_stack(p_header_rec); -- Bug 2659435
932           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_ID');
933           FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.inventory_item_id);
934           FND_MSG_PUB.Add;
935           RAISE FND_API.G_EXC_ERROR;
936         END IF;
937         -- Log message if item_number is also passed
938         IF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND
939            (p_header_rec.item_number IS NOT NULL) THEN
940           IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
941                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
942                 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ITEM_NO');
943                 FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
944                 FND_MSG_PUB.Add;
945           END IF;
946         END IF;
947     ELSIF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND
948           (p_header_rec.item_number IS NOT NULL)  THEN
949         -- Convert item number value into item ID.
950         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
951            log_msg('validating item_number : ' || p_header_rec.item_number);
952         END IF;
953           -- If Organization id is passed as null then assign the derived organization id
954         l_header_rec.organization_id := nvl(p_header_rec.organization_id,l_header_rec.organization_id) ;
955         l_header_rec.inventory_item_id := GMF_VALIDATIONS_PVT.Validate_Item_Number(p_header_rec.item_number,l_header_rec.organization_id);
956 
957         IF l_header_rec.inventory_item_id IS NULL THEN       -- item_Id fetch was not successful
958           -- Conversion failed.
959           add_header_to_error_stack(p_header_rec); -- Bug 2659435
960           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_NO');
961           FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
962           FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',l_header_rec.organization_id);
963           FND_MSG_PUB.Add;
964           RAISE FND_API.G_EXC_ERROR;
965         ELSE
966           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
967              log_msg('inventory_item_id : ' || l_header_rec.inventory_item_id );
968           END IF;
969         END IF;
970     ELSE
971         add_header_to_error_stack(p_header_rec); -- Bug 2659435
972         FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_ID_REQ');
973         FND_MSG_PUB.Add;
974         RAISE FND_API.G_EXC_ERROR;
975     END IF;
976     -- End Item validation
977 
978 
979     ------------------------
980     -- Cost Method Code
981     ------------------------
982     IF (p_header_rec.cost_type_id <> FND_API.G_MISS_NUM)
983     AND (p_header_rec.cost_type_id IS NOT NULL)
984     THEN
985       IF (FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level)
986       THEN
987      	log_msg('Validating Cost type Id : ' || p_header_rec.cost_type_id);
988       END IF;
989        -- cost type id should be standard or actual cost type because this API is for Standard and actual cost
990        -- overheads only. So Call Validate_Lot_Cost_type_id to verify the cost type is lot cost type or not.
991        -- If it is lot cost type id then log error message as invalid cost type
992       IF GMF_VALIDATIONS_PVT.Validate_Lot_Cost_type_id(p_header_rec.cost_type_id) THEN
993         add_header_to_error_stack(p_header_rec);
994         FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE_ID');
995         FND_MESSAGE.SET_TOKEN('COST_TYPE_ID',p_header_rec.cost_type_id);
996         FND_MSG_PUB.Add;
997         RAISE FND_API.G_EXC_ERROR;
998       END IF;
999        -- log a message to ignore if cost method code also passed
1000       IF (p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.cost_mthd_code IS NOT NULL) THEN
1001          IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)   THEN
1002             FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_COST_TYPE');
1003             FND_MESSAGE.SET_TOKEN('COST_TYPE', p_header_rec.cost_mthd_code);
1004             FND_MSG_PUB.Add;
1005           END IF;
1006       END IF;
1007        -- if cost type method code passed
1008     ELSE
1009       IF (p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR)
1010       AND (p_header_rec.cost_mthd_code IS NOT NULL)
1011       THEN
1012         IF (FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level)  THEN
1013           log_msg('Validating Cost type : ' || p_header_rec.cost_mthd_code);
1014         END IF;
1015           -- call validate lot cost type
1016          l_header_rec.cost_Type_id := GMF_VALIDATIONS_PVT.Validate_Cost_type_Code(p_header_rec.cost_mthd_code);
1017           -- Call validate lot cost type to check lot cost type, if it is lot cost type then log error
1018           -- because overheads will be created for actual and standard costs
1019          l_lc_cost_type_id := GMF_VALIDATIONS_PVT.Validate_Lot_Cost_Type(p_header_rec.cost_mthd_code);
1020          --If cost type id is null or cost type is lot cost type then log invalid cost type message
1021          IF (l_header_rec.cost_Type_id IS NULL)
1022             OR (l_lc_cost_type_id IS NOT NULL ) THEN
1023            add_header_to_error_stack(p_header_rec);
1024            FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE');
1025            FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header_rec.cost_mthd_code);
1026            FND_MSG_PUB.Add;
1027            RAISE FND_API.G_EXC_ERROR;
1028          ELSE
1029            IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1030               log_msg('Cost_Type_id : ' || l_header_rec.cost_Type_id );
1031            END IF;
1032          END IF;
1033       ELSE
1034         add_header_to_error_stack(p_header_rec);
1035         FND_MESSAGE.SET_NAME('GMF','GMF_API_COST_TYPE_ID_REQ');
1036         FND_MSG_PUB.Add;
1037         RAISE FND_API.G_EXC_ERROR;
1038       END IF;
1039     END IF;
1040     -- End Cost Method Code
1041 
1042     ------------------------
1043     -- Period Id validation
1044     ------------------------
1045     IF (p_header_rec.period_id <> FND_API.G_MISS_NUM) AND (p_header_rec.period_id IS NOT NULL)
1046     THEN
1047        IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1048        THEN
1049         log_msg('validating Period Id : ' || p_header_rec.period_id);
1050        END IF;
1051        IF NOT GMF_VALIDATIONS_PVT.Validate_period_id(p_header_rec.period_id)
1052        THEN
1053         add_header_to_error_stack(p_header_rec);
1054         FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_PERIOD_ID');
1055         FND_MESSAGE.SET_TOKEN('PERIOD_ID',p_header_rec.period_id);
1056         FND_MSG_PUB.Add;
1057         RAISE FND_API.G_EXC_ERROR;
1058       END IF;
1059        -- If period code also passed then ignore period code
1060       IF ((p_header_rec.calendar_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.calendar_code IS NOT NULL))
1061          AND ((p_header_rec.period_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.period_code IS NOT NULL)) THEN
1062         IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
1063            FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_PERIOD_CODE');
1064            FND_MESSAGE.SET_TOKEN('CALENDAR_CODE', p_header_rec.calendar_code);
1065            FND_MESSAGE.SET_TOKEN('PERIOD_CODE', p_header_rec.period_code);
1066            FND_MSG_PUB.Add;
1067          END IF;
1068       END IF;
1069       -- period code and calendar code are passed instead of period id
1070     ELSE
1071       IF ((p_header_rec.calendar_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.calendar_code IS NOT NULL))
1072       AND ((p_header_rec.period_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.period_code IS NOT NULL))
1073       THEN
1074          IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level
1075          THEN
1076             log_msg('Validating Calendar Code : '|| p_header_rec.Calendar_code||' period_code : ' || p_header_rec.period_code);
1077          END IF;
1078         -- if cost type id passed as null then  assign derived cost type id to the record
1079         -- and pass the derived cost type id for derving to period id
1080         l_header_rec.cost_type_id    := nvl(p_header_rec.cost_type_id,l_header_rec.cost_type_id) ;
1081         l_header_rec.organization_id := nvl(p_header_rec.organization_id,l_header_rec.organization_id) ;
1082          -- get the period id value
1083         l_header_rec.period_id := GMF_VALIDATIONS_PVT.Validate_period_code(l_header_rec.organization_id, p_header_rec.calendar_code,p_header_rec.period_code,l_header_rec.cost_type_id );
1084         -- if derived period id is null then log a message
1085         IF l_header_rec.period_id IS NULL THEN
1086           add_header_to_error_stack(p_header_rec);
1087           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CLDR_PERIOD');
1088           FND_MESSAGE.SET_TOKEN('CALENDAR_CODE',p_header_rec.calendar_code);
1089           FND_MESSAGE.SET_TOKEN('PERIOD_CODE',p_header_rec.period_code);
1090           FND_MSG_PUB.Add;
1091           RAISE FND_API.G_EXC_ERROR;
1092         ELSE
1093           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1094              log_msg('period_id : ' || l_header_rec.period_id );
1095           END IF;
1096         END IF;
1097       ELSE
1098         add_header_to_error_stack(p_header_rec);
1099         FND_MESSAGE.SET_NAME('GMF','GMF_API_PERIOD_ID_REQ');
1100         FND_MSG_PUB.Add;
1101         RAISE FND_API.G_EXC_ERROR;
1102       END IF;
1103     END IF;
1104 
1105     -- Note: period Code
1106     -- No need to bother about Frozen and Closed Periods. Screen allows insert
1107     -- and updates even of period is Frozen and Closed.
1108     --
1109     ------------------------
1110     -- Populate WHO columns
1111     ------------------------
1112     IF (p_header_rec.user_name <> FND_API.G_MISS_CHAR) AND
1113        (p_header_rec.user_name IS NOT NULL)  THEN
1114        IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1115           log_msg('Validating user name : ' || p_header_rec.user_name);
1116        END IF;
1117             GMA_GLOBAL_GRP.Get_who( p_user_name  => p_header_rec.user_name
1118                                   , x_user_id    => l_user_id
1119                                   );
1120 
1121             IF l_user_id = -1 THEN      -- Bug 2681243: GMA changed return status value to -1.
1122                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1123                 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_USER_NAME');
1124                 FND_MESSAGE.SET_TOKEN('USER_NAME',p_header_rec.user_name);
1125                 FND_MSG_PUB.Add;
1126                 RAISE FND_API.G_EXC_ERROR;
1127             END IF;
1128 
1129     ELSE
1130         add_header_to_error_stack(p_header_rec); -- Bug 2659435
1131         FND_MESSAGE.SET_NAME('GMF','GMF_API_USER_NAME_REQ');
1132         FND_MSG_PUB.Add;
1133         RAISE FND_API.G_EXC_ERROR;
1134     END IF;
1135     -- End User Name
1136     l_header_rec.organization_id   := nvl(p_header_rec.organization_id,l_header_rec.organization_id) ;
1137     l_header_rec.organization_code := p_header_rec.organization_code ;
1138     l_header_rec.inventory_item_id := nvl(p_header_rec.inventory_item_id,l_header_rec.inventory_item_id) ;
1139     l_header_rec.item_number       := p_header_rec.item_number ;
1140     l_header_rec.period_id         := nvl(p_header_rec.period_id,l_header_rec.period_id) ;
1141     l_header_rec.calendar_code     := p_header_rec.calendar_code ;
1142     l_header_rec.period_code       := p_header_rec.period_code ;
1143     l_header_rec.cost_type_id      := nvl(p_header_rec.cost_type_id,l_header_rec.cost_type_id) ;
1144     l_header_rec.cost_mthd_code    := p_header_rec.cost_mthd_code ;
1145     l_header_rec.user_name         := p_header_rec.user_name ;
1146 
1147     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1148         log_msg( 'organization_id : '   || l_header_rec.organization_id ) ;
1149         log_msg( 'organization_code : ' || l_header_rec.organization_code ) ;
1150         log_msg( 'inventory_item_id : ' || l_header_rec.inventory_item_id ) ;
1151         log_msg( 'item_number : '   || l_header_rec.item_number ) ;
1152         log_msg( 'period_id : '     || l_header_rec.period_id ) ;
1153         log_msg( 'calendar_code : ' || l_header_rec.calendar_code ) ;
1154         log_msg( 'period_code : '   || l_header_rec.period_code ) ;
1155         log_msg( 'cost_type_id : '  || l_header_rec.cost_type_id ) ;
1156         log_msg( 'cost_mthd_code : ' || l_header_rec.cost_mthd_code ) ;
1157         log_msg( 'user_name : ' || l_header_rec.user_name ) ;
1158     END IF;
1159 
1160     /* End of Validations on Header Record */
1161     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1162        log_msg('Calling private API to retrieve records...');
1163     END IF;
1164     GMF_BurdenDetails_PVT.Get_Burden_Details
1165       (
1166         p_api_version         => 2.0
1167       , p_init_msg_list       => FND_API.G_FALSE
1168 
1169       , x_return_status       => l_return_status
1170       , x_msg_count           => l_count
1171       , x_msg_data            => l_data
1172 
1173       , p_header_rec          => l_header_rec
1174       , x_dtl_tbl             => x_dtl_tbl
1175     );
1176 
1177     -- Return if update fails for any reason
1178     IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1179       RAISE FND_API.G_EXC_ERROR;
1180     ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1181       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1182     END IF;
1183 
1184     /*
1185     -- Standard check of p_commit.
1186     IF FND_API.To_Boolean( p_commit ) THEN
1187         COMMIT WORK;
1188     END IF;
1189     */
1190 
1191     -- Standard call to get message count and if count is 1, get message info.
1192     FND_MSG_PUB.Count_And_Get
1193         (       p_count         =>      x_msg_count             ,
1194                 p_data          =>      x_msg_data
1195         );
1196 
1197 EXCEPTION
1198     WHEN FND_API.G_EXC_ERROR THEN
1199         ROLLBACK TO  Get_Burden_Details_PUB;
1200         x_return_status := FND_API.G_RET_STS_ERROR ;
1201         FND_MSG_PUB.Count_And_Get
1202         (       p_count                 =>      x_msg_count     ,
1203                 p_data                  =>      x_msg_data
1204         );
1205     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1206         ROLLBACK TO  Get_Burden_Details_PUB;
1207         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1208         FND_MSG_PUB.Count_And_Get
1209         (       p_count                 =>      x_msg_count     ,
1210                 p_data                  =>      x_msg_data
1211         );
1212     WHEN OTHERS THEN
1213         ROLLBACK TO  Get_Burden_Details_PUB;
1214         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1215         IF FND_MSG_PUB.Check_Msg_Level
1216            (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1217         THEN
1218            FND_MSG_PUB.Add_Exc_Msg
1219                 (       G_PKG_NAME      ,
1220                         l_api_name
1221                 );
1222         END IF;
1223         FND_MSG_PUB.Count_And_Get
1224                 (       p_count                 =>      x_msg_count     ,
1225                         p_data                  =>      x_msg_data
1226                 );
1227 END Get_Burden_Details ;
1228 
1229 -- Proc start of comments
1230 --+==========================================================================+
1231 --|  PROCEDURE NAME                                                          |
1232 --|       Validate_Input_Params                                              |
1233 --|                                                                          |
1234 --|  DESCRIPTION                                                             |
1235 --|       Validates all the input parameters.                                |
1236 --|                                                                          |
1237 --|  PARAMETERS                                                              |
1238 --|        p_header_rec       IN  Burden_Header_Rec_Type                     |
1239 --|        p_dtl_tbl          IN  Burden_Dtl_Tbl_Type                        |
1240 --|        p_operation        IN  VARCHAR2                                   |
1241 --|                                                                          |
1242 --|        x_header_rec       OUT Burden_Header_Rec_Type                     |
1243 --|        x_dtl_tbl          OUT Burden_Dtl_Tbl_Type                        |
1244 --|        x_dtl_tbl          OUT Burden_Dtl_Tbl_Type                        |
1245 --|        x_user_id          OUT fnd_user.user_id%TYPE                      |
1246 --|        x_return_status    OUT VARCHAR2                                   |
1247 --|                                                                          |
1248 --|  RETURNS                                                                 |
1249 --|       TRUE  - If succesfully initialized all variables                   |
1250 --|       FALSE - If any error                                               |
1251 --|                                                                          |
1252 --|  HISTORY                                                                 |
1253 --|    27/Feb/2001  Uday Moogla - Created                                    |
1254 --|    13/Aug/2001  Uday Moogala  Bug# 1935297                               |
1255 --|                 UOM conversion fails even in case of same UOMs. This is  |
1256 --|                 happenning since item id is not getting passed to the    |
1257 --|                 UOM conversion routine. And this happens only when Item  |
1258 --|                 No is passed instead of Item_Id. Fix is done to pass the |
1259 --|                 Item_Id to UOM conversion routine.                       |
1260 --|    12/May/2004  Dinesh Vadivel Bug# 3314310                              |
1261 --|                 Removed Validation code for the item BURDEN_USAGE in     |
1262 --|                 VALIDATE_INPUT_PARAMS proc so that it takes negative     |
1263 --|                 values                                                   |
1264 --|    20-Oct-2005  Prasad marada, Bug 4689137 Modified the record type as   |
1265 --|                per inventory convergence                                 |
1266 --|    29-Mar-2007 Prasad marada Bug 5589409, Fixed small formating issues   |
1267 --|                                                                          |
1268 --+==========================================================================+
1269 -- Proc end of comments
1270 
1271 PROCEDURE Validate_Input_Params
1272 (
1273  p_header_rec      IN  Burden_Header_Rec_Type
1274 ,p_dtl_tbl         IN  Burden_Dtl_Tbl_Type
1275 ,p_operation       IN  VARCHAR2
1276 ,x_header_rec      OUT NOCOPY Burden_Header_Rec_Type
1277 ,x_dtl_tbl         OUT NOCOPY Burden_Dtl_Tbl_Type
1278 ,x_user_id         OUT NOCOPY fnd_user.user_id%TYPE
1279 ,x_brdn_factor_tbl OUT NOCOPY GMF_BurdenDetails_PVT.Burden_factor_Tbl_Type
1280 ,x_return_status   OUT NOCOPY VARCHAR2
1281 )
1282 IS
1283 
1284         l_period_status        cm_cldr_dtl.period_status%TYPE ;
1285         l_usage_ind            cm_cmpt_mst.usage_ind%TYPE ;
1286         l_cost_cmpntcls_id     cm_cmpt_mst.cost_cmpntcls_id%TYPE ;
1287         l_cost_cmpntcls_code   cm_cmpt_mst.cost_cmpntcls_code%TYPE ;
1288 
1289         l_act_item_uom         mtl_item_flexfields.primary_uom_code%TYPE ;
1290         l_resource_uom         cr_rsrc_mst.std_usage_uom%TYPE ;
1291         l_burden_uom_class     mtl_units_of_measure.uom_class%TYPE ;
1292         l_resource_uom_class   mtl_units_of_measure.uom_class%TYPE ;
1293 
1294         l_burdenline_id        cm_brdn_dtl.burdenline_id%TYPE ;
1295         l_burden_factor        cm_brdn_dtl.burden_factor%TYPE ;
1296 
1297         -- Bug 2681243
1298         l_resources            cm_brdn_dtl.resources%TYPE ;
1299         l_burden_qty           cm_brdn_dtl.burden_qty%TYPE ;
1300         l_burden_usage         cm_brdn_dtl.burden_usage%TYPE ;
1301         l_burden_uom           cm_brdn_dtl.burden_uom%TYPE ;
1302         l_item_qty             cm_brdn_dtl.item_qty%TYPE ;
1303         l_item_uom             cm_brdn_dtl.item_uom%TYPE ;
1304         l_lc_cost_type_id       cm_mthd_mst.cost_type_id%TYPE;
1305 
1306         l_converted_burden_qty NUMBER ;
1307         l_converted_item_qty   NUMBER ;
1308 
1309         l_idx                  NUMBER(10) := 0 ;
1310         e_brdn_dtl             EXCEPTION ;
1311 
1312 BEGIN
1313 
1314     --  Initialize API return status to success
1315     x_return_status := FND_API.G_RET_STS_SUCCESS;
1316 
1317     -- just to make sure no elements exist.
1318     x_dtl_tbl.delete ;
1319     x_brdn_factor_tbl.delete ;
1320 
1321     /* Validating Header Record */
1322     --
1323     ------------------------------
1324     -- Organization Id validation
1325     ------------------------------
1326     -- If organization id is sent then use organization id else
1327     -- use organization code
1328     -- organization id
1329     IF (p_header_rec.organization_id <> FND_API.G_MISS_NUM) AND
1330        (p_header_rec.organization_id IS NOT NULL)  THEN
1331         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1332            log_msg('validating organization_id : ' || p_header_rec.organization_id);
1333         END IF;
1334 
1335         IF NOT GMF_VALIDATIONS_PVT.Validate_organization_id(p_header_rec.organization_id)
1336         THEN
1337           add_header_to_error_stack(p_header_rec); -- Bug 2659435
1338           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_ID');
1339           FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header_rec.organization_id);
1340           FND_MSG_PUB.Add;
1341           RAISE FND_API.G_EXC_ERROR;
1342         END IF;
1343 
1344           -- Log message to ignore if organization_Code is also passed
1345         IF (p_header_rec.organization_code <> FND_API.G_MISS_CHAR) AND
1346            (p_header_rec.organization_code IS NOT NULL) THEN
1347           IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
1348                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1349                 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ORGN_CODE');
1350                 FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header_rec.organization_code);
1351                 FND_MSG_PUB.Add;
1352           END IF;
1353         END IF;
1354           -- organization code
1355     ELSIF (p_header_rec.organization_code <> FND_API.G_MISS_CHAR) AND
1356        (p_header_rec.organization_code IS NOT NULL)  THEN
1357 
1358         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN -- Bug 2659435
1359            log_msg('validating organization_code : ' || p_header_rec.organization_code);
1360         END IF;
1361         x_header_rec.organization_id := GMF_VALIDATIONS_PVT.Validate_organization_Code(p_header_rec.organization_code);
1362         IF x_header_rec.organization_id IS NULL THEN
1363           add_header_to_error_stack(p_header_rec); -- Bug 2659435
1364           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ORGN_CODE');
1365           FND_MESSAGE.SET_TOKEN('ORG_CODE',p_header_rec.organization_code);
1366           FND_MSG_PUB.Add;
1367           RAISE FND_API.G_EXC_ERROR;
1368         ELSE
1369           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 5589409, pmarada
1370              log_msg('Organization Id : ' || x_header_rec.organization_id );
1371           END IF;
1372         END IF;
1373     ELSE
1374           add_header_to_error_stack(p_header_rec);
1375           FND_MESSAGE.SET_NAME('GMF','GMF_API_ORGANIZATION_ID_REQ');
1376           FND_MSG_PUB.Add;
1377           RAISE FND_API.G_EXC_ERROR;
1378     END IF;
1379     -- End organization validation
1380     -------------------
1381     -- Item Validation
1382     -------------------
1383     -- Use inventory item_id if sent otherwise use item_number
1384     -- If both are sent then use only item_id and ignore other params and log a message
1385     -- If both are not sent then raise error.
1386     --
1387     IF (p_header_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
1388        (p_header_rec.inventory_item_id IS NOT NULL)  THEN
1389         -- validate inventory_item_id
1390         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN
1391            log_msg('validating inventory_item_id : ' || p_header_rec.inventory_item_id);
1392         END IF;
1393          x_header_rec.organization_id := nvl(p_header_rec.organization_id,x_header_rec.organization_id) ;
1394         IF NOT GMF_VALIDATIONS_PVT.Validate_inventory_item_Id(p_header_rec.inventory_item_id, x_header_rec.organization_id)
1395         THEN
1396           add_header_to_error_stack(p_header_rec); -- Bug 2659435
1397           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_ID');
1398           FND_MESSAGE.SET_TOKEN('ITEM_ID',p_header_rec.inventory_item_id);
1399           FND_MSG_PUB.Add;
1400           RAISE FND_API.G_EXC_ERROR;
1401         END IF;
1402         -- Log message if item_number is also passed
1403         IF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND
1404            (p_header_rec.item_number IS NOT NULL) THEN
1405           IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
1406                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1407                 FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_ITEM_NO');
1408                 FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
1409                 FND_MSG_PUB.Add;
1410           END IF;
1411         END IF;
1412     ELSIF (p_header_rec.item_number <> FND_API.G_MISS_CHAR) AND
1413           (p_header_rec.item_number IS NOT NULL)  THEN
1414         -- Convert item number value into item ID.
1415         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1416            log_msg('validating item_number : ' || p_header_rec.item_number);
1417         END IF;
1418           -- If Organization id is passed as null then assign the derived organization id
1419           x_header_rec.organization_id := nvl(p_header_rec.organization_id,x_header_rec.organization_id) ;
1420           x_header_rec.inventory_item_id :=GMF_VALIDATIONS_PVT.Validate_Item_Number(p_header_rec.item_number, x_header_rec.organization_id);
1421         IF x_header_rec.inventory_item_id IS NULL THEN       -- item_Id fetch was not successful
1422           -- Conversion failed.
1423           add_header_to_error_stack(p_header_rec); -- Bug 2659435
1424           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_NO');
1425           FND_MESSAGE.SET_TOKEN('ITEM_NO',p_header_rec.item_number);
1426           FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',x_header_rec.organization_id);
1427           FND_MSG_PUB.Add;
1428           RAISE FND_API.G_EXC_ERROR;
1429         ELSE
1430           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1431              log_msg('inventory_item_id : ' || x_header_rec.inventory_item_id );
1432           END IF;
1433         END IF;
1434     ELSE
1435         add_header_to_error_stack(p_header_rec); -- Bug 2659435
1436         FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_ID_REQ');
1437         FND_MSG_PUB.Add;
1438         RAISE FND_API.G_EXC_ERROR;
1439     END IF;
1440     -- End Item validation
1441 
1442     -- Bug 7513552 Now Item Org is valid fetch UOM No need to handle exception
1443 
1444      SELECT Primary_uom_code INTO l_act_item_uom
1445      FROM mtl_system_items_b
1446      WHERE inventory_item_id = nvl(p_header_rec.inventory_item_id,x_header_rec.inventory_item_id)
1447        AND organization_id = nvl(p_header_rec.organization_id,x_header_rec.organization_id);
1448 
1449 
1450     -------------------
1451     -- Cost Method Code
1452     -------------------
1453     IF (p_header_rec.cost_type_id <> FND_API.G_MISS_NUM)
1454     AND (p_header_rec.cost_type_id IS NOT NULL)
1455     THEN
1456          IF (FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level) THEN
1457            log_msg('Validating Cost type Id : ' || p_header_rec.cost_type_id);
1458          END IF;
1459          --validate cost type id
1460          -- cost type id should be standard or actual cost type because this API is for Standard and actual cost
1461          -- overheads only. So Call Validate_Lot_Cost_type_id to verify the cost type is lot cost type or not.
1462          -- If it is lot cost type id then log error message as invalid cost type
1463       IF GMF_VALIDATIONS_PVT.Validate_Lot_Cost_type_id(p_header_rec.cost_type_id) THEN
1464         add_header_to_error_stack(p_header_rec);
1465         FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE_ID');
1466         FND_MESSAGE.SET_TOKEN('COST_TYPE_ID',p_header_rec.cost_type_id);
1467         FND_MSG_PUB.Add;
1468         RAISE FND_API.G_EXC_ERROR;
1469       END IF;
1470       -- log a message to ignore if cost method code also passed
1471       IF (p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.cost_mthd_code IS NOT NULL) THEN
1472          IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS)   THEN
1473             FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_COST_TYPE');
1474             FND_MESSAGE.SET_TOKEN('COST_TYPE', p_header_rec.cost_mthd_code);
1475             FND_MSG_PUB.Add;
1476           END IF;
1477       END IF;
1478       -- If cost type code is passed then derive the cost type id
1479     ELSE
1480       IF (p_header_rec.cost_mthd_code <> FND_API.G_MISS_CHAR)
1481       AND (p_header_rec.cost_mthd_code IS NOT NULL)
1482       THEN
1483          IF (FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level) THEN
1484            log_msg('Validating Cost type code : ' || p_header_rec.cost_mthd_code);
1485          END IF;
1486           -- Call validate cost type
1487          x_header_rec.cost_Type_id := GMF_VALIDATIONS_PVT.Validate_Cost_type_Code(p_header_rec.cost_mthd_code);
1488           -- call validate lot cost type.. if it is lot cost type then log an error
1489           -- because overheads will be created for actual and standard costs
1490          l_lc_cost_type_id := GMF_VALIDATIONS_PVT.Validate_Lot_Cost_Type(p_header_rec.cost_mthd_code);
1491          --If cost type id is null or cost type is lot cost type then log invalid cost type message
1492          IF (x_header_rec.cost_Type_id IS NULL)
1493              OR (l_lc_cost_type_id IS NOT NULL ) THEN
1494             add_header_to_error_stack(p_header_rec);
1495             FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_COST_TYPE');
1496             FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header_rec.cost_mthd_code);
1497             FND_MSG_PUB.Add;
1498             RAISE FND_API.G_EXC_ERROR;
1499          ELSE
1500           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 5589409, pmarada
1501              log_msg('Cost Type Id : ' || x_header_rec.cost_Type_id );
1502           END IF;
1503         END IF;
1504       ELSE
1505         add_header_to_error_stack(p_header_rec);
1506         FND_MESSAGE.SET_NAME('GMF','GMF_API_COST_TYPE_ID_REQ');
1507         FND_MSG_PUB.Add;
1508         RAISE FND_API.G_EXC_ERROR;
1509       END IF;
1510     END IF;
1511     -- End Cost Method Code
1512 
1513     ------------------------
1514     -- Period Id validation
1515     ------------------------
1516     IF (p_header_rec.period_id <> FND_API.G_MISS_NUM) AND (p_header_rec.period_id IS NOT NULL)
1517     THEN
1518         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level  THEN
1519           log_msg('validating Period Id : ' || p_header_rec.period_id);
1520         END IF;
1521         -- validate period id
1522        IF NOT GMF_VALIDATIONS_PVT.Validate_period_id(p_header_rec.period_id)
1523        THEN
1524         add_header_to_error_stack(p_header_rec);
1525         FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_PERIOD_ID');
1526         FND_MESSAGE.SET_TOKEN('PERIOD_ID',p_header_rec.period_id);
1527         FND_MSG_PUB.Add;
1528         RAISE FND_API.G_EXC_ERROR;
1529       END IF;
1530        -- If period code also passed then ignore period code
1531       IF ((p_header_rec.calendar_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.calendar_code IS NOT NULL))
1532          AND ((p_header_rec.period_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.period_code IS NOT NULL)) THEN
1533         IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
1534            FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_PERIOD_CODE');
1535            FND_MESSAGE.SET_TOKEN('CALENDAR_CODE', p_header_rec.calendar_code);
1536            FND_MESSAGE.SET_TOKEN('PERIOD_CODE', p_header_rec.period_code);
1537            FND_MSG_PUB.Add;
1538          END IF;
1539       END IF;
1540     ELSE
1541           -- period code and calendar code are passed instead of period id
1542       IF ((p_header_rec.calendar_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.calendar_code IS NOT NULL))
1543       AND ((p_header_rec.period_code <> FND_API.G_MISS_CHAR) AND (p_header_rec.period_code IS NOT NULL))
1544       THEN
1545          IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level  THEN
1546            log_msg('Validating Calendar Code : '|| p_header_rec.Calendar_code||' period_code : ' || p_header_rec.period_code);
1547         END IF;
1548         -- if cost type id passed as null then  assign derived cost type id to the record
1549         -- and pass the derived cost type id for derving to period id
1550 
1551         x_header_rec.cost_type_id := nvl(p_header_rec.cost_type_id,x_header_rec.cost_type_id) ;
1552         x_header_rec.organization_id := nvl(p_header_rec.organization_id,x_header_rec.organization_id) ;
1553 
1554         x_header_rec.period_id := GMF_VALIDATIONS_PVT.Validate_period_code(x_header_rec.organization_id, p_header_rec.calendar_code,p_header_rec.period_code,x_header_rec.cost_Type_id);
1555         IF x_header_rec.period_id IS NULL THEN
1556           add_header_to_error_stack(p_header_rec);
1557           FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CLDR_PERIOD');
1558           FND_MESSAGE.SET_TOKEN('CALENDAR_CODE',p_header_rec.calendar_code);
1559           FND_MESSAGE.SET_TOKEN('PERIOD_CODE',p_header_rec.period_code);
1560           FND_MSG_PUB.Add;
1561           RAISE FND_API.G_EXC_ERROR;
1562         ELSE
1563           IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 5589409, pmarada
1564              log_msg('Period Id : ' || x_header_rec.period_id );
1565           END IF;
1566         END IF;
1567       ELSE
1568         add_header_to_error_stack(p_header_rec);
1569         FND_MESSAGE.SET_NAME('GMF','GMF_API_PERIOD_ID_REQ');
1570         FND_MSG_PUB.Add;
1571         RAISE FND_API.G_EXC_ERROR;
1572       END IF;
1573     END IF;
1574 
1575     -- Note: period Code
1576     -- No need to bother about Frozen and Closed Periods. Screen allows insert
1577     -- and updates even of period is Frozen and Closed.
1578     --
1579 
1580     -- Populate WHO columns
1581     IF (p_header_rec.user_name <> FND_API.G_MISS_CHAR) AND
1582        (p_header_rec.user_name IS NOT NULL)  THEN
1583        IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1584          log_msg('Validating user name : ' || p_header_rec.user_name);
1585        END IF;
1586             GMA_GLOBAL_GRP.Get_who( p_user_name  => p_header_rec.user_name
1587                                   , x_user_id    => x_user_id
1588                                   );
1589 
1590             IF x_user_id = -1 THEN      -- Bug 2681243: GMA changed return status value to -1.
1591                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1592                 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_USER_NAME');
1593                 FND_MESSAGE.SET_TOKEN('USER_NAME',p_header_rec.user_name);
1594                 FND_MSG_PUB.Add;
1595                 RAISE FND_API.G_EXC_ERROR;
1596             END IF;
1597 
1598     ELSE
1599         add_header_to_error_stack(p_header_rec); -- Bug 2659435
1600         FND_MESSAGE.SET_NAME('GMF','GMF_API_USER_NAME_REQ');
1601         FND_MSG_PUB.Add;
1602         RAISE FND_API.G_EXC_ERROR;
1603     END IF;
1604     -- End User Name
1605 
1606     x_header_rec.organization_id   := nvl(p_header_rec.organization_id,x_header_rec.organization_id) ;
1607     x_header_rec.organization_code := p_header_rec.organization_code ;
1608     x_header_rec.inventory_item_id := nvl(p_header_rec.inventory_item_id,x_header_rec.inventory_item_id) ;
1609     x_header_rec.item_number       := p_header_rec.item_number ;
1610     x_header_rec.period_id         := nvl(p_header_rec.period_id,x_header_rec.period_id) ;
1611     x_header_rec.calendar_code     := p_header_rec.calendar_code ;
1612     x_header_rec.period_code       := p_header_rec.period_code ;
1613     x_header_rec.cost_type_id      := nvl(p_header_rec.cost_type_id,x_header_rec.cost_type_id) ;
1614     x_header_rec.cost_mthd_code    := p_header_rec.cost_mthd_code ;
1615     x_header_rec.user_name         := p_header_rec.user_name ;
1616 
1617     IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1618         log_msg( 'organization_id : '   || x_header_rec.organization_id ) ;
1619         log_msg( 'organization_code : ' || x_header_rec.organization_code ) ;
1620         log_msg( 'inventory_item_id : ' || x_header_rec.inventory_item_id ) ;
1621         log_msg( 'item_number : '    || x_header_rec.item_number ) ;
1622         log_msg( 'period_id : '      || x_header_rec.period_id ) ;
1623         log_msg( 'calendar_code : '  || x_header_rec.calendar_code ) ;
1624         log_msg( 'period_code : '    || x_header_rec.period_code ) ;
1625         log_msg( 'cost_type_id : '   || x_header_rec.cost_type_id ) ;
1626         log_msg( 'cost_mthd_code : ' ||x_header_rec.cost_mthd_code ) ;
1627         log_msg( 'user_name : '      || x_header_rec.user_name ) ;
1628     END IF;
1629 
1630     /* End of Validations on Header Record */
1631 
1632     /* Begin detail records validations */
1633     --------------------------------
1634     -- Validate Detail Records
1635     --------------------------------
1636 
1637     FOR i in 1..p_dtl_tbl.count
1638     LOOP
1639       BEGIN
1640 
1641         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1642                 log_msg('Record # : ' || i);
1643         END IF;
1644 
1645         -- initialize the local variables
1646         l_usage_ind            := NULL ;
1647         l_cost_cmpntcls_id     := NULL ;
1648         l_cost_cmpntcls_code   := NULL ;
1649         l_resource_uom         := NULL ;
1650         l_burden_uom_class     := NULL ;
1651         l_resource_uom_class   := NULL ;
1652         l_burdenline_id        := NULL ;
1653         l_burden_factor        := NULL ;
1654         l_converted_burden_qty := NULL ;
1655         l_converted_item_qty   := NULL ;
1656 
1657         -- Bug 2681243
1658         l_resources            := NULL ;
1659         l_burden_qty           := NULL ;
1660         l_burden_usage         := NULL ;
1661         l_burden_uom           := NULL ;
1662         l_item_qty             := NULL ;
1663         l_item_uom             := NULL ;
1664         --
1665         -- In case of delete,
1666         -- if burdenline_id is supplied skip all validations and use
1667         --   burdenline_id to delete the records
1668         -- If burdenline_id is not supplied then skip all validations
1669         --   except resource, cost_cmpntcls_id and analysis code
1670         --
1671         IF ((p_operation = 'DELETE') AND
1672             ((p_dtl_tbl(i).burdenline_id <> FND_API.G_MISS_NUM) OR (p_dtl_tbl(i).burdenline_id IS NOT NULL))
1673            ) THEN
1674           add_header_to_error_stack(p_header_rec); -- Bug 2659435
1675           FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_BRDN_UNIQUE_KEY');
1676           FND_MESSAGE.SET_TOKEN('OVERHEADLINE_ID', p_dtl_tbl(i).burdenline_id);
1677           FND_MSG_PUB.Add;
1678           l_burdenline_id := p_dtl_tbl(i).burdenline_id;
1679         ELSE
1680 
1681           --
1682           -- Bug# 2659435
1683           -- In case of update,
1684           -- if burdenline_id is supplied skip validations on columns
1685           --   of unique key i.e., cmpntcls and alys code
1686           -- If burdenline_id is not supplied then do all validations
1687           --
1688           -- Message is given before calling private API since it is
1689           -- appropriate place.
1690           --
1691           IF ((p_operation = 'UPDATE') AND
1692               ((p_dtl_tbl(i).burdenline_id <> FND_API.G_MISS_NUM) OR
1693                (p_dtl_tbl(i).burdenline_id IS NOT NULL))
1694              ) THEN
1695 
1696               l_burdenline_id := p_dtl_tbl(i).burdenline_id;
1697               --
1698               -- Bug 2681243: added new elsif block. For updates when burdenline_id is
1699               -- passed retrieve all burden details to use later in the program for
1700               -- UOM conversions.
1701               --
1702               BEGIN
1703                 SELECT resources, burden_qty, burden_usage, burden_uom, item_qty, item_uom
1704                   INTO l_resources, l_burden_qty, l_burden_usage, l_burden_uom, l_item_qty, l_item_uom
1705                   FROM cm_brdn_dtl
1706                  WHERE burdenline_id = l_burdenline_id;
1707 
1708               EXCEPTION
1709                 WHEN NO_DATA_FOUND THEN
1710                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1711                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_BRDN_LINE_ID');
1712                   FND_MESSAGE.SET_TOKEN('OVERHEADLINE_ID',p_dtl_tbl(i).burdenline_id);
1713                   FND_MSG_PUB.Add;
1714                   RAISE e_brdn_dtl;
1715               END;
1716 
1717               GMF_VALIDATIONS_PVT.Validate_Resource(l_resources, l_resource_uom, l_resource_uom_class) ;
1718 
1719               IF (l_resource_uom IS NULL) OR (l_resource_uom_class IS NULL) THEN
1720                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1721                 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_RESOURCES');
1722                 FND_MESSAGE.SET_TOKEN('RESOURCES',p_dtl_tbl(i).resources);
1723                 FND_MSG_PUB.Add;
1724                 RAISE e_brdn_dtl;
1725               END IF;
1726 
1727           ELSE
1728           -- End of Bug# 2659435
1729 
1730             ------------
1731             -- Resources
1732             ------------
1733              IF (p_dtl_tbl(i).resources <> FND_API.G_MISS_CHAR) AND
1734                (p_dtl_tbl(i).resources IS NOT NULL)  THEN
1735 
1736              IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1737                log_msg('validating resources : '|| p_dtl_tbl(i).resources);
1738              END IF;
1739 
1740               l_resources := p_dtl_tbl(i).resources;
1741 
1742               GMF_VALIDATIONS_PVT.Validate_Resource(l_resources, l_resource_uom, l_resource_uom_class) ;
1743               IF (l_resource_uom IS NULL) OR (l_resource_uom_class IS NULL) THEN
1744                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1745                 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_RESOURCES');
1746                 FND_MESSAGE.SET_TOKEN('RESOURCES',p_dtl_tbl(i).resources);
1747                 FND_MSG_PUB.Add;
1748                 RAISE e_brdn_dtl;
1749               END IF;
1750             ELSE
1751               add_header_to_error_stack(p_header_rec); -- Bug 2659435
1752               FND_MESSAGE.SET_NAME('GMF','GMF_API_RESOURCES_REQ');
1753               FND_MSG_PUB.Add;
1754               RAISE e_brdn_dtl;
1755             END IF;
1756 
1757             --------------
1758             -- CmpntCls Id
1759             --------------
1760             -- Use cmpntcls_id if sent otherwise use cmpntcls_code
1761             -- If both are sent then use only cmpntcls_id and ignore other params and log a message
1762             -- If both are not sent then raise error.
1763             --
1764             IF (p_dtl_tbl(i).cost_cmpntcls_id <> FND_API.G_MISS_NUM) AND
1765                (p_dtl_tbl(i).cost_cmpntcls_id IS NOT NULL)  THEN
1766                 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1767                         log_msg('validating Cmpt Cls ID('||i||') : '||
1768                                                      p_dtl_tbl(i).cost_cmpntcls_id);
1769                 END IF;
1770 
1771                 -- validate CmpntCls Id
1772                 GMF_VALIDATIONS_PVT.Validate_Cost_Cmpntcls_Id (p_dtl_tbl(i).cost_cmpntcls_id,l_cost_cmpntcls_code,l_usage_ind);
1773                 IF l_usage_ind IS NULL THEN
1774                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1775                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CMPNTCLS_ID');
1776                   FND_MESSAGE.SET_TOKEN('CMPNTCLS_ID',p_dtl_tbl(i).cost_cmpntcls_id);
1777                   FND_MSG_PUB.Add;
1778                   RAISE e_brdn_dtl;
1779                 ELSIF l_usage_ind <> 2 THEN
1780                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1781                   FND_MESSAGE.SET_NAME('GMF','GMF_API_CMPNTCLS_USG_NOT_BRDN');
1782                   FND_MESSAGE.SET_TOKEN('CMPNTCLS_ID',p_dtl_tbl(i).cost_cmpntcls_id);
1783                   FND_MSG_PUB.Add;
1784                   RAISE e_brdn_dtl;
1785                 END IF;
1786 
1787                 l_cost_cmpntcls_id := p_dtl_tbl(i).cost_cmpntcls_id ;
1788 
1789                 -- Log message if cost_cmpntcls_code is also passed
1790                 IF (p_dtl_tbl(i).cost_cmpntcls_code <> FND_API.G_MISS_CHAR) AND
1791                          (p_dtl_tbl(i).cost_cmpntcls_code IS NOT NULL)  THEN
1792                   IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_SUCCESS) THEN
1793                     add_header_to_error_stack(p_header_rec); -- Bug 2659435
1794                     FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_CMPNTCLS_CODE');
1795                     FND_MESSAGE.SET_TOKEN('CMPNTCLS_CODE',p_dtl_tbl(i).cost_cmpntcls_code);
1796                     FND_MSG_PUB.Add;
1797                   END IF;
1798                 END IF;
1799             ELSIF (p_dtl_tbl(i).cost_cmpntcls_code <> FND_API.G_MISS_CHAR) AND
1800                         (p_dtl_tbl(i).cost_cmpntcls_code IS NOT NULL)  THEN
1801                 l_cost_cmpntcls_code := p_dtl_tbl(i).cost_cmpntcls_code ;
1802 
1803                 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1804                         log_msg('validating Cmpt Cls Code('||i||') : ' ||
1805                                                          p_dtl_tbl(i).cost_cmpntcls_code);
1806 
1807                 END IF;
1808                 -- Convert value into ID.
1809                 GMF_VALIDATIONS_PVT.Validate_Cost_Cmpntcls_Code (
1810                                                                   p_dtl_tbl(i).cost_cmpntcls_code,
1811                                                                   l_cost_cmpntcls_id,
1812                                                                   l_usage_ind
1813                                                                 ) ;
1814                 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
1815                         log_msg('Cmpt Cls Id := ' || l_cost_cmpntcls_id);
1816                 END IF;
1817 
1818                 IF (l_cost_cmpntcls_id IS NULL) OR (l_usage_ind IS NULL) THEN
1819                   -- Conversion failed.
1820                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1821                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_CMPNTCLS_CODE');
1822                   FND_MESSAGE.SET_TOKEN('CMPNTCLS_CODE',p_dtl_tbl(i).cost_cmpntcls_code);
1823                   FND_MSG_PUB.Add;
1824                   RAISE e_brdn_dtl;
1825                 ELSIF l_usage_ind <> 2 THEN
1826                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1827                   FND_MESSAGE.SET_NAME('GMF','GMF_API_CMPNTCLS_USG_NOT_BRDN');
1828                   FND_MESSAGE.SET_TOKEN('CMPNTCLS_ID',l_cost_cmpntcls_id);
1829                   FND_MSG_PUB.Add;
1830                   RAISE e_brdn_dtl;
1831                 END IF;
1832             ELSE
1833                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
1834                 FND_MESSAGE.SET_NAME('GMF','GMF_API_CMPNTCLS_ID_REQ');
1835                 FND_MSG_PUB.Add;
1836                 RAISE e_brdn_dtl;
1837             END IF;
1838             -- End CmpntCls Id
1839 
1840             ----------------
1841             -- Analysis Code
1842             ----------------
1843             IF (p_dtl_tbl(i).cost_analysis_code <> FND_API.G_MISS_CHAR) AND
1844                      (p_dtl_tbl(i).cost_analysis_code IS NOT NULL)  THEN
1845 
1846                  IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1847                    log_msg('validating analysis_code('||i||') : ' || p_dtl_tbl(i).cost_analysis_code);
1848                  END IF;
1849                 IF NOT GMF_VALIDATIONS_PVT.Validate_Analysis_Code(p_dtl_tbl(i).cost_analysis_code)
1850                 THEN
1851                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1852                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ANALYSIS_CODE');
1853                   FND_MESSAGE.SET_TOKEN('ANALYSIS_CODE',p_dtl_tbl(i).cost_analysis_code);
1854                   FND_MSG_PUB.Add;
1855                   RAISE e_brdn_dtl;
1856                 END IF;
1857             ELSE
1858                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1859                   FND_MESSAGE.SET_NAME('GMF','GMF_API_ANALYSIS_CODE_REQ');
1860                   FND_MSG_PUB.Add;
1861                   RAISE e_brdn_dtl;
1862             END IF;
1863             -- End Analysis Code
1864 
1865             IF (p_operation = 'UPDATE') THEN
1866               --
1867               -- Bug 2681243: added new elsif block. For updates when burdenline_id is
1868               -- passed retrieve all burden details to use later in the program for
1869               -- UOM conversions.
1870               --
1871                BEGIN
1872                  SELECT resources, burden_qty, burden_usage, burden_uom, item_qty, item_uom
1873                    INTO l_resources, l_burden_qty, l_burden_usage, l_burden_uom, l_item_qty, l_item_uom
1874                    FROM
1875                          cm_brdn_dtl
1876                   WHERE
1877                          organization_id    = x_header_rec.organization_id
1878                     AND  inventory_item_id  = x_header_rec.inventory_item_id
1879                     AND  period_id          = x_header_rec.period_id
1880                     AND  cost_type_id       = x_header_rec.cost_type_id
1881                     AND  resources          = l_resources
1882                     AND  cost_cmpntcls_id   = l_cost_cmpntcls_id
1883                     AND  cost_analysis_code = p_dtl_tbl(i).cost_analysis_code ;
1884 
1885                EXCEPTION
1886                  WHEN NO_DATA_FOUND THEN
1887                    add_header_to_error_stack(p_header_rec);
1888                    FND_MESSAGE.SET_NAME('GMF','GMF_API_BRDN_DTL_NOT_FOUND');
1889                    FND_MESSAGE.SET_TOKEN('RESOURCE',l_resources);
1890                    FND_MESSAGE.SET_TOKEN('CMPNTCLS_CODE',p_dtl_tbl(i).cost_cmpntcls_code);
1891                    FND_MESSAGE.SET_TOKEN('CMPNTCLS_ID',l_cost_cmpntcls_id);
1892                    FND_MESSAGE.SET_TOKEN('ALYS_CODE',p_dtl_tbl(i).cost_analysis_code);
1893                    FND_MSG_PUB.Add;
1894                    RAISE e_brdn_dtl;
1895                END;
1896             END IF;
1897 
1898           END IF; -- Bug 2659435
1899 
1900 
1901           --
1902           -- Enough of validations for delete.
1903           -- For update and insert we should do all validations.
1904           --
1905           IF (p_operation <> 'DELETE') THEN
1906             --
1907             -- Burden Usage
1908             -- Burden Usage should be > 0
1909             -- In the form the format mask for this is : 999999999D999999999(999,999,999.999999999)
1910             -- To put that check here, the cost should not be >= 1,000,000,000
1911             --
1912             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1913                 log_msg('validating Burden Usage : '||p_dtl_tbl(i).burden_usage);
1914             END IF;
1915 
1916             IF (p_dtl_tbl(i).burden_usage <> FND_API.G_MISS_NUM) AND
1917                 (p_dtl_tbl(i).burden_usage IS NOT NULL)  THEN
1918 
1919               l_burden_usage := p_dtl_tbl(i).burden_usage; -- Bug 2681243
1920 
1921 
1922               /**********************************************************************
1923               * dvadivel Bug # 3314310 12-May-2004 Allowing negative burden_usage
1924               **********************************************************************/
1925               /*
1926               IF ((nvl(p_dtl_tbl(i).burden_usage,0) <= 0.000000001) OR
1927                   (nvl(p_dtl_tbl(i).burden_usage,0) >= 1000000000)) THEN
1928                  add_header_to_error_stack(p_header_rec); -- Bug 2659435
1929                  FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_BURDEN_USAGE');
1930                  FND_MESSAGE.SET_TOKEN('BURDEN_USAGE',p_dtl_tbl(i).burden_usage);
1931                  FND_MSG_PUB.Add;
1932                  RAISE e_brdn_dtl;
1933               END IF;
1934               */
1935 
1936             ELSIF (p_dtl_tbl(i).burden_usage = FND_API.G_MISS_NUM AND   -- Bug 2659435
1937                    p_operation = 'UPDATE') OR
1938                   (p_operation = 'INSERT') THEN
1939               add_header_to_error_stack(p_header_rec); -- Bug 2659435
1940               FND_MESSAGE.SET_NAME('GMF','GMF_API_BURDEN_USAGE_REQ');
1941               FND_MSG_PUB.Add;
1942               RAISE e_brdn_dtl;
1943             END IF;
1944             -- End Burden Usage
1945 
1946             ----------------
1947             -- Item Quantity
1948             ----------------
1949             -- Item Quantity should be > 0
1950             -- In the form the format mask for this is : 999999999D999999999(999,999,999.999999999)
1951             -- To put that check here, the cost should not be >= 1,000,000,000
1952             --
1953             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1954                 log_msg('validating Item Quantity : '||p_dtl_tbl(i).item_qty);
1955             END IF;
1956 
1957             IF (p_dtl_tbl(i).item_qty <> FND_API.G_MISS_NUM) AND
1958                 (p_dtl_tbl(i).item_qty IS NOT NULL)  THEN
1959 
1960               l_item_qty := p_dtl_tbl(i).item_qty; -- Bug 2681243
1961 
1962               IF ((nvl(p_dtl_tbl(i).item_qty,0) <= 0.000000001) OR
1963                   (nvl(p_dtl_tbl(i).item_qty,0) >= 1000000000)) THEN
1964                  add_header_to_error_stack(p_header_rec); -- Bug 2659435
1965                  FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_QTY');
1966                  FND_MESSAGE.SET_TOKEN('ITEM_QTY',p_dtl_tbl(i).item_qty);
1967                  FND_MSG_PUB.Add;
1968                  RAISE e_brdn_dtl;
1969               END IF;
1970             ELSIF (p_dtl_tbl(i).item_qty = FND_API.G_MISS_NUM AND       -- Bug 2659435
1971                    p_operation = 'UPDATE') OR
1972                   (p_operation = 'INSERT') THEN
1973               add_header_to_error_stack(p_header_rec); -- Bug 2659435
1974               FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_QTY_REQ');
1975               FND_MSG_PUB.Add;
1976               RAISE e_brdn_dtl;
1977             END IF;
1978             -- End Item Quantity
1979 
1980             -----------------------
1981             -- Item Unit of Measure
1982             -----------------------
1983             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
1984                 log_msg('validating item_uom : ' || p_dtl_tbl(i).item_uom);
1985             END IF;
1986 
1987             IF (p_dtl_tbl(i).item_uom <> FND_API.G_MISS_CHAR) AND
1988                (p_dtl_tbl(i).item_uom IS NOT NULL)  THEN
1989 
1990                 l_item_uom := p_dtl_tbl(i).item_uom; -- Bug 2681243
1991                 IF NOT GMF_VALIDATIONS_PVT.Validate_Usage_Uom(p_dtl_tbl(i).item_uom) THEN
1992                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
1993                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_ITEM_UM');
1994                   FND_MESSAGE.SET_TOKEN('ITEM_UOM',p_dtl_tbl(i).item_uom);
1995                   FND_MSG_PUB.Add;
1996                   RAISE e_brdn_dtl;
1997                 END IF;
1998 
1999             ELSIF (p_dtl_tbl(i).item_uom = FND_API.G_MISS_CHAR AND       -- Bug 2659435
2000                    p_operation = 'UPDATE') OR
2001                   (p_operation = 'INSERT') THEN
2002                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
2003                   FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_UM_REQ');
2004                   FND_MSG_PUB.Add;
2005                   RAISE e_brdn_dtl;
2006             END IF;
2007 
2008             --
2009             -- Bug 2681243: Only in case of insert or update with any one of
2010             -- other values is passed then do the conversion.
2011             --
2012             IF ((p_operation = 'INSERT') OR
2013                 ( (p_operation = 'UPDATE') AND
2014                   (p_dtl_tbl(i).burden_qty      IS NOT NULL OR
2015                    p_dtl_tbl(i).burden_usage    IS NOT NULL OR
2016                    p_dtl_tbl(i).burden_uom      IS NOT NULL OR
2017                    p_dtl_tbl(i).item_qty        IS NOT NULL OR
2018                    p_dtl_tbl(i).item_uom        IS NOT NULL)
2019                 )
2020                ) THEN
2021 
2022                -- Convert item quantity actual item UOM
2023                IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN -- Bug 2659435
2024                        log_msg('Converting Item Qty ' || l_item_qty ||
2025                        ' from UOM ' || l_item_uom || ' to UOM ' || l_act_item_uom ||
2026                        ' for Item_Id : ' || x_header_rec.inventory_item_id);
2027                END IF;
2028 
2029                BEGIN
2030                l_converted_item_qty :=inv_convert.inv_um_convert
2031                                       (item_id       => x_header_rec.inventory_item_id,
2032                                        precision     => 5,           -- precision 5
2033                                        from_quantity => l_item_qty,  -- initial item qty to convert
2034                                        from_unit     => l_item_uom,     -- initial UOM to convert
2035                                        to_unit       => l_act_item_uom, -- initial Burden UOM to convert from
2036                                        from_name     => NULL,
2037                                        to_name       => NULL);
2038 
2039                  -- Bug 7513552 Inform user incase there are any conversion issues as well.
2040                  IF l_converted_item_qty = -99999 THEN
2041                    RAISE e_brdn_dtl;
2042                  End IF;
2043 
2044                  IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN       -- Bug 2659435
2045                        log_msg('Converted Item Qty : ' || l_converted_item_qty);
2046                  END IF;
2047 
2048                EXCEPTION
2049                  WHEN OTHERS THEN
2050                    add_header_to_error_stack(p_header_rec); -- Bug 2659435
2051                    FND_MESSAGE.SET_NAME('GMF','GMF_API_ITEM_UM_CONV_ERR');
2052                    FND_MESSAGE.SET_TOKEN('ITEM_ID', x_header_rec.inventory_item_id); --p_header_rec.item_id); Bug# 1935297
2053                    FND_MESSAGE.SET_TOKEN('ITEM_UM',l_item_uom);
2054                    FND_MESSAGE.SET_TOKEN('ITEM_ACT_UM',l_act_item_uom);
2055                    FND_MSG_PUB.Add;
2056                    RAISE e_brdn_dtl;
2057                END ;
2058             END IF ;
2059             -- End Item Unit of Measure
2060 
2061             ------------------
2062             -- Burden Quantity
2063             ------------------
2064             -- Burden Quantity should be > 0
2065             -- In the form the format mask for this is : 999999999D999999999(999,999,999.999999999)
2066             -- To put that check here, the cost should not be >= 1,000,000,000
2067             --
2068             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
2069                 log_msg('validating Burden Quantity : '||p_dtl_tbl(i).burden_qty);
2070             END IF;
2071 
2072             IF (p_dtl_tbl(i).burden_qty <> FND_API.G_MISS_NUM) AND
2073                (p_dtl_tbl(i).burden_qty IS NOT NULL)  THEN
2074 
2075               l_burden_qty := p_dtl_tbl(i).burden_qty; -- Bug 2681243
2076               IF ((nvl(p_dtl_tbl(i).burden_qty,0) <= 0.000000001) OR
2077                   (nvl(p_dtl_tbl(i).burden_qty,0) >= 1000000000)) THEN
2078                  add_header_to_error_stack(p_header_rec); -- Bug 2659435
2079                  FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_BURDEN_QTY');
2080                  FND_MESSAGE.SET_TOKEN('OVERHEAD_QTY',p_dtl_tbl(i).burden_qty);
2081                  FND_MSG_PUB.Add;
2082                  RAISE e_brdn_dtl;
2083               END IF;
2084             ELSIF (p_dtl_tbl(i).burden_qty = FND_API.G_MISS_NUM AND     -- Bug 2659435
2085                    p_operation = 'UPDATE') OR
2086                   (p_operation = 'INSERT') THEN
2087               add_header_to_error_stack(p_header_rec); -- Bug 2659435
2088               FND_MESSAGE.SET_NAME('GMF','GMF_API_BURDEN_QTY_REQ');
2089               FND_MSG_PUB.Add;
2090               RAISE e_brdn_dtl;
2091             END IF;
2092             -- End Burden Quantity
2093 
2094             --------------------------
2095             -- Burden Unit of Measure
2096             --------------------------
2097             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
2098                 log_msg('validating burden_uom : ' || p_dtl_tbl(i).burden_uom);
2099             END IF;
2100 
2101             IF (p_dtl_tbl(i).burden_uom <> FND_API.G_MISS_CHAR) AND
2102                (p_dtl_tbl(i).burden_uom IS NOT NULL)  THEN
2103 
2104                 l_burden_uom := p_dtl_tbl(i).burden_uom; -- Bug 2681243
2105                 GMF_VALIDATIONS_PVT.Validate_Usage_Uom(p_dtl_tbl(i).burden_uom, l_burden_uom_class) ;
2106                 IF l_burden_uom_class IS NULL THEN
2107                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
2108                   FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_BURDEN_UM');
2109                   FND_MESSAGE.SET_TOKEN('OVERHEAD_UM',p_dtl_tbl(i).burden_uom);
2110                   FND_MSG_PUB.Add;
2111                   RAISE e_brdn_dtl;
2112                 END IF;
2113 
2114                 IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
2115                    log_msg('Burden UOM Class : ' || l_burden_uom_class || ' resource UOM Class : ' || l_resource_uom_class);
2116                 END IF;
2117 
2118                 -- Burden UOM must be of the same type as the resource UOM
2119                 IF (l_resource_uom_class <> l_burden_uom_class) THEN
2120                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
2121                   FND_MESSAGE.SET_NAME('GMF','GMF_API_UOM_SAMETYPE_REQ');
2122                   FND_MESSAGE.SET_TOKEN('OVERHEAD_UM',p_dtl_tbl(i).burden_uom);
2123                   FND_MESSAGE.SET_TOKEN('RESOURCE_UM',l_resource_uom_class);
2124                   FND_MSG_PUB.Add;
2125                   RAISE e_brdn_dtl;
2126                 END IF;
2127             ELSIF (p_dtl_tbl(i).burden_uom = FND_API.G_MISS_CHAR AND     -- Bug 2659435
2128                    p_operation = 'UPDATE') OR
2129                   (p_operation = 'INSERT') THEN
2130                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
2131                   FND_MESSAGE.SET_NAME('GMF','GMF_API_BURDEN_UM_REQ');
2132                   FND_MSG_PUB.Add;
2133                   RAISE e_brdn_dtl;
2134             END IF;
2135             -- End Burden Unit of Measure
2136 
2137             --
2138             -- Calculate burden factor
2139             -- If converted item qty is zero then burden_factor = 0 else
2140             -- first convert burden usage to resource uom, then use converted qty to get burden factor
2141             --
2142             IF (l_converted_item_qty  IS NOT NULL) AND   -- Bug 2681243
2143                (l_converted_item_qty = 0) THEN
2144 
2145                 l_burden_factor := 0 ;
2146 
2147             ELSIF l_converted_item_qty  IS NOT NULL THEN
2148 
2149                 -- Convert burden usage to resource uom.
2150                 BEGIN
2151                   IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN      -- Bug 2659435
2152                         log_msg( 'Converting Brdn Usage ' || l_burden_usage ||
2153                           ' from UOM ' || l_burden_uom || ' to UOM ' || l_resource_uom);
2154                   END IF;
2155                   l_converted_burden_qty :=inv_convert.inv_um_convert
2156                                            (item_id       => 0,         -- here item is not required
2157                                             precision     => 5,         -- precision 5
2158                                             from_quantity => l_burden_usage,  -- initial qty to convert
2159                                             from_unit     => l_burden_uom,    -- initial qty to convert
2160                                             to_unit       => l_resource_uom,  -- initial Burden UOM to convert from
2161                                             from_name     => NULL,
2162                                             to_name       => NULL);
2163                   IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN      -- Bug 2659435
2164                         log_msg('Converted Burden Usage : ' || l_converted_burden_qty);
2165                   END IF;
2166 
2167                   l_burden_factor := ROUND( (l_converted_burden_qty / l_converted_item_qty) * l_burden_qty, 9 );
2168 
2169                   IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN      -- Bug 2659435
2170                         log_msg('Burden Factor : ' || l_burden_factor);
2171                   END IF;
2172 
2173                 EXCEPTION
2174                   WHEN OTHERS THEN
2175                     add_header_to_error_stack(p_header_rec); -- Bug 2659435
2176                     FND_MESSAGE.SET_NAME('GMF','GMF_API_BRDN_UM_CONV_ERR');
2177                     FND_MESSAGE.SET_TOKEN('RESOURCES',l_resources);  -- Bug 2681243: use local variable.
2178                     FND_MESSAGE.SET_TOKEN('OVERHEAD_UM',l_burden_uom);
2179                     FND_MESSAGE.SET_TOKEN('RESOURCE_UM',l_resource_uom);
2180                     FND_MSG_PUB.Add;
2181                     RAISE e_brdn_dtl;
2182                 END ;
2183             END IF;
2184 
2185             --------------
2186             -- Delete Mark
2187             --------------
2188             IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN    -- Bug 2659435
2189                 log_msg('validating delete_mark('||i||') :' ||
2190                                                  p_dtl_tbl(i).delete_mark);
2191             END IF;
2192 
2193             IF (p_dtl_tbl(i).delete_mark <> FND_API.G_MISS_NUM) AND
2194                (p_dtl_tbl(i).delete_mark IS NOT NULL)  THEN
2195               IF p_dtl_tbl(i).delete_mark NOT IN (0,1) THEN
2196                 add_header_to_error_stack(p_header_rec); -- Bug 2659435
2197                 FND_MESSAGE.SET_NAME('GMF','GMF_API_INVALID_DELETE_MARK');
2198                 FND_MESSAGE.SET_TOKEN('DELETE_MARK',p_dtl_tbl(i).delete_mark);
2199                 FND_MSG_PUB.Add;
2200                 RAISE e_brdn_dtl;
2201               END IF;
2202             ELSIF (p_dtl_tbl(i).delete_mark = FND_API.G_MISS_NUM AND    -- Bug 2659435
2203                    p_operation = 'UPDATE') OR
2204                   (p_operation = 'INSERT') THEN
2205                   add_header_to_error_stack(p_header_rec); -- Bug 2659435
2206                   FND_MESSAGE.SET_NAME('GMF','GMF_API_DELETE_MARK_REQ');
2207                   FND_MSG_PUB.Add;
2208                   RAISE e_brdn_dtl;
2209             END IF;
2210             IF ((p_operation = 'UPDATE') AND (p_dtl_tbl(i).delete_mark = 1)) THEN
2211               add_header_to_error_stack(p_header_rec); -- Bug 2659435
2212               FND_MESSAGE.SET_NAME('GMF','GMF_API_CANT_MARK_FOR_PURGE');
2213               FND_MSG_PUB.Add;
2214               RAISE e_brdn_dtl;
2215             END IF;
2216             -- End Delete Mark
2217 
2218           END IF ;  -- check for delete to eliminate unneccessary validations.
2219 
2220      /* End of detail records validations */
2221 
2222           --
2223           -- Ignore unique key combination if burdenline_id is supplied. If not supplied then
2224           -- use unique key combination to update/delete the record.
2225           -- Private API check uses burdenline_id if supplied else uses unique key combination
2226           --
2227           IF ((p_operation = 'UPDATE') AND
2228               ((p_dtl_tbl(i).burdenline_id <> FND_API.G_MISS_NUM) OR (p_dtl_tbl(i).burdenline_id IS NOT NULL))
2229              ) THEN
2230             add_header_to_error_stack(p_header_rec); -- Bug 2659435
2231             FND_MESSAGE.SET_NAME('GMF','GMF_API_IGNORE_BRDN_UNIQUE_KEY');
2232             FND_MESSAGE.SET_TOKEN('OVERHEADLINE_ID', p_dtl_tbl(i).burdenline_id);
2233             FND_MSG_PUB.Add;
2234             l_burdenline_id := p_dtl_tbl(i).burdenline_id;
2235           END IF ;
2236 
2237         END IF ; -- Main if(after for loop stmt) to check for delete operation and check for burdenline_id.
2238 
2239         l_idx := l_idx + 1 ;
2240         x_dtl_tbl(l_idx).burdenline_id       := l_burdenline_id ;
2241         x_dtl_tbl(l_idx).resources           := l_resources ;
2242         x_dtl_tbl(l_idx).cost_cmpntcls_id    := nvl(p_dtl_tbl(i).cost_cmpntcls_id,l_cost_cmpntcls_id);
2243         x_dtl_tbl(l_idx).cost_cmpntcls_code  := nvl(p_dtl_tbl(i).cost_cmpntcls_code,l_cost_cmpntcls_code) ;
2244         x_dtl_tbl(l_idx).cost_analysis_code  := p_dtl_tbl(i).cost_analysis_code ;
2245         x_dtl_tbl(l_idx).burden_usage        := p_dtl_tbl(i).burden_usage ;
2246         x_dtl_tbl(l_idx).item_qty            := p_dtl_tbl(i).item_qty ;
2247         x_dtl_tbl(l_idx).item_uom            := p_dtl_tbl(i).item_uom ;
2248         x_dtl_tbl(l_idx).burden_qty          := p_dtl_tbl(i).burden_qty ;
2249         x_dtl_tbl(l_idx).burden_uom          := p_dtl_tbl(i).burden_uom ;
2250         IF p_operation in ('INSERT', 'UPDATE') THEN
2251           x_dtl_tbl(l_idx).delete_mark       := 0 ;
2252         ELSE
2253           x_dtl_tbl(l_idx).delete_mark       := 1 ;
2254         END IF ;
2255         x_brdn_factor_tbl(l_idx).burden_factor:= l_burden_factor ;
2256 
2257         IF FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW >= G_Debug_Level THEN        -- Bug 2659435
2258           log_msg('x_burdenline_id('||l_idx||'): '||x_dtl_tbl(l_idx).burdenline_id);
2259           log_msg('x_resources('||l_idx||'): '||x_dtl_tbl(l_idx).resources);
2260           log_msg('x_cost_cmpntcls_id('||l_idx||'): '||x_dtl_tbl(l_idx).cost_cmpntcls_id);
2261           log_msg('x_cost_cmpntcls_code('||l_idx||'): '|| x_dtl_tbl(l_idx).cost_cmpntcls_code)  ;
2262           log_msg('x_cost_analysis_code('||l_idx||'): '|| x_dtl_tbl(l_idx).cost_analysis_code)  ;
2263           log_msg('x_burden_usage('||l_idx||'): '||x_dtl_tbl(l_idx).burden_usage);
2264           log_msg('x_item_qty('||l_idx||'): '||x_dtl_tbl(l_idx).item_qty);
2265           log_msg('x_item_uom('||l_idx||'): '||x_dtl_tbl(l_idx).item_uom);
2266           log_msg('x_burden_qty('||l_idx||'): '||x_dtl_tbl(l_idx).burden_qty);
2267           log_msg('x_burden_uom('||l_idx||'): '||x_dtl_tbl(l_idx).burden_uom);
2268           log_msg('x_brdn_factor('||l_idx||'): '||x_brdn_factor_tbl(l_idx).burden_factor);
2269           log_msg('x_delete_mark('||l_idx||'): '||x_dtl_tbl(l_idx).delete_mark);
2270         END IF;
2271 
2272       EXCEPTION
2273         WHEN e_brdn_dtl THEN
2274          RAISE FND_API.G_EXC_ERROR;
2275       END ;
2276     END LOOP;
2277 
2278 EXCEPTION       -- Bug 2681243: removed when others to capture ORA errors.
2279     WHEN FND_API.G_EXC_ERROR THEN
2280         x_return_status := FND_API.G_RET_STS_ERROR ;
2281     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2282         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2283 END Validate_Input_Params ;
2284 --
2285 -- Func start of comments
2286 --+==========================================================================+
2287 --|  Procedure Name                                                          |
2288 --|       log_msg                                                            |
2289 --|                                                                          |
2290 --|  DESCRIPTION                                                             |
2291 --|       This procedure logs messages to message stack.                     |
2292 --|                                                                          |
2293 --|  PARAMETERS                                                              |
2294 --|       p_msg_lvl             IN NUMBER(10) - Message Level                |
2295 --|       p_msg_text            IN NUMBER(10) - Actual Message Text          |
2296 --|                                                                          |
2297 --|  RETURNS                                                                 |
2298 --|                                                                          |
2299 --|  HISTORY                                                                 |
2300 --|       27/02/2001 Uday Moogla - Created                                   |
2301 --|       05/nov/2002 Uday Moogala Bug 2659435                               |
2302 --|         Removed first param for debug level                              |
2303 --|                                                                          |
2304 --+==========================================================================+
2305 -- Func end of comments
2306 
2307 PROCEDURE log_msg
2308 (
2309 p_msg_text      IN VARCHAR2
2310 )
2311 IS
2312 BEGIN
2313 
2314   -- IF FND_MSG_PUB.Check_Msg_Level (p_msg_lvl) THEN    -- Bug 2659435
2315     FND_MESSAGE.SET_NAME('GMF','GMF_API_DEBUG');
2316     FND_MESSAGE.SET_TOKEN('MSG',p_msg_text);
2317     FND_MSG_PUB.Add;
2318   -- END IF;
2319 
2320 END log_msg ;
2321 
2322 -- Func start of comments
2323 --+==========================================================================+
2324 --|  Procedure Name                                                          |
2325 --|       add_header_to_error_stack                                          |
2326 --|                                                                          |
2327 --|  DESCRIPTION                                                             |
2328 --|       This procedure logs header to message stack.                       |
2329 --|                                                                          |
2330 --|  PARAMETERS                                                              |
2331 --|       p_header            Header Record to be logged                     |
2332 --|                                                                          |
2333 --|  RETURNS                                                                 |
2334 --|                                                                          |
2335 --|  HISTORY                                                                 |
2336 --|       05/11/2001 Uday Moogla - Created Bug 2659435                       |
2337 --|                                                                          |
2338 --+==========================================================================+
2339 -- Func end of comments
2340 
2341 PROCEDURE add_header_to_error_stack
2342 (
2343  p_header       Burden_Header_Rec_Type
2344 )
2345 IS
2346 BEGIN
2347 
2348   IF G_header_logged = 'N' THEN
2349     G_header_logged := 'Y';
2350     FND_MESSAGE.SET_NAME('GMF','GMF_API_BURDEN_HEADER');
2351     FND_MESSAGE.SET_TOKEN('ORGANIZATION_ID',p_header.organization_id);
2352     FND_MESSAGE.SET_TOKEN('ORGANIZATION_CODE',p_header.organization_code);
2353     FND_MESSAGE.SET_TOKEN('INVENTORY_ITEM_ID',p_header.inventory_item_id);
2354     FND_MESSAGE.SET_TOKEN('ITEM_NUMBER',p_header.item_number);
2355     FND_MESSAGE.SET_TOKEN('PERIOD_ID',p_header.period_id);
2356     FND_MESSAGE.SET_TOKEN('CALENDAR',p_header.calendar_code);
2357     FND_MESSAGE.SET_TOKEN('PERIOD_CODE',p_header.period_code);
2358     FND_MESSAGE.SET_TOKEN('COSTTYPE_ID',p_header.cost_type_id);
2359     FND_MESSAGE.SET_TOKEN('COST_TYPE',p_header.cost_mthd_code);
2360     FND_MSG_PUB.Add;
2361   END IF;
2362 
2363 END add_header_to_error_stack;
2364 
2365 END GMF_BurdenDetails_PUB;