How to retrieve IBMi (iSeries AS400) operating system version in a CLP program

IBM i

Dec 16

There are lots of way of checking the operating system version on your IBM i Server. On your command line type DSPSFWRSC and with F11 you will see the Software Version of all the products installed on your iSeries. You could also use the DSPPTF command to show the current release as well as the current Cumulative PTF Package (SF99540).

Or you could write a a little something and using an IBM API the CLP code is very simple

Code:
IBMi (iSeries AS400) operating system versionDCL VAR(&VERSION) TYPE(*CHAR) LEN(6) 
DCL VAR(&RCVR) TYPE(*CHAR) LEN(128) 
DCL VAR(&RCVRLEN) TYPE(*CHAR) LEN(4) VALUE(X'00000080') 
DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) VALUE('PRDR0100') 
DCL VAR(&PRDINFO) TYPE(*CHAR) LEN(27) +
 VALUE('*OPSYS *CUR 0000*CODE ') 
DCL VAR(&APIERROR) TYPE(*CHAR) LEN(4) VALUE(X'00000000') 

CALL PGM(QSZRTVPR) PARM(&RCVR &RCVRLEN &FORMAT +
 &PRDINFO &APIERROR) 
 
CHGVAR VAR(&VERSION) VALUE(%SST(&RCVR 20 6)) 

SNDPGMMSG MSG('IBMi Version is' *bcat &RELEASE)

For example, on my little AS400e iSeries 270 eServer System i Power System running IBMi5.4 this will return a status message saying: » IBMi Version is V5R4M0

Follow

About the Author

IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.