Longest Consecutive Subsequence in ABAP

Suppose we have an array of integers. We have to find the length of the longest consecutive elements sequence. So if the input is like [100, 4, 250, 1, 3, 2,101], answer will be 4, as the longest consecutive sequence is [1,2,3,4].