Application Development and Automation 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: 
Read only

Scheduling program in background

Former Member
0 Likes
635

Hi All

I have scheduled a program with selection screen in background.

I have scheduled it to run every minute . when I go to sm37 and check it shows the job my job name and against it it say 'Released' .

Why doesn't my program start in background.

Kindly help me resolve this issue.

5 REPLIES 5
Read only

Former Member
0 Likes
607

HI Sudheendra,

Have you specified variants for job to run in background? Don't forget to specify the values to be passed for selection screen parameters in variants.

Regards,

Amit

Read only

Former Member
0 Likes
607

Hi

This is how to do it through code

data: lv_job_name like tbtco-jobname,

lv_job_nr like tbtco-jobcount,

lv_job_released type c,

lv_job_start_sofort type c,

lv_print_parameters type pri_params.

lv_job_name = 'Z_test'. " your background program name

call function 'JOB_OPEN'

exporting

jobname = lv_job_name

importing

jobcount = lv_job_nr

exceptions

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

others = 4.

if syst-subrc = 0.

*submit job with all the selection screen params...

submit (lv_job_name)

with applfile = applfile

with p_lines = p_lines

with rfc_dest = rfcdest

with p_selmtd = lv_selmtd

with px_shsim = px_shsim

with px_sherr = px_sherr

user syst-uname

via job lv_job_name number lv_job_nr and return.

if sy-subrc = 0.

call function 'JOB_CLOSE'

exporting

jobcount = lv_job_nr

jobname = lv_job_name

strtimmed = 'X'

importing

job_was_released = lv_job_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 syst-subrc <> 0.

message i162(00) with

'An error occured while closing the background job.'.

stop.

endif.

endif.

endif.

skip 1.

write: / 'Background process', lv_job_name ,

'called successfully' no-gap.

write: / 'You can check the job in transaction SM37'.

Use Sm36 and SM37 Transaction

http://help.sap.com/saphelp_nw04s/helpdata/en/73/69ef5755bb11d189680000e829fbbd/frameset.htm

<b>Reward if usefull</b>

Read only

Former Member
0 Likes
607

Dear,

you know if your selection criteria(values entered on selection screen0

doesn't produce any output, how you are going to see on the same ??

check your input values better to use variants for the same.

reward if useful.

Amit Singla

Read only

Former Member
0 Likes
607

HI

Actually you can do this with a variant and you would not need to make any additional code:

Try these steps:

1) create a variant

2) on the screen called 'ABAP Save as Variant' for your date range select field attribute 'L' (selection variable) and then click the tab for 'selection variables'

3) on the screen called 'Choose Variant Variables ...' change the yellow button under 'D' (dynamic date calculation) to green and then click the drop down list.

4) go to the bottom of the list and select Beginning of mth-xx months, end of mth+yy months

5) then for values xxx give it a 3 (for 3 months back) and for yyy give it a -1 (take my word for the 3 and -1)

6) save the variant

7) save again

Read only

Former Member
0 Likes
607

Hi,

Have you given any start condition for the job.

Released status will be shown immediately before the job starts.

If it is not started, the reason could be there is no BTC work process that is free .

Check with your BASIS consultant if everything related to job is fine.