Develop > Tailoring > Form creation > Format Control > Using expressions in Format Control

Using expressions in Format Control

To create Format Control expressions you will need to be familiar with system functions, boolean (logical) fields and the file variable.

Use the following definitions when Creating Format Control expressions:

Primary File:
The file attached to a form. This is referred to as $file in a Format Control record. Additional files are defined as $file1, $file2, etc. in the order of their entry in the secondary files section of the Additional File Queries screen of the Format Control record.

Semicolon:
Semicolons(;) separate statements to allow them to be entered on one line.

Variable:
A value that resides in memory only, rather than in a database record. Variable names always start with $. To ensure that a variable contains the proper value, initialize it in the Initializations Section of the Format Control record.

Statements:
Service Manager supports some C-like statements.

  • if then else
  • do while
  • for do

Format Control system functions

Many of the Service Manager system functions are used to create expressions in Format Control. The following is a list of the most commonly used functions:

Function Description
denull() Compresses an array by deleting all trailing NULL entries and returns the compressed array.
index() Returns the index or position number for a specific element value in an array or character in a string. If the target value is not in the array or string, it returns 0 (zero).
lng() Returns the number of elements in an array or structure and the number of characters in a string.
nullsub() Replaces a null value with a known value, eliminating the possibility that expressions will return null or unknown results.
operator() Returns the logon id of the current operator.
str() Converts a non–string data type into a string.
substr() Extracts a substring from a string.
tod() Returns the current date and time.
val() Converts a field into a numeric, logical, or date/time value.

Format Control Boolean (logical) fields

In the forms for Additional File Queries, Calculations, Validations, and Subroutines, you will find some or all of the following fields:

Conditional Field Format Control processing area Description
add Additional File Queries, Calculations, Validations, JavaScript Conditional expressions used in this field are evaluated before a record is added.
update Additional File Queries, Calculations, Validations, JavaScript Conditional expressions used in this field are evaluated before a record is updated.
delete Additional File Queries, Calculations, Validations, JavaScript Conditional expressions used in this field are evaluated before a record is deleted.
display Additional File Queries, Calculations, Validations, JavaScript Conditional expressions used in this field are evaluated when a screen/format is displayed or when the Format Control record is used with reports.
initial Additional File Queries, Calculations, Validations, JavaScript Conditional expressions used in this field are evaluated once, before a record is displayed the first time.
before Subroutines This field determines when the Conditional expressions in the add, update, and delete fields are evaluated. If the condition is true, the expression will be evaluated before the record is added, updated, or deleted. If the condition is false, the evaluated after the record is added, updated, or deleted. You cannot use a variable in this field.

These fields must evaluate to true or false only. A value of true (or an expression that evaluates to true) in any of these fields causes the Format Control functions to execute. These functions execute before the edit is performed. If the fields are blank, the calculation or validation are not performed for this table. For example, a value of true in the add field causes Format Control functions to be performed before a record is added. If the other fields (update, delete, display) are blank, the functions are not performed when the record is updated, deleted, or displayed.

Normally, these fields contain true, false, blank, or they can contain a variable that is calculated in the Calculations process before being used in another process. When using either of these methods, use either the short or long version of Format Control to enter an expression that is evaluated to true or false at execution time.

This is an example of an expression that is frequently used:

index ("SysAdmin", $lo.ucapex)>0

This expression searches the user’s capability array in the Operator Record to see if it has SysAdmin capabilities. The function executes if this evaluates to true, indicating that the operator has SysAdmin listed as a capability and therefore is authorized for the function.

Format Control file variable

The current database record (the record the user is opening for modifying) in Format Control is always identified by the variable $file. Elements of the current record being acted upon by Format Control associate with $file by expressions. For example, <field.name > in $file might identify a particular field in the current record to which a Format Control process is attached. The $file variable does NOT reference a file, which may use several forms to input data.

Important: In order for a property to depend on a variable or record field, the variable must be assigned as an input in Format Control.

Turn on menu forms by using Format Control

Applies to User roles: System Administrator

To turn on menu forms using Format Control:

  1. Open Format Control using one of the following options:
    • Click Tailoring > Format Control.
    • Type fc in the Service Manager command line and click Execute command or press Enter.

      Service Manager opens a blank Format Control Maintenance form.

  2. Type login.DEFAULT and then click Search.
  3. Service Manager opens the login default form showing the Main Information screen.
  4. Add $G.show.menu.forms="true" to the end of the Initialization Expressions.

Related topics

Format Control

Service Manager Programming