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

help in SORT


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 23, 2014 11:25 pm
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: 1353
Location: Israel

PostPosted: Thu Jul 24, 2014 2:30 pm
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

Moderator Emeritus


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

PostPosted: Thu Jul 24, 2014 2:46 pm
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: 1353
Location: Israel

PostPosted: Thu Jul 24, 2014 3:01 pm
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

Moderator Emeritus


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

PostPosted: Thu Jul 24, 2014 3:13 pm
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
Reply with quote

Nice logic. Bunch of thanks for your code.
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 Jul 24, 2014 5:44 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jul 25, 2014 1:48 pm
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

Moderator Emeritus


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

PostPosted: Fri Jul 25, 2014 2:15 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jul 25, 2014 3:08 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top