1 Event after

In this example we prepare a form with 2 event after, one to fill a field after with the name of a previous item entered and other that will control the disponibility of an item and stock itroduced.

1.1 Create the form head

  • Choose action Report
  • Inform the SQL-sentence that will be executed at each iteration
  • The where statement includes the variable item_code introduced by the user at each iteration in the form.
  • In this example the output of the list-report is the warehouse, the location and the current stock.

1.2 Create a group

Create the group before the fields.

In this example we only need one group to include the field item.

1.3 Create the fields of the form

Add 4 fields to the form, the params of the fields are:

1.3.1 Params of field warehouse_code

  • Field of 'group 1' at head group.
  • Code 'warehouse_code' related with the column of the table.
  • Label Warehouse. Just to inform the user that the input field belongs to an warehouse code.
  • Mnemonic 'Warehouse_code'. Show tag in zone scroll.
  • Mode 'Input'. Field not hidden and editable.
  • Type 'char'. Because the related column 'warehouse_code' is a char.
  • Required 'Yes'. Because it's mandatory to introduce an item code in this case.
  • Hide 'No'. Just to make the field input and let the user introduce a value.
  • Spoken 'No'. Not talk.
  • Introducing validation parameters to ensure the introduction of a specific set of values that in this case the user instead of entering a value as warehouse , select from a list of values from the table term_wms_warehouse . To perform validation will fill the box ' help'

1.3.2 Params of field item_location

  • Field of 'group 1' at head group.
  • Code 'item_location' related with the column of the table.
  • Label Location. Just to inform the user that the input field belongs to an location code.
  • Mnemonic location_code. Show tag in zone scroll.
  • Mode Input. Field not hidden and editable.
  • Type 'char'. Because the related column 'item_location' is a char.
  • Required 'Yes'. Because it's mandatory to introduce an item code in this case.
  • Default '0'. Just to add this default value in the filed input.
  • Hide 'No'. Just to make the field input and let the user introduce a value.
  • Spoken 'No'. Not talk.

1.3.3 Params of field item_code

  • Field of 'group 1' at head group.
  • Code 'item_code' related with the column of the table.
  • Label Item. Just to inform the user that the input field belongs to an item code.
  • Mnemonic 'item_code' Show tag in zone scroll.
  • Mode 'Input' Field not hidden and editable.
  • Type 'char'. Because the related column 'item_code' is a char.
  • Required 'Yes'. Because it's mandatory to introduce an item code in this case.
  • Introducing validation parameters to ensure the introduction of a specific set of values that in this case the user instead of entering a value as item , select from a list of values from the table term_wms_item . To perform validation will fill the box ' help'
  • Hide 'No'. Just to make the field input and let the user introduce a value.
  • Spoken 'No' Not talk.
  • Event after. Program that will recive the code of the item and return the name of the item, just to add at form-field 'v_item_name'


The XSQLScript code is:

Copy
<call into='v_item_name'>
    <args>
        <arg>@item_code</arg>
    </args>
<![CDATA[ 
    <xsql-script>
        <args>
            <arg name='p_item_code' type='string'  />
        </args>
        <body>

            <select prefix='m_'>
                <columns>
                    item_name
                </columns>
                <from table='term_wms_item' />
                <where>
                    item_code = <p_item_code />
                </where>
            </select>

            <return><m_item_name /></return>
        </body>
    </xsql-script>

]]>
</call>

1.3.4 Params of field v_item_name

  • Field of 'group 1' at head group.
  • Code 'v_item_name'.
  • Label Description. Just to inform the user the name of the item.
  • Mnemonic 'description_code'. Show tag in zone scroll.
  • Mode 'Display'. Field not hidden and not editable.
  • Type 'char'. .
  • Required 'No'. Because it's display field.
  • Hide 'No'. Just to make the field input and let the user introduce a value.
  • Spoken 'No'. Not talk.

1.3.5 Params of field required stock

  • Field of 'group 1' at head group.
  • Code 'stock' related with the column of the table.
  • Label Stock. Just to inform the user that the input field belongs to an stock number.
  • Mnemonic 'stock_code' Show tag in zone scroll.
  • Mode 'Input' Field not hidden and not editable.
  • Type 'Integer.'
  • Required 'Yes'. Because it's mandatory to introduce an value in this case.
  • Default '0.'Just to add this default value in the filed input.
  • Hide 'No'. Just to make the field input and let the user introduce a value.
  • Spoken 'No' Not talk.
  • Event after'. XSQL-script that will check if exist enought stock


The XSQLScript code is:

Copy
<call>
    <args>
        <arg>@warehouse_code</arg>
        <arg>@item_location</arg>
        <arg>@item_code</arg>
        <arg>@stock</arg>
    </args>
    <![CDATA[ 
    <xsql-script>
        <args>
            <arg name='p_warehouse_code' type='string'  />
            <arg name='p_item_location'  type='string'  />
            <arg name='p_item_code'      type='string'  />
            <arg name='p_stock'          type='integer' />
        </args>
        <body>

            <select prefix='m_'>
                <columns>
                    stock <alias name='curr_stock' />
                </columns>
                <from table='term_wms_stock' />
                <where>
                    warehouse_code = <p_warehouse_code/> AND
                    item_location  = <p_item_location/>  AND
                    item_code = <p_item_code />
                </where>
            </select>
            
            <if>
                <expr><isnull><m_curr_stock/></isnull></expr>
                <then>
                    <set name='m_curr_stock'>0</set>
                </then>
            </if>
            
            <if>
                <expr><gt><p_stock/><m_curr_stock/></gt></expr>
                <then>
                    <exception>NO AVAILABLE STOCK (MAX STOCK:<m_curr_stock/>)</exception>
                </then>
            </if>

        </body>
    </xsql-script>
]]>
</call>

1.4 Execution

Execution at web
First field warehouse with soft-ref to warehouse table Second field location, by default 0 List of available items soft-ref to items table
Stock required and Description of item (display) automatically filled. Input 200 and event after display error message with no available stock. Input 0 and form execution display a list with the stock of the item at warehouses.

2 Helper

In the following example we are going to program which contains a field () that has a helper. That is, the value in the field must be validated against a table ( or query).

If the user input dosen't exist in the destiny table, a list of available values will be displayed.

Code Description
Validate table

Name of table where look at.

Validate column Column of the table to bring at field.
Validate alias Description that appears in list selector of validate column.
Validate condition Where condition to filter values at table.Can use previous fields of form using @ + field_code to perform the condition if necessary.
Auxiliary columns Other columns in table to show in list selector.
Force exists Force exists at table.

In this example we prepare a help field that need to inform a warehouse code of the table term_wms_warehouse.

3 Check validation

In this example we prepare a field with validation, force to introduce a value greater than 0


Param of field:


Code Value Information
Check expression

@v_stock > 0

Reference of own filed @v_stock with the validation condition.
Message incorrect value Value must be greater than 0 Message to show when expression isn't satisfy


Execution at web
Field input with validation Error with the message.

4 SQL Default

4.1 Single column SQL Default

In this example we prepare a field with a default value that is the reuslt of an SQL query with referencs to a previous field

The example form contains 2 fields

  1. Item code (v_codart):

  2. the warehouse code (v_warehouse) :

  3. The stock (v_stock). The default value is calculated using the values of the fields v_codart and v_warehouse:

    Copy
    SELECT  SUM(stock) from term_wms_stock WHERE warehouse_code = '@{v_warehouse}' AND item_code = '@{v_codart}'

4.2 Multiple column SQL Default

When the default value statement returns a ResultSet with multiple columns, the first column in the resultset is interpreted as the default value of the field. The rest of the columns are matched to the other fields of the form.

A multiple column SQL defautl would look like:

Copy
SELECT codart, v_codubi, '0' v_wahehouse 
  FROM xxx 
 WHERE ...

Sometimes a more complex logic is needed to extract the default of a column and the execution of a SPL is required. However, SPLs don't return named values. To overcome this issue we could do the following tick, first define a procedure:

Copy
CREATE PROCEDURE testDefaults(param1 INTEGER, param2 CHAR(5)) RETURNING CHAR(20), CHAR(10), CHAR(5);
    -- some complex logic here...        
    return 'CHAR-20', 'CHAR-10', 'CHAR5';
END PROCEDURE;

And then the SQL default sql statement should make use of a table valued functon clause, such as

Copy
SELECT * FROM TABLE(FUNCTION(testDefaults(0, 'X-9823') )) as x1(v_codart, v_codubi, v_wahehouse);

which would set default values for fields v_codart, v_codubi, v_wahehouse in the form

5 Column with a template

In this example we show how to program custom view for fields when are in history

Our exmple form contains 4 fields:

  1. v_codart: an input field with the flag Hide in historic enabled
  2. v_warehouse: an input field with the flag Hide in historic enabled
  3. v_date: a hidden field with the flag Hide in historic enabled and a default value

    Copy
    SELECT CURRENT FROM systables WHERE tabid =  1
  4. v_stock: an input field with the flag Hide in historic disabled and with an HTML template:

    Copy
    <div class="text-left"><i>@{v_wharehouse} </i>/ <i>@{v_codart}</i>, <b>@{v_date}</b> Stock : @{v_stock}</div>

The resulting form when executed and iterated:

6 Hide condition

This exmaple shows how to programs a warehouse recount form. When the expected stock quantity does not match the measured quantity, then an "Indicidence" field shows.

Our example will contain 4 fields:

  1. v_warehouse: a required input field
  2. v_codart: a required input field
  3. v_stock_expected: a display-only field with a default value. This field will contain the expected amount of stock for the item in the warehouse
  4. v_stock: an input field . The user enters the actual amount of stock
  5. v_incidence: An input field with a hide condition. It be be hidden when v_stock_expected matches v_stock and visible otherwise. Such a condition can be programmed as:

    Copy
    '@{v_stock_expected}' == '@{v_stock}'

The resulting form:

  • The expected stock equals the actual stock:

  • The expected stock does not matc the actual stock:

    and thefore the field Report incidence becomes visible:

7 Exit input

In this example we will demonstrate the use of the Exit input flag.

this flag allows us the interrumpt the execution of the form and exit based on a condition. Exit input will trigger an exit of the form only if the field is visible, that is, it won't act if the field is hidden because of a hide condition

Our example is almost identicat as the previous example:

  1. v_warehouse: a required input field
  2. v_codart: a required input field
  3. v_stock_expected: a display-only field with a default value. This field will contain the expected amount of stock for the item in the warehouse
  4. v_stock: an input field . The user enters the actual amount of stock
  5. v_exit: An display field with a hide condition and the flag Exit input enabled. It will be hidden when v_stock_expected does not macht v_stock and visible otherwise. That means, that when the stock amounts are the same the field will be visible and therefor the program will exit to the menu.

8 HTML in display

In this example we prepare a display field with HTML code

The field v_display2 must be a Display field and must be of type character. For instance, the following example would increase the text size and the color:

Copy
<b>HELLO</b><span style="color:#AA1122;font-size:22px;"> WORLD</span>


Execution at web

9 Async event after

TO DO

This section is incomplete and will be concluded as soon as possible.