<?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: Application log &amp; Assertion Faild problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427726#M1647259</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put the flag  i_in_update_task = ' X'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this case irrespective of the assert statement it will wait for a update task to occur, when that occurs it will save the log.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you dont pass the flag, database update will be called but not in update task and your assert statement wont let it reach the commit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2012 16:06:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-01-11T16:06:07Z</dc:date>
    <item>
      <title>Application log &amp; Assertion Faild problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427725#M1647258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAP community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;does SAP support writting log messages not into database but into log file? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;My Problem:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to check if the bal messages would be saved in database even if an ASSERTION_FAILED occures. As you see in the report below, the function 'BAL_DB_SAVE'  doesn't really save the logs directly into the database table but it waits until a COMMIT WORK is executred which means if any ASSERTION-FAILED occurs in between no BAL will be saved and I'll loose the traces of my program flow which I've written in that BAL handler. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bahjat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a short report demonstrating my problem. &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;
REPORT  Z_BAL_AFTER_ASSERT_TEST.

PARAMETERS: pv_x  type abap_bool as CHECKBOX.


data:
      lv_bool type abap_bool,
      lt_but  type table of but000,
      ls_but  type but000.


DATA: lv_log_handle        TYPE                   balloghndl,
      ls_log               TYPE                   bal_s_log,
      ls_msg               TYPE                   bal_s_msg,
      lv_msgno             TYPE                   symsgno,
      lt_log_handle        TYPE                   bal_t_logh.
* -------------------------------------------------------------------------------------


START-OF-SELECTION.


* Start BAL Logging
* -----------------------------------------------------------------
CONCATENATE sy-datum sy-uzeit INTO ls_log-extnumber SEPARATED BY space.  "Unique number for the current log
ls_log-object    = 'ZSALBAH_BAL'. "See table BALOBJ for possible entries (new entries via SLG0) CRM_DOCUMENT
ls_log-subobject = 'BAL_TEST'.      "See table BALSUB for possible entries (new entries via SLG0) SINGLE

* Initialize BAL Logging (see TX SLG1)
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
  i_s_log      = ls_log
IMPORTING
  e_log_handle = lv_log_handle
EXCEPTIONS
  OTHERS       = 1.
IF sy-subrc &amp;lt;&amp;gt; 0.
  MESSAGE ID sy-msgid
  TYPE sy-msgty
  NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  EXIT.
ENDIF.
* -----------------------------------------------------------------

ls_msg-msgid     = 'ZCRM'.
ls_msg-msgno     = '000'.
ls_msg-msgty     = 'S'.
ls_msg-probclass = '3'.

CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
  i_log_handle = lv_log_handle
  i_s_msg      = ls_msg
EXCEPTIONS
  OTHERS       = 1.
IF sy-subrc &amp;lt;&amp;gt; 0.
  MESSAGE ID sy-msgid
  TYPE sy-msgty
  NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*   --------------------------------------------------------------------




* Save log
* -----------------------------------------------------------------
APPEND lv_log_handle TO lt_log_handle.
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
  i_in_update_task = ' '
  i_save_all       = ' '
  i_t_log_handle   = lt_log_handle
EXCEPTIONS
  log_not_found    = 1
  save_not_allowed = 2
  numbering_error  = 3
  OTHERS           = 4.

IF sy-subrc &amp;lt;&amp;gt; 0.
  MESSAGE ID sy-msgid
  TYPE sy-msgty
  NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* -----------------------------------------------------------------


IF pv_x = abap_true.  
  ASSERT 1 = 2.
endif.

COMMIT WORK.


write lv_bool.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 15:53:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427725#M1647258</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-11T15:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Application log &amp; Assertion Faild problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427726#M1647259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put the flag  i_in_update_task = ' X'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this case irrespective of the assert statement it will wait for a update task to occur, when that occurs it will save the log.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you dont pass the flag, database update will be called but not in update task and your assert statement wont let it reach the commit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 16:06:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427726#M1647259</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-11T16:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Application log &amp; Assertion Faild problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427727#M1647260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the fast reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to set the flag flag i_in_update_task = ' X' too but it seems that doesn't help too. the COMMIT WORK will never be executed when assertion_failed occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody know an &lt;STRONG&gt;alternative to BAL&lt;/STRONG&gt;  ? for example writing the logs into a file instead into database?&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;Bahjat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jan 2012 08:08:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427727#M1647260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-12T08:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Application log &amp; Assertion Faild problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427728#M1647261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since this was the first search result for this issue I want to share some solutions from &lt;A href="https://wiki.scn.sap.com/wiki/display/Snippets/Application+Logging+in+SAP+Using+ABAP" title="https://wiki.scn.sap.com/wiki/display/Snippets/Application+Logging+in+SAP+Using+ABAP"&gt;Application Logging in SAP Using ABAP - Code Gallery - SCN Wiki&lt;/A&gt; (and the comments, h/t Ben Meijs) which should work in most scenarios:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;As of 731:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Use second connection parameters (2th +2th_commit) of BAL_DB_SAVE set to abap_true&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Legacy handling:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Issue explicit Commit (e.g. COMMIT WORK) directly after BAL_DB_SAVE with update task parameter&lt;/LI&gt;&lt;LI&gt;Call BAL_DB_SAVE inside an RFC-Wrapper with destination NONE&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I should note another finding: BAL_DB_LOAD only exports a handle if the log is not already loaded yet -&amp;gt; use parameter i_exception_if_already_loaded, catch the exception and use BAL_GLB_SEARCH_LOG to find a recently saved log which is still in memory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2016 08:29:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/8427728#M1647261</guid>
      <dc:creator>tho_hoffmann</dc:creator>
      <dc:date>2016-08-03T08:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Application log &amp; Assertion Faild problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/13685423#M2027835</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I solved my problem regarding your comment. Thanks.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used parameters (2th +2th_commit) of BAL_DB_SAVE set to abap_true.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 07:55:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/application-log-assertion-faild-problem/m-p/13685423#M2027835</guid>
      <dc:creator>Abdelkun</dc:creator>
      <dc:date>2024-04-29T07:55:34Z</dc:date>
    </item>
  </channel>
</rss>

