Hi,
I have an input file with the first line as header line and remaining records are data records. I have to sort the data records and the o/p should have the header line followed by the sorted data records. can we do it using DFSORT?
Please advice
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You can do this in one pass with DFSORT using DFSORT's new IFTHEN and OVERLAY functions available with z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004). If you don't have the Dec, 2004 PTF installed, ask your System Programmer to install it (it's free). Here's the DFSORT job. I assumed your input file has RECFM=FB and LRECL=80 and I made up some data. But you can change the job appropriately for other attributes and data.
Code:
//S1 EXEC PGM=ICEMAN
//SORTDIAG DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD *
THIS IS THE HEADER RECORD
DATA 05
DATA 03
DATA 02
DATA 04
DATA 01
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
* Reformat record 1 (header to):
* |record|0|seqnum|
* Reformat record 2-n (data) to:
* |record|1|seqnum|
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1',82:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(82,8,ZD,EQ,+1),OVERLAY=(81:C'0'))
* Sort on 0 or 1 and then the key. 0 for the header record
* and 1 for the data records keeps the header first.
SORT FIELDS=(81,1,CH,A,6,2,CH,A)
* Remove 0 or 1 and seqnum.
OUTREC FIELDS=(1,80)
/*
SORTOUT has:
Code:
THIS IS THE HEADER RECORD
DATA 01
DATA 02
DATA 03
DATA 04
DATA 05
If you need more specific help on this, you need to tell me the RECFM and LRECL of your input file and show me an example of the input records with the relevent fields.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Priyesh,
As I said, you need DFSORT R14 PTF UQ95213 (Dec, 2004) to use DFSORT's new IFTHEN function. The error message indicates you don't have that PTF installed. Ask your System Programmer to install the PTF (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see: