Application Development 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: 

how to create a bg job with time zone issues

asatish_kumar
Explorer
0 Kudos

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


1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

0 Kudos

Yes, not released, but A Satish Kumaris not a customer (icon SAP)

Former Member
0 Kudos

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

alexander_bolloni
Contributor
0 Kudos

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