select
PS.segment1 Supplier_Number,
pvs.vendor_Site_id Supplier_Site_Id,
pvs.vendor_site_code Supplier_Site_Code,
IEBA.EXT_BANK_ACCOUNT_ID Bank_Account_Id,
ieba.BANK_ACCOUNT_NUM Bank_Account_No,
TO_cHAR(ieba.START_DATE,'yyyy-MM-dd') Bank_Account_Start_Date,
TO_cHAR(ieba.end_DATE,'yyyy-MM-dd') Bank_Account_end_Date,
decode(hp_bank.STATus,'A','Y','I','N',hp_bank.STATus) Bank_Active_Status,
hp_branch.Party_Name Bank_Branch_Name,
hp_branch.CITY Bank_City,
hp_branch.COUNTRY Bank_Country_Code ,
hp_bank.PArty_Name Bank_Name,
hp_branch.ADDRESS1 Bank_Street1,
hp_branch.ADDRESS2 Bank_Street2,
hp_branch.ADDRESS3 Bank_Street3,
ieba.BANK_ACCOUNT_NAME Bank_Account_Name,
hp_branch.ADDRESS4 Bank_Name_Alt ,
ieba.CURRENCY_CODE Currency,
ieba.iban Iban_No,
hp_branch.CITY Local_Bank_City,
hp_bank.PArty_Name Local_Bank_Name,
null Order_of_Preference,
null Partner_Bank_Type,
ieba.EFT_SWIFT_CODE Swift_Code,
ieba.last_update_date,
ieba.attribute1 Temp_1,
ieba.attribute2 Temp_2,
ieba.attribute3 Temp_3,
ieba.attribute4 Temp_4,
ieba.attribute5 Temp_5,
ieba.attribute6 Temp_6,
ieba.attribute7 Temp_7,
ieba.attribute8 Temp_8,
ieba.attribute9 Temp_9,
ieba.attribute10 Temp_10
from
poz_suppliers PS,
poz_supplier_sites_all_m pvs,
hz_parties hp,
hr_organization_units_f_tl hout,
iby_external_payees_all iepa,
iby_pmt_instr_uses_all ipiua,
iby_ext_bank_accounts ieba,
--hz_party_sites bank_address,
--hz_locations hl,
hz_parties hp_bank ,
hz_parties hp_branch
where ps.vendor_id = pvs.vendor_id
--AND ps.enabled_flag ='Y'
--AND nvl(ps.end_Date_Active, sysdate+1) >= sysdate
--AND nvl(pvs.EFFECTIVE_END_DATE,sysdate+1) >= sysdate
and ps.party_id=hp.party_id
and pvs.prc_bu_id=hout.organization_id
and hout.LANGUAGE = USERENV('LANG')
and iepa.payee_party_id = PS.party_id
--and trunc(IEPA.end_Date) >= trunc(sysdate)
and pvs.party_site_id=iepa.party_site_id
and iepa.supplier_Site_id= pvs.vendor_Site_id
and ipiua.ext_pmt_party_id = IEPA.ext_payee_id
--and trunc(ipiua.end_Date) >= trunc(sysdate)
and ieba.ext_bank_account_id = ipiua.instrument_id
--and pvs.party_site_id = bank_address.party_site_id
--and bank_address.location_id=hl.location_id
and ieba.bank_id = hp_bank.party_id
and ieba.branch_id = hp_branch.party_id
and hout.name = NVL(:P_BU_NAME,hout.name)
--and pvs.vendor_Site_id=300000185706839
and ieba.OBJECT_VERSION_NUMBER
IN(
select max(OBJECT_VERSION_NUMBER) from iby_ext_bank_accounts ieba1
where ieba1.ext_bank_account_id = ieba.ext_bank_account_id
and ieba1.bank_id = ieba.bank_id
)
and EXISTS
(
select 1 from POZ_SITE_ASSIGNMENTS_ALL_M psaa
where psaa.VENDOR_SITE_ID = pvs.VENDOR_SITE_ID
and psaa.bu_id= pvs.PRC_BU_ID
-- and nvl(psaa.EFFECTIVE_END_DATE,sysdate+1) >= sysdate
)
and trunc(ieba.last_update_date) between nvl(:P_FROM_DATE,trunc(ieba.last_update_date)) and nvl(:P_END_DATE,trunc(ieba.last_update_date))
UNION ALL
select
(select 'Oracle-'|| instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||PS.segment1||'-'||IEBA.EXT_BANK_ACCOUNT_ID AP_External_Key__c,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) Source_System,
(select 'Oracle-'||instance_name||'-'||to_Char(sysdate,'yyyymmddhhmmss') from gv$instance where INSTANCE_NUMBER =1) Batch_Id,
NULL Company_Code_Unique_Key,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||PS.segment1 Supplier_Unique_Key,
PS.segment1 Supplier_Number,
NULL Supplier_Site_Id,
NULL Supplier_Site_Code,
IEBA.EXT_BANK_ACCOUNT_ID Bank_Account_Id,
ieba.BANK_ACCOUNT_NUM Bank_Account_No,
TO_cHAR(ieba.START_DATE,'yyyy-MM-dd') Bank_Account_Start_Date,
TO_cHAR(ieba.end_DATE,'yyyy-MM-dd') Bank_Account_end_Date,
decode(hp_bank.STATus,'A','Y','I','N',hp_bank.STATus) Bank_Active_Status,
hp_branch.Party_Name Bank_Branch_Name,
hp_branch.CITY Bank_City,
hp_branch.COUNTRY Bank_Country_Code ,
hp_bank.PArty_Name Bank_Name,
hp_branch.ADDRESS1 Bank_Street1,
hp_branch.ADDRESS2 Bank_Street2,
hp_branch.ADDRESS3 Bank_Street3,
ieba.BANK_ACCOUNT_NAME Bank_Account_Name,
hp_branch.ADDRESS4 Bank_Name_Alt ,
ieba.CURRENCY_CODE Currency,
ieba.iban Iban_No,
hp_branch.CITY Local_Bank_City,
hp_bank.PArty_Name Local_Bank_Name,
null Order_of_Preference,
null Partner_Bank_Type,
ieba.EFT_SWIFT_CODE Swift_Code,
ieba.last_update_date,
ieba.attribute1 Temp_1,
ieba.attribute2 Temp_2,
ieba.attribute3 Temp_3,
ieba.attribute4 Temp_4,
ieba.attribute5 Temp_5,
ieba.attribute6 Temp_6,
ieba.attribute7 Temp_7,
ieba.attribute8 Temp_8,
ieba.attribute9 Temp_9,
ieba.attribute10 Temp_10
from
poz_suppliers PS,
--poz_supplier_sites_all_m pvs,
hz_parties hp,
--hr_organization_units_f_tl hout,
iby_external_payees_all iepa,
iby_pmt_instr_uses_all ipiua,
iby_ext_bank_accounts ieba,
--hz_party_sites bank_address,
--hz_locations hl,
hz_parties hp_bank ,
hz_parties hp_branch
where 1=1
and ps.party_id=hp.party_id
and iepa.payee_party_id = PS.party_id
--and trunc(IEPA.end_Date) >= trunc(sysdate)
and iepa.party_site_id is null
and ipiua.ext_pmt_party_id = IEPA.ext_payee_id
--and trunc(ipiua.end_Date) >= trunc(sysdate)
and ieba.ext_bank_account_id = ipiua.instrument_id
--and pvs.party_site_id = bank_address.party_site_id
--and bank_address.location_id=hl.location_id
and ieba.bank_id = hp_bank.party_id
and ieba.branch_id = hp_branch.party_id
and ieba.OBJECT_VERSION_NUMBER
IN(
select max(OBJECT_VERSION_NUMBER) from iby_ext_bank_accounts ieba1
where ieba1.ext_bank_account_id = ieba.ext_bank_account_id
and ieba1.bank_id = ieba.bank_id
)
and trunc(ieba.last_update_date) between nvl(:P_FROM_DATE,trunc(ieba.last_update_date)) and nvl(:P_END_DATE,trunc(ieba.last_update_date))
PS.segment1 Supplier_Number,
pvs.vendor_Site_id Supplier_Site_Id,
pvs.vendor_site_code Supplier_Site_Code,
IEBA.EXT_BANK_ACCOUNT_ID Bank_Account_Id,
ieba.BANK_ACCOUNT_NUM Bank_Account_No,
TO_cHAR(ieba.START_DATE,'yyyy-MM-dd') Bank_Account_Start_Date,
TO_cHAR(ieba.end_DATE,'yyyy-MM-dd') Bank_Account_end_Date,
decode(hp_bank.STATus,'A','Y','I','N',hp_bank.STATus) Bank_Active_Status,
hp_branch.Party_Name Bank_Branch_Name,
hp_branch.CITY Bank_City,
hp_branch.COUNTRY Bank_Country_Code ,
hp_bank.PArty_Name Bank_Name,
hp_branch.ADDRESS1 Bank_Street1,
hp_branch.ADDRESS2 Bank_Street2,
hp_branch.ADDRESS3 Bank_Street3,
ieba.BANK_ACCOUNT_NAME Bank_Account_Name,
hp_branch.ADDRESS4 Bank_Name_Alt ,
ieba.CURRENCY_CODE Currency,
ieba.iban Iban_No,
hp_branch.CITY Local_Bank_City,
hp_bank.PArty_Name Local_Bank_Name,
null Order_of_Preference,
null Partner_Bank_Type,
ieba.EFT_SWIFT_CODE Swift_Code,
ieba.last_update_date,
ieba.attribute1 Temp_1,
ieba.attribute2 Temp_2,
ieba.attribute3 Temp_3,
ieba.attribute4 Temp_4,
ieba.attribute5 Temp_5,
ieba.attribute6 Temp_6,
ieba.attribute7 Temp_7,
ieba.attribute8 Temp_8,
ieba.attribute9 Temp_9,
ieba.attribute10 Temp_10
from
poz_suppliers PS,
poz_supplier_sites_all_m pvs,
hz_parties hp,
hr_organization_units_f_tl hout,
iby_external_payees_all iepa,
iby_pmt_instr_uses_all ipiua,
iby_ext_bank_accounts ieba,
--hz_party_sites bank_address,
--hz_locations hl,
hz_parties hp_bank ,
hz_parties hp_branch
where ps.vendor_id = pvs.vendor_id
--AND ps.enabled_flag ='Y'
--AND nvl(ps.end_Date_Active, sysdate+1) >= sysdate
--AND nvl(pvs.EFFECTIVE_END_DATE,sysdate+1) >= sysdate
and ps.party_id=hp.party_id
and pvs.prc_bu_id=hout.organization_id
and hout.LANGUAGE = USERENV('LANG')
and iepa.payee_party_id = PS.party_id
--and trunc(IEPA.end_Date) >= trunc(sysdate)
and pvs.party_site_id=iepa.party_site_id
and iepa.supplier_Site_id= pvs.vendor_Site_id
and ipiua.ext_pmt_party_id = IEPA.ext_payee_id
--and trunc(ipiua.end_Date) >= trunc(sysdate)
and ieba.ext_bank_account_id = ipiua.instrument_id
--and pvs.party_site_id = bank_address.party_site_id
--and bank_address.location_id=hl.location_id
and ieba.bank_id = hp_bank.party_id
and ieba.branch_id = hp_branch.party_id
and hout.name = NVL(:P_BU_NAME,hout.name)
--and pvs.vendor_Site_id=300000185706839
and ieba.OBJECT_VERSION_NUMBER
IN(
select max(OBJECT_VERSION_NUMBER) from iby_ext_bank_accounts ieba1
where ieba1.ext_bank_account_id = ieba.ext_bank_account_id
and ieba1.bank_id = ieba.bank_id
)
and EXISTS
(
select 1 from POZ_SITE_ASSIGNMENTS_ALL_M psaa
where psaa.VENDOR_SITE_ID = pvs.VENDOR_SITE_ID
and psaa.bu_id= pvs.PRC_BU_ID
-- and nvl(psaa.EFFECTIVE_END_DATE,sysdate+1) >= sysdate
)
and trunc(ieba.last_update_date) between nvl(:P_FROM_DATE,trunc(ieba.last_update_date)) and nvl(:P_END_DATE,trunc(ieba.last_update_date))
UNION ALL
select
(select 'Oracle-'|| instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||PS.segment1||'-'||IEBA.EXT_BANK_ACCOUNT_ID AP_External_Key__c,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) Source_System,
(select 'Oracle-'||instance_name||'-'||to_Char(sysdate,'yyyymmddhhmmss') from gv$instance where INSTANCE_NUMBER =1) Batch_Id,
NULL Company_Code_Unique_Key,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||PS.segment1 Supplier_Unique_Key,
PS.segment1 Supplier_Number,
NULL Supplier_Site_Id,
NULL Supplier_Site_Code,
IEBA.EXT_BANK_ACCOUNT_ID Bank_Account_Id,
ieba.BANK_ACCOUNT_NUM Bank_Account_No,
TO_cHAR(ieba.START_DATE,'yyyy-MM-dd') Bank_Account_Start_Date,
TO_cHAR(ieba.end_DATE,'yyyy-MM-dd') Bank_Account_end_Date,
decode(hp_bank.STATus,'A','Y','I','N',hp_bank.STATus) Bank_Active_Status,
hp_branch.Party_Name Bank_Branch_Name,
hp_branch.CITY Bank_City,
hp_branch.COUNTRY Bank_Country_Code ,
hp_bank.PArty_Name Bank_Name,
hp_branch.ADDRESS1 Bank_Street1,
hp_branch.ADDRESS2 Bank_Street2,
hp_branch.ADDRESS3 Bank_Street3,
ieba.BANK_ACCOUNT_NAME Bank_Account_Name,
hp_branch.ADDRESS4 Bank_Name_Alt ,
ieba.CURRENCY_CODE Currency,
ieba.iban Iban_No,
hp_branch.CITY Local_Bank_City,
hp_bank.PArty_Name Local_Bank_Name,
null Order_of_Preference,
null Partner_Bank_Type,
ieba.EFT_SWIFT_CODE Swift_Code,
ieba.last_update_date,
ieba.attribute1 Temp_1,
ieba.attribute2 Temp_2,
ieba.attribute3 Temp_3,
ieba.attribute4 Temp_4,
ieba.attribute5 Temp_5,
ieba.attribute6 Temp_6,
ieba.attribute7 Temp_7,
ieba.attribute8 Temp_8,
ieba.attribute9 Temp_9,
ieba.attribute10 Temp_10
from
poz_suppliers PS,
--poz_supplier_sites_all_m pvs,
hz_parties hp,
--hr_organization_units_f_tl hout,
iby_external_payees_all iepa,
iby_pmt_instr_uses_all ipiua,
iby_ext_bank_accounts ieba,
--hz_party_sites bank_address,
--hz_locations hl,
hz_parties hp_bank ,
hz_parties hp_branch
where 1=1
and ps.party_id=hp.party_id
and iepa.payee_party_id = PS.party_id
--and trunc(IEPA.end_Date) >= trunc(sysdate)
and iepa.party_site_id is null
and ipiua.ext_pmt_party_id = IEPA.ext_payee_id
--and trunc(ipiua.end_Date) >= trunc(sysdate)
and ieba.ext_bank_account_id = ipiua.instrument_id
--and pvs.party_site_id = bank_address.party_site_id
--and bank_address.location_id=hl.location_id
and ieba.bank_id = hp_bank.party_id
and ieba.branch_id = hp_branch.party_id
and ieba.OBJECT_VERSION_NUMBER
IN(
select max(OBJECT_VERSION_NUMBER) from iby_ext_bank_accounts ieba1
where ieba1.ext_bank_account_id = ieba.ext_bank_account_id
and ieba1.bank_id = ieba.bank_id
)
and trunc(ieba.last_update_date) between nvl(:P_FROM_DATE,trunc(ieba.last_update_date)) and nvl(:P_END_DATE,trunc(ieba.last_update_date))
No comments:
Post a Comment