Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

Overview

Related to my NetWeaver BPM 7.20: Enhanced task notification, I asked the way to get timestamp as unique value in BPM. This blog shows how to get timestamp by using built-in mapping functions, hence you don't need to write any java codes.

 

Sample Process

Here is an example process which has two data objects. "StartDateTime" is string, "TaskKey" is long type. Both objects intend to store timestamp.

Mapping is below.

 

Current dateTime as string

NetWeaver BPM 7.20 has built-in mapping function "current-dateTime()", it returns current timestamp in xsd:dateTime format. And it can be cast to xsd:string. String is easy to be used in mapping and task parameters.

Here is the mapping expression below.

string(current-dateTime())

At runtime, "StartDateTime" holds timestamp in xsd:dateTime format.

Current dateTime as UNIX time

Let's make one more hack. You can get current timestamp in UNIX time as long integer. UNIX time means erapsed time since 1970-01-01. It can be millisecond scale on Java systems.

You can use "subtract-dateTimes-as-milliseconds()" build-in function, it returns difference of two dateTime objects in millisecond scale. You can get current UNIX time by subtracting zero from current time. As described above, UNIX zeto time is 1970-01-01.

subtract-dateTimes-as-milliseconds(current-dateTime(), dateTime("1970-01-01"))

You can see such result at runtime.

Note

Strictly, timestamps are not unique value because multiple process instances can be started at same time. But timestamps will rarely conflict in millisecond scale, so it will not be serious problem in actual use.

You should consider timestamp confliction on implementing large or high volume systems.


Enjoy,
Hiro

1 Comment