<?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: How to control an error in a function in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235011#M1629528</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;The FM is having message type E in it, so the system will raise exception for the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid this, you need to validate the same before passing to FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the code of FM it is having around 5-6 error messages in it. You check them before passing to FM and handle the same using precheck condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Sep 2011 14:16:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-27T14:16:45Z</dc:date>
    <item>
      <title>How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235004#M1629521</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'm working with the FM FI_FIND_PAYMENT_CONDITIONS. It works fine but sometimes it fails with the exporting parameter i_bldat. My funtion is into a loop with hundred of lines and I don't which line is making the mistake.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it's possible to use the the sy-subrc&amp;lt;&amp;gt;0 to control the mistake, how can I use it easily to see in which line is the problem? Can anybody give an example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 13:01:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235004#M1629521</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T13:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235005#M1629522</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;Well, you should have something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT itab ASSIGNING &amp;lt;fs&amp;gt;.
   l_tabix = sy-tabix.
"...
   CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS'
    EXPORTING
      i_zterm                 = &amp;lt;fs&amp;gt;-zterm
       i_bldat                = &amp;lt;fs&amp;gt;-bldat
       i_budat                = &amp;lt;fs&amp;gt;-budat
    exceptions
     terms_incorrect          = 1
     terms_not_found          = 2
     no_date_entered          = 3
     no_day_limit_found       = 4
     OTHERS                   = 5.

   IF sy-subrc &amp;lt;&amp;gt; 0.
     "L_TABIX is the index of erroneous entry
  ENDIF.
"...
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 13:13:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235005#M1629522</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T13:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235006#M1629523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Manu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but when the report has finished I get the following message (error):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Indicate the base date for the payment deadline"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is is possible to see the log with the errors or to write something into the &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;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 13:43:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235006#M1629523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235007#M1629524</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 return from FM, check the SY-SUBRC, if it is not equal to zero, then pass all the data to ITAB and finally display it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 13:51:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235007#M1629524</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T13:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235008#M1629525</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;You could for example store the error message with the corresponding keys into a local error table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
IF sy-subrc NE 0.
   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
      INTO ls_err-msg.
   ls_err-key = l_tabix.
   APPEND ls_err TO gt_err.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And display the table gt_err (if not empty) in a SALV grid object at the end of the report...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lr_table   TYPE REF TO cl_salv_table,
      lr_funct   TYPE REF TO cl_salv_functions,
      lr_columns TYPE REF TO cl_salv_columns_table,
 
    CHECK gt_err[] is not INITIAL.                              "Errors found
    TRY.
         CALL METHOD cl_salv_table=&amp;gt;factory
           IMPORTING
            r_salv_table = lr_table
           CHANGING
            t_table      = gt_err.
       CATCH cx_salv_msg.
         EXIT.
    ENDTRY.
 
    lr_funct = lr_table-&amp;gt;get_functions( ).
    lr_funct-&amp;gt;set_all( abap_true ).
    lr_columns = lr_table-&amp;gt;get_columns( ).
    lr_columns-&amp;gt;set_optimize( 'X' ).
 
    lr_table-&amp;gt;display( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manu D'Haeyer on Sep 27, 2011 4:01 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 13:58:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235008#M1629525</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T13:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235009#M1629526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shiva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've something like this:&lt;/P&gt;&lt;P&gt; CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS' "Determine cash discount using ZTERM and document, posting, CPU, base date&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_zterm = p_zterm                  " t052-zterm    Terms of payment key&lt;/P&gt;&lt;P&gt;      i_bldat = p_fent               " bkpf-bldat    Document date&lt;/P&gt;&lt;P&gt;      i_budat = p_fdoc                  " bkpf-budat    Posting date&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    i_cpudt = SY-DATLO          " bkpf-cpudt    System date&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    i_zfbdt = 00000000          " bseg-zfbdt    Base date (optional) default 00000000&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    i_funcl = SPACE             " t020-funcl    Function class from transaction control&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     e_t052 =                    " t052          Payment terms work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      e_zfbdt = i_dzfbdt                   " bseg-zfbdt    Calculated base date&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     e_sklin =                   " sklin         Cash discount&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      TERMS_INCORRECT = 1         "               Cash discount line invalid&lt;/P&gt;&lt;P&gt;      TERMS_NOT_FOUND = 2         "               Key not found in T052&lt;/P&gt;&lt;P&gt;      NO_DATE_ENTERED = 3         "               No import parameters defined&lt;/P&gt;&lt;P&gt;      .  "  FI_FIND_PAYMENT_CONDITIONS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    write 'hello'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whatever it is what I' like to write I don't get to see it, for example, the hello world.&lt;/P&gt;&lt;P&gt;My report finish with the empty screen and the before error message..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 14:06:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235009#M1629526</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T14:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235010#M1629527</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 to use the ERROR_MESSAGE option in the exceptions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS'
    ..............................
   EXCEPTIONS
     TERMS_INCORRECT          = 1
     TERMS_NOT_FOUND          = 2
     NO_DATE_ENTERED          = 3
     NO_DAY_LIMIT_FOUND       = 4
     ERROR_MESSAGE            = 5        "&amp;lt;---- New exception
     OTHERS                   = 6.
  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR_MESSAGE should be triggered if an error message (without an exception) is rasied in the function module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 14:16:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235010#M1629527</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T14:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235011#M1629528</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;The FM is having message type E in it, so the system will raise exception for the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid this, you need to validate the same before passing to FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the code of FM it is having around 5-6 error messages in it. You check them before passing to FM and handle the same using precheck condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 14:16:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235011#M1629528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T14:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235012#M1629529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the Exceptions from the FM. You are not capturing them all. Add &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NO_DAY_LIMIT_FOUND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OTHERS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 14:17:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235012#M1629529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T14:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235013#M1629530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is the problem. I needed more exceptions in my funtion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 15:19:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235013#M1629530</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T15:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to control an error in a function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235014#M1629531</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;&lt;/P&gt;&lt;P&gt;ERROR_MESSAGE is a particular exception option, just like OTHERS and it can used for every function module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 15:37:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-control-an-error-in-a-function/m-p/8235014#M1629531</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-27T15:37:06Z</dc:date>
    </item>
  </channel>
</rss>

