开发者

Reading records from a file

开发者 https://www.devze.com 2023-01-03 11:42 出处:网络
I have a file having some number of records and I want to copy only first and last 10 records in开发者_C百科to another file.

I have a file having some number of records and I want to copy only first and last 10 records in开发者_C百科to another file.

Can anybody tell how to write jcl, using sort, icetool, etc.


You can use ICETOOL to copy a subset of your input file.

Here's the JCL to copy the first and last 10 records into another file. I'm assuming fixed length records of 80 bytes each.

You'll also have to change the JOB card to fit with your mainframe shop's requirements.

//EXAMP    JOB A400,PROGRAMMER
//STEP1    EXEC PGM=ICETOOL
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=INPUT,DISP=SHR
//T1       DD DSN=&&T1,DISP=(,PASS),UNIT=VIO 
//T2       DD DSN=&&T2,DISP=(,PASS),UNIT=VIO 
//T3       DD DSN=&&T3,DISP=(,PASS),UNIT=VIO
//SORTOUT  DD DSN=OUTPUT,DISP=(NEW,CATLG),UNIT=SYSDA,
//            SPACE=(CYL,(5,1))
//SYSIN    DD * 
  COPY FROM(IN) USING(CTL1)                                     
  COPY FROM(T1) USING(CTL2)                                     
  COPY FROM(T1) USING(CTL3)
  COPY FROM(T2,T3) USING(CTL4)
/* 
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,OUTREC=(1,80,SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=T2,ENDREC=10
/*
//CTL3CNTL DD *
  SORT FIELDS=(81,8,BI,D)                                       
  OUTFIL FNAMES=T3,ENDREC=10 
/*
//CTL4CNTL DD *
  SORT FIELDS=(81,8,BI,A)                                       
  OUTFIL FNAMES=SORTOUT,OUTREC=(1,80)
//

The first set of control cards (CTL1CNTL) adds a sequence number to the input records.

The second set of control cards (CTL2CNTL) gets the first 10 input records.

The third set of control cards (CTL3CNTL) sorts the input records in reverse order, and gets the first 10 (which would be the last 10) records.

The fourth set of control cards (CTL4CNTL) sorts the extracted records in the correct order and removes the sequence numbers added by the first set of control cards.

Here's IBM's DFSORT Application Programming Guide for more information.


From July 2008 ICETOOL has SUBSET.

//STEP1    EXEC PGM=ICETOOL
//SYSOUT   DD SYSOUT=*
//IN       DD DSN=your input
//OUT      DD DSN=your output
//SYSIN    DD * 
  SUBSET FROM(IN) TO(OUT) KEEP INPUT FIRST(10) LAST(10)

To know whether you have July 2008 available, look at the ICE201I message in any sort step.

ICE201I F RECORD TYPE ...

The letter immediately after the message number is F or greater, then you have July 2008 included.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号