|
View previous topic :: View next topic
|
| Author |
Message |
vinuk2009
New User
Joined: 30 Apr 2009 Posts: 19 Location: chennai
|
|
|
|
Hi,
I have two fixed length files. file1 has record length 80 and file2 has record length 600. I need to compare these two files and replace file2 values file1 values if the key in file1 match with key in file2. key in file1 starts from 10 and ends at 18. key in file2 starts from 6 and ends at 14. I need to replace file2 values start from 20 to 28 with file1 values start from 1 to 9 if the file1 key matches with file2 key otherwise we need not to replace. Also I need to keep header and trailer of file2 as it is. header record is first record on the file and trailer record is last record in the file. Could some one please help me in achieving this result. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Quote: |
| Could some one please help me in achieving this result. |
Can you this and post the sysout so we can see what level of sort you have at your site, please?
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
/* |
JOINKEYS would be the favourite if you have it, but we need to know the results of the above to see if you do and what else you may have. |
|
| Back to top |
|
 |
vinuk2009
New User
Joined: 30 Apr 2009 Posts: 19 Location: chennai
|
|
|
|
Hi Bill,
Thank you for looking into this post. Our site will support DFSORT as well as join keys. So please give me solution by using any of the above. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
other than position in the file,
is there a way to interrogate and recognize the head and trailer records?
The sysout was requested,
because JOINKEYS is available with G.
hopefully none of the H functions are necessary if you only have G.
re: ibmmainframes.com/viewtopic.php?t=33389 |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| vinuk2009 wrote: |
Hi Bill,
Thank you for looking into this post. Our site will support DFSORT as well as join keys. So please give me solution by using any of the above. |
Post the SYSOUT from the sample job that BILL gave you to run. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
How did we slip from giving you help to giving you a solution?
With respect, I'd like to see the requested output before investing time into giving you some pointers. |
|
| Back to top |
|
 |
vinuk2009
New User
Joined: 30 Apr 2009 Posts: 19 Location: chennai
|
|
|
|
Hi Bill,
Sorry for late response. I have executed your sort job and the information of DFSORT from the sysout is as follows. I believe you are looking for this information.
ICE250I 0 VISIT www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND,MORE
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 01:52 ON WED SEP 05, 2012 -
0 OPTION COPY 00001601
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1 |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Thank you vinuk2009.
It is a fairly simple JOINKEYS.
Specify the key for each file on the JOINKEYS statement. If the files are already sorted, specify SORTED,NOSEQ on the JOINKEYS statement. If not sorted, they will be sorted by default.
JOIN UNPAIRED,F2
Assuming that F2 is your main file.
REFORMAT FIELDS=(F2:1,600,F1:1,9,?)
INREC IFOUTLEN=600,
IFTHEN=(WHEN=(610,1,CH,EQ,C'B),
OVERLAY=(20:602,9)
And that'd be about it.
I'm assuming that the file 1 can never match a header/trailer record; that you want all unmatch file 2 records on your output file; that you are unconcerned about unmatched file 1 records; you are not really "comparing" the recors, but joining/matching on the key fields.
The header/trailer point that you brought up is a red-herring, unless there is more you are not telling.
Edit: Corrected 601 to 602, per Kolusu :-) |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
vinuk2009,
use the following DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DISP=SHR,DSN=Your Input FB 600 Byte file
//INB DD DISP=SHR,DSN=Your Input FB 80 Byte file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(06,9,A)
JOINKEYS F2=INB,FIELDS=(10,9,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,600,?,F2:1,9)
INREC IFOUTLEN=600,
IFTHEN=(WHEN=(601,1,CH,EQ,C'B'),OVERLAY=(20:602,9))
//* |
|
|
| Back to top |
|
 |
vinkum
New User
Joined: 20 Sep 2019 Posts: 2 Location: INDIA
|
|
|
|
Hi,
Can anyone help me out, File 1 data is not getting overlayed with file2 data
i could see in spool number of matched records and mismatched records but for matched records data in FILE1 is not getting replaced by file2
Can someone please correct me or suggest
//**REQUIREMENT: FOR ALL MATCHING RECORDS OF FILE2,UPDATE FILE 1 DATA AT POSITION 24:8 BY PICKING VALUES FROM FILE2 FROM POSITION 16:8
//SETP001 EXEC PGM=SORT,REGION=0K
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=FILE1,DISP=SHR FB LRECL=49 KEY 9,15
//SORTJNF2 DD DSN=FILE2,DISP=SHR FB LRECL=250 KEY 1,15
//SORTOUT DD DSN=FILE.ALL,DISP=SHR
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(50,500),RLSE)
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(50,500),RLSE)
//SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,(50,500),RLSE)
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(9,015,A)
JOINKEYS FILES=F2,FIELDS=(1,015,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,49,?,F2:16,08)
OPTION COPY
INREC IFOUTLEN=49,
IFTHEN=(WHEN=(50,1,CH,EQ,C'B'),OVERLAY=(24:51,8))
/*
SPOOL:
WER484I SORTJNF1 : RCD IN= 72597,OMITTED= 0,PAIRED= 37573,UNPAIRED= 35024
WER484I SORTJNF2 : RCD IN= 40257,OMITTED= 0,PAIRED= 37573,UNPAIRED= 2684 |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2287 Location: USA
|
|
|
|
| vinuk2009 wrote: |
Hi,
I have two fixed length files. file1 has record length 80 and file2 has record length 600. I need to compare these two files and replace file2 values file1 values if the key in file1 match with key in file2. key in file1 starts from 10 and ends at 18. key in file2 starts from 6 and ends at 14. I need to replace file2 values start from 20 to 28 with file1 values start from 1 to 9 if the file1 key matches with file2 key otherwise we need not to replace. Also I need to keep header and trailer of file2 as it is. header record is first record on the file and trailer record is last record in the file. Could some one please help me in achieving this result. |
Dear Moderators,
I believe the questions of this type: "How can I start doing my own job?" - must be prohibited at the Expert Forum.
The only questions allowed are:
- I tried to do <this>, and <this>
- I use this tool to achieve my goal
- I expected results like <this>, and <this>
- I've got the result like <this>, and/or messages/errors like <this>
- Please clarify for me the reason of bad results
Instead, again and again there are messages in the style
- Please, perform my job duties for me! I have no idea where to start from...
Those trying to ask these questions must be banned, I think. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
sergeyken, This is 7 years old post. What you raised is totally a different topic which has been discussed in past several times... So far it difficult to control such posts appearing it here than Beginners Forum.
vinkum, Please don't tailgate any post , specially too old ones. Start a new one with your requirements and make a use of Code tags.
Please lock this Thread. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Vinkum - apart from tailgating someone else's topic, posting to an old topic and not using the code tags you have posted in the DFSort part of the formum when you are using Syncsort.
Topic locked. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|