zOs/SQL/YNZGFM1

$#@
m.vv.1 = 'VNZ100A1V'
m.vv.2 = 'VNZ101A1V'
m.vv.3 = 'VNZ106A1V'
m.vv.4 = 'VNZ111A1V'
m.vv.5 = 'VNZ113A1V'
m.vv.6 = 'VNZ118A1V'
call sqlConnect dbof
$do vx=1 to 5 $@/eachView/
m.vv.vx.0 = 0
call sqlQueryPrep 3, 'select orderRefNumber ord, runningNumber run' ,
    'from oa1p.'m.vv.vx 'where orderRefNumber >= ?' ,
    'order by orderRefNumber, runningNumber fetch first row only'
ordLa = ''
rL = 0
oL = 0
seq = m.ut_alfNum
$do cx=1 $@/nxRow/
    call sqlQueryArgs 3, ordLa
    fFou = sqlFetch(3, ff)
    call sqlClose 3
    if \ fFou then
        leave
    oL = max(length(strip(m.ff.ord, t)), oL)
    rL = max(length(m.ff.run), rL)
    call mAdd vv.vx, left(m.ff.ord, 17) || left(m.ff.run, 5)
 $** if cx // 2 = 0 then
 $**    $$- right("|| '", 10)strip(m.ff.ord) m.ff.run+0"'"
    ordLa = left(m.ff.ord, 11)
    do forever
        sx = pos(right(ordLa, 1), seq)
        if sx > 0 & sx < length(seq) then
            leave
        ordLa = left(ordLa, length(ordLa) - 1)
        if ordLa = '' then
            return err('no next for ordLa' m.ff.ord)
        end
    ordLa = overlay(substr(seq, sx+1, 1), ordLa, length(ordLa))
    $/nxRow/
    say vx m.vv.vx m.vv.vx.0 oL rL m.vv.vx.1
$/eachView/
say 'after eachView'
$$- '       /*' sysvar(sysnode) f('%t s') '*/'
do i=1 by 103 to 103001
    jx = i // m.vv.3.0 + 1
    $$- "    || '3"m.vv.3.jx"'"
    jy = i // 4
    jy = jy + 1 + (jy>1)
    jz = i // m.vv.jy.0 + 1
    $$- "    || '"jy || m.vv.jy.jz"'"
    end
$#out                                              20140728 07:52:12
       /* RZ2 2014-07-28-07.52.17 */
    || '3XS80140714800016300001'
    || '21000140709140014400001'
    || '33D00140626800748700001'
    || '13D00140715800002600001'
    || '33D30140618800017000001'
    || '53M80100929800012800010'
    || '33D60140630800189200001'
    || '43N60140702800246300010'