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

Function Module to create batch job

Former Member
10,468

Hi Experts,

Is there any standard function module available to create a batch job?

Thanks.

Best Regards,

Wei Shan

1 ACCEPTED SOLUTION
Read only

Former Member
3,590

Hi,

use this function module.


 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 <> 0.
    MESSAGE e888(sabapdocu) WITH 'JOB_OPEN FAILED'.
    EXIT.
  ENDIF.

  CALL FUNCTION 'JOB_SUBMIT'
    EXPORTING
      authcknam               = sy-uname
      jobcount                = jobcount
      jobname                 = jobname
      report                  = program
      variant                 = ''
    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 e888(sabapdocu) WITH 'JOB_SUBMIT FAILED'.
    EXIT.
  ENDIF.

  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 e888(sabapdocu) WITH 'JOB_CLOSE FAILED'.
    EXIT.
  ENDIF.

regards,

Santosh Thorat

9 REPLIES 9
Read only

Former Member
0 Likes
3,590

HI.

Iam not sure about this function module. but it may be helpfull to you.

SUBST_START_BATCHJOB

SUBST_SCHEDULE_BATCHJOB

SALP_UI_REPORT_BATCH_JOB

Regards.

Jay

Read only

Former Member
3,591

Hi,

use this function module.


 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 <> 0.
    MESSAGE e888(sabapdocu) WITH 'JOB_OPEN FAILED'.
    EXIT.
  ENDIF.

  CALL FUNCTION 'JOB_SUBMIT'
    EXPORTING
      authcknam               = sy-uname
      jobcount                = jobcount
      jobname                 = jobname
      report                  = program
      variant                 = ''
    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 e888(sabapdocu) WITH 'JOB_SUBMIT FAILED'.
    EXIT.
  ENDIF.

  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 e888(sabapdocu) WITH 'JOB_CLOSE FAILED'.
    EXIT.
  ENDIF.

regards,

Santosh Thorat

Read only

3,590

Hi,

I had used job_open, job_submit and job_close to create batch job and it's working.

Just another question, will i be able to define what data needs to be input into the defined program for job submit instead of using variant?

or, is there any way i can create a variant for the program (in terms of programming)?

thanks.

best regards,

weishan

Read only

Former Member
0 Likes
3,590

hi

FM : BAPI_BATCH_CREATE

thanks

Sachin

Read only

Former Member
0 Likes
3,590

Hi,

Try to use the following fm.

Job_open

submit

job_close

thanks.

Read only

Former Member
0 Likes
3,590

There are several FMs available for Jobs..creation scheduling..

Try looking in FunctionGroup BTCH and BTC2 you will find what you need.

Read only

Former Member
0 Likes
3,590

Hi,

Try with these FMs 'JOB_OPEN'

'JOB_SUBMIT'

'JOB_CLOSE'

You can try with this FM 'BAPI_BATCH_CREATE'.

Regards,

Jyothi CH.

Read only

Former Member
0 Likes
3,590

Hi

try using these---

(1) Job_open

(2) Job_submit

(3) Job_close

4) BP_JOB_RELEASE

or see this link

regards

Prashant

Read only

Former Member
0 Likes
3,590

Hi,

Use the following steps to craete a batch job :

Create a job using function module JOB-OPEN and collect the job specifications, add a job step to the job with the function module JOB-SUBMIT and then close the job and pass it to Background processing system for execution with the function module JOB-CLOSE.

Tcodes are :-

SM36(Job creation)

SM37(Job selection and execution).