zOs/SQL/CATCOPFG

$£ timing() 'be'
$;
ddal = dsnAlloc('~wk.texv(syscopy)')
say ddAl
dd = word(ddAl, 1)
call readDDBegin dd
x = 0
z = 0
cDb = 0
cTs = 0
cPa = 0
old = ''
curr = '2008-03-13-11.11'
last = '2008-03-12-11.11'
keys = 'B N C L O'
do kx=1 to words(keys)
    ky = word(keys, kx)
    c.ky.f.By = 0
    c.ky.f.cn = 0
    c.ky.i.By = 0
    c.ky.i.cn = 0
    end
do while readDD(dd, i., 1000)
    x = x + i.0
    do y=1 to i.0
        z = z + 1
        if z // 10000 = 0 then
             say 'en' x 'z' z 'db' cDb 'ts' cTs 'pa' cPa ,
                     db'.'ts'.'pa'|'
        if old ^== left(i.y, 20) then do
            if left(old, 8) ^== left(i.y, 8) then do
                cDb = cDb+1
                db = strip(left(i.y, 8))
                end
            if left(old, 16) ^== left(i.y, 16) then do
                cTs = cTs+1
                ts = strip(substr(i.y, 9, 8))
                end
            cPa = cPa + 1
            pa = c2d(substr(i.y, 17, 4))
            old = left(i.y, 20)
            sta = 'B'
            end
        parse var i.y 21 tst 47 tp 48 dsn . 92 bytes .
        if sta == 'B' then
            if tst <= curr then
                sta = 'N'
        if sta == 'C' then do
            say 'changing' dsn
            if tp = 'F' then
                if tst <  last then
                    sta = 'L'
            end

        say sta tp dsn
        c.sta.tp.cn = c.sta.tp.cn + 1
        c.sta.tp.by = c.sta.tp.by + bytes
        if sta == 'N' then
            if tp = 'F' then
                sta = 'C'
        if sta == 'L' then
            sta = 'O'
        end
    call sf 'before' curr
    call sf 'new'        , n
    end
call readDDEnd dd
interpret subWord(ddAl, 2)
$£ timing() 'en' x 'z' z 'db' cDb 'ts' cTs 'pa' cPa
$***out            20080313 17:10:53
$***out            20080313 17:09:47
$***out            20080313 17:08:27
$***out            20080313 17:07:29
$***out            20080313 17:06:39
$***out            20080313 17:06:11
$***out            20080313 17:05:56
$***out            20080313 16:16:53
$***out