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

Merging of two files


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

New User


Joined: 28 Nov 2007
Posts: 63
Location: Chennai

PostPosted: Fri Feb 19, 2016 12:36 pm
Reply with quote

Hi All,

I am looking for some help in sort to merge two files and the results to capture in an output file.

Input File 1 : FB, 200 LRECL
Input File 2: FBA, 166 LRECL

File 1 Format:

Code:


----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
XXXXX     02/16/201602/17/201602/18/2016



File 2 Format:

Code:


----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
     *** (AAA)                         9,999.99       8,88.00   77,777.07 
gjb jkhkjbn jhbgjk
ghfhjgfn jhygjhbjgh hjgjh
hngjk hjvjhbb
     *** (WWW)                         999,999.99     8,888.00  777,777.77 
asdjkashdkjh lkajsdklj
asdbhkjjkl nhjklanmsd,n j
ajksdnhjkn  lkkjjl
     *** (ZZZ)                         9,999.99       8,88.00   555,777.77
asda as sf  asdad 
     *** (MMM)                         9,909.99       8,88.00   555,777.77 


The output should be as below:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
Sample report for system
WWW 999,999.99hard core  2016021720160218values        WWW   
ZZZ   9,999.99hard code  2016021720160218values        ZZZ


Condition to create:
1) It will have the header records written in the file as "Sample report for system".
2) It will look in file-2, and pull the values from it only when the value in position 10 to 14 are either (WWW) or (ZZZ).
3) For both the scenario:first three bytes as www or zzz.
4) Starting from 5th byte, the amount field will be pulled from file 2 position 40 to 50.
5) Constant "hard core " value will be populated from 15 to 25.
6) for date it will look into the file 1. for position 26 to 33 it will use the value from 21 to 30 from file 1. In file 1 the dates are in MM/DD/YYYY but in the output file it should be in YYYYMMDD.
7) for position 34 to 41, it will use the file 1 from 31 to 40.
8) Again hard code values needs to be populated.

Can someone please help me in this regard.
Back to top
View user's profile Send private message
Lakshmi Prakash

New User


Joined: 22 Feb 2016
Posts: 5
Location: India

PostPosted: Tue Feb 23, 2016 8:06 pm
Reply with quote

Hello,

On the first glance I could think of this approach

1) Remove unnecessary records from File 2
2) Add some dummy keys in front of file 1 and 2
3) Use Joinkeys and concatenate both File1 and file 2
4) Now you have both file 1 and file 2 in one line, you can reformat the line in the way you desire.

Not sure if this is any other better approach.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Feb 23, 2016 8:17 pm
Reply with quote

Lakshmi Prakash,

That approach would work, but JOINKEYS uses more resources.

Better would be a two-step approach. First step generates a DFSORT symbol/SMNAMES for the static data from the single-record file.

Then it is the INCLUDE COND=(what you want), do the necessary formatting, using the symbol where required. Use OUTFIL with REMOVECC and HEADER1 to get the heading.

Several examples here.
Back to top
View user's profile Send private message
Lakshmi Prakash

New User


Joined: 22 Feb 2016
Posts: 5
Location: India

PostPosted: Tue Feb 23, 2016 8:21 pm
Reply with quote

I completely agree with your approach Bill, that's an efficient way.
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 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top