Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to concat two files using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
srajanbose
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 5:43 pm    Post subject: How to concat two files using DFSORT
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

Moderator Team Head


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

PostPosted: Wed Jun 16, 2010 5:56 pm    Post subject: Reply to: How to concat two files using DFSORT
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
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 6:18 pm    Post subject:
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: 578
Location: USA

PostPosted: Wed Jun 16, 2010 8:30 pm    Post subject:
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
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Wed Jun 16, 2010 10:16 pm    Post subject:
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: 578
Location: USA

PostPosted: Wed Jun 16, 2010 10:38 pm    Post subject:
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
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Thu Jun 17, 2010 4:41 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us