This function returns one of the following values:
If the function returns any code other than AM_SUCCESS, the iteration will terminate and the same status code will be returned to the user.
If the parameters are invalid.