END FUNCTION expected - A FUNCTION block was not terminated with an associated END FUNCTION statement. It's likely you tried to start a new procedure block, without first terminating the current FUNCTION.