Automate your Repetitive (Boring) Tasks with SAP BTP – Job Scheduling Service

As a developer, there are always more tasks to complete than you have time for in a day. While it’s important to prioritize time-sensitive, impactful or blocking issues, they’re usually not the kind of things that can be knocked off your list quickly. If you try breaking down bigger tasks into smaller subtasks, you just end up increasing the list of things that still need to get done.

Most developers hate doing things that could be automated.

Here it comes to save your time and automate boring tasks

Define and manage one-time and recurring jobs or Cloud Foundry tasks.

SAP Job Scheduling service allows you to define and manage jobs that run once or on a recurring schedule. Use this runtime-agnostic service to schedule action endpoints in your application or long-running processes using Cloud Foundry tasks. Use REST APIs to schedule jobs, including long-running jobs asynchronously, and create multiple schedule formats for simple and complex recurring schedules. Manage jobs and tasks and manage schedules with a web-based user interface.

This is available via the Pay-As-You-Go for SAP BTP and CPEA payment models, which offer usage-based pricing.

The following features are available for the SAP Job Scheduling service:

Use flexible schedule formats Flexibly choose between cron and human-readable date formats for your schedules.
Get secure access Run jobs on behalf of an application secured by an OAuth 2.0 protected communication used when the service calls the action endpoint, and when the application invokes the services’ REST APIs.
Schedule synchronously or asynchronously Define and manage jobs synchronously or asynchronously as well as run long-running CF tasks asynchronously.
Optimize your resources usage Run Cloud Foundry tasks asynchronously and thereby optimize your resources usage.
App and scheduling logic separated USE REST APIs to perform CRUD operations on jobs and schedules and to retrieve run logs of executed schedules.
Dashboard for managing jobs and tasks Use the web-based user interface to create, edit, or delete jobs and tasks for a service instance. Create, manage, and monitor schedules for your jobs and tasks. Check the logs to see if a schedule was executed successfully.
Supports Node-js client libraries Convenient client library to execute CRUD operations, including create job, from your Node.js application.

Use cases

Developers/sysadmins do a lot of repetitive tasks on a daily basis like moving a file from one folder to another or running a specific job in the area of Devops. And as for the database admin owners, they might have to take a backup of their database schema on daily basis/nightly job or even on a hourly basis. Cron jobs could come in handy at situations like these.

There are tons of use cases to mention (few of them are below)

  • Execute Stored Procedure regularly.
  • Running Pipeline jobs based on the scheduled time
  • Trigger SAP Process Automation Jobs
  • Trigger SAP Integration Suite Iflows
  • Trigger S/4 HANA Cloud related manual tasks
  • Trigger SAP Commissions Pipeline Jobs
  • Trigger SAP Data Intelligence Jobs
  • Send Notifications if Services are down (Health Check Status)

Get Started to enable in your SAP BTP Cockpit Service

Go to Service Marketplace > find in Search “Job”

After you selected Job Scheduling Service – click Create

update json value as mentioned and click Next and Finish
Job%20Scheduler%20Service%u30A4%u30F3%u30B9%u30BF%u30F3%u30B9%u4F5C%u6210-2
Go to Instance & Subscriptions, you will find the Service name you created and click on the Job Scheduling Service link which will redirect to your Dashboard Portal.

After you enabled, Job Scheduling Service Dashboard with first look of glance with empty Tasks.

Plan : Lite

cf create-service jobscheduler lite <instance name> -c '{"enable-xsuaa-support": true}'

Plan : Standard

cf create-service jobscheduler standard <instance name> -c '{"enable-xsuaa-support": true}'

Get Started to create your own Use Case

There are 2 ways to Schedule & run the service :

  • Running Cloud Foundry Tasks
  • Consuming your existing deployed Application running on Cloud Foundry

manifest.yml

---
applications:
- name: commissions_pipeline memory: 128M disk_quota: 128M buildpacks: - nodejs_buildpack command: node server.js services: - xsuaa_apiaccess - jobs

server.js

const express = require('express');
const app = express(); // write your logic to execute or trigger your scenario const port = process.env.PORT || 3000;
app.listen(port, function () { console.log('listening');
})

package.json

{ "main": "server.js", "dependencies": { "express": "^4.18.1" }
}

Run this command to deploy Cloud foundry

cf push --task

To check once if its running

cf run-task commissions_pipeline --command "npm start" --name taskfromCli or cf run-task commissions_pipeline --command "node server.js" --name taskfromCli

To check in logs what is executed.

cf logs commissions_pipeline --recent 

Go to SAP Job Scheduling Dashboard Portal and Create a Task and Save


Select the Pattern for Schedule as per your choice of execution for your use case.

Also you can define Human readable date format ( explained below)
After you configured from above steps, you can click this Description of your Job to view Inside the schedule logs

 you can go to Run Logs to check if Job is started or completed.

Job is ran successful and completed.

Go to SAP Commissions – Pipeline Workspace to see if your Pipeline is triggered and running already.


Human-Readable Date Formats

The SAP Job Scheduling service supports human-readable dates and ranges for configuring both job and task schedules.

Note:

References


JobScheduler RestAPIs

JobScheduler Documentation

Purchase JobScheduler SAP Store

For more information about use cases for SAP Job Scheduling service, see SAP Discovery Center

crontab.guru