|
View previous topic :: View next topic
|
| Author |
Message |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Hi
I have an input file in below format
| Code: |
pgmname
Date
HEADER1 HEADER2 HEADER3
12345678 554579 TOTAL AMOUT SOLD
12365789 559870 ALREADY SOLDOUT
......
TOTAL NO OF RECORDS:100 |
I need an output file in sorted order of only HEADER3
OUTPUT :
| Code: |
pgmname
Date
HEADER1 HEADER2 HEADER3
12345678 554579 ALREADY SOLDOUT
12365789 559870 TOTAL AMOUT SOLD
.......
TOTAL NO OF RECORDS:100 |
I am using the below sort logic but its not working
| Code: |
OPTION COPY
OUTREC IFTHEN=(WHEN=(05,3,CH,EQ,C'ICN',OR,01,5,CH,EQ,C'TOTAL'),
HIT=NEXT)
|
Can anyone help me on this ? |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
| If you're with DFSORT, please check DATASORT Operator of ICETOOL. |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Actually I am using the
| Code: |
OPTION COPY
OUTREC IFTHEN=(WHEN=(01,7,CH,EQ,C'HEADER1',OR,01,5,CH,EQ,C'TOTAL'),
HIT=NEXT) |
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

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?
It's quarter to nine in the office. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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. |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
| Thanks its working fine. But I need the results to be achived using SORT utility. How to get the same results using PGM=SORT |
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
janmejay,
| Quote: |
But I need the results to be achived using SORT utility. How to get the same results using PGM=SORT
|
Tell us what sort product and the version you are using ?
Thanks
-3nadh |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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. |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
| I am using DFSORT , SORT utility . Version: FOR Z/OS 1.3.2.2R |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
'S funny, as the version number you quote is for Syncsort.
Do you get messages which start WER in the output from sort steps? |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
| WER276B |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
You saved him Bill!  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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. |
|
| Back to top |
|
 |
bodatrinadh
Active User

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
|
Thanks
-3nadh |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
the TS was asked here
ibmmainframes.com/viewtopic.php?t=44883&highlight=
about the sort product in use in his organization,
but he did not care to reply
Usually when I see some topics I look at the TS profile, to see his/her way of doing things,
and... yes, the behavior does not change |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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... |
|
| Back to top |
|
 |
xknight
Active User

Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Also try the below snippet, only if the chance of your request being different as suggested by bill.
| Code: |
//STEP01 EXEC PGM=SORT
//SORTIN DD *
PGMNAME
DATE
HEADER1 HEADER2 HEADER3
12345678 554579 TOTAL AMOUT SOLD
12365789 559870 ALREADY SOLDOUT
12365789 559870 AAAAADY SOLDOUT
12365789 559870 XRERADY SOLDOUT
12365786 559873 MIDDLE RECORD
TOTAL NO OF RECORDS:100
//SORTOUT DD DSN=&TMP,
// DISP=(MOD,PASS,DELETE),
// RECFM=FB,LRECL=85,BLKSIZE=0,
// SPACE=(CYL,(10,10),RLSE),UNIT=SYSDA
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(1,80,SS,EQ,C'PGM'),OVERLAY=(81:C'3')),
IFTHEN=(WHEN=(1,80,SS,EQ,C'DATE'),OVERLAY=(81:C'2')),
IFTHEN=(WHEN=(1,80,SS,EQ,C'HEADER'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(1,80,SS,EQ,C'TOTAL NO'),OVERLAY=(81:X'00'))
SORT FIELDS=(37,18,CH,A)
//*
//STEP02 EXEC PGM=SORT
//SORTIN DD DSN=&TMP,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,1,CH,D)
OUTFIL BUILD=(1,80) |
Output:
| Code: |
********************************* 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 |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Hi bodatrinadh
its working fine. but there is issue like the Date in second header should be the current date in MMDDYY format not C'DATE' .so how to print the Date. |
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
Ok.. Change C'DATE' to &DATENS=(MDY).
Thanks
-3nadh |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
i just replaced C'DATE' TO &DATEN=(MDY) keeping remainind as same. now its showing WER118A SORTOUT ILLEGAL OVERLAPPING FIELDS '
how to correct this. |
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
May be a typo error from your end. It should be &DATENS=(MDY) . Not &DATEN=(MDY).
Thanks
-3nadh |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| janmejay wrote: |
i just replaced C'DATE' TO &DATEN=(MDY) keeping remainind as same. now its showing WER118A SORTOUT ILLEGAL OVERLAPPING FIELDS '
how to correct this. |
How about posting your cards and the messages? Much easier than to-and-fro. |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Hi Bodatrinadh
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 .
should we need to use overlay parameter |
|
| Back to top |
|
 |
bodatrinadh
Active User

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.
Thanks
-3nadh |
|
| Back to top |
|
 |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Its working now. thank you.
one more thing like My Header is some what big its like more than 120 character.
PGM NAME CUSTOMER MONTHLY INVENTORY STATUS REPORT
now if I am continuing to next line its showing error
C' PGM NAME CUSTOMER MONTHLY INVENTORY
STATUS REPORT',/,&DATENS=(MDY),..........
how to continue to next statement for the same line. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|