Triggering background jobs
What is the best solution to trigger background jobs within user exits?
Currently the method I am using is quite cumbersome.
1. Create user event in SM62
2. Create background job attached to this user event.
3. Within user exit call function module BP_EVENT_RAISE using user event.
The problem I have with this approach is that in the program I have to add a 15 - 20 sec delay to handle record locking. Lets say I am in a user exit in MM02, triggering this event without the delay can lead to no records been processed.
What are other ways of implementing this solution?
Can I do a SUBMIT report VIA JOB
or CALL FUNCTION IN UPDATE TASK.
Try this way also.
In the userexit update a custom table with document number + flag (pending for process)
Create standalone program that to be scheduled like every 5 minutes (as you like ) search for this table and get all open documents (with flag eq space ) and process one by one.( Calling jobs)
This will reduced number of repetative background jobs
Say User A edit document 100 at 10.00 am and saves at 10.01 am and user B edit document 100 at 10.02 am and save it
10.03 am ( so every save if you trigger a backgound job, unncessary create jobs for same document number 10 )
a®
Similar Messages
-
Error in triggering background job
HI, I've been facing an error which a background job is being scheduled. The scenario is something like this ...
1) A third party schedulling system triggers a SAP job and monitors the progress
2) In SAP, the master job is been copied with a different user name and then released for processing.
3) There are multiple jobs which get triggered but there is one job which is causing a problem.
4) The job makes a copy an stays in a scheduled status without getting released. While i try to manually release the job it give me an error that cannot create record in the database.
5) Upon checking the system log it gives me this - Error: INSERT background sched. table(job $$$$).
There is already an entry for the specified job in the table TBTCS.
6) While checking the TBTCS table i've found multiple entries out there. Should this table be empty or have information about the runtime of this job.
Please help as this background job is causing concerns in archiving processess defined.
Thankx in advance for your help.
Arvind.the earlier problem of background job was solved by changing the output device assigned to user wf-batch .
regarding the transport request :
when i was trying to execute the step : "Schedule bakgrd for missed deadlines " MANUEL it was giving me an option of SAVE AND SCHEDULE . which was creating the transport request . but when i executed it automatically it worked fine without asking a request to me ... i don't know why )-: ... probablly we can specify a different interval then the standard of three minutes and which will be transported (it's just a guess) . i have executed it automatically ...
well thanks all for u r help -
Triggering background job event from Unix script
Hi all,
I am having one question regarding triggering of background job in SAP using Events from Unix script. Is this possible? If so, can anyboy provide some sample code related to Unix script and how do we communicate to SAP from Unix system. Actually, here the backend of R/3 system is MSSQL. I am having a program in R/3 system which is scheduled as a background job based upon event trigger. I want to trigger that even from the unix script.
Appreciate for your help in advance.
Thanks,
Adithya KHi,
Check if this can help you
http://help.sap.com/saphelp_sm32/helpdata/en/fa/096e6b543b11d1898e0000e8322d00/content.htm
Regards,
Atish -
Create background job triggered by another job
Hi experts,
I want to run FCHU in background everytime I finished run F110.
I'm thinking to use background job creation SM36 - triggered by job. But the problem is, job created from F110 the job name is not fixed.
Please anyone can give better idea ??
Thanks,
MelissaHi melissa,
The suggestion given by Prem is perfectly Ok.
I would suggest you to create an event by sm62 and then create an event triggered background job which will run the FCHU in Back ground.
So you need to get an enhancement point in F110 and put the code of triggering the event .
If there is no enhancement then you can create a program which will call the Transaction F110 by using CALL TRANSACTION statement and after F110 processing the control will get back to your program and you can write a code for triggering the event by using the FM SWE_EVENT_CREATE.
I hope this will help you -
Sending of email triggered in a background job ends with error.
Hello all,
I have created a API which triggers mail to a distribution list using class CL_BCS. When i execute this API in foreground it works fine and the mails are triggered.
However i am calling this API in a report which will scheduled as a background job in my application and this job executes for some 5 to 6 hours and after that i trigger the mail. However at this point the job gets cancelled due to an abort message raised in
one of the CL_BCS methods.
The method is cl_cam_address_bcs=>create_internet_address which is called in my API and internally this calls many other methods. The abort meessage is thrown from the method instantiate_imp_class of class CL_EXIT_MASTER.
The ST22 log reads like this:
Runtime Errors: LOAD_SWITCHSTATES_MISMATCH
Short text: Current switch statuses are incompatible with program switch statuses.
What happened?
The current switch statuses that are read for the execution of the
program "CL_IM_CVI_ADDRESS_UPD_IMPL====CP" are incompatible with the switch
statuses with which the
program "CL_IM_CVI_ADDRESS_UPD_IMPL====CP" was generated at the time
20090902114544.
Any advice would be greatly helpful.
Warm Regards,
Naveen MHi!
How you determine sender (method set_sender) ? if you use current user, when it runs on background use a backgorund user and it maybe can not determine an email.
Try force a sender (harcode your user for test when sy-batch eq 'X')
If it works, you need to determine the user to be used on jobs to solve this problem.
I hope it helps
Regards!!!! -
Triggering a background job of class 'A' from within the ABAP program
Dear All,
We are implementing SAP ECC 6.0 on IBM System i, i5/OS V5R4, SAP kernel 7.00, kernel patch level 173.
Is there a way to control that when a background job is triggered from within an ABAP program using the : CALL FUNCTION 'JOB_OPEN' statement, the background job is of class A ?
I know that through transaction SM37, the job class for a background job can be changed manually, but the situation is an outsource company did for us some changes in the native SAP ABAP programs related to some SAP native transactions, and those programs trigger at their end some background jobs, each job running with the name of user running the transaction.
Through SM37, I can't find a template background job, to be changed to have class 'A'
The following is an excerpt from the ABAP code, bearing the CALL FUNCTION 'JOB_OPEN' statement :
FUNCTION z_cs_technical_completion.
""Local Interface:
*" IMPORTING
*" VALUE(AUFNR) TYPE VBRP-AUFNR
DATA jobcount TYPE tbtcjob-jobcount.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = 'CS_TECH_COMPLETE'
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
jobcount = jobcount
CHANGING
RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
SUBMIT zcs_technical_completion
WITH p_aufnr EQ aufnr
AND RETURN
VIA JOB 'CS_TECH_COMPLETE'
NUMBER jobcount.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = 'CS_TECH_COMPLETE'
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9.
ENDFUNCTION.
Thank you in advance for your cooperation.
Best regards.
Reda KhalifaDear Darren,
Thank you very much for your cooperation and for your prompt reply.
Could you please explain to me how to find out the template background job that was first used, or in other words, how things were set up in the first place, i.e. when first the ABAP program was written and executed, there had to be at least one background job created through transaction SM36 ?
Thank you in advance for your cooperation.
Best regards.
Reda Khalifa -
Background job schedule and mail triggering
Hi Experts,
I schedule a background job to run a custom program for project closure.The job is running successfully. But,the mail I am getting from this job run is same all the time (means it's showing same project closure again and again though I am running job for different projects). Is it some bug in our custom program or any parameters required to be check in job schedule?
Kindly suggest.
Thanks & Regards
SaurabhYes. That is the point I am missing. Just one 'date' is checked and project is taken into account for the custom program and after its successful run the mail is sent to users.
And when the same program I am assigning in SM36,it is actually running the program accurately for project/s but sending the same mail which it send for very first project earlier.
Can you please guide me on the way to create these variants?
You will need to Save different variants for different projects and then assign the variants with your job.
Will it be required to create variant again and again and assign different projects individually? As, we are not sure that which project is gonna be created in future. So, need guideline how these variants can help me to sort out the e-mail issue.
Regards
Saurabh -
Triggering of alert by email or message after completion of background job
Hi,
Can any let me know if there is a scope for creating and alert by Email or by Message on completion of a Background job?
- if yes please let me know the procedure.
Satish.Read,
http://help.sap.com/saphelp_nw04s/helpdata/en/9a/4a813b680c250fe10000000a114084/frameset.htm
That should answer your question.
Regards
Juan -
Hi,
I have problems when creating a job that is supposed to be run once in background. I use the common steps as described below. My problem is that the report is executed twice.
- First it is executed synchronously when the job is created
- Then it is executed in the normal job step as I want it to do
I don't want it to be executed the first time because it creates data!!!
Code:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_jobid
IMPORTING
jobcount = w_jobnr
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit.
SUBMIT (p_prog)
WITH p_idocnr = p_idocno
USER p_user
VIA JOB w_jobid
NUMBER w_jobnr
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobnr
jobname = w_jobid
strtimmed = 'X'
IMPORTING
job_was_released = w_jobrel.
Does anyone have a clue of what I should do to prevent this?
// Regards HansHi again,
1. U are right.
2. It will happen if we use SUBMIT.
3. As per the help documentation,
it will run the program in separate session,
( as soon as submit statement comes)
4. and run the INITIALIZATION event.
The VIA JOB addition also loads the program accessed in a separate internal mode when the SUBMIT statement is executed and the system performs all the steps specified before START-OF-SELECTION. This means the events LOAD-OF-PROGRAM and INITIALIZATION are triggered and selection screen processing is performed. If the selection screen is not processed in the background when VIA SELECTION-SCREEN is specified, the user of the calling program can eidit it and schedule the program accessed in the background request using the function Place in Job. If the user cancels selection screen processing, the program is not scheduled in the background job. In both cases, execution of the program executed is completed after selection screen processing and the system returns to the calling program due to the AND RETURN statement.
regards,
amit m. -
How to cancel the background job processing in ABAP programming?
Hi,
I have a requirement where i need to cancel the job depending on some constraint. My code is something like this:
Select some data from the table.
if sy-subrc = 0.
Do nothing.
Else
Cancel the job
call function 'BP_JOB_ABORT'
exporting
jobcount = number
jobname = name
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6
The above code is cancelling the job but it is throwing an exception called CX_SY_DYN_CALL_PARAM_MISSING because i dint pass job count. How can we find the job count of next job that is going to run? Or How to handle the exception which it is throwing. Even if i try to handle that exception something like this:
TRY
call function 'BP_JOB_ABORT'
exporting
jobcount = number
jobname = name
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6
RAISE EXCEPTION TYPE CX_SY_DYN_CALL_PARAM_MISSING.
CATCH
CX_SY_DYN_CALL_PARAM_MISSING.
ENDTRY.
It avoids the exception but it doesnt cancel the job. I even tried with function modules like JOB_OPEN
JOB_SUBMIT,BP_JOB_SELECT,BP_JOB_ABORT and tried to build some logic using status overview table (TBTCO) and TBTCP (Jobstep overview table).
Can someone suggest me the right way to write this program ?
Thanks in advance.
RashmiHi,
Problem is solved.
Create an background job with 2 steps. The first step in the background job calls the program ZBACKJOB_STEP1. In the variant we have a wrong material number
If the material number is not found in Mara, the next step in the job should not get executed and the job should get cancelled..
In the above posts i had asked how do I get the job count of the job that is currently triggering the program at the runtimeu2026..If u see the below code uu2019ll get to know.. We have to use the standard structure TBTCM which captures the properties/characteristics of the job.
REPORT ZBACKJOB_STEP1.
TABLES: MARA,TBTCM.
PARAMETERS : MATNR TYPE MATNR.
START-OF-SELECTION.
SELECT SINGLE * FROM MARA WHERE MATNR = MATNR.
IF SY-SUBRC IS INITIAL.
WRITE / : 'This is the material selected on the selection-screen' , MARA-MATNR.
ELSE.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
EVENTID = TBTCM-EVENTID
EVENTPARM = TBTCM-EVENTPARM
EXTERNAL_PROGRAM_ACTIVE = TBTCM-XPGACTIVE
JOBCOUNT = TBTCM-JOBCOUNT
JOBNAME = TBTCM-JOBNAME
STEPCOUNT = TBTCM-STEPCOUNT
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2.
IF SY-SUBRC = 0.
CALL FUNCTION 'BP_JOB_ABORT'
EXPORTING
JOBCOUNT = TBTCM-JOBCOUNT
JOBNAME = TBTCM-JOBNAME
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDIF.
Regards,
Rashmi -
Background job in APO does not start because of invalid user name
Hello,
I have a macro in a planning book and the /sapapo/cons_check program which a triggered via a background job. Now, I have problems with the start of the job:
At the time the job was created inside SAP, an error occured. The job contains invalid values.
The user name within the job does not exist any more.
Now, I try to change the user name of the job (via step in sm37), but the error occured again.
I have the possibility to create the invalid user name once again in su01.
But I want to change the user name of the job - does somebody know how to do it?
Thanks for your help!
Kind regards
HeinzHello Heinz, this looks surprising.
It's quite easy to change the user name in the SM37 job step, and we haven't faced issues with this.
Could you check how many jobs are in either "scheduled" or in "released" status, and change steps for all of them? May be you changed the scheduled job, but the released job wasn't changed.
Use your job name and give a search date as 1-2 years in the past, and around 1 month in the future. With this time horizon, you should most likely be able to capture all the relevant jobs having the same name that you are using.
Now change the user name in step for all the jobs received above to be fully sure.
One more trial could be to copy the current scheduled job to another job, modify the user name in this newly created job and then delete the old one.
One of the above trials might possibly help you in some way, else its very tough to understand/explain your situation.
Thanks - Pawan -
How to Execute WebDynpro Applications as Background Job ?
Hi Gurus,
We have developed a lot of WDJ applications with component reusage; ie,
quite a lot of business logic are wrapped in WDJ Components which are
re-used by other WD UIs.
Now we'd like to automate some of the processes with background jobs
and faced with a few problems :
#1. How can we write a background WD application which can be
triggered by external mechanism and without presenting any UI?
#2. If we write the background program in a Java DC, how can we
invoke existing methods in WD components ?
Anyone got a clue ??
Ying-Jie ChenHello Amit,
> Well I can think of a workaround in this case.If you are aware
> of the suspend-resume functionality of the WD application then
> its possible to run the WD application virtually in background.
[ stuffs deleted ...]
It sounds like a possible alternative to our requirement, I'll
spend some time to investigate on the WD suspend-resume mechanism !
> Also let me know why are you preffering the WD if you dont
> require its UI
Our application requires the process to be performed with UI interaction;
with some instances it should be run as a background job. Either case involves
RFC calls to backend SAP R/3 and it's easy for RFC access with WD
Component. Though it's also possible to use CAF application service for
RFC access; due to some technical constrains, we did not use CAF
framework. Therefore it ends up where we are now ...
Thanks for your tip!
Ying-Jie Chen -
Background job not run properly
Hi,
When an infopackage is triggred through process chain in BI a background job will be exeuted at R/3 to fetch data from R/3.
But the bakground job did not execute properly hat is it did not fetch any data but ot finished.
But when the infopackage is executed manually the background job fetches the data from R/3.
Why the job is not fetching data when triggered through process chain.
Please help me to sole this issue.
Regards,
IndhuHi Induja,
In your case, you will have to debug the background job that is activated through BI. Check if proper data is coming from BI.
You can only debug a background job if it is created under your user id. Thus, to debug the job you first have to own it and then debug by selecting it and either typing 'JDBG' in the command field or through menus available on the top.
Job overview transaction code - SM37.
Hopefully the issue is in Development/Test/Quality system and not in Production.
Hope that helps!.
Regards,
Saba -
Background Job not Printing TOs immediately
Hello experts,
I am having an issue with printing Transfer Orders created by background job, the output requests are sent to the output controller with status '-' . It works when I manually create the TOs or if I run the RLAUTA10 program with my userID in SE38 .
I have set the background job user default print parameters in SU3 to print immediately.
Also in the Job step, I have set up the print parameters to 'print immediately'
I have assigned printer for sorce storage type & set the indicator to use the source sto type in OMLV, The printer seems to be determined correctly, I've checked the Spool request name & printer in the spool controller, only issue seems to be the print not being triggered immediately.
Not sure, if there is some other setting that I have to make to be able to print the TOs created by the background job immediately.
Any help would be appreciated.
Thanks
Kris Twhether the printer which you assigned is configured in SAP (network printer)? or LOCL?
printing may not happen if LOCL(background job)
Thanks -
Hi,
is there a function module that will check the background job status and will wait for it to finish before returning to the calling program?
I have developed a program that triggers a background job at runtime, but i also need to make sure the job is finished, successful or not, before the output of the program. i'm currently doing a query in a job table inside a do enddo loop, but i believe this is not efficient.
Any ideas?
thanks.
tykenI am not having the sample Code with me right now...
But i'll help you to build the logic...
after Write report.
Use the Function module I told u...
then...
write a select query on table tbtcp with job info you will get from FM.
What is your objective after getting the Background Job details..?
Maybe you are looking for
-
My iPhone 4S is only playing part of a song and then stops, sometimes plays whole song but for the most part it just stops randomly
-
I have an ipod touch 4. Can change it with the ipod touch 5?
I have an ipod touch 4. Can change it with the ipod touch 5? if yes then how much do i have to pay for it?
-
Resizing columns in a simple table
Hello, I have several simple tables in my structured FM files. They were copied from unstructured FM when we went DITA. I want to resize the columns so the tables look presentable. I tried to do Table > Resize Colums, but when I run the map throug
-
Reversal Posting was not happened
Hi Gurus, It's a high prioroty issue please give your inputs. I have done the posting to FI. But after some time done Reversal posting due to some reasons. After this the employee in the pc00_m99_cipc where we can see posting s are not done. The prob
-
Com. Channel of type XI: URL and logon
Hi I am stuck with a set of scenarios and business processes in XI. Just to give an overview: I have a business process in XI which I would like to be called from several other processes. But I would like to do this without replicating the informatio