Example: Changing a user space with an ILE RPG program

This example changes the contents of information in the user area in the user space using a pointer.

Note: Read the Code license and disclaimer information for important legal information.

To change the user area of a user space as shown in the previous example with a call from an ILE RPG program, specify the following:

     H*****************************************************************
     H*
     H* PROGRAM: CHANGUSPTR
     H*
     H* LANGUAGE: ILE RPG for i5/OS
     H*
     H* DESCRIPTION: CHANGE THE CONTENTS OF INFORMATION IN THE USER
     H*              AREA IN THE USER SPACE USING A POINTER
     H*
     H*****************************************************************
     D*
     DUSRSPCNAM        S             20    INZ('TEMPSPACE QTEMP     ')
     DNEWVALUE         S             64    INZ('Big String padded with blanks')
     DUSRSPCPTR        S               *
     DUSERAREA         DS                  BASED(USRSPCPTR)
     D CHARFIELD               1     64
     D*
     D* Following QUSEC structure copied from QSYSINC library
     D*
     DQUSEC            DS
     D*                                             Qus EC
     D QUSBPRV                 1      4B 0
     D*                                             Bytes Provided
     D QUSBAVL                 5      8B 0
     D*                                             Bytes Available
     D QUSEI                   9     15
     D*                                             Exception Id
     D QUSERVED               16     16
     D*                                             Reserved
     D* End of QSYSINC copy
     D*
     C*
     C* Initialize Error code structure to return error ids
     C*
     C                   Z-ADD     16            QUSBPRV
     C*
     C* Set USRSPCPTR to the address of the user space
     C*
     C                   CALL      'QUSPTRUS'
     C                   PARM                    USRSPCNAM
     C                   PARM                    USRSPCPTR
     C                   PARM                    QUSEC
     C*
     C* Check for successful setting of pointer
     C*
     C     QUSBAVL       IFGT      0
     C*
     C* If an error, then display the error message id
     C*
     C                   DSPLY                   QUSEI
     C                   ELSE
     C*
     C* Otherwise, update the user space via the based structure
     C*
     C                   MOVEL     NEWVALUE      USERAREA
     C                   END
     C*
     C* And return to our caller
     C*
     C                   SETON                                       LR
     C                   RETURN