IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INCLUDE condition for checking low values or spaces


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rammohan paulrajan

New User


Joined: 28 Nov 2007
Posts: 11
Location: chennai

PostPosted: Fri Jul 19, 2013 3:02 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 3:07 am
Reply with quote

You want to exclude all records with spaces or binary-zeros in the first 40 bytes?
Back to top
View user's profile Send private message
rammohan paulrajan

New User


Joined: 28 Nov 2007
Posts: 11
Location: chennai

PostPosted: Fri Jul 19, 2013 3:15 am
Reply with quote

Yes Woodger. Thats right
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 5:39 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 11:44 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jul 19, 2013 12:38 pm
Reply with quote

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
Code:

                                                   
    A                                               



STEP0002 produced 1 line of output
Code:

    A                           



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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 12:49 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jul 19, 2013 1:00 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 1:34 pm
Reply with 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.

However, TS's code is equivalent, and doesn't work (in some unknown way).

I'm using DFSORT.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Jul 19, 2013 1:42 pm
Reply with quote

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? icon_rolleyes.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Fri Jul 19, 2013 2:11 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jul 19, 2013 2:44 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Fri Jul 19, 2013 2:45 pm
Reply with quote

Yes indeed
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Jul 19, 2013 3:39 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 4:35 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 19, 2013 8:11 pm
Reply with quote

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 icon_cool.gif

Good catch!

d
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sun Jul 21, 2013 4:43 am
Reply with quote

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
View user's profile Send private message
rammohan paulrajan

New User


Joined: 28 Nov 2007
Posts: 11
Location: chennai

PostPosted: Sun Jul 21, 2013 5:51 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jul 21, 2013 12:53 pm
Reply with quote

Then show the full sysout from your step, and show the three input records, in hexadecimal.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 22, 2013 3:07 am
Reply with quote

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
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Jul 22, 2013 6:06 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Jul 22, 2013 6:18 pm
Reply with quote

As the poster has given us naff all information

Maybe it's a VB record
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Jul 23, 2013 3:37 am
Reply with quote

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
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Jul 23, 2013 12:04 pm
Reply with quote

Yes Gerry I assumed that could be a copy / paste error.

Thank you
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 23, 2013 8:37 pm
Reply with quote

Hello,

So, is the problem with the 3 records now resolved?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top