Create User Space

CrtUsrSpace

The CrtUsrSpace procedure creates a *USRSPC (user space) object on the system.

The CrtUsrSpace procedure can be used to create a user space object on the system. The size, auto-extend attribute, and domain may be specified.

void  CrtUsrSpace(
 szUserSpace    21A    Const
 szExtAttr      10A    Const OPTIONS(*NOPASS : *OMIT) 
 nSize          10I 0  Const OPTIONS(*NOPASS : *OMIT)
 bAutoExt        1N    Const OPTIONS(*NOPASS : *OMIT)
 bReplace        1N    Const OPTIONS(*NOPASS : *OMIT) 
 szTextDesc     50A    Const OPTIONS(*NOPASS : *OMIT)
 nDomain        10I 0  Const OPTIONS(*NOPASS : *OMIT) 
)

See also: ChgUsrSpace, DltUsrSpace

Parameters

szUserSpace
[input Char(21) const]  This parameter consists of two parts (1) in the first 10 positions, the name of the user space being created, and (2) in the second 10 positions, the name of the library in which the user space is to be created.  For example:
 
 *...v....1....v....2
'MYSPACE   QTEMP     '
 

An alternative syntax is also supported for the user space parameter. The alternate syntax allows you to specify the user space name similar to that of an OS/400 CL command, that is it may be qualified using qualified name syntax, as follows:

 *...v....1....v....2
'QTEMP/MYSPACE       '
 

The qualified user space name is MYSPACE in the QTEMP library. Either syntax is acceptable.

 
szExtAttr [optional] DFT(XTOOLS)
[input Char(10) const]  The extended object attribute for the user space. This value appears on the various OS/400 DSPxxx commands under the Object Type value. If this parameter is not specified the value "XTOOLS" is used as the extended object attribute.
 
nSize  [optional] DFT(65535)
[input Int(4) const]  The initial size of the user space. The permissible values range from 1 to 16Meg. If this parameter is not specified 65535 is used. To create a user space with the maximum size use the named constant XT_US_MAXSIZE from the QCPYSRC(space) source member.
 
bAutoExt [optional] DFT(*ON)
[input Indy(1) const] An indicator that controls the auto extend attribute of the user space. If this value is set to *ON ('1') then the user space is automatically extended by the system when more space is needed by any of the APIs that write information to the user space. If *OFF ('0') is specified, the user space size if fixed and does not automatically extend as needed. To change the size of the user space use the QUSCUSAT API to modify the size of the user space.
 
bReplace [optional] DFT('1')
[input Indy(1) const] An indicator that controls whether or not the user space object is replaced by the CrtUsrSpace procedure if it already exists. A value of '1' causes the user space to be replaced, any other value does not replace the user space.
 
szTextDesc [optional] DFT(*BLANKS)
[input Char(50) const]  The object text for the user space.
 
nDomain [optional] DFT(0)
[input Indy(1) const] The domain control parameter indicates the domain in which the user space is created. The value choices are:
 
Named Constant Value Description
XT_CS_DFTDOM 0 The user space is created in the default domain based on the system setup. Typically this means it is created in the user domain.
XT_CS_USRDOM 1 The user space is created in the user domain.
XT_CS_SYSDOM 2 The user space is created in the system domain.

 If this parameter is not specified, the default is XT_CS_DFTDOM

Return Value

If the user space is created, *ON is returned, otherwise, *OFF is returned.

If the function fails, check the XT_ERROR data structure's subfield XT_ERRMsgID for the error message ID indicating why the user space was not created.

Example

Normally, the command and user space name are the only values that need to be specified. For example:

.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++
     D szUS            C                   Const('MYUSRSPC  QGPL')
     D szMyUs          C                   Const('FIELDLIST QTEMP')
.....CSRn01..............OpCode(ex)Extended-factor2+++++++++++++++++++++++++++
     C                   CallP     CrtUsrSpace(szUS)
     C                   CallP     CrtUsrSpace(szMyUS : *OMIT : XT_MAXUSRSPC)
     C                   CallP     CrtUsrSpace('QTEMP/MYSPACE')

The first call to CrtUsrSpace() creates a user space named MYUSRSPC in the QGPL library, using the defaults for size, extendibility and so on.

The second call to CrtUsrSpace() creates a user space named FIELDLIST in the QTEMP library and sizes it to the maximum allowed for a user space (currently 16 megabytes in length).

The third call to CrtUsrSpace() creates a user space named MYSPACE in the QTEMP library. Note the syntax for the user space name used in this example is in the traditional OS/400 CL command style of library/object. Both formats are supported.