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

Syncsort - Sort by maximum occuerence of item#


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

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Jan 14, 2011 9:03 am
Reply with quote

The requirement is to sort the data on the max no. of occurrences of a field. The input is as follows :

1111ABC
1111ABC
1111ABC
0111DDD
0111DDD
0111DDD
0111DDD
0111DDD
0011XXX
0011XXX

Output file to look like:

0111DDD
0111DDD
0111DDD
0111DDD
0111DDD
1111ABC
1111ABC
1111ABC
0011XXX
0011XXX

This post was in DFSORT forum where Skolusu had provided the below option :

Code:
//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//INA      DD DSN=your input file,DISP=SHR
//INB      DD DSN=same input file again,DISP=SHR
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                       
  JOINKEYS F1=INA,FIELDS=(1,7,A)     
  JOINKEYS F2=INB,FIELDS=(1,7,A)     
  JOIN UNPAIRED                       
  REFORMAT FIELDS=(F1:1,80,F2:81,8)   
  SORT FIELDS=(81,8,CH,D),EQUALS
  OUTREC BUILD=(1,80)       
//JNF2CNTL DD *                       
  INREC OVERLAY=(81:7C'0',C'1')       
  SUM FIELDS=(81,8,ZD)               
//*



I wanted to try using ICETOOL'S WHEN=GROUP option .

I wanted to include the 1st 4 chars in col 85 for records in same group and a seq num for each record. Then sort on the seq num and col 85 , 4

It would be something as follows :


cols 1 - 7 : input data
81 - 82 seq num
85 - 88 1st 4 chars
Code:
---1-7-------------81-82  -----85-88
1111ABC              01           1111
1111ABC              02           1111
1111ABC              03           1111
0111DDD              01           0111
0111DDD              02           0111
0111DDD              03           0111
0111DDD              04           0111
0111DDD              05           0111
0011XXX               01           0011
0011XXX               02           0011


//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
SORT FROM(T1) TO(SORTOUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4),
PUSH=(85:1,4,81:SEQ=2))
SORT FIELDS=COPY
SUM FIELDS=(81,2,ZD)
//CTL2CNTL DD *
SORT FIELDS=(85,4,ZD,D,81,2,ZD,D)
OUTREC BUILD=(1,88)
//*

We have SYNCSORT , and on executing the above jcl i get the following error :

CTL1CNTL :
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4),
*
PUSH=(85:1,4,81:SEQ=2))
SORT FIELDS=COPY
SUM FIELDS=(81,2,ZD)
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000

Could you please help me in understanding what's the error in INREC.

Also do let me know other than JOINKEYS , is there any other way to achieve this.
Thanks
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Fri Jan 14, 2011 3:14 pm
Reply with quote

Possibly because you are on earlier release of SyncSort in which PUSH is not yet available...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jan 14, 2011 8:36 pm
Reply with quote

Hello,

Which release of Syncsort is being used?

Why not use JOINKEYS? Why re-invent a process that already works?

Maybe there is something i misunderstand . . .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jan 14, 2011 10:37 pm
Reply with quote

Ambili S,

I understood your initial requirement and Kolusu's reply on that.

It's quite obvious that Kolusu's solution is for DFSORT and if you're a Syncsort user as your topic title suggests, it may not work for you because DFSORT has added a lot more to their version of JOIN than what Syncsort JOIN had originally.
Ambili S wrote:
I wanted to try using ICETOOL'S WHEN=GROUP option .

I wanted to include the 1st 4 chars in col 85 for records in same group and a seq num for each record. Then sort on the seq num and col 85 , 4
Now are you trying for an alternative solution or is it a totally new requirement?

btw KEYBEGIN is a DFSORT feature which came into existence in Oct 2010. AFAIK Syncsort supports PUSH and WHEN=GROUP, but NOT KEYBEGIN as of today.

So you need to explain clearly what you're trying to achieve here.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Mon Jan 17, 2011 10:34 am
Reply with quote

Hi Dick

All i wanted to know was if the result can be achieved using any option other than JOINKEYS . Also i am not very clear on the JOINKEYS option mentioned above.

Code:
  JOINKEYS F1=INA,FIELDS=(1,7,A)     
  JOINKEYS F2=INB,FIELDS=(1,7,A)     
  JOIN UNPAIRED                       
  REFORMAT FIELDS=(F1:1,80,F2:81,8)   
  SORT FIELDS=(81,8,CH,D),EQUALS
  OUTREC BUILD=(1,80)       
//JNF2CNTL DD *                       
  INREC OVERLAY=(81:7C'0',C'1')       
  SUM FIELDS=(81,8,ZD)


What i understood here is , INB file has '00000001' from 81 position. Then REFORMAT is done and the summation. But when i try the above jcl it says , REFORMAT OUT OF RANGE. So i tried increasing the LRECL if INB to 88 and it worked.
But still not clear as to how the SUM is working .
Also if you could suggest me some other alternative it would be really helpful.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jan 17, 2011 11:17 am
Reply with quote

Hello,

If you don't want to use the feature implemented to do things like this, you could always write a bit of (cobol?) code to do what you want. . .

It also appears that you have posted only part of what you are submitting. You need to post the entire sort step (jcl and control statements). Also post the informatoinal output from an execution of this complete set of info.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Jan 17, 2011 2:22 pm
Reply with quote

Hi Ambil,

this maybe a solution without using JOINKEYS
Code:
//S1       EXEC PGM=SYNCTOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD *                                             
1111ABC                                                     
1111ABC                                                     
1111ABC                                                     
0111DDD                                                     
0111DDD                                                     
0111DDD                                                     
0111DDD                                                     
0111DDD                                                     
0011XXX                                                     
0011XXX                                                     
//T1       DD DSN=&&T1,DISP=(,PASS,DELETE),                 
//            UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE)             
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                             
SORT FROM(IN) TO(T1) USING(CTL1)                             
SORT FROM(T1) TO(OUT) USING(CTL2)                           
//CTL1CNTL DD *                                                   
  INREC  OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))                   
  SORT FIELDS=(1,7,CH,A,81,8,ZD,D)                               
/*                                                               
//CTL2CNTL DD *                                                   
  INREC  OVERLAY=(89:SEQNUM,8,ZD,RESTART=(1,7),                   
                  97:81,8,ZD,ADD,89,8,ZD)                         
  SORT FIELDS=(97,15,ZD,D,1,7,CH,A)                               
  OUTREC BUILD=(1,80)                                             
/*                                                               

Gerry
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Mon Jan 17, 2011 5:24 pm
Reply with quote

Thanks Gerry icon_smile.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jan 18, 2011 10:23 am
Reply with quote

Quote:
What i understood here is , INB file has '00000001' from 81 position. Then REFORMAT is done and the summation. But when i try the above jcl it says , REFORMAT OUT OF RANGE. So i tried increasing the LRECL if INB to 88 and it worked.
But still not clear as to how the SUM is working .
You dont seem to understand that what you're trying to execute is not available to you. A DFSORT solution may not work for a Syncsort user. DFSORT and Syncsort and competitive sort products.

Here the logic is simple. INB is padded with '00000001' at the end and summed on key to find the count of records for each key, Then the JOIN is performed to overlay the count next to each record in the input file. Finally SORT is performed to sort the records in descending order of the 'count'.
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 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
Search our Forums:

Back to Top