View previous topic :: View next topic
|
Author |
Message |
rammohan paulrajan
New User
Joined: 28 Nov 2007 Posts: 11 Location: chennai
|
|
|
|
Hi, I have a requirement like below
I have a file with address information and I would like to filter (include) only records which has address information. Address position is 1 to 40.
When I tried the below sort card, it didn't work out. Could you help me with any other way
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,40,CH,NE,X'00',AND,1,40,CH,NE,X'40')
/* |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You want to exclude all records with spaces or binary-zeros in the first 40 bytes? |
|
Back to top |
|
|
rammohan paulrajan
New User
Joined: 28 Nov 2007 Posts: 11 Location: chennai
|
|
|
|
Yes Woodger. Thats right |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Can there be both x'00' and x'40' in the same 1st 40 bytes?
Or does the first 40 bytes need to be completely space or x'00' to be skipped? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Other than the INCLUDE being more difficult tp read due tpo the negated condition, it should be working.
Which means what you have described is not the full story.
Please post the sysout from a step which did not work, show some sample input records and expected output and provide the RECFM/LRECL of the input, and output if different.
Pay close attention to Dick's question.
Consider re-writing the INCLUDE as OMIT:
Code: |
OMIT COND=(1,40,CH,EQ,X'00',
OR,1,40,CH,EQ,C' ') |
NB. TS had X'40', which in the test for a field longer than one byte compared the value "padded" with binary zeros, due to the use of a hexadecimal constant. Using C' ' for a space, a character constant, causes the comparison to be padded with space and works correctly. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Bill,
I tried the following :-
Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'00',
OR,1,20,CH,EQ,X'40')
//STEP0002 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'0000000000000000000000000000000000000000',
OR,1,20,CH,EQ,X'4040404040404040404040404040404040404040')
|
from STEP0001
Code: |
//SORTIN DD *
66EDDECD444CC45444444444444444444444444444444444444444444444444444444444
11269395000440C000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
444444444444444444444444444444444444444444444444444444444444444444444444
000000000000000000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
A
4444C4444444444444444444444444444444444444444444444444444444444444444444
000010000000000000000000000000000000000000000000000000000000000000000000
|
From STEP0002
Code: |
//SORTIN DD *
66EDDECD444CC45444444444444444444444444444444444444444444444444444444444
11269395000440C000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
444444444444444444444444444444444444444444444444444444444444444444444444
000000000000000000000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
A
4444C4444444444444444444444444444444444444444444444444444444444444444444
000010000000000000000000000000000000000000000000000000000000000000000000
|
STEP0001 produced output of 2 lines
STEP0002 produced 1 line of output
I was expecting the result to be the same for both steps ie. only 1 records out
Am I missing something ?
Gerry |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think I must be :-)
Why are you expecting only one record output, when the first record of your input is neither 20 binary-zeros nor 20 spaces? |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Bill,
does this
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'00',
OR,1,20,CH,EQ,X'40')
|
equal this
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'0000000000000000000000000000000000000000',
OR,1,20,CH,EQ,X'4040404040404040404040404040404040404040')
|
Gerry |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
A guarded Yes. When I tried it, mine got rid of a line of 40 binary-zeros or 40 spaces, but retained lines containing at least one other character.
However, TS's code is equivalent, and doesn't work (in some unknown way).
I'm using DFSORT. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Bill Woodger wrote: |
Why are you expecting only one record output, when the first record of your input is neither 20 binary-zeros nor 20 spaces? |
I got confused by the above statement, Gerry's input has spaces at pos 1-20 in record-1 right? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Looks like when ever we need to provide X we need give the value equal to length in Include or OMIT
Coudlnt find any details of that in Manuals
Pretty strange for me
Edit: Also the same does not happen when using C' ' |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
I'm also using DFSORT.
Also my first record is all blanks.
Quote: |
A guarded Yes. When I tried it, mine got rid of a line of 40 binary-zeros or 40 spaces, but retained lines containing at least one other character |
Bill, just so I'm not confused, which of my 2 options did you use ?
Pandora-box, so you are getting the same results as I'm getting
Gerry |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Yes indeed |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
I had a look at the DFSORT manual and it is pretty much clear about field-to-constant comparison rules when the operands differ in length.
Quote: |
Character and hexadecimal strings are truncated and padded on the right.
The padding characters are:
X'40' For a character string
X'00' For a hexadecimal string. |
In Gerry's card, the comparison was with hexadecimal strings and as per the rule, both were padded with X'00' on the right before comparison.
So the equivalent of
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'0000000000000000000000000000000000000000',
OR,1,20,CH,EQ,X'4040404040404040404040404040404040404040') |
will be
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,CH,EQ,X'00',
OR,1,20,CH,EQ,C' ') |
Hope this makes sense now. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That'll be it Arun.
I just can't bring myself to code X'40' instead of C' ', so that was how I tested. Then this morning I reaslised I'd not bothered to post the results, so just copied TS's stuff and re-arranged, so untested code, with the X'40' as in the original.
All now clear. The X'40' in 40 bytes looks for X'40' and 39 binary zeros. The C' ' looks for 40 spaces. The X'00' looks for 40 binary zeros.
EDIT:
I've updated the original to avoid confusion. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Arun wrote: |
I had a look at the DFSORT manual |
Now, you've done it . . . Everyone will be reading manuals and not asking us to do
Good catch!
d |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
another way to code this could be
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,SS,EQ,X'00',
OR,1,20,SS,EQ,X'40')
|
Gerry |
|
Back to top |
|
|
rammohan paulrajan
New User
Joined: 28 Nov 2007 Posts: 11 Location: chennai
|
|
|
|
Hi Dick,
My input records either will have all X'40' or all X'00' not a mixture of both. So I had 3 records with 40 length and one record had value, one record had all X'40' and one record had all X'00'. When I used the OMIT condition given, still I got all 3 records in the output file. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Then show the full sysout from your step, and show the three input records, in hexadecimal. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
When I used the OMIT condition given, still I got all 3 records in the output file. |
Because the Sort Control info is incorrect.
Until you do as asked and post the submitted job and the informational messages produced along with the 3 records (in hex), we can't be much help. |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Gerry,
Quote: |
Code: |
SORT FIELDS=COPY
OMIT COND=(1,20,SS,EQ,X'00',
OR,1,20,SS,EQ,X'40') |
|
If am not wrong, SS (Substring) would look out for any single spaces to be found, when it does then the particular record would be omitted. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
As the poster has given us naff all information
Maybe it's a VB record |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
Quote: |
If am not wrong, SS (Substring) would look out for any single spaces to be found, when it does then the particular record would be omitted.
|
My mistake, you are correct, I had a number of steps in my job and the SORTOUT statement I looked at did not belong to the above statements.
Gerry |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Yes Gerry I assumed that could be a copy / paste error.
Thank you |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
So, is the problem with the 3 records now resolved? |
|
Back to top |
|
|
|