How active We are?

October 2014
M T W T F S S
« Apr    
 12345
6789101112
13141516171819
20212223242526
2728293031  


String Length in ABAP (STRLEN)

GD Star Rating
loading...


Keyword STRLEN

You can use key word STRLEN to find the length of strings or character type data objects. The result of this keyword is an integer.

Syntax:

<vLength> = STRLEN( <vCharacterSequence> ).

where, <vCharacterSequence> is the string or character type variable whose length needs to be determined and vLength is the integer variable to holds the calculated length.

For flexible length character data objects which are of data type STRING, the keyword returns the exact length of string.

e.g.

DATA: lvWord1  TYPE string,

lvLength TYPE i.

lvWord1 = ‘RAM’.

lvLength = STRLEN( lvWord1 ).              ”value of lvLength would be 3

lvWord1 = ‘RAMDIN’.

lvLength = STRLEN( lvWord1 ).              ”value of lvLength would be 6

For fixed length character data objects which are defined using data type C, the keyword returns the occupied length of data object i.e. up to its last non-space character.

e.g.

DATA: lvWord1(10)  TYPE c,

lvWord2(20)  TYPE c,

lvLength TYPE i.

lvWord1 = ‘RAM SAY   ‘.

lvLength = STRLEN( lvWord1 ).              ”value of lvLength would be 7

lvWord2 = ‘RAM SAY BROTHERS    ’.

lvLength = STRLEN( lvWord1 ).              ”value of lvLength would be 16

Keyword STRLEN can also be used to find length of raw strings as well which are defined using data type XSTRING.

GD Star Rating
loading...
GD Star Rating
loading...
String Length in ABAP (STRLEN), 9.0 out of 10 based on 2 ratings

Leave a Reply