‎2007 Apr 13 1:51 PM
Hi,
is it possible to add a whole internal table to application log by one command ? ( a function /method call ).
Thanks.
Marian
‎2007 Apr 13 1:53 PM
Yes we can add the whole data into application log..
Please refer the below code.
* Application Log data save option
c_save_all_log_data TYPE c VALUE 'X',
l_subrc(6) TYPE c,
l_text(200),
l_pernr(8).
IF g_log_call = 1.
g_bal_log-extnumber = 'IT15 BDC Error log!'.
g_bal_log-aluser = sy-uname.
g_bal_log-alprog = sy-repid.
* Create a Application log
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = g_bal_log
IMPORTING
e_log_handle = g_log_handle
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.
ENDIF.
loop at g_return.
g_log_mess-msgty = g_return-type.
g_log_mess-msgid = g_return-id.
g_log_mess-msgno = g_return-number.
g_log_mess-msgv1 = g_return-message.
g_log_mess-msgv2 = g_return-message_v1.
g_log_mess-msgv3 = g_return-message_v2.
g_log_mess-msgv4 = g_return-message_v3.
g_log_mess-probclass = 'Error Class'.
appemd g_log_mess.
endloop.
* add this message to log file
CALL FUNCTION 'BAL_LOG_MSG_ADD' "#EC *
EXPORTING
i_s_msg = g_log_mess
EXCEPTIONS
log_not_found = 0
OTHERS = 1.
‎2007 Jun 25 10:51 AM
Marian, you probably noticed that sample code Abhay provided does not work. The parameter i_s_msg in function module BAL_LOG_MSG_ADD is a flat structure - not a table. Abhay's sample may work, but only for the table header - in case the internal table has been defined with addition 'WITH HEADER LINE'.
Sorry, I cannot provide a solution to your ultimate question.
br: Kimmo