SELECT
'6' || /* Record Type Code */
decode(upper(substr(ba.bank_account_type,1,4)),'SAVI', -- BANK_ACCOUNT_TYPE
decode(i.amount,0,'33','32'),
decode(i.amount,0,'23','22')) || /* Transaction Code */
rpad(nvl(substr(ba.bank_account_name_alt,1,8),' '),8,' ') || --BANK_ACCOUNT_NAME_ALT /* Transit Routing# without check digit */
rpad(nvl(substr(ba.bank_account_name_alt,9,1),' '),1,' ') || /* check digit */
rpad(nvl(substr(ba.bank_account_num,1,17),' '),17,' ') || -- BANK_ACCOUNT_NUM /* Vendor Bank Account Number */
lpad(nvl(substr((i.amount * 100),1,10),'0'),10,'0') || /* Dollar Amount */
rpad(nvl(substr(e.SEGMENT1,1,15),' '),15,' ') || /* Employee Number */
rpad(nvl(substr(upper(e.vendor_name),1,22),' '),22,' ') || /* Employee Name */
' ' || /* Discretionary Data..Don't Care */
'0' || /* No Addenda Records */
rpad (nvl(substr(:C_UBOC_ROUTING_NO,1,8),' '),8,' ') || /* UBOC Transit Number */
lpad(nvl(substr(i.check_number,1,7),'0'),7,'0') check_body,
'6' sort_sequence_1,
upper(e.vendor_name) sort_sequence_2
from CE_BANK_ACCOUNTS ba , -- ap_bank_accounts_all ba,
CE_BANK_ACCT_USES_ALL bau, -- ap_bank_account_uses_all bau,
ap_checks_all i,-- ap_selected_invoice_checks_all i
po_vendors e -- newly added table
WHERE Ba.BANK_ACCOUNT_ID = bau.BANK_ACCOUNT_ID
and bau.BANK_ACCOUNT_ID = i.CE_BANK_ACCT_USE_ID(+)
and i.vendor_id = e.vendor_id(+)
'6' || /* Record Type Code */
decode(upper(substr(ba.bank_account_type,1,4)),'SAVI', -- BANK_ACCOUNT_TYPE
decode(i.amount,0,'33','32'),
decode(i.amount,0,'23','22')) || /* Transaction Code */
rpad(nvl(substr(ba.bank_account_name_alt,1,8),' '),8,' ') || --BANK_ACCOUNT_NAME_ALT /* Transit Routing# without check digit */
rpad(nvl(substr(ba.bank_account_name_alt,9,1),' '),1,' ') || /* check digit */
rpad(nvl(substr(ba.bank_account_num,1,17),' '),17,' ') || -- BANK_ACCOUNT_NUM /* Vendor Bank Account Number */
lpad(nvl(substr((i.amount * 100),1,10),'0'),10,'0') || /* Dollar Amount */
rpad(nvl(substr(e.SEGMENT1,1,15),' '),15,' ') || /* Employee Number */
rpad(nvl(substr(upper(e.vendor_name),1,22),' '),22,' ') || /* Employee Name */
' ' || /* Discretionary Data..Don't Care */
'0' || /* No Addenda Records */
rpad (nvl(substr(:C_UBOC_ROUTING_NO,1,8),' '),8,' ') || /* UBOC Transit Number */
lpad(nvl(substr(i.check_number,1,7),'0'),7,'0') check_body,
'6' sort_sequence_1,
upper(e.vendor_name) sort_sequence_2
from CE_BANK_ACCOUNTS ba , -- ap_bank_accounts_all ba,
CE_BANK_ACCT_USES_ALL bau, -- ap_bank_account_uses_all bau,
ap_checks_all i,-- ap_selected_invoice_checks_all i
po_vendors e -- newly added table
WHERE Ba.BANK_ACCOUNT_ID = bau.BANK_ACCOUNT_ID
and bau.BANK_ACCOUNT_ID = i.CE_BANK_ACCT_USE_ID(+)
and i.vendor_id = e.vendor_id(+)
No comments:
Post a Comment