Processing Sequence When Posting An Event

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Processing sequence when posting a SAP EM event using

BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02
Author: Kevin Wilson (Q Data USA, Inc. SAP Supply Chain Extended Solutions Practice Lead)
Date: 10/21/2013
1 The sequence of BAPI: /SAPTRX/BAPI_EH_ADDEVENTMSG_02
1. Check authorizations
a. Check SNDCOD and SNDID are in table /SAPTRX/AUTH_SND If not then continue
checking
b. Authority-check: Object X_EM_EVM: (/SAPTRX/CS, /SAPTRX/CD, ACTVT=32) (See 2.1.1)
2. Data Pre-Processing
a. Create EVM and Batch GUID (See 2.2.1)
b. Convert data to upper case
c. Convert Tracking IDs (If configured in table /SAPTRX/CONVUSE)
3. Fill data tables
a. Assign Header
i. Assign internal event code using table /SAPTRX/EVENTS
ii. Assign internal reason code using table /SAPTRX/SRCODES
1. Retrieve reason code text from table /SAPTRX/SRCODEST or
/SAPTRX/SRINTCDT
2. Check that the reason code is assigned to the event using table
/SAPTRX/EVC_RC
iii. Assign message mode (MSGMOD) Created artificially = B
iv. Save mode determination using table /SAPTRX/EVM_SAVE (See 2.3.1)
b. Assign Location
i. Map external to internal location codes using function module
/SAPTRX/CODE_MAPPING (See 2.2.3)
c. Assign Partner
i. Map external to internal partner codes using function module
/SAPTRX/CODE_MAPPING (See 2.2.3)
d. Assign EE Modify
i. Map external to internal location and partner codes using function module
/SAPTRX/CODE_MAPPING (See 2.2.3)
e. Assign Confirmation Status Table
i. Map external to internal partner codes using function module
/SAPTRX/CODE_MAPPING (See 2.2.3)
f. Assign Further References
i. Special case: If REFUSAGE = D then get document type from table
/SAPTRX/EXDOC
Sequencing BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02

Author: Kevin Wilson (Q Data USA, Inc.) Page 2

g. Assign Measurements
i. Map external to internal partner codes using function module
/SAPTRX/CODE_MAPPING (See 2.2.3)
h. Assign Status Attribute
i. Assign Parameters
j. Create Event Message Header Extension table
i. Call function /SAPTRX/EXEC_EVM_EXT_PAR_MAP (See 2.2.4)
1. Maps parameters
2. Creates Event Message extension table
k. Assign Attached files
l. Assign Text header
4. Set flag for processing by inactive EH
a. Select from table /SAPTRX/EVMPRIN
5. Save files to the file system or DB?
a. Select from table /SAPTRX/MSG_FATD (Message buffering filter)
b. If file system then generate file name and path
i. Save ASC (Text) or BIN (Binary) file
6. Event Message Input Validation
a. Perform function /SAPTRX/EVTMSGCHECK_02 if BAPI-SKIPCHECK <> X (See 2.2.1)
i. Assign missing time zones (HDR, EEM, CST, MER)
ii. Ensure MSG and Batch GUID are created
iii. Check event exists in table /SAPTRX/EVCODE -> Error
iv. Check reason code exists in table /SAPTRX/SRINTCOD -> Error
v. Check TRXCOD is not initial -> Error
vi. Check TRXID is not initial -> Error
vii. Call function /SAPTRX/CHECK_DATETIME to check the date and time (See 2.2.5)
1. Assigns users local time zone if none are filled in
viii. If reporting Date / Time are not entered then assign system values
ix. Delete file tables if no binary or ascii files are found
x. Check on ATTACHED FILE tables: if mime type is missing, table SDOKMIME and
SDOKMIME_C are queried with the file-extension. Table SDOKMIME is the
standard table that contains MIME content type for file name extension;
SDOKMIME_C is a customizing table with the same purpose
7. BAPI override for Event Message Pre-Processing
a. If BAPI-PREPROCESS_MODE = A then call pre-processing function BAPI-
PREPROCESS_FUNCTION
i. Function module template check: /SAPTRX/EVM_PPF_TEMPL
8. Prevent processing on error
a. If BAPI-BLOCKONERRORIN = X then stop processing if an error was found in the
validation check
9. Message Buffering
a. Call function /SAPTRX/SPLIT_MESSAGE_TABLE_O2
Sequencing BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02

Author: Kevin Wilson (Q Data USA, Inc.) Page 3

i. If BAPI-BUFFER_MODE = A (All messages buffered) -> Move to buffer table
ii. If BAPI-BUFFER_MODE =N (No messages buffered) -> Do nothing
iii. Otherwise check buffering table /SAPTRX/MSG_BUFF
b. Save buffered messages to the database using asynchronous call to function module
/SAPTRX/UPDATE_MSG_DB_02
i. Increase EVM counter for SAP EM licensing audit check using function module
SLIM_CNT_INCREASE_COUNTER (See 2.2.6)
ii. Save to the database
1. Check saving mode from table /SAPTRX/EVM_SAVE
<blank> Entire message is regularly saved in the event message DB
N Event message is not saved
L Only last event message is saved, accounting for evtid,
trxcod, trxid, tipcod, tipid.
R Event message is saved with reduced size
S Only last event message is saved, Current message will be
inserted in DB, but previous message(s) for the same EH will be
deleted. The deletion is accounting for event code, sender and
location as specified in /SAPTRX/EVM_SAVE.
H Only the header entry of the event message is saved
2. Save tables to the database
10. Process non-buffered messages
a. If SYNCHRONOUS = X then process now
i. ELSE process in update task
b. Set processing timestamp
c. Update database tables with call to function module /SAPTRX/UPDATE_MSG_DB_02
(Unless in simulation mode)
d. If reduce message flag is set (Call FM /SAPTRX/SET_REDUCE_MSGS_FLAG explicitly
before each BAPI call to reduce the message) then call function
/SAPTRX/REBUILD_MSGS
i. Rebuilt event messages from information in further references if requested in
cases only Tracking ID differs in event messages to reduce the disk space
e. Process the event messages using function /SAPTRX/PROCESS_MESSAGES_02
i. Check and process EH Generation
1. If BAPI-GENERATION_MODE = A then call function BAPI-
GENERATION_FUNCTION to process events
a. Template: /SAPTRX/EH_GEN_TEMPL
b. Call BAPI /SAPTRX/BAPI_EH_POST
2. ELSE if BAPI-GENERATION_MODE = N = Do Noting
3. ELSE check customizing table /SAPTRX/EVMEHGEN
ii. Process events using method PROCESS_EVENTS of class
/SAPTRX/CL_EVENT_MSG_PROCESSOR
Sequencing BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02

Author: Kevin Wilson (Q Data USA, Inc.) Page 4

1. Check buffering
2. Find EHs -> Method: FIND_EVENT_HANDLERS
a. If no EH is found save as an unprocessed message
b. If found then process event for that EH using method:
PROCESS_EVENT_MSGS for class
/SAPTRX/CL_EH_EVENT_MSG_MODEL
i. Enqueue EH using AO System, ID Type, ID
1. Fail -> Log locked EH
ii. Process message
1. Get rule set
2. Fill last event date in header
3. Get EH type
a. If Change docs are on then write to the
buffer before data is changed
4. Process rules for event 1 at a time
a. Commit BAPIs
5. If flag for processing unprocessed messages is
set in the rule set then process unprocessed
events using method:
process_unprocessed_msgs
iii. Dequeue EH, EH Set and Doc Flow
2 Appendix
2.1 Authorization checks
2.1.1 Check Sender ID and Code
authority-check object 'X_EM_EVM'
id '/SAPTRX/CS' field ls_evm_hdr-sndcod
id '/SAPTRX/CD' field ls_evm_hdr-sndid "#EC *
id 'ACTVT' field '32'.
2.2 Function Calls
2.2.1 /SAPTRX/EVTMSGCHECK_02 Validate event message input
Event message input: check if the minimum required amount of data is passed in input:
Event code Checked in table /SAPTRX/EVCODE
Date : For date and time formal plausibility checks are carried out (this means that it is checked
whether a field can possibly be a date /time / time zone / timestamp, but not if the date is
"sensible" (that is let to the event manager rules).
reporting date
Tracking Ids
Sequencing BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02

Author: Kevin Wilson (Q Data USA, Inc.) Page 5

IF in the message header there is no recognizable event code (/SAPTRX/EVCODE), or no tracking IDs, the
message fails the check.
Furthermore, if there is no file attached, the file header and reference tables are deleted
2.2.2 SYSTEM_UUID_C22_CREATE - EVM GUID Create
2.2.3 /SAPTRX/CODE_MAPPING Map external to internal location and partner codes
Table: /SAPTRX/MAPLOCI2, /SAPTRX/MAPLOCID, /SAPTRX/MAPPART2 (Partner Code mapping table),
/SAPTRX/MAPPART
2.2.4 /SAPTRX/EXEC_EVM_EXT_PAR_MAP Message parameter mapping to Extension table
Check event message mapping profile in table /SAPTRX/EXEC_EVM_EXT_PAR_MAP,
/SAPTRX/TSPARMAP, /SAPTRX/TSPARDC
Perform value mapping if required (Checking table /SAPTRX/TSPARMVL)
Create Event Message Extension table
o Retrieve table from /SAPTRX/EXTTABID
2.2.5 /SAPTRX/CHECK_DATETIME Check date and time appropriateness
Calls FM: /SAPTRX/CHECK_DATE to check date plausibility
Calls FM: /SAPTRX/CHECK_TIME to check time plausibility
Calls FM: /SAPTRX/CHECK_TIMEZONE to check time plausibility
o Select from table TTZZ to validate
Calls FM: /SAPTRX/CHECK_TIMESTAMP to check time plausibility
2.2.6 SLIM_CNT_INCREASE_COUNTER SAP EM License auditing
The counter is assigned to a specific server and a specific work process in DB table TUCNTRAW for
performance reasons: without this assignment long waiting times would occur for frequently used
counters because of database locks. (Everybody would be waiting for access to this one record.)
The work process specific counters from table TUCNTRAW are consolidated daily by function
SLIM_CNT_CONSOLIDATE_COUNTERS into table TUCNT. The old counters are deleted from table
TUCNTRAW.
2.3 Miscellaneous
2.3.1 Message save mode
<blank> Entire message is regularly saved in the event message DB
N Event message is not saved
L Only last event message is saved
R Event message is saved with reduced size
S Only last event message is saved, accounting for sender/loc.
H Only the header entry of the event message is saved

You might also like