<?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: Problem with open dataset for output in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497240#M841195</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;Do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Local Variables&lt;/P&gt;&lt;P&gt;  DATA : l_erfile TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Clear file&lt;/P&gt;&lt;P&gt;  CLEAR : l_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_erfile = p_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Open dataset for output mode to transfer the error log&lt;/P&gt;&lt;P&gt;  OPEN DATASET l_erfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF NOT it_erfile[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT it_erfile INTO st_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        TRANSFER st_erfile TO l_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CLEAR : st_erfile.&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;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2008 08:51:39 GMT</pubDate>
    <dc:creator>former_member386202</dc:creator>
    <dc:date>2008-03-11T08:51:39Z</dc:date>
    <item>
      <title>Problem with open dataset for output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497239#M841194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to create a file in a particular location. I am getting Runtime error if there already exists a file with the same name and with more than 35 MB of size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The runtime error is as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime Errors         DATASET_NOT_OPEN&lt;/P&gt;&lt;P&gt;Exceptn                CX_SY_FILE_OPEN_MODE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there exists a file already with the same name and lesser size, The program could able to recreate the file with the new data, the problem exists only if the existing file is Larger.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is the code I am using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;open dataset p_outf1 for output in text mode encoding default.&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt; transfer excel to p_outf1.&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;close dataset p_outf1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advice, helpfull answers are rewarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Veeru.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 08:48:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497239#M841194</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T08:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with open dataset for output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497240#M841195</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;Do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Local Variables&lt;/P&gt;&lt;P&gt;  DATA : l_erfile TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Clear file&lt;/P&gt;&lt;P&gt;  CLEAR : l_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_erfile = p_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Open dataset for output mode to transfer the error log&lt;/P&gt;&lt;P&gt;  OPEN DATASET l_erfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF NOT it_erfile[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT it_erfile INTO st_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        TRANSFER st_erfile TO l_erfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CLEAR : st_erfile.&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;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 08:51:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497240#M841195</guid>
      <dc:creator>former_member386202</dc:creator>
      <dc:date>2008-03-11T08:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with open dataset for output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497241#M841196</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;This is the code that i have used in my development and it is working fine with any size of the file i normally overwrite it. sometimes it consists of huge data and sometimes it does not contain any data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; OPEN DATASET target FOR OUTPUT IN TEXT MODE.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    WRITE:/ 'Cannot open ',target ,/ 'error = ', sy-subrc.&lt;/P&gt;&lt;P&gt;    STOP.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  LOOP AT itbl.&lt;/P&gt;&lt;P&gt;    TRANSFER itbl TO target.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  CLOSE DATASET target.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this if it can help u &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 08:52:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497241#M841196</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T08:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with open dataset for output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497242#M841197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the File is already existing with the same name then use APPENDING key word&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
... FOR APPENDING 


Effect 
OPEN ... FOR APPENDING tries to open the file in 'append' mode. If the file is already open, the system moves to the end of the file. When you open a file using FOR APPENDING, attempting to read the file sets SY-SUBRC to 4. The system display the end of the file. 



Note 
You can only use one of the additions 1 to 3 in a single statement. 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to recreate the file then delete the file before recreating using &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DELETE DATASET dsn. 


Effect 
Deletes the file specified in the field dsn. 

The return code is set as follows: 



SY-SUBRC = 0: 
File deleted. 
SY-SUBRC = 4: 
File does not exist or could not be deleted. 

Possible reasons: 

1) The file does not exist. 
2) The file is a directory. 
3) The R/3 System has no search authorization 
for a component of the file name. 
4) The R/3 System has no search authorization 
for the directory which contains the file. 
5) A component of the search path is not a 
directory. 
6) The file is a symbolic link which cannot be 
resolved (endless loop ?). 
7) The file is a program which is currently 
running. 


Note 
The system automatically performs an authorization check. If the user does not have the appropriate authorization, a runtime error occurs. You can check the existence of an authorization with the function module AUTHORITY_CHECK_DATASET. 



Catchable runtime errors 

The following runtime errors can occur with this variant: 

DATASET_CANT_OPEN: Unable to open file. 

OPEN_DATASET_NO_AUTHORITY: You are not authorized to access a file. 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 08:53:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-open-dataset-for-output/m-p/3497242#M841197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T08:53:43Z</dc:date>
    </item>
  </channel>
</rss>

