STRING statement strings together the partial or complete contents of two or more data items or literals into one single data item. STRING needs at least two identifiers or literals. It can only concatenate alphabetic and alpha-numeric items. It will remove multiple instances of delimiter character and consider multiple spaces as a single space. END-STRING, DELIMITED BY, WITH POINTER, ON OVERFLOW and NOT ON OVERFLOW clause is optional in STRING usage.
STING {Variable-1} [DELIMITED BY SIZE/SPACE/specified delimiter] {Variable-2} [DELIMITED BY SIZE/SPACE/ specified delimiter] …….. …….. INTO identifier [WITH POINTER ws-pointer] [ON OVERFLOW imperative-statements-1] [NOT ON OVERFLOW imperative-statements-2] [END-STRING.]
DELIMITED BY phrase: Sets the limits of the string & its optional.
INTO phrase: Identifies the receiving field.
POINTER phrase: Points to a character position in the receiving field. The pointer field indicates a relative alphanumeric character position, DBCS character position, or national character position when the receiving field is of usage DISPLAY, DISPLAY-1, or NATIONAL, respectively.
ON OVERFLOW phrases: ON OVERFLOW is used to execute a set of imperative statements when overflow occurs during STRING concatenation. This will be triggered when the size of the concatenated strings is greater than the receiving field.
NOT ON OVERFLOW phrases: NOT ON OVERFLOW is used to execute the set of imperative statements when the STRING concatenation is successful. NOT ON OVERFLOW is fully reverse to ON OVERFLOW functionality.
END-STRING phrase: This explicit scope terminator serves to delimit the scope of the STRING statement. END-STRING permits a conditional STRING statement to be nested in another conditional statement. END-STRING can also be used with an imperative STRING statement.
STRING FIRST-NAME DELIMITED BY SPACE ' ' DELIMITED BY SIZE LAST-NAME DELIMITED BY SPACE ' ' DELIMITED BY SIZE INITIAL DELIMITED BY SPACE INTO NAME-OUT ON OVERFLOW DISPLAY “ERROR FOUND” NOT ON OVERFLOW DISPLAY “SUCCESSFUL” END-STRING.
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-IN.
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.bSMITHbbbbb 444bSPRINGbST.,bCHICAGO,bILL.bbbbb A14275 $4,736.85 $2,400.00 09/22/76 $2,336.85 10/22/76
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 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:
00001 J.B. SMITH 444 SPRING ST., CHICAGO, ILL. A14725 10/22/76 $2,336
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…