Numeric Functions

Sterling B2B Integrator Map Editor provides the following numeric functions, which enable you to convert one data type to another.

len

The len function counts and returns the number of characters in a string. For more information about the len function, see len.

Here is an example of the syntax:


integer a;
a = len("hello");

atoi, aton, ntoa

The atoi function converts strings into integers. For more information about the atoi function, see atoi.

The aton function converts strings into real numbers. For more information about the aton function, see aton.

The ntoa function converts real numbers into strings. For more information about the ntoa function, see ntoa.

Here is an example of the syntax:


integer a;
real b;
string[8] s;
     a = atoi("5");
     b = aton("5.5");
     ntoa(5.5, s);

Raise Compliance Error Function (cerror)

The cerror function raises a compliance error. You typically specify this function as an action to be performed if a condition is false. This function is valid on the input side of a map only. There is also an optional third parameter you can supply—a string which is written to the translator report as part of the entry for the compliance error you are raising. For more information about the cerror function, see cerror.

The following example raises compliance error 100 on the FIELDNAME field of the specified instance of the GROUPNAME group:


cerror(100,$GROUPNAME[1][1][1].#FIELDNAME, "Extra error information can be 
supplied here");

Number of Errors Function (numerrors)

The numerrors function returns an integer which contains the current count of errors in the translation report (the count at the time the rule is executed). For more information about the numerrors function, see numerrors.

Remove Field Value Function (empty)

The empty function sets the value of a field in internal storage to null. This function is not the same as setting the value of a field to a zero-length string (" ") or to zero. For more information about the empty function, see empty.

The following example sets the value of the specified instance of the FIELDNAME field to null:


empty($GROUPNAME[1][1][1].#FIELDNAME);

Existence of Data Function (exist)

The exist function returns a nonzero (true) value if there is data in a specified field in internal storage. If there is not data in the specified field, this function returns a zero (false) value. This function is typically used as a part of a condition. For more information about the exist function, see exist.

The following example returns a nonzero value if the condition is true (data is present in the specified instance of the FIELDNAME field). A zero value is returned if the condition is false (no data is present in the specified instance of the FIELDNAME field):


IF exist($GROUPNAME[1][1][1].#FIELDNAME) THEN

Count Function (count)

The count function returns the number of iterations of a group (or repeating record). For more information about the count function, see count.

Note: When a count extended rule is performed on an empty group, the value of -1 is returned from count($GROUPNAME[*]).

The following example returns the total iterations of the GROUPNAME group within the third iteration of the parent group:


count(GROUPNAME[3][*]);

Delete Function (delete)

The delete function deletes the specified occurrence of a repeating record or group. For more information about the delete function, see delete.

Use this syntax:


delete(GROUPNAME[occurrence]);