|
View previous topic :: View next topic
|
| Author |
Message |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Hi,
What would be the best way (fastest, simplest) to perform the following task:
I want to dynamically build a CNTL-card with a INCLUDE COND that looks like this:
| Code: |
INCLUDE COND=(SYMBOL,EQ,C'TYPE1',OR,
SYMBOL,EQ,C'TYPE2',OR,
....
SYMBOL,EQ,C'TYPEn')
|
Where "SYMBOL" is the name of a symbol referring to a field.
The values for the types are coming from file - and I don't know how many there will be, but I do know, that they are all different.
The output need only be syntaxical correct - the example is one solution - there are other possiblities, ie. move OR etc. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Don't have time to test, but by making the "dummy" tests for the first and last, which can be generated from HEADERn and TRAILERn, the construction of the actual tests you want is simplified. Read the conditions file and for every line generate the same with the contents of the data from your file being placed within the quotes of the literal in the INCLUDE tests.
| Code: |
INCLUDE COND=(1,1,CH,NE,1,1,CH,OR,
SYMBOL,EQ,C'TYPE1',OR,
SYMBOL,EQ,C'TYPE2',OR,
....
SYMBOL,EQ,C'TYPEn',OR,
1,1,CH,NE,1,1,CH)
|
|
|
| Back to top |
|
 |
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
I would write a REXX exec to read the 'file' and generate the include condition to an output file.
This output file would be part of a concatenated SYSIN DD for your actual sort step.
Just one of the possibilities. |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Hi Bill,
Sounds simple and fast - thanks I'll present the "fun" solution here later..
/Claes |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Hi Dave, sure is. But I prefer to use ICETOOL if possible.  |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Bill,
Decided that your solution was not only simple and fast, but also fun..
No need to put more time into this.. Thanks again. |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
| Code: |
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(TYPE) FIRST USING(CTL1)
//CTL1CNTL DD *
OUTFIL FNAMES=OUT,
BUILD=(16X,C'TYPE,EQ,C',
P,TYPE,P,C',OR,',80:X),
HEADER1=(2X,C'INCLUDE COND=(1,1,BI,NE,1,1,BI,OR,'),
TRAILER1=(16X,C'1,1,BI,NE,1,1,BI)')
|
Outputs:
| Code: |
INCLUDE COND=(1,1,BI,NE,1,1,BI,OR,
TYPE,EQ,C'TYP1',OR,
TYPE,EQ,C'TYP2',OR,
TYPE,EQ,C'TYP3',OR,
1,1,BI,NE,1,1,BI) |
|
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
| Note, P is a symbol equalvalent to X'7D' here at my site. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
How and when are you going to find that 1,1,CH is not equal to 1,1CH but real quick without testing, below should help.
| Code: |
INCLUDE COND=(1,1,CH,NE,1,1,CH,OR, -->??
(SYMBOL(FIRST 4 BYTE),EQ,C'TYPE',AND,
(SYMBOL(LAST BYTE),GE,1,AND,SYMBOL(LAST BYTE),LE,N))) |
OR if last byte is numeric check only then...
| Code: |
INCLUDE COND=(1,1,CH,NE,1,1,CH,OR, --> ??
(SYMBOL(FIRST 4 BYTE),EQ,C'TYPE',AND,
(SYMBOL(LAST BYTE),EQ,NUM))) |
Thanks, |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The test for the first byte not equal to the first byte is just a "placeholder". It will never be true, and combining it by using OR will not affect the processing of the selection actually desired in the INCLUDE.
<Some necessary opening stuff>NOT TRUE, OR
SOME CONDITION,OR,
SOME CONDITION,OR,
SOME CONDITION,OR,
NOT TRUE<some necessary closing stuff>
Purpose just to simplify the generation of the SOME CONDITION stuff, so no need to worry about first/last.
I saw Frank Yaeger using something like it and had no time to search for the example so "imagined" what it had to be :-)
Kolusu will be along later.... |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
| Add REMOVECC, then it's all great. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Bill Woodger,
| Quote: |
| The test for the first byte not equal to the first byte is just a "placeholder". It will never be true, and combining it by using OR will not affect the processing of the selection actually desired in the INCLUDE. |
If this was a response to my question, why does OP want to add extra condition and processing? If the condition is never going to be true, why bother to have it in the card itself?
I was merely implying typo on OP's end when i asked that question.
Thanks, |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think everything is in the original post and in my reply.
Perhaps an even simpler way is to use concatenation:
//SYSIN DD "top of the cards"
// DD generated cards
// DD bottom of the cards
More "set up" this way.
The HEADERn and TRAILERn can be modified to generate any other control statements required, so a general "quick way of generating a sort deck with data from a file". Yes, slows down a little with the never-true tests, but gets the job done and is "reusable".
If the selection file is
and the data is
then testing for NUM is going to get too much.
My reading is that the selection file is more like
| Code: |
TYPE1
TOPEX
IJDK3
11111 |
From the original:
| Quote: |
| I don't know how many there will be, but I do know, that they are all different. |
|
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Yes, the types are diverse, like Bill suggests.
Maybe, it makes more sense if you just repeat the first and last record.
Like this:
| Code: |
INCLUDE COND=(TYPE,EQ,C'ABCD',OR,
TYPE,EQ,C'ABCD',OR,
TYPE,EQ,C'EFGH',OR,
TYPE,EQ,C'IJKL',OR,
TYPE,EQ,C'IJKL') |
|
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Claes Norreen,
Since you have "diverse types", why not use JOINKEYs? Using dynamic sort card for too many INCLUDE/OMIT leaves you vulnerable to ice151a
Thanks, |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Sqlcode1,
I think you misunderstand the task I wish to do. I don't know I would use JOINKEYS here, anyway? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Claes Norreen wrote: |
Sqlcode1,
I think you misunderstand the task I wish to do. I don't know I would use JOINKEYS here, anyway? |
I agree with SQLCODE that you can use JOINKEYS as you are looking for TYPE field which is at the same position for every record. So why not match the 2 files (extract file and Look up file) on the type field and get the matching records? |
|
| Back to top |
|
 |
Claes Norreen
Active User
Joined: 20 Dec 2005 Posts: 137 Location: Denmark
|
|
|
|
Ah, I see now. Maybe "diverse" was not correct English.. I have a few types I wish to include from a dataset, and I don't want to sort it by TYPE, but keep it the way it is. Hence, a copy operation makes sense.
Sorry for the confusion |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|