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

Merging files and adding constant at the end using sort


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

New User


Joined: 22 May 2012
Posts: 32
Location: india

PostPosted: Wed Jul 25, 2012 4:41 pm
Reply with quote

Hi All,

I am having 4 files with me. The LRECL is of 80 and all the files are FB.
The data in each files looks like.

Code:
File 1:
001NITIN

File2:
001ROHIT

File3:
001ABHISHEK

File4:
001JOHN
002PETER


I have to merge this 4 files in such a way that after merging i can identify which record is from which file.

The output expected is as follows:

Output:
Code:
001NITIN          A
001ROHIT          B
001ABHISHEK       C
001JOHN           D
002PETER          D


Code'd and aligned
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: Wed Jul 25, 2012 5:13 pm
Reply with quote

You post has been "Code'd" to preserve the proportional spacing. By using Preview, you can see what needs to be done to align data and then only Submit when you are happy with the layout. Please do this yourself in future.

As to your task, I don't think there is a way to do this within the MERGE by saying "what is the DD for this record" or anything similar.

You could append an indicator for each file and then do the MERGE.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 25, 2012 6:59 pm
Reply with quote

Also it would be pretty straight forward if you could append the file identifier while creating the input file.

Just think about it if thats feasible
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 26, 2012 12:11 am
Reply with quote

use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
//SORTOUT  DD DSN=&&H,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)   
//SYSIN    DD *                                             
  OPTION COPY                                               
  OUTFIL REMOVECC,HEADER1=('HDR')                           
//*                                                         
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DISP=SHR,DSN=Your input FB 80 File1
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DISP=SHR,DSN=Your input FB 80 File2
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DISP=SHR,DSN=Your input FB 80 File3
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DISP=SHR,DSN=Your input FB 80 File4
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  INREC IFOUTLEN=80,                                               
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1)),     
  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(20:C'A')),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(20:C'B')),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,3),OVERLAY=(20:C'C')),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,4),OVERLAY=(20:C'D'))                   
  OUTFIL OMIT=(1,3,CH,EQ,C'HDR')
//*
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: Thu Jul 26, 2012 5:34 am
Reply with quote

Nice solution Kolusu. No need for the MERGE with the data shown, I missed that :-)

Nitin Bhargava, I do hope your file samples are representative.
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 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top