Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Merging files and adding constant at the end using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Merging files and adding constant at the end using sort
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jul 25, 2012 5:13 pm    Post subject: Reply to: Merging files and adding constant at the end using
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

Moderator


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

PostPosted: Wed Jul 25, 2012 6:59 pm    Post subject:
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    Post subject: Reply to: Merging files and adding constant at the end using
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Jul 26, 2012 5:34 am    Post subject: Reply to: Merging files and adding constant at the end using
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us