Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

application log and system log

Former Member
0 Likes
666

Hi,

I want to pass message to application log and save the log, for reports, interface.

I have created the FM using 'BAL_LOG_MSG_ADD', 'BAL_DB_SAVE', also referred many documents available.

and created object in SLG0.

here how i can pass the message through my program to application log and save it.

Here i want to pass my message classes or how i can pass through object which i have created for my FM by calling the FM in my program.

Thanks in Advance,

Arun .

Edited by: Arun Kumaran on Jan 8, 2010 8:34 AM

Edited by: Arun Kumaran on Jan 8, 2010 8:55 AM

2 REPLIES 2
Read only

Former Member
0 Likes
567

Hi Arun,

First create the following 3 subroutines in your program.

Call these routines at appropriate places in your coding.

  • Create application log ( at the beginning of the program)

PERFORM create_log CHANGING gv_log_handle.

  • Add this error message to your log

PERFORM log_msg_add USING gv_log_handle

<messagetype> <messageclassname> <messageno> <messagevar1> <messagevar2>

<messagevar3> <messagevar4>gc_class_addl_info.

If you pass the actual values, it looks like

PERFORM log_msg_add USING gv_log_handle

'E' 'ZMSGCLASS' '001' TEXT-001 TEXT-002 TEXT-003 TEXT-004 '4'.

  • Save message log ( ( at the end )

PERFORM log_save.

&----


*& Form CREATE_LOG

&----


  • Create application log

----


FORM create_log CHANGING cv_log_handle TYPE balloghndl.

DATA: ls_log TYPE bal_s_log.

ls_log-object = <objectname>. "object name created in SLG0

ls_log-subobject = <subobjectname> . " sub object name created in SLG0

ls_log-aldate = sy-datum.

ls_log-altime = sy-uzeit.

ls_log-aluser = sy-uname.

ls_log-altcode = sy-tcode.

ls_log-alprog = sy-repid.

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING

i_s_log = ls_log

IMPORTING

e_log_handle = cv_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.

ENDFORM. " CREATE_LOG

&----


*& Form LOG_MSG_ADD

&----


  • Add messages to log

----


FORM log_msg_add USING iv_log_handle TYPE balloghndl

iv_msgty TYPE symsgty

iv_msgid TYPE symsgid

iv_msgno TYPE symsgno

iv_msgv1 TYPE symsgv

iv_msgv2 TYPE symsgv

iv_msgv3 TYPE symsgv

iv_msgv4 TYPE symsgv

iv_probclass TYPE balprobcl.

DATA: ls_log_msg TYPE bal_s_msg.

ls_log_msg-msgty = iv_msgty.

ls_log_msg-msgid = iv_msgid.

ls_log_msg-msgno = iv_msgno.

ls_log_msg-msgv1 = iv_msgv1.

ls_log_msg-msgv2 = iv_msgv2.

ls_log_msg-msgv3 = iv_msgv3.

ls_log_msg-msgv4 = iv_msgv4.

ls_log_msg-probclass = iv_probclass.

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

i_log_handle = iv_log_handle

i_s_msg = ls_log_msg

  • IMPORTING

  • E_S_MSG_HANDLE =

  • E_MSG_WAS_LOGGED =

  • E_MSG_WAS_DISPLAYED =

EXCEPTIONS

log_not_found = 1

msg_inconsistent = 2

log_is_full = 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.

ENDFORM. " LOG_MSG_ADD

&----


*& Form LOG_SAVE

&----


  • Save all messages

----


FORM log_save .

CALL FUNCTION 'BAL_DB_SAVE'

EXPORTING

  • I_CLIENT = SY-MANDT

  • I_IN_UPDATE_TASK = ' '

i_save_all = 'X'

  • I_T_LOG_HANDLE =

  • IMPORTING

  • E_NEW_LOGNUMBERS =

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.

ENDFORM. " LOG_SAVE

Regards,

Savitha

Edited by: Savitha Madhavagiri on Jan 8, 2010 4:03 AM

Read only

former_member182371
Active Contributor
0 Likes
567

Hi,

if you try to use the search options of the forum you´ll find plenty of answers and even a wiki about it:

http://wiki.sdn.sap.com/wiki/display/Snippets/UsingApplicationLog

Best regards

Edited by: Pablo Casamayor on Jan 8, 2010 10:23 AM