<?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: Write file contents dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975340#M399689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a little more complete example,  instead this uses comma as the delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

types: begin of ttab,
       fld1(10) type c,
       fld2(10) type c,
       fld3(10) type c,
       end   of ttab.
data: itab type table of ttab.
data: wa like line of itab.


data: istr type table of string.
data: xstr type string.

data:
      dsn(100) value '/usr/sap/TST/sys/test.txt'.

field-symbols: &amp;lt;fs&amp;gt;.

clear itab.  refresh itab.

* Read the data.
open dataset dsn for input in text mode.
do.
  read dataset dsn into xstr.
  if sy-subrc = 0.
    split xstr at ',' into table istr.
    loop at istr into xstr.
      assign component sy-tabix of structure wa to &amp;lt;fs&amp;gt;.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      &amp;lt;fs&amp;gt; = xstr.
    endloop.
    append wa to itab.
  else.
    exit.
  endif.
enddo.
close dataset dsn.


loop at itab into wa.
  write:/ wa-fld1, wa-fld2, wa-fld3.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is how the file looks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

ABC,DEF,GHI
JKL,MNO,PQR
STV,WVX,YZ0

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Feb 2007 17:51:51 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2007-02-07T17:51:51Z</dc:date>
    <item>
      <title>Write file contents dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975338#M399687</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;I'm reading a file from the application server using OPEN DATASET as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DO.&lt;/P&gt;&lt;P&gt;      READ DATASET ds_file INTO l_string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&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;      SPLIT l_string AT con_tab INTO TABLE lt_itab.&lt;/P&gt;&lt;P&gt;      LOOP AT lt_itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;        ?????&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;    ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lt_itab consists of one field 25 characters long. I want to assign each row in lt_itab to a specific field in a work area dynamically...maybe using a field symbol...can I do that? I don't want to have to name each field in the work area....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2007 17:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975338#M399687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-07T17:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Write file contents dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975339#M399688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the values which are in the table IT_ITAB are in the same order as the fields in the target structure then you can do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DO.
READ DATASET ds_file INTO l_string.

IF sy-subrc NE 0.
EXIT.
ENDIF.

SPLIT l_string AT con_tab INTO TABLE lt_itab.
field-symbols: &amp;lt;fs&amp;gt; .
LOOP AT lt_itab INTO wa_itab.
 
 assign component sy-tabix of structure wa_struc to &amp;lt;fs&amp;gt;.
   if sy-subrc &amp;lt;&amp;gt; 0.
     exit.
  endif.
&amp;lt;fs&amp;gt; = wa_itab.

ENDLOOP.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2007 17:41:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975339#M399688</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2007-02-07T17:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Write file contents dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975340#M399689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a little more complete example,  instead this uses comma as the delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

types: begin of ttab,
       fld1(10) type c,
       fld2(10) type c,
       fld3(10) type c,
       end   of ttab.
data: itab type table of ttab.
data: wa like line of itab.


data: istr type table of string.
data: xstr type string.

data:
      dsn(100) value '/usr/sap/TST/sys/test.txt'.

field-symbols: &amp;lt;fs&amp;gt;.

clear itab.  refresh itab.

* Read the data.
open dataset dsn for input in text mode.
do.
  read dataset dsn into xstr.
  if sy-subrc = 0.
    split xstr at ',' into table istr.
    loop at istr into xstr.
      assign component sy-tabix of structure wa to &amp;lt;fs&amp;gt;.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      &amp;lt;fs&amp;gt; = xstr.
    endloop.
    append wa to itab.
  else.
    exit.
  endif.
enddo.
close dataset dsn.


loop at itab into wa.
  write:/ wa-fld1, wa-fld2, wa-fld3.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is how the file looks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

ABC,DEF,GHI
JKL,MNO,PQR
STV,WVX,YZ0

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2007 17:51:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-file-contents-dynamically/m-p/1975340#M399689</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2007-02-07T17:51:51Z</dc:date>
    </item>
  </channel>
</rss>

