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

Syntax for merging two different files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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: 1287
Location: Chennai, India

PostPosted: Fri Jul 18, 2008 4:15 pm
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: 496
Location: USA

PostPosted: Fri Jul 18, 2008 8:30 pm
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jul 21, 2008 11:47 am
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
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: 2481
Location: @my desk

PostPosted: Tue Jul 22, 2008 11:08 am
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
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

Moderator Emeritus


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

PostPosted: Tue Jul 22, 2008 9:21 pm
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: 496
Location: USA

PostPosted: Wed Jul 23, 2008 2:26 am
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 23, 2008 9:26 am
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: 496
Location: USA

PostPosted: Wed Jul 23, 2008 8:27 pm
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: 496
Location: USA

PostPosted: Wed Jul 23, 2008 8:29 pm
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 Developer


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

PostPosted: Wed Jul 23, 2008 11:10 pm
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:

Use [URL] BBCode for External Links
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
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
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: 2481
Location: @my desk

PostPosted: Thu Jul 24, 2008 1:51 pm
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: 496
Location: USA

PostPosted: Thu Jul 24, 2008 8:07 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files and write Matched/Unm... JCL & VSAM 8
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
Search our Forums:

Back to Top