da_one Beginner
Joined: 15 Oct 2003 Posts: 11 Topics: 4
|
Posted: Thu Dec 25, 2003 3:10 am Post subject: Retaining sequence of input records while merging |
|
|
Hi,
Merry Christmas
I am confused with how the Merge functions. I have a requirement of Merging Fixed Length files to form a variable length file.
Consider File A (Fixed record length file of 20 bytes)
Records:
10000AAAAAAAAAAAAAAA
10002BBBBBBBBBBBBBBB
10002CCCCCCCCCCCCCCC
10004AAAAAAAAAAAAAAA
Consider File B (Fixed record length file of 10 bytes)
Records:
10000PPPPP
10001PPPPP
10002QQQQQ
10002RRRRR
10004SSSSS
The Output C for the above 2 Input files(Variable Length file)
10000AAAAAAAAAAAAAAA
10000PPPPP
10001PPPPP
10002BBBBBBBBBBBBBBB
10002CCCCCCCCCCCCCCC
10002QQQQQ
10002RRRRR
10004AAAAAAAAAAAAAAA
10004SSSSS
I want the files to be merged on the first 5 bytes such that the Resultant file C that is created is a variable length file. I do not want to combine file A and B in a sort step, but I want to retain the sequence of records in file A and B. |
|
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Dec 25, 2003 11:20 am Post subject: |
|
|
You can't merge two FB files with different LRECLs directly. You could pad out the FB 10 file to an FB 20 file and then merge those and convert them to VB, but you would end up with extra blanks you don't need. You can merge two VB files with different LRECLs directly. So the best way to do what you want is to convert each FB file to a VB file separately and then merge them. Here's a DFSORT job to do that:
Code: |
//C1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file A (FB)
//SORTOUT DD DSN=&&OA,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *
* COPY FB FILEA AND CONVERT TO VB
OPTION COPY
OUTFIL FTOV
/*
//C2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file B (FB)
//SORTOUT DD DSN=&&OB,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *
* COPY FB FILEB AND CONVERT TO VB
OPTION COPY
OUTFIL FTOV
/*
//M1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN01 DD DSN=&&OA,DISP=(OLD,PASS)
//SORTIN02 DD DSN=&&OB,DISP=(OLD,PASS)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
* MERGE THE TWO VB FILES
OPTION EQUALS
MERGE FIELDS=(5,5,CH,A)
/*
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|