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

Include condition for for checking a numeric value in rec


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Sep 11, 2007 5:42 pm
Reply with quote

Hi ,
I have a input file of the below mentioned format.

MasterCard 5100 natwest
MasterCard 5101 hsbc
MasterCard 5101 natwest
MasterCard 5102 natwest
MasterCard 5102 natwest
Visa 400844 natwest
Visa 400880 natwest
Visa 401317 natwest
Visa 401343 natwest
Visa 401344 natwest
Visa 401744 natwest
UK Maestro 676795
UK Maestro 676796
UK Maestro 676798
UK Maestro 676799
UK Maestro 677230


My requirement is to copy all the records which has numeric value in the 6th column. here only Visa cards have numeric values in 6th posistion.

I have used the below mentioned condition

//sysin dd *
sort fields=(1,4,ch,a)
include cond=(6,1,zd,ge,0,and,6,1,zd,le,9)
/*


i have also tried with
//sysin dd *
sort fields=copy
include condition=(1,4,ch,eq,c'Visa')
/*

but still in the output i am getting other records which dont have numeric values in the 6th column or does not have a character visa in the begining.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Tue Sep 11, 2007 5:50 pm
Reply with quote

Hi Raghavendra,

Try this sort card

Code:

  INCLUDE=(6,1,FS,EQ,NUM)         


Thanks
Sai
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Sep 11, 2007 5:54 pm
Reply with quote

Raghavendra P K wrote:
but still in the output i am getting other records which dont have numeric values in the 6th column or does not have a character visa in the begining.
I find that very hard to believe, what proof can you provide (the sort's sysouts?) that shows that you are using that include and sort is ignoring it?
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Sep 11, 2007 7:00 pm
Reply with quote

Thanks Sai,

its working now.
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Sep 11, 2007 7:13 pm
Reply with quote

Hi Sai,

I have one more doubt , what is that FS stands for. In what situations we need to use it.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Sep 11, 2007 9:15 pm
Reply with quote

Quote:
but still in the output i am getting other records which dont have numeric values in the 6th column


I can explain that. You have 6,1,ZD in your condition. A 1-byte ZD value has is sd where s is the sign and d is the digit. In your Mastercard records, position 6 has 'r' = X'99' which is actually a ZD value of -9 (a sign of 9 is treated as negative). Since -9 is less than +0, these records are not included. But in your UK Maestro records, position 6 has 'e' = X'85' which is actually a ZD value of +5 (a sign of 8 is treated as positive). Since +5 is gt +0 and lt +9, these records are included.

If you had used CH instead of ZD, your INCLUDE statement would have worked:

Code:

   INCLUDE COND=(6,1,CH,GE,C'0',AND,6,1,CH,LE,C'9') 


But a better way is to use DFSORT's NUM function:

Code:

  INCLUDE COND=(6,1,FS,EQ,NUM)     


FS is used here for a character numeric value of '0'-'9'. For more information on DFSORT's NUM function, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Sep 11, 2007 9:22 pm
Reply with quote

Frank Yaeger wrote:
If you had used CH instead of ZD, your INCLUDE statement would have worked:
Why?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Sep 11, 2007 10:08 pm
Reply with quote

Because with CH, C'0' and C'9', you would be looking for values between '0'-'9' = X'F0'-X'F9', so nothing outside of those values would be included, e.g. 'r' = X'99' is lt X'F0' and 'e' = X'85' is lt X'F0'.

Note that FS,EQ,NUM looks for values between '0'-'9' as well.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Sep 11, 2007 10:33 pm
Reply with quote

Thanks, I'm seeing that in the ZD compare, the sign half byte messes things up, right?
I am not quite sure what you mean by:
Quote:
e.g. 'r' = X'99' is lt X'F0' and 'e' = X'85' is lt X'F0'.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Sep 11, 2007 11:34 pm
Reply with quote

Yes, if you use ZD it treats the value as signed and messes things up (see my previous post).

If you use CH or BI, it treats the value as unsigned so

Code:

   INCLUDE COND=(6,1,CH,GE,C'0',AND,6,1,CH,LE,C'9') 


is equivalent to checking for an unsigned binary value between X'F0' and X'F9'. In the example input, 'r', 4' and 'e' are the values in position 6. 'r' is X'99' in hex and 'e' is X'85' in hex - both are treated as less than X'F0' when you use CH or BI. '4' is X'F4' in hex and is treated as between X'F0' and X'F9' when you use CH, BI or ZD.

Does that help?
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Thu Sep 13, 2007 1:02 pm
Reply with quote

Hi Frank,

thanks a lot for your valuable suggestions.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Sep 14, 2007 1:11 pm
Reply with quote

Quite a valuable information is there in this thread about 'CH' & 'ZD' icon_smile.gif . Marked for my future reference icon_smile.gif
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 Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts REXX - Dataset checking in a do forev... CLIST & REXX 6
Search our Forums:

Back to Top