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

ABAP Substring?

Hi,

I'm looking for a substring command in ABAP.

I have a string like this...

text = 'hello, how are you today'.

Here's my goal...

I want to separate my string at the 10th character into two strings (text1 and text2).

so the result would be

text1 has the value 'hello, how'

text2 has the value ' are you today'

of course, the characters in the string 'text' will vary.

Can anyone help?

Thanks.

Audrey

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on May 16, 2005 at 08:04 PM

    Hi Audrey

    You can use offset and length additions.

    DATA lv_str TYPE string .
    
    lv_str = 'hello, how are you today' .
    write:/ lv_str+7 ,
          / lv_str+7(3) ,
          / lv_str(7) .

    The output should be:

    how are you today
    how
    hello,

    Regards

    *--Serdar https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 16, 2005 at 08:03 PM

    Check out the following logic.

    
    report zrich_0001 .
    
    
    data: x(100) type c,
          y(100) type c,
          z(100) type c.
    
    x = 'Hello, how are you doing?'.
    
    
    y = x+0(10).
    z = x+10(90).
    
    
    write:/ y.
    write:/ z.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 18, 2005 at 04:06 PM

    Use Function module 'STRING_SPLIT_AT_POSITION'

    Manoj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 17, 2005 at 06:27 AM

    Ho Audrey,

    or try this:

    DATA text(80).
    DATA: BEGIN OF tx,
    text1(10),
    text2(70),
    END OF tx.
    
    text = 'hello, how are you today'.
    WRITE : / text.
    ULINE.
    MOVE text TO tx.
    WRITE: / tx-text1.
    WRITE: / tx-text2.

    regards Andreas

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 17, 2005 at 06:43 AM
    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.