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
- PICTURE character strings
User-defined DBCS character-strings used to form the below items -
- Literals [Not Covered]
- Comment [Not Covered]
Below list shows the examples for each character-string -
|COBOL User-defined Words||
WS-VAR VAR PARA-ADD PARA-SUBTRACT
MOVE IF PERFORM
"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.