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

Creating job

Former Member
0 Likes
1,234

Hi Experts,

I am about to create a batch job. I used FM JOB_OPEN, JOB_SUBMIT and JOB_CLOSE. However, whenever I run the program it creates job for every 1 second. It will not stop creating jobs unless you completely exited in the program. The code is not inside the loop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,162

Hi Mariposa,

I think you can use the function module SUBST_START_REPORT_IN_BATCH as an alternative.

Below is an example code.

DATA: i_param1 TYPE TABLE OF rsparams,

wa_param1 LIKE LINE OF i_param1.

wa_param1-selname = 'PA_FILE'.

wa_param1-kind = 'P'.

wa_param1-low = pa_file.

APPEND wa_param1 TO i_param1.

CALL FUNCTION 'SUBST_START_REPORT_IN_BATCH'

EXPORTING

iv_repname = sy-repid

TABLES

tt_reportparam = i_param1

EXCEPTIONS

variant_exist_check_failed = 1

variant_update_failed = 2

variant_update_not_authorized = 3

variant_update_no_report = 4

variant_update_no_variant = 5

variant_update_variant_locked = 6

variant_insert_failed = 7

variant_insert_not_authorized = 8

variant_insert_no_report = 9

variant_insert_variant_exists = 10

variant_insert_variant_locked = 11

variant_write_failed = 12

no_batch_service = 13

no_server_list = 14

batch_scheduling_failed = 15

OTHERS = 16.

ENDFORM. "RUN_JOB

Hope this helps!

Hi Experts,

I am about to create a batch job. I used FM JOB_OPEN, JOB_SUBMIT and JOB_CLOSE. However, whenever I run the program it creates job for every 1 second. It will not stop creating jobs unless you completely exited in the program. The code is not inside the loop.

7 REPLIES 7
Read only

Former Member
0 Likes
1,162

Hello,

Check this Documentation:

Here many examples are available to create a job

http://help.sap.com/saphelp_nw04/helpdata/en/fa/096d40543b11d1898e0000e8322d00/frameset.htm

Regards,

Vasanth

Read only

Former Member
0 Likes
1,162

Hi Experts,

It seems that the reason for infinite creation of jobs is that the program which I run is the same program that I submit. Was there any way to just let the program submit it once so as to create only 1 job?

Thanks a lot!

Read only

0 Likes
1,162

try this..

data: w_fl.

import w_fl from memory id 'ZMEM'.

if w_fl eq space.

SUBMIT <>.

w_fl = 'X'.

export w_fl to memory id 'ZMEM'.

endif.

~Suresh

Read only

0 Likes
1,162

Hi,

Is it possible for you to write another program which can submit the original program[ job_open,job_submit and job_claose in another program]?

Read only

Former Member
0 Likes
1,162

mariposa,

Suppose you have 100000 records which is going for dump in background also.

Taht time decided to create a job for every 20000 records.

select * from database table

into itab

packaze size 20000

where x = s_x.

your functionality here if required and moved to final internal table.

Now you have to pass this final internal table data to your submit program selection screen.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

  • DELANFREP = ' '

  • JOBGROUP = ' '

jobname = csm_std_reconciliation_job

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4

.

IF sy-subrc <> 0.

MESSAGE ID 'CSM' TYPE 'W' NUMBER '045' WITH csm_std_reconciliation_job.

EXIT.

ENDIF.

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

  • ARCPARAMS =

authcknam = sy-uname

  • COMMANDNAME = ' '

  • OPERATINGSYSTEM = ' '

  • EXTPGM_NAME = ' '

  • EXTPGM_PARAM = ' '

  • EXTPGM_SET_TRACE_ON = ' '

  • EXTPGM_STDERR_IN_JOBLOG = 'X'

  • EXTPGM_STDOUT_IN_JOBLOG = 'X'

  • EXTPGM_SYSTEM = ' '

  • EXTPGM_RFCDEST = ' '

  • EXTPGM_WAIT_FOR_TERMINATION = 'X'

jobcount = jobcount

jobname = csm_std_reconciliation_job

  • LANGUAGE = SY-LANGU

  • PRIPARAMS = ' '

report = csm_std_reconciler

variant = csmvari

  • IMPORTING

  • STEP_NUMBER =

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 'CSM' TYPE 'W' NUMBER '045' WITH csm_std_reconciliation_job.

EXIT.

ENDIF.

strttime = sy-uzeit + timepad.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcount

jobname = csm_std_reconciliation_job

sdlstrtdt = sy-datum

sdlstrttm = strttime

  • IMPORTING

  • JOB_WAS_RELEASED =

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 'CSM' TYPE 'W' NUMBER '045'

WITH csm_std_reconciliation_job.

EXIT.

ELSE.

MESSAGE ID 'CSM' TYPE 'I' NUMBER '104' WITH

csm_std_reconciliation_job.

ENDIF.

endselect.

Now for every 20000 records it will create one batch job.

Pls. reward if useful.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,162

Hi,

Another way is to export a variable to memory.The variable should be imported and incremented by one when the program is called.

If the variable count is one,then restrict the job in such a way so that it is submitted.

if count = 1.

call job_open..

call job_submit..

call job_close..

endif.

Read only

Former Member
0 Likes
1,163

Hi Mariposa,

I think you can use the function module SUBST_START_REPORT_IN_BATCH as an alternative.

Below is an example code.

DATA: i_param1 TYPE TABLE OF rsparams,

wa_param1 LIKE LINE OF i_param1.

wa_param1-selname = 'PA_FILE'.

wa_param1-kind = 'P'.

wa_param1-low = pa_file.

APPEND wa_param1 TO i_param1.

CALL FUNCTION 'SUBST_START_REPORT_IN_BATCH'

EXPORTING

iv_repname = sy-repid

TABLES

tt_reportparam = i_param1

EXCEPTIONS

variant_exist_check_failed = 1

variant_update_failed = 2

variant_update_not_authorized = 3

variant_update_no_report = 4

variant_update_no_variant = 5

variant_update_variant_locked = 6

variant_insert_failed = 7

variant_insert_not_authorized = 8

variant_insert_no_report = 9

variant_insert_variant_exists = 10

variant_insert_variant_locked = 11

variant_write_failed = 12

no_batch_service = 13

no_server_list = 14

batch_scheduling_failed = 15

OTHERS = 16.

ENDFORM. "RUN_JOB

Hope this helps!