01-08-2015 8:23 PM
I am facing an issue while creating a bg job , the system time is ahead of user time (timezone) and with that it gives an error in SM21 logs saying start date for the job provided is in the past (the reason is system time is 2 hours ahead of user with which it is creating bg job )
and also in our existing code CALL FUNCTION 'BP_JOB_CREATE' is used , but in sdn discusions I see JOB_OPEN, then JOB_SUBMIT and JOB_CLOSE to be used /suggested and also the code snippet existing is
SELECT SINGLE tzonesys FROM ttzcu INTO lv_tzonesys.
GET TIME STAMP FIELD lv_tstmp.
CONVERT TIME STAMP lv_tstmp TIME ZONE lv_tzonesys
INTO TIME lv_cur_time.
ADD 10 TO lv_cur_time.
* Create Job header.
ls_job_head-jobname = 'XXXXXXX'. // I changed the jobname here
ls_job_head-sdlstrtdt = sy-datum.
ls_job_head-sdlstrttm = lv_cur_time.
ls_job_head-sdluname = /xxx/cl_sr_tml_services=>mv_bguserid.
ls_job_head-periodic = space.
ls_job_head-authcknam = /XXXX/cl_sr_tml_services=>mv_bguserid.
ls_job_head-reluname = /XXXX/cl_sr_tml_services=>mv_bguserid.
it is a mainteneace project should I just change ls_job_head-sdlstrttm = sy-uzeit and continue with existing code or change it completely by removing BP_JOB_CREATE to JOB_OPEN and JOB_SUBMIT and JOB_CLOSE , please suggest as i am new to ABAP .
Thanks
Satish
01-09-2015 2:32 AM
Hi Satish,
Both is ok, if you still want use 'BP_CREATE_JOB', do not forget ls_job_head-sdlstrttm = sy-uzeit + 10.
And this FM is not released for customer use.
regards,
Archer
01-09-2015 2:32 AM
Hi Satish,
Both is ok, if you still want use 'BP_CREATE_JOB', do not forget ls_job_head-sdlstrttm = sy-uzeit + 10.
And this FM is not released for customer use.
regards,
Archer
01-09-2015 2:53 PM
Yes, not released, but A Satish Kumaris not a customer (icon SAP)
01-09-2015 4:39 AM
Hi Satish,
You can use the below code to create bg job.
DATA: lv_jobname TYPE tbtcjob-jobname,
lv_jobcount TYPE tbtcjob-jobcount,
starttimeimmediate LIKE btch0000-char1 VALUE 'X'.
lv_jobname = 'BG_JOB'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03
OTHERS = 99.
"" Submit report into job
SUBMIT zreport AND RETURN
WITH param1 = lv_param1
WITH param2 = lv_param2
USER sy-uname
VIA JOB lv_jobname
NUMBER lv_jobcount.
"" Close the job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = starttimeimmediate
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.
Thanks,
Ritu
01-09-2015 8:16 AM
Hello,
as far as I know, the batch subsystem (and the APIs) do not know about user timezones. Everything works in system timezone. So if you have a start time in a user-timezone, you should convert this timestamp to system timezone before passing it to the batch APIs.
Best regards,
Alex