With the CPYF, you just need a CL program that receives your data as a parm.
Then use (assuming this is an externally defined file) you use the inputted parm in the INCREL option of the CPYF command.
With the SQL, it is the same thing.
If you do not have a Command to run an SQL statement in a CL program, you can download one off the net. Or you can have an RPG program that does the SQL statement and receives the data as a parm, Or you can build the source for a RUNSQL command using the inputted date.