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: 

How do JOB_OPEN, JOB_SUBMIT, & JOB_INSERT Work?

Former Member
0 Kudos

Hi,

Can anybody tell me how to use the function modules JOB_OPEN and JOB_SUBMIT in my report program?

Thanks,

Das.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use JOB_OPEN to indicate that you want to create a background job. Use JOB_INSERT to define the steps in your background job and JOB_CLOSE to indicate that you have completed your definition of it. The parameters of these functions mimic the input requirements from SE37. If you look at their definition in SE11 the vast majority of these parameters are self-explanatory.

In order to try them out, try these parameters:

JOBNAME LIKE TBTCJOB-JOBNAME default 'TEST'.

JOBGROUP LIKE TBTCJOB-JOBGROUP.

data:

JOBCOUNT LIKE TBTCJOB-JOBCOUNT.

  • Open the Job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = JOBNAME

IMPORTING

JOBCOUNT = JOBCOUNT

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

WRITE: /1 'JOB_OPEN FAILED reason code :', SY-SUBRC.

CHECK 1 = 2.

ENDIF.

  • Create the actual payment

SUBMIT ZZAPXXX AND RETURN "add step zzapXXX to job

USER SY-UNAME

Reward points if found helpfull...

Cheers,

Siva.

3 REPLIES 3

Former Member
0 Kudos

Hi,

Use JOB_OPEN to indicate that you want to create a background job. Use JOB_INSERT to define the steps in your background job and JOB_CLOSE to indicate that you have completed your definition of it. The parameters of these functions mimic the input requirements from SE37. If you look at their definition in SE11 the vast majority of these parameters are self-explanatory.

In order to try them out, try these parameters:

JOBNAME LIKE TBTCJOB-JOBNAME default 'TEST'.

JOBGROUP LIKE TBTCJOB-JOBGROUP.

data:

JOBCOUNT LIKE TBTCJOB-JOBCOUNT.

  • Open the Job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = JOBNAME

IMPORTING

JOBCOUNT = JOBCOUNT

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

WRITE: /1 'JOB_OPEN FAILED reason code :', SY-SUBRC.

CHECK 1 = 2.

ENDIF.

  • Create the actual payment

SUBMIT ZZAPXXX AND RETURN "add step zzapXXX to job

USER SY-UNAME

Reward points if found helpfull...

Cheers,

Siva.

Former Member
0 Kudos

Hi Manosh,

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.

Also,

Yes you can use job functions:

JOB_OPEN

JOB_SUBMIT

JOB_CLOSE

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

kindly reward if found helpful.

cheers,

Hema.

Former Member
0 Kudos

Hi Manosh,

Also,

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

FM: JOB_OPEN

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

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

Regards,

hema.