Popular

IS NUMERIC clause IN COBOL IS NUMERIC CLAUSE

IS NUMERIC is used to check if the data is numeric or not.


IS NUMERIC clause IN COBOL EXAMPLE


01 WS-TEXT PIC X(05).
MOVE '15623' TO WS-TEXT.
IF WS-TEXT IS
NUMERIC DISPLAY 'NUMBER'
ELSE
DISPLAY 'TEXTUAL CHARACTERS’
END-IF.

Output:
NUMBER
MOVE 'HE123' TO WS-TEXT

IF WS-TEXT IS NUMERIC DISPLAY 'NUMBER'
ELSE
DISPLAY 'TEXTUAL CHARACTERS’
END-IF.



Output:
TEXTUAL CHARACTERS

5 comments:

  1. Y si el numero llega con espacion cual seria el resultado "8421 243"

    ReplyDelete
  2. Good info .

    For real time scenario based Mainframe interview questions with good explanation,please refer
    www.MAINFRAMEINTERVIEW.com

    ReplyDelete
  3. What will happen if the value in WS-TEXT is shorter than the length of the variable ? The result of IS NUMERIC is TRUE or FALSE ?

    For example :

    01 WS-TEXT PIC X(10).
    MOVE '1562 ' TO WS-TEXT.

    ReplyDelete
    Replies
    1. In cobol, moves are controlled by the size and type of the receiving field. Therefore, the resulting value will be "1562 ": not numeric.

      Delete