Hi,
Why don't you use counter function?
Standard Functions in PI 7.0 - Process Integration - SCN Wiki
If your requirement is to generate sequence number externally then have a look at the below blogs
Sequence Numbers and Counters: Stuck in a world of Workarounds?