[Home] [Help]
930: ,x_dimension_rec => x_request_rec.dimension_rec
931: );
932:
933: ------------------------------------------------------------------------------
934: -- Validate the Processing Key on FEM_BALANCES to make sure that it can
935: -- handle rollup processing on the appropriate composite dimension.
936: ------------------------------------------------------------------------------
937: -- Validation added with bug 4475839
938: FEM_SETUP_PKG.Validate_Proc_Key (
943: ,x_return_status => l_return_status
944: ,x_msg_count => l_msg_count
945: ,x_msg_data => l_msg_data
946: ,p_dimension_varchar_label => l_dimension_varchar_label
947: ,p_table_name => 'FEM_BALANCES'
948: );
949:
950: if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then
951: Get_Put_Messages (
1033: raise l_request_prep_error;
1034: end;
1035:
1036: ------------------------------------------------------------------------------
1037: -- Call the Where Clause Generator for source data in FEM_BALANCES
1038: ------------------------------------------------------------------------------
1039: FEM_DS_WHERE_CLAUSE_GENERATOR.FEM_Gen_DS_WClause_PVT (
1040: p_api_version => 1.0
1041: ,p_init_msg_list => FND_API.G_FALSE
1044: ,x_msg_count => l_msg_count
1045: ,x_msg_data => l_msg_data
1046: ,p_ds_io_def_id => x_request_rec.dataset_grp_obj_def_id
1047: ,p_output_period_id => x_request_rec.output_cal_period_id
1048: ,p_table_name => 'FEM_BALANCES'
1049: ,p_table_alias => 'B'
1050: ,p_ledger_id => x_request_rec.ledger_id
1051: ,p_where_clause => x_input_ds_b_where_clause
1052: );
1067: ,p_value1 => x_request_rec.dataset_grp_obj_def_id
1068: ,p_token2 => 'OUTPUT_CAL_PERIOD_ID'
1069: ,p_value2 => x_request_rec.output_cal_period_id
1070: ,p_token3 => 'TABLE_NAME'
1071: ,p_value3 => 'FEM_BALANCES'
1072: ,p_token4 => 'LEDGER_ID'
1073: ,p_value4 => x_request_rec.ledger_id
1074: );
1075: raise l_request_prep_error;
1833:
1834: FEM_ENGINES_PKG.Tech_Message (
1835: p_severity => G_LOG_LEVEL_1
1836: ,p_module => G_BLOCK||'.'||L_API_NAME
1837: ,p_msg_text => 'Step 1: Update Activity Id in FEM_BALANCES Table'
1838: );
1839:
1840: -- A join to FEM_ACTIVITIES is
1841: -- necessary for Populate_Activity_Id to work properly as it needs all the
1838: );
1839:
1840: -- A join to FEM_ACTIVITIES is
1841: -- necessary for Populate_Activity_Id to work properly as it needs all the
1842: -- component dimension columns for the join on FEM_BALANCES.
1843:
1844: l_source_table_query_stmt :=
1845: ' select act.activity_id'||
1846: ' from fem_activities act'||
1864: ,p_source_table_query => l_source_table_query_stmt
1865: ,p_source_table_query_param1 => l_source_table_query_param1
1866: ,p_source_table_query_param2 => l_source_table_query_param2
1867: ,p_source_table_alias => 'act'
1868: ,p_target_table_name => 'FEM_BALANCES'
1869: ,p_target_table_alias => 'b'
1870: ,p_target_dsg_where_clause => p_input_ds_b_where_clause
1871: ,p_ledger_id => p_request_rec.ledger_id
1872: );
1886:
1887: FEM_ENGINES_PKG.Tech_Message (
1888: p_severity => G_LOG_LEVEL_1
1889: ,p_module => G_BLOCK||'.'||L_API_NAME
1890: ,p_msg_text => 'Step 2: Bulk Insert into FEM_BALANCES Table'
1891: );
1892:
1893:
1894: -- l_drv_vals_tbl_where_clause cannot have aliases, otherwise
1899:
1900: IF ((p_rule_rec.entered_exch_rate_den IS NOT NULL) AND (p_rule_rec.entered_exch_rate_num IS NOT NULL)) THEN
1901:
1902: l_act_rate_stmt :=
1903: ' insert into FEM_BALANCES ('||
1904: ' dataset_code'||
1905: ' ,cal_period_id'||
1906: ' ,creation_row_sequence'||
1907: ' ,source_system_code'||
1996: ' ,max(drv.statistic_basis_id) as statistic_basis_id'||
1997: ' ,b.entity_id'||
1998: ' ,b.intercompany_id'||
1999: ' ,sum(b.xtd_balance_f) / max(abs(drv.driver_value)) as act_rate_value'||
2000: ' from fem_balances b'||
2001: ' ,pft_ar_driver_values_t {{table_partition}} drv'||
2002: ' where b.ledger_id = '||p_request_rec.ledger_id||
2003: ' and b.financial_elem_id not in ('||G_FIN_ELEM_ID_STATISTIC||','||G_FIN_ELEM_ID_ACTIVITY_RATE||')'||
2004: ' and b.currency_type_code = ''ENTERED'''||
2044:
2045: ELSE
2046:
2047: l_act_rate_stmt :=
2048: ' insert into FEM_BALANCES ('||
2049: ' dataset_code'||
2050: ' ,cal_period_id'||
2051: ' ,creation_row_sequence'||
2052: ' ,source_system_code'||
2141: ' ,max(drv.statistic_basis_id) as statistic_basis_id'||
2142: ' ,b.entity_id'||
2143: ' ,b.intercompany_id'||
2144: ' ,sum(b.xtd_balance_f) / max(abs(drv.driver_value)) as act_rate_value'||
2145: ' from fem_balances b'||
2146: ' ,pft_ar_driver_values_t {{table_partition}} drv'||
2147: ' where b.ledger_id = '||p_request_rec.ledger_id||
2148: ' and b.financial_elem_id not in ('||G_FIN_ELEM_ID_STATISTIC||','||G_FIN_ELEM_ID_ACTIVITY_RATE||')'||
2149: ' and b.currency_type_code = ''ENTERED'''||
2265: );
2266: end if;
2267:
2268: ------------------------------------------------------------------------------
2269: -- STEP 3: Bulk Insert into FEM_BALANCES_CALC_FCTRS Table
2270: ------------------------------------------------------------------------------
2271:
2272: FEM_ENGINES_PKG.Tech_Message (
2273: p_severity => G_LOG_LEVEL_1
2271:
2272: FEM_ENGINES_PKG.Tech_Message (
2273: p_severity => G_LOG_LEVEL_1
2274: ,p_module => G_BLOCK||'.'||L_API_NAME
2275: ,p_msg_text => 'Step 3: Bulk Insert into FEM_BALANCES_CALC_FCTRS Table'
2276: );
2277:
2278: -- Prepare the insert statement for FEM_BALANCES_CALC_FCTRS
2279: -- ammittal 03/30/06 - Bug # 5074996 - Updating the code below to uptake changes in FEM_BALANCES_CALC_FCTRS table
2274: ,p_module => G_BLOCK||'.'||L_API_NAME
2275: ,p_msg_text => 'Step 3: Bulk Insert into FEM_BALANCES_CALC_FCTRS Table'
2276: );
2277:
2278: -- Prepare the insert statement for FEM_BALANCES_CALC_FCTRS
2279: -- ammittal 03/30/06 - Bug # 5074996 - Updating the code below to uptake changes in FEM_BALANCES_CALC_FCTRS table
2280: l_calc_fctrs_stmt :=
2281: ' insert into FEM_BALANCES_CALC_FCTRS ('||
2282: ' created_by_request_id'||
2275: ,p_msg_text => 'Step 3: Bulk Insert into FEM_BALANCES_CALC_FCTRS Table'
2276: );
2277:
2278: -- Prepare the insert statement for FEM_BALANCES_CALC_FCTRS
2279: -- ammittal 03/30/06 - Bug # 5074996 - Updating the code below to uptake changes in FEM_BALANCES_CALC_FCTRS table
2280: l_calc_fctrs_stmt :=
2281: ' insert into FEM_BALANCES_CALC_FCTRS ('||
2282: ' created_by_request_id'||
2283: ' ,created_by_object_id'||
2277:
2278: -- Prepare the insert statement for FEM_BALANCES_CALC_FCTRS
2279: -- ammittal 03/30/06 - Bug # 5074996 - Updating the code below to uptake changes in FEM_BALANCES_CALC_FCTRS table
2280: l_calc_fctrs_stmt :=
2281: ' insert into FEM_BALANCES_CALC_FCTRS ('||
2282: ' created_by_request_id'||
2283: ' ,created_by_object_id'||
2284: ' ,creation_row_sequence'||
2285: ' ,factor'||
2293: ' ,1/drv.driver_value'||
2294: ' ,''N/A'''||
2295: ' ,b.last_updated_by_object_id'||
2296: ' ,b.last_updated_by_request_id'||
2297: ' from fem_balances b'||
2298: ' ,pft_ar_driver_values_t {{table_partition}} drv'||
2299: ' where b.ledger_id = '||p_request_rec.ledger_id||
2300: ' and b.dataset_code = '||p_request_rec.output_dataset_code||
2301: ' and b.cal_period_id = '||p_request_rec.output_cal_period_id||
2616: end if;
2617:
2618: ------------------------------------------------------------------------------
2619: -- Set the Temporary Sequence Names for performing Processing in the
2620: -- FEM_BALANCES table.
2621: ------------------------------------------------------------------------------
2622: x_rule_rec.rate_sequence_name :=
2623: 'pft_ar_rate_'||
2624: to_char(p_request_rec.request_id)||
2870: );
2871: raise l_register_rule_error;
2872: end if;
2873:
2874: -- Register the data location for the FEM_BALANCES output table
2875: FEM_DIMENSION_UTIL_PKG.Register_Data_Location (
2876: p_request_id => p_request_rec.request_id
2877: ,p_object_id => p_rule_rec.act_rate_obj_id
2878: ,p_table_name => 'FEM_BALANCES'
2874: -- Register the data location for the FEM_BALANCES output table
2875: FEM_DIMENSION_UTIL_PKG.Register_Data_Location (
2876: p_request_id => p_request_rec.request_id
2877: ,p_object_id => p_rule_rec.act_rate_obj_id
2878: ,p_table_name => 'FEM_BALANCES'
2879: ,p_ledger_id => p_request_rec.ledger_id
2880: ,p_cal_per_id => p_request_rec.output_cal_period_id
2881: ,p_dataset_cd => p_request_rec.output_dataset_code
2882: ,p_source_cd => p_request_rec.source_system_code
2882: ,p_source_cd => p_request_rec.source_system_code
2883: ,p_load_status => null
2884: );
2885:
2886: -- Register the FEM_BALANCES output table as INSERT so that Undo will
2887: -- delete all output records
2888: Register_Table (
2889: p_request_rec => p_request_rec
2890: ,p_rule_rec => p_rule_rec
2887: -- delete all output records
2888: Register_Table (
2889: p_request_rec => p_request_rec
2890: ,p_rule_rec => p_rule_rec
2891: ,p_table_name => 'FEM_BALANCES'
2892: ,p_statement_type => 'INSERT'
2893: );
2894:
2895: -- Register the PFT_AR_DRIVERS_T processing table as INSERT. This is needed
3307: );
3308:
3309: ------------------------------------------------------------------------------
3310: -- Create Activity Rate Sequence for peforming Activity Rate Processing in
3311: -- FEM_BALANCES.
3312: ------------------------------------------------------------------------------
3313: begin
3314: -- Temporary sequence is in the default APPS schema as GSCC does not
3315: -- allow hardcoded schemas.
3455: );
3456:
3457: ------------------------------------------------------------------------------
3458: -- Drop Activity Rate Sequence for peforming Activity Rate Processing in
3459: -- FEM_BALANCES.
3460: ------------------------------------------------------------------------------
3461: begin
3462: select 'Y'
3463: into l_object_exists_flag
4226: exit next_driver;
4227: end;
4228:
4229: ------------------------------------------------------------------------
4230: -- Call the Where Clause Generator for source data in FEM_BALANCES
4231: ------------------------------------------------------------------------
4232: FEM_DS_WHERE_CLAUSE_GENERATOR.FEM_Gen_DS_WClause_PVT (
4233: p_api_version => 1.0
4234: ,p_init_msg_list => FND_API.G_FALSE
4299: ' and d.ledger_id = :b_ledger_id';
4300:
4301: -- ammittal - Do not allow Activity Rate data to be the driver of
4302: -- another activity rate
4303: if (l_drv_table_name_tbl(i) = 'FEM_BALANCES') then
4304: l_calc_drv_stmt := l_calc_drv_stmt||
4305: ' and d.financial_elem_id <> :b_act_rate_fin_elem_id';
4306: end if;
4307:
4311: end if;
4312:
4313: begin
4314:
4315: if (l_drv_table_name_tbl(i) = 'FEM_BALANCES') then
4316: execute immediate l_calc_drv_stmt
4317: into l_driver_value_tbl(i)
4318: using l_statistic_basis_id_tbl(i)
4319: ,p_ledger_id
4325: ,p_ledger_id;
4326: end if;
4327:
4328: -- Bug fix 4626068 - ammittal 06/21/05 - added the code for null
4329: -- as the statistic value can be null in FEM_BALANCES
4330: if ((l_driver_value_tbl(i) = 0)
4331: OR (l_driver_value_tbl(i) IS NULL)) then
4332:
4333: FEM_ENGINES_PKG.User_Message (
4793: | PROCEDURE
4794: | Register_Source_Chains
4795: |
4796: | DESCRIPTION
4797: | Register Source (FEM_BALANCES) Chains - Called from Act_Rate_Rule
4798: |
4799: | SCOPE - PRIVATE
4800: |
4801: +===========================================================================*/
4835:
4836: l_find_source_chains_stmt :=
4837: ' select distinct created_by_request_id'||
4838: ' ,created_by_object_id'||
4839: ' from fem_balances b'||
4840: ' where b.ledger_id = :b_ledger_id'||
4841: ' and b.financial_elem_id not in (:b_stat_fin_elem_id, :b_act_rate_fin_elem_id)'||
4842: ' and b.currency_type_code = ''ENTERED'''||
4843: ' and '||p_input_ds_b_where_clause||
5042: );
5043:
5044: ------------------------------------------------------------------------------
5045: -- STEP 2: If a successful object execution, update number of input rows in
5046: -- FEM_BALANCES before purging PFT_AR_DRIVER_VALUES_T.
5047: ------------------------------------------------------------------------------
5048: if (p_exec_status_code = G_EXEC_STATUS_SUCCESS) then
5049:
5050: FEM_ENGINES_PKG.Tech_Message (
5054: );
5055:
5056: l_num_of_input_rows_stmt :=
5057: ' select count(*)'||
5058: ' from fem_balances b'||
5059: ' where b.ledger_id = :b_ledger_id'||
5060: ' and b.financial_elem_id not in (:b_stat_fin_elem_id,:b_act_rate_fin_elem_id)'||
5061: ' and b.currency_type_code = ''ENTERED'''||
5062: ' and '||p_input_ds_b_where_clause||
5151: );
5152:
5153: select count(*)
5154: into l_num_of_output_rows
5155: from fem_balances
5156: where dataset_code = p_request_rec.output_dataset_code
5157: and cal_period_id = p_request_rec.output_cal_period_id
5158: and created_by_request_id = p_request_rec.request_id
5159: and created_by_object_id = p_rule_rec.act_rate_obj_id
5158: and created_by_request_id = p_request_rec.request_id
5159: and created_by_object_id = p_rule_rec.act_rate_obj_id
5160: and ledger_id = p_request_rec.ledger_id;
5161:
5162: -- Unregister the data location for the FEM_BALANCES output table if no
5163: -- output rows were created.
5164: if (l_num_of_output_rows = 0) then
5165:
5166: FEM_DIMENSION_UTIL_PKG.Unregister_Data_Location (
5169: );
5170:
5171: end if;
5172:
5173: -- Set the number of output rows for the FEM_BALANCES output table.
5174: FEM_PL_PKG.Update_Num_Of_Output_Rows (
5175: p_api_version => 1.0
5176: ,p_commit => FND_API.G_FALSE
5177: ,p_request_id => p_request_rec.request_id
5175: p_api_version => 1.0
5176: ,p_commit => FND_API.G_FALSE
5177: ,p_request_id => p_request_rec.request_id
5178: ,p_object_id => p_rule_rec.act_rate_obj_id
5179: ,p_table_name => 'FEM_BALANCES'
5180: ,p_statement_type => 'INSERT'
5181: ,p_num_of_output_rows => l_num_of_output_rows
5182: ,p_user_id => p_request_rec.user_id
5183: ,p_last_update_login => p_request_rec.login_id