Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATA VALIDATION

Status
Not open for further replies.

jps111s

Programmer
Feb 19, 2001
6
0
0
US
i have a program with field that is to be validated numeric. If it is not numeric we are suposed to display the field with the error and a message. I have it defined as numeric because it is used to calculate something. The Data set I have to use contains letters in it. When i run the program I get 'illegal character in numeric field error'. How can i define this so this doesn't happen? If u could help i would really apreciate it.
 
Hi JPS,

You can define each field that needs that kind of interrogation as pic x then redefine it as pic 9. This is a good habit to get into if you are unsure of the contents of a field. If you know the field has been edited, then it's not required.

Code:
       05  fld-a             pic  x(005).
       05  fld-a-red         redefines
           fld-a             pic  9(003)v99.



       if fld-a is not numeric 
          display '>' fld-a '<' ' is not numeric'
       end-if

Hope this helps, Jack.
 
Hi,

I prefer to test the numeric field with its numeric definition.

The method above can give different results when there are other numeric definitions, especialy if you use signs the conclusion can be wrong.

Regards,

Crox
 
Hi Crox,

I know you're right when using the current mainframe based COBOL compilers, but I wasn't sure if the PC based compilers used it.

Jack
 
Hi Jack,

It is fun to test it out with some demo programs. You will see with CA-REALIA for example that there is not so much difference between mainframe and pc, even when there are different charactersets used.

Also fun is to test how fast statements are and how they can behave different depending on how you are using it. For example replacing one byte by an other, you better use some subscript construction. If you translate more than 32 of them, the converting option of the inspect is faster with CA-REALIA.

There are lots of 'quirks' to know and it is nice to hear about them.

Regards,

Crox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top