DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_METHODS_PKG

Source


1 PACKAGE BODY FA_METHODS_PKG as
2 /* $Header: faximtb.pls 120.8.12010000.1 2008/07/28 13:25:54 appldev ship $ */
3 
4   PROCEDURE Insert_Row(X_Rowid                   IN OUT NOCOPY VARCHAR2,
5                        X_Method_Id                      IN OUT NOCOPY NUMBER,
6                        X_Method_Code                    VARCHAR2,
7                        X_Life_In_Months                 NUMBER DEFAULT NULL,
8                        X_Depreciate_Lastyear_Flag       VARCHAR2,
9                        X_Stl_Method_Flag                VARCHAR2,
10                        X_Rate_Source_Rule               VARCHAR2,
11                        X_Deprn_Basis_Rule               VARCHAR2,
12                        X_Prorate_Periods_Per_Year       NUMBER DEFAULT NULL,
13                        X_Name                           VARCHAR2 DEFAULT NULL,
14                        X_Last_Update_Date               DATE,
15                        X_Last_Updated_By                NUMBER,
16                        X_Created_By                     NUMBER DEFAULT NULL,
17                        X_Creation_Date                  DATE DEFAULT NULL,
18                        X_Last_Update_Login              NUMBER DEFAULT NULL,
19                        X_Attribute1                     VARCHAR2 DEFAULT NULL,
20                        X_Attribute2                     VARCHAR2 DEFAULT NULL,
21                        X_Attribute3                     VARCHAR2 DEFAULT NULL,
22                        X_Attribute4                     VARCHAR2 DEFAULT NULL,
23                        X_Attribute5                     VARCHAR2 DEFAULT NULL,
24                        X_Attribute6                     VARCHAR2 DEFAULT NULL,
25                        X_Attribute7                     VARCHAR2 DEFAULT NULL,
26                        X_Attribute8                     VARCHAR2 DEFAULT NULL,
27                        X_Attribute9                     VARCHAR2 DEFAULT NULL,
28                        X_Attribute10                    VARCHAR2 DEFAULT NULL,
29                        X_Attribute11                    VARCHAR2 DEFAULT NULL,
30                        X_Attribute12                    VARCHAR2 DEFAULT NULL,
31                        X_Attribute13                    VARCHAR2 DEFAULT NULL,
32                        X_Attribute14                    VARCHAR2 DEFAULT NULL,
33                        X_Attribute15                    VARCHAR2 DEFAULT NULL,
34                        X_Attribute_Category_Code        VARCHAR2 DEFAULT NULL,
35                        X_Exclude_Salvage_Value_Flag     VARCHAR2 DEFAULT 'NO',
36  -- alternative flat depreciation calculation.   added for 11.5.2
37                        X_Deprn_Basis_Formula            VARCHAR2 DEFAULT NULL,
38                        X_Polish_Adj_Calc_Basis_Flag     VARCHAR2 DEFAULT NULL,
39                        X_Guarantee_Rate_Method_Flag     VARCHAR2 DEFAULT NULL,
40                        X_Calling_Fn                     VARCHAR2,
41  -- For Depreciable Basis Formula
42                        X_Deprn_Basis_Rule_Id            NUMBER DEFAULT NULL,
43                         p_log_level_rec             IN     FA_API_TYPES.log_level_rec_type default null) IS
44     CURSOR C IS SELECT rowid FROM fa_methods
45                  WHERE method_id = X_Method_Id;
46       CURSOR C2 IS SELECT fa_methods_s.nextval FROM dual;
47 
48    BEGIN
49 
50       if (X_Method_Id is NULL) then
51         OPEN C2;
52         FETCH C2 INTO X_Method_Id;
53         CLOSE C2;
54       end if;
55 
56        INSERT INTO fa_methods(
57               method_id,
58               method_code,
59               life_in_months,
60               depreciate_lastyear_flag,
61               stl_method_flag,
62               rate_source_rule,
63               deprn_basis_rule,
64               prorate_periods_per_year,
65               name,
66               last_update_date,
67               last_updated_by,
68               created_by,
69               creation_date,
70               last_update_login,
71               attribute1,
72               attribute2,
73               attribute3,
74               attribute4,
75               attribute5,
76               attribute6,
77               attribute7,
78               attribute8,
79               attribute9,
80               attribute10,
81               attribute11,
82               attribute12,
83               attribute13,
84               attribute14,
85               attribute15,
86               attribute_category_code,
87               exclude_salvage_value_flag,
88               deprn_basis_formula,
89               deprn_basis_rule_id,
90               polish_adj_calc_basis_flag,
91               guarantee_rate_method_flag
92              ) VALUES (
93               X_Method_Id,
94               X_Method_Code,
95               X_Life_In_Months,
96               X_Depreciate_Lastyear_Flag,
97               X_Stl_Method_Flag,
98               X_Rate_Source_Rule,
99               X_Deprn_Basis_Rule,
100               X_Prorate_Periods_Per_Year,
101               X_Name,
102               X_Last_Update_Date,
103               X_Last_Updated_By,
104               X_Created_By,
105               X_Creation_Date,
106               X_Last_Update_Login,
107               X_Attribute1,
108               X_Attribute2,
109               X_Attribute3,
110               X_Attribute4,
111               X_Attribute5,
112               X_Attribute6,
113               X_Attribute7,
114               X_Attribute8,
115               X_Attribute9,
116               X_Attribute10,
117               X_Attribute11,
118               X_Attribute12,
119               X_Attribute13,
120               X_Attribute14,
121               X_Attribute15,
122               X_Attribute_Category_Code,
123               X_Exclude_Salvage_Value_Flag,
124               X_Deprn_Basis_Formula,
125               X_Deprn_Basis_Rule_Id,
126               X_Polish_Adj_Calc_Basis_Flag,
127               X_Guarantee_Rate_Method_Flag
128              );
129 
130     OPEN C;
131     FETCH C INTO X_Rowid;
132     if (C%NOTFOUND) then
133       CLOSE C;
134       Raise NO_DATA_FOUND;
135     end if;
136     CLOSE C;
137 
138     -- Fix for Bug #3810332.  Need to be more specific when updating the
139     -- basis rules to prevent deadlock.
140     if ((X_Rate_Source_Rule = 'FLAT') and
141         (X_Deprn_Basis_Rule = 'NBV') and
142         (nvl(X_Deprn_Basis_Formula, 'STRICT_FLAT') = 'STRICT_FLAT') and
143         (X_Deprn_Basis_Rule_Id is null)) then
144 
145        -- For Depreciable Basis Formula logic
146        UPDATE fa_methods
147        SET deprn_basis_rule_id =
148           (SELECT deprn_basis_rule_id
149            FROM   fa_deprn_basis_rules
150            WHERE  RULE_NAME='TRANSACTION')
151        WHERE rate_source_rule='FLAT'
152        AND deprn_basis_rule='NBV'
153        AND deprn_basis_formula IS NULL
154        AND deprn_basis_rule_id IS NULL
155        AND method_id = X_Method_Id;
156 
157        UPDATE fa_methods
158        SET deprn_basis_rule_id =
159           (SELECT deprn_basis_rule_id
160            FROM   fa_deprn_basis_rules
161            WHERE  RULE_NAME='FYBEGIN')
162        WHERE rate_source_rule='FLAT'
163        AND deprn_basis_rule='NBV'
164        AND deprn_basis_formula ='STRICT_FLAT'
165        AND deprn_basis_rule_id IS NULL
166        AND method_id = X_Method_Id;
167 
168     end if;
169 
170   exception
171     when others then
172 
173       fa_srvr_msg.add_sql_error(
174                 calling_fn => 'fa_methods_pkg.insert_row'
175                 ,p_log_level_rec => p_log_level_rec);
176 
177       FA_STANDARD_PKG.RAISE_ERROR(
178                 CALLED_FN => 'fa_methods_pkg.insert_row',
179                 CALLING_FN => X_Calling_Fn
180                 ,p_log_level_rec => p_log_level_rec);
181 
182   END Insert_Row;
183 
184 
185   PROCEDURE Lock_Row(X_Rowid                            VARCHAR2,
186                      X_Method_Id                        NUMBER,
187                      X_Method_Code                      VARCHAR2,
188                      X_Life_In_Months                   NUMBER DEFAULT NULL,
189                      X_Depreciate_Lastyear_Flag         VARCHAR2,
190                      X_Stl_Method_Flag                  VARCHAR2,
191                      X_Rate_Source_Rule                 VARCHAR2,
192                      X_Deprn_Basis_Rule                 VARCHAR2,
193                      X_Prorate_Periods_Per_Year         NUMBER DEFAULT NULL,
194                      X_Name                             VARCHAR2 DEFAULT NULL,
195                      X_Attribute1                       VARCHAR2 DEFAULT NULL,
196                      X_Attribute2                       VARCHAR2 DEFAULT NULL,
197                      X_Attribute3                       VARCHAR2 DEFAULT NULL,
198                      X_Attribute4                       VARCHAR2 DEFAULT NULL,
199                      X_Attribute5                       VARCHAR2 DEFAULT NULL,
200                      X_Attribute6                       VARCHAR2 DEFAULT NULL,
201                      X_Attribute7                       VARCHAR2 DEFAULT NULL,
202                      X_Attribute8                       VARCHAR2 DEFAULT NULL,
203                      X_Attribute9                       VARCHAR2 DEFAULT NULL,
204                      X_Attribute10                      VARCHAR2 DEFAULT NULL,
205                      X_Attribute11                      VARCHAR2 DEFAULT NULL,
206                      X_Attribute12                      VARCHAR2 DEFAULT NULL,
207                      X_Attribute13                      VARCHAR2 DEFAULT NULL,
208                      X_Attribute14                      VARCHAR2 DEFAULT NULL,
209                      X_Attribute15                      VARCHAR2 DEFAULT NULL,
210                      X_Attribute_Category_Code          VARCHAR2 DEFAULT NULL,
211                      X_Exclude_Salvage_Value_Flag       VARCHAR2 DEFAULT 'NO',
212   -- added for alternative flat depreciation calcuation.   for 11.5.2
213                      X_Deprn_Basis_Formula              VARCHAR2 DEFAULT NULL,
214                      X_Polish_Adj_Calc_Basis_Flag       VARCHAR2 DEFAULT NULL,
215                      X_Guarantee_Rate_Method_Flag       VARCHAR2 DEFAULT NULL,
216                      X_Calling_Fn                       VARCHAR2,
217   -- added for Depreciable Basis Formula
218                      X_Deprn_Basis_Rule_Id              NUMBER DEFAULT NULL,
219                      p_log_level_rec             IN     FA_API_TYPES.log_level_rec_type default null) IS
220     CURSOR C IS
221         SELECT  method_id,
222                 method_code,
223                 life_in_months,
224                 depreciate_lastyear_flag,
225                 stl_method_flag,
226                 rate_source_rule,
227                 deprn_basis_rule,
228                 prorate_periods_per_year,
229                 name,
230                 last_update_date,
231                 last_updated_by,
232                 created_by,
233                 creation_date,
234                 last_update_login,
235                 attribute1,
236                 attribute2,
237                 attribute3,
238                 attribute4,
239                 attribute5,
240                 attribute6,
241                 attribute7,
242                 attribute8,
243                 attribute9,
244                 attribute10,
245                 attribute11,
246                 attribute12,
247                 attribute13,
248                 attribute14,
249                 attribute15,
250                 attribute_category_code,
251                 deprn_basis_formula,
252                 exclude_salvage_value_flag,
253                 deprn_basis_rule_id,
254                 polish_adj_calc_basis_flag,
255                 guarantee_rate_method_flag
256         FROM   fa_methods
257         WHERE  method_code = X_Method_Code
258         AND    ((life_in_months = X_Life_In_Months) or
259                 ((life_in_months is null) and (X_Life_In_Months is null)))
260         FOR UPDATE of Method_Id NOWAIT;
261     Recinfo C%ROWTYPE;
262 
263   BEGIN
264 
265     OPEN C;
266     FETCH C INTO Recinfo;
267     if (C%NOTFOUND) then
268       CLOSE C;
269       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
270       APP_EXCEPTION.Raise_Exception;
271     end if;
272     CLOSE C;
273     if (
274                (Recinfo.method_id =  X_Method_Id)
275            AND (Recinfo.method_code =  X_Method_Code)
276            AND (   (Recinfo.life_in_months =  X_Life_In_Months)
277                 OR (    (Recinfo.life_in_months IS NULL)
278                     AND (X_Life_In_Months IS NULL)))
279            AND (Recinfo.depreciate_lastyear_flag =  X_Depreciate_Lastyear_Flag)
280            AND (Recinfo.stl_method_flag =  X_Stl_Method_Flag)
281            AND (Recinfo.rate_source_rule =  X_Rate_Source_Rule)
282            AND (Recinfo.deprn_basis_rule =  X_Deprn_Basis_Rule)
283            AND (   (Recinfo.prorate_periods_per_year =
284                X_Prorate_Periods_Per_Year)
285                 OR (    (Recinfo.prorate_periods_per_year IS NULL)
286                     AND (X_Prorate_Periods_Per_Year IS NULL)))
287            AND (   (Recinfo.name =  X_Name)
288                 OR (    (Recinfo.name IS NULL)
289                     AND (X_Name IS NULL)))
290            AND (   (Recinfo.attribute1 =  X_Attribute1)
291                 OR (    (Recinfo.attribute1 IS NULL)
292                     AND (X_Attribute1 IS NULL)))
293            AND (   (Recinfo.attribute2 =  X_Attribute2)
294                 OR (    (Recinfo.attribute2 IS NULL)
295                     AND (X_Attribute2 IS NULL)))
296            AND (   (Recinfo.attribute3 =  X_Attribute3)
297                 OR (    (Recinfo.attribute3 IS NULL)
298                     AND (X_Attribute3 IS NULL)))
299            AND (   (Recinfo.attribute4 =  X_Attribute4)
300                 OR (    (Recinfo.attribute4 IS NULL)
301                     AND (X_Attribute4 IS NULL)))
302            AND (   (Recinfo.attribute5 =  X_Attribute5)
303                 OR (    (Recinfo.attribute5 IS NULL)
304                     AND (X_Attribute5 IS NULL)))
305            AND (   (Recinfo.attribute6 =  X_Attribute6)
306                 OR (    (Recinfo.attribute6 IS NULL)
307                     AND (X_Attribute6 IS NULL)))
308            AND (   (Recinfo.attribute7 =  X_Attribute7)
309                 OR (    (Recinfo.attribute7 IS NULL)
310                     AND (X_Attribute7 IS NULL)))
311            AND (   (Recinfo.attribute8 =  X_Attribute8)
312                 OR (    (Recinfo.attribute8 IS NULL)
313                     AND (X_Attribute8 IS NULL)))
314            AND (   (Recinfo.attribute9 =  X_Attribute9)
315                 OR (    (Recinfo.attribute9 IS NULL)
316                     AND (X_Attribute9 IS NULL)))
317            AND (   (Recinfo.attribute10 =  X_Attribute10)
318                 OR (    (Recinfo.attribute10 IS NULL)
319                     AND (X_Attribute10 IS NULL)))
320            AND (   (Recinfo.attribute11 =  X_Attribute11)
321                 OR (    (Recinfo.attribute11 IS NULL)
322                     AND (X_Attribute11 IS NULL)))
323            AND (   (Recinfo.attribute12 =  X_Attribute12)
324                 OR (    (Recinfo.attribute12 IS NULL)
325                     AND (X_Attribute12 IS NULL)))
326            AND (   (Recinfo.attribute13 =  X_Attribute13)
327                 OR (    (Recinfo.attribute13 IS NULL)
328                     AND (X_Attribute13 IS NULL)))
329            AND (   (Recinfo.attribute14 =  X_Attribute14)
330                 OR (    (Recinfo.attribute14 IS NULL)
331                     AND (X_Attribute14 IS NULL)))
332            AND (   (Recinfo.attribute15 =  X_Attribute15)
333                 OR (    (Recinfo.attribute15 IS NULL)
334                     AND (X_Attribute15 IS NULL)))
335            AND (   (Recinfo.attribute_category_code =  X_Attribute_Category_Code
336 )
337                 OR (    (Recinfo.attribute_category_code IS NULL)
338                     AND (X_Attribute_Category_Code IS NULL)))
339            AND (   (Recinfo.exclude_salvage_value_flag =  X_Exclude_Salvage_Value_Flag)
340                 OR (    (Recinfo.exclude_salvage_value_flag IS NULL)
341                     AND (X_Exclude_Salvage_Value_Flag IS NULL)))
342            AND (   (Recinfo.deprn_basis_formula = X_Deprn_Basis_Formula)
343                 OR (    (Recinfo.deprn_basis_formula IS NULL)
344                     AND (X_Deprn_Basis_Formula is NULL)))
345            AND (   (Recinfo.deprn_basis_rule_id = X_Deprn_Basis_Rule_Id)
346                 OR (    (Recinfo.deprn_basis_rule_id IS NULL)
347                     AND (X_Deprn_Basis_Rule_Id is NULL)))   ) then
348       return;
349     else
350       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
351       APP_EXCEPTION.Raise_Exception;
352     end if;
353   END Lock_Row;
354 
355   PROCEDURE Update_Row(X_Rowid                          VARCHAR2,
356                        X_Method_Id                      NUMBER,
357                        X_Method_Code                    VARCHAR2,
358                        X_Life_In_Months                 NUMBER,
359                        X_Depreciate_Lastyear_Flag       VARCHAR2,
360                        X_Stl_Method_Flag                VARCHAR2,
361                        X_Rate_Source_Rule               VARCHAR2,
362                        X_Deprn_Basis_Rule               VARCHAR2,
363                        X_Prorate_Periods_Per_Year       NUMBER,
364                        X_Name                           VARCHAR2,
365                        X_Last_Update_Date               DATE,
366                        X_Last_Updated_By                NUMBER,
367                        X_Last_Update_Login              NUMBER,
368                        X_Attribute1                     VARCHAR2,
369                        X_Attribute2                     VARCHAR2,
370                        X_Attribute3                     VARCHAR2,
371                        X_Attribute4                     VARCHAR2,
372                        X_Attribute5                     VARCHAR2,
373                        X_Attribute6                     VARCHAR2,
374                        X_Attribute7                     VARCHAR2,
375                        X_Attribute8                     VARCHAR2,
376                        X_Attribute9                     VARCHAR2,
377                        X_Attribute10                    VARCHAR2,
378                        X_Attribute11                    VARCHAR2,
379                        X_Attribute12                    VARCHAR2,
380                        X_Attribute13                    VARCHAR2,
381                        X_Attribute14                    VARCHAR2,
382                        X_Attribute15                    VARCHAR2,
383                        X_Attribute_Category_Code        VARCHAR2,
384                        X_Exclude_Salvage_Value_Flag     VARCHAR2,
385  -- added for alternative flat rate depreciation calculation.   for 11.5.2
386                        X_Deprn_Basis_Formula            VARCHAR2,
387                        X_Polish_Adj_Calc_Basis_Flag     VARCHAR2,
388                        X_Guarantee_Rate_Method_Flag     VARCHAR2,
389                        X_Calling_Fn                     VARCHAR2,
390  -- added for Depreciable Basis Formula
391                        X_Deprn_Basis_Rule_Id            NUMBER DEFAULT NULL,
392                        p_log_level_rec             IN   FA_API_TYPES.log_level_rec_type default null) IS
393 
394   BEGIN
395 
396     -- Split into separate statements for performance reasons.
397     if (X_Life_In_Months is not null) then
398 
399        UPDATE fa_methods
400        SET
401        depreciate_lastyear_flag        =     X_Depreciate_Lastyear_Flag,
402        stl_method_flag                 =     X_Stl_Method_Flag,
403        rate_source_rule                =     X_Rate_Source_Rule,
404        deprn_basis_rule                =     X_Deprn_Basis_Rule,
405        prorate_periods_per_year        =     X_Prorate_Periods_Per_Year,
406        name                            =     X_Name,
407        last_update_date                =     X_Last_Update_Date,
408        last_updated_by                 =     X_Last_Updated_By,
409        last_update_login               =     X_Last_Update_Login,
410        attribute1                      =     X_Attribute1,
411        attribute2                      =     X_Attribute2,
412        attribute3                      =     X_Attribute3,
413        attribute4                      =     X_Attribute4,
414        attribute5                      =     X_Attribute5,
415        attribute6                      =     X_Attribute6,
416        attribute7                      =     X_Attribute7,
417        attribute8                      =     X_Attribute8,
418        attribute9                      =     X_Attribute9,
419        attribute10                     =     X_Attribute10,
420        attribute11                     =     X_Attribute11,
421        attribute12                     =     X_Attribute12,
422        attribute13                     =     X_Attribute13,
423        attribute14                     =     X_Attribute14,
424        attribute15                     =     X_Attribute15,
425        attribute_category_code         =     X_Attribute_Category_Code,
426        exclude_salvage_value_flag      =     X_Exclude_Salvage_Value_Flag,
427        deprn_basis_formula             =     X_Deprn_Basis_Formula,
428        polish_adj_calc_basis_flag      =     X_Polish_Adj_Calc_Basis_Flag,
429        guarantee_rate_method_flag      =     X_Guarantee_Rate_Method_Flag,
430        deprn_basis_rule_id             =     X_Deprn_Basis_Rule_Id
431        WHERE method_code = X_Method_Code
432        AND   life_in_months = X_Life_In_Months;
433 
434        if (SQL%NOTFOUND) then
435          Raise NO_DATA_FOUND;
436        end if;
437 
438        -- Fix for Bug #3810332.  Need to be more specific when updating the
439        -- basis rules to prevent deadlock.
440        if ((X_Rate_Source_Rule = 'FLAT') and
441            (X_Deprn_Basis_Rule = 'NBV') and
442            (nvl(X_Deprn_Basis_Formula, 'STRICT_FLAT') = 'STRICT_FLAT') and
443            (X_Deprn_Basis_Rule_Id is null)) then
444 
445           -- For Depreciable Basis Formula logic
446           UPDATE fa_methods
447           SET deprn_basis_rule_id =
448              (SELECT deprn_basis_rule_id
449               FROM   fa_deprn_basis_rules
450               WHERE  RULE_NAME='TRANSACTION')
451           WHERE rate_source_rule='FLAT'
452           AND deprn_basis_rule='NBV'
453           AND deprn_basis_formula IS NULL
454           AND deprn_basis_rule_id IS NULL
455           AND method_code = X_Method_Code
456           AND life_in_months = X_Life_In_Months;
457 
458           UPDATE fa_methods
459           SET deprn_basis_rule_id =
460              (SELECT deprn_basis_rule_id
461               FROM   fa_deprn_basis_rules
462               WHERE  RULE_NAME='FYBEGIN')
463           WHERE rate_source_rule='FLAT'
464           AND deprn_basis_rule='NBV'
465           AND deprn_basis_formula ='STRICT_FLAT'
466           AND deprn_basis_rule_id IS NULL
467           AND method_code = X_Method_Code
468           AND life_in_months = X_Life_In_Months;
469 
470        end if;
471     else
472 
473        UPDATE fa_methods
474        SET
475        depreciate_lastyear_flag        =     X_Depreciate_Lastyear_Flag,
476        stl_method_flag                 =     X_Stl_Method_Flag,
477        rate_source_rule                =     X_Rate_Source_Rule,
478        deprn_basis_rule                =     X_Deprn_Basis_Rule,
479        prorate_periods_per_year        =     X_Prorate_Periods_Per_Year,
480        name                            =     X_Name,
481        last_update_date                =     X_Last_Update_Date,
482        last_updated_by                 =     X_Last_Updated_By,
483        last_update_login               =     X_Last_Update_Login,
484        attribute1                      =     X_Attribute1,
485        attribute2                      =     X_Attribute2,
486        attribute3                      =     X_Attribute3,
487        attribute4                      =     X_Attribute4,
488        attribute5                      =     X_Attribute5,
489        attribute6                      =     X_Attribute6,
490        attribute7                      =     X_Attribute7,
491        attribute8                      =     X_Attribute8,
492        attribute9                      =     X_Attribute9,
493        attribute10                     =     X_Attribute10,
494        attribute11                     =     X_Attribute11,
495        attribute12                     =     X_Attribute12,
496        attribute13                     =     X_Attribute13,
497        attribute14                     =     X_Attribute14,
498        attribute15                     =     X_Attribute15,
499        attribute_category_code         =     X_Attribute_Category_Code,
500        exclude_salvage_value_flag      =     X_Exclude_Salvage_Value_Flag,
501        deprn_basis_formula             =     X_Deprn_Basis_Formula,
502        polish_adj_calc_basis_flag      =     X_Polish_Adj_Calc_Basis_Flag,
503        guarantee_rate_method_flag      =     X_Guarantee_Rate_Method_Flag,
504        deprn_basis_rule_id             =     X_Deprn_Basis_Rule_Id
505        WHERE method_code = X_Method_Code
506        AND   life_in_months is null;
507 
508        if (SQL%NOTFOUND) then
509          Raise NO_DATA_FOUND;
510        end if;
511 
512        -- Fix for Bug #3810332.  Need to be more specific when updating the
513        -- basis rules to prevent deadlock.
514        if ((X_Rate_Source_Rule = 'FLAT') and
515            (X_Deprn_Basis_Rule = 'NBV') and
516            (nvl(X_Deprn_Basis_Formula, 'STRICT_FLAT') = 'STRICT_FLAT') and
517            (X_Deprn_Basis_Rule_Id is null)) then
518 
519           -- For Depreciable Basis Formula logic
520           UPDATE fa_methods
521           SET deprn_basis_rule_id =
522              (SELECT deprn_basis_rule_id
523               FROM   fa_deprn_basis_rules
524               WHERE  RULE_NAME='TRANSACTION')
525           WHERE rate_source_rule='FLAT'
526           AND deprn_basis_rule='NBV'
527           AND deprn_basis_formula IS NULL
528           AND deprn_basis_rule_id IS NULL
529           AND method_code = X_Method_Code
530           AND life_in_months is null;
531 
532           UPDATE fa_methods
533           SET deprn_basis_rule_id =
534              (SELECT deprn_basis_rule_id
535               FROM   fa_deprn_basis_rules
536               WHERE  RULE_NAME='FYBEGIN')
537           WHERE rate_source_rule='FLAT'
538           AND deprn_basis_rule='NBV'
539           AND deprn_basis_formula ='STRICT_FLAT'
540           AND deprn_basis_rule_id IS NULL
541           AND method_code = X_Method_Code
542           AND life_in_months is null;
543 
544        end if;
545     end if;
546 
547   exception
548     when others then
549 
550       fa_srvr_msg.add_sql_error(
551                 calling_fn => 'fa_methods_pkg.update_row'
552                 ,p_log_level_rec => p_log_level_rec);
553 
554       FA_STANDARD_PKG.RAISE_ERROR(
555                 CALLED_FN => 'fa_methods_pkg.update_row',
556                 CALLING_FN => X_Calling_Fn
557                 ,p_log_level_rec => p_log_level_rec);
558 
559   END Update_Row;
560 
561   PROCEDURE Delete_Row(X_Rowid VARCHAR2,
562                        X_Calling_Fn VARCHAR2,
563                        p_log_level_rec  IN  FA_API_TYPES.log_level_rec_type default null) IS
564   BEGIN
565     DELETE FROM fa_methods
566     WHERE rowid = X_Rowid;
567 
568     if (SQL%NOTFOUND) then
569       Raise NO_DATA_FOUND;
570     end if;
571   exception
572     when others then
573 
574       fa_srvr_msg.add_sql_error(
575                 calling_fn => 'fa_methods_pkg.delete_row'
576                 ,p_log_level_rec => p_log_level_rec);
577 
578       FA_STANDARD_PKG.RAISE_ERROR(
579                 CALLED_FN => 'fa_methods_pkg.delete_row',
580                 CALLING_FN => X_Calling_Fn
581                 ,p_log_level_rec => p_log_level_rec);
582 
583 end DELETE_ROW;
584 
585 procedure LOAD_ROW (
586    X_CUSTOM_MODE in VARCHAR2,
587    X_METHOD_ID in NUMBER,
588    X_DB_LAST_UPDATED_BY NUMBER,
589    X_DB_LAST_UPDATE_DATE DATE,
590    X_OWNER in VARCHAR2,
591    X_LAST_UPDATE_DATE in DATE,
592    X_METHOD_CODE in VARCHAR2,
593    X_LIFE_IN_MONTHS in NUMBER,
594    X_DEPRECIATE_LASTYEAR_FLAG in VARCHAR2,
595    X_STL_METHOD_FLAG in VARCHAR2,
596    X_RATE_SOURCE_RULE in VARCHAR2,
597    X_DEPRN_BASIS_RULE in VARCHAR2,
598    X_PRORATE_PERIODS_PER_YEAR in NUMBER,
599    X_NAME in VARCHAR2,
600    X_ATTRIBUTE1 in VARCHAR2,
601    X_ATTRIBUTE2 in VARCHAR2,
602    X_ATTRIBUTE3 in VARCHAR2,
603    X_ATTRIBUTE4 in VARCHAR2,
604    X_ATTRIBUTE5 in VARCHAR2,
605    X_ATTRIBUTE6 in VARCHAR2,
606    X_ATTRIBUTE7 in VARCHAR2,
607    X_ATTRIBUTE8 in VARCHAR2,
608    X_ATTRIBUTE9 in VARCHAR2,
609    X_ATTRIBUTE10 in VARCHAR2,
610    X_ATTRIBUTE11 in VARCHAR2,
611    X_ATTRIBUTE12 in VARCHAR2,
612    X_ATTRIBUTE13 in VARCHAR2,
613    X_ATTRIBUTE14 in VARCHAR2,
614    X_ATTRIBUTE15 in VARCHAR2,
615    X_ATTRIBUTE_CATEGORY_CODE in VARCHAR2,
616    X_EXCLUDE_SALVAGE_VALUE_FLAG in VARCHAR2,
617 -- added for alternative flat depreciatio calculation.   for 11.5.2
618    X_DEPRN_BASIS_FORMULA in VARCHAR2,
619    X_POLISH_ADJ_CALC_BASIS_FLAG in VARCHAR2,
620    X_GUARANTEE_RATE_METHOD_FLAG in VARCHAR2,
621 -- added for Depreciable Basis Formula
622    X_DEPRN_BASIS_RULE_ID in NUMBER DEFAULT NULL,
623    p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) is
624 
625   h_record_exists       number(15);
626   h_method_id           number(15);
627 
628   user_id               number;
629   row_id                varchar2(64);
630 
631 begin
632 
633   user_id := fnd_load_util.owner_id (X_Owner);
634 
635   if (X_Method_Id is not null) then
636 
637      if (fnd_load_util.upload_test(user_id, x_last_update_date,
638                                    X_db_last_updated_by, X_db_last_update_date,
639                                    X_CUSTOM_MODE)) then
640 
641         fa_methods_pkg.update_row (
642            X_Rowid                             => row_id,
643            X_Method_ID                         => h_method_id,
644            X_Method_Code                       => X_Method_Code,
645            X_Life_In_Months                    => X_Life_In_Months,
646            X_Depreciate_Lastyear_Flag          => X_Depreciate_Lastyear_Flag,
647            X_Stl_Method_Flag                   => X_Stl_Method_Flag,
648            X_Rate_Source_Rule                  => X_Rate_Source_Rule,
649            X_Deprn_Basis_Rule                  => X_Deprn_Basis_Rule,
650            X_Prorate_Periods_Per_Year          => X_Prorate_Periods_Per_Year,
651            X_Name                              => X_Name,
652            X_Last_Update_Date                  => sysdate,
653            X_Last_Updated_By                   => user_id,
654            X_Last_Update_Login                 => 0,
655            X_Attribute1                        => X_Attribute1,
656            X_Attribute2                        => X_Attribute2,
657            X_Attribute3                        => X_Attribute3,
658            X_Attribute4                        => X_Attribute4,
659            X_Attribute5                        => X_Attribute5,
660            X_Attribute6                        => X_Attribute6,
661            X_Attribute7                        => X_Attribute7,
662            X_Attribute8                        => X_Attribute8,
663            X_Attribute9                        => X_Attribute9,
664            X_Attribute10                       => X_Attribute10,
665            X_Attribute11                       => X_Attribute11,
666            X_Attribute12                       => X_Attribute12,
667            X_Attribute13                       => X_Attribute13,
668            X_Attribute14                       => X_Attribute14,
669            X_Attribute15                       => X_Attribute15,
670            X_Attribute_Category_Code           => X_Attribute_Category_Code,
671            X_Exclude_Salvage_Value_Flag        => X_Exclude_Salvage_Value_Flag,
672            X_Deprn_Basis_Formula               => X_Deprn_Basis_Formula,
673            X_Polish_Adj_Calc_Basis_Flag        => X_Polish_Adj_Calc_Basis_Flag,
674            X_Guarantee_Rate_Method_Flag        => X_Guarantee_Rate_Method_Flag,
675            X_Calling_Fn                        => 'fa_methods_pkg.load_row',
676            X_Deprn_Basis_Rule_Id               => X_Deprn_Basis_Rule_Id
677            ,p_log_level_rec => p_log_level_rec);
678      end if;
679 else
680 
681   h_method_id := null;
682 
683   fa_methods_pkg.insert_row (
684     X_Rowid                             => row_id,
685     X_Method_ID                         => h_method_id,
686     X_Method_Code                       => X_Method_Code,
687     X_Life_In_Months                    => X_Life_In_Months,
688     X_Depreciate_Lastyear_Flag          => X_Depreciate_Lastyear_Flag,
689     X_Stl_Method_Flag                   => X_Stl_Method_Flag,
690     X_Rate_Source_Rule                  => X_Rate_Source_Rule,
691     X_Deprn_Basis_Rule                  => X_Deprn_Basis_Rule,
692     X_Prorate_Periods_Per_Year          => X_Prorate_Periods_Per_Year,
693     X_Name                              => X_Name,
694     X_Last_Update_Date                  => sysdate,
695     X_Last_Updated_By                   => user_id,
696     X_Created_By                        => user_id,
697     X_Creation_Date                     => sysdate,
698     X_Last_Update_Login                 => 0,
699     X_Attribute1                        => X_Attribute1,
700     X_Attribute2                        => X_Attribute2,
701     X_Attribute3                        => X_Attribute3,
702     X_Attribute4                        => X_Attribute4,
703     X_Attribute5                        => X_Attribute5,
704     X_Attribute6                        => X_Attribute6,
705     X_Attribute7                        => X_Attribute7,
706     X_Attribute8                        => X_Attribute8,
707     X_Attribute9                        => X_Attribute9,
708     X_Attribute10                       => X_Attribute10,
709     X_Attribute11                       => X_Attribute11,
710     X_Attribute12                       => X_Attribute12,
711     X_Attribute13                       => X_Attribute13,
712     X_Attribute14                       => X_Attribute14,
713     X_Attribute15                       => X_Attribute15,
714     X_Attribute_Category_Code           => X_Attribute_Category_Code,
715     X_Exclude_Salvage_Value_Flag        => X_Exclude_Salvage_Value_Flag,
716     X_Deprn_Basis_Formula               => X_Deprn_Basis_Formula,
717     X_Polish_Adj_Calc_Basis_Flag        => X_Polish_Adj_Calc_Basis_Flag,
718     X_Guarantee_Rate_Method_Flag        => X_Guarantee_Rate_Method_Flag,
719     X_Calling_Fn                        => 'fa_methods_pkg.load_row',
720     X_Deprn_Basis_Rule_Id               => X_Deprn_Basis_Rule_Id
721     ,p_log_level_rec => p_log_level_rec);
722 end if;
723 
724 exception
725    when others then
726 
727       fa_srvr_msg.add_sql_error(
728                 calling_fn => 'fa_methods_pkg.load_row'
729                 ,p_log_level_rec => p_log_level_rec);
730 
731        FA_STANDARD_PKG.RAISE_ERROR(
732                         CALLED_FN => 'fa_methods_pkg.load_row',
733                         CALLING_FN => 'upload fa_methods:' || SQLERRM
734                         ,p_log_level_rec => p_log_level_rec);
735 
736 end LOAD_ROW;
737 
738 /*Bugfix 6685881: Added x_method_code and x_life_in_months
739           * parameters */
740 procedure TRANSLATE_ROW (
741    X_CUSTOM_MODE in VARCHAR2,
742    X_METHOD_ID in NUMBER,
743    X_METHOD_CODE in VARCHAR2,
744    X_LIFE_IN_MONTHS in NUMBER,
745    X_DB_LAST_UPDATED_BY NUMBER,
746    X_DB_LAST_UPDATE_DATE DATE,
747    X_OWNER in VARCHAR2,
748    X_LAST_UPDATE_DATE DATE,
749    X_NAME in VARCHAR2,
750    p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) is
751 
752   user_id       number;
753 
754 begin
755 
756    user_id := fnd_load_util.owner_id (X_Owner);
757 
758    if (fnd_load_util.upload_test(user_id, x_last_update_date,
759                                  x_db_last_updated_by, x_db_last_update_date,
760                                  X_CUSTOM_MODE)) then
761       /*Bugfix 6685881: Use method_code and life_in_months to update
762       * the appropriate row instead of method_id. This is because
763       * for new methods, method_id will be different from what is being
764       * passed from ldt file. fyi, LOAD_ROW procedure passes method_id
765       * as null to INSERT_ROW. To translate the new row, we need to make use
766       * of method_code and life_in_months.
767       * */
768 
769       if (X_Life_In_Months is not null) then
770 
771          update FA_METHODS
772          set    NAME = nvl(X_Name, Name),
773                 LAST_UPDATE_DATE = sysdate,
774                 LAST_UPDATED_BY = user_id
775          --where METHOD_ID = X_Method_ID
776          where method_code = X_Method_Code
777          and   life_in_months = X_Life_In_Months
778          and    userenv('LANG') =
779                 (select language_code
780                  from FND_LANGUAGES
781                  where installed_flag = 'B');
782       else
783 
784           update FA_METHODS set
785                  NAME = nvl(X_Name, Name),
786                  LAST_UPDATE_DATE = sysdate,
787                  LAST_UPDATED_BY = user_id,
788                  LAST_UPDATE_LOGIN = 0
789                --where METHOD_ID = X_Method_ID
790                where method_code = X_Method_Code
791                and   life_in_months is null
792                and   userenv('LANG') =
793                  (select language_code
794                  from FND_LANGUAGES
795                  where installed_flag = 'B');
796        end if;
797 
798    end if;
799 
800 exception
801    when others then
802 
803       fa_srvr_msg.add_sql_error(
804                 calling_fn => 'fa_methods_pkg.translate_row'
805                 ,p_log_level_rec => p_log_level_rec);
806 
807        FA_STANDARD_PKG.RAISE_ERROR(
808                         CALLED_FN => 'fa_methods_pkg.translate_row',
809                         CALLING_FN => 'upload fa_methods'
810                         ,p_log_level_rec => p_log_level_rec);
811 
812 end TRANSLATE_ROW;
813 
814 procedure LOAD_SEED_ROW (
815              x_upload_mode                IN VARCHAR2,
816              x_custom_mode                IN VARCHAR2,
817              x_owner                      IN VARCHAR2,
818              x_last_update_date           IN DATE,
819              x_method_code                IN VARCHAR2,
820              x_life_in_months             IN NUMBER,
821              x_depreciate_lastyear_flag   IN VARCHAR2,
822              x_stl_method_flag            IN VARCHAR2,
823              x_rate_source_rule           IN VARCHAR2,
824              x_deprn_basis_rule           IN VARCHAR2,
825              x_prorate_periods_per_year   IN NUMBER,
826              x_name                       IN VARCHAR2,
827              x_attribute1                 IN VARCHAR2,
828              x_attribute2                 IN VARCHAR2,
829              x_attribute3                 IN VARCHAR2,
830              x_attribute4                 IN VARCHAR2,
831              x_attribute5                 IN VARCHAR2,
832              x_attribute6                 IN VARCHAR2,
833              x_attribute7                 IN VARCHAR2,
834              x_attribute8                 IN VARCHAR2,
835              x_attribute9                 IN VARCHAR2,
836              x_attribute10                IN VARCHAR2,
837              x_attribute11                IN VARCHAR2,
838              x_attribute12                IN VARCHAR2,
839              x_attribute13                IN VARCHAR2,
840              x_attribute14                IN VARCHAR2,
841              x_attribute15                IN VARCHAR2,
842              x_attribute_category_code    IN VARCHAR2,
843              x_exclude_salvage_value_flag IN VARCHAR2,
844              x_deprn_basis_formula        IN VARCHAR2,
845 	     X_Polish_Adj_Calc_Basis_Flag IN VARCHAR2,
846  	     X_Guarantee_Rate_Method_Flag IN VARCHAR2,
847              x_deprn_basis_rule_id        IN NUMBER) IS
848 
849 
850    h_method_id           number(15);
851    h_last_update_date    date;
852    h_last_updated_by     number;
853 
854 BEGIN
855 
856       if not fa_cache_pkg.fazccmt (
857          X_method                => x_method_code,
858          X_life                  => x_life_in_months) then
859 
860          h_method_id := null;
861 
862       else
863 
864          h_method_id        := fa_cache_pkg.fazccmt_record.method_id;
865          h_last_update_date := fa_cache_pkg.fazccmt_record.last_update_date;
866          h_last_updated_by  := fa_cache_pkg.fazccmt_record.last_updated_by;
867 
868       end if;
869 
870       if (x_upload_mode = 'NLS') then
871            fa_methods_pkg.TRANSLATE_ROW (
872              x_custom_mode                => x_custom_mode,
873              x_method_id                  => h_method_id,
874 	     x_method_code                => x_method_code,
875              x_life_in_months             => x_life_in_months,
876              x_db_last_update_date        => h_last_update_date,
877              x_db_last_updated_by         => h_last_updated_by,
878              x_owner                      => x_owner,
879              x_last_update_date           => x_last_update_date,
880              x_name                       => x_name);
881       else
882            fa_methods_pkg.LOAD_ROW (
883              x_custom_mode                => x_custom_mode,
884              x_method_id                  => h_method_id,
885              x_db_last_update_date        => h_last_update_date,
886              x_db_last_updated_by         => h_last_updated_by,
887              x_owner                      => x_owner,
888              x_last_update_date           => x_last_update_date,
889              x_method_code                => x_method_code,
890              x_life_in_months             => x_life_in_months,
891              x_depreciate_lastyear_flag   => x_depreciate_lastyear_flag,
892              x_stl_method_flag            => x_stl_method_flag,
893              x_rate_source_rule           => x_rate_source_rule,
894              x_deprn_basis_rule           => x_deprn_basis_rule,
895              x_prorate_periods_per_year   => x_prorate_periods_per_year,
896              x_name                       => x_name,
897              x_attribute1                 => x_attribute1,
898              x_attribute2                 => x_attribute2,
899              x_attribute3                 => x_attribute3,
900              x_attribute4                 => x_attribute4,
901              x_attribute5                 => x_attribute5,
902              x_attribute6                 => x_attribute6,
903              x_attribute7                 => x_attribute7,
904              x_attribute8                 => x_attribute8,
905              x_attribute9                 => x_attribute9,
906              x_attribute10                => x_attribute10,
907              x_attribute11                => x_attribute11,
908              x_attribute12                => x_attribute12,
909              x_attribute13                => x_attribute13,
910              x_attribute14                => x_attribute14,
911              x_attribute15                => x_attribute14,
912              x_attribute_category_code    => x_attribute_category_code,
913              x_exclude_salvage_value_flag => x_exclude_salvage_value_flag,
914              x_deprn_basis_formula        => x_deprn_basis_formula,
915 	     X_Polish_Adj_Calc_Basis_Flag => X_Polish_Adj_Calc_Basis_Flag,
916              X_Guarantee_Rate_Method_Flag => X_Guarantee_Rate_Method_Flag,
917              x_deprn_basis_rule_id        => x_deprn_basis_rule_id);
918 
919       end if;
920 
921 END LOAD_SEED_ROW;
922 
923 END FA_METHODS_PKG;