The following example illustrates some of the considerations that apply to the STRING statement.
In the Data Division, the programmer has defined the following fields:
01 RPT-LINE PICTURE X(120). 01 LINE-POS PICTURE 99. 01 LINE-NO PICTURE 9(5) VALUE 1. 01 DEC-POINT PICTURE X VALUE ".".
In the File Section, he or she has defined the following input record:
01 RCD-01.
05 CUST-INFO.
10 CUST-NAME PICTURE X(15).
10 CUST-ADDR PICTURE X(34).
05 BILL-INFO.
10 INV-NO PICTURE X(6).
10 INV-AMT PICTURE $$,$$$.99.
10 AMT-PAID PICTURE $$,$$$.99.
10 DATE-PAID PICTURE X(8).
10 BAL-DUE PICTURE $$,$$$.99.
10 DATE-DUE PICTURE X(8).
The programmer wants to construct an output line consisting of portions of the information from RCD-01. The line is to consist of a line number, customer name and address, invoice number, date due, and balance due, truncated to the dollar figure shown.
The record as read in contains the following information:
J.B. SMITH
444 SPRING ST., CHICAGO, ILL.
A14275
$4,736.85
$2,400.00
09/22/76
$2,336.85
09/09/94
In the Procedure Division, the programmer initializes RPT-LINE to SPACES and sets LINE-POS (which is to be used as the pointer field) to 4. Then he issues this STRING statement:
STRING LINE-NO SPACE CUST-INFO SPACE INV-NO SPACE DATE-DUE SPACE DELIMITED BY SIZE, BAL-DUE DELIMITED BY DEC-POINT INTO RPT-LINE WITH POINTER LINE-POS.
When the statement is executed, the following actions take place:
After the STRING statement has been executed:
Figure 24. STRING Statement Example Output Data

(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.