Before calling any of the REXX Twain functions, you must first load the DLL (RXTWAIN.DLL) using a LIBRARY statement. Here's an example:
LIBRARY rxtwain
After loading/registering the Twain functions, you need to call TwainInit to initialize REXX Twain. Before calling any other Twain functions, you also need to call TwainOpenDSM to open the Data Source Manager. You need do the above once only, so a good place to do this is at the beginning of your script.