cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic scheduling xscron from xsjs/ui in SP11

Saritha_K
Contributor
0 Kudos

Hi Experts,

We have created a xsjs script which accepts date and time from UI5 screen for setting the xscron job dynamically.

In it, we are passing parameters for xscron as 2016 08 08 mon 17 01 00.

It gets scheduled and its status doesnt get changed to running.

In our case, this date and time would depend upon user inputs and would be dynamic.

Has anyone been able to successfully execute xsjob based on user inputs ?

Regards,

Saritha

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

Hello Saritha,

yes, that works. What steps have you done in your code.

An example (which can be easily enhanced to accept user input values for the schedules) is listed in the online help: Add or Delete a Job Schedule during Runtime - SAP HANA Developer Guide for SAP HANA Studio - SAP Lib...

Regards,

Florian

Saritha_K
Contributor
0 Kudos

hi Florian,

It worked now but the  job's status seems to get updated into running status by a delay of 1 hour meaning, if i have scheduled xscron with parameters to run at 9am, it gets into running status at 10am.

Regards,

Saritha

pfefferf
Active Contributor
0 Kudos

Can you share your code?

Regards,

Florian

Saritha_K
Contributor
0 Kudos

Hi Florian,

Here is my code-

  1. calljob.xsjs

var responseBody = '';

$.import("sap.hana.xs.libs.dbutils", "xsds");

var XSDS = $.sap.hana.xs.libs.dbutils.xsds;

var myjob = new $.jobs.Job({uri:"/TEST_XSJS/demoXSJS.xsjob"});          

  1. myjob.activate({

        user: '#####',

        password: '#####'

    });

var year =  "2016";

var month = '8';

var day = '9';

var day_of_week = 'tue';

var hour = '10';

var minute = '07';

var second = '00';

var input_cron1 = year + " " + month + " " + day + " " + day_of_week + " " + hour + " " + minute + " " + second ;

   

var id = myjob.schedules.add({"description": "Table upd",

"xscron": input_cron1});

---------------------------------------------

this xjs calls xsjob as below-

{       

       "description": "test run" ,

       "action": "TEST_XSJS:insertjob.xsjs::createEntry2",

       "schedules": []

  }

--------------------------------------------

and in here my insertjob actually enters the records in a test table.

currently the problem is job gets scheduled and gets triggered by a delay of 1 hour.

Let me know if there is anything unclear.

Regards,

Saritha

pfefferf
Active Contributor
0 Kudos

Hello Saritha,

thx for sharing your code. Looks ok.

Did you consider that the schedules are in UTC and not in the local timezone?

Regards,

Florian

Saritha_K
Contributor
0 Kudos

Hi Florian,

Not very clear with the UTC and local timezone part which you mentioned.

Actually, I just ran the current_timestamp  and current_date function to get the time and date in hana studio and I am passing 5mins ahead time in my xscron parameters. Still it gets triggered after an hour.

Kindly suggest if I am missing on setting some additional time parameter as such on server level for scheduling as such

Regards,

Saritha

pfefferf
Active Contributor
0 Kudos

Please can you compare the values of CURRENT_TIMESTAMP and CURRENT_UTCTIMESTSAMP, to check if there is a difference?

Saritha_K
Contributor
0 Kudos

Hi Florian,

Yes there is a difference when I run current_timestamp and current_utctimestamp functions.

below is the output-

current_timestamp - 11:38:21

current_utctimestamp - 09-Aug-2016 10:39:06.246

so it means that server is scheduling jobs based on the utc timestamp.

Regards,

Saritha

pfefferf
Active Contributor
0 Kudos

Right, as I said above.

Regards,

Florian

Saritha_K
Contributor
0 Kudos

Hi Florian,

thank you so much for your help!!

Saritha_K
Contributor
0 Kudos

This message was moderated.

Answers (0)