View previous topic :: View next topic
|
Author |
Message |
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi,
Below is my requirement
The FIRST input file conatins below records..
0001 A 15 20
0003 C 35 30
0005 E 55 59
0002 B 25
0004 D 45
0006 F 65
the second input file contains below records
0001 A 15 19
0002 B 25 29
0003 C 35 39
0004 D 45 49
0005 E 55 59
0006 F 65 69
I want to have my output as
0001 A 15 20
0002 B 25 29
0003 C 35 30
0004 D 45 49
0005 E 55 59
0006 F 65 69
Please let me know how to acheive this using DFSORT? |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
So, you want to concatenate the two files, file-two first, then file-one, sorting on the primary key of positions 1-4, and selecting only the first occurence of the key?
Does that sound right? |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi Kevin,
Thanks for the solution.Could you please let me know how to write only the first occurence in to the output. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
superk,
Quote: |
So, you want to concatenate the two files, file-two first, then file-one, sorting on the primary key of positions 1-4, and selecting only the first occurence of the key? |
This doesn't match with the expected output. For the 0003, if we are to select record from second file,it should be 0003 C 35 39 in the expected output but OP is showing that he wants 0003 C 35 30(record from first file).
srajanbose,
Was that a typo or is this how you want output records to be? Try to concatenate both the files(file2 first) and then using OPTION EQUALS and SORT/SUM FIELDS NONE on Primary Key would help.
Also,please provide LRECL and RECFM for both the files. Without this its a guessing game.
Thanks, |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi,
I want the output as 0003 C 35 30(record from first file). LRECL is 80 and RECFM is FB.
if the value of 4th column is not present in the first input file it has to replace the record alone with the contents present in the second input file. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
srajanbose,
With tons of assumtion see if below mentioned job would work for you.
Code: |
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
0001 A 15 20
0003 C 35 30
0005 E 55 59
0002 B 25
0004 D 45
0006 F 65
//INB DD *
0001 A 15 19
0002 B 25 29
0003 C 35 39
0004 D 45 49
0005 E 55 59
0006 F 65 69
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(1,4,A)
JOINKEYS F2=INB,FIELDS=(1,4,A)
REFORMAT FIELDS=(F1:01,13,F2:11,02)
INREC IFTHEN=(WHEN=(11,02,CH,EQ,C' '),
OVERLAY=(11:14,02))
SORT FIELDS=COPY
OUTREC BUILD=(01,12)
/* |
Thanks, |
|
Back to top |
|
|
srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi,
Thanks for the informartion.It worked fine for me.Thanks a lot. |
|
Back to top |
|
|
|