Ansicht
Dokumentation

BAL_CH_DELETE -

BAL_CH_DELETE -

Addresses (Business Address Services)   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

|---------------------------------------------------------------------|
| Delete log from the database |
|---------------------------------------------------------------------|

Overview
=======================================================================

Logs must be deleted to prevent the Application Log database tables from overflowing. There are two ways of doing so:

  • with the standard log deletion transaction SLG2, whose log deletion logic is described below.
  • by calling Application Log function modules from the application (e.g. when deleting an application object or in a user application transaction)

Function modules
BAL_DB_DELETE Delete logs from the database

Transaction SLG2: Delete logs
=======================================================================

This transaction is a report on whose selection screen you can specify which logs are to be deleted. It can run online (Program -> Execute (F8)) or in the background (Program->Execute in Background (F9)), where it can be scheduled regularly.

  • Options
  • Get number only
    The report reads no database data, it just determines how many logs can be deleted. This is quick, and is the default option.

  • Create list
    No logs are deleted, those which can be deleted are listed, and the user can select those to be deleted.
    If more than 100 logs can be deleted, the first 100 are displayed, followed by the next 100 on demand, etc.

  • Delete immediately
    All deletable logs are deleted immediately from the database (useful in Batch).

  • Selection conditions
    The set of logs to be deleted can be specified by selection conditions for the Application Log object/subobject, external number, log number, problem class and creation date/time.
  • Expiry date
    Not all logs which satisfy the selection conditions can be deleted.
    A log can only be deleted when it has expired, i.e. its expiry date has been reached or passed. You specify the expiry date in the log header data (structure BAL_S_LOG) field ALDATE_DEL when you create a log with the function module BAL_LOG_CREATE.
    The field ALDATE_DEL is rarely filled and is set to 31.12.2098 by the Application Log by default. Such logs are in practice never deleted from the system, so the report has the following "Expiry date" options:
  • Only delete logs whose expiry data has been reached
    This is the standard option which does not delete logs for which no expiry date was specified.

  • Delete logs which can be deleted before expiry
    This option also deletes logs whose expiry date has not been reached, but whose DEL_BEFORE flag is initial. DEL_BEFORE can be passed when you open a log, like ALDATE_DEL. It's default value is initial, i.e. "Delete before expiry" is allowed.

The user can thus delete logs in two steps:

  • delete expired logs
  • delete logs which can be deleted before expiry, with object/subobject selection conditions

The application developer has various ways of using the expiry date ALDATE_DEL and the DEL_BEFORE flag when the function module BAL_LOG_CREATE is called. Examples:

  • Delete log as soon as possible
    ALDATE_DEL = sy-datum.
    DEL_BEFORE = space.
    The log can be deleted on the day it is created.
  • Delete log in 100 days at the earliest
    ALDATE_DEL = sy-datum + 100.
    DEL_BEFORE = "X".
    The residence time of 100 days must be specified by the application. Application Log residence times (e.g. dependent on Application Log object/subobject) cannot currently be set in customizing.
  • Retain log for as long as possible
    ALDATE_DEL = "20981231". (or initial)
    DEL_BEFORE = space.
    This log is not deleted when the delete transaction SLG2 is called with the standard option "Only expired logs". Only the option "Delete logs for which delete before expiry is allowed" deletes the log.
  • Log must not be deleted by the standard transaction
    ALDATE_DEL = "20981231". (or initial)
    DEL_BEFORE = "X".
    This log can only be explicitly deleted by the application (see next chapter).

==>Note
Transaction SLG2 did not exist before Release 4.6A. Logs used to be deleted by the program RSSLG200 which was not parameterized and deleted all expired logs. It could be scheduled as a job with RSSLG210.
To delete logs before expiry, you had to use the program RSSLGK90 which had selection conditions for Application Log object/subobject, etc.

Delete logs with function modules
=======================================================================

Functionality

The function module BAL_DB_DELETE deletes logs from the application.
You can pass the logs to be deleted to the function module in one of three ways.

  • I_T_LOG_HANDLE: table with log handles.
    This method is useful if you have kept the LOG_HANDLE in your application.
  • I_T_LOGNUMBER: table with log numbers.
    You can use this table if you have the log number LOGNUMBER as reference to the log in the application table and not the LOG_HANDLE (perhaps from older releases)
  • I_T_LOGS_TO_DELETE: table with log headers.
    This table is returned by the function module BAL_DB_SEARCH which you use when you have no reference to the log in your application table and the link is established via the field EXTNUMBER in the log header. In this case specify the application log object/subobject and the external number in the BAL_DB_SEARCH filter.

BAL_DB_DELETE is cross-client:

  • If you specify I_T_LOG_HANDLE, logs in other clients are also deleted (this is not critically because the log handle is unique)
  • If you specify I_T_LOGNUMBER it deletes in the client I_CLIENT. If you do not specify I_CLIENT, it deletes in the current client.
  • If you specify I_T_LOG_HEADER the client in the field MANDANT is taken into account (filled by the function module BAL_DB_SEARCH automatically).

Other parameters:

The parameter I_IN_UPDATE_TASK in the function module BAL_DB_DELETE specifies whether the deletion is to be performed in the update task.

The parameter I_WITH_COMMIT_WORK specifies whether the function module BAL_DB_DELETE should COMMIT WORK. This is advantageous if you want to delete a lot of logs with a lot of data. Databases usually restrict the Rollback segment or the number of DB locks for table entries to be deleted. BAL_DB_DELETE works blockwise when I_WITH_COMMIT_WORK = "X" to avoid exceeding this limit.

Note:

The function module BAL_DB_DELETE does not check whether a log can be deleted (expiry date, etc.). These checks must be made in the application.

There are various possible application log deletion scenarios:

  • The log must be deleted because the object which points to the log is deleted.
    In this case you can pass LOG_HANDLE, LOGNUMBER, etc. directly to the delete module.
  • You must check whether the log can be deleted.
    The most important log header data can be read directly with BAL_DB_SEARCH. The table E_T_LOG_HEADER can be checked and the deletable logs passed to BAL_DB_DELETE.
  • The BAL_DB_SEARCH data are not sufficient.
    This procedure is more complicated and should be an exception:
  • The log is loaded into main memory with BAL_DB_LOAD (with the option I_DO_NOT_LOAD_MESSAGES = "X" only all log header data is loaded).

  • The log header data can now be read with BAL_LOG_HDR_READ, checked, and the deletable logs found.

  • The logs loaded are removed from main memory with BAL_LOG_REFRESH ...

  • ... and the deletable logs are finally deleted from the database with BAL_DB_DELETE.

==>Note
The function module BAL_DB_DELETE did not exist before Release 46A. The function modules APPL_LOG_DELETE and APPL_LOG_DELETE_WITH_LOGNUMBER existed instead.
These function modules also deleted logs, but only those which had expired, or which could be deleted before expiry.

==>Note
When logs are deleted, a callback routine, in which you can delete your own log tables, is called (see here).






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 10008 Date: 20240510 Time: 103845     sap01-206 ( 118 ms )