06-16-2011 6:31 AM
Hi,
I want to run my program as background job. I want the user to select the server, in which background job should be run, in the selection screen of my program. When it is sheduled in background the job should run in the selected server.
How to do this?
Regards,
Sriram
06-16-2011 7:26 AM
SM36 ---select option JOb wizard . in that you can select target server
06-16-2011 7:47 AM
Thanks for the reply. Is there any way I can control the selection of targetapplication server through my program?
Thanks & Regards,
Sriram
06-16-2011 7:27 AM
Hi,
Background job should run on the server you want program to be executed, if yiur program is transported to production system and you want it to be exucuted in background then you need to schedule the job in the production system.
If you have program with selection screen then you need to create a varient for the program and for perticular selection criteria and while creating the background job; you need to assign this varient and you need to give start time of the job, so program will be executed in background at given time and date for the assigned varient.
YOU WILL FIND MANY THREADS TO DO THE SAME.
06-16-2011 8:22 AM
Hi,
please write the code like as below.
DATA : D_GROUP like TBTCJOB-JOBGROUP.
use the function moulde JOB_OPEN.
D_JOBNAME = SY-REPID.
D_GROUP- BTCSYSREAX = " pass the target server name Here
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = D_JOBNAME
JOBGROUP = D_GROUP
IMPORTING
JOBCOUNT = D_JOBNO
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
submit <Program name>
USER SY-UNAME VIA JOB D_JOBNAME NUMBER D_JOBNO
USING SELECTION-SET ' var1 ' " Give varient name
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = D_JOBNO
JOBNAME = D_JOBNAME
STRTIMMED = 'X'
IMPORTING
JOB_WAS_RELEASED = D_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.
Hope this will helps you
Regards
Kiran
06-16-2011 9:26 AM
Use parameter TARGETSERVER of the JOB_CLOSE function module. Study the online documentation for further details.
Thomas