/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
*/
CREATE COLUMN TABLE "<SPACE_NAME>#<OSS_NAME>"."SP_CONTROL_TABLE_OSS"(
"SP_NAME" NVARCHAR(100) NOT NULL,
"DATE" DATE NOT NULL,
"RUN_NUMBER" INTEGER NOT NULL,
"SP_START_DATE_TIME" LONGDATE,
"SP_END_DATE_TIME" LONGDATE,
"RUN" INTEGER NOT NULL,
PRIMARY KEY ("SP_NAME","DATE","RUN_NUMBER")
);
/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
*/
CREATE COLUMN TABLE "<SPACE_NAME>#<OSS_NAME>"."SP_TEST"
(TEST VARCHAR(100));
/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
<STORED_PROC_NAME> - Name of Stored Procedure
*/
CREATE PROCEDURE "<SPACE_NAME>#<OSS_NAME>"."<STORED_PROC_NAME>"
AS
BEGIN
IF
(
SELECT 1 as RUN_STATUS
FROM "<SPACE_NAME>#<OSS_NAME>"."SP_CONTROL_TABLE_OSS" OSS
INNER JOIN "<SPACE_NAME>"."SP_CONTROL_VIEW_DSP" DSP
on OSS."SP_NAME" = DSP."SP_NAME"
and OSS."RUN_NUMBER" = DSP."RUN_NUMBER"
and OSS."DATE" = DSP."DATE"
WHERE
OSS."DATE" = CURRENT_DATE
AND OSS."SP_NAME" = '<STORED_PROC_NAME>'
AND OSS."RUN" = 0
AND DSP."RUN" = 1
and OSS."SP_START_DATE_TIME" IS NULL
) = 1
THEN
--Updater SP Start Time
MERGE INTO "<SPACE_NAME>#<OSS_NAME>"."SP_CONTROL_TABLE_OSS" OSS
USING "<SPACE_NAME>"."SP_CONTROL_VIEW_DSP" DSP
ON
OSS."SP_NAME" = DSP."SP_NAME"
AND OSS."RUN_NUMBER" = DSP."RUN_NUMBER"
AND OSS."DATE" = DSP."DATE"
AND OSS."DATE" = CURRENT_DATE
AND OSS."SP_NAME" = '<STORED_PROC_NAME>'
AND OSS."RUN" = 0
AND DSP."RUN" = 1
WHEN MATCHED THEN UPDATE SET OSS."SP_START_DATE_TIME" = CURRENT_TIMESTAMP ;
COMMIT;
-- Call other Stored procedures or steps
INSERT INTO "<SPACE_NAME>#<OSS_NAME>"."SP_TEST" ("TEST")
VALUES (CONCAT('Test Entry - ',(current_utctimestamp)));
-- --Updater SP End Time
MERGE INTO "<SPACE_NAME>#<OSS_NAME>"."SP_CONTROL_TABLE_OSS" OSS
USING "<SPACE_NAME>"."SP_CONTROL_VIEW_DSP" DSP
ON
OSS."SP_NAME" = DSP."SP_NAME"
AND OSS."RUN_NUMBER" = DSP."RUN_NUMBER"
AND OSS."DATE" = DSP."DATE"
AND OSS."DATE" = CURRENT_DATE
AND OSS."SP_NAME" = '<STORED_PROC_NAME>'
AND OSS."RUN" = 0
AND DSP."RUN" = 1
WHEN MATCHED THEN UPDATE SET OSS."RUN" = 1, OSS."SP_END_DATE_TIME" = CURRENT_TIMESTAMP ;
END IF;
END
/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
<STORED_PROC_NAME> - Name of Stored Procedure
*/
-- Schedule Stored Procedure to run every minute
CREATE SCHEDULER JOB <STORED_PROC_NAME>_JOB CRON '* * * * * * 00'
ENABLE PROCEDURE "<SPACE_NAME>#<OSS_NAME>"."<STORED_PROC_NAME>" ;
/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
*/
--Create Tally Table Function
CREATE FUNCTION "<SPACE_NAME>#<OSS_NAME>".TALLY_TABLE (maxnumber int)
RETURNS table (rownum int)
AS
BEGIN
RETURN
SELECT ROW_NUMBER() OVER (ORDER BY OBJECT_OID) AS ROWNUM
FROM SYS.OBJECTS
LIMIT :maxnumber;
END
/*
Find and replace the following with your values
<SPACE_NAME> - Space Name
<OSS_NAME> - Open SQL Schema Space Name
<STORED_PROC_NAME> - Name of Stored Procedure
*/
--Load Run schedule into Control table (Space Time Dimension - SAP.TIME.VIEW_DIMENSION_DAY and TALLY_TABLE function)
INSERT INTO "<SPACE_NAME>#<OSS_NAME>"."SP_CONTROL_TABLE_OSS"
("SP_NAME","DATE","RUN_NUMBER","RUN")
SELECT
'<STORED_PROC_NAME>' as SP_NAME
,"DATE_SQL" as DATE
,b."ROWNUM" as RUN_NUMBER
,0 as RUN
FROM "<SPACE_NAME>"."SAP.TIME.VIEW_DIMENSION_DAY" a
CROSS JOIN "<SPACE_NAME>#<OSS_NAME>"."TALLY_TABLE"(100) b
WHERE "DATE_SQL" Between CURRENT_DATE and '2026-04-01'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |