sort keeping header as rec1

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
GW
Member
Posts: 3
Joined: Fri Oct 27, 2006 5:56 pm

sort keeping header as rec1

Post by GW » Tue Oct 30, 2007 3:15 pm

Hi,
anyone got a solution to this?
I have an input file like this

HEADER
GGGGG
ZZZZZZ
BBBBBB
DDDDD
AAAAAA

when I sort I want to keep HEADER as rec1 not like this :-
AAAAAA
BBBBBB
DDDDD
GGGGG
HEADER
ZZZZZZ

but like this
HEADER
AAAAAA
BBBBBB
DDDDD
GGGGG
ZZZZZZ

I know I should RTFM but too busy.
thanks in advance

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Oct 30, 2007 8:09 pm

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: Select all

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
    IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),OVERLAY=(81:C'0'))
  SORT FIELDS=(81,1,CH,A,1,6,CH,A)
  OUTREC BUILD=(1,80)
/*
For more information, see the "Sort records between a header and trailer" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/supp ... vs/tricks/
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

GW
Member
Posts: 3
Joined: Fri Oct 27, 2006 5:56 pm

Post by GW » Fri Nov 02, 2007 3:02 pm

thanks Frank

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others