Skip to Content
author's profile photo Former Member
Former Member

code should not get executed for a particular background job run

I have a function exit which should not get triggered for a particular batch job run.It should get executed for online transaction and any other jobs. Using the sy-batch <>'X' check is not advicable as it will block all other interfaces/jobs. Is there a best way to get around this. Can i read the job details using through some FM and make a check. Any ideas higly appreciated.

Thanks,

RK

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 09:25 PM

    That's a tough one - if you use some sort of "swtich" that you EXPORT to memory, then you effectively turn off the function exit for the entire time that the "ignored" job is being run in the background. Any other background job or on-line program would see the exit switched off for the same period of time. Which is the same result of looking for a "running" job name which should be ignored.

    Is there some other logic that can be used to determine if the exit should be executed or not? Maybe some more details would help.

    Regards,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      There is a program which updates the PO items and is run once in a month in background as a batch job.When this happens it also triggers a function exit for release strategy. We need to prevent from triggering the release strategy for PO. How to use export memory here. can you give more details.May be we can use sy-cprog also to restrict that to only the given interface.

      Thanks,

      RK

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2008 at 05:43 PM

    RK-

    Sometimes (but not always) you can use the field SY-CPROG (calling program) to help with logic on whether or not code should be executed.

    Hope this helps,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2008 at 05:44 PM

    Hello

    You could try FM GET_JOB_RUNTIME_INFO to get the name of the job that is running your program

    Then you could execute code based on the job name.

    Regards

    Greg Kern

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Any other way to resolve this may be using export memory as we feel the idea of using FM"BP_find_jobs_with_program" is not a good idea even though it works.

      The following code would completely block it from execution.

      IF sy-batch = 'X' AND sy-cprog = "program_name".

      EXIT.

      ENDIF.

      Thanks,

      RK

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 09:51 PM

    The monthy program that updates the PO's - is that the only process it's used in? Or is it used for other processes that should have the user-exit execute?

    If it's the only program that should ignore the user exit, then SY-CPROG should work (depending on the level at which it is called). If it is not - and the same program is used other ways, maybe you could make a "Z" copy of the program, then ignore the "Z" program? That isn't always the best way, as this increases maintenance in case of upgrades/OSS notes applied to the original program, etc.

    Have you tried interrogating the value of SY-CPROG to see if it changes from an backgroud run vs. a n on-line use?

    -Mark

    Add a comment
    10|10000 characters needed characters exceeded

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.