<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Changing a user space with an ILE RPG program" />
<meta name="abstract" content="This example changes the contents of information in the user area in the user space using a pointer." />
<meta name="description" content="This example changes the contents of information in the user area in the user space using a pointer." />
<meta name="DC.Relation" scheme="URI" content="listChangeUser.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="exampleusilerpg" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Changing a user space with an ILE RPG program</title>
</head>
<body id="exampleusilerpg"><a name="exampleusilerpg"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Changing a user space with an ILE RPG program</h1>
<div><p>This example changes the contents of information in the user area
in the user space using a pointer.</p>
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important
legal information.</div>
<p>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:</p>
<pre>
     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
</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="listChangeUser.htm" title="These examples illustrate how a user space can be changed.">Examples: Change a user space</a></div>
</div>
</div>
</body>
</html>