Beruflich Dokumente
Kultur Dokumente
SELECT
ooh.order_number,
ooh.flow_status_code headerstatus,
ooh.ordered_date order_date,
ott.name order_type,
hp.party_number customer_number,
hp.party_name customer_name,
qlht.name pricelist_name,
rsa.name salesrep_name,
hcsu1.location cust_shipto_loc,
hl1.address1 shipto_address,
hl1.city shipto_city,
hl1.postal_code shipto_postal_code,
hcsu2.location cust_billto_loc,
hl2.address1 billto_address,
hl2.city billto_city,
hl2.postal_code billto_postal_code,
ool.ordered_item,
ool.ordered_quantity,
ool.order_quantity_uom uom,
ool.unit_selling_price unit_price,
ool.flow_status_code linestatus,
wdd.released_status released_status,
wda.delivery_id deliveryid,
wnd.delivery_type deliverytype,
rcta.trx_number invoiceno,
rcta.trx_date invoicedate,
rctla.line_type,
araa.amount_applied invoice_amount,
acra.receipt_number receiptno,
acra.receipt_date receiptdate,
acra.amount receiptamount,
acra.type receipttype,
apsa.amount_applied paymentamount,
hcaa.account_number acctno,
hcaa.account_name acctname
FROM
oe_order_headers_all ooh,
oe_order_lines_all ool,
oe_transaction_types_tl ott,
hz_parties hp,
qp_list_headers_tl qlht,
ra_salesreps_all rsa,
hz_party_sites hps,
hz_cust_acct_sites_all hcas1,
hz_cust_site_uses_all hcsu1,
hz_locations hl1,
hz_cust_acct_sites_all hcas2,
hz_cust_site_uses_all hcsu2,
hz_locations hl2,
mtl_system_items_b msib,
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_payment_schedules_all apsa,
hz_cust_accounts_all hcaa
WHERE
ooh.org_id = 204
AND
ooh.order_number = 15025
AND
ooh.header_id = ool.header_id
AND
ooh.order_type_id = ott.transaction_type_id
AND
ooh.sold_to_org_id = hp.party_id
AND
ooh.price_list_id = qlht.list_header_id
AND
ooh.salesrep_id = rsa.salesrep_id --AND HP.PARTY_ID=HPS.PARTY_IDAND
HPS.PARTY_SITE_ID=HCAS1.PARTY_SITE_ID
AND
hcas1.cust_acct_site_id = hcsu1.cust_acct_site_id
AND
ooh.ship_to_org_id = hcsu1.site_use_id
AND
hps.location_id = hl1.location_id
AND
hps.party_site_id = hcas2.party_site_id
AND
hcas2.cust_acct_site_id = hcsu2.cust_acct_site_id
AND
ooh.ship_to_org_id = hcsu2.site_use_id
AND
hps.location_id = hl2.location_id
AND
ool.inventory_item_id = msib.inventory_item_id
AND
ool.org_id = msib.organization_id
AND
wdd.source_header_id = ooh.header_id --AND WDD.SOURCE_LINE_ID=OOL.LINE_ID
AND
wdd.delivery_detail_id = wda.delivery_detail_id
AND
wda.delivery_id = wnd.delivery_id
AND
rcta.customer_trx_id = rctla.customer_trx_id
AND
rcta.interface_header_attribute1 = TO_CHAR(ooh.order_number)
AND
rctla.interface_line_attribute6 = TO_CHAR(ool.line_id)
AND
araa.applied_customer_trx_id = rcta.customer_trx_id
AND
araa.cash_receipt_id = acra.cash_receipt_id
AND
araa.applied_payment_schedule_id = apsa.payment_schedule_id
AND
acra.pay_from_customer = hcaa.cust_account_id;