Ansicht
Dokumentation

INIT_EVENT_MASTER_TUUID_GET - Providing the transaction ID for the master transaction

INIT_EVENT_MASTER_TUUID_GET - Providing the transaction ID for the master transaction

CPI1466 during Backup   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

Event handling by application programs

Since only the event "COMMIT WORK" ("ROLLBACK WORK") exists with registration "PERFORM ON COMMIT" ("PERFORM ON ROLLBACK"), the following functional gaps may cause data inconsistencies and performance problems:

  • Background programs, transactions, and BAPIs are often implemented so that data in global memory is implemented as a buffer or as a transaction memory. To avoid inconsistencies in the transaction memory or performance problems with the buffers (internal tables that are too large), this global data must be regularly reset.
  • Previously, this had to be implemented by the main program with explicit calls of the respective function modules that reset the global data. However, due to the complex integration, the main program very often has no information at all about which modules and service are being used.
  • A method of addressing all used modules and services through a registration mechanism and an event is missing here.

To provide a solution for this, the following function modules were implemented in a function group:

  • INIT_EVENT_REGISTER
    Contains a parameter with the name of a function module

  • INIT_EVENT_REGISTER_FORM
    Contains two parameters with the name of a form and associated program.

  • INIT_EVENT_RAISE
    Contains a parameter used to pass on an ID to uniquely identify a transaction. Only if this ID matches the ID that belongs to INIT_EVENT_MASTER_KEY_GET can the event "INIT" be triggered. If no ID has been requested with INIT_EVENT_MASTER_KEY_GET, the parameter TUUID is optional and not relevant.

  • INIT_EVENT_MASTER_KEY_GET
    Contains a parameter to return an ID that identifies the current transaction uniquely. The main program of a transaction can thus be identified. Only with this ID can the INIT event be triggered. As long as this function module has not been called within a transaction, no main program exists, and the INIT event can be triggered by any program. If the INIT_EVENT_MASTER_KEY_GET is called repeatedly, the exception "NOT_MASTER" is triggered. Calling INIT_EVENT_MASTER_KEY_GET prevents an automatic triggering of the INIT event with every COMMIT and ROLLBACK WORK.

Event handling process

There are basically two mechanisms to control the EVENT

  • Targeted through the main program
    The main program uses INIT_EVENT_MASTER_KEY_GET to procure the unique key for triggering the INIT event. The main program should always be the program that triggers COMMIT, ROLLBACK, EXIT, ... .
  • Automatically with commit work and rollback work:
    If no key is retrieved with INIT_EVENT_MASTER_KEY_GET, the INIT event is automatically triggered after every "COMMIT WORK" and "ROLLBACK WORK" (following the corresponding DB commit/rollback).

  1. All function groups to which the INIT event should be communicated must register with INIT_EVENT_REGISTER. The parameter defines which function module is called by the event. These function module names are collected in an internal table of the function group using COLLECT. The same applies for FORM calls and programs.

  2. By triggering the INIT event, all registered function modules and forms are executed. If the function modules or FORMs do not exist, a DUMP is generated. The internal table is not deleted afterwards, that is, the registration is retained until the end of the transaction (/n). Only the main program, that is, the first program to call INIT_EVENT_MASTER_KEY_GET can trigger the event. As long as no ID has been assigned, that is, INIT_EVENT_MASTER_KEY_GET has not been called, any program involved can trigger the INIT event.
  3. You must include the INIT_EVENT_RAISE for all ROLLBACKS and in all sections where initialization routines are called.

The existing PERFORM ON COMMIT solutions remain unchanged to reduce the effort required.

Advantages of this procedure

  • Non-registered function groups are not called when the INIT event occurs and thus not loaded unnecessarily.

  • The application can respond to a programmed ROLLBACK.

  • New function groups/applications have a central location for registration.

Example

Notes

You should use these function modules if in transactions or batch programs global data needs to be initialized after a commit or rollback in order that the next "processing block" can be processed consistently. If the transaction or batch program is left with the COMMIT or Rollback (/n), the global data is reset automatically. In this case it is not necessaryto use this function group.

If you want to prevent the automatic triggering of the INIT event with COMMIT or ROLLBACK WORK, you need only to call the module INIT_EVENT_MASTER_KEY_GET.

Further information





Parameters

TUUID

Exceptions

NOT_MASTER

Function Group

AIEV

General Material Data   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 5661 Date: 20240523 Time: 064556     sap01-206 ( 112 ms )