Example in ILE RPG: Changing a user space
This ILE RPG program changes the user area of a user space using a pointer.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
H*****************************************************************
H*
H* PROGRAM: CHANGUSPTR
H*
H* LANGUAGE: ILE RPG for IBM i
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