<?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: Autonomous database transaction in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263596#M490994</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would be grateful for any other solution to log messages in an ABAP (BSP) application. &lt;/P&gt;&lt;P&gt;I've also find to write system logs (SM21) outof the application, but this is overkill I think.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 May 2007 14:10:34 GMT</pubDate>
    <dc:creator>Torsten_</dc:creator>
    <dc:date>2007-05-16T14:10:34Z</dc:date>
    <item>
      <title>Autonomous database transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263594#M490992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'll log some application information in a local table like this:&lt;/P&gt;&lt;P&gt;Here a pseudocode example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;funktion mainFunction{

  "INSERT something"
  log(count of inserted rows).
  do something other 
  on error COMMIT eles ROLLBACK
}

function log(message){
 insert message into log-table.
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case of an error in the mainFunction the ROLLBACK will also rollback the log information. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the ORACLE world I've solved the problem by using the PRAGMA autonomous_transaction&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;funktion mainFunction{

  "INSERT something"
  log(count of inserted rows).
  do something other 
  on error COMMIT eles ROLLBACK
}

function log(message){
 Pragma autonomous_transaction. 
insert message into log-table.
 COMMIT.
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The COMMIT in the log function has no effect to the insert in the mainFunction. IN case of an error and a rollback in the mainFunction the log entry is any longer in the log-table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So on in the ORACLE world, but what can I do in SAP (with openSQL) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Torsten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 13:58:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263594#M490992</guid>
      <dc:creator>Torsten_</dc:creator>
      <dc:date>2007-05-16T13:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Autonomous database transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263595#M490993</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;refer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2818117"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Award points if it helps.&lt;/P&gt;&lt;P&gt;-Gaurang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 14:06:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263595#M490993</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T14:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Autonomous database transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263596#M490994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would be grateful for any other solution to log messages in an ABAP (BSP) application. &lt;/P&gt;&lt;P&gt;I've also find to write system logs (SM21) outof the application, but this is overkill I think.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 14:10:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263596#M490994</guid>
      <dc:creator>Torsten_</dc:creator>
      <dc:date>2007-05-16T14:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Autonomous database transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263597#M490995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;no this ref doesn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;funktion mainFunction{
   try

    "INSERT something"
    log(count of inserted rows).

    "INSERT something else"
    log(log status message).
    
    COMMIT
 catch
    ROLLBACK
}
 
function log(message){
 insert message into log-table.
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both inserts can only commited together (business logic / not technical view). In case an exception or error occurs by inserting the second one the catch branch will rollback all informtaion, also the log information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution from your ref will mean:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function log(message){
  insert message into log-table.
  if sy-subrc ne 0.
  rollback work.
  exit.
  endif. 
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this solution has the effect, that the first log entry also commit the first insert in the mainFunction. In case of an error by inserting the second one a rollback from the first insert isn't possible.&lt;/P&gt;&lt;P&gt;Torsten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 14:46:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/autonomous-database-transaction/m-p/2263597#M490995</guid>
      <dc:creator>Torsten_</dc:creator>
      <dc:date>2007-05-16T14:46:21Z</dc:date>
    </item>
  </channel>
</rss>

