Skip to Content
Technical Articles

Analyse your processes with Celonis Snap via the SAP Data Hub

For this blog, I wrote a process simulator to mimic me at home after work. (Code available in the appendix.) I enter my house through the hall and from there alternate randomly between my study, the lounge and the kitchen. The implemented logic is that after two visits to the kitchen I must go to the bathroom and after fife visits to the lounge I go to the bedroom which also ends the day. In the Celonis Activities Process Overview this looks as follows:

Since my process simulator publishes its events to a Kafka channel, I leverage the SAP Data Hub (Graph details in the appendix) to collect those and store them in a file (available in the appendix) for upload into Celonis Snap:

As a result, I get my process analysed by the Celonis Process Explorer:

Of course, this reveals the implemented logic that after two visits to the kitchen I must go to the bathroom and after fife visits to the lounge I go to the bedroom which also ends the process.

How cool is that?

Appendix

import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
import java.util.Properties;
import java.sql.Timestamp;
import java.util.Random;
public class Celonis {
 public static void main(String[] args) {
  try {
   Properties props = new Properties();
   props.put("bootstrap.servers", "kafka.server.com:6667");
   props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
   props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
   int day = 101;
   String step = "initial";
   int loo = 0;
   int sleep = 0;
   int wee = 1;
   int tired = 3;
   int days = 103;
   int rooms = 4;
   while (true) {
    Producer < String, String > producer = new KafkaProducer < > (props);
    Random rand = new Random();
    int x = rand.nextInt(rooms);
    boolean send = true;
    switch (x) {
     case 0:
      switch (step) {
       case "initial":
        step = "Hall";
        break;
       case "Bedroom":
        day++;
        if (day > days) {
         System.exit(0);
        }
        step = "Hall";
        loo = 0;
        sleep = 0;
        break;
       default:
        if (day > days) {
         System.exit(0);
        } else if (loo > wee) {
         loo = 0;
         step = "Bathroom";
        } else if (sleep > tired) {
         sleep = 0;
         step = "Bedroom";
        } else {
         send = false;
        }
      }
      break;
     case 1:
      switch (step) {
       case "initial":
        step = "Hall";
        break;
       case "Bedroom":
        day++;
        if (day > days) {
         System.exit(0);
        }
        step = "Hall";
        loo = 0;
        sleep = 0;
        break;
       case "Kitchen":
        send = false;
        break;
       default:
        if (day > days) {
         System.exit(0);
        } else if (sleep > tired) {
         sleep = 0;
         step = "Bedroom";
        } else {
         loo++;
         step = "Kitchen";
        }
      }
      break;
     case 2:
      switch (step) {
       case "initial":
        step = "Hall";
        break;
       case "Bedroom":
        day++;
        if (day > days) {
         System.exit(0);
        }
        step = "Hall";
        loo = 0;
        sleep = 0;
        break;
       case "Lounge":
        send = false;
        break;
       default:
        if (day > days) {
         System.exit(0);
        } else if (loo > wee) {
         loo = 0;
         step = "Bathroom";
        } else if (sleep > tired) {
         sleep = 0;
         step = "Bedroom";
        } else {
         sleep++;
         step = "Lounge";
        }
      }
      break;
     case 3:
      switch (step) {
       case "initial":
        step = "Hall";
        break;
       case "Bedroom":
        day++;
        if (day > days) {
         System.exit(0);
        }
        step = "Hall";
        loo = 0;
        sleep = 0;
        break;
       case "Study":
        send = false;
        break;
       default:
        if (day > days) {
         System.exit(0);
        } else if (loo > wee) {
         loo = 0;
         step = "Bathroom";
        } else if (sleep > tired) {
         sleep = 0;
         step = "Bedroom";
        } else {
         step = "Study";
        }
      }
      break;
     default:
      step = "error";
    }
    Timestamp timestamp = new Timestamp(System.currentTimeMillis());
    if (send) {
     producer.send(new ProducerRecord < String, String > ("celonis", Integer.toString(0), timestamp + "," + Integer.toString(day) + "," + step));
     producer.close();
    }
    Thread.sleep(10000);
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}
{
    "properties": {},
    "description": "",
    "processes": {
        "terminal1": {
            "component": "com.sap.util.terminal",
            "metadata": {
                "label": "Terminal",
                "x": 501.99999713897705,
                "y": 12,
                "height": 80,
                "width": 120,
                "ui": "dynpath",
                "config": {}
            }
        },
        "tostringconverter1": {
            "component": "com.sap.util.toStringConverter",
            "metadata": {
                "label": "ToString Converter",
                "x": 386.99999809265137,
                "y": 42,
                "height": 50,
                "width": 50,
                "config": {}
            }
        },
        "kafkaconsumer1": {
            "component": "com.sap.kafka.consumer2",
            "metadata": {
                "label": "Kafka Consumer",
                "x": 17,
                "y": 72,
                "height": 80,
                "width": 120,
                "config": {
                    "kafkaVersion": "0.10.1",
                    "connectionType": "connection management",
                    "connection": {
                        "configurationType": "Configuration Manager",
                        "connectionID": "Kafka"
                    },
                    "topics": "celonis"
                }
            }
        },
        "12multiplexer1": {
            "component": "com.sap.system.multiplexer.1-2",
            "metadata": {
                "label": "1:2 Multiplexer",
                "x": 201.99999904632568,
                "y": 72,
                "height": 80,
                "width": 120,
                "extensible": true,
                "config": {}
            }
        },
        "toblobconverter1": {
            "component": "com.sap.util.toBlobConverter",
            "metadata": {
                "label": "ToBlob Converter",
                "x": 386.99999809265137,
                "y": 132,
                "height": 50,
                "width": 50,
                "config": {}
            }
        },
        "formatconverter1": {
            "component": "com.sap.util.formatConverter",
            "metadata": {
                "label": "Format Converter",
                "x": 501.99999713897705,
                "y": 132,
                "height": 80,
                "width": 120,
                "config": {
                    "targetFormat": "CSV",
                    "fields": "millis,case,activity"
                }
            }
        },
        "writefile1": {
            "component": "com.sap.storage.write",
            "metadata": {
                "label": "Write File",
                "x": 686.9999961853027,
                "y": 72,
                "height": 80,
                "width": 120,
                "config": {
                    "service": "adl",
                    "adlConnection": {
                        "connectionProperties": {
                            "accountName": "",
                            "clientId": "",
                            "clientKey": "",
                            "rootPath": "",
                            "tenantId": ""
                        },
                        "configurationType": "Configuration Manager",
                        "connectionID": "architectIT"
                    },
                    "path": "celonis.csv"
                }
            }
        }
    },
    "groups": [],
    "connections": [
        {
            "metadata": {
                "points": "440.99999809265137,67 468.9999976158142,67 468.9999976158142,52 496.99999713897705,52"
            },
            "src": {
                "port": "outstring",
                "process": "tostringconverter1"
            },
            "tgt": {
                "port": "in1",
                "process": "terminal1"
            }
        },
        {
            "metadata": {
                "points": "141,103 168.99999952316284,103 168.99999952316284,112 196.99999904632568,112"
            },
            "src": {
                "port": "message",
                "process": "kafkaconsumer1"
            },
            "tgt": {
                "port": "in1",
                "process": "12multiplexer1"
            }
        },
        {
            "metadata": {
                "points": "325.9999990463257,103 353.9999985694885,103 353.9999985694885,76 381.99999809265137,76"
            },
            "src": {
                "port": "out1",
                "process": "12multiplexer1"
            },
            "tgt": {
                "port": "inmessage",
                "process": "tostringconverter1"
            }
        },
        {
            "metadata": {
                "points": "325.9999990463257,121 353.9999985694885,121 353.9999985694885,157 381.99999809265137,157"
            },
            "src": {
                "port": "out2",
                "process": "12multiplexer1"
            },
            "tgt": {
                "port": "ininterface",
                "process": "toblobconverter1"
            }
        },
        {
            "metadata": {
                "points": "440.99999809265137,157 468.9999976158142,157 468.9999976158142,172 496.99999713897705,172"
            },
            "src": {
                "port": "outbytearray",
                "process": "toblobconverter1"
            },
            "tgt": {
                "port": "input",
                "process": "formatconverter1"
            }
        },
        {
            "metadata": {
                "points": "625.999997138977,172 653.9999966621399,172 653.9999966621399,112 681.9999961853027,112"
            },
            "src": {
                "port": "output",
                "process": "formatconverter1"
            },
            "tgt": {
                "port": "inFile",
                "process": "writefile1"
            }
        }
    ],
    "inports": {},
    "outports": {}
}
2019-07-17 13:26:26.681,101,Hall
2019-07-17 13:26:41.426,101,Kitchen
2019-07-17 13:26:51.915,101,Study
2019-07-17 13:27:33.396,101,Lounge
2019-07-17 13:27:44.073,101,Study
2019-07-17 13:27:54.508,101,Kitchen
2019-07-17 13:28:05.133,101,Bathroom
2019-07-17 13:28:26.078,101,Lounge
2019-07-17 13:28:36.597,101,Kitchen
2019-07-17 13:29:17.647,101,Study
2019-07-17 13:29:28.142,101,Lounge
2019-07-17 13:29:48.718,101,Kitchen
2019-07-17 13:29:59.099,101,Bathroom
2019-07-17 13:30:19.857,101,Lounge
2019-07-17 13:30:40.437,101,Bedroom
2019-07-17 13:30:50.766,102,Hall
2019-07-17 13:31:01.103,102,Lounge
2019-07-17 13:31:41.928,102,Study
2019-07-17 13:32:02.468,102,Lounge
2019-07-17 13:32:13.2,102,Study
2019-07-17 13:32:23.674,102,Lounge
2019-07-17 13:32:34.045,102,Study
2019-07-17 13:32:54.425,102,Lounge
2019-07-17 13:33:04.803,102,Bedroom
2019-07-17 13:33:15.498,103,Hall
2019-07-17 13:33:26.129,103,Lounge
2019-07-17 13:33:56.836,103,Kitchen
2019-07-17 13:34:07.307,103,Study
2019-07-17 13:34:28.114,103,Lounge
2019-07-17 13:34:38.445,103,Kitchen
2019-07-17 13:34:58.875,103,Bathroom
2019-07-17 13:35:09.256,103,Kitchen
2019-07-17 13:35:19.94,103,Lounge
2019-07-17 13:35:30.497,103,Kitchen
2019-07-17 13:35:40.825,103,Bathroom
2019-07-17 13:35:51.227,103,Lounge
2019-07-17 13:36:01.546,103,Bedroom
1 Comment
You must be Logged on to comment or reply to a post.