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: 

How to select server in which background job should run

Former Member
0 Kudos

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

5 REPLIES 5

Rushikesh_Yeole
Contributor
0 Kudos

SM36 ---select option JOb wizard . in that you can select target server

0 Kudos

Thanks for the reply. Is there any way I can control the selection of targetapplication server through my program?

Thanks & Regards,

Sriram

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

ThomasZloch
Active Contributor

Use parameter TARGETSERVER of the JOB_CLOSE function module. Study the online documentation for further details.

Thomas