Once a budget is created then a budget can be base lined
PROCEDURE budget_baseline_conc (
errorbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_project_number IN VARCHAR2,
p_version_num IN VARCHAR2,
p_rev_amount IN NUMBER,
p_cost_amount IN NUMBER,
p_period_num IN VARCHAR2,
p_user_id IN NUMBER,
p_success IN OUT VARCHAR2,
p_error_message IN OUT VARCHAR2
)
l_api_version_number NUMBER := 1.0;
x_finplan_version_id NUMBER;
l_commit VARCHAR2 (1) := 'F';
l_return_status VARCHAR2 (1);
l_init_msg_list VARCHAR2 (1) := 'F';
l_msg_data VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_index_out NUMBER;
l_data VARCHAR2 (2000);
l_workflow_started VARCHAR2 (1) := 'Y';
l_pm_product_code VARCHAR2 (10) := 'XXBUDGET';
l_budget_type_code VARCHAR2 (30);
l_responsility VARCHAR2 (100 BYTE);
l_application_id NUMBER;
--l_user_id NUMBER := 10803;
--l_responsibility_id NUMBER := 51222;
l_user_id NUMBER := 0;
l_responsibility_id NUMBER := 0;
l_project_id pa_projects_all.project_id%TYPE;
l_resource_list_name pa_resource_lists.NAME%TYPE;
l_resource_list_id pa_resource_lists.resource_list_id%TYPE;
l_task_id NUMBER;
l_description pa_budget_versions.description%TYPE;
l_pm_finplan_reference pa_budget_versions.pm_budget_reference%TYPE;
l_project_reference pa_projects_all.pm_project_reference%TYPE;
l_change_reason_code pa_budget_versions.change_reason_code%TYPE;
l_budget_version_name pa_budget_versions.version_name%TYPE;
l_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE;
l_fin_plan_type_name pa_fin_plan_types_vl.NAME%TYPE;
l_version_type pa_budget_versions.version_type%TYPE;
l_fin_plan_level_code pa_proj_fp_options.cost_fin_plan_level_code%TYPE;
l_time_phased_code pa_proj_fp_options.cost_time_phased_code%TYPE;
l_raw_cost_flag VARCHAR2 (1);
l_burdened_cost_flag VARCHAR2 (1);
l_revenue_flag VARCHAR2 (1);
l_cost_qty_flag VARCHAR2 (1);
l_revenue_qty_flag VARCHAR2 (1);
l_all_qty_flag VARCHAR2 (1);
l_create_new_working_flag VARCHAR2 (1);
l_replace_current_working_flag VARCHAR2 (1);
l_using_resource_lists_flag VARCHAR2 (1);
p_message VARCHAR2 (2000);
l_resource_list_member_id NUMBER;
l_line_return_status VARCHAR2 (1);
l_proj_count NUMBER;
l_budget_lines_in pa_budget_pub.budget_line_in_tbl_type;
l_budget_lines_in_rec pa_budget_pub.budget_line_in_rec_type;
l_budget_lines_out pa_budget_pub.budget_line_out_tbl_type;
l_budget_lines_out_rec pa_budget_pub.budget_line_out_rec_type;
l_loop_cnt NUMBER;
l_dummy_cnt NUMBER;
l_error VARCHAR2 (500);
l_cnt NUMBER;
l_project_number VARCHAR2 (30);
l_org_id NUMBER := fnd_profile.VALUE ('ORG_ID');
l_error_message VARCHAR2 (4000);
l_start_date DATE;
l_end_date DATE;
v_budget_version_id NUMBER;
l_currency VARCHAR2 (3);
v_rev_amount NUMBER;
v_cost_amount NUMBER;
v_rate NUMBER;
v_status VARCHAR2 (1);
l_func_currency VARCHAR2 (3);
BEGIN
mo_global.set_policy_context ('S', l_org_id);
l_responsility := fnd_profile.VALUE ('XX_PROJECT_BUDGET_RESP');
SELECT responsibility_id, application_id
INTO l_responsibility_id, l_application_id
FROM fnd_responsibility_tl
WHERE responsibility_name = l_responsility;
/*
fnd_global.apps_initialize (user_id => p_user_id,
resp_id => l_responsibility_id,
resp_appl_id => l_application_id
);
*/
pa_interface_utils_pub.set_global_info
(p_api_version_number => l_api_version_number,
p_responsibility_id => l_responsibility_id,
p_user_id => p_user_id,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status
);
mo_global.set_policy_context ('S', l_org_id);
l_budget_type_code := NULL;
l_return_status := NULL;
pa_budget_pub.baseline_budget
(p_api_version_number => 1.0,
p_commit => 'T',
p_init_msg_list => l_init_msg_list,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status,
p_workflow_started => l_workflow_started,
p_pm_product_code => l_pm_product_code,
p_pa_project_id => l_project_id,
p_pm_project_reference => p_project_number,
p_budget_type_code => l_budget_type_code,
p_fin_plan_type_id => NULL,
p_fin_plan_type_name => 'XX Cost and Revenue Budget',
p_version_type => 'ALL'
);
-- IF l_return_status != 'S'
-- THEN
-- RAISE api_error;
-- END IF;
DBMS_OUTPUT.put_line (l_return_status);
--COMMIT;
IF l_msg_count > 0
THEN
l_loop_cnt := 1;
LOOP
fnd_msg_pub.get (p_msg_index => l_loop_cnt,
p_data => l_msg_data,
p_encoded => fnd_api.g_false,
p_msg_index_out => l_dummy_cnt
);
IF l_return_status = 'E' OR l_return_status = 'U'
THEN
l_msg_data :=
CONCAT ('ERROR pa_budget_pub.baseline_budget>>> ', l_msg_data);
DBMS_OUTPUT.put_line (l_msg_data);
fnd_file.put_line (fnd_file.LOG,
'*** ERROR ENCOUNTERED ***:' || l_msg_data
);
fnd_file.put_line (fnd_file.output,
'*** ERROR ENCOUNTERED ***:' || l_msg_data
);
--fnd_file.put_line(fnd_file.OUTPUT,x_msg_data1);
v_status := 'E';
ELSE
fnd_file.put_line (fnd_file.output,
'*** BUDGET BASE LINED ***:' || l_msg_data
);
v_status := 'S';
END IF;
DBMS_OUTPUT.put_line ('RETURN STATUS :' || l_return_status);
l_error_message :=
SUBSTR (l_error_message || '~' || l_msg_data, 1, 4000);
l_loop_cnt := l_loop_cnt + 1;
EXIT WHEN l_loop_cnt > l_msg_count;
END LOOP;
END IF;
fnd_file.put_line (fnd_file.LOG,
'pa_budget_pub.baseline_budget RETURN STATUS :'
|| l_return_status
);
---------------------
fnd_file.put_line (fnd_file.LOG, 'API RETURN STATUS :' || l_return_status);
fnd_file.put_line (fnd_file.LOG, 'APT MESSAGE :' || p_error_message);
END;
PROCEDURE budget_baseline_conc (
errorbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_project_number IN VARCHAR2,
p_version_num IN VARCHAR2,
p_rev_amount IN NUMBER,
p_cost_amount IN NUMBER,
p_period_num IN VARCHAR2,
p_user_id IN NUMBER,
p_success IN OUT VARCHAR2,
p_error_message IN OUT VARCHAR2
)
l_api_version_number NUMBER := 1.0;
x_finplan_version_id NUMBER;
l_commit VARCHAR2 (1) := 'F';
l_return_status VARCHAR2 (1);
l_init_msg_list VARCHAR2 (1) := 'F';
l_msg_data VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_index_out NUMBER;
l_data VARCHAR2 (2000);
l_workflow_started VARCHAR2 (1) := 'Y';
l_pm_product_code VARCHAR2 (10) := 'XXBUDGET';
l_budget_type_code VARCHAR2 (30);
l_responsility VARCHAR2 (100 BYTE);
l_application_id NUMBER;
--l_user_id NUMBER := 10803;
--l_responsibility_id NUMBER := 51222;
l_user_id NUMBER := 0;
l_responsibility_id NUMBER := 0;
l_project_id pa_projects_all.project_id%TYPE;
l_resource_list_name pa_resource_lists.NAME%TYPE;
l_resource_list_id pa_resource_lists.resource_list_id%TYPE;
l_task_id NUMBER;
l_description pa_budget_versions.description%TYPE;
l_pm_finplan_reference pa_budget_versions.pm_budget_reference%TYPE;
l_project_reference pa_projects_all.pm_project_reference%TYPE;
l_change_reason_code pa_budget_versions.change_reason_code%TYPE;
l_budget_version_name pa_budget_versions.version_name%TYPE;
l_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE;
l_fin_plan_type_name pa_fin_plan_types_vl.NAME%TYPE;
l_version_type pa_budget_versions.version_type%TYPE;
l_fin_plan_level_code pa_proj_fp_options.cost_fin_plan_level_code%TYPE;
l_time_phased_code pa_proj_fp_options.cost_time_phased_code%TYPE;
l_raw_cost_flag VARCHAR2 (1);
l_burdened_cost_flag VARCHAR2 (1);
l_revenue_flag VARCHAR2 (1);
l_cost_qty_flag VARCHAR2 (1);
l_revenue_qty_flag VARCHAR2 (1);
l_all_qty_flag VARCHAR2 (1);
l_create_new_working_flag VARCHAR2 (1);
l_replace_current_working_flag VARCHAR2 (1);
l_using_resource_lists_flag VARCHAR2 (1);
p_message VARCHAR2 (2000);
l_resource_list_member_id NUMBER;
l_line_return_status VARCHAR2 (1);
l_proj_count NUMBER;
l_budget_lines_in pa_budget_pub.budget_line_in_tbl_type;
l_budget_lines_in_rec pa_budget_pub.budget_line_in_rec_type;
l_budget_lines_out pa_budget_pub.budget_line_out_tbl_type;
l_budget_lines_out_rec pa_budget_pub.budget_line_out_rec_type;
l_loop_cnt NUMBER;
l_dummy_cnt NUMBER;
l_error VARCHAR2 (500);
l_cnt NUMBER;
l_project_number VARCHAR2 (30);
l_org_id NUMBER := fnd_profile.VALUE ('ORG_ID');
l_error_message VARCHAR2 (4000);
l_start_date DATE;
l_end_date DATE;
v_budget_version_id NUMBER;
l_currency VARCHAR2 (3);
v_rev_amount NUMBER;
v_cost_amount NUMBER;
v_rate NUMBER;
v_status VARCHAR2 (1);
l_func_currency VARCHAR2 (3);
BEGIN
mo_global.set_policy_context ('S', l_org_id);
l_responsility := fnd_profile.VALUE ('XX_PROJECT_BUDGET_RESP');
SELECT responsibility_id, application_id
INTO l_responsibility_id, l_application_id
FROM fnd_responsibility_tl
WHERE responsibility_name = l_responsility;
/*
fnd_global.apps_initialize (user_id => p_user_id,
resp_id => l_responsibility_id,
resp_appl_id => l_application_id
);
*/
pa_interface_utils_pub.set_global_info
(p_api_version_number => l_api_version_number,
p_responsibility_id => l_responsibility_id,
p_user_id => p_user_id,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status
);
mo_global.set_policy_context ('S', l_org_id);
l_budget_type_code := NULL;
l_return_status := NULL;
pa_budget_pub.baseline_budget
(p_api_version_number => 1.0,
p_commit => 'T',
p_init_msg_list => l_init_msg_list,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status,
p_workflow_started => l_workflow_started,
p_pm_product_code => l_pm_product_code,
p_pa_project_id => l_project_id,
p_pm_project_reference => p_project_number,
p_budget_type_code => l_budget_type_code,
p_fin_plan_type_id => NULL,
p_fin_plan_type_name => 'XX Cost and Revenue Budget',
p_version_type => 'ALL'
);
-- IF l_return_status != 'S'
-- THEN
-- RAISE api_error;
-- END IF;
DBMS_OUTPUT.put_line (l_return_status);
--COMMIT;
IF l_msg_count > 0
THEN
l_loop_cnt := 1;
LOOP
fnd_msg_pub.get (p_msg_index => l_loop_cnt,
p_data => l_msg_data,
p_encoded => fnd_api.g_false,
p_msg_index_out => l_dummy_cnt
);
IF l_return_status = 'E' OR l_return_status = 'U'
THEN
l_msg_data :=
CONCAT ('ERROR pa_budget_pub.baseline_budget>>> ', l_msg_data);
DBMS_OUTPUT.put_line (l_msg_data);
fnd_file.put_line (fnd_file.LOG,
'*** ERROR ENCOUNTERED ***:' || l_msg_data
);
fnd_file.put_line (fnd_file.output,
'*** ERROR ENCOUNTERED ***:' || l_msg_data
);
--fnd_file.put_line(fnd_file.OUTPUT,x_msg_data1);
v_status := 'E';
ELSE
fnd_file.put_line (fnd_file.output,
'*** BUDGET BASE LINED ***:' || l_msg_data
);
v_status := 'S';
END IF;
DBMS_OUTPUT.put_line ('RETURN STATUS :' || l_return_status);
l_error_message :=
SUBSTR (l_error_message || '~' || l_msg_data, 1, 4000);
l_loop_cnt := l_loop_cnt + 1;
EXIT WHEN l_loop_cnt > l_msg_count;
END LOOP;
END IF;
fnd_file.put_line (fnd_file.LOG,
'pa_budget_pub.baseline_budget RETURN STATUS :'
|| l_return_status
);
---------------------
fnd_file.put_line (fnd_file.LOG, 'API RETURN STATUS :' || l_return_status);
fnd_file.put_line (fnd_file.LOG, 'APT MESSAGE :' || p_error_message);
END;
No comments:
Post a Comment