View previous topic :: View next topic
|
Author |
Message |
sandip_datta
Active User
Joined: 02 Dec 2003 Posts: 150 Location: Tokyo, Japan
|
|
|
|
What is the difference between Character and HEX Values.
We have an address field X(32). It may contain proper value or some junk like X'0000'. We need to seperate out those records having junk values in the Address field.
Your help will be appreciated.
Regards,
Sandip. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sandip,
Check out the CLASS clause in the SPECIAL-Names pgraph of the CONFIGURATION SECTION of the ENVIRONMENT DIVISION.
You can create a CLASS that contains all the chars that you deem acceptable. Then, in the proc div you can code a CLASS test to determine that your 32 byte field only contains those acceptable chars.
Example: Define a CLASS as "ACCEPTABLE"
In the proc div, code:
Code: |
IF FLD-32 IS ACCEPTABLE
PERFORM PROCESS-FLD
ELSE
PERFORM BY-PASS-FLD
END-IF
|
One cautionary note. When using the THRU feature in defining the CLASS, remember that 'A' THRU 'Z' defines all chars with bit configurations between X'C1' and X'E9'. That means that there are gaps between "I" and "J", "R" and "S" that contain values that are not alphabetic.
Take a look at Appendix B of the COBOL Reference Manual. It contains the EBCDIC & ASCII collating sequences, you'll see what I mean.
Regards, Jack. |
|
Back to top |
|
|
sandip_datta
Active User
Joined: 02 Dec 2003 Posts: 150 Location: Tokyo, Japan
|
|
|
|
Hi Jack,
It may seem to be ridiculas to you but I don't know the possible junk characters in the field.
Regards,
Sandip. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sandip,
Do you know what the valid chars can be?
Regards, Jack. |
|
Back to top |
|
|
sandip_datta
Active User
Joined: 02 Dec 2003 Posts: 150 Location: Tokyo, Japan
|
|
|
|
Hi Jack,
It may be anything A-Z, a-z, 0-9.
Regards,
Sandip. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sandip,
Try this:
Code: |
ENVIRONMENT DIVISION.
SPECIAL NAMES.
ACCEPTABLE IS
'0' THRU '9'
'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M'
'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm'
'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'. |
Use the PROC DIV code I listed in a previous post. The IF stmt will PERFORM the code that will process the field if it ONLY contains the chars listed above. If your testing shows that the list doesn't contain ALL the acceptable chars just expand the list.
Regards, Jack. |
|
Back to top |
|
|
|