<?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: customized text messages in class based exceptions in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595373#M1436529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;simply..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* implementation
METHOD SELECT
  EXCEPTION TYPE ZX_XYZ.

select ... from mara...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MARA' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
select ... from makt...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MAKT' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
select ... from mard...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MARD' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
ENDMETHOD.

* Program call
TRY.
  select().
  catch  ZX_XYZ.
  message ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDTRY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the very simplified version without log objects - that would go beyond the limit...&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;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Feb 2010 00:29:48 GMT</pubDate>
    <dc:creator>Clemenss</dc:creator>
    <dc:date>2010-02-06T00:29:48Z</dc:date>
    <item>
      <title>customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595369#M1436525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;       I am using the class based exception to raise SQL query exception using CX_SY_SQL_ERROR.I am using 3 select statements in a method and i am raising the error after checking SY-SUBRC.I am catching the error outside the method.&lt;/P&gt;&lt;P&gt;I want to know from which SQL query has failed..eg: &lt;/P&gt;&lt;P&gt;If the database query was successfull and i did not get records for that input I want to have a customized message like 'No records found in MARA',. &lt;/P&gt;&lt;P&gt;If the database connectivity was lost etc, I will get the messages by reading the message from method GET_TEXT.&lt;/P&gt;&lt;P&gt;etc depending on the query at which exception was raised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestion in this regard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;sandeep akella.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sandeep akella on Feb 5, 2010 6:42 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sandeep akella on Feb 5, 2010 6:49 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 05:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595369#M1436525</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-05T05:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595370#M1436526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i fell the exception class object of CX_SY_SQL_ERROR will not be instantiated if the query fails . Moreover the  CX_SY_SQL_ERROR  does not have amy attribute idication any table name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My advise to you is to have a &lt;/P&gt;&lt;P&gt;centralised Z exception class( say zselect_exception) which has attribute TABLE_NAME. &lt;/P&gt;&lt;P&gt;Add a text in the Z excep tion class say NO_DATA_FOUND like 'No data records found in &amp;amp;TABLE_NAME&amp;amp;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So whenever the data exception fails in your select then  use like&lt;/P&gt;&lt;P&gt;raise exception type zselect_exception &lt;/P&gt;&lt;P&gt;  exporting text_id = zselect_exception=&amp;gt;NO_DATA_FOUND&lt;/P&gt;&lt;P&gt;                                                                                table_name = 'MARA'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So outside the method &lt;/P&gt;&lt;P&gt;You catch the same and use get_text method to get the corresponding message.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 07:46:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595370#M1436526</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-05T07:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595371#M1436527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in our project we learned that you will run into trouble if you do not issue a customized message using the message statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In error sistuations, we tend to always use a MESSAGE ... INTO DUMMY with DUMMY defined as a string variable. After issuing this dummy message, we raise an exception and/or add the message to a protocol object or issue the mesage directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The big advantage is: When users see a message regardless of context we can check the where-used-list and find the error source quickly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When people started this big project years ago they also worked with get_text methods and then issued generic error messages. Now it is extremely difficult to determine the exact source of the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAP used the way of coding "IF 1 = 2. MESSAGE &amp;lt;ID&amp;gt; &amp;lt;TYPE&amp;gt; &amp;lt;NUMBER&amp;gt;.ENDFIF. just to create a whre-used-list-entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I think is is far better to use a MESSAGE INTO DUMMY statement: You create a where-used-lust entry, you can see the full error text in debugger and you can use the SY-MSG++ variables for any subsequent handling.&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;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 12:57:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595371#M1436527</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-02-05T12:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595372#M1436528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Clemens,&lt;/P&gt;&lt;P&gt; Could you explain in details may be with an example.&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;sandeep akella.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 13:08:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595372#M1436528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-05T13:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595373#M1436529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;simply..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* implementation
METHOD SELECT
  EXCEPTION TYPE ZX_XYZ.

select ... from mara...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MARA' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
select ... from makt...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MAKT' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
select ... from mard...
if sy-subrc &amp;lt;&amp;gt; 0.
  message ID ZXY TYPE E NUMBER 123 WITH 'MARD' into mv_dummy.
  raise EXCEPTION TYPE ZX_XYZ..
endif.
ENDMETHOD.

* Program call
TRY.
  select().
  catch  ZX_XYZ.
  message ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDTRY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the very simplified version without log objects - that would go beyond the limit...&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;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2010 00:29:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595373#M1436529</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-02-06T00:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: customized text messages in class based exceptions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595374#M1436530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Clemens,&lt;/P&gt;&lt;P&gt;   Thank you for the solution. It solved my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regards,&lt;/P&gt;&lt;P&gt;sandeep akella&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2010 06:14:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/customized-text-messages-in-class-based-exceptions/m-p/6595374#M1436530</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-08T06:14:30Z</dc:date>
    </item>
  </channel>
</rss>

