Example: Changing a user space with an OPM RPG program

This program changes the contents of information in the user area in the user space.

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

To change the user area of a user space with a call from an OPM RPG program, specify the following:

     H****************************************************************
     H****************************************************************
     H*                                                              *
     H*  PROGRAM:  CHANGUS                                           *
     H*                                                              *
     H*  LANGUAGE:  RPG                                              *
     H*                                                              *
     H*  DESCRIPTION:  THIS PROGRAM WILL CHANGE THE CONTENTS OF      *
     H*                INFORMATION IN THE USER AREA IN THE USER SPACE*
     H*                (FIRST 64 BYTES).                             *
     H*                                                              *
     H*  APIs USED:  QUSCHGUS                                        *
     H*                                                              *
     H****************************************************************
     H****************************************************************
     E                    ARY     1   1 20
     E                    CHG     1   1 64
     IUSRSPC      DS
     I                                        1  10 USNAME
     I                                       11  20 USLIB
     I            DS
     I                                    B   1   40LENDTA
     I                                    B   5   80STRPOS
     C*                                                              *
     C****************************************************************
     C****************************************************************
     C*                                                              *
     C*              OPERABLE CODE STARTS HERE                       *
     C*                                                              *
     C****************************************************************
     C****************************************************************
     C*                                                              *
     C* MOVE THE USER SPACE AND LIBRARY NAME FROM ARY ARRAY INTO THE *
     C* USRSPC DATA STRUCTURE.  ALSO, MOVE THE NEW USER DATA FROM    *
     C* CHG ARRAY INTO NEWVAL.                                       *
     C*                                                              *
     C                     MOVELARY,1     USRSPC
     C                     MOVELCHG,1     NEWVAL  64
     C*                                                              *
     C                     Z-ADD64        LENDTA           LEN OF USERAREA
     C                     Z-ADD1         STRPOS           STARTING POS
     C                     MOVE '1'       FORCE   1        FORCE PARM
     C*                                                              *
     C* CALL THE QUSCHGUS API WHICH WILL CHANGE THE USER AREA IN THE *
     C* USER SPACE.                                                  *
     C*                                                              *
     C                     CALL 'QUSCHGUS'
     C                     PARM           USRSPC
     C                     PARM           STRPOS
     C                     PARM           LENDTA
     C                     PARM           NEWVAL
     C                     PARM           FORCE
     C*                                                              *
     C* IF MORE OF THE USER SPACE NEEDS TO BE CHANGED, THIS PROGRAM  *
     C* COULD BE UPDATED TO LOOP UNTIL THE END OF THE ARRAY WAS      *
     C* REACHED.                                                     *
     C*                                                              *
     C                     SETON                     LR
     C                     RETRN
** ARY
TEMPSPACE QGPL
** CHG
Big String padded with blanks