/* Formatted on 21-Apr-15 12:00:02 PM (QP5 v5.114.809.3010) */
SELECT DISTINCT prha.segment1 req,
prha.DESCRIPTION ,
AUTHORIZATION_STATUS,
papf.full_name req_raised_by,
reqah.full_name req_last_approver,
DECODE (AUTHORIZATION_STATUS,
'APPROVED',
NULL,
'IN PROCESS',
reqah1.full_name,
NULL)
pending_with
FROM po.po_requisition_headers_all prha,
po.po_requisition_lines_all prla,
hr.per_all_people_f papf,
(SELECT papf.full_name, pah.action_code, pah.object_id
FROM po.po_action_history pah,
po.po_requisition_headers_all prha,
applsys.fnd_user fu,
hr.per_all_people_f papf
WHERE object_id = prha.requisition_header_id
AND pah.employee_id = fu.employee_id
AND fu.employee_id = papf.person_id
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND pah.object_type_code = 'REQUISITION'
AND pah.action_code = 'APPROVE'
AND pah.sequence_num =
(SELECT MAX (sequence_num)
FROM po.po_action_history pah1
WHERE pah1.object_id = pah.object_id
AND pah1.object_type_code = 'REQUISITION'
AND pah1.action_code = 'APPROVE')) reqah,
(SELECT DISTINCT papf.full_name, pah.action_code, pah.object_id
FROM po.po_action_history pah,
po.po_requisition_headers_all prha,
applsys.fnd_user fu,
hr.per_all_people_f papf
WHERE prha.requisition_header_id = object_id
AND prha.requisition_header_id = pah.OBJECT_ID
AND pah.employee_id = fu.employee_id
AND fu.employee_id = papf.person_id
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND pah.object_type_code = 'REQUISITION'
AND pah.sequence_num =
(SELECT MAX (sequence_num)
FROM po.po_action_history pah1
WHERE pah1.object_id = pah.object_id
AND pah1.object_type_code = 'REQUISITION')) reqah1
WHERE prha.requisition_header_id = prla.requisition_header_id
AND reqah.object_id = prha.requisition_header_id
AND reqah1.object_id = prha.requisition_header_id
AND prha.preparer_id = papf.person_id
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND prha.creation_date >= :start_date
AND prha.creation_date <= :end_date
AND prha.ORG_ID = :org_id -- in (611 , 612 , 613,614 , 615 , 616 , 617)
-- AND prha.segment1 = 1531610037
ORDER BY 3 desc
select * from hr_operating_units
No comments:
Post a Comment