29
Fri, Nov
0 New Articles

The API Corner: Saving Individual User Profiles

APIs
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Use the Save Object List API.

 

I was recently asked by Vasilis F. if there was a way to save specific user profiles from one system and then restore those profiles to one or more other systems. He had found the Restore User Profile (RSTUSRPRF) command, which allows you to restore from 1 to 300 specific profiles but, strangely enough, no Save User Profile command in order to save those specific profiles. Rather, the help text for RSTUSRPRF points to the Save System (SAVSYS) and Save Security Data (SAVSECDTA) commands, both of which are a bit of overkill when you just want to duplicate three user profiles (out of hundreds) to several other systems. Fortunately, the Save Object List (QSRSAVO) API supports, among many other capabilities, the saving of a specific list of user profiles.

To simplify the saving of the user profiles, we'll first create the command SAVUSRPRFS. Note that I am intentionally adding an "S" to the end of the command name so that, if IBM ever comes out with a SAVUSRPRF command, our command will (hopefully) not have a name conflict. The command definition is:

            Cmd        Prompt('Save User Profiles')        

            Parm       Kwd(UsrPrf) Type(*Name) +           

                         Min(1) Max(300) +                 

                         Prompt('User profiles')           

            Parm       Kwd(SavF) Type(QualObj) +           

                         Prompt('Save file')               

QualObj:    Qual       Type(*Name) Len(10) Dft(SavUsrPrfs) 

            Qual       Type(*Name) Len(10) Dft(*Libl) +    

                         SpcVal((*Libl) (*CurLib)) +       

                         Prompt('Library')                 

The command requires that you specify at least one user profile (*USRPRF) that is to be saved and allows up to 300 *USRPRFs. An optional second parameter on the command, SAVF, allows you to also specify the qualified name of a save file where the *USRPRF information will be saved. The default for this parameter is a save file named SAVUSRPRF that can be found in the job's current library list. The user of the SAVUSRPRFS command is responsible for creating this save file.

Assuming that you have stored the above command definition in source file QCMDSRC and that the library containing QCMDSRC is in your current library list, then you can create the SAVUSRPRFS command with the following command.

CrtCmd Cmd(SavUsrPrfs) Pgm(SavUsrPrf)

This creates the SAVUSRPRFS command into your current library and specifies that the command processing program (CPP) for the command is the program SAVUSRPRF. The source for the SAVUSRPRF CPP is shown below.

h dftactgrp(*no)                                                 

                                                                 

d SavUsrPrf       pr                                            

d  NbrPrfs_In                    5i 0                           

d  SavF_In                      20a                             

                                                                 

d SavUsrPrf       pi                                            

d  NbrPrfs_In                    5i 0                           

d  SavF_In                      20a                             

                                                                 

 **********************************************************     

                                                                 

d ChgUsrSpcA      pr                  extpgm('QUSCUSAT')        

d  RtnUsrSpcLib                 10a                             

d  QualUsrSpcN                  20a   const                     

d  UsrSpcAttrs                   1a   const options(*varsize)   

d  ErrCde                             likeds(QUSEC)             

                                                                 

d CrtUsrSpc       pr                  extpgm('QUSCRTUS')         

d  QualUsrSpcN                  20a   const                          

d  XAttr                        10a   const                          

d  IntSize                      10i 0 const                          

d  IntValue                      1a   const                          

d  PubAut                       10a   const                          

d  TxtDesc                      50a   const                          

d  ReplaceOpt                   10a   const options(*nopass)         

d  ErrCde                             likeds(QUSEC) options(*nopass) 

d  Domain                       10a   const options(*nopass)         

d  TfrSize                      10i 0 const options(*nopass)         

d  OptSpcAlgn                    1a   const options(*nopass)         

                                                                      

d FinishEntry     pr                                                 

                                                                      

d RtvUsrSpcPtr    pr                  extpgm('QUSPTRUS')             

d  QualUsrSpcN                  20a   const                          

d  UsrSpcPtr                      *                                  

d  ErrCde                             likeds(QUSEC) options(*nopass) 

                                                                      

d SavObjLst       pr                  extpgm('QSRSAVO')              

d  QualUsrSpcN                  20a   const                  

d  ErrCde                             likeds(QUSEC)          

                                                              

 **********************************************************  

                                                              

d UsrSpc_Ptr      s               *                          

d SRUS            ds                  likeds(QSRUS)          

d                                     based(UsrSpc_Ptr)      

                                                              

d SRR_Ptr         s               *                          

d SRR             ds                  likeds(QSRR)           

d                                     based(SRR_Ptr)         

                                                              

d ObjEntry_Ptr    s               *                          

d ObjEntryHdr     ds                  qualified              

d                                     based(ObjEntry_Ptr)    

d  Nbr                          10i 0                        

                                                              

d ObjEntry        ds                  qualified              

d                                     based(ObjEntry_Ptr)    

d  Name                         10a                          

d  Type                         10a                          

                                                              

d LibEntry_Ptr    s               *                          

d LibEntry        ds                  qualified              

d                                     based(LibEntry_Ptr)    

d  Nbr                          10i 0                        

d  Library                      10a                          

                                                              

d DevEntry_Ptr    s               *                          

d DevEntry        ds                  qualified              

d                                     based(DevEntry_Ptr)    

d  Nbr                          10i 0                        

d  Device                       10a                          

                                                              

d QualUsrSpcN     ds                  qualified              

d  Name                         10a   inz('SAVUSRPRFS')      

d  Library                      10a   inz('QTEMP')           

                                                              

d UsrSpcAttrs     ds                  qualified              

d  NbrAttrs                     10i 0 inz(1)                 

d  AutoXtndKey                  10i 0 inz(3)                 

d  LenKeyVal                    10i 0 inz(1)                 

d  AutXtndYes                    1a   inz('1')               

d                                3a                          

                                                              

d ErrCde          ds                  qualified              

d  Hdr                                likeds(QUSEC)          

d  MsgDta                      256a                          

                                                              

 **********************************************************  

                                                              

d AlignOn         s             10i 0 inz(4)                 

d Profile_Ptr     s               *                          

d Profile_In      s             10a   based(Profile_Ptr)     

d RtnUsrSpcLib    s             10a                          

d SavFEntry_Ptr   s               *                          

d SavFEntry       s             20a   based(SavFEntry_Ptr)   

d X               s             10i 0                        

                                                              

 **********************************************************

                                                            

 /copy qsysinc/qrpglesrc,qsr                               

 /copy qsysinc/qrpglesrc,qusec                             

                                                            

 /free                                                     

                                                            

  // Set Key 1 values (List of user profiles)              

                                                            

  SRR.QSRKNbr = 1;                                         

  SRR.QSRDL = %size(ObjEntryHdr) +                         

              (%size(ObjEntry) * NbrPrfs_In);              

                                                            

  ObjEntry_Ptr = SRR_Ptr + %size(SRR);                     

  ObjEntryHdr.Nbr = NbrPrfs_In;                            

                                                            

  for X = 1 to NbrPrfs_In;                                 

      if X = 1;                                             

         Profile_Ptr = %addr(NbrPrfs_In) +                 

                       %size(NbrPrfs_In);                  

         ObjEntry_Ptr += %size(ObjEntryHdr);         

      else;                                          

         Profile_Ptr += %size(Profile_In);           

         ObjEntry_Ptr += %size(ObjEntry);            

      endif;                                         

                                                      

      ObjEntry.Name = Profile_In;                     

      ObjEntry.Type = '*USRPRF';                     

  endfor;                                            

                                                      

  FinishEntry();                                  

                                                      

  // Set Key 2 values (Library)                      

                                                      

  SRR.QSRKNbr = 2;                                   

  SRR.QSRDL = %size(LibEntry);                        

  LibEntry_Ptr = SRR_Ptr + %size(SRR);               

  LibEntry.Nbr = 1;                                  

  LibEntry.Library = 'QSYS';                         

  FinishEntry();                                  

                                                       

  // Set Key 3 values (Device)                        

                                                       

  SRR.QSRKNbr = 3;                                    

  SRR.QSRDL = %size(DevEntry);                         

  DevEntry_Ptr = SRR_Ptr + %size(SRR);                

  DevEntry.Nbr = 1;                                   

  DevEntry.Device = '*SAVF';                          

  FinishEntry();                                   

                                                       

  // Set Key 4 values (Save file)                     

                                                       

  SRR.QSRKNbr = 4;                                    

  SRR.QSRDL = %size(SavFEntry);                       

  SavFEntry_Ptr = SRR_Ptr + %size(SRR);               

  SavFEntry = SavF_In;                                

  FinishEntry();                                   

                                                       

  // Perform the save                                  

                                                       

  SavObjLst(QualUsrSpcN :QUSEC);                              

                                                               

  *inlr = *on;                                                

  return;                                                     

                                                               

  begsr *inzsr;                                               

                                                               

    // Set API QUSEC parameter to send exceptions             

    QUSBPrv = 0;                                              

                                                               

    // Set API ErrCde parameter to not send exceptions        

    ErrCde.Hdr.QUSBPrv = %size(ErrCde);                       

                                                               

    RtvUsrSpcPtr(QualUsrSpcN :UsrSpc_Ptr :ErrCde);            

                                                               

    select;                                                   

       when ErrCde.Hdr.QUSBAvl = 0;                           

            // All is OK                                      

                                                               

       when ErrCde.Hdr.QUSEI = 'CPF9801';                     

            // UsrSpc not found, so create it                  

                                                                

            CrtUsrSpc(QualUsrSpcN :' ' :512                    

                      :x'00' :'*ALL' :'QSRSAVO input values'   

                      :'*YES' :QUSEC :'*DEFAULT' :0 :'1');     

                                                                

            // Set user space to autoextend yes                

                                                                

            ChgUsrSpcA(RtnUsrSpcLib :QualUsrSpcN               

                       :UsrSpcAttrs :QUSEC);                   

                                                                

            // Get accessibility to user space                 

                                                                

            RtvUsrSpcPtr(QualUsrSpcN :UsrSpc_Ptr :QUSEC);      

                                                                

       other;                                                  

            // Something seriously wrong. Send Escape           

                                                                

    endsl;                                                     

                                                                

    // Initialize current number of records                  

                                                             

    SRUS.QSRNbrR = 0;                                       

                                                             

    // Set SRR_Ptr to first record entry                    

                                                             

    SRR_Ptr = UsrSpc_Ptr + %size(SRUS);                     

                                                             

  endsr;                                                    

                                                             

 /end-free                                                  

                                                             

 ********************************************************** 

                                                             

p FinishEntry     b                                         

d FinishEntry     pi                                        

                                                             

 /free                                                       

                                                             

  if %rem(SRR.QSRDL :AlignOn) <> 0;                         

     SRR.QSRRL00 = %size(SRR) + SRR.QSRDL +                  

                   (AlignOn - %rem(SRR.QSRDL :AlignOn));     

  else;                                                      

     SRR.QSRRL00 = %size(SRR) + SRR.QSRDL;                   

  endif;                                                     

                                                              

  SRUS.QSRNbrR += 1;                                         

  SRR_Ptr += SRR.QSRRL00;                                    

                                                              

 /end-free                                                   

                                                              

p FinishEntry     e                                          

The QSRSAVO API, like many other APIs that support a wide range of options (in this case the various options/keywords found on various SAV* CL commands), uses a keyed approach with variable-length records. Each variable-length record starts with three fixed fields, which represent the length of the current record (used to locate the next variable-length record), the key of the current record, and the length of the data associated with the current key, respectively. A fourth field of the variable-length record then provides the data associated with the key. A key value of 1, for instance, is used to identify the objects and object types to be saved with the fourth field containing the list of objects to be saved. This corresponds (loosely) to the OBJ and OBJTYPE keywords of the SAVOBJ command. A key value of 11 is used to identify the target release for the save and corresponds to the TGTRLS keyword of the SAVOBJ command; a key value of 20 identifies whether or not the storage associated with various object types should be freed, corresponding to the STG keyword of the SAVOBJ command; and so on.

For the purposes of saving user profiles, we will be using the following keys:

 

  • 1The list of *USRPRFs to save (specified by the USRPRF keyword of the SAVUSRPRFS command)
  • 2The library where the *USRPRFs are found (QSYS)
  • 3The device to be used for the save operation (a *SAVF)
  • 4The qualified name of the *SAVF (specified by the SAVF keyword of the SAVUSRPRFS command)

 

Many system APIs would defined the parameter where you provide this keyed information as a variable length input parameterthat is, a parameter defined as type Char(*). Though not unique to the QSRSAVO API, QSRSAVO takes the approach of passing this keyed information in a user space (*USRSPC). The qualified name of the *USRSPC is the first parameter passed to QSRSAVO. This use of a *USRSPC (rather than just a parameter being passed by our program) could be handy if we wanted to save the same list of objects every night. In that case, we could format the *USRSPC once and then reference the *USRSPC every time we wanted to save the objects, thereby avoiding the need to reformat the *USRSPC contents every time we wanted to save the objects. In the case of our SAVUSRPRF CPP, we will create the *USRSPC into QTEMP as I don't see any need (with our sample program anyway) to retain the formatted contents of the *USRSPC). Another possible use of this *USRSPC, if you're careful about the key values used, is that the *USRSPC could be used as an input to the Restore Object List (QSRRSTO) API (though this reuse does not apply to our saving of *USRRPFs due to the need to later issue commands such as RSTUSRPRF and RSTAUT). The second parameter passed to the QSRSAVO API is the standard API error-code structure.

Before getting into the specifics of the SAVUSRPRF program, I want to point out that this program uses pointers extensively. If you have a phobia concerning pointersor worse, your company forbids the use of pointersthis implementation of the SAVUSRPRF program is most likely not for you. In this case, feel free to send me a note and I will provide a few other implementations of the programapproaches that do not require the use of pointers. These non-pointer-based implementations may not run as fast as the version provided above (note that this does not mean that they'll run like molasses, just that they will not run as fast), be as flexible, or, to my way of thinking anyway, be as "clean" to follow, but they will get the job done. The one thing I won't do is provide a fixed-form RPG implementation; that's just asking too much. J

The *INZSR subroutine of the SAVUSRPRF program is used to establish the environment for the mainline of the program. The processing found in the *INZSR is:

  • Initialize the QUSEC error-code data structure to return API errors as escape messages.
  • Initialize the ErrCde error-code data structure to not return API errors as escape messages but rather as structured feedback information that is available to the SAVUSRPRF program for recovery purposes.
  • Attempt, using the ErrCde error-code data structure, to access a space pointer to the *USRSPC QTEMP/SAVUSRPRFS using the Retrieve Pointer to User Space (QUSPTRUS) API. If successful, the pointer value is returned in variable UsrSpc_Ptr. This pointer addresses the first available byte of the *USRSPC.
  • If an error is encountered accessing the *USRSPC (that is, ErrCde.Hdr.QUSBAvl is not 0), then determine what the problem is:

 

 

      • If the error is related to the *USRSPC not being found (ErrCde.Hdr.QUSEI is CPF9801), then create the *USRSPC using the Create User Space (QUSCRTUS) API, use the Change User Space Attributes (QUSCUSAT) API to set the *USRSPC to being auto-extendable as we don't know how big a *USRSPC we need (we could figure it out, but it's so much easier to just let the system automatically grow the *USRSPC to the size we need), and then attempt again to access a pointer to the *USRSPC using QUSPTRUS. In these calls to QUSCRTUS, QUSCUSAT, and QUSPTRUS, we use the QUSEC error-code data structure so that any errors encountered here will be returned as escape messages.

 

      • If the error is not related to the *USRSPC not being found, then, though not shown, the program should send an escape message to the user, reporting what the problem is. This sending of an escape message can be found in many earlier "API Corner" programs (see "More on Sending Messages from an Application Program" for one article that discusses this).

 

  • Initialize the variable SRUS.QSRNbrR to 0. Per the documentation for the QSRSAVO API, the first four bytes of the *USRSPC are used to tell the API how many variable-length records are to be processed within the *USRSPC. The variable SRUS.QSRNbrR is defined as a 4-byte integer based on the pointer UsrSpc_Ptr and, as UsrSpc_Ptr is addressing the first byte of the *USRSPC, we are indicating that there are currently 0 variable-length records.
  • Initialize the pointer variable SRR_Ptr to where the next (in the current case, also the first) variable-length record will start. This is done by taking the value of UsrSpc_Ptr and adding to it the size of variable SRUS.QSRNbrR.

 

Having completed the preparatory work in setting our environment, the main line of SAVUSRPRF builds the various variable-length records, defining what we want to save and where we want to save it. The first record we will format is the list of the user profiles that we want to save. This is done by formatting a variable-length record with a key value of 1.

As mentioned previously, all of the variable-length records have a common header defining three fields: the length of the current record, the key of the current record, and the length of the data associated with the current record's key. This common definition can be found in QSYSINC/QRPGLESRC include member QSR as data structure QSRR. The SAVUSRPRF program defines the data structure SRR as being LikeDS(QSRR) and based on the pointer variable SRR_Ptr. As SRR_Ptr was previously set, in the *INZSR subroutine, to the location of the "next" variable-length record, SAVUSRPRF can simply start formatting this record by setting the key number (SRR.QSrKNbr) to 1 and the data length associated with the key (SRR.QSRDL) to the appropriate length. In reviewing the API documentation, we see that the data associated with key 1 is comprised of two items. The first is a 4-byte integer indicating how many objects are provided in the list of objects to be saved, and the second is the actual list of objects to be saved. Each object entry is 20 bytes in length with the first 10 bytes being an object name, a generic object name, or the special value *ALL; and the second 10 bytes being an object type or a special value. With this information, we can set the data length for key 1 by summing the length of the 4-byte integer representing the number of objects being saved and the size of the object list in bytes. The byte size of the object list can be determined by multiplying the number of user profiles specified by the user (NbrPrfs_In) by the size of each user profile entry (20 bytes or, as shown in the program to avoid hard coding the value 20, %size(ObjEntry)).

In case you are wondering how NbrPrfs_In was set to the number of user profiles specified by the user, it's a function of how we defined the SAVUSRPRFS command. The USRPRF keyword is defined as being a list parameter of Type(*Name) so the system, by default, will pass the list to the CPP as a 2-byte integer count of the number of list entries specified, immediately followed by that number of 10-byte list entries. Reviewing the prototype and procedure interface of SAVUSRPRF, you'll see that NbrPrfs_In is defined as a 2-byte integer being passed as the first parameter to the program and represents the start of the SAVUSRPRFS's USRPRF list.

Having set two of the three variables defined in the SRR header (the third element we'll set in just a bit during procedure FinishEntry() processing), SAVUSRPRF now formats the actual data associated with key 1. We previously saw that the first item associated with key 1 is the number of variable-length entries. As this item immediately follows the SRR header, SAVUSRPRF sets variable ObjEntry_Ptr to the start of the current SRR structure (SRR_Ptr) plus the size of the SRR structure. Variable ObjEntryHdr.Nbr, which is based on ObjEntry_Ptr, is then set to the value of NbrPrfs_In. Following this, the list of user profiles is loaded by way of a FOR loop that is run NbrPrfs_In times.

On the first iteration of the FOR group (X is equal to 1):

 

  • Profile_Ptr is set to address the first *USRPRF name specified by the user of the SAVUSRPRFS command. This is done by taking the address of NbrPrfs_In and adding the size of NbrPrfs_In.
  • ObjEntry_Ptr is set to address the location of the first object entry to be passed to the QSRSAVO API. This is done by taking the current value of ObjEntry_Ptr (which is pointing to the number of objects to be saved, ObjEntryHdr.Nbr) and adding the size of ObjEntryHdr.
  • The user profile name addressed by Profile_Ptr is then copied to the location addressed by ObjEntry_Ptr, the object type is set to the special value '*USRPRF', and the next iteration of the FOR group is run.

 

In these subsequent iterations (X is not equal to 1):

 

  • Profile_Ptr is set to address the next *USRPRF name specified by the user of the SAVUSRPRFS command. This is done by taking the current value of Profile_Ptr and adding the size of the profile just processed (%size(Profile_In)).
  • ObjEntry_Ptr is set to address the location of the next object entry to be passed to the QSRSAVO API. This is done by taking the current value of ObjEntry_Ptr and adding the size of the ObjEntry just processed (%size(ObjEntry)).
  • The user profile name addressed by Profile_Ptr is then copied to the location addressed by ObjEntry_Ptr, the object type is set to the special value '*USRPRF', and the next iteration of the FOR group is run.

 

When all *USRPRF names have been copied to the list of objects to be saved. then procedure FinishEntry() is run.

The FinishEntry procedure accomplishes a few common tasks. The first task is related to performance.

In reviewing the documentation for the QSRSAVO API. you may have noticed the following note related to the variable-length records passed to the API:

It is recommended, but not required, to align each variable length record on a 4-byte boundary. That is, you should make the length of each variable length record a multiple of 4, even if the data length is not a multiple of 4.

The first addressable byte of a *USRSPC is always aligned on a 4-byte boundary (for that matter, it's also on a 16-byte boundary in case you ever need to align pointers in a *USRSPC), so the first operation done in FinishEntry() is to determine if the length of the current variable-length record is a multiple of 4 (variable AlignOn). If not currently a multiple of 4 (that is, %rem(SRR.QSRDL :AlignOn) is not equal to 0), FinishEntry() determines how many bytes are needed in order to make the current record length a multiple of 4 so that subsequent records will also start on a 4-byte boundary. This padded length is what is then written to the length of the current record (SRR.QSRRL00). If the current length is already a multiple of 4, then the current length is written to SRR.QSRRL00.

The other two tasks of FinishEntry() are similar to the last two tasks done in the *INZSR subroutine in order to prepare the environment for the adding of variable-length records. FinishEntry() records that another variable-length record has been written to the *USRSPC (SRUS.QSRNbrR += 1) and then sets SRR_Ptr to the starting location of the next (if any) variable-length record. We're now ready to start formatting another variable-length record to pass to the QSRSAVO API.

Using the same general approach as was done for key 1, SAVUSRPRF now formats the variable-length records for keys 2, 3, and 4 (where you might notice a certain pattern being repeated for each record):

          Key 2:

  • Set SRR.QSRKNbr to the value of 2, indicating a library entry.

  • Set SRR.QSRDL to the size of a library entry (%size(LibEntry)).

  • Set LibEntry_Ptr to the first byte following the SRR structure (SRR_Ptr + %size(SRR)).

  • Record the number of libraries (LibEntry.Nbr = 1).

  • Record the name of the library (LibEntry.Library = 'QSYS').

  • Run the FinishEntry() procedure to prepare for the next variable-length entry.

     

    Key 3:

     

  • Set SRR.QSRKNbr to the value of 3, indicating a device entry.

  • Set SRR.QSRDL to the size of a device entry (%size(DevEntry)).

  • Set DevEntry_Ptr to the first byte following the SRR structure (SRR_Ptr + %size(SRR)).

  • Record the number of devices (DevEntry.Nbr = 1).

  • Record the type of device (DevEntry.Device = '*SAVF').

  • Run the FinishEntry() procedure to prepare for the next variable-length entry.

          Key 4:

  • Set SRR.QSRKNbr to the value of 4, indicating a *SAVF entry.

  • Set SRR.QSRDL to the size of a *SAVF entry (%size(SavFEntry)).

  • Set SavFEntry_Ptr to the first byte following the SRR structure (SRR_Ptr + %size(SRR)).

  • Record the *SAVF qualified name that was passed to the program as the second parameter (SavF_In).

  • Run the FinishEntry() procedure to prepare for the next variable-length entry.

    Having successfully formatted the four variable-length records defining what profiles to save and where to save them, the QSRSAVO API is then called using the QUSEC error-code structure so that any error encountered while saving the *USRPRFs will be returned as an escape message. Assuming no error was found, the SAVUSRPRF program then ends and you can move the *SAVF to the system(s) where you want to restore the *USRPRFs.

Assuming that you have stored the above program source in source file QRPGLESRC and that the library containing QRPGLESRC is in your current library list, then you can create the SAVUSRPRF program with the following command.

CrtBndRPG Pgm(SavUsrPrf)    

To save *USRPRFs One, Two, and Three, you can now use the following commands to create a *SAVF and save those user profiles.     

CrtSavF File(SavUsrPrfs)

SavUsrPrfs UsrPrf(One Two Three)

After moving the SAVUSRPRFS *SAVF to a target system where you want to restore the *USRPRFs, you can run a command such as this:

RstUsrPrf Dev(*SavF) UsrPrf(One Two Three) SavF(SavUsrPrfs)  

When running the RSTUSRPF, keep in mind that you may, or may not, want to override the defaults for RSTUSRPRF parameters, such as Security data (SECDTA) and Allow object differences (ALWOBJDIF).

To restore the private authorities associated with one of the *USRPRFsfor instance, profile THREEyou will also want to run the RSTAUT command as in:

   

RstAut UsrPrf(Three) 

Today we've seen how to save specific user profiles and then restore them to a system. More importantly, we've also seen how to work with an API that uses variable-length records as inputs to its processing. There are many such APIs, with QSRSAVO being just one example, so it's my hope that you will find this article to be of assistance in other endeavors involving system APIs.

As usual, if you have any API questions, send them to me at This email address is being protected from spambots. You need JavaScript enabled to view it.. I'll see what I can do about answering your burning questions in future columns.

 

Bruce Vining

Bruce Vining is president and co-founder of Bruce Vining Services, LLC, a firm providing contract programming and consulting services to the System i community. He began his career in 1979 as an IBM Systems Engineer in St. Louis, Missouri, and then transferred to Rochester, Minnesota, in 1985, where he continues to reside. From 1992 until leaving IBM in 2007, Bruce was a member of the System Design Control Group responsible for OS/400 and i5/OS areas such as System APIs, Globalization, and Software Serviceability. He is also the designer of Control Language for Files (CLF).A frequent speaker and writer, Bruce can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it.. 


MC Press books written by Bruce Vining available now on the MC Press Bookstore.

IBM System i APIs at Work IBM System i APIs at Work
Leverage the power of APIs with this definitive resource.
List Price $89.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: