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

Sorting a file excluding the 1st and last rec


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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 Developer


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

PostPosted: Tue Jul 25, 2006 8:35 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top