|
View previous topic :: View next topic
|
| Author |
Message |
wiprov
New User
Joined: 13 Feb 2008 Posts: 15 Location: Chennai
|
|
|
|
Hi,
I have an i/p file with LREC-80 and i have to omit the record, if it contains '9999...' from col 01 - 80.
Could you please let me know, is there any easier way to acheive this?
SORT FIELDS=COPY
INCLUDE COND=(1,80,CH,EQ,C'99...').
I felt, placing 80 occurances of '99...' in COND wouldn't be a better option.
Could you please update, is there any smart way to omit this record?
Thanks in advance. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Try 80C'9'. |
|
| Back to top |
|
 |
wiprov
New User
Joined: 13 Feb 2008 Posts: 15 Location: Chennai
|
|
|
|
Hi Bill,
I have tried the below code and it is throwing me syntax error.
| Code: |
SORT FIELDS=COPY
INCLUDE COND=(1,80,CH,NE,80C'9')
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
]
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, that's a No then.
I'd suggest two consecutive tests for 40 9's, to save having to continue the literal.
Please post SyncSort questions in the JCL part of the forum, not in DFSORT. |
|
| Back to top |
|
 |
wiprov
New User
Joined: 13 Feb 2008 Posts: 15 Location: Chennai
|
|
|
|
Thanks Bill..
I have tried the below code but still facing the same issue
| Code: |
SORT FIELDS=COPY
INCLUDE COND=(1,40,CH,NE,40C'9',AND,41,40,CH,NE,40C'9')
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
|
Kindly suggest |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No, I meant since you can't use the repetition factor in a condition, then you can't use it.
| Code: |
OMIT COND=(1,40,CH,EQ,C'999999forty of them',
AND,
1,40,CH,EQ,41,40,CH) |
Something like that.
Looking now at your code, you'd be better off with OMIT to avoid negating the conditions. |
|
| Back to top |
|
 |
Marso
REXX Moderator

Joined: 13 Mar 2006 Posts: 1356 Location: Israel
|
|
|
|
| Code: |
| OMIT COND=(1,1,CH,EQ,C'9',AND,2,79,CH,EQ,1,79) |
 |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Indeed Marso. Needs documentation, else people will just stare at it :-)
Define some symbols on DDname SYMNAMES:
| Code: |
FIELD-TO-CHECK-FOR-SAME-VALUE,3,40,CH
POSITION,FIELD-TO-CHECK-FOR-SAME-VALUE
SAME-VALUE-FIRST-BYTE,*,1,=
FIELD-EXCLUDING-LEADING-BYTE,*,39,=
POSITION,SAME-VALUE-FIRST-BYTE
FIELD-EXCLUDING-TRAILING-BYTE,*,=,=
* CONSTANT
ALL-VALUE-TO-IGNORE,C'U' |
Include SYMNOUT DDname for run-time copy of symbols and hteir translation:
| Code: |
------- ORIGINAL STATEMENTS FROM SYMNAMES -------
FIELD-TO-CHECK-FOR-SAME-VALUE,3,40,CH
POSITION,FIELD-TO-CHECK-FOR-SAME-VALUE
SAME-VALUE-FIRST-BYTE,*,1,=
FIELD-EXCLUDING-LEADING-BYTE,*,39,=
POSITION,SAME-VALUE-FIRST-BYTE
FIELD-EXCLUDING-TRAILING-BYTE,*,=,=
* CONSTANT
ALL-VALUE-TO-IGNORE,C'U'
------------------ SYMBOL TABLE -----------------
FIELD-TO-CHECK-FOR-SAME-VALUE,3,40,CH
SAME-VALUE-FIRST-BYTE,3,1,CH
FIELD-EXCLUDING-LEADING-BYTE,4,39,CH
FIELD-EXCLUDING-TRAILING-BYTE,3,39,CH
ALL-VALUE-TO-IGNORE,C'U' |
The code:
| Code: |
OPTION COPY
OMIT COND=((SAME-VALUE-FIRST-BYTE,
EQ,
ALL-VALUE-TO-IGNORE),
AND,
(FIELD-EXCLUDING-TRAILING-BYTE,
EQ,
FIELD-EXCLUDING-LEADING-BYTE)) |
The translated code:
| Code: |
OPTION COPY
OMIT COND=((3,1,CH,EQ,C'U'),AND,(3,39,CH,EQ,4,39,CH)) |
When the field needs to be different, change the start, length and the length-minus-one value, and the constant to match to. That's it.
(note, names chosen are just for demonstration, not actual suggestions...) |
|
| Back to top |
|
 |
Marso
REXX Moderator

Joined: 13 Mar 2006 Posts: 1356 Location: Israel
|
|
|
|
| Bill wrote: |
| Indeed Marso. Needs documentation, else people will just stare at it :-) |
Indeed :-)
It works because character comparison goes from left to right.
So I make sure the first character is a '9':
then I check that the 2nd char is equal to the 1st, the 3rd equal to the 2nd, and so on until the end of the field:
If all come true, then 1st char = 2nd char = 3rd = 4th ... = 80th, all of them being equal to '9'.
(I remember using similar tricks when I was programming in Assembler, way back in the 20th century) |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| Marso wrote: |
| Code: |
| OMIT COND=(1,1,CH,EQ,C'9',AND,2,79,CH,EQ,1,79) |
 |
Good trick!  |
|
| Back to top |
|
 |
wiprov
New User
Joined: 13 Feb 2008 Posts: 15 Location: Chennai
|
|
|
|
| Super.....Thanks for the smart code.... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|