Extended Rules Used with SWIFT Maps
The following new extended rules are used with SWIFT maps, though they can also be used with any other data format:
- cerror
- occurrencetotal
- resetoccurrencetotal
- sum
- sumtotal
See Alphabetic Language Reference for information on all the available extended rules.
cerror
The cerror function raises a compliance error in the translation report. This extended rule has been updated for use with SWIFTNet FIN to allow it to be called with only a code and description string (instead of code, field reference, option description string). 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.
cerror(code,$GROUPNAME[0][1][1].#FIELDNAME, "Optional string with error information
can be supplied here");
Example1: An example of this function follows:
resetoccurrencetotal(%myRec);
//This returns the current sum of the field debitAmount (on which the sum function
//was used, and returns the current sum of that field into the debitTotal field.
cerror(code, "String with error information supplied here");
cerror(100, “Number not valid”);
//This raises compliance error 100 with error text “Number not valid” in the
//translator report.
occurrencetotal
The occurrencetotal function allows an extended rule to check the total occurrences of a particular record thus far in the processing (this is a running total of the number of times the record has occurred at the specific point in time that the occurrencetotal rule is called). This function returns an integer value containing the number of occurrences of the specified record that have been processed.
occurrencetotal(%recordname);
If occurrencetotal(%myRec) > 2 then
//This specifies that if the myRec record has occurred (been processed) more than
//twice, then the logic that follows this function will be performed by the
//translator.
resetoccurrencetotal
The reset occurrencetotal function allows you to reset OccurrenceTotal to zero so you can determine if a particular block occurred in the current iteration of a group, as opposed to learning how many times the translator has encountered a specified block in the course of processing the data on either the input or output side of a map.
resetoccurrencetotal(%recordname);
The syntax %recordname indicates a record that is referenced by name
An example of this function follows:
resetoccurrencetotal(%myRec);
//This specifies that the Occurrencetotal for the myRec record will be set to zero.
sum
The sum function is used (along with the sumtotal function) to maintain and validate the sum of a specified numeric field. This function is called with no parameters in the extended rule of the field for which you need to keep a running sum. Optionally, you can add a string parameter—the first character in the string indicates whether the value of the field is treated as a negative number before it is added to the running sum of the field. If the first character of the string begins with N or n, the value from the field is treated as a negative and added to the sumtotal.
sum();
An example of this function follows:
sum();
//This maintains a running sum for the field on which the extended rule is called.
sum(“nString”);
An example of this function follows:
sum(“n”);
//This adds the value of the field as a negative number to the sumtotal to maintains
//a running sum for the field on which the extended rule is called.
sumtotal
The sumtotal function is used (along with the sum function) to maintain and validate the sum of a specified numeric field. This function returns a real numeric value and is used to obtain the current sum of a specified field wherever the value is needed. For example, if want to verify the sum of a specific field (debitAmount), add the sum function to the extended rule of this field. Then, to access this running sum in a later field (debitTotal), use the sumtotal function on the debitTotal field.
sumtotal(#fieldname);
An example of this function follows:
sumtotal(debitTotal);
//This returns the current sum of the field debitAmount (on which the sum function
//was used, and returns the current sum of that field into the debitTotal field.