IBM Books

Reference


String Functions

The following functions are the set of standard string functions that Net.Data supports:

MBCS support for OS/390, OS/2, Windows NT, and UNIX: You can specify multiple-byte character set (MBCS) support for word and string functions with the DTW_MBMODE configuration value. Specify this value in the Net.Data initialization file; the default is no support. You can override the value in the initialization file by setting the DTW_MBMODE variable in a Net.Data macro. See the configuration variable section in Net.Data Administration and Programming Guide and DTW_MBMODE for more information.

MBCS support for OS/400: DBCS support is provided automatically and does not require this variable.

DTW_ASSIGN


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Assigns a value to a variable.

Format

@DTW_ASSIGN(stringOut, stringIn)

Parameters

Table 73. DTW_ASSIGN Parameters

Data Type Parameter Use Description
string stringOut OUT A variable that contains the literal string identical to stringIn.
string stringIn IN A variable or literal string.

Return Codes

Table 74. DTW_ASSIGN Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_ASSIGN(RC, "0")

Example 2:

@DTW_ASSIGN(string1, string2)

DTW_CHARTOHEX


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT





X


Purpose

Converts each character in a string to two hexadecimal characters.

Format

@DTW_CHARTOHEX(stringIn, stringOut)

@DTW_rCHARTOHEX(stringIn)

Parameters

Table 75. DTW_CHARTOHEX Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string that is to be converted.
string stringOut OUT A variable that contains stringIn represented in hexadecimal format.

Return Codes

Table 76. DTW_CHARTOHEX Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Usage Notes

Each hexadecimal character represents 4-bits of the input character (a character is represented by 8 bits).

Examples

Example 1: EBCDIC operating systems

@DTW_rCHARTOHEX("12345")

Example 2: ASCII operating systems

@DTW_rCHARTOHEX("12345")

DTW_CONCAT


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Concatenates two strings.

Format

@DTW_CONCAT(stringIn1, stringIn2, stringOut)

@DTW_rCONCAT(stringIn1, stringIn2)

Parameters

Table 77. DTW_CONCAT Parameters

Data Type Parameter Use Description
string stringIn1 IN A variable or literal string.
string stringIn2 IN A variable or literal string.
string stringOut OUT A variable that contains the string 'stringIn1stringIn2', where string1 is concatenated with string2.

Return Codes

Table 78. DTW_CONCAT Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_CONCAT("This", " is a test.", result)

Example 2:

@DTW_CONCAT(string1, "1-2-3", result)

Example 3:

@DTW_rCONCAT("This", " is a test.")

DTW_DELSTR


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Deletes a substring of a string from the nth character for length characters.

Format

@DTW_DELSTR(stringIn, n, length, stringOut)

@DTW_DELSTR(stringIn, n, stringOut)

@DTW_rDELSTR(stringIn, n, length)

@DTW_rDELSTR(stringIn, n)

Parameters

Table 79. DTW_DELSTR Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The position of the character at which the substring to delete begins. If n is greater than the length of stringIn, stringOut is set to the value of stringIn.
integer length IN The length of the substring to delete. The default is to delete all characters to the end of stringIn.
string stringOut OUT A variable that contains the modified form of stringIn.

Return Codes

Table 80. DTW_DELSTR Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1002 An input parameter contained a string value which consisted of the null-terminating character.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_DELSTR("abcde", "3", "2", result)

Example 2:

@DTW_rDELSTR("abcde", "4", "1")

DTW_HEXTOCHAR


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT





X


Purpose

Converts each hexadecimal character in a string to a character value.

Format

@DTW_HEXTOCHAR(stringIn, stringOut)

@DTW_rHEXTOCHAR(stringIn)

Parameters

Table 81. DTW_HEXTOCHAR Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string that is to be converted.
string stringOut OUT A variable that contains stringIn represented in character format.

Return Codes

Table 82. DTW_HEXTOCHAR Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Usage Notes

Each hexadecimal character in the input string represents 4 bits in the resultant character string (a character is represented by 8 bits). The input string must contain an even number of hexadecimal characters and can contain the following characters: 0-9, A-F, and a-f.

Examples

Example 1: EBCDIC operating systems

@DTW_rHEXTOCHAR("F0F1F2")

Example 2: ASCII operating systems

@DTW_rHEXTOCHAR("303132")

DTW_INSERT


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Inserts a string into another string starting after the nth character.

Format

@DTW_INSERT(stringIn1, stringIn2, n, length, pad, stringOut)

@DTW_INSERT(stringIn1, stringIn2, n, length, stringOut)

@DTW_INSERT(stringIn1, stringIn2, n, stringOut)

@DTW_INSERT(stringIn1, stringIn2, stringOut)

@DTW_rINSERT(stringIn1, stringIn2, n, length, pad)

@DTW_rINSERT(stringIn1, stringIn2, n, length)

@DTW_rINSERT(stringIn1, stringIn2, n)

@DTW_rINSERT(stringIn1, stringIn2)

Parameters

Table 83. DTW_INSERT Parameters

Data Type Parameter Use Description
string stringIn1 IN A variable or literal string to be inserted into stringIn2.
string stringIn2 IN A variable or literal string.
integer n IN The character position in stringIn2 after which stringIn1 is inserted. If n is greater than the length of stringIn2, it is padded with the padding character, pad, until it has enough characters. The default is to insert at the beginning of stringIn2.
integer length IN The number of characters of stringIn1 to insert. The string is padded with the padding character, pad, if this parameter is greater than the length of stringIn1. The default is the length of stringIn1.
integer pad IN The padding character, as described for n and length. The default pad character is a blank.
string stringOut OUT A variable that contains stringIn2 modified by inserting part or all of stringIn1.

Return Codes

Table 84. DTW_INSERT Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_INSERT("123", "abc", result)

Example 2:

@DTW_INSERT("123", "abc", "5", result)

Example 3:

@DTW_INSERT("123", "abc", "5", "6", result)

Example 4:

@DTW_INSERT("123", "abc", "5", "6", "/", result)

Example 5:

@DTW_rINSERT("123", "abc", "5", "6", "+")

DTW_LASTPOS


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the position of the last occurrence of a string in another string, starting from the nth character and working backwards (right to left).

Format

@DTW_LASTPOS(stringIn1, stringIn2, n, position)

@DTW_LASTPOS(stringIn1, stringIn2, position)

@DTW_rLASTPOS(stringIn1, stringIn2, n)

@DTW_rLASTPOS(stringIn1, stringIn2)

Parameters

Table 85. DTW_LASTPOS Parameters

Data Type Parameter Use Description
string stringIn1 IN A variable or literal string searched for in stringIn2.
string stringIn2 IN A variable or literal string.
integer n IN The character position in stringIn2 to begin searching for stringIn1. The default is to start searching at the last character and scan backwards (from right to left).
integer position OUT The position of the last occurrence of stringIn1 in stringIn2. If no occurrence is found, 0 is returned.

Return Codes

Table 86. DTW_LASTPOS Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_LASTPOS(" ", "abc def ghi", result)

Example 2:

@DTW_LASTPOS(" ", "abc def ghi", "10", result)

Example 3:

@DTW_rLASTPOS(" ", "abc def ghi", "7")

DTW_LENGTH


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the length of a string.

Format

@DTW_LENGTH(stringIn, length)

@DTW_rLENGTH(stringIn)

Parameters

Table 87. DTW_LENGTH Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer length OUT A symbol containing the number of characters in stringIn.

Return Codes

Table 88. DTW_LENGTH Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_LENGTH("abcdefgh", result)

Example 2:

@DTW_rLENGTH("")

DTW_LOWERCASE


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns a string in all lowercase.

Format

@DTW_LOWERCASE(stringIn, stringOut)

@DTW_rLOWERCASE(stringIn)

@DTW_mLOWERCASE(stringMult1, stringMult2, ..., stringMultn)

Parameters

Table 89. DTW_LOWERCASE Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string with characters of any case.
string stringOut OUT A variable that contains stringIn with all characters in lowercase.
string stringMult INOUT
  • On input: A variable that contains a string.
  • On output: A variable that contains the input string converted to lowercase.

Return Codes

Table 90. DTW_LOWERCASE Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_LOWERCASE("This", stringOut)

Example 2:

@DTW_rLOWERCASE(string1)

Example 3:

@DTW_mLOWERCASE(string1, string2, string3)

DTW_POS


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the position of the first occurrence of a string in another string, using a forward search pattern.

Format

@DTW_POS(stringIn1, stringIn2, n, nOut)

@DTW_POS(stringIn1, stringIn2, nOut)

@DTW_rPOS(stringIn1, stringIn2, n)

@DTW_rPOS(stringIn1, stringIn2)

Parameters

Table 91. DTW_POS Parameters

Data Type Parameter Use Description
string stringIn1 IN A variable or literal string to search for.
string stringIn2 IN A variable or literal string to search.
integer n IN The character position in stringIn2 to begin searching. The default value is to start searching at the first character of stringIn2.
integer nOut OUT A variable that contains the position of the first occurrence of stringIn1 in stringIn2. If no occurrence is found, 0 is returned.

Return Codes

Table 92. DTW_POS Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1002 An input parameter contained a string value which consisted of the null-terminating character.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_POS("day", "Saturday", result)

Example 2:

@DTW_POS("a", "Saturday", "3", result)

Example 3:

@DTW_rPOS(" ", "abc def ghi", "5")

DTW_REPLACE


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT





X


Purpose

Replaces characters in a string.

Format

@DTW_REPLACE(stringIn, stringFrom, stringTo, n, option, stringOut)

@DTW_REPLACE(stringIn, stringFrom, stringTo, n, stringOut)

@DTW_REPLACE(stringIn, stringFrom, stringTo, stringOut)

@DTW_rREPLACE(stringIn, stringFrom, stringTo, n, option)

@DTW_rREPLACE(stringIn, stringFrom, stringTo, n)

@DTW_rREPLACE(stringIn, stringFrom, stringTo)

Parameters

Table 93. DTW_REPLACE Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string that is to be searched.
string stringFrom IN A variable or literal string that is to be replaced.
string stringTo IN A variable or literal string that replaces occurrences of stringFrom.
integer n IN The position of the character at which to begin the search.
string option IN Specifies whether to replace all occurrences, or just the first occurrence, and can have one of the following values:

A or a
Replaces all occurrences. The default is A.

F or f
Replaces only the first occurrence.
string stringOut OUT A variable that contains stringIn with occurrences of stringFrom replaced by stringTo.

Return Codes

Table 94. DTW_REPLACE Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_rREPLACE("ABCABCABC", "AB", "1234")

DTW_REVERSE


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Reverses a string so that the last character is first, second to last is second, until the entire string is reversed.

Format

@DTW_REVERSE(stringIn, stringOut)

@DTW_rREVERSE(stringIn)

Parameters

Table 95. DTW_REVERSE Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string to reverse.
string stringOut OUT A variable that contains the reversed form of stringIn.

Return Codes

Table 96. DTW_REVERSE Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_REVERSE("This is it.", result)

Example 2:

@DTW_rREVERSE(string1)

DTW_STRIP


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Removes leading blanks, trailing blanks, or both from a string.

Format

@DTW_STRIP(stringIn, option, stringOut)

@DTW_STRIP(stringIn, stringOut)

@DTW_rSTRIP(stringIn, option)

@DTW_rSTRIP(stringIn)

Parameters

Table 97. DTW_STRIP Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
string option IN Specifies which blanks to remove from stringIn. The default is B.

B or b - remove both leading and trailing blanks

L or l - remove leading blanks only

T or t - remove trailing blanks only

string stringOut OUT A variable that contains stringIn with blanks removed as specified by option.

Return Codes

Table 98. DTW_STRIP Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_STRIP("  day ", result)

Example 2:

@DTW_STRIP("  day ", "T", result)

Example 3:

@DTW_rSTRIP("  a day  ", "L")

DTW_SUBSTR


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns a substring of a string, with optional pad characters.

Format

@DTW_SUBSTR(stringIn, n, length, pad, stringOut)

@DTW_SUBSTR(stringIn, n, length, stringOut)

@DTW_SUBSTR(stringIn, n, stringOut)

@DTW_rSUBSTR(stringIn, n, length, pad)

@DTW_rSUBSTR(stringIn, n, length)

@DTW_rSUBSTR(stringIn, n)

Parameters

Table 99. DTW_SUBSTR Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string to be searched.
integer n IN The first character position of the substring. The default is to start at the beginning of stringIn
integer length IN The number of characters of the substring. The default is the rest of the string.
string pad IN The padding character used if n is greater than the length of stringIn or if length is longer than stringIn. The default is a blank.
string stringOut OUT A variable that contains a substring of stringIn.

Return Codes

Table 100. DTW_SUBSTR Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_SUBSTR("abc", "2", result)

Example 2:

@DTW_SUBSTR("abc", "2", "4", result)

Example 3:

@DTW_SUBSTR("abc", "2", "4", ".", result )

Example 4:

@DTW_rSUBSTR("abc", "2", "6", ".")

DTW_TRANSLATE


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns a string with each character translated to another character or unchanged.

Format

@DTW_TRANSLATE(stringIn, tableO, tableI, default, stringOut)

@DTW_TRANSLATE(stringIn, tableO, tableI, stringOut)

@DTW_TRANSLATE(stringIn, tableO, stringOut)

@DTW_TRANSLATE(stringIn, stringOut)

@DTW_rTRANSLATE(stringIn, tableO, tableI, default)

@DTW_rTRANSLATE(stringIn, tableO, tableI)

@DTW_rTRANSLATE(stringIn, tableO)

@DTW_rTRANSLATE(stringIn)

Parameters

Table 101. DTW_TRANSLATE Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
string tableO IN A variable or literal string used as a translation table. Use null ("") to specify tableI or default; otherwise this parameter is optional.
string tableI IN A variable or literal string searched for in stringIn. Use null ("") to specify default; otherwise this parameter is optional.
string default IN The default character to use. The default is a blank.
string stringOut OUT A variable that contains the translated result of stringIn.

Return Codes

Table 102. DTW_TRANSLATE Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Usage Notes

  1. If tableI, tableO, and the default character are not in the parameter list, the stringIn parameter is translated to uppercase.
  2. If tableI and tableO are in the list, each character in the input string is searched for in tableI and translated to the corresponding character in tableO. If a character in tableI has no corresponding character in tableO, the default character is used instead.

Examples

Example 1:

@DTW_TRANSLATE("abbc", result)

Example 2:

@DTW_TRANSLATE("abbc", "R", "bc", result)

Example 3:

@DTW_rTRANSLATE("abcdef", "12", "abcd", ".")

Example 4:

@DTW_rTRANSLATE("abbc", "", "", "")

DTW_UPPERCASE


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns a string in uppercase.

Format

@DTW_UPPERCASE(stringIn, stringOut)

@DTW_rUPPERCASE(stringIn)

@DTW_mUPPERCASE(stringMult1, stringMult2, ..., stringMultn)

Parameters

Table 103. DTW_UPPERCASE Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string with characters of any case.
string stringOut OUT A variable that contains stringIn with all characters in uppercase.
string stringMult INOUT
  • On input: A variable that contains a string.
  • On output: A variable that contains the input string converted to uppercase.

Return Codes

Table 104. DTW_UPPERCASE Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_UPPERCASE("Test", result)

Example 2:

@DTW_rUPPERCASE(string1)

Example 3:

@DTW_mUPPERCASE(string1, string2, string3)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]