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

Syncsort Sort between records


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

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Sat Aug 21, 2010 4:18 am
Reply with quote

Hi All,

I have the below case which needs some help. I have a sequential file with recfm=fb and lrecl=300. It contains records in the below manner.

COLS> ----+----1----+----2----+----3----+-
*********************************** Top of
000001 152020100729922
000002 252020100729000000711920 300013400CV
000003 300000506472943110567335020100726201
000004 452020100729000000711920 30001340000
000005 252020100729000001001267 300003997IC
000006 300000506509052110056397020100728201
000007 300000506509058120056397020100726201
000008 300000506511560110924657420100729201
000009 452020100729000002004721 30001380000
000010 252020100729000002223814 300013400CV
000011 300000506463549110860299220100729201
000012 300000506515062110875863020100725201
000013 452020100729000002223814 30001340000
000014 552020100729922000082000000039600000


Only Record 3 has a date field which needs to be sorted in ascending order. Record 3 always comes between record 2 and 4. I only need to sort record 3 . Any other records should remain as they are. i.e the output should look like this,

COLS> ----+----1----+----2----+----3----+-
*********************************** Top of
000001 152020100729922
000002 252020100729000000711920 300013400CV
000003 300000506472943110567335020100726201
000004 452020100729000000711920 30001340000
000005 252020100729000001001267 300003997IC
000006 300000506509052110056397020100726201
000007 300000506509058120056397020100728201
000008 300000506511560110924657420100729201
000009 452020100729000002004721 30001380000
000010 252020100729000002223814 300013400CV
000011 300000506463549110860299220100725201
000012 300000506515062110875863020100729201
000013 452020100729000002223814 30001340000
000014 552020100729922000082000000039600000

Is it possible using sort?
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: Sat Aug 21, 2010 5:31 am
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you wanted. I assumed that '3' is in position 1 and the date starts in position 26.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/300)
//OUT DD DSN=...  output file (FB/300)
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'2'),
    END=(1,1,CH,EQ,C'4'),PUSH=(301:ID=8))
  SORT FIELDS=(301,8,ZD,A,1,1,CH,A,26,8,CH,A)
  OUTFIL FNAMES=OUT,BUILD=(1,300)
/*
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Sat Aug 21, 2010 6:39 am
Reply with quote

If the record type '5' ( record number 14 ) is not the file trailer, I am not certain that the original sequence of "groups" will be maintained with the solution posted, since the '5' record will not fall between the BEGIN and END criteria (inclusive) and will, therefore, have no group id number in positions 301-304.

If the type '5' record is the highest record type OTHER than the trailer, I think that the END statement will need to be changed to
Code:
    END=(1,1,SS,EQ,C'4,5'),PUSH=(301:ID=8))


Note: if the file contains other type records as well (other than the trailer, that is), it would be
Code:
    END=(1,1,SS,EQ,C'4,5,?'),PUSH=(301:ID=8))


where ? represents another value; etc. if there are others

Please let me know if I am wrong. I was unable to perform any tests (could not connect to mainframe tonight for some unknown reason).
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Sat Aug 21, 2010 9:56 pm
Reply with quote

baljinders,

See if below works for you...

Code:

//SORT01   EXEC PGM=SORT                                           
//SORTIN   DD  *                                                   
152020100729922                                                     
252020100729000000711920 300013400CV                               
300000506472943110567335020100726201                               
452020100729000000711920 30001340000                               
252020100729000001001267 300003997IC                               
300000506509052110056397020100728201                               
300000506509058120056397020100726201                               
300000506511560110924657420100729201                               
452020100729000002004721 30001380000                               
252020100729000002223814 300013400CV                               
300000506463549110860299220100729201                               
300000506515062110875863020100725201                               
452020100729000002223814 30001340000                               
552020100729922000082000000039600000                               
//SORTOUT  DD  SYSOUT=*                                             
//SYSIN    DD  *                                                   
 OPTION EQUALS                                                     
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(301:SEQNUM,8,ZD,RESTART=(1,1))), 
       IFTHEN=(WHEN=GROUP,BEGIN=(301,8,ZD,EQ,1),PUSH=(311:ID=8)),   
       IFTHEN=(WHEN=(1,1,ZD,EQ,3),OVERLAY=(321:26,8))               
 SORT FIELDS=(311,8,ZD,A,321,8,CH,A)
 OUTFIL BUILD=(1,300)                             
//SYSOUT   DD  SYSOUT=*                                             
//SYSPRINT DD  SYSOUT=*                                             
//SYSUDUMP DD  SYSOUT=D                                             


Thanks,
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Mon Aug 23, 2010 3:12 am
Reply with quote

Thanks a lot guys... i'll try them and get back to you.
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Mon Aug 23, 2010 7:40 pm
Reply with quote

Is there any other way to do it as the synctool and syncsort version that we have doesn't recognise datasort, group and push functions.
Synctool version: 1.6.1 and syncsort version 1.3.1.0R
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Aug 23, 2010 9:01 pm
Reply with quote

Is the '1' record a file header? Is the '5' record a file trailer? Or is it possible that either will occur multiple times in the file?
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Mon Aug 23, 2010 9:33 pm
Reply with quote

Either will occur multiple times in the file
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: Mon Aug 23, 2010 11:44 pm
Reply with quote

Ronald,

I tend to give solutions based on the example the poster shows. Given how badly people present their requirements here, if I tried to guess what other variations there might be in the data that were not posted, I couldn't give any answers at all. If my solution doesn't work because the posted data was incomplete, then I expect the poster to tell me that, and give me a better example. I usually note my assumptions, but sometimes I get too busy to do that, as in this case.

Given the example posted, I think it was fair to assume that '1' is the header and '5' is the trailer and they only occur once. Of course, if the poster had come back and said "here's what the data really looks like", then I would given a new job based on that data. But in this case, it turns out the poster is using Syncsort, not DFSORT, and I don't respond to Syncsort questions.

So basically, the poster posted in the wrong Forum and showed a bad example, which to me, qualifies as "garbage in, garbage out".

(Sometimes I wonder why I bother.)
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Aug 24, 2010 12:05 am
Reply with quote

I understand your point completely, Frank - in this case it appears that several folks wasted time attempting to provide a valid DFSORT solution to whatever "requirement" one inferred from what was posted.

As it is, I realized, after the fact, that the "solution" that I suggested would not produce the correct results for the situation I thought might be the case.

I'm not sure that there even IS a one-step Syncsort solution, though I have placed the problem on the back burner of my brain in case a solution pops into mind.
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Tue Aug 24, 2010 12:40 am
Reply with quote

My apologies for the confusion. 1 is infact the header and 5 the trailer.
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

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top