View previous topic :: View next topic
|
Author |
Message |
Unique
New User
Joined: 10 Jul 2007 Posts: 24 Location: Blore
|
|
|
|
hi,
I have 2 files,one has 1 rec and other has many records.
File 1
------
REGIONA123
File2
-----
12012008regiona123
11111
22222
33333
44444
My requirement is to compare the cycle no in each file and if match should return code 0 and not match rc 4 and change the file1 to match file2 using SYNCSORT only. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
This can be done but what is 'cycle no.', there is no reference of this in Your files shown, is it 'regiona123'? |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
assuming that the Cycle no. is REGIONA123.
Is that the Cycle no. may be present in any position in your second file?
What is the RECFM and LRECL of your input and o/p files? |
|
Back to top |
|
|
Unique
New User
Joined: 10 Jul 2007 Posts: 24 Location: Blore
|
|
|
|
Hi,
In the input file FILE 1 , there is only one record with the data as <Region><Cycle NO>.
REGIONA is the test region and cycle no is 123 and the length is 80 FB
the second file contains the
first record as <Date><Region><CYCLE NO>
and the rest of the records have data for that cycleno
i need to match the cycle no in both the files and if matching ,i should be get RC=0 and if notmatching, set RC=4 and change the cycle no in the file1 same as second file. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Hi
Code: |
//********************************************************************
//SORT1 EXEC PGM=SYNCSORT
//SORTJNF1 DD DSN=HLQ.TEST.FB80,DISP=SHR
//SORTJNF2 DD *
12012008REGIONA123
11111
22222
33333
44444
//SORTOUT DD DSN=&&TEMP,DISP=(,PASS),UNIT=SYSDA
//SORTOF01 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(8,3,A)
JOINKEYS FILE=F2,FIELDS=(16,3,A)
REFORMAT FIELDS=(F2:9,10)
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(1,6,CH,EQ,C'REGION'),NULLOFL=RC4,
OVERLAY=(80:C' ')
//*
//SORT2 EXEC PGM=SORT,COND=(04,EQ,SORT1)
//SORTIN DD DSN=&&TEMP1,DISP=(MOD,PASS,DELETE)
//SORTOUT DD DSN=HLQ.TEST.FB80,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY |
Explanaion:
in step SORT1 the DD SORTJNF1 contains your first file contents
DD SORTJNF2 will contain the second file contents.
JOINKEYS will match the keys, the OUTFIL will set return code 00 if the key matched else returns 04.
The step SORT2 will excecute only if the step SORT1 returns 04. This step when excecuted will update the latest key from second file to first file.
Hope this is what you wanted!!! |
|
Back to top |
|
|
Unique
New User
Joined: 10 Jul 2007 Posts: 24 Location: Blore
|
|
|
|
I will try your solution and will let you know. |
|
Back to top |
|
|
Unique
New User
Joined: 10 Jul 2007 Posts: 24 Location: Blore
|
|
|
|
Hi Krisprem,
I tried ur solution .I am able to get rc=0 if the cycle no matchs and rc=4,when cycle no mismatches. But when there is a mismatch,the input file1 is not updated with the cycle no of file2. Please guide
Thanks |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Unique,
Try the modified second step I emailed you with COND=(04,NE,SORT1). |
|
Back to top |
|
|
|