<?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: BAPI return error message in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-return-error-message/m-p/9017472#M1699247</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kosmo,&lt;/P&gt;&lt;P&gt;This is because the code inside the BAPI is not written the way it should have been. Instead of populating the return table it is raising the message with Message command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to trap it. use this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_ASSET_ACQUISITION_POST'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;error_message = 99.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to add the code written in bold in addition to the BAPI call. It will trap the error and will not throw any error in the screen. In order to know the error you can use system variable like SY-MSGID, SY-MSGNO, SY-MSGTY and SY-MSGV1 to SY-MSGV4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So add the following code after the BAPI call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 99.&lt;/P&gt;&lt;P&gt;****convert the message to message text using simple coding or FORMAT_MESSAGE/ MESSAGE_TEXT_BUILD FMs&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Sep 2012 12:18:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-09-26T12:18:12Z</dc:date>
    <item>
      <title>BAPI return error message</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-return-error-message/m-p/9017471#M1699246</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 use BAPI_ASSET_ACQUISITION_POST and when I fill all need data with incorrect field ASSETTRTYP then I got error message on bottom bar&lt;/P&gt;&lt;P&gt;and my program is stop processing. Why this message isn't in return BAPI table but on screen?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 11:59:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-return-error-message/m-p/9017471#M1699246</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-09-26T11:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI return error message</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-return-error-message/m-p/9017472#M1699247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kosmo,&lt;/P&gt;&lt;P&gt;This is because the code inside the BAPI is not written the way it should have been. Instead of populating the return table it is raising the message with Message command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to trap it. use this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_ASSET_ACQUISITION_POST'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;error_message = 99.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to add the code written in bold in addition to the BAPI call. It will trap the error and will not throw any error in the screen. In order to know the error you can use system variable like SY-MSGID, SY-MSGNO, SY-MSGTY and SY-MSGV1 to SY-MSGV4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So add the following code after the BAPI call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 99.&lt;/P&gt;&lt;P&gt;****convert the message to message text using simple coding or FORMAT_MESSAGE/ MESSAGE_TEXT_BUILD FMs&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 12:18:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-return-error-message/m-p/9017472#M1699247</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-09-26T12:18:12Z</dc:date>
    </item>
  </channel>
</rss>

