IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Remove first and last record and copy other records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
squid_rocks

New User


Joined: 21 Mar 2005
Posts: 15
Location: Pune, INDIA

PostPosted: Wed Oct 25, 2006 12:06 am
Reply with quote

I want to eleminate first and last record from input file and copy rest of the records to an output file.
I can only use SORT (DFSORT or SYNCSORT) and FILEAID.

Please advice.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 25, 2006 12:55 am
Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/100)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=T1,OVERLAY=(101:SEQNUM,8,ZD)
  OUTFIL FNAMES=S1,REMOVECC,NODETAIL,BUILD=(80X),
    TRAILER1=('Lastrec,+',COUNT=(M11,LENGTH=8))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (FB/100)
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(101,8,ZD,EQ,+1,OR,101,8,ZD,EQ,Lastrec)
  OUTREC BUILD=(1,100)
/*
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Fri Oct 27, 2006 10:49 am
Reply with quote

Frank,

How do we capture the removed header record into another flat file?

Many thanks,
Twissi.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 27, 2006 8:30 pm
Reply with quote

If you want the data records in one file and the header record in another file, you can use this DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/100)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=T1,OVERLAY=(101:SEQNUM,8,ZD)
  OUTFIL FNAMES=S1,REMOVECC,NODETAIL,BUILD=(80X),
    TRAILER1=('Lastrec,+',COUNT=(M11,LENGTH=8))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//OUT     DD DSN=... output file (FB/100)
//HDR     DD DSN=... header record file (FB/100)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=OUT,
    OMIT=(101,8,ZD,EQ,+1,OR,101,8,ZD,EQ,Lastrec),
    BUILD=(1,100)
  OUTFIL FNAMES=HDR,ENDREC=1,BUILD=(1,100)
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Sep 05, 2008 9:45 pm
Reply with quote

You can now do this more easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//IN DD DSN=...  input file (FB/100)
//OUT     DD DSN=... output file (FB/100)
//HDR     DD DSN=... header record file (FB/100)
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) REMOVE INPUT HEADER TRAILER -             
  DISCARD(HDR) USING(CTL1)                                       
/*
//CTL1CNTL DD *                   
  OUTFIL FNAMES=OUT               
  OUTFIL FNAMES=HDR,ENDREC=1     
/*


For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top