1 PACKAGE BODY PO_WF_PO_CHARGE_ACC AS
2 /* $Header: POXWPCAB.pls 120.15 2010/11/25 03:39:24 srkotika ship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
6
7 /*=======================================================================+
8 | FILENAME
9 | POXWPCAB.pls
10 |
11 | DESCRIPTION
12 | PL/SQL body for package: PO_WF_PO_CHARGE_ACC
13 |
14 | NOTES
15 | MODIFIED IMRAN ALI (09/02/97) - Created
16 | Imran Ali (01/23/98)
17 *=====================================================================*/
18
19
20 /*
21 * A Global variable to set the debug mode
22 */
23 debug_acc_generator_wf BOOLEAN := FALSE;
24
25
26 --
27 -- Check Destination Type
28 --
29 procedure check_destination_type ( itemtype in varchar2,
30 itemkey in varchar2,
31 actid in number,
32 funcmode in varchar2,
33 result out NOCOPY varchar2 )
34 is
35 x_progress varchar2(100);
36 x_destination_type varchar2(25);
37 begin
38
39 x_progress := 'PO_WF_PO_CHARGE_ACC.check_destination_type: 01';
40 IF (g_po_wf_debug = 'Y') THEN
41 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
42 END IF;
43
44
45 -- Do nothing in cancel or timeout mode
46 --
47 if (funcmode <> wf_engine.eng_run) then
48
49 result := wf_engine.eng_null;
50 return;
51
52 end if;
53
54 x_destination_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
55 itemkey => itemkey,
56 aname => 'DESTINATION_TYPE_CODE');
57
58 /* Start DEBUG
59 If (debug_acc_generator_wf) then
60 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.check_destination_type');
61 dbms_output.put_line ('DESTINATION_TYPE_CODE: ' || x_destination_type);
62 end if;
63 End DEBUG */
64
65 if x_destination_type = 'EXPENSE' then
66 result := 'COMPLETE:EXPENSE';
67 elsif x_destination_type = 'INVENTORY' then
68 result := 'COMPLETE:INVENTORY';
69 elsif x_destination_type = 'SHOP FLOOR' then
70 result := 'COMPLETE:SHOP_FLOOR';
71 end if;
72
73 return;
74
75 EXCEPTION
76 WHEN OTHERS THEN
77 wf_core.context('PO_WF_PO_CHARGE_ACC','check_destination_type',x_progress);
78
79 /* Start DEBUG
80 If (debug_acc_generator_wf) then
81 dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.check_destination_type');
82 end if;
83 End DEBUG */
84
85 raise;
86 end check_destination_type;
87
88 -- * ****************************************************************************** *
89 -- * ****************************************************************************** *
90
91 --
92 -- Private functions specifications for Inventory destination type.
93 --
94
95 function check_inv_item_type (itemtype varchar2, itemkey varchar2, x_dest_org_id number, x_item_id number)
96 return varchar2;
97
98 function check_sub_inv_type (itemtype varchar2, itemkey varchar2, x_dest_sub_inv varchar2, x_dest_org_id number) return varchar2;
99
100
101 --
102 -- Inventory
103 --
104 procedure inventory ( itemtype in varchar2,
105 itemkey in varchar2,
106 actid in number,
107 funcmode in varchar2,
108 result out NOCOPY varchar2 )
109 is
110 x_progress varchar2(100) := '000';
111 x_debug_stmt varchar2(100) := NULL;
112 x_dest_sub_inv varchar2(25);
113 x_subinv_type varchar2(25);
114 x_account number := NULL;
115 x_inv_item_type varchar2(25);
116 x_dest_org_id number;
117 x_item_id number;
118 --<INVCONV R12 START>
119 x_status varchar2(1);
120 x_vendor_site_id number;
121 x_msg_data varchar2(2000);
122 x_msg_count number;
123 --<INVCONV R12 END>
124 success varchar2(2) := 'Y';
125 dummy VARCHAR2(40);
126 ret BOOLEAN;
127 begin
128
129 x_debug_stmt := 'PO_WF_PO_CHARGE_ACC.inventory: 01' || x_progress;
130 IF (g_po_wf_debug = 'Y') THEN
131 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_debug_stmt);
132 END IF;
133
134
135 -- Do nothing in cancel or timeout mode
136 --
137 if (funcmode <> wf_engine.eng_run) then
138
139 result := wf_engine.eng_null;
140 return;
141
142 end if;
143
144 x_dest_org_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
145 itemkey => itemkey,
146 aname => 'DESTINATION_ORGANIZATION_ID');
147
148 x_item_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
149 itemkey => itemkey,
150 aname => 'ITEM_ID');
151
152 x_dest_sub_inv := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
153 itemkey => itemkey,
154 aname => 'DESTINATION_SUBINVENTORY');
155
156 /* Start DEBUG
157 If (debug_acc_generator_wf) then
158 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.inventory');
159 dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_dest_org_id));
160 dbms_output.put_line ('ITEM_ID: ' || to_char(x_item_id));
161 dbms_output.put_line ('DESTINATION_SUBINVENTORY: ' || x_dest_sub_inv);
162 end if;
163 End DEBUG */
164
165 x_debug_stmt := 'PO_WF_PO_CHARGE_ACC.inventory: dest sub inv :' || x_dest_sub_inv;
166 IF (g_po_wf_debug = 'Y') THEN
167 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_debug_stmt);
168 END IF;
169
170 /* Start DEBUG
171 If (debug_acc_generator_wf) then
172 dbms_output.put_line ('X_INV_ITEM_TYPE:' || x_inv_item_type);
173 end if;
174 End DEBUG */
175
176 x_debug_stmt := 'PO_WF_PO_CHARGE_ACC.inventory: inv item type :' || x_inv_item_type;
177 IF (g_po_wf_debug = 'Y') THEN
178 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_debug_stmt);
179 END IF;
180
181 x_inv_item_type := check_inv_item_type (itemtype, itemkey, x_dest_org_id, x_item_id);
182
183 --Bug 7639037. Uday Phadtare. Commented call to GMF SLA API for process_org because currently
184 --GMF_transaction_accounts_PUB.get_accounts is not getting the account as per SLA setup.
185 /*
186 --<INVCONV R12 START> call the SLA API instead of GML_ACT_ENERATE
187 IF ( PO_GML_DB_COMMON.check_process_org(x_dest_org_id) = 'Y') THEN
188 x_vendor_site_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
189 itemkey => itemkey,
190 aname => 'VENDOR_SITE_ID');
191
192 if (x_dest_sub_inv is not null) then
193 x_subinv_type := check_sub_inv_type(itemtype, itemkey, x_dest_sub_inv,
194 x_dest_org_id);
195 end if;
196 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).account_type_code := GMF_transaction_accounts_PUB.G_CHARGE_INV_ACCT;
197 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).item_type := x_inv_item_type;
198 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).subinventory_type := x_subinv_type;
199 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).organization_id := x_dest_org_id;
200 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).inventory_item_id := x_item_id;
201 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).vendor_site_id := x_vendor_site_id;
202
203 GMF_transaction_accounts_PUB.get_accounts(
204 p_api_version => 1.0,
205 p_init_msg_list => dummy,
206 p_source => 'PO',
207 x_return_status => X_status,
208 x_msg_data => x_msg_data,
209 x_msg_count => x_msg_count);
210 x_account := GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).target_ccid;
211 --<INVCONV R12 END>
212 ELSE
213 */
214
215 If x_inv_item_type = 'EXPENSE' then
216
217 if (x_dest_sub_inv IS NOT NULL) then -- Subinventory is provided
218 begin
219
220 /* 949595 kbenjami 8/25/99. Proprogated fix from R11.
221 Bug # 943948
222 Adding the organization_id condition to the select below.
223 */
224 select expense_account into x_account
225 from mtl_secondary_inventories
226 where secondary_inventory_name = x_dest_sub_inv
227 and organization_id = x_dest_org_id;
228 exception
229 when others then
230 x_account := NULL;
231 end;
232 end if;
233
234 if (x_account is NULL) then -- Get expense account from Item Master
235 begin
236 select EXPENSE_ACCOUNT into x_account
237 from MTL_SYSTEM_ITEMS
238 where organization_id = x_dest_org_id
239 and inventory_item_id = x_item_id;
240
241 exception
242 when others then
243 x_account := NULL;
244 end;
245 end if;
246
247 if (x_account is NULL) then -- Get account from Org
248 begin
249 select expense_account into x_account
250 from mtl_parameters
251 where organization_id = x_dest_org_id;
252
253 exception
254 when no_data_found then
255 x_account := NULL;
256 when others then
257 x_progress := '001';
258 raise;
259 end;
260 end if;
261
262 else -- item type is ASSET
263
264 -- Test subinventory for Asset or Expense tracking.
265
266 if (x_dest_sub_inv is not null) then
267 x_subinv_type := check_sub_inv_type(itemtype, itemkey, x_dest_sub_inv, x_dest_org_id);
268 end if;
269
270 IF (x_dest_sub_inv is null) then
271
272 -- Get the default account from the Organization
273 begin
274 select material_account into x_account
275 from mtl_parameters
276 where organization_id = x_dest_org_id;
277 exception
278 when no_data_found then
279 x_account := NULL;
280 when others then
281 x_progress := '002';
282 raise;
283 end;
284
285 ELSIF x_subinv_type = 'EXPENSE' then
286
287 begin
288 select expense_account into x_account
289 from mtl_secondary_inventories
290 where secondary_inventory_name = x_dest_sub_inv
291 and organization_id = x_dest_org_id;
292 exception
293 when others then
294 x_account := NULL;
295 end;
296
297 if (x_account is NULL) then
298
299 -- Get the default account from the Organization
300 begin
301 select expense_account into x_account
302 from mtl_parameters
303 where organization_id = x_dest_org_id;
304 exception
305 when no_data_found then
306 x_account := NULL;
307 when others then
308 x_progress := '003';
309 raise;
310 end;
311 end if;
312
313 ELSE -- destination sub inv type is ASSET
314
315 begin
316 select material_account into x_account
317 from mtl_secondary_inventories
318 where secondary_inventory_name = x_dest_sub_inv
319 and organization_id = x_dest_org_id;
320 exception
321 when others then
322 x_account := NULL;
323 end;
324
325 if (x_account IS NULL) then
326 begin
327 select material_account into x_account
328 from mtl_parameters
329 where organization_id = x_dest_org_id;
330 exception
331 when no_data_found then
332 x_account := NULL;
333 when others then
334 x_progress := '004';
335 raise;
336 end;
337 end if;
338 END IF;
339 end if;
340 --END IF; --Bug 7639037
341
342 if (x_account IS NULL) then
343
344 /* Start DEBUG
345 If (debug_acc_generator_wf) then
346 dbms_output.put_line ('RESULT = COMPLETE:FAILURE');
347 end if;
348 End DEBUG */
349
350 result := 'COMPLETE:FAILURE';
351 return;
352 end if;
353
354 po_wf_util_pkg.SetItemAttrNumber ( itemtype=>itemtype,
355 itemkey=>itemkey,
356 aname=>'TEMP_ACCOUNT_ID',
357 avalue=>x_account );
358 /* Start DEBUG
359 If (debug_acc_generator_wf) then
360 dbms_output.put_line ('RESULT = COMPLETE:SUCCESS, x_account = ' || to_char(x_account));
361 end if;
362 End DEBUG */
363
364 result := 'COMPLETE:SUCCESS';
365 RETURN;
366
367 EXCEPTION
368 WHEN OTHERS THEN
369 wf_core.context('PO_WF_PO_CHARGE_ACC','inventory',x_progress);
370
371 /* Start DEBUG
372 If (debug_acc_generator_wf) then
373 dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.inventory');
374 end if;
375 End DEBUG */
376
377 raise;
378
379 end inventory;
380
381
382 --
383 -- Private functions body for Inventory destination type.
384 --
385
386 function check_inv_item_type ( itemtype varchar2,
387 itemkey varchar2,
388 x_dest_org_id number,
389 x_item_id number)
390 return varchar2
391 is
392 x_asset_item_flag varchar2(4);
393 x_progress varchar2(200);
394 begin
395 x_progress := 'PO_WF_PO_CHARGE_ACC.check_inv_item_type: 01';
396
397 select inventory_asset_flag into x_asset_item_flag
398 from mtl_system_items
399 where organization_id = x_dest_org_id
400 and inventory_item_id = x_item_id;
401
402 /* Start DEBUG
403 If (debug_acc_generator_wf) then
404 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.check_inv_item_type');
405 dbms_output.put_line ('X_ASSET_ITEM_FLAG: ' || x_asset_item_flag);
406 end if;
407 End DEBUG */
408
409 if x_asset_item_flag = 'Y' then
410 return 'ASSET';
411 else
412 return 'EXPENSE';
413 end if;
414
415 EXCEPTION
416 WHEN OTHERS THEN
417 -- Bug 3433867: Enhanced exception handling for this function
418 IF (g_po_wf_debug = 'Y') THEN
419 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
420 'PO_WF_PO_CHARGE_ACC.check_inv_item_type EXCEPTION at '||x_progress
421 ||': '||SQLERRM);
422 END IF;
423 wf_core.context('PO_WF_PO_CHARGE_ACC','check_inv_item_type',x_progress);
424 raise;
425 end;
426
427 --
428
429 function check_sub_inv_type ( itemtype varchar2,
430 itemkey varchar2,
431 x_dest_sub_inv varchar2,
432 x_dest_org_id number )
433 return varchar2
434 is
435 x_asset_inventory number;
436 x_progress varchar2(100);
437 begin
438
439 x_progress := 'PO_WF_PO_CHARGE_ACC.check_sub_inv_type: 01';
440
441 select asset_inventory into x_asset_inventory
442 from mtl_secondary_inventories
443 where secondary_inventory_name = x_dest_sub_inv
444 and organization_id = x_dest_org_id;
445
446 if (x_asset_inventory = 1) then
447 return 'ASSET';
448 elsif (x_asset_inventory = 2) then
449 return 'EXPENSE';
450 else
451 return '';
452 end if;
453
454 EXCEPTION
455 WHEN OTHERS THEN
456 wf_core.context('PO_WF_PO_CHARGE_ACC','check_sub_inv_type',x_progress);
457 raise;
458 end;
459
460 -- * ****************************************************************************** *
461 -- * ****************************************************************************** *
462
463 --
464 -- Expense
465 --
466 procedure expense ( itemtype in varchar2,
467 itemkey in varchar2,
468 actid in number,
469 funcmode in varchar2,
470 result out NOCOPY varchar2 )
471 is
472 x_progress varchar2(100);
473 success varchar2(2);
474 x_dest_org_id number;
475 x_item_id number;
476 x_expense_acc number;
477 --<INVCONV R12 START>
478 x_status varchar2(1);
479 x_vendor_site_id number;
480 x_msg_data varchar2(2000);
481 x_msg_count number;
482 --<INVCONV R12 END>
483
484 dummy VARCHAR2(40);
485 ret BOOLEAN;
486 begin
487
488 x_progress := 'PO_WF_PO_CHARGE_ACC.expense: 01';
489 IF (g_po_wf_debug = 'Y') THEN
490 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
491 END IF;
492
493
494 -- Do nothing in cancel or timeout mode
495 --
496 if (funcmode <> wf_engine.eng_run) then
497
498 result := wf_engine.eng_null;
499 return;
500
501 end if;
502
503 x_dest_org_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
504 itemkey => itemkey,
505 aname => 'DESTINATION_ORGANIZATION_ID');
506
507 x_item_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
508 itemkey => itemkey,
509 aname => 'ITEM_ID');
510
511 /* Start DEBUG
512 If (debug_acc_generator_wf) then
513 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.expense');
514 dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_dest_org_id));
515 dbms_output.put_line ('ITEM_ID: ' || to_char(x_item_id));
516 end if;
517 End DEBUG */
518
519 --Bug 7639037. Uday Phadtare. Commented call to GMF SLA API for process_org because currently
520 --GMF_transaction_accounts_PUB.get_accounts is not getting the account as per SLA setup.
521 /*
522 --<INVCONV R12 START>
523 if ( PO_GML_DB_COMMON.check_process_org(x_dest_org_id) = 'Y')
524 then
525 x_vendor_site_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
526 itemkey => itemkey,
527 aname => 'VENDOR_SITE_ID');
528 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).account_type_code := GMF_transaction_accounts_PUB.G_CHARGE_EXP_ACCT;
529 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).item_type := '';
530 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).subinventory_type := '';
531 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).organization_id := x_dest_org_id;
532 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).inventory_item_id := x_item_id;
533 GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).vendor_site_id := x_vendor_site_id;
534
535 GMF_transaction_accounts_PUB.get_accounts(
536 p_api_version => 1.0,
537 p_init_msg_list => dummy,
538 p_source => 'PO',
539 x_return_status => X_status,
540 x_msg_data => x_msg_data,
541 x_msg_count => x_msg_count);
542 x_expense_acc := GMF_transaction_accounts_PUB.g_gmf_accts_tab_PUR(1).target_ccid;
543
544 --GML_ACCT_GENERATE.GENERATE_OPM_ACCT('EXPENSE','', '', x_dest_org_id, x_item_id, x_vendor_site_id, x_expense_acc);
545 If (x_expense_acc is null) then
546 success := 'N';
547 end if;
548 ELSE
549 */
550 begin
551
552 select EXPENSE_ACCOUNT into x_expense_acc
553 from MTL_SYSTEM_ITEMS
554 where organization_id = x_dest_org_id
555 and inventory_item_id = x_item_id;
556
557 /*Bug 1319679
558 If the default expense account for the item is null
559 we should be returning 'N' for Success ie the result
560 of the workflow process should be COMPLETE:FAILURE
561 */
562
563 if (x_expense_acc is null) then
564 success := 'N';
565 end if;
566
567 exception
568 WHEN NO_DATA_FOUND THEN
569 success := 'N';
570 end;
571 --END IF; --Bug 7639037
572 --<INVCONV R12 END>
573
574 if (success = 'N') then
575 result := 'COMPLETE:FAILURE';
576
577 IF (g_po_wf_debug = 'Y') THEN
578 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
579 'PO_WF_PO_CHARGE_ACC.expense result='||result);
580 END IF;
581
582 return;
583 end if;
584
585 po_wf_util_pkg.SetItemAttrNumber ( itemtype=>itemtype,
586 itemkey=>itemkey,
587 aname=>'TEMP_ACCOUNT_ID',
588 avalue=>x_expense_acc );
589
590 result := 'COMPLETE:SUCCESS';
591 -- Bug 3703469: Clear any previous messages in the stack if
592 -- account is generated successfully
593 fnd_message.clear;
594 RETURN;
595
596 IF (g_po_wf_debug = 'Y') THEN
597 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
598 'PO_WF_PO_CHARGE_ACC.expense x_expense_acc='||x_expense_acc);
599 END IF;
600
601 EXCEPTION
602 WHEN OTHERS THEN
603 wf_core.context('PO_WF_PO_CHARGE_ACC','expense',x_progress);
604
605 /* Start DEBUG
606 If (debug_acc_generator_wf) then
607 dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.expense');
608 end if;
609 End DEBUG */
610
611 raise;
612
613 end expense;
614
615 -- * ****************************************************************************** *
616 -- * ****************************************************************************** *
617 --
618 -- Check type of WIP
619 --
620 procedure check_type_of_wip ( itemtype in varchar2,
621 itemkey in varchar2,
622 actid in number,
623 funcmode in varchar2,
624 result out NOCOPY varchar2 )
625 is
626 wip_entity_type varchar2(80);
627 x_progress varchar2(100);
628 begin
629
630 x_progress := 'PO_WF_PO_CHARGE_ACC.check_type_of_wip: 01';
631 IF (g_po_wf_debug = 'Y') THEN
632 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
633 END IF;
634
635
636 -- Do nothing in cancel or timeout mode
637 --
638 if (funcmode <> wf_engine.eng_run) then
639
640 result := wf_engine.eng_null;
641 return;
642
643 end if;
644
645 wip_entity_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
646 itemkey => itemkey,
647 aname => 'WIP_ENTITY_TYPE');
648 /* Start DEBUG
649 If (debug_acc_generator_wf) then
650 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.check_type_of_wip');
651 dbms_output.put_line ('WIP_ENTITY_TYPE: ' || wip_entity_type);
652 end if;
653 End DEBUG */
654
655 if (wip_entity_type = '2') then
656 result := 'COMPLETE:SCHEDULE';
657 else
658 result := 'COMPLETE:JOB_WIP';
659 end if;
660
661 return;
662
663 EXCEPTION
664 WHEN OTHERS THEN
665 wf_core.context('PO_WF_PO_CHARGE_ACC','check_type_of_wip',x_progress);
666 raise;
667
668 end check_type_of_wip;
669
670 -- * ****************************************************************************** *
671
672 --
673 -- JOB_WIP
674 --
675 procedure job_wip ( itemtype in varchar2,
676 itemkey in varchar2,
677 actid in number,
678 funcmode in varchar2,
679 result out NOCOPY varchar2 )
680 is
681 x_wip_entity_type varchar2(80);
682 x_wip_job_account NUMBER := NULL;
683 x_wip_entity_id NUMBER;
684 x_bom_cost_element_id NUMBER;
685 x_destination_organization_id NUMBER;
686 x_progress varchar2(200);
687 --Bug# 1902716 togeorge 07/25/2001
688 --EAM:
689 x_return_status varchar2(1);
690 x_msg_count number;
691 x_msg_data varchar2(8000);
692
693 -- <FPJ Costing CST_EAM API START>
694 l_category_id NUMBER;
695 -- <FPJ Costing CST_EAM API END>
696
697 begin
698
699 x_progress := 'PO_WF_PO_CHARGE_ACC.job_wip: 01';
700 IF (g_po_wf_debug = 'Y') THEN
701 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
702 END IF;
703
704 -- Do nothing in cancel or timeout mode
705 --
706 if (funcmode <> wf_engine.eng_run) then
707
708 result := wf_engine.eng_null;
709 return;
710
711 end if;
712
713 x_destination_organization_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
714 itemkey => itemkey,
715 aname => 'DESTINATION_ORGANIZATION_ID');
716
717 x_bom_cost_element_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
718 itemkey => itemkey,
719 aname => 'BOM_COST_ELEMENT_ID');
720
721 x_wip_entity_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
722 itemkey => itemkey,
723 aname => 'WIP_ENTITY_ID');
724
725 x_wip_entity_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
726 itemkey => itemkey,
727 aname => 'WIP_ENTITY_TYPE');
728
729 -- <FPJ Costing CST_EAM API START>
730 l_category_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
731 itemkey => itemkey,
732 aname => 'CATEGORY_ID');
733 -- <FPJ Costing CST_EAM API END>
734
735 /* Start DEBUG
736 If (debug_acc_generator_wf) then
737 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.job_wip');
738 dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_destination_organization_id));
739 dbms_output.put_line ('BOM_COST_ELEMENT_ID: ' || to_char(x_bom_cost_element_id));
740 dbms_output.put_line ('WIP_ENTITY_ID: ' || to_char(x_wip_entity_id));
741 dbms_output.put_line ('WIP_ENTITY_TYPE: ' || x_wip_entity_type);
742 end if;
743 End DEBUG */
744
745 x_progress := 'org_id:' || to_char(x_destination_organization_id) || 'bom_cost_element_id:' ||
746 to_char(x_bom_cost_element_id) || 'wip_entity_id' || to_char(x_wip_entity_id) ||
747 'wip_entity_type' || x_wip_entity_type ||
748 -- <FPJ Costing CST_EAM API START>
749 'l_category_id' || to_char(l_category_id);
750 -- <FPJ Costing CST_EAM API END>
751
752 IF (g_po_wf_debug = 'Y') THEN
753 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
754 END IF;
755
756 --Bug# 1902716 togeorge 07/25/2001
757 --EAM: if entity type in(6,7) get the eam account. This call is
758 -- made from job_wip to avoid the impact on workflow.
759 --On failure the API returns -1. So it is nullified for the check
760 --at the end of this procedure.
761
762 IF (x_wip_entity_type in (6,7)) THEN
763 IF (x_wip_job_account IS NULL) THEN
764
765 -- bug 556021 : if the cost element is OSP then pick the OSP account.
766 IF (x_bom_cost_element_id LIKE '4') THEN
767
768 BEGIN
769 SELECT outside_processing_account
770 INTO x_wip_job_account
771 FROM WIP_DISCRETE_JOBS
772 WHERE ORGANIZATION_ID = x_destination_organization_id
773 AND WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
774 AND OUTSIDE_PROCESSING_ACCOUNT <> -1;
775 EXCEPTION
776 WHEN NO_DATA_FOUND THEN
777 NULL;
778 END;
779
780 ELSE
781 -- <FPJ Costing CST_EAM API START>
782 IF (CST_VersionCtrl_GRP.Get_Current_Release_Level <
783 CST_Release_GRP.Get_J_Release_Level) THEN
784 -- Lower the J Release
785 CST_eamCost_PUB.get_Direct_Item_Charge_Acct(
786 p_api_version => 1.0,
787 p_init_msg_list => null,
788 p_commit => null,
789 p_validation_level => null,
790 p_wip_entity_id => x_wip_entity_id,
791 x_material_acct => x_wip_job_account,
792 x_return_status => x_return_status,
793 x_msg_count => x_msg_count,
794 x_msg_data => x_msg_data);
795 ELSE
796 -- J Release or higher
797 CST_Utility_PUB.get_Direct_Item_Charge_Acct(
798 p_api_version => 1.0,
799 p_init_msg_list => null,
800 p_commit => null,
801 p_validation_level => null,
802 p_wip_entity_id => x_wip_entity_id,
803 x_material_acct => x_wip_job_account,
804 x_return_status => x_return_status,
805 x_msg_count => x_msg_count,
806 x_msg_data => x_msg_data,
807 p_category_id => l_category_id);
808 END IF; /* IF (CST_VersionCtrl_GRP.Get_Current_Release_Level < */
809 -- <FPJ Costing CST_EAM API END>
810 END IF; -- bug 556021
811
812 IF (x_wip_job_account = -1) THEN
813 x_wip_job_account := null;
814 END IF;
815 END IF;
816 ELSE
817
818 /* Bug - 2204214 - WIP has added more WIP ENTITY types for JOBS and hence
819 checking for just 1 for a JOB is not valid and does not build the account.
820 Changed all the where clauses in the below sqls to check for 1, 3, 4 , 5 */
821
822 IF (x_wip_job_account IS NULL) THEN
823 IF (x_bom_cost_element_id LIKE '5') THEN
824 BEGIN
825 SELECT OVERHEAD_ACCOUNT INTO x_wip_job_account
826 FROM WIP_DISCRETE_JOBS
827 WHERE ORGANIZATION_ID = x_destination_organization_id
828 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
829 AND OVERHEAD_ACCOUNT <> -1
830 AND NVL(x_wip_entity_type,'2') in ('1', '3', '4', '5'));
831 EXCEPTION
832 WHEN NO_DATA_FOUND THEN
833 NULL;
834 END;
835 END IF;
836 END IF;
837 IF (x_wip_job_account IS NULL) THEN
838 IF (x_bom_cost_element_id LIKE '4') THEN
839 BEGIN
840 SELECT outside_processing_account INTO x_wip_job_account
841 FROM WIP_DISCRETE_JOBS
842 WHERE ORGANIZATION_ID = x_destination_organization_id
843 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
844 AND OUTSIDE_PROCESSING_ACCOUNT <> -1
845 AND NVL(x_wip_entity_type,'2') in ('1', '3', '4', '5'));
846 EXCEPTION
847 WHEN NO_DATA_FOUND THEN
848 NULL;
849 END;
850 END IF;
851 END IF;
852 IF (x_wip_job_account IS NULL) THEN
853 IF (x_bom_cost_element_id LIKE '3') THEN
854 BEGIN
855 SELECT RESOURCE_ACCOUNT INTO x_wip_job_account
856 FROM WIP_DISCRETE_JOBS
857 WHERE ORGANIZATION_ID = x_destination_organization_id
858 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
859 AND RESOURCE_ACCOUNT <> -1
860 AND NVL(x_wip_entity_type,'2') in ('1', '3', '4', '5'));
861 EXCEPTION
862 WHEN NO_DATA_FOUND THEN
863 NULL;
864 END;
865 END IF;
866 END IF;
867 IF (x_wip_job_account IS NULL) THEN
868 IF (x_bom_cost_element_id LIKE '2') THEN
869 BEGIN
870 SELECT MATERIAL_OVERHEAD_ACCOUNT INTO x_wip_job_account
871 FROM WIP_DISCRETE_JOBS
872 WHERE ORGANIZATION_ID = x_destination_organization_id
873 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
874 AND MATERIAL_OVERHEAD_ACCOUNT <> -1
875 AND NVL(x_wip_entity_type,'2') in ('1', '3', '4', '5'));
876 EXCEPTION
877 WHEN NO_DATA_FOUND THEN
878 NULL;
879 END;
880 END IF;
881 END IF;
882 IF (x_wip_job_account IS NULL) THEN
883 IF (x_bom_cost_element_id LIKE '1') THEN
884 BEGIN
885 SELECT MATERIAL_ACCOUNT INTO x_wip_job_account
886 FROM WIP_DISCRETE_JOBS
887 WHERE ORGANIZATION_ID = x_destination_organization_id
888 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
889 AND MATERIAL_ACCOUNT <> -1
890 AND NVL(x_wip_entity_type,'2') in ('1', '3', '4', '5'));
891 EXCEPTION
892 WHEN NO_DATA_FOUND THEN
893 NULL;
894 END;
895 END IF;
896 END IF;
897 IF (x_wip_job_account IS NULL) THEN
898 BEGIN
899 SELECT FLEX_VALUE INTO x_wip_job_account
900 FROM FND_FLEX_VALUES_VL
901 WHERE FLEX_VALUE = x_destination_organization_id
902 AND (FLEX_VALUE_SET_ID = 102256);
903 EXCEPTION
904 WHEN NO_DATA_FOUND THEN
905 NULL;
906 END;
907 END IF;
908 END IF;
909
910 x_progress := 'WIP_JOB_ACCOUNT is :' || to_char(x_wip_job_account);
911 IF (g_po_wf_debug = 'Y') THEN
912 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
913 END IF;
914
915 if (x_wip_job_account IS NOT NULL) then
916
917 po_wf_util_pkg.SetItemAttrText ( itemtype=>itemtype,
918 itemkey=>itemkey,
919 aname=>'TEMP_ACCOUNT_ID',
920 avalue=>x_wip_job_account );
921 result := 'COMPLETE:SUCCESS';
922 else
923 result := 'COMPLETE:FAILURE';
924 end if;
925
926 RETURN;
927
928 EXCEPTION
929 WHEN OTHERS THEN
930 wf_core.context('PO_WF_PO_CHARGE_ACC','job_wip',x_progress);
931 IF (g_po_wf_debug = 'Y') THEN
932 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.JOB_WIP');
933 END IF;
934 raise;
935
936 end job_wip;
937
938 -- * ****************************************************************************** *
939
940 --
941 -- Schedule
942 --
943 procedure schedule ( itemtype in varchar2,
944 itemkey in varchar2,
945 actid in number,
946 funcmode in varchar2,
947 result out NOCOPY varchar2 )
948 is
949 x_wip_entity_type varchar2(80);
950 x_wip_schedule_account NUMBER := NULL;
951 x_wip_entity_id NUMBER;
952 x_bom_cost_element_id NUMBER;
953 x_destination_organization_id NUMBER;
954 x_wip_repetitive_schedule_id NUMBER;
955 x_progress varchar2(200);
956 begin
957
958 x_progress := 'PO_WF_PO_CHARGE_ACC.schedule: 01';
959 IF (g_po_wf_debug = 'Y') THEN
960 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
961 END IF;
962
963
964 -- Do nothing in cancel or timeout mode
965 --
966 if (funcmode <> wf_engine.eng_run) then
967
968 result := wf_engine.eng_null;
969 return;
970
971 end if;
972
973 x_destination_organization_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
974 itemkey => itemkey,
975 aname => 'DESTINATION_ORGANIZATION_ID');
976
977 x_bom_cost_element_id := po_wf_util_pkg.GetItemAttrNumber (itemtype => itemtype,
978 itemkey => itemkey,
979 aname => 'BOM_COST_ELEMENT_ID');
980
981 x_wip_entity_id := po_wf_util_pkg.GetItemAttrNumber ( itemtype => itemtype,
982 itemkey => itemkey,
983 aname => 'WIP_ENTITY_ID');
984
985 x_wip_entity_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
986 itemkey => itemkey,
987 aname => 'WIP_ENTITY_TYPE');
988
989 x_wip_repetitive_schedule_id := po_wf_util_pkg.GetItemAttrNumber (itemtype => itemtype,
990 itemkey => itemkey,
991 aname => 'WIP_REPETITIVE_SCHEDULE_ID');
992
993 /* Start DEBUG
994 If (debug_acc_generator_wf) then
995 dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.Schedule');
996 dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_destination_organization_id));
997 dbms_output.put_line ('BOM_COST_ELEMENT_ID: ' || to_char(x_bom_cost_element_id));
998 dbms_output.put_line ('WIP_ENTITY_ID: ' || to_char(x_wip_entity_id));
999 dbms_output.put_line ('WIP_ENTITY_TYPE: ' || x_wip_entity_type);
1000 dbms_output.put_line ('WIP_REPETITIVE_SCHEDULE_ID: ' || to_char(x_wip_repetitive_schedule_id));
1001 end if;
1002 End DEBUG */
1003
1004 x_progress := 'org_id:' || to_char(x_destination_organization_id) || 'bom_cost_element_id:' ||
1005 to_char(x_bom_cost_element_id) || 'wip_entity_id' || to_char(x_wip_entity_id) ||
1006 'wip_entity_type' || x_wip_entity_type || 'wip_repetitive_schedule_id' ||
1007 to_char(x_wip_repetitive_schedule_id);
1008
1009 IF (g_po_wf_debug = 'Y') THEN
1010 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1011 END IF;
1012
1013
1014 IF (x_wip_schedule_account IS NULL) THEN
1015 IF (x_bom_cost_element_id LIKE '5') THEN
1016 BEGIN
1017 SELECT OVERHEAD_ACCOUNT INTO x_wip_schedule_account
1018 FROM WIP_REPETITIVE_SCHEDULES
1019 WHERE ORGANIZATION_ID = x_destination_organization_id
1020 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
1021 AND '2' = NVL(x_wip_entity_type,'1')
1022 AND REPETITIVE_SCHEDULE_ID = NVL(x_wip_repetitive_schedule_id,-99)
1023 AND OVERHEAD_ACCOUNT <> -1);
1024 EXCEPTION
1025 WHEN NO_DATA_FOUND THEN
1026 NULL;
1027 END;
1028 END IF;
1029 END IF;
1030
1031 IF (x_wip_schedule_account IS NULL) THEN
1032 IF (x_bom_cost_element_id LIKE '4') THEN
1033 BEGIN
1034 SELECT OUTSIDE_PROCESSING_ACCOUNT INTO x_wip_schedule_account
1035 FROM WIP_REPETITIVE_SCHEDULES
1036 WHERE ORGANIZATION_ID = TO_NUMBER(x_destination_organization_id)
1037 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
1038 AND '2' = NVL(x_wip_entity_type,'1')
1039 AND REPETITIVE_SCHEDULE_ID = NVL(x_wip_repetitive_schedule_id,-99)
1040 AND OUTSIDE_PROCESSING_ACCOUNT <> -1);
1041 EXCEPTION
1042 WHEN NO_DATA_FOUND THEN
1043 NULL;
1044 END;
1045 END IF;
1046 END IF;
1047 IF (x_wip_schedule_account IS NULL) THEN
1048 IF (x_bom_cost_element_id LIKE '3') THEN
1049 BEGIN
1050 SELECT RESOURCE_ACCOUNT INTO x_wip_schedule_account
1051 FROM WIP_REPETITIVE_SCHEDULES
1052 WHERE ORGANIZATION_ID = x_destination_organization_id
1053 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
1054 AND '2' = NVL(x_wip_entity_type,'1')
1055 AND REPETITIVE_SCHEDULE_ID = NVL(x_wip_repetitive_schedule_id,-99)
1056 AND RESOURCE_ACCOUNT <> -1) ;
1057 EXCEPTION
1058 WHEN NO_DATA_FOUND THEN
1059 NULL;
1060 END;
1061 END IF;
1062 END IF;
1063
1064 IF (x_wip_schedule_account IS NULL) THEN
1065 IF (x_bom_cost_element_id LIKE '2') THEN
1066 BEGIN
1067 SELECT MATERIAL_OVERHEAD_ACCOUNT INTO x_wip_schedule_account
1068 FROM WIP_REPETITIVE_SCHEDULES
1069 WHERE ORGANIZATION_ID = TO_NUMBER(x_destination_organization_id)
1070 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
1071 AND '2' = NVL(x_wip_entity_type,'1')
1072 AND REPETITIVE_SCHEDULE_ID = NVL(x_wip_repetitive_schedule_id,-99)
1073 AND MATERIAL_OVERHEAD_ACCOUNT <> -1);
1074 EXCEPTION
1075 WHEN NO_DATA_FOUND THEN
1076 NULL;
1077 END;
1078 END IF;
1079 END IF;
1080
1081 IF (x_wip_schedule_account IS NULL) THEN
1082 IF (x_bom_cost_element_id LIKE '1') THEN
1083 BEGIN
1084 SELECT MATERIAL_ACCOUNT INTO x_wip_schedule_account
1085 FROM WIP_REPETITIVE_SCHEDULES
1086 WHERE ORGANIZATION_ID = x_destination_organization_id
1087 AND (WIP_ENTITY_ID = NVL(x_wip_entity_id,-99)
1088 AND '2' = NVL(x_wip_entity_type,'2')
1089 AND REPETITIVE_SCHEDULE_ID = NVL(x_wip_repetitive_schedule_id,-99)
1090 AND MATERIAL_ACCOUNT <> -1);
1091 EXCEPTION
1092 WHEN NO_DATA_FOUND THEN
1093 NULL;
1094 END;
1095 END IF;
1096 END IF;
1097 IF (X_WIP_SCHEDULE_ACCOUNT IS NULL) THEN
1098 BEGIN
1099 SELECT FLEX_VALUE INTO x_wip_schedule_account
1100 FROM FND_FLEX_VALUES_VL
1101 WHERE FLEX_VALUE = x_destination_organization_id
1102 AND (FLEX_VALUE_SET_ID = 102256);
1103 EXCEPTION
1104 WHEN NO_DATA_FOUND THEN
1105 NULL;
1106 END;
1107 END IF;
1108
1109 x_progress := 'WIP_JOB_ACCOUNT is :' || to_char(x_wip_schedule_account);
1110 IF (g_po_wf_debug = 'Y') THEN
1111 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1112 END IF;
1113
1114 if (x_wip_schedule_account IS NOT NULL) then
1115
1116 po_wf_util_pkg.SetItemAttrText ( itemtype=>itemtype,
1117 itemkey=>itemkey,
1118 aname=>'TEMP_ACCOUNT_ID',
1119 avalue=>x_wip_schedule_account );
1120 result := 'COMPLETE:SUCCESS';
1121 else
1122 result := 'COMPLETE:FAILURE';
1123 end if;
1124
1125 RETURN;
1126
1127 EXCEPTION
1128 WHEN OTHERS THEN
1129 wf_core.context('PO_WF_PO_CHARGE_ACC','schedule',x_progress);
1130 IF (g_po_wf_debug = 'Y') THEN
1131 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.SCHEDULE');
1132 END IF;
1133 raise;
1134
1135 end schedule;
1136
1137 --
1138
1139 --
1140 -- is_encumbrance_on
1141 --
1142
1143 procedure is_encumbrance_on ( itemtype in varchar2,
1144 itemkey in varchar2,
1145 actid in number,
1146 funcmode in varchar2,
1147 result out NOCOPY varchar2 )
1148 is
1149 po_encumbrance_flag varchar2(4);
1150 x_destination_type varchar2(25);
1151 l_is_financing_flag varchar2(4); --<Complex Work R12>
1152 l_is_advance_flag varchar2(4); --<Complex Work R12>
1153 x_progress varchar2(200);
1154
1155 l_purch_encumbrance_flag VARCHAR2(10);
1156 l_req_encumbrance_flag VARCHAR2(10);
1157 x_wip_entity_type NUMBER;
1158 begin
1159
1160 x_progress := 'PO_WF_PO_CHARGE_ACC.is_encumbrance_on: 01';
1161 IF (g_po_wf_debug = 'Y') THEN
1162 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1163 END IF;
1164
1165
1166 -- Do nothing in cancel or timeout mode
1167 --
1168 if (funcmode <> wf_engine.eng_run) then
1169
1170 result := wf_engine.eng_null;
1171 return;
1172
1173 end if;
1174
1175 po_encumbrance_flag := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
1176 itemkey => itemkey,
1177 aname => 'PO_ENCUMBRANCE_FLAG');
1178
1179 x_destination_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
1180 itemkey => itemkey,
1181 aname => 'DESTINATION_TYPE_CODE');
1182
1183 --<Complex Work R12>: added check for financing_flag and advance_flag in the
1184 --setting of result below. if either flag is set to 'Y', then this is a PREPAYMENT
1185 --type distribution and we do not encumber it.
1186 l_is_financing_flag := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
1187 itemkey => itemkey,
1188 aname => 'IS_FINANCING_DISTRIBUTION');
1189
1190 l_is_advance_flag := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
1191 itemkey => itemkey,
1192 aname => 'IS_ADVANCE_DISTRIBUTION');
1193
1194 -- Bug 5058123 Start: This code is shared between Req and PO Account Generators.
1195 -- The new R12 Complex Work attributes are not defined in Req AG WF. So we would
1196 -- get NULL for these attribute values for requisition case. Set them to 'N'.
1197 -- We do not want to compare the item_type to 'POWFRQAG' (i.e. seeded Req AG WF)
1198 -- because the item_types are not hard-coded and customers may change them.
1199 IF (g_po_wf_debug = 'Y') THEN
1200 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'po_encumbrance_flag='||po_encumbrance_flag||', x_destination_type='||x_destination_type||', l_is_financing_flag='||l_is_financing_flag||', l_is_advance_flag='||l_is_advance_flag);
1201
1202 -- DEBUG QUERIES: Start
1203 -- As part of bug 5058123, there was another issue related to MOAC setup
1204 -- of MO: Security Profile. The value of PO_ENCUMBRANCE_FLAG was NULL.
1205 -- Bug 4932685 had similar symptoms. In both cases, the bug stopped
1206 -- getting reproduced after couple of days, and we could not get to the
1207 -- root cause. The following queries are put in to record some debug values
1208 -- that will help get to the root cause if the issue appears again.
1209 -- I suspect that the values loaded in PO_STARTUP_VALUES are NULL in
1210 -- PO_CORE_S.get_po_parameters() [POXCOC1B.pls]. The following queries should
1211 -- get us moe information.
1212 -- Remove this DEBUG QUERIES block, once the MOAC issue is completely fixed.
1213 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'org_id from PO_MOAC='||PO_MOAC_UTILS_PVT.get_current_org_id||', org_id from PO_GA_PVT='||PO_GA_PVT.get_current_org );
1214 -- Query from: PO_CORE_S.get_po_parameters() [POXCOC1B.pls].
1215 SELECT nvl(fsp.purch_encumbrance_flag,'N'),
1216 nvl(fsp.req_encumbrance_flag,'N')
1217 INTO l_purch_encumbrance_flag,
1218 l_req_encumbrance_flag
1219 FROM financials_system_parameters fsp,
1220 gl_sets_of_books sob,
1221 po_system_parameters psp,
1222 rcv_parameters rcv
1223 WHERE fsp.set_of_books_id = sob.set_of_books_id
1224 AND rcv.organization_id (+) = fsp.inventory_organization_id;
1225
1226 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'PO_CORE_S: l_purch_encumbrance_flag='||l_purch_encumbrance_flag||', l_req_encumbrance_flag='||l_req_encumbrance_flag);
1227
1228 SELECT purch_encumbrance_flag,
1229 req_encumbrance_flag
1230 INTO l_purch_encumbrance_flag,
1231 l_req_encumbrance_flag
1232 FROM FINANCIALS_SYSTEM_PARAMETERS; -- view
1233
1234 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'View: l_purch_encumbrance_flag='||l_purch_encumbrance_flag||', l_req_encumbrance_flag='||l_req_encumbrance_flag);
1235
1236 SELECT purch_encumbrance_flag,
1237 req_encumbrance_flag
1238 INTO l_purch_encumbrance_flag,
1239 l_req_encumbrance_flag
1240 FROM FINANCIALS_SYSTEM_PARAMS_ALL -- table
1241 WHERE org_id = PO_MOAC_UTILS_PVT.get_current_org_id;
1242
1243 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'Table: MOAC: l_purch_encumbrance_flag='||l_purch_encumbrance_flag||', l_req_encumbrance_flag='||l_req_encumbrance_flag);
1244
1245 SELECT purch_encumbrance_flag,
1246 req_encumbrance_flag
1247 INTO l_purch_encumbrance_flag,
1248 l_req_encumbrance_flag
1249 FROM FINANCIALS_SYSTEM_PARAMS_ALL -- table
1250 WHERE org_id = PO_GA_PVT.get_current_org;
1251
1252 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'Table: PO_GA_PVT: l_purch_encumbrance_flag='||l_purch_encumbrance_flag||', l_req_encumbrance_flag='||l_req_encumbrance_flag);
1253 -- DEBUG QUERIES: End
1254 END IF;
1255
1256 IF (l_is_financing_flag IS NULL) THEN
1257 l_is_financing_flag := 'N';
1258 END IF;
1259
1260 IF (l_is_advance_flag IS NULL) THEN
1261 l_is_advance_flag := 'N';
1262 END IF;
1263
1264 IF (g_po_wf_debug = 'Y') THEN
1265 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'After: l_is_financing_flag='||l_is_financing_flag||', l_is_advance_flag='||l_is_advance_flag);
1266 END IF;
1267 -- Bug 5058123: End
1268
1269 /* For Encumbrance Project - To enable Encumbrance for Destination type Shop Floor and WIP entity type EAM */
1270
1271 x_wip_entity_type := po_wf_util_pkg.GetItemAttrText ( itemtype => itemtype,
1272 itemkey => itemkey,
1273 aname => 'WIP_ENTITY_TYPE');
1274
1275
1276 if (po_encumbrance_flag = 'Y' and (x_destination_type <> 'SHOP FLOOR' OR (x_destination_type = 'SHOP FLOOR' AND x_wip_entity_type = 6 ))
1277 /* Condition added for Encumbrance Project */
1278 AND l_is_financing_flag <> 'Y' AND l_is_advance_flag <> 'Y') then
1279 result := 'COMPLETE:TRUE';
1280 else
1281 result := 'COMPLETE:FALSE';
1282 end if;
1283
1284 x_progress := 'PO_WF_PO_CHARGE_ACC.is_encumbrance_on: result = ' || result;
1285 IF (g_po_wf_debug = 'Y') THEN
1286 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1287 END IF;
1288
1289 return;
1290
1291 EXCEPTION
1292 WHEN OTHERS THEN
1293 wf_core.context('PO_WF_PO_CHARGE_ACC','is_encumbrace_on',x_progress);
1294 raise;
1295
1296 end is_encumbrance_on;
1297
1298 --
1299
1300 -- * ****************************************************************************** *
1301 -- * ****************************************************************************** *
1302
1303 --
1304 -- is_po_project_related
1305 --
1306 -- This is a dummy function that should be replaced by the customized function
1307 -- activity in the workflow that return TRUE or FALSE based on whether you want to
1308 -- use the default PO expense charge account generation rules or use "CUSTOMIZED"
1309 -- project accounting rules.
1310
1311 procedure is_po_project_related ( itemtype in varchar2,
1312 itemkey in varchar2,
1313 actid in number,
1314 funcmode in varchar2,
1315 result out NOCOPY varchar2 )
1316 is
1317 begin
1318
1319 result := 'COMPLETE:F';
1320 return;
1321
1322 end is_po_project_related;
1323
1324
1325 /*
1326 * Set the debug mode on
1327 */
1328
1329 PROCEDURE debug_on IS
1330 BEGIN
1331 debug_acc_generator_wf := TRUE;
1332
1333 END debug_on;
1334
1335 /*
1336 * Set the debug mode off
1337 */
1338
1339 PROCEDURE debug_off IS
1340 BEGIN
1341 debug_acc_generator_wf := FALSE;
1342
1343 END debug_off;
1344
1345 --< Shared Proc FPJ Start >
1346
1347 ---------------------------------------------------------------------------
1348 --Start of Comments
1349 --Name: is_dest_accounts_flow_type
1350 --Pre-reqs:
1351 -- None.
1352 --Modifies:
1353 -- None
1354 --Locks:
1355 -- None.
1356 --Function:
1357 -- The PO Account Generator could be run 2 times -- first to generate the
1358 -- PO Accounts and second time to generate the DESTINATION accounts. The
1359 -- calling program specifies the flow type in the WF item attribute
1360 -- called ACCOUNT_GENERATION_FLOW_TYPE.
1361 -- The flow could take either of the following 2 values:
1362 -- 1. PO_WF_BUILD_ACCOUNT_INIT.g_po_accounts (PO_ACCOUNTS)
1363 -- 2. PO_WF_BUILD_ACCOUNT_INIT.g_destination_accounts (DESTINATION_ACCOUNTS)
1364 -- This function determines if the flow type specified by the calling
1365 -- program is for the Destination Accounts or not.
1366 --Parameters:
1367 --IN:
1368 -- Standard workflow function parameters
1369 --OUT:
1370 -- Standard workflow function result parameter of type 'Yes/No'.
1371 --Testing:
1372 --
1373 --Notes:
1374 -- We could have used the standard WF activity COMPARE_TEXT for this
1375 -- purpose, but it is not as readable because on the workflow diagram
1376 -- we would see just 'Compare Text' written beneath the activity. To find
1377 -- out what it is exactly being compared, we would have to go to the 'Node
1378 -- Attribute' tab of that activity and inspect the item attributes. Also,
1379 -- we would have had to hard-code the value being compared there. In this
1380 -- function, we can use the global variable
1381 -- 'PO_WF_BUILD_ACCOUNT_INIT.g_po_accounts' instead of the hard coded value.
1382 --End of Comments
1383 ---------------------------------------------------------------------------
1384 PROCEDURE is_dest_accounts_flow_type
1385 (
1386 itemtype IN VARCHAR2,
1387 itemkey IN VARCHAR2,
1388 actid IN NUMBER,
1389 funcmode IN VARCHAR2,
1390 result OUT NOCOPY VARCHAR2
1391 )
1392 IS
1393 l_progress WF_ITEM_ACTIVITY_STATUSES.error_stack%TYPE; -- VARCHAR2(4000)
1394 l_account_gen_flow_type VARCHAR2(25);
1395 BEGIN
1396 l_progress := '010';
1397
1398 -- Do nothing in cancel or timeout mode
1399 IF (funcmode <> WF_ENGINE.eng_run) THEN
1400 result := WF_ENGINE.eng_null;
1401 RETURN;
1402 END IF;
1403
1404 l_progress := '020';
1405
1406 l_account_gen_flow_type := PO_WF_UTIL_PKG.GetItemAttrText(
1407 itemtype => itemtype,
1408 itemkey => itemkey,
1409 aname => 'ACCOUNT_GENERATION_FLOW_TYPE');
1410
1411 l_progress := '030';
1412
1413 IF (l_account_gen_flow_type IS NULL OR
1414 l_account_gen_flow_type = PO_WF_BUILD_ACCOUNT_INIT.g_po_accounts)
1415 THEN
1416 result := WF_ENGINE.eng_completed || ':N';
1417 ELSE
1418 result := WF_ENGINE.eng_completed || ':Y';
1419 END IF;
1420
1421 IF (g_po_wf_debug = 'Y') THEN
1422 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1423 'PO_WF_PO_CHARGE_ACC.is_dest_accounts_flow_type result='||result);
1424 END IF;
1425 EXCEPTION
1426 WHEN OTHERS THEN
1427 WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_dest_accounts_flow_type',
1428 l_progress);
1429 RAISE;
1430 END is_dest_accounts_flow_type;
1431
1432 ---------------------------------------------------------------------------
1433 --Start of Comments
1434 --Name: is_SPS_distribution
1435 --Pre-reqs:
1436 -- None.
1437 --Modifies:
1438 -- None
1439 --Locks:
1440 -- None.
1441 --Function:
1442 -- Determines if it is a Shared Procurement Services (SPS) distribution.
1443 --Parameters:
1444 --IN:
1445 -- Standard workflow function parameters
1446 --OUT:
1447 -- Standard workflow function result parameter of type 'Yes/No'.
1448 --Testing:
1449 --End of Comments
1450 ---------------------------------------------------------------------------
1451 PROCEDURE is_SPS_distribution
1452 (
1453 itemtype IN VARCHAR2,
1454 itemkey IN VARCHAR2,
1455 actid IN NUMBER,
1456 funcmode IN VARCHAR2,
1457 result OUT NOCOPY VARCHAR2
1458 )
1459 IS
1460 l_progress WF_ITEM_ACTIVITY_STATUSES.error_stack%TYPE; -- VARCHAR2(4000)
1461 l_is_SPS_distribution VARCHAR2(1);
1462 BEGIN
1463 -- Do nothing in cancel or timeout mode
1464 IF (funcmode <> WF_ENGINE.eng_run) THEN
1465 result := WF_ENGINE.eng_null;
1466 RETURN;
1467 END IF;
1468
1469 l_progress := '010';
1470 l_is_SPS_distribution := PO_WF_UTIL_PKG.GetItemAttrText(
1471 itemtype => itemtype,
1472 itemkey => itemkey,
1473 aname => 'IS_SPS_DISTRIBUTION');
1474
1475 l_progress := '020';
1476 IF (l_is_SPS_distribution IS NULL) THEN
1477 result := WF_ENGINE.eng_completed || ':N';
1478 ELSE
1479 result := WF_ENGINE.eng_completed || ':' || l_is_SPS_distribution;
1480 END IF;
1481
1482 IF (g_po_wf_debug = 'Y') THEN
1483 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1484 'PO_WF_PO_CHARGE_ACC.is_SPS_distribution result='||result);
1485 END IF;
1486 EXCEPTION
1487 WHEN OTHERS THEN
1488 WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_SPS_distribution', l_progress);
1489 RAISE;
1490 END is_SPS_distribution;
1491
1492 ---------------------------------------------------------------------------
1493 --Start of Comments
1494 --Name: is_shopfloor_enabled_item
1495 --Pre-reqs:
1496 -- None.
1497 --Modifies:
1498 -- None
1499 --Locks:
1500 -- None.
1501 --Function:
1502 -- Determines if a given item is enabled for shopfloor (outside processing)
1503 -- in the given Inventory Org
1504 --Parameters:
1505 --IN:
1506 -- p_item_id
1507 -- : The given item's ID
1508 -- p_inv_org_id
1509 -- : The org ID of the Inventory Org where the item's attribute need to be
1510 -- tested.
1511 --OUT:
1512 -- None.
1513 --RETURN
1514 -- BOOLEAN: TRUE if the item is shopfloor enables, FALSE otherwise.
1515 --Testing:
1516 --End of Comments
1517 ---------------------------------------------------------------------------
1518 FUNCTION is_shopfloor_enabled_item(p_item_id IN NUMBER,
1519 p_inv_org_id IN NUMBER) RETURN BOOLEAN
1520 IS
1521 is_shopfloor_enabled_item MTL_SYSTEM_ITEMS.outside_operation_flag%TYPE;
1522 BEGIN
1523 --SQL WHAT: Get the outside_operation_flag for a given item
1524 --SQL WHY: To find out if the item is Shopfloor enabled.
1525 SELECT outside_operation_flag -- it is a NOT NULL column
1526 INTO is_shopfloor_enabled_item
1527 FROM MTL_SYSTEM_ITEMS
1528 WHERE inventory_item_id = p_item_id AND
1529 organization_id = p_inv_org_id;
1530
1531 IF (is_shopfloor_enabled_item = 'Y') THEN
1532 RETURN TRUE;
1533 ELSE
1534 RETURN FALSE;
1535 END IF;
1536 EXCEPTION
1537 WHEN NO_DATA_FOUND THEN
1538 RETURN FALSE;
1539 WHEN OTHERS THEN
1540 RAISE;
1541 END is_shopfloor_enabled_item;
1542
1543 ---------------------------------------------------------------------------
1544 --Start of Comments
1545 --Name: get_COGS_account
1546 --Pre-reqs:
1547 -- None.
1548 --Modifies:
1549 -- None
1550 --Locks:
1551 -- None.
1552 --Function:
1553 -- Gets the Cost of Goods Sold (COGS) account associated with the intermediate
1554 -- Logical Inventory Org for the POU.
1555 --Parameters:
1556 --IN:
1557 -- p_inv_org_id IN NUMBER
1558 -- : The Org ID of the Logical Inv Org associated with a Transaction Flow
1559 --OUT:
1560 -- None
1561 --RETURN
1562 -- NUMBER
1563 -- : The Cost of Goods Sold Account for the LINV.
1564 --Testing:
1565 --End of Comments
1566 ---------------------------------------------------------------------------
1567 FUNCTION get_COGS_account(p_inv_org_id IN NUMBER) RETURN NUMBER
1568 IS
1569 l_COGS_account_id GL_CODE_COMBINATIONS.code_combination_id%TYPE := NULL;
1570 BEGIN
1571 --SQL WHAT: Get the Get the COGS account for the Logical Inventory Org
1572 -- associated with an OU for a given Transaction Flow.
1573 --SQL WHY: Default as the PO Charge Account for SPS case
1574 SELECT cost_of_sales_account
1575 INTO l_COGS_account_id
1576 FROM MTL_PARAMETERS
1577 WHERE ORGANIZATION_ID = p_inv_org_id;
1578
1579 RETURN l_COGS_account_id;
1580 EXCEPTION
1581 WHEN NO_DATA_FOUND THEN
1582 RETURN NULL;
1583 WHEN OTHERS THEN
1584 RAISE;
1585 END get_COGS_account;
1586
1587 ---------------------------------------------------------------------------
1588 --Start of Comments
1589 --Name: get_item_expense_account
1590 --Pre-reqs:
1591 -- None.
1592 --Modifies:
1593 -- None
1594 --Locks:
1595 -- None.
1596 --Function:
1597 -- Gets the Expense Account associated with a given inventory item.
1598 --Parameters:
1599 --IN:
1600 -- p_item_id IN NUMBER
1601 -- : The given item id
1602 -- p_inv_org_id IN NUMBER
1603 -- : The inventory org id to which the item belongs
1604 --OUT:
1605 -- None
1606 --RETURN
1607 -- NUMBER
1608 -- : The Expense Account associated with the given inventory item.
1609 --Testing:
1610 --End of Comments
1611 ---------------------------------------------------------------------------
1612 FUNCTION get_item_expense_account(p_item_id IN NUMBER,
1613 p_inv_org_id IN NUMBER)
1614 RETURN NUMBER
1615 IS
1616 l_item_expense_account_id GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1617 BEGIN
1618 --SQL WHAT: Get the Expense Account associated with an item in the Logical
1619 -- Inventory Org for a Start OU for a given Transaction Flow.
1620 --SQL WHY: To default this as the PO Expense Account for SPS case
1621 SELECT expense_account
1622 INTO l_item_expense_account_id
1623 FROM MTL_SYSTEM_ITEMS
1624 WHERE organization_id = p_inv_org_id AND
1625 inventory_item_id = p_item_id;
1626
1627 RETURN l_item_expense_account_id;
1628 EXCEPTION
1629 WHEN NO_DATA_FOUND THEN
1630 RETURN NULL;
1631 WHEN OTHERS THEN
1632 RAISE;
1633 END get_item_expense_account;
1634
1635 ---------------------------------------------------------------------------
1636 --Start of Comments
1637 --Name: get_org_expense_account
1638 --Pre-reqs:
1639 -- None.
1640 --Modifies:
1641 -- None
1642 --Locks:
1643 -- None.
1644 --Function:
1645 -- Gets the Expense Account associated with a given inventory org.
1646 --Parameters:
1647 --IN:
1648 -- p_inv_org_id IN NUMBER
1649 -- : The given inventory org id
1650 --OUT:
1651 -- None
1652 --RETURN
1653 -- NUMBER
1654 -- : The Expense Account associated with the given inventory org.
1655 --Testing:
1656 --End of Comments
1657 ---------------------------------------------------------------------------
1658 FUNCTION get_org_expense_account(p_inv_org_id IN NUMBER)
1659 RETURN NUMBER
1660 IS
1661 l_org_expense_account_id GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1662 BEGIN
1663 --SQL WHAT: Get the Expense Account associated with the Logical
1664 -- Inventory Org for a Start OU for a given Transaction Flow.
1665 --SQL WHY: To default this as the PO Expense Account for SPS case
1666 SELECT expense_account
1667 INTO l_org_expense_account_id
1668 FROM MTL_PARAMETERS
1669 WHERE organization_id = p_inv_org_id;
1670
1671 RETURN l_org_expense_account_id;
1672 EXCEPTION
1673 WHEN NO_DATA_FOUND THEN
1674 RETURN NULL;
1675 WHEN OTHERS THEN
1676 RAISE;
1677 END get_org_expense_account;
1678
1679 ---------------------------------------------------------------------------
1680 --Start of Comments
1681 --Name: get_org_material_account
1682 --Pre-reqs:
1683 -- None.
1684 --Modifies:
1685 -- None
1686 --Locks:
1687 -- None.
1688 --Function:
1689 -- Gets the Material Account associated with a given inventory org.
1690 --Parameters:
1691 --IN:
1692 -- p_inv_org_id IN NUMBER
1693 -- : The given inventory org id
1694 --OUT:
1695 -- None
1696 --RETURN
1697 -- NUMBER
1698 -- : The Material Account associated with the given inventory org.
1699 --Testing:
1700 --End of Comments
1701 ---------------------------------------------------------------------------
1702 FUNCTION get_org_material_account(p_inv_org_id IN NUMBER)
1703 RETURN NUMBER
1704 IS
1705 l_org_material_account_id GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1706 BEGIN
1707 --SQL WHAT: Get the Material Account associated with the Logical
1708 -- Inventory Org for a Start OU for a given Transaction Flow.
1709 --SQL WHY: To default this as the PO Expense Account for SPS case
1710 SELECT material_account
1711 INTO l_org_material_account_id
1712 FROM MTL_PARAMETERS
1713 WHERE organization_id = p_inv_org_id;
1714
1715 RETURN l_org_material_account_id;
1716 EXCEPTION
1717 WHEN NO_DATA_FOUND THEN
1718 RETURN NULL;
1719 WHEN OTHERS THEN
1720 RAISE;
1721 END get_org_material_account;
1722
1723 ---------------------------------------------------------------------------
1724 --Start of Comments
1725 --Name: sanity_check_logical_inv_org
1726 --Pre-reqs:
1727 -- None.
1728 --Modifies:
1729 -- None
1730 --Locks:
1731 -- None.
1732 --Function:
1733 -- This function gets executed in DEBUG MODE ONLY.
1734 -- The purpose of this function is to perform a sanity check on the Logical
1735 -- Inventory Org that is derived from the MTL_TRANSATION_FLOW_LINES table.
1736 -- Since this a new table with a brand new functionality of Transaction Flows,
1737 -- and since this table belongs to a group outside of Procurement Family, we
1738 -- should make sure that the Logical Inventory Org (LINV) derived from this
1739 -- table is correct.
1740 -- Here we check if the LINV actually belong to the POU, as it should.
1741 -- This function merely inserts debug comments in PO debug tables.
1742 --
1743 --Parameters:
1744 --IN:
1745 -- p_logical_inv_org_id IN NUMBER
1746 -- : The logical inventory org id, derived from MTL table.
1747 -- p_itemtype IN VARCHAR2
1748 -- : The item type of the current AG workflow
1749 -- p_itemkey IN VARCHAR2
1750 -- : The item key of the current AG workflow
1751 --
1752 --OUT:
1753 -- None
1754 --Testing:
1755 --End of Comments
1756 ---------------------------------------------------------------------------
1757 PROCEDURE sanity_check_logical_inv_org(p_logical_inv_org_id IN NUMBER,
1758 p_itemtype IN VARCHAR2,
1759 p_itemkey IN VARCHAR2)
1760 IS
1761 l_temp_ou_id NUMBER;
1762 l_purchasing_ou_id NUMBER;
1763 BEGIN
1764 IF (g_po_wf_debug = 'Y') THEN
1765 BEGIN
1766 SELECT operating_unit
1767 INTO l_temp_ou_id
1768 FROM org_organization_definitions
1769 WHERE organization_id = p_logical_inv_org_id;
1770
1771 l_purchasing_ou_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
1772 itemtype => p_itemtype,
1773 itemkey => p_itemkey,
1774 aname => 'PURCHASING_OU_ID');
1775
1776 IF (l_temp_ou_id <> l_purchasing_ou_id) THEN
1777 PO_WF_DEBUG_PKG.insert_debug(p_itemtype, p_itemkey,
1778 'LINV does not belong to POU');
1779 END IF;
1780 EXCEPTION
1781 WHEN OTHERS THEN
1782 -- record and ignore the exception, this is just debug code.
1783 PO_WF_DEBUG_PKG.insert_debug(p_itemtype, p_itemkey,
1784 'Exception while sanity checking LINV');
1785 END;
1786 END IF; -- IF (g_po_wf_debug = 'Y'), sanity check for LINV
1787 END sanity_check_logical_inv_org;
1788
1789 ---------------------------------------------------------------------------
1790 --Start of Comments
1791 --Name: get_SPS_charge_account
1792 --Pre-reqs:
1793 -- None.
1794 --Modifies:
1795 -- Item Attribute: TEMP_ACCOUNT_ID
1796 --Locks:
1797 -- None.
1798 --Function:
1799 -- Gets the PO Charge Account for SPS case.
1800 --Parameters:
1801 --IN:
1802 -- Standard workflow function parameters
1803 --OUT:
1804 -- Standard workflow function result parameter
1805 --Testing:
1806 --End of Comments
1807 ---------------------------------------------------------------------------
1808 PROCEDURE get_SPS_charge_account
1809 (
1810 itemtype IN VARCHAR2,
1811 itemkey IN VARCHAR2,
1812 actid IN NUMBER,
1813 funcmode IN VARCHAR2,
1814 result OUT NOCOPY VARCHAR2
1815 )
1816 IS
1817 l_progress WF_ITEM_ACTIVITY_STATUSES.error_stack%TYPE; -- VARCHAR2(4000)
1818 l_item_id NUMBER;
1819 l_transaction_flow_header_id NUMBER;
1820 l_logical_inv_org_id NUMBER;
1821 l_SPS_charge_account_id NUMBER := NULL;
1822 l_item_inventory_type VARCHAR2(10);
1823 BEGIN
1824 l_progress := '010';
1825
1826 -- Do nothing in cancel or timeout mode
1827 IF (funcmode <> WF_ENGINE.eng_run) THEN
1828 result := WF_ENGINE.eng_null;
1829 RETURN;
1830 END IF;
1831
1832 l_progress := '020';
1833 l_item_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
1834 itemtype => itemtype,
1835 itemkey => itemkey,
1836 aname => 'ITEM_ID');
1837
1838 l_progress := '030';
1839 l_transaction_flow_header_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
1840 itemtype => itemtype,
1841 itemkey => itemkey,
1842 aname => 'TRANSACTION_FLOW_HEADER_ID');
1843
1844 l_progress := '040';
1845
1846 -- Get the org id for the Logical Inventory Org associated with
1847 -- the given Transaction Flow. This LINV would belong to the POU.
1848 l_logical_inv_org_id := PO_SHARED_PROC_PVT.get_logical_inv_org_id(l_transaction_flow_header_id);
1849
1850 l_progress := '050';
1851 IF (l_logical_inv_org_id IS NULL) THEN
1852 l_progress := 'Logical Inventory Org Not Found';
1853 APP_EXCEPTION.raise_exception(exception_type => 'GET_LOGICAL_INV_ORG_ID',
1854 exception_code => 0,
1855 exception_text => l_progress);
1856 END IF;
1857
1858 l_progress := '060';
1859 -- Sanity check. Does LINV belong to POU?
1860 -- Check this in debug mode only.
1861 sanity_check_logical_inv_org(l_logical_inv_org_id,
1862 itemtype,
1863 itemkey);
1864
1865 l_progress := '070';
1866 -- 1. If one-time item or shopfloor enabled item, get COGS account
1867 IF ( (l_item_id IS NULL) OR
1868 (is_shopfloor_enabled_item(l_item_id,
1869 l_logical_inv_org_id)) ) THEN
1870 l_SPS_charge_account_id := get_COGS_account(l_logical_inv_org_id);
1871
1872 ELSE -- else if NOT a one-time or shopfloor enabled item --(
1873
1874 l_progress := '080';
1875 -- Get the Inventory Item Type of the given item in the given LINV.
1876 IF (check_inv_item_type(itemtype,
1877 itemkey,
1878 l_logical_inv_org_id,
1879 l_item_id) = 'EXPENSE') THEN
1880 l_item_inventory_type := 'EXPENSE';
1881 ELSE
1882 l_item_inventory_type := 'ASSET';
1883 END IF;
1884
1885 l_progress := '090';
1886 -- 2a. If Expense Item, get Item Expense Account
1887 IF ( (l_SPS_charge_account_id IS NULL) AND
1888 (l_item_inventory_type = 'EXPENSE') ) THEN
1889 l_progress := '100';
1890 l_SPS_charge_account_id := get_item_expense_account(l_item_id,
1891 l_logical_inv_org_id);
1892
1893 l_progress := '110';
1894 -- 2b. If Expense Item, get Org Expense Account
1895 IF (l_SPS_charge_account_id IS NULL) THEN
1896 l_SPS_charge_account_id := get_org_expense_account(l_logical_inv_org_id);
1897 END IF;
1898 END IF;
1899
1900 l_progress := '120';
1901 -- 3. If Asset Item, get Org Material Account
1902 IF ( (l_SPS_charge_account_id IS NULL) AND
1903 (l_item_inventory_type = 'ASSET') ) THEN
1904 l_SPS_charge_account_id := get_org_material_account(l_logical_inv_org_id);
1905 END IF;
1906
1907 l_progress := '130';
1908 IF (l_SPS_charge_account_id IS NULL) THEN
1909 result := WF_ENGINE.eng_completed || ':FAILURE';
1910 RETURN;
1911 END IF;
1912 END IF; -- IF (l_item_id IS NULL) OR
1913 -- (is_shopfloor_enabled_item(l_item_id, l_logical_inv_org_id)) --)
1914
1915 l_progress := '140';
1916 PO_WF_UTIL_PKG.SetItemAttrNumber(itemtype => itemtype,
1917 itemkey => itemkey,
1918 aname => 'TEMP_ACCOUNT_ID',
1919 avalue => l_SPS_charge_account_id);
1920
1921 l_progress := '150';
1922 result := WF_ENGINE.eng_completed || ':SUCCESS';
1923
1924 l_progress := '160';
1925
1926 IF (g_po_wf_debug = 'Y') THEN
1927 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1928 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account result='||result);
1929 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1930 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account l_SPS_charge_account_id='||
1931 l_SPS_charge_account_id);
1932 END IF;
1933 EXCEPTION
1934 WHEN OTHERS THEN
1935 IF (g_po_wf_debug = 'Y') THEN
1936 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1937 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account EXCEPTION at '|| l_progress);
1938 END IF;
1939 WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'get_SPS_charge_account', l_progress);
1940 RAISE;
1941 END get_SPS_charge_account;
1942
1943 ---------------------------------------------------------------------------
1944 --Start of Comments
1945 --Name: is_dest_charge_acc_null
1946 --Pre-reqs:
1947 -- None.
1948 --Modifies:
1949 -- Item Attribute: TEMP_ACCOUNT_ID
1950 --Locks:
1951 -- None.
1952 --Function:
1953 -- Checks if the attribute DEST_CHARGE_ACCOUNT_ID is NULL or not.
1954 -- If it is NULL, it returns 'N'.
1955 -- If it is not NULL, it copies the value in DEST_CHARGE_ACCOUNT_ID to
1956 -- TEMP_ACCOUNT_ID and returns 'Y'.
1957 --Parameters:
1958 --IN:
1959 -- Standard workflow function parameters
1960 --OUT:
1961 -- Standard workflow function result parameter
1962 --Testing:
1963 --End of Comments
1964 ---------------------------------------------------------------------------
1965 PROCEDURE is_dest_charge_acc_null
1966 (
1967 itemtype IN VARCHAR2,
1968 itemkey IN VARCHAR2,
1969 actid IN NUMBER,
1970 funcmode IN VARCHAR2,
1971 result OUT NOCOPY VARCHAR2
1972 )
1973 IS
1974 l_progress WF_ITEM_ACTIVITY_STATUSES.error_stack%TYPE; -- VARCHAR2(4000)
1975 l_dest_charge_account_id GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1976 l_temp_acc_id GL_CODE_COMBINATIONS.code_combination_id%TYPE;
1977 BEGIN
1978 l_progress := '010';
1979
1980 -- Do nothing in cancel or timeout mode
1981 IF (funcmode <> WF_ENGINE.eng_run) THEN
1982 result := WF_ENGINE.eng_null;
1983 RETURN;
1984 END IF;
1985
1986 l_progress := '020';
1987 l_dest_charge_account_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
1988 itemtype => itemtype,
1989 itemkey => itemkey,
1990 aname => 'DEST_CHARGE_ACCOUNT_ID');
1991
1992 l_progress := '030';
1993 IF l_dest_charge_account_id IS NULL OR
1994 l_dest_charge_account_id = 0 OR
1995 l_dest_charge_account_id = -1 THEN
1996 result := WF_ENGINE.eng_completed || ':Y';
1997 ELSE
1998 IF (g_po_wf_debug = 'Y') THEN
1999 l_temp_acc_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
2000 itemtype => itemtype,
2001 itemkey => itemkey,
2002 aname => 'TEMP_ACCOUNT_ID');
2003
2004 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2005 'PO_WF_PO_CHARGE_ACC.is_dest_charge_acc_null '||
2006 'Copying DestChargeAccId to TEMP_ACCOUNT_ID '||
2007 '(current val = ' || l_temp_acc_id || ') ' ||
2008 'dest_charge_account_id='||l_dest_charge_account_id);
2009 END IF;
2010
2011 -- If the Dest Charge Account is not null (autocreate, or through
2012 -- Forms/PDOI), then copy it into the TEMP_ACCOUNT_ID.
2013 l_progress := '040';
2014 PO_WF_UTIL_PKG.SetItemAttrNumber(itemtype => itemtype,
2015 itemkey => itemkey,
2016 aname => 'TEMP_ACCOUNT_ID',
2017 avalue => l_dest_charge_account_id);
2018 l_progress := '050';
2019 result := WF_ENGINE.eng_completed || ':N';
2020 END IF;
2021
2022 IF (g_po_wf_debug = 'Y') THEN
2023 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2024 'PO_WF_PO_CHARGE_ACC.is_dest_charge_acc_null result='||result||
2025 ' l_dest_charge_account_id='||l_dest_charge_account_id);
2026 END IF;
2027
2028 EXCEPTION
2029 WHEN OTHERS THEN
2030 WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_dest_charge_acc_null',
2031 l_progress);
2032 RAISE;
2033 END is_dest_charge_acc_null;
2034
2035
2036 ---------------------------------------------------------------------------
2037 --Start of Comments
2038 --Name: are_COAs_same
2039 --Pre-reqs:
2040 -- None.
2041 --Modifies:
2042 -- None
2043 --Locks:
2044 -- None.
2045 --Function:
2046 -- Determines if the Chart of Accounts (COA's) of the POU and the DOU are
2047 -- the same or not.
2048 --Parameters:
2049 --IN:
2050 -- Standard workflow function parameters
2051 --OUT:
2052 -- Standard workflow function result parameter
2053 --Testing:
2054 --End of Comments
2055 ---------------------------------------------------------------------------
2056 PROCEDURE are_COAs_same
2057 (
2058 itemtype IN VARCHAR2,
2059 itemkey IN VARCHAR2,
2060 actid IN NUMBER,
2061 funcmode IN VARCHAR2,
2062 result OUT NOCOPY VARCHAR2
2063 )
2064 IS
2065 l_progress WF_ITEM_ACTIVITY_STATUSES.error_stack%TYPE; -- VARCHAR2(4000)
2066 l_pou_coa_id GL_CODE_COMBINATIONS.chart_of_accounts_id%TYPE;
2067 l_ship_to_ou_coa_id GL_CODE_COMBINATIONS.chart_of_accounts_id%TYPE;
2068 l_is_sps_distribution VARCHAR2(10); --<BUG 4882220>
2069 BEGIN
2070 l_progress := '010';
2071
2072 -- Do nothing in cancel or timeout mode
2073 IF (funcmode <> WF_ENGINE.eng_run) THEN
2074 result := WF_ENGINE.eng_null;
2075 RETURN;
2076 END IF;
2077
2078 --<BUG 4882220 START>
2079 -- Return immediately if this is not an SPS distribution.
2080 --
2081 l_progress := '015';
2082 l_is_sps_distribution := PO_WF_UTIL_PKG.GetItemAttrText(
2083 itemtype => itemtype,
2084 itemkey => itemkey,
2085 aname => 'IS_SPS_DISTRIBUTION' );
2086
2087 IF nvl( l_is_sps_distribution, 'N' ) = 'N' THEN
2088 result := WF_ENGINE.eng_completed || ':N';
2089 RETURN;
2090 END IF;
2091 --<BUG 4882220 END>
2092
2093 l_progress := '020';
2094 l_pou_coa_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
2095 itemtype => itemtype,
2096 itemkey => itemkey,
2097 aname => 'CHART_OF_ACCOUNTS_ID');
2098
2099 l_progress := '030';
2100 -- Use the wrapper because it is a new attribute
2101 l_ship_to_ou_coa_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
2102 itemtype => itemtype,
2103 itemkey => itemkey,
2104 aname => 'SHIP_TO_OU_COA_ID');
2105
2106 l_progress := '040';
2107 IF (l_ship_to_ou_coa_id IS NULL) OR
2108 (l_ship_to_ou_coa_id <> l_pou_coa_id) THEN
2109 result := WF_ENGINE.eng_completed || ':N';
2110 ELSE
2111 result := WF_ENGINE.eng_completed || ':Y';
2112 END IF;
2113
2114 IF (g_po_wf_debug = 'Y') THEN
2115 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2116 'PO_WF_PO_CHARGE_ACC.are_COAs_same result='||result);
2117 END IF;
2118 EXCEPTION
2119 WHEN OTHERS THEN
2120 WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'are_COAs_same',
2121 l_progress);
2122 RAISE;
2123 END are_COAs_same;
2124
2125 --< Shared Proc FPJ End >
2126
2127 --Bug4033391 Start
2128 --In the account generator, all the accounts are validated using the activity
2129 --FND_FLEX_VALIDATE_COMBINATION, which applies the security rule irrespective
2130 --of whether the account is entered by the user or derived.
2131 --Security rules should be only be applied for the user entered accounts.
2132 --This is fixed by setting the responsibility_id of the context to null
2133 --before calling validation and resetting the same after validation.
2134 -------------------------------------------------------------------------------
2135 --Start of Comments
2136 --Name: set_null_resp_id
2137 --Pre-reqs:
2138 -- None.
2139 --Modifies:
2140 -- None
2141 --Locks:
2142 -- None.
2143 --Function:
2144 -- Sets the responsibility ID to NULL
2145 --End of Comments
2146 -----------------------------------------------------------------------------
2147 PROCEDURE set_null_resp_id(itemtype IN VARCHAR2,
2148 itemkey IN VARCHAR2,
2149 actid IN NUMBER,
2150 funcmode IN VARCHAR2,
2151 result OUT NOCOPY VARCHAR2)
2152 IS
2153 l_progress varchar2(3);
2154 BEGIN
2155 -- <CLM Project>
2156 -- Commented out the code below as it was leading to Stale Data Error in BWC.
2157 -- LAST_UPDATE_LOGIN was going as -1 into UDA tables (po_lines_all_ext_b)
2158 /*
2159 l_progress := '010';
2160 wf_engine.SetItemAttrNumber( itemtype => itemtype,
2161 itemkey => itemkey,
2162 aname =>'RESPONSIBILITY_ID',
2163 avalue => fnd_global.resp_id);
2164 l_progress := '020';
2165 IF (g_po_wf_debug = 'Y') THEN
2166 PO_WF_DEBUG_PKG.insert_debug(itemtype,
2167 itemkey,
2168 'PO_WF_PO_CHARGE_ACC.set_null_resp_id: Setting the Responsibility to NULL ');
2169 END IF;
2170 FND_GLOBAL.apps_initialize( user_id => fnd_global.user_id,
2171 resp_id => NULL,
2172 resp_appl_id => fnd_global.resp_appl_id);
2173 l_progress := '030';
2174 */
2175 result := WF_ENGINE.eng_completed || ':Y';
2176 EXCEPTION
2177 WHEN OTHERS THEN
2178 WF_CORE.context('PO_WF_PO_CHARGE_ACC','SET_NULL_RESP_ID',l_progress);
2179 raise;
2180
2181 END set_null_resp_id;
2182
2183 -------------------------------------------------------------------------------
2184 --Start of Comments
2185 --Name: reset_resp_id
2186 --Pre-reqs:
2187 -- None.
2188 --Modifies:
2189 -- None
2190 --Locks:
2191 -- None.
2192 --Function:
2193 -- Sets the responsibility ID back to original value
2194 --End of Comments
2195 -----------------------------------------------------------------------------
2196 PROCEDURE reset_resp_id(itemtype IN VARCHAR2,
2197 itemkey IN VARCHAR2,
2198 actid IN NUMBER,
2199 funcmode IN VARCHAR2,
2200 result OUT NOCOPY VARCHAR2)
2201 IS
2202 l_progress varchar2(3);
2203 l_resp_id FND_RESPONSIBILITY.responsibility_id%type;
2204 BEGIN
2205 -- <CLM Project>
2206 -- Commented out the code below as it was leading to Stale Data Error in BWC.
2207 -- LAST_UPDATE_LOGIN was going as -1 into UDA tables (po_lines_all_ext_b)
2208 /*
2209 l_resp_id :=NULL;
2210 l_progress := '010';
2211 l_resp_id := wf_engine.GetItemAttrNumber( itemtype => itemtype,
2212 itemkey => itemkey,
2213 aname => 'RESPONSIBILITY_ID');
2214 l_progress := '020';
2215 IF (g_po_wf_debug = 'Y') THEN
2216 PO_WF_DEBUG_PKG.insert_debug(itemtype,
2217 itemkey,
2218 'PO_WF_PO_CHARGE_ACC.reset_resp_id: Setting the Responsibility back to:' || l_resp_id);
2219 END IF;
2220 FND_GLOBAL.apps_initialize( user_id => fnd_global.user_id,
2221 resp_id => l_resp_id,
2222 resp_appl_id => fnd_global.resp_appl_id);
2223 l_progress := '030';
2224 */
2225 result := WF_ENGINE.eng_completed || ':Y';
2226 EXCEPTION
2227 WHEN OTHERS THEN
2228 WF_CORE.context('PO_WF_PO_CHARGE_ACC','RESET_RESP_ID',l_progress);
2229 RAISE;
2230 END reset_resp_id;
2231 --Bug4033391 End
2232
2233 ---------------------------------------------------------------------------
2234 --Start of Comments
2235 --Bug 7260456: Added this procedure.
2236 --Name: validate_combination
2237 --Pre-reqs:
2238 -- FND_FLEX_WORKFLOW_APIS.VALIDATE_COMBINATION should be called to validate
2239 -- standard validations. Workflow attributes FND_FLEX_STATUS,
2240 -- CHART_OF_ACCOUNTS_ID, FND_FLEX_SEGMENTS, ENCUMBRANCE_DATE must be set.
2241 --Modifies:
2242 -- None
2243 --Locks:
2244 -- None.
2245 --Function:
2246 -- This procedure checks for validations apart from
2247 -- FND_FLEX_WORKFLOW_APIS.VALIDATE_COMBINATION and should be called just
2248 -- after calling VALIDATE_COMBINATION.
2249 -- This procedure has been created to validate for parent account and the
2250 -- posting allowed flag.
2251 -- The procedure is called from the account generator workflow, for
2252 -- validating the accounts.
2253 --Parameters:
2254 --IN:
2255 -- Standard workflow function parameters
2256 --OUT:
2257 -- Standard workflow function result parameter.
2258 --Testing:
2259 --
2260 --Notes:
2261 -- This procedure has been created because the standard workflow API
2262 -- FND_FLEX_WORKFLOW_APIS.VALIDATE_COMBINATION does not support VRULE.
2263 -- Bug 7168777 has been logged for same.
2264 --End of Comments
2265 ---------------------------------------------------------------------------
2266 PROCEDURE validate_combination(
2267 itemtype IN VARCHAR2,
2268 itemkey IN VARCHAR2,
2269 actid IN NUMBER,
2270 funcmode IN VARCHAR2,
2271 result OUT NOCOPY VARCHAR2)
2272 IS
2273 l_progress wf_item_activity_statuses.error_stack%TYPE;
2274 l_flex_status VARCHAR2(100);
2275 l_concat_segments VARCHAR2(2000);
2276 l_validation_date DATE;
2277 l_coa_id gl_code_combinations.chart_of_accounts_id%TYPE;
2278 l_is_combination_valid BOOLEAN;
2279
2280 --Bug 9645501
2281 l_account_gen_flow_type VARCHAR2(25);
2282
2283 BEGIN
2284
2285 l_progress := '010';
2286 -- Do nothing in cancel or timeout mode
2287 IF (funcmode <> wf_engine.eng_run) THEN
2288 result := wf_engine.eng_null;
2289 RETURN;
2290 END IF;
2291
2292 l_progress := '020';
2293 l_flex_status := po_wf_util_pkg.getitemattrtext(
2294 itemtype => itemtype,
2295 itemkey => itemkey,
2296 aname => 'FND_FLEX_STATUS');
2297
2298 IF (g_po_wf_debug = 'Y') THEN
2299 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2300 'PO_WF_PO_CHARGE_ACC.validate_combination: l_flex_status='
2301 ||l_flex_status);
2302 END IF;
2303
2304 -- Do nothing if FND_FLEX_STATUS is INVALID
2305 IF (l_flex_status = 'INVALID') THEN
2306 result := wf_engine.eng_null;
2307 RETURN;
2308 END IF;
2309
2310 --Begin Bug 9645501
2311 l_account_gen_flow_type := PO_WF_UTIL_PKG.GetItemAttrText(
2312 itemtype => itemtype,
2313 itemkey => itemkey,
2314 aname => 'ACCOUNT_GENERATION_FLOW_TYPE');
2315
2316
2317 IF (l_account_gen_flow_type IS NULL OR l_account_gen_flow_type = PO_WF_BUILD_ACCOUNT_INIT.g_po_accounts) THEN
2318 l_coa_id := po_wf_util_pkg.getitemattrtext(
2319 itemtype => itemtype,
2320 itemkey => itemkey,
2321 aname => 'CHART_OF_ACCOUNTS_ID');
2322 ELSE
2323
2324 l_coa_id := PO_WF_UTIL_PKG.GetItemAttrNumber(
2325 itemtype => itemtype,
2326 itemkey => itemkey,
2327 aname => 'SHIP_TO_OU_COA_ID');
2328
2329 END IF;
2330 --End Bug 9645501
2331
2332 l_concat_segments := po_wf_util_pkg.getitemattrtext(
2333 itemtype => itemtype,
2334 itemkey => itemkey,
2335 aname => 'FND_FLEX_SEGMENTS');
2336
2337 l_validation_date := nvl(po_wf_util_pkg.getitemattrtext(
2338 itemtype => itemtype,
2339 itemkey => itemkey,
2340 aname => 'ENCUMBRANCE_DATE'),
2341 SYSDATE);
2342
2343 l_progress := '030';
2344 -- Validate VRULE for the combination
2345 l_is_combination_valid := fnd_flex_keyval.validate_segs(
2346 operation => 'CHECK_COMBINATION',
2347 appl_short_name => 'SQLGL',
2348 key_flex_code => 'GL#',
2349 structure_number => l_coa_id,
2350 concat_segments => l_concat_segments,
2351 validation_date => l_validation_date,
2352 vrule => '\nSUMMARY_FLAG\nI' ||
2353 '\nAPPL=SQLGL;NAME=GL_NO_PARENT_SEGMENT_ALLOWED\nN\0' ||
2354 'GL_GLOBAL\nDETAIL_POSTING_ALLOWED\nI\nNAME=PO_ALL_POSTING_NA\nY');
2355
2356 IF (NOT l_is_combination_valid) THEN
2357 IF (g_po_wf_debug = 'Y') THEN
2358 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2359 'PO_WF_PO_CHARGE_ACC.validate_combination: l_is_combination_valid is false');
2360 END IF;
2361
2362 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_STATUS','INVALID');
2363 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_MESSAGE',
2364 fnd_flex_keyval.encoded_error_message);
2365 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_CCID','0');
2366 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_DATA','');
2367 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_DESCRIPTIONS','');
2368 wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_NEW','N');
2369 END IF;
2370
2371 result := wf_engine.eng_completed || ':' || wf_engine.eng_null;
2372 END validate_combination;
2373
2374 END PO_WF_PO_CHARGE_ACC;