[Home] [Help]
PACKAGE BODY: APPS.PO_WF_BUILD_ACCOUNT_INIT
Source
1 PACKAGE BODY PO_WF_BUILD_ACCOUNT_INIT AS
2 /* $Header: POXWPOSB.pls 120.7.12020000.2 2013/06/06 14:33:01 gjyothi ship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
6
7 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
8 g_pkg_name CONSTANT VARCHAR2(100) := 'PO_WF_BUILD_ACCOUNT_INIT';
9 g_log_head CONSTANT VARCHAR2(1000) := 'po.plsql.'||g_pkg_name||'.';
10
11 g_debug_stmt CONSTANT BOOLEAN := PO_DEBUG.is_debug_stmt_on;
12 g_debug_unexp CONSTANT BOOLEAN := PO_DEBUG.is_debug_unexp_on;
13 -- End
14
15 /****************************************************************************
16 * The following are local/Private procedure that support the workflow APIs: *
17 *****************************************************************************/
18
19 PROCEDURE Call_WF_API_to_set_Att (ItemType varchar2, ItemKey varchar2,
20 aname varchar2, avalue varchar2);
21 PROCEDURE Call_WF_API_to_set_no_Att (ItemType varchar2, ItemKey varchar2,
22 aname varchar2, avalue number);
23 PROCEDURE Call_WF_API_to_set_date_Att (ItemType varchar2, ItemKey varchar2,
24 aname varchar2, avalue date);
25
26 -- ************************************************************************************ --
27 /*
28 PRIVATE PROCEDURES / FUNCTIONS
29 */
30 -- ************************************************************************************ --
31
32 PROCEDURE Call_WF_API_to_set_Att (ItemType varchar2, ItemKey varchar2, aname varchar2,
33 avalue varchar2)
34 IS
35 BEGIN
36
37 If avalue IS NOT NULL then
38 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
39 itemkey => itemkey,
40 aname => aname,
41 avalue => avalue );
42 end if;
43 END Call_WF_API_to_set_Att;
44
45 PROCEDURE Call_WF_API_to_set_no_Att (ItemType varchar2, ItemKey varchar2, aname varchar2,
46 avalue number)
47 IS
48 BEGIN
49
50 If avalue IS NOT NULL then
51 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
52 itemkey => itemkey,
53 aname => aname,
54 avalue => avalue );
55 end if;
56 END Call_WF_API_to_set_no_Att;
57
58 PROCEDURE Call_WF_API_to_set_date_Att (ItemType varchar2, ItemKey varchar2, aname varchar2,
59 avalue date)
60 IS
61 BEGIN
62 If avalue IS NOT NULL then
63 po_wf_util_pkg.SetItemAttrDate ( itemtype => itemtype,
64 itemkey => itemkey,
65 aname => aname,
66 avalue => avalue );
67 end if;
68 END Call_WF_API_to_set_date_Att;
69
70 PROCEDURE set_ag_wf_attributes(
71 itemtype IN VARCHAR2,
72 wf_itemkey IN VARCHAR2,
73 x_coa_id IN NUMBER,
74 x_bom_cost_element_id IN NUMBER,
75 x_bom_resource_id IN NUMBER,
76 x_category_id IN NUMBER,
77 x_deliver_to_location_id IN NUMBER,
78 x_destination_organization_id IN NUMBER,
79 x_destination_subinventory IN VARCHAR2,
80 x_destination_type_code IN VARCHAR2,
81 x_po_encumberance_flag IN VARCHAR2,
82 header_att1 IN VARCHAR2, header_att2 IN VARCHAR2,
83 header_att3 IN VARCHAR2, header_att4 IN VARCHAR2,
84 header_att5 IN VARCHAR2, header_att6 IN VARCHAR2,
85 header_att7 IN VARCHAR2, header_att8 IN VARCHAR2,
86 header_att9 IN VARCHAR2, header_att10 IN VARCHAR2,
87 header_att11 IN VARCHAR2, header_att12 IN VARCHAR2,
88 header_att13 IN VARCHAR2, header_att14 IN VARCHAR2,
89 header_att15 IN VARCHAR2,
90 line_att1 IN VARCHAR2, line_att2 IN VARCHAR2,
91 line_att3 IN VARCHAR2, line_att4 IN VARCHAR2,
92 line_att5 IN VARCHAR2, line_att6 IN VARCHAR2,
93 line_att7 IN VARCHAR2, line_att8 IN VARCHAR2,
94 line_att9 IN VARCHAR2, line_att10 IN VARCHAR2,
95 line_att11 IN VARCHAR2, line_att12 IN VARCHAR2,
96 line_att13 IN VARCHAR2, line_att14 IN VARCHAR2,
97 line_att15 IN VARCHAR2,
98 shipment_att1 IN VARCHAR2, shipment_att2 IN VARCHAR2,
99 shipment_att3 IN VARCHAR2, shipment_att4 IN VARCHAR2,
100 shipment_att5 IN VARCHAR2, shipment_att6 IN VARCHAR2,
101 shipment_att7 IN VARCHAR2, shipment_att8 IN VARCHAR2,
102 shipment_att9 IN VARCHAR2, shipment_att10 IN VARCHAR2,
103 shipment_att11 IN VARCHAR2, shipment_att12 IN VARCHAR2,
104 shipment_att13 IN VARCHAR2, shipment_att14 IN VARCHAR2,
105 shipment_att15 IN VARCHAR2,
106 distribution_att1 IN VARCHAR2, distribution_att2 IN VARCHAR2,
107 distribution_att3 IN VARCHAR2, distribution_att4 IN VARCHAR2,
108 distribution_att5 IN VARCHAR2, distribution_att6 IN VARCHAR2,
109 distribution_att7 IN VARCHAR2, distribution_att8 IN VARCHAR2,
110 distribution_att9 IN VARCHAR2, distribution_att10 IN VARCHAR2,
111 distribution_att11 IN VARCHAR2, distribution_att12 IN VARCHAR2,
112 distribution_att13 IN VARCHAR2, distribution_att14 IN VARCHAR2,
113 distribution_att15 IN VARCHAR2,
114 x_expenditure_item_date IN DATE,
115 x_expenditure_organization_id IN NUMBER,
116 x_expenditure_type IN VARCHAR2,
117 x_item_id IN NUMBER,
118 x_line_type_id IN NUMBER,
119 x_result_billable_flag IN VARCHAR2,
120 x_agent_id IN NUMBER,
121 x_project_id IN NUMBER,
122 x_from_header_id IN NUMBER,
123 x_from_line_id IN NUMBER,
124 x_from_type_lookup_code IN VARCHAR2,
125 x_task_id IN NUMBER,
126 x_deliver_to_person_id IN NUMBER,
127 x_type_lookup_code IN VARCHAR2,
128 x_vendor_id IN NUMBER,
129 -- B1548597 Common Receiving RVK
130 x_vendor_site_id IN NUMBER,
131 x_wip_entity_id IN NUMBER,
132 x_wip_entity_type IN VARCHAR2,
133 x_wip_line_id IN NUMBER,
134 x_wip_operation_seq_num IN NUMBER,
135 x_wip_repetitive_schedule_id IN NUMBER,
136 x_wip_resource_seq_num IN NUMBER,
137
138 --< Shared Proc FPJ Start >
139 x_account_generation_flow_type IN VARCHAR2,
140 x_ship_to_ou_coa_id IN NUMBER, -- DOU's COA ID
141 x_ship_to_ou_id IN NUMBER, -- DOU's org ID
142 x_purchasing_ou_id IN NUMBER, -- POU's org ID
143 x_transaction_flow_header_id IN NUMBER,
144 x_is_SPS_distribution IN BOOLEAN,
145 x_dest_charge_account_id IN NUMBER,
146 x_dest_variance_account_id IN NUMBER,
147 --< Shared Proc FPJ End >
148 p_func_unit_price IN NUMBER, --<BUG 3407630>, Bug 3463242
149 p_distribution_type IN VARCHAR2, --<Complex Work R12>
150 p_payment_type IN VARCHAR2, --<Complex Work R12>
151 p_clm_misc_loa IN VARCHAR2 --<Clm Fed Fields>
152 )
153 IS
154 --< Shared Proc FPJ Start >
155 l_bom_resource_code bom_resources.resource_code%TYPE := '';
156 l_bom_resource_unit bom_resources.unit_of_measure%TYPE := '';
157 l_entity_name wip_entities.wip_entity_name%TYPE := '';
158 l_bom_cost_element_id NUMBER;
159 l_wip_entity_type NUMBER;
160 --< Shared Proc FPJ End >
161
162 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
163 l_api_name CONSTANT VARCHAR2(100) := 'set_ag_wf_attributes';
164 l_progress VARCHAR2(10) := '000';
165 BEGIN
166
167 IF g_debug_stmt THEN
168 PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
169 END IF;
170
171 -- Initialize workflow item attributes
172
173 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
174 itemkey => wf_itemkey,
175 aname => 'CHART_OF_ACCOUNTS_ID',
176 avalue => x_coa_id );
177
178 --< Shared Proc FPJ Start >
179 -- If x_bom_cost_element_id is NULL(e.g.in autocreate/PDOI for shopfloor items),
180 -- initialize it before initializing the workflow item attribute:
181
182 IF x_bom_cost_element_id IS NULL THEN
183 outside_proc_sv.get_resource_defaults(
184 x_bom_resource_id => x_bom_resource_id,
185 x_dest_org_id => x_destination_organization_id,
186 x_bom_resource_code => l_bom_resource_code,
187 x_bom_resource_unit => l_bom_resource_unit,
188 x_bom_cost_element_id => l_bom_cost_element_id);
189
190 po_wf_util_pkg.SetItemAttrNumber( itemtype => itemtype,
191 itemkey => wf_itemkey,
192 aname => 'BOM_COST_ELEMENT_ID',
193 avalue => l_bom_cost_element_id );
194 ELSE
195 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
196 itemkey => wf_itemkey,
197 aname => 'BOM_COST_ELEMENT_ID',
198 avalue => x_bom_cost_element_id );
199 END IF;
200 --< Shared Proc FPJ End >
201
202 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
203 itemkey => wf_itemkey,
204 aname => 'BOM_RESOURCE_ID',
205 avalue => x_bom_resource_id );
206 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
207 itemkey => wf_itemkey,
208 aname => 'CATEGORY_ID',
209 avalue => x_category_id );
210 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
211 itemkey => wf_itemkey,
212 aname => 'DELIVER_TO_LOCATION_ID',
213 avalue => x_deliver_to_location_id );
214 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
215 itemkey => wf_itemkey,
216 aname => 'DESTINATION_ORGANIZATION_ID',
217 avalue => x_destination_organization_id );
218 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
219 itemkey => wf_itemkey,
220 aname => 'DESTINATION_SUBINVENTORY',
221 avalue => x_destination_subinventory );
222 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
223 itemkey => wf_itemkey,
224 aname => 'DESTINATION_TYPE_CODE',
225 avalue => x_destination_type_code );
226 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
227 itemkey => wf_itemkey,
228 aname => 'PO_ENCUMBRANCE_FLAG',
229 avalue => x_po_encumberance_flag );
230
231 -- Header
232
233 If header_att1 is not null then
234 begin
235 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
236 itemkey => wf_itemkey,
237 aname => 'HEADER_ATT1',
238 avalue => header_att1 );
239 exception when others then
240 null;
241 end;
242 end if;
243
244 If header_att2 is not null then
245 begin
246 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
247 itemkey => wf_itemkey,
248 aname => 'HEADER_ATT2',
249 avalue => header_att2 );
250 exception when others then
251 null;
252 end;
253 end if;
254
255 If header_att3 is not null then
256 begin
257 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
258 itemkey => wf_itemkey,
259 aname => 'HEADER_ATT3',
260 avalue => header_att3 );
261 exception when others then
262 null;
263 end;
264 end if;
265
266 If header_att4 is not null then
267 begin
268 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
269 itemkey => wf_itemkey,
270 aname => 'HEADER_ATT4',
271 avalue => header_att4 );
272 exception when others then
273 null;
274 end;
275 end if;
276
277 If header_att5 is not null then
278 begin
279 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
280 itemkey => wf_itemkey,
281 aname => 'HEADER_ATT5',
282 avalue => header_att5 );
283 exception when others then
284 null;
285 end;
286 end if;
287
288 If header_att6 is not null then
289 begin
290 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
291 itemkey => wf_itemkey,
292 aname => 'HEADER_ATT6',
293 avalue => header_att6 );
294 exception when others then
295 null;
296 end;
297 end if;
298
299 If header_att7 is not null then
300 begin
301 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
302 itemkey => wf_itemkey,
303 aname => 'HEADER_ATT7',
304 avalue => header_att7 );
305 exception when others then
306 null;
307 end;
308 end if;
309
310 If header_att8 is not null then
311 begin
312 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
313 itemkey => wf_itemkey,
314 aname => 'HEADER_ATT8',
315 avalue => header_att8 );
316 exception when others then
317 null;
318 end;
319 end if;
320
321 If header_att9 is not null then
322 begin
323 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
324 itemkey => wf_itemkey,
325 aname => 'HEADER_ATT9',
326 avalue => header_att9 );
327 exception when others then
328 null;
329 end;
330 end if;
331
332 If header_att10 is not null then
333 begin
334 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
335 itemkey => wf_itemkey,
336 aname => 'HEADER_ATT10',
337 avalue => header_att10 );
338 exception when others then
339 null;
340 end;
341 end if;
342
343 If header_att11 is not null then
344 begin
345 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
346 itemkey => wf_itemkey,
347 aname => 'HEADER_ATT11',
348 avalue => header_att11 );
349 exception when others then
350 null;
351 end;
352 end if;
353
354 If header_att12 is not null then
355 begin
356 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
357 itemkey => wf_itemkey,
358 aname => 'HEADER_ATT12',
359 avalue => header_att12 );
360 exception when others then
361 null;
362 end;
363 end if;
364
365 If header_att13 is not null then
366 begin
367 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
368 itemkey => wf_itemkey,
369 aname => 'HEADER_ATT13',
370 avalue => header_att13 );
371 exception when others then
372 null;
373 end;
374 end if;
375
376 If header_att14 is not null then
377 begin
378 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
379 itemkey => wf_itemkey,
380 aname => 'HEADER_ATT14',
381 avalue => header_att14 );
382 exception when others then
383 null;
384 end;
385 end if;
386
387 If header_att15 is not null then
388 begin
389 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
390 itemkey => wf_itemkey,
391 aname => 'HEADER_ATT15',
392 avalue => header_att15 );
393 exception when others then
394 null;
395 end;
396 end if;
397
398 -- Line
399
400 If line_att1 is not null then
401 begin
402 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
403 itemkey => wf_itemkey,
404 aname => 'LINE_ATT1',
405 avalue => line_att1 );
406 exception when others then
407 null;
408 end;
409 end if;
410
411 If line_att2 is not null then
412 begin
413 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
414 itemkey => wf_itemkey,
415 aname => 'LINE_ATT2',
416 avalue => line_att2 );
417 exception when others then
418 null;
419 end;
420 end if;
421
422 If line_att3 is not null then
423 begin
424 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
425 itemkey => wf_itemkey,
426 aname => 'LINE_ATT3',
427 avalue => line_att3 );
428 exception when others then
429 null;
430 end;
431 end if;
432
433 If line_att4 is not null then
434 begin
435 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
436 itemkey => wf_itemkey,
437 aname => 'LINE_ATT4',
438 avalue => line_att4 );
439 exception when others then
440 null;
441 end;
442 end if;
443
444 If line_att5 is not null then
445 begin
446 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
447 itemkey => wf_itemkey,
448 aname => 'LINE_ATT5',
449 avalue => line_att5 );
450 exception when others then
451 null;
452 end;
453 end if;
454
455 If line_att6 is not null then
456 begin
457 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
458 itemkey => wf_itemkey,
459 aname => 'LINE_ATT6',
460 avalue => line_att6 );
461 exception when others then
462 null;
463 end;
464 end if;
465
466 If line_att7 is not null then
467 begin
468 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
469 itemkey => wf_itemkey,
470 aname => 'LINE_ATT7',
471 avalue => line_att7 );
472 exception when others then
473 null;
474 end;
475 end if;
476
477 If line_att8 is not null then
478 begin
479 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
480 itemkey => wf_itemkey,
481 aname => 'LINE_ATT8',
482 avalue => line_att8 );
483 exception when others then
484 null;
485 end;
486 end if;
487
488 If line_att9 is not null then
489 begin
490 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
491 itemkey => wf_itemkey,
492 aname => 'LINE_ATT9',
493 avalue => line_att9 );
494 exception when others then
495 null;
496 end;
497 end if;
498
499 If line_att10 is not null then
500 begin
501 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
502 itemkey => wf_itemkey,
503 aname => 'LINE_ATT10',
504 avalue => line_att10 );
505 exception when others then
506 null;
507 end;
508 end if;
509
510 If line_att11 is not null then
511 begin
512 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
513 itemkey => wf_itemkey,
514 aname => 'LINE_ATT11',
515 avalue => line_att11 );
516 exception when others then
517 null;
518 end;
519 end if;
520
521 If line_att12 is not null then
522 begin
523 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
524 itemkey => wf_itemkey,
525 aname => 'LINE_ATT12',
526 avalue => line_att12 );
527 exception when others then
528 null;
529 end;
530 end if;
531
532 If line_att13 is not null then
533 begin
534 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
535 itemkey => wf_itemkey,
536 aname => 'LINE_ATT13',
537 avalue => line_att13 );
538 exception when others then
539 null;
540 end;
541 end if;
542
543 If line_att14 is not null then
544 begin
545 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
546 itemkey => wf_itemkey,
547 aname => 'LINE_ATT14',
548 avalue => line_att14 );
549 exception when others then
550 null;
551 end;
552 end if;
553
554 If line_att15 is not null then
555 begin
556 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
557 itemkey => wf_itemkey,
558 aname => 'LINE_ATT15',
559 avalue => line_att15 );
560 exception when others then
561 null;
562 end;
563 end if;
564
565 -- shipment
566
567 If shipment_att1 is not null then
568 begin
569 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
570 itemkey => wf_itemkey,
571 aname => 'SHIPMENT_ATT1',
572 avalue => shipment_att1 );
573 exception when others then
574 null;
575 end;
576 end if;
577
578 If shipment_att2 is not null then
579 begin
580 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
581 itemkey => wf_itemkey,
582 aname => 'SHIPMENT_ATT2',
583 avalue => shipment_att2 );
584 exception when others then
585 null;
586 end;
587 end if;
588
589 If shipment_att3 is not null then
590 begin
591 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
592 itemkey => wf_itemkey,
593 aname => 'SHIPMENT_ATT3',
594 avalue => shipment_att3 );
595 exception when others then
596 null;
597 end;
598 end if;
599
600 If shipment_att4 is not null then
601 begin
602 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
603 itemkey => wf_itemkey,
604 aname => 'SHIPMENT_ATT4',
605 avalue => shipment_att4 );
606 exception when others then
607 null;
608 end;
609 end if;
610
611 If shipment_att5 is not null then
612 begin
613 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
614 itemkey => wf_itemkey,
615 aname => 'SHIPMENT_ATT5',
616 avalue => shipment_att5 );
617 exception when others then
618 null;
619 end;
620 end if;
621
622 If shipment_att6 is not null then
623 begin
624 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
625 itemkey => wf_itemkey,
626 aname => 'SHIPMENT_ATT6',
627 avalue => shipment_att6 );
628 exception when others then
629 null;
630 end;
631 end if;
632
633 If shipment_att7 is not null then
634 begin
635 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
636 itemkey => wf_itemkey,
637 aname => 'SHIPMENT_ATT7',
638 avalue => shipment_att7 );
639 exception when others then
640 null;
641 end;
642 end if;
643
644 If shipment_att8 is not null then
645 begin
646 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
647 itemkey => wf_itemkey,
648 aname => 'SHIPMENT_ATT8',
649 avalue => shipment_att8 );
650 exception when others then
651 null;
652 end;
653 end if;
654
655 If shipment_att9 is not null then
656 begin
657 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
658 itemkey => wf_itemkey,
659 aname => 'SHIPMENT_ATT9',
660 avalue => shipment_att9 );
661 exception when others then
662 null;
663 end;
664 end if;
665
666 If shipment_att10 is not null then
667 begin
668 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
669 itemkey => wf_itemkey,
670 aname => 'SHIPMENT_ATT10',
671 avalue => shipment_att10 );
672 exception when others then
673 null;
674 end;
675 end if;
676
677 If shipment_att11 is not null then
678 begin
679 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
680 itemkey => wf_itemkey,
681 aname => 'SHIPMENT_ATT11',
682 avalue => shipment_att11 );
683 exception when others then
684 null;
685 end;
686 end if;
687
688 If shipment_att12 is not null then
689 begin
690 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
691 itemkey => wf_itemkey,
692 aname => 'SHIPMENT_ATT12',
693 avalue => shipment_att12 );
694 exception when others then
695 null;
696 end;
697 end if;
698
699 If shipment_att13 is not null then
700 begin
701 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
702 itemkey => wf_itemkey,
703 aname => 'SHIPMENT_ATT13',
704 avalue => shipment_att13 );
705 exception when others then
706 null;
707 end;
708 end if;
709
710 If shipment_att14 is not null then
711 begin
712 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
713 itemkey => wf_itemkey,
714 aname => 'SHIPMENT_ATT14',
715 avalue => shipment_att14 );
716 exception when others then
717 null;
718 end;
719 end if;
720
721 If shipment_att15 is not null then
722 begin
723 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
724 itemkey => wf_itemkey,
725 aname => 'SHIPMENT_ATT15',
726 avalue => shipment_att15 );
727 exception when others then
728 null;
729 end;
730 end if;
731
732 -- Distribution
733
734 If distribution_att1 is not null then
735 begin
736 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
737 itemkey => wf_itemkey,
738 aname => 'DISTRIBUTION_ATT1',
739 avalue => distribution_att1 );
740 exception when others then
741 null;
742 end;
743 end if;
744
745 If distribution_att2 is not null then
746 begin
747 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
748 itemkey => wf_itemkey,
749 aname => 'DISTRIBUTION_ATT2',
750 avalue => distribution_att2 );
751 exception when others then
752 null;
753 end;
754 end if;
755
756 If distribution_att3 is not null then
757 begin
758 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
759 itemkey => wf_itemkey,
760 aname => 'DISTRIBUTION_ATT3',
761 avalue => distribution_att3 );
762 exception when others then
763 null;
764 end;
765 end if;
766
767 If distribution_att4 is not null then
768 begin
769 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
770 itemkey => wf_itemkey,
771 aname => 'DISTRIBUTION_ATT4',
772 avalue => distribution_att4 );
773 exception when others then
774 null;
775 end;
776 end if;
777
778 If distribution_att5 is not null then
779 begin
780 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
781 itemkey => wf_itemkey,
782 aname => 'DISTRIBUTION_ATT5',
783 avalue => distribution_att5 );
784 exception when others then
785 null;
786 end;
787 end if;
788
789 If distribution_att6 is not null then
790 begin
791 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
792 itemkey => wf_itemkey,
793 aname => 'DISTRIBUTION_ATT6',
794 avalue => distribution_att6 );
795 exception when others then
796 null;
797 end;
798 end if;
799
800 If distribution_att7 is not null then
801 begin
802 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
803 itemkey => wf_itemkey,
804 aname => 'DISTRIBUTION_ATT7',
805 avalue => distribution_att7 );
806 exception when others then
807 null;
808 end;
809 end if;
810
811 If distribution_att8 is not null then
812 begin
813 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
814 itemkey => wf_itemkey,
815 aname => 'DISTRIBUTION_ATT8',
816 avalue => distribution_att8 );
817 exception when others then
818 null;
819 end;
820 end if;
821
822 If distribution_att9 is not null then
823 begin
824 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
825 itemkey => wf_itemkey,
826 aname => 'DISTRIBUTION_ATT9',
827 avalue => distribution_att9 );
828 exception when others then
829 null;
830 end;
831 end if;
832
833 If distribution_att10 is not null then
834 begin
835 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
836 itemkey => wf_itemkey,
837 aname => 'DISTRIBUTION_ATT10',
838 avalue => distribution_att10 );
839 exception when others then
840 null;
841 end;
842 end if;
843
844 If distribution_att11 is not null then
845 begin
846 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
847 itemkey => wf_itemkey,
848 aname => 'DISTRIBUTION_ATT11',
849 avalue => distribution_att11 );
850 exception when others then
851 null;
852 end;
853 end if;
854
855 If distribution_att12 is not null then
856 begin
857 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
858 itemkey => wf_itemkey,
859 aname => 'DISTRIBUTION_ATT12',
860 avalue => distribution_att12 );
861 exception when others then
862 null;
863 end;
864 end if;
865
866 If distribution_att13 is not null then
867 begin
868 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
869 itemkey => wf_itemkey,
870 aname => 'DISTRIBUTION_ATT13',
871 avalue => distribution_att13 );
872 exception when others then
873 null;
874 end;
875 end if;
876
877 If distribution_att14 is not null then
878 begin
879 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
880 itemkey => wf_itemkey,
881 aname => 'DISTRIBUTION_ATT14',
882 avalue => distribution_att14 );
883 exception when others then
884 null;
885 end;
886 end if;
887
888 If distribution_att15 is not null then
889 begin
890 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
891 itemkey => wf_itemkey,
892 aname => 'DISTRIBUTION_ATT15',
893 avalue => distribution_att15 );
894 exception when others then
895 null;
896 end;
897 end if;
898
899 po_wf_util_pkg.SetItemAttrDate ( itemtype => itemtype,
900 itemkey => wf_itemkey,
901 aname => 'EXPENDITURE_ITEM_DATE',
902 avalue => x_expenditure_item_date );
903 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
904 itemkey => wf_itemkey,
905 aname => 'EXPENDITURE_ORGANIZATION_ID',
906 avalue => x_expenditure_organization_id );
907 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
908 itemkey => wf_itemkey,
909 aname => 'EXPENDITURE_TYPE',
910 avalue => x_expenditure_type );
911 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
912 itemkey => wf_itemkey,
913 aname => 'ITEM_ID',
914 avalue => x_item_id );
915 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
916 itemkey => wf_itemkey,
917 aname => 'LINE_TYPE_ID',
918 avalue => x_line_type_id );
919 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
920 itemkey => wf_itemkey,
921 aname => 'PA_BILLABLE_FLAG',
922 avalue => x_result_billable_flag );
923 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
924 itemkey => wf_itemkey,
925 aname => 'PREPARER_ID',
926 avalue => x_agent_id );
927 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
928 itemkey => wf_itemkey,
929 aname => 'PROJECT_ID',
930 avalue => x_project_id );
931 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
932 itemkey => wf_itemkey,
933 aname => 'SOURCE_DOCUMENT_HEADER_ID',
934 avalue => x_from_header_id);
935 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
936 itemkey => wf_itemkey,
937 aname => 'SOURCE_DOCUMENT_LINE_ID',
938 avalue => x_from_line_id );
939 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
940 itemkey => wf_itemkey,
941 aname => 'SOURCE_DOCUMENT_TYPE_CODE',
942 avalue => x_from_type_lookup_code );
943 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
944 itemkey => wf_itemkey,
945 aname => 'TASK_ID',
946 avalue => x_task_id );
947 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
948 itemkey => wf_itemkey,
949 aname => 'TO_PERSON_ID',
950 avalue => x_deliver_to_person_id );
951 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
952 itemkey => wf_itemkey,
953 aname => 'TYPE_LOOKUP_CODE',
954 avalue => x_type_lookup_code );
955 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
956 itemkey => wf_itemkey,
957 aname => 'VENDOR_ID',
958 avalue => x_vendor_id );
959 -- B1548597 Common Receiving RVK
960 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
961 itemkey => wf_itemkey,
962 aname => 'VENDOR_SITE_ID',
963 avalue => x_vendor_site_id );
964 -- B1548597 Common Receiving End RVK
965 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
966 itemkey => wf_itemkey,
967 aname => 'WIP_ENTITY_ID',
968 avalue => x_wip_entity_id );
969
970 --< Shared Proc FPJ Start >
971 -- If x_wip_entity_type is NULL(e.g. autocreate shopfloor items),
972 -- initialize it before initializing the workflow item attribute:
973
974 IF x_wip_entity_type IS NULL THEN
975 outside_proc_sv.get_entity_defaults(
976 x_entity_id => x_wip_entity_id,
977 x_dest_org_id => x_destination_organization_id,
978 x_entity_name => l_entity_name,
979 x_entity_type => l_wip_entity_type);
980
981 po_wf_util_pkg.SetItemAttrText( itemtype => itemtype,
982 itemkey => wf_itemkey,
983 aname => 'WIP_ENTITY_TYPE',
984 avalue => l_wip_entity_type );
985 ELSE
986 po_wf_util_pkg.SetItemAttrText( itemtype => itemtype,
987 itemkey => wf_itemkey,
988 aname => 'WIP_ENTITY_TYPE',
989 avalue => x_wip_entity_type );
990 END IF;
991 --< Shared Proc FPJ End >
992
993 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
994 itemkey => wf_itemkey,
995 aname => 'WIP_LINE_ID',
996 avalue => x_wip_line_id );
997 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
998 itemkey => wf_itemkey,
999 aname => 'WIP_OPERATION_SEQ_NUM',
1000 avalue => x_wip_operation_seq_num );
1001 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1002 itemkey => wf_itemkey,
1003 aname => 'WIP_REPETITIVE_SCHEDULE_ID',
1004 avalue => x_wip_repetitive_schedule_id );
1005 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1006 itemkey => wf_itemkey,
1007 aname => 'WIP_RESOURCE_SEQ_NUM',
1008 avalue => x_wip_resource_seq_num );
1009
1010 --< Shared Proc FPJ Start >
1011 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
1012 itemkey => wf_itemkey,
1013 aname => 'ACCOUNT_GENERATION_FLOW_TYPE',
1014 avalue => x_account_generation_flow_type );
1015 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1016 itemkey => wf_itemkey,
1017 aname => 'SHIP_TO_OU_COA_ID',
1018 avalue => x_ship_to_ou_coa_id );
1019 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1020 itemkey => wf_itemkey,
1021 aname => 'SHIP_TO_OU_ID',
1022 avalue => x_ship_to_ou_id );
1023 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1024 itemkey => wf_itemkey,
1025 aname => 'PURCHASING_OU_ID',
1026 avalue => x_purchasing_ou_id );
1027 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1028 itemkey => wf_itemkey,
1029 aname => 'TRANSACTION_FLOW_HEADER_ID',
1030 avalue => x_transaction_flow_header_id );
1031 IF (x_is_SPS_distribution = TRUE) THEN
1032 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
1033 itemkey => wf_itemkey,
1034 aname => 'IS_SPS_DISTRIBUTION',
1035 avalue => 'Y' );
1036 ELSE
1037 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
1038 itemkey => wf_itemkey,
1039 aname => 'IS_SPS_DISTRIBUTION',
1040 avalue => 'N' );
1041 END IF;
1042 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1043 itemkey => wf_itemkey,
1044 aname => 'DEST_CHARGE_ACCOUNT_ID',
1045 avalue => x_dest_charge_account_id );
1046 po_wf_util_pkg.SetItemAttrNumber ( itemtype => itemtype,
1047 itemkey => wf_itemkey,
1048 aname => 'DEST_VARIANCE_ACCOUNT_ID',
1049 avalue => x_dest_variance_account_id );
1050 --< Shared Proc FPJ End >
1051
1052 --<Clm Fed Fields: Passing Misc LOA to workflow>
1053 po_wf_util_pkg.SetItemAttrText ( itemtype => itemtype,
1054 itemkey => wf_itemkey,
1055 aname => 'CLM_MISC_LOA',
1056 avalue => p_clm_misc_loa );
1057 --<End Clm Fed Fields: Passing Misc LOA to workflow>
1058
1059 --<BUG 3407630 START>
1060 --Call WF API to set the unit_price attribute to the PO line / release
1061 --shipment price, converted to the functional currency (Bug 3463242).
1062 --unit_price will be taken into consideration when generating accounts.
1063
1064 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => itemtype,
1065 itemkey => wf_itemkey,
1066 aname => 'UNIT_PRICE',
1067 -- Bug 3463242:
1068 avalue => p_func_unit_price );
1069
1070
1071 -- <Complex Work R12 START>: set the WF attributes that indicate
1072 -- if this distribution belongs to a financing pay item or an
1073 -- advance. Note: in R12, distribution_type param will be null unless
1074 -- coming from the HTML UIs, but HTML is the only place we will be
1075 -- creating 'PREPAYMENT' type distributions
1076 IF nvl(p_distribution_type, 'NOT PREPAYMENT') = 'PREPAYMENT' THEN
1077
1078 l_progress := '010';
1079
1080 IF p_payment_type = 'ADVANCE' THEN
1081 --the distribution belongs to an advance, not a financing pay item
1082 l_progress := '020';
1083
1084 po_wf_util_pkg.SetItemAttrText (
1085 itemtype => itemtype,
1086 itemkey => wf_itemkey,
1087 aname => 'IS_ADVANCE_DISTRIBUTION',
1088 avalue => 'Y' );
1089
1090 po_wf_util_pkg.SetItemAttrText (
1091 itemtype => itemtype,
1092 itemkey => wf_itemkey,
1093 aname => 'IS_FINANCING_DISTRIBUTION',
1094 avalue => 'N' );
1095
1096 ELSE
1097 --distr type is prepayment, but payment type is not advance
1098 --this means the distribution belongs to a financing pay item
1099 l_progress := '030';
1100
1101 po_wf_util_pkg.SetItemAttrText (
1102 itemtype => itemtype,
1103 itemkey => wf_itemkey,
1104 aname => 'IS_ADVANCE_DISTRIBUTION',
1105 avalue => 'N' );
1106
1107 po_wf_util_pkg.SetItemAttrText (
1108 itemtype => itemtype,
1109 itemkey => wf_itemkey,
1110 aname => 'IS_FINANCING_DISTRIBUTION',
1111 avalue => 'Y' );
1112
1113 END IF; --is payment type advance or not
1114
1115 ELSE
1116 -- distribution type is not prepayment
1117 -- the distribution belongs to neither an advance nor a
1118 -- financing pay item
1119 l_progress := '040';
1120
1121 po_wf_util_pkg.SetItemAttrText (
1122 itemtype => itemtype,
1123 itemkey => wf_itemkey,
1124 aname => 'IS_ADVANCE_DISTRIBUTION',
1125 avalue => 'N' );
1126
1127 po_wf_util_pkg.SetItemAttrText (
1128 itemtype => itemtype,
1129 itemkey => wf_itemkey,
1130 aname => 'IS_FINANCING_DISTRIBUTION',
1131 avalue => 'N' );
1132
1133 END IF; --is distribution type check
1134 -- <Complex Work R12 END>
1135
1136
1137 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
1138 l_progress := '050';
1139
1140 IF g_debug_stmt THEN
1141 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1142 p_token => l_progress,
1143 p_message => 'Set WF item UNIT_PRICE to ' ||
1144 PO_WF_UTIL_PKG.GetItemAttrNumber (
1145 itemtype => itemtype,
1146 itemkey => wf_itemkey,
1147 aname => 'UNIT_PRICE')
1148 );
1149 END IF;
1150
1151 --<BUG 3407630 END>
1152
1153 l_progress := '060';
1154
1155 -- Done setting WF item attributes
1156 IF g_debug_stmt THEN
1157 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
1158 END IF;
1159
1160 END set_ag_wf_attributes;
1161
1162 PROCEDURE derive_pa_params(itemtype IN VARCHAR2,
1163 wf_itemkey IN VARCHAR2,
1164 x_project_id IN NUMBER,
1165 x_task_id IN NUMBER,
1166 x_expenditure_type IN VARCHAR2,
1167 x_vendor_id IN NUMBER,
1168 x_expenditure_organization_id IN NUMBER,
1169 x_expenditure_item_date IN DATE,
1170 x_award_id IN NUMBER)
1171 IS
1172 -- PA project accounting parameters to the WF
1173 l_class_code PA_CLASS_CODES.class_code%TYPE;
1174 l_direct_flag PA_PROJECT_TYPES_ALL.direct_flag%TYPE;
1175 l_expenditure_category PA_EXPENDITURE_CATEGORIES.expenditure_category%TYPE;
1176 l_expenditure_org_name HR_ORGANIZATION_UNITS.name%TYPE;
1177 l_project_number PA_PROJECTS_ALL.segment1%TYPE;
1178 l_project_organization_name HR_ORGANIZATION_UNITS.name%TYPE;
1179 l_project_organization_id HR_ORGANIZATION_UNITS.organization_id %TYPE;
1180 l_project_type PA_PROJECT_TYPES_ALL.project_type%TYPE;
1181 l_public_sector_flag PA_PROJECTS_ALL.public_sector_flag%TYPE;
1182 l_revenue_category PA_EXPENDITURE_TYPES.revenue_category_code%TYPE;
1183 -- Bug 16919294 pointing declaration of x_task
1184 -- to pa_tasks_expend_v
1185 l_task_number PA_TASKS_EXPEND_V.task_number%TYPE;
1186 l_task_organization_name HR_ORGANIZATION_UNITS.name%TYPE;
1187 l_task_organization_id HR_ORGANIZATION_UNITS.organization_id %TYPE;
1188 l_task_service_type PA_TASKS.service_type_code%TYPE;
1189 l_top_task_id PA_TASKS.task_id%TYPE;
1190 -- Bug 16919294 pointing declaration of x_task
1191 -- to pa_tasks_expend_v
1192 l_top_task_number PA_TASKS_EXPEND_V.task_number%TYPE;
1193 l_vendor_employee_id PER_PEOPLE_F.person_id%TYPE;
1194 l_vendor_employee_number PER_PEOPLE_F.employee_number%TYPE;
1195 l_vendor_type PO_VENDORS.vendor_type_lookup_code%TYPE;
1196
1197 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
1198 l_api_name CONSTANT VARCHAR2(100) := 'derive_pa_params';
1199 l_progress VARCHAR2(10) := '000';
1200
1201 BEGIN
1202
1203 IF g_debug_stmt THEN
1204 PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
1205 END IF;
1206
1207 -- Calling AP routine to get raw and derived parameters for project
1208 -- accounting accounts.
1209 IF (x_project_id IS NOT NULL) THEN
1210 BEGIN
1211 IF g_debug_stmt THEN
1212 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1213 p_token => l_progress,
1214 p_message => 'project_id = ' || x_project_id);
1215 END IF;
1216
1217 pa_acc_gen_wf_pkg.wf_acc_derive_params(
1218 p_project_id => x_project_id,
1219 p_task_id => x_task_id,
1220 p_expenditure_type => x_expenditure_type,
1221 p_vendor_id => x_vendor_id,
1222 p_expenditure_organization_id => x_expenditure_organization_id,
1223 p_expenditure_item_date => x_expenditure_item_date,
1224 x_class_code => l_class_code,
1225 x_direct_flag => l_direct_flag,
1226 x_expenditure_category => l_expenditure_category,
1227 x_expenditure_org_name => l_expenditure_org_name,
1228 x_project_number => l_project_number,
1229 x_project_organization_name => l_project_organization_name,
1230 x_project_organization_id => l_project_organization_id,
1231 x_project_type => l_project_type,
1232 x_public_sector_flag => l_public_sector_flag,
1233 x_revenue_category => l_revenue_category,
1234 x_task_number => l_task_number,
1235 x_task_organization_name => l_task_organization_name,
1236 x_task_organization_id => l_task_organization_id,
1237 x_task_service_type => l_task_service_type,
1238 x_top_task_id => l_top_task_id,
1239 x_top_task_number => l_top_task_number,
1240 x_vendor_employee_id => l_vendor_employee_id,
1241 x_vendor_employee_number => l_vendor_employee_number,
1242 x_vendor_type => l_vendor_type );
1243 EXCEPTION
1244 WHEN OTHERS THEN
1245 NULL;
1246 END;
1247
1248 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'CLASS_CODE',
1249 l_class_code);
1250 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'DIRECT_FLAG',
1251 l_direct_flag);
1252 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'EXPENDITURE_CATEGORY',
1253 l_expenditure_category);
1254 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'EXPENDITURE_ORG_NAME',
1255 l_expenditure_org_name);
1256 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'PROJECT_NUMBER',
1257 l_project_number);
1258 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'PROJECT_ORGANIZATION_NAME',
1259 l_project_organization_name);
1260 Call_WF_API_to_set_no_Att (ItemType, Wf_Itemkey,'PROJECT_ORGANIZATION_ID',
1261 l_project_organization_id);
1262 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'PROJECT_TYPE',
1263 l_project_type);
1264 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'PUBLIC_SECTOR_FLAG',
1265 l_public_sector_flag);
1266 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'REVENUE_CATEGORY',
1267 l_revenue_category);
1268 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'TASK_NUMBER',
1269 l_task_number);
1270 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'TASK_ORGANIZATION_NAME',
1271 l_task_organization_name);
1272 Call_WF_API_to_set_no_Att (ItemType, Wf_Itemkey, 'TASK_ORGANIZATION_ID',
1273 l_task_organization_id);
1274 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'TASK_SERVICE_TYPE',
1275 l_task_service_type);
1276 Call_WF_API_to_set_no_Att (ItemType, Wf_Itemkey, 'TOP_TASK_ID',
1277 l_top_task_id);
1278 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'TOP_TASK_NUMBER',
1279 l_top_task_number);
1280 Call_WF_API_to_set_no_Att (ItemType, Wf_Itemkey, 'VENDOR_EMPLOYEE_ID',
1281 l_vendor_employee_id);
1282 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'VENDOR_EMPLOYEE_NUMBER',
1283 l_vendor_employee_number);
1284 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'VENDOR_TYPE',
1285 l_vendor_type);
1286 -- OGM stores award_set id into award_id column and derives award_id
1287 -- from ADLs table.
1288 Call_WF_API_to_set_Att (ItemType, Wf_Itemkey, 'AWARD_SET_ID',
1289 X_Award_id); --OGM_0.0 change
1290 END IF; -- IF (x_project_id IS NOT NULL)
1291 -- done setting AP project accounting attributes.
1292
1293 IF g_debug_stmt THEN
1294 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
1295 END IF;
1296 END derive_pa_params;
1297
1298 /**************************************************************************
1299 * The following are the global APIs. *
1300 **************************************************************************/
1301 --
1302 -- This function is used to check if partial flex segments returned when
1303 -- building an expense account have any value for any segment. The function
1304 -- returns TRUE if all the flex segments returned are NULL, else it returns
1305 -- FALSE. This is used to determine if the segments returned from the AG
1306 -- (if any) should be copied into the charge account flex field or should
1307 -- the segment defaults be used instead when popping up the key flex LOV
1308 -- for the charge account. Note that if any segments are copied into the
1309 -- flex field (even if they are all null) the key flex will not bring up
1310 -- the segment defaults.
1311 --
1312
1313 FUNCTION all_returned_segments_null_sv(x_charge_account_flex VARCHAR2,
1314 x_coa_id NUMBER) RETURN Boolean
1315 IS
1316 number_of_segment NUMBER;
1317 segment_delimiter VARCHAR2(1);
1318 segments FND_FLEX_EXT.segmentArray;
1319 result BOOLEAN := TRUE;
1320 BEGIN
1321 segment_delimiter := FND_FLEX_EXT.get_delimiter(
1322 application_short_name => 'SQLGL',
1323 key_flex_code => 'GL#',
1324 structure_number => X_coa_id );
1325
1326 number_of_segment := FND_FLEX_EXT.breakup_segments(x_charge_account_flex,
1327 segment_delimiter,
1328 segments );
1329
1330 FOR i IN 1 .. segments.COUNT LOOP
1331 IF segments(i) IS NOT NULL THEN
1332 result := FALSE;
1333 EXIT;
1334 END IF;
1335 END LOOP;
1336
1337 RETURN result;
1338 END all_returned_segments_null_sv;
1339
1340 PROCEDURE generate_destination_accounts(
1341 itemtype IN VARCHAR2,
1342 wf_itemkey IN VARCHAR2,
1343 p_is_SPS_distribution IN BOOLEAN,
1344 x_insert_if_new IN BOOLEAN,
1345 x_account_generation_flow_type IN VARCHAR2,
1346 x_coa_id IN NUMBER,
1347 x_ship_to_ou_coa_id IN NUMBER,
1348 x_gl_encumbered_date IN DATE,
1349 x_dest_charge_account_id IN OUT NOCOPY NUMBER,
1350 x_dest_charge_account_flex IN OUT NOCOPY VARCHAR2,
1351 x_dest_charge_account_desc IN OUT NOCOPY VARCHAR2,
1352 x_dest_charge_success IN OUT NOCOPY BOOLEAN,
1353 x_dest_variance_account_id IN OUT NOCOPY NUMBER,
1354 x_dest_variance_account_flex IN OUT NOCOPY VARCHAR2,
1355 x_dest_variance_account_desc IN OUT NOCOPY VARCHAR2,
1356 x_dest_variance_success IN OUT NOCOPY BOOLEAN,
1357 x_success IN OUT NOCOPY BOOLEAN,
1358 FB_ERROR_MSG IN OUT NOCOPY VARCHAR2,
1359 x_new_combination IN OUT NOCOPY BOOLEAN)
1360 IS
1361 ccid GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1362 concat_segs VARCHAR2(2000);
1363 concat_ids VARCHAR2(240);
1364 concat_descrs VARCHAR2(2000);
1365 l_block_activity_label VARCHAR2(60);
1366 l_progress VARCHAR2(3); --< Shared Proc FPJ >
1367
1368 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
1369 l_api_name CONSTANT VARCHAR2(100) := 'generate_destination_accounts';
1370 BEGIN
1371
1372 IF g_debug_stmt THEN
1373 PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
1374 END IF;
1375
1376 l_progress := '000';
1377
1378 -- Call the following new code for either of the 2 cases:
1379 -- 1. The Account Generation Flow Type is DESTINATION ACCOUNTS, or
1380 -- 2. If its is a SPS distribution AND the POU's COA = DOU's COA. In this
1381 -- case, the key flexfield cache (which is specific to one COA) initialzed
1382 -- for PO account generation would be reused for generating the two
1383 -- destination accounts. The purpose is to optimize the workflow by not
1384 -- calling the initialize( ) function twice.
1385
1386 IF ( (x_account_generation_flow_type = g_destination_accounts) OR
1387 (p_is_SPS_distribution AND (x_coa_id = x_ship_to_ou_coa_id)) ) THEN --(
1388
1389 -- Call the GENERATE_PARTIAL function for the Destination Charge Account and
1390 -- the Destination Variance Accounts
1391
1392 -- If continuing in the first call to the WF then continue from the end
1393 -- of the PO Variance Account Generation, else initialize and begin from the
1394 -- start of the workflow.
1395 IF (x_coa_id = x_ship_to_ou_coa_id) THEN
1396 l_block_activity_label := 'BLOCK_DEST_CHARGE_ACC_GENERATE';
1397 ELSE
1398 l_block_activity_label := NULL;
1399 END IF;
1400
1401 IF g_debug_stmt THEN
1402 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1403 p_token => l_progress,
1404 p_message => 'Block Activity='||l_block_activity_label);
1405 END IF;
1406
1407 l_progress := '010';
1408
1409 -- Bug 1497909 : Set the encumbrance date for validation
1410 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
1411 itemkey => wf_itemkey,
1412 aname => 'ENCUMBRANCE_DATE',
1413 avalue => x_gl_encumbered_date);
1414
1415 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL (
1416 ItemType,
1417 Wf_Itemkey,
1418 'GENERATE_DEST_CHARGE_ACCOUNT',
1419 l_block_activity_label,
1420 x_insert_if_new,
1421 ccid,
1422 concat_segs,
1423 concat_ids,
1424 concat_descrs,
1425 FB_ERROR_MSG,
1426 x_new_combination);
1427
1428 x_dest_charge_success := x_success;
1429 x_dest_charge_account_id := ccid;
1430 x_dest_charge_account_flex := concat_segs;
1431 x_dest_charge_account_desc := concat_descrs;
1432
1433 IF g_debug_stmt THEN
1434 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1435 p_token => l_progress,
1436 p_message => 'dest_charge_account_id = '||
1437 x_dest_charge_account_id);
1438 END IF;
1439
1440
1441 IF x_dest_charge_account_id IS NULL OR
1442 x_dest_charge_account_id = 0 OR
1443 x_dest_charge_account_id = -1 THEN
1444
1445 l_progress := '020';
1446 x_dest_charge_account_id := NULL;
1447
1448 -- Complete the blocked workflow as it may be running in synch mode and
1449 -- cause problems for consequent account generation runs for this session.
1450 BEGIN
1451 fnd_message.clear;
1452
1453 IF g_debug_stmt THEN
1454 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1455 p_token => l_progress,
1456 p_message => 'Terminating the workflow because'||
1457 ' invalid dest charge account was generated.');
1458 END IF;
1459
1460 wf_engine.CompleteActivity(itemtype, wf_itemkey,
1461 'BLOCK_DEST_VAR_ACC_GENERATE', 'FAILURE');
1462 EXCEPTION
1463 WHEN OTHERS THEN
1464 IF g_debug_stmt THEN
1465 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1466 p_token => l_progress,
1467 p_message =>
1468 'Exception when completing WF for dest accounts '||
1469 'Item key='|| Wf_Itemkey);
1470 END IF;
1471
1472 IF g_debug_unexp THEN
1473 PO_DEBUG.debug_exc(p_log_head => g_log_head||l_api_name,
1474 p_progress => l_progress);
1475 END IF;
1476 END;
1477 END IF; -- IF (ccid IS NULL OR ccid = 0 OR ccid = -1 )
1478
1479 IF g_debug_stmt THEN
1480 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1481 p_token => l_progress,
1482 p_message =>
1483 'DESTINATION CHARGE ACCOUNT: ccid:' || to_char(ccid) ||
1484 ' concat_segs:' || concat_segs ||
1485 ' concat_ids:' || concat_ids || ' concat_descrs:' ||
1486 concat_descrs || ' FB_ERROR_MSG:' || FB_ERROR_MSG);
1487 END IF;
1488
1489 l_progress := '030';
1490 IF x_success THEN
1491 l_progress := '040';
1492 po_wf_util_pkg.SetItemAttrNumber(itemtype => itemtype,
1493 itemkey => wf_itemkey,
1494 aname => 'DEST_CHARGE_ACCOUNT_ID',
1495 avalue => x_dest_charge_account_id );
1496
1497 IF g_debug_stmt THEN
1498 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1499 p_token => l_progress,
1500 p_message => 'Generating Destination Variance Account...');
1501 END IF;
1502
1503 l_progress := '050';
1504
1505 -- Bug 1497909 : Set the encumbrance date for validation
1506 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
1507 itemkey => wf_itemkey,
1508 aname => 'ENCUMBRANCE_DATE',
1509 avalue => x_gl_encumbered_date);
1510
1511 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL (
1512 ItemType,
1513 Wf_Itemkey,
1514 'GENERATE_DEST_VARIANCE_ACCOUNT',
1515 'BLOCK_DEST_VAR_ACC_GENERATE',
1516 x_insert_if_new,
1517 ccid,
1518 concat_segs,
1519 concat_ids,
1520 concat_descrs,
1521 FB_ERROR_MSG,
1522 x_new_combination );
1523
1524 l_progress := '060';
1525 x_dest_variance_success := x_success;
1526 x_dest_variance_account_id := ccid;
1527 x_dest_variance_account_flex := concat_segs;
1528 x_dest_variance_account_desc := concat_descrs;
1529
1530 IF x_dest_variance_account_id IS NULL OR
1531 x_dest_variance_account_id = 0 OR
1532 x_dest_variance_account_id = -1 THEN
1533 x_dest_variance_account_id := NULL;
1534 END IF;
1535
1536 l_progress := '070';
1537 IF g_debug_stmt THEN
1538 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1539 p_token => l_progress,
1540 p_message =>
1541 'DESTINATION VARIANCE ACCOUNT: ccid:' || to_char(ccid) ||
1542 ' concat_segs:' || concat_segs
1543 || ' concat_ids:' || concat_ids || ' concat_descrs:' ||
1544 concat_descrs || ' FB_ERROR_MSG:' || FB_ERROR_MSG);
1545 END IF;
1546
1547
1548 l_progress := '080';
1549 IF x_success THEN
1550 l_progress := '090';
1551 po_wf_util_pkg.SetItemAttrNumber(itemtype => itemtype,
1552 itemkey => wf_itemkey,
1553 aname => 'DEST_VARIANCE_ACCOUNT_ID',
1554 avalue => x_dest_variance_account_id );
1555 END IF; -- IF x_success (DEST_VARIANCE_ACCOUNT)
1556 END IF; -- IF x_success (DEST_CHARGE_ACCOUNT)
1557
1558 l_progress := '100';
1559 IF (NOT x_success) THEN
1560 l_progress := '110';
1561 IF g_debug_stmt THEN
1562 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1563 p_token => l_progress,
1564 p_message =>
1565 'PO account generate failure for Destination Accounts: => '
1566 || FB_ERROR_MSG);
1567 END IF;
1568 END IF;
1569
1570 ELSE
1571 -- if the Destination Accounts are not meant to be generated at all
1572 -- then send them out as NULL's.
1573
1574 l_progress := '120';
1575 IF g_debug_stmt THEN
1576 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1577 p_token => l_progress,
1578 p_message => 'Destination Account Generation skipped...');
1579 END IF;
1580
1581
1582 x_dest_charge_success := TRUE;
1583
1584 -- Destination Charge Account can have a value when the
1585 -- dest_charge_account_flex is modified.Setting them to Null here will
1586 -- cause the value from user input to be lost.
1587 --x_dest_charge_account_id := NULL;
1588 --x_dest_charge_account_flex := NULL;
1589 --x_dest_charge_account_desc := NULL;
1590
1591 x_dest_variance_success := TRUE;
1592 x_dest_variance_account_id := NULL;
1593 x_dest_variance_account_flex := NULL;
1594 x_dest_variance_account_desc := NULL;
1595 END IF; -- IF ( (x_account_generation_flow_type = g_destination_accounts) OR
1596 -- (p_is_SPS_distribution AND (x_coa_id = x_ship_to_ou_coa_id)) )
1597
1598 l_progress := '140';
1599
1600 IF g_debug_stmt THEN
1601 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
1602 END IF;
1603 EXCEPTION
1604 WHEN OTHERS THEN
1605 po_message_s.sql_error('generate_destination_accounts',
1606 l_progress, sqlcode);
1607 IF g_debug_unexp THEN
1608 PO_DEBUG.debug_exc(p_log_head => g_log_head||l_api_name,
1609 p_progress => l_progress);
1610 END IF;
1611 RAISE;
1612 END generate_destination_accounts;
1613
1614 --
1615 -- Start_Workflow
1616 -- Generates the itemkey, sets up the Item Attributes,
1617 -- then starts the workflow process.
1618 --
1619 FUNCTION Start_Workflow_internal (
1620
1621 --< Shared Proc FPJ Start >
1622 x_account_generation_flow_type IN VARCHAR2,
1623 x_ship_to_ou_coa_id IN NUMBER, -- DOU's COA ID
1624 x_ship_to_ou_id IN NUMBER, -- DOU's org ID
1625 x_purchasing_ou_id IN NUMBER, -- POU's org ID
1626 x_transaction_flow_header_id IN NUMBER,
1627 x_is_SPS_distribution IN BOOLEAN,
1628 x_dest_charge_success IN OUT NOCOPY BOOLEAN,
1629 x_dest_variance_success IN OUT NOCOPY BOOLEAN,
1630 x_dest_charge_account_id IN OUT NOCOPY NUMBER,
1631 x_dest_variance_account_id IN OUT NOCOPY NUMBER,
1632 x_dest_charge_account_desc IN OUT NOCOPY VARCHAR2,
1633 x_dest_variance_account_desc IN OUT NOCOPY VARCHAR2,
1634 x_dest_charge_account_flex IN OUT NOCOPY VARCHAR2,
1635 x_dest_variance_account_flex IN OUT NOCOPY VARCHAR2,
1636 --< Shared Proc FPJ End >
1637
1638 x_charge_success IN OUT NOCOPY BOOLEAN,
1639 x_budget_success IN OUT NOCOPY BOOLEAN,
1640 x_accrual_success IN OUT NOCOPY BOOLEAN,
1641 x_variance_success IN OUT NOCOPY BOOLEAN,
1642 x_code_combination_id IN OUT NOCOPY NUMBER,
1643 x_budget_account_id IN OUT NOCOPY NUMBER,
1644 x_accrual_account_id IN OUT NOCOPY NUMBER,
1645 x_variance_account_id IN OUT NOCOPY NUMBER,
1646 x_charge_account_flex IN OUT NOCOPY VARCHAR2,
1647 x_budget_account_flex IN OUT NOCOPY VARCHAR2,
1648 x_accrual_account_flex IN OUT NOCOPY VARCHAR2,
1649 x_variance_account_flex IN OUT NOCOPY VARCHAR2,
1650 x_charge_account_desc IN OUT NOCOPY VARCHAR2,
1651 x_budget_account_desc IN OUT NOCOPY VARCHAR2,
1652 x_accrual_account_desc IN OUT NOCOPY VARCHAR2,
1653 x_variance_account_desc IN OUT NOCOPY VARCHAR2,
1654 x_coa_id NUMBER,
1655 x_bom_resource_id NUMBER,
1656 x_bom_cost_element_id NUMBER,
1657 x_category_id NUMBER,
1658 x_destination_type_code VARCHAR2,
1659 x_deliver_to_location_id NUMBER,
1660 x_destination_organization_id NUMBER,
1661 x_destination_subinventory VARCHAR2,
1662 x_expenditure_type VARCHAR2,
1663 x_expenditure_organization_id NUMBER,
1664 x_expenditure_item_date DATE,
1665 x_item_id NUMBER,
1666 x_line_type_id NUMBER,
1667 x_result_billable_flag VARCHAR2,
1668 x_agent_id NUMBER,
1669 x_project_id NUMBER,
1670 x_from_type_lookup_code VARCHAR2,
1671 x_from_header_id NUMBER,
1672 x_from_line_id NUMBER,
1673 x_task_id NUMBER,
1674 x_deliver_to_person_id NUMBER,
1675 x_type_lookup_code VARCHAR2,
1676 x_vendor_id NUMBER,
1677 x_wip_entity_id NUMBER,
1678 x_wip_entity_type VARCHAR2,
1679 x_wip_line_id NUMBER,
1680 x_wip_repetitive_schedule_id NUMBER,
1681 x_wip_operation_seq_num NUMBER,
1682 x_wip_resource_seq_num NUMBER,
1683 x_po_encumberance_flag VARCHAR2,
1684 x_gl_encumbered_date DATE,
1685
1686 -- because of changes due to WF synch mode this input parameter is not used.
1687 wf_itemkey IN OUT NOCOPY VARCHAR2,
1688 x_new_combination IN OUT NOCOPY BOOLEAN,
1689
1690 header_att1 VARCHAR2, header_att2 VARCHAR2, header_att3 VARCHAR2,
1691 header_att4 VARCHAR2, header_att5 VARCHAR2, header_att6 VARCHAR2,
1692 header_att7 VARCHAR2, header_att8 VARCHAR2, header_att9 VARCHAR2,
1693 header_att10 VARCHAR2, header_att11 VARCHAR2, header_att12 VARCHAR2,
1694 header_att13 VARCHAR2, header_att14 VARCHAR2, header_att15 VARCHAR2,
1695
1696 line_att1 VARCHAR2, line_att2 VARCHAR2, line_att3 VARCHAR2,
1697 line_att4 VARCHAR2, line_att5 VARCHAR2, line_att6 VARCHAR2,
1698 line_att7 VARCHAR2, line_att8 VARCHAR2, line_att9 VARCHAR2,
1699 line_att10 VARCHAR2, line_att11 VARCHAR2, line_att12 VARCHAR2,
1700 line_att13 VARCHAR2, line_att14 VARCHAR2, line_att15 VARCHAR2,
1701
1702 shipment_att1 VARCHAR2, shipment_att2 VARCHAR2, shipment_att3 VARCHAR2,
1703 shipment_att4 VARCHAR2, shipment_att5 VARCHAR2, shipment_att6 VARCHAR2,
1704 shipment_att7 VARCHAR2, shipment_att8 VARCHAR2, shipment_att9 VARCHAR2,
1705 shipment_att10 VARCHAR2, shipment_att11 VARCHAR2, shipment_att12 VARCHAR2,
1706 shipment_att13 VARCHAR2, shipment_att14 VARCHAR2, shipment_att15 VARCHAR2,
1707
1708 distribution_att1 VARCHAR2, distribution_att2 VARCHAR2,
1709 distribution_att3 VARCHAR2, distribution_att4 VARCHAR2,
1710 distribution_att5 VARCHAR2, distribution_att6 VARCHAR2,
1711 distribution_att7 VARCHAR2, distribution_att8 VARCHAR2,
1712 distribution_att9 VARCHAR2, distribution_att10 VARCHAR2,
1713 distribution_att11 VARCHAR2, distribution_att12 VARCHAR2,
1714 distribution_att13 VARCHAR2, distribution_att14 VARCHAR2,
1715 distribution_att15 VARCHAR2,
1716
1717 FB_ERROR_MSG IN OUT NOCOPY VARCHAR2,
1718 p_distribution_type IN VARCHAR2,
1719 p_payment_type IN VARCHAR2,
1720 x_award_id NUMBER DEFAULT NULL, --OGM_0.0 changes added award_id
1721 x_vendor_site_id NUMBER DEFAULT NULL, -- B1548597 RVK Common Receiving
1722 p_func_unit_price IN NUMBER DEFAULT NULL, --<BUG 3407630>, Bug 3463242
1723 p_clm_misc_loa IN VARCHAR2 DEFAULT NULL -- CLM fed fields
1724 ) RETURN BOOLEAN IS
1725
1726 ItemType VARCHAR2(8);
1727 ItemKey VARCHAR2(240);
1728 ccid NUMBER;
1729
1730 -- Bug 752384: Increase the size of flexfield to 2000
1731 concat_segs VARCHAR2(2000);
1732 concat_ids VARCHAR2(240);
1733 concat_descrs VARCHAR2(2000);
1734
1735 x_block_activity_label VARCHAR2(60);
1736 x_insert_if_new BOOLEAN := TRUE;
1737 x_new_ccid_generated BOOLEAN := FALSE;
1738 x_success BOOLEAN;
1739 l_debug_msg PO_WF_DEBUG.debug_message%TYPE; --< Shared Proc FPJ >
1740 l_progress VARCHAR2(3); --< Shared Proc FPJ >
1741 x_appl_short_name VARCHAR2(40);
1742 x_flex_field_code VARCHAR2(150);
1743 x_flex_field_struc_num NUMBER; -- coa_id
1744
1745 was_ccid_passed_in_from_form BOOLEAN := FALSE;
1746
1747 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
1748 l_api_name CONSTANT VARCHAR2(100) := 'Start_Workflow_internal';
1749 l_distribution_type PO_DISTRIBUTIONS_ALL.distribution_type%TYPE; --<Complex Work R12>
1750
1751 BEGIN
1752
1753 IF g_debug_stmt THEN
1754 PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
1755 END IF;
1756
1757 -- Start_Workflow_internal --
1758 l_progress := '000';
1759
1760 /* Bug # 1942357
1761 Clearing the temporary cache before calling the Workflow */
1762
1763 -- Note from bug5075361: We probably don't need to keep the clearcache
1764 -- at the beginning of the procedure since they're called at the end
1765 -- but it doesn't hurt to keep them anyway
1766 wf_item.clearcache;
1767
1768 ItemType := 'POWFPOAG'; -- PO Account Generator Workflow
1769 x_appl_short_name := 'SQLGL';
1770 x_flex_field_code := 'GL#';
1771
1772 l_progress := '010';
1773
1774 --< Shared Proc FPJ Start >
1775 --x_flex_field_struc_num := x_coa_id;
1776 IF (x_account_generation_flow_type = g_po_accounts) THEN
1777 x_flex_field_struc_num := x_coa_id; -- POU's COA
1778 ELSE
1779 x_flex_field_struc_num := x_ship_to_ou_coa_id; -- DOU's COA
1780 END IF;
1781 --< Shared Proc FPJ End >
1782
1783 --Bug 4947589 <Complex Work R12>: distribution_type is only passed in
1784 --when calling from the HTML UI. We only need this column to determine
1785 --if the distribution belongs to a financing pay item or advance, which
1786 --can only be created via HTML UI. Hence, if distribution_type is null,
1787 --we can assume that it will never be a prepayment distribution.
1788 l_distribution_type := nvl(p_distribution_type, 'NOT PREPAYMENT');
1789
1790 l_progress := '020';
1791
1792 Wf_Itemkey := FND_FLEX_WORKFLOW.initialize(x_appl_short_name,
1793 x_flex_field_code,
1794 x_flex_field_struc_num,
1795 ItemType);
1796
1797 IF g_debug_stmt THEN
1798 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1799 p_token => l_progress,
1800 p_message => 'x_account_generation_flow_type='
1801 || x_account_generation_flow_type
1802 || 'item_key=' || wf_itemkey);
1803 END IF;
1804
1805 l_progress := '030';
1806
1807 IF ( ItemType IS NOT NULL ) AND ( Wf_Itemkey IS NOT NULL) THEN -- (
1808
1809 l_progress := '040';
1810
1811 -- Moved the calling of AP routine to get raw and derived parameters for
1812 -- project accounting accounts into this new private procedure called
1813 -- derive_pa_params(). This procedure also sets the PA related WF item
1814 -- attributes that are derived from the PA API. It also sets the
1815 -- AWARD_SET_ID attribute if project_id is not null.
1816
1817 derive_pa_params(itemtype,
1818 wf_itemkey,
1819 x_project_id,
1820 x_task_id,
1821 x_expenditure_type,
1822 x_vendor_id,
1823 x_expenditure_organization_id,
1824 x_expenditure_item_date,
1825 x_award_id);
1826
1827 l_progress := '050';
1828
1829 -- Moved the initialization of over 90 workflow item attributes into
1830 -- this new private procedure called set_ag_wf_attributes(). This makes
1831 -- the procedure Start_Workflow() more modular and more readable.
1832
1833 set_ag_wf_attributes(itemtype,
1834 wf_itemkey,
1835 x_coa_id,
1836 x_bom_cost_element_id,
1837 x_bom_resource_id,
1838 x_category_id,
1839 x_deliver_to_location_id,
1840 x_destination_organization_id,
1841 x_destination_subinventory,
1842 x_destination_type_code,
1843 x_po_encumberance_flag,
1844 header_att1, header_att2, header_att3, header_att4,
1845 header_att5, header_att6, header_att7, header_att8,
1846 header_att9, header_att10, header_att11, header_att12,
1847 header_att13, header_att14, header_att15,
1848 line_att1, line_att2, line_att3, line_att4,
1849 line_att5, line_att6, line_att7, line_att8,
1850 line_att9, line_att10, line_att11, line_att12,
1851 line_att13, line_att14, line_att15,
1852 shipment_att1, shipment_att2, shipment_att3,
1853 shipment_att4, shipment_att5, shipment_att6,
1854 shipment_att7, shipment_att8, shipment_att9,
1855 shipment_att10, shipment_att11, shipment_att12,
1856 shipment_att13, shipment_att14, shipment_att15,
1857 distribution_att1, distribution_att2,
1858 distribution_att3, distribution_att4,
1859 distribution_att5, distribution_att6,
1860 distribution_att7, distribution_att8,
1861 distribution_att9, distribution_att10,
1862 distribution_att11, distribution_att12,
1863 distribution_att13, distribution_att14,
1864 distribution_att15,
1865 x_expenditure_item_date,
1866 x_expenditure_organization_id,
1867 x_expenditure_type,
1868 x_item_id,
1869 x_line_type_id,
1870 x_result_billable_flag,
1871 x_agent_id,
1872 x_project_id,
1873 x_from_header_id,
1874 x_from_line_id,
1875 x_from_type_lookup_code,
1876 x_task_id,
1877 x_deliver_to_person_id,
1878 x_type_lookup_code,
1879 x_vendor_id,
1880 -- B1548597 Common Receiving RVK
1881 x_vendor_site_id,
1882 x_wip_entity_id,
1883 x_wip_entity_type,
1884 x_wip_line_id,
1885 x_wip_operation_seq_num,
1886 x_wip_repetitive_schedule_id,
1887 x_wip_resource_seq_num,
1888
1889 --< Shared Proc FPJ Start >
1890 x_account_generation_flow_type,
1891 x_ship_to_ou_coa_id, -- DOU's COA ID
1892 x_ship_to_ou_id, -- DOU's org ID
1893 x_purchasing_ou_id, -- POU's org ID
1894 x_transaction_flow_header_id,
1895 x_is_SPS_distribution, -- BOOLEAN
1896 x_dest_charge_account_id,
1897 x_dest_variance_account_id,
1898 --< Shared Proc FPJ End >
1899 p_func_unit_price, --<BUG 3407630>, Bug 3463242
1900 p_distribution_type, --<Complex Work R12>
1901 p_payment_type, --<Complex Work R12>
1902 p_clm_misc_loa --<Clm Fed Fields>
1903 );
1904
1905 l_progress := '070';
1906
1907 --< Shared Proc FPJ Start >
1908 IF (x_account_generation_flow_type = g_po_accounts) THEN --(
1909 --< Shared Proc FPJ End >
1910
1911 IF x_code_combination_id IS NULL THEN -- (
1912
1913 l_progress := '080';
1914 -- Call the AOL function to start the Workflow process and retrieve the
1915 -- results.
1916 x_block_activity_label := NULL;
1917
1918 -- Bug 1497909 : Set the encumbrance date for validation
1919 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
1920 itemkey => wf_itemkey,
1921 aname => 'ENCUMBRANCE_DATE',
1922 avalue => x_gl_encumbered_date);
1923
1924 IF g_debug_stmt THEN
1925 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1926 p_token => l_progress,
1927 p_message => 'Before calling FND_FLEX_WORKFLOW.generate_partial');
1928 END IF;
1929
1930 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL ( ItemType,
1931 Wf_Itemkey,
1932 'DEFAULT_CHARGE_ACC_GENERATION',
1933 x_block_activity_label,
1934 x_insert_if_new,
1935 ccid,
1936 concat_segs,
1937 concat_ids,
1938 concat_descrs,
1939 FB_ERROR_MSG,
1940 x_new_combination );
1941
1942 IF (x_success AND ( ccid IS NULL OR ccid = 0 OR ccid = -1 )) THEN
1943
1944 l_progress := '090';
1945 -- Complete the blocked workflow as it may be running in synch mode and
1946 -- cause problems for consequent account generation runs for this
1947 -- session.
1948 BEGIN
1949 /*
1950 ** Bug #2098214, Added the following statement
1951 ** "fnd_message.clear" to clear the messages that are generated
1952 ** while creating an account. This messages are generated by
1953 ** FND as workflow calls the function to validate the account
1954 ** and it returns success even if the account is not generated.
1955 */
1956 IF x_destination_type_code = 'EXPENSE' THEN
1957 fnd_message.clear;
1958 END IF;
1959
1960 IF g_debug_stmt THEN
1961 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1962 p_token => l_progress,
1963 p_message =>
1964 'Terminating the workflow because invalid charge'||
1965 ' Account was generated.');
1966 END IF;
1967
1968
1969 wf_engine.CompleteActivity(itemtype, wf_itemkey,
1970 'BLOCK_BUDGET_ACC_GENERATION', 'FAILURE');
1971 EXCEPTION
1972 WHEN OTHERS THEN
1973 IF g_debug_stmt THEN
1974 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
1975 p_token => l_progress,
1976 p_message => 'Exception when completing WF.' ||
1977 ' item_key='||Wf_Itemkey);
1978 END IF;
1979
1980 IF g_debug_unexp THEN
1981 PO_DEBUG.debug_exc(p_log_head => g_log_head||l_api_name,
1982 p_progress => l_progress);
1983 END IF;
1984 END;
1985 END IF; -- IF (x_success AND ( ccid IS NULL OR ccid = 0 OR ccid = -1 ))
1986
1987 x_charge_success := x_success;
1988
1989 IF x_new_combination THEN
1990 x_new_ccid_generated := TRUE;
1991 END IF;
1992
1993 l_progress := '100';
1994
1995 l_debug_msg := 'CHARGE ACCOUNT: ccid:' || to_char(ccid) ||
1996 ' concat_segs:' || concat_segs || ' concat_ids:' ||
1997 concat_ids || ' concat_descrs:' || concat_descrs ||
1998 ' FB_ERROR_MSG:' || FB_ERROR_MSG;
1999
2000 IF g_debug_stmt THEN
2001 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2002 p_token => l_progress,
2003 p_message => l_debug_msg);
2004 END IF;
2005
2006 -- Copy the returned value into appropriate function parameters to pass
2007 -- them back to the form.
2008 x_code_combination_id := ccid;
2009 x_charge_account_flex := concat_segs;
2010 x_charge_account_desc := concat_descrs;
2011
2012 was_ccid_passed_in_from_form := FALSE;
2013
2014 ELSE -- ELSE IF x_code_combination_id IS not NULL
2015
2016 l_progress := '110';
2017 IF g_debug_stmt THEN
2018 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2019 p_token => l_progress,
2020 p_message =>
2021 'The Charge Account ID passed to the Workflow is not null ='||
2022 x_code_combination_id);
2023 END IF;
2024
2025 x_charge_success := TRUE;
2026 x_success := TRUE;
2027 was_ccid_passed_in_from_form := TRUE;
2028
2029 END IF; -- IF x_code_combination_id IS NULL )
2030
2031 l_progress := '120';
2032
2033 IF ( x_success AND
2034 (x_code_combination_id IS NOT NULL) AND
2035 (x_code_combination_id <> 0) AND
2036 (x_code_combination_id <> -1) ) THEN -- (
2037
2038 l_progress := '130';
2039
2040 po_wf_util_pkg.SetItemAttrNumber(itemtype => itemtype,
2041 itemkey => wf_itemkey,
2042 aname => 'CODE_COMBINATION_ID',
2043 avalue => x_code_combination_id );
2044
2045 -- Generate Budget Account if encumbrance is on
2046 IF ( (x_po_encumberance_flag = 'Y') AND
2047 (x_destination_type_code <> 'SHOP FLOOR' OR (x_destination_type_code = 'SHOP FLOOR' AND x_wip_entity_type = 6) ) AND
2048 /* Condition added for Encumbrance Project - To enable Encumbrance for Destination type Shop Floor and WIP entity type EAM */
2049 (l_distribution_type <> 'PREPAYMENT') --<Complex Work R12> bug 4947589
2050 ) THEN
2051 -- No Budget Acct is generated for the distributions of financing pay
2052 -- items or advances because we never encumber these distributions
2053
2054 IF g_debug_stmt THEN
2055 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2056 p_token => l_progress,
2057 p_message => 'Generating Budget Account...');
2058 END IF;
2059
2060 IF was_ccid_passed_in_from_form = FALSE THEN
2061 x_block_activity_label := 'BLOCK_BUDGET_ACC_GENERATION';
2062 ELSE
2063 x_block_activity_label := NULL;
2064 END IF;
2065
2066 l_progress := '140';
2067
2068 -- Bug 1497909 : Set the encumbrance date for validation
2069 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
2070 itemkey => wf_itemkey,
2071 aname => 'ENCUMBRANCE_DATE',
2072 avalue => x_gl_encumbered_date);
2073
2074 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL(
2075 ItemType,
2076 Wf_Itemkey,
2077 'DEFAULT_BUDGET_ACC_GENERATION',
2078 x_block_activity_label,
2079 x_insert_if_new,
2080 ccid,
2081 concat_segs,
2082 concat_ids,
2083 concat_descrs,
2084 FB_ERROR_MSG,
2085 x_new_combination );
2086
2087 x_budget_success := x_success;
2088
2089 IF x_new_combination THEN
2090 x_new_ccid_generated := TRUE;
2091 END IF;
2092
2093 x_budget_account_id := ccid;
2094 x_budget_account_flex := concat_segs;
2095 x_budget_account_desc := concat_descrs;
2096
2097 l_progress := '150';
2098
2099 l_debug_msg := 'BUDGET ACCOUNT ccid:' || to_char(ccid) ||
2100 ' concat_segs:' || concat_segs || ' concat_ids:' ||
2101 concat_ids || ' concat_descrs:' || concat_descrs ||
2102 ' FB_ERROR_MSG:' || FB_ERROR_MSG;
2103
2104 IF g_debug_stmt THEN
2105 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2106 p_token => l_progress,
2107 p_message => l_debug_msg);
2108 END IF;
2109
2110 ELSE
2111
2112 l_progress := '160';
2113
2114 IF g_debug_stmt THEN
2115 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2116 p_token => l_progress,
2117 p_message => 'Skipping Budget Account generation...');
2118 END IF;
2119
2120
2121 x_success := TRUE;
2122 x_budget_success := x_success;
2123 END IF; -- IF ( (x_po_encumberance_flag = 'Y') AND
2124 -- (x_destination_type_code <> 'SHOP FLOOR') AND
2125 -- (l_distribution_type <> 'PREPAYMENT'))
2126
2127 IF x_success THEN
2128
2129 l_progress := '170';
2130
2131 po_wf_util_pkg.SetItemAttrNumber(itemtype => itemtype,
2132 itemkey => wf_itemkey,
2133 aname => 'BUDGET_ACCOUNT_ID',
2134 avalue => x_budget_account_id );
2135
2136 -- Generate Accrual Account
2137 IF was_ccid_passed_in_from_form = FALSE THEN
2138 IF ( (x_po_encumberance_flag = 'Y') AND
2139 (x_destination_type_code <> 'SHOP FLOOR' OR (x_destination_type_code = 'SHOP FLOOR' AND x_wip_entity_type = 6) ) AND
2140 /* Condition added for Encumbrance Project - To enable Encumbrance for Destination type Shop Floor and WIP entity type EAM */
2141 (l_distribution_type <> 'PREPAYMENT') --<Complex Work R12> bug 4947589
2142 ) THEN
2143 x_block_activity_label := 'BLOCK_ACCRUAL_ACC_GENERATION';
2144 ELSE
2145 x_block_activity_label := 'BLOCK_BUDGET_ACC_GENERATION';
2146 END IF;
2147 ELSE
2148 IF ( (x_po_encumberance_flag = 'Y') AND
2149 (x_destination_type_code <> 'SHOP FLOOR' OR (x_destination_type_code = 'SHOP FLOOR' AND x_wip_entity_type = 6) ) AND
2150 /* Condition added for Encumbrance Project - To enable Encumbrance for Destination type Shop Floor and WIP entity type EAM */
2151 (l_distribution_type <> 'PREPAYMENT') --<Complex Work R12> bug 4947589
2152 ) THEN
2153 x_block_activity_label := 'BLOCK_ACCRUAL_ACC_GENERATION';
2154 ELSE
2155 x_block_activity_label := NULL;
2156 END IF;
2157 END IF;
2158
2159 l_progress := '180';
2160
2161 IF g_debug_stmt THEN
2162 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2163 p_token => l_progress,
2164 p_message =>
2165 'Generating Accrual Account: x_block_activity_label = '||
2166 x_block_activity_label);
2167 END IF;
2168
2169 -- Bug 1497909 : Set the encumbrance date for validation
2170 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
2171 itemkey => wf_itemkey,
2172 aname => 'ENCUMBRANCE_DATE',
2173 avalue => x_gl_encumbered_date);
2174
2175 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL (
2176 ItemType,
2177 Wf_Itemkey,
2178 'DEFAULT_ACCRUAL_ACC_GENERATION',
2179 x_block_activity_label,
2180 x_insert_if_new,
2181 ccid,
2182 concat_segs,
2183 concat_ids,
2184 concat_descrs,
2185 FB_ERROR_MSG,
2186 x_new_combination );
2187
2188 x_accrual_success := x_success;
2189
2190 IF x_new_combination THEN
2191 x_new_ccid_generated := TRUE;
2192 END IF;
2193
2194 x_accrual_account_id := ccid;
2195 x_accrual_account_flex := concat_segs;
2196 x_accrual_account_desc := concat_descrs;
2197
2198 l_debug_msg := 'ACCRUAL ACCOUNT: ccid:' || to_char(ccid) ||
2199 ' concat_segs:' || concat_segs || ' concat_ids:'
2200 || concat_ids || ' concat_descrs:' || concat_descrs ||
2201 ' FB_ERROR_MSG:' || FB_ERROR_MSG;
2202
2203 IF g_debug_stmt THEN
2204 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2205 p_token => l_progress,
2206 p_message => l_debug_msg);
2207 END IF;
2208
2209 IF x_success THEN
2210
2211 l_progress := '190';
2212
2213 po_wf_util_pkg.SetItemAttrNumber(itemtype => itemtype,
2214 itemkey => wf_itemkey,
2215 aname => 'ACCRUAL_ACCOUNT_ID',
2216 avalue => x_accrual_account_id );
2217
2218 IF g_debug_stmt THEN
2219 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2220 p_token => l_progress,
2221 p_message => 'Generating Variance Account...');
2222 END IF;
2223
2224 l_progress := '200';
2225
2226 -- Bug 1497909 : Set the encumbrance date for validation
2227 po_wf_util_pkg.SetItemAttrDate(itemtype => itemtype,
2228 itemkey => wf_itemkey,
2229 aname => 'ENCUMBRANCE_DATE',
2230 avalue => x_gl_encumbered_date);
2231
2232 -- Generate Variance Account
2233 x_success := FND_FLEX_WORKFLOW.GENERATE_PARTIAL(
2234 ItemType,
2235 Wf_Itemkey,
2236 'DEFAULT_VARIANCE_ACC_GENERATION',
2237 'BLOCK_VARIANCE_ACC_GENERATION',
2238 x_insert_if_new,
2239 ccid,
2240 concat_segs,
2241 concat_ids,
2242 concat_descrs,
2243 FB_ERROR_MSG,
2244 x_new_combination);
2245
2246 x_variance_success := x_success;
2247
2248 IF x_new_combination THEN
2249 x_new_ccid_generated := TRUE;
2250 END IF;
2251
2252 x_variance_account_id := ccid;
2253 x_variance_account_flex := concat_segs;
2254 x_variance_account_desc := concat_descrs;
2255
2256 l_progress := '210';
2257
2258 l_debug_msg := 'VARIANCE ACCOUNT: ccid:' || to_char(ccid) ||
2259 ' concat_segs:' || concat_segs || ' concat_ids:' ||
2260 concat_ids || ' concat_descrs:' || concat_descrs ||
2261 ' FB_ERROR_MSG:'|| FB_ERROR_MSG;
2262
2263 IF g_debug_stmt THEN
2264 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2265 p_token => l_progress,
2266 p_message => l_debug_msg);
2267 END IF;
2268
2269 --RETURN (x_success);
2270 IF NOT x_success THEN
2271 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2272 RETURN (x_success);
2273 END IF;
2274 ELSE -- accrual acc failed.
2275 x_accrual_success := x_success;
2276
2277 --RETURN (x_success);
2278 IF NOT x_success THEN
2279 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2280 RETURN (x_success);
2281 END IF;
2282
2283 END IF; -- IF x_success
2284 ELSE -- budget acc failed.
2285 x_budget_success := x_success;
2286
2287 --RETURN (x_success);
2288 IF NOT x_success THEN
2289 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2290 RETURN (x_success);
2291 END IF;
2292
2293 END IF; -- IF x_success
2294 ELSE -- charge acc failed.
2295 x_charge_success := x_success;
2296
2297 --RETURN (x_success);
2298 IF NOT x_success THEN
2299 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2300 RETURN (x_success);
2301 END IF;
2302
2303 END IF; -- IF ( x_success AND
2304 -- (x_code_combination_id IS NOT NULL) AND
2305 -- (x_code_combination_id <> 0) AND
2306 -- (x_code_combination_id <> -1) ) THEN )
2307
2308 IF (NOT x_success) THEN
2309 l_debug_msg := 'PO ACCOUNT GENERATE FAILURE: => ' || FB_ERROR_MSG;
2310 IF g_debug_stmt THEN
2311 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2312 p_token => l_progress,
2313 p_message => l_debug_msg);
2314 END IF;
2315 END IF;
2316
2317 --< Shared Proc FPJ Start >
2318 END IF; -- IF (x_account_generation_flow_type = g_po_accounts) THEN --)
2319 --< Shared Proc FPJ End >
2320
2321 l_progress := '220';
2322
2323 --< Shared Proc FPJ Start >
2324 generate_destination_accounts(
2325 itemtype, -- IN VARCHAR2
2326 wf_itemkey, -- IN VARCHAR2,
2327 x_is_SPS_distribution, -- IN BOOLEAN
2328 x_insert_if_new, -- IN BOOLEAN,
2329 x_account_generation_flow_type, -- IN VARCHAR2,
2330 x_coa_id, -- IN NUMBER,
2331 x_ship_to_ou_coa_id, -- IN NUMBER,
2332 x_gl_encumbered_date, -- IN DATE,
2333 x_dest_charge_account_id, -- IN OUT NUMBER,
2334 x_dest_charge_account_flex, -- IN OUT NUMBER,
2335 x_dest_charge_account_desc, -- IN OUT NUMBER,
2336 x_dest_charge_success, -- IN OUT NOCOPY BOOLEAN
2337 x_dest_variance_account_id, -- IN OUT NUMBER,
2338 x_dest_variance_account_flex, -- IN OUT NUMBER,
2339 x_dest_variance_account_desc, -- IN OUT NUMBER
2340 x_dest_variance_success, -- IN OUT NOCOPY BOOLEAN
2341 x_success, -- IN OUT BOOLEAN
2342 FB_ERROR_MSG, -- IN OUT VARCHAR2
2343 x_new_combination); -- IN OUT BOOLEAN
2344
2345 IF (g_po_wf_debug = 'Y') THEN
2346 IF (x_success) THEN
2347 IF g_debug_stmt THEN
2348 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2349 p_token => l_progress,
2350 p_message =>
2351 'After generate_destination_accounts():'||
2352 ' x_success = TRUE' ||
2353 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2354 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2355 END IF;
2356 ELSE
2357 IF g_debug_stmt THEN
2358 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2359 p_token => l_progress,
2360 p_message =>
2361 'After generate_destination_accounts():'||
2362 ' x_success = FALSE' ||
2363 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2364 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2365 END IF;
2366 END IF;
2367 END IF;
2368 --< Shared Proc FPJ End >
2369
2370 IF g_debug_stmt THEN
2371 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
2372 END IF;
2373
2374 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2375 RETURN x_success;
2376 ELSE
2377 FB_ERROR_MSG := 'Invalid Item Type OR Item Key';
2378 IF g_debug_stmt THEN
2379 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2380 p_token => l_progress,
2381 p_message => FB_ERROR_MSG);
2382 END IF;
2383
2384 IF g_debug_stmt THEN
2385 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
2386 END IF;
2387
2388 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2389 RETURN FALSE;
2390 END IF; -- IF ( ItemType IS NOT NULL ) AND ( Wf_Itemkey IS NOT NULL) -- )
2391
2392 IF g_debug_stmt THEN
2393 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
2394 END IF;
2395
2396 EXCEPTION
2397 WHEN OTHERS THEN
2398 PO_WF_UTIL_PKG.clear_wf_cache; -- bug5075361
2399 po_message_s.sql_error('Start_Workflow_internal',
2400 l_progress, sqlcode);
2401 IF g_debug_unexp THEN
2402 PO_DEBUG.debug_exc(p_log_head => g_log_head||l_api_name,
2403 p_progress => l_progress);
2404 END IF;
2405 RAISE;
2406 END Start_Workflow_internal;
2407
2408 FUNCTION Start_Workflow(
2409
2410 --< Shared Proc FPJ Start >
2411 x_purchasing_ou_id IN NUMBER, -- POU's org ID
2412 x_transaction_flow_header_id IN NUMBER,
2413 x_dest_charge_success IN OUT NOCOPY BOOLEAN,
2414 x_dest_variance_success IN OUT NOCOPY BOOLEAN,
2415 x_dest_charge_account_id IN OUT NOCOPY NUMBER,
2416 x_dest_variance_account_id IN OUT NOCOPY NUMBER,
2417 x_dest_charge_account_desc IN OUT NOCOPY VARCHAR2,
2418 x_dest_variance_account_desc IN OUT NOCOPY VARCHAR2,
2419 x_dest_charge_account_flex IN OUT NOCOPY VARCHAR2,
2420 x_dest_variance_account_flex IN OUT NOCOPY VARCHAR2,
2421 --< Shared Proc FPJ End >
2422
2423 x_charge_success IN OUT NOCOPY BOOLEAN,
2424 x_budget_success IN OUT NOCOPY BOOLEAN,
2425 x_accrual_success IN OUT NOCOPY BOOLEAN,
2426 x_variance_success IN OUT NOCOPY BOOLEAN,
2427 x_code_combination_id IN OUT NOCOPY NUMBER,
2428 x_budget_account_id IN OUT NOCOPY NUMBER,
2429 x_accrual_account_id IN OUT NOCOPY NUMBER,
2430 x_variance_account_id IN OUT NOCOPY NUMBER,
2431 x_charge_account_flex IN OUT NOCOPY VARCHAR2,
2432 x_budget_account_flex IN OUT NOCOPY VARCHAR2,
2433 x_accrual_account_flex IN OUT NOCOPY VARCHAR2,
2434 x_variance_account_flex IN OUT NOCOPY VARCHAR2,
2435 x_charge_account_desc IN OUT NOCOPY VARCHAR2,
2436 x_budget_account_desc IN OUT NOCOPY VARCHAR2,
2437 x_accrual_account_desc IN OUT NOCOPY VARCHAR2,
2438 x_variance_account_desc IN OUT NOCOPY VARCHAR2,
2439 x_coa_id NUMBER,
2440 x_bom_resource_id NUMBER,
2441 x_bom_cost_element_id NUMBER,
2442 x_category_id NUMBER,
2443 x_destination_type_code VARCHAR2,
2444 x_deliver_to_location_id NUMBER,
2445 x_destination_organization_id NUMBER,
2446 x_destination_subinventory VARCHAR2,
2447 x_expenditure_type VARCHAR2,
2448 x_expenditure_organization_id NUMBER,
2449 x_expenditure_item_date DATE,
2450 x_item_id NUMBER,
2451 x_line_type_id NUMBER,
2452 x_result_billable_flag VARCHAR2,
2453 x_agent_id NUMBER,
2454 x_project_id NUMBER,
2455 x_from_type_lookup_code VARCHAR2,
2456 x_from_header_id NUMBER,
2457 x_from_line_id NUMBER,
2458 x_task_id NUMBER,
2459 x_deliver_to_person_id NUMBER,
2460 x_type_lookup_code VARCHAR2,
2461 x_vendor_id NUMBER,
2462 x_wip_entity_id NUMBER,
2463 x_wip_entity_type VARCHAR2,
2464 x_wip_line_id NUMBER,
2465 x_wip_repetitive_schedule_id NUMBER,
2466 x_wip_operation_seq_num NUMBER,
2467 x_wip_resource_seq_num NUMBER,
2468 x_po_encumberance_flag VARCHAR2,
2469 x_gl_encumbered_date DATE,
2470
2471 -- because of changes due to WF synch mode this input parameter is not used.
2472 wf_itemkey IN OUT NOCOPY VARCHAR2,
2473 x_new_combination IN OUT NOCOPY BOOLEAN,
2474
2475 header_att1 VARCHAR2, header_att2 VARCHAR2, header_att3 VARCHAR2,
2476 header_att4 VARCHAR2, header_att5 VARCHAR2, header_att6 VARCHAR2,
2477 header_att7 VARCHAR2, header_att8 VARCHAR2, header_att9 VARCHAR2,
2478 header_att10 VARCHAR2, header_att11 VARCHAR2, header_att12 VARCHAR2,
2479 header_att13 VARCHAR2, header_att14 VARCHAR2, header_att15 VARCHAR2,
2480
2481 line_att1 VARCHAR2, line_att2 VARCHAR2, line_att3 VARCHAR2,
2482 line_att4 VARCHAR2, line_att5 VARCHAR2, line_att6 VARCHAR2,
2483 line_att7 VARCHAR2, line_att8 VARCHAR2, line_att9 VARCHAR2,
2484 line_att10 VARCHAR2, line_att11 VARCHAR2, line_att12 VARCHAR2,
2485 line_att13 VARCHAR2, line_att14 VARCHAR2, line_att15 VARCHAR2,
2486
2487 shipment_att1 VARCHAR2, shipment_att2 VARCHAR2, shipment_att3 VARCHAR2,
2488 shipment_att4 VARCHAR2, shipment_att5 VARCHAR2, shipment_att6 VARCHAR2,
2489 shipment_att7 VARCHAR2, shipment_att8 VARCHAR2, shipment_att9 VARCHAR2,
2490 shipment_att10 VARCHAR2, shipment_att11 VARCHAR2, shipment_att12 VARCHAR2,
2491 shipment_att13 VARCHAR2, shipment_att14 VARCHAR2, shipment_att15 VARCHAR2,
2492
2493 distribution_att1 VARCHAR2, distribution_att2 VARCHAR2,
2494 distribution_att3 VARCHAR2, distribution_att4 VARCHAR2,
2495 distribution_att5 VARCHAR2, distribution_att6 VARCHAR2,
2496 distribution_att7 VARCHAR2, distribution_att8 VARCHAR2,
2497 distribution_att9 VARCHAR2, distribution_att10 VARCHAR2,
2498 distribution_att11 VARCHAR2, distribution_att12 VARCHAR2,
2499 distribution_att13 VARCHAR2, distribution_att14 VARCHAR2,
2500 distribution_att15 VARCHAR2,
2501
2502 FB_ERROR_MSG IN OUT NOCOPY VARCHAR2,
2503 p_distribution_type IN VARCHAR2 DEFAULT NULL, --<Complex Work R12>
2504 p_payment_type IN VARCHAR2 DEFAULT NULL, --<Complex Work R12>
2505 x_award_id NUMBER DEFAULT NULL, --OGM_0.0 changes added award_id
2506 x_vendor_site_id NUMBER DEFAULT NULL, -- B1548597 RVK Common Receiving
2507 p_func_unit_price IN NUMBER DEFAULT NULL, --<BUG 3407630>, Bug 3463242
2508 p_clm_misc_loa IN VARCHAR2 DEFAULT NULL) -- CLM fed fields
2509 RETURN BOOLEAN IS
2510 l_ship_to_ou_coa_id NUMBER;
2511 l_ship_to_ou_id NUMBER;
2512 l_is_SPS_distribution BOOLEAN;
2513 x_success BOOLEAN;
2514 l_progress VARCHAR2(3); --< Shared Proc FPJ >
2515 l_return_status VARCHAR2(1); -- FND_API.g_ret_sts_success
2516 -- $FND_TOP/patch/115/sql/AFASAPIS.pls
2517
2518 -- Added debug comments to FND logs instead on PO_WF_DEBUG logs
2519 l_api_name CONSTANT VARCHAR2(100) := 'start_workflow';
2520
2521 BEGIN
2522 IF g_debug_stmt THEN
2523 PO_DEBUG.debug_begin(p_log_head => g_log_head||l_api_name);
2524 END IF;
2525
2526 -- Start_Workflow --
2527 l_progress := '000';
2528
2529 IF g_debug_stmt THEN
2530 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2531 p_token => l_progress,
2532 p_message =>
2533 'x_destination_organization_id='||x_destination_organization_id);
2534 END IF;
2535
2536
2537 -- Derive the OU and COA of the Ship-to-OU
2538 PO_SHARED_PROC_PVT.get_ou_and_coa_from_inv_org(
2539 p_inv_org_id => x_destination_organization_id, -- IN
2540 x_coa_id => l_ship_to_ou_coa_id, -- OUT
2541 x_ou_id => l_ship_to_ou_id, -- OUT
2542 x_return_status => l_return_status); -- OUT
2543
2544 IF g_debug_stmt THEN
2545 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2546 p_token => l_progress,
2547 p_message => 'Call PO_SHARED_PROC_PVT.get_ou_and_coa_from_inv_org:' ||
2548 ' return_status='||l_return_status||
2549 ', ship_to_ou_coa_id='||l_ship_to_ou_coa_id||
2550 ', ship_to_ou_id='||l_ship_to_ou_id);
2551 END IF;
2552
2553
2554 IF (l_return_status <> FND_API.g_ret_sts_success) THEN
2555 l_progress := '010';
2556 APP_EXCEPTION.raise_exception(exception_type => 'START_WORKFLOW_EXCEPTION',
2557 exception_code => 0,
2558 exception_text => 'PO_SHARED_PROC_PVT.' ||
2559 'get_ou_and_coa_from_inv_org');
2560 END IF;
2561
2562 l_progress := '020';
2563 l_is_SPS_distribution := PO_SHARED_PROC_PVT.is_SPS_distribution(
2564 p_destination_type_code => x_destination_type_code,
2565 p_document_type_code => x_type_lookup_code,
2566 p_purchasing_ou_id => x_purchasing_ou_id,
2567 p_project_id => x_project_id,
2568 p_ship_to_ou_id => l_ship_to_ou_id,
2569 p_transaction_flow_header_id => x_transaction_flow_header_id);
2570
2571 -- Call the AG Workflow 2 times -- First to build the PO Accounts.
2572 -- Second, in case of SPS, to build the Destination Accounts,
2573 -- if POU's COA <> DOU's COA.
2574
2575 IF g_debug_stmt THEN
2576 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2577 p_token => l_progress,
2578 p_message => 'First call to Start_Workflow_internal with POUs COA');
2579 END IF;
2580
2581
2582 l_progress := '030';
2583 -- First call with the Purchasing OU's COA
2584 x_success := Start_Workflow_internal(
2585 --< Shared Proc FPJ Start >
2586 g_po_accounts, -- New parameter for Account Generation Type
2587 l_ship_to_ou_coa_id, -- DOU's COA ID
2588 l_ship_to_ou_id, -- DOU's org ID
2589 x_purchasing_ou_id, -- POU's org ID
2590 x_transaction_flow_header_id,
2591 l_is_SPS_distribution,
2592 x_dest_charge_success,
2593 x_dest_variance_success,
2594 x_dest_charge_account_id,
2595 x_dest_variance_account_id,
2596 x_dest_charge_account_desc,
2597 x_dest_variance_account_desc,
2598 x_dest_charge_account_flex,
2599 x_dest_variance_account_flex,
2600 --< Shared Proc FPJ End >
2601
2602 x_charge_success,
2603 x_budget_success,
2604 x_accrual_success,
2605 x_variance_success,
2606 x_code_combination_id,
2607 x_budget_account_id,
2608 x_accrual_account_id,
2609 x_variance_account_id,
2610 x_charge_account_flex,
2611 x_budget_account_flex,
2612 x_accrual_account_flex,
2613 x_variance_account_flex,
2614 x_charge_account_desc,
2615 x_budget_account_desc,
2616 x_accrual_account_desc,
2617 x_variance_account_desc,
2618 x_coa_id,
2619 x_bom_resource_id,
2620 x_bom_cost_element_id,
2621 x_category_id,
2622 x_destination_type_code,
2623 x_deliver_to_location_id,
2624 x_destination_organization_id,
2625 x_destination_subinventory,
2626 x_expenditure_type,
2627 x_expenditure_organization_id,
2628 x_expenditure_item_date,
2629 x_item_id,
2630 x_line_type_id,
2631 x_result_billable_flag,
2632 x_agent_id,
2633 x_project_id,
2634 x_from_type_lookup_code,
2635 x_from_header_id,
2636 x_from_line_id,
2637 x_task_id,
2638 x_deliver_to_person_id,
2639 x_type_lookup_code,
2640 x_vendor_id,
2641 x_wip_entity_id,
2642 x_wip_entity_type,
2643 x_wip_line_id,
2644 x_wip_repetitive_schedule_id,
2645 x_wip_operation_seq_num,
2646 x_wip_resource_seq_num,
2647 x_po_encumberance_flag,
2648 x_gl_encumbered_date,
2649
2650 -- because of changes due to WF synch mode this input parameter is not
2651 -- used.
2652 wf_itemkey,
2653 x_new_combination,
2654
2655 header_att1, header_att2, header_att3, header_att4, header_att5,
2656 header_att6, header_att7, header_att8, header_att9, header_att10,
2657 header_att11, header_att12, header_att13, header_att14, header_att15,
2658
2659 line_att1, line_att2, line_att3, line_att4, line_att5,
2660 line_att6, line_att7, line_att8, line_att9, line_att10,
2661 line_att11, line_att12, line_att13, line_att14, line_att15,
2662
2663 shipment_att1, shipment_att2, shipment_att3, shipment_att4,
2664 shipment_att5, shipment_att6, shipment_att7, shipment_att8,
2665 shipment_att9, shipment_att10, shipment_att11, shipment_att12,
2666 shipment_att13, shipment_att14, shipment_att15,
2667
2668 distribution_att1, distribution_att2, distribution_att3,
2669 distribution_att4, distribution_att5, distribution_att6,
2670 distribution_att7, distribution_att8, distribution_att9,
2671 distribution_att10, distribution_att11, distribution_att12,
2672 distribution_att13, distribution_att14, distribution_att15,
2673
2674 FB_ERROR_MSG,
2675 p_distribution_type, --<Complex Work R12>
2676 p_payment_type, --<Complex Work R12>
2677 x_award_id,
2678 x_vendor_site_id,
2679 p_func_unit_price, --<BUG 3407630>, Bug 3463242
2680 p_clm_misc_loa --< CLM fed fields>
2681 );
2682
2683 l_progress := '040';
2684
2685 IF (g_po_wf_debug = 'Y') THEN
2686 IF (x_success) THEN
2687 IF g_debug_stmt THEN
2688 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2689 p_token => l_progress,
2690 p_message =>
2691 'After first call to Start Workflow Internal():'||
2692 ' x_success = TRUE' ||
2693 ' x_code_combination_id=' || x_code_combination_id||
2694 ' x_budget_account_id='||x_budget_account_id||
2695 ' x_accrual_account_id='||x_accrual_account_id||
2696 ' x_variance_account_id='||x_variance_account_id||
2697 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2698 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2699 END IF;
2700 ELSE
2701 IF g_debug_stmt THEN
2702 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2703 p_token => l_progress,
2704 p_message =>
2705 'After first call to Start Workflow Internal():'||
2706 ' x_success = FALSE' ||
2707 ' x_code_combination_id=' || x_code_combination_id||
2708 ' x_budget_account_id='||x_budget_account_id||
2709 ' x_accrual_account_id='||x_accrual_account_id||
2710 ' x_variance_account_id='||x_variance_account_id||
2711 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2712 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2713 END IF;
2714 END IF;
2715 END IF;
2716
2717 if (NOT x_success) THEN
2718 return FALSE;
2719 END IF;
2720
2721 -- No need to call the Workflow again, if NOT a SPS distribution.
2722 if (NOT l_is_SPS_distribution) THEN
2723 return x_success;
2724 END IF;
2725
2726 l_progress := '050';
2727
2728 -- In SPS case, call the Workflow again with a different COA (ship-to-ou's
2729 -- COA). Call again only if POU's COA is different from DOU's COA. If they
2730 -- are the same then the Receiving Accounts have already been generated by
2731 -- the first call to the workflow itself.
2732
2733 IF ( l_is_SPS_distribution AND
2734 (x_coa_id <> l_ship_to_ou_coa_id) ) THEN
2735
2736 l_progress := '060';
2737
2738 IF (g_po_wf_debug = 'Y') THEN
2739 IF g_debug_stmt THEN
2740 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2741 p_token => l_progress,
2742 p_message => 'Second call to Start_Workflow_internal with DOUs COA');
2743 END IF;
2744 END IF;
2745
2746 x_success := Start_Workflow_internal (
2747 --< Shared Proc FPJ Start >
2748 g_destination_accounts, -- New parameter for Account Generation Type
2749 l_ship_to_ou_coa_id, -- DOU's COA ID
2750 l_ship_to_ou_id, -- DOU's org ID
2751 x_purchasing_ou_id, -- POU's org ID
2752 x_transaction_flow_header_id,
2753 l_is_SPS_distribution,
2754 x_dest_charge_success,
2755 x_dest_variance_success,
2756 x_dest_charge_account_id,
2757 x_dest_variance_account_id,
2758 x_dest_charge_account_desc,
2759 x_dest_variance_account_desc,
2760 x_dest_charge_account_flex,
2761 x_dest_variance_account_flex,
2762 --< Shared Proc FPJ End >
2763
2764 x_charge_success,
2765 x_budget_success,
2766 x_accrual_success,
2767 x_variance_success,
2768 x_code_combination_id,
2769 x_budget_account_id,
2770 x_accrual_account_id,
2771 x_variance_account_id,
2772 x_charge_account_flex,
2773 x_budget_account_flex,
2774 x_accrual_account_flex,
2775 x_variance_account_flex,
2776 x_charge_account_desc,
2777 x_budget_account_desc,
2778 x_accrual_account_desc,
2779 x_variance_account_desc,
2780 x_coa_id,
2781 x_bom_resource_id,
2782 x_bom_cost_element_id,
2783 x_category_id,
2784 x_destination_type_code,
2785 x_deliver_to_location_id,
2786 x_destination_organization_id,
2787 x_destination_subinventory,
2788 x_expenditure_type,
2789 x_expenditure_organization_id,
2790 x_expenditure_item_date,
2791 x_item_id,
2792 x_line_type_id,
2793 x_result_billable_flag,
2794 x_agent_id,
2795 x_project_id,
2796 x_from_type_lookup_code,
2797 x_from_header_id,
2798 x_from_line_id,
2799 x_task_id,
2800 x_deliver_to_person_id,
2801 x_type_lookup_code,
2802 x_vendor_id,
2803 x_wip_entity_id,
2804 x_wip_entity_type,
2805 x_wip_line_id,
2806 x_wip_repetitive_schedule_id,
2807 x_wip_operation_seq_num,
2808 x_wip_resource_seq_num,
2809 x_po_encumberance_flag,
2810 x_gl_encumbered_date,
2811
2812 -- because of changes due to WF synch mode this input parameter is not
2813 -- used.
2814 wf_itemkey,
2815 x_new_combination,
2816
2817 header_att1, header_att2, header_att3, header_att4, header_att5,
2818 header_att6, header_att7, header_att8, header_att9, header_att10,
2819 header_att11, header_att12, header_att13, header_att14, header_att15,
2820
2821 line_att1, line_att2, line_att3, line_att4, line_att5,
2822 line_att6, line_att7, line_att8, line_att9, line_att10,
2823 line_att11, line_att12, line_att13, line_att14, line_att15,
2824
2825 shipment_att1, shipment_att2, shipment_att3, shipment_att4,
2826 shipment_att5, shipment_att6, shipment_att7, shipment_att8,
2827 shipment_att9, shipment_att10, shipment_att11, shipment_att12,
2828 shipment_att13, shipment_att14, shipment_att15,
2829
2830 distribution_att1, distribution_att2, distribution_att3,
2831 distribution_att4, distribution_att5, distribution_att6,
2832 distribution_att7, distribution_att8, distribution_att9,
2833 distribution_att10, distribution_att11, distribution_att12,
2834 distribution_att13, distribution_att14, distribution_att15,
2835
2836 FB_ERROR_MSG,
2837 p_distribution_type, --<Complex Work R12>
2838 p_payment_type, --<Complex Work R12>
2839 x_award_id,
2840 x_vendor_site_id,
2841 p_func_unit_price, --<BUG 3407630>, Bug 3463242
2842 p_clm_misc_loa -- CLM fed fields
2843 );
2844
2845 l_progress := '070';
2846
2847 IF (g_po_wf_debug = 'Y') THEN
2848 IF (x_success) THEN
2849 IF g_debug_stmt THEN
2850 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2851 p_token => l_progress,
2852 p_message =>
2853 'After second call to Start Workflow_Internal():'||
2854 ' x_success = TRUE' ||
2855 ' x_code_combination_id=' || x_code_combination_id||
2856 ' x_budget_account_id='||x_budget_account_id||
2857 ' x_accrual_account_id='||x_accrual_account_id||
2858 ' x_variance_account_id='||x_variance_account_id||
2859 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2860 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2861 END IF;
2862 ELSE
2863 IF g_debug_stmt THEN
2864 PO_DEBUG.debug_stmt(p_log_head => g_log_head||l_api_name,
2865 p_token => l_progress,
2866 p_message =>
2867 'After second call to Start Workflow_Internal():'||
2868 ' x_success = FALSE' ||
2869 ' x_code_combination_id=' || x_code_combination_id||
2870 ' x_budget_account_id='||x_budget_account_id||
2871 ' x_accrual_account_id='||x_accrual_account_id||
2872 ' x_variance_account_id='||x_variance_account_id||
2873 ' x_dest_charge_account_id=' || x_dest_charge_account_id ||
2874 ' x_dest_variance_account_id='|| x_dest_variance_account_id);
2875 END IF;
2876 END IF;
2877 END IF;
2878
2879 IF g_debug_stmt THEN
2880 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
2881 END IF;
2882
2883 RETURN x_success;
2884 END IF; -- if ( l_is_SPS_distribution AND
2885 -- (x_coa_id <> l_ship_to_ou_coa_id)) --)
2886
2887 IF g_debug_stmt THEN
2888 PO_DEBUG.debug_end(p_log_head => g_log_head||l_api_name);
2889 END IF;
2890
2891 RETURN x_success;
2892 EXCEPTION
2893 WHEN OTHERS THEN
2894 po_message_s.sql_error('PO_WF_BUILD_ACCOUNT_INIT.Start_Workflow', l_progress,
2895 sqlcode);
2896 IF g_debug_unexp THEN
2897 PO_DEBUG.debug_exc(p_log_head => g_log_head||l_api_name,
2898 p_progress => l_progress);
2899 END IF;
2900 APP_EXCEPTION.raise_exception;
2901 END Start_Workflow;
2902
2903 --< Shared Proc FPJ Start >
2904 --------------------------------------------------------------------------------
2905 --Start of Comments
2906 --Name: Start_Workflow
2907 -- This is an overloaded function for backward compatibility. It calls
2908 -- the Start_Workflow function with the new Shared Procurement Services
2909 -- parameters.
2910 --Pre-reqs:
2911 -- None.
2912 --Modifies:
2913 -- Workflow Status tables.
2914 --Locks:
2915 -- None.
2916 --Function:
2917 -- Generates the accounts for a PO
2918 --End of Comments
2919 --------------------------------------------------------------------------------
2920
2921 FUNCTION Start_Workflow(
2922
2923 x_charge_success IN OUT NOCOPY BOOLEAN,
2924 x_budget_success IN OUT NOCOPY BOOLEAN,
2925 x_accrual_success IN OUT NOCOPY BOOLEAN,
2926 x_variance_success IN OUT NOCOPY BOOLEAN,
2927 x_code_combination_id IN OUT NOCOPY NUMBER,
2928 x_budget_account_id IN OUT NOCOPY NUMBER,
2929 x_accrual_account_id IN OUT NOCOPY NUMBER,
2930 x_variance_account_id IN OUT NOCOPY NUMBER,
2931 x_charge_account_flex IN OUT NOCOPY VARCHAR2,
2932 x_budget_account_flex IN OUT NOCOPY VARCHAR2,
2933 x_accrual_account_flex IN OUT NOCOPY VARCHAR2,
2934 x_variance_account_flex IN OUT NOCOPY VARCHAR2,
2935 x_charge_account_desc IN OUT NOCOPY VARCHAR2,
2936 x_budget_account_desc IN OUT NOCOPY VARCHAR2,
2937 x_accrual_account_desc IN OUT NOCOPY VARCHAR2,
2938 x_variance_account_desc IN OUT NOCOPY VARCHAR2,
2939 x_coa_id NUMBER,
2940 x_bom_resource_id NUMBER,
2941 x_bom_cost_element_id NUMBER,
2942 x_category_id NUMBER,
2943 x_destination_type_code VARCHAR2,
2944 x_deliver_to_location_id NUMBER,
2945 x_destination_organization_id NUMBER,
2946 x_destination_subinventory VARCHAR2,
2947 x_expenditure_type VARCHAR2,
2948 x_expenditure_organization_id NUMBER,
2949 x_expenditure_item_date DATE,
2950 x_item_id NUMBER,
2951 x_line_type_id NUMBER,
2952 x_result_billable_flag VARCHAR2,
2953 x_agent_id NUMBER,
2954 x_project_id NUMBER,
2955 x_from_type_lookup_code VARCHAR2,
2956 x_from_header_id NUMBER,
2957 x_from_line_id NUMBER,
2958 x_task_id NUMBER,
2959 x_deliver_to_person_id NUMBER,
2960 x_type_lookup_code VARCHAR2,
2961 x_vendor_id NUMBER,
2962 x_wip_entity_id NUMBER,
2963 x_wip_entity_type VARCHAR2,
2964 x_wip_line_id NUMBER,
2965 x_wip_repetitive_schedule_id NUMBER,
2966 x_wip_operation_seq_num NUMBER,
2967 x_wip_resource_seq_num NUMBER,
2968 x_po_encumberance_flag VARCHAR2,
2969 x_gl_encumbered_date DATE,
2970
2971 -- because of changes due to WF synch mode this input parameter is not used.
2972 wf_itemkey IN OUT NOCOPY VARCHAR2,
2973 x_new_combination IN OUT NOCOPY BOOLEAN,
2974
2975 header_att1 VARCHAR2, header_att2 VARCHAR2, header_att3 VARCHAR2,
2976 header_att4 VARCHAR2, header_att5 VARCHAR2, header_att6 VARCHAR2,
2977 header_att7 VARCHAR2, header_att8 VARCHAR2, header_att9 VARCHAR2,
2978 header_att10 VARCHAR2, header_att11 VARCHAR2, header_att12 VARCHAR2,
2979 header_att13 VARCHAR2, header_att14 VARCHAR2, header_att15 VARCHAR2,
2980
2981 line_att1 VARCHAR2, line_att2 VARCHAR2, line_att3 VARCHAR2,
2982 line_att4 VARCHAR2, line_att5 VARCHAR2, line_att6 VARCHAR2,
2983 line_att7 VARCHAR2, line_att8 VARCHAR2, line_att9 VARCHAR2,
2984 line_att10 VARCHAR2, line_att11 VARCHAR2, line_att12 VARCHAR2,
2985 line_att13 VARCHAR2, line_att14 VARCHAR2, line_att15 VARCHAR2,
2986
2987 shipment_att1 VARCHAR2, shipment_att2 VARCHAR2, shipment_att3 VARCHAR2,
2988 shipment_att4 VARCHAR2, shipment_att5 VARCHAR2, shipment_att6 VARCHAR2,
2989 shipment_att7 VARCHAR2, shipment_att8 VARCHAR2, shipment_att9 VARCHAR2,
2990 shipment_att10 VARCHAR2, shipment_att11 VARCHAR2, shipment_att12 VARCHAR2,
2991 shipment_att13 VARCHAR2, shipment_att14 VARCHAR2, shipment_att15 VARCHAR2,
2992
2993 distribution_att1 VARCHAR2, distribution_att2 VARCHAR2,
2994 distribution_att3 VARCHAR2, distribution_att4 VARCHAR2,
2995 distribution_att5 VARCHAR2, distribution_att6 VARCHAR2,
2996 distribution_att7 VARCHAR2, distribution_att8 VARCHAR2,
2997 distribution_att9 VARCHAR2, distribution_att10 VARCHAR2,
2998 distribution_att11 VARCHAR2, distribution_att12 VARCHAR2,
2999 distribution_att13 VARCHAR2, distribution_att14 VARCHAR2,
3000 distribution_att15 VARCHAR2,
3001
3002 FB_ERROR_MSG IN OUT NOCOPY VARCHAR2,
3003 p_distribution_type IN VARCHAR2 DEFAULT NULL, --<Complex Work R12>
3004 p_payment_type IN VARCHAR2 DEFAULT NULL, --<Complex Work R12>
3005 x_award_id NUMBER DEFAULT NULL, --OGM_0.0 changes added award_id
3006 x_vendor_site_id NUMBER DEFAULT NULL, -- B1548597 RVK Common Receiving
3007 p_func_unit_price IN NUMBER DEFAULT NULL, --<BUG 3407630>, Bug 3463242
3008 p_clm_misc_loa IN VARCHAR2 DEFAULT NULL --< Clm Fed Fields>
3009 ) RETURN BOOLEAN IS
3010
3011 l_dest_charge_success BOOLEAN;
3012 l_dest_variance_success BOOLEAN;
3013 l_dest_charge_account_id NUMBER;
3014 l_dest_variance_account_id NUMBER;
3015 l_dest_charge_account_desc VARCHAR2(2000);
3016 l_dest_variance_account_desc VARCHAR2(2000);
3017 l_dest_charge_account_flex VARCHAR2(2000);
3018 l_dest_variance_account_flex VARCHAR2(2000);
3019
3020 BEGIN
3021 -- Start_Workflow --
3022 RETURN
3023 Start_Workflow(
3024 -- New parameters for Shared Procurement FPJ Start
3025 FND_Global.org_id, -- p_purachasing_ou_id
3026 NULL, -- p_transaction_flow_header_id
3027 l_dest_charge_success,
3028 l_dest_variance_success,
3029 l_dest_charge_account_id,
3030 l_dest_variance_account_id,
3031 l_dest_charge_account_desc,
3032 l_dest_variance_account_desc,
3033 l_dest_charge_account_flex,
3034 l_dest_variance_account_flex,
3035 -- New parameters for Shared Procurement FPJ End
3036
3037 x_charge_success,
3038 x_budget_success,
3039 x_accrual_success,
3040 x_variance_success,
3041 x_code_combination_id,
3042 x_budget_account_id,
3043 x_accrual_account_id,
3044 x_variance_account_id,
3045 x_charge_account_flex,
3046 x_budget_account_flex,
3047 x_accrual_account_flex,
3048 x_variance_account_flex,
3049 x_charge_account_desc,
3050 x_budget_account_desc,
3051 x_accrual_account_desc,
3052 x_variance_account_desc,
3053 x_coa_id,
3054 x_bom_resource_id,
3055 x_bom_cost_element_id,
3056 x_category_id,
3057 x_destination_type_code,
3058 x_deliver_to_location_id,
3059 x_destination_organization_id,
3060 x_destination_subinventory,
3061 x_expenditure_type,
3062 x_expenditure_organization_id,
3063 x_expenditure_item_date,
3064 x_item_id,
3065 x_line_type_id,
3066 x_result_billable_flag,
3067 x_agent_id,
3068 x_project_id,
3069 x_from_type_lookup_code,
3070 x_from_header_id,
3071 x_from_line_id,
3072 x_task_id,
3073 x_deliver_to_person_id,
3074 x_type_lookup_code,
3075 x_vendor_id,
3076 x_wip_entity_id,
3077 x_wip_entity_type,
3078 x_wip_line_id,
3079 x_wip_repetitive_schedule_id,
3080 x_wip_operation_seq_num,
3081 x_wip_resource_seq_num,
3082 x_po_encumberance_flag,
3083 x_gl_encumbered_date,
3084
3085 -- because of changes due to WF synch mode this input
3086 -- parameter is not used.
3087 wf_itemkey,
3088 x_new_combination,
3089
3090 header_att1, header_att2, header_att3,
3091 header_att4, header_att5, header_att6,
3092 header_att7, header_att8, header_att9,
3093 header_att10, header_att11, header_att12,
3094 header_att13, header_att14, header_att15,
3095
3096 line_att1, line_att2, line_att3,
3097 line_att4, line_att5, line_att6,
3098 line_att7, line_att8, line_att9,
3099 line_att10, line_att11, line_att12,
3100 line_att13, line_att14, line_att15,
3101
3102 shipment_att1, shipment_att2, shipment_att3,
3103 shipment_att4, shipment_att5, shipment_att6,
3104 shipment_att7, shipment_att8, shipment_att9,
3105 shipment_att10, shipment_att11, shipment_att12,
3106 shipment_att13, shipment_att14, shipment_att15,
3107
3108 distribution_att1, distribution_att2,
3109 distribution_att3, distribution_att4,
3110 distribution_att5, distribution_att6,
3111 distribution_att7, distribution_att8,
3112 distribution_att9, distribution_att10,
3113 distribution_att11, distribution_att12,
3114 distribution_att13, distribution_att14,
3115 distribution_att15,
3116
3117 FB_ERROR_MSG,
3118 x_award_id,
3119 x_vendor_site_id,
3120 p_func_unit_price, --<BUG 3407630>, Bug 3463242
3121 p_clm_misc_loa --< CLM Fed Fields>
3122 );
3123
3124 END Start_Workflow;
3125 --< Shared Proc FPJ End >
3126
3127 /*
3128 * Set the debug mode on
3129 */
3130
3131 PROCEDURE debug_on IS
3132 BEGIN
3133 PO_WF_PO_CHARGE_ACC.debug_on;
3134 PO_WF_PO_BUDGET_ACC.debug_on;
3135 -- PO_WF_PO_ACCRUAL_ACC.debug_on;
3136 -- PO_WF_PO_VARIANCE_ACC.debug_on;
3137
3138 END debug_on;
3139
3140 /*
3141 * Set the debug mode off
3142 */
3143
3144 PROCEDURE debug_off IS
3145 BEGIN
3146
3147 PO_WF_PO_CHARGE_ACC.debug_off;
3148 PO_WF_PO_BUDGET_ACC.debug_off;
3149 -- PO_WF_PO_ACCRUAL_ACC.debug_off;
3150 -- PO_WF_PO_VARIANCE_ACC.debug_off;
3151
3152 END debug_off;
3153
3154 end PO_WF_BUILD_ACCOUNT_INIT;