OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
- Registered Member
- Posts: 50
- Joined: Thu Jun 27, 2013 6:17 pm
If I have a COBOL declaration like this:
Code: Select all
01 WS-A PIC X(20) VALUES SPACES.
01 WS-B REDEFINES WS-A PIC 9(10).
and I do a numeric check on the WS- like this:
Will WS-B be considered as numeric value or not?
Is it a good coding practice?
- Global Moderator
- Posts: 1379
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
It is very bad practice to do things like your code. REDEFINES variables should be the same length as the REDEFINED variable; it is common for REDEFINES to change PIC X to PIC 9 (or vice versa).
WS-B will be considered numeric (although if you put a period or many other punctuation marks into WS-A, WS-B would not be numeric) since spaces have zero for the second half of each byte.