SELECT ma.book_type_code AS book,
ma.posting_status AS queue_name,
TRIM(TO_CHAR(ma.Payables_cost, '99999999.00')) AS cost,
ma.invoice_number,
b.line_number AS invoice_line_number,
CASE WHEN b.quantity_invoiced IS NOT NULL THEN b.quantity_invoiced ELSE 1 END AS units,
b.description,
gcc.segment4 AS acct,
TO_CHAR(ma.create_batch_date, 'MM-DD-YYYY') AS ma_create_date ,
ma.invoice_id,
ma.feeder_system_name AS source,
SYSDATE AS run_dt,
'X' KEY
FROM fa_mass_additions ma,
ap_invoices_all a,
ap_invoice_lines_all b,
ap_invoice_distributions_all c,
gl_code_combinations gcc
WHERE a.invoice_id = b.invoice_id
AND b.invoice_id = c.invoice_id
AND b.line_number = c.invoice_line_number
AND gcc.code_combination_id = c.DIST_CODE_COMBINATION_ID
AND b.invoice_id = ma.invoice_id
AND b.line_number = ma.invoice_line_number
AND ma.posting_status = 'NEW'
AND ma.fixed_assets_cost != 0
AND ma.feeder_system_name = 'ORACLE PAYABLES'
AND gcc.segment4 = '164100'
ORDER BY ma.book_type_code DESC, ma.invoice_number, b.line_number
No comments:
Post a Comment