There are at least three things you’re missing here.
<li>The CREATE PROCEDURE statement is missing.</li><li>The CREATE FUNCTION statement is missing.</li><li>The statements that work and don’t work are missing.</li>
Without those, there’s not much anyone can add to what you wrote above. You need to show us the statements in order for us to make more than random guesses. Post them in the ‘Discussion’ area below. At the least, someone might be able see from them that there are other things you also need to post — library structure, RPG creation parameters, authorities…