ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

get OS version of the iseries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • get OS version of the iseries

    Give this a test......... Original code came from Iseries network and I tweaked it a bit........



    PHP Code:
         h DFTACTGRP(*NO)  bnddir('QC2LE'Option(*SrcStmt: *NoDebugIO)


         
    d Date            s               d
         d Date1           s               d   inz
    (D'2004-07-01')
         
    d UsaDate         s              8  0

         d getversion      PR             6

         d atoll           pr            20i 0 extproc
    ('atoll')
         
    d  string                         *   value options(*string)

          /
    free


              
    if getversion() = 'V5R1M0';
              
    usaDate atoll(%char(date1: *usa0));
              else;
              
    date  = %date();
              
    usaDate = %int(%char(date : *usa0));
              endif;

             *
    inlr = *on;

          /
    end-free

          
    *------------------------------------------------
          * Use 
    QSZRTVPR API to get the current OS release
          
    *------------------------------------------------
         
    P getversion      B
         d getversion      PI             6A

         d ErrorCode       DS                  qualified
         d  BytesProv                    10I 0 INZ
    (0)
         
    d  BytesAvail                   10I 0 INZ(0)

         
    d PRDI0100        DS                  qualified
         d   ProdID                       7A   inz
    ('*OPSYS')
         
    d   version                      6A   inz('*CUR')
         
    d   ProdOpt                      4A   inz('0000')
         
    d   LoadID                      10A   inz('*CODE')

         
    d QSZRTVPR        PR                  extpgm('QSZRTVPR')
         
    d  RecVar                    32767A   options(*varsize)
         
    d  RecVarLen                    10I 0 const
         
    d  FormatName                    8A   const
         
    d  ProdInfo                           like(PRDI0100) const
         
    d  ErrCode                   32767A   options(*varsize)

         
    d PRDR0100        DS                  qualified
         d   BytesRtn                    10I 0
         d   BytesAval                   10I 0
         d                               10I 0
         d   ProdID                       7A
         d   version                      6A

          
    /free
               QSZRTVPR
    PRDR0100
                       
    : %size(PRDR0100)
                       : 
    'PRDR0100'
                       
    PRDI0100
                       
    ErrorCode );

               return 
    PRDR0100.version;
          /
    end-free
         P                 E 
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: get OS version of the iseries

    Here is how I get the OS level - I've just posted the programs as they are but I am sure you guys can figure it out..


    Code:
    /*           CRTCMD     CMD(MYLIB/MMOSLVL) +                      */
    /*                      PGM(QSYS/QSZRTVPR) +                       */
    /*                      SRCFILE(MYLIB/MYSRCF) +                    */
    /*                      SRCMBR(MMOSLVL) +                         */
    /*                      TEXT('QSZRTVPR RETRIEVE OS/400 INFO') +    */
    /*                      ALLOW( +                                   */
    /*                        *BPGM +                                  */
    /*                        *IPGM)                                   */
    
                 CMD        PROMPT('RETRIEVE OS LEVEL')
                 PARM       KWD(OSINFO) TYPE(*CHAR) LEN(105) +
                              RTNVAL(*YES) MIN(1) PROMPT('RETURNED +
                              OS/400 INFORMATION')
                 PARM       KWD(OSINFOLEN) TYPE(*INT4) CONSTANT(105)
                 PARM       KWD(FORMAT) TYPE(*CHAR) LEN(8) +
                              CONSTANT(PRDR0100)
                 PARM       KWD(PRDINFO) TYPE(*CHAR) LEN(27) +
                              CONSTANT('*OPSYS *CUR  0000*CODE')
                 PARM       KWD(ERRCOD) TYPE(*INT4) CONSTANT(0)
    Code:
                 PGM        PARM(&OUTPUT)
    
                 DCL        VAR(&OUTPUT) TYPE(*CHAR) LEN(6)
                 DCL        VAR(&SYSTEM) TYPE(*CHAR) LEN(8)
                 DCL        VAR(&SYSNAME) TYPE(*CHAR) LEN(8)
                 DCL        VAR(&PSYSNAME) TYPE(*CHAR) LEN(8)
                 DCL        VAR(&NETID) TYPE(*CHAR) LEN(8)
                 DCL        VAR(&MODEL)  TYPE(*CHAR) LEN(4)
                 DCL        VAR(&PROC)  TYPE(*CHAR) LEN(4)
                 DCL        VAR(&CSPLIB) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(1024)
                 DCL        VAR(&BAND )  TYPE(*CHAR) LEN(3)
    /* NEW VARS FOR OS LVL AND P BANDING */
                 DCL        VAR(&OSVAL) TYPE(*CHAR) LEN(105)
                 DCL        VAR(&RCVR) TYPE(*CHAR) LEN(64)
                 DCL        VAR(&RCVRLEN) TYPE(*CHAR) LEN(4) +
                              VALUE(X'00000040')
                 DCL        VAR(&RCVRFMT) TYPE(*CHAR) LEN(8) +
                              VALUE('LICR0200')
                 DCL        VAR(&PRDID) TYPE(*CHAR) LEN(17) +
                              VALUE('5769SS1V4R4M05050')
                 DCL        VAR(&PRDFMT) TYPE(*CHAR) LEN(8) +
                              VALUE('LICP0100')
                 DCL        VAR(&EC) TYPE(*CHAR) LEN(4) VALUE(X'00000000')
                 DCL        VAR(&PRCGRP) TYPE(*CHAR) LEN(3)
                 DCL        VAR(&OSPGM) TYPE(*CHAR) LEN(7)
                 DCL        VAR(&OSLVL) TYPE(*CHAR) LEN(6)
    /* END OF NEW VARS */
    
                 RTVDTAARA  DTAARA(CSPDA (48 10)) RTNVAR(&CSPLIB)
                 RTVSYSVAL  SYSVAL(QSRLNBR) RTNVAR(&SYSTEM)
                 RTVSYSVAL  SYSVAL(QMODEL) RTNVAR(&MODEL)
                 RTVNETA    SYSNAME(&SYSNAME) PNDSYSNAME(&PSYSNAME) +
                              LCLNETID(&NETID)
    /*                                                                            */
    /* MMOSLVL RETRIEVES OS/400 LEVEL INFO INTO THIS FIELD. WE'LL EXTRACT OS/400  */
    /*   PRODUCT ID, LEVEL AND FEATURE TO USE TO RETRIEVE LICENSE INFO...         */
    /*                                                                            */
                 MMOSLVL    OSINFO(&OSVAL)
                 CHGVAR     VAR(&PRDID) VALUE(%SST(&OSVAL 13 13) *CAT +
                              %SST(&OSVAL 30 4))
    /*                                                                            */
    /* CALL THE RETRIEVE LICENSE INFORMATION (QLZARTV) API...                     */
    /*                                                                            */
                 CALL       PGM(QLZARTV) PARM(&RCVR &RCVRLEN &RCVRFMT +
                              &PRDID &PRDFMT &EC)
    /*                                                                            */
    /* EXTRACT INDIVIDUAL ELEMENTS WANTED...                                      */
    /*                                                                            */
                 CHGVAR     VAR(&OSPGM) VALUE(%SST(&OSVAL 13 7))
                 CHGVAR     VAR(&OSLVL) VALUE(%SST(&OSVAL 20 6))
                 CHGVAR     VAR(&PRCGRP) VALUE(%SUBSTRING(&RCVR 48 3))
    
                 CALL       PGM(*LIBL/MMBAND) PARM(&MODEL &BAND &PROC)
    
                 IF         COND(&OUTPUT *EQ '*PRINT') THEN(DO)
                 CALL       PGM(WHERERPT) PARM(&SYSTEM &OSLVL &MODEL +
                              &PROC &PRCGRP &NETID &SYSNAME)
                 GOTO       CMDLBL(ENDPGM)
                 ENDDO
    
                 CHGVAR     VAR(&MSGDTA) VALUE('Maximise is loaded on +
                              system ' *BCAT &SYSNAME *BCAT 'in +
                              library' *BCAT &CSPLIB *BCAT 'on AS400 +
                              serial number' *BCAT &SYSTEM *BCAT +
                              'Model' *BCAT &MODEL *BCAT 'with +
                              processor feature' *BCAT &PROC *BCAT '+
                              and performance band ' *BCAT &PRCGRP *BCAT '+
                              . Local network ID' *BCAT &NETID *BCAT '. +
                              OS Level ' *BCAT &OSLVL)
                 IF         COND(&PSYSNAME *NE ' ') THEN(CHGVAR +
                              VAR(&MSGDTA) VALUE(&MSGDTA *BCAT 'Pending +
                              system name' *BCAT &PSYSNAME))
    
     ENDPGM:     ENDPGM

    Comment


    • #3
      Re: get OS version of the iseries

      Hey Chris..........Take a look here

      RTVDTAARA QSS1MRI (shhhhh.....its our little secret )
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: get OS version of the iseries

        But the long-winded and complicated way is sooooo much more fun

        Comment


        • #5
          Re: get OS version of the iseries

          what about this data area QRCLSTG
          Last edited by amar; February 11, 2009, 11:38 AM.

          Comment


          • #6
            Re: get OS version of the iseries

            Another way to get OS version number is using MI instruction MATMATR(materialize machine attributes) on a V5R4 box or later. The following examples demonstrate how to use MATMATR in an MI or in a RPG program.
            Example 1, use MATMATR in an MI program:
            Code:
            /**
             * @file getosver.mi
             *        
             * @param os-version, char(6)
             *
             * sample CL program to call program getosver:
             *   DCL        VAR(&OSVER) TYPE(*CHAR) LEN(6)
             *   CALL       PGM(GETOSVER) PARM(&OSVER)
             *   SNDPGMMSG  MSG(&OSVER) TOUSR(*REQUESTER) MSGTYPE(*INFO)
             */
            
            dcl spcptr .os-version parm	; 
            dcl ol plist-main(.os-version) parm ext ; 
            dcl dd os-version char(6) bas(.os-version) ; 
            
            entry *(plist-main) ext         ; 
            
            dcl dd mat-tmpl char(16) auto        ;
            dcl spcptr .mat-tmpl auto init(mat-tmpl) ; 
                    dcl dd bytes-in bin(4) def(mat-tmpl) pos(1) init(16) ; 
                    dcl dd bytes-available bin(4) def(mat-tmpl) pos(5) ; 
                    dcl dd lic-version char(6) def(mat-tmpl) pos(9) ; 
            
                    matmatr .mat-tmpl, x"020C" ; 
                      /* now `lic-version' would be something like:   'V5R4M0' */
                    cpybla os-version, lic-version ; 
            
                    brk 'RTN'               ; 
                    rtx *                   ; 
            pend                            ;
            Example 2, use MATMATR's bound program interface _MATMATR1 in a RPG program:
            Code:
            /**
             * @file RPGOSVER.RPGLE
             */
            h dftactgrp(*no)
            
            d matmatr_tmpl    ds
            d   bytes_in                    10i 0 inz(16)
            d   bytes_...
            d     available                 10i 0
            d   lic_version                  6a
            d   reserved                     2a
            
            d matmatr_opt     s              2a   inz(x'020C')
            
            c                   callb     '_MATMATR1'
            c                   parm                    matmatr_tmpl
            c                   parm                    matmatr_opt
            c     'OS VERSION'  dsply                   lic_version
            c                   seton                                          lr
            Regards!
            Junlei Li

            Comment


            • #7
              Re: get OS version of the iseries

              Another way: Check the mod notes from John Marchant (the reclen value for v5r4 is 3841 (this changes from version to version))
              Regards

              Kit
              http://www.ecofitonline.com
              DeskfIT - ChangefIT - XrefIT
              ___________________________________
              There are only 3 kinds of people -
              Those that can count and those that can't.

              Comment


              • #8
                Re: get OS version of the iseries

                Answer: CALL PGM(QSFWINV)

                (toggle F11 to see all informations including Keys)

                or for hardcopy

                CALL PGM(QSFWINV) PARM(*PRINT)

                This has the added advantage of showing your software keys and "P" group.

                This tip was submitted on another forum by Bryan Dietz. Thanks Bryan !

                Comment


                • #9
                  Re: get OS version of the iseries

                  what do you mean .... "another forum"
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: get OS version of the iseries

                    Can't you just ask the person who bought the system what version they installed?

                    Comment


                    • #11
                      Re: get OS version of the iseries

                      From: Scott Klement System iNEWS Technical Editor

                      I'd retrieve the version of the QCMD program thinking it'll always be the same as the OS/400 release. However, I was told by an IBMer that this is a bad idea.

                      The only IBM-supported way to get the release of the operating system is the QSZRTVPR API. Other methods may work, but may stop working without any notice, because IBM doesn't support them as programmatic ways to retrieve the release.

                      For example -- and this is purely theoretical, I don't know if this'll really happen -- IBM could come out with V5R5, but not make any changes to QCMD. It'd, therefore, they might decide to leave the release of QCMD at V5R4 even though the operating system is V5R5. Your code would then think the release is V5R4 even though it's actually newer than that...

                      The only officially supported IBM way is the QSZRTVPR API.

                      What I do is write a little CL program that calls the API and returns the release as a parameter.

                      Here's the code for that CL program:

                      Code:
                      PGM PARM(&RELEASE)
                      
                          DCL VAR(&RELEASE)  TYPE(*CHAR) LEN(6)
                          DCL VAR(&RCVVAR)   TYPE(*CHAR) LEN(32)
                          DCL VAR(&RCVLEN)   TYPE(*CHAR) LEN(4)
                          DCL VAR(&PRODINFO) TYPE(*CHAR) LEN(27)
                          DCL VAR(&ERRCODE)  TYPE(*CHAR) LEN(8)
                      
                          CHGVAR VAR(%BIN(&RCVLEN  1 4)) VALUE(32)
                          CHGVAR VAR(%BIN(&ERRCODE 1 4)) VALUE(0)
                      
                          CHGVAR VAR(%SST(&PRODINFO  1  7)) VALUE('*OPSYS')
                          CHGVAR VAR(%SST(&PRODINFO  8  6)) VALUE('*CUR'  )
                          CHGVAR VAR(%SST(&PRODINFO 14  4)) VALUE('0000'  )
                          CHGVAR VAR(%SST(&PRODINFO 18 10)) VALUE('*CODE' )
                      
                          CALL PGM(QSZRTVPR) PARM(&RCVVAR    +
                                                  &RCVLEN    +
                                                  'PRDR0100' +
                                                  &PRODINFO  +
                                                  &ERRCODE   )
                      
                          CHGVAR VAR(&RELEASE) VALUE(%SST(&RCVVAR 20 6))
                      
                      ENDPGM
                      Now, whenever I want to know the release of OS/400 from one of my programs, all I do is call the preceding CL program.

                      It's as simple as doing this:
                      Code:
                      CALL PGM(GETREL) PARM(&RELEASE)

                      Comment


                      • #12
                        Re: get OS version of the iseries

                        marc,

                        page up to the top of this thread......thats how all this got started..
                        how funny.....we hav come full circle grasshopper
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: get OS version of the iseries

                          Originally posted by Marc_d View Post
                          The only IBM-supported way to get the release of the operating system is the QSZRTVPR API. Other methods may work, but may stop working without any notice, because IBM doesn't support them as programmatic ways to retrieve the release.
                          The MI instruction MATMATR introduced since V5R4 returns the "Licensed Internal Code version release modification" with option hex 020C.
                          I do think the result returned by MATMATR is accurate enough on a V5R4 machine or later.
                          By the way, using this instruction will save many lines of code comparing to using the QSZRTVPR(retrieve product information) api.
                          e.g.
                          Code:
                          h dftactgrp(*no)
                          
                          d matmatr_tmpl    ds
                          d   bytes_in                    10i 0 inz(16)
                          d   bytes_...
                          d     available                 10i 0
                          d   lic_version                  6a
                          d   reserved                     2a
                          
                          d matmatr_opt     s              2a   inz(x'020C')
                          
                          c                   callb     '_MATMATR1'
                          c                   parm                    matmatr_tmpl
                          c                   parm                    matmatr_opt
                          c     'OS VERSION'  dsply                   lic_version
                          c                   seton                                          lr
                          Regards!
                          Junlei Li

                          Comment

                          Working...
                          X