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