Application Logging in ABAP

Hello,
     we are trying to use application logging feature provided with ABAP by way of function modules BAL_LOG_ADD/SAVE etc. the results of these are visible in trasnaction SLG1.
    In our scenario, we want to keep track of different abnormal situations which a background Job of a user with dialogue operation faces. So these situations could be part of a successful or un-successful transactions i.e. there could be and overall COMMIT or ROLLBACK for each transactions for which the log operations have been carried out.
    Now the problem is that , the Logs are not getting saved for unsuccessful transactions i.e. where there is no COMMIT.
     I need your help to get over this situation so that I able to save the Logs (in standard Log objects which are visiible in  SLG1) even if the business transaction is not committed.
regards
Sushil

How come code always looke like this? I cut and pasted it right in my replay. Highlighted it, and selected "code"?
Oh well, here is the FM I call I tried several times to get it to display properly.
FUNCTION ziu_message_logging.
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(I_LOG_OBJECT) TYPE  BALOBJ_D
*"     REFERENCE(I_EXTNUMBER) TYPE  STRING
*"  TABLES
*"      T_LOG_MESSAGE STRUCTURE  ZZLOG_MESSAGE
*"  EXCEPTIONS
*"      LOG_HEADER_INCONSISTENT
*"      LOGGING_ERROR
  CONSTANTS: c_message TYPE syst-msgid VALUE 'ZMESSAGE',
             c_999 TYPE syst-msgno VALUE '999'.
  DATA:
  l_log_handle TYPE balloghndl,
  l_s_log TYPE bal_s_log,
  l_dummy TYPE string,
  l_ext_no TYPE bal_s_log-extnumber,
  l_s_mdef TYPE bal_s_mdef.
*  IF t_log_message[] IS NOT INITIAL.
    l_s_log-object = i_log_object.
    l_ext_no = i_extnumber.
    l_s_log-extnumber = l_ext_no.
* Create the log with header data
    CALL FUNCTION 'BAL_LOG_CREATE'
         EXPORTING
              i_s_log                 = l_s_log
         IMPORTING
              e_log_handle            = l_log_handle
         EXCEPTIONS
              log_header_inconsistent = 1
              OTHERS                  = 2.
    IF sy-subrc <> 0.
      CASE sy-subrc.
        WHEN 1.
          RAISE log_header_inconsistent.
        WHEN OTHERS.
          RAISE logging_error.
      ENDCASE.
    ENDIF.
    l_s_mdef-log_handle = l_log_handle.
* Set the default value
    CALL FUNCTION 'BAL_GLB_MSG_DEFAULTS_SET'
         EXPORTING
              i_s_msg_defaults = l_s_mdef
         EXCEPTIONS
              others = 0.
* Loop the message table and write the messages into the log
    LOOP AT t_log_message.
* Use the message type ZMESSAGE and msg no 999
* Issue the message in a dummy variable
      MESSAGE ID c_message TYPE t_log_message-msgty NUMBER c_999
      WITH t_log_message-msg_text_1 t_log_message-msg_text_2
      t_log_message-msg_text_3 t_log_message-msg_text_4
      INTO l_dummy.
* The parameters set by message statement will be used
* Add the message in the log
      PERFORM msg_add.
    ENDLOOP.
* save logs in the database
    CALL FUNCTION 'BAL_DB_SAVE'
         EXPORTING
              i_save_all       = 'X'
         EXCEPTIONS
              log_not_found    = 1
              save_not_allowed = 2
              numbering_error  = 3
              OTHERS           = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
*  ENDIF.
endfunction.
* FORM MSG_ADD
* Add the message to the log
FORM msg_add.
  DATA:
  l_s_msg TYPE bal_s_msg.
* define data of message for Application Log
  l_s_msg-msgty = sy-msgty.
  l_s_msg-msgid = sy-msgid.
  l_s_msg-msgno = sy-msgno.
  l_s_msg-msgv1 = sy-msgv1.
  l_s_msg-msgv2 = sy-msgv2.
  l_s_msg-msgv3 = sy-msgv3.
  l_s_msg-msgv4 = sy-msgv4.
* add this message to log file
* (I_LOG_HANDLE is not specified, we want to add to the default log.
* If it does not exist we do not care =>EXCEPTIONS log_not_found = 0)
  CALL FUNCTION 'BAL_LOG_MSG_ADD'
  EXPORTING
* I_LOG_HANDLE =
  i_s_msg = l_s_msg
  EXCEPTIONS
  log_not_found = 0
  OTHERS = 1.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.
Edited by: Tom Matys on Mar 9, 2010 1:15 PM

Similar Messages

  • Application logging in SLG1..

    Hello Gurus,
    I want to know how can I insert message to application log through ABAP. In one of the programs following condition occurs. When this happens , I want the error message to be written to error log so that later it can be accessed by SLG1 T-code.
    IF SY-SUBRC <> 0.
            lv_error_msg = 'User Workitem creation failed'.
      ENDIF.
    Please help.
    Regards,
    Tushar.

    Please refer to the below thread and look for Sandra Rossi's answer
    Re: How to create info. bar/window which displays success and error messages

  • How to make a downloadable report of application log file.

    Hi Every One,
    i am new to this ABAP environment, I have application logs in my system, i need to generate the reports based on my filter condition and i need to download them as file/report, For example;
    I need a Application Log report for:
    only Particular User
    only particular time
    only importent logs
    only errors
    like that....so on..
    Can any one give me step by step, how to make a report of application logs, i know only i can see logs use transaction CodeSLG1. I want to make report them.
    Thank you
    Regards
    Ravi

    Found answer in log itself

  • Calling error/application logs in CRM inbound proxy

    Hi All,
    In inbound proxy of CRM, I have to call Error/Application logs (for eg:SLG1) whenever an integration process throws some error. Has anyone worked on this kind of scenario to call different application logs in CRM or R3 side inbound proxy.
    If so, please give some ideas on this.
    Thanks
    Deno

    Hi Deno,
    did you have a look at my blog in which I describe it ?
    /people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility
    Regards,
    michal

  • How to create Application Log

    Hi,
    I have written a report which gathers errors in a test data container.
    These errors are stored in a internal table of type stringtab.
    I want to create a Application Log of these errors so that the user can
    view it at a later time.
    Are there predefined function modules available in ABAP for creating and viewing log?
    Kindly provide me the details.
    Regards,
    Bikash.

    Hi Monika,
    Is it necessary to  add messages from message class in
    BAL_LOG_MSG_ADD --> Put message in log.
    Is there any way where a string can also be added and viewed from a application
    log?
    For my use case i actually have a stringtab for which i want to have a log.
    Regards,
    Bikash.

  • Application logs for log handling in lsmw idoc method

    Hi Abapers,
          Im using LSMW IDOC method for data transfer from legacy to sap system.Now the requirement is to handle application logs for log handling i.e i have to make use of custom report to handle logs,can any one tell me what all steps to be done for this or if any one can share a link related to application logs would be greatly appreciated.
    Thanks.
    Edited by: saeed.abap on Dec 27, 2011 5:13 PM

    Hi Saeed,
    Please check with this fms
    1) BAL_DSP_LOG_DISPLA
    2) APPL_LOG_READ_DB
    3) IDOC_GET_MESSAGE_ATTRIBUTE
    There is a wiki [Error Log Lsmw|http://wiki.sdn.sap.com/wiki/display/Snippets/ErrorLogProgramforBAPIandIDocMethodin+LSMW] available.
    Regards,
    Madhu.
    Edited by: madhurao123 on Dec 28, 2011 8:25 AM

  • Writing Application Log of SAP PI

    Hi All,
    I have a requirement to update the Application Log of SAP PI 7.1 with Ehp1 whenever mapping for a particular pair of Sender and Receiver is executed.
    SenderA (JMS) -> SAP PI (update Application Log; SLG1) -> ReceiverA (JMS).
    I have already seen this blog: /people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility but it seems to be written long back.
    How should this be done in PI?
    Thanks
    Pankaj

    You can do this with an RFC lookup in message mapping, or with a BPM by calling an abap proxy that post a log in SLG1.

  • How to determine SLG1 Application Log Size

    Hi, Can anyone tell me how we might be able to determine the size of our SLG1 Application Logs on our BW System?
    We want to be sure they are not taking up too much space.  If they are we'll purge with SLG2, and if not then we will keep them around.
    Thanks!

    Hello,
    system does writes the application log in to the database.
    SAP_COLLECTOR_FOR_NONE_R3_STAT is designed to collect non ABAP Statistic Data in/for a central repository.
    look service.sap.com/notes and search for SAP_COLLECTOR_FOR_NONE_R3_STAT
    Hope it will hep you.
    Regards,

  • Table that stores the application logs messages for transaction CRMD_ORDER

    Hi Guru's,
    I would like to know which CRM table that is used to store application logs (consist of error / warning / information messages) in transaction CRMD_ORDER? I would like to retrieve the text messages of the application log.
    Thanks.

    Hi there,
    The logs are on tables BALHDR (header) and BALDAT (detail).
    In BALHDR you can fill OBJECT with 'CRM_DOCUMENT' and EXTNUMBER with the document GUID (you can obtain it in CRMD_ORDERADM_H table).
    The BALDAT is a cluster table, so the information is a little 'encoded' there for direct consulting without abap code.
    Alternatively, you can use FM APPL_LOG_READ_DB to read the messages that are contained in any CRM document.
    Kind regards,

  • Who uses Application Logs?

    Hey there, I just wanted to understand more about the usage of application logs.  Do any of you use it for debugging/analysis purposes of your applications?  For those that use it, would you mind explain how you use it etc.
    Sorry, I'm pretty much an ABAP newbie.

    I used Application Logs to get errors or other messages for RFC Calls etc in most of my Custom BAPIs.
    See this\
    http://help.sap.com/saphelp_nw04/helpdata/en/3a/c8263712c79958e10000009b38f936/content.htm
    It doesnt help you much but definetly gives you some idea.
    There are a bunch of function modules to help in getting Application Logs. Theoritically an Application Log is similar to System Log. But System Log is for the whole SAP system where are an Application log is specific to the Custom Object (and sometimes even sub-object) that you create and assign to.
    Pros: If improves performance by reducing number of database hits and writing the logs locally.
    Cons: A lot of effort is needed for initial setup.
    If this helps, award points suitably.

  • Custom error message in SAP application log

    Is there a way to add a custom error message to the SAP application log without passing the message variables MSGV1, MSGV2, MSGV3, MSGV4 and the Message class and number. 
    We want to pass a custom message from the BAPIRET2-MESSAGE without giving it a Message class and number.  The reason for this is that  we are using class based exceptions instead of the traditional message class with errors.  When we catch the class based exception, we take the error text of the exception and put in in the BAPIRET2-message and set the BAPIRET2-TYPE as 'E'.  Now we want to add this to the SAP application log.
    The call to 'BAL_LOG_MSG_ADD' takes a structure BAL_S_MSG which is just like BAPIRET2.  However this function builds the entry to the application log use the message variables MSGV1, MSGV2, MSGV3, MSGV4.  There is no provision to pass in the BAPIRET2 message.
    Add message to application log
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
         i_log_handle              = app_log_handle
         i_s_msg                   = log_message
    Thanks,
    Jay

    Hi Jay,
    Did you see <b>BAL_LOG_EXCEPTION_ADD</b>?
    This FM is represented by the structure <b>BAL_S_EXC</b>. This can have various versions as described below:
    <b>Data of BAL_S_EXC Structure  /     Use</b>
    <b>EXCEPTION</b>  /                              Exception class from which an exception text 
                                                       is added to the log. This field must be filled.
    <b>MSGTY</b>  /                                     Message type (MSGTY) of a T100 message.
                                                       This field must also be filled for exceptions.
    <b>PROBCLASS,
    DETLEVEL,
    ALSORT, TIME_STMP</b>  /                Message or exception attributes, such as
                                                        problem class (PROBCLASS, for
                                                        example, "very important"), level of detail
                                                        (DETLEVEL, from 1 to 9), sort criterion
                                                        (ALSORT, unrestricted) and timestamp
                                                        (TIME_STMP). These fields can be displayed
                                                        in the log (except TIME_STMP).
    <b>MSG_COUNT</b>   /                            This attribute is not used for exceptions.
    Follow the link below for more details:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/d6/5d7f38f52f923ae10000009b38f8cf/frameset.htm">SAP Help DOc</a>
    Hope this helps.
    Thanks
    Sanjeev

  • Had this error msg in my application log:

    Had this error msg in my application log:
    [21/Feb/2002 10:16:20:7] info: REQ-012: thread add
    [21/Feb/2002 10:16:20:7] info: REQ-012: thread add
    [21/Feb/2002 10:16:20:7] info: ENGINE-ready: ready: 10820
    BASEURL: https://ssunp03.company.com:8081
    strURL: https://ssunp03.company.com:8081/cgi-bin/gx.cgi/AppLogic+EventServerManager
    EventServerHttpInvocation > java.net.MalformedURLException: unknown protocol: https
    **Out of memory, exiting**
    ld.so.1: /pimcreg5/imc/nas/40sp3/nas/usr/java/bin/sparc/native_threads/jre: fatal: /pimcreg5/imc/nas/40sp3/nas/us
    r/java/lib/sparc/native_threads/libjava.so: mprotect failed: Resource temporarily unavailable
    Killed
    Connected to LDAP server on ssunp03.company.com port 1390
    [21/Feb/2002 02:42:49:1] info: ENGINE-class_loader_created: New class loader com.kivasoft.engine.EngineClassLoade
    rNonVersionable@1c14d67f has just been created
    Can anyone share with me his experience about ld.so.1?? What is it and why does it cause my apps server to reboot?

    It looks like you might simply have run out of memory. It just looks like the JRE tried to adjust its memory map and run out space. When mprotect fails the problem probably isn't with the .so itself.
    What are the memory characteristics of your machine? Including the heap and stack space that you allocate for your JVM, as well as the actual physical and swap space available on the server.

  • Any guidelines using RSAL_LOG_WRITE to post message in the application log

    Hi SDN!
    I've programmed a rather complex extractor. As most you will know, the real test is when the extractor goes live in productions;-) So in order to be able to check if everything works as designed - I've customized the extractor in order to post more or less entries in the application logs - This setting can be alterered in the uses system directly.
    I've tested the functionality using RSA3 and the application log is filled as expected. The Application log object is RSFH and everything shows up fine. When tring to use it from BW - The application log gets no entries under object RSAP (Where they normally will end up).
    I'm using the function module RSAL_LOG_WRITE to add entries to the same log as the macroes LOG_WRITE uses.
    Does anybody have any experiance adding entries to the standard application log in the source system when extracting data into BW?
    Best Regards
    Søren Hansen

    Sorry Arkesh,
    I to don't know that how to install the jar files, actually thats the role of BASIS guys.
    Watch the below threads for which jar files we need to deploy and how to deploy the jar files
    Re: Required jar files for using jdbc adapter
    Re: Error in JDBC adapter

  • Error Message in portal application.log

    Hi all,
    There are error messages continually been written to application.log.
    Here is the path.
    $ORACLE_HOME/j2ee/OC4J_Portal/application-deployments/portal/OC4J_Portal_default_island_1/application.log
    We couldn't find out what's wrong.
    Portal Version is 10.1.2.2.0.
    application.log
    07/01/31 16:54:54 portal: [module=RepositoryServlet, ecid=103102642203,1] ERROR: Repository Gateway error: Request Processing Error:
    maxlength.htc: PROCEDURE DOESN'T EXIST
    07/01/31 17:23:44 portal: [module=RepositoryServlet, ecid=133169185626,1] ERROR: Repository Gateway error: Request Processing Error:
    maxlength.htc: PROCEDURE DOESN'T EXIST
    07/01/31 17:23:58 portal: Broken pipe
    07/01/31 17:23:58 portal: Broken pipe
    07/01/31 17:23:58 portal: id=146054097151,1 Exception processing portlet response
    java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at com.evermind.server.http.EvermindServletOutputStream.write(EvermindServletOutputStream.java:216)
         at com.evermind.server.http.EvermindServletOutputStream.write(EvermindServletOutputStream.java:151)
         at oracle.webdb.repository.service.RepositoryHttpResponseWrapper$RepositoryOutputStreamWrapper.write(Unknown Source)
         at oracle.webdb.page.CharConvertingOutputStream.write(Unknown Source)
         at oracle.webdb.page.v2.BaseDataProcessor.addToOutputStream(Unknown Source)
         at oracle.webdb.page.v2.BaseDataProcessor.includePortlet(Unknown Source)
         at oracle.webdb.page.v2.BaseDataProcessor.parseLayout(Unknown Source)
         at oracle.webdb.page.v2.BaseDataProcessor.assemblePage(Unknown Source)
         at oracle.webdb.page.v2.BaseDataProcessor.process(Unknown Source)
         at oracle.webdb.page.PageBuilder.process(Unknown Source)
         at oracle.webdb.page.Main.doRequest(Unknown Source)
         at oracle.webdb.page.ParallelServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:834)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
         at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:260)
         at oracle.webdb.portal.servlet.PortalServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:834)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:228)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    ----------------------

    $ORACLE_HOME/j2ee/OC4J_Portal/application-deployments/portal/OC4J_Portal_default_island_1/application.log
    os the log of the "parent application". This is rather high level in the container. The message in the logfiles tells you that a procedure doesn't exist.
    This can mean 3 things:
    1. The procedure really doesn't exist
    2. The procedure expects different parameters then passed
    3. In the procedure a specific array member is called (but not found). (don't know how to explain this better in English, sorry for that).
    It has been a while since I touched portal. In the past portal used a DAD (located in your HTTP-Server configuration). By changing the error style of the dad, you might find a more comprohensive error message.

  • How to add custom error message in standard application log of change doc.

    Hi,
    While saving chnage document I need to add raise an error on specific condition. As Error messages is being shown in application log I added custom message in include LCRM_1O_UIF15 by using BAL_LOG_MSG_ADD FM however it is not showing in the screen. What could be the reason? Can anybody please explain?
    Rgds
    Sudhanshu

    Muhammed,
    Have you tried throwing a JboException in your AM code?
    John

Maybe you are looking for

  • Does anyone have a daily report for system status?

    Basically, I am looking for an automated daily report to give me the status of jobs and workflows.  I am having a hard time finding the talbes and relationships for all the jobs, workflows, and tasks in the CMDB. Once I know where to find all the pie

  • An easy way to make a text box blink??

    Hello everyone! So I can make a graphic symbol blink easy enough, but I am trying to "simulate" an electronic LCD screen, so I would like to display the value of a variable in a dynamic text box and make it blink. The idea is kind of like an alarm cl

  • Lumia 800 in south africa

    when will the lumia 800 become available in south African?

  • A question about users assigned roles extraction

    Dear all, I have a question about users assigned roles list extraction. I need the list of the users who have already been created along with their assigned roles. According to what I found on Google, there is a table named AGR_USERS which provides t

  • FileContentConvesation.(Recordset Structure)

    If the record is mandary and comes only once we declare in recordset structure as record,1 if record has multiple occurences we declare as record,* if the record id optional .....??  what  we need to give ??recordset structure.  Thanks sagar