Instaed of IF i_messtab NE 0.
write
If not IF i_messtab[] IS INITIAL.
for some standard error message you will not get the error text directly into the message but it gives you with Message class and Message Number.
based on that you need to get the Error text from T100 table or we have some standard FM to read the Message from message class.
Let me know if there are any issues.