Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
Your post is in TSO/ISPF part of the Forum, you show some input without BBcode - which makes it hard to comprehend your example , you ask for a SORT solution without telling what sort-product is in use at your shop?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
janmejay,
You only showed a snippet of your control statements (one IFTHEN). How are we supposed to know what the rest of your control statements look like? You didn't even show your SORT statement.
Assuming you want to sort the data only on the third field and leave the 3 header records and 1 trailer record where they are, you can use DATASORT as previously suggested. Here's the DFSORT/ICETOOL job:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
pgmname
Date
HEADER1 HEADER2 HEADER3
12345678 554579 TOTAL AMOUT SOLD
12365789 559870 ALREADY SOLDOUT
12365786 559873 MIDDLE RECORD
TOTAL NO OF RECORDS:100
//OUT DD SYSOUT=*
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER(3) TRAILER USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(37,20,CH,A)
OUT would have:
Code:
pgmname
Date
HEADER1 HEADER2 HEADER3
12365789 559870 ALREADY SOLDOUT
12365786 559873 MIDDLE RECORD
12345678 554579 TOTAL AMOUT SOLD
TOTAL NO OF RECORDS:100
If that doesn't do what you want, then you need to do a better job of explaining exactly what it you do want.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You need to get rid of the headers/trailer. Sort the data. Put the headers/trailer back.
Maybe a JOINKEYS? Same file on the two inputs for the join. In one CNTL you exclude the headers/trailers, the other exclude the data. Have a "sequence" for the headers/trailer, looks like you only need one byte, C'9' for trailer. For data, set to C'5'. Join on that field and your sort key. For the header/trailer, specify that the file is already sorted and does not require sequence checking.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
OK, Syncsort it is. This topic's travels recommence.
Thinking about it, you just need to sort on one key which is sourced from two different places.
For data records, sort on your third field. For header, a sequence number appended to some very low hexadecimal value. For trailer, a high hexadecimal value.
Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
janmejay,
Try this one...
Code:
//S1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
PGMNAME
DATE
HEADER1 HEADER2 HEADER3
12345678 554579 TOTAL AMOUNT SOLD
12365789 559870 ALREADY SOLDOUT
12365786 559873 MIDDLE RECORD
12365784 559873 CLOSED RECORD
12365785 559873 EXISTING RECORD
12365780 559873 MIDDLE RECORD
TOTAL NO OF RECORDS:006
//SYSIN DD *
INCLUDE COND=(1,1,CH,EQ,C' ',&,2,8,FS,EQ,NUM)
OUTFIL REMOVECC,BUILD=(1,80),HEADER2=(C'PGMNAME',/,C'DATE',/,
03:C'HEADER1',22:C'HEADER2',37:C'HEADER3'),
TRAILER2=(C'TOTAL NO OF RECORDS: ',COUNT=(M11,LENGTH=3))
SORT FIELDS=(37,25,CH,A)
And output will be :-
Code:
PGMNAME
DATE
HEADER1 HEADER2 HEADER3
12365789 559870 ALREADY SOLDOUT
12365784 559873 CLOSED RECORD
12365785 559873 EXISTING RECORD
12365786 559873 MIDDLE RECORD
12365780 559873 MIDDLE RECORD
12345678 554579 TOTAL AMOUNT SOLD
TOTAL NO OF RECORDS: 006
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
bodatrinadh wrote:
janmejay,
Try this one...
[...]
Only thing I don't like about the solution is this: the value for total is generated from the actual data records. If the original total is wrong, no-one will ever know...
********************************* TOP OF DATA **********************************
PGMNAME
DATE
HEADER1 HEADER2 HEADER3
12365789 559870 AAAAADY SOLDOUT
12365789 559870 ALREADY SOLDOUT
12365786 559873 MIDDLE RECORD
12345678 554579 TOTAL AMOUT SOLD
12365789 559870 XRERADY SOLDOUT
TOTAL NO OF RECORDS:100
******************************** BOTTOM OF DATA ********************************
Note: It is possible to merge two steps to one using ICETOOL. If you desire to generate report with the count of records in trailer, use the snippet given by boda
I am using the same code as you mentioned.
INCLUDE COND=(1,1,CH,EQ,C' ',&,2,8,FS,EQ,NUM)
OUTFIL REMOVECC,BUILD=(1,80),HEADER2=(C'PGMNAME',/,C'DATE',/,
03:C'HEADER1',22:C'HEADER2',37:C'HEADER3'),
TRAILER2=(C'TOTAL NO OF RECORDS: ',COUNT=(M11,LENGTH=3))
SORT FIELDS=(37,25,CH,A)
now instead of C'DATE' , now I am using &DATENS=(MDY). but its showing WER118A SORTOUT ILLEGAL OVERLAPPING FIELDS .
Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
Here is my sort card and output. It worked perfectly for me.
Code:
//S1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
PGMNAME
DATE
HEADER1 HEADER2 HEADER3
12345678 554579 TOTAL AMOUNT SOLD
12365789 559870 ALREADY SOLDOUT
12365786 559873 MIDDLE RECORD
12365784 559873 CLOSED RECORD
12365785 559873 EXISTING RECORD
12365780 559873 MIDDLE RECORD
TOTAL NO OF RECORDS:006
//SYSIN DD *
INCLUDE COND=(1,1,CH,EQ,C' ',&,2,8,FS,EQ,NUM)
OUTFIL REMOVECC,BUILD=(1,80),HEADER2=(C'PGMNAME',/,&DATENS=(MDY),/,
03:C'HEADER1',22:C'HEADER2',37:C'HEADER3'),
TRAILER2=(C'TOTAL NO OF RECORDS: ',COUNT=(M11,LENGTH=3))
SORT FIELDS=(37,25,CH,A)
Output :-
Code:
PGMNAME
040512
HEADER1 HEADER2 HEADER3
12365789 559870 ALREADY SOLDOUT
12365784 559873 CLOSED RECORD
12365785 559873 EXISTING RECORD
12365786 559873 MIDDLE RECORD
12365780 559873 MIDDLE RECORD
12345678 554579 TOTAL AMOUNT SOLD
TOTAL NO OF RECORDS: 006
Can you show us your complete spool WER msgs including sort card.