*&---------------------------------------------------------------------*
* & Report z_barry_set_job *
*&*
*&---------------------------------------------------------------------*
* & Set the background job. For more functions, see function group: btch *
*&---------------------------------------------------------------------*
Report z_barry_set_job.
Data: jobcount like tbtcjob-jobcount.
Data: abort type C,
Finish type C,
Prelim type C,
Ready type C,
Run type C,
Sched type C.
parameters: p_name like tbtcjob-jobname obligatory default 'z _ barry_test_job ',
p_date like sy-datum obligatory,
p_time like sy-uzeit obligatory.
select-options s_rept for Sy-repid no intervals obligatory.
Start-of-selection.
Call function 'job _ open' "to define a job
Exporting
Jobname = p_name
Importing
Jobcount = jobcount "job ID
Exceptions
Cant_create_job = 1
Invalid_job_data = 2
Jobname_missing = 3
Others = 4.
If sy-subrc <> 0.
Message ID sy-msgid type sy-msgty number sy-msgno
With sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.
Loop at s_rept.
Call function 'job _ submit '"scheduled this job
Exporting
Authcknam = sy-uname
Jobcount = jobcount
Jobname = p_name
Report = s_rept-low
* Variant = 'test'
Exceptions
Bad_priparams = 1
Bad_xpgflags = 2
Invalid_jobdata = 3
Jobname_missing = 4
Job_notex = 5
Job_submit_failed = 6
Lock_failed = 7
Program_missing = 8
Prog_abap_and_extpg_set = 9
Others = 10.
If sy-subrc <> 0.
Message ID sy-msgid type sy-msgty number sy-msgno
With sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.
Endloop.
Call function 'job _ close' "release this job
Exporting
Jobcount = jobcount
Jobname = p_name
Sdlstrtdt = p_date
Sdlstrttm = p_time
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 ID sy-msgid type sy-msgty number sy-msgno
With sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.
Call function 'show _ jobstate'
Exporting
Jobcount = jobcount
Jobname = p_name
Importing
Aborted = abort
Finished = finish
Preliminary = prelim
Ready = ready
Running = run
Scheduled = sched
Exceptions
Jobcount_missing = 1
Jobname_missing = 2
Job_notex = 3
Others = 4.
If sy-subrc <> 0.
Message ID sy-msgid type sy-msgty number sy-msgno
With sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.
write:/'canceled: ', abort,
/'finished:', finish,
/'scheduled temporarily: ', prelim,
/'Ready for execution: ', ready,
/'Active:', run,
/'scheduling released: ', sched.