cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduling a background job in sap hana.

Former Member
0 Kudos

Hello Experts,

I have been assigned a task where I have to schedule background jobs in SAP HANA .

Is it necessary to create procedures or can it be done using simple sql statements?

Please help me out in solving this issue.

Thanks & Regards,

Shreya.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Shreya,

You can try the following document:

Scheduling a XSengine Background job to call a procedure

Regards,

Sharath

Former Member
0 Kudos

Hi ,

I have 2 development servers and I am able to create the background job in one server and running every 1 min ,the other one I tried to follow same steps but not able to activate my .xsjob file.

The error says :Required object does not exist or exist multiple times.

I have all the required roles assigned to my userid,

.xsjob file loos like

 

{

"description": "Background job test",

"action": "xxxxx::procedure",

"schedules":

[ { "description": "This job will run every minute",

"xscron": "* * * * * * 59"

}

]

}

DeepakVarandani
Explorer
0 Kudos

Hi Dipti,

   I am getting same error at the time of activation of .xsjob file.

Did you get the solution for the same ??

Former Member
0 Kudos

Hi Deepak,

Yes ,My problem resolved by creating .hdbprocedure   .

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

This error seems to be related to the action you refer to in your xsjob file.

Pay attention to the syntax: path:filename.xsjs::functionname

Hope this helps someone to fix this problem!

Trinidad.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You can only schedule SQLScript Procedures or XSJS functions.  If you have a series of simple SQL statements they need to be wrapped in either on of these.

Former Member
0 Kudos

Hi Thomas,

      Thanks for your reply. Can you please let me know how to schedule background jobs using sql script procedures..?

Thanks & Regards,

     Shreya.

thomas_jung
Developer Advocate
Developer Advocate
Former Member
0 Kudos
Hi Thomas,
I have tried writing these procedures and xsjob files.But when I'm trying to Activate the Schedule. xsjob file. It is giving activation error stating "Invalid file content". I'm not understanding what the problem is, Can you please go through the below scripts and let me know what the problem is?
schtest.hdbprocedure
PROCEDURE "TEST1"."Testdemo.jobs::schtest" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA TEST1
READS SQL DATA AS

BEGIN
Insert into "DEMOTABLE" values(now(),'Inserted SQL via SQL Script');
/*****************************
Write your procedure logic
*****************************/


END;

Schedule.xsjob file

{
"description": "My first SQL Script job"
"action": "Testdemo.jobs::schtest.hdbprocedure"
"schedules": [ {

"description": "Will run every 10 seconds"
"xscron": " * * * * * * 59" }
]

}

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Don't put the .hdbprocedure on the end of the procedure name in the XSJOB definition.  Here is an example of calling a stored procedure from XSJOB:

{

  "description": "My first SQLScript job",

  "action": "playground.sp7.procedures::jobsCreateEntry",

  "schedules": [ {

    "description": "Will run every 10 seconds", 

    "xscron": "* * * * * * 0:59/10" } ]}

Former Member
0 Kudos

Hi Thomas ,

      When i don't put the .hdbprocedure at the end it shows an error at schtest statement.

I have attached the snapshot for your reference.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Is that really an error or just the editors spell checker?  I think from the screen shot its just the spell checker - which is pretty meaningless for such artifacts.  Did it activate correctly?

Former Member
0 Kudos

Hi Thomas,

Yes, that was just a spell checker. May I know what what is JobsDemo.Details in your example?

The other thing is that whenever I login into XS Admin tool, I am unable to edit anything. I can just see a message  stating "You are logged in as System". What might be the issue? How can I proceed and activate my .xsjob file and my procedure over there?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

JobsDemo.Details?  I don't see that anywhere in the job definition I posted. That is in the body of my procedure, but I didn't post that here.  How did you see that?  Its just a test table for the demo.  Whenever the job runs it writes a record into that table. That way its easy to show that the job is really running.

>The other thing is that whenever I login into XS Admin tool, I am unable to edit anything

First guess would be that you are missing the proper authorizations.  Just because you are SYSTEM user doesn't mean you automatically have access.  Even system must be granted the necessary roles.

Former Member
0 Kudos

Hi Thomas,

I'm sorry, it was not in the post. I saw JobsDemo.Details in one of your videos regarding Scheduling Background Jobs in SAP Hana. Would you please let me know what that is? What access rights must be granted to SYSTEM in order to access XS Admin tool?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Would you please let me know what that is?

I did already in the previous posting.

>What access rights must be granted to SYSTEM in order to access XS Admin tool?

The required role was listed toward the beginning of the help link I posted earlier.

NoteThe tasks required to set up a scheduled job in SAP HANA XS are performed by two distinct user roles: the application developer and the SAP HANA administrator. In addition, to maintain details of an XS job in the SAP HANA XS Administration Tool, the administrator user requires the privileges assigned by the user rolesap.hana.xs.admin.roles::JobAdministrator .

Former Member
0 Kudos

Hi Thomas,

I checked for the roles of the System. I can find sap.hana.xs.admin.roles::JobAdministrator  role  assigned over there. Even then I'm unable to log in completely in XS admin tool. It is still displaying  "You are logged in as System" after log in. Should I check any other roles?How can I resolve this issue?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That's the role required to use the tool. Make sure that your user also has package privileges.  Double check the role assignment and force re-login.  If it continues to fail, you will need to enter a support ticket.

srinivasan_vinayagam
Active Contributor
0 Kudos

Hi Shreya,

Regards,

V Srinivasan