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

Position of Character in a dynamically generated string

Hi all,

Can anyone tell me how I can find the position of the first character in a dynamically generated string, which has empty spaces preceding the 1st character.

For eg.,

" Hello World".

Here, the string Hello World is dynamic and in real time can be any string which the user might not know. In that case, how do I find out the position of the first character or find the number of spaces existing before I encounter the 1st character ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 10:30 AM

    You can try this code..

    DATA text(30).
    
    text = '   My String'. "for example this is dynamic text
    
    IF text CA sy-abcde OR text CA '0123456789'.
      WRITE : sy-fdpos.
    ENDIF.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 10:17 AM

    If u want to remove leading spaces, just use following statement:

    SHIFT <fieldname> LEFT DELETING LEADING SPACES

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 10:34 AM

    Thank you all.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 10:39 AM

    HI,

    For searching the string u can use

    SEARCH <c> FOR <str> <options>.

    for deleting the preceeding r successing space

    SHIFT <c> LEFT DELETING LEADING <str>.

    SHIFT <c> RIGHT DELETING TRAILING <str>.

    regards

    zubair

    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.