DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGC_CC_DET_PF_PKG

Source


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