Saturday 2 July 2011

O2C query in order management

select ooha.order_number,
       ooha.ordered_date,
       ooha.flow_status_code,
       oola.ordered_item,
       oola.ordered_quantity,
       oola.unit_selling_price,
       wdd.item_description,
       wdd.subinventory,
       wdd.released_status,
       wda.delivery_assignment_id,
       wnd.status_code,
       rcta.trx_number,
       rcta.trx_date,
       sum(rctla.extended_amount) amount,
       sum(rctla.tax_rate) tax_rate,
       araa.amount_applied,
       araa.gl_date,
       araa.application_type,
       araa.line_applied,
       araa.tax_applied,
       acra.currency_code,
       acra.receipt_number,
       acra.receipt_date,
       acrha.status
       --ooha.org_id
from oe_order_headers_all ooha,
     oe_order_lines_all oola,
     wsh_delivery_details wdd,
     wsh_delivery_assignments wda,
     wsh_new_deliveries wnd,
     ra_customer_trx_all rcta,
     ra_customer_trx_lines_all rctla,
     ar_receivable_applications_all araa,
     ar_cash_receipts_all acra,
     ar_cash_receipt_history_all acrha
where order_number='67284' and
      ooha.org_id=&organization_id
and ooha.header_id=oola.header_id
and ooha.header_id=wdd.source_header_id
and wdd.delivery_detail_id= wda.delivery_detail_id
and wda.delivery_id=wnd.delivery_id
and rcta.interface_header_attribute1=to_char(ooha.order_number)
and rcta.customer_trx_id=rctla.customer_trx_id
and rcta.customer_trx_id=araa.applied_customer_trx_id
and araa.cash_receipt_id=acra.cash_receipt_id
and acra.cash_receipt_id=acrha.cash_receipt_id
group by ooha.order_number,
       ooha.ordered_date,
       ooha.flow_status_code,
       oola.ordered_item,
       oola.ordered_quantity,
       oola.unit_selling_price,
       wdd.item_description,
       wdd.subinventory,
       wdd.released_status,
       wda.delivery_assignment_id,
       wnd.status_code,
       rcta.trx_number,
       rcta.trx_date,

      araa.amount_applied,
       araa.gl_date,
       araa.application_type,
       araa.line_applied,
       araa.tax_applied,
       acra.currency_code,
       acra.receipt_number,
       acra.receipt_date,
       acrha.status
      

No comments:

Post a Comment