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
 

 

Comparison of three files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu Jun 20, 2013 7:12 pm    Post subject: Comparison of three files
Reply with quote

Hi

I have three files of length 4500 each (FB). I need to compare and see if a value at position 16 of length 24 are matching in the three files. If they match I need to check if there is a value of '0' (zero) at position 2057. If there exists a value of '0' then I need to display the values at the position 2057 from these three files such that the values are in ascending order in the third file first, then ascending order of second file and then ascending order of first file. Kindly advise.

Regards Suraaj
Back to top
View user's profile Send private message

Arun Raj

Moderator


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

PostPosted: Thu Jun 20, 2013 7:20 pm    Post subject:
Reply with quote

Quote:
I need to check if there is a value of '0' (zero) at position 2057. If there exists a value of '0' then I need to display the values at the position 2057 from these three files
If pos-2057 is '0', then why display it icon_confused.gif
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jun 20, 2013 7:33 pm    Post subject:
Reply with quote

Suraaj,

You need to explain the requirement much better

May be give us the sample input data and also exepected output within code tags and with cols on
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: Thu Jun 20, 2013 8:58 pm    Post subject:
Reply with quote

Hello,

You need to make up 3 sample input files. Make them only 40 bytes. In position 16 for a length of 4 show your "keys". Include whatever is needed for the "zero" consideration.

Then post the output you want from those 3 input files.

Use the code tags to preserve alignment.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu Jun 20, 2013 9:21 pm    Post subject: Reply to: Comparison of three files
Reply with quote

The input files would be like below:

Code:



111111111111111111111111123450
222222222222222222222222123450
333333333333333333333333123450
444444444444444444444444123450
555555555555555555555555123450
666666666666666666666666abcdf0
777777777777777777777777mbmbm0
888888888888888888888888ouiou0
999999999999999999999999iyutt0


111111111111111111111111lklkj1
222222222222222222222222lklkk2
333333333333333333333333jhjhj1
444444444444444444444444hghgf1
555555555555555555555555nbnbv1
666666666666666666666666gfgfd1
777777777777777777777777reree1
888888888888888888888888ytytt1
9999999999999999999999995r4re1


111111111111111111111111poiuu2
222222222222222222222222iuytr2
333333333333333333333333poiut2
444444444444444444444444fghjk2
555555555555555555555555qwert2
666666666666666666666666yuiop2
777777777777777777777777asdfg2
888888888888888888888888hjklm2
999999999999999999999999nbvcx2


The filed to be matched starts from position 1 with length 24 and the position to check for '0' is 30.

The output file would be like below:

Code:

111111111111111111111111   0   1   2
222222222222222222222222   0   2   2
333333333333333333333333   0   1   2
444444444444444444444444   0   1   2
555555555555555555555555   0   1   2
666666666666666666666666   0   1   2
777777777777777777777777   0   1   2
888888888888888888888888   0   1   2
999999999999999999999999   0   1   2


Please advise for further questions
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu Jun 20, 2013 9:27 pm    Post subject: Reply to: Comparison of three files
Reply with quote

I accomplished the task with three sort cards. One each for join keys for comparison between two files. And the third one I used to write to a new file if the file contained '0' at the any of the three particular positions and also sorted in the required format.

Code:


JOINKEYS FILE=F1,FIELDS=(16,24,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(16,24,A),SORTED,NOSEQCK
JOIN     UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:16,24,2057,1,F2:16,24,2057,1,?)
OPTION   COPY
OUTFIL   FNAMES=BOTH,INCLUDE=(51,1,CH,EQ,C'B'),
                    BUILD=(1,24,C'     ',25,1,C'  ',50,1)

JOINKEYS FILE=F1,FIELDS=(1,24,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(16,24,A),SORTED,NOSEQCK
JOIN     UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1,24,25,5,30,1,31,2,33,1,F2:16,24,2057,1,?)
OPTION   COPY
OUTFIL   FNAMES=ALL,INCLUDE=(59,1,CH,EQ,C'B'),
                    BUILD=(1,33,C'  ',58,1)

SORT FIELDS=(36,1,CH,A,30,1,CH,A,30,1,CH,A)
INCLUDE COND=(30,1,CH,EQ,C'0',OR,33,1,CH,EQ,C'0',OR,36,1,CH,EQ,C'0')



Is there an easier way out???

Thanks Suraaj
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jun 20, 2013 9:32 pm    Post subject:
Reply with quote

Suraaj,

You need to understand what JOIN UNPAIRED,F1,F2
is for

When you just need the matching records you dont need JOIN UNPAIRED,F1,F2
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu Jun 20, 2013 9:39 pm    Post subject: Reply to: Comparison of three files
Reply with quote

Sorry, I forgot to mention that. I had reused existing code so much for the usage of unpaired. Also the sort card that I have mentioned is for the actuals that I had mentioned in my first post.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jun 20, 2013 9:52 pm    Post subject:
Reply with quote

Try JOINKEYS in ICETOOL example below

Code:
//SRTJK EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//JNA DD *
AAAA 1
BBBB 1
CCCC 1
DDDD 1
EEEE 1
//JNB DD *
AAAA 2
BBBB 2
CCCC 2
DDDD 2
EEEE 2
//JNC DD *
AAAA 3
BBBB 3
CCCC 3
DDDD 3
EEEE 3
//JTEMP    DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(TRK,(5,5),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
 SORT JKFROM TO(JTEMP) USING(CTL1)
 SORT JKFROM TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  JOINKEYS F1=JNA,FIELDS=(1,4,A),SORTED
  JOINKEYS F2=JNB,FIELDS=(1,4,A),SORTED
  REFORMAT FIELDS=(F1:1,7,F2:6,2)
  OPTION EQUALS
  SORT FIELDS=COPY
/*
//CTL2CNTL DD *
  JOINKEYS F1=JTEMP,FIELDS=(1,4,A),SORTED
  JOINKEYS F2=JNC,FIELDS=(1,4,A),SORTED
  REFORMAT FIELDS=(F1:1,9,F2:6,2)
  OPTION EQUALS
  SORT FIELDS=COPY
/*


output

Code:
AAAA 1 2 3
BBBB 1 2 3
CCCC 1 2 3
DDDD 1 2 3
EEEE 1 2 3
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 21, 2013 12:25 am    Post subject: Re: Reply to: Comparison of three files
Reply with quote

suraaj wrote:
The input files would be like below:

Code:



111111111111111111111111123450
222222222222222222222222123450
333333333333333333333333123450
444444444444444444444444123450
555555555555555555555555123450
666666666666666666666666abcdf0
777777777777777777777777mbmbm0
888888888888888888888888ouiou0
999999999999999999999999iyutt0


111111111111111111111111lklkj1
222222222222222222222222lklkk2
333333333333333333333333jhjhj1
444444444444444444444444hghgf1
555555555555555555555555nbnbv1
666666666666666666666666gfgfd1
777777777777777777777777reree1
888888888888888888888888ytytt1
9999999999999999999999995r4re1


111111111111111111111111poiuu2
222222222222222222222222iuytr2
333333333333333333333333poiut2
444444444444444444444444fghjk2
555555555555555555555555qwert2
666666666666666666666666yuiop2
777777777777777777777777asdfg2
888888888888888888888888hjklm2
999999999999999999999999nbvcx2


The filed to be matched starts from position 1 with length 24 and the position to check for '0' is 30.

The output file would be like below:

Code:

111111111111111111111111   0   1   2
222222222222222222222222   0   2   2
333333333333333333333333   0   1   2
444444444444444444444444   0   1   2
555555555555555555555555   0   1   2
666666666666666666666666   0   1   2
777777777777777777777777   0   1   2
888888888888888888888888   0   1   2
999999999999999999999999   0   1   2


Please advise for further questions



Your requirements are a mess. If your Input file 1 has a '0' in position 2057 you need to list values from file 2 and file 3 for the same key? Is that it?

And I am not sure as to how this requirement will fit?
suraaj wrote:

I need to display the values at the position 2057 from these three files such that the values are in ascending order in the third file first, then ascending order of second file and then ascending order of first file. Kindly advise.


If you are only checking for the keys based of file1, how does the order come into picture? You need to do a better job of explaining your requirements
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Jun 21, 2013 1:55 am    Post subject: Re: Reply to: Comparison of three files
Reply with quote

suraaj wrote:
I accomplished the task with three sort cards. One each for join keys for comparison between two files. And the third one I used to write to a new file if the file contained '0' at the any of the three particular positions and also sorted in the required format.

Code:


JOINKEYS FILE=F1,FIELDS=(16,24,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(16,24,A),SORTED,NOSEQCK
JOIN     UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:16,24,2057,1,F2:16,24,2057,1,?)
OPTION   COPY
OUTFIL   FNAMES=BOTH,INCLUDE=(51,1,CH,EQ,C'B'),
                    BUILD=(1,24,C'     ',25,1,C'  ',50,1)

JOINKEYS FILE=F1,FIELDS=(1,24,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(16,24,A),SORTED,NOSEQCK
JOIN     UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1,24,25,5,30,1,31,2,33,1,F2:16,24,2057,1,?)
OPTION   COPY
OUTFIL   FNAMES=ALL,INCLUDE=(59,1,CH,EQ,C'B'),
                    BUILD=(1,33,C'  ',58,1)

SORT FIELDS=(36,1,CH,A,30,1,CH,A,30,1,CH,A)
INCLUDE COND=(30,1,CH,EQ,C'0',OR,33,1,CH,EQ,C'0',OR,36,1,CH,EQ,C'0')



Is there an easier way out???

Thanks Suraaj


Your data does not exercise your required conditions very well. File 1 are all 0, File 3 are all 2 and File 2 is all 1, except for one record which is set to 2.

The one item on File 2 set to 2 does not obey your stated requirement. Perhaps the two 30,1,CH,A in your SORT are the reason for that (the type of typo that the use of symbols should easily avoid)?

What you seem to want is:

Keys to match on all three files.
If (original) position 2057 is 0 on any file, then select for output
The output is then to be in the order of 2057 from File 3, followed by 2057 from File 2
followed by 2057 file File 1.

The UNPAIRED has already been mentioned. Without the UNPAIRED, you'll not need the ? match marker, therefore you'll not need the BUILD on OUTFIL (as long as you take notice of the next as well).

You seem to be inserting spaces in your JOINs just for the final formatting. This means your output contains more data than necessary, more data is sorted than necessary. Just use the data you need until the end, when you can do all the formatting you need.

In your second JOIN you seem to feel the need to specify the F1 fields individually, including those which just contain the blanks you inserted. This makes things "look" more complex, and is easier to mess up if maintenance is needed at some point.

You seem to be relying on EQUALS to get your key sequence as the final "sort" on your output. The more values which are the same for a sort key, the more "strain" is imposed on the use of EQUALS. As well as being clearer, it would perhaps perform better with the original "key" as a fourth sort key for your final output and using NOEQUALS.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Mon Jun 24, 2013 6:49 pm    Post subject: Reply to: Comparison of three files
Reply with quote

Sorry for the delayed reply because of some other additional assignments.

There is a small correction to my last post. The sort card is :
Code:

SORT FIELDS=(36,1,CH,A,[color=red]33[/color],1,CH,A,30,1,CH,A)
INCLUDE COND=(30,1,CH,EQ,C'0',OR,33,1,CH,EQ,C'0',OR,36,1,CH,EQ,C'0')


And as mentioned I will remove the spaces to decrease the overhead on sorting.

@Skolusu...

I am checking the first 24 bytes in all the three files and then if they match I need to pick up the data at position 2057 and list them from all the three files. Once they are listed I need to sort them based on the ascending value of value from file 3, then from file 2 and then from file 1.

PS: Other than the first 24 positions of data I have provided the actual data from my work.

With all these changes I have accomplished the task.

Thanks Suraaj
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 -> DFSORT/ICETOOL 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 CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 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


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