kumarks
New User
Joined: 25 Nov 2008 Posts: 2 Location: chennai
|
|
|
|
Both of my input files are of length 25. Both are fixed block files.
My record structure is like this.
File 1:
0000000000000012345678911
0000000000000023456789913
0000000000000023466789921
File 2:
0000000000000012456738914
0000000000000023456789929
0000000000000033456789922
The first 23 bytes is a employee number field. Next two bytes is pay code.
Now i want to the common records (key field is emp number) alone. The second record is common in both the files. Now i want the output record in below format.
Output:
000000000000002345678991329
Here first 23 bytes is the employee number and next two bytes (24,25) are pay code from file 1 and next two bytes (26,27) are pay code from file 2. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Kumarks,
The following DFSORT JCL will give you the desired results using when=group function. Simply concatenate the 2 files to sortin and sort on the key. And we push the contents of key on to the second record using when=group and only select those records. I assumed that your input keys are unique. We can modify the job to handle the duplicates also.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=S1S3.BEN.PAID.ASSOC.DATA.SORT,DISP=SHR
// DD DSN=S1S3.BEN.ASSOIDT.UNLD.DATA.SORT,DISP=SHR
//SORTOUT DD DSN=S1S3.BEN.PAID.ASSOIDT.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(60,20),RLSE)
//SYSIN DD *
SORT FIELDS=(1,23,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(28:SEQNUM,8,ZD,RESTART=(1,23))),
IFTHEN=(WHEN=GROUP,BEGIN=(28,8,ZD,EQ,1),PUSH=(26:24,2),RECORDS=2)
OUTFIL INCLUDE=(28,8,ZD,EQ,2),BUILD=(1,23,X,24,2,X,26,2)
/* |
|
|