Summary -

In this topic, we described about the Separators with detailed example.

  • A separator is single or multiple characters that separate words or character strings.
  • A separator is a string of one or more punctuation characters.

The below table shows the separators list -

Separator Meaning Description & Example
Space Space is always a delimiter except within quotation marks.

For example -
IDENTIFICATION DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR PIC X(20).
PROCEDURE DIVISION.
MOVE "ABC" TO WS-VAR.
ADD 1 TO WS-NUM.
CALL PROGRAM-B.
, Comma Comma, followed by space, is a delimiter to separate two variables.

For example -
MOVE 10            TO WS-VAR1, WS-VAR2.
ADD  10            TO WS-VAR1, WS-VAR2.
SUBTRACT 10       FROM WS-VAR1, WS-VAR2.
. Period Every statement in COBOL program should end with a separator period(.).

For example -
IDENTIFICATION DIVISION.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
01 WS-VAR PIC X(20).
MOVE "ABC" TO WS-VAR.
ADD 1 TO WS-NUM.
CALL PROGRAM-B.
STOP RUN.
; Semicolon Semicolons may separate clauses and operands within clauses.
( Left parenthesis Should appear as balanced pairs of right parentheses.
It uses as separators in reference modification, arithmetic expressions, and conditions.

For example -
MOVE WS-VAR(1:10)            TO WS-VAR1.
COMPUTE WS-A = (WS-A + WS-B) - WS-C.
IF (WS-A > WS-B)	
WHILE (WS-A > 10)
) Right parenthesis Should appear as balanced pairs of left parentheses.
It uses as separators in reference modification, arithmetic expressions, and conditions.

For example -
MOVE WS-VAR(1:10)            TO WS-VAR1.
COMPUTE WS-A = (WS-A + WS-B) - WS-C.
IF (WS-A > WS-B)	
WHILE (WS-A > 10)
: Colon Uses in reference modification and COPY statement with REPLACING.

For example -
MOVE WS-VAR(1:10)            TO WS-VAR1.
COPY COPYBOOK REPLACING ==:WS:== BY ==WS1==.
" Quotation mark They should appear as balanced pairs.
They delimit non-numeric literals, except when the literal is continued more than one line.

For example -
----+----1----+----2----+----3----+----4----+----5
       01 WS-VAR1       PIC X(99) VALUE "THIS THE MULTILINE
- " TEXT DISTRIBUTED ON TWO LINES".
' Apostrophe They should appear as balanced pairs.
They delimit non-numeric literals, except when the literal is continued more than one line.

For example -
----+----1----+----2----+----3----+----4----+----5
       01 WS-VAR1       PIC X(99) VALUE "THIS THE MULTILINE
- " TEXT DISTRIBUTED ON TWO LINES".
== Pseudo-text delimiter It uses to replace the string with COPY statement.

For example -
COPY COPYBOOK REPLACING ==:WS:== BY ==WS1==.

Single space or multiple spaces can use anywhere as a separator.

The separators can use as – Space {b}, Period {.b}, Comma {,b}, Semicolon {;b}, Parentheses { ( } ... { ) }, Colon { : }, Quotation marks {"} ... {"}, Apostrophes {'} ... {'} and Pseudo-text delimiters {b==} ... {==b}. b represents the blank/space.