purbasha
New User
Joined: 12 Dec 2012 Posts: 3 Location: India
|
|
|
|
I want to achieve the below scenario:
I need to compare current days file with the previous days file and create one output file with the following details:
1) Records present in file1 and not in file2--Records are added. Write File1 records in output file with indicator A at the end.
2) Records present in file2 and not in file1--Records are deleted. Write File2 records in output file with indicator D at the end.
3) Key is same in File1 & File2 but other value changed--Records are modified. Write File1 records in output file with indicator C at the end.
Example :
Key (1,6)
LRECL of both files are 30.
File1
Code: |
EEEEEE TTTT
FFFFFF JJJJ
VVVVVV LLLL |
File2
Code: |
EEEEEE TTTT
FFFFFF HHHH
GGGGGG RRRR
LLLLLL UUUU |
OUTPUT
Code: |
FFFFFF HHHH C
GGGGGG RRRR A
LLLLLL UUUU A
VVVVVV LLLL D
|
Hope the requirement is clear, appreciate your help!!.
Regards,
Purva |
|
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
Purva,
Your example output doesn't match with your requirement.
Quote: |
1) Records present in file1 and not in file2--Records are added. Write File1 records in output file with indicator A at the end.
2) Records present in file2 and not in file1--Records are deleted. Write File2 records in output file with indicator D at the end.
3) Key is same in File1 & File2 but other value changed--Records are modified. Write File1 records in output file with indicator C at the end. |
It should be
Code: |
FFFFFF JJJJ C
GGGGGG RRRR D
LLLLLL UUUU D
VVVVVV LLLL A |
Sort Card:
Code: |
SORT FIELDS=COPY
JOINKEYS F1=IN1,FIELDS=(1,6,A)
JOINKEYS F2=IN2,FIELDS=(1,6,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,11,?,F2:1,11)
INREC IFTHEN=(WHEN=(12,1,CH,EQ,C'1'),
BUILD=(1:1,11,12:C' A')),
IFTHEN=(WHEN=(12,1,CH,EQ,C'2'),
BUILD=(1:13,11,12:C' D')),
IFTHEN=(WHEN=(12,1,CH,EQ,C'B',AND,
8,4,CH,NE,20,4,CH),
BUILD=(1:1,11,12:C' C'))
OUTFIL FNAMES=SORTOUT,
OMIT=(12,1,CH,EQ,C'B') |
Output:
Code: |
FFFFFF JJJJ C
GGGGGG RRRR D
LLLLLL UUUU D
VVVVVV LLLL A |
Note: I used DFSORT |
|