<?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: Read file into internal table using OPEN DATASET FOR INPUT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484982#M1556689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read it to a string then split it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:it_string type table of string.
field-symbols:&amp;lt;fs&amp;gt; type string,
                      &amp;lt;fs_f&amp;gt; type any.

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT it_data INTO ls_data.
do.
assign component sy-index of structure ls_data to &amp;lt;fs_f&amp;gt;.
if sy-subrc = 0.
if sy-index = 1.
wf_string = &amp;lt;fs_f&amp;gt; .
else.
concatenate wf_string &amp;lt;fs_f&amp;gt; separated by '|'.
endif.
else.
transfer wf_string to file.
exit.
endif.
enddo.
ENDLOOP.


OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET file INTO wf_string. 
 IF sy-subrc EQ 0.
  clear it_string[].
  split wf_string at '|' into table it_string. "assuming '|' as separator
  loop at it_string assigning &amp;lt;fs&amp;gt;.
   assign component sy-tabix of structure ls_data to &amp;lt;fs_f&amp;gt;.
   if sy-subrc = 0.
    &amp;lt;fs_f&amp;gt; = &amp;lt;fs&amp;gt;.
   endif.
    at last.
    append ls_data to it_data.
   endat.
  endloop.
ELSE.
EXIT.
ENDIF.
ENDDO:
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Dec 2010 14:23:26 GMT</pubDate>
    <dc:creator>kesavadas_thekkillath</dc:creator>
    <dc:date>2010-12-01T14:23:26Z</dc:date>
    <item>
      <title>Read file into internal table using OPEN DATASET FOR INPUT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484981#M1556688</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 want to save a internal table (simple structure) to a file on the application server using the OPEN DATASET x FOR OUTPUT IN TEXT MODE (...). I don't have a problem creating the file - so far so good.&lt;/P&gt;&lt;P&gt;Afterwards i want to load the same file into a internal table. &lt;/P&gt;&lt;P&gt;The OPEN DATASET x FOR INPUT IN TEXT MODE (...) and the following READ DATASET x INTO y doean't accept the original structure as the input structure y.&lt;/P&gt;&lt;P&gt;Is there an easy way to "press" a input file line into a structure if the structure that was used to create the file is known?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create file using the internal table it_data (structure ls_data):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_data INTO ls_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRANSFER ls_data TO file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Read the file into the table (NOT WORKING)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ DATASET file INTO ls_data.   " NOT WORKING !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;   APPEND ls_data TO it_data.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;   EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second step is not working because only a string structure seems to be accepted to read a dataset into.&lt;/P&gt;&lt;P&gt;Does anybody know a easy way to read the file into the internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Manfred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 14:06:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484981#M1556688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-01T14:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Read file into internal table using OPEN DATASET FOR INPUT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484982#M1556689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read it to a string then split it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:it_string type table of string.
field-symbols:&amp;lt;fs&amp;gt; type string,
                      &amp;lt;fs_f&amp;gt; type any.

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT it_data INTO ls_data.
do.
assign component sy-index of structure ls_data to &amp;lt;fs_f&amp;gt;.
if sy-subrc = 0.
if sy-index = 1.
wf_string = &amp;lt;fs_f&amp;gt; .
else.
concatenate wf_string &amp;lt;fs_f&amp;gt; separated by '|'.
endif.
else.
transfer wf_string to file.
exit.
endif.
enddo.
ENDLOOP.


OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET file INTO wf_string. 
 IF sy-subrc EQ 0.
  clear it_string[].
  split wf_string at '|' into table it_string. "assuming '|' as separator
  loop at it_string assigning &amp;lt;fs&amp;gt;.
   assign component sy-tabix of structure ls_data to &amp;lt;fs_f&amp;gt;.
   if sy-subrc = 0.
    &amp;lt;fs_f&amp;gt; = &amp;lt;fs&amp;gt;.
   endif.
    at last.
    append ls_data to it_data.
   endat.
  endloop.
ELSE.
EXIT.
ENDIF.
ENDDO:
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 14:23:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484982#M1556689</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-12-01T14:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Read file into internal table using OPEN DATASET FOR INPUT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484983#M1556690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i already though about the ASSIGN COMPONENT command. But as you described it it seems quite easy to handle.&lt;/P&gt;&lt;P&gt;Is it possible to use a TAB as a delimiter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Manfred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 14:37:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484983#M1556690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-01T14:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Read file into internal table using OPEN DATASET FOR INPUT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484984#M1556691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to use a TAB as a delimiter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes .&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
concatenate wf_string &amp;lt;fs_f&amp;gt; separated by CL_ABAP_CHAR_UTILITIES=&amp;gt;HORIZONTAL_TAB.
split wf_string at  CL_ABAP_CHAR_UTILITIES=&amp;gt;HORIZONTAL_TAB into table i_string .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 14:44:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-into-internal-table-using-open-dataset-for-input/m-p/7484984#M1556691</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-12-01T14:44:05Z</dc:date>
    </item>
  </channel>
</rss>

