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

Concatenate 2 different VB files to a new VB file


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

New User


Joined: 11 Mar 2015
Posts: 10
Location: India

PostPosted: Sat Oct 10, 2015 2:12 am
Reply with quote

Hi,

I have a requirement to concatenate 2 files based on account number field. The position of the account number field in each of the input file is different. Please find the file 1 and file 2 format and the output that am expecting. Please let me know how can this be achieved thru sort ?

Input File 1 - Variable block say of length 50. Account number position is 15 of size 5.

Code:

----+----1----+----2----+----3----+----4----+-
***************************** Top of Data ****
ABCDEFGH       11223     BANGALORE           
XXXXXXXX       11345     CHENNAI             
TTTTTTTT       11700     MYSORE               
YYYYYYYYYY     12000     USA                 
ZZZZZZZZZ      13000     CANADA               
             
**************************** Bottom of Data **



Input File 2 - Variable block say of length 30. Account number position is 1 of size 5.

Code:

----+----1----+----2----+-                   
***************************** Top of Data ***
11223     CHINA                             
11345     BANGLADESH                         
11700     AUSTRALIA                         
12000     JAPAN                             
13000     WENTZVILLE                         
**************************** Bottom of Data *


Expected Output:


Code:

ABCDEFGH       11223     BANGALORE                             
11223     CHINA                                                 
XXXXXXXX       11345     CHENNAI                               
11345     BANGLADESH                                           
TTTTTTTT       11700     MYSORE                                 
11700     AUSTRALIA                                             
YYYYYYYYYY     12000     USA                                   
12000     JAPAN                                                 
ZZZZZZZZZ      13000     CANADA                                 
13000     WENTZVILLE                                           
           
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Oct 10, 2015 2:25 am
Reply with quote

Will there always be one record for each account on each file. Are the files in account number sequence?
Back to top
View user's profile Send private message
santhosh5983

New User


Joined: 11 Mar 2015
Posts: 10
Location: India

PostPosted: Sat Oct 10, 2015 2:36 am
Reply with quote

Yes the files will be sorted on account number. And yes both the files will have one record for every account number.

As part of error handling, it will be great if we can push the records that does not have the corresponding matching record to a different/separate file.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Oct 10, 2015 2:40 am
Reply with quote

I see the file is already sorted by account number so all you need to do is add sequence number to each file and then sort based on that.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Oct 10, 2015 3:13 am
Reply with quote

I got disconnected so couldn't edit my post.
So to continue, may be use a join key on account number or the sequence number as told above and reformat them together and then resize based on record length, Not sure if that works but try.
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: Sat Oct 10, 2015 4:10 am
Reply with quote

JOINKEYS on the account number.

Variable-length REFORMAT record, although one of the records (better the short one) need to be padded to fixed-length in the REFORMAT. Also specify the match-marker. JOIN UNMATCHED,F1,F2. There OUTFILs, one for matched, one for unmatched F1, one for unmatched F2.

On your match, BUILD, using the slash operator (/) to create two records from one OUTFIL input. Use VLTRIM to make the records variable again, being careful of what values may be in the final field on each record (you don't want to lose necessary trailing blanks).
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Mon Oct 12, 2015 8:36 pm
Reply with quote

Bill, Can we use resize(ICETOOL) as below as a alternative to '/'? any downsides?
e.g.Vb is not considered for this example.

Code:
//TOOLIN DD *                         
   COPY JKFROM     TO(OUT1) USING(CTL2)
   RESIZE FROM(OUT1) TO(OUT2) TOLEN(50)
//CTL2CNTL DD *                       
   JOINKEYS F1=IN1,FIELDS=(16,5,A)     
   JOINKEYS F2=IN2,FIELDS=(1,5,A)     
   JOIN UNPAIRED                       
   OPTION COPY                         
   REFORMAT FIELDS=(F1:1,50,F2:1,30)   
/*   
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: Mon Oct 12, 2015 9:41 pm
Reply with quote

RESIZE is for fixed-length records only.

With the COPY already being a JOINKEYS, the RESIZE would add a second pass of the data.

You could make a fixed-length REFORMAT record, and then RESIZE, but you still have the extra pass.

ICETOOL's COPY and SORT can use JKFROM. RESIZE cannot. Can't avoid the two passes.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Oct 13, 2015 3:00 am
Reply with quote

Thanks Bill.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 6
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
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top