<?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: Multiple file creation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442629#M210349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Simran.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT zztest.
TABLES : t001w.

*Declare one Internal table for werks
DATA :BEGIN OF it_werks OCCURS 0,
      werks TYPE t001w-werks,
      END OF it_werks.

*Select options
SELECT-OPTIONS : s_werks FOR t001w-werks.

START-OF-SELECTION.


*GEt all the plants entered in selection screen from
*DB table &amp;lt;b&amp;gt;T001W (Plants/Branches)&amp;lt;/b&amp;gt;

  SELECT werks FROM t001w INTO TABLE it_werks WHERE werks IN s_werks.

*Loop that internal table
&amp;lt;b&amp;gt;  LOOP AT it_werks.&amp;lt;/b&amp;gt;
    CONCATENATE
    c_path "file path
    c_qm " 'QM'
    c_underscore   "underscore
    c_results      " 'RESULTS'
    c_underscore
   &amp;lt;b&amp;gt; it_werks-werks    "Plant&amp;lt;/b&amp;gt;
    c_underscore
    sy-datum+4(2)    "system date
    sy-datum+6(2)
    sy-datum+0(4)
    c_underscore
    sy-uzeit+0(2)  "system time
    sy-uzeit+2(2)
    c_ext "file extension

    INTO g_file_name.

&amp;lt;b&amp;gt;*Now you have the file path for the werks
*Open File on the application server for processing&amp;lt;/b&amp;gt;


    OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
    ENCODING DEFAULT.

    IF sy-subrc NE 0.

*Display error message
      MESSAGE i055. " Error in opening file
      LEAVE LIST-PROCESSING.

    ELSE.

      LOOP AT i_final INTO wa_final.

        TRANSFER wa_final TO g_file_name.

      ENDLOOP.
    ENDIF.
    CLOSE DATASET g_file_name.

* Then i am updating the database table using i_update
* Work Area for Z_DATADOWNLOAD table

    DATA: l_wa_update TYPE ztable


    l_wa_update-prog_name = g_repid.
    l_wa_update-plant = s_werks.
    l_wa_update-last_run_dt = g_sysdate.
    l_wa_update-last_run_tm = g_systime.

    MODIFY ztable FROM l_wa_update.

*Pls let me know how to manage this for multiple files.

&amp;lt;b&amp;gt;  ENDLOOP.&amp;lt;/b&amp;gt;

&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;Arun Sambargi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 16 Jul 2006 11:32:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-07-16T11:32:02Z</dc:date>
    <item>
      <title>Multiple file creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442625#M210345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I have to create multiple files for mulitiple plants entered through select-options.&lt;/P&gt;&lt;P&gt;I have done this for single file but not getting the idea how to do it for multiple files.&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;&amp;lt;b&amp;gt;My work:&amp;lt;/b&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;*File creation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CONCATENATE&lt;/P&gt;&lt;P&gt;                c_path               "file path&lt;/P&gt;&lt;P&gt;                c_qm                 " 'QM'&lt;/P&gt;&lt;P&gt;                c_underscore         "underscore&lt;/P&gt;&lt;P&gt;                c_results            " 'RESULTS'&lt;/P&gt;&lt;P&gt;                c_underscore&lt;/P&gt;&lt;P&gt;                s_werks              "plant&lt;/P&gt;&lt;P&gt;                c_underscore&lt;/P&gt;&lt;P&gt;                sy-datum+4(2)        "system date&lt;/P&gt;&lt;P&gt;                sy-datum+6(2)&lt;/P&gt;&lt;P&gt;                sy-datum+0(4)&lt;/P&gt;&lt;P&gt;                c_underscore&lt;/P&gt;&lt;P&gt;                sy-uzeit+0(2)        "system time&lt;/P&gt;&lt;P&gt;                sy-uzeit+2(2)&lt;/P&gt;&lt;P&gt;                c_ext                "file extension&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           INTO g_file_name.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Open File on the application server for processing&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE&lt;/P&gt;&lt;P&gt;  ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Display error message&lt;/P&gt;&lt;P&gt;    MESSAGE i055.              " Error in opening file&lt;/P&gt;&lt;P&gt;    LEAVE LIST-PROCESSING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT i_final INTO wa_final.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      TRANSFER wa_final TO g_file_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  CLOSE DATASET g_file_name.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Then i am updating the database table using i_update&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Work Area for Z_DATADOWNLOAD table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; DATA: l_wa_update TYPE ztable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_wa_update-prog_name    = g_repid.&lt;/P&gt;&lt;P&gt;  l_wa_update-plant        = s_werks.&lt;/P&gt;&lt;P&gt;  l_wa_update-last_run_dt  = g_sysdate.&lt;/P&gt;&lt;P&gt;  l_wa_update-last_run_tm  = g_systime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  MODIFY ztable FROM l_wa_update.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls let me know how to manage this for multiple files.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Jul 2006 11:05:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442625#M210345</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-16T11:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442626#M210346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might have the following flow logic in your program&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Extract the data based on given plant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moving data into i_final table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you change as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where itab is the list of selected plants from SELECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Extract the data&lt;/P&gt;&lt;P&gt;write into application server.&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;Regds&lt;/P&gt;&lt;P&gt;Manohar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls reward if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Jul 2006 11:13:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442626#M210346</guid>
      <dc:creator>Manohar2u</dc:creator>
      <dc:date>2006-07-16T11:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442627#M210347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. &lt;/P&gt;&lt;P&gt;I have already extracted the data into the final internal table i_final.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However,&lt;/P&gt;&lt;P&gt;my plant selections are on table i_t001w&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i am looping it with i_t001w &lt;DEL&gt;&amp;gt; creating file name&lt;/DEL&gt;&amp;gt; writing it into app server(using table i_final)--&amp;gt; updating the database table (using i_update).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can it be possible?&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Simran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Jul 2006 11:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442627#M210347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-16T11:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442628#M210348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes this is the way you should approach for writing a file per plant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds&lt;/P&gt;&lt;P&gt;Manohar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Jul 2006 11:28:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442628#M210348</guid>
      <dc:creator>Manohar2u</dc:creator>
      <dc:date>2006-07-16T11:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442629#M210349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Simran.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT zztest.
TABLES : t001w.

*Declare one Internal table for werks
DATA :BEGIN OF it_werks OCCURS 0,
      werks TYPE t001w-werks,
      END OF it_werks.

*Select options
SELECT-OPTIONS : s_werks FOR t001w-werks.

START-OF-SELECTION.


*GEt all the plants entered in selection screen from
*DB table &amp;lt;b&amp;gt;T001W (Plants/Branches)&amp;lt;/b&amp;gt;

  SELECT werks FROM t001w INTO TABLE it_werks WHERE werks IN s_werks.

*Loop that internal table
&amp;lt;b&amp;gt;  LOOP AT it_werks.&amp;lt;/b&amp;gt;
    CONCATENATE
    c_path "file path
    c_qm " 'QM'
    c_underscore   "underscore
    c_results      " 'RESULTS'
    c_underscore
   &amp;lt;b&amp;gt; it_werks-werks    "Plant&amp;lt;/b&amp;gt;
    c_underscore
    sy-datum+4(2)    "system date
    sy-datum+6(2)
    sy-datum+0(4)
    c_underscore
    sy-uzeit+0(2)  "system time
    sy-uzeit+2(2)
    c_ext "file extension

    INTO g_file_name.

&amp;lt;b&amp;gt;*Now you have the file path for the werks
*Open File on the application server for processing&amp;lt;/b&amp;gt;


    OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
    ENCODING DEFAULT.

    IF sy-subrc NE 0.

*Display error message
      MESSAGE i055. " Error in opening file
      LEAVE LIST-PROCESSING.

    ELSE.

      LOOP AT i_final INTO wa_final.

        TRANSFER wa_final TO g_file_name.

      ENDLOOP.
    ENDIF.
    CLOSE DATASET g_file_name.

* Then i am updating the database table using i_update
* Work Area for Z_DATADOWNLOAD table

    DATA: l_wa_update TYPE ztable


    l_wa_update-prog_name = g_repid.
    l_wa_update-plant = s_werks.
    l_wa_update-last_run_dt = g_sysdate.
    l_wa_update-last_run_tm = g_systime.

    MODIFY ztable FROM l_wa_update.

*Pls let me know how to manage this for multiple files.

&amp;lt;b&amp;gt;  ENDLOOP.&amp;lt;/b&amp;gt;

&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;Arun Sambargi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Jul 2006 11:32:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-file-creation/m-p/1442629#M210349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-16T11:32:02Z</dc:date>
    </item>
  </channel>
</rss>

