SET Statement


The SET statement is used to perform the below operations -

  • Initializing the table indexes.
  • Increasing or decreasing table indexes.
  • Setting the condition name to true or false.

Initializing the table indexes


SET statement is used to initialize the table index.

Syntax -

SET index-name    TO initial-value

Example -

SET WS-INDEX      TO 1

Parameters -

  • index-name - Specifies the table index. From the example, it is WS-INDEX.
  • initial-value - The value assigned to the index. From the example, it is 1.

Increasing or decreasing table indexes -


SET statement is also used to increase the index (UP BY) or decrease the index (DOWN BY).

Syntax -

SET index-name    UP BY   increment-value

SET index-name    DOWN BY decrement-value

Example -

SET WS-INDEX    UP BY 1

Parameters -

  • increment-value - The increasing value from the current index value. From example, it is 1.
  • decrement-value - The decreasing value from the current index value.

Setting the condition name to true or false -


SET statement is also used to set the condition name that initializes the condition variable. When the SET statement is executed, the condition name value is placed in its condition variable.

Syntax -

SET condition-name    TO TRUE|FALSE

Example -

WORKING-STORAGE SECTION.
01 WS-GENDER        PIC X(01).
   88 WS-MALE       VALUE 'M'.
   88 WS-FENAME     VALUE 'F'.
...
PROCEDURE DIVISION.
    SET WS-MALE    TO TRUE.
	...

Parameters -

  • condition-name - Specifies the condition name. From example, it is WS-MALE, WS-FEMALE.