Posts

Showing posts from November, 2018

ABAP predefined length functions STRLEN and NUMOFCHAR

 Many a time when traversing a text, you would want to know the actual length of the text. in today's predefined function series post, I wanted to welcome you with ABAP length predefined functions: strlen , numofchar . While strlen is pretty well-known, numofchar is relatively unknown so I thought we should take a look at its feature and usage as well. Let's dive right in. STRLEN : Syntax : STRLEN ( arg ). Features :  It returns the number of characters in arg.  If the data object is of fixed length then trailing blanks are ignored.  If the data object is of type string, then trailing blanks are also counted. Example : NUMOFCHAR : Syntax : NUMOFCHAR ( arg ). Features :  It returns the number of characters in arg.  Trailing blanks are ignored regardless of the data object type. Example: As you would have noticed from the examples,  numofchar always ignores the trailing blanks whereas strlen behaves differently according to the data