Thanks to all.
Below is the explaination abt this requirement:
I need to read a value in to a Working storage variable from an input file. How do I check whether the value(say "FRANCE") in the variable is made up of ASCII charcaters?
I think some real thought needs to be given to this requirement. For example, you have a variable that has one character in it; that character's hexadecimal value is 4E (78 decimal). In EBCDIC that is a plus sign but in ASCII it is an upper case N. Which way you refer to it depends on how you want to use it -- there is absolutely no inherent meaning to the character.
So in general, you cannot tell automatically if a given variable has EBCDIC or ASCII data in it since each character represents BOTH an ASCII value as well as an EBCDIC value. If I see a batch of hex '40' values in the variable I'm going to suspect EBCDIC whereas a batch of hex '20' values means I'm going to be thinking ASCII -- but I've seen cases where both of those assumptions are wrong.
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
How do we check whether a string contains all ASCII characters in a COBOL program?
If you are reading from an "input file", it is more than 99% likely that you are reading ebcdic characters.
The most common way i've seen ascii characters in a file read on the mainframe is when someone made a mistake transferring the file to the mainframe. They sent the file in binary causing the resulting data to still be in ascii. Whenever this happened, the file transfer is correct so that the resulting data is ebcdic on the mainframe.