08-03-2006 1:34 PM
hi i am saving messages to application log.
i have data containng Sale orders.
for each sale order application log has to create.
then pu messages into each application log.
but while savin allication log using 'BAL_DB_SAVE' FM .following error has come .
<b>Log not found (in main memory)
Message no. BL 207</b>
please help.
08-03-2006 1:36 PM
hi Sharadha,
Check T-code SE91 and there give the message number and the class that you are getting... hope by this way you can diaognise the problem
Regards,
Santosh
08-03-2006 1:41 PM
hi,
First use this FM BAL_LOG_MSG_ADD and then use save fm.
hope it works.
Regards,
Swapnil.
08-03-2006 1:46 PM
Hey,
See the sample program below.
REPORT zkar_create_log MESSAGE-ID bl.
SET EXTENDED CHECK OFF.
INCLUDE sbal_constants.
SET EXTENDED CHECK ON.
DATA:
g_s_log TYPE bal_s_log,
g_log_handle TYPE balloghndl,
g_dummy TYPE c. "#EC NEEDED
DATA:
l_s_msg TYPE bal_s_msg,
lognumber TYPE bal_t_lgnm,
wa_lognumber LIKE bal_s_lgnm,
lt_balloghndl TYPE bal_t_logh. "Log handle internal table
END-OF-SELECTION.
Define header data of this log
g_s_log-extnumber = 'Application Log Demo'. "#EC NOTEXT
g_s_log-object = 'ZADVINTF'.
g_s_log-subobject = 'SERVREP'.
g_s_log-aldate = sy-datum.
g_s_log-altime = sy-uzeit.
g_s_log-aluser = sy-uname.
g_s_log-alprog = sy-repid.
Create a log
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = g_s_log
IMPORTING
e_log_handle = g_log_handle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Store log handle in global internal table for DB save later & flush
APPEND g_log_handle TO lt_balloghndl.
MESSAGE e305 INTO g_dummy.
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.
l_s_msg-probclass = probclass_very_high.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_s_msg = l_s_msg
i_log_handle = g_log_handle
EXCEPTIONS
log_not_found = 0
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_t_log_handle = lt_balloghndl
IMPORTING
e_new_lognumbers = lognumber
EXCEPTIONS
log_not_found = 1
save_not_allowed = 2
numbering_error = 3
OTHERS = 4.
IF sy-subrc EQ 0.
READ TABLE lognumber INTO wa_lognumber INDEX 1.
MESSAGE i000(vz) WITH wa_lognumber-lognumber.
ENDIF.
ENDIF.
-Kiran
Please mark useful answers
08-10-2006 12:36 PM
Hi,
when you use different logs (loghandle) then you had first to load the log into memory. Use therefore FM BAL_DB_LOAD.
Then you can add the message and at the end you can use the FM BAL_DB_SAVE
regards
Thomas
08-10-2006 1:02 PM
Hi,
You need to create to separate log handle for each SO , for this you need to deleted the log handle which was used previously and create a new log handle.
Try this Code.
DATA: WL_LOG TYPE BAL_S_LOG. "Log header
* Delete the old log handle if already created
IF NOT W_LOG_HANDLE IS INITIAL.
CALL FUNCTION 'BAL_LOG_DELETE'
EXPORTING
I_LOG_HANDLE = W_LOG_HANDLE
EXCEPTIONS
LOG_NOT_FOUND = 0
OTHERS = 0.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
* Create log and get handle
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
I_S_LOG = WL_LOG
IMPORTING
E_LOG_HANDLE = W_LOG_HANDLE
EXCEPTIONS
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.