[Home] [Help]
PACKAGE BODY: APPS.PA_ACC_GEN_WF_PKG
Source
1 PACKAGE BODY pa_acc_gen_wf_pkg AS
2 /* $Header: PAXWFACB.pls 120.13.12020000.5 2013/04/09 17:55:19 rboyalap ship $ */
3
4 /***Bug 3182416 :Moved the declaration of g_ variables to spec .
5 g_error_message VARCHAR2(1000) :='';
6 g_error_stack VARCHAR2(500) :='';
7 g_error_stage VARCHAR2(100) :='';
8 *************************************************************/
9
10 /* Bug 5233487 - g_error_stack_history will store all the messages in the error stack */
11 TYPE ErrorStack IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
12 g_error_stack_history ErrorStack;
13
14 ----------------------------------------------------------------------
15 -- Procedure pa_acc_gen_wf_pkg.wf_acc_derive_params
16 -- Definition of procedure in package specifications
17 ----------------------------------------------------------------------
18
19 PROCEDURE wf_acc_derive_params (
20 p_project_id IN pa_projects_all.project_id%TYPE,
21 p_task_id IN pa_tasks.task_id%TYPE,
22 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
23 p_vendor_id IN po_vendors.vendor_id%type,
24 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
25 p_expenditure_item_date IN
26 pa_expenditure_items_all.expenditure_item_date%TYPE,
27 x_class_code OUT NOCOPY pa_class_codes.class_code%TYPE,
28 x_direct_flag OUT NOCOPY pa_project_types_all.direct_flag%TYPE,
29 x_expenditure_category OUT
30 NOCOPY pa_expenditure_categories.expenditure_category%TYPE,
31 x_expenditure_org_name OUT NOCOPY hr_organization_units.name%TYPE,
32 x_project_number OUT NOCOPY pa_projects_all.segment1%TYPE,
33 x_project_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
34 x_project_organization_id OUT NOCOPY hr_organization_units.organization_id %TYPE,
35 x_project_type OUT NOCOPY pa_project_types_all.project_type%TYPE,
36 x_public_sector_flag OUT NOCOPY pa_projects_all.public_sector_flag%TYPE,
37 x_revenue_category OUT NOCOPY pa_expenditure_types.revenue_category_code%TYPE,
38 x_task_number OUT NOCOPY pa_tasks.task_number%TYPE,
39 x_task_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
40 x_task_organization_id OUT NOCOPY hr_organization_units.organization_id %TYPE,
41 x_task_service_type OUT NOCOPY pa_tasks.service_type_code%TYPE,
42 x_top_task_id OUT NOCOPY pa_tasks.task_id%TYPE,
43 x_top_task_number OUT NOCOPY pa_tasks.task_number%TYPE,
44 x_vendor_employee_id OUT NOCOPY per_people_f.person_id%TYPE,
45 x_vendor_employee_number OUT NOCOPY per_people_f.employee_number%TYPE,
46 x_vendor_type OUT NOCOPY po_vendors.vendor_type_lookup_code%TYPE)
47 AS
48
49 l_person_effective_date DATE;
50
51 BEGIN
52
53 set_error_stack('-->wf_acc_derive_params'); /* Bug 5233487 */
54 g_encoded_error_message := NULL; /* Bug 5233487 */
55 g_error_message := '';
56 ---------------------------------------------------
57 -- If EI date is not passed, consider system date
58 ---------------------------------------------------
59 g_error_stage := '10';
60
61 IF p_expenditure_item_date is null
62 THEN
63 l_person_effective_date := sysdate;
64 ELSE
65 l_person_effective_date := p_expenditure_item_date;
66 END IF;
67
68 ----------------------------------------------------------
69 -- Derive vendor information if the vendor id is present
70 ----------------------------------------------------------
71 g_error_stage := '20';
72
73 IF p_vendor_id IS NOT NULL
74 THEN /* Commented for Bug# 4007983
75 SELECT
76 VEND.employee_id VENDOR_EMPLOYEE_ID,
77 EMP.employee_number VENDOR_EMPLOYEE_NUMBER,
78 VEND.vendor_type_lookup_code VENDOR_TYPE
79 INTO
80 x_vendor_employee_id,
81 x_vendor_employee_number,
82 x_vendor_type
83 FROM
84 po_vendors VEND,
85 per_people_f EMP
86 WHERE
87 VEND.vendor_id = p_vendor_id
88 AND VEND.employee_id = EMP.person_id (+)
89 AND l_person_effective_date
90 between EMP.effective_start_date(+)
91 and nvl(EMP.effective_end_date(+),sysdate); */
92
93 /* Start of Bug# 4007983 - Replaced the above query by these 2 queries */
94 SELECT
95 VEND.employee_id VENDOR_EMPLOYEE_ID,
96 VEND.vendor_type_lookup_code VENDOR_TYPE
97 INTO
98 x_vendor_employee_id,
99 x_vendor_type
100 FROM
101 po_vendors VEND
102 WHERE
103 VEND.vendor_id = p_vendor_id;
104
105 IF x_vendor_employee_id IS NOT NULL
106 THEN
107 BEGIN -- Bug 6053374
108 SELECT
109 EMP.employee_number VENDOR_EMPLOYEE_NUMBER
110 INTO
111 x_vendor_employee_number
112 FROM
113 per_people_f EMP
114 WHERE x_vendor_employee_id = EMP.person_id
115 AND l_person_effective_date between EMP.effective_start_date
116 and NVL (EMP.effective_end_date, sysdate);
117
118 /* Bug 6053374: Added the Exception block. Exception would be thrown only for a
119 Standard Invoice, as the case would be taken care in PAXTTXCB itself, for an Expense Report.
120 And for Standard Invoices, System should not throw an error even if the EI date does not fall
121 between effective_start_date and effective_end_date of the employee */
122 EXCEPTION
123 WHEN NO_DATA_FOUND THEN
124 null;
125 END; -- Bug 6053374: End
126 END IF;
127 /* End of Bug# 4007983 */
128 END IF;
129
130 ---------------------------------------------------------------
131 -- Derive project information
132 ---------------------------------------------------------------
133 g_error_stage := '30';
134
135 pa_acc_gen_wf_pkg.wf_acc_derive_pa_params(
136 p_project_id ,
137 p_task_id ,
138 p_expenditure_type ,
139 p_expenditure_organization_id ,
140 p_expenditure_item_date ,
141 x_class_code ,
142 x_direct_flag ,
143 x_expenditure_category ,
144 x_expenditure_org_name ,
145 x_project_number ,
146 x_project_organization_name ,
147 x_project_organization_id ,
148 x_project_type ,
149 x_public_sector_flag ,
150 x_revenue_category ,
151 x_task_number ,
152 x_task_organization_name ,
153 x_task_organization_id ,
154 x_task_service_type ,
155 x_top_task_id ,
156 x_top_task_number );
157
158 reset_error_stack; /* Bug 5233487 */
159
160 EXCEPTION WHEN others THEN
161 /* Bug 5233487 - Start */
162 IF g_encoded_error_message IS NULL THEN
163 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
164 END IF;
165 reset_error_stack;
166 /* Bug 5233487 - End */
167 g_error_message := SQLERRM;
168 raise;
169 END wf_acc_derive_params;
170
171 ------------------- End of procedure wf_acc_Derive_params ---------------------
172
173 ----------------------------------------------------------------------
174 -- Procedure pa_acc_gen_wf_pkg.wf_acc_derive_er_params
175 -- Definition of procedure in package specifications
176 ----------------------------------------------------------------------
177
178 PROCEDURE wf_acc_derive_er_params (
179 p_project_id IN pa_projects_all.project_id%TYPE,
180 p_task_id IN pa_tasks.task_id%TYPE,
181 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
182 p_vendor_id IN po_vendors.vendor_id%type,
183 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
184 p_expenditure_item_date IN
185 pa_expenditure_items_all.expenditure_item_date%TYPE,
186 p_calling_module IN VARCHAR2,
187 p_employee_id IN per_people_f.person_id%TYPE,
188 p_employee_ccid IN OUT NOCOPY gl_code_combinations.code_combination_id%TYPE,
189 p_expense_type IN ap_expense_report_lines_all.web_parameter_id%TYPE,
190 p_expense_cc IN ap_expense_report_headers_all.flex_concatenated%TYPE,
191 x_class_code OUT NOCOPY pa_class_codes.class_code%TYPE,
192 x_direct_flag OUT NOCOPY pa_project_types_all.direct_flag%TYPE,
193 x_expenditure_category OUT NOCOPY pa_expenditure_categories.expenditure_category%TYPE,
194 x_expenditure_org_name OUT NOCOPY hr_organization_units.name%TYPE,
195 x_project_number OUT NOCOPY pa_projects_all.segment1%TYPE,
196 x_project_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
197 x_project_organization_id OUT NOCOPY hr_organization_units.organization_id%TYPE,
198 x_project_type OUT NOCOPY pa_project_types_all.project_type%TYPE,
199 x_public_sector_flag OUT NOCOPY pa_projects_all.public_sector_flag%TYPE,
203 x_task_organization_id OUT NOCOPY hr_organization_units.organization_id%TYPE,
200 x_revenue_category OUT NOCOPY pa_expenditure_types.revenue_category_code%TYPE,
201 x_task_number OUT NOCOPY pa_tasks.task_number%TYPE,
202 x_task_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
204 x_task_service_type OUT NOCOPY pa_tasks.service_type_code%TYPE,
205 x_top_task_id OUT NOCOPY pa_tasks.task_id%TYPE,
206 x_top_task_number OUT NOCOPY pa_tasks.task_number%TYPE,
207 x_employee_number OUT NOCOPY per_people_f.employee_number%TYPE,
208 x_vendor_type OUT NOCOPY po_vendors.vendor_type_lookup_code%TYPE,
209 x_person_type OUT NOCOPY VARCHAR2 )
210 AS
211
212 l_person_effective_date DATE;
213 l_employee_ccid Number;
214
215 BEGIN
216 set_error_stack('-->wf_acc_derive_er_params'); /* Bug 5233487 */
217 g_encoded_error_message := NULL; /* Bug 5233487 */
218 g_error_message := '';
219
220 ---------------------------------------------------
221 -- If EI date is not passed, consider system date
222 ---------------------------------------------------
223 g_error_stage := '10';
224
225 IF p_expenditure_item_date is null
226 THEN
227 l_person_effective_date := sysdate;
228 ELSE
229 l_person_effective_date := p_expenditure_item_date;
230 END IF;
231
232 ----------------------------------------------------------
233 -- Derive vendor information if the vendor id is present
234 ----------------------------------------------------------
235 g_error_stage := '20';
236
237 IF p_vendor_id IS NOT NULL
238 THEN
239 SELECT
240 VEND.vendor_type_lookup_code VENDOR_TYPE
241 INTO
242 x_vendor_type
243 FROM
244 po_vendors VEND
245 WHERE
246 VEND.vendor_id = p_vendor_id ;
247 END IF;
248
249 ---------------------------------------------------------------
250 -- Derive employee information if employee id is present
251 ---------------------------------------------------------------
252 g_error_stage := '30';
253
254 IF p_employee_id IS NOT NULL
255 THEN
256 BEGIN
257 /** Commented out below SQL to accommodate CWK changes **/
258
259 /* SELECT
260 EMP.employee_num, EMP.default_code_combination_id
261 INTO
262 x_employee_number, l_employee_ccid
263 FROM
264 hr_employees_current_v EMP
265 WHERE
266 EMP.employee_id = p_employee_id; */
267
268 SELECT DECODE(p.current_npw_flag,'Y',p.npw_number, p.employee_number) employee_number, a.default_code_comb_id,
269 DECODE(p.current_npw_flag,'Y','CWK','EMP') person_type
270 INTO x_employee_number, l_employee_ccid, x_person_type
271 FROM per_people_f p,
272 per_assignments_f a,
273 per_assignment_status_types past
274 WHERE p.person_id = p_employee_id
275 AND p.business_group_id + 0 = (SELECT nvl(max(fsp.business_group_id),0)
276 FROM financials_system_parameters fsp)
277 AND a.person_id = p.person_id
278 AND a.primary_flag = 'Y'
279 AND TRUNC(l_person_effective_date) BETWEEN p.effective_start_date and p.effective_end_date
280 AND TRUNC(l_person_effective_date) BETWEEN a.effective_start_date and a.effective_end_date
281 AND ((p.current_employee_flag = 'Y')
282 OR (p.current_npw_flag = 'Y') )
283 AND a.assignment_type in ('E','C')
284 AND a.assignment_status_type_id = past.assignment_status_type_id
285 AND past.per_system_status IN ('ACTIVE_ASSIGN','SUSP_ASSIGN','ACTIVE_CWK');
286
287 EXCEPTION WHEN no_data_found THEN /* added for bug 6954412 */
288 fnd_message.set_name('PA','PA_NO_ASSIGNMENT');
289 app_exception.raise_exception;
290
291 END;
292
293 IF p_employee_ccid is NULL then
294 p_employee_ccid := l_employee_ccid;
295 END IF;
296
297 END IF;
298
299
300 ---------------------------------------------------------------
301 -- Derive project information
302 ---------------------------------------------------------------
303 g_error_stage := '40';
304
305 pa_acc_gen_wf_pkg.wf_acc_derive_pa_params(
306 p_project_id ,
307 p_task_id ,
308 p_expenditure_type ,
309 p_expenditure_organization_id ,
310 p_expenditure_item_date ,
311 x_class_code ,
312 x_direct_flag ,
313 x_expenditure_category ,
314 x_expenditure_org_name ,
315 x_project_number ,
316 x_project_organization_name ,
317 x_project_organization_id ,
318 x_project_type ,
319 x_public_sector_flag ,
320 x_revenue_category ,
321 x_task_number ,
322 x_task_organization_name ,
323 x_task_organization_id ,
324 x_task_service_type ,
325 x_top_task_id ,
326 x_top_task_number );
327
328 reset_error_stack; /* Bug 5233487 */
329
330 EXCEPTION WHEN others THEN
331 /* Bug 5233487 - Start */
332 IF g_encoded_error_message IS NULL THEN
336 /* Bug 5233487 - End */
333 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
334 END IF;
335 reset_error_stack;
337 g_error_message := SQLERRM;
338 raise;
339
340 END wf_acc_derive_er_params;
341
342 ------------------- End of procedure wf_acc_Derive_er_params ------------------
343
344 ----------------------------------------------------------------------
345 -- Procedure pa_acc_gen_wf_pkg.wf_acc_derive_pa_params
346 -- Definition of package body and function in package specifications
347 ----------------------------------------------------------------------
348
349
350 PROCEDURE wf_acc_derive_pa_params (
351 p_project_id IN pa_projects_all.project_id%TYPE,
352 p_task_id IN pa_tasks.task_id%TYPE,
353 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
354 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
355 p_expenditure_item_date IN pa_expenditure_items_all.expenditure_item_date%TYPE,
356 x_class_code OUT NOCOPY pa_class_codes.class_code%TYPE,
357 x_direct_flag OUT NOCOPY pa_project_types_all.direct_flag%TYPE,
358 x_expenditure_category OUT NOCOPY pa_expenditure_categories.expenditure_category%TYPE,
359 x_expenditure_org_name OUT NOCOPY hr_organization_units.name%TYPE,
360 x_project_number OUT NOCOPY pa_projects_all.segment1%TYPE,
361 x_project_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
362 x_project_organization_id OUT NOCOPY hr_organization_units.organization_id %TYPE,
363 x_project_type OUT NOCOPY pa_project_types_all.project_type%TYPE,
364 x_public_sector_flag OUT NOCOPY pa_projects_all.public_sector_flag%TYPE,
365 x_revenue_category OUT NOCOPY pa_expenditure_types.revenue_category_code%TYPE,
366 x_task_number OUT NOCOPY pa_tasks.task_number%TYPE,
367 x_task_organization_name OUT NOCOPY hr_organization_units.name%TYPE,
368 x_task_organization_id OUT NOCOPY hr_organization_units.organization_id %TYPE,
369 x_task_service_type OUT NOCOPY pa_tasks.service_type_code%TYPE,
370 x_top_task_id OUT NOCOPY pa_tasks.task_id%TYPE,
371 x_top_task_number OUT NOCOPY pa_tasks.task_number%TYPE)
372 AS
373
374 -- l_cbs_enabled varchar2(1); /* Added for bug 16220146 */ commented for bug 16613999
375
376 BEGIN
377 set_error_stack('-->wf_acc_derive_pa_params'); /* Bug 5233487 */
378 g_encoded_error_message := NULL; /* Bug 5233487 */
379 g_error_message := '';
380 g_error_stage := '10';
381 -----------------------------------------------------
382 -- Project id will always be there.
383 -- Get all project-related derived parameters
384
385
386 SELECT
387 PTYPE.direct_flag DIRECT_FLAG,
388 PROJ.segment1 PROJECT_NUMBER,
389 ORG.Name PROJECT_ORGANIZATION_NAME,
390 ORG.Organization_ID PROJECT_ORGANIZATION_ID,
391 PROJ.project_type PROJECT_TYPE,
392 PROJ.public_sector_flag PUBLIC_SECTOR_FLAG
393 -- nvl(cbs_enable_flag,'N') /* Added for bug 16220146 */
394 INTO
395 x_direct_flag,
396 x_project_number,
397 x_project_organization_name,
398 x_project_organization_id,
399 x_project_type,
400 x_public_sector_flag
401 -- l_cbs_enabled /* Added for bug 16220146 */ commented for bug 16613999
402 FROM
403 HR_Organization_Units ORG,
404 PA_Project_Types_all PTYPE,
405 PA_Projects_all PROJ
406 WHERE
407 PROJ.project_id = p_project_id
408 AND ORG.organization_id = PROJ.carrying_out_organization_id
409 AND nvl(PTYPE.org_id,-99) = nvl(PROJ.org_id,-99)
410 AND PTYPE.Project_Type = PROJ.Project_Type;
411
412 ----------------------------------------------------------------
413 -- Derive the expenditure category and revenue category if the
414 -- expenditure type is defined
415 ----------------------------------------------------------------
416 g_error_stage := '20';
417
418 IF p_expenditure_type is not null
419 THEN
420 SELECT
421 ETYPE.Expenditure_Category EXPENDITURE_CATEGORY,
422 ETYPE.revenue_category_code REVENUE_CATEGORY
423 INTO
424 x_expenditure_category,
425 x_revenue_category
426 FROM
427 PA_Expenditure_Types ETYPE
428 WHERE
429 ETYPE.expenditure_type = p_expenditure_type;
430 END IF;
431
432 ----------------------------------------------------------
433 -- Derive the project class code if it exists; otherwise
434 -- set the parameter to null
435 -- Bug 998553: Added clause to select class category row
436 -- valid for sysdate
437 ----------------------------------------------------------
438 g_error_stage := '30';
439
440 BEGIN
441 SELECT a.class_code
442 INTO x_class_code
443 FROM pa_project_classes a,
444 pa_class_categories b
445 WHERE a.project_id = p_project_id
446 AND a.class_category = b.class_category
447 AND b.autoaccounting_flag = 'Y'
448 AND sysdate BETWEEN b.start_date_active
449 AND nvl(b.end_date_active, sysdate);
450
451 EXCEPTION
452 WHEN no_data_found
453 THEN
454 x_class_code := null;
455 END;
456
457 ------------------------------------------------------------
458 -- Derive Expenditure organization name is Expenditure org
459 -- id has been passed
460 ------------------------------------------------------------
461 g_error_stage := '40';
462
463 IF p_expenditure_organization_id IS NOT NULL
464 THEN
465 SELECT ORG.name EXP_ORG_NAME
466 INTO x_expenditure_org_name
467 FROM hr_organization_units ORG
468 WHERE ORG.organization_id = p_expenditure_organization_id;
469 END IF;
470
471 --------------------------------------------------------
472 -- Derive parameters related to the task id if task id
473 -- has been passed
474 --------------------------------------------------------
475 g_error_stage := '50';
476
477 IF p_task_id IS NOT NULL
478 THEN
479
480 -- IF l_cbs_enabled = 'N' THEN /* Added for bug 16220146 */ commented for bug 16613999
481 SELECT
482 TASK.task_number TASK_NUMBER,
483 ORG.Name TASK_ORGANIZATION_NAME,
484 ORG.Organization_id TASK_ORGANIZATION_ID,
485 TASK.Service_Type_Code TASK_SERVICE_TYPE,
486 TOP_TASK.Task_ID TOP_TASK_ID,
487 TOP_TASK.Task_Number TOP_TASK_NUMBER
488 INTO
489 x_task_number,
490 x_task_organization_name,
491 x_task_organization_id,
492 x_task_service_type,
493 x_top_task_id,
494 x_top_task_number
495 FROM
496 HR_Organization_Units ORG,
497 PA_Tasks TOP_TASK,
498 PA_Tasks TASK
499 WHERE
500 TASK.task_id = p_task_id
501 AND ORG.organization_id = TASK.carrying_out_organization_id
502 AND TASK.Top_Task_ID = TOP_TASK.Task_ID;
503 -- Start: commented for bug 16613999
504 -- ELSE /* Added for bug 16220146 */
505 /*
506 SELECT
507 TASK.task_number TASK_NUMBER,
508 ORG.Name TASK_ORGANIZATION_NAME,
509 ORG.Organization_id TASK_ORGANIZATION_ID,
510 TASK.Service_Type_Code TASK_SERVICE_TYPE,
511 TOP_TASK.Task_ID TOP_TASK_ID,
512 TOP_TASK.Task_Number TOP_TASK_NUMBER
513 INTO
514 x_task_number,
515 x_task_organization_name,
516 x_task_organization_id,
517 x_task_service_type,
518 x_top_task_id,
519 x_top_task_number
520 FROM
521 HR_Organization_Units ORG,
522 PA_Tasks TOP_TASK,
523 PA_Tasks TASK,
524 pa_alternate_tasks alt
525 WHERE alt.alt_task_id = p_task_id
526 AND TASK.task_id = alt.proj_element_id
527 AND ORG.organization_id = TASK.carrying_out_organization_id
528 AND TASK.Top_Task_ID = TOP_TASK.Task_ID;
529 */
530 -- END IF; /* Added for bug 16220146 */
531 -- End: commented for bug 16613999
532 END IF;
533
534 reset_error_stack; /* Bug 5233487 */
535
536 EXCEPTION WHEN OTHERS THEN
537 /* Bug 5233487 - Start */
538 IF g_encoded_error_message IS NULL THEN
539 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
540 END IF;
541 reset_error_stack;
542 /* Bug 5233487 - End */
543 g_error_message := SQLERRM;
544 raise;
545 END wf_acc_derive_pa_params;
546
547 ------------------- End of procedure wf_acc_Derive_pa_params -------------------
548
549 ----------------------------------------------------------------------
550 -- Procedure pa_acc_gen_wf_pkg.SetPa_Item_Attr
551 -- Definition of package body and procedure in package specifications
552 ----------------------------------------------------------------------
553 PROCEDURE Set_Pa_Item_Attr
554 (
555 p_itemtype IN VARCHAR2,
556 p_itemkey IN VARCHAR2,
557 p_project_id IN pa_projects_all.project_id%TYPE,
558 p_task_id IN pa_tasks.task_id%TYPE,
559 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
560 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
561 p_expenditure_item_date IN DATE, /* Added For Bug 1629411 */
562 p_billable_flag IN pa_tasks.billable_flag%TYPE,
563 p_class_code IN pa_class_codes.class_code%TYPE,
564 p_direct_flag IN pa_project_types_all.direct_flag%TYPE,
565 p_expenditure_category IN pa_expenditure_categories.expenditure_category%TYPE,
566 p_expenditure_org_name IN hr_organization_units.name%TYPE,
567 p_project_number IN pa_projects_all.segment1%TYPE,
568 p_project_organization_name IN hr_organization_units.name%TYPE,
569 p_project_organization_id IN hr_organization_units.organization_id %TYPE,
570 p_project_type IN pa_project_types_all.project_type%TYPE,
571 p_public_sector_flag IN pa_projects_all.public_sector_flag%TYPE,
572 p_revenue_category IN pa_expenditure_types.revenue_category_code%TYPE,
573 p_task_number IN pa_tasks.task_number%TYPE,
574 p_task_organization_name IN hr_organization_units.name%TYPE,
575 p_task_organization_id IN hr_organization_units.organization_id %TYPE,
576 p_task_service_type IN pa_tasks.service_type_code%TYPE,
577 p_top_task_id IN pa_tasks.task_id%TYPE,
578 p_top_task_number IN pa_tasks.task_number%TYPE) AS
579
580
581
582 BEGIN
583 set_error_stack('-->Set_Pa_Item_Attr'); /* Bug 5233487 */
584 g_encoded_error_message := NULL; /* Bug 5233487 */
585 g_error_message := '';
586 g_error_stage := '10';
587
588 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
589 itemkey => p_itemkey,
590 aname => 'PROJECT_ID',
591 avalue => p_project_id);
592 g_error_stage := '20';
593
594
595 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
596 itemkey => p_itemkey,
597 aname => 'TASK_ID',
598 avalue => p_task_id);
599 g_error_stage := '30';
600
601 wf_engine.SetItemAttrText( itemtype => p_itemtype,
602 itemkey => p_itemkey,
603 aname => 'EXPENDITURE_TYPE',
604 avalue => p_expenditure_type);
605 g_error_stage := '40';
606
607 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
608 itemkey => p_itemkey,
609 aname => 'EXPENDITURE_ORGANIZATION_ID',
610 avalue => p_expenditure_organization_id);
611 g_error_stage := '50';
612
613 wf_engine.SetItemAttrText( itemtype => p_itemtype,
614 itemkey => p_itemkey,
615 aname => 'BILLABLE_FLAG',
616 avalue => p_billable_flag);
617 g_error_stage := '60';
618
619 wf_engine.SetItemAttrText( itemtype => p_itemtype,
620 itemkey => p_itemkey,
621 aname => 'CLASS_CODE',
622 avalue => p_class_code);
623 g_error_stage := '70';
624
625 wf_engine.SetItemAttrText( itemtype => p_itemtype,
626 itemkey => p_itemkey,
627 aname => 'DIRECT_FLAG',
628 avalue => p_direct_flag);
629 g_error_stage := '80';
630
631 wf_engine.SetItemAttrText( itemtype => p_itemtype,
632 itemkey => p_itemkey,
633 aname => 'EXPENDITURE_CATEGORY',
634 avalue => p_expenditure_category);
635 g_error_stage := '90';
636
637 wf_engine.SetItemAttrText( itemtype => p_itemtype,
638 itemkey => p_itemkey,
639 aname => 'EXPENDITURE_ORG_NAME',
640 avalue => p_expenditure_org_name);
641 g_error_stage := '100';
642
643 wf_engine.SetItemAttrText( itemtype => p_itemtype,
644 itemkey => p_itemkey,
645 aname => 'PROJECT_NUMBER',
646 avalue => p_project_number);
647 g_error_stage := '110';
648
649 wf_engine.SetItemAttrText( itemtype => p_itemtype,
650 itemkey => p_itemkey,
651 aname => 'PROJECT_ORGANIZATION_NAME',
652 avalue => p_project_organization_name);
653 g_error_stage := '120';
654
655 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
656 itemkey => p_itemkey,
657 aname => 'PROJECT_ORGANIZATION_ID',
658 avalue => p_project_organization_id);
659 g_error_stage := '130';
660
661 wf_engine.SetItemAttrText( itemtype => p_itemtype,
662 itemkey => p_itemkey,
663 aname => 'PROJECT_TYPE',
664 avalue => p_project_type);
665 g_error_stage := '140';
666
667 wf_engine.SetItemAttrText( itemtype => p_itemtype,
668 itemkey => p_itemkey,
669 aname => 'PUBLIC_SECTOR_FLAG',
670 avalue => p_public_sector_flag);
671 g_error_stage := '150';
672
673 wf_engine.SetItemAttrText( itemtype => p_itemtype,
674 itemkey => p_itemkey,
675 aname => 'REVENUE_CATEGORY',
676 avalue => p_revenue_category);
677 g_error_stage := '160';
678
679 wf_engine.SetItemAttrText( itemtype => p_itemtype,
680 itemkey => p_itemkey,
681 aname => 'TASK_NUMBER',
682 avalue => p_task_number);
683 g_error_stage := '170';
684
685 wf_engine.SetItemAttrText( itemtype => p_itemtype,
686 itemkey => p_itemkey,
687 aname => 'TASK_ORGANIZATION_NAME',
688 avalue => p_task_organization_name);
689 g_error_stage := '180';
690
691 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
692 itemkey => p_itemkey,
693 aname => 'TASK_ORGANIZATION_ID',
694 avalue => p_task_organization_id);
695 g_error_stage := '190';
696
697 wf_engine.SetItemAttrText( itemtype => p_itemtype,
698 itemkey => p_itemkey,
699 aname => 'TASK_SERVICE_TYPE',
700 avalue => p_task_service_type);
701 g_error_stage := '200';
702
703 wf_engine.SetItemAttrNumber( itemtype => p_itemtype,
704 itemkey => p_itemkey,
705 aname => 'TOP_TASK_ID',
706 avalue => p_top_task_id);
707 g_error_stage := '210';
708
709 wf_engine.SetItemAttrText( itemtype => p_itemtype,
710 itemkey => p_itemkey,
711 aname => 'TOP_TASK_NUMBER',
712 avalue => p_top_task_number);
713
714 /* Added for bug 1629411 */
715
716 g_error_stage := '220';
717
718 wf_engine.SetItemAttrText( itemtype => p_itemtype,
719 itemkey => p_itemkey,
720 aname => 'EXPENDITURE_ITEM_DATE',
721 avalue => to_char(p_expenditure_item_date));
722
723 reset_error_stack; /* Bug 5233487 */
724
725 EXCEPTION WHEN OTHERS THEN
726 /* Bug 5233487 - Start */
727 IF g_encoded_error_message IS NULL THEN
728 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
729 END IF;
730 reset_error_stack;
731 /* Bug 5233487 - End */
732 g_error_message := SQLERRM;
733 RAISE;
734 END set_pa_item_attr;
735 ------------------- End pa_acc_gen_wf_pkg.Set_pa_item_attr --------------------
736
737 ----------------------------------------------------------------------
738 -- Procedure pa_acc_gen_wf_pkg.ap_er_generate_account
739 -- Definition of package body and function in package specifications
740 ----------------------------------------------------------------------
741
742 FUNCTION ap_er_generate_account
743 (
744 p_project_id IN pa_projects_all.project_id%TYPE,
745 p_task_id IN pa_tasks.task_id%TYPE,
746 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
747 p_vendor_id IN po_vendors.vendor_id%type,
748 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
749 p_expenditure_item_date IN
750 pa_expenditure_items_all.expenditure_item_date%TYPE,
751 p_billable_flag IN pa_tasks.billable_flag%TYPE,
752 p_chart_of_accounts_id IN NUMBER,
753 p_calling_module IN VARCHAR2,
754 p_employee_id IN per_people_f.person_id%TYPE,
755 p_employee_ccid IN gl_code_combinations.code_combination_id%TYPE,
756 p_expense_type IN ap_expense_report_lines_all.web_parameter_id%TYPE,
757 p_expense_cc IN ap_expense_report_headers_all.flex_concatenated%TYPE,
758 p_attribute_category IN ap_expense_report_headers_all.attribute_category%TYPE,
759 p_attribute1 IN ap_expense_report_headers_all.attribute1%TYPE,
760 p_attribute2 IN ap_expense_report_headers_all.attribute2%TYPE,
761 p_attribute3 IN ap_expense_report_headers_all.attribute3%TYPE,
762 p_attribute4 IN ap_expense_report_headers_all.attribute4%TYPE,
763 p_attribute5 IN ap_expense_report_headers_all.attribute5%TYPE,
764 p_attribute6 IN ap_expense_report_headers_all.attribute6%TYPE,
765 p_attribute7 IN ap_expense_report_headers_all.attribute7%TYPE,
766 p_attribute8 IN ap_expense_report_headers_all.attribute8%TYPE,
767 p_attribute9 IN ap_expense_report_headers_all.attribute9%TYPE,
768 p_attribute10 IN ap_expense_report_headers_all.attribute10%TYPE,
769 p_attribute11 IN ap_expense_report_headers_all.attribute11%TYPE,
770 p_attribute12 IN ap_expense_report_headers_all.attribute12%TYPE,
771 p_attribute13 IN ap_expense_report_headers_all.attribute13%TYPE,
772 p_attribute14 IN ap_expense_report_headers_all.attribute14%TYPE,
773 p_attribute15 IN ap_expense_report_headers_all.attribute15%TYPE,
774 p_line_attribute_category IN ap_expense_report_lines_all.attribute_category%TYPE,
775 p_line_attribute1 IN ap_expense_report_lines_all.attribute1%TYPE,
776 p_line_attribute2 IN ap_expense_report_lines_all.attribute2%TYPE,
777 p_line_attribute3 IN ap_expense_report_lines_all.attribute3%TYPE,
778 p_line_attribute4 IN ap_expense_report_lines_all.attribute4%TYPE,
779 p_line_attribute5 IN ap_expense_report_lines_all.attribute5%TYPE,
780 p_line_attribute6 IN ap_expense_report_lines_all.attribute6%TYPE,
781 p_line_attribute7 IN ap_expense_report_lines_all.attribute7%TYPE,
782 p_line_attribute8 IN ap_expense_report_lines_all.attribute8%TYPE,
783 p_line_attribute9 IN ap_expense_report_lines_all.attribute9%TYPE,
784 p_line_attribute10 IN ap_expense_report_lines_all.attribute10%TYPE,
785 p_line_attribute11 IN ap_expense_report_lines_all.attribute11%TYPE,
786 p_line_attribute12 IN ap_expense_report_lines_all.attribute12%TYPE,
787 p_line_attribute13 IN ap_expense_report_lines_all.attribute13%TYPE,
788 p_line_attribute14 IN ap_expense_report_lines_all.attribute14%TYPE,
789 p_line_attribute15 IN ap_expense_report_lines_all.attribute15%TYPE,
790 p_input_ccid IN gl_code_combinations.code_combination_id%TYPE default null, /* Bug 5378579 */
791 x_return_ccid OUT NOCOPY gl_code_combinations.code_combination_id%TYPE,
792 x_concat_segs IN OUT NOCOPY VARCHAR2, -- Bug 5935019
793 x_concat_ids IN OUT NOCOPY VARCHAR2, -- Bug 5935019
794 x_concat_descrs IN OUT NOCOPY VARCHAR2, -- Bug 5935019
795 x_error_message OUT NOCOPY VARCHAR2,
796 /* R12 Changes Start - Added two new parameters Award_Id and Expenditure Item ID */
797 X_award_set_id IN NUMBER DEFAULT NULL,
798 p_award_id IN NUMBER DEFAULT NULL,
799 p_expenditure_item_id IN NUMBER DEFAULT NULL )
800 /* R12 Changes End */
801 RETURN BOOLEAN IS
802
803 l_itemtype CONSTANT VARCHAR2(30) := 'PAAPWEBX';
804 l_itemkey VARCHAR2(30);
805 l_result BOOLEAN;
806 l_concat_segs VARCHAR2(200);
810 l_employee_ccid gl_code_combinations.code_combination_id%TYPE;
807 l_concat_ids VARCHAR2(200);
808 l_concat_descrs VARCHAR2(500);
809 l_return_ccid gl_code_combinations.code_combination_id%TYPE;
811 l_class_code pa_class_codes.class_code%TYPE;
812 l_direct_flag pa_project_types_all.direct_flag%TYPE;
813 l_expenditure_category pa_expenditure_categories.expenditure_category%TYPE;
814 l_expenditure_organization_id hr_organization_units.organization_id%TYPE;
815 l_expenditure_org_name hr_organization_units.name%TYPE;
816 l_project_number pa_projects_all.segment1%TYPE;
817 l_project_organization_name hr_organization_units.name%TYPE;
818 l_project_organization_id hr_organization_units.organization_id %TYPE;
819 l_project_type pa_project_types_all.project_type%TYPE;
820 l_public_sector_flag pa_projects_all.public_sector_flag%TYPE;
821 l_revenue_category pa_expenditure_types.revenue_category_code%TYPE;
822 l_task_number pa_tasks.task_number%TYPE;
823 l_task_organization_name hr_organization_units.name%TYPE;
824 l_task_organization_id hr_organization_units.organization_id %TYPE;
825 l_task_service_type pa_tasks.service_type_code%TYPE;
826 l_top_task_id pa_tasks.task_id%TYPE;
827 l_top_task_number pa_tasks.task_number%TYPE;
828 l_employee_number per_people_f.employee_number%TYPE;
829 l_vendor_type po_vendors.vendor_type_lookup_code%TYPE;
830 l_error_message VARCHAR2(1000) := '';
831 l_org_id hr_organization_units.organization_id %TYPE; -- Workflow Enhancement
832
833 l_code_combination BOOLEAN;
834 l_person_type VARCHAR2(10);
835
836 /* R12 Changes Start */
837 /* Local variable used to set WF AWARD ID attribute */
838 l_award_id NUMBER;
839 /* R12 Changes End */
840
841 l_input_ccid gl_code_combinations.code_combination_id%TYPE; /* Bug 5378579 */
842
843 -- Start: Added for bug 16613999
844 l_task_id pa_tasks.task_id%TYPE;
845 l_task_count NUMBER := 0;
846 -- End: Added for bug 16613999
847
848 BEGIN
849 ---------------------------------------------------------------
850 -- Derive Organization id if employee id is present and
851 -- organization id is null
852 ---------------------------------------------------------------
853 set_error_stack('-->pa_acc_gen_wf_pkg.ap_er_generate_account'); /* Bug 5233487 */
854 g_encoded_error_message := NULL; /* Bug 5233487 */
855 g_error_stage := '10';
856 g_error_message := '';
857
858 -- Start: Added for bug 16613999
859 select count(*) into l_task_count
860 from pa_tasks
861 where project_id = p_project_id
862 and task_id = p_task_id;
863
864 IF l_task_count <> 0 THEN
865 l_task_id := p_task_id;
866 ELSE
867 BEGIN
868 select proj_element_id into l_task_id
869 from pa_alternate_tasks
870 where alt_task_id = p_task_id;
871 EXCEPTION
872 WHEN OTHERS THEN
873 l_task_id := p_task_id;
874 END;
875 END IF;
876 -- End: Added for bug 16613999
877
878 IF p_expenditure_organization_id IS NULL
879 THEN
880 IF p_employee_id IS NOT NULL
881 THEN
882 l_expenditure_organization_id := pa_utils.GetEmpOrgId(p_employee_id,
883 nvl(p_expenditure_item_date,sysdate));
884 END IF;
885 ELSE
886 l_expenditure_organization_id := p_expenditure_organization_id;
887 END IF;
888 ---------------------------------------------------------------------
889 -- Call the procedure to obtain the derived parameters from the raw
890 -- parameters
891 ---------------------------------------------------------------------
892 g_error_stage := '20';
893 l_employee_ccid := p_employee_ccid;
894
895 pa_acc_gen_wf_pkg.wf_acc_derive_er_params
896 (
897 p_project_id => p_project_id,
898 p_task_id => l_task_id, -- Modified for bug 16613999
899 p_expenditure_type => p_expenditure_type,
900 p_vendor_id => p_vendor_id,
901 p_expenditure_organization_id => l_expenditure_organization_id,
902 p_expenditure_item_date => p_expenditure_item_date,
903 p_calling_module => p_calling_module,
904 p_employee_id => p_employee_id,
905 p_employee_ccid => l_employee_ccid,
906 p_expense_type => p_expense_type,
907 p_expense_cc => p_expense_cc,
908 x_class_code => l_class_code,
909 x_direct_flag => l_direct_flag,
910 x_expenditure_category => l_expenditure_category,
911 x_expenditure_org_name => l_expenditure_org_name,
912 x_project_number => l_project_number,
913 x_project_organization_name => l_project_organization_name,
914 x_project_organization_id => l_project_organization_id,
915 x_project_type => l_project_type,
916 x_public_sector_flag => l_public_sector_flag,
917 x_revenue_category => l_revenue_category,
918 x_task_number => l_task_number,
919 x_task_organization_name => l_task_organization_name,
920 x_task_organization_id => l_task_organization_id,
921 x_task_service_type => l_task_service_type,
922 x_top_task_id => l_top_task_id,
923 x_top_task_number => l_top_task_number,
924 x_employee_number => l_employee_number,
925 x_vendor_type => l_vendor_type,
926 x_person_type => l_person_type);
927
928 -------------------------------------
929 -- Call the FND initialize function
930 -------------------------------------
931 g_error_stage := '30';
932
933 l_itemkey := fnd_flex_workflow.initialize
934 (appl_short_name => 'SQLGL',
935 code => 'GL#',
936 num => p_chart_of_accounts_id,
937 itemtype =>l_itemtype);
938
939 ---------------------------------------------
940 -- Initialize the workflow item attributes
941 ---------------------------------------------
942 g_error_stage := '40';
943
944 pa_acc_gen_wf_pkg.Set_Pa_Item_Attr(
945 p_itemtype => l_itemtype,
946 p_itemkey => l_itemkey,
947 p_project_id => p_project_id,
948 p_task_id => l_task_id, -- Modified for bug 16613999
949 p_expenditure_type => p_expenditure_type,
950 p_expenditure_organization_id => l_expenditure_organization_id,
951 p_expenditure_item_date => p_expenditure_item_date,
952 p_billable_flag => p_billable_flag,
953 p_class_code => l_class_code,
954 p_direct_flag => l_direct_flag,
955 p_expenditure_category => l_expenditure_category,
956 p_expenditure_org_name => l_expenditure_org_name,
957 p_project_number => l_project_number,
958 p_project_organization_name => l_project_organization_name,
959 p_project_organization_id => l_project_organization_id,
960 p_project_type => l_project_type,
961 p_public_sector_flag => l_public_sector_flag,
962 p_revenue_category => l_revenue_category,
963 p_task_number => l_task_number,
964 p_task_organization_name => l_task_organization_name,
965 p_task_organization_id => l_task_organization_id,
966 p_task_service_type => l_task_service_type,
967 p_top_task_id => l_top_task_id,
968 p_top_task_number => l_top_task_number);
969
970 g_error_stage := '50';
971
972 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
973 itemkey => l_itemkey,
974 aname => 'VENDOR_ID',
975 avalue => p_vendor_id);
976
977 /* R12 Changes Start - Commented for R12; workflow will use award id instead
978 of award set id
979 g_error_stage := '55';
980 -- ---------------------------------------------------------------
981 -- OGM_0.0 : Vertical application OGM may use award_set_id to
982 -- derive award_id, which can be used to derive segments for
983 -- the account generator.
984 -- ---------------------------------------------------------------
985 IF x_award_set_id is not NULL THEN
986 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
987 itemkey => l_itemkey,
988 aname => 'AWARD_SET_ID',
989 avalue => x_award_set_id);
990 END IF ;
991 R12 Changes End */
992
993 g_error_stage := '60';
994
995 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
996 itemkey => l_itemkey,
997 aname => 'EMPLOYEE_ID',
998 avalue => p_employee_id);
999 g_error_stage := '70';
1000
1001 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1002 itemkey => l_itemkey,
1003 aname => 'EMPLOYEE_NUMBER',
1004 avalue => l_employee_number);
1005
1006 g_error_stage := '71';
1007
1008 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1009 itemkey => l_itemkey,
1010 aname => 'PERSON_TYPE',
1011 avalue => l_person_type);
1012
1013 g_error_stage := '80';
1014
1015 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1016 itemkey => l_itemkey,
1017 aname => 'VENDOR_TYPE',
1018 avalue => l_vendor_type);
1019 g_error_stage := '90';
1020
1021 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1022 itemkey => l_itemkey,
1023 aname => 'CHART_OF_ACCOUNTS_ID',
1024 avalue => p_chart_of_accounts_id);
1025 g_error_stage := '100';
1026
1027 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1028 itemkey => l_itemkey,
1029 aname => 'CALLING_MODULE',
1030 avalue => p_calling_module);
1031 g_error_stage := '110';
1032
1033 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1034 itemkey => l_itemkey,
1035 aname => 'EMPLOYEE_CCID',
1036 avalue => l_employee_ccid);
1037 g_error_stage := '120';
1038
1039 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1043 g_error_stage := '130';
1040 itemkey => l_itemkey,
1041 aname => 'EXPENSE_TYPE',
1042 avalue => p_expense_type);
1044
1045 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1046 itemkey => l_itemkey,
1047 aname => 'EXPENSE_CC',
1048 avalue => p_expense_cc);
1049 g_error_stage := '140';
1050
1051 IF p_attribute_category IS NOT NULL
1052 THEN
1053 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1054 itemkey => l_itemkey,
1055 aname => 'ATTRIBUTE_CATEGORY',
1056 avalue => p_attribute_category);
1057 END IF;
1058
1059 g_error_stage := '150';
1060
1061 IF p_attribute1 IS NOT NULL
1062 THEN
1063 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1064 itemkey => l_itemkey,
1065 aname => 'ATTRIBUTE1',
1066 avalue => p_attribute1);
1067 END IF;
1068
1069 g_error_stage := '160';
1070
1071 IF p_attribute2 IS NOT NULL
1072 THEN
1073 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1074 itemkey => l_itemkey,
1075 aname => 'ATTRIBUTE2',
1076 avalue => p_attribute2);
1077 END IF;
1078
1079
1080 g_error_stage := '170';
1081
1082 IF p_attribute3 IS NOT NULL
1083 THEN
1084 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1085 itemkey => l_itemkey,
1086 aname => 'ATTRIBUTE3',
1087 avalue => p_attribute3);
1088 END IF;
1089
1090 g_error_stage := '180';
1091
1092 IF p_attribute4 IS NOT NULL
1093 THEN
1094 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1095 itemkey => l_itemkey,
1096 aname => 'ATTRIBUTE4',
1097 avalue => p_attribute4);
1098 END IF;
1099
1100 g_error_stage := '190';
1101
1102 IF p_attribute5 IS NOT NULL
1103 THEN
1104 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1105 itemkey => l_itemkey,
1106 aname => 'ATTRIBUTE5',
1107 avalue => p_attribute5);
1108 END IF;
1109
1110 g_error_stage := '200';
1111
1112 IF p_attribute6 IS NOT NULL
1113 THEN
1114 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1115 itemkey => l_itemkey,
1116 aname => 'ATTRIBUTE6',
1117 avalue => p_attribute6);
1118 END IF;
1119
1120 g_error_stage := '210';
1121
1122 IF p_attribute7 IS NOT NULL
1123 THEN
1124 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1125 itemkey => l_itemkey,
1126 aname => 'ATTRIBUTE7',
1127 avalue => p_attribute7);
1128 END IF;
1129 g_error_stage := '220';
1130
1131 IF p_attribute8 IS NOT NULL
1132 THEN
1133 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1134 itemkey => l_itemkey,
1135 aname => 'ATTRIBUTE8',
1136 avalue => p_attribute8);
1137 END IF;
1138 g_error_stage := '230';
1139
1140 IF p_attribute9 IS NOT NULL
1141 THEN
1142 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1143 itemkey => l_itemkey,
1144 aname => 'ATTRIBUTE9',
1145 avalue => p_attribute9);
1146 END IF;
1147 g_error_stage := '240';
1148
1149 IF p_attribute10 IS NOT NULL
1150 THEN
1151 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1152 itemkey => l_itemkey,
1153 aname => 'ATTRIBUTE10',
1154 avalue => p_attribute10);
1155 END IF;
1156 g_error_stage := '250';
1157
1158 IF p_attribute11 IS NOT NULL
1159 THEN
1160 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1161 itemkey => l_itemkey,
1162 aname => 'ATTRIBUTE11',
1163 avalue => p_attribute11);
1164 END IF;
1165 g_error_stage := '260';
1166
1167 IF p_attribute12 IS NOT NULL
1168 THEN
1169 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1170 itemkey => l_itemkey,
1171 aname => 'ATTRIBUTE12',
1172 avalue => p_attribute12);
1173 END IF;
1174 g_error_stage := '270';
1175
1176 IF p_attribute13 IS NOT NULL
1177 THEN
1178 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1179 itemkey => l_itemkey,
1180 aname => 'ATTRIBUTE13',
1181 avalue => p_attribute13);
1182 END IF;
1183 g_error_stage := '280';
1184
1185 IF p_attribute14 IS NOT NULL
1186 THEN
1187 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1188 itemkey => l_itemkey,
1189 aname => 'ATTRIBUTE14',
1190 avalue => p_attribute14);
1191 END IF;
1192 g_error_stage := '290';
1193
1194 IF p_attribute15 IS NOT NULL
1195 THEN
1196 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1197 itemkey => l_itemkey,
1198 aname => 'ATTRIBUTE15',
1199 avalue => p_attribute15);
1200 END IF;
1201 g_error_stage := '300';
1202
1203 IF p_line_attribute1 IS NOT NULL
1204 THEN
1205 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1206 itemkey => l_itemkey,
1207 aname => 'LINE_ATTRIBUTE1',
1208 avalue => p_line_attribute1);
1209
1210 END IF;
1211 g_error_stage := '310';
1212
1213 IF p_line_attribute2 IS NOT NULL
1214 THEN
1215 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1216 itemkey => l_itemkey,
1217 aname => 'LINE_ATTRIBUTE2',
1218 avalue => p_line_attribute2);
1219
1220 END IF;
1221 g_error_stage := '320';
1222
1223 IF p_line_attribute3 IS NOT NULL
1224 THEN
1225 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1226 itemkey => l_itemkey,
1227 aname => 'LINE_ATTRIBUTE3',
1228 avalue => p_line_attribute3);
1229
1230 END IF;
1231 g_error_stage := '330';
1232
1233 IF p_line_attribute4 IS NOT NULL
1234 THEN
1235 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1236 itemkey => l_itemkey,
1237 aname => 'LINE_ATTRIBUTE4',
1238 avalue => p_line_attribute4);
1239
1240 END IF;
1241 g_error_stage := '340';
1242
1243 IF p_line_attribute5 IS NOT NULL
1244 THEN
1245 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1246 itemkey => l_itemkey,
1247 aname => 'LINE_ATTRIBUTE5',
1248 avalue => p_line_attribute5);
1249
1250 END IF;
1251 g_error_stage := '350';
1252
1253 IF p_line_attribute6 IS NOT NULL
1254 THEN
1255 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1256 itemkey => l_itemkey,
1257 aname => 'LINE_ATTRIBUTE6',
1258 avalue => p_line_attribute6);
1259
1260 END IF;
1261 g_error_stage := '360';
1262
1263 IF p_line_attribute7 IS NOT NULL
1264 THEN
1265 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1266 itemkey => l_itemkey,
1267 aname => 'LINE_ATTRIBUTE7',
1268 avalue => p_line_attribute7);
1269
1270 END IF;
1271 g_error_stage := '370';
1272
1273 IF p_line_attribute8 IS NOT NULL
1274 THEN
1275 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1276 itemkey => l_itemkey,
1277 aname => 'LINE_ATTRIBUTE8',
1278 avalue => p_line_attribute8);
1279
1280 END IF;
1281 g_error_stage := '380';
1282
1283 IF p_line_attribute9 IS NOT NULL
1284 THEN
1285 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1286 itemkey => l_itemkey,
1287 aname => 'LINE_ATTRIBUTE9',
1288 avalue => p_line_attribute9);
1289
1290 END IF;
1291 g_error_stage := '390';
1292
1293 IF p_line_attribute10 IS NOT NULL
1294 THEN
1295 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1296 itemkey => l_itemkey,
1297 aname => 'LINE_ATTRIBUTE10',
1298 avalue => p_line_attribute10);
1299
1300 END IF;
1301 g_error_stage := '400';
1302
1303 IF p_line_attribute11 IS NOT NULL
1304 THEN
1305 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1306 itemkey => l_itemkey,
1307 aname => 'LINE_ATTRIBUTE11',
1308 avalue => p_line_attribute11);
1309
1310 END IF;
1311 g_error_stage := '410';
1312
1313 IF p_line_attribute12 IS NOT NULL
1314 THEN
1315 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1316 itemkey => l_itemkey,
1317 aname => 'LINE_ATTRIBUTE12',
1318 avalue => p_line_attribute12);
1319
1320 END IF;
1321 g_error_stage := '420';
1322
1323 IF p_line_attribute13 IS NOT NULL
1324 THEN
1325 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1326 itemkey => l_itemkey,
1327 aname => 'LINE_ATTRIBUTE13',
1328 avalue => p_line_attribute13);
1329
1330 END IF;
1331 g_error_stage := '430';
1332
1333 IF p_line_attribute14 IS NOT NULL
1334 THEN
1335 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1336 itemkey => l_itemkey,
1337 aname => 'LINE_ATTRIBUTE14',
1338 avalue => p_line_attribute14);
1339
1340 END IF;
1341 g_error_stage := '440';
1342
1343 IF p_line_attribute15 IS NOT NULL
1344 THEN
1345 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1346 itemkey => l_itemkey,
1347 aname => 'LINE_ATTRIBUTE15',
1348 avalue => p_line_attribute15);
1349
1350 END IF;
1351 g_error_stage := '450';
1352
1353 IF p_line_attribute_category IS NOT NULL
1354 THEN
1355 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1356 itemkey => l_itemkey,
1357 aname => 'LINE_ATTRIBUTE_CATEGORY',
1358 avalue => p_line_attribute_category);
1359 END IF;
1360
1361 --- Following section has been added as a part of enhancement request where
1362 --- Users can have workflow(PAAPINVW) setup accross orgs.
1363 --- Workflow Enhancement
1364
1365 BEGIN
1366 IF g_invoice_id IS NOT NULL THEN -- bug 13875781 start
1367 SELECT org_id
1368 INTO l_org_id
1369 FROM AP_INVOICES_ALL
1370 WHERE invoice_id = g_invoice_id;
1371 ELSE -- bug 13875781 end
1372 SELECT org_id
1373 INTO l_org_id
1374 FROM PA_IMPLEMENTATIONS;
1375 END IF; -- Added for bug 13875781
1376 END;
1377
1378 g_error_stage := '451';
1379
1380 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1381 itemkey => l_itemkey,
1382 aname => 'ORG_ID',
1383 avalue => l_org_id);
1384
1385 /* Bug 5935019 - Changes start */
1386 -- We cannot directly assign this to attribute
1387 -- 'FND_FLEX_SEGMENTS' as workflow will take care of this.
1388 IF x_concat_segs IS NOT NULL THEN
1389 g_error_stage := '382';
1390
1391 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1392 itemkey => l_itemkey,
1393 aname => 'CONCAT_SEGMENTS',
1394 avalue => x_concat_segs);
1395 END IF;
1396 /* Bug 5935019 - Changes end */
1397
1398 /* R12 Changes Start - Setting attributes Award ID and Expenditure Item ID
1399 for Workflow */
1400 g_error_stage := '452';
1401
1402 IF x_award_set_id IS NOT NULL THEN
1403
1404 l_award_id := PA_GMS_API.VERT_GET_AWARD_ID(x_award_set_id,NULL,NULL);
1405
1406 ELSE
1407
1408 l_award_id := p_award_id;
1409
1410 END IF;
1411
1412 IF l_award_id IS NOT NULL THEN
1413
1414 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1415 itemkey => l_itemkey,
1416 aname => 'AWARD_ID',
1417 avalue => l_award_id);
1418
1419 END IF;
1420
1421 g_error_stage := '453';
1422
1423 IF p_expenditure_item_id IS NOT NULL THEN
1424
1425 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1426 itemkey => l_itemkey,
1427 aname => 'EXPENDITURE_ITEM_ID',
1428 avalue => p_expenditure_item_id);
1429
1430 END IF;
1431 /* R12 Changes End */
1432
1433 /* Bug 5378579 - Start */
1434 g_error_stage := '454';
1435
1436 IF p_input_ccid IS NULL THEN
1437 l_input_ccid := 0;
1438 ELSE
1439 l_input_ccid := p_input_ccid;
1440 END IF;
1441
1442 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1443 itemkey => l_itemkey,
1444 aname => 'DIST_CODE_COMBINATION_ID',
1445 avalue => l_input_ccid);
1446 /* Bug 5378579 - End */
1447
1448 -----------------------------------------------------------
1449 -- Call the workflow Generate function to trigger off the
1450 -- workflow account generation
1451 -----------------------------------------------------------
1452 g_error_stage := '460';
1453
1454 l_result := fnd_flex_workflow.generate( l_itemtype,
1455 l_itemkey,
1456 TRUE,
1457 l_return_ccid,
1458 x_concat_segs, -- Bug 5935019
1459 x_concat_ids, -- Bug 5935019
1460 x_concat_descrs, -- Bug 5935019
1461 l_error_message,
1462 l_code_combination);
1463
1464 ---Added this section for Workflow error handling.
1465 -- Workflow Enhancement
1466 /* IF (l_result and ( l_return_ccid is null or l_return_ccid = 0 or l_return_ccid = -1 )) OR
1467 (NOT l_result) THEN ** commenting this out for bug 2802847 */
1468
1469 /* Added the check for l_error_message for bug 2694601 */
1470 IF l_error_message is null THEN
1471 fnd_message.set_name('PA','PA_WF_SETUP_ERROR');
1472 x_error_message := fnd_message.get_encoded;
1473 ELSE
1474 x_error_message := l_error_message;
1475 END IF;
1476 /* 2694601 */
1477
1478 /* return(FALSE);
1479 END IF; ** bug 2802847 */
1480
1481 ------------------------------------------------------------------
1482 -- Copy the return values to the corresponding output parameters
1483 ------------------------------------------------------------------
1484 /* Bug 5935019 - Changes start -- commented 3 lines
1485 x_concat_segs := l_concat_segs;
1486 x_concat_ids := l_concat_ids;
1487 x_concat_descrs:= l_concat_descrs;
1488 Bug 5935019 - Changes start */
1489 -- x_error_message:= l_error_message; bug 2802847
1490 x_return_ccid := l_return_ccid;
1491
1492 -------------------------------------------------------------------
1493 -- Reset the error stack.
1494 -------------------------------------------------------------------
1495
1496 reset_error_stack;
1497
1498 --------------------------------------------------------------------
1499 -- Return the return value of the Generate function as the return
1500 -- value for the process
1501 --------------------------------------------------------------------
1502
1503 RETURN l_result;
1504
1505 EXCEPTION
1506
1507 WHEN OTHERS
1508 THEN
1509
1510 -----------------------------------------------------------------------
1511 -- Record error using generic error message routine for debugging and
1512 -- raise it
1513 -----------------------------------------------------------------------
1514 /* Bug 5233487 - Start */
1515 IF g_encoded_error_message IS NULL THEN
1516 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
1517 END IF;
1518 x_error_message := g_encoded_error_message;
1519 reset_error_stack;
1520 /* Bug 5233487 - End */
1521
1522 wf_core.context( pkg_name => 'pa_acc_gen_wf_pkg',
1523 proc_name => 'ap_er_generate_account',
1524 arg1 => 'Project id: '||p_project_id,
1525 arg2 => 'Task id: '||l_task_id, -- Modified for bug 16613999
1526 arg3 => 'Vendor id: '||p_vendor_id,
1527 arg4 => 'Exp type: '||p_expenditure_type,
1528 arg5 => 'Exp Org id: '||p_expenditure_organization_id);
1529
1530 RETURN FALSE;
1531
1532 END ap_er_generate_account;
1533
1534 ----------------------------------------------------------------------
1535 -- Procedure pa_acc_gen_wf_pkg.ap_inv_generate_account
1536 -- Definition of package body and function in package specifications
1537 ----------------------------------------------------------------------
1538
1539 FUNCTION ap_inv_generate_account
1540 (
1541 p_project_id IN pa_projects_all.project_id%TYPE,
1542 p_task_id IN pa_tasks.task_id%TYPE,
1543 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
1544 p_vendor_id IN po_vendors.vendor_id%type,
1545 p_expenditure_organization_id IN hr_organization_units.organization_id%TYPE,
1546 p_expenditure_item_date IN
1547 pa_expenditure_items_all.expenditure_item_date%TYPE,
1548 p_billable_flag IN pa_tasks.billable_flag%TYPE,
1549 p_chart_of_accounts_id IN NUMBER,
1550 p_attribute_category IN ap_invoices_all.attribute_category%TYPE,
1551 p_attribute1 IN ap_invoices_all.attribute1%TYPE,
1552 p_attribute2 IN ap_invoices_all.attribute2%TYPE,
1553 p_attribute3 IN ap_invoices_all.attribute3%TYPE,
1554 p_attribute4 IN ap_invoices_all.attribute4%TYPE,
1555 p_attribute5 IN ap_invoices_all.attribute5%TYPE,
1556 p_attribute6 IN ap_invoices_all.attribute6%TYPE,
1557 p_attribute7 IN ap_invoices_all.attribute7%TYPE,
1558 p_attribute8 IN ap_invoices_all.attribute8%TYPE,
1559 p_attribute9 IN ap_invoices_all.attribute9%TYPE,
1560 p_attribute10 IN ap_invoices_all.attribute10%TYPE,
1561 p_attribute11 IN ap_invoices_all.attribute11%TYPE,
1562 p_attribute12 IN ap_invoices_all.attribute12%TYPE,
1563 p_attribute13 IN ap_invoices_all.attribute13%TYPE,
1564 p_attribute14 IN ap_invoices_all.attribute14%TYPE,
1565 p_attribute15 IN ap_invoices_all.attribute15%TYPE,
1566 p_dist_attribute_category IN
1567 ap_invoice_distributions_all.attribute_category%TYPE,
1568 p_dist_attribute1 IN ap_invoice_distributions_all.attribute1%TYPE,
1569 p_dist_attribute2 IN ap_invoice_distributions_all.attribute2%TYPE,
1570 p_dist_attribute3 IN ap_invoice_distributions_all.attribute3%TYPE,
1571 p_dist_attribute4 IN ap_invoice_distributions_all.attribute4%TYPE,
1572 p_dist_attribute5 IN ap_invoice_distributions_all.attribute5%TYPE,
1573 p_dist_attribute6 IN ap_invoice_distributions_all.attribute6%TYPE,
1574 p_dist_attribute7 IN ap_invoice_distributions_all.attribute7%TYPE,
1575 p_dist_attribute8 IN ap_invoice_distributions_all.attribute8%TYPE,
1576 p_dist_attribute9 IN ap_invoice_distributions_all.attribute9%TYPE,
1577 p_dist_attribute10 IN ap_invoice_distributions_all.attribute10%TYPE,
1578 p_dist_attribute11 IN ap_invoice_distributions_all.attribute11%TYPE,
1579 p_dist_attribute12 IN ap_invoice_distributions_all.attribute12%TYPE,
1580 p_dist_attribute13 IN ap_invoice_distributions_all.attribute13%TYPE,
1581 p_dist_attribute14 IN ap_invoice_distributions_all.attribute14%TYPE,
1582 p_dist_attribute15 IN ap_invoice_distributions_all.attribute15%TYPE,
1583 /* Adding parameter p_input_ccid for bug 2348764 */
1584 p_input_ccid IN gl_code_combinations.code_combination_id%TYPE default NULL,
1585 x_return_ccid OUT NOCOPY gl_code_combinations.code_combination_id%TYPE,
1586 x_concat_segs IN OUT NOCOPY VARCHAR2, -- Bug 5935019
1587 x_concat_ids IN OUT NOCOPY VARCHAR2, -- Bug 5935019
1588 x_concat_descrs IN OUT NOCOPY VARCHAR2, -- Bug 5935019
1589 x_error_message OUT NOCOPY VARCHAR2,
1590 X_award_set_id IN NUMBER DEFAULT NULL,
1591 /* R12 Changes Start - Added two new parameters Award_Id and Expenditure Item ID */
1592 p_accounting_date IN ap_invoice_distributions_all.accounting_date%TYPE default NULL,
1593 p_award_id IN NUMBER DEFAULT NULL,
1594 p_expenditure_item_id IN NUMBER DEFAULT NULL )
1595 /* R12 Changes End */
1596
1597 RETURN BOOLEAN IS
1598 l_itemtype CONSTANT VARCHAR2(30) := 'PAAPINVW';
1599 l_itemkey VARCHAR2(30);
1600 l_result BOOLEAN;
1601 l_concat_segs VARCHAR2(200);
1602 l_concat_ids VARCHAR2(200);
1603 l_concat_descrs VARCHAR2(500);
1604 /* Adding parameter l_input_ccid for bug 2348764 */
1605 l_input_ccid gl_code_combinations.code_combination_id%TYPE;
1606 l_return_ccid gl_code_combinations.code_combination_id%TYPE;
1607 l_class_code pa_class_codes.class_code%TYPE;
1608 l_direct_flag pa_project_types_all.direct_flag%TYPE;
1609 l_expenditure_category pa_expenditure_categories.expenditure_category%TYPE;
1610 l_expenditure_org_name hr_organization_units.name%TYPE;
1611 l_project_number pa_projects_all.segment1%TYPE;
1612 l_project_organization_name hr_organization_units.name%TYPE;
1613 l_project_organization_id hr_organization_units.organization_id %TYPE;
1614 l_project_type pa_project_types_all.project_type%TYPE;
1615 l_public_sector_flag pa_projects_all.public_sector_flag%TYPE;
1616 l_revenue_category pa_expenditure_types.revenue_category_code%TYPE;
1617 l_task_number pa_tasks.task_number%TYPE;
1618 l_task_organization_name hr_organization_units.name%TYPE;
1619 l_task_organization_id hr_organization_units.organization_id %TYPE;
1620 l_task_service_type pa_tasks.service_type_code%TYPE;
1621 l_top_task_id pa_tasks.task_id%TYPE;
1622 l_top_task_number pa_tasks.task_number%TYPE;
1623 l_vendor_employee_id per_people_f.person_id%TYPE;
1624 l_vendor_employee_number per_people_f.employee_number%TYPE;
1625 l_vendor_type po_vendors.vendor_type_lookup_code%TYPE;
1626 l_error_message VARCHAR2(1000) :='';
1627 l_accounting_date DATE;
1628 l_org_id hr_organization_units.organization_id %TYPE; -- Workflow Enhancement
1629
1630 l_code_combination BOOLEAN;
1631
1632 -- Start: Added for bug 16613999
1633 l_task_id pa_tasks.task_id%TYPE;
1634 l_task_count NUMBER := 0;
1635 -- End: Added for bug 16613999
1636
1637 /* R12 Changes Start */
1638 /* Local variable used to set WF AWARD ID attribute */
1639 l_award_id NUMBER;
1640 /* R12 Changes End */
1641
1642 BEGIN
1643 ---------------------------------------------------------------------
1644 -- Call the procedure to obtain the derived parameters from the raw
1645 -- parameters
1646 ---------------------------------------------------------------------
1647 set_error_stack('-->pa_acc_gen_wf_pkg.ap_inv_generate_account'); /* Bug 5233487 */
1648 g_encoded_error_message := NULL; /* Bug 5233487 */
1649 g_error_stage := '10';
1650 g_error_message := '';
1651
1652 -- Start: Added for bug 16613999
1653 select count(*) into l_task_count
1654 from pa_tasks
1655 where project_id = p_project_id
1656 and task_id = p_task_id;
1657
1658 IF l_task_count <> 0 THEN
1659 l_task_id := p_task_id;
1660 ELSE
1661 BEGIN
1662 select proj_element_id into l_task_id
1663 from pa_alternate_tasks
1664 where alt_task_id = p_task_id;
1665 EXCEPTION
1666 WHEN OTHERS THEN
1667 l_task_id := p_task_id;
1668 END;
1669 END IF;
1670 -- End: Added for bug 16613999
1671
1672 pa_acc_gen_wf_pkg.wf_acc_derive_params
1673 (
1674 p_project_id => p_project_id,
1675 p_task_id => l_task_id, -- Modified for bug 16613999
1676 p_expenditure_type => p_expenditure_type,
1677 p_vendor_id => p_vendor_id,
1678 p_expenditure_organization_id => p_expenditure_organization_id,
1679 p_expenditure_item_date => p_expenditure_item_date,
1680 x_class_code => l_class_code,
1681 x_direct_flag => l_direct_flag,
1682 x_expenditure_category => l_expenditure_category,
1683 x_expenditure_org_name => l_expenditure_org_name,
1684 x_project_number => l_project_number,
1685 x_project_organization_name => l_project_organization_name,
1686 x_project_organization_id => l_project_organization_id,
1687 x_project_type => l_project_type,
1688 x_public_sector_flag => l_public_sector_flag,
1689 x_revenue_category => l_revenue_category,
1690 x_task_number => l_task_number,
1691 x_task_organization_name => l_task_organization_name,
1692 x_task_organization_id => l_task_organization_id,
1693 x_task_service_type => l_task_service_type,
1694 x_top_task_id => l_top_task_id,
1695 x_top_task_number => l_top_task_number,
1696 x_vendor_employee_id => l_vendor_employee_id,
1697 x_vendor_employee_number => l_vendor_employee_number,
1698 x_vendor_type => l_vendor_type);
1699
1700 -------------------------------------
1701 -- Call the FND initialize function
1702 -------------------------------------
1703 g_error_stage := '20';
1704
1705 l_itemkey := fnd_flex_workflow.initialize
1706 (appl_short_name => 'SQLGL',
1707 code => 'GL#',
1708 num => p_chart_of_accounts_id,
1709 itemtype =>l_itemtype);
1710
1711 ---------------------------------------------
1712 -- Initialize the workflow item attributes
1713 ---------------------------------------------
1714 g_error_stage := '30';
1715
1716 pa_acc_gen_wf_pkg.Set_Pa_Item_Attr(
1717 p_itemtype => l_itemtype,
1718 p_itemkey => l_itemkey,
1719 p_project_id => p_project_id,
1720 p_task_id => l_task_id, -- Modified for bug 16613999
1721 p_expenditure_type => p_expenditure_type,
1722 p_expenditure_organization_id => p_expenditure_organization_id,
1723 p_expenditure_item_date => p_expenditure_item_date,
1724 p_billable_flag => p_billable_flag,
1725 p_class_code => l_class_code,
1726 p_direct_flag => l_direct_flag,
1727 p_expenditure_category => l_expenditure_category,
1728 p_expenditure_org_name => l_expenditure_org_name,
1729 p_project_number => l_project_number,
1730 p_project_organization_name => l_project_organization_name,
1731 p_project_organization_id => l_project_organization_id,
1732 p_project_type => l_project_type,
1733 p_public_sector_flag => l_public_sector_flag,
1734 p_revenue_category => l_revenue_category,
1735 p_task_number => l_task_number,
1736 p_task_organization_name => l_task_organization_name,
1737 p_task_organization_id => l_task_organization_id,
1738 p_task_service_type => l_task_service_type,
1739 p_top_task_id => l_top_task_id,
1740 p_top_task_number => l_top_task_number);
1741
1742 g_error_stage := '40';
1743
1744 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1745 itemkey => l_itemkey,
1746 aname => 'VENDOR_ID',
1747 avalue => p_vendor_id);
1748
1749 /*Added for bug2100489 */
1750
1751 g_error_stage :='45';
1752
1753 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1754 itemkey => l_itemkey,
1755 aname => 'ACCOUNTING_DATE',
1756 avalue => to_char(NVL(p_accounting_date,sysdate)));
1757
1758 g_error_stage := '50';
1759
1760 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1761 itemkey => l_itemkey,
1762 aname => 'VENDOR_EMPLOYEE_ID',
1763 avalue => l_vendor_employee_id);
1764
1765 /* R12 changes Start - Commented for R12; workflow will use award id instead
1766 of award set id
1767 g_error_stage := '55';
1768 -- ---------------------------------------------------------------
1769 -- OGM_0.0 : Vertical application OGM may use award_set_id to
1770 -- derive award_id, which can be used to derive segments for
1771 -- the account generator.
1772 -- ---------------------------------------------------------------
1773 IF x_award_set_id is not NULL THEN
1774
1775 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1776 itemkey => l_itemkey,
1777 aname => 'AWARD_SET_ID',
1778 avalue => x_award_set_id);
1779 END IF ;
1780 R12 Changes End */
1781
1782 g_error_stage := '60';
1783
1784 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1785 itemkey => l_itemkey,
1786 aname => 'VENDOR_EMPLOYEE_NUMBER',
1787 avalue => l_vendor_employee_number);
1788
1789 g_error_stage := '70';
1790
1791 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1792 itemkey => l_itemkey,
1793 aname => 'VENDOR_TYPE',
1794 avalue => l_vendor_type);
1795
1796 g_error_stage := '80';
1797
1798 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
1799 itemkey => l_itemkey,
1800 aname => 'CHART_OF_ACCOUNTS_ID',
1801 avalue => p_chart_of_accounts_id);
1802
1803 IF p_attribute_category IS NOT NULL
1804 THEN
1805 g_error_stage := '90';
1806
1807 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1808 itemkey => l_itemkey,
1809 aname => 'ATTRIBUTE_CATEGORY',
1810 avalue => p_attribute_category);
1811 END IF;
1812
1813 IF p_attribute1 IS NOT NULL
1814 THEN
1815 g_error_stage := '100';
1816
1817 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1818 itemkey => l_itemkey,
1819 aname => 'ATTRIBUTE1',
1820 avalue => p_attribute1);
1821 END IF;
1822
1823 IF p_attribute2 IS NOT NULL
1824 THEN
1825 g_error_stage := '110';
1826
1827 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1828 itemkey => l_itemkey,
1829 aname => 'ATTRIBUTE2',
1830 avalue => p_attribute2);
1831 END IF;
1832
1833 IF p_attribute3 IS NOT NULL
1834 THEN
1835 g_error_stage := '120';
1836
1837 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1838 itemkey => l_itemkey,
1839 aname => 'ATTRIBUTE3',
1840 avalue => p_attribute3);
1841 END IF;
1842
1843 IF p_attribute4 IS NOT NULL
1844 THEN
1845 g_error_stage := '130';
1846
1847 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1848 itemkey => l_itemkey,
1849 aname => 'ATTRIBUTE4',
1850 avalue => p_attribute4);
1851 END IF;
1852
1853 IF p_attribute5 IS NOT NULL
1854 THEN
1855 g_error_stage := '140';
1856
1857 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1858 itemkey => l_itemkey,
1859 aname => 'ATTRIBUTE5',
1860 avalue => p_attribute5);
1861 END IF;
1862
1863 IF p_attribute6 IS NOT NULL
1864 THEN
1865 g_error_stage := '150';
1866
1867 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1868 itemkey => l_itemkey,
1869 aname => 'ATTRIBUTE6',
1870 avalue => p_attribute6);
1871 END IF;
1872
1873 IF p_attribute7 IS NOT NULL
1874 THEN
1875 g_error_stage := '160';
1876
1877 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1878 itemkey => l_itemkey,
1879 aname => 'ATTRIBUTE7',
1880 avalue => p_attribute7);
1881 END IF;
1882
1883 IF p_attribute8 IS NOT NULL
1884 THEN
1885 g_error_stage := '170';
1886
1887 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1888 itemkey => l_itemkey,
1889 aname => 'ATTRIBUTE8',
1890 avalue => p_attribute8);
1891 END IF;
1892
1893 IF p_attribute9 IS NOT NULL
1894 THEN
1895 g_error_stage := '180';
1896
1897 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1898 itemkey => l_itemkey,
1899 aname => 'ATTRIBUTE9',
1900 avalue => p_attribute9);
1901 END IF;
1902
1903 IF p_attribute10 IS NOT NULL
1904 THEN
1905 g_error_stage := '190';
1906
1907 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1908 itemkey => l_itemkey,
1909 aname => 'ATTRIBUTE10',
1910 avalue => p_attribute10);
1911 END IF;
1912
1913 IF p_attribute11 IS NOT NULL
1914 THEN
1915 g_error_stage := '200';
1916
1917 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1918 itemkey => l_itemkey,
1919 aname => 'ATTRIBUTE11',
1920 avalue => p_attribute11);
1921 END IF;
1922
1923 IF p_attribute12 IS NOT NULL
1924 THEN
1925 g_error_stage := '210';
1926
1927 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1928 itemkey => l_itemkey,
1929 aname => 'ATTRIBUTE12',
1930 avalue => p_attribute12);
1931 END IF;
1932
1933 IF p_attribute13 IS NOT NULL
1934 THEN
1935 g_error_stage := '220';
1936
1937 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1938 itemkey => l_itemkey,
1939 aname => 'ATTRIBUTE13',
1940 avalue => p_attribute13);
1941 END IF;
1942
1943 IF p_attribute14 IS NOT NULL
1944 THEN
1945 g_error_stage := '230';
1946
1947 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1948 itemkey => l_itemkey,
1949 aname => 'ATTRIBUTE14',
1950 avalue => p_attribute14);
1951 END IF;
1952
1953 IF p_attribute15 IS NOT NULL
1954 THEN
1955 g_error_stage := '240';
1956
1957 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1958 itemkey => l_itemkey,
1959 aname => 'ATTRIBUTE15',
1960 avalue => p_attribute15);
1961 END IF;
1962
1963 IF p_dist_attribute1 IS NOT NULL
1964 THEN
1965 g_error_stage := '250';
1966
1967 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1968 itemkey => l_itemkey,
1969 aname => 'DIST_ATTRIBUTE1',
1970 avalue => p_dist_attribute1);
1971
1972 END IF;
1973
1974 IF p_dist_attribute2 IS NOT NULL
1975 THEN
1976 g_error_stage := '260';
1977
1978 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1979 itemkey => l_itemkey,
1980 aname => 'DIST_ATTRIBUTE2',
1981 avalue => p_dist_attribute2);
1982
1983 END IF;
1984
1985 IF p_dist_attribute3 IS NOT NULL
1986 THEN
1987 g_error_stage := '270';
1988
1989 wf_engine.SetItemAttrText( itemtype => l_itemtype,
1990 itemkey => l_itemkey,
1991 aname => 'DIST_ATTRIBUTE3',
1992 avalue => p_dist_attribute3);
1993
1994 END IF;
1995
1996 IF p_dist_attribute4 IS NOT NULL
1997 THEN
1998 g_error_stage := '280';
1999
2000 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2001 itemkey => l_itemkey,
2002 aname => 'DIST_ATTRIBUTE4',
2003 avalue => p_dist_attribute4);
2004
2005 END IF;
2006
2007 IF p_dist_attribute5 IS NOT NULL
2008 THEN
2009 g_error_stage := '290';
2010
2011 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2012 itemkey => l_itemkey,
2013 aname => 'DIST_ATTRIBUTE5',
2014 avalue => p_dist_attribute5);
2015
2016 END IF;
2017
2018 IF p_dist_attribute6 IS NOT NULL
2019 THEN
2020 g_error_stage := '280';
2021
2022 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2023 itemkey => l_itemkey,
2024 aname => 'DIST_ATTRIBUTE6',
2025 avalue => p_dist_attribute6);
2026
2027 END IF;
2028
2029 IF p_dist_attribute7 IS NOT NULL
2030 THEN
2031 g_error_stage := '290';
2032
2033 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2034 itemkey => l_itemkey,
2035 aname => 'DIST_ATTRIBUTE7',
2036 avalue => p_dist_attribute7);
2037
2038 END IF;
2039
2040 IF p_dist_attribute8 IS NOT NULL
2041 THEN
2042 g_error_stage := '300';
2043
2044 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2045 itemkey => l_itemkey,
2046 aname => 'DIST_ATTRIBUTE8',
2047 avalue => p_dist_attribute8);
2048
2049 END IF;
2050
2051 IF p_dist_attribute9 IS NOT NULL
2052 THEN
2053 g_error_stage := '310';
2054
2055 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2056 itemkey => l_itemkey,
2057 aname => 'DIST_ATTRIBUTE9',
2058 avalue => p_dist_attribute9);
2059
2060 END IF;
2061
2062 IF p_dist_attribute10 IS NOT NULL
2063 THEN
2064 g_error_stage := '320';
2065
2066 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2067 itemkey => l_itemkey,
2068 aname => 'DIST_ATTRIBUTE10',
2069 avalue => p_dist_attribute10);
2070
2071 END IF;
2072
2073 IF p_dist_attribute11 IS NOT NULL
2074 THEN
2075 g_error_stage := '330';
2076
2077 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2078 itemkey => l_itemkey,
2079 aname => 'DIST_ATTRIBUTE11',
2080 avalue => p_dist_attribute11);
2081
2082 END IF;
2083
2084 IF p_dist_attribute12 IS NOT NULL
2085 THEN
2086 g_error_stage := '340';
2087
2088 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2089 itemkey => l_itemkey,
2090 aname => 'DIST_ATTRIBUTE12',
2091 avalue => p_dist_attribute12);
2092
2093 END IF;
2094
2095 IF p_dist_attribute13 IS NOT NULL
2096 THEN
2097 g_error_stage := '350';
2098
2099 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2100 itemkey => l_itemkey,
2101 aname => 'DIST_ATTRIBUTE13',
2102 avalue => p_dist_attribute13);
2103
2104 END IF;
2105
2106 IF p_dist_attribute14 IS NOT NULL
2107 THEN
2108 g_error_stage := '360';
2109
2110 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2111 itemkey => l_itemkey,
2112 aname => 'DIST_ATTRIBUTE14',
2113 avalue => p_dist_attribute14);
2114
2115 END IF;
2116
2117 IF p_dist_attribute15 IS NOT NULL
2118 THEN
2119 g_error_stage := '370';
2120
2121 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2122 itemkey => l_itemkey,
2123 aname => 'DIST_ATTRIBUTE15',
2124 avalue => p_dist_attribute15);
2125
2126 END IF;
2127
2128 IF p_dist_attribute_category IS NOT NULL
2129 THEN
2130 g_error_stage := '380';
2131
2132 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2133 itemkey => l_itemkey,
2134 aname => 'DIST_ATTRIBUTE_CATEGORY',
2135 avalue => p_dist_attribute_category);
2136 END IF;
2137
2138 --- Following section has been added as a part of enhancement request where
2139 --- Users can have workflow(PAAPINVW) setup accross orgs.
2140 --- Workflow Enhancement
2141
2142 BEGIN
2143 IF g_invoice_id IS NOT NULL THEN -- bug 13875781 start
2144 SELECT org_id
2145 INTO l_org_id
2146 FROM AP_INVOICES_ALL
2147 WHERE invoice_id = g_invoice_id;
2148 ELSE -- bug 13875781 end
2149 SELECT org_id
2150 INTO l_org_id
2151 FROM PA_IMPLEMENTATIONS;
2152 END IF; -- Added for bug 13875781
2153 END;
2154
2155 g_error_stage := '381';
2156
2157 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
2158 itemkey => l_itemkey,
2159 aname => 'ORG_ID',
2160 avalue => l_org_id);
2161
2162 /* Bug 5935019 - Changes start */
2163 -- We cannot directly assign this to attribute
2164 -- 'FND_FLEX_SEGMENTS' as workflow will take care of this.
2165 IF x_concat_segs IS NOT NULL THEN
2166 g_error_stage := '382';
2167
2168 wf_engine.SetItemAttrText( itemtype => l_itemtype,
2169 itemkey => l_itemkey,
2173 /* Bug 5935019 - Changes end */
2170 aname => 'CONCAT_SEGMENTS',
2171 avalue => x_concat_segs);
2172 END IF;
2174
2175 /* changes for bug 2348764 - passing the value of user entered ccid to
2176 the workflow */
2177
2178 g_error_stage := '383';
2179
2180 IF p_input_ccid IS NULL THEN
2181 l_input_ccid := 0;
2182 ELSE
2183 l_input_ccid := p_input_ccid;
2184 END IF;
2185 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
2186 itemkey => l_itemkey,
2187 aname => 'DIST_CODE_COMBINATION_ID',
2188 avalue => l_input_ccid);
2189 /* changes for bug 2348764 end */
2190
2191
2192 /* R12 Changes Start - Setting attributes Award ID and Expenditure Item ID
2193 for Workflow */
2194 g_error_stage := '384';
2195
2196 IF x_award_set_id IS NOT NULL THEN
2197
2198 l_award_id := PA_GMS_API.VERT_GET_AWARD_ID(x_award_set_id,NULL,NULL);
2199
2200 ELSE
2201
2202 l_award_id := p_award_id;
2203
2204 END IF;
2205
2206 IF l_award_id IS NOT NULL THEN
2207
2208 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
2209 itemkey => l_itemkey,
2210 aname => 'AWARD_ID',
2211 avalue => l_award_id);
2212
2213 END IF;
2214
2215 g_error_stage := '385';
2216
2217 IF p_expenditure_item_id IS NOT NULL THEN
2218
2219 wf_engine.SetItemAttrNumber( itemtype => l_itemtype,
2220 itemkey => l_itemkey,
2221 aname => 'EXPENDITURE_ITEM_ID',
2222 avalue => p_expenditure_item_id);
2223
2224 END IF;
2225 /* R12 Changes End */
2226
2227 -----------------------------------------------------------
2228 -- Call the workflow Generate function to trigger off the
2229 -- workflow account generation
2230 -----------------------------------------------------------
2231
2232 g_error_stage := '390';
2233
2234 l_result := fnd_flex_workflow.generate( l_itemtype,
2235 l_itemkey,
2236 TRUE,
2237 l_return_ccid,
2238 x_concat_segs, -- Bug 5935019
2239 x_concat_ids, -- Bug 5935019
2240 x_concat_descrs, -- Bug 5935019
2241 l_error_message,
2242 l_code_combination);
2243
2244 ---Added this section for Workflow error handling.
2245 -- Workflow Enhancement
2246 /* IF (l_result and ( l_return_ccid is null or l_return_ccid = 0 or l_return_ccid = -1 )) OR
2247 (NOT l_result) THEN ** Commenting this out for bug 2802847 */
2248
2249 /* Added the check for l_error_message for bug 2694601 */
2250 IF l_error_message is null THEN
2251 fnd_message.set_name('PA','PA_WF_SETUP_ERROR');
2252 x_error_message := fnd_message.get_encoded;
2253 ELSE
2254 x_error_message := l_error_message;
2255 END IF;
2256 /* 2694601*/
2257
2258 /* return(FALSE);
2259 END IF; ** bug 2802947 */
2260
2261 ------------------------------------------------------------------
2262 -- Copy the return values to the corresponding output parameters
2263 ------------------------------------------------------------------
2264 g_error_stage := '400';
2265
2266 /* Bug 5935019 - Changes start -- commented 3 lines
2267 x_concat_segs := l_concat_segs;
2268 x_concat_ids := l_concat_ids;
2269 x_concat_descrs:= l_concat_descrs;
2270 Bug 5935019 - Changes end */
2271 -- x_error_message:= l_error_message; bug 2802847
2272 x_return_ccid := l_return_ccid;
2273
2274 --------------------------------------------------------------------
2275 -- Reset the error stack because there were no errors
2276 --------------------------------------------------------------------
2277
2278 reset_error_stack;
2279
2280 --------------------------------------------------------------------
2281 -- Return the return value of the Generate function as the return
2282 -- value for the process
2283 --------------------------------------------------------------------
2284
2285 RETURN l_result;
2286
2287 EXCEPTION
2288
2289 WHEN OTHERS
2290 THEN
2291
2292 -----------------------------------------------------------------------
2293 -- Record error using generic error message routine for debugging and
2294 -- raise it
2295 -----------------------------------------------------------------------
2296
2297 /* Bug 5233487 - Start */
2298 IF g_encoded_error_message IS NULL THEN
2299 g_encoded_error_message := show_error(g_error_stack,g_error_stage,NULL);
2300 END IF;
2301 x_error_message := g_encoded_error_message;
2302 reset_error_stack;
2303 /* Bug 5233487 - End */
2304
2305
2306 wf_core.context( pkg_name => 'pa_acc_gen_wf_pkg',
2307 proc_name => 'ap_inv_generate_account',
2308 arg1 => 'Project id: '||p_project_id,
2309 arg2 => 'Task id: '||l_task_id, -- Modified for bug 16613999
2310 arg3 => 'Vendor id: '||p_vendor_id,
2311 arg4 => 'Exp type: '||p_expenditure_type,
2312 arg5 => 'Exp Org id: '||p_expenditure_organization_id);
2313
2314 RETURN FALSE;
2315
2316 END ap_inv_generate_account;
2317 ----------------------------------------------------------------------
2318 -- Start of procedure upgrade_flexbuilder_account. Procedure level
2319 -- comments with specifications
2320 ----------------------------------------------------------------------
2321
2322 PROCEDURE ap_inv_upgrade_flex_account (
2323 p_itemtype IN VARCHAR2,
2324 p_itemkey IN VARCHAR2,
2328 AS
2325 p_actid IN NUMBER,
2326 p_funcmode IN VARCHAR2,
2327 x_result OUT NOCOPY VARCHAR2)
2329
2330 l_project_id pa_projects_all.project_id%TYPE;
2331 l_task_id pa_tasks.task_id%TYPE;
2332 l_expenditure_type pa_expenditure_types.expenditure_type%TYPE;
2333 l_vendor_id po_vendors.vendor_id%type;
2334 l_expenditure_organization_id hr_organization_units.organization_id%TYPE;
2335 l_expenditure_item_date pa_expenditure_items_all.expenditure_item_date%TYPE;
2336 l_billable_flag pa_tasks.billable_flag%TYPE;
2337 l_chart_of_accounts_id NUMBER;
2338 l_fb_error_msg VARCHAR2(2000);
2339 l_fb_flex_seg VARCHAR2(500);
2340 l_build_account_result BOOLEAN;
2341 l_award_set_id NUMBER; /* Added to fix bug 1612877 */
2342
2343 BEGIN
2344
2345 -----------------------------------------------------------------------
2346 -- Check the Workflow mode in which this function has been called. If
2347 -- it is not in the RUN mode, then exit out of this function
2348 -----------------------------------------------------------------------
2349
2350 IF p_funcmode <> 'RUN'
2351 THEN
2352 x_result := null;
2353 return;
2354 END IF;
2355
2356 --------------------------------------------------------------
2357 -- Get the values of the attributes that were defined as raw
2358 -- parameters in Flexbuilder
2359 --------------------------------------------------------------
2360
2361 l_project_id := wf_engine.GetItemAttrNumber ( itemtype => p_itemtype,
2362 itemkey => p_itemkey,
2363 aname => 'PROJECT_ID');
2364
2365 l_task_id := wf_engine.GetItemAttrNumber ( itemtype => p_itemtype,
2366 itemkey => p_itemkey,
2367 aname => 'TASK_ID');
2368
2369 l_expenditure_type := wf_engine.GetItemAttrText ( itemtype => p_itemtype,
2370 itemkey => p_itemkey,
2371 aname => 'EXPENDITURE_TYPE');
2372
2373 l_expenditure_item_date:= wf_engine.GetItemAttrDate ( itemtype => p_itemtype,
2374 itemkey => p_itemkey,
2375 aname => 'EXPENDITURE_ITEM_DATE');
2376
2377 l_expenditure_organization_id :=
2378 wf_engine.GetItemAttrNumber ( itemtype => p_itemtype,
2379 itemkey => p_itemkey,
2380 aname => 'EXPENDITURE_ORGANIZATION_ID');
2381
2382
2383 /* l_vendor_id populated for bug 2037544 */
2384
2385 l_vendor_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
2386 itemkey => p_itemkey,
2387 aname => 'VENDOR_ID');
2388
2389 l_billable_flag := wf_engine.GetItemAttrText ( itemtype => p_itemtype,
2390 itemkey => p_itemkey,
2391 aname => 'BILLABLE_FLAG');
2392
2393 l_chart_of_accounts_id:=
2394 wf_engine.GetItemAttrNumber ( itemtype => p_itemtype,
2395 itemkey => p_itemkey,
2396 aname => 'CHART_OF_ACCOUNTS_ID');
2397
2398 /* Added to fix bug 1612877 */
2399 l_award_set_id:=
2400 wf_engine.GetItemAttrNumber ( itemtype => p_itemtype,
2401 itemkey => p_itemkey,
2402 aname => 'AWARD_SET_ID');
2403
2404
2405 -----------------------------------------------------------------------
2406 -- Call the build function to derive the account based on Flexbuilder
2407 -- rules
2408 -----------------------------------------------------------------------
2409 /* Added the call for award_set_id in this function to fix bug 1612877 */
2410
2411 l_build_account_result := pa_vend_inv_charge_account.build (
2412 fb_flex_num => l_chart_of_accounts_id,
2413 expenditure_organization_id => l_expenditure_organization_id,
2414 expenditure_type => l_expenditure_type,
2415 pa_billable_flag => l_billable_flag,
2416 project_id => l_project_id,
2417 task_id => l_task_id,
2418 vendor_id => l_vendor_id,
2419 fb_flex_seg => l_fb_flex_seg,
2420 fb_error_msg => l_fb_error_msg) ;
2421
2422 /* Removed to fix bug 1612877 */
2423 -- award_set_id => l_award_set_id );
2424 -- =====================================================
2425
2426 --------------------------------------------------------------------
2427 -- Call the FND procedure to load the values into the concatenated
2428 -- segments
2429 --------------------------------------------------------------------
2430
2431 fnd_flex_workflow.load_concatenated_segments ( p_itemtype,
2432 p_itemkey,
2433 l_fb_flex_seg );
2434
2435 -------------------------------------------------------------------------
2436 -- Check the result of the Build function and return success or failure
2437 -- accordingly
2438 -------------------------------------------------------------------------
2439
2440 IF l_build_account_result
2441 THEN
2442 x_result := 'COMPLETE:SUCCESS';
2443 RETURN;
2444 ELSE
2445 ---------------------------
2446 -- Set error message here
2447 ---------------------------
2448 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2449 itemkey => p_itemkey,
2450 aname => 'ERROR_MESSAGE',
2451 avalue => l_fb_error_msg);
2452
2453 x_result := 'COMPLETE:FAILURE';
2454 RETURN;
2455 END IF;
2456
2457 EXCEPTION
2458
2459 WHEN OTHERS
2460 THEN
2461
2462 -----------------------------------------------------------------------
2463 -- Record error using generic error message routine for debugging and
2464 -- raise it
2465 -----------------------------------------------------------------------
2466
2467 wf_core.context( pkg_name => 'pa_acc_gen_wf_pkg',
2468 proc_name => 'ap_inv_upgrade_flex_account',
2469 arg1 => 'Project Id: ' ||l_project_id,
2470 arg2 => 'Task Id: ' ||l_task_id,
2471 arg3 => 'Vendor Id: ' ||l_vendor_id,
2472 arg4 => 'Exp type: ' ||l_expenditure_type,
2473 arg5 => 'Exp Org Id: ' ||l_expenditure_organization_id);
2474
2475 raise;
2476
2477
2478 END ap_inv_upgrade_flex_account;
2479
2480 ----------------------------------------------------------------------
2481 -- Start of procedure ap_inv_acc_undefined_rules. Function level
2482 -- comments with specifications
2483 ----------------------------------------------------------------------
2484
2485 PROCEDURE ap_inv_acc_undefined_rules (
2486 p_itemtype IN VARCHAR2,
2487 p_itemkey IN VARCHAR2,
2488 p_actid IN NUMBER,
2489 p_funcmode IN VARCHAR2,
2490 x_result OUT NOCOPY VARCHAR2)
2491 IS
2492 l_fb_error_msg VARCHAR2(400);
2493 BEGIN
2494
2495 -----------------------------------------------------------------------
2496 -- Check the Workflow mode in which this function has been called. If
2497 -- it is not in the RUN mode, then exit out of this function
2498 -----------------------------------------------------------------------
2499
2500 IF p_funcmode <> 'RUN'
2501 THEN
2502 x_result := null;
2503 return;
2504 END IF;
2505
2506 -----------------------------------------
2507 -- Set the appropriate message and exit
2508 -----------------------------------------
2509
2510 fnd_message.set_name('PA','FLEXWF-DEFAULT MISSING');
2511 l_fb_error_msg := fnd_message.get_encoded;
2512 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2513 itemkey => p_itemkey,
2514 aname => 'ERROR_MESSAGE',
2515 avalue => l_fb_error_msg);
2516
2517 x_result := 'COMPLETE:FAILURE';
2518 RETURN;
2519
2520 EXCEPTION
2521
2522 WHEN OTHERS
2523 THEN
2524
2525 -----------------------------------------------------------------------
2526 -- Record error using generic error message routine for debugging and
2527 -- raise it
2528 -----------------------------------------------------------------------
2529
2530 wf_core.context( pkg_name => 'pa_acc_gen_wf_pkg ',
2531 proc_name => 'ap_inv_acc_undefined_rules',
2532 arg1 => 'Error: Default workflow not defined',
2533 arg2 => null,
2534 arg3 => null,
2535 arg4 => null,
2536 arg5 => null);
2537
2538 raise;
2539 END ap_inv_acc_undefined_rules;
2540
2541 ----------------------------------------------------------------------
2542
2543 ----------------------------------------------------------------------
2544 -- Start of procedure pa_seg_lookup_set_value. Procedure level
2545 -- comments with specifications
2546 ----------------------------------------------------------------------
2547
2548 PROCEDURE pa_seg_lookup_set_value (
2549 p_itemtype IN VARCHAR2,
2550 p_itemkey IN VARCHAR2,
2551 p_actid IN NUMBER,
2552 p_funcmode IN VARCHAR2,
2553 x_result OUT NOCOPY VARCHAR2)
2554 AS
2555
2556 l_seg_value_lookup_set_name
2557 pa_segment_value_lookup_sets.segment_value_lookup_set_name%TYPE;
2558
2559 l_intermediate_value
2560 pa_segment_value_lookups.segment_value_lookup%TYPE;
2561
2562 l_segment_value pa_segment_value_lookups.segment_value%TYPE;
2563
2564 no_lookup_type EXCEPTION;
2565 no_lookup_code EXCEPTION;
2566 l_error_message VARCHAR2(2000);
2567
2568 BEGIN
2569
2570 -----------------------------------------------------------------------
2571 -- Check the Workflow mode in which this function has been called. If
2572 -- it is not in the RUN mode, then exit out of this function
2573 -----------------------------------------------------------------------
2574
2575 set_error_stack('-->pa_seg_lookup_set_value'); /* Bug 5233487 */
2576 g_error_stage := '10';
2577
2578 IF p_funcmode <> 'RUN'
2579 THEN
2580 x_result := null;
2581 return;
2582 END IF;
2583
2584 ---------------------------------------------------
2585 -- Retrieve the current value for the lookup type
2586 ---------------------------------------------------
2587 g_error_stage := '20';
2588
2589 l_seg_value_lookup_set_name :=
2590 wf_engine.GetActivityAttrText
2591 ( itemtype => p_itemtype,
2592 itemkey => p_itemkey,
2593 actid => p_actid,
2594 aname => 'LOOKUP_TYPE' );
2595
2596 ------------------------------------------------------------------------
2597 -- Raise the appropriate exception if the lookup type has not been set
2598 ------------------------------------------------------------------------
2599
2600 IF l_seg_value_lookup_set_name IS NULL
2601 THEN
2602 RAISE no_lookup_type;
2603 END IF;
2604
2605 ---------------------------------------------------
2606 -- Retrieve the current value for the lookup code
2607 ---------------------------------------------------
2608 g_error_stage := '30';
2609
2610 l_intermediate_value :=
2611 wf_engine.GetActivityAttrText
2612 ( itemtype => p_itemtype,
2613 itemkey => p_itemkey,
2614 actid => p_actid,
2615 aname => 'LOOKUP_CODE' );
2616
2617 ------------------------------------------------------------------------
2618 -- Raise the appropriate exception if the lookup code has not been set
2619 ------------------------------------------------------------------------
2620
2621 IF l_intermediate_value IS NULL
2622 THEN
2623 RAISE no_lookup_code;
2624 END IF;
2625
2626
2627 -------------------------------------------
2628 -- Select the lookup value from the table
2629 -------------------------------------------
2630 g_error_stage := '40';
2631
2632 SELECT segment_value
2633 INTO l_segment_value
2634 FROM pa_segment_value_lookups valuex,
2635 pa_segment_value_lookup_sets sets
2636 WHERE sets.segment_value_lookup_set_id =
2637 valuex.segment_value_lookup_set_id
2638 AND sets.segment_value_lookup_set_name = l_seg_value_lookup_set_name
2639 AND valuex.segment_value_lookup = l_intermediate_value;
2640
2641
2642 -----------------------------------------------------------------------
2643 -- If the retrieval was successful, then set the appropriate item
2644 -- attribute to the value retrieved. Otherwise, raise the appropriate
2645 -- error message
2646 -----------------------------------------------------------------------
2647 g_error_stage := '50';
2648
2649 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2650 itemkey => p_itemkey,
2651 aname => 'LOOKUP_SET_VALUE',
2652 avalue => l_segment_value);
2653
2654
2655 x_result := 'COMPLETE:SUCCESS';
2656
2657 -- If you are here then there were no errors. Reset the error stack.
2658
2659 reset_error_stack;
2660
2661 EXCEPTION
2662
2663 ------------------------------------------------------------------
2664 -- User defined exception raised when lookup type is not defined
2665 ------------------------------------------------------------------
2666
2667 WHEN no_lookup_type
2668 THEN
2669 reset_error_stack; /* Bug 5233487 */
2670 -- Record standard workflow debugging message
2671 wf_core.context( pkg_name => 'PA_ACC_GEN_WF_PKG ',
2672 proc_name => 'PA_SEG_LOOKUP_SET_VALUE',
2673 arg1 => 'Lookup Set:' || l_seg_value_lookup_set_name,
2674 arg2 => 'Intermediate Value: ' || l_intermediate_value,
2675 arg3 => 'Lookup type null',
2676 arg4 => null,
2677 arg5 => null);
2678
2679
2680 -- Error requires an error message to be set so that it can be
2681 -- displayed on the form.
2682
2683
2684 fnd_message.set_name('PA','WF_ACC_LOOKUP_TYPE_FAIL');
2685 l_error_message := fnd_message.get_encoded;
2686 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2687 itemkey => p_itemkey,
2688 aname => 'ERROR_MESSAGE',
2689 avalue => l_error_message);
2690
2691
2692 -- Return a failure so that the abort generation End function is called
2693
2694 x_result := 'COMPLETE:FAILURE';
2695 RETURN;
2696
2697 ------------------------------------------------------------------
2698 -- User defined exception raised when lookup code is not defined
2699 ------------------------------------------------------------------
2700
2701 WHEN no_lookup_code
2702 THEN
2703 reset_error_stack; /* Bug 5233487 */
2704 -- Record standard workflow debugging message
2705 wf_core.context( pkg_name => 'PA_ACC_GEN_WF_PKG ',
2706 proc_name => 'PA_SEG_LOOKUP_SET_VALUE',
2707 arg1 => 'Lookup Set:' || l_seg_value_lookup_set_name,
2708 arg2 => 'Intermediate Value: ' || l_intermediate_value,
2709 arg3 => 'Lookup code null',
2710 arg4 => null,
2711 arg5 => null);
2712
2713
2714 -- Error requires an error message to be set so that it can be
2715 -- displayed on the form. The error message name is defined in
2716 -- Applications.
2717
2718 wf_engine.SetItemAttrText
2719 ( itemtype=> p_itemtype,
2720 itemkey => p_itemkey,
2721 aname => 'ERROR_MESSAGE',
2722 avalue => 'WF_ACC_LOOKUP_CODE_FAIL');
2723
2724 fnd_message.set_name('PA','WF_ACC_LOOKUP_CODE_FAIL');
2725 l_error_message := fnd_message.get_encoded;
2726 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2727 itemkey => p_itemkey,
2728 aname => 'ERROR_MESSAGE',
2729 avalue => l_error_message);
2730
2731
2732 -- Return a failure so that the abort generation End function is called
2733
2734 x_result := 'COMPLETE:FAILURE';
2735 RETURN;
2736
2737 ------------------------------------------------------------------------
2738 -- If data is not found after the SELECT, it indicates that the
2739 -- combination of the lookup type and lookup code has not been defined
2740 ------------------------------------------------------------------------
2741
2742 WHEN no_data_found
2743 THEN
2744 reset_error_stack; /* Bug 5233487 */
2745 -- Record standard workflow debugging message
2746 wf_core.context( pkg_name => 'PA_ACC_GEN_WF_PKG ',
2747 proc_name => 'PA_SEG_LOOKUP_SET_VALUE',
2748 arg1 => 'Lookup Set:' || l_seg_value_lookup_set_name,
2749 arg2 => 'Intermediate Value: ' || l_intermediate_value,
2750 arg3 => 'Lookup code null',
2751 arg4 => null,
2752 arg5 => null);
2753
2754
2755 -- Error requires an error message to be set so that it can be
2756 -- displayed on the form.
2757
2758 wf_engine.SetItemAttrText
2759 ( itemtype=> p_itemtype,
2760 itemkey => p_itemkey,
2761 aname => 'ERROR_MESSAGE',
2762 avalue => 'WF_ACC_LOOKUP_NODATA_FAIL');
2763
2764 fnd_message.set_name('PA','WF_ACC_LOOKUP_NODATA_FAIL');
2765 l_error_message := fnd_message.get_encoded;
2766 wf_engine.SetItemAttrText( itemtype => p_itemtype,
2767 itemkey => p_itemkey,
2768 aname => 'ERROR_MESSAGE',
2769 avalue => l_error_message);
2770
2771
2772 -- Return a failure so that the abort generation End function is called
2773
2774 x_result := 'COMPLETE:FAILURE';
2775 RETURN;
2776
2777 -----------------------------------------------------------
2778 -- All other exceptions are raised to the calling program
2779 -----------------------------------------------------------
2780
2781 WHEN others
2782 THEN
2783 g_error_message := SQLERRM;
2784 --
2785 -- Call the show error function, this function should be used for handling
2786 -- fatal errors. It accepts 5 arguments, we have used this function to
2787 -- pin point the exact error section. Customers can user p_arg1, p_arg2 for
2788 -- more specific debugging, we have used these 2 arguments to identify the
2789 -- record in error( i.e. lookup_set_name and intermediate_value).
2790 --
2791
2792 l_error_message := pa_acc_gen_wf_pkg.show_error(p_error_stack => g_error_stack,
2793 p_error_stage => g_error_stage,
2794 p_error_message => g_error_message,
2795 p_arg1 => 'Lookup Set:'||l_seg_value_lookup_set_name,
2796 p_arg2 => 'Intermediate Value: ' || l_intermediate_value);
2797 reset_error_stack; /* Bug 5233487 */
2798
2799 -- populate the error message wf attribute and return failure.
2800
2801 wf_engine.SetItemAttrText
2802 ( itemtype=> p_itemtype,
2803 itemkey => p_itemkey,
2804 aname => 'ERROR_MESSAGE',
2805 avalue => l_error_message);
2806
2807 -- Return a failure so that the abort generation End function is called
2808
2809 x_result := 'COMPLETE:FAILURE';
2810
2811 -- Record standard workflow debugging message
2812 wf_core.context( pkg_name => 'PA_ACC_GEN_WF_PKG ',
2813 proc_name => 'PA_SEG_LOOKUP_SET_VALUE',
2814 arg1 => 'Lookup Set:' || l_seg_value_lookup_set_name,
2815 arg2 => 'Intermediate Value: ' || l_intermediate_value,
2816 arg3 => null,
2817 arg4 => null,
2818 arg5 => null);
2819
2820 RETURN;
2821
2822 END pa_seg_lookup_set_value;
2823
2824 ----------------------------------------------------------------------
2825 -- Start of procedure pa_aa_function_transaction. Procedure level
2826 -- comments with specifications
2827 ----------------------------------------------------------------------
2828 /*
2829 PROCEDURE pa_aa_function_transaction (
2830 p_itemtype IN VARCHAR2,
2831 p_itemkey IN VARCHAR2,
2832 p_actid IN NUMBER,
2833 p_funcmode IN VARCHAR2,
2834 x_result OUT VARCHAR2)
2835 AS
2836
2837 CURSOR c_ft_code(p_ft_code IN VARCHAR2,
2838 p_ptype_ft_code IN VARCHAR2)
2839 IS
2840 Select function_transaction_code ft_code,
2841 decode(function_transaction_code,'ALL',10,'CON',9,'CAP',8,'IND',7,5) ft_order
2842 from pa_function_transactions
2843 where function_transaction_code in
2844 ('ALL',p_ft_code,p_ptype_ft_code)
2845 and application_id = 275
2846 and function_code = 'BER'
2847 and enabled_flag = 'Y'
2848 order by 2;
2849
2850 ft_rec c_ft_code%ROWTYPE;
2851
2852 l_project_id
2853 pa_projects_all.project_id%TYPE;
2854
2855 l_ptype_class_code
2856 pa_project_types_all.project_type_class_code%TYPE;
2857
2858 l_public_sector_flag
2859 pa_projects_all.public_sector_flag%TYPE;
2860
2861 l_billable_flag pa_tasks.billable_flag%TYPE;
2862
2863 l_ft_code pa_function_transactions_all.function_transaction_code%TYPE;
2864
2865 l_ptype_ft_code pa_function_transactions_all.function_transaction_code%TYPE;
2866
2867
2868 l_old_error_stack VARCHAR2(500);
2869
2870 l_error_message VARCHAR2(2000);
2871
2872 BEGIN
2873
2874 -----------------------------------------------------------------------
2875 -- Check the Workflow mode in which this function has been called. If
2876 -- it is not in the RUN mode, then exit out of this function
2877 -----------------------------------------------------------------------
2878
2879 l_old_error_stack := g_error_stack;
2880 g_error_stack := g_error_stack||'-->'||'pa_aa_function_transaction';
2881 g_error_stage := '10';
2882
2883 IF p_funcmode <> 'RUN'
2884 THEN
2885 x_result := null;
2886 return;
2887 END IF;
2888
2889 ---------------------------------------------------
2890 -- Retrieve the current value for the lookup type
2891 ---------------------------------------------------
2892 g_error_stage := '20';
2893
2894 l_project_id :=
2895 wf_engine.GetItemAttrNumber
2896 ( itemtype => p_itemtype,
2897 itemkey => p_itemkey,
2898 aname => 'PROJECT_ID' );
2899
2900 select a.project_type_class_code
2901 into l_ptype_class_code
2902 from pa_project_types_all a,
2903 pa_projects_all b
2904 where a.project_type = b.project_type
2905 and nvl(a.org_id,-99) = nvl(b.org_id, -99)
2906 and b.project_id = l_project_id;
2907
2908 ----------------------------------------------------------
2909 -- Retrieve the current value for the public sector flag
2910 ----------------------------------------------------------
2911 g_error_stage := '30';
2912
2913 l_public_sector_flag :=
2917 aname => 'PUBLIC_SECTOR_FLAG' );
2914 wf_engine.GetItemAttrText
2915 ( itemtype => p_itemtype,
2916 itemkey => p_itemkey,
2918
2919 --------------------------------------------------------------
2920 -- Retrieve the current value for billable flag
2921 --------------------------------------------------------------
2922 g_error_stage := '40';
2923
2924 l_billable_flag :=
2925 wf_engine.GetItemAttrText
2926 ( itemtype => p_itemtype,
2927 itemkey => p_itemkey,
2928 aname => 'BILLABLE_FLAG' );
2929
2930 ---------------------------------------------------------
2931 -- derive the AutoAccounting function transaction code
2932 -- from project_type_class_code, public_sector_flag and
2933 -- billable_flag
2934 ---------------------------------------------------------
2935
2936 g_error_stage := '50';
2937
2938 IF ( l_ptype_class_code = 'CONTRACT' ) THEN
2939
2940 l_ptype_ft_code := 'CON';
2941
2942 IF ( l_public_sector_flag = 'Y' ) THEN
2943
2944 IF ( l_billable_flag = 'Y' ) THEN
2945
2946 l_ft_code := 'PUB-BILL';
2947 ELSE
2948
2949 l_ft_code := 'PUB-NOBIL';
2950 END IF;
2951 ELSE
2952
2953 IF ( l_billable_flag = 'Y' ) THEN
2954
2955 l_ft_code := 'PRV-BILL';
2956 ELSE
2957
2958 l_ft_code := 'PRV-NOBIL';
2959 END IF;
2960 END IF;
2961
2962 ELSIF ( l_ptype_class_code = 'CAPITAL' ) THEN
2963
2964 l_ptype_ft_code := 'CAP';
2965
2966 IF ( l_public_sector_flag = 'Y' ) THEN
2967
2968 IF ( l_billable_flag = 'Y' ) THEN
2969
2970 l_ft_code := 'PUB-CAP';
2971 ELSE
2972
2973 l_ft_code := 'PUB-NOCAP';
2974 END IF;
2975 ELSE
2976
2977 IF ( l_billable_flag = 'Y' ) THEN
2978
2979 l_ft_code := 'PRV-CAP';
2980 ELSE
2981
2982 l_ft_code := 'PRV-NOCAP';
2983 END IF;
2984 END IF;
2985
2986 ELSIF ( l_ptype_class_code = 'INDIRECT' ) THEN
2987
2988 l_ptype_ft_code := 'IND';
2989
2990 IF ( l_public_sector_flag = 'Y' ) THEN
2991
2992 l_ft_code := 'IND-PUB';
2993 ELSE
2994
2995 l_ft_code := 'IND-PRV';
2996 END IF;
2997
2998 END IF;
2999
3000 ----------------------------------------------------------------
3001 -- Now we have all the function transaction codes
3002 -- lookup the pa_function_transactions_all table and
3003 -- get the code that applies to this transaction
3004 ----------------------------------------------------------------
3005 g_error_stage := '60';
3006
3007 OPEN c_ft_code(l_ft_code,
3008 l_ptype_ft_code);
3009
3010 g_error_stage := '70';
3011
3012 FETCH c_ft_code INTO ft_rec;
3013
3014 CLOSE c_ft_code;
3015
3016 g_error_stage := '80';
3017
3018 wf_engine.SetItemAttrText( itemtype => p_itemtype,
3019 itemkey => p_itemkey,
3020 aname => 'TRANSACTION_CODE',
3021 avalue => ft_rec.ft_code);
3022
3023
3024 x_result := 'COMPLETE:SUCCESS';
3025
3026 -- If you are here then there were no errors. Reset the error stack.
3027
3028 g_error_stack := l_old_error_stack;
3029
3030 EXCEPTION
3031
3032 -----------------------------------------------------------
3033 -- All other exceptions are raised to the calling program
3034 -----------------------------------------------------------
3035
3036 WHEN others
3037 THEN
3038 g_error_message := SQLERRM;
3039 --
3040 -- Call the show error function, this function should be used for handling
3041 -- fatal errors. It accepts 5 arguments, we have used this function to
3042 -- pin point the exact error location. Customers can user p_arg1, p_arg2 for
3043 -- more specific debugging, we have used these 2 arguments to identify the
3044 -- record in error( i.e. l_function_transaction_c and l_ptype_class_code).
3045 --
3046
3047 l_error_message := pa_acc_gen_wf_pkg.show_error(p_error_stack => g_error_stack,
3048 p_error_stage => g_error_stage,
3049 p_error_message => g_error_message,
3050 p_arg1 => 'Function Transaction code:'||l_ft_code,
3051 p_arg2 => 'Project Type Class Code: ' || l_ptype_class_code);
3052
3053 -- populate the error message wf attribute and return failure.
3054
3055 wf_engine.SetItemAttrText
3056 ( itemtype=> p_itemtype,
3057 itemkey => p_itemkey,
3058 aname => 'ERROR_MESSAGE',
3059 avalue => l_error_message);
3060
3061 -- Return a failure so that the abort generation End function is called
3062
3063 x_result := 'COMPLETE:FAILURE';
3064
3065 -- Record standard workflow debugging message
3066 wf_core.context( pkg_name => 'PA_ACC_GEN_WF_PKG ',
3067 proc_name => 'PA_AA_FUNCTION_TRANSACTION',
3068 arg1 => 'Function Transaction Code' || l_ft_code,
3069 arg2 => 'Project Type Class Code: ' || l_ptype_class_code,
3070 arg3 => null,
3071 arg4 => null,
3072 arg5 => null);
3073
3074 RETURN;
3075
3076 END pa_aa_function_transaction;
3077
3078 */
3079 ----------------------------------------------------------------------
3080 -- Start of function show_error. Procedure level
3081 -- comments with specifications
3082 ----------------------------------------------------------------------
3083 FUNCTION show_error(p_error_stack IN VARCHAR2,
3084 p_error_stage IN VARCHAR2,
3085 p_error_message IN VARCHAR2,
3086 p_arg1 IN VARCHAR2 DEFAULT null,
3087 p_arg2 IN VARCHAR2 DEFAULT null) RETURN VARCHAR2
3088 IS
3089
3090 l_result FND_NEW_MESSAGES.MESSAGE_TEXT%TYPE;
3091
3092 BEGIN
3093 g_error_message := nvl(p_error_message,SUBSTRB(SQLERRM,1,1000));
3094
3095 fnd_message.set_name('PA','PA_WF_FATAL_ERROR');
3096 fnd_message.set_token('ERROR_STACK',p_error_stack);
3097 fnd_message.set_token('ERROR_STAGE',p_error_stage);
3098 fnd_message.set_token('ERROR_MESSAGE',g_error_message);
3099 fnd_message.set_token('ERROR_ARG1',p_arg1);
3100 fnd_message.set_token('ERROR_ARG2',p_arg2);
3101
3102 l_result := fnd_message.get_encoded;
3103
3104 g_error_message := NULL;
3105
3106 RETURN l_result;
3107 EXCEPTION WHEN OTHERS
3108 THEN
3109 raise;
3110 END show_error;
3111
3112 /* Bug 5233487 - Start */
3113 PROCEDURE set_error_stack(p_error_stack_msg IN VARCHAR2) IS
3114 BEGIN
3115 IF g_error_stack_history.COUNT = 0 THEN
3116 g_error_stack_history(0) := g_error_stack;
3117 ELSE
3118 g_error_stack_history(g_error_stack_history.LAST + 1) := g_error_stack;
3119 END IF;
3120 g_error_stack := SUBSTR(g_error_stack || p_error_stack_msg, 0, 500);
3121 END set_error_stack;
3122
3123 PROCEDURE reset_error_stack IS
3124 BEGIN
3125 IF g_error_stack_history.COUNT > 0 THEN
3126 g_error_stack := g_error_stack_history(g_error_stack_history.LAST);
3127 g_error_stack_history.DELETE(g_error_stack_history.LAST);
3128 END IF;
3129 END reset_error_stack;
3130 /* Bug 5233487 - End */
3131
3132 END pa_acc_gen_wf_pkg ;