Substring in ABAP
* This function is used to split the string into sub strings.
Code
REPORT zab_rp_substring.
DATA: str1 TYPE string VALUE 'abcdefghi',
str2 TYPE string.
str2 = substring( val = str1 off = 2 len = 3 ).
WRITE: / 'substring: ', str2 COLOR 1. " cde
str2 = substring_from( val = str1 sub = 'd' ).
WRITE: / 'substring from: ', str2 COLOR 2. " defghi
str2 = substring_after( val = str1 sub = 'd' ).
WRITE: / 'substring after: ', str2 COLOR 3. " efghi
str2 = substring_before( val = str1 sub = 'd' ).
WRITE: / 'substring before: ', str2 COLOR 4. " abc
str2 = substring_to( val = str1 sub = 'd' ).
WRITE: / 'substring to: ', str2 COLOR 5. " abcd
Output
*****************Thank You****************
Comments
Post a Comment