Skip to Content
author's profile photo Former Member
Former Member

Reading data which was wrote using fm BAL_LOG_MSG_ADD

I have two queries:

1) My z program is writing logs Using fn modules





<b>Where can I view the log. Which tcode?</b>

I have seen <b>SM21</b> but there is no entry for my transaction.

2) What is the suitable way of writing log to SAP. My program is Posting goods movements with the help of fn module BAPI_GOODSMVT_CREATE.

Code realted to point 1.


  PERFORM activate_message_header.
  PERFORM msg_add USING lw_bapireturn-type
                       lw_bapireturn-message_v1 lw_bapireturn-MESSAGE+0(15)
                       lw_bapireturn-message_v2 lw_bapireturn-MESSAGE+14(15)
                       lw_bapireturn-message_v3 lw_bapireturn-MESSAGE+29(15)
                       lw_bapireturn-message_v4 lw_bapireturn-MESSAGE+44(15).

FORM activate_message_header .
  DATA: l_s_log    TYPE bal_s_log.

* define some header data of this log
  l_s_log-aluser    = sy-uname.
  l_s_log-altcode   = sy-tcode.

* create a log
      i_s_log                 = l_s_log
      e_log_handle            = w_handle_1
      log_header_inconsistent = 1
      OTHERS                  = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.


FORM msg_add  USING   p_msgty TYPE syst-msgty
                            p_msgid TYPE syst-msgid
                            p_msgno TYPE syst-msgno
                            p_msgv1 TYPE syst-msgv1 p_msgv1_SRC TYPE BALMSGVSRC
                            p_msgv2 TYPE syst-msgv2 p_msgv2_SRC TYPE BALMSGVSRC
                            p_msgv3 TYPE syst-msgv3 p_msgv3_SRC TYPE BALMSGVSRC
                            p_msgv4 TYPE syst-msgv4 p_msgv4_SRC TYPE BALMSGVSRC

  DATA: l_s_msg TYPE bal_s_msg.

* define data of message for Application Log
  l_s_msg-msgty     = p_msgty.
  l_s_msg-msgid     = p_msgid.
  l_s_msg-msgno     = p_msgno.
  l_s_msg-msgv1     = p_msgv1. l_s_msg-MSGV1_SRC = p_msgv1_src.
  l_s_msg-msgv2     = p_msgv2. l_s_msg-MSGV2_SRC = p_msgv2_src.
  l_s_msg-msgv3     = p_msgv3. l_s_msg-MSGV3_SRC = p_msgv3_src.
  l_s_msg-msgv4     = p_msgv4. l_s_msg-MSGV4_SRC = p_msgv4_src.

* add this message to log file
* we do not specify I_LOG_HANDLE since we want to add this message
* to the default log. If it does not exist we do not care
* (EXCEPTIONS log_not_found = 0).
      i_s_msg      = l_s_msg
      i_log_handle = w_handle_1
        log_not_found = 0
        OTHERS        = 1.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 26, 2006 at 11:17 AM

    Try using the fm: BAL_LOG_MSG_READ passing the same parameters.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 27, 2006 at 04:11 AM

    Q 1. Where can I view the log. Which tcode?


    Q 2. (To best of my knowledge, which is very limited 😊 First we need to create a Z log object and subobject (transaction SLG0). Save it using fn BAL_DB_SAVE

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.