DBA Data[Home] [Help]

PACKAGE BODY: APPS.IPA_ASSET_MECH_APIS_PKG

Source


1 PACKAGE BODY IPA_ASSET_MECH_APIS_PKG AS
2 /* $Header: IPAAMAPB.pls 120.3 2006/02/14 16:56:58 dlanka noship $ */
3 /* Original Header: IPAFAXB.pls 41.8 98/02/06 17:01:21 porting ship  */
4 Procedure IPA_AUTO_ASSET_CREATION (
5 			  x_project_num_from        IN  VARCHAR2,
6 			  x_project_num_to          IN  VARCHAR2,
7               		  x_pa_date                 IN  OUT NOCOPY DATE,
8 			  x_err_code                IN OUT NOCOPY varchar2,
9 			  x_err_stack               IN OUT NOCOPY varchar2,
10 			  x_err_stage               IN OUT NOCOPY varchar2,
11                           x_conc_request_id         IN OUT NOCOPY NUMBER
12 			) IS
13 
14   l_exp_id number;
15 
16    -- End added cursor to update attributes 8,9 and 10 for invoice lines.
17    -- CRL3.1  5/18/99
18 
19 
20   CURSOR get_asset_naming_method IS
21   SELECT asset_name ,
22 	 asset_description1,
23 	 asset_description2,
24 	 asset_description3,
25 	 asset_desc_separator,
26 	 asset_location,
27 	 asset_category
28   FROM ipa_asset_naming_conventions;
29 
30   asset_naming_method_rec    get_asset_naming_method%rowtype;
31    v_asset_name        varchar2(30);
32    v_asset_description varchar2(80);
33    v_row_id            varchar2(80);
34    v_row_id2           varchar2(80);
35    v_project_asset_id  number;
36    v_rejection_code    varchar2(30);
37    v_asset_location    varchar2(300);
38    v_asset_category    varchar2(300);
39    v_location_id       number;
40    v_category_id       number;
41    v_book_type_code    varchar2(15);
42    v_dummy             varchar2(1);
43    v_org_id            number;
44    v_deprn_expense_ccid number;
45    v_err_code           varchar2(640);
46    v_err_stage          varchar2(640);
47    v_err_stack          varchar2(640);
48    v_accounting_flex_structure number;
49 
50 --  Modified to pull crl inventory_item and serial_number too
51 --  for crl scm 3.1.  tls 5/9/99
52 
53   CURSOR get_expenditure_items IS
54   SELECT pei.attribute8,
55          pei.attribute9,
56          pei.attribute10,
57          pei.attribute6, --crl_inventory_item
58          pei.attribute7, --crl_serial_number
59          pt.task_name,
60          pt.attribute10 task_attribute10,
61          ppr.name project_name,
62          pt.task_id,
63          ppr.project_id,
64          pei.expenditure_item_id
65    FROM  pa_projects_all ppr, -- Changed to _all as part of MOAC changes.
66 	 pa_project_types ppt,
67     --	 pa_cost_distribution_lines_all pcdl,
68 	 pa_expenditure_items_all pei,
69 	 pa_tasks pt,
70        pa_tasks pt2
71    WHERE ppr.segment1 between x_project_num_from and x_project_num_to and
72          ppr.template_flag <> 'Y' and
73          ppr.project_status_code <> 'CLOSED' and
74          ppr.project_type = ppt.project_type and
75          ppt.cip_grouping_method_code = 'CIPGCE' and
76 	 --nvl(ppt.attribute10,'N') = 'Y' and
77          ppt.project_type_class_code = 'CAPITAL' and
78          nvl(ppr.attribute10,'Y') ='Y' and
79          nvl(pt2.attribute9,'Y') ='Y' and
80          ppt.interface_asset_cost_code = 'F'
81    AND   pt.project_id = ppr.project_id
82    AND   ppt.org_id = ppr.org_id -- Fix for bug : 4969694
83    --AND pcdl.expenditure_item_id = pei.expenditure_item_id
84    --  dcharlto 4/21/99 crl3.1
85    AND decode(IPA_ASSET_MECH_APIS_PKG.g_nl_installed,'Y',pei.expenditure_item_id,-99) = decode(IPA_ASSET_MECH_APIS_PKG.g_nl_installed,'Y',nvl(IPA_ASSET_MECH_APIS_PKG.g_expenditure_item_id,pei.expenditure_item_id), -99)
86    --  dcharlto 4/21/99 crl3.1
87    --AND decode(nvl(IPA_ASSET_MECH_APIS_PKG.g_nl_installed,'N'),'Y','N',pei.revenue_distributed_flag) = 'N'
88    --AND pei.revenue_distributed_flag||'' = 'N'
89    --AND   pcdl.line_type = DECODE(ppt.capital_cost_type_code,'R','R','B','D','R')
90    --AND   pcdl.billable_flag = 'Y'
91    AND   pei.billable_flag = 'Y'
92    --AND   pcdl.pa_date  <= x_pa_date
93    AND   pei.expenditure_item_date  <= x_pa_date
94    AND   pei.task_id = pt.task_id
95    AND   nvl(pei.CRL_ASSET_CREATION_STATUS_CODE,'N') <>'Y'
96    AND   pt.top_task_id = pt2.task_id
97    AND   ((pei.attribute8 is not null) OR (pei.attribute9 is not null)
98           OR (pei.attribute10 is not null) )
99    /* Added for Bug 3574567 */
100    AND   (pei.revenue_distributed_flag = 'N' OR
101           (pei.revenue_distributed_flag = 'Y'
102           AND   NOT EXISTS (SELECT 'This CDL was summarized before'
103                             FROM   pa_project_asset_line_details pald,
104                                    pa_project_asset_lines pal
105                             WHERE  pald.expenditure_item_id = pei.expenditure_item_id
106                             AND    pald.project_asset_line_detail_id = pal.project_asset_line_detail_id
107                             AND    pal.project_asset_id >= 1)
108           )
109          )
110    for update of CRL_ASSET_CREATION_STATUS_CODE NOWAIT;
111 
112 --  Modified to check crl inventory_item and serial_number too
113 --  for crl scm 3.1.  tls 5/9/99
114 
115    cursor check_asset_existence (c_project_id in number,
116                            c_task_id in number,
117                            c_attribute8 in varchar2,
118                            c_attribute9 in varchar2,
119                            c_attribute10 in varchar2,
120                            c_attribute6 in varchar2, --crl_inventory_item
121                            c_attribute7 in varchar2 --crl_serial_number
122 			) IS
123    select 'X'
124    FROM pa_project_asset_assignments ppaa
125    WHERE ppaa.task_id = c_task_id
126    AND   ppaa.project_id = c_project_id
127    AND   nvl(ppaa.attribute8,'~!@#') = nvl(c_attribute8, '~!@#')
128    AND   nvl(ppaa.attribute9,'~!@#') = nvl(c_attribute9, '~!@#')
129    AND   nvl(ppaa.attribute10,'~!@#') = nvl(c_attribute10, '~!@#')
130    /* Start Bug fix:2956569 : attribute6,7 Should be validated only when the nl_installed flag = Y*/
131    AND  ( (NVL(IPA_ASSET_MECH_APIS_PKG.g_nl_installed,'N') = 'Y'
132            AND   nvl(ppaa.attribute6,'~!@#') = nvl(c_attribute6, '~!@#') --crl_inventory
133            AND   nvl(ppaa.attribute7,'~!@#') = nvl(c_attribute7, '~!@#') --serial_number
134 	  )
135          OR
136           NVL(IPA_ASSET_MECH_APIS_PKG.g_nl_installed,'N') = 'N'
137 	);
138    /* End Bug fix:2956569 */
139 
140 
141    /* Bug#3043050. Added decode for attributes 6 and 7 based on NL Installed flag */
142    cursor get_asset_description(task_name in varchar2,
143                                 project_name in varchar2,
144                                 attribute8 in varchar2,
145                                 attribute9 in varchar2,
146                                 attribute10 in varchar2,
147                                 attribute6 in varchar2, -- inventory_item
148                                 attribute7 in varchar2) IS --serial_number
149    select substr(decode(asset_naming_method_rec.asset_description1,
150                  'ADT',task_name,
151 		 'ADP',project_name,
152 		 'ADGE1',attribute8,
153 		 'ADGE2',attribute9,
154 		 'ADGE3',attribute10)
155 		 ||decode(asset_naming_method_rec.asset_description2,'None',null,asset_naming_method_rec.asset_desc_separator)||
156 	  decode(asset_naming_method_rec.asset_description2,
157                  'ADT',task_name,
158 		 'ADP',project_name,
159 		 'ADGE1',attribute8,
160 		 'ADGE2',attribute9,
161 		 'ADGE3',attribute10)
162 		 ||decode(asset_naming_method_rec.asset_description3,'None',null,asset_naming_method_rec.asset_desc_separator)||
163 	  decode(asset_naming_method_rec.asset_description3,
164                  'ADT',task_name,
165 		 'ADP',project_name,
166 		 'ADGE1',attribute8,
167 		 'ADGE2',attribute9,
168 		 'ADGE3',attribute10)||
169           decode(nvl(IPA_ASSET_MECH_APIS_PKG.g_nl_installed, 'N'), 'Y',
170                decode(attribute6,null,null,
171                asset_naming_method_rec.asset_desc_separator||
172                  attribute6||                --Inventory_item
173                 decode(attribute7,null,null,
174                    asset_naming_method_rec.asset_desc_separator||
175                      attribute7)), null),1,80)
176         asset_description
177     from dual;
178 
179    cursor get_asset_category_id is
180    select category_id
181    from fa_categories
182    where upper(segment1||segment2||segment3||segment4||segment5||segment6||segment7) = upper(v_asset_category);
183 
184    cursor get_asset_location_id is
185    select location_id
186    from fa_locations
187    where upper(segment1||segment2||segment3||segment4||segment5||segment6||segment7) = upper(v_asset_location);
188 
189    cursor get_book_type IS
190    select bc.book_type_code
191    from fa_book_controls bc, fa_category_books cb, pa_implementations pi
192    where cb.category_id = v_category_id
193    and cb.book_type_code = bc.book_type_code
194    and bc.book_class = 'CORPORATE'
195    and pi.set_of_books_id = bc.set_of_books_id;
196 
197    cursor get_book_info is
198     Select accounting_flex_structure
199     from fa_book_controls
200     where book_type_code = v_book_type_code;
201   Begin
202    -- added more staging code messages tls crl3.1
203 
204    x_err_code := '0';
205    x_conc_request_id := x_request_id;
206 
207    -- Added to update attributes 8,9 and 10 for invoice lines.
208    -- CRL3.1  5/18/99
209   /************************** client Extension is being used ***************
210   if nvl(fnd_profile.value('CRL: COPY GROUPING ELEMENT INFORMATION'),'N') = 'Y' then
211    open get_invoice_8910;
212    fetch get_invoice_8910 into l_exp_id;
213    while get_invoice_8910%found loop
214         update pa_expenditure_items_all pei
215         set   (attribute8, attribute9, attribute10) =
216               (select aid.attribute8,aid.attribute9, aid.attribute10
217                from ap_invoice_distributions aid,
218                     pa_cost_distribution_lines_all pcd
219                where pei.expenditure_item_id = pcd.expenditure_item_id
220                and   pcd.system_reference2 = aid.invoice_id
221                and   pcd.system_reference3 = aid.distribution_line_number
222                and   pcd.transfer_status_code = 'V')
223         where pei.expenditure_item_id = l_exp_id;
224 
225         fetch get_invoice_8910 into l_exp_id;
226     end loop;
227     close get_invoice_8910;
228   end if;
229 
230    -- End added to update attributes 8,9 and 10 for invoice lines.
231    -- CRL3.1  5/18/99
232  ***********************************************/
233     x_err_stage := 'ipa_get_org';
234 
235     select org_id
236     into v_org_id
237     from pa_implementations;
238 
239     x_err_stage := 'ipa_get_name_method';
240 
241     open get_asset_naming_method;
242     fetch get_asset_naming_method into
243       asset_naming_method_rec.asset_name ,
244       asset_naming_method_rec.asset_description1,
245       asset_naming_method_rec.asset_description2,
246       asset_naming_method_rec.asset_description3,
247       asset_naming_method_rec.asset_desc_separator,
248       asset_naming_method_rec.asset_location,
249       asset_naming_method_rec.asset_category ;
250     if get_asset_naming_method%notfound then
251       x_err_code := '10';
252       return;
253     end if;
254     close get_asset_naming_method;
255 
256     x_err_stage := 'ipa_get_expenditure';
257 
258     for ei_rec in get_expenditure_items loop
259        v_asset_name        := null;
260        v_asset_description := null;
261        v_row_id            := null;
262        v_project_asset_id  := null;
263        v_rejection_code    := null;
264        v_asset_location    := null;
265        v_asset_category    := null;
266        v_location_id       := null;
267        v_category_id       := null;
268 
269      x_err_stage := 'ipa_chk_asset_exist';
270 
271 --  Modified call to pass crl inventory_item and serial_number
272 --  for crl scm 3.1.  tls 5/9/99
273 
274       open check_asset_existence(ei_rec.project_id,
275                                  ei_rec.task_id,
276                                  ei_rec.attribute8,
277                                  ei_rec.attribute9,
278                                  ei_rec.attribute10,
279                                  ei_rec.attribute6, --crl_inventory_item
280                                  ei_rec.attribute7); --crl_serial_number
281       fetch check_asset_existence into v_dummy;
282       if check_asset_existence%found then
283         close check_asset_existence;
284         goto  next_row;
285       end if;
286       close check_asset_existence;
287 
288      x_err_stage := 'ipa_get_asset_name';
289 
290   -- Asset Name
291       if asset_naming_method_rec.asset_name = 'ANT' then
292        v_asset_name := ei_rec.task_name;
293       elsif asset_naming_method_rec.asset_name = 'ANP' then
294        v_asset_name := ei_rec.project_name;
295       elsif asset_naming_method_rec.asset_name = 'ANGE1' then
296        v_asset_name := ei_rec.attribute8;
297       elsif asset_naming_method_rec.asset_name = 'ANGE2' then
298        v_asset_name := ei_rec.attribute9;
299       elsif asset_naming_method_rec.asset_name = 'ANGE3' then
300        v_asset_name := ei_rec.attribute10;
301       end if;
302 
303      x_err_stage := 'ipa_get_asset_desc';
304 
305 --  Modified call to pass crl inventory_item and serial_number
306 --  for crl scm 3.1.  tls 5/9/99
307 
308 -- Asset Description
309       open get_asset_description(ei_rec.task_name,
310                                  ei_rec.project_name,
311                                  ei_rec.attribute8,
312                                  ei_rec.attribute9,
313                                  ei_rec.attribute10,
314                                  ei_rec.attribute6, --crl_inventory_item
315                                  ei_rec.attribute7); --crl_serial_number
316       fetch get_asset_description into v_asset_description;
317       close get_asset_description;
318 
319      x_err_stage := 'ipa_get_asset_loc';
320 
321 -- Asset Location
322       if asset_naming_method_rec.asset_location = 'ALGE1' then
323        v_asset_location := ei_rec.attribute8;
324       elsif asset_naming_method_rec.asset_location = 'ALGE2' then
325        v_asset_location := ei_rec.attribute9;
326       elsif asset_naming_method_rec.asset_location = 'ALGE3' then
327        v_asset_location := ei_rec.attribute10;
328       end if;
329 
330       open get_asset_location_id;
331       fetch get_asset_location_id into v_location_id;
332       if (get_asset_location_id%notfound) OR (v_asset_location is null) then
333         v_rejection_code := 'ASSET_LOC_NOTFOUND';
334         close get_asset_location_id;
335         goto next_row;
336       end if;
337       close get_asset_location_id;
338 
339      x_err_stage := 'ipa_get_asset_cat';
340 
341 -- Asset Category
342       if asset_naming_method_rec.asset_category = 'ACT' then
343        v_asset_category := ei_rec.task_name;
344       elsif asset_naming_method_rec.asset_category = 'ACDF' then
345        v_asset_category := ei_rec.task_attribute10;
346       elsif asset_naming_method_rec.asset_category = 'ACGE1' then
347        v_asset_category := ei_rec.attribute8;
351        v_asset_category := ei_rec.attribute10;
348       elsif asset_naming_method_rec.asset_category = 'ACGE2' then
349        v_asset_category := ei_rec.attribute9;
350       elsif asset_naming_method_rec.asset_category = 'ACGE3' then
352       end if;
353 
354       open get_asset_category_id;
355       fetch get_asset_category_id into v_category_id;
356       if (get_asset_category_id%notfound) OR (v_asset_category is null)then
357         v_rejection_code := 'ASSET_CAT_NOTFOUND';
358         close get_asset_category_id;
359         goto next_row;
360       end if;
361       close get_asset_category_id;
362 
363      x_err_stage := 'ipa_get_book_type';
364 
365 --Book Type Code
366 
367       --Bug 3068204
368       --Get Book_Type_Code from Pa_Implementations, If NULL then derive from FA.
369 
370       Select Book_Type_Code
371       Into   V_Book_Type_Code
372       From   Pa_Implementations;
373 
374       --Bug 3068204
375       If V_Book_Type_Code is NULL Then
376          open get_book_type;
377          fetch get_book_type into v_book_type_code;
378          close get_book_type;
379       End If;
380 
381 --Deprn CCID
382       x_err_stage := 'Get Depreciation Expense Account';
383       v_err_code := '0';
384       v_deprn_expense_ccid := -1;
385       ipa_client_Extension_pkg.get_default_deprn_expense(v_book_type_code,
386                                      v_category_id,
387                                      v_location_id ,
388                                      ei_rec.expenditure_item_id ,
389                                      v_deprn_expense_ccid,
390                                      v_err_stack ,
391                                      v_err_stage ,
392                                      v_err_code);
393 
394       if v_err_code <> '0' then
395         v_rejection_code := substr(v_err_code,1,30);
396         goto next_row;
397       end if;
398 
399      if(nvl(v_deprn_expense_ccid,0) > 0 ) then  /* Added for Bug#3571657 */
400       open get_book_info;
401       fetch get_book_info into v_accounting_flex_structure;
402       close get_book_info;
403 
404       if not(FND_FLEX_KEYVAL.validate_ccid(
405                         appl_short_name    =>'SQLGL',
406                         key_flex_code           =>'GL#',
407                         structure_number        =>v_accounting_flex_structure,
408                         combination_id          => v_deprn_expense_ccid,
409                         vrule =>'GL_ACCOUNT\\nGL_ACCOUNT_TYPE\\nI\\n' ||
410                                 'APPL=''OFA'';NAME=FA_SHARED_NOT_EXPENSE_ACCOUNT\\nE' ||
411                                 '\\0GL_GLOBAL\\nDETAIL_POSTING_ALLOWED\\nI\\n' ||
412                                 'APPL=''SQLGL'';NAME=GL Detail Posting Not Allowed\\nY' ||
413                                 '\\0\\nSUMMARY_FLAG\\nI\\n' ||
414                                 'APPL=''SQLGL'';NAME=GL summary credit debit\\nN'
415                                         )) then
416           v_rejection_code := 'IFA_INVALID_DEPR_CCID';
417           goto next_row;
418        end if;
419       end if;   /* v_deprn_expense_ccid check - Added for Bug#3571657 */
420 
421        x_err_stage := 'Inserting Into PA_PROJECT_ASSETS_ALL';
422 
423       PA_PROJECT_ASSETS_PKG.Insert_Row(
424           X_Rowid                       =>v_Row_id
425          ,X_Project_Asset_Id            =>v_Project_Asset_ID
426          ,X_Project_Id                  =>ei_rec.Project_Id
427          ,X_Asset_Number                =>null
428          ,X_Asset_Name                  =>'X'
429          ,X_Asset_Description           =>v_Asset_Description
430          ,X_Location_Id                 =>v_location_id
431          ,X_Assigned_To_Person_Id       =>null
432          ,X_Date_Placed_In_Service      =>null
433          ,X_Asset_Category_Id           =>v_category_id
434          ,X_Asset_key_ccid              => null --Added for 11i
435          ,X_Book_Type_Code              =>v_book_type_code
436          -- dcharlto
437          ,X_Asset_Units            =>nvl(IPA_ASSET_MECH_APIS_PKG.g_number_of_units,1)
438          -- dcharlto
439          ,X_Depreciate_Flag             =>'Y'
440          ,X_Amortize_Flag               =>'N'
441          ,X_Cost_Adjustment_Flag        => 'N'
442          ,X_Reverse_Flag                => 'N'
443          ,X_Depreciation_Expense_Ccid   =>v_deprn_expense_ccid
444          ,X_Capitalized_Flag            =>'N'
445          ,X_Estimated_In_Service_Date   =>to_date(null)
446          ,X_Capitalized_Cost            =>0
447          ,X_Grouped_CIP_Cost            =>0
448          ,X_Last_Update_Date            =>sysdate
449          ,X_Last_Updated_By             =>X_Last_Updated_By
450          ,X_Creation_Date               =>sysdate
451          ,X_Created_By                  =>X_Created_By
452          ,X_Last_Update_Login           =>X_Last_Update_Login
453          ,X_Attribute_Category          =>null
454          ,X_Attribute1                  =>null
455          ,X_Attribute2                  =>null
456          ,X_Attribute3          =>null
457          ,X_Attribute4          =>null
458          ,X_Attribute5          =>null
459          ,X_Attribute6          =>null
460          ,X_Attribute7          =>null
461          ,X_Attribute8          =>ei_rec.attribute8
462          ,X_Attribute9          =>ei_rec.attribute9
463          ,X_Attribute10         =>ei_rec.attribute10
467          ,X_Attribute14         =>null
464          ,X_Attribute11         =>null
465          ,X_Attribute12         =>null
466          ,X_Attribute13         =>null
468          ,X_Attribute15         =>null
469          --Bug 3068204, added the new parameters included in PA.L
470          , X_Project_Asset_Type =>'ESTIMATED'
471          , X_Estimated_Units    =>1
472          , X_Parent_Asset_Id    =>null
473          , X_Estimated_Cost     =>null
474          , X_Manufacturer_Name  =>null
475          , X_Model_Number       =>null
476          , X_Serial_Number      =>null
477          , X_Tag_Number         =>null
478          , X_Capital_Hold_Flag  =>'N'
479          , X_Ret_Target_Asset_Id =>null
480          , X_ORG_ID => v_org_id -- MOAC changes
481          );
482 
483           x_err_stage := 'Updating PA_PROJECT_ASSETS_ALL';
484           update pa_project_assets
485           set asset_name = substr(v_asset_name,1,30-length(asset_naming_method_rec.asset_desc_separator||to_char(v_project_asset_id)))
486                               ||asset_naming_method_rec.asset_desc_separator||to_char(v_project_asset_id),
487           org_id = v_org_id,
488           request_id = x_request_id,
489 	  program_application_id = x_program_application_id,
490 	  program_id = x_program_id,
491 	  program_update_date = sysdate
492           where rowid = v_row_id;
493 
494       x_err_stage := 'Inserting Into PA_PROJECT_ASSETS_ASSIGNMENTS';
495       PA_PROJ_ASSET_ASSIGN_PKG.insert_row(X_Rowid =>v_row_id2
496                       ,X_Project_Asset_Id  =>v_project_asset_id
497                       ,X_Task_Id           => ei_rec.task_id
498                       ,X_Project_Id        => ei_rec.project_id
499 		      ,X_Last_Update_Date  =>sysdate
500 		      ,X_Last_Updated_By   =>x_Last_Updated_By
501 		      ,X_Creation_Date     =>sysdate
502 		      ,X_Created_By        =>x_Created_By
503 		      ,X_Last_Update_Login =>x_Last_Update_Login);
504 
505       --  Added crl inventory_item and serial_number to assignment
506       --  for crl scm 3.1 modification that an item must be its own
507       --  asset.  tls  5/9/99
508 
509       /* Bug#3043050. Added decode for attributes 6 and 7 based on NL Installed flag */
510       x_err_stage := 'Updating PA_PROJECT_ASSETS_ASSIGNMENTS';
511       update pa_project_asset_assignments
512       set   attribute8 = ei_rec.attribute8
513            ,attribute9 = ei_rec.attribute9
514            ,attribute10 = ei_rec.attribute10
515            ,attribute6 = decode(nvl(IPA_ASSET_MECH_APIS_PKG.g_nl_installed, 'N'), 'Y',
516                                 ei_rec.attribute6, attribute6) --crl_inventory_item
517            ,attribute7 = decode(nvl(IPA_ASSET_MECH_APIS_PKG.g_nl_installed, 'N'), 'Y',
518                                 ei_rec.attribute7, attribute7) --crl_serial_number
519       where rowid = v_row_id2;
520 
521 
522  <<next_row>>
523   x_err_stage := 'Updating PA_EXPENDITURE_ITEMS_ALL';
524   update pa_expenditure_items_all
525   set crl_asset_creation_rej_code = v_rejection_code,
526       crl_asset_creation_status_code = decode(v_rejection_code,null,'Y','R') ,
527       request_id = x_request_id,
528       program_application_id = x_program_application_id,
529       program_id = x_program_id,
530       program_update_date = sysdate,
531       last_update_date = sysdate,
532       last_updated_by = x_last_updated_by,
533       last_update_login = x_last_update_login
534   where current of get_expenditure_items;
535 
536 end loop;
537 
538 EXCEPTION
539   WHEN OTHERS THEN
540     x_err_code := (SQLCODE);
541     ROLLBACK WORK;
542 End;
543 
544 Function check_auto_asset  (x_project_id in number,
545                             x_task_id in number) return boolean IS
546 
547   cursor check_auto_asset is
548   select 'X'
549   from pa_tasks pt,
550        pa_tasks pt2,
551        pa_project_types ppt,
552        pa_projects_all pp -- Changed to _ALL as part of MOAC changes
553   where pp.project_type = ppt.project_type
554   and   ppt.cip_grouping_method_code = 'CIPGCE'
555   --and   nvl(ppt.attribute10,'N') = 'Y'
556   and   pp.project_id = x_project_id
557   and   pt.task_id= x_task_id
558   and   pt.project_id = x_project_id
559   and   pt2.task_id = pt.top_task_id
560   and   nvl(pp.attribute10,'Y') = 'Y'
561   and   nvl(pt2.attribute9,'Y') = 'Y';
562   v_dummy     varchar2(1);
563 
564   Begin
565 
566     open check_auto_asset ;
567     fetch check_auto_asset into v_dummy;
568     if check_auto_asset%found then
569       return true;
570     else
571       return false;
572     end if;
573     close check_auto_asset ;
574 
575  End;
576 
577 END IPA_ASSET_MECH_APIS_PKG;