<?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: Error handling with OPEN DATASET in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762683#M1305162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Jun 2009 16:01:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-25T16:01:34Z</dc:date>
    <item>
      <title>Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762672#M1305151</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 have a question about the usage of error handling in OPEN DATASET&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can user MESSAGE msg option with OPEN DATASET &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can use TRY .... CATCH .. ENDTRY. statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Can I use both these ? or If I use one option, Is it true that I should not use the other option?&lt;/P&gt;&lt;P&gt;2. What is the difference between these two options?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know. Your help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Surya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 19:48:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762672#M1305151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T19:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762673#M1305152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET dset FOR access IN mode MESSAGE msg .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an error occurs when a fileis opened, the corresponding operating system message is assigned to the data object msg. A character-type variable can be entered for msg. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;KC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 20:07:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762673#M1305152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T20:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762674#M1305153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Surya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always use this code to handle errors in OPEN DATASET, both those that gets a SY-SUBRC NE 0 and those which could generate a dump (TRY...CATCH...ENDTRY):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CONSTANTS: c_error TYPE sy-msgty VALUE 'E'.

PARAMETERS: p_path TYPE admi_path.

START-OF-SELECTION.
 
...
 
  DATA: l_message   TYPE string,
        o_exception TYPE REF TO cx_root.

  TRY.

      OPEN DATASET p_path
           FOR OUTPUT
           IN TEXT MODE ENCODING DEFAULT
           MESSAGE l_message.

*     Error
      IF sy-subrc IS NOT INITIAL.

        MESSAGE l_message
           TYPE c_error.

      ENDIF.

*   Error
    CATCH cx_root
      INTO o_exception.

*     Gets error message
      CALL METHOD o_exception-&amp;gt;if_message~get_text
        RECEIVING
          result = l_message.

      MESSAGE l_message
         TYPE c_error.

  ENDTRY.
 
...
 
  CLOSE DATASET p_path. 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 21:17:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762674#M1305153</guid>
      <dc:creator>martinborda</dc:creator>
      <dc:date>2009-06-23T21:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762675#M1305154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding the difference between SY-SUBRC errors and EXCEPTIONS errors in OPEN DATASET, they are just two different ways of getting (different) possible errors, so you must take both into account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is from OPEN DATASET SAP help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Return Value

sy-subrc Description 
0 File was opened. 
8 Operating system could not open file. 
 

Exceptions 
Catchable Exceptions 

CX_SY_FILE_OPEN 

Cause: File is already open (only in Unicode programs) 
Runtime Error: DATASET_REOPEN 

CX_SY_CODEPAGE_CONVERTER_INIT 

Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.) 
Runtime Error: CONVT_CODEPAGE_INIT (catchable) 

CX_SY_CONVERSION_CODEPAGE 

Cause: Internal error in the conversion. 
Runtime Error: CONVT_CODEPAGE (catchable) 

CX_SY_FILE_AUTHORITY 

Cause: No authorization for access to file 
Runtime Error: OPEN_DATASET_NO_AUTHORITY (catchable) 

Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER. 
Runtime Error: OPEN_PIPE_NO_AUTHORITY (catchable) 

CX_SY_PIPES_NOT_SUPPORTED 

CX_SY_TOO_MANY_FILES 

Cause: Maximum number of open files exceeded. 
Runtime Error: DATASET_TOO_MANY_FILES (catchable) 


Non-Catchable Exceptions 

Cause: You tried to open a pipe that is already open. 
Runtime Error: DATASET_PIPE_POSITION&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 21:25:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762675#M1305154</guid>
      <dc:creator>martinborda</dc:creator>
      <dc:date>2009-06-23T21:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762676#M1305155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thaks for your quick reply. This helps me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a final question. What will be the value of SY-SUBRC in case of an exception?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Surya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 22:04:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762676#M1305155</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T22:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762677#M1305156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __jive_macro_name="message" id="6616123"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2009 03:16:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762677#M1305156</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-06-24T03:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762678#M1305157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use sy-subrc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc is ne 0&lt;/P&gt;&lt;P&gt;    " then you have a problem &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use more specific number if you wish... I use and it tends to work well&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2009 03:22:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762678#M1305157</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-24T03:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762679#M1305158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Keith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you said, some errors will just generate a SY-SUBRC NE 0, but not trigger any exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These errors are easily "catchable" with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: l_message   TYPE string.

      OPEN DATASET p_path
           FOR OUTPUT
           IN TEXT MODE ENCODING DEFAULT
           MESSAGE l_message.
 
*     Error
      IF sy-subrc IS NOT INITIAL.
 
        MESSAGE l_message
           TYPE c_error.
 
      ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But another errors will trigger an exception, and if you don't catch them, they will show a nice dump in your program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You catch them with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: l_message   TYPE string,
        o_exception TYPE REF TO cx_root.

  TRY.
 
      OPEN DATASET p_path
           FOR OUTPUT
           IN TEXT MODE ENCODING DEFAULT.
 
...
 
*   Error
    CATCH cx_root
      INTO o_exception.
 
*     Gets error message
      CALL METHOD o_exception-&amp;gt;if_message~get_text
        RECEIVING
          result = l_message.
 
      MESSAGE l_message
         TYPE c_error.
 
  ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's why in the code I posted, you catch both types of errors that OPEN DATASET can generate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2009 14:21:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762679#M1305158</guid>
      <dc:creator>martinborda</dc:creator>
      <dc:date>2009-06-24T14:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762680#M1305159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it Ok to use like the following in Get error message?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Error&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    CATCH cx_root&lt;/P&gt;&lt;P&gt;      INTO o_exception.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Gets error message&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          l_message = o_exception-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      MESSAGE l_message&lt;/P&gt;&lt;P&gt;         TYPE c_error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Surya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2009 20:42:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762680#M1305159</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-24T20:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762681#M1305160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  gr_err TYPE REF TO cx_root,
  gs_msg TYPE string.
*
TRY.
  OPEN DATASET xxx FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    CATCH cx_root INTO gr_err.
      gs_msg = gr_err-&amp;gt;get_text( ).
ENDTRY.
*
IF  gs_msg IS NOT INITIAL.
    WRITE: /001 gs_msg.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From the link I posted before.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2009 21:06:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762681#M1305160</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-06-24T21:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762682#M1305161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it's the same, I just copied and pasted the method name from SE24. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to take SY-SUBRC errors into account too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2009 13:40:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762682#M1305161</guid>
      <dc:creator>martinborda</dc:creator>
      <dc:date>2009-06-25T13:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling with OPEN DATASET</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762683#M1305162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2009 16:01:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-with-open-dataset/m-p/5762683#M1305162</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-25T16:01:34Z</dc:date>
    </item>
  </channel>
</rss>

