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: 

Schedule jobs witj job open, submit and close

Former Member
0 Kudos

Hi gurus,

I need to know if there is any way to schedule various jobs using the FM job_open job_submit and job_close. Like schedule the first job for a date and a hour and schedule others jobs to run after the first job sequential.

Its this possible?

Thk in advance

3 REPLIES 3

TuncayKaraca
Active Contributor
0 Kudos

@Johnny,

Yes you can use job functions:

<a href="http://help.sap.com/saphelp_46c/helpdata/en/fa/096d40543b11d1898e0000e8322d00/frameset.htm">JOB_OPEN</a>

<a href="http://help.sap.com/saphelp_46c/helpdata/en/fa/096d4d543b11d1898e0000e8322d00/frameset.htm">JOB_SUBMIT</a>

<a href="http://help.sap.com/saphelp_46c/helpdata/en/fa/096da8543b11d1898e0000e8322d00/frameset.htm">JOB_CLOSE</a>

  • You can add multiple steps into one job by using JOB_SUBMIT.

Former Member
0 Kudos

Hi

see the sample code for the Job scheduling using the fun modules

IF p_bjob = 'X'.

CONCATENATE sy-cprog sy-datum sy-uzeit

INTO jobname SEPARATED BY '_'.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

IMPORTING

out_archive_parameters = arc_params

out_parameters = print_params

valid = valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF valid = chk.

SUBMIT yREP WITH s_kunnr IN s_cust

AND RETURN

USER sy-uname

VIA JOB jobname

NUMBER jobcount

TO SAP-SPOOL

SPOOL PARAMETERS print_params

ARCHIVE PARAMETERS arc_params

WITHOUT SPOOL DYNPRO.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcount

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

invalid_target = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

MESSAGE i029 WITH jobname.

ENDIF.

ELSE.

MESSAGE s000 WITH text-003.

STOP.

ENDIF.

ENDIF.

Regards

anji

naimesh_patel
Active Contributor
0 Kudos

To schedule a job on perticluar time you can use these parameters:

FM: <b>JOB_OPEN</b>

TBTCJOB-SDLSTRTDT = '20071122'. " << your schdule start date

TBTCJOB-SDLSTRTTM = '122233'. " << your schdule start time

Regards,

Naimesh Patel