Ansicht
Dokumentation

BAL_S_CONT - Application Log: Context

BAL_S_CONT - Application Log: Context

ABAP Short Reference   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book


A message or log header is often only meaningful in context.
The Aplication Log provides a context.

Example:
The message 'Credit limit exceeded for customer ABC' is meaningful in dialog because it appears while a particular document is being processed, but the log should also contain the document number. This information may be in the message variables, but this can cause problems in detailed context information (e.g. order number, item number, schedule line number, etc.).

This context information can be passed with a message (or log header) to the Application Log in a DDIC structure (maximum length 256 bytes). You pass the name of the DDIC structure in CONTEXT-TABNAME and its contents in CONTEXT-VALUE for later display.

Example:
====================================================================
DATA:
l_s_msg TYPE bal_s_msg,
l_s_my_context type my_ddic_structure.

* Message 123(XY): 'Credit limit exceeded for customer &1'.
l_s_msg-msgty = 'E'.
l_s_msg-msgid = 'XY'.
l_s_msg-msgno = '123'.
l_s_msg-msgv1 = 'ABC'.
* Add document number to message as context:
l_s_my_context-document = '3000012345'.
l_s_msg-context-tabname = 'MY_DDIC_STRUCTURE'.
l_s_msg-context-value = l_s_my_context.
* Log message
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_s_msg = l_s_msg
EXCEPTIONS
others = 1.
====================================================================

Note:
The line
l_s_msg-context-value = l_s_my_context.
causes a syntax error in unicode if the context contains fields that are not of character type (for example, INTEGER).
It is therefore recommended that in this context you only use fields of character type (subsequent conversion is possible, old context information on the database is converted automatically when it is read).
If fields that are not of character type must be used in this context,
the line above can be replaced by:
FIELD-SYMBOLS:
TYPE c.
ASSIGN l_s_my_context TO CASTING.
l_s_msg-context-value = .

Further information

Overview of the most important function groups

Quick start documentation

Application Log: Technical documentation






PERFORM Short Reference   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 2753 Date: 20240512 Time: 201613     sap01-206 ( 43 ms )