View previous topic :: View next topic
|
Author |
Message |
samanthjain
New User
Joined: 25 Jul 2008 Posts: 17 Location: Mumbai
|
|
|
|
Posted: Wed Dec 10, 2008 8:32 am Post subject: how to test whether the field is ALPHANUMERIC or not ?
--------------------------------------------------------------------------------
Hi,
Can anyone pls tell me how to check whether a field defined as X(10) is ALPHANUMERIC or not in COBOL ?
Suppose this field has some special charecters like dot (.) or any other special charecters that are invalid. . .
Similar to Is Numeric and Alphabetic, do we have an for ALPHANUMERIC ?
Please help me out on this.
Thanks in Advance. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Do not double-post the same question in multiple parts of the forum. The duplicate has been deleted.
Every pic x(n) field is alphanumeric. The "dot" is what you see for unprintable characters - they are usually not all the same hex value. . .
You need to decide which characters are "good" and which are not and write your code accordingly. There s nothing automatic. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You can set up a test for whatever characters you don't want by using reference modification or other COBOL facilities; however, since alphanumeric characters include the entire collating sequence you can't test for ALPHANUMERIC in COBOL directly. |
|
Back to top |
|
|
samanthjain
New User
Joined: 25 Jul 2008 Posts: 17 Location: Mumbai
|
|
|
|
What actually i need is. . .
i have a file of 1000s of records and in that file i need to select only those records based on the invalid value in one ALPHANUMERIC field.
This X field is showing '0' whenHEX ON. . .which is invalid in my case. . .
Its just one example. . .i think there might be more of these kinds. . .
all i need to do is to seperate this. . .i just want the fields with spaces or numeric or alphabetic or both. . .
how can i do this ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The first thing you need to do is formailze the rules. What you have posted is too loose. What about lower-case letters? What about quote or comma or dollar-sign?
Once you define the rules, then you can write code to keep/discard the values however you want. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What you might consider is to set up one byte in working-storage and create an 88 level with either all of the "good" values or all of the "bad" values. Using reference modification, you could verify whether each byte of the problem record/field was valid or not. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Samanth Jain,
Take a look at the CLASS clause of the SPECIAL-NAMES pgraph in the COBOL Reference Manual. I think that's what you're looking for.
See the top of this page and click on"manuals". |
|
Back to top |
|
|
|