SAP ABAP BASIC STRING OPERATIONS

*&---------------------------------------------------------------------*
*& Report  ZSTA_STRING_OPERATIONS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZSAN_STRING_OPERATIONS.

data:g_f_value1 type char10 value 'Sankarganesh',
     g_f_value2 type char10 value 'Thirumalaisamy',
     g_f_value3 type char50,
     g_f_value4 type char40 VALUE 'this is small    example',
     g_f_str1 type char10,
     g_f_str2 type char10,
     g_f_str3 type char10,
     g_f_str4 type char10,
     g_f_value5 type char10 VALUE '000000012'.


START-OF-SELECTION.

* Concatenate operation
CONCATENATE g_f_value1 g_f_value2 into g_f_value3 SEPARATED BY space.

write:g_f_value3.


* condense operation
write:/.
write:'before condense operation'.
write:/.
WRITE:g_f_value4.
write:/.

condense g_f_value4.
write:'After condense operation'.
write:/.
write: g_f_value4.

* split operation

split g_f_value4 at space into :g_f_str1 g_f_str2 g_f_str3 g_f_str4.

write:/.
write:g_f_str1.
write:/.
write:g_f_str2.
write:/.
write:g_f_str3.
write:/.
write:g_f_str4.

* Translate operation

TRANSLATE g_f_value4 to UPPER CASE.
write:/.
write:g_f_value4.


* Replace operation
replace 'Sankarganesh' with 'Thirumalaisamy' into g_f_value3.
write:/.
write:g_f_value3.

* Search operation
SEARCH g_f_value1 for 's'.
write:/.
write:sy-fdpos.

* Shift operation
write:/.
write:g_f_value5.
write:/.
shift g_f_value5 LEFT DELETING LEADING '0'.

write: g_f_value5.

0 comments: