Skip to Content

Challenge

The MDG rule derivation standard code strictly turns custom triggered error or warning messages of derivation BAdI customer code into info message type. In some situations the derivation BAdI is a perfect location for doing not only derivations but also other checks and data transformations including throwing warning or even error messages (for stopping the MDG process).

 

 

Solution approach

Implement a so-called “implicit enhancement” at the very end of the relevant method IF_USMD_RULE_SERVICE~DERIVE_ENTITY of class CL_USMD_RULE_SERVICE. The disadvantage of an “implicit enhancement” is the dependency on future code-changes of the original code – however this is quite unlikely. The advantage is definitely the simplicity of this solution approach.

 

A suggestion for such an implementation approach:

“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””$”$\SE:(1) Class CL_USMD_RULE_SERVICE, Interface IF_USMD_RULE_SERVICE, Method DERIVE_ENTITY, End                                                             A
*$*$-Start: (1)———————————————————————————$*$*
ENHANCEMENT 1  ZZ_DERIVE_MSG_TYPE_MGT.    “active version
* this DERIVE method turns all W messages into info message
* in special case that messages out of class ZZ_MSG_CLASS are used, warn messages should remain warnings
loop at et_message into ls_message where msgid eq ‘ZZ_MSG_CLASS’ and msgty eq ‘I’.
if lf_error = ‘X’ .
ls_message-msgty = ‘E’.
else.
ls_message-msgty = ‘W’.
endif.
modify et_message from ls_message index sy-tabix.
endloop.
ENDENHANCEMENT.
*$*$-End:   (1)———————————————————————————$*$*

 

 

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Michael Theis

    Hi,

    please be aware that doing this might cause inconsistencies in your data. Warnings or errors returned from the derivation method of the rule services BAdI can cause mis-behavior of the delta buffer. You might be faced with un-resolvable error messages that finally require the creation of a new change request.

    For checking data, you should always use the check methods of the rule service BAdI.

    Kind regards

    Michael

    (0) 
  2. Jan Rauscher
    Post author

    Hello Michael,

    am aware that the validation and derivation are two kind of things and in most cases info messages are the best option for the derivation BAdI. However in some situations it makes not only sense to derive and change user input but also warn and even stop the process if needed. In one customer project i had such a situation where we had a remarkable amount of rule logic distributed in validation and derivation BAdI and it wouldn’t be a good idea to move all logic into the validations BAdI (sometimes customer projects have a time and budget limit). So i wanted to share this quick but helpful solution to have an efficient way to handle the requirement.

    Best,

    Jan

    (0) 

Leave a Reply