View previous topic :: View next topic
|
Author |
Message |
srramesh Currently Banned New User
Joined: 11 Jul 2008 Posts: 10 Location: Chennai
|
|
|
|
Hi tell me syntax for merging two different files?
sysin dd=*
merge fields=(2,3,ch,a)
/*
is it correct?[/img] |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
srramesh Currently Banned New User
Joined: 11 Jul 2008 Posts: 10 Location: Chennai
|
|
|
|
[img][/img] |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
srramesh Currently Banned New User
Joined: 11 Jul 2008 Posts: 10 Location: Chennai
|
|
|
|
how to upload my prog...like screenshots... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
Alissa Margulies,
Is it possible to merge fields using SORT? If so, can u please give me the logic? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
... 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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
Alissa,
Thank you very much. |
|
Back to top |
|
|
|