An accounts payable analyst messaged me two weeks after a supplier create was activated. Company-code payment terms were Z030. The requester's note from submit day said they had typed NT30, and that the screen still showed it. Nobody rejected the request. Purchasing had already posted an invoice on Z030.
I opened the change request. Payment terms were Z030. The approver had not edited that field, and the active supplier matched the request. The value was already wrong when the request was approved. This is a different problem from a change request that activates and never replicates, which I wrote about earlier this month.
The change documents, next to the mail
I read the change documents for the company-code data with the requester's mail beside them.
If they saved NT30 and a later check rewrote it, the document shows NT30, then Z030, under their user ID, and no comment on the request. The user ID is theirs because the derivation ran in their session. The line looks like they changed their mind. They had not.
If they pressed Check before the first save, NT30 may never have been stored. The first value on the document is already Z030. The mail, or a screenshot, is the only copy of what they typed. Activation then copies that value onto the supplier, so the partner's own change documents start too late.
The same reading works for the reconciliation account on the company code, and for payment terms on the purchasing organization. A legal value reached the approver. The mail said something else.
Then I repeat their steps on the change-request type in the menu. I type NT30. I press Check. The field shows Z030. That flip is the rule.
The rule is in USMD_RULE
USMD_SSW_RULE and the agent decision tables decide who gets the work item. They do not write payment terms.
In MDGIMG I open General Settings, Data Quality and Search, Define Validation and Derivation Rules. That activity is the Web Dynpro application USMD_RULE. Data model BP opens the BRF+ catalog FMDM_MODEL_BP.
A derivation node is named DERIVE_ plus the entity type. Company code is BP_COMPNY, so the node is DERIVE_BP_COMPNY. That function is assigned to the DERIVATION event. The check node for the same entity is CHECK_BP_COMPNY, on CHECK_ENTITY. CHECK_CHANGE_REQUEST runs when the change request is checked, and again before the final check. A check can raise a message. Change Context, on the derivation, is what replaces a value.
Purchasing-organization terms sit on BP_PORG, node DERIVE_BP_PORG. I open both. If payment terms is not on the signature, I am in the wrong node.
If BRF+ does not assign the attribute, I check BAdI USMD_RULE_SERVICE, activity BAdI: Define Validations/Derivations in the same MDGIMG branch. Filter data model BP and entity type BP_COMPNY. DERIVE_ENTITY writes. CHECK_ENTITY checks. When the terms depend on another entity, such as the account group on the header, that write is in USMD_RULE_SERVICE_CROSS_ET.
It runs again after they type
The functional spec called the row a default: payment terms from the account group, and only when the requester leaves the field blank. The BRF+ row had no such test. For that account group, Change Context set the terms to Z030, and the condition was empty, so it matched every time.
DERIVATION does not fire once when the change request is created. It fires when data is entered in single processing, so every roundtrip sends the company-code entity again. Check does that. So does leaving the company-code screen and coming back, or changing the account group. Each call wrote Z030 over the value already there.
They typed NT30 on the first visit. The next check put Z030 back. Submit was on another screen, so they did not see the flip. Z030 is valid for that account group, so no check message fired, and the approver approved it.
The same row can still win when the condition does say initial. I have seen that test pointed at the active supplier. On a new company code the active record has no payment terms, so the test stays true after NT30 is on the screen. Every check writes Z030. The guard has to read the change request, not the active copy.
The context also carries SAPFMDM_CREQUEST_TYPE. A blank matches every type. I retest the type in the menu, not a workshop type sitting in that column.
Simulate the value they typed
I simulate DERIVE_BP_COMPNY in the BRF+ session USMD_RULE opened, before I edit the rule.
The context is the one after they typed. Account group filled. Company code filled. Payment terms already NT30. Change-request type set to the one in the menu. If the result comes back Z030, the row overwrites. That is the function the UI calls.
I run it again with payment terms left initial. The result should be Z030. That is the only case the spec asked for.
If the simulation keeps NT30 and the screen still flips, I go to DERIVE_ENTITY on USMD_RULE_SERVICE for BP_COMPNY. Another implementation can assign the attribute after BRF+ has left it alone.
A default stays a default
The condition I transport is: payment terms on the change request is initial. Only then does Change Context set Z030.
I read every later row in the ruleset, and every other derivation on BP_COMPNY that assigns the same attribute. One guarded row is useless if the next row sets Z030 with an empty condition. Every assignment to that field needs the initial check, or the extra assignment comes out.
Then I split the spec. Default Z030 when the field is blank. That is the derivation. This account group is not allowed to keep another term. That is not a derivation. Change Context on the second sentence removes the value before the approver can see it.
The second sentence goes on a check. CHECK_BP_COMPNY is enough when the test only needs that entity. I use CHECK_CHANGE_REQUEST when it has to see the whole request, including the run before the final check. The action is a message. NT30 stays on the screen. An error stops the request. A warning is only for a term the business will still accept. A message on the derivation is too late: Change Context has already replaced the value, under the requester's user.
DERIVE_ENTITY gets the same split. I fill the attribute only when it is initial in the data the method receives. Anything that must block the request goes in CHECK_ENTITY.
I activate the changed function in BRF+. A saved change that is not activated leaves the old row running. The application has to travel with the data-quality customizing, into the system where the invoice was posted.
What has to survive Check
I retest on the change-request type in the menu.
Payment terms left blank, account group set to the one in the rule. After Check, BP_COMPNY shows Z030.
Payment terms set to NT30. I press Check, leave the company-code screen, come back, and submit without editing that field. The last change-document value is NT30. If Z030 returns, the guard is on the active record, or another row is still assigning the field.
Where that account group must not use NT30, Check returns the message and leaves NT30 on the screen. The request must not activate with Z030 written underneath.
The same two tests cover the reconciliation account on BP_COMPNY, and payment terms on BP_PORG. Blank receives the default. A typed value is still there after Check, after a roundtrip, and after submit.
One request goes through to activation. The active supplier shows the term from the mail. That is the field I send back to accounts payable.
To walk this on practice servers, join the next MDG batch at https://saberia.in/training, or email hikmat@saberia.in.