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
 

 

Sorting a file excluding the 1st and last rec

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
munztah

New User


Joined: 25 Jul 2006
Posts: 3

PostPosted: Tue Jul 25, 2006 7:44 pm    Post subject: Sorting a file excluding the 1st and last rec
Reply with quote

Hi,

Is it possible to sort a File excluding the first and the last record using JCL?

example:

Input

Hello
CCCC
XXXX
AAAA
KKKK
World

Output

Hello
AAAA
CCCC
KKKK
XXXX
World

Thanks
Back to top
View user's profile Send private message

shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Jul 25, 2006 8:07 pm    Post subject: Re: Sorting a file excluding the 1st and last rec
Reply with quote

Hi,

This is the JCL for You.

Code:

//SORTIN  EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN      DD DSN=KBY@V1.TEST.SORT.INPUT,DISP=SHR
//*** MUST USE DISP=MOD FOR OUTPUT - MAKE SURE
//*** THE OUTPUT DATA SET IS EMPTY INITIALLY
//OUT     DD DISP=MOD,DSN=KBY@V1.OUTPUT.RESULT(0),
//          DCB=(LRECL=080,RECFM=FB),
//          SPACE=(TRK,(10,10),RLSE),
//          UNIT=DISK
//TOOLIN  DD *
* COPY HEADER RECORD
COPY FROM(IN) TO(OUT) USING(HHHH)
* SORT DETAIL RECORDS
SORT FROM(IN) TO(OUT) USING(DDDD)
* COPY TRAILER RECORD
COPY FROM(IN) TO(OUT) USING(TTTT)
/*
//HHHHCNTL DD *
* GET HEADER RECORD (FIRST)
  OPTION STOPAFT=1
/*
//DDDDCNTL DD *
* SKIP HEADER RECORD
  OPTION SKIPREC=1
* SKIP TRAILER RECORD
** USE AN OMIT CONDITION THAT DISTINGUISHES
** THE TRAILER RECORD FROM THE DETAIL RECORDS
  OMIT COND=(1,4,CH,EQ,C'VAMS')
* SORT ALL BUT THE HEADER AND TRAILER RECORDS
  SORT FIELDS=(1,6,CH,A)
/*
//TTTTCNTL DD *
* SKIP HEADER RECORD
  OPTION SKIPREC=1
* GET TRAILER RECORD
** USE AN INCLUDE CONDITION THAT DISTINGUISHES
** THE TRAILER RECORD FROM THE DETAIL RECORDS
** (SAME AS ABOVE)
  INCLUDE COND=(1,4,CH,EQ,C'VAMS')
/*



~Vamsi
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: Tue Jul 25, 2006 8:35 pm    Post subject:
Reply with quote

munztah,

If the first and last record have an "identifier", you can do it in one pass with a DFSORT job like the one below. 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/80)
//SORTOUT  DD DSN=... output file (FB/80)
//SYSIN    DD    *
* Put special key of '1' in 81 for data records.
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
* For header record, put special key of '0' in 81.
       IFTHEN=(WHEN=(1,5,CH,EQ,C'Hello'),OVERLAY=(81:C'0')),
* For trailer record, put special key of '9' in 81.
       IFTHEN=(WHEN=(1,5,CH,EQ,C'World'),OVERLAY=(81:C'9'))
* Sort by special key ('0', '1' or '9') and then regular key.
   SORT FIELDS=(81,1,CH,A,1,5,CH,A)
* Remove special key.
   OUTREC FIELDS=(1,80)
/*


If the first or last record does not have an identifier, let me know what the exact situation is, and I'll show you another approach.
Back to top
View user's profile Send private message
munztah

New User


Joined: 25 Jul 2006
Posts: 3

PostPosted: Thu Jul 27, 2006 10:30 am    Post subject:
Reply with quote

Thanks shreevamsi
Thanks Frank

Both answers were very helpful.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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