I have a PIC X(5) field which can have the following values -

1. 12345

2. -12.3

3. A1234

4. Spaces

Out of these 4, the vallid values are - 12345 & -12.3 only. I am trying to find out a way using which I can ascertain that. I tried using IS NUMERIC but, that doesn't consider -12.3 a numeric digit. Another option which I was toying around with was to redefine the PIC X(5) Field as

05 WS-X PIC X(5).

05 WS-X1 REDEFINES WS-X.

06 WS-X1C PIC X OCCURS 5 TIMES.

05 WS-X1 REDEFINES WS-X.

06 WS-X1C PIC X OCCURS 5 TIMES.

& then, checking the redefined field as shown below -

PERFORM VARYING WS-9 FROM 0 BY 1

UNTIL WS-9 = 5

IF WS-X1C(WS-9) = '1' OR

WS-X1C(WS-9) = '-' OR

WS-X1C(WS-9) = '.'

---Check for all the Numerals---

DISPLAY WS-X1C(WS-9)

END-IF

END-PERFORM

UNTIL WS-9 = 5

IF WS-X1C(WS-9) = '1' OR

WS-X1C(WS-9) = '-' OR

WS-X1C(WS-9) = '.'

---Check for all the Numerals---

DISPLAY WS-X1C(WS-9)

END-IF

END-PERFORM

This seems to be working fine but, I am concerned if this is the right way of doing this. Can someone please advise me on this or if there is a better way of doing this.