Hi @Heiko ,
I recommend checking out this post:
It includes an example of parsing the step return and building the channel pattern for custom error handling.
Edit:
Upon second look at your code, it looks like you are missing the ErrGetDataAt function to pull your step return from an error state.
Assuming you are using cancel automatic error handling to trigger the Error Handling by the user, you need to add the ErrGetDataAt function from the HSLErrLib to populate the l_ChannelNumber variable. The step return does not get populated if the step uses a cancel as the recovery.

