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

background job

Former Member
0 Likes
885

Hi experts,

I have developed program with selection screen

parameter: plant

start_date

end_date

Here start date current date 24.10.2010

end_date background start 25.10.2010

once uploaded next upload should start 26.06.2010 like very next day .

how can i achieve this through background scheduling .

regards,

K.Satyanarayana

Moderator message: please use more descriptive subject lines from now on.

Edited by: Thomas Zloch on Sep 27, 2010 2:51 PM

Hi experts,

I have developed program with selection screen

parameter: plant

start_date

end_date

Here start date current date 24.10.2010

end_date background start 25.10.2010

once uploaded next upload should start 26.06.2010 like very next day .

how can i achieve this through background scheduling .

regards,

K.Satyanarayana

Moderator message: please use more descriptive subject lines from now on.

Edited by: Thomas Zloch on Sep 27, 2010 2:51 PM

6 REPLIES 6
Read only

Former Member
0 Likes
849

Hi Satya,

First estimate how long your program will execute.

Ex : exection time : 12 hours

Then you could schedule your program for every 12 + 24 hours = 36 hours

Read only

Former Member
0 Likes
849

Hi,

Save a variant with selection variables for your date fields - you can use +/- number of days. Then reference this variant in your batch job.

Regards, Andy

Read only

_IvanFemia_
Active Contributor
0 Likes
849

Hi,

create a dynamic variant and schedule your report as background job using that variant.

Regards,

Ivan

Read only

Former Member
0 Likes
849

hi

you need to handle this with some coding..in ur program

you can schedule the job on daily basis but if user tries to run the job in foreground then the user msut be stopped from doing that ..

check the below code to do that ..

perform run_in_background..


form run_in_background.
  data:seltab  type rsparams occurs 0 with header line,
       jobnumber type tbtcjob-jobcount,
       jobname   type tbtcjob-jobname value sy-repid,
       print_parameters type pri_params.
  check sy-batch is initial.
  call function 'RS_REFRESH_FROM_SELECTOPTIONS'
    exporting
      curr_report     = sy-repid
    tables
      selection_table = seltab
    exceptions
      not_found       = 1
      no_report       = 2
      others          = 3.
  "it shouldn't be possible to have an exception here!
  call function 'JOB_OPEN'
    exporting
      jobname          = jobname
    importing
      jobcount         = jobnumber
    exceptions
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      others           = 4.
  if sy-subrc <> 0.
    message 'Can''t create a new job' type 'E'.
  else.
    submit (sy-repid) with selection-table seltab
           via job jobname number jobnumber and return.
    if sy-subrc <> 0.
      message 'Error adding a step for background execution' type 'E'.
    else.
      call function 'JOB_CLOSE'
        exporting
          jobcount             = jobnumber
          jobname              = jobname
          strtimmed            = 'X'
        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.
        message 'Can''t close the new job' type 'E'.
      else.
        message 'Background processing successfully scheduled' type 'S'.
      endif.
    endif.
  endif.
  leave program.
endform.         

br,

vijay

Read only

Former Member
0 Likes
849

Hi,

If I have understand the requirement properly then, in the initialization u can populate the start date and end date depending on the system date.

Regards,

Amitava

Read only

former_member300258
Participant
0 Likes
849

Hi Satya,

go to Tcode SM36 - Define Background Job, click on the "start condition" button on the application toolbar and there you will options to define the background job as your wish.