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: 

job scheduling

former_member841898
Participant
0 Kudos

hi abapers,

i have simple code:

report ytest.

write:/ 'hello sap'.

ca anyone pls give me the full code how to schedule this<b> program in background

for a specific time not immediately and to display it though spool.

all things is to be done programitically (t cde sm36 sm37 not to be used)</b>

regards

pankaj

6 REPLIES 6

kiran_k8
Active Contributor
0 Kudos

Pankaj,

Use the following Function modules to schedule a job programtically.

job_open

job_submit

job_close

K.Kiran.

Former Member
0 Kudos

refer this and set ur parameters accordingly...

JOB_OPEN->For opening a job in the background

JOB_SUBMIT->For submitting the job

JOB_CLOSE->For closing the job.

Take a look at the example code for these functions.

http://www.sap-basis-abap.com/sapac018.htm

*Submit report as job(i.e. in background)

data: jobname like tbtcjob-jobname value

' TRANSFER TRANSLATION'.

data: jobcount like tbtcjob-jobcount,

host like msxxlist-host.

data: begin of starttime.

include structure tbtcstrt.

data: end of starttime.

data: starttimeimmediate like btch0000-char1.

  • Job open

call function 'JOB_OPEN'

exporting

delanfrep = ' '

jobgroup = ' '

jobname = jobname

sdlstrtdt = sy-datum

sdlstrttm = sy-uzeit

importing

jobcount = jobcount

exceptions

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

if sy-subrc ne 0.

"error processing

endif.

  • Insert process into job

SUBMIT zreport and return

with p_param1 = 'value'

with p_param2 = 'value'

user sy-uname

via job jobname

number jobcount.

if sy-subrc > 0.

"error processing

endif.

  • Close job

starttime-sdlstrtdt = sy-datum + 1.

starttime-sdlstrttm = '220000'.

call function 'JOB_CLOSE'

exporting

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

laststrtdt = starttime-laststrtdt

laststrttm = starttime-laststrttm

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

sdlstrtdt = starttime-sdlstrtdt

sdlstrttm = starttime-sdlstrttm

strtimmed = starttimeimmediate

targetsystem = host

exceptions

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

others = 99.

if sy-subrc eq 0.

"error processing

endif.

Regards

vasu

0 Kudos

hi vasu sir,

why u have checked startimmedieate parameter check in fm job_close.

and sir what to do if program has sel screen like this:

REPORT YTIME .

tables: makt.

data: begin of itab occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of itab.

select-options: s_mat for makt-matnr.

select matnr maktx from makt into table itab where matnr in s_mat.

sort itab by matnr.

loop at itab.

write:/ itab-matnr, 45 itab-maktx.

endloop.

sir iwant this code to run every night at 1 am.

how to achive this . how will i attach variant pls help.

regards

pankaj

0 Kudos

Pankaj,

Give the program name in SE38 click on the program in menu bar,click execute,and click background,create a varinat and schedule the job.

K.Kiran.

0 Kudos

hi kiran sir,

i want to do all things programitically.

thaks

pankaj

0 Kudos

hi kiran,

if u have found the solution please reply back. even i am facing the same problem.

Thanks in advance.