SELECT
ooha.header_id order_header_id,
ottt.NAME order_type_name,
ooha.order_number,
ooha.order_number,
ooha.ordered_date,
ooha.transactional_curr_code order_currency,
ooha.transactional_curr_code order_currency,
hp.party_id,
hp.party_number,
hp.party_number,
hp.party_name customer_name,
hca.cust_account_id customer_id,
hca.cust_account_id customer_id,
hca.account_number customer_number,
oola.line_id order_line_id,
oola.line_id order_line_id,
oola.line_number,
oola.inventory_item_id,
msib.segment1 item_number,
msib.segment1 item_number,
msib.description item_desc,
oola.attribute15 superseded_item,
oola.attribute15 superseded_item,
oola.order_quantity_uom,
oola.ordered_quantity,
oola.ordered_quantity,
oola.unit_selling_price
FROM OE_ORDER_HEADERS_ALL OOHA,
OE_ORDER_LINES_ALL OOLA,
OE_TRANSACTION_TYPES_TL OTTT,
MTL_SYSTEM_ITEMS_B MSIB,
MTL_PARAMETERS MP,
ORG_ORGANIZATION_DEFINITIONS OOD,
HZ_PARTIES HP,
HZ_CUST_ACCOUNTS HCA
WHERE ooha.header_id = oola.header_id
AND ottt.transaction_type_id(+) = ooha.order_type_id
AND ottt.LANGUAGE = USERENV ('LANG')
AND hca.cust_account_id(+) = ooha.sold_to_org_id
AND hp.party_id = hca.party_id
AND ooha.org_id = oola.org_id(+)
AND msib.inventory_item_id = oola.inventory_item_id
AND msib.organization_id = mp.master_organization_id
AND mp.organization_id = ood.organization_id
AND mp.master_organization_id = mp.organization_id
AND ood.operating_unit = fnd_profile.VALUE ('ORG_ID')
AND ooha.order_number = :P_sales_order_number;
FROM OE_ORDER_HEADERS_ALL OOHA,
OE_ORDER_LINES_ALL OOLA,
OE_TRANSACTION_TYPES_TL OTTT,
MTL_SYSTEM_ITEMS_B MSIB,
MTL_PARAMETERS MP,
ORG_ORGANIZATION_DEFINITIONS OOD,
HZ_PARTIES HP,
HZ_CUST_ACCOUNTS HCA
WHERE ooha.header_id = oola.header_id
AND ottt.transaction_type_id(+) = ooha.order_type_id
AND ottt.LANGUAGE = USERENV ('LANG')
AND hca.cust_account_id(+) = ooha.sold_to_org_id
AND hp.party_id = hca.party_id
AND ooha.org_id = oola.org_id(+)
AND msib.inventory_item_id = oola.inventory_item_id
AND msib.organization_id = mp.master_organization_id
AND mp.organization_id = ood.organization_id
AND mp.master_organization_id = mp.organization_id
AND ood.operating_unit = fnd_profile.VALUE ('ORG_ID')
AND ooha.order_number = :P_sales_order_number;