To concatenate two strings including a separator if desired.

Syntax

Concat(character-expression1, character-expression2, [ ,character-expression3 ] )

character-expression1 + character-expression2 

Type Returned:
Character

Where:
character-expression3
Is the separator between character-expression1 and character-expression2

+ (plus sign)

Description

Returns a String that results from the concatenation of character-expression1 and character-expression2> and separator character-expression3. Trailing blanks of string character-expression1 are truncated. If character-expression3 is not specified, no separator is inserted.

Note

In the iSeries, if the strings character-expression1, character-expression2 or character-expression3 are substituted with functions (substr(), str(), etc), then the returned value is null, because the returned values of these functions are 256-character-long variables.

Examples

LastName  = 'SMITH '
FirstName = 'JOHN '
&FullName  = Concat(FirstName,LastName,' ')

Result: &FullName = 'JOHN SMITH '

In case you want to maintain the trailing blanks in the first parameter, you may change the order of the parameters. For example:

LastName  = 'SMITH'
FirstName = 'JOHN '
&FullName = Concat(,LastName,FirstName)

With the plus sign, the concatenation is very simple:

&FullName  = &Firstname + ' ' + &Lastname

Result: &FullName = 'JOHN SMITH'

See also

Str function
Substr function