Take a look at the RTVSYSVAL command to retrieve a sysval.
You will need to DCL your variables before using them.
You can store data in a data area using CHGDTAARA and retrieve it using RTVDTAARA.
You can display the result using one of the SNDMSG, SNDPGMMSG, SNDBRKMSG or SNDUSRMSG commands.
There is plenty of help available on the commands – press the help key and you can read the info.