230: END IF;
231:
232: -- Debug Message
233:
234: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Private API: ' || l_api_name || 'start at: '||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
235:
236: -- Initialize API return status to sucess
237: l_return_status := FND_API.G_RET_STS_SUCCESS;
238:
271: FND_MSG_PUB.add;
272: RAISE FND_API.G_EXC_ERROR;
273: END IF;
274:
275: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After mandatory checks:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
276:
277: l_bg_process_mode := nvl(fnd_profile.value('DPP_ACCT_GEN_USE_WORKFLOW'),'N');
278:
279: --Get the user name for the last updated by user
283: FROM fnd_user
284: WHERE user_id = l_txn_hdr_rec.last_updated_by;
285: EXCEPTION
286: WHEN NO_DATA_FOUND THEN
287: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Invalid User');
288: RAISE FND_API.G_EXC_ERROR;
289: WHEN OTHERS THEN
290: fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
291: fnd_message.set_token('ROUTINE', 'DPP_ITEMCOST_PVT');
644: FND_MESSAGE.set_name('DPP', 'DPP_INVALID_RESP');
645: FND_MESSAGE.set_token('USER', l_user_name);
646: FND_MSG_PUB.add;
647:
648: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Price Protection responsibility not available for Last updated user'||l_user_name);
649:
650: RAISE FND_API.G_EXC_ERROR;
651: END IF;
652:
659: FROM cst_cost_types
660: WHERE cost_type_id = 8;
661: EXCEPTION
662: WHEN NO_DATA_FOUND THEN
663: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'The cost type DPPCost is not setup.');
664: RAISE FND_API.G_EXC_ERROR;
665: END;
666:
667: SELECT dpp_cst_group_id_seq.nextval
685: AND hr.organization_id = l_txn_hdr_rec.org_id;
686:
687: l_debug_flag := fnd_profile.value('ACCOUNT_GENERATOR:DEBUG_MODE');
688:
689: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Debug Flag: ' || l_debug_flag );
690:
691: END IF;
692:
693: -- Standard begin of API savepoint
694: SAVEPOINT Update_ItemCost_PVT;
695:
696: IF l_item_cost_tbl.COUNT > 0 THEN
697:
698: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before For Loop:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
699:
700: FOR i IN l_item_cost_tbl.FIRST..l_item_cost_tbl.LAST LOOP
701: l_status_Update_tbl(i).transaction_line_id := l_item_cost_tbl(i).transaction_line_id;
702: l_status_Update_tbl(i).update_status := 'Y';
775: --If Prior cost is Zero or not defined then raise an Exception
776: IF l_prior_cost = 0 THEN
777: --ADD Messages
778: l_item_cost_tbl(i).Reason_for_failure := 'Costing setup is not done or the cost is Zero for the item:'||l_item_cost_tbl(i).item_number ;
779: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Costing setup is not done or the cost is Zero for the item:'||l_item_cost_tbl(i).item_number);
780: l_return_status := FND_API.G_RET_STS_ERROR;
781:
782: UPDATE DPP_OUTPUT_XML_GT
783: SET reason_for_failure = l_item_cost_tbl(i).Reason_for_failure
841: END IF; --NVL(l_incorrect_price_exists,0) = 0
842:
843: IF NVL(l_incorrect_price_exists,0) = 1 THEN
844: l_item_cost_tbl(i).Reason_for_failure := 'This inventory organizations has an incorrect cost for item:'||l_item_cost_tbl(i).item_number;
845: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'This inventory organizations has an incorrect cost for item:'||l_item_cost_tbl(i).item_number);
846: l_return_status := FND_API.G_RET_STS_ERROR;
847:
848: UPDATE DPP_OUTPUT_XML_GT
849: SET reason_for_failure = l_item_cost_tbl(i).Reason_for_failure
896: itemkey => l_itemkey,
897: aname => 'ORGANIZATION_ID',
898: avalue => Item_rec.organization_id);
899:
900: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'submitting the fnd_flex_workflow_generate process');
901:
902: l_result := Fnd_Flex_Workflow.GENERATE('OZFACCTG',
903: l_itemkey,
904: TRUE,
1013: l_To_Amount);
1014:
1015: l_status_Update_tbl(i).update_status := 'Y';
1016:
1017: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Success OZFACCTG WF'||'-'||x_return_ccid);
1018:
1019: END IF; -- end if for primary_cost_method
1020: ELSE
1021:
1018:
1019: END IF; -- end if for primary_cost_method
1020: ELSE
1021:
1022: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'OZFACCTG WF - Failure');
1023:
1024: l_return_status := FND_API.G_RET_STS_ERROR;
1025: l_status_Update_tbl(i).update_status := 'N';
1026: l_item_cost_tbl(i).Reason_for_failure := 'OZFACCTG Workflow - Failure for item:'||l_item_cost_tbl(i).item_number||' Error Message: '||SUBSTR(l_errmsg,1,254);
1145: l_item_cost_tbl(i).inv_org_details_tbl := l_inv_org_details_tbl;
1146: END LOOP;
1147: END IF;
1148:
1149: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After For Loop:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1150:
1151: --Calling the "Cost Import Process" Concurrent Program
1152: BEGIN
1153: l_cost_import_req_id := FND_REQUEST.submit_request(
1165: argument7 => 1); --Delete successful rows
1166:
1167: COMMIT;
1168:
1169: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Cost Import Request ID: '||l_cost_import_req_id);
1170:
1171: l_wait_req := fnd_concurrent.wait_for_request(
1172: request_id => l_cost_import_req_id,
1173: interval => 60,
1178: dev_status => l_dev_status,
1179: message => l_message);
1180: END;
1181:
1182: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Import Request:' || to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1183: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'l_phase: ' || l_dev_phase || '; l_status: ' || l_dev_status);
1184:
1185: IF l_dev_status NOT IN ('WARNING','ERROR') THEN
1186:
1179: message => l_message);
1180: END;
1181:
1182: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Import Request:' || to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1183: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'l_phase: ' || l_dev_phase || '; l_status: ' || l_dev_status);
1184:
1185: IF l_dev_status NOT IN ('WARNING','ERROR') THEN
1186:
1187: FOR Organization_Rec IN Organization_Cur(l_cost_type_id,l_cost_import_req_id)
1219: argument23 => 1,
1220: argument24 => 2);
1221: COMMIT;
1222:
1223: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Std Cost Update Request ID: '||l_cost_upd_req_id);
1224:
1225: l_wait_req := fnd_concurrent.wait_for_request(
1226: request_id => l_cost_upd_req_id,
1227: interval => 60,
1231: dev_phase => l_dev_phase,
1232: dev_status => l_dev_status,
1233: message => l_message);
1234:
1235: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'l_phase: '||l_dev_phase|| '; l_status: '||l_dev_status);
1236:
1237: END;
1238:
1239: IF l_dev_status IN ('WARNING','ERROR') THEN
1250: END IF;
1251:
1252: END LOOP;
1253:
1254: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Std Cost Update request:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1255:
1256: ELSE
1257: l_return_status := FND_API.g_ret_sts_error;
1258: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Item Cost Import Request ID: '||l_cost_import_req_id||' '|| l_dev_phase||' with '||l_dev_status);
1254: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Std Cost Update request:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1255:
1256: ELSE
1257: l_return_status := FND_API.g_ret_sts_error;
1258: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Item Cost Import Request ID: '||l_cost_import_req_id||' '|| l_dev_phase||' with '||l_dev_status);
1259:
1260: UPDATE DPP_OUTPUT_XML_GT
1261: SET reason_for_failure = 'Item Cost Import Request ID: '||l_cost_import_req_id||' '|| l_dev_phase||' with '||l_dev_status;
1262:
1267: END LOOP;
1268:
1269: END IF;
1270:
1271: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Starting Error Processing: ' || l_return_status);
1272:
1273: -- Standard begin of API savepoint
1274: SAVEPOINT Update_ItemCost_PVT;
1275:
1272:
1273: -- Standard begin of API savepoint
1274: SAVEPOINT Update_ItemCost_PVT;
1275:
1276: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before Std Cost Error Processing:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1277:
1278: -- Begin Error Processing for Std Cost Update
1279: SELECT Inventory_Item_Id,
1280: Error_Explanation
1294: IF inventory_item_ids.COUNT > 0 THEN
1295: l_return_status := FND_API.g_ret_sts_error;
1296: END IF;
1297:
1298: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Std Cost Error Processing:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1299:
1300: -- End Error Processing for Std Cost Update
1301:
1302: -- Begin Error Processing for Avg Cost Update
1316: max_wait => 0,
1317: message => l_msg_data);
1318:
1319: ELSE
1320: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before Avg Cost Error Processing:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1321:
1322: SELECT Source_Line_Id,
1323: Nvl(Error_Explanation,Error_Code) Error_Explanation
1324: BULK COLLECT INTO Source_Line_Ids,
1340:
1341: END IF;
1342: -- End Error Processing for Avg Cost Update
1343:
1344: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Avg Cost Error Processing:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1345: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA tables: ' || l_return_status);
1346:
1347: l_sysdate := sysdate;
1348:
1341: END IF;
1342: -- End Error Processing for Avg Cost Update
1343:
1344: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Avg Cost Error Processing:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1345: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA tables: ' || l_return_status);
1346:
1347: l_sysdate := sysdate;
1348:
1349:
1369: ,l_sysdate
1370: ,l_txn_hdr_rec.last_updated_by
1371: ,FND_GLOBAL.login_id);
1372:
1373: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After SLA Hdr Insert:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1374: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA Lines table for Avg Cost Update ');
1375:
1376: -- Begin SLA Line Processing for Avg Cost Update
1377: BEGIN
1370: ,l_txn_hdr_rec.last_updated_by
1371: ,FND_GLOBAL.login_id);
1372:
1373: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After SLA Hdr Insert:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1374: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA Lines table for Avg Cost Update ');
1375:
1376: -- Begin SLA Line Processing for Avg Cost Update
1377: BEGIN
1378: SELECT
1416: ,l_sysdate
1417: ,l_txn_hdr_rec.last_updated_by);
1418: EXCEPTION
1419: WHEN NO_DATA_FOUND THEN
1420: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'No Data Found for SLA lines table insertion - Avg Costing...');
1421: END;
1422: -- End SLA Line Processing for Avg Cost Update
1423:
1424: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA Lines table for Std Cost Update: ');
1420: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'No Data Found for SLA lines table insertion - Avg Costing...');
1421: END;
1422: -- End SLA Line Processing for Avg Cost Update
1423:
1424: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA Lines table for Std Cost Update: ');
1425: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before SLA Line Insert - Std:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1426:
1427: -- Begin SLA Line Processing for Std Cost Update
1428: BEGIN
1421: END;
1422: -- End SLA Line Processing for Avg Cost Update
1423:
1424: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Inserting into SLA Lines table for Std Cost Update: ');
1425: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before SLA Line Insert - Std:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1426:
1427: -- Begin SLA Line Processing for Std Cost Update
1428: BEGIN
1429: SELECT
1470: ,l_txn_hdr_rec.last_updated_by);
1471:
1472: EXCEPTION
1473: WHEN NO_DATA_FOUND THEN
1474: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'No Data Found for SLA table insertion...');
1475: END;
1476: -- End SLA Line Processing for Std Cost Update
1477:
1478: EXCEPTION
1484: fnd_message.set_token('ERRNO', sqlcode);
1485: fnd_message.set_token('REASON', sqlerrm);
1486: FND_MSG_PUB.add;
1487: -- END IF;
1488: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Error in SLA Tables Insertion:' || sqlerrm);
1489: END;
1490: END IF;
1491:
1492: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before Exe Dtls Update:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1488: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Error in SLA Tables Insertion:' || sqlerrm);
1489: END;
1490: END IF;
1491:
1492: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Before Exe Dtls Update:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1493:
1494: << INCORRECT_PRICE >>
1495:
1496: << WORKFLOW_ERROR >>
1501: INTO l_execution_status
1502: FROM DUAL;
1503:
1504: BEGIN
1505: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Status before generating output xml: ' || l_return_status);
1506:
1507: --Get the output XML from DPP_OUTPUT_XML_GT table
1508: l_Transaction_Number := '''' || l_txn_hdr_rec.Transaction_Number || '''';
1509:
1533: fnd_message.set_token('REASON', sqlerrm);
1534: FND_MSG_PUB.add;
1535: END;
1536:
1537: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Status before calling update API: ' || l_return_status);
1538:
1539: l_exe_update_rec.Transaction_Header_ID := l_txn_hdr_rec.Transaction_Header_ID;
1540: l_exe_update_rec.Org_ID := l_txn_hdr_rec.Org_ID;
1541: l_exe_update_rec.Execution_Detail_ID := l_txn_hdr_rec.Execution_Detail_ID;
1557: ,p_EXE_UPDATE_rec => l_exe_update_rec
1558: ,p_status_Update_tbl=> l_status_Update_tbl
1559: );
1560:
1561: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'After Exe Dtls Update:'||to_char(sysdate,'dd-mon-yyyy hh24:mi:ss'));
1562:
1563: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1564: x_return_status := l_return_status;
1565: END IF;
1571: END IF;
1572:
1573: -- Debug Message
1574:
1575: dpp_utility_pvt.debug_message(FND_LOG.LEVEL_STATEMENT, l_module, 'Private API: ' || l_api_name || 'end');
1576:
1577: -- Standard call to get message count and if count is 1, get message info.
1578: FND_MSG_PUB.Count_And_Get
1579: (p_count => x_msg_count,