Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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 FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us