Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Remove first and last record and copy other records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Remove first and last record and copy other records
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 Moderator


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

PostPosted: Wed Oct 25, 2006 12:55 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 27, 2006 8:30 pm    Post subject:
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 Moderator


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

PostPosted: Fri Sep 05, 2008 9:45 pm    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us