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 Usergroups Profile Log in to check your private messages Log in
 

 

How can i merge two files in sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How can i merge two files in sort
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: 680
Location: NJ

PostPosted: Tue May 16, 2006 7:24 pm    Post subject: Merget & Sort
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 Moderator


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

PostPosted: Tue May 16, 2006 8:49 pm    Post subject:
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    Post subject: Hi Frank
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

Moderator Team Head


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

PostPosted: Tue May 16, 2006 9:07 pm    Post subject: Re: Sort
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    Post subject: Thanks Superk
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    Post subject:
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 Moderator


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

PostPosted: Tue May 16, 2006 10:16 pm    Post subject:
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:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
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    Post subject: Hi Frank
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    Post subject: Hi Frank Yaeger
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    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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm


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