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

Concatenatiting table records to string without stripping blanks?

Hi,

Does anyone know how to concatenate records in internal table to a string field without cutting blanks?

Example:

data:

it_data type standard table of char05,

g_output type string.

record 1: 'AB '

record 2: 'CDE '

record 3: 'FGHI '

I want g_output to be 'AB CDE FGHI '

Kind regards,

Keld Gregersen

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:34 PM

    abap statment:

    concatenate a b c separated by space.

    br, JAcek

    p.s please rewar helpful answers

    Message was edited by: Jacek Slowikowski

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:46 PM

    Hi,

    data string1 type string.

    string1 = space.

    loop at itab.

    concatenate string1 itab into string1 separated by

    space.

    endloop.

    Regards

    Amole

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:49 PM
    loop at it_data.
    
      concatenate string1 it_data-record into string1 separated by space.
    
    endloop.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:50 PM

    data: begin of it occurs 0,

    dd(50) type c,

    end of it.

    data: g_output type string,

    l1 type string,

    l2 type string.

    it = '34345'.

    append it.

    it = 'cvsv'.

    append it.

    it = 'raja asjh ashxb'.

    append it.

    loop at it.

    move it to l1.

    concatenate l2 l1 into l2 separated by space.

    endloop.

    Regards,

    -- Raj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:55 PM

    Hi,

    Thank you for your answers, but it is a bit more complicated!

    Maybe my example wasn't very clear. I need more than just a blank/space between my records.

    record 1: 'AB...'

    record 2: 'CDE..'

    record 3: 'FGHI.'

    '.' means in this case a blank/space

    the result should be 'AB...CDE..FGHI.'

    Kind regards,

    Keld Gregersen

    Add a comment
    10|10000 characters needed characters exceeded

    • record 1: `AB   `
      record 2: `CDE  `
      record 3: `FGHI `

      try this , instead of single quote (') use `(which is next to number one in your key board)

      now the following stt. will preserve the spaces.

      concatenate record1 record2 record3 into result_rec.

      (note you dont need separated by space addition in this case)

      Regards

      Raja

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2006 at 01:58 PM

    Hi,

    Loop at that table and use concatenate command.

    eg: loop at it_data into wa_data.

    concatenate g_output wa_data into g_output.

    endloop.

    Hope this helps

    Vamsi

    Add a comment
    10|10000 characters needed characters exceeded

    • hi,

      try:

      loop at itab.
       do.
        assign component sy-index of structure itab to <f>.
        if sy-subrc <> 0.
          exit.
        endif.
      
        describe field <f> length i.
       if sy-index = 1.
        move <f> to str.
       else.
        move <f> to str+i.
       endif.
      endif.
      
      enddo.
      endloop.

      A.

      Message was edited by: Andreas Mann

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.