select poh.object_id, prha.segment1 REQUISITION_NUMBER,
(Select name from apps.hr_operating_units where ORGANIZATION_ID = prha.org_id ) Circle_name,
(select max(wfn.notification_id)
from apps.wf_item_activity_statuses wias,
apps.wf_notifications wfn
where wias.notification_id is not null
and wias.notification_id = wfn.group_id
and wfn.status = 'OPEN'
and wias.item_type = 'REQAPPRV'
and wias.item_key in (select max(wi.item_key)
from apps.wf_items wi
where wi.parent_item_key = prha.wf_item_key
and end_date is null
)) Notification_id ,
poh.object_type_code,
poh.object_sub_type_code,
poh.sequence_num,
poh.action_code,
poh.action_date,
poh.employee_id,
papf.full_name
from apps.po_action_history poh, apps.per_all_people_f papf,apps.po_requisition_headers_all prha
where poh.object_type_code='REQUISITION'
and poh.employee_id = papf.person_id
and prha.requisition_header_id=poh.object_id
and prha.wf_item_key is not null
and sysdate between papf.effective_start_date and papf.effective_end_date
and poh.sequence_num = (select max(pah1.sequence_num) from apps.po_action_history pah1 where pah1.object_id = poh.object_id)
and exists (select '1' from apps.po_action_history where object_id = poh.object_id and action_code ='NO ACTION')
and poh.object_id in (select requisition_header_id from apps.po_requisition_headers_all where authorization_status ='IN PROCESS' and creation_date between '01-Mar-2019' and '14-Jun-2019')
union all
select poh.object_id, prha.segment1 po_NUMBER,
(Select name from apps.hr_operating_units where ORGANIZATION_ID = prha.org_id ) Circle_name,
(select max(wfn.notification_id)
from apps.wf_item_activity_statuses wias,
apps.wf_notifications wfn
where wias.notification_id is not null
and wias.notification_id = wfn.group_id
and wfn.status = 'OPEN'
and wias.item_type = 'POAPPRV'
and wias.item_key = (select max(wi.item_key)
from apps.wf_items wi
where wi.item_key = prha.wf_item_key )
) Notfication_id ,
poh.object_type_code,
poh.object_sub_type_code,
poh.sequence_num,
poh.action_code,
poh.action_date,
poh.employee_id,
papf.full_name
from apps.po_action_history poh, apps.per_all_people_f papf,apps.po_headers_all prha
where poh.object_type_code='PO'
and poh.employee_id = papf.person_id
and prha.po_header_id=poh.object_id
and prha.wf_item_key is not null
and sysdate between papf.effective_start_date and papf.effective_end_date
and poh.sequence_num = (select max(pah1.sequence_num) from apps.po_action_history pah1 where pah1.object_id = poh.object_id)
and exists (select '1' from apps.po_action_history where object_id = poh.object_id and action_code ='NO ACTION')
and poh.object_id in (select po_header_id from apps.po_headers_all where authorization_status ='IN PROCESS' and creation_date between '01-Mar-2019' and '14-Jun-2019')
order by 5,3,2,1;
No comments:
Post a Comment