SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Scheduling SAP HANA Cloud Tasks

Learn different ways that SAP HANA Cloud tasks can be scheduled.

Overview

🎓 intermediate 10 min. SAP HANA CloudIntermediateSAP HANA Cloud SAP HANA DatabaseSAP HANA Cloud Data LakeSAP Automation Pilot

You will learn

  • โœ”How stored procedures can be scheduled with the CREATE SCHEDULER JOB SQL statement
  • โœ”How tasks can be scheduled using cron on Linux
  • โœ”How tasks can be scheduled in the SAP Automation Pilot There are different tools that can be used to schedule commands. SAP HANA enables stored procedures to be scheduled. Linux provides a service called cron that can execute a script at a scheduled time. The SAP Automation Pilot is a service in the SAP BTP that has a feature to enable commands to be scheduled. This tutorial will demonstrate each of these methods of scheduling tasks.
Unknown U Unknown April 15, 2025
Created by October 16, 2023
Contributors

Prerequisites

Prerequisites

  • An SAP BTP account
  • An SAP HANA Cloud instance

Steps

Step 1 Scheduling SQL using CREATE SCHEDULER JOB
โ€”

In this step a diagnostic script from the SQL Statement Collection for SAP HANA will be used. If you have not already done so, download SQLStatements_SHC.zip. The download section shown below is near the bottom of the SAP Note.

download SQL statements
download SQL statements

The script HANA_Configuration_MiniChecks_SHC.txt will be placed in a stored procedure and its output will be written to a table. The procedure can be scheduled to run once a day. It will check for configuration values that are outside of expected values.

  1. Create a table to hold the results. Run the below SQL in the SAP HANA database explorer connected to an SAP HANA database.

    SQL
    CREATE COLUMN TABLE DBADMIN.MINI_CHECK_RESULTS(
      CHID VARCHAR(5),
      DESCRIPTION VARCHAR(100),
      HOST VARCHAR(100),
      VALUE VARCHAR(100),
      EXPECTED_VALUE VARCHAR(100),
      C VARCHAR(1),
      SAP_NOTE VARCHAR(8),
      CHECK_TIME TIMESTAMP
    );
  2. Copy the contents of HANA_Configuration_MiniChecks_SHC.txt into a SQL console.

    configuration mini checks
    configuration mini checks

    Execute the script to ensure that it runs correctly and examine its output.

    mini checks results
    mini checks results

  3. Modify the script to only show critical errors by removing the below from approximately line 7916. Ctrl+L can be used to go to a line within the SQL console. The line numbers mentioned here are subject to change as the script is frequently updated.

    SQL
    ONLY_POTENTIALLY_CRITICAL_RESULTS = ' ' OR
  4. Below line 688 which contains LPAD(SAP_NOTE, 8) SAP_NOTE) add the SQL below so that each row in the table will have a timestamp.

    SQL
    ,
    CURRENT_TIMESTAMP
  5. Create a stored procedure and insert the results into a table by adding the following to the top of the file. The shortcut Ctrl+Home can be used to navigate to the top of the file.

    SQL
    CREATE OR REPLACE PROCEDURE DBADMIN.HANA_Configuration_MiniChecks()
    LANGUAGE SQLSCRIPT AS
    BEGIN
    INSERT INTO DBADMIN.MINI_CHECK_RESULTS
  6. At the bottom (Ctrl+End), add

    SQL
    ;
    END;
  7. Run the SQL to create the new procedure.

    create stored procedure
    create stored procedure

  8. In a new SQL console, call the stored procedure and check the results.

    SQL
    CALL DBADMIN.HANA_CONFIGURATION_MINICHECKS();
    SELECT * FROM DBADMIN.MINI_CHECK_RESULTS;

    call the procedure
    call the procedure

    Notice that the table MINI_CHECK_RESULTS contains the results of the checks that occurred from running the HANA_Configuration_MiniChecks_SHC.

  9. The procedure can now be scheduled to run at a set frequency.

    SQL
    --Get the current date and time in UTC
    SELECT CURRENT_DATE, CURRENT_TIME FROM DUMMY;
    SQL
    --Schedule an event a few minutes in the future
    --Adjust the date and time below
    CREATE SCHEDULER JOB DBADMIN.MINICHECKS CRON '2023 08 28 * 17 14 0' ENABLE PROCEDURE DBADMIN.HANA_CONFIGURATION_MINICHECKS;
    SELECT * FROM SCHEDULER_JOBS WHERE SCHEDULER_JOB_NAME = 'MINICHECKS';
    SELECT * FROM M_SCHEDULER_JOBS;

    The script will be run on a specified schedule and will record the results of each run in the table MINI_CHECK_RESULTS.

    After the scheduled time, examine the contents of the table MINI_CHECK_RESULTS to confirm that the stored procedure was executed at the scheduled time.

    SQL
    SELECT * FROM DBADMIN.MINI_CHECK_RESULTS;
  10. Details of scheduled jobs and their executions can also be seen under Job Scheduler in the SAP HANA database explorer’s catalog.

    job schedueler
    job schedueler

    If the job does not appear, check if a schema filter is set.

    For additional details see Scheduling Administrative Tasks.

A job has now been scheduled within SAP HANA Cloud, SAP HANA database. It should be noted that scheduled jobs only run when the SAP HANA database is running.

Step 2 Scheduling using CRON
+
Step 3 Scheduling Tasks in the SAP Automation Pilot
+
Step 4 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Scheduling SQL using CREATE SCHEDULER JOB 2. Scheduling using CRON 3. Scheduling Tasks in the SAP Automation Pilot 4. Knowledge check

Learn more →