Summary -

In this topic, we have explained Character Strings with detailed examples.

Character-string is a single character or set of adjacent characters that can form a COBOL word, literal, a PICTURE character-string, or a comment. A character-string is delimited by separators.

Single-byte character-strings used to form the below items -

  • COBOL words with DBCS character [Not Covered]
  • COBOL words
  • Literals
  • PICTURE character strings
  • Comment

User-defined DBCS character-strings used to form the below items -

  • Literals [Not Covered]
  • Comment [Not Covered]

Example -

Below list shows the examples for each character-string -

Type Some Examples
COBOL User-defined Words
WS-VAR
VAR
PARA-ADD
PARA-SUBTRACT
Keywords/Reserved Words
MOVE
IF
PERFORM
Literals
"HELLO WORLD"
"123"
123
9
PICTURE Character String
PIC A(20).
PICTURE A(20).
PIC 9(10).
PIC X(25).
Comment * This is a comment in COBOL program.
Note! The astrik (*) should be coded in the column 7 to make it as comment.

Practical Example -

Below screenshot describes how the different types of words formed using character sets in COBOL programming.

Character String Code example