Manipulation a sting in SAP ABAP very common in developing reports, programs, enhancements etc, SAP ABAP supports wide range of string manipulation, below are the list of keywords to manipulate strings.
Keyword/Operation | Usage |
---|---|
CONCATENATE |
Can combine two strings to form a new string
CONCATENATE lv_string1 lv_string INTO lv_string3. |
CONDENSE |
This will delete spaces between characters in a string/character string
CONDENCE lv_string. |
STRLEN |
This is used to find the length of a string
length = STRLEN ( lv_string ). |
REPLACE |
Using this we can replace some value in a string with other
DATA text TYPE string VALUE 'xxababcdcdxx'. REPLACE ALL OCCURRENCES OF 'abcd' IN text WITH ''. |
SEARCH |
can search a string
DATA: text TYPE string VALUE 'Roll over Beethoven'. SEARCH text FOR 'bth' ABBREVIATED. |
SHIFT |
Used to move contents of a string to left or right
DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ', M1(4) VALUE 'ABCD', M2(6) VALUE 'BJJCA '. SHIFT ALPHABET LEFT DELETING LEADING M1. |
SPLIT |
Used to split the contents of a field into two or more fields
DATA : LV_STRING TYPE STRING . "declaration for main string DATA : LV_STRING1 TYPE STRING, "declaration for splitting string into LV_STRING2 TYPE STRING, "declaration for splitting string into LV_STRING3 TYPE STRING, "declaration for splitting string into LV_STRING4 TYPE STRING. "declaration for splitting string into LV_STRING = 'SPLIT ME AT SPACE'. "main string value SPLIT LV_STRING AT ' ' INTO LV_STRING1 LV_STRING2 LV_STRING3 LV_STRING4. "split the main string into specified fields at space WRITE :/ LV_STRING1. "print split fields WRITE :/ LV_STRING2. WRITE :/ LV_STRING3. WRITE :/ LV_STRING4. |
Hi, Team I am a sap sd consultant and willing to learn ABAP programming language.