Monday 23 June 2014

AR to GL link in R12

SELECT ooha.order_number,
       oola.line_number,
       wdd.source_header_type_name,
       wnd.name,
       rcta.trx_number,
       xlate.transaction_number,
       b.name batch_name,
       b.description batch_description,
       h.je_category,
       h.je_source,
       h.period_name je_period_name,
       h.name journal_name,
       h.status journal_status,
       h.description je_description
FROM -- Create Sales Order --
     oe_order_headers_all ooha,
     oe_order_lines_all oola,
     -- Book the Sales Order --
     wsh_delivery_details wdd,
     wsh_delivery_assignments wda,
     wsh_new_deliveries wnd,
     -- Enter Invoices in Receivables --
     ra_customer_trx_all rcta,
     -- Sub ledger accounting --
     xla.xla_transaction_entities xlate,
     xla_events xlae,
     xla_ae_headers xlah,
     xla_ae_lines xlal,
     -- GL --
     gl_import_references gir,
     gl_code_combinations_kfv glcc,
     gl_je_lines l,
     gl_je_headers h,
     gl_je_batches b
WHERE     1 = 1
      -- Create Sales Order --
      AND ORDER_NUMBER = '601694' --  (OR)  AND trx_number = '1715'
      AND ooha.header_id = oola.header_id
      -- Book the Sales Order --
      AND oola.line_id = wdd.source_line_id
      AND wdd.delivery_detail_id = wda.delivery_detail_id
      AND wda.delivery_id = wnd.delivery_id
      -- Enter Invoices in Receivables --
      AND TO_CHAR (ooha.order_number) = rcta.interface_header_attribute1
          -- Sub ledger accounting --
      AND rcta.trx_number = xlate.transaction_number
      AND xlae.application_id = xlate.application_id
      AND xlae.entity_id = xlate.entity_id
      AND xlah.event_id = xlae.event_id
      AND xlal.ae_header_id = xlah.ae_header_id
      -- GL --
      --Like Between Sub Ledger to GL --
      AND gir.gl_sl_link_table = xlal.gl_sl_link_table
      AND gir.gl_sl_link_id = xlal.gl_sl_link_id
      AND xlal.code_combination_id = glcc.code_combination_id
      --Like Between Sub Ledger to GL --
      AND l.je_header_id = gir.je_header_id
      AND l.je_line_num = gir.je_line_num
      AND h.je_header_id = l.je_header_id
      AND b.je_batch_id = h.je_batch_id
      AND h.je_source = 'Receivables'
      AND h.period_name = '12-07'
ORDER BY line_number

No comments:

Post a Comment