## 4.2.15.9.2.3.3  CL\_BALI\_LOG (Interface IF\_BALI\_LOG)
Class CL\_BALI\_LOG handles all read and change operations on a single application log. It contains methods to read and change the log header. In addition, it allows to read items from the log and to add items to the log. The public interface of the instance methods is IF\_BALI\_LOG .
## Public Methods
Create an instance of the log class:
## CREATE (static)
| Name                                                          | Description                                                                                                   |
|---------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| Returning parameter                                           |                                                                                                               |
| LOG                                                           | Log object: A reference to interface IF_BALI_LOG                                                              |
| Exceptions (inherit from CX_BALI_RUNTIME)                     |                                                                                                               |
| CX_BALI_INTERNAL_ERROR                                        | Internal error during processing                                                                              |
| Create an instance of the log class and set the header:       |                                                                                                               |
| CREATE_WITH_HEADER (static)                                   |                                                                                                               |
| Name                                                          | Description                                                                                                   |
| Importing parameter                                           |                                                                                                               |
| HEADER                                                        | Header which is put into the log: Reference to interface IF_BALI_HEADER_SETTER                                |
| Returning parameter                                           |                                                                                                               |
| LOG                                                           | Log object: A reference to interface IF_BALI_LOG                                                              |
| Exceptions (inherit from CX_BALI_RUNTIME)                     |                                                                                                               |
| CX_BALI_NOT_POSSIBLE                                          | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>OB- JECT_NOT_ALLOWED: Access to the log object of the header is not allowed |
| CX_BALI_INVALID_PARAMETER                                     | The log object or subobject of the header don't exist                                                         |
| CX_BALI_INTERNAL_ERROR                                        | Internal error during processing                                                                              |
| Get the log handle which is the unique identifier of the log: |                                                                                                               |
| GET_HANDLE                                                    |                                                                                                               |
| Name                                                          | Description                                                                                                   |
| Returning parameter                                           |                                                                                                               |
| HANDLE                                                        | Log handle                                                                                                    |
| Get the log header:                                           |                                                                                                               |
| GET_HEADER                                                    |                                                                                                               |
| Name                                                          | Description                                                                                                   |
| Returning parameter                                           |                                                                                                               |
| HEADER                                                        | Log header: References to interface IF_BALI_HEADER_GET- TER                                                   |
| Name                                      | Description                                                                                                                                                                                                                          |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                                      |
| CX_BALI_NOT_POSSIBLE                      | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>LOG_WAS_IN- VALIDATED: The memory of the log was released. The log can't be used                                                                                                                   |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                                                                                                                                     |
| Set the log header:                       |                                                                                                                                                                                                                                      |
| SET_HEADER                                |                                                                                                                                                                                                                                      |
| Name                                      | Description                                                                                                                                                                                                                          |
| Importing parameter                       |                                                                                                                                                                                                                                      |
| HEADER                                    | Header which is put into the log: References to interface IF_BALI_HEADER_SETTER                                                                                                                                                      |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                                      |
| CX_BALI_NOT_POSSIBLE                      | • ERROR_CODE: CX_BALI_NOT_POSSIBLE=>OB- JECT_NOT_ALLOWED: Access to the log object of the header is not allowed • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INVALID_PARAMETER                 | The log object or subobject of the header don't exist                                                                                                                                                                                |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                                                                                                                                     |
| Add an item (e.g. a message) to the log:  |                                                                                                                                                                                                                                      |
| ADD_ITEM                                  |                                                                                                                                                                                                                                      |
| Name                                      | Description                                                                                                                                                                                                                          |
| Importing parameter                       |                                                                                                                                                                                                                                      |
| ITEM                                      | Item which is added: Reference to interface IF_BALI_ITEM_SETTER                                                                                                                                                                      |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                                      |
## Name
| CX_BALI_NOT_POSSIBLE      | • ERROR_CODE: CX_BALI_NOT_POSSIBLE=>OB- JECT_NOT_ALLOWED: Access to the log object of the header is not allowed • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used   |
|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CX_BALI_INVALID_PARAMETER | The log object or subobject of the header don't exist                                                                                                                                                                                  |
| CX_BALI_INTERNAL_ERROR    | Internal error during processing                                                                                                                                                                                                       |
##  Note
An exception may contain a message. This means that the ABAP exception class contains interface IF\_T100\_MESSAGE , or it contains at least the attributes T100\_MSGID and T100\_MSGNO . In this case, the exception is internally converted into a message before it is added to the log.
If the item is a message, it's checked whether the log already contains another message with identical message attributes. These are the attributes: severity, message ID, message number and message variable 1 - 4. If this message exist, the message counter of the message is increased by 1. Otherwise, a new message is added to the log. Also free texts and exceptions are always added to the log without cumulation.
## CUMULATE\_ITEM
| Name                                      | Description                                                                                                                                                                                                                          |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Importing parameter                       |                                                                                                                                                                                                                                      |
| ITEM                                      | Item which is cumulated or added: Reference to interface IF_BALI_ITEM_SETTER                                                                                                                                                         |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                                      |
| CX_BALI_NOT_POSSIBLE                      | • ERROR_CODE: CX_BALI_NOT_POSSIBLE=>OB- JECT_NOT_ALLOWED: Access to the log object of the header is not allowed • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INVALID_PARAMETER                 | The log object or subobject of the header don't exist                                                                                                                                                                                |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                                                                                                                                     |
##  Note
An exception may contain a message. This means that the ABAP exception class contains interface IF\_T100\_MESSAGE , or it contains at least the attributes T100\_MSGID and T100\_MSGNO . In this case,
## Description
the exception is internally converted to a message before it is added to the log (but this message is not cumulated to an already existing message).
Add all messages from an internal table of type BAPIRETTAB table to the log:
ADD\_MESSAGES\_FROM\_BAPIRETTAB
| Name                                      | Description                                                                                                                                                                                                               |
|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Importing parameter                       |                                                                                                                                                                                                                           |
| MESSAGE_TABLE                             | An internal table with messages which use type BAPIRET- TAB                                                                                                                                                               |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                           |
| CX_BALI_NOT_POSSIBLE                      | • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>TOO_MANY_ITEMS: The maximum number 999999 of items was reached • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INVALID_PARAMETER                 | The message ID of one of the messages is initial                                                                                                                                                                          |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                                                                                                                          |
##  Note
If a message of the message table can't be added to the log, it's skipped and the processing continues until the end of the table is reached. Afterwards, an exception is raised to notify the caller that some of the messages couldn't be added to the log.
Add a message from the ABAP Restful Application Programming Model (interface IF\_ABAP\_BEHV\_MESSAGE) to the log:
ADD\_ABAP\_BEHAVIOR\_MESSAGE
Name
| Importing parameter                       |                                                                                                                                                                                                                           |
|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| MESSAGE                                   | A reference to the interface IF_ABAP_BEHV_MESSAGE                                                                                                                                                                         |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                           |
| CX_BALI_NOT_POSSIBLE                      | • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>TOO_MANY_ITEMS: The maximum number 999999 of items was reached • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INVALID_PARAMETER                 | The message ID of the messages is initial                                                                                                                                                                                 |
Description
## Name
| CX_BALI_INTERNAL_ERROR                                                        | Internal error during processing                                                                                                                                                                                          |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Add all items from another log to this log: ADD_ALL_ITEMS_FROM_OTHER_LOG Name | Description                                                                                                                                                                                                               |
| Importing parameter                                                           |                                                                                                                                                                                                                           |
| SOURCE_LOG                                                                    | Reference to the log whose items are to be copied                                                                                                                                                                         |
| Exceptions (inherit from CX_BALI_RUNTIME)                                     |                                                                                                                                                                                                                           |
| CX_BALI_NOT_POSSIBLE                                                          | • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>TOO_MANY_ITEMS: The maximum number of 999999 items was reached • ERROR_CODE: CX_BALI_NOT_POSSI- BLE=>LOG_WAS_INVALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INVALID_PARAMETER                                                     | The source log is invalid. It contains a log handle which doesn't exist                                                                                                                                                   |
| CX_BALI_INTERNAL_ERROR                                                        | Internal error during processing                                                                                                                                                                                          |
<!-- image -->
If the parameter SOURCE\_LOG is initial, the processing is skipped and no exception is raised.
Add an item filter to the log. The item filter is checked before an item is added to the log using the methods ADD\_ITEM, CUMULATE\_ITEM, ADD\_MESSAGES\_FROM\_BAPIRETTAB, or ADD\_ABAP\_BEHAVIOR\_MESSAGE. If an item doesn't pass the filter, it's ignored.
SET\_FILTER\_FOR\_ADD\_ITEM
| Name                                      | Description                                                                                                        |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| Importing parameter                       |                                                                                                                    |
| FILTER                                    | A reference to the item filter                                                                                     |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                    |
| CX_BALI_NOT_POSSIBLE                      | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>LOG_WAS_IN- VALIDATED: The memory of the log was released. The log can't be used |
<!-- image -->
##  Note
- If FILTER is initial, any item filter is removed from the log. The log then no longer uses an item filter.
- Since the method ADD\_ALL\_ITEMS\_FROM\_OTHER\_LOG is intended for the mass-processing of items, it ignores the item filter because of performance reasons.
## Description
- The filter is only used by methods of the class CL\_BALI\_LOG. If an application uses the application log function modules to add an item to the log, the filter is ignored.
Get the item filter which was set using SET\_FILTER\_FOR\_ADD\_ITEM.
## GET\_FILTER\_FOR\_ADD\_ITEM
| Name                                      | Description                                                                                                        |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| Returning parameter                       |                                                                                                                    |
| FILTER                                    | A reference to the item filter which is currently used by the log                                                  |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                    |
| CX_BALI_NOT_POSSIBLE                      | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>LOG_WAS_IN- VALIDATED: The memory of the log was released. The log can't be used |
| Get a single item from the log:           |                                                                                                                    |
| GET_ITEM                                  |                                                                                                                    |
| Name                                      | Description                                                                                                        |
| Importing parameter                       |                                                                                                                    |
| LOG_ITEM_NUMBER                           | Serial number of the item which shall be read (it is the posi- tion of the item in the log)                        |
| Returning parameter                       |                                                                                                                    |
| ITEM                                      | Item which was read: Reference to interface IF_BALI_ITEM_GETTER                                                    |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                    |
| CX_BALI_NOT_FOUND                         | An item with the requested log item number does not exist                                                          |
| CX_BALI_NOT_POSSIBLE                      | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>LOG_WAS_IN- VALIDATED: The memory of the log was released. The log can't be used |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                   |
| Get all items from the log:               |                                                                                                                    |
| GET_ALL_ITEMS                             |                                                                                                                    |
| Name                                      | Description                                                                                                        |
| Returning parameter                       |                                                                                                                    |
| Name                                      | Description                                                                                                                                                                                                        |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ITEM_TABLE                                | Table of all items which are stored in the log. The table has the following structure: • LOG_ITEM_NUMBER: The serial number of the item in the log • ITEM: Item object: Reference to interface IF_BALI_ITEM_GETTER |
| Exceptions (inherit from CX_BALI_RUNTIME) |                                                                                                                                                                                                                    |
| CX_BALI_NOT_FOUND                         | No item was found in the log                                                                                                                                                                                       |
| CX_BALI_NOT_POSSIBLE                      | ERROR_CODE: CX_BALI_NOT_POSSIBLE=>LOG_WAS_IN- VALIDATED: The memory of the log was released. The log can't be used                                                                                                 |
| CX_BALI_INTERNAL_ERROR                    | Internal error during processing                                                                                                                                                                                   |
## RELEASE\_MEMORY:
Remove the log from the memory. After this, the log is invalidated and can no longer be used.
Check whether the memory of the log was released in order to verify that the log is invalidated and can no longer be used.
IS\_INVALIDATED
| Name                | Description                                              |
|---------------------|----------------------------------------------------------|
| Returning parameter |                                                          |
| IS_INVALIDATED      | If set, the log is invalidated and can no longer be used |