Pages

Friday, January 31, 2014

GL Query for Inventory(source) - Receiving(category)

SELECT   msib.segment1 item, msib.description, pha.segment1 po_num,
        rsh.receipt_num, hp.party_number, hp.party_name, xal.accounted_dr,
        xal.accounted_cr , gjh.je_source, gjh.je_category
   FROM apps.gl_je_headers gjh,
        apps.gl_je_lines gjl,
        apps.gl_je_batches gjb,
        apps.gl_import_references gir,
        xla.xla_ae_lines xal,
        xla.xla_ae_headers xah,
        xla.xla_transaction_entities xte,
        apps.gmf_rcv_accounting_txns grat,
        apps.rcv_transactions rt,
        apps.po_headers_all pha,
        apps.rcv_shipment_lines rsl,
        apps.rcv_shipment_headers rsh,
        apps.po_vendors po,
        apps.hz_parties hp,
        apps.mtl_system_items_b msib,
        apps.gl_code_combinations gcc,
        apps.mtl_parameters mp
  WHERE gjh.je_header_id = gjl.je_header_id
    AND gjh.je_header_id = gir.je_header_id
    AND gir.je_header_id = gjl.je_header_id
    AND gir.je_line_num = gjl.je_line_num
    AND gjb.je_batch_id = gir.je_batch_id
    AND gjh.je_source = 'Inventory'
    AND gjh.je_category = 'Receiving'
    AND gir.gl_sl_link_id = xal.gl_sl_link_id
    AND xal.ae_header_id = xah.ae_header_id
    AND gjl.code_combination_id = gcc.code_combination_id
    AND xah.entity_id = xte.entity_id
    AND xte.source_id_int_1 = grat.accounting_txn_id
    AND grat.rcv_transaction_id = rt.transaction_id
    AND rsl.shipment_line_id = rt.shipment_line_id
    AND rsl.shipment_header_id = rt.shipment_header_id
    AND rsh.shipment_header_id = rsl.shipment_header_id
    AND rsh.shipment_header_id = rt.shipment_header_id
    AND rsh.vendor_id = po.vendor_id
    AND po.party_id = hp.party_id
    AND rsl.item_id = msib.inventory_item_id
    AND rt.organization_id = msib.organization_id
    AND mp.organization_id = rt.organization_id
    AND pha.po_header_id = rt.po_header_id
    and gcc.segment4 in (3021000, 3021100)--, 3021700, 3023000, 3023100)
    and gcc.segment3 in (102099)
    and gcc.segment2  in (000)
    and gjl.period_name in (select distinct period_name from apps.gl_periods where start_date between :p_from_per and :p_to_per)
ORDER BY rsh.receipt_num 

No comments:

Post a Comment