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
 

 

help in SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
wiprov

New User


Joined: 13 Feb 2008
Posts: 15
Location: Chennai

PostPosted: Wed Jul 23, 2014 10:26 pm    Post subject: help in SORT
Reply with quote

Hi,

I have an input file as follows...

01 rec1
05 rec1
01 rec2
04 rec1
01 rec3
05 rec2
03 rec1
05 rec3


And i have to to direct this to two o/p files as follows
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(1,1,CH,EQ,C'01')
OUTFIL FILES=02,INCLUDE=(1,1,CH,EQ,C'05')

But the key part is, i have to pick only first two occurances of either '01' or '05, such that

O/p file -01:
01 rec1
01 rec2

O/p file2:
05 rec1
05 rec2

Is there any direct option in SORT to achieve this? I have already tried creating SEQNUM to the right and filtered based on that (pos,len,LT,3).
Just curious to know, is there any advanced/direct option in SORT to achieve this.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed Jul 23, 2014 11:25 pm    Post subject: Reply to: help in SORT
Reply with quote

What does your SyncSort manual say? DFSORT has ACCEPT on OUTFIL which does what you want. Does (your) SyncSort?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu Jul 24, 2014 2:30 pm    Post subject: Reply to: help in SORT
Reply with quote

As there is no ACCEPT parameter in SYNCSORT (v 1.4.1) and as I haven't succeeded in finding an equivalent option, I turned to SYNCTOOL.
There also it was not obvious (as there is no documentation) but I finally nailed it with this:
Code:
//STEP01   EXEC PGM=SYNCTOOL             
//SYSPRINT DD   SYSOUT=*                 
//TOOLMSG  DD   SYSOUT=*                 
//SSMSG    DD   SYSOUT=*                 
//IN       DD   *                         
04 REC1                                   
01 REC1                                   
05 REC1                                   
01 REC2                                   
04 REC2                                   
01 REC3                                   
05 REC2                                   
03 REC1                                   
05 REC3                                   
05 REC4                                   
01 REC4                                   
//TEMP     DD   DISP=(NEW,PASS),DSN=&TEMP
//OUTP1    DD   DISP=SHR,DSN=your.first.output.file                 
//OUTP2    DD   DISP=SHR,DSN=your.second.output.file                 
//TOOLIN   DD   *                                   
   COPY   FROM(IN)    TO(TEMP)  USING(OUT1)         
   SUBSET FROM(TEMP)  TO(OUTP1) KEEP INPUT FIRST(2)
   COPY   FROM(IN)    TO(TEMP)  USING(OUT2)         
   SUBSET FROM(TEMP)  TO(OUTP2) KEEP INPUT FIRST(2)
//OUT1CNTL DD   *                                   
   INCLUDE COND=(1,2,CH,EQ,C'01')                   
//OUT2CNTL DD   *                                   
   INCLUDE COND=(1,2,CH,EQ,C'05')                   
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Jul 24, 2014 2:46 pm    Post subject: Reply to: help in SORT
Reply with quote

Without ACCEPT, the SEQNUM solution you already have will be the preferred one.

Marso,

SUBSET can take a USING, where you could INCLUDE COND the record-types (individually) that you want. That would cut out a couple of operators. Still going through the file twice...
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu Jul 24, 2014 3:01 pm    Post subject:
Reply with quote

I tried that before:
Code:
            SUBSET FROM(IN) TO(OUTP1) KEEP INPUT FIRST(2) USING(OUT1)
SYT020I  SYNCSORT CALLED WITH IDENTIFIER "0001"                     
SYT063E  STOPAFT/SKIPREC/COND CANNOT BE USED WITH "SUBSET" OPERATOR 
SYT030I  OPERATION COMPLETED WITH RETURN CODE 12                     
I would have been too easy icon_confused.gif
Maybe it's time to talk to my boss and recommend DFSORT ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Jul 24, 2014 3:13 pm    Post subject: Reply to: help in SORT
Reply with quote

Looking deeper, same thing with DFSORT. I'm just waiting for the SELECT solution, which sorts the file on the record type, and then take the first two dupes (OPTION EQUALS) :-)
Back to top
View user's profile Send private message
wiprov

New User


Joined: 13 Feb 2008
Posts: 15
Location: Chennai

PostPosted: Thu Jul 24, 2014 5:18 pm    Post subject:
Reply with quote

Nice logic. Bunch of thanks for your code.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Jul 24, 2014 5:44 pm    Post subject: Reply to: help in SORT
Reply with quote

wiprov,

Are you saying you are going to use Marso's code (no offence Marso). It reads the entire file twice. You already have a SEQNUM solution. Depending on the size of your file, frequency of running, usual type of stuff, you may be making the wrong choice...
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jul 25, 2014 1:48 pm    Post subject:
Reply with quote

I was just trying and came up with this. Is there something wrong in it?
Code:
//STEP01   EXEC PGM=SYNCTOOL           
//TOOLMSG  DD SYSOUT=*                 
//DFSMSG   DD SYSOUT=*                 
//IN       DD *                         
04 REC1                                 
01 REC1                                 
05 REC1                                 
01 REC3                                 
04 REC2                                 
01 REC2                                 
05 REC2                                 
03 REC1                                 
05 REC3                                 
05 REC4                                 
01 REC4                                 
//**                                   
//OUT1     DD SYSOUT=*                 
//OUT2     DD SYSOUT=*                 
//**                                   
//TOOLIN   DD *                         
  COPY   FROM(IN)   TO(OUT1) USING(CTL1)
  COPY   FROM(IN)   TO(OUT2) USING(CTL2)
//CTL1CNTL DD *                         
  OPTION STOPAFT=2                     
  INCLUDE  COND=(1,2,CH,EQ,C'01')       
//CTL2CNTL DD *                         
  OPTION STOPAFT=2                     
  INCLUDE  COND=(1,2,CH,EQ,C'05')       

Output
OUT1
Code:
********
01 REC1
01 REC3
********

OUT2
Code:
*******
05 REC1
05 REC2
*******
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Jul 25, 2014 2:15 pm    Post subject: Reply to: help in SORT
Reply with quote

mistah kurtz,

No, that's fine. Good shot.

Better than the SEQNUM, which is going to require reading the entire file all the time. This will stop when two records have got past the INCLUDE COND=, so assuming a reasonable distribution of data it will not read anywhere near so many records, despite theoretically reading the entire file twice.

The ACCEPT on OUTFIL would be better, but SyncSort doesn't have that...
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jul 25, 2014 3:08 pm    Post subject:
Reply with quote

Thanks Bill
Back to top
View user's profile Send private message
JAYACHANDRAN THAMPY

New User


Joined: 06 Jun 2006
Posts: 8

PostPosted: Fri Jul 25, 2014 6:39 pm    Post subject:
Reply with quote

Syncsort V1.4.2 supports ACCEPT on OUTFIL
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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 Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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