Summary -

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

A separator is a character or a string of contiguous characters that separates 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 in pseudo-text delimiter and within quotation marks.
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.
, 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 left and 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 and 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)
: 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 (i.e., distributed on more than one line).
For example - 01 WS-VAR1 PIC X(99) VALUE "THIS THE MULTILINE TEXT THAT
- "WAS DISTRIBUTED ON TWO LINES".
' Apostrophe They should appear as balanced pairs. They delimit non-numeric literals, except when the literal is continued (i.e., distributed on more than one line).
For example - 01 WS-VAR1 PIC X(99) VALUE 'THIS THE MULTILINE TEXT THAT
- 'WAS DISTRIBUTED ON TWO LINES'.
== Pseudo-text delimiter It uses with COPY statement REPLACING.
For example - COPY COPYBOOK REPLACING ==:WS:== BY ==WS1==.

Space can be used anywhere as a separator or more than one space as part of a separator.
The separators can be used like – Space {b}, Period {.b}, Comma {,b}, Semicolon {;b}, Parentheses { ( } ... { ) }, Colon { : }, Quotation marks {"} ... {"}, Apostrophes {'} ... {'} and Pseudo-text delimiters {b==} ... {==b}. b represents the blank/space.