Hi Ram,
You can define an internal table for storing the errors and exception. You can fill that internal table by checking the sy-subrc after the function is executed. The sy-subrc field will return the value referring to exception.
For eg.
NO_REFERENCE = 1
NO_DOCUMENT = 2
MANY_DOCUMENTS = 3
WRONG_INPUT = 4
OVERWRITE_CREDITCARD = 5
OTHERS = 6.
depending on the value stored in sy-subrc write a logic in CASE.. ENDCASE block and fill the internal table accordingly.
Hope this will help you.