Professional Documents
Culture Documents
SAP HANA Developer Edition
SAP HANA Developer Edition
SAP HANA Developer Edition
Most of the time we get requirement from client, where we need to update a table(s) on specified time interval
say week or month basis. So, here I come with an easy step-by-step process showing, how to schedule a job in
SAP HANA which will auto-execute stored procedure after specified interval.
Prerequisite:
Note - First verify XS Engine is up and running by using following URL in your Internet Browser where HANA
Client is installed. -
http://localhost:8000/
Replace 'localhost' with IP. Contact Basis / HANA Admin Team to get IP
Result:
In the above table, we will update price by 10% on selected date for selected state i.e STATE_ID_FK=1.
Step 1:
Note : We have not used any date filter in where clause to make example simpler.
Step 2 :
Goto
File -> New -> Project
Step 4:
. xsaccess :
{
"exposed" : true,
"authentication" :
[
{ "method" : "Form" }
]
}
.xsapp :
MyFirstSourceFile.xsjs:
function My_table()
{
var query = "{CALL <<YOUR_SCHEMA_NAME>>.<<YOUR_STORE_PROCEDURE_NAME>>}";
$.trace.debug(query);
var conn = $.db.getConnection();
var pcall = conn.prepareCall(query);
pcall.execute();
pcall.close();
conn.commit();
conn.close();
}
MyJobs.xsjob :
{
"description": "Job to Update MY_TABLE values",
"action": "XS_job_learning:MyFirstSourceFile.xsjs::My_table",
"schedules":
[
{
"description": "Table will update after every 59 sec",
"xscron": "* * * * * * 59"
}
]
}
Note : "action" row in very important line in .xsjob file. It will search 'XS_job_Learning' then
'MyFirstSourceFile.xsjs' file and try to execute 'My_table' function which will execute the created store
procedure.
If you want more information about Cron Job, then click on Cron - Wikipedia, the free encyclopedia
Step 5 :
Now, you have completed all your coding at desktop level. Move your files at repositories.
Please type http://localhost:8000/<<Your_Path>> in browser. (This is XS_job_Learning Path in repository. For complete
path, you can coordinate with your Basis / HANA admin team. )
Please login using appropriate credentials.
Step 7 :
After successful Login, You will find 'XS_job_Learning' - > MyJobs.xsjob in Application Objects window
On above screen, please select 'Active' checkbox and click on 'Save' push button to activate job scheduling in
SAP HANA.
After this, Job is auto-scheduled after specified time interval mentioned in MyJobs.xsjob .
To unscheduled job, uncheck the 'Activate' checkbox and click on 'Save' push button.
Observation -
Step 8 :
Note: You need to provide following rights to execute job in xs engine to users.