Skip to Content
-1
Jun 26, 2017 at 03:58 PM

Problem with SUBMIT in Background

101 Views

I have requirement to update a data base table in background job. As per my requirement i cannot use update task. to achieve this i have created one report and in that report i wrote code to update my table. in foreground program i am submitting background job program. If i will execute background submitted program individually it's working fine but if i will submit program via background same record appending two times in data base table. i wrote the code like below. Please help me on this issue

** Open job without dialog
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc IS NOT INITIAL.
RAISE job_not_scheduled.

ELSE.

*-- Submit the program
SUBMIT /zupdate/c_pp_pplist_snapshot USER lv_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.

ENDIF.

*-- Job close.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = abap_true
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.
RAISE job_not_scheduled.
ENDIF.