0% found this document useful (0 votes)
25 views2 pages

CONCATENATE - Combines 2 or More Strings Into One String

This document provides examples of using ABAP string functions including CONCATENATE, SPLIT, SEARCH, and REPLACE. CONCATENATE combines strings, SPLIT splits a string into smaller strings, SEARCH searches for a substring, and REPLACE replaces a substring. Each function sets a return code in the system variable sy-subrc to indicate success or failure.

Uploaded by

nivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

CONCATENATE - Combines 2 or More Strings Into One String

This document provides examples of using ABAP string functions including CONCATENATE, SPLIT, SEARCH, and REPLACE. CONCATENATE combines strings, SPLIT splits a string into smaller strings, SEARCH searches for a substring, and REPLACE replaces a substring. Each function sets a return code in the system variable sy-subrc to indicate success or failure.

Uploaded by

nivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CONCATENATE Combines 2 or more strings into one string.

DATA: s1(10) VALUE 'Hello',


s2(10) VALUE 'ABAP',
s3(10) VALUE 'World',
result1(30),
result2(30).
CONCATENATE s1 s2 s3 INTO result1.
CONCATENATE s1 s2 s3 INTO result2 SEPARATED BY '-'.
WRITE / result1.
WRITE / result2.

Output

If the the concatenated string fits in the result string, then the system variable sy-subrc is set to 0.
If the result has to be truncated then sy-subrc is set to 4.
SPLIT Splits a string into 2 or more smaller strings.
DATA: s1(10), s2(10), s3(10),
source(20) VALUE 'abc-def-ghi'.
SPLIT source AT '-' INTO s1 s2 s3.
WRITE:/ 'S1 - ', s1.
WRITE:/ 'S2 - ', s2.
WRITE:/ 'S3 - ', s3.

Output

If all target fields are long enough and no target fields has to be truncated then sy-subrc is set to
0, else set to 4.
SEARCH Searches for a sub string in main string. If found then sy-subrc is set to 0, else set to
4.
DATA: string(30) VALUE 'SAP ABAP Development',
str(10) VALUE 'ABAP'.

SEARCH string FOR str.


IF sy-subrc = 0.
WRITE:/ 'Found'.
ELSE.
WRITE:/ 'Not found'.
ENDIF.

Output

REPLACE Replaces the sub string with another sub string specified, in the main string. If
replaced successfully then sy-subrc is set to 0, else set to 4.
DATA: string(30) VALUE 'SAP ABAP Development',
str(10) VALUE 'World'.
REPLACE 'Development' WITH str INTO string.
WRITE:/ string.

Output

You might also like