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
 

 

Syntax for merging two different files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
srramesh
Currently Banned

New User


Joined: 11 Jul 2008
Posts: 10
Location: Chennai

PostPosted: Fri Jul 18, 2008 4:08 pm    Post subject: Syntax for merging two different files
Reply with quote

Hi tell me syntax for merging two different files?

sysin dd=*
merge fields=(2,3,ch,a)
/*

is it correct?[/img]
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Jul 18, 2008 4:15 pm    Post subject: Reply to: mergin two files
Reply with quote

ramesh,

Quote:
Hi tell me syntax for merging two different files?


Refer to the manuals.

It should be
Code:
  //SYSIN    DD   *
       MERGE  FIELDS=(1,5,CH,A,10,5,CH,A)
     /*


SORTINnn will have input files to be merged.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Fri Jul 18, 2008 8:30 pm    Post subject: Re: mergin two files
Reply with quote

srramesh wrote:
Hi tell me syntax for merging two different files?

sysin dd=*
merge fields=(2,3,ch,a)
/*

is it correct?[/img]

That all depends on what you mean by "merge".

If the 2 files are pre-sequenced with the same sort order, and you simply want your output file to contain all the records from both input files, then you can code the following:
Code:
//STEP1  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN01 DD DSN=input.file1
//SORTIN02 DD DSN=input.file2
//SORTOUT  DD DSN=output.file
//SYSIN DD *
   MERGE FIELDS=(2,3,CH,A)
/*


However, if they are not pre-sequenced, then you can use the following:
Code:
//STEP1 EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTIN  DD DSN=input.file1
//        DD DSN=input.file2
//SORTOUT DD DSN=output.file
//SYSIN   DD *
   SORT FIELDS=(2,3,CH,A)
/*

If you do not mean "merge" the data sets, but rather "merge" the records (i.e., merge a record from File1 with a record from File2), let me know and I can provide you with the JCL for a SyncSort JOIN application.

Hope this helps.
Back to top
View user's profile Send private message
srramesh
Currently Banned

New User


Joined: 11 Jul 2008
Posts: 10
Location: Chennai

PostPosted: Mon Jul 21, 2008 11:43 am    Post subject: this is my program
Reply with quote

[img][/img]
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jul 21, 2008 11:47 am    Post subject:
Reply with quote

Hello,

Better try again. . . Nothing was posted.

It appears you tried to use "img". It is best to use "Code". Please do not try to attach images or screen shots.

When posting, it is a good idea to use Preview so you can see what your post will look like to the forum rather than just what you see in the Reply editor. After Preview, you must click Submit. . .
Back to top
View user's profile Send private message
srramesh
Currently Banned

New User


Joined: 11 Jul 2008
Posts: 10
Location: Chennai

PostPosted: Tue Jul 22, 2008 10:43 am    Post subject:
Reply with quote

how to upload my prog...like screenshots...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Jul 22, 2008 11:08 am    Post subject:
Reply with quote

Ramesh,

Cut Paste your code.
Select the entire code...click the "Code" button...
"Preview" to see everything is fine and then Submit.

Thanks,
Arun
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Tue Jul 22, 2008 4:24 pm    Post subject:
Reply with quote

Alissa Margulies,

Is it possible to merge fields using SORT? If so, can u please give me the logic?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jul 22, 2008 9:21 pm    Post subject:
Reply with quote

Hello,

Sample MERGE code was posted. Does this not meet your requirement?

If not, you need to post sample input data for 2 files and the output you want from the sample input. Please also menton the recfm and lrecl of the 3 files.

If you are not trying to merge 2 files into a 3rd file, please clarify.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Jul 23, 2008 2:26 am    Post subject:
Reply with quote

Bharath Nadipally wrote:
Is it possible to merge fields using SORT? If so, can u please give me the logic?

Are you asking if SORT can produce a record with some fields from File1 and other fields from File2? YES, using JOIN.

If this is not what you are asking, then you need to provide sample data from both input files and your expected output, as Dick has requested.
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Wed Jul 23, 2008 9:12 am    Post subject:
Reply with quote

Hi,

My requirement is as below.

File1:

field1
field2
field3

File2:

field4
field5
field6

File3(Output file):

field1 field4
field2 field5
field3 field6
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 23, 2008 9:26 am    Post subject:
Reply with quote

Hello,

You mention "fields" but what you've posted are records. . .

It will help if you use "real" record and field names and show sample content for those names. Things like account number, amount-due, zip-code, etc.

Keep in mind that a file typically contains records and records contain fields. Every time a file "read" is issued one record is read, not one field.
When posting technical questions it is best to stay with the existing terminology and not introduce new ways of saying things.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Jul 23, 2008 8:27 pm    Post subject:
Reply with quote

Bharath,

Is there a common key field between File1 and File2. It does not have to be in the same position for File1 and File2...
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Jul 23, 2008 8:29 pm    Post subject:
Reply with quote

... Or, do you simply want to pair Record1 from File1 to Record1 of File2, and Record2 from File1 with Record2 of File2, etc...
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: Wed Jul 23, 2008 11:10 pm    Post subject:
Reply with quote

Bharath,

See if the technique described in the "Join fields from two files record-by-record" Smart DFSORT Trick does what you want. You can find it at:

www.ibm.com/systems/support/storage/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Thu Jul 24, 2008 12:58 pm    Post subject:
Reply with quote

Alissa,

Alissa Margulies wrote:
... Or, do you simply want to pair Record1 from File1 to Record1 of File2, and Record2 from File1 with Record2 of File2, etc...


Yes. I just want to pair record1 from file1 to record2 of file2, etc....
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Thu Jul 24, 2008 1:01 pm    Post subject:
Reply with quote

Alissa,

Quote:
... Or, do you simply want to pair Record1 from File1 to Record1 of File2, and Record2 from File1 with Record2 of File2, etc...


Yes. I want to pair Record1 from File1 to Recor1 of File2, etc....
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Thu Jul 24, 2008 1:51 pm    Post subject:
Reply with quote

Bharat,

Are both the files having equal number of records. If not, what is your expected output in that case?

Thanks,
Arun
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Thu Jul 24, 2008 8:07 pm    Post subject:
Reply with quote

Bharath,

This SyncSort job should produce the desired results:
Code:
//STEP1 EXEC PGM=SORT                     
//SORTIN  DD *                             
FIELD1                                     
FIELD2                                     
FIELD3                                     
//SORTOUT DD DSN=&&TEMP1,DISP=(NEW,PASS)
//SYSOUT  DD SYSOUT=*                       
//SYSIN   DD *                               
   SORT FIELDS=COPY                       
   OUTREC FIELDS=(1:SEQNUM,4,ZD,1,6)       
//*****************************************
//STEP2 EXEC PGM=SORT                     
//SORTIN  DD *                             
FIELD4                                     
FIELD5                                     
FIELD6                                     
//SORTOUT DD DSN=&&TEMP2,DISP=(NEW,PASS)
//SYSOUT  DD SYSOUT=*                       
//SYSIN   DD *                               
   SORT FIELDS=COPY                       
   OUTREC FIELDS=(1:SEQNUM,4,ZD,1,6)       
//*****************************************
//STEP3  EXEC PGM=SORT                     
//SORTJNF1 DD DSN=&&TEMP1,DISP=(OLD,DELETE)
//SORTJNF2 DD DSN=&&TEMP2,DISP=(OLD,DELETE)
//SORTOUT  DD DSN=FINAL.OUTPUT
//SYSOUT   DD SYSOUT=*                       
//SYSIN    DD *                               
   JOINKEYS FILES=F1,FIELDS=(1,4,A)       
   JOINKEYS FILES=F2,FIELDS=(1,4,A)       
   REFORMAT FIELDS=(F1:5,6,F2:5,6)         
   SORT FIELDS=COPY                       
   OUTREC FIELDS=(1,6,1X,7,6)             
/* 
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Sun Jul 27, 2008 7:33 pm    Post subject:
Reply with quote

Alissa,

Thank you very much.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm
No new posts Icetool or Joinkeys example to compar... ishant chauhan DFSORT/ICETOOL 21 Sat Aug 20, 2016 2:40 am


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