Enabling GUARD on a new Business Object is a one-time job for a developer. After that, every new rule is configuration — and the developer can step away. Here's exactly what those first hours look like.
Find a place to fire GUARD before SAVE
The developer scans the transaction (or report, or custom application) to find the point in the standard SAP toolkit where GUARD can plug in. Any of the four candidates below will do — the common requirement is that the rule must run before the SAVE commits, must have access to the changed tables, and must be allowed to abort the SAVE.
BADI
Business Add-In implementations — most modern SAP BOs expose
a *_BEFORE_SAVE filter implementation that's
perfect for GUARD.
USER-EXIT
Classic includes that ship with the standard programs — the go-to insertion point in older transactions and SD/MM modules.
CUSTOMER-EXIT
CMOD / SMOD enhancement projects. When a transaction has a customer-exit before SAVE, GUARD slots straight in.
Custom code
Any line in a custom transaction, custom function module, or custom application — wherever your code already runs before the SAVE.
The insertion point must
List every table that gets edited
The developer runs the transaction in debug or skims the source code and writes down every table that gets modified — header, items, parties, conditions, partner functions, anything that ends up touched. Those tables become the Inbound Data Sources GUARD will check against.
Below is the list for a contract maintained through ME31K / ME32K — a typical example.
CONTRACT
EKKOPurchasing document — headerEKPOPurchasing document — itemsEKPAPartner roles per documentEKKNAccount assignment per itemKONPConditions (item-level)KONHConditions (header-level)SYSystem data (for SY-UNAME, SY-LANGU filters)Where header-and-item data must be checked together (e.g. EKKO ⇄ EKPO, EINA ⇄ EINE), the developer can register a combined Data Source so OSQL queries can join them in a single statement.
Six lines of ABAP
EXECUTE.
The developer instantiates the BO-specific child of
ZCL_GUARD, calls
ADD_TABLE_ENTRY for each Data Source, then
EXECUTE. The framework returns the messages and an
error flag — the developer just needs to abort the SAVE if any
errors came back.
"--- Inside the BEFORE-SAVE BAdI ---------------------------------- DATA(lo_guard) = NEW zcl_guard_contract( iv_object_key = |{ ls_ekko-ebeln }| ). lo_guard->add_table_entry( iv_tname = 'EKKO' i_data = VALUE tt_ekko( ( ls_ekko ) ) ). lo_guard->add_table_entry( iv_tname = 'EKPO' i_data = lt_ekpo ). lo_guard->add_table_entry( iv_tname = 'EKPA' i_data = lt_ekpa ). lo_guard->add_table_entry( iv_tname = 'EKKN' i_data = lt_ekkn ). lo_guard->add_table_entry( iv_tname = 'KONP' i_data = lt_konp ). lo_guard->execute( IMPORTING et_msg_bapi = DATA(lt_msg) et_msg_bal = DATA(lt_bal_msg) ). "--- Stop SAVE if any error came back ------------------------------ IF line_exists( lt_msg[ type = 'E' ] ). ct_messages = lt_msg. RAISE EXCEPTION TYPE cx_im_save_error. ENDIF.
That's the entire integration. The class
ZCL_GUARD_CONTRACT is one short subclass of
ZCL_GUARD the developer creates once for the BO. Every
future rule lives outside this code.
Register the Object once · transaction ZGUARD_SET
Open ZGUARD_SET and create an Object record matching
the BO. Then list the Inbound Data Source tables the code passes
in — the same names from Step 2. Only the developer can do this
step, because the developer is the one who decides which tables
are exposed.
That's the last thing the developer has to do here. Everything after this is a functional task.
| Table name | DB table | Description |
|---|---|---|
EKKO | EKKO | Purchasing document — header |
EKPO | EKPO | Purchasing document — items |
EKPA | EKPA | Partner roles |
EKKN | EKKN | Account assignment |
KONP | KONP | Conditions (item) |
KONH | KONH | Conditions (header) |
SY | (virtual) | System data — for SY-UNAME filters |
From here on, every new rule is configuration
The Business Object is now GUARD-ready. Functional
consultants, business users, and analysts open
ZGUARD_CONF and start adding Projects, Rules,
Filters, Steps, Conditions, and Messages — using the Data Sources
the developer registered. The developer can be on a different
team, in a different country, or out for the week. None of that
blocks the next rule.
A few hours, once per Business Object
ZCL_GUARD, feed the tables, call EXECUTEZGUARD_SETNo development ticket required
One developer, one afternoon, and your Business Object is permanently open to configurable checks — across every project, every team, every environment.
See real situations → Back to overview