<?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: Output an internal table to application server using field separator in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676370#M298271</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;Concatenate all the fields into one string and use seperated by space addition before you transfer the record to the opened file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Nov 2006 10:55:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-23T10:55:36Z</dc:date>
    <item>
      <title>Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676367#M298268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to output the contents of a rather large internal table to the application server with the columns tab separated. Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the general idea:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of large_itab occurs 100,
field1(10) type c,
field2(8) type c,
...
field50(3) type c.
data: end of large_itab.

data: l_file type string.
l_file  = '/tmp/tst.txt'

* Fill the table with data


open dataset l_file in text mode for output type 'UNIX' encoding default.
loop at large_itab into wa_large.
  transfer wa_large to l_file.
endloop.
close dataset l_file.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This obviously does not output the fields with a field separator (only all the fileds after one another), but is there an easy way to do it? Would like CL_ABAP_CHAR_UTILITIES=&amp;gt;HORIZONTAL_TAB as my separator. Have tried concatenating the fields one by one into a string with that separator, i.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
concatenate wa_large-field1 wa_tot-field2 ...  wa_tot-field50 into l_output separated by l_tab.
transfer l_output to l_file
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, but it's not very pretty. Could be ok if done by a loop, but typing all the fields after one another on one line is not appealing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Surely, there must be an easier way to do this. Outputting an internal table to the application server together with some form of separator seems pretty basic to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:35:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676367#M298268</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T10:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676368#M298269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can do something like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM download_to_excel_server .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA:  lv_cnt             TYPE    i,&lt;/P&gt;&lt;P&gt;        lv_fld             TYPE    string,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        ls_product_group   TYPE    ty_product_group.         &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        ls_product_group   TYPE    ty_product_group_download.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; FIELD-SYMBOLS &amp;lt;fs&amp;gt;          TYPE ANY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   IF NOT gt_product_group[] IS INITIAL.&lt;/P&gt;&lt;P&gt;           OPEN DATASET p_fnmprg FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;       IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;         SET CURSOR FIELD p_fnmprg.&lt;/P&gt;&lt;P&gt;         MESSAGE e060 WITH p_fnmprg.&lt;/P&gt;&lt;P&gt;         EXIT.&lt;/P&gt;&lt;P&gt;       ENDIF.&lt;/P&gt;&lt;P&gt;       LOOP AT gt_product_group INTO ls_product_group.&lt;/P&gt;&lt;P&gt;         CLEAR: file_text,lv_cnt.&lt;/P&gt;&lt;P&gt;         DO.&lt;/P&gt;&lt;P&gt;           ADD 1 TO lv_cnt.&lt;/P&gt;&lt;P&gt;         ASSIGN COMPONENT lv_cnt OF STRUCTURE ls_product_group TO &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;           IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;             EXIT.&lt;/P&gt;&lt;P&gt;           ENDIF.&lt;/P&gt;&lt;P&gt;           lv_fld = &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;       CONCATENATE file_text lv_fld INTO file_text SEPARATED BY gc_tab.&lt;/P&gt;&lt;P&gt;         ENDDO.&lt;/P&gt;&lt;P&gt;         SHIFT file_text LEFT BY 1 PLACES.&lt;/P&gt;&lt;P&gt;         TRANSFER file_text TO p_fnmprg.&lt;/P&gt;&lt;P&gt;       ENDLOOP.&lt;/P&gt;&lt;P&gt;       CLOSE DATASET p_fnmprg.&lt;/P&gt;&lt;P&gt;       ENDIF.&lt;/P&gt;&lt;P&gt; ENDFORM.                    " download_to_excel_server&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:52:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676368#M298269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T10:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676369#M298270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of large_itab occurs 100,
field1(10) type c,
delimit1(1) type c,   
field2(8) type c,
delimit2(1) type c,
...
field50(3) type c.
data: end of large_itab.
 
data: l_file type string.
l_file  = '/tmp/tst.txt'
 
* Fill the table with data and delimiter
 
open dataset l_file in text mode for output type 'UNIX' encoding default.
loop at large_itab into wa_large.
  transfer wa_large to l_file.
endloop.
close dataset l_file.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bernd&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:53:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676369#M298270</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T10:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676370#M298271</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;Concatenate all the fields into one string and use seperated by space addition before you transfer the record to the opened file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:55:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676370#M298271</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T10:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676371#M298272</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;Why not use ASSIGN COMPONENT OF STRUCTURE in a loop to process each field in each row? Something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
field-symbols:
  &amp;lt;field&amp;gt; type any.
count = " number of fields in structure

loop at large_itab into wa_large.
  do count times.
    assign component sy-index of structure wa_large to &amp;lt;field&amp;gt;.
    if sy-subrc = 0.
      transfer &amp;lt;field&amp;gt; to l_file.
      transfer cl_abap_char_utilities=&amp;gt;horizontal_tab to l_file.
    endif.
  enddo.

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tested the above, but it should do what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:57:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676371#M298272</guid>
      <dc:creator>michael-john_turner</dc:creator>
      <dc:date>2006-11-23T10:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676372#M298273</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;As you already ahve data in your internal table, only you want to add separator to fileds &lt;/P&gt;&lt;P&gt;do the following:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: separator type c/ABAp_char1.&lt;/P&gt;&lt;P&gt;move CL_ABAP_CHAR_UTILITIES=&amp;gt;HORIZONTAL_TAB to c.&lt;/P&gt;&lt;P&gt;open dataset l_file in text mode for output type 'UNIX' encoding default.&lt;/P&gt;&lt;P&gt;loop at large_itab into wa_large.&lt;/P&gt;&lt;P&gt;  transfer wa_large to l_file.&lt;/P&gt;&lt;P&gt;  transfer c to l_file. &lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*if want to add separator after the last field also then&lt;/P&gt;&lt;P&gt;  transfer c to l_file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;close dataset l_file.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this will solve your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 10:59:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676372#M298273</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T10:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676373#M298274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;try this...

data : fields like RSTRUCINFO occurs 0 with header line,
         text(1000).

data:  len type i,
       len2 type i,
       len3 type i.



CALL FUNCTION 'GET_COMPONENT_LIST'
  EXPORTING
    program          = sy-repid
    fieldname        = 'LARGE_ITAB'
  tables
    components       = fields[]
          .

open dataset l_file in text mode for output type 'UNIX' encoding default.

describe table fields lines len3.

loop at large_itab into wa_large.
 text = '"'.
loop at fields.
    len = strlen( text ).
  text+len(fields-olen) =
wa_large+len2(fields-olen).

    len2 = len2 + fields-olen.

    len = len + fields-olen.

    if not sy-tabix = len3.
      text+len = '","'.
    endif.
endloop.

  text+len = '"'.

transfer  text to l_file

    clear: len,len2, text.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls let me know if u need any clarifications&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        chandrasekhar jagarlamudi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 11:15:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676373#M298274</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T11:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Output an internal table to application server using field separator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676374#M298275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks MJ, your answer did the trick. All I needed to add was the "NO END OF LINE" parameter to the transfer statement, and add some logic to enter a newline character at the end of the table row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
do count times.
  assign component sy-index of structure wa_large to &amp;lt;field&amp;gt;.
  if sy-subrc = 0.
    transfer &amp;lt;field&amp;gt; to l_file NO END OF LINE.
    if sy-index = count.
      transfer cl_abap_char_utilities=&amp;gt;newline to l_file NO END OF LINE.
    else.
      transfer cl_abap_char_utilities=&amp;gt;horizontal_tab to l_file NO END OF LINE.
    endif.
  endif.
enddo.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 12:43:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/output-an-internal-table-to-application-server-using-field-separator/m-p/1676374#M298275</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T12:43:10Z</dc:date>
    </item>
  </channel>
</rss>

