DBA Data[Home] [Help]

PACKAGE BODY: APPS.AP_EXPENSE_REPORT_HEADERS_PKG

Source


1 PACKAGE BODY AP_EXPENSE_REPORT_HEADERS_PKG as
2 /* $Header: apixxrhb.pls 120.5 2005/11/16 07:18:23 srinvenk ship $ */
3 
4   PROCEDURE Insert_Row(X_Rowid                   IN OUT NOCOPY VARCHAR2,
5 
6                        X_Report_Header_Id               NUMBER,
7                        X_Employee_Id                    NUMBER DEFAULT NULL,
8                        X_Week_End_Date                  DATE,
9                        X_Creation_Date                  DATE,
10                        X_Created_By                     NUMBER,
11                        X_Last_Update_Date               DATE,
12                        X_Last_Updated_By                NUMBER,
13                        X_Vouchno                        NUMBER,
14                        X_Total                          NUMBER,
15                        X_Vendor_Id                      NUMBER DEFAULT NULL,
16                        X_Vendor_Site_Id                 NUMBER DEFAULT NULL,
17                        X_Expense_Check_Address_Flag     VARCHAR2 DEFAULT NULL,
18                        X_Reference_1                    NUMBER DEFAULT NULL,
19                        X_Reference_2                    VARCHAR2 DEFAULT NULL,
20                        X_Invoice_Num                    VARCHAR2 DEFAULT NULL,
21                        X_Expense_Report_Id              NUMBER DEFAULT NULL,
22                        X_Accts_Pay_Code_Combinat_Id     NUMBER DEFAULT NULL,
23                        X_Set_Of_Books_Id                NUMBER DEFAULT NULL,
24                        X_Source                         VARCHAR2 DEFAULT NULL,
25                        X_Purgeable_Flag                 VARCHAR2 DEFAULT NULL,
26                        X_Accounting_Date                DATE DEFAULT NULL,
27                        X_Employee_Ccid                  NUMBER DEFAULT NULL,
28                        X_Description                    VARCHAR2 DEFAULT NULL,
29                        X_Reject_Code                    VARCHAR2 DEFAULT NULL,
30                        X_Hold_Lookup_Code               VARCHAR2 DEFAULT NULL,
31                        X_Attribute_Category             VARCHAR2 DEFAULT NULL,
32                        X_Attribute1                     VARCHAR2 DEFAULT NULL,
33                        X_Attribute2                     VARCHAR2 DEFAULT NULL,
34                        X_Attribute3                     VARCHAR2 DEFAULT NULL,
35                        X_Attribute4                     VARCHAR2 DEFAULT NULL,
36                        X_Attribute5                     VARCHAR2 DEFAULT NULL,
37                        X_Default_Currency_Code          VARCHAR2,
38                        X_Default_Exchange_Rate_Type     VARCHAR2 DEFAULT NULL,
39                        X_Default_Exchange_Rate          NUMBER DEFAULT NULL,
40                        X_Default_Exchange_Date          DATE DEFAULT NULL,
41 		       		   X_Payment_Currency_Code          VARCHAR2,
42                        X_Payment_Cross_Rate_Type        VARCHAR2,
43                        X_Payment_Cross_Rate_Date        DATE,
44                        X_Payment_Cross_Rate             NUMBER,
45 		       		   X_Apply_Advances_Flag			VARCHAR2,
46 		       		   X_Prepay_Num						VARCHAR2,
47 		       		   X_Prepay_Dist_Num				NUMBER,
48 		       		   X_Maximum_Amount_To_Apply		NUMBER,
49 		       		   X_Prepay_Gl_Date					DATE,
50 					   X_Advance_Invoice_To_Apply		NUMBER DEFAULT NULL,
51                        X_Last_Update_Login              NUMBER DEFAULT NULL,
52                        X_Voucher_Num                    VARCHAR2 DEFAULT NULL,
53                        X_Attribute11                    VARCHAR2 DEFAULT NULL,
54                        X_Attribute12                    VARCHAR2 DEFAULT NULL,
55                        X_Attribute13                    VARCHAR2 DEFAULT NULL,
56                        X_Attribute14                    VARCHAR2 DEFAULT NULL,
57                        X_Attribute6                     VARCHAR2 DEFAULT NULL,
58                        X_Attribute7                     VARCHAR2 DEFAULT NULL,
59                        X_Attribute8                     VARCHAR2 DEFAULT NULL,
60                        X_Attribute9                     VARCHAR2 DEFAULT NULL,
61                        X_Attribute10                    VARCHAR2 DEFAULT NULL,
62                        X_Attribute15                    VARCHAR2 DEFAULT NULL,
63                        X_Doc_Category_Code              VARCHAR2 DEFAULT NULL,
64                        X_Awt_Group_Id                   NUMBER DEFAULT NULL,
65                        X_Org_Id                         NUMBER DEFAULT NULL,
66                        X_Workflow_Approved_Flag         VARCHAR2 DEFAULT NULL,
67         	       X_global_attribute_category	VARCHAR2 DEFAULT NULL,
68         	       X_global_attribute1		VARCHAR2 DEFAULT NULL,
69         	       X_global_attribute2              VARCHAR2 DEFAULT NULL,
70         	       X_global_attribute3              VARCHAR2 DEFAULT NULL,
71         	       X_global_attribute4              VARCHAR2 DEFAULT NULL,
72         	       X_global_attribute5              VARCHAR2 DEFAULT NULL,
73         	       X_global_attribute6              VARCHAR2 DEFAULT NULL,
74         	       X_global_attribute7              VARCHAR2 DEFAULT NULL,
75         	       X_global_attribute8              VARCHAR2 DEFAULT NULL,
76         	       X_global_attribute9              VARCHAR2 DEFAULT NULL,
77         	       X_global_attribute10             VARCHAR2 DEFAULT NULL,
78         	       X_global_attribute11             VARCHAR2 DEFAULT NULL,
79         	       X_global_attribute12             VARCHAR2 DEFAULT NULL,
80         	       X_global_attribute13             VARCHAR2 DEFAULT NULL,
81         	       X_global_attribute14             VARCHAR2 DEFAULT NULL,
82         	       X_global_attribute15             VARCHAR2 DEFAULT NULL,
83         	       X_global_attribute16             VARCHAR2 DEFAULT NULL,
84         	       X_global_attribute17             VARCHAR2 DEFAULT NULL,
85         	       X_global_attribute18             VARCHAR2 DEFAULT NULL,
86         	       X_global_attribute19             VARCHAR2 DEFAULT NULL,
87         	       X_global_attribute20             VARCHAR2 DEFAULT NULL,
88 		       X_calling_sequence	IN	VARCHAR2
89   ) IS
90     CURSOR C IS SELECT rowid FROM AP_EXPENSE_REPORT_HEADERS
91                  WHERE report_header_id = X_Report_Header_Id;
92     current_calling_sequence    VARCHAR2(2000);
93     debug_info                  VARCHAR2(100);
94 
95    BEGIN
96 --     Update the calling sequence
97 --
98        current_calling_sequence := 'AP_EXPENSE_REPORT_HEADERS_PKG.INSERT_ROW<-' ||
99                                     X_calling_sequence;
100 
101        debug_info := 'Insert into AP_EXPENSE_REPORT_HEADERS';
102        INSERT INTO AP_EXPENSE_REPORT_HEADERS(
103 
104               report_header_id,
105               employee_id,
106               week_end_date,
107               creation_date,
108               created_by,
109               last_update_date,
110               last_updated_by,
111               vouchno,
112               total,
113               vendor_id,
114               vendor_site_id,
115               expense_check_address_flag,
116               reference_1,
117               reference_2,
118               invoice_num,
119               expense_report_id,
120               accts_pay_code_combination_id,
121               set_of_books_id,
122               source,
123               purgeable_flag,
124               accounting_date,
125               employee_ccid,
126               description,
127               reject_code,
128               hold_lookup_code,
129               attribute_category,
130               attribute1,
131               attribute2,
132               attribute3,
133               attribute4,
134               attribute5,
135               default_currency_code,
136               default_exchange_rate_type,
137               default_exchange_rate,
138               default_exchange_date,
139               payment_currency_code,
140               payment_cross_rate_type,
141               payment_cross_rate_date,
142               payment_cross_rate,
143 	      	  apply_advances_default,
144 	      	  prepay_num,
145 	      	  prepay_dist_num,
146 	      	  maximum_amount_to_apply,
147 	      	  prepay_gl_date,
148 			  advance_invoice_to_apply,
149               last_update_login,
150               voucher_num,
151               attribute11,
152               attribute12,
153               attribute13,
154               attribute14,
155               attribute6,
156               attribute7,
157               attribute8,
158               attribute9,
159               attribute10,
160               attribute15,
161               doc_category_code,
162               awt_group_id,
163               workflow_approved_flag,
164               global_attribute_category,
165               global_attribute1,
166               global_attribute2,
167               global_attribute3,
168               global_attribute4,
169               global_attribute5,
170               global_attribute6,
171               global_attribute7,
172               global_attribute8,
173               global_attribute9,
174               global_attribute10,
175               global_attribute11,
176               global_attribute12,
177               global_attribute13,
178               global_attribute14,
179               global_attribute15,
180               global_attribute16,
181               global_attribute17,
182               global_attribute18,
183               global_attribute19,
184               global_attribute20,
185               org_id
186              ) VALUES (
187 
188               X_Report_Header_Id,
189               X_Employee_Id,
190               X_Week_End_Date,
191               X_Creation_Date,
192               X_Created_By,
193               X_Last_Update_Date,
194               X_Last_Updated_By,
195               X_Vouchno,
196               X_Total,
197               X_Vendor_Id,
198               X_Vendor_Site_Id,
199               X_Expense_Check_Address_Flag,
200               X_Reference_1,
201               X_Reference_2,
202               X_Invoice_Num,
203               X_Expense_Report_Id,
204               X_Accts_Pay_Code_Combinat_Id,
205               X_Set_Of_Books_Id,
206               X_Source,
207               X_Purgeable_Flag,
208               X_Accounting_Date,
209               X_Employee_Ccid,
210               X_Description,
211               X_Reject_Code,
212               X_Hold_Lookup_Code,
213               X_Attribute_Category,
214               X_Attribute1,
215               X_Attribute2,
216               X_Attribute3,
217               X_Attribute4,
218               X_Attribute5,
219               X_Default_Currency_Code,
220               X_Default_Exchange_Rate_Type,
221               X_Default_Exchange_Rate,
222               X_Default_Exchange_Date,
223               X_Payment_Currency_Code,
224               X_Payment_Cross_Rate_Type,
225               X_Payment_Cross_Rate_Date,
226               X_Payment_Cross_Rate,
227 	      	  X_Apply_Advances_flag,
228 	          X_Prepay_Num,
229 	      	  X_Prepay_Dist_Num,
230 	      	  X_Maximum_Amount_To_Apply,
231 	      	  X_Prepay_Gl_Date,
232 			  X_Advance_Invoice_To_Apply,
233               X_Last_Update_Login,
234               X_Voucher_Num,
235               X_Attribute11,
236               X_Attribute12,
237               X_Attribute13,
238               X_Attribute14,
239               X_Attribute6,
240               X_Attribute7,
241               X_Attribute8,
242               X_Attribute9,
243               X_Attribute10,
244               X_Attribute15,
245               X_Doc_Category_Code,
246               X_Awt_Group_Id,
247               X_Workflow_Approved_Flag,
248               X_global_attribute_category,
249               X_global_attribute1,
250               X_global_attribute2,
251               X_global_attribute3,
252               X_global_attribute4,
253               X_global_attribute5,
254               X_global_attribute6,
255               X_global_attribute7,
256               X_global_attribute8,
257               X_global_attribute9,
258               X_global_attribute10,
259               X_global_attribute11,
260               X_global_attribute12,
261               X_global_attribute13,
262               X_global_attribute14,
263               X_global_attribute15,
264               X_global_attribute16,
265               X_global_attribute17,
266               X_global_attribute18,
267               X_global_attribute19,
268               X_global_attribute20,
269               X_org_id
270              );
271 
272     debug_info := 'Open cursor C';
273     OPEN C;
274     debug_info := 'Fetch cursor C';
275     FETCH C INTO X_Rowid;
276     if (C%NOTFOUND) then
277       debug_info := 'Close cursor C - DATA NOTFOUND';
278       CLOSE C;
279       Raise NO_DATA_FOUND;
280     end if;
281     debug_info := 'Close cursor C';
282     CLOSE C;
283 
284     EXCEPTION
285         WHEN OTHERS THEN
286            IF (SQLCODE <> -20001) THEN
287               FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
288               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
289               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
290               FND_MESSAGE.SET_TOKEN('PARAMETERS','REPORT_HEADER_ID = ' ||
291                                     X_Report_Header_Id);
292               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
293            END IF;
294            APP_EXCEPTION.RAISE_EXCEPTION;
295 
296   END Insert_Row;
297 
298 
299   PROCEDURE Lock_Row(X_Rowid                            VARCHAR2,
300                      X_Report_Header_Id                 NUMBER,
301                      X_Employee_Id                      NUMBER DEFAULT NULL,
302                      X_Week_End_Date                    DATE,
303                      X_Vouchno                          NUMBER,
304                      X_Total                            NUMBER,
305                      X_Vendor_Id                        NUMBER DEFAULT NULL,
306                      X_Vendor_Site_Id                   NUMBER DEFAULT NULL,
307                      X_Expense_Check_Address_Flag       VARCHAR2 DEFAULT NULL,
308                      X_Reference_1                      NUMBER DEFAULT NULL,
309                      X_Reference_2                      VARCHAR2 DEFAULT NULL,
310                      X_Invoice_Num                      VARCHAR2 DEFAULT NULL,
311                      X_Expense_Report_Id                NUMBER DEFAULT NULL,
312                      X_Accts_Pay_Code_Combinat_Id    NUMBER DEFAULT NULL,
313                      X_Set_Of_Books_Id                  NUMBER DEFAULT NULL,
314                      X_Source                           VARCHAR2 DEFAULT NULL,
315                      X_Purgeable_Flag                   VARCHAR2 DEFAULT NULL,
316                      X_Accounting_Date                  DATE DEFAULT NULL,
317                      X_Employee_Ccid                    NUMBER DEFAULT NULL,
318                      X_Description                      VARCHAR2 DEFAULT NULL,
319                      X_Reject_Code                      VARCHAR2 DEFAULT NULL,
320                      X_Hold_Lookup_Code                 VARCHAR2 DEFAULT NULL,
321                      X_Attribute_Category               VARCHAR2 DEFAULT NULL,
322                      X_Attribute1                       VARCHAR2 DEFAULT NULL,
323                      X_Attribute2                       VARCHAR2 DEFAULT NULL,
324                      X_Attribute3                       VARCHAR2 DEFAULT NULL,
325                      X_Attribute4                       VARCHAR2 DEFAULT NULL,
326                      X_Attribute5                       VARCHAR2 DEFAULT NULL,
327                      X_Default_Currency_Code            VARCHAR2,
328                      X_Default_Exchange_Rate_Type       VARCHAR2 DEFAULT NULL,
329                      X_Default_Exchange_Rate            NUMBER DEFAULT NULL,
330                      X_Default_Exchange_Date            DATE DEFAULT NULL,
331                      X_Payment_Currency_Code            VARCHAR2,
332                      X_Payment_Cross_Rate_Type          VARCHAR2,
333                      X_Payment_Cross_Rate_Date          DATE,
334                      X_Payment_Cross_Rate               NUMBER,
335 		     		 X_Apply_Advances_Flag				VARCHAR2,
336 		     		 X_Prepay_Num						VARCHAR2,
337 					 X_Prepay_Dist_Num          		NUMBER,
338 					 X_Maximum_Amount_To_Apply			NUMBER,
339 					 X_Prepay_Gl_Date           		DATE,
343                      X_Attribute12                      VARCHAR2 DEFAULT NULL,
340 					 X_Advance_Invoice_To_Apply			NUMBER DEFAULT NULL,
341                      X_Voucher_Num                      VARCHAR2 DEFAULT NULL,
342                      X_Attribute11                      VARCHAR2 DEFAULT NULL,
344                      X_Attribute13                      VARCHAR2 DEFAULT NULL,
345                      X_Attribute14                      VARCHAR2 DEFAULT NULL,
346                      X_Attribute6                       VARCHAR2 DEFAULT NULL,
347                      X_Attribute7                       VARCHAR2 DEFAULT NULL,
348                      X_Attribute8                       VARCHAR2 DEFAULT NULL,
349                      X_Attribute9                       VARCHAR2 DEFAULT NULL,
350                      X_Attribute10                      VARCHAR2 DEFAULT NULL,
351                      X_Attribute15                      VARCHAR2 DEFAULT NULL,
352                      X_Doc_Category_Code                VARCHAR2 DEFAULT NULL,
353                      X_Awt_Group_Id                     NUMBER DEFAULT NULL,
354                      X_Org_Id                           NUMBER DEFAULT NULL,
355                      X_Workflow_Approved_Flag           VARCHAR2 DEFAULT NULL,
356                      X_global_attribute_category        VARCHAR2 DEFAULT NULL,
357                      X_global_attribute1                VARCHAR2 DEFAULT NULL,
358                      X_global_attribute2                VARCHAR2 DEFAULT NULL,
359                      X_global_attribute3                VARCHAR2 DEFAULT NULL,
360                      X_global_attribute4                VARCHAR2 DEFAULT NULL,
361                      X_global_attribute5                VARCHAR2 DEFAULT NULL,
362                      X_global_attribute6                VARCHAR2 DEFAULT NULL,
363                      X_global_attribute7                VARCHAR2 DEFAULT NULL,
364                      X_global_attribute8                VARCHAR2 DEFAULT NULL,
365                      X_global_attribute9                VARCHAR2 DEFAULT NULL,
366                      X_global_attribute10               VARCHAR2 DEFAULT NULL,
367                      X_global_attribute11               VARCHAR2 DEFAULT NULL,
368                      X_global_attribute12               VARCHAR2 DEFAULT NULL,
369                      X_global_attribute13               VARCHAR2 DEFAULT NULL,
370                      X_global_attribute14               VARCHAR2 DEFAULT NULL,
371                      X_global_attribute15               VARCHAR2 DEFAULT NULL,
372                      X_global_attribute16               VARCHAR2 DEFAULT NULL,
373                      X_global_attribute17               VARCHAR2 DEFAULT NULL,
374                      X_global_attribute18               VARCHAR2 DEFAULT NULL,
375                      X_global_attribute19               VARCHAR2 DEFAULT NULL,
376                      X_global_attribute20               VARCHAR2 DEFAULT NULL,
377 		     X_calling_sequence		IN	VARCHAR2
378   ) IS
379     CURSOR C IS
380         SELECT *
381         FROM   AP_EXPENSE_REPORT_HEADERS
382         WHERE  rowid = X_Rowid
383         FOR UPDATE of Report_Header_Id NOWAIT;
384     Recinfo C%ROWTYPE;
385 
386     current_calling_sequence    VARCHAR2(2000);
387     debug_info                  VARCHAR2(100);
388 
389   BEGIN
390 --  Update the calling sequence
391 --
392     current_calling_sequence := 'AP_EXPENSE_REPORT_HEADERS_PKG.LOCK_ROW<-' ||
393                                  X_calling_sequence;
394     debug_info := 'Open cursor C';
395     OPEN C;
396     debug_info := 'Fetch cursor C';
397     FETCH C INTO Recinfo;
398     if (C%NOTFOUND) then
399       debug_info := 'Close cursor C - DATA NOTFOUND';
400       CLOSE C;
401       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
402       APP_EXCEPTION.Raise_Exception;
403     end if;
404     debug_info := 'Close cursor C';
405     CLOSE C;
406     if (
407 
408                (Recinfo.report_header_id =  X_Report_Header_Id)
409            AND (   (Recinfo.employee_id =  X_Employee_Id)
410                 OR (    (Recinfo.employee_id IS NULL)
411                     AND (X_Employee_Id IS NULL)))
412            AND (Recinfo.week_end_date =  X_Week_End_Date)
413            AND (Recinfo.vouchno =  X_Vouchno)
414            AND (Recinfo.total =  X_Total)
415            AND (   (Recinfo.vendor_id =  X_Vendor_Id)
416                 OR (    (Recinfo.vendor_id IS NULL)
417                     AND (X_Vendor_Id IS NULL)))
418            AND (   (Recinfo.vendor_site_id =  X_Vendor_Site_Id)
419                 OR (    (Recinfo.vendor_site_id IS NULL)
420                     AND (X_Vendor_Site_Id IS NULL)))
421            AND (   (Recinfo.expense_check_address_flag = X_Expense_Check_Address_Flag)
422                 OR (    (Recinfo.expense_check_address_flag IS NULL)
423                     AND (X_Expense_Check_Address_Flag IS NULL)))
424            AND (   (Recinfo.reference_1 =  X_Reference_1)
425                 OR (    (Recinfo.reference_1 IS NULL)
426                     AND (X_Reference_1 IS NULL)))
427            AND (   (Recinfo.reference_2 =  X_Reference_2)
428                 OR (    (Recinfo.reference_2 IS NULL)
429                     AND (X_Reference_2 IS NULL)))
430            AND (   (Recinfo.invoice_num =  X_Invoice_Num)
431                 OR (    (Recinfo.invoice_num IS NULL)
432                     AND (X_Invoice_Num IS NULL)))
433            AND (   (Recinfo.expense_report_id =  X_Expense_Report_Id)
434                 OR (    (Recinfo.expense_report_id IS NULL)
435                     AND (X_Expense_Report_Id IS NULL)))
436            AND (   (Recinfo.accts_pay_code_combination_id =  X_Accts_Pay_Code_Combinat_Id)
440                 OR (    (Recinfo.set_of_books_id IS NULL)
437                 OR (    (Recinfo.accts_pay_code_combination_id IS NULL)
438                     AND (X_Accts_Pay_Code_Combinat_Id IS NULL)))
439            AND (   (Recinfo.set_of_books_id =  X_Set_Of_Books_Id)
441                     AND (X_Set_Of_Books_Id IS NULL)))
442            AND (   (Recinfo.source =  X_Source)
443                 OR (    (Recinfo.source IS NULL)
444                     AND (X_Source IS NULL)))
445            AND (   (Recinfo.purgeable_flag =  X_Purgeable_Flag)
446                 OR (    (Recinfo.purgeable_flag IS NULL)
447                     AND (X_Purgeable_Flag IS NULL)))
448            AND (   (Recinfo.accounting_date =  X_Accounting_Date)
449                 OR (    (Recinfo.accounting_date IS NULL)
450                     AND (X_Accounting_Date IS NULL)))
451            AND (   (Recinfo.employee_ccid =  X_Employee_Ccid)
452                 OR (    (Recinfo.employee_ccid IS NULL)
453                     AND (X_Employee_Ccid IS NULL)))
454            AND (   (Recinfo.description =  X_Description)
455                 OR (    (Recinfo.description IS NULL)
456                     AND (X_Description IS NULL)))
457            AND (   (Recinfo.reject_code =  X_Reject_Code)
458                 OR (    (Recinfo.reject_code IS NULL)
459                     AND (X_Reject_Code IS NULL)))
460            AND (   (Recinfo.hold_lookup_code =  X_Hold_Lookup_Code)
461                 OR (    (Recinfo.hold_lookup_code IS NULL)
462                     AND (X_Hold_Lookup_Code IS NULL)))
463            AND (   (Recinfo.attribute_category =  X_Attribute_Category)
464                 OR (    (Recinfo.attribute_category IS NULL)
465                     AND (X_Attribute_Category IS NULL)))
466            AND (   (Recinfo.attribute1 =  X_Attribute1)
467                 OR (    (Recinfo.attribute1 IS NULL)
468                     AND (X_Attribute1 IS NULL)))
469            AND (   (Recinfo.attribute2 =  X_Attribute2)
470                 OR (    (Recinfo.attribute2 IS NULL)
471                     AND (X_Attribute2 IS NULL)))
472            AND (   (Recinfo.attribute3 =  X_Attribute3)
473                 OR (    (Recinfo.attribute3 IS NULL)
474                     AND (X_Attribute3 IS NULL)))
475            AND (   (Recinfo.attribute4 =  X_Attribute4)
476                 OR (    (Recinfo.attribute4 IS NULL)
477                     AND (X_Attribute4 IS NULL)))
478            AND (   (Recinfo.attribute5 =  X_Attribute5)
479                 OR (    (Recinfo.attribute5 IS NULL)
480                     AND (X_Attribute5 IS NULL)))
481            AND (Recinfo.default_currency_code =  X_Default_Currency_Code)
482            AND (   (Recinfo.default_exchange_rate_type =  X_Default_Exchange_Rate_Type)
483                 OR (    (Recinfo.default_exchange_rate_type IS NULL)
484                     AND (X_Default_Exchange_Rate_Type IS NULL)))
485            AND (   (Recinfo.default_exchange_rate =  X_Default_Exchange_Rate)
486                 OR (    (Recinfo.default_exchange_rate IS NULL)
487                     AND (X_Default_Exchange_Rate IS NULL)))
488            AND (   (Recinfo.default_exchange_date =  X_Default_Exchange_Date)
489                 OR (    (Recinfo.default_exchange_date IS NULL)
490                     AND (X_Default_Exchange_Date IS NULL)))
491            AND (   (Recinfo.Payment_currency_code =  X_Payment_Currency_Code)
492                 OR (    (Recinfo.Payment_currency_code IS NULL)
493                     AND (X_Payment_Currency_Code IS NULL)))
494            AND (   (Recinfo.payment_cross_rate_type =  X_Payment_Cross_Rate_Type)
495                 OR (    (Recinfo.payment_cross_rate_type IS NULL)
496                     AND (X_Payment_Cross_Rate_Type IS NULL)))
497            AND (   (Recinfo.Payment_Cross_rate =  X_Payment_Cross_Rate)
498                 OR (    (Recinfo.payment_cross_rate IS NULL)
499                     AND (X_Payment_Cross_Rate IS NULL)))
500            AND (   (Recinfo.payment_cross_rate_date =  X_Payment_Cross_Rate_Date)
501                 OR (    (Recinfo.payment_cross_rate_date IS NULL)
502                     AND (X_Payment_Cross_Rate_Date IS NULL)))
503 	   AND (   (Recinfo.apply_advances_default =  X_Apply_Advances_Flag)
504                 OR (    (Recinfo.apply_advances_default IS NULL)
505                     AND (X_Apply_Advances_Flag IS NULL)))
506 	   AND (   (Recinfo.prepay_num =  X_Prepay_Num)
507                 OR (    (Recinfo.prepay_num IS NULL)
508                     AND (X_Prepay_Num IS NULL)))
509 	   AND (   (Recinfo.prepay_dist_num =  X_Prepay_Dist_Num)
510                 OR (    (Recinfo.prepay_dist_num IS NULL)
511                     AND (X_Prepay_Dist_Num IS NULL)))
512 	   AND (   (Recinfo.maximum_amount_to_apply =  X_Maximum_Amount_To_Apply)
513                 OR (    (Recinfo.maximum_amount_to_apply IS NULL)
514                     AND (X_Maximum_Amount_To_Apply IS NULL)))
515 	   AND (   (Recinfo.prepay_gl_date =  X_Prepay_Gl_Date)
516                 OR (    (Recinfo.prepay_gl_date IS NULL)
517                     AND (X_Prepay_Gl_Date IS NULL)))
518 	   AND (	(Recinfo.advance_invoice_to_apply = X_Advance_Invoice_To_Apply)
519 				OR ( (Recinfo.advance_invoice_to_apply IS NULL)
520 					AND (X_Advance_Invoice_To_Apply IS NULL)))
521            AND (   (Recinfo.voucher_num =  X_Voucher_Num)
522                 OR (    (Recinfo.voucher_num IS NULL)
523                     AND (X_Voucher_Num IS NULL)))
524            AND (   (Recinfo.attribute11 =  X_Attribute11)
525                 OR (    (Recinfo.attribute11 IS NULL)
526                     AND (X_Attribute11 IS NULL)))
527            AND (   (Recinfo.attribute12 =  X_Attribute12)
528                 OR (    (Recinfo.attribute12 IS NULL)
532                     AND (X_Attribute13 IS NULL)))
529                     AND (X_Attribute12 IS NULL)))
530            AND (   (Recinfo.attribute13 =  X_Attribute13)
531                 OR (    (Recinfo.attribute13 IS NULL)
533            AND (   (Recinfo.attribute14 =  X_Attribute14)
534                 OR (    (Recinfo.attribute14 IS NULL)
535                     AND (X_Attribute14 IS NULL)))
536            AND (   (Recinfo.attribute6 =  X_Attribute6)
537                 OR (    (Recinfo.attribute6 IS NULL)
538                     AND (X_Attribute6 IS NULL)))
539            AND (   (Recinfo.attribute7 =  X_Attribute7)
540                 OR (    (Recinfo.attribute7 IS NULL)
541                     AND (X_Attribute7 IS NULL)))
542            AND (   (Recinfo.attribute8 =  X_Attribute8)
543                 OR (    (Recinfo.attribute8 IS NULL)
544                     AND (X_Attribute8 IS NULL)))
545            AND (   (Recinfo.attribute9 =  X_Attribute9)
546                 OR (    (Recinfo.attribute9 IS NULL)
547                     AND (X_Attribute9 IS NULL)))
548            AND (   (Recinfo.attribute10 =  X_Attribute10)
549                 OR (    (Recinfo.attribute10 IS NULL)
550                     AND (X_Attribute10 IS NULL)))
551            AND (   (Recinfo.attribute15 =  X_Attribute15)
552                 OR (    (Recinfo.attribute15 IS NULL)
553                     AND (X_Attribute15 IS NULL)))
554            AND (   (Recinfo.doc_category_code =  X_Doc_Category_Code)
555                 OR (    (Recinfo.doc_category_code IS NULL)
556                     AND (X_Doc_Category_Code IS NULL)))
557            AND (   (Recinfo.awt_group_id =  X_Awt_Group_Id)
558                 OR (    (Recinfo.awt_group_id IS NULL)
559                     AND (X_Awt_Group_Id IS NULL)))
560            AND (   (Recinfo.Workflow_approved_flag =  X_Workflow_approved_flag)
561                 OR (    (Recinfo.Workflow_approved_flag IS NULL)
562                     AND (X_Workflow_approved_flag IS NULL)))
563       ) then
564       null;
565     else
566       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
567       APP_EXCEPTION.Raise_Exception;
568     end if;
569 
570     if (
571                (   (Recinfo.global_attribute_category =  X_global_attribute_category)
572                 OR (    (Recinfo.global_attribute_category IS NULL)
573                     AND (X_global_attribute_category IS NULL)))
574            AND (   (Recinfo.global_attribute1 =  X_global_attribute1)
575                 OR (    (Recinfo.global_attribute1 IS NULL)
576                     AND (X_global_attribute1 IS NULL)))
577            AND (   (Recinfo.global_attribute2 =  X_global_attribute2)
578                 OR (    (Recinfo.global_attribute2 IS NULL)
579                     AND (X_global_attribute2 IS NULL)))
580            AND (   (Recinfo.global_attribute3 =  X_global_attribute3)
581                 OR (    (Recinfo.global_attribute3 IS NULL)
582                     AND (X_global_attribute3 IS NULL)))
583            AND (   (Recinfo.global_attribute4 =  X_global_attribute4)
584                 OR (    (Recinfo.global_attribute4 IS NULL)
585                     AND (X_global_attribute4 IS NULL)))
586            AND (   (Recinfo.global_attribute5 =  X_global_attribute5)
587                 OR (    (Recinfo.global_attribute5 IS NULL)
588                     AND (X_global_attribute5 IS NULL)))
589            AND (   (Recinfo.global_attribute6 =  X_global_attribute6)
590                 OR (    (Recinfo.global_attribute6 IS NULL)
591                     AND (X_global_attribute6 IS NULL)))
592            AND (   (Recinfo.global_attribute7 =  X_global_attribute7)
593                 OR (    (Recinfo.global_attribute7 IS NULL)
594                     AND (X_global_attribute7 IS NULL)))
595            AND (   (Recinfo.global_attribute8 =  X_global_attribute8)
596                 OR (    (Recinfo.global_attribute8 IS NULL)
597                     AND (X_global_attribute8 IS NULL)))
598            AND (   (Recinfo.global_attribute9 =  X_global_attribute9)
599                 OR (    (Recinfo.global_attribute9 IS NULL)
600                     AND (X_global_attribute9 IS NULL)))
601            AND (   (Recinfo.global_attribute10 =  X_global_attribute10)
602                 OR (    (Recinfo.global_attribute10 IS NULL)
603                     AND (X_global_attribute10 IS NULL)))
604            AND (   (Recinfo.global_attribute11 =  X_global_attribute11)
605                 OR (    (Recinfo.global_attribute11 IS NULL)
606                     AND (X_global_attribute11 IS NULL)))
607            AND (   (Recinfo.global_attribute12 =  X_global_attribute12)
608                 OR (    (Recinfo.global_attribute12 IS NULL)
609                     AND (X_global_attribute12 IS NULL)))
610            AND (   (Recinfo.global_attribute13 =  X_global_attribute13)
611                 OR (    (Recinfo.global_attribute13 IS NULL)
612                     AND (X_global_attribute13 IS NULL)))
613            AND (   (Recinfo.global_attribute14 =  X_global_attribute14)
614                 OR (    (Recinfo.global_attribute14 IS NULL)
615                     AND (X_global_attribute14 IS NULL)))
616            AND (   (Recinfo.global_attribute15 =  X_global_attribute15)
617                 OR (    (Recinfo.global_attribute15 IS NULL)
618                     AND (X_global_attribute15 IS NULL)))
619            AND (   (Recinfo.global_attribute16 =  X_global_attribute16)
620                 OR (    (Recinfo.global_attribute16 IS NULL)
621                     AND (X_global_attribute16 IS NULL)))
622            AND (   (Recinfo.global_attribute17 =  X_global_attribute17)
623                 OR (    (Recinfo.global_attribute17 IS NULL)
624                     AND (X_global_attribute17 IS NULL)))
628            AND (   (Recinfo.global_attribute19 =  X_global_attribute19)
625            AND (   (Recinfo.global_attribute18 =  X_global_attribute18)
626                 OR (    (Recinfo.global_attribute18 IS NULL)
627                     AND (X_global_attribute18 IS NULL)))
629                 OR (    (Recinfo.global_attribute19 IS NULL)
630                     AND (X_global_attribute19 IS NULL)))
631            AND (   (Recinfo.global_attribute20 =  X_global_attribute20)
632                 OR (    (Recinfo.global_attribute20 IS NULL)
633                     AND (X_global_attribute20 IS NULL)))
634       ) then
635       return;
636     else
637       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
638       APP_EXCEPTION.Raise_Exception;
639     end if;
640 
641     EXCEPTION
642        WHEN OTHERS THEN
643          IF (SQLCODE <> -20001) THEN
644            IF (SQLCODE = -54) THEN
645              FND_MESSAGE.SET_NAME('SQLAP','AP_RESOURCE_BUSY');
646            ELSE
647              FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
648              FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
649              FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
650              FND_MESSAGE.SET_TOKEN('PARAMETERS','REPORT_HEADER_ID = ' ||
651                                    X_Report_Header_Id);
652              FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
653            END IF;
654 	 END IF;
655          APP_EXCEPTION.RAISE_EXCEPTION;
656 
657   END Lock_Row;
658 
659 
660 
661   PROCEDURE Update_Row(X_Rowid                          VARCHAR2,
662                        X_Report_Header_Id               NUMBER,
663                        X_Employee_Id                    NUMBER DEFAULT NULL,
664                        X_Week_End_Date                  DATE,
665                        X_Last_Update_Date               DATE,
666                        X_Last_Updated_By                NUMBER,
667                        X_Vouchno                        NUMBER,
668                        X_Total                          NUMBER,
669                        X_Vendor_Id                      NUMBER DEFAULT NULL,
670                        X_Vendor_Site_Id                 NUMBER DEFAULT NULL,
671                        X_Expense_Check_Address_Flag     VARCHAR2 DEFAULT NULL,
672                        X_Reference_1                    NUMBER DEFAULT NULL,
673                        X_Reference_2                    VARCHAR2 DEFAULT NULL,
674                        X_Invoice_Num                    VARCHAR2 DEFAULT NULL,
675                        X_Expense_Report_Id              NUMBER DEFAULT NULL,
676                        X_Accts_Pay_Code_Combinat_Id  NUMBER DEFAULT NULL,
677                        X_Set_Of_Books_Id                NUMBER DEFAULT NULL,
678                        X_Source                         VARCHAR2 DEFAULT NULL,
679                        X_Purgeable_Flag                 VARCHAR2 DEFAULT NULL,
680                        X_Accounting_Date                DATE DEFAULT NULL,
681                        X_Employee_Ccid                  NUMBER DEFAULT NULL,
682                        X_Description                    VARCHAR2 DEFAULT NULL,
683                        X_Reject_Code                    VARCHAR2 DEFAULT NULL,
684                        X_Hold_Lookup_Code               VARCHAR2 DEFAULT NULL,
685                        X_Attribute_Category             VARCHAR2 DEFAULT NULL,
686                        X_Attribute1                     VARCHAR2 DEFAULT NULL,
687                        X_Attribute2                     VARCHAR2 DEFAULT NULL,
688                        X_Attribute3                     VARCHAR2 DEFAULT NULL,
689                        X_Attribute4                     VARCHAR2 DEFAULT NULL,
690                        X_Attribute5                     VARCHAR2 DEFAULT NULL,
691                        X_Default_Currency_Code          VARCHAR2,
692                        X_Default_Exchange_Rate_Type     VARCHAR2 DEFAULT NULL,
693                        X_Default_Exchange_Rate          NUMBER DEFAULT NULL,
694                        X_Default_Exchange_Date          DATE DEFAULT NULL,
695                        X_Payment_Currency_Code         VARCHAR2,
696                        X_Payment_Cross_Rate_Type        VARCHAR2,
697                        X_Payment_Cross_Rate_Date        DATE,
698                        X_Payment_Cross_Rate             NUMBER,
699 		       		   X_Apply_Advances_Flag			VARCHAR2,
700 		       		   X_Prepay_Num						VARCHAR2,
701 		       		   X_Prepay_Dist_Num				NUMBER,
702 		       		   X_Maximum_Amount_To_Apply		NUMBER,
703 		       		   X_Prepay_Gl_Date					DATE,
704 					   X_Advance_Invoice_To_Apply		NUMBER DEFAULT NULL,
705                        X_Last_Update_Login              NUMBER DEFAULT NULL,
706                        X_Voucher_Num                    VARCHAR2 DEFAULT NULL,
707                        X_Attribute11                    VARCHAR2 DEFAULT NULL,
708                        X_Attribute12                    VARCHAR2 DEFAULT NULL,
709                        X_Attribute13                    VARCHAR2 DEFAULT NULL,
710                        X_Attribute14                    VARCHAR2 DEFAULT NULL,
711                        X_Attribute6                     VARCHAR2 DEFAULT NULL,
712                        X_Attribute7                     VARCHAR2 DEFAULT NULL,
713                        X_Attribute8                     VARCHAR2 DEFAULT NULL,
714                        X_Attribute9                     VARCHAR2 DEFAULT NULL,
715                        X_Attribute10                    VARCHAR2 DEFAULT NULL,
716                        X_Attribute15                    VARCHAR2 DEFAULT NULL,
720                        X_Workflow_Approved_Flag         VARCHAR2 DEFAULT NULL,
717                        X_Doc_Category_Code              VARCHAR2 DEFAULT NULL,
718                        X_Awt_Group_Id                   NUMBER DEFAULT NULL,
719                        X_Org_Id                         NUMBER DEFAULT NULL,
721                        X_global_attribute_category      VARCHAR2 DEFAULT NULL,
722                        X_global_attribute1              VARCHAR2 DEFAULT NULL,
723                        X_global_attribute2              VARCHAR2 DEFAULT NULL,
724                        X_global_attribute3              VARCHAR2 DEFAULT NULL,
725                        X_global_attribute4              VARCHAR2 DEFAULT NULL,
726                        X_global_attribute5              VARCHAR2 DEFAULT NULL,
727                        X_global_attribute6              VARCHAR2 DEFAULT NULL,
728                        X_global_attribute7              VARCHAR2 DEFAULT NULL,
729                        X_global_attribute8              VARCHAR2 DEFAULT NULL,
730                        X_global_attribute9              VARCHAR2 DEFAULT NULL,
731                        X_global_attribute10             VARCHAR2 DEFAULT NULL,
732                        X_global_attribute11             VARCHAR2 DEFAULT NULL,
733                        X_global_attribute12             VARCHAR2 DEFAULT NULL,
734                        X_global_attribute13             VARCHAR2 DEFAULT NULL,
735                        X_global_attribute14             VARCHAR2 DEFAULT NULL,
736                        X_global_attribute15             VARCHAR2 DEFAULT NULL,
737                        X_global_attribute16             VARCHAR2 DEFAULT NULL,
738                        X_global_attribute17             VARCHAR2 DEFAULT NULL,
739                        X_global_attribute18             VARCHAR2 DEFAULT NULL,
740                        X_global_attribute19             VARCHAR2 DEFAULT NULL,
741                        X_global_attribute20             VARCHAR2 DEFAULT NULL,
742 		       X_calling_sequence	IN	VARCHAR2
743 
744   ) IS
745     current_calling_sequence    VARCHAR2(2000);
746     debug_info                  VARCHAR2(100);
747   BEGIN
748 --  Update the calling sequence
749 --
750     current_calling_sequence := 'AP_EXPENSE_REPORT_HEADERS_PKG.UPDATE_ROW<-' ||
751                                  X_calling_sequence;
752     debug_info := 'Update AP_EXPENSE_REPORT_HEADERS';
753     UPDATE AP_EXPENSE_REPORT_HEADERS
754     SET
755        report_header_id                =     X_Report_Header_Id,
756        employee_id                     =     X_Employee_Id,
757        week_end_date                   =     X_Week_End_Date,
758        last_update_date                =     X_Last_Update_Date,
759        last_updated_by                 =     X_Last_Updated_By,
760        vouchno                         =     X_Vouchno,
761        total                           =     X_Total,
762        vendor_id                       =     X_Vendor_Id,
763        vendor_site_id                  =     X_Vendor_Site_Id,
764        expense_check_address_flag      =     X_Expense_Check_Address_Flag,
765        reference_1                     =     X_Reference_1,
766        reference_2                     =     X_Reference_2,
767        invoice_num                     =     X_Invoice_Num,
768        expense_report_id               =     X_Expense_Report_Id,
769        accts_pay_code_combination_id   =     X_Accts_Pay_Code_Combinat_Id,
770        set_of_books_id                 =     X_Set_Of_Books_Id,
771        source                          =     X_Source,
772        purgeable_flag                  =     X_Purgeable_Flag,
773        accounting_date                 =     X_Accounting_Date,
774        employee_ccid                   =     X_Employee_Ccid,
775        description                     =     X_Description,
776        reject_code                     =     X_Reject_Code,
777        hold_lookup_code                =     X_Hold_Lookup_Code,
778        attribute_category              =     X_Attribute_Category,
779        attribute1                      =     X_Attribute1,
780        attribute2                      =     X_Attribute2,
781        attribute3                      =     X_Attribute3,
782        attribute4                      =     X_Attribute4,
783        attribute5                      =     X_Attribute5,
784        default_currency_code           =     X_Default_Currency_Code,
785        default_exchange_rate_type      =     X_Default_Exchange_Rate_Type,
786        default_exchange_rate           =     X_Default_Exchange_Rate,
787        default_exchange_date           =     X_Default_Exchange_Date,
788        payment_currency_code           =     X_Payment_Currency_Code,
789        payment_cross_rate_type         =     X_Payment_Cross_Rate_Type,
790        payment_cross_rate_date         =     X_Payment_Cross_Rate_Date,
791        payment_cross_rate              =     X_Payment_Cross_Rate,
792    	   apply_advances_default	       =     X_Apply_Advances_Flag,
793        prepay_num		       		   =     X_Prepay_Num,
794        prepay_dist_num		       	   =     X_Prepay_Dist_Num,
795        maximum_amount_to_apply	       =     X_Maximum_Amount_To_Apply,
796        prepay_gl_date		       	   =     X_Prepay_Gl_Date,
797 	   advance_invoice_to_apply 	   = 	 X_Advance_Invoice_To_Apply,
798        last_update_login               =     X_Last_Update_Login,
799        voucher_num                     =     X_Voucher_Num,
800        attribute11                     =     X_Attribute11,
801        attribute12                     =     X_Attribute12,
802        attribute13                     =     X_Attribute13,
806        attribute8                      =     X_Attribute8,
803        attribute14                     =     X_Attribute14,
804        attribute6                      =     X_Attribute6,
805        attribute7                      =     X_Attribute7,
807        attribute9                      =     X_Attribute9,
808        attribute10                     =     X_Attribute10,
809        attribute15                     =     X_Attribute15,
810        doc_category_code               =     X_Doc_Category_Code,
811        awt_group_id                    =     X_Awt_Group_Id,
812        workflow_approved_flag          =     X_Workflow_Approved_Flag,
813        global_attribute_category       =     X_global_attribute_category,
814        global_attribute1               =     X_global_attribute1,
815        global_attribute2               =     X_global_attribute2,
816        global_attribute3               =     X_global_attribute3,
817        global_attribute4               =     X_global_attribute4,
818        global_attribute5               =     X_global_attribute5,
819        global_attribute6               =     X_global_attribute6,
820        global_attribute7               =     X_global_attribute7,
821        global_attribute8               =     X_global_attribute8,
822        global_attribute9               =     X_global_attribute9,
823        global_attribute10              =     X_global_attribute10,
824        global_attribute11              =     X_global_attribute11,
825        global_attribute12              =     X_global_attribute12,
826        global_attribute13              =     X_global_attribute13,
827        global_attribute14              =     X_global_attribute14,
828        global_attribute15              =     X_global_attribute15,
829        global_attribute16              =     X_global_attribute16,
830        global_attribute17              =     X_global_attribute17,
831        global_attribute18              =     X_global_attribute18,
832        global_attribute19              =     X_global_attribute19,
833        global_attribute20              =     X_global_attribute20
834     WHERE rowid = X_Rowid;
835 
836     if (SQL%NOTFOUND) then
837       Raise NO_DATA_FOUND;
838     end if;
839 
840     EXCEPTION
841         WHEN OTHERS THEN
842            IF (SQLCODE <> -20001) THEN
843               FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
844               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
845               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
846               FND_MESSAGE.SET_TOKEN('PARAMETERS','REPORT_HEADER_ID = ' ||
847                                     X_Report_Header_Id);
848               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
849            END IF;
850            APP_EXCEPTION.RAISE_EXCEPTION;
851 
852   END Update_Row;
853 
854   PROCEDURE Delete_Row(X_Rowid 				VARCHAR2,
855 		       X_calling_sequence	IN	VARCHAR2
856   ) IS
857     current_calling_sequence    VARCHAR2(2000);
858     debug_info                  VARCHAR2(100);
859   BEGIN
860 --  Update the calling sequence
861 --
862     current_calling_sequence := 'AP_EXPENSE_REPORT_HEADERS_PKG.DELETE_ROW<-' ||
863                                  X_calling_sequence;
864     debug_info := 'Delete from AP_EXPENSE_REPORT_HEADERS';
865     DELETE FROM AP_EXPENSE_REPORT_HEADERS
866     WHERE rowid = X_Rowid;
867 
868     if (SQL%NOTFOUND) then
869       Raise NO_DATA_FOUND;
870     end if;
871 
872     EXCEPTION
873         WHEN OTHERS THEN
874            IF (SQLCODE <> -20001) THEN
875               FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
876               FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
877               FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',current_calling_sequence);
878               FND_MESSAGE.SET_TOKEN('PARAMETERS','ROWID = ' || X_Rowid);
879               FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
880            END IF;
881            APP_EXCEPTION.RAISE_EXCEPTION;
882 
883   END Delete_Row;
884 
885 
886 END AP_EXPENSE_REPORT_HEADERS_PKG;