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: 

BAL_LOG_EXCEPTION_ADD with Context

uwe_isenmann2
Participant
0 Kudos

Hello together,

Is it possible to log an exception with context Information.

The Standard function module BAL_LOG_MSG_ADD has a Parameter i_s_msg-context where you can save additional Information to a message.

There is also a function module BAL_LOG_EXCEPTION_ADD but it has no pararameter for context.

I tried different round trips (for exampel: BAL_LOG_MSG_CHANGE) but I found no way to set context.

Does anybody has an idea?

Best regards
Uwe

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Uwe,

I hate to be the bearer of bad news but unfortunately context information is not supported for exceptions. As per the FM documentation -


Context information for exceptions and cumulated addition of exceptions are not supported.

What you can try on the other hand is generate the message from the exception object and then call BAL_LOG_MSG_ADD to add the message along with the context.

Note:

  • If you are using IF_T100_MESSAGE and are on the correct ABAP release, you can raise the message directly via MESSAGE statement. (Refer ABAP Keyword Documentation).
  • If you are on lower ABAP release use the method CL_MESSAGE_HELPER=>SET_MSG_VARS_FOR_IF_MSG( ) to set the SY-MSG* variables.

BR,

Suhas

PS - If you are super motivated, then enhance the structure BAL_S_EXC & the FM BAL_LOG_EXCEPTION_ADD to support context info

Message was edited by: Suhas Saha

2 REPLIES 2

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Uwe,

I hate to be the bearer of bad news but unfortunately context information is not supported for exceptions. As per the FM documentation -


Context information for exceptions and cumulated addition of exceptions are not supported.

What you can try on the other hand is generate the message from the exception object and then call BAL_LOG_MSG_ADD to add the message along with the context.

Note:

  • If you are using IF_T100_MESSAGE and are on the correct ABAP release, you can raise the message directly via MESSAGE statement. (Refer ABAP Keyword Documentation).
  • If you are on lower ABAP release use the method CL_MESSAGE_HELPER=>SET_MSG_VARS_FOR_IF_MSG( ) to set the SY-MSG* variables.

BR,

Suhas

PS - If you are super motivated, then enhance the structure BAL_S_EXC & the FM BAL_LOG_EXCEPTION_ADD to support context info

Message was edited by: Suhas Saha

0 Kudos

Hello Suhas,

Thank you for your response.

But I found an other way.

First call: BAL_LOG_EXCEPTION ADD

Then: BAL_LOG_MSG_READ

!!! FM throws an incorrect exception msg_not_found

Then: Set the context and call.

BAL_LOG_MSG_CHANGE

Best Regards
Uwe