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.
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.
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.
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
sir, extreemely thankful for your post. gives a lot of help. great work .keep it up.
Thx sir !! this is very helpful !! please update your blog !!
good 1….keep it up
Now that is some excellent writing.
Very helpful. thanks
when there are multiple occurences in a single string of a any word and all of them are to be replaced the syntax is
Replace all occurrences of ‘Development’ in string with str.
So, cool.~
very useful
very useful
thanks da chellam !!!!
Explained nicely
how to count the number of charecters in the string without using “strlen” .
hi sir ..
im new to programming …can u plz explain me about sub str..