[Home] [Help]
PACKAGE BODY: APPS.PA_OTC_API
Source
1 Package Body Pa_Otc_Api As
2 -- $Header: PAXVOTCB.pls 120.18.12010000.6 2008/12/19 06:42:43 anuragar ship $
3
4 -- Package Variables
5
6 -- Used to indicate that last index point in the pl/sql detail attribute table that was accessed.
7 G_Detail_Attr_Index Binary_Integer := 0;
8
9 -- Used to indicate that last index point in the pl/sql old detail attribute table that was accessed.
10 G_Old_Detail_Attr_Index Binary_Integer := 0;
11
12 -- Stores the Timecard Scope BB_ID and BB_OVN and is used to populate in
13 G_Orig_Exp_Txn_Reference1 Pa_Expenditures_All.Orig_Exp_Txn_Reference1%TYPE := Null;
14
15 G_Time_BB_Id Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE := Null;
16
17 -- Used to indicate what was actually happening when unexpected error occurs.
18 G_Stage Varchar2(2000);
19
20 -- Used to indentify the path taken to the point on where an unexpected error occurs.
21 G_Path Varchar2(2000) := ' ';
22
23 -- These pl/sql table are used for flushing out procedure tables
24 G_Msg_Tokens_Table Pa_Otc_Api.Message_Tokens;
25
26 -- This pl/sql table stores a list of the expenditure_ending_dates and there associated batch_name
27 -- This pl/sql table is used during the Pre-Import phase of Trx Import
28 G_EndDateBatchName_Table Pa_Otc_Api.EndDateBatchName_Tab;
29
30 -- Used to store the binary_index for the pl/sql table records inserted into the interface table so that can speed up
31 -- the tieback process.
32 G_Trx_Inserted_Tab Pa_Otc_Api.Trx_Inserted_Table;
33
34 -- Used to store the binary_index for pl/sql table records that were directly updated. This is so that can speed up
35 -- the tieback process.
36 G_Trx_Direct_Upd_Tab Pa_Otc_Api.Trx_Inserted_Table;
37
38 -- Used as a check flag for the looping that is now been added in Trx Import for OTL. The flag is used within
39 -- the exception handler for Upload_Otc_Timecard() procedure.
40 G_Processed_Import_Batch Boolean := Null;
41
42 -- Global arrays for bulk insert into Trx Interface table
43 G_Txn_Interface_Id_Tbl Pa_Txn_Interface_Items_Pkg.Txn_Interface_Id_Typ;
44 G_Transaction_Source_Tbl Pa_Txn_Interface_Items_Pkg.Transaction_Source_Typ;
45 G_User_Transaction_Source_Tbl Pa_Txn_Interface_Items_Pkg.User_Transaction_Source_Typ;
46 G_Batch_Name_Tbl Pa_Txn_Interface_Items_Pkg.Batch_Name_Typ;
47 G_Expenditure_End_Date_Tbl Pa_Txn_Interface_Items_Pkg.Expenditure_End_Date_Typ;
48 G_Person_Bus_Grp_Name_Tbl Pa_Txn_Interface_Items_Pkg.Person_Business_Group_Name_Typ;
49 G_Person_Bus_Grp_Id_Tbl Pa_Txn_Interface_Items_Pkg.Person_Business_Group_Id_Typ;
50 G_Employee_Number_Tbl Pa_Txn_Interface_Items_Pkg.Employee_Number_Typ;
51 G_Person_Id_Tbl Pa_Txn_Interface_Items_Pkg.Person_Id_Typ;
52 G_Organization_Name_Tbl Pa_Txn_Interface_Items_Pkg.Organization_Name_Typ;
53 G_Organization_Id_Tbl Pa_Txn_Interface_Items_Pkg.Organization_Id_Typ;
54 G_Expenditure_Item_Date_Tbl Pa_Txn_Interface_Items_Pkg.Expenditure_Item_Date_Typ;
55 G_Project_Number_Tbl Pa_Txn_Interface_Items_Pkg.Project_Number_Typ;
56 G_Project_Id_Tbl Pa_Txn_Interface_Items_Pkg.Project_Id_Typ;
57 G_Task_Number_Tbl Pa_Txn_Interface_Items_Pkg.Task_Number_Typ;
58 G_Task_Id_Tbl Pa_Txn_Interface_Items_Pkg.Task_Id_Typ;
59 G_Expenditure_Type_Tbl Pa_Txn_Interface_Items_Pkg.Expenditure_Type_Typ;
60 G_System_Linkage_Tbl Pa_Txn_Interface_Items_Pkg.System_Linkage_Typ;
61 G_Non_Labor_Resource_Tbl Pa_Txn_Interface_Items_Pkg.Non_Labor_Resource_Typ;
62 G_Non_Labor_Res_Org_Name_Tbl Pa_Txn_Interface_Items_Pkg.Non_Labor_Res_Org_Name_Typ;
63 G_Non_Labor_Res_Org_Id_Tbl Pa_Txn_Interface_Items_Pkg.Non_Labor_Res_Org_Id_Typ;
64 G_Quantity_Tbl Pa_Txn_Interface_Items_Pkg.Quantity_Typ;
65 G_Raw_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Raw_Cost_Typ;
66 G_Raw_Cost_Rate_Tbl Pa_Txn_Interface_Items_Pkg.Raw_Cost_Rate_Typ;
67 G_Burden_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Burden_Cost_Typ;
68 G_Burden_Cost_Rate_Tbl Pa_Txn_Interface_Items_Pkg.Burden_Cost_Rate_Typ;
69 G_Expenditure_Comment_Tbl Pa_Txn_Interface_Items_Pkg.Expenditure_Comment_Typ;
70 G_Gl_Date_Tbl Pa_Txn_Interface_Items_Pkg.Gl_Date_Typ;
71 G_Transaction_Status_Code_Tbl Pa_Txn_Interface_Items_Pkg.Transaction_Status_Code_Typ;
72 G_Trans_Rejection_Code_Tbl Pa_Txn_Interface_Items_Pkg.Transaction_Rejection_Code_Typ;
73 G_Orig_Trans_Reference_Tbl Pa_Txn_Interface_Items_Pkg.Orig_Transaction_Reference_Typ;
74 G_Unmatched_Neg_Txn_Flag_Tbl Pa_Txn_Interface_Items_Pkg.Unmatched_Neg_Txn_Flag_Typ;
75 G_Expenditure_Id_Tbl Pa_Txn_Interface_Items_Pkg.Expenditure_Id_Typ;
76 G_Attribute_Category_Tbl Pa_Txn_Interface_Items_Pkg.Attribute_Category_Typ;
77 G_Attribute1_Tbl Pa_Txn_Interface_Items_Pkg.Attribute1_Typ;
78 G_Attribute2_Tbl Pa_Txn_Interface_Items_Pkg.Attribute2_Typ;
79 G_Attribute3_Tbl Pa_Txn_Interface_Items_Pkg.Attribute3_Typ;
80 G_Attribute4_Tbl Pa_Txn_Interface_Items_Pkg.Attribute4_Typ;
81 G_Attribute5_Tbl Pa_Txn_Interface_Items_Pkg.Attribute5_Typ;
82 G_Attribute6_Tbl Pa_Txn_Interface_Items_Pkg.Attribute6_Typ;
83 G_Attribute7_Tbl Pa_Txn_Interface_Items_Pkg.Attribute7_Typ;
84 G_Attribute8_Tbl Pa_Txn_Interface_Items_Pkg.Attribute8_Typ;
85 G_Attribute9_Tbl Pa_Txn_Interface_Items_Pkg.Attribute9_Typ;
86 G_Attribute10_Tbl Pa_Txn_Interface_Items_Pkg.Attribute10_Typ;
87 G_Dr_Code_Combination_Id_Tbl Pa_Txn_Interface_Items_Pkg.Dr_Code_Combination_Id_Typ;
88 G_Cr_Code_Combination_Id_Tbl Pa_Txn_Interface_Items_Pkg.Cr_Code_Combination_Id_Typ;
89 G_Cdl_System_Reference1_Tbl Pa_Txn_Interface_Items_Pkg.Cdl_System_Reference1_Typ;
90 G_Cdl_System_Reference2_Tbl Pa_Txn_Interface_Items_Pkg.Cdl_System_Reference2_Typ;
91 G_Cdl_System_Reference3_Tbl Pa_Txn_Interface_Items_Pkg.Cdl_System_Reference3_Typ;
92 G_Interface_Id_Tbl Pa_Txn_Interface_Items_Pkg.Interface_Id_Typ;
93 G_Receipt_Currency_Amount_Tbl Pa_Txn_Interface_Items_Pkg.Receipt_Currency_Amount_Typ;
94 G_Receipt_Currency_Code_Tbl Pa_Txn_Interface_Items_Pkg.Receipt_Currency_Code_Typ;
95 G_Receipt_Exchange_Rate_Tbl Pa_Txn_Interface_Items_Pkg.Receipt_Exchange_Rate_Typ;
96 G_Denom_Currency_Code_Tbl Pa_Txn_Interface_Items_Pkg.Denom_Currency_Code_Typ;
97 G_Denom_Raw_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Denom_Raw_Cost_Typ;
98 G_Denom_Burdened_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Denom_Burdened_Cost_Typ;
99 G_Acct_Rate_Date_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Rate_Date_Typ;
100 G_Acct_Rate_Type_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Rate_Type_Typ;
101 G_Acct_Exchange_Rate_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Exchange_Rate_Typ;
102 G_Acct_Raw_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Raw_Cost_Typ;
103 G_Acct_Burdened_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Burdened_Cost_Typ;
104 G_Acct_Exch_Rounding_Limit_Tbl Pa_Txn_Interface_Items_Pkg.Acct_Exch_Rounding_Limit_Typ;
105 G_Project_Currency_Code_Tbl Pa_Txn_Interface_Items_Pkg.Project_Currency_Code_Typ;
106 G_Project_Rate_Date_Tbl Pa_Txn_Interface_Items_Pkg.Project_Rate_Date_Typ;
107 G_Project_Rate_Type_Tbl Pa_Txn_Interface_Items_Pkg.Project_Rate_Type_Typ;
108 G_Project_Exchange_Rate_Tbl Pa_Txn_Interface_Items_Pkg.Project_Exchange_Rate_Typ;
109 G_Orig_Exp_Txn_Reference1_Tbl Pa_Txn_Interface_Items_Pkg.Orig_Exp_Txn_Reference1_Typ;
110 G_Orig_Exp_Txn_Reference2_Tbl Pa_Txn_Interface_Items_Pkg.Orig_Exp_Txn_Reference2_Typ;
111 G_Orig_Exp_Txn_Reference3_Tbl Pa_Txn_Interface_Items_Pkg.Orig_Exp_Txn_Reference3_Typ;
112 G_Orig_User_Exp_Txn_Ref_Tbl Pa_Txn_Interface_Items_Pkg.Orig_User_Exp_Txn_Ref_Typ;
113 G_Vendor_Number_Tbl Pa_Txn_Interface_Items_Pkg.Vendor_Number_Typ;
114 G_Vendor_Id_Tbl Pa_Txn_Interface_Items_Pkg.Vendor_Id_Typ;
115 G_Override_To_Org_Name_Tbl Pa_Txn_Interface_Items_Pkg.Override_To_Org_Name_Typ;
116 G_Override_To_Org_Id_Tbl Pa_Txn_Interface_Items_Pkg.Override_To_Org_Id_Typ;
117 G_Reversed_Orig_Txn_Ref_Tbl Pa_Txn_Interface_Items_Pkg.Reversed_Orig_Txn_Ref_Typ;
118 G_Billable_Flag_Tbl Pa_Txn_Interface_Items_Pkg.Billable_Flag_Typ;
119 G_ProjFunc_Currency_Code_Tbl Pa_Txn_Interface_Items_Pkg.ProjFunc_Currency_Code_Typ;
120 G_ProjFunc_Cost_Rate_Date_Tbl Pa_Txn_Interface_Items_Pkg.ProjFunc_Cost_Rate_Date_Typ;
121 G_ProjFunc_Cost_Rate_Type_Tbl Pa_Txn_Interface_Items_Pkg.ProjFunc_Cost_Rate_Type_Typ;
122 G_ProjFunc_Cost_Exch_Rate_Tbl Pa_Txn_Interface_Items_Pkg.ProjFunc_Cost_Exch_Rate_Typ;
123 G_Project_Raw_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Project_Raw_Cost_Typ;
124 G_Project_Burdened_Cost_Tbl Pa_Txn_Interface_Items_Pkg.Project_Burdened_Cost_Typ;
125 G_Assignment_Name_Tbl Pa_Txn_Interface_Items_Pkg.Assignment_Name_Typ;
126 G_Assignment_Id_Tbl Pa_Txn_Interface_Items_Pkg.Assignment_Id_Typ;
127 G_Work_Type_Name_Tbl Pa_Txn_Interface_Items_Pkg.Work_Type_Name_Typ;
128 G_Work_Type_Id_Tbl Pa_Txn_Interface_Items_Pkg.Work_Type_Id_Typ;
129 G_Cdl_System_Reference4_Tbl Pa_Txn_Interface_Items_Pkg.Cdl_System_Reference4_Typ;
130 G_Accrual_Flag_Tbl Pa_Txn_Interface_Items_Pkg.Accrual_Flag_Typ;
131 G_Last_Update_Date_Tbl Pa_Txn_Interface_Items_Pkg.Last_Update_Date_Typ;
132 G_Last_Updated_By_Tbl Pa_Txn_Interface_Items_Pkg.Last_Updated_By_Typ;
133 G_Creation_Date_Tbl Pa_Txn_Interface_Items_Pkg.Creation_Date_Typ;
134 G_Created_By_Tbl Pa_Txn_Interface_Items_Pkg.Created_By_Typ;
135 -- PA.M/CWK changes
136 G_PO_Number_Tbl Pa_Txn_Interface_Items_Pkg.PO_Number_Typ;
137 G_PO_Header_Id_Tbl Pa_Txn_Interface_Items_Pkg.PO_Header_Id_Typ;
138 G_PO_Line_Num_Tbl Pa_Txn_Interface_Items_Pkg.PO_Line_Num_Typ;
139 G_PO_Line_Id_Tbl Pa_Txn_Interface_Items_Pkg.PO_Line_Id_Typ;
140 G_PO_Price_Type_Tbl Pa_Txn_Interface_Items_Pkg.PO_Price_Type_Typ;
141 G_Person_Type_Tbl Pa_Txn_Interface_Items_Pkg.Person_Type_Typ;
142 -- Other PA.M changes
143 G_Inventory_Item_Id_Tbl Pa_Txn_Interface_Items_Pkg.Inventory_Item_Id_Typ;
144 G_WIP_Resource_Id_Tbl Pa_Txn_Interface_Items_Pkg.WIP_Resource_Id_Typ;
145 G_Unit_Of_Measure_Tbl Pa_Txn_Interface_Items_Pkg.Unit_Of_Measure_Typ;
146
147 G_Trx_Import_Index Binary_Integer := 0;
148
149 -- Used as a counter to bulk insert.
150 G_Txn_Rec_Count Number := Null;
151
152 -- Handling unhandled exceptions
153 G_EXCEPT_CNT_ALLOWED Number := to_Number(Nvl(Fnd_Profile.Value('HXC_RETRIEVAL_MAX_ERRORS'),0));
154 G_Unhandled_Except_Cnt Number;
155
156 G_BAD_OTL_DATA Exception;
157 HXC_RETRIEVAL_MAX_ERRORS Exception;
158
159 G_Debug_Mode Varchar2(1) := Nvl(Fnd_Profile.Value('PA_DEBUG_MODE'), 'N');
160
161 -- Begin PA.M/CWK changes
162 G_Po_Line_Id Number := Null;
163 G_Vendor_Id Number := Null;
164 G_PO_Header_Id Number := Null;
165 -- End PA.M/CWK changes
166
167 -- Added to support performance change in OTL, when creating billable flag record
168 G_Billable_Segment HXC_MAPPING_COMPONENTS.SEGMENT%TYPE;
169
170 -- 12i changes
171 G_OU_Tbl Pa_Txn_Interface_Items_Pkg.OU_Id_Typ;
172 G_Current_Org_Id Number := Pa_Moac_Utils.Get_Current_Org_Id;
173
174 -- =======================================================================
175 -- Start of Comments
176 -- API Name : TrackPath
177 -- Type : Private
178 -- Pre-Reqs : None
179 -- Type : Procedure
180 -- Function : This procedure tracks the path thru the code to attach to error messages.
181 --
182 -- Parameters:
183 --
184 -- IN
185 -- P_Function - Varchar2 -- ADD or STRIP
186 -- P_Value - Varchar2
187 --
188
189 /*-------------------------------------------------------------------------*/
190
191 Procedure TrackPath (
192 P_Function IN Varchar2,
193 P_Value IN Varchar2)
194
195 Is
196
197 l_Value Varchar2(2000) := '->' || P_Value;
198
199 Begin
200
201 G_Stage := 'Entering procedure TrackPath().';
202
203 If P_Function = 'ADD' Then
204
205 G_Stage := 'TrackPath(): Adding to G_Path.';
206 G_Path := G_Path || l_Value;
207
208 ElsIf P_Function = 'STRIP' Then
209
210 G_Stage := 'TrackPath(): Stripping from G_Path.';
211 G_Path := Substr(G_Path,1,Instr(G_Path,l_Value) - 1);
212
213 End If;
214
215 G_Stage := 'Leaving procedure TrackPath().';
216
217 Exception
218 When Others Then
219 Raise;
220
221 End TrackPath;
222
223
224 -- =======================================================================
225 -- Start of Comments
226 -- API Name : Add_Error_To_Table
227 -- Type : Private
228 -- Pre-Reqs : None
229 -- Type : Procedure
230 -- Function : This procedure populates the error table for any expected errors.
231 --
232 -- Parameters:
233 --
234 -- IN
235 -- P_Message_Table - Hxc_User_Type_Definition_Grp.Message_Table%TYPE
236 -- P_Message_Name - Fnd_New_Messages.Message_Name%TYPE
237 -- P_Message_Level - Varchar2
238 -- P_Message_Field - Varchar2
239 -- P_Msg_Tokens - Pa_Otc_Api.Messages_Tokens
240 -- P_Time_Building_Block_Id - Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE
241 -- P_Time_Attribute_Id - Hxc_Time_Attributes.Time_Attribute_Id%TYPE
242 -- P_Message_App - Varchar2 Default 'PA'
243 --
244 -- OUT
245 -- P_Message_Table - Hxc_User_Type_Definition_Grp.Message_Table%TYPE
246 --
247
248 /*-------------------------------------------------------------------------*/
249
250 Procedure Add_Error_To_Table(
251 P_Message_Table IN OUT NOCOPY Hxc_User_Type_Definition_Grp.Message_Table, -- 2672653
252 P_Message_Name IN Fnd_New_Messages.Message_Name%TYPE,
253 P_Message_Level IN Varchar2,
254 P_Message_Field IN Varchar2,
255 P_Msg_Tokens IN Pa_Otc_Api.Message_Tokens,
256 P_Time_Building_Block_Id IN Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE,
257 P_Time_Attribute_Id IN Hxc_Time_Attributes.Time_Attribute_Id%TYPE,
258 P_Message_App IN Varchar2 )
259
260 Is
261
262 l_Last_Index Number := P_Message_Table.Last;
263 l_Tokens Varchar2(2000) := Null;
264
265 Begin
266
267 G_Stage := 'Entering Add_Error_To_Table().';
268 Pa_Otc_Api.TrackPath('ADD','Add_Error_To_Table');
269
270 G_Stage := 'Determine Error token count.';
271 If P_Msg_Tokens.Count > 0 Then
272
273 G_Stage := 'Get token data if it exists.';
274 For i in P_Msg_Tokens.First .. P_Msg_Tokens.Last
275 Loop
276
277 If l_Tokens is Null Then
278
279 G_Stage := 'Concatenate the token name and token value 1.';
280 l_Tokens := P_Msg_Tokens(i).Token_Name || '&' || P_Msg_Tokens(i).Token_Value;
281
282 Else
283
284 G_Stage := 'Concatenate the token name and token value 2.';
285 -- Added appending for l_Tokens for bug 4593869
286 l_Tokens := l_Tokens || '&' || P_Msg_Tokens(i).Token_Name || '&' || P_Msg_Tokens(i).Token_Value;
287
288 End If;
289
290 End Loop;
291
292 End If;
293
294 G_Stage := 'Get next available index for error table.';
295 l_Last_Index := Nvl(l_Last_Index,0) + 1;
296
297 G_Stage := 'Assign message name to error table record.';
298 P_Message_Table(l_last_index).Message_Name := P_Message_Name;
299
300 G_Stage := 'Assign message level to error table record.';
301 P_Message_Table(l_last_index).Message_Level := P_Message_Level;
302
303 G_Stage := 'Assign message field to error table record.';
304 P_Message_Table(l_last_index).Message_Field := P_Message_Field;
305
306 G_Stage := 'Assign application short name to error table record.';
307 P_Message_Table(l_last_index).Application_Short_Name := P_Message_App;
308
309 G_Stage := 'Assign token string to error table record.';
310 P_Message_Table(l_last_index).Message_Tokens := l_Tokens;
311
312 G_Stage := 'Assign Time Building Block Id to error table record.';
313 P_Message_Table(l_last_index).Time_Building_Block_Id := P_Time_Building_Block_Id;
314
315 G_Stage := 'Assign Time Attribute Id to error table record.';
316 P_Message_Table(l_last_index).Time_Attribute_Id := P_Time_Attribute_Id;
317
318 G_Stage := 'Leaving Add_Error_To_Table() procedure.';
319 Pa_Otc_Api.TrackPath('STRIP','Add_Error_To_Table');
320
321 Exception
322 When Others Then
323 Raise;
324
325 End Add_Error_To_Table;
326
327
328
329 -- **** TRX IMPORT PROCEDURES AND FUNCTIONS ****
330
331 -- =======================================================================
332 -- Start of Comments
333 -- API Name : Upload_Otc_Timecards
334 -- Type : Public
335 -- Pre-Reqs : None
336 -- Type : Procedure
337 -- Function : This procedure is used to pull approved self service
338 -- timecards into transaction interface table. This is an
339 -- entry point procedure for the pre_import extension call
340 -- from Trx Import.
341 -- Parameters :
342 -- IN
343 -- P_Transaction_Source: Unique identifier for source of the txn
344 -- P_Batch: Batch Name to group txns into batches
345 -- P_Xface_Id: Interface Id
346 -- P_User_Id: User Id
347
348 /*--------------------------------------------------------------------------*/
349
350 Procedure Upload_Otc_Timecards(P_Transaction_Source IN Pa_Transaction_Interface_All.Transaction_Source%TYPE,
351 P_Batch IN Pa_Transaction_Interface_All.Batch_Name%TYPE,
352 P_Xface_Id IN Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE,
353 P_User_Id IN NUMBER) IS
354
355 l_Txn_Rowid RowId := Null;
356 l_Txn_Xface_Id Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE := NULL;
357 l_Where_Clause Varchar2(2000);
358 l_Batch_Name Pa_Transaction_Interface_All.Batch_Name%TYPE;
359 l_Override_Approver_Id Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE;
360 l_New_Orig_Trx_Ref Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE;
361 l_Old_Orig_Trx_Ref Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE;
362 l_Insert_Rec_Flag Boolean := False;
363 l_Org_Id Hr_All_Organization_Units.Organization_Id%TYPE := NULL;
364 l_Direct_Update_Flag Boolean := False;
365 l_Comment_Or_Dff Varchar2(1);
366 l_Comment Varchar2(150);
367 l_New_Timecard_Rec Pa_Otc_Api.Timecard_Rec;
368 l_Old_Timecard_Rec Pa_Otc_Api.Timecard_Rec;
369 l_Temp_Timecard_Rec Pa_Otc_Api.Timecard_Rec := NULL;
370 l_Old_Detail_Index Binary_Integer := 0;
371 l_Error_Code Varchar2(30) := NULL;
372 l_dummy Number := NULL;
373 l_Error_Text Varchar2(2000);
374
375 -- Maximum number of eis to be bulkinserted that is allowed
376 L_MAX_RECS_FOR_BULKINSERT Number := 1000;
377 l_ac_termination_date per_periods_of_service.actual_termination_date%type; /* Bug 6698171 */
378
379 Function GetVendorId(P_Po_Line_Id in Number) RETURN Number
380
381 Is
382
383 X_Vendor_Id Number := Null;
384
385 Begin
386
387 If Nvl(G_Po_Line_Id,-9999999) <> P_Po_Line_Id Then
388
389 Select
390 h.Vendor_Id
391 Into
392 X_Vendor_Id
393 from
394 PO_Headers_All h,
395 PO_Lines_All l
396 where
397 l.po_line_Id = P_Po_Line_Id
398 and l.po_header_id = h.po_header_Id;
399
400 G_Po_Line_Id := P_Po_Line_Id;
401 G_Vendor_Id := G_Vendor_Id;
402
403 End If;
404
405 Return G_Vendor_Id;
406
407 Exception
408 When Others Then
409 Return Null;
410
411 End GetVendorId;
412
413 Begin
414
415 G_Path := ' ';
416
417 G_Stage := 'Entering Upload_Otc_Timecard(), add procedure to trackpath.';
418 If G_Debug_Mode = 'Y' Then
419 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
420 pa_cc_utils.log_message( Pa_Debug.G_Err_Stage,1);
421 End If;
422 Pa_Otc_Api.TrackPath('ADD','Upload_Otc_Timecards');
423
424 If G_Processed_Import_Batch is Null Then
425
426 G_Stage := 'Single time process initialization section needed.';
427 If G_Debug_Mode = 'Y' Then
428 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
429 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
430 End If;
431
432 G_Stage := 'Call BulkInsertReset() procedure for reset.';
433 If G_Debug_Mode = 'Y' Then
434 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
435 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
436 End If;
437 Pa_Otc_Api.BulkInsertReset(P_Command => 'RESET');
438
439 G_Stage := 'Initialize what remains.';
440 If G_Debug_Mode = 'Y' Then
441 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
442 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
443 End If;
444 G_Processed_Import_Batch := FALSE;
445 G_EndDateBatchName_Table.Delete;
446 G_Unhandled_Except_Cnt := 0;
447
448 End If;
449
450 G_Stage := 'Each time Upload_Otc_Timecards() called initializaion of global variables.';
451 If G_Debug_Mode = 'Y' Then
452 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
453 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
454 End If;
455
456 G_Old_Detail_Attr_Index := 0;
457 G_Detail_Attr_Index := 0;
458 G_Trx_Inserted_Tab.Delete;
459 G_Trx_Direct_Upd_Tab.Delete;
460 G_Trx_Import_Index := 0;
461 Pa_Trx_Import.G_Batch_Size := 0;
462
463 -- PA.M/CWK changes
464 G_Po_Line_Id := Null;
465 G_Vendor_Id := Null;
466 G_PO_Header_Id := Null;
467
468 /* Where clause must restrict the retrieval to the current
469 * operating unit if Multi-Org is Implemented for Projects.
470 */
471 If Pa_Utils.Pa_Morg_Implemented = 'Y' Then
472
473 G_Stage := 'Create where clause.';
474 If G_Debug_Mode = 'Y' Then
475 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
476 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
477 End If;
478
479 -- 12i MOAC changes
480 -- l_Where_Clause := '[ORG_ID] { = ''' || to_Char(to_Number(SubStr(UserEnv('CLIENT_INFO'),1,10))) || ''' }';
481 l_Where_Clause := '[ORG_ID] { = ''' || to_Char(G_Current_Org_Id) || ''' }';
482
483 Else
484
485 G_Stage := 'No where clause.';
486 If G_Debug_Mode = 'Y' Then
487 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
488 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
489 End If;
490
491 l_Where_Clause := NULL;
492
493 End If;
494
495 /* Pull the data into the OTL pl/sql tables.
496 *
497 * PL/SQL tables to work with once the procedure execute_retrieval_process is done:
498 * Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks Using
499 * Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks Using
500 * Hxc_User_Type_Definition_Grp.T_Detail_Attributes Using
501 * Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes Using
502 * Hxc_User_Type_Definition_Grp.T_Day_Bld_Blks Using for ei date retrieval
503 * Hxc_User_Type_Definition_Grp.T_Old_Day_Bld_Blks Using for ei date retrieval
504 * Hxc_User_Type_Definition_Grp.T_Day_Attributes Not Using
505 * Hxc_User_Type_Definition_Grp.T_Old_Day_Attributes Not Using
506 * Hxc_User_Type_Definition_Grp.T_Time_Bld_Blks Not Using
507 * Hxc_User_Type_Definition_Grp.T_Old_Time_Bld_Blks Not Using
508 * Hxc_User_Type_Definition_Grp.T_Time_Attributes Not Using
509 * Hxc_User_Type_Definition_Grp.T_Old_Time_Attributes Not Using
510 * Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status Using
511 * Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception Using
512 */
513
514 G_Stage := 'Call execute retrieval process API.';
515 If G_Debug_Mode = 'Y' Then
516 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
517 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
518 End If;
519 Hxc_Integration_Layer_V1_Grp.Execute_Retrieval_Process(
520 P_Process => 'Projects Retrieval Process',
521 P_Transaction_code => Null,
522 P_Start_Date => Null,
523 P_End_Date => Null,
524 P_Incremental => 'Y',
525 P_Rerun_Flag => 'N',
526 P_Where_Clause => l_Where_Clause,
527 P_Scope => 'DAY',
528 P_Clusive => 'EX');
529
530 If Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.COUNT > 0 Then
531
532 Pa_Trx_Import.G_Exit_Main := FALSE;
533
534 G_Stage := 'Loop thru all hxc detail building block records.';
535 If G_Debug_Mode = 'Y' Then
536 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
537 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
538 End If;
539 For i IN Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.First .. Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.Last
540 Loop
541
542 G_Stage := 'Process bb/ovn: ' || to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
543 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn) ||
544 ' for Resource_Id(Person_Id): ' || to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Resource_Id);
545 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
546 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
547
548 Begin
549
550 G_Stage := 'Primary condition evaluation within the loop.';
551 If G_Debug_Mode = 'Y' Then
552 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
553 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
554 End If;
555
556 If Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Changed = 'N' and
557 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Deleted = 'Y' Then
558
559 G_Stage := 'Item Changed: N, Deleted: Y.';
560 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
561 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
562
563
564 -- Even though the building block was deleted prior to being imported into projects
565 -- appearantly attribution data is created and sent via the Generic retrieval process
566 -- via the Generic retrieval process. Need to sequence thru to position
567 -- the global index variable for the next bb to process.
568 -- Since it was deleted means it does not need to be imported into projects.
569 -- There is also no need to look at the old pl/sql tables records.
570
571 G_Stage := 'Call Populate Project Record new 1 for positioning purposes only.';
572 If G_Debug_Mode = 'Y' Then
573 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
574 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
575 End If;
576
577 Pa_Otc_Api.PopulateProjRec(
578 P_New_Old_BB => 'NEW',
579 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
580 P_Detail_Index => i,
581 P_Old_Detl_Ind => l_Old_Detail_Index,
582 P_Timecard_Rec => l_New_Timecard_Rec);
583
584 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'SUCCESS';
585
586 l_insert_rec_flag := FALSE;
587
588 ElsIf Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Changed = 'N' and
589 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Deleted = 'N' Then
590
591 -- If this is the condition then there is only new data to process via PopulateProjRec() procedure
592 -- and there is no need to look at the old data via the same procedure.
593
594 G_Stage := 'Item Changed: N, Deleted: N.';
595 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
596 pa_cc_Utils.log_message(Pa_Debug.G_Err_Stage,1);
597
598 G_Stage := 'Call Populate Project Record new 2.';
599 If G_Debug_Mode = 'Y' Then
600 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
601 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
602 End If;
603
604 Pa_Otc_Api.PopulateProjRec(
605 P_New_Old_BB => 'NEW',
606 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
607 P_Detail_Index => i,
608 P_Old_Detl_Ind => l_Old_Detail_Index,
609 P_Timecard_Rec => l_New_Timecard_Rec);
610
611 G_Stage := 'EI data status check 2.';
612 If G_Debug_Mode = 'Y' Then
613 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
614 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
615 End If;
616
617 If l_New_Timecard_Rec.Status is Not Null Then
618
619 G_Stage := 'New Record Status is not null 2. Timecard status is ' || l_New_Timecard_Rec.Status;
620 If G_Debug_Mode = 'Y' Then
621 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
622 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
623 End If;
624
625 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
626 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_New_Timecard_Rec.Status;
627 l_insert_rec_flag := FALSE;
628
629 Else
630
631 G_Stage := 'Create new orig trx ref 2.';
632 If G_Debug_Mode = 'Y' Then
633 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
634 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
635 End If;
636
637 l_new_orig_trx_ref :=
638 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
639 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn);
640
641 G_Stage := 'Check if original transaction reference already exists 2';
642 If G_Debug_Mode = 'Y' Then
643 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
644 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
645 End If;
646
647 -- Calling the function is a sanity check to confirm that this is solely new data.
648 If NOT Pa_Otc_Api.OrigTrxRefValueExists(l_new_orig_trx_ref) Then
649
650 -- Insert a new record. There should be no records in either
651 -- pl/sql tables t_old_detail_bld_blks or t_old_detail_attributes
652 -- for this building block id.
653 --
654
655 l_insert_rec_flag := TRUE;
656
657 G_Stage := 'Call the GetBatchName procedure 2';
658 If G_Debug_Mode = 'Y' Then
659 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
660 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
661 End If;
662
663 Pa_Otc_Api.GetBatchName(
664 P_Exp_End_Date => l_New_Timecard_Rec.Expenditure_Ending_Date,
665 X_Batch_Name => l_Batch_Name);
666
667 Else
668 -- This condition result should never happen, but it's here just in case.
669
670 G_Stage := 'Building block/ovn combo already exists in projects 2.';
671 If G_Debug_Mode = 'Y' Then
672 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
673 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
674 End If;
675 l_insert_rec_flag := FALSE;
676 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'SUCCESS';
677
678 End If;
679
680 End If;
681
682 ElsIf Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Changed = 'Y' and
683 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Deleted = 'N' Then
684
685 G_Stage := 'Item Changed: Y, Deleted: N.';
686 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
687 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
688
689 l_Old_Detail_Index := l_Old_Detail_Index + 1;
690
691 G_Stage := 'Create new orig trx ref 3.';
692 If G_Debug_Mode = 'Y' Then
693 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
694 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
695 End If;
696
697 l_new_orig_trx_ref :=
698 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
699 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn);
700
701 If NOT Pa_Otc_Api.OrigTrxRefValueExists(l_new_orig_trx_ref) Then
702
703 G_Stage := 'Call Populate Project Record new 3a.';
704 If G_Debug_Mode = 'Y' Then
705 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
706 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
707 End If;
708
709 Pa_Otc_Api.PopulateProjRec(
710 P_New_Old_BB => 'NEW',
711 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
712 P_Detail_Index => i,
713 P_Old_Detl_Ind => l_Old_Detail_Index,
714 P_timecard_Rec => l_New_Timecard_Rec);
715
716 G_Stage := 'EI data status check 3a.';
717 If G_Debug_Mode = 'Y' Then
718 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
719 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
720 End If;
721
722 If l_New_Timecard_Rec.Status is Not Null Then
723
724 G_Stage := 'New Record Status is not null 3a. Timecard status is ' || l_New_Timecard_Rec.Status;
725 If G_Debug_Mode = 'Y' Then
726 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
727 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
728 End If;
729
730 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
731 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_New_Timecard_Rec.Status;
732 l_insert_rec_Flag := FALSE;
733
734 G_Stage := 'Since the Status is not null 3a has been hit for new record, ' ||
735 'call PopulateProjRec() for old records for positioning ' ||
736 'purposes only to maintain sync with new pl/sql tables.';
737 If G_Debug_Mode = 'Y' Then
738 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
739 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
740 End If;
741
742 Pa_Otc_Api.PopulateProjRec(
743 P_New_Old_BB => 'OLD',
744 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).bb_id,
745 P_Detail_Index => i,
746 P_Old_Detl_Ind => l_Old_Detail_Index,
747 P_timecard_Rec => l_Old_Timecard_Rec);
748
749 -- We don't care about the handled errors, since using only for positioning
750 -- purposees so we don't check the status after the call to the procedure.
751
752 Else
753
754 G_Stage := 'Call Populate Project Record old 3a.';
755 If G_Debug_Mode = 'Y' Then
756 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
757 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
758 End If;
759
760 Pa_Otc_Api.PopulateProjRec(
761 P_New_Old_BB => 'OLD',
762 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).bb_id,
763 P_Detail_Index => i,
764 P_Old_Detl_Ind => l_Old_Detail_Index,
765 P_timecard_Rec => l_Old_Timecard_Rec);
766
767 If l_Old_Timecard_Rec.Status is Not Null Then
768
769 G_Stage := 'Old Record Status is not null 3a. Timecard status is ' || l_Old_Timecard_Rec.Status;
770 If G_Debug_Mode = 'Y' Then
771 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
772 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
773 End If;
774
775 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
776 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_Old_Timecard_Rec.Status;
777 l_insert_rec_Flag := FALSE;
778
779 Else
780
781 -- Need to find out what has changed to determine whether or not need to
782 -- insert record into pa_transaction_interface or update tables
783 -- pa_expenditure_comments and/or pa_expenditure_items_all.
784 G_Stage := 'Call Determine Direct Update 3.';
785 If G_Debug_Mode = 'Y' Then
786 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
787 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
788 End If;
789
790 Pa_Otc_Api.DetermineDirectUpdate(
791 P_New_Timecard_Rec => l_New_Timecard_Rec,
792 P_Old_Timecard_Rec => l_Old_Timecard_Rec,
793 P_Direct_Update_Flag => l_direct_update_flag,
794 P_Comment_or_Dff => l_Comment_or_Dff);
795
796 If l_direct_update_flag Then
797
798 l_insert_rec_flag := FALSE;
799
800 G_Stage := 'Direct Update of the exp item in projects. ' ||
801 'Need to update (C)omment, (D)ff, (B)oth: ' || l_Comment_or_Dff;
802 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
803 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
804
805 G_Stage := 'Direct Update get trx ref. by calling GetOrigTrxRef '||
806 'to use to update the expenditure item.';
807 If G_Debug_Mode = 'Y' Then
808 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
809 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
810 End If;
811
812 Pa_Otc_Api.GetOrigTrxRef(
813 P_Building_Block_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
814 X_OrigTrxRef => l_old_orig_trx_ref,
815 X_Status => l_New_Timecard_Rec.Status);
816
817 If l_New_Timecard_Rec.Status is not null Then
818
819 G_Stage := 'Update hxc exception pl/sql tables 1.';
820 If G_Debug_Mode = 'Y' Then
821 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
822 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
823 End If;
824
825 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
826 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_New_Timecard_Rec.Status;
827 Raise G_BAD_OTL_DATA;
828
829 End If;
830
831 G_Stage := 'Call Update Changed Original Txn 3.';
832 If G_Debug_Mode = 'Y' Then
833 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
834 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
835 End If;
836
837 Pa_Otc_Api.UpdateChangedOrigTxn(
838 P_Old_Orig_Txn_Ref => l_old_orig_trx_ref,
839 P_New_Orig_Txn_Ref => l_new_orig_trx_ref,
840 P_Comment_or_Dff => l_comment_or_dff,
841 P_Timecard_Rec => l_new_timecard_rec,
842 P_User_Id => P_User_Id);
843
844 G_Stage := 'Store the Bb_Id and index in pl/sql table for use ' ||
845 'in tieback process 3a for directly updated ei.';
846 If G_Debug_Mode = 'Y' Then
847 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
848 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
849 End If;
850
851 G_Trx_Direct_Upd_Tab(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id).BB_Index := i;
852
853 Else
854
855 l_insert_rec_flag := TRUE;
856
857 G_Stage := 'Call the GetBatchName procedure 3';
858 If G_Debug_Mode = 'Y' Then
859 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
860 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
861 End If;
862
863 Pa_Otc_Api.GetBatchName(
864 P_Exp_End_Date => l_New_Timecard_Rec.Expenditure_Ending_Date,
865 X_Batch_Name => l_Batch_Name);
866
867 G_Stage := 'Get old orig trx ref 3 using the new bb_id/ovn ' || 'combo ' ||
868 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
869 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn);
870 If G_Debug_Mode = 'Y' Then
871 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
872 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
873 End If;
874
875 -- Bug ?
876 -- Switched from function to procedure to determine if
877 -- ei is available for adjustment in projects
878 G_Stage := 'Calling procedure GetOrigTrxRef() Determine if ' ||
879 'availability of ei for adjusted 1';
880 If G_Debug_Mode = 'Y' Then
881 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
882 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
883 End If;
884
885 Pa_Otc_Api.GetOrigTrxRef(
886 P_Building_Block_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
887 X_OrigTrxRef => l_old_orig_trx_ref,
888 X_Status => l_New_Timecard_Rec.Status);
889
890 If l_New_Timecard_Rec.Status is not null Then
891
892 G_Stage := 'Update hxc exception pl/sql tables 2.';
893 If G_Debug_Mode = 'Y' Then
894 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
895 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
896 End If;
897 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
898 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) :=
899 l_New_Timecard_Rec.Status;
900 Raise G_BAD_OTL_DATA;
901
902 End If;
903
904 -- l_old_orig_trx_ref :=
905 -- Pa_Otc_Api.GetOrigTrxRef(
906 -- Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id);
907
908 -- End bug enhancement
909
910 G_Stage := 'Call Build Reverse Item 3.';
911 If G_Debug_Mode = 'Y' Then
912 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
913 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
914 End If;
915
916 Pa_Otc_Api.Build_Reverse_Item(
917 P_Old_Orig_Trx_Ref => l_old_orig_trx_ref,
918 P_New_Orig_Trx_Ref => l_new_orig_trx_ref,
919 P_Batch_Name => l_batch_name,
920 P_User_Id => P_User_Id,
921 P_Orig_Exp_Txn_Reference1 => l_new_timecard_rec.Orig_Exp_Txn_Reference1,
922 P_Xface_Id => P_Xface_Id);
923
924 G_Stage := 'Store the Bb_Id and index in pl/sql table for use ' ||
925 'in tieback process 3b.';
926 If G_Debug_Mode = 'Y' Then
927 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
928 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
929 End If;
930 G_Trx_Inserted_Tab(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id).BB_Index := i;
931
932 End If; -- l_direct_update_flag
933
934 End If; -- l_Old_Timecard_Rec.Status
935
936 End If; -- l_New_Timecard_Rec.Status
937
938 Else
939
940 -- The bb_id/ovn combo already exists in projects. This happened because
941 -- during the validation of the timecard it was determined that need to
942 -- update the ei record orig_transaction_reference column due to the fact that
943 -- the ovn went up a version but not project specific data has changed.
944 -- When an approved timecard that has already be sent to projects if a ei has
945 -- change of the many that exist in the timecard and no other ei was changed
946 -- and the user decides to click on the "Save for Later" button then all
947 -- eis in OTL timecard get an incremented ovn number and we need to account for this.
948
949 G_Stage := 'The bb_id/ovn combo already exists in projects, bypassing BB_Id: ' ||
950 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) ||
951 ':' || to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn) ||
952 ' for Resource_Id: ' || to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Resource_Id);
953 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Stage;
954 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
955
956 G_Stage := 'Call Populate Project Record new 3b for positioning purposes only.';
957 If G_Debug_Mode = 'Y' Then
958 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
959 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
960 End If;
961
962 Pa_Otc_Api.PopulateProjRec(
963 P_New_Old_BB => 'NEW',
964 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
965 P_Detail_Index => i,
966 P_Old_Detl_Ind => l_Old_Detail_Index,
967 P_timecard_Rec => l_New_Timecard_Rec);
968
969 G_Stage := 'Call Populate Project Record old 3b for positioning purposes only.';
970 If G_Debug_Mode = 'Y' Then
971 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
972 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
973 End If;
974
975 Pa_Otc_Api.PopulateProjRec(
976 P_New_Old_BB => 'OLD',
977 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).bb_id,
978 P_Detail_Index => i,
979 P_Old_Detl_Ind => l_Old_Detail_Index,
980 P_timecard_Rec => l_Old_Timecard_Rec);
981
982 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'SUCCESS';
983 l_insert_rec_Flag := FALSE;
984
985 End If;
986
987 ElsIf Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Changed = 'Y' and
988 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Deleted = 'Y' Then
989
990 -- The item was deleted in OTL after it was imported into Projects.
991 -- Need to Reverse out the original transaction.
992
993 G_Stage := 'Item Changed: Y, Deleted: Y.';
994 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
995 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
996
997 l_insert_rec_flag := FALSE;
998 l_Old_Detail_Index := l_Old_Detail_Index + 1;
999
1000 G_Stage := 'Create new orig trx ref 4.';
1001 If G_Debug_Mode = 'Y' Then
1002 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1003 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1004 End If;
1005
1006 l_new_orig_trx_ref := to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
1007 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn);
1008
1009 G_Stage := 'Call Populate Project Record new 4.';
1010 If G_Debug_Mode = 'Y' Then
1011 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1012 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1013 End If;
1014
1015 Pa_Otc_Api.PopulateProjRec(
1016 P_New_Old_BB => 'NEW',
1017 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
1018 P_Detail_Index => i,
1019 P_Old_Detl_Ind => l_Old_Detail_Index,
1020 P_timecard_Rec => l_New_Timecard_Rec);
1021
1022 G_Stage := 'EI data status check 4.';
1023 If G_Debug_Mode = 'Y' Then
1024 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1025 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1026 End If;
1027
1028 If l_New_Timecard_Rec.Status is Not Null Then
1029
1030 G_Stage := 'Status is not null 4. Timecard status is ' || l_New_Timecard_Rec.Status;
1031 If G_Debug_Mode = 'Y' Then
1032 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1033 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1034 End If;
1035
1036 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
1037 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_New_Timecard_Rec.Status;
1038
1039 G_Stage := 'Since Status is not null 4 occured for new record, call the ' ||
1040 'PopulateProjRec() procedure for the old record for positioning purposes ' ||
1041 'so as to maintain sync with new pl/sql tables.';
1042 If G_Debug_Mode = 'Y' Then
1043 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1044 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1045 End If;
1046
1047 Pa_Otc_Api.PopulateProjRec(
1048 P_New_Old_BB => 'OLD',
1049 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).bb_id,
1050 P_Detail_Index => i,
1051 P_Old_Detl_Ind => l_Old_Detail_Index,
1052 P_timecard_Rec => l_Old_Timecard_Rec);
1053
1054 -- We don't check the status column since the only purpose for calling the
1055 -- procedure is for positioning index values.
1056
1057 Else
1058
1059 G_Stage := 'Call the GetBatchName procedure 4';
1060 If G_Debug_Mode = 'Y' Then
1061 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1062 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1063 End If;
1064
1065 Pa_Otc_Api.GetBatchName(
1066 P_Exp_End_Date => l_New_Timecard_Rec.Expenditure_Ending_Date,
1067 X_Batch_Name => l_Batch_Name);
1068
1069 G_Stage := 'Call Populate Project Record old 4 positioning purposes only.';
1070 If G_Debug_Mode = 'Y' Then
1071 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1072 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1073 End If;
1074
1075 Pa_Otc_Api.PopulateProjRec(
1076 P_New_Old_BB => 'OLD',
1077 P_BB_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).bb_id,
1078 P_Detail_Index => i,
1079 P_Old_Detl_Ind => l_Old_Detail_Index,
1080 P_timecard_Rec => l_Old_Timecard_Rec);
1081
1082 -- We are not checking the status column since the call is for positioning purposes only.
1083
1084 G_Stage := 'Create old orig trx ref 4 using bb_id/ovn ' ||
1085 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id) || ':' ||
1086 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).Ovn);
1087 If G_Debug_Mode = 'Y' Then
1088 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1089 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1090 End If;
1091
1092 -- Switched from function to procedure to determine if
1093 -- ei is available for adjustment in projects
1094
1095 G_Stage := 'Calling procedure GetOrigTrxRef() Determine if ' ||
1096 'availability of ei for adjustment 4';
1097 If G_Debug_Mode = 'Y' Then
1098 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1099 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1100 End If;
1101
1102 Pa_Otc_Api.GetOrigTrxRef(
1103 P_Building_Block_Id => Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id,
1104 X_OrigTrxRef => l_old_orig_trx_ref,
1105 X_Status => l_New_Timecard_Rec.Status);
1106
1107 If l_New_Timecard_Rec.Status is not null Then
1108
1109 G_Stage := 'Updating hxc exception pl/sql tables 3.';
1110 If G_Debug_Mode = 'Y' Then
1111 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1112 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1113 End If;
1114
1115 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
1116 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) := l_New_Timecard_Rec.Status;
1117 Raise G_BAD_OTL_DATA;
1118
1119 End If;
1120
1121 -- l_old_orig_trx_ref :=
1122 -- Pa_Otc_Api.GetOrigTrxRef(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id);
1123
1124 -- End switch from function to procedure
1125
1126 G_Stage := 'Call Build Reverse Item 4.';
1127 If G_Debug_Mode = 'Y' Then
1128 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1129 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1130 End If;
1131
1132 l_error_code := NULL;
1133
1134 Pa_Otc_Api.Build_Reverse_Item(
1135 P_Old_Orig_Trx_Ref => l_old_orig_trx_ref,
1136 P_New_Orig_Trx_Ref => l_new_orig_trx_ref,
1137 P_Batch_Name => l_batch_name,
1138 P_User_id => P_User_Id,
1139 P_Orig_Exp_Txn_Reference1 => l_New_Timecard_Rec.Orig_Exp_Txn_Reference1,
1140 P_Xface_Id => P_Xface_id);
1141
1142 G_Stage := 'Store the Bb_Id and index in pl/sql table for use in tieback process 4.';
1143 If G_Debug_Mode = 'Y' Then
1144 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1145 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1146 End If;
1147 G_Trx_Inserted_Tab(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id).BB_Index := i;
1148
1149 End If; -- l_New_Timecard_Rec.Status
1150
1151 End If; -- Change/Delete flags
1152
1153 If l_insert_rec_flag Then
1154
1155 G_Stage := 'Get the next available Transaction Interface Id from sequence.';
1156 If G_Debug_Mode = 'Y' Then
1157 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1158 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1159 End If;
1160
1161 select pa_txn_interface_s.nextval
1162 into l_txn_xface_id
1163 from dual;
1164
1165 G_Stage := 'Store new/changed Trx Import Rec in pl/sql arrays for BB/Ovn: ' || l_New_Orig_Trx_Ref ||
1166 ' for Resource_Id(Person_Id): ' || to_char(l_New_Timecard_Rec.Incurred_By_Person_Id);
1167 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Stage;
1168 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1169
1170 G_Stage := 'Store Trx Import record in pl/sql arrays for bulk insert.';
1171 If G_Debug_Mode = 'Y' Then
1172 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1173 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1174 End If;
1175 /* Bug 6698171 */ if (l_New_Timecard_Rec.Person_Type = 'EMP') then /* Added if..else for bug 7505424 */
1176 patc.check_termination (l_New_Timecard_Rec.Incurred_By_Person_Id, l_New_Timecard_Rec.Expenditure_Item_Date, l_ac_termination_date);
1177 else
1178 patc.check_termination_for_cwk(l_New_Timecard_Rec.Incurred_By_Person_Id, l_New_Timecard_Rec.Expenditure_Item_Date, l_ac_termination_date);
1179 end if;
1180 -- following if does validation for employee termination
1181 IF l_New_Timecard_Rec.Expenditure_Item_Date <= nvl(l_ac_termination_date, l_New_Timecard_Rec.Expenditure_Item_Date) then
1182
1183 G_Trx_Import_Index := G_Trx_Import_Index + 1;
1184
1185 G_Txn_Interface_Id_Tbl(G_Trx_Import_Index) := l_txn_xface_id;
1186 G_Transaction_Source_Tbl(G_Trx_Import_Index) := 'ORACLE TIME AND LABOR';
1187 G_User_Transaction_Source_Tbl(G_Trx_Import_Index) := Null;
1188 G_Batch_Name_Tbl(G_Trx_Import_Index) := l_batch_name;
1189 G_Expenditure_End_Date_Tbl(G_Trx_Import_Index) := Pa_Utils.NewGetWeekEnding(l_New_Timecard_Rec.Expenditure_Item_Date);
1190 G_Person_Bus_Grp_Name_Tbl(G_Trx_Import_Index) := Null;
1191 G_Person_Bus_Grp_Id_Tbl(G_Trx_Import_Index) := Null;
1192 G_Employee_Number_Tbl(G_Trx_Import_Index) := Null;
1193 G_Person_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Incurred_By_Person_Id;
1194 G_Organization_Name_Tbl(G_Trx_Import_Index) := Null;
1195 G_Organization_Id_Tbl(G_Trx_Import_Index) := Null;
1196 G_Expenditure_Item_Date_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Expenditure_Item_Date;
1197 G_Project_Number_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Project_Number;
1198 G_Project_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Project_Id;
1199 G_Task_Number_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Task_Number;
1200 G_Task_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Task_Id;
1201 G_Expenditure_Type_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Expenditure_Type;
1202 G_System_Linkage_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.System_Linkage_Function;
1203 G_Non_Labor_Resource_Tbl(G_Trx_Import_Index) := Null;
1204 G_Non_Labor_Res_Org_Name_Tbl(G_Trx_Import_Index) := Null;
1205 G_Non_Labor_Res_Org_Id_Tbl(G_Trx_Import_Index) := Null;
1206 G_Quantity_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Quantity;
1207 G_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1208 G_Raw_Cost_Rate_Tbl(G_Trx_Import_Index) := Null;
1209 G_Burden_Cost_Tbl(G_Trx_Import_Index) := Null;
1210 G_Burden_Cost_Rate_Tbl(G_Trx_Import_Index) := Null;
1211 G_Expenditure_Comment_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Expenditure_Item_Comment;
1212 G_Gl_Date_Tbl(G_Trx_Import_Index) := Null;
1213 G_Transaction_Status_Code_Tbl(G_Trx_Import_Index) := 'P';
1214 G_Trans_Rejection_Code_Tbl(G_Trx_Import_Index) := Null;
1215 G_Orig_Trans_Reference_Tbl(G_Trx_Import_Index) := l_New_Orig_Trx_Ref;
1216 G_Unmatched_Neg_Txn_Flag_Tbl(G_Trx_Import_Index) := 'Y';
1217 G_Expenditure_Id_Tbl(G_Trx_Import_Index) := Null;
1218 G_Attribute_Category_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute_Category;
1219 G_Attribute1_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute1;
1220 G_Attribute2_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute2;
1221 G_Attribute3_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute3;
1222 G_Attribute4_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute4;
1223 G_Attribute5_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute5;
1224 G_Attribute6_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute6;
1225 G_Attribute7_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute7;
1226 G_Attribute8_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute8;
1227 G_Attribute9_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute9;
1228 G_Attribute10_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Attribute10;
1229 G_Dr_Code_Combination_Id_Tbl(G_Trx_Import_Index) := Null;
1230 G_Cr_Code_Combination_Id_Tbl(G_Trx_Import_Index) := Null;
1231 G_Cdl_System_Reference1_Tbl(G_Trx_Import_Index) := Null;
1232 G_Cdl_System_Reference2_Tbl(G_Trx_Import_Index) := Null;
1233 G_Cdl_System_Reference3_Tbl(G_Trx_Import_Index) := Null;
1234 G_Interface_Id_Tbl(G_Trx_Import_Index) := P_Xface_Id;
1235 G_Receipt_Currency_Amount_Tbl(G_Trx_Import_Index) := Null;
1236 G_Receipt_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1237 G_Receipt_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1238 G_Denom_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1239 G_Denom_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1240 G_Denom_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1241 G_Acct_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1242 G_Acct_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1243 G_Acct_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1244 G_Acct_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1245 G_Acct_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1246 G_Acct_Exch_Rounding_Limit_Tbl(G_Trx_Import_Index) := Null;
1247 G_Project_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1248 G_Project_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1249 G_Project_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1250 G_Project_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1251 G_Orig_Exp_Txn_Reference1_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Orig_Exp_Txn_Reference1;
1252 G_Orig_Exp_Txn_Reference2_Tbl(G_Trx_Import_Index) := Null;
1253 G_Orig_Exp_Txn_Reference3_Tbl(G_Trx_Import_Index) := Null;
1254 G_Orig_User_Exp_Txn_Ref_Tbl(G_Trx_Import_Index) := Null;
1255 G_Vendor_Number_Tbl(G_Trx_Import_Index) := Null;
1256 G_Vendor_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Vendor_Id; -- PA.M/CWK changes
1257 G_Override_To_Org_Name_Tbl(G_Trx_Import_Index) := Null;
1258 G_Override_To_Org_Id_Tbl(G_Trx_Import_Index) := Null;
1259 G_Reversed_Orig_Txn_Ref_Tbl(G_Trx_Import_Index) := Null;
1260 G_Billable_Flag_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Billable_Flag;
1261 G_ProjFunc_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1262 G_ProjFunc_Cost_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1263 G_ProjFunc_Cost_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1264 G_ProjFunc_Cost_Exch_Rate_Tbl(G_Trx_Import_Index) := Null;
1265 G_Project_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1266 G_Project_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1267 G_Assignment_Name_Tbl(G_Trx_Import_Index) := Null;
1268 G_Assignment_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Assignment_Id;
1269 G_Work_Type_Name_Tbl(G_Trx_Import_Index) := Null;
1270 G_Work_Type_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Work_Type_Id;
1271 G_Cdl_System_Reference4_Tbl(G_Trx_Import_Index) := Null;
1272 G_Accrual_Flag_Tbl(G_Trx_Import_Index) := Null;
1273 G_Last_Update_Date_Tbl(G_Trx_Import_Index) := sysdate;
1274 G_Last_Updated_By_Tbl(G_Trx_Import_Index) := P_User_Id;
1275 G_Creation_Date_Tbl(G_Trx_Import_Index) := sysdate;
1276 G_Created_By_Tbl(G_Trx_Import_Index) := P_User_Id;
1277 -- Begin PA.M/CWK changes
1278 G_PO_Number_Tbl(G_Trx_Import_Index) := Null;
1279 G_PO_Header_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.PO_Header_Id;
1280 G_PO_Line_Num_Tbl(G_Trx_Import_Index) := Null;
1281 G_PO_Line_Id_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.PO_Line_Id;
1282 G_PO_Price_Type_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.PO_Price_Type;
1283 G_Person_Type_Tbl(G_Trx_Import_Index) := l_New_Timecard_Rec.Person_Type;
1284 -- End PA.M/CWK changes
1285 G_Inventory_Item_Id_Tbl(G_Trx_Import_Index) := Null;
1286 G_WIP_Resource_Id_Tbl(G_Trx_Import_Index) := Null;
1287 G_Unit_Of_Measure_Tbl(G_Trx_Import_Index) := Null;
1288 -- 12i MOAC changes
1289 G_OU_Tbl(G_Trx_Import_Index) := G_Current_Org_Id;
1290
1291 G_Stage := 'Pl/sql record counter increment.';
1292 If G_Debug_Mode = 'Y' Then
1293 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1294 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1295 End If;
1296 G_Txn_Rec_Count := nvl(G_Txn_Rec_Count,0) + 1;
1297
1298 G_Stage := 'Store the Bb_Id and index in pl/sql table for use in tieback process.';
1299 If G_Debug_Mode = 'Y' Then
1300 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1301 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1302 End If;
1303 G_Trx_Inserted_Tab(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id).BB_Index := i;
1304
1305 End If;
1306
1307 G_Stage := 'Check if need to call bulk insert.';
1308 If G_Debug_Mode = 'Y' Then
1309 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1310 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1311 End If;
1312 If G_Txn_Rec_Count >= L_MAX_RECS_FOR_BULKINSERT Then
1313
1314 G_Stage := 'Call BulkInsertReset() procedure for insert.';
1315 If G_Debug_Mode = 'Y' Then
1316 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1317 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
1318 End If;
1319 Pa_Otc_Api.BulkInsertReset(P_Command => 'INSERT');
1320
1321 G_Stage := 'Store total records inserted. Reset counter to 0.';
1322 If G_Debug_Mode = 'Y' Then
1323 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1324 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
1325 End If;
1326 Pa_Trx_Import.G_Batch_Size := Nvl(Pa_Trx_Import.G_Batch_Size,0) + G_Txn_Rec_Count;
1327 G_Txn_Rec_Count := 0;
1328
1329 End If;
1330 End if; /* Bug 6698171, End of validation for terminated employee */
1331
1332 Exception
1333 When G_BAD_OTL_DATA Then
1334 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(i) := 'ERRORS';
1335 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(i) :=
1336 nvl(l_New_Timecard_Rec.Status,l_Old_Timecard_Rec.Status);
1337 G_Unhandled_Except_Cnt := G_Unhandled_Except_Cnt + 1;
1338
1339 G_Stage := 'Unhandled exception count is now ' || to_char(G_Unhandled_Except_Cnt);
1340 If G_Debug_Mode = 'Y' Then
1341 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1342 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
1343 End If;
1344
1345 If G_Unhandled_Except_Cnt > G_EXCEPT_CNT_ALLOWED Then
1346
1347 G_Stage := 'Unhandled exceptions count exceeds maximum allowed of ' ||
1348 to_char(G_EXCEPT_CNT_ALLOWED) || '. Raising user defined exception!';
1349 If G_Debug_Mode = 'Y' Then
1350 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1351 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
1352 End If;
1353
1354 Raise HXC_RETRIEVAL_MAX_ERRORS;
1355
1356 End If;
1357
1358 When Others Then
1359 Raise;
1360
1361 End;
1362
1363 G_Stage := 'Resetting the pl/sql new and old timecard record variables.';
1364 If G_Debug_Mode = 'Y' Then
1365 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1366 Pa_Cc_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
1367 End If;
1368 l_New_Timecard_Rec := l_Temp_Timecard_Rec;
1369 l_Old_Timecard_Rec := l_Temp_Timecard_Rec;
1370
1371 End Loop;
1372
1373 G_Stage := 'Exited the loop. Check if need to call bulk insert for any remaining pl/sql records.';
1374 If G_Debug_Mode = 'Y' Then
1375 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1376 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1377 End If;
1378
1379 If G_Txn_Rec_Count > 0 Then
1380
1381 G_Stage := 'Call bulk insert for the remaining pl/sql records.';
1382 If G_Debug_Mode = 'Y' Then
1383 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1384 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1385 End If;
1386 Pa_Otc_Api.BulkInsertReset(P_Command => 'INSERT');
1387
1388 G_Stage := 'Set the final records count for the next import phase. Reset counter.';
1389 If G_Debug_Mode = 'Y' Then
1390 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1391 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1392 End If;
1393 Pa_Trx_Import.G_Batch_Size := Nvl(Pa_Trx_Import.G_Batch_Size,0) + G_Txn_Rec_Count;
1394
1395 G_Txn_Rec_Count := 0;
1396
1397 End If;
1398
1399 G_Stage := 'This chunk has ' || to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.COUNT) ||
1400 ' records, of which ' || to_char(Pa_Trx_Import.G_Batch_Size) || ' are to be processed' ||
1401 ' in the next phase of Trx Import.';
1402 If G_Debug_Mode = 'Y' Then
1403 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1404 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1405 End If;
1406
1407 Else
1408
1409 G_Stage := 'Last chunk from OTL. Flag process we are done. No further records to process.';
1410 If G_Debug_Mode = 'Y' Then
1411 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1412 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1413 End If;
1414
1415 Pa_Trx_Import.G_Exit_Main := NULL;
1416 Pa_Trx_Import.G_Batch_Size := 0;
1417
1418 G_Stage := 'Call Hxc_Generic_Retrieval_Pkg.Update_Transaction_Status() one last time.';
1419 If G_Debug_Mode = 'Y' Then
1420 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1421 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1422 End If;
1423 Hxc_Integration_Layer_V1_Grp.Set_Parent_Statuses;
1424 Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status
1425 (P_Process => 'Projects Retrieval Process',
1426 P_Status => 'SUCCESS',
1427 P_Exception_Description => NULL);
1428
1429 End If; -- Are there records in the otl pl/sql tables to process
1430
1431 G_Stage := 'Leaving Upload_Otc_Timecards(), strip procedure from trackpath.';
1432 If G_Debug_Mode = 'Y' Then
1433 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1434 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1435 End If;
1436 Pa_Otc_Api.TrackPath('STRIP','Upload_Otc_Timecards');
1437
1438 Exception
1439
1440 When HXC_RETRIEVAL_MAX_ERRORS Then
1441
1442 fnd_message.set_name('HXC','HXC_RET_MAX_ERRORS');
1443 l_Error_Text := SUBSTR(fnd_message.get,1,2000);
1444
1445 Hxc_Integration_Layer_V1_Grp.Set_Parent_Statuses;
1446 Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status
1447 (P_Process => 'Projects Retrieval Process',
1448 P_Status => 'ERRORS',
1449 P_Exception_Description => l_Error_Text);
1450
1451 fnd_message.set_name('HXC','HXC_RET_MAX_ERRORS');
1452 fnd_message.raise_error;
1453
1454 When Others Then
1455
1456 If ( SQLERRM = 'ORA-20001: HXC_0012_GNRET_NO_TIMECARDS:' or
1457 SQLERRM = 'ORA-20001: HXC_0013_GNRET_NO_BLD_BLKS:' ) Then
1458
1459 -- Begin bug 3422899 Customer feedback on this bit of code shows that we should always
1460 -- suppress these 2 errors and let the report handle that there
1461 -- was no data to process.
1462 --
1463 -- The G_Processed_Import_Batch is FALSE then this is the first time thru the Trx
1464 -- Import loop which would mean we want to raise. If G_Processed_Import_Batch is TRUE
1465 -- that meains this is not the first time thru and we would not want to raise an error.
1466 -- The global variable is set to TRUE at the end of the Tieback_Otc_Timecards() procedure.
1467 -- If Not G_Processed_Import_Batch Then
1468 --
1469 -- Hxc_Integration_Layer_V1_Grp.Set_Parent_Statuses;
1470 -- Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status
1471 -- (P_Process => 'Projects Retrieval Process',
1472 -- P_Status => 'ERRORS',
1473 -- P_Exception_Description =>
1474 -- substr('Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage ||
1475 -- ' : ' || SQLERRM, 1, 2000));
1476 --
1477 -- Fnd_Message.Raise_Error;
1478 --
1479 -- End If;
1480
1481 If SQLERRM = 'ORA-20001: HXC_0012_GNRET_NO_TIMECARDS:' Then
1482
1483 fnd_message.set_name('HXC','HXC_0012_GNRET_NO_TIMECARDS');
1484 Else
1485
1486 fnd_message.set_name('HXC','HXC_0013_GNRET_NO_BLD_BLKS');
1487
1488 End If;
1489 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || fnd_message.get;
1490 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1491
1492 -- End bug 3422899
1493
1494 Else
1495
1496 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM;
1497 Hxc_Integration_Layer_V1_Grp.Set_Parent_Statuses;
1498 Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status
1499 (P_Process => 'Projects Retrieval Process',
1500 P_Status => 'ERRORS',
1501 P_Exception_Description =>
1502 substr('Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM, 1, 2000));
1503 Raise;
1504
1505 End If;
1506
1507 End Upload_Otc_Timecards;
1508
1509
1510 -- =======================================================================
1511 -- Start of Comments
1512 -- API Name : Build_Reverse_Item
1513 -- Type : Private
1514 -- Pre-Reqs : None
1515 -- Type : Procedure
1516 -- Function : This procedure is called when need to reverse expenditure_item
1517 -- already imported into projects and need to create a record to
1518 -- insert into pa_transaction_interface table for this.
1519 -- Conditions : 1. Deleted the original item
1520 -- called 2. Changed either project,
1521 -- task,
1522 -- expenditure_type,
1523 -- system_linkage_function,
1524 -- quantity
1525 --
1526 -- Parameters :
1527 -- IN
1528 -- P_Old_Orig_Trx_Ref Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
1529 -- P_New_Orig_Trx_Ref Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
1530 -- P_Batch_Name Pa_Transaction_Interface_All.Batch_Name%TYPE
1531 -- P_User_Id Pa_Expenditure_Items_All.Last_Updated_By%TYPE
1532 -- P_Orig_Exp_Txn_Reference1 Pa_Expenditures_All.Orig_Exp_Txn_Reference1%TYPE
1533 -- P_Xface_Id Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE
1534
1535 /*------------------------------------------------------------------------- */
1536
1537 Procedure Build_Reverse_Item(
1538 P_Old_Orig_Trx_Ref IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE,
1539 P_New_Orig_Trx_Ref IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE,
1540 P_Batch_Name IN Pa_Transaction_Interface_All.Batch_Name%TYPE,
1541 P_User_Id IN Pa_Expenditure_Items_All.Last_Updated_By%TYPE,
1542 P_Orig_Exp_Txn_Reference1 IN Pa_Expenditures_All.Orig_Exp_Txn_Reference1%TYPE,
1543 P_Xface_Id IN Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE )
1544
1545 Is
1546
1547 l_txn_rowid RowId := Null;
1548 l_txn_xface_id Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE := Null;
1549
1550 l_Exp_End_Date Pa_Expenditures_All.Expenditure_Ending_Date%TYPE;
1551 l_Inc_By_Org_Id Hr_Organization_Units.Organization_Id%TYPE;
1552 l_Exp_Item_Date Pa_Expenditure_Items_All.Expenditure_Item_Date%TYPE;
1553 l_Proj_Id Pa_Projects_All.Project_Id%TYPE;
1554 l_Task_Id Pa_Tasks.Task_Id%TYPE;
1555 l_Exp_Type Pa_Expenditure_Types.Expenditure_Type%TYPE;
1556 l_Sys_Link Pa_Expenditure_Items_All.System_Linkage_Function%TYPE;
1557 l_Quantity Pa_Expenditure_Items_All.Quantity%TYPE;
1558 l_Inc_By_Person_Id Pa_Expenditures_All.Incurred_By_Person_Id%TYPE;
1559 l_Attribute_Category Pa_Expenditure_Items_All.Attribute_Category%TYPE;
1560 l_Attribute1 Pa_Expenditure_Items_All.Attribute1%TYPE;
1561 l_Attribute2 Pa_Expenditure_Items_All.Attribute2%TYPE;
1562 l_Attribute3 Pa_Expenditure_Items_All.Attribute3%TYPE;
1563 l_Attribute4 Pa_Expenditure_Items_All.Attribute4%TYPE;
1564 l_Attribute5 Pa_Expenditure_Items_All.Attribute5%TYPE;
1565 l_Attribute6 Pa_Expenditure_Items_All.Attribute6%TYPE;
1566 l_Attribute7 Pa_Expenditure_Items_All.Attribute7%TYPE;
1567 l_Attribute8 Pa_Expenditure_Items_All.Attribute8%TYPE;
1568 l_Attribute9 Pa_Expenditure_Items_All.Attribute9%TYPE;
1569 l_Attribute10 Pa_Expenditure_Items_All.Attribute10%TYPE;
1570 l_Assignment_Id Pa_Expenditure_Items_All.Assignment_Id%TYPE;
1571 l_Work_Type_Id Pa_Expenditure_Items_All.Work_Type_Id%TYPE;
1572 l_Billable_Flag Pa_Expenditure_Items_All.Billable_Flag%TYPE;
1573 l_Exp_Comment Pa_Expenditure_Comments.Expenditure_Comment%TYPE;
1574 -- Begin CWK changes PA.M
1575 l_Person_Type Pa_Expenditures_All.Person_Type%TYPE;
1576 l_PO_Line_Id Pa_Expenditure_Items_All.PO_Line_Id%TYPE;
1577 l_PO_Price_Type Pa_Expenditure_Items_All.PO_Price_Type%TYPE;
1578 l_Vendor_Id Pa_Expenditures_All.Vendor_id%TYPE;
1579 l_PO_Header_Id Number := Null;
1580 l_Dummy_Vendor_Id Number := Null;
1581 -- End CWK changes PA.M
1582 -- 12i changes
1583 l_Org_Id Number := Null;
1584
1585 Begin
1586
1587 G_Stage := 'Enter Build_Reverse_Item().';
1588 If G_Debug_Mode = 'Y' Then
1589 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1590 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1591 End If;
1592
1593 G_Stage := 'Add procedure to track path';
1594 If G_Debug_Mode = 'Y' Then
1595 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1596 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1597 End If;
1598 Pa_Otc_Api.TrackPath('ADD','Build_Reverse_Item');
1599
1600 G_Stage := 'Get needed data to build reversing item phase 1.';
1601 If G_Debug_Mode = 'Y' Then
1602 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1603 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1604 End If;
1605
1606 Select
1607 EI.Task_Id,
1608 EI.Project_Id, -- Changed from T.Project_Id
1609 E.Expenditure_Ending_Date,
1610 E.Incurred_By_Organization_Id,
1611 E.Incurred_By_Person_Id,
1612 EI.Expenditure_Item_Date,
1613 EI.Expenditure_Type,
1614 EI.System_Linkage_Function,
1615 -(EI.quantity),
1616 EI.Attribute_Category,
1617 EI.Attribute1,
1618 EI.Attribute2,
1619 EI.Attribute3,
1620 EI.Attribute4,
1621 EI.Attribute5,
1622 EI.Attribute6,
1623 EI.Attribute7,
1624 EI.Attribute8,
1625 EI.Attribute9,
1626 EI.Attribute10,
1627 EI.Assignment_Id,
1628 EI.Work_Type_Id,
1629 EI.Billable_Flag,
1630 EC.Expenditure_Comment,
1631 -- Begin CWK changes PA.M
1632 EI.PO_Line_Id,
1633 EI.PO_Price_Type,
1634 E.Person_Type,
1635 E.Vendor_Id,
1636 -- End CWK changes PA.M
1637 -- 12i changes
1638 ei.org_id
1639 Into
1640 l_Task_Id,
1641 l_Proj_Id,
1642 l_Exp_End_Date,
1643 l_Inc_By_Org_Id,
1644 l_Inc_By_Person_Id,
1645 l_Exp_Item_Date,
1646 l_Exp_Type,
1647 l_Sys_Link,
1648 l_Quantity,
1649 l_Attribute_Category,
1650 l_Attribute1,
1651 l_Attribute2,
1652 l_Attribute3,
1653 l_Attribute4,
1654 l_Attribute5,
1655 l_Attribute6,
1656 l_Attribute7,
1657 l_Attribute8,
1658 l_Attribute9,
1659 l_Attribute10,
1660 l_Assignment_Id,
1661 l_Work_Type_Id,
1662 l_Billable_Flag,
1663 l_Exp_Comment,
1664 -- Begin CWK changes PA.M
1665 l_PO_Line_Id,
1666 l_PO_Price_Type,
1667 l_Person_Type,
1668 l_Vendor_Id,
1669 -- End CWK changes PA.M
1670 -- 12i changes
1671 l_org_id
1672 From
1673 Pa_Expenditure_Items EI,
1674 Pa_Expenditure_Comments EC,
1675 Pa_Expenditures E
1676 -- 3457943 S.N.
1677 --Pa_Tasks T
1678 -- 3457943 E.N.
1679 Where
1680 -- 3457943 S.N.
1681 --T.Task_Id = EI.Task_Id
1682 -- 3457943 E.N.
1683 E.Expenditure_Id = EI.Expenditure_Id
1684 And EI.Expenditure_Item_Id = EC.Expenditure_Item_Id(+)
1685 And EI.Transaction_Source = 'ORACLE TIME AND LABOR'
1686 And EI.Orig_Transaction_Reference = P_Old_Orig_Trx_Ref
1687 And Nvl(EI.Net_Zero_Adjustment_Flag,'N') = 'N'
1688 And EI.Adjusted_Expenditure_Item_Id is Null;
1689
1690 G_Stage := 'Get Transaction Interface Id from sequence for reversing item.';
1691 If G_Debug_Mode = 'Y' Then
1692 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1693 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1694 End If;
1695
1696 Select Pa_Txn_Interface_S.NextVal
1697 Into l_Txn_Xface_Id
1698 From Dual;
1699
1700 If l_Person_Type = 'CWK' And l_PO_Line_Id Is Not Null Then
1701
1702 G_Stage := 'Get Supplier Info by calling GetPOInfo() 2.';
1703 If G_Debug_Mode = 'Y' Then
1704 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Stage;
1705 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1706 End If;
1707
1708 Pa_Otc_Api.GetPOInfo(
1709 P_Po_Line_Id => l_PO_Line_Id,
1710 X_Po_Header_Id => l_PO_Header_Id,
1711 X_Vendor_Id => l_Dummy_Vendor_Id);
1712
1713 End If;
1714
1715 G_Stage := 'Inserting reversing item into interface table BB/Ovn: ' || P_New_Orig_Trx_Ref ||
1716 ' for Resource_Id(Person_Id): ' || to_char(l_Inc_By_Person_Id);
1717 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Stage;
1718 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
1719
1720 G_Stage := 'Store record for reversing item into arrays for bulk insert later.';
1721 If G_Debug_Mode = 'Y' Then
1722 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1723 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1724 End If;
1725
1726 G_Trx_Import_Index := G_Trx_Import_Index + 1;
1727
1728 G_Txn_Interface_Id_Tbl(G_Trx_Import_Index) := l_Txn_Xface_Id;
1729 G_Transaction_Source_Tbl(G_Trx_Import_Index) := 'ORACLE TIME AND LABOR';
1730 G_User_Transaction_Source_Tbl(G_Trx_Import_Index) := Null;
1731 G_Batch_Name_Tbl(G_Trx_Import_Index) := P_Batch_Name;
1732 G_Expenditure_End_Date_Tbl(G_Trx_Import_Index) := l_Exp_End_Date;
1733 G_Person_Bus_Grp_Name_Tbl(G_Trx_Import_Index) := Null;
1734 G_Person_Bus_Grp_Id_Tbl(G_Trx_Import_Index) := Null;
1735 G_Employee_Number_Tbl(G_Trx_Import_Index) := Null;
1736 G_Person_Id_Tbl(G_Trx_Import_Index) := l_Inc_By_Person_Id;
1737 G_Organization_Name_Tbl(G_Trx_Import_Index) := Null;
1738 G_Organization_Id_Tbl(G_Trx_Import_Index) := l_Inc_By_Org_Id;
1739 G_Expenditure_Item_Date_Tbl(G_Trx_Import_Index) := l_Exp_Item_Date;
1740 G_Project_Number_Tbl(G_Trx_Import_Index) := Null;
1741 G_Project_Id_Tbl(G_Trx_Import_Index) := l_Proj_Id;
1742 G_Task_Number_Tbl(G_Trx_Import_Index) := Null;
1743 G_Task_Id_Tbl(G_Trx_Import_Index) := l_Task_Id;
1744 G_Expenditure_Type_Tbl(G_Trx_Import_Index) := l_Exp_Type;
1745 G_System_Linkage_Tbl(G_Trx_Import_Index) := l_Sys_Link;
1746 G_Non_Labor_Resource_Tbl(G_Trx_Import_Index) := Null;
1747 G_Non_Labor_Res_Org_Name_Tbl(G_Trx_Import_Index) := Null;
1748 G_Non_Labor_Res_Org_Id_Tbl(G_Trx_Import_Index) := Null;
1749 G_Quantity_Tbl(G_Trx_Import_Index) := l_Quantity;
1750 G_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1751 G_Raw_Cost_Rate_Tbl(G_Trx_Import_Index) := Null;
1752 G_Burden_Cost_Tbl(G_Trx_Import_Index) := Null;
1753 G_Burden_Cost_Rate_Tbl(G_Trx_Import_Index) := Null;
1754 G_Expenditure_Comment_Tbl(G_Trx_Import_Index) := l_Exp_Comment;
1755 G_Gl_Date_Tbl(G_Trx_Import_Index) := Null;
1756 G_Transaction_Status_Code_Tbl(G_Trx_Import_Index) := 'P';
1757 G_Trans_Rejection_Code_Tbl(G_Trx_Import_Index) := Null;
1758 G_Orig_Trans_Reference_Tbl(G_Trx_Import_Index) := P_New_Orig_Trx_Ref;
1759 G_Unmatched_Neg_Txn_Flag_Tbl(G_Trx_Import_Index) := 'N';
1760 G_Expenditure_Id_Tbl(G_Trx_Import_Index) := Null;
1761 G_Attribute_Category_Tbl(G_Trx_Import_Index) := l_Attribute_Category;
1762 G_Attribute1_Tbl(G_Trx_Import_Index) := l_Attribute1;
1763 G_Attribute2_Tbl(G_Trx_Import_Index) := l_Attribute2;
1764 G_Attribute3_Tbl(G_Trx_Import_Index) := l_Attribute3;
1765 G_Attribute4_Tbl(G_Trx_Import_Index) := l_Attribute4;
1766 G_Attribute5_Tbl(G_Trx_Import_Index) := l_Attribute5;
1767 G_Attribute6_Tbl(G_Trx_Import_Index) := l_Attribute6;
1768 G_Attribute7_Tbl(G_Trx_Import_Index) := l_Attribute7;
1769 G_Attribute8_Tbl(G_Trx_Import_Index) := l_Attribute8;
1770 G_Attribute9_Tbl(G_Trx_Import_Index) := l_Attribute9;
1771 G_Attribute10_Tbl(G_Trx_Import_Index) :=l_Attribute10;
1772 G_Dr_Code_Combination_Id_Tbl(G_Trx_Import_Index) := Null;
1773 G_Cr_Code_Combination_Id_Tbl(G_Trx_Import_Index) := Null;
1774 G_Cdl_System_Reference1_Tbl(G_Trx_Import_Index) := Null;
1775 G_Cdl_System_Reference2_Tbl(G_Trx_Import_Index) := Null;
1776 G_Cdl_System_Reference3_Tbl(G_Trx_Import_Index) := Null;
1777 G_Interface_Id_Tbl(G_Trx_Import_Index) := P_Xface_Id;
1778 G_Receipt_Currency_Amount_Tbl(G_Trx_Import_Index) := Null;
1779 G_Receipt_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1780 G_Receipt_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1781 G_Denom_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1782 G_Denom_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1783 G_Denom_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1784 G_Acct_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1785 G_Acct_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1786 G_Acct_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1787 G_Acct_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1788 G_Acct_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1789 G_Acct_Exch_Rounding_Limit_Tbl(G_Trx_Import_Index) := Null;
1790 G_Project_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1791 G_Project_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1792 G_Project_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1793 G_Project_Exchange_Rate_Tbl(G_Trx_Import_Index) := Null;
1794 G_Orig_Exp_Txn_Reference1_Tbl(G_Trx_Import_Index) := P_Orig_Exp_Txn_Reference1;
1795 G_Orig_Exp_Txn_Reference2_Tbl(G_Trx_Import_Index) := Null;
1796 G_Orig_Exp_Txn_Reference3_Tbl(G_Trx_Import_Index) := Null;
1797 G_Orig_User_Exp_Txn_Ref_Tbl(G_Trx_Import_Index) := Null;
1798 G_Vendor_Number_Tbl(G_Trx_Import_Index) := Null;
1799 G_Vendor_Id_Tbl(G_Trx_Import_Index) := l_Vendor_Id; -- PA.M/CWK changes
1800 G_Override_To_Org_Name_Tbl(G_Trx_Import_Index) := Null;
1801 G_Override_To_Org_Id_Tbl(G_Trx_Import_Index) := Null;
1802 G_Reversed_Orig_Txn_Ref_Tbl(G_Trx_Import_Index) := P_Old_Orig_Trx_Ref;
1803 G_Billable_Flag_Tbl(G_Trx_Import_Index) := l_Billable_Flag;
1804 G_ProjFunc_Currency_Code_Tbl(G_Trx_Import_Index) := Null;
1805 G_ProjFunc_Cost_Rate_Date_Tbl(G_Trx_Import_Index) := Null;
1806 G_ProjFunc_Cost_Rate_Type_Tbl(G_Trx_Import_Index) := Null;
1807 G_ProjFunc_Cost_Exch_Rate_Tbl(G_Trx_Import_Index) := Null;
1808 G_Project_Raw_Cost_Tbl(G_Trx_Import_Index) := Null;
1809 G_Project_Burdened_Cost_Tbl(G_Trx_Import_Index) := Null;
1810 G_Assignment_Name_Tbl(G_Trx_Import_Index) := Null;
1811 G_Assignment_Id_Tbl(G_Trx_Import_Index) := l_Assignment_Id;
1812 G_Work_Type_Name_Tbl(G_Trx_Import_Index) := Null;
1813 G_Work_Type_Id_Tbl(G_Trx_Import_Index) := l_Work_Type_Id;
1814 G_Cdl_System_Reference4_Tbl(G_Trx_Import_Index) := Null;
1815 G_Accrual_Flag_Tbl(G_Trx_Import_Index) := Null;
1816 G_Last_Update_Date_Tbl(G_Trx_Import_Index) := SysDate;
1817 G_Last_Updated_By_Tbl(G_Trx_Import_Index) := P_User_Id;
1818 G_Creation_Date_Tbl(G_Trx_Import_Index) := SysDate;
1819 G_Created_By_Tbl(G_Trx_Import_Index) := P_User_Id;
1820 -- Begin CWK changes PA.M
1821 G_PO_Number_Tbl(G_Trx_Import_Index) := Null;
1822 G_PO_Header_Id_Tbl(G_Trx_Import_Index) := l_PO_Header_Id;
1823 G_PO_Line_Num_Tbl(G_Trx_Import_Index) := Null;
1824 G_Person_Type_Tbl(G_Trx_Import_Index) := l_Person_Type;
1825 G_PO_Line_Id_Tbl(G_Trx_Import_Index) := l_PO_Line_Id;
1826 G_PO_Price_Type_Tbl(G_Trx_Import_Index) := l_PO_Price_Type;
1827 -- End CWK changes PA.M
1828 G_INVENTORY_ITEM_ID_Tbl(G_Trx_Import_Index) := Null;
1829 G_WIP_RESOURCE_ID_Tbl(G_Trx_Import_Index) := Null;
1830 G_UNIT_OF_MEASURE_Tbl(G_Trx_Import_Index) := Null;
1831 -- 12i MOAC changes
1832 G_OU_Tbl(G_Trx_Import_Index) := l_org_id;
1833
1834 G_Txn_Rec_Count := Nvl(G_Txn_Rec_Count,0) + 1;
1835
1836 G_Stage := 'About to leave Build_Reverse_Item(), strip procedure from trackpath.';
1837 If G_Debug_Mode = 'Y' Then
1838 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1839 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1840 End If;
1841 Pa_Otc_Api.TrackPath('STRIP','Build_Reverse_Item');
1842
1843 G_Stage := 'Leaving Build_Reverse_Item().';
1844 If G_Debug_Mode = 'Y' Then
1845 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1846 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1847 End If;
1848
1849 Exception
1850 When others then
1851 Raise;
1852
1853 End Build_Reverse_Item;
1854
1855
1856 -- =======================================================================
1857 -- Start of Comments
1858 -- API Name : UpdateChangedOrigTxn
1859 -- Type : Private
1860 -- Pre-Reqs : None
1861 -- Type : Procedure
1862 -- Function : This procedure is used to update the expenditure item directly
1863 -- for an item that has not being reversed but ONLY the
1864 -- item comment has been changed and/or the DFF has been changed.
1865 -- No record will be inserted into table pa_transaction_interface.
1866 --
1867 -- Values for parameter P_Comment_or_Dff
1868 -- -------------------------------------
1869 -- C for Comment
1870 -- D for Dff
1871 -- B for Both
1872 --
1873 -- Parameters :
1874 -- IN P_Old_Orig_Txn_Ref - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
1875 -- P_New_Orig_Txn_Ref - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
1876 -- P_Comment_Or_Dff - Varchar2(1)
1877 -- P_Timecard_Rec - Pa_Otc_Api.Timecard_Rec
1878 -- P_User_Id - Pa_Expenditure_Items_All.Last_Updated_By%TYPE
1879 --
1880 -- OUT NONE
1881 --
1882
1883 /*--------------------------------------------------------------------------*/
1884
1885 Procedure UpdateChangedOrigTxn(
1886 P_Old_Orig_Txn_Ref IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE,
1887 P_New_Orig_Txn_Ref IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE,
1888 P_Comment_Or_Dff IN Varchar2,
1889 P_Timecard_Rec IN Pa_Otc_Api.Timecard_Rec,
1890 P_User_Id IN Pa_Expenditure_Items_All.Last_Updated_By%TYPE)
1891
1892 Is
1893
1894 l_Exp_Item_Id Pa_Expenditure_Items_All.Expenditure_Item_Id%TYPE := Null;
1895 l_RowId RowId;
1896 l_Last_Update_Login Pa_Expenditure_Items_All.Last_Update_Login%TYPE := to_Number(Fnd_Profile.Value('LOGIN_ID'));
1897 --Added for bug 4105561
1898 x_request_id NUMBER(15);
1899 x_program_application_id NUMBER(15);
1900 x_program_id NUMBER(15);
1901
1902 Cursor CheckExpComment (P_Ei_Id IN Number) Is
1903 Select
1904 Count(*)
1905 From
1906 Pa_Expenditure_Comments
1907 Where
1908 Expenditure_Item_Id = P_Ei_Id;
1909
1910 l_Comment_Count Number := 0;
1911
1912 Begin
1913
1914 G_Stage := 'Entering UpdateChangedOrigTxn(), add procedure to trackpath.';
1915 If G_Debug_Mode = 'Y' Then
1916 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1917 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1918 End If;
1919 Pa_Otc_Api.TrackPath('ADD','UpdateChangedOrigTxn');
1920
1921 G_Stage := 'Get Expenditure Item Id.';
1922 If G_Debug_Mode = 'Y' Then
1923 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1924 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1925 End If;
1926
1927 Select
1928 RowId,
1929 Expenditure_Item_Id
1930 Into
1931 l_RowId,
1932 l_Exp_Item_Id
1933 From
1934 Pa_Expenditure_Items_All
1935 Where
1936 Transaction_Source = 'ORACLE TIME AND LABOR'
1937 And Orig_Transaction_Reference = P_Old_Orig_Txn_Ref
1938 And Net_Zero_Adjustment_Flag = 'N'; -- Bug 3480159
1939
1940 --Added for bug 4105561
1941 X_request_id := FND_GLOBAL.CONC_REQUEST_ID ;
1942 X_program_id := FND_GLOBAL.CONC_PROGRAM_ID ;
1943 X_program_application_id := FND_GLOBAL.PROG_APPL_ID ;
1944
1945 /* Though the if clause below requires more code, it is
1946 * faster code due to potentially less updates taking place
1947 * when P_Comment_Or_Dff has a value of B.
1948 */
1949 G_Stage := 'What updating needs to be done.';
1950 If G_Debug_Mode = 'Y' Then
1951 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1952 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1953 End If;
1954
1955 If P_Comment_Or_Dff = 'C' Then
1956
1957 G_Stage := 'P_Comment_Or_Dff Is C: Update ei table.';
1958 If G_Debug_Mode = 'Y' Then
1959 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1960 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1961 End If;
1962
1963 Update Pa_Expenditure_Items_All
1964 Set Orig_Transaction_Reference = P_New_Orig_Txn_Ref,
1965 Last_Updated_By = P_User_Id,
1966 Last_Update_Date = SysDate,
1967 Last_Update_Login = l_Last_Update_Login,
1968 Request_id = x_request_id, --Added for bug 4105561
1969 Program_application_id = x_program_application_id,
1970 Program_id = x_program_id,
1971 Program_update_date = sysdate
1972 Where Rowid = l_RowId ;
1973
1974 Open CheckExpComment (P_Ei_Id => l_Exp_Item_Id);
1975 Fetch CheckExpComment into l_Comment_Count;
1976 Close CheckExpComment;
1977
1978 If l_Comment_Count = 0 Then
1979
1980 G_Stage := 'P_Comment_Or_Dff Is C: Insert record into exp comment table.';
1981 If G_Debug_Mode = 'Y' Then
1982 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
1983 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
1984 End If;
1985
1986 Insert into Pa_Expenditure_Comments
1987 ( Expenditure_Item_Id,
1988 Line_Number,
1989 Last_Update_Date,
1990 Last_Updated_By,
1991 Creation_Date,
1992 Created_By,
1993 Expenditure_Comment,
1994 Last_Update_Login,
1995 Request_Id,
1996 Program_Id,
1997 Program_Application_Id,
1998 Program_Update_Date )
1999 Values (
2000 l_Exp_Item_Id,
2001 10,
2002 SysDate,
2003 P_User_Id,
2004 SysDate,
2005 P_User_Id,
2006 P_Timecard_Rec.Expenditure_Item_Comment,
2007 l_Last_Update_Login,
2008 X_request_id, --Added for bug 4105561
2009 X_program_id,
2010 X_program_application_id,
2011 sysdate);
2012
2013 ElsIf l_Comment_Count > 0 And P_Timecard_Rec.Expenditure_Item_Comment Is Not Null Then -- Bug 3496762
2014
2015 G_Stage := 'P_Comment_Or_Dff Is C: Update exp comment table.';
2016 If G_Debug_Mode = 'Y' Then
2017 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2018 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2019 End If;
2020
2021 Update Pa_Expenditure_Comments
2022 Set Expenditure_Comment = P_Timecard_Rec.Expenditure_Item_Comment,
2023 Last_Updated_By = P_User_Id,
2024 Last_Update_Date = SysDate,
2025 Last_Update_Login = l_Last_Update_Login,
2026 Request_id = x_request_id, --Added for bug 4105561
2027 Program_application_id= x_program_application_id,
2028 Program_id = x_program_id,
2029 Program_update_date = sysdate
2030 Where Expenditure_Item_Id = l_exp_item_id ;
2031
2032 -- Begin bug 3496762
2033 ElsIf l_Comment_Count > 0 And P_Timecard_Rec.Expenditure_Item_Comment Is Null Then
2034
2035 G_Stage := 'P_Comment_Or_Dff Is B: Remove exp comment from table since comment has been updated to null by the user.';
2036 If G_Debug_Mode = 'Y' Then
2037 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2038 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2039 End If;
2040
2041 Delete From Pa_Expenditure_Comments
2042 Where Expenditure_Item_Id = l_Exp_Item_Id ;
2043
2044 -- End bug 3496762
2045 End If;
2046
2047 ElsIf P_Comment_Or_Dff = 'D' Then
2048
2049 G_Stage := 'P_Comment_Or_Dff Is D: Update ei table.';
2050 If G_Debug_Mode = 'Y' Then
2051 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2052 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2053 End If;
2054
2055 Update Pa_Expenditure_Items_All
2056 Set Orig_Transaction_Reference = P_New_Orig_Txn_Ref,
2057 Attribute_category = P_Timecard_Rec.Attribute_Category,
2058 Attribute1 = P_Timecard_Rec.Attribute1,
2059 Attribute2 = P_Timecard_Rec.Attribute2,
2060 Attribute3 = P_Timecard_Rec.Attribute3,
2061 Attribute4 = P_Timecard_Rec.Attribute4,
2062 Attribute5 = P_Timecard_Rec.Attribute5,
2063 Attribute6 = P_Timecard_Rec.Attribute6,
2064 Attribute7 = P_Timecard_Rec.Attribute7,
2065 Attribute8 = P_Timecard_Rec.Attribute8,
2066 Attribute9 = P_Timecard_Rec.Attribute9,
2067 Attribute10 = P_Timecard_Rec.Attribute10,
2068 Last_Updated_By = P_User_Id,
2069 Last_Update_Date = SysDate,
2070 Last_Update_Login = l_Last_Update_Login,
2071 Request_id = x_request_id, --Added for bug 4105561
2072 Program_application_id = x_program_application_id,
2073 Program_id = x_program_id,
2074 Program_update_date = sysdate
2075 Where RowId = l_RowId ;
2076
2077 ElsIf P_Comment_Or_Dff = 'B' Then
2078
2079 Open CheckExpComment (P_Ei_Id => l_Exp_Item_Id);
2080 Fetch CheckExpComment into l_Comment_Count;
2081 Close CheckExpComment;
2082
2083 If l_Comment_Count = 0 Then
2084
2085 G_Stage := 'P_Comment_Or_Dff Is B: Insert record into exp comment table.';
2086 If G_Debug_Mode = 'Y' Then
2087 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2088 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2089 End If;
2090
2091 Insert into Pa_Expenditure_Comments
2092 ( Expenditure_Item_Id,
2093 Line_Number,
2094 Last_Update_Date,
2095 Last_Updated_By,
2096 Creation_Date,
2097 Created_By,
2098 Expenditure_Comment,
2099 Last_Update_Login,
2100 Request_Id,
2101 Program_Id,
2102 Program_Application_Id,
2103 Program_Update_Date )
2104 Values (
2105 l_Exp_Item_Id,
2106 10,
2107 SysDate,
2108 P_User_Id,
2109 SysDate,
2110 P_User_Id,
2111 P_Timecard_Rec.Expenditure_Item_Comment,
2112 l_Last_Update_Login,
2113 X_request_id,
2114 X_program_id,
2115 X_program_application_id,
2116 sysdate);
2117
2118 ElsIf l_Comment_Count > 0 and P_Timecard_Rec.Expenditure_Item_Comment Is Not Null Then -- Bug 3496762
2119
2120 G_Stage := 'P_Comment_Or_Dff Is B: Update exp comment table.';
2121 If G_Debug_Mode = 'Y' Then
2122 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2123 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2124 End If;
2125
2126 Update Pa_Expenditure_Comments
2127 Set Expenditure_Comment = P_Timecard_Rec.Expenditure_Item_Comment,
2128 Last_Updated_By = P_User_Id,
2129 Last_Update_Date = SysDate,
2130 Last_Update_Login = l_Last_Update_Login,
2131 Request_id = x_request_id, --Added for bug 4105561
2132 Program_application_id= x_program_application_id,
2133 Program_id = x_program_id,
2134 Program_update_date = sysdate
2135 Where Expenditure_Item_Id = l_Exp_Item_Id ;
2136
2137 -- Begin bug 3496762
2138 ElsIf l_Comment_Count > 0 and P_Timecard_Rec.Expenditure_Item_Comment Is Null Then
2139
2140 G_Stage := 'P_Comment_Or_Dff Is B: Remove exp comment from table since comment has been updated to null by the user.';
2141 If G_Debug_Mode = 'Y' Then
2142 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2143 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2144 End If;
2145
2146 Delete From Pa_Expenditure_Comments
2147 Where Expenditure_Item_Id = l_Exp_Item_Id ;
2148
2149 -- End bug 3496762
2150 End If;
2151
2152 G_Stage := 'P_Comment_Or_Dff Is B: Update ei table.';
2153 If G_Debug_Mode = 'Y' Then
2154 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2155 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2156 End If;
2157
2158 Update Pa_Expenditure_Items_All
2159 Set Orig_Transaction_Reference = P_New_Orig_Txn_Ref,
2160 Attribute_category = P_Timecard_Rec.Attribute_Category,
2161 Attribute1 = P_Timecard_Rec.Attribute1,
2162 Attribute2 = P_Timecard_Rec.Attribute2,
2163 Attribute3 = P_Timecard_Rec.Attribute3,
2164 Attribute4 = P_Timecard_Rec.Attribute4,
2165 Attribute5 = P_Timecard_Rec.Attribute5,
2166 Attribute6 = P_Timecard_Rec.Attribute6,
2167 Attribute7 = P_Timecard_Rec.Attribute7,
2168 Attribute8 = P_Timecard_Rec.Attribute8,
2169 Attribute9 = P_Timecard_Rec.Attribute9,
2170 Attribute10 = P_Timecard_Rec.Attribute10,
2171 Last_Updated_By = P_User_Id,
2172 Last_Update_Date = SysDate,
2173 Last_Update_Login = l_Last_Update_Login,
2174 Request_id = x_request_id, --Added for bug 4105561
2175 Program_application_id = x_program_application_id,
2176 Program_id = x_program_id,
2177 Program_update_date = sysdate
2178 Where RowId = l_RowId ;
2179
2180 End If; -- P_Comment_Of_Dff is C or D or B
2181
2182 G_Stage := 'Leaving UpdateChangedOrigTxn(), strip procedure from trackpath.';
2183 Pa_Otc_Api.TrackPath('STRIP','UpdateChangedOrigTxn');
2184 If G_Debug_Mode = 'Y' Then
2185 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2186 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2187 End If;
2188
2189 Exception
2190 When Others Then
2191 Raise;
2192
2193 End UpdateChangedOrigTxn;
2194
2195
2196 -- =======================================================================
2197 -- Start of Comments
2198 -- API Name : Tieback_Otc_Timecards
2199 -- Type : Public
2200 -- Pre-Reqs : None
2201 -- Type : Procedure
2202 -- Function : This procedure is used to tieback timecards that have been
2203 -- interfaced to Oracle Projects successfully. This procedure
2204 -- will stamp the OTL timecard transaction status PL/SQL arrays with the fact that
2205 -- timecards retrieved have been sucessfully imported.
2206 -- We do not plan to deal with any exception handling so the transaction exception
2207 -- arrays will not be used. This is a entry point from the Trx Import
2208 -- post_import extension.
2209 -- We will use the transaction_source and P_Xface_Id and transaction_status_code of 'I'
2210 -- to pull the data from the interface table for review.
2211 -- Parameters :
2212 -- IN
2213 -- P_Transaction_source: Unique identifier for source of the txn
2214 -- P_batch: Batch Name to group txns into batches
2215 -- P_xface_id: Interface Id
2216 -- P_user_id: User Id
2217 -- OUT
2218 -- none
2219 /*--------------------------------------------------------------------------*/
2220
2221 Procedure Tieback_Otc_Timecards (
2222 P_Transaction_Source IN Pa_Transaction_Interface_All.Transaction_Source%TYPE,
2223 P_Batch IN Pa_Transaction_Interface_All.Batch_Name%TYPE,
2224 P_Xface_Id IN Pa_Transaction_Interface_All.Txn_Interface_Id%TYPE,
2225 P_User_Id IN Number)
2226
2227 Is
2228
2229 Cursor TrxRecords (P_Interface_Id IN Pa_Transaction_Interface_All.Interface_Id%TYPE) Is
2230 Select To_Number(Substr(Orig_Transaction_Reference,1,Instr(Orig_Transaction_Reference,':') - 1)) Detail_BB_Id,
2231 Transaction_Status_Code,
2232 Transaction_Rejection_Code,
2233 Txn_Interface_Id,
2234 Expenditure_Id,
2235 Expenditure_Item_Id,
2236 Orig_Transaction_Reference,
2237 Person_Id
2238 From
2239 Pa_Transaction_Interface
2240 Where
2241 Interface_Id = P_Interface_Id
2242 And Transaction_Source = 'ORACLE TIME AND LABOR'
2243 And Transaction_Status_Code in ('I','R')
2244 And Pa_Otc_Api.TrxInCurrentChunk(To_Number(Substr(Orig_Transaction_Reference,1,Instr(Orig_Transaction_Reference,':') - 1))) = 'Y'
2245 Order by 7,3; -- Bug 3355510
2246
2247 TrxRecord TrxRecords%ROWTYPE;
2248 l_Detail_Index Binary_Integer := Null;
2249 j Binary_Integer := Null;
2250
2251 Begin
2252
2253 G_Path := ' ';
2254
2255 G_Stage := 'Entering Tieback_Otc_Timecards().';
2256 If G_Debug_Mode = 'Y' Then
2257 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2258 Pa_CC_Utils.Log_Message(Pa_Debug.G_Err_Stage,0);
2259 End If;
2260 Pa_Otc_Api.TrackPath('ADD','Tieback_Otc_Timecards');
2261
2262 G_Stage := 'Open cursor TrxRecords.';
2263 If G_Debug_Mode = 'Y' Then
2264 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2265 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2266 End If;
2267
2268 Open TrxRecords(P_Interface_Id => P_Xface_Id);
2269
2270 G_Stage := 'Looping thru the Trx Records.';
2271 Loop
2272
2273 G_Stage := 'Fetch record from cursor TrxRecs.';
2274 If G_Debug_Mode = 'Y' Then
2275 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2276 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2277 End If;
2278
2279 Fetch TrxRecords Into TrxRecord;
2280 Exit When TrxRecords%Notfound;
2281
2282 If TrxRecord.Transaction_Status_Code = 'I' Then
2283
2284 G_Stage := 'Update Detail Status to SUCCESS for BB_Id: ' || to_char(TrxRecord.Detail_BB_Id) ||
2285 ' Index position is: ' || to_char((G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index));
2286 If G_Debug_Mode = 'Y' Then
2287 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2288 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2289 End If;
2290 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index) :=
2291 'SUCCESS';
2292
2293 ElsIf TrxRecord.Transaction_Status_Code = 'R' Then
2294
2295 G_Stage := 'Update Detail Status to ERRORS for BB_Id: ' || to_char(TrxRecord.Detail_BB_Id) ||
2296 ' Index position is: ' || to_char((G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index));
2297 If G_Debug_Mode = 'Y' Then
2298 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2299 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2300 End If;
2301
2302 /* Since we now have the looping functionality in Trx Import and we can't restrict the cursor
2303 * more than it currently is. We have to make sure that we don't try to update rejected
2304 * Trx records from other loops that have already been ran. They are at a status of 'R'
2305 * So we check to first see if it exists in the pl/sql table and then if it does
2306 * we update the otl pl/sql table accordingly run.
2307 */
2308
2309 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Status(G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index) := 'ERRORS';
2310
2311 If TrxRecord.Transaction_Rejection_Code is not null Then
2312
2313 Fnd_Message.Set_Name('PA', TrxRecord.Transaction_Rejection_Code);
2314 Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index) :=
2315 Substr(Fnd_Message.Get,1,2000);
2316
2317 -- Begin Bug 3355510 Don't needed to explicitly set the value to null with by default it already is. This was the problem.
2318 -- Else
2319 --
2320 -- Hxc_User_Type_Definition_Grp.T_Tx_Detail_Exception(G_Trx_Inserted_Tab(TrxRecord.Detail_BB_Id).BB_Index) := Null;
2321 -- End Bug 3355510
2322
2323 End If;
2324
2325 End If;
2326
2327 G_Stage := 'Tieback Results are Bb_Id/Ovn: ' || TrxRecord.Orig_Transaction_Reference ||
2328 ' Status(I is Success,R is Errors): ' || TrxRecord.Transaction_Status_Code ||
2329 ' Exception: ' || TrxRecord.Transaction_Rejection_Code ||
2330 ' Resource_Id(Person_Id): ' || TrxRecord.Person_Id ||
2331 ' Exp_Id(Null when Errors): ' || to_char(TrxRecord.Expenditure_Id) ||
2332 ' Ei_Id(Null when Errors): ' || to_char(TrxRecord.Expenditure_Item_Id);
2333 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Stage;
2334 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
2335
2336 End Loop;
2337
2338 G_Stage := 'Loop is done so lose cursor TrxRecs.';
2339 If G_Debug_Mode = 'Y' Then
2340 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2341 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2342 End If;
2343
2344 Close TrxRecords;
2345
2346 G_Stage := 'Update the Transaction_Status_Code for successful transactions in interface table.';
2347 If G_Debug_Mode = 'Y' Then
2348 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2349 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2350 End If;
2351
2352 Update Pa_Transaction_Interface
2353 Set
2354 Transaction_Status_Code = 'A'
2355 Where
2356 Interface_Id = P_Xface_Id
2357 And Transaction_Status_Code = 'I';
2358
2359 G_Stage := 'Loop thru and flag as success those building blocks where we directly updated the eis.';
2360 If G_Debug_Mode = 'Y' Then
2361 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2362 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2363 End If;
2364
2365 If G_Trx_Direct_Upd_Tab.COUNT > 0 Then
2366
2367 Loop
2368
2369 If j is null then
2370
2371 j := G_Trx_Direct_Upd_Tab.First;
2372
2373 Else
2374
2375 /* The use of NEXT allows us to avoid going thru pl/sql records that do not exist.
2376 * The pl/sql table will likely be sparcely populated and only want to deal with those
2377 * records that were inserted.
2378 * DO NOT CHANGE THIS SO WE DO NOT GET ANY NO_DATA_FOUND ERRORS.
2379 */
2380 j := G_Trx_Direct_Upd_Tab.Next(j);
2381
2382 End If;
2383
2384 G_Stage := 'Update Detail Status to SUCCESS for direct updated ei BB_Id: ' || to_char(j) ||
2385 ' Index position is: ' || to_char((G_Trx_Direct_Upd_Tab(j).BB_Index));
2386 If G_Debug_Mode = 'Y' Then
2387 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2388 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2389 End If;
2390
2391 Hxc_Generic_Retrieval_Pkg.T_Tx_Detail_Status(G_Trx_Direct_Upd_Tab(j).BB_Index) := 'SUCCESS';
2392 EXIT when j = G_Trx_Direct_Upd_Tab.Last;
2393
2394 End Loop;
2395
2396 End If;
2397
2398 G_Stage := 'Call OTL API to update transactions';
2399 If G_Debug_Mode = 'Y' Then
2400 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2401 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2402 End If;
2403
2404 Hxc_Integration_Layer_V1_Grp.Set_Parent_Statuses;
2405 Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status (
2406 P_Process => 'Projects Retrieval Process',
2407 P_Status => 'SUCCESS',
2408 P_Exception_Description => NULL);
2409
2410 G_Stage := 'Set the process import looping flag to true since completed at least loop thru.';
2411 If G_Debug_Mode = 'Y' Then
2412 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2413 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2414 End If;
2415 -- G_Processed_Import_Batch effects exception handling in the Upload_Otc_Timecard() procedure.
2416 -- When G_Processed_Import_Batch is TRUE then the exception handler in Upload_Otc_Timecard()
2417 -- will ignore 2 HXC exceptions that are thrown when there are no records found by the
2418 -- HXC Generic Retreival Process to pull for Import.
2419 G_Processed_Import_Batch := TRUE;
2420
2421 G_Stage := 'Leaving Tieback_Otc_Timecards(), strip procedure from trackpath.';
2422 If G_Debug_Mode = 'Y' Then
2423 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2424 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
2425 End If;
2426 Pa_Otc_Api.TrackPath('STRIP','Tieback_Otc_Timecards');
2427
2428 Exception
2429 When Others Then
2430 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM;
2431 Hxc_Integration_Layer_V1_Grp.Update_Transaction_Status (
2432 P_Process => 'Projects Retrieval Process',
2433 P_Status => 'ERRORS',
2434 P_Exception_Description => Pa_Debug.G_err_Stage);
2435 RAISE;
2436
2437 End Tieback_Otc_Timecards;
2438
2439 -- =======================================================================
2440 -- Start of Comments
2441 -- API Name : DetermineDirectUpdate
2442 -- Type : Private
2443 -- Pre-Reqs : None
2444 -- Type : Procedure
2445 -- Function : This procedure determines if the expenditure item should be updated directly
2446 -- : or if a reversing entry and a new entry neeed to be inserted into table
2447 -- : pa_transaction_interface_all. This is done by comparing to see what has
2448 -- : actually changed. If only the dff and/or the item comment has changed and
2449 -- : nothing else then the item should be directly updated.
2450 --
2451 -- Parameters :
2452 -- IN
2453 -- P_New_Timecard_Rec - Pa_Otc_Api.Timecard_Rec
2454 -- P_Old_Timecard_Rec - Pa_Otc_Api.Timecard_Rec
2455 -- OUT
2456 -- P_Direct_Update_Flag - Boolean
2457 -- P_comment_or_dff - Varchar2
2458 -- B - Both comment and DFFs
2459 -- C - Comment only
2460 -- D - DFFs only
2461 --
2462 /*--------------------------------------------------------------------------*/
2463
2464 Procedure DetermineDirectUpdate(
2465 P_New_Timecard_Rec IN Pa_Otc_Api.Timecard_Rec,
2466 P_Old_Timecard_Rec IN Pa_Otc_Api.Timecard_Rec,
2467 P_Direct_Update_Flag OUT NOCOPY Boolean,
2468 P_Comment_Or_Dff OUT NOCOPY Varchar2) IS
2469
2470 l_Others_Changed Boolean := False;
2471 l_Comment_Changed Boolean := False;
2472 l_DFFs_Changed Boolean := False;
2473
2474 Begin
2475
2476 G_Stage := 'Entering DetermineDirectUpdate(), add procedure to trackpath.';
2477 If G_Debug_Mode = 'Y' Then
2478 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2479 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2480 End If;
2481 Pa_Otc_Api.TrackPath('ADD','DetermineDirectUpdate');
2482
2483 If P_New_Timecard_Rec.Project_Id <> P_Old_Timecard_Rec.Project_Id OR -- bug 3241052
2484 P_New_Timecard_Rec.Task_Id <> P_Old_Timecard_Rec.Task_Id OR -- changed from number to id
2485 P_New_Timecard_Rec.Expenditure_Type <> P_Old_Timecard_Rec.Expenditure_Type OR
2486 P_New_Timecard_Rec.Expenditure_Item_Date <> P_Old_Timecard_Rec.Expenditure_Item_Date OR
2487 P_New_Timecard_Rec.System_Linkage_Function <> P_Old_Timecard_Rec.System_Linkage_Function OR
2488 P_New_Timecard_Rec.Quantity <> P_Old_Timecard_Rec.Quantity OR
2489 P_New_Timecard_Rec.Billable_Flag <> P_Old_Timecard_Rec.Billable_Flag OR
2490 Nvl(P_New_Timecard_Rec.PO_Line_Id,-99999) <> Nvl(P_Old_Timecard_Rec.PO_Line_Id,-99999) OR
2491 Nvl(P_New_Timecard_Rec.PO_Price_Type,'-99999') <> Nvl(P_Old_Timecard_Rec.PO_Price_Type,'-99999') Then
2492
2493 G_Stage := 'Detail has changed.';
2494 If G_Debug_Mode = 'Y' Then
2495 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2496 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2497 End If;
2498
2499 l_Others_Changed := True;
2500
2501 End If;
2502
2503 If nvl(P_New_Timecard_Rec.Expenditure_Item_Comment,'-9999999999') <>
2504 nvl(P_Old_Timecard_Rec.Expenditure_Item_Comment,'-9999999999') Then
2505
2506 G_Stage := 'Comment has changed.';
2507 If G_Debug_Mode = 'Y' Then
2508 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2509 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2510 End If;
2511
2512 l_Comment_Changed := True;
2513
2514 End If;
2515
2516 If nvl(P_New_Timecard_Rec.Attribute_Category,'-9999999999') <>
2517 nvl(P_Old_Timecard_Rec.Attribute_Category,'-9999999999') OR
2518 nvl(P_New_Timecard_Rec.Attribute1,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute1,'-9999999999') OR
2519 nvl(P_New_Timecard_Rec.Attribute2,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute2,'-9999999999') OR
2520 nvl(P_New_Timecard_Rec.Attribute3,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute3,'-9999999999') OR
2521 nvl(P_New_Timecard_Rec.Attribute4,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute4,'-9999999999') OR
2522 nvl(P_New_Timecard_Rec.Attribute5,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute5,'-9999999999') OR
2523 nvl(P_New_Timecard_Rec.Attribute6,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute6,'-9999999999') OR
2524 nvl(P_New_Timecard_Rec.Attribute7,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute7,'-9999999999') OR
2525 nvl(P_New_Timecard_Rec.Attribute8,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute8,'-9999999999') OR
2526 nvl(P_New_Timecard_Rec.Attribute9,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute9,'-9999999999') OR
2527 nvl(P_New_Timecard_Rec.Attribute10,'-9999999999') <> nvl(P_Old_Timecard_Rec.Attribute10,'-9999999999') Then
2528
2529 G_Stage := 'DFFs have changed.';
2530 If G_Debug_Mode = 'Y' Then
2531 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2532 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2533 End If;
2534
2535 l_DFFs_Changed := True;
2536
2537 End If;
2538
2539 G_Stage := 'Determine change flag value.';
2540
2541 If l_Others_Changed Then
2542
2543 G_Stage := 'No Direct Update.';
2544 If G_Debug_Mode = 'Y' Then
2545 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2546 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2547 End If;
2548 /* No direct update since other columns have been updated besides
2549 * the comments and DFFs.
2550 */
2551 P_Direct_Update_Flag := FALSE;
2552
2553 ElsIf Not l_Others_Changed And (l_Comment_Changed Or l_DFFs_Changed) Then
2554
2555 /* Looks like the comment or DFFS where updated in
2556 * OTL so will do direct updating of the tables instead of
2557 * using TRX_IMPORT.
2558 */
2559
2560 G_Stage := 'Direct Update.';
2561 If G_Debug_Mode = 'Y' Then
2562 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2563 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2564 End If;
2565
2566 P_Direct_Update_Flag := TRUE;
2567
2568 If l_Comment_Changed And l_DFFs_Changed Then
2569
2570 G_Stage := 'Direct Update - Both.';
2571 If G_Debug_Mode = 'Y' Then
2572 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2573 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2574 End If;
2575 /* Update both the comment in the comment table and
2576 * the DFFs in the ei table.
2577 */
2578 P_Comment_Or_Dff := 'B';
2579
2580 ElsIf l_Comment_Changed Then
2581
2582 G_Stage := 'Direct Update - Comment only.';
2583 If G_Debug_Mode = 'Y' Then
2584 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2585 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2586 End If;
2587 /* Only need to update the comment in the comment table */
2588 P_Comment_Or_Dff := 'C';
2589
2590 Else
2591
2592 G_Stage := 'Direct Update - DFFs only.';
2593 If G_Debug_Mode = 'Y' Then
2594 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2595 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2596 End If;
2597 /* Only need to update the DFFs in the ei table. */
2598 P_Comment_Or_Dff := 'D';
2599
2600 End If;
2601
2602 End If;
2603
2604 G_Stage := 'Leaving DetermineDirectUpdate(), strip procedure from trackpath.';
2605 If G_Debug_Mode = 'Y' Then
2606 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2607 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2608 End If;
2609 Pa_Otc_Api.TrackPath('STRIP','DetermineDirectUpdate');
2610
2611 Exception
2612 When Others Then
2613 Raise;
2614
2615 End DetermineDirectUpdate;
2616
2617
2618 -- =======================================================================
2619 -- Start of Comments
2620 -- API Name : PopulateProjRec
2621 -- Type : Private
2622 -- Pre-Reqs : None
2623 -- Type : Procedure
2624 -- Function : This procedure pulls all the data from the OTL pl/sql tables into a projects
2625 -- : oriented structure for easier processing. It will also get the TIME scope
2626 -- : BB_ID to be stored table pa_expenditures_all.orig_exp_txn_reference1.
2627 --
2628 -- Parameters :
2629 -- IN
2630 -- P_New_Old_BB - Varchar2 Allowed Values:
2631 -- Import values: 'OLD' 'NEW'
2632 -- Validation value:
2633 -- P_BB_Id - Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE
2634 -- P_Detail_Index - Binary_Integer
2635 -- P_Old_Detl_Ind - Binary_Integer
2636 -- OUT
2637 -- P_Timecard_Rec - Pa_Otc_Api.Timecard_Rec
2638 --
2639 /*--------------------------------------------------------------------------*/
2640
2641 Procedure PopulateProjRec(
2642 P_New_Old_BB IN Varchar2,
2643 P_BB_Id IN Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE,
2644 P_Detail_Index IN Binary_Integer,
2645 P_Old_Detl_Ind IN Binary_Integer,
2646 P_Timecard_Rec OUT NOCOPY Pa_Otc_Api.Timecard_Rec) IS -- 2672653
2647
2648 l_attribute_category Varchar2(100) := NULL;
2649 i Binary_Integer;
2650 j Binary_Integer;
2651 l_Rec_Found Boolean := False;
2652 l_error_text Varchar2(1800) := Null;
2653 l_Status_Code Varchar2(40) := Null;
2654 l_comment_text VARCHAR2(2000) := Null; -- bug 5412033
2655
2656 Begin
2657
2658 G_Stage := 'Entering PopulateProjRec(), add procedure to trackpath.';
2659 If G_Debug_Mode = 'Y' Then
2660 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2661 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2662 End If;
2663 Pa_Otc_Api.TrackPath('ADD','PopulateProjRec');
2664
2665 G_Stage := 'Set Timecard Rec to NULL.';
2666 If G_Debug_Mode = 'Y' Then
2667 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2668 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2669 End If;
2670
2671 P_Timecard_Rec := Null;
2672
2673 G_Stage := 'The current Detail Building Block Id being processed is: ' || to_char(P_BB_Id);
2674 If G_Debug_Mode = 'Y' Then
2675 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2676 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2677 End If;
2678
2679 G_Stage := 'Checking if processsing new or old Building Block.';
2680 If G_Debug_Mode = 'Y' Then
2681 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2682 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2683 End If;
2684
2685 If P_New_Old_BB = 'NEW' Then
2686
2687 G_Stage := 'Get New Detail Building Block data. Inc by person id(Resource Id): ' ||
2688 to_char(Hxc_Generic_Retrieval_Pkg.T_Detail_Bld_Blks(P_Detail_Index).Resource_Id);
2689 If G_Debug_Mode = 'Y' Then
2690 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2691 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2692 End If;
2693
2694 P_Timecard_Rec.Incurred_By_Person_Id := Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Resource_Id;
2695
2696 G_Stage := 'Get New Detail Building Block data. Quantity: ' ||
2697 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Measure);
2698 If G_Debug_Mode = 'Y' Then
2699 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2700 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2701 End If;
2702
2703 P_Timecard_Rec.Quantity := Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Measure;
2704
2705 /* begin bug 5412033 */
2706 G_Stage := 'Get New Detail Building Block data. Expenditure Item Comment: ' ||
2707 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text ||
2708 '(End of comment)';
2709 If G_Debug_Mode = 'Y' Then
2710 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2711 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2712 End If;
2713
2714 G_Stage := 'Assigning comment to local variable.';
2715 If G_Debug_Mode = 'Y' Then
2716 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2717 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2718 End If;
2719 l_comment_text := Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text;
2720
2721 G_Stage := 'Checking if comment is not null.';
2722 If G_Debug_Mode = 'Y' Then
2723 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2724 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2725 End If;
2726
2727 If l_comment_text is not Null Then
2728
2729 G_Stage := 'The comment is not null so determine the length of comment.';
2730 If G_Debug_Mode = 'Y' Then
2731 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2732 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2733 End If;
2734
2735 /* Bug 2930551 If the length of the comment_text is greater than 240 then we should only
2736 grab the first 240 characters. */
2737 -- begin bug 4926265
2738 -- If length(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text) > 240 Then
2739 -- If lengthb(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text) > 240 Then
2740 If lengthb(l_comment_text) > 240 Then
2741
2742 If G_Debug_Mode = 'Y' Then
2743 G_Stage := 'Comment_Text length > 240.';
2744 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2745 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2746 End If;
2747
2748 -- P_Timecard_Rec.Expenditure_Item_Comment :=
2749 -- substr(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text,1,240);
2750 -- P_Timecard_Rec.Expenditure_Item_Comment :=
2751 -- substrb(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text,1,240);
2752 -- end bug 4926265
2753 P_Timecard_Rec.Expenditure_Item_Comment := substrb(l_comment_text,1,240);
2754
2755 Else
2756
2757 If G_Debug_Mode = 'Y' Then
2758 G_Stage := 'Comment_Text length <= 240.';
2759 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2760 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2761 End If;
2762
2763 -- P_Timecard_Rec.Expenditure_Item_Comment :=
2764 -- Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Comment_Text;
2765 P_Timecard_Rec.Expenditure_Item_Comment := l_comment_text;
2766
2767 End If;
2768
2769 Else -- l_comment_text is Null
2770
2771 If G_Debug_Mode = 'Y' Then
2772 G_Stage := 'Setting the comment to null.';
2773 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2774 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2775 End If;
2776 P_Timecard_Rec.Expenditure_Item_Comment := Null;
2777
2778 End If; -- l_comment_text is not Null
2779 /* End bug 5412033 */
2780
2781 G_Stage := 'Get New Detail Building Block data. Exp Item Date, first attempt.';
2782 If G_Debug_Mode = 'Y' Then
2783 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2784 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2785 End If;
2786
2787 P_Timecard_Rec.Expenditure_Item_Date :=
2788 TRUNC(Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Start_Time);
2789
2790 If P_Timecard_Rec.Expenditure_Item_Date Is Null Then
2791
2792 G_Stage := 'Get New Detail Building Block data. Exp Item Date, second attempt.';
2793 If G_Debug_Mode = 'Y' Then
2794 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2795 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2796 End If;
2797
2798 i := 1;
2799
2800 G_Stage := 'Get New Detail Building Block data. Exp Item Date, via day scope building block.';
2801 If G_Debug_Mode = 'Y' Then
2802 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2803 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2804 End If;
2805
2806 While i <= Hxc_User_Type_Definition_Grp.T_Day_Bld_Blks.LAST and NOT l_Rec_Found
2807 Loop
2808
2809 G_Stage := 'Check if the current record is the correct DAY ' ||
2810 'record to grab Exp Item Date from.';
2811 If G_Debug_Mode = 'Y' Then
2812 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2813 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2814 End If;
2815
2816 If Hxc_User_Type_Definition_Grp.T_Day_Bld_Blks(i).BB_Id =
2817 Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(P_Detail_Index).Parent_BB_Id Then
2818
2819 G_Stage := 'Grab the Exp Item Date from new day building block record.';
2820 If G_Debug_Mode = 'Y' Then
2821 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2822 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2823 End If;
2824
2825 P_Timecard_Rec.Expenditure_Item_Date := Trunc(Hxc_User_Type_Definition_Grp.T_Day_Bld_Blks(i).Start_Time);
2826 l_Rec_Found := TRUE;
2827
2828 End If;
2829
2830 i := i + 1;
2831
2832 End Loop;
2833
2834 End If; -- P_Timecard_Rec.Expenditure_Item_Date Is Null
2835
2836 G_Stage := 'Exp Item Date(Detail Building Block Start Time): ' || to_char(P_Timecard_Rec.Expenditure_Item_Date);
2837 If G_Debug_Mode = 'Y' Then
2838 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2839 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2840 End If;
2841
2842 G_Stage := 'Get Expenditure Ending Date from new building block data.';
2843 If G_Debug_Mode = 'Y' Then
2844 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2845 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2846 End If;
2847
2848 If P_Timecard_Rec.Expenditure_Item_Date is not null Then
2849
2850 P_Timecard_Rec.Expenditure_Ending_date :=
2851 Pa_Utils.NewGetWeekEnding(P_Timecard_Rec.Expenditure_Item_Date);
2852
2853 End If;
2854
2855 -- Begin PA.M/CWK changes
2856 -- The person type can be returned as null and will be handled later in the code.
2857 G_Stage := 'Get Person_Type New.';
2858 If G_Debug_Mode = 'Y' Then
2859 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2860 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2861 End If;
2862
2863 P_Timecard_Rec.Person_Type := GetPersonType(P_Person_Id => P_Timecard_Rec.Incurred_By_Person_Id,
2864 P_Ei_Date => P_Timecard_Rec.Expenditure_Item_Date);
2865
2866 G_Stage := 'New Person_Type: ' || P_Timecard_Rec.Person_Type;
2867 If G_Debug_Mode = 'Y' Then
2868 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2869 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2870 End If;
2871 -- End PA.M/CWK changes
2872
2873 /* Pull data from the new detail_attributes pl/sql table */
2874 G_Stage := 'Get NEW detail bb attribution using for loop.';
2875 If G_Debug_Mode = 'Y' Then
2876 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2877 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2878 End If;
2879
2880 If G_Detail_Attr_Index = 0 Then
2881
2882 G_Detail_Attr_Index := 1;
2883
2884 End If;
2885
2886 i := G_Detail_Attr_Index;
2887
2888 G_Stage := 'Looping thru NEW attibution starting at index position: ' || to_char(i) ;
2889 If G_Debug_Mode = 'Y' Then
2890 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2891 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2892 End If;
2893
2894 G_Stage := 'Current position in NEW attribute pl/sql table bb_id value is: ' ||
2895 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).BB_Id);
2896 If G_Debug_Mode = 'Y' Then
2897 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2898 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2899 End If;
2900
2901 While i <= Hxc_User_Type_Definition_Grp.T_Detail_Attributes.LAST And
2902 Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).BB_Id = P_BB_Id
2903 Loop
2904
2905 If Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PROJECT_ID' Then
2906
2907 G_Stage := 'Retrieved Project Id: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2908 ' Index position: ' || to_char(i);
2909 If G_Debug_Mode = 'Y' Then
2910 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2911 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2912 End If;
2913
2914 P_Timecard_Rec.Project_Id := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2915
2916 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'TASK_ID' Then
2917
2918 G_Stage := 'Retrieved Task Id: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2919 ' Index position: ' || to_char(i);
2920 If G_Debug_Mode = 'Y' Then
2921 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2922 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2923 End If;
2924
2925 P_Timecard_Rec.Task_Id := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2926
2927 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'EXPENDITURE_TYPE' Then
2928
2929 G_Stage := 'Retrieved Expenditure Type: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2930 ' Index position: ' || to_char(i);
2931 If G_Debug_Mode = 'Y' Then
2932 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2933 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2934 End If;
2935
2936 P_Timecard_Rec.Expenditure_Type := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2937
2938 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'SYSTEM_LINKAGE_FUNCTION' Then
2939
2940 G_Stage := 'Retrieve System Linkage Function: ' ||
2941 Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2942 ' Index position: ' || to_char(i);
2943 If G_Debug_Mode = 'Y' Then
2944 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2945 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2946 End If;
2947
2948 P_Timecard_Rec.System_Linkage_Function := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2949
2950 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'OVERRIDING_APPROVER_PERSON_ID' Then
2951
2952 G_Stage := 'Retrieve Overidding Approver Person Id: ' ||
2953 Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2954 ' Index position: ' || to_char(i);
2955 If G_Debug_Mode = 'Y' Then
2956 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2957 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2958 End If;
2959
2960 P_Timecard_Rec.Override_Approver_Person_Id := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2961
2962 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'DUMMY PAEXPITDFF CONTEXT' Then
2963
2964 /* The value column contains the following format:
2965 * 'PAEXPITDFF - <attribute_category>'
2966 * So to get the attribute_category out will need to find the position
2967 * for ' - ' that is: '<space>-<space>' and then add 3.
2968 */
2969
2970 G_Stage := 'Get new attribute category: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
2971 ' Index position: ' || to_char(i);
2972 If G_Debug_Mode = 'Y' Then
2973 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2974 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2975 End If;
2976
2977 l_attribute_category := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
2978
2979 /* Need to check for null so as to avoid the unecessary use of errors using instr
2980 * to avoid unhandled exceptions.
2981 */
2982
2983 G_Stage := 'Get new attribute category, checking if Null.';
2984 If G_Debug_Mode = 'Y' Then
2985 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2986 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2987 End If;
2988
2989 If l_attribute_category is not null Then
2990
2991 G_Stage := 'Get new attribute category, Strip out prefix.';
2992 If G_Debug_Mode = 'Y' Then
2993 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
2994 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
2995 End If;
2996
2997 P_Timecard_Rec.Attribute_Category := substr(l_attribute_category,instr(l_attribute_category,' - ') + 3);
2998
2999 End If;
3000
3001 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE1' Then
3002
3003 G_Stage := 'Got new attribute1: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3004 ' Index position: ' || to_char(i);
3005 If G_Debug_Mode = 'Y' Then
3006 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3007 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3008 End If;
3009
3010 P_Timecard_Rec.Attribute1 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3011
3012 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE2' Then
3013
3014 G_Stage := 'Got new attribute2: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3015 ' Index position: ' || to_char(i);
3016 If G_Debug_Mode = 'Y' Then
3017 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3018 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3019 End If;
3020
3021 P_Timecard_Rec.Attribute2 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3022
3023 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE3' Then
3024
3025 G_Stage := 'Got new attribute3: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3026 ' Index position: ' || to_char(i);
3027 If G_Debug_Mode = 'Y' Then
3028 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3029 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3030 End If;
3031
3032 P_Timecard_Rec.Attribute3 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3033
3034 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE4' Then
3035
3036 G_Stage := 'Got new attribute4: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3037 ' Index position: ' || to_char(i);
3038 If G_Debug_Mode = 'Y' Then
3039 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3040 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3041 End If;
3042
3043 P_Timecard_Rec.Attribute4 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3044
3045 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE5' Then
3046
3047 G_Stage := 'Got new attribute5: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3048 ' Index position: ' || to_char(i);
3049 If G_Debug_Mode = 'Y' Then
3050 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3051 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3052 End If;
3053
3054 P_Timecard_Rec.Attribute5 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3055
3056 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE6' Then
3057
3058 G_Stage := 'Got new attribute6: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3059 ' Index position: ' || to_char(i);
3060 If G_Debug_Mode = 'Y' Then
3061 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3062 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3063 End If;
3064
3065 P_Timecard_Rec.Attribute6 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3066
3067 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE7' Then
3068
3069 G_Stage := 'Got new attribute7: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3070 ' Index position: ' || to_char(i);
3071 If G_Debug_Mode = 'Y' Then
3072 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3073 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3074 End If;
3075
3076 P_Timecard_Rec.Attribute7 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3077
3078 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE8' Then
3079
3080 G_Stage := 'Got new attribute8: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3081 ' Index position: ' || to_char(i);
3082 If G_Debug_Mode = 'Y' Then
3083 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3084 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3085 End If;
3086
3087 P_Timecard_Rec.Attribute8 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3088
3089 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE9' Then
3090
3091 G_Stage := 'Got new attribute9: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3092 ' Index position: ' || to_char(i);
3093 If G_Debug_Mode = 'Y' Then
3094 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3095 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3096 End If;
3097
3098 P_Timecard_Rec.Attribute9 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3099
3100 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PADFFATTRIBUTE10' Then
3101
3102 G_Stage := 'Got new attribute10: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3103 ' Index position: ' || to_char(i);
3104 If G_Debug_Mode = 'Y' Then
3105 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3106 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3107 End If;
3108
3109 P_Timecard_Rec.Attribute10 := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3110
3111 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'BILLABLE_FLAG' Then
3112
3113 G_Stage := 'Got new Billable Flag: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3114 ' Index position: ' || to_char(i);
3115 If G_Debug_Mode = 'Y' Then
3116 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3117 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3118 End If;
3119
3120 P_Timecard_Rec.Billable_Flag := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3121
3122 -- Begin PA.M/CWK changes
3123 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PO LINE ID' Then
3124
3125 G_Stage := 'Retrieved Po Line Id: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3126 ' Index position: ' || to_char(i);
3127 If G_Debug_Mode = 'Y' Then
3128 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3129 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3130 End If;
3131
3132 P_Timecard_Rec.PO_Line_Id := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3133
3134 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Field_Name) = 'PO PRICE TYPE' Then
3135
3136 G_Stage := 'Retrieved Po Price Type: ' || Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value ||
3137 ' Index position: ' || to_char(i);
3138 If G_Debug_Mode = 'Y' Then
3139 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3140 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3141 End If;
3142
3143 P_Timecard_Rec.PO_Price_Type := Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).Value;
3144
3145 -- End PA.M/CWK changes
3146 End If;
3147
3148 i := i + 1;
3149
3150 End Loop;
3151
3152 G_Stage := 'Exited loop. No more NEW attribution for BB_Id. Store the current index position ' ||
3153 to_char(i) || ' in global variable.';
3154 If G_Debug_Mode = 'Y' Then
3155 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3156 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3157 End If;
3158
3159 /* Note that variable G_Detail_Attr_Index is already pointing the the next building block.
3160 * This is due to the fact that we are using the while/loop structure and only leaving the loop
3161 * when the building block ids no longer match or have reach the end of the pl/sql table.
3162 */
3163
3164 G_Detail_Attr_Index := i;
3165
3166 G_Stage := 'Determine why exited loop looking for NEW record attribution.';
3167 If G_Debug_Mode = 'Y' Then
3168 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3169 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3170 End If;
3171
3172 If i > Hxc_User_Type_Definition_Grp.T_Detail_Attributes.LAST Then
3173
3174 G_Stage := 'Reached last record index position ' ||
3175 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Attributes.LAST) || ' ' ||
3176 'in NEW attrib pl/sql table.';
3177 If G_Debug_Mode = 'Y' Then
3178 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3179 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3180 End If;
3181
3182 ElsIf Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).BB_Id <> P_BB_Id Then
3183
3184 G_Stage := 'P_BB_Id: ' || to_char(P_BB_Id) || ' -- ' ||
3185 'BB_Id in NEW attrib pl/sql: ' ||
3186 to_char(Hxc_User_Type_Definition_Grp.T_Detail_Attributes(i).BB_Id) || '. ' ||
3187 'They do not match!';
3188 If G_Debug_Mode = 'Y' Then
3189 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3190 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3191 End If;
3192
3193 End If;
3194
3195 -- Begin PA.M/CWK changes
3196 G_Stage := 'Check Person Type is CWK and PO_Line_Id is Not Null New.';
3197 If G_Debug_Mode = 'Y' Then
3198 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3199 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3200 End If;
3201
3202 If P_Timecard_Rec.Person_Type = 'CWK' and P_Timecard_Rec.PO_Line_Id is Not Null Then
3203
3204 G_Stage := 'Calling Pa_Otc_Api.GetPOInfo() procedure New.';
3205 If G_Debug_Mode = 'Y' Then
3206 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3207 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3208 End If;
3209
3210 Pa_Otc_Api.GetPOInfo(
3211 P_Po_Line_Id => P_Timecard_Rec.PO_Line_Id,
3212 X_PO_Header_Id => P_Timecard_Rec.PO_Header_Id,
3213 X_Vendor_Id => P_Timecard_Rec.Vendor_Id);
3214
3215 G_Stage := 'Got new Vendor Id: ' || to_char(P_Timecard_Rec.Vendor_Id) || ' based on PO_Line_Id';
3216 If G_Debug_Mode = 'Y' Then
3217 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3218 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3219 End If;
3220
3221 Else
3222
3223 G_Stage := 'Set to null po info, vendor_id, and price_type New.';
3224 If G_Debug_Mode = 'Y' Then
3225 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3226 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3227 End If;
3228 P_Timecard_Rec.PO_Line_Id := NULL;
3229 P_Timecard_Rec.PO_Header_Id := NULL;
3230 P_Timecard_Rec.Vendor_Id := NULL;
3231 P_Timecard_Rec.PO_Price_Type := NULL;
3232
3233 End If;
3234 -- End PA.M/CWK changes
3235
3236 Elsif P_New_Old_BB = 'OLD' Then
3237
3238 G_Stage := 'Got Old Detail Building Block data. Incurred by Person Id(Resource Id): ' ||
3239 to_char(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Resource_Id);
3240 If G_Debug_Mode = 'Y' Then
3241 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3242 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3243 End If;
3244
3245 P_Timecard_Rec.Incurred_By_Person_Id := Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Resource_Id;
3246
3247 G_Stage := 'Got Old Detail Building Block data. Incurred by Person Id';
3248 If G_Debug_Mode = 'Y' Then
3249 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3250 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3251 End If;
3252
3253 G_Stage := 'Got Old Detail Building Block data. Quantity: ' ||
3254 to_char(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Measure);
3255 If G_Debug_Mode = 'Y' Then
3256 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3257 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3258 End If;
3259
3260 P_Timecard_Rec.Quantity := Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Measure;
3261
3262 /* Begin bug 5412033 */
3263 G_Stage := 'Get Old Detail Building Block data. Expenditure Item Comment: ' ||
3264 Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text ||
3265 '(End of comment)';
3266 If G_Debug_Mode = 'Y' Then
3267 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3268 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3269 End If;
3270
3271 G_Stage := 'Assigning Old comment to local variable.';
3272 If G_Debug_Mode = 'Y' Then
3273 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3274 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3275 End If;
3276 l_comment_text := Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text;
3277
3278 G_Stage := 'Checking if Old comment is not null.';
3279 If G_Debug_Mode = 'Y' Then
3280 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3281 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3282 End If;
3283
3284 If l_comment_text is not Null Then
3285
3286 G_Stage := 'The old comment is not null so determine the length of comment.';
3287 If G_Debug_Mode = 'Y' Then
3288 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3289 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3290 End If;
3291
3292 /* Bug 2930551 If the length of the comment_text is greater than 240 then we should only
3293 grab the first 240 characters. */
3294 -- begin bug 4926265
3295 -- If length(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text) > 240 Then
3296 -- If lengthb(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text) > 240 Then
3297 If lengthb(l_comment_text) > 240 Then
3298
3299 If G_Debug_Mode = 'Y' Then
3300 G_Stage := 'Old Comment_Text length > 240.';
3301 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3302 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3303 End If;
3304
3305 -- P_Timecard_Rec.Expenditure_Item_Comment :=
3306 -- substr(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text,1,240);
3307 -- P_Timecard_Rec.Expenditure_Item_Comment :=
3308 -- substrb(Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text,1,240);
3309 -- end bug 4926265
3310 P_Timecard_Rec.Expenditure_Item_Comment := substrb(l_comment_text,1,240);
3311
3312 Else
3313
3314 If G_Debug_Mode = 'Y' Then
3315 G_Stage := 'Old Comment_Text length <= 240.';
3316 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3317 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3318 End If;
3319
3320 -- P_Timecard_Rec.Expenditure_Item_Comment :=
3321 -- Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Comment_Text;
3322 P_Timecard_Rec.Expenditure_Item_Comment := l_comment_text;
3323
3324 End If;
3325
3326 Else -- l_comment_text is null
3327
3328 If G_Debug_Mode = 'Y' Then
3329 G_Stage := 'Setting the Old comment to null.';
3330 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3331 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3332 End If;
3333 P_Timecard_Rec.Expenditure_Item_Comment := Null;
3334
3335 End If; -- l_comment_text is not Null
3336 /* End Bug 5412033 */
3337
3338 G_Stage := 'Get Old Day Building Block data. Exp Item Date. First Attempt.';
3339 If G_Debug_Mode = 'Y' Then
3340 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3341 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3342 End If;
3343
3344 P_Timecard_Rec.Expenditure_Item_Date := Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Start_Time;
3345
3346 If P_Timecard_Rec.Expenditure_Item_Date Is Null Then
3347
3348 G_Stage := 'Get Old Day Building Block data. Exp Item Date. Second Attempt.';
3349 If G_Debug_Mode = 'Y' Then
3350 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3351 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3352 End If;
3353
3354 j := 1;
3355
3356 G_Stage := 'Get Old Detail Building Block data. Exp Item Date, via old day scope building block.';
3357 If G_Debug_Mode = 'Y' Then
3358 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3359 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3360 End If;
3361
3362 While j <= Hxc_User_Type_Definition_Grp.T_Old_Day_Bld_Blks.LAST and NOT l_Rec_Found
3363 Loop
3364
3365 G_Stage := 'Check if the current record is the correct DAY ' ||
3366 'record to grab Exp Item Date from.';
3367 If G_Debug_Mode = 'Y' Then
3368 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3369 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3370 End If;
3371
3372 If Hxc_User_Type_Definition_Grp.T_Day_Bld_Blks(j).BB_Id =
3373 Hxc_User_Type_Definition_Grp.T_Old_Detail_Bld_Blks(P_Old_Detl_Ind).Parent_BB_Id Then
3374
3375 G_Stage := 'Grab the Exp Item Date from old day building block record.';
3376 If G_Debug_Mode = 'Y' Then
3377 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3378 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3379 End If;
3380
3381 P_Timecard_Rec.Expenditure_Item_Date := Trunc(Hxc_User_Type_Definition_Grp.T_Old_Day_Bld_Blks(j).Start_Time);
3382 l_Rec_Found := TRUE;
3383
3384 End If;
3385
3386 j := j + 1;
3387
3388 End Loop;
3389
3390 End If;
3391
3392 G_Stage := 'Exp Item Date(Detail Building Block Start Time): ' || to_char(P_Timecard_Rec.Expenditure_Item_Date);
3393 If G_Debug_Mode = 'Y' Then
3394 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3395 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3396 End If;
3397
3398 G_Stage := 'Get Expenditure Ending Date for old building block data.';
3399 If G_Debug_Mode = 'Y' Then
3400 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3401 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3402 End If;
3403
3404 P_Timecard_Rec.Expenditure_Ending_date := Pa_Utils.NewGetWeekEnding(P_Timecard_Rec.Expenditure_Item_Date);
3405
3406 G_Stage := 'Old Index check and assignment for use in loop';
3407 If G_Debug_Mode = 'Y' Then
3408 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3409 Pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3410 End If;
3411
3412 -- Begin PA.M/CWK changes
3413 -- The person type can be returned as null and will be handled later in the code.
3414 G_Stage := 'Get Person_Type old.';
3415 If G_Debug_Mode = 'Y' Then
3416 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3417 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3418 End If;
3419
3420 P_Timecard_Rec.Person_Type := GetPersonType(P_Person_Id => P_Timecard_Rec.Incurred_By_Person_Id,
3421 P_Ei_Date => P_Timecard_Rec.Expenditure_Item_Date);
3422
3423 G_Stage := 'Old Person_Type: ' || P_Timecard_Rec.Person_Type;
3424 If G_Debug_Mode = 'Y' Then
3425 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3426 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3427 End If;
3428 -- End PA.M/CWK changes
3429
3430 If G_Old_Detail_Attr_Index = 0 Then
3431
3432 G_Old_Detail_Attr_Index := 1;
3433
3434 End If;
3435
3436 j := G_Old_Detail_Attr_Index;
3437
3438 /* Pull data from the detail_attributes pl/sql table */
3439 G_Stage := 'Looping thru OLD attibution starting at index position: ' || to_char(j) ;
3440 If G_Debug_Mode = 'Y' Then
3441 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3442 Pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3443 End If;
3444
3445 G_Stage := 'Current position in OLD attribute pl/sql table bb_id value: ' ||
3446 to_char(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).BB_Id);
3447 If G_Debug_Mode = 'Y' Then
3448 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3449 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3450 End If;
3451
3452 While j <= Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes.LAST and
3453 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).BB_Id = P_BB_Id
3454 Loop
3455
3456 If Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PROJECT_ID' Then
3457
3458 G_Stage := 'Got old Project Id: ' || Hxc_Generic_Retrieval_Pkg.T_Old_Detail_Attributes(j).Value ||
3459 ' Index position: ' || to_char(j);
3460 If G_Debug_Mode = 'Y' Then
3461 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3462 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3463 End If;
3464
3465 P_Timecard_Rec.Project_Id := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3466
3467 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'TASK_ID' Then
3468
3469 G_Stage := 'Got old Task Id: ' || Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3470 ' Index position: ' || to_char(j);
3471 If G_Debug_Mode = 'Y' Then
3472 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3473 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3474 End If;
3475
3476 P_Timecard_Rec.Task_Id := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3477
3478 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'EXPENDITURE_TYPE' Then
3479
3480 G_Stage := 'Got old Expenditure Type: ' ||
3481 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3482 ' Index position: ' || to_char(j);
3483 If G_Debug_Mode = 'Y' Then
3484 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3485 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3486 End If;
3487
3488 P_Timecard_Rec.Expenditure_Type := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3489
3490 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'SYSTEM_LINKAGE_FUNCTION' Then
3491
3492 G_Stage := 'Got old System Linkage Function: ' ||
3493 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3494 ' Index position: ' || to_char(j);
3495 If G_Debug_Mode = 'Y' Then
3496 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3497 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3498 End If;
3499
3500 P_Timecard_Rec.System_Linkage_Function := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3501
3502 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'OVERRIDING_APPROVER_PERSON_ID' Then
3503
3504 G_Stage := 'Got old Overriding Approver Person Id: ' ||
3505 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3506 ' Index position: ' || to_char(j);
3507 If G_Debug_Mode = 'Y' Then
3508 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3509 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3510 End If;
3511
3512 P_Timecard_Rec.Override_Approver_Person_Id := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3513
3514 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'DUMMY PAEXPITDFF CONTEXT' Then
3515
3516 /* The value column contains the following format:
3517 * 'PAEXPITDFF - <attribute_category>'
3518 * So to get the attribute_category out will need to find the position
3519 * for ' - ' that is: '<space>-<space>' and then add 3.
3520 */
3521
3522 G_Stage := 'Get old attribute category info: ' ||
3523 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3524 ' Index position: ' || to_char(j);
3525 If G_Debug_Mode = 'Y' Then
3526 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3527 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3528 End If;
3529
3530 l_attribute_category := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3531
3532 /* Need to check for null to avoid the unecessary errors using instr
3533 * avoiding unhandled exceptions.
3534 */
3535 G_Stage := 'Get old attribute category, checking if Null.'|| to_char(j);
3536 If G_Debug_Mode = 'Y' Then
3537 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3538 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3539 End If;
3540
3541 If l_attribute_category is not null Then
3542
3543 G_Stage := 'Get old attribute category, Strip out prefix.'|| to_char(j);
3544 If G_Debug_Mode = 'Y' Then
3545 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3546 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3547 End If;
3548
3549 P_Timecard_Rec.Attribute_Category := substr(l_attribute_category,instr(l_attribute_category,' - ') + 3);
3550
3551 End If;
3552
3553 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE1' Then
3554
3555 G_Stage := 'Got old Attribute1: ' ||
3556 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3557 ' Index position: ' || to_char(j);
3558 If G_Debug_Mode = 'Y' Then
3559 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3560 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3561 End If;
3562
3563 P_Timecard_Rec.Attribute1 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3564
3565 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE2' Then
3566
3567 G_Stage := 'Got old Attribute2: ' ||
3568 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3569 ' Index position: ' || to_char(j);
3570 If G_Debug_Mode = 'Y' Then
3571 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3572 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3573 End If;
3574
3575 P_Timecard_Rec.Attribute2 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3576
3577 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE3' Then
3578
3579 G_Stage := 'Got old Attribute3: ' ||
3580 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3581 ' Index position: ' || to_char(j);
3582 If G_Debug_Mode = 'Y' Then
3583 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3584 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3585 End If;
3586
3587 P_Timecard_Rec.Attribute3 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3588
3589 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE4' Then
3590
3591 G_Stage := 'Got old Attribute4: ' ||
3592 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3593 ' Index position: ' || to_char(j);
3594 If G_Debug_Mode = 'Y' Then
3595 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3596 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3597 End If;
3598
3599 P_Timecard_Rec.Attribute4 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3600
3601 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE5' Then
3602
3603 G_Stage := 'Got old Attribute5: ' ||
3604 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3605 ' Index position: ' || to_char(j);
3606 If G_Debug_Mode = 'Y' Then
3607 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3608 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3609 End If;
3610
3611 P_Timecard_Rec.Attribute5 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3612
3613 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE6' Then
3614
3615 G_Stage := 'Got old Attribute6: ' ||
3616 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3617 ' Index position: ' || to_char(j);
3618 If G_Debug_Mode = 'Y' Then
3619 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3620 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3621 End If;
3622
3623 P_Timecard_Rec.Attribute6 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3624
3625 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE7' Then
3626
3627 G_Stage := 'Got old Attribute7: ' ||
3628 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3629 ' Index position: ' || to_char(j);
3630 If G_Debug_Mode = 'Y' Then
3631 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3632 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3633 End If;
3634
3635 P_Timecard_Rec.Attribute7 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3636
3637 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE8' Then
3638
3639 G_Stage := 'Got old Attribute8: ' ||
3640 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3641 ' Index position: ' || to_char(j);
3642 If G_Debug_Mode = 'Y' Then
3643 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3644 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3645 End If;
3646
3647 P_Timecard_Rec.Attribute8 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3648
3649 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE9' Then
3650
3651 G_Stage := 'Got old Attribute9: ' ||
3652 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3653 ' Index position: ' || to_char(j);
3654 If G_Debug_Mode = 'Y' Then
3655 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3656 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3657 End If;
3658
3659 P_Timecard_Rec.Attribute9 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3660
3661 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PADFFATTRIBUTE10' Then
3662
3663 G_Stage := 'Got old Attribute10: ' ||
3664 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3665 ' Index position: ' || to_char(j);
3666 If G_Debug_Mode = 'Y' Then
3667 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3668 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3669 End If;
3670
3671 P_Timecard_Rec.Attribute10 := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3672
3673 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'BILLABLE_FLAG' Then
3674
3675 G_Stage := 'Got old Billable Flag: ' ||
3676 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3677 ' Index position: ' || to_char(j);
3678 If G_Debug_Mode = 'Y' Then
3679 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3680 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3681 End If;
3682
3683 P_Timecard_Rec.Billable_Flag := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3684
3685 -- Begin PA.M/CWK changes
3686 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PO LINE ID' Then
3687
3688 G_Stage := 'Got old Po Line Id: ' ||
3689 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3690 ' Index position: ' || to_char(j);
3691 If G_Debug_Mode = 'Y' Then
3692 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3693 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3694 End If;
3695
3696 P_Timecard_Rec.PO_Line_Id := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3697
3698 ElsIf Upper(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Field_Name) = 'PO PRICE TYPE' Then
3699
3700 G_Stage := 'Got old PO Price Type: ' ||
3701 Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value ||
3702 ' Index position: ' || to_char(j);
3703 If G_Debug_Mode = 'Y' Then
3704 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3705 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3706 End If;
3707
3708 P_Timecard_Rec.PO_Price_Type := Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).Value;
3709
3710 -- End PA.M/CWK changes
3711 End If;
3712
3713 j := j + 1;
3714
3715 End Loop;
3716
3717 G_Stage := 'Exited loop. No more OLD attribution for BB_Id. Store the current index position ' ||
3718 to_char(j) || ' in global variable.';
3719 If G_Debug_Mode = 'Y' Then
3720 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3721 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3722 End If;
3723
3724 /* Note that variable G_Old_Detail_Attr_Index is already pointing the the next building block.
3725 * This is due to the fact that we are using the while/loop structure and only leaving the loop
3726 * when the building block ids no longer match or have reach the end of the pl/sql table.
3727 */
3728
3729 G_Old_Detail_Attr_Index := j;
3730
3731 G_Stage := 'Determine why exited loop while looking for OLD record attribution.';
3732 If G_Debug_Mode = 'Y' Then
3733 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3734 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3735 End If;
3736
3737 If j > Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes.LAST Then
3738
3739 G_Stage := 'Reached last record index position ' ||
3740 to_char(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes.LAST) || ' ' ||
3741 'in OLD attrib pl/sql table.';
3742 If G_Debug_Mode = 'Y' Then
3743 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3744 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3745 End If;
3746
3747 ElsIf Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).BB_Id <> P_BB_Id Then
3748
3749 G_Stage := 'P_BB_Id: ' || to_char(P_BB_Id) || ' -- ' ||
3750 'BB_Id in OLD attrib pl/sql: ' ||
3751 to_char(Hxc_User_Type_Definition_Grp.T_Old_Detail_Attributes(j).BB_Id) || '. ' ||
3752 'They do not match!';
3753 If G_Debug_Mode = 'Y' Then
3754 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3755 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3756 End If;
3757
3758 End If;
3759
3760 -- Begin PA.M/CWK changes
3761 G_Stage := 'Check if P_Timecard_Rec.Person_Type is CWK and PO_Line_Id Is Not Null old.';
3762 If G_Debug_Mode = 'Y' Then
3763 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3764 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3765 End If;
3766 If P_Timecard_Rec.Person_Type = 'CWK' and P_Timecard_Rec.PO_Line_Id Is Not Null Then
3767
3768 G_Stage := 'Calling Pa_Otc_Api.GetPOInfo() procedure old.';
3769 If G_Debug_Mode = 'Y' Then
3770 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3771 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3772 End If;
3773
3774 Pa_Otc_Api.GetPOInfo(
3775 P_Po_Line_Id => P_Timecard_Rec.PO_Line_Id,
3776 X_PO_Header_Id => P_Timecard_Rec.PO_Header_Id,
3777 X_Vendor_Id => P_Timecard_Rec.Vendor_Id);
3778
3779 G_Stage := 'Got old Vendor Id: ' || to_char(P_Timecard_Rec.Vendor_Id) || ' based on PO_Line_Id';
3780 If G_Debug_Mode = 'Y' Then
3781 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3782 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3783 End If;
3784
3785 Else
3786
3787 G_Stage := 'Set po infor, vendor_id and price_type to null old.';
3788 If G_Debug_Mode = 'Y' Then
3789 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3790 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3791 End If;
3792
3793 P_Timecard_Rec.PO_Line_Id := NULL;
3794 P_Timecard_Rec.PO_Header_Id := NULL;
3795 P_Timecard_Rec.Vendor_Id := NULL;
3796 P_Timecard_Rec.PO_Price_Type := NULL;
3797
3798 End If;
3799 -- End PA.M/CWK changes
3800
3801 End If;
3802
3803 G_Stage := 'Checking that needed data was retrieved to properly process building block for import.';
3804 If G_Debug_Mode = 'Y' Then
3805 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3806 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3807 End If;
3808
3809 If P_Timecard_Rec.Project_Id is null and
3810 P_Timecard_Rec.Task_Id is null and
3811 P_Timecard_Rec.Expenditure_Type is null and
3812 P_Timecard_Rec.System_Linkage_Function is null and
3813 P_Timecard_Rec.Quantity is null and
3814 P_Timecard_Rec.Incurred_By_Person_Id is null and
3815 P_Timecard_Rec.Expenditure_Item_Date is null and
3816 P_Timecard_Rec.Expenditure_Ending_Date is null and
3817 P_Timecard_Rec.Billable_Flag is null and
3818 P_Timecard_Rec.Person_Type is null Then -- CWK changes PA.M
3819
3820 l_Status_Code := 'HXC_RET_NO_TIMECARD_DATA';
3821
3822 If P_New_Old_BB = 'OLD' Then
3823
3824 l_Status_Code := 'HXC_RET_NO_TIMECARD_DATA_OLD';
3825
3826 End If;
3827
3828 fnd_message.set_name('HXC', l_Status_Code);
3829 P_Timecard_Rec.Status := SubStr(Fnd_Message.Get,1,2000);
3830
3831 Elsif P_Timecard_Rec.Project_id is null and
3832 P_Timecard_Rec.Task_id is null and
3833 P_Timecard_Rec.Expenditure_Type is null and
3834 P_Timecard_Rec.System_Linkage_Function is null and
3835 P_Timecard_Rec.Billable_flag is null and
3836 P_Timecard_Rec.Person_Type is null Then -- CWK changes PA.M
3837
3838 l_Status_Code := 'HXC_RET_NO_ATT_DATA';
3839
3840 If P_New_Old_BB = 'OLD' Then
3841
3842 l_Status_Code := 'HXC_RET_NO_ATT_DATA_OLD';
3843
3844 End If;
3845 fnd_message.set_name('HXC',l_Status_Code);
3846 fnd_message.set_token('STAGE', '1');
3847 P_Timecard_Rec.Status := SubStr(Fnd_Message.Get,1,2000);
3848
3849 ElsIf P_Timecard_Rec.Quantity is null or
3850 P_Timecard_Rec.Incurred_By_Person_Id is null or
3851 P_Timecard_Rec.Expenditure_Item_Date is null Then
3852
3853 l_Status_Code := 'HXC_RET_NO_BLD_BLK_DATA';
3854
3855 If P_New_Old_BB = 'OLD' Then
3856
3857 l_Status_Code := 'HXC_RET_NO_BLD_BLK_DATA_OLD';
3858
3859 End If;
3860 fnd_message.set_name('HXC',l_Status_Code);
3861 fnd_message.set_token('STAGE', '1');
3862 P_Timecard_Rec.Status := SubStr(Fnd_Message.Get,1,2000);
3863
3864 ElsIf P_Timecard_Rec.Billable_flag is null or
3865 P_Timecard_Rec.Project_id is null or
3866 P_Timecard_Rec.Task_id is null or
3867 P_Timecard_Rec.Expenditure_Type is null or
3868 P_Timecard_Rec.System_Linkage_Function is null or
3869 (P_Timecard_Rec.Person_Type = 'CWK' and -- CWK changes PA.M
3870 P_Timecard_Rec.PO_Line_Id is Not Null and -- CWK changes PA.M -- Bug 3643126
3871 (P_Timecard_Rec.PO_Price_Type is Null or -- CWK changes PA.M
3872 P_Timecard_Rec.Vendor_Id Is Null)) or -- CWK changes PA.M
3873 P_Timecard_Rec.Person_Type is NULL Then -- CWK changes PA.M
3874
3875 l_Status_Code := 'HXC_RET_NO_ATT_DATA';
3876
3877 If P_New_Old_BB = 'OLD' Then
3878
3879 l_Status_Code := 'HXC_RET_NO_ATT_DATA_OLD';
3880
3881 End If;
3882 fnd_message.set_name('HXC',l_Status_Code);
3883 fnd_message.set_token('STAGE', '2');
3884 P_Timecard_Rec.Status := SubStr(Fnd_Message.Get,1,2000);
3885
3886 End If;
3887
3888 G_Stage := 'Leaving PopulateProjRec(), strip procedure from trackpath.';
3889 If G_Debug_Mode = 'Y' Then
3890 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3891 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3892 End If;
3893 Pa_Otc_Api.TrackPath('STRIP','PopulateProjRec');
3894
3895 Exception
3896 When Others Then
3897 l_error_text := SubStr('Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' -- ' || SqlErrM, 1, 1800);
3898 fnd_message.set_name('HXC', 'HXC_RET_UNEXPECTED_ERROR');
3899 fnd_message.set_token('ERR', l_Error_Text);
3900 P_Timecard_Rec.Status := SubStr(Fnd_Message.Get,1,2000);
3901
3902 If G_Debug_Mode = 'Y' Then
3903 Pa_Debug.G_err_Stage := P_Timecard_Rec.Status;
3904 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3905 End If;
3906
3907 l_error_text := 'Leaving PopulateProjRec() due to unhandled exception, strip procedure from trackpath.';
3908 If G_Debug_Mode = 'Y' Then
3909 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || l_error_text;
3910 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3911 End If;
3912 Pa_Otc_Api.TrackPath('STRIP','PopulateProjRec');
3913
3914 Raise G_BAD_OTL_DATA;
3915
3916 End PopulateProjRec;
3917
3918 -- ========================================================================
3919 -- Start Of Comments
3920 -- API Name : GetDetailIndex
3921 -- Type : Private
3922 -- Pre-Reqs : None
3923 -- Type : Procedure
3924 -- Return : n/a
3925 -- Function : This procedure finds the Index located in the detail pl/sql
3926 -- Hxc_Generic_Retrieval_Pkg.T_Detail_Bld_Blks table generated
3927 -- during the generic retrieval process for the
3928 -- Building_Block_Id that is passed in to it.
3929 --
3930 -- Parameters :
3931 -- IN
3932 -- P_Detail_BB_Id - Hxc_Time_Building_Blocks.Resource_Id%TYPE
3933 -- OUT
3934 -- X_Detail_Index - Binary_Integer
3935
3936 /*--------------------------------------------------------------------------*/
3937
3938
3939 Procedure GetDetailIndex( P_Detail_BB_Id IN Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE,
3940 X_Detail_Index OUT NOCOPY Binary_Integer)
3941
3942 Is
3943
3944 Begin
3945
3946 G_Stage := 'Entering procedure GetDetailIndex(), add procedure to trackpath.';
3947 If G_Debug_Mode = 'Y' Then
3948 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3949 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3950 End If;
3951 Pa_Otc_Api.TrackPath('ADD','GetDetailIndex');
3952
3953 G_Stage := 'Begin loop searching for the matching BB_Id.';
3954 If G_Debug_Mode = 'Y' Then
3955 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3956 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3957 End If;
3958
3959 For i in Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.FIRST .. Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks.LAST
3960 Loop
3961
3962 G_Stage := 'Determine if BB_Id in the pl/sql matches the one provided.';
3963 If G_Debug_Mode = 'Y' Then
3964 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3965 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3966 End If;
3967
3968 If Hxc_User_Type_Definition_Grp.T_Detail_Bld_Blks(i).BB_Id = P_Detail_BB_Id Then
3969
3970 G_Stage := 'Set Index to use since found the one needed.';
3971 If G_Debug_Mode = 'Y' Then
3972 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3973 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3974 End If;
3975
3976 X_Detail_Index := i;
3977
3978 G_Stage := 'Exiting the loop since found the index needed.';
3979 If G_Debug_Mode = 'Y' Then
3980 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3981 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3982 End If;
3983
3984 EXIT;
3985
3986 End If;
3987
3988 End Loop;
3989
3990 G_Stage := 'Leaving procedure GetDetailIndex().';
3991 If G_Debug_Mode = 'Y' Then
3992 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
3993 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
3994 End If;
3995 Pa_Otc_Api.TrackPath('STRIP','GetDetailIndex');
3996
3997 Exception
3998 When Others Then
3999 Raise;
4000
4001 End GetDetailIndex;
4002
4003
4004
4005
4006 /* UPDATE and VALIDATION ROUTINES */
4007
4008 -- ========================================================================
4009 -- Start Of Comments
4010 -- API Name : Projects_Retrieval_Process
4011 -- Type : Public
4012 -- Pre-Reqs : None
4013 -- Type : Function
4014 -- Return : Varchar2
4015 -- Function : This function is called to provide the retrieval process name so that the appropriate
4016 -- attribution is retrieved for validation.
4017 --
4018
4019 /*--------------------------------------------------------------------------*/
4020
4021
4022 Function Projects_Retrieval_Process RETURN Varchar2
4023
4024 Is
4025
4026 l_retrieval_process Hxc_Time_Recipients.Application_Retrieval_Function%TYPE;
4027
4028 Begin
4029
4030 l_retrieval_process := 'Projects Retrieval Process';
4031
4032 Return l_retrieval_process;
4033
4034 End Projects_Retrieval_Process;
4035
4036
4037 -- =======================================================================
4038 -- Start of Comments
4039 -- API Name : Update_Otc_Data
4040 -- Type : Public
4041 -- Pre-Reqs : None
4042 -- Type : Procedure
4043 -- Function : This procedure is called by the OTL client team server-side
4044 -- non-user data modification section of their code.
4045 -- The only intent of the Procedure is get the data in Hxc and
4046 -- then call the Private procedure Update_Process() to update the
4047 -- Billable_flag when appropriate. Then sent the changes back to Hxc.
4048 --
4049 -- Parameters :
4050 -- IN
4051 -- P_operation - Varchar2
4052
4053 /*------------------------------------------------------------------------- */
4054
4055 Procedure Update_Otc_Data
4056 (P_Operation IN Varchar2)
4057
4058 Is
4059
4060 l_Blocks Hxc_User_Type_Definition_Grp.Timecard_Info;
4061 l_Attributes Hxc_User_Type_Definition_Grp.App_Attributes_Info;
4062 l_Messages Hxc_User_Type_Definition_Grp.Message_Table;
4063
4064 Begin
4065
4066 G_Path := ' ';
4067
4068 G_Stage := 'Entering Update_Otc_Data() procedure.';
4069 Pa_Otc_Api.TrackPath('ADD','Update_Otc_Data');
4070
4071 If P_Operation <> 'MIGRATION' Then
4072
4073 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Get_App_Hook_Params()';
4074 Hxc_Integration_Layer_V1_Grp.Get_App_Hook_Params(
4075 P_Building_Blocks => l_Blocks,
4076 P_App_Attributes => l_Attributes,
4077 P_Messages => l_Messages);
4078
4079 G_Stage := 'Call the Upate_Process() to update the billable flag.';
4080 Pa_Otc_Api.Update_Process (
4081 P_Operation => P_Operation,
4082 P_Building_Blocks => l_Blocks,
4083 P_Attribute_Table => l_Attributes);
4084
4085 G_Stage := 'Call hxc_self_service_time_deposit.set_app_hook_params()';
4086 Hxc_Integration_Layer_V1_Grp.Set_App_Hook_Params(
4087 P_Building_Blocks => l_Blocks,
4088 P_App_Attributes => l_Attributes,
4089 P_Messages => l_Messages);
4090
4091 End If; -- P_Operation
4092
4093 G_Stage := 'Leaving Update_Otc_Data() procedure.';
4094 Pa_Otc_Api.TrackPath('STRIP','Update_Otc_Data');
4095
4096 Exception
4097 When Others Then
4098 Raise_Application_Error(-20010, 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_stage || ' : ' || SqlErrM );
4099
4100 End Update_Otc_Data;
4101
4102
4103 -- =======================================================================
4104 -- Start of Comments
4105 -- API Name : Update_Process
4106 -- Type : Private
4107 -- Pre-Reqs : None
4108 -- Type : Procedure
4109 -- Function : This procedure is called by public procedure Update_Process.
4110 -- The only intent of this procedure is to get the BILLABLE_FLAG
4111 -- from patc/patcx and return control back to the calling procedure.
4112 -- No handled errors will be returned to the OTL client team server code calling
4113 -- procedure. Unhandled exceptions will be allowed.
4114 --
4115 -- P_Operation: SAVE
4116 -- SUBMIT
4117 --
4118 -- Parameters:
4119 -- IN
4120 -- P_Operation -- Varchar2
4121 -- P_Building_Blocks -- Hxc_User_Type_Definition_Grp.Timecard_Info
4122 -- P_Attribute_Table -- Hxc_User_Type_Definition_Grp.App_Attributes_Info
4123 -- OUT
4124 -- P_Building_Blocks -- Hxc_User_Type_Definition_Grp.Timecard_Info
4125 -- P_Attribute_Table -- Hxc_User_Type_Definition_Grp.App_Attributes_Info
4126
4127 /*------------------------------------------------------------------------- */
4128
4129 Procedure Update_Process(
4130 P_Operation IN Varchar2,
4131 P_Building_Blocks IN OUT NOCOPY Hxc_User_Type_Definition_Grp.Timecard_Info, -- 2672653
4132 P_Attribute_Table IN OUT NOCOPY Hxc_User_Type_Definition_Grp.App_Attributes_Info) -- 2672653
4133
4134 Is
4135
4136 l_Proj_Attrib_Rec Pa_Otc_Api.Project_Attribution_Rec;
4137
4138 /* Stores a single record from the Building Block Table */
4139 l_Building_Block_Record Hxc_User_Type_Definition_Grp.Building_Block_Info;
4140
4141 l_BB_Detail_Changed Varchar2(1) := 'N'; -- The OTL item has changed.
4142 l_BB_Detail_Deleted Varchar2(1) := 'N'; -- The OTL item has been deleted.
4143 l_BB_Detail_Pass Varchar2(1) := 'N'; -- The OTL item has changed but values same as in Projects
4144 l_Data_Conflict_Flag Varchar2(1) := 'N'; -- If attempt to delete,update after already saved change or
4145 -- delete in OTL that should not have been allowed
4146 l_Adjusted_In_Projects Varchar2(1) := 'N'; -- The OTL item was adjusted in Projects already
4147
4148 l_Detail_Attr_Changed Varchar2(1) := 'N';
4149 l_Logical_Rec_Changed Varchar2(1) := 'N';
4150
4151 l_Msg_Name Varchar2(30) := Null;
4152 l_Msg_Application Varchar2(3) := Null;
4153 l_Msg_Type Varchar2(30) := Null;
4154 l_Msg_Token1_Name Varchar2(30) := Null;
4155 l_Msg_Token1_Value Varchar2(30) := Null;
4156 l_Msg_Token2_Name Varchar2(30) := Null;
4157 l_Msg_Token2_Value Varchar2(30) := Null;
4158 l_Msg_Token3_Name Varchar2(30) := Null;
4159 l_Msg_Token3_Value Varchar2(30) := Null;
4160 l_Msg_Count Number := Null;
4161 l_Error_Code Varchar2(30) := Null;
4162 l_Error_Type Varchar2(30) := Null;
4163 l_Status Varchar2(30) := Null;
4164
4165 i Binary_Integer := Null;
4166
4167 Begin
4168
4169 G_Stage := 'Entering procedure Update_Process().';
4170 Pa_Otc_Api.TrackPath('ADD','Update_Process');
4171
4172 G_Stage := 'Loop thru Building Blocks record to validate detail records.';
4173 -- For i in P_Building_Blocks.First .. P_Building_Blocks.Last
4174 Loop
4175
4176 If i is null Then
4177
4178 i := P_Building_Blocks.First;
4179
4180 Else
4181
4182 i := P_Building_Blocks.Next(i);
4183
4184 End If;
4185
4186 If P_Building_Blocks(i).Scope = 'DETAIL' Then
4187
4188 G_Stage := 'Copy current record in BB table to BB record variable.';
4189 l_Building_Block_Record := P_Building_Blocks(i);
4190 G_Stage := 'Pull out the data to friendlier formated variables.';
4191 /* Pull out the data to project friendly variables */
4192 /* Bug 4318639
4193 Pa_Otc_Api.RetrieveProjAttribution( */
4194 Pa_Otc_Api.RetrieveProjAttribForUpd(
4195 P_Building_Block_Rec => l_Building_Block_Record,
4196 P_Building_Block => P_Building_Blocks,
4197 P_Attribute_Table => P_Attribute_Table,
4198 X_Detail_Attr_Changed => l_Detail_Attr_Changed,
4199 X_Proj_Attrib_Rec => l_Proj_Attrib_Rec);
4200
4201 G_Stage := 'Determine building block change flag value to pass.';
4202 If l_Detail_Attr_Changed = 'Y' OR P_Building_Blocks(i).Changed = 'Y' Then
4203
4204 l_Logical_Rec_Changed := 'Y';
4205
4206 Else
4207
4208 l_Logical_Rec_Changed := 'N';
4209
4210 End If;
4211
4212 G_Stage := 'Determine the processing flags for using further in code.';
4213 Pa_Otc_Api.DetermineProcessingFlags(
4214 P_BB_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4215 P_BB_Ovn => P_Building_Blocks(i).Object_Version_Number,
4216 P_BB_Date_To => P_Building_Blocks(i).Date_To,
4217 P_BB_Changed => l_Logical_Rec_Changed,
4218 P_BB_New => P_Building_Blocks(i).New,
4219 P_Proj_Attribute_Rec => l_Proj_Attrib_Rec,
4220 P_Mode => 'UPDATE',
4221 P_Process_Flag => P_Building_Blocks(i).Process,
4222 X_BB_Detail_Changed => l_BB_Detail_Changed,
4223 X_Data_Conflict_Flag => l_Data_Conflict_Flag,
4224 X_BB_Detail_Deleted => l_BB_Detail_Deleted,
4225 X_Adj_in_Projects_Flag => l_Adjusted_In_Projects);
4226
4227 If l_BB_Detail_Deleted = 'N' and
4228 (l_BB_Detail_Changed = 'Y' or P_Building_Blocks(i).New = 'Y') and
4229 l_Adjusted_In_Projects = 'N' and
4230 l_Data_Conflict_Flag = 'N' Then
4231
4232 l_Status := Null;
4233
4234 G_Stage := 'Firing patc(). Only want the Billable Flag and no validation checked.';
4235
4236 Pa_Transactions_Pub.Validate_Transaction(
4237 X_Project_Id => l_Proj_Attrib_Rec.Project_Id,
4238 X_Task_Id => l_Proj_Attrib_Rec.Task_Id,
4239 X_Ei_Date => l_Proj_Attrib_Rec.Expenditure_Item_Date,
4240 X_Expenditure_Type => l_Proj_Attrib_Rec.Expenditure_Type,
4241 X_Non_Labor_Resource => Null,
4242 X_Person_Id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
4243 X_Billable_Flag => l_Proj_Attrib_Rec.Billable_Flag,
4244 X_Quantity => l_Proj_Attrib_Rec.Quantity,
4245 X_Transfer_Ei => Null,
4246 X_Incurred_By_Org_Id => Null, -- letting patc get it
4247 X_NL_Resource_Org_Id => Null,
4248 X_Transaction_Source => 'ORACLE TIME AND LABOR',
4249 X_Calling_Module => 'PAXVOTCB',
4250 X_Vendor_Id => l_Proj_Attrib_Rec.Vendor_Id, -- PA.M/CWK changes
4251 X_Entered_By_User_Id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
4252 X_Attribute_Category => l_Proj_Attrib_Rec.Attrib_Category,
4253 X_Attribute1 => l_Proj_Attrib_Rec.Attribute1,
4254 X_Attribute2 => l_Proj_Attrib_Rec.Attribute2,
4255 X_Attribute3 => l_Proj_Attrib_Rec.Attribute3,
4256 X_Attribute4 => l_Proj_Attrib_Rec.Attribute4,
4257 X_Attribute5 => l_Proj_Attrib_Rec.Attribute5,
4258 X_Attribute6 => l_Proj_Attrib_Rec.Attribute6,
4259 X_Attribute7 => l_Proj_Attrib_Rec.Attribute7,
4260 X_Attribute8 => l_Proj_Attrib_Rec.Attribute8,
4261 X_Attribute9 => l_Proj_Attrib_Rec.Attribute9,
4262 X_Attribute10 => l_Proj_Attrib_Rec.Attribute10,
4263 -- MC columns are NULL because OTL does not support
4264 -- multi-currency
4265 X_Denom_Currency_Code => Null,
4266 X_Acct_Currency_Code => Null,
4267 X_Denom_Raw_Cost => Null,
4268 X_Acct_Raw_Cost => Null,
4269 X_Acct_Rate_Type => Null,
4270 X_Acct_Rate_Date => Null,
4271 X_Acct_Exchange_Rate => Null,
4272 X_Msg_Application => l_Msg_Application,
4273 X_Msg_Type => l_Msg_Type,
4274 X_Msg_Token1 => l_Msg_Token1_Name,
4275 X_Msg_Token2 => l_Msg_Token2_Name,
4276 X_Msg_Token3 => l_Msg_Token3_Name,
4277 X_Msg_Count => l_Msg_Count,
4278 X_Msg_Data => l_Status,
4279 -- PA.M/CWK changes
4280 P_Po_Header_Id => l_Proj_Attrib_Rec.Po_Header_Id,
4281 P_Po_Line_Id => l_Proj_Attrib_Rec.Po_Line_Id,
4282 P_Person_Type => l_Proj_Attrib_Rec.Person_Type,
4283 P_Po_Price_Type => l_Proj_Attrib_Rec.Po_Price_Type,
4284 P_Sys_Link_Function => l_Proj_Attrib_Rec.Sys_Linkage_Func);
4285
4286
4287
4288 G_Stage := 'Check the returned status from patc.';
4289 If ( l_Status is null OR
4290 ( l_Status is NOT NULL AND nvl(l_Msg_Type,'W') <> 'E') ) Then /*Bug4518893*/
4291
4292 G_Stage := 'Patc returned status that is Null.';
4293
4294 -- Populate the Billable Flag in the pl/sql table
4295 -- Bug 4318639 Added IF condition to see if the billable_flag_index is populated.
4296 -- If no project related data was entered or there is no project_id attribution data in the
4297 -- attribution pl/sql table then we are able to build the billable_flag attribution record in
4298 -- Pa_Otc_Api.RetrieveProjAttribForUpd() so won't be able to assign the billable_flag to the
4299 -- attribution record.
4300 G_Stage := 'Check if billable_flag attribution pl/sql record exists.';
4301 If l_Proj_Attrib_Rec.Billable_Flag_Index is Not Null Then
4302 G_Stage := 'Populate the Billable Flag in the attribution pl/sql table record.';
4303 P_Attribute_Table(l_Proj_Attrib_Rec.Billable_Flag_Index).Attribute_Value := l_Proj_Attrib_Rec.Billable_Flag;
4304 End If;
4305
4306 End If; -- l_Status is null
4307
4308 End If; -- Detail building block not deleted and has changed.
4309
4310 End If; -- Detail Scope building block record
4311
4312 G_Stage := 'Check to exit loop.';
4313 Exit When i = P_Building_Blocks.Last;
4314
4315 End Loop; -- End of looping thru the building_block table
4316
4317 G_Stage := 'Leaving procedure Update_Process().';
4318 Pa_Otc_Api.TrackPath('STRIP','Update_Process');
4319
4320 Exception
4321 When Others Then
4322 Raise;
4323
4324 End Update_Process;
4325
4326
4327 -- =======================================================================
4328 -- Start of Comments
4329 -- API Name : Validate_Otc_Data
4330 -- Type : Public
4331 -- Pre-Reqs : None
4332 -- Type : Procedure
4333 -- Function : This procedure is called by the OTL client team server-side
4334 -- Validation section of their code. The only intent of the
4335 -- Procedure is manipulate the parameters passed in and then call
4336 -- the Private procedure Validate_Process() to Validate the data.
4337 --
4338 -- Parameters :
4339 -- IN
4340 -- P_operation - Varchar2
4341
4342 /*------------------------------------------------------------------------- */
4343
4344 Procedure Validate_Otc_Data
4345 (P_Operation IN Varchar2)
4346
4347 Is
4348
4349 l_Blocks Hxc_User_Type_Definition_Grp.Timecard_Info;
4350 l_Attributes Hxc_User_Type_Definition_Grp.App_Attributes_Info;
4351 l_Messages Hxc_User_Type_Definition_Grp.Message_Table;
4352
4353 Begin
4354
4355 G_Path := ' ';
4356
4357 G_Stage := 'Entering procedure Validate_Otc_Data().';
4358 Pa_Otc_Api.TrackPath('ADD','Validate_Otc_Data');
4359
4360 If P_Operation <> 'MIGRATION' Then
4361
4362 G_Stage := 'Call hxc_self_service_time_deposit.get_app_hook_params()';
4363 Hxc_Integration_Layer_V1_Grp.Get_App_Hook_Params(
4364 P_Building_Blocks => l_Blocks,
4365 P_App_Attributes => l_Attributes,
4366 P_Messages => l_Messages);
4367
4368 G_Stage := 'Call the Validate_Process() to validate data.';
4369 Pa_Otc_Api.Validate_Process (
4370 P_Operation => P_Operation,
4371 P_Building_Blocks => l_Blocks,
4372 P_Attribute_Table => l_Attributes,
4373 P_Message_Table => l_Messages);
4374
4375 If l_Messages.COUNT > 0 Then
4376
4377 G_Stage := 'Call hxc_self_service_time_deposit.set_app_hook_params()';
4378 Hxc_Integration_Layer_V1_Grp.Set_App_Hook_Params(
4379 P_Building_Blocks => l_Blocks,
4380 P_App_Attributes => l_Attributes,
4381 P_Messages => l_Messages);
4382
4383 End If; -- l_Message.COUNT
4384
4385 End If; -- P_Operation
4386
4387 G_Stage := 'Leaving procedure Validate_Otc_Data().';
4388 Pa_Otc_Api.TrackPath('STRIP','Validate_Otc_Data');
4389
4390 Exception
4391 When Others Then
4392 Raise_Application_Error(-20020,'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_stage || ' : ' || SQLERRM );
4393
4394 End Validate_Otc_Data;
4395
4396
4397 -- =======================================================================
4398 -- Start of Comments
4399 -- API Name : Validate_Process
4400 -- Type : Private
4401 -- Pre-Reqs : None
4402 -- Type : Procedure
4403 -- Function : This procedure validates the Timecard Header/lines
4404 -- information entered by the user.
4405 --
4406 -- P_Operation: SAVE
4407 -- SUBMIT
4408 --
4409 --
4410 -- Parameters :
4411 -- IN
4412 -- P_Operation -- Varchar2
4413 -- P_Building_Blocks -- Hxc_User_Type_Definition_Grp.Timecard_Info
4414 -- P_Attribute_Table -- Hxc_User_Type_Definition_Grp.App_Attributes_Info
4415 -- OUT
4416 -- P_Message_Table -- Hxc_User_Type_Definition_Grp.Message_Table
4417
4418 /*------------------------------------------------------------------------- */
4419
4420 Procedure Validate_Process(
4421 P_Operation IN Varchar2,
4422 P_Building_Blocks IN Hxc_User_Type_Definition_Grp.Timecard_Info,
4423 P_Attribute_Table IN Hxc_User_Type_Definition_Grp.App_Attributes_Info,
4424 P_Message_Table IN OUT NOCOPY Hxc_User_Type_Definition_Grp.Message_Table) -- 2672653
4425
4426 Is
4427
4428 l_Status Varchar2(30) := Null;
4429 l_Exp_Status Varchar2(30) := Null;
4430 l_Not_Bypass_Patc_Flag Boolean := True;
4431 l_Error_Level Varchar2(10) := Null; /* Added for Bug#2798986 */
4432
4433 /* The OTL item has been imported into projects and max orig_transaction_reference does not match
4434 * its equivalent in OTL( to_char(BB_ID) || to_char(BB_OVN) ) Then l_BB_Detail_Changed = 'Y' else 'N'
4435 */
4436 l_BB_Detail_Changed Varchar2(1) := 'N'; -- The OTL item has changed.
4437 l_BB_Detail_Deleted Varchar2(1) := 'N'; -- The OTL item has been deleted.
4438 l_Data_Conflict_Flag Varchar2(1) := 'N'; -- If attempt to delete,update after already saved change or
4439 -- delete in OTL that should not have been allowed
4440 l_Adjusted_In_Projects Varchar2(1) := 'N'; -- The OTL item was adjusted in Projects already
4441
4442 l_Detail_Attr_Changed Varchar2(1) := 'N';
4443 l_Logical_Rec_Changed Varchar2(1) := 'N';
4444
4445 l_Inc_By_Org_Id Pa_Expenditures_All.Incurred_By_Organization_Id%TYPE := Null;
4446 l_Job_Id Pa_Expenditure_Items_All.Job_Id%TYPE:= Null;
4447 l_Ovr_Approver_Person_Id Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE := Null;
4448
4449 l_Bill_Flag_Meaning Fnd_Lookups.Meaning%TYPE := Null;
4450
4451 l_Proj_Attrib_Rec Pa_Otc_Api.Project_Attribution_Rec;
4452
4453 l_Msg_Name VARCHAR2(30) := Null;
4454 l_Msg_Application VARCHAR2(2) := Null;
4455 l_Msg_Type VARCHAR2(30) := Null;
4456 l_Msg_Token1_Name VARCHAR2(30) := Null;
4457 l_Msg_Token1_Value VARCHAR2(2000) := Null;
4458 l_Msg_Token2_Name VARCHAR2(30) := Null;
4459 l_Msg_Token2_Value VARCHAR2(2000) := Null;
4460 l_Msg_Token3_Name VARCHAR2(30) := Null;
4461 l_Msg_Token3_Value VARCHAR2(2000) := Null;
4462 l_dummy_Message VARCHAR2(2000) := Null;
4463 l_Msg_Count NUMBER := Null;
4464 l_Error_Code VARCHAR2(30) := Null;
4465 l_Error_Type VARCHAR2(30) := Null;
4466
4467 l_Error_Stack Varchar2(2000);
4468 l_Old_Stack Varchar2(2000);
4469 l_Error_Stage Varchar2(2000);
4470 l_Error_Message Varchar2(2000);
4471
4472 -- Variables for dff validation
4473 l_recDFlexR Fnd_Dflex.Dflex_R;
4474 l_recDFlexDR Fnd_Dflex.Dflex_Dr;
4475 l_recContextsDR Fnd_Dflex.Contexts_Dr;
4476 l_arrDflex Pa_Self_Service_Dflex_Pub.Dflex_Array;
4477 l_strContext Varchar2(30); -- Changed length from 20 to 30. Bug 4036480
4478 l_strReferenceField Varchar2(200);
4479 l_bresult Boolean;
4480
4481 /* Variables needed for running of the summary-validation and Business Message APIs */
4482 l_Timecard_Table Pa_Otc_Api.Timecard_Table;
4483 l_Timecard_Table_Week Pa_Otc_Api.Timecard_Table;
4484 l_Weeks_To_Process Binary_Integer := 0;
4485 l_Exp_Ending_Date_Check Pa_Expenditures_All.Expenditure_Ending_Date%TYPE := Null;
4486 l_Timecard_Table_Index Binary_Integer := 0;
4487 l_Time_Building_Block_Id Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE := Null;
4488 l_Approval_Status Hxc_Time_Building_Blocks.Approval_Status%TYPE := Null;
4489
4490 TYPE Exp_End_Date_Rec IS Record (
4491 Expenditure_Ending_Date Pa_Expenditures_All.Expenditure_Ending_Date%TYPE,
4492 Incurred_By_Person_Id Pa_Expenditures_All.Incurred_By_Person_Id%TYPE);
4493
4494 TYPE Exp_End_Date_Tab IS Table OF Exp_End_Date_Rec
4495 INDEX BY Binary_Integer;
4496
4497 l_Detail_BB_Id Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE := Null;
4498 l_Detail_BB_Ovn Hxc_Time_Building_Blocks.Object_Version_Number%TYPE := Null;
4499
4500 l_Exp_End_Date_Tab Exp_End_Date_Tab;
4501
4502 /* Stores a single record from the Building Block Table */
4503 l_Building_Block_Record Hxc_User_Type_Definition_Grp.Building_Block_Info;
4504
4505 Cursor GetBillFlagMeaning(P_Lookup_Code IN VARCHAR2) Is
4506 Select
4507 Meaning
4508 From
4509 Fnd_Lookups
4510 Where
4511 Lookup_Type = 'YES_NO'
4512 And Lookup_Code = P_Lookup_Code;
4513
4514 /* For Bug 7645561*/
4515 Cursor Check_Term_with_pay(p_person_id IN NUMBER) is
4516 select max(person_id) from per_all_assignments_f paf,per_assignment_status_types past
4517 where paf.person_id = p_person_id
4518 and paf.assignment_status_type_id = past.assignment_status_type_id
4519 and past.per_system_status = 'TERM_ASSIGN';
4520 /* For Bug 7645561*/
4521
4522 test_term_with_pay Number := Null;
4523
4524 E_Unhandled_Exception Exception;
4525 E_Dff_Exception Exception;
4526
4527 l_Header_Pass_Val_Flag Varchar2(1) := Null;
4528 i Binary_Integer := Null;
4529
4530 Begin
4531
4532 G_Stage := 'Entering procedure Validate_Process().';
4533 Pa_Otc_Api.TrackPath('ADD','Validate_Process');
4534
4535 -- The out variables are used in the summary level validation and the business message
4536 -- API calls.
4537
4538 G_Stage := 'Find and Validate Header Record in the Building Blocks Pl/Sql table.';
4539 Pa_Otc_Api.FindandValidateHeader(
4540 P_Building_Blocks_Table => P_Building_Blocks,
4541 P_Attribute_Table => P_Attribute_Table,
4542 P_Message_Table => P_Message_Table,
4543 X_TimeBB_Id => l_Time_Building_Block_Id,
4544 X_Ovr_Approver_Person_Id => l_Ovr_Approver_Person_Id,
4545 X_Pass_Val_Flag => l_Header_Pass_Val_Flag,
4546 X_Approval_Status => l_Approval_Status);
4547
4548 If l_Header_Pass_Val_Flag = 'N' Then
4549
4550 RETURN;
4551
4552 End If;
4553
4554 -- Initializing dff validation procedures
4555 G_Stage := 'Call procedure Pa_Self_Service_Dflex_Pub.InitDFlex().';
4556 Pa_Self_Service_Dflex_Pub.InitDFlex(
4557 P_StrProductName => 'PA',
4558 P_StrDFlexName => 'PA_EXPENDITURE_ITEMS_DESC_FLEX',
4559 P_sErrorStack => l_Error_Stack,
4560 X_RecDFlexR => l_RecDFlexR,
4561 X_RecDFlexDR => l_RecDFlexDR,
4562 X_RecContextsDR => l_RecContextsDR,
4563 X_sErrorType => l_Error_Type,
4564 X_sErrorStack => l_Error_Stack,
4565 X_sErrorStage => l_Error_Stage,
4566 X_sErrorMessage => l_Error_Message);
4567
4568 --If an unexpected error occured in InitDFlex
4569 --then raise the exception.
4570
4571 If (l_Error_Type = 'U') Then
4572
4573 Raise E_Dff_Exception;
4574
4575 End If;
4576
4577 -- Call IsDFlexUsed to determine whether any desc flex segments
4578 -- are defined. If no, then it is not necessary to perform DFF
4579 -- validation.
4580
4581 G_Stage := 'Call Pa_Self_Service_Dflex_Pub.IsDFlexUsed().';
4582 Pa_Self_Service_Dflex_Pub.IsDFlexUsed(
4583 P_RecDFlexR => l_RecDFlexR,
4584 P_RecContextsDR => l_RecContextsDR,
4585 P_sErrorStack => l_Error_Stack,
4586 X_bResult => l_bResult,
4587 X_sErrorType => l_Error_Type,
4588 X_sErrorStack => l_Error_Stack,
4589 X_sErrorStage => l_Error_Stage,
4590 X_sErrorMessage => l_Error_Message);
4591
4592 --If an unexpected error occured in IsDFlexUsed then raise the exception.
4593
4594 If (l_Error_Type = 'U') Then
4595
4596 Raise E_Dff_Exception;
4597
4598 End If;
4599
4600 --Call GetDFlexReferenceField to determine the Reference field for the DFF, either
4601 --system_linkage_function or expenditure_type in this case.
4602
4603 G_Stage := 'Call Pa_Self_Service_Dflex_Pub.GetDFlexReferenceField().';
4604 Pa_Self_Service_DFlex_Pub.GetDFlexReferenceField(
4605 P_RecDFlexDR => l_RecDFlexDR,
4606 P_sErrorStack => l_Error_Stack,
4607 X_StrReferenceField => l_strReferenceField,
4608 X_sErrorType => l_Error_Type,
4609 X_sErrorStack => l_Error_Stack,
4610 X_sErrorStage => l_Error_Stage,
4611 X_sErrorMessage => l_Error_Message);
4612
4613 --If an unexpected error occured in GetDFlexReferenceField then raise the exception.
4614
4615 If (l_Error_Type = 'U') Then
4616
4617 Raise E_Dff_Exception;
4618
4619 End If;
4620
4621 G_Stage := 'Loop thru Building Blocks record to validate detail records.';
4622 Loop
4623
4624 If i is null Then
4625
4626 i := P_Building_Blocks.First;
4627
4628 Else
4629
4630 i := P_Building_Blocks.Next(i);
4631
4632 End If;
4633
4634 If P_Building_Blocks(i).Scope = 'DETAIL' Then
4635
4636 G_Stage := 'Init variables within loop.';
4637 l_Building_Block_Record := P_Building_Blocks(i);
4638 l_Detail_Attr_Changed := 'N';
4639
4640 G_Stage := 'Pull out the data to friendlier formated variables.';
4641 -- Pull out the data to project friendly variables
4642 Pa_Otc_Api.RetrieveProjAttribution(
4643 P_Building_Block_Rec => l_Building_Block_Record,
4644 P_Building_Block => P_Building_Blocks,
4645 P_Attribute_Table => P_Attribute_Table,
4646 X_Detail_Attr_Changed => l_Detail_Attr_Changed,
4647 X_Proj_Attrib_Rec => l_Proj_Attrib_Rec);
4648
4649 G_Stage := 'Determine record change flag value.';
4650 If l_Detail_Attr_Changed = 'Y' OR P_Building_Blocks(i).Changed = 'Y' Then
4651
4652 l_Logical_Rec_Changed := 'Y';
4653
4654 Else
4655
4656 l_Logical_Rec_Changed := 'N';
4657
4658 End If;
4659
4660 G_Stage := 'Determine the processing flags for use further in code.';
4661 Pa_Otc_Api.DetermineProcessingFlags(
4662 P_BB_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4663 P_BB_Ovn => P_Building_Blocks(i).Object_Version_Number,
4664 P_BB_Date_To => P_Building_Blocks(i).Date_To,
4665 P_BB_Changed => l_Logical_Rec_Changed,
4666 P_BB_New => P_Building_Blocks(i).New,
4667 P_Proj_Attribute_Rec => l_Proj_Attrib_Rec,
4668 P_Mode => 'VALIDATE',
4669 P_Process_Flag => P_Building_Blocks(i).Process,
4670 X_BB_Detail_Changed => l_BB_Detail_Changed,
4671 X_Data_Conflict_Flag => l_Data_Conflict_Flag,
4672 X_BB_Detail_Deleted => l_BB_Detail_Deleted,
4673 X_Adj_in_Projects_Flag => l_Adjusted_In_Projects);
4674
4675 -- If the Building Block(BB) can be adjusted in OTL then that will consistently be the case
4676 -- until the BB is imported into projects at which point the ei associated to the
4677 -- BB and Object_Version_Number combo can be adjusted or reversed out prior to any attempt to
4678 -- adjust the BB in OTL. Anotherwards, once adjusted on OTL then can't adjust in Projects
4679 -- and vice versa.
4680 --
4681 -- If l_Adjusted_In_Projects is 'Y' then
4682 -- An adjustment was made in Projects so can't adjust in OTL.
4683 -- If l_Adjusted_In_Projects is 'N' then
4684 -- No adjustment was made in projects so it can be adjusted in OTL
4685 -- or it is not in projects yet and can do whatever wanted.
4686 --
4687
4688 If l_Adjusted_In_Projects = 'Y' Then
4689
4690 G_Stage := 'Item is Adjusted.';
4691
4692 If l_BB_Detail_Deleted = 'Y' Then
4693
4694 G_Stage := 'Building Block has been deleted.';
4695
4696 -- Really don't need to process this record any further.
4697 -- The timecard cannot be save or submitted due to this. Period!
4698
4699 If l_Data_Conflict_Flag = 'Y' Then
4700
4701 G_Stage := 'Not allowed to delete Item In OTL data conflict - Inserting error rec.';
4702
4703 G_Msg_Tokens_Table.Delete;
4704
4705 -- Add record to error table.
4706 Pa_Otc_Api.Add_Error_To_Table(
4707 P_Message_Table => P_Message_Table,
4708 P_Message_Name => 'PA_TR_UNDO_DEL_IN_OTC',
4709 P_Message_Level => 'ERROR',
4710 P_Message_Field => NULL,
4711 P_Msg_Tokens => G_Msg_Tokens_Table,
4712 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4713 P_Time_Attribute_Id => NULL);
4714
4715 Else
4716
4717 G_Stage := 'Not allowed to Delete Item In OTL - Inserting error rec.';
4718 G_Msg_Tokens_Table.Delete;
4719
4720 -- Add record to error table.
4721 Pa_Otc_Api.Add_Error_To_Table(
4722 P_Message_Table => P_Message_Table,
4723 P_Message_Name => 'PA_NO_DEL_EX_ITEM',
4724 P_Message_Level => 'ERROR',
4725 P_Message_Field => NULL,
4726 P_Msg_Tokens => G_Msg_Tokens_Table,
4727 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4728 P_Time_Attribute_Id => NULL);
4729
4730 End If; -- Data Confict or SUBMIT
4731
4732 End If; -- l_BB_Detail_Deleted is Y
4733
4734 If l_BB_Detail_Changed = 'Y' and l_BB_Detail_Deleted = 'N' Then
4735
4736 If l_Data_Conflict_Flag = 'Y' Then
4737
4738 -- Really don't need to process this record any further.
4739 -- The timecard cannot be save due to this. Period!
4740
4741 G_Stage := 'Not allowed to Adjust Item In OTL confict - Inserting error rec.';
4742 G_Msg_Tokens_Table.Delete;
4743
4744 -- Add record to error table.
4745 Pa_Otc_Api.Add_Error_To_Table(
4746 P_Message_Table => P_Message_Table,
4747 P_Message_Name => 'PA_TR_UNDO_CHGE_IN_OTC',
4748 P_Message_Level => 'ERROR',
4749 P_Message_Field => NULL,
4750 P_Msg_Tokens => G_Msg_Tokens_Table,
4751 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4752 P_Time_Attribute_Id => NULL);
4753
4754 Else
4755
4756 G_Stage := 'Not allowed to Adjust Item In OTL - Inserting error rec.';
4757
4758 G_Msg_Tokens_Table.Delete;
4759
4760 -- Add record to error table.
4761 Pa_Otc_Api.Add_Error_To_Table(
4762 P_Message_Table => P_Message_Table,
4763 P_Message_Name => 'PA_TR_ADJ_NO_NET_ZERO',
4764 P_Message_Level => 'ERROR',
4765 P_Message_Field => NULL,
4766 P_Msg_Tokens => G_Msg_Tokens_Table,
4767 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4768 P_Time_Attribute_Id => NULL);
4769
4770 End If; -- l_Data_Conflict_Flag is 'Y'
4771
4772 End If; -- l_BB_Detail_Changed is Y and l_BB_Detail_Deleted is N
4773
4774 End If; -- l_Adjusted_In_Projects is Y
4775
4776 If l_BB_Detail_Deleted = 'N' and
4777 l_Adjusted_In_Projects = 'N' and
4778 ( l_BB_Detail_Changed = 'Y' or P_Building_Blocks(i).New = 'Y') Then
4779
4780 G_Stage := 'Check the Unit Of Measure value.';
4781 If l_Proj_Attrib_Rec.UOM <> 'HOURS' Then
4782
4783 -- Really don't need to process this record any further.
4784 -- The timecard cannot be save due to this. Period!
4785
4786 G_Stage := 'Cannot have data where UOM is not HOURS - Inserting error rec.';
4787
4788 G_Msg_Tokens_Table.Delete;
4789
4790 -- Add record to error table.
4791 Pa_Otc_Api.Add_Error_To_Table(
4792 P_Message_Table => P_Message_Table,
4793 P_Message_Name => 'PA_UOM_MUST_BE_HOURS',
4794 P_Message_Level => 'ERROR',
4795 P_Message_Field => NULL,
4796 P_Msg_Tokens => G_Msg_Tokens_Table,
4797 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4798 P_Time_Attribute_Id => NULL);
4799
4800 End If; -- l_UOM <> 'HOURS'
4801
4802 G_Stage := 'Check for quantity being negative.';
4803 If l_Proj_Attrib_Rec.Quantity < 0 And
4804 Nvl(Fnd_Profile.Value('PA_SST_ALLOW_NEGATIVE_TXN'),'N') = 'N' Then
4805
4806 -- If the quantity is less than 0 and the profile is set to not allow
4807 -- for negative transactions then raise error in error table.
4808 --
4809 -- Really don't need to process this record any further.
4810 -- The timecard cannot be save due to this. Period!
4811
4812 G_Stage := 'Negative quantity not allowed In OTL - Inserting error rec.';
4813 G_Msg_Tokens_Table.Delete;
4814
4815 -- Add record to error table.
4816 Pa_Otc_Api.Add_Error_To_Table(
4817 P_Message_Table => P_Message_Table,
4818 P_Message_Name => 'PA_SU_NEGATIVE_NUM_NOT_ALLOWED',
4819 P_Message_Level => 'ERROR',
4820 P_Message_Field => NULL,
4821 P_Msg_Tokens => G_Msg_Tokens_Table,
4822 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4823 P_Time_Attribute_Id => NULL);
4824
4825 End If; -- P_Building_Blocks_Table(i).Measure is negative and it is not allowed
4826
4827 -- Begin PA.M/CWK changes
4828 If l_Proj_Attrib_Rec.Person_Type not in ('CWK','EMP') Then
4829
4830 G_Stage := 'Invalid Person Type - Inserting error rec.';
4831 G_Msg_Tokens_Table.Delete;
4832
4833 -- Add record to error table.
4834 Pa_Otc_Api.Add_Error_To_Table(
4835 P_Message_Table => P_Message_Table,
4836 P_Message_Name => 'PA_INVALID_PERSON_TYPE',
4837 P_Message_Level => 'ERROR',
4838 P_Message_Field => NULL,
4839 P_Msg_Tokens => G_Msg_Tokens_Table,
4840 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4841 P_Time_Attribute_Id => NULL);
4842
4843 ElsIf l_Proj_Attrib_Rec.Person_Type = 'CWK' Then
4844
4845 If Pa_Pjc_Cwk_Utils.Is_Cwk_Tc_Xface_Allowed(l_Proj_Attrib_Rec.Project_Id) <> 'Y' And
4846 l_Proj_Attrib_Rec.PO_Line_Id Is Not Null And
4847 l_Proj_Attrib_Rec.Sys_Linkage_Func in ('OT','ST') Then
4848
4849 G_Stage := 'Project organization does not allow CWK timecards - Inserting error rec.';
4850 G_Msg_Tokens_Table.Delete;
4851
4852 -- Add record to error table.
4853 Pa_Otc_Api.Add_Error_To_Table(
4854 P_Message_Table => P_Message_Table,
4855 P_Message_Name => 'PA_CWK_TC_NOT_ALLOWED',
4856 P_Message_Level => 'ERROR',
4857 P_Message_Field => NULL,
4858 P_Msg_Tokens => G_Msg_Tokens_Table,
4859 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4860 P_Time_Attribute_Id => NULL);
4861
4862 Else
4863
4864 G_Stage := 'Check if the CWK working is creating timecard with PO reference.';
4865 If l_Proj_Attrib_Rec.PO_Line_Id Is Not Null Then
4866
4867 G_Stage := 'Check if the PO_Price_Type is populated. It is required.';
4868 If l_Proj_Attrib_Rec.PO_Price_Type is Null Then
4869
4870 G_Stage := 'Price Type is null - Inserting error rec.';
4871 G_Msg_Tokens_Table.Delete;
4872
4873 -- Add record to error table.
4874 Pa_Otc_Api.Add_Error_To_Table(
4875 P_Message_Table => P_Message_Table,
4876 P_Message_Name => 'PA_CWK_PRICE_TYPE_NULL',
4877 P_Message_Level => 'ERROR',
4878 P_Message_Field => NULL,
4879 P_Msg_Tokens => G_Msg_Tokens_Table,
4880 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4881 P_Time_Attribute_Id => NULL);
4882
4883 ElsIf l_Proj_Attrib_Rec.Vendor_Id is Null Then
4884
4885 G_Stage := 'Derived Vendor Id is null - Inserting error rec.';
4886 G_Msg_Tokens_Table.Delete;
4887
4888 -- Add record to error table.
4889 Pa_Otc_Api.Add_Error_To_Table(
4890 P_Message_Table => P_Message_Table,
4891 P_Message_Name => 'PA_CWK_VEND_INFO_NULL',
4892 P_Message_Level => 'ERROR',
4893 P_Message_Field => NULL,
4894 P_Msg_Tokens => G_Msg_Tokens_Table,
4895 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4896 P_Time_Attribute_Id => NULL);
4897
4898 End If;
4899
4900 End If; -- l_Proj_Attrib_Rec.PO_Line_Id Is Not Null
4901
4902 End If;
4903
4904 End If;
4905 -- End PA.M/CWK changes
4906
4907 -- Get Project Number
4908 l_Error_Code := Null;
4909 G_stage := 'Get Project Number.';
4910 Pa_Otc_Api.Validate_Project_Exists(
4911 P_Project_Id => l_Proj_Attrib_Rec.Project_Id,
4912 X_Error_Code => l_Error_Code,
4913 X_Error_Type => l_Error_Type,
4914 X_Project_Number => l_Proj_Attrib_Rec.Project_Number);
4915
4916 If l_Error_Code is Not Null Then
4917
4918 G_Stage := 'Get Project Number - Inserting error rec.';
4919 G_Msg_Tokens_Table.Delete;
4920
4921 -- Add record to error table.
4922 Pa_Otc_Api.Add_Error_To_Table(
4923 P_Message_Table => P_Message_Table,
4924 P_Message_Name => l_Error_Code,
4925 P_Message_Level => 'ERROR',
4926 P_Message_Field => 'PROJECT_ID',
4927 P_Msg_Tokens => G_Msg_Tokens_Table,
4928 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4929 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Proj_Attr_Id);
4930
4931 End If; -- l_Error_Code is not NULL
4932
4933 -- Get Task Number
4934 l_Error_Code := Null;
4935 G_stage := 'Get Task Number.';
4936 Pa_Otc_Api.Validate_Task_Exists(
4937 P_Task_Id => l_Proj_Attrib_Rec.Task_Id,
4938 P_Project_Id => l_Proj_Attrib_Rec.Project_Id,
4939 X_Error_Code => l_Error_Code,
4940 X_Error_Type => l_Error_Type,
4941 X_Task_Number => l_Proj_Attrib_Rec.Task_Number);
4942
4943 If l_Error_Code is Not Null Then
4944
4945 G_Stage := 'Get Task Number - Inserting error rec.';
4946 G_Msg_Tokens_Table.Delete;
4947
4948 -- Add record to error table.
4949 Pa_Otc_Api.Add_Error_To_Table(
4950 P_Message_Table => P_Message_Table,
4951 P_Message_Name => l_Error_Code,
4952 P_Message_Level => 'ERROR',
4953 P_Message_Field => 'TASK_ID',
4954 P_Msg_Tokens => G_Msg_Tokens_Table,
4955 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4956 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Task_Attr_Id);
4957
4958 End If;
4959
4960 -- Validate the expenditure type and system linkage function
4961 G_Stage := 'Validation the expenditure type and system linkage function.';
4962 l_Error_Code := Null;
4963
4964 Pa_Otc_Api.Validate_Exp_Type_Exists(
4965 P_System_Linkage => l_Proj_Attrib_Rec.Sys_Linkage_Func,
4966 P_Expenditure_Type => l_Proj_Attrib_Rec.Expenditure_Type,
4967 P_Exp_Item_Date => l_Proj_Attrib_Rec.Expenditure_Item_Date,
4968 X_Error_Type => l_Error_Type,
4969 X_Error_Code => l_Error_Code);
4970
4971 If l_Error_Code is Not Null Then
4972
4973 G_Stage := 'Validate the exp type and syst link func - Inserting error rec.';
4974 -- Add record to error table.
4975
4976 G_Msg_Tokens_Table.Delete;
4977
4978 If l_Proj_Attrib_Rec.Sys_Linkage_Func Is Null OR
4979 l_Proj_Attrib_Rec.Sys_Linkage_Func Not in ('OT','ST') Then
4980
4981 Pa_Otc_Api.Add_Error_To_Table(
4982 P_Message_Table => P_Message_Table,
4983 P_Message_Name => l_Error_Code,
4984 P_Message_Level => 'ERROR',
4985 P_Message_Field => 'SYSTEM_LINKAGE_FUNCTION',
4986 P_Msg_Tokens => G_Msg_Tokens_Table,
4987 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4988 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Sys_Link_Attr_Id);
4989
4990 Else
4991
4992 Pa_Otc_Api.Add_Error_To_Table(
4993 P_Message_Table => P_Message_Table,
4994 P_Message_Name => l_Error_Code,
4995 P_Message_Level => 'ERROR',
4996 P_Message_Field => 'EXPENDITURE_TYPE',
4997 P_Msg_Tokens => G_Msg_Tokens_Table,
4998 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
4999 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Exp_Type_Attr_Id);
5000
5001 End If; -- l_Sys_Linkage_Func
5002
5003 ElsIf l_Proj_Attrib_Rec.Sys_Linkage_Func Not in ('OT','ST') Then
5004
5005 G_Stage := 'Invalid sys link func - Inserting error rec.';
5006 -- Add record to error table.
5007
5008 G_Msg_Tokens_Table.Delete;
5009
5010 Pa_Otc_Api.Add_Error_To_Table(
5011 P_Message_Table => P_Message_Table,
5012 P_Message_Name => 'INVALID_ETYPE_SYSLINK',
5013 P_Message_Level => 'ERROR',
5014 P_Message_Field => 'SYSTEM_LINKAGE_FUNCTION',
5015 P_Msg_Tokens => G_Msg_Tokens_Table,
5016 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5017 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Sys_Link_Attr_Id);
5018
5019 End If; -- l_Error_Code is not null
5020
5021 -- Get Incurred_By_Organization_Id
5022 l_Error_Code := Null;
5023 l_Inc_By_Org_Id := Null;
5024 G_Stage := 'Get Incurred by Organization Id.';
5025 l_Inc_By_Org_Id := Pa_Utils.GetEmpOrgId(
5026 X_Person_Id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
5027 X_Date => l_Proj_Attrib_Rec.Expenditure_Item_Date);
5028
5029 If l_Inc_By_Org_Id is Null Then
5030
5031 G_Stage := 'Get Inc by Org Id - Inserting error rec.';
5032 G_Msg_Tokens_Table.Delete;
5033
5034 G_Msg_Tokens_Table(1).Token_Name := 'EXPDATE';
5035 G_Msg_Tokens_Table(1).Token_Value :=
5036 fnd_date.date_to_displaydate(l_Proj_Attrib_Rec.Expenditure_Item_Date);
5037
5038 -- Add record to error table.
5039 Pa_Otc_Api.Add_Error_To_Table(
5040 P_Message_Table => P_Message_Table,
5041 P_Message_Name => 'NO_ASSIGNMENT',
5042 P_Message_Level => 'ERROR',
5043 P_Message_Field => Null,
5044 P_Msg_Tokens => G_Msg_Tokens_Table,
5045 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5046 P_Time_Attribute_Id => Null);
5047
5048 Else
5049
5050 -- If the employee is assigned to an organization then it makes sense to check
5051 -- to see if there is a job assigned to the employee
5052 -- If there is no org then there is no need to check job since the same
5053 -- error message is used.
5054
5055 -- Check Job_Id
5056 G_Stage := 'Check for Job Id.';
5057 l_Job_Id := Null;
5058 l_Job_Id := Pa_Utils.GetEmpJobId (
5059 X_person_id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
5060 X_date => l_Proj_Attrib_Rec.Expenditure_Item_Date);
5061
5062 If l_Job_Id is Null Then
5063
5064 G_Msg_Tokens_Table.Delete;
5065
5066 G_Msg_Tokens_Table(1).Token_Name := 'EXPDATE';
5067 G_Msg_Tokens_Table(1).Token_Value :=
5068 fnd_date.date_to_displaydate(l_Proj_Attrib_Rec.Expenditure_Item_Date);
5069
5070 G_Stage := 'Check Job Id - Inserting error rec.';
5071
5072 -- Add record to error table.
5073 Pa_Otc_Api.Add_Error_To_Table(
5074 P_Message_Table => P_Message_Table,
5075 P_Message_Name => 'NO_ASSIGNMENT',
5076 P_Message_Level => 'ERROR',
5077 P_Message_Field => Null,
5078 P_Msg_Tokens => G_Msg_Tokens_Table,
5079 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5080 P_Time_Attribute_Id => Null);
5081
5082 End If; -- l_Job_Id check
5083
5084 End If; -- l_Inc_By_Org_Id check
5085
5086 -- DFF validation section.
5087 If l_bResult Then
5088
5089 If (l_StrReferenceField = 'SYSTEM_LINKAGE_FUNCTION') Then
5090
5091 l_StrContext := l_Proj_Attrib_Rec.Sys_Linkage_Func;
5092
5093 ElsIf (l_StrReferenceField = 'EXPENDITURE_TYPE') Then
5094
5095 l_StrContext := l_Proj_Attrib_Rec.Expenditure_Type;
5096
5097 Else
5098
5099 l_StrContext := Null;
5100
5101 End If;
5102
5103 G_Stage := 'Customer has defined Dffs and enabled them. ' ||
5104 'Populate dflex array with attributes 1 - 10.';
5105
5106 l_ArrDFlex(1) := l_Proj_Attrib_Rec.Attribute1;
5107 l_ArrDFlex(2) := l_Proj_Attrib_Rec.Attribute2;
5108 l_ArrDFlex(3) := l_Proj_Attrib_Rec.Attribute3;
5109 l_ArrDFlex(4) := l_Proj_Attrib_Rec.Attribute4;
5110 l_ArrDFlex(5) := l_Proj_Attrib_Rec.Attribute5;
5111 l_ArrDFlex(6) := l_Proj_Attrib_Rec.Attribute6;
5112 l_ArrDFlex(7) := l_Proj_Attrib_Rec.Attribute7;
5113 l_ArrDflex(8) := l_Proj_Attrib_Rec.Attribute8;
5114 l_ArrDFlex(9) := l_Proj_Attrib_Rec.Attribute9;
5115 l_ArrDFlex(10) := l_Proj_Attrib_Rec.Attribute10;
5116
5117 G_Stage := 'Call Pa_Self_Service_Dflex_Pub.ValidateDFlex().';
5118 Pa_Self_Service_Dflex_Pub.ValidateDFlex(
5119 P_StrProductName => 'PA',
5120 P_StrDFlexName => 'PA_EXPENDITURE_ITEMS_DESC_FLEX',
5121 P_RecContextsDR => l_RecContextsDR,
5122 P_StrContextName => l_StrContext,
5123 P_ArrDFlex => l_ArrDFlex,
5124 P_sErrorStack => l_Error_Stack,
5125 X_sErrorType => l_Error_Type,
5126 X_sErrorStack => l_Error_Stack,
5127 X_sErrorStage => l_Error_Stage,
5128 X_sErrorMessage => l_Error_Message);
5129
5130 --If an unexpected error occured in ValidateDFlex then raise the exception.
5131
5132 If (l_Error_Type = 'U') Then
5133
5134 Raise E_Dff_Exception;
5135
5136 ElsIf l_Error_Type = 'E' Then
5137
5138 -- Can only provide generic message since can't pass back
5139 -- messages to OTL. Only message names and token info.
5140
5141 G_Msg_Tokens_Table.Delete;
5142
5143 Pa_Otc_Api.Add_Error_To_Table(
5144 P_Message_Table => P_Message_Table,
5145 P_Message_Name => 'PA_DFF_VALIDATION_FAILED',
5146 P_Message_Level => 'ERROR',
5147 P_Message_Field => Null,
5148 P_Msg_Tokens => G_Msg_Tokens_Table,
5149 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5150 P_Time_Attribute_Id => Null);
5151
5152 End If;
5153
5154 End If;
5155
5156 -- Transaction Control validation call.
5157
5158 l_Status := Null;
5159
5160 G_Stage := 'Firing patc call.';
5161 Pa_Transactions_Pub.Validate_Transaction(
5162 X_Project_Id => l_Proj_Attrib_Rec.Project_Id,
5163 X_Task_Id => l_Proj_Attrib_Rec.Task_Id,
5164 X_Ei_Date => l_Proj_Attrib_Rec.Expenditure_Item_Date,
5165 X_Expenditure_Type => l_Proj_Attrib_Rec.Expenditure_Type,
5166 X_Non_Labor_Resource => Null,
5167 X_Person_Id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
5168 X_Billable_Flag => l_Proj_Attrib_Rec.Billable_Flag2,
5169 X_Quantity => l_Proj_Attrib_Rec.Quantity,
5170 X_Transfer_Ei => Null,
5171 X_Incurred_By_Org_Id => Null, -- letting patc get it
5172 X_NL_Resource_Org_Id => Null,
5173 X_Transaction_Source => 'ORACLE TIME AND LABOR',
5174 X_Calling_Module => 'PAXVOTCB',
5175 X_Vendor_Id => l_Proj_Attrib_Rec.Vendor_Id,
5176 X_Entered_By_User_Id => l_Proj_Attrib_Rec.Inc_By_Person_Id,
5177 X_Attribute_Category => l_Proj_Attrib_Rec.Attrib_Category,
5178 X_Attribute1 => l_Proj_Attrib_Rec.Attribute1,
5179 X_Attribute2 => l_Proj_Attrib_Rec.Attribute2,
5180 X_Attribute3 => l_Proj_Attrib_Rec.Attribute3,
5181 X_Attribute4 => l_Proj_Attrib_Rec.Attribute4,
5182 X_Attribute5 => l_Proj_Attrib_Rec.Attribute5,
5183 X_Attribute6 => l_Proj_Attrib_Rec.Attribute6,
5184 X_Attribute7 => l_Proj_Attrib_Rec.Attribute7,
5185 X_Attribute8 => l_Proj_Attrib_Rec.Attribute8,
5186 X_Attribute9 => l_Proj_Attrib_Rec.Attribute9,
5187 X_Attribute10 => l_Proj_Attrib_Rec.Attribute10,
5188 -- MC columns are NULL because OTL does not support
5189 -- multi-currency
5190 X_Denom_Currency_Code => Null,
5191 X_Acct_Currency_Code => Null,
5192 X_Denom_Raw_Cost => Null,
5193 X_Acct_Raw_Cost => Null,
5194 X_Acct_Rate_Type => Null,
5195 X_Acct_Rate_Date => Null,
5196 X_Acct_Exchange_Rate => Null,
5197 X_Msg_Application => l_Msg_Application,
5198 X_Msg_Type => l_Msg_Type,
5199 X_Msg_Token1 => l_Msg_Token1_Value,
5200 X_Msg_Token2 => l_Msg_Token2_Value,
5201 X_Msg_Token3 => l_Msg_Token3_Value,
5202 X_Msg_Count => l_Msg_Count,
5203 X_Msg_Data => l_Status,
5204 P_Po_Header_Id => l_Proj_Attrib_Rec.Po_Header_Id,
5205 P_Po_Line_Id => l_Proj_Attrib_Rec.Po_Line_Id,
5206 P_Person_Type => l_Proj_Attrib_Rec.Person_Type,
5207 P_Po_Price_Type => l_Proj_Attrib_Rec.Po_Price_Type,
5208 P_Sys_Link_Function => l_Proj_Attrib_Rec.Sys_Linkage_Func);
5209
5210 /* Bug 7645561*/
5211 Open Check_Term_with_pay(l_Proj_Attrib_Rec.Inc_By_Person_Id);
5212 fetch Check_Term_with_pay into test_term_with_pay;
5213 Close Check_Term_with_pay;
5214
5215
5216 /* Bug 7645561*/
5217 If (l_status <> 'PA_NO_ASSIGNMENT' or test_term_with_pay is Null) then
5218 -- check if patc has returned any errors
5219 If l_Status is Not Null Then
5220
5221 If Pa_Otc_Api.IsNumber(l_Status) Then
5222
5223 Raise E_Unhandled_Exception;
5224
5225 Else
5226
5227 G_Stage := 'Patc returned status that is Not Null - Inserting error rec.';
5228 G_Msg_Tokens_Table.Delete;
5229
5230 If l_Msg_Token1_Value is not null Then
5231
5232 G_Msg_Tokens_Table(1).Token_Name := 'PATC_MSG_TOKEN1';
5233 G_Msg_Tokens_Table(1).Token_Value := l_Msg_Token1_Value;
5234
5235 -- Begin message token is not defined for bug#4593869
5236 Else
5237
5238 G_Msg_Tokens_Table(1).Token_Name := 'PATC_MSG_TOKEN1';
5239 G_Msg_Tokens_Table(1).Token_Value := FND_API.G_MISS_CHAR;
5240
5241 -- End message token is not defined for bug#4593869
5242 End If;
5243
5244 If l_Msg_Token2_Value is not null Then
5245
5246 G_Msg_Tokens_Table(2).Token_Name := 'PATC_MSG_TOKEN2';
5247 G_Msg_Tokens_Table(2).Token_Value := l_Msg_Token2_Value;
5248
5249 -- Begin message token is not defined for bug#4593869
5250 Else
5251
5252 G_Msg_Tokens_Table(2).Token_Name := 'PATC_MSG_TOKEN2';
5253 G_Msg_Tokens_Table(2).Token_Value := FND_API.G_MISS_CHAR;
5254
5255 -- End message token is not defined for bug#4593869
5256 End If;
5257
5258 If l_Msg_Token3_Value is not null Then
5259
5260 G_Msg_Tokens_Table(3).Token_Name := 'PATC_MSG_TOKEN3';
5261 G_Msg_Tokens_Table(3).Token_Value := l_Msg_Token3_Value;
5262
5263 -- Begin message token is not defined for bug#4593869
5264 Else
5265
5266 G_Msg_Tokens_Table(3).Token_Name := 'PATC_MSG_TOKEN3';
5267 G_Msg_Tokens_Table(3).Token_Value := FND_API.G_MISS_CHAR;
5268
5269 -- End message token is not defined for bug#4593869
5270 End If;
5271
5272 End If;
5273
5274 If l_Msg_Application is Null Then
5275
5276 l_Msg_Application := 'PA';
5277
5278 End If;
5279
5280 /* Added following if condition for Bug#2798986 */
5281 If l_Msg_Type = 'W' Then
5282
5283 l_Error_Level := 'WARNING';
5284
5285 ElsIf l_Msg_Type = 'E' Then
5286
5287 l_Error_Level := 'ERROR';
5288
5289 End If;
5290
5291 If l_Status <> 'NO_ASSIGNMENT' Then
5292
5293 Pa_Otc_Api.Add_Error_To_Table(
5294 P_Message_Table => P_Message_Table,
5295 P_Message_Name => l_Status,
5296 P_Message_Level => l_Error_Level, /* Bug#2798986 */
5297 P_Message_Field => Null,
5298 P_Msg_Tokens => G_Msg_Tokens_Table,
5299 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5300 P_Time_Attribute_Id => Null,
5301 P_Message_App => l_Msg_Application);
5302
5303 End If;
5304
5305 -- Begin Bug 4518893
5306 If l_Msg_Type = 'W' Then
5307
5308 /* Check if the billable flag was change externally either by other app
5309 * in OTL or by third party.
5310 */
5311 If l_Proj_Attrib_Rec.Billable_Flag <> l_Proj_Attrib_Rec.Billable_Flag2 Then
5312
5313 /* l_Billable_Flag is coming from the pl/sql table
5314 * This can occur if another app changes project,task,billable_flag
5315 * in update phase of validation logic and billable no longer
5316 * matches what patc returns.
5317 */
5318
5319 G_Stage := 'Get translated value for Billable_flag code using fnd_lookups.';
5320 l_Bill_Flag_Meaning := Null;
5321
5322 G_Stage := 'Open cursor getBillFlagMeaning.';
5323 Open GetBillFlagMeaning(l_Proj_Attrib_Rec.Billable_Flag);
5324
5325 G_Stage := 'Fetch data for cursor getBillFlagMeaning.';
5326 Fetch GetBillFlagMeaning into l_Bill_Flag_Meaning;
5327
5328 G_Stage := 'Close cursor GetBillFlagMeaning.';
5329 Close GetBillFlagMeaning;
5330
5331 G_Stage := 'Invalid external change of billable flag - Inserting error rec.';
5332 G_Msg_Tokens_Table.Delete;
5333
5334 G_Msg_Tokens_Table(1).Token_Name := 'BILL_FLAG';
5335 G_Msg_Tokens_Table(1).Token_Value := l_Bill_Flag_Meaning;
5336
5337 -- Add record to error message table.
5338 Pa_Otc_Api.Add_Error_To_Table(
5339 P_Message_Table => P_Message_Table,
5340 P_Message_Name => 'BILL_FLAG_CHGE_INVALID',
5341 P_Message_Level => 'ERROR',
5342 P_Message_Field => 'BILLABLE_FLAG',
5343 P_Msg_Tokens => G_Msg_Tokens_Table,
5344 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5345 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Billable_Flag_Attr_Id);
5346
5347 End If; -- l_Proj_Attrib_Rec.Billable_Flag <> l_Proj_Attrib_Rec.Billable_Flag2
5348
5349 End If; -- l_Msg_Type = 'W'
5350 -- end bug 4518893
5351
5352 Else -- l_Status is Not Null
5353
5354 /* Check if the billable flag was change externally either by other app
5355 * in OTL or by third party.
5356 */
5357 If l_Proj_Attrib_Rec.Billable_Flag <> l_Proj_Attrib_Rec.Billable_Flag2 Then
5358
5359 /* l_Billable_Flag is coming from the pl/sql table
5360 * This can occur if another app changes project,task,billable_flag
5361 * in update phase of validation logic and billable no longer
5362 * matches what patc returns.
5363 */
5364
5365 G_Stage := 'Get translated value for Billable_flag code using fnd_lookups.';
5366 l_Bill_Flag_Meaning := Null;
5367
5368 G_Stage := 'Open cursor getBillFlagMeaning.';
5369 Open GetBillFlagMeaning(l_Proj_Attrib_Rec.Billable_Flag);
5370
5371 G_Stage := 'Fetch data for cursor getBillFlagMeaning.';
5372 Fetch GetBillFlagMeaning into l_Bill_Flag_Meaning;
5373
5374 G_Stage := 'Close cursor GetBillFlagMeaning.';
5375 Close GetBillFlagMeaning;
5376
5377 G_Stage := 'Invalid external change of billable flag - Inserting error rec.';
5378 G_Msg_Tokens_Table.Delete;
5379
5380 G_Msg_Tokens_Table(1).Token_Name := 'BILL_FLAG';
5381 G_Msg_Tokens_Table(1).Token_Value := l_Bill_Flag_Meaning;
5382
5383 -- Add record to error message table.
5384 Pa_Otc_Api.Add_Error_To_Table(
5385 P_Message_Table => P_Message_Table,
5386 P_Message_Name => 'BILL_FLAG_CHGE_INVALID',
5387 P_Message_Level => 'ERROR',
5388 P_Message_Field => 'BILLABLE_FLAG',
5389 P_Msg_Tokens => G_Msg_Tokens_Table,
5390 P_Time_Building_Block_Id => P_Building_Blocks(i).Time_Building_Block_Id,
5391 P_Time_Attribute_Id => l_Proj_Attrib_Rec.Billable_Flag_Attr_Id);
5392
5393 End If; -- l_Proj_Attrib_Rec.billable_flag <> l_Proj_Attrib_Rec.billable_flag2
5394
5395 End If; -- l_Status check
5396 End If; -- Bug 7645561
5397
5398 End If; -- l_Adjusted_In_Projects = 'N' and l_BB_Detail_Changed = 'Y' and l_BB_Detail_Deleted = 'N'
5399
5400 If P_Message_Table.Count = 0 and l_BB_Detail_Deleted = 'N' Then
5401
5402 -- Add ei record to l_Timecard_Table
5403 G_Stage := 'Add ei record to l_Timecard_Table for use by extensions.';
5404
5405 l_Timecard_Table_Index := l_Timecard_Table_Index + 1;
5406 l_Timecard_Table(l_Timecard_Table_Index).Project_Number := l_Proj_Attrib_Rec.Project_Number;
5407 l_Timecard_Table(l_Timecard_Table_Index).Project_Id := l_Proj_Attrib_Rec.Project_id;
5408 l_Timecard_Table(l_Timecard_Table_Index).Task_Number := l_Proj_Attrib_Rec.Task_Number;
5409 l_Timecard_Table(l_Timecard_Table_Index).Task_Id := l_Proj_Attrib_Rec.Task_Id;
5410 l_Timecard_Table(l_Timecard_Table_Index).Expenditure_Type := l_Proj_Attrib_Rec.Expenditure_Type;
5411 l_Timecard_Table(l_Timecard_Table_Index).System_Linkage_Function := l_Proj_Attrib_Rec.Sys_Linkage_Func;
5412 l_Timecard_Table(l_Timecard_Table_Index).Quantity := l_Proj_Attrib_Rec.Quantity;
5413 l_Timecard_Table(l_Timecard_Table_Index).Incurred_By_Person_Id := l_Proj_Attrib_Rec.Inc_By_Person_Id;
5414 l_Timecard_Table(l_Timecard_Table_Index).Override_Approver_Person_Id := l_Ovr_Approver_Person_Id;
5415 l_Timecard_Table(l_Timecard_Table_Index).Expenditure_Item_Date := l_Proj_Attrib_Rec.Expenditure_Item_Date;
5416 l_Timecard_Table(l_Timecard_Table_Index).Expenditure_Ending_Date := l_Proj_Attrib_Rec.Exp_Ending_Date;
5417 l_Timecard_Table(l_Timecard_Table_Index).Attribute_Category := l_Proj_Attrib_Rec.Attrib_Category;
5418 l_Timecard_Table(l_Timecard_Table_Index).Attribute1 := l_Proj_Attrib_Rec.Attribute1;
5419 l_Timecard_Table(l_Timecard_Table_Index).Attribute2 := l_Proj_Attrib_Rec.Attribute2;
5420 l_Timecard_Table(l_Timecard_Table_Index).Attribute3 := l_Proj_Attrib_Rec.Attribute3;
5421 l_Timecard_Table(l_Timecard_Table_Index).Attribute4 := l_Proj_Attrib_Rec.Attribute4;
5422 l_Timecard_Table(l_Timecard_Table_Index).Attribute5 := l_Proj_Attrib_Rec.Attribute5;
5423 l_Timecard_Table(l_Timecard_Table_Index).Attribute6 := l_Proj_Attrib_Rec.Attribute6;
5424 l_Timecard_Table(l_Timecard_Table_Index).Attribute7 := l_Proj_Attrib_Rec.Attribute7;
5425 l_Timecard_Table(l_Timecard_Table_Index).Attribute8 := l_Proj_Attrib_Rec.Attribute8;
5426 l_Timecard_Table(l_Timecard_Table_Index).Attribute9 := l_Proj_Attrib_Rec.Attribute9;
5427 l_Timecard_Table(l_Timecard_Table_Index).Attribute10 := l_Proj_Attrib_Rec.Attribute10;
5428 l_Timecard_Table(l_Timecard_Table_Index).Billable_Flag := l_Proj_Attrib_Rec.Billable_Flag;
5429 l_Timecard_Table(l_Timecard_Table_Index).Expenditure_Item_Comment := l_Proj_Attrib_Rec.Expenditure_Item_Comment;
5430 l_Timecard_Table(l_Timecard_Table_Index).Approval_Status := l_Approval_Status;
5431 /* Begin bug 5087510 PA.M CWK changes. */
5432 l_Timecard_Table(l_Timecard_Table_Index).Po_Line_Id := l_Proj_Attrib_Rec.Po_Line_Id;
5433 l_Timecard_Table(l_Timecard_Table_Index).PO_Price_Type := l_Proj_Attrib_Rec.PO_Price_Type;
5434 l_Timecard_Table(l_Timecard_Table_Index).Person_Type := l_Proj_Attrib_Rec.Person_Type;
5435 l_Timecard_Table(l_Timecard_Table_Index).Po_Header_Id := l_Proj_Attrib_Rec.Po_Header_Id;
5436 /* End bug 5087510 */
5437 /* Bug 4022269 added action column to allowed summary validation extension to
5438 * be able to determine if OTL timecard is being saved or submitted.
5439 */
5440 l_Timecard_Table(l_Timecard_Table_Index).Action := P_Operation; -- Validate values: SAVE or SUBMIT
5441
5442 -- Though this is not needed it helps to clarify that a reset these local
5443 -- variables is assumed at this point.
5444 --
5445 G_Stage := 'Reset variable used for table insert';
5446 l_Proj_Attrib_Rec := Null;
5447
5448 End If; -- P_Message_Table.Count = 0
5449
5450 End If; -- Detail Scope Building Block
5451
5452 G_Stage := 'Check to exit loop.';
5453 Exit When i = P_Building_Blocks.Last;
5454
5455 End Loop; -- Processing Building Blocks Loop
5456
5457 G_Stage := 'Done with Processing Building Blocks loop.';
5458 If P_Message_Table.Count = 0 and l_Timecard_Table.COUNT > 0 Then
5459
5460 /* Not need to null out l_msg_name and l_exp_status but doing so for clarity. */
5461 l_Msg_Name := Null;
5462
5463 G_Stage := 'Calling Summary-validation Extension';
5464 -- Summary level Validation Call
5465 Pagtcx.Summary_Validation_Extension(
5466 P_Timecard_Table => l_Timecard_Table,
5467 P_Module => 'OTL',
5468 X_Expenditure_Id => Null,
5469 X_Incurred_By_Person_Id => l_Timecard_Table(1).Incurred_By_Person_Id,
5470 X_Expenditure_End_Date => Null,
5471 X_Exp_Class_Code => 'PT',
5472 X_Status => l_Exp_Status,
5473 X_Comment => l_Msg_Name);
5474
5475 If l_Exp_Status = 'REJECTED' Then
5476
5477 -- Add record to error message table
5478 G_Stage := 'Calling Summary-validation Extension - Insert Error Rec.';
5479 G_Msg_Tokens_Table.Delete;
5480
5481 Pa_Otc_Api.Add_Error_To_Table(
5482 P_Message_Table => P_Message_Table,
5483 P_Message_Name => l_Msg_Name,
5484 P_Message_Level => 'ERROR',
5485 P_Message_Field => Null,
5486 P_Msg_Tokens => G_Msg_Tokens_Table,
5487 P_Time_Building_Block_Id => NULL, --Bug5215484 l_Time_Building_Block_Id,
5488 P_Time_Attribute_Id => Null);
5489
5490 End If;
5491
5492 If Nvl(Fnd_Profile.Value('PA_SST_ENABLE_BUS_MSG'),'N') = 'Y' Then
5493
5494 -- Business Message Call
5495 G_Stage := 'Calling Business Message API';
5496 Pa_Time_Client_Extn.Display_Business_Message(
5497 P_Timecard_Table => l_Timecard_Table,
5498 P_Module => 'OTL',
5499 P_Person_id => l_Timecard_Table(1).Incurred_By_Person_Id,
5500 P_Week_Ending_Date => Null,
5501 X_Msg_Application_Name => l_Msg_Application,
5502 X_Message_Data => l_Msg_Name,
5503 X_Msg_Token1_Name => l_Msg_Token1_Name,
5504 X_Msg_Token1_Value => l_Msg_Token1_Value ,
5505 X_Msg_Token2_Name => l_Msg_Token2_Name,
5506 X_Msg_Token2_Value => l_Msg_token2_Value,
5507 X_Msg_Token3_Name => l_Msg_Token3_Name,
5508 X_Msg_Token3_Value => l_Msg_Token3_Value);
5509
5510 If l_Msg_Name is Not Null Then
5511
5512 -- Add record to error message table
5513 G_Stage := 'Calling Business Message API - Insert Business Rec Msg.';
5514 G_Msg_Tokens_Table.Delete;
5515
5516 If l_Msg_Token1_Name is Not Null Then
5517
5518 G_Msg_Tokens_Table(1).Token_Name := l_Msg_Token1_Name;
5519 G_Msg_Tokens_Table(1).Token_Value := l_Msg_Token1_Value;
5520
5521 End If;
5522
5523 If l_Msg_Token2_Name is Not Null Then
5524
5525 G_Msg_Tokens_Table(2).Token_Name := l_Msg_Token2_Name;
5526 G_Msg_Tokens_Table(2).Token_Value := l_Msg_Token2_Value;
5527
5528 End If;
5529
5530 If l_Msg_Token3_Name is Not Null Then
5531
5532 G_Msg_Tokens_Table(3).Token_Name := l_Msg_Token3_Name;
5533 G_Msg_Tokens_Table(3).Token_Value := l_Msg_Token3_Value;
5534
5535 End If;
5536
5537 If l_Msg_Application is Null Then
5538
5539 l_Msg_Application := 'PA';
5540
5541 End If;
5542
5543 Pa_Otc_Api.Add_Error_To_Table(
5544 P_Message_Table => P_Message_Table,
5545 P_Message_Name => l_Msg_Name,
5546 P_Message_Level => 'BUSINESS',
5547 P_Message_Field => Null,
5548 P_Msg_Tokens => G_Msg_Tokens_Table,
5549 P_Time_Building_Block_Id => NULL, --Bug5215484 l_Time_Building_Block_Id,
5550 P_Time_Attribute_Id => Null,
5551 P_Message_App => l_Msg_Application);
5552
5553 End If; -- l_Msg_Name is Not Null
5554
5555 End If; -- Profile 'PA_SST_ENABLE_BUS_MSG' = 'Y'
5556
5557 G_Stage := 'Last point of looping thru all the weeks.';
5558
5559 End If; -- P_Message_Table.Count = 0 and l_Timecard_Table.Count > 0
5560
5561 G_Stage := 'Leaving procedure Validate_Process().';
5562 Pa_Otc_Api.TrackPath('STRIP','Validate_Process');
5563
5564 Exception
5565 When E_Unhandled_Exception Then
5566 Raise_Application_Error(-20021,SqlErrm(to_number(l_Status)));
5567
5568 When E_Dff_Exception Then
5569 G_Stage := G_Stage || ' => ' || l_Error_Stage;
5570 Raise_Application_Error(-20021,l_Error_Message);
5571
5572 When Others Then
5573 Raise;
5574
5575 End Validate_Process;
5576
5577
5578 -- =======================================================================
5579 -- Start of Comments
5580 -- API Name : Validate_Project_Exists
5581 -- Type : Private
5582 -- Pre-Reqs : None
5583 -- Type : Procedure
5584 -- Function : This procedure accepts the Project_Id
5585 -- as IN parameter and ckecks if this project exists in
5586 -- Oracle Projects. This procedure does not perform any
5587 -- extensive project related validations. If the project
5588 -- exists in Oracle Projects, X_project_Number will be populated
5589 -- with segment1, else X_project_number will be null.
5590 -- Parameters :
5591 -- IN
5592 -- P_Project_Id - Pa_Projects_All.Project_Id%TYPE
5593 -- OUT
5594 -- X_Error_Code - Varchar2
5595 -- X_Error_Type - Varchar2
5596 -- X_Project_Id - Pa_Projects_All.Segment1%TYPE
5597
5598 /*-------------------------------------------------------------------------*/
5599
5600 Procedure Validate_Project_Exists(
5601 P_Project_Id IN Pa_Projects_All.Project_Id%TYPE,
5602 X_Error_Code OUT NOCOPY Varchar2,
5603 X_Error_Type OUT NOCOPY Varchar2,
5604 X_Project_Number OUT NOCOPY Pa_Projects_All.Segment1%TYPE)
5605 Is
5606
5607 /* begin bug 4766396
5608 Cursor GetProjInfo(P_Proj_Id IN Pa_Projects_All.Project_Id%TYPE) Is
5609 Select
5610 Project_Number
5611 From
5612 Pa_Online_Projects_V
5613 Where
5614 Project_Id = P_Proj_Id; */
5615
5616 Cursor GetProjInfo(P_Proj_Id IN Pa_Projects_All.Project_Id%TYPE) IS
5617 select
5618 p.segment1
5619 from Pa_Online_Projects_V pp,
5620 pa_projects_all p
5621 where pp.Project_Id = P_Proj_Id
5622 and pp.project_id = p.project_id;
5623 /* end bug 4766396 */
5624
5625 l_Proj_Num Pa_Projects_All.Segment1%TYPE := Null;
5626
5627 Begin
5628
5629 G_Stage := 'Entering procedure Validate_Project_Exists().';
5630 Pa_Otc_Api.TrackPath('ADD','Validate_Project_Exists');
5631
5632 If P_Project_Id is Not Null Then
5633
5634 G_Stage := 'Open cursor GetProjInfo.';
5635 Open GetProjInfo(P_Project_Id);
5636
5637 G_Stage := 'Fetch Project info from cursor.';
5638 Fetch GetProjInfo Into l_Proj_Num;
5639
5640 G_Stage := 'Close cursor GetProjInfo.';
5641 Close GetProjInfo;
5642
5643 If l_Proj_Num is Null Then
5644
5645 G_Stage := 'No project number was returned - Invalid project.';
5646
5647 -- This implies that this project is no longer valid to use. This
5648 -- can be due to many different reasons.
5649 -- Providing the specific reason why the project can no longer be
5650 -- used is impractical, so a generic message is sent back to the user.
5651
5652 X_Error_Type := 'E';
5653 X_Error_Code := 'INVALID_PROJECT';
5654
5655 ELSE
5656
5657 X_Project_Number := l_Proj_Num;
5658
5659 End If; -- End l_Proj_Num is null
5660
5661 Else -- Project id is null
5662
5663 G_Stage := 'The Project Id parameter are Null - Invalid parameter values.';
5664
5665 -- Both project id and project number are null,
5666 -- this should not occur under normal situations.
5667 -- if this occurs then populate error_type with 'E'
5668 -- (normal Error).
5669
5670 X_Error_Type := 'E';
5671 X_Error_Code := 'PA_PROJ_PARAM_IS_NULL';
5672
5673 End If; -- End Project Id is not null
5674
5675 G_Stage := 'Leaving procedure Validate_Project_Exists().';
5676 Pa_Otc_Api.TrackPath('STRIP','Validate_Project_Exists');
5677
5678 EXCEPTION
5679 When Others Then
5680 Raise;
5681
5682 End Validate_Project_Exists;
5683
5684
5685 -- =======================================================================
5686 -- Start of Comments
5687 -- API Name : Validate_Task_Exists
5688 -- Type : Private
5689 -- Pre-Reqs : None
5690 -- Type : Procedure
5691 -- Function : This procedure accepts the Project_Id, Task_Number
5692 -- IN parameters and ckecks if this task exists in
5693 -- pa_online_task_v. This procedure does not perform any
5694 -- extensive task related validations. If the task
5695 -- exists in the online view, X_task_Id will be populated
5696 -- with task_id, else X_task_id will be null.
5697 -- Parameters :
5698 -- IN
5699 -- P_Task_Id - Pa_Tasks.Task_Id%TYPE
5700 -- P_Project_Id - Pa_Projects.Project_Id%TYPE
5701 -- OUT
5702 -- X_Error_Code - Varchar2
5703 -- X_Error_Type - Varchar2
5704 -- X_Task_Number - Pa_Tasks.Task_Number%TYPE
5705 /*-------------------------------------------------------------------------*/
5706
5707 Procedure Validate_Task_Exists(
5708 P_Task_Id IN Pa_Tasks.Task_Id%TYPE,
5709 P_Project_Id IN Pa_Projects.Project_Id%TYPE,
5710 X_Error_Code OUT NOCOPY Varchar2,
5711 X_Error_Type OUT NOCOPY Varchar2,
5712 X_Task_Number OUT NOCOPY Pa_Tasks.Task_Number%TYPE)
5713 Is
5714
5715 l_Task_Num Pa_Tasks.Task_Number%TYPE := Null;
5716 l_Task_Name Pa_Tasks.Task_Name%TYPE := Null;
5717
5718 /* begin bug 4766396
5719 Cursor Validate_ProjTask_Combo(P_Prj_Id IN Number,
5720 P_Tsk_Id IN Number) Is
5721 Select
5722 Task_Number
5723 From
5724 Pa_Online_Tasks_V
5725 Where
5726 Task_Id = P_Tsk_Id
5727 And Project_Id = P_Prj_Id; */
5728
5729 cursor Validate_ProjTask_Combo(P_Prj_Id IN NUMBER,
5730 P_Tsk_Id IN NUMBER) is
5731 select
5732 t.task_number
5733 from pa_online_tasks_v tt,
5734 pa_tasks t
5735 where
5736 tt.task_id = P_Tsk_Id
5737 and tt.project_id = P_Prj_Id
5738 and t.task_id = tt.task_id;
5739 /* end bug 4766396 */
5740
5741 Begin
5742
5743 -- Validate project_id parameter
5744
5745 G_Stage := 'Entering procedure Validate_Task_Exists().';
5746 Pa_Otc_Api.TrackPath('ADD','Validate_Task_Exists');
5747
5748 If P_Task_Id is Not Null Then
5749
5750 G_Stage := 'Parameter P_Task_Id is not Null, get Task Info.';
5751 Pa_Utils.GetTaskInfo (
5752 X_Task_Id => P_Task_Id,
5753 X_Task_Num => l_Task_Num,
5754 X_Task_Name => l_Task_Name);
5755
5756 -- Check if retrieved task number for the task id.
5757 -- If it didn't then the task id is invalid,
5758 -- return normal error.
5759
5760 If l_Task_Num is Null Then
5761
5762 G_Stage := 'The returned Task Number is Null so error out.';
5763 X_Error_Type := 'E';
5764 X_Error_Code := 'INVALID_TASK';
5765
5766 Else -- Check the project/task combo being valid
5767
5768 G_Stage := 'Open cursor Validate_ProjTask_Combo.';
5769 Open Validate_ProjTask_Combo(P_Project_Id,P_Task_Id);
5770
5771 G_Stage := 'Fetch data from cursor Validate_ProjTask_Combo.';
5772 Fetch Validate_ProjTask_Combo into l_Task_Num;
5773
5774 G_Stage := 'Close cursor Validate_ProjTask_Combo.';
5775 Close Validate_ProjTask_Combo;
5776
5777 If l_Task_Num is Null Then
5778
5779 G_Stage := 'Invalid Project/Task combination. Populate error code.';
5780 X_Error_Type := 'E';
5781 X_Error_Code := 'PA_INVALID_PROJ_TASK_COMB';
5782
5783 Else
5784
5785 G_Stage := 'The Project/Task combination is valid.';
5786
5787 X_Task_Number := l_Task_Num;
5788
5789 End If;
5790
5791 End If; -- end l_Task_Number is null
5792
5793 Else -- Task Id is Null
5794
5795 G_Stage := 'The parameter P_Task_Id is Null so error out.';
5796 X_Error_Type := 'E';
5797 X_Error_Code := 'INVALID_TASK';
5798
5799 End If; -- End P_Task_Id is not null
5800
5801 G_Stage := 'Leaving procedure Validate_Task_Exists().';
5802 Pa_Otc_Api.TrackPath('STRIP','Validate_Task_Exists');
5803
5804 Exception
5805 When Others Then
5806 Raise;
5807
5808 End Validate_Task_Exists;
5809
5810
5811 -- ==========================================================================
5812 -- Start of Comments
5813 -- API Name : Validate_Exp_Type_Exists
5814 -- Type : Private
5815 -- Pre-Reqs : None
5816 -- Type : Procedure
5817 -- Function : This procedure checks if the system linkage/expenditure type
5818 -- combination exists in the database for the given date.
5819 -- Parameters :
5820 -- IN
5821 -- P_System_Linkage - Pa_System_Linkages.Function%TYPE
5822 -- P_Expenditure_Type - Pa_Expenditure_Types.Expenditure_Type%TYPE
5823 -- P_Exp_Item_date - Pa_Expenditure_Items_All.Expenditure_Item_Date%TYPE
5824 -- OUT
5825 -- X_Error_Code - Varchar2
5826 -- X_Error_Type - Varchar2
5827
5828 /*--------------------------------------------------------------------------*/
5829
5830 Procedure Validate_Exp_Type_Exists(
5831 P_System_Linkage IN Pa_System_Linkages.Function%TYPE,
5832 P_Expenditure_Type IN Pa_Expenditure_Types.Expenditure_Type%TYPE,
5833 P_Exp_Item_Date IN Pa_Expenditure_Items_All.Expenditure_Item_Date%TYPE,
5834 X_Error_Type OUT NOCOPY Varchar2,
5835 X_Error_Code OUT NOCOPY Varchar2) Is
5836
5837 Cursor Cur_Etype_Slink (P_EI_Date IN Date,
5838 P_Sys_Link_Func IN Varchar2,
5839 P_Exp_Type IN Varchar2) Is
5840 Select
5841 System_Linkage_Function,
5842 Expenditure_Type
5843 From
5844 Pa_Online_Expenditure_Types_V
5845 Where
5846 System_Linkage_Function = P_Sys_Link_Func
5847 And Expenditure_Type = P_Exp_Type
5848 And P_Exp_Item_Date Between Sys_Link_Start_Date_Active
5849 And Nvl(Sys_Link_End_Date_Active,P_EI_Date)
5850 And P_Exp_Item_Date Between Expnd_Typ_Start_Date_Active
5851 And Nvl(Expnd_Typ_End_Date_Active,P_EI_Date)
5852 And system_linkage_function in ('ST','OT'); -- bug 5020394
5853
5854 Rec_Ets Cur_Etype_Slink%RowType;
5855
5856 Begin
5857
5858 G_Stage := 'Entering procedure Validate_Exp_Type_Exists().';
5859 Pa_Otc_Api.TrackPath('ADD','Validate_Exp_Type_Exists');
5860
5861 G_Stage := 'Open cursor Fetch AdjustmentAllowed.';
5862 Open Cur_Etype_Slink(P_Exp_Item_Date,P_System_Linkage,P_Expenditure_Type);
5863
5864 G_Stage := 'Fetch from cursor Cur_Etype_Slink.';
5865 Fetch Cur_Etype_Slink Into Rec_Ets;
5866
5867 G_Stage := 'Close cursor Cur_Etype_Slink.';
5868 Close Cur_Etype_Slink;
5869
5870 G_Stage := 'Check if exp type sys link func conditions passed muster.';
5871 If Rec_Ets.Expenditure_Type is Null Then
5872
5873 G_Stage := 'Expenditure Type is null so error out.';
5874 X_Error_Type := 'E';
5875 X_Error_Code := 'INVALID_ETYPE_SYSLINK';
5876
5877 End If;
5878
5879 G_Stage := 'Leaving procedure Validate_Exp_Type_Exists().';
5880 Pa_Otc_Api.TrackPath('STRIP','Validate_Exp_Type_Exists');
5881
5882 Exception
5883 When Others Then
5884 Raise;
5885
5886 End Validate_Exp_Type_Exists;
5887
5888
5889 -- ===========================================================================
5890 -- API Name : Validate_overriding_approver
5891 -- Type : Private
5892 -- Pre-Reqs : None
5893 -- Type : Procedure
5894 -- Function : This function validates the overriding approver entered
5895 -- in timecard header screen. If the approver_id is passed
5896 -- then it is implied that the overriding approver is picked
5897 -- from the LOV provided in enter timecard header screen, in
5898 -- this case it is not necessary to validate the overriding
5899 -- approver bcoz the LOV displays only valid approvers.
5900 -- However if the overriding approver_id is null and
5901 -- overriding approver_name is provided, then the approver
5902 -- name is validated against pa_exp_ovrrde_approver_v view.
5903 --
5904 -- Parameters :
5905 -- IN
5906 -- P_Approver_Id - Per_People_F.Person_Id%TYPE
5907 --
5908 -- OUT
5909 -- X_Approver_Id - Per_People_F.Person_Id%TYPE
5910 -- X_Error_Type - Varchar2
5911 -- X_Error_Code - Varchar2
5912 /* ------------------------------------------------------------------------*/
5913
5914 Procedure Validate_Overriding_Approver(
5915 P_Approver_Id IN Per_People_F.Person_Id%TYPE,
5916 X_Approver_Id OUT NOCOPY Per_People_F.Person_Id%TYPE,
5917 X_Error_Type OUT NOCOPY Varchar2,
5918 X_Error_Code OUT NOCOPY Varchar2) Is
5919
5920 Begin
5921
5922 G_Stage := 'Entering procedure Validate_Overriding_Approver().';
5923 Pa_Otc_Api.TrackPath('ADD','Validate_Overriding_Approver');
5924
5925 G_Stage := 'Check if Approver Id populated or not.';
5926 If P_Approver_Id is Not Null Then
5927
5928 /*
5929 * Performance related change:
5930 * distinct clause added in this query so that the view Pa_Exp_Ovrrde_Approver_V
5931 * gets merged.
5932 */
5933 G_Stage := 'Get Overriding Approver Id.';
5934 Select
5935 Distinct
5936 Person_Id
5937 Into
5938 X_Approver_Id
5939 From
5940 Pa_Exp_Ovrrde_Approver_V
5941 Where
5942 Person_Id = P_Approver_Id;
5943
5944 Else -- P_Approver_Id is Null.
5945
5946 Raise No_Data_Found;
5947
5948 End If; -- End Approver_Id is not null
5949
5950 G_Stage := 'Leaving procedure Validate_Overriding_Approver().';
5951 Pa_Otc_Api.TrackPath('STRIP','Validate_Overriding_Approver');
5952
5953 Exception
5954 When No_Data_Found Then
5955 X_Error_Type := 'E';
5956 X_Error_Code := 'PA_OVRRDE_APPROVER_NOT_VALID';
5957
5958 When Too_Many_Rows Then
5959 X_Error_Type := 'E';
5960 X_Error_Code := 'PA_TOO_MANY_OVRRD_APPROVER';
5961
5962 When Others Then
5963 Raise;
5964
5965 End Validate_Overriding_Approver;
5966
5967
5968 -- =======================================================================
5969 -- Start of Comments
5970 -- API Name : DetermineProcessingFlags
5971 -- Type : Private
5972 -- Pre-Reqs : None
5973 -- Type : Procedure
5974 -- Return : n/a
5975 -- Function : This procedure deteremines the three flags necessary for processing
5976 -- of the data further along in the main processing routine
5977 -- Update_Validate_Timecard() which class this procedure at the for each
5978 -- DETAIL record being looped thru.
5979 --
5980 -- Parameters :
5981 -- IN
5982 -- P_BB_Id - Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE
5983 -- P_BB_Ovn - Hxc_Time_Building_Blocks.Object_Version_Number%TYPE
5984 -- P_BB_Date_To - Hxc_Time_Building_Blocks.Date_To%TYPE
5985 -- P_BB_Changed - VARCHAR2
5986 -- P_BB_New - VARCHAR2
5987 -- P_Proj_Attribute_Rec - Pa_Otc_Api.Project_Attribution_Rec
5988 -- P_Mode - VARCHAR2(10)
5989 -- P_Process_Flag - Varchar2(30)
5990 -- OUT
5991 -- X_BB_Detail_Changed - VARCHAR2(1)
5992 -- X_Data_Conflict_Flag - VARCHAR2(1)
5993 -- X_BB_Detail_Deleted - VARCHAR2(1)
5994 -- X_Adj_in_Projects_Flag - VARCHAR2(1)
5995 --
5996
5997 /*--------------------------------------------------------------------------*/
5998
5999 Procedure DetermineProcessingFlags (
6000 P_BB_Id IN Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE,
6001 P_BB_Ovn IN Hxc_Time_Building_Blocks.Object_Version_Number%TYPE,
6002 P_BB_Date_To IN Hxc_Time_Building_Blocks.Date_To%TYPE,
6003 P_BB_Changed IN Varchar2,
6004 P_BB_New IN Varchar2,
6005 P_Proj_Attribute_Rec IN Pa_Otc_Api.Project_Attribution_Rec,
6006 P_Mode IN Varchar2,
6007 P_Process_Flag IN Varchar2,
6008 X_BB_Detail_Changed OUT NOCOPY Varchar2,
6009 X_Data_Conflict_Flag OUT NOCOPY Varchar2,
6010 X_BB_Detail_Deleted OUT NOCOPY Varchar2,
6011 X_Adj_in_Projects_Flag OUT NOCOPY Varchar2)
6012
6013 Is
6014
6015 l_Orig_Trx_Ref Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE := Null;
6016 l_Net_Zero_flag Pa_Expenditure_Items_All.Net_Zero_Adjustment_Flag%TYPE := 'N';
6017 l_Max_Version Number := 0;
6018 l_RowId RowId;
6019 l_Exp_Item_Id Pa_Expenditure_Items_All.Expenditure_Item_Id%TYPE;
6020 l_Exp_Item_Comment Pa_Expenditure_Comments.Expenditure_Comment%TYPE;
6021 l_Ovn_Check_Value Number := 0;
6022
6023 Cursor AdjustmentRecords (P_Orig_Trx_Ref IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE) Is
6024 Select
6025 RowId,
6026 Expenditure_Item_Id,
6027 Net_Zero_Adjustment_Flag,
6028 Orig_Transaction_Reference
6029 From
6030 Pa_Expenditure_Items_All
6031 Where
6032 Transaction_Source = 'ORACLE TIME AND LABOR'
6033 And Orig_Transaction_Reference like l_orig_trx_ref
6034 Order By Orig_Transaction_Reference;
6035
6036 Cursor EiIsChanged ( P_RowId IN RowId ) Is
6037 Select
6038 'Y'
6039 From
6040 Pa_Expenditure_Items_All ei,
6041 Pa_Expenditure_Comments c
6042 Where
6043 ei.Expenditure_Item_Id = c.Expenditure_Item_Id(+)
6044 And (ei.Task_Id <> nvl(P_Proj_Attribute_Rec.Task_Id,-99)
6045 Or ei.Expenditure_Type <> nvl(P_Proj_Attribute_Rec.Expenditure_Type,'-999999999')
6046 Or ei.System_Linkage_Function <> nvl(P_Proj_Attribute_Rec.Sys_Linkage_Func,'-99')
6047 Or ei.Quantity <> nvl(P_Proj_Attribute_Rec.Quantity,-99)
6048 Or nvl(ei.Attribute_Category,'-99') <> nvl(P_Proj_Attribute_Rec.Attrib_Category,'-99')
6049 Or nvl(ei.Attribute1,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute1,'-99')
6050 Or nvl(ei.Attribute2,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute2,'-99')
6051 Or nvl(ei.Attribute3,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute3,'-99')
6052 Or nvl(ei.Attribute4,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute4,'-99')
6053 Or nvl(ei.Attribute5,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute5,'-99')
6054 Or nvl(ei.Attribute6,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute6,'-99')
6055 Or nvl(ei.Attribute7,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute7,'-99')
6056 Or nvl(ei.Attribute8,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute8,'-99')
6057 Or nvl(ei.Attribute9,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute9,'-99')
6058 Or nvl(ei.Attribute10,'-99') <> nvl(P_Proj_Attribute_Rec.Attribute10,'-99')
6059 Or nvl(c.Expenditure_Comment,'-99') <> nvl(P_Proj_Attribute_Rec.Expenditure_Item_Comment,'-99')
6060 Or nvl(ei.PO_Line_Id,-99) <> nvl(P_Proj_Attribute_Rec.PO_Line_Id,-99)
6061 Or nvl(ei.PO_Price_Type,'-99') <> nvl(P_Proj_Attribute_Rec.PO_Price_Type,'-99') )
6062 And ei.RowId = P_RowId;
6063
6064 AdjRec AdjustmentRecords%RowType;
6065 l_Orig_Transaction_Reference Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE;
6066 l_Ei_Changed_Flag Varchar2(1) := 'N';
6067
6068 E_Exception Exception;
6069
6070 Begin
6071
6072 G_Stage := 'Entering procedure DetermineProcessingFlags().';
6073 Pa_Otc_Api.TrackPath('ADD','DetermineProcessingFlags');
6074
6075 G_Stage := 'Initialize the out parameters to No.';
6076 X_BB_Detail_Changed := 'N';
6077 X_Data_Conflict_Flag := 'N';
6078 X_BB_Detail_Deleted := 'N';
6079 X_Adj_in_Projects_Flag := 'N';
6080
6081 G_Stage := 'Check for deleted detail bb.';
6082 If P_BB_Date_To <> Hr_General.End_Of_Time Then
6083
6084 G_Stage := 'Detail bb block has been deleted.';
6085 X_BB_Detail_Deleted := 'Y';
6086
6087 End If;
6088
6089 -- If an item has been deleted in OTL then P_BB_Changed = Y as well.
6090
6091 G_Stage := 'Check and setting the ovn value to scan Project ei table with';
6092 If P_BB_Changed = 'Y' and P_BB_New = 'N' Then
6093
6094 G_Stage := 'The detail scope bb has changed.';
6095 l_Ovn_Check_Value := P_BB_Ovn + 1;
6096 X_BB_Detail_Changed := 'Y';
6097
6098 ElsIf X_BB_Detail_Deleted = 'Y' Then
6099
6100 G_Stage := 'The detail scope bb is being deleted.';
6101 l_Ovn_Check_Value := P_BB_Ovn + 1;
6102
6103 ElsIf P_Process_Flag = 'Y' Then
6104
6105 -- Only the header for the timecard has been changed and not the detail
6106 -- building block, but the detail bb ovn still needs to be incremented.
6107 G_Stage := 'The detail scope bb is being processed.';
6108 l_Ovn_Check_Value := P_BB_Ovn + 1;
6109
6110 Else
6111
6112 l_Ovn_Check_Value := P_BB_Ovn;
6113
6114 End If;
6115
6116 /* Build the value for "where like" clause in cursor to check for in projects
6117 * in cursor call.
6118 */
6119
6120 G_Stage := 'Create conditional variable value.';
6121 l_orig_trx_ref := to_char(P_BB_Id) || ':%';
6122
6123 G_Stage := 'Open cursor AdjustmentRecords.';
6124 Open AdjustmentRecords (l_orig_trx_ref);
6125
6126 G_Stage := 'Start Loop for cursor AdjustmentRecords.';
6127 Loop
6128
6129 G_Stage := 'Fetch AdjustmentRecords.';
6130 Fetch AdjustmentRecords into AdjRec;
6131
6132 /* If there are no records then the exit routine is fire the first time
6133 * it is executed and the default value for the net zero flag of 'N' will be used.
6134 */
6135 Exit When AdjustmentRecords%NOTFOUND;
6136
6137 /* Since the original_transaction_reference columns is a concatenation of Building Block Id
6138 * and the Object Version Number for the OTL record being processed, we need to determine the
6139 * max Object Version Number always for determining if adjustments can be done, since we only
6140 * want to look at the last record imported into Projects for this with the same Building Block
6141 * Id in the pa_expenditure_items table.
6142 */
6143
6144 G_Stage := 'Check match condition.';
6145 If l_Max_Version < To_Number(Substr(AdjRec.Orig_Transaction_Reference,
6146 Instr(AdjRec.Orig_Transaction_Reference,':') + 1)) Then
6147
6148 G_Stage := 'Store nzf, row_id, ei_id, orig_trans_ref, and Max Version variables.';
6149 l_Net_Zero_flag := AdjRec.Net_Zero_Adjustment_Flag;
6150 l_Max_Version := To_Number(Substr(AdjRec.Orig_Transaction_Reference,
6151 Instr(AdjRec.Orig_Transaction_Reference,':') + 1));
6152 l_RowId := AdjRec.RowId;
6153 l_Exp_Item_Id := AdjRec.Expenditure_Item_Id;
6154 l_Orig_Transaction_Reference := AdjRec.Orig_Transaction_Reference;
6155
6156 ElsIf l_Max_Version = To_Number(Substr(AdjRec.Orig_Transaction_Reference,
6157 Instr(AdjRec.Orig_Transaction_Reference,':') + 1)) And
6158 nvl(AdjRec.Net_Zero_Adjustment_Flag,'N') <> 'Y' Then
6159
6160 /* If an earlier adjustment was made in OTL and that was sent to Project via Trx Import
6161 * there will be two ei records with the same Orig_Transaction_Reference. Both need to
6162 * be looked at since one will have a Net_Zero_Adjustment_Flag = 'Y' and the other will not.
6163 */
6164
6165 G_Stage := 'Store nzf, row_id, ei_id variables where org_trx_ref is same.';
6166 l_Net_Zero_flag := AdjRec.Net_Zero_Adjustment_Flag;
6167 l_RowId := AdjRec.RowId;
6168 l_Exp_Item_Id := AdjRec.Expenditure_Item_Id;
6169
6170 End If;
6171
6172 End Loop;
6173
6174 G_Stage := 'Close cursor AdjustmentRecords.';
6175 Close AdjustmentRecords;
6176
6177 /* If l_Max_Version = 0 Then the OTL Building Block was never imported into Projects.
6178 * If l_Max_Version > 0 Then the OTL Building Block has been imported at least once into Projects.
6179 */
6180
6181 G_Stage := 'Determining if BB sent for validation is a change from the one in projects.';
6182 If l_Max_Version > 0 Then
6183
6184 /* l_Max_Version should always be less than or equal to the Object_Version_Number
6185 * passed to this procedure. It should never be greater than the Object_Version_Number passed in.
6186 * If l_Max_Version = l_Ovn_Check_Value Then the bb was not changed and can ignore further testing.
6187 */
6188 If l_Max_Version < l_Ovn_Check_Value Then
6189
6190 G_Stage := 'Open cursor EiIsChanged.';
6191 Open EiIsChanged( l_RowId ) ;
6192
6193 G_Stage := 'Fetch from cursor EiIsChanged.';
6194 Fetch EiIsChanged into l_Ei_Changed_Flag;
6195
6196 G_Stage := 'Close cursor EiIsChanged.';
6197 Close EiIsChanged;
6198
6199 If l_Ei_Changed_Flag = 'N' Then
6200
6201 If P_Mode = 'VALIDATE' and
6202 ( P_BB_Changed = 'Y' or P_Process_Flag = 'Y' ) and
6203 X_BB_Detail_Deleted = 'N' Then
6204
6205 G_Stage := 'Only Ovn has changed. Update the orig_transaction_reference of the ei.';
6206 Update Pa_Expenditure_Items
6207 Set
6208 Orig_Transaction_Reference = To_Char(P_BB_Id) || ':' || To_Char(l_Ovn_Check_Value),
6209 last_update_date = sysdate,
6210 last_updated_by = to_Number(Fnd_Profile.Value('USER_ID')),
6211 last_update_login = to_Number(Fnd_Profile.Value('LOGIN_ID'))
6212 Where
6213 RowId = l_RowId;
6214
6215 -- Since only the ovn has changed we don't care about net zero flag value.
6216 -- And we can ignore the change over all since we are updating the
6217 -- ei record to store the new ovn. No change we care about has occurred.
6218 G_Stage := 'Set the BB_Detail_Changed flag to N.';
6219 X_BB_Detail_Changed := 'N';
6220 /* Bug 2283011 The changed_flag is coming in as 'N' for deleted items not 'Y' so
6221 we don't need to consider it value then.
6222 ElsIf P_BB_Changed = 'Y' and */
6223 ElsIf X_BB_Detail_Deleted = 'Y' and
6224 l_Net_Zero_flag = 'Y' Then
6225
6226 G_Stage := 'BB/EI has been already changed in Projects, so cannot delete.';
6227 X_Adj_in_Projects_Flag := 'Y';
6228
6229 End If;
6230
6231 Else -- The OTL detail block record is different from what is in Projects.
6232
6233 G_Stage := 'Check net zero flag value to indicate adj in Projects.';
6234 /* Note that If net zero flag is 'Y' then l_max_version > 0 */
6235 If l_Net_Zero_flag = 'Y' Then
6236
6237 G_Stage := 'BB/EI has been already changed in Projects, so cannot change.';
6238 X_Adj_in_Projects_Flag := 'Y' ;
6239
6240 G_Stage := 'Checking for Data confict.';
6241 If P_BB_Changed = 'N' and X_BB_Detail_Deleted = 'N' Then
6242
6243 G_Stage := 'Data conflict exists.';
6244 X_Data_Conflict_Flag := 'Y';
6245
6246 End If;
6247
6248 End If; -- Net_Zero_Flag
6249
6250 End If; -- l_Ei_Changed_Flag = 'N'
6251
6252 End If; -- l_Max_Version < l_Ovn_Check_Value
6253
6254 End If; -- l_Max_Version > 0
6255
6256 G_Stage := 'Leaving procedure DetermineProcessingFlags().';
6257 Pa_Otc_Api.TrackPath('STRIP','DetermineProcessingFlags');
6258
6259 Exception
6260 When Others Then
6261 Raise;
6262
6263 End DetermineProcessingFlags;
6264
6265
6266 -- =======================================================================
6267 -- Start of Comments
6268 -- API Name : AdjustAllowedToOTCItem
6269 -- Type : Public
6270 -- Pre-Reqs : None
6271 -- Type : Procedure
6272 -- Function : This procedure is used to check and see if an OTL expenditure item that
6273 -- has been imported into Projects can adjusted in Projects by calling the
6274 -- API Hxc_Generic_Retrieval_Utils.Time_Bld_Blk_Changed.
6275 --
6276 -- Parameters :
6277 -- IN P_Orig_Txn_Reference - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
6278 -- OUT X_Flag - Varchar2(1)
6279 --
6280 /*--------------------------------------------------------------------------*/
6281
6282 Procedure AdjustAllowedToOTCItem(
6283 P_Orig_Txn_Reference IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE,
6284 X_flag OUT NOCOPY BOOLEAN) Is
6285
6286 l_BB_Id Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE;
6287 l_BB_Ovn Hxc_Time_Building_Blocks.Object_Version_Number%TYPE;
6288 l_Changed_Flag Boolean := False;
6289
6290 Begin
6291
6292 G_Stage := 'Entering procedure AdjustAllowedToOTCItem().';
6293 Pa_Otc_Api.TrackPath('ADD','AdjustAllowedToOTCItem');
6294
6295 G_Path := ' ';
6296
6297 G_Stage := 'Check if the original transaction reference is null or not.';
6298 If P_Orig_Txn_Reference Is Not Null Then
6299
6300 G_Stage := 'BB Id and BB Ovn.';
6301 l_BB_Id := To_Number(SubStr(P_Orig_Txn_Reference,1,InStr(P_Orig_Txn_Reference,':') - 1));
6302 l_BB_Ovn := To_Number(SubStr(P_Orig_Txn_Reference,InStr(P_Orig_Txn_Reference,':') + 1));
6303
6304 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Time_Bld_Blk_Changed API.';
6305 l_Changed_Flag := Hxc_Integration_Layer_V1_Grp.Time_Bld_Blk_Changed(
6306 P_Bb_Id => l_bb_id,
6307 P_Bb_Ovn => l_bb_ovn);
6308
6309 G_Stage := 'Set out going flag based on what OTL is saying.';
6310 If l_Changed_Flag Then
6311
6312 X_flag := False;
6313
6314 Else
6315
6316 X_Flag := True;
6317
6318 End If;
6319
6320 Else
6321
6322 /* Did not originate in OTL. This item is a resulting child of the
6323 * original OTL item that was adjusted. So want to always default it
6324 * so that it can adjusted and let other code restrictions in PA handle
6325 * whether or not the expenditure item can be adjusted.
6326 */
6327 X_Flag := True;
6328
6329 End If;
6330
6331 G_Stage := 'Leaving procedure AdjustAllowedToOTCItem().';
6332 Pa_Otc_Api.TrackPath('STRIP','AdjustAllowedToOTCItem');
6333
6334 Exception
6335 When Others Then
6336 Raise_Application_Error(-20003,'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM);
6337
6338 End AdjustAllowedToOTCItem;
6339
6340
6341 -- =======================================================================
6342 -- Start of Comments
6343 -- API Name : ProjectTaskUsed
6344 -- Type : Public
6345 -- Pre-Reqs : None
6346 -- Type : Procedure
6347 -- Return : n/a
6348 -- Function : This procedure is used to check to see if there are Project OTL
6349 -- expenditure items that are using a specific project or task. Will be calling
6350 -- an OTL API to determine this. If parameters are not properly populated then
6351 -- return TRUE.
6352 --
6353 -- Parameters :
6354 -- IN P_Search_Attribute - Varchar2 -- 'PROJECT_ID' or 'TASK_ID'
6355 -- P_Search_Value - Number -- Project_Id or Task_Id
6356 -- OUT X_Used - Boolean
6357 --
6358
6359 /*--------------------------------------------------------------------------*/
6360
6361 Procedure ProjectTaskUsed(
6362 P_Search_Attribute IN Varchar2,
6363 P_Search_Value IN Number,
6364 X_Used OUT NOCOPY Boolean)
6365
6366 Is
6367
6368 l_Attribute_Exists Boolean := False;
6369
6370 Begin
6371
6372 G_Stage := 'Entering procedure ProjectTaskUsed().';
6373 Pa_Otc_Api.TrackPath('ADD','ProjectTaskUsed');
6374
6375 G_Path := ' ';
6376
6377 G_Stage := 'Check that the parameters is valid.';
6378 If P_Search_Attribute in ('PROJECT','TASK') and P_Search_Value is not null Then
6379
6380 If P_Search_Attribute = 'PROJECT' Then
6381
6382 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists() API to check if project exists.';
6383 l_Attribute_Exists := Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists (
6384 P_Bld_Blk_Info_Type => 'PROJECTS'
6385 , P_Field_Name => 'Project_Id'
6386 , P_Field_Value => P_Search_Value
6387 , P_Scope => 'DETAIL');
6388
6389 Else
6390
6391 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists() API to check if task exists.';
6392 l_Attribute_Exists := Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists (
6393 P_Bld_Blk_Info_Type => 'PROJECTS'
6394 , P_Field_Name => 'Task_Id'
6395 , P_Field_Value => P_Search_Value
6396 , P_Scope => 'DETAIL');
6397
6398 End If;
6399
6400
6401 X_Used := l_Attribute_Exists;
6402
6403 Else
6404
6405 X_Used := True;
6406
6407 End If;
6408
6409 G_Stage := 'Leaving procedure ProjectTaskUsed().';
6410 Pa_Otc_Api.TrackPath('STRIP','ProjectTaskUsed');
6411
6412 Exception
6413 When Others Then
6414 Raise_Application_Error(-20005,'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM);
6415
6416 End ProjectTaskUsed;
6417
6418 -- =======================================================================
6419 -- Start of Comments
6420 -- API Name : ProjectTaskPurgeable
6421 -- Type : Public
6422 -- Pre-Reqs : None
6423 -- Type : Procedure
6424 -- Return : n/a
6425 -- Function : This procedure is used to check to see if there are Project OTC
6426 -- expenditure items that are using a specific project or task that have/have not been
6427 -- imported successfullying into projects. Will be calling
6428 -- an OTC API to determine this. If parameters are not properly populated then
6429 -- return TRUE.
6430 --
6431 -- Parameters :
6432 -- IN P_Search_Attribute - Varchar2 -- 'PROJECT' or 'TASK'
6433 -- P_Search_Value - Number -- Project_Id or Task_Id
6434 -- OUT X_Purgeable - Boolean
6435 --
6436
6437 /*--------------------------------------------------------------------------*/
6438
6439 Procedure ProjectTaskPurgeable(P_Search_Attribute IN Varchar2,
6440 P_Search_Value IN Number,
6441 X_Purgeable OUT NOCOPY Boolean)
6442
6443 Is
6444
6445 l_Attribute_Purgeable Boolean := False;
6446
6447 Begin
6448
6449 G_Stage := 'Entering procedure ProjectTaskPurgeable().';
6450 Pa_Otc_Api.TrackPath('ADD','ProjectTaskPurgeable');
6451
6452 G_Path := ' ';
6453
6454 G_Stage := 'Check that the parameters is valid.';
6455 If P_Search_Attribute in ('PROJECT','TASK') And P_Search_Value is Not Null Then
6456
6457 If P_Search_Attribute = 'PROJECT' Then
6458
6459 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists() API procedure to check if project purgeable.';
6460 l_Attribute_Purgeable := Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists (
6461 P_Bld_Blk_Info_Type => 'PROJECTS'
6462 , P_Field_Name => 'Project_Id'
6463 , P_Field_Value => P_Search_Value
6464 , P_Scope => 'DETAIL'
6465 , P_Retrieval_Process_Name => 'Projects Retrieval Process');
6466
6467 Else
6468
6469 G_Stage := 'Call Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists() API procedure to check if task purgeable.';
6470 l_Attribute_Purgeable := Hxc_Integration_Layer_V1_Grp.Chk_Mapping_Exists (
6471 P_Bld_Blk_Info_Type => 'PROJECTS'
6472 , P_Field_Name => 'Task_Id'
6473 , P_Field_Value => P_Search_Value
6474 , P_Scope => 'DETAIL'
6475 , P_Retrieval_Process_Name => 'Projects Retrieval Process');
6476
6477 End If;
6478
6479
6480 /* Chk_Mapping_Exists() returns TRUE if the field name / value combination exist but have
6481 * not yet been transferred. FALSE, if they have been transferred or the
6482 * combination does not exist.
6483 */
6484 If l_Attribute_Purgeable Then
6485
6486 X_Purgeable := False;
6487
6488 Else
6489
6490 X_Purgeable := True;
6491
6492 End If;
6493
6494 Else
6495
6496 X_Purgeable := False;
6497
6498 End If;
6499
6500 G_Stage := 'Leaving procedure ProjectTaskPurgeable().';
6501 Pa_Otc_Api.TrackPath('STRIP','ProjectTaskPurgeable');
6502
6503 Exception
6504 When Others Then
6505 Raise_Application_Error(-20006,'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM);
6506
6507 End ProjectTaskPurgeable;
6508
6509
6510 -- ========================================================================
6511 -- Start Of Comments
6512 -- API Name : RetrieveProjAttribution
6513 -- Type : Private
6514 -- Pre-Reqs : None
6515 -- Type : Procedure
6516 -- Return : n/a
6517 -- Function : This procedure is used to pull out the needed project specific data from
6518 -- the OTL pl/sql table P_Attribute_Table.
6519 --
6520 -- Parameters :
6521 -- IN P_Building_Block_Rec - Hxc_User_Type_Definition_Grp.Building_Block_Info
6522 -- P_Building_Block - Hxc_User_Type_Definition_Grp.Timecard_Info
6523 -- P_Attribute_Table - Hxc_User_Type_Definition_Grp.App_Attributes_Info
6524 -- X_Detail_Attr_Changed - Varchar2
6525 -- OUT
6526 -- X_Detail_Attr_Changed - Varchar2
6527 -- X_Proj_Attrib_Rec - Pa_Otc_Api.Project_Attribution_Rec
6528 --
6529
6530 /*--------------------------------------------------------------------------*/
6531
6532 Procedure RetrieveProjAttribution(
6533 P_Building_Block_Rec IN Hxc_User_Type_Definition_Grp.Building_Block_Info,
6534 P_Building_Block IN Hxc_User_Type_Definition_Grp.Timecard_Info,
6535 P_Attribute_Table IN Hxc_User_Type_Definition_Grp.App_Attributes_Info,
6536 X_Detail_Attr_Changed IN OUT NOCOPY Varchar2,
6537 X_Proj_Attrib_Rec OUT NOCOPY Pa_Otc_Api.Project_Attribution_Rec) -- 2672653
6538
6539 Is
6540
6541 j Binary_Integer := Null;
6542 i Binary_Integer := Null;
6543 l_Attrib_Category Varchar2(30) := Null;
6544
6545 Begin
6546
6547 G_Stage := 'Entering procedure RetrieveProjAttribution().';
6548 Pa_Otc_Api.TrackPath('ADD','RetrieveProjAttribution');
6549
6550 G_Stage := 'Entering attribute table loop.';
6551 Loop
6552
6553 If j is null Then
6554
6555 j := P_Attribute_Table.First;
6556
6557 Else
6558
6559 j := P_Attribute_Table.Next(j);
6560
6561 End If;
6562
6563 G_Stage := 'Looping thru attribute pl/sql table yanking out project attribution for current record.';
6564 If P_Attribute_Table(j).Building_Block_Id = P_Building_Block_Rec.Time_Building_Block_Id Then
6565
6566 If Upper(P_Attribute_Table(j).Attribute_Name) = 'PROJECT_ID' Then
6567
6568 G_Stage := 'Get Project Id.';
6569 X_Proj_Attrib_Rec.Project_Id := To_Number(P_Attribute_Table(j).Attribute_Value);
6570 G_Stage := 'Get Project Attribute Id.';
6571 X_Proj_Attrib_Rec.Proj_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6572 -- X_Proj_Attrib_Rec.Proj_Attr_Ovn := P_Attribute_Table(j).Object_Version_Number;
6573
6574 G_Stage := 'Check project changed flag.';
6575 If P_Attribute_Table(j).Changed <> 'N' Then
6576 X_Detail_Attr_Changed := 'Y';
6577 End If;
6578
6579 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'TASK_ID' Then
6580
6581 G_Stage := 'Get Task Id.';
6582 X_Proj_Attrib_Rec.Task_Id := To_Number(P_Attribute_Table(j).Attribute_Value);
6583 G_Stage := 'Get Task Attribute Id';
6584 X_Proj_Attrib_Rec.Task_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6585
6586 G_Stage := 'Check task changed flag.';
6587 If P_Attribute_Table(j).Changed <> 'N' Then
6588 X_Detail_Attr_Changed := 'Y';
6589 End If;
6590
6591 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'EXPENDITURE_TYPE' Then
6592
6593 G_Stage := 'Get Expenditure Type.';
6594 X_Proj_Attrib_Rec.Expenditure_Type := P_Attribute_Table(j).Attribute_Value;
6595 G_Stage := 'Get Expenditure Type Attribute Id';
6596 X_Proj_Attrib_Rec.Exp_Type_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6597
6598 G_Stage := 'Check expenditure_type changed flag.';
6599 If P_Attribute_Table(j).Changed <> 'N' Then
6600 X_Detail_Attr_Changed := 'Y';
6601 End If;
6602
6603 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'SYSTEM_LINKAGE_FUNCTION' Then
6604
6605 G_Stage := 'Get Sys Link Func.';
6606 X_Proj_Attrib_Rec.Sys_Linkage_Func := P_Attribute_Table(j).Attribute_Value;
6607 G_Stage := 'Get Sys Link Func Attribute Id.';
6608 X_Proj_Attrib_Rec.Sys_Link_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6609
6610 G_Stage := 'Check sys link func changed flag.';
6611 If P_Attribute_Table(j).Changed <> 'N' Then
6612 X_Detail_Attr_Changed := 'Y';
6613 End If;
6614
6615 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'DUMMY PAEXPITDFF CONTEXT' Then
6616
6617 /* The value column contains the following format:
6618 * 'PAEXPITDFF - <attribute_category>'
6619 * So to get the attribute_category out will need to find the position
6620 * for ' - ' that is: '<space>-<space>' and then add 3.
6621 */
6622
6623 l_Attrib_Category := P_Attribute_Table(j).Attribute_Value;
6624
6625 /* Need to check for null to avoid the unecessary errors using instr
6626 * avoiding unhandled exceptions.
6627 */
6628 If l_Attrib_Category is not null Then
6629
6630 G_Stage := 'Get DFF Attribute Category.';
6631 X_Proj_Attrib_Rec.Attrib_Category := substr(l_Attrib_Category, instr(l_Attrib_category,' - ') + 3);
6632
6633 End If;
6634
6635 G_Stage := 'Check Attribute Category changed flag.';
6636 If P_Attribute_Table(j).Changed <> 'N' Then
6637 X_Detail_Attr_Changed := 'Y';
6638 End If;
6639
6640 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE1' Then
6641
6642 G_Stage := 'Get DFF Attribute 1.';
6643 X_Proj_Attrib_Rec.Attribute1 := P_Attribute_Table(j).Attribute_Value;
6644
6645 G_Stage := 'Check DFF Attribute 1 changed flag.';
6646 If P_Attribute_Table(j).Changed <> 'N' Then
6647 X_Detail_Attr_Changed := 'Y';
6648 End If;
6649
6650 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE2' Then
6651
6652 G_Stage := 'Get DFF Attribute 2.';
6653 X_Proj_Attrib_Rec.Attribute2 := P_Attribute_Table(j).Attribute_Value;
6654
6655 G_Stage := 'Check DFF Attribute 2 changed flag.';
6656 If P_Attribute_Table(j).Changed <> 'N' Then
6657 X_Detail_Attr_Changed := 'Y';
6658 End If;
6659
6660 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE3' Then
6661
6662 G_Stage := 'Get DFF Attribute 3.';
6663 X_Proj_Attrib_Rec.Attribute3 := P_Attribute_Table(j).Attribute_Value;
6664
6665 G_Stage := 'Check DFF Attribute 3 changed flag.';
6666 If P_Attribute_Table(j).Changed <> 'N' Then
6667 X_Detail_Attr_Changed := 'Y';
6668 End If;
6669
6670 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE4' Then
6671
6672 G_Stage := 'Get DFF Attribute 4.';
6673 X_Proj_Attrib_Rec.Attribute4 := P_Attribute_Table(j).Attribute_Value;
6674
6675 G_Stage := 'Check DFF Attribute 4 changed flag.';
6676 If P_Attribute_Table(j).Changed <> 'N' Then
6677 X_Detail_Attr_Changed := 'Y';
6678 End If;
6679
6680 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE5' Then
6681
6682 G_Stage := 'Get DFF Attribute 5.';
6683 X_Proj_Attrib_Rec.Attribute5 := P_Attribute_Table(j).Attribute_Value;
6684
6685 G_Stage := 'Check DFF Attribute 5 changed flag.';
6686 If P_Attribute_Table(j).Changed <> 'N' Then
6687 X_Detail_Attr_Changed := 'Y';
6688 End If;
6689
6690 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE6' Then
6691
6692 G_Stage := 'Get DFF Attribute 6.';
6693 X_Proj_Attrib_Rec.Attribute6 := P_Attribute_Table(j).Attribute_Value;
6694
6695 G_Stage := 'Check DFF Attribute 6 changed flag.';
6696 If P_Attribute_Table(j).Changed <> 'N' Then
6697 X_Detail_Attr_Changed := 'Y';
6698 End If;
6699
6700 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE7' Then
6701
6702 G_Stage := 'Get DFF Attribute 7.';
6703 X_Proj_Attrib_Rec.Attribute7 := P_Attribute_Table(j).Attribute_Value;
6704
6705 G_Stage := 'Check DFF Attribute 7 changed flag.';
6706 If P_Attribute_Table(j).Changed <> 'N' Then
6707 X_Detail_Attr_Changed := 'Y';
6708 End If;
6709
6710 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE8' Then
6711
6712 G_Stage := 'Get DFF Attribute 8.';
6713 X_Proj_Attrib_Rec.Attribute8 := P_Attribute_Table(j).Attribute_Value;
6714
6715 G_Stage := 'Check DFF Attribute 8 changed flag.';
6716 If P_Attribute_Table(j).Changed <> 'N' Then
6717 X_Detail_Attr_Changed := 'Y';
6718 End If;
6719
6720 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE9' Then
6721
6722 G_Stage := 'Get DFF Attribute 9.';
6723 X_Proj_Attrib_Rec.Attribute9 := P_Attribute_Table(j).Attribute_Value;
6724
6725 G_Stage := 'Check DFF Attribute 9 changed flag.';
6726 If P_Attribute_Table(j).Changed <> 'N' Then
6727 X_Detail_Attr_Changed := 'Y';
6728 End If;
6729
6730 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE10' Then
6731
6732 G_Stage := 'Get DFF Attribute 10.';
6733 X_Proj_Attrib_Rec.Attribute10 := P_Attribute_Table(j).Attribute_Value;
6734
6735 G_Stage := 'Check DFF Attribute 10 changed flag.';
6736 If P_Attribute_Table(j).Changed <> 'N' Then
6737 X_Detail_Attr_Changed := 'Y';
6738 End If;
6739
6740 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'BILLABLE_FLAG' Then
6741
6742 G_Stage := 'Get Billable Flag Index value.';
6743 X_Proj_Attrib_Rec.Billable_Flag_Index := j;
6744
6745 G_Stage := 'Get Billable Flag.';
6746 X_Proj_Attrib_Rec.Billable_Flag := P_Attribute_Table(j).Attribute_Value;
6747
6748 G_Stage := 'Get Billable Flag Attribute Id.';
6749 X_Proj_Attrib_Rec.Billable_Flag_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6750
6751 -- G_Stage := 'Get Billable Flag Attribute Ovn.';
6752 -- X_Proj_Attrib_Rec.Billable_Flag_Attr_Ovn := P_Attribute_Table(j).Object_Version_Number;
6753
6754 -- Begin CWK changes PA.M
6755 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PO LINE ID' Then
6756
6757 G_Stage := 'Get PO_Line Number.';
6758 X_Proj_Attrib_Rec.Po_Line_Id := P_Attribute_Table(j).Attribute_Value;
6759 G_Stage := 'Get PO Line Id Attribute Id.';
6760 X_Proj_Attrib_Rec.PO_Line_Id_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6761
6762 G_Stage := 'Check PO_Line Number change flag.';
6763 If P_Attribute_Table(j).Changed <> 'N' Then
6764 X_Detail_Attr_Changed := 'Y';
6765 End If;
6766
6767 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PO PRICE TYPE' Then
6768
6769 G_Stage := 'Get Price Type.';
6770 X_Proj_Attrib_Rec.PO_Price_Type := P_Attribute_Table(j).Attribute_Value;
6771 G_Stage := 'Get Price Type Attribute Id.';
6772 X_Proj_Attrib_Rec.PO_Price_Type_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6773
6774 G_Stage := 'Check Price Type change flag.';
6775 If P_Attribute_Table(j).Changed <> 'N' Then
6776 X_Detail_Attr_Changed := 'Y';
6777 End If;
6778
6779 -- End CWK changes PA.M
6780 End If;
6781
6782 End If; -- The correct building block to pull data from.
6783
6784 G_Stage := 'Exit loop check.';
6785 Exit When j = P_Attribute_Table.Last;
6786
6787 End Loop;
6788
6789 G_Stage := 'Get Expenditure Item Date using loop to grab from DAY scope record.';
6790 /* The Start Time column in the DETAIL scope record passed to this procedure will not be populated.
6791 So we must grab the Start Time column value from the DAY scope. We will loop thru the same table
6792 containing the entire timecard and find the correct DAY scope record for the detail scope record that
6793 we are currently working on. */
6794
6795 Loop
6796
6797 If i is null Then
6798
6799 i := P_Building_Block.First;
6800
6801 Else
6802
6803 i := P_Building_Block.Next(i);
6804
6805 End If;
6806
6807 G_Stage := 'Check if the current record is the correct DAY record to grab Exp Item Date from.';
6808 If P_Building_Block(i).Time_Building_Block_Id = P_Building_Block_Rec.Parent_Building_Block_Id and
6809 P_Building_Block(i).Scope = 'DAY' Then
6810
6811 G_Stage := 'Grab the Exp Item Date and exit the loop.';
6812 X_Proj_Attrib_Rec.Expenditure_Item_Date := Trunc(P_Building_Block(i).Start_Time);
6813 Exit;
6814
6815 End If;
6816
6817 End Loop;
6818
6819 G_Stage := 'Get Expenditure Ending Date.';
6820 X_Proj_Attrib_Rec.Exp_Ending_date := Pa_Utils.NewGetWeekEnding(X_Proj_Attrib_Rec.Expenditure_Item_Date);
6821
6822 G_Stage := 'Get Unit of Measure.';
6823 X_Proj_Attrib_Rec.UOM := P_Building_Block_Rec.Unit_Of_Measure;
6824
6825 G_Stage := 'Get Inc By Person Id.';
6826 X_Proj_Attrib_Rec.Inc_By_Person_Id := P_Building_Block_Rec.Resource_Id;
6827
6828 G_Stage := 'Get the Quantity.';
6829 X_Proj_Attrib_Rec.Quantity := to_number(P_Building_Block_Rec.Measure);
6830
6831 G_Stage := 'Get the Expenditure Item Comment.';
6832 /* Bug 2930551 Check for length and truncate if needed */
6833 -- begin bug 4926265
6834 -- If length(P_Building_Block_Rec.Comment_Text) > 240 Then
6835 If lengthb(P_Building_Block_Rec.Comment_Text) > 240 Then
6836
6837 -- X_Proj_Attrib_Rec.Expenditure_Item_Comment := substr(P_Building_Block_Rec.Comment_Text,1,240);
6838 X_Proj_Attrib_Rec.Expenditure_Item_Comment := substrb(P_Building_Block_Rec.Comment_Text,1,240);
6839 -- end bug 4926265
6840
6841 Else
6842
6843 X_Proj_Attrib_Rec.Expenditure_Item_Comment := P_Building_Block_Rec.Comment_Text;
6844
6845 End If;
6846
6847 -- Beging CWK changes PA.M
6848 G_Stage := 'Get Person_Type.';
6849 X_Proj_Attrib_Rec.Person_Type := Pa_Otc_Api.GetPersonType(
6850 P_Person_Id => X_Proj_Attrib_Rec.Inc_By_Person_Id,
6851 P_Ei_Date => X_Proj_Attrib_Rec.Expenditure_Item_Date);
6852
6853
6854 If X_Proj_Attrib_Rec.Person_Type = 'CWK' And X_Proj_Attrib_Rec.Po_Line_Id Is Not Null Then
6855
6856 G_Stage := 'Get PO Info.';
6857 PA_Otc_Api.GetPOInfo(
6858 P_PO_Line_Id => X_Proj_Attrib_Rec.Po_Line_Id,
6859 X_PO_Header_Id => X_Proj_Attrib_Rec.PO_Header_Id,
6860 X_Vendor_Id => X_Proj_Attrib_Rec.Vendor_Id);
6861
6862 End If;
6863
6864 -- End CWK changes PA.M
6865 G_Stage := 'Leaving procedure RetrieveProjAttribution().';
6866 Pa_Otc_Api.TrackPath('STRIP','RetrieveProjAttribution');
6867
6868 Exception
6869 When Others Then
6870 Raise;
6871
6872 End RetrieveProjAttribution;
6873
6874
6875 -- ========================================================================
6876 -- Start Of Comments
6877 -- API Name : RetrieveProjAttribForUpd
6878 -- Type : Private
6879 -- Pre-Reqs : None
6880 -- Type : Procedure
6881 -- Return : n/a
6882 -- Function : This procedure is used to pull out the needed project specific data from
6883 -- the OTL pl/sql table P_Attribute_Table.
6884 --
6885 -- Parameters :
6886 -- IN P_Building_Block_Rec - Hxc_User_Type_Definition_Grp.Building_Block_Info
6887 -- P_Building_Block - Hxc_User_Type_Definition_Grp.Timecard_Info
6888 -- P_Attribute_Table - Hxc_User_Type_Definition_Grp.App_Attributes_Info
6889 -- X_Detail_Attr_Changed - Varchar2
6890 -- OUT
6891 -- P_Attribute_Table - Hxc_User_Type_Definition_Grp.App_Attributes_Info
6892 -- X_Detail_Attr_Changed - Varchar2
6893 -- X_Proj_Attrib_Rec - Pa_Otc_Api.Project_Attribution_Rec
6894 --
6895
6896 /*--------------------------------------------------------------------------*/
6897
6898 Procedure RetrieveProjAttribForUpd(
6899 P_Building_Block_Rec IN Hxc_User_Type_Definition_Grp.Building_Block_Info,
6900 P_Building_Block IN Hxc_User_Type_Definition_Grp.Timecard_Info,
6901 P_Attribute_Table IN OUT NOCOPY Hxc_User_Type_Definition_Grp.App_Attributes_Info,
6902 X_Detail_Attr_Changed IN OUT NOCOPY Varchar2,
6903 X_Proj_Attrib_Rec OUT NOCOPY Pa_Otc_Api.Project_Attribution_Rec) -- 2672653
6904
6905 Is
6906
6907 j Binary_Integer := Null;
6908 i Binary_Integer := Null;
6909 l_Attrib_Category Varchar2(30) := Null;
6910 found_billable BOOLEAN ;
6911 billable_index BINARY_INTEGER := Null;
6912 project_index BINARY_INTEGER := Null;
6913
6914 Begin
6915
6916 G_Stage := 'Entering procedure RetrieveProjAttribution().';
6917 Pa_Otc_Api.TrackPath('ADD','RetrieveProjAttribution');
6918
6919 found_billable := false;
6920
6921 G_Stage := 'Entering attribute table loop.';
6922 Loop
6923
6924 If j is null Then
6925
6926 j := P_Attribute_Table.First;
6927
6928 Else
6929
6930 j := P_Attribute_Table.Next(j);
6931
6932 End If;
6933
6934 G_Stage := 'Looping thru attribute pl/sql table yanking out project attribution for current record.';
6935 If P_Attribute_Table(j).Building_Block_Id = P_Building_Block_Rec.Time_Building_Block_Id Then
6936
6937 If Upper(P_Attribute_Table(j).Attribute_Name) = 'PROJECT_ID' Then
6938
6939 G_Stage := 'Get Project Id.';
6940 project_index := j;
6941 X_Proj_Attrib_Rec.Project_Id := To_Number(P_Attribute_Table(j).Attribute_Value);
6942 G_Stage := 'Get Project Attribute Id.';
6943 X_Proj_Attrib_Rec.Proj_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6944 -- X_Proj_Attrib_Rec.Proj_Attr_Ovn := P_Attribute_Table(j).Object_Version_Number;
6945
6946 G_Stage := 'Check project changed flag.';
6947 If P_Attribute_Table(j).Changed <> 'N' Then
6948 X_Detail_Attr_Changed := 'Y';
6949 End If;
6950
6951 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'TASK_ID' Then
6952
6953 G_Stage := 'Get Task Id.';
6954 X_Proj_Attrib_Rec.Task_Id := To_Number(P_Attribute_Table(j).Attribute_Value);
6955 G_Stage := 'Get Task Attribute Id';
6956 X_Proj_Attrib_Rec.Task_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6957
6958 G_Stage := 'Check task changed flag.';
6959 If P_Attribute_Table(j).Changed <> 'N' Then
6960 X_Detail_Attr_Changed := 'Y';
6961 End If;
6962
6963 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'EXPENDITURE_TYPE' Then
6964
6965 G_Stage := 'Get Expenditure Type.';
6966 X_Proj_Attrib_Rec.Expenditure_Type := P_Attribute_Table(j).Attribute_Value;
6967 G_Stage := 'Get Expenditure Type Attribute Id';
6968 X_Proj_Attrib_Rec.Exp_Type_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6969
6970 G_Stage := 'Check expenditure_type changed flag.';
6971 If P_Attribute_Table(j).Changed <> 'N' Then
6972 X_Detail_Attr_Changed := 'Y';
6973 End If;
6974
6975 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'SYSTEM_LINKAGE_FUNCTION' Then
6976
6977 G_Stage := 'Get Sys Link Func.';
6978 X_Proj_Attrib_Rec.Sys_Linkage_Func := P_Attribute_Table(j).Attribute_Value;
6979 G_Stage := 'Get Sys Link Func Attribute Id.';
6980 X_Proj_Attrib_Rec.Sys_Link_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
6981
6982 G_Stage := 'Check sys link func changed flag.';
6983 If P_Attribute_Table(j).Changed <> 'N' Then
6984 X_Detail_Attr_Changed := 'Y';
6985 End If;
6986
6987 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'DUMMY PAEXPITDFF CONTEXT' Then
6988
6989 /* The value column contains the following format:
6990 * 'PAEXPITDFF - <attribute_category>'
6991 * So to get the attribute_category out will need to find the position
6992 * for ' - ' that is: '<space>-<space>' and then add 3.
6993 */
6994
6995 l_Attrib_Category := P_Attribute_Table(j).Attribute_Value;
6996
6997 /* Need to check for null to avoid the unecessary errors using instr
6998 * avoiding unhandled exceptions.
6999 */
7000 If l_Attrib_Category is not null Then
7001
7002 G_Stage := 'Get DFF Attribute Category.';
7003 X_Proj_Attrib_Rec.Attrib_Category := substr(l_Attrib_Category, instr(l_Attrib_category,' - ') + 3);
7004
7005 End If;
7006
7007 G_Stage := 'Check Attribute Category changed flag.';
7008 If P_Attribute_Table(j).Changed <> 'N' Then
7009 X_Detail_Attr_Changed := 'Y';
7010 End If;
7011
7012 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE1' Then
7013
7014 G_Stage := 'Get DFF Attribute 1.';
7015 X_Proj_Attrib_Rec.Attribute1 := P_Attribute_Table(j).Attribute_Value;
7016
7017 G_Stage := 'Check DFF Attribute 1 changed flag.';
7018 If P_Attribute_Table(j).Changed <> 'N' Then
7019 X_Detail_Attr_Changed := 'Y';
7020 End If;
7021
7022 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE2' Then
7023
7024 G_Stage := 'Get DFF Attribute 2.';
7025 X_Proj_Attrib_Rec.Attribute2 := P_Attribute_Table(j).Attribute_Value;
7026
7027 G_Stage := 'Check DFF Attribute 2 changed flag.';
7028 If P_Attribute_Table(j).Changed <> 'N' Then
7029 X_Detail_Attr_Changed := 'Y';
7030 End If;
7031
7032 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE3' Then
7033
7034 G_Stage := 'Get DFF Attribute 3.';
7035 X_Proj_Attrib_Rec.Attribute3 := P_Attribute_Table(j).Attribute_Value;
7036
7037 G_Stage := 'Check DFF Attribute 3 changed flag.';
7038 If P_Attribute_Table(j).Changed <> 'N' Then
7039 X_Detail_Attr_Changed := 'Y';
7040 End If;
7041
7042 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE4' Then
7043
7044 G_Stage := 'Get DFF Attribute 4.';
7045 X_Proj_Attrib_Rec.Attribute4 := P_Attribute_Table(j).Attribute_Value;
7046
7047 G_Stage := 'Check DFF Attribute 4 changed flag.';
7048 If P_Attribute_Table(j).Changed <> 'N' Then
7049 X_Detail_Attr_Changed := 'Y';
7050 End If;
7051
7052 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE5' Then
7053
7054 G_Stage := 'Get DFF Attribute 5.';
7055 X_Proj_Attrib_Rec.Attribute5 := P_Attribute_Table(j).Attribute_Value;
7056
7057 G_Stage := 'Check DFF Attribute 5 changed flag.';
7058 If P_Attribute_Table(j).Changed <> 'N' Then
7059 X_Detail_Attr_Changed := 'Y';
7060 End If;
7061
7062 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE6' Then
7063
7064 G_Stage := 'Get DFF Attribute 6.';
7065 X_Proj_Attrib_Rec.Attribute6 := P_Attribute_Table(j).Attribute_Value;
7066
7067 G_Stage := 'Check DFF Attribute 6 changed flag.';
7068 If P_Attribute_Table(j).Changed <> 'N' Then
7069 X_Detail_Attr_Changed := 'Y';
7070 End If;
7071
7072 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE7' Then
7073
7074 G_Stage := 'Get DFF Attribute 7.';
7075 X_Proj_Attrib_Rec.Attribute7 := P_Attribute_Table(j).Attribute_Value;
7076
7077 G_Stage := 'Check DFF Attribute 7 changed flag.';
7078 If P_Attribute_Table(j).Changed <> 'N' Then
7079 X_Detail_Attr_Changed := 'Y';
7080 End If;
7081
7082 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE8' Then
7083
7084 G_Stage := 'Get DFF Attribute 8.';
7085 X_Proj_Attrib_Rec.Attribute8 := P_Attribute_Table(j).Attribute_Value;
7086
7087 G_Stage := 'Check DFF Attribute 8 changed flag.';
7088 If P_Attribute_Table(j).Changed <> 'N' Then
7089 X_Detail_Attr_Changed := 'Y';
7090 End If;
7091
7092 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE9' Then
7093
7094 G_Stage := 'Get DFF Attribute 9.';
7095 X_Proj_Attrib_Rec.Attribute9 := P_Attribute_Table(j).Attribute_Value;
7096
7097 G_Stage := 'Check DFF Attribute 9 changed flag.';
7098 If P_Attribute_Table(j).Changed <> 'N' Then
7099 X_Detail_Attr_Changed := 'Y';
7100 End If;
7101
7102 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PADFFATTRIBUTE10' Then
7103
7104 G_Stage := 'Get DFF Attribute 10.';
7105 X_Proj_Attrib_Rec.Attribute10 := P_Attribute_Table(j).Attribute_Value;
7106
7107 G_Stage := 'Check DFF Attribute 10 changed flag.';
7108 If P_Attribute_Table(j).Changed <> 'N' Then
7109 X_Detail_Attr_Changed := 'Y';
7110 End If;
7111
7112 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'BILLABLE_FLAG' Then
7113
7114 G_Stage := 'Get Billable Flag Index value.';
7115 X_Proj_Attrib_Rec.Billable_Flag_Index := j;
7116
7117 G_Stage := 'Get Billable Flag.';
7118 X_Proj_Attrib_Rec.Billable_Flag := P_Attribute_Table(j).Attribute_Value;
7119
7120 G_Stage := 'Get Billable Flag Attribute Id.';
7121 X_Proj_Attrib_Rec.Billable_Flag_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
7122
7123 -- G_Stage := 'Get Billable Flag Attribute Ovn.';
7124 -- X_Proj_Attrib_Rec.Billable_Flag_Attr_Ovn := P_Attribute_Table(j).Object_Version_Number;
7125
7126 G_Stage := 'Found Billable Flag Attribute.';
7127 found_billable := true;
7128
7129 -- Begin CWK changes PA.M
7130 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PO LINE ID' Then
7131
7132 G_Stage := 'Get PO_Line Number.';
7133 X_Proj_Attrib_Rec.Po_Line_Id := P_Attribute_Table(j).Attribute_Value;
7134 G_Stage := 'Get PO Line Id Attribute Id.';
7135 X_Proj_Attrib_Rec.PO_Line_Id_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
7136
7137 G_Stage := 'Check PO_Line Number change flag.';
7138 If P_Attribute_Table(j).Changed <> 'N' Then
7139 X_Detail_Attr_Changed := 'Y';
7140 End If;
7141
7142 ElsIf Upper(P_Attribute_Table(j).Attribute_Name) = 'PO PRICE TYPE' Then
7143
7144 G_Stage := 'Get Price Type.';
7145 X_Proj_Attrib_Rec.PO_Price_Type := P_Attribute_Table(j).Attribute_Value;
7146 G_Stage := 'Get Price Type Attribute Id.';
7147 X_Proj_Attrib_Rec.PO_Price_Type_Attr_Id := P_Attribute_Table(j).Time_Attribute_Id;
7148
7149 G_Stage := 'Check Price Type change flag.';
7150 If P_Attribute_Table(j).Changed <> 'N' Then
7151 X_Detail_Attr_Changed := 'Y';
7152 End If;
7153
7154 -- End CWK changes PA.M
7155 End If;
7156
7157 End If; -- The correct building block to pull data from.
7158
7159 G_Stage := 'Exit loop check.';
7160 Exit When j = P_Attribute_Table.Last;
7161
7162 End Loop;
7163
7164 G_Stage := 'Check if found billable_flag.';
7165 If(NOT found_billable) Then
7166
7167 --
7168 -- We must add the billable flag to the attribute structure, and set the values
7169 -- appropriately. We permit the normal processing of the PA code to determine
7170 -- if this value should be changed.
7171 --
7172 G_Stage := 'Did not find billable_flag so get next available index.';
7173 billable_index := P_Attribute_Table.Last+1;
7174 --
7175 -- Find the billable segment name
7176 -- Cache it, since we don't want to issue the statement
7177 -- more than we need to, and the value should be session
7178 -- independent.
7179 --
7180 G_Stage := 'Check if already know the dff segment for the billable_flag.';
7181 If(G_Billable_Segment is null) then
7182
7183 G_Stage := 'Get the segment for the billable_flag from hxc table.';
7184 select mc.segment
7185 Into G_Billable_Segment
7186 from hxc_mapping_components mc,
7187 hxc_bld_blk_info_types bbit
7188 where mc.field_name = 'BILLABLE_FLAG'
7189 and bbit.bld_blk_info_type_id = mc.bld_blk_info_type_id
7190 and bbit.bld_blk_info_type = 'PROJECTS';
7191
7192 End If;
7193
7194 If project_index is not null then
7195 --
7196 -- Add the (null) value
7197 -- the PROJECTS attribute is a seeded one, but is customizable by the customer.
7198 --
7199 G_Stage := 'Create the billable_flag attribute record.';
7200 P_Attribute_Table(billable_index).time_attribute_id := P_Attribute_Table(project_index).time_attribute_id;
7201 P_Attribute_Table(billable_index).building_block_id := P_Attribute_Table(project_index).building_block_id;
7202 P_Attribute_Table(billable_index).attribute_name := 'BILLABLE_FLAG';
7203 P_Attribute_Table(billable_index).attribute_value := null;
7204 P_Attribute_Table(billable_index).attribute_index := P_Attribute_Table(project_index).attribute_index;
7205 P_Attribute_Table(billable_index).segment := G_Billable_Segment;
7206 P_Attribute_Table(billable_index).bld_blk_info_type := P_Attribute_Table(project_index).bld_blk_info_type;
7207 P_Attribute_Table(billable_index).category := P_Attribute_Table(project_index).category;
7208 P_Attribute_Table(billable_index).updated := 'N';
7209 P_Attribute_Table(billable_index).changed := 'N';
7210 --
7211 -- Set internal Project attributes based on above value
7212 --
7213 X_Proj_Attrib_Rec.Billable_Flag_Index := billable_index;
7214 X_Proj_Attrib_Rec.Billable_Flag := Null;
7215 X_Proj_Attrib_Rec.Billable_Flag_Attr_Id := P_Attribute_Table(billable_index).Time_Attribute_Id;
7216
7217 End If;
7218
7219 End If; -- Did we find the billable flag?
7220
7221 G_Stage := 'Get Expenditure Item Date using loop to grab from DAY scope record.';
7222 /* The Start Time column in the DETAIL scope record passed to this procedure will not be populated.
7223 So we must grab the Start Time column value from the DAY scope. We will loop thru the same table
7224 containing the entire timecard and find the correct DAY scope record for the detail scope record that
7225 we are currently working on. */
7226
7227 Loop
7228
7229 If i is null Then
7230
7231 i := P_Building_Block.First;
7232
7233 Else
7234
7235 i := P_Building_Block.Next(i);
7236
7237 End If;
7238
7239 G_Stage := 'Check if the current record is the correct DAY record to grab Exp Item Date from.';
7240 If P_Building_Block(i).Time_Building_Block_Id = P_Building_Block_Rec.Parent_Building_Block_Id and
7241 P_Building_Block(i).Scope = 'DAY' Then
7242
7243 G_Stage := 'Grab the Exp Item Date and exit the loop.';
7244 X_Proj_Attrib_Rec.Expenditure_Item_Date := Trunc(P_Building_Block(i).Start_Time);
7245 Exit;
7246
7247 End If;
7248
7249 End Loop;
7250
7251 G_Stage := 'Get Expenditure Ending Date.';
7252 X_Proj_Attrib_Rec.Exp_Ending_date := Pa_Utils.NewGetWeekEnding(X_Proj_Attrib_Rec.Expenditure_Item_Date);
7253
7254 G_Stage := 'Get Unit of Measure.';
7255 X_Proj_Attrib_Rec.UOM := P_Building_Block_Rec.Unit_Of_Measure;
7256
7257 G_Stage := 'Get Inc By Person Id.';
7258 X_Proj_Attrib_Rec.Inc_By_Person_Id := P_Building_Block_Rec.Resource_Id;
7259
7260 G_Stage := 'Get the Quantity.';
7261 X_Proj_Attrib_Rec.Quantity := to_number(P_Building_Block_Rec.Measure);
7262
7263 G_Stage := 'Get the Expenditure Item Comment.';
7264 /* Bug 2930551 Check for length and truncate if needed */
7265 -- begin bug 4926265
7266 -- If length(P_Building_Block_Rec.Comment_Text) > 240 Then
7267 If lengthb(P_Building_Block_Rec.Comment_Text) > 240 Then
7268
7269 -- X_Proj_Attrib_Rec.Expenditure_Item_Comment := substr(P_Building_Block_Rec.Comment_Text,1,240);
7270 X_Proj_Attrib_Rec.Expenditure_Item_Comment := substrb(P_Building_Block_Rec.Comment_Text,1,240);
7271 -- end bug 4926265
7272
7273 Else
7274
7275 X_Proj_Attrib_Rec.Expenditure_Item_Comment := P_Building_Block_Rec.Comment_Text;
7276
7277 End If;
7278
7279 -- Beging CWK changes PA.M
7280 G_Stage := 'Get Person_Type.';
7281 X_Proj_Attrib_Rec.Person_Type := Pa_Otc_Api.GetPersonType(
7282 P_Person_Id => X_Proj_Attrib_Rec.Inc_By_Person_Id,
7283 P_Ei_Date => X_Proj_Attrib_Rec.Expenditure_Item_Date);
7284
7285
7286 If X_Proj_Attrib_Rec.Person_Type = 'CWK' And X_Proj_Attrib_Rec.Po_Line_Id Is Not Null Then
7287
7288 G_Stage := 'Get PO Info.';
7289 PA_Otc_Api.GetPOInfo(
7290 P_PO_Line_Id => X_Proj_Attrib_Rec.Po_Line_Id,
7291 X_PO_Header_Id => X_Proj_Attrib_Rec.PO_Header_Id,
7292 X_Vendor_Id => X_Proj_Attrib_Rec.Vendor_Id);
7293
7294 End If;
7295
7296 -- End CWK changes PA.M
7297 G_Stage := 'Leaving procedure RetrieveProjAttribution().';
7298 Pa_Otc_Api.TrackPath('STRIP','RetrieveProjAttribution');
7299
7300 Exception
7301 When Others Then
7302 Raise;
7303
7304 End RetrieveProjAttribForUpd;
7305
7306 -- ========================================================================
7307 -- Start Of Comments
7308 -- API Name : GetPRMAssignTemplates
7309 -- Type : Public
7310 -- Pre-Reqs : None
7311 -- Type : Procedure
7312 -- Return : n/a
7313 -- Function : This procedure is used to pull from PRM the Forecast Assignment data and provide
7314 -- it as template data for OTL. It will not have TASK information in it. It will
7315 -- be placed in OTL friendly format for the OTL team to populate the current timecard
7316 -- with the Forecast Assignment data. Validation for expenditure_type and system_linkage_function
7317 -- combinations will take place within the code before passing it to OTL. Any combo that
7318 -- is not valid for the day in question will not be pulled over.
7319 --
7320 -- Parameters :
7321 -- IN P_Resource_Id - Hxc_Time_Building_Blocks.Resource_Id%TYPE
7322 -- P_Start_Date - Hxc_Time_Building_Blocks.Start_Time%TYPE
7323 -- P_Stop_Date - Hxc_Time_Building_Blocks.Stop_Time%TYPE
7324 -- OUT
7325 -- P_Attributes - Varchar2
7326 -- P_Timecard - Varchar2
7327 -- P_Messages - Varchar2
7328
7329
7330 /*--------------------------------------------------------------------------*/
7331
7332 Procedure GetPRMAssignTemplates(
7333 P_Resource_Id IN Hxc_Time_Building_Blocks.Resource_Id%TYPE,
7334 P_Start_Date IN Hxc_Time_Building_Blocks.Start_Time%TYPE,
7335 P_Stop_Date IN Hxc_Time_Building_Blocks.Stop_Time%TYPE,
7336 P_Attributes OUT NOCOPY Varchar2,
7337 P_Timecard OUT NOCOPY Varchar2,
7338 P_Messages OUT NOCOPY Varchar2)
7339
7340 Is
7341
7342 l_BB_Index Binary_Integer := 0;
7343 l_Attrib_Index Binary_Integer := 0;
7344 l_Time_Building_Block_Id Number := 1;
7345 l_Day_Parent_BB_Id Number := Null;
7346 l_Org_Id Number := Null;
7347 l_Valid_ExpTypClass_Combo Varchar2(1) := Null;
7348 l_Val_Proj_Flag Varchar2(1) := Null;
7349
7350 l_Building_Blocks_Table Hxc_User_Type_Definition_Grp.Timecard_Info;
7351 l_Attribute_Table Hxc_User_Type_Definition_Grp.App_Attributes_info;
7352 l_Message_Table Hxc_User_Type_Definition_Grp.Message_Table;
7353
7354 l_dummy_bb_Table Hxc_User_Type_Definition_Grp.Timecard_Info;
7355 l_dummy_Attrib_Table Hxc_User_Type_Definition_Grp.App_Attributes_info;
7356
7357 /* If the profile value is NULL or 'N' then we want to retrieve all the records
7358 * irregardless of the value stored in column Provisional_Flag.
7359 * If the profile value is 'Y' then we only want to retrieve those records
7360 * where column Provisional_Flag = 'Y'.
7361 */
7362 /* Begin bug 5011267
7363 Cursor PRMAssignments(
7364 P_Emp_Id IN Number,
7365 P_Start_Date IN Date,
7366 P_Stop_Date IN Date,
7367 P_Exp_Org_Id IN Number) is
7368 Select
7369 FI.Project_Id,
7370 P.Segment1,
7371 FI.Item_Date,
7372 FI.Expenditure_Type,
7373 FI.Expenditure_Type_Class,
7374 FI.Item_Quantity
7375 From
7376 Pa_Forecast_Items FI,
7377 Pa_Projects_All P,
7378 Pa_Project_Assignments PPA
7379 Where
7380 Person_Id = P_Emp_Id
7381 And Item_Date Between P_Start_Date
7382 And P_Stop_Date
7383 And Forecast_Item_Type in ('A','U')
7384 And FI.Project_Id = P.Project_Id
7385 And PPA.assignment_id = FI.assignment_id
7386 And FI.delete_flag = 'N'
7387 And Nvl(FI.expenditure_org_id,-99) = Nvl(P_Exp_Org_Id,-99)
7388 And Nvl(FI.Item_Quantity,0) <> 0
7389 Order by 2,4,3; -- project/exp_type/item_date
7390 */
7391
7392 /* Begin Bug 5366183
7393 Cursor PRMAssignments(
7394 P_Emp_Id IN Number,
7395 P_Start_Date IN Date,
7396 P_Stop_Date IN Date,
7397 P_Exp_Org_Id IN Number) is
7398 Select
7399 FI.Project_Id,
7400 P.Segment1,
7401 FI.Item_Date,
7402 FI.Expenditure_Type,
7403 FI.Expenditure_Type_Class,
7404 FI.Item_Quantity
7405 From
7406 Pa_Forecast_Items FI,
7407 Pa_Projects_All P
7408 Where
7409 Person_Id = P_Emp_Id
7410 And Item_Date Between P_Start_Date
7411 And P_Stop_Date
7412 And Forecast_Item_Type = 'A'
7413 And FI.Project_Id = P.Project_Id
7414 And FI.delete_flag = 'N'
7415 And FI.expenditure_org_id = P_Exp_Org_Id
7416 And FI.Item_Quantity <> 0
7417 Order by 2,4,3; -- project/exp_type/item_date
7418 */
7419 /* End bug 5011267 */
7420
7421 Cursor PRMAssignments(
7422 P_Emp_Id IN Number,
7423 P_Start_Date IN Date,
7424 P_Stop_Date IN Date,
7425 P_Exp_Org_Id IN Number) is
7426 Select
7427 FI.Project_Id,
7428 P.Segment1,
7429 FI.Item_Date,
7430 FI.Expenditure_Type,
7431 FI.Expenditure_Type_Class,
7432 FI.Item_Quantity
7433 From
7434 Pa_Forecast_Items FI,
7435 Pa_Projects_All P,
7436 Pa_Resource_Txn_Attributes PTA
7437 Where
7438 PTA.Person_Id = P_Emp_Id
7439 And FI.Resource_id = PTA.Resource_id
7440 And FI.Item_Date Between P_Start_Date
7441 And P_Stop_Date
7442 And FI.Forecast_Item_Type = 'A'
7443 And FI.Project_Id = P.Project_Id
7444 And FI.delete_flag = 'N'
7445 And FI.expenditure_org_id = P_Exp_Org_Id
7446 And FI.Item_Quantity <> 0
7447 Order by 2,4,3; -- project/exp_type/item_date
7448 /* End bug 5366183 */
7449
7450 /* Expenditure_Type_Class is the system_linkage_function */
7451 -- Cursor ValidateExpTypeAndClass (P_Exp_Item_Date IN Date,
7452 -- P_Exp_Type IN Varchar2,
7453 -- P_Exp_Type_Class IN Varchar2) Is
7454 -- Select
7455 -- 'Y'
7456 -- From
7457 -- Pa_Online_Expenditure_Types_V
7458 -- Where
7459 -- Expenditure_Type = P_Exp_Type
7460 -- And System_Linkage_Function = P_Exp_Type_Class
7461 -- And Trunc(P_Exp_Item_Date) Between Expnd_Typ_Start_Date_Active
7462 -- And nvl(Expnd_Typ_End_Date_Active, P_Exp_Item_Date)
7463 -- And Trunc(P_Exp_Item_Date) Between Sys_Link_Start_Date_Active
7464 -- And nvl(Sys_Link_End_Date_Active, P_Exp_Item_Date);
7465
7466 PRMAssignRecs PRMAssignments%ROWTYPE;
7467
7468 -- Cursor ValidateProject ( P_Project_Id IN Pa_Projects_All.Project_Id%TYPE ) Is
7469 -- Select
7470 -- 'Y'
7471 -- From
7472 -- Pa_Online_Projects_V
7473 -- Where
7474 -- Project_Id = P_Project_Id;
7475
7476 TYPE Day_Rec IS Record (
7477 Day_Index_Number Binary_Integer,
7478 Date_for_Day Date);
7479
7480 TYPE Day_Table IS Table OF Day_Rec
7481 INDEX BY Binary_Integer;
7482
7483 l_Day_Table Day_Table;
7484 l_Days_in_Period Number := 0;
7485
7486
7487 Begin
7488
7489 G_Path := ' ';
7490
7491 G_Stage := 'Entering procedure GetPRMAssignTemplates().';
7492 Pa_Otc_Api.TrackPath('ADD','GetPRMAssignTemplates');
7493
7494 G_Stage := 'Initialize the pl/sql message table.';
7495 l_Message_Table.Delete;
7496 l_Building_Blocks_Table.Delete;
7497 l_Attribute_Table.Delete;
7498 l_dummy_bb_Table.Delete;
7499 l_dummy_Attrib_Table.Delete;
7500
7501 /* Begin Bug 3766110
7502 There is no reason to do any validation in building the template data
7503 since the data will get validated when the OTL user submits the timecard.
7504
7505 -- The default period length for a timecard is a week for Projects OTL timecards.
7506 -- But that can be changed. If the default is kept, then we want to make sure that
7507 -- the week ending date is consistant with Projects implementation.
7508
7509 l_Days_in_Period := Trunc(P_Stop_Date) - Trunc(P_Start_Date) + 1;
7510
7511 G_Stage := 'Checking start and end dates. Check if OTL using week long timecards.';
7512 If l_Days_in_Period = 7 Then
7513
7514 G_Stage := 'Checking end the Stop_Date passed in matches WeekEnding dates in Projects.';
7515 If Pa_Utils.NewGetWeekEnding(Trunc(P_Stop_Date)) <> Trunc(P_Stop_Date) Then
7516
7517 G_Msg_Tokens_Table.Delete;
7518
7519 -- Add record to error table.
7520 Pa_Otc_Api.Add_Error_To_Table(
7521 P_Message_Table => l_Message_Table,
7522 P_Message_Name => 'PA_INVALID_WEEK_ENDING_DATE',
7523 P_Message_Level => 'ERROR',
7524 P_Message_Field => Null,
7525 P_Msg_Tokens => G_Msg_Tokens_Table,
7526 P_Time_Building_Block_Id => Null,
7527 P_Time_Attribute_Id => Null);
7528
7529 End If;
7530
7531 End If;
7532
7533 End bug 3766110 */
7534
7535 l_Days_in_Period := Trunc(P_Stop_Date) - Trunc(P_Start_Date) + 1;
7536
7537 /* Begin bug 3766110
7538 G_Stage := 'If messages now exist in pl/sql table then do not do any further processing. OTL not properly setup.';
7539 If l_Message_Table.Count = 0 Then
7540 End bug 3766110 */
7541
7542 G_Stage := 'Assigning null dummy tables to the BB and Attribution pl/sql tables. ';
7543 l_Building_Blocks_Table := l_dummy_BB_Table;
7544 l_Attribute_Table := l_dummy_Attrib_Table;
7545
7546 G_Stage := 'Check Multi Org';
7547 If Pa_Utils.Pa_Morg_Implemented = 'Y' Then
7548
7549 l_Org_Id := Fnd_Profile.Value('ORG_ID');
7550
7551 End If;
7552
7553 -- Insert Timecard Scope record
7554 G_Stage := 'Build/Insert Timecard Scope BB record.';
7555 l_BB_Index := l_BB_Index + 1;
7556 l_Building_Blocks_Table(l_BB_Index).Resource_Id := P_Resource_Id;
7557 l_Building_Blocks_Table(l_BB_Index).Start_Time := P_Start_Date;
7558 l_Building_Blocks_Table(l_BB_Index).Stop_Time := P_Stop_Date;
7559 l_Building_Blocks_Table(l_BB_Index).Scope := 'TIMECARD';
7560 l_Building_Blocks_Table(l_BB_Index).Date_From := SysDate;
7561 l_Building_Blocks_Table(l_BB_Index).Date_To := Hr_General.End_Of_Time;
7562 l_Building_Blocks_Table(l_BB_Index).New := 'Y';
7563 l_Building_Blocks_Table(l_BB_Index).Resource_Type := 'PERSON';
7564 l_Building_Blocks_Table(l_BB_Index).Type := 'RANGE';
7565 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Id := Null;
7566 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Ovn := Null;
7567 l_Building_Blocks_Table(l_BB_Index).Approval_Status := 'WORKING';
7568 l_Building_Blocks_Table(l_BB_Index).Approval_Style_Id := Null;
7569 l_Building_Blocks_Table(l_BB_Index).Time_Building_Block_Id := l_Time_Building_Block_Id;
7570 l_Building_Blocks_Table(l_BB_Index).Object_Version_Number := 1;
7571 l_Building_Blocks_Table(l_BB_Index).Comment_Text := Null;
7572 l_Building_Blocks_Table(l_BB_Index).Measure := Null;
7573 l_Building_Blocks_Table(l_BB_Index).Unit_Of_Measure := Null;
7574
7575
7576 -- Insert Day Scope records.
7577 G_Stage := 'Build/Insert day scope records using loop based on the number of days in timecard period.';
7578 For i in 1 .. l_Days_in_Period
7579 loop
7580
7581 G_Stage := 'Create Day Scope Record 1.';
7582 l_BB_Index := l_BB_Index + 1;
7583 l_Time_Building_Block_Id := l_Time_Building_Block_Id + 1;
7584
7585 l_Building_Blocks_Table(l_BB_Index).Resource_Id := P_Resource_Id;
7586 l_Building_Blocks_Table(l_BB_Index).Start_Time := P_Start_Date + i - 1;
7587 l_Building_Blocks_Table(l_BB_Index).Stop_Time := P_Start_Date + i - 1;
7588 l_Building_Blocks_Table(l_BB_Index).Scope := 'DAY';
7589 l_Building_Blocks_Table(l_BB_Index).Date_From := SysDate;
7590 l_Building_Blocks_Table(l_BB_Index).Date_To := Hr_General.End_Of_Time;
7591 l_Building_Blocks_Table(l_BB_Index).New := 'Y';
7592 l_Building_Blocks_Table(l_BB_Index).Resource_Type := 'PERSON';
7593 l_Building_Blocks_Table(l_BB_Index).Type := 'RANGE';
7594 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Id := 1;
7595 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Ovn := 1;
7596 l_Building_Blocks_Table(l_BB_Index).Approval_Status := 'WORKING';
7597 l_Building_Blocks_Table(l_BB_Index).Approval_Style_Id := Null;
7598 l_Building_Blocks_Table(l_BB_Index).Time_Building_Block_Id := l_Time_Building_Block_Id;
7599 l_Building_Blocks_Table(l_BB_Index).Object_Version_Number := 1;
7600 l_Building_Blocks_Table(l_BB_Index).Comment_Text := Null;
7601 l_Building_Blocks_Table(l_BB_Index).Measure := Null;
7602 l_Building_Blocks_Table(l_BB_Index).Unit_Of_Measure := Null;
7603
7604 l_Day_Table(i).Day_Index_Number := l_BB_Index;
7605 l_Day_Table(i).Date_for_Day := l_Building_Blocks_Table(l_BB_Index).Start_Time;
7606
7607 End Loop;
7608
7609 -- Create Detail Scope Records as appropriate
7610 G_Stage := 'Open cursor PRMAssignments to get detail scope data.';
7611 Open PRMAssignments (
7612 P_Emp_Id => P_Resource_Id,
7613 P_Start_Date => P_Start_Date,
7614 P_Stop_Date => P_Stop_Date,
7615 P_Exp_Org_Id => l_Org_Id);
7616
7617 G_Stage := 'Start Loop for cursor PRMAssignments.';
7618 Loop
7619
7620 G_Stage := 'Fetch forecast assignment record into record.';
7621 Fetch PRMAssignments into PRMAssignRecs;
7622 Exit When PRMAssignments%NotFound;
7623
7624 /* Begin bug 3766110
7625 There is no reason to do any validation in building the template data
7626 since the data will get validated when the OTL user submits the timecard.
7627
7628 Check if the expenditure and system_linkage_function combo is valid for the
7629 date in question.
7630
7631 l_Valid_ExpTypClass_Combo := 'N';
7632
7633 G_Stage := 'Validate Expenditure_Type/Expenditure_Type_Class, open cursor.';
7634 Open ValidateExpTypeAndClass(
7635 PRMAssignRecs.Item_Date,
7636 PRMAssignRecs.Expenditure_Type,
7637 PRMAssignRecs.Expenditure_Type_Class);
7638
7639 G_Stage := 'Validate Expenditure_Type/Expenditure_Type_Class, fetch cursor data.';
7640 Fetch ValidateExpTypeAndClass Into l_Valid_ExpTypClass_Combo;
7641
7642 G_Stage := 'Validate Expenditure_Type/Expenditure_Type_Class, close cursor.';
7643 Close ValidateExpTypeAndClass;
7644
7645 l_Val_Proj_Flag := 'N';
7646
7647 G_Stage := 'Validate Project, open cursor.';
7648 Open ValidateProject(PRMAssignRecs.Project_Id);
7649
7650 G_Stage := 'Validate Project, fetch cursor data.';
7651 Fetch ValidateProject Into l_Val_Proj_Flag;
7652
7653 G_Stage := 'Validate Project, close cursor.';
7654 Close ValidateProject;
7655
7656 If l_Valid_ExpTypClass_Combo = 'Y' and l_Val_Proj_Flag = 'Y' Then
7657 */
7658 -- End bug 3766110
7659
7660 G_Stage := 'Building and insert detail scope record.';
7661
7662 l_BB_Index := l_BB_Index + 1;
7663 l_Time_Building_Block_Id := l_Time_Building_Block_Id + 1;
7664
7665 <<Day_Loop>>
7666 For p in l_Day_Table.FIRST .. l_Day_Table.LAST
7667 Loop
7668
7669 If l_Day_Table(p).Date_For_Day = PRMAssignRecs.Item_Date Then
7670
7671 l_Day_Parent_BB_Id := l_Day_Table(p).Day_Index_Number;
7672 Exit Day_Loop;
7673
7674 End If;
7675
7676 End Loop Day_Loop;
7677
7678 l_Building_Blocks_Table(l_BB_Index).Resource_Id := P_Resource_Id;
7679 l_Building_Blocks_Table(l_BB_Index).Start_Time := Null;
7680 l_Building_Blocks_Table(l_BB_Index).Stop_Time := Null;
7681 l_Building_Blocks_Table(l_BB_Index).Scope := 'DETAIL';
7682 l_Building_Blocks_Table(l_BB_Index).Date_From := SysDate;
7683 l_Building_Blocks_Table(l_BB_Index).Date_To := Hr_General.End_Of_Time;
7684 l_Building_Blocks_Table(l_BB_Index).New := 'Y';
7685 l_Building_Blocks_Table(l_BB_Index).Resource_Type := 'PERSON';
7686 l_Building_Blocks_Table(l_BB_Index).Type := 'MEASURE';
7687 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Id := l_Day_Parent_BB_Id;
7688 l_Building_Blocks_Table(l_BB_Index).Parent_Building_Block_Ovn := 1;
7689 l_Building_Blocks_Table(l_BB_Index).Approval_Status := 'WORKING';
7690 l_Building_Blocks_Table(l_BB_Index).Approval_Style_Id := Null;
7691 l_Building_Blocks_Table(l_BB_Index).Time_Building_Block_Id := l_Time_Building_Block_Id;
7692 l_Building_Blocks_Table(l_BB_Index).Object_Version_Number := 1;
7693 l_Building_Blocks_Table(l_BB_Index).Comment_Text := Null;
7694 l_Building_Blocks_Table(l_BB_Index).Measure := PRMAssignRecs.Item_Quantity;
7695 l_Building_Blocks_Table(l_BB_Index).Unit_Of_Measure := 'HOURS';
7696
7697 -- Create Detail Scope Attribution
7698
7699 G_Stage := 'Building and insert detail scope attribution records.';
7700 -- Project Id
7701
7702 G_Stage := 'Building and insert detail scope attribution record project_Id.';
7703 l_Attrib_Index := l_Attrib_Index + 1;
7704
7705 l_Attribute_Table(l_Attrib_Index).Time_Attribute_Id := l_Time_Building_Block_Id;
7706 l_Attribute_Table(l_Attrib_Index).Building_Block_Id := l_Time_Building_Block_Id;
7707 l_Attribute_Table(l_Attrib_Index).Attribute_Name := 'Project_Id';
7708 l_Attribute_Table(l_Attrib_Index).Attribute_Value := PRMAssignRecs.Project_Id;
7709 l_Attribute_Table(l_Attrib_Index).Updated := 'N';
7710 l_Attribute_Table(l_Attrib_Index).Bld_Blk_Info_Type := 'PROJECTS';
7711 l_Attribute_Table(l_Attrib_Index).Category := 'PROJECTS';
7712
7713 -- Expenditure Type
7714
7715 G_Stage := 'Building and insert detail scope attribution record Expenditure Type.';
7716 l_Attrib_Index := l_Attrib_Index + 1;
7717
7718 l_Attribute_Table(l_Attrib_Index).Time_Attribute_Id := l_Time_Building_Block_Id;
7719 l_Attribute_Table(l_Attrib_Index).Building_Block_Id := l_Time_Building_Block_Id;
7720 l_Attribute_Table(l_Attrib_Index).Attribute_Name := 'Expenditure_Type';
7721 l_Attribute_Table(l_Attrib_Index).Attribute_Value := PRMAssignRecs.Expenditure_Type;
7722 l_Attribute_Table(l_Attrib_Index).Updated := 'N';
7723 l_Attribute_Table(l_Attrib_Index).Bld_Blk_Info_Type := 'PROJECTS';
7724 l_Attribute_Table(l_Attrib_Index).Category := 'PROJECTS';
7725
7726 -- System Linkage Function
7727
7728 G_Stage := 'Building and insert detail scope attribution record Expenditure_Type_Class.';
7729 l_Attrib_Index := l_Attrib_Index + 1;
7730
7731 l_Attribute_Table(l_Attrib_Index).Time_Attribute_Id := l_Time_Building_Block_Id;
7732 l_Attribute_Table(l_Attrib_Index).Building_Block_Id := l_Time_Building_Block_Id;
7733 l_Attribute_Table(l_Attrib_Index).Attribute_Name := 'SYSTEM_LINKAGE_FUNCTION';
7734 l_Attribute_Table(l_Attrib_Index).Attribute_Value := PRMAssignRecs.Expenditure_Type_Class;
7735 l_Attribute_Table(l_Attrib_Index).Updated := 'N';
7736 l_Attribute_Table(l_Attrib_Index).Bld_Blk_Info_Type := 'PROJECTS';
7737 l_Attribute_Table(l_Attrib_Index).Category := 'PROJECTS';
7738
7739 /* Begin bug 3766110
7740 Else
7741
7742 G_Msg_Tokens_Table.Delete;
7743
7744 If l_Val_Proj_Flag = 'N' Then
7745
7746 G_Stage := 'Create error message for Invalid Project in PRM Template.';
7747 Pa_Otc_Api.Add_Error_To_Table(
7748 P_Message_Table => l_Message_Table,
7749 P_Message_Name => 'INVALID_PROJECT',
7750 P_Message_Level => 'ERROR',
7751 P_Message_Field => 'Project_Id',
7752 P_Msg_Tokens => G_Msg_Tokens_Table,
7753 P_Time_Building_Block_Id => Null,
7754 P_Time_Attribute_Id => Null);
7755
7756 End If;
7757
7758 If l_Valid_ExpTypClass_Combo = 'N' Then
7759
7760 G_Stage := 'Create error message for Invalid Exp Type/Sys ' ||
7761 'Link func in PRM Template.';
7762 Pa_Otc_Api.Add_Error_To_Table(
7763 P_Message_Table => l_Message_Table,
7764 P_Message_Name => 'INVALID_ETYPE_SYSLINK',
7765 P_Message_Level => 'ERROR',
7766 P_Message_Field => 'Expenditure_Type',
7767 P_Msg_Tokens => G_Msg_Tokens_Table,
7768 P_Time_Building_Block_Id => Null,
7769 P_Time_Attribute_Id => Null);
7770
7771 End If;
7772
7773 End If; -- Valid ExpTypeClass Combo
7774 */
7775 -- End bug 3766110
7776
7777 End Loop; -- Cursor with the data from PRM Assignment forecast data.
7778
7779 G_Stage := 'Closing cursor PRMAssignments.';
7780 Close PRMAssignments;
7781
7782 -- End If; Bug 3766110
7783
7784
7785 -- The building blocs table will at least have the timecard scope record and the 7 day scope records
7786 -- so there must be more than 8 records in the pl/sql table to determine if there is data to send back to OTL.
7787 -- There cannot be any records in the message table as that would mean error and don't want to pass
7788 -- back a partial set of building blocks.
7789 If l_Building_Blocks_Table.Count > 1 Then -- and l_Message_Table.Count = 0 Then bug 3766110
7790
7791 G_Stage := 'Convert Building Blocks pl/sql table to varchar2.';
7792 P_Timecard := Hxc_Integration_Layer_V1_Grp.Blocks_To_String( P_Blocks => l_Building_Blocks_Table );
7793
7794 G_Stage := 'Convert Attribution pl/sql table to varchar2.';
7795 P_Attributes := Hxc_Integration_Layer_V1_Grp.Attributes_To_String ( P_Attributes => l_Attribute_Table );
7796
7797 End If;
7798
7799 -- Begin bug 3766110
7800
7801 -- If l_Message_Table.Count > 0 Then
7802
7803 -- G_Stage := 'Convert Message pl/sql table to varchar2.';
7804 -- P_Messages := Hxc_Integration_Layer_V1_Grp.Messages_to_String ( P_Messages => l_Message_Table );
7805
7806 -- End If;
7807
7808 -- End Bug 3766110
7809
7810 G_Stage := 'Leaving procedure GetPRMAssignTemplates().';
7811 Pa_Otc_Api.TrackPath('STRIP','GetPRMAssignTemplates');
7812
7813 Exception
7814 When Others then
7815 Raise_Application_Error(-20007,'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage || ' : ' || SQLERRM);
7816
7817 End GetPRMAssignTemplates;
7818
7819 -- ========================================================================
7820 -- Start Of Comments
7821 -- API Name : FindandValidateHeader
7822 -- Type : Private
7823 -- Pre-Reqs : None
7824 -- Type : Procedure
7825 -- Return : n/a
7826 -- Function : This procedure finds and validate the Timecard Header record.
7827 -- This procedure is only called when Mode is VALIDATE.
7828 --
7829 -- Parameters :
7830 -- IN
7831 -- P_Building_Blocks_Table - Hxc_User_Type_Definition_Grp.Timecard_Info
7832 -- P_Attribute_Table - Hxc_User_Type_Definition_Grp.App_Attributes_Info
7833 -- P_Message_Table - Hxc_User_Type_Definition_Grp.Message_Table
7834 -- OUT
7835 -- P_Message_Table - Hxc_User_Type_Definition_Grp.Message_Table
7836 -- X_TimeBB_Id - Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE
7837 -- X_Ovr_Approver_Person_Id - Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE
7838 -- X_Timecard_Ending_Date - Date
7839
7840 /*--------------------------------------------------------------------------*/
7841
7842
7843 Procedure FindandValidateHeader(
7844 P_Building_Blocks_Table IN Hxc_User_Type_Definition_Grp.Timecard_Info,
7845 P_Attribute_Table IN Hxc_User_Type_Definition_Grp.App_Attributes_Info,
7846 P_Message_Table IN OUT NOCOPY Hxc_User_Type_Definition_Grp.Message_Table, -- 2672653
7847 X_TimeBB_Id OUT NOCOPY Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE,
7848 X_Ovr_Approver_Person_Id OUT NOCOPY Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE,
7849 X_Pass_Val_Flag OUT NOCOPY Varchar2,
7850 X_Approval_Status OUT NOCOPY Hxc_Time_Building_Blocks.Approval_Status%TYPE)
7851
7852 Is
7853
7854 l_Error_Code Varchar2(30) := Null;
7855 l_Error_Type Varchar2(30) := Null;
7856
7857 l_Pass_Val_Flag Varchar2(1) := 'Y';
7858 l_TimeBB_Ovn Number := Null;
7859 i Binary_Integer := Null;
7860 x Binary_Integer := Null;
7861 l_Found Boolean := Null;
7862 l_pref_table hxc_preference_evaluation.t_pref_table;
7863 l_period_type varchar2(50);/* bug 5890771 */
7864 l_termination_date Date := Null; /* Added the variable for bug 7584432 */
7865
7866 cursor check_tc_period (p_rec_id number) is
7867 select hrp.period_type
7868 from hxc_recurring_periods hrp
7869 where hrp.recurring_period_id = p_rec_id;
7870 /* Added the cursor for bug 7584432 */
7871 Cursor get_termination_date(p_person_id number, p_stop_date DATE) is
7872 Select max(effective_end_date) from per_people_f
7873 where person_id = p_person_id and
7874 effective_end_date <= p_stop_date and
7875 (current_employee_flag = 'Y' or current_npw_flag = 'Y');
7876
7877
7878 Begin
7879
7880 G_Stage := 'Entering FindandValidateHeader procedure.';
7881 Pa_Otc_Api.TrackPath('ADD','FindandValidateHeader');
7882
7883 Loop
7884
7885 If i is Null Then
7886
7887 i := P_Building_Blocks_Table.First;
7888
7889 Else
7890
7891 i := P_Building_Blocks_Table.Next(i);
7892
7893 End If;
7894
7895 G_Stage := 'Get the Time Scope Building Block Id.';
7896 If P_Building_Blocks_Table(i).Scope = 'TIMECARD' Then
7897 /* bug 5890771*/
7898 hxc_preference_evaluation.resource_preferences(
7899 p_resource_id => P_Building_Blocks_Table(i).resource_id
7900 , p_pref_code_list=> 'TC_W_TCRD_PERIOD'
7901 , p_pref_table => l_pref_table );
7902
7903 open check_tc_period(l_pref_table(l_pref_table.first).attribute1);
7904 fetch check_tc_period into l_period_type;
7905 close check_tc_period;
7906 X_TimeBB_Id := P_Building_Blocks_Table(i).Time_Building_Block_Id;
7907 l_TimeBB_Ovn := P_Building_Blocks_Table(i).Object_Version_Number;
7908 X_Approval_Status := P_Building_Blocks_Table(i).Approval_Status;
7909
7910 /* bug 5890771 If Trunc(P_Building_Blocks_Table(i).Stop_Time) - Trunc(P_Building_Blocks_Table(i).Start_Time) = 6 Then*/
7911 if l_period_type = 'Week' then
7912
7913 -- The default timecard period in OTL is a week.
7914
7915 If Pa_Utils.NewGetWeekEnding(Trunc(P_Building_Blocks_Table(i).Stop_Time)) <>
7916 Trunc(P_Building_Blocks_Table(i).Stop_Time) Then
7917
7918 -- The the week ending dates don't match. This is not allowed.
7919 /* change for bug 7584432 start here */
7920
7921 open get_termination_date(P_Building_Blocks_Table(i).resource_id,P_Building_Blocks_Table(i).Stop_Time);
7922 fetch get_termination_date into l_termination_date;
7923 close get_termination_date;
7924
7925 if Trunc(nvl(l_termination_date,P_Building_Blocks_Table(i).Stop_Time + 1)) <> Trunc(P_Building_Blocks_Table(i).Stop_Time) Then
7926
7927 /* change for bug 7584432 end here */
7928
7929 X_Pass_Val_Flag := 'N';
7930 G_Msg_Tokens_Table.Delete;
7931
7932 -- Add record to error table.
7933 Pa_Otc_Api.Add_Error_To_Table(
7934 P_Message_Table => P_Message_Table,
7935 P_Message_Name => 'PA_INVALID_WEEK_ENDING_DATE',
7936 P_Message_Level => 'ERROR',
7937 P_Message_Field => Null,
7938 P_Msg_Tokens => G_Msg_Tokens_Table,
7939 P_Time_Building_Block_Id => X_TimeBB_Id,
7940 P_Time_Attribute_Id => Null);
7941
7942 End if; /*Added bug 7584432 */
7943 End If;
7944
7945 End If;
7946
7947 -- R12 change
7948 -- This section of code is conditionally getting the override approver person id if the
7949 -- overriding approver flag is set to Yes and AutoApproval is set to No. This is not
7950 -- correct. We need only be concerned about the autoapproval flag.
7951 -- If Nvl(Fnd_Profile.Value('PA_ONLINE_OVERRIDE_APPROVER'),'N') = 'Y' Then
7952 If Nvl(Fnd_Profile.Value('PA_PTE_AUTOAPPROVE_TS'),'N') = 'N' Then
7953
7954 /* This variable is being used in the summary validate and
7955 * business message section of the procedure.
7956 */
7957
7958 l_Found := False;
7959
7960 G_Stage := 'Time block found. Need to pull out Overriding Approver if exists.';
7961 Loop
7962
7963 If x is null Then
7964
7965 G_Stage := 'Get first record in attribution table.';
7966 x := P_Attribute_Table.First;
7967
7968 Else
7969
7970 G_Stage := 'Get next record in attribution table.';
7971 x := P_Attribute_Table.Next(x);
7972
7973 End If;
7974
7975 G_Stage := 'Check if found the correct record in attribution table.';
7976 If X_TimeBB_Id = P_Attribute_Table(x).Building_Block_Id And
7977 Upper(P_Attribute_Table(x).Attribute_Name) = 'OVERRIDING_APPROVER_PERSON_ID' And
7978 P_Attribute_Table(x).Bld_Blk_Info_Type = 'APPROVAL' Then
7979
7980 l_Found := True;
7981
7982 /* If there is attribute name 'OVERRIDING_APPROVER_PERSON_ID' is found then
7983 * the user populate the field during entry else the user left it alone even
7984 * though the user could have assigned an overriding approver.
7985 */
7986
7987 G_Stage := 'Call Validate_Overriding_Approver procedure.';
7988 Pa_Otc_Api.Validate_Overriding_Approver(
7989 P_Approver_Id => to_number(P_Attribute_Table(x).Attribute_Value),
7990 X_Approver_Id => X_Ovr_Approver_Person_Id,
7991 X_Error_Code => l_Error_Code,
7992 X_Error_Type => l_Error_Type);
7993
7994 If l_Error_Code Is Not Null Then
7995
7996 G_Stage := 'Validate Overriding Approver - Inserting error rec.';
7997 G_Msg_Tokens_Table.Delete;
7998
7999 -- Add record to error table.
8000 Pa_Otc_Api.Add_Error_To_Table(
8001 P_Message_Table => P_Message_Table,
8002 P_Message_Name => l_Error_Code,
8003 P_Message_Level => 'ERROR',
8004 P_Message_Field => 'OVERRIDING_APPROVER_PERSON_ID',
8005 P_Msg_Tokens => G_Msg_Tokens_Table,
8006 P_Time_Building_Block_Id => X_TimeBB_Id,
8007 P_Time_Attribute_Id => P_Attribute_Table(x).Time_Attribute_Id);
8008
8009 End If; -- l_Error_Code Is Not Null
8010
8011 G_Stage := 'Since found the Overriding Approver rec and validated then exit out of loop.';
8012 Exit;
8013
8014 End If; -- Same building block id and attribute_name and BB info type.
8015
8016 G_Stage := 'In case of incorrect implementation of overriding approver check if last record.';
8017 Exit When x = P_Attribute_Table.LAST;
8018
8019 End Loop; -- Loop for Overriding Approver Person Id at Time Scope.
8020
8021 /* R12 changes.
8022 * We no longer require the overriding approver to be populated.
8023 * But will pull it if it is there.
8024 G_Stage := 'Check if found the overriding approver person_id record in attribute table.';
8025 If Not l_Found Then
8026
8027 G_Stage := 'No attribute record was found for overriding approver when there should have been.';
8028 G_Msg_Tokens_Table.Delete;
8029
8030 -- Add record to error table.
8031 Pa_Otc_Api.Add_Error_To_Table(
8032 P_Message_Table => P_Message_Table,
8033 P_Message_Name => 'PA_OVRRDE_APPROVER_NOT_VALID',
8034 P_Message_Level => 'ERROR',
8035 P_Message_Field => 'OVERRIDING_APPROVER_PERSON_ID',
8036 P_Msg_Tokens => G_Msg_Tokens_Table,
8037 P_Time_Building_Block_Id => X_TimeBB_Id,
8038 P_Time_Attribute_Id => Null);
8039
8040 X_Pass_Val_Flag := 'N';
8041
8042 End If;
8043 */
8044
8045 End If; -- Check if Override approver needs to be pulled if exists
8046
8047 G_Stage := 'Exit the loop since found the header record and validated it.';
8048 Exit;
8049
8050 End If; -- Scope is TIMECARD
8051
8052 End Loop; -- Processing Building Blocks to find Header info and validate.';
8053
8054 G_Stage := 'Check if header pass validation and set flag.';
8055 If X_Pass_Val_Flag is null Then
8056
8057 X_Pass_Val_Flag := 'Y';
8058
8059 End If;
8060
8061 G_Stage := 'Leaving FindandValidateHeader() procedure.';
8062 Pa_Otc_Api.TrackPath('STRIP','FindandValidateHeader');
8063
8064 Exception
8065 When Others Then
8066 Raise;
8067
8068 End FindandValidateHeader;
8069
8070 -- =======================================================================
8071 -- Start of Comments
8072 -- API Name : Wf_AutoApproval_BusMsg
8073 -- Type : Public
8074 -- Pre-Reqs : None
8075 -- Type : Procedure
8076 -- Function : This procedure is called by the OTL client team.
8077 -- Calls the PA_CLIENT_EXTN_PTE.Get_Exp_AutoApproval() and
8078 -- the PA_TIME_CLIENT_EXTN.Display_Business_Message().
8079 --
8080 -- Parameters :
8081 -- OUT
8082 -- X_AutoApproval_Flag - Varchar2
8083 -- X_Messages - Varchar2
8084
8085 /*------------------------------------------------------------------------- */
8086
8087 Procedure Wf_AutoApproval_BusMsg
8088 (X_AutoApproval_Flag OUT NOCOPY Varchar2
8089 ,X_Messages OUT NOCOPY Varchar2)
8090
8091 Is
8092
8093 l_Timecard_Table Pa_Otc_Api.Timecard_Table;
8094 l_Inc_By_Person_Id Pa_Expenditures_All.Incurred_By_Person_Id%TYPE;
8095 l_Overriding_Approver_Id Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE;
8096
8097 /* Stores a single record from the Building Block Table */
8098 l_Building_Block_Record Hxc_User_Type_Definition_Grp.Building_Block_Info;
8099
8100 l_Message_Name Varchar2(30);
8101 l_Message_Table Hxc_User_Type_Definition_Grp.Message_Table;
8102
8103 l_Status Number(10);
8104 l_Appl_Id Varchar2(10);
8105 l_Msg_Name Varchar2(30);
8106 l_Msg_Application Varchar2(10);
8107 l_Msg_Token1_Name Varchar2(30);
8108 l_Msg_Token1_Value Varchar2(255);
8109 l_Msg_Token2_Name Varchar2(30);
8110 l_Msg_Token2_Value Varchar2(255);
8111 l_Msg_Token3_Name Varchar2(30);
8112 l_Msg_Token3_Value Varchar2(255);
8113
8114 Begin
8115
8116 G_Path := ' ';
8117
8118 G_Stage := 'Entering Wf_AutoApproval_BusMsg() procedure.';
8119 Pa_Otc_Api.TrackPath('ADD','Wf_AutoApproval_BusMsg');
8120
8121 G_Stage := 'Initialize the hxc pl/sql tables that will be used.';
8122 l_Timecard_Table.delete;
8123 l_Message_Table.delete;
8124
8125 G_Stage := 'Calling Pa_Otc_Api.CreateProjTimecardTable()';
8126 Pa_Otc_Api.CreateProjTimecardTable(
8127 X_Inc_By_Person_Id => l_Inc_By_Person_Id,
8128 X_Timecard_Table => l_Timecard_Table,
8129 X_Overriding_Approver_Id => l_Overriding_Approver_Id );
8130
8131 G_Stage := 'Calling Pa_Client_Extn_Pte.Get_Exp_AutoApproval()';
8132 Pa_Client_Extn_Pte.Get_Exp_AutoApproval (
8133 X_Source => 'PA',
8134 X_Exp_Class_Code => 'PT',
8135 X_Txn_Id => Null,
8136 X_Exp_Ending_Date => Null,
8137 X_Person_Id => l_Inc_By_Person_Id,
8138 P_Timecard_Table => l_Timecard_Table,
8139 P_Module => 'OTL',
8140 X_Approved => X_AutoApproval_Flag );
8141
8142 If X_AutoApproval_Flag NOT IN ('N','Y') Then
8143
8144 G_Stage := 'AutoApproval Extension does not return valid value. Create error message.';
8145 l_Message_Name := 'PA_TR_INVALID_AUTOAPPROVAL_FLG';
8146 X_AutoApproval_Flag := Null;
8147
8148 G_Msg_Tokens_Table.Delete;
8149
8150 Pa_Otc_Api.Add_Error_To_Table(
8151 P_Message_Table => l_Message_Table,
8152 P_Message_Name => l_Message_Name,
8153 P_Message_Level => 'ERROR',
8154 P_Message_Field => Null,
8155 P_Msg_Tokens => G_Msg_Tokens_Table,
8156 P_Time_Building_Block_Id => Null,
8157 P_Time_Attribute_Id => Null);
8158
8159 End If;
8160
8161 /* If the AutoApproval flag is Yes then there is no reason to get the business message for this
8162 * timecard.
8163 */
8164 If X_AutoApproval_Flag = 'N' and Nvl(Fnd_Profile.Value('PA_SST_ENABLE_BUS_MSG'),'N') = 'Y' Then
8165
8166 G_Stage := 'Calling Pa_Time_Client_Extn.Display_Business_Message()';
8167 Pa_Time_Client_Extn.Display_Business_Message(
8168 P_Timecard_Table => l_Timecard_Table,
8169 P_Module => 'OTL',
8170 P_Person_id => l_Inc_By_Person_Id,
8171 P_Week_Ending_Date => Null,
8172 X_Msg_Application_Name => l_Msg_Application,
8173 X_Message_Data => l_Msg_Name,
8174 X_Msg_Token1_Name => l_Msg_Token1_Name,
8175 X_Msg_Token1_Value => l_Msg_Token1_Value ,
8176 X_Msg_Token2_Name => l_Msg_Token2_Name,
8177 X_Msg_Token2_Value => l_Msg_token2_Value,
8178 X_Msg_Token3_Name => l_Msg_Token3_Name,
8179 X_Msg_Token3_Value => l_Msg_Token3_Value);
8180
8181 If l_Msg_Name is Not Null Then
8182
8183 G_Stage := 'Message was returned from Display_Business_Message Extension. Create message.';
8184 G_Msg_Tokens_Table.Delete;
8185
8186 If l_Msg_Token1_Name Is Not Null Then
8187
8188 G_Msg_Tokens_Table(1).Token_Name := l_Msg_Token1_Name;
8189 G_Msg_Tokens_Table(1).Token_Value := l_Msg_Token1_Value;
8190
8191 End If;
8192
8193 If l_Msg_Token2_Name Is Not Null Then
8194
8195 G_Msg_Tokens_Table(2).Token_Name := l_Msg_Token2_Name;
8196 G_Msg_Tokens_Table(2).Token_Value := l_Msg_Token2_Value;
8197
8198 End If;
8199
8200 If l_Msg_Token3_Name Is Not Null Then
8201
8202 G_Msg_Tokens_Table(3).Token_Name := l_Msg_Token3_Name;
8203 G_Msg_Tokens_Table(3).Token_Value := l_Msg_Token3_Value;
8204
8205 End If;
8206
8207 If l_Msg_Application Is Null Then
8208
8209 l_Msg_Application := 'PA';
8210
8211 End If;
8212
8213 Pa_Otc_Api.Add_Error_To_Table(
8214 P_Message_Table => l_Message_Table,
8215 P_Message_Name => l_Msg_Name,
8216 P_Message_Level => 'BUSINESS',
8217 P_Message_Field => Null,
8218 P_Msg_Tokens => G_Msg_Tokens_Table,
8219 P_Time_Building_Block_Id => Null,
8220 P_Time_Attribute_Id => Null,
8221 P_Message_App => l_Msg_Application);
8222
8223 End If; -- l_Msg_Name Is Not Null
8224
8225 End If; -- Profile 'PA_SST_ENABLE_BUS_MSG' = 'Y'
8226
8227 If l_Message_Table.Count > 0 Then
8228
8229 G_Stage := 'Calling Hxc_Deposit_Wrapper_Utilities.Messages_To_String().';
8230 X_Messages := Hxc_Integration_Layer_V1_Grp.Messages_To_String(P_Messages => l_Message_Table);
8231 End If;
8232
8233 G_Stage := 'Leaving Wf_AutoApproval_BusMsg() procedure.';
8234 Pa_Otc_Api.TrackPath('STRIP','Wf_AutoApproval_BusMsg');
8235
8236 Exception
8237 When Others Then
8238 Raise_Application_Error(-20500, 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_stage || ' : ' || SQLERRM );
8239
8240 End Wf_AutoApproval_BusMsg;
8241
8242 -- =======================================================================
8243 -- Start of Comments
8244 -- API Name : Wf_RouteTo_CheckApproval
8245 -- Type : Public
8246 -- Pre-Reqs : None
8247 -- Type : Procedure
8248 -- Function : This procedure is called by the OTL client team.
8249 -- The only intent of the procedure is manipulate
8250 -- the parameters passed in and then call
8251 -- the PaRoutingX.Route_To_Extension().
8252 --
8253 -- Parameters :
8254 -- IN
8255 -- P_Previous_Approver_Id - Number
8256 -- OUT
8257 -- X_Approver_Person_Id - Number
8258 -- X_Messages - Varchar2
8259
8260 /*------------------------------------------------------------------------- */
8261
8262 Procedure Wf_RouteTo_CheckApproval(
8263 P_Previous_Approver_Id IN Number,
8264 X_Approver_Person_Id OUT NOCOPY Number,
8265 X_Messages OUT NOCOPY Varchar2)
8266
8267 Is
8268
8269 l_Timecard_Table Pa_Otc_Api.Timecard_Table;
8270 l_Inc_By_Person_Id Pa_Expenditures_All.Incurred_By_Person_Id%TYPE;
8271 l_Overriding_Approver_Id Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE := Null;
8272
8273 l_Message_Table Hxc_User_Type_Definition_Grp.Message_Table;
8274 l_Message_Name Varchar2(30);
8275
8276 l_Status Number(10);
8277 l_Msg_App Varchar2(10);
8278 l_Msg_Code Varchar2(30);
8279 l_Token_1 Varchar2(255);
8280 l_Token_2 Varchar2(255);
8281 l_Token_3 Varchar2(255);
8282 l_Token_4 Varchar2(255);
8283 l_Token_5 Varchar2(255);
8284
8285 l_Approval_Flag Varchar2(30) := 'COMPLETE:FAIL'; -- Do not change!
8286
8287 Unexpected_Error Exception;
8288
8289 Begin
8290
8291 G_Path := ' ';
8292
8293 G_Stage := 'Entering Wf_RouteTo_CheckApproval() procedure.';
8294 Pa_Otc_Api.TrackPath('ADD','Wf_RouteTo_CheckApproval');
8295
8296 G_Stage := 'Initialize the PA pl/sql tables that will be used.';
8297 l_Timecard_Table.Delete;
8298
8299 G_Stage := 'Calling Pa_Otc_Api.CreateProjTimecardTable()';
8300 Pa_Otc_Api.CreateProjTimecardTable(
8301 X_Inc_By_Person_Id => l_Inc_By_Person_Id,
8302 X_Timecard_Table => l_Timecard_Table,
8303 X_Overriding_Approver_Id => l_Overriding_Approver_Id);
8304
8305 If P_Previous_Approver_Id is Not Null Then
8306
8307 G_Stage := 'Previous_Approver is not null call Pa_Client_Extn_Rte.Check_Approval().';
8308
8309 Pa_Client_Extn_Rte.Check_Approval(
8310 X_Expenditure_Id => Null,
8311 X_Incurred_By_Person_Id => l_Inc_By_Person_Id,
8312 X_Expenditure_End_Date => Null,
8313 X_Exp_Class_Code => 'PT',
8314 X_Amount => Null,
8315 X_Approver_Id => P_Previous_Approver_Id,
8316 X_Routed_To_Mode => 'SUPERVISOR',
8317 P_Timecard_Table => l_Timecard_Table,
8318 P_Module => 'OTL',
8319 X_Status => l_Status,
8320 X_Application_Id => l_Msg_App,
8321 X_Message_Code => l_Msg_Code,
8322 X_Token_1 => l_Token_1, -- Token Name --> 'TOKEN_1'
8323 X_Token_2 => l_Token_2, -- Token Name --> 'TOKEN_2'
8324 X_Token_3 => l_Token_3, -- Token Name --> 'TOKEN_3'
8325 X_Token_4 => l_Token_4, -- Token Name --> 'TOKEN_4'
8326 X_Token_5 => l_Token_5 ); -- Token Name --> 'TOKEN_5'
8327
8328 If l_Status = 0 Then
8329
8330 G_Stage := 'Previous Approver had final authority to approve the timecard.';
8331 l_Approval_Flag := 'COMPLETE:PASS';
8332
8333 ElsIf l_Status < 0 Then
8334
8335 G_Stage := 'Unexpected error occurred in the called routine Pa_Client_Extn_Rte.Check_Approval().';
8336 Raise Unexpected_Error;
8337
8338 Else -- l_Status > 0
8339
8340 G_Stage := 'The previous approver did not have the final authority to approve the timecard.';
8341 l_Approval_Flag := 'COMPLETE:FAIL';
8342
8343 G_Msg_Tokens_Table.Delete;
8344
8345 If l_Msg_Code Is Not Null Then
8346
8347 G_Stage := 'A message has been passed back from Pa_Client_Extn_Rte.Check_Approval(). ' ||
8348 'Create a message.';
8349 If l_Token_1 Is Not Null Then
8350
8351 G_Msg_Tokens_Table(1).Token_Name := 'TOKEN_1';
8352 G_Msg_Tokens_Table(1).Token_Value := l_Token_1;
8353
8354 End If;
8355
8356 If l_Token_2 Is Not Null Then
8357
8358 G_Msg_Tokens_Table(2).Token_Name := 'TOKEN_2';
8359 G_Msg_Tokens_Table(2).Token_Value := l_Token_2;
8360
8361 End If;
8362
8363 If l_Token_3 Is Not Null Then
8364
8365 G_Msg_Tokens_Table(3).Token_Name := 'TOKEN_3';
8366 G_Msg_Tokens_Table(3).Token_Value := l_Token_3;
8367
8368 End If;
8369
8370 If l_Token_4 Is Not Null Then
8371
8372 G_Msg_Tokens_Table(4).Token_Name := 'TOKEN_4';
8373 G_Msg_Tokens_Table(4).Token_Value := l_Token_4;
8374
8375 End If;
8376
8377 If l_Token_5 Is Not Null Then
8378
8379 G_Msg_Tokens_Table(5).Token_Name := 'TOKEN_5';
8380 G_Msg_Tokens_Table(5).Token_Value := l_Token_5;
8381
8382 End If;
8383
8384
8385 If l_Msg_App Is Null Then
8386
8387 l_Msg_App := 'PA';
8388
8389 End If;
8390
8391 Pa_Otc_Api.Add_Error_To_Table (
8392 P_Message_Table => l_Message_Table,
8393 P_Message_Name => l_Msg_Code,
8394 P_Message_Level => 'ERROR',
8395 P_Message_Field => Null,
8396 P_Msg_Tokens => G_Msg_Tokens_Table,
8397 P_Time_Building_Block_Id => Null,
8398 P_Time_Attribute_Id => Null,
8399 P_Message_App => l_Msg_App);
8400
8401 End If; -- Message Code Is Not Null
8402
8403 End If; -- l_Status
8404
8405 End If; -- P_Previous_Approver_Id Is Not Null
8406
8407 /* If the previous approver does not have the authority to make the final decision then
8408 * the approval flag will be 'COMPLETE:FAIL'. If the previous approver did have the
8409 * authority to have final approval for the timecard being process then the approval
8410 * flag will be 'COMPLETE:PASS' in which case the route_to_extension does not need
8411 * to be called.
8412 */
8413
8414 -- Approver authority flag check
8415 If l_Approval_Flag = 'COMPLETE:FAIL' Then
8416
8417 G_Stage := 'Checking who the next approver should be.';
8418 /* Want to check and see if there is an overriding approver to send the timecard to for approval.
8419 * For this to be correct need to make sure that this part is only called when the timecard is submitted.
8420 * That is why we check if the previous approver is null. It has to be null upon submission.
8421 */
8422 -- Bug 2773066
8423 -- We don't need to check if the profile is set at this point.
8424 -- If the overriding approver is populated then use it when appropriate.
8425 -- If Nvl(Fnd_Profile.Value('PA_ONLINE_OVERRIDE_APPROVER'),'N') = 'Y' And
8426 If l_Overriding_Approver_Id Is Not Null And
8427 P_Previous_Approver_Id Is Null Then
8428
8429 X_Approver_Person_Id := l_Overriding_Approver_Id;
8430
8431 Else
8432
8433 G_Stage := 'The previous approver did not have the final authority to approve the timecard. ' ||
8434 'Call PaRoutingX.Route_To_Extension() to get the next approver in line.';
8435
8436 PaRoutingX.Route_To_Extension(
8437 X_Expenditure_Id => Null,
8438 X_Incurred_By_Person_Id => l_Inc_By_Person_Id,
8439 X_Expenditure_End_Date => Null,
8440 X_Exp_Class_Code => 'PT',
8441 X_Previous_Approver_Person_Id => P_Previous_Approver_Id,
8442 P_Timecard_Table => l_Timecard_Table,
8443 P_Module => 'OTL',
8444 X_Route_To_Person_Id => X_Approver_Person_Id );
8445
8446 If P_Previous_Approver_Id Is Null And X_Approver_Person_Id Is Null Then
8447
8448 G_Stage := 'There is no previous approver and no one to route the timecard to. ' ||
8449 'Create error message.';
8450 l_Message_Name := 'PA_TR_NO_ROUTE_TO_PERSON';
8451
8452 G_Msg_Tokens_Table.Delete;
8453
8454 Pa_Otc_Api.Add_Error_To_Table(
8455 P_Message_Table => l_Message_Table,
8456 P_Message_Name => l_Message_Name,
8457 P_Message_Level => 'ERROR',
8458 P_Message_Field => Null,
8459 P_Msg_Tokens => G_Msg_Tokens_Table,
8460 P_Time_Building_Block_Id => Null,
8461 P_Time_Attribute_Id => Null);
8462
8463 ElsIf P_Previous_Approver_Id Is Not Null And X_Approver_Person_Id Is Null Then
8464
8465 G_Stage := 'There is no one to route the timecard to. ' ||
8466 'Create an error message.';
8467 l_Message_Name := 'PA_NO_APPROVER_FOUND';
8468 G_Msg_Tokens_Table.Delete;
8469
8470 Pa_Otc_Api.Add_Error_To_Table(
8471 P_Message_Table => l_Message_Table,
8472 P_Message_Name => l_Message_Name,
8473 P_Message_Level => 'ERROR',
8474 P_Message_Field => Null,
8475 P_Msg_Tokens => G_Msg_Tokens_Table,
8476 P_Time_Building_Block_Id => Null,
8477 P_Time_Attribute_Id => Null);
8478
8479 End If; -- l_Msg_Name Is Not Null
8480
8481 End If; -- checking of overriding approver
8482
8483 ElsIf l_Approval_Flag = 'COMPLETE:PASS' Then
8484
8485 G_Stage := 'The timecard has final approval. Set approver person id to -99.';
8486
8487 /* If the previous approver had the final authority to approver the timecard, then
8488 * pass back -99 for the next approver to route to so that OTL knows that no further
8489 * approvers are needed.
8490 */
8491 X_Approver_Person_Id := -99;
8492
8493 End If; -- Approver authority flag check
8494
8495 If l_Message_Table.Count > 0 Then
8496
8497 G_Stage := 'Messages have been created convert to varchar by calling ' ||
8498 'Hxc_Integration_Layer_V1_Grp.Messages_To_String().';
8499 X_Messages := Hxc_Integration_Layer_V1_Grp.Messages_To_String(P_Messages => l_Message_Table);
8500 End If;
8501
8502 G_Stage := 'Leaving Wf_RouteTo_CheckApproval() procedure.';
8503 Pa_Otc_Api.TrackPath('STRIP','Wf_RouteTo_CheckApproval');
8504
8505 Exception
8506 When Others Then
8507 Raise_Application_Error(-20600, 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_stage || ' : ' || SQLERRM );
8508
8509 End Wf_RouteTo_CheckApproval;
8510
8511 -- =======================================================================
8512 -- Start of Comments
8513 -- API Name : CreateProjTimecardTable
8514 -- Type : Private
8515 -- Pre-Reqs : None
8516 -- Type : Procedure
8517 -- Function : This procedure create pl/sql table of OTL data in
8518 -- project friendly format.
8519 --
8520 -- Parameters :
8521 -- OUT
8522 -- X_Inc_By_Person_Id - Pa_Expenditures_All.Incurred_By_Person_Id%TYPE
8523 -- X_Timecard_Table - Pa_Otc_Api.Timecard_Table
8524 -- X_Overriding_Approver_Id - Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE
8525
8526 /*------------------------------------------------------------------------- */
8527
8528 Procedure CreateProjTimecardTable(
8529 X_Inc_By_Person_Id OUT NOCOPY Pa_Expenditures_All.Incurred_By_Person_Id%TYPE,
8530 X_Timecard_Table OUT NOCOPY Pa_Otc_Api.Timecard_Table, --2672653
8531 X_Overriding_Approver_Id OUT NOCOPY Pa_Expenditures_All.Overriding_Approver_Person_Id%TYPE)
8532
8533 Is
8534
8535 l_Proj_Attrib_Rec Pa_Otc_Api.Project_Attribution_Rec;
8536 j Binary_Integer := 0;
8537
8538 l_Time_Building_Blocks Hxc_User_Type_Definition_Grp.Timecard_Info;
8539 l_Time_Attributes Hxc_User_Type_Definition_Grp.App_Attributes_Info;
8540 l_Detail_Attr_Changed Varchar2(1) := 'N';
8541
8542 /* Stores a single record from the Building Block Table */
8543 l_Building_Block_Record Hxc_User_Type_Definition_Grp.Building_Block_Info;
8544
8545 Begin
8546
8547 G_Stage := 'Entering CreateProjTimecardTable() procedure.';
8548 Pa_Otc_Api.TrackPath('ADD','CreateProjTimecardTable');
8549
8550 G_Stage := 'Initialize PA structure pl/sql table.';
8551
8552 X_Timecard_Table.delete;
8553
8554 G_Stage := 'Get the hxc pl/sql building block and attribution tables.';
8555 l_Time_Building_Blocks := Hxc_Integration_Layer_V1_Grp.Get_Wf_G_Time_Building_Blocks;
8556 l_Time_Attributes := Hxc_Integration_Layer_V1_Grp.Get_Wf_G_Time_App_Attributes;
8557
8558 G_Stage := 'Begin looping thru hxc pl/sql building block table.';
8559 For i in l_Time_Building_Blocks.FIRST .. l_Time_Building_Blocks.LAST
8560 Loop
8561
8562 G_Stage := 'Check if overriding approver exists when the scope is TIMECARD.';
8563 -- Bug 2773066
8564 -- We don't need to check the overriding approver profile.
8565 -- If it is populated then it should be picked up and used when and if needed.
8566 -- If Nvl(Fnd_Profile.Value('PA_ONLINE_OVERRIDE_APPROVER'),'N') = 'Y' And
8567 If l_Time_Building_Blocks(i).Scope = 'TIMECARD' Then
8568
8569 G_Stage := 'Now loop thru and attribution records for the TIMECARD scope building block.';
8570 <<Approval_Attribs_Loop>>
8571 For q in l_Time_Attributes.FIRST .. l_Time_Attributes.LAST
8572 Loop
8573
8574 G_Stage := 'Check for overriding approver attribution record exists.';
8575 If l_Time_Building_Blocks(i).Time_Building_Block_Id =
8576 l_Time_Attributes(q).Building_Block_Id And
8577 Upper(l_Time_Attributes(q).Attribute_Name) = 'OVERRIDING_APPROVER_PERSON_ID' And
8578 l_Time_Attributes(q).Bld_Blk_Info_Type = 'APPROVAL' Then
8579
8580 G_Stage := 'Assign overriding approver to out paramanter';
8581 X_Overriding_Approver_Id := l_Time_Attributes(q).Attribute_Value;
8582
8583 G_Stage := 'Exit Approval_Attribs_Loop.';
8584 Exit Approval_Attribs_Loop;
8585
8586 End If;
8587
8588 End Loop Approval_Attribs_Loop;
8589
8590 End If;
8591
8592 G_Stage := 'Check if building block scope is DETAIL.';
8593 If l_Time_Building_Blocks(i).Scope = 'DETAIL' Then
8594
8595 G_Stage := 'Initialize variables for loop.';
8596 l_Building_Block_Record := l_Time_Building_Blocks(i);
8597 l_Detail_Attr_Changed := 'N';
8598
8599 G_Stage := 'Pull out the data to PA friendly format by calling RetrieveProjAttribution().';
8600 Pa_Otc_Api.RetrieveProjAttribution(
8601 P_Building_Block_Rec => l_Building_Block_Record,
8602 P_Building_Block => l_Time_Building_Blocks,
8603 P_Attribute_Table => l_Time_Attributes,
8604 X_Detail_Attr_Changed => l_Detail_Attr_Changed,
8605 X_Proj_Attrib_Rec => l_Proj_Attrib_Rec);
8606
8607 j := j + 1;
8608
8609 G_Stage := 'Push the PA friendly format pl/sql record into pl/sql table.';
8610 X_Timecard_Table(j).Project_Number := l_Proj_Attrib_Rec.Project_Number;
8611 X_Timecard_Table(j).Project_Id := l_Proj_Attrib_Rec.Project_id;
8612 X_Timecard_Table(j).Task_Number := l_Proj_Attrib_Rec.Task_Number;
8613 X_Timecard_Table(j).Task_Id := l_Proj_Attrib_Rec.Task_Id;
8614 X_Timecard_Table(j).Expenditure_Type := l_Proj_Attrib_Rec.Expenditure_Type;
8615 X_Timecard_Table(j).System_Linkage_Function := l_Proj_Attrib_Rec.Sys_Linkage_Func;
8616 X_Timecard_Table(j).Quantity := l_Proj_Attrib_Rec.Quantity;
8617 X_Timecard_Table(j).Incurred_By_Person_Id := l_Proj_Attrib_Rec.Inc_By_Person_Id;
8618 X_Timecard_Table(j).Override_Approver_Person_Id := Null;
8619 X_Timecard_Table(j).Expenditure_Item_Date := l_Proj_Attrib_Rec.Expenditure_Item_Date;
8620 X_Timecard_Table(j).Expenditure_Ending_Date := l_Proj_Attrib_Rec.Exp_Ending_Date;
8621 X_Timecard_Table(j).Attribute_Category := l_Proj_Attrib_Rec.Attrib_Category;
8622 X_Timecard_Table(j).Attribute1 := l_Proj_Attrib_Rec.Attribute1;
8623 X_Timecard_Table(j).Attribute2 := l_Proj_Attrib_Rec.Attribute2;
8624 X_Timecard_Table(j).Attribute3 := l_Proj_Attrib_Rec.Attribute3;
8625 X_Timecard_Table(j).Attribute4 := l_Proj_Attrib_Rec.Attribute4;
8626 X_Timecard_Table(j).Attribute5 := l_Proj_Attrib_Rec.Attribute5;
8627 X_Timecard_Table(j).Attribute6 := l_Proj_Attrib_Rec.Attribute6;
8628 X_Timecard_Table(j).Attribute7 := l_Proj_Attrib_Rec.Attribute7;
8629 X_Timecard_Table(j).Attribute8 := l_Proj_Attrib_Rec.Attribute8;
8630 X_Timecard_Table(j).Attribute9 := l_Proj_Attrib_Rec.Attribute9;
8631 X_Timecard_Table(j).Attribute10 := l_Proj_Attrib_Rec.Attribute10;
8632 X_Timecard_Table(j).Billable_Flag := l_Proj_Attrib_Rec.Billable_Flag;
8633 X_Timecard_Table(j).Expenditure_Item_Comment := l_Proj_Attrib_Rec.Expenditure_Item_Comment;
8634 X_Timecard_Table(j).Orig_Exp_Txn_Reference1 := Null;
8635
8636 End If;
8637
8638 G_Stage := 'Grab the Inc By Person Id to return as our parameter.';
8639 X_Inc_By_Person_Id := l_Proj_Attrib_Rec.Inc_By_Person_Id;
8640
8641 End Loop;
8642
8643 G_Stage := 'Leaving CreateProjTimecardTable() procedure.';
8644 Pa_Otc_Api.TrackPath('STRIP','CreateProjTimecardTable');
8645
8646 Exception
8647 When Others Then
8648 Raise;
8649
8650 End CreateProjTimecardTable;
8651
8652
8653 -- =======================================================================
8654 -- Start of Comments
8655 -- API Name : OrigTrxRefValueExists
8656 -- Type : Private
8657 -- Pre-Reqs : None
8658 -- Type : Function
8659 -- Function : This function checks to see if the detail scope bb_id/ovn
8660 -- combination is already in Projects. This can occur during
8661 -- validation of the timecard under certain conditions. The
8662 -- orig_transaction_reference columns may get updated during
8663 -- validation to resink with OTL. (Changes are made that
8664 -- projects does not recognize and doesn't want to, thus the ovn changes in OTL.)
8665 --
8666 -- Parameters :
8667 -- IN
8668 -- P_Orig_Transaction_Reference - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
8669
8670 /*------------------------------------------------------------------------- */
8671
8672 Function OrigTrxRefValueExists
8673 ( P_Orig_Transaction_Reference IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE) Return Boolean
8674
8675 Is
8676
8677 l_Exists_Flag VARCHAR2(1) := 'N';
8678
8679 Begin
8680
8681 Select
8682 'Y'
8683 Into
8684 l_Exists_Flag
8685 From
8686 Pa_Expenditure_Items_All
8687 Where
8688 Transaction_Source = 'ORACLE TIME AND LABOR'
8689 And Orig_Transaction_Reference = P_Orig_Transaction_Reference;
8690
8691 If l_Exists_Flag = 'Y' Then
8692
8693 Return ( True ) ;
8694
8695 Else
8696
8697 Return ( False );
8698
8699 End If;
8700
8701 Exception
8702 When No_Data_Found Then
8703 Return ( False );
8704 When Others Then
8705 Raise;
8706
8707 End OrigTrxRefValueExists;
8708
8709
8710 -- =======================================================================
8711 -- Start of Comments
8712 -- API Name : ChkAdjustAllowedToOTCItem
8713 -- Type : Public
8714 -- Pre-Reqs : None
8715 -- Type : Function
8716 -- Function : This function s used to check and see if an OTL expenditure item that
8717 -- has been imported into Projects can adjusted in Projects by calling the
8718 -- API Hxc_Generic_Retrieval_Utils.Time_Bld_Blk_Changed.
8719 --
8720 -- Parameters :
8721 -- IN P_Orig_Txn_Reference - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
8722 --
8723 /*--------------------------------------------------------------------------*/
8724
8725 Function ChkAdjustAllowedToOTCItem
8726 (P_Orig_Txn_Reference IN Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE) Return Varchar2
8727
8728 Is
8729
8730 l_BB_Id Hxc_Time_Building_Blocks.Time_Building_Block_Id%TYPE := Null;
8731 l_BB_Ovn Hxc_Time_Building_Blocks.Object_Version_Number%TYPE := Null;
8732
8733 Begin
8734
8735 -- Check if the original transaction reference is null or not.
8736 If P_Orig_Txn_Reference Is Not Null Then
8737
8738 l_BB_Id := to_number(substr(P_Orig_Txn_Reference,1,instr(P_Orig_Txn_Reference,':') - 1));
8739 l_BB_Ovn := to_number(substr(P_Orig_Txn_Reference,instr(P_Orig_Txn_Reference,':') + 1));
8740
8741 /* The hxc function returns the case of whether or not there is a higher ovn value in the OTL table
8742 * than the ovn value we are passing in.
8743 * Therefore we actually want to return the opposite of that to the calling procedure/view.
8744 */
8745 If Hxc_Integration_Layer_V1_Grp.Time_Bld_Blk_Changed( P_BB_Id => l_BB_id, P_BB_Ovn => l_BB_Ovn) Then
8746
8747 Return ( 'N' );
8748
8749 Else
8750
8751 Return ( 'Y' );
8752
8753 End If;
8754
8755 Else
8756
8757 /* Did not originate in OTL. This item is a resulting child of the
8758 * original OTL item that was adjusted. So want to always default it
8759 * so that it can adjusted and let other code restrictions in PA handle
8760 * whether or not the expenditure item can be adjusted.
8761 */
8762 Return ( 'Y' );
8763
8764 End If;
8765
8766 Exception
8767 When Others Then
8768 Raise;
8769
8770 End ChkAdjustAllowedToOTCItem;
8771
8772
8773 -- =======================================================================
8774 -- Start of Comments
8775 -- API Name : GetBatchName
8776 -- Type : Private
8777 -- Pre-Reqs : None
8778 -- Type : Procedure
8779 -- Function : This procedure returns a batch name for Trx Import to used based on the
8780 -- : expenditure_ending_date passed in. Each time a new batch is created a new
8781 -- : record is added to a pl/sql table holding the Ending_Date Batch_Name so as
8782 -- : to only create single batch_name for each Ending_Date for a Trx Import run.
8783 -- : Used in the Upload_Otc_Timecards() procedure.
8784 --
8785 -- Parameters :
8786 -- IN
8787 -- P_Exp_End_Date - Pa_Transaction_Interface_All.Expenditure_Ending_Date%TYPE
8788 -- OUT
8789 -- X_Batch_Name - Pa_Transaction_Interface_All.Batch_Name%TYPE
8790 /*--------------------------------------------------------------------------*/
8791
8792 Procedure GetBatchName (P_Exp_End_Date IN Pa_Transaction_Interface_All.Expenditure_Ending_Date%TYPE,
8793 X_Batch_Name OUT NOCOPY Pa_Transaction_Interface_All.Batch_Name%TYPE)
8794
8795 Is
8796
8797 l_Found_Match Boolean := False;
8798 l_Date_String Varchar2(10);
8799 l_Sequence_No Number;
8800 l_New_Index Binary_Integer := 0;
8801 l_debug_text Varchar2(200);
8802
8803 Begin
8804
8805 G_Stage := 'Entering GetBatchName(), add procedure to trackpath.';
8806 If G_Debug_Mode = 'Y' Then
8807 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8808 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8809 End If;
8810 Pa_Otc_Api.TrackPath('ADD','GetBatchName');
8811
8812 If G_EndDateBatchName_Table.Count > 0 Then
8813
8814 G_Stage := 'There are already batch name recs in pl/sql table. See if find a matching one via loop.';
8815 If G_Debug_Mode = 'Y' Then
8816 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8817 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8818 End If;
8819
8820 For i IN G_EndDateBatchName_Table.First .. G_EndDateBatchName_Table.Last
8821 Loop
8822
8823 If G_EndDateBatchName_Table(i).Expenditure_Ending_Date = P_Exp_End_Date Then
8824
8825 X_Batch_Name := G_EndDateBatchName_Table(i).Batch_Name;
8826 l_Found_Match := True;
8827
8828 End If;
8829
8830 End Loop;
8831
8832 G_Stage := 'Done searching for matching batch name record via loop.';
8833 If G_Debug_Mode = 'Y' Then
8834 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8835 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8836 End If;
8837
8838 End If; -- G_EndDateBatchName_Table.Count > 0
8839
8840 If Not l_Found_Match Then
8841
8842 /* Create a batch Name for Import run.*/
8843 G_Stage := 'Get string of sysdate in YYMMDD format.';
8844 If G_Debug_Mode = 'Y' Then
8845 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8846 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8847 End If;
8848
8849 Select
8850 To_Char(P_Exp_End_Date,'YYMMDD')
8851 Into
8852 l_Date_String
8853 From
8854 Dual;
8855
8856 G_Stage := 'Use mod(pa_expenditure_groups_s.nextval,1000) to create number value.';
8857 If G_Debug_Mode = 'Y' Then
8858 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8859 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8860 End If;
8861
8862 SELECT
8863 Mod(Pa_Expenditure_Groups_S.NextVal,1000)
8864 INTO
8865 l_Sequence_No
8866 FROM
8867 Dual;
8868
8869 G_Stage := 'Create a batch Name for Import run.';
8870 If G_Debug_Mode = 'Y' Then
8871 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8872 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8873 End If;
8874
8875 X_Batch_Name := l_Date_String || '-' || To_Char(l_Sequence_No);
8876
8877 l_New_Index := G_EndDateBatchName_Table.Count + 1;
8878
8879 G_EndDateBatchName_Table(l_New_Index).Expenditure_Ending_Date := P_Exp_End_Date;
8880 G_EndDateBatchName_Table(l_New_Index).Batch_Name := X_Batch_Name;
8881
8882 End If; -- Not l_Found_Match
8883
8884 G_Stage := 'Leaving GetBatchName(), strip procedure from trackpath.';
8885 If G_Debug_Mode = 'Y' Then
8886 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8887 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8888 End If;
8889 Pa_Otc_Api.TrackPath('STRIP','GetBatchName');
8890
8891 Exception
8892 When Others Then
8893 l_debug_text := 'Leaving GetBatchName() due to unhandled exception, strip procedure from trackpath.';
8894 If G_Debug_Mode = 'Y' Then
8895 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || l_debug_text;
8896 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
8897 End If;
8898 Pa_Otc_Api.TrackPath('STRIP','GetBatchName');
8899 Raise;
8900
8901 End GetBatchName;
8902
8903 -- =======================================================================
8904 -- Start of Comments
8905 -- API Name : IsNumber
8906 -- Type : Private
8907 -- Pre-Reqs : None
8908 -- Type : Function
8909 -- Returns : BOOLEAN
8910 -- Function : This functions determines if the varchar passed back is a number.
8911 -- : Used in the Validate_Process() procedure.
8912 --
8913 -- Parameters :
8914 -- IN
8915 -- P_Value - Varchar2
8916 /*--------------------------------------------------------------------------*/
8917
8918 Function IsNumber (P_Value IN Varchar2) Return Boolean
8919
8920 Is
8921
8922 l_Converted_Value Number := Null;
8923
8924 Begin
8925
8926 l_Converted_Value := to_Number(P_Value);
8927 Return ( True );
8928
8929 Exception
8930
8931 When Others Then
8932 Return ( False );
8933
8934 End IsNumber;
8935
8936
8937 -- =======================================================================
8938 -- Start of Comments
8939 -- API Name : GetOrigTrxRef
8940 -- Type : Private
8941 -- Pre-Reqs : None
8942 -- Type : Procedure
8943 -- Returns :
8944 -- Function : This procedure determines the max orig_transaction_reference to
8945 -- : return based on the Building Block Id passed in.
8946 -- : Since this procedure is only called when OTL is sending a detail bb for
8947 -- : adjustment of existing data in Projects a NO_DATA_FOUND error means data corruption
8948 -- : Used in the Upload_Otc_Timecards() procedure.
8949 --
8950 -- Parameters :
8951 -- IN
8952 -- P_Building_Block_Id - Number
8953 -- OUT
8954 -- X_OrigTrxRef - Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE
8955 -- X_Status - Varchar2
8956 /*--------------------------------------------------------------------------*/
8957
8958 Procedure GetOrigTrxRef (P_Building_Block_Id IN Number,
8959 X_OrigTrxRef OUT NOCOPY Varchar2,
8960 X_Status OUT NOCOPY Varchar2)
8961
8962 Is
8963
8964 l_Search Pa_Expenditure_Items_All.Orig_Transaction_Reference%TYPE;
8965 l_Error_Text Varchar2(1800);
8966
8967 Begin
8968
8969 G_Stage := 'Entering GetOrigTrxRef(), add procedure to trackpath.';
8970 If G_Debug_Mode = 'Y' Then
8971 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8972 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
8973 End If;
8974 Pa_Otc_Api.TrackPath('ADD','GetOrigTrxRef');
8975
8976 G_Stage := 'Build search string.';
8977 If G_Debug_Mode = 'Y' Then
8978 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8979 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
8980 End If;
8981 l_Search := to_char(P_Building_Block_Id) || ':%';
8982
8983 G_Stage := 'Search ei table for available ei record.';
8984 If G_Debug_Mode = 'Y' Then
8985 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
8986 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,1);
8987 End If;
8988 Select
8989 Orig_Transaction_Reference
8990 Into
8991 X_OrigTrxRef
8992 From
8993 Pa_Expenditure_Items_All
8994 Where
8995 Orig_Transaction_Reference like l_Search
8996 And Transaction_Source = 'ORACLE TIME AND LABOR'
8997 And Nvl(Net_Zero_Adjustment_Flag,'N') = 'N'
8998 And Adjusted_Expenditure_Item_Id is Null
8999 And to_number(substr(Orig_Transaction_Reference,instr(Orig_Transaction_Reference,':') + 1)) = (
9000 Select
9001 Max(to_Number(Substr(Orig_Transaction_Reference,instr(Orig_Transaction_Reference,':') + 1)))
9002 From
9003 Pa_Expenditure_Items_All
9004 Where
9005 Orig_Transaction_Reference like l_Search
9006 And Transaction_Source = 'ORACLE TIME AND LABOR'
9007 And Nvl(Net_Zero_Adjustment_Flag,'N') = 'N'
9008 And Adjusted_Expenditure_Item_Id is Null);
9009
9010 G_Stage := 'Leaving GetOrigTrxRef(), strip procedure from trackpath.';
9011 If G_Debug_Mode = 'Y' Then
9012 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9013 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
9014 End If;
9015 Pa_Otc_Api.TrackPath('STRIP','GetOrigTrxRef');
9016
9017 Exception
9018 When No_Data_Found Then
9019 -- Data corruption exists if this happens here.
9020 l_error_text := SubStr('Pa_Otc_Api ::: ' || G_Path || ' : ' || G_Stage || ' -- ' ||
9021 SqlErrM, 1, 1800);
9022 fnd_message.set_name('HXC', 'HXC_RET_UNEXPECTED_ERROR');
9023 fnd_message.set_token('ERR', l_error_text);
9024 X_Status := SubStr(fnd_message.get,1,2000);
9025
9026 G_Stage := 'Leaving GetOrigTrxRef() due to unhandled exception, strip procedure from trackpath';
9027 If G_Debug_Mode = 'Y' Then
9028 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9029 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
9030 End If;
9031 Pa_Otc_Api.TrackPath('STRIP','GetOrigTrxRef');
9032
9033 If G_Debug_Mode = 'Y' Then
9034 Pa_Debug.G_err_Stage := l_error_text;
9035 pa_cc_utils.log_message(Pa_Debug.G_Err_Stage,0);
9036 End If;
9037
9038 When Others Then
9039 Raise;
9040
9041 End GetOrigTrxRef;
9042
9043 -- =======================================================================
9044 -- Start of Comments
9045 -- API Name : GetAdditionalTrxData
9046 -- Type : Private
9047 -- Pre-Reqs : None
9048 -- Type : Procedure
9049 -- Returns :
9050 -- Function : Gets all the addition data needed to insert records into the Trx Interface table
9051 -- : Used in the Upload_Otc_Timecards() procedure.
9052 --
9053 -- Parameters :
9054 -- IN
9055 -- P_Ei_Date Date
9056 -- P_Person_Id Number
9057 -- OUT
9058 -- X_Org_Id Number
9059 -- X_Error_Status Varchar2
9060
9061 /*--------------------------------------------------------------------------*/
9062
9063 Procedure GetAdditionalTrxData (P_Ei_Date IN Date,
9064 P_Person_Id IN Number,
9065 X_Org_Id OUT NOCOPY Number,
9066 X_Error_Status OUT NOCOPY Varchar2)
9067
9068 Is
9069
9070 Begin
9071
9072 G_Stage := 'Entering GetAdditionalTrxData(), add procedure to trackpath.';
9073 If G_Debug_Mode = 'Y' Then
9074 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9075 pa_cc_utils.log_message('GetAdditionalTrxData: ' || Pa_Debug.G_Err_Stage,0);
9076 End If;
9077 Pa_Otc_Api.TrackPath('ADD','GetAdditionalTrxData');
9078
9079 G_Stage := 'Get Incurred by Organization Id.';
9080 If G_Debug_Mode = 'Y' Then
9081 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9082 pa_cc_utils.log_message('GetAdditionalTrxData: ' || Pa_Debug.G_Err_Stage,0);
9083 End If;
9084
9085 Pa_Utils3.GetCachedOrgId( P_Inc_By_Per_Id => P_Person_Id,
9086 P_Exp_Item_Date => P_EI_Date,
9087 X_Inc_By_Org_Id => X_Org_Id);
9088
9089 G_Stage := 'Incurred by Organization Id is ' || to_char(X_Org_Id) ;
9090 If G_Debug_Mode = 'Y' Then
9091 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9092 pa_cc_utils.log_message('GetAdditionalTrxData: ' || Pa_Debug.G_Err_Stage,0);
9093 End If;
9094
9095 X_Error_Status := Null;
9096
9097 G_Stage := 'Leaving GetAdditionalTrxData(), strip procedure from trackpath.';
9098 If G_Debug_Mode = 'Y' Then
9099 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9100 Pa_Cc_Utils.Log_Message('GetAdditionalTrxData: ' || Pa_Debug.G_Err_Stage,0);
9101 End If;
9102 Pa_Otc_Api.TrackPath('STRIP','GetAdditionalTrxData');
9103
9104 Exception
9105 When Others Then
9106 X_Error_Status := 'Could not get Incurred by Organization Id.';
9107 G_Stage := 'Leaving GetAdditionalTrxData() in exception handler.';
9108 If G_Debug_Mode = 'Y' Then
9109 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9110 pa_cc_utils.log_message('GetAdditionalTrxData: ' || Pa_Debug.G_Err_Stage,0);
9111 End If;
9112 Pa_Otc_Api.TrackPath('STRIP','GetAdditionalTrxData');
9113
9114 End GetAdditionalTrxData;
9115
9116
9117 -- =======================================================================
9118 -- Start of Comments
9119 -- API Name : BulkInsertReset
9120 -- Type : Private
9121 -- Pre-Reqs : None
9122 -- Type : Procedure
9123 -- Returns :
9124 -- Function : Calls bulk insert API.
9125 -- : Empties out all the global pl/sql arrays used for the bulk insert.
9126 -- : If the P_Command is 'INSERT' then the bulk insert command table handler is executed,
9127 -- : then the pl/sql table arrays are reset for the next time thru.
9128 -- : If the P_Command is 'RESET' then pl/sql table arrays are only reset.
9129 -- : Used in the Upload_Otc_Timecards() procedure.
9130 --
9131 -- Parameters :
9132 -- IN :
9133 -- : P_Command Varchar2
9134 -- OUT : n/a
9135
9136 /*--------------------------------------------------------------------------*/
9137
9138 Procedure BulkInsertReset (P_Command IN Varchar2)
9139
9140 Is
9141
9142 Begin
9143
9144 G_Stage := 'Entering BulkInsertReset(), add procedure to trackpath.';
9145 If G_Debug_Mode = 'Y' Then
9146 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9147 pa_cc_utils.log_message('BulkInsertReset: ' || Pa_Debug.G_Err_Stage,0);
9148 End If;
9149 Pa_Otc_Api.TrackPath('ADD','BulkInsertReset');
9150
9151 If P_Command = 'INSERT' Then
9152
9153 G_Stage := 'Bulk Insert records into Interface table via Pa_Txn_Interface_Items_Pkg.Bulk_Insert().';
9154 If G_Debug_Mode = 'Y' Then
9155 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9156 pa_cc_utils.log_message('BulkInsertReset: ' || Pa_Debug.G_Err_Stage,0);
9157 End If;
9158
9159 Pa_Txn_Interface_Items_Pkg.Bulk_Insert(
9160 P_Txn_Interface_Id_Tbl => G_Txn_Interface_Id_Tbl,
9161 P_Transaction_Source_Tbl => G_Transaction_Source_Tbl,
9162 P_User_Transaction_Source_Tbl => G_User_Transaction_Source_Tbl,
9163 P_Batch_Name_Tbl => G_Batch_Name_Tbl,
9164 P_Expenditure_End_Date_Tbl => G_Expenditure_End_Date_Tbl,
9165 P_Person_Bus_Grp_Name_Tbl => G_Person_Bus_Grp_Name_Tbl,
9166 P_Person_Bus_Grp_Id_Tbl => G_Person_Bus_Grp_Id_Tbl,
9167 P_Employee_Number_Tbl => G_Employee_Number_Tbl,
9168 P_Person_Id_Tbl => G_Person_Id_Tbl,
9169 P_Organization_Name_Tbl => G_Organization_Name_Tbl,
9170 P_Organization_Id_Tbl => G_Organization_Id_Tbl,
9171 P_Expenditure_Item_Date_Tbl => G_Expenditure_Item_Date_Tbl,
9172 P_Project_Number_Tbl => G_Project_Number_Tbl,
9173 P_Project_Id_Tbl => G_Project_Id_Tbl,
9174 P_Task_Number_Tbl => G_Task_Number_Tbl,
9175 P_Task_Id_Tbl => G_Task_Id_Tbl,
9176 P_Expenditure_Type_Tbl => G_Expenditure_Type_Tbl,
9177 P_System_Linkage_Tbl => G_System_Linkage_Tbl,
9178 P_Non_Labor_Resource_Tbl => G_Non_Labor_Resource_Tbl,
9179 P_Non_Labor_Res_Org_Name_Tbl => G_Non_Labor_Res_Org_Name_Tbl,
9180 P_Non_Labor_Res_Org_Id_Tbl => G_Non_Labor_Res_Org_Id_Tbl,
9181 P_Quantity_Tbl => G_Quantity_Tbl,
9182 P_Raw_Cost_Tbl => G_Raw_Cost_Tbl,
9183 P_Raw_Cost_Rate_Tbl => G_Raw_Cost_Rate_Tbl,
9184 P_Burden_Cost_Tbl => G_Burden_Cost_Tbl,
9185 P_Burden_Cost_Rate_Tbl => G_Burden_Cost_Rate_Tbl,
9186 P_Expenditure_Comment_Tbl => G_Expenditure_Comment_Tbl,
9187 P_Gl_Date_Tbl => G_Gl_Date_Tbl,
9188 P_Transaction_Status_Code_Tbl => G_Transaction_Status_Code_Tbl,
9189 P_Trans_Rejection_Code_Tbl => G_Trans_Rejection_Code_Tbl,
9190 P_Orig_Trans_Reference_Tbl => G_Orig_Trans_Reference_Tbl,
9191 P_Unmatched_Neg_Txn_Flag_Tbl => G_Unmatched_Neg_Txn_Flag_Tbl,
9192 P_Expenditure_Id_Tbl => G_Expenditure_Id_Tbl,
9193 P_Attribute_Category_Tbl => G_Attribute_Category_Tbl,
9194 P_Attribute1_Tbl => G_Attribute1_Tbl,
9195 P_Attribute2_Tbl => G_Attribute2_Tbl,
9196 P_Attribute3_Tbl => G_Attribute3_Tbl,
9197 P_Attribute4_Tbl => G_Attribute4_Tbl,
9198 P_Attribute5_Tbl => G_Attribute5_Tbl,
9199 P_Attribute6_Tbl => G_Attribute6_Tbl,
9200 P_Attribute7_Tbl => G_Attribute7_Tbl,
9201 P_Attribute8_Tbl => G_Attribute8_Tbl,
9202 P_Attribute9_Tbl => G_Attribute9_Tbl,
9203 P_Attribute10_Tbl => G_Attribute10_Tbl,
9204 P_Dr_Code_Combination_Id_Tbl => G_Dr_Code_Combination_Id_Tbl,
9205 P_Cr_Code_Combination_Id_Tbl => G_Cr_Code_Combination_Id_Tbl,
9206 P_Cdl_System_Reference1_Tbl => G_Cdl_System_Reference1_Tbl,
9207 P_Cdl_System_Reference2_Tbl => G_Cdl_System_Reference2_Tbl,
9208 P_Cdl_System_Reference3_Tbl => G_Cdl_System_Reference3_Tbl,
9209 P_Interface_Id_Tbl => G_Interface_Id_Tbl,
9210 P_Receipt_Currency_Amount_Tbl => G_Receipt_Currency_Amount_Tbl,
9211 P_Receipt_Currency_Code_Tbl => G_Receipt_Currency_Code_Tbl,
9212 P_Receipt_Exchange_Rate_Tbl => G_Receipt_Exchange_Rate_Tbl,
9213 P_Denom_Currency_Code_Tbl => G_Denom_Currency_Code_Tbl,
9214 P_Denom_Raw_Cost_Tbl => G_Denom_Raw_Cost_Tbl,
9215 P_Denom_Burdened_Cost_Tbl => G_Denom_Burdened_Cost_Tbl,
9216 P_Acct_Rate_Date_Tbl => G_Acct_Rate_Date_Tbl,
9217 P_Acct_Rate_Type_Tbl => G_Acct_Rate_Type_Tbl,
9218 P_Acct_Exchange_Rate_Tbl => G_Acct_Exchange_Rate_Tbl,
9219 P_Acct_Raw_Cost_Tbl => G_Acct_Raw_Cost_Tbl,
9220 P_Acct_Burdened_Cost_Tbl => G_Acct_Burdened_Cost_Tbl,
9221 P_Acct_Exch_Rounding_Limit_Tbl => G_Acct_Exch_Rounding_Limit_Tbl,
9222 P_Project_Currency_Code_Tbl => G_Project_Currency_Code_Tbl,
9223 P_Project_Rate_Date_Tbl => G_Project_Rate_Date_Tbl,
9224 P_Project_Rate_Type_Tbl => G_Project_Rate_Type_Tbl,
9225 P_Project_Exchange_Rate_Tbl => G_Project_Exchange_Rate_Tbl,
9226 P_Orig_Exp_Txn_Reference1_Tbl => G_Orig_Exp_Txn_Reference1_Tbl,
9227 P_Orig_Exp_Txn_Reference2_Tbl => G_Orig_Exp_Txn_Reference2_Tbl,
9228 P_Orig_Exp_Txn_Reference3_Tbl => G_Orig_Exp_Txn_Reference3_Tbl,
9229 P_Orig_User_Exp_Txn_Ref_Tbl => G_Orig_User_Exp_Txn_Ref_Tbl,
9230 P_Vendor_Number_Tbl => G_Vendor_Number_Tbl,
9231 P_Vendor_Id_Tbl => G_Vendor_Id_Tbl,
9232 P_Override_To_Org_Name_Tbl => G_Override_To_Org_Name_Tbl,
9233 P_Override_To_Org_Id_Tbl => G_Override_To_Org_Id_Tbl,
9234 P_Reversed_Orig_Txn_Ref_Tbl => G_Reversed_Orig_Txn_Ref_Tbl,
9235 P_Billable_Flag_Tbl => G_Billable_Flag_Tbl,
9236 P_ProjFunc_Currency_Code_Tbl => G_ProjFunc_Currency_Code_Tbl,
9237 P_ProjFunc_Cost_Rate_Date_Tbl => G_ProjFunc_Cost_Rate_Date_Tbl,
9238 P_ProjFunc_Cost_Rate_Type_Tbl => G_ProjFunc_Cost_Rate_Type_Tbl,
9239 P_ProjFunc_Cost_Exch_Rate_Tbl => G_ProjFunc_Cost_Exch_Rate_Tbl,
9240 P_Project_Raw_Cost_Tbl => G_Project_Raw_Cost_Tbl,
9241 P_Project_Burdened_Cost_Tbl => G_Project_Burdened_Cost_Tbl,
9242 P_Assignment_Name_Tbl => G_Assignment_Name_Tbl,
9243 P_Assignment_Id_Tbl => G_Assignment_Id_Tbl,
9244 P_Work_Type_Name_Tbl => G_Work_Type_Name_Tbl,
9245 P_Work_Type_Id_Tbl => G_Work_Type_Id_Tbl,
9246 P_Cdl_System_Reference4_Tbl => G_Cdl_System_Reference4_Tbl,
9247 P_Accrual_Flag_Tbl => G_Accrual_Flag_Tbl,
9248 P_Last_Update_Date_Tbl => G_Last_Update_Date_Tbl,
9249 P_Last_Updated_By_Tbl => G_Last_Updated_By_Tbl,
9250 P_Creation_Date_Tbl => G_Creation_Date_Tbl,
9251 P_Created_By_Tbl => G_Created_By_Tbl,
9252 P_PO_Number_Tbl => G_PO_Number_Tbl,
9253 P_PO_Header_Id_Tbl => G_PO_Header_Id_Tbl,
9254 P_PO_Line_Num_Tbl => G_PO_Line_Num_Tbl,
9255 P_PO_Line_Id_Tbl => G_PO_Line_Id_Tbl,
9256 P_PO_Price_Type_Tbl => G_PO_Price_Type_Tbl,
9257 P_Person_Type_Tbl => G_Person_Type_Tbl,
9258 P_Inventory_Item_Id_Tbl => G_Inventory_Item_Id_Tbl,
9259 P_WIP_Resource_Id_Tbl => G_WIP_Resource_Id_Tbl,
9260 P_Unit_Of_Measure_Tbl => G_Unit_Of_Measure_Tbl,
9261 P_Org_Id_Tbl => G_OU_Tbl);
9262
9263 End If;
9264
9265 If P_Command in ( 'INSERT', 'RESET' ) Then
9266
9267 G_Stage := 'Reset all pl/sql table arrays used for bulk insert.';
9268 If G_Debug_Mode = 'Y' Then
9269 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9270 pa_cc_utils.log_message('BulkInsertReset: ' || Pa_Debug.G_Err_Stage,0);
9271 End If;
9272
9273 G_Txn_Interface_Id_Tbl.Delete;
9274 G_Transaction_Source_Tbl.Delete;
9275 G_User_Transaction_Source_Tbl.Delete;
9276 G_Batch_Name_Tbl.Delete;
9277 G_Expenditure_End_Date_Tbl.Delete;
9278 G_Person_Bus_Grp_Name_Tbl.Delete;
9279 G_Person_Bus_Grp_Id_Tbl.Delete;
9280 G_Employee_Number_Tbl.Delete;
9281 G_Person_Id_Tbl.Delete;
9282 G_Organization_Name_Tbl.Delete;
9283 G_Organization_Id_Tbl.Delete;
9284 G_Expenditure_Item_Date_Tbl.Delete;
9285 G_Project_Number_Tbl.Delete;
9286 G_Project_Id_Tbl.Delete;
9287 G_Task_Number_Tbl.Delete;
9288 G_Task_Id_Tbl.Delete;
9289 G_Expenditure_Type_Tbl.Delete;
9290 G_System_Linkage_Tbl.Delete;
9291 G_Non_Labor_Resource_Tbl.Delete;
9292 G_Non_Labor_Res_Org_Name_Tbl.Delete;
9293 G_Non_Labor_Res_Org_Id_Tbl.Delete;
9294 G_Quantity_Tbl.Delete;
9295 G_Raw_Cost_Tbl.Delete;
9296 G_Raw_Cost_Rate_Tbl.Delete;
9297 G_Burden_Cost_Tbl.Delete;
9298 G_Burden_Cost_Rate_Tbl.Delete;
9299 G_Expenditure_Comment_Tbl.Delete;
9300 G_Gl_Date_Tbl.Delete;
9301 G_Transaction_Status_Code_Tbl.Delete;
9302 G_Trans_Rejection_Code_Tbl.Delete;
9303 G_Orig_Trans_Reference_Tbl.Delete;
9304 G_Unmatched_Neg_Txn_Flag_Tbl.Delete;
9305 G_Expenditure_Id_Tbl.Delete;
9306 G_Attribute_Category_Tbl.Delete;
9307 G_Attribute1_Tbl.Delete;
9308 G_Attribute2_Tbl.Delete;
9309 G_Attribute3_Tbl.Delete;
9310 G_Attribute4_Tbl.Delete;
9311 G_Attribute5_Tbl.Delete;
9312 G_Attribute6_Tbl.Delete;
9313 G_Attribute7_Tbl.Delete;
9314 G_Attribute8_Tbl.Delete;
9315 G_Attribute9_Tbl.Delete;
9316 G_Attribute10_Tbl.Delete;
9317 G_Dr_Code_Combination_Id_Tbl.Delete;
9318 G_Cr_Code_Combination_Id_Tbl.Delete;
9319 G_Cdl_System_Reference1_Tbl.Delete;
9320 G_Cdl_System_Reference2_Tbl.Delete;
9321 G_Cdl_System_Reference3_Tbl.Delete;
9322 G_Interface_Id_Tbl.Delete;
9323 G_Receipt_Currency_Amount_Tbl.Delete;
9324 G_Receipt_Currency_Code_Tbl.Delete;
9325 G_Receipt_Exchange_Rate_Tbl.Delete;
9326 G_Denom_Currency_Code_Tbl.Delete;
9327 G_Denom_Raw_Cost_Tbl.Delete;
9328 G_Denom_Burdened_Cost_Tbl.Delete;
9329 G_Acct_Rate_Date_Tbl.Delete;
9330 G_Acct_Rate_Type_Tbl.Delete;
9331 G_Acct_Exchange_Rate_Tbl.Delete;
9332 G_Acct_Raw_Cost_Tbl.Delete;
9333 G_Acct_Burdened_Cost_Tbl.Delete;
9334 G_Acct_Exch_Rounding_Limit_Tbl.Delete;
9335 G_Project_Currency_Code_Tbl.Delete;
9336 G_Project_Rate_Date_Tbl.Delete;
9337 G_Project_Rate_Type_Tbl.Delete;
9338 G_Project_Exchange_Rate_Tbl.Delete;
9339 G_Orig_Exp_Txn_Reference1_Tbl.Delete;
9340 G_Orig_Exp_Txn_Reference2_Tbl.Delete;
9341 G_Orig_Exp_Txn_Reference3_Tbl.Delete;
9342 G_Orig_User_Exp_Txn_Ref_Tbl.Delete;
9343 G_Vendor_Number_Tbl.Delete;
9344 G_Vendor_Id_Tbl.Delete;
9345 G_Override_To_Org_Name_Tbl.Delete;
9346 G_Override_To_Org_Id_Tbl.Delete;
9347 G_Reversed_Orig_Txn_Ref_Tbl.Delete;
9348 G_Billable_Flag_Tbl.Delete;
9349 G_ProjFunc_Currency_Code_Tbl.Delete;
9350 G_ProjFunc_Cost_Rate_Date_Tbl.Delete;
9351 G_ProjFunc_Cost_Rate_Type_Tbl.Delete;
9352 G_ProjFunc_Cost_Exch_Rate_Tbl.Delete;
9353 G_Project_Raw_Cost_Tbl.Delete;
9354 G_Project_Burdened_Cost_Tbl.Delete;
9355 G_Assignment_Name_Tbl.Delete;
9356 G_Assignment_Id_Tbl.Delete;
9357 G_Work_Type_Name_Tbl.Delete;
9358 G_Work_Type_Id_Tbl.Delete;
9359 G_Cdl_System_Reference4_Tbl.Delete;
9360 G_Accrual_Flag_Tbl.Delete;
9361 G_Last_Update_Date_Tbl.Delete;
9362 G_Last_Updated_By_Tbl.Delete;
9363 G_Creation_Date_Tbl.Delete;
9364 G_Created_By_Tbl.Delete;
9365 -- Begin PA.M/CWK changes
9366 G_PO_Number_Tbl.Delete;
9367 G_PO_Header_Id_Tbl.Delete;
9368 G_PO_Line_Num_Tbl.Delete;
9369 G_PO_Line_Id_Tbl.Delete;
9370 G_PO_Price_Type_Tbl.Delete;
9371 G_Person_Type_Tbl.Delete;
9372 -- End PA.M/CWK changes
9373 G_Inventory_Item_Id_Tbl.Delete;
9374 G_WIP_Resource_Id_Tbl.Delete;
9375 G_Unit_Of_Measure_Tbl.Delete;
9376 -- 12i MOAC changes
9377 G_OU_Tbl.Delete;
9378
9379 End If;
9380
9381 G_Stage := 'Leaving BulkInsertReset(), strip procedure from trackpath.';
9382 If G_Debug_Mode = 'Y' Then
9383 Pa_Debug.G_err_Stage := 'Pa_Otc_Api ::: ' || G_Path || ' :: ' || G_Stage;
9384 Pa_Cc_Utils.Log_Message('BulkInsertReset: ' || Pa_Debug.G_Err_Stage,0);
9385 End If;
9386 Pa_Otc_Api.TrackPath('STRIP','BulkInsertReset');
9387
9388 Exception
9389 When Others Then
9390 Raise;
9391
9392 End BulkInsertReset;
9393
9394 -- =======================================================================
9395 -- Start of Comments
9396 -- API Name : TrxInCurrentChunk
9397 -- Type : Private
9398 -- Pre-Reqs : None
9399 -- Type : Function
9400 -- Returns : Varchar2
9401 -- Function : Determine if the Trx in part of the current chunk being processed.
9402 -- : Since we now have the looping functionality in Trx Import and we have to restrict the cursor
9403 -- : more in what it picks up. We have to make sure that we don't try to update rejected
9404 -- : Trx records from other loops that have already been ran. They are at a status of 'R'
9405 -- : So we check to see if it exists in the pl/sql table and then if it does
9406 -- : we update the otl pl/sql table accordingly run.
9407 -- : Used in the Tieback_Otc_Timecards() procedure.
9408 --
9409 -- Parameters :
9410 -- IN :
9411 -- : P_Detail_BB_Id - Number
9412 -- OUT : n/a
9413
9414 /*--------------------------------------------------------------------------*/
9415
9416 Function TrxInCurrentChunk (P_Detail_BB_Id IN Number) Return Varchar2 Is
9417
9418 Begin
9419
9420 If G_Trx_Inserted_Tab.Exists(P_Detail_BB_Id) Then
9421
9422 Return ( 'Y' );
9423
9424 Else
9425
9426 Return ( 'N' );
9427
9428 End If;
9429
9430 Exception
9431 When Others Then
9432 Raise;
9433
9434
9435 End TrxInCurrentChunk;
9436
9437 -- =======================================================================
9438 -- Start of Comments
9439 -- API Name : GetProjectManager
9440 -- Type : Public
9441 -- Pre-Reqs : None
9442 -- Type : Function
9443 -- Returns : Number
9444 -- Function : Returns the current project manager, person_id, for a project
9445 --
9446 -- Parameters :
9447 -- IN :
9448 -- : P_Project_Id - Number
9449 -- OUT : n/a
9450
9451 /*--------------------------------------------------------------------------*/
9452
9453 Function GetProjectManager ( P_Project_Id IN Number ) Return Number Is
9454
9455 l_Proj_Mgr_Person_Id Number := Null;
9456
9457 Begin
9458
9459 l_Proj_Mgr_Person_Id := Pa_Projects_Maint_Utils.Get_Project_Manager(p_project_id);
9460 Return l_Proj_Mgr_Person_Id;
9461
9462 Exception
9463 When Others Then
9464 Raise;
9465
9466
9467 End GetProjectManager;
9468
9469 -- =======================================================================
9470 -- Start of Comments
9471 -- API Name : GetPersonType
9472 -- Type : Private
9473 -- Pre-Reqs : None
9474 -- Type : Function
9475 -- Returns : Varchar2
9476 -- Function : Returns the Person Type based on the employee id.
9477 -- Valid Values: 'CWK' or 'EMP'
9478 --
9479 -- Parameters :
9480 -- IN :
9481 -- : P_Person_Id - NUMBER
9482 -- : P_Ei_Date - DATE
9483 -- OUT : n/a
9484
9485 /*--------------------------------------------------------------------------*/
9486
9487 Function GetPersonType ( P_Person_Id IN Number, P_Ei_Date IN Date) Return Varchar2
9488
9489 Is
9490
9491 X_Person_Type Pa_Expenditures_All.Person_Type%TYPE := Null;
9492
9493 Begin
9494
9495 Select
9496 Decode(Current_Npw_Flag,'Y','CWK','EMP')
9497 Into
9498 X_Person_Type
9499 From
9500 Per_People_F
9501 Where
9502 P_Ei_Date between Effective_Start_Date
9503 and Effective_End_Date
9504 And Person_Id = P_Person_Id;
9505
9506 Return ( X_Person_Type );
9507
9508 Exception
9509 When Others Then
9510 Return ( Null );
9511
9512 End GetPersonType;
9513
9514
9515 -- =======================================================================
9516 -- Start of Comments
9517 -- API Name : GetPOInfo
9518 -- Type : Private
9519 -- Pre-Reqs : None
9520 -- Type : Procedure
9521 -- Returns : n/a
9522 -- Function : Returns the Vendor_Id and PO_Header_Id
9523 --
9524 -- Parameters :
9525 -- IN :
9526 -- : P_PO_Line_Id - Number
9527 -- OUT :
9528 -- : X_Po_Header_Id - Number
9529 -- : X_Vendor_Id - Number
9530
9531 /*--------------------------------------------------------------------------*/
9532
9533 Procedure GetPOInfo(P_Po_Line_Id In Number,
9534 X_Po_Header_Id OUT NOCOPY Number,
9535 X_Vendor_Id OUT NOCOPY Number)
9536
9537 Is
9538
9539 l_Vendor_Id Number := Null;
9540 l_Po_Header_Id Number := Null;
9541
9542 Begin
9543
9544 If nvl(G_Po_Line_Id,-99999) <> P_Po_Line_Id Then
9545
9546 Select
9547 h.Vendor_Id,
9548 h.Po_Header_Id
9549 Into
9550 l_Vendor_Id,
9551 l_Po_Header_Id
9552 from
9553 PO_Headers_All h,
9554 PO_Lines_All l
9555 where
9556 l.po_line_Id = P_Po_Line_Id
9557 and l.po_header_id = h.po_header_Id;
9558
9559 G_Po_Line_Id := P_Po_Line_Id;
9560 G_Vendor_Id := l_Vendor_Id;
9561 G_PO_Header_Id := l_Po_Header_Id;
9562
9563 End If;
9564
9565 X_Po_Header_Id := G_PO_Header_Id;
9566 X_Vendor_Id := G_Vendor_Id;
9567
9568 Exception
9569 When Others Then
9570 Null;
9571
9572 End GetPOInfo;
9573
9574
9575 END Pa_Otc_Api ;