Nufarm: PO Action History Report

Description
Categories: Nufarm
select hou.name operating_unit,
obj.obj_id,
obj.obj_type_code,
obj.obj_sub_type_code,
obj.obj_number,
obj.amount,
obj.currency_code,
obj.sequence_num,
asp.vendor_name,
assa.vendor_site_code,
obj.action_code,
obj.action_date,
papf.global_name action_by,
xxen_util.meaning(obj.authorization_status,'DOCUMENT STATE',201) obj_status,
xxen_util.user_name(obj.obj_created_by) created_by,
xxen_util.client_time(obj.obj_creation_date) creation_date,
xxen_util.user_name(obj.obj_last_update_by) last_updated_by,
xxen_util.client_time(obj.obj_last_update_date) last_update_date
from 
( select 
  pah.object_id obj_id,
  pah.object_type_code obj_type_code,
  pah.object_sub_type_code obj_sub_type_code,
  pha.segment1 obj_number,
  (
  select round(sum(plla.quantity*pla.unit_price))
  from po_lines_all pla,
  po_line_locations_all plla
  where plla.po_header_id = pha.po_header_id
  and plla.po_line_id   = pla.po_line_id
  )amount,
  pha.currency_code,
  pah.sequence_num,
  pah.action_code,
  pah.employee_id,
  pah.action_date,
  pha.created_by obj_created_by,
  pha.creation_date obj_creation_date,
  pha.last_update_date obj_last_update_date,
  pha.last_updated_by obj_last_update_by,
  pha.vendor_id,
  pha.vendor_site_id,
  pha.org_id,
  pha.authorization_status
  from 
  po_headers_all pha,
  po_action_history pah
  where 2=2 and
  :object_type_code='PO' and
  pah.object_type_code='PO' and
  pah.object_id=pha.po_header_id
  union all
  select 
  pah.object_id obj_id,
  pah.object_type_code obj_type_code,
  pah.object_sub_type_code obj_sub_type_code,
  prha.segment1 obj_number,
  rdl.amount,
  rdl.currency_code,
  pah.sequence_num,
  pah.action_code,
  pah.employee_id,
  pah.action_date,
  prha.created_by obj_created_by,
  prha.creation_date obj_creation_date,
  prha.last_update_date obj_last_update_date,
  prha.last_updated_by obj_last_update_by,
  rdl.vendor_id,
  rdl.vendor_site_id,
  prha.org_id,
  prha.authorization_status
  from 
  po_requisition_headers_all prha,
  po_action_history pah,
  (select prla.requisition_header_id,
   max(prla.currency_code) currency_code,
   sum(prla.unit_price * prla.quantity) amount,
   max(prla.vendor_id) vendor_id,
   max(prla.vendor_site_id) vendor_site_id
   from po_requisition_lines_all prla
   group by prla.requisition_header_id
  ) rdl
  where 2=2 and
  :object_type_code='REQUISITION' and
  pah.object_id=prha.requisition_header_id and
  pah.object_type_code='REQUISITION' and
  rdl.requisition_header_id=prha.requisition_header_id
) obj,
  (select distinct papf.global_name,papf.person_id from per_all_people_f papf)papf,
  hr_operating_units hou,
  ap_suppliers asp,
  ap_supplier_sites_all assa
  where 1=1 and
  papf.person_id=obj.employee_id and
  hou.organization_id=obj.org_id and
  asp.vendor_id=obj.vendor_id and
  asp.vendor_id=assa.vendor_id and
  assa.vendor_site_id=obj.vendor_site_id
--  and obj.obj_number = '5180032146'
  order by obj.obj_id,obj.sequence_num
Parameter NameSQL textValidation
Operating Unit
hou.name=:operating_unit
LOV
Object Type
 
LOV
Object Number
obj.obj_number=:obj_number
LOV
Creation Date From
pah.creation_date >= :creation_date_from
Date
Creation Date To
pah.creation_date < :creation_date_to + 1
Date