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

permutation combination in SYNCSORT...


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

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Mon Nov 17, 2008 10:55 pm
Reply with quote

Hi,

I have two files as below.

File 1 Content

AAA BBB CCC
AAA EEE FFF
AAA GGG HHH
GGG HHH III

File 2 Content

XXX
YYY
ZZZ
WWW


I want my output file should be as below

AAA BBB CCC XXX
AAA BBB CCC YYY
AAA BBB CCC ZZZ
AAA BBB CCC WWW
AAA EEE FFF XXX
AAA EEE FFF YYY
AAA EEE FFF ZZZ

For each entry in file 1 should have entries for file2. Number of records in file 1 and file 2 always varies.

Is it possible to do?
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Nov 18, 2008 2:17 am
Reply with quote

Sasikumar,

Try this:
Code:
//STEP1 EXEC PGM=SORT                       
//SYSOUT  DD SYSOUT=*                       
//SORTOUT DD DISP=(NEW,PASS),DSN=&&TEMP1,...   
//SORTIN  DD *                               
AAA BBB CCC                                 
AAA EEE FFF                                 
AAA GGG HHH                                 
GGG HHH III                                 
//SYSIN   DD *                               
  SORT FIELDS=COPY                         
  OUTREC OVERLAY=(12:C' ')
//*********************************               
//STEP2 EXEC PGM=SORT                     
//SYSOUT  DD SYSOUT=*                       
//SORTOUT DD DISP=(NEW,PASS),DSN=&&TEMP2,...   
//SORTIN  DD *                             
XXX                                       
YYY                                       
ZZZ                                       
WWW                                       
//SYSIN   DD *                               
  SORT FIELDS=COPY                         
  OUTREC OVERLAY=(4:C' ')
//**********************************                 
//STEP3  EXEC PGM=SORT               
//SORTJNF1 DD DISP=SHR,DSN=&&TEMP1 
//SORTJNF2 DD DISP=SHR,DSN=&&TEMP2 
//SORTOUT  DD SYSOUT=*               
//SYSOUT   DD SYSOUT=*               
//SYSIN    DD *                       
  JOINKEYS FILES=F1,FIELDS=(12,1,A)
  JOINKEYS FILES=F2,FIELDS=(4,1,A) 
  REFORMAT FIELDS=(F1:1,12,F2:1,3) 
  SORT FIELDS=COPY
/* 

Steps 1 & 2 are simply inserting a control field at the end of the record, which can then be used as the JOINKEY in Step 3.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Nov 18, 2008 6:50 pm
Reply with quote

Alissa,

Quote:
Steps 1 & 2 are simply inserting a control field at the end of the record, which can then be used as the JOINKEY in Step 3.


In this example do we actually need the first 2 steps? Anyways the 12th and 4th column are spaces in both the input files.

I can understand that this has got somwthing to do with the input record length. Just thought of asking you.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 18, 2008 7:11 pm
Reply with quote

Aaru,

I guess that's to generate a key in both the files which will result in a match for all the records. Unless you have something like that, you need those 2 steps. But in this particular example(instream input) I guess it's not really needed. But when it comes to "real" files, you may not have such a key in both the files which has the same value for all the records.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Nov 18, 2008 8:37 pm
Reply with quote

Aaru wrote:
In this example do we actually need the first 2 steps?

Arun is correct. In this particular example, inserting the control field is not necessary, but I was trying to provide a jobstream that could be easily modified for "real world" situations.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Nov 19, 2008 11:40 pm
Reply with quote

Thanks Arun and Alissa for the confirmation.
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Thu Nov 20, 2008 7:27 am
Reply with quote

Hi All,

Thanks for all u people support.... But my requirement bit got changed. i explained below.

File 1 Content

AAA BBB CCC 123 001 01
AAA BBB CCC 123 001 02
AAA EEE FFF 456 002 01
AAA GGG HHH 456 003 02
GGG HHH III 789 001 01

File 2 Content

XXX 123 001
YYY 123 001
ZZZ 123 001
XXX 123 002
YYY 123 002
YYY 456 002
WWW 456 002
YYY 789 001


I want my output file should be as below

AAA BBB CCC XXX 123 001 01
AAA BBB CCC YYY 123 001 01
AAA BBB CCC ZZZ 123 001 01
AAA BBB CCC XXX 123 001 02
AAA BBB CCC YYY 123 001 02
AAA EEE FFF YYY 456 002 01
AAA EEE FFF WWW 456 002 01
GGG HHH III YYY 789 001 01

Each entry in file 1 should have all the entries present in file having variable 2 and variable 3 in file 2 should match with variable 4 and variable 5 in file 1.

Can someone pls change the SORT card and provide me. Thanks in advance.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Nov 20, 2008 8:54 am
Reply with quote

Sasikumar,

Do you want only the matching records into the output? What about the non-matching entries in both the files(not shown in your example)?
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Thu Nov 20, 2008 8:59 am
Reply with quote

Hi Arun,

Thanks for reply. my output file should have for each entry in file 1 all the entries of file 2 having matching variable 4 and variable 5 in file 1 with variable 2 and variable 3 in file 2. If there is no match with file 2 then i dont need the that entry at all. hope this is clear.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Nov 20, 2008 9:15 am
Reply with quote

Sasikumar,

You can use the below Syncsort job to achieve this.
Code:
//STEP1  EXEC PGM=SORT               
//SORTJNF1 DD DSN= File1
//SORTJNF2 DD DSN= File2
//SORTOUT  DD DSN= Output file               
//SYSOUT   DD SYSOUT=*               
//SYSIN    DD *                       
  JOINKEYS FILES=F1,FIELDS=(13,7,A)
  JOINKEYS FILES=F2,FIELDS=(5,7,A)
  REFORMAT FIELDS=(F1:1,12,F2:1,11,F1:20,3)
  SORT FIELDS=COPY
/* 
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Thu Nov 20, 2008 11:17 pm
Reply with quote

Hi Arun,

It worked fine for me... thanks a lot....
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Sat Nov 22, 2008 12:46 pm
Reply with quote

Arun,

There is only one step in your final JCL icon_biggrin.gif
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Sun Nov 23, 2008 8:47 am
Reply with quote

Yes Arun, only one step.. but i have a small doubt... what is the purpose of first two steps provided by Alissa first.. Please explain me.
Back to top
View user's profile Send private message
abhishek dadhichi

New User


Joined: 19 Apr 2007
Posts: 37
Location: Bangalore

PostPosted: Mon Nov 24, 2008 3:04 pm
Reply with quote

Hi All,

I tried running the above code given by Alissa Margulies, but the following is the comppilation error.

code:
-------- PROCESSING SYSIN --------
JOINKEYS FILES=F1,FIELDS=(12,1,A)
E3 - DSS10065E - PARAMETER 'FILES' IS UNIDENTIFIED.
JOINKEYS FILES=F2,FIELDS=(4,1,A)
E4 - DSS10065E - PARAMETER 'FILES' IS UNIDENTIFIED.
REFORMAT FIELDS=(F1:1,12,F2:1,3)
SORT FIELDS=COPY


Pls let me know if this is the error due to SORT utility

Thanks,
Abhishek
[/code]
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 Nov 24, 2008 3:12 pm
Reply with quote

Hello,

Are you running Syncsort? If you are running Syncsort, which version? If you are not running Syncsort, you will probably not be able to use JOINKEYS.

Did you submit the job or simply run it thru some jcl checker? If you did not submit the job, do so.
Back to top
View user's profile Send private message
abhishek dadhichi

New User


Joined: 19 Apr 2007
Posts: 37
Location: Bangalore

PostPosted: Mon Nov 24, 2008 3:38 pm
Reply with quote

Hi Dick,

Just checked in my shop ..it is DFSORT not syncsort.
Thanks for the response, dont we have similar Joinkeys facility in DFSORT..just curious.



Thanks,
Regards
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 Nov 24, 2008 3:44 pm
Reply with quote

Hello,

While the sort products have many similarities, they also have quite a few differences.

If you start a new topic in the DFSORT part of the forum and describe your input files and relevant fields and what you want as output, someone may be able to show you a way to to what you need without joinkeys.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Nov 25, 2008 1:44 am
Reply with quote

abhishek dadhichi wrote:
Thanks for the response, dont we have similar Joinkeys facility in DFSORT..just curious.
Joinkeys are the "facility" from SyncSort.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 25, 2008 1:48 pm
Reply with quote

wrote:
what is the purpose of first two steps provided by Alissa first.. Please explain me.

sasikumar1984,

The purpose of those steps is already explained in this thread. Initially you tried a "keyless" matching which requires overlaying keys explicitly before matching. But your second requirement really had keys to match.
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Wed Nov 26, 2008 8:00 am
Reply with quote

Thanks for ur reply Arun....
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 Compare only first records of the fil... SYNCSORT 7
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8
No new posts Sort counter to show records combination JCL & VSAM 2
No new posts Syncsort "Y2C" Function SYNCSORT 1
Search our Forums:

Back to Top