How to trigger a background job from BADI method.
hi friends,
i need to trigger a background job from the badi method CHANGE_AT_SAVE for the BADI BOM_UPDATE.
for this i think i need to create an event which i should give with parameters during job creation.
can you pls help me solve this issue.
thank u all.
Hi Saravanan,
Here is an example of what you have to do.
Regards,
Eric
Reward any helpful sugestion.
*& Form generar_job
FORM generar_job .
Generar Variante
PERFORM generar_variante.
w_fecha = sy-datum + 3.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = w_fecha
IMPORTING
day = w_weekday.
Si la fecha cae en sabado o domingo se debe continuar el lunes.
CASE w_weekday.
when '1'.
ADD 2 TO w_fecha.
WHEN '6'.
ADD 2 TO w_fecha.
WHEN '7'.
ADD 1 TO w_fecha.
ENDCASE.
w_jobname = 'ZQM_CIERRE_LOTE_INSPECCION'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = 'QUEUE'
jobname = w_jobname
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc EQ 0.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = sy-uname
jobcount = w_jobcount
jobname = w_jobname
report = 'ZQM_CIERRE_LOTE_INSPECCION'
variant = w_var
IMPORTING
step_number = w_stepnum
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10.
IF sy-subrc EQ 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
sdlstrtdt = w_fecha
sdlstrttm = w_hora
IMPORTING
job_was_released = w_rel
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc EQ 0.
IF w_rel EQ 'X'.
WRITE:/ w_jobname, 'FUE LIBERADO. VER SM37.'.
Guardamos los destinatarios
PERFORM destinatarios_job.
Guardamos la información a utilizar al ejecutar el job
PERFORM guardar_datos_job.
ELSE.
WRITE:/ w_jobname, 'NO FUE LIBERADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE CERRADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE ENVIADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE CREADO'.
ENDIF.
ENDFORM. " generar_job
Similar Messages
-
Creation of background job from SE38
hello all...
In the selection screen of my report program, there are two radiobuttons - read mode or update mode.
In read mode, the program reads an excel file and gives the output in teh form of errors, if at all, after some chekcs on this excel file.
In update mode, the program should check the excel file, get an internal table with errors from the excel file as well as run BDC for the correct records in excel file. So the output here has two blocks, first one - errors in excel file, second one - errors in BDC update.
But this update mode should run in background.
HOW TO CALL THE BACKGROUND JOB FROM THIS REPORT PROGRAMME when the update mode is selected??
Advance Thanks
omkarHi Vishal,
1. How are u running the BDC ?
2. If u are using call transaction syntax,
then there is an extension to it.
MODE mode
(See help F1 on call transaction)
The processing mode can take the following values:
'A' Display screen
'E' Display only if an error occurs
'N' Do not display
'P' Do not display; debugging possible
3. We can use N
4. N means, it won't display any screens
of that BDC transaction.
5. It does not exactly mean the BACKGROUND JOB
generated thru sm36.
Regards,
Amit M.
Message was edited by: Amit Mittal -
Kicking off Background Job from Another SAP system
Hi,
Does anybody know how to kick off a background job from a separate SAP system??
i.e I have a job on our CRM system that is dependant on a Job finishing from our ECC6 system first.
Does anyone know how to do this? I know I might be able to use events, is there anything else I should be making use of??
Many ThanksHi Daniel,
Guess there is one more solution. In system A write a report (let us name it X) that would trigger a job in system B through an RFC call.
Now in System A create a job with 2 steps. First step would be normal one, the second one for report X. Only when step 1 is over would step 2 start. So indirectly end of the existing Job A would trigger the required Job B.
Regards.
Ruchit. -
How to schedule a background Job based on events
Hi,
We are on 4.6 C.
We have a background job that has two ABAP programs.
We need to start the 2nd ABAP program only after the first one has run successfully.
If the second ABAP program does not run, the the job should have a status "FINISHED".
Help appreciated.
Thanks
MalaHi,
How to schedule a background Job based on events,please refer to the follow SAP help:
You can use events that have already been defined, or you can create new events for scheduling background jobs.
If you wish to use new events, do the following to implement the event scheduling:
Define and transport the event as a user event with transaction SM62.
You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
Do this to transport an event:
Create a transport request.
Start the editor in the transport request and enter the following:
R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event IDs that you have created.
Save and release the transport request. Ensure that it is imported into your production system(s).
To trigger an event, add:
the function module BP_EVENT_RAISE to your ABAP program, or
the program SAPEVT to your external script, batch file, or program.
When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
Schedule the jobs that are to run when your events are triggered.
You can schedule jobs for one-time start or to be started whenever an event is triggered.
Regards,
collysun -
How to Schedule SAP background job at OS Level
Hi All,
Can Anyone tell me how to Schedule SAP background job at OS Level (unix).
Regards,
AnilHi Anil,
I donu2019t know your requirements, anyway itu2019s possible to setup your SAP job in order to start after an event, and after that you can get the event triggered from the Operating System in the following way:
- log into you Operating System with the SIDadm user id (at the Operating System level) and go to directory /usr/sap/SID/SYS/exe/run
- Run the SAPEVT executable as follows:
sapevt YOUR_EVENT -t pf=/usr/sap/SID/SYS/profile/DEV_DVEBMGS00_server001 nr=01
This will raise the event, and cause the job scheduled within SAP to execute.
You can periodically execute this job with crontab.
Thanks,
Federico Biavati -
How to schedule the background job daily twice?
Hi,
How to schedule the background job daily twice? any conditions?
Regards,
Srihithasee the step by step procedure.
Scheduling Background Jobs:
1. Background jobs are scheduled by Basis administrators using transaction SM36.
2. To run a report in a background, a job needs to be created with a step using the report name
and a variant for selection parameters. It is recommended to create a separate variant for each
scheduled job to produce results for specific dates (e.g. previous month) or organizational units (e.g.
company codes).
3. While defining the step, the spool parameters needs to be specified
(Step-> Print Specifications->Properties) to secure the output of the report and help authorized users
to find the spool request. The following parameters needs to be maintained:
a. Time of printing: set to Send to SAP spooler Only for now
b. Name abbreviated name to identify the job output
c. Title free form description for the report output
d. Authorization a value defined by Security in user profiles to allow those users to access
this spool request (authorization object S_SPO_ACT, value SPOAUTH). Only users with matching
authorization value in their profiles will be able to see the output.
e. Department set to appropriate department/functional area name. This field can be used in
a search later.
f. Retention period set to Do not delete if the report output needs to be retained for more
than 8 days. Once the archiving/document repository solution is in place the spool requests could
be automatically moved to the archive/repository. Storage Mode parameter on the same screen
could be used to immediately send the output to archive instead of creating a spool request.
Configuring user access:
1. To access a report output created by a background job, a user must have at
least access to SP01 (Spool requests) transaction without restriction on the user
name (however by itself it will not let the user to see all spool requests). To have
that access the user must have S_ADMI_FCD authorization object in the profile with
SPOR (or SP01) value of S_ADMI_FCD parameter (maintained by Security).
2. To access a particular jobs output in the spool, the user must have
S_SPO_ACT object in the profile with SPOAUTH parameter matching the value used
in the Print Specifications of the job (see p. 3.d above).
3. Levels of access to the spool (display, print once, reprint, download, etc) are
controlled by SPOACTION parameter of S_SPO_ACT. The user must have at least
BASE access (display).
On-line reports:
1. Exactly the same configuration can be maintained for any output produced
from R/3. If a user clicks Parameters button on a SAP Printer selection dialog, it
allows to specify all the parameters as described in p. 3 of
Scheduling background jobs section. Thus any output created by an online report
can be saved and accessed by any user authorized to access that spool request
(access restriction provided by the Authorization field of the spool request
attributes, see p. 3.d of Scheduling background jobs section).
Access to reports output:
1. A user that had proper access (see Configuring user access above) can
retrieve a job/report output through transaction SP01.
2. The selection screen can be configured by clicking Further selection
criteria button (e.g. to bring Spool request name (suffix 2) field or hide other
fields).
3. The following fields can be used to search for a specific output (Note that
Created By must be blank when searching for scheduled jobs outputs)
a. Spool request name (suffix 2) corresponds to a spool name in p. 3.b in
Scheduling background jobs section above).
b. Date created to find an output of a job that ran within a certain date range.
c. Title corresponds to spool Title in p. 3.c in Scheduling background jobs
section above).
d. Department - corresponds to spool Department in p. 3.e in Scheduling
background jobs section above).
4. Upon entering selection criteria, the user clicks the Execute button to
retrieve the list of matching spool requests.
5. From the spool list the user can use several function such as view the
content of a spool request, print the spool request, view attributed of the spool
request, etc. (some functions may need special authorization, see p.3 in
Configuring user access)
a. Click the Print button to print the spool request with the default attributes
(usually defined with the job definition). It will print it on a printer that was
specified when a job was created.
b. Click the Print with changed attributed button to print the spool request
with the different attributes (e.g. changing the printer name).
c. Click the Display contents button to preview the spool request contents. A
Print and Download functions are available from the preview mode. -
How to create a background job without a variant ?
How to create a background job without a variant ?
Hi,
Go to se38.. specify the program name and execute Or use Tcode
On the selection screen specify the variant...
Then from the menu options choose program->excute in background...
In this way we can crate a backgroup job with out crateing any varinat for the report...
Satya. -
Trigger a background job after executing tcode MMPV
Hi All,
I would like to trigger a background job after executing tcode MMPV. In MMPV, after closing a particular period and entering
new period, the transaction will be saved. After saving, the background job should be triggered. How to do it?
Regards,
VinodDepending what system you are on your best bet would be to create an enhancement point inside a form, that is called after the save has been performed, and raise an event within that form.
Events can be used to trigger background jobs are maintained in transaction SM62.
Cheers. -
How to cancel scheduled background job?
Hi,
I have used FM 'HR_START_BATCHJOB_IN_OTHER_SYS' to schedule background job.
Some mistake has happend and this FM calling has gone to infinite loop. So, now the system is keep on generating background job. I tried looking into SM36 to stop this background job but i failed.
Can anybody help me how to stop scheduled background job please.
Regards,
Mukund.Hi,
Check which background process your job is running from the Job details and inform your Basis consultant to Kill the process. If you have sm50 acess or sm66 access you can do the same.
Regards,
Vijay v -
How to schedule a background job in realtime
Hi,
Can you tell me how to schedule a background job in realtime.
give some example scenerios in scheduling the background jobs in realtime.
Thanks.
sam.And also.....
There are two ways for you to handle,
one manually setting up the job through SM36 which is better and convinient,
secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.
Find below steps in doing both:
Procedure 1:
1. Goto Trans -> SM36
2. Define a job with the program and variant if any
3. Click on start condition in application tool bar
4. In the pop-up window, click on Date/Time
5. Below you can see a check box "Periodic Job"
6. Next click on Period Values
7. Select "Other Period"
8. Now give '15' for Minutes
9. Save the job
Procedure 2 via Program:
Below is a sample code for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
L_RELEASE(1) TYPE c.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = 'ZTEMP2'
IMPORTING
JOBCOUNT = P_JOBCNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
WITH DESTINATION = 'HPMISPRT'
WITH IMMEDIATELY = SPACE
WITH KEEP_IN_SPOOL = 'X' AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = P_JOBCNT
JOBNAME = 'ZTEMP2'
STRTIMMED = 'X'
PRDMINS = 15
IMPORTING
JOB_WAS_RELEASED = L_RELEASE
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.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope the above helps you.
***********reward points,if found useful -
How to schedule the background job using current selection screen field val
Hello Friends,
How to schedule the background job using current selection screen field values.
after completion of the job the spool should be sent as a mail to SAP Inbox.
Is there any way to create the variant dynamically by reading the current selection screen values.
Thanks,
RaviHi,
To get the variant details you can use teh following FM.
'RS_VARIANT_CONTENTS'.
Regards,
Ankur Parab -
How to stop the background job "Sap_collector_for_job_statistic"
Dear All,
Kindly let me know how to stop the Background job "Sap_collector_for_job_statistic" which is running everyday.
We want to stop this background job.
Kindly suggest.
Regards,
MullairajaSelect the Job using SM37 transaction. In the Menu Choose
Job ---> Cancel Active Job.
Before you do this it may be good idea to check the pid using SM50.
It will be using a Background work process. Check the pid and the status.
Select the same and in the Menu Choose Process --> Cancel with Core.
Refresh and check in SM37 for the Active and Cancelled Jobs. -
How to debug the background job in ABAP
Hi Guys,
Can anyone let me know how to debug the background job in ABAP.
Thanks in advance
peterHi,
Goto SM37 and see the log if any is there and based on that you can check the code.
you can't debug background job.
Create a Variant for the Program and
Schedule JOB in background:
Go to SM36 create a Job
enter Program and Variant for that program in STEP..
click on Start Condition
Click on DATE and TIME enter date scheduled Start and END times
click on Period Values
Click on HOURLY/WEEKLY etc
CLick on RESTRICTIONS also to use further criteria.
so your job will be scheduled and run as per your requirement.
and in SM37 Transaction check the status of that JOB
Check this link for scheduling jobs..
http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a7f87505211d189550000e829fbbd/content.htm
Check this
http://jplamontre.free.fr/SAP/Debug%20background%20process.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap+debugger&
Regards,
Padmam. -
Hi all,
Can any one tell me how to Debugg a BackGround job in 4.7 version.
I used something like JDBG in SM37 but its not working.
Is there any process for this....Hi,
You can do using SM50 transaction.
Please check this link
http://www.allinterview.com/showanswers/56422.html
Best regards,
raam -
What to add to an program code in order to trigger an background job
Hi there
I wander what to add to an program code in order to trigger an event which consequently can trigger an background job
thx in advanceCheck this code:
DATA : v_jobhead LIKE tbtcjob.
DATA : v_jobcount LIKE tbtcjob-jobcount.
DATA : v_eventparm LIKE tbtcjob-eventparm.
DATA : v_flg_released TYPE c.
DATA: e_error.
DATA: running LIKE tbtcv-run.
TYPES: esp1_boolean LIKE boole-boole.
CONSTANTS: esp1_false TYPE esp1_boolean VALUE ' ',
esp1_true TYPE esp1_boolean VALUE 'X'.
CONSTANTS: true TYPE boolean VALUE esp1_true,
false TYPE boolean VALUE esp1_false.
PARAMETERS: v_jobnam LIKE tbtcjob-jobname,
v_report LIKE sy-repid,
v_varian LIKE raldb-variant,
v_uname LIKE sy-uname.
START-OF-SELECTION.
* add the new job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
* delanfrep = 'X'
jobname = v_jobnam
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_SUBMIT' " or you can use SUBMIT statement as well.
EXPORTING
authcknam = v_uname
jobcount = v_jobcount
jobname = v_jobnam
report = v_report
variant = v_varian
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10.
IF sy-subrc <> 0.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
* EVENT_ID = IC_WWI_WORKPROCESS_EVENT
* EVENT_PARAM = V_EVENTPARM
* EVENT_PERIODIC = 'X'
jobcount = v_jobcount
jobname = v_jobnam
strtimmed = 'X'
IMPORTING
job_was_released = v_flg_released
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
e_error = true.
ELSE.
DO.
CALL FUNCTION 'SHOW_JOBSTATE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobnam
* IMPORTING
* ABORTED =
* FINISHED =
* PRELIMINARY =
* READY =
* running =
* SCHEDULED =
EXCEPTIONS
jobcount_missing = 1
jobname_missing = 2
job_notex = 3
OTHERS = 4.
IF sy-subrc <> 0.
e_error = true.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF running = space.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDIF.
Maybe you are looking for
-
Restriction on number of line items in an automatically generated document
Hi all, As per my info, an accounting document must have a minimum of 2 line items to complete the document. At the same time an accounting document can have a maximum of 999 line items. My observation:- When I am posting depreciation using t-code AF
-
Very Slow Mac Mini / Decreasing Memory?
Hi, Unfortunatly I'm having a problem with my Mac Mini. For an unknown reason my Mac Mini (Mac OS X 10.6, Snow Leopard) has been running extemely slow the last few days. I have reset the Mac a countless number of times now and done everything I can t
-
Printer not working with iphoto 11
I am new to Macs so take pity on me. I have googled and chased this problem for 2 days but to no avail. I have reset the printers but no joy. Above shot is when I choose one picture to print. Program seems to think that I want to print 1 of 5001. I
-
Incorporate pdf into a web app
I have an asp web app everything works great details page - gets good here: they want to clik on a button in the app to create a .pdf from the web site/apps detail page? is this possible,, is there a tool/app or command to do this with? i would like
-
Invalid Escape Character Issue
I seem to be getting this error when I try to post this simple snippet online <%-- This page lists topics for a selected forum. --%> <%@ page errorPage="/misc/error.jsp" import="java.net.*"