<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting Internal table contents to string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703534#M891715</link>
    <description>&lt;P&gt;My proposal:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONCATENATE LINES OF lt_string_table INTO l_single_string SEPARATED BY cl_abap_char_utilities=&amp;gt;cr_lf.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 15 Oct 2019 15:12:07 GMT</pubDate>
    <dc:creator>adam_krawczyk1</dc:creator>
    <dc:date>2019-10-15T15:12:07Z</dc:date>
    <item>
      <title>Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703526#M891707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to convert each row of internal table into string using the function module &lt;STRONG&gt;SAP_CONVERT_TO_TXT_FORMAT&lt;/STRONG&gt; . Using this I can able to convert into string. But if one of the field is blank, it is concatenating the field and not showing the space for that field. In that place, the next field value is coming. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to pass the internal table line items to the string, without concetanating the field values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone guide me. &lt;/P&gt;&lt;P&gt;Thanks in advance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ramesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 11:21:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703526#M891707</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T11:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703527#M891708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why don´t you just copy the content of the whole workarea to a string linewise?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 11:27:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703527#M891708</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T11:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703528#M891709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 45 fields in my internal table. It is Laborious process to do that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 11:30:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703528#M891709</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T11:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703529#M891710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. It is resolved. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ramesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 12:23:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703529#M891710</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T12:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703530#M891711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How was it solved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For people who are interested, I had the same issue, I finally succeeded with the following code (it may be enhanced by adding a length parameter so that it can be used after cl_gui_frontend_services=&amp;gt;gui_upload to convert text table into string:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  z_merge_itab_respecting_blanks.

DATA it TYPE TABLE OF char20 WITH HEADER LINE.
DATA v TYPE string.

APPEND 'xxxj' TO it.
APPEND 'jj' TO it.
PERFORM table_2_string USING it[] CHANGING v.
WRITE v. "displays xxxj                jj

FORM table_2_string USING it TYPE ANY TABLE CHANGING v TYPE string.
  FIELD-SYMBOLS &amp;lt;z&amp;gt; TYPE ANY.
  DATA str TYPE string.
  DATA len TYPE i.
  DATA j TYPE i.
  DATA blanks TYPE string.

  CLEAR v.
  LOOP AT it ASSIGNING &amp;lt;z&amp;gt;.
    EXIT.
  ENDLOOP.
  IF sy-subrc EQ 0.

    DESCRIBE FIELD &amp;lt;z&amp;gt; LENGTH len IN CHARACTER MODE.
    SHIFT blanks RIGHT BY len PLACES.

    LOOP AT it ASSIGNING &amp;lt;z&amp;gt;.
      str = &amp;lt;z&amp;gt;.
      j = len - STRLEN( str ).
      IF j EQ 0.
        CONCATENATE v str INTO v.
      ELSE.
        CONCATENATE v str blanks(j) INTO v.
      ENDIF.
    ENDLOOP.

  ENDIF.

ENDFORM.                    "table_2_string&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2008 15:10:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703530#M891711</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-14T15:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703531#M891712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of coding yourself the conversion, you can use function module SWA_STRING_FROM_TABLE (available in any sap install) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* The following converts an internal table into string
* Demo : internal table with 2 lines of 5 characters each:
* ' xxx ' and ' hhh ' is converted into
* ' xxx  hhh ' (10 characters long, with one trailing space)
REPORT  zz_table_to_string.

DATA itab1 TYPE TABLE OF char5.
DATA str TYPE string.

APPEND ' xxx ' TO itab1.
APPEND ' hhh ' TO itab1.

CALL FUNCTION 'SWA_STRING_FROM_TABLE'
  EXPORTING
    character_table            = itab1
*   NUMBER_OF_CHARACTERS             =
*   LINE_SIZE                        =
    keep_trailing_spaces       = 'X'
*   CHECK_TABLE_TYPE                 = ' '
  IMPORTING
    character_string           = str
  EXCEPTIONS
    no_flat_charlike_structure = 1
    OTHERS                     = 2.
IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

data i type i.
i = strlen( str ).
assert i = 10.

data test(10) type c.
test = str.
assert test = ' xxx  hhh'.

write : / str, i.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 09:28:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703531#M891712</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T09:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703532#M891713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I replace the space between two string with a comma for the example shown above?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am expecting for an output like:&lt;BR /&gt;xxx, hhh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 07:07:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703532#M891713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-03T07:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703533#M891714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are planning to create CSV file I suggest you follow the rules of CSV .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules_and_examples" title="http://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules_and_examples"&gt;Comma-separated values - Wikipedia, the free encyclopedia&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 07:47:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703533#M891714</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2014-07-03T07:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Internal table contents to string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703534#M891715</link>
      <description>&lt;P&gt;My proposal:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONCATENATE LINES OF lt_string_table INTO l_single_string SEPARATED BY cl_abap_char_utilities=&amp;gt;cr_lf.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 15:12:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-internal-table-contents-to-string/m-p/3703534#M891715</guid>
      <dc:creator>adam_krawczyk1</dc:creator>
      <dc:date>2019-10-15T15:12:07Z</dc:date>
    </item>
  </channel>
</rss>

