Package_123

CREATE OR REPLACE PACKAGE BODY APPS.XXTI_Projects_Budget_Pkg
IS
PROCEDURE XXTI_Create_budgets(errbuf OUT VARCHAR2, retcode OUT VARCHAR2) IS
-- variables needed for API standard parameters
l_api_version_number NUMBER := 1.0;
l_commit VARCHAR2(1) := 'F';
l_return_status VARCHAR2(1);
l_init_msg_list VARCHAR2(1) := 'T';
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_data VARCHAR2(2000);
-- l_msg_entity VARCHAR2(100);
-- l_msg_entity_index NUMBER;
l_msg_index NUMBER;
l_msg_index_out NUMBER;
l_encouded VARCHAR2(1);
i NUMBER;
a NUMBER;
-- variables needed for the user_id and responsibility_id
l_user_id NUMBER;
l_responsibility_id NUMBER;
-- variables needed for Oracle Project specific parameters
l_pm_product_code VARCHAR2(10);
l_pa_project_id NUMBER;
l_pm_project_reference VARCHAR2(25);
l_budget_type_code VARCHAR2(30);
l_change_reason_code VARCHAR2(30);
l_description VARCHAR2(255);
l_entry_method_code VARCHAR2(30);
l_resource_list_name VARCHAR2(60);
l_resource_list_id 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;
ln_msg_count NUMBER;
lc_msg_data VARCHAR2(2000);
lc_return_status VARCHAR2(1);
lt_budget_lines_in pa_budget_pub.budget_line_in_tbl_type;
lt_budget_lines_out pa_budget_pub.budget_line_out_tbl_type;
l_budget_version_name VARCHAR2(20) := 'Version 1';
l_line_index NUMBER;
l_line_return_status VARCHAR2(1);
ln_line_count NUMBER;
API_ERROR EXCEPTION;
CURSOR get_project_cur
IS
SELECT project_number,project_name,project_id,
PM_project_reference,pm_product_code ,
budget_type_code,budget_entry_method_code
FROM XXTI_PA_CR_BUDGETS_STG;
CURSOR get_task_cur (p_project_id Number)
IS
SELECT task_id,resource_list_id
FROM XXTI_PA_CR_BUDGETS_STG
WHERE project_id = p_project_id
GROUP BY task_id,resource_list_id;
CURSOR get_period_cur (p_project_id NUMBER,p_task_id NUMBER)
IS
SELECT period_name,raw_cost
FROM XXTI_PA_CR_BUDGETS_STG
WHERE project_id = p_project_id
and task_id = p_task_id;
BEGIN
FOR get_project_rec IN get_project_cur
LOOP
BEGIN
FOR get_task_rec IN get_task_cur(get_project_rec.project_id)
LOOP
BEGIN
FOR get_period_rec IN get_period_cur(get_project_rec.project_id,get_task_rec.task_id)
LOOP
--project details
l_project_number := get_project_rec.project_number;
l_project_name := get_project_rec.project_name;
l_project_id := get_project_rec.project_id;
l_pm_project_reference := get_project_rec.pm_project_reference;
l_pm_product_code := get_project_rec.pm_product_code;
l_budget_type_code := get_project_rec.budget_type_code;
l_budget_entry_method_code := get_project_rec.budget_entry_method_code;
--task details
l_task_id := get_task_rec.task_id;
l_resource_list_id := get_task_rec.resource_list_id;
--period details        
l_period_name := get_period_rec.period_name;
l_raw_cost := get_period_rec.raw_cost;
******** Instruction For the developer **************
Here i have statically passed the values below for lt_budget_lines_in tbl type below:
You need to put single set in LOOP and load data into "lt_budget_lines_in" depends on the the combinations of budget lines
you are
loading based on EXCEL date.
Eg: Project has 2 tasks T1, T2 and need to create budget lines for MAR-12, APR-12 and MAY-12, Then the number of lines will
be SIX.
then six times you will have to LOOP below data load with combinations below:
T1 > MAR-12
T1 > APR-12
T1 > MAY-12
T2 > MAR-12
T2 > APR-12
T2 > MAY-12
In HK entity (I52S), Project 77777 was tested with this script by loading budget.
It was found that budget accounts also were generated properly for the loaded budget.
/*TO BE IN LOOP START*/
--task-1 apr-2012
/* ln_line_count := 1;
lt_budget_lines_in.DELETE;
lt_budget_lines_in(ln_line_count).pa_task_id := 11000;
lt_budget_lines_in(ln_line_count).pm_task_reference := 'Task1';
lt_budget_lines_in(ln_line_count).resource_alias := 'Computer';
lt_budget_lines_in(ln_line_count).resource_list_member_id := 2016;
lt_budget_lines_in(ln_line_count).budget_start_date := NULL;
lt_budget_lines_in(ln_line_count).budget_end_date := NULL;
lt_budget_lines_in(ln_line_count).period_name := 'APR-12';
lt_budget_lines_in(ln_line_count).description := NULL;
lt_budget_lines_in(ln_line_count).raw_cost := 1000;
lt_budget_lines_in(ln_line_count).burdened_cost := NULL;
lt_budget_lines_in(ln_line_count).revenue := NULL;
lt_budget_lines_in(ln_line_count).quantity := NULL;
lt_budget_lines_in(ln_line_count).pm_product_code := 'MSEXCEL';
lt_budget_lines_in(ln_line_count).txn_currency_code := NULL;
/*TO BE IN LOOP END
--task-1 May-2012
ln_line_count := ln_line_count + 1;
lt_budget_lines_in(ln_line_count).pa_task_id := 11000;
lt_budget_lines_in(ln_line_count).pm_task_reference := 'Task1';
lt_budget_lines_in(ln_line_count).resource_alias := 'Computer';
lt_budget_lines_in(ln_line_count).resource_list_member_id := 2016;
lt_budget_lines_in(ln_line_count).budget_start_date := NULL;
lt_budget_lines_in(ln_line_count).budget_end_date := NULL;
lt_budget_lines_in(ln_line_count).period_name := 'MAY-12';
lt_budget_lines_in(ln_line_count).description := NULL;
lt_budget_lines_in(ln_line_count).raw_cost := 2000;
lt_budget_lines_in(ln_line_count).burdened_cost := NULL;
lt_budget_lines_in(ln_line_count).revenue := NULL;
lt_budget_lines_in(ln_line_count).quantity := NULL;
lt_budget_lines_in(ln_line_count).pm_product_code := 'MSEXCEL';
lt_budget_lines_in(ln_line_count).txn_currency_code := NULL;
-- GET GLOBAL INFO
SELECT user_id, responsibility_id
INTO l_user_id, l_responsibility_id
FROM pa_user_resp_v
WHERE user_name = fnd_profile.value('USER_ID') --'OHAORACLE'
AND responsibility_id = fnd_profile.value('RESP_ID'); -- '20433';
-- SET GLOBAL INFO
pa_interface_utils_pub.set_global_info (
p_api_version_number => 1.0,
p_responsibility_id => l_responsibility_id,
p_user_id => l_user_id,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status);
-- INIT_BUDGET
pa_budget_pub.init_budget;
-- CREATE_DRAFT_BUDGET
PA_BUDGET_PUB.create_draft_budget( p_api_version_number => l_api_version_number --1.1--G_API_VERSION
,p_commit => l_commit
,p_init_msg_list => l_init_msg_list
,p_msg_count => ln_msg_count
,p_msg_data => lc_msg_data
,p_return_status => lc_return_status
,p_pm_product_code => l_pm_product_code --'MSEXCEL'
,p_pm_budget_reference => NULL
,p_budget_version_name => l_budget_version_name
,p_pa_project_id => l_project_id
,p_pm_project_reference => l_pm_project_reference
,p_budget_type_code => l_budget_type_code
,p_change_reason_code => NULL
,p_description => NULL
,p_entry_method_code => l_budget_entry_method_code
,p_resource_list_name => NULL
,p_resource_list_id => l_resource_list_id
,p_attribute_category => NULL
,p_attribute1 => NULL
,p_attribute2 => NULL
,p_attribute3 => NULL
,p_attribute4 => NULL
,p_attribute5 => NULL
,p_attribute6 => NULL
,p_attribute7 => NULL
,p_attribute8 => NULL
,p_attribute9 => NULL
,p_attribute10 => NULL
,p_attribute11 => NULL
,p_attribute12 => NULL
,p_attribute13 => NULL
,p_attribute14 => NULL
,p_attribute15 => NULL
,p_budget_lines_in => lt_budget_lines_in
,p_budget_lines_out => lt_budget_lines_out
,p_fin_plan_type_id => NULL
,p_fin_plan_type_name => NULL
,p_version_type => NULL
,p_fin_plan_level_code => NULL
,p_time_phased_code => NULL
,p_plan_in_multi_curr_flag => NULL
,p_projfunc_cost_rate_type => NULL
,p_projfunc_cost_rate_date_typ => NULL
,p_projfunc_cost_rate_date => NULL
,p_projfunc_rev_rate_type => NULL
,p_projfunc_rev_rate_date_typ => NULL
,p_projfunc_rev_rate_date => NULL
,p_project_cost_rate_type => NULL
,p_project_cost_rate_date_typ => NULL
,p_project_cost_rate_date => NULL
,p_project_rev_rate_type => NULL
,p_project_rev_rate_date_typ => NULL
,p_project_rev_rate_date => NULL
,p_raw_cost_flag => NULL
,p_burdened_cost_flag => NULL
,p_revenue_flag => NULL
,p_cost_qty_flag => NULL
,p_revenue_qty_flag => NULL
,P_all_qty_flag => NULL
,p_create_new_curr_working_flag=> NULL
,p_replace_current_working_flag=> NULL
,p_using_resource_lists_flag => NULL
dbms_output.put_line('Status ' || l_return_status);
if l_return_status != 'S'
then
raise API_ERROR;
end if;
for i in 1..lt_budget_lines_out.count
loop
dbms_output.put_line('create draft budget was successful for line ' || i);
dbms_output.put_line('Return Code = ' || lt_budget_lines_out(i).return_status);
end loop;
-- CLEAR_BUDGET
--pa_budget_pub.clear_budget;
if l_return_status != 'S'
then
raise API_ERROR;
end if;
-- HANDLE EXCEPTIONS
EXCEPTION
WHEN API_ERROR
THEN
FOR i in 1..l_msg_count
LOOP
pa_interface_utils_pub.get_messages
(p_msg_data => l_msg_data,
p_data => l_data,
p_msg_count => l_msg_count,
p_msg_index_out => l_msg_index_out
dbms_output.put_line('error msg ' || l_data);
----dbms_output.put_line('error msg ' || l_msg_data);
----dbms_output.put_line('error msg ' || l_msg_count);
END LOOP;
--dbms_output.put_line('api error ' || sqlerrm);
WHEN OTHERS then
FOR i in 1..l_msg_count
LOOP
pa_interface_utils_pub.get_messages
(p_msg_data => l_msg_data,
p_data => l_data,
p_msg_count => l_msg_count,
p_msg_index_out => l_msg_index_out
dbms_output.put_line('error msg ' || l_data);
END LOOP;
--dbms_output.put_line('others ' || sqlerrm);
END;
END LOOP; --end for periso cur
END LOOP; --end for task cur
END LOOP; --end for project cur
END; --end for period
END: --end for task
END; --end for project
END XXTI_Create_budgets;
END XXTI_Projects_Budget_Pkg;

Hi;
What is the question than?
Regard
Helios

Similar Messages

Maybe you are looking for