<?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: Dynamic Field - Exception in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068196#M1355118</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 this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure you pass the relevant field name in CAPS to P_STAT before the select query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single (P_stat)&lt;/P&gt;&lt;P&gt;from K810008&lt;/P&gt;&lt;P&gt;into LV_STAT    " LV_STAT is a variable of type ANY&lt;/P&gt;&lt;P&gt;where gjahr = p_year and&lt;/P&gt;&lt;P&gt;perde = p_period.&lt;/P&gt;&lt;P&gt;if sy-subrc 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MESSAGE e000 WITH text-s05.&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Sep 2009 12:56:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-09-14T12:56:00Z</dc:date>
    <item>
      <title>Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068195#M1355117</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 need to raise exception in a select statement.  Is it possible,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to check whether a particular field is present in a table rather than a value.  If not, need to raise error,.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single (P_stat)&lt;/P&gt;&lt;P&gt;       from K810008&lt;/P&gt;&lt;P&gt;       into (p_Stat)&lt;/P&gt;&lt;P&gt;       where gjahr = p_year and&lt;/P&gt;&lt;P&gt;             perde = p_period.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MESSAGE e000 WITH text-s05.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following gives a dump cos the field name is given wrongly, i cant capture it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 12:46:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068195#M1355117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T12:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068196#M1355118</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 this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure you pass the relevant field name in CAPS to P_STAT before the select query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single (P_stat)&lt;/P&gt;&lt;P&gt;from K810008&lt;/P&gt;&lt;P&gt;into LV_STAT    " LV_STAT is a variable of type ANY&lt;/P&gt;&lt;P&gt;where gjahr = p_year and&lt;/P&gt;&lt;P&gt;perde = p_period.&lt;/P&gt;&lt;P&gt;if sy-subrc 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MESSAGE e000 WITH text-s05.&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 12:56:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068196#M1355118</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T12:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068197#M1355119</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;After you get a dump goto transaction ST22 and find the class exception of the dump you are getting. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the class exception is cx_division_by_zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then code like the below,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: error type ref to cx_division_by_zero.

try.

select single (P_stat)
from K810008
into (p_Stat)
where gjahr = p_year and
perde = p_period.

catch cx_division_by_zero into error.
endtry.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the reference variable error will hold the dump error which can be displayed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the relevant class exception instead of cx_division_by_zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vikranth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 12:56:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068197#M1355119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T12:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068198#M1355120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Krish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rather than catching the error after receiving it, you should look before your query in table DD03L if the field exists in this table! &lt;/P&gt;&lt;P&gt;Example of code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM dd03l
  WHERE tabname = 'K810008' AND
               fieldname = p_stat.
IF sy-subrc = 0.
SELECT SINGLE (p_stat)
  FROM K810008
  INTO (p_stat)
  WHERE gjahr = p_year AND
        perde = p_period.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Samuel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 13:07:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068198#M1355120</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T13:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068199#M1355121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT * FROM dd03l
  WHERE tabname = 'K810008' AND
               fieldname = p_stat.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would work only if p_stat is a single field either valid or invalid. But since its dynamic and if you are concatenating two fields, even if both fields are valid, the above select would fail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 13:22:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068199#M1355121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T13:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Field - Exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068200#M1355122</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;we can catch the  exception with the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY.&lt;/P&gt;&lt;P&gt;select single (P_stat)&lt;/P&gt;&lt;P&gt;from K810008&lt;/P&gt;&lt;P&gt;into (p_Stat)&lt;/P&gt;&lt;P&gt;where gjahr = p_year and&lt;/P&gt;&lt;P&gt;perde = p_period.&lt;/P&gt;&lt;P&gt;    RAISE EXCEPTION TYPE CX_SY_DYNAMIC_OSQL_SEMANTICS.  &lt;/P&gt;&lt;P&gt;  CATCH CX_SY_DYNAMIC_OSQL_SEMANTICS.&lt;/P&gt;&lt;P&gt;    WRITE:/5 'Exception caught'.&lt;/P&gt;&lt;P&gt;ENDTRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ashok&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 13:24:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-exception/m-p/6068200#M1355122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T13:24:51Z</dc:date>
    </item>
  </channel>
</rss>

