Beruflich Dokumente
Kultur Dokumente
sign
ceil
floor
trunc
FRAC
WRITE t1.
Result:
100
Two conversions are performed. First, the contents of field t2 (type c) are converted to type p. Then
the system processes the abs function using the results of the conversion. Then, during the
assignment to the type c field t1, the result of the function is converted back to type c.
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.
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
CONDENSE c [NO-GAPS].
This statement removes any leading blanks in the field c and replaces other sequences of blanks by
exactly one blank. The result is a left-justified sequence of words, each separated by one blank. If
the addition NO-GAPS is specified, all blanks are removed.
TRANSLATE text TO UPPER CASE.
Converts the characters "A" to "B", "a" to "b", and vice versa. text contains "Abracadabra" after the
conversion.
DATA text TYPE string.
text = `Barbcbdbarb`.
TRANSLATE text USING 'ABBAabba'.
pattern. pattern contains letter pairs where the first letter of each pair is replaced by the
second. pattern can be a variable.
For more variants of the TRANSLATE statement with more complex substitution rules (obsolete
variants!), refer to the keyword documentation.
Shifts the field content on a cyclical basis: shifts content npositions to the left and shifts the n
characters on the left to the right.
abcdefghij',
string = t.
WRITE string.
SHIFT string LEFT DELETING LEADING SPACE.
WRITE / string.
string = t.
SHIFT string RIGHT DELETING TRAILING str.
WRITE / string.
Output:
abcdefghij
abcdefghij
abcdef