997: -- 10/25/1999 ptendulk Created
998: -- 08/28/2000 SVEERAVE Modified to convert/default metric values with
999: -- currencies and with out currencies in case of manual
1000: -- or non-manual type metrics. Replaced API call for
1001: -- currency conversions with centralized AMS_UTILITY_PVT
1002: -- api.
1003: -- 10/11/2000 SVEERAVE Defaulted trans_currency_code to be that of parent
1004: -- object's
1005: -- End of comments
1647: --
1648: --SAVEPOINT Create_ActMetric2_pvt;
1649:
1650: IF (AMS_DEBUG_HIGH_ON) THEN
1651: Ams_Utility_Pvt.Debug_Message(l_full_name||': start');
1652: END IF;
1653:
1654: --
1655: -- Initialize message list if p_init_msg_list is set to TRUE.
1694: AND UPPER(l_met_info.metric_calculation_type) IN ('MANUAL', 'FUNCTION') THEN
1695: -- choang - 26-dec-2002 - ignore the metric when create activity metric
1696: -- requested.
1697: IF (AMS_DEBUG_HIGH_ON) THEN
1698: Ams_Utility_Pvt.Debug_Message(l_full_name||': ignore metric id: ' || p_act_metric_rec.metric_id);
1699: END IF;
1700:
1701: RETURN;
1702: -- l_return_status := Fnd_Api.G_RET_STS_ERROR;
1817: --
1818: -- Debug message.
1819: --
1820: IF (AMS_DEBUG_HIGH_ON) THEN
1821: Ams_Utility_Pvt.debug_message(l_full_name ||': insert');
1822: END IF;
1823:
1824: IF l_act_metrics_rec.activity_metric_id IS NULL THEN
1825: LOOP
2013: AND l_accrual_type = G_VARIABLE
2014: AND l_compute_using_function IS NOT NULL THEN
2015:
2016: IF (AMS_DEBUG_HIGH_ON) THEN
2017: Ams_Utility_Pvt.Debug_Message(l_full_name||': Variable Metric id='||
2018: l_act_metrics_rec.metric_id);
2019: Ams_Utility_Pvt.Debug_Message(l_full_name||': compute_using_function='||
2020: l_compute_using_function||'.');
2021: END IF;
2015:
2016: IF (AMS_DEBUG_HIGH_ON) THEN
2017: Ams_Utility_Pvt.Debug_Message(l_full_name||': Variable Metric id='||
2018: l_act_metrics_rec.metric_id);
2019: Ams_Utility_Pvt.Debug_Message(l_full_name||': compute_using_function='||
2020: l_compute_using_function||'.');
2021: END IF;
2022:
2023: -- Check for a multiplier metric.
2114: --
2115: -- Add success message to message list.
2116: --
2117: IF (AMS_DEBUG_HIGH_ON) THEN
2118: Ams_Utility_Pvt.debug_message(l_full_name ||': end Success');
2119: END IF;
2120:
2121: /*
2122: EXCEPTION
2220:
2221:
2222: IF (AMS_DEBUG_HIGH_ON) THEN
2223:
2224: Ams_Utility_Pvt.debug_message('Now updating act met id: '||p_act_metric_rec.activity_metric_id);
2225:
2226: END IF;
2227: --
2228: -- Initialize savepoint.
2231: --
2232: -- Output debug message.
2233: --
2234: IF (AMS_DEBUG_HIGH_ON) THEN
2235: Ams_Utility_Pvt.debug_message(l_full_name||': start');
2236: END IF;
2237: --
2238: -- Initialize message list if p_init_msg_list is set to TRUE.
2239: --
2262: --
2263: -- Debug Message
2264:
2265: IF (AMS_DEBUG_HIGH_ON) THEN
2266: Ams_Utility_Pvt.debug_message(l_full_name ||': validate');
2267: END IF;
2268:
2269: -- BUG4391308: Added locking to prevent overwriting.
2270: Lock_ActMetric ( 1.0, fnd_api.G_FALSE,
2283: Complete_ActMetric_Rec(p_act_metric_rec, l_actmet_rec);
2284:
2285:
2286: IF (AMS_DEBUG_HIGH_ON) THEN
2287: Ams_Utility_Pvt.debug_message(l_full_name ||': select calc type, metric_id ='||l_actmet_rec.metric_id);
2288: END IF;
2289:
2290: SELECT metric_calculation_type
2291: INTO l_calc_type
2383: -- Fnd_Msg_Pub.Initialize;
2384: Fnd_Message.set_name('AMS', 'AMS_MET_NO_POST');
2385: Fnd_Msg_Pub.ADD;
2386: --IF (AMS_DEBUG_HIGH_ON) THEN
2387: -- Ams_Utility_Pvt.debug_message('You can not post this cost!');
2388: --END IF;
2389: END IF;
2390: IF l_return_status = Fnd_Api.g_ret_sts_unexp_error THEN
2391: RAISE Fnd_Api.g_exc_unexpected_error;
2394: END IF;
2395: END IF;
2396:
2397: IF (AMS_DEBUG_HIGH_ON) THEN
2398: Ams_Utility_Pvt.debug_message(l_full_name ||': update Activity Metrics Table');
2399: END IF;
2400:
2401: -- Update AMS_ACT_METRICS_ALL
2402: UPDATE ams_act_metrics_all
2539: --
2540: -- Debug message.
2541: --
2542: IF (AMS_DEBUG_HIGH_ON) THEN
2543: Ams_Utility_Pvt.debug_message(l_full_name ||': end');
2544: END IF;
2545:
2546:
2547: EXCEPTION
2734: --
2735: -- Output debug message.
2736: --
2737: IF (AMS_DEBUG_HIGH_ON) THEN
2738: Ams_Utility_Pvt.debug_message(l_full_name||': start');
2739: END IF;
2740:
2741: --
2742: -- Initialize message list if p_init_msg_list is set to TRUE.
2831: IF (l_freeze_status = Fnd_Api.G_TRUE) THEN
2832: -- frozen to create the record
2833: IF Fnd_Msg_Pub.Check_Msg_Level (Fnd_Msg_Pub.G_MSG_LVL_ERROR) THEN
2834: -- sunkumar 04/30/2003 added message for delete status of objects depending on status (ACTIVE, CANCELLED, COMPLETED)
2835: l_object_name := ams_utility_pvt.get_lookup_meaning(
2836: 'AMS_SYS_ARC_QUALIFIER',l_act_metric_rec.arc_act_metric_used_by);
2837: Fnd_Message.Set_Name('AMS', 'AMS_METR_DELETE');
2838: Fnd_Message.set_token('OBJECT', l_object_name);
2839: Fnd_Msg_Pub.ADD;
2876: END IF;
2877:
2878: -- Debug message.
2879: IF (AMS_DEBUG_HIGH_ON) THEN
2880: Ams_Utility_Pvt.debug_message(l_full_name ||': delete with Validation');
2881: END IF;
2882:
2883: -- huili added on 05/07/2001 to check dependent activity metrics
2884: l_depend_act_met_id := NULL;
2943: --
2944: -- Debug message.
2945: --
2946: IF (AMS_DEBUG_HIGH_ON) THEN
2947: Ams_Utility_Pvt.debug_message(l_full_name ||': End');
2948: END IF;
2949:
2950: --
2951: -- Standard API to get message count, and if 1,
3060: --
3061: -- Output debug message.
3062: --
3063: IF (AMS_DEBUG_HIGH_ON) THEN
3064: Ams_Utility_Pvt.debug_message(l_full_name||': start');
3065: END IF;
3066:
3067: --
3068: -- Initialize message list if p_init_msg_list is set to TRUE.
3193: --
3194: -- Debug message.
3195: --
3196: IF (AMS_DEBUG_HIGH_ON) THEN
3197: Ams_Utility_Pvt.debug_message(l_full_name ||': End');
3198: END IF;
3199:
3200: --
3201: -- Standard API to get message count, and if 1,
3288: --
3289: -- Output debug message.
3290: --
3291: IF (AMS_DEBUG_HIGH_ON) THEN
3292: Ams_Utility_Pvt.debug_message(l_full_name||': start');
3293: END IF;
3294:
3295: --
3296: -- Initialize message list if p_init_msg_list is set to TRUE.
3318: --
3319: -- Begin API Body
3320: --
3321: IF (AMS_DEBUG_HIGH_ON) THEN
3322: Ams_Utility_Pvt.debug_message(l_full_name||': lock');
3323: END IF;
3324:
3325:
3326: OPEN c_act_metrics_info;
3362: --
3363: -- Debug message.
3364: --
3365: IF (AMS_DEBUG_HIGH_ON) THEN
3366: Ams_Utility_Pvt.debug_message(l_full_name ||': end');
3367: END IF;
3368:
3369:
3370: EXCEPTION
3381: p_count => x_msg_count,
3382: p_data => x_msg_data,
3383: p_encoded => FND_API.G_FALSE
3384: );
3385: WHEN Ams_Utility_Pvt.RESOURCE_LOCKED THEN
3386: x_return_status := Fnd_Api.G_RET_STS_ERROR ;
3387:
3388: IF Fnd_Msg_Pub.check_msg_level(Fnd_Msg_Pub.g_msg_lvl_error) THEN
3389: Fnd_Message.set_name('AMS', 'AMS_API_RESOURCE_LOCKED');
3445: --
3446: -- Output debug message.
3447: --
3448: IF (AMS_DEBUG_HIGH_ON) THEN
3449: Ams_Utility_Pvt.debug_message(l_full_name||': start');
3450: END IF;
3451:
3452: --
3453: -- Initialize message list if p_init_msg_list is set to TRUE.
3476: -- Begin API Body.
3477: --
3478:
3479: IF (AMS_DEBUG_HIGH_ON) THEN
3480: Ams_Utility_Pvt.debug_message(l_full_name||': Validate items');
3481: END IF;
3482:
3483: -- Validate required items in the record.
3484: IF p_validation_level >= Jtf_Plsql_Api.g_valid_level_item THEN
3497: END IF;
3498: END IF;
3499:
3500: IF (AMS_DEBUG_HIGH_ON) THEN
3501: Ams_Utility_Pvt.debug_message(l_full_name||': check record');
3502: END IF;
3503:
3504: IF p_validation_level >= Jtf_Plsql_Api.g_valid_level_record THEN
3505: Validate_ActMetric_record(
3529: p_encoded => Fnd_Api.G_FALSE
3530: );
3531:
3532: IF (AMS_DEBUG_HIGH_ON) THEN
3533: Ams_Utility_Pvt.debug_message(l_full_name ||': end');
3534: END IF;
3535:
3536: EXCEPTION
3537: WHEN Fnd_Api.G_EXC_ERROR THEN
3757: AND p_act_metric_rec.activity_metric_id IS NOT NULL
3758: THEN
3759: l_where_clause := ' activity_metric_id = '||p_act_metric_rec.activity_metric_id ;
3760:
3761: IF Ams_Utility_Pvt.Check_Uniqueness(
3762: p_table_name => 'ams_act_metrics_all',
3763: p_where_clause => l_where_clause
3764: ) = Fnd_Api.g_false
3765: THEN
3930: /*
3931: l_table_name := 'FND_CURRENCIES';
3932: l_pk_name := 'CURRENCY_CODE';
3933: l_pk_value := l_act_metrics_rec.transaction_currency_code;
3934: l_pk_data_type := Ams_Utility_Pvt.G_VARCHAR2;
3935: l_additional_where_clause := ' enabled_flag = ''Y''';
3936: IF Ams_Utility_Pvt.Check_FK_Exists (
3937: p_table_name => l_table_name
3938: ,p_pk_name => l_pk_name
3932: l_pk_name := 'CURRENCY_CODE';
3933: l_pk_value := l_act_metrics_rec.transaction_currency_code;
3934: l_pk_data_type := Ams_Utility_Pvt.G_VARCHAR2;
3935: l_additional_where_clause := ' enabled_flag = ''Y''';
3936: IF Ams_Utility_Pvt.Check_FK_Exists (
3937: p_table_name => l_table_name
3938: ,p_pk_name => l_pk_name
3939: ,p_pk_value => l_pk_value
3940: ,p_pk_data_type => l_pk_data_type
3955:
3956: /*l_table_name := 'FND_CURRENCIES';
3957: l_pk_name := 'CURRENCY_CODE';
3958: l_pk_value := l_act_metrics_rec.functional_currency_code;
3959: l_pk_data_type := Ams_Utility_Pvt.G_VARCHAR2;
3960: l_additional_where_clause := ' enabled_flag = ''Y''';
3961:
3962: IF Ams_Utility_Pvt.Check_FK_Exists (
3963: p_table_name => l_table_name
3958: l_pk_value := l_act_metrics_rec.functional_currency_code;
3959: l_pk_data_type := Ams_Utility_Pvt.G_VARCHAR2;
3960: l_additional_where_clause := ' enabled_flag = ''Y''';
3961:
3962: IF Ams_Utility_Pvt.Check_FK_Exists (
3963: p_table_name => l_table_name
3964: ,p_pk_name => l_pk_name
3965: ,p_pk_value => l_pk_value
3966: ,p_pk_data_type => l_pk_data_type
3988: --
3989:
3990: -- SENSITIVE_DATA_FLAG
3991: IF l_act_metrics_rec.sensitive_data_flag <> Fnd_Api.G_MISS_CHAR THEN
3992: IF Ams_Utility_Pvt.Is_Y_Or_N (l_act_metrics_rec.sensitive_data_flag)
3993: = Fnd_Api.G_FALSE
3994: THEN
3995: IF Fnd_Msg_Pub.Check_Msg_Level (Fnd_Msg_Pub.G_MSG_LVL_ERROR)
3996: THEN
4185: -- choang - 11-may-2005 - validate edit metric access
4186: IF AMS_Access_PVT.check_update_access (
4187: p_object_id => l_act_metrics_rec.act_metric_used_by_id,
4188: p_object_type => l_act_metrics_rec.arc_act_metric_used_by,
4189: p_user_or_role_id => AMS_Utility_PVT.get_resource_id (FND_GLOBAL.user_id),
4190: p_user_or_role_type => 'USER') <> 'F' THEN
4191: x_return_status := Fnd_Api.G_RET_STS_ERROR;
4192: FND_MESSAGE.set_name ('AMS', 'AMS_NO_METRIC_UPDATE_ACCESS');
4193: FND_MESSAGE.set_token('OBJECT',
4190: p_user_or_role_type => 'USER') <> 'F' THEN
4191: x_return_status := Fnd_Api.G_RET_STS_ERROR;
4192: FND_MESSAGE.set_name ('AMS', 'AMS_NO_METRIC_UPDATE_ACCESS');
4193: FND_MESSAGE.set_token('OBJECT',
4194: AMS_Utility_PVT.get_object_name(l_act_metrics_rec.arc_act_metric_used_by,
4195: l_act_metrics_rec.act_metric_used_by_id)
4196: );
4197: FND_MSG_PUB.add;
4198: -- exit the program immediately after this
4224: -- to set trans_forecasted_value back to
4225: -- its original value
4226:
4227: IF Fnd_Msg_Pub.check_msg_level(Fnd_Msg_Pub.g_msg_lvl_error) THEN
4228: l_object_name := ams_utility_pvt.get_lookup_meaning(
4229: 'AMS_SYS_ARC_QUALIFIER',
4230: l_act_metrics_rec.arc_act_metric_used_by);
4231: Fnd_Message.set_name('AMS', 'AMS_UPDATE_FORECAST');
4232: Fnd_Message.set_token('OBJECT', l_object_name);
4342: ,p_object_id => l_act_metrics_rec.act_metric_used_by_id
4343: ) = Fnd_Api.G_FALSE
4344: THEN
4345: IF Fnd_Msg_Pub.Check_Msg_Level (Fnd_Msg_Pub.G_MSG_LVL_ERROR) THEN
4346: l_object_name := ams_utility_pvt.get_lookup_meaning(
4347: 'AMS_SYS_ARC_QUALIFIER',l_act_metrics_rec.arc_act_metric_used_by);
4348: Fnd_Message.Set_Name ('AMS', 'AMS_METR_INVALID_OBJECT');
4349: Fnd_Message.Set_Token('OBJTYPE',l_object_name);
4350: Fnd_Message.Set_Token('OBJID',l_pk_value);
4854: --
4855: -- Output debug message.
4856: --
4857: IF (AMS_DEBUG_HIGH_ON) THEN
4858: Ams_Utility_Pvt.debug_message(l_full_name||': start');
4859: END IF;
4860:
4861: --
4862: -- Initialize message list if p_init_msg_list is set to TRUE.
4888: --
4889: -- Output debug message.
4890: --
4891: IF (AMS_DEBUG_HIGH_ON) THEN
4892: Ams_Utility_Pvt.debug_message(l_full_name||': Update');
4893: END IF;
4894:
4895: UPDATE ams_act_metrics_all
4896: SET func_committed_value = p_func_committed_value
4929: --
4930: -- Output debug message.
4931: --
4932: IF (AMS_DEBUG_HIGH_ON) THEN
4933: Ams_Utility_Pvt.debug_message(l_full_name||': End');
4934: END IF;
4935:
4936:
4937: EXCEPTION
5320: l_used_by_type VARCHAR2(100) := p_used_by_type;
5321: BEGIN
5322: IF (AMS_DEBUG_HIGH_ON) THEN
5323:
5324: Ams_Utility_Pvt.debug_message('Invalidating object: '||p_used_by_type||
5325: ', '||p_used_by_id);
5326: END IF;
5327:
5328: --
5333: -- Output debug message.
5334: --
5335: IF (AMS_DEBUG_HIGH_ON) THEN
5336:
5337: Ams_Utility_Pvt.debug_message(l_full_name||': START');
5338: END IF;
5339:
5340: --
5341: -- Initialize message list if p_init_msg_list is set to TRUE.
5393: -- Debug message.
5394: --
5395: IF (AMS_DEBUG_HIGH_ON) THEN
5396:
5397: Ams_Utility_Pvt.debug_message(l_full_name ||': END');
5398: END IF;
5399:
5400: EXCEPTION
5401: WHEN Fnd_Api.G_EXC_ERROR THEN
5481: l_func_currency VARCHAR2(30);
5482:
5483: BEGIN
5484: IF (AMS_DEBUG_HIGH_ON) THEN
5485: Ams_Utility_Pvt.debug_message('Now posting costs FOR object: '||p_obj_type||':'||p_obj_id);
5486: END IF;
5487:
5488: --
5489: -- Initialize savepoint.
5492: --
5493: -- Output debug message.
5494: --
5495: IF (AMS_DEBUG_HIGH_ON) THEN
5496: Ams_Utility_Pvt.debug_message(l_full_name||': START');
5497: END IF;
5498:
5499: --
5500: -- Initialize message list if p_init_msg_list is set to TRUE.
5571: --
5572: -- Debug message.
5573: --
5574: IF (AMS_DEBUG_HIGH_ON) THEN
5575: Ams_Utility_Pvt.debug_message(l_full_name ||': END');
5576: END IF;
5577:
5578:
5579: EXCEPTION
6684: --
6685: -- Output debug message.
6686: --
6687: IF (AMS_DEBUG_HIGH_ON) THEN
6688: Ams_Utility_Pvt.debug_message(l_full_name||': START');
6689: Ams_Utility_Pvt.debug_message('Generating results FOR object: '||
6690: p_object_type||':'||p_object_id||', metric id'||p_metric_id);
6691: Ams_Utility_Pvt.debug_message('FROM/TO/interval/unit: '||
6692: p_from_date||'/'||p_to_date||'/'||p_increment||'/'||p_interval_unit);
6685: -- Output debug message.
6686: --
6687: IF (AMS_DEBUG_HIGH_ON) THEN
6688: Ams_Utility_Pvt.debug_message(l_full_name||': START');
6689: Ams_Utility_Pvt.debug_message('Generating results FOR object: '||
6690: p_object_type||':'||p_object_id||', metric id'||p_metric_id);
6691: Ams_Utility_Pvt.debug_message('FROM/TO/interval/unit: '||
6692: p_from_date||'/'||p_to_date||'/'||p_increment||'/'||p_interval_unit);
6693: END IF;
6687: IF (AMS_DEBUG_HIGH_ON) THEN
6688: Ams_Utility_Pvt.debug_message(l_full_name||': START');
6689: Ams_Utility_Pvt.debug_message('Generating results FOR object: '||
6690: p_object_type||':'||p_object_id||', metric id'||p_metric_id);
6691: Ams_Utility_Pvt.debug_message('FROM/TO/interval/unit: '||
6692: p_from_date||'/'||p_to_date||'/'||p_increment||'/'||p_interval_unit);
6693: END IF;
6694:
6695: --
6876:
6877: x_result_table := l_result_table;
6878:
6879: IF (AMS_DEBUG_HIGH_ON) THEN
6880: Ams_Utility_Pvt.debug_message('Generated: '||x_result_table.COUNT||' results');
6881: END IF;
6882:
6883: --
6884: -- End API Body
6897: --
6898: -- Debug message.
6899: --
6900: IF (AMS_DEBUG_HIGH_ON) THEN
6901: Ams_Utility_Pvt.debug_message(l_full_name ||': END');
6902: END IF;
6903:
6904: EXCEPTION
6905: WHEN Fnd_Api.G_EXC_ERROR THEN
7075: -- Initialize savepoint.
7076: SAVEPOINT Copy_Metric_pvt;
7077:
7078: IF (AMS_DEBUG_HIGH_ON) THEN
7079: Ams_Utility_Pvt.Debug_Message(l_full_name||': start');
7080: END IF;
7081:
7082: -- Initialize message list if p_init_msg_list is set to TRUE.
7083: IF FND_API.To_Boolean (p_init_msg_list) THEN
7201: --
7202: -- Debug message.
7203: --
7204: IF (AMS_DEBUG_HIGH_ON) THEN
7205: Ams_Utility_Pvt.debug_message(l_full_name ||': END');
7206: END IF;
7207:
7208: EXCEPTION
7209: WHEN FND_API.G_EXC_ERROR THEN
7307: BEGIN
7308:
7309: -- Output debug message.
7310: IF (AMS_DEBUG_HIGH_ON) THEN
7311: Ams_Utility_Pvt.debug_message(l_full_name||': start');
7312: END IF;
7313:
7314: -- Initialize message list if p_init_msg_list is set to TRUE.
7315: IF Fnd_Api.To_Boolean (p_init_msg_list) THEN
7329: x_return_status := Fnd_Api.G_RET_STS_SUCCESS;
7330:
7331: -- Begin API Body.
7332: IF (AMS_DEBUG_HIGH_ON) THEN
7333: Ams_Utility_Pvt.debug_message(l_full_name||': Validate items');
7334: END IF;
7335:
7336: --check source object exists
7337: IF (l_source_object_type IN ('RCAM', 'CAMP')) THEN
7365: l_valid_object := Fnd_Api.G_TRUE;
7366:
7367: END IF;
7368:
7369: l_object_name := ams_utility_pvt.get_lookup_meaning('AMS_SYS_ARC_QUALIFIER', l_source_object_type);
7370:
7371: --the object type passed is not a valid one for metrics.
7372: IF (l_valid_object = Fnd_Api.G_FALSE) THEN
7373: IF Fnd_Msg_Pub.Check_Msg_Level (Fnd_Msg_Pub.G_MSG_LVL_ERROR) THEN
7438: );
7439:
7440: -- Add success message to message list.
7441: IF (AMS_DEBUG_HIGH_ON) THEN
7442: Ams_Utility_Pvt.debug_message(l_full_name ||': end Success');
7443: END IF;
7444:
7445: x_return_status := l_return_status;
7446:
7523: ELSIF (p_arc_act_metric_used_by = 'ALIST') THEN
7524: l_table_name := 'AMS_ACT_LISTS';
7525: l_pk_name := 'ACT_LIST_HEADER_ID';
7526: ELSE
7527: AMS_Utility_PVT.error_message ('AMS_INVALID_SYS_QUAL', 'SYS_QUALIFIER', p_arc_act_metric_used_by);
7528: x_return_status := FND_API.g_ret_sts_unexp_error;
7529: l_table_name := NULL;
7530: l_pk_name := NULL;
7531: END IF;
7536: ' SET object_version_number = object_version_number '||
7537: ' WHERE ' || UPPER(l_pk_name) || ' = :b1 ';
7538:
7539: IF (AMS_DEBUG_HIGH_ON) THEN
7540: ams_utility_pvt.debug_message('SQL statement: '||l_sql);
7541: END IF;
7542:
7543: BEGIN
7544: EXECUTE IMMEDIATE l_sql