String Command In Abap

The following are some the STRING command you can used in your ABAP program.

SPLIT

This function is used to split the given string value based an any separator and save in separate string variables.

eg. code:

DATA STR(30) VALUE 'SAP IS AN ERP'.

DATA: S1(5), S2(5), S3(5), S4(5).

SPLIT STR AT ' ' INTO S1 S2 S3 S4.

WRITE :/ S1, / S2, / S3, / S4.
 

SEARCH

This string function is used to search for the specified value in a given string.

eg. code:
DATA STR(30) VALUE 'SAP IS AN ERP'.

DATA S1(3) VALUE 'AN'.

SEARCH STR FOR S1.

WRITE :/ SY-FDPOS.

sy-fdpos  - is the system variable used to hold the position of an alphabet in the string.
 

CONCATENATE

This string function is used to add the different character type variables into one string.

eg. code:

DATA STR(30).

DATA: S1(5) VALUE 'You Are', S2(5) VALUE 'IS', S3(5) VALUE 'GREAT'.

CONCATENATE S1 S2 S3 INTO STR SEPARATED BY ' '. WRITE :/ STR.
 

SHIFT

This string function is used to move the string to the specified position (LEFT, RIGHT, CIRCULAR) based on the number of places specified.

eg. code:

DATA STR(20) VALUE 'ABAP IS IN SAP'.

SHIFT STR BY 5 PLACES.

WRITE STR COLOR 5.

DATA STR(20) VALUE 'ABAP IS IN SAP'.

SHIFT STR RIGHT BY 5 PLACES.

WRITE STR COLOR 5.

DATA STR(20) VALUE 'ABAP IS IN SAP'.

SHIFT STR CIRCULAR BY 5 PLACES.

WRITE STR COLOR 5.
 

TRANSLATE

This string function is used to change the case of the given string value.

eg. code:

DATA STR(10) VALUE 'CHENNAI'.

TRANSLATE STR TO LOWER CASE. WRITE STR.

CONDENSE

This string function is used to remove the blank spaces in the given string.

eg. code:

data str(30) value 'You Are GREAT'.

CONDENSE STR.

WRITE STR.
 

REPLACE

This string function is used to replace the given string with specified string value.

eg. code:

data str(30) value 'INDIA IS GREAT'.

DATA S1(10) VALUE 'WRITE'.

REPLACE 'IS' IN STR WITH S1. WRITE STR.
 

STRLEN

This string function is used to identify the length of the given string.

Eg. code:

data str(30) value 'You Are GREAT'.

data len type i.

len = STRLEN( STR ).

write len.

ABAP Tips

Read Also
Mass Idoc Change Corrections

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.