Phantom fields

A PHANTOM field defines a screen-record field which is not rendered in the layout (it acts as a hidden field).

Syntax

PHANTOM { [table.]column
            | FORMONLY.field-name
               [ TYPE
                  { LIKE [table.]column
                  | data-type [NOT NULL] }
               ]
        } ;

where data-type is one of:

{ CHAR
| DECIMAL [(p[,s])]
| SMALLFLOAT
| REAL
| FLOAT
| MONEY [(p[,s])]
| INTEGER
| SMALLINT
| DATE
| VARCHAR
| TEXT
| BYTE
| INTERVAL interval-qualifier
| DATETIME datetime-qualifier
| BIGINT
| BOOLEAN
}
  1. table is the name or alias of a table, synonym, or view, as declared in the TABLES section.
  2. column is the name of a database column.
  3. field-name is the identifier that will be used in programs to handle the field.
  4. interval-qualifier is an INTERVAL qualification clause such as HOUR(5) TO SECOND.
  5. datetime-qualifier is a DATETIME qualification clause such as DAY TO SECOND.

Usage:

A PHANTOM field defines a form field listed in a screen-record or screen-array, that has no corresponding layout element. It is only used for the screen-record (or screen-array) definition, to bind with program variables used by dialogs, typically to match a given database table definition.

Phantom fields will be used by dialog instructions as regular form fields, but will not be displayed to the end user, and the end user will not be able to enter values for these fields. Data hold by phantom fields is never send to the front-ends: They can be used to store critical data that must not go out of the application server.

Phantom fields can be based on columns defined in a database schema file, or as FORMONLY field.

For example, if you want to implement a screen-array with all the columns of a database table defined in the database schema file, but you don't want to display all the columns in the TABLE container of the LAYOUT section, you must use PHANTOM fields. With the screen-array matching the database table, you can easily write program code to fetch all columns into an array defined with a LIKE clause.

Example (grid-based layout)

Form file:

SCHEMA carstore 
LAYOUT( TEXT = "Vehicles" )
GRID
{
<T t1                                  >
 Num      Name            Price 
[c1      |c2             |c3           ]
[c1      |c2             |c3           ]
[c1      |c2             |c3           ]
}
END
END
TABLES
  vehicle 
END
ATTRIBUTES
  TABLE t1: table1;
  EDIT c1 = vehicle.num;
  EDIT c2 = vehicle.name;
  EDIT c3 = vehicle.price;
  PHANTOM vehicle.available;  -- not used in layout 
END
INSTRUCTIONS
  SCREEN RECORD sr(vehicle.*);
END

Program code:

SCHEMA carstore
...
DEFINE vl DYNAMIC ARRAY OF RECORD LIKE vehicle.*
...
DISPLAY ARRAY vl TO sr.*
...