10-26-2006 12:09 PM
I have two queries:
1) My z program is writing logs Using fn modules
BAL_LOG_CREATE
and
BAL_LOG_MSG_ADD
.
<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-id
lw_bapireturn-number
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
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = l_s_log
IMPORTING
e_log_handle = w_handle_1
EXCEPTIONS
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.
ENDIF.
ENDFORM.
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).
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_s_msg = l_s_msg
i_log_handle = w_handle_1
EXCEPTIONS
log_not_found = 0
OTHERS = 1.
ENDFORM.
10-26-2006 12:17 PM
Try using the fm: BAL_LOG_MSG_READ passing the same parameters.
Regards,
Ravi
10-26-2006 12:17 PM
Try using the fm: BAL_LOG_MSG_READ passing the same parameters.
Regards,
Ravi
10-27-2006 5:11 AM
Q 1. Where can I view the log. Which tcode?
SLG1
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