Below is my program. I am trying to determine if the value user keyed in is NUMERIC or not. BALANCE-INPUT that accepts user input is defined as type VARCHAR. Irrespective of the type of input I key in, same result "INVALID BALANCE. SHOULD BE NUMERIC VALUE".
IDENTIFICATION DIVISION.
*--------------------
PROGRAM-ID. INTCHECK.
*--------------------
ENVIRONMENT DIVISION.
*--------------------
DATA DIVISION.
*-------------
WORKING-STORAGE SECTION.
*-----------------------
01 ACCEPT-INPUT.
02 BALANCE-INPUT PIC X(10).
02 AMOUNT-INPUT PIC S9(5)V99 USAGE IS COMP-3.
PROCEDURE DIVISION.
*------------------
BEGIN.
DISPLAY 'ENTER AMOUNT TO DEPOSIT'
ACCEPT BALANCE-INPUT
STRING BALANCE-INPUT DELIMITED BY SPACES INTO BALANCE-INPUT
IF BALANCE-INPUT IS NUMERIC
COMPUTE AMOUNT-INPUT = FUNCTION NUMVAL(BALANCE-INPUT)
DISPLAY 'IS NUMERIC'
DISPLAY AMOUNT-INPUT
ELSE
DISPLAY 'INVALID BALANCE. SHOULD BE NUMERIC VALUE'
DISPLAY BALANCE-INPUT
END-IF.
GOBACK.
*--------------------
PROGRAM-ID. INTCHECK.
*--------------------
ENVIRONMENT DIVISION.
*--------------------
DATA DIVISION.
*-------------
WORKING-STORAGE SECTION.
*-----------------------
01 ACCEPT-INPUT.
02 BALANCE-INPUT PIC X(10).
02 AMOUNT-INPUT PIC S9(5)V99 USAGE IS COMP-3.
PROCEDURE DIVISION.
*------------------
BEGIN.
DISPLAY 'ENTER AMOUNT TO DEPOSIT'
ACCEPT BALANCE-INPUT
STRING BALANCE-INPUT DELIMITED BY SPACES INTO BALANCE-INPUT
IF BALANCE-INPUT IS NUMERIC
COMPUTE AMOUNT-INPUT = FUNCTION NUMVAL(BALANCE-INPUT)
DISPLAY 'IS NUMERIC'
DISPLAY AMOUNT-INPUT
ELSE
DISPLAY 'INVALID BALANCE. SHOULD BE NUMERIC VALUE'
DISPLAY BALANCE-INPUT
END-IF.
GOBACK.