You have some sort of syntax error (SQLCODE -104). Are you using ';' as statement delimiter or some other character? It must not be ';' because that is used inside the BEGIN ATOMIC ... END and the actual CREATE FUNCTION statement should use some other delimiter.
Aside from that, is this really your complete function? I'm asking because the function could easily be simplified.
- you use a loop and only pick v_fullname and abALPH from the last row that was fetched -> use a descending sorting and fetch the first row only (no loop needed)
- you could also use FETCH FIRST 1 ROW ONLY
- you have no ORDER BY in your query, so DB2 is free to return the rows in any arbitrary order -> your results are not predictable and can change from call to call
- I always try to avoid procedural processing; it makes the optimizer's job much harder to optimize the overall SQL statement in which you may use this function -> use set-oriented processing instead