Xxca Asset Project PKG
Xxca Asset Project PKG
Xxca Asset Project PKG
PROJECT_NAME IN VARCHAR,
ASSET_NUMBER IN VARCHAR,
ASSET_DESCRIPTION IN VARCHAR,
PROJECT_ASSET_TYPE IN VARCHAR,
ASSET_LOCATION IN VARCHAR,
DATE_PLACED_IN_SERVICE IN DATE,
ASSET_CATEGORY IN VARCHAR,
BOOK_TYPE_CODE IN VARCHAR,
ASSET_UNITS IN NUMBER,
ESTIMATED_ASSET_UNITS IN NUMBER,
ESTIMATED_COST IN NUMBER,
DEPRECIATE_FLAG IN VARCHAR,
DEPRECIATION_EXPENSE IN VARCHAR,
AMORTIZE_FLAG IN VARCHAR,
MANUFACTURER_NAME IN VARCHAR,
MODEL_NUMBER IN VARCHAR,
SERIAL_NUMBER IN VARCHAR,
TAG_NUMBER IN VARCHAR,
TASK_NAME IN VARCHAR,
PROJECT_STATUS IN VARCHAR,
TASK_STATUS IN VARCHAR,
USER_ID IN NUMBER,
RESP_ID IN NUMBER,
SEGMENT1 IN VARCHAR2,
SEGMENT2 IN VARCHAR2,
SEGMENT3 IN VARCHAR2,
SEGMENT4 IN VARCHAR2,
SEGMENT5 IN VARCHAR2,
SEGMENT6 IN VARCHAR2,
SEGMENT7 IN VARCHAR2,
SEGMENT8 IN VARCHAR2,
SEGMENT9 IN VARCHAR2,
SEGMENT10 IN VARCHAR2,
SEGMENT11 IN VARCHAR2,
SEGMENT12 IN VARCHAR2
--ASSET_KEY IN VARCHAR2
) Is
--l_APPLICATION_ID NUMBER;
l_RESP_id NUMBER;
lc_err_msg VARCHAR2(200) ;
lc_mesg VARCHAR2(200) ;
Begin
-- commit;
--commit;
/*Delete asset creation previous records from runtime table after backup */
-- commit;
--commit;
/* 02-06-2018 Backup of Previous Data
XXX_ASSET_PROJECT_ADD_TL_Bk
CMPAK_ASSET_GEN_TL_Bk
*/
DELETE XXX_ASSET_PROJECT_ADD_TL K
AND K.USER_ID=FND_PROFILE.value('USER_ID');
COMMIT ;
BEGIN
AND DS.PERIOD_COUNTER =
(SELECT max(DS1.PERIOD_COUNTER)
and rownum = 1)
)q
NET_BOOK_VALUE1 :=1 ;
END ;
/* update xxx_asset_project_add_tl a
a.status ='ERROR'
where 1=1
COMMIT;*/
Dbms_Output.put_line ('ERROR GENERATED FOR Asset Net Book Vlaue is Zero ') ;
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END IF ;
/*
BEGIN
AND DS.PERIOD_COUNTER =
(SELECT max(DS1.PERIOD_COUNTER)
and rownum = 1)
)q
;
NET_BOOK_VALUE1 :=1 ;
END ;
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END IF ;
*/
values
(S_NO,
PROJECT_NAME,
UPPER(ASSET_NUMBER),
ASSET_DESCRIPTION,
PROJECT_ASSET_TYPE,
ASSET_LOCATION,
DATE_PLACED_IN_SERVICE,
ASSET_CATEGORY,
BOOK_TYPE_CODE,
ASSET_UNITS,
ESTIMATED_ASSET_UNITS,
ESTIMATED_COST,
DEPRECIATE_FLAG,
DEPRECIATION_EXPENSE,
AMORTIZE_FLAG,
MANUFACTURER_NAME,
UPPER (MODEL_NUMBER),
SERIAL_NUMBER,
TAG_NUMBER,
TASK_NAME,
PROJECT_STATUS,
TASK_STATUS,
l_user_id ,--USER_ID,
RESP_ID,
null ,
SEGMENT1,
SEGMENT2,
SEGMENT3,
SEGMENT4,
SEGMENT5,
SEGMENT6,
SEGMENT7,
SEGMENT8,
SEGMENT9,
SEGMENT10,
SEGMENT11,
SYSDATE,
SYSDATE,
'NEW'
);
Commit;
declare
cursor abc is
select s_no,
project_name,
asset_number,
asset_description,
project_asset_type,
asset_location,
date_placed__service,
asset_category,
book_type_code,
asset_units,
estimated_asset_units,
estimated_cost,
depreciate_flag,
depreciation_expense,
amortize_flag,
manufacturer_name,
model_number,
serial_number,
tag_number,
task_name,
project_status,
task_status,
user_id,
resp_id,
asset_key,
segment1,
segment2,
segment3,
segment4,
segment5,
segment6,
segment7,
segment8,
segment9,
segment10,
segment11,
segment12,
ROWID
from xxx_asset_project_add_tl
--- ;
vv_project_id number;
vv_task_id number;
vv_category_id number;
vv_depr_exp_id number;
vv_loc_id number;
v_asset_number varchar2(200);
lc_err_msg varchar2(1000);
lc_mesg varchar2(4000);
--l_APPLICATION_ID NUMBER;
--l_RESPONSIBILITY_id NUMBER;
--l_user_id number;
begin
-- l_user_id := USER_ID;
-- from fnd_responsibility_tl t
-- dbms_output.put_line('Arshad');
/*
BEGIN
AND DS.PERIOD_COUNTER =
(SELECT max(DS1.PERIOD_COUNTER)
NET_BOOK_VALUE1 :=1 ;
END ;
IF NET_BOOK_VALUE1 = 0 THEN
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END IF ;*/
select count(*)
into l_asst_cnt
end if ;
/*
BEGIN
AND DS.PERIOD_COUNTER =
(SELECT max(DS1.PERIOD_COUNTER)
NET_BOOK_VALUE1 :=1 ;
END ;
IF NET_BOOK_VALUE1 = 0 THEN
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END IF ;*/
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
else
into vv_project_id
BEGIN
into vv_task_id
lp.task_name
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END;
select l.LOCATION_ID
into vv_loc_id
from FA_LOCATIONS l
--l.SEGMENT4
-- like lp.asset_location;
select c.CATEGORY_ID
from FA_CATEGORY_BOOKS a,
FA_BOOK_CONTROLS b,
FA_CATEGORIES_VL c
select a.CODE_COMBINATION_ID
into vv_depr_exp_id
from gl_code_combinations a
BEGIN
v_asset_number :=LP.ASSET_NUMBER;
/*
BEGIN
AND DS.PERIOD_COUNTER =
(SELECT max(DS1.PERIOD_COUNTER)
and rownum = 1)
)q
;
NET_BOOK_VALUE1 :=1 ;
END ;
update xxx_asset_project_add_tl a
a.status ='ERROR'
where 1=1
COMMIT;
Dbms_Output.put_line ('ERROR GENERATED FOR Asset Net Book Vlaue is Zero ') ;
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
END IF ;
*/
ELSE
lc_err_msg := 'Both Asset Number field and old Asset Number should not null';
fnd_message.set_name('PA', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
-- v_asset_number :=LP.ASSET_NUMBER;
END IF;
END;
-- v_asset_number :=LP.ASSET_NUMBER;
declare
v_number number;
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_return_status VARCHAR2(2000);
l_pa_project_id_out NUMBER;
l_pa_project_number_out VARCHAR2(2000);
l_pa_project_asset_id_out NUMBER;
l_pm_asset_reference_out VARCHAR2(2000);
l_output VARCHAR2(2000);
l_msg_dummy VARCHAR2(2000);
lc_er_msg varchar2(1000);
-- lc_mesg varchar2(1000);
-- api_error EXCEPTION;
-- n NUMBER := 0;
begin
p_asset_key_ccid => 1,
COMMIT;
-- dbms_output.put_line(l_pa_project_asset_id_out);
fnd_msg_pub.get(n,
fnd_api.g_false,
l_msg_data,
l_msg_dummy);
l_output);
*/
update xxx_asset_project_add_tl a
l_output,
a.status ='ERROR'
COMMIT;
lc_er_msg := l_output;
fnd_message.set_name('PA', lc_er_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
/* if error i donot want to insert into next task assign table 18-12-2018*/
/*
pa_project_id,
pa_task_id,
pa_project_asset_id_out,
status)
Values
lp.asset_number,
vv_project_id,
vv_task_id,
l_pa_project_asset_id_out,
*/
END LOOP;
ELSE
update xxx_asset_project_add_tl a
l_pa_project_asset_id_out,
a.status ='SUCCESS'
where a.project_name = lp.project_name
(pa_project_asset,
pa_project_id,
pa_task_id,
pa_project_asset_id_out,
status,
project_name,
task_name,
user_id,
resp_id,
RECORD_STATUS)
Values
lp.asset_number,
vv_project_id,
vv_task_id,
l_pa_project_asset_id_out,
lp.project_name,
lp.task_name,
lp.user_id,
lp.resp_id,
'NEW');
COMMIT;
(pa_project_asset,
pa_project_id,
pa_task_id,
pa_project_asset_id_out,
status,
project_name,
task_name,
user_id,
resp_id,
RECORD_STATUS)
Values
lp.model_number,
vv_project_id,
vv_task_id,
l_pa_project_asset_id_out,
lp.project_name,
lp.task_name,
lp.user_id,
lp.resp_id,
'NEW');
COMMIT;
END IF ;
END IF;
EXCEPTION
l_output,
a.status ='ERROR'
COMMIT;
lc_er_msg := l_output;
fnd_message.set_name('PA', lc_er_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
end;
end if;
NET_BOOK_VALUE1 :=2 ;
end loop;
declare
cursor abc is
select *
from CMPAK_ASSET_GEN_TL k
and k.record_status='NEW';
begin
declare
v_number number;
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_return_status VARCHAR2(2000);
l_pa_project_id_out NUMBER;
l_pa_task_id_out NUMBER;
l_pa_project_number_out VARCHAR2(2000);
-- L_pa_project_asset_id_out NUMBER;
l_pa_project_asset_id_out NUMBER;
l_pm_asset_reference_out VARCHAR2(2000);
l_output VARCHAR2(2000);
l_msg_dummy VARCHAR2(2000);
lc_e_msg VARCHAR2(2000);
-- api_error EXCEPTION;
n NUMBER := 0;
begin
--:User_id,
COMMIT;
fnd_msg_pub.get(n,
fnd_api.g_false,
l_msg_data,
l_msg_dummy);
/* update xxx_asset_project_add_tl a
set a.task_status = 'Error: API Error while updating the Task: ' ||
l_output || l_pa_task_id_out,
STATUS ='ERROR'
update CMPAK_ASSET_GEN_TL b
set Task_Status = 'Error: API Error while updating the Task: ' ||
l_output,
record_status ='ERROR'
and b.pa_project_asset_id_out =
t.pa_project_asset_id_out;
COMMIT;
lc_err_msg :=l_output;
fnd_message.set_name('PA', lc_err_msg);
--fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg); */
END LOOP;
ELSE
update xxx_asset_project_add_tl a
l_output || l_pa_task_id_out
update CMPAK_ASSET_GEN_TL b
b.record_status ='SUCCESS'
END IF;
EXCEPTION
update CMPAK_ASSET_GEN_TL b
set Task_Status = 'Error: API Error while updating the Task: ' ||
l_output,
record_status ='ERROR'
and b.pa_project_asset_id_out =
t.pa_project_asset_id_out;
update xxx_asset_project_add_tl a
set a.task_status = 'Error: API Error while updating the Task: ' ||
l_output || l_pa_task_id_out,
STATUS ='ERROR'
lc_e_msg := l_output;
fnd_message.set_name('PA', lc_e_msg);
lc_mesg := fnd_message.get;
raise_application_error(-20001, lc_mesg);
end;
end loop;
end;
end;
end;
VA_CNT NUMBER;
BEGIN
select COUNT(*) INTO VA_CNT from pa_project_assets_all where asset_number LIKE '%' || P_ASSET_NUM || '%' ;
IF
ELSE
VA_ASSET_NUM := P_ASSET_NUM;
END IF;
RETURN VA_ASSET_NUM;
END ;
End XXCA_ASSET_PROJECT_PKG ;