View previous topic :: View next topic
|
Author |
Message |
bhavya_sha
New User
Joined: 16 Apr 2005 Posts: 33
|
|
|
|
Hello all,
I have 2 files
file1 of length 80(having 1 record with numeric data from 1to 7byte)
file2 of length 400
I want to compare each record in file2(10-17) with the data in file1(1-7) giving >= condition and data is ZD.if the value in file2 is GE to value from file1 need to write to output file.
Could any one let me know is that possible to do using SORT?
Eg:
File1:
882388
file2
xxxxxxxxx8888888xxx
xxxxxxxxx7777777xxx
xxxxxxxxx9999899xxx
outfile
xxxxxxxxx8888888xxx
xxxxxxxxx9999899xxx
Thanks & Regards,
Bhavya |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
One way you might do it is to build a SYMNAMES record from the data in File1 and use this in an INCLUDE statement for processing File2.
Quote: |
want to compare each record in file2(10-17) with the data in file1(1-7) |
10-17 is a 8-byte field which differs from 1-7 which is a 7-byte field.
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
I want to compare each record in file2(10-17) with the data in file1(1-7) |
If you need more help with this, give the correct positions, or verify that these are the correct positions.
Also, what is the RECFM of the input files? |
|
Back to top |
|
|
bhavya_sha
New User
Joined: 16 Apr 2005 Posts: 33
|
|
|
|
File1 of Record length 80
The key length in both file is 7 bytes. i.e, 10-16 in file2.
File2 of Record length 357
File1 data (key 1 -7)
899299 (key 10-16)
File2 data
xxxxxxxxx9999999 xx xxxxxxx xxxxxxx xxxxxxxxxxxxx
xxxxxxxxx8888865 xx xxxxxxx xxxxxxx xxxxxxxxxxxxx
xxxxxxxxx9333444 xx xxxxxxx xxxxxxx xxxxxxxxxxxxx
If key data from file2 >= file1 key i.e, 9999999 >= 899299
write record to output file as below
output file
xxxxxxxxx9999999 xx xxxxxxx xxxxxxx xxxxxxxxxxxxx
xxxxxxxxx9333444 xx xxxxxxx xxxxxxx xxxxxxxxxxxxx
Thanks & Regards,
Bhavya |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Again, you have 6 digits for the key in file1 (899299) and 7 digits for the key in file2 (9999999) - you need to be more careful when giving your requirements. Assuming that the key in file1 really is 7 digits with leading zeros in positions 1-7 (e.g. 8992999 or 0899299), you can use a DFSORT job like the following to do what you asked for:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1 (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
INREC BUILD=(C'F1KEY,+',1,7,80:X)
/*
//S2 EXEC PGM=SORT
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYMNOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file2 (FB/357)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(10,7,ZD,GE,F1KEY)
/*
|
|
|
Back to top |
|
|
|