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 the number of characters

Former Member
0 Kudos

Dear All,

Can anyone tell me a Function Code or sample code to count the number of charactes in a text.

Regards,

Vijay

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi to count the number of character in text... use the following code.


data: l_length type i,
       text(200).

text = 'My TEXT'.

l_length = STRLEN( text ).

l_length = 7.

Message was edited by:

Abhay Chauhan

11 REPLIES 11

Former Member
0 Kudos

Hi to count the number of character in text... use the following code.


data: l_length type i,
       text(200).

text = 'My TEXT'.

l_length = STRLEN( text ).

l_length = 7.

Message was edited by:

Abhay Chauhan

Former Member
0 Kudos

use strlen fuction... it will help u

Former Member
0 Kudos

Use STRLEN( variablename)

Reward points if useful!

Cheers,

Sam

Former Member
0 Kudos

Hi,

Please check the code below:

To read the last characters of a string:

DATA: offset TYPE i.

DATA:str(15) TYPE c.

v_string = STRLEN( gt_dummy ).

v_string = v_string - 20.

Regards

Kannaiah

Former Member
0 Kudos

also chk this

REPORT ZTEST.

DATA : V_STR TYPE STRING VALUE 'asfrasgdgkjkasdgjkjdskgjsd',
       V_LEN TYPE I.

CALL FUNCTION 'STRING_LENGTH'
  EXPORTING
    STRING = V_STR
  IMPORTING
    LENGTH = V_LEN.

WRITE : / V_LEN.

Former Member
0 Kudos

hi

<b>use the inbuilt function strlen</b>

Number of characters in arg; blanks at the end of data objects with a fixed length are not counted, although they are counted in type string data objects. If you use a non-Unicode double-byte code, a character that occupies 2 bytes is counted twice.

<b>example</b>

data: v_len type i,

v_str type string value 'gggugik'.

v_len = strlen( v_str ).

write:/ v_len.

Regards,

ravish

<b>plz reward points if helpful</b>

Former Member
0 Kudos

hi,

Use the following FM

SWA_STRINGLENGTH_GET

regards,

Navneeth.K

Former Member
0 Kudos

Hello,

Use the STRLEN command. Ex: STRLEN( variable ).

Regards,

Shehryar Dahar

Former Member
0 Kudos

Hi,

Use STRLEN() standard function provided in SAP.

Reward is useful,

Regards,

Tanmay

Former Member
0 Kudos

Hi,

Can u tell me your proper reqmnt. the above posts seems to solve your purpose what is your actual need.

if your purpose is solved close this post

regards,

Navneeth.K

0 Kudos

Dear All,

Thanks a ton for your replies . The output was achieved as per your guidances.

Thanks once again!!!!

Regards,

Vijay