Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

code should not get executed for a particular background job run

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Thanks for your answers. I'm using the FM "BP_FIND_JOBS_WITH_PROGRAM" and passing the program name and status as "R" (running). This should solve it.

RK

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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