|
View previous topic :: View next topic
|
| Author |
Message |
Saini19
New User
Joined: 12 Apr 2012 Posts: 23 Location: Singapore
|
|
|
|
I need to compare two files using SORT.
Here is my requirement:
I have two input files
input 1: length 38 bytes
input 2: length 1 byte (Basically its a data card having value from 1-9)
I need to compare the (21,1,ch) of input 1 with (1,1,ch) of input 2 and include only those records (of the file input 1) in the output file whose key matches with the key of the record in file input 2.
How can this be done using sort or ICETOOL.
Can my requirements be done using SORT CARD??
input 1:
| Code: |
col1-7 Col 21
------ -
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1 |
INPUT2:
Output:
| Code: |
col1-7 col21
------ -
156546 1
532323 1
584985 1
679769 1
263982 1
370733 1 |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'd not really call that "comparing files". Also your subject does not convey much meaning.
Personally, I'd do it in two steps, setting up a SYMNAME for the value on your single record file in the first step and INCLUDE with that SYMNAME in the second step.
There are examples in the forum, usually with a date record. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
does it occur to You that using a meaningful title might provide You with more replies.
most of the people just skip the topics with stupid/irrelevant titles
Note: TITLE EDITED |
|
| Back to top |
|
 |
Saini19
New User
Joined: 12 Apr 2012 Posts: 23 Location: Singapore
|
|
|
|
@Bill: I saw the link <http://ibmmainframes.com/about28075.html> and will try it in my case. Hope it works.
I want to have solution using ICETOOL only, can you help me in this.? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think, once you get it working with Sort, you could use an ICETOOL function with a USING and have the statements in your control file for the two steps. There may be other ways.
Edit, there are more recent examples than the one you chose, but that's not a problem. |
|
| Back to top |
|
 |
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
Try Below mentioned sort card
| Code: |
//STEP010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INPUT1 DD *
1
/*
//INPUT2 DD *
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1
/*
//TEMP1 DD DSN=&&TEMP1,
// UNIT=(SYSDA,9),SPACE=(CYL,(25,50),RLSE),
// DISP=(MOD,DELETE,DELETE)
//OUT1 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(INPUT1) TO(TEMP1) USING(CTL1)
COPY FROM(INPUT2) TO(TEMP1) USING(CTL2)
SPLICE FROM(TEMP1) TO(OUT1) -
ON(21,1,CH) -
WITHALL WITH(1,80) WITH(82,1)-
USING(CTL3) KEEPNODUPS -
KEEPBASE
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:20X,21:1,1,22:59X,81:C'AA'))
/*
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,80,81:C'BB'))
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT1,
INCLUDE=(81,2,CH,EQ,C'AB'),
BUILD=(1:1,80)
/* |
Output:
| Code: |
156546 1
532323 1
584985 1
679769 1
263982 1
370733 1 |
|
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Saini19,
Are you always going to have 1 record in the 1 byte file or is it possible to have multiple records? If you can have multiple records in the 1 byte file, please show an example of input records and expected output.
Thanks, |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You still have to copy the code from the forum for your single-record SYMNAMES generate, but...
| Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD * replace with your generated SYMNAMES and remove following data line
SELECTION-VALUE,C'1'
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(13,1,CH,EQ,SELECTION-VALUE)
//SORTIN DD *
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1
/*
|
ICETOOL if you insist:
| Code: |
//STEP0002 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYMNAMES DD * replace with your generated SYMNAMES and remove following data line
SELECTION-VALUE,C'1'
//OUT1 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
INCLUDE COND=(13,1,CH,EQ,SELECTION-VALUE)
//IN1 DD *
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1
/* |
Output from either is:
| Code: |
156546 1
532323 1
584985 1
679769 1
263982 1
370733 1 |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Saini19,
The easiest way to get the desired results using SET and PROC Symbols.
| Code: |
// SET PICKVAL='1'
//STEP0100 EXEC PGM=SORT,PARM='JP1"&PICKVAL"'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5-
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(21,1,CH,EQ,JP1)
//* |
saiprasadh,
I really appreciate you trying to help, but please do NOT post solutions that involve multiple passes of data. You don't need 3 passes of data. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Just in case you need ICETOOL solution
| Code: |
// SET PICKVAL='1'
//STEP0100 EXEC PGM=ICETOOL,PARM='JP1"&PICKVAL"'
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
156546 1
223244 2
532323 1
367856 6
424345 7
584985 1
679769 1
372382 6
263982 1
370733 1
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
//CTL1CNTL DD *
INCLUDE COND=(21,1,CH,EQ,JP1)
//* |
|
|
| Back to top |
|
 |
Saini19
New User
Joined: 12 Apr 2012 Posts: 23 Location: Singapore
|
|
|
|
@Saiprasadh: Thanks for the help.
I'll try this in my case. Hope it works fine.
@Sqlcode1: Yes, 1 byte file will always have 1 record.
@Bill/Skolusu:Input2 file may have any digit from 1-7, but at a time it will have only one record, not particularly fixed to numeral '1' only. It may have values as '2', '3' and so on till '7'. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Remember the idea is for you to find and amend a sort deck which can take a single record file (or the first record of a multi-record file) and from the contents of that generate the symbol/SYMNAMES for the step that is doing the work.
Let's see how long it takes to find one, starting, now...
One minute 37 and a bit seconds to find this.
OK, I knew where to look, how to use the search on the DFSORT forum, or the SEARCH on the top of each page. But, it is not difficult to get practice of. Then next time, you might find the solution all on your own, and two days faster than doing it this way.
We don't mind, we don't get paid either way. But learning how to get to what you want is a valuable skill which will benefit you time and again in your career.
Now, do you want me to fix the code up for you? Or do you want to do it yourself? Get the buzz you get from that? Having done it yourself, have it in the back of your mind for other solutions? Wonder what SYMNAMES are and look them up and find out what they can do for you?
Or do you want to sit there and moan mildly that no-one has made the complete code for you yet, even though you've had all the "hints" necessary? |
|
| Back to top |
|
 |
Saini19
New User
Joined: 12 Apr 2012 Posts: 23 Location: Singapore
|
|
|
|
@Bill: As mentioned in my last comment, I am trying it on my end as well. You should not have assumed that people just post and sit idle waiting for reply. May be you are experienced in handling sorting problems, however this is not an appreciable way to welcome new members who are willing to learn something from good teachers like you.
Anyways, let's not get into war of words. I just made that comment to you to let you know my scenario. Thanks a lot for your efforts.
Peace now please!! |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Bill Woodger wrote: |
You still have to copy the code from the forum for your single-record SYMNAMES generate, but...
] |
If you do this, you don't get "static" values in.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=your single-record file
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,0)),DISP=(,PASS) temporary dataset to //SYMNAMES DD in next step
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTREC FIELDS=(C'SELECTION-VALUE,''',1,1,C'''',80:X)
/* |
Yes, you are right. Why should I be concerned if I have told you how to do it, where to find examples, and then you point out to me that you might want different values for different runs... :-)
The above is untested (the stuff I've put there, not the original). You have a single record, so you can ditch the STOPAFT=1. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Saini19 wrote: |
@Bill/Skolusu:Input2 file may have any digit from 1-7, but at a time it will have only one record, not particularly fixed to numeral '1' only. It may have values as '2', '3' and so on till '7'. |
Well you can change your file 2 to be a set value and it doesn't matter what the value is.
Here is a detailed explanation of SET statement with examples (see 25.1 section)
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B631/25.0? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|