[E-Bussiness Suite] Query PR which don't have PO R12


Description
    this is query to display PR with details line ,Cost center, last approver (action history) ,  which don't have PO, you can costumize this query that can display all PR which have or Not a PO.

How to 

select distinct prha.segment1 as PR_NUM
       ,prla.LINE_NUM
       ,gcc.SEGMENT3 as Cost_Center
       ,prla.ITEM_DESCRIPTION
       ,prla.QUANTITY
       ,prla.UNIT_PRICE
       ,prla.UNIT_PRICE * prla.QUANTITY as Total_Amount
       ,pha.SEGMENT1 as PO_NUM
       ,prha.CREATION_DATE as Tanggal_Buat_PR
       ,reqah.full_name req_last_approver
       ,reqah.action_date "Date PR Approver"
       ,prha.AUTHORIZATION_STATUS STATUS_PR
FROM    po.po_requisition_headers_all prha
        , po.po_requisition_lines_all prla
        , po.po_line_locations_all plla
        , po.po_lines_all pla
        , po_headers_all PHA
        , gl.gl_code_combinations gcc
        , po.po_req_distributions_all prda
        , (SELECT prha.requisition_header_id
           ,papf.full_name
           ,pah.action_code
           ,pah.object_id
           ,pah.ACTION_DATE
           FROM po.po_action_history pah
                      , po.po_requisition_headers_all prha
                      , applsys.fnd_user fu
                      , hr.per_all_people_f papf
                  WHERE prha.ORG_ID = '86'
                    --AND prha.segment1 = '8880'
                    AND pah.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
WHERE prha.ORG_ID = '86'
AND prha.AUTHORIZATION_STATUS = 'APPROVED'
--AND prha.segment1 = '8880'
AND prha.creation_date >= to_date('1/1/2014','dd/mm/yyyy')
AND prha.creation_date <= to_date('12/8/2014','dd/mm/yyyy')
AND prha.requisition_header_id = prla.requisition_header_id
--linking to action history (reqah) based on header PR / PO
AND reqah.requisition_header_id = prha.requisition_header_id
--distribution always linking to Line ID
AND prda.REQUISITION_LINE_ID = prla.REQUISITION_LINE_ID
--if line location is Null then the PO doesn't exist, if exist then PO exist too.
AND plla.line_location_id is null
AND prla.line_location_id = plla.line_location_id(+)
AND plla.po_header_id = pla.po_header_id(+)
AND pla.po_header_id = pha.po_header_id(+)
AND gcc.CODE_COMBINATION_ID = prda.CODE_COMBINATION_ID
-- select your cost center , this is optional you can comment it if you want display all cost center
AND gcc.SEGMENT3 in ('000','001')
order by prha.segment1,prla.line_num, gcc.SEGMENT3 asc

Post a Comment

Harap gunakan bahasa yang baik dan sopan, terima kasih