Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us