Joining two files with SORT.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Roohi N
New Member
Posts: 6
Joined: Mon Jan 18, 2016 4:56 pm

Joining two files with SORT.

Post by Roohi N »

Hi,

I have two files which have just one-one record each. I need to combine them in a specific way. I shall try to explain them with example:

Let's say file one is: my.input.file1 with data 12345
file second is: my.input.file2 with data abcdef09876543

I want my output file should be as: 12345abcdef09876543

Can I do this using some SORT card?
Last edited by Anuj Dhawan on Tue Sep 06, 2016 10:14 pm, edited 2 times in total.
Reason: Added code tags.
Roohi N
New Member
Posts: 6
Joined: Mon Jan 18, 2016 4:56 pm

Re: Joining two files with SORT.

Post by Roohi N »

The files are both of logical length 80 and and fixed blocked.

I might get these files as variable block, can we still do it in SORT with variable block file?
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Joining two files with SORT.

Post by Magesh_j »

Roohi,

what is the output LRECL ?

Whether fields you have are in fixed length or length varies ?

Assuming output LRECL=80 and All the fields have fixed length then use the below code and you have only one record in each file.

File 1(1,5) and File2 (1,14)

Code: Select all

//SORT010    EXEC PGM=SORT                                  
//SORTIN  DD DSN=YOUR FIRST FILE                            
//        DD DSN=YOUR SECOND IFLE                           
//SORTOUT DD SYSOUT=*                                       
//SYSOUT DD SYSOUT=*                                        
//SYSIN DD *                                                
  OPTION COPY,STOPAFT=2                                     
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(81:1,5,SEQ=1))   
                                                            
  OUTFIL INCLUDE(86,1,CH,EQ,C'2'),BUILD=(81,5,1,14,80:X)    
/*                                                          
On you next question on Variable file, what is the maximum length of input record ? And what is the maximum length of output record ?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Joining two files with SORT.

Post by nicc »

There are NO files. They are data sets.
Regards
Nic
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Joining two files with SORT.

Post by Magesh_j »

Nic,

Mistake, agreed Datasets.

Thanks
Magesh
Roohi N
New Member
Posts: 6
Joined: Mon Jan 18, 2016 4:56 pm

Re: Joining two files with SORT.

Post by Roohi N »

Magesh_j wrote: what is the output LRECL ?Whether fields you have are in fixed length or length varies ?Assuming output LRECL=80 and All the fields have fixed length then use the below code and you have only one record in each file.File 1(1,5) and File2 (1,14)
The datasets are both of logical length 80 and and fixed blocked.

Length of field is fixed for my case but the dataset's can be of RECFM=VB (this is a condiction we are expecting but as of now they are FB. THat's why I'm thimking for VB soluction too).

For VB, adding (1,4) should work but I'm still to get a VB file. Please advise.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Joining two files with SORT.

Post by nicc »

But what is the output dataset LRECL?
Regards
Nic
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Joining two files with SORT.

Post by zprogrammer »

Roohi,

I would suggest : Overlay sequence numbers in both files and then do a join keys
zprogrammer
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Joining two files with SORT.

Post by Magesh_j »

zprogrammer wrote: Roohi,

I would suggest : Overlay sequence numbers in both files and then do a join keys
Joinkey consumes three pass. where the solution which i have provided consume only two pass.

For this situation join key is not at all recommended.

Roohi N.

For VB yes, you should use 1,4 (RDW), Also you need to know the maximum record length.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Joining two files with SORT.

Post by zprogrammer »

Magesh_j wrote: For this situation join key is not at all recommended.
Could you please prove it :)
zprogrammer
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Joining two files with SORT.

Post by Magesh_j »

zprogrammer,

Check the spool for Joinkey, you will see three outputs.

Code: Select all

SYSOUT  
JNF1JMSG
JNF2JMSG
JNF1 => 1 Pass.
JNF2 => 1 Pass.
After Join => 1 pass.

ideally any DFSORT Joinkey will have three pass irrespective of JNF1CNTL/JNF2CNTL statements.

Also test my solution and you will see only one SYSOUT( ideally one pass) but since it is two file we concatenate it is considered as two pass solution.

Regards,
Magesh
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Joining two files with SORT.

Post by zprogrammer »

Magesh_j,

You are yet to answer my question => why is Join keys not recommended for this situation ?
zprogrammer
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Joining two files with SORT.

Post by Magesh_j »

zprogrammer,

Because three pass is unnecessary, where something can be achieved in two pass which would be an optimal solution.

thanks
Magesh
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: Joining two files with SORT.

Post by enrico-sorichetti »

the TS stated clearly that
I have two files which have just one-one record each.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”