Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 14

CREATE OR REPLACE PROCEDURE APPS.

BOQ_CREATE_EVENTS (P_PPBR_ID IN NUMBER,


X_MSG OUT VARCHAR2,
X_FLAG OUT VARCHAR2
)
IS
CURSOR cur_event--(p_org_id IN NUMBER)
IS
SELECT ppa.segment1 project_number,
ppa.org_id,
PPC.PPCA_NUMBER,
PPC.CUSTOMER_PC_NUMBER,
--(SELECT TASK_NUMBER FROM JAMBOQ.BOQ_PROJ_TASK_DEF_LN_T WHERE
TASK_DEF_ID=ppbrl.task_number)
NULL TASK_NUMBER,
-- ppbrl.task_name,
NULL task_name,
bill.pbr_number,
'AED' CURRENCY,
bill.EVENT_DATE,
bill.BILL_AMOUNT,
bill.EVENT_TYPE,
bill.ppbr_id,
PPA.project_id,
--ppc.CUSTOMER_PC_NUMBER,
bill.EVENT_NUMBER,
bill.REVENUE_AMOUNT
FROM JAMBOQ.BOQ_PROJ_PAYM_BILL_REQ_T bill,
PA_PROJECTS_ALL ppa,
JAMBOQ.BOQ_PROJ_PAYM_CERT_APPR_T PPC ,
JAMBOQ.BOQ_PROJ_PORTAL_HDR_T pph
--,jamboq.BOQ_PPBR_BOQ_LINE_T ppbrl
WHERE bill.project_id= pph.proj_portal_id
--and bill.ppbr_id =ppbrl.ppbr_id(+)
and pph.ebs_project_id=ppa.project_id
AND PPC.PPCA_ID=BILL.PPCA_ID
AND BILL.PPBR_ID=P_PPBR_ID
and NVL(bill.attribute20,'E')='E'
and bill.project_id is not null
--and pbr_status ='PSACRA'
ORDER BY bill.PPBR_ID;

l_error VARCHAR2 (300);


l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
l_return_status VARCHAR2 (10);
l_data VARCHAR2 (2000);
l_msg_index_out NUMBER;
l_event_in_tbl pa_event_pub.event_in_tbl_type;
l_event_out_tbl pa_event_pub.event_out_tbl_type;
ln_line_no NUMBER := 0;
l_ref_no varchar2(900);
l_rowcount NUMBER;
l_index NUMBER := 0;
l_reference VARCHAR2 (100);
l_event_id NUMBER;
l_status VARCHAR2 (100);
l_event_type pa_event_types.event_type%TYPE;
l_project_number pa_projects_all.segment1%TYPE;
l_org_name hr_all_organization_units.NAME%TYPE;
l_currency fnd_currencies.currency_code%TYPE;
l_task_number pa_tasks.task_number%TYPE:= NULL;
l_validation_flag VARCHAR2 (1);
l_validation_errors NUMBER := 0;
l_cursor_rowcount NUMBER;

ln_user_id NUMBER := fnd_profile.VALUE ('USER_ID');


ln_user_name fnd_user.user_name%TYPE;
ln_responsibility_id NUMBER := fnd_profile.VALUE ('RESP_ID');
ln_responsibility_name fnd_responsibility_tl.RESPONSIBILITY_NAME%TYPE;
ln_resp_appl_id NUMBER := fnd_profile.VALUE ('RESP_APPL_ID');
ln_org_id NUMBER;-- NVL (mo_global.get_current_org_id, fnd_profile.VALUE
('ORG_ID'));
ln_org_name hr_operating_units.name%TYPE;
l_project_currency_code fnd_currencies.currency_code%TYPE;
lv_err_msg VARCHAR2(4000);
lv_request_id NUMBER;
lc_phase VARCHAR2 (50);
l_req_return_status BOOLEAN;
-- lc_status VARCHAR2 (50);
lc_dev_phase VARCHAR2 (50);
lc_dev_status VARCHAR2 (50);
lc_message VARCHAR2 (50);
lc_status VARCHAR2 (50);

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;

exception when others then


DBMS_OUTPUT.PUT_LINE('Error while getting profile option values-User
Name/Responsibility Name/Operating Unit for the Org ID: '||ln_org_id);
end;*/

DBMS_OUTPUT.PUT_LINE('Logged in User: '||ln_user_name);


DBMS_OUTPUT.PUT_LINE('Responsibility Name: '||ln_responsibility_name);
DBMS_OUTPUT.PUT_LINE('Appl ID: '||ln_resp_appl_id);
DBMS_OUTPUT.PUT_LINE('Operating Unit: '||ln_org_name);
DBMS_OUTPUT.PUT_LINE('Org 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);

FOR l_cur_rec in cur_event


LOOP
mo_global.set_policy_context ('S',l_cur_rec.ORG_ID);
LV_PROJECT_ID:=l_cur_rec.project_id;

-- DBMS_OUTPUT.PUT_LINE('Number of rows fetched: '||cur%rowcount);


/* IF cur%rowcount = 0 THEN
-- l_cursor_rowcount := 0;
fnd_file.put_line
(fnd_file.LOG,'There are no records to fetch hence events have not created');
RETURN;
END IF;

exit when cur%notfound;*/

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;

pa_interface_utils_pub.set_global_info (p_api_version_number => 1.0,


p_responsibility_id => ln_responsibility_id,
p_user_id => ln_user_id,
p_operating_unit_id => ln_org_id,
p_msg_count => l_msg_count,
p_msg_data => l_msg_data,
p_return_status => l_return_status);

dbms_output.put_line('After set Global info l_return_status:'||l_return_status);


-- DBMS_OUTPUT.PUT_LINE('After set Global info l_return_status.');
SELECT jamboq_proj_event_ref_no_seq.NEXTVAL
INTO l_ref_no
FROM DUAL;

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;

------------------------ Project Number Validation


-------------------------------------------------------------
dbms_output.put_line('l_cur_rec.project_id:'||l_cur_rec.project_id) ;
IF l_cur_rec.project_id IS NOT NULL
THEN
BEGIN
SELECT segment1,project_currency_code
INTO l_project_number,l_project_currency_code
FROM pa_projects_all
WHERE project_id = l_cur_rec.project_id
and org_id = ln_org_id
-- and project_status_code in ('APPROVED','1002')
-- AND TRUNC (SYSDATE) BETWEEN start_date
--AND NVL (completion_date, SYSDATE)
;

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;

lv_err_msg :=lv_err_msg||':'|| 'Other error occured while validating Project


Number: '
|| l_cur_rec.project_number;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END;
ELSE
DBMS_OUTPUT.PUT_LINE(
'Project Number is NULL in the line: ' || ' and the PBR_Number: '||
l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END IF;

------------------------ Organixation Name Validation


------------------------------------------------------------

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;

lv_err_msg :=lv_err_msg||':'||'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;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END;
ELSE
DBMS_OUTPUT.PUT_LINE(
'Organization Name is NULL in the line: '
||l_cur_rec.PBR_NUMBER
);
l_validation_flag := 'N';
l_validation_errors := l_validation_errors + 1;

lv_err_msg :=lv_err_msg||':'|| 'Organization Name is NULL in the line: '


||l_cur_rec.PBR_NUMBER;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END IF;

------------------------- Currency Validation


-------------------------------------------------------------
dbms_output.put_line('l_cur_rec.currency:'||l_cur_rec.currency) ;
IF l_cur_rec.currency IS NOT NULL
THEN
-- Not validating billing currency with project functional currency because there
may be cases
BEGIN
SELECT currency_code
INTO l_currency
FROM fnd_currencies
WHERE TRUNC (SYSDATE) BETWEEN NVL(start_date_active,SYSDATE-1)
AND NVL (end_date_active, SYSDATE)
AND currency_code = l_cur_rec.currency;

-- 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;

lv_err_msg :=lv_err_msg||':'||'Currency is NULL in the line: ' || ' the


PBR_Number: '||l_cur_rec.PBR_NUMBER;
X_MSG:=lv_err_msg;
lv_err_msg:='E';
END IF;

------------------------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

IF l_cur_rec.task_number IS NOT NULL


THEN
BEGIN
SELECT task_number
INTO l_task_number
FROM pa_tasks
WHERE TRUNC (SYSDATE) BETWEEN start_date
AND NVL (completion_date, SYSDATE)
AND task_number = l_cur_rec.task_number
AND PROJECT_ID=l_cur_rec.project_id;

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);

ln_line_no :=1 ;--ln_line_no + 1;


l_event_in_tbl (ln_line_no).p_pm_event_reference :=l_cur_rec.PBR_NUMBER;--
l_ref_no;
-- l_event_in_tbl (ln_line_no).p_event_number:=l_cur_rec.Event_number;
l_event_in_tbl (ln_line_no).p_task_number := l_task_number;
l_event_in_tbl (ln_line_no).p_event_type := 'Scheduled Payment';--l_event_type;
l_event_in_tbl (ln_line_no).p_description :='Scheduled Payment' ||'-'||
l_cur_rec.CUSTOMER_PC_NUMBER;-- l_event_type;--l_cur_rec.PBR_NUMBER;
l_event_in_tbl (ln_line_no).p_completion_date := l_cur_rec.event_date;
-- l_event_in_tbl (ln_line_no).p_desc_flex_name := 'PA_EVENTS_DESC_FLEX';
--l_event_in_tbl (ln_line_no).P_attribute_category := 'Events';
-- l_event_in_tbl (ln_line_no).p_attribute1 := l_cur_rec.attribute1;
-- l_event_in_tbl (ln_line_no).p_attribute2 := l_cur_rec.attribute2;
l_event_in_tbl (ln_line_no).p_project_number := l_project_number;
l_event_in_tbl (ln_line_no).p_organization_name := l_org_name; -- Project owning
organization
l_event_in_tbl (ln_line_no).p_bill_trans_bill_amount := l_cur_rec.bill_amount;
l_event_in_tbl (ln_line_no).p_bill_trans_rev_amount :=l_cur_rec.revenue_amount;
l_event_in_tbl (ln_line_no).p_bill_trans_currency_code := 'AED';--l_currency;
l_event_in_tbl (ln_line_no).P_attribute9:=l_cur_rec.pbr_number;
-- Project Functional currency

DBMS_OUTPUT.PUT_LINE(' l_cur_rec.bill_amount '||l_cur_rec.bill_amount||'


l_cur_rec.revenue_amount '||l_cur_rec.revenue_amount);

dbms_output.put_line('l_validation_errors:'||l_validation_errors);
dbms_output.put_line('lv_err_msg:'||lv_err_msg);

-- IF l_cursor_rowcount <> 0 THEN


IF l_validation_errors = 0

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;

DBMS_OUTPUT.PUT_LINE('Events created successfully and updated the custom table');


X_FLAG:='S';
X_MSG:='Events created successfully and updated the custom table';

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
;

DBMS_OUTPUT.PUT_LINE( 'Program ends up with Error:'||substr(l_data,1,200));


DBMS_OUTPUT.put_line ('Program ends up with Error:'||substr(l_data,1,200));
X_MSG:=( 'Program ends up with Error:'||substr(l_data,1,200));
X_FLAG:='E';

END IF; --l_return_status = 'S'


ELSE -- l_validation_errors =0

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;

-- ELSE --l_rowcount <> 0


-- DBMS_OUTPUT.PUT_LINE('There are no records to fetch hence events have not
created');
-- END IF; --l_rowcount <> 0
/* 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);
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;

IF UPPER (lc_phase) = 'COMPLETED' AND UPPER (lc_status) = 'ERROR'


THEN
fnd_file.
put_line (
fnd_file.LOG,
'The Draft Release completed in error. Oracle request id: '
|| lv_request_id
|| ' '
|| SQLERRM);
ELSIF UPPER (lc_phase) = 'COMPLETED' AND UPPER (lc_status) = 'NORMAL'
THEN
fnd_file.
put_line (
fnd_file.LOG,
'The Draft Release request successful for request id: '
|| lv_request_id);

BEGIN

fnd_global.apps_initialize (user_id => 64169, --


fnd_profile.VALUE ('USER_ID'),
resp_id => 50324, --fnd_profile.VALUE
('RESP_ID'),
resp_appl_id => 275, --fnd_profile.VALUE
('RESP_APPL_ID'),
security_group_id => 0);

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

IF UPPER (lc_phase) = 'COMPLETED'


AND UPPER (lc_status) = 'ERROR'
THEN
fnd_file.
put_line (
fnd_file.LOG,
'Ar Action process completed in error. Oracle request id: '
|| lv_request_id
|| ' '
|| SQLERRM);

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;

ELSIF UPPER (lc_phase) = 'COMPLETED'


AND UPPER (lc_status) = 'NORMAL'
THEN
fnd_file.
put_line (
fnd_file.LOG,
'AR Action request successful for request id: '
|| lv_request_id);
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;
/

You might also like