Skip to Content
author's profile photo
Former Member

Any Way to Share an Update Rule?

I have a situation where I have to go and revise about 20 Update Rules that all use the same 25 lines of ABAP code.

Looking to reduce future maintenance efforts, rather than cut and paste this code into all the updates rules, I want to be able to reuse the code so that it only needs to be maintained in once.

I looked at custom defined functions for the formula builder, but that means I need to change the current update rules to a formula and then specify some parameters in the formula. This doesn't save me any time or really give me the reusability I am looking for in this case.

So now I am leaning towards having one of our App Dev folks create an Include Program so the 25 lines of code can be copied into each update rule by simply placing an INCLUDE stmt in the update rule.

I also considered creating the code as a function module and calling it, but the Include program seems more straight forward, and someone else once cautioned me about some problems they had calling an FM in an update rule (didn't work right for them, but don't know any other details).

I like the Include Program approach, allowing me to just change the Include program and reactivate the rules when a change is needed.

Are there any other options to consider or issues to conerned about?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    author's profile photo
    Former Member
    Oct 05, 2005 at 02:17 PM

    Sidartha -

    Copying the doesn't really accomplish what I'm trying to do. I trying to find a way to avoid having to revisit all 20 update rules next time there is a change.

    To all the others that have posted so far suggesting using a Function Module. That has been an option I am considering - glad to here others are not having problems with them.

    In this case I would think an FM might be a little more limiting than an Include program and I was trying to keep it very simple for others to understand and maintain - not that using an FM was a big deal.

    If I use a FM, each Update Rule would still need to have some data declarations and a few lines to add the call and export/import parameter lists, e.g.

    parameters: op1 type i default 2, "operand 1

    op2 type i default 3. "operand 2

    data rslt type p decimals 2. "result

    call function 'Z_TX_DIV'

    exporting

    p1 = op1

    p2 = op2

    importing

    p3 = rslt.

    Wouldn't

    INCLUDE Z_MY_UPDT_RULE.

    be much easier?

    And to cover my bases, I probably need to add exception handling. While not large, I also have to imagine there is some additional resource consumption having to make the call and return. Any change to my logic that effects the data length/type or parameter lists also means I hmight need to come back and modify the 20 update rules.

    It just seems to me this is really a situation better suited for an INCLUDE - I don't need any data declarations, just s small snippet of the same code - isn't that what an INCLUDE is all about?

    Would like to here from someone using INCLUDE programs in Update Rules. Might still go the FM route. The other reason to consider using an FM is that I think I also may have Transfer Rules that need to perform the same code and that means I can not reference the communication structure in the INCLUDE.

    Thanks for the feedback on FMs.

    My thinking was to try to keep this as simple as possible for others to understand and maintain - , but it

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      guys,

      i think otherthan Exception handling, FM is an example of moduler programming even though you can achieve the same result with INCLUDES.

      but in case of PIZZMAN, you have same set of lines to be used in 20 UpdateRules then go for INCLUDE..cheers..

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:35 AM

    Hi,

    If I'm understanding right, why dont u go for the option of copying update rule.

    Regards-

    Siddhu

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:58 AM

    hi,

    Function module will be a best option because even u can use it some other places based on some parameters and we are function Modules everywhere and no problems whatsover.

    reward if helps.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 07:02 AM

    We have used FMs in update rules with no issues whatsovever.

    Shailesh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 09:35 AM

    hi,

    I use FMs in such cases and have never had any problems...

    regs

    ak

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 04:14 PM

    Thanks all -

    Good responses. Demonstrates always more than one way to skin a cat.

    Thanks Roberto for the Update Rules include example - I see where there are a number of similar Includes for other appslications. Lots of interesting stuff in them.

    Add comment
    10|10000 characters needed characters exceeded