Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. with grn_val as (select substring(b.LENQ_DATA,1,2) as CMPY
  2. ,substring(b.LENQ_DATA,3,12) as SUPP
  3. ,substring(b.LENQ_DATA,15,1) as DOC_IND
  4. ,substring(b.LENQ_DATA,16,20) as DOC_REF
  5. ,substring(b.LENQ_DATA,36,5) as LINE_NUM
  6. ,substring(b.LENQ_DATA,48,8) as RCPT_REF
  7. ,substring(b.LENQ_DATA,56,2) as DOC_CODE
  8. ,substring(b.LENQ_DATA,58,5) as SEQ_NUM
  9. ,a.ix_key,b.sysref,sum(b.fncl_val) as fncl_val
  10. ,b.REF_NUM,b.recon
  11. from tedtrnix a, tedtran b, tplgrn c
  12. where a.ix_cmpy = 'PG'
  13. and a.IX_TYPE = '7'
  14. and a.IX_KEY = c.GL_TRAN_REF
  15. and c.cmpy = a.IX_CMPY
  16. and c.grn_stat_ind in ('3','4')
  17. and b.CMPY = a.IX_CMPY
  18. and b.PATH = a.PATH
  19. and b.SYSREF = a.SYSREF
  20. and b.BAL = a.BAL
  21. and b.TRAN_DATE = a.TRAN_DATE
  22. and b.BTCH_NUM = a.BTCH_NUM
  23. and b.BTCH_SEQ_NUM = a.BTCH_SEQ_NUM
  24. and c.grn in ('00088234','00088235','00019124','00072020','00122066','00122068','00096673')
  25. group by substring(b.LENQ_DATA,1,2) ,substring(b.LENQ_DATA,3,12)
  26. ,substring(b.LENQ_DATA,15,1),substring(b.LENQ_DATA,16,20)
  27. ,substring(b.LENQ_DATA,36,5),substring(b.LENQ_DATA,48,8)
  28. ,substring(b.LENQ_DATA,56,2)
  29. ,substring(b.LENQ_DATA,58,5)
  30. ,a.ix_key,b.sysref
  31. ,b.REF_NUM,b.recon
  32. having SUM(b.fncl_val) <> 0)
  33. insert into TEDHIFU (JOBTAG,CMPY,BTCH_NUM,REC_TYPE,BTCH_SEQ_NUM,LENQ_KEY,FNCL_VAL_S,FNCL_VAL,
  34. REF_NUM_S,REF_NUM,RECON_S,RECON,ACCT_S,ACCT,ANAL_S,ANAL,TRAN_DATE,DETL_DESCR_S,DETL_DESCR)
  35. select ' ','PG',1234566,'2',ROW_NUMBER() over(order by a.cmpy desc),
  36. a.CMPY + a.SUPP + a.DOC_IND + a.DOC_REF + a.LINE_NUM + '0735406' + a.RCPT_REF + a.DOC_CODE + a.SEQ_NUM,
  37. 'Y',a.fncl_val * -1,'Y',a.ref_num,'Y',a.recon,'Y',c.acct,'Y',b.gl_anal,
  38. '31-AUG-2013','Y','Correction Posting GRN-' + a.RCPT_REF
  39. from grn_val a, tplanal b, tebacct c
  40. where b.cmpy = a.cmpy
  41. and b.grn = a.rcpt_ref
  42. and b.seq_num = a.seq_num
  43. and c.cmpy = a.cmpy
  44. and c.path = 0
  45. and c.sysref = a.sysref;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement