<?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: Try-Catch exceptionin ABAP.... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229284#M1208851</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jainam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.

SUBMIT &amp;lt;ZPROGRAM&amp;gt; AND RETURN.

CATCH &amp;lt;EXCEPTION ID&amp;gt;.

ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will solve your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hareesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Feb 2009 01:36:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-26T01:36:29Z</dc:date>
    <item>
      <title>Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229282#M1208849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In my code I am submitting another program. Now the programn that should be submitted is based in a configuration. So if the program is not present in the configuration, then I would like to catch error using try-catch execption stuff isntead of giving dump. Can somebody help on this ?&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;Jainam,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2009 22:40:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229282#M1208849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-25T22:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229283#M1208850</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;check if the program exists in TRDIR table before using it in SUBMIT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: v_program TYPE syrepid.

v_program = 'ZTEST122'.

SELECT SINGLE name INTO v_program
              FROM trdir
              WHERE name = v_program.

IF sy-subrc = 0.

  SUBMIT (v_program) AND RETURN.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2009 23:04:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229283#M1208850</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-25T23:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229284#M1208851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jainam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.

SUBMIT &amp;lt;ZPROGRAM&amp;gt; AND RETURN.

CATCH &amp;lt;EXCEPTION ID&amp;gt;.

ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will solve your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hareesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 01:36:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229284#M1208851</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T01:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229285#M1208852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jainam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please use the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: oref   TYPE REF TO cx_root, 
           text   TYPE string. 

TRY. 
Submit &amp;lt;your Report Name&amp;gt; with &amp;lt; parameters&amp;gt; and return.
  CATCH &amp;lt;the exception name&amp;gt; INTO oref. 
    text = oref-&amp;gt;get_text( ). 
  CATCH cx_root INTO oref. 
    text = oref-&amp;gt;get_text( ). 
ENDTRY. 

IF NOT text IS INITIAL. 
  WRITE / text. 
ENDIF. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 03:59:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229285#M1208852</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T03:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229286#M1208853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jainam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best solution would be to implement how Narendran has specified. The TRY-CATCH-ENDTRY block will not work in a SUMBIT statement because LOAD_PROGRAM_NOT_FOUND is a non-catchable exception. I quote from ABAP documentation for SUBMIT statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Non-Catchable Exceptions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cause: The specified program was not found. &lt;/P&gt;&lt;P&gt;Runtime Error: LOAD_PROGRAM_NOT_FOUND &lt;/P&gt;&lt;P&gt;Cause: You tried to transfer an invalid value to a selection using the addition SIGN. &lt;/P&gt;&lt;P&gt;Runtime Error: SUBMIT_WRONG_SIGN &lt;/P&gt;&lt;P&gt;Cause: The specified program is not a report. &lt;/P&gt;&lt;P&gt;Runtime Error: SUBMIT_WRONG_TYPE &lt;/P&gt;&lt;P&gt;Cause: You tried to transfer more than one value to a report parameter. &lt;/P&gt;&lt;P&gt;Runtime Error: SUBMIT_IMPORT_ONLY_PARAMETER &lt;/P&gt;&lt;P&gt;Cause: You tried to use WITH sel IN itab to transfer a table that does not have the appropriate structure to a selection. &lt;/P&gt;&lt;P&gt;Runtime Error: SUBMIT_IN_ITAB_ILL_STRUCTURE &lt;/P&gt;&lt;P&gt;Cause: You tried to transfer a parameter that cannot be converted to the target field to the selection screen. &lt;/P&gt;&lt;P&gt;Runtime Error: SUBMIT_PARAM_NOT_CONVERTIBLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not even try to CATCH the SUBMIT as some of the others have suggested out because it is a &lt;STRONG&gt;NON-CATCHABLE Exception&lt;/STRONG&gt;. As soon as the ABAP run-time hits the SUBMIT, it will immediately short-dump even if you have a TRY-CATCH block with an exception class.... so better to check it against table TRDIR before SUMBIT. I recently had to do a similar check before SUBMIT, so this is how I did it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Calling Program&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    ............................  .....................
    read table lt_zft_buff_vers into ls_vers index 1.
    ev_prog_name = ls_vers-prog_name.
" Config was found - now check if the program name is valid and it is Type '1'
    if zcl_f_buff_config=&amp;gt;check_veh_prog_name( ev_prog_name ) is not initial.  "&amp;lt;---- check
        ev_prog_name = ls_vers-vr_abap_name.
        submit (ev_prog_name)
           with pa_bukrs eq pa_bukrs
           with pa_email eq pa_email
           with pa_herm  eq pa_herm
           with pa_msg1  eq pa_msg1
           with pa_msg2  eq pa_msg2
           with pa_optio eq pa_optio
           with pa_mthyr eq pa_mthyr
         and return.
    else.
" Program not found in program directory - (could be a typo in the customizing table)
" OR the program name entered is not an executable program (Type '1')
" we handle this here so that it does not short-dump
      message a011(zf_vr_messages)
      with ev_prog_name
      raising program_not_found.
    endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Method&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
method check_veh_prog_name.

" RV_EXIST = X -&amp;gt; program exists and program type = '1' (Executable)
" RV_EXIST = space -&amp;gt; program does not exist or program type &amp;lt;&amp;gt; '1'

    data: ls_trdir type trdir.

    select single * from  trdir into ls_trdir
                    where name = iv_program.

    check sy-subrc = 0.

    check ls_trdir-subc = '1'.

    rv_exist = lcl_gc=&amp;gt;gc_true.

endmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 04:59:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229286#M1208853</guid>
      <dc:creator>Sougata</dc:creator>
      <dc:date>2009-02-26T04:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Try-Catch exceptionin ABAP....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229287#M1208854</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;try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;submit &amp;lt;report&amp;gt; with &amp;lt;parameters&amp;gt; and return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATCH &amp;lt;exceptions&amp;gt;.&lt;/P&gt;&lt;P&gt;&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;Jyothi CH.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 05:04:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-catch-exceptionin-abap/m-p/5229287#M1208854</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T05:04:57Z</dc:date>
    </item>
  </channel>
</rss>

