|
View previous topic :: View next topic
|
| Author |
Message |
krishna_ragav
New User
.jpg)
Joined: 29 Oct 2010 Posts: 10 Location: Chennai
|
|
|
|
Hi all,
I have a flat file which can have 2 records with same key. My requirement is to fetch first occurrence among the duplicates from the flat file using DFSORT. Can you guys help me.
Thanks,
Krishna |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
| Back to top |
|
 |
krishna_ragav
New User
.jpg)
Joined: 29 Oct 2010 Posts: 10 Location: Chennai
|
|
|
|
I just want to expand the situation. The flat file created contains the records from two input flat files. I have merged these two input files by using DFSORT - MERGE=COPY command.
Now the requirement is changed. I want the records from these two input flat files to be sort/merged and loaded into one VSAM file having key from 1-43 location. In case the two flat files have record with same key, the record from first file has to be loaded into VSAM file directly. We dont want any intermediate workfile.
Thanks,
Krishna |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| nobody prevents You from using as output dataset the VSAM itself |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
| Quote: |
| In case the two flat files have record with same key, the record from first file has to be loaded into VSAM file directly. |
If both the files have the same LRECL and DSORG then make a concatenated DD statement in SORTIN and use the technique on ibmmainframes.com/post-98317.html
If this is not the solution you are looking for, then it would be better if you give us more information, like show the input/output records. LRECL,DSORG of the i/p files. |
|
| Back to top |
|
 |
krishna_ragav
New User
.jpg)
Joined: 29 Oct 2010 Posts: 10 Location: Chennai
|
|
|
|
Hi All,
I have tried using JOINKEYS but i do not know how can we use both F1 and F2 Full LRECL Length in REFORMAT. Because
1) I need complete record from F1 if there any key present in both F1 and F2
2) I need complete record F1 if its un-paired record ( i.e. Its available only in F1)
3) I need complete record F2 if its un-paired record ( i.e. Its available only in F2)
We have done using ICETOOL but people wants either DFSORT - SORT Utility( Not with ICETOOL) / Join Keys.
| Code: |
//PS010 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTJNF1 DD DSN=XXXXX.CASVSMOT,DISP=SHR
//SORTJNF2 DD DSN=XXXXX.CASMONTH,DISP=SHR
//SORTOUT DD DSN=XXXXX.CASMONTH.TST1, CAS MONTHLY VSAM
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),
// DCB=(SYS3.DSCB,
// RECFM=VB,LRECL=254,DSORG=PS,BLKSIZE=0)
//*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,43,A)
JOINKEYS FILE=F2,FIELDS=(1,43,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,250)
SORT FIELDS=COPY
//* |
|
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
Krishna,
Try this..
1) complete record from F1 if there any key present in both F1 and F2
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,43,A)
JOINKEYS FILE=F2,FIELDS=(1,43,A)
REFORMAT FIELDS=(F1:1,250)
SORT FIELDS=COPY
//*
|
2) complete record F1 if its un-paired record ( i.e. Its available only in F1)
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,43,A)
JOINKEYS FILE=F2,FIELDS=(1,43,A)
JOIN UNPAIRED,F1,ONLY
SORT FIELDS=COPY
//*
|
3) complete record F2 if its un-paired record ( i.e. Its available only in F2)
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,43,A)
JOINKEYS FILE=F2,FIELDS=(1,43,A)
JOIN UNPAIRED,F2,ONLY
SORT FIELDS=COPY
//*
|
Thanks
-3nadh |
|
| Back to top |
|
 |
krishna_ragav
New User
.jpg)
Joined: 29 Oct 2010 Posts: 10 Location: Chennai
|
|
|
|
Thank You. I do not wants to increase no of steps
I am also trying other possibilities
| Code: |
//JS010 EXEC PGM=SORT
//SORTIN01 DD DSN=XXXX.CASVSMOT.EDIT,DISP=SHR
//SORTIN02 DD DSN=XXXX.COMJW.CASMONTH.EDIT,DISP=SHR
//SORTOUT DD DSN=XXXX.SEQ.CASMONTH,
// DISP=(NEW,CATLG,DELETE),
// UNIT=PERMDA,SPACE=(CYL,(100,50),RLSE),
// DCB=(SYS3.DSCB,
// RECFM=VB,LRECL=254,DSORG=PS,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
MERGE FIELDS=(1,43,CH,A)
SUM FIELDS=NONE
/* |
It takes the record from second file and writes into output file If the key present in both the file. But I need to write from 1st file if key is available in both the files. Can you please help me. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
the link posted had already given You the reply ...
| Code: |
//SORTIN DD <first dataset>
// DD <second dataset>
//SORTOUT DD <output dataset> could be the VSAM
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(<position>,<length>,<type>,<order>)
SUM FIELDS=NONE
|
the option equals makes sure that the sorted records with the same key are in the original order
( file1 records before file2 records ) |
|
| Back to top |
|
 |
krishna_ragav
New User
.jpg)
Joined: 29 Oct 2010 Posts: 10 Location: Chennai
|
|
|
|
Thank You All,
I have tried with option EQUALS and It worked. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|