Search This Blog

Monday, May 6, 2019

Oracle Apps R12 Customer Phone Number, Email and AR Invoice Details Query

SELECT
CUSTOMER_TRX_ID,SET_OF_BOOKS_ID,TRX_NUMBER,
TRX_DATE,
BILL_TO_CUSTOMER_ID,
fnd_conc_date.string_to_date(INTERFACE_HEADER_ATTRIBUTE12)ST_DT,
fnd_conc_date.string_to_date(INTERFACE_HEADER_ATTRIBUTE13)END_DT,
SUBSTR(INTERFACE_HEADER_ATTRIBUTE13,1,10) END_DATE,
INTERFACE_HEADER_ATTRIBUTE14,
RAC.ORG_ID,PARTY_NAME, ACCOUNT_NUMBER,
(select
     hcp.PHONE_COUNTRY_CODE||hcp.phone_number phone_number
  from apps.hz_cust_accounts hca
     , apps.hz_parties       hp
     , apps.hz_contact_points hcp
 where hca.party_id          = hp.party_id
   and hp.party_id          = hcp.owner_table_id
   and hcp.owner_table_name = 'HZ_PARTIES'
   and CONTACT_POINT_PURPOSE = 'BUSINESS'
   and hcp.contact_point_type = 'PHONE'
   and hca.CUST_ACCOUNT_ID = BILL_TO_CUSTOMER_ID
   )phone_number,
(select
     hcp.EMAIL_ADDRESS
  from apps.hz_cust_accounts hca
     , apps.hz_parties       hp
     , apps.hz_contact_points hcp
 where hca.party_id          = hp.party_id
   and hp.party_id          = hcp.owner_table_id
   and hcp.owner_table_name = 'HZ_PARTIES'
   and CONTACT_POINT_PURPOSE = 'BUSINESS'
   and hcp.contact_point_type = 'EMAIL'
    and hca.CUST_ACCOUNT_ID = BILL_TO_CUSTOMER_ID)Email_Address
FROM  RA_CUSTOMER_TRX_ALL RAC
      ,apps.hz_cust_accounts hca
     , apps.hz_parties       hp
WHERE
hca.CUST_ACCOUNT_ID = RAC.BILL_TO_CUSTOMER_ID
AND hca.party_id          = hp.party_id
AND RAC.ORG_ID = 145
AND RAC.CUST_TRX_TYPE_ID = 1001 --type_id ???????
AND RAC.BATCH_SOURCE_ID = 1003 --Source ???????
AND RAC.INTERFACE_HEADER_ATTRIBUTE12 IS NOT NULL --ST_DT
AND RAC.INTERFACE_HEADER_ATTRIBUTE13 IS NOT NULL --END_DT
AND TRX_NUMBER = '61843'

No comments:

Post a Comment