TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - Relation Condition


A general relation condition compares two operands, either of which can be an identifier, literal, arithmetic expression, or index-name.

Syntax:

image missing


Where,
operand-1 and operand-1 - The subject of the relation condition. Can be an identifier, literal,function-identifier, arithmetic expression, or index-name.

Relational operatorCan be writtenMeaning
IS GREATER THANIS >Greater than
IS NOT GREATER THANIS NOT >Not greater than
IS LESS THANIS <Less than
IS NOT LESS THANIS NOT < Not less than
IS EQUAL TOIS =Equal to
IS NOT EQUAL TOIS NOT =Not equal to
IS GREATER THAN OR EQUAL TOIS >=Is greater than or equal to
IS LESS THAN OR EQUAL TOIS <Is less than or equal to

Example: 1

IDENTIFICATION DIVISION.
PROGRAM-ID. COBRELAC.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(9).
01 B PIC 9(9).

PROCEDURE DIVISION.
A000-FIRST-PARA.
    MOVE 15 TO A.
    MOVE 20 TO B.

    IF A IS GREATER THAN OR EQUAL TO B THEN
      DISPLAY 'A IS GREATER THAN B'
    ELSE
      DISPLAY 'A IS LESS THAN B'
    END-IF.

    STOP RUN.

When you compile and execute the above program, it produces the following result −

Output :

A IS LESS THAN B

If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal