Professional Documents
Culture Documents
Boq Create Events Prog BKP
Boq Create Events Prog BKP
LV_PROJECT_ID NUMBER;
L_SSPBR_NO Varchar2(100);
BEGIN
BEGIN
Select PBR_NUMBER INTO L_SSPBR_NO
from BOQ_PROJ_PAYM_BILL_REQ_T
where ppbr_id = p_ppbr_id;
EXCEPTION
WHEN OTHERS THEN
L_SSPBR_NO := NULL ;
END;
-- This is not required when you are registering the code as concurrent program
/*fnd_global.apps_initialize (ln_user_id,
ln_responsibility_id,
ln_resp_appl_id
);*/
fnd_global.apps_initialize (0,50321,275);
/*begin
select user_name
into ln_user_name
from fnd_user
where user_id = ln_user_id;
select responsibility_name
into ln_responsibility_name
from fnd_responsibility_tl
where responsibility_id = ln_responsibility_id;
select name
into ln_org_name
from hr_operating_units
where organization_id = ln_org_id;
-- This is not required when you are registering the code as concurrent program
--mo_global.set_policy_context ('S',ln_org_id);
ln_org_id:=l_cur_rec.org_id;
mo_global.set_policy_context ('S',l_cur_rec.org_id);
ln_user_id := 0;
ln_responsibility_id := 50321;
l_ref_no :=l_cur_rec.PBR_NUMBER||'-'||l_cur_rec.event_number||'-'||l_ref_no;
-- l_validation_flag :='N';
------------------------ Event Type Validation
--------------------------------------------------------------
dbms_output.put_line('l_cur_rec.event_type:'||l_cur_rec.event_type) ;
IF l_cur_rec.event_type IS NOT NULL
THEN
BEGIN
SELECT event_type
INTO l_event_type
FROM pa_event_types
WHERE event_type_ID = l_cur_rec.event_type
AND TRUNC (SYSDATE) BETWEEN start_date_active
AND NVL (end_date_active, SYSDATE);
l_validation_flag := 'Y';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE(
'Event type validation is failed for the Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
);
X_MSG:=
'Event type validation is failed for the Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER;
X_FLAG:='E';
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
lv_err_msg := 'Event type validation is failed for the Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER;
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(
'Other error occurred while validating Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
X_MSG:='Other error occurred while validating Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER;
X_FLAG:='E';
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'||'Other error occurred while validating Event Type: '
|| l_cur_rec.event_type||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER;
END;
ELSE
DBMS_OUTPUT.PUT_LINE(
'Event Type is NULL in the line: ' || ' and the PBR_Number: '||
l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
X_FLAG:='E';
X_MSG:='Event Type is NULL in the line: ' || ' and the PBR_Number: '||
l_cur_rec.PBR_NUMBER;
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'||'Event Type is NULL in the line: ' || ' and the
PBR_Number: '||l_cur_rec.PBR_NUMBER;
END IF;
l_validation_flag := 'Y';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE(
'Validation failed for the Project Number: '
|| l_cur_rec.project_number
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'|| 'Validation failed for the Project Number: '
|| l_cur_rec.project_number;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(
'Other error occured while validating Project Number: '
|| l_cur_rec.project_number
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
dbms_output.put_line('l_cur_rec.org_id:'||l_cur_rec.org_id) ;
IF l_cur_rec.org_id IS NOT NULL
THEN
BEGIN
SELECT NAME
INTO l_org_name
FROM hr_all_organization_units
WHERE TRUNC (SYSDATE) BETWEEN date_from AND NVL (date_to,
SYSDATE
)
AND organization_id =l_cur_rec.org_id;
l_validation_flag := 'Y';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE(
'Validation failed for the Organization: '
|| l_org_name||' for the project number: '||l_cur_rec.project_number||' and the
PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'|| 'Validation failed for the Organization: '
|| l_org_name||' for the project number: '||l_cur_rec.project_number||' and the
PBR_Number: '||l_cur_rec.PBR_NUMBER;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(
'Other error occured while validating Organization: '
|| l_org_name||' for the project number: '||l_cur_rec.project_number||' and the
PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
-- Commented because project functional currency need not be same as the project
event billing currency
/*IF l_project_currency_code = l_cur_rec.currency THEN
l_validation_flag := 'Y';
ELSE
fnd_file.put_line
(fnd_file.LOG,
'Validation mismatch for the Currency: '
|| l_cur_rec.currency || ' with Project Currency: '||l_project_currency_code||'
for the project: '||l_cur_rec.project_number||'in SNo: '||l_cur_rec.sno
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
END IF;*/
EXCEPTION
WHEN NO_DATA_FOUND
THEN
fnd_file.put_line
(fnd_file.LOG,
'Validation failed for the Currency: '
|| l_cur_rec.currency||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'|| 'Validation failed for the Currency: '
|| l_cur_rec.currency||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
WHEN OTHERS
THEN
fnd_file.put_line
(fnd_file.LOG,
'Other error occured while validating Currency: '
|| l_cur_rec.currency||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
lv_err_msg :=lv_err_msg||':'|| 'Other error occured while validating Currency: '
|| l_cur_rec.currency||' for the project number: '||l_cur_rec.project_number||'
and the PBR_Number: '||l_cur_rec.PBR_NUMBER
;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END;
ELSE
DBMS_OUTPUT.PUT_LINE(
'Currency is NULL in the line: ' || ' the PBR_Number: '||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
------------------------Task Validation
--------------------------------------------------------------
-- Commented because Task is not mandatory for creating project events.
-- Client is not using task while creating project events, so made it as null while
initiating l_task_number
-- Enable this code depends on the requirement
l_validation_flag := 'Y';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
fnd_file.put_line
(fnd_file.LOG,
'Validation failed for the Task Number: '
|| l_cur_rec.task_number
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
WHEN OTHERS
THEN
fnd_file.put_line
(fnd_file.LOG,
'Other error occured while validating Task Number: '
|| l_cur_rec.task_number
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END;
ELSE
l_task_number := NULL;
END IF;
-----------------------------------------------------------------------------------
---
dbms_output.put_line('Task:'||l_task_number);
dbms_output.put_line('Event Type: '||l_event_type);
dbms_output.put_line('Completion date: '||l_cur_rec.event_date);
dbms_output.put_line('Project Number: '||l_project_number);
dbms_output.put_line('Org Name: '||l_org_name);
dbms_output.put_line('Currency: '||l_currency);
dbms_output.put_line('l_ref_no: '||l_ref_no);
dbms_output.put_line('l_validation_errors:'||l_validation_errors);
dbms_output.put_line('lv_err_msg:'||lv_err_msg);
THEN
DBMS_OUTPUT.PUT_LINE('All the records are validated successfully');
DBMS_OUTPUT.PUT_LINE('Calling API....');
mo_global.set_policy_context('S', 1068);
pa_event_pub.init_event;
pa_event_pub.create_event (p_api_version_number => 1.0,
p_commit => fnd_api.g_false,
p_init_msg_list => fnd_api.g_true,
p_pm_product_code => 'PJM', -- Data Migration
p_event_in_tbl => l_event_in_tbl,
p_event_out_tbl => l_event_out_tbl,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status
);
DBMS_OUTPUT.PUT_LINE(
'API message: ' || NVL(l_msg_data,'Nothing to display')
);
DBMS_OUTPUT.PUT_LINE(
'Return Status of API is: ' || l_return_status
);
DBMS_OUTPUT.put_line ('After API: ' || l_msg_data);
DBMS_OUTPUT.put_line ('Return Status: ' || l_return_status);
IF l_return_status = 'S'
THEN
UPDATE JAMBOQ.BOQ_PROJ_PAYM_BILL_REQ_T
SET attribute20 = 'Event Created'
WHERE ppbr_id =l_cur_rec.ppbr_id;
UPDATE APPS.PA_EVENTS
SET ATTRIBUTE9=l_cur_rec.PBR_NUMBER
WHERE EVENT_ID=l_event_out_tbl(1).EVENT_ID;
ELSE
FOR i IN 1 .. l_msg_count
LOOP
apps.pa_interface_utils_pub.get_messages
(p_encoded => 'F',
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_data => l_data,
p_msg_index => i,
p_msg_index_out => l_msg_index_out
);
END LOOP;
DBMS_OUTPUT.PUT_LINE('From pa_interface_utils_pub.get_messages: ' || l_data);
UPDATE JAMBOQ.BOQ_PROJ_PAYM_BILL_REQ_T
SET attribute20 = 'E'
, attribute19 =substr(l_data,1,200)
WHERE ppbr_id =l_cur_rec.ppbr_id
;
UPDATE JAMBOQ.BOQ_PROJ_PAYM_BILL_REQ_T
SET attribute20 = 'E'
WHERE ppbr_id =l_cur_rec.ppbr_id
;
fnd_file.put_line
(fnd_file.LOG,
'Events have not created because of validation failures'
);
END IF; -- l_validation_errors = 0
COMMIT;
END LOOP;
END LOOP;
DBMS_OUTPUT.PUT_LINE('From pa_interface_utils_pub.get_messages: ' || l_data);
DBMS_OUTPUT.put_line ('From pa_interface_utils_pub.get_messages: ' || l_data); */
-- dbms_output.put_line('Before Commit');
IF X_FLAG ='S' THEN
fnd_global.apps_initialize (
user_id => 0,--fnd_profile.VALUE ('USER_ID'),
resp_id => 50241,--fnd_profile.VALUE ('RESP_ID'),
resp_appl_id => 222,--fnd_profile.VALUE ('RESP_APPL_ID'),
security_group_id => 0);
lv_request_id := fnd_request.submit_request (
application => 'PA',
program => 'JAMBOQ_CALL_DRAFT_RELEASE',
description => NULL,
start_time => sysdate,
sub_request => FALSE,
argument1=> LV_PROJECT_ID);
COMMIT;
fnd_file.put_line(fnd_file.LOG,'lv_request_id '||lv_request_id);
IF lv_request_id = 0
THEN
fnd_file.
put_line (fnd_file.LOG,
'Request Not Submitted due to "' || fnd_message.get || '".');
ELSE
fnd_file.
put_line (
fnd_file.LOG,
'The Program Draft Release submitted successfully – Request id :'
|| lv_request_id);
END IF;
IF lv_request_id > 0
THEN
LOOP
--
--To make process execution to wait for 1st program to complete
--
l_req_return_status :=
fnd_concurrent.wait_for_request (request_id => lv_request_id,
INTERVAL => 5 --interval Number of
seconds to wait between checks
,
max_wait => 60 --Maximum number of
seconds to wait for the request completion
-- out arguments
,
phase => lc_phase,
STATUS => lc_status,
dev_phase => lc_dev_phase,
dev_status => lc_dev_status,
MESSAGE => lc_message);
EXIT WHEN UPPER (lc_phase) = 'COMPLETED'
OR UPPER (lc_status) IN
('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
BEGIN
MO_GLOBAL.INIT ('PA');
FND_REQUEST.SET_ORG_ID(1068);
-- FND_SUBMIT.SET_NLS_OPTIONS ('AMERICAN','UNITED ARAB EMIRATES');
--
lv_request_id := fnd_request.submit_request (
application => 'AR',
program => 'BOQ_AR_INVOICE_ACTION',
description => NULL,
start_time => sysdate,
sub_request => FALSE,
argument1=> L_SSPBR_NO);
COMMIT;
fnd_file.put_line(fnd_file.LOG,'lv_request_id '||lv_request_id);
IF lv_request_id = 0
THEN
fnd_file.
put_line (
fnd_file.LOG,
'AR actions Request Not Submitted due to "'
|| fnd_message.get
|| '".');
ELSE
fnd_file.
put_line (
fnd_file.LOG,
'The Streamline Program PROGRAM submitted successfully – Request
id :'
|| lv_request_id);
END IF;
IF lv_request_id > 0 THEN
lv_request_id := fnd_request.submit_request (
application => 'AR',
program => 'BOQ_AR_INVOICE_ACTION',
description => NULL,
start_time => sysdate,
sub_request => FALSE,
argument1=> L_SSPBR_NO);
COMMIT;
END IF;
END IF;
END;
END IF;
END IF;
END IF;
EXCEPTION
WHEN OTHERS
THEN
l_error := SUBSTR (SQLERRM, 1, 200);
DBMS_OUTPUT.PUT_LINE(
'Other Error while creating event: ' || l_error
);
X_MSG:=(
'Other Error while creating event: ' || l_error
);
X_FLAG:='E';
END BOQ_CREATE_EVENTS;
/