DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_DELETION_PUB

Source


1 PACKAGE BODY FA_DELETION_PUB as
2 /* $Header: FAPDELB.pls 120.17 2011/11/08 10:44:38 gigupta ship $   */
3 
4 --*********************** Global constants ******************************--
5 
6 G_PKG_NAME      CONSTANT   varchar2(30) := 'FA_DELETION_PUB';
7 G_API_NAME      CONSTANT   varchar2(30) := 'Deletion API';
8 G_API_VERSION   CONSTANT   number       := 1.0;
9 
10 g_log_level_rec fa_api_types.log_level_rec_type;
11 
12 --*********************** Private functions ******************************--
13 
14 -- private declaration for books (mrc) wrapper
15 
16 FUNCTION do_all_books
17    (px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
18     p_asset_desc_rec           IN     FA_API_TYPES.asset_desc_rec_type,
19     p_asset_type_rec           IN     FA_API_TYPES.asset_type_rec_type,
20     p_asset_cat_rec            IN     FA_API_TYPES.asset_cat_rec_type,
21     p_validation_level         IN     NUMBER,
22     p_log_level_rec            IN     FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN;
23 
24 FUNCTION delete_asset_events
25         (px_asset_hdr_rec      IN     FA_API_TYPES.asset_hdr_rec_type
26         ,p_asset_type_rec      IN     fa_api_types.asset_type_rec_type
27         ,p_log_level_rec       IN     fa_api_types.log_level_rec_type default null) RETURN BOOLEAN;
28 
29 --*********************** Public procedures ******************************--
30 
31 PROCEDURE do_delete
32    (p_api_version              IN     NUMBER,
33     p_init_msg_list            IN     VARCHAR2 := FND_API.G_FALSE,
34     p_commit                   IN     VARCHAR2 := FND_API.G_FALSE,
35     p_validation_level         IN     NUMBER   := FND_API.G_VALID_LEVEL_FULL,
36     p_calling_fn               IN     VARCHAR2,
37     x_return_status               OUT NOCOPY VARCHAR2,
38     x_msg_count                   OUT NOCOPY NUMBER,
39     x_msg_data                    OUT NOCOPY VARCHAR2,
40 
41     px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type) IS
42 
43    CURSOR c_tax_books IS
44     select distinct book_type_code
45       from fa_books
46      where asset_id = px_asset_hdr_rec.asset_id
47    /*code fix for bug no.3768406.Changed the field from date_effective to date_ineffective*/
48        and date_ineffective is null;
49 
50    l_reporting_flag          varchar2(1);
51    l_inv_count               number := 0;
52    l_rate_count              number := 0;
53    l_deprn_count             number := 0;
54    l_count                   number := 0;
55 
56    l_asset_desc_rec          FA_API_TYPES.asset_desc_rec_type;
57    l_asset_type_rec          FA_API_TYPES.asset_type_rec_type;
58    l_asset_cat_rec           FA_API_TYPES.asset_cat_rec_type;
59 
60    -- used for tax book loop
61    l_asset_hdr_rec           FA_API_TYPES.asset_hdr_rec_type;
62    l_tax_book_tbl            FA_CACHE_PKG.fazctbk_tbl_type;
63    l_tax_index               NUMBER;  -- index for tax loop
64 
65    l_calling_fn              VARCHAR2(35) := 'fa_deletion_pub.do_delete';
66    del_err                   EXCEPTION;
67 
68 
69 BEGIN
70 
71    SAVEPOINT do_delete;
72 
73    if (not g_log_level_rec.initialized) then
74       if (NOT fa_util_pub.get_log_level_rec (
75                 x_log_level_rec =>  g_log_level_rec
76       )) then
77          raise del_err;
78       end if;
79    end if;
80 
81    -- Initialize message list if p_init_msg_list is set to TRUE.
82    if (fnd_api.to_boolean(p_init_msg_list)) then
83         -- initialize error message stack.
84         fa_srvr_msg.init_server_message;
85 
86         -- initialize debug message stack.
87         fa_debug_pkg.initialize;
88    end if;
89 
90    -- Check version of the API
91    -- Standard call to check for API call compatibility.
92    if NOT fnd_api.compatible_api_call (
93           G_API_VERSION,
94           p_api_version,
95           G_API_NAME,
96           G_PKG_NAME
97          ) then
98       x_return_status := FND_API.G_RET_STS_ERROR;
99       raise del_err;
100    end if;
101 
102    -- check to see if the asset is populated
103    if (px_asset_hdr_rec.asset_id is null) then
104       raise del_err;
105    end if;
106 
107 
108    -- check to see if the book is populated
109    -- if not assume corporate
110    if (px_asset_hdr_rec.book_type_code is null) then
111 
112       select bk.book_type_code
113         into px_asset_hdr_rec.book_type_code
114         from fa_books bk,
115              fa_book_controls bc
116        where bk.asset_id = px_asset_hdr_rec.asset_id
117          and bk.date_ineffective is null
118          and bk.book_type_code = bc.book_type_code
119          and bc.book_class = 'CORPORATE';
120 
121    end if;
122 
123 
124    -- call the cache for the primary transaction book
125    if NOT fa_cache_pkg.fazcbc(X_book => px_asset_hdr_rec.book_type_code, p_log_level_rec => g_log_level_rec) then
126       raise del_err;
127    end if;
128 
129    px_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
130 
131    -- verify the asset exist in the book already
132    if not FA_ASSET_VAL_PVT.validate_asset_book
133               (p_transaction_type_code      => 'ADJUSTMENT',
134                p_book_type_code             => px_asset_hdr_rec.book_type_code,
135                p_asset_id                   => px_asset_hdr_rec.asset_id,
136                p_calling_fn                 => l_calling_fn
137               , p_log_level_rec => g_log_level_rec) then
138       raise del_err;
139    end if;
140 
141    -- Account for transaction submitted from a responsibility
142    -- that is not tied to a SOB_ID by getting the value from
143    -- the book struct
144 
145    -- Get the book type code P,R or N
146    if not fa_cache_pkg.fazcsob
147       (X_set_of_books_id   => px_asset_hdr_rec.set_of_books_id,
148        X_mrc_sob_type_code => l_reporting_flag
149       , p_log_level_rec => g_log_level_rec) then
150       raise del_err;
151    end if;
152 
153    --  Error out if the program is submitted from the Reporting Responsibility
154    --  No transaction permitted directly on reporting books.
155 
156    IF l_reporting_flag = 'R' THEN
157       fa_srvr_msg.add_message
158           (calling_fn => l_calling_fn,
159            name => 'MRC_OSP_INVALID_BOOK_TYPE', p_log_level_rec => g_log_level_rec);
160       raise del_err;
161    END IF;
162 
163    -- end initial MRC validation
164 
165    -- pop the structs for the non-fin information needed for trx
166    if not FA_UTIL_PVT.get_asset_desc_rec
167           (p_asset_hdr_rec         => px_asset_hdr_rec,
168            px_asset_desc_rec       => l_asset_desc_rec
169           , p_log_level_rec => g_log_level_rec) then
170       raise del_err;
171    end if;
172 
173    if not FA_UTIL_PVT.get_asset_type_rec
174           (p_asset_hdr_rec         => px_asset_hdr_rec,
175            px_asset_type_rec       => l_asset_type_rec,
176            p_date_effective        => null
177           , p_log_level_rec => g_log_level_rec) then
178       raise del_err;
179    end if;
180 
181    if not FA_UTIL_PVT.get_asset_cat_rec
182           (p_asset_hdr_rec         => px_asset_hdr_rec,
183            px_asset_cat_rec        => l_asset_cat_rec,
184            p_date_effective        => null
185           , p_log_level_rec => g_log_level_rec) then
186       raise del_err;
187    end if;
188 
189 
190    -- cache the category info
191    if not fa_cache_pkg.fazcat(X_cat_id => l_asset_cat_rec.category_id, p_log_level_rec => g_log_level_rec)  then
192       raise del_err;
193    end if;
194 
195 
196    -- call the mrc wrapper for the transaction book
197    if not do_all_books
198       (px_asset_hdr_rec           => px_asset_hdr_rec,
199        p_asset_type_rec           => l_asset_type_rec,
200        p_asset_desc_rec           => l_asset_desc_rec,
201        p_asset_cat_rec            => l_asset_cat_rec,
202        p_validation_level         => p_validation_level,
203        p_log_level_rec            => g_log_level_rec
204        )then
205       raise del_err;
206    end if;
207 
208    if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
209 
210       -- note: don't want to use fazctbk cache here
211       --       because the asset may exist in ineffective books
212 
213       for l_tax_rec in c_tax_books loop
214 
215          l_asset_hdr_rec                   := px_asset_hdr_rec;
216          l_asset_hdr_rec.book_type_code    := l_tax_rec.book_type_code;
217 
218          -- cache the book information for the tax book
219          if (NOT fa_cache_pkg.fazcbc(X_book => l_tax_rec.book_type_code, p_log_level_rec => g_log_level_rec)) then
220             raise del_err;
221          end if;
222 	 l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id; --Bug 10306673
223          if not do_all_books
224             (px_asset_hdr_rec           => l_asset_hdr_rec ,         -- tax
225              p_asset_type_rec           => l_asset_type_rec,
226              p_asset_desc_rec           => l_asset_desc_rec,
227              p_asset_cat_rec            => l_asset_cat_rec,
228              p_validation_level         => p_validation_level,
229              p_log_level_rec            => g_log_level_rec
230             ) then
231             raise del_err;
232          end if;
233 
234       end loop; -- tax books
235 
236    end if; -- corporate book
237 
238    -- commit if p_commit is TRUE.
239    if (fnd_api.to_boolean (p_commit)) then
240         COMMIT WORK;
241    end if;
242 
243    x_return_status :=  FND_API.G_RET_STS_SUCCESS;
244 
245 
246 EXCEPTION
247 
248    when del_err then
249       ROLLBACK TO do_delete;
250 
251       fa_srvr_msg.add_message(calling_fn => l_calling_fn, p_log_level_rec => g_log_level_rec);
252 
253       -- do not retrieve / clear messaging when this is being called
254       -- from reclass api - allow calling util to dump them
255       FND_MSG_PUB.count_and_get (
256             p_count => x_msg_count,
257             p_data  => x_msg_data
258          );
259       x_return_status :=  FND_API.G_RET_STS_ERROR;
260 
261    when others then
262       ROLLBACK TO do_delete;
263 
264       fa_srvr_msg.add_sql_error(
265               calling_fn => l_calling_fn, p_log_level_rec => g_log_level_rec);
266 
267       -- do not retrieve / clear messaging when this is being called
268       -- from reclass api - allow calling util to dump them
269       FND_MSG_PUB.count_and_get (
270             p_count => x_msg_count,
271             p_data  => x_msg_data
272          );
273 
274       x_return_status :=  FND_API.G_RET_STS_ERROR;
275 
276 END do_delete;
277 
278 -----------------------------------------------------------------------------
279 
280 -- Books (MRC) Wrapper - called from public API above
281 --
282 -- For non mrc books, this just calls the private API with provided params
283 -- For MRC, it processes the primary and then loops through each reporting
284 -- book calling the private api for each.
285 
286 
287 FUNCTION do_all_books
288    (px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
289     p_asset_desc_rec           IN     FA_API_TYPES.asset_desc_rec_type,
290     p_asset_type_rec           IN     FA_API_TYPES.asset_type_rec_type,
291     p_asset_cat_rec            IN     FA_API_TYPES.asset_cat_rec_type,
292     p_validation_level         IN     NUMBER
293    , p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN IS
294 
295    -- used for calling private api for reporting books
296    l_asset_hdr_rec            FA_API_TYPES.asset_hdr_rec_type;
297 
298    l_period_rec               FA_API_TYPES.period_rec_type;
299    l_sob_tbl                  FA_CACHE_PKG.fazcrsob_sob_tbl_type;
300 
301    -- used for local runs
302    l_responsibility_id       number;
303    l_application_id          number;
304 
305    l_rowid                   varchar2(120);
306 
307    l_calling_fn              varchar2(30) := 'fa_delete_pub.do_all_books';
308    del_err                   EXCEPTION;
309    g_release                  number  := fa_cache_pkg.fazarel_release;
310    -- Added as a result of High Cost SQL drill bugfix 3116047 msiddiqu
311    Cursor C1 is
312    SELECT INVOICE_TRANSACTION_ID_IN,
313           INVOICE_TRANSACTION_ID_OUT
314    FROM FA_ASSET_INVOICES
315    WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
316 
317 BEGIN
318 
319    -- only call transaction approval
320    -- BUG# 2247404 and 2230178 - call regardless if from a mass request
321    if not FA_TRX_APPROVAL_PKG.faxcat
322           (X_book              => px_asset_hdr_rec.book_type_code,
323            X_asset_id          => px_asset_hdr_rec.asset_id,
324            X_trx_type          => 'DELETE',
325            X_trx_date          => sysdate,
326            X_init_message_flag => 'NO'
327           , p_log_level_rec => p_log_level_rec) then
328       raise del_err;
329    end if;
330 
331    -- check if this is the period of addition - use absolute mode for adjustments
332    if not FA_ASSET_VAL_PVT.validate_period_of_addition
333              (p_asset_id            => px_asset_hdr_rec.asset_id,
334               p_book                => px_asset_hdr_rec.book_type_code,
335               p_mode                => 'ABSOLUTE',
336               px_period_of_addition => px_asset_hdr_rec.period_of_addition, p_log_level_rec => p_log_level_rec) then
337       raise del_err;
338    end if;
339 
340    -- load the period struct for current period info
341    if not FA_UTIL_PVT.get_period_rec
342           (p_book           => px_asset_hdr_rec.book_type_code,
343            p_effective_date => NULL,
344            x_period_rec     => l_period_rec
345           , p_log_level_rec => p_log_level_rec) then
346       raise del_err;
347    end if;
348 
349    -- handle needed validation
350    -- bypass if validation level <> FULL
351 
352    if (p_validation_level = FND_API.G_VALID_LEVEL_FULL) then
353       if not fa_deletion_pvt.do_validation
354              (px_asset_hdr_rec           => px_asset_hdr_rec,
355               p_asset_type_rec           => p_asset_type_rec,
356               p_asset_desc_rec           => p_asset_desc_rec,
357               p_asset_cat_rec            => p_asset_cat_rec, p_log_level_rec => p_log_level_rec) then
358          raise del_err;
359       end if;
360    end if;
361 
362    --Delete associated events
363    if not delete_asset_events (px_asset_hdr_rec
364                               ,p_asset_type_rec
365                               ,p_log_level_rec) then
366       raise del_err;
367    end if;
368 
369    DELETE FROM FA_ADJUSTMENTS
370           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
371           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
372 
373    DELETE FROM FA_BOOKS
374           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
375           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
376 
377    DELETE FROM FA_DEPRN_DETAIL
378           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
379           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
380 
381    DELETE FROM FA_DEPRN_SUMMARY
382           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
383           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
384 
385    --13343131
386    if G_release <> 11 then
387       DELETE FROM FA_DEPRN_EVENTS
388              WHERE Asset_Id          = px_asset_hdr_rec.asset_id
389              AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
390    end if;
391 
392    DELETE FROM FA_RETIREMENTS
393           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
394           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
395 
396    DELETE FROM FA_TRANSACTION_HEADERS
397           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
398           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
399 
400          -- mrc
401    DELETE FROM FA_MC_ADJUSTMENTS
402           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
403           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
404 
405    DELETE FROM FA_MC_BOOKS
406           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
407           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
408 
409    DELETE FROM FA_MC_DEPRN_DETAIL
410           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
411           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
412 
413    DELETE FROM FA_MC_DEPRN_SUMMARY
414           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
415           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
416 
417    DELETE FROM FA_MC_RETIREMENTS
418           WHERE Asset_Id          = px_asset_hdr_rec.asset_id
419           AND book_Type_Code    = px_asset_hdr_rec.book_type_code;
420 
421 
422 -- Asset hierarchy delete
423     if (nvl(fnd_profile.value('CRL-FA ENABLED'), 'N') = 'Y') then
424           fa_cua_wb_ext_pkg.facuas1(px_asset_hdr_rec.Asset_Id, p_log_level_rec => p_log_level_rec);
425     end if;
426 
427 
428     if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
429 
430            -- Added transfer_header_id in the where clause
431            -- as a result of High Cost SQL drill bugfix 3116047 msiddiqu
432 
433            DELETE FROM FA_TRANSFER_DETAILS
434            WHERE ( DISTRIBUTION_ID, transfer_header_id) IN
435                  ( SELECT DISTRIBUTION_ID, transaction_header_id_in transfer_header_id
436                    FROM FA_DISTRIBUTION_HISTORY
437                    WHERE ASSET_ID = px_asset_hdr_rec.asset_id );
438 
439          -- BUG# 4173695
440          -- removing this for performance and because invoice
441          -- transfers could affect other assets
442 
443          -- For C1_rec in C1 Loop
444          --   DELETE FROM FA_INVOICE_TRANSACTIONS
445          --   WHERE INVOICE_TRANSACTION_ID = C1_rec.INVOICE_TRANSACTION_ID_IN
446          --   OR INVOICE_TRANSACTION_ID = C1_rec.INVOICE_TRANSACTION_ID_OUT;
447          -- End Loop;
448 
449          DELETE FROM FA_DISTRIBUTION_HISTORY
450           WHERE Asset_Id          = px_asset_hdr_rec.asset_id;
451 
452          DELETE FROM FA_ASSET_HISTORY
453           WHERE Asset_Id          = px_asset_hdr_rec.asset_id;
454 
455          FA_ADDITIONS_PKG.DELETE_ROW
456             (X_Rowid      => l_rowid,
457              X_Asset_id   => px_asset_hdr_rec.asset_id,
458              X_Calling_Fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
459 
460          DELETE FROM FA_ASSET_INVOICES
461           WHERE Asset_Id          = px_asset_hdr_rec.asset_id;
462 
463          DELETE FROM FA_MC_ASSET_INVOICES
464           WHERE Asset_Id          = px_asset_hdr_rec.asset_id;
465 
466          DELETE FROM FA_PERIODIC_PRODUCTION WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
467 
468          DELETE FROM fa_add_warranties
469           WHERE asset_id= px_asset_hdr_rec.asset_id;
470 
471          if ( (fa_cache_pkg.fazcat_record.category_type = 'LEASEHOLD IMPROVEMENT')
472 	    and (p_asset_desc_rec.lease_id is not null) )	then
473             FA_LEASES_PKG.Delete_Row
474                (X_Lease_Id   => p_asset_desc_rec.lease_id,
475                 X_Calling_Fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
476          end if;
477 
478     elsif (fa_cache_pkg.fazcbc_record.book_class = 'BUDGET') then
479 
480          DELETE FROM FA_CAPITAL_BUDGET WHERE ASSET_ID = px_asset_hdr_rec.asset_id ;
481 
482     End if;
483 
484 /*
485       DELETE FROM FA_ACE_BOOKS
486        WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
487 
488       DELETE FROM FA_BALANCES_REPORT
489        WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
490 
491       DELETE FROM FA_DEFERRED_DEPRN
492        WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
493 
494       DELETE FROM FA_MASS_REVALUATION_RULES
495        WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
496 
497       DELETE FROM FA_RESERVE_LEDGER
498        WHERE ASSET_ID = px_asset_hdr_rec.asset_id;
499 */
500 
501 
502    return true;
503 
504 
505 EXCEPTION
506 
507    WHEN DEL_ERR THEN
508       fa_srvr_msg.add_message(calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
509       return FALSE;
510 
511    WHEN OTHERS THEN
512       fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
513       return FALSE;
514 
515 END do_all_books;
516 
517 FUNCTION delete_asset_events (px_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
518                               p_asset_type_rec IN fa_api_types.asset_type_rec_type,
519                               p_log_level_rec  IN fa_api_types.log_level_rec_type default null) RETURN BOOLEAN IS
520 
521    del_err              EXCEPTION;
522    l_calling_fn         varchar2(80) := 'fa_delete_pub.delete_asset_events';
523 
524    --Need this to get any events that might have been sent to SLA to avoid
525    --leaving orphans there.  Second part of union is used to get dist-related
526    --trxs in tax book, since we use the th id from corp book in such cases.
527 
528    CURSOR get_trx_id IS
529      select th.transaction_header_id, th.event_id, th.book_type_code
530      from fa_transaction_headers th
531      where th.book_type_code = px_asset_hdr_rec.book_type_code
532      and th.asset_id = px_asset_hdr_rec.asset_id
533      and th.event_id is not null
534      union
535      select en.source_id_int_1, ev.event_id, en.valuation_method
536      from xla_transaction_entities en, xla_events ev,
537           fa_transaction_headers th, fa_book_controls bc
538      where bc.book_class = 'TAX'
539      and bc.date_ineffective is null
540      and ev.entity_id          = en.entity_id
541      and ev.application_id     = 140
542      and ev.event_status_code  <> 'P'
543      and th.book_type_code     = bc.distribution_source_book
544      and th.asset_id           = px_asset_hdr_rec.asset_id
545      and nvl(en.source_id_int_1, (-99))   = th.transaction_header_id   /* Modified for Bug 12583005 */
546      and en.valuation_method   = bc.book_type_code
547      and en.entity_code        = 'TRANSACTIONS'
548      and en.ledger_id          = bc.set_of_books_id
549      and en.application_id     = 140
550      and en.source_id_int_1 is not null;
551 
552    --Bug#13343131
553    --Delete depreciation event too,this will happen when depreciation is run but period is not closed yet.
554    CURSOR get_deprn_id IS
555       select event_id,
556              period_counter,
557 	     deprn_run_id
558 	from fa_deprn_events
559        where asset_id = px_asset_hdr_rec.asset_id
560          and book_type_code = px_asset_hdr_rec.book_type_code;
561 BEGIN
562 
563    FOR trx_rec IN get_trx_id LOOP
564 
565       if not fa_xla_events_pvt.delete_transaction_event
566            (p_ledger_id              => px_asset_hdr_rec.set_of_books_id,
567             p_transaction_header_id  => trx_rec.transaction_header_id,
568             p_book_type_code         => trx_rec.book_type_code,
569             p_asset_type             => p_asset_type_rec.asset_type,
570             p_calling_fn             => l_calling_fn,
571             p_log_level_rec          => p_log_level_rec) then
572          raise del_err;
573       end if;
574 
575    END LOOP; -- end for
576 
577    FOR deprn_rec IN get_deprn_id LOOP
578       if not fa_xla_events_pvt.delete_deprn_event
579            (p_event_id        =>deprn_rec.event_id,
580             p_ledger_id       =>px_asset_hdr_rec.set_of_books_id,
581             p_asset_id        =>px_asset_hdr_rec.asset_id,
582             p_book_type_code  =>px_asset_hdr_rec.book_type_code,
583             p_period_counter  =>deprn_rec.period_counter,
584             p_deprn_run_id    =>deprn_rec.deprn_run_id,
585             p_calling_fn      =>l_calling_fn,
586             p_log_level_rec   =>p_log_level_rec) then
587          raise del_err;
588       end if;
589    END LOOP; -- end for
590    return TRUE;
591 
592 EXCEPTION
593 
594    WHEN DEL_ERR THEN
595       fa_srvr_msg.add_message(calling_fn => l_calling_fn
596             ,p_log_level_rec => p_log_level_rec);
597       return FALSE;
598 
599    WHEN OTHERS THEN
600       fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
601             ,p_log_level_rec => p_log_level_rec);
602       return FALSE;
603 
604 END delete_asset_events;
605 
606 -----------------------------------------------------------------------------
607 
608 END FA_DELETION_PUB;