Application Development and Automation 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: 
Read only

getting the char length

Former Member
0 Likes
20,091

Hello all!!

I´m working with type C, and I wonder how can I get, in my program, the length of a variable or a parameter declarated like this:

PARAMETER: chain(10).

I know that its lenght is 10 (max) but I would like to know if there is a way in ABAP to get it dynamically, I mean, in the program.

Thank you very much.

Reyes.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,354

use describe statement as follows.

data: n type i.

describe field chain length n.

if you want exact length of the content in chain.

then use strlen().

regds,

kiran

Hello all!!

I´m working with type C, and I wonder how can I get, in my program, the length of a variable or a parameter declarated like this:

PARAMETER: chain(10).

I know that its lenght is 10 (max) but I would like to know if there is a way in ABAP to get it dynamically, I mean, in the program.

Thank you very much.

Reyes.

4 REPLIES 4
Read only

Former Member
0 Likes
7,355

use describe statement as follows.

data: n type i.

describe field chain length n.

if you want exact length of the content in chain.

then use strlen().

regds,

kiran

Read only

Former Member
0 Likes
7,354

USE <b>STRLEN</b> OPTION

DATA: CHAIN(10) TYPE C VALUE 'ABCDEFGHIJ'.

DATA : LEN TYPE I.

LEN = STRLEN( CHAIN ).

WRITE:/ 'length of chain is', LEN.

regards,

vijay

Read only

Former Member
0 Likes
7,354

Hi Reyes,

check this option:

data len type i.
     i = STRLEN( chain ).

hope this helps,

Sajan Joseph.

Read only

Former Member
0 Likes
7,354

say ur field has 'ABAP'.

now, V1 = strlen( chain ).

so, V1 returns 4.