Skip to Content
avatar image
Former Member

add space in a string

Hi experts,

I have this problem: I split a string in a table, because I need to analyze each word in (I'm programmin a parser) and I want to write the word one by one, but I cannot find a way to write a space between them: the write is in a cycle:

LOOP AT word_table INTO word_wa.
   CONCATENATE word_wa space INTO word_wa SEPARATED BY space.
   WRITE word_wa.
ENDLOOP.

but it seems ignoring my instructions ...

So how can I add a space between the words?

Thanks in advance.

Gabriele

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

20 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 01, 2008 at 04:36 PM

    Hi Gabriele,

    Common problem. Instead of using SPACE, you need to ALT+255

    You can use the same statement, don't necessary need the separated by clause:

    CONCATENATE word_wa ' ' INTO word_wa.

    But when you create the ' ' do not use the space bar. Press ', then press Alt key+pressNumpadkey255 to create the space (you will see it get created), then press ' again. I am betting this will work.

    Good luck.

    SL

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 10:15 AM

    Try

    CONCATENATE word_wa space INTO word_wa RESPECTING BLANKS.

    Regards,

    Mohaiyuddin

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 01, 2008 at 11:36 AM

    Hi,

    i you use strings instead of char varaibles you can have spaces at the end.

    Literals have to be enclosed in back quotes instead of apostrophes to make them strings.

    concatenate `A` ` ` `B` into s.
    

    will have another result as

    concatenate 'A' ' ' 'B' into s.
    

    In the above case s will contain a space between A and B using backquotes, even if s is only a char variable.

    concatenate `A` ` ` `B` ` ` into s.
    

    In that case, s will contain a space between A and B and a space at the end if s is declared as string, and it will contain a space between A and B, but now space at the end if it is declared as c.

    Give it a try, it will make life easier if you are dealing with spaces, without always using the separeted by clause.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 10:16 AM

    use SPLIT command.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 10:25 AM

    hi ,

    use SPLIT

    Also Check this link for SPLIT ..

    http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb3400358411d1829f0000e829fbfe/frameset.htm

    Regards,

    Sachin

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 10:44 AM

    Try Using

    LOOP AT word_table INTO word_wa.

    CONCATENATE word_wa '' INTO word_wa1 SEPARATED BY SPACE.

    ENDLOOP.

    WRITE word_wa1.

    Regards,

    Prashant

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 11:22 AM

    Dear friend,

    EXAMPLE:

    BEGIN OF WORD_TABLE,

    A(10) TYPE C,

    B(10) TYPE C,

    END OF WORD_TABLE.

    data : WORD_WA_TEMP TYPE STRING.

    Word_wa having 3 or 4 fields example.

    LOOP AT word_table INTO word_wa.

    CONCATENATE WORD_WA-A WORD_WA-B INTO WORD_WA_TEMP SEPARATED BY SPACE.

    WRITE WORD_WA_TEMP .

    ENDLOOP.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 11:26 AM

    Hello,

    Use SPLIT command.

    regards,

    Vivek

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 11:28 AM

    CONCATENATE word_wa 'space' into word_wa SEPARATED BY SPACE.

    Regards,

    Ajay

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2008 at 11:37 AM

    Hi,

    Just check this code.

    DATA: BEGIN OF word_table OCCURS 0,

    a1 TYPE string,

    END OF word_table.

    DATA: word_wa LIKE word_table-a1.

    DATA: a2 TYPE string.

    word_table-a1 = 'nitesh1'.

    APPEND word_table.

    word_table-a1 = 'nitesh2'.

    APPEND word_table.

    LOOP AT word_table.

    word_wa = word_table-a1.

    CONCATENATE word_wa space INTO a2 SEPARATED BY space.

    WRITE a2.

    CLEAR a2.

    ENDLOOP.

    OUTPUT:  nitesh1  nitesh2

    Thanks

    NK

    Add comment
    10|10000 characters needed characters exceeded