IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort to output file in sorted order


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Tue Mar 27, 2012 7:26 pm
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 27, 2012 7:29 pm
Reply with quote

If you're with DFSORT, please check DATASORT Operator of ICETOOL.
Back to top
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Tue Mar 27, 2012 7:42 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Mar 27, 2012 8:44 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 27, 2012 11:09 pm
Reply with quote

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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Wed Mar 28, 2012 12:29 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Mar 28, 2012 12:54 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 28, 2012 1:19 pm
Reply with quote

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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Wed Mar 28, 2012 1:28 pm
Reply with quote

I am using DFSORT , SORT utility . Version: FOR Z/OS 1.3.2.2R
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 28, 2012 1:39 pm
Reply with quote

'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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Wed Mar 28, 2012 2:43 pm
Reply with quote

WER276B
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed Mar 28, 2012 2:44 pm
Reply with quote

You saved him Bill! icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 28, 2012 2:46 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Mar 28, 2012 3:31 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Mar 28, 2012 5:19 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 28, 2012 8:36 pm
Reply with quote

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
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Thu Mar 29, 2012 10:07 am
Reply with quote

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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Wed Apr 04, 2012 8:42 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Apr 04, 2012 11:47 pm
Reply with quote

Ok.. Change C'DATE' to &DATENS=(MDY).

Thanks
-3nadh
Back to top
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Thu Apr 05, 2012 12:20 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Thu Apr 05, 2012 12:31 pm
Reply with quote

May be a typo error from your end. It should be &DATENS=(MDY) . Not &DATEN=(MDY).


Thanks
-3nadh
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2012 12:42 pm
Reply with quote

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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Thu Apr 05, 2012 1:11 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Thu Apr 05, 2012 1:48 pm
Reply with quote

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
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Thu Apr 05, 2012 3:01 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts Syncsort help SYNCSORT 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts Reroute print output via REXX/SDSF TSO/ISPF 6
Search our Forums:

Back to Top