Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. --The full list of DD transactions within the BOB files in August and September.
  2. --This takes ~30-40 seconds to run.
  3. select
  4. cast(prh.post_utc as date) as 'Approx. BOB File Date',
  5. ddt.fil_nbr as 'DD File Number',
  6. prd.ctm_nbr as 'Billing Customer Number',
  7. prd.src_dta as 'Item Source',
  8. case when prd.src_dta = 'CIR' then pub.pub_ttl else sac.scde_dsc end as 'Magazine Title',
  9. ddt.crd_amt as 'DD Amount',
  10. ddt.ddt_sta as 'DDT Status'
  11. from arpprh_m prh
  12. join arpprd_m prd on prd.crx_dte = prh.crx_dte and prd.crx_ops = prh.crx_ops and prd.pay_type = prh.pay_type and prd.pay_code = prh.pay_code and
  13. prd.ctm_nbr = prh.ctm_nbr and prd.crx_vch = prh.crx_vch and prd.aud_src = prh.aud_src and prd.sub_grp = prh.sub_grp
  14. join arpddt_m ddt on ddt.crx_vch = prd.crx_vch and ddt.ddt_typ = 'PYMT'
  15. join arprdd_m rdd on rdd.ddi_idn = ddt.ddi_idn
  16. left join cdsitm_m itm on itm.itm_num = prd.itm_num
  17. left join invsac_t sac on sac.sac_cde = itm.itm_sac
  18. left join cirpub_t pub on pub.pub_cde = prd.itm_num
  19. where (prd.crx_ops <> 'ARPUDA' or prd.pay_type = 'DD') and
  20. prh.pay_code <> '' and prd.pad_amt > 0 and
  21. cast(prh.post_utc as date) between {d'2018-08-01'} and {d'2018-09-30'}
  22. order by cast(prh.post_utc as date), prd.itm_num
  23.  
  24.  
  25. --Information about which DDT file numbers can be found in each BOB file. This is an approximation, since
  26. --ARPBGL runs do not correspond 1-to-1 with each day (i.e the previous day's transactions may be found in
  27. --the following day's BOB file; or, if ARPBGL was not run on the approximate date, those lines should be in
  28. --the next BOB file).
  29. select
  30. cast(prh.post_utc as date) as 'Approx. BOB File Date',
  31. ddt.fil_nbr as 'DD File Number',
  32. count(*) as 'Count'
  33. from arpprh_m prh
  34. join arpprd_m prd on prd.crx_dte = prh.crx_dte and prd.crx_ops = prh.crx_ops and prd.pay_type = prh.pay_type and prd.pay_code = prh.pay_code and
  35. prd.ctm_nbr = prh.ctm_nbr and prd.crx_vch = prh.crx_vch and prd.aud_src = prh.aud_src and prd.sub_grp = prh.sub_grp
  36. join arpddt_m ddt on ddt.crx_vch = prd.crx_vch and ddt.ddt_typ = 'PYMT'
  37. join arprdd_m rdd on rdd.ddi_idn = ddt.ddi_idn
  38. left join cdsitm_m itm on itm.itm_num = prd.itm_num
  39. left join invsac_t sac on sac.sac_cde = itm.itm_sac
  40. left join cirpub_t pub on pub.pub_cde = prd.itm_num
  41. where (prd.crx_ops <> 'ARPUDA' or prd.pay_type = 'DD') and
  42. prh.pay_code <> '' and prd.pad_amt > 0 and ddt.fil_nbr <> '0' and
  43. cast(prh.post_utc as date) between {d'2018-08-01'} and {d'2018-09-30'}
  44. group by cast(prh.post_utc as date), ddt.fil_nbr
  45. order by cast(prh.post_utc as date), ddt.fil_nbr
  46.  
  47.  
  48. --These are the DDTs where the file number is reported as 0, due to the next processing date not
  49. --being reached yet. Note that the status is R (Requested Outbound) rather than S (Successful).
  50. --These will be picked up by ARP376 the first time it is run after their DDT.NXT-INF.
  51. select
  52. cast(prh.post_utc as date) as 'Approx. BOB File Date',
  53. ddt.fil_nbr as 'DD File Number',
  54. prd.ctm_nbr as 'Billing Customer Number',
  55. prd.src_dta as 'Item Source',
  56. case when prd.src_dta = 'CIR' then pub.pub_ttl else sac.scde_dsc end as 'Magazine Title',
  57. ddt.crd_amt as 'DD Amount',
  58. ddt.ddt_sta as 'DDT Status',
  59. ddt.nxt_inf as 'DDT Next Date'
  60. from arpprh_m prh
  61. join arpprd_m prd on prd.crx_dte = prh.crx_dte and prd.crx_ops = prh.crx_ops and prd.pay_type = prh.pay_type and prd.pay_code = prh.pay_code and
  62. prd.ctm_nbr = prh.ctm_nbr and prd.crx_vch = prh.crx_vch and prd.aud_src = prh.aud_src and prd.sub_grp = prh.sub_grp
  63. join arpddt_m ddt on ddt.crx_vch = prd.crx_vch and ddt.ddt_typ = 'PYMT'
  64. join arprdd_m rdd on rdd.ddi_idn = ddt.ddi_idn
  65. left join cdsitm_m itm on itm.itm_num = prd.itm_num
  66. left join invsac_t sac on sac.sac_cde = itm.itm_sac
  67. left join cirpub_t pub on pub.pub_cde = prd.itm_num
  68. where (prd.crx_ops <> 'ARPUDA' or prd.pay_type = 'DD') and
  69. prh.pay_code <> '' and prd.pad_amt > 0 and ddt.fil_nbr = '0' and
  70. cast(prh.post_utc as date) between {d'2018-08-01'} and {d'2018-09-30'}
  71. order by cast(prh.post_utc as date), prd.itm_num
  72.  
  73.  
  74. --These are the DDTs that generated errors during ARP376, identified by the DDT-STA of E they were given.
  75. --These errors occurred because, at the time, the ARPRDD record had a status (RDD-STA) that was not active (e.g. not A, P, or blank).
  76. select
  77. cast(prh.post_utc as date) as 'Approx. BOB File Date',
  78. ddt.fil_nbr as 'DD File Number',
  79. prd.ctm_nbr as 'Billing Customer Number',
  80. prd.src_dta as 'Item Source',
  81. case when prd.src_dta = 'CIR' then pub.pub_ttl else sac.scde_dsc end as 'Magazine Title',
  82. ddt.crd_amt as 'DD Amount',
  83. ddt.ddt_sta as 'DDT Status'
  84. from arpprh_m prh
  85. join arpprd_m prd on prd.crx_dte = prh.crx_dte and prd.crx_ops = prh.crx_ops and prd.pay_type = prh.pay_type and prd.pay_code = prh.pay_code and
  86. prd.ctm_nbr = prh.ctm_nbr and prd.crx_vch = prh.crx_vch and prd.aud_src = prh.aud_src and prd.sub_grp = prh.sub_grp
  87. join arpddt_m ddt on ddt.crx_vch = prd.crx_vch and ddt.ddt_typ = 'PYMT'
  88. join arprdd_m rdd on rdd.ddi_idn = ddt.ddi_idn
  89. left join cdsitm_m itm on itm.itm_num = prd.itm_num
  90. left join invsac_t sac on sac.sac_cde = itm.itm_sac
  91. left join cirpub_t pub on pub.pub_cde = prd.itm_num
  92. where (prd.crx_ops <> 'ARPUDA' or prd.pay_type = 'DD') and
  93. prh.pay_code <> '' and prd.pad_amt > 0 and ddt.ddt_sta = 'E' and
  94. cast(prh.post_utc as date) between {d'2018-08-01'} and {d'2018-09-30'}
  95. order by cast(prh.post_utc as date), prd.itm_num
  96.  
  97.  
  98. --Information requested about the transaction lines that were stripped from the BACS files.
  99. select
  100. rem.file_nbr as 'File Number',
  101. rem.sort_code as 'Bank ID Number',
  102. rem.acct_nbr as 'Bank Account Number',
  103. rem.ddi_idn as 'DDI-IDN',
  104. rem.bks_ddi as 'BKS-DDI',
  105. rem.amt_paid as 'Amount Paid',
  106. case when rem.tran_typ = '17' then 'PYMT' else 'CANCL' end as 'Transaction Type'
  107. from DdtRemovedFromBankFile rem
  108. where rem.file_nbr in ('2463', '2465', '2466', '2467', '2469')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement