Return to Navigation

Preparing to Write Equations

This section discusses how to prepare to write equations.

Before you write an equation, decide what information you want the equation to provide. You must know which fields exist in which tables to use an equation. For example, to determine whether all new transfer students who are receiving an FFELP loan have completed the required interview, you must know that a field exists to track the completion of the interview and in which table it is stored.

If you want the equation to select a population of students for a process, define the criteria exactly as well as the steps to make in selecting those students. If you want the equation to provide you with a calculated value such as an award maximum, determine where the value comes from and how it is calculated.

These criteria must be met to write an equation:

  1. A table or view must exist to be named in an equation.

  2. You must have security access to the table or view.

  3. Table security must be turned on for you to access the table or view.

  4. Any table or view that you access must not have a long VAR_CHAR field in it.

Using Equation Keywords

You must write equations using keywords and operands. A keyword is an instruction for the equation to perform. Equation keywords include:

Field or Control

Definition

ASSIGN

Assigns a value to a global or local variable in an equation.

CALL

Calls a subequation or an external routine or an SQL statement. When you CALL something, control returns to the statement after the CALL when the called item finishes. For a subequation, control might not return if that subequation issues a HALT statement. Calls to subequations pass parameters through local and global variables and pass values back through global variables. An equation can call itself. Calls to external routines pass parameters back and forth using global variables. Calls to SQL pass parameters back and forth as well and can be used to get an array of data or update relational tables.

CHOOSE

Can be used with the keywords INSERT, UPDATE; or DELETE, INSERT, UPDATE and DELETE. Use a WHERE clause to select a rowset. If the CHOOSE returns a global variable with the same name or the global variable A-SELECT with a value of TRUE, then that row will remain in the rowset. That is, the CHOOSE equation can be used to further limit the rows deleted.

EXIST

Tests for the existence of a local variable, a global variable, or a table. It returns numeric zero for false and numeric 1 for true. It yields false for a local or global variable that has not been assigned or a table with zero rows selected from a find.

FIND FIRST

Finds the first row in the specified table using the specified key values with relational operators (Equal or Greater-or-Equal) comparing these to either local or global variables. FIND NEXT does not have any key value parameters, but it finds the next row relating to the previously issued FIND FIRST. If a FIND is successful, then references to the table and fields for that FIND are valid and return the corresponding field values.

FIND NEXT

Points to the next occurrence of the row of fields in a FIND table You can set up the equation so that failure to find an occurrence can be handled, for example, by the equation returning to the calling equation or program.

IF

Indicates a conditional statement that must be followed by a THEN keyword and can contain an ELSE or an ELSE IF keyword. It must be terminated by the keyword END IF. It compares one operand against another operand.

LOOP

Causes the equation to repeat the statements between the LOOP and the END LOOP statement in a loop until an EXIT LOOP statement is encountered within that loop, usually within an IF statement.

MESSAGE

Writes a message to the log.

SKIP

Used to make a progam more readable. It enables you to break up the program statements, and it can simplify your IF logic.

TRACE

Writes debugging statements to the log and is used for problem resolution.

See Understanding Equation Engine.

Using Operand Types

Equations employ operand types that identify the type of information contained in the operand that follows it. Type choices differ depending on where the operand type is located in the equation. Options include:

Field or Control

Definition

Table

Table or view name.

Value

Valid values for a field.

SQL

This operand applies only to the CALL statement.

Global

User-defined global variable.

Local

User-defined local variable.

See Understanding Equation Engine.

Using Operators

Equations use operands and operators. Operands are based on the previous type. Operators are entered in the keyword column and can be:

Field or Control

Definition

Arithmetic

(+, —, *, /) Add, Minus or Subtract, Multiply, Divide

Arithmetic operators apply to two expressions and provide an arithmetic result. You can use parentheses to group expressions or to make the equation more readable.

Boolean

(AND, OR, NOT) These are logical operators. You use them within an IF statement. AND is used between two conditions. It indicates that both statements must be met for the selection to be made. For example, A and B must be true for a selection.

OR is used between two conditions. It indicates that only one of the statements must be met for selection to be made. For example, A OR B can be true for a selection.

NOT is used in conjunction with a condition to show that the condition does not exist. For example, NOT <condition>.

Relational

(=, <, <=, >, >=, < >) Equal, Less than, Less than or equal, Greater than, Greater than or equal, Less than or Greater than (for example, not equal). Relational operators compare two expressions and provide a truth value. You can use parentheses to group expressions or to enhance readability.

See Understanding Equation Engine.

Using Variables

Two types of variables are available in the equation engine—local and global. The data is passed to the equation engine by means of the global variable array in a process instance of a copy of the global variables that is defined by the Equation Test Data page or by a calling program. Global variables are visible and are referenced by an equation that is running or called. Local variables are visible only to the currently running equation, but copies of local variables can be passed to called subequations as parameters.

See Understanding Equation Engine.