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

SYNCSORT to compare two variable length file


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

New User


Joined: 11 Dec 2007
Posts: 2
Location: USA

PostPosted: Tue Dec 11, 2007 4:35 am
Reply with quote

I have a requirement to compare two Variable length(VB) files(Yesterday's & Today's file). The max length of the file is 3372. Requirement is to compare the two files and generate two output files, one with matching records and the other file with non-matching records. The constraint is both the files have a date field which would be different from yesterday's file to today's file. So we need to omit the date field while comparing. Could anybody please suggest doing this in SYNCSORT.

Rags
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Tue Dec 11, 2007 7:25 pm
Reply with quote

Rags

SYNCSORT allows you to write to multiple output files. There are two different ways to do this. Both methods use the OUTFIL keyword, and are identical except in how you specify the DDNAME.
Method 1 allows you to specify the DDNAME to be written to.

SORT FIELDS=(1,10,CH,A)
OUTFIL FNAMES=CUST1,
INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FNAMES=CUST2,
INCLUDE=(1,1,CH,EQ,C'B')

In this example the sort file will be split into 2 files, CUST1 and CUST2, depending on whether the first character is A or B. CUST1 and CUST2 must be defined as DDNAMES in the JCL.
Method 2 uses DDNAMEs defined by DFSORT in the form SORTOFxx.


SORT FIELDS=(1,10,CH,A)
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(1,1,CH,EQ,C'B')

In this example the sort file is split into 2 files SORTOF1 and SORTOF2, depending on whether the first character is A or B. SORTOF1 and SORTOF2 must be defined as DDNAMEs in the JCL.
Note that the INCLUDE format differs from the normal format when using it with OUTFIL

as your saying its VB file u need to leave first 4 bytes and start from 5th byte it mean..if you want to sort 1 letter of the file u r sort condition start at (5,1....)

if you want to sort 5 to 10 letters of the file u r sort condition start at (9,10....)

A B C D E FGHIJ
1 2 3 4 5

Please let me know if your not clear.
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 Dec 11, 2007 7:46 pm
Reply with quote

Hi,

You need to provide a sample of your both the input files & expected output.

A JOB like this, should be handy for you..but this is written for FB DSNs..
Code:
//STEP001 EXEC PGM=SYNCTOOL                                     
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG  DD SYSOUT=*                                           
//IN1     DD DSN=HLQ.FIRST.FILE,DISP=SHR                   
//IN2     DD DSN=HLQ.SECOND.FILE,DISP=SHR                   
//T1      DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),             
//           DISP=(MOD,PASS)                                   
//OUT12   DD DSN=HLQ.MATCHED.OUTPUT,DISP=(NEW,CATLG,DELETE)
//OUT1    DD DSN=HLQ.ONLY.IN.IN1.OUT,DISP=(NEW,CATLG,DELETE)
//OUT2    DD DSN=HLQ.ONLY.IN.IN2.OUT,DISP=(NEW,CATLG,DELETE)
//TOOLIN  DD *                                                 
  COPY FROM(IN1) TO(T1) USING(CTL1)                             
  COPY FROM(IN2) TO(T1) USING(CTL2)                             
  SPLICE FROM(T1) TO(OUT12) ON(1,3,CH) WITH(81,1) -             
  USING(CTL3) KEEPNODUPS                                       
/*                                                             
//CTL1CNTL DD *                                                 
  INREC OVERLAY=(80:C'11')                                     
/*                                                             
//CTL2CNTL DD *                                                 
  INREC OVERLAY=(80:C'22')                                     
/*                                                             
//CTL3CNTL DD *                                                 
  OUTFIL FNAMES=OUT12,INCLUDE=(80,2,CH,EQ,C'12'),BUILD=(1,80)   
  OUTFIL FNAMES=OUT1,INCLUDE=(80,2,CH,EQ,C'11'),BUILD=(1,80)   
  OUTFIL FNAMES=OUT2,INCLUDE=(80,2,CH,EQ,C'22'),BUILD=(1,80)   
/*                                                             


IN1
Code:
111 $$$$$
222 AAAAA
444 FFFFF
555 GGGGG
888 CCCCC

IN2
Code:
111 BBBBB
333 DDDDD
444 FFFFF
555 HHHHH

OUT12
Code:
111 $$$$$
444 FFFFF
555 GGGGG

OUT1
Code:
222 AAAAA
888 CCCCC

OUT2
Code:
333 DDDDD

By the way when you say..non-matching records..which records you are talking about (A-B) or (B-A), where A & B are two input files.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Dec 11, 2007 9:54 pm
Reply with quote

Rags,

If you have SyncSort for z/OS 1.2, then the JOIN feature would most likely be the best solution. Please provide sample input so that we can better help you with this application.
Back to top
View user's profile Send private message
Gnr_Rags

New User


Joined: 11 Dec 2007
Posts: 2
Location: USA

PostPosted: Wed Dec 12, 2007 1:37 am
Reply with quote

Hi Alissa,

We have 2 variable length files of record length 3372.

File 1:

ABCF01710021USD310000111MTGB390
BTRF01710021USD310000112MTGB390
CMSF01710021USD310000113MTGB390
UMSF01710021USD310000210MTGB370
UMSF01710021USD310000211MTGB390


File 2:

ABCF01710021USD310000111MTGB100
BTRF01710021USD310000112MTGB100
FASF01710021USD310000113MTGB390
MASF01710021USD310000210MTGB370
QRTF01710021USD310000211MTGB390
UMSF01710021USD310000111MTGB100
UMSF01710021USD310000112MTGB390

I have just given the first 30 characters from the files. First character is spaces in both files. The key starts from 2nd position and it is 24 bytes in length(2,24).

My requirement is to create 2 output files:

OUT1 : Should have records matching the key.The file should contain entire record and it has to be taken from File2.The result should be

ABCF01710021USD310000111MTGB100
BTRF01710021USD310000112MTGB100
UMSF01710021USD310000111MTGB100
UMSF01710021USD310000112MTGB390


OUT2: Should have records which are there in File 2 and NOT there in File1. Again file should contain entire record and it has to be taken from File2.The result should be

FASF01710021USD310000113MTGB390
MASF01710021USD310000210MTGB370
QRTF01710021USD310000211MTGB390

Thanks,
Rags.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Dec 12, 2007 2:11 am
Reply with quote

Code:
000007 //STEP0010 EXEC PGM=SYNCSORT,REGION=6M               
000009 //SORTJNF1 DD DISP=SHR,DSN=DS1     
000012 //SORTJNF2 DD DISP=SHR,DSN=DS2

For matching records

000032 //SYSIN    DD *                                       
000033  JOINKEYS FILES=F1,FIELDS=(1,100,A,111,389,A)                       
000035  JOINKEYS FILES=F2,FIELDS=(1,100,A,111,389,A)                   
000037  REFORMAT FIELDS=(F1:1,500,F2:501,500)               
000038  SORT     FIELDS=COPY                                 

For Non matching records

000032 //SYSIN    DD *                                       
000033  JOINKEYS FILES=F1,FIELDS=(1,100,A,111,389,A)                       
000035  JOINKEYS FILES=F2,FIELDS=(1,100,A,111,389,A)
000036  JOIN UNPAIRED, ONLY                 
000037  REFORMAT FIELDS=(F1:1,500,F2:501,500)               
000038  SORT     FIELDS=COPY                                 



The Date field can be skipped by not mentioning in the Join Keys files as above, assuming the date field is in 101 - 110.
The reformat fields will give you, what your output file must look like.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Dec 12, 2007 3:54 am
Reply with quote

Rags,

Here is a one-step JOIN application that should produce your desired output. As previously mentioned, this application requires SyncSort for z/OS 1.2.0 or later.
Code:

//STEP1 EXEC PGM=SORT                           
//SORTJNF1 DD DISP=SHR,DSN=INPUT.FILE1
//SORTJNF2 DD DISP=SHR,DSN=INPUT.FILE2
//SORTOF01 DD DSN=MATCHED.FILE2,DISP=(NEW,CATLG),   
//     UNIT=SYSDA,SPACE=(TRK,1)                     
//SORTOF02 DD DSN=UNIQUE.FILE2,DISP=(NEW,CATLG),   
//     UNIT=SYSDA,SPACE=(TRK,1)                     
//SYSOUT DD SYSOUT=*                               
//SYSIN    DD    *                                                 
  JOINKEYS FILES=F1,FIELDS=(6,24,A)                               
  JOINKEYS FILES=F2,FIELDS=(6,24,A)                               
  REFORMAT FIELDS=(F2:1,3372,F1:1,3372),FILL=X'FF'                   
  JOIN UNPAIRED,F2                                                 
  SORT FIELDS=COPY                                                 
  OUTFIL FILES=01,INCLUDE=(5,1,BI,NE,X'FF',AND,3377,1,CH,NE,X'FF'),
      OUTREC=(5,3368),FTOV,VLTRIM=X'FF'                             
  OUTFIL FILES=02,INCLUDE=(5,1,BI,NE,X'FF',AND,3377,1,BI,EQ,X'FF'),
      OUTREC=(5,3368),FTOV,VLTRIM=X'FF' 
/*                         
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 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top