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: 

Length of a String

Former Member
0 Kudos
164

Hi,

I want to find a length of a string.

This is my program to write the length of a string.But iam getting errors. Plz correct it.

PARAMETERS: P_STR(30) TYPE C.

DATA:

W_LEN TYPE I.

  • FIND LENGTH OF A STRING

W_LEN = STRLEN(P_STR).

WRITE:/ 'LENGTH OF', P_STR IS', W_LEN.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
118

Hi,

PARAMETERS: P_STR(30) TYPE C.
DATA:
W_LEN TYPE I.
* FIND LENGTH OF A STRING
W_LEN = STRLEN( P_STR ).  " Space after ( and before ) 

WRITE:/ 'LENGTH OF', P_STR, 'IS', W_LEN." Commas 

Regards

Sudheer

9 REPLIES 9

Former Member
0 Kudos
118

Copy ,paste and execute the code

PARAMETERS: P_STR(30) TYPE C.

DATA:

W_LEN TYPE I.

  • FIND LENGTH OF A STRING

W_LEN = STRLEN( P_STR ).

WRITE:/ 'LENGTH OF', P_STR ,'IS', W_LEN.

Regards,

Pavan.

0 Kudos
118

Hi

Try like this its working fine

REPORT  ZSTRING                                 .
PARAMETERS: P_STR(30) TYPE C.
DATA:
W_LEN TYPE I.
*STRLEN TYPE XSTRING.
* FIND LENGTH OF A STRING
W_LEN = STRLEN( P_STR ).

WRITE:/ 'LENGTH OF', P_STR ,'IS', W_LEN.

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos
119

Hi,

PARAMETERS: P_STR(30) TYPE C.
DATA:
W_LEN TYPE I.
* FIND LENGTH OF A STRING
W_LEN = STRLEN( P_STR ).  " Space after ( and before ) 

WRITE:/ 'LENGTH OF', P_STR, 'IS', W_LEN." Commas 

Regards

Sudheer

Former Member
0 Kudos
118

strlen(text)

Former Member
0 Kudos
118

Hi

Just give space on both sides of the field p_str.it will work

W_LEN = STRLEN( P_STR ).

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos
118

hi

DATA: int TYPE i,

word1(20) TYPE c VALUE '12345',

word2(20) TYPE c ,

word3(20) TYPE c VALUE ' 4 '.

int = strlen( word1 ). WRITE int.

int = strlen( word2 ). WRITE / int.

int = strlen( word3 ). WRITE / int.

if this can be of any use..

praveen

Former Member
0 Kudos
118

compute W_LEN = STRLEN( P_STR ).

check the space after ( and before ).

add compute key word also.

regards

shiba dutta

gopi_narendra
Active Contributor
0 Kudos
118
PARAMETERS: p_str(30) TYPE c.
DATA : w_len TYPE i.
* FIND LENGTH OF A STRING
w_len = strlen( p_str ). " include spaces before and after p_str

WRITE:/ 'LENGTH OF', p_str , 'IS', w_len.

Regards

Gopi

Former Member
0 Kudos
118

hi..

parameters: P_STR(30) TYPE c.

DATA:

W_LEN TYPE I.

*STRLEN type c.

  • FIND LENGTH OF A STRING

W_LEN = STRLEN( P_STR )." <b>leave space between ( and P_STR.</b>

WRITE:/ 'LENGTH OF P_STR IS', W_LEN.

<b>

Reward points if useful</b>

Regards

Ashu