Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Synopses:

The purpose of this alert report is to check if any employee leave is starting today (sysdate) than send
email notification to his manager with leave details. Notification is like: (variables are bold case)

Subject: Leave type for Employee Name started today (leave start date)

Email body:
Dear Manager Name,

Please be informed that Leave Type for Employee Name is started today with hereunder information:

Name Start Date End Date Duration Notification Return Date Remarks Status
Date
Employee 04-09-2016 08-09-2016 5 28-07-2016 18-09-2016 In Progress
Name

Best Regards,

1. Create data model:

Query: The important clause is “AND trunc(abs.start_date) = trunc(sysdate)” it will make sure
that leave is starting today:
SELECT
emp_name.first_name||' '||emp_name.last_name full_name, sup_name.first_name||'
'||sup_name.last_name sup_name,sup_email.email_address,TYP.NAME leave,
ABS.DURATION,
to_char(abs.start_Date,'DD-Mon-yyyy') start_date,
to_char(abs.end_Date,'dd-Mon-yyyy') end_date,
to_char(nvl(submitted_date,notification_date),'dd-Mon-yyyy') notification_DAte,
to_char(abs.ATTRIBUTE_DATE1,'dd-Mon-yyyy') ret_dt,
abs.ATTRIBUTE1 rem,

initcap(DECODE(abs.ABSENCE_STATUS_CD , 'SUBMITTED'
,DECODE(abs.APPROVAL_STATUS_CD,
'APPROVED',DECODE(abs.ABSENCE_STATUS_CD
, 'SUBMITTED' ,DECODE(SIGN(trunc(to_date(sysdate))-trunc(END_DATETIME)),
1,'COMPLETED',0,'INPROGRESS',DECODE(SIGN(trunc(START_DATETIME)-
trunc(to_date(sysdate))),1,
'SCHEDULED','IN PROGRESS'))),'DENIED','DENIED', 'AWAITING' ),
'ORA_WITHDRAWN',DECODE(abs.APPROVAL_STATUS_CD,'APPROVED','CANCELE
D','ORA_WDRWL_PEND'),
ABSENCE_STATUS_CD )) as ABSENCE_DISP_STATUS_CD

FROM ANC_PER_ABS_ENTRIES Abs ,


ANC_ABSENCE_TYPES_VL TYP,
per_person_names_f emp_name,
per_all_assignments_m emp_asg,
per_assignment_supervisors_f sup_asg,
per_person_names_f sup_name,
per_email_addresses sup_email
WHERE emp_name.person_id = abs.person_id
AND abs.APPROVAL_STATUS_CD = 'APPROVED'
AND emp_name.name_type = 'GLOBAL'
and trunc(sysdate) between typ.effective_start_date and typ.effective_end_date
and emp_asg.person_id= abs.person_id
AND emp_asg.assignment_type = 'E'
AND emp_asg.primary_flag = 'Y'
and trunc(sysdate) between emp_name.effective_start_Date and
emp_name.effective_end_date
and trunc(sysdate) between emp_asg.effective_start_Date and emp_asg.effective_end_date
and sup_asg.assignment_id = emp_asg.assignment_id
and sup_asg.manager_id = sup_name.person_id
and sup_name.name_type(+) = 'GLOBAL'
and trunc(sysdate) between sup_asg.effective_start_Date and sup_asg.effective_end_date
and trunc(sysdate) between sup_name.effective_start_Date and sup_name.effective_end_date
AND sup_email.person_id(+)= sup_asg.manager_id
AND sup_email.email_type(+)= 'W1'
and ABS.ABSENCE_TYPE_ID = TYP.ABSENCE_TYPE_ID
AND trunc(abs.start_date) = trunc(sysdate)
and abs.ABSENCE_STATUS_CD = 'SUBMITTED'
and abs.APPROVAL_STATUS_CD = 'APPROVED'

2. Create Bursting for Data Model:


Split By: EMAIL_ADDRESS (manager email address from data model)

Deliver By: EMAIL_ADDRESS (manager email address from data model)

SQL Query:

SELECT

sup_email.email_address KEY,

'Notification Template' TEMPLATE,

'RTF' TEMPLATE_FORMAT,

'en-US' as LOCALE,

'HTML' as OUTPUT_FORMAT,

'EMAIL' as DEL_CHANNEL,

sup_email.email_address as PARAMETER1,

'shahzad.ali@salic.com' as PARAMETER8,

'bipublisher-report@oracle.com' as PARAMETER3,

Initcap(TYP.NAME)||' for '||emp_name.first_name||' '||emp_name.last_name||' started today


('||to_char(abs.start_Date,'DD-Mon-yyyy')||')' as PARAMETER4,

'false' as PARAMETER6,

'shahzad.ali@salic.com' as PARAMETER7

FROM ANC_PER_ABS_ENTRIES Abs ,

ANC_ABSENCE_TYPES_VL TYP,

per_person_names_f emp_name,

per_all_assignments_m emp_asg,

per_assignment_supervisors_f sup_asg,

per_person_names_f sup_name,

per_email_addresses sup_email

WHERE emp_name.person_id = abs.person_id

AND abs.APPROVAL_STATUS_CD = 'APPROVED'

AND emp_name.name_type = 'GLOBAL'

and emp_asg.person_id= abs.person_id

AND emp_asg.assignment_type = 'E'


AND emp_asg.primary_flag = 'Y'

and trunc(sysdate) between emp_name.effective_start_Date and emp_name.effective_end_date

and trunc(sysdate) between emp_asg.effective_start_Date and emp_asg.effective_end_date

and sup_asg.assignment_id = emp_asg.assignment_id

and sup_asg.manager_id = sup_name.person_id

and sup_name.name_type(+) = 'GLOBAL'

and trunc(sysdate) between sup_asg.effective_start_Date and sup_asg.effective_end_date

and trunc(sysdate) between sup_name.effective_start_Date and sup_name.effective_end_date

AND sup_email.person_id(+)= sup_asg.manager_id

AND sup_email.email_type(+)= 'W1'

and ABS.ABSENCE_TYPE_ID = TYP.ABSENCE_TYPE_ID

/*AND upper(TYP.NAME) ='ANNUAL LEAVE'

and abs.person_id = 300000006318107*/

AND trunc(abs.start_date) = trunc(sysdate)

and abs.ABSENCE_STATUS_CD = 'SUBMITTED'

and abs.APPROVAL_STATUS_CD = 'APPROVED'

Things to be noted:

3. Create the report on the basis of this data model with rtf template:
Notification
Template.rtf
Template:

4. Enable the report Bursting, open report properties:


5. Create the Report Job to schedule this report every day at 7:30 am:

a. Select the report which need to be scheduled:

b. Give the schedule information (Frequency, start date and end date)
6. You can monitor the information about report execution from report
history or job history:
a. BI home page click on Report Job:

b. Click on history to view the job history


One problem is if no record is retrieved (no leave is entered for today) then report job is showing error:

Job processor caused exception


[INSTANCE_ID=nlfsn1xhen04.nldc1.oraclecloud.com.1471554406742]
[INSTANCE_JOB_ID=12679]::oracle.xdo.servlet.scheduler.ProcessingException:
::DATA_PROCESSING_FAILED::[INSTANCE_ID=nlfsn1xhen04.nldc1.oraclecloud.com.14
71554406742]
There is no data to process
[INSTANCE_ID=nlfsn1xhen04.nldc1.oraclecloud.com.1471554406742]
oracle.xdo.servlet.scheduler.ProcessingException:
There is no data to process
[INSTANCE_ID=nlfsn1xhen04.nldc1.oraclecloud.com.1471554406742]
at oracle.xdo.enterpris

I had seen this can be handled with Job Trigger but system is not saving the data model. Need to check
with Oracle for this issue. Otherwise it is working fine.

You might also like