1: PACKAGE BODY PO_WF_PO_CHARGE_ACC AS
2: /* $Header: POXWPCAB.pls 120.9.12010000.2 2008/08/04 08:36:47 rramasam 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');
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)
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:
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:
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');
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;
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:
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;
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:
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:
363: RETURN;
364:
365: EXCEPTION
366: WHEN OTHERS THEN
367: wf_core.context('PO_WF_PO_CHARGE_ACC','inventory',x_progress);
368:
369: /* Start DEBUG
370: If (debug_acc_generator_wf) then
371: dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.inventory');
367: wf_core.context('PO_WF_PO_CHARGE_ACC','inventory',x_progress);
368:
369: /* Start DEBUG
370: If (debug_acc_generator_wf) then
371: dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.inventory');
372: end if;
373: End DEBUG */
374:
375: raise;
389: is
390: x_asset_item_flag varchar2(4);
391: x_progress varchar2(200);
392: begin
393: x_progress := 'PO_WF_PO_CHARGE_ACC.check_inv_item_type: 01';
394:
395: select inventory_asset_flag into x_asset_item_flag
396: from mtl_system_items
397: where organization_id = x_dest_org_id
398: and inventory_item_id = x_item_id;
399:
400: /* Start DEBUG
401: If (debug_acc_generator_wf) then
402: dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.check_inv_item_type');
403: dbms_output.put_line ('X_ASSET_ITEM_FLAG: ' || x_asset_item_flag);
404: end if;
405: End DEBUG */
406:
414: WHEN OTHERS THEN
415: -- Bug 3433867: Enhanced exception handling for this function
416: IF (g_po_wf_debug = 'Y') THEN
417: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
418: 'PO_WF_PO_CHARGE_ACC.check_inv_item_type EXCEPTION at '||x_progress
419: ||': '||SQLERRM);
420: END IF;
421: wf_core.context('PO_WF_PO_CHARGE_ACC','check_inv_item_type',x_progress);
422: raise;
417: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
418: 'PO_WF_PO_CHARGE_ACC.check_inv_item_type EXCEPTION at '||x_progress
419: ||': '||SQLERRM);
420: END IF;
421: wf_core.context('PO_WF_PO_CHARGE_ACC','check_inv_item_type',x_progress);
422: raise;
423: end;
424:
425: --
433: x_asset_inventory number;
434: x_progress varchar2(100);
435: begin
436:
437: x_progress := 'PO_WF_PO_CHARGE_ACC.check_sub_inv_type: 01';
438:
439: select asset_inventory into x_asset_inventory
440: from mtl_secondary_inventories
441: where secondary_inventory_name = x_dest_sub_inv
450: end if;
451:
452: EXCEPTION
453: WHEN OTHERS THEN
454: wf_core.context('PO_WF_PO_CHARGE_ACC','check_sub_inv_type',x_progress);
455: raise;
456: end;
457:
458: -- * ****************************************************************************** *
482: dummy VARCHAR2(40);
483: ret BOOLEAN;
484: begin
485:
486: x_progress := 'PO_WF_PO_CHARGE_ACC.expense: 01';
487: IF (g_po_wf_debug = 'Y') THEN
488: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
489: END IF;
490:
507: aname => 'ITEM_ID');
508:
509: /* Start DEBUG
510: If (debug_acc_generator_wf) then
511: dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.expense');
512: dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_dest_org_id));
513: dbms_output.put_line ('ITEM_ID: ' || to_char(x_item_id));
514: end if;
515: End DEBUG */
569: result := 'COMPLETE:FAILURE';
570:
571: IF (g_po_wf_debug = 'Y') THEN
572: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
573: 'PO_WF_PO_CHARGE_ACC.expense result='||result);
574: END IF;
575:
576: return;
577: end if;
588: RETURN;
589:
590: IF (g_po_wf_debug = 'Y') THEN
591: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
592: 'PO_WF_PO_CHARGE_ACC.expense x_expense_acc='||x_expense_acc);
593: END IF;
594:
595: EXCEPTION
596: WHEN OTHERS THEN
593: END IF;
594:
595: EXCEPTION
596: WHEN OTHERS THEN
597: wf_core.context('PO_WF_PO_CHARGE_ACC','expense',x_progress);
598:
599: /* Start DEBUG
600: If (debug_acc_generator_wf) then
601: dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.expense');
597: wf_core.context('PO_WF_PO_CHARGE_ACC','expense',x_progress);
598:
599: /* Start DEBUG
600: If (debug_acc_generator_wf) then
601: dbms_output.put_line (' --> EXCEPTION <-- in PO_WF_PO_CHARGE_ACC.expense');
602: end if;
603: End DEBUG */
604:
605: raise;
620: wip_entity_type varchar2(80);
621: x_progress varchar2(100);
622: begin
623:
624: x_progress := 'PO_WF_PO_CHARGE_ACC.check_type_of_wip: 01';
625: IF (g_po_wf_debug = 'Y') THEN
626: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
627: END IF;
628:
640: itemkey => itemkey,
641: aname => 'WIP_ENTITY_TYPE');
642: /* Start DEBUG
643: If (debug_acc_generator_wf) then
644: dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.check_type_of_wip');
645: dbms_output.put_line ('WIP_ENTITY_TYPE: ' || wip_entity_type);
646: end if;
647: End DEBUG */
648:
655: return;
656:
657: EXCEPTION
658: WHEN OTHERS THEN
659: wf_core.context('PO_WF_PO_CHARGE_ACC','check_type_of_wip',x_progress);
660: raise;
661:
662: end check_type_of_wip;
663:
689: --
690:
691: begin
692:
693: x_progress := 'PO_WF_PO_CHARGE_ACC.job_wip: 01';
694: IF (g_po_wf_debug = 'Y') THEN
695: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
696: END IF;
697:
727: --
728:
729: /* Start DEBUG
730: If (debug_acc_generator_wf) then
731: dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.job_wip');
732: dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_destination_organization_id));
733: dbms_output.put_line ('BOM_COST_ELEMENT_ID: ' || to_char(x_bom_cost_element_id));
734: dbms_output.put_line ('WIP_ENTITY_ID: ' || to_char(x_wip_entity_id));
735: dbms_output.put_line ('WIP_ENTITY_TYPE: ' || x_wip_entity_type);
920: RETURN;
921:
922: EXCEPTION
923: WHEN OTHERS THEN
924: wf_core.context('PO_WF_PO_CHARGE_ACC','job_wip',x_progress);
925: IF (g_po_wf_debug = 'Y') THEN
926: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.JOB_WIP');
927: END IF;
928: raise;
922: EXCEPTION
923: WHEN OTHERS THEN
924: wf_core.context('PO_WF_PO_CHARGE_ACC','job_wip',x_progress);
925: IF (g_po_wf_debug = 'Y') THEN
926: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.JOB_WIP');
927: END IF;
928: raise;
929:
930: end job_wip;
948: x_wip_repetitive_schedule_id NUMBER;
949: x_progress varchar2(200);
950: begin
951:
952: x_progress := 'PO_WF_PO_CHARGE_ACC.schedule: 01';
953: IF (g_po_wf_debug = 'Y') THEN
954: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
955: END IF;
956:
985: aname => 'WIP_REPETITIVE_SCHEDULE_ID');
986:
987: /* Start DEBUG
988: If (debug_acc_generator_wf) then
989: dbms_output.put_line ('Procedure PO_WF_PO_CHARGE_ACC.Schedule');
990: dbms_output.put_line ('DESTINATION_ORGANIZATION_ID: ' || to_char(x_destination_organization_id));
991: dbms_output.put_line ('BOM_COST_ELEMENT_ID: ' || to_char(x_bom_cost_element_id));
992: dbms_output.put_line ('WIP_ENTITY_ID: ' || to_char(x_wip_entity_id));
993: dbms_output.put_line ('WIP_ENTITY_TYPE: ' || x_wip_entity_type);
1119: RETURN;
1120:
1121: EXCEPTION
1122: WHEN OTHERS THEN
1123: wf_core.context('PO_WF_PO_CHARGE_ACC','schedule',x_progress);
1124: IF (g_po_wf_debug = 'Y') THEN
1125: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.SCHEDULE');
1126: END IF;
1127: raise;
1121: EXCEPTION
1122: WHEN OTHERS THEN
1123: wf_core.context('PO_WF_PO_CHARGE_ACC','schedule',x_progress);
1124: IF (g_po_wf_debug = 'Y') THEN
1125: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey, 'EXCEPTION IN PO_WF_PO_CHARGE_ACC.SCHEDULE');
1126: END IF;
1127: raise;
1128:
1129: end schedule;
1149: l_purch_encumbrance_flag VARCHAR2(10);
1150: l_req_encumbrance_flag VARCHAR2(10);
1151: begin
1152:
1153: x_progress := 'PO_WF_PO_CHARGE_ACC.is_encumbrance_on: 01';
1154: IF (g_po_wf_debug = 'Y') THEN
1155: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1156: END IF;
1157:
1265: else
1266: result := 'COMPLETE:FALSE';
1267: end if;
1268:
1269: x_progress := 'PO_WF_PO_CHARGE_ACC.is_encumbrance_on: result = ' || result;
1270: IF (g_po_wf_debug = 'Y') THEN
1271: /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1272: END IF;
1273:
1274: return;
1275:
1276: EXCEPTION
1277: WHEN OTHERS THEN
1278: wf_core.context('PO_WF_PO_CHARGE_ACC','is_encumbrace_on',x_progress);
1279: raise;
1280:
1281: end is_encumbrance_on;
1282:
1404: END IF;
1405:
1406: IF (g_po_wf_debug = 'Y') THEN
1407: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1408: 'PO_WF_PO_CHARGE_ACC.is_dest_accounts_flow_type result='||result);
1409: END IF;
1410: EXCEPTION
1411: WHEN OTHERS THEN
1412: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_dest_accounts_flow_type',
1408: 'PO_WF_PO_CHARGE_ACC.is_dest_accounts_flow_type result='||result);
1409: END IF;
1410: EXCEPTION
1411: WHEN OTHERS THEN
1412: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_dest_accounts_flow_type',
1413: l_progress);
1414: RAISE;
1415: END is_dest_accounts_flow_type;
1416:
1465: END IF;
1466:
1467: IF (g_po_wf_debug = 'Y') THEN
1468: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1469: 'PO_WF_PO_CHARGE_ACC.is_SPS_distribution result='||result);
1470: END IF;
1471: EXCEPTION
1472: WHEN OTHERS THEN
1473: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_SPS_distribution', l_progress);
1469: 'PO_WF_PO_CHARGE_ACC.is_SPS_distribution result='||result);
1470: END IF;
1471: EXCEPTION
1472: WHEN OTHERS THEN
1473: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_SPS_distribution', l_progress);
1474: RAISE;
1475: END is_SPS_distribution;
1476:
1477: ---------------------------------------------------------------------------
1909: l_progress := '160';
1910:
1911: IF (g_po_wf_debug = 'Y') THEN
1912: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1913: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account result='||result);
1914: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1915: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account l_SPS_charge_account_id='||
1916: l_SPS_charge_account_id);
1917: END IF;
1911: IF (g_po_wf_debug = 'Y') THEN
1912: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1913: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account result='||result);
1914: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1915: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account l_SPS_charge_account_id='||
1916: l_SPS_charge_account_id);
1917: END IF;
1918: EXCEPTION
1919: WHEN OTHERS THEN
1918: EXCEPTION
1919: WHEN OTHERS THEN
1920: IF (g_po_wf_debug = 'Y') THEN
1921: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1922: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account EXCEPTION at '|| l_progress);
1923: END IF;
1924: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'get_SPS_charge_account', l_progress);
1925: RAISE;
1926: END get_SPS_charge_account;
1920: IF (g_po_wf_debug = 'Y') THEN
1921: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1922: 'PO_WF_PO_CHARGE_ACC.get_SPS_charge_account EXCEPTION at '|| l_progress);
1923: END IF;
1924: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'get_SPS_charge_account', l_progress);
1925: RAISE;
1926: END get_SPS_charge_account;
1927:
1928: ---------------------------------------------------------------------------
1986: itemkey => itemkey,
1987: aname => 'TEMP_ACCOUNT_ID');
1988:
1989: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
1990: 'PO_WF_PO_CHARGE_ACC.is_dest_charge_acc_null '||
1991: 'Copying DestChargeAccId to TEMP_ACCOUNT_ID '||
1992: '(current val = ' || l_temp_acc_id || ') ' ||
1993: 'dest_charge_account_id='||l_dest_charge_account_id);
1994: END IF;
2005: END IF;
2006:
2007: IF (g_po_wf_debug = 'Y') THEN
2008: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2009: 'PO_WF_PO_CHARGE_ACC.is_dest_charge_acc_null result='||result||
2010: ' l_dest_charge_account_id='||l_dest_charge_account_id);
2011: END IF;
2012:
2013: EXCEPTION
2011: END IF;
2012:
2013: EXCEPTION
2014: WHEN OTHERS THEN
2015: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'is_dest_charge_acc_null',
2016: l_progress);
2017: RAISE;
2018: END is_dest_charge_acc_null;
2019:
2097: END IF;
2098:
2099: IF (g_po_wf_debug = 'Y') THEN
2100: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2101: 'PO_WF_PO_CHARGE_ACC.are_COAs_same result='||result);
2102: END IF;
2103: EXCEPTION
2104: WHEN OTHERS THEN
2105: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'are_COAs_same',
2101: 'PO_WF_PO_CHARGE_ACC.are_COAs_same result='||result);
2102: END IF;
2103: EXCEPTION
2104: WHEN OTHERS THEN
2105: WF_CORE.context('PO_WF_PO_CHARGE_ACC', 'are_COAs_same',
2106: l_progress);
2107: RAISE;
2108: END are_COAs_same;
2109:
2145: l_progress := '020';
2146: IF (g_po_wf_debug = 'Y') THEN
2147: PO_WF_DEBUG_PKG.insert_debug(itemtype,
2148: itemkey,
2149: 'PO_WF_PO_CHARGE_ACC.set_null_resp_id: Setting the Responsibility to NULL ');
2150: END IF;
2151: FND_GLOBAL.apps_initialize( user_id => fnd_global.user_id,
2152: resp_id => NULL,
2153: resp_appl_id => fnd_global.resp_appl_id);
2154: l_progress := '030';
2155: result := WF_ENGINE.eng_completed || ':Y';
2156: EXCEPTION
2157: WHEN OTHERS THEN
2158: WF_CORE.context('PO_WF_PO_CHARGE_ACC','SET_NULL_RESP_ID',l_progress);
2159: raise;
2160:
2161: END set_null_resp_id;
2162:
2190: l_progress := '020';
2191: IF (g_po_wf_debug = 'Y') THEN
2192: PO_WF_DEBUG_PKG.insert_debug(itemtype,
2193: itemkey,
2194: 'PO_WF_PO_CHARGE_ACC.reset_resp_id: Setting the Responsibility back to:' || l_resp_id);
2195: END IF;
2196: FND_GLOBAL.apps_initialize( user_id => fnd_global.user_id,
2197: resp_id => l_resp_id,
2198: resp_appl_id => fnd_global.resp_appl_id);
2199: l_progress := '030';
2200: result := WF_ENGINE.eng_completed || ':Y';
2201: EXCEPTION
2202: WHEN OTHERS THEN
2203: WF_CORE.context('PO_WF_PO_CHARGE_ACC','RESET_RESP_ID',l_progress);
2204: RAISE;
2205: END reset_resp_id;
2206: --Bug4033391 End
2207:
2267: aname => 'FND_FLEX_STATUS');
2268:
2269: IF (g_po_wf_debug = 'Y') THEN
2270: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2271: 'PO_WF_PO_CHARGE_ACC.validate_combination: l_flex_status='
2272: ||l_flex_status);
2273: END IF;
2274:
2275: -- Do nothing if FND_FLEX_STATUS is INVALID
2309:
2310: IF (NOT l_is_combination_valid) THEN
2311: IF (g_po_wf_debug = 'Y') THEN
2312: PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,
2313: 'PO_WF_PO_CHARGE_ACC.validate_combination: l_is_combination_valid is false');
2314: END IF;
2315:
2316: wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_STATUS','INVALID');
2317: wf_engine.setitemattrtext(itemtype,itemkey,'FND_FLEX_MESSAGE',
2324:
2325: result := wf_engine.eng_completed || ':' || wf_engine.eng_null;
2326: END validate_combination;
2327:
2328: END PO_WF_PO_CHARGE_ACC;