Debugging BOPF Determinations and Validations in SAP TM
Every SAP TM project hits the same ticket sooner or later: “The field changed by itself” or “The Freight Order cannot be saved, but the message makes no sense.” Behind both sits BOPF. A Freight Order (/SCMTMS/TOR) runs dozens of determinations and validations on every modify and save, and standard and customer logic run in the same round trip.
Stepping through from the UI feeder class does not scale: you end up deep in /BOBF/CL_FRW and the determination you want ran three loops ago. This is the routine we use on projects to find out quickly which determination or validation did what.
1) Know what you are looking for: the BOPF execution model in one minute
Be clear about which kind of logic you are chasing. Much debugging time is lost looking for a determination when the culprit is an action.
- Determinations implement /BOBF/IF_FRW_DETERMINATION (method EXECUTE, plus CHECK and CHECK_DELTA to filter which instances run). They are triggered by changes on trigger nodes at an evaluation timepoint, such as after modify, before save (finalize) or after loading.
- Validations implement /BOBF/IF_FRW_VALIDATION. They return failed keys (ET_FAILED_KEY) and messages (EO_MESSAGE). Action validations block an action. Consistency validations run on modify or save and can prevent the save or set a consistency status.
- Actions implement /BOBF/IF_FRW_ACTION and run only when something calls them explicitly: a UI button, a PPF output, a background report or another action.
Why this matters
If a field changes the moment the user leaves the input field, look at after-modify determinations. If it changes only after save, look at before-save timepoints. If a field is already “wrong” when the document opens, look at after-loading determinations and at the persisted value in the table (for example /SCMTMS/D_TORROT for the TOR root).
2) Step 1 – Read the model in /BOBF/CONF_UI before debugging
Transaction /BOBF/CONF_UI is the BOPF configuration browser. Open business object /SCMTMS/TOR and expand the node you care about (ROOT, ITEM_TR, STOP, and so on). For each node the screen shows the lists of determinations, validations and actions. Double-clicking a determination shows:
- the implementing class (this is where the breakpoint goes),
- the trigger nodes and trigger operations (create, update, delete),
- the evaluation timepoints,
- the dependencies to other determinations, which control the execution order.
For a “which logic touched field X” question, write down every determination on the node that owns field X and on its parent and child nodes. Customer enhancements created with the BOPF Enhancement Workbench (transaction BOPF_EWB) show up in the same model, so do not forget your own Z determinations. In our experience they cause about half of these tickets.
Pitfall
Determinations with an empty CHECK_DELTA implementation run for every triggered instance. A determination that looks harmless in the model can still overwrite a field the user just entered, if the same field is also written further down in the dependency chain.
3) Step 2 – Reproduce outside the UI with /BOBF/TEST_UI
The FPM UI, the cockpit and PPF add noise. Transaction /BOBF/TEST_UI (on newer releases the shortcut BOBT opens the same tool; verify in your release) lets you load a single TOR instance and work directly on BOPF:
- Enter BO /SCMTMS/TOR and load the instance, either by node key or by alternative key (TOR_ID with leading zeros).
- Navigate to the node, change the field the user changes, and confirm. The after-modify determinations run now.
- Use the check function to run consistency validations without saving. The messages appear in the message area of the tool.
- Run the action the user runs, if the problem is tied to an action.
- Only save if you are in a sandbox or test client.
Set your breakpoints in the classes from Step 1 before you confirm the change. If the problem does not reproduce here, the trigger is likely in the UI layer, an action or a PPF output, not in a determination.
4) Step 3 – Find out which determination changed a field
When the short list from Step 1 is too long, let the buffer tell you. Each BOPF node has a buffer class in the model, usually /BOBF/CL_BUF_SIMPLE. Every determination writes through the framework into that buffer. So a breakpoint on the buffer’s modify method catches all writers.
- Set a breakpoint in the modify method of /BOBF/CL_BUF_SIMPLE (check the exact method name in SE24 in your release).
- Add a condition on the node key so it stops only for your node, e.g. the key of /SCMTMS/IF_TOR_C=>SC_NODE-STOP. The node keys are GUIDs; read them from /BOBF/CONF_UI or from the constants interface in the debugger.
- When it stops, open the ABAP call stack. Go up to the first class that is not part of the /BOBF/ framework. That is the determination, action or BAdI implementation that wrote the data.
An alternative that works well for single fields is a watchpoint on the changed data in the determination’s local table, once you are inside a candidate class. If the candidate list is unclear, record the dialog step with SAT and search the hit list for /SCMTMS/ and Z classes that implement the determination interface.
Decision table: which tool for which symptom
| Symptom | Start with | Then |
|---|---|---|
| Field changes after user input | /BOBF/CONF_UI, after-modify determinations on the node | Breakpoints in those classes, reproduce in /BOBF/TEST_UI |
| Field changes only on save | Before-save determinations (finalize) | Buffer modify breakpoint with node key condition |
| Value wrong when document opens | Table value (e.g. /SCMTMS/D_TORROT) vs. UI value | After-loading determinations, UI conversion |
| Save blocked, unclear error | Message origin (see Step 4) | Validation class, ET_FAILED_KEY logic |
| Not reproducible in /BOBF/TEST_UI | Feeder class, action or PPF output | SAT trace of the UI round trip |
5) Step 4 – Trace a validation message back to its source
Validation messages are instances of exception classes that inherit from /BOBF/CM_FRW, collected in an /BOBF/IF_FRW_MESSAGE object. On the screen the user only sees the text. To find the origin:
- Get the message class and number from the UI message details, then use the where-used list (SE91) to find the TM message class or exception class that raises it.
- In the debugger, inspect the EO_MESSAGE object returned by the service manager. Some releases include a BOPF debugger script that formats these objects; the name /BOBF/TOOL_DEBUGGER_SCRIPT_F is mentioned in community posts, but verify it in your release.
- Check ET_FAILED_KEY in the validation. If your instance key is in it, that validation is the one blocking the save. A message without a failed key is only information.
To repeat a validation without clicking through the UI, a small test report helps. The sketch below loads a Freight Order by TOR_ID and runs the consistency check on the root and its substructure. Check the parameter names against /BOBF/IF_TRA_SERVICE_MANAGER in SE24 in your release before using it.
REPORT zdebug_tor_check.
PARAMETERS p_torid TYPE /scmtms/tor_id OBLIGATORY.
DATA lt_torid TYPE STANDARD TABLE OF /scmtms/tor_id WITH EMPTY KEY.
DATA lt_key TYPE /bobf/t_frw_key.
DATA(lo_srv) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/scmtms/if_tor_c=>sc_bo_key ).
" TOR_ID is stored with leading zeros
lt_torid = VALUE #( ( |{ p_torid ALPHA = IN }| ) ).
lo_srv->convert_altern_key(
EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root
iv_altkey_key = /scmtms/if_tor_c=>sc_alternative_key-root-tor_id
it_key = lt_torid
IMPORTING et_key = lt_key ).
" Runs the consistency validations; set breakpoints in the
" validation classes found in /BOBF/CONF_UI before executing
lo_srv->check_consistency(
EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root
it_key = lt_key
iv_check_scope = /bobf/if_frw_c=>sc_scope_substructure
IMPORTING eo_message = DATA(lo_msg) ).
IF lo_msg IS BOUND.
lo_msg->get_messages( IMPORTING et_message = DATA(lt_msg) ).
LOOP AT lt_msg INTO DATA(ls_msg).
WRITE / ls_msg-message->get_text( ).
ENDLOOP.
ENDIF.
6) Step 5 – Debug your own determinations safely
Most of these tickets end in a Z determination. A few rules save time:
- Always implement CHECK_DELTA so the determination runs only when its input fields really changed. This avoids loops and surprise overwrites.
- Declare dependencies in the model instead of relying on execution order by chance. Without a dependency, the order between two determinations on the same timepoint is not something you should rely on.
- Write only through IO_MODIFY, and only the fields you own. Changing a field that a standard determination also derives creates a ping-pong that is very hard to debug.
- Add a user-specific break point (BREAK-POINT ID with a checkpoint group, activated in SAAB) instead of hard-coded BREAK statements, so the code can go to production and still be debugged there.
Pitfall
Breakpoints in background processing (PPF, batch planning, inbound services) are not reached by dialog debugging. Use an external breakpoint for the processing user, or reproduce the call in /BOBF/TEST_UI or in the test report above.
Takeaways
- Read the model in /BOBF/CONF_UI first: the node, its determinations, timepoints and dependencies give you a short list of suspect classes.
- Reproduce in /BOBF/TEST_UI to separate BOPF logic from UI and output logic.
- A conditional breakpoint on the node buffer’s modify method, filtered by node key, finds any writer. The call stack does the rest.
- For blocked saves, follow the message and ET_FAILED_KEY back to the validation, and use a small check report to repeat it without saving.
If you have your own tricks for BOPF debugging in TM, share them in the comments.