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

How can i merge two files in sort


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

New User


Joined: 13 Sep 2005
Posts: 35
Location: India

PostPosted: Tue May 16, 2006 6:47 pm
Reply with quote

Hi
How can i merge two files in sort
My input is like

Code:

File1:input:
abcde
ghijkl


Code:

File2:input:
12345
67893


And i Want output as

Code:

File3:output:
abcde
12345
ghijkl
67893
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Tue May 16, 2006 7:24 pm
Reply with quote

Hi rink,

When two files(sorted files) are merged it will get appended in the thirdfile, but i dont think we can do it in ur way. Else u should read the first data of one file and first data of another file and put it in third file using application program(COBOL). before that u can sort the ps file using JCL's.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue May 16, 2006 8:49 pm
Reply with quote

rinkubhat,

Here's a DFSORT/ICETOOL job that will do what I think you're asking for which is to interleave the records from file1 and file2. I assumed your input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN1  DD *
abcde
ghijkl
/*
//IN2  DD *
12345
67893
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN DD *
* Add sequence number 1, 3, 5, ... to file1 records.
COPY FROM(IN1) TO(T1) USING(CTL1)
* Add sequence number 2, 4, 6, ... to file2 records.
COPY FROM(IN2) TO(T2) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=1,INCR=2)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=2,INCR=2)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD DSN=&&T1,DISP=(OLD,PASS)
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Merge on sequence number to interleave records from
* file1 and file2.
  MERGE FIELDS=(81,8,ZD,A)
* Remove sequence number.
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
rinkubhat

New User


Joined: 13 Sep 2005
Posts: 35
Location: India

PostPosted: Tue May 16, 2006 9:02 pm
Reply with quote

Look like teh code should work well will let u tomorrow
But where is the output file in this case
Also i am not clear with follwoing piece of code
Code:

//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=1,INCR=2)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=2,INCR=2)
/*
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue May 16, 2006 9:07 pm
Reply with quote

rinkubhat, please use CODE tags around code you post. It retains any imbedded indentations and spaces, making it much easier to read. Thanks.
Back to top
View user's profile Send private message
rinkubhat

New User


Joined: 13 Sep 2005
Posts: 35
Location: India

PostPosted: Tue May 16, 2006 9:11 pm
Reply with quote

Thanks Superk for correcting
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue May 16, 2006 9:24 pm
Reply with quote

In Step S2 specify file instead of directing to spool

//SORTOUT DD SYSOUT=*

use //SORTOUT DD dsn=outputfile..

Regards
jai
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue May 16, 2006 10:16 pm
Reply with quote

Quote:
But where is the output file in this case


The output is SORTOUT in S2. You can use a data set instead of SYSOUT=* for SORTOUT if appropriate.

Code:

//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=1,INCR=2)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=2,INCR=2)
/*


CTL1CNTL supplies DFSORT control statements for the first COPY operator. The INREC statement adds an 8-byte ZD sequence number at the end of the record. The sequence number starts at 1 and is incremented by 2 for each record giving 1, 3, 5, ...

CTL2CNTL supplies DFSORT control statements for the second COPY operator. The INREC statement adds an 8-byte ZD sequence number at the end of the record. The sequence number starts at 2 and is incremented by 2 for each record giving 2, 4, 6, ...

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
rinkubhat

New User


Joined: 13 Sep 2005
Posts: 35
Location: India

PostPosted: Wed May 17, 2006 11:54 am
Reply with quote

Thanks the code u gave worked fine
But when i replaced SORTOUT WITH DSN NAME IT GIVES ME AN ABEND
Code:

//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Merge on sequence number to interleave records from
* file1 and file2.
  MERGE FIELDS=(81,8,ZD,A)
* Remove sequence number.
  OUTREC BUILD=(1,80)

ABEND IS RELATED TO SOME DCB PARAMETER RELATED WITH EROPT
Code:
IEF403I KARBHAT5 - STARTED - TIME=01.00.44
+IEC020I 001-4,KARBHAT5,S2      ,SYSOUT  ,JES
+IEC020I EROPT IS 'ABE' OR NOT SPECIFIED
IEA995I SYMPTOM DUMP OUTPUT  357
SYSTEM COMPLETION CODE=001
 TIME=01.00.45  SEQ=14175  CPU=0000  ASID=0072
 PSW AT TIME OF ERROR  078D1000   00EC3A6E  ILC 2  INTC 0D
   NO ACTIVE MODULE FOUND
   NAME=UNKNOWN
   DATA AT PSW  00EC3A68 - 00181610  0A0D0000  00238000
   AR/GR 0: 80D3FB3E/80000000   1: 00000000/80001000
         2: 00000000/008C0FE8   3: 00000000/00006EA0
Back to top
View user's profile Send private message
rinkubhat

New User


Joined: 13 Sep 2005
Posts: 35
Location: India

PostPosted: Wed May 17, 2006 12:27 pm
Reply with quote

Issue rsolved Thanks for your help
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 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
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top