DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGC_CC_ACCT_LINES_PKG

Source


1 PACKAGE BODY IGC_CC_ACCT_LINES_PKG as
2 /* $Header: IGCCACLB.pls 120.6.12000000.4 2007/10/19 06:55:31 smannava ship $  */
3 
4    G_PKG_NAME CONSTANT VARCHAR2(30):= 'IGC_CC_ACCT_LINES_PKG';
5    g_debug_flag        VARCHAR2(1) := 'N' ;
6    g_debug_msg         VARCHAR2(10000) := NULL;
7 
8 --   g_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.VALUE('IGC_DEBUG_ENABLED'),'N');
9    g_debug_mode        VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
10 
11 -- Variables for ATG central logging
12   g_debug_level       NUMBER	:=	FND_LOG.G_CURRENT_RUNTIME_LEVEL;
13   g_state_level       NUMBER	:=	FND_LOG.LEVEL_STATEMENT;
14   g_proc_level        NUMBER	:=	FND_LOG.LEVEL_PROCEDURE;
15   g_event_level       NUMBER	:=	FND_LOG.LEVEL_EVENT;
16   g_excep_level       NUMBER	:=	FND_LOG.LEVEL_EXCEPTION;
17   g_error_level       NUMBER	:=	FND_LOG.LEVEL_ERROR;
18   g_unexp_level       NUMBER	:=	FND_LOG.LEVEL_UNEXPECTED;
19   g_path              VARCHAR2(255) := 'IGC.PLSQL.IGCCACLB.IGC_CC_ACCT_LINES_PKG.';
20 
21 /* ================================================================================
22                          PROCEDURE Output_Debug
23    ===============================================================================*/
24 
25 PROCEDURE Output_Debug (
26    p_path           IN VARCHAR2,
27    p_debug_msg      IN VARCHAR2
28 ) IS
29 
30 -- --------------------------------------------------------------------
31 -- Local Variables :
32 -- --------------------------------------------------------------------
33    /*l_prod             VARCHAR2(3)           := 'IGC';
34    l_sub_comp         VARCHAR2(8)           := 'CC_ACLB';
35    l_profile_name     VARCHAR2(255)         := 'IGC_DEBUG_LOG_DIRECTORY';
36    l_Return_Status    VARCHAR2(1);*/
37    l_api_name         CONSTANT VARCHAR2(30) := 'Output_Debug';
38 
39 BEGIN
40 
41    /*IGC_MSGS_PKG.Put_Debug_Msg (p_debug_message    => p_debug_msg,
42                                p_profile_log_name => l_profile_name,
43                                p_prod             => l_prod,
44                                p_sub_comp         => l_sub_comp,
45                                p_filename_val     => NULL,
46                                x_Return_Status    => l_Return_Status
47                               );
48 
49    IF (l_Return_Status <> FND_API.G_RET_STS_SUCCESS) THEN
50       raise FND_API.G_EXC_ERROR;
51    END IF;*/
52 
53    IF(g_state_level >= g_debug_level) THEN
54         FND_LOG.STRING(g_state_level, p_path, p_debug_msg);
55    END IF;
56 
57    RETURN;
58 
59 -- --------------------------------------------------------------------
60 -- Exception handler section for the Output_Debug procedure.
61 -- --------------------------------------------------------------------
62 EXCEPTION
63 
64    /*WHEN FND_API.G_EXC_ERROR THEN
65        RETURN;*/
66 
67    WHEN OTHERS THEN
68        IF (FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)) THEN
69           FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME, l_api_name);
70        END IF;
71        NULL;
72        RETURN;
73 
74 END Output_Debug;
75 
76 /* ================================================================================
77                          PROCEDURE Insert_Row
78    ===============================================================================*/
79 
80 PROCEDURE Insert_Row(
81    p_api_version               IN    NUMBER,
82    p_init_msg_list             IN    VARCHAR2 := FND_API.G_FALSE,
83    p_commit                    IN    VARCHAR2 := FND_API.G_FALSE,
84    p_validation_level          IN    NUMBER   := FND_API.G_VALID_LEVEL_FULL,
85    X_return_status             OUT NOCOPY   VARCHAR2,
86    X_msg_count                 OUT NOCOPY   NUMBER,
87    X_msg_data                  OUT NOCOPY   VARCHAR2,
88    p_Rowid                  IN OUT NOCOPY   VARCHAR2,
89    p_CC_Acct_Line_Id        IN OUT NOCOPY   IGC_CC_ACCT_LINES.CC_Acct_Line_Id%TYPE,
90    p_CC_Header_Id                    IGC_CC_ACCT_LINES.CC_Header_Id%TYPE,
91    p_Parent_Header_Id                IGC_CC_ACCT_LINES.Parent_Header_Id%TYPE,
92    p_Parent_Acct_Line_Id             IGC_CC_ACCT_LINES.Parent_Acct_Line_Id%TYPE,
93    p_CC_Charge_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Charge_Code_Combination_Id%TYPE,
94    p_CC_Acct_Line_Num                IGC_CC_ACCT_LINES.CC_Acct_Line_Num%TYPE,
95    p_CC_Budget_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Budget_Code_Combination_Id%TYPE,
96    p_CC_Acct_Entered_Amt             IGC_CC_ACCT_LINES.CC_Acct_Entered_Amt%TYPE,
97    p_CC_Acct_Func_Amt                IGC_CC_ACCT_LINES.CC_Acct_Func_Amt%TYPE,
98    p_CC_Acct_Desc                    IGC_CC_ACCT_LINES.CC_Acct_Desc%TYPE,
99    p_CC_Acct_Billed_Amt              IGC_CC_ACCT_LINES.CC_Acct_Billed_Amt%TYPE,
100    p_CC_Acct_Unbilled_Amt            IGC_CC_ACCT_LINES.CC_Acct_Unbilled_Amt%TYPE,
101    p_CC_Acct_Taxable_Flag            IGC_CC_ACCT_LINES.CC_Acct_Taxable_Flag%TYPE,
102    p_Tax_Id                          IGC_CC_ACCT_LINES.Tax_Id%TYPE,
103    p_CC_Acct_Encmbrnc_Amt            IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Amt%TYPE,
104    p_CC_Acct_Encmbrnc_Date           IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Date%TYPE,
105    p_CC_Acct_Encmbrnc_Status         IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Status%TYPE,
106    p_Project_Id                      IGC_CC_ACCT_LINES.Project_Id%TYPE,
107    p_Task_Id                         IGC_CC_ACCT_LINES.Task_Id%TYPE,
108    p_Expenditure_Type                IGC_CC_ACCT_LINES.Expenditure_Type%TYPE,
109    p_Expenditure_Org_Id              IGC_CC_ACCT_LINES.Expenditure_Org_Id%TYPE,
110    p_Expenditure_Item_Date           IGC_CC_ACCT_LINES.Expenditure_Item_Date%TYPE,
111    p_Last_Update_Date                IGC_CC_ACCT_LINES.Last_Update_Date%TYPE,
112    p_Last_Updated_By                 IGC_CC_ACCT_LINES.Last_Updated_By%TYPE,
113    p_Last_Update_Login               IGC_CC_ACCT_LINES.Last_Update_Login%TYPE,
114    p_Creation_Date                   IGC_CC_ACCT_LINES.Creation_Date%TYPE,
115    p_Created_By                      IGC_CC_ACCT_LINES.Created_By%TYPE,
116    p_Attribute1                      IGC_CC_ACCT_LINES.Attribute1%TYPE,
117    p_Attribute2                      IGC_CC_ACCT_LINES.Attribute2%TYPE,
118    p_Attribute3                      IGC_CC_ACCT_LINES.Attribute3%TYPE,
119    p_Attribute4                      IGC_CC_ACCT_LINES.Attribute4%TYPE,
120    p_Attribute5                      IGC_CC_ACCT_LINES.Attribute5%TYPE,
121    p_Attribute6                      IGC_CC_ACCT_LINES.Attribute6%TYPE,
122    p_Attribute7                      IGC_CC_ACCT_LINES.Attribute7%TYPE,
123    p_Attribute8                      IGC_CC_ACCT_LINES.Attribute8%TYPE,
124    p_Attribute9                      IGC_CC_ACCT_LINES.Attribute9%TYPE,
125    p_Attribute10                     IGC_CC_ACCT_LINES.Attribute10%TYPE,
126    p_Attribute11                     IGC_CC_ACCT_LINES.Attribute11%TYPE,
127    p_Attribute12                     IGC_CC_ACCT_LINES.Attribute12%TYPE,
128    p_Attribute13                     IGC_CC_ACCT_LINES.Attribute13%TYPE,
129    p_Attribute14                     IGC_CC_ACCT_LINES.Attribute14%TYPE,
130    p_Attribute15                     IGC_CC_ACCT_LINES.Attribute15%TYPE,
131    p_Context                         IGC_CC_ACCT_LINES.Context%TYPE,
132    p_cc_func_withheld_amt            IGC_CC_ACCT_LINES.cc_func_withheld_amt%TYPE,
133    p_cc_ent_withheld_amt             IGC_CC_ACCT_LINES.cc_ent_withheld_amt%TYPE,
134    G_FLAG                   IN OUT NOCOPY   VARCHAR2,
135    P_Tax_Classif_Code                IGC_CC_ACCT_LINES.Tax_Classif_Code%TYPE
136 ) IS
137 
138    l_api_name            CONSTANT VARCHAR2(30)   := 'Insert_Row';
139    l_api_version         CONSTANT NUMBER         :=  1.0;
140 
141    l_version_num         IGC_CC_HEADERS.CC_Version_Num%TYPE ;
142 
143    l_Application_Id      NUMBER;
144    l_MRC_Enabled         VARCHAR2(1);
145    l_Conversion_Date     DATE;
146    l_Set_Of_Books_Id     NUMBER;
147    l_Org_Id              NUMBER(15);
148    l_flag                VARCHAR2(1) := 'I';
149    l_return_status       VARCHAR2(1);
150    l_row_id              VARCHAR2(18);
151    l_debug               VARCHAR2(1);
152 
153    CURSOR c_acct_row_id IS
154       SELECT Rowid
155         FROM IGC_CC_ACCT_LINES
156        WHERE CC_Acct_Line_Id = p_CC_Acct_Line_Id;
157 
158    CURSOR c_cc_version_num IS
159      SELECT CC_Version_Num
160        FROM IGC_CC_HEADERS
161       WHERE CC_Header_Id = p_CC_Header_Id;
162 
163    CURSOR c_igc_app_id IS
164      SELECT Application_Id
165        FROM FND_APPLICATION
166       WHERE Application_Short_Name =  'IGC';
167 
168    CURSOR c_cc_info IS
169      SELECT SET_OF_BOOKS_ID,
170             ORG_ID,
171             CONVERSION_DATE
172        FROM IGC_CC_HEADERS,
173             IGC_CC_ACCT_LINES
174       WHERE IGC_CC_HEADERS.CC_HEADER_ID       = IGC_CC_ACCT_LINES.CC_HEADER_ID
175         AND IGC_CC_ACCT_LINES.CC_ACCT_LINE_ID = p_CC_Acct_Line_Id;
176 
177   l_full_path         VARCHAR2(255);
178 
179 BEGIN
180 
181    l_full_path := g_path || 'Insert_Row';
182 
183    SAVEPOINT Insert_Row_Pvt ;
184 
185 -- -----------------------------------------------------------------
186 -- Ensure that the version requested to be used is correct for
187 -- this API.
188 -- -----------------------------------------------------------------
189    IF NOT FND_API.Compatible_API_Call ( l_api_version,
190                                         p_api_version,
191                                         l_api_name,
192                                         G_PKG_NAME )
193    THEN
194       RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
195    END IF;
196 
197    IF FND_API.to_Boolean ( p_init_msg_list ) THEN
198       FND_MSG_PUB.initialize ;
199    END IF;
200 
201 
202    X_return_status := FND_API.G_RET_STS_SUCCESS ;
203 --   l_debug         := FND_PROFILE.VALUE('IGC_DEBUG_ENABLED');
204 
205 --   IF (l_debug = 'Y') THEN
206 --      l_debug := FND_API.G_TRUE;
207 --   ELSE
208 --      l_debug := FND_API.G_FALSE;
209 --   END IF;
210 --   IGC_MSGS_PKG.g_debug_mode := FND_API.TO_BOOLEAN(l_debug);
211 
212 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
213    IF (g_debug_mode = 'Y') THEN
214       g_debug_msg := ' IGCCACLB -- Begin Insert account line ID ....' || ' for Header ID .... ' || p_cc_header_id;
215       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
216    END IF;
217 
218 -- -----------------------------------------------------------------
219 -- Insert the account line record as requested.
220 -- -----------------------------------------------------------------
221    INSERT
222      INTO IGC_CC_ACCT_LINES
223              (CC_Acct_Line_Id,
224               CC_Header_Id,
225               Parent_Header_Id,
226               Parent_Acct_Line_Id,
227               CC_Charge_Code_Combination_Id,
228               CC_Acct_Line_Num,
229               CC_Budget_Code_Combination_Id,
230               CC_Acct_Entered_Amt,
231               CC_Acct_Func_Amt,
232               CC_Acct_Desc,
233               CC_Acct_Billed_Amt,
234               CC_Acct_Unbilled_Amt,
235               CC_Acct_Taxable_Flag,
236               Tax_Id,
237               CC_Acct_Encmbrnc_Amt,
238               CC_Acct_Encmbrnc_Date,
239               CC_Acct_Encmbrnc_Status,
240               Project_Id,
241               Task_Id,
242               Expenditure_Type,
243               Expenditure_Org_Id,
244               Expenditure_Item_Date,
245               Last_Update_Date,
246               Last_Updated_By,
247               Last_Update_Login,
248               Creation_Date,
249               Created_By,
250               Attribute1,
251               Attribute2,
252               Attribute3,
253               Attribute4,
254               Attribute5,
255               Attribute6,
256               Attribute7,
257               Attribute8,
258               Attribute9,
259               Attribute10,
260               Attribute11,
261               Attribute12,
262               Attribute13,
263               Attribute14,
264               Attribute15,
265               Context,
266               cc_func_withheld_amt,
267               cc_ent_withheld_amt,
268               Tax_Classif_Code
269              )
270        VALUES
271            (  NVL(p_CC_Acct_Line_Id, igc_cc_acct_lines_s.NEXTVAL),
272               p_CC_Header_Id,
273               p_Parent_Header_Id,
274               p_Parent_Acct_Line_Id,
275               p_CC_Charge_Code_Comb_Id,
276               p_CC_Acct_Line_Num,
277               p_CC_Budget_Code_Comb_Id,
278               p_CC_Acct_Entered_Amt,
279               p_CC_Acct_Func_Amt,
280               p_CC_Acct_Desc,
281               p_CC_Acct_Billed_Amt,
282               p_CC_Acct_Unbilled_Amt,
283               p_CC_Acct_Taxable_Flag,
284               p_Tax_Id,
285               p_CC_Acct_Encmbrnc_Amt,
286               p_CC_Acct_Encmbrnc_Date,
287               p_CC_Acct_Encmbrnc_Status,
288               p_Project_Id,
289               p_Task_Id,
290               p_Expenditure_Type,
291               p_Expenditure_Org_Id,
292               p_Expenditure_Item_Date,
293               p_Last_Update_Date,
294               p_Last_Updated_By,
295               p_Last_Update_Login,
296               p_Creation_Date,
297               p_Created_By,
298               p_Attribute1,
299               p_Attribute2,
300               p_Attribute3,
301               p_Attribute4,
302               p_Attribute5,
303               p_Attribute6,
304               p_Attribute7,
305               p_Attribute8,
306               p_Attribute9,
307               p_Attribute10,
308               p_Attribute11,
309               p_Attribute12,
310               p_Attribute13,
311               p_Attribute14,
312               p_Attribute15,
313               p_Context,
314               p_cc_func_withheld_amt,
315               p_cc_ent_withheld_amt,
316               P_Tax_Classif_Code
317              )
318            RETURNING CC_Acct_Line_Id INTO p_CC_Acct_Line_Id;
319 
320 -- -----------------------------------------------------------------
321 -- Get the next history version number for the account line history
322 -- -----------------------------------------------------------------
323    OPEN c_cc_version_num;
324    FETCH c_cc_version_num
325     INTO l_Version_Num;
326 
327 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
328    IF (g_debug_mode = 'Y') THEN
329       g_debug_msg := ' IGCCACLB -- Fetching account line version num';
330       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
331    END IF;
332 
333 -- -----------------------------------------------------------------
334 -- If there is a version number present then insert the next
335 -- history record for the account line being inserted.
336 -- -----------------------------------------------------------------
337    IF (l_Version_Num > 0) THEN
338 
339       IGC_CC_ACCT_LINE_HISTORY_PKG.Insert_Row(
340                        l_api_version ,
341                        FND_API.G_FALSE,
342                        FND_API.G_FALSE,
343                        p_validation_level,
344                        l_return_status,
345                        X_msg_count,
346                        X_msg_data,
347                        p_Rowid,
348                        p_CC_Acct_Line_Id,
349                        p_CC_Header_Id,
350                        p_Parent_Header_Id,
351                        p_Parent_Acct_Line_Id ,
352                        p_CC_Acct_Line_Num,
353                        l_Version_Num - 1 ,
354                        'I',
355                        p_CC_Charge_Code_Comb_Id,
356                        p_CC_Budget_Code_Comb_Id,
357                        p_CC_Acct_Entered_Amt ,
358                        p_CC_Acct_Func_Amt,
359                        p_CC_Acct_Desc ,
360                        p_CC_Acct_Billed_Amt ,
361                        p_CC_Acct_Unbilled_Amt,
362                        p_CC_Acct_Taxable_Flag,
363                        p_Tax_Id,
364                        p_CC_Acct_Encmbrnc_Amt,
365                        p_CC_Acct_Encmbrnc_Date,
366                        p_CC_Acct_Encmbrnc_Status,
367                        p_Project_Id,
368                        p_Task_Id,
369                        p_Expenditure_Type,
370                        p_Expenditure_Org_Id,
371                        p_Expenditure_Item_Date,
372                        p_Last_Update_Date,
373                        p_Last_Updated_By,
374                        p_Last_Update_Login ,
375                        p_Creation_Date ,
376                        p_Created_By ,
377                        p_Attribute1,
378                        p_Attribute2,
379                        p_Attribute3,
380                        p_Attribute4,
381                        p_Attribute5,
382                        p_Attribute6,
383                        p_Attribute7,
384                        p_Attribute8,
385                        p_Attribute9,
386                        p_Attribute10,
387                        p_Attribute11,
388                        p_Attribute12,
389                        p_Attribute13,
390                        p_Attribute14,
391                        p_Attribute15,
392                        p_Context,
393                        p_cc_func_withheld_amt,
394                        p_cc_ent_withheld_amt,
395                        G_FLAG,
396                        P_Tax_Classif_Code);
397 
398 -- ------------------------------------------------------------------
399 -- Make sure that the insertion was a success
400 -- ------------------------------------------------------------------
401        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
402 --          IF (IGC_MSGS_PKG.g_debug_mode) THEN
403           IF (g_debug_mode = 'Y') THEN
404              g_debug_msg := ' IGCCACLB -- Failure returned from insert History row...';
405              Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
406           END IF;
407           RAISE FND_API.G_EXC_ERROR;
408        END IF;
409 
410 --       IF (IGC_MSGS_PKG.g_debug_mode) THEN
411        IF (g_debug_mode = 'Y') THEN
412           g_debug_msg := ' IGCCACLB -- Successfully inserted History row...';
413           Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
414        END IF;
415        G_FLAG := 'Y';
416 
417    ELSE
418 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
419       IF (g_debug_mode = 'Y') THEN
420          g_debug_msg := ' IGCCACLB -- Not inserting History row version num <= 0...';
421          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
422       END IF;
423    END IF;
424 
425    CLOSE c_cc_version_num;
426 
427 -- -------------------------------------------------------------------
428 -- Obtain the ROWID of the record that was just inserted to return
429 -- to the caller.
430 -- -------------------------------------------------------------------
431    OPEN c_acct_row_id;
432    FETCH c_acct_row_id
433     INTO p_Rowid;
434 
435 -- -------------------------------------------------------------------
436 -- If no ROWID can be obtained then exit the procedure with a failure
437 -- -------------------------------------------------------------------
438    IF (c_acct_row_id%NOTFOUND) THEN
439 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
440       IF (g_debug_mode = 'Y') THEN
441          g_debug_msg := ' IGCCACLB -- Failure obtaining acct line inserted rowid...';
442          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
443       END IF;
444       RAISE FND_API.G_EXC_ERROR;
445    END IF;
446 
447    CLOSE c_acct_row_id;
448 
449 -- ------------------------------------------------------------------
450 -- Obtain the application ID for IGC to be used for the MRC check
451 -- being enabled for this set of books.
452 -- ------------------------------------------------------------------
453    OPEN c_igc_app_id;
454    FETCH c_igc_app_id
455     INTO l_Application_Id;
456 
457 -- ------------------------------------------------------------------
458 -- If the application ID can not be attained then exit the procedure
459 -- ------------------------------------------------------------------
460    IF (c_igc_app_id%NOTFOUND) THEN
461 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
462       IF (g_debug_mode = 'Y') THEN
463          g_debug_msg := ' IGCCACLB -- Failure obtaining application ID...';
464          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
465       END IF;
466       RAISE FND_API.G_EXC_ERROR;
467    END IF;
468 
469    CLOSE c_igc_app_id;
470 
471 -- ------------------------------------------------------------------
472 -- Obtain the set of books, org id, and the conversion date for the
473 -- CC Header record that the account line is associated to.
474 -- ------------------------------------------------------------------
475    OPEN c_cc_info;
476    FETCH c_cc_info
477     INTO l_Set_Of_Books_Id,
478          l_Org_Id,
479          l_Conversion_Date;
480 
481 -- ------------------------------------------------------------------
482 -- Exit procedure if the values can not be obtained.
483 -- ------------------------------------------------------------------
484    IF (c_cc_info%NOTFOUND) THEN
485 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
486       IF (g_debug_mode = 'Y') THEN
487          g_debug_msg := ' IGCCACLB -- Failure obtaining CC Info conversion date...';
488          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
489       END IF;
490       RAISE FND_API.G_EXC_ERROR;
491    END IF;
492 
493    CLOSE c_cc_info;
494 
495 -- ------------------------------------------------------------------
496 -- If the conversion date is NULL then fill in the value with the
497 -- current system date.
498 -- ------------------------------------------------------------------
499 
500    gl_mc_info.mrc_enabled (l_Set_Of_Books_Id,
501                            101, /*--l_Application_Id, commented for MRC uptake*/
502                            l_Org_Id,
503                            Null,
504                            l_MRC_Enabled);
505 
506 -- ------------------------------------------------------------------
507 -- If MRC is enabled for this set of books being used then call the
508 -- handler to insert all reporting set of books into the MRC
509 -- table for the account line inserted.
510 -- ------------------------------------------------------------------
511    IF (l_MRC_Enabled = 'Y') THEN
512 
513 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
514       IF (g_debug_mode = 'Y') THEN
515          g_debug_msg := ' IGCCACLB -- MRC Enabled so now inserting MRC info...';
516          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
517       END IF;
518 
519 -- ------------------------------------------------------------------
520 -- MRC Handler For IGC_CC_ACCT_LINES to insert all MRC records for
521 -- the reporting set of books for this PRIMARY set of books.
522 -- ------------------------------------------------------------------
523 
524       IGC_CC_MC_MAIN_PVT.get_rsobs_Acct_Lines (
525                                    l_api_version,
526                                    FND_API.G_FALSE,
527                                    FND_API.G_FALSE,
528                                    p_validation_level,
529                                    l_return_status,
530                                    X_msg_count,
531                                    X_msg_data,
532                                    p_CC_Acct_Line_Id,
533                                    l_Set_Of_Books_Id,
534                                     101, /*--l_Application_Id, commented for MRC uptake*/
535                                    l_org_Id,
536                                    NVL(l_Conversion_Date, sysdate),
537                                    p_CC_Acct_Func_Amt,
538                                    p_CC_Acct_Encmbrnc_Amt,
539                                    p_CC_Func_Withheld_Amt,
540                                    l_flag);
541 -- ------------------------------------------------------------------
542 -- Make sure that the insertion was a success
543 -- ------------------------------------------------------------------
544        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
545 --          IF (IGC_MSGS_PKG.g_debug_mode) THEN
546           IF (g_debug_mode = 'Y') THEN
547              g_debug_msg := ' IGCCACLB -- Failure returned from MC.get_rsobs_Acct_Lines...';
548              Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
549           END IF;
550           RAISE FND_API.G_EXC_ERROR;
551        END IF;
552    END IF;
553 
554 -- -----------------------------------------------------------------
555 -- If the records are to be commited in this procedure then
556 -- commit the work now otherwise wait for the caller to do COMMIT.
557 -- -----------------------------------------------------------------
558 
559    IF FND_API.To_Boolean ( p_commit ) THEN
560 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
561       IF (g_debug_mode = 'Y') THEN
562          g_debug_msg := ' IGCCACLB -- Committing Inserted account line...';
563          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
564       END IF;
565       COMMIT WORK;
566    END iF;
567 
568    FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
569                                p_data  => X_msg_data );
570 
571 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
572    IF (g_debug_mode = 'Y') THEN
573       g_debug_msg := ' IGCCACLB -- Done inserting row for Account Line...' || p_CC_Acct_Line_Id  ||
574                      ' for Header ID .... ' || p_cc_header_id;
575       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
576    END IF;
577 
578    RETURN;
579 
580 
581 EXCEPTION
582 
583   WHEN FND_API.G_EXC_ERROR THEN
584 
585     ROLLBACK TO Insert_Row_Pvt;
586     X_return_status := FND_API.G_RET_STS_ERROR;
587 
588 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
589     IF (g_debug_mode = 'Y') THEN
590        g_debug_msg := ' IGCCACLB -- Failure Execute Error...' || p_CC_Acct_Line_Id  ||
591                      ' for Header ID .... ' || p_cc_header_id;
592        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
593 
594     END IF;
595 
596     IF (c_acct_row_id%ISOPEN) THEN
597        CLOSE c_acct_row_id;
598     END IF;
599     IF (c_cc_version_num%ISOPEN) THEN
600        CLOSE c_cc_version_num;
601     END IF;
602     IF (c_igc_app_id%ISOPEN) THEN
603        CLOSE c_igc_app_id;
604     END IF;
605     IF (c_cc_info%ISOPEN) THEN
606        CLOSE c_cc_info;
607     END IF;
608     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
609                                 p_data  => X_msg_data );
610     IF (g_excep_level >=  g_debug_level ) THEN
611        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_ERROR Exception Raised');
612     END IF;
613 
614   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
615 
616     ROLLBACK TO Insert_Row_Pvt ;
617     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
618 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
619     IF (g_debug_mode = 'Y') THEN
620        g_debug_msg := ' IGCCACLB -- Failure Unexpected Error...' || p_CC_Acct_Line_Id  ||
621                      ' for Header ID .... ' || p_cc_header_id;
622        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
623     END IF;
624     IF (c_acct_row_id%ISOPEN) THEN
625        CLOSE c_acct_row_id;
626     END IF;
627     IF (c_cc_version_num%ISOPEN) THEN
628        CLOSE c_cc_version_num;
629     END IF;
630     IF (c_igc_app_id%ISOPEN) THEN
631        CLOSE c_igc_app_id;
632     END IF;
633     IF (c_cc_info%ISOPEN) THEN
634        CLOSE c_cc_info;
635     END IF;
636     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
637                                 p_data  => X_msg_data );
638     IF (g_excep_level >=  g_debug_level ) THEN
639        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_UNEXPECTED_ERROR Exception Raised');
640     END IF;
641 
642   WHEN OTHERS THEN
643 
644     ROLLBACK TO Insert_Row_Pvt ;
645     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
646 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
647     IF (g_debug_mode = 'Y') THEN
648        g_debug_msg := ' IGCCACLB -- Failure Others Error...'|| p_CC_Acct_Line_Id  ||
649                      ' for Header ID .... ' || p_cc_header_id;
650        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
651     END IF;
652     IF (c_acct_row_id%ISOPEN) THEN
653        CLOSE c_acct_row_id;
654     END IF;
655     IF (c_cc_version_num%ISOPEN) THEN
656        CLOSE c_cc_version_num;
657     END IF;
658     IF (c_igc_app_id%ISOPEN) THEN
659        CLOSE c_igc_app_id;
660     END IF;
661     IF (c_cc_info%ISOPEN) THEN
662        CLOSE c_cc_info;
663     END IF;
664 
665     IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
666       FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME,
667                                 l_api_name);
668     END if;
669 
670     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
671                                 p_data  => X_msg_data );
672 
673     IF ( g_unexp_level >= g_debug_level ) THEN
674       FND_MESSAGE.SET_NAME('IGC','IGC_LOGGING_UNEXP_ERROR');
675       FND_MESSAGE.SET_TOKEN('CODE',SQLCODE);
676       FND_MESSAGE.SET_TOKEN('MSG',  SQLERRM);
677       FND_LOG.MESSAGE ( g_unexp_level,l_full_path, TRUE);
678     END IF;
679 
680 END Insert_Row;
681 
682 
683 /* ================================================================================
684                          PROCEDURE Lock_Row
685    ===============================================================================*/
686 
687 
688 PROCEDURE Lock_Row(
689    p_api_version                 IN  NUMBER,
690    p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE,
691    p_commit                      IN  VARCHAR2 := FND_API.G_FALSE,
692    p_validation_level            IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
693    X_return_status               OUT NOCOPY VARCHAR2,
694    X_msg_count                   OUT NOCOPY NUMBER,
695    X_msg_data                    OUT NOCOPY VARCHAR2,
696    p_Rowid                    IN OUT NOCOPY VARCHAR2,
697    p_CC_Acct_Line_Id                 IGC_CC_ACCT_LINES.CC_Acct_Line_Id%TYPE,
698    p_CC_Header_Id                    IGC_CC_ACCT_LINES.CC_Header_Id%TYPE,
699    p_Parent_Header_Id                IGC_CC_ACCT_LINES.Parent_Header_Id%TYPE,
700    p_Parent_Acct_Line_Id             IGC_CC_ACCT_LINES.Parent_Acct_Line_Id%TYPE,
701    p_CC_Charge_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Charge_Code_Combination_Id%TYPE,
702    p_CC_Acct_Line_Num                IGC_CC_ACCT_LINES.CC_Acct_Line_Num%TYPE,
703    p_CC_Budget_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Budget_Code_Combination_Id%TYPE,
704    p_CC_Acct_Entered_Amt             IGC_CC_ACCT_LINES.CC_Acct_Entered_Amt%TYPE,
705    p_CC_Acct_Func_Amt                IGC_CC_ACCT_LINES.CC_Acct_Func_Amt%TYPE,
706    p_CC_Acct_Desc                    IGC_CC_ACCT_LINES.CC_Acct_Desc%TYPE,
707    p_CC_Acct_Billed_Amt              IGC_CC_ACCT_LINES.CC_Acct_Billed_Amt%TYPE,
708    p_CC_Acct_Unbilled_Amt            IGC_CC_ACCT_LINES.CC_Acct_Unbilled_Amt%TYPE,
709    p_CC_Acct_Taxable_Flag            IGC_CC_ACCT_LINES.CC_Acct_Taxable_Flag%TYPE,
710    p_Tax_Id                          IGC_CC_ACCT_LINES.Tax_Id%TYPE,
711    p_CC_Acct_Encmbrnc_Amt            IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Amt%TYPE,
712    p_CC_Acct_Encmbrnc_Date           IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Date%TYPE,
713    p_CC_Acct_Encmbrnc_Status         IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Status%TYPE,
714    p_Project_Id                      IGC_CC_ACCT_LINES.Project_Id%TYPE,
715    p_Task_Id                         IGC_CC_ACCT_LINES.Task_Id%TYPE,
716    p_Expenditure_Type                IGC_CC_ACCT_LINES.Expenditure_Type%TYPE,
717    p_Expenditure_Org_Id              IGC_CC_ACCT_LINES.Expenditure_Org_Id%TYPE,
718    p_Expenditure_Item_Date           IGC_CC_ACCT_LINES.Expenditure_Item_Date%TYPE,
719    p_Last_Update_Date                IGC_CC_ACCT_LINES.Last_Update_Date%TYPE,
720    p_Last_Updated_By                 IGC_CC_ACCT_LINES.Last_Updated_By%TYPE,
721    p_Last_Update_Login               IGC_CC_ACCT_LINES.Last_Update_Login%TYPE,
722    p_Creation_Date                   IGC_CC_ACCT_LINES.Creation_Date%TYPE,
723    p_Created_By                      IGC_CC_ACCT_LINES.Created_By%TYPE,
724    p_Attribute1                      IGC_CC_ACCT_LINES.Attribute1%TYPE,
725    p_Attribute2                      IGC_CC_ACCT_LINES.Attribute2%TYPE,
726    p_Attribute3                      IGC_CC_ACCT_LINES.Attribute3%TYPE,
727    p_Attribute4                      IGC_CC_ACCT_LINES.Attribute4%TYPE,
728    p_Attribute5                      IGC_CC_ACCT_LINES.Attribute5%TYPE,
729    p_Attribute6                      IGC_CC_ACCT_LINES.Attribute6%TYPE,
730    p_Attribute7                      IGC_CC_ACCT_LINES.Attribute7%TYPE,
731    p_Attribute8                      IGC_CC_ACCT_LINES.Attribute8%TYPE,
732    p_Attribute9                      IGC_CC_ACCT_LINES.Attribute9%TYPE,
733    p_Attribute10                     IGC_CC_ACCT_LINES.Attribute10%TYPE,
734    p_Attribute11                     IGC_CC_ACCT_LINES.Attribute11%TYPE,
735    p_Attribute12                     IGC_CC_ACCT_LINES.Attribute12%TYPE,
736    p_Attribute13                     IGC_CC_ACCT_LINES.Attribute13%TYPE,
737    p_Attribute14                     IGC_CC_ACCT_LINES.Attribute14%TYPE,
738    p_Attribute15                     IGC_CC_ACCT_LINES.Attribute15%TYPE,
739    p_Context                         IGC_CC_ACCT_LINES.Context%TYPE,
740    p_cc_func_withheld_amt            IGC_CC_ACCT_LINES.cc_func_withheld_amt%TYPE,
741    p_cc_ent_withheld_amt             IGC_CC_ACCT_LINES.cc_ent_withheld_amt%TYPE,
742    X_row_locked                  OUT NOCOPY VARCHAR2,
743    G_FLAG                     IN OUT NOCOPY VARCHAR2,
744    P_Tax_Classif_Code                IGC_CC_ACCT_LINES.Tax_Classif_Code%TYPE
745 ) IS
746 
747    l_api_name            CONSTANT VARCHAR2(30)   := 'Lock_Row';
748    l_api_version         CONSTANT NUMBER         :=  1.0;
749    Counter               NUMBER;
750    l_debug               VARCHAR2(1);
751 
752    CURSOR C IS
753         SELECT *
754         FROM   IGC_CC_ACCT_LINES
755         WHERE  Rowid = p_Rowid
756         FOR UPDATE of CC_Acct_Line_Id NOWAIT;
757 
758     Recinfo C%ROWTYPE;
759 
760     l_full_path         VARCHAR2(255);
761 
762 BEGIN
763 
764    l_full_path := g_path || 'Lock_Row';
765 
766    SAVEPOINT Lock_Row_Pvt ;
767 
768    IF NOT FND_API.Compatible_API_Call ( l_api_version,
769                                         p_api_version,
770                                         l_api_name,
771                                         G_PKG_NAME )
772    THEN
773       RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
774    END IF;
775 
776 
777    IF FND_API.to_Boolean ( p_init_msg_list ) THEN
778     FND_MSG_PUB.initialize ;
779    END IF;
780 
781    X_return_status := FND_API.G_RET_STS_SUCCESS ;
782    X_row_locked    := FND_API.G_TRUE ;
783 --   l_debug         := FND_PROFILE.VALUE('IGC_DEBUG_ENABLED');
784 
785 --   IF (l_debug = 'Y') THEN
786 --      l_debug := FND_API.G_TRUE;
787 --   ELSE
788 --      l_debug := FND_API.G_FALSE;
789 --   END IF;
790 --   IGC_MSGS_PKG.g_debug_mode := FND_API.TO_BOOLEAN(l_debug);
791 
792 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
793    IF (g_debug_mode = 'Y') THEN
794       g_debug_msg := ' IGCCACLB -- Beginning Lock account line ID ...' || p_CC_Acct_Line_Id  ||
795                      ' for Header ID .... ' || p_cc_header_id;
796       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
797    END IF;
798 
799    OPEN C;
800    FETCH C INTO Recinfo;
801 
802    IF (C%NOTFOUND) THEN
803       CLOSE C;
804       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
805       FND_MSG_PUB.Add;
806       IF (g_excep_level >=  g_debug_level ) THEN
807           FND_LOG.MESSAGE (g_excep_level ,l_full_path ,FALSE);
808       END IF;
809       RAISE FND_API.G_EXC_ERROR ;
810    END IF;
811 
812    CLOSE C;
813 
814    IF (
815                (Recinfo.CC_Acct_Line_Id =  p_CC_Acct_Line_Id)
816            AND (Recinfo.CC_Header_Id =  p_CC_Header_Id)
817            AND (Recinfo.CC_Acct_Line_Num =  p_CC_Acct_Line_Num)
818            AND (   (Recinfo.Parent_Acct_Line_Id =  p_Parent_Acct_Line_Id)
819                 OR (    (Recinfo.Parent_Acct_Line_Id IS NULL)
820                     AND (p_parent_acct_line_Id IS NULL)))
821            AND (   (Recinfo.Parent_Header_Id =  p_Parent_Header_Id)
822                 OR (    (Recinfo.Parent_Header_Id IS NULL)
823                     AND (p_Parent_Header_Id IS NULL)))
824            AND (   (Recinfo.CC_Charge_Code_Combination_Id =  p_CC_Charge_Code_Comb_Id)
825                 OR (    (Recinfo.CC_Charge_Code_Combination_Id IS NULL)
826                     AND (p_CC_Charge_Code_Comb_Id IS NULL)))
827            AND (   (Recinfo.CC_Budget_Code_Combination_Id =  p_CC_Budget_Code_Comb_Id)
828                 OR (    (Recinfo.CC_Budget_Code_Combination_Id IS NULL)
829                     AND (p_CC_Budget_Code_Comb_Id IS NULL)))
830            AND (   (Recinfo.CC_Acct_Entered_Amt =  p_CC_Acct_Entered_Amt)
831                 OR (    (Recinfo.CC_Acct_Entered_Amt IS NULL)
832                     AND (p_CC_Acct_Entered_Amt IS NULL)))
833            AND (   (Recinfo.CC_Acct_Func_Amt =  p_CC_Acct_Func_Amt)
834                 OR (    (Recinfo.CC_Acct_Func_Amt IS NULL)
835                     AND (p_CC_Acct_Func_Amt IS NULL)))
836            AND (   (Recinfo.CC_Acct_Desc =  p_CC_Acct_Desc )
837                 OR (    (Recinfo.CC_Acct_Desc  IS NULL)
838                     AND (p_CC_Acct_Desc IS NULL)))
839           -- AND (   (Recinfo.CC_Acct_Billed_Amt =  p_CC_Acct_Billed_Amt)
840            --     OR (    (Recinfo.CC_Acct_Billed_Amt IS NULL)
841             --        AND (p_CC_Acct_Billed_Amt IS NULL)))
842            AND (   (Recinfo.CC_Acct_UnBilled_Amt =  p_CC_Acct_UnBilled_Amt)
843                 OR (    (Recinfo.CC_Acct_UnBilled_Amt IS NULL)
844                     AND (p_CC_Acct_UnBilled_Amt IS NULL)))
845            AND (   (Recinfo.CC_Acct_Taxable_Flag =  p_CC_Acct_Taxable_Flag)
846                 OR (    (Recinfo.CC_Acct_Taxable_Flag IS NULL)
847                     AND (p_CC_Acct_Taxable_Flag IS NULL)))
848            AND (   (Recinfo.Tax_Id =  p_Tax_Id )
849                 OR (    (Recinfo.Tax_Id  IS NULL)
850                     AND (p_Tax_Id IS NULL)))
851            AND (   (Recinfo.CC_Acct_Encmbrnc_Amt =  p_CC_Acct_Encmbrnc_Amt)
852                 OR (    (Recinfo.CC_Acct_Encmbrnc_Amt IS NULL)
853                     AND (p_CC_Acct_Encmbrnc_Amt IS NULL)))
854            AND (   (Recinfo.CC_Acct_Encmbrnc_Date =  p_CC_Acct_Encmbrnc_Date)
855                 OR (    (Recinfo.CC_Acct_Encmbrnc_Date IS NULL)
856                     AND (p_CC_Acct_Encmbrnc_Date IS NULL)))
857 --           AND (   (Recinfo.CC_Acct_Encmbrnc_Status=  p_CC_Acct_Encmbrnc_Status)
858 --                OR (    (Recinfo.CC_Acct_Encmbrnc_Status IS NULL)
859 --                    AND (p_CC_Acct_Encmbrnc_Status IS NULL)))
860            AND (   (Recinfo.Project_Id =  p_Project_Id)
861                 OR (    (Recinfo.Project_Id IS NULL)
862                     AND (p_Project_Id IS NULL)))
863            AND (   (Recinfo.Task_Id =  p_Task_Id)
864                 OR (    (Recinfo.Task_Id IS NULL)
865                     AND (p_Task_Id IS NULL)))
866            AND (   (Recinfo.Expenditure_Type =  p_Expenditure_Type)
867                 OR (    (Recinfo.Expenditure_Type IS NULL)
868                     AND (p_Expenditure_Type IS NULL)))
869            AND (   (Recinfo.Expenditure_Org_Id =  p_Expenditure_Org_Id)
870                 OR (    (Recinfo.Expenditure_Org_Id IS NULL)
871                     AND (p_Expenditure_Org_Id IS NULL)))
872            AND (   (Recinfo.Expenditure_Item_Date =  p_Expenditure_Item_Date)
873                 OR (    (Recinfo.Expenditure_Item_Date IS NULL)
874                     AND (p_Expenditure_Item_Date IS NULL)))
875            AND (   (Recinfo.Attribute1 =  p_Attribute1)
876                 OR (    (Recinfo.Attribute1 IS NULL)
877                     AND (p_Attribute1 IS NULL)))
878            AND (   (Recinfo.Attribute2 =  p_Attribute2)
879                 OR (    (Recinfo.Attribute2 IS NULL)
880                     AND (p_Attribute2 IS NULL)))
881            AND (   (Recinfo.Attribute3 =  p_Attribute3)
882                 OR (    (Recinfo.Attribute3 IS NULL)
883                     AND (p_Attribute3 IS NULL)))
884            AND (   (Recinfo.Attribute4 =  p_Attribute4)
885                 OR (    (Recinfo.Attribute4 IS NULL)
886                     AND (p_Attribute4 IS NULL)))
887            AND (   (Recinfo.Attribute5 =  p_Attribute5)
888                 OR (    (Recinfo.Attribute5 IS NULL)
889                     AND (p_Attribute5 IS NULL)))
890            AND (   (Recinfo.Attribute6 =  p_Attribute6)
891                 OR (    (Recinfo.Attribute6 IS NULL)
892                     AND (p_Attribute6 IS NULL)))
893            AND (   (Recinfo.Attribute7 =  p_Attribute7)
894                 OR (    (Recinfo.Attribute7 IS NULL)
895                     AND (p_Attribute7 IS NULL)))
896            AND (   (Recinfo.Attribute8 =  p_Attribute8)
897                 OR (    (Recinfo.Attribute8 IS NULL)
898                     AND (p_Attribute8 IS NULL)))
899            AND (   (Recinfo.Attribute9 =  p_Attribute9)
900                 OR (    (Recinfo.Attribute9 IS NULL)
901                     AND (p_Attribute9 IS NULL)))
902            AND (   (Recinfo.Attribute10 =  p_Attribute10)
903                 OR (    (Recinfo.Attribute10 IS NULL)
904                     AND (p_Attribute10 IS NULL)))
905            AND (   (Recinfo.Attribute11 =  p_Attribute11)
906                 OR (    (Recinfo.Attribute11 IS NULL)
907                     AND (p_Attribute11 IS NULL)))
908            AND (   (Recinfo.Attribute12 =  p_Attribute12)
909                 OR (    (Recinfo.Attribute12 IS NULL)
910                     AND (p_Attribute12 IS NULL)))
911            AND (   (Recinfo.Attribute13 =  p_Attribute13)
912                 OR (    (Recinfo.Attribute13 IS NULL)
913                     AND (p_Attribute13 IS NULL)))
914            AND (   (Recinfo.Attribute14 =  p_Attribute14)
915                 OR (    (Recinfo.Attribute14 IS NULL)
916                     AND (p_Attribute14 IS NULL)))
917            AND (   (Recinfo.Attribute15 =  p_Attribute15)
918                 OR (    (Recinfo.Attribute15 IS NULL)
919                     AND (p_Attribute15 IS NULL)))
920            AND (   (Recinfo.Context =  p_Context)
921                 OR (    (Recinfo.Context IS NULL)
922                     AND (p_Context IS NULL)))
923            AND (   (Recinfo.CC_Func_Withheld_Amt =  p_CC_Func_Withheld_Amt)
924                 OR (    (Recinfo.CC_Func_Withheld_Amt IS NULL)
925                     AND (p_CC_Func_Withheld_Amt IS NULL)))
926            AND (   (Recinfo.CC_Ent_Withheld_Amt =  p_CC_Ent_Withheld_Amt)
927                 OR (    (Recinfo.CC_Ent_Withheld_Amt IS NULL)
928                     AND (p_CC_Ent_Withheld_Amt IS NULL)))
929            AND (   (Recinfo.Tax_Classif_Code =  P_Tax_Classif_Code)
930                 OR (    (Recinfo.Tax_Classif_Code IS NULL)
931                     AND (P_Tax_Classif_Code IS NULL)))
932 
933      ) THEN
934 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
935       IF (g_debug_mode = 'Y') THEN
936          g_debug_msg := ' IGCCACLB -- Locked account line';
937          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
938       END IF;
939       NULL;
940 
941    ELSE
942 --     IF (IGC_MSGS_PKG.g_debug_mode) THEN
943      IF (g_debug_mode = 'Y') THEN
944         g_debug_msg := ' IGCCACLB -- Failure Locking account line';
945         Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
946      END IF;
947      FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
948      IF (g_excep_level >=  g_debug_level ) THEN
949        FND_LOG.MESSAGE (g_excep_level,l_full_path,FALSE);
950      END IF;
951      FND_MSG_PUB.Add;
952      RAISE FND_API.G_EXC_ERROR ;
953    END IF;
954 
955    IF FND_API.To_Boolean ( p_commit ) THEN
956 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
957       IF (g_debug_mode = 'Y') THEN
958          g_debug_msg := ' IGCCACLB -- Committing Locked account line';
959          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
960       END IF;
961       COMMIT WORK;
962    END iF;
963 
964    FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
965                                p_data  => X_msg_data );
966 
967 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
968    IF (g_debug_mode = 'Y') THEN
969       g_debug_msg := ' IGCCACLB -- End of Locking account line ID ...' || p_CC_Acct_Line_Id  ||
970                      ' for Header ID .... ' || p_cc_header_id;
971       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
972    END IF;
973 
974 EXCEPTION
975 
976   WHEN APP_EXCEPTION.RECORD_LOCK_EXCEPTION THEN
977 
978     ROLLBACK TO Lock_Row_Pvt ;
979     X_row_locked := FND_API.G_FALSE;
980     X_return_status := FND_API.G_RET_STS_ERROR;
981 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
982     IF (g_debug_mode = 'Y') THEN
983        g_debug_msg := ' IGCCACLB -- Record Lock exception...' || p_CC_Acct_Line_Id  ||
984                      ' for Header ID .... ' || p_cc_header_id;
985        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
986     END IF;
987     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
988                                 p_data  => X_msg_data );
989     IF (g_excep_level >=  g_debug_level ) THEN
990        FND_LOG.STRING (g_excep_level,l_full_path,'APP_EXCEPTION.RECORD_LOCK_EXCEPTION Exception Raised');
991     END IF;
992 
993   WHEN FND_API.G_EXC_ERROR THEN
994 
995     ROLLBACK TO Lock_Row_Pvt ;
996     X_return_status := FND_API.G_RET_STS_ERROR;
997 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
998     IF (g_debug_mode = 'Y') THEN
999        g_debug_msg := ' IGCCACLB -- Execute exception...' || p_CC_Acct_Line_Id  ||
1000                      ' for Header ID .... ' || p_cc_header_id;
1001        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1002     END IF;
1003     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1004                                 p_data  => X_msg_data );
1005     IF (g_excep_level >=  g_debug_level ) THEN
1006        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_ERROR Exception Raised');
1007     END IF;
1008 
1009   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1010 
1011     ROLLBACK TO Lock_Row_Pvt ;
1012     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1013 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1014     IF (g_debug_mode = 'Y') THEN
1015        g_debug_msg := ' IGCCACLB -- Unexpected exception...' || p_CC_Acct_Line_Id  ||
1016                      ' for Header ID .... ' || p_cc_header_id;
1017        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1018     END IF;
1019     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1020                                 p_data  => X_msg_data );
1021     IF (g_excep_level >=  g_debug_level ) THEN
1022        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_UNEXPECTED_ERROR Exception Raised');
1023     END IF;
1024 
1025   WHEN OTHERS THEN
1026 
1027     ROLLBACK TO Lock_Row_Pvt ;
1028     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1029 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1030     IF (g_debug_mode = 'Y') THEN
1031        g_debug_msg := ' IGCCACLB -- Others exception...' || p_CC_Acct_Line_Id  ||
1032                      ' for Header ID .... ' || p_cc_header_id;
1033        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1034     END IF;
1035     IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1036       FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME,
1037                                 l_api_name);
1038     END if;
1039 
1040     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1041                                 p_data  => X_msg_data );
1042     IF ( g_unexp_level >= g_debug_level ) THEN
1043       FND_MESSAGE.SET_NAME('IGC','IGC_LOGGING_UNEXP_ERROR');
1044       FND_MESSAGE.SET_TOKEN('CODE',SQLCODE);
1045       FND_MESSAGE.SET_TOKEN('MSG',  SQLERRM);
1046       FND_LOG.MESSAGE ( g_unexp_level,l_full_path, TRUE);
1047     END IF;
1048 
1049 END Lock_Row;
1050 
1051 
1052 /* ================================================================================
1053                          PROCEDURE Update_Row
1054    ===============================================================================*/
1055 
1056 PROCEDURE Update_Row(
1057    p_api_version                 IN  NUMBER,
1058    p_init_msg_list               IN  VARCHAR2 := FND_API.G_FALSE,
1059    p_commit                      IN  VARCHAR2 := FND_API.G_FALSE,
1060    p_validation_level            IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1061    X_return_status               OUT NOCOPY VARCHAR2,
1062    X_msg_count                   OUT NOCOPY NUMBER,
1063    X_msg_data                    OUT NOCOPY VARCHAR2,
1064    p_Rowid                       IN OUT NOCOPY VARCHAR2,
1065    p_CC_Acct_Line_Id             IN OUT NOCOPY IGC_CC_ACCT_LINES.CC_Acct_Line_Id%TYPE,
1066    p_CC_Header_Id                    IGC_CC_ACCT_LINES.CC_Header_Id%TYPE,
1067    p_Parent_Header_Id                IGC_CC_ACCT_LINES.Parent_Header_Id%TYPE,
1068    p_Parent_Acct_Line_Id             IGC_CC_ACCT_LINES.Parent_Acct_Line_Id%TYPE,
1069    p_CC_Charge_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Charge_Code_Combination_Id%TYPE,
1070    p_CC_Acct_Line_Num                IGC_CC_ACCT_LINES.CC_Acct_Line_Num%TYPE,
1071    p_CC_Budget_Code_Comb_Id          IGC_CC_ACCT_LINES.CC_Budget_Code_Combination_Id%TYPE,
1072    p_CC_Acct_Entered_Amt             IGC_CC_ACCT_LINES.CC_Acct_Entered_Amt%TYPE,
1073    p_CC_Acct_Func_Amt                IGC_CC_ACCT_LINES.CC_Acct_Func_Amt%TYPE,
1074    p_CC_Acct_Desc                    IGC_CC_ACCT_LINES.CC_Acct_Desc%TYPE,
1075    p_CC_Acct_Billed_Amt              IGC_CC_ACCT_LINES.CC_Acct_Billed_Amt%TYPE,
1076    p_CC_Acct_Unbilled_Amt            IGC_CC_ACCT_LINES.CC_Acct_Unbilled_Amt%TYPE,
1077    p_CC_Acct_Taxable_Flag            IGC_CC_ACCT_LINES.CC_Acct_Taxable_Flag%TYPE,
1078    p_Tax_Id                          IGC_CC_ACCT_LINES.Tax_Id%TYPE,
1079    p_CC_Acct_Encmbrnc_Amt            IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Amt%TYPE,
1080    p_CC_Acct_Encmbrnc_Date           IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Date%TYPE,
1081    p_CC_Acct_Encmbrnc_Status         IGC_CC_ACCT_LINES.CC_Acct_Encmbrnc_Status%TYPE,
1082    p_Project_Id                      IGC_CC_ACCT_LINES.Project_Id%TYPE,
1083    p_Task_Id                         IGC_CC_ACCT_LINES.Task_Id%TYPE,
1084    p_Expenditure_Type                IGC_CC_ACCT_LINES.Expenditure_Type%TYPE,
1085    p_Expenditure_Org_Id              IGC_CC_ACCT_LINES.Expenditure_Org_Id%TYPE,
1086    p_Expenditure_Item_Date           IGC_CC_ACCT_LINES.Expenditure_Item_Date%TYPE,
1087    p_Last_Update_Date                IGC_CC_ACCT_LINES.Last_Update_Date%TYPE,
1088    p_Last_Updated_By                 IGC_CC_ACCT_LINES.Last_Updated_By%TYPE,
1089    p_Last_Update_Login               IGC_CC_ACCT_LINES.Last_Update_Login%TYPE,
1090    p_Creation_Date                   IGC_CC_ACCT_LINES.Creation_Date%TYPE,
1091    p_Created_By                      IGC_CC_ACCT_LINES.Created_By%TYPE,
1092    p_Attribute1                      IGC_CC_ACCT_LINES.Attribute1%TYPE,
1093    p_Attribute2                      IGC_CC_ACCT_LINES.Attribute2%TYPE,
1094    p_Attribute3                      IGC_CC_ACCT_LINES.Attribute3%TYPE,
1095    p_Attribute4                      IGC_CC_ACCT_LINES.Attribute4%TYPE,
1096    p_Attribute5                      IGC_CC_ACCT_LINES.Attribute5%TYPE,
1097    p_Attribute6                      IGC_CC_ACCT_LINES.Attribute6%TYPE,
1098    p_Attribute7                      IGC_CC_ACCT_LINES.Attribute7%TYPE,
1099    p_Attribute8                      IGC_CC_ACCT_LINES.Attribute8%TYPE,
1100    p_Attribute9                      IGC_CC_ACCT_LINES.Attribute9%TYPE,
1101    p_Attribute10                     IGC_CC_ACCT_LINES.Attribute10%TYPE,
1102    p_Attribute11                     IGC_CC_ACCT_LINES.Attribute11%TYPE,
1103    p_Attribute12                     IGC_CC_ACCT_LINES.Attribute12%TYPE,
1104    p_Attribute13                     IGC_CC_ACCT_LINES.Attribute13%TYPE,
1105    p_Attribute14                     IGC_CC_ACCT_LINES.Attribute14%TYPE,
1106    p_Attribute15                     IGC_CC_ACCT_LINES.Attribute15%TYPE,
1107    p_Context                         IGC_CC_ACCT_LINES.Context%TYPE,
1108    p_cc_func_withheld_amt            IGC_CC_ACCT_LINES.cc_func_withheld_amt%TYPE,
1109    p_cc_ent_withheld_amt             IGC_CC_ACCT_LINES.cc_ent_withheld_amt%TYPE,
1110    G_FLAG                     IN OUT NOCOPY VARCHAR2,
1111    P_Tax_Classif_Code                IGC_CC_ACCT_LINES.Tax_Classif_Code%TYPE
1112 ) IS
1113 
1114    l_api_name            CONSTANT VARCHAR2(30)   := 'Update_Row';
1115    l_api_version         CONSTANT NUMBER         :=  1.0;
1116    l_Application_Id      NUMBER;
1117    l_MRC_Enabled         VARCHAR2(1);
1118    l_Conversion_Date     DATE;
1119    l_Set_Of_Books_Id     NUMBER;
1120    l_Org_Id              NUMBER(15);
1121    l_flag                VARCHAR2(1) := 'U';
1122    l_return_status       VARCHAR2(1);
1123    l_debug               VARCHAR2(1);
1124 
1125    CURSOR c_igc_app_id IS
1126      SELECT Application_Id
1127        FROM FND_APPLICATION
1128       WHERE Application_Short_Name =  'IGC';
1129 
1130    CURSOR c_acct_line_info IS
1131      SELECT ICH.set_of_books_id,
1132             ICH.org_id
1133        FROM IGC_CC_HEADERS     ICH,
1134             IGC_CC_ACCT_LINES  IAL
1135       WHERE ICH.CC_HEADER_ID    = IAL.CC_HEADER_ID
1136         AND IAL.CC_ACCT_LINE_ID = p_CC_Acct_Line_Id;
1137 
1138   l_full_path         VARCHAR2(255);
1139 
1140 BEGIN
1141 
1142    l_full_path := g_path || 'Update_Row';
1143 
1144    SAVEPOINT Update_Row_Pvt ;
1145 
1146 -- -----------------------------------------------------------------
1147 -- Ensure that the version requested to be used is correct for
1148 -- this API.
1149 -- -----------------------------------------------------------------
1150    IF NOT FND_API.Compatible_API_Call ( l_api_version,
1151                                         p_api_version,
1152                                         l_api_name,
1153                                         G_PKG_NAME )
1154    THEN
1155       RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1156    END IF;
1157 
1158    IF FND_API.to_Boolean ( p_init_msg_list ) THEN
1159       FND_MSG_PUB.initialize ;
1160    END IF;
1161 
1162    X_return_status := FND_API.G_RET_STS_SUCCESS ;
1163 --   l_debug         := FND_PROFILE.VALUE('IGC_DEBUG_ENABLED');
1164 
1165 --   IF (l_debug = 'Y') THEN
1166 --      l_debug := FND_API.G_TRUE;
1167 --   ELSE
1168 --      l_debug := FND_API.G_FALSE;
1169 --   END IF;
1170 --   IGC_MSGS_PKG.g_debug_mode := FND_API.TO_BOOLEAN(l_debug);
1171 
1172 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1173    IF (g_debug_mode = 'Y') THEN
1174       g_debug_msg := ' IGCCACLB -- Starting Update Account for Header ID .... ' || p_cc_header_id;
1175       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1176    END IF;
1177 
1178 -- --------------------------------------------------------------------------
1179 -- Update the Account Line Record
1180 -- --------------------------------------------------------------------------
1181    UPDATE IGC_CC_ACCT_LINES
1182       SET CC_Acct_Line_Id = NVL(p_CC_Acct_Line_Id, igc_cc_acct_lines_s.NEXTVAL),
1183           CC_Header_Id                  =  p_CC_Header_Id,
1184           Parent_Header_Id              =  p_Parent_Header_id,
1185           Parent_Acct_Line_Id           =  p_Parent_Acct_Line_Id,
1186           CC_Charge_Code_Combination_Id =  p_CC_Charge_Code_Comb_Id,
1187           CC_Acct_Line_Num              =  p_CC_Acct_Line_Num,
1188           CC_Budget_Code_Combination_Id =  p_CC_Budget_Code_Comb_Id,
1189           CC_Acct_Entered_Amt           =  p_CC_Acct_Entered_Amt,
1190           CC_Acct_Func_Amt              =  p_CC_Acct_Func_Amt,
1191           CC_Acct_Desc                  =  p_CC_Acct_Desc,
1192           CC_Acct_Billed_Amt            =  p_CC_Acct_Billed_Amt,
1193           CC_Acct_Unbilled_Amt          =  p_CC_Acct_Unbilled_Amt,
1194           CC_Acct_Taxable_Flag          =  p_CC_Acct_Taxable_Flag,
1195           Tax_Id                        =  p_Tax_Id,
1196           CC_Acct_Encmbrnc_Amt          =  p_CC_Acct_Encmbrnc_Amt,
1197           CC_Acct_Encmbrnc_Date         =  p_CC_Acct_Encmbrnc_Date,
1198           CC_Acct_Encmbrnc_Status       =  p_CC_Acct_Encmbrnc_Status,
1199           Project_Id                    =  p_Project_Id,
1200           Task_Id                       =  p_Task_Id,
1201           Expenditure_Type              =  p_Expenditure_Type,
1202           Expenditure_Org_Id            =  p_Expenditure_Org_Id,
1203           Expenditure_Item_Date         =  p_Expenditure_Item_Date,
1204           Last_Update_Date              =  p_Last_Update_Date,
1205           Last_Updated_By               =  p_Last_Updated_By,
1206           Last_Update_Login             =  p_Last_Update_Login,
1207           Creation_Date                 =  p_Creation_Date,
1208           Created_By                    =  p_Created_By,
1209           Attribute1                    =  p_Attribute1,
1210           Attribute2                    =  p_Attribute2,
1211           Attribute3                    =  p_Attribute3,
1212           Attribute4                    =  p_Attribute4,
1213           Attribute5                    =  p_Attribute5,
1214           Attribute6                    =  p_Attribute6,
1215           Attribute7                    =  p_Attribute7,
1216           Attribute8                    =  p_Attribute8,
1217           Attribute9                    =  p_Attribute9,
1218           Attribute10                   =  p_Attribute10,
1219           Attribute11                   =  p_Attribute11,
1220           Attribute12                   =  p_Attribute12,
1221           Attribute13                   =  p_Attribute13,
1222           Attribute14                   =  p_Attribute14,
1223           Attribute15                   =  p_Attribute15,
1224           Context                       =  p_Context  ,
1225           cc_func_withheld_amt          =  p_cc_func_withheld_amt,
1226           cc_ent_withheld_amt           =  p_cc_ent_withheld_amt,
1227           Tax_Classif_Code              =  P_Tax_Classif_Code
1228     WHERE rowid = p_Rowid
1229     RETURNING CC_Acct_Line_Id INTO p_CC_Acct_Line_Id ;
1230 
1231    IF (SQL%NOTFOUND) THEN
1232 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1233       IF (g_debug_mode = 'Y') THEN
1234          g_debug_msg := ' IGCCACLB -- Account Line not found to update.....';
1235          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1236       END IF;
1237       RAISE NO_DATA_FOUND;
1238    END IF;
1239 
1240 -- -------------------------------------------------------------------------
1241 -- Obtain the information required for doing the update for the MRC
1242 -- records and reporting sets of books.
1243 -- -------------------------------------------------------------------------
1244    OPEN c_igc_app_id;
1245    FETCH c_igc_app_id
1246     INTO l_Application_Id;
1247 
1248 -- ------------------------------------------------------------------
1249 -- If the application ID can not be attained then exit the procedure
1250 -- ------------------------------------------------------------------
1251    IF (c_igc_app_id%NOTFOUND) THEN
1252 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1253       IF (g_debug_mode = 'Y') THEN
1254          g_debug_msg := ' IGCCACLB -- Failure obtaining application ID.....';
1255          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1256       END IF;
1257       RAISE FND_API.G_EXC_ERROR;
1258    END IF;
1259 
1260    CLOSE c_igc_app_id;
1261 
1262 -- ------------------------------------------------------------------
1263 -- Obtain the set of books, org id, and the conversion date for the
1264 -- CC Header record that the Account line is associated to.
1265 -- ------------------------------------------------------------------
1266    OPEN c_acct_line_info;
1267    FETCH c_acct_line_info
1268     INTO l_Set_Of_Books_Id,
1269          l_Org_Id;
1270 
1271 -- ------------------------------------------------------------------
1272 -- Exit procedure if the values can not be obtained.
1273 -- ------------------------------------------------------------------
1274    IF (c_acct_line_info%NOTFOUND) THEN
1275 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1276       IF (g_debug_mode = 'Y') THEN
1277          g_debug_msg := ' IGCCACLB -- Failure obtaining account line info for update.....';
1278          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1279       END IF;
1280       RAISE NO_DATA_FOUND;
1281    END IF;
1282 
1283    CLOSE c_acct_line_info;
1284 
1285 -- ------------------------------------------------------------------
1286 -- If the conversion date is NULL then fill in the value with the
1287 -- current system date.
1288 -- ------------------------------------------------------------------
1289 
1290    gl_mc_info.mrc_enabled (l_Set_Of_Books_Id,
1291                             101, /*--l_Application_Id, commented for MRC uptake*/
1292                            l_Org_Id,
1293                            Null,
1294                            l_MRC_Enabled
1295                           );
1296 
1297 -- ------------------------------------------------------------------
1298 -- If MRC has been enabled for this set of books then make sure that
1299 -- the records are updated accordingly.
1300 -- ------------------------------------------------------------------
1301    IF (l_MRC_Enabled = 'Y') THEN
1302 
1303 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1304       IF (g_debug_mode = 'Y') THEN
1305          g_debug_msg := ' IGCCACLB -- MRC enabled for update account line.....';
1306          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1307       END IF;
1308 
1309 -- ------------------------------------------------------------------
1310 -- MRC Handler For IGC_CC_ACCT_LINES to insert all MRC records for
1311 -- the reporting set of books for this PRIMARY set of books.
1312 -- ------------------------------------------------------------------
1313       IGC_CC_MC_MAIN_PVT.get_rsobs_ACCT_LINES(
1314                                  l_api_version,
1315                                  FND_API.G_FALSE,
1316                                  FND_API.G_FALSE,
1317                                  p_validation_level,
1318                                  l_return_status,
1319                                  X_msg_count,
1320                                  X_msg_data,
1321                                  p_CC_Acct_Line_Id,
1322                                  l_Set_Of_Books_Id,
1323                                   101, /*--l_Application_Id, commented for MRC uptake*/
1324                                  l_org_Id,
1325                                  NVL(l_Conversion_Date, sysdate),
1326                                  p_CC_Acct_Func_Amt,
1327                                  p_CC_Acct_Encmbrnc_Amt,
1328                                  p_CC_Func_Withheld_Amt,
1329                                  l_flag);
1330 
1331 -- ------------------------------------------------------------------
1332 -- Make sure that the insertion was a success
1333 -- ------------------------------------------------------------------
1334       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1335 --         IF (IGC_MSGS_PKG.g_debug_mode) THEN
1336          IF (g_debug_mode = 'Y') THEN
1337             g_debug_msg := ' IGCCACLB -- Failure returned from MRC update account line.....';
1338             Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1339          END IF;
1340          RAISE FND_API.G_EXC_ERROR;
1341       END IF;
1342 
1343    END IF;
1344 
1345 -- -----------------------------------------------------------------
1346 -- If the records are to be commited in this procedure then
1347 -- commit the work now otherwise wait for the caller to do COMMIT.
1348 -- -----------------------------------------------------------------
1349    IF FND_API.To_Boolean ( p_commit ) THEN
1350 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1351       IF (g_debug_mode = 'Y') THEN
1352          g_debug_msg := ' IGCCACLB -- Committing account line update.....';
1353          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1354       END IF;
1355       COMMIT WORK;
1356    END iF;
1357 
1358    FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1359                                p_data  => X_msg_data );
1360 
1361 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1362    IF (g_debug_mode = 'Y') THEN
1363       g_debug_msg := ' IGCCACLB -- End of Update Account Line ID ...' || p_CC_Acct_Line_Id  ||
1364                      ' for Header ID .... ' || p_cc_header_id;
1365       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1366    END IF;
1367 
1368    RETURN;
1369 
1370 EXCEPTION
1371 
1372   WHEN FND_API.G_EXC_ERROR THEN
1373 
1374     ROLLBACK TO Update_Row_Pvt ;
1375     X_return_status := FND_API.G_RET_STS_ERROR;
1376 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1377     IF (g_debug_mode = 'Y') THEN
1378        g_debug_msg := ' IGCCACLB -- Failure update execute error.....' || p_CC_Acct_Line_Id  ||
1379                      ' for Header ID .... ' || p_cc_header_id;
1380        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1381     END IF;
1382     IF (c_acct_line_info%ISOPEN) THEN
1383        CLOSE c_acct_line_info;
1384     END IF;
1385     IF (c_igc_app_id%ISOPEN) THEN
1386        CLOSE c_igc_app_id;
1387     END IF;
1388     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1389                                 p_data  => X_msg_data );
1390     IF (g_excep_level >=  g_debug_level ) THEN
1391        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_ERROR Exception Raised');
1392     END IF;
1393 
1394   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1395 
1396     ROLLBACK TO Update_Row_Pvt ;
1397     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1398 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1399     IF (g_debug_mode = 'Y') THEN
1400        g_debug_msg := ' IGCCACLB -- Failure update Unexpected error.....' || p_CC_Acct_Line_Id  ||
1401                      ' for Header ID .... ' || p_cc_header_id;
1402        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1403     END IF;
1404     IF (c_acct_line_info%ISOPEN) THEN
1405        CLOSE c_acct_line_info;
1406     END IF;
1407     IF (c_igc_app_id%ISOPEN) THEN
1408        CLOSE c_igc_app_id;
1409     END IF;
1410     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1411                                 p_data  => X_msg_data );
1412     IF (g_excep_level >=  g_debug_level ) THEN
1413        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_UNEXPECTED_ERROR Exception Raised');
1414     END IF;
1415 
1416   WHEN OTHERS THEN
1417 
1418     ROLLBACK TO Update_Row_Pvt ;
1419     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1420 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1421     IF (g_debug_mode = 'Y') THEN
1422        g_debug_msg := ' IGCCACLB -- Failure update Others error.....' || p_CC_Acct_Line_Id  ||
1423                      ' for Header ID .... ' || p_cc_header_id;
1424        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1425     END IF;
1426     IF (c_acct_line_info%ISOPEN) THEN
1427        CLOSE c_acct_line_info;
1428     END IF;
1429     IF (c_igc_app_id%ISOPEN) THEN
1430        CLOSE c_igc_app_id;
1431     END IF;
1432 
1433     IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1434       FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME,
1435                                 l_api_name);
1436     END if;
1437 
1438     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1439                                 p_data  => X_msg_data );
1440     IF ( g_unexp_level >= g_debug_level ) THEN
1441       FND_MESSAGE.SET_NAME('IGC','IGC_LOGGING_UNEXP_ERROR');
1442       FND_MESSAGE.SET_TOKEN('CODE',SQLCODE);
1443       FND_MESSAGE.SET_TOKEN('MSG',  SQLERRM);
1444       FND_LOG.MESSAGE ( g_unexp_level,l_full_path, TRUE);
1445     END IF;
1446 
1447   END Update_Row;
1448 
1449 
1450 /* ================================================================================
1451                          PROCEDURE Delete_Row
1452    ===============================================================================*/
1453 
1454 PROCEDURE Delete_Row(
1455    p_api_version               IN   NUMBER,
1456    p_init_msg_list             IN   VARCHAR2 := FND_API.G_FALSE,
1457    p_commit                    IN   VARCHAR2 := FND_API.G_FALSE,
1458    p_validation_level          IN   NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1459    X_return_status             OUT NOCOPY  VARCHAR2,
1460    X_msg_count                 OUT NOCOPY  NUMBER,
1461    X_msg_data                  OUT NOCOPY  VARCHAR2,
1462    p_Rowid                  IN OUT NOCOPY  VARCHAR2,
1463    G_FLAG                   IN OUT NOCOPY  VARCHAR2
1464 ) IS
1465 
1466    l_api_name                CONSTANT VARCHAR2(30)   := 'Delete_Row';
1467    l_api_version             CONSTANT NUMBER         :=  1.0;
1468 
1469    l_Application_Id          NUMBER;
1470    l_return_status           VARCHAR2(1) ;
1471    l_msg_count               NUMBER ;
1472    l_msg_data                VARCHAR2(2000) ;
1473    l_version_num             IGC_CC_HEADERS.CC_Version_Num%TYPE;
1474    l_acct_row_id             Varchar2(18);
1475    l_pf_row_id               Varchar2(18);
1476    l_action_flag             VARCHAR2(1) := 'D';
1477    l_Conversion_Date         DATE;
1478    l_Set_Of_Books_Id         NUMBER;
1479    l_Org_Id                  NUMBER(15);
1480    l_MRC_Enabled             VARCHAR2(1);
1481    l_global_flag             VARCHAR2(1);
1482    l_debug                   VARCHAR2(1);
1483 
1484    CURSOR c_acct_row_info IS
1485       SELECT *
1486         FROM IGC_CC_ACCT_LINES
1487        WHERE Rowid = p_Rowid;
1488 
1489    CURSOR c_cc_version_num IS
1490      SELECT ICH.CC_Version_Num
1491        FROM IGC_CC_HEADERS    ICH,
1492             IGC_CC_ACCT_LINES IAL
1493       WHERE ICH.CC_Header_Id = IAL.CC_Header_Id
1494         AND IAL.Rowid        = p_Rowid;
1495 
1496    Recinfo c_acct_row_info%ROWTYPE;
1497 
1498    CURSOR c_igc_app_id IS
1499      SELECT Application_Id
1500        FROM FND_APPLICATION
1501       WHERE Application_Short_Name =  'IGC';
1502 
1503    CURSOR c_cc_info IS
1504      SELECT ICH.SET_OF_BOOKS_ID,
1505             ICH.ORG_ID,
1506             ICH.CONVERSION_DATE
1507        FROM IGC_CC_HEADERS     ICH,
1508             IGC_CC_ACCT_LINES  CAL
1509       WHERE ICH.CC_HEADER_ID    = CAL.CC_HEADER_ID
1510         AND CAL.CC_ACCT_LINE_ID = Recinfo.cc_acct_line_id;
1511 
1512    CURSOR c_get_all_pf_lines IS
1513      SELECT rowid
1514        FROM igc_cc_det_pf CDP
1515       WHERE CDP.cc_acct_line_id = Recinfo.cc_acct_line_id;
1516 
1517   l_full_path         VARCHAR2(255);
1518 
1519 BEGIN
1520 
1521    l_full_path := g_path || 'Delete_Row';
1522 
1523    SAVEPOINT Delete_Row_Pvt ;
1524 
1525 -- -----------------------------------------------------------------
1526 -- Ensure that the version requested to be used is correct for
1527 -- this API.
1528 -- -----------------------------------------------------------------
1529    IF NOT FND_API.Compatible_API_Call ( l_api_version,
1530                                         p_api_version,
1531                                         l_api_name,
1532                                         G_PKG_NAME )
1533    THEN
1534       RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1535    END IF;
1536 
1537    IF FND_API.to_Boolean ( p_init_msg_list ) THEN
1538       FND_MSG_PUB.initialize ;
1539    END IF ;
1540 
1541    X_return_status := FND_API.G_RET_STS_SUCCESS ;
1542 --   l_debug         := FND_PROFILE.VALUE('IGC_DEBUG_ENABLED');
1543 
1544 --   IF (l_debug = 'Y') THEN
1545 --      l_debug := FND_API.G_TRUE;
1546 --   ELSE
1547 --      l_debug := FND_API.G_FALSE;
1548 --   END IF;
1549 --   IGC_MSGS_PKG.g_debug_mode := FND_API.TO_BOOLEAN(l_debug);
1550 
1551 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1552    IF (g_debug_mode = 'Y') THEN
1553        g_debug_msg := ' IGCCACLB -- Starting account line delete Rowid ...' || p_rowid;
1554        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1555    END IF;
1556 
1557 -- -----------------------------------------------------------------
1558 -- Get The record that is about to be deleted
1559 -- -----------------------------------------------------------------
1560    OPEN c_acct_row_info;
1561    FETCH c_acct_row_info
1562     INTO Recinfo;
1563 
1564 -- ------------------------------------------------------------------
1565 -- If the row information can not be attained then exit the procedure
1566 -- ------------------------------------------------------------------
1567    IF (c_acct_row_info%NOTFOUND) THEN
1568 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1569       IF (g_debug_mode = 'Y') THEN
1570          g_debug_msg := ' IGCCACLB -- Failure delete obtain acct info.....';
1571          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1572       END IF;
1573       RAISE NO_DATA_FOUND;
1574    END IF;
1575 
1576    CLOSE c_acct_row_info;
1577 
1578 -- -----------------------------------------------------------------
1579 -- Get the next history version number for the account line history
1580 -- -----------------------------------------------------------------
1581    OPEN c_cc_version_num;
1582    FETCH c_cc_version_num
1583     INTO l_version_num;
1584 
1585 -- ------------------------------------------------------------------
1586 -- If the version number can not be attained then exit the procedure
1587 -- ------------------------------------------------------------------
1588    IF (c_cc_version_num%NOTFOUND) THEN
1589 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1590       IF (g_debug_mode = 'Y') THEN
1591          g_debug_msg := ' IGCCACLB -- Failure delete getting version num.....';
1592          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1593       END IF;
1594       RAISE NO_DATA_FOUND;
1595    END IF;
1596 
1597    CLOSE c_cc_version_num;
1598 
1599 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1600    IF (g_debug_mode = 'Y') THEN
1601       g_debug_msg := ' IGCCACLB -- Inserting history record for Delete action account line.....';
1602       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1603    END IF;
1604 
1605 -- ----------------------------------------------------------------
1606 -- Insert the deleted history record for the account line
1607 -- ----------------------------------------------------------------
1608    IGC_CC_ACCT_LINE_HISTORY_PKG.Insert_Row(
1609                        l_api_version ,
1610                        FND_API.G_FALSE,
1611                        FND_API.G_FALSE,
1612                        p_validation_level,
1613                        l_return_status,
1614                        X_msg_count,
1615                        X_msg_data,
1616                        l_acct_row_id,
1617                        Recinfo.CC_Acct_Line_Id,
1618                        Recinfo.CC_Header_Id,
1619                        Recinfo.Parent_Header_Id,
1620                        Recinfo.Parent_Acct_Line_Id ,
1621                        Recinfo.CC_Acct_Line_Num,
1622                        l_Version_Num - 1 ,
1623                        l_action_flag,
1624                        Recinfo.CC_Charge_Code_Combination_Id,
1625                        Recinfo.CC_Budget_Code_Combination_Id,
1626                        Recinfo.CC_Acct_Entered_Amt ,
1627                        Recinfo.CC_Acct_Func_Amt,
1628                        Recinfo.CC_Acct_Desc ,
1629                        Recinfo.CC_Acct_Billed_Amt ,
1630                        Recinfo.CC_Acct_Unbilled_Amt,
1631                        Recinfo.CC_Acct_Taxable_Flag,
1632                        Recinfo.Tax_Id,
1633                        Recinfo.CC_Acct_Encmbrnc_Amt,
1634                        Recinfo.CC_Acct_Encmbrnc_Date,
1635                        Recinfo.CC_Acct_Encmbrnc_Status,
1636                        Recinfo.Project_Id,
1637                        Recinfo.Task_Id,
1638                        Recinfo.Expenditure_Type,
1639                        Recinfo.Expenditure_Org_Id,
1640                        Recinfo.Expenditure_Item_Date,
1641                        Recinfo.Last_Update_Date,
1642                        Recinfo.Last_Updated_By,
1643                        Recinfo.Last_Update_Login ,
1644                        Recinfo.Creation_Date ,
1645                        Recinfo.Created_By ,
1646                        Recinfo.Attribute1,
1647                        Recinfo.Attribute2,
1648                        Recinfo.Attribute3,
1649                        Recinfo.Attribute4,
1650                        Recinfo.Attribute5,
1651                        Recinfo.Attribute6,
1652                        Recinfo.Attribute7,
1653                        Recinfo.Attribute8,
1654                        Recinfo.Attribute9,
1655                        Recinfo.Attribute10,
1656                        Recinfo.Attribute11,
1657                        Recinfo.Attribute12,
1658                        Recinfo.Attribute13,
1659                        Recinfo.Attribute14,
1660                        Recinfo.Attribute15,
1661                        Recinfo.Context,
1662                        Recinfo.cc_func_withheld_amt,
1663                        Recinfo.cc_ent_withheld_amt,
1664                        G_FLAG,
1665                        Recinfo.Tax_Classif_code);
1666 
1667 -- ------------------------------------------------------------------
1668 -- Make sure that the insertion was a success
1669 -- ------------------------------------------------------------------
1670    IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1671 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1672       IF (g_debug_mode = 'Y') THEN
1673          g_debug_msg := ' IGCCACLB -- Failure returned from history delete action.....';
1674          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1675       END IF;
1676       RAISE FND_API.G_EXC_ERROR;
1677    END IF;
1678 
1679 -- ------------------------------------------------------------------
1680 -- Obtain the application ID for IGC to be used for the MRC check
1681 -- being enabled for this set of books.
1682 -- ------------------------------------------------------------------
1683    OPEN c_igc_app_id;
1684    FETCH c_igc_app_id
1685     INTO l_Application_Id;
1686 
1687 -- ------------------------------------------------------------------
1688 -- If the application ID can not be attained then exit the procedure
1689 -- ------------------------------------------------------------------
1690    IF (c_igc_app_id%NOTFOUND) THEN
1691 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1692       IF (g_debug_mode = 'Y') THEN
1693          g_debug_msg := ' IGCCACLB -- Failure obtaining application ID in delete operation...';
1694          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1695       END IF;
1696       RAISE FND_API.G_EXC_ERROR;
1697    END IF;
1698 
1699    CLOSE c_igc_app_id;
1700 
1701 -- ------------------------------------------------------------------
1702 -- Obtain the set of books, org id, and the conversion date for the
1703 -- CC Header record that the account line is associated to.
1704 -- ------------------------------------------------------------------
1705    OPEN c_cc_info;
1706    FETCH c_cc_info
1707     INTO l_Set_Of_Books_Id,
1708          l_Org_Id,
1709          l_Conversion_Date;
1710 
1711 
1712 -- ------------------------------------------------------------------
1713 -- Exit procedure if the values can not be obtained.
1714 -- ------------------------------------------------------------------
1715    IF (c_cc_info%NOTFOUND) THEN
1716 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1717       IF (g_debug_mode = 'Y') THEN
1718          g_debug_msg := ' IGCCACLB -- Failure obtaining CC Info conversion date in delete...';
1719          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1720       END IF;
1721       RAISE FND_API.G_EXC_ERROR;
1722    END IF;
1723 
1724    CLOSE c_cc_info;
1725 
1726 -- ------------------------------------------------------------------
1727 -- If the conversion date is NULL then fill in the value with the
1728 -- current system date.
1729 -- ------------------------------------------------------------------
1730 
1731    gl_mc_info.mrc_enabled (l_Set_Of_Books_Id,
1732                             101, /*--l_Application_Id, commented for MRC uptake*/
1733                            l_Org_Id,
1734                            Null,
1735                            l_MRC_Enabled);
1736 
1737 -- ------------------------------------------------------------------
1738 -- If MRC is enabled for this set of books being used then call the
1739 -- handler to insert all reporting set of books into the MRC
1740 -- table for the account line inserted.
1741 -- ------------------------------------------------------------------
1742    IF (l_MRC_Enabled = 'Y') THEN
1743 
1744 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1745       IF (g_debug_mode = 'Y') THEN
1746          g_debug_msg := ' IGCCACLB -- MRC Enabled so now deleting MRC info...';
1747          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1748       END IF;
1749 
1750 -- ------------------------------------------------------------------
1751 -- MRC Handler For IGC_CC_ACCT_LINES to insert all MRC records for
1752 -- the reporting set of books for this PRIMARY set of books.
1753 -- ------------------------------------------------------------------
1754       IGC_CC_MC_MAIN_PVT.get_rsobs_Acct_Lines (
1755                                    l_api_version,
1756                                    FND_API.G_FALSE,
1757                                    FND_API.G_FALSE,
1758                                    p_validation_level,
1759                                    l_return_status,
1760                                    X_msg_count,
1761                                    X_msg_data,
1762                                    Recinfo.cc_acct_line_id,
1763                                    l_Set_Of_Books_Id,
1764                                    101, /*--l_Application_Id, commented for MRC uptake*/
1765                                    l_org_Id,
1766                                    NVL(l_Conversion_Date, sysdate),
1767                                    0,
1768                                    0,
1769                                    0,
1770                                    l_action_flag);
1771 
1772 -- ------------------------------------------------------------------
1773 -- Make sure that the insertion was a success
1774 -- ------------------------------------------------------------------
1775        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1776 --          IF (IGC_MSGS_PKG.g_debug_mode) THEN
1777           IF (g_debug_mode = 'Y') THEN
1778              g_debug_msg := ' IGCCACLB -- Failure returned from MC.get_rsobs_Acct_Lines delete...';
1779              Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1780           END IF;
1781           RAISE FND_API.G_EXC_ERROR;
1782        END IF;
1783 
1784    END IF;
1785 
1786 -- ----------------------------------------------------------------
1787 -- Get all the associated Detail Payment Forcast Lines to the
1788 -- Account line to be deleted.  Then delete the associated PF
1789 -- Lines.
1790 -- ----------------------------------------------------------------
1791    OPEN c_get_all_pf_lines;
1792    FETCH c_get_all_pf_lines
1793     INTO l_pf_row_id;
1794 
1795    IF (c_get_all_pf_lines%FOUND) THEN
1796 
1797       WHILE (c_get_all_pf_lines%FOUND) LOOP
1798 
1799          IGC_CC_DET_PF_PKG.Delete_Row (l_api_version,
1800                                        FND_API.G_FALSE,
1801                                        FND_API.G_FALSE,
1802                                        p_validation_level,
1803                                        l_return_status,
1804                                        X_msg_count,
1805                                        X_msg_data,
1806                                        l_pf_row_id,
1807                                        l_global_flag);
1808 
1809 -- ------------------------------------------------------------------
1810 -- Make sure that the insertion was a success
1811 -- ------------------------------------------------------------------
1812          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1813 --            IF (IGC_MSGS_PKG.g_debug_mode) THEN
1814             IF (g_debug_mode = 'Y') THEN
1815                g_debug_msg := ' IGCCACLB -- Failure returned from Delete Row DET PF...';
1816                Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1817             END IF;
1818             RAISE FND_API.G_EXC_ERROR;
1819          END IF;
1820 
1821 -- ------------------------------------------------------------------
1822 -- Get the next row of Payment forcast record
1823 -- ------------------------------------------------------------------
1824          FETCH c_get_all_pf_lines
1825           INTO l_pf_row_id;
1826 
1827       END LOOP;
1828 
1829    END IF;
1830 
1831    CLOSE c_get_all_pf_lines;
1832 
1833 -- ----------------------------------------------------------------
1834 -- Delete the requested record from the acct line table
1835 -- ----------------------------------------------------------------
1836    DELETE
1837      FROM IGC_CC_ACCT_LINES
1838     WHERE rowid = p_Rowid;
1839 
1840 -- ------------------------------------------------------------------
1841 -- If the row can not be deleted then exit the procedure
1842 -- ------------------------------------------------------------------
1843    IF (SQL%NOTFOUND) THEN
1844 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1845       IF (g_debug_mode = 'Y') THEN
1846          g_debug_msg := ' IGCCACLB -- Failure delete not found.....';
1847          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1848       END IF;
1849       RAISE NO_DATA_FOUND;
1850    END IF;
1851 
1852 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1853    IF (g_debug_mode = 'Y') THEN
1854       g_debug_msg := ' IGCCACLB -- Deleted account line.....';
1855       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1856    END IF;
1857 
1858    G_FLAG := 'Y';
1859 
1860 -- -----------------------------------------------------------------
1861 -- If the records are to be commited in this procedure then
1862 -- commit the work now otherwise wait for the caller to do COMMIT.
1863 -- -----------------------------------------------------------------
1864    IF FND_API.To_Boolean ( p_commit ) THEN
1865 --      IF (IGC_MSGS_PKG.g_debug_mode) THEN
1866       IF (g_debug_mode = 'Y') THEN
1867          g_debug_msg := ' IGCCACLB -- Committing account line delete.....';
1868          Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1869       END IF;
1870       COMMIT WORK;
1871    END iF;
1872 
1873    FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1874                                p_data  => X_msg_data );
1875 
1876 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
1877    IF (g_debug_mode = 'Y') THEN
1878       g_debug_msg := ' IGCCACLB -- End of Delete Rowid ...' || p_rowid;
1879       Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1880    END IF;
1881 
1882 -- ------------------------------------------------------------
1883 -- Make sure (double check that all cursors are closed.
1884 -- ------------------------------------------------------------
1885    IF (c_acct_row_info%ISOPEN) THEN
1886       CLOSE c_acct_row_info;
1887    END IF;
1888    IF (c_cc_version_num%ISOPEN) THEN
1889       CLOSE c_cc_version_num;
1890    END IF;
1891    IF (c_igc_app_id%ISOPEN) THEN
1892       CLOSE c_igc_app_id;
1893    END IF;
1894    IF (c_cc_info%ISOPEN) THEN
1895       CLOSE c_cc_info;
1896    END IF;
1897    IF (c_get_all_pf_lines%ISOPEN) THEN
1898       CLOSE c_get_all_pf_lines;
1899    END IF;
1900 
1901    RETURN;
1902 
1903 EXCEPTION
1904 
1905   WHEN FND_API.G_EXC_ERROR THEN
1906 
1907     ROLLBACK TO Delete_Row_Pvt ;
1908     X_return_status := FND_API.G_RET_STS_ERROR;
1909 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1910     IF (g_debug_mode = 'Y') THEN
1911        g_debug_msg := ' IGCCACLB -- Failure Delete Execute Error Rowid ...' || p_rowid;
1912        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1913     END IF;
1914     IF (c_acct_row_info%ISOPEN) THEN
1915        CLOSE c_acct_row_info;
1916     END IF;
1917     IF (c_cc_version_num%ISOPEN) THEN
1918        CLOSE c_cc_version_num;
1919     END IF;
1920     IF (c_igc_app_id%ISOPEN) THEN
1921        CLOSE c_igc_app_id;
1922     END IF;
1923     IF (c_cc_info%ISOPEN) THEN
1924        CLOSE c_cc_info;
1925     END IF;
1926     IF (c_get_all_pf_lines%ISOPEN) THEN
1927        CLOSE c_get_all_pf_lines;
1928     END IF;
1929     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1930                                 p_data  => X_msg_data );
1931     IF (g_excep_level >=  g_debug_level ) THEN
1932        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_ERROR Exception Raised');
1933     END IF;
1934 
1935   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1936 
1937     ROLLBACK TO Delete_Row_Pvt ;
1938     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1939 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1940     IF (g_debug_mode = 'Y') THEN
1941        g_debug_msg := ' IGCCACLB -- Failure Delete Unexpected Error Rowid ...' || p_rowid;
1942        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1943     END IF;
1944     IF (c_acct_row_info%ISOPEN) THEN
1945        CLOSE c_acct_row_info;
1946     END IF;
1947     IF (c_cc_version_num%ISOPEN) THEN
1948        CLOSE c_cc_version_num;
1949     END IF;
1950     IF (c_igc_app_id%ISOPEN) THEN
1951        CLOSE c_igc_app_id;
1952     END IF;
1953     IF (c_cc_info%ISOPEN) THEN
1954        CLOSE c_cc_info;
1955     END IF;
1956     IF (c_get_all_pf_lines%ISOPEN) THEN
1957        CLOSE c_get_all_pf_lines;
1958     END IF;
1959     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1960                                 p_data  => X_msg_data );
1961     IF (g_excep_level >=  g_debug_level ) THEN
1962        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_UNEXPECTED_ERROR Exception Raised');
1963     END IF;
1964 
1965   WHEN OTHERS THEN
1966 
1967     ROLLBACK TO Delete_Row_Pvt ;
1968     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1969 --    IF (IGC_MSGS_PKG.g_debug_mode) THEN
1970     IF (g_debug_mode = 'Y') THEN
1971        g_debug_msg := ' IGCCACLB -- Failure Delete Others Error Rowid ...' || p_rowid;
1972        Output_Debug (l_full_path, p_debug_msg => g_debug_msg);
1973     END IF;
1974     IF (c_acct_row_info%ISOPEN) THEN
1975        CLOSE c_acct_row_info;
1976     END IF;
1977     IF (c_cc_version_num%ISOPEN) THEN
1978        CLOSE c_cc_version_num;
1979     END IF;
1980     IF (c_igc_app_id%ISOPEN) THEN
1981        CLOSE c_igc_app_id;
1982     END IF;
1983     IF (c_cc_info%ISOPEN) THEN
1984        CLOSE c_cc_info;
1985     END IF;
1986     IF (c_get_all_pf_lines%ISOPEN) THEN
1987        CLOSE c_get_all_pf_lines;
1988     END IF;
1989 
1990     IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1991       FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME,
1992                                 l_api_name);
1993     END if;
1994 
1995     FND_MSG_PUB.Count_And_Get ( p_count => X_msg_count,
1996                                 p_data  => X_msg_data );
1997     IF ( g_unexp_level >= g_debug_level ) THEN
1998       FND_MESSAGE.SET_NAME('IGC','IGC_LOGGING_UNEXP_ERROR');
1999       FND_MESSAGE.SET_TOKEN('CODE',SQLCODE);
2000       FND_MESSAGE.SET_TOKEN('MSG',  SQLERRM);
2001       FND_LOG.MESSAGE ( g_unexp_level,l_full_path, TRUE);
2002     END IF;
2003 
2004 END Delete_Row;
2005 
2006 END IGC_CC_ACCT_LINES_PKG;