Synon built-in functions specify low level operations that you can use within the user points in action diagrams to implement a specific field manipulation or to control an action within the action diagram.
Follow these steps to insert a built-in function at an action diagram user point.
1. Enter IAF next to the location in the action diagram where you want to insert the function. The Edit Action - Function Name window displays.
° Leave the Function File option blank to default to the *Built in functions file
° Enter ? for the Function option and press Enter to display a list of the built-in functions. Alternatively, you can enter the name of the built-in function.
2. Select the built-in function you want. The Edit Action - Function Name window displays. Press Enter to display the Edit Action - Function Details window and enter parameters for the built-in function you selected.
3. Press Enter to continue editing the Action Diagram
Each of the built-in functions are listed alphabetically and described on the following pages.
Add
The *ADD built-in function specifies an arithmetic addition on two operands. There are three parameters for this function type:
· Two input parameters which are the two operands.
· One output parameter which is the *Result field containing the result of the addition.
All three parameters must be a numeric field type such as PRICE or QUANTITY.
Synon/2E implements the *ADD built-in function as an ADD statement for all generators.
> USER: Process detail record
: - -
: WRK. Cost = RCD. Cost + RCD. Tax <<<
’- -
Commit
The *COMMIT built-in function allows you to add your own commit points to a program that is executing under OS/400 commitment control.
Commitment control is a method of grouping database file operations that allow the processing of a database change to be either fully processed (COMMIT) or fully removed (ROLLBACK).
There are no parameters for this built-in function.
Synon implements the *COMMIT built-in function as an RPG COMMIT statement, and as a COBOL COMMIT statement.
Compute
The *COMPUTE built-in function allows you to define a complex arithmetic expression using the following mathematical operators on a single compute expression line.
There is one output parameter, the *Result field of the object type FLD, associated with this function type. It contains the result of the computation expression.
To define a compute expression: Enter the built-in function *COMPUTE or press F7 on the Edit Action Function Details panel to convert an existing arithmetic built-in function to a compute expression. This action causes the Edit Action - Compute Expression panel to display.
By default, intermediate results for each operation are contained in *Synon (17,7) Work fields.
Concatenation
The *CONCAT built-in function provides the means of joining together or concatenating two discrete strings of data into a single string.
Convert Variable
The *CVTVAR built-in function specifies that the value of one Synon field is to be moved to another field of a different type; that is, the two fields do not have to be of the same domain.
Synon converts the field values according to the assignment rules of the HLL language in which you create the function.
An example of the use of this function might be to move a numeric code, stored in a CDE field, into a NBR field.
You can also use the *CVTVAR built-in function with the ELM context to move data between a field and a data structure.
In Synon, a data structure is equivalent to a single element array.
This provides a method for decomposition or (re)composition of field data in a single operation.
For example, you can use this technique to compose a complex data string into a single parameter required by a system API (Application Interface Program) or a third party application. Conversely, you can use this technique to decompose and recompose a telephone number or postal code.
There are two parameters associated with the *CVTVAR function type:
· One input parameter (*FACTOR2). The field of any attribute or domain that is to be moved.
· One output parameter. The *Result field, also of any attribute or domain, into which the field is to be moved.
By default, Synon implements the *CVTVAR built-in function as an RPG MOVEL statement when moving from a numeric field into an alphanumeric field.
Synon uses an RPG MOVE statement when moving from an alphanumeric field into a numeric field.
Synon implements the *CVTVAR function as a COBOL MOVE statement.
If the *Result field is longer than the moved field, the result field is blanked out or converted to zeroes prior to the move.
Any excess characters are converted to blanks or zeros.
Example 1
This example shows how to move a number into a code field.
Example 2
This example shows how to decompose a field (Customer postal code) into a structure defined by an array.
Divide
The *DIV built-in function specifies an arithmetic division of one field by another. You can specify the shipped field *Rounded to determine whether the result of the division will be half-adjusted or not; Synon provides two conditions for this purpose.
There are four parameters for this function type:
· Three input parameters which are the dividend (*FACTOR1), the divisor (*FACTOR2), and the *Rounded field.
· One output parameter which is the *Result field containing the result of the division.
*FACTOR1, *FACTOR2, and the *Result field must all be numeric field types.
Synon implements the *DIV built-in function as an RPG DIV statement and as a COBOL DIVIDE statement.
Example
> USER: Process detail record
: - -
: CTL. Average value = WRK.Total val / WRK. Total no. <<<
’ - -
Divide With Remainder
The *DIV WITH REMAINDER built-in function specifies an arithmetic division of two fields with the remainder being stored in an additional field. There are four parameters for this function type:
· Two input parameters which are the dividend (*FACTOR1) and the divisor (*FACTOR2).
· Two output parameters which are the *Remainder field and the *Result field containing the result of the division.
All parameters must be numeric field types.
Exit Program
The *EXIT PROGRAM built-in function specifies an exit from a program.
The only parameter for this built-in function is the *Return code.
You can use the *Return code parameter to inform the calling program of the circumstances under which the program was exited. Synon supplies the *Return code field from the PGM context as an input parameter, by default.
You can also supply alternate conditions to the *Return code field, other than those supplied by default, such as *Record does not exist.
Synon implements the *EXIT PROGRAM built-in function as a call to a Synon supplied exit subroutine, ZYEXPG.
This issues an *EXIT PROGRAM in COBOL or in RPG. If closedown program is specified, RPG will also set on the LR indicator.
Example:
> Fast exit <<<
-CASE: <<<
| -CTL. *CMD key is CF13 <<<
| *Exit program - return code CND. *User QUIT request <<<
-ENDCASE <<<
Modulo
The *MODULO built-in function specifies the remainder of a division of two fields.
The *MODULO function provides more control over the remainder precision and is a single value field as opposed to the *DIV With Remainder, which returns two values.
This allows this function to be used in *COMPUTE functions.
> USER: Process detail record
:- -
: WRK.MODULO Field = RCD.EXT Price\RCD.Quantity <<<
’- -
Move
The *MOVE built-in function specifies that the value of one field is to be moved to another.
There are two parameters for this function type:
· One input parameter which is the field that is to be moved (*FACTOR2).
· One output parameter which is the *Result field into which the field is moved.
Move All
The *MOVE ALL built-in function specifies that all of the fields from one context are to be moved to another context by name.
You can specify up to four source contexts.
There are potentially five parameters for this function type:
· Up to four input parameters which are the four source contexts that can be moved.
· One output parameter which is the *Result context field. For each field in the result context, Synonexamines the source contexts in the order in which you specify them in the *MOVE ALL action, to determine instances of the same field.
The *MOVE ALL built-in function performs a series of moves from one context to another, mapping fields by name.
Synon implements the *MOVE ALL built-in function as an RPG Z-ADD statement for numeric fields and as a set of MOVEL statements for alphanumeric fields.
In COBOL, Synon implements the *MOVE function as a set of MOVE statements.
Multiply
The *MULT built-in function specifies an arithmetic multiplication of two fields.
The *Rounded field allows you to specify whether the result of the multiplication is to be half-adjusted.
Specify the condition *ROUNDED for rounding; specify the condition * for no rounding.
> USER: Process detail record
:"
: RCD. Line value = RCD. Quantity * RCD. Price <<<
’"