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

about error logs...urgent..

Former Member
0 Likes
701

hello experts,

how will i use error log in my program?

thank you.:-)

hello experts,

how will i use error log in my program?

thank you.:-)

2 REPLIES 2
Read only

Former Member
0 Likes
572

Generally an error log is used whenever you encounters errors during some sort of validation of data within you interface/report. What are you trying to do with it?

Read only

Former Member
0 Likes
572

Hi,

if there is no data in the table,if we write select statement then error message should be created in 'error log' when it run on background.

You need to create a Custom table , where you can store the Error Log.say report name and error text , Date of run , user name etc.

Best is create a Include , which you can use in all reports for future.

Later you can use the table to retrive log.

Or you can do in the following way:::::::::::::::::

You can use the function module 'APPL_LOG_WRITE_MESSAGES' to log application messages and display using FM 'APPL_LOG_DISPLAY'.

CALL FUNCTION 'APPL_LOG_WRITE_MESSAGES'

EXPORTING

OBJECT = ls_balhdri-object

  • SUBOBJECT = ' '

LOG_HANDLE = gd_handle

  • UPDATE_OR_INSERT = 'U'

TABLES

MESSAGES = lt_balmi

  • EXCEPTIONS

  • OBJECT_NOT_FOUND = 1

  • SUBOBJECT_NOT_FOUND = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Or You can use the function module 'APPL_LOG_WRITE_MESSAGES' to log application messages and display using FM 'APPL_LOG_DISPLAY'.

CALL FUNCTION 'APPL_LOG_WRITE_MESSAGES'

EXPORTING

OBJECT = ls_balhdri-object

  • SUBOBJECT = ' '

LOG_HANDLE = gd_handle

  • UPDATE_OR_INSERT = 'U'

TABLES

MESSAGES = lt_balmi

  • EXCEPTIONS

  • OBJECT_NOT_FOUND = 1

  • SUBOBJECT_NOT_FOUND = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regarding help for why you require and why to go for application logs, refer this SAP Help

http://help.sap.com/saphelp_47x200/helpdata/en/2a/fa0223493111d182b70000e829fbfe/frameset.htm

Or you can try in the following way.depending upon your reqt you use any one.

DATA: ls_log TYPE bal_s_log.

DATA: p_log_handle TYPE balloghndl.

ls_log-extnumber = 'YMYTEST'.

ls_log-alprog = sy-repid.

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING

I_S_LOG = ls_log

IMPORTING

E_LOG_HANDLE = p_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.

data: l_s_msg TYPE bal_s_msg.

data: E_MSG_WAS_DISPLAYED type boolean.

data: E_MSG_WAS_LOGGED type boolean.

data: E_S_MSG_HANDLE type BALMSGHNDL.

l_s_msg-msgid = '00'.

l_s_msg-msgty = 'E'.

l_s_msg-msgno = '001'.

l_s_msg-msgv1 = 'This is a test message from 20130810'.

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

I_LOG_HANDLE = p_log_handle

I_S_MSG = l_s_msg

IMPORTING

E_S_MSG_HANDLE = E_S_MSG_HANDLE

E_MSG_WAS_LOGGED = E_MSG_WAS_LOGGED

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

data: I_T_LOG_HANDLE type BAL_T_LOGH.

append p_log_handle to i_t_log_handle.

CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'

EXPORTING

  • I_S_DISPLAY_PROFILE =

I_T_LOG_HANDLE = i_t_log_handle

  • I_T_MSG_HANDLE =

  • I_S_LOG_FILTER =

  • I_S_MSG_FILTER =

  • I_T_LOG_CONTEXT_FILTER =

  • I_T_MSG_CONTEXT_FILTER =

  • I_AMODAL = ' '

  • IMPORTING

  • E_S_EXIT_COMMAND =

EXCEPTIONS

PROFILE_INCONSISTENT = 1

INTERNAL_ERROR = 2

NO_DATA_AVAILABLE = 3

NO_AUTHORITY = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Please reward if its useful.

Regards,

Sivaparvathi