Sie sind auf Seite 1von 4

SELECT ooha.header_id, ooha.order_number, ott.

NAME "ORDER TYPE",


hp.party_name "CUSTOMER", hca.account_number "CUSTOMER NUMBER",
ooha.ordered_date "DATE ORDERED", qh.NAME "PRICE LIST",
ooha.transactional_curr_code "CURRENCY",
ooha.cust_po_number "CUSTOMER PO",
ooha.freight_carrier_code "SHIPPING METHOD",
ooha.flow_status_code "STATUS", rtt.NAME "PAYMENT TERMS",
mp.organization_code "WARE HOUSE", ol.meaning "FREIGHT TERMS",
ol1.meaning "SHIPMENT PRIORITY", al.meaning "FOB",
rsa.NAME "SALESPERSON",
hcsua.LOCATION
','
hl.address2
','
hl.city
','
hl.state
','
hl.postal_code
','
hl.county "BILL TO LOCATION",
hcsua1.LOCATION
','
hl1.address2
','
hl1.city
','
hl1.state
','
hl1.postal_code
','
hl1.county "SHIP TO LOCATION"
FROM oe_order_headers_all ooha,
oe_transaction_types_tl ott,
qp_list_headers qh,
ra_terms_tl rtt,
mtl_parameters mp,
ra_salesreps_all rsa,
hz_cust_accounts hca,
hz_parties hp,
hz_parties hp1,
hz_locations hl,
hz_locations hl1,
hz_cust_acct_sites_all hcasa,
hz_cust_acct_sites_all hcasa1,
hz_cust_site_uses_all hcsua,
hz_cust_site_uses_all hcsua1,
hz_party_sites hps,
hz_party_sites hps1,
oe_lookups ol,
oe_lookups ol1,
ar_lookups al
WHERE 1 = 1
AND ooha.order_number = 10265
AND ooha.sold_to_org_id = hca.cust_account_id
AND ooha.order_type_id = ott.transaction_type_id
AND ott.LANGUAGE = USERENV ('LANG')
AND rtt.LANGUAGE = USERENV ('LANG')
AND rtt.term_id = ooha.payment_term_id
AND qh.list_header_id = ooha.price_list_id
AND mp.organization_id = ooha.ship_from_org_id
AND ooha.salesrep_id = rsa.salesrep_id
AND hca.party_id = hp.party_id
AND hca.party_id = hp1.party_id
AND ooha.invoice_to_org_id = hcsua.site_use_id(+)
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id(+)
AND hcasa.party_site_id = hps.party_site_id(+)
AND hl.location_id(+) = hps.location_id
AND ooha.ship_to_org_id = hcsua1.site_use_id(+)
AND hcsua1.cust_acct_site_id = hcasa1.cust_acct_site_id(+)
AND hcasa1.party_site_id = hps1.party_site_id(+)
AND hl1.location_id(+) = hps1.location_id
AND ooha.freight_terms_code = ol.lookup_code
AND ooha.shipment_priority_code = ol1.lookup_code
AND al.lookup_code = ooha.fob_point_code;

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;

Das könnte Ihnen auch gefallen