View previous topic :: View next topic
|
Author |
Message |
Sreenivasulu. Vemula
New User
Joined: 21 Aug 2008 Posts: 6 Location: Chennai
|
|
|
|
Hi,
How can compare two files and all matched records will be stored in another output file. These two files are different length and key values is also different position in two files.
Fetch the number from first file and that number compare in second file. If any match is occur that record will be stored into output file. But we need all occurences in second file. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Can you please post sample input and required output with
positions specified? it will help to answer.
At this point of time i can only answer that it can be done using ICETOOL.
|
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Sreeni,
Welcome to the forum.
Quote: |
Fetch the number from first file and that number compare in second file. If any match is occur that record will be stored into output file. But we need all occurences in second file. |
Give us few more details on the field positions, record length and all. Are you using DFSORT or SYNCSORT?
Do search the forums as this has been discussed many times. |
|
Back to top |
|
|
Sreenivasulu. Vemula
New User
Joined: 21 Aug 2008 Posts: 6 Location: Chennai
|
|
|
|
Input File1:
100
200
300
500
InputFIle2
100
100
100
200
200
500
500
600
Output File:
100
100
100
200
200
500
500
Two input files are different length and values positions are also different |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Quote: |
Two input files are different length and values positions are also different |
Sorry, but Wednesday is psycic day, so you might want to help us help you by providing some useful information such as the locations of key fields in both files, the RECFM & LRECL of both files. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Also the SORT poduct which is installed at your shop...
Thanks,
Arun |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Sreeni,
Check this and change as per your reqts.
Code: |
//STEPS200 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
100
200
300
500
/*
//IN2 DD *
100
100
100
200
200
500
500
600
/*
//T1 DD DSN=&&T1234,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),
// UNIT=SYSDA
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,3,CH) WITH(1,51) WITHALL USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(50:C'BB')
/*
//CTL2CNTL DD *
INREC OVERLAY=(50:C'TT')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(50,2,CH,EQ,C'TT'),BUILD=(1,49)
/*
//OUT DD SYSOUT=* |
Output:
Code: |
********************************* TOP OF DATA **********************************
100
100
100
200
200
500
500
******************************** BOTTOM OF DATA ******************************** |
I have assumed a recl of 49 |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Aaru, see line from vemula
Quote: |
Two input files are different length and values positions are also different
|
i think above code will work when keys are at same position in file |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Sambhaji,
Quote: |
Hi Aaru, see line from vemula
Quote:
Two input files are different length and values positions are also different
i think above code will work when keys are at same position in file |
Read my post again. The very first line says "Check this and change as per your reqts. ".
I have asked him to change the SORT card as per his requirements. We had asked all sorts of questions to the OP which he didn't answer. So just posted assuming that the field positions are same (that is how it looked from teh sample input) .
Anyways shall wait for the OP to answer. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Sambhaji,
Quote: |
Check this and change as per your reqts. |
Did you happen to notice this?
We can provide only a generic solution unless the OP comes up with the actual file positions.
Thanks,
Arun |
|
Back to top |
|
|
Sreenivasulu. Vemula
New User
Joined: 21 Aug 2008 Posts: 6 Location: Chennai
|
|
|
|
My requirement is, I have two files, files contains data as follows
File1: File length is 50, but key value starts from 10th position, remaining places are empty(Spaces)
100
200
300
500
400
700
600
FIle2: File length 50, here also key value start at 10th position, remaining places are not empty.
123441 100 ABC
123441 100 ABC
123441 100 ABC
123442 200 AAA
123442 200 AAA
123443 500 BBB
123443 500 BBB
123444 600 CCC
123445 800 XYZ
123445 800 XYZ
123446 900 AAA
123446 900 AAA
Output is:
123441 100 ABC
123441 100 ABC
123441 100 ABC
123442 200 AAA
123442 200 AAA
123443 500 BBB
123443 500 BBB
123444 600 CCC
Please let me know how to solve this problem. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Sreenivasulu,
I have assumed 3 character key starting from 10th position in both the files. If match is found, file-2 record gets copied to output.
The below SYNCSORT job would give you the expected results if your shop has SYNCSORT FOR Z/OS 1.2 or above.
Code: |
//STEP1 EXEC PGM=SORT
//SORTJNF1 DD DSN=File-1 ------------- FB,LRECL=50
//SORTJNF2 DD DSN=File-2 ------------- FB,LRECL=50
//SORTOUT DD DSN=Output File -------- FB,LRECL=50
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(10,3,A)
JOINKEYS FILE=F2,FIELDS=(10,3,A)
REFORMAT FIELDS=(F2:1,50)
SORT FIELDS=COPY |
Thanks,
Arun |
|
Back to top |
|
|
|