DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_ASSET_DESC_PUB

Source


1 PACKAGE BODY FA_ASSET_DESC_PUB AS
2 /* $Header: FAPADSCB.pls 120.18 2006/08/25 15:01:33 spooyath noship $   */
3 
4 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'FA_ASSET_DESC_PUB';
5 G_API_NAME      CONSTANT VARCHAR2(30) := 'Update Asset Description API';
6 G_API_VERSION   CONSTANT NUMBER       := 1.0;
7 
8 g_log_level_rec  fa_api_types.log_level_rec_type;
9 
10 --*********************** Private functions ******************************--
11 
12 FUNCTION update_row(
13           p_trans_rec           IN fa_api_types.trans_rec_type,
14           p_asset_hdr_rec       IN fa_api_types.asset_hdr_rec_type,
15           p_asset_desc_rec_new  IN fa_api_types.asset_desc_rec_type,
16           p_asset_cat_rec_new   IN fa_api_types.asset_cat_rec_type,
17           p_old_warranty_id     IN number,
18           p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) return boolean;
19 
20 FUNCTION initialize_category_df (
21          px_asset_cat_rec        IN OUT NOCOPY   FA_API_TYPES.asset_cat_rec_type,
22          p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) return boolean;
23 
24 
25 --*********************** Public procedures ******************************--
26 PROCEDURE update_desc(
27           -- Standard Parameters --
28           p_api_version           IN     NUMBER,
29           p_init_msg_list         IN     VARCHAR2 := FND_API.G_FALSE,
30           p_commit                IN     VARCHAR2 := FND_API.G_FALSE,
31           p_validation_level      IN     NUMBER   := FND_API.G_VALID_LEVEL_FULL,
32           x_return_status            OUT NOCOPY VARCHAR2,
33           x_msg_count                OUT NOCOPY NUMBER,
34           x_msg_data                 OUT NOCOPY VARCHAR2,
35           p_calling_fn            IN     VARCHAR2,
36           -- Transaction Object --
37           px_trans_rec            IN OUT NOCOPY fa_api_types.trans_rec_type,
38           -- Asset Object --
39           px_asset_hdr_rec        IN OUT NOCOPY fa_api_types.asset_hdr_rec_type,
40           px_asset_desc_rec_new   IN OUT NOCOPY fa_api_types.asset_desc_rec_type,
41           px_asset_cat_rec_new    IN OUT NOCOPY fa_api_types.asset_cat_rec_type) IS
42 
43    l_asset_desc_rec   FA_API_TYPES.asset_desc_rec_type;
44    l_asset_cat_rec    FA_API_TYPES.asset_cat_rec_type;
45    l_asset_fin_rec    FA_API_TYPES.asset_fin_rec_type;
46    l_calling_fn       varchar2(50);
47    pub_error          exception;
48 
49    l_err_stage        varchar2(640);
50    l_crl_enabled      boolean := FALSE;
51    l_override_flag    varchar2(1) := null;
52    l_old_warranty_id  number(15);
53 
54 BEGIN
55 
56    l_calling_fn := 'FA_ASSET_DESC_PUB.update_desc';
57 
58    SAVEPOINT do_desc_update;
59    if (not g_log_level_rec.initialized) then
60       if (NOT fa_util_pub.get_log_level_rec (
61                 x_log_level_rec =>  g_log_level_rec
62       )) then
63          raise pub_error;
64       end if;
65    end if;
66 
67    l_err_stage:= 'Compatible_API_Call';
68    if (g_log_level_rec.statement_level) then
69                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
70                               ,p_log_level_rec => g_log_level_rec);
71      end if;
72 
73    if (NOT FND_API.Compatible_API_Call(
74         G_API_VERSION,
75         p_api_version,
76         G_API_NAME, G_PKG_NAME
77    )) then
78       raise pub_error;
79    end if;
80 
81 
82    l_err_stage:= 'Init_Server_Message';
83     if (g_log_level_rec.statement_level) then
84                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
85                               ,p_log_level_rec => g_log_level_rec);
86      end if;
87 
88 
89    if (FND_API.To_Boolean(p_init_msg_list)) then
90        -- Initialize error message stack.
91        FA_SRVR_MSG.Init_Server_Message;
92 
93        -- Initialize debug message stack.
94        FA_DEBUG_PKG.Initialize;
95    end if;
96 
97 
98    l_err_stage:= 'validate mandatory input params';
99    if (g_log_level_rec.statement_level) then
100                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
101                               ,p_log_level_rec => g_log_level_rec);
102      end if;
103 
104    if (px_asset_hdr_rec.asset_id is NULL) then
105        fa_srvr_msg.add_message(
106                calling_fn => l_calling_fn,
107                name       => 'FA_ASSET_MAINT_WRONG_PARAM',
108                p_log_level_rec => g_log_level_rec);
109        raise pub_error;
110     end if;
111 
112    l_err_stage:= 'We need a calling book if it was not provided';
113    if (px_asset_hdr_rec.book_type_code is null) then
114       select bc.book_type_code
115       into   px_asset_hdr_rec.book_type_code
116       from   fa_book_controls bc
117       where  bc.book_class = 'CORPORATE'
118       and exists
119       (
120        select 'X'
121        from   fa_books bks
122        where  bks.asset_id = px_asset_hdr_rec.asset_id
123        and    bks.book_type_code = bc.book_type_code
124        );
125    end if;
126 
127 
128    l_err_stage:= 'fa_cache_pkg.fazcbc';
129    if (g_log_level_rec.statement_level) then
130          fa_debug_pkg.add('Update_desc', 'before', l_err_stage
131                   ,p_log_level_rec => g_log_level_rec);
132       end if;
133 
134    if (NOT fa_cache_pkg.fazcbc (
135       X_book => px_asset_hdr_rec.book_type_code,
136       p_log_level_rec => g_log_level_rec)) then
137       raise pub_error;
138    end if;
139 
140 
141    l_err_stage:= 'FA_UTIL_PVT.get_asset_desc_rec';
142    if (g_log_level_rec.statement_level) then
143          fa_debug_pkg.add('Update_desc', 'before', l_err_stage
144                   ,p_log_level_rec => g_log_level_rec);
145       end if;
146 
147     if not FA_UTIL_PVT.get_asset_desc_rec(
148                      p_asset_hdr_rec   => px_asset_hdr_rec,
149                      px_asset_desc_rec => l_asset_desc_rec,
150                      p_log_level_rec => g_log_level_rec) then
151           raise pub_error;
152     end if;
153 
154     -- check if CRL enabled
155     if (nvl(fnd_profile.value('CRL-FA ENABLED'), 'N') = 'Y') then
156 
157         -- If called from Asset Hierarchy batch ignore CRL validations
158         if px_trans_rec.calling_interface <> 'ASSET_HIERARCHY' then
159            l_crl_enabled := TRUE;
160         end if;
161     end if;
162 
163 
164     -- Asset Number
165     l_err_stage:= 'Asset NUmber';
166     if (g_log_level_rec.statement_level) then
167                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
168                               ,p_log_level_rec => g_log_level_rec);
169      end if;
170 
171 
172     if (px_asset_desc_rec_new.asset_number is NOT NULL) then
173        if (px_asset_desc_rec_new.asset_number <>
174            nvl(l_asset_desc_rec.asset_number, '-999')) then
175 
176          if (px_asset_desc_rec_new.asset_number is null) then
177             -- retain the old asset_number
178             null;
179          else
180             -- Check if user intentionally nulls out item.
181             if (px_asset_desc_rec_new.asset_number = FND_API.G_MISS_CHAR) then
182                -- use asset_id for asset_number
183                px_asset_desc_rec_new.asset_number :=
184                   to_char(px_asset_hdr_rec.asset_id);
185             end if;
186 
187             -- Validate asset_number
188             if (NOT FA_ASSET_VAL_PVT.validate_asset_number(
189                   p_transaction_type_code => 'ADDITION',
190                                            --px_trans_rec.transaction_type_code,
191                   p_asset_number          => px_asset_desc_rec_new.asset_number,
192                   p_calling_fn            => l_calling_fn,
193                    p_log_level_rec => g_log_level_rec)) then
194                raise pub_error;
195             end if;
196          end if;
197        end if;
198        l_asset_desc_rec.asset_number:= px_asset_desc_rec_new.asset_number;
199     end if;   /* asset_number */
200 
201     -- Asset Description
202     l_err_stage:= 'Asset Description';
203     if (g_log_level_rec.statement_level) then
204                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
205                               ,p_log_level_rec => g_log_level_rec);
206      end if;
207 
208 
209     if (px_asset_desc_rec_new.description is NOT NULL) then
210        if (px_asset_desc_rec_new.description <>
211            nvl(l_asset_desc_rec.description, '-999')) then
212 
213           if (px_asset_desc_rec_new.description is null) then
214              -- retain the old description
215              null;
216 
217           -- Check if user intentionally nulls out item.
218           elsif (px_asset_desc_rec_new.description = FND_API.G_MISS_CHAR) then
219              --l_asset_desc_rec.description := NULL;
220              null;
221           end if;
222 
223           l_asset_desc_rec.description:= px_asset_desc_rec_new.description;
224        end if;
225     end if;  /* asset description */
226 
227     -- Tag Number
228     l_err_stage:= 'Tag Number';
229      if (g_log_level_rec.statement_level) then
230                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
231                               ,p_log_level_rec => g_log_level_rec);
232      end if;
233 
234     if (px_asset_desc_rec_new.tag_number is NOT NULL) then
235       if (nvl(l_asset_desc_rec.tag_number, '-999') <>
236           px_asset_desc_rec_new.tag_number) then
237 
238          if (px_asset_desc_rec_new.tag_number = FND_API.G_MISS_CHAR) then
239             --l_asset_desc_rec.tag_number := NULL;
240             null;
241          else
242 
243             if (NOT FA_ASSET_VAL_PVT.validate_tag_number (
244                  p_tag_number        => px_asset_desc_rec_new.tag_number,
245                  p_mass_addition_id  => null,
246                  p_calling_fn        => l_calling_fn,
247                   p_log_level_rec => g_log_level_rec)) then
248                raise pub_error;
249             end if;
250          end if;
251          l_asset_desc_rec.tag_number:= px_asset_desc_rec_new.tag_number;
252       end if;
253     end if;
254 
255     l_err_stage:= 'Get_asset_cat';
256     if (g_log_level_rec.statement_level) then
257                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
258                               ,p_log_level_rec => g_log_level_rec);
259      end if;
260 
261 
262     if not FA_UTIL_PVT.get_asset_cat_rec(
263                      p_asset_hdr_rec   => px_asset_hdr_rec,
264                      px_asset_cat_rec =>  l_asset_cat_rec,
265                      p_log_level_rec => g_log_level_rec) then
266           raise pub_error;
267     end if;
268 
269     l_asset_cat_rec.desc_flex := px_asset_cat_rec_new.desc_flex;
270 
271     l_err_stage:= 'initialize_category_df';
272     if not initialize_category_df ( l_asset_cat_rec, g_log_level_rec) then
273            raise pub_error;
274     end if;
275 
276 /*
277 
278     if not FA_ASSET_VAL_PVT.validate_category_df (
279            p_transaction_type_code => px_trans_rec.transaction_type_code,
280            p_cat_desc_flex         => l_asset_cat_rec.desc_flex,
281            p_calling_fn            => p_calling_fn
282            ,p_log_level_rec => g_log_level_rec) then
283            raise pub_error;
284     end if;
285 
286 */
287 
288     -- Serial Number
289     l_err_stage:= 'Serial Number';
290     if (g_log_level_rec.statement_level) then
291                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
292                               ,p_log_level_rec => g_log_level_rec);
293      end if;
294 
295 
296     if (px_asset_desc_rec_new.serial_number is NOT NULL) then
297        if (nvl(l_asset_desc_rec.serial_number, '-999') <>
298            px_asset_desc_rec_new.serial_number) then
299 
300           if (px_asset_desc_rec_new.serial_number = FND_API.G_MISS_CHAR) then
301              --px_asset_desc_rec_new.serial_number := NULL;
302              null;
303           else
304              -- check whether update is allowed for Hierarchy Attached asset
305              if (l_crl_enabled) then
306                 if (NOT fa_cua_asset_apis.check_override_allowed (
307                       p_attribute_name => 'SERIAL_NUMBER',
308                       p_book_type_code => px_asset_hdr_rec.book_type_code,
309                       p_asset_id       => px_asset_hdr_rec.asset_id,
310                       x_override_flag  => l_override_flag)) then
311 
312                    fa_srvr_msg.add_message(calling_fn => l_calling_fn,
313                                            p_log_level_rec => g_log_level_rec);
314                    raise pub_error;
315                 end if;
316 
317                 if (l_override_flag = 'N') then
318                    fa_srvr_msg.add_message(
319                        calling_fn => l_calling_fn,
320                        name       => 'FA_OVERRIDE_NOT_ALLOWED',
321                        token1     => 'SERIAL NUMBER',
322                        p_log_level_rec => g_log_level_rec);
323                    raise pub_error;
324                 end if;
325              end if;
326 
327              if (NOT FA_ASSET_VAL_PVT.validate_serial_number (
328                  p_transaction_type_code => px_trans_rec.transaction_type_code,
329                  p_serial_number         => px_asset_desc_rec_new.serial_number,
330                  p_calling_fn            => l_calling_fn,
331                  p_log_level_rec => g_log_level_rec)) then
332                 raise pub_error;
333              end if;
334           end if;
335           l_asset_desc_rec.serial_number:= px_asset_desc_rec_new.serial_number;
336        end if;
337     end if;
338 
339     -- Asset Key
340     l_err_stage:= 'Asset Key';
341     if (g_log_level_rec.statement_level) then
342                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
343                               ,p_log_level_rec => g_log_level_rec);
344      end if;
345 
346 
347     if (px_asset_desc_rec_new.asset_key_ccid is NOT NULL) then
348       if (nvl(l_asset_desc_rec.asset_key_ccid, -999) <>
349           px_asset_desc_rec_new.asset_key_ccid) then
350 
351           if (px_asset_desc_rec_new.asset_key_ccid = FND_API.G_MISS_NUM) then
352              --px_asset_desc_rec_new.asset_key_ccid := NULL;
353 
354              if (NOT FA_ASSET_VAL_PVT.validate_asset_key (
355                 p_transaction_type_code => px_trans_rec.transaction_type_code,
356                 p_asset_key_ccid        => NULL,
357                 p_calling_fn            => l_calling_fn
358                 ,p_log_level_rec => g_log_level_rec)) then
359                 raise pub_error;
360              end if;
361           else
362              if (l_crl_enabled) then
363                 if (NOT fa_cua_asset_APIS.check_override_allowed(
364                       p_attribute_name => 'ASSET_KEY',
365                       p_book_type_code => px_asset_hdr_rec.book_type_code,
366                       p_asset_id       => px_asset_hdr_rec.asset_id,
367                       x_override_flag  => l_override_flag
368                 )) then
369 
370                    fa_srvr_msg.add_message(
371                       calling_fn => l_calling_fn,
372                       p_log_level_rec => g_log_level_rec);
373                    raise pub_error;
374                 end if;
375 
376                 if (l_override_flag = 'N') then
377                      fa_srvr_msg.add_message(
378                          calling_fn => l_calling_fn,
379                          name       => 'FA_OVERRIDE_NOT_ALLOWED',
380                          token1     => 'ASSET KEY',
381                          p_log_level_rec => g_log_level_rec);
382                      raise pub_error;
383                 end if;
384              end if;
385          end if;
386 
387          if (NOT FA_ASSET_VAL_PVT.validate_asset_key (
388              p_transaction_type_code => px_trans_rec.transaction_type_code,
389              p_asset_key_ccid        => px_asset_desc_rec_new.asset_key_ccid,
390              p_calling_fn            => l_calling_fn,
391              p_log_level_rec => g_log_level_rec)) then
392              raise pub_error;
393          end if;
394 
395          l_asset_desc_rec.asset_key_ccid:= px_asset_desc_rec_new.asset_key_ccid;
396       end if;
397     end if;
398 
399    -- Parent asset
400    l_err_stage:= 'Parent Asset';
401    if (g_log_level_rec.statement_level) then
402                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
403                               ,p_log_level_rec => g_log_level_rec);
404    end if;
405 
406 
407    if (px_asset_desc_rec_new.parent_asset_id is NOT NULL) then
408       if (nvl(l_asset_desc_rec.parent_asset_id, -999) <>
409           px_asset_desc_rec_new.parent_asset_id) then
410 
411           if (px_asset_desc_rec_new.parent_asset_id = FND_API.G_MISS_NUM) then
412              --px_asset_desc_rec_new.parent_asset_id := NULL;
413              null;
414           else
415              if (NOT FA_ASSET_VAL_PVT.validate_parent_asset(
416                   p_parent_asset_id  => px_asset_desc_rec_new.parent_asset_id,
417                   p_asset_id         => px_asset_hdr_rec.asset_id,
418                   p_log_level_rec => g_log_level_rec)) then
419                 raise pub_error;
420              end if;
421           end if;
422           l_asset_desc_rec.parent_asset_id :=
423              px_asset_desc_rec_new.parent_asset_id;
424       end if;
425    end if;
426 
427    -- Manufacturer
428    l_err_stage:= 'Manufacturer';
429    if (g_log_level_rec.statement_level) then
430                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
431                               ,p_log_level_rec => g_log_level_rec);
432    end if;
433 
434 
435    if (px_asset_desc_rec_new.manufacturer_name is NOT NULL) then
436        if (nvl(l_asset_desc_rec.manufacturer_name, '-999') <>
437            px_asset_desc_rec_new.manufacturer_name) then
438 
439            if (px_asset_desc_rec_new.manufacturer_name = FND_API.G_MISS_CHAR)
440               then null; --px_asset_desc_rec_new.manufacturer_name := NULL;
441            end if;
442 
443            l_asset_desc_rec.manufacturer_name :=
444               px_asset_desc_rec_new.manufacturer_name;
445        end if;
446    end if;
447 
448    /*
449    if (nvl(l_asset_desc_rec.manufacturer_name, '-999') <>
450        px_asset_desc_rec_new.manufacturer_name) then
451 
452       if (NOT FA_ASSET_VAL_PVT.validate_supplier_name (
453                  p_transaction_type_code => p_trans_rec.transaction_type_code,
454                  p_calling_fn            => l_calling_fn ,
455                  p_log_level_rec => g_log_level_rec)) then
456          raise pub_error;
457       end if;
458    end if;
459 
460    if (NOT FA_ASSET_VAL_PVT.validate_supplier_number (
461              p_transaction_type_code => p_trans_rec.transaction_type_code,
462              p_calling_fn            => p_calling_fn,
463              p_log_level_rec => g_log_level_rec)) then return FALSE;
464    end if;
465    */
466 
467    -- Model Number
468    l_err_stage:= 'Model Number';
469    if (g_log_level_rec.statement_level) then
470                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
471                               ,p_log_level_rec => g_log_level_rec);
472      end if;
473 
474 
475    if (px_asset_desc_rec_new.model_number is NOT NULL) then
476       if (nvl(l_asset_desc_rec.model_number, '-999') <>
477           px_asset_desc_rec_new.model_number)
478       then
479          if (px_asset_desc_rec_new.model_number = FND_API.G_MISS_CHAR) then
480             --px_asset_desc_rec_new.model_number := NULL;
481             null;
482          end if;
483 
484          l_asset_desc_rec.model_number := px_asset_desc_rec_new.model_number;
485       end if;
486    end if;
487 
488    -- Warranty Number
489    l_err_stage:= 'Warranty Number';
490    if (g_log_level_rec.statement_level) then
491                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
492                               ,p_log_level_rec => g_log_level_rec);
493      end if;
494 
495 
496    if (px_asset_desc_rec_new.warranty_id is NOT NULL) then
497       if (nvl(l_asset_desc_rec.warranty_id, -999) <>
498           px_asset_desc_rec_new.warranty_id)
499       then
500          if (px_asset_desc_rec_new.warranty_id = FND_API.G_MISS_NUM) then
501             --px_asset_desc_rec_new.warranty_id := NULL;
502             null;
503          else
504             -- We will need dpis to validate warranty.  Same in primary/rep
505             if not FA_UTIL_PVT.get_asset_fin_rec(
506                      p_asset_hdr_rec     => px_asset_hdr_rec,
507                      px_asset_fin_rec    => l_asset_fin_rec,
508                      p_mrc_sob_type_code => 'P',
509                      p_log_level_rec => g_log_level_rec) then
510                raise pub_error;
511             end if;
512 
513             if (NOT FA_ASSET_VAL_PVT.validate_warranty(
514                 p_warranty_id            => px_asset_desc_rec_new.warranty_id,
515                 p_date_placed_in_service =>
516                    l_asset_fin_rec.date_placed_in_service,
517                 p_book_type_code         => px_asset_hdr_rec.book_type_code,
518                 p_log_level_rec => g_log_level_rec)) then
519                raise pub_error;
520             end if;
521          end if;
522       end if;
523       l_old_warranty_id := l_asset_desc_rec.warranty_id;
524       l_asset_desc_rec.warranty_id := px_asset_desc_rec_new.warranty_id;
525    end if;
526 
527    -- Lease
528    l_err_stage:= 'Lease';
529    if (g_log_level_rec.statement_level) then
530                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
531                               ,p_log_level_rec => g_log_level_rec);
532    end if;
533 
534    if (px_asset_desc_rec_new.lease_id is NOT NULL) then
535       if (nvl(l_asset_desc_rec.lease_id, -999) <>
536           px_asset_desc_rec_new.lease_id) then
537 
538          if (px_asset_desc_rec_new.lease_id = FND_API.G_MISS_NUM) then
539 
540             null;
541 
542             -- px_asset_desc_rec_new.lease_id := NULL;
543 
544 /*
545             -- null out the lease dffs
546             l_asset_desc_rec.lease_desc_flex.attribute_category_code := null;
547             l_asset_desc_rec.lease_desc_flex.context    := null;
548             l_asset_desc_rec.lease_desc_flex.attribute1 := null;
549             l_asset_desc_rec.lease_desc_flex.attribute2 := null;
550             l_asset_desc_rec.lease_desc_flex.attribute3 := null;
551             l_asset_desc_rec.lease_desc_flex.attribute4 := null;
552             l_asset_desc_rec.lease_desc_flex.attribute5 := null;
553             l_asset_desc_rec.lease_desc_flex.attribute6 := null;
554             l_asset_desc_rec.lease_desc_flex.attribute7 := null;
555             l_asset_desc_rec.lease_desc_flex.attribute8 := null;
556             l_asset_desc_rec.lease_desc_flex.attribute9 := null;
557             l_asset_desc_rec.lease_desc_flex.attribute10 := null;
558             l_asset_desc_rec.lease_desc_flex.attribute11 := null;
559             l_asset_desc_rec.lease_desc_flex.attribute12 := null;
560             l_asset_desc_rec.lease_desc_flex.attribute13 := null;
561             l_asset_desc_rec.lease_desc_flex.attribute14 := null;
562             l_asset_desc_rec.lease_desc_flex.attribute15 := null;
563 */
564          else
565 
566             if (l_crl_enabled) then
567                if (NOT fa_cua_asset_apis.check_override_allowed(
568                       p_attribute_name => 'LEASE_NUMBER',
569                       p_book_type_code => px_asset_hdr_rec.book_type_code,
570                       p_asset_id       => px_asset_hdr_rec.asset_id,
571                       x_override_flag  => l_override_flag
572                )) then
573                   fa_srvr_msg.add_message(
574                       calling_fn => l_calling_fn,
575                       p_log_level_rec => g_log_level_rec);
576                   raise pub_error;
577                end if;
578 
579                if (l_override_flag = 'N') then
580                   fa_srvr_msg.add_message(
581                       calling_fn => l_calling_fn,
582                       name       => 'FA_OVERRIDE_NOT_ALLOWED',
583                       token1     => 'LEASE NUMBER',
584                       p_log_level_rec => g_log_level_rec);
585                   raise pub_error;
586                end if;
587             end if;
588 
589             if (NOT FA_ASSET_VAL_PVT.validate_lease(
590                p_asset_id  => px_asset_hdr_rec.asset_id,
591                p_lease_id  => px_asset_desc_rec_new.lease_id ,
592                p_log_level_rec => g_log_level_rec)) then
593                raise pub_error;
594             end if;
595 
596          end if;
597          l_asset_desc_rec.lease_id := px_asset_desc_rec_new.lease_id;
598       end if;
599 
600       -- Update Lease DFF
601       if (px_asset_desc_rec_new.lease_desc_flex.attribute1 is NOT NULL) then
602           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute1, '-999') <>
603               px_asset_desc_rec_new.lease_desc_flex.attribute1) then
604 
605               if (px_asset_desc_rec_new.lease_desc_flex.attribute1 =
606                   FND_API.G_MISS_CHAR)
607               then null;
608               end if;
609 
610               l_asset_desc_rec.lease_desc_flex.attribute1 :=
611                  px_asset_desc_rec_new.lease_desc_flex.attribute1;
612 
613           end if;
614       end if;
615 
616       if (px_asset_desc_rec_new.lease_desc_flex.attribute2 is NOT NULL) then
617           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute2, '-999') <>
618               px_asset_desc_rec_new.lease_desc_flex.attribute2) then
619 
620               if (px_asset_desc_rec_new.lease_desc_flex.attribute2 =
621                   FND_API.G_MISS_CHAR)
622               then null;
623               end if;
624 
625               l_asset_desc_rec.lease_desc_flex.attribute2 :=
626                  px_asset_desc_rec_new.lease_desc_flex.attribute2;
627 
628           end if;
629       end if;
630 
631       if (px_asset_desc_rec_new.lease_desc_flex.attribute3 is NOT NULL) then
632           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute3, '-999') <>
633               px_asset_desc_rec_new.lease_desc_flex.attribute3) then
634 
635               if (px_asset_desc_rec_new.lease_desc_flex.attribute3 =
636                   FND_API.G_MISS_CHAR)
637               then null;
638               end if;
639 
640               l_asset_desc_rec.lease_desc_flex.attribute3 :=
641                  px_asset_desc_rec_new.lease_desc_flex.attribute3;
642 
643           end if;
644       end if;
645 
646       if (px_asset_desc_rec_new.lease_desc_flex.attribute4 is NOT NULL) then
647           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute4, '-999') <>
648               px_asset_desc_rec_new.lease_desc_flex.attribute4) then
649 
650               if (px_asset_desc_rec_new.lease_desc_flex.attribute4 =
651                   FND_API.G_MISS_CHAR)
652               then null;
653               end if;
654 
655               l_asset_desc_rec.lease_desc_flex.attribute4 :=
656                  px_asset_desc_rec_new.lease_desc_flex.attribute4;
657 
658           end if;
659       end if;
660 
661       if (px_asset_desc_rec_new.lease_desc_flex.attribute5 is NOT NULL) then
662           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute5, '-999') <>
663               px_asset_desc_rec_new.lease_desc_flex.attribute5) then
664 
665               if (px_asset_desc_rec_new.lease_desc_flex.attribute5 =
666                   FND_API.G_MISS_CHAR)
667               then null;
668               end if;
669 
670               l_asset_desc_rec.lease_desc_flex.attribute5 :=
671                  px_asset_desc_rec_new.lease_desc_flex.attribute5;
672 
673           end if;
674       end if;
675 
676       if (px_asset_desc_rec_new.lease_desc_flex.attribute6 is NOT NULL) then
677           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute6, '-999') <>
678               px_asset_desc_rec_new.lease_desc_flex.attribute6) then
679 
680               if (px_asset_desc_rec_new.lease_desc_flex.attribute6 =
681                   FND_API.G_MISS_CHAR)
682               then null;
683               end if;
684 
685               l_asset_desc_rec.lease_desc_flex.attribute6 :=
686                  px_asset_desc_rec_new.lease_desc_flex.attribute6;
687 
688           end if;
689       end if;
690 
691       if (px_asset_desc_rec_new.lease_desc_flex.attribute7 is NOT NULL) then
692           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute7, '-999') <>
693               px_asset_desc_rec_new.lease_desc_flex.attribute7) then
694 
695               if (px_asset_desc_rec_new.lease_desc_flex.attribute7 =
696                   FND_API.G_MISS_CHAR)
697               then null;
698               end if;
699 
700               l_asset_desc_rec.lease_desc_flex.attribute7 :=
701                  px_asset_desc_rec_new.lease_desc_flex.attribute7;
702 
703           end if;
704       end if;
705 
706       if (px_asset_desc_rec_new.lease_desc_flex.attribute8 is NOT NULL) then
707           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute8, '-999') <>
708               px_asset_desc_rec_new.lease_desc_flex.attribute8) then
709 
710               if (px_asset_desc_rec_new.lease_desc_flex.attribute8 =
711                   FND_API.G_MISS_CHAR)
712               then null;
713               end if;
714 
715               l_asset_desc_rec.lease_desc_flex.attribute8 :=
716                  px_asset_desc_rec_new.lease_desc_flex.attribute8;
717 
718           end if;
719       end if;
720 
721       if (px_asset_desc_rec_new.lease_desc_flex.attribute9 is NOT NULL) then
722           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute9, '-999') <>
723               px_asset_desc_rec_new.lease_desc_flex.attribute9) then
724 
725               if (px_asset_desc_rec_new.lease_desc_flex.attribute9 =
726                   FND_API.G_MISS_CHAR)
727               then null;
728               end if;
729 
730               l_asset_desc_rec.lease_desc_flex.attribute9 :=
731                  px_asset_desc_rec_new.lease_desc_flex.attribute9;
732 
733           end if;
734       end if;
735 
736       if (px_asset_desc_rec_new.lease_desc_flex.attribute10 is NOT NULL) then
737           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute10, '-999') <>
738               px_asset_desc_rec_new.lease_desc_flex.attribute10) then
739 
740               if (px_asset_desc_rec_new.lease_desc_flex.attribute10 =
741                   FND_API.G_MISS_CHAR)
742               then null;
743               end if;
744 
745               l_asset_desc_rec.lease_desc_flex.attribute10 :=
746                  px_asset_desc_rec_new.lease_desc_flex.attribute10;
747 
748           end if;
749       end if;
750 
751       if (px_asset_desc_rec_new.lease_desc_flex.attribute11 is NOT NULL) then
752           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute11, '-999') <>
753               px_asset_desc_rec_new.lease_desc_flex.attribute11) then
754 
755               if (px_asset_desc_rec_new.lease_desc_flex.attribute11 =
756                   FND_API.G_MISS_CHAR)
757               then null;
758               end if;
759 
760               l_asset_desc_rec.lease_desc_flex.attribute11 :=
761                  px_asset_desc_rec_new.lease_desc_flex.attribute11;
762 
763           end if;
764       end if;
765 
766       if (px_asset_desc_rec_new.lease_desc_flex.attribute12 is NOT NULL) then
767           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute12, '-999') <>
768               px_asset_desc_rec_new.lease_desc_flex.attribute12) then
769 
770               if (px_asset_desc_rec_new.lease_desc_flex.attribute12 =
771                   FND_API.G_MISS_CHAR)
772               then null;
773               end if;
774 
775               l_asset_desc_rec.lease_desc_flex.attribute12 :=
776                  px_asset_desc_rec_new.lease_desc_flex.attribute12;
777 
778           end if;
779       end if;
780 
781       if (px_asset_desc_rec_new.lease_desc_flex.attribute13 is NOT NULL) then
782           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute13, '-999') <>
783               px_asset_desc_rec_new.lease_desc_flex.attribute13) then
784 
785               if (px_asset_desc_rec_new.lease_desc_flex.attribute13 =
786                   FND_API.G_MISS_CHAR)
787               then null;
788               end if;
789 
790               l_asset_desc_rec.lease_desc_flex.attribute13 :=
791                  px_asset_desc_rec_new.lease_desc_flex.attribute13;
792 
793           end if;
794       end if;
795 
796       if (px_asset_desc_rec_new.lease_desc_flex.attribute14 is NOT NULL) then
797           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute14, '-999') <>
798               px_asset_desc_rec_new.lease_desc_flex.attribute14) then
799 
800               if (px_asset_desc_rec_new.lease_desc_flex.attribute14 =
801                   FND_API.G_MISS_CHAR)
802               then null;
803               end if;
804 
805               l_asset_desc_rec.lease_desc_flex.attribute14 :=
806                  px_asset_desc_rec_new.lease_desc_flex.attribute14;
807 
808           end if;
809       end if;
810 
811       if (px_asset_desc_rec_new.lease_desc_flex.attribute15 is NOT NULL) then
812           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute15, '-999') <>
813               px_asset_desc_rec_new.lease_desc_flex.attribute15) then
814 
815               if (px_asset_desc_rec_new.lease_desc_flex.attribute15 =
816                   FND_API.G_MISS_CHAR)
817               then null;
818               end if;
819 
820               l_asset_desc_rec.lease_desc_flex.attribute15 :=
821                  px_asset_desc_rec_new.lease_desc_flex.attribute15;
822 
823           end if;
824       end if;
825 
826       if (px_asset_desc_rec_new.lease_desc_flex.attribute_category_code
827           is NOT NULL) then
828           if (nvl(l_asset_desc_rec.lease_desc_flex.attribute_category_code,
829                  '-999') <>
830               px_asset_desc_rec_new.lease_desc_flex.attribute_category_code)
831           then
832 
833               if (px_asset_desc_rec_new.lease_desc_flex.attribute_category_code
834                   = FND_API.G_MISS_CHAR)
835               then null;
836               end if;
837 
838               l_asset_desc_rec.lease_desc_flex.attribute_category_code :=
839                  px_asset_desc_rec_new.lease_desc_flex.attribute_category_code;
840 
841           end if;
842       end if;
843 
844       if (px_asset_desc_rec_new.lease_desc_flex.context is NOT NULL) then
845           if (nvl(l_asset_desc_rec.lease_desc_flex.context, '-999') <>
846               px_asset_desc_rec_new.lease_desc_flex.context) then
847 
848               if (px_asset_desc_rec_new.lease_desc_flex.context =
849                   FND_API.G_MISS_CHAR)
850               then null;
851               end if;
852 
853               l_asset_desc_rec.lease_desc_flex.context :=
854                  px_asset_desc_rec_new.lease_desc_flex.context;
855 
856           end if;
857       end if;
858    end if;
859 
860    -- in_use_flag
861    l_err_stage:= 'in_use_flag';
862    if (g_log_level_rec.statement_level) then
863                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
864                               ,p_log_level_rec => g_log_level_rec);
865      end if;
866 
867 
868    if (px_asset_desc_rec_new.in_use_flag is NOT NULL) then
869       if (nvl(l_asset_desc_rec.in_use_flag, '-999') <>
870           px_asset_desc_rec_new.in_use_flag)
871       then
872 
873          if (px_asset_desc_rec_new.in_use_flag = FND_API.G_MISS_CHAR) then
874             --px_asset_desc_rec_new.in_use_flag := NULL;
875             null;
876          end if;
877 
878          l_asset_desc_rec.in_use_flag := px_asset_desc_rec_new.in_use_flag;
879       end if;
880    end if;
881 
882    -- inventorial
883    l_err_stage:= 'inventorial';
884    if (g_log_level_rec.statement_level) then
885                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
886                               ,p_log_level_rec => g_log_level_rec);
887      end if;
888 
889 
890    if (px_asset_desc_rec_new.inventorial is NOT NULL) then
891       if (nvl(l_asset_desc_rec.inventorial, '-999') <> px_asset_desc_rec_new.inventorial)
892       then
893 
894          if (px_asset_desc_rec_new.inventorial = FND_API.G_MISS_CHAR) then
895             --px_asset_desc_rec_new.inventorial := NULL;
896             null;
897          end if;
898 
899          l_asset_desc_rec.inventorial:= px_asset_desc_rec_new.inventorial;
900       end if;
901    end if;
902 
903 
904 -- commitment
905    l_err_stage:= 'commitment';
906    if (g_log_level_rec.statement_level) then
907                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
908                               ,p_log_level_rec => g_log_level_rec);
909      end if;
910 
911 
912    if (px_asset_desc_rec_new.commitment is NOT NULL) then
913 
914          l_asset_desc_rec.commitment:= px_asset_desc_rec_new.commitment;
915 
916    end if;
917 
918    -- investment_law
919    l_err_stage:= 'investment_law';
920    if (g_log_level_rec.statement_level) then
921                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
922                               ,p_log_level_rec => g_log_level_rec);
923      end if;
924 
925 
926    if (px_asset_desc_rec_new.investment_law is NOT NULL) then
927 
928          l_asset_desc_rec.investment_law:= px_asset_desc_rec_new.investment_law;
929 
930    end if;
931 
932    -- property_type_code
933    l_err_stage:= 'property_type_code';
934     if (g_log_level_rec.statement_level) then
935                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
936                               ,p_log_level_rec => g_log_level_rec);
937      end if;
938 
939 
940    if (px_asset_desc_rec_new.property_type_code is NOT NULL) then
941       if (nvl(l_asset_desc_rec.property_type_code, '-999') <>
942           px_asset_desc_rec_new.property_type_code) then
943 
944          if (px_asset_desc_rec_new.property_type_code = FND_API.G_MISS_CHAR)
945             then --px_asset_desc_rec_new.property_type_code := NULL;
946 
947             if (NOT FA_ASSET_VAL_PVT.validate_property_type(
948                p_property_type_code => NULL,
949                p_log_level_rec => g_log_level_rec)) then
950                raise pub_error;
951             end if;
952          else
953             if (NOT FA_ASSET_VAL_PVT.validate_property_type(
954                p_property_type_code => px_asset_desc_rec_new.property_type_code,
955                p_log_level_rec => g_log_level_rec)) then
956                raise pub_error;
957             end if;
958          end if;
959          l_asset_desc_rec.property_type_code :=
960             px_asset_desc_rec_new.property_type_code ;
961       end if;
962    end if;
963 
964    -- property_1245_1250_code
965    l_err_stage:= 'property_1245_1250_code';
966    if (g_log_level_rec.statement_level) then
967                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
968                               ,p_log_level_rec => g_log_level_rec);
969      end if;
970 
971 
972    if (px_asset_desc_rec_new.property_1245_1250_code is NOT NULL) then
973       if (nvl(l_asset_desc_rec.property_1245_1250_code, '-999') <>
974           px_asset_desc_rec_new.property_1245_1250_code) then
975 
976          if (px_asset_desc_rec_new.property_1245_1250_code =
977              FND_API.G_MISS_CHAR) then
978             --px_asset_desc_rec_new.property_1245_1250_code := NULL;
979 
980             if (NOT FA_ASSET_VAL_PVT.validate_1245_1250_code(
981                p_1245_1250_code => NULL,
982                p_log_level_rec => g_log_level_rec)) then
983                raise pub_error;
984             end if;
985          else
986             if (NOT FA_ASSET_VAL_PVT.validate_1245_1250_code(
987                p_1245_1250_code => px_asset_desc_rec_new.property_1245_1250_code,
988                p_log_level_rec => g_log_level_rec)) then
989                raise pub_error;
990             end if;
991          end if;
992 
993          l_asset_desc_rec.property_1245_1250_code :=
994             px_asset_desc_rec_new.property_1245_1250_code;
995       end if;
996    end if;
997 
998    -- owned_leased
999    l_err_stage:= 'owned_leased';
1000    if (g_log_level_rec.statement_level) then
1001                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1002                               ,p_log_level_rec => g_log_level_rec);
1003      end if;
1004 
1005 
1006    if (px_asset_desc_rec_new.owned_leased is NOT NULL) then
1007       if (nvl(l_asset_desc_rec.owned_leased, '-999') <>
1008           px_asset_desc_rec_new.owned_leased) then
1009          if (px_asset_desc_rec_new.owned_leased = FND_API.G_MISS_CHAR) then
1010             null;
1011             --px_asset_desc_rec_new.owned_leased := NULL;
1012          end if;
1013 
1014          l_asset_desc_rec.owned_leased := px_asset_desc_rec_new.owned_leased;
1015       end if;
1016    end if;
1017 
1018    -- new_used
1019    l_err_stage:= 'new_used';
1020    if (g_log_level_rec.statement_level) then
1021                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1022                               ,p_log_level_rec => g_log_level_rec);
1023      end if;
1024 
1025 
1026    if (px_asset_desc_rec_new.new_used is NOT NULL) then
1027       if (nvl(l_asset_desc_rec.new_used, '-999') <>
1028           px_asset_desc_rec_new.new_used) then
1029          if (px_asset_desc_rec_new.new_used = FND_API.G_MISS_CHAR) then
1030             --px_asset_desc_rec_new.new_used := NULL;
1031             null;
1032          end if;
1033 
1034          l_asset_desc_rec.new_used := px_asset_desc_rec_new.new_used;
1035       end if;
1036    end if;
1037 
1038    -- add_cost_je_flag
1039    l_err_stage:= 'add_cost_je_flag';
1040    if (g_log_level_rec.statement_level) then
1041                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1042                               ,p_log_level_rec => g_log_level_rec);
1043      end if;
1044 
1045 
1046    if (px_asset_desc_rec_new.add_cost_je_flag is NOT NULL) then
1047       if (nvl(l_asset_desc_rec.add_cost_je_flag, '-999') <>
1048           px_asset_desc_rec_new.add_cost_je_flag) then
1049 
1050          if (px_asset_desc_rec_new.add_cost_je_flag = FND_API.G_MISS_CHAR) then
1051             --px_asset_desc_rec_new.add_cost_je_flag := NULL;
1052             null;
1053          end if;
1054 
1055          l_asset_desc_rec.add_cost_je_flag :=
1056             px_asset_desc_rec_new.add_cost_je_flag;
1057       end if;
1058    end if;
1059 
1060    -- status
1061    l_err_stage:= 'status';
1062    if (g_log_level_rec.statement_level) then
1063                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1064                               ,p_log_level_rec => g_log_level_rec);
1065      end if;
1066 
1067 
1068    if (px_asset_desc_rec_new.status is NOT NULL) then
1069       if (nvl(l_asset_desc_rec.status, '-999') <>
1070           px_asset_desc_rec_new.status) then
1071 
1072          if (px_asset_desc_rec_new.status = FND_API.G_MISS_CHAR) then
1073             --px_asset_desc_rec_new.status := NULL;
1074             null;
1075          end if;
1076 
1077          l_asset_desc_rec.status :=
1078             px_asset_desc_rec_new.status;
1079       end if;
1080    end if;
1081 
1082    -- Update Global Attributes
1083     l_err_stage:= 'Global_desc_flex';
1084     if (g_log_level_rec.statement_level) then
1085                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1086                               ,p_log_level_rec => g_log_level_rec);
1087      end if;
1088 
1089     l_asset_desc_rec.global_desc_flex := px_asset_desc_rec_new.global_desc_flex;
1090 
1091 
1092    l_err_stage:= 'Update Row';
1093    if (g_log_level_rec.statement_level) then
1094                fa_debug_pkg.add('Update_desc', 'before', l_err_stage
1095                               ,p_log_level_rec => g_log_level_rec);
1096      end if;
1097 
1098    if (NOT update_row(
1099           p_trans_rec          => px_trans_rec,
1100           p_asset_hdr_rec      => px_asset_hdr_rec,
1101           p_asset_desc_rec_new => l_asset_desc_rec,
1102           p_asset_cat_rec_new  => l_asset_cat_rec,
1103           p_old_warranty_id    => l_old_warranty_id,
1104           p_log_level_rec => g_log_level_rec)) then
1105       raise pub_error;
1106    end if;
1107 
1108    if (FND_API.To_Boolean(p_commit)) then
1109       commit;
1110    end if;
1111 
1112    x_return_status :=  FND_API.G_RET_STS_SUCCESS;
1113 
1114 EXCEPTION
1115 
1116    when pub_error then
1117 
1118       ROLLBACK TO do_desc_update;
1119 
1120       fa_srvr_msg.add_message
1121            (calling_fn => 'fa_asset_desc_pub.update_desc',
1122             p_log_level_rec => g_log_level_rec);
1123 
1124       FND_MSG_PUB.count_and_get (
1125          p_count => x_msg_count,
1126          p_data  => x_msg_data
1127       );
1128 
1129       x_return_status :=  FND_API.G_RET_STS_ERROR;
1130 
1131    when others then
1132 
1133       ROLLBACK TO do_desc_update;
1134 
1135       fa_srvr_msg.add_sql_error
1136            (calling_fn => 'fa_asset_desc_pub.update_desc'
1137                       ,p_log_level_rec => g_log_level_rec);
1138 
1139       FND_MSG_PUB.count_and_get (
1140          p_count => x_msg_count,
1141          p_data  => x_msg_data
1142       );
1143 
1144       x_return_status :=  FND_API.G_RET_STS_ERROR;
1145 
1146 END update_desc;
1147 
1148 
1149 FUNCTION update_row(
1150           p_trans_rec           IN fa_api_types.trans_rec_type,
1151           p_asset_hdr_rec       IN fa_api_types.asset_hdr_rec_type,
1152           p_asset_desc_rec_new  IN fa_api_types.asset_desc_rec_type,
1153           p_asset_cat_rec_new   IN fa_api_types.asset_cat_rec_type,
1154           p_old_warranty_id     IN number,
1155           p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) return boolean IS
1156 
1157    l_return_status boolean:= FALSE;
1158    l_calling_fn varchar2(30);
1159    update_error EXCEPTION;
1160    l_rowid            varchar2(10):= null;
1161 BEGIN
1162 
1163    l_calling_fn := 'FA_ASSET_DESC_PUB.update_row';
1164 
1165    -- update fa_additions.
1166    -- for bug no. 3643781. made the serial number case sensitive.
1167    fa_additions_pkg.update_row (
1168          X_Rowid                => l_rowid,
1169          X_Asset_Id             => p_asset_hdr_rec.asset_id,
1170          X_Asset_Number         => upper(p_asset_desc_rec_new.asset_number),
1171          X_Asset_Key_Ccid       => p_asset_desc_rec_new.asset_key_ccid,
1172          X_Current_Units        => p_asset_desc_rec_new.current_units,
1173          X_Tag_Number           => upper(p_asset_desc_rec_new.tag_number),
1174          X_Description          => p_asset_desc_rec_new.description,
1175          X_Asset_Category_Id    => p_asset_cat_rec_new.category_id,
1176          X_Parent_Asset_Id      => p_asset_desc_rec_new.parent_asset_id,
1177          X_Manufacturer_Name    => p_asset_desc_rec_new.manufacturer_name,
1178          X_Serial_Number        => p_asset_desc_rec_new.serial_number,
1179          X_Model_Number         => p_asset_desc_rec_new.model_number,
1180          X_Property_Type_Code   => upper(p_asset_desc_rec_new.property_type_code),
1181          X_Property_1245_1250_Code =>
1182               p_asset_desc_rec_new.property_1245_1250_code,
1183          X_In_Use_Flag          => upper(p_asset_desc_rec_new.in_use_flag),
1184          X_Owned_Leased         => upper(p_asset_desc_rec_new.owned_leased),
1185          X_New_Used             => upper(p_asset_desc_rec_new.new_used),
1186          X_Unit_Adjustment_Flag => upper(p_asset_desc_rec_new.unit_adjustment_flag),
1187          X_Add_Cost_Je_Flag     => upper(p_asset_desc_rec_new.add_cost_je_flag),
1188          X_Attribute1           => p_asset_cat_rec_new.desc_flex.attribute1,
1189          X_Attribute2           => p_asset_cat_rec_new.desc_flex.attribute2,
1190          X_Attribute3           => p_asset_cat_rec_new.desc_flex.attribute3,
1191          X_Attribute4           => p_asset_cat_rec_new.desc_flex.attribute4,
1192          X_Attribute5           => p_asset_cat_rec_new.desc_flex.attribute5,
1193          X_Attribute6           => p_asset_cat_rec_new.desc_flex.attribute6,
1194          X_Attribute7           => p_asset_cat_rec_new.desc_flex.attribute7,
1195          X_Attribute8           => p_asset_cat_rec_new.desc_flex.attribute8,
1196          X_Attribute9           => p_asset_cat_rec_new.desc_flex.attribute9,
1197          X_Attribute10          => p_asset_cat_rec_new.desc_flex.attribute10,
1198          X_Attribute11          => p_asset_cat_rec_new.desc_flex.attribute11,
1199          X_Attribute12          => p_asset_cat_rec_new.desc_flex.attribute12,
1200          X_Attribute13          => p_asset_cat_rec_new.desc_flex.attribute13,
1201          X_Attribute14          => p_asset_cat_rec_new.desc_flex.attribute14,
1202          X_Attribute15          => p_asset_cat_rec_new.desc_flex.attribute15,
1203          X_Attribute16          => p_asset_cat_rec_new.desc_flex.attribute16,
1204          X_Attribute17          => p_asset_cat_rec_new.desc_flex.attribute17,
1205          X_Attribute18          => p_asset_cat_rec_new.desc_flex.attribute18,
1206          X_Attribute19          => p_asset_cat_rec_new.desc_flex.attribute19,
1207          X_Attribute20          => p_asset_cat_rec_new.desc_flex.attribute20,
1208          X_Attribute21          => p_asset_cat_rec_new.desc_flex.attribute21,
1209          X_Attribute22          => p_asset_cat_rec_new.desc_flex.attribute22,
1210          X_Attribute23          => p_asset_cat_rec_new.desc_flex.attribute23,
1211          X_Attribute24          => p_asset_cat_rec_new.desc_flex.attribute24,
1212          X_Attribute25          => p_asset_cat_rec_new.desc_flex.attribute25,
1213          X_Attribute26          => p_asset_cat_rec_new.desc_flex.attribute26,
1214          X_Attribute27          => p_asset_cat_rec_new.desc_flex.attribute27,
1215          X_Attribute28          => p_asset_cat_rec_new.desc_flex.attribute28,
1216          X_Attribute29          => p_asset_cat_rec_new.desc_flex.attribute29,
1217          X_Attribute30          => p_asset_cat_rec_new.desc_flex.attribute30,
1218          X_Attribute_Category_Code =>
1219               p_asset_cat_rec_new.desc_flex.attribute_category_code,
1220          X_gf_Attribute1        =>
1221               p_asset_desc_rec_new.global_desc_flex.attribute1,
1222          X_gf_Attribute2        =>
1223               p_asset_desc_rec_new.global_desc_flex.attribute2,
1224          X_gf_Attribute3        =>
1225               p_asset_desc_rec_new.global_desc_flex.attribute3,
1226          X_gf_Attribute4        =>
1227               p_asset_desc_rec_new.global_desc_flex.attribute4,
1228          X_gf_Attribute5        =>
1229               p_asset_desc_rec_new.global_desc_flex.attribute5,
1230          X_gf_Attribute6        =>
1231               p_asset_desc_rec_new.global_desc_flex.attribute6,
1232          X_gf_Attribute7        =>
1233               p_asset_desc_rec_new.global_desc_flex.attribute7,
1234          X_gf_Attribute8        =>
1235               p_asset_desc_rec_new.global_desc_flex.attribute8,
1236          X_gf_Attribute9        =>
1237               p_asset_desc_rec_new.global_desc_flex.attribute9,
1238          X_gf_Attribute10       =>
1239               p_asset_desc_rec_new.global_desc_flex.attribute10,
1240          X_gf_Attribute11       =>
1241               p_asset_desc_rec_new.global_desc_flex.attribute11,
1242          X_gf_Attribute12       =>
1243               p_asset_desc_rec_new.global_desc_flex.attribute12,
1244          X_gf_Attribute13       =>
1245               p_asset_desc_rec_new.global_desc_flex.attribute13,
1246          X_gf_Attribute14       =>
1247               p_asset_desc_rec_new.global_desc_flex.attribute14,
1248          X_gf_Attribute15       =>
1249               p_asset_desc_rec_new.global_desc_flex.attribute15,
1250          X_gf_Attribute16       =>
1251               p_asset_desc_rec_new.global_desc_flex.attribute16,
1252          X_gf_Attribute17       =>
1253               p_asset_desc_rec_new.global_desc_flex.attribute17,
1254          X_gf_Attribute18       =>
1255               p_asset_desc_rec_new.global_desc_flex.attribute18,
1256          X_gf_Attribute19       =>
1257               p_asset_desc_rec_new.global_desc_flex.attribute19,
1258          X_gf_Attribute20       =>
1259               p_asset_desc_rec_new.global_desc_flex.attribute20,
1260          X_gf_Attribute_Category_Code =>
1261               p_asset_desc_rec_new.global_desc_flex.attribute_category_code,
1262          X_Context              => p_asset_cat_rec_new.desc_flex.context,
1263          X_Lease_Id             => p_asset_desc_rec_new.lease_id,
1264          X_Inventorial          => upper(p_asset_desc_rec_new.inventorial),
1265 	 X_Commitment		=> p_asset_desc_rec_new.commitment,
1266 	 X_Investment_Law	=> p_asset_desc_rec_new.investment_law,
1267          X_Status               => upper(p_asset_desc_rec_new.status),
1268          X_Last_Update_Date     => p_trans_rec.who_info.last_update_date,
1269          X_Last_Updated_By      => p_trans_rec.who_info.last_updated_by,
1270          X_Last_Update_Login    => p_trans_rec.who_info.last_update_login,
1271          x_return_status        => l_return_status,
1272          X_Calling_Fn           => l_calling_fn,
1273          p_log_level_rec        => p_log_level_rec);
1274 
1275    if not l_return_status then
1276       raise update_error;
1277    end if;
1278 
1279 
1280    if ( p_asset_desc_rec_new.lease_id is not null and
1281         p_asset_desc_rec_new.lease_id <> FND_API.G_MISS_NUM) then
1282 
1283         FA_DET_ADD_PKG.UPDATE_LEASE_DF
1284                (X_Lease_Id          => p_asset_desc_rec_new.Lease_Id,
1285                 X_Last_Update_Date  => p_trans_rec.who_info.Last_Update_Date,
1286                 X_Last_Updated_By   => p_trans_rec.who_info.Last_Updated_By,
1287                 X_Last_Update_Login => p_trans_rec.who_info.Last_Update_Login,
1288                 X_Attribute1        =>
1289                    p_asset_desc_rec_new.lease_desc_flex.Attribute1,
1290                 X_Attribute2        =>
1291                    p_asset_desc_rec_new.lease_desc_flex.Attribute2,
1292                 X_Attribute3        =>
1293                    p_asset_desc_rec_new.lease_desc_flex.Attribute3,
1294                 X_Attribute4        =>
1295                    p_asset_desc_rec_new.lease_desc_flex.Attribute4,
1296                 X_Attribute5        =>
1297                    p_asset_desc_rec_new.lease_desc_flex.Attribute5,
1298                 X_Attribute6        =>
1299                    p_asset_desc_rec_new.lease_desc_flex.Attribute6,
1300                 X_Attribute7        =>
1301                    p_asset_desc_rec_new.lease_desc_flex.Attribute7,
1302                 X_Attribute8        =>
1303                    p_asset_desc_rec_new.lease_desc_flex.Attribute8,
1304                 X_Attribute9        =>
1305                    p_asset_desc_rec_new.lease_desc_flex.Attribute9,
1306                 X_Attribute10       =>
1307                    p_asset_desc_rec_new.lease_desc_flex.Attribute10,
1308                 X_Attribute11       =>
1309                    p_asset_desc_rec_new.lease_desc_flex.Attribute11,
1310                 X_Attribute12       =>
1311                    p_asset_desc_rec_new.lease_desc_flex.Attribute12,
1312                 X_Attribute13       =>
1313                    p_asset_desc_rec_new.lease_desc_flex.Attribute13,
1314                 X_Attribute14       =>
1315                    p_asset_desc_rec_new.lease_desc_flex.Attribute14,
1316                 X_Attribute15       =>
1317                    p_asset_desc_rec_new.lease_desc_flex.Attribute15,
1318                 X_Attribute_Category_Code
1319                                     =>
1320                    p_asset_desc_rec_new.lease_desc_flex.Attribute_Category_Code,
1321                 X_Return_Status     => l_return_status,
1322                 X_Calling_Fn        => l_calling_fn,
1323                 p_log_level_rec     => p_log_level_rec);
1324 
1325       if not l_return_status then
1326          raise update_error;
1327       end if;
1328    end if;
1329 
1330    -- Update warranty info
1331    if (p_asset_desc_rec_new.warranty_id is NOT NULL) then
1332       if ((p_asset_desc_rec_new.warranty_id = FND_API.G_MISS_NUM) and
1333           (p_old_warranty_id is NOT NULL)) then
1334           -- Remove an existing warranty from an asset
1335           FA_ADD_WARRANTY_PKG.Update_table(
1336              WR_warranty_id       => NULL,
1337              WR_old_warranty_id   => p_old_warranty_id,
1338              WR_asset_id          => p_asset_hdr_rec.asset_id,
1339              WR_date_effective    => NULL,
1340              WR_date_ineffective  => p_trans_rec.who_info.last_update_date,
1341              WR_last_update_date  => p_trans_rec.who_info.last_update_date,
1342              WR_last_updated_by   => p_trans_rec.who_info.last_updated_by,
1343              WR_created_by        => NULL,
1344              WR_creation_date     => NULL,
1345              WR_last_update_login => p_trans_rec.who_info.last_update_login,
1346              WR_Update_Row        => 'YES',
1347              WR_Insert_Row        => 'NO',
1348              WR_calling_fn        => 'fa_asset_desc_pub.update_row' ,
1349              p_log_level_rec => p_log_level_rec);
1350       elsif (p_old_warranty_id is NULL) then
1351          -- Add a warranty to an asset that doesn't have one
1352          FA_ADD_WARRANTY_PKG.Update_table(
1353              WR_warranty_id       => p_asset_desc_rec_new.warranty_id,
1354              WR_old_warranty_id   => NULL,
1355              WR_asset_id          => p_asset_hdr_rec.asset_id,
1356              WR_date_effective    => p_trans_rec.who_info.last_update_date,
1357              WR_date_ineffective  => NULL,
1358              WR_last_update_date  => p_trans_rec.who_info.last_update_date,
1359              WR_last_updated_by   => p_trans_rec.who_info.last_updated_by,
1360              WR_created_by        => p_trans_rec.who_info.last_updated_by,
1361              WR_creation_date     => p_trans_rec.who_info.last_update_date,
1362              WR_last_update_login => p_trans_rec.who_info.last_update_login,
1363              WR_Update_Row        => 'NO',
1364              WR_Insert_Row        => 'YES',
1365              WR_calling_fn        => 'fa_asset_desc_pub.update_row' ,
1366              p_log_level_rec => p_log_level_rec);
1367       elsif (p_asset_desc_rec_new.warranty_id <> p_old_warranty_id) then
1368          -- Change an asset's existing warranty
1369          FA_ADD_WARRANTY_PKG.Update_table(
1370              WR_warranty_id       => p_asset_desc_rec_new.warranty_id,
1371              WR_old_warranty_id   => p_old_warranty_id,
1372              WR_asset_id          => p_asset_hdr_rec.asset_id,
1373              WR_date_effective    => p_trans_rec.who_info.last_update_date,
1374              WR_date_ineffective  => p_trans_rec.who_info.last_update_date,
1375              WR_last_update_date  => p_trans_rec.who_info.last_update_date,
1376              WR_last_updated_by   => p_trans_rec.who_info.last_updated_by,
1377              WR_created_by        => p_trans_rec.who_info.last_updated_by,
1378              WR_creation_date     => p_trans_rec.who_info.last_update_date,
1379              WR_last_update_login => p_trans_rec.who_info.last_update_login,
1380              WR_Update_Row        => 'YES',
1381              WR_Insert_Row        => 'YES',
1382              WR_calling_fn        => 'fa_asset_desc_pub.update_row' ,
1383              p_log_level_rec => p_log_level_rec);
1384       end if;
1385    end if;
1386 
1387    return TRUE;
1388 
1389 EXCEPTION
1390    when update_error then
1391 	FA_SRVR_MSG.Add_Message(
1392 	           Calling_Fn	       => l_calling_fn
1393 	           ,p_log_level_rec => p_log_level_rec);
1394 
1395 	return FALSE;
1396    when others then
1397         fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
1398                 ,p_log_level_rec => p_log_level_rec);
1399         return FALSE;
1400 
1401 END update_row;
1402 
1403 
1404 PROCEDURE update_invoice_desc(
1405           -- Standard Parameters --
1406           p_api_version           IN     NUMBER,
1407           p_init_msg_list         IN     VARCHAR2 := FND_API.G_FALSE,
1408           p_commit                IN     VARCHAR2 := FND_API.G_FALSE,
1409           p_validation_level      IN     NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1410           x_return_status            OUT NOCOPY VARCHAR2,
1411           x_msg_count                OUT NOCOPY NUMBER,
1412           x_msg_data                 OUT NOCOPY VARCHAR2,
1413           p_calling_fn            IN     VARCHAR2,
1414           -- Transaction Object --
1415           px_trans_rec            IN OUT NOCOPY fa_api_types.trans_rec_type,
1416           -- Asset Object --
1417           px_asset_hdr_rec        IN OUT NOCOPY fa_api_types.asset_hdr_rec_type,
1418           px_inv_tbl_new          IN OUT NOCOPY fa_api_types.inv_tbl_type) IS
1419 
1420    inv_err         exception;
1421 
1422    l_rowid                        ROWID;
1423    l_period_rec                   fa_api_types.period_rec_type;
1424    l_inv_rec                      fa_api_types.inv_rec_type;
1425 
1426    l_calling_fn varchar2(40) := 'FA_ASSET_DESC_PUB.update_invoice_desc';
1427 
1428    -- Bug 5475276 Cursor to get the book_type_code
1429    CURSOR c_corp_book( p_asset_id number ) IS
1430         SELECT bc.book_type_code
1431           FROM fa_books bks,
1432                fa_book_controls bc
1433          WHERE bks.book_type_code = bc.distribution_source_book
1434            AND bks.book_type_code = bc.book_type_code
1435            AND bks.asset_id       = p_asset_id
1436            AND bks.transaction_header_id_out is null;
1437 
1438 
1439    -- For primary and reporting books
1440    l_reporting_flag               varchar2(1) := 'P';
1441    l_rsob_tbl                     fa_cache_pkg.fazcrsob_sob_tbl_type;
1442    l_mrc_asset_hdr_rec            fa_api_types.asset_hdr_rec_type;
1443 
1444 BEGIN
1445 
1446    SAVEPOINT do_invoice_desc_update;
1447 
1448    if (not g_log_level_rec.initialized) then
1449       if (NOT fa_util_pub.get_log_level_rec (
1450                 x_log_level_rec =>  g_log_level_rec
1451       )) then
1452          raise inv_err;
1453       end if;
1454    end if;
1455 
1456    -- Initialize message list if p_init_msg_list is set to TRUE.
1457    if (fnd_api.to_boolean(p_init_msg_list)) then
1458         -- initialize error message stack.
1459         fa_srvr_msg.init_server_message;
1460 
1461         -- initialize debug message stack.
1462         fa_debug_pkg.initialize;
1463    end if;
1464 
1465    -- Check version of the API
1466    -- Standard call to check for API call compatibility.
1467    if (NOT fnd_api.compatible_api_call (
1468           G_API_VERSION,
1469           p_api_version,
1470           G_API_NAME,
1471           G_PKG_NAME
1472    )) then
1473       raise inv_err;
1474    end if;
1475 
1476    -- Bug 5475276 Get the book_type_code if it is not supplied.
1477    if (px_asset_hdr_rec.book_type_code is null) then
1478       open c_corp_book( px_asset_hdr_rec.asset_id );
1479       fetch c_corp_book into px_asset_hdr_rec.book_type_code;
1480       close c_corp_book;
1481 
1482       if px_asset_hdr_rec.book_type_code is null then
1483          fa_srvr_msg.add_message
1484              (calling_fn => l_calling_fn,
1485               name       => 'FA_EXP_GET_ASSET_INFO'
1486               ,p_log_level_rec => g_log_level_rec);
1487          raise inv_err;
1488       end if;
1489    end if;
1490 
1491    -- Call the cache for the primary transaction book
1492    if (NOT fa_cache_pkg.fazcbc (
1493       X_book => px_asset_hdr_rec.book_type_code,
1494       p_log_level_rec  => g_log_level_rec)) then
1495       raise inv_err;
1496    end if;
1497 
1498    px_asset_hdr_rec.set_of_books_id :=
1499       fa_cache_pkg.fazcbc_record.set_of_books_id;
1500 
1501    -- Set the gl_sob profile to this book
1502    fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
1503    fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
1504 
1505    if (NOT FA_UTIL_PVT.get_period_rec (
1506       p_book           => px_asset_hdr_rec.book_type_code,
1507       p_effective_date => NULL,
1508       x_period_rec     => l_period_rec,
1509       p_log_level_rec  => g_log_level_rec)) then
1510       raise inv_err;
1511    end if;
1512 
1513    -- Call cache to verify whether this is a primary or reporting book
1514    if (NOT fa_cache_pkg.fazcsob (
1515       X_set_of_books_id   => px_asset_hdr_rec.set_of_books_id,
1516       X_mrc_sob_type_code => l_reporting_flag,
1517       p_log_level_rec  => g_log_level_rec)) then
1518       raise inv_err;
1519    end if;
1520 
1521    -- Call the reporting books cache to get rep books.
1522    if (l_reporting_flag <> 'R') then
1523       if (NOT fa_cache_pkg.fazcrsob (
1524          x_book_type_code => px_asset_hdr_rec.book_type_code,
1525          x_sob_tbl        => l_rsob_tbl,
1526          p_log_level_rec  => g_log_level_rec)) then
1527          raise inv_err;
1528       end if;
1529    end if;
1530 
1531    for mrc_index in 0..l_rsob_tbl.COUNT loop
1532 
1533       l_mrc_asset_hdr_rec := px_asset_hdr_rec;
1534 
1535       -- if the counter mrc_index  is at 0, then process incoming
1536       -- book else iterate through reporting books
1537       if (mrc_index  = 0) then
1538          l_mrc_asset_hdr_rec.set_of_books_id :=
1539             px_asset_hdr_rec.set_of_books_id;
1540       else
1541          l_mrc_asset_hdr_rec.set_of_books_id :=
1542             l_rsob_tbl(mrc_index);
1543          l_reporting_flag := 'R';
1544       end if;
1545 
1546       -- Set the gl_sob profile to this reporting book
1547       fnd_profile.put('GL_SET_OF_BKS_ID', l_mrc_asset_hdr_rec.set_of_books_id);
1548       fnd_client_info.set_currency_context
1549          (l_mrc_asset_hdr_rec.set_of_books_id);
1550 
1551       -- Need to always call fazcbcs
1552       if (NOT fa_cache_pkg.fazcbcs (
1553          X_book => l_mrc_asset_hdr_rec.book_type_code,
1554          p_log_level_rec  => g_log_level_rec)) then
1555          raise inv_err;
1556       end if;
1557 /*
1558       -- call transaction approval for primary books only
1559       -- Will probably need to break this into an MRC wrapper thing
1560       if (l_reporting_flag <> 'R') then
1561          if (NOT fa_trx_approval_pkg.faxcat (
1562                X_book              => l_mrc_asset_hdr_rec.book_type_code,
1563                X_asset_id          => l_mrc_asset_hdr_rec.asset_id,
1564                X_trx_type          => px_trans_rec.transaction_type_code,
1565                X_trx_date          => px_trans_rec.transaction_date_entered,
1566                X_init_message_flag => 'NO',
1567                p_log_level_rec  => g_log_level_rec)) then
1568             raise inv_err;
1569          end if;
1570       end if;
1571 */
1572       for i in 1 .. px_inv_tbl_new.COUNT loop
1573 
1574          -- Retrieve old invoice record
1575          l_inv_rec.source_line_id := px_inv_tbl_new(i).source_line_id;
1576 
1577          if (NOT FA_UTIL_PVT.get_inv_rec (
1578             px_inv_rec          => l_inv_rec,
1579             p_mrc_sob_type_code => l_reporting_flag,
1580             p_log_level_rec  => g_log_level_rec)) then
1581             raise inv_err;
1582          end if;
1583 
1584          -- Invoice_Number
1585          if (px_inv_tbl_new(i).invoice_number is NOT NULL) then
1586             if (nvl(l_inv_rec.invoice_number, '-999') <>
1587                 px_inv_tbl_new(i).invoice_number)
1588             then
1589                if (px_inv_tbl_new(i).invoice_number = FND_API.G_MISS_CHAR) then
1590                   --px_inv_tbl_new(i).invoice_number := NULL;
1591                   null;
1592                end if;
1593 
1594                l_inv_rec.invoice_number := px_inv_tbl_new(i).invoice_number;
1595             end if;
1596          end if;
1597 
1598          -- Ap_Distribution_Line_Number
1599          if (px_inv_tbl_new(i).ap_distribution_line_number is NOT NULL) then
1600             if (nvl(l_inv_rec.ap_distribution_line_number, -999) <>
1601                 px_inv_tbl_new(i).ap_distribution_line_number) then
1602                if (px_inv_tbl_new(i).ap_distribution_line_number =
1603                    FND_API.G_MISS_NUM) then
1604                    --px_inv_tbl_new(i).ap_distribution_line_number := NULL;
1605                    null;
1606                end if;
1607 
1608                l_inv_rec.ap_distribution_line_number :=
1609                   px_inv_tbl_new(i).ap_distribution_line_number;
1610             end if;
1611          end if;
1612 
1613          -- Invoice_Line_Number
1614          if (px_inv_tbl_new(i).invoice_line_number is NOT NULL) then
1615             if (nvl(l_inv_rec.invoice_line_number, '-999') <>
1616                 px_inv_tbl_new(i).invoice_line_number)
1617             then
1618                if (px_inv_tbl_new(i).invoice_line_number = FND_API.G_MISS_NUM) then
1619                   --px_inv_tbl_new(i).invoice_line_number := NULL;
1620                   null;
1621                end if;
1622 
1623                l_inv_rec.invoice_line_number := px_inv_tbl_new(i).invoice_line_number;
1624             end if;
1625          end if;
1626 
1627          -- Invoice_Distribution_id
1628          if (px_inv_tbl_new(i).invoice_distribution_id is NOT NULL) then
1629             if (nvl(l_inv_rec.invoice_distribution_id, '-999') <>
1630                 px_inv_tbl_new(i).invoice_distribution_id)
1631             then
1632                if (px_inv_tbl_new(i).invoice_distribution_id = FND_API.G_MISS_NUM) then
1633                   --px_inv_tbl_new(i).invoice_distribution_id := NULL;
1634                   null;
1635                end if;
1636 
1637                l_inv_rec.invoice_distribution_id := px_inv_tbl_new(i).invoice_distribution_id;
1638             end if;
1639          end if;
1640 
1641          -- Po_Distribution_id
1642          if (px_inv_tbl_new(i).po_distribution_id is NOT NULL) then
1643             if (nvl(l_inv_rec.po_distribution_id, '-999') <>
1644                 px_inv_tbl_new(i).po_distribution_id)
1645             then
1646                if (px_inv_tbl_new(i).po_distribution_id = FND_API.G_MISS_NUM) then
1647                   --px_inv_tbl_new(i).po_distribution_id := NULL;
1648                   null;
1649                end if;
1650 
1651                l_inv_rec.po_distribution_id := px_inv_tbl_new(i).po_distribution_id;
1652             end if;
1653          end if;
1654 
1655          -- Description
1656          if (px_inv_tbl_new(i).description is NOT NULL) then
1657             if (nvl(l_inv_rec.description, '-999') <>
1658                 px_inv_tbl_new(i).description) then
1659                if (px_inv_tbl_new(i).description = FND_API.G_MISS_CHAR) then
1660                   --px_inv_tbl_new(i).description := NULL;
1661                   null;
1662                end if;
1663 
1664                l_inv_rec.description := px_inv_tbl_new(i).description;
1665             end if;
1666          end if;
1667 
1668          -- Deleted_Flag
1669          if (px_inv_tbl_new(i).deleted_flag is NOT NULL) then
1670             if (nvl(l_inv_rec.deleted_flag, '-999') <>
1671                 px_inv_tbl_new(i).deleted_flag) then
1672                if (px_inv_tbl_new(i).deleted_flag = FND_API.G_MISS_CHAR) then
1673                   --px_inv_tbl_new(i).deleted_flag := NULL;
1674                   null;
1675                end if;
1676 
1677                l_inv_rec.deleted_flag := px_inv_tbl_new(i).deleted_flag;
1678 
1679             end if;
1680          end if;
1681 
1682          -- PO_Vendor_Id
1683          if (px_inv_tbl_new(i).po_vendor_id is NOT NULL) then
1684             if (nvl(l_inv_rec.po_vendor_id, -999) <>
1685                 px_inv_tbl_new(i).po_vendor_id) then
1686                if (px_inv_tbl_new(i).po_vendor_id = FND_API.G_MISS_NUM) then
1687                   --px_inv_tbl_new(i).po_vendor_id := NULL;
1688                   null;
1689                end if;
1690 
1691                l_inv_rec.po_vendor_id := px_inv_tbl_new(i).po_vendor_id;
1692             end if;
1693          end if;
1694 
1695          -- PO_Number
1696          if (px_inv_tbl_new(i).po_number is NOT NULL) then
1697             if (nvl(l_inv_rec.po_number, '-999') <>
1698                 px_inv_tbl_new(i).po_number) then
1699                if (px_inv_tbl_new(i).po_number = FND_API.G_MISS_CHAR) then
1700                   --px_inv_tbl_new(i).po_number := NULL;
1701                   null;
1702                end if;
1703 
1704                l_inv_rec.po_number := px_inv_tbl_new(i).po_number;
1705             end if;
1706          end if;
1707 
1708          -- Payables_Batch_Name
1709          if (px_inv_tbl_new(i).payables_batch_name is NOT NULL) then
1710             if (nvl(l_inv_rec.payables_batch_name, '-999') <>
1711                 px_inv_tbl_new(i).payables_batch_name) then
1712                if (px_inv_tbl_new(i).payables_batch_name = FND_API.G_MISS_CHAR)
1713                   then null; --px_inv_tbl_new(i).payables_batch_name := NULL;
1714                end if;
1715 
1716                l_inv_rec.payables_batch_name :=
1717                   px_inv_tbl_new(i).payables_batch_name;
1718             end if;
1719          end if;
1720 
1721          -- Project_Asset_Line_Id
1722          if (px_inv_tbl_new(i).project_asset_line_id is NOT NULL) then
1723             if (nvl(l_inv_rec.project_asset_line_id, -999) <>
1724                 px_inv_tbl_new(i).project_asset_line_id) then
1725                if (px_inv_tbl_new(i).project_asset_line_id =
1726                    FND_API.G_MISS_NUM) then
1727                   --px_inv_tbl_new(i).project_asset_line_id := NULL;
1728                   null;
1729                end if;
1730 
1731                l_inv_rec.project_asset_line_id :=
1732                   px_inv_tbl_new(i).project_asset_line_id;
1733             end if;
1734          end if;
1735 
1736          -- Project_Id
1737          if (px_inv_tbl_new(i).project_id is NOT NULL) then
1738             if (nvl(l_inv_rec.project_id, -999) <>
1739                 px_inv_tbl_new(i).project_id) then
1740                if (px_inv_tbl_new(i).project_id = FND_API.G_MISS_NUM) then
1741                   --px_inv_tbl_new(i).project_id := NULL;
1742                   null;
1743                end if;
1744 
1745                l_inv_rec.project_id := px_inv_tbl_new(i).project_id;
1746             end if;
1747          end if;
1748 
1749          -- Task_Id
1750          if (px_inv_tbl_new(i).task_id is NOT NULL) then
1751             if (nvl(l_inv_rec.task_id, -999) <> px_inv_tbl_new(i).task_id) then
1752                if (px_inv_tbl_new(i).task_id = FND_API.G_MISS_NUM) then
1753                   --px_inv_tbl_new(i).task_id := NULL;
1754                   null;
1755                end if;
1756 
1757                l_inv_rec.task_id := px_inv_tbl_new(i).task_id;
1758             end if;
1759          end if;
1760 
1761          -- Material Indicator
1762          if (px_inv_tbl_new(i).material_indicator_flag is NOT NULL) then
1763             if (nvl(l_inv_rec.material_indicator_flag, '-999') <>
1764                 px_inv_tbl_new(i).material_indicator_flag) then
1765                if (px_inv_tbl_new(i).material_indicator_flag =
1766                    FND_API.G_MISS_CHAR) then
1767                   --px_inv_tbl_new(i).material_indicator_flag := NULL;
1768                   null;
1769                end if;
1770 
1771                l_inv_rec.material_indicator_flag :=
1772                   px_inv_tbl_new(i).material_indicator_flag;
1773             end if;
1774          end if;
1775 
1776          -- Flex Columns
1777          if (px_inv_tbl_new(i).attribute1 is NOT NULL) then
1778             if (nvl(l_inv_rec.attribute1, '-999') <>
1779                 px_inv_tbl_new(i).attribute1) then
1780 
1781                l_inv_rec.attribute1 := px_inv_tbl_new(i).attribute1;
1782             end if;
1783          end if;
1784 
1785          if (px_inv_tbl_new(i).attribute2 is NOT NULL) then
1786             if (nvl(l_inv_rec.attribute2, '-999') <>
1787                 px_inv_tbl_new(i).attribute2) then
1788 
1789                l_inv_rec.attribute2 := px_inv_tbl_new(i).attribute2;
1790             end if;
1791          end if;
1792 
1793          if (px_inv_tbl_new(i).attribute3 is NOT NULL) then
1794             if (nvl(l_inv_rec.attribute3, '-999') <>
1795                 px_inv_tbl_new(i).attribute3) then
1796 
1797                l_inv_rec.attribute3 := px_inv_tbl_new(i).attribute3;
1798             end if;
1799          end if;
1800 
1801          if (px_inv_tbl_new(i).attribute4 is NOT NULL) then
1802             if (nvl(l_inv_rec.attribute4, '-999') <>
1803                 px_inv_tbl_new(i).attribute4) then
1804 
1805                l_inv_rec.attribute4 := px_inv_tbl_new(i).attribute4;
1806             end if;
1807          end if;
1808 
1809          if (px_inv_tbl_new(i).attribute5 is NOT NULL) then
1810             if (nvl(l_inv_rec.attribute5, '-999') <>
1811                 px_inv_tbl_new(i).attribute5) then
1812 
1813                l_inv_rec.attribute5 := px_inv_tbl_new(i).attribute5;
1814             end if;
1815          end if;
1816 
1817          if (px_inv_tbl_new(i).attribute6 is NOT NULL) then
1818             if (nvl(l_inv_rec.attribute6, '-999') <>
1819                 px_inv_tbl_new(i).attribute6) then
1820 
1821                l_inv_rec.attribute6 := px_inv_tbl_new(i).attribute6;
1822             end if;
1823          end if;
1824 
1825          if (px_inv_tbl_new(i).attribute7 is NOT NULL) then
1826             if (nvl(l_inv_rec.attribute7, '-999') <>
1827                 px_inv_tbl_new(i).attribute7) then
1828 
1829                l_inv_rec.attribute7 := px_inv_tbl_new(i).attribute7;
1830             end if;
1831          end if;
1832 
1833          if (px_inv_tbl_new(i).attribute8 is NOT NULL) then
1834             if (nvl(l_inv_rec.attribute8, '-999') <>
1835                 px_inv_tbl_new(i).attribute8) then
1836 
1837                l_inv_rec.attribute8 := px_inv_tbl_new(i).attribute8;
1838             end if;
1839          end if;
1840 
1841          if (px_inv_tbl_new(i).attribute9 is NOT NULL) then
1842             if (nvl(l_inv_rec.attribute9, '-999') <>
1843                 px_inv_tbl_new(i).attribute9) then
1844 
1845                l_inv_rec.attribute9 := px_inv_tbl_new(i).attribute9;
1846             end if;
1847          end if;
1848 
1849          if (px_inv_tbl_new(i).attribute10 is NOT NULL) then
1850             if (nvl(l_inv_rec.attribute10, '-999') <>
1851                 px_inv_tbl_new(i).attribute10) then
1852 
1853                l_inv_rec.attribute10 := px_inv_tbl_new(i).attribute10;
1854             end if;
1855          end if;
1856 
1857          if (px_inv_tbl_new(i).attribute11 is NOT NULL) then
1858             if (nvl(l_inv_rec.attribute11, '-999') <>
1859                 px_inv_tbl_new(i).attribute11) then
1860 
1861                l_inv_rec.attribute11 := px_inv_tbl_new(i).attribute11;
1862             end if;
1863          end if;
1864 
1865          if (px_inv_tbl_new(i).attribute12 is NOT NULL) then
1866             if (nvl(l_inv_rec.attribute12, '-999') <>
1867                 px_inv_tbl_new(i).attribute12) then
1868 
1869                l_inv_rec.attribute12 := px_inv_tbl_new(i).attribute12;
1870             end if;
1871          end if;
1872 
1873          if (px_inv_tbl_new(i).attribute13 is NOT NULL) then
1874             if (nvl(l_inv_rec.attribute13, '-999') <>
1875                 px_inv_tbl_new(i).attribute13) then
1876 
1877                l_inv_rec.attribute13 := px_inv_tbl_new(i).attribute13;
1878             end if;
1879          end if;
1880 
1881          if (px_inv_tbl_new(i).attribute14 is NOT NULL) then
1882             if (nvl(l_inv_rec.attribute14, '-999') <>
1883                 px_inv_tbl_new(i).attribute14) then
1884 
1885                l_inv_rec.attribute14 := px_inv_tbl_new(i).attribute14;
1886             end if;
1887          end if;
1888 
1889          if (px_inv_tbl_new(i).attribute15 is NOT NULL) then
1890             if (nvl(l_inv_rec.attribute15, '-999') <>
1891                 px_inv_tbl_new(i).attribute15) then
1892 
1893                l_inv_rec.attribute15 := px_inv_tbl_new(i).attribute15;
1894             end if;
1895          end if;
1896 
1897          if (px_inv_tbl_new(i).attribute_category_code is NOT NULL) then
1898             if (nvl(l_inv_rec.attribute_category_code, '-999') <>
1899                 px_inv_tbl_new(i).attribute_category_code) then
1900 
1901                l_inv_rec.attribute_category_code :=
1902                   px_inv_tbl_new(i).attribute_category_code;
1903             end if;
1904          end if;
1905 
1906          l_rowid := NULL;
1907 
1908          FA_ASSET_INVOICES_PKG.Update_Row (
1909             X_Rowid                      => l_rowid,
1910             X_Source_Line_id             => l_inv_rec.Source_Line_Id,
1911             X_Asset_Id                   => l_mrc_asset_hdr_rec.asset_id,
1912             X_Po_Vendor_Id               => l_inv_rec.Po_Vendor_Id,
1913             X_Asset_Invoice_Id           => l_inv_rec.Asset_Invoice_Id,
1914             X_Fixed_Assets_Cost          => l_inv_rec.Fixed_Assets_Cost,
1915             X_Deleted_Flag               => l_inv_rec.Deleted_Flag,
1916             X_Po_Number                  => l_inv_rec.Po_Number,
1917             X_Invoice_Number             => l_inv_rec.Invoice_Number,
1918             X_Payables_Batch_Name        => l_inv_rec.Payables_Batch_Name,
1919             X_Payables_Code_Combination_Id
1920                                          =>
1921                l_inv_rec.Payables_Code_Combination_Id,
1922             X_Feeder_System_Name         =>
1923                l_inv_rec.Feeder_System_Name,
1924             X_Create_Batch_Date          => l_inv_rec.Create_Batch_Date,
1925             X_Create_Batch_Id            => l_inv_rec.Create_Batch_Id,
1926             X_Invoice_Date               => l_inv_rec.Invoice_Date,
1927             X_Payables_Cost              => l_inv_rec.Payables_Cost,
1928             X_Post_Batch_Id              => l_inv_rec.Post_Batch_Id,
1929             X_Invoice_Id                 => l_inv_rec.Invoice_Id,
1930             X_Ap_Distribution_Line_Number
1931                                          =>
1932                l_inv_rec.Ap_Distribution_Line_Number,
1933             X_Payables_Units             => l_inv_rec.Payables_Units,
1934             X_Split_Merged_Code          => l_inv_rec.Split_Merged_Code,
1935             X_Description                => l_inv_rec.Description,
1936             X_Parent_Mass_Addition_Id    => l_inv_rec.Parent_Mass_Addition_Id,
1937             X_Last_Update_Date           =>
1938                px_trans_rec.who_info.Last_Update_Date,
1939             X_Last_Updated_By            =>
1940                px_trans_rec.who_info.Last_Updated_By,
1941             X_Last_Update_Login          =>
1942                px_trans_rec.who_info.Last_Update_Login,
1943             X_Attribute1                 => l_inv_rec.Attribute1,
1944             X_Attribute2                 => l_inv_rec.Attribute2,
1945             X_Attribute3                 => l_inv_rec.Attribute3,
1946             X_Attribute4                 => l_inv_rec.Attribute4,
1947             X_Attribute5                 => l_inv_rec.Attribute5,
1948             X_Attribute6                 => l_inv_rec.Attribute6,
1949             X_Attribute7                 => l_inv_rec.Attribute7,
1950             X_Attribute8                 => l_inv_rec.Attribute8,
1951             X_Attribute9                 => l_inv_rec.Attribute9,
1952             X_Attribute10                => l_inv_rec.Attribute10,
1953             X_Attribute11                => l_inv_rec.Attribute11,
1954             X_Attribute12                => l_inv_rec.Attribute12,
1955             X_Attribute13                => l_inv_rec.Attribute13,
1956             X_Attribute14                => l_inv_rec.Attribute14,
1957             X_Attribute15                => l_inv_rec.Attribute15,
1958             X_Attribute_Category_Code    =>
1959                l_inv_rec.Attribute_Category_Code,
1960             X_Unrevalued_Cost            => l_inv_rec.Unrevalued_Cost,
1961             X_Merged_Code                => l_inv_rec.Merged_Code,
1962             X_Split_Code                 => l_inv_rec.Split_Code,
1963             X_Merge_Parent_Mass_Add_Id   =>
1964                l_inv_rec.Merge_Parent_Mass_Additions_Id,
1965             X_Split_Parent_Mass_Add_Id   =>
1966                l_inv_rec.Split_Parent_Mass_Additions_Id,
1967             X_Project_Asset_Line_Id      =>
1968                l_inv_rec.Project_Asset_Line_Id,
1969             X_Project_Id                 => l_inv_rec.Project_Id,
1970             X_Task_Id                    => l_inv_rec.Task_Id,
1971             X_Material_Indicator_Flag    => l_inv_rec.Material_Indicator_Flag,
1972             X_invoice_distribution_id    => l_inv_rec.Invoice_distribution_id,
1973             X_invoice_line_number        => l_inv_rec.Invoice_line_number,
1974             X_po_distribution_id         => l_inv_rec.Po_distribution_id,
1975             X_mrc_sob_type_code          => l_reporting_flag,
1976             X_Calling_Fn                 => p_calling_fn,
1977             p_log_level_rec  => g_log_level_rec);
1978       end loop;
1979    end loop;
1980 
1981    -- commit if p_commit is TRUE.
1982    if (fnd_api.to_boolean (p_commit)) then
1983         COMMIT WORK;
1984    end if;
1985 
1986    -- Reset the gl_sob profile to this book
1987    fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
1988    fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
1989 
1990    -- Standard call to get message count and if count is 1 get message info.
1991    fnd_msg_pub.count_and_get (
1992       p_count   => x_msg_count,
1993       p_data    => x_msg_data
1994    );
1995 
1996    x_return_status := FND_API.G_RET_STS_SUCCESS;
1997 
1998 EXCEPTION
1999 
2000    WHEN inv_err THEN
2001 
2002       ROLLBACK TO do_invoice_desc_update;
2003 
2004       -- set back to original environment when the procedure is finished
2005       fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2006       fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2007 
2008       fa_srvr_msg.add_message
2009            (calling_fn => l_calling_fn,
2010             p_log_level_rec => g_log_level_rec);
2011 
2012       FND_MSG_PUB.count_and_get (
2013          p_count => x_msg_count,
2014          p_data  => x_msg_data
2015       );
2016 
2017       x_return_status := FND_API.G_RET_STS_ERROR;
2018 
2019    WHEN OTHERS THEN
2020 
2021       ROLLBACK TO do_invoice_desc_update;
2022 
2023       -- set back to original environment when the procedure is finished
2024       fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2025       fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2026 
2027       fa_srvr_msg.add_sql_error
2028            (calling_fn => l_calling_fn
2029                       ,p_log_level_rec => g_log_level_rec);
2030 
2031       FND_MSG_PUB.count_and_get (
2032          p_count => x_msg_count,
2033          p_data  => x_msg_data
2034       );
2035 
2036       x_return_status := FND_API.G_RET_STS_ERROR;
2037 
2038 END update_invoice_desc;
2039 
2040 PROCEDURE update_retirement_desc(
2041           -- Standard Parameters --
2042           p_api_version           IN     NUMBER,
2043           p_init_msg_list         IN     VARCHAR2 := FND_API.G_FALSE,
2044           p_commit                IN     VARCHAR2 := FND_API.G_FALSE,
2045           p_validation_level      IN     NUMBER   := FND_API.G_VALID_LEVEL_FULL,
2046           x_return_status            OUT NOCOPY VARCHAR2,
2047           x_msg_count                OUT NOCOPY NUMBER,
2048           x_msg_data                 OUT NOCOPY VARCHAR2,
2049           p_calling_fn            IN     VARCHAR2,
2050           -- Transaction Object --
2051           px_trans_rec            IN OUT NOCOPY fa_api_types.trans_rec_type,
2052           -- Asset Object --
2053           px_asset_hdr_rec        IN OUT NOCOPY fa_api_types.asset_hdr_rec_type,
2054           px_asset_retire_rec_new IN OUT NOCOPY fa_api_types.asset_retire_rec_type) AS
2055 
2056    ret_err         exception;
2057 
2058    l_rowid                        ROWID;
2059    l_period_rec                   fa_api_types.period_rec_type;
2060    l_asset_retire_rec             fa_api_types.asset_retire_rec_type;
2061 
2062    l_calling_fn varchar2(40) := 'FA_ASSET_DESC_PUB.update_retirement_desc';
2063 
2064    -- For primary and reporting books
2065    l_reporting_flag               varchar2(1) := 'P';
2066    l_rsob_tbl                     fa_cache_pkg.fazcrsob_sob_tbl_type;
2067    l_mrc_asset_hdr_rec            fa_api_types.asset_hdr_rec_type;
2068 
2069    l_old_primary_proceeds_of_sale number;
2070    l_old_primary_cost_of_removal  number;
2071    l_old_rep_proceeds_of_sale     number;
2072    l_old_rep_cost_of_removal      number;
2073    l_rate                         number;
2074 
2075 BEGIN
2076 
2077    SAVEPOINT do_retirement_desc_update;
2078    if (not g_log_level_rec.initialized) then
2079       if (NOT fa_util_pub.get_log_level_rec (
2080                 x_log_level_rec =>  g_log_level_rec
2081       )) then
2082          raise ret_err;
2083       end if;
2084    end if;
2085 
2086    -- Initialize message list if p_init_msg_list is set to TRUE.
2087    if (fnd_api.to_boolean(p_init_msg_list)) then
2088         -- initialize error message stack.
2089         fa_srvr_msg.init_server_message;
2090 
2091         -- initialize debug message stack.
2092         fa_debug_pkg.initialize;
2093    end if;
2094 
2095    -- Check version of the API
2096    -- Standard call to check for API call compatibility.
2097    if (NOT fnd_api.compatible_api_call (
2098           G_API_VERSION,
2099           p_api_version,
2100           G_API_NAME,
2101           G_PKG_NAME
2102    )) then
2103       raise ret_err;
2104    end if;
2105 
2106    -- Bug 5475276 Populate the values of book_type_code
2107    -- and asset_id if they are not supplied.
2108    if (px_asset_hdr_rec.book_type_code is null or
2109        px_asset_hdr_rec.asset_id is null) then
2110 
2111       l_asset_retire_rec.retirement_id := px_asset_retire_rec_new.retirement_id;
2112       if not FA_UTIL_PVT.get_asset_retire_rec
2113              (px_asset_retire_rec => l_asset_retire_rec,
2114               p_mrc_sob_type_code => 'P',
2115               p_log_level_rec => g_log_level_rec) then
2116                  raise ret_err;
2117       end if;
2118 
2119       px_asset_hdr_rec.book_type_code := l_asset_retire_rec.detail_info.book_type_code;
2120       px_asset_hdr_rec.asset_id := l_asset_retire_rec.detail_info.asset_id;
2121 
2122    end if;
2123 
2124 
2125    -- Call the cache for the primary transaction book
2126    if (NOT fa_cache_pkg.fazcbc (
2127       X_book => px_asset_hdr_rec.book_type_code,
2128       p_log_level_rec => g_log_level_rec)) then
2129       raise ret_err;
2130    end if;
2131 
2132    px_asset_hdr_rec.set_of_books_id :=
2133       fa_cache_pkg.fazcbc_record.set_of_books_id;
2134 
2135    -- Set the gl_sob profile to this book
2136    fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2137    fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2138 
2139    if (NOT FA_UTIL_PVT.get_period_rec (
2140       p_book           => px_asset_hdr_rec.book_type_code,
2141       p_effective_date => NULL,
2142       x_period_rec     => l_period_rec,
2143       p_log_level_rec => g_log_level_rec)) then
2144       raise ret_err;
2145    end if;
2146 
2147    -- Call cache to verify whether this is a primary or reporting book
2148    if (NOT fa_cache_pkg.fazcsob (
2149       X_set_of_books_id   => px_asset_hdr_rec.set_of_books_id,
2150       X_mrc_sob_type_code => l_reporting_flag,
2151       p_log_level_rec => g_log_level_rec)) then
2152       raise ret_err;
2153    end if;
2154 
2155    -- Call the reporting books cache to get rep books.
2156    if (l_reporting_flag <> 'R') then
2157       if (NOT fa_cache_pkg.fazcrsob (
2158          x_book_type_code => px_asset_hdr_rec.book_type_code,
2159          x_sob_tbl        => l_rsob_tbl,
2160          p_log_level_rec => g_log_level_rec)) then
2161          raise ret_err;
2162       end if;
2163    end if;
2164 
2165    for mrc_index in 0..l_rsob_tbl.COUNT loop
2166 
2167       l_mrc_asset_hdr_rec := px_asset_hdr_rec;
2168 
2169       -- if the counter mrc_index  is at 0, then process incoming
2170       -- book else iterate through reporting books
2171       if (mrc_index  = 0) then
2172          l_mrc_asset_hdr_rec.set_of_books_id :=
2173             px_asset_hdr_rec.set_of_books_id;
2174       else
2175          l_mrc_asset_hdr_rec.set_of_books_id :=
2176             l_rsob_tbl(mrc_index);
2177          l_reporting_flag := 'R';
2178       end if;
2179 
2180       -- Set the gl_sob profile to this reporting book
2181       fnd_profile.put('GL_SET_OF_BKS_ID', l_mrc_asset_hdr_rec.set_of_books_id);
2182       fnd_client_info.set_currency_context
2183          (l_mrc_asset_hdr_rec.set_of_books_id);
2184 
2185       -- Need to always call fazcbcs
2186       if (NOT fa_cache_pkg.fazcbcs (
2187          X_book => l_mrc_asset_hdr_rec.book_type_code,
2188          p_log_level_rec => g_log_level_rec)) then
2189          raise ret_err;
2190       end if;
2191 /*
2192       -- call transaction approval for primary books only
2193       -- Will probably need to break this into an MRC wrapper thing
2194       if (l_reporting_flag <> 'R') then
2195          if (NOT fa_trx_approval_pkg.faxcat (
2196                X_book              => l_mrc_asset_hdr_rec.book_type_code,
2197                X_asset_id          => l_mrc_asset_hdr_rec.asset_id,
2198                X_trx_type          => px_trans_rec.transaction_type_code,
2199                X_trx_date          => px_trans_rec.transaction_date_entered,
2200                X_init_message_flag => 'NO',
2201                p_log_level_rec => g_log_level_rec)) then
2202             raise ret_err;
2203          end if;
2204       end if;
2205 */
2206       l_asset_retire_rec := px_asset_retire_rec_new;
2207 
2208       if (g_log_level_rec.statement_level) then
2209          fa_debug_pkg.add('Set Of Books Id',
2210                           'l_mrc_asset_hdr_rec.set_of_books_id',
2211                           to_char(l_mrc_asset_hdr_rec.set_of_books_id),g_log_level_rec);
2212          fa_debug_pkg.add('Reporting Flag','l_reporting_flag',
2213                           l_reporting_flag ,p_log_level_rec => g_log_level_rec);
2214          fa_debug_pkg.add('Retirement ID','l_asset_retire_rec.retirement_id',
2215                           to_char(l_asset_retire_rec.retirement_id),g_log_level_rec);
2216       end if;
2217 
2218       if (NOT FA_UTIL_PVT.get_asset_retire_rec (
2219          px_asset_retire_rec => l_asset_retire_rec,
2220          p_mrc_sob_type_code => l_reporting_flag,
2221          p_log_level_rec => g_log_level_rec)) then
2222          raise ret_err;
2223       end if;
2224 
2225       -- Date Retired
2226       if (px_asset_retire_rec_new.date_retired is NOT NULL) then
2227          if (l_asset_retire_rec.date_retired <>
2228              px_asset_retire_rec_new.date_retired) then
2229 
2230             l_asset_retire_rec.date_retired :=
2231                px_asset_retire_rec_new.date_retired;
2232          end if;
2233       end if;
2234 
2235       -- Status
2236       if (px_asset_retire_rec_new.status is NOT NULL) then
2237          if (l_asset_retire_rec.status <> px_asset_retire_rec_new.status) then
2238             if (px_asset_retire_rec_new.status = FND_API.G_MISS_CHAR) then
2239                --px_asset_retire_rec_new.status := NULL;
2240                null;
2241             end if;
2242 
2243             l_asset_retire_rec.status := px_asset_retire_rec_new.status;
2244          end if;
2245       end if;
2246 
2247       -- Retirement Type Code
2248       if (px_asset_retire_rec_new.retirement_type_code is NOT NULL) then
2249          if (nvl(l_asset_retire_rec.retirement_type_code, '-999') <>
2250              px_asset_retire_rec_new.retirement_type_code) then
2251             if (px_asset_retire_rec_new.retirement_type_code =
2252                 FND_API.G_MISS_CHAR) then
2253                 --px_asset_retire_rec_new.retirement_type_code := NULL;
2254                 null;
2255             end if;
2256 
2257             l_asset_retire_rec.retirement_type_code :=
2258                px_asset_retire_rec_new.retirement_type_code;
2259          end if;
2260       end if;
2261 
2262       -- Retirement Convention
2263       if (px_asset_retire_rec_new.retirement_prorate_convention is NOT NULL)
2264       then
2265          if (l_asset_retire_rec.retirement_prorate_convention <>
2266              px_asset_retire_rec_new.retirement_prorate_convention) then
2267             if (px_asset_retire_rec_new.retirement_prorate_convention =
2268                 FND_API.G_MISS_CHAR) then
2269                --px_asset_retire_rec_new.retirement_prorate_convention := NULL;
2270                null;
2271             end if;
2272 
2273             l_asset_retire_rec.retirement_prorate_convention :=
2274                px_asset_retire_rec_new.retirement_prorate_convention;
2275          end if;
2276       end if;
2277 
2278       -- Proceeds of Sale
2279       if (px_asset_retire_rec_new.proceeds_of_sale is NOT NULL) then
2280          if (nvl(l_asset_retire_rec.proceeds_of_sale, -999) <>
2281              px_asset_retire_rec_new.proceeds_of_sale) then
2282             if (px_asset_retire_rec_new.proceeds_of_sale = FND_API.G_MISS_NUM)
2283                then null; --px_asset_retire_rec_new.proceeds_of_sale := NULL;
2284             end if;
2285 
2286             -- Fix for Bug #2368292.  Need to account for reporting books
2287             if (l_reporting_flag <> 'R') then
2288 
2289                -- Save old primary proceeds for rate calculation
2290                l_old_primary_proceeds_of_sale :=
2291                   l_asset_retire_rec.proceeds_of_sale;
2292 
2293                -- Set new proceeds
2294                l_asset_retire_rec.proceeds_of_sale :=
2295                   px_asset_retire_rec_new.proceeds_of_sale;
2296             else
2297 
2298                -- Save old reporting proceeds for rate calculation
2299                l_old_rep_proceeds_of_sale :=
2300                   l_asset_retire_rec.proceeds_of_sale;
2301 
2302          /* BUG4128113
2303                -- Calculate exchange rate.
2304                if (nvl(l_old_primary_proceeds_of_sale, 0) <> 0) then
2305                   l_rate := l_old_rep_proceeds_of_sale /
2306                             l_old_primary_proceeds_of_sale;
2307 
2308                else
2309                   -- get average rate from the latest transaction record
2310                   select br1.avg_exchange_rate
2311                   into   l_rate
2312                   from   fa_mc_books_rates br1
2313                   where  br1.asset_id = l_mrc_asset_hdr_rec.asset_id
2314                   and    br1.book_type_code = l_mrc_asset_hdr_rec.book_type_code
2315                   and    br1.set_of_books_id =
2316                             l_mrc_asset_hdr_rec.set_of_books_id
2317                   and    br1.transaction_header_id =
2318                   (
2319                    select max(br2.transaction_header_id)
2320                    from   fa_mc_books_rates br2
2321                    where  br2.asset_id = l_mrc_asset_hdr_rec.asset_id
2322                    and    br2.book_type_code  =
2323                              l_mrc_asset_hdr_rec.book_type_code
2324                    and    br2.set_of_books_id =
2325                              l_mrc_asset_hdr_rec.set_of_books_id
2326                   );
2327                end if;
2328          */
2329 
2330                /* BUG#4128113 */
2331                if not FA_MC_UTIL_PVT.get_trx_rate
2332                      (p_prim_set_of_books_id      => px_asset_hdr_rec.set_of_books_id,
2333                       p_reporting_set_of_books_id => l_mrc_asset_hdr_rec.set_of_books_id,
2334                       px_exchange_date            => l_asset_retire_rec.date_retired,
2335                       p_book_type_code            => l_mrc_asset_hdr_rec.book_type_code,
2336                       px_rate                     => l_rate,
2337                       p_log_level_rec => g_log_level_rec) then raise ret_err;
2338 
2339                end if;
2340 
2341                -- Calculate the new proceeds of sale
2342                l_asset_retire_rec.proceeds_of_sale :=
2343                   px_asset_retire_rec_new.proceeds_of_sale * l_rate;
2344 
2345                -- Round the converted amount
2346                if (NOT fa_utils_pkg.faxrnd (
2347                   x_amount => l_asset_retire_rec.proceeds_of_sale,
2348                   x_book   => l_mrc_asset_hdr_rec.book_type_code,
2349                   p_log_level_rec => g_log_level_rec)) then
2350                   raise ret_err;
2351                end if;
2352             end if;
2353          end if;
2354       end if;
2355 
2356       -- Cost of Removal
2357       if (px_asset_retire_rec_new.cost_of_removal is NOT NULL) then
2358          if (nvl(l_asset_retire_rec.cost_of_removal, -999) <>
2359              px_asset_retire_rec_new.cost_of_removal) then
2360             if (px_asset_retire_rec_new.cost_of_removal = FND_API.G_MISS_NUM)
2361                then null; --px_asset_retire_rec_new.cost_of_removal := NULL;
2362             end if;
2363 
2364             -- Fix for Bug #2368292.  Need to account for reporting books
2365             if (l_reporting_flag <> 'R') then
2366 
2367                -- Save old primary cost of removal for rate calculation
2368                l_old_primary_cost_of_removal :=
2369                   l_asset_retire_rec.cost_of_removal;
2370 
2371                -- Set new cost of removal
2372                l_asset_retire_rec.cost_of_removal :=
2373                   px_asset_retire_rec_new.cost_of_removal;
2374             else
2375 
2376 
2377                -- Save old reporting cost of removal for rate calculation
2378                l_old_rep_cost_of_removal :=
2379                   l_asset_retire_rec.cost_of_removal;
2380 
2381                -- Calculate exchange rate.
2382                if (l_rate is not null) then
2383                   -- If we already have a rate from proceeds, use that
2384                   null;
2385 
2386                elsif (nvl(l_old_primary_cost_of_removal, 0) <> 0) then
2387                   l_rate := l_old_rep_cost_of_removal /
2388                             l_old_primary_cost_of_removal;
2389 
2390                else
2391 
2392 
2393                   -- get average rate from the latest transaction record
2394                   select br1.avg_exchange_rate
2395                   into   l_rate
2396                   from   fa_mc_books_rates br1
2397                   where  br1.asset_id = l_mrc_asset_hdr_rec.asset_id
2398                   and    br1.book_type_code = l_mrc_asset_hdr_rec.book_type_code
2399                   and    br1.set_of_books_id =
2400                             l_mrc_asset_hdr_rec.set_of_books_id
2401                   and    br1.transaction_header_id =
2402                   (
2403                    select max(br2.transaction_header_id)
2404                    from   fa_mc_books_rates br2
2405                    where  br2.asset_id = l_mrc_asset_hdr_rec.asset_id
2406                    and    br2.book_type_code  =
2407                              l_mrc_asset_hdr_rec.book_type_code
2408                    and    br2.set_of_books_id =
2409                              l_mrc_asset_hdr_rec.set_of_books_id
2410                   );
2411 
2412                end if;
2413 
2414                -- Calculate the new cost of removal
2415                l_asset_retire_rec.cost_of_removal :=
2416                   px_asset_retire_rec_new.cost_of_removal * l_rate;
2417 
2418                -- Round the converted amount
2419                if (NOT fa_utils_pkg.faxrnd (
2420                   x_amount => l_asset_retire_rec.cost_of_removal,
2421                   x_book   => l_mrc_asset_hdr_rec.book_type_code,
2422                   p_log_level_rec => g_log_level_rec)) then
2423                   raise ret_err;
2424                end if;
2425             end if;
2426          end if;
2427       end if;
2428 
2429       -- STL Method Code
2430       if (px_asset_retire_rec_new.detail_info.stl_method_code is NOT NULL) then
2431          if (nvl(l_asset_retire_rec.detail_info.stl_method_code, '-999') <>
2432              px_asset_retire_rec_new.detail_info.stl_method_code) then
2433             if (px_asset_retire_rec_new.detail_info.stl_method_code =
2434                 FND_API.G_MISS_CHAR) then
2435                null;
2436                --px_asset_retire_rec_new.detail_info.stl_method_code := NULL;
2437             end if;
2438 
2439             l_asset_retire_rec.detail_info.stl_method_code :=
2440                px_asset_retire_rec_new.detail_info.stl_method_code;
2441          end if;
2442       end if;
2443 
2444       -- STL Life in Months
2445       if (px_asset_retire_rec_new.detail_info.stl_life_in_months is NOT NULL)
2446       then
2447          if (nvl(l_asset_retire_rec.detail_info.stl_life_in_months, -999) <>
2448              px_asset_retire_rec_new.detail_info.stl_life_in_months) then
2449             if (px_asset_retire_rec_new.detail_info.stl_life_in_months =
2450                 FND_API.G_MISS_NUM) then
2451                --px_asset_retire_rec_new.detail_info.stl_life_in_months := NULL;
2452                null;
2453             end if;
2454 
2455             l_asset_retire_rec.detail_info.stl_life_in_months :=
2456                px_asset_retire_rec_new.detail_info.stl_life_in_months;
2457          end if;
2458       end if;
2459 
2460       -- Reference Num
2461       if (px_asset_retire_rec_new.reference_num is NOT NULL) then
2462          if (nvl(l_asset_retire_rec.reference_num, '-999') <>
2463              px_asset_retire_rec_new.reference_num) then
2464             if (px_asset_retire_rec_new.reference_num = FND_API.G_MISS_CHAR)
2465                then null; --px_asset_retire_rec_new.reference_num := NULL;
2466             end if;
2467 
2468             l_asset_retire_rec.reference_num :=
2469                px_asset_retire_rec_new.reference_num;
2470          end if;
2471       end if;
2472 
2473       -- Sold To
2474       if (px_asset_retire_rec_new.sold_to is NOT NULL) then
2475          if (nvl(l_asset_retire_rec.sold_to, '-999') <>
2476              px_asset_retire_rec_new.sold_to)
2477          then
2478             if (px_asset_retire_rec_new.sold_to = FND_API.G_MISS_CHAR) then
2479                null;
2480                --px_asset_retire_rec_new.sold_to := NULL;
2481             end if;
2482 
2483             l_asset_retire_rec.sold_to := px_asset_retire_rec_new.sold_to;
2484          end if;
2485       end if;
2486 
2487       -- Trade In Asset Id
2488       if (px_asset_retire_rec_new.trade_in_asset_id is NOT NULL) then
2489          if (nvl(l_asset_retire_rec.trade_in_asset_id, -999) <>
2490              px_asset_retire_rec_new.trade_in_asset_id) then
2491             if (px_asset_retire_rec_new.trade_in_asset_id = FND_API.G_MISS_NUM)
2492                then null; --px_asset_retire_rec_new.trade_in_asset_id := NULL;
2493             end if;
2494 
2495             l_asset_retire_rec.trade_in_asset_id :=
2496                px_asset_retire_rec_new.trade_in_asset_id;
2497          end if;
2498       end if;
2499 
2500       -- Flex Columns
2501       if (px_asset_retire_rec_new.desc_flex.attribute1 is NOT NULL) then
2502          if (nvl(l_asset_retire_rec.desc_flex.attribute1, '-999') <>
2503              px_asset_retire_rec_new.desc_flex.attribute1) then
2504 
2505             l_asset_retire_rec.desc_flex.attribute1 :=
2506                px_asset_retire_rec_new.desc_flex.attribute1;
2507          end if;
2508       end if;
2509 
2510       if (px_asset_retire_rec_new.desc_flex.attribute2 is NOT NULL) then
2511          if (nvl(l_asset_retire_rec.desc_flex.attribute2, '-999') <>
2512              px_asset_retire_rec_new.desc_flex.attribute2) then
2513 
2514             l_asset_retire_rec.desc_flex.attribute2 :=
2515                px_asset_retire_rec_new.desc_flex.attribute2;
2516          end if;
2517       end if;
2518 
2519       if (px_asset_retire_rec_new.desc_flex.attribute3 is NOT NULL) then
2520          if (nvl(l_asset_retire_rec.desc_flex.attribute3, '-999') <>
2521              px_asset_retire_rec_new.desc_flex.attribute3) then
2522 
2523             l_asset_retire_rec.desc_flex.attribute3 :=
2524                px_asset_retire_rec_new.desc_flex.attribute3;
2525          end if;
2526       end if;
2527 
2528       if (px_asset_retire_rec_new.desc_flex.attribute4 is NOT NULL) then
2529          if (nvl(l_asset_retire_rec.desc_flex.attribute4, '-999') <>
2530              px_asset_retire_rec_new.desc_flex.attribute4) then
2531 
2532             l_asset_retire_rec.desc_flex.attribute4 :=
2533                px_asset_retire_rec_new.desc_flex.attribute4;
2534          end if;
2535       end if;
2536 
2537       if (px_asset_retire_rec_new.desc_flex.attribute5 is NOT NULL) then
2538          if (nvl(l_asset_retire_rec.desc_flex.attribute5, '-999') <>
2539              px_asset_retire_rec_new.desc_flex.attribute5) then
2540 
2541             l_asset_retire_rec.desc_flex.attribute5 :=
2542                px_asset_retire_rec_new.desc_flex.attribute5;
2543          end if;
2544       end if;
2545 
2546       if (px_asset_retire_rec_new.desc_flex.attribute6 is NOT NULL) then
2547          if (nvl(l_asset_retire_rec.desc_flex.attribute6, '-999') <>
2548              px_asset_retire_rec_new.desc_flex.attribute6) then
2549 
2550             l_asset_retire_rec.desc_flex.attribute6 :=
2551                px_asset_retire_rec_new.desc_flex.attribute6;
2552          end if;
2553       end if;
2554 
2555       if (px_asset_retire_rec_new.desc_flex.attribute7 is NOT NULL) then
2556          if (nvl(l_asset_retire_rec.desc_flex.attribute7, '-999') <>
2557              px_asset_retire_rec_new.desc_flex.attribute7) then
2558 
2559             l_asset_retire_rec.desc_flex.attribute7 :=
2560                px_asset_retire_rec_new.desc_flex.attribute7;
2561          end if;
2562       end if;
2563 
2564       if (px_asset_retire_rec_new.desc_flex.attribute8 is NOT NULL) then
2565          if (nvl(l_asset_retire_rec.desc_flex.attribute8, '-999') <>
2566              px_asset_retire_rec_new.desc_flex.attribute8) then
2567 
2568             l_asset_retire_rec.desc_flex.attribute8 :=
2569                px_asset_retire_rec_new.desc_flex.attribute8;
2570          end if;
2571       end if;
2572 
2573       if (px_asset_retire_rec_new.desc_flex.attribute9 is NOT NULL) then
2574          if (nvl(l_asset_retire_rec.desc_flex.attribute9, '-999') <>
2575              px_asset_retire_rec_new.desc_flex.attribute9) then
2576 
2577             l_asset_retire_rec.desc_flex.attribute9 :=
2578                px_asset_retire_rec_new.desc_flex.attribute9;
2579          end if;
2580       end if;
2581 
2582       if (px_asset_retire_rec_new.desc_flex.attribute10 is NOT NULL) then
2583          if (nvl(l_asset_retire_rec.desc_flex.attribute10, '-999') <>
2584              px_asset_retire_rec_new.desc_flex.attribute10) then
2585 
2586             l_asset_retire_rec.desc_flex.attribute10 :=
2587                px_asset_retire_rec_new.desc_flex.attribute10;
2588          end if;
2589       end if;
2590 
2591       if (px_asset_retire_rec_new.desc_flex.attribute11 is NOT NULL) then
2592          if (nvl(l_asset_retire_rec.desc_flex.attribute11, '-999') <>
2593              px_asset_retire_rec_new.desc_flex.attribute11) then
2594 
2595             l_asset_retire_rec.desc_flex.attribute11 :=
2596                px_asset_retire_rec_new.desc_flex.attribute11;
2597          end if;
2598       end if;
2599 
2600       if (px_asset_retire_rec_new.desc_flex.attribute12 is NOT NULL) then
2601          if (nvl(l_asset_retire_rec.desc_flex.attribute12, '-999') <>
2602              px_asset_retire_rec_new.desc_flex.attribute12) then
2603 
2604             l_asset_retire_rec.desc_flex.attribute12 :=
2605                px_asset_retire_rec_new.desc_flex.attribute12;
2606          end if;
2607       end if;
2608 
2609       if (px_asset_retire_rec_new.desc_flex.attribute13 is NOT NULL) then
2610          if (nvl(l_asset_retire_rec.desc_flex.attribute13, '-999') <>
2611              px_asset_retire_rec_new.desc_flex.attribute13) then
2612 
2613             l_asset_retire_rec.desc_flex.attribute13 :=
2614                px_asset_retire_rec_new.desc_flex.attribute13;
2615          end if;
2616       end if;
2617 
2618       if (px_asset_retire_rec_new.desc_flex.attribute14 is NOT NULL) then
2619          if (nvl(l_asset_retire_rec.desc_flex.attribute14, '-999') <>
2620              px_asset_retire_rec_new.desc_flex.attribute14) then
2621 
2622             l_asset_retire_rec.desc_flex.attribute14 :=
2623                px_asset_retire_rec_new.desc_flex.attribute14;
2624          end if;
2625       end if;
2626 
2627       if (px_asset_retire_rec_new.desc_flex.attribute15 is NOT NULL) then
2628          if (nvl(l_asset_retire_rec.desc_flex.attribute15, '-999') <>
2629              px_asset_retire_rec_new.desc_flex.attribute15) then
2630 
2631             l_asset_retire_rec.desc_flex.attribute15 :=
2632                px_asset_retire_rec_new.desc_flex.attribute15;
2633          end if;
2634       end if;
2635 
2636       if (px_asset_retire_rec_new.desc_flex.attribute_category_code is NOT NULL)
2637       then
2638          if (nvl(l_asset_retire_rec.desc_flex.attribute_category_code, '999') <>
2639              px_asset_retire_rec_new.desc_flex.attribute_category_code) then
2640 
2641             l_asset_retire_rec.desc_flex.attribute_category_code :=
2642                px_asset_retire_rec_new.desc_flex.attribute_category_code;
2643          end if;
2644       end if;
2645 
2646       l_rowid := NULL;
2647 
2648 
2649       FA_RETIREMENTS_PKG.Update_Row(
2650            X_Rowid                => l_rowid,
2651            X_Retirement_Id        => l_asset_retire_rec.retirement_id,
2652            X_Book_Type_Code       =>
2653               l_asset_retire_rec.detail_info.book_type_code,
2654            X_Asset_Id             => l_asset_retire_rec.detail_info.asset_id,
2655            X_Date_Retired         => l_asset_retire_rec.date_retired,
2656            X_Cost_Retired         => l_asset_retire_rec.cost_retired,
2657            X_Status               => l_asset_retire_rec.status,
2658            X_Last_Update_Date     => px_trans_rec.who_info.last_update_date,
2659            X_Last_Updated_By      => px_trans_rec.who_info.last_updated_by,
2660            X_Ret_Prorate_Convention
2661                                   =>
2662               l_asset_retire_rec.retirement_prorate_convention,
2663            X_Units                => l_asset_retire_rec.units_retired,
2664            X_Cost_Of_Removal      => l_asset_retire_rec.cost_of_removal,
2665            X_Nbv_Retired          => l_asset_retire_rec.detail_info.nbv_retired,
2666            X_Gain_Loss_Amount     =>
2667               l_asset_retire_rec.detail_info.gain_loss_amount,
2668            X_Proceeds_Of_Sale     => l_asset_retire_rec.proceeds_of_sale,
2669            X_Gain_Loss_Type_Code  =>
2670               l_asset_retire_rec.detail_info.gain_loss_type_code,
2671            X_Retirement_Type_Code => l_asset_retire_rec.retirement_type_code,
2672            X_Itc_Recaptured       =>
2673               l_asset_retire_rec.detail_info.itc_recaptured,
2674            X_Itc_Recapture_Id     =>
2675               l_asset_retire_rec.detail_info.itc_recapture_id,
2676            X_Reference_Num        => l_asset_retire_rec.reference_num,
2677            X_Sold_To              => l_asset_retire_rec.sold_to,
2678            X_Trade_In_Asset_Id    => l_asset_retire_rec.trade_in_asset_id,
2679            X_Stl_Method_Code      =>
2680               l_asset_retire_rec.detail_info.stl_method_code,
2681            X_Stl_Life_In_Months   =>
2682               l_asset_retire_rec.detail_info.stl_life_in_months,
2683            X_Last_Update_Login    => px_trans_rec.who_info.last_update_login,
2684            X_Attribute1           => l_asset_retire_rec.desc_flex.attribute1,
2685            X_Attribute2           => l_asset_retire_rec.desc_flex.attribute2,
2686            X_Attribute3           => l_asset_retire_rec.desc_flex.attribute3,
2687            X_Attribute4           => l_asset_retire_rec.desc_flex.attribute4,
2688            X_Attribute5           => l_asset_retire_rec.desc_flex.attribute5,
2689            X_Attribute6           => l_asset_retire_rec.desc_flex.attribute6,
2690            X_Attribute7           => l_asset_retire_rec.desc_flex.attribute7,
2691            X_Attribute8           => l_asset_retire_rec.desc_flex.attribute8,
2692            X_Attribute9           => l_asset_retire_rec.desc_flex.attribute9,
2693            X_Attribute10          => l_asset_retire_rec.desc_flex.attribute10,
2694            X_Attribute11          => l_asset_retire_rec.desc_flex.attribute11,
2695            X_Attribute12          => l_asset_retire_rec.desc_flex.attribute12,
2696            X_Attribute13          => l_asset_retire_rec.desc_flex.attribute13,
2697            X_Attribute14          => l_asset_retire_rec.desc_flex.attribute14,
2698            X_Attribute15          => l_asset_retire_rec.desc_flex.attribute15,
2699            X_Attribute_Category_Code
2700                                   =>
2701               l_asset_retire_rec.desc_flex.attribute_category_code,
2702            X_mrc_sob_type_code    => l_reporting_flag,
2703            X_Calling_Fn           => p_calling_fn
2704            ,p_log_level_rec => g_log_level_rec);
2705 
2706    end loop;
2707 
2708    -- commit if p_commit is TRUE.
2709    if (fnd_api.to_boolean (p_commit)) then
2710         COMMIT WORK;
2711    end if;
2712 
2713    -- Reset the gl_sob profile to this book
2714    fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2715    fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2716 
2717    -- Standard call to get message count and if count is 1 get message info.
2718    fnd_msg_pub.count_and_get (
2719       p_count   => x_msg_count,
2720       p_data    => x_msg_data
2721    );
2722 
2723    x_return_status := FND_API.G_RET_STS_SUCCESS;
2724 
2725 EXCEPTION
2726 
2727    WHEN ret_err THEN
2728 
2729       ROLLBACK TO do_retirement_desc_update;
2730 
2731       -- set back to original environment when the procedure is finished
2732       fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2733       fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2734 
2735       fa_srvr_msg.add_message
2736            (calling_fn => l_calling_fn,
2737             p_log_level_rec => g_log_level_rec);
2738 
2739       FND_MSG_PUB.count_and_get (
2740          p_count => x_msg_count,
2741          p_data  => x_msg_data
2742       );
2743 
2744       x_return_status := FND_API.G_RET_STS_ERROR;
2745 
2746    WHEN OTHERS THEN
2747 
2748       ROLLBACK TO do_retirement_desc_update;
2749 
2750       -- set back to original environment when the procedure is finished
2751       fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
2752       fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
2753 
2754       fa_srvr_msg.add_sql_error
2755            (calling_fn => l_calling_fn
2756                       ,p_log_level_rec => g_log_level_rec);
2757 
2758       FND_MSG_PUB.count_and_get (
2759          p_count => x_msg_count,
2760          p_data  => x_msg_data
2761       );
2762 
2763       x_return_status := FND_API.G_RET_STS_ERROR;
2764 
2765 END update_retirement_desc;
2766 
2767 
2768 --
2769 FUNCTION initialize_category_df (
2770          px_asset_cat_rec        IN OUT NOCOPY   FA_API_TYPES.asset_cat_rec_type,
2771          p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
2772 
2773 l_return_status                BOOLEAN;
2774 l_category_chart_id            number;
2775 l_num_segs                     number;
2776 l_delimiter                    varchar2(1);
2777 l_segment_array                FND_FLEX_EXT.SEGMENTARRAY;
2778 l_concat_string                varchar2(210);
2779 
2780 BEGIN
2781 
2782    -- Get defaults from the category.
2783 /*
2784       if not fa_cache_pkg.fazcat(
2785          X_cat_id => px_asset_cat_rec.category_id
2786          ,p_log_level_rec => p_log_level_rec) then
2787          fa_srvr_msg.add_message(
2788              calling_fn => 'fa_asset_desc_pub.initialize_category_df',
2789              p_log_level_rec => p_log_level_rec);
2790              return FALSE;
2791       end if;
2792 */
2793      if not fa_cache_pkg.fazsys then
2794         fa_srvr_msg.add_message(
2795              calling_fn => 'fa_asset_desc_pub.initialize_category_df',
2796              p_log_level_rec => p_log_level_rec);
2797              return FALSE;
2798      end if;
2799 
2800      l_category_chart_id :=
2801                fa_cache_pkg.fazsys_record.category_flex_structure;
2802 
2803      if not fa_flex_pvt.get_concat_segs (
2804             p_ccid                   => px_asset_cat_rec.category_id,
2805             p_application_short_name => 'OFA',
2806             p_flex_code              => 'CAT#',
2807             p_flex_num               => l_category_chart_id,
2808             p_num_segs               => l_num_segs,
2809             p_delimiter              => l_delimiter,
2810             p_segment_array          => l_segment_array,
2811             p_concat_string          => l_concat_string
2812             ,p_log_level_rec => p_log_level_rec) then
2813         fa_srvr_msg.add_message(
2814              calling_fn => 'fa_asset_desc_pub.initialize_category_df',
2815              p_log_level_rec => p_log_level_rec);
2816              return FALSE;
2817      end if;
2818 
2819      px_asset_cat_rec.desc_flex.attribute_category_code := l_concat_string;
2820 
2821      -- commenting this for bug 2700227
2822      --px_asset_cat_rec.desc_flex.context                 := l_concat_string;
2823 /*
2824      if (px_asset_cat_rec.desc_flex.attribute1 = FND_API.G_MISS_CHAR) then
2825         px_asset_cat_rec.desc_flex.attribute1 := null;
2826      end if;
2827      if (px_asset_cat_rec.desc_flex.attribute2 = FND_API.G_MISS_CHAR) then
2828         px_asset_cat_rec.desc_flex.attribute2 := null;
2829      end if;
2830      if (px_asset_cat_rec.desc_flex.attribute3 = FND_API.G_MISS_CHAR) then
2831         px_asset_cat_rec.desc_flex.attribute3 := null;
2832      end if;
2833      if (px_asset_cat_rec.desc_flex.attribute4 = FND_API.G_MISS_CHAR) then
2834         px_asset_cat_rec.desc_flex.attribute4 := null;
2835      end if;
2836      if (px_asset_cat_rec.desc_flex.attribute5 = FND_API.G_MISS_CHAR) then
2837         px_asset_cat_rec.desc_flex.attribute5 := null;
2838      end if;
2839      if (px_asset_cat_rec.desc_flex.attribute6 = FND_API.G_MISS_CHAR) then
2840         px_asset_cat_rec.desc_flex.attribute6 := null;
2841      end if;
2842      if (px_asset_cat_rec.desc_flex.attribute7 = FND_API.G_MISS_CHAR) then
2843         px_asset_cat_rec.desc_flex.attribute7 := null;
2844      end if;
2845      if (px_asset_cat_rec.desc_flex.attribute8 = FND_API.G_MISS_CHAR) then
2846         px_asset_cat_rec.desc_flex.attribute8 := null;
2847      end if;
2848      if (px_asset_cat_rec.desc_flex.attribute9 = FND_API.G_MISS_CHAR) then
2849         px_asset_cat_rec.desc_flex.attribute9 := null;
2850      end if;
2851      if (px_asset_cat_rec.desc_flex.attribute10 = FND_API.G_MISS_CHAR) then
2852         px_asset_cat_rec.desc_flex.attribute10 := null;
2853      end if;
2854      if (px_asset_cat_rec.desc_flex.attribute11 = FND_API.G_MISS_CHAR) then
2855         px_asset_cat_rec.desc_flex.attribute11 := null;
2856      end if;
2857      if (px_asset_cat_rec.desc_flex.attribute12 = FND_API.G_MISS_CHAR) then
2858         px_asset_cat_rec.desc_flex.attribute12 := null;
2859      end if;
2860      if (px_asset_cat_rec.desc_flex.attribute13 = FND_API.G_MISS_CHAR) then
2861         px_asset_cat_rec.desc_flex.attribute13 := null;
2862      end if;
2863      if (px_asset_cat_rec.desc_flex.attribute14 = FND_API.G_MISS_CHAR) then
2864         px_asset_cat_rec.desc_flex.attribute14 := null;
2865      end if;
2866      if (px_asset_cat_rec.desc_flex.attribute15 = FND_API.G_MISS_CHAR) then
2867         px_asset_cat_rec.desc_flex.attribute15 := null;
2868      end if;
2869      if (px_asset_cat_rec.desc_flex.attribute16 = FND_API.G_MISS_CHAR) then
2870         px_asset_cat_rec.desc_flex.attribute16 := null;
2871      end if;
2872      if (px_asset_cat_rec.desc_flex.attribute17 = FND_API.G_MISS_CHAR) then
2873         px_asset_cat_rec.desc_flex.attribute17 := null;
2874      end if;
2875      if (px_asset_cat_rec.desc_flex.attribute18 = FND_API.G_MISS_CHAR) then
2876         px_asset_cat_rec.desc_flex.attribute18 := null;
2877      end if;
2878      if (px_asset_cat_rec.desc_flex.attribute19 = FND_API.G_MISS_CHAR) then
2879         px_asset_cat_rec.desc_flex.attribute19 := null;
2880      end if;
2881      if (px_asset_cat_rec.desc_flex.attribute20 = FND_API.G_MISS_CHAR) then
2882         px_asset_cat_rec.desc_flex.attribute20 := null;
2883      end if;
2884      if (px_asset_cat_rec.desc_flex.attribute21 = FND_API.G_MISS_CHAR) then
2885         px_asset_cat_rec.desc_flex.attribute21 := null;
2886      end if;
2887      if (px_asset_cat_rec.desc_flex.attribute22 = FND_API.G_MISS_CHAR) then
2888         px_asset_cat_rec.desc_flex.attribute22 := null;
2889      end if;
2890      if (px_asset_cat_rec.desc_flex.attribute23 = FND_API.G_MISS_CHAR) then
2891         px_asset_cat_rec.desc_flex.attribute23 := null;
2892      end if;
2893      if (px_asset_cat_rec.desc_flex.attribute24 = FND_API.G_MISS_CHAR) then
2894         px_asset_cat_rec.desc_flex.attribute24 := null;
2895      end if;
2896      if (px_asset_cat_rec.desc_flex.attribute25 = FND_API.G_MISS_CHAR) then
2897         px_asset_cat_rec.desc_flex.attribute25 := null;
2898      end if;
2899      if (px_asset_cat_rec.desc_flex.attribute26 = FND_API.G_MISS_CHAR) then
2900         px_asset_cat_rec.desc_flex.attribute26 := null;
2901      end if;
2902      if (px_asset_cat_rec.desc_flex.attribute27 = FND_API.G_MISS_CHAR) then
2903         px_asset_cat_rec.desc_flex.attribute27 := null;
2904      end if;
2905      if (px_asset_cat_rec.desc_flex.attribute28 = FND_API.G_MISS_CHAR) then
2906         px_asset_cat_rec.desc_flex.attribute28 := null;
2907      end if;
2908      if (px_asset_cat_rec.desc_flex.attribute29 = FND_API.G_MISS_CHAR) then
2909         px_asset_cat_rec.desc_flex.attribute29 := null;
2910      end if;
2911      if (px_asset_cat_rec.desc_flex.attribute30 = FND_API.G_MISS_CHAR) then
2912         px_asset_cat_rec.desc_flex.attribute30 := null;
2913      end if;
2914 */
2915      return (TRUE);
2916 EXCEPTION
2917 
2918    WHEN OTHERS THEN
2919         fa_srvr_msg.add_sql_error(calling_fn => 'fa_asset_desc_pub.initialize_category_df'
2920                 ,p_log_level_rec => p_log_level_rec);
2921         return FALSE;
2922 
2923 END;
2924 
2925 END FA_ASSET_DESC_PUB;