36759492 file processing with rexx

Upload: airish-sashidharan

Post on 02-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 36759492 File Processing With REXX

    1/13

  • 8/10/2019 36759492 File Processing With REXX

    2/13

  • 8/10/2019 36759492 File Processing With REXX

    3/13

  • 8/10/2019 36759492 File Processing With REXX

    4/13

  • 8/10/2019 36759492 File Processing With REXX

    5/13

  • 8/10/2019 36759492 File Processing With REXX

    6/13

  • 8/10/2019 36759492 File Processing With REXX

    7/13

  • 8/10/2019 36759492 File Processing With REXX

    8/13

  • 8/10/2019 36759492 File Processing With REXX

    9/13

    d+ne > 3esSAY Re*+rd > re*+rd

    ENDE'SE NOP

    ENDE'SE

    d+ne > 3esEND

    =EXECIO 9 DISKR INDD %#INIS=EXIT 9

    L& T)is e7e* *+pies re*+rds -r+m data set pre-i7. Y.INPUT t+ t)e end +- data set pre-i7. Y.OUTPUT. Neit)er data

    set )as /een all+*ated t+ a ddname. It assumes t)at t)einput data set )as n+ null lines.

    =A''OC DA% Y.INPUT& #%INDD& S$R REUSE==A''OC DA% Y.OUTPUT& #%OUTDD& OD REUSE=SAY C+p3in2 ...

    =EXECIO 8 DISKR INDD %#INIS=HUEUE ,8 Insert a null line at t)e end t+ indi*ate end +- -ile 8, =EXECIO 8 DISKW OUTDD %#INIS=

    SAY C+p3 *+mplete.=#REE #%INDD OUTDD&=EXIT 9

    M& T)is e7e* reads -i!e re*+rds -r+m t)e data setall+*ated t+ YINDD startin2 wit) t)e t)ird re*+rd. Itstrips trailin2 /lan0s -r+m t)e re*+rds4 and t)enwrites an3 re*+rd t)at is l+n2er t)an 9 *)ara*ters.

    T)e -ile is n+t *l+sed w)en t)e e7e* is -inis)ed.

    =EXECIO G DISKR YINDD =DO i > ? t+ G

    PARSE PU'' linestripline > STRIP%line4t&len > 'EN RC

  • 8/10/2019 36759492 File Processing With REXX

    10/13

    I# return@*+de > e+--la2 T$ENSAY Premature end +- -ile.

    E'SESAY ?99 Re*+rds read.

    EXIT return@*+de

    ?9& T)is e7e* erases an3 e7istin2 data -r+m t)e data set#RED.WORKSET.#I'E /3 +penin2 t)e data set and t)en*l+sin2 it wit)+ut writin2 an3 re*+rds. 63 d+in2 t)is4EXECIO ust writes an end +- -ile mar0er4 w)i*) erasesan3 e7istin2 re*+rds in t)e data set.

    In t)is e7ample4 t)e data set -r+m w)i*) 3+u areerasin2 re*+rds must n+t /e all+*ated wit) adisp+siti+n +- OD. I- 3+u all+*ate t)e data set wit) adisp+siti+n +- OD4 t)e EXECIO OPEN -+ll+wed /3 t)eEXECIO #INIS results in EXECIO ust rewritin2 t)ee7istin2 end +- -ile mar0er.

    =A''OCATE DA% #RED.WORKSET.#I'E & #%OUTDD& O'D REUSE==EXECIO 9 DISKW OUTDD %OPEN= ,8 Open t)e OUTDD -ile -+r writin24

    /ut d+ n+t write a re*+rd 8, =EXECIO 9 DISKW OUTDD %#INIS= ,8 Cl+se t)e OUTDD -ile. T)is

    /asi*all3 *+mpletes t)e erasin2+- an3 e7istin2 re*+rds -r+m t)eOUTDD -ile. 8,

    N+te t)at in t)is e7ample4 t)e EXECIO ... %OPEN *+mmand -+ll+wed /3t)e EXECIO ... %#INIS *+mmand is e5ui!alent t+:

    =EXECIO 9 DISKW OUTDD %OPEN #INIS=

    ??& T)is e7e* +pens t)e data set Y.IN(NTORY wit)+utreadin2 an3 re*+rds. T)e e7e* t)en uses a main l++p t+read re*+rds -r+m t)e data set and pr+*ess t)e re*+rds.

    =A''OCATE DA% Y.IN(NTORY & #%INDD& S$R REUSE==A''OCATE DA% Y.A(AI'.#I'E & #%OUTDD& O'D REUSE==EXECIO 9 DISKR INDD %OPEN= ,8 Open INDD -ile -+r input4 /ut

    d+ n+t read an3 re*+rds 8, e+- > NO ,8 Initiali1e end +- -ile -la2 8, a!ail@*+unt > 9 ,8 Initiali1e *+unter 8,

    DO W$I'E e+- > NO ,8 '++p until t)e EO# +- input-ile 8,

    =EXECIO ? DISKR INDD %STE 'INE.= ,8 Read a line 8, I# RC > T$EN ,8 I- end +- -ile is rea*)ed48, e+- > YES ,8 set t)e end +- -ile %e+-&

    -la2 8, E'SE ,8 Ot)erwise4a re*+rd is read8, DO

    I# INDEX%line.?4 A(AI'A6'E & T$EN ,8 '++0 -+r re*+rdsmar0ed =a!aila/le=8,

  • 8/10/2019 36759492 File Processing With REXX

    11/13

    DO ,8 =A!aila/le= re*+rd -+und 8,=EXECIO ? DISKW OUTDD= ,8 Write re*+rd t+ a!aila/le

    -ile 8,a!ail@*+unt > a!ail@*+unt J ? ,8 In*rement =a!aila/le=

    *+unter 8,END

    ENDEND

    =EXECIO 9 DISKR INDD %#INIS= ,8 Cl+se INDD -ile t)at is *urrentl3+pen 8,

    =EXECIO 9 DISKW OUTDD %#INIS= ,8 Cl+se OUTDD -ile i- -ile is *urrentl3 +pen. I- t)e OUTDD -ileis n+t +pen4 t)e EXECIO *+mmand)as n+ e--e*t. 8,

    EXIT 9

    ? & T)is e7e* +pens t)e data set Y.WRK#I'E and sets t)e*urrent re*+rd num/er t+ re*+rd M s+ t)at t)e ne7tEXECIO DISKR *+mmand /e2ins readin2 at t)e ei2)t)

    re*+rd.=A''OC DA% Y.WRK#I'E & #%INDD& S$R REUSE==EXECIO 9 DISKR INDD M %OPEN= ,8 Open INDD -ile -+r input and set

    *urrent re*+rd num/er t+ M. 8, CA'' READ@NEXT@RECORD ,8 Call su/r+utine t+ read re*+rd

    +n t+ t)e data sta*0. T)e ne7tre*+rd EXECIO reads is re*+rd M/e*ause t)e pre!i+us EXEC IO sett)e *urrent re*+rd num/er t+ M.8,

    ...

    =EXECIO 9 DISKR INDD %#INIS= ,8 Cl+se t)e INDD -ile. 8,

    ILLUS R$ ION o& t'e e&&ect o& residual data in S E! "aria(les:

    ? & T)is e7e* uses EXECIO t+ su**essi!el3 append t)ere*+rds -r+m sample?.data and t)en -r+m

    sample .data t+ t)e end +- t)e data setall.sample.data . It illustrates t)e e--e*t +-residual data in STE !aria/les. Data set

    sample?.data *+ntains 9 re*+rds. Data setsample .data *+ntains ?9 re*+rds.

    =A''OC #I% YINDD?& DA% SA P'E?.DATA & S$R REUSE= ,8input -ile ? 8, =A''OC #I% YINDD & DA% SA P'E .DATA & S$R REUSE= ,8 input -ile 8, =A''OC #I% YOUTDD& DA% A''.SA P'E.DATA & OD REUSE= ,8 +utput append

    -ile 8,

    ,8888888888888888888888888888888888888888888888888888888888888888888,

  • 8/10/2019 36759492 File Processing With REXX

    12/13

  • 8/10/2019 36759492 File Processing With REXX

    13/13

    d+,8888888888888888888888888888888888888888888888888888888888888,

    ,8 At t)is p+int4 new!ar.9 s)+uld /e ?94 indi*atin2 ?9 8, ,8 re*+rds )a!e /een read. Stem !aria/les new!ar.?4 new!ar. 48, ,8 ... t)r+u2) new!ar.?9 will *+ntain t)e ?9 re*+rds. I- we 8, ,8 )ad n+t *leared t)e stem new!ar. wit) t)e pre!i+us DROP 8, ,8 instru*ti+n4 !aria/les new!ar.?? t)r+u2) new!ar. 9 w+uld 8, ,8 still *+ntain re*+rds ?? t)r+u2) 9 -r+m t)e -irst data 8, ,8 set. $+we!er4 we w+uld 0n+w t)at t)ese !alues were n+t 8, ,8 read /3 t)e last EXECIO DISKR sin*e t)e *urrent new!ar.9 8, ,8 !aria/le indi*ates t)at +nl3 ?9 re*+rds were read /3 8, ,8 t)at last EXECIO. 8, ,8888888888888888888888888888888888888888888888888888888888888,

    sa3sa3sa3 = =sa3 new!ar.9 =re*+rds )a!e /een read -r+m sample .data : =sa3d+ i > ? t+ new!ar.9 ,8 '++p t)r+u2) all re*+rds 8,

    sa3 new!ar.i ,8 Displa3 t)e it) re*+rd 8, end

    =EXECIO= new!ar.9 =DISKW YOUTDD %STE NEW(AR.= ,8 Writee7a*tl3 t)e num/er +- re*+rds read 8,

    i- r* > 9 t)en ,8 I- write was su**ess-ul 8, d+

    sa3sa3 new!ar.9 =re*+rds were written t+ all.sample.data =

    endelse

    d+e7e*@RC > RC ,8 Sa!e e7e* return *+de 8,sa3sa3 =Err+r durin2 nd EXECIO ...DISKW4 return *+de is = RC

    sa3end

    endelse

    d+e7e*@RC > RC ,8 Sa!e e7e* return *+de 8,sa3sa3 =Err+r durin2 nd EXECIO ... DISKR4 return *+de is = RCsa3

    endend=EXECIO 9 DISKW YOUTDD %#INIS= ,8 Cl+se +utput -ile 8,=#REE #I% YINDD?&==#REE #I% YINDD &==#REE #I% YOUTDD&=

    e7it 9