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

SYNCSORT Comparing two files with more than 1 condition


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

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Wed Jun 04, 2008 4:16 pm
Reply with quote

Please let me know if the following can be done using SYNCSORT.

I have 2 files with 3 columns each... for input
They are

File 1

Col1 Col2 Col3
1 E1 A1
2 E2 A2
3 E3 A3

File 2

Col1 Col2 Col3
1 E1 A1
3 E4 A4
7 E7 E7


Then I need the output file to be

Col1 Col2 Col3 Col4 Col5
3 E3 A3 E4 A4

That is output file should contain only , if Col1 of File 1 = Col1 of File2 and (Col2 or Col3) of File 1 not = (Col2 or col3) of File 2 ...

as you can see the output file should contain columns from both file1 and file 2.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 04, 2008 4:48 pm
Reply with quote

Try this code.
Code:

//S1 EXEC PGM=SORT                           
//SORTMSG DD SYSOUT=*                         
//DFSMSG DD SYSOUT=*                         
//SYSOUT DD SYSOUT=*                         
//SORTJNF1 DD *                               
1 E1 A1                                       
2 E2 A2                                       
3 E3 A3                                       
//SORTJNF2 DD *                               
1 E1 A1                                       
3 E4 A4                                       
7 E7 E7                                       
//MYOUT DD DSN=USERID.SORTIN,DISP=SHR       
//SYSIN DD *                                 
  OPTION COPY                                 
  JOINKEYS FILES=F1,FIELDS=(1,01,D)           
  JOINKEYS FILES=F2,FIELDS=(1,01,D)           
  REFORMAT FIELDS=(F1:1,80,F2:1,80)           
   OUTFIL FNAMES=MYOUT                           
   OUTREC FIELDS=(1,7,X,83,7,65X)                 
 /*                                               
 //S2 EXEC PGM=SORT                               
 //SORTMSG DD SYSOUT=*                           
 //DFSMSG DD SYSOUT=*                             
 //SYSOUT DD SYSOUT=*                             
 //SORTIN DD DSN=USERID.SORTIN,DISP=SHR         
 //SORTOUT DD DSN=USERID.SORTOUT,DISP=SHR       
 //SYSIN DD *                                     
   SORT FIELDS=COPY                               
   INCLUDE COND=((3,2,CH,NE,9,2,CH),OR,           
                 (6,2,CH,NE,12,2,CH))             
 /*                                               
 //SYSOUT DD SYSOUT=*                             
 //SYSPRINT DD SYSOUT=*


Note: I assumed the LRECL of the file as 80
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Wed Jun 04, 2008 5:10 pm
Reply with quote

Hi , thanks for your solution..
can you pls let me know what X stands for in the below line..

OUTREC FIELDS=(1,7,X,83,7,65X)
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Wed Jun 04, 2008 5:12 pm
Reply with quote

Aniyaa,
Check the below code.

Code:

//S1       EXEC  PGM=SORT                               
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SORTJNF1 DD *                                         
1 E1 A1                                                 
2 E2 A2                                                 
3 E3 A3                                                 
//SORTJNF2 DD *                                         
1 E1 A1                                                 
3 E4 A4                                                 
7 E7 E7                                                 
//MYOUT    DD SYSOUT=*                                 
//SYSIN    DD *                                         
  JOINKEYS FILES=F1,FIELDS=(01,01,A)                   
  JOINKEYS FILES=F2,FIELDS=(01,01,A)                   
  REFORMAT FIELDS=(F1:1,7,F2:1,7)                       
  SORT FIELDS=COPY                                     
  OUTFIL FNAMES=MYOUT,INCLUDE=((3,2,CH,NE,10,2,CH),AND,
                      (6,2,CH,NE,13,2,CH)),             
  OUTREC=(1,7,1X,10,5,80:X)                             


Thanks
Back to top
View user's profile Send private message
0d311

Guest





PostPosted: Wed Jun 04, 2008 5:21 pm
Reply with quote

Aniyaa wrote:
Hi , thanks for your solution..
can you pls let me know what X stands for in the below line..

OUTREC FIELDS=(1,7,X,83,7,65X)


'X' stands for space.
Back to top
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Thu Jun 05, 2008 11:13 am
Reply with quote

Hi,

Thanks a lot for all your suggestions . I got the solution right.

Now I have two choices , I can implement the above using a cobol program or using a sort(as you have suggested above).

Which would be better , considering there would be around 60,000 to 70,000 records in each of the input files.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Thu Jun 05, 2008 12:30 pm
Reply with quote

Well,

Run two JOBs one using above sorts & other with the program, check for CPU consumption. Try to run both the JOBs at the same time.
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: Thu Jun 05, 2008 7:46 pm
Reply with quote

Hello,

Quote:
Which would be better , considering there would be around 60,000 to 70,000 records in each of the input files.
This volume should not be an issue either way.

Quote:
Try to run both the JOBs at the same time.
I'd not run them concurrently - there may be performance issues as well as allocation issues. If you run both tests, i'd suggest you run them serially and alternate the order of execution making multiple tests.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Thu Jun 05, 2008 9:59 pm
Reply with quote

Hi Dick,
dick scherrer wrote:
Quote:
Try to run both the JOBs at the same time.
I'd not run them concurrently - there may be performance issues as well as allocation issues. If you run both tests, i'd suggest you run them serially and alternate the order of execution making multiple tests.
Recently, I ran one job two times with the same inputs/setups, but at different times CPU usage were different, so I suggested the above.

For the TS concern, there might be a problem in using the same DSN in both the "concurrent" JOBs (one JOB might go on 'hold') but that DSN name can be changed, while having the same contents, if some one is concerned about performance issues.
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 Jun 06, 2008 2:04 am
Reply with quote

Hello,

Quote:
but at different times CPU usage were different
This should not have an impact on the amount of cpu the "test" job uses. It may impact wall time, but not cpu time needed.

When trying to compare 2 processes like these, it is a good idea to run them in the same job, multiple times, alternating the sequence. This will give a decent approximation of a benchmark without needing to set up some formal benchmark environment.

The 2 items to look at for a simple comparison is cpu time and i/o (excps).
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Mon Jun 09, 2008 2:40 pm
Reply with quote

Thanks a lot for all your suggestions. I have decided to go for the program and not the JCL.. not becos of any performance issues . But becos I can handle exceptions better thru a cobol program.

Thanks
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 Jun 09, 2008 8:14 pm
Reply with quote

Thank you for the update icon_smile.gif

Personally, i believe specific exception handling and implementing business rules is better done in code.

d
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 Jun 10, 2008 2:49 pm
Reply with quote

Aniyaa wrote:
I can handle exceptions better thru a cobol program.
As a Mianframe progammer I love COBOL code than JCLs to do "magics"..
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top