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

background job

Former Member
0 Likes
574

I open a job and submit a program via this job name.I closed this job and run it immediately. But I find that as if this job is scheduled as background job again to run later. I just want it run once (when calling job_close). Who can tell me how I can just run the job once and this job would not be scheduled again? My codes is attached.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

SUBMIT sd70av3a AND RETURN

WITH rg_kschl = output_type

WITH pm_vermo = 2

WITH rg_vbeln = num

TO SAP-SPOOL

SPOOL PARAMETERS ls_params WITHOUT SPOOL DYNPRO

VIA JOB jobname

NUMBER jobcount.

  • Close job

  • start it immediately

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

strtimmed = 'X'

targetsystem = host

EXCEPTIONS

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

OTHERS = 99.

  • check job status

DO.

CALL FUNCTION 'BP_JOB_STATUS_GET'

EXPORTING

jobcount = jobcount

jobname = jobname

IMPORTING

status = job_status

has_child = job_child.

IF job_status = 'F'. "job has finished

EXIT.

ENDIF.

ENDDO.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
533

Change prddays to '0' in JOB_CLOSE.

I open a job and submit a program via this job name.I closed this job and run it immediately. But I find that as if this job is scheduled as background job again to run later. I just want it run once (when calling job_close). Who can tell me how I can just run the job once and this job would not be scheduled again? My codes is attached.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

SUBMIT sd70av3a AND RETURN

WITH rg_kschl = output_type

WITH pm_vermo = 2

WITH rg_vbeln = num

TO SAP-SPOOL

SPOOL PARAMETERS ls_params WITHOUT SPOOL DYNPRO

VIA JOB jobname

NUMBER jobcount.

  • Close job

  • start it immediately

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

strtimmed = 'X'

targetsystem = host

EXCEPTIONS

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

OTHERS = 99.

  • check job status

DO.

CALL FUNCTION 'BP_JOB_STATUS_GET'

EXPORTING

jobcount = jobcount

jobname = jobname

IMPORTING

status = job_status

has_child = job_child.

IF job_status = 'F'. "job has finished

EXIT.

ENDIF.

ENDDO.

2 REPLIES 2
Read only

Former Member
0 Likes
534

Change prddays to '0' in JOB_CLOSE.

Read only

Former Member
0 Likes
533

Hi Jack,

Please change this (bold).

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

<b>prddays = 0</b>

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

strtimmed = 'X'

targetsystem = host

Regards,

Ferry Lianto