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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.