sap-transaction-notifications

Installation
SKILL.md

SAP Transaction Notifications

SAP Business One calls SBO_SP_TransactionNotification on every committed transaction. You edit the body; SAP defines only the signature.

Quick Start

Add a guard inside the BEGIN … END block. Always use ALTER PROCEDURE (never CREATE) — the procedure already exists in the company database:

IF :object_type = '4' AND (:transaction_type = 'A' OR :transaction_type = 'U') THEN
    CALL "MYAPP_TN_OBJ004_OITM" (:list_of_cols_val_tab_del, :transaction_type, :error, :error_message);
END IF;

Procedure Signature

ALTER PROCEDURE SBO_SP_TransactionNotification
(
    IN  object_type              nvarchar(30),
    IN  transaction_type         nchar(1),
    IN  num_of_cols_in_key       int,
    IN  list_of_key_cols_tab_del nvarchar(255),
    IN  list_of_cols_val_tab_del nvarchar(255)
)
LANGUAGE SQLSCRIPT
AS
error         int;
error_message nvarchar(200);
BEGIN
    error         := 0;
    error_message := N'Ok';

    -- routing guards go here

    SELECT :error, :error_message FROM dummy;  -- mandatory return
END;

Always initialise error := 0 / error_message := N'Ok' as the first two statements. Always end with SELECT :error, :error_message FROM dummy; — SAP reads return values through this SELECT. Omitting it silently swallows all errors.

Transaction Types

Code Meaning
A Add — new record committed
U Update — record updated
D Delete — record deleted
C Cancel — document cancelled
L Close — document closed

Sub-procedure Naming

Pattern: [PROJECT]_TN_OBJ[nnn]_[TABLE] — prefix with a project token to avoid collisions.

Segment Meaning Example
nnn zero-padded object type code 004, 017
TABLE SAP table name OITM, ORDR

Examples: MYAPP_TN_OBJ004_OITM, MYAPP_TN_OBJ017_ORDR

Object type codes: see references/stored-procedure.md.

Error Contract

Return error = 0 for success (SAP commits). Return error ≠ 0 to block the transaction — SAP rolls back and shows error_message to the user. Only block for truly fatal errors.

See Also

Related skills
Installs
1
Repository
kehwar/skills
First Seen
3 days ago
Security Audits