SAP StackFICOHRMMSDPMPSABAPNetWeaverTablesTcodes ☰MENU

CONDENSE in ABAP for remove spaces in strings

CONDENSE statement in ABAP is used for removing leading and closing blank completely and convert sequence of blanks into a single blank for a string.

Syntax:

CONDENSE text [NO-GAPS].

The addition NO-GAPS is used for removing the entire blank spaces.

After the CONDENSE statement execution the strings appears as left justified sequence of words. You will get clearer picture after seeing the following sample programs.

 

DATA: STRING TYPE C VALUE ‘ This is    CONDENSE         EFFECT    ’.

CONDENSE STRING.

WRITE: STRING,’*’.

 

Its output will be

This is CONDENSE EFFECT*

(You can watch that all the leading and trailing spaces are removed, and consecutive blank spaces are converted into a single space)

 

See another scenario for a fixed length string.

DATA: STRING(40) TYPE C VALUE ‘ This is    CONDENSE         EFFECT    ’.

CONDENSE STRING.

WRITE: STRING,’*’.

 

Its output will be

This is CONDENSE EFFECT                *

 

(You can watch that all the spaces created by the CONDESNE statement have been added at the end of string to preserve the string with specified fixed length.

 

 

See another scenario with NO-GAPS addition.

DATA: STRING TYPE C VALUE ‘ This is    CONDENSE         EFFECT    ’.

CONDENSE STRING NO-GAPS..

WRITE: STRING,’*’.

 

Its output will be

ThisisCONDENSEEFFECT*

 

(You can watch that all the spaces are removed in the string.)

 

See another scenario with NO-GAPS addition for fixed length string.

DATA: STRING(40) TYPE C VALUE ‘ This is    CONDENSE         EFFECT    ’.

CONDENSE STRING NO-GAPS..

WRITE: STRING,’*’.

 

Its output will be

ThisisCONDENSEEFFECT                   *

 

(You can watch that all the blank spaces are removed and preserving the same fixed length by adding additional spaces at the end of string)

Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes

SAP ALECRMSCMSRMSAP Solutions SAP ReferencesSAP BasicsPP ModuleWMSAP Partners
HomeContact & Privacy PolicyTwitter
All of the product names here are trademarks of their respective companies. The site sapstack.com is not affiliated with SAP AG.
©2024 sapstack.com