You can retrieve the system name in a CL by executing the RTVNETA command, There is a parameter on this command named SYSNAME. You would define an 8 character variable and do the RTVNETA to get the system name into the variable.
If you are using SDA to define display files used in RPG programs, you can enter *SYSNAME on a screen format and press Enter. This will add a system name field to the screen. The operating system handles loading this value when the screen is displayed.