SELECT
asp.segment1 "VENDOR_NUMBER"
,asp.vendor_name "VENDOR_NAME"
,ASP.VENDOR_NAME_ALT
,ASP.VENDOR_TYPE_LOOKUP_CODE "VENDOR_TYPE"
,ass.VENDOR_SITE_CODE "VENDOR_SITE"
,ATT.NAME"VENDOR_PAYMENT_TERMS"
,GLCC.CONCATENATED_SEGMENTS"LIABILITY_ACCOUNT"
,ass.ADDRESS_LINE1
,ass.city
,ass.state
--,ass.COUNTRY
,ftt.TERRITORY_SHORT_NAME "COUNTRY"
--,pty_rel.county
,ass.zip"ZIP_CODE"
,person.PERSON_NAME_SUFFIX "CONTACT_PREFIX"
,person.person_first_name "CONTACT_FIRST_NAME"
,person.person_first_name "CONTACT_MIDDLE_NAME"
,person.person_last_name "CONTACT_LAST_NAME"
,pty_rel.primary_phone_number "CONTACT_PHONE"
,pty_rel.primary_phone_number "CONTACT_MOBILE"
,pty_rel.email_address "CONTACT_EMAIL"
,''"CONTACT_FAX"
,'' "V_SUPP_FLAG"
,'' "V_SITE_FLAG"
,'' "V_CONTACT_FLAG"
,'' "SUPPLIER_ERROR_MESSAGE"
,'' "SITE_ERROR_MESSAGE"
,'' "CONTACT_ERROR_MESSAGE"
,'' "PKG_STATUS"
,'' "CREATED_BY"
,'' "CREATED_date"
,iepa.default_payment_method_code "DEFAULT_PMT_METHOD"
,ass.DUNS_NUMBER
,asp.PAY_DATE_BASIS_LOOKUP_CODE "PAY_DATE_BASIS"
,ass.ADDRESS_LINE2
,ass.ADDRESS_LINE3
,asp.ENFORCE_SHIP_TO_LOCATION_CODE "ENFORCE_SHIP_TO_LOCATION"
,ASP.RECEIPT_REQUIRED_FLAG "RECEIPT_ROUTING"
,ASP.MATCH_OPTION "MATCH_APPROVAL_LEVEL"
,asp.QTY_RCV_TOLERANCE "QUANTITY_RECEIVED_TOLERANCE"
,asp.QTY_RCV_EXCEPTION_CODE "QUANTITY_RECEIVED_EXCEPTION"
,'' "AREA_CODE"
,GLCCa.CONCATENATED_SEGMENTS "PREPAYMENT_ACCOUNT"
,ASS.INACTIVE_DATE
FROM ap_suppliers asp ,
ap_supplier_sites_all ass ,
ap_supplier_contacts apsc ,
hz_parties person ,
hz_parties pty_rel,
ap_terms_tl ATT,
GL_CODE_COMBINATIONS_KFV GLCC,
GL_CODE_COMBINATIONS_KFV GLCCa,
apps.iby_external_payees_all iepa,
fnd_territories_tl ftt
--hr_operating_units hou
WHERE ass.vendor_id = asp.vendor_id
AND apsc.per_party_id = person.party_id(+)
AND apsc.rel_party_id = pty_rel.party_id(+)
--AND ass.org_id = hou.organization_id
AND apsc.org_party_site_id(+) = ass.party_site_id
AND ASP.TERMS_ID=ATT.TERM_ID(+)
AND GLCC.CODE_COMBINATION_ID=ass.ACCTS_PAY_CODE_COMBINATION_ID
AND GLCCa.CODE_COMBINATION_ID=ass.PREPAY_CODE_COMBINATION_ID
and asp.party_id=iepa.payee_party_id
and ass.vendor_site_id(+)=iepa.supplier_site_id
and UPPER (TRIM (ftt.TERRITORY_CODE)) =UPPER (TRIM (ass.COUNTRY))
order by 1
asp.segment1 "VENDOR_NUMBER"
,asp.vendor_name "VENDOR_NAME"
,ASP.VENDOR_NAME_ALT
,ASP.VENDOR_TYPE_LOOKUP_CODE "VENDOR_TYPE"
,ass.VENDOR_SITE_CODE "VENDOR_SITE"
,ATT.NAME"VENDOR_PAYMENT_TERMS"
,GLCC.CONCATENATED_SEGMENTS"LIABILITY_ACCOUNT"
,ass.ADDRESS_LINE1
,ass.city
,ass.state
--,ass.COUNTRY
,ftt.TERRITORY_SHORT_NAME "COUNTRY"
--,pty_rel.county
,ass.zip"ZIP_CODE"
,person.PERSON_NAME_SUFFIX "CONTACT_PREFIX"
,person.person_first_name "CONTACT_FIRST_NAME"
,person.person_first_name "CONTACT_MIDDLE_NAME"
,person.person_last_name "CONTACT_LAST_NAME"
,pty_rel.primary_phone_number "CONTACT_PHONE"
,pty_rel.primary_phone_number "CONTACT_MOBILE"
,pty_rel.email_address "CONTACT_EMAIL"
,''"CONTACT_FAX"
,'' "V_SUPP_FLAG"
,'' "V_SITE_FLAG"
,'' "V_CONTACT_FLAG"
,'' "SUPPLIER_ERROR_MESSAGE"
,'' "SITE_ERROR_MESSAGE"
,'' "CONTACT_ERROR_MESSAGE"
,'' "PKG_STATUS"
,'' "CREATED_BY"
,'' "CREATED_date"
,iepa.default_payment_method_code "DEFAULT_PMT_METHOD"
,ass.DUNS_NUMBER
,asp.PAY_DATE_BASIS_LOOKUP_CODE "PAY_DATE_BASIS"
,ass.ADDRESS_LINE2
,ass.ADDRESS_LINE3
,asp.ENFORCE_SHIP_TO_LOCATION_CODE "ENFORCE_SHIP_TO_LOCATION"
,ASP.RECEIPT_REQUIRED_FLAG "RECEIPT_ROUTING"
,ASP.MATCH_OPTION "MATCH_APPROVAL_LEVEL"
,asp.QTY_RCV_TOLERANCE "QUANTITY_RECEIVED_TOLERANCE"
,asp.QTY_RCV_EXCEPTION_CODE "QUANTITY_RECEIVED_EXCEPTION"
,'' "AREA_CODE"
,GLCCa.CONCATENATED_SEGMENTS "PREPAYMENT_ACCOUNT"
,ASS.INACTIVE_DATE
FROM ap_suppliers asp ,
ap_supplier_sites_all ass ,
ap_supplier_contacts apsc ,
hz_parties person ,
hz_parties pty_rel,
ap_terms_tl ATT,
GL_CODE_COMBINATIONS_KFV GLCC,
GL_CODE_COMBINATIONS_KFV GLCCa,
apps.iby_external_payees_all iepa,
fnd_territories_tl ftt
--hr_operating_units hou
WHERE ass.vendor_id = asp.vendor_id
AND apsc.per_party_id = person.party_id(+)
AND apsc.rel_party_id = pty_rel.party_id(+)
--AND ass.org_id = hou.organization_id
AND apsc.org_party_site_id(+) = ass.party_site_id
AND ASP.TERMS_ID=ATT.TERM_ID(+)
AND GLCC.CODE_COMBINATION_ID=ass.ACCTS_PAY_CODE_COMBINATION_ID
AND GLCCa.CODE_COMBINATION_ID=ass.PREPAY_CODE_COMBINATION_ID
and asp.party_id=iepa.payee_party_id
and ass.vendor_site_id(+)=iepa.supplier_site_id
and UPPER (TRIM (ftt.TERRITORY_CODE)) =UPPER (TRIM (ass.COUNTRY))
order by 1