IF you do DSPCMD RTVSYSVAL and put your cursor on “Where allowed to run” and do F1, you will find it is not allow to run in a batch job.
You create a CL program call that from within your RPG program to get the value OR you can change the command to include *EXEC as one of the parms for “Where allowed to run”
If you review the documentation for the RTVSYSVAL command you will find that it is only valid in CL programs or REXX procedures. There is no problem running the command in batch (which was suggested as being a problem in an earlier response). Your problem is that you’re trying to run the command out of a RPG program using QCMDEXC — which is not going to work. Among other things, there are no return variables supported when using QCMDEXC and you certainly need a return variable. As mentioned in another response, the RPG language provides more direct ways to access the system time.