Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SYNCSORT to compare two variable length file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: SYNCSORT to compare two variable length file
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    Post subject: Of1
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

Senior Member


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

PostPosted: Tue Dec 11, 2007 7:46 pm    Post subject:
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: 500
Location: USA

PostPosted: Tue Dec 11, 2007 9:54 pm    Post subject: Reply to: SYNCSORT to compare two variable length file
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    Post subject: Reply to: SYNCSORT to compare two variable length file
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    Post subject:
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: 500
Location: USA

PostPosted: Wed Dec 12, 2007 3:54 am    Post subject: Reply to: SYNCSORT to compare two variable length file
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us