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

Merge in a file depending upon the key


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Wed Dec 26, 2007 5:11 pm
Reply with quote

Hi,
I am having two input file of LRECL - 80 and they are PS.

File-1
------------------------------
Col: 1-15 - Sub ID
Col: 16-8 - Start - Date

File-2
------------------------------
Col: 1-15 - Sub ID
Col: 16-8 - End - Date

But in the output, I want like -

File-3
------------------------------
Col: 1-15 - Sub ID
Col: 16-8 - Start - Date
Col: 25-8 - End Date

But here I want to mention that here I am not having any master file or so. In detail, a subscriber with no start date (so not present in File-1) but with end date (so present in File-2) should come into the output file-File-3. And also true for vice-versa!
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 26, 2007 5:36 pm
Reply with quote

amitava

1. Assuming that the field Sub ID is the KEY field, are there any duplicate records within FILE-1 and FILE-2?
2.
Quote:
a subscriber with no start date (so not present in File-1) but with end date (so present in File-2) should come into the output file-File-3.
So you want all the matching records from FILE-1 and FILE-2 and also the records that are present in FILE-2 only. Am i right?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Dec 26, 2007 5:36 pm
Reply with quote

Amitava,

Post some examples. And also how do you want this? Using util or prog.
Back to top
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Wed Dec 26, 2007 5:50 pm
Reply with quote

krisprems, in regard to ur Qs -
Quote:
1. Assuming that the field Sub ID is the KEY field, are there any duplicate records within FILE-1 and FILE-2?

- No no such duplicate Sub-ID is there!
Quote:
So you want all the matching records from FILE-1 and FILE-2 and also the records that are present in FILE-2 only.

- I tried to mean that matching records from File-1 and File-2, unique records from File-2 and unique records from File-1.
And murmohk1,
Quote:
Post some examples. And also how do you want this? Using util or prog.

- I am giving some example here -

File-1
------
Code:
Sub-ID    Start Dt
123232233  20071213
123232231  20071211
123232234  20071212

File-2
-------
Code:
Sub-ID     End Dt
123232230  20071214
123232231  20071215
123232232  20071216
123232235  20071218


File-3
-------
Code:

Sub-ID        Start Dt   End Dt
123232230                 20071214
123232231  20071211 20071215
123232232                 20071216
123232233  20071213
123232234  20071212
123232235                  20071218


Now obviously murmohk1, I am looking for some utility! If it is possible by utility, who wants to go for a program?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Dec 26, 2007 6:19 pm
Reply with quote

amitava,

Quote:
- I tried to mean that matching records from File-1 and File-2, unique records from File-2 and unique records from File-1.


For matching records you can use SPLICE parameter of ICETOOL to get the reqd output.



Quote:
unique records from File-2 and unique records from File-1.


First remove the duplicates from both the input files and then reformat the first file as

Code:
sub-id   start-date  spaces(end-date)



second file as

Code:
sub-id spaces(start-date)  end-date


The output of SPLICE and the reformat outputs should be put in a single file.
Back to top
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Wed Dec 26, 2007 6:21 pm
Reply with quote

If possible, can u pls provide me some sample JCL? It will be helpful for me ...
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 26, 2007 7:05 pm
Reply with quote

Here is the sample ICETOOL JCL. Change as per your requirment. This is a variation of the "Join fields from two files on a key" Smart DFSORT Trick at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

Also look at z/OS V1R8.0-V1R9.0 DFSORT Getting Started and other DFSORT materials here
Code:
//*******************************************************             
//STEP001  EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                       
123232233  20071213                                                   
123232231  20071211                                                   
123232234  20071212                                                   
/*                                                                     
//IN2      DD *                                                       
123232230  20071214                                                   
123232231  20071215                                                   
123232232  20071216                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
123232235  20071218                                                   
/*                                                                     
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//BOTH     DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
 COPY FROM(IN1)  TO(TMP1)                         
 COPY FROM(IN2)  TO(TMP1) USING(NKK1)             
 SPLICE FROM(TMP1) TO(BOTH) ON(1,9,CH) WITH(21,8) -
      KEEPNODUPS       WITHALL                     
/*                                                 
//NKK1CNTL DD   *                                 
  OUTREC BUILD=(1,10,21:12,8,80:X)                 
/*                                                 
Back to top
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Fri Dec 28, 2007 2:03 pm
Reply with quote

Hey krisprems! Its working man! Thanks a lot ... And obviously thanks for sharing the link.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top