Views

This function is used to create and modify views by describing their characteristics in the folder data dictionary. You can create views in tables in different folders.

Validating its description allows the view to be created in the database, or its characteristics to be modified.

A view will then be read-only. Programming with a view is similar to programming with a table. The view will have its own class [F]. The following instructions are available for views:

  • (Local) File,
  • Close (local) File,
  • Filter,
  • For ... Next,
  • Read,
  • Columns,
  • Link.

A view can be accessed using Crystal Reports and the formula editor.

Restoring or validating a table clears views based on that table. During restore, views and triggers are automatically regenerated by the supervisor. However, after you force the validation of a table, you must launch the validation of the views of the current folder and the other folders that apply to that table.

For example, a view allows you to:

  • Avoid having to explicitly open a table from another folder, for example, for historical records. A view is created for each table that is not archived. In this way, the inquiry functions and reports work equally in the main folder and the archived folder.
  • Develop reports that access data from multiple folders.
  • Access SQL functions that could not be previously accessed: union, group by, SQL functions.

Prerequisites

SEEREFERTTO See the Implementation documentation.

Screen management

A view is defined in 3 tabs:

  • the query tab,
  • the fields tab,
  • the sort keys tab.

Header

Query tab

Use this tab to write the query.

The query must be written at least in the language of the folder current database. On the other hand, for any delivered standard view, a script is delivered for each database. When the view is validated, the *.viw file is created with the script adapted to the database of the current folder. It is created in the FIL directory on the data server.

In the query, if you want to specify fields that are linked to an activity code, as well as a folder name, it is recommended to use a formula. It is indeed advised not to “hard code” the folder in the query. This will allow operation in another folder where this view could have been copied.

Example: Activity code sized from 1 to 3 for the LIEN field, and formula on file:

Select CLENUM1_0, CLENUM2_0, LIEN_0

%string$(find(func AFNC.ACTIV("ZZM"),2,3)<>0,", LIEN_1")%

%string$(find(func AFNC.ACTIV("ZZM"),3)<>0,", LIEN_2")%

From %nomap+"."%ZZMB

For more information about the query writing rules, you can read the field help.

Fields tab

This tab is used to define all the fields in the view in a drop-down table. The description of the fields in the query and in this tab (number, order, and type of the fields) must be fully compatible. This control is performed upon view validation. These fields can exist in the table dictionary. This is nevertheless not obligatory.

Keys tab

This tab is used to define the set of keys available for an Order By code on the view.

Warning: There is no index creation for the view.

Specific buttons

Option/.srf source

This option is used to view the *.srf file corresponding to the current table in the current application.

This option is particularly interesting in the event of the FIL directory of a server for which you do not have rights.

Option/.viw source

This option is used to view the *.viw file containing the source of the view in the current application.

This option is particularly interesting in the event of the FIL directory of a server for which you do not have rights.

Error messages

Other than the generic messages, the following error messages can appear when entering data:

A table with the same name already exists

You cannot create a view whose name is already given to a table. In effect, the system creates a *.srf file and a *.fde file.

The file size is too large

Limited size of the configuration file.

Data type not managed

You cannot create a view with a field with type AXX (translatable text).

Incorrect length

The length is incorrect against the internal field type.

  • Description: The length must be ≤ 30.
  • Short integer: The length must be ≤ 4.
  • Long integer: The length must be ≤ 8.
  • Decimal: Integer part + decimal part ≤ 32.
  • Alphanumeric: The length must be ≤ 250.
  • Blob, clob: The length must be ≤ 20.

Incorrect option

You tried to enter an option that does not exist.

Option incompatible with format x (data type y)

When specifying a format on an alpha data type, you must not use the A and # options.

Abbreviation already exists

This warning message appears if you try to enter an abbreviation on a view that already exists for another view or table. It is recommended to use unique abbreviations.

Notes

A view is created in the folder database where it is installed at the time of validation. All Sage X3 functions used in such a view (with the %formula% syntax) are valued on view validation and transferred to the database as constants.

When a folder is created or validated, the operation that will validate the views is triggered from the X3 folder which is different from the one where the view is installed. You should therefore take the following precautions:

  • In formulas, avoid using functions (func syntax) to calculate constants that will then be inserted when the view is created, unless you are absolutely certain that the function in question is available in all folders (including the X3 folder) and generates the same value.
  • Prefer the declaration of tables or views without specifying in which folder they are located (and in particular not nomap or adxmother whose definition may vary depending on the folder).

SEEWARNING If these precautions cannot be followed, you must manually revalidate the problematic views in the folder itself after the folder validation operations.

Tables used

SEEREFERTTO See the Implementation documentation.