SHARE
TWEET

Untitled

a guest May 10th, 2017 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function doCleaning()
  2.    define out_rec record
  3.       cust_code      char(20),
  4.       cust_type      char(10),
  5.       cust_upd_date  date,
  6.       bus_name       varchar(60),
  7.       bus_name2      varchar(60),
  8.       address1       varchar(60),
  9.       address2       varchar(60),
  10.       address3       varchar(60),
  11.       city           varchar(60),
  12.       state          char(2),
  13.       zip            char(10)
  14.    end record
  15.  
  16.    define
  17.       tmpstr      string,
  18.       tcount      integer,
  19.       ch          base.channel,
  20.       exportDir   string
  21.  
  22.  
  23.  
  24.    if tfile.getLength() = 0 then
  25.       call util.Math.srand()
  26.       let exportDir = "/data3/qasbatch/"
  27.  
  28.       let batchID = today using "yyyymmdd"
  29.       let batchID  = batchID.append(util.Math.rand(9999) using "&&&&")
  30.  
  31.       let tfile = SFMT("%1%2.csv", exportDir, batchID)
  32.  
  33.    end if
  34.  
  35.    let ch = base.channel.create()
  36.    call ch.setDelimiter("|")
  37.    call ch.openFile(tfile, "wb")
  38.  
  39.    call ch.write(["cust_code", "cust_type","bus_name","bus_name2","address1","address2",
  40.                   "address3","city","state","zip"])
  41.  
  42.  
  43.    let tmpstr = "select "<PIPE><PIPE>tblCode<PIPE><PIPE>"
  44.         , '"<PIPE><PIPE>tblName<PIPE><PIPE>"'
  45.         , update_date
  46.         , bus_name
  47.         , bus_name2
  48.         , address1
  49.         , address2
  50.         , address3
  51.         , city
  52.         , state
  53.         , zip
  54.      from  "<PIPE><PIPE> tblName <PIPE><PIPE>"
  55.      where "<PIPE><PIPE> tblCriteria
  56.  
  57.  
  58.    display "Starting batch process - "<PIPE><PIPE>current
  59.  
  60.    prepare theqry from tmpstr
  61.    declare export_curs cursor for theqry
  62.  
  63.  
  64.    let tcount = 0
  65.  
  66.    foreach export_curs into out_rec.*
  67.  
  68.       call CleanAddress(out_rec.*)
  69.  
  70.  
  71.       call ch.write([out_rec.cust_code,
  72.                      out_rec.cust_type,
  73.                      out_rec.cust_upd_date,
  74.                      out_rec.bus_name ,
  75.                      out_rec.bus_name2,
  76.                      out_rec.address1 ,
  77.                      out_rec.address2 ,
  78.                      out_rec.address3 ,
  79.                      out_rec.city     ,
  80.                      out_rec.state    ,
  81.                      out_rec.zip])      
  82.  
  83.  
  84.  
  85.  
  86.       let tcount = tcount+1
  87.  
  88.    end foreach
  89.  
  90.  
  91.    call ch.close()
  92.  
  93.    display SFMT("Batch ID: %1", batchID) at 1,1
  94.    display SFMT("Batch File: %1", tfile) at 2,1
  95.    display SFMT("Batch Date: %1", today) at 3,1
  96.    display SFMT("Total records: %1", tcount) at 4,1
  97.  
  98.    call ch.openFile(SFMT("%1batchhistory.txt", exportDir), "a")
  99.    call ch.setDelimiter("\t")
  100.    call ch.write([current year to minute, batchID, tcount, tblCriteria])
  101.    call ch.close()
  102.  
  103. end function
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top