Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
JWootton
Advisor
Advisor
0 Kudos

How do you delay each event by a fixed amount of time before publishing?  Here's a simple example using the AGING feature of CCL and a filter.  Until an event has "aged' by the desired amount it doesn't pass thru the filter.

/* This example simply buffers incoming events and then publishes them after a delay.
* The amount of delay is the value in the AGES clause.  Note that the value in the KEEP clause
* needs to be greater than the value in the AGES clause.  The output stream will suppress the
* deletes generated by the retention policy (i.e. the KEEP clause)
*
*/


CREATE INPUT STREAM EventsIn
  SCHEMA (Column1 integer , Column2 integer );

CREATE OUTPUT WINDOW Delay
  SCHEMA (ID long, Age integer, Column1 integer , Column2 integer )
  PRIMARY KEY ( ID )
  KEEP 10 SECONDS
  AGES EVERY 5 SECONDS SET Age
   AS SELECT
    nextval() as ID,
    0 as Age,
    EventsIn.Column1 as Column1,
    EventsIn.Column2 as Column2
  FROM EventsIn;

CREATE OUTPUT STREAM EventsOut
  AS SELECT
    Delay.Column1 Column1 ,
    Delay.Column2 Column2
  FROM Delay
  WHERE Delay.Age = 1;