Transform Functions

Topics:

Functions provide various algorithms that calculate output mapping values in iWay Transformer.

iWay Transformer provides numerous predefined functions in the following major categories:

Predefined Functions

Topics:

To find more information about a function or its parameters, navigate to an appropriate function category within this topic. Functions and categories are arranged in alphabetical order.

EDI Functions

The EDI functions available in iWay Transformer are described in the following table.

Format-specific functions, such as EDI, do not appear in the Functions pane of the Mapping Builder unless the output is using the exact format.

EDI Function

Description

@COUNT_GROUP()

Returns the occurrences of the group within an EDI message.

Parameters: None.

@COUNT_SEGMENT()

Returns the occurrences of the segment within a transaction set.

Parameters: None.

@COUNT_SEGMENT

(param1)

Returns the occurrences of the specified segment within a transaction set.

Parameter: param1. Name of the segment. It must be a constant.

@COUNT_TRANSACTION()

Returns the occurrences of the transaction within a group.

Parameters: None.

@CRC16()

Is specific to the UCS 4010 894 document. It is used on the 866 element (CRC 16 checksum) of the G8501 segment. The value of this function is generated using a Cyclic Redundancy Code (CRC) algorithm. It has a fixed length of four characters with no zero suppression. It applies to the contents of the entire transaction that is configured for segments ST through G86, inclusive.

@LINE_COUNTER

(param1)

Returns the occurrences of the specified segment within the same loop instance. The counter is reset when a new loop starts.

Parameter: param1. Name of the segment. It must be a constant. It is based on the LN segment description.

Numerical Functions

The numerical functions available in iWay Transformer are described in the following table.

Numerical Function

Description

@ADD

(param1, param2)

Returns the result of adding the two numbers specified as parameters.

Parameters:

param1. Number to add to param2.

param2. Number to add to param1.

Example: @ADD(24.01, 12.02) returns 36.03.

@AVERAGE

(param1)

Returns the average of the specified parameter values within the same parent instance. This function is used within the group in combination with the Agg looping property.

You must carefully set the looping settings of the parent and grandparent of the attribute or element that uses the @AVERAGE function. For more information, see Group Properties.

Parameter: param1. Number that represents the value to average. Usually, it is mapped from the ancestor node to the input document node.

 

Example:

In the following example, the output node ValueAverage has the value @AVERAGE(Sales/Company/Year/Quarter/Product/Item@value), where the output obtained is:

<Sales_Totals>
  <companyName>Video and Sound Card 
Express</companyName>
  <Statistics>
     <itemValueAverage>139.7407</itemValueAverage>
     <allTimeSales>95022.02</allTimeSales>
  </Statistics>
</Sales_Totals>

In this XML-to-XML transformation example, the Sales_Totals output group has the looping property set to False. The Statistics group has the looping property set to Agg. The desired output value is also obtained with the Sales_Totals looping property set to Agg, but not when it is set to True.

@CHKNUM

(param1)

Returns the string true if the specified parameter is a valid number. Use this function to determine if the parameter is a number (either integer or decimal). Returns true or false.

Parameter: param1. Number to validate.

Examples:

@CHKNUM('1.1') returns true.

@CHKNUM('abcd') or @CHKNUM('1,234.55') returns false.

@COUNT

Counts the input items processed and returns the next sequential value. The first loop through @COUNT initializes the counter to 1. Subsequent passes increment the counter to the next integer number.

Parameters: None.

@DIVIDE

(param1, param2)

Returns the decimal result of dividing two numbers specified as parameters.

Parameters:

param1. Number that represents the dividend.

param2. Number that represents the divisor.

Example: @DIVIDE('24.02', '12.01') returns 2.0.

@INT

(param1)

Returns the first occurrence of the integer value found in the specified parameter. If the integer value cannot be found, the number 0 (zero) is returned.

Parameter: param1. String to be checked.

Examples:

@INT('45.60 or 65.60') returns 45.

@INT('in the summer of 1998 and 1999') returns 1998.

@INT('time is 23:11:56') returns 23.

@INT('last year') returns 0.

@INTVAL

(param1)

Returns the specified parameter value if it is a valid integer. Otherwise, it returns the number 0 (zero).

Parameter: param1. String to be checked.

Examples:

@INTVAL('45') returns 45.

@INTVAL('45.12') or @INTVAL('dollars 1.23') returns 0.

@MULTIPLY

(param1, param2)

Returns the decimal result of multiplying two members specified as parameters.

Parameters:

param1. Number to multiply by param2.

param2. Number to multiply by param1.

Example: @MULT(12.01, 2.00) returns 24.02.

@NUM

(param1)

Converts an integer string to a numeric value. Use this function to determine if a parameter is an integer (whole number). The function returns the parameter or an error.

Parameter: param1. Numeric string to be converted to an integer value.

Example: @NUM('45') returns 45.

@NUM_CHR

(param1)

Returns the ASCII character that corresponds to a number.

Parameter: param1. Integer number between 1 and 127 that represents the order of an ASCII character.

Example: @NUM_CHR ('66') returns 'B'.

@RANDOM

(param1)

Returns a pseudo random number.

Parameter: param1. Number used to seed the random number generator.

If param1 = -1, the seed is initialized randomly.

If param1 = n (where n is not 0 or -1), the seed is initialized to n.

If param1 = 0, the same random number value that is generated for the previous output item is used as the result for the next output item.

For example, if the @RANDOM value of an output element is '-12345', and you use @RANDOM('0') for the next element, the same '-12345' value is returned for this element.

@RANGE

(param1, param2, param3)

Determines if a number falls within a range, and returns the string value "true" or "false". The range is given by param2 to param3, inclusive.

Parameters:

param1. Value that is checked.

param2. Value that represents the lower limit of the range.

param3. Value that represents the upper limit of the range.

Example: @RANGE('10', '5', '15') evaluates to true.

@ROUND

(param1, param2, param3)

Extracts a specified part of a number and rounds the result to an integer.

Parameters:

param1. Number subjected to the operation.

param2. Number of digits to be extracted from the integer part of param1. Digits are counted from the left of the decimal separator.

param3. Number of digits to be extracted from the decimal part of param1. Digits are counted from the right of the decimal separator.

Example: @ROUND(345.995, 2, 2) returns 46.00.

@SCALE_ROUND

(param1, param2, param3)

Returns the specified parameter rounded in a specified fashion. Enables you to scale a number and specify the way that it is rounded during scaling.

Parameters:

param1. Number subjected to the operation.

param2. Number of digits to the right of the decimal place to keep. The value must be a non-negative integer.

param3. Type of rounding required.

The following are possible values:

ROUND_CEILING: Round towards positive infinity.

ROUND_DOWN: Round towards zero.

ROUND_FLOOR: Round towards negative infinity.

ROUND_HALF_DOWN: Round towards nearest number. If equidistant to two numbers, round down.

ROUND_HALF_EVEN: Round towards nearest number. If equidistant to two numbers, round towards even number.

ROUND_HALF_UP: Round towards nearest number. If equidistant to two numbers, round up.

ROUND_UNNECESSARY: No rounding is necessary. Use this rounding mode to make sure that the output value has the exact number of decimals specified in param2. If the number of decimals is different, an error is returned.

ROUND_UP: Round away from zero.

Example: @SCALE_ROUND(5.111, 2, ROUND_UP) returns 5.12.

@STR

(param1, param2)

Converts a number to an alpha string according to a picture mask. Use this function to format numbers.

Parameters:

param1. Number to be converted into an alpha string.

param2. Picture mask format for the string. For more information, see Numeric Pictures.

Examples: @STR('45.12', '##.#') returns '45.1'.

@STR('75','#.00') returns 75.00.

@STR('567.1', '#.00') returns 567.10.

Since a picture mask is used, the function may cause rounding. For example, @STR(39.999,'#.00') returns '40.00'.

@SUBTRACT

(param1, param2)

Returns the result of subtracting two numbers specified as parameters.

Parameters:

param1. Float number from which to subtract param2.

param2. Float number to subtract from param1.

Example: @SUBTRACT(24.02, 11.01) returns 13.01.

@SUM

(param1)

Returns the sum of the numeric values of a specified input node.

You must carefully set the looping settings of the parent and grandparent of the node that uses the @SUM function. For more information, see Group Properties.

Parameter: param1. Input node that has a numeric value.

Example: In the following example, the output node allTimeSales has the value @SUM(@MULTIPLY(Sales/Company/Year/Quarter/Product/Item @value, Sales/Company/Year/Quarter/Product/Item@sold)), where the output obtained is:

<Sales_Totals>
<companyName>Video and Sound Card 
Express</companyName>
  <Statistics>
     <itemValueAverage>139.7407</itemValueAverage>
     <allTimeSales>95022.02</allTimeSales>
  </Statistics>
</Sales_Totals>

In this XML-to-XML transformation example, the Sales_Totals output group has the looping property set to False. The Statistics group has the looping property set to Agg. The desired output value is also obtained with the Sales_Totals looping property set to Agg, but not when it is set to True.

@VAL

(param1, param2)

Returns the number that matches the specified picture mask. This function returns a value only if the picture mask matches the input format. For example, if the picture mask is # and the input is 7.3, the function returns an error, not 7 as might be expected.

Use this function to retrieve the numeric value from a string.

Do not use this function to format a number. To format a number, use the @STR function.

Parameters:

param1. String that contains the number to be retrieved.

param2. Format in which the number is stored in the string. Must be specified as a constant in the Mapping Builder. For more information, see Numeric Pictures.

Examples:

@VAL('30.11 dollars plus a fee of 40 dollars','##') returns 40.

@VAL('30.11 dollars plus a fee of 40 dollars','##.##') returns 30.11.

To format a number with commas, such as <X>123,456,789</X>, you can remove the commas by using the @CONCAT and @SUBSTR functions. For example:

@CONCAT(@SUBSTR(X,'1','3'),@SUBSTR(X,'5','3'),@SUBSTR(X,'9','3'))

Processing Functions

The processing functions available in iWay Transformer are described in the following table.

Processing Function

Description

@CONDITION

(param1)

The @CONDITION function is a new processing function that supports embedded conditions. This function also includes support for AND / OR operators.

Note: The @CONDITION function is designed to be used within the @IF function to support a more refined handling of multiple conditions instead of a series of nested @IF statements.

Parameters:

Param1: A boolean expression of a defined syntax (<left_operand><operator><right_operand>). The left_operand and right_operand can be any supported mapped values. Supported arguments for the operator include all arguments of the current @IF processing function (for example: ==, !=, <, >, <=, >=, AND, OR). By default, the operator is set to AND in the Output Node Mapping Builder.

For AND or OR operators, if the left or right operands are mapped to an input context, it will be assumed that the @EXISTS function is used. For example:

@CONDITION(a/b/c AND a/b/e)
@IF(a/b/c AND a/b/e,'true','false')

Will be the same as:

@CONDITION(@EXISTS(a/b/c) AND @EXISTS(a/b/e))
@IF (@EXISTS(a/b/c) AND @EXISTS(a/b/e) ,'true','false')

The @CONDITION function returns a string:

  • true - If condition results to true, Boolean.TRUE is returned.
  • false - If condition results to false, Boolean.FALSE is returned.
@EDIT

(param1, param2, param3)

Returns a value formatted using the specified picture mask and formatter class name. For more information, see Numeric Pictures.

Parameters:

param1. String representing the formatter class name. Supports the DecimalFormat class.

param2. String representing the picture mask to be applied to param3.

param3. Number to be formatted.

Examples:

@EDIT('DecimalFormat','#,###.##','123456.78) returns 123,456.78.

@EDIT('DecimalFormat','000','12') returns 012.

@EXISTS

(context_to_be_checked)

Returns a string with a Boolean value that indicates whether or not the context is null.

Use this processing function to distinguish between an element that is missing from a document structure from an element that is present, but has a value of an empty string.

Examples:

<Statistics>
   <itemValueAverage>139.7407</itemValueAverage>
   <allTimeSales>95022.02</allTimeSales>
</Statistics>

@EXISTS (Statistics/ itemValueAverage) returns true.

<Statistics>
   <itemValueAverage></itemValueAverage>
   <allTimeSales>95022.02</allTimeSales>
</Statistics>

@EXISTS (Statistics/ itemValueAverage) returns true.

<Statistics>
   <allTimeSales>95022.02</allTimeSales>
</Statistics>

@EXISTS(Statistics/ itemValueAverage) returns false.

@GETCONSTANT

(param1)

Returns the value of the global constant specified by name in the parameter.

Parameter: param1. Global constant defined in the Global Constant section of the Project Properties pane.

Example: Assume that you defined the following global constant in project properties:

Name: COMPANY_ADDRESS Value: 1234 1st Avenue

As a result, @GETCONSTANT('COMPANY_ADDRESS') returns '1234 1st Avenue'.

@IF

(param1, param2, param3, param4, param5)

Allows for a conditional selection statement defined by the first three parameters. If the condition evaluates to true, it returns the contents of the fourth parameter. Otherwise, it returns the contents of the fifth parameter.

Parameters:

param1. Left operand of the condition statement.

param2. Conditional operator. The possible arguments are:

  • = = equal to
  • != not equal to
  • >= equal to or greater than
  • <= equal to or less than
  • > greater than
  • < less than

param3. Right operand of the condition statement.

param4 (true_option). The string to be returned if the condition statement is true.

param5 (false_option). The string to be returned if the condition statement is false.

Example: The variable X has a value that fluctuates between 4 and 8. @IF(X<'10', 'ABC', 'DEF') always returns 'ABC'.

@INPUT_CONTENT

Returns the contents of the entire input data file as a string.

Parameters: None.

@JDBCLOOKUP

(param1, param2)

Returns a value retrieved from a database using an SQL statement. The SQL statement can be dynamically based on the input from other transform functions. If more than one value is retrieved by the SQL statement, the last value in the sequence is returned.

Parameters:

param1. String that represents the name of a globally defined JDBC connection configuration.

param2. SQL statement that is defined using SQL Builder.

Example:

@JDBCLOOKUP('LOOKUP_TEST', {'SELECT field1 FROM LOOKUP_TABLE WHERE field2 ' = '+@QUOTE(Customer/Person/Name)})

where:

LOOKUP_TEST

Is the name of the specific JDBC connection configuration.

{'SELECT field1 FROM LOOKUP_TABLE WHERE field2 ' = '+@QUOTE(Customer/Person/Name)}

Is the SQL statement that is constructed dynamically.

@NULL

Returns a null output, that is, no output. Useful, for example, as either the true_option or false_option in an @IF function.

Parameters: None.

@REPLACE

(param1, param2)

Calls the predefined replace function specified by name in the second parameter of @REPLACE, which replaces every matched string specified in the first parameter. If the match is not found, the first parameter is returned. For more information on how to define replace functions, see Using the Mapping Builder.

Parameters:

param1. Input node, value, or constant in which to make changes.

param2. Replace function name as defined.

The @REPLACE processing function supports spaces and unprintable characters (for example, \t, \r, or \n) as parameter values.

Example: @REPLACE('11009333009', 'REPLACE_009_WITH_Add') returns 11Add333Add.

@SIMPLE_REPLACE

(param1, param2)

Calls the predefined replace function, which replaces the first string that matches the value of the first parameter of this function. If a match is not found, the first parameter is returned.

Parameters:

param1. Input node value in which to make changes.

param2. Replace function name as defined.

Example: @SIMPLE_REPLACE('009', 'REPLACE_009_WITH_Add') returns Add.

Run-Time Functions

The run-time functions available in iWay Transformer are described in the following table.

Run-Time Function

Description

@IWENCR

(param1)

Returns the encrypted value of the parameter, based on the iWay Service Manager internal encryptor.

Parameter: param1. String to be encrypted.

Example:

@IWENCR('1234') returns the value in a format similar to:

@ENCR(32533101323532123122319631833137).

@SREG

(param1, param2)

Returns some of the iWay Service Manager special registers defined by the specified parameter. This functionality is supported for run-time purposes only. If the function is tested in design time, param2 is always returned.

Parameters:

param1. String that represents the name of the special register whose value is returned.

param2. String that represents the default value to return if the special register identified by param1 is not found.

The second parameter of the @SREG() function must consist of a mapped dynamic value. A static default value as the second parameter is not allowed. When you troubleshoot @SREG() evaluation problems, we recommend that you map a dynamic value to the second parameter instead of using a static default value.

@SET_SREG

(param1, param2, param3, param4)

Sets the specified iWay Service Manager special register to the specified value, and returns param4. This functionality is supported for run-time purposes only.

The special register name is specified in param1. The value to be assigned is specified in param2. The type of the special register is specified in param3. The last parameter, param4, contains the value to be returned upon successful execution.

Parameters:

param1. String that represents the name of the special register.

param2. String that represents the new value of the special register.

param3. Number that represents the type of the special register. Possible values include:

  • 2: user-defined variable
  • 3: user-defined emit header

param4. String that represents the expected return value of this function.

Example: @SET_SREG ('custom_functions_location', 'tools/transformer/custom_functions','2','custom functions location is set') returns 'custom function location is set'.

@SREG_EXISTS

(param1)

Determines if an iWay Service Manager special register with the name specified in the parameter is already defined, and returns a true or false response. This functionality is supported for run-time purposes only.

Parameters:

param1. String that represents the name of the special register.

Example: @SREG_EXISTS('custom_functions_location') returns true if the register is already defined. Returns false if the register is not defined.

@REMOVE_SREG

(param1, param2)

Removes the iWay Service Manager special register with the name specified in param1, and returns param2. This functionality is supported for run-time purposes only.

Parameters:

param1. String that represents the name of the special register.

param2. String that represents the expected return value of this function.

Example: @REMOVE_SREG ('custom_functions_location','custom functions location is removed') returns 'custom function location is removed'.

Security Functions

The security functions available in iWay Transformer are described in the following table.

Security Function

Description

@CHKDGT

(param1, param2)

Determines if the alphanumeric character, at the specified position of the string in param1, is a number or a letter. Returns 'true' if it is a number, or 'false' if it is a letter.

Parameters:

param1. Alpha string that represents the number to be checked.

param2. Position of the character in param1 to check. The position numbering starts at 0 (zero) from the left. Supply this parameter as a constant in the Mapping Builder.

Examples:

@CHKDGT('4abc', '0') returns 'true'.

@CHKDGT('6a89', '1') returns 'false'.

String Functions

The string functions available in iWay Transformer are described in the following table.

String Function

Description

@CONCAT

(param1, param2, param3, param4)

Returns the string of concatenations of the specified parameters.

If required, you can add or remove parameters for the @CONCAT function using the Mapping Builder. For more information, see Customizing @CONCAT Functions.

The following signatures of the @CONCAT function are available:

@CONCAT(param1, param2)

@CONCAT(param1, param2, param3)

@CONCAT(param1, param2, param3, param4)

Parameters:

param1. String to be concatenated.

param2. String to be concatenated.

param3. String to be concatenated.

param4. String to be concatenated.

Example: @CONCAT('The cow ', 'jumped ', ' over ', ' the moon') returns 'The cow jumped over the moon'.

@CRLF

Returns the combination of the Carriage Return and new Line Feed characters.

Parameters: None.

Example: @CONCAT('First line',@CRLF(),'Second line') returns 'First line Second line'.

@DELSTR

(param1, param2, param3)

Deletes the character substring from an alpha string for the length specified in param3.

Parameters:

param1. Alpha string or alpha string expression.

param2. Position of the first character to be deleted.

param3. Number of characters to be deleted, beginning with param2 and continuing to the right.

Examples:

@DELSTR('ABCD', '2', '1') deletes the second letter of the string and returns 'ACD'.

@IF(Y<0, @DELSTR(X, '1', '1'), @IF(Y>0, @DELSTR(X, '2', '1'), X))

If X contains a character string with a length greater than or equal to 2, the expression removes either the first or second character, or leaves the string intact, depending on the value that appears in column Y (negative, positive, or zero).

@EQUALS

(param1, param2)

Compares two strings, and returns 'true' if they are equal or 'false' if they are not.

Parameters:

param1. String to compare.

param2. String to compare.

Example: @EQUALS('BA', 'AB') returns 'false'.

@FILL

(param1, param2)

Repeats an alpha string or expression multiple times.

This function accepts a maximum of 32 kilobytes (KB).

Parameters:

param1. An alpha string or expression.

param2. The number of times that the string is repeated.

Example: @FILL('*',5) creates a string of five asterisks '*****'.

@FLIP

(param1)

Reverses an alpha string, or the result of an alpha expression, to its mirrored image.

Parameter: param1. Alpha string or alpha string expression.

Example: @FLIP('Good') returns 'dooG'.

@HSTR

(param1)

Returns the hexadecimal (base 16) string value of a decimal (base 10) number specified as param1.

Parameter: param1. Decimal (base 10) number or numeric expression that represents a decimal number.

Example: @HSTR('15') returns 'F'. @HSTR('16') returns '10'.

@HVAL

(param1)

Returns the decimal (base 10) value of a hexadecimal (base 16) number specified as param1.

Parameter: param1. Alpha string that represents a hexadecimal (base 16) number.

Example: @HVAL('FF') returns 255. @HVAL('10') returns 16.

@INSERT

(param1, param2, param3, param4)

Inserts one string into another at the specified position.

Parameters:

param1. Alpha string that represents the target string.

param2. Alpha string that represents the source string.

param3. Number that represents the character position in param1, after which the insertion takes place.

param4. Number that represents how many characters from param2 are inserted into param1.

Example: @INSERT('abcde', 'xxx', '3', '2') returns 'abcxxde'.

@INSTR

(param1, param2)

Returns an integer that represents the first position of a substring within an alpha string or alpha expression.

If the search argument is not found, the function returns 0 (zero).

Parameters:

param1. Input string or alpha expression string.

param2. Alpha string that is searched for in the input string.

Examples:

@INSTR('abcd', 'b') returns 2.

@INSTR('ABCDEF', 'DE') returns 4.

@LEFT

(param1, param2)

Returns a substring of an alpha string, starting from the left, with its length specified in param2.

Parameters:

param1. Input string.

param2. Number of characters to be returned, starting from the left.

Example: @LEFT('abcdefg', '3') returns 'abc'.

@LEN

(param1)

Returns an integer number that equals the length of an alpha string.

The string is right-justified (for example, trailing blanks are removed) before starting.

Parameter: param1. Input string.

Example: @LEN ('abcdefg') returns 7.

@LOWER

(param1)

Returns a string converted to all lowercase letters.

Parameter: param1. Input string.

Example: @LOWER('Who said THAT?') returns 'who said that?'

@LPAD

(param1, param2)

Returns the specified input string padded to the left, using the string specified in param1. The padding is inserted to the left of the string input until the length specified in param2 is reached. If padding is not performed (for example, if there is an invalid parameter or the desired length is smaller than the length of the input string), param1 is returned.

Parameters:

param1. String input to be padded.

param2. Number that represents the desired length of the returned string.

Examples:

Single quotation marks are not part of the data. They are used to visually mark the length of the padded string.

@LPAD('constant','12') returns '            constant'.
@LPAD('constant','3') returns '   constant'.
@LPAD

(param1, param2, param3)

Returns the specified input string padded to the left, using the string specified in param3. The string is inserted to the left of the input string until the desired length specified in param2 is reached. If padding is not performed (for example, if there is an invalid parameter or the desired length is smaller than the length of the input string), param1 is returned.

Parameters:

param1. Input string to be padded.

param2. Number that represents the length of the returned string.

param3. String used for padding.

Examples:

Single quotation marks are not part of the data. They are used to visually mark the length of the padded string.

@LPAD('constant','12', 'L') returns 'LLLLLLLLLLLLconstant'.

@LPAD('constant','3', 'L') returns 'LLLconstant'.

@LTRIM

(param1)

Removes leading white spaces (such as blanks, tabs, line feeds) from an alpha string or an alpha expression.

Parameter: param1. Input string.

Example: @LTRIM(' John') returns 'John'.

@LTRIM

(param1, param2)

Removes a leading specified trim character from an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

Example: @RTRIM('XJohn ',X) returns 'John'.

@LTRIM

(param1, param2, param3)

Removes leading white space (blanks, tabs, line feeds) or specified trim characters from an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

param3. A true or false flag to trim all occurrences of the trim character specified in param2.

Example: @RTRIM('XXJohn ',X, true) returns 'John'.

@MID

(param1, param2, param3)

Returns the substring extract of the specified number of characters from an input string.

This function will be deprecated in future releases. Use @SUBSTR instead.

Parameters:

param1. Input string.

param2. Number that represents the starting position of the substring within param1.

param3. Number of characters to be extracted (the length of the substring).

Example: @MID('John', '3', '2') returns 'hn'.

@NOT_EQUALS

(param1, param2)

Compares two strings in param1 and param2, and returns 'false' if they are equal, or 'true' if they are not.

Parameters:

param1. String.

param2. String.

Example: @EQUALS('BA', 'AB') returns 'true'.

@QUOTE

(param1)

Returns the specified parameter in param1, delineated by the single quotation marks.

Parameter:

param1. String to be quoted.

Examples:

@QUOTE('quote me') returns 'quote me'.

@QUOTE('23') returns '23'.

@QUOTEGEN

(param1)

Generates a WHERE clause in an SQL statement. Generates single quotation marks around an alpha string, but not if the input is an integer or a number.

Parameter:

param1. String. It can be an input node value, a constant, or the result of another function.

Examples:

@QUOTEGEN('HELLO') returns 'HELLO'.

@QUOTEGEN('1234') returns 1234.

@CONCAT('SELECT column1 from table where column2 = ', @QUOTEGEN(parent/child/value))

returns:

  • “SELECT column1 from table where column2 = 'value', IF parent/child/value type is an alpha string.”
  • “SELECT column1 from table where column2 = value, IF parent/child/value type is integer or number.”
@REP

(param1, param2, param3, param4)

Returns the result of the replacement of an alpha substring in an input string with another substring.

Parameters:

param1. Input alpha string or expression in which the replacement takes place.

param2. Alpha string or expression that provides the substring to copy to param1.

param3. First position in param1 that receives the substring from param2.

param4. Number of characters that are moved from param2 to param1, starting from the left-most character of param2.

Example: @REP('12345', 'abcde', '3', '2') returns '12ab5'.

@RIGHT

(param1, param2)

Returns a substring of an alpha string, starting from the right, with its length specified in param2.

Parameters:

param1. Input string from which the characters are taken.

param2. Number of characters to be retrieved, starting from the character furthest right.

Example: @RIGHT('abcdefg ', '3') returns 'efg'.

@RPAD

(param1, param2)

Returns the specified input string padded to the right, using the string specified in param1. The padding is inserted to the right of the input string until the desired length specified in param2 is reached. If padding is not performed (for example, if there is an invalid parameter or the desired length is smaller than the length of the input string), param1 is returned.

Parameters:

param1. String to be padded.

param2. Number that represents the length of the returned string.

Examples:

Single quotation marks are not part of the data. They are used to visually mark the length of the padded string.

@RPAD ('constant','12') returns 'constant            '.
@RPAD ('constant','3') returns 'constant   '.
@RPAD

(param1, param2, param3)

Returns the specified input string padded to the right, using the string specified in param3. The padding string is inserted to the right of the input string until the desired length specified in param2 is reached. If padding is not performed (for example, if there is an invalid parameter or the desired length is smaller than the length of the input string), the first parameter is returned.

Parameters:

param1. String to be padded.

param2. Number that represents the length of the returned string.

param3. String used for padding.

Examples:

Single quotation marks are not part of the data. They are used to visually mark the length of the padded string.

@RPAD ('constant','12', 'R') returns 'constantRRRRRRRRRRRR'.

@RPAD ('constant','3', 'R')returns 'constantRRR'.

@RTRIM

(param1)

Removes trailing white spaces (such as blanks, tabs, line feeds) from an alpha string or an alpha expression.

Parameter: param1. Input alpha string or alpha expression.

Example: @RTRIM('John ') returns 'John'.

@RTRIM

(param1, param2)

Removes a trailing specified trim character from an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

Example: @RTRIM('JohnX ',X) returns 'John'.

@RTRIM

(param1, param2, param3)

Removes trailing white space (blanks, tabs, line feeds) or specified trim characters from an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

param3. A true or false flag to trim all occurrences of the trim character specified in param2.

Example: @RTRIM('JohnXX ',X, true) returns 'John'.

@STRTOKEN

(param1, param2, param3)

Returns a specified string token from a delimited token string.

Parameters:

param1. Input string, delimited with tokens.

param2. Requested token index (numeric).

param3. Delimiter. You can use valid <XML> element tags (nodes) as delimiters. The XML format of a list can be a variable or URL. Content must consist of a <list><tag>Value</tag></list> set, in which element names can be arbitrary but must be consistent.

Parameter Notes:

  • The third parameter, param3, can have more than one character as the delimiter.
  • An empty string is returned if a delimiter is not found or is empty, or if the input string is empty.
  • Every delimiter is counted for the index calculation (no repetition).

Example: variable BA = abcd,cdef,ghik,lmnp, then @STRTOKEN(BA, '2', ',') returns cdef.

@SUBSTR

(param1, param2, param3)

Returns the substring representing the extracts of a specified number of characters from an alpha string.

Parameters:

param1. Input alpha string.

param2. Number that represents the starting position of the substring within param1.

param3. Number of characters to be extracted (the length of the substring).

Example: @SUBSTR('John', '3', '2') returns 'hn'.

@TRIM

(param1)

Removes white space characters (such as blanks, tabs, and line feeds) from the left and right sides of an alpha string or an alpha expression.

Parameter: param1. Input alpha string.

Example: @TRIM(' John ') returns 'John'.

@TRIM

(param1, param2)

Removes a specified trim character from the left and right sides of an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

Example: @RTRIM('XJohnX ',X) returns 'John'.

@TRIM

(param1, param2, param3)

Removes white space characters (such as blanks, tabs, and line feeds) or specified trim characters from the left and right sides of an alpha string or an alpha expression.

Parameters:

param1. Input alpha string or alpha expression.

param2. Specified trim character.

param3. A true or false flag to trim all occurrences of the trim character specified in param2.

Example: @RTRIM('XXJohnXX ',X, true) returns 'John'.

@UPPER

(param1)

Returns a string converted to all uppercase letters.

Parameter: param1. Alpha string.

Example: @UPPER('Pablo Picasso') returns 'PABLO PICASSO'.

Time Functions

The time functions available in iWay Transformer are described in the following table.

Time Function

Description

@ADD_DATE

(param1, param2, param3, param4)

Performs a calculation on a date variable. It constructs a resulting date out of an input date and three values added to that date: years, months, and days. The result is always a valid date format.

Parameters:

param1. Input date (format: MM/dd/yyyy).

param2. Number of years to add to param1.

param3. Number of months to add to param1.

param4. Number of days to add to param1.

A parameter with a value of 0 (zero) is ignored.

Example: @ADD_DATE('01/01/1992', '1', '2', '2') returns 03/03/1993.

@ADD_TIME

(param1, param2, param3, param4)

Performs a calculation on a time variable. It constructs a resulting time out of an input time and three values added to that time: hours, minutes, and seconds. The result is always a valid time format.

Parameters:

param1. Input time.

param2. Number of hours to add to param1.

param3. Number of minutes to add to param1.

param4. Number of seconds to add to param1.

A parameter with a value of 0 (zero) is ignored.

Example: @ADD_TIME('12:00:00', '1', '2', '3') returns 13:02:03.

@CUSTOMDATE()

Will be deprecated in future releases. Use @DATE instead.

@DATE

(param1)

Returns the system date in the specified format. For more information, see Date Pictures.

Parameter: param1. Date format.

Example: If the system date is 01/28/1992, @DATE ('dd/MM/yyyy') returns '28/01/1992'.

@DAY

(param1)

Returns the day of the specified date as a number between 1 and 31.

Parameter: param1. Input date. It is a date or date expression.

Example: @DAY('01/28/1992') returns '28'.

@DOW

(param1)

Returns the number of the day of the week for the specified date. For example, Sunday is 1 and Monday is 2.

Parameter: param1. Input date (format MM/dd/yyyy).

Example: @DOW('01/29/1992'), representing a Wednesday, returns '4'.

@DSTR

(param1, param2)

Returns the specified date in the format specified by the second parameter. The original input must be in the format 'MM/dd/yyyy'. For more information, see Date Pictures.

Parameters:

param1. Input date (format MM/dd/yyyy).

param2. Picture mask (format) of the returned date string.

Example: @DSTR('2/12/1998','MMMM dd, yyyy') returns 'February 12, 1998'.

@DSTR

(param1, param2, param3)

Returns an input date in the format specified by the third parameter. The input date must conform to the format specified by the second parameter. For more information, see Date Pictures.

Parameters:

param1. Input date.

param2. Picture mask of the input date.

param3. Picture mask (format) of the returned date string.

Example: @DSTR('2/12/1998','dd/MM/yyyy','MMMM dd, yyyy') returns 'December 02, 1998'.

@DSTR

(param1, param2, param3, param4)

Returns an input date format according to the fourth parameter, which accepts a Boolean value (true or false).

Parameters:

param1. Input date.

param2. Picture mask of the input date.

param3. Picture mask (format) of the returned date string.

param4. Determines whether or not the input date complies with standard formatting requirements.

@DVAL

(param1, param2)

Converts an input date to a numeric value. The numeric value represents the number of days elapsed since the day before the first day of the first century (01/01/01) until the input date. For more information, see Date Pictures.

Parameters:

param1. Input date string that can be interpreted as a date (for example, '01/01/92', 'Jan 1, 1992').

param2. Format of the input date. This parameter is required for the system to read and interpret param1.

Example: @DVAL('01/01/92', 'MM/dd/yy') and @DVAL('Jan 1, 1992', 'MMM dd, yyyy') each return 727198.

@EOM

(param1)

Returns the date of the end of the month specified in the parameter.

Parameter: param1. Input date.

Example: @EOM ('05/05/93') returns 05/31/93.

@EOY

(param1)

Returns the date of the end of the year specified in the parameter.

Parameter: param1. Input date.

Example: @EOY ('10/05/93') returns '12/31/93'.

@GD2JD

(param1, param2)

Converts a date in Gregorian format to Julian format.

The Gregorian date format, which is based on the Gregorian solar calendar, is the most widely used date format in the world. A Gregorian date is specified by the Year, the Month (identified by name or number), and the Day of the Month (numbered sequentially starting at 1). For example, 2008-03-25 is the Gregorian date representation for March 25, 2008.

In J.D. Edwards systems, Julian dates (JD) are identified by the year first, followed by the number of days into the year at which this date appears. For example, Jan 15, 1999 is represented as 99015. March 15 is 99074. March 15, 2001 is 101074, since dates in the current century start with 100 (2000), 101 (2001), and so on.

Parameters:

param1. Gregorian date.

param2. Gregorian date picture mask.

@HOUR

(param1)

Returns a number that represents the hour portion of the input time.

Parameter: param1. Input time.

Example: @HOUR('2:00:00') returns 2.

@JD2GD

(param1, param2)

Converts a date in Julian format to Gregorian format.

In J.D. Edwards systems, Julian dates (JD) are identified by the year first, followed by the number of days into the year at which this date appears. For example, Jan 15, 1999 is represented as 99015. March 15 is 99074. March 15, 2001 is 101074, since dates in the current century start with 100 (2000), 101 (2001), and so on.

The Gregorian date format, which is based on the Gregorian solar calendar, is the most widely used date format in the world. A Gregorian date is specified by the Year, the Month (identified by name or number), and the Day of the Month (numbered sequentially starting at 1). For example, 2008-03-25 is the Gregorian date representation for March 25, 2008.

Parameters:

param1. Julian date.

param2. Gregorian date picture mask.

@MINUTE

(param1)

Returns a number that represents the minutes portion of the input time.

Parameter: param1. Input time.

Example: @MINUTE('2:35:00') returns 35.

@MONTH

(param1)

Returns a number that represents the month portion of the input time.

Parameter: param1. Input time.

Example: @MONTH('01/28/1992') returns 1.

@SECOND

(param1)

Returns a number that represents the seconds portion of the input time.

Parameter: param1. Input time.

Example: @SECOND('12:02:05') returns 5.

@SOM

(param1)

Returns a number that represents the start of the month portion of the input time.

Parameter: param1. Input time.

Example: @SOM ('05/18/93') returns '05/01/93'.

@SOY

(param1)

Returns a number that represents the start of the year portion of the input time.

Parameter: param1. Input time.

Example: @SOY ('10/05/93') returns '01/01/93'.

@TIME

(param1)

Returns the system time. For more information, see Time Pictures.

Parameter: param1. Desired time format.

Example: @TIME ('HH:mm:ss') returns 17:08:42.

@TSTR

(param1, param2)

Converts a time to an alpha string, according to the format provider. A blank picture interprets the string as 'HH:mm:ss'.

For more information, see Time Pictures.

Parameters:

param1. Desired input time.

param2. Format of the resulting character string.

Example: @TSTR ('14:30', 'HH:mm PM') returns '2:30 PM'.

@YEAR

(param1)

Returns a number that represents the year portion of the input time.

Parameter: param1. Date or date expression.

Example: @YEAR('01/28/1992') returns 1992.

Numeric Pictures

The numeric picture masks available in iWay Transformer are described in the following table.

Symbol

Location

Description

0

Number

Digit.

#

Number

Digit. Zero shows as absent.

.

Number

Decimal separator or monetary decimal separator.

-

Number

Minus sign.

,

Number

Grouping separator.

E

Number

Separates mantissa and exponent in scientific notation. It does not require quotation marks in the prefix or suffix.

%

Prefix or suffix

Multiply by 100 and show as a percentage.

Examples of numeric picture masks are shown in the following table. The ^ symbol represents one space character.

Numeric Value

Picture

Resulting Numeric Value

1234.56

#,###.##

1,234.56

123456789.56

#,###.##

123,456,789.56

-1234.56

N###,###.##C

^^-1,234.56

-1234.56

N######.##L

-1234.56^^

-1234.56

N######.##P*

-**1234.56

0

N######.##Z*

*********

-13.5

N##.##-DB;

DB13.50

45.3

N##.##+CR;

CR45.30

-13.5

N##.##-(,);

(13.50)

4055.3

$######.##

$^^4055.30

Date Pictures

The following table describes the date symbols and shows an example of each.

Symbol

Description

Example

Presentation

G

Era designator.

AD

Text

y

Year.

1996

Number

M

Month in year.

July & 07

Text & Number

d

Day in month.

10

Number

E

Day in week.

Tuesday

Text

D

Day in year.

189

Number

F

Day of week in month.

2 (second Wed. in July)

Number

w

Week in year.

27

Number

W

Week in month.

2

Number

'

Escape for text.

'

Delimiter

' '

Single quotation mark.

'

Literal

-

Separates month, day, and year.

12-24-86

Delimiter

/

Separates month, day, and year.

12/24/86

Delimiter

The typical date formats are 'dd/MM/yyyy' (European), 'MM/dd/yyyy' (American), and 'yyyy/MM/dd' (Scandinavian). When you define the attribute Date for the parameter in one of the functions, you must also select the format for the date item, as described in the following table. You can change the default format and place in it any positional directives and masking characters that you require.

The following table provides examples of the date format (picture), using the date of 21 March 1992. The ^ symbol represents one space character.

Date Picture

Result

MM/dd/yyyy

03/21/1992

##/##/##

21/03/92 when an XML parser default is set to European

03/21/92 when an XML parser is set to American

MMMM^dd^yyyy

March^21^1992

MMM^dd, ^yyyy

Mar.^21^1992

EEEE^^-^7

Saturday^^^-^7

E^7

Mon^7

Time Pictures

The following table describes the time symbols and shows an example of each.

Symbol

Description

Example

Presentation

h

Hour in am/pm (1-12)

12

Number

H

Hour in day (0-23)

0

Number

m

Minute in hour

30

Number

s

Second in minute

55

Number

-

Separates hours from seconds

1-22

1-22

:

Separates hours from seconds

1:22

1:22

S

Millisecond

978

Number

a

AM/PM marker

PM

Text

k

Hour in day (1-24)

24

Number

K

Hour in am/pm (0-11)

0

Number

z

Time zone

Pacific Standard Time

Text

The following table shows examples of time pictures and results.

Time Picture

Result

Description

HH:mm:SS

08:20:00

Time displayed on 24-hour clock.

HH:mm:SS

16:40:00

Time displayed on 24-hour clock.

HH:mm PM

8:20 pm

Time displayed on 12-hour clock.

HH:mm PM

4:40 pm

Time displayed on 12-hour clock.

HH-mm-SS

16-40-00

Example of the minus sign (-) as the time separator.

Custom Functions

A function is a procedure that is built within the iWay Transformer graphical user interface. It produces the required output based on calculation upon, or manipulation of, input data. You can apply a function to produce the output value for a specific node using the Mapping Builder.

In addition to the set of predefined functions discussed in Predefined Functions, iWay Transformer enables you to implement your own custom functions in Java, according to the format specified in this chapter.

You can integrate custom functions into iWay Transformer and make them available for use in your transformations at run time or design time.