1: PACKAGE BODY PO_ACCOUNT_HELPER AS
2: -- $Header: PO_ACCOUNT_HELPER.plb 120.8.12020000.6 2013/04/26 08:21:10 yuandli ship $
3:
4: --
5: d_pkg_name CONSTANT varchar2(50) := PO_LOG.get_package_base('PO_ACCOUNT_HELPER');
6:
7: --
8: PROCEDURE INSERT_REPORT_AUTONOMOUS(
9: P_MESSAGE_TEXT IN VARCHAR2
1099: AND pod.draft_id = p_draftid; --bug 16628805
1100:
1101: BEGIN
1102:
1103: IF (PO_LOG.d_proc) THEN
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1100:
1101: BEGIN
1102:
1103: IF (PO_LOG.d_proc) THEN
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1108: PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
1101: BEGIN
1102:
1103: IF (PO_LOG.d_proc) THEN
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1108: PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
1109: END IF;
1102:
1103: IF (PO_LOG.d_proc) THEN
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1108: PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
1109: END IF;
1110:
1103: IF (PO_LOG.d_proc) THEN
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1108: PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
1109: END IF;
1110:
1111: -- establish savepoint to roll back to (general exception)
1104: PO_LOG.proc_begin(d_module);
1105: PO_LOG.proc_begin(d_module, 'p_document_id', p_document_id);
1106: PO_LOG.proc_begin(d_module, 'p_document_type', p_document_type);
1107: PO_LOG.proc_begin(d_module, 'p_document_subtype', p_document_subtype);
1108: PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
1109: END IF;
1110:
1111: -- establish savepoint to roll back to (general exception)
1112: SAVEPOINT PO_ACCOUNT_HELPER_RB_ACC_SP;
1120: x_sequence := 0;
1121: x_return_status := l_return_status;
1122:
1123: d_position := 10;
1124: IF (PO_LOG.d_stmt) THEN
1125: PO_LOG.stmt(d_module,d_position,'l_report_id',l_report_id);
1126: END IF;
1127:
1128: --Check if EAM installed.
1121: x_return_status := l_return_status;
1122:
1123: d_position := 10;
1124: IF (PO_LOG.d_stmt) THEN
1125: PO_LOG.stmt(d_module,d_position,'l_report_id',l_report_id);
1126: END IF;
1127:
1128: --Check if EAM installed.
1129: l_product:= 'EAM';
1134: l_eam_installed := FALSE;
1135: END IF;
1136:
1137: d_position := 20;
1138: IF (PO_LOG.d_stmt) THEN
1139: PO_LOG.stmt(d_module,d_position,'l_eam_installed',l_status);
1140: END IF;
1141: --Check profile.
1142: l_is_dd_shopfloor := NVL(FND_PROFILE.VALUE('PO_DIRECT_DELIVERY_TO_SHOPFLOOR'),'N');
1135: END IF;
1136:
1137: d_position := 20;
1138: IF (PO_LOG.d_stmt) THEN
1139: PO_LOG.stmt(d_module,d_position,'l_eam_installed',l_status);
1140: END IF;
1141: --Check profile.
1142: l_is_dd_shopfloor := NVL(FND_PROFILE.VALUE('PO_DIRECT_DELIVERY_TO_SHOPFLOOR'),'N');
1143: l_is_pa_flex_override := NVL(FND_PROFILE.VALUE('PA_ALLOW_FLEXBUILDER_OVERRIDES'),'N');
1142: l_is_dd_shopfloor := NVL(FND_PROFILE.VALUE('PO_DIRECT_DELIVERY_TO_SHOPFLOOR'),'N');
1143: l_is_pa_flex_override := NVL(FND_PROFILE.VALUE('PA_ALLOW_FLEXBUILDER_OVERRIDES'),'N');
1144:
1145: d_position := 30;
1146: IF (PO_LOG.d_stmt) THEN
1147: PO_LOG.stmt(d_module,d_position,'l_is_dd_shopfloor',l_is_dd_shopfloor);
1148: PO_LOG.stmt(d_module,d_position,'l_is_pa_flex_override',l_is_pa_flex_override);
1149: END IF;
1150: -- Get OU ID.
1143: l_is_pa_flex_override := NVL(FND_PROFILE.VALUE('PA_ALLOW_FLEXBUILDER_OVERRIDES'),'N');
1144:
1145: d_position := 30;
1146: IF (PO_LOG.d_stmt) THEN
1147: PO_LOG.stmt(d_module,d_position,'l_is_dd_shopfloor',l_is_dd_shopfloor);
1148: PO_LOG.stmt(d_module,d_position,'l_is_pa_flex_override',l_is_pa_flex_override);
1149: END IF;
1150: -- Get OU ID.
1151: SELECT org_id
1144:
1145: d_position := 30;
1146: IF (PO_LOG.d_stmt) THEN
1147: PO_LOG.stmt(d_module,d_position,'l_is_dd_shopfloor',l_is_dd_shopfloor);
1148: PO_LOG.stmt(d_module,d_position,'l_is_pa_flex_override',l_is_pa_flex_override);
1149: END IF;
1150: -- Get OU ID.
1151: SELECT org_id
1152: INTO l_current_ou_id
1154: WHERE poh.po_header_id = p_document_id
1155: AND poh.draft_id = NVL(p_draft_id, -1); --bug 16628805
1156:
1157: d_position := 40;
1158: IF (PO_LOG.d_stmt) THEN
1159: PO_LOG.stmt(d_module,d_position,'l_current_ou_id',l_current_ou_id);
1160: END IF;
1161: --Get OU Info.
1162: SELECT NVL(FSP.req_encumbrance_flag, 'N') req_encumbrance_flag,
1155: AND poh.draft_id = NVL(p_draft_id, -1); --bug 16628805
1156:
1157: d_position := 40;
1158: IF (PO_LOG.d_stmt) THEN
1159: PO_LOG.stmt(d_module,d_position,'l_current_ou_id',l_current_ou_id);
1160: END IF;
1161: --Get OU Info.
1162: SELECT NVL(FSP.req_encumbrance_flag, 'N') req_encumbrance_flag,
1163: NVL(FSP.purch_encumbrance_flag, 'N') purch_encumbrance_flag,
1178: AND COAFS.id_flex_code = 'GL#'
1179: and PSP.org_id = l_current_ou_id;
1180:
1181: d_position := 50;
1182: IF (PO_LOG.d_stmt) THEN
1183: PO_LOG.stmt(d_module,d_position,'l_req_encum_on',l_req_encum_on);
1184: PO_LOG.stmt(d_module,d_position,'l_po_encum_on',l_po_encum_on);
1185: PO_LOG.stmt(d_module,d_position,'l_expense_accrual_code',l_expense_accrual_code);
1186: PO_LOG.stmt(d_module,d_position,'l_coa_id',l_coa_id);
1179: and PSP.org_id = l_current_ou_id;
1180:
1181: d_position := 50;
1182: IF (PO_LOG.d_stmt) THEN
1183: PO_LOG.stmt(d_module,d_position,'l_req_encum_on',l_req_encum_on);
1184: PO_LOG.stmt(d_module,d_position,'l_po_encum_on',l_po_encum_on);
1185: PO_LOG.stmt(d_module,d_position,'l_expense_accrual_code',l_expense_accrual_code);
1186: PO_LOG.stmt(d_module,d_position,'l_coa_id',l_coa_id);
1187: END IF;
1180:
1181: d_position := 50;
1182: IF (PO_LOG.d_stmt) THEN
1183: PO_LOG.stmt(d_module,d_position,'l_req_encum_on',l_req_encum_on);
1184: PO_LOG.stmt(d_module,d_position,'l_po_encum_on',l_po_encum_on);
1185: PO_LOG.stmt(d_module,d_position,'l_expense_accrual_code',l_expense_accrual_code);
1186: PO_LOG.stmt(d_module,d_position,'l_coa_id',l_coa_id);
1187: END IF;
1188: --Lock document
1181: d_position := 50;
1182: IF (PO_LOG.d_stmt) THEN
1183: PO_LOG.stmt(d_module,d_position,'l_req_encum_on',l_req_encum_on);
1184: PO_LOG.stmt(d_module,d_position,'l_po_encum_on',l_po_encum_on);
1185: PO_LOG.stmt(d_module,d_position,'l_expense_accrual_code',l_expense_accrual_code);
1186: PO_LOG.stmt(d_module,d_position,'l_coa_id',l_coa_id);
1187: END IF;
1188: --Lock document
1189: BEGIN
1182: IF (PO_LOG.d_stmt) THEN
1183: PO_LOG.stmt(d_module,d_position,'l_req_encum_on',l_req_encum_on);
1184: PO_LOG.stmt(d_module,d_position,'l_po_encum_on',l_po_encum_on);
1185: PO_LOG.stmt(d_module,d_position,'l_expense_accrual_code',l_expense_accrual_code);
1186: PO_LOG.stmt(d_module,d_position,'l_coa_id',l_coa_id);
1187: END IF;
1188: --Lock document
1189: BEGIN
1190: IF NVL(p_draft_id,-1) = -1 THEN --bug 16628805
1205: END IF;
1206: END;
1207:
1208: d_position := 60;
1209: IF (PO_LOG.d_stmt) THEN
1210: PO_LOG.stmt(d_module,d_position,'locked document',p_document_id);
1211: END IF;
1212: --Loop each distribution.
1213: FOR l_dists in dists_csr(p_document_id, p_draft_id) --bug 16628805
1206: END;
1207:
1208: d_position := 60;
1209: IF (PO_LOG.d_stmt) THEN
1210: PO_LOG.stmt(d_module,d_position,'locked document',p_document_id);
1211: END IF;
1212: --Loop each distribution.
1213: FOR l_dists in dists_csr(p_document_id, p_draft_id) --bug 16628805
1214: LOOP
1212: --Loop each distribution.
1213: FOR l_dists in dists_csr(p_document_id, p_draft_id) --bug 16628805
1214: LOOP
1215: d_position := 61;
1216: IF (PO_LOG.d_stmt) THEN
1217: PO_LOG.stmt(d_module,d_position,'Checking distribution',l_dists.po_distribution_id);
1218: END IF;
1219: --Lock distribution
1220: BEGIN
1213: FOR l_dists in dists_csr(p_document_id, p_draft_id) --bug 16628805
1214: LOOP
1215: d_position := 61;
1216: IF (PO_LOG.d_stmt) THEN
1217: PO_LOG.stmt(d_module,d_position,'Checking distribution',l_dists.po_distribution_id);
1218: END IF;
1219: --Lock distribution
1220: BEGIN
1221: IF NVL(p_draft_id,-1) = -1 THEN --bug 16628805
1236: END IF;
1237: END;
1238:
1239: d_position := 62;
1240: IF (PO_LOG.d_stmt) THEN
1241: PO_LOG.stmt(d_module,d_position,'locked distribution',l_dists.po_distribution_id);
1242: END IF;
1243: --Get OSP flag.
1244: SELECT nvl(pltb.outside_operation_flag, 'N')
1237: END;
1238:
1239: d_position := 62;
1240: IF (PO_LOG.d_stmt) THEN
1241: PO_LOG.stmt(d_module,d_position,'locked distribution',l_dists.po_distribution_id);
1242: END IF;
1243: --Get OSP flag.
1244: SELECT nvl(pltb.outside_operation_flag, 'N')
1245: INTO l_osp_flag
1259: EAM conditions require that EAM be installed, direct delivery to
1260: shop floor profile option is Y, and outside operation flag is N.
1261: */
1262: d_position := 63;
1263: IF (PO_LOG.d_stmt) THEN
1264: PO_LOG.stmt(d_module,d_position,'l_osp_flag',l_osp_flag);
1265: END IF;
1266: IF ('Y' = l_dists.encumbered_flag)
1267: OR l_dists.DESTINATION_ORGANIZATION_ID IS NULL
1260: shop floor profile option is Y, and outside operation flag is N.
1261: */
1262: d_position := 63;
1263: IF (PO_LOG.d_stmt) THEN
1264: PO_LOG.stmt(d_module,d_position,'l_osp_flag',l_osp_flag);
1265: END IF;
1266: IF ('Y' = l_dists.encumbered_flag)
1267: OR l_dists.DESTINATION_ORGANIZATION_ID IS NULL
1268: OR ('SHOP FLOOR' = l_dists.destination_type_code
1274: CONTINUE;
1275: END IF;
1276:
1277: d_position := 64;
1278: IF (PO_LOG.d_stmt) THEN
1279: PO_LOG.stmt(d_module,d_position,'first validation passed', 'Y');
1280: END IF;
1281: --#2. Validate if the account is read-only.
1282: l_isPoChargeAccountReadOnly := FALSE;
1275: END IF;
1276:
1277: d_position := 64;
1278: IF (PO_LOG.d_stmt) THEN
1279: PO_LOG.stmt(d_module,d_position,'first validation passed', 'Y');
1280: END IF;
1281: --#2. Validate if the account is read-only.
1282: l_isPoChargeAccountReadOnly := FALSE;
1283: l_isSPSDistribution := FALSE;
1329: END IF;
1330: END IF;
1331:
1332: d_position := 65;
1333: IF (PO_LOG.d_stmt) THEN
1334: PO_LOG.stmt(d_module,d_position,'l_isPoChargeAccountReadOnly', l_isPoChargeAccountReadOnly);
1335: PO_LOG.stmt(d_module,d_position,'l_isSPSDistribution', l_isSPSDistribution);
1336: END IF;
1337:
1330: END IF;
1331:
1332: d_position := 65;
1333: IF (PO_LOG.d_stmt) THEN
1334: PO_LOG.stmt(d_module,d_position,'l_isPoChargeAccountReadOnly', l_isPoChargeAccountReadOnly);
1335: PO_LOG.stmt(d_module,d_position,'l_isSPSDistribution', l_isSPSDistribution);
1336: END IF;
1337:
1338: IF l_isPoChargeAccountReadOnly = TRUE THEN
1331:
1332: d_position := 65;
1333: IF (PO_LOG.d_stmt) THEN
1334: PO_LOG.stmt(d_module,d_position,'l_isPoChargeAccountReadOnly', l_isPoChargeAccountReadOnly);
1335: PO_LOG.stmt(d_module,d_position,'l_isSPSDistribution', l_isSPSDistribution);
1336: END IF;
1337:
1338: IF l_isPoChargeAccountReadOnly = TRUE THEN
1339: CONTINUE;
1389: X_billable_flag => l_billable_flag);
1390: END;
1391:
1392: d_position := 66;
1393: IF (PO_LOG.d_stmt) THEN
1394: PO_LOG.stmt(d_module,d_position,'l_billable_flag', l_billable_flag);
1395: END IF;
1396: --#4: Get entity type
1397: BEGIN
1390: END;
1391:
1392: d_position := 66;
1393: IF (PO_LOG.d_stmt) THEN
1394: PO_LOG.stmt(d_module,d_position,'l_billable_flag', l_billable_flag);
1395: END IF;
1396: --#4: Get entity type
1397: BEGIN
1398: select entity_type
1409: l_entity_type := NULL;
1410: END;
1411:
1412: d_position := 67;
1413: IF (PO_LOG.d_stmt) THEN
1414: PO_LOG.stmt(d_module,d_position,'l_entity_type', l_entity_type);
1415: END IF;
1416: --#5: store into variables
1417: l_dest_charge_account_id := l_dists.DEST_CHARGE_ACCOUNT_ID;
1410: END;
1411:
1412: d_position := 67;
1413: IF (PO_LOG.d_stmt) THEN
1414: PO_LOG.stmt(d_module,d_position,'l_entity_type', l_entity_type);
1415: END IF;
1416: --#5: store into variables
1417: l_dest_charge_account_id := l_dists.DEST_CHARGE_ACCOUNT_ID;
1418: l_dest_variance_account_id := l_dists.DEST_VARIANCE_ACCOUNT_ID;
1425: --l_award_number := PO_GMS_INTEGRATION_PVT.get_number_from_award_set_id(
1426: -- p_award_set_id => l_dists.award_id);
1427:
1428: d_position := 68;
1429: IF (PO_LOG.d_stmt) THEN
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1426: -- p_award_set_id => l_dists.award_id);
1427:
1428: d_position := 68;
1429: IF (PO_LOG.d_stmt) THEN
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1427:
1428: d_position := 68;
1429: IF (PO_LOG.d_stmt) THEN
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1428: d_position := 68;
1429: IF (PO_LOG.d_stmt) THEN
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1436: PO_LOG.stmt(d_module,d_position,'old_variance_account_id', l_variance_account_id);
1429: IF (PO_LOG.d_stmt) THEN
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1436: PO_LOG.stmt(d_module,d_position,'old_variance_account_id', l_variance_account_id);
1437: END IF;
1430: PO_LOG.stmt(d_module,d_position,'l_award_number', l_award_number);
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1436: PO_LOG.stmt(d_module,d_position,'old_variance_account_id', l_variance_account_id);
1437: END IF;
1438:
1431: PO_LOG.stmt(d_module,d_position,'old_dest_charge_account_id', l_dest_charge_account_id);
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1436: PO_LOG.stmt(d_module,d_position,'old_variance_account_id', l_variance_account_id);
1437: END IF;
1438:
1439: --#6: call workflow
1432: PO_LOG.stmt(d_module,d_position,'old_dest_variance_account_id', l_dest_variance_account_id);
1433: PO_LOG.stmt(d_module,d_position,'old_code_combination_id', l_old_code_combination_id);
1434: PO_LOG.stmt(d_module,d_position,'old_budget_account_id', l_budget_account_id);
1435: PO_LOG.stmt(d_module,d_position,'old_accrual_account_id', l_accrual_account_id);
1436: PO_LOG.stmt(d_module,d_position,'old_variance_account_id', l_variance_account_id);
1437: END IF;
1438:
1439: --#6: call workflow
1440: l_code_combination_id := NULL;
1572: p_distribution_id => l_dists.po_distribution_id,
1573: p_award_number => l_award_number);
1574:
1575: d_position := 69;
1576: IF (PO_LOG.d_stmt) THEN
1577: PO_LOG.stmt(d_module,d_position,'l_success', l_success);
1578: PO_LOG.stmt(d_module,d_position,'new_code_combination_id', l_code_combination_id);
1579: END IF;
1580: --#7: handle workflow result
1573: p_award_number => l_award_number);
1574:
1575: d_position := 69;
1576: IF (PO_LOG.d_stmt) THEN
1577: PO_LOG.stmt(d_module,d_position,'l_success', l_success);
1578: PO_LOG.stmt(d_module,d_position,'new_code_combination_id', l_code_combination_id);
1579: END IF;
1580: --#7: handle workflow result
1581: IF l_success
1574:
1575: d_position := 69;
1576: IF (PO_LOG.d_stmt) THEN
1577: PO_LOG.stmt(d_module,d_position,'l_success', l_success);
1578: PO_LOG.stmt(d_module,d_position,'new_code_combination_id', l_code_combination_id);
1579: END IF;
1580: --#7: handle workflow result
1581: IF l_success
1582: AND l_code_combination_id IS NOT NULL
1606: OR (l_dists.destination_type_code = 'SHOP FLOOR'
1607: AND l_entity_type = 6)) --EAM JOB
1608: AND l_dists.distribution_type <> 'PREPAYMENT'
1609: THEN
1610: IF (PO_LOG.d_stmt) THEN
1611: PO_LOG.stmt(d_module,d_position,'new_budget_account_id', l_budget_account_id);
1612: END IF;
1613: --update current distribution budget_account_id with l_budget_account_id
1614: IF NVL(p_draft_id, -1) = -1 THEN --bug 16628805
1607: AND l_entity_type = 6)) --EAM JOB
1608: AND l_dists.distribution_type <> 'PREPAYMENT'
1609: THEN
1610: IF (PO_LOG.d_stmt) THEN
1611: PO_LOG.stmt(d_module,d_position,'new_budget_account_id', l_budget_account_id);
1612: END IF;
1613: --update current distribution budget_account_id with l_budget_account_id
1614: IF NVL(p_draft_id, -1) = -1 THEN --bug 16628805
1615: update po_distributions_all
1626: and draft_id = p_draft_id;
1627: END IF;
1628: END IF;
1629:
1630: IF (PO_LOG.d_stmt) THEN
1631: PO_LOG.stmt(d_module,d_position,'new_accrual_account_id', l_accrual_account_id);
1632: PO_LOG.stmt(d_module,d_position,'new_variance_account_id', l_variance_account_id);
1633: END IF;
1634: --update current distribution accrual_account_id with l_accrual_account_id
1627: END IF;
1628: END IF;
1629:
1630: IF (PO_LOG.d_stmt) THEN
1631: PO_LOG.stmt(d_module,d_position,'new_accrual_account_id', l_accrual_account_id);
1632: PO_LOG.stmt(d_module,d_position,'new_variance_account_id', l_variance_account_id);
1633: END IF;
1634: --update current distribution accrual_account_id with l_accrual_account_id
1635: --update current distribution variance_account_id with l_variance_account_id
1628: END IF;
1629:
1630: IF (PO_LOG.d_stmt) THEN
1631: PO_LOG.stmt(d_module,d_position,'new_accrual_account_id', l_accrual_account_id);
1632: PO_LOG.stmt(d_module,d_position,'new_variance_account_id', l_variance_account_id);
1633: END IF;
1634: --update current distribution accrual_account_id with l_accrual_account_id
1635: --update current distribution variance_account_id with l_variance_account_id
1636: IF NVL(p_draft_id, -1) = -1 THEN --bug 16628805
1649: where po_distribution_id = l_dists.po_distribution_id
1650: and draft_id = p_draft_id;
1651: END IF;
1652:
1653: IF (PO_LOG.d_stmt) THEN
1654: PO_LOG.stmt(d_module,d_position,'new_dest_charge_account_id', l_dest_charge_account_id);
1655: PO_LOG.stmt(d_module,d_position,'new_dest_variance_account_id', l_dest_variance_account_id);
1656: END IF;
1657: IF l_isSPSDistribution THEN
1650: and draft_id = p_draft_id;
1651: END IF;
1652:
1653: IF (PO_LOG.d_stmt) THEN
1654: PO_LOG.stmt(d_module,d_position,'new_dest_charge_account_id', l_dest_charge_account_id);
1655: PO_LOG.stmt(d_module,d_position,'new_dest_variance_account_id', l_dest_variance_account_id);
1656: END IF;
1657: IF l_isSPSDistribution THEN
1658: --update current distribution dest_charge_account_id with l_dest_charge_account_id
1651: END IF;
1652:
1653: IF (PO_LOG.d_stmt) THEN
1654: PO_LOG.stmt(d_module,d_position,'new_dest_charge_account_id', l_dest_charge_account_id);
1655: PO_LOG.stmt(d_module,d_position,'new_dest_variance_account_id', l_dest_variance_account_id);
1656: END IF;
1657: IF l_isSPSDistribution THEN
1658: --update current distribution dest_charge_account_id with l_dest_charge_account_id
1659: --update current distribution dest_variance_account_id with l_dest_variance_account_id
1676: END IF;
1677: END IF;
1678:
1679: d_position := 70;
1680: IF (PO_LOG.d_stmt) THEN
1681: PO_LOG.stmt(d_module,d_position,'l_return_status', l_return_status);
1682: END IF;
1683: IF (NOT l_success) AND l_fb_error_msg IS NOT NULL THEN
1684: IF (PO_LOG.d_stmt) THEN
1677: END IF;
1678:
1679: d_position := 70;
1680: IF (PO_LOG.d_stmt) THEN
1681: PO_LOG.stmt(d_module,d_position,'l_return_status', l_return_status);
1682: END IF;
1683: IF (NOT l_success) AND l_fb_error_msg IS NOT NULL THEN
1684: IF (PO_LOG.d_stmt) THEN
1685: PO_LOG.stmt(d_module,d_position,'l_fb_error_msg', l_fb_error_msg);
1680: IF (PO_LOG.d_stmt) THEN
1681: PO_LOG.stmt(d_module,d_position,'l_return_status', l_return_status);
1682: END IF;
1683: IF (NOT l_success) AND l_fb_error_msg IS NOT NULL THEN
1684: IF (PO_LOG.d_stmt) THEN
1685: PO_LOG.stmt(d_module,d_position,'l_fb_error_msg', l_fb_error_msg);
1686: END IF;
1687: INSERT_REPORT_AUTONOMOUS(
1688: P_MESSAGE_TEXT => l_fb_error_msg
1681: PO_LOG.stmt(d_module,d_position,'l_return_status', l_return_status);
1682: END IF;
1683: IF (NOT l_success) AND l_fb_error_msg IS NOT NULL THEN
1684: IF (PO_LOG.d_stmt) THEN
1685: PO_LOG.stmt(d_module,d_position,'l_fb_error_msg', l_fb_error_msg);
1686: END IF;
1687: INSERT_REPORT_AUTONOMOUS(
1688: P_MESSAGE_TEXT => l_fb_error_msg
1689: , P_USER_ID => FND_GLOBAL.user_id
1701: );
1702: ELSE
1703:
1704: IF (NOT l_charge_success) THEN
1705: IF (PO_LOG.d_stmt) THEN
1706: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_CHARGE_FLEX'));
1707: END IF;
1708: INSERT_REPORT_AUTONOMOUS(
1709: P_MESSAGE_TEXT => NULL
1702: ELSE
1703:
1704: IF (NOT l_charge_success) THEN
1705: IF (PO_LOG.d_stmt) THEN
1706: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_CHARGE_FLEX'));
1707: END IF;
1708: INSERT_REPORT_AUTONOMOUS(
1709: P_MESSAGE_TEXT => NULL
1710: , P_USER_ID => FND_GLOBAL.user_id
1722: );
1723: END IF;
1724:
1725: IF (NOT l_accrual_success) THEN
1726: IF (PO_LOG.d_stmt) THEN
1727: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_ACCRUAL_FLEX'));
1728: END IF;
1729: INSERT_REPORT_AUTONOMOUS(
1730: P_MESSAGE_TEXT => NULL
1723: END IF;
1724:
1725: IF (NOT l_accrual_success) THEN
1726: IF (PO_LOG.d_stmt) THEN
1727: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_ACCRUAL_FLEX'));
1728: END IF;
1729: INSERT_REPORT_AUTONOMOUS(
1730: P_MESSAGE_TEXT => NULL
1731: , P_USER_ID => FND_GLOBAL.user_id
1743: );
1744: END IF;
1745:
1746: IF (NOT l_budget_success) THEN
1747: IF (PO_LOG.d_stmt) THEN
1748: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_BUDGET_FLEX'));
1749: END IF;
1750: INSERT_REPORT_AUTONOMOUS(
1751: P_MESSAGE_TEXT => NULL
1744: END IF;
1745:
1746: IF (NOT l_budget_success) THEN
1747: IF (PO_LOG.d_stmt) THEN
1748: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_BUDGET_FLEX'));
1749: END IF;
1750: INSERT_REPORT_AUTONOMOUS(
1751: P_MESSAGE_TEXT => NULL
1752: , P_USER_ID => FND_GLOBAL.user_id
1782: );
1783: END IF;
1784:
1785: IF (NOT l_dest_charge_success) THEN
1786: IF (PO_LOG.d_stmt) THEN
1787: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_DEST_CHARGE_FLEX'));
1788: END IF;
1789: INSERT_REPORT_AUTONOMOUS(
1790: P_MESSAGE_TEXT => NULL
1783: END IF;
1784:
1785: IF (NOT l_dest_charge_success) THEN
1786: IF (PO_LOG.d_stmt) THEN
1787: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_DEST_CHARGE_FLEX'));
1788: END IF;
1789: INSERT_REPORT_AUTONOMOUS(
1790: P_MESSAGE_TEXT => NULL
1791: , P_USER_ID => FND_GLOBAL.user_id
1803: );
1804: END IF;
1805:
1806: IF (NOT l_dest_variance_success) THEN
1807: IF (PO_LOG.d_stmt) THEN
1808: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_DEST_VARIANCE_FLEX'));
1809: END IF;
1810: INSERT_REPORT_AUTONOMOUS(
1811: P_MESSAGE_TEXT => NULL
1804: END IF;
1805:
1806: IF (NOT l_dest_variance_success) THEN
1807: IF (PO_LOG.d_stmt) THEN
1808: PO_LOG.stmt(d_module,d_position,'error msg', fnd_message.get_string('PO', 'PO_ALL_NO_DEST_VARIANCE_FLEX'));
1809: END IF;
1810: INSERT_REPORT_AUTONOMOUS(
1811: P_MESSAGE_TEXT => NULL
1812: , P_USER_ID => FND_GLOBAL.user_id
1829: END LOOP; --Loop each distribution
1830:
1831: x_return_status := l_return_status;
1832:
1833: IF (PO_LOG.d_proc) THEN
1834: PO_LOG.proc_end(d_module);
1835: END IF;
1836:
1837: EXCEPTION
1830:
1831: x_return_status := l_return_status;
1832:
1833: IF (PO_LOG.d_proc) THEN
1834: PO_LOG.proc_end(d_module);
1835: END IF;
1836:
1837: EXCEPTION
1838: WHEN OTHERS THEN
1868: l_user_id NUMBER;
1869:
1870: BEGIN
1871:
1872: IF (PO_LOG.d_proc) THEN
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1869:
1870: BEGIN
1871:
1872: IF (PO_LOG.d_proc) THEN
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1870: BEGIN
1871:
1872: IF (PO_LOG.d_proc) THEN
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1878: PO_LOG.proc_begin(d_module, 'p_online_report_id', p_online_report_id);
1871:
1872: IF (PO_LOG.d_proc) THEN
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1878: PO_LOG.proc_begin(d_module, 'p_online_report_id', p_online_report_id);
1879: END IF;
1872: IF (PO_LOG.d_proc) THEN
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1878: PO_LOG.proc_begin(d_module, 'p_online_report_id', p_online_report_id);
1879: END IF;
1880:
1873: PO_LOG.proc_begin(d_module);
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1878: PO_LOG.proc_begin(d_module, 'p_online_report_id', p_online_report_id);
1879: END IF;
1880:
1881: d_position := 10;
1874: PO_LOG.proc_begin(d_module, 'p_message_text', p_message_text);
1875: PO_LOG.proc_begin(d_module, 'p_user_id', p_user_id);
1876: PO_LOG.proc_begin(d_module, 'p_text_line', p_text_line);
1877: PO_LOG.proc_begin(d_module, 'p_message_type', p_message_type);
1878: PO_LOG.proc_begin(d_module, 'p_online_report_id', p_online_report_id);
1879: END IF;
1880:
1881: d_position := 10;
1882: x_return_status := 'E';
1881: d_position := 10;
1882: x_return_status := 'E';
1883: l_user_id := NVL(p_user_id,0);
1884:
1885: IF (PO_LOG.d_stmt) THEN
1886: PO_LOG.stmt(d_module,d_position,'l_user_id',l_user_id);
1887: END IF;
1888:
1889: d_position := 20;
1882: x_return_status := 'E';
1883: l_user_id := NVL(p_user_id,0);
1884:
1885: IF (PO_LOG.d_stmt) THEN
1886: PO_LOG.stmt(d_module,d_position,'l_user_id',l_user_id);
1887: END IF;
1888:
1889: d_position := 20;
1890: IF (p_message_text IS NULL) THEN
1929: );
1930:
1931: p_sequence_num := p_sequence_num + 1;
1932:
1933: IF (PO_LOG.d_proc) THEN
1934: PO_LOG.proc_end(d_module);
1935: END IF;
1936:
1937: COMMIT;
1930:
1931: p_sequence_num := p_sequence_num + 1;
1932:
1933: IF (PO_LOG.d_proc) THEN
1934: PO_LOG.proc_end(d_module);
1935: END IF;
1936:
1937: COMMIT;
1938: EXCEPTION
2034:
2035: BEGIN
2036: l_key := PO_CORE_S.get_session_gt_nextval;
2037:
2038: IF (PO_LOG.d_proc) THEN
2039: PO_LOG.proc_end(d_module);
2040: END IF;
2041:
2042: -- INSERT INTO PO_SESSION GT values for all the records you got from
2035: BEGIN
2036: l_key := PO_CORE_S.get_session_gt_nextval;
2037:
2038: IF (PO_LOG.d_proc) THEN
2039: PO_LOG.proc_end(d_module);
2040: END IF;
2041:
2042: -- INSERT INTO PO_SESSION GT values for all the records you got from
2043: -- UI.
2087: )
2088: SELECT l_key,dist_num,acc_nbr,loa_val,gen_val,change_stat,acr FROM test_tab;
2089: l_count := SQL%rowcount;
2090: d_position := 10;
2091: IF (PO_LOG.d_stmt) THEN
2092: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2093: END IF;
2094:
2095:
2088: SELECT l_key,dist_num,acc_nbr,loa_val,gen_val,change_stat,acr FROM test_tab;
2089: l_count := SQL%rowcount;
2090: d_position := 10;
2091: IF (PO_LOG.d_stmt) THEN
2092: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2093: END IF;
2094:
2095:
2096: -- INSERT INTO PO_SESSION_GT all the values available from po_distributions_merge_v
2114: WHERE po_header_id = p_header_id;
2115:
2116: l_count := SQL%rowcount;
2117: d_position := 20;
2118: IF (PO_LOG.d_stmt) THEN
2119: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2120: END IF;
2121:
2122: -- SELECT DISTINCT DISTRIBUTIONS FROM THE LOT TO CALL
2115:
2116: l_count := SQL%rowcount;
2117: d_position := 20;
2118: IF (PO_LOG.d_stmt) THEN
2119: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2120: END IF;
2121:
2122: -- SELECT DISTINCT DISTRIBUTIONS FROM THE LOT TO CALL
2123: -- THIS IS TO MAKE SURE THAT WE WILL CONSIDER ALL DISTRIBUTIONS FOR THAT DOCUMENT.
2139: -- Calling build acrn values.
2140:
2141: l_count := SQL%rowcount;
2142: d_position := 30;
2143: IF (PO_LOG.d_stmt) THEN
2144: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2145: END IF;
2146:
2147:
2140:
2141: l_count := SQL%rowcount;
2142: d_position := 30;
2143: IF (PO_LOG.d_stmt) THEN
2144: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2145: END IF;
2146:
2147:
2148: PO_ACCOUNT_HELPER.BUILD_ACRN(p_header_id=>p_header_id,
2195: -- Retrieving the acrn values for the records passed by ui in the same order
2196: -- It has to be in the same order as the distribution ids table , so using loop.
2197: l_count := SQL%rowcount;
2198: d_position := 30;
2199: IF (PO_LOG.d_stmt) THEN
2200: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2201: END IF;
2202:
2203:
2196: -- It has to be in the same order as the distribution ids table , so using loop.
2197: l_count := SQL%rowcount;
2198: d_position := 30;
2199: IF (PO_LOG.d_stmt) THEN
2200: PO_LOG.stmt(d_module,d_position,'No Of records ',l_count);
2201: END IF;
2202:
2203:
2204: for i in 1 .. P_DIST_ID_TBL.count LOOP
2220:
2221:
2222: delete from po_session_gt where key = l_key;
2223:
2224: IF (PO_LOG.d_proc) THEN
2225: PO_LOG.proc_end(d_module);
2226: END IF;
2227:
2228: EXCEPTION
2221:
2222: delete from po_session_gt where key = l_key;
2223:
2224: IF (PO_LOG.d_proc) THEN
2225: PO_LOG.proc_end(d_module);
2226: END IF;
2227:
2228: EXCEPTION
2229: WHEN OTHERS THEN
2226: END IF;
2227:
2228: EXCEPTION
2229: WHEN OTHERS THEN
2230: IF ( po_log.d_exc ) THEN
2231: po_log.Exc(d_module, d_position, SQLCODE ||SQLERRM);
2232: END IF;
2233: RAISE;
2234: END BUILD_ACRN_WRAP;
2227:
2228: EXCEPTION
2229: WHEN OTHERS THEN
2230: IF ( po_log.d_exc ) THEN
2231: po_log.Exc(d_module, d_position, SQLCODE ||SQLERRM);
2232: END IF;
2233: RAISE;
2234: END BUILD_ACRN_WRAP;
2235: --Bug 16518955