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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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