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