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

Join 2 files according to one key field.


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

New User


Joined: 25 May 2023
Posts: 18
Location: India

PostPosted: Thu Jun 01, 2023 2:34 pm
Reply with quote

Hi,

I have 2 VB files with record length=2004. I need to generate an output file by merging the first lines of both. The first line has $F in common. I need the count value from FILE2 at 10th position in the o/p file and rest FILE1 data to be same.

INPUT FILE1:
Code:

1234567890123456789
$F COUNT     
$A H                                             
LINE 1A
LINE 1B                                         
$U                                               
$A H                                             
LINE 2A
LINE 2B                                         
$U 


INPUT FILE2:

Code:

1234567890123456789
$F       2 


OUTPUT FILE:
Code:
1234567890123456789
$F COUNT 2     
$A H                                             
LINE 1A
LINE 1B                                         
$U                                               
$A H                                             
LINE 2A
LINE 2B                                         
$U
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1329
Location: Bamberg, Germany

PostPosted: Thu Jun 01, 2023 4:24 pm
Reply with quote

To combine all your attempts, this one should work.

Code:
//WHATEVER EXEC PGM=ICEMAN                                           
//F1       DD DISP=OLD,DSN=&SYSUID..VB2004                           
//F2       DD DISP=OLD,DSN=&SYSUID..VB2004                           
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD DISP=OLD,DSN=&SYSUID..VB2004                           
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  JOINKEYS F1=F1,FIELDS=(2005,1,A),SORTED,NOSEQCK                     
  JOINKEYS F2=F2,FIELDS=(2005,1,A)                                   
  REFORMAT FIELDS=(F1:5,2000,F2:2006,4)                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(2005:SEQNUM,8,BI))                 
  OUTFIL FNAMES=(SORTOUT),                                           
    OMIT=(1,3,CH,EQ,C'$F'),                                           
    REMOVECC,FTOV,                                                   
    IFTHEN=(WHEN=(2005,8,BI,EQ,+1),                                   
      BUILD=(1,2000,/,C'$F COUNT',X,2001,4,BI,M11,LENGTH=6)),         
    IFTHEN=(WHEN=NONE,BUILD=(1,2000))                                 
  END                                                                 
/*                                                                   
//JNF1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(2005:X))                           
  END                                                                 
/*                                                                   
//JNF2CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(2006:4Z)),                         
    IFTHEN=(WHEN=GROUP,BEGIN=(5,3,CH,EQ,C'$A'),END=(5,3,CH,EQ,C'$U'),
      PUSH=(2010:ID=8),RECORDS=1),                                   
    IFTHEN=(WHEN=(2010,8,FS,EQ,NUM),OVERLAY=(2006:+1,BI,LENGTH=4))   
  SUM FIELDS=(2006,4,BI)                                             
  END                                                                 
/*
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2136
Location: USA

PostPosted: Thu Jun 01, 2023 5:05 pm
Reply with quote

It would be nice if TS had read at least some SORT manuals before asking exactly the same questions in about 10 different topics.

Some very kind responders present him ready-to-use code solutions, but instead of trying to understand the response the TS just opened new topics on the same issue.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1329
Location: Bamberg, Germany

PostPosted: Thu Jun 01, 2023 9:29 pm
Reply with quote

May this, altogether with the other comments, help the TS to understand the logic. JOINKEYS is a mighty weapon that should be assembled when each of its parts are understood, and other options are not applicable.

As it was said, the record count should be added to the trailer, not the header.
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 Help required to reset decimal points... DFSORT/ICETOOL 6
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top