IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to concat two files using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 5:43 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Jun 16, 2010 5:56 pm
Reply with 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?

Does that sound right?
Back to top
View user's profile Send private message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 6:18 pm
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 16, 2010 8:30 pm
Reply with quote

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
View user's profile Send private message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 10:16 pm
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 16, 2010 10:38 pm
Reply with quote

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
View user's profile Send private message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Thu Jun 17, 2010 4:41 pm
Reply with quote

Hi,

Thanks for the informartion.It worked fine for me.Thanks a lot. icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top