Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syncsort to output file in sorted order
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 81
Location: bangalore

PostPosted: Tue Mar 27, 2012 7:26 pm    Post subject: Syncsort to output file in sorted order
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: 785
Location: Chennai, India

PostPosted: Tue Mar 27, 2012 7:29 pm    Post subject:
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: 81
Location: bangalore

PostPosted: Tue Mar 27, 2012 7:42 pm    Post subject:
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

Senior Member


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

PostPosted: Tue Mar 27, 2012 8:44 pm    Post subject:
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 Moderator


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

PostPosted: Tue Mar 27, 2012 11:09 pm    Post subject:
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: 81
Location: bangalore

PostPosted: Wed Mar 28, 2012 12:29 pm    Post subject: Reply to: JCL sort help
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    Post subject: Reply to: JCL sort help
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Mar 28, 2012 1:19 pm    Post subject: Reply to: JCL sort help
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: 81
Location: bangalore

PostPosted: Wed Mar 28, 2012 1:28 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Mar 28, 2012 1:39 pm    Post subject: Reply to: JCL sort help
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: 81
Location: bangalore

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

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

Senior Member


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

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

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Mar 28, 2012 2:46 pm    Post subject: Reply to: JCL sort help
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    Post subject: Reply to: JCL sort help
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Mar 28, 2012 5:19 pm    Post subject: Reply to: JCL sort help
Reply with quote

the TS was asked here
http://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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Mar 28, 2012 8:36 pm    Post subject: Re: Reply to: JCL sort help
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    Post subject:
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: 81
Location: bangalore

PostPosted: Wed Apr 04, 2012 8:42 pm    Post subject:
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    Post subject: Reply to: JCL sort help
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: 81
Location: bangalore

PostPosted: Thu Apr 05, 2012 12:20 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us