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 count number of characters in a string?

Former Member
0 Kudos

Hi

I need to display values in a script. but the alignment getting distrubed if it is less than 20 charaters, for exmple material descirption is only displaying 20 characters in script. if it is less than 20 charcters the alignment getting changed.

please help me ...urgent..

thanks in advance...

5 REPLIES 5

Former Member
0 Kudos

hi Sapein,

use FM

STRING_LENGTH

to calculate the length .

you can even use this logic

LENGTH = STRLEN( STRING ).

regards,

Santosh

Former Member
0 Kudos

Hi,

You can count the no of characters using STRLEN(field name).

regards,

madhu

former_member186143
Active Contributor
0 Kudos

why not set the output in ALV. not much extra work and looks better than write statement and never have to worry about alignment problems anymore

otherwise look at help on function FIND match LENGTH len

Message was edited by:

A. de Smidt

0 Kudos

Use STRLEN command.

Former Member
0 Kudos

solution to this problem in script is not to count the characters but to align them based on positions .

1.

Use the tab positions for that paragraph format to display the values in a finite format .

In this u need to give the position start and position end length and use the same in the script as

p ,,&itab-f1&

say my value has to print from position 125mm to 155 mm

i take one tab position for this paragraph format P and maintain the same in the output.

here ,, is the tab position .

See whether it is one character or 20 character it has to behave the same way it should not be misaligned .

check the tab position for that paragraph format in Tabs ..

regards,

vijay.