STRING command is used to concatenate one or more strings.
Syntax:
STRING identifier-1 / literal-1, identifier-2/ literal-2
DELIMITED BY (identifier-3/literal-3/SIZE)
INTO identifier-4
END-STRING.
01 VAR1 PIC X(10) VALUE ‘MUTHU ‘
01 VAR2 PIC X(10) VALUE ‘SARA ‘
01 VAR2 PIC X(20).
To get display ‘MUTHU,SARA’
STRING VAR1 DELIMITED BY ‘ ‘
‘,’ DELIMITED BY SIZE
VAR2 DELIMITED BY ‘ ‘
INTO VAR3
END-STRING.
The receiving field must be an elementary data item with no editing symbols and JUST RIGHT clause.
With STRING statement, specific characters of a string can be replaced whereas MOVE replaces the full string.
01 AGE-OUT PIC X(12) VALUE ’12 YEARS OLD’.
STRING ‘18’ DELIMITED BY SIZE INTO AGE-OUT. => 18 YEARS OLD.
Reference Modification – equivalent of SUBSTR
‘Reference modification’ is used to retrieve or overwrite a sub-string of a string. ‘:’ is known as reference modification operator.
Syntax: String(Starting-Position:Length)
MOVE ‘18’ TO AGE-OUT(1:2) does the same as what we did with STRING command.
When it is used in array elements, the syntax is
Array-element (occurrence) (Starting-Position:Length)
No comments:
Post a Comment