Query tool
Use this function to create inquiry screens that display the results of database requests. It operates by temporarily extracting data into a table and then running a query on that table. The query can then be done at multiple levels of detail, defined by successive page breaks.
The structure of this temporary table enables each user to keep the results of their last query, unless it is a shared query. Using this functionality involves 3 different phases:
-
Defining the query using this function.
- Executing the query by clicking the Run button.
-
Reviewing the query results if the query has already been executed.
To define a query, you need to provide:
-
A list of fields from database tables.
-
Expressions that can be applied to these fields.
-
Constants and additional expressions.
Joins between tables are automatically determined from the data dictionary, but you can explicitly define them in the Advanced tab.
Additionally, 2 complementary functions are available:
-
The Graphical query function (GESALT), offering similar features through a graphical interface.
-
The SQL query function (GESALQ), which uses the same inquiry screens but is designed for creating SQL-based queries.
Prerequisites
Refer to the implementation documentation.
Screen management
The screen is defined in 5 tabs:
You can edit your query across multiple tabs, but only the first one is mandatory.
Header
The header provides information to identify the query, along with general configuration settings.
General information
| Code (COD) |
|
This code is used to identify a request. |
| Description (INTIT) |
|
Use this field to assign a description to each record. |
| Short description (INTITSHO) |
|
This title, which describes the record, is used in some screens or records when there is not enough space to display the long title. |
| Factory owner (AFACTORYOWN) |
| Indicates if the query is delivered by Sage. You cannot modify factory queries. |
| Active (ENAFLG) |
|
Select this checkbox to activate the current record. Inactive records keep their content and configuration but cannot be used by recalling their code:
Authorizations for a given function can restrict the creation of an active record. In this case, the checkbox is disabled by default. It can only be modified by an authorized user or through a signature workflow. |
Characteristics
| Representation (REPGRA) |
|
This indicator defines how data will be displayed on the screen. The available display modes are as follows:
|
| Default display or graphical position (OPTGRA) |
|
This setting defines how the graphical representation is positioned relative to the grid when the data display mode allows both formats.
|
| Activity code (CODACT) |
|
An activity code is used to:
|
| Module (MODULE) |
| Select the module to which your query belongs. |
Fields tab
This tab allows you to define the information to be printed using a grid layout. Within this grid, you specify:
-
The database table where the data originates
-
The fields or expressions to extract
-
The criteria for totals and breaks
Based on the information provided in the grid, the query designer automatically generates a query, using default join conditions between related tables.
In straightforward cases, this setup is sufficient, and there is no need to configure the following tab.
| Table (TBL) |
|
This field specifies the name of the table from which the data will be extracted. An entry is required, even if you intend to display an expression that combines fields from multiple tables or that is not directly tied to any table. In such cases, simply enter the code of one of the tables involved in the query. This means that the first row of a user-defined inquiry cannot consist solely of such an expression. |
| Field (FLD) |
|
This field represents the code of the data field to be displayed in the inquiry. Your selection here depends on the specific table chosen in the previous field, as only fields belonging to that table are available. If you leave the field blank, you will need to enter an expression in the next column. If the field is indexed, meaning it has multiple occurrences, such as the CCE field in the BPCUSTOMER table, you need to reference a specific index. For example, use CCE(2) to refer to the second occurrence. Indexes start at 1, not 0. So, if your system defines 4 dimensions, valid entries range from CCE(1) to CCE(4). Entries like CCE(0) or CCE(5) are invalid and will result in an error.
|
| Description (INTITLIG) |
|
This field defines the title of the column as it will display when the request is executed. By default, if a field from a table is selected, its title (stored in the data dictionary) is automatically proposed. In a multilingual environment, this title is displayed in the user's connection language, as dictionary texts are maintained in all supported languages. If you modify the title or use a calculated expression without a predefined translation, you can still provide translations manually. For translatable fields like this one, you can enter a description in a language other than the current connection language by selecting Online translations from the Actions menu. For further information, refer to the Online translation of descriptions documentation. |
| Expression (CLC) |
|
You can enter an expression written in Adonix language, typically with the help of the formula editor if needed. An expression must be provided, if no field name has been specified, on the inquiry line. The expression can include:
Expressions are limited to 200 characters. For complex expressions, you might need to use abbreviated syntax to stay within this limit. For example, instead of writing [F:SOH], you can use the shorter [SOH] form to reference the table. |
| Type (CODTYP) |
|
This field defines the data type, which determines how the data will be displayed. When referencing a field, the associated data type is proposed by default, but you can modify it if needed. When using an expression, the data type must be explicitly specified. It can be a generic type such as:
For alphanumeric strings, the maximum length is defined in the Length field that follows. For local menus, both the display length and the local menu number are specified. If the selected data type is linked to an object, a tunnel to the object’s management screen is available during the inquiry execution. |
| Length (LNG) |
|
Define here the length of a field that uses a generic data type where the length is not fixed. This applies particularly to alphanumeric and decimal types. |
| Menu (NOLIB) |
|
Defines the local menu number associated with the field on this line. A field of type local menu corresponds to a predefined list of choices, identified by a number between 1 and 255. Each number refers to a title in a table called local menu, stored in the APLSTD messages table. When entering or displaying data, the options can display in the user interface as:
The main advantage of this field type is that the list of choices displays in the user’s connection language. Each local menu number defines a specific list of options. For example, local menu 1 corresponds to the No / Yes choice in this order. In this particular case, the user interface can also be a checkbox. |
| Range (STREND) |
|
When you run a user-defined inquiry, you often need to refine the data selection criteria so that you see only the information you need, rather than all available data. To do this, simply enter Yes for the fields you want to use as filters. When the inquiry runs, a criteria entry window displays. In this window, you can specify starting and ending values for the selected fields (or leave them blank). Because these criteria are linked to known fields, the selection window guides you in choosing valid values. It is recommended to include at least one field in each inquiry with the range set to Yes. This ensures that the Execute inquiries function (EXEALH) can initialize and refresh the data displayed on the screen.
|
| Total (CUM) |
|
This option can only be assigned if the line contains a numeric data element. When set to Yes, it enables rolling up totals to higher-level groups in the inquiry display. This works well for raw data (such as sales revenue), but it is not appropriate for calculated values such as percentages (for example, gross margins). In these cases, the totals are not recalculated for the summary lines. Instead, they display an uninterpretable sum.
|
| Sort (SRT) |
|
This field determines the sort order of the data elements displayed in the inquiry. The sorting follows the order in which the fields appear in this table. You can choose to sort the data in ascending or descending order. You need to set this field to a value other than No to enable data grouping. Without grouping, the data remains unorganized. However, in a simple inquiry with no grouping (and no roll-up capability), you can still sort the data without grouping it. Example: A basic listing of sales orders. |
| Group (GRP) |
|
Use this field to create a break level. When set to Yes, it creates a grouping based on the current field. You can then group all subsequent fields under this break, and any totals (if applicable) will be displayed at the group level. You need to define a sort order (ascending or descending) for the current line before setting this option. For example, if a list of users is defined by profile, you can use a break by profile to group on a single line all the users linked to a profile. Totals related to the group (such as the number of users, if there is a field with the 1 value that is accumulated) will also display. |
| Level (NIV) |
|
Define the level of detail for displaying information.
Default behavior:
You can modify this level to display a value at a different aggregation level. Example: If you sort and group by user code and want to display the user name in the next column, the name should appear at the same level as the code, not only at the most detailed level. |
| Tunnel (TUN) |
| Set to Yes to enable tunneling to the corresponding field. |
| Graph type (GRA) |
|
You can only modify this field if the representation mode in the header is not set to Character. It specifies how the field is used in the graphical representation. Possible values:
|
| Representation (REP) |
|
You can only edit this field:
Used to manage graph combinations when the selected graph type (defined in the graphical parameters) supports multiple series, even of different types. If the graph type does not allow multiple series, this setting is ignored. Available combinations include:
The rule is as follows :
|
| First default (VALDEB) |
|
Enter the setup value as a calculated expression that can include variables related to the launch context. If the setup requires a start-end range, you need to enter two values. The first value goes in this field. |
| Last default (VALFIN) |
|
If the setup in the previous field requires a start-end range, you need to enter two values. The second value goes in this field. |
Advanced tab
This tab is optional. It allows you to define:
-
Presentation criteria (such as page numbering and report layout)
-
Additional selection criteria
-
Specific join conditions
Join conditions are useful in two cases:
-
When the automatic join algorithm fails.
-
This is easy to identify because an error message displays when validating the query.
-
Often, adding a link to one of the tables not described in the dictionary resolves the issue. Other links remain automatic.
-
-
When the automatic join does not match the expected logic.
-
In complex cases, multiple links can exist between tables, but the algorithm stops at the first one it finds.
-
To verify the join, use the Info > Links action button, which displays the details of the detected links.
-
First block
| Number of lines (NBRLIG) |
|
Specify the maximum number of lines returned by the query. The default value is 0. The maximum number is 100. |
| Maximum lines (MAXLIG) |
|
Specify the maximum number of lines to return. This corresponds to the query parameter maxrows, which stops the search once the specified number of rows meeting the conditions is found in the database. These rows are then sorted, but the database does not guarantee that the retrieved rows are the first N in the final sort order. This parameter is an optimization to reduce database load. |
| No. of fixed columns (NBRCOL) |
|
Use this field to fix the first X columns of a grid when horizontal paging is enabled. |
| Maximum times (MAXTIM) |
|
Specify the maximum execution time for the search in seconds. If this time limit is reached, the search stops automatically. This helps avoid long wait times, especially when setting up a new query. Unlike the maximum number of lines, this setting is not sent to the database. The maximum time limit can still be exceeded if the inquiry takes too long to process.
|
| Report (RPT) |
|
Define the report code associated with the File / List function from the query inquiry. If no report code is specified, the ALISTE report is used, which applies a standard page format. You can duplicate this generic report and adjust the page format to create a custom report tailored to the inquiry. The report code entered here can also be linked to a set of print codes using the dedicated function. |
Selections grid
| Selection criteria (SEL) |
|
Define selection criteria as logical expressions applied to table fields. These expressions can include constants, functions, and operators. Only rows that meet these conditions will be extracted. To simplify writing these expressions, you can use the formula editor. |
Links grid
| Link expression (LNK) |
|
Use this field to define links that are not specified in the dictionary or that should take priority. The link structure must match the key of the target table and include as many fields (separated by semicolons) as there are key parts. Syntax: [F:ABV1]CLE=expression1 ; expression2..., where:
From the database perspective, this syntax defines left outer joins. To create a strict join (which can improve performance), add a tilde (~) before the key: [F:ABV1]CLE=expression1 ; expression2... |
Access tab
Use this tab to define the access conditions to the query and the extracted data.
| Query type (ALLUSR) |
|
This field controls how the query behaves in inquiry mode. There are three possible modes:
|
| Group (GRP) |
|
Makes a classification criterion available for requests. |
| Access code (ACS) |
|
Defines access control for the current record and query execution.
|
| Object (OBJLNK) |
|
This field determines the authorization filters applied when building the query. These filters are by site, by role, and by access code. Filtering principles:
The table on which the filters are applied must be included in the generated query. This refers to the table containing:
This table is not necessarily the main table in the query. Example: A query on document lines can still be filtered based on authorizations defined in the document header table. These filters are applied only when the query is executed, not when it is later viewed. This distinction matters if the query is shared or if a user’s site-specific filters have changed between the time the query was run and the time it is accessed.
|
| Function (FCTLNK) |
|
This field links query access authorizations to the permissions granted for the associated function. When a user opens a query, the system checks whether they are authorized to use the linked function. This is done for at least one site, if the function’s authorization is site-based. This check is performed only when the query is not shared. If the query is shared, the permissions of the person who executed the query apply and are inherited by all users who have viewing rights. Therefore, extra caution is required when defining authorizations for shared queries, especially when they involve sensitive data. These permissions are managed using the access code available in this tab. |
Graph tab
You can edit this tab only if a graphical representation is available for the query. It allows you to define how the data displays in the chart.
Graph
| Type (TYPGRA) |
|
You can use this field when the grid contains multiple numeric values that can be displayed graphically. It supports two options:
|
| Representation (FSHGRA) |
|
When multiple series are displayed in a graph, provided they share the same presentation style and are not of the sector type, you can define how their values are combined by selecting one of the following options
|
| Default graph (DEFGRA) |
|
This field defines the type of graphical representation used to display the data. Options include Bars, Lines, Area, or Sectors. An image displays based on the selected option. If only one data series is available, the default representation is determined by this parameter. If multiple series are present, you can mix presentation modes (for example, one series as bars, another as lines). In this case, each series uses the value specified in the Representation field in the grid:
When only one series is displayed, a graph type selector is available, allowing the user to choose a different presentation mode. |
| (IMAG) |
|
Visual representation of the previously entered information. |
Specific buttons
-
Validate
This button generates a processing associated with the request as well as the dedicated inquiry screen. This validation is linked to the saving of a record, but it is possible to independently launch it if for example a request has been transferred by copy.
-
Copy
This button is used to copy the record definition from or to another folder.
The following fields are included on the window opened through this button:
Block 1
(OBJET)
(CLES)
Block 2
From folder (DOSORG)
Use this field to define the folder from which the record will be copied. The possible syntaxes are described in the dedicated appendix.
All folders (TOUDOS)
Use this option to copy the record to all the folders defined in the dictionary (ADOSSIER table of the current solution).
To folder (DOSDES)
Use this field to define the folder to which the record will be copied. The possible syntaxes are described in the dedicated appendix.
-
Run
Use this button to execute the current request. The execution triggers the update of a temporary table and links to the request display function, which is used to view the detail of the movements, but also to successively aggregate at the different break levels defined.
-
Display
Select this button to display your query's results in a grid.
Menu bar
Information/Links
This function defines the logic for navigating through the tables to be used, based on the selected tables and the implicit links from the dictionary.
An information box displays the name of the main table and the list of links used to access the other tables specified in the request.
Error messages
Other than the generic messages, the following error messages can appear when entering data:
There must be at least one line.
There are no lines in the requests grid.
Too many sort criteria
The request exceeds the allowed limits. The number of sort criteria cannot exceed 8.
Too many ranges
The request exceeds the allowed limits. The number of ranges cannot exceed 10.
Too many totals
The request exceeds the allowed limits. The number of totals cannot exceed 10.
Table not defined
A calculation formula was used in an expression that references fields from a table that is not linked.
xxx: Non-existent table
The table does not exist in the dictionary.
yyy: Non-existent field
The field does not exist in the dictionary.
Incorrect index
A field is indexed with a value that exceeds its dimension.
Impossible links
The links between the tables could not be established from the dictionary. This can indicate an error in the request, or you might need to explicitly define the links in detail under the Advanced tab.
Tables used
Refer to the implementation documentation.