DBA Data[Home] [Help]

PACKAGE BODY: APPS.LNS_XLA_EVENTS

Source


1 PACKAGE BODY LNS_XLA_EVENTS AS
2 /* $Header: LNS_XLA_EVENTS_B.pls 120.8.12010000.3 2008/09/11 21:56:49 scherkas ship $ */
3 
4  --------------------------------------------
5  -- declaration of global variables and types
6  --------------------------------------------
7  G_DEBUG_COUNT                       NUMBER := 0;
8  G_DEBUG                             BOOLEAN := FALSE;
9  G_FILE_NAME   CONSTANT VARCHAR2(30) := 'LNS_XLA_EVENTS_B.pls';
10 
11  G_PKG_NAME                          CONSTANT VARCHAR2(30) := 'LNS_XLA_EVENTS';
12  G_DAYS_COUNT                        NUMBER;
13  G_DAYS_IN_YEAR                      NUMBER;
14 
15  --------------------------------------------
16  -- internal package routines
17  --------------------------------------------
18 procedure logMessage(log_level in number
19                     ,module    in varchar2
20                     ,message   in varchar2)
21 is
22 
23 begin
24 
25     IF log_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
26         FND_LOG.STRING(log_level, module, message);
27         if FND_GLOBAL.Conc_Request_Id is not null then
28             fnd_file.put_line(FND_FILE.LOG, message);
29         end if;
30     END IF;
31 
32 end;
33 
34 
35 
36 /*=========================================================================
37 || PUBLIC PROCEDURE create_event
38 ||
39 || DESCRIPTION
40 || Overview: will write to xla_events table
41 ||
42 || PSEUDO CODE/LOGIC
43 ||
44 || PARAMETERS
45 || Parameter: p_loan_id => loan_id
46 ||           ,p_event_type_code    => seeded code for loans "APPROVED" "IN_FUNDING"
47 ||           ,p_event_date         => most likely GL_DATE
48 ||           ,p_event_status       => event Status
49 ||             CONSTANT  = 'U';   -- event status:unprocessed
50 ||             CONSTANT  = 'I';   -- event status:incomplete
51 ||             CONSTANT  = 'N';   -- event status:noaction
52 ||
53 || Return value:
54 ||               standard
55 || KNOWN ISSUES
56 ||
57 || NOTES
58 ||
59 || MODIFICATION HISTORY
60 || Date                  Author            Description of Changes
61 || 4/11/2005             raverma           Created
62 ||
63  *=======================================================================*/
64 procedure create_event(p_loan_id            in  number
65 					  ,p_disb_header_id     in  number
66                       ,p_event_type_code    in  varchar
67                       ,p_event_date         in  date
68                       ,p_event_status       in  varchar2
69                       ,p_init_msg_list      in  varchar2
70                       ,p_commit             in  varchar2
71 					  ,p_bc_flag            in  varchar2
72                       ,x_event_id           out nocopy number
73                       ,x_return_status      out nocopy varchar2
74                       ,x_msg_count          out nocopy number
75                       ,x_msg_data           out nocopy varchar2)
76 is
77 
78     l_api_name         varchar2(15);
79     l_return_status    VARCHAR2(1);
80     l_msg_count        NUMBER;
81     l_msg_data         VARCHAR2(32767);
82 
83     l_event_id         integer;
84     l_loan_details     XLA_EVENTS_PUB_PKG.t_event_source_info;
85     l_security_context XLA_EVENTS_PUB_PKG.t_security;
86     l_legal_entity_id  number;
87     l_sob_id           number;
88     l_loan_number      varchar2(60);
89     l_disb_header_id   number;
90     l_event_exists     boolean;
91     l_event_info       xla_events_pub_pkg.t_event_info;
92 
93     CURSOR C_Get_Loan_Info (X_Loan_Id NUMBER) IS
94     SELECT LEGAL_ENTITY_ID
95             ,LOAN_NUMBER
96         FROM LNS_LOAN_HEADERS_ALL
97     WHERE LOAN_ID = X_Loan_Id;
98 
99     cursor c_sob_id is
100     select so.ledger_id
101         from lns_system_options sb,
102             gl_ledgers so
103     where sb.set_of_books_id = so.ledger_id;
104 
105     CURSOR C_Get_Event (p_application_id NUMBER,
106                         p_ledger_id NUMBER,
107                         p_entity_type_code VARCHAR2,
108                         p_source_id_int_1 NUMBER,
109                         p_source_id_int_2 NUMBER,
110                         p_valuation_method VARCHAR2) IS
111     SELECT xe.event_id
112     FROM  xla_transaction_entities   xte
113           ,xla_events     xe
114           ,xla_entity_types_b xet
115     WHERE xte.application_id                  = p_application_id
116         AND xte.ledger_id                       = p_ledger_id
117         AND xte.entity_code                     = p_entity_type_code
118         AND NVL(xte.source_id_int_1,-99)   = NVL(p_source_id_int_1,-99)
119         AND NVL(xte.source_id_int_2,-99)   = NVL(p_source_id_int_2,-99)
120         AND NVL(xte.valuation_method,' ')    = NVL(p_valuation_method,' ')
121         AND xe.entity_id                        = xte.entity_id
122         AND xet.application_id                  = xte.application_id
123         AND xte.entity_code                     = xet.entity_code;
124 
125 begin
126 
127     l_api_name           := 'create_event';
128     logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - BEGIN');
129 
130     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Input:');
131     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'loan_id = ' || p_loan_id);
132     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_disb_header_id = ' || p_disb_header_id);
133     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_type_code = ' || p_event_type_code);
134     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_date = ' || p_event_date);
135     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_status = ' || p_event_status);
136     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_bc_flag = ' || p_bc_flag);
137 
138     -- Standard Start of API savepoint
139     SAVEPOINT create_event;
140 
141     -- Initialize message list IF p_init_msg_list is set to TRUE.
142     IF FND_API.to_Boolean(p_init_msg_list) THEN
143         FND_MSG_PUB.initialize;
144     END IF;
145 
146     -- Initialize API return status to SUCCESS
147     x_return_status := FND_API.G_RET_STS_SUCCESS;
148 
149     -- ---------------------------------------------------------------------
150     -- Api body
151     -- ---------------------------------------------------------------------
152 
153     open C_Get_Loan_Info(p_loan_id);
154     fetch C_Get_Loan_Info into l_legal_entity_id, l_loan_number;
155     close C_Get_Loan_Info;
156 
157     open c_sob_id;
158     fetch c_sob_id into l_sob_id;
159     close c_sob_id;
160 
161     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_number = ' || l_loan_number);
162     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_legal_entity_id = ' || l_legal_entity_id);
163     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_sob_id = ' || l_sob_id);
164 
165     -- force caller to pass disbursement_id
166     if p_disb_header_id is null then
167         FND_MESSAGE.SET_NAME('LNS', 'LNS_API_OTHERS_EXCEP');
168         FND_MESSAGE.SET_TOKEN('ERROR' ,'Failed API call: ' || l_api_name || ' SQLERRM: ' || SQLERRM);
169         FND_MSG_PUB.ADD;
170         RAISE FND_API.G_EXC_ERROR;
171     end if;
172 
173     -- initialize any variables here
174     l_loan_details.application_id          := 206;   -- XLA registered application
175     l_loan_details.ledger_id               := l_sob_id;  -- l_sob_id;
176     l_loan_details.legal_entity_id         := l_legal_entity_id;
177     l_loan_details.source_id_int_1         := p_loan_id; -- loan_id
178     l_loan_details.entity_type_code        := 'LOANS';
179     l_loan_details.transaction_number      := l_loan_number;
180     l_loan_details.source_id_int_2         := p_disb_header_id; -- disb_header_id
181     l_loan_details.source_application_id   := 206;   -- XLA registered application
182 
183     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_1 = ' || l_loan_details.source_id_int_1);
184     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_2 = ' || l_loan_details.source_id_int_2);
185     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.transaction_number = ' || l_loan_details.transaction_number);
186     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_application_id = ' || l_loan_details.source_application_id);
187     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.entity_type_code = ' || l_loan_details.entity_type_code);
188 
189 
190     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Checking if event already exists...');
191     l_event_exists :=  xla_events_pub_pkg.event_exists (p_event_source_info => l_loan_details
192                                                         ,p_event_type_code   => p_event_type_code
193                                                         ,p_valuation_method  => null
194                                                         ,p_security_context  => l_security_context);
195     if not l_event_exists then
196         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Event doesnt exist');
197         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Calling XLA_EVENTS_PUB_PKG.create_event...');
198 	    x_event_id := XLA_EVENTS_PUB_PKG.create_event(p_event_source_info      => l_loan_details
199 	                                                ,p_event_type_code        => p_event_type_code  -- event type code
200 	                                                ,p_event_date             => p_event_date       -- gl date
201 	                                                ,p_event_status_code      => p_event_status     -- event status
202 	                                                ,p_event_number           => NULL
203 	                                                ,p_reference_info         => null
204 	                                                ,p_valuation_method       => null
205 	                                                ,p_security_context       => l_security_context
206                                                     ,p_budgetary_control_flag => p_bc_flag);
207         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'x_event_id = ' || x_event_id);
208         if x_event_id is null then
209             FND_MESSAGE.SET_NAME('LNS', 'LNS_API_OTHERS_EXCEP');
210             FND_MESSAGE.SET_TOKEN('ERROR' ,'Failed to create Loans XLA event ' || p_event_type_code);
211             FND_MSG_PUB.ADD;
212             logMessage(FND_LOG.LEVEL_UNEXPECTED, G_PKG_NAME, FND_MSG_PUB.Get(p_encoded => 'F'));
213             RAISE FND_API.G_EXC_ERROR;
214         end if;
215         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Successfully created Loans XLA event ' || p_event_type_code);
216     else
217         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Event already exists');
218 
219         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Querying event_id...');
220         OPEN C_Get_Event (p_application_id => l_loan_details.application_id,
221                             p_ledger_id => l_sob_id,
222                             p_entity_type_code => l_loan_details.entity_type_code,
223                             p_source_id_int_1 => l_loan_details.source_id_int_1,
224                             p_source_id_int_2 => l_loan_details.source_id_int_2,
225                             p_valuation_method => null);
226         fetch C_Get_Event into x_event_id;
227         CLOSE C_Get_Event;
228         logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'x_event_id = ' || x_event_id);
229 
230         if x_event_id is null then
231             FND_MESSAGE.SET_NAME('LNS', 'LNS_API_OTHERS_EXCEP');
232             FND_MESSAGE.SET_TOKEN('ERROR' ,'Failed to find Loans XLA event ' || p_event_type_code);
233             FND_MSG_PUB.ADD;
234             logMessage(FND_LOG.LEVEL_UNEXPECTED, G_PKG_NAME, FND_MSG_PUB.Get(p_encoded => 'F'));
235             RAISE FND_API.G_EXC_ERROR;
236         end if;
237     end if;
238 
239     -- ---------------------------------------------------------------------
240     -- End of API body
241     -- ---------------------------------------------------------------------
242     FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data  => x_msg_data);
243 
244     logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - END');
245 
246 EXCEPTION
247     WHEN FND_API.G_EXC_ERROR THEN
248             x_return_status := FND_API.G_RET_STS_ERROR;
249             x_msg_count := l_msg_count;
250             x_msg_data  := l_msg_data;
251             FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
252             logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
253             ROLLBACK TO create_event;
254 
255         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
256             x_return_status := FND_API.G_RET_STS_ERROR;
257             x_msg_count := l_msg_count;
258             x_msg_data  := l_msg_data;
259             FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
260             logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
261             ROLLBACK TO create_event;
262 
263     WHEN OTHERS THEN
264             x_return_status := FND_API.G_RET_STS_ERROR;
265             x_msg_count := l_msg_count;
266             x_msg_data  := l_msg_data;
267             FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
268             logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
269             ROLLBACK TO create_event;
270 
271 end create_event;
272 
273 /*=========================================================================
274 || PUBLIC PROCEDURE update_event
275 ||
276 || DESCRIPTION
277 || Overview: will write to xla_events table
278 ||
279 || PSEUDO CODE/LOGIC
280 ||
281 || PARAMETERS
282 || Parameter: p_loan_id => loan_id
283 ||           ,p_event_type_code    => seeded code for loans "APPROVED" "IN_FUNDING"
284 ||           ,p_event_date         => most likely GL_DATE
285 ||           ,p_event_status       => event Status
286 ||             CONSTANT  = 'U';   -- event status:unprocessed
287 ||             CONSTANT  = 'I';   -- event status:incomplete
288 ||             CONSTANT  = 'N';   -- event status:noaction
289 ||
290 || Return value:
291 ||               standard
292 || KNOWN ISSUES
293 ||
294 || NOTES
295 ||
296 || MODIFICATION HISTORY
297 || Date                  Author            Description of Changes
298 || 4/11/2005             raverma           Created
299 ||
300  *=======================================================================*/
301 procedure update_event(p_loan_id            in  number
302 					  ,p_disb_header_id     in  number
303                       ,p_event_id           in  number
304                       ,p_event_type_code    in  varchar
305                       ,p_event_date         in  date
306                       ,p_event_status       in  varchar2
307                       ,p_init_msg_list      in  varchar2
308                       ,p_commit             in  varchar2
309                       ,x_return_status      out nocopy varchar2
310                       ,x_msg_count          out nocopy number
311                       ,x_msg_data           out nocopy varchar2)
312 is
313   l_api_name         varchar2(15);
314   l_return_status    VARCHAR2(1);
315   l_msg_count        NUMBER;
316   l_msg_data         VARCHAR2(32767);
317 
318   --l_event_id         integer;
319   l_loan_details     XLA_EVENTS_PUB_PKG.t_event_source_info;
320   l_security_context XLA_EVENTS_PUB_PKG.t_security;
321   l_legal_entity_id  number;
322   l_sob_id           number;
323 
324   CURSOR C_Get_Loan_Info (X_Loan_Id NUMBER) IS
325   SELECT LEGAL_ENTITY_ID
326     FROM LNS_LOAN_HEADERS
327    WHERE LOAN_ID = X_Loan_Id;
328 
329   cursor c_sob_id is
330   select so.set_of_books_id
331     from lns_system_options sb,
332          gl_sets_of_books so
333    where sb.set_of_books_id = so.set_of_books_id;
334 
335 begin
336    l_api_name           := 'update_event';
337    logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - BEGIN');
338    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Input:');
339    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'event_id ' || p_event_id);
340    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_type_code ' || p_event_type_code);
341    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_date ' || p_event_date);
342    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'p_event_status ' || p_event_status);
343 
344    -- Standard Start of API savepoint
348    IF FND_API.to_Boolean(p_init_msg_list) THEN
345    SAVEPOINT update_event;
346 
347    -- Initialize message list IF p_init_msg_list is set to TRUE.
349        FND_MSG_PUB.initialize;
350    END IF;
351 
352    -- Initialize API return status to SUCCESS
353    x_return_status := FND_API.G_RET_STS_SUCCESS;
354 
355    -- ---------------------------------------------------------------------
356    -- Api body
357    -- ---------------------------------------------------------------------
358    open C_Get_Loan_Info(p_loan_id);
359    fetch C_Get_Loan_Info into l_legal_entity_id;
360    close C_Get_Loan_Info;
361 
362    open c_sob_id;
363    fetch c_sob_id into l_sob_id;
364    close c_sob_id;
365 
366     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_legal_entity_id = ' || l_legal_entity_id);
367     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_sob_id = ' || l_sob_id);
368 
369    -- initialize any variables here
370    l_loan_details.application_id   := 206;   -- XLA registered application
371    l_loan_details.legal_entity_id  := l_legal_entity_id;     --
372    l_loan_details.ledger_id        := l_sob_id;     --
373    l_loan_details.source_id_int_1  := p_loan_id; -- loan_id
374    l_loan_details.entity_type_code := 'LOANS';
375    l_loan_details.source_id_int_2  := p_disb_header_id; -- loan_id
376 
377     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_1 = ' || l_loan_details.source_id_int_1);
378     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_2 = ' || l_loan_details.source_id_int_2);
379     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.entity_type_code = ' || l_loan_details.entity_type_code);
380 
381    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Calling XLA_EVENTS_PUB_PKG.Update_event...');
382    XLA_EVENTS_PUB_PKG.Update_event(p_event_source_info   => l_loan_details
383                                   ,p_event_id            => p_event_id
384                                   ,p_event_type_code     => p_event_type_code
385                                   ,p_event_date          => p_event_date
386                                   ,p_event_status_code   => p_event_status
387                                   ,p_valuation_method    => null
388                                   ,p_security_context    => l_security_context);
389 
390    -- ---------------------------------------------------------------------
391    -- End of API body
392    -- ---------------------------------------------------------------------
393    FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data  => x_msg_data);
394 
395    logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - END');
396 
397    EXCEPTION
398        WHEN FND_API.G_EXC_ERROR THEN
399              x_return_status := FND_API.G_RET_STS_ERROR;
400              x_msg_count := l_msg_count;
401              x_msg_data  := l_msg_data;
402              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
403              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
404              ROLLBACK TO update_event;
405 
406         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
407              x_return_status := FND_API.G_RET_STS_ERROR;
408              x_msg_count := l_msg_count;
409              x_msg_data  := l_msg_data;
410              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
411              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
412              ROLLBACK TO update_event;
413 
414        WHEN OTHERS THEN
415              x_return_status := FND_API.G_RET_STS_ERROR;
416              x_msg_count := l_msg_count;
417              x_msg_data  := l_msg_data;
418              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
419              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
420              ROLLBACK TO update_event;
421 
422 end update_event;
423 
424 /*=========================================================================
425 || PUBLIC PROCEDURE delete_event
426 ||
427 || DESCRIPTION
428 || Overview: will delete events from xla_events table
429 ||
430 || PSEUDO CODE/LOGIC
431 ||
432 || PARAMETERS
433 || Parameter: p_event_id => event_id
434 ||
435 || Return value:
436 ||               standard
437 || KNOWN ISSUES
438 ||
439 || NOTES
440 ||
441 || MODIFICATION HISTORY
442 || Date                  Author            Description of Changes
443 || 4/11/2005             raverma           Created
444 ||
445  *=======================================================================*/
446 procedure delete_event(p_loan_id            in  number
447 											,p_disb_header_id     in  number
448                       ,p_event_id           in  number
449                       ,p_init_msg_list      in  varchar2
450                       ,p_commit             in  varchar2
451                       ,x_return_status      out nocopy varchar2
452                       ,x_msg_count          out nocopy number
453                       ,x_msg_data           out nocopy varchar2)
454 is
455   l_api_name         varchar2(15);
456   l_return_status    VARCHAR2(1);
457   l_msg_count        NUMBER;
458   l_msg_data         VARCHAR2(32767);
459 
460   CURSOR C_Get_Loan_Info (X_Loan_Id NUMBER) IS
461   SELECT LEGAL_ENTITY_ID
462     FROM LNS_LOAN_HEADERS
463    WHERE LOAN_ID = X_Loan_Id;
464 
465   cursor c_sob_id is
466   select so.set_of_books_id
467     from lns_system_options sb,
468          gl_sets_of_books so
469    where sb.set_of_books_id = so.set_of_books_id;
470 
471   l_loan_details     XLA_EVENTS_PUB_PKG.t_event_source_info;
472   l_security_context XLA_EVENTS_PUB_PKG.t_security;
473   l_legal_entity_id  number;
474   l_sob_id           number;
475 
476 begin
477    l_api_name           := 'delete_event';
478    logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - BEGIN');
479    logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - event_id ' || p_event_id);
480 
481    -- Standard Start of API savepoint
482    SAVEPOINT delete_event;
483 
484    -- Initialize message list IF p_init_msg_list is set to TRUE.
485    IF FND_API.to_Boolean(p_init_msg_list) THEN
486        FND_MSG_PUB.initialize;
487    END IF;
488 
489    -- Initialize API return status to SUCCESS
490    x_return_status := FND_API.G_RET_STS_SUCCESS;
491 
492    -- ---------------------------------------------------------------------
493    -- Api body
494    -- ---------------------------------------------------------------------
495 
496    open C_Get_Loan_Info(p_loan_id);
497    fetch C_Get_Loan_Info into l_legal_entity_id;
498    close C_Get_Loan_Info;
499 
500    open c_sob_id;
501    fetch c_sob_id into l_sob_id;
502    close c_sob_id;
503 
504     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_legal_entity_id = ' || l_legal_entity_id);
505     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_sob_id = ' || l_sob_id);
506 
507    -- initialize any variables here
508    l_loan_details.application_id   := 206;                -- XLA registered application
509    l_loan_details.legal_entity_id  := l_legal_entity_id;  --
510    l_loan_details.ledger_id        := l_sob_id;           --
511    l_loan_details.source_id_int_1  := p_loan_id;          -- loan_id
512    l_loan_details.entity_type_code := 'LOANS';
513    l_loan_details.source_id_int_2  := p_disb_header_id;          -- loan_id
514 
515     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_1 = ' || l_loan_details.source_id_int_1);
516     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.source_id_int_2 = ' || l_loan_details.source_id_int_2);
517     logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'l_loan_details.entity_type_code = ' || l_loan_details.entity_type_code);
518 
519    logMessage(FND_LOG.LEVEL_STATEMENT, G_PKG_NAME, 'Calling XLA_EVENTS_PUB_PKG.delete_event...');
520    XLA_EVENTS_PUB_PKG.delete_event
521    (p_event_source_info            => l_loan_details
522    ,p_event_id                     => p_event_id
523    ,p_valuation_method             => null
524    ,p_security_context             => l_security_context);
525 
526    -- ---------------------------------------------------------------------
527    -- End of API body
528    -- ---------------------------------------------------------------------
529    FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data  => x_msg_data);
530 
531    logMessage(FND_LOG.LEVEL_PROCEDURE, G_PKG_NAME, l_api_name || ' - END');
532 
533    EXCEPTION
534        WHEN FND_API.G_EXC_ERROR THEN
535              x_return_status := FND_API.G_RET_STS_ERROR;
536              x_msg_count := l_msg_count;
537              x_msg_data  := l_msg_data;
538              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
539              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
540              ROLLBACK TO delete_event;
541 
542         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
543              x_return_status := FND_API.G_RET_STS_ERROR;
544              x_msg_count := l_msg_count;
545              x_msg_data  := l_msg_data;
546              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
547              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
548              ROLLBACK TO delete_event;
549 
550        WHEN OTHERS THEN
551              x_return_status := FND_API.G_RET_STS_ERROR;
552              x_msg_count := l_msg_count;
553              x_msg_data  := l_msg_data;
554              FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
555              logMessage(FND_LOG.LEVEL_ERROR, G_PKG_NAME, sqlerrm);
556              ROLLBACK TO delete_event;
557 
558 end delete_event;
559 
560 end lns_xla_events;