Technical Articles
Using Job Scheduler in SAP Cloud Platform [0]: Intro and Prep
This series of blogs intends to show in an easy way how to use the Job Scheduler service in SAP Cloud Platform
In this first blog, we’re going to prepare ourselves before we start with a first example
Overview
What’s that: Job Scheduler?
It is a tool.
It allows to define jobs in SAP Cloud Platform
A job can be configured to run regularly, or just once
A job triggers an action
What is it not?
Job Scheduler is not a framework
It doesn’t help to create the actions which should be executed
It’s just a tool to trigger anything which already exists
How does it work?
Job Scheduler is a cloud service in SAP Cloud Platform
There’s a Dashboard which allows to define jobs
A job is configured with a URL
This means your job would invoke that URL e.g. every night
A job can as well be configured with a CloudFoundry-Task
How does it work technically?
You have an application in SAP Cloud Platform
You add a REST endpoint to your app, which can be invoked and which does something
You bind your app to an instance of Job Scheduler service
Now you can configure Job Scheduler to call this endpoint every night (or whatever)
The result of the HTTP call is evaluated by Job Scheduler
More details please?
Job Scheduler requires that you bind your app also to an instance of xsuaa service (Authorization and Trust Management)
Note: the order of binding is relevant !
Which Features does it have ?
Job Scheduler functionality of triggering actions (It doesn’t help to define such actions)
User Interface to create jobs and define schedules, to view results, etc
Interface to manage jobs/schedules via API (REST, node.js, Java)
Details:
Support for Cloud Foundry tasks
Schedules can be defined with cron or human readable format
Jobs can run synchronously or asynchronously
2 Service plans: ‘lite’ and ‘standard’
What’s the difference between both service plans ?
Service Plan ‘lite’
Is only intended to be used in trial landscape.
Allows to create multiple jobs (or Cloud Foundry “Tasks”) with minimum schedule frequency of an hour (Non Productive usage).
Supports HTTP REST endpoints to be triggered by a job
Supports as well Cloud Foundry “Tasks”
Allows 15 schedules.
Service Plan ‘standard’
Minimum schedule frequency is 5 minutes.
Support for multitenancy
OAuth2 for REST API
Service Plan ‘service’
Don’t use
Deprecated since long time -> do nut use
Will be removed in the future -> so better not use
Remember: It should not be used
Note:
In case you face problems with display of Job Scheduler Dashboard:
Are you using old Microsoft browser?
Background:
Newer UI5 versions (from 1.88) don’t support the legacy browsers IE11 and Edge Legacy (Edge HTML) anymore (more info)
To solve the problem, you should use modern browser
Preparation
If you want to use Job Scheduler in SAP Cloud Platform, you need to create 2 service instances
Create instance of Job Scheduler service
Creating an instance of the Job Scheduler service is anyways the first step do do
It can be reused by all required applications
In SAP Cloud Platform, Cloud Foundry Environment, (Trial) go to your Space and open the Service Marketplace
Find the tile “Job Scheduler”
Note: if you don’t see the Job Scheduler in the Service Marketplace, you need to configure Entitlements. See Appendix
Click the tile Job Scheduler -> Instances -> New instance
Choose Service Plan as ‘lite’ (anyways, in Trial, only ‘lite’ is supported)
Parameters: fill in the following into the text field :
{
"enable-xsuaa-support": true
}
It looks like this:
Step through the wizard and provide an instance name of your choice, e.g. jobschedulerinstance
Note:
The configuration parameter enable-xsuaa-support is always required, unless you want to trigger only CF Tasks (no REST endpoints)
Create instance of xsuaa service
After creating the service instance of Job Scheduler, the next task to do is creating an instance of Authorization and Trust Management (XSUAA)
However, this instance requires configuration which is a bit specific to the use case.
As such, it will be described later
Only one info: You should use service plan ‘broker’
Note:
If you already have a XSUAA instance that is bound to your application then you can also re-use it and bind it to the Jobscheduler. It might require the update-service command
Summary
In this blog, we’ve learned that Job Scheduler is a tool which can trigger actions,
e.g. invoke REST endpoints.
It can be configured to do that on e.g. regular basis
To use Job Scheduler, you need and application (with endpoint) and you have to bind it to service instances of JobScheduler and XSUAA
And remember that the order is important (order of creation and binding)
Next Steps
Recommended readings:
Part 1: First simple use case in Trial account
Part 3: Simple use case with authentication and authorization
Part 5: Long-running operations (async jobs)
Part 6: Troublemaking (get little help for 403 error)
Links
See links section in the overview blog post.
Appendix: How to Configure Entitlements
- Go to your global account, e.g. P123456789trial
- Click on Entitlements in the left menu pane
- Click on Entity Assignments
- Select in SubAccounts in the DropDownbox e.g. ‘Trial’
- Click on ‘Go’
- Click on ‘Configure’
- Afterwards one click on “Add Service Plans”
- In the dialog you can search for Job Scheduler
- Select Checkbox ‘lite’ (Available service plans)
If the allowed service plan is grayed-out, then you might need to remove from other subaccount or, in productive environment, purchase quota - Click on Button ‘Add 1 ServicePlan’
- Don’t forget to click on ‘save’
- Go back to the Service market place you should see the Job Scheduler Tile
Dear Carlos,
Thanks for the summary of the main concepts of job scheduler, and how we can setup it in cf instance.
Regards,
Luis Benavides Andrade
Dear Luis Benavides Andrade ,
Thanks for your comment, I'm glad if it was helpful and I hope Jobscheduler is useful tool for you
In the meantime, there are more Blogs - just in case you need some more information
Thanks and kind Regards, Carlos
Hello Carlos, I have a app for executing every 2 days a procedure of long duration from SAP Cloud Foundry, I'm trying configurate a task for using this app, but I have problems with the setting of the action parameter, I haven't could make it work, You have a example or documentation similary I whant to make through task, because understand that i can stop the app in the cockpit and the shedule task continue works, because I don't need the asociate url
thanks for your help
Hi Aristobulo Cruz , I assume you're talking about CloudFoundry-Tasks, as described here?
I haven't tried (yet) and creating a tutorial would take time. If you still haven't got it running, I'd need to ask for support myself.
You can contact me via personal message
Kind Regards,
Carlos
Dear Carlos,
we are using Job Scheduler and are missing an alerting functionality. A Job Scheduler without notifications is kinda missing the point 🙂 Can you give us some information on that? I believe I read somewhere that SAP plans to integrate all kinds of applications into altert notfication, I should think job scheduler would be integrated too?
Thanks and best regards,
Tobias
Hello Tobias Mitter , thanks for your comment, yes, you're absolutely correct. This is an enhancement which would round up the Jobscheduler functionality.
It is planned, but will need some time.
In the meantime, I guess it should be possible to add the required alert into the own endpoint?
Thanks, Carlos
Hi Carlos Roggan
Do we any tentative timeline when this will be available for customers as alert functionality from Job Scheduler would help .
Regards
Taranam
Hello @Carlos,
First of all, thanks for the awesome blog. I am looking forwards to consuming the SAP Apis for our platform. But I am not sure, if the above content is something that i should follow.
My use case is simple, from our platform, we wish to utilise the SAP apis(API that will expose certain docs that they have shared on the SAP application platform.)
The above examples show how i can utilise there APIs but do you have any input/advice for my use case.
Hello Vivek Singh ,
Thank your for your nice feedback!
Jobscheduler is used to trigger <your> API endpoint on a regular basis.
I'm not sure if I understand your question.
You can write a personal message to me, to clarify further.
OK?
Kind Regards,
Carlos
Hello Carlos,
Can we trigger external APIs example from CPI? Does it support destination concept?
Thanks
Pranav
Hello Pranav Nagpal ,
Jobscheduler is designed to be bound to an application in Cloud Foundry environment. Like that, Jobscheduler can automatically do the oauth flow.
In the UI, you can enter any URL (as long as it doesn't require JWT token login).
The UI also requires to enter an application, so this would require a trick/workaround (create dummy app)
Kind Regards,
Carlos
Hi Carlos Roggan ,
thanks for his blog series!
I get in my trial account despite having one appropriate entitlement (already tried repeatedly removing the entitlement and readding it; and as expected when entitlement is removed the tile is not there)
Service broker error: Service broker jobscheduler-broker failed with: Subaccount quota limit for specified service plan has exceeded. Please contact service administrator.
Any idea what goes wrong here?
Also can the job scheduler be used to start a CF app at regular intervals? I am bit confused by the CF tasks discussion...
Thanks!
Hello Wolfgang Röckelein ,
it seems that sometimes there are issues with service creation via cockpit.
It works when using the cloudfoundry CLI on command line.
Could you give it a try?
Jobscheduler is used to trigger endpoint of a CF app. The app must be running. It cannot be started by Jobscheduler.
In addition, Jobscheduler can also be used to trigger CF Task. This is different by nature.
Kind regards,
Carlos
Hi Carlos Roggan ,
thank you very much for your fast answer!
indeed using the CLI immediatly worked.
Thanks for the clarification regarding CF Tasks. Is there a complete example somewhere for Jobscheduler to start a CF Task as I think tasks are more the thing matching what I like to achieve?
Regards,
Wolfgang
Re
Hello Wolfgang Röckelein , good to know that it worked ! About the CF Tasks, unfortunately, I'm not aware of any example.
Kind Regards, Carlos
Hi @Roggan,
meanwhile I found a blog from Marius Obert https://blogs.sap.com/2019/05/01/cloudfoundryfun-4-fetch-football-scores-periodically/ . I built a task and scheduled it following this blog and everything works as expected.
What however still puzzles me regarding xsuaa : Does the task run with some authorizations and can I use them in an outgoing REST call?
Regards,
Wolfgang
Hi Wolfgang Röckelein ,
thanks for sharing the link, it will be useful for other readers as well (including myself)
I don't fully get the question about xsuaa. As far as I understand, a CF Task behaves like a command that is started by Jobscheduler. As such, Jobscheduler cannot send any token. If the task is supposed to do a REST call, it would need to fetch the required token itself (e.g. it might be required to create service key of xsuaa).
Hope this clarifies a bit?
Kind Regards,
Carlos
Hi Carlos,
we currently use IBM product Tivoli Workload Scheduler to run our R/3 jobs... we are planning to migrate to the cloud in the next year... are you aware of any course that SAP has to learn job scheduler in the cloud environment. i wanted to see the differences between TWS and SAP Job Scheduler...
i.e unix file based dependencies to launch the job, pager/email alerts if jobs fail. job dependencies on jobs and jobstreams. In TWS we have jobstreams where a set of jobs reside i.e. jobstream for Mondays that have 10 jobs in them and each one is dependent on the previous job completing successfully before the next one kicks off... also the Monday jobstream is dependent on the Sunday jobstream completing successfully before any of the jobs in the Monday jobstream can even think of kicking off. Any info from you would be much apprecated,
thanks
Armin Pohl
Hi Carlos,
Can we schedule a Flowgraph/reptask using Job Scheduler. If yes then can you please guide me.
Best Regards,
MK
Could you please share the Document or PPT with me