Application Development 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: 

Custom error message in SAP application log

Former Member
0 Kudos

Is there a way to add a custom error message to the SAP application log without passing the message variables MSGV1, MSGV2, MSGV3, MSGV4 and the Message class and number.

We want to pass a custom message from the BAPIRET2-MESSAGE without giving it a Message class and number. The reason for this is that we are using class based exceptions instead of the traditional message class with errors. When we catch the class based exception, we take the error text of the exception and put in in the BAPIRET2-message and set the BAPIRET2-TYPE as 'E'. Now we want to add this to the SAP application log.

The call to 'BAL_LOG_MSG_ADD' takes a structure BAL_S_MSG which is just like BAPIRET2. However this function builds the entry to the application log use the message variables MSGV1, MSGV2, MSGV3, MSGV4. There is no provision to pass in the BAPIRET2 message.

  • Add message to application log

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

i_log_handle = app_log_handle

i_s_msg = log_message

Thanks,

Jay

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Jay,

Did you see <b>BAL_LOG_EXCEPTION_ADD</b>?

This FM is represented by the structure <b>BAL_S_EXC</b>. This can have various versions as described below:

<b>Data of BAL_S_EXC Structure / Use</b>

<b>EXCEPTION</b> / Exception class from which an exception text

is added to the log. This field must be filled.

<b>MSGTY</b> / Message type (MSGTY) of a T100 message.

This field must also be filled for exceptions.

<b>PROBCLASS,

DETLEVEL,

ALSORT, TIME_STMP</b> / Message or exception attributes, such as

problem class (PROBCLASS, for

example, "very important"), level of detail

(DETLEVEL, from 1 to 9), sort criterion

(ALSORT, unrestricted) and timestamp

(TIME_STMP). These fields can be displayed

in the log (except TIME_STMP).

<b>MSG_COUNT</b> / This attribute is not used for exceptions.

Follow the link below for more details:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/d6/5d7f38f52f923ae10000009b38f8cf/frameset.htm">SAP Help DOc</a>

Hope this helps.

Thanks

Sanjeev

2 REPLIES 2

Former Member
0 Kudos

Hi Jay,

Did you see <b>BAL_LOG_EXCEPTION_ADD</b>?

This FM is represented by the structure <b>BAL_S_EXC</b>. This can have various versions as described below:

<b>Data of BAL_S_EXC Structure / Use</b>

<b>EXCEPTION</b> / Exception class from which an exception text

is added to the log. This field must be filled.

<b>MSGTY</b> / Message type (MSGTY) of a T100 message.

This field must also be filled for exceptions.

<b>PROBCLASS,

DETLEVEL,

ALSORT, TIME_STMP</b> / Message or exception attributes, such as

problem class (PROBCLASS, for

example, "very important"), level of detail

(DETLEVEL, from 1 to 9), sort criterion

(ALSORT, unrestricted) and timestamp

(TIME_STMP). These fields can be displayed

in the log (except TIME_STMP).

<b>MSG_COUNT</b> / This attribute is not used for exceptions.

Follow the link below for more details:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/d6/5d7f38f52f923ae10000009b38f8cf/frameset.htm">SAP Help DOc</a>

Hope this helps.

Thanks

Sanjeev

0 Kudos

Thanks Sanjeev,

That worked. We had to use - BAL_LOG_MSG_ADD_FREE_TEXT since we did not have BAL_LOG_EXCEPTION_ADD in our R/3 Enterprise system.

We do have BAL_LOG_EXC_ADD but that does not work. But BAL_LOG_MSG_ADD_FREE_TEXT works very well.

Regards,

jay