Skip to Content
author's profile photo Former Member
Former Member

Length of a String

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 05:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 05:56 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 05:57 AM

    strlen(text)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 05:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 05:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 11, 2007 at 06:02 AM
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 06:06 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 06:00 AM

    compute W_LEN = STRLEN( P_STR ).

    check the space after ( and before ).

    add compute key word also.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.