May 15


Find the IBMi (iSeries AS400) Operating System Version in a RPGLE program

By NickLitten

May 15, 2022

Ever wanted to find your IBM i OS Version in RPG?

Following on from this old blog about how to find the OS version from a CL Program (and when I say OLD I mean from back in 2009, when I was still young and crispy.. as opposed to how I am now; old, wrinkled and generally dustier). I decided to quickly convert the same code into RPGLE.

Here is the same code concept (minus all over the old “If the OS is a version from 2004 then do this” bits) written in RPGLE, as a sub-procedure — so you could copy this into a *SRVPGM if you wanted:

// +------------------------------------------------------------------------+
// | rtn_IBMi_Version - RPGLE version of os and Return to calling program   |
// |                   Use QSZRTVPR API to get the current OS release       |
// +------------------------------------------------------------------------+
dcl-proc rtn_IBMi_Version export;
  dcl-pi rtn_IBMi_Version char(10) end-pi;

  dcl-s XPFPRDINF char(27) inz('*OPSYS *CUR  0000*CODE     ');
  dcl-s SLICPRDINF char(27) inz('XXXX999*XXXX 0000*CODE     ');

  dcl-pr RtvPrdInfo extpgm('QSZRTVPR');
    *n char(1) options(*varsize); // RecVar
    *n int(10) const; // RecVarLen
    *n char(8) const; // FormatName
    *n like(XPFPRDINF) const options(*varsize); // ProdInfo
    *n char(32000) options(*varsize); // ErrCode

  dcl-ds ErrorCode qualified;
    BytesProv int(10) inz(0);
    BytesAvail int(10) inz(0);

  dcl-s Receiver char(109);

  dcl-s XPFVRM char(6);
  dcl-s XPFLVL char(3);

  dcl-s SLICVRM char(6);
  dcl-s SLICLVL char(3);

  dcl-s rtnvalue char(10);

  // Retrieve IBM OS/400, IBM i5/OS or IBM i (XPF) Release Information
  RtvPrdInfo ( Receiver:

  XPFVRM = %SUBST(Receiver:20:6);
  XPFLVL = %SUBST(Receiver:106:3);

  %SUBST(SLICPRDINF:1:4) = %SUBST(Receiver:13:4);

  // Retrieve IBM System Licensed Internal Code (SLIC) Release Information
  RtvPrdInfo ( Receiver:

  SLICVRM = %SUBST(Receiver:20:6);
  SLICLVL = %SUBST(Receiver:106:3);


  Return RtnValue;


PS: Yes, I know I could have written this in many other ways, but I tried to make this as readable as possible for newbie IBM-i Programmers.

  • The link in “Following on from this old blog ” leads right back to this web page instead of to the old blog

  • If you want the OS Version/Release as a numeric values, such as 730 or 750, etc. you can use the following IBM built-in function to get that info. All the CEExxxx APIs are in-line code so they perform very fast. I use them when navigating code based on which release level the program is running.
    dcl-proc getOSVER export;
    dcl-pi getOSVER int(10) end-pi;

    dcl-ds FB_T Qualified Inz TEMPLATE;
    msgsev uns(5);
    msgno uns(5);
    flags char(1);
    Facility_ID char(3);
    Info uns(10);

    dcl-s osvrm int(10);
    dcl-s platform int(10);
    dcl-ds fb likeDS(FB_T) Inz(*LIKEDS);

    osRel int(10);
    platform int(10);
    fb likeDS(FB_T);

    CEEGPID(osvrm : platform : fb);

    return OSVRM;


  • dcl-s nam varchar(16);
    dcl-s ver varchar(4);
    dcl-s rls varchar(4);
    exec sql
    select os_name, os_version, os_release
    into :nam, :ver, :rls
    from sysibmadm.env_sys_info;
    dsply (nam + ‘:’ + ver + ‘.’ + rls) ‘*EXT’;

  • Other way to know the OS rel. is:
    SELECT substring(DATA_AREA_VALUE, 1, 8) FROM qsys2.data_area_info
    WHERE data_area_library = ‘QUSRSYS’ and data_area_name = ‘QSS1MRI’

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips