Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the number of characters filled in a variable????????

Former Member
0 Kudos

Hi,

Suppose i declared a variable

test(20) type c.

test = '123'.

Now if you see out of 20 characters number of charecters filled in is 3. Or is there any way to find out string length???

1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
0 Kudos

data : w_len type i.

w_len = strlen( w_field ).

to have the lenght of the content of w_field.

5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos

data : w_len type i.

w_len = strlen( w_field ).

to have the lenght of the content of w_field.

Former Member
0 Kudos

Hi,

Use STrlen statement to get the length

Or fm SWA_STRINGLENGTH_GET

Import parameters Value

EXPRESSION 1666

CONDENSE_NO_GAPS

CONDENSE

WITH_LEADING_BLANKS

Export parameters Value

LENGTH 004

EX_MODIFY_EXPRESSION 1666

regards

Shiva

Former Member
0 Kudos

USE STRLEN COMMAND.

DATA : TEST(20).

DATA : V TYPE I.

TEST = '123'.

V = STRLEN( TEST ).

WRITE 😕 V.

former_member188829
Active Contributor
0 Kudos

Hi,

DATA:CHAR(20) TYPE C.

CHAR = '123'.

DATA:LEN TYPE I.

LEN = STRLEN( CHAR ).

WRITE:LEN.

Output will be 3.

Former Member
0 Kudos

Use: STRLEN(variable). to get the number of characters currently contained in the variable.