Hi. I'm relatively new to free form RPG and I rewrote a program to be RPG free and SQL. I'm having problems with my where clause. I'm trying to substring the second byte on a 2 digit packed field. I've tried to use the CAST statement to convert the packed field to CHAR and then do the SUBSTRING on it. When it runs in the program I get sqlstt = 22023 and sqlcode = -802. When I try to run the sql statement separately interactively, I get "Selection error involving field *N. " and in the joblog I get "Select or omit error on field Cast(SFAM_1.SPRPID AS Char(1) CCSID 37) member SFAMLNR." It appears to be a problem with my CAST statement, but I can't figure out what is wrong. Any help would be greatly appreciated. Thanks!!