Skip to Content

Non workflow based substitution - Badi WF_SUBSTITUTE

Hi All,

Hope you are well, can you please point me in the right direction.

I have implemented non workflow based substitution and so far so good, i have created a profile and when creating substitution rules i am bale to create the rule and update HRUS_D2. I am then processing the substitution based on the active substitution for that profile and everything works fine however i have a problem with sequence of actions/process. I would like to send an email when creating the rule or soon after creating the substitution rule.

I have used the Badi WF_SUBSTITUTUE and this is where the issue is,this BADI is called before the entries in HRUS_D2 are created, therefore my code is not working as i check for entries in HRUS_D2. I would liek my code to be executed after the entries in HRUS_D2 have been created.

Is there another BADI which is called soon after creating the substitution rule? If not where can i insert my code to send emails soon after a rule has been created. I have more business requirements in the pipeline but they will all be based on this logic ie processing the logic after entries shave been written to the table. I want this to be be dynamic ie done soon after creating the rule.

Thank you in advance for your help.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 17, 2015 at 09:41 AM

    I have few approaches for your problem.

    1) First of all, why do you exactly need to execute your code after the table has been updated? When you maintain the substitute, doesn't the method of the BADI have the needed parameters/information concerning the substitution (=same fields as the HRUS_D2)? (Just now I don't have access to a system to check this.) All the rest of the substitution rules are in HRUS_D2 and the one being created/manipulated "is" in the BADI method? Why do you need to read the whole table?

    2) If a BADI doesn't fulfill requirements (or there isn't any BADI / user-exit), then the normal approach would be to find a suitable spot for a enhancement in the standard code. If I understand correctly, this was basically what Sandy tried to say. I am not sure but I guess that those functions that Sandy mentioned (or at least some of them), gets executed when the substitution gets saves. You could put a break point in those, and see what is going on, and then make an enhancement to a suitable spot (after the database has been updated). You could also put breakpoint to the BADI method, and continue debugging from there. If this does not make sense to you, then I suggest you to ask an experienced ABAPer to take a look.

    3) Use the BADI to trigger a workflow. Just a simple workflow that has a wait step (1 minute or whatever), perhaps some kind of "database read of HRUS_D2" step and email sending step. After 1 minute the table has been updated and you can read the table, and send your email.

    Kind regards,


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Many thanks for your explanation actually I want to execute my code after the HRUS_D2 has been updated simply because I want to send a notification email soon after the substitute rule has been created. This is a non workflow based substitution hence this approach. Basically we have a custom Webdynpro application and we want substitute this.

      I have managed to write a separate program that will be schedule once a day, it will read HRUS_D2 and send email valid entries are in the table. I just wanted to be clever and do things instantly, ie i wanted to send the email soon after creating the rule and not wait for a job..

      So all in all I would this is resolved though not in a clean and clever way

      Thank you.


  • Posted on May 16, 2015 at 05:00 AM


    You can try to create a POST EXIT using an implicit enhancement implementation in one of the following FM :




    In this implicit enhancement implementation, you can try call a custom FM which will be called in Update task (when substitution entry is committed ). and you can trigger an email. If there are any delay in commit, then I suggest create a Custom Class and event and trigger an event instead of triggering email. Start a workflow based on this event and add a WAIT step in the workflow to check the entry in table HRUS_D2. After this wait step, trigger the email from WF



    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Sandy,

      There is no workflow behind this and i don't want to use a workflow. I am just creating the entries in HRUS_D2 once a substitute rule has been created. I am then readin the entries in HRUS_D2 and process based on that entry. My issues is that I would like to read this tabel after the entries has been created but teh BADi WF_SUBSTITUTE is called before teh table is updated.

      The suggested SAP_WAPI_SUBSTITUTE_MAINTAIN would be fine but the issue is where do i call this? i need the email to be triggered soon after creating the substitution profile.

      Please help.

      Thank you.


  • Posted on May 16, 2015 at 06:40 AM

    Dear Andy,

    Have u checked below function module.


    there is one class for updating the substitute.

    CL_SWL_SUBSTITUTION Please cchk.



    Add a comment
    10|10000 characters needed characters exceeded

    • Dear Andy,

      Please check this FM RH_UPDATE_SUBST_LIST_SERVER, If you check the code of this FM, it's directly updates the table with insert statement.

      1. Create one Program with selection screen element same as like the importing parameter of FM. Create the implicit enhancement point in the FM after successfully insert send the mail. or in the program you can directly check the error tab is populated or not. if error tab is blank then send the mail.



Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.