|
View previous topic :: View next topic
|
| Author |
Message |
Mahan Mh
New User
Joined: 28 Mar 2012 Posts: 2 Location: USA
|
|
|
|
Hi,
I need to compare two files of different lengths and key fields are also in different positions. Please find the details as below:
FILE-1, LRECL=2000 & FB, Key field position - 1 to 20 (X(20)).
Sample data:
Key-Field Field-2 (Pos-145 len-9) Fild-3(pos-511-len-1)
--------- ------------------------ -----------
0000000000000000000003/29/2012 ==> Header with date
11111111111111111111 123456789 C
22222222222222222222 777888999 O
33333333333333333333 666333222
44444444444444444444 111444777 O
55555555555555555555 111555999 C
66666666666666666666 888555222 C
77777777777777777777 111222333 E
88888888888888888888 999666333 E
9999999999999999999900000010 ==> Trailer with record count
FILE-2, LRECL=691 & FB, Key field position - 280 to 299 (X(20)).
Sample data:
Key-Field
-----------
1111111111111111111
3333333333333333333
5555555555555555555
The output file will be LRECL=2000 & FB and this needs to created based on below conditions.
1. Header and trailer needs to copied as is, but trailer should be updated with latest count of records.
2. The output file will have all matching and non-matching record but with Field-3 NOT = 'E' and with another below condition.
3. For all matching record, Field-2 should be copied as it is and for all non-matching records Field-2 should be masked (spaced out). Field-2 has sensitive data and we need to mask it for all non-matching records.
The desired output would looks like:
Key-Field Field-2 (Pos-145 len-9) Fild-3(pos-511-len-1)
--------- ------------------------ -----------
0000000000000000000003/29/2012 ==> Header with date
11111111111111111111 123456789 C
22222222222222222222 O
33333333333333333333 666333222
44444444444444444444 O
55555555555555555555 111555999 C
66666666666666666666 C
9999999999999999999900000008 ==> Trailer with record count
I am sorry, if I am having too many condition check here, I am not sure whether we can achieve this using ICETOOL/DFSORT. Please let me know.
I am attaching the document which has screen prints of sample data. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Mahan Mh,
Use the following DFSORT JCL which will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=Your Input FB 2000 byte file,DISP=SHR
//INB DD DSN=Your Input FB 691 byte file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(001,20,A),OMIT=(511,1,CH,EQ,C'E')
JOINKEYS F2=INB,FIELDS=(280,20,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,2000,?)
OUTFIL IFOUTLEN=2000,
IFTHEN=(WHEN=(2001,1,CH,EQ,C'1'),OVERLAY=(145:9X)),
IFTRAIL=(TRLID=(1,20,CH,EQ,C'99999999999999999999'),
TRLUPD=(21:COUNT+1=(M11,LENGTH=8)))
//* |
|
|
| Back to top |
|
 |
Mahan Mh
New User
Joined: 28 Mar 2012 Posts: 2 Location: USA
|
|
|
|
Thank you lot Kolusu for all your help and time. I got the desired output.
Thanks,
Mahan. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|